You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
361 lines
903 KiB
361 lines
903 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[241,7],{"+NIl":function(xt,at,re){(function(ne){ne(re("VrN/"))})(function(ne){"use strict";ne.defineMode("stex",function($,_){"use strict";function V(L,w){L.cmdState.push(w)}function N(L){return L.cmdState.length>0?L.cmdState[L.cmdState.length-1]:null}function M(L){var w=L.cmdState.pop();w&&w.closeBracket()}function H(L){for(var w=L.cmdState,x=w.length-1;x>=0;x--){var u=w[x];if(u.name=="DEFAULT")continue;return u}return{styleIdentifier:function(){return null}}}function F(L,w,x){return function(){this.name=L,this.bracketNo=0,this.style=w,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 P={};P.importmodule=F("importmodule","tag",["string","builtin"]),P.documentclass=F("documentclass","tag",["","atom"]),P.usepackage=F("usepackage","tag",["atom"]),P.begin=F("begin","tag",["atom"]),P.end=F("end","tag",["atom"]),P.label=F("label","tag",["atom"]),P.ref=F("ref","tag",["atom"]),P.eqref=F("eqref","tag",["atom"]),P.cite=F("cite","tag",["atom"]),P.bibitem=F("bibitem","tag",["atom"]),P.Bibitem=F("Bibitem","tag",["atom"]),P.RBibitem=F("RBibitem","tag",["atom"]),P.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function O(L,w){L.f=w}function b(L,w){var x;if(L.match(/^\\[a-zA-Z@]+/)){var u=L.current().slice(1);return x=P.hasOwnProperty(u)?P[u]:P.DEFAULT,x=new x,V(w,x),O(w,D),x.style}if(L.match(/^\\[$&%#{}_]/))return"tag";if(L.match(/^\\[,;!\/\\]/))return"tag";if(L.match("\\["))return O(w,function(l,h){return A(l,h,"\\]")}),"keyword";if(L.match("\\("))return O(w,function(l,h){return A(l,h,"\\)")}),"keyword";if(L.match("$$"))return O(w,function(l,h){return A(l,h,"$$")}),"keyword";if(L.match("$"))return O(w,function(l,h){return A(l,h,"$")}),"keyword";var a=L.next();if(a=="%")return L.skipToEnd(),"comment";if(a=="}"||a=="]"){if(x=N(w),x)x.closeBracket(a),O(w,D);else return"error";return"bracket"}else return a=="{"||a=="["?(x=P.DEFAULT,x=new x,V(w,x),"bracket"):/\d/.test(a)?(L.eatWhile(/[\w.%]/),"atom"):(L.eatWhile(/[\w\-_]/),x=H(w),x.name=="begin"&&(x.argument=L.current()),x.styleIdentifier())}function A(L,w,x){if(L.eatSpace())return null;if(x&&L.match(x))return O(w,b),"keyword";if(L.match(/^\\[a-zA-Z@]+/))return"tag";if(L.match(/^[a-zA-Z]+/))return"variable-2";if(L.match(/^\\[$&%#{}_]/))return"tag";if(L.match(/^\\[,;!\/]/))return"tag";if(L.match(/^[\^_&]/))return"tag";if(L.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(L.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var u=L.next();return u=="{"||u=="}"||u=="["||u=="]"||u=="("||u==")"?"bracket":u=="%"?(L.skipToEnd(),"comment"):"error"}function D(L,w){var x=L.peek(),u;return x=="{"||x=="["?(u=N(w),u.openBracket(x),L.eat(x),O(w,b),"bracket"):/[ \t\r]/.test(x)?(L.eat(x),null):(O(w,b),M(w),b(L,w))}return{startState:function(){var L=_.inMathMode?function(w,x){return A(w,x)}:b;return{cmdState:[],f:L}},copyState:function(L){return{cmdState:L.cmdState.slice(),f:L.f}},token:function(L,w){return w.f(L,w)},blankLine:function(L){L.f=b,L.cmdState.length=0},lineComment:"%"}}),ne.defineMIME("text/x-stex","stex"),ne.defineMIME("text/x-latex","stex")})},"19Vz":function(xt,at,re){(function(ne){ne(re("VrN/"))})(function(ne){ne.defineOption("placeholder","",function(F,P,O){var b=O&&O!=ne.Init;if(P&&!b)F.on("blur",N),F.on("change",M),F.on("swapDoc",M),ne.on(F.getInputField(),"compositionupdate",F.state.placeholderCompose=function(){V(F)}),M(F);else if(!P&&b){F.off("blur",N),F.off("change",M),F.off("swapDoc",M),ne.off(F.getInputField(),"compositionupdate",F.state.placeholderCompose),$(F);var A=F.getWrapperElement();A.className=A.className.replace(" CodeMirror-empty","")}P&&!F.hasFocus()&&N(F)});function $(F){F.state.placeholder&&(F.state.placeholder.parentNode.removeChild(F.state.placeholder),F.state.placeholder=null)}function _(F){$(F);var P=F.state.placeholder=document.createElement("pre");P.style.cssText="height: 0; overflow: visible",P.style.direction=F.getOption("direction"),P.className="CodeMirror-placeholder CodeMirror-line-like";var O=F.getOption("placeholder");typeof O=="string"&&(O=document.createTextNode(O)),P.appendChild(O),F.display.lineSpace.insertBefore(P,F.display.lineSpace.firstChild)}function V(F){setTimeout(function(){var P=!1,O=F.getInputField();O.nodeName=="TEXTAREA"?P=!O.value:F.lineCount()==1&&(P=!/[^\u200b]/.test(O.querySelector(".CodeMirror-line").textContent)),P?_(F):$(F)},20)}function N(F){H(F)&&_(F)}function M(F){var P=F.getWrapperElement(),O=H(F);P.className=P.className.replace(" CodeMirror-empty","")+(O?" CodeMirror-empty":""),O?_(F):$(F)}function H(F){return F.lineCount()===1&&F.getLine(0)===""}})},"1eCo":function(xt,at,re){(function(ne){ne(re("VrN/"))})(function(ne){"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};ne.defineMode("xml",function(V,N){var M=V.indentUnit,H={},F=N.htmlMode?$:_;for(var P in F)H[P]=F[P];for(var P in N)H[P]=N[P];var O,b;function A(o,S){function y(G){return S.tokenize=G,G(o,S)}var T=o.next();if(T=="<")return o.eat("!")?o.eat("[")?o.match("CDATA[")?y(w("atom","]]>")):null:o.match("--")?y(w("comment","-->")):o.match("DOCTYPE",!0,!0)?(o.eatWhile(/[\w\._\-]/),y(x(1))):null:o.eat("?")?(o.eatWhile(/[\w\._\-]/),S.tokenize=w("meta","?>"),"meta"):(O=o.eat("/")?"closeTag":"openTag",S.tokenize=D,"tag bracket");if(T=="&"){var I;return o.eat("#")?o.eat("x")?I=o.eatWhile(/[a-fA-F\d]/)&&o.eat(";"):I=o.eatWhile(/[\d]/)&&o.eat(";"):I=o.eatWhile(/[\w\.\-:]/)&&o.eat(";"),I?"atom":"error"}else return o.eatWhile(/[^&<]/),null}A.isInText=!0;function D(o,S){var y=o.next();if(y==">"||y=="/"&&o.eat(">"))return S.tokenize=A,O=y==">"?"endTag":"selfcloseTag","tag bracket";if(y=="=")return O="equals",null;if(y=="<"){S.tokenize=A,S.state=h,S.tagName=S.tagStart=null;var T=S.tokenize(o,S);return T?T+" tag error":"tag error"}else return/[\'\"]/.test(y)?(S.tokenize=L(y),S.stringStartCol=o.column(),S.tokenize(o,S)):(o.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function L(o){var S=function(y,T){for(;!y.eol();)if(y.next()==o){T.tokenize=D;break}return"string"};return S.isInAttribute=!0,S}function w(o,S){return function(y,T){for(;!y.eol();){if(y.match(S)){T.tokenize=A;break}y.next()}return o}}function x(o){return function(S,y){for(var T;(T=S.next())!=null;){if(T=="<")return y.tokenize=x(o+1),y.tokenize(S,y);if(T==">")if(o==1){y.tokenize=A;break}else return y.tokenize=x(o-1),y.tokenize(S,y)}return"meta"}}function u(o,S,y){this.prev=o.context,this.tagName=S,this.indent=o.indented,this.startOfLine=y,(H.doNotIndent.hasOwnProperty(S)||o.context&&o.context.noIndent)&&(this.noIndent=!0)}function a(o){o.context&&(o.context=o.context.prev)}function l(o,S){for(var y;;){if(!o.context)return;if(y=o.context.tagName,!H.contextGrabbers.hasOwnProperty(y)||!H.contextGrabbers[y].hasOwnProperty(S))return;a(o)}}function h(o,S,y){return o=="openTag"?(y.tagStart=S.column(),C):o=="closeTag"?g:h}function C(o,S,y){return o=="word"?(y.tagName=S.current(),b="tag",v):H.allowMissingTagName&&o=="endTag"?(b="tag bracket",v(o,S,y)):(b="error",C)}function g(o,S,y){if(o=="word"){var T=S.current();return y.context&&y.context.tagName!=T&&H.implicitlyClosed.hasOwnProperty(y.context.tagName)&&a(y),y.context&&y.context.tagName==T||H.matchClosing===!1?(b="tag",m):(b="tag error",k)}else return H.allowMissingTagName&&o=="endTag"?(b="tag bracket",m(o,S,y)):(b="error",k)}function m(o,S,y){return o!="endTag"?(b="error",m):(a(y),h)}function k(o,S,y){return b="error",m(o,S,y)}function v(o,S,y){if(o=="word")return b="attribute",f;if(o=="endTag"||o=="selfcloseTag"){var T=y.tagName,I=y.tagStart;return y.tagName=y.tagStart=null,o=="selfcloseTag"||H.autoSelfClosers.hasOwnProperty(T)?l(y,T):(l(y,T),y.context=new u(y,T,I==y.indented)),h}return b="error",v}function f(o,S,y){return o=="equals"?p:(H.allowMissing||(b="error"),v(o,S,y))}function p(o,S,y){return o=="string"?d:o=="word"&&H.allowUnquoted?(b="string",v):(b="error",v(o,S,y))}function d(o,S,y){return o=="string"?d:v(o,S,y)}return{startState:function(o){var S={tokenize:A,state:h,indented:o||0,tagName:null,tagStart:null,context:null};return o!=null&&(S.baseIndent=o),S},token:function(o,S){if(!S.tagName&&o.sol()&&(S.indented=o.indentation()),o.eatSpace())return null;O=null;var y=S.tokenize(o,S);return(y||O)&&y!="comment"&&(b=null,S.state=S.state(O||y,o,S),b&&(y=b=="error"?y+" error":b)),y},indent:function(o,S,y){var T=o.context;if(o.tokenize.isInAttribute)return o.tagStart==o.indented?o.stringStartCol+1:o.indented+M;if(T&&T.noIndent)return ne.Pass;if(o.tokenize!=D&&o.tokenize!=A)return y?y.match(/^(\s*)/)[0].length:0;if(o.tagName)return H.multilineTagIndentPastTag!==!1?o.tagStart+o.tagName.length+2:o.tagStart+M*(H.multilineTagIndentFactor||1);if(H.alignCDATA&&/<!\[CDATA\[/.test(S))return 0;var I=S&&/^<(\/)?([\w_:\.-]*)/.exec(S);if(I&&I[1])for(;T;)if(T.tagName==I[2]){T=T.prev;break}else if(H.implicitlyClosed.hasOwnProperty(T.tagName))T=T.prev;else break;else if(I)for(;T;){var G=H.contextGrabbers[T.tagName];if(G&&G.hasOwnProperty(I[2]))T=T.prev;else break}for(;T&&T.prev&&!T.startOfLine;)T=T.prev;return T?T.indent+M:o.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:H.htmlMode?"html":"xml",helperType:H.htmlMode?"html":"xml",skipAttribute:function(o){o.state==p&&(o.state=v)},xmlCurrentTag:function(o){return o.tagName?{name:o.tagName,close:o.type=="closeTag"}:null},xmlCurrentContext:function(o){for(var S=[],y=o.context;y;y=y.prev)y.tagName&&S.push(y.tagName);return S.reverse()}}}),ne.defineMIME("text/xml","xml"),ne.defineMIME("application/xml","xml"),ne.mimeModes.hasOwnProperty("text/html")||ne.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"389U":function(xt,at,re){"use strict";re.r(at);var ne=re("+L6B"),$=re("2/Rp"),_=re("oBTY"),V=re("giR+"),N=re("fyUT"),M=re("5Dmo"),H=re("3S7+"),F=re("sRBo"),P=re("kaz8"),O=re("2qtc"),b=re("kLXV"),A=re("miYZ"),D=re("tsqr"),L=re("k1fw"),w=re("9og8"),x=re("tJVT"),u=re("PpiC"),a=re("5NDa"),l=re("5rEg"),h=re("OaEy"),C=re("2fM7"),g=re("WmNS"),m=re.n(g),k=re("q1tI"),v=re.n(k),f=re("9kvl"),p=re("Ot1p"),d=re("HBuW"),o=re("LvDl"),S=re.n(o),y=re("bNIU"),T=re.n(y),I=re("9ZNV"),G=re("fnXi"),X=re("nuEh"),Q=re("UqFu"),z=C.a.Option,W=l.a.TextArea,ee=function(pe){var ve=pe.shixunsDetail,De=pe.dispatch,xe=pe.match,Ce=pe.practiceSetting,Ae=Object(u.a)(pe,["shixunsDetail","dispatch","match","practiceSetting"]),Se=Object(k.useState)({}),ge=Object(x.a)(Se,2),oe=ge[0],Re=ge[1],Ze=Object(k.useState)([]),He=Object(x.a)(Ze,2),Ge=He[0],$e=He[1],_e=Object(k.useState)(!1),Ie=Object(x.a)(_e,2),We=Ie[0],Ve=Ie[1],ze=Object(k.useRef)(null),Be=Object(k.useRef)({editData:null,answerList:null}),Fe=Object(k.useState)(!0),ot=Object(x.a)(Fe,2),it=ot[0],Je=ot[1];Object(k.useEffect)(function(){qe()},[]),Object(k.useEffect)(function(){we()},[oe,Ge]);var qe=function(){var Te=Object(w.a)(m.a.mark(function Le(){return m.a.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:return Je(!0),le.next=3,ct();case 3:return le.next=5,et();case 5:Je(!1);case 6:case"end":return le.stop()}},Le)}));return function(){return Te.apply(this,arguments)}}(),ct=function(){var Te=Object(w.a)(m.a.mark(function Le(){var fe;return m.a.wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:return ue.next=2,Object(d.H)({id:xe.params.id,challengeId:xe.params.challengesId,tab:2});case 2:fe=ue.sent,Be.current.editData=fe,fe&&Re(fe);case 5:case"end":return ue.stop()}},Le)}));return function(){return Te.apply(this,arguments)}}(),et=function(){var Te=Object(w.a)(m.a.mark(function Le(){var fe,le;return m.a.wrap(function(q){for(;;)switch(q.prev=q.next){case 0:return q.next=2,Object(d.I)({id:xe.params.id,challengeId:xe.params.challengesId});case 2:fe=q.sent,le=fe.map(function(te){return Object(L.a)(Object(L.a)({},te),{},{contents:Object(Q.a)(te.contents)})}),Be.current.answerList=le,fe&&$e(le);case 6:case"end":return q.stop()}},Le)}));return function(){return Te.apply(this,arguments)}}(),Qe=function(){var Te=Object(w.a)(m.a.mark(function Le(){var fe,le,ue;return m.a.wrap(function(te){for(;;)switch(te.prev=te.next){case 0:if(Ve(!0),fe=Ge.map(function(ie){return ie.score}),le=fe.reduce(function(ie,de){return ie+de},0),!(le!==100&&Ge!==null&&Ge!==void 0&&Ge.length)){te.next=7;break}return Ve(!1),D.b.info("\u6D4B\u8BD5\u96C6\u7684\u8BC4\u5206\u5360\u6BD4\u4E4B\u548C\u5FC5\u987B\u7B49\u4E8E100"),te.abrupt("return");case 7:if(Ge.every(function(ie){return ie.name})){te.next=11;break}return Ve(!1),D.b.info("\u8BF7\u5148\u586B\u5199\u53C2\u8003\u7B54\u6848\u540D\u79F0"),te.abrupt("return");case 11:if(Ge.every(function(ie){return ie.contents})){te.next=15;break}return Ve(!1),D.b.info("\u8BF7\u5148\u586B\u5199\u53C2\u8003\u7B54\u6848\u5185\u5BB9"),te.abrupt("return");case 15:return te.next=17,Object(d.Lb)({id:xe.params.id,challengeId:xe.params.challengesId,challenge_answer:Ge,hide_answer:oe==null?void 0:oe.hide_answer,disable_copy:oe==null?void 0:oe.disable_copy});case 17:ue=te.sent,Ve(!1),De({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}}),ue!=null&&ue.message&&D.b.info(ue.message),ue.status===1&&f.d.push("/shixuns/".concat(xe.params.id,"/edit/").concat(xe.params.challengesId,"/tab=4"));case 22:case"end":return te.stop()}},Le)}));return function(){return Te.apply(this,arguments)}}(),we=function(){clearTimeout(ze.current),ze.current=setTimeout(lt,500)},lt=function(){!Object(o.isEqual)(Be.current.editData,oe)||!Object(o.isEqual)(Be.current.answerList,Ge)?De({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!0}}):De({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})},tt=function(){var Le,fe=function(){f.d.push("/shixuns/".concat(xe.params.id,"/challenges")),De({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})};Ce!=null&&(Le=Ce.sideBar)!==null&&Le!==void 0&&Le.confirmLeave?b.a.confirm({title:"\u79BB\u5F00\u6B64\u9875\u63D0\u793A",content:"\u7CFB\u7EDF\u53EF\u80FD\u4E0D\u4F1A\u4FDD\u5B58\u60A8\u6240\u505A\u7684\u66F4\u6539\u3002",okText:"\u79BB\u5F00",cancelText:"\u53D6\u6D88",onOk:function(){fe()}}):fe()};return v.a.createElement("section",{className:T.a.bg},v.a.createElement("div",{className:T.a.formWrap},v.a.createElement(G.a,{activeIndex:2}),v.a.createElement("div",{className:T.a.check},v.a.createElement("div",null,v.a.createElement(P.a,{checked:oe==null?void 0:oe.hide_answer,onChange:function(Le){return Re(Object(L.a)(Object(L.a)({},oe),{},{hide_answer:Le.target.checked}))}},"\u9690\u85CF\u53C2\u8003\u7B54\u6848\u6A21\u5757")),v.a.createElement("div",null,v.a.createElement(P.a,{checked:oe==null?void 0:oe.disable_copy,onChange:function(Le){return Re(Object(L.a)(Object(L.a)({},oe),{},{disable_copy:Le.target.checked}))}},"\u7981\u6B62\u590D\u5236\u53C2\u8003\u7B54\u6848"))),v.a.createElement("div",{className:T.a.fieldWrap},v.a.createElement("p",null,"\u53EF\u4EE5\u5C06\u53C2\u8003\u7B54\u6848\u5206\u7EA7\u8BBE\u7F6E\uFF0C\u8BA9\u5B66\u5458\u81EA\u884C\u9009\u62E9\u7EA7\u522B\uFF0C\u6BCF\u7EA7\u67E5\u770B\u540E\u6309\u7167\u6BD4\u4F8B\u6263\u5206\u503C\uFF08\u5B66\u5458\u5DF2\u5B8C\u6210\u4EFB\u52A1\u518D\u67E5\u770B\uFF0C\u5219\u4E0D\u5F71\u54CD\u5B66\u5458\u5DF2\u83B7\u5F97\u7684\u6210\u7EE9\uFF09"),v.a.createElement("p",null,"\u793A\u4F8B\uFF1A\u7EA7\u522B1\uFF0C\u6263\u51CF\u5206\u503C\u5360\u6BD425%\uFF1B\u7EA7\u522B2\uFF0C\u6263\u51CF\u5206\u503C\u5360\u6BD435%\uFF1B\u7EA7\u522B3\uFF0C\u6263\u51CF\u5206\u503C\u5360\u6BD440%\uFF1B"),v.a.createElement("p",null,"\u82E5\u5B66\u5458\u9009\u62E9\u67E5\u770B\u7EA7\u522B1\u7684\u7B54\u6848\uFF0C\u5C06\u88AB\u6263\u51CF25%\u7684\u5206\u503C\uFF1B\u9009\u62E9\u67E5\u770B\u7EA7\u522B2\u7684\u7B54\u6848\uFF0C\u5C06\u88AB\u6263\u51CF60%\u7684\u5206\u503C\uFF1B\u9009\u62E9\u67E5\u770B\u7EA7\u522B3\u7684\u7B54\u6848\uFF0C\u5C06\u88AB\u6263\u51CF100%\u7684\u5206\u503C\u3002"),Ge==null?void 0:Ge.map(function(Te,Le){return v.a.createElement("div",{key:Le,className:"mt30 pb5"},v.a.createElement("div",{className:T.a.flexRow},v.a.createElement("b",{className:"font16"},"\u7EA7\u522B\uFF1A",Le+1),v.a.createElement("div",{className:"tr flex1"},v.a.createElement(H.a,{placement:"bottom",title:"\u5220\u9664"},v.a.createElement("span",{className:"font14 c-red current",onClick:function(){var le=Ge.filter(function(te,ie){return ie!==Le}),ue=Math.floor(100/le.length),q=ue+100%le.length;le=le.map(function(te,ie){return ie===le.length-1?Object(L.a)(Object(L.a)({},te),{},{score:q}):Object(L.a)(Object(L.a)({},te),{},{score:ue})}),$e(le)}},"\u5220\xA0\u9664")))),v.a.createElement("div",{className:T.a.contentWrap},v.a.createElement("div",{className:T.a.flexRow},v.a.createElement("div",null,v.a.createElement("p",{className:"font16"},"\u540D\u79F0\uFF1A"),v.a.createElement(l.a,{bordered:!1,value:Te.name,onChange:function(le){var ue=Ge.map(function(q,te){return te===Le?Object(L.a)(Object(L.a)({},q),{},{name:le.target.value}):q});$e(ue)}})),v.a.createElement("div",{className:"ml10"},v.a.createElement("p",{className:"font16"},"\u6263\u51CF\u5206\u503C\u5360\u6BD4\uFF1A"),v.a.createElement(N.a,{min:0,max:100,value:Te.score,onChange:function(le){var ue=Ge.map(function(q,te){return te===Le?Object(L.a)(Object(L.a)({},q),{},{score:le}):q});$e(ue)}})))),v.a.createElement("div",{className:"mt10 mb10"},v.a.createElement("div",{className:"font16 mb20"},"\u5185\u5BB9\uFF1A"),v.a.createElement(p.a,{placeholder:"\u5EFA\u8BAE\u63D0\u4F9B\u5305\u62EC\u6587\u4EF6\u6240\u6709\u4EE3\u7801\u7684\u5B8C\u6574\u7B54\u6848",defaultValue:Te.contents,onChange:function(le){var ue=Ge.map(function(q,te){return te===Le?Object(L.a)(Object(L.a)({},q),{},{contents:le}):q});$e(ue)}})))}),v.a.createElement("div",null,v.a.createElement($.a,{type:"primary",size:"large",ghost:!0,style:{width:200},className:"mt10",onClick:function(){var Le=[].concat(Object(_.a)(Ge),[{name:"\u89E3\u9898\u601D\u8DEF".concat(Ge.length+1),contents:"",score:0,id:null,level:null}]),fe=Math.floor(100/Le.length),le=fe+100%Le.length;Le=Le.map(function(ue,q){return q===Le.length-1?Object(L.a)(Object(L.a)({},ue),{},{score:le}):Object(L.a)(Object(L.a)({},ue),{},{score:fe})}),$e(Le)}},"\u65B0\u589E\u53C2\u8003\u7B54\u6848")))),v.a.createElement(I.a,{onOk:Qe,className:"customFixedButton",onCancel:tt,loading:We}),v.a.createElement(X.a,{loading:it}))};at.default=Object(f.a)(function(ae){var pe=ae.shixunsDetail,ve=ae.newCourse,De=ae.globalSetting,xe=ae.practiceSetting;return{shixunsDetail:pe,newCourse:ve,globalSetting:De,practiceSetting:xe}})(ee)},"7Cbv":function(xt,at,re){"use strict";var ne=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(!ne)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ne($)}var V=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function N(D){return typeof D=="string"&&V.test(D)}for(var M=N,H=[],F=0;F<256;++F)H.push((F+256).toString(16).substr(1));function P(D){var L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,w=(H[D[L+0]]+H[D[L+1]]+H[D[L+2]]+H[D[L+3]]+"-"+H[D[L+4]]+H[D[L+5]]+"-"+H[D[L+6]]+H[D[L+7]]+"-"+H[D[L+8]]+H[D[L+9]]+"-"+H[D[L+10]]+H[D[L+11]]+H[D[L+12]]+H[D[L+13]]+H[D[L+14]]+H[D[L+15]]).toLowerCase();if(!M(w))throw TypeError("Stringified UUID is invalid");return w}var O=P;function b(D,L,w){D=D||{};var x=D.random||(D.rng||_)();if(x[6]=x[6]&15|64,x[8]=x[8]&63|128,L){w=w||0;for(var u=0;u<16;++u)L[w+u]=x[u];return L}return O(x)}var A=at.a=b},"7ahc":function(xt,at,re){"use strict";re.d(at,"a",function(){return C});var ne=re("k1fw"),$=re("0Owb"),_=re("+L6B"),V=re("2/Rp"),N=re("y8nQ"),M=re("Vl3Y"),H=re("tJVT"),F=re("OaEy"),P=re("2fM7"),O=re("q1tI"),b=re.n(O),A=re("VrN/"),D=re.n(A),L=re("p77/"),w=re.n(L),x=re("c5Ni"),u=re.n(x),a=P.a.Option,l={labelCol:{span:4},wrapperCol:{span:20}},h={asp:["ASP","vbscript"],actionscript:["ActionScript(3.0)/Flash/Flex","clike"],bash:["Bash/Bat","shell"],css:["CSS","css"],c:["C","clike"],cpp:["C++","clike"],csharp:["C#","clike"],coffeescript:["CoffeeScript","coffeescript"],d:["D","d"],dart:["Dart","dart"],delphi:["Delphi/Pascal","pascal"],erlang:["Erlang","erlang"],go:["Golang","go"],groovy:["Groovy","groovy"],html:["HTML","text/html"],java:["Java","clike"],json:["JSON","text/json"],javascript:["Javascript","javascript"],lua:["Lua","lua"],less:["LESS","css"],markdown:["Markdown","gfm"],"objective-c":["Objective-C","clike"],php:["PHP","php"],perl:["Perl","perl"],python:["Python","python"],r:["R","r"],rst:["reStructedText","rst"],ruby:["Ruby","ruby"],sql:["SQL","sql"],sass:["SASS/SCSS","sass"],shell:["Shell","shell"],scala:["Scala","clike"],swift:["Swift","clike"],vb:["VB/VBScript","vb"],xml:["XML","text/xml"],yaml:["YAML","yaml"]};at.b=function(g){var m=g.callback,k=g.onCancel,v=Object(O.useState)("python"),f=Object(H.a)(v,2),p=f[0],d=f[1];function o(y){d(h[y][1])}function S(y){m(y)}return b.a.createElement(M.a,Object($.a)({},l,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:S}),b.a.createElement(M.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},b.a.createElement(P.a,{onChange:o},Object.keys(h).map(function(y){return b.a.createElement(a,{key:y,value:y},h[y][0])}))),b.a.createElement(M.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},b.a.createElement(C,{mode:p})),b.a.createElement("div",{className:"flex-container flex-end"},b.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),b.a.createElement(V.a,{type:"ghost",onClick:k},"\u53D6\u6D88")))};function C(g){var m=g.value,k=g.onChange,v=g.mode,f=g.options,p=f===void 0?{}:f,d=Object(O.useRef)(),o=Object(O.useState)(),S=Object(H.a)(o,2),y=S[0],T=S[1];return Object(O.useEffect)(function(){if(y){function I(G){var X=G.getValue();k&&k(X)}return y.on("change",I),function(){y.off("change",I)}}},[y,k]),Object(O.useEffect)(function(){y&&y.setOption("mode",v)},[y,v]),Object(O.useEffect)(function(){y&&((m!==y.getValue()||m==="")&&setTimeout(function(){y.setValue(m||" ")},300))},[y,m]),Object(O.useEffect)(function(){if(d.current&&!y){var I=D.a.fromTextArea(d.current,Object(ne.a)({mode:v,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},p));T(I)}},[d.current,y]),b.a.createElement("div",{className:"my-codemirror-container"},b.a.createElement("textarea",{ref:d}))}},"7ixt":function(xt,at,re){"use strict";re.d(at,"a",function(){return _});var ne={adjustX:1,adjustY:1},$=[0,0],_={left:{points:["cr","cl"],overflow:ne,offset:[-4,0],targetOffset:$},right:{points:["cl","cr"],overflow:ne,offset:[4,0],targetOffset:$},top:{points:["bc","tc"],overflow:ne,offset:[0,-4],targetOffset:$},bottom:{points:["tc","bc"],overflow:ne,offset:[0,4],targetOffset:$},topLeft:{points:["bl","tl"],overflow:ne,offset:[0,-4],targetOffset:$},leftTop:{points:["tr","tl"],overflow:ne,offset:[-4,0],targetOffset:$},topRight:{points:["br","tr"],overflow:ne,offset:[0,-4],targetOffset:$},rightTop:{points:["tl","tr"],overflow:ne,offset:[4,0],targetOffset:$},bottomRight:{points:["tr","br"],overflow:ne,offset:[0,4],targetOffset:$},rightBottom:{points:["bl","br"],overflow:ne,offset:[4,0],targetOffset:$},bottomLeft:{points:["tl","bl"],overflow:ne,offset:[0,4],targetOffset:$},leftBottom:{points:["br","bl"],overflow:ne,offset:[-4,0],targetOffset:$}},V=_},"8EBN":function(xt,at,re){(function(ne){ne(re("VrN/"))})(function(ne){"use strict";ne.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;$<ne.modeInfo.length;$++){var _=ne.modeInfo[$];_.mimes&&(_.mime=_.mimes[0])}ne.findModeByMIME=function(V){V=V.toLowerCase();for(var N=0;N<ne.modeInfo.length;N++){var M=ne.modeInfo[N];if(M.mime==V)return M;if(M.mimes){for(var H=0;H<M.mimes.length;H++)if(M.mimes[H]==V)return M}}if(/\+xml$/.test(V))return ne.findModeByMIME("application/xml");if(/\+json$/.test(V))return ne.findModeByMIME("application/json")},ne.findModeByExtension=function(V){V=V.toLowerCase();for(var N=0;N<ne.modeInfo.length;N++){var M=ne.modeInfo[N];if(M.ext){for(var H=0;H<M.ext.length;H++)if(M.ext[H]==V)return M}}},ne.findModeByFileName=function(V){for(var N=0;N<ne.modeInfo.length;N++){var M=ne.modeInfo[N];if(M.file&&M.file.test(V))return M}var H=V.lastIndexOf("."),F=H>-1&&V.substring(H+1,V.length);if(F)return ne.findModeByExtension(F)},ne.findModeByName=function(V){V=V.toLowerCase();for(var N=0;N<ne.modeInfo.length;N++){var M=ne.modeInfo[N];if(M.name.toLowerCase()==V)return M;if(M.alias){for(var H=0;H<M.alias.length;H++)if(M.alias[H].toLowerCase()==V)return M}}}})},"8hTe":function(xt,at,re){xt.exports={button:"button___1wy9m"}},"93VE":function(xt,at,re){},"9Bee":function(xt,at,re){"use strict";var ne=re("DYRE"),$=re("zeV3"),_=re("+L6B"),V=re("2/Rp"),N=re("k1fw"),M=re("9og8"),H=re("tJVT"),F=re("WmNS"),P=re.n(F),O=re("q1tI"),b=re.n(O),A=re("vg9a"),D=re("DlQD"),L=re.n(D),w=re("rUJ1");function x(j,s){var c=j.match(/^(\s+)(?:```)/);if(c===null)return s;var R=c[1];return s.split(`
|
|
`).map(function(Z){var U=Z.match(/^\s+/);if(U===null)return Z;var ce=Object(H.a)(U,1),Oe=ce[0];return Oe.length>=R.length?Z.slice(R.length):Z}).join(`
|
|
`)}var u=[],a=["<ul>"],l=new L.a.Renderer,h=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function C(){u.length=0,a=["<ul>"]}var g={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function m(j,s,c,R){if(s>=j.length||j[s].level<=c)return s;var Z=j[s];R.push("<li><a href='#"+Z.anchor+"'>"+Z.text+"</a>"),s++;var U=[];return s=m(j,s,Z.level,U),U.length>0&&(R.push("<ul>"),U.forEach(function(ce){R.push(ce)}),R.push("</ul>")),R.push("</li>"),s=m(j,s,c,R),s}function k(){return m(u,0,0,a),a.push("</ul>"),a.join("")}var v={heading:function(s){var c=h.exec(s);if(c)return{type:"heading",raw:c[0],depth:c[1].length,text:c[2]}},fences:function(s){var c=this.rules.block.fences.exec(s);if(c){var R=c[0],Z=x(R,c[3]||""),U=c[2]?c[2].trim():c[2];if(["latex","katex","math"].indexOf(U)>=0){var ce=d(),Oe=Z;Z=ce,o[ce]={type:"block",expression:Oe}}return{type:"code",raw:R,lang:U,text:Z}}}},f=/(?:\${2})([^\n`]+?)(?:\${2})/gi,p=0,d=function(){return"__special_katext_id_".concat(p++,"__")},o={};function S(){return o}function y(){p=0,o={}}function T(j){return j=j.replace(f,function(s,c){var R=d();return o[R]={type:"inline",expression:c},R}),j}var I=l.listitem;l.listitem=function(j){return I(T(j))};var G=l.paragraph;l.paragraph=function(j){return G(T(j))};var X=l.tablecell;l.tablecell=function(j,s){return X(T(j),s)},l.code=function(j,s,c){var R=(s||"").match(/\S*/)[0];return R?["latex","katex","math"].indexOf(R)>=0?"<p class='editormd-tex'>".concat(j,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(s,'">').concat(c?j:Object(w.escape)(j,!0),`</code></pre>
|
|
`):'<pre class="prettyprint linenums"><code>'+(c?j:Object(w.escape)(j,!0))+"</code></pre>"},l.heading=function(j,s,c){var R=this.options.headerPrefix+c.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return u.push({anchor:R,level:s,text:j}),"<h"+s+' id="'+R+'">'+j+"</h"+s+">"},L.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),L.a.use({tokenizer:v,renderer:l});var Q=L.a,z=re("SJMd"),W=re("ulZh"),ee=re.n(W),ae=re("m3rI"),pe=re("Oy/b"),ve=re("p5ED"),De=re("ErOA");/*! *****************************************************************************
|
|
Copyright (c) Microsoft Corporation.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
***************************************************************************** */var xe=function(j,s){return(xe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(c,R){c.__proto__=R}||function(c,R){for(var Z in R)Object.prototype.hasOwnProperty.call(R,Z)&&(c[Z]=R[Z])})(j,s)};function Ce(j,s){function c(){this.constructor=j}xe(j,s),j.prototype=s===null?Object.create(s):(c.prototype=s.prototype,new c)}function Ae(j,s,c,R){return new(c||(c=Promise))(function(Z,U){function ce(dt){try{Ke(R.next(dt))}catch(Me){U(Me)}}function Oe(dt){try{Ke(R.throw(dt))}catch(Me){U(Me)}}function Ke(dt){var Me;dt.done?Z(dt.value):(Me=dt.value,Me instanceof c?Me:new c(function(vt){vt(Me)})).then(ce,Oe)}Ke((R=R.apply(j,s||[])).next())})}function Se(j,s){var c,R,Z,U,ce={label:0,sent:function(){if(1&Z[0])throw Z[1];return Z[1]},trys:[],ops:[]};return U={next:Oe(0),throw:Oe(1),return:Oe(2)},typeof Symbol=="function"&&(U[Symbol.iterator]=function(){return this}),U;function Oe(Ke){return function(dt){return function(Me){if(c)throw new TypeError("Generator is already executing.");for(;ce;)try{if(c=1,R&&(Z=2&Me[0]?R.return:Me[0]?R.throw||((Z=R.return)&&Z.call(R),0):R.next)&&!(Z=Z.call(R,Me[1])).done)return Z;switch(R=0,Z&&(Me=[2&Me[0],Z.value]),Me[0]){case 0:case 1:Z=Me;break;case 4:return ce.label++,{value:Me[1],done:!1};case 5:ce.label++,R=Me[1],Me=[0];continue;case 7:Me=ce.ops.pop(),ce.trys.pop();continue;default:if(!(Z=ce.trys,(Z=Z.length>0&&Z[Z.length-1])||Me[0]!==6&&Me[0]!==2)){ce=0;continue}if(Me[0]===3&&(!Z||Me[1]>Z[0]&&Me[1]<Z[3])){ce.label=Me[1];break}if(Me[0]===6&&ce.label<Z[1]){ce.label=Z[1],Z=Me;break}if(Z&&ce.label<Z[2]){ce.label=Z[2],ce.ops.push(Me);break}Z[2]&&ce.ops.pop(),ce.trys.pop();continue}Me=s.call(j,ce)}catch(vt){Me=[6,vt],R=0}finally{c=Z=0}if(5&Me[0])throw Me[1];return{value:Me[0]?Me[1]:void 0,done:!0}}([Ke,dt])}}}function ge(){for(var j=0,s=0,c=arguments.length;s<c;s++)j+=arguments[s].length;var R=Array(j),Z=0;for(s=0;s<c;s++)for(var U=arguments[s],ce=0,Oe=U.length;ce<Oe;ce++,Z++)R[Z]=U[ce];return R}var oe=function(){function j(){}return j.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},j.setAttributes=function(s,c){for(var R=0,Z=c;R<Z.length;R++){var U=Z[R],ce=U[0],Oe=U[1];s.setAttribute(ce,Oe)}},j.createRect=function(s,c,R){var Z=document.createElementNS("http://www.w3.org/2000/svg","rect");return Z.setAttribute("width",s.toString()),Z.setAttribute("height",c.toString()),R&&j.setAttributes(Z,R),Z},j.createLine=function(s,c,R,Z,U){var ce=document.createElementNS("http://www.w3.org/2000/svg","line");return ce.setAttribute("x1",s.toString()),ce.setAttribute("y1",c.toString()),ce.setAttribute("x2",R.toString()),ce.setAttribute("y2",Z.toString()),U&&j.setAttributes(ce,U),ce},j.createPolygon=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","polygon");return R.setAttribute("points",s),c&&j.setAttributes(R,c),R},j.createCircle=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","circle");return R.setAttribute("cx",(s/2).toString()),R.setAttribute("cy",(s/2).toString()),R.setAttribute("r",s.toString()),c&&j.setAttributes(R,c),R},j.createEllipse=function(s,c,R){var Z=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return Z.setAttribute("cx",(s/2).toString()),Z.setAttribute("cy",(c/2).toString()),Z.setAttribute("rx",(s/2).toString()),Z.setAttribute("ry",(c/2).toString()),R&&j.setAttributes(Z,R),Z},j.createGroup=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&j.setAttributes(c,s),c},j.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},j.createMarker=function(s,c,R,Z,U,ce,Oe){var Ke=document.createElementNS("http://www.w3.org/2000/svg","marker");return j.setAttributes(Ke,[["id",s],["orient",c],["markerWidth",R.toString()],["markerHeight",Z.toString()],["refX",U.toString()],["refY",ce.toString()]]),Ke.appendChild(Oe),Ke},j.createText=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","text");return c.setAttribute("x","0"),c.setAttribute("y","0"),s&&j.setAttributes(c,s),c},j.createTSpan=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","tspan");return R.textContent=s,c&&j.setAttributes(R,c),R},j.createImage=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&j.setAttributes(c,s),c},j.createPoint=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return R.x=s,R.y=c,R},j.createPath=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","path");return R.setAttribute("d",s),c&&j.setAttributes(R,c),R},j}(),Re=function(){function j(){}return j.addKey=function(s){j.key=s},Object.defineProperty(j,"isLicensed",{get:function(){return!!j.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(j.key)},enumerable:!1,configurable:!0}),j}(),Ze=function(){function j(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return j.prototype.rasterize=function(s,c,R){var Z=this;return new Promise(function(U){var ce=R!==void 0?R:document.createElement("canvas");s===null&&(Z.markersOnly=!0,Z.naturalSize=!1);var Oe=document.createElementNS("http://www.w3.org/2000/svg","svg");Oe.setAttribute("xmlns","http://www.w3.org/2000/svg"),Oe.setAttribute("width",c.width.baseVal.valueAsString),Oe.setAttribute("height",c.height.baseVal.valueAsString),Oe.setAttribute("viewBox","0 0 "+c.viewBox.baseVal.width.toString()+" "+c.viewBox.baseVal.height.toString()),Oe.innerHTML=c.innerHTML,Z.naturalSize===!0?(Oe.width.baseVal.value=s.naturalWidth,Oe.height.baseVal.value=s.naturalHeight):Z.width!==void 0&&Z.height!==void 0&&(Oe.width.baseVal.value=Z.width,Oe.height.baseVal.value=Z.height),ce.width=Oe.width.baseVal.value,ce.height=Oe.height.baseVal.value;var Ke=Oe.outerHTML,dt=ce.getContext("2d");Z.markersOnly!==!0&&dt.drawImage(s,0,0,ce.width,ce.height);var Me=window.URL,vt=new Image(ce.width,ce.height);vt.setAttribute("crossOrigin","anonymous");var Nt=new Blob([Ke],{type:"image/svg+xml"}),Kt=Me.createObjectURL(Nt);vt.onload=function(){dt.drawImage(vt,0,0),Me.revokeObjectURL(Kt);var Rr=ce.toDataURL(Z.imageType,Z.imageQuality);U(Rr)},vt.src=Kt})},j}(),He=function(){},Ge=function(){function j(s){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(j.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#ffffff",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarColor:"#eeeeee",toolbarHeight:40,toolboxColor:"#eeeeee",toolboxAccentColor:"#3080c3",undoButtonVisible:!0,redoButtonVisible:!1,zoomButtonVisible:!1,zoomOutButtonVisible:!1,clearButtonVisible:!1,resultButtonBlockVisible:!0,logoPosition:"left"}},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),j.prototype.addClass=function(s){return this.styleSheet===void 0&&this.addStyleSheet(),s.name=""+this.classNamePrefix+s.localName,this.classes.push(s),this.styleSheet.sheet.insertRule("."+s.name+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length),s},j.prototype.addRule=function(s){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(s),this.styleSheet.sheet.insertRule(s.selector+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length)},j.prototype.addStyleSheet=function(){var s;this.styleSheet=document.createElement("style"),((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).appendChild(this.styleSheet),this.addRule(new $e("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new $e("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new $e("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new _e("fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new _e("fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},j.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},j}(),$e=function(j,s){this.selector=j,this.style=s},_e=function(j,s){this.localName=j,this.style=s},Ie=function(){function j(s,c,R,Z,U){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=s,this.displayMode=c,this.markerItems=R,this.uiStyleSettings=Z,this.styles=U,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return j.prototype.show=function(s){var c=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var R=document.createElement("div");R.className=this.toolbarBlockStyleClass.name,R.style.whiteSpace="nowrap",this.uiContainer.appendChild(R),this.addActionButton(R,'<svg viewBox="0 0 24 24"><path d="M10.07 14.27a.997.997 0 011.33.48l2.3 4.99 1.8-.85-2.31-4.98c-.24-.5-.02-1.1.48-1.33l.28-.08 2.3-.45L8 5.12V15.9l1.82-1.47.25-.16m3.57 7.7a.99.99 0 01-1.33-.47l-2.18-4.74-2.51 2.02c-.17.14-.38.22-.62.22a1 1 0 01-1-1V3a1 1 0 011-1c.24 0 .47.09.64.23l.01-.01 11.49 9.64a1.001 1.001 0 01-.44 1.75l-3.16.62 2.2 4.73c.26.5.02 1.09-.48 1.32l-3.62 1.69z"/></svg>',"select"),this.addActionButton(R,'<svg viewBox="0 0 24 24"><path d="M9 3v1H4v2h1v13a2 2 0 002 2h10a2 2 0 002-2V6h1V4h-5V3H9M7 6h10v13H7V6m2 2v9h2V8H9m4 0v9h2V8h-2z"/></svg>',"delete"),this.uiStyleSettings.clearButtonVisible&&this.addActionButton(R,'<svg viewBox="0 0 24 24"><path d="M19.36 2.72l1.42 1.42-5.72 5.71c1.07 1.54 1.22 3.39.32 4.59L9.06 8.12c1.2-.9 3.05-.75 4.59.32l5.71-5.72M5.93 17.57c-2.01-2.01-3.24-4.41-3.58-6.65l4.88-2.09 7.44 7.44-2.09 4.88c-2.24-.34-4.64-1.57-6.65-3.58z"/></svg>',"clear"),this.uiStyleSettings.undoButtonVisible&&this.addActionButton(R,'<svg viewBox="0 0 24 24"><path d="M12.5 8c-2.65 0-5.05 1-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"/></svg>',"undo"),this.uiStyleSettings.redoButtonVisible&&this.addActionButton(R,'<svg viewBox="0 0 24 24"><path d="M18.4 10.6C16.55 9 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16a8.002 8.002 0 017.6-5.5c1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"/></svg>',"redo"),this.uiStyleSettings.zoomButtonVisible&&this.addActionButton(R,'<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"zoom"),this.uiStyleSettings.zoomButtonVisible&&this.uiStyleSettings.zoomOutButtonVisible&&this.addActionButton(R,'<svg viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0016 9.5 6.5 6.5 0 009.5 3 6.5 6.5 0 003 9.5 6.5 6.5 0 009.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 5 1.5-1.5-5-5m-6 0C7 14 5 12 5 9.5S7 5 9.5 5 14 7 14 9.5 12 14 9.5 14M7 9h5v1H7V9z"/></svg>',"zoom-out"),this.uiStyleSettings.notesButtonVisible&&this.addActionButton(R,'<svg viewBox="0 0 24 24"><path d="M18.13 12l1.26-1.26c.44-.44 1-.68 1.61-.74V9l-6-6H5c-1.11 0-2 .89-2 2v14a2 2 0 002 2h6v-1.87l.13-.13H5V5h7v7h6.13M14 4.5l5.5 5.5H14V4.5m5.13 9.33l2.04 2.04L15.04 22H13v-2.04l6.13-6.13m3.72.36l-.98.98-2.04-2.04.98-.98c.19-.2.52-.2.72 0l1.32 1.32c.2.2.2.53 0 .72z"/></svg>',"notes"),this.markerButtonBlock=document.createElement("div"),this.markerButtonBlock.className=this.toolbarBlockStyleClass.name,this.markerButtonBlock.style.flexGrow="2",this.markerButtonBlock.style.textAlign="center",this.uiContainer.appendChild(this.markerButtonBlock),this.markerButtonOverflowBlock=document.createElement("div"),this.markerButtonOverflowBlock.className=this.toolbarOverflowBlockStyleClass.name+" "+(this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName?this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName:this.toolbarOverflowBlockStyleColorsClass.name),this.markerButtonOverflowBlock.style.display="none",this.uiContainer.appendChild(this.markerButtonOverflowBlock),this.markerItems&&(this.markerItems.forEach(function(U){var ce=document.createElement("div");ce.className=""+c.toolbarButtonStyleClass.name,ce.setAttribute("data-type-name",U.typeName),ce.innerHTML=U.icon,ce.addEventListener("click",function(){c.markerToolbarButtonClicked(ce,U)}),c.buttons.push(ce),c.markerButtons.push(ce)}),this.overflowButton=document.createElement("div"),this.overflowButton.className=this.toolbarButtonStyleClass.name+" "+(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name),this.overflowButton.innerHTML='<svg viewBox="0 0 24 24"><path d="M12 16a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2z"/></svg>',this.overflowButton.addEventListener("click",this.overflowButtonClicked),this.markerButtonBlock.appendChild(this.overflowButton));var Z=document.createElement("div");Z.className=this.toolbarBlockStyleClass.name,Z.style.whiteSpace="nowrap",Z.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(Z),this.addActionButton(Z,'<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"render"),this.addActionButton(Z,'<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"close"),this.markerjsContainer.appendChild(this.uiContainer),this.setSelectMode(),this.setCurrentMarker(),this.adjustLayout()},j.prototype.addButtonClickListener=function(s){this.buttonClickListeners.push(s)},j.prototype.removeButtonClickListener=function(s){this.buttonClickListeners.indexOf(s)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(s),1)},j.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},j.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var s=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var c=0;c<this.markerButtons.length;c++)c<s||c===s&&this.markerButtons.length-1===s?this.markerButtonBlock.appendChild(this.markerButtons[c]):(c===s&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[c]))}},j.prototype.overflowButtonClicked=function(){this.markerButtonOverflowBlock.style.display!=="none"?(this.markerButtonOverflowBlock.className=this.markerButtonOverflowBlock.className.replace(this.styles.fadeInAnimationClassName,""),this.markerButtonOverflowBlock.style.display="none"):(this.markerButtonOverflowBlock.className+=" "+this.styles.fadeInAnimationClassName,this.markerButtonOverflowBlock.style.top=this.uiContainer.offsetTop+this.overflowButton.offsetHeight+"px",this.markerButtonOverflowBlock.style.right=this.uiContainer.offsetWidth-this.overflowButton.offsetLeft-this.overflowButton.offsetWidth+2*this.uiContainer.offsetLeft+"px",this.markerButtonOverflowBlock.style.display="inline-block")},j.prototype.resetButtonStyles=function(){var s=this;this.buttons.forEach(function(c){c.className=c.className.replace(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name,"").trim(),c.className=c.className.replace(s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:s.toolbarActiveButtonStyleColorsClass.name,"").trim(),c.className+=" "+(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name)})},j.prototype.addActionButton=function(s,c,R){var Z=this,U=document.createElement("div");switch(U.className=""+this.toolbarButtonStyleClass.name,U.innerHTML=c,U.setAttribute("data-action",R),U.addEventListener("click",function(){Z.actionToolbarButtonClicked(U,R)}),R){case"select":U.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":U.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":U.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":U.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":U.style.fill=this.uiStyleSettings.closeButtonColor}s.appendChild(U),this.buttons.push(U)},j.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new _e("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 _e("toolbar_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new _e("toolbar-block",`
|
|
display: inline-block;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new _e("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 _e("toolbar-overflow-block_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`));var s=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new _e("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*s)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*s)+`px;
|
|
padding: `+s+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new _e("toolbar_button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new _e("toolbar_active_button",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new $e("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new $e("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`))},j.prototype.markerToolbarButtonClicked=function(s,c){this.setActiveButton(s),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(R){return R("marker",c)}),this.markerButtonOverflowBlock.style.display="none"},j.prototype.actionToolbarButtonClicked=function(s,c){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(R){return R("action",c)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},j.prototype.setActiveButton=function(s){this.resetButtonStyles(),s.className=s.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),s.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},j.prototype.setActiveMarkerButton=function(s){var c=this.markerButtons.find(function(R){return R.getAttribute("data-type-name")===s});c&&this.setActiveButton(c)},j.prototype.setCurrentMarker=function(s){var c=this;this.currentMarker=s,this.buttons.filter(function(R){return/delete|notes/.test(R.getAttribute("data-action"))}).forEach(function(R){c.currentMarker===void 0?(R.style.fillOpacity="0.4",R.style.pointerEvents="none"):(R.style.fillOpacity="1",R.style.pointerEvents="all")})},j}(),We=function(){function j(s,c,R,Z){this.panels=[],this.panelButtons=[],this.markerjsContainer=s,this.displayMode=c,this.uiStyleSettings=R,this.styles=Z,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return j.prototype.addStyles=function(){var s;this.toolboxStyleClass=this.styles.addClass(new _e("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 _e("toolbox_colors",`
|
|
color: `+this.uiStyleSettings.toolboxColor+`;
|
|
`));var c=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new _e("toolbox-button-row",`
|
|
display: flex;
|
|
cursor: default;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new _e("toolbox-button-row_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new _e("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 _e("toolbox-panel-row_colors",`
|
|
background-color: `+((s=this.uiStyleSettings.toolboxBackgroundColor)!==null&&s!==void 0?s:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
|
|
`)),this.toolboxButtonStyleClass=this.styles.addClass(new _e("toolbox_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*c)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*c)+`px;
|
|
padding: `+c+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new _e("toolbox-button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new _e("toolbox-active-button_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.styles.addRule(new $e("."+this.toolboxButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new $e("."+this.toolboxButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`))},j.prototype.show=function(s){var c;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolboxStyleClass.name+" "+((c=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&c!==void 0?c:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},j.prototype.setPanelButtons=function(s){var c,R,Z=this;this.panels=s,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((c=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&c!==void 0?c:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((R=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&R!==void 0?R:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(U){var ce;U.uiStyleSettings=Z.uiStyleSettings;var Oe=document.createElement("div");Oe.className=Z.toolboxButtonStyleClass.name+" "+((ce=Z.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&ce!==void 0?ce:Z.toolboxButtonStyleColorsClass.name),Oe.innerHTML=U.icon,Oe.title=U.title,Oe.addEventListener("click",function(){Z.panelButtonClick(U)}),Z.panelButtons.push(Oe),Z.buttonRow.appendChild(Oe)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},j.prototype.panelButtonClick=function(s){var c=this,R=-1;if(s!==this.activePanel){R=this.panels.indexOf(s),this.panelRow.innerHTML="";var Z=s.getUi();Z.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(Z),this.panelRow.style.display="flex",this.panelRow.style.visibility="visible",this.panelRow.className=this.panelRow.className.replace(this.styles.fadeOutAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeInAnimationClassName,this.activePanel=s}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){c.displayMode==="inline"?c.panelRow.style.display="none":c.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(U,ce){var Oe,Ke;U.className=c.toolboxButtonStyleClass.name+" "+(ce===R?""+((Oe=c.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&Oe!==void 0?Oe:c.toolboxActiveButtonStyleColorsClass.name):""+((Ke=c.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Ke!==void 0?Ke:c.toolboxButtonStyleColorsClass.name))})},j}(),Ve=function(j,s){this.title=j,this.icon=s},ze=function(j){function s(c,R,Z,U){var ce=j.call(this,c,U||'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 01-1.5-1.5A1.5 1.5 0 0117.5 9a1.5 1.5 0 011.5 1.5 1.5 1.5 0 01-1.5 1.5m-3-4A1.5 1.5 0 0113 6.5 1.5 1.5 0 0114.5 5 1.5 1.5 0 0116 6.5 1.5 1.5 0 0114.5 8m-5 0A1.5 1.5 0 018 6.5 1.5 1.5 0 019.5 5 1.5 1.5 0 0111 6.5 1.5 1.5 0 019.5 8m-3 4A1.5 1.5 0 015 10.5 1.5 1.5 0 016.5 9 1.5 1.5 0 018 10.5 1.5 1.5 0 016.5 12M12 3a9 9 0 00-9 9 9 9 0 009 9 1.5 1.5 0 001.5-1.5c0-.39-.15-.74-.39-1-.23-.27-.38-.62-.38-1a1.5 1.5 0 011.5-1.5H16a5 5 0 005-5c0-4.42-4.03-8-9-8z"/></svg>')||this;return ce.colors=[],ce.addTransparent=!1,ce.colorBoxes=[],ce.colors=R,ce.currentColor=Z,ce.setCurrentColor=ce.setCurrentColor.bind(ce),ce.getColorBox=ce.getColorBox.bind(ce),ce}return Ce(s,j),s.prototype.getUi=function(){var c=this,R=document.createElement("div");return R.style.overflow="hidden",R.style.whiteSpace="nowrap",this.colors.forEach(function(Z){var U=c.getColorBox(Z);R.appendChild(U),c.colorBoxes.push(U)}),R},s.prototype.getColorBox=function(c){var R=this,Z=this.uiStyleSettings.toolbarHeight/4,U=this.uiStyleSettings.toolbarHeight-Z,ce=document.createElement("div");ce.style.display="inline-block",ce.style.boxSizing="content-box",ce.style.width=U-2+"px",ce.style.height=U-2+"px",ce.style.padding="1px",ce.style.marginRight="2px",ce.style.marginBottom="2px",ce.style.borderWidth="2px",ce.style.borderStyle="solid",ce.style.borderRadius=(U+2)/2+"px",ce.style.borderColor=c===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",ce.addEventListener("click",function(){R.setCurrentColor(c,ce)});var Oe=document.createElement("div");return Oe.style.display="inline-block",Oe.style.width=U-2+"px",Oe.style.height=U-2+"px",Oe.style.backgroundColor=c,Oe.style.borderRadius=U/2+"px",c==="transparent"&&(Oe.style.fill=this.uiStyleSettings.toolboxAccentColor,Oe.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>`),ce.appendChild(Oe),ce},s.prototype.setCurrentColor=function(c,R){var Z=this;this.currentColor=c,this.colorBoxes.forEach(function(U){U.style.borderColor=U===R?Z.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(c)},s}(Ve),Be=function(){function j(s,c,R){this._state="new",this._isSelected=!1,this._container=s,this._overlayContainer=c,this.globalSettings=R,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(j.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),j.prototype.ownsTarget=function(s){return!1},Object.defineProperty(j.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),j.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},j.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},j.prototype.pointerDown=function(s,c){},j.prototype.dblClick=function(s,c){},j.prototype.manipulate=function(s){},j.prototype.pointerUp=function(s){this.stateChanged()},j.prototype.dispose=function(){},j.prototype.addMarkerVisualToContainer=function(s){this.container.childNodes.length>0?this.container.insertBefore(s,this.container.childNodes[0]):this.container.appendChild(s)},j.prototype.getState=function(){return{typeName:j.typeName,state:this.state,notes:this.notes}},j.prototype.restoreState=function(s){this._state=s.state,this.notes=s.notes},j.prototype.scale=function(s,c){},j.prototype.colorChanged=function(s){this.onColorChanged&&this.onColorChanged(s),this.stateChanged()},j.prototype.fillColorChanged=function(s){this.onFillColorChanged&&this.onFillColorChanged(s),this.stateChanged()},j.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var s=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),s.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(s)&&this.onStateChanged(this)}},j.typeName="MarkerBase",j}(),Fe=function(){function j(){this.findGripByVisual=this.findGripByVisual.bind(this)}return j.prototype.findGripByVisual=function(s){return this.topLeft.ownsTarget(s)?this.topLeft:this.topCenter.ownsTarget(s)?this.topCenter:this.topRight.ownsTarget(s)?this.topRight:this.centerLeft.ownsTarget(s)?this.centerLeft:this.centerRight.ownsTarget(s)?this.centerRight:this.bottomLeft.ownsTarget(s)?this.bottomLeft:this.bottomCenter.ownsTarget(s)?this.bottomCenter:this.bottomRight.ownsTarget(s)?this.bottomRight:void 0},j}(),ot=function(){function j(){this.GRIP_SIZE=10,this.visual=oe.createGroup(),this.visual.appendChild(oe.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(oe.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return j.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},j}(),it=function(){function j(){}return j.toITransformMatrix=function(s){return{a:s.a,b:s.b,c:s.c,d:s.d,e:s.e,f:s.f}},j.toSVGMatrix=function(s,c){return s.a=c.a,s.b=c.b,s.c=c.c,s.d=c.d,s.e=c.e,s.f=c.f,s},j}(),Je=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.left=0,U.top=0,U.width=0,U.height=0,U.defaultSize={x:50,y:20},U.offsetX=0,U.offsetY=0,U.rotationAngle=0,U.CB_DISTANCE=10,U._suppressMarkerCreateEvent=!1,U.container.transform.baseVal.appendItem(oe.createTransform()),U.setupControlBox(),U}return Ce(s,j),Object.defineProperty(s.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"visual",{get:function(){return this._visual},set:function(c){this._visual=c;var R=oe.createTransform();this._visual.transform.baseVal.appendItem(R)},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(c){return!!j.prototype.ownsTarget.call(this,c)||!!(this.controlGrips.findGripByVisual(c)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(c))},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),this.state==="new"&&(this.left=c.x,this.top=c.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var Z=this.unrotatePoint(c);if(this.manipulationStartX=Z.x,this.manipulationStartY=Z.y,this.offsetX=Z.x-this.left,this.offsetY=Z.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(R),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(R)){this.activeGrip=this.rotatorGrip;var U=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=U.x-this.width/2,this.top=U.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var ce=this.container.transform.baseVal.getItem(0);ce.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(ce,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},s.prototype.pointerUp=function(c){var R=this.state;j.prototype.pointerUp.call(this,c),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(c),this._state="select",R==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},s.prototype.moveVisual=function(c){this.visual.style.transform="translate("+c.x+"px, "+c.y+"px)"},s.prototype.manipulate=function(c){var R=this.unrotatePoint(c);this.state==="creating"?this.resize(c):this.state==="move"?(this.left=this.manipulationStartLeft+(R.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(R.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(R):this.state==="rotate"&&this.rotate(c)},s.prototype.resize=function(c){var R=this.manipulationStartLeft,Z=this.manipulationStartWidth,U=this.manipulationStartTop,ce=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:R=this.manipulationStartLeft+c.x-this.manipulationStartX,Z=this.manipulationStartWidth+this.manipulationStartLeft-R;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:Z=this.manipulationStartWidth+c.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:U=this.manipulationStartTop+c.y-this.manipulationStartY,ce=this.manipulationStartHeight+this.manipulationStartTop-U;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:ce=this.manipulationStartHeight+c.y-this.manipulationStartY}Z>=0?(this.left=R,this.width=Z):(this.left=R+Z,this.width=-Z),ce>=0?(this.top=U,this.height=ce):(this.top=U+ce,this.height=-ce),this.setSize()},s.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},s.prototype.rotate=function(c){if(Math.abs(c.x-this.centerX)>.1){var R=Math.sign(c.x-this.centerX);this.rotationAngle=180*Math.atan((c.y-this.centerY)/(c.x-this.centerX))/Math.PI+90*R,this.applyRotation()}},s.prototype.applyRotation=function(){var c=this.container.transform.baseVal.getItem(0);c.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(c,0)},s.prototype.rotatePoint=function(c){if(this.rotationAngle===0)return c;var R=this.container.getCTM(),Z=oe.createPoint(c.x,c.y);return{x:(Z=Z.matrixTransform(R)).x,y:Z.y}},s.prototype.unrotatePoint=function(c){if(this.rotationAngle===0)return c;var R=this.container.getCTM();R=R.inverse();var Z=oe.createPoint(c.x,c.y);return{x:(Z=Z.matrixTransform(R)).x,y:Z.y}},s.prototype.select=function(){j.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){j.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=oe.createGroup();var c=oe.createTransform();c.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(c),this.container.appendChild(this.controlBox),this.controlRect=oe.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=oe.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 Fe,this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){var c=this.controlBox.transform.baseVal.getItem(0);c.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(c,0),this.controlRect.setAttribute("width",(this.width+this.CB_DISTANCE).toString()),this.controlRect.setAttribute("height",(this.height+this.CB_DISTANCE).toString()),this.rotatorGripLine!==void 0&&(this.rotatorGripLine.setAttribute("x1",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y1",(-this.CB_DISTANCE/2).toString()),this.rotatorGripLine.setAttribute("x2",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y2",(3*-this.CB_DISTANCE).toString())),this.positionGrips()},s.prototype.addControlGrips=function(){this.controlGrips.topLeft=this.createGrip(),this.controlGrips.topCenter=this.createGrip(),this.controlGrips.topRight=this.createGrip(),this.controlGrips.centerLeft=this.createGrip(),this.controlGrips.centerRight=this.createGrip(),this.controlGrips.bottomLeft=this.createGrip(),this.controlGrips.bottomCenter=this.createGrip(),this.controlGrips.bottomRight=this.createGrip(),this.globalSettings.disableRotation!==!0&&(this.rotatorGrip=this.createGrip()),this.positionGrips()},s.prototype.createGrip=function(){var c=new ot;return c.visual.transform.baseVal.appendItem(oe.createTransform()),this.controlBox.appendChild(c.visual),c},s.prototype.positionGrips=function(){var c=this.controlGrips.topLeft.GRIP_SIZE,R=-c/2,Z=R,U=(this.width+this.CB_DISTANCE)/2-c/2,ce=(this.height+this.CB_DISTANCE)/2-c/2,Oe=this.height+this.CB_DISTANCE-c/2,Ke=this.width+this.CB_DISTANCE-c/2;this.positionGrip(this.controlGrips.topLeft.visual,R,Z),this.positionGrip(this.controlGrips.topCenter.visual,U,Z),this.positionGrip(this.controlGrips.topRight.visual,Ke,Z),this.positionGrip(this.controlGrips.centerLeft.visual,R,ce),this.positionGrip(this.controlGrips.centerRight.visual,Ke,ce),this.positionGrip(this.controlGrips.bottomLeft.visual,R,Oe),this.positionGrip(this.controlGrips.bottomCenter.visual,U,Oe),this.positionGrip(this.controlGrips.bottomRight.visual,Ke,Oe),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,U,Z-3*this.CB_DISTANCE)},s.prototype.positionGrip=function(c,R,Z){var U=c.transform.baseVal.getItem(0);U.setTranslate(R,Z),c.transform.baseVal.replaceItem(U,0)},s.prototype.hideControlBox=function(){this.controlBox.style.display="none"},s.prototype.showControlBox=function(){this.controlBox.style.display=""},s.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:it.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:it.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},j.prototype.getState.call(this))},s.prototype.restoreState=function(c){j.prototype.restoreState.call(this,c);var R=c;this.left=R.left,this.top=R.top,this.width=R.width,this.height=R.height,this.rotationAngle=R.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(it.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,R.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(it.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,R.containerTransformMatrix))},s.prototype.scale=function(c,R){j.prototype.scale.call(this,c,R);var Z=this.rotatePoint({x:this.left,y:this.top}),U=this.unrotatePoint({x:Z.x*c,y:Z.y*R});this.left=U.x,this.top=U.y,this.width=this.width*c,this.height=this.height*R,this.adjustControlBox()},s}(Be),qe=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.fillColor="transparent",U.strokeColor="transparent",U.strokeWidth=0,U.strokeDasharray="",U.opacity=1,U.setStrokeColor=U.setStrokeColor.bind(U),U.setFillColor=U.setFillColor.bind(U),U.setStrokeWidth=U.setStrokeWidth.bind(U),U.setStrokeDasharray=U.setStrokeDasharray.bind(U),U.createVisual=U.createVisual.bind(U),U}return Ce(s,j),s.prototype.ownsTarget=function(c){return!(!j.prototype.ownsTarget.call(this,c)&&c!==this.visual)},s.prototype.createVisual=function(){this.visual=oe.createRect(1,1,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),this.state==="new"&&(this.createVisual(),this.moveVisual(c),this._state="creating")},s.prototype.manipulate=function(c){j.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){j.prototype.resize.call(this,c),this.setSize()},s.prototype.setSize=function(){j.prototype.setSize.call(this),oe.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(c){j.prototype.pointerUp.call(this,c),this.setSize()},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.visual&&oe.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(c),this.stateChanged()},s.prototype.setFillColor=function(c){this.fillColor=c,this.visual&&oe.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.visual&&oe.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.visual&&oe.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},j.prototype.getState.call(this))},s.prototype.restoreState=function(c){var R=c;this.fillColor=R.fillColor,this.strokeColor=R.strokeColor,this.strokeWidth=R.strokeWidth,this.strokeDasharray=R.strokeDasharray,this.opacity=R.opacity,this.createVisual(),j.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,R){j.prototype.scale.call(this,c,R),this.setSize()},s.title="Rectangle marker",s}(Je),ct=function(j){function s(c,R,Z,U){var ce=j.call(this,c,U||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return ce.widths=[],ce.widthBoxes=[],ce.widths=R,ce.currentWidth=Z,ce.setCurrentWidth=ce.setCurrentWidth.bind(ce),ce}return Ce(s,j),s.prototype.getUi=function(){var c=this,R=document.createElement("div");return R.style.display="flex",R.style.overflow="hidden",R.style.flexGrow="2",this.widths.forEach(function(Z){var U=document.createElement("div");U.style.display="flex",U.style.flexGrow="2",U.style.alignItems="center",U.style.justifyContent="space-between",U.style.padding="5px",U.style.borderWidth="2px",U.style.borderStyle="solid",U.style.borderColor=Z===c.currentWidth?c.uiStyleSettings.toolboxAccentColor:"transparent",U.addEventListener("click",function(){c.setCurrentWidth(Z,U)}),R.appendChild(U);var ce=document.createElement("div");ce.innerText=Z.toString(),ce.style.marginRight="5px",U.appendChild(ce);var Oe=document.createElement("div");Oe.style.minHeight="20px",Oe.style.flexGrow="2",Oe.style.display="flex",Oe.style.alignItems="center";var Ke=document.createElement("hr");Ke.style.minWidth="20px",Ke.style.border="0px",Ke.style.borderTop=Z+"px solid "+c.uiStyleSettings.toolboxColor,Ke.style.flexGrow="2",Oe.appendChild(Ke),U.appendChild(Oe),c.widthBoxes.push(U)}),R},s.prototype.setCurrentWidth=function(c,R){var Z=this;this.currentWidth=c,this.widthBoxes.forEach(function(U){U.style.borderColor=U===R?Z.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},s}(Ve),et=function(j){function s(c,R,Z,U){var ce=j.call(this,c,U||'<svg viewBox="0 0 24 24"><path d="M3 16h5v-2H3v2m6.5 0h5v-2h-5v2m6.5 0h5v-2h-5v2M3 20h2v-2H3v2m4 0h2v-2H7v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2M3 12h8v-2H3v2m10 0h8v-2h-8v2M3 4v4h18V4H3z"/></svg>')||this;return ce.styles=[],ce.styleBoxes=[],ce.styles=R,ce.currentStyle=Z,ce.setCurrentStyle=ce.setCurrentStyle.bind(ce),ce}return Ce(s,j),s.prototype.getUi=function(){var c=this,R=document.createElement("div");return R.style.display="flex",R.style.overflow="hidden",R.style.flexGrow="2",this.styles.forEach(function(Z){var U=document.createElement("div");U.style.display="flex",U.style.alignItems="center",U.style.justifyContent="space-between",U.style.padding="5px",U.style.borderWidth="2px",U.style.borderStyle="solid",U.style.overflow="hidden",U.style.maxWidth=100/c.styles.length-5+"%",U.style.borderColor=Z===c.currentStyle?c.uiStyleSettings.toolboxAccentColor:"transparent",U.addEventListener("click",function(){c.setCurrentStyle(Z,U)}),R.appendChild(U);var ce=document.createElement("div");ce.style.minHeight="20px",ce.style.flexGrow="2",ce.style.overflow="hidden";var Oe=`<svg width="100" height="20">
|
|
<line x1="0" y1="10" x2="100" y2="10" stroke="`+c.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(Z!==""?'stroke-dasharray="'+Z+'"':"")+` />
|
|
</svg>`;ce.innerHTML=Oe,U.appendChild(ce),c.styleBoxes.push(U)}),R},s.prototype.setCurrentStyle=function(c,R){var Z=this;this.currentStyle=c,this.styleBoxes.forEach(function(U){U.style.borderColor=U===R?Z.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},s}(Ve),Qe=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.strokeColor=Z.defaultColor,U.strokeWidth=Z.defaultStrokeWidth,U.strokeDasharray=Z.defaultStrokeDasharray,U.strokePanel=new ze("Line color",Z.defaultColorSet,Z.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.strokeWidthPanel=new ct("Line width",Z.defaultStrokeWidths,Z.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new et("Line style",Z.defaultStrokeDasharrays,Z.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U}return Ce(s,j),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=j.prototype.getState.call(this);return c.typeName=s.typeName,c},s.typeName="FrameMarker",s.title="Frame marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',s}(qe),we=function(){this.defaultColorSet=["#EF4444","#10B981","#2563EB","#FFFF00","#7C3AED","#F472B6","#000000","#FFFFFF"],this.defaultColor=this.defaultColorSet[0],this.defaultFillColor=this.defaultColorSet[0],this.defaultStrokeColor=this.defaultColorSet[7],this.defaultHighlightColor=this.defaultColorSet[3],this.defaultStrokeWidth=3,this.defaultStrokeDasharray="",this.defaultHighlightOpacity=.5,this.defaultFontFamily="Helvetica, Arial, sans-serif",this.defaultStrokeWidths=[1,2,3,5,10],this.defaultStrokeDasharrays=["","3","12 3","9 6 3 6"],this.defaultOpacitySteps=[.1,.25,.5,.75,1],this.displayMode="inline",this.defaultFontFamilies=['Times, "Times New Roman", serif',"Helvetica, Arial, sans-serif",'Courier, "Courier New", monospace',"cursive","fantasy"],this.popupMargin=30,this.newFreehandMarkerOnPointerUp=!1,this.defaultColorsFollowCurrentColors=!1,this.freehandPixelRatio=1,this.disableRotation=!1},lt=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.x1=0,U.y1=0,U.x2=0,U.y2=0,U.defaultLength=50,U.manipulationStartX=0,U.manipulationStartY=0,U.manipulationStartX1=0,U.manipulationStartY1=0,U.manipulationStartX2=0,U.manipulationStartY2=0,U.setupControlBox(),U}return Ce(s,j),s.prototype.ownsTarget=function(c){return!!j.prototype.ownsTarget.call(this,c)||!(!this.grip1.ownsTarget(c)&&!this.grip2.ownsTarget(c))},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),this.manipulationStartX=c.x,this.manipulationStartY=c.y,this.state==="new"&&(this.x1=c.x,this.y1=c.y,this.x2=c.x,this.y2=c.y),this.manipulationStartX1=this.x1,this.manipulationStartY1=this.y1,this.manipulationStartX2=this.x2,this.manipulationStartY2=this.y2,this.state!=="new"&&(this.select(),this.grip1.ownsTarget(R)?this.activeGrip=this.grip1:this.grip2.ownsTarget(R)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},s.prototype.pointerUp=function(c){var R=this.state;j.prototype.pointerUp.call(this,c),this.state==="creating"&&Math.abs(this.x1-this.x2)<10&&Math.abs(this.y1-this.y2)<10?(this.x2=this.x1+this.defaultLength,this.adjustVisual(),this.adjustControlBox()):this.manipulate(c),this._state="select",R==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},s.prototype.adjustVisual=function(){},s.prototype.manipulate=function(c){this.state==="creating"?this.resize(c):this.state==="move"?(this.x1=this.manipulationStartX1+c.x-this.manipulationStartX,this.y1=this.manipulationStartY1+c.y-this.manipulationStartY,this.x2=this.manipulationStartX2+c.x-this.manipulationStartX,this.y2=this.manipulationStartY2+c.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(c)},s.prototype.resize=function(c){switch(this.activeGrip){case this.grip1:this.x1=c.x,this.y1=c.y;break;case this.grip2:case void 0:this.x2=c.x,this.y2=c.y}this.adjustVisual(),this.adjustControlBox()},s.prototype.select=function(){j.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){j.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=oe.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){this.positionGrips()},s.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},s.prototype.createGrip=function(){var c=new ot;return c.visual.transform.baseVal.appendItem(oe.createTransform()),this.controlBox.appendChild(c.visual),c},s.prototype.positionGrips=function(){var c=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-c/2,this.y1-c/2),this.positionGrip(this.grip2.visual,this.x2-c/2,this.y2-c/2)},s.prototype.positionGrip=function(c,R,Z){var U=c.transform.baseVal.getItem(0);U.setTranslate(R,Z),c.transform.baseVal.replaceItem(U,0)},s.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},j.prototype.getState.call(this))},s.prototype.restoreState=function(c){j.prototype.restoreState.call(this,c);var R=c;this.x1=R.x1,this.y1=R.y1,this.x2=R.x2,this.y2=R.y2},s.prototype.scale=function(c,R){j.prototype.scale.call(this,c,R),this.x1=this.x1*c,this.y1=this.y1*R,this.x2=this.x2*c,this.y2=this.y2*R,this.adjustVisual(),this.adjustControlBox()},s}(Be),tt=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.strokeColor="transparent",U.strokeWidth=0,U.strokeDasharray="",U.setStrokeColor=U.setStrokeColor.bind(U),U.setStrokeWidth=U.setStrokeWidth.bind(U),U.setStrokeDasharray=U.setStrokeDasharray.bind(U),U.strokeColor=Z.defaultColor,U.strokeWidth=Z.defaultStrokeWidth,U.strokeDasharray=Z.defaultStrokeDasharray,U.strokePanel=new ze("Line color",Z.defaultColorSet,Z.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.strokeWidthPanel=new ct("Line width",Z.defaultStrokeWidths,Z.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new et("Line style",Z.defaultStrokeDasharrays,Z.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U}return Ce(s,j),s.prototype.ownsTarget=function(c){return!(!j.prototype.ownsTarget.call(this,c)&&c!==this.visual&&c!==this.selectorLine&&c!==this.visibleLine)},s.prototype.createVisual=function(){this.visual=oe.createGroup(),this.selectorLine=oe.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=oe.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.visual.appendChild(this.selectorLine),this.visual.appendChild(this.visibleLine),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},s.prototype.adjustVisual=function(){this.selectorLine&&this.visibleLine&&(this.selectorLine.setAttribute("x1",this.x1.toString()),this.selectorLine.setAttribute("y1",this.y1.toString()),this.selectorLine.setAttribute("x2",this.x2.toString()),this.selectorLine.setAttribute("y2",this.y2.toString()),this.visibleLine.setAttribute("x1",this.x1.toString()),this.visibleLine.setAttribute("y1",this.y1.toString()),this.visibleLine.setAttribute("x2",this.x2.toString()),this.visibleLine.setAttribute("y2",this.y2.toString()),oe.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),oe.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),oe.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.adjustVisual(),this.colorChanged(c)},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.adjustVisual()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.adjustVisual(),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},j.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){j.prototype.restoreState.call(this,c);var R=c;this.strokeColor=R.strokeColor,this.strokeWidth=R.strokeWidth,this.strokeDasharray=R.strokeDasharray,this.createVisual(),this.adjustVisual()},s.typeName="LineMarker",s.title="Line marker",s.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',s}(lt),Te=function(j){function s(c,R,Z,U){var ce=j.call(this,c,U||'<svg viewBox="0 0 24 24"><path d="M17 8h3v12h1v1h-4v-1h1v-3h-4l-1.5 3H14v1h-4v-1h1l6-12m1 1l-3.5 7H18V9M5 3h5c1.11 0 2 .89 2 2v11H9v-5H6v5H3V5c0-1.11.89-2 2-2m1 2v4h3V5H6z"/></svg>')||this;return ce.fonts=[],ce.fontBoxes=[],ce.fonts=R,ce.currentFont=Z,ce.setCurrentFont=ce.setCurrentFont.bind(ce),ce}return Ce(s,j),s.prototype.getUi=function(){var c=this,R=document.createElement("div");return R.style.overflow="hidden",R.style.flexGrow="2",this.fonts.forEach(function(Z){var U=document.createElement("div");U.style.display="inline-block",U.style.alignItems="center",U.style.justifyContent="space-between",U.style.padding="5px",U.style.borderWidth="2px",U.style.borderStyle="solid",U.style.overflow="hidden",U.style.maxWidth=100/c.fonts.length-5+"%",U.style.borderColor=Z===c.currentFont?c.uiStyleSettings.toolboxAccentColor:"transparent",U.addEventListener("click",function(){c.setCurrentFont(Z,U)}),R.appendChild(U);var ce=document.createElement("div");ce.style.display="flex",ce.style.minHeight="20px",ce.style.flexGrow="2",ce.style.fontFamily=Z,ce.style.overflow="hidden";var Oe=document.createElement("div");Oe.style.whiteSpace="nowrap",Oe.style.overflow="hidden",Oe.style.textOverflow="ellipsis",Oe.innerHTML="The quick brown fox jumps over the lazy dog",ce.appendChild(Oe),U.appendChild(ce),c.fontBoxes.push(U)}),R},s.prototype.setCurrentFont=function(c,R){var Z=this;this.currentFont=c,this.fontBoxes.forEach(function(U){U.style.borderColor=U===R?Z.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},s}(Ve),Le=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.color="transparent",U.padding=5,U.DEFAULT_TEXT="your text here",U.text=U.DEFAULT_TEXT,U.isMoved=!1,U.color=Z.defaultColor,U.fontFamily=Z.defaultFontFamily,U.defaultSize={x:100,y:30},U.setColor=U.setColor.bind(U),U.setFont=U.setFont.bind(U),U.renderText=U.renderText.bind(U),U.sizeText=U.sizeText.bind(U),U.textEditDivClicked=U.textEditDivClicked.bind(U),U.showTextEditor=U.showTextEditor.bind(U),U.setSize=U.setSize.bind(U),U.positionTextEditor=U.positionTextEditor.bind(U),U.colorPanel=new ze("Color",Z.defaultColorSet,Z.defaultColor),U.colorPanel.onColorChanged=U.setColor,U.fontFamilyPanel=new Te("Font",Z.defaultFontFamilies,Z.defaultFontFamily),U.fontFamilyPanel.onFontChanged=U.setFont,U}return Ce(s,j),s.prototype.ownsTarget=function(c){if(j.prototype.ownsTarget.call(this,c)||c===this.visual||c===this.textElement||c===this.bgRectangle)return!0;var R=!1;return this.textElement.childNodes.forEach(function(Z){Z===c&&(R=!0)}),R},s.prototype.createVisual=function(){this.visual=oe.createGroup(),this.bgRectangle=oe.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=oe.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(oe.createTransform()),this.textElement.transform.baseVal.appendItem(oe.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),this.isMoved=!1,this.pointerDownPoint=c,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(c),this._state="creating")},s.prototype.renderText=function(){var c=this;if(this.textElement){for(;this.textElement.lastChild;)this.textElement.removeChild(this.textElement.lastChild);this.text.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/).forEach(function(R){c.textElement.appendChild(oe.createTSpan(R.trim()===""?" ":R.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},s.prototype.getTextScale=function(){var c=this.textElement.getBBox(),R=1;if(c.width>0&&c.height>0){var Z=(1*this.width-this.width*this.padding*2/100)/c.width,U=(1*this.height-this.height*this.padding*2/100)/c.height;R=Math.min(Z,U)}return R},s.prototype.getTextPosition=function(c){var R=this.textElement.getBBox(),Z=0,U=0;return R.width>0&&R.height>0&&(Z=(this.width-R.width*c)/2,U=this.height/2-R.height*c/2),{x:Z,y:U}},s.prototype.sizeText=function(){var c=this.textElement.getBBox(),R=this.getTextScale(),Z=this.getTextPosition(R);Z.y-=c.y*R,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+Z.x+"px, "+Z.y+"px) scale("+R+", "+R+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(Z.x,Z.y),this.textElement.transform.baseVal.getItem(1).setScale(R,R))},s.prototype.manipulate=function(c){j.prototype.manipulate.call(this,c),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(c.x-this.pointerDownPoint.x)>5||Math.abs(c.y-this.pointerDownPoint.y)>5)},s.prototype.resize=function(c){j.prototype.resize.call(this,c),this.isMoved=!0,this.setSize(),this.sizeText()},s.prototype.setSize=function(){j.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(oe.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),oe.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},s.prototype.pointerUp=function(c){var R=this.state;R==="creating"&&(this._suppressMarkerCreateEvent=!0),j.prototype.pointerUp.call(this,c),this.setSize(),(R==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},s.prototype.showTextEditor=function(){var c=this;this._state="edit",this.overlayContainer.innerHTML="",this.textEditDiv=document.createElement("div"),this.textEditDiv.style.flexGrow="2",this.textEditDiv.style.alignItems="center",this.textEditDiv.style.justifyContent="center",this.textEditDiv.style.pointerEvents="auto",this.textEditDiv.style.overflow="hidden",this.textEditor=document.createElement("div"),this.textEditor.style.position="absolute",this.textEditor.style.fontFamily=this.fontFamily,this.textEditor.style.lineHeight="1em",this.textEditor.innerText=this.text,this.textEditor.contentEditable="true",this.textEditor.style.color=this.color,this.textEditor.style.whiteSpace="pre",this.positionTextEditor(),this.textEditor.addEventListener("pointerup",function(R){R.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var R=Number.parseFloat(c.textEditor.style.fontSize);c.textEditor.clientWidth>=Number.parseInt(c.textEditor.style.maxWidth)&&R>.9;)R-=.1,c.textEditor.style.fontSize=Math.max(R,.9)+"em"}),this.textEditor.addEventListener("keyup",function(R){R.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(R){if(R.clipboardData){var Z=R.clipboardData.getData("text"),U=window.getSelection();if(!U.rangeCount)return!1;U.deleteFromDocument(),U.getRangeAt(0).insertNode(document.createTextNode(Z)),R.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){c.textEditDivClicked(c.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},s.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var c=this.getTextScale(),R=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),Z=this.textElement.getBBox(),U={x:Z.width*c,y:Z.height*c};R.x-=U.x/2,R.y-=U.y/2,this.textEditor.style.top=R.y+"px",this.textEditor.style.left=R.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-R.x+"px",this.textEditor.style.fontSize=Math.max(16*c,12)+"px",this.textElement.style.display="none"}},s.prototype.textEditDivClicked=function(c){this.text=c.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},s.prototype.select=function(){j.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},s.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),j.prototype.deselect.call(this)},s.prototype.dblClick=function(c,R){j.prototype.dblClick.call(this,c,R),this.showTextEditor()},s.prototype.setColor=function(c){this.textElement&&oe.setAttributes(this.textElement,[["fill",c]]),this.color=c,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(c)},s.prototype.setFont=function(c){this.textElement&&oe.setAttributes(this.textElement,[["font-family",c]]),this.fontFamily=c,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},s.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},s.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},j.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){var R=c;this.color=R.color,this.fontFamily=R.fontFamily,this.padding=R.padding,this.text=R.text,this.createVisual(),j.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,R){j.prototype.scale.call(this,c,R),this.setSize(),this.sizeText(),this.positionTextEditor()},s.typeName="TextMarker",s.title="Text marker",s.icon='<svg viewBox="0 0 24 24"><path d="M9.6 14L12 7.7l2.4 6.3M11 5L5.5 19h2.2l1.1-3H15l1.1 3h2.2L13 5h-2z"/></svg>',s}(Je),fe=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.color="transparent",U.lineWidth=3,U.drawing=!1,U.pixelRatio=1,U.color=Z.defaultColor,U.lineWidth=Z.defaultStrokeWidth,U.pixelRatio=Z.freehandPixelRatio,U.setColor=U.setColor.bind(U),U.addCanvas=U.addCanvas.bind(U),U.finishCreation=U.finishCreation.bind(U),U.setLineWidth=U.setLineWidth.bind(U),U.colorPanel=new ze("Color",Z.defaultColorSet,Z.defaultColor),U.colorPanel.onColorChanged=U.setColor,U.lineWidthPanel=new ct("Line width",Z.defaultStrokeWidths,Z.defaultStrokeWidth),U.lineWidthPanel.onWidthChanged=U.setLineWidth,U}return Ce(s,j),s.prototype.ownsTarget=function(c){return!(!j.prototype.ownsTarget.call(this,c)&&c!==this.visual&&c!==this.drawingImage)},s.prototype.createVisual=function(){this.visual=oe.createGroup(),this.drawingImage=oe.createImage(),this.visual.appendChild(this.drawingImage);var c=oe.createTransform();this.visual.transform.baseVal.appendItem(c),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,R){this.state==="new"&&(this.addCanvas(),this.createVisual(),this._state="creating"),this.state==="creating"?(this.canvasContext.strokeStyle=this.color,this.canvasContext.lineWidth=this.lineWidth,this.canvasContext.beginPath(),this.canvasContext.moveTo(c.x,c.y),this.drawing=!0):j.prototype.pointerDown.call(this,c,R)},s.prototype.manipulate=function(c){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(c.x,c.y),this.canvasContext.stroke()):j.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){j.prototype.resize.call(this,c),oe.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),oe.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(c){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):j.prototype.pointerUp.call(this,c)},s.prototype.addCanvas=function(){this.overlayContainer.innerHTML="",this.canvasElement=document.createElement("canvas"),this.canvasElement.width=this.overlayContainer.clientWidth*this.pixelRatio,this.canvasElement.height=this.overlayContainer.clientHeight*this.pixelRatio,this.canvasContext=this.canvasElement.getContext("2d"),this.canvasContext.scale(this.pixelRatio,this.pixelRatio),this.overlayContainer.appendChild(this.canvasElement)},s.prototype.select=function(){this.state==="creating"&&this.finishCreation(),j.prototype.select.call(this)},s.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),j.prototype.deselect.call(this)},s.prototype.finishCreation=function(){for(var c=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),R=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],Z=R[0],U=R[1],ce=R[2],Oe=R[3],Ke=!1,dt=0;dt<this.canvasElement.height;dt++)for(var Me=0;Me<this.canvasElement.width;Me++)c.data[dt*this.canvasElement.width*4+4*Me+3]>0&&(Ke=!0,dt<U&&(U=dt),Me<Z&&(Z=Me),dt>Oe&&(Oe=dt),Me>ce&&(ce=Me));if(Ke){this.left=Z/this.pixelRatio,this.top=U/this.pixelRatio,this.width=(ce-Z)/this.pixelRatio,this.height=(Oe-U)/this.pixelRatio;var vt=document.createElement("canvas");vt.width=ce-Z,vt.height=Oe-U,vt.getContext("2d").putImageData(this.canvasContext.getImageData(Z,U,ce-Z,Oe-U),0,0),this.drawingImgUrl=vt.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},s.prototype.setDrawingImage=function(){oe.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),oe.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},s.prototype.setColor=function(c){this.color=c,this.colorChanged(c)},s.prototype.setLineWidth=function(c){this.lineWidth=c},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({drawingImgUrl:this.drawingImgUrl},j.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){this.createVisual(),j.prototype.restoreState.call(this,c),this.drawingImgUrl=c.drawingImgUrl,this.setDrawingImage()},s.prototype.scale=function(c,R){j.prototype.scale.call(this,c,R),this.setDrawingImage()},s.typeName="FreehandMarker",s.title="Freehand marker",s.icon='<svg viewBox="0 0 24 24"><path d="M9.75 20.85c1.78-.7 1.39-2.63.49-3.85-.89-1.25-2.12-2.11-3.36-2.94A9.817 9.817 0 014.54 12c-.28-.33-.85-.94-.27-1.06.59-.12 1.61.46 2.13.68.91.38 1.81.82 2.65 1.34l1.01-1.7C8.5 10.23 6.5 9.32 4.64 9.05c-1.06-.16-2.18.06-2.54 1.21-.32.99.19 1.99.77 2.77 1.37 1.83 3.5 2.71 5.09 4.29.34.33.75.72.95 1.18.21.44.16.47-.31.47-1.24 0-2.79-.97-3.8-1.61l-1.01 1.7c1.53.94 4.09 2.41 5.96 1.79m11.09-15.6c.22-.22.22-.58 0-.79l-1.3-1.3a.562.562 0 00-.78 0l-1.02 1.02 2.08 2.08M11 10.92V13h2.08l6.15-6.15-2.08-2.08L11 10.92z"/></svg>',s}(Je),le=function(j){function s(c,R,Z){var U=j.call(this,c,Z||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return U.typeBoxes=[],U.currentType=R,U.setCurrentType=U.setCurrentType.bind(U),U}return Ce(s,j),s.prototype.getUi=function(){var c=this,R=document.createElement("div");R.style.display="flex",R.style.overflow="hidden",R.style.flexGrow="2";for(var Z=function(Oe){var Ke="both";switch(Oe){case 0:Ke="both";break;case 1:Ke="start";break;case 2:Ke="end";break;case 3:Ke="none"}var dt=document.createElement("div");if(dt.style.display="flex",dt.style.flexGrow="2",dt.style.alignItems="center",dt.style.justifyContent="space-between",dt.style.padding="5px",dt.style.borderWidth="2px",dt.style.borderStyle="solid",dt.style.borderColor=Ke===U.currentType?U.uiStyleSettings.toolboxAccentColor:"transparent",dt.addEventListener("click",function(){c.setCurrentType(Ke,dt)}),R.appendChild(dt),Ke==="both"||Ke==="start"){var Me=document.createElement("div");Me.style.display="flex",Me.style.alignItems="center",Me.style.minHeight="20px",Me.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
|
|
<polygon points="0,5 10,0 10,10" fill="`+(U.uiStyleSettings!==void 0?U.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,Me.style.marginLeft="5px",dt.appendChild(Me)}var vt=document.createElement("div");vt.style.display="flex",vt.style.alignItems="center",vt.style.minHeight="20px",vt.style.flexGrow="2";var Nt=document.createElement("hr");if(Nt.style.minWidth="20px",Nt.style.border="0px",Nt.style.borderTop="3px solid "+(U.uiStyleSettings!==void 0?U.uiStyleSettings.toolboxColor:"#eeeeee"),Nt.style.flexGrow="2",vt.appendChild(Nt),dt.appendChild(vt),Ke==="both"||Ke==="end"){var Kt=document.createElement("div");Kt.style.display="flex",Kt.style.alignItems="center",Kt.style.minHeight="20px",Kt.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
|
|
<polygon points="0,0 10,5 0,10" fill="`+(U.uiStyleSettings!==void 0?U.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,Kt.style.marginRight="5px",dt.appendChild(Kt)}U.typeBoxes.push(dt)},U=this,ce=0;ce<4;ce++)Z(ce);return R},s.prototype.setCurrentType=function(c,R){var Z=this;this.currentType=c,this.typeBoxes.forEach(function(U){U.style.borderColor=U===R?Z.uiStyleSettings!==void 0?Z.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},s}(Ve),ue=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.arrowType="end",U.arrowBaseHeight=10,U.arrowBaseWidth=10,U.getArrowPoints=U.getArrowPoints.bind(U),U.setArrowType=U.setArrowType.bind(U),U.arrowTypePanel=new le("Arrow type","end"),U.arrowTypePanel.onArrowTypeChanged=U.setArrowType,U}return Ce(s,j),s.prototype.ownsTarget=function(c){return!(!j.prototype.ownsTarget.call(this,c)&&c!==this.arrow1&&c!==this.arrow2)},s.prototype.getArrowPoints=function(c,R){var Z=this.arrowBaseWidth+2*this.strokeWidth,U=this.arrowBaseHeight+2*this.strokeWidth;return c-Z/2+","+(R+U/2)+" "+c+","+(R-U/2)+" "+(c+Z/2)+","+(R+U/2)},s.prototype.createTips=function(){this.arrow1=oe.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(oe.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=oe.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(oe.createTransform()),this.visual.appendChild(this.arrow2)},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(j.prototype.adjustVisual.call(this),this.arrow1&&this.arrow2&&(this.arrow1.style.display=this.arrowType==="both"||this.arrowType==="start"?"":"none",this.arrow2.style.display=this.arrowType==="both"||this.arrowType==="end"?"":"none",oe.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),oe.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var c=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),R=this.arrow1.transform.baseVal.getItem(0);R.setRotate(c,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(R,0);var Z=this.arrow2.transform.baseVal.getItem(0);Z.setRotate(c+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(Z,0)}},s.prototype.setArrowType=function(c){this.arrowType=c,this.adjustVisual(),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({arrowType:this.arrowType},j.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){j.prototype.restoreState.call(this,c);var R=c;this.arrowType=R.arrowType,this.createTips(),this.adjustVisual()},s.typeName="ArrowMarker",s.title="Arrow marker",s.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',s}(tt),q=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.fillColor=Z.defaultFillColor,U.strokeWidth=0,U.fillPanel=new ze("Color",Z.defaultColorSet,Z.defaultFillColor),U.fillPanel.onColorChanged=U.setFillColor,U}return Ce(s,j),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=j.prototype.getState.call(this);return c.typeName=s.typeName,c},s.typeName="CoverMarker",s.title="Cover marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',s}(qe),te=function(j){function s(c,R,Z,U){var ce=j.call(this,c,U||'<svg viewBox="0 0 24 24"><path d="M17.66 8L12 2.35 6.34 8A8.02 8.02 0 004 13.64c0 2 .78 4.11 2.34 5.67a7.99 7.99 0 0011.32 0c1.56-1.56 2.34-3.67 2.34-5.67S19.22 9.56 17.66 8M6 14c0-2 .62-3.27 1.76-4.4L12 5.27l4.24 4.38C17.38 10.77 18 12 18 14H6z"/></svg>')||this;return ce.opacities=[],ce.opacityBoxes=[],ce.opacities=R,ce.currentOpacity=Z,ce.setCurrentOpacity=ce.setCurrentOpacity.bind(ce),ce}return Ce(s,j),s.prototype.getUi=function(){var c=this,R=document.createElement("div");return R.style.display="flex",R.style.overflow="hidden",R.style.flexGrow="2",R.style.justifyContent="space-between",this.opacities.forEach(function(Z){var U=document.createElement("div");U.style.display="flex",U.style.alignItems="center",U.style.justifyContent="center",U.style.padding="5px",U.style.borderWidth="2px",U.style.borderStyle="solid",U.style.borderColor=Z===c.currentOpacity?c.uiStyleSettings.toolboxAccentColor:"transparent",U.addEventListener("click",function(){c.setCurrentOpacity(Z,U)}),R.appendChild(U);var ce=document.createElement("div");ce.innerText=100*Z+"%",U.appendChild(ce),c.opacityBoxes.push(U)}),R},s.prototype.setCurrentOpacity=function(c,R){var Z=this;this.currentOpacity=c,this.opacityBoxes.forEach(function(U){U.style.borderColor=U===R?Z.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},s}(Ve),ie=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.setOpacity=U.setOpacity.bind(U),U.fillColor=Z.defaultHighlightColor,U.strokeWidth=0,U.opacity=Z.defaultHighlightOpacity,U.fillPanel=new ze("Color",Z.defaultColorSet,U.fillColor),U.fillPanel.onColorChanged=U.setFillColor,U.opacityPanel=new te("Opacity",Z.defaultOpacitySteps,U.opacity),U.opacityPanel.onOpacityChanged=U.setOpacity,U}return Ce(s,j),s.prototype.setOpacity=function(c){this.opacity=c,this.visual&&oe.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=j.prototype.getState.call(this);return c.typeName=s.typeName,c},s.typeName="HighlightMarker",s.title="Highlight marker",s.icon='<svg viewBox="0 0 24 24"><path d="M18.5 1.15c-.53 0-1.04.19-1.43.58l-5.81 5.82 5.65 5.65 5.82-5.81c.77-.78.77-2.04 0-2.83l-2.84-2.83c-.39-.39-.89-.58-1.39-.58M10.3 8.5l-5.96 5.96c-.78.78-.78 2.04.02 2.85C3.14 18.54 1.9 19.77.67 21h5.66l.86-.86c.78.76 2.03.75 2.81-.02l5.95-5.96"/></svg>',s}(q),de='<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>',me=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.bgColor="transparent",U.tipPosition={x:0,y:0},U.tipBase1Position={x:0,y:0},U.tipBase2Position={x:0,y:0},U.tipMoving=!1,U.color=Z.defaultStrokeColor,U.bgColor=Z.defaultFillColor,U.fontFamily=Z.defaultFontFamily,U.defaultSize={x:100,y:30},U.setBgColor=U.setBgColor.bind(U),U.getTipPoints=U.getTipPoints.bind(U),U.positionTip=U.positionTip.bind(U),U.setTipPoints=U.setTipPoints.bind(U),U.colorPanel=new ze("Text color",Z.defaultColorSet,U.color,'<svg viewBox="0 0 24 24"><path d="M9.62 12L12 5.67 14.37 12M11 3L5.5 17h2.25l1.12-3h6.25l1.13 3h2.25L13 3h-2z"/></svg>'),U.colorPanel.onColorChanged=U.setColor,U.bgColorPanel=new ze("Fill color",Z.defaultColorSet,U.bgColor,de),U.bgColorPanel.onColorChanged=U.setBgColor,U.fontFamilyPanel=new Te("Font",Z.defaultFontFamilies,Z.defaultFontFamily),U.fontFamilyPanel.onFontChanged=U.setFont,U.tipGrip=new ot,U.tipGrip.visual.transform.baseVal.appendItem(oe.createTransform()),U.controlBox.appendChild(U.tipGrip.visual),U}return Ce(s,j),s.prototype.ownsTarget=function(c){return j.prototype.ownsTarget.call(this,c)||this.tipGrip.ownsTarget(c)||this.tip===c},s.prototype.createTip=function(){oe.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=oe.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},s.prototype.pointerDown=function(c,R){this.state==="new"&&j.prototype.pointerDown.call(this,c,R),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(R)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):j.prototype.pointerDown.call(this,c,R)},s.prototype.pointerUp=function(c){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,j.prototype.pointerUp.call(this,c);else{var R=this.state==="creating";j.prototype.pointerUp.call(this,c),this.setTipPoints(R),this.positionTip()}},s.prototype.manipulate=function(c){if(this.tipMoving){var R=this.unrotatePoint(c);this.tipPosition={x:R.x-this.manipulationStartLeft,y:R.y-this.manipulationStartTop},this.positionTip()}else j.prototype.manipulate.call(this,c)},s.prototype.setBgColor=function(c){this.bgRectangle&&this.tip&&(oe.setAttributes(this.bgRectangle,[["fill",c]]),oe.setAttributes(this.tip,[["fill",c]])),this.bgColor=c,this.fillColorChanged(c)},s.prototype.getTipPoints=function(){return this.setTipPoints(this.state==="creating"),this.tipBase1Position.x+","+this.tipBase1Position.y+" "+this.tipBase2Position.x+","+this.tipBase2Position.y+" "+this.tipPosition.x+","+this.tipPosition.y},s.prototype.setTipPoints=function(c){c===void 0&&(c=!1);var R=Math.min(this.height/2,15),Z=this.height/5;c&&(this.tipPosition={x:R+Z/2,y:this.height+20});var U=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?U<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(Z=this.width/5,R=Math.min(this.width/2,15),this.tipBase1Position={x:R,y:0},this.tipBase2Position={x:R+Z,y:0}):(this.tipBase1Position={x:0,y:R},this.tipBase2Position={x:0,y:R+Z}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?U<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(Z=this.width/5,R=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-R-Z,y:0},this.tipBase2Position={x:this.width-R,y:0}):(this.tipBase1Position={x:this.width,y:R},this.tipBase2Position={x:this.width,y:R+Z}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?U<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(Z=this.width/5,R=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-R-Z,y:this.height},this.tipBase2Position={x:this.width-R,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-R-Z},this.tipBase2Position={x:this.width,y:this.height-R}):U<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(Z=this.width/5,R=Math.min(this.width/2,15),this.tipBase1Position={x:R,y:this.height},this.tipBase2Position={x:R+Z,y:this.height}):(this.tipBase1Position={x:0,y:this.height-R},this.tipBase2Position={x:0,y:this.height-R-Z})},s.prototype.resize=function(c){j.prototype.resize.call(this,c),this.positionTip()},s.prototype.positionTip=function(){oe.setAttributes(this.tip,[["points",this.getTipPoints()]]);var c=this.tipGrip.visual.transform.baseVal.getItem(0);c.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(c,0)},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),s.prototype.select=function(){this.positionTip(),j.prototype.select.call(this)},s.prototype.getState=function(){var c=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},j.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){var R=c;this.bgColor=R.bgColor,this.tipPosition=R.tipPosition,j.prototype.restoreState.call(this,c),this.createTip(),this.setTipPoints()},s.prototype.scale=function(c,R){j.prototype.scale.call(this,c,R),this.tipPosition={x:this.tipPosition.x*c,y:this.tipPosition.y*R},this.positionTip()},s.typeName="CalloutMarker",s.title="Callout marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 2h16a2 2 0 012 2v12a2 2 0 01-2 2h-4l-4 4-4-4H4a2 2 0 01-2-2V4a2 2 0 012-2m0 2v12h4.83L12 19.17 15.17 16H20V4H4m2 3h12v2H6V7m0 4h10v2H6v-2z"/></svg>',s}(Le),Ee=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.fillColor="transparent",U.strokeColor="transparent",U.strokeWidth=0,U.strokeDasharray="",U.opacity=1,U.strokeColor=Z.defaultColor,U.strokeWidth=Z.defaultStrokeWidth,U.strokeDasharray=Z.defaultStrokeDasharray,U.fillColor=Z.defaultFillColor,U.setStrokeColor=U.setStrokeColor.bind(U),U.setFillColor=U.setFillColor.bind(U),U.setStrokeWidth=U.setStrokeWidth.bind(U),U.setStrokeDasharray=U.setStrokeDasharray.bind(U),U.setOpacity=U.setOpacity.bind(U),U.createVisual=U.createVisual.bind(U),U.strokePanel=new ze("Line color",ge(Z.defaultColorSet,["transparent"]),Z.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.fillPanel=new ze("Fill color",ge(Z.defaultColorSet,["transparent"]),U.fillColor,de),U.fillPanel.onColorChanged=U.setFillColor,U.strokeWidthPanel=new ct("Line width",Z.defaultStrokeWidths,Z.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new et("Line style",Z.defaultStrokeDasharrays,Z.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U.opacityPanel=new te("Opacity",Z.defaultOpacitySteps,U.opacity),U.opacityPanel.onOpacityChanged=U.setOpacity,U}return Ce(s,j),s.prototype.ownsTarget=function(c){return!(!j.prototype.ownsTarget.call(this,c)&&c!==this.visual)},s.prototype.createVisual=function(){this.visual=oe.createEllipse(this.width/2,this.height/2,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),this.state==="new"&&(this.createVisual(),this.moveVisual(c),this._state="creating")},s.prototype.manipulate=function(c){j.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){j.prototype.resize.call(this,c),this.setSize()},s.prototype.setSize=function(){j.prototype.setSize.call(this),oe.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},s.prototype.pointerUp=function(c){j.prototype.pointerUp.call(this,c),this.setSize()},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.visual&&oe.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(c),this.stateChanged()},s.prototype.setFillColor=function(c){this.fillColor=c,this.visual&&oe.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(c),this.stateChanged()},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.visual&&oe.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.visual&&oe.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.setOpacity=function(c){this.opacity=c,this.visual&&oe.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},j.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){var R=c;this.fillColor=R.fillColor,this.strokeColor=R.strokeColor,this.strokeWidth=R.strokeWidth,this.strokeDasharray=R.strokeDasharray,this.opacity=R.opacity,this.createVisual(),j.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,R){j.prototype.scale.call(this,c,R),this.setSize()},s.typeName="EllipseMarker",s.title="Ellipse marker",s.icon='<svg viewBox="0 0 24 24"><path d="M12 4C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',s}(Je),Pe=function(j){function s(c,R,Z){return j.call(this,c,R,Z)||this}return Ce(s,j),Object.defineProperty(s.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(c){return!(!j.prototype.ownsTarget.call(this,c)&&c!==this.tip1&&c!==this.tip2)},s.prototype.createTips=function(){this.tip1=oe.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(oe.createTransform()),this.visual.appendChild(this.tip1),this.tip2=oe.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(oe.createTransform()),this.visual.appendChild(this.tip2)},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(j.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(oe.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()]]),oe.setAttributes(this.tip2,[["x1",(this.x2-this.tipLength/2).toString()],["y1",this.y2.toString()],["x2",(this.x2+this.tipLength/2).toString()],["y2",this.y2.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),Math.abs(this.x1-this.x2)>.1)){var c=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),R=this.tip1.transform.baseVal.getItem(0);R.setRotate(c,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(R,0);var Z=this.tip2.transform.baseVal.getItem(0);Z.setRotate(c+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(Z,0)}},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=j.prototype.getState.call(this);return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){j.prototype.restoreState.call(this,c),this.createTips(),this.adjustVisual()},s.typeName="MeasurementMarker",s.title="Measurement marker",s.icon='<svg viewBox="0 0 24 24"><path d="M1.39 18.36l1.77-1.76L4.58 18l1.06-1.05-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.42 1.41L10.59 12l-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.41 1.41 1.07-1.06-1.42-1.41 1.42-1.42L18 6.7l1.07-1.06-2.47-2.48 1.76-1.77 4.25 4.25L5.64 22.61l-4.25-4.25z"/></svg>',s}(tt),rt=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.strokePanel.colors=Z.defaultColorSet,U.fillColor="transparent",U}return Ce(s,j),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=j.prototype.getState.call(this);return c.typeName=s.typeName,c},s.typeName="EllipseFrameMarker",s.title="Ellipse frame marker",s.icon='<svg viewBox="0 0 24 24"><path d="M12 6c4.41 0 8 2.69 8 6s-3.59 6-8 6-8-2.69-8-6 3.59-6 8-6m0-2C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',s}(Ee),mt=function(){function j(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(j.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),j.prototype.addUndoStep=function(s){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(s)||(this.undoStack.push(s),JSON.stringify(this.lastRedoStep)!==JSON.stringify(s)&&this.redoStack.splice(0,this.redoStack.length))},j.prototype.replaceLastUndoStep=function(s){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=s)},j.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},j.prototype.undo=function(){if(this.undoStack.length>1){var s=this.undoStack.pop();return s!==void 0&&this.redoStack.push(s),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},j.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},j}(),ft=function(j){function s(c,R,Z){var U=j.call(this,c,R,Z)||this;return U.strokeColor="transparent",U.strokeWidth=0,U.strokeDasharray="",U.curveX=0,U.curveY=0,U.manipulationStartCurveX=0,U.manipulationStartCurveY=0,U.setStrokeColor=U.setStrokeColor.bind(U),U.setStrokeWidth=U.setStrokeWidth.bind(U),U.setStrokeDasharray=U.setStrokeDasharray.bind(U),U.positionGrips=U.positionGrips.bind(U),U.addControlGrips=U.addControlGrips.bind(U),U.adjustVisual=U.adjustVisual.bind(U),U.setupControlBox=U.setupControlBox.bind(U),U.resize=U.resize.bind(U),U.strokeColor=Z.defaultColor,U.strokeWidth=Z.defaultStrokeWidth,U.strokeDasharray=Z.defaultStrokeDasharray,U.strokePanel=new ze("Line color",Z.defaultColorSet,Z.defaultColor),U.strokePanel.onColorChanged=U.setStrokeColor,U.strokeWidthPanel=new ct("Line width",Z.defaultStrokeWidths,Z.defaultStrokeWidth),U.strokeWidthPanel.onWidthChanged=U.setStrokeWidth,U.strokeStylePanel=new et("Line style",Z.defaultStrokeDasharrays,Z.defaultStrokeDasharray),U.strokeStylePanel.onStyleChanged=U.setStrokeDasharray,U}return Ce(s,j),s.prototype.ownsTarget=function(c){return!(!j.prototype.ownsTarget.call(this,c)&&c!==this.visual&&c!==this.selectorCurve&&c!==this.visibleCurve&&!this.curveGrip.ownsTarget(c))},s.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},s.prototype.createVisual=function(){this.visual=oe.createGroup(),this.selectorCurve=oe.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=oe.createPath(this.getPathD(),[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["fill","transparent"]]),this.visual.appendChild(this.selectorCurve),this.visual.appendChild(this.visibleCurve),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,R){j.prototype.pointerDown.call(this,c,R),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=c.x,this.curveY=c.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(R)&&(this.activeGrip=this.curveGrip,this._state="resize")},s.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),oe.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),oe.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),oe.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setupControlBox=function(){j.prototype.setupControlBox.call(this),this.curveControlLine1=oe.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=oe.createLine(this.x2,this.y2,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.insertBefore(this.curveControlLine1,this.controlBox.firstChild),this.controlBox.insertBefore(this.curveControlLine2,this.controlBox.firstChild)},s.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,j.prototype.addControlGrips.call(this)},s.prototype.positionGrips=function(){j.prototype.positionGrips.call(this);var c=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-c/2,this.curveY-c/2),this.curveControlLine1&&this.curveControlLine2&&(this.curveControlLine1.setAttribute("x1",this.x1.toString()),this.curveControlLine1.setAttribute("y1",this.y1.toString()),this.curveControlLine1.setAttribute("x2",this.curveX.toString()),this.curveControlLine1.setAttribute("y2",this.curveY.toString()),this.curveControlLine2.setAttribute("x1",this.x2.toString()),this.curveControlLine2.setAttribute("y1",this.y2.toString()),this.curveControlLine2.setAttribute("x2",this.curveX.toString()),this.curveControlLine2.setAttribute("y2",this.curveY.toString()))},s.prototype.manipulate=function(c){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+c.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+c.y-this.manipulationStartY),j.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){this.activeGrip===this.curveGrip&&(this.curveX=c.x,this.curveY=c.y),j.prototype.resize.call(this,c),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.adjustVisual(),this.colorChanged(c)},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.adjustVisual()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.adjustVisual()},s.prototype.scale=function(c,R){this.curveX=this.curveX*c,this.curveY=this.curveY*R,j.prototype.scale.call(this,c,R)},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},j.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){j.prototype.restoreState.call(this,c);var R=c;this.strokeColor=R.strokeColor,this.strokeWidth=R.strokeWidth,this.strokeDasharray=R.strokeDasharray,this.curveX=R.curveX,this.curveY=R.curveY,this.createVisual(),this.adjustVisual()},s.typeName="CurveMarker",s.title="Curve marker",s.icon='<svg viewBox="0 0 24 24"><path d="M18.5 2A1.5 1.5 0 0120 3.5 1.5 1.5 0 0118.5 5c-.23 0-.45-.05-.65-.15l-3.69 3.7.34.45c2.19-1.26 4.76-2 7.5-2l1 .03v2.01L22 9c-2.58 0-5 .75-7 2.04A3.96 3.96 0 0111.04 15C9.75 17 9 19.42 9 22l.04 1H7.03L7 22c0-2.74.74-5.31 2-7.5l-.45-.34-3.7 3.69c.1.2.15.42.15.65A1.5 1.5 0 013.5 20 1.5 1.5 0 012 18.5 1.5 1.5 0 013.5 17c.23 0 .45.05.65.15l3.69-3.7C7.31 12.78 7 11.92 7 11a4 4 0 014-4c.92 0 1.78.31 2.45.84l3.7-3.69c-.1-.2-.15-.42-.15-.65A1.5 1.5 0 0118.5 2M11 9a2 2 0 00-2 2 2 2 0 002 2 2 2 0 002-2 2 2 0 00-2-2z"/></svg>',s}(lt),wt=function(){function j(s,c){c===void 0&&(c=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=s,this.cancelable=c}return Object.defineProperty(j.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),j.prototype.preventDefault=function(){this._defaultPrevented=!0},j}(),Tt=function(j){function s(c,R,Z){var U=j.call(this,c,!1)||this;return U.dataUrl=R,U.state=Z,U}return Ce(s,j),s}(wt),ut=function(j){function s(c,R,Z){Z===void 0&&(Z=!1);var U=j.call(this,c,Z)||this;return U.marker=R,U}return Ce(s,j),s}(wt),Ft=function(){function j(){this.render=[],this.beforeclose=[],this.close=[],this.show=[],this.restorestate=[],this.statechange=[],this.markerselect=[],this.markerdeselect=[],this.markercreating=[],this.markercreate=[],this.markerbeforedelete=[],this.markerdelete=[],this.markerchange=[],this.focus=[],this.blur=[]}return j.prototype.addEventListener=function(s,c){this[s].push(c)},j.prototype.removeEventListener=function(s,c){var R=this[s].indexOf(c);R>-1&&this[s].splice(R,1)},j}(),Ot=function(){function j(s){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new we,this._isOpen=!1,this.undoRedoManager=new mt,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 Ft,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=j.instanceCounter++,this.styles=new Ge(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=s,this.targetRoot=document.body,this.width=s.clientWidth,this.height=s.clientHeight,this.styles.removeStyleSheet(),this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.toolbarButtonClicked=this.toolbarButtonClicked.bind(this),this.createNewMarker=this.createNewMarker.bind(this),this.addNewMarker=this.addNewMarker.bind(this),this.markerCreated=this.markerCreated.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onDblClick=this.onDblClick.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOut=this.onPointerOut.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.deleteSelectedMarker=this.deleteSelectedMarker.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.removeMarker=this.removeMarker.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this),this.onPopupTargetResize=this.onPopupTargetResize.bind(this),this.showNotesEditor=this.showNotesEditor.bind(this),this.hideNotesEditor=this.hideNotesEditor.bind(this),this.stepZoom=this.stepZoom.bind(this),this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.markerStateChanged=this.markerStateChanged.bind(this),this.switchToSelectMode=this.switchToSelectMode.bind(this),this.addDefs=this.addDefs.bind(this),this.addDefsToImage=this.addDefsToImage.bind(this)}return Object.defineProperty(j.prototype,"ALL_MARKER_TYPES",{get:function(){return[Qe,fe,ue,Le,rt,Ee,ie,me,Pe,q,tt,ft]},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[Qe,fe,ue,Le,Ee,ie,me]},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"BASIC_MARKER_TYPES",{get:function(){return[Qe,fe,ue,Le,ie]},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(s){var c=this;this._availableMarkerTypes.splice(0),s.forEach(function(R){if(typeof R=="string"){var Z=c.ALL_MARKER_TYPES.find(function(U){return U.typeName===R});Z!==void 0&&c._availableMarkerTypes.push(Z)}else c._availableMarkerTypes.push(R)})},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(s){this._zoomLevel=s,this.editorCanvas&&this.contentDiv&&(this.editorCanvas.style.transform="scale("+this._zoomLevel+")",this.contentDiv.scrollTo({left:(this.editorCanvas.clientWidth*this._zoomLevel-this.contentDiv.clientWidth)/2,top:(this.editorCanvas.clientHeight*this._zoomLevel-this.contentDiv.clientHeight)/2}))},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),j.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),Re.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},j.prototype.show=function(){var s=this;this.styles.styleSheetRoot===void 0&&He.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=He.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(c){return c(new wt(s))})},j.prototype.render=function(){return Ae(this,void 0,void 0,function(){var s;return Se(this,function(c){switch(c.label){case 0:return this.setCurrentMarker(),(s=new Ze).naturalSize=this.renderAtNaturalSize,s.imageType=this.renderImageType,s.imageQuality=this.renderImageQuality,s.markersOnly=this.renderMarkersOnly,s.width=this.renderWidth,s.height=this.renderHeight,[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return c.sent(),[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,c.sent()]}})})},j.prototype.close=function(s){var c=this;if(s===void 0&&(s=!1),this.isOpen){var R=!1;s||this.eventListeners.beforeclose.forEach(function(Z){var U=new wt(c,!0);Z(U),U.defaultPrevented&&(R=!0)}),R||(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.settings.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),this.eventListeners.close.forEach(function(Z){return Z(new wt(c))}),this.detachEvents(),this._isOpen=!1)}},j.prototype.addMarkersToToolbar=function(){for(var s,c=[],R=0;R<arguments.length;R++)c[R]=arguments[R];(s=this._availableMarkerTypes).push.apply(s,c)},j.prototype.addRenderEventListener=function(s){this.addEventListener("render",function(c){s(c.dataUrl,c.state)})},j.prototype.removeRenderEventListener=function(s){},j.prototype.addCloseEventListener=function(s){this.addEventListener("close",function(){s()})},j.prototype.removeCloseEventListener=function(s){},j.prototype.setupResizeObserver=function(){var s=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){s.resize(s.target.clientWidth,s.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return s.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},j.prototype.onPopupTargetResize=function(){var s=1*this.target.clientWidth/this.target.clientHeight,c=this.editorCanvas.clientWidth/s>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*s:this.editorCanvas.clientWidth,R=c<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/s;this.resize(c,R)},j.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},j.prototype.resize=function(s,c){this._isResizing=!0;var R=s/this.imageWidth,Z=c/this.imageHeight;this.imageWidth=Math.round(s),this.imageHeight=Math.round(c),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px",this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.settings.displayMode!=="popup"?this.coverDiv.style.width=this.imageWidth.toString()+"px":(this.setTopLeft(),this.positionMarkerImage()),this.toolbar!==void 0&&this.toolbar.adjustLayout(),this.positionLogo(),this.scaleMarkers(R,Z),this._isResizing=!1},j.prototype.scaleMarkers=function(s,c){var R,Z=this;this._currentMarker&&this._currentMarker instanceof Le?this._currentMarker.scale(s,c):(R=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(U){U!==Z._currentMarker&&U.scale(s,c)}),R!==void 0&&this.setCurrentMarker(R)},j.prototype.setEditingTarget=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px"},j.prototype.setTopLeft=function(){var s=this.editingTarget.getBoundingClientRect(),c=this.editorCanvas.getBoundingClientRect();this.left=s.left-c.left,this.top=s.top-c.top},j.prototype.initMarkerCanvas=function(){this.markerImageHolder=document.createElement("div"),this.markerImageHolder.style.setProperty("touch-action","pinch-zoom"),this.markerImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.markerImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImage.style.pointerEvents="auto",this.markerImageHolder.style.position="absolute",this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.markerImageHolder.style.transformOrigin="top left",this.positionMarkerImage(),this.markerImageHolder.appendChild(this.markerImage),this.editorCanvas.appendChild(this.markerImageHolder)},j.prototype.addDefs=function(){for(var s,c=[],R=0;R<arguments.length;R++)c[R]=arguments[R];this.defs=oe.createDefs(),this.addDefsToImage(),(s=this.defs).append.apply(s,c)},j.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},j.prototype.initOverlay=function(){this.overlayContainer=document.createElement("div"),this.overlayContainer.style.position="absolute",this.overlayContainer.style.left="0px",this.overlayContainer.style.top="0px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.overlayContainer.style.display="flex",this.markerImageHolder.appendChild(this.overlayContainer)},j.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},j.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},j.prototype.attachWindowEvents=function(){window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp),window.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("pointerout",this.onPointerOut),window.addEventListener("pointerleave",this.onPointerUp),window.addEventListener("resize",this.onWindowResize),window.addEventListener("keyup",this.onKeyUp)},j.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},j.prototype.detachWindowEvents=function(){window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("pointerout",this.onPointerOut),window.removeEventListener("pointerleave",this.onPointerUp),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("keyup",this.onKeyUp)},j.prototype.addLogo=function(){this.logoUI=document.createElement("div"),this.logoUI.style.display="inline-block",this.logoUI.style.margin="0px",this.logoUI.style.padding="0px",this.logoUI.style.fill="#333333";var s=document.createElement("a");s.href="https://markerjs.com/",s.target="_blank",s.innerHTML='<svg viewBox="0 0 112 96" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path fill="#e5f20d" fill-opacity=".647" d="M0 40.386h111.96V95.62H0z"/><path d="M93.61 61.452c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.591 1.048-1.481 0-2.222-.74-2.222-2.22 0-16.617-.533-29.347-1.604-38.192-1.068-8.842-2.92-13.265-5.552-13.265-4.443 0-10.94 15.509-19.497 46.52v.124c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.592 1.048-1.48 0-2.22-.74-2.22-2.22 0-3.29.165-8.392.493-15.302.33-7.732.494-13.82.494-18.262 0-6.17-.186-10.55-.556-13.142-.37-2.591-1.172-3.887-2.406-3.887-2.796 0-6.333 5.12-10.612 15.363C38.494 34.367 34.01 46.44 29.32 60.34l-1.11 3.209a5.714 5.714 0 01-1.42 2.097c-.617.578-1.295.864-2.036.864-.987 0-1.644-.081-1.974-.247-.328-.162-.533-.656-.617-1.48-.41-4.03-.74-9.418-.987-16.165-.163-1.728-.329-4.566-.494-8.515-.822-13.901-1.562-23.3-2.221-28.196-.657-4.893-.987-7.628-.987-8.205 0-.657.33-1.44.987-2.345.659-.903 1.276-1.357 1.85-1.357 1.319 0 2.387.947 3.21 2.838.411.906.863 4.526 1.357 10.859.493 6.335.905 14.19 1.233 23.568l.617 18.88c4.527-13.983 9.216-26.673 14.068-38.068C45.65 6.686 50.093.988 54.123.988c2.715 0 4.566 1.974 5.553 5.923.987 3.949 1.481 9.667 1.481 17.152 0 3.949-.081 9.625-.247 17.029l-.123 5.676c3.373-11.762 6.725-21.634 10.057-29.615 3.331-7.979 6.685-11.97 10.056-11.97 8.475 0 12.71 18.757 12.71 56.269z" fill-rule="nonzero"/></svg>',s.title="Powered by marker.js",s.style.display="grid",s.style.alignItems="center",s.style.justifyItems="center",s.style.padding="3px",s.style.width="20px",s.style.height="20px",this.logoUI.appendChild(s),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},j.prototype.positionLogo=function(){this.logoUI&&(this.uiStyleSettings.logoPosition!=="right"?this.logoUI.style.left=this.markerImageHolder.offsetLeft+10+"px":this.logoUI.style.left=this.markerImageHolder.offsetLeft+this.markerImageHolder.offsetWidth-this.logoUI.clientWidth-10+"px",this.logoUI.style.top=this.markerImageHolder.offsetTop+this.markerImageHolder.offsetHeight-this.logoUI.clientHeight-10+"px")},j.prototype.overrideOverflow=function(){this.scrollXState=window.scrollX,this.scrollYState=window.scrollY,this.bodyOverflowState=document.body.style.overflow,window.scroll({top:0,left:0}),document.body.style.overflow="hidden"},j.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},j.prototype.showUI=function(){switch(this.settings.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.style.visibility=this._silentRenderMode?"hidden":"visible",this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.coverDiv.style.userSelect="none",this.settings.displayMode){case"inline":this.coverDiv.style.position="absolute";var s=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=s+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px",this.coverDiv.style.width=this.target.offsetWidth.toString()+"px",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.settings.displayMode==="popup"?this.settings.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.toolbar=new Ie(this.uiDiv,this.settings.displayMode,this._availableMarkerTypes,this.uiStyleSettings,this.styles),this.toolbar.addButtonClickListener(this.toolbarButtonClicked),this.toolbar.show(this._silentRenderMode||this.uiStyleSettings.hideToolbar?"hidden":"visible"),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.settings.displayMode==="popup"&&(this.contentDiv.style.backgroundColor=this.uiStyleSettings.canvasBackgroundColor,this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.uiStyleSettings.toolbarHeight+"px",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.settings.popupMargin+"px)"),this.contentDiv.style.overflow="auto",this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.settings.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.editorCanvas.style.transformOrigin="left top",this.editorCanvas.style.transform="scale("+this.zoomLevel+")",this.contentDiv.appendChild(this.editorCanvas),this.editingTarget=this.target instanceof HTMLImageElement?document.createElement("img"):document.createElement("canvas"),this.target.getClientRects().item(0).y<this.styles.settings.toolbarHeight&&(this.editingTarget.style.marginTop=this.target.offsetTop-this.styles.settings.toolbarHeight+"px"),this.editorCanvas.appendChild(this.editingTarget),this.toolbox=new We(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},j.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},j.prototype.removeMarker=function(s){this.markerImage.removeChild(s.container),this.markers.indexOf(s)>-1&&this.markers.splice(this.markers.indexOf(s),1),s.dispose()},j.prototype.switchToSelectMode=function(){this.mode="select",this.hideNotesEditor(),this._currentMarker!==void 0&&(this._currentMarker.state!=="new"?this._currentMarker.select():(this.removeMarker(this._currentMarker),this.setCurrentMarker(),this.markerImage.style.cursor="default"),this.addUndoStep())},j.prototype.toolbarButtonClicked=function(s,c){if(s==="marker"&&c!==void 0)this.createNewMarker(c);else if(s==="action")switch(c){case"select":this.switchToSelectMode(),this.switchToSelectMode();break;case"delete":this.deleteSelectedMarker();break;case"clear":this.clear();break;case"undo":this.undo();break;case"redo":this.redo();break;case"zoom":this.stepZoom();break;case"zoom-out":this.zoomLevel=1;break;case"notes":this.notesArea===void 0?(this.switchToSelectMode(),this.zoomLevel=1,this.showNotesEditor()):this.switchToSelectMode();break;case"close":this.close();break;case"render":this.switchToSelectMode(),this.startRenderAndClose()}},j.prototype.deleteSelectedMarker=function(){var s=this;if(this._currentMarker!==void 0){var c=!1;if(this.eventListeners.markerbeforedelete.forEach(function(Z){var U=new ut(s,s._currentMarker,!0);Z(U),U.defaultPrevented&&(c=!0)}),!c){var R=this._currentMarker;this._currentMarker.dispose(),this.markerImage.removeChild(this._currentMarker.container),this.markers.splice(this.markers.indexOf(this._currentMarker),1),this.setCurrentMarker(),this.addUndoStep(),this.eventListeners.markerdelete.forEach(function(Z){return Z(new ut(s,R))})}}},j.prototype.clear=function(){var s=this,c=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(ce){var Oe=new ut(s,void 0,!0);ce(Oe),Oe.defaultPrevented&&(c=!0)}),!c)){this.setCurrentMarker();for(var R=function(ce){var Oe=Z.markers[ce];Z.setCurrentMarker(Z.markers[ce]),Z._currentMarker.dispose(),Z.markerImage.removeChild(Z._currentMarker.container),Z.markers.splice(Z.markers.indexOf(Z._currentMarker),1),Z.eventListeners.markerdelete.forEach(function(Ke){return Ke(new ut(s,Oe))})},Z=this,U=this.markers.length-1;U>=0;U--)R(U);this.addUndoStep()}},Object.defineProperty(j.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),j.prototype.showNotesEditor=function(){var s;this._currentMarker!==void 0&&(this.overlayContainer.innerHTML="",this.notesArea=document.createElement("textarea"),this.notesArea.className=this.uiStyleSettings.notesAreaStyleClassName,this.notesArea.style.pointerEvents="auto",this.notesArea.style.alignSelf="stretch",this.notesArea.style.width="100%",this.notesArea.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.notesArea.value=(s=this._currentMarker.notes)!==null&&s!==void 0?s:"",this.overlayContainer.appendChild(this.notesArea))},j.prototype.hideNotesEditor=function(){this.isNotesAreaOpen&&(this._currentMarker!==void 0&&(this._currentMarker.notes=this.notesArea.value.trim()!==""?this.notesArea.value:void 0),this.overlayContainer.removeChild(this.notesArea),this.notesArea=void 0)},j.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},j.prototype.addUndoStep=function(){var s=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var c=this.getState(),R=this.undoRedoManager.getLastUndoStep();if(!R||R.width===c.width&&R.height===c.height){var Z=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(c),Z<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(U){return U(new wt(s))})}else this.undoRedoManager.replaceLastUndoStep(c),this.eventListeners.statechange.forEach(function(U){return U(new wt(s))})}},j.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},j.prototype.undoStep=function(){var s=this,c=this.undoRedoManager.undo();c!==void 0&&(this.restoreState(c),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(R){return R(new wt(s))}))},j.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},j.prototype.redoStep=function(){var s=this,c=this.undoRedoManager.redo();c!==void 0&&(this.restoreState(c),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(R){return R(new wt(s))}))},j.prototype.stepZoom=function(){var s=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=s<this.zoomSteps.length-1?this.zoomSteps[s+1]:this.zoomSteps[0]},j.prototype.panTo=function(s){this.contentDiv.scrollBy({left:this.prevPanPoint.x-s.x,top:this.prevPanPoint.y-s.y}),this.prevPanPoint=s},j.prototype.startRenderAndClose=function(){return Ae(this,void 0,void 0,function(){var s,c,R=this;return Se(this,function(Z){switch(Z.label){case 0:return[4,this.render()];case 1:return s=Z.sent(),c=this.getState(),this.eventListeners.render.forEach(function(U){return U(new Tt(R,s,c))}),this.close(!0),[2]}})})},j.prototype.getState=function(s){s===!0&&this.setCurrentMarker();var c={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(R){return c.markers.push(R.getState())}),c},j.prototype.restoreState=function(s){var c=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);s.markers.forEach(function(R){var Z=c._availableMarkerTypes.find(function(ce){return ce.typeName===R.typeName});if(Z!==void 0){var U=c.addNewMarker(Z);U.restoreState(R),c.markers.push(U)}}),s.width&&s.height&&(s.width!==this.imageWidth||s.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/s.width,this.imageHeight/s.height),this.eventListeners.restorestate.forEach(function(R){return R(new wt(c))})},j.prototype.addNewMarker=function(s){var c=oe.createGroup();return this.markerImage.appendChild(c),new s(c,this.overlayContainer,this.settings)},j.prototype.createNewMarker=function(s){var c,R=this;(c=typeof s=="string"?this._availableMarkerTypes.find(function(Z){return Z.typeName===s}):s)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(c),this._currentMarker.onMarkerCreated=this.markerCreated,this._currentMarker.onColorChanged=this.colorChanged,this._currentMarker.onFillColorChanged=this.fillColorChanged,this._currentMarker.onStateChanged=this.markerStateChanged,this.markerImage.style.cursor="crosshair",this.toolbar.setActiveMarkerButton(c.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(Z){return Z(new ut(R,R._currentMarker))}))},j.prototype.markerCreated=function(s){var c=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(s),this.setCurrentMarker(s),s instanceof fe&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(fe):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(R){return R(new ut(c,c._currentMarker))})},j.prototype.colorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=s,this.settings.defaultStrokeColor=s)},j.prototype.fillColorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=s)},j.prototype.markerStateChanged=function(s){var c=this;this.eventListeners.markerchange.forEach(function(R){return R(new ut(c,s))})},j.prototype.setCurrentMarker=function(s){var c=this;this._currentMarker!==s&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(R){return R(new ut(c,c._currentMarker))})),this._currentMarker=s,this._currentMarker===void 0||this._currentMarker.isSelected||(this._currentMarker.state!=="new"&&this._currentMarker.select(),this.toolbar.setCurrentMarker(this._currentMarker),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this._isResizing||this.eventListeners.markerselect.forEach(function(R){return R(new ut(c,c._currentMarker))}))},j.prototype.onPointerDown=function(s){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||s.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var c=this.markers.find(function(R){return R.ownsTarget(s.target)});c!==void 0?(this.setCurrentMarker(c),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(s.clientX,s.clientY),s.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:s.clientX,y:s.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(s.clientX,s.clientY))},j.prototype.onDblClick=function(s){if(this._isFocused||this.focus(),this.mode==="select"){var c=this.markers.find(function(R){return R.ownsTarget(s.target)});c!==void 0&&c!==this._currentMarker&&this.setCurrentMarker(c),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(s.clientX,s.clientY),s.target):this.setCurrentMarker()}},j.prototype.onPointerMove=function(s){this.touchPoints!==1&&s.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||s.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(s.clientX,s.clientY)):this.zoomLevel>1&&this.panTo({x:s.clientX,y:s.clientY}))},j.prototype.onPointerUp=function(s){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(s.clientX,s.clientY)),this.isDragging=!1,this.addUndoStep()},j.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},j.prototype.onKeyUp=function(s){this._currentMarker===void 0||this.notesArea!==void 0||s.key!=="Delete"&&s.key!=="Backspace"||this.deleteSelectedMarker()},j.prototype.clientToLocalCoordinates=function(s,c){var R=this.markerImage.getBoundingClientRect();return{x:(s-R.left)/this.zoomLevel,y:(c-R.top)/this.zoomLevel}},j.prototype.onWindowResize=function(){this.positionUI()},j.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var s=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=s+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.styles.settings.toolbarHeight+"px"}this.positionMarkerImage(),this.positionLogo()},j.prototype.addLicenseKey=function(s){Re.addKey(s)},j.prototype.addEventListener=function(s,c){this.eventListeners.addEventListener(s,c)},j.prototype.removeEventListener=function(s,c){this.eventListeners.removeEventListener(s,c)},j.prototype.renderState=function(s){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(s),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(j.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),j.prototype.focus=function(){var s=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(c){return c(new wt(s))}))},j.prototype.blur=function(){var s=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(c){return c(new wt(s))}))},j.instanceCounter=0,j}();/* **********************************
|
|
cropro version 1.2.0
|
|
@license SEE LICENSE IN LICENSE
|
|
|
|
copyright Alan Mendelevich
|
|
see README and LICENSE for details
|
|
********************************** *//*! *****************************************************************************
|
|
Copyright (c) Microsoft Corporation.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
***************************************************************************** */var Zt=function(j,s){return(Zt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(c,R){c.__proto__=R}||function(c,R){for(var Z in R)Object.prototype.hasOwnProperty.call(R,Z)&&(c[Z]=R[Z])})(j,s)};function Xt(j,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function c(){this.constructor=j}Zt(j,s),j.prototype=s===null?Object.create(s):(c.prototype=s.prototype,new c)}function Rt(j,s,c,R){return new(c||(c=Promise))(function(Z,U){function ce(dt){try{Ke(R.next(dt))}catch(Me){U(Me)}}function Oe(dt){try{Ke(R.throw(dt))}catch(Me){U(Me)}}function Ke(dt){var Me;dt.done?Z(dt.value):(Me=dt.value,Me instanceof c?Me:new c(function(vt){vt(Me)})).then(ce,Oe)}Ke((R=R.apply(j,s||[])).next())})}function Ir(j,s){var c,R,Z,U,ce={label:0,sent:function(){if(1&Z[0])throw Z[1];return Z[1]},trys:[],ops:[]};return U={next:Oe(0),throw:Oe(1),return:Oe(2)},typeof Symbol=="function"&&(U[Symbol.iterator]=function(){return this}),U;function Oe(Ke){return function(dt){return function(Me){if(c)throw new TypeError("Generator is already executing.");for(;ce;)try{if(c=1,R&&(Z=2&Me[0]?R.return:Me[0]?R.throw||((Z=R.return)&&Z.call(R),0):R.next)&&!(Z=Z.call(R,Me[1])).done)return Z;switch(R=0,Z&&(Me=[2&Me[0],Z.value]),Me[0]){case 0:case 1:Z=Me;break;case 4:return ce.label++,{value:Me[1],done:!1};case 5:ce.label++,R=Me[1],Me=[0];continue;case 7:Me=ce.ops.pop(),ce.trys.pop();continue;default:if(!(Z=ce.trys,(Z=Z.length>0&&Z[Z.length-1])||Me[0]!==6&&Me[0]!==2)){ce=0;continue}if(Me[0]===3&&(!Z||Me[1]>Z[0]&&Me[1]<Z[3])){ce.label=Me[1];break}if(Me[0]===6&&ce.label<Z[1]){ce.label=Z[1],Z=Me;break}if(Z&&ce.label<Z[2]){ce.label=Z[2],ce.ops.push(Me);break}Z[2]&&ce.ops.pop(),ce.trys.pop();continue}Me=s.call(j,ce)}catch(vt){Me=[6,vt],R=0}finally{c=Z=0}if(5&Me[0])throw Me[1];return{value:Me[0]?Me[1]:void 0,done:!0}}([Ke,dt])}}}var Kr=function(){function j(){}return j.addKey=function(s){j.key=s},Object.defineProperty(j,"isLicensed",{get:function(){return!!j.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(j.key)},enumerable:!1,configurable:!0}),j}(),bt=function(){function j(){}return j.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},j.setAttributes=function(s,c){for(var R=0,Z=c;R<Z.length;R++){var U=Z[R],ce=U[0],Oe=U[1];s.setAttribute(ce,Oe)}},j.createRect=function(s,c,R){var Z=document.createElementNS("http://www.w3.org/2000/svg","rect");return Z.setAttribute("width",s.toString()),Z.setAttribute("height",c.toString()),R&&j.setAttributes(Z,R),Z},j.createLine=function(s,c,R,Z,U){var ce=document.createElementNS("http://www.w3.org/2000/svg","line");return ce.setAttribute("x1",s.toString()),ce.setAttribute("y1",c.toString()),ce.setAttribute("x2",R.toString()),ce.setAttribute("y2",Z.toString()),U&&j.setAttributes(ce,U),ce},j.createPolygon=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","polygon");return R.setAttribute("points",s),c&&j.setAttributes(R,c),R},j.createCircle=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","circle");return R.setAttribute("cx",(s/2).toString()),R.setAttribute("cy",(s/2).toString()),R.setAttribute("r",s.toString()),c&&j.setAttributes(R,c),R},j.createEllipse=function(s,c,R){var Z=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return Z.setAttribute("cx",(s/2).toString()),Z.setAttribute("cy",(c/2).toString()),Z.setAttribute("rx",(s/2).toString()),Z.setAttribute("ry",(c/2).toString()),R&&j.setAttributes(Z,R),Z},j.createGroup=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&j.setAttributes(c,s),c},j.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},j.createMarker=function(s,c,R,Z,U,ce,Oe){var Ke=document.createElementNS("http://www.w3.org/2000/svg","marker");return j.setAttributes(Ke,[["id",s],["orient",c],["markerWidth",R.toString()],["markerHeight",Z.toString()],["refX",U.toString()],["refY",ce.toString()]]),Ke.appendChild(Oe),Ke},j.createText=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","text");return c.setAttribute("x","0"),c.setAttribute("y","0"),s&&j.setAttributes(c,s),c},j.createTSpan=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","tspan");return R.textContent=s,c&&j.setAttributes(R,c),R},j.createImage=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&j.setAttributes(c,s),c},j.createPoint=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return R.x=s,R.y=c,R},j.createPath=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg","path");return R.setAttribute("d",s),c&&j.setAttributes(R,c),R},j.createElement=function(s,c){var R=document.createElementNS("http://www.w3.org/2000/svg",s);return c&&j.setAttributes(R,c),R},j.getHollowRectanglePath=function(s,c,R,Z,U,ce,Oe,Ke){return"M"+s+","+c+"V"+(c+Z)+"H"+(s+R)+"V"+c+"H"+U+"V"+ce+"H"+(U+Oe)+"V"+(ce+Ke)+"H"+U+"V"+c+"Z"},j}(),Nr=function(){function j(s){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(j.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#333333",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarBackgroundActiveColor:"#282828",toolbarColor:"#eeeeee",cropShadeColor:"#ffffff",cropFrameColor:"#ffffff",gripColor:"#333333",gripFillColor:"#cccccc",toolbarHeight:40}},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),j.prototype.addClass=function(s){return this.styleSheet===void 0&&this.addStyleSheet(),s.name=""+this.classNamePrefix+s.localName,this.classes.push(s),this.styleSheet.sheet.insertRule("."+s.name+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length),s},j.prototype.addRule=function(s){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(s),this.styleSheet.sheet.insertRule(s.selector+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length)},j.prototype.addStyleSheet=function(){var s;this.styleSheet=document.createElement("style"),((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).appendChild(this.styleSheet),this.addRule(new hr("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new hr("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new hr("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new pr("_fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new pr("_fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},j.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},j}(),hr=function(j,s){this.selector=j,this.style=s},pr=function(j,s){this.localName=j,this.style=s},Br=function(){function j(){this.blocks=[],this.display=""}return j.prototype.addButtonBlock=function(s){s.className=this.blockClassName,s.buttonClassName=this.buttonClassName,s.buttonColorsClassName=this.buttonColorsClassName,s.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(s)},j.prototype.addElementBlock=function(s){s.className===void 0&&(s.className=this.blockClassName),this.blocks.push(s)},j.prototype.getUI=function(){var s=document.createElement("div");return s.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,s.style.display=this.display,this.blocks.forEach(function(c){return s.appendChild(c.getUI())}),s},j}(),ci=function(){function j(){}return j.prototype.getUI=function(){var s=document.createElement("div");if(s.className=this.className,this.minWidth!==void 0&&(s.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":s.style.justifyContent="flex-start";break;case"center":s.style.justifyContent="center";break;case"end":s.style.justifyContent="flex-end"}return s.style.whiteSpace="nowrap",s},j}(),qr=function(j){function s(){var c=j!==null&&j.apply(this,arguments)||this;return c.buttons=[],c}return Xt(s,j),s.prototype.addButton=function(c){c.className=this.buttonClassName,c.colorsClassName=this.buttonColorsClassName,c.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(c)},s.prototype.getUI=function(){var c=j.prototype.getUI.call(this);return this.buttons.forEach(function(R){return c.appendChild(R.getUI())}),c},s}(ci),It=function(){function j(s,c){this._isActive=!1,this._isHidden=!1,this._icon=s,this.title=c,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(j.prototype,"icon",{get:function(){return this._icon},set:function(s){this._icon=s,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isActive",{get:function(){return this._isActive},set:function(s){this._isActive=s,this.adjustClassName()},enumerable:!1,configurable:!0}),j.prototype.getUI=function(){var s=this;return this.buttonContainer=document.createElement("div"),this.buttonContainer.title=this.title,this.buttonContainer.className=this.className+" "+this.colorsClassName,this.adjustClassName(),this.buttonContainer.innerHTML=this._icon,this.onClick&&this.buttonContainer.addEventListener("click",function(){return s.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},j.prototype.adjustClassName=function(){this.activeColorsClassName&&(this._isActive&&this.buttonContainer.className.indexOf(this.activeColorsClassName)<0?this.buttonContainer.className+=" "+this.activeColorsClassName:this._isActive||(this.buttonContainer.className=this.buttonContainer.className.replace(this.activeColorsClassName,"")))},j.prototype.hide=function(){this._isHidden=!0},j}(),ht=function(j){function s(){var c=j!==null&&j.apply(this,arguments)||this;return c.elements=[],c}return Xt(s,j),s.prototype.addElement=function(c){this.elements.push(c)},s.prototype.getUI=function(){var c=j.prototype.getUI.call(this);return this.elements.forEach(function(R){return c.appendChild(R)}),c},s}(ci),Hr=function(){function j(s,c){this.horizontal=s,this.vertical=c}return Object.defineProperty(j.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),j.prototype.getVerticalLength=function(s){return s/this.ratio},j.prototype.getHorizontalLength=function(s){return s*this.ratio},j}(),ei=function(){function j(){}return j.getIcon=function(s,c){if(s>0&&c>0){var R=new Hr(s,c),Z=R.ratio>=1?20:R.getHorizontalLength(20),U=R.ratio<1?20:R.getVerticalLength(20),ce=document.createElementNS("http://www.w3.org/2000/svg","svg");ce.setAttribute("xmlns","http://www.w3.org/2000/svg"),ce.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(ce);var Oe=bt.createDefs();ce.appendChild(Oe);var Ke=bt.createElement("clipPath",[["id","text-bg-clip"]]);Oe.appendChild(Ke);var dt=bt.createPath(bt.getHollowRectanglePath((24-Z)/2,(24-U)/2,Z,U,(24-Z)/2+2,(24-U)/2+2,Z-4,U-4));ce.appendChild(dt);var Me=bt.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Me.appendChild(bt.createTSpan(s+":"+c)),ce.appendChild(Me);var vt=Me.getBBox();bt.setAttributes(Me,[["x",((24-vt.width)/2).toString()],["y",((24-vt.height)/2-vt.y).toString()]]);var Nt=bt.createPath(bt.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(vt.width))/2,(24-Math.ceil(vt.height))/2,Math.ceil(vt.width),Math.ceil(vt.height)));return Ke.appendChild(Nt),bt.setAttributes(dt,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(ce),ce.outerHTML}return'<svg viewBox="0 0 24 24"><path d="M19 12h-2v3h-3v2h5v-5M7 9h3V7H5v5h2V9m14-6H3a2 2 0 00-2 2v14a2 2 0 002 2h18a2 2 0 002-2V5a2 2 0 00-2-2m0 16H3V5h18v14z"/></svg>'},j}(),mr=function(j){function s(c,R,Z){var U=j.call(this,c,R)||this;return U.isDropdownOpen=!1,U.onClick=U.dropdownButtonClicked,U.dropdownButtons=Z,U}return Xt(s,j),s.prototype.setupDropdown=function(){var c=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(R){R.className=c.className,R.colorsClassName=c.colorsClassName,c.dropdownBlock.appendChild(R.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},s.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},s.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},s.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},s.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},s.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},s}(It),kt=function(){function j(s,c){this.GRIP_SIZE=10,this.color=s,this.fillColor=c,this.visual=bt.createGroup(),this.visual.appendChild(bt.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(bt.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return j.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},j.prototype.setCenter=function(s,c){this.visual.childNodes.forEach(function(R){return bt.setAttributes(R,[["cx",s.toString()],["cy",c.toString()]])})},j}(),Fr=function(){function j(s,c,R,Z){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=s,this.canvasHeight=c,this.margin=R,this.container=Z,this.attachEvents=this.attachEvents.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.resize=this.resize.bind(this),this.adjustCropRect=this.adjustCropRect.bind(this),this.scaleCanvas=this.scaleCanvas.bind(this),this.getRescaledRect=this.getRescaledRect.bind(this)}return Object.defineProperty(j.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(s){this._aspectRatio=s,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(s){this._isGridVisible=s,this.gridContainer&&bt.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(s){this._zoomFactor=s,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),j.prototype.open=function(){var s=this;this.cropShadeElement=bt.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=bt.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var c=0;c<this.numberOfGridLines;c++)this.horizontalGridLines.push(bt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(bt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(R){return s.gridContainer.appendChild(R)}),this.verticalGridLines.forEach(function(R){return s.gridContainer.appendChild(R)}),this.cropRectElement=bt.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new kt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new kt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new kt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new kt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},j.prototype.setCropRectangle=function(s){this.cropRect=s;var c=Object.assign({},this.cropRect);this.zoomFactor!==1&&(c.width=this.cropRect.width*this.zoomFactor,c.height=this.cropRect.height*this.zoomFactor,c.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-c.width/2,c.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-c.height/2),bt.setAttributes(this.cropRectElement,[["x",c.x.toString()],["y",c.y.toString()],["width",c.width.toString()],["height",c.height.toString()]]);var R=c.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(U,ce){var Oe=c.y+R*(ce+1);bt.setAttributes(U,[["x1",""+c.x],["y1",""+Oe],["x2",""+(c.x+c.width)],["y2",""+Oe]])});var Z=c.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(U,ce){var Oe=c.x+Z*(ce+1);bt.setAttributes(U,[["x1",""+Oe],["y1",""+c.y],["x2",""+Oe],["y2",""+(c.y+c.height)]])}),bt.setAttributes(this.cropShadeElement,[["d",bt.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,c.x,c.y,c.width,c.height)]]),this.topLeftGrip.setCenter(c.x,c.y),this.topRightGrip.setCenter(c.x+c.width,c.y),this.bottomLeftGrip.setCenter(c.x,c.y+c.height),this.bottomRightGrip.setCenter(c.x+c.width,c.y+c.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},j.prototype.attachEvents=function(){this.container.style.touchAction="none",this.container.addEventListener("pointerdown",this.onPointerDown),this.container.addEventListener("pointermove",this.onPointerMove),this.container.addEventListener("pointerup",this.onPointerUp)},j.prototype.clientToLocalCoordinates=function(s,c){var R=this.container.getBoundingClientRect();return{x:s-R.left+this.margin,y:c-R.top+this.margin}},j.prototype.onPointerDown=function(s){this.container.setPointerCapture(s.pointerId),this.previousPoint=this.clientToLocalCoordinates(s.clientX,s.clientY),this.cropRectElement===s.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(s.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(s.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(s.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(s.target)&&(this.activeGrip=this.bottomRightGrip)},j.prototype.onPointerMove=function(s){if(this.isMoving)this.move(this.clientToLocalCoordinates(s.clientX,s.clientY));else if(this.activeGrip){var c=this.clientToLocalCoordinates(s.clientX,s.clientY);this.resize(c)}s.preventDefault()},j.prototype.onPointerUp=function(s){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(s.pointerId)},j.prototype.move=function(s){var c=s.x-this.previousPoint.x,R=s.y-this.previousPoint.y;this.zoomFactor!==1&&(c=-c/this.zoomFactor,R=-R/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+c),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+R),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=s},j.prototype.resize=function(s){var c=Object.assign({},this.cropRect),R=s.x-this.previousPoint.x,Z=s.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:c.x+R<this.margin&&(R=this.margin-c.x),c.x+=R,c.width=this.cropRect.x+this.cropRect.width-c.x;break;case this.bottomRightGrip:case this.topRightGrip:c.width+R>this.canvasWidth*this.zoomFactor&&(R=this.canvasWidth*this.zoomFactor-c.width),c.width+=R}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(c.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(R),c.height=this.aspectRatio.getVerticalLength(c.width)):(c.y+=Z,c.height=this.cropRect.y+this.cropRect.height-c.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?c.height=this.aspectRatio.getVerticalLength(c.width):c.height+=Z}c.width<10&&(c.x=this.cropRect.x,c.width=10),c.height<10&&(c.y=this.cropRect.y,c.height=10),this.previousPoint=s,c.x>=this.margin&&c.y>=this.margin&&c.x-this.margin+c.width<=this.canvasWidth&&c.y-this.margin+c.height<=this.canvasHeight&&(this.cropRect=c,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},j.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var s=this.cropRect.x+this.cropRect.width/2,c=this.cropRect.y+this.cropRect.height/2,R=this.aspectRatio.getHorizontalLength(this.cropRect.height),Z=this.aspectRatio.getVerticalLength(this.cropRect.width);R/this.canvasWidth<Z/this.canvasHeight?this.cropRect.width=R:this.cropRect.height=Z,this.cropRect.width>this.canvasWidth&&(this.cropRect.height/=this.cropRect.width/this.canvasWidth,this.cropRect.width=this.canvasWidth),this.cropRect.height>this.canvasHeight&&(this.cropRect.width/=this.cropRect.height/this.canvasHeight,this.cropRect.height=this.canvasHeight),this.cropRect.x=s-this.cropRect.width/2,this.cropRect.y=c-this.cropRect.height/2,this.cropRect.x+this.cropRect.width>this.margin+this.canvasWidth&&(this.cropRect.x=this.margin+this.canvasWidth-this.cropRect.width),this.cropRect.y+this.cropRect.height>this.margin+this.canvasHeight&&(this.cropRect.y=this.margin+this.canvasHeight-this.cropRect.height),this.cropRect.x=Math.max(this.cropRect.x,this.margin),this.cropRect.y=Math.max(this.cropRect.y,this.margin)}},j.prototype.getRescaledRect=function(s,c,R,Z,U,ce){var Oe=R/s,Ke=Z/c;return{x:(U.x-ce)*Oe+ce,y:(U.y-ce)*Ke+ce,width:U.width*Oe,height:U.height*Ke}},j.prototype.scaleCanvas=function(s,c){var R=this.getRescaledRect(this.canvasWidth,this.canvasHeight,s,c,this.cropRect,this.margin);this.canvasWidth=s,this.canvasHeight=c,this.onCropChange&&this.onCropChange(R),this.setCropRectangle(R)},j}(),Vr=function(){function j(s){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=s,this.uiContainer=document.createElement("div"),this.getUI=this.getUI.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.setAngleLabel=this.setAngleLabel.bind(this),this.positionScaleShape=this.positionScaleShape.bind(this)}return Object.defineProperty(j.prototype,"angle",{get:function(){return this._angle},set:function(s){this._angle=s,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),j.prototype.getUI=function(){return this.controlContainer=document.createElement("div"),this.controlContainer.title=this.title,this.controlContainer.className=this.className+" "+this.colorsClassName,this.controlContainer.appendChild(this.getVisual()),this.controlContainer.addEventListener("pointerdown",this.onPointerDown),this.controlContainer.addEventListener("pointermove",this.onPointerMove),this.controlContainer.addEventListener("pointerup",this.onPointerUp),this.uiContainer.appendChild(this.controlContainer),this.uiContainer.style.display="inline-block",this.uiContainer.style.touchAction="none",this.setAngleLabel(),this.positionScaleShape(),this.uiContainer},j.prototype.onPointerDown=function(s){this.controlContainer.setPointerCapture(s.pointerId),this.isDragging=!0,this.previousPoint={x:s.clientX,y:s.clientY}},j.prototype.onPointerMove=function(s){this.isDragging&&(this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.previousPoint.x=s.clientX)},j.prototype.onPointerUp=function(s){this.isDragging&&this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(s.pointerId)},j.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var s=this.angleLabelText.getBBox();bt.setAttributes(this.angleLabelElement,[["x",((this.width-s.width)/2).toString()],["y",(this.height/2).toString()]])}},j.prototype.positionScaleShape=function(){if(this.scaleShape){var s=this.scaleShape.transform.baseVal.getItem(0);s.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(s,0)}},j.prototype.getVisual=function(){var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("xmlns","http://www.w3.org/2000/svg"),s.setAttribute("width",this.width+"px"),s.setAttribute("height",this.height+"px"),s.setAttribute("viewBox","0 0 "+this.width+" "+this.height),s.style.flexShrink="0",document.body.appendChild(s);for(var c="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,R=1;R<=this.width/5+10;R++){var Z=R%5==0?this.height/3:this.height/6;c+="h4v"+-Z+"h1v"+Z}c+="v1H0Z",this.scaleShape=bt.createPath(c);var U=bt.createTransform();this.scaleShape.transform.baseVal.appendItem(U),s.appendChild(this.scaleShape),this.angleLabelElement=bt.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=bt.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var ce=bt.createTSpan("");return ce.innerHTML="°",this.angleLabelElement.appendChild(ce),s.appendChild(this.angleLabelElement),document.body.removeChild(s),s},j}(),fi=function(){function j(){this.naturalSize=!1,this.imageType="image/png"}return j.prototype.rasterize=function(s,c,R,Z,U,ce,Oe){var Ke=this;return new Promise(function(dt){var Me=document.createElement("canvas");Me.width=s.width.baseVal.value-2*Z,Me.height=s.height.baseVal.value-2*Z;var vt=1,Nt=1;Ke.naturalSize===!0?(vt=c.naturalWidth/(s.width.baseVal.value-2*Z)/ce,Nt=c.naturalHeight/(s.height.baseVal.value-2*Z)/Oe,Me.width=c.naturalWidth/ce,Me.height=c.naturalHeight/Oe):Ke.width!==void 0&&Ke.height!==void 0&&(vt=Ke.width/R.width,Nt=Ke.height/R.height,Me.width*=vt,Me.height*=Nt);var Kt=Me.getContext("2d");Kt.translate(Me.width/2,Me.height/2),Kt.rotate(U*Math.PI/180),Kt.scale(ce,Oe),Kt.translate(-Me.width/2,-Me.height/2),Kt.drawImage(c,0,0,Me.width,Me.height);var Rr=document.createElement("canvas");Rr.width=R.width*vt,Rr.height=R.height*Nt,Rr.getContext("2d").putImageData(Kt.getImageData((R.x-Z)*vt,(R.y-Z)*Nt,R.width*vt,R.height*Nt),0,0),dt(Rr.toDataURL(Ke.imageType,Ke.imageQuality))})},j}(),Ue=function(){function j(s){this._zoomToCropEnabled=!0,this.zoomFactor=1,this.flippedHorizontally=!1,this.flippedVertically=!1,this._isGridVisible=!0,this._gridLines=2,this._rotationAngle=0,this.scaleFactor=1,this.renderEventListeners=[],this.closeEventListeners=[],this._isOpen=!1,this.CANVAS_MARGIN=20,this.renderAtNaturalSize=!1,this.renderImageType="image/png",this.displayMode="inline",this.popupMargin=30,this.toolbarHeight=40,this.aspectRatios=[{horizontal:0,vertical:0},{horizontal:4,vertical:3},{horizontal:3,vertical:2},{horizontal:16,vertical:9},{horizontal:1,vertical:1},{horizontal:3,vertical:4},{horizontal:2,vertical:3},{horizontal:9,vertical:16}],this._instanceNo=j.instanceCounter++,this.styles=new Nr(this.instanceNo),this.target=s,this.targetRoot=document.body,this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.rotateBy=this.rotateBy.bind(this),this.applyRotation=this.applyRotation.bind(this),this.cropRectChanged=this.cropRectChanged.bind(this),this.zoomToCrop=this.zoomToCrop.bind(this),this.unzoomFromCrop=this.unzoomFromCrop.bind(this),this.rotateLeftButtonClicked=this.rotateLeftButtonClicked.bind(this),this.rotateRightButtonClicked=this.rotateRightButtonClicked.bind(this),this.flipHorizontallyButtonClicked=this.flipHorizontallyButtonClicked.bind(this),this.flipVerticallyButtonClicked=this.flipVerticallyButtonClicked.bind(this),this.applyFlip=this.applyFlip.bind(this),this.startRenderAndClose=this.startRenderAndClose.bind(this),this.render=this.render.bind(this),this.onPopupResize=this.onPopupResize.bind(this),this.applyAspectRatio=this.applyAspectRatio.bind(this)}return Object.defineProperty(j.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(s){this._zoomToCropEnabled=s,s?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(s){this._isGridVisible=s,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"gridLines",{get:function(){return this._gridLines},set:function(s){this._gridLines=s,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(s){this._rotationAngle=s,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"aspectRatio",{get:function(){var s;return(s=this._aspectRatio)!==null&&s!==void 0?s:this.aspectRatios[0]},set:function(s){this._aspectRatio=s},enumerable:!1,configurable:!0}),j.prototype.open=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.setupResizeObserver(),this.initCropCanvas(),this.setEditingTarget(),this.setTopLeft(),this.initCropLayer(),this.attachEvents(),this.applyAspectRatio(),this.displayMode==="popup"&&this.onPopupResize(),this._isOpen=!0},j.prototype.show=function(){this.showUI(),this.open()},j.prototype.close=function(s){s===void 0&&(s=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),s||this.closeEventListeners.forEach(function(c){return c()}),this._isOpen=!1)},j.prototype.addRenderEventListener=function(s){this.renderEventListeners.push(s)},j.prototype.removeRenderEventListener=function(s){this.renderEventListeners.indexOf(s)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(s),1)},j.prototype.addCloseEventListener=function(s){this.closeEventListeners.push(s)},j.prototype.removeCloseEventListener=function(s){this.closeEventListeners.indexOf(s)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(s),1)},j.prototype.setupResizeObserver=function(){var s=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){s.resize(s.target.clientWidth,s.target.clientHeight)}),this.targetObserver.observe(this.target)):this.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(this.onPopupResize),this.targetObserver.observe(this.contentDiv)),window.addEventListener("resize",this.setWindowHeight))},j.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var s=1*this.target.clientWidth/this.target.clientHeight,c=this.contentDiv.clientWidth/s>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*s:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,R=c+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/s;this.resize(c,R)}},j.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},j.prototype.setEditingTargetSize=function(){this.editorCanvas.style.width=this.imageWidth+2*this.CANVAS_MARGIN+"px",this.editorCanvas.style.height=this.imageHeight+2*this.CANVAS_MARGIN+"px",bt.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},j.prototype.resize=function(s,c){this.imageWidth=Math.round(s),this.imageHeight=Math.round(c),this.setEditingTargetSize(),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.displayMode!=="popup"?this.coverDiv.style.width=this.paddedImageWidth+"px":(this.setTopLeft(),this.positionCropImage()),this.cropLayer.scaleCanvas(this.imageWidth,this.imageHeight),this.applyRotation()},j.prototype.setEditingTarget=function(){var s=document.createElement("canvas");s.width=this.target.naturalWidth,s.height=this.target.naturalHeight,s.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var c=s.toDataURL();bt.setAttributes(this.editingTarget,[["href",c]]),this.setEditingTargetSize()},j.prototype.setTopLeft=function(){var s=this.target.getBoundingClientRect(),c=this.editorCanvas.getBoundingClientRect();this.left=s.left-c.left-this.CANVAS_MARGIN,this.top=s.top-c.top-this.CANVAS_MARGIN},j.prototype.initCropCanvas=function(){this.cropImageHolder=document.createElement("div"),this.cropImageHolder.style.setProperty("touch-action","none"),this.cropImageHolder.style.setProperty("-ms-touch-action","none"),this.cropImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.cropImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImage.style.pointerEvents="auto",this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.cropImageHolder.style.transformOrigin="top left",this.positionCropImage(),this.defs=bt.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=bt.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=bt.createGroup(),this.editingTargetRotationScaleContainer=bt.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var s=bt.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(s);var c=bt.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(c),this.editingTargetContainer=bt.createGroup(),this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px)",this.editingTargetContainer.appendChild(this.editingTargetRotationContainer),this.cropImage.appendChild(this.editingTargetContainer),this.cropImageHolder.appendChild(this.cropImage),this.editorCanvas.appendChild(this.cropImageHolder)},j.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},j.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=bt.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new Fr(this.imageWidth,this.imageHeight,this.CANVAS_MARGIN,this.cropLayerContainer),this.cropLayer.onCropChange=this.cropRectChanged,this.cropLayer.numberOfGridLines=this.gridLines,this.cropLayer.isGridVisible=this.isGridVisible,this.cropLayer.cropShadeColor=this.styles.settings.cropShadeColor,this.cropLayer.cropFrameColor=this.styles.settings.cropFrameColor,this.cropLayer.gripColor=this.styles.settings.gripColor,this.cropLayer.gripFillColor=this.styles.settings.gripFillColor,this.cropLayer.open(),this.cropLayer.setCropRectangle(this.cropRect),this.zoomToCropEnabled&&this.zoomToCrop()},j.prototype.zoomToCrop=function(){if(this.cropRect){var s=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,c=this.cropRect.y-this.CANVAS_MARGIN+this.cropRect.height/2;this.zoomFactor=Math.min(this.imageWidth/this.cropRect.width,this.imageHeight/this.cropRect.height),this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin=s+"px "+c+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-s+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-c+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},j.prototype.unzoomFromCrop=function(){this.zoomFactor=1,this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin="center",this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px) scale(1)",this.cropLayer.zoomFactor=this.zoomFactor)},j.prototype.cropRectChanged=function(s){this.cropRect=s,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},j.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},j.prototype.overrideOverflow=function(){this.scrollXState=window.scrollX,this.scrollYState=window.scrollY,this.bodyOverflowState=document.body.style.overflow,window.scroll({top:0,left:0}),document.body.style.overflow="hidden"},j.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},j.prototype.showUI=function(){switch(this.addStyles(),this.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.displayMode){case"inline":this.coverDiv.style.position="absolute";var s=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,c=this.target.offsetTop>s+this.CANVAS_MARGIN?this.target.offsetTop-(s+this.CANVAS_MARGIN):0;this.coverDiv.style.top=c+"px",this.coverDiv.style.left=(this.target.offsetLeft>this.CANVAS_MARGIN?this.target.offsetLeft-this.CANVAS_MARGIN:0)+"px",this.coverDiv.style.width=this.target.offsetWidth+this.CANVAS_MARGIN+"px",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.displayMode==="popup"?this.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.addToolbars(),this.uiDiv.appendChild(this.topToolbar.getUI()),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.alignItems="center",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.contentDiv.style.overflow="hidden",this.contentDiv.style.backgroundColor=this.styles.settings.canvasBackgroundColor,this.displayMode==="popup"&&(this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.popupMargin+"px)"),this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.contentDiv.appendChild(this.editorCanvas),this.uiDiv.appendChild(this.bottomToolbar.getUI()),this.straightener.angle=this.rotationAngle},j.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},j.prototype.addTopToolbar=function(){var s=this;this.topToolbar=new Br,this.topToolbar.display=this.styles.settings.hideTopToolbar?"none":"",this.topToolbar.className=this.toolbarStyleClass.name,this.topToolbar.colorsClassName=this.styles.settings.toolbarStyleColorsClassName?this.styles.settings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name,this.topToolbar.fadeInClassName=this.styles.fadeInAnimationClassName,this.topToolbar.blockClassName=this.toolbarBlockStyleClass.name,this.topToolbar.buttonClassName=this.toolbarButtonStyleClass.name,this.topToolbar.buttonColorsClassName=this.styles.settings.toolbarButtonStyleColorsClassName?this.styles.settings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,this.topToolbar.buttonActiveColorsClassName=this.styles.settings.toolbarActiveButtonStyleColorsClassName?this.styles.settings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name;var c=new qr;c.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(c);var R=[];this.aspectRatios.forEach(function(Nt){var Kt=new It(ei.getIcon(Nt.horizontal,Nt.vertical),Nt.horizontal===0&&Nt.vertical===0?"FREE":Nt.horizontal+":"+Nt.vertical);Kt.onClick=function(){return s.ratioButtonClicked(Nt)},R.push(Kt)}),this.aspectRatioButton=new mr(ei.getIcon(0,0),"Aspect ratio",R),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,c.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var Z=new It('<svg viewBox="0 0 24 24"><path d="M10 4v4h4V4h-4m6 0v4h4V4h-4m0 6v4h4v-4h-4m0 6v4h4v-4h-4m-2 4v-4h-4v4h4m-6 0v-4H4v4h4m0-6v-4H4v4h4m0-6V4H4v4h4m2 6h4v-4h-4v4M4 2h16a2 2 0 012 2v16a2 2 0 01-2 2H4c-1.08 0-2-.9-2-2V4a2 2 0 012-2z"/></svg>',"Toggle grid");Z.isActive=this.isGridVisible,Z.onClick=function(){s.isGridVisible=!s.isGridVisible,Z.isActive=s.isGridVisible},c.addButton(Z);var U=new It('<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"Zoom to selection");if(U.isActive=this.zoomToCropEnabled,U.onClick=function(){s.zoomToCropEnabled=!s.zoomToCropEnabled,U.isActive=s.zoomToCropEnabled},c.addButton(U),!Kr.isLicensed){var ce=new ht;this.topToolbar.addElementBlock(ce);var Oe=document.createElement("div");Oe.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var Ke=document.createElement("a");Ke.style.color="currentColor",Ke.href="https://markerjs.com/products/cropro",Ke.target="_blank",Ke.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>',Oe.appendChild(Ke),ce.addElement(Oe)}var dt=new qr;dt.minWidth=3*this.toolbarHeight+"px",dt.contentAlign="end",this.topToolbar.addButtonBlock(dt);var Me=new It('<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");Me.onClick=this.startRenderAndClose,dt.addButton(Me),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Me.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var vt=new It('<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");vt.onClick=this.close,dt.addButton(vt),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(vt.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},j.prototype.addBottomToolbar=function(){var s=this;this.bottomToolbar=new Br,this.bottomToolbar.display=this.styles.settings.hideBottomToolbar?"none":"",this.bottomToolbar.className=this.toolbarStyleClass.name,this.bottomToolbar.colorsClassName=this.styles.settings.toolbarStyleColorsClassName?this.styles.settings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name,this.bottomToolbar.fadeInClassName=this.styles.fadeInAnimationClassName,this.bottomToolbar.blockClassName=this.toolbarBlockStyleClass.name,this.bottomToolbar.buttonClassName=this.toolbarButtonStyleClass.name,this.bottomToolbar.buttonColorsClassName=this.styles.settings.toolbarButtonStyleColorsClassName?this.styles.settings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,this.bottomToolbar.buttonActiveColorsClassName=this.styles.settings.toolbarActiveButtonStyleColorsClassName?this.styles.settings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name;var c=new qr;c.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(c);var R=new It('<svg viewBox="0 0 24 24"><path d="M13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93M7.1 18.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32M6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47m1.02-4.47L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47z"/></svg>',"Rotate left");R.onClick=this.rotateLeftButtonClicked,c.addButton(R);var Z=new It('<svg viewBox="0 0 24 24"><path d="M16.89 15.5l1.42 1.39c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.5M13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03m6.93-6.9a7.906 7.906 0 00-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47m-2.36-5.45L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45z"/></svg>',"Rotate right");Z.onClick=this.rotateRightButtonClicked,c.addButton(Z);var U=new ht;U.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(U),this.straightener=new Vr("Straighten"),this.straightener.className=this.toolbarStraightenerStyleClass.name,this.straightener.colorsClassName=this.styles.settings.toolbarStraightenerColorsClassName?this.styles.settings.toolbarStraightenerColorsClassName:this.toolbarStraightenerStyleColorsClass.name,this.straightener.onAngleChange=function(dt){s.rotateBy(dt),s.straightener.angle=s.rotationAngle},U.addElement(this.straightener.getUI());var ce=new qr;ce.minWidth=2*this.toolbarHeight+"px",ce.contentAlign="end",this.bottomToolbar.addButtonBlock(ce);var Oe=new It('<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");Oe.onClick=this.flipHorizontallyButtonClicked,ce.addButton(Oe);var Ke=new It('<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");Ke.onClick=this.flipVerticallyButtonClicked,ce.addButton(Ke)},j.prototype.ratioButtonClicked=function(s){this.aspectRatio=s,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},j.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=ei.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},j.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new Hr(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},j.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},j.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},j.prototype.restoreState=function(s){if(s){var c=this.cropLayer.getRescaledRect(s.width,s.height,this.imageWidth,this.imageHeight,s.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(c),this.cropRectChanged(c),this.flippedHorizontally=s.flippedHorizontally,this.flippedVertically=s.flippedVertically,this.applyFlip(),this.rotationAngle=s.rotationAngle,this.applyRotation()}},j.prototype.clientToLocalCoordinates=function(s,c){var R=this.cropImage.getBoundingClientRect();return{x:s-R.left,y:c-R.top}},j.prototype.onWindowResize=function(){this.positionUI()},j.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var s=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=s+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)"}this.positionCropImage()},j.prototype.rotateLeftButtonClicked=function(){var s=this.rotationAngle-90;this.rotationAngle%90!=0&&(s+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(s)},j.prototype.rotateRightButtonClicked=function(){var s=this.rotationAngle+90;this.rotationAngle%90!=0&&(s-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(s)},j.prototype.rotateTo=function(s){s=(s=s>180?s-360:s)<=-180?s+360:s,this.rotationAngle=s,this.applyRotation()},j.prototype.rotateBy=function(s){this.rotateTo((this.rotationAngle+s)%360)},j.prototype.applyRotation=function(){var s=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var c=this.editingTargetRotationContainer.transform.baseVal.getItem(0);c.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(c,0);var R=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/R.width,this.imageHeight/R.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=s},j.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},j.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},j.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},j.prototype.startRenderAndClose=function(){return Rt(this,void 0,void 0,function(){var s,c;return Ir(this,function(R){switch(R.label){case 0:return[4,this.render()];case 1:return s=R.sent(),c=this.getState(),this.renderEventListeners.forEach(function(Z){return Z(s,c)}),this.close(!0),[2]}})})},j.prototype.render=function(){return Rt(this,void 0,void 0,function(){var s;return Ir(this,function(c){switch(c.label){case 0:return(s=new fi).naturalSize=this.renderAtNaturalSize,s.imageType=this.renderImageType,s.imageQuality=this.renderImageQuality,s.width=this.renderWidth,s.height=this.renderHeight,this.unzoomFromCrop(),bt.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,s.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 1:return c.sent(),[4,s.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 2:return[2,c.sent()]}})})},j.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new pr("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 pr("toolbar_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new pr("toolbar-block",`
|
|
display: flex;
|
|
align-items: center;
|
|
box-sizing: content-box;
|
|
`));var s=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new pr("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.toolbarHeight-2*s)+`px;
|
|
height: `+(this.toolbarHeight-2*s)+`px;
|
|
padding: `+s+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new pr("toolbar_button_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new pr("toolbar_active_button",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
|
|
`)),this.styles.addRule(new hr("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new hr("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
|
|
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new pr("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 pr("toolbar_dropdown_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new pr("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 pr("toolbar_straightener",`
|
|
display: flex;
|
|
overflow: hidden;
|
|
justify-content: center;
|
|
height: `+(this.toolbarHeight-2*s)+`px;
|
|
padding: `+s+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new pr("toolbar_straightener_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`))},j.instanceCounter=0,j}(),St=re("8hTe"),pi=re.n(St),mi=/<pre[^>]*>/g;function gi(j){var s=document.createElement("div");return s.innerHTML=j,s.childNodes.length===0?"":s.childNodes[0].nodeValue}var vi=at.a=function(j){var s=j.value,c=s===void 0?"":s,R=j.edit,Z=R===void 0?!1:R,U=j.className,ce=j.showTextOnly,Oe=j.showLines,Ke=j.replaces,dt=j.zoomImg,Me=j.hasMask,vt=j.style,Nt=vt===void 0?{}:vt,Kt=j.stylesPrev,Rr=Kt===void 0?{}:Kt,gr=String(c),vr=Object(O.useRef)(),Xr=Object(O.useRef)(),Ri=Object(O.useState)(""),nr=Object(H.a)(Ri,2),Ur=nr[0],oi=nr[1],si=Object(O.useState)("office"),Or=Object(H.a)(si,2),Oi=Or[0],yi=Or[1],zi=function(){var Bt=new Ue(Xr.current);Bt.displayMode="popup",Bt.addRenderEventListener(function(){var dr=Object(M.a)(P.a.mark(function _t(qt){var Wt;return P.a.wrap(function(ar){for(;;)switch(ar.prev=ar.next){case 0:return vr.current.style.display="none",ar.next=3,Object(De.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:qt}});case 3:Wt=ar.sent,Wt!=null&&Wt.id&&Ke(Xr.current.getAttribute("src").replace(ae.a.API_SERVER,""),"/api/attachments/".concat(Wt==null?void 0:Wt.id,"?type=").concat(Wt.content_type));case 5:case"end":return ar.stop()}},_t)}));return function(_t){return dr.apply(this,arguments)}}()),Bt.show()},Ki=function(){var Bt=new Ot(Xr.current);Bt.settings.displayMode="popup",Bt.addEventListener("render",function(){var dr=Object(M.a)(P.a.mark(function _t(qt){var Wt;return P.a.wrap(function(ar){for(;;)switch(ar.prev=ar.next){case 0:if(vr.current.style.display="none",!Xr.current){ar.next=6;break}return ar.next=4,Object(De.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:qt.dataUrl}});case 4:Wt=ar.sent,Wt!=null&&Wt.id&&Ke(Xr.current.getAttribute("src").replace(ae.a.API_SERVER,""),"/api/attachments/".concat(Wt==null?void 0:Wt.id,"?type=").concat(Wt.content_type));case 6:case"end":return ar.stop()}},_t)}));return function(_t){return dr.apply(this,arguments)}}()),Bt.show(),window.markerArea=Bt},Yr=Object(O.useMemo)(function(){vr.current&&(vr.current.style.zIndex=-1);try{var Jt=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,Bt=/\"\/api\/attachments\/|\"\/attachments\/download\//g,dr=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;gr=gr.replace(Jt,"("+ae.a.API_SERVER+"/api/attachments/").replace(Bt,'"'+ae.a.API_SERVER+"/api/attachments/").replace(dr,'"'+ae.a.API_SERVER+"/files/uploads/").replaceAll("http://video.educoder","https://video.educoder").replaceAll("http://www.educoder.net/api","https://data.educoder.net/api").replaceAll("https://www.educoder.net/api","https://data.educoder.net/api").replace(/\r\n/g,`
|
|
`)}catch(ti){}var _t=Q(gr),qt=S();if(gr.match(/\[TOC\]/)&&(_t=_t.replace("<p>[TOC]</p>",k()),C()),_t=_t.replace(/(__special_katext_id_\d+__)/g,function(ti,ar){var Er=qt[ar],Vi=Er.type,Ei=Er.expression;return Object(pe.renderToString)(gi(Ei)||"",{displayMode:Vi==="block",throwOnError:!1,output:"html"})}),_t=_t.replace(/▁/g,"\u2581\u2581\u2581"),y(),ce){var Wt=document.createElement("div");return Wt.innerHTML=_t,Wt.innerText}return setTimeout(function(){return dn()},500),_t},[gr]),Gr=Object(O.useRef)();g.WebkitLineClamp=Oe,Oe&&(Nt=Object(N.a)(Object(N.a)({},Nt),g));function bi(Jt){var Bt=Jt.target;if(Bt.tagName.toUpperCase()==="IMG"){if(dt){var dr=Bt.getAttribute("src");oi(dr),yi("image")}}else if(Bt.tagName.toUpperCase()==="A"){var _t=Bt.getAttribute("href");if(_t.indexOf("office")>-1)Jt.preventDefault(),oi(_t),yi("office");else if(_t.indexOf("application/pdf")>-1)Jt.preventDefault(),oi(_t),yi("pdf");else if(_t.indexOf("text/html")>-1)Jt.preventDefault(),oi(_t),yi("html");else if(_t.startsWith("#")){Jt.preventDefault();var qt=document.getElementById(_t.replace("#",""));qt&&qt.scrollIntoView(!0)}}}var dn=function(){var Bt,dr=(Bt=Gr.current)===null||Bt===void 0?void 0:Bt.querySelectorAll("video");dr==null||dr.forEach(function(_t){if(_t.oncontextmenu=function(){return!1},_t.src.indexOf(".m3u8")>-1&&!_t.canPlayType("application/vnd.apple.mpegurl")){if(ee.a.isSupported()){var qt=new ee.a;qt.loadSource(_t.src),qt.attachMedia(_t)}}})};Object(O.useEffect)(function(){if(Gr.current&&Yr&&(Yr.match(mi)&&window.PR.prettyPrint()),Gr.current)return Gr.current.addEventListener("click",bi),function(){Gr.current.removeEventListener("click",bi),y(),C()}},[Yr,Gr.current,bi]);var xi=function(Bt){if(!Z)return;Bt.target.nodeName==="IMG"?(vr.current.style.zIndex=1,vr.current.style.display="flex",vr.current.style.width=Bt.target.clientWidth+"px",vr.current.style.height=Bt.target.clientHeight+"px",vr.current.style.top=Bt.target.offsetTop+"px",vr.current.style.left=Bt.target.offsetLeft+"px",Xr.current.src=Bt.target.getAttribute("src")):vr.current.style.display="none"};return b.a.createElement("div",{style:{position:"relative"}},b.a.createElement("div",{ref:Gr,style:Object(N.a)({},Nt),className:"".concat(U||""," markdown-body ").concat(pi.a.mdBody),onMouseOver:xi,dangerouslySetInnerHTML:{__html:Yr}}),b.a.createElement("div",{ref:vr,className:pi.a.button},b.a.createElement($.a,null,b.a.createElement(V.a,{onClick:function(){return zi()}},"\u88C1\u526A"),b.a.createElement(V.a,{onClick:function(){return Ki()}},"\u7F16\u8F91"))),b.a.createElement("img",{ref:Xr,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),b.a.createElement(ve.a,{close:!0,data:Ur,type:Ur!=null&&Ur.length?Oi:"",style:Object(N.a)({},Rr),onClose:function(){return oi("")}}))}},"9VGf":function(xt,at,re){"use strict";re.d(at,"a",function(){return _});var ne=re("q1tI"),$=re.n(ne);function _(V,N){var M=Object(ne.useRef)();Object(ne.useEffect)(function(){M.current=V}),Object(ne.useEffect)(function(){function H(){M.current()}if(N!==null){var F=setInterval(H,N);return function(){return clearInterval(F)}}},[N])}},"9ZNV":function(xt,at,re){"use strict";re.d(at,"a",function(){return O});var ne=re("0Owb"),$=re("+L6B"),_=re("2/Rp"),V=re("q1tI"),N=re.n(V),M=re("UUDw"),H=re.n(M),F=re("TSYQ"),P=re.n(F),O=function(A){var D=A.cancelText,L=D===void 0?"\u53D6\u6D88":D,w=A.okText,x=w===void 0?"\u786E\u5B9A":w,u=A.loading,a=u===void 0?!1:u,l=A.hasOkBtn,h=l===void 0?!0:l,C=A.okButtonProps,g=C===void 0?{}:C,m=A.onCancel,k=m===void 0?function(){}:m,v=A.onOk,f=v===void 0?function(){}:v,p=A.className,d=p===void 0?"":p;return N.a.createElement("div",{className:P()(H.a.buttonFixed,d)},N.a.createElement("div",{className:H.a.buttonWrap},N.a.createElement(_.a,{size:"large",className:"".concat(H.a.button," mr20"),onClick:k},L),h&&N.a.createElement(_.a,Object(ne.a)({size:"large",type:"primary",className:"".concat(H.a.button," mr20"),loading:a,onClick:f},g),x)))}},Bd2K:function(xt,at,re){(function(ne){ne(re("VrN/"),re("osHv"))})(function(ne){ne.defineOption("autoCloseTags",!1,function(P,O,b){if(b!=ne.Init&&b&&P.removeKeyMap("autoCloseTags"),!O)return;var A={name:"autoCloseTags"};(typeof O!="object"||O.whenClosing!==!1)&&(A["'/'"]=function(D){return M(D)}),(typeof O!="object"||O.whenOpening!==!1)&&(A["'>'"]=function(D){return V(D)}),P.addKeyMap(A)});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(P){if(P.getOption("disableInput"))return ne.Pass;for(var O=P.listSelections(),b=[],A=P.getOption("autoCloseTags"),D=0;D<O.length;D++){if(!O[D].empty())return ne.Pass;var L=O[D].head,w=P.getTokenAt(L),x=ne.innerMode(P.getMode(),w.state),u=x.state,a=x.mode.xmlCurrentTag&&x.mode.xmlCurrentTag(u),l=a&&a.name;if(!l)return ne.Pass;var h=x.mode.configuration=="html",C=typeof A=="object"&&A.dontCloseTags||h&&$,g=typeof A=="object"&&A.indentTags||h&&_;w.end>L.ch&&(l=l.slice(0,l.length-w.end+L.ch));var m=l.toLowerCase();if(!l||w.type=="string"&&(w.end!=L.ch||!/[\"\']/.test(w.string.charAt(w.string.length-1))||w.string.length==1)||w.type=="tag"&&a.close||w.string.indexOf("/")==L.ch-w.start-1||C&&H(C,m)>-1||F(P,x.mode.xmlCurrentContext&&x.mode.xmlCurrentContext(u)||[],l,L,!0))return ne.Pass;var k=typeof A=="object"&&A.emptyTags;if(k&&H(k,l)>-1){b[D]={text:"/>",newPos:ne.Pos(L.line,L.ch+2)};continue}var v=g&&H(g,m)>-1;b[D]={indent:v,text:">"+(v?`
|
|
|
|
`:"")+"</"+l+">",newPos:v?ne.Pos(L.line+1,0):ne.Pos(L.line,L.ch+1)}}for(var f=typeof A=="object"&&A.dontIndentOnAutoClose,D=O.length-1;D>=0;D--){var p=b[D];P.replaceRange(p.text,O[D].head,O[D].anchor,"+insert");var d=P.listSelections().slice(0);d[D]={head:p.newPos,anchor:p.newPos},P.setSelections(d),!f&&p.indent&&(P.indentLine(p.newPos.line,null,!0),P.indentLine(p.newPos.line+1,null,!0))}}function N(P,O){for(var b=P.listSelections(),A=[],D=O?"/":"</",L=P.getOption("autoCloseTags"),w=typeof L=="object"&&L.dontIndentOnSlash,x=0;x<b.length;x++){if(!b[x].empty())return ne.Pass;var u=b[x].head,a=P.getTokenAt(u),l=ne.innerMode(P.getMode(),a.state),h=l.state;if(O&&(a.type=="string"||a.string.charAt(0)!="<"||a.start!=u.ch-1))return ne.Pass;var C,g=l.mode.name!="xml"&&P.getMode().name=="htmlmixed";if(g&&l.mode.name=="javascript")C=D+"script";else if(g&&l.mode.name=="css")C=D+"style";else{var m=l.mode.xmlCurrentContext&&l.mode.xmlCurrentContext(h);if(!m||m.length&&F(P,m,m[m.length-1],u))return ne.Pass;C=D+m[m.length-1]}P.getLine(u.line).charAt(a.end)!=">"&&(C+=">"),A[x]=C}if(P.replaceSelections(A),b=P.listSelections(),!w)for(var x=0;x<b.length;x++)(x==b.length-1||b[x].head.line<b[x+1].head.line)&&P.indentLine(b[x].head.line)}function M(P){return P.getOption("disableInput")?ne.Pass:N(P,!0)}ne.commands.closeTag=function(P){return N(P)};function H(P,O){if(P.indexOf)return P.indexOf(O);for(var b=0,A=P.length;b<A;++b)if(P[b]==O)return b;return-1}function F(P,O,b,A,D){if(!ne.scanForClosingTag)return!1;var L=Math.min(P.lastLine()+1,A.line+500),w=ne.scanForClosingTag(P,A,null,L);if(!w||w.tag!=b)return!1;for(var x=D?1:0,u=O.length-1;u>=0&&O[u]==b;u--)++x;A=w.to;for(var u=1;u<x;u++){var a=ne.scanForClosingTag(P,A,null,L);if(!a||a.tag!=b)return!1;A=a.to}return!0}})},BjJ7:function(xt,at,re){"use strict";re.d(at,"d",function(){return $}),re.d(at,"c",function(){return _}),re.d(at,"e",function(){return V}),re.d(at,"b",function(){return N}),re.d(at,"a",function(){return H});var ne=re("m3rI");function $(F){var P=!0;if(F.length>0){for(var O=0;O<F.length;O++)if(F[O].compile_success==0||!F[O].compile_success){P=!1;break}}else P=!1;return P}function _(F){for(var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",O=[],b=0;b<F.length;b++){var A=F[b],D=P?"".concat(P,"/").concat(A.name):"".concat(A.name);O.push({title:A.name,isLeaf:!(A.type==="tree"),key:D})}return O}function V(F,P,O){for(var b=0;b<F.length;b++){var A=F[b];if(A.key===P){A.children=O;break}A.children&&V(A.children,P,O)}return F}function N(F,P,O){var b;return function(){var A=this,D=arguments,L=function(){b=null,O||F.apply(A,D)},w=O&&!b;clearTimeout(b),b=setTimeout(L,P),w&&F.apply(A,D)}}var M=!0,H=ne.a.API_SERVER},"C+DQ":function(xt,at,re){},DlQD:function(xt,at,re){(function(ne,$){xt.exports=$()})(this,function(){"use strict";function ne(fe,le){for(var ue=0;ue<le.length;ue++){var q=le[ue];q.enumerable=q.enumerable||!1,q.configurable=!0,"value"in q&&(q.writable=!0),Object.defineProperty(fe,q.key,q)}}function $(fe,le,ue){return le&&ne(fe.prototype,le),ue&&ne(fe,ue),fe}function _(fe,le){if(!fe)return;if(typeof fe=="string")return V(fe,le);var ue=Object.prototype.toString.call(fe).slice(8,-1);if(ue==="Object"&&fe.constructor&&(ue=fe.constructor.name),ue==="Map"||ue==="Set")return Array.from(fe);if(ue==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(ue))return V(fe,le)}function V(fe,le){(le==null||le>fe.length)&&(le=fe.length);for(var ue=0,q=new Array(le);ue<le;ue++)q[ue]=fe[ue];return q}function N(fe,le){var ue;if(typeof Symbol=="undefined"||fe[Symbol.iterator]==null){if(Array.isArray(fe)||(ue=_(fe))||le&&fe&&typeof fe.length=="number"){ue&&(fe=ue);var q=0;return function(){return q>=fe.length?{done:!0}:{done:!1,value:fe[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 ue=fe[Symbol.iterator](),ue.next.bind(ue)}function M(fe,le){return le={exports:{}},fe(le,le.exports),le.exports}var H=M(function(fe){function le(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}function ue(q){fe.exports.defaults=q}fe.exports={defaults:le(),getDefaults:le,changeDefaults:ue}}),F=H.defaults,P=H.getDefaults,O=H.changeDefaults,b=/[&<>"']/,A=/[&<>"']/g,D=/[<>"']|&(?!#?\w+;)/,L=/[<>"']|&(?!#?\w+;)/g,w={"&":"&","<":"<",">":">",'"':""","'":"'"},x=function(le){return w[le]};function u(fe,le){if(le){if(b.test(fe))return fe.replace(A,x)}else if(D.test(fe))return fe.replace(L,x);return fe}var a=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function l(fe){return fe.replace(a,function(le,ue){return ue=ue.toLowerCase(),ue==="colon"?":":ue.charAt(0)==="#"?ue.charAt(1)==="x"?String.fromCharCode(parseInt(ue.substring(2),16)):String.fromCharCode(+ue.substring(1)):""})}var h=/(^|[^\[])\^/g;function C(fe,le){fe=fe.source||fe,le=le||"";var ue={replace:function(te,ie){return ie=ie.source||ie,ie=ie.replace(h,"$1"),fe=fe.replace(te,ie),ue},getRegex:function(){return new RegExp(fe,le)}};return ue}var g=/[^\w:]/g,m=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function k(fe,le,ue){if(fe){var q;try{q=decodeURIComponent(l(ue)).replace(g,"").toLowerCase()}catch(te){return null}if(q.indexOf("javascript:")===0||q.indexOf("vbscript:")===0||q.indexOf("data:")===0)return null}le&&!m.test(ue)&&(ue=o(le,ue));try{ue=encodeURI(ue).replace(/%25/g,"%")}catch(te){return null}return ue}var v={},f=/^[^:]+:\/*[^/]*$/,p=/^([^:]+:)[\s\S]*$/,d=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(fe,le){v[" "+fe]||(f.test(fe)?v[" "+fe]=fe+"/":v[" "+fe]=I(fe,"/",!0)),fe=v[" "+fe];var ue=fe.indexOf(":")===-1;return le.substring(0,2)==="//"?ue?le:fe.replace(p,"$1")+le:le.charAt(0)==="/"?ue?le:fe.replace(d,"$1")+le:fe+le}var S={exec:function(){}};function y(fe){for(var le=1,ue,q;le<arguments.length;le++){ue=arguments[le];for(q in ue)Object.prototype.hasOwnProperty.call(ue,q)&&(fe[q]=ue[q])}return fe}function T(fe,le){var ue=fe.replace(/\|/g,function(ie,de,me){for(var Ee=!1,Pe=de;--Pe>=0&&me[Pe]==="\\";)Ee=!Ee;return Ee?"|":" |"}),q=ue.split(/ \|/),te=0;if(q.length>le)q.splice(le);else for(;q.length<le;)q.push("");for(;te<q.length;te++)q[te]=q[te].trim().replace(/\\\|/g,"|");return q}function I(fe,le,ue){var q=fe.length;if(q===0)return"";for(var te=0;te<q;){var ie=fe.charAt(q-te-1);if(ie===le&&!ue)te++;else if(ie!==le&&ue)te++;else break}return fe.substr(0,q-te)}function G(fe,le){if(fe.indexOf(le[1])===-1)return-1;for(var ue=fe.length,q=0,te=0;te<ue;te++)if(fe[te]==="\\")te++;else if(fe[te]===le[0])q++;else if(fe[te]===le[1]&&(q--,q<0))return te;return-1}function X(fe){fe&&fe.sanitize&&!fe.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 Q={escape:u,unescape:l,edit:C,cleanUrl:k,resolveUrl:o,noopTest:S,merge:y,splitCells:T,rtrim:I,findClosingBracket:G,checkSanitizeDeprecation:X},z=H.defaults,W=Q.rtrim,ee=Q.splitCells,ae=Q.escape,pe=Q.findClosingBracket;function ve(fe,le,ue){var q=le.href,te=le.title?ae(le.title):null,ie=fe[1].replace(/\\([\[\]])/g,"$1");return fe[0].charAt(0)!=="!"?{type:"link",raw:ue,href:q,title:te,text:ie}:{type:"image",raw:ue,href:q,title:te,text:ae(ie)}}function De(fe,le){var ue=fe.match(/^(\s+)(?:```)/);if(ue===null)return le;var q=ue[1];return le.split(`
|
|
`).map(function(te){var ie=te.match(/^\s+/);if(ie===null)return te;var de=ie[0];return de.length>=q.length?te.slice(q.length):te}).join(`
|
|
`)}var xe=function(){function fe(ue){this.options=ue||z}var le=fe.prototype;return le.space=function(q){var te=this.rules.block.newline.exec(q);if(te)return te[0].length>1?{type:"space",raw:te[0]}:{raw:`
|
|
`}},le.code=function(q,te){var ie=this.rules.block.code.exec(q);if(ie){var de=te[te.length-1];if(de&&de.type==="paragraph")return{raw:ie[0],text:ie[0].trimRight()};var me=ie[0].replace(/^ {4}/gm,"");return{type:"code",raw:ie[0],codeBlockStyle:"indented",text:this.options.pedantic?me:W(me,`
|
|
`)}}},le.fences=function(q){var te=this.rules.block.fences.exec(q);if(te){var ie=te[0],de=De(ie,te[3]||"");return{type:"code",raw:ie,lang:te[2]?te[2].trim():te[2],text:de}}},le.heading=function(q){var te=this.rules.block.heading.exec(q);if(te)return{type:"heading",raw:te[0],depth:te[1].length,text:te[2]}},le.nptable=function(q){var te=this.rules.block.nptable.exec(q);if(te){var ie={type:"table",header:ee(te[1].replace(/^ *| *\| *$/g,"")),align:te[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:te[3]?te[3].replace(/\n$/,"").split(`
|
|
`):[],raw:te[0]};if(ie.header.length===ie.align.length){var de=ie.align.length,me;for(me=0;me<de;me++)/^ *-+: *$/.test(ie.align[me])?ie.align[me]="right":/^ *:-+: *$/.test(ie.align[me])?ie.align[me]="center":/^ *:-+ *$/.test(ie.align[me])?ie.align[me]="left":ie.align[me]=null;for(de=ie.cells.length,me=0;me<de;me++)ie.cells[me]=ee(ie.cells[me],ie.header.length);return ie}}},le.hr=function(q){var te=this.rules.block.hr.exec(q);if(te)return{type:"hr",raw:te[0]}},le.blockquote=function(q){var te=this.rules.block.blockquote.exec(q);if(te){var ie=te[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:te[0],text:ie}}},le.list=function(q){var te=this.rules.block.list.exec(q);if(te){for(var ie=te[0],de=te[2],me=de.length>1,Ee=de[de.length-1]===")",Pe={type:"list",raw:ie,ordered:me,start:me?+de.slice(0,-1):"",loose:!1,items:[]},rt=te[0].match(this.rules.block.item),mt=!1,ft,wt,Tt,ut,Ft,Ot,Zt,Xt=rt.length,Rt=0;Rt<Xt;Rt++)ft=rt[Rt],ie=ft,wt=ft.length,ft=ft.replace(/^ *([*+-]|\d+[.)]) */,""),~ft.indexOf(`
|
|
`)&&(wt-=ft.length,ft=this.options.pedantic?ft.replace(/^ {1,4}/gm,""):ft.replace(new RegExp("^ {1,"+wt+"}","gm"),"")),Rt!==Xt-1&&(Tt=this.rules.block.bullet.exec(rt[Rt+1])[0],(me?Tt.length===1||!Ee&&Tt[Tt.length-1]===")":Tt.length>1||this.options.smartLists&&Tt!==de)&&(ut=rt.slice(Rt+1).join(`
|
|
`),Pe.raw=Pe.raw.substring(0,Pe.raw.length-ut.length),Rt=Xt-1)),Ft=mt||/\n\n(?!\s*$)/.test(ft),Rt!==Xt-1&&(mt=ft.charAt(ft.length-1)===`
|
|
`,Ft||(Ft=mt)),Ft&&(Pe.loose=!0),Ot=/^\[[ xX]\] /.test(ft),Zt=void 0,Ot&&(Zt=ft[1]!==" ",ft=ft.replace(/^\[[ xX]\] +/,"")),Pe.items.push({type:"list_item",raw:ie,task:Ot,checked:Zt,loose:Ft,text:ft});return Pe}},le.html=function(q){var te=this.rules.block.html.exec(q);if(te)return{type:this.options.sanitize?"paragraph":"html",raw:te[0],pre:!this.options.sanitizer&&(te[1]==="pre"||te[1]==="script"||te[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(te[0]):ae(te[0]):te[0]}},le.def=function(q){var te=this.rules.block.def.exec(q);if(te){te[3]&&(te[3]=te[3].substring(1,te[3].length-1));var ie=te[1].toLowerCase().replace(/\s+/g," ");return{tag:ie,raw:te[0],href:te[2],title:te[3]}}},le.table=function(q){var te=this.rules.block.table.exec(q);if(te){var ie={type:"table",header:ee(te[1].replace(/^ *| *\| *$/g,"")),align:te[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:te[3]?te[3].replace(/\n$/,"").split(`
|
|
`):[]};if(ie.header.length===ie.align.length){ie.raw=te[0];var de=ie.align.length,me;for(me=0;me<de;me++)/^ *-+: *$/.test(ie.align[me])?ie.align[me]="right":/^ *:-+: *$/.test(ie.align[me])?ie.align[me]="center":/^ *:-+ *$/.test(ie.align[me])?ie.align[me]="left":ie.align[me]=null;for(de=ie.cells.length,me=0;me<de;me++)ie.cells[me]=ee(ie.cells[me].replace(/^ *\| *| *\| *$/g,""),ie.header.length);return ie}}},le.lheading=function(q){var te=this.rules.block.lheading.exec(q);if(te)return{type:"heading",raw:te[0],depth:te[2].charAt(0)==="="?1:2,text:te[1]}},le.paragraph=function(q){var te=this.rules.block.paragraph.exec(q);if(te)return{type:"paragraph",raw:te[0],text:te[1].charAt(te[1].length-1)===`
|
|
`?te[1].slice(0,-1):te[1]}},le.text=function(q,te){var ie=this.rules.block.text.exec(q);if(ie){var de=te[te.length-1];return de&&de.type==="text"?{raw:ie[0],text:ie[0]}:{type:"text",raw:ie[0],text:ie[0]}}},le.escape=function(q){var te=this.rules.inline.escape.exec(q);if(te)return{type:"escape",raw:te[0],text:ae(te[1])}},le.tag=function(q,te,ie){var de=this.rules.inline.tag.exec(q);if(de)return!te&&/^<a /i.test(de[0])?te=!0:te&&/^<\/a>/i.test(de[0])&&(te=!1),!ie&&/^<(pre|code|kbd|script)(\s|>)/i.test(de[0])?ie=!0:ie&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(de[0])&&(ie=!1),{type:this.options.sanitize?"text":"html",raw:de[0],inLink:te,inRawBlock:ie,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(de[0]):ae(de[0]):de[0]}},le.link=function(q){var te=this.rules.inline.link.exec(q);if(te){var ie=pe(te[2],"()");if(ie>-1){var de=te[0].indexOf("!")===0?5:4,me=de+te[1].length+ie;te[2]=te[2].substring(0,ie),te[0]=te[0].substring(0,me).trim(),te[3]=""}var Ee=te[2],Pe="";if(this.options.pedantic){var rt=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(Ee);rt?(Ee=rt[1],Pe=rt[3]):Pe=""}else Pe=te[3]?te[3].slice(1,-1):"";Ee=Ee.trim().replace(/^<([\s\S]*)>$/,"$1");var mt=ve(te,{href:Ee&&Ee.replace(this.rules.inline._escapes,"$1"),title:Pe&&Pe.replace(this.rules.inline._escapes,"$1")},te[0]);return mt}},le.reflink=function(q,te){var ie;if((ie=this.rules.inline.reflink.exec(q))||(ie=this.rules.inline.nolink.exec(q))){var de=(ie[2]||ie[1]).replace(/\s+/g," ");if(de=te[de.toLowerCase()],!de||!de.href){var me=ie[0].charAt(0);return{type:"text",raw:me,text:me}}var Ee=ve(ie,de,ie[0]);return Ee}},le.strong=function(q,te,ie){ie===void 0&&(ie="");var de=this.rules.inline.strong.start.exec(q);if(de&&(!de[1]||de[1]&&(ie===""||this.rules.inline.punctuation.exec(ie)))){te=te.slice(-1*q.length);var me=de[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;me.lastIndex=0;for(var Ee;(de=me.exec(te))!=null;)if(Ee=this.rules.inline.strong.middle.exec(te.slice(0,de.index+3)),Ee)return{type:"strong",raw:q.slice(0,Ee[0].length),text:q.slice(2,Ee[0].length-2)}}},le.em=function(q,te,ie){ie===void 0&&(ie="");var de=this.rules.inline.em.start.exec(q);if(de&&(!de[1]||de[1]&&(ie===""||this.rules.inline.punctuation.exec(ie)))){te=te.slice(-1*q.length);var me=de[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;me.lastIndex=0;for(var Ee;(de=me.exec(te))!=null;)if(Ee=this.rules.inline.em.middle.exec(te.slice(0,de.index+2)),Ee)return{type:"em",raw:q.slice(0,Ee[0].length),text:q.slice(1,Ee[0].length-1)}}},le.codespan=function(q){var te=this.rules.inline.code.exec(q);if(te){var ie=te[2].replace(/\n/g," "),de=/[^ ]/.test(ie),me=ie.startsWith(" ")&&ie.endsWith(" ");return de&&me&&(ie=ie.substring(1,ie.length-1)),ie=ae(ie,!0),{type:"codespan",raw:te[0],text:ie}}},le.br=function(q){var te=this.rules.inline.br.exec(q);if(te)return{type:"br",raw:te[0]}},le.del=function(q){var te=this.rules.inline.del.exec(q);if(te)return{type:"del",raw:te[0],text:te[1]}},le.autolink=function(q,te){var ie=this.rules.inline.autolink.exec(q);if(ie){var de,me;return ie[2]==="@"?(de=ae(this.options.mangle?te(ie[1]):ie[1]),me="mailto:"+de):(de=ae(ie[1]),me=de),{type:"link",raw:ie[0],text:de,href:me,tokens:[{type:"text",raw:de,text:de}]}}},le.url=function(q,te){var ie;if(ie=this.rules.inline.url.exec(q)){var de,me;if(ie[2]==="@")de=ae(this.options.mangle?te(ie[0]):ie[0]),me="mailto:"+de;else{var Ee;do Ee=ie[0],ie[0]=this.rules.inline._backpedal.exec(ie[0])[0];while(Ee!==ie[0]);de=ae(ie[0]),ie[1]==="www."?me="http://"+de:me=de}return{type:"link",raw:ie[0],text:de,href:me,tokens:[{type:"text",raw:de,text:de}]}}},le.inlineText=function(q,te,ie){var de=this.rules.inline.text.exec(q);if(de){var me;return te?me=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(de[0]):ae(de[0]):de[0]:me=ae(this.options.smartypants?ie(de[0]):de[0]),{type:"text",raw:de[0],text:me}}},fe}(),Ce=Q.noopTest,Ae=Q.edit,Se=Q.merge,ge={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:Ce,table:Ce,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};ge._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,ge._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ge.def=Ae(ge.def).replace("label",ge._label).replace("title",ge._title).getRegex(),ge.bullet=/(?:[*+-]|\d{1,9}[.)])/,ge.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,ge.item=Ae(ge.item,"gm").replace(/bull/g,ge.bullet).getRegex(),ge.list=Ae(ge.list).replace(/bull/g,ge.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ge.def.source+")").getRegex(),ge._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ge._comment=/<!--(?!-?>)[\s\S]*?-->/,ge.html=Ae(ge.html,"i").replace("comment",ge._comment).replace("tag",ge._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ge.paragraph=Ae(ge._paragraph).replace("hr",ge.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",ge._tag).getRegex(),ge.blockquote=Ae(ge.blockquote).replace("paragraph",ge.paragraph).getRegex(),ge.normal=Se({},ge),ge.gfm=Se({},ge.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n *([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n *\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),ge.gfm.nptable=Ae(ge.gfm.nptable).replace("hr",ge.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",ge._tag).getRegex(),ge.gfm.table=Ae(ge.gfm.table).replace("hr",ge.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",ge._tag).getRegex(),ge.pedantic=Se({},ge.normal,{html:Ae(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ge._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:Ce,paragraph:Ae(ge.normal._paragraph).replace("hr",ge.hr).replace("heading",` *#{1,6} *[^
|
|
]`).replace("lheading",ge.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var oe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ce,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",strong:{start:/^(?:(\*\*(?=[*punctuation]))|\*\*)(?![\s])|__/,middle:/^\*\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*\*$|^__(?![\s])((?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?)__$/,endAst:/[^punctuation\s]\*\*(?!\*)|[punctuation]\*\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]__(?!_)(?:(?=[punctuation\s])|$)/},em:{start:/^(?:(\*(?=[punctuation]))|\*)(?![*\s])|_/,middle:/^\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*$|^_(?![_\s])(?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?_$/,endAst:/[^punctuation\s]\*(?!\*)|[punctuation]\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]_(?!_)(?:(?=[punctuation\s])|$)/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Ce,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};oe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",oe.punctuation=Ae(oe.punctuation).replace(/punctuation/g,oe._punctuation).getRegex(),oe._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",oe._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",oe.em.start=Ae(oe.em.start).replace(/punctuation/g,oe._punctuation).getRegex(),oe.em.middle=Ae(oe.em.middle).replace(/punctuation/g,oe._punctuation).replace(/overlapSkip/g,oe._overlapSkip).getRegex(),oe.em.endAst=Ae(oe.em.endAst,"g").replace(/punctuation/g,oe._punctuation).getRegex(),oe.em.endUnd=Ae(oe.em.endUnd,"g").replace(/punctuation/g,oe._punctuation).getRegex(),oe.strong.start=Ae(oe.strong.start).replace(/punctuation/g,oe._punctuation).getRegex(),oe.strong.middle=Ae(oe.strong.middle).replace(/punctuation/g,oe._punctuation).replace(/blockSkip/g,oe._blockSkip).getRegex(),oe.strong.endAst=Ae(oe.strong.endAst,"g").replace(/punctuation/g,oe._punctuation).getRegex(),oe.strong.endUnd=Ae(oe.strong.endUnd,"g").replace(/punctuation/g,oe._punctuation).getRegex(),oe.blockSkip=Ae(oe._blockSkip,"g").getRegex(),oe.overlapSkip=Ae(oe._overlapSkip,"g").getRegex(),oe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,oe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,oe._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])?)+(?![-_])/,oe.autolink=Ae(oe.autolink).replace("scheme",oe._scheme).replace("email",oe._email).getRegex(),oe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,oe.tag=Ae(oe.tag).replace("comment",ge._comment).replace("attribute",oe._attribute).getRegex(),oe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,oe._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,oe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,oe.link=Ae(oe.link).replace("label",oe._label).replace("href",oe._href).replace("title",oe._title).getRegex(),oe.reflink=Ae(oe.reflink).replace("label",oe._label).getRegex(),oe.reflinkSearch=Ae(oe.reflinkSearch,"g").replace("reflink",oe.reflink).replace("nolink",oe.nolink).getRegex(),oe.normal=Se({},oe),oe.pedantic=Se({},oe.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:Ae(/^!?\[(label)\]\((.*?)\)/).replace("label",oe._label).getRegex(),reflink:Ae(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",oe._label).getRegex()}),oe.gfm=Se({},oe.normal,{escape:Ae(oe.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),oe.gfm.url=Ae(oe.gfm.url,"i").replace("email",oe.gfm._extended_email).getRegex(),oe.breaks=Se({},oe.gfm,{br:Ae(oe.br).replace("{2,}","*").getRegex(),text:Ae(oe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var Re={block:ge,inline:oe},Ze=H.defaults,He=Re.block,Ge=Re.inline;function $e(fe){return fe.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 _e(fe){var le="",ue,q,te=fe.length;for(ue=0;ue<te;ue++)q=fe.charCodeAt(ue),Math.random()>.5&&(q="x"+q.toString(16)),le+="&#"+q+";";return le}var Ie=function(){function fe(ue){this.tokens=[],this.tokens.links=Object.create(null),this.options=ue||Ze,this.options.tokenizer=this.options.tokenizer||new xe,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var q={block:He.normal,inline:Ge.normal};this.options.pedantic?(q.block=He.pedantic,q.inline=Ge.pedantic):this.options.gfm&&(q.block=He.gfm,this.options.breaks?q.inline=Ge.breaks:q.inline=Ge.gfm),this.tokenizer.rules=q}fe.lex=function(q,te){var ie=new fe(te);return ie.lex(q)};var le=fe.prototype;return le.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},le.blockTokens=function(q,te,ie){te===void 0&&(te=[]),ie===void 0&&(ie=!0),q=q.replace(/^ +$/gm,"");for(var de,me,Ee,Pe;q;){if(de=this.tokenizer.space(q)){q=q.substring(de.raw.length),de.type&&te.push(de);continue}if(de=this.tokenizer.code(q,te)){q=q.substring(de.raw.length),de.type?te.push(de):(Pe=te[te.length-1],Pe.raw+=`
|
|
`+de.raw,Pe.text+=`
|
|
`+de.text);continue}if(de=this.tokenizer.fences(q)){q=q.substring(de.raw.length),te.push(de);continue}if(de=this.tokenizer.heading(q)){q=q.substring(de.raw.length),te.push(de);continue}if(de=this.tokenizer.nptable(q)){q=q.substring(de.raw.length),te.push(de);continue}if(de=this.tokenizer.hr(q)){q=q.substring(de.raw.length),te.push(de);continue}if(de=this.tokenizer.blockquote(q)){q=q.substring(de.raw.length),de.tokens=this.blockTokens(de.text,[],ie),te.push(de);continue}if(de=this.tokenizer.list(q)){for(q=q.substring(de.raw.length),Ee=de.items.length,me=0;me<Ee;me++)de.items[me].tokens=this.blockTokens(de.items[me].text,[],!1);te.push(de);continue}if(de=this.tokenizer.html(q)){q=q.substring(de.raw.length),te.push(de);continue}if(ie&&(de=this.tokenizer.def(q))){q=q.substring(de.raw.length),this.tokens.links[de.tag]||(this.tokens.links[de.tag]={href:de.href,title:de.title});continue}if(de=this.tokenizer.table(q)){q=q.substring(de.raw.length),te.push(de);continue}if(de=this.tokenizer.lheading(q)){q=q.substring(de.raw.length),te.push(de);continue}if(ie&&(de=this.tokenizer.paragraph(q))){q=q.substring(de.raw.length),te.push(de);continue}if(de=this.tokenizer.text(q,te)){q=q.substring(de.raw.length),de.type?te.push(de):(Pe=te[te.length-1],Pe.raw+=`
|
|
`+de.raw,Pe.text+=`
|
|
`+de.text);continue}if(q){var rt="Infinite loop on byte: "+q.charCodeAt(0);if(this.options.silent){console.error(rt);break}else throw new Error(rt)}}return te},le.inline=function(q){var te,ie,de,me,Ee,Pe,rt=q.length;for(te=0;te<rt;te++){Pe=q[te];switch(Pe.type){case"paragraph":case"text":case"heading":{Pe.tokens=[],this.inlineTokens(Pe.text,Pe.tokens);break}case"table":{for(Pe.tokens={header:[],cells:[]},me=Pe.header.length,ie=0;ie<me;ie++)Pe.tokens.header[ie]=[],this.inlineTokens(Pe.header[ie],Pe.tokens.header[ie]);for(me=Pe.cells.length,ie=0;ie<me;ie++)for(Ee=Pe.cells[ie],Pe.tokens.cells[ie]=[],de=0;de<Ee.length;de++)Pe.tokens.cells[ie][de]=[],this.inlineTokens(Ee[de],Pe.tokens.cells[ie][de]);break}case"blockquote":{this.inline(Pe.tokens);break}case"list":{for(me=Pe.items.length,ie=0;ie<me;ie++)this.inline(Pe.items[ie].tokens);break}}}return q},le.inlineTokens=function(q,te,ie,de,me){te===void 0&&(te=[]),ie===void 0&&(ie=!1),de===void 0&&(de=!1),me===void 0&&(me="");var Ee,Pe=q,rt;if(this.tokens.links){var mt=Object.keys(this.tokens.links);if(mt.length>0)for(;(rt=this.tokenizer.rules.inline.reflinkSearch.exec(Pe))!=null;)mt.includes(rt[0].slice(rt[0].lastIndexOf("[")+1,-1))&&(Pe=Pe.slice(0,rt.index)+"["+"a".repeat(rt[0].length-2)+"]"+Pe.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(rt=this.tokenizer.rules.inline.blockSkip.exec(Pe))!=null;)Pe=Pe.slice(0,rt.index)+"["+"a".repeat(rt[0].length-2)+"]"+Pe.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;q;){if(Ee=this.tokenizer.escape(q)){q=q.substring(Ee.raw.length),te.push(Ee);continue}if(Ee=this.tokenizer.tag(q,ie,de)){q=q.substring(Ee.raw.length),ie=Ee.inLink,de=Ee.inRawBlock,te.push(Ee);continue}if(Ee=this.tokenizer.link(q)){q=q.substring(Ee.raw.length),Ee.type==="link"&&(Ee.tokens=this.inlineTokens(Ee.text,[],!0,de)),te.push(Ee);continue}if(Ee=this.tokenizer.reflink(q,this.tokens.links)){q=q.substring(Ee.raw.length),Ee.type==="link"&&(Ee.tokens=this.inlineTokens(Ee.text,[],!0,de)),te.push(Ee);continue}if(Ee=this.tokenizer.strong(q,Pe,me)){q=q.substring(Ee.raw.length),Ee.tokens=this.inlineTokens(Ee.text,[],ie,de),te.push(Ee);continue}if(Ee=this.tokenizer.em(q,Pe,me)){q=q.substring(Ee.raw.length),Ee.tokens=this.inlineTokens(Ee.text,[],ie,de),te.push(Ee);continue}if(Ee=this.tokenizer.codespan(q)){q=q.substring(Ee.raw.length),te.push(Ee);continue}if(Ee=this.tokenizer.br(q)){q=q.substring(Ee.raw.length),te.push(Ee);continue}if(Ee=this.tokenizer.del(q)){q=q.substring(Ee.raw.length),Ee.tokens=this.inlineTokens(Ee.text,[],ie,de),te.push(Ee);continue}if(Ee=this.tokenizer.autolink(q,_e)){q=q.substring(Ee.raw.length),te.push(Ee);continue}if(!ie&&(Ee=this.tokenizer.url(q,_e))){q=q.substring(Ee.raw.length),te.push(Ee);continue}if(Ee=this.tokenizer.inlineText(q,de,$e)){q=q.substring(Ee.raw.length),me=Ee.raw.slice(-1),te.push(Ee);continue}if(q){var ft="Infinite loop on byte: "+q.charCodeAt(0);if(this.options.silent){console.error(ft);break}else throw new Error(ft)}}return te},$(fe,null,[{key:"rules",get:function(){return{block:He,inline:Ge}}}]),fe}(),We=H.defaults,Ve=Q.cleanUrl,ze=Q.escape,Be=function(){function fe(ue){this.options=ue||We}var le=fe.prototype;return le.code=function(q,te,ie){var de=(te||"").match(/\S*/)[0];if(this.options.highlight){var me=this.options.highlight(q,de);me!=null&&me!==q&&(ie=!0,q=me)}return de?'<pre><code class="'+this.options.langPrefix+ze(de,!0)+'">'+(ie?q:ze(q,!0))+`</code></pre>
|
|
`:"<pre><code>"+(ie?q:ze(q,!0))+`</code></pre>
|
|
`},le.blockquote=function(q){return`<blockquote>
|
|
`+q+`</blockquote>
|
|
`},le.html=function(q){return q},le.heading=function(q,te,ie,de){return this.options.headerIds?"<h"+te+' id="'+this.options.headerPrefix+de.slug(ie)+'">'+q+"</h"+te+`>
|
|
`:"<h"+te+">"+q+"</h"+te+`>
|
|
`},le.hr=function(){return this.options.xhtml?`<hr/>
|
|
`:`<hr>
|
|
`},le.list=function(q,te,ie){var de=te?"ol":"ul",me=te&&ie!==1?' start="'+ie+'"':"";return"<"+de+me+`>
|
|
`+q+"</"+de+`>
|
|
`},le.listitem=function(q){return"<li>"+q+`</li>
|
|
`},le.checkbox=function(q){return"<input "+(q?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},le.paragraph=function(q){return"<p>"+q+`</p>
|
|
`},le.table=function(q,te){return te&&(te="<tbody>"+te+"</tbody>"),`<table>
|
|
<thead>
|
|
`+q+`</thead>
|
|
`+te+`</table>
|
|
`},le.tablerow=function(q){return`<tr>
|
|
`+q+`</tr>
|
|
`},le.tablecell=function(q,te){var ie=te.header?"th":"td",de=te.align?"<"+ie+' align="'+te.align+'">':"<"+ie+">";return de+q+"</"+ie+`>
|
|
`},le.strong=function(q){return"<strong>"+q+"</strong>"},le.em=function(q){return"<em>"+q+"</em>"},le.codespan=function(q){return"<code>"+q+"</code>"},le.br=function(){return this.options.xhtml?"<br/>":"<br>"},le.del=function(q){return"<del>"+q+"</del>"},le.link=function(q,te,ie){if(q=Ve(this.options.sanitize,this.options.baseUrl,q),q===null)return ie;var de='<a href="'+ze(q)+'"';return te&&(de+=' title="'+te+'"'),de+=">"+ie+"</a>",de},le.image=function(q,te,ie){if(q=Ve(this.options.sanitize,this.options.baseUrl,q),q===null)return ie;var de='<img src="'+q+'" alt="'+ie+'"';return te&&(de+=' title="'+te+'"'),de+=this.options.xhtml?"/>":">",de},le.text=function(q){return q},fe}(),Fe=function(){function fe(){}var le=fe.prototype;return le.strong=function(q){return q},le.em=function(q){return q},le.codespan=function(q){return q},le.del=function(q){return q},le.html=function(q){return q},le.text=function(q){return q},le.link=function(q,te,ie){return""+ie},le.image=function(q,te,ie){return""+ie},le.br=function(){return""},fe}(),ot=function(){function fe(){this.seen={}}var le=fe.prototype;return le.slug=function(q){var te=q.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(te)){var ie=te;do this.seen[ie]++,te=ie+"-"+this.seen[ie];while(this.seen.hasOwnProperty(te))}return this.seen[te]=0,te},fe}(),it=H.defaults,Je=Q.unescape,qe=function(){function fe(ue){this.options=ue||it,this.options.renderer=this.options.renderer||new Be,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Fe,this.slugger=new ot}fe.parse=function(q,te){var ie=new fe(te);return ie.parse(q)};var le=fe.prototype;return le.parse=function(q,te){te===void 0&&(te=!0);var ie="",de,me,Ee,Pe,rt,mt,ft,wt,Tt,ut,Ft,Ot,Zt,Xt,Rt,Ir,Kr,bt,Nr=q.length;for(de=0;de<Nr;de++){ut=q[de];switch(ut.type){case"space":continue;case"hr":{ie+=this.renderer.hr();continue}case"heading":{ie+=this.renderer.heading(this.parseInline(ut.tokens),ut.depth,Je(this.parseInline(ut.tokens,this.textRenderer)),this.slugger);continue}case"code":{ie+=this.renderer.code(ut.text,ut.lang,ut.escaped);continue}case"table":{for(wt="",ft="",Pe=ut.header.length,me=0;me<Pe;me++)ft+=this.renderer.tablecell(this.parseInline(ut.tokens.header[me]),{header:!0,align:ut.align[me]});for(wt+=this.renderer.tablerow(ft),Tt="",Pe=ut.cells.length,me=0;me<Pe;me++){for(mt=ut.tokens.cells[me],ft="",rt=mt.length,Ee=0;Ee<rt;Ee++)ft+=this.renderer.tablecell(this.parseInline(mt[Ee]),{header:!1,align:ut.align[Ee]});Tt+=this.renderer.tablerow(ft)}ie+=this.renderer.table(wt,Tt);continue}case"blockquote":{Tt=this.parse(ut.tokens),ie+=this.renderer.blockquote(Tt);continue}case"list":{for(Ft=ut.ordered,Ot=ut.start,Zt=ut.loose,Pe=ut.items.length,Tt="",me=0;me<Pe;me++)Rt=ut.items[me],Ir=Rt.checked,Kr=Rt.task,Xt="",Rt.task&&(bt=this.renderer.checkbox(Ir),Zt?Rt.tokens.length>0&&Rt.tokens[0].type==="text"?(Rt.tokens[0].text=bt+" "+Rt.tokens[0].text,Rt.tokens[0].tokens&&Rt.tokens[0].tokens.length>0&&Rt.tokens[0].tokens[0].type==="text"&&(Rt.tokens[0].tokens[0].text=bt+" "+Rt.tokens[0].tokens[0].text)):Rt.tokens.unshift({type:"text",text:bt}):Xt+=bt),Xt+=this.parse(Rt.tokens,Zt),Tt+=this.renderer.listitem(Xt,Kr,Ir);ie+=this.renderer.list(Tt,Ft,Ot);continue}case"html":{ie+=this.renderer.html(ut.text);continue}case"paragraph":{ie+=this.renderer.paragraph(this.parseInline(ut.tokens));continue}case"text":{for(Tt=ut.tokens?this.parseInline(ut.tokens):ut.text;de+1<Nr&&q[de+1].type==="text";)ut=q[++de],Tt+=`
|
|
`+(ut.tokens?this.parseInline(ut.tokens):ut.text);ie+=te?this.renderer.paragraph(Tt):Tt;continue}default:{var hr='Token with "'+ut.type+'" type was not found.';if(this.options.silent){console.error(hr);return}else throw new Error(hr)}}}return ie},le.parseInline=function(q,te){te=te||this.renderer;var ie="",de,me,Ee=q.length;for(de=0;de<Ee;de++){me=q[de];switch(me.type){case"escape":{ie+=te.text(me.text);break}case"html":{ie+=te.html(me.text);break}case"link":{ie+=te.link(me.href,me.title,this.parseInline(me.tokens,te));break}case"image":{ie+=te.image(me.href,me.title,me.text);break}case"strong":{ie+=te.strong(this.parseInline(me.tokens,te));break}case"em":{ie+=te.em(this.parseInline(me.tokens,te));break}case"codespan":{ie+=te.codespan(me.text);break}case"br":{ie+=te.br();break}case"del":{ie+=te.del(this.parseInline(me.tokens,te));break}case"text":{ie+=te.text(me.text);break}default:{var Pe='Token with "'+me.type+'" type was not found.';if(this.options.silent){console.error(Pe);return}else throw new Error(Pe)}}}return ie},fe}(),ct=Q.merge,et=Q.checkSanitizeDeprecation,Qe=Q.escape,we=H.getDefaults,lt=H.changeDefaults,tt=H.defaults;function Te(fe,le,ue){if(typeof fe=="undefined"||fe===null)throw new Error("marked(): input parameter is undefined or null");if(typeof fe!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(fe)+", string expected");if(typeof le=="function"&&(ue=le,le=null),le=ct({},Te.defaults,le||{}),et(le),ue){var q=le.highlight,te;try{te=Ie.lex(fe,le)}catch(Ee){return ue(Ee)}var ie=function(Pe){var rt;if(!Pe)try{rt=qe.parse(te,le)}catch(mt){Pe=mt}return le.highlight=q,Pe?ue(Pe):ue(null,rt)};if(!q||q.length<3)return ie();if(delete le.highlight,!te.length)return ie();var de=0;Te.walkTokens(te,function(Ee){Ee.type==="code"&&(de++,setTimeout(function(){q(Ee.text,Ee.lang,function(Pe,rt){if(Pe)return ie(Pe);rt!=null&&rt!==Ee.text&&(Ee.text=rt,Ee.escaped=!0),de--,de===0&&ie()})},0))}),de===0&&ie();return}try{var me=Ie.lex(fe,le);return le.walkTokens&&Te.walkTokens(me,le.walkTokens),qe.parse(me,le)}catch(Ee){if(Ee.message+=`
|
|
Please report this to https://github.com/markedjs/marked.`,le.silent)return"<p>An error occurred:</p><pre>"+Qe(Ee.message+"",!0)+"</pre>";throw Ee}}Te.options=Te.setOptions=function(fe){return ct(Te.defaults,fe),lt(Te.defaults),Te},Te.getDefaults=we,Te.defaults=tt,Te.use=function(fe){var le=ct({},fe);if(fe.renderer&&function(){var q=Te.defaults.renderer||new Be,te=function(me){var Ee=q[me];q[me]=function(){for(var Pe=arguments.length,rt=new Array(Pe),mt=0;mt<Pe;mt++)rt[mt]=arguments[mt];var ft=fe.renderer[me].apply(q,rt);return ft===!1&&(ft=Ee.apply(q,rt)),ft}};for(var ie in fe.renderer)te(ie);le.renderer=q}(),fe.tokenizer&&function(){var q=Te.defaults.tokenizer||new xe,te=function(me){var Ee=q[me];q[me]=function(){for(var Pe=arguments.length,rt=new Array(Pe),mt=0;mt<Pe;mt++)rt[mt]=arguments[mt];var ft=fe.tokenizer[me].apply(q,rt);return ft===!1&&(ft=Ee.apply(q,rt)),ft}};for(var ie in fe.tokenizer)te(ie);le.tokenizer=q}(),fe.walkTokens){var ue=Te.defaults.walkTokens;le.walkTokens=function(q){fe.walkTokens(q),ue&&ue(q)}}Te.setOptions(le)},Te.walkTokens=function(fe,le){for(var ue=N(fe),q;!(q=ue()).done;){var te=q.value;le(te);switch(te.type){case"table":{for(var ie=N(te.tokens.header),de;!(de=ie()).done;){var me=de.value;Te.walkTokens(me,le)}for(var Ee=N(te.tokens.cells),Pe;!(Pe=Ee()).done;)for(var rt=Pe.value,mt=N(rt),ft;!(ft=mt()).done;){var wt=ft.value;Te.walkTokens(wt,le)}break}case"list":{Te.walkTokens(te.items,le);break}default:te.tokens&&Te.walkTokens(te.tokens,le)}}},Te.Parser=qe,Te.parser=qe.parse,Te.Renderer=Be,Te.TextRenderer=Fe,Te.Lexer=Ie,Te.lexer=Ie.lex,Te.Tokenizer=xe,Te.Slugger=ot,Te.parse=Te;var Le=Te;return Le})},ELLl:function(xt,at,re){(function(ne){ne(re("VrN/"))})(function(ne){var $={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},_=ne.Pos;ne.defineOption("autoCloseBrackets",!1,function(w,x,u){u&&u!=ne.Init&&(w.removeKeyMap(N),w.state.closeBrackets=null),x&&(M(V(x,"pairs")),w.state.closeBrackets=x,w.addKeyMap(N))});function V(w,x){return x=="pairs"&&typeof w=="string"?w:typeof w=="object"&&w[x]!=null?w[x]:$[x]}var N={Backspace:P,Enter:O};function M(w){for(var x=0;x<w.length;x++){var u=w.charAt(x),a="'"+u+"'";N[a]||(N[a]=H(u))}}M($.pairs+"`");function H(w){return function(x){return A(x,w)}}function F(w){var x=w.state.closeBrackets;if(!x||x.override)return x;var u=w.getModeAt(w.getCursor());return u.closeBrackets||x}function P(w){var x=F(w);if(!x||w.getOption("disableInput"))return ne.Pass;for(var u=V(x,"pairs"),a=w.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return ne.Pass;var h=D(w,a[l].head);if(!h||u.indexOf(h)%2!=0)return ne.Pass}for(var l=a.length-1;l>=0;l--){var C=a[l].head;w.replaceRange("",_(C.line,C.ch-1),_(C.line,C.ch+1),"+delete")}}function O(w){var x=F(w),u=x&&V(x,"explode");if(!u||w.getOption("disableInput"))return ne.Pass;for(var a=w.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return ne.Pass;var h=D(w,a[l].head);if(!h||u.indexOf(h)%2!=0)return ne.Pass}w.operation(function(){var C=w.lineSeparator()||`
|
|
`;w.replaceSelection(C+C,null),w.execCommand("goCharLeft"),a=w.listSelections();for(var g=0;g<a.length;g++){var m=a[g].head.line;w.indentLine(m,null,!0),w.indentLine(m+1,null,!0)}})}function b(w){var x=ne.cmpPos(w.anchor,w.head)>0;return{anchor:new _(w.anchor.line,w.anchor.ch+(x?-1:1)),head:new _(w.head.line,w.head.ch+(x?1:-1))}}function A(w,x){var u=F(w);if(!u||w.getOption("disableInput"))return ne.Pass;var a=V(u,"pairs"),l=a.indexOf(x);if(l==-1)return ne.Pass;for(var h=V(u,"closeBefore"),C=V(u,"triples"),g=a.charAt(l+1)==x,m=w.listSelections(),k=l%2==0,v,f=0;f<m.length;f++){var p=m[f],d=p.head,o,S=w.getRange(d,_(d.line,d.ch+1));if(k&&!p.empty())o="surround";else if((g||!k)&&S==x)g&&L(w,d)?o="both":C.indexOf(x)>=0&&w.getRange(d,_(d.line,d.ch+3))==x+x+x?o="skipThree":o="skip";else if(g&&d.ch>1&&C.indexOf(x)>=0&&w.getRange(_(d.line,d.ch-2),d)==x+x){if(d.ch>2&&/\bstring/.test(w.getTokenTypeAt(_(d.line,d.ch-2))))return ne.Pass;o="addFour"}else if(g){var y=d.ch==0?" ":w.getRange(_(d.line,d.ch-1),d);if(!ne.isWordChar(S)&&y!=x&&!ne.isWordChar(y))o="both";else return ne.Pass}else if(k&&(S.length===0||/\s/.test(S)||h.indexOf(S)>-1))o="both";else return ne.Pass;if(!v)v=o;else if(v!=o)return ne.Pass}var T=l%2?a.charAt(l-1):x,I=l%2?x:a.charAt(l+1);w.operation(function(){if(v=="skip")w.execCommand("goCharRight");else if(v=="skipThree")for(var G=0;G<3;G++)w.execCommand("goCharRight");else if(v=="surround"){for(var X=w.getSelections(),G=0;G<X.length;G++)X[G]=T+X[G]+I;w.replaceSelections(X,"around"),X=w.listSelections().slice();for(var G=0;G<X.length;G++)X[G]=b(X[G]);w.setSelections(X)}else v=="both"?(w.replaceSelection(T+I,null),w.triggerElectric(T+I),w.execCommand("goCharLeft")):v=="addFour"&&(w.replaceSelection(T+T+T+T,"before"),w.execCommand("goCharRight"))})}function D(w,x){var u=w.getRange(_(x.line,x.ch-1),_(x.line,x.ch+1));return u.length==2?u:null}function L(w,x){var u=w.getTokenAt(_(x.line,x.ch+1));return/\bstring/.test(u.type)&&u.start==x.ch&&(x.ch==0||!/\bstring/.test(w.getTokenTypeAt(x)))}})},F8wB:function(xt,at,re){xt.exports={loading:"loading___1SIOG"}},Gytx:function(xt,at){xt.exports=function(ne,$,_,V){var N=_?_.call(V,ne,$):void 0;if(N!==void 0)return!!N;if(ne===$)return!0;if(typeof ne!="object"||!ne||typeof $!="object"||!$)return!1;var M=Object.keys(ne),H=Object.keys($);if(M.length!==H.length)return!1;for(var F=Object.prototype.hasOwnProperty.bind($),P=0;P<M.length;P++){var O=M[P];if(!F(O))return!1;var b=ne[O],A=$[O];if(N=_?_.call(V,b,A,O):void 0,N===!1||N===void 0&&b!==A)return!1}return!0}},HmJG:function(xt,at,re){},LdHM:function(xt,at,re){"use strict";re.d(at,"b",function(){return h}),re.d(at,"a",function(){return g});var ne=re("1OyB"),$=re("vuIU"),_=re("Ji7U"),V=re("LK+K"),N=re("q1tI"),M=re("rePB"),H=re("Ff2n"),F=re("ODXe"),P=re("4IlW"),O=re("bX4T"),b=re("YrtM"),A=re("TSYQ"),D=re.n(A),L=re("+nKL"),w=re("8OUc"),x=function(ee,ae){var pe=ee.prefixCls,ve=ee.id,De=ee.flattenOptions,xe=ee.childrenAsData,Ce=ee.values,Ae=ee.searchValue,Se=ee.multiple,ge=ee.defaultActiveFirstOption,oe=ee.height,Re=ee.itemHeight,Ze=ee.notFoundContent,He=ee.open,Ge=ee.menuItemSelectedIcon,$e=ee.virtual,_e=ee.onSelect,Ie=ee.onToggleOpen,We=ee.onActiveValue,Ve=ee.onScroll,ze=ee.onMouseEnter,Be="".concat(pe,"-item"),Fe=Object(b.a)(function(){return De},[He,De],function(Le,fe){return fe[0]&&Le[1]!==fe[1]}),ot=N.useRef(null),it=function(fe){fe.preventDefault()},Je=function(fe){ot.current&&ot.current.scrollTo({index:fe})},qe=function(fe){for(var le=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,ue=Fe.length,q=0;q<ue;q+=1){var te=(fe+q*le+ue)%ue,ie=Fe[te],de=ie.group,me=ie.data;if(!de&&!me.disabled)return te}return-1},ct=N.useState(function(){return qe(0)}),et=Object(F.a)(ct,2),Qe=et[0],we=et[1],lt=function(fe){we(fe);var le=Fe[fe];if(!le){We(null,-1);return}We(le.data.value,fe)};N.useEffect(function(){lt(ge!==!1?qe(0):-1)},[Fe.length,Ae]),N.useEffect(function(){var Le=setTimeout(function(){if(!Se&&He&&Ce.size===1){var fe=Array.from(Ce)[0],le=Fe.findIndex(function(ue){var q=ue.data;return q.value===fe});lt(le),Je(le)}});return function(){return clearTimeout(Le)}},[He]);var tt=function(fe){fe!==void 0&&_e(fe,{selected:!Ce.has(fe)}),Se||Ie(!1)};if(N.useImperativeHandle(ae,function(){return{onKeyDown:function(fe){var le=fe.which;switch(le){case P.a.UP:case P.a.DOWN:{var ue=0;if(le===P.a.UP?ue=-1:le===P.a.DOWN&&(ue=1),ue!==0){var q=qe(Qe+ue,ue);Je(q),lt(q)}break}case P.a.ENTER:{var te=Fe[Qe];te&&!te.data.disabled?tt(te.data.value):tt(void 0),He&&fe.preventDefault();break}case P.a.ESC:Ie(!1)}},onKeyUp:function(){},scrollTo:function(fe){Je(fe)}}}),Fe.length===0)return N.createElement("div",{role:"listbox",id:"".concat(ve,"_list"),className:"".concat(Be,"-empty"),onMouseDown:it},Ze);function Te(Le){var fe=Fe[Le];if(!fe)return null;var le=fe.data||{},ue=le.value,q=le.label,te=le.children,ie=Object(O.a)(le,!0),de=xe?te:q;return fe?N.createElement("div",Object.assign({"aria-label":typeof de=="string"?de:null},ie,{key:Le,role:"option",id:"".concat(ve,"_list_").concat(Le),"aria-selected":Ce.has(ue)}),ue):null}return N.createElement(N.Fragment,null,N.createElement("div",{role:"listbox",id:"".concat(ve,"_list"),style:{height:0,width:0,overflow:"hidden"}},Te(Qe-1),Te(Qe),Te(Qe+1)),N.createElement(L.a,{itemKey:"key",ref:ot,data:Fe,height:oe,itemHeight:Re,fullHeight:!1,onMouseDown:it,onScroll:Ve,virtual:$e,onMouseEnter:ze},function(Le,fe){var le,ue=Le.group,q=Le.groupOption,te=Le.data,ie=te.label,de=te.key;if(ue)return N.createElement("div",{className:D()(Be,"".concat(Be,"-group"))},ie!==void 0?ie:de);var me=te.disabled,Ee=te.value,Pe=te.title,rt=te.children,mt=te.style,ft=te.className,wt=Object(H.a)(te,["disabled","value","title","children","style","className"]),Tt=Ce.has(Ee),ut="".concat(Be,"-option"),Ft=D()(Be,ut,ft,(le={},Object(M.a)(le,"".concat(ut,"-grouped"),q),Object(M.a)(le,"".concat(ut,"-active"),Qe===fe&&!me),Object(M.a)(le,"".concat(ut,"-disabled"),me),Object(M.a)(le,"".concat(ut,"-selected"),Tt),le)),Ot=xe?rt:ie,Zt=!Ge||typeof Ge=="function"||Tt;return N.createElement("div",Object.assign({},wt,{"aria-selected":Tt,className:Ft,title:Pe,onMouseMove:function(){if(Qe===fe||me)return;lt(fe)},onClick:function(){me||tt(Ee)},style:mt}),N.createElement("div",{className:"".concat(ut,"-content")},Ot||Ee),N.isValidElement(Ge)||Tt,Zt&&N.createElement(w.a,{className:"".concat(Be,"-option-state"),customizeIcon:Ge,customizeIconProps:{isSelected:Tt}},Tt?"\u2713":null))}))},u=N.forwardRef(x);u.displayName="OptionList";var a=u,l=function(){return null};l.isSelectOption=!0;var h=l,C=function(){return null};C.isSelectOptGroup=!0;var g=C,m=re("VTBJ"),k=re("Zm9Q");function v(W){var ee=W.key,ae=W.props,pe=ae.children,ve=ae.value,De=Object(H.a)(ae,["children","value"]);return Object(m.a)({key:ee,value:ve!==void 0?ve:ee,children:pe},De)}function f(W){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(k.a)(W).map(function(ae,pe){if(!N.isValidElement(ae)||!ae.type)return null;var ve=ae.type.isSelectOptGroup,De=ae.key,xe=ae.props,Ce=xe.children,Ae=Object(H.a)(xe,["children"]);return ee||!ve?v(ae):Object(m.a)(Object(m.a)({key:"__RC_SELECT_GRP__".concat(De===null?pe:De,"__"),label:De},Ae),{},{options:f(Ce)})}).filter(function(ae){return ae})}var p=re("2Qr1"),d=re("qNPg"),o=re("U8pU"),S=re("Kwbf"),y=re("WKfj");function T(W){var ee=W.mode,ae=W.options,pe=W.children,ve=W.backfill,De=W.allowClear,xe=W.placeholder,Ce=W.getInputElement,Ae=W.showSearch,Se=W.onSearch,ge=W.defaultOpen,oe=W.autoFocus,Re=W.labelInValue,Ze=W.value,He=W.inputValue,Ge=W.optionLabelProp,$e=ee==="multiple"||ee==="tags",_e=Ae!==void 0?Ae:$e||ee==="combobox",Ie=ae||f(pe);if(Object(S.a)(ee!=="tags"||Ie.every(function(Be){return!Be.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),ee==="tags"||ee==="combobox"){var We=Ie.some(function(Be){return Be.options?Be.options.some(function(Fe){return typeof("value"in Fe?Fe.value:Fe.key)=="number"}):typeof("value"in Be?Be.value:Be.key)=="number"});Object(S.a)(!We,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(S.a)(ee!=="combobox"||!Ge,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(S.a)(ee==="combobox"||!ve,"`backfill` only works with `combobox` mode."),Object(S.a)(ee==="combobox"||!Ce,"`getInputElement` only work with `combobox` mode."),Object(S.b)(ee!=="combobox"||!Ce||!De||!xe,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),Se&&!_e&&ee!=="combobox"&&ee!=="tags"&&Object(S.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(S.b)(!ge||oe,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),Ze!=null){var Ve=Object(y.d)(Ze);Object(S.a)(!Re||Ve.every(function(Be){return Object(o.a)(Be)==="object"&&("key"in Be||"value"in Be)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(S.a)(!$e||Array.isArray(Ze),"`value` should be array when `mode` is `multiple` or `tags`")}if(pe){var ze=null;Object(k.a)(pe).some(function(Be){if(!N.isValidElement(Be)||!Be.type)return!1;var Fe=Be.type;if(Fe.isSelectOption)return!1;if(Fe.isSelectOptGroup){var ot=Object(k.a)(Be.props.children).every(function(it){return!N.isValidElement(it)||!Be.type||it.type.isSelectOption?!0:(ze=it.type,!1)});return!ot}return ze=Fe,!0}),ze&&Object(S.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(ze.displayName||ze.name||ze,"`.")),Object(S.a)(He===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var I=T,G=Object(d.a)({prefixCls:"rc-select",components:{optionList:a},convertChildrenToData:f,flattenOptions:p.d,getLabeledValue:p.e,filterOptions:p.b,isValueDisabled:p.g,findValueOption:p.c,warningProps:I,fillOptionsWithMissingValue:p.a}),X=function(W){Object(_.a)(ae,W);var ee=Object(V.a)(ae);function ae(){var pe;return Object(ne.a)(this,ae),pe=ee.apply(this,arguments),pe.selectRef=N.createRef(),pe.focus=function(){pe.selectRef.current.focus()},pe.blur=function(){pe.selectRef.current.blur()},pe}return Object($.a)(ae,[{key:"render",value:function(){return N.createElement(G,Object.assign({ref:this.selectRef},this.props))}}]),ae}(N.Component);X.Option=h,X.OptGroup=g;var Q=X,z=at.c=Q},M8RZ:function(xt,at,re){"use strict";re.d(at,"a",function(){return P});var ne=re("fWQN"),$=re("mtLc"),_=re("yKVA"),V=re("879j"),N=re("q1tI"),M=re.n(N),H=re("i8i4"),F=re.n(H),P=function(O){Object(_.a)(A,O);var b=Object(V.a)(A);function A(D){var L;Object(ne.a)(this,A),L=b.call(this,D);var w=window.document;return L.node=w.createElement("div"),w.body.appendChild(L.node),L}return Object($.a)(A,[{key:"render",value:function(){var L=this.props.children;return Object(H.createPortal)(L,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),A}(M.a.Component)},OLES:function(xt,at,re){"use strict";var ne=re("U8pU"),$=re("VTBJ"),_=re("Ff2n"),V=re("q1tI"),N=re("uciX"),M=re("7ixt"),H=function(D){var L=D.overlay,w=D.prefixCls,x=D.id,u=D.overlayInnerStyle;return V.createElement("div",{className:"".concat(w,"-inner"),id:x,role:"tooltip",style:u},typeof L=="function"?L():L)},F=H,P=function(D,L){var w=D.overlayClassName,x=D.trigger,u=x===void 0?["hover"]:x,a=D.mouseEnterDelay,l=a===void 0?0:a,h=D.mouseLeaveDelay,C=h===void 0?.1:h,g=D.overlayStyle,m=D.prefixCls,k=m===void 0?"rc-tooltip":m,v=D.children,f=D.onVisibleChange,p=D.afterVisibleChange,d=D.transitionName,o=D.animation,S=D.placement,y=S===void 0?"right":S,T=D.align,I=T===void 0?{}:T,G=D.destroyTooltipOnHide,X=G===void 0?!1:G,Q=D.defaultVisible,z=D.getTooltipContainer,W=D.overlayInnerStyle,ee=Object(_.a)(D,["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer","overlayInnerStyle"]),ae=Object(V.useRef)(null);Object(V.useImperativeHandle)(L,function(){return ae.current});var pe=Object($.a)({},ee);"visible"in D&&(pe.popupVisible=D.visible);var ve=function(){var Se=D.arrowContent,ge=Se===void 0?null:Se,oe=D.overlay,Re=D.id;return[V.createElement("div",{className:"".concat(k,"-arrow"),key:"arrow"},ge),V.createElement(F,{key:"content",prefixCls:k,id:Re,overlay:oe,overlayInnerStyle:W})]},De=!1,xe=!1;if(typeof X=="boolean")De=X;else if(X&&Object(ne.a)(X)==="object"){var Ce=X.keepParent;De=Ce===!0,xe=Ce===!1}return V.createElement(N.a,Object.assign({popupClassName:w,prefixCls:k,popup:ve,action:u,builtinPlacements:M.a,popupPlacement:y,ref:ae,popupAlign:I,getPopupContainer:z,onPopupVisibleChange:f,afterPopupVisibleChange:p,popupTransitionName:d,popupAnimation:o,defaultPopupVisible:Q,destroyPopupOnHide:De,autoDestroy:xe,mouseLeaveDelay:C,popupStyle:g,mouseEnterDelay:l},pe),v)},O=Object(V.forwardRef)(P),b=at.a=O},Ot1p:function(xt,at,re){"use strict";var ne=re("2qtc"),$=re("kLXV"),_=re("rAM+"),V=re("miYZ"),N=re("tsqr"),M=re("9og8"),H=re("tJVT"),F=re("jrin"),P=re("WmNS"),O=re.n(P),b=re("q1tI"),A=re.n(b),D=re("VrN/"),L=re.n(D),w=re("bdgK"),x=re("p77/"),u=re("Bd2K"),a=re("ELLl"),l=re("19Vz"),h=re("lZu9"),C=re("+NIl"),g=re("kSUc"),m=re("9Bee"),k=function(me){var Ee=me.value,Pe=Ee===void 0?"":Ee,rt=me.className,mt=me.showTextOnly,ft=me.showLines,wt=me.style,Tt=wt===void 0?{}:wt,ut=Object(b.useMemo)(function(){return""},[Pe]);return A.a.createElement(A.a.Fragment,null,A.a.createElement("div",{dangerouslySetInnerHTML:{__html:ut}}))},v=re("0Owb"),f=re("dejd"),p=re("C+DQ"),d=re("1vsH"),o=re("m3rI"),S=[{title:"\u7C97\u4F53",icon:"icon-bold",actionName:"bold"},{title:"\u659C\u4F53",icon:"icon-italic",actionName:"italic"},"|",{title:"\u65E0\u5E8F\u5217\u8868",icon:"icon-unorder-list",actionName:"list-ul"},{title:"\u6709\u5E8F\u5217\u8868",icon:"icon-order-list",actionName:"list-ol"},"|",{title:"\u884C\u5185\u4EE3\u7801",icon:"icon-code",actionName:"code"},{title:"\u4EE3\u7801\u5757\uFF08\u591A\u8BED\u8A00\u98CE\u683C\uFF09",icon:"icon-file-code",actionName:"code-block"},{title:"\u94FE\u63A5",icon:"icon-link",actionName:"link"},"|",{title:"\u884C\u5185\u516C\u5F0F",icon:"icon-sum",actionName:"inline-latex"},{title:"\u591A\u884C\u516C\u5F0F",icon:"icon-formula",actionName:"latex"},"|",{title:"\u6DFB\u52A0\u56FE\u7247",icon:"icon-picture",actionName:"upload-image"},{title:"\u8868\u683C",icon:"icon-table",actionName:"add-table"},"|",{title:"\u6362\u884C",icon:"icon-minus",actionName:"line-break"},{title:"\u6E05\u7A7A",icon:"icon-eraser",actionName:"eraser"}];function y(me){var Ee=me.onActionCallback,Pe=me.title,rt=me.icon,mt=me.actionName,ft=me.className,wt=ft===void 0?"":ft,Tt=me.children;function ut(){Ee(mt)}return A.a.createElement("a",{title:Pe,className:wt,onClick:ut},A.a.createElement("i",{className:"md-iconfont ".concat(rt)}),Tt)}var T=function(me){var Ee=me.watch,Pe=me.showNullButton,rt=me.onActionCallback,mt=me.fullScreen,ft=me.insertTemp,wt=me.hidetoolBar,Tt=me.uuid,ut=me.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(d.F)("_educoder_session_login"),"&_educoder_session=").concat(Object(d.F)("_educoder_session"),"&key=").concat(Tt,"&api=").concat(encodeURIComponent(o.a.PROXY_SERVER)));var Ft=[].concat(S,[{title:"".concat(Ee?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(Ee?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return A.a.createElement("ul",{className:"markdown-toolbar-container"},!wt&&Ft.map(function(Ot,Zt){return A.a.createElement("li",{key:Zt},Ot.actionName?A.a.createElement(y,Object(v.a)({},Ot,{onActionCallback:rt})):A.a.createElement("span",{className:"v-line"}))}),Pe?A.a.createElement("li",null,A.a.createElement(y,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:rt},A.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,ft&&A.a.createElement("li",null,A.a.createElement(y,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(ft),onActionCallback:rt},A.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),A.a.createElement("li",{className:"btn-full-screen"},A.a.createElement(y,{icon:"".concat(mt?"icon-shrink":"icon-enlarge"),title:mt?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:rt})))},I=re("M8RZ"),G=re("+L6B"),X=re("2/Rp"),Q=re("y8nQ"),z=re("Vl3Y"),W=re("5NDa"),ee=re("5rEg"),ae={labelCol:{span:4},wrapperCol:{span:20}},pe=function(me){var Ee=me.callback,Pe=me.onCancel;function rt(mt){Ee(mt)}return A.a.createElement(z.a,Object(v.a)({},ae,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:rt}),A.a.createElement(z.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},A.a.createElement(ee.a,null)),A.a.createElement(z.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},A.a.createElement(ee.a,null)),A.a.createElement("div",{className:"flex-container flex-end"},A.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),A.a.createElement(X.a,{type:"ghost",onClick:Pe},"\u53D6\u6D88")))},ve=re("7ahc"),De=re("HmJG"),xe=re("BjJ7"),Ce=z.a.useForm,Ae={width:280,marginRight:10},Se={labelCol:{span:5},wrapperCol:{span:19}},ge=function(me){var Ee=me.callback,Pe=me.onCancel,rt=Ce(),mt=Object(H.a)(rt,1),ft=mt[0];function wt(Ft){Ee(Ft)}function Tt(Ft,Ot){if(Ft.status===-1){N.b.error(Ft.message);return}ft.setFieldsValue({src:"/api/attachments/".concat(Ft.id),type:Ot.type})}function ut(Ft){var Ot=Ft.target.files[0];Re(Ot,Tt)}return A.a.createElement(z.a,Object(v.a)({form:ft},Se,{className:"upload-image-panel",onFinish:wt}),A.a.createElement(z.a.Item,{label:"\u56FE\u7247\u5730\u5740",required:!0},A.a.createElement("div",{className:"flex-container"},A.a.createElement(z.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740"}]},A.a.createElement(ee.a,{style:Ae})),A.a.createElement(oe,{onFileChange:ut}))),A.a.createElement(z.a.Item,{label:"\u56FE\u7247\u63CF\u8FF0",name:"alt"},A.a.createElement(ee.a,{style:{width:264}})),A.a.createElement(z.a.Item,{style:{textAlign:"right"}},A.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),A.a.createElement(X.a,{type:"ghost",onClick:Pe},"\u53D6\u6D88")))};function oe(me){var Ee=me.onFileChange;return A.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",A.a.createElement("input",{type:"file",onChange:Ee}))}function Re(me,Ee){if(!me)throw new String("\u6CA1\u6709\u6587\u4EF6");var Pe=new FormData;Pe.append("editormd-image-file",me),Pe.append("file_param_name","editormd-image-file"),Pe.append("byxhr","true");var rt=new window.XMLHttpRequest;rt.withCredentials=!0,rt.addEventListener("load",function(mt){Ee(JSON.parse(mt.target.responseText),me)},!1),rt.addEventListener("error",function(mt){console.error(mt)},!1),rt.open("POST","".concat(xe.a,"/api/attachments.json")),rt.send(Pe)}var Ze=re("giR+"),He=re("fyUT"),Ge=re("7Kak"),$e=re("9yH6"),_e=$e.a.Group,Ie={margin:"0 8px"},We=function(me){var Ee=me.callback,Pe=me.onCancel;function rt(mt){Ee(mt)}return A.a.createElement(z.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:rt},A.a.createElement("div",{className:"flex-container",style:{alignItems:"baseline"}},A.a.createElement("span",{style:Ie},"\u5355\u5143\u683C\u6570\uFF1A"),A.a.createElement("span",{style:Ie},"\u884C\u6570"),A.a.createElement(z.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},A.a.createElement(He.a,null)),A.a.createElement("span",{style:Ie},"\u5217\u6570"),A.a.createElement(z.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},A.a.createElement(He.a,null))),A.a.createElement("div",{className:"flex-container",style:{marginTop:12,alignItems:"baseline"}},A.a.createElement("span",{style:Ie},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),A.a.createElement(z.a.Item,{name:"align"},A.a.createElement(_e,null,A.a.createElement($e.a,{value:"default"},A.a.createElement("i",{className:"fa fa-align-justify"})),A.a.createElement($e.a,{value:"left"},A.a.createElement("i",{className:"fa fa-align-left"})),A.a.createElement($e.a,{value:"center"},A.a.createElement("i",{className:"fa fa-align-center"})),A.a.createElement($e.a,{value:"right"},A.a.createElement("i",{className:"fa fa-align-right"}))))),A.a.createElement("div",{className:"flex-container flex-end"},A.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),A.a.createElement(X.a,{type:"ghost",onClick:Pe},"\u53D6\u6D88")))},Ve=re("ErOA"),ze=re("7Cbv"),Be="link",Fe="upload-image",ot="code-block",it="add-table",Je="------------",qe={default:Je,left:":".concat(Je),center:":".concat(Je,":"),right:"".concat(Je,":")},ct=re("9VGf"),et,Qe;function we(){}var lt=0,tt=1e4,Te="\u2581",Le=`
|
|
**\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 fe(me){return/^\d+$/.test(me)?"".concat(me,"px"):me}var le=navigator.platform.toUpperCase().indexOf("MAC")>=0,ue=le?"Cmd":"Ctrl",q=["pptm","pptx","ppt","pot","pps","ppa","potx","ppsx","ppam","pptm","potm","ppsm","doc","docx","dot","dotx","docm","dotm","xls","xlsx","csv","xlt","xla","xltx","xlsm","xltm","xlam","xlsb"],te=(et={},Object(F.a)(et,ue+"-B","bold"),Object(F.a)(et,ue+"-I","italic"),et),ie=(Qe={},Object(F.a)(Qe,Be,"\u6DFB\u52A0\u94FE\u63A5"),Object(F.a)(Qe,ot,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(F.a)(Qe,Fe,"\u6DFB\u52A0\u6587\u4EF6"),Object(F.a)(Qe,it,"\u6DFB\u52A0\u8868\u683C"),Qe),de=at.a=function(me){var Ee=me.defaultValue,Pe=Ee===void 0?"":Ee,rt=me.onChange,mt=me.width,ft=mt===void 0?"100%":mt,wt=me.height,Tt=wt===void 0?400:wt,ut=me.miniToolbar,Ft=ut===void 0?!1:ut,Ot=me.isFocus,Zt=Ot===void 0?!1:Ot,Xt=me.watch,Rt=me.insertTemp,Ir=me.mode,Kr=Ir===void 0?"markdown":Ir,bt=me.id,Nr=bt===void 0?"markdown-editor-id":bt,hr=me.showResizeBar,pr=hr===void 0?!1:hr,Br=me.noStorage,ci=Br===void 0?!1:Br,qr=me.showNullButton,It=qr===void 0?!1:qr,ht=me.hidetoolBar,Hr=ht===void 0?!1:ht,ei=me.fullScreen,mr=ei===void 0?!1:ei,kt=me.onBlur,Fr=me.onCMBeforeChange,Vr=me.onFullScreen,fi=me.className,Ue=fi===void 0?"":fi,St=me.disablePaste,pi=St===void 0?!1:St,mi=me.placeholder,gi=mi===void 0?"":mi,vi=me.values,j=vi===void 0?"":vi,s=Object(b.useState)(null),c=Object(H.a)(s,2),R=c[0],Z=c[1],U=Object(b.useState)(Pe),ce=Object(H.a)(U,2),Oe=ce[0],Ke=ce[1],dt=Object(b.useState)(Xt),Me=Object(H.a)(dt,2),vt=Me[0],Nt=Me[1],Kt=Object(b.useState)(mr),Rr=Object(H.a)(Kt,2),gr=Rr[0],vr=Rr[1],Xr=Object(b.useState)(""),Ri=Object(H.a)(Xr,2),nr=Ri[0],Ur=Ri[1],oi=Object(b.useState)(0),si=Object(H.a)(oi,2),Or=si[0],Oi=si[1],yi=Object(b.useState)(Tt),zi=Object(H.a)(yi,2),Ki=zi[0],Yr=zi[1],Gr=Object(b.useState)(!1),bi=Object(H.a)(Gr,2),dn=bi[0],xi=bi[1],Jt=Object(b.useRef)(Object(ze.a)()),Bt=Object(b.useRef)(!1),dr=Object(b.useRef)(),_t=Object(b.useRef)(),qt=Object(b.useRef)(),Wt=Object(b.useRef)(),ti=Object(b.useRef)(),ar=function(){var pt=Object(M.a)(O.a.mark(function Ct(){var yt,Lt;return O.a.wrap(function(Gt){for(;;)switch(Gt.prev=Gt.next){case 0:return Gt.next=2,Object(Ve.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:Jt.current}});case 2:Lt=Gt.sent,Lt!=null&&(yt=Lt.attachments)!==null&&yt!==void 0&&yt.length&&(console.log("cm:",R,_t),Lt.attachments.map(function(Pt){Pt.content_type.indexOf("image")>-1?R.replaceSelection(".concat(Pt.content_type,")")):Pt.content_type.indexOf("video")>-1?R.replaceSelection('<video width="100%" controls src="'.concat(o.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):Pt.content_type.indexOf("pdf")>-1?R.replaceSelection('<a href="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Pt.id,"?type=").concat(Pt.content_type,'&disposition=inline" target="_blank">').concat(Pt.name,"</a>")):R.replaceSelection("[".concat(Pt.name,"](").concat(o.a.API_SERVER,"/api/attachments/").concat(Pt.id,"?type=").concat(Pt.content_type,")"))}));case 4:case"end":return Gt.stop()}},Ct)}));return function(){return pt.apply(this,arguments)}}();Object(b.useEffect)(function(){Ke(j),R==null||R.setValue(j)},[j]),Object(b.useEffect)(function(){Vr==null||Vr(gr)},[gr]),Object(b.useEffect)(function(){if(_t.current){var pt=L.a.fromTextArea(_t.current,{mode:Kr,lineNumbers:!Ft,lineWrapping:!0,value:Pe,autoCloseTags:!0,autoCloseBrackets:!0});Zt&&pt.focus();function Ct(yt,Lt){if(pi){Lt.preventDefault();return}var Mt=Lt.clipboardData;if(Mt){var Gt=Mt.types.toString(),Pt=Mt.items;if(Gt==="Files"||Mt.types.indexOf("Files")>-1){if(Lt.preventDefault(),Kr=="stex")return;try{var rr,Cr=Pt[1];((rr=Pt[0])===null||rr===void 0?void 0:rr.kind)==="file"&&(Cr=Pt[0]);var Dt=Cr.getAsFile(),li=Dt.name.split(".").pop();Re(Dt,function(Ut){if(Ut.id){var wr,yr,zr;(Dt==null||((wr=Dt.type)===null||wr===void 0)?void 0:wr.indexOf("image"))>-1?pt.replaceSelection(".concat(Ut.content_type,")")):(Dt==null||((yr=Dt.type)===null||yr===void 0)?void 0:yr.indexOf("video"))>-1?pt.replaceSelection('<video width="100%" controls src="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Ut.id,'"></video>')):(Dt==null||((zr=Dt.type)===null||zr===void 0)?void 0:zr.indexOf("pdf"))>-1?pt.replaceSelection('<a href="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Ut.id,"?type=").concat(Dt.type,'&disposition=inline" target="_blank">').concat(Dt.name,"</a>")):q.includes(li)?pt.replaceSelection('<a href="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Ut.id,'?type=office&disposition=inline" target="_blank">').concat(Dt.name,"</a>")):pt.replaceSelection("[".concat(Dt.name,"](").concat(o.a.API_SERVER,"/api/attachments/").concat(Ut.id,"?type=").concat(Ut.content_type,")"))}else(Ut==null?void 0:Ut.status)===401&&(document.location.href="/user/login")})}catch(Ut){N.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return pt.on("paste",Ct),pt.on("dragleave",function(yt,Lt){qt.current.classList.remove("mouse-hover-md")}),pt.on("dragover",function(yt,Lt){qt.current.classList.add("mouse-hover-md")}),pt.on("drop",function(yt,Lt){qt.current.classList.add("mouse-hover-md");var Mt;if(Mt=Lt.dataTransfer.files,Mt.length>0){Lt.preventDefault(),Lt.stopPropagation();for(var Gt=function(Cr){var Dt=Mt[Cr],li=Dt.name.split(".").pop();Re(Dt,function(Ut){if(Ut.id){var wr,yr,zr;(Dt==null||((wr=Dt.type)===null||wr===void 0)?void 0:wr.indexOf("image"))>-1?pt.replaceSelection(".concat(Ut.content_type,")")):(Dt==null||((yr=Dt.type)===null||yr===void 0)?void 0:yr.indexOf("video"))>-1?pt.replaceSelection('<video width="100%" controls src="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Ut.id,'"></video>')):(Dt==null||((zr=Dt.type)===null||zr===void 0)?void 0:zr.indexOf("pdf"))>-1?pt.replaceSelection('<a href="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Ut.id,"?type=").concat(Dt.type,'&disposition=inline" target="_blank">').concat(Dt.name,"</a>")):q.includes(li)?pt.replaceSelection('<a href="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Ut.id,'?type=office&disposition=inline" target="_blank">').concat(Dt.name,"</a>")):pt.replaceSelection("[".concat(Dt.name,"](").concat(o.a.API_SERVER,"/api/attachments/").concat(Ut.id,"?type=").concat(Ut.content_type,")"))}else(Ut==null?void 0:Ut.status)===401&&(document.location.href="/user/login")})},Pt=0;Pt<Mt.length;Pt++)Gt(Pt)}}),Z(pt),function(){pt.off("paste",Ct)}}},[]);var Er=Object(b.useCallback)(function(){if(qt.current)try{}catch(pt){console.log(pt,"---- to set md editor body height")}},[Ki,qt,gr]);Object(b.useEffect)(function(){function pt(){var yt=new w.default(function(Lt){var Mt=Object(_.a)(Lt),Gt;try{for(Mt.s();!(Gt=Mt.n()).done;){var Pt=Gt.value;(Pt.target.offsetHeight>0||Pt.target.offsetWidth>0)&&(Er(),R.setSize("100%","100%"),R.refresh())}}catch(rr){Mt.e(rr)}finally{Mt.f()}});return yt.observe(_t.current.parentElement),yt}if(R){var Ct=pt();return function(){Ct.unobserve(_t.current.parentElement)}}},[R,Er]),Object(b.useEffect)(function(){if(R){for(var pt=[],Ct=function(){var Pt=Lt[yt];Mt=Object(H.a)(Pt,2);var rr=Mt[0],Cr=Mt[1],Dt=Object(F.a)({},rr,function(){Vi(Cr)});pt.push(Dt),R.addKeyMap(Dt)},yt=0,Lt=Object.entries(te);yt<Lt.length;yt++){var Mt;Ct()}return dr.current=setInterval(function(){Bt.current&&ar()},4e3),function(){clearInterval(dr.current);var Gt=Object(_.a)(pt),Pt;try{for(Gt.s();!(Pt=Gt.n()).done;){var rr=Pt.value;R.removeKeyMap(rr)}}catch(Cr){Gt.e(Cr)}finally{Gt.f()}}}},[R]),Object(b.useEffect)(function(){mr!==gr&&vr(mr)},[mr]),Object(ct.a)(function(){if(!ci&&Or>0){var pt=new Date().getTime(),Ct=window.sessionStorage.getItem(Nr);pt>=Or+tt&&(!Ct||Ct!==Oe)&&(window.sessionStorage.setItem(Nr,Oe),xi(!0))}},tt),Object(b.useEffect)(function(){Nt(Xt)},[R,Xt]),Object(b.useEffect)(function(){R&&(Zt&&R.focus())},[R,Zt]),Object(b.useEffect)(function(){if(vt&&R){var pt=R.getScrollerElement();function Ct(yt){var Lt=yt.target;if(ti.current){var Mt=Lt.scrollTop/Lt.scrollHeight;ti.current.scrollTop=ti.current.scrollHeight*Mt}}return pt.addEventListener("scroll",Ct),function(){pt.removeEventListener("scroll",Ct)}}},[R,vt]),Object(b.useEffect)(function(){if(R&&Fr){function pt(Ct,yt){Fr(Ct,yt)}return R.on("beforeChange",pt),function(){R.off("beforeChange",pt)}}},[R,Fr]),Object(b.useEffect)(function(){if(R&&kt){function pt(){kt(R.getValue())}return R.on("blur",pt),function(){R.off("blur",pt)}}},[R,kt]),Object(b.useEffect)(function(){if(R){function pt(Ct){var yt=Ct.getValue();Ke(yt),Oi(new Date().getTime()),Ct.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),rt&&rt(yt)}return R.on("change",pt),function(){R.off("change",pt)}}},[R,rt]),Object(b.useEffect)(function(){R&&(Pe==null?(R.setValue(""),Ke("")):Pe!==R.getValue()&&(R.setValue(Pe),Ke(Pe),R.setCursor(R.lineCount(),0)))},[R,Pe]);var Vi=Object(b.useCallback)(function(pt){var Ct=R.getCursor(),yt=R.getSelection(),Lt=yt.split(`
|
|
`);switch(pt){case"bold":return R.replaceSelection("**"+yt+"**"),yt===""&&R.setCursor(Ct.line,Ct.ch+2),R.focus();case"italic":return R.replaceSelection("*"+yt+"*"),yt===""&&R.setCursor(Ct.line,Ct.ch+1),R.focus();case"code":return R.replaceSelection("`"+yt+"`"),yt===""&&R.setCursor(Ct.line,Ct.ch+1),R.focus();case"inline-latex":return R.replaceSelection("`$$"+yt+"$$`"),yt===""&&R.setCursor(Ct.line,Ct.ch+3),R.focus();case"latex":return R.replaceSelection("```latex\n"+yt+"\n```"),R.setCursor(Ct.line+1,yt.length+1),R.focus();case"line-break":return R.replaceSelection(`<br/>
|
|
`),R.focus();case"list-ul":return yt===""?R.replaceSelection("- "+yt):R.replaceSelection(Lt.map(function(Mt){return Mt===""?"":"- ".concat(Mt)}).join(`
|
|
`)),R.focus();case"list-ol":return yt===""?R.replaceSelection("1. "+yt):R.replaceSelection(Lt.map(function(Mt,Gt){return Mt===""?"":"".concat(Gt+1,". ").concat(Mt)}).join(`
|
|
`)),R.focus();case"add-null-ch":return yt===""&&R.setCursor(Ct.line,Ct.ch+1),R.replaceSelection(Te),R.focus();case"inster-template-1":return yt===""&&R.setCursor(Ct.line,Ct.ch),R.replaceSelection(Le),R.focus();case"eraser":return R.setValue(""),R.focus();case"trigger-watch":return Nt(!vt),R.focus();case"trigger-full-screen":return vr(!gr),R.focus();case Be:Ur(Be);return;case ot:Ur(ot);return;case Fe:Ur(Fe);return;case it:Ur(it);return;default:throw new Error}},[R,vt,gr]),Ei=Object(b.useCallback)(function(pt){Ur("");switch(nr){case Be:var Ct=pt.title,yt=pt.link;return R.replaceSelection("[".concat(Ct,"](").concat(yt,")")),R.focus();case ot:var Lt=pt.language,Mt=pt.content;return R.replaceSelection(["```"+Lt,Mt,"```"].join(`
|
|
`)),R.focus();case Fe:var Gt=pt.src,Pt=pt.alt;return Pt?R.replaceSelection(".concat(Gt,' "').concat(Pt,'" )')):R.replaceSelection("")),R.focus();case it:for(var rr=pt.row,Cr=pt.col,Dt=pt.align,li=`
|
|
`,Ut=0;Ut<rr;Ut++){for(var wr=[],yr=[],zr=0;zr<Cr;zr++)Ut===1&&yr.push(qe[Dt]),wr.push(" ");Ut===1&&(li+="| ".concat(yr.join(" | "),` |
|
|
`)),li+="| ".concat(wr.join(Cr===1?"":" | "),` |
|
|
`)}return R.replaceSelection(li+`
|
|
`),R.focus();default:throw new Error}},[R,nr]),cn=Object(b.useMemo)(function(){switch(nr){case Be:return A.a.createElement(pe,{callback:Ei,onCancel:Si});case ot:return A.a.createElement(ve.b,{callback:Ei,onCancel:Si});case Fe:return A.a.createElement(ge,{callback:Ei,onCancel:Si});case it:return A.a.createElement(We,{callback:Ei,onCancel:Si});default:return null}},[nr]);function Si(){Ur("")}Object(b.useEffect)(function(){if(Wt.current){var pt=Wt.current,Ct=!1,yt=0;function Lt(Pt){Ct=!0,yt=Pt.pageY}function Mt(){Ct=!1}function Gt(Pt){if(Ct){var rr=Pt.pageY-yt;rr<0&&(rr=0),rr>300&&(rr=300);var Cr=Tt+rr+"px";Yr(Cr)}}return pt.addEventListener("mousedown",Lt),document.addEventListener("mousemove",Gt),document.addEventListener("mouseup",Mt),function(){pt.removeEventListener("mousedown",Lt),document.removeEventListener("mousemove",Gt),document.removeEventListener("mouseup",Mt)}}},[R,Wt]),Object(b.useEffect)(function(){Yr(Tt)},[Tt]);var ri=fe(ft),fn=fe(Ki),$r={width:ri,height:fn},pn=Object(b.useMemo)(function(){if(Or){var pt=new Date(Or),Ct=pt.getHours(),yt=pt.getMinutes(),Lt=pt.getSeconds();return Ct=Ct<10?"0"+Ct:Ct,yt=yt<10?"0"+yt:yt,Lt=Lt<10?"0"+Lt:Lt,"".concat(Ct,":").concat(yt,":").concat(Lt)}return 0},[Or]);function jn(){window.sessionStorage.removeItem(Nr),xi(!1),Oi(0)}function Pi(){xi(!1),Oi(0),R.setValue(window.sessionStorage.getItem(Nr))}function ua(pt,Ct){var yt=R.getValue();yt=yt.replace(pt,Ct),Ke(yt),R==null||R.setValue(yt)}return A.a.createElement(b.Fragment,null,A.a.createElement("div",{className:"markdown-editor-wrapper",ref:qt},A.a.createElement("div",{className:"markdown-editor-container ".concat(Ue," ").concat(vt?"on-preview":""," ").concat(Ft?"mini":""," ").concat(gr?"full-screen":""),style:$r},A.a.createElement(T,{insertTemp:Rt,watch:vt,fullScreen:gr,showNullButton:It,onActionCallback:Vi,hidetoolBar:Hr,uuid:Jt.current,setOpenPhones:function(){Bt.current=!0}}),A.a.createElement("div",{className:"markdown-editor-body"},A.a.createElement("div",{className:"codemirror-container"},A.a.createElement("textarea",{ref:_t,placeholder:gi})),vt?A.a.createElement("div",{ref:ti,className:"preview-container"},Kr==="stex"&&A.a.createElement(k,{value:Oe}),Kr!=="stex"&&A.a.createElement(m.a,{edit:!0,value:Oe,replaces:ua})):null))),pr?A.a.createElement("a",{ref:Wt,className:"editor-resize"}):null,A.a.createElement(I.a,null,ie[nr]?A.a.createElement($.a,{centered:!0,title:ie[nr],visible:!0,onCancel:Si,footer:null,className:"markdown-popup-form"},cn):null))}},SJMd:function(xt,at){/**
|
|
* @license
|
|
* Copyright (C) 2006 Google Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/var re,ne,$,_=!1,V,N;window.PR_SHOULD_USE_CONTINUATION=!0;var M,H;(function(){var F=window,P=["break,continue,do,else,for,if,return,while"],O=[P,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],b=[O,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],A=[b,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],D=[b,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],L=[b,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],w="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",x=[b,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],u="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",a=[P,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],l=[P,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],h=[P,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],C=[A,L,D,x,u,a,l,h],g=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,m="str",k="kwd",v="com",f="typ",p="lit",d="pun",o="pln",S="tag",y="dec",T="src",I="atn",G="atv",X="nocode",Q="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function z(_e){for(var Ie=0,We=!1,Ve=!1,ze=0,Be=_e.length;ze<Be;++ze){var Fe=_e[ze];if(Fe.ignoreCase)Ve=!0;else if(/[a-z]/i.test(Fe.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){We=!0,Ve=!1;break}}var ot={b:8,t:9,n:10,v:11,f:12,r:13};function it(Qe){var we=Qe.charCodeAt(0);if(we!==92)return we;var lt=Qe.charAt(1);return we=ot[lt],we||("0"<=lt&<<="7"?parseInt(Qe.substring(1),8):lt==="u"||lt==="x"?parseInt(Qe.substring(2),16):Qe.charCodeAt(1))}function Je(Qe){if(Qe<32)return(Qe<16?"\\x0":"\\x")+Qe.toString(16);var we=String.fromCharCode(Qe);return we==="\\"||we==="-"||we==="]"||we==="^"?"\\"+we:we}function qe(Qe){var we=Qe.substring(1,Qe.length-1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g")),lt=[],tt=we[0]==="^",Te=["["];tt&&Te.push("^");for(var Le=tt?1:0,fe=we.length;Le<fe;++Le){var le=we[Le];if(/\\[bdsw]/i.test(le))Te.push(le);else{var ue=it(le),q;Le+2<fe&&we[Le+1]==="-"?(q=it(we[Le+2]),Le+=2):q=ue,lt.push([ue,q]),q<65||ue>122||(q<65||ue>90||lt.push([Math.max(65,ue)|32,Math.min(q,90)|32]),q<97||ue>122||lt.push([Math.max(97,ue)&~32,Math.min(q,122)&~32]))}}lt.sort(function(me,Ee){return me[0]-Ee[0]||Ee[1]-me[1]});for(var te=[],ie=[],Le=0;Le<lt.length;++Le){var de=lt[Le];de[0]<=ie[1]+1?ie[1]=Math.max(ie[1],de[1]):te.push(ie=de)}for(var Le=0;Le<te.length;++Le){var de=te[Le];Te.push(Je(de[0])),de[1]>de[0]&&(de[1]+1>de[0]&&Te.push("-"),Te.push(Je(de[1])))}return Te.push("]"),Te.join("")}function ct(Qe){for(var we=Qe.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),lt=we.length,tt=[],Te=0,Le=0;Te<lt;++Te){var fe=we[Te];if(fe==="(")++Le;else if(fe.charAt(0)==="\\"){var le=+fe.substring(1);le&&(le<=Le?tt[le]=-1:we[Te]=Je(le))}}for(var Te=1;Te<tt.length;++Te)tt[Te]===-1&&(tt[Te]=++Ie);for(var Te=0,Le=0;Te<lt;++Te){var fe=we[Te];if(fe==="(")++Le,tt[Le]||(we[Te]="(?:");else if(fe.charAt(0)==="\\"){var le=+fe.substring(1);le&&le<=Le&&(we[Te]="\\"+tt[le])}}for(var Te=0;Te<lt;++Te)we[Te]==="^"&&we[Te+1]!=="^"&&(we[Te]="");if(Qe.ignoreCase&&We)for(var Te=0;Te<lt;++Te){var fe=we[Te],ue=fe.charAt(0);fe.length>=2&&ue==="["?we[Te]=qe(fe):ue!=="\\"&&(we[Te]=fe.replace(/[a-zA-Z]/g,function(ie){var de=ie.charCodeAt(0);return"["+String.fromCharCode(de&~32,de|32)+"]"}))}return we.join("")}for(var et=[],ze=0,Be=_e.length;ze<Be;++ze){var Fe=_e[ze];if(Fe.global||Fe.multiline)throw new Error(""+Fe);et.push("(?:"+ct(Fe)+")")}return new RegExp(et.join("|"),Ve?"gi":"g")}function W(_e,Ie){var We=/(?:^|\s)nocode(?:\s|$)/,Ve=[],ze=0,Be=[],Fe=0;function ot(it){var Je=it.nodeType;if(Je==1){if(We.test(it.className))return;for(var qe=it.firstChild;qe;qe=qe.nextSibling)ot(qe);var ct=it.nodeName.toLowerCase();(ct==="br"||ct==="li")&&(Ve[Fe]=`
|
|
`,Be[Fe<<1]=ze++,Be[Fe++<<1|1]=it)}else if(Je==3||Je==4){var et=it.nodeValue;et.length&&(Ie?et=et.replace(/\r\n?/g,`
|
|
`):et=et.replace(/[ \t\r\n]+/g," "),Ve[Fe]=et,Be[Fe<<1]=ze,ze+=et.length,Be[Fe++<<1|1]=it)}}return ot(_e),{sourceCode:Ve.join("").replace(/\n$/,""),spans:Be}}function ee(_e,Ie,We,Ve,ze){if(!We)return;var Be={sourceNode:_e,pre:1,langExtension:null,numberLines:null,sourceCode:We,spans:null,basePos:Ie,decorations:null};Ve(Be),ze.push.apply(ze,Be.decorations)}var ae=/\S/;function pe(_e){for(var Ie=void 0,We=_e.firstChild;We;We=We.nextSibling){var Ve=We.nodeType;Ie=Ve===1?Ie?_e:We:Ve===3&&ae.test(We.nodeValue)?_e:Ie}return Ie===_e?void 0:Ie}function ve(_e,Ie){var We={},Ve;(function(){for(var Fe=_e.concat(Ie),ot=[],it={},Je=0,qe=Fe.length;Je<qe;++Je){var ct=Fe[Je],et=ct[3];if(et)for(var Qe=et.length;--Qe>=0;)We[et.charAt(Qe)]=ct;var we=ct[1],lt=""+we;it.hasOwnProperty(lt)||(ot.push(we),it[lt]=null)}ot.push(/[\0-\uffff]/),Ve=z(ot)})();var ze=Ie.length,Be=function(Fe){for(var ot=Fe.sourceCode,it=Fe.basePos,Je=Fe.sourceNode,qe=[it,o],ct=0,et=ot.match(Ve)||[],Qe={},we=0,lt=et.length;we<lt;++we){var tt=et[we],Te=Qe[tt],Le=void 0,fe;if(typeof Te=="string")fe=!1;else{var le=We[tt.charAt(0)];if(le)Le=tt.match(le[1]),Te=le[0];else{for(var ue=0;ue<ze;++ue)if(le=Ie[ue],Le=tt.match(le[1]),Le){Te=le[0];break}Le||(Te=o)}fe=Te.length>=5&&Te.substring(0,5)==="lang-",fe&&!(Le&&typeof Le[1]=="string")&&(fe=!1,Te=T),fe||(Qe[tt]=Te)}var q=ct;if(ct+=tt.length,!fe)qe.push(it+q,Te);else{var te=Le[1],ie=tt.indexOf(te),de=ie+te.length;Le[2]&&(de=tt.length-Le[2].length,ie=de-te.length);var me=Te.substring(5);ee(Je,it+q,tt.substring(0,ie),Be,qe),ee(Je,it+q+ie,te,oe(me,te),qe),ee(Je,it+q+de,tt.substring(de),Be,qe)}}Fe.decorations=qe};return Be}function De(_e){var Ie=[],We=[];_e.tripleQuotedStrings?Ie.push([m,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):_e.multiLineStrings?Ie.push([m,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Ie.push([m,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),_e.verbatimStrings&&We.push([m,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Ve=_e.hashComments;Ve&&(_e.cStyleComments?(Ve>1?Ie.push([v,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Ie.push([v,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),We.push([m,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Ie.push([v,/^#[^\r\n]*/,null,"#"])),_e.cStyleComments&&(We.push([v,/^\/\/[^\r\n]*/,null]),We.push([v,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var ze=_e.regexLiterals;if(ze){var Be=ze>1?"":`
|
|
\r`,Fe=Be?".":"[\\S\\s]",ot="/(?=[^/*"+Be+"])(?:[^/\\x5B\\x5C"+Be+"]|\\x5C"+Fe+"|\\x5B(?:[^\\x5C\\x5D"+Be+"]|\\x5C"+Fe+")*(?:\\x5D|$))+/";We.push(["lang-regex",RegExp("^"+Q+"("+ot+")")])}var it=_e.types;it&&We.push([f,it]);var Je=(""+_e.keywords).replace(/^ | $/g,"");Je.length&&We.push([k,new RegExp("^(?:"+Je.replace(/[\s,]+/g,"|")+")\\b"),null]),Ie.push([o,/^\s+/,null,` \r
|
|
\xA0`]);var qe="^.[^\\s\\w.$@'\"`/\\\\]*";return _e.regexLiterals&&(qe+="(?!s*/)"),We.push([p,/^@[a-z_$][a-z_$@0-9]*/i,null],[f,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[o,/^[a-z_$][a-z_$@0-9]*/i,null],[p,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[o,/^\\[\s\S]?/,null],[d,new RegExp(qe),null]),ve(Ie,We)}var xe=De({keywords:C,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function Ce(_e,Ie,We){for(var Ve=/(?:^|\s)nocode(?:\s|$)/,ze=/\r\n?|\n/,Be=_e.ownerDocument,Fe=Be.createElement("li");_e.firstChild;)Fe.appendChild(_e.firstChild);var ot=[Fe];function it(we){var lt=we.nodeType;if(lt==1&&!Ve.test(we.className))if(we.nodeName==="br")Je(we),we.parentNode&&we.parentNode.removeChild(we);else for(var tt=we.firstChild;tt;tt=tt.nextSibling)it(tt);else if((lt==3||lt==4)&&We){var Te=we.nodeValue,Le=Te.match(ze);if(Le){var fe=Te.substring(0,Le.index);we.nodeValue=fe;var le=Te.substring(Le.index+Le[0].length);if(le){var ue=we.parentNode;ue.insertBefore(Be.createTextNode(le),we.nextSibling)}Je(we),fe||we.parentNode.removeChild(we)}}}function Je(we){for(;!we.nextSibling;)if(we=we.parentNode,!we)return;function lt(Le,fe){var le=fe?Le.cloneNode(!1):Le,ue=Le.parentNode;if(ue){var q=lt(ue,1),te=Le.nextSibling;q.appendChild(le);for(var ie=te;ie;ie=te)te=ie.nextSibling,q.appendChild(ie)}return le}for(var tt=lt(we.nextSibling,0),Te;(Te=tt.parentNode)&&Te.nodeType===1;)tt=Te;ot.push(tt)}for(var qe=0;qe<ot.length;++qe)it(ot[qe]);Ie===(Ie|0)&&ot[0].setAttribute("value",Ie);var ct=Be.createElement("ol");ct.className="linenums";for(var et=Math.max(0,Ie-1|0)||0,qe=0,Qe=ot.length;qe<Qe;++qe)Fe=ot[qe],Fe.className="L"+(qe+et)%10,Fe.firstChild||Fe.appendChild(Be.createTextNode("\xA0")),ct.appendChild(Fe);_e.appendChild(ct)}function Ae(_e){var Ie=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Ie=Ie&&+Ie[1]<=8;var We=/\n/g,Ve=_e.sourceCode,ze=Ve.length,Be=0,Fe=_e.spans,ot=Fe.length,it=0,Je=_e.decorations,qe=Je.length,ct=0;Je[qe]=ze;var et,Qe;for(Qe=et=0;Qe<qe;)Je[Qe]!==Je[Qe+2]?(Je[et++]=Je[Qe++],Je[et++]=Je[Qe++]):Qe+=2;for(qe=et,Qe=et=0;Qe<qe;){for(var we=Je[Qe],lt=Je[Qe+1],tt=Qe+2;tt+2<=qe&&Je[tt+1]===lt;)tt+=2;Je[et++]=we,Je[et++]=lt,Qe=tt}qe=Je.length=et;var Te=_e.sourceNode,Le="";Te&&(Le=Te.style.display,Te.style.display="none");try{for(var fe=null;it<ot;){var le=Fe[it],ue=Fe[it+2]||ze,q=Je[ct+2]||ze,tt=Math.min(ue,q),te=Fe[it+1],ie;if(te.nodeType!==1&&(ie=Ve.substring(Be,tt))){Ie&&(ie=ie.replace(We,"\r")),te.nodeValue=ie;var de=te.ownerDocument,me=de.createElement("span");me.className=Je[ct+1];var Ee=te.parentNode;Ee.replaceChild(me,te),me.appendChild(te),Be<ue&&(Fe[it+1]=te=de.createTextNode(Ve.substring(tt,ue)),Ee.insertBefore(te,me.nextSibling))}Be=tt,Be>=ue&&(it+=2),Be>=q&&(ct+=2)}}finally{Te&&(Te.style.display=Le)}}var Se={};function ge(_e,Ie){for(var We=Ie.length;--We>=0;){var Ve=Ie[We];Se.hasOwnProperty(Ve)?F.console&&console.warn("cannot override language handler %s",Ve):Se[Ve]=_e}}function oe(_e,Ie){return _e&&Se.hasOwnProperty(_e)||(_e=/^\s*</.test(Ie)?"default-markup":"default-code"),Se[_e]}ge(xe,["default-code"]),ge(ve([],[[o,/^[^<?]+/],[y,/^<!\w[^>]*(?:>|$)/],[v,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[d,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]),ge(ve([[o,/^[\s]+/,null,` \r
|
|
`],[G,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[S,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[I,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[d,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]),ge(ve([],[[G,/^[\s\S]+/]]),["uq.val"]),ge(De({keywords:A,hashComments:!0,cStyleComments:!0,types:g}),["c","cc","cpp","cxx","cyc","m"]),ge(De({keywords:"null,true,false"}),["json"]),ge(De({keywords:L,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:g}),["cs"]),ge(De({keywords:D,cStyleComments:!0}),["java"]),ge(De({keywords:h,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),ge(De({keywords:a,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),ge(De({keywords:u,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),ge(De({keywords:l,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),ge(De({keywords:x,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),ge(De({keywords:w,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),ge(ve([],[[m,/^[\s\S]+/]]),["regex"]);function Re(_e){var Ie=_e.langExtension;try{var We=W(_e.sourceNode,_e.pre),Ve=We.sourceCode;_e.sourceCode=Ve,_e.spans=We.spans,_e.basePos=0,oe(Ie,Ve)(_e),Ae(_e)}catch(ze){F.console&&console.log(ze&&ze.stack||ze)}}function Ze(_e,Ie,We){var Ve=We||!1,ze=Ie||null,Be=document.createElement("div");Be.innerHTML="<pre>"+_e+"</pre>",Be=Be.firstChild,Ve&&Ce(Be,Ve,!0);var Fe={langExtension:ze,numberLines:Ve,sourceNode:Be,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return Re(Fe),Be.innerHTML}function He(_e,Ie){var We=Ie||document.body,Ve=We.ownerDocument||document;function ze(le){return We.getElementsByTagName(le)}for(var Be=[ze("pre"),ze("code"),ze("xmp")],Fe=[],ot=0;ot<Be.length;++ot)for(var it=0,Je=Be[ot].length;it<Je;++it)Fe.push(Be[ot][it]);Be=null;var qe=Date;qe.now||(qe={now:function(){return+new Date}});var ct=0,et=/\blang(?:uage)?-([\w.]+)(?!\S)/,Qe=/\bprettyprint\b/,we=/\bprettyprinted\b/,lt=/pre|xmp/i,tt=/^code$/i,Te=/^(?:pre|code|xmp)$/i,Le={};function fe(){for(var le=F.PR_SHOULD_USE_CONTINUATION?qe.now()+250:Infinity;ct<Fe.length&&qe.now()<le;ct++){for(var ue=Fe[ct],q=Le,te=ue;te=te.previousSibling;){var ie=te.nodeType,de=(ie===7||ie===8)&&te.nodeValue;if(de?!/^\??prettify\b/.test(de):ie!==3||/\S/.test(te.nodeValue))break;if(de){q={},de.replace(/\b(\w+)=([\w:.%+-]+)/g,function(Xt,Rt,Ir){q[Rt]=Ir});break}}var me=ue.className;if((q!==Le||Qe.test(me))&&!we.test(me)){for(var Ee=!1,Pe=ue.parentNode;Pe;Pe=Pe.parentNode){var rt=Pe.tagName;if(Te.test(rt)&&Pe.className&&Qe.test(Pe.className)){Ee=!0;break}}if(!Ee){ue.className+=" prettyprinted";var mt=q.lang;if(!mt){mt=me.match(et);var ft;!mt&&(ft=pe(ue))&&tt.test(ft.tagName)&&(mt=ft.className.match(et)),mt&&(mt=mt[1])}var wt;if(lt.test(ue.tagName))wt=1;else{var Tt=ue.currentStyle,ut=Ve.defaultView,Ft=Tt?Tt.whiteSpace:ut&&ut.getComputedStyle?ut.getComputedStyle(ue,null).getPropertyValue("white-space"):0;wt=Ft&&Ft.substring(0,3)==="pre"}var Ot=q.linenums;(Ot=Ot==="true"||+Ot)||(Ot=me.match(/\blinenums\b(?::(\d+))?/),Ot=Ot?Ot[1]&&Ot[1].length?+Ot[1]:!0:!1),Ot&&Ce(ue,Ot,wt);var Zt={langExtension:mt,sourceNode:ue,numberLines:Ot,pre:wt,sourceCode:null,basePos:null,spans:null,decorations:null};Re(Zt)}}}ct<Fe.length?F.setTimeout(fe,250):typeof _e=="function"&&_e()}fe()}var Ge=F.PR={createSimpleLexer:ve,registerLangHandler:ge,sourceDecorator:De,PR_ATTRIB_NAME:I,PR_ATTRIB_VALUE:G,PR_COMMENT:v,PR_DECLARATION:y,PR_KEYWORD:k,PR_LITERAL:p,PR_NOCODE:X,PR_PLAIN:o,PR_PUNCTUATION:d,PR_SOURCE:T,PR_STRING:m,PR_TAG:S,PR_TYPE:f,prettyPrintOne:_?F.prettyPrintOne=Ze:M=Ze,prettyPrint:H=_?F.prettyPrint=He:H=He},$e=F.define;typeof $e=="function"&&$e.amd&&$e("google-code-prettify",[],function(){return Ge})})()},UUDw:function(xt,at,re){xt.exports={buttonFixed:"buttonFixed___2zLVJ",button:"button___-JgFH",buttonWrap:"buttonWrap___aZhhk"}},UqFu:function(xt,at,re){"use strict";re.d(at,"a",function(){return ne});var ne=function(_){var V=document.createElement("textarea");return V.value=_,V.value}},"VrN/":function(xt,at,re){(function(ne,$){xt.exports=$()})(this,function(){"use strict";var ne=navigator.userAgent,$=navigator.platform,_=/gecko\/\d/i.test(ne),V=/MSIE \d/.test(ne),N=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ne),M=/Edge\/(\d+)/.exec(ne),H=V||N||M,F=H&&(V?document.documentMode||6:+(M||N)[1]),P=!M&&/WebKit\//.test(ne),O=P&&/Qt\/\d+\.\d+/.test(ne),b=!M&&/Chrome\//.test(ne),A=/Opera\//.test(ne),D=/Apple Computer/.test(navigator.vendor),L=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(ne),w=/PhantomJS/.test(ne),x=!M&&/AppleWebKit/.test(ne)&&/Mobile\/\w+/.test(ne),u=/Android/.test(ne),a=x||u||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(ne),l=x||/Mac/.test($),h=/\bCrOS\b/.test(ne),C=/win/i.test($),g=A&&ne.match(/Version\/(\d*\.\d*)/);g&&(g=Number(g[1])),g&&g>=15&&(A=!1,P=!0);var m=l&&(O||A&&(g==null||g<12.11)),k=_||H&&F>=9;function v(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var f=function(e,t){var i=e.className,r=v(t).exec(i);if(r){var n=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(n?r[1]+n:"")}};function p(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function d(e,t){return p(e).appendChild(t)}function o(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var E=0;E<t.length;++E)n.appendChild(t[E]);return n}function S(e,t,i,r){var n=o(e,t,i,r);return n.setAttribute("role","presentation"),n}var y;document.createRange?y=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:y=function(e,t,i){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(n){return r}return r.collapse(!0),r.moveEnd("character",i),r.moveStart("character",t),r};function T(e,t){if(t.nodeType==3&&(t=t.parentNode),e.contains)return e.contains(t);do if(t.nodeType==11&&(t=t.host),t==e)return!0;while(t=t.parentNode)}function I(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function G(e,t){var i=e.className;v(t).test(i)||(e.className+=(i?" ":"")+t)}function X(e,t){for(var i=e.split(" "),r=0;r<i.length;r++)i[r]&&!v(i[r]).test(t)&&(t+=" "+i[r]);return t}var Q=function(e){e.select()};x?Q=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:H&&(Q=function(e){try{e.select()}catch(t){}});function z(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function W(e,t,i){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(i!==!1||!t.hasOwnProperty(r))&&(t[r]=e[r]);return t}function ee(e,t,i,r,n){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var E=r||0,B=n||0;;){var K=e.indexOf(" ",E);if(K<0||K>=t)return B+(t-E);B+=K-E,B+=i-B%i,E=K+1}}var ae=function(){this.id=null,this.f=null,this.time=0,this.handler=z(this.onTimeout,this)};ae.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},ae.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 pe(e,t){for(var i=0;i<e.length;++i)if(e[i]==t)return i;return-1}var ve=50,De={toString:function(){return"CodeMirror.Pass"}},xe={scroll:!1},Ce={origin:"*mouse"},Ae={origin:"+move"};function Se(e,t,i){for(var r=0,n=0;;){var E=e.indexOf(" ",r);E==-1&&(E=e.length);var B=E-r;if(E==e.length||n+B>=t)return r+Math.min(B,t-n);if(n+=E-r,n+=i-n%i,r=E+1,n>=t)return r}}var ge=[""];function oe(e){for(;ge.length<=e;)ge.push(Re(ge)+" ");return ge[e]}function Re(e){return e[e.length-1]}function Ze(e,t){for(var i=[],r=0;r<e.length;r++)i[r]=t(e[r],r);return i}function He(e,t,i){for(var r=0,n=i(t);r<e.length&&i(e[r])<=n;)r++;e.splice(r,0,t)}function Ge(){}function $e(e,t){var i;return Object.create?i=Object.create(e):(Ge.prototype=e,i=new Ge),t&&W(t,i),i}var _e=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function Ie(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||_e.test(e))}function We(e,t){return t?t.source.indexOf("\\w")>-1&&Ie(e)?!0:t.test(e):Ie(e)}function Ve(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ze=/[\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 Be(e){return e.charCodeAt(0)>=768&&ze.test(e)}function Fe(e,t,i){for(;(i<0?t>0:t<e.length)&&Be(e.charAt(t));)t+=i;return t}function ot(e,t,i){for(var r=t>i?-1:1;;){if(t==i)return t;var n=(t+i)/2,E=r<0?Math.ceil(n):Math.floor(n);if(E==t)return e(E)?t:i;e(E)?i=E:t=E+r}}function it(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,E=0;E<e.length;++E){var B=e[E];(B.from<i&&B.to>t||t==i&&B.to==t)&&(r(Math.max(B.from,t),Math.min(B.to,i),B.level==1?"rtl":"ltr",E),n=!0)}n||r(t,i,"ltr")}var Je=null;function qe(e,t,i){var r;Je=null;for(var n=0;n<e.length;++n){var E=e[n];if(E.from<t&&E.to>t)return n;E.to==t&&(E.from!=E.to&&i=="before"?r=n:Je=n),E.from==t&&(E.from!=E.to&&i!="before"?r=n:Je=n)}return r!=null?r:Je}var ct=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(J){return J<=247?e.charAt(J):1424<=J&&J<=1524?"R":1536<=J&&J<=1785?t.charAt(J-1536):1774<=J&&J<=2220?"r":8192<=J&&J<=8203?"w":J==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,E=/[LRr]/,B=/[Lb1n]/,K=/[1n]/;function Y(J,se,he){this.level=J,this.from=se,this.to=he}return function(J,se){var he=se=="ltr"?"L":"R";if(J.length==0||se=="ltr"&&!r.test(J))return!1;for(var be=J.length,ye=[],ke=0;ke<be;++ke)ye.push(i(J.charCodeAt(ke)));for(var Ne=0,je=he;Ne<be;++Ne){var Xe=ye[Ne];Xe=="m"?ye[Ne]=je:je=Xe}for(var nt=0,Ye=he;nt<be;++nt){var st=ye[nt];st=="1"&&Ye=="r"?ye[nt]="n":E.test(st)&&(Ye=st,st=="r"&&(ye[nt]="R"))}for(var Et=1,gt=ye[0];Et<be-1;++Et){var At=ye[Et];At=="+"&>=="1"&&ye[Et+1]=="1"?ye[Et]="1":At==","&>==ye[Et+1]&&(gt=="1"||gt=="n")&&(ye[Et]=gt),gt=At}for(var zt=0;zt<be;++zt){var lr=ye[zt];if(lr==",")ye[zt]="N";else if(lr=="%"){var Yt=void 0;for(Yt=zt+1;Yt<be&&ye[Yt]=="%";++Yt);for(var Mr=zt&&ye[zt-1]=="!"||Yt<be&&ye[Yt]=="1"?"1":"N",kr=zt;kr<Yt;++kr)ye[kr]=Mr;zt=Yt-1}}for(var er=0,_r=he;er<be;++er){var fr=ye[er];_r=="L"&&fr=="1"?ye[er]="L":E.test(fr)&&(_r=fr)}for(var ir=0;ir<be;++ir)if(n.test(ye[ir])){var tr=void 0;for(tr=ir+1;tr<be&&n.test(ye[tr]);++tr);for(var $t=(ir?ye[ir-1]:he)=="L",Dr=(tr<be?ye[tr]:he)=="L",un=$t==Dr?$t?"L":"R":he,Di=ir;Di<tr;++Di)ye[Di]=un;ir=tr-1}for(var xr=[],ai,ur=0;ur<be;)if(B.test(ye[ur])){var Va=ur;for(++ur;ur<be&&B.test(ye[ur]);++ur);xr.push(new Y(0,Va,ur))}else{var di=ur,Hi=xr.length,Gi=se=="rtl"?1:0;for(++ur;ur<be&&ye[ur]!="L";++ur);for(var Tr=di;Tr<ur;)if(K.test(ye[Tr])){di<Tr&&(xr.splice(Hi,0,new Y(1,di,Tr)),Hi+=Gi);var hn=Tr;for(++Tr;Tr<ur&&K.test(ye[Tr]);++Tr);xr.splice(Hi,0,new Y(2,hn,Tr)),Hi+=Gi,di=Tr}else++Tr;di<ur&&xr.splice(Hi,0,new Y(1,di,ur))}return se=="ltr"&&(xr[0].level==1&&(ai=J.match(/^\s+/))&&(xr[0].from=ai[0].length,xr.unshift(new Y(0,0,ai[0].length))),Re(xr).level==1&&(ai=J.match(/\s+$/))&&(Re(xr).to-=ai[0].length,xr.push(new Y(0,be-ai[0].length,be)))),se=="rtl"?xr.reverse():xr}}();function et(e,t){var i=e.order;return i==null&&(i=e.order=ct(e.text,t)),i}var Qe=[],we=function(e,t,i){if(e.addEventListener)e.addEventListener(t,i,!1);else if(e.attachEvent)e.attachEvent("on"+t,i);else{var r=e._handlers||(e._handlers={});r[t]=(r[t]||Qe).concat(i)}};function lt(e,t){return e._handlers&&e._handlers[t]||Qe}function tt(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 E=pe(n,i);E>-1&&(r[t]=n.slice(0,E).concat(n.slice(E+1)))}}}function Te(e,t){var i=lt(e,t);if(!i.length)return;for(var r=Array.prototype.slice.call(arguments,2),n=0;n<i.length;++n)i[n].apply(null,r)}function Le(e,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Te(e,i||t.type,e,t),ie(t)||t.codemirrorIgnore}function fe(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)pe(i,t[r])==-1&&i.push(t[r])}function le(e,t){return lt(e,t).length>0}function ue(e){e.prototype.on=function(t,i){we(this,t,i)},e.prototype.off=function(t,i){tt(this,t,i)}}function q(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function te(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function ie(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function de(e){q(e),te(e)}function me(e){return e.target||e.srcElement}function Ee(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),l&&e.ctrlKey&&t==1&&(t=3),t}var Pe=function(){if(H&&F<9)return!1;var e=o("div");return"draggable"in e||"dragDrop"in e}(),rt;function mt(e){if(rt==null){var t=o("span","\u200B");d(e,o("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(rt=t.offsetWidth<=1&&t.offsetHeight>2&&!(H&&F<8))}var i=rt?o("span","\u200B"):o("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var ft;function wt(e){if(ft!=null)return ft;var t=d(e,document.createTextNode("A\u062EA")),i=y(t,0,1).getBoundingClientRect(),r=y(t,1,2).getBoundingClientRect();return p(e),!i||i.left==i.right?!1:ft=r.right-i.right<3}var Tt=`
|
|
|
|
b`.split(/\n/).length!=3?function(e){for(var t=0,i=[],r=e.length;t<=r;){var n=e.indexOf(`
|
|
`,t);n==-1&&(n=e.length);var E=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),B=E.indexOf("\r");B!=-1?(i.push(E.slice(0,B)),t+=B+1):(i.push(E),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},ut=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(i){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},Ft=function(){var e=o("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),Ot=null;function Zt(e){if(Ot!=null)return Ot;var t=d(e,o("span","x")),i=t.getBoundingClientRect(),r=y(t,0,1).getBoundingClientRect();return Ot=Math.abs(i.left-r.left)>1}var Xt={},Rt={};function Ir(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Xt[e]=t}function Kr(e,t){Rt[e]=t}function bt(e){if(typeof e=="string"&&Rt.hasOwnProperty(e))e=Rt[e];else if(e&&typeof e.name=="string"&&Rt.hasOwnProperty(e.name)){var t=Rt[e.name];typeof t=="string"&&(t={name:t}),e=$e(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return bt("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return bt("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function Nr(e,t){t=bt(t);var i=Xt[t.name];if(!i)return Nr(e,"text/plain");var r=i(e,t);if(hr.hasOwnProperty(t.name)){var n=hr[t.name];for(var E in n){if(!n.hasOwnProperty(E))continue;r.hasOwnProperty(E)&&(r["_"+E]=r[E]),r[E]=n[E]}}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var B in t.modeProps)r[B]=t.modeProps[B];return r}var hr={};function pr(e,t){var i=hr.hasOwnProperty(e)?hr[e]:hr[e]={};W(t,i)}function Br(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var i={};for(var r in t){var n=t[r];n instanceof Array&&(n=n.concat([])),i[r]=n}return i}function ci(e,t){for(var i;e.innerMode&&!(i=e.innerMode(t),!i||i.mode==e);)t=i.state,e=i.mode;return i||{mode:e,state:t}}function qr(e,t,i){return e.startState?e.startState(t,i):!0}var It=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};It.prototype.eol=function(){return this.pos>=this.string.length},It.prototype.sol=function(){return this.pos==this.lineStart},It.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},It.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},It.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},It.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},It.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},It.prototype.skipToEnd=function(){this.pos=this.string.length},It.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},It.prototype.backUp=function(e){this.pos-=e},It.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=ee(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?ee(this.string,this.lineStart,this.tabSize):0)},It.prototype.indentation=function(){return ee(this.string,null,this.tabSize)-(this.lineStart?ee(this.string,this.lineStart,this.tabSize):0)},It.prototype.match=function(e,t,i){if(typeof e=="string"){var r=function(B){return i?B.toLowerCase():B},n=this.string.substr(this.pos,e.length);if(r(n)==r(e))return t!==!1&&(this.pos+=e.length),!0}else{var E=this.string.slice(this.pos).match(e);return E&&E.index>0?null:(E&&t!==!1&&(this.pos+=E[0].length),E)}},It.prototype.current=function(){return this.string.slice(this.start,this.pos)},It.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},It.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},It.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function ht(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],E=n.chunkSize();if(t<E){i=n;break}t-=E}return i.lines[t]}function Hr(e,t,i){var r=[],n=t.line;return e.iter(t.line,i.line+1,function(E){var B=E.text;n==i.line&&(B=B.slice(0,i.ch)),n==t.line&&(B=B.slice(t.ch)),r.push(B),++n}),r}function ei(e,t,i){var r=[];return e.iter(t,i,function(n){r.push(n.text)}),r}function mr(e,t){var i=t-e.height;if(i)for(var r=e;r;r=r.parent)r.height+=i}function kt(e){if(e.parent==null)return null;for(var t=e.parent,i=pe(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var n=0;!(r.children[n]==t);++n)i+=r.children[n].chunkSize();return i+t.first}function Fr(e,t){var i=e.first;e:do{for(var r=0;r<e.children.length;++r){var n=e.children[r],E=n.height;if(t<E){e=n;continue e}t-=E,i+=n.chunkSize()}return i}while(!e.lines);for(var B=0;B<e.lines.length;++B){var K=e.lines[B],Y=K.height;if(t<Y)break;t-=Y}return i+B}function Vr(e,t){return t>=e.first&&t<e.first+e.size}function fi(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function Ue(e,t,i){if(i===void 0&&(i=null),!(this instanceof Ue))return new Ue(e,t,i);this.line=e,this.ch=t,this.sticky=i}function St(e,t){return e.line-t.line||e.ch-t.ch}function pi(e,t){return e.sticky==t.sticky&&St(e,t)==0}function mi(e){return Ue(e.line,e.ch)}function gi(e,t){return St(e,t)<0?t:e}function vi(e,t){return St(e,t)<0?e:t}function j(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function s(e,t){if(t.line<e.first)return Ue(e.first,0);var i=e.first+e.size-1;return t.line>i?Ue(i,ht(e,i).text.length):c(t,ht(e,t.line).text.length)}function c(e,t){var i=e.ch;return i==null||i>t?Ue(e.line,t):i<0?Ue(e.line,0):e}function R(e,t){for(var i=[],r=0;r<t.length;r++)i[r]=s(e,t[r]);return i}var Z=function(e,t){this.state=e,this.lookAhead=t},U=function(e,t,i,r){this.state=t,this.doc=e,this.line=i,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};U.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},U.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},U.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},U.fromSaved=function(e,t,i){return t instanceof Z?new U(e,Br(e.mode,t.state),i,t.lookAhead):new U(e,Br(e.mode,t),i)},U.prototype.save=function(e){var t=e!==!1?Br(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Z(t,this.maxLookAhead):t};function ce(e,t,i,r){var n=[e.state.modeGen],E={};gr(e,t.text,e.doc.mode,i,function(J,se){return n.push(J,se)},E,r);for(var B=i.state,K=function(J){i.baseTokens=n;var se=e.state.overlays[J],he=1,be=0;i.state=!0,gr(e,t.text,se.mode,i,function(ye,ke){for(var Ne=he;be<ye;){var je=n[he];je>ye&&n.splice(he,1,ye,n[he+1],je),he+=2,be=Math.min(ye,je)}if(!ke)return;if(se.opaque)n.splice(Ne,he-Ne,ye,"overlay "+ke),he=Ne+2;else for(;Ne<he;Ne+=2){var Xe=n[Ne+1];n[Ne+1]=(Xe?Xe+" ":"")+"overlay "+ke}},E),i.state=B,i.baseTokens=null,i.baseTokenPos=1},Y=0;Y<e.state.overlays.length;++Y)K(Y);return{styles:n,classes:E.bgClass||E.textClass?E:null}}function Oe(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=Ke(e,kt(t)),n=t.text.length>e.options.maxHighlightLength&&Br(e.doc.mode,r.state),E=ce(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=E.styles,E.classes?t.styleClasses=E.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 Ke(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new U(r,!0,t);var E=vr(e,t,i),B=E>r.first&&ht(r,E-1).stateAfter,K=B?U.fromSaved(r,B,E):new U(r,qr(r.mode),E);return r.iter(E,t,function(Y){dt(e,Y.text,K);var J=K.line;Y.stateAfter=J==t-1||J%5==0||J>=n.viewFrom&&J<n.viewTo?K.save():null,K.nextLine()}),i&&(r.modeFrontier=K.line),K}function dt(e,t,i,r){var n=e.doc.mode,E=new It(t,e.options.tabSize,i);for(E.start=E.pos=r||0,t==""&&Me(n,i.state);!E.eol();)vt(n,E,i.state),E.start=E.pos}function Me(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var i=ci(e,t);if(i.mode.blankLine)return i.mode.blankLine(i.state)}function vt(e,t,i,r){for(var n=0;n<10;n++){r&&(r[0]=ci(e,i).mode);var E=e.token(t,i);if(t.pos>t.start)return E}throw new Error("Mode "+e.name+" failed to advance stream.")}var Nt=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function Kt(e,t,i,r){var n=e.doc,E=n.mode,B;t=s(n,t);var K=ht(n,t.line),Y=Ke(e,t.line,i),J=new It(K.text,e.options.tabSize,Y),se;for(r&&(se=[]);(r||J.pos<t.ch)&&!J.eol();)J.start=J.pos,B=vt(E,J,Y.state),r&&se.push(new Nt(J,B,Br(n.mode,Y.state)));return r?se:new Nt(J,B,Y.state)}function Rr(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 gr(e,t,i,r,n,E,B){var K=i.flattenSpans;K==null&&(K=e.options.flattenSpans);var Y=0,J=null,se=new It(t,e.options.tabSize,r),he,be=e.options.addModeClass&&[null];for(t==""&&Rr(Me(i,r.state),E);!se.eol();){if(se.pos>e.options.maxHighlightLength?(K=!1,B&&dt(e,t,r,se.pos),se.pos=t.length,he=null):he=Rr(vt(i,se,r.state,be),E),be){var ye=be[0].name;ye&&(he="m-"+(he?ye+" "+he:ye))}if(!K||J!=he){for(;Y<se.start;)Y=Math.min(se.start,Y+5e3),n(Y,J);J=he}se.start=se.pos}for(;Y<se.pos;){var ke=Math.min(se.pos,Y+5e3);n(ke,J),Y=ke}}function vr(e,t,i){for(var r,n,E=e.doc,B=i?-1:t-(e.doc.mode.innerMode?1e3:100),K=t;K>B;--K){if(K<=E.first)return E.first;var Y=ht(E,K-1),J=Y.stateAfter;if(J&&(!i||K+(J instanceof Z?J.lookAhead:0)<=E.modeFrontier))return K;var se=ee(Y.text,null,e.options.tabSize);(n==null||r>se)&&(n=K-1,r=se)}return n}function Xr(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),e.highlightFrontier<t-10)return;for(var i=e.first,r=t-1;r>i;r--){var n=ht(e,r).stateAfter;if(n&&(!(n instanceof Z)||r+n.lookAhead<t)){i=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)}var Ri=!1,nr=!1;function Ur(){Ri=!0}function oi(){nr=!0}function si(e,t,i){this.marker=e,this.from=t,this.to=i}function Or(e,t){if(e)for(var i=0;i<e.length;++i){var r=e[i];if(r.marker==t)return r}}function Oi(e,t){for(var i,r=0;r<e.length;++r)e[r]!=t&&(i||(i=[])).push(e[r]);return i}function yi(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function zi(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var E=e[n],B=E.marker,K=E.from==null||(B.inclusiveLeft?E.from<=t:E.from<t);if(K||E.from==t&&B.type=="bookmark"&&(!i||!E.marker.insertLeft)){var Y=E.to==null||(B.inclusiveRight?E.to>=t:E.to>t);(r||(r=[])).push(new si(B,E.from,Y?null:E.to))}}return r}function Ki(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var E=e[n],B=E.marker,K=E.to==null||(B.inclusiveRight?E.to>=t:E.to>t);if(K||E.from==t&&B.type=="bookmark"&&(!i||E.marker.insertLeft)){var Y=E.from==null||(B.inclusiveLeft?E.from<=t:E.from<t);(r||(r=[])).push(new si(B,Y?null:E.from-t,E.to==null?null:E.to-t))}}return r}function Yr(e,t){if(t.full)return null;var i=Vr(e,t.from.line)&&ht(e,t.from.line).markedSpans,r=Vr(e,t.to.line)&&ht(e,t.to.line).markedSpans;if(!i&&!r)return null;var n=t.from.ch,E=t.to.ch,B=St(t.from,t.to)==0,K=zi(i,n,B),Y=Ki(r,E,B),J=t.text.length==1,se=Re(t.text).length+(J?n:0);if(K)for(var he=0;he<K.length;++he){var be=K[he];if(be.to==null){var ye=Or(Y,be.marker);ye?J&&(be.to=ye.to==null?null:ye.to+se):be.to=n}}if(Y)for(var ke=0;ke<Y.length;++ke){var Ne=Y[ke];if(Ne.to!=null&&(Ne.to+=se),Ne.from==null){var je=Or(K,Ne.marker);je||(Ne.from=se,J&&(K||(K=[])).push(Ne))}else Ne.from+=se,J&&(K||(K=[])).push(Ne)}K&&(K=Gr(K)),Y&&Y!=K&&(Y=Gr(Y));var Xe=[K];if(!J){var nt=t.text.length-2,Ye;if(nt>0&&K)for(var st=0;st<K.length;++st)K[st].to==null&&(Ye||(Ye=[])).push(new si(K[st].marker,null,null));for(var Et=0;Et<nt;++Et)Xe.push(Ye);Xe.push(Y)}return Xe}function Gr(e){for(var t=0;t<e.length;++t){var i=e[t];i.from!=null&&i.from==i.to&&i.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function bi(e,t,i){var r=null;if(e.iter(t.line,i.line+1,function(ye){if(ye.markedSpans)for(var ke=0;ke<ye.markedSpans.length;++ke){var Ne=ye.markedSpans[ke].marker;Ne.readOnly&&(!r||pe(r,Ne)==-1)&&(r||(r=[])).push(Ne)}}),!r)return null;for(var n=[{from:t,to:i}],E=0;E<r.length;++E)for(var B=r[E],K=B.find(0),Y=0;Y<n.length;++Y){var J=n[Y];if(St(J.to,K.from)<0||St(J.from,K.to)>0)continue;var se=[Y,1],he=St(J.from,K.from),be=St(J.to,K.to);(he<0||!B.inclusiveLeft&&!he)&&se.push({from:J.from,to:K.from}),(be>0||!B.inclusiveRight&&!be)&&se.push({from:K.to,to:J.to}),n.splice.apply(n,se),Y+=se.length-3}return n}function dn(e){var t=e.markedSpans;if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.detachLine(e);e.markedSpans=null}function xi(e,t){if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.attachLine(e);e.markedSpans=t}function Jt(e){return e.inclusiveLeft?-1:0}function Bt(e){return e.inclusiveRight?1:0}function dr(e,t){var i=e.lines.length-t.lines.length;if(i!=0)return i;var r=e.find(),n=t.find(),E=St(r.from,n.from)||Jt(e)-Jt(t);if(E)return-E;var B=St(r.to,n.to)||Bt(e)-Bt(t);return B||t.id-e.id}function _t(e,t){var i=nr&&e.markedSpans,r;if(i)for(var n=void 0,E=0;E<i.length;++E)n=i[E],n.marker.collapsed&&(t?n.from:n.to)==null&&(!r||dr(r,n.marker)<0)&&(r=n.marker);return r}function qt(e){return _t(e,!0)}function Wt(e){return _t(e,!1)}function ti(e,t){var i=nr&&e.markedSpans,r;if(i)for(var n=0;n<i.length;++n){var E=i[n];E.marker.collapsed&&(E.from==null||E.from<t)&&(E.to==null||E.to>t)&&(!r||dr(r,E.marker)<0)&&(r=E.marker)}return r}function ar(e,t,i,r,n){var E=ht(e,t),B=nr&&E.markedSpans;if(B)for(var K=0;K<B.length;++K){var Y=B[K];if(!Y.marker.collapsed)continue;var J=Y.marker.find(0),se=St(J.from,i)||Jt(Y.marker)-Jt(n),he=St(J.to,r)||Bt(Y.marker)-Bt(n);if(se>=0&&he<=0||se<=0&&he>=0)continue;if(se<=0&&(Y.marker.inclusiveRight&&n.inclusiveLeft?St(J.to,i)>=0:St(J.to,i)>0)||se>=0&&(Y.marker.inclusiveRight&&n.inclusiveLeft?St(J.from,r)<=0:St(J.from,r)<0))return!0}}function Er(e){for(var t;t=qt(e);)e=t.find(-1,!0).line;return e}function Vi(e){for(var t;t=Wt(e);)e=t.find(1,!0).line;return e}function Ei(e){for(var t,i;t=Wt(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function cn(e,t){var i=ht(e,t),r=Er(i);return i==r?t:kt(r)}function Si(e,t){if(t>e.lastLine())return t;var i=ht(e,t),r;if(!ri(e,i))return t;for(;r=Wt(i);)i=r.find(1,!0).line;return kt(i)+1}function ri(e,t){var i=nr&&t.markedSpans;if(i)for(var r=void 0,n=0;n<i.length;++n){if(r=i[n],!r.marker.collapsed)continue;if(r.from==null)return!0;if(r.marker.widgetNode)continue;if(r.from==0&&r.marker.inclusiveLeft&&fn(e,t,r))return!0}}function fn(e,t,i){if(i.to==null){var r=i.marker.find(1,!0);return fn(e,r.line,Or(r.line.markedSpans,i.marker))}if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(var n=void 0,E=0;E<t.markedSpans.length;++E)if(n=t.markedSpans[E],n.marker.collapsed&&!n.marker.widgetNode&&n.from==i.to&&(n.to==null||n.to!=i.from)&&(n.marker.inclusiveLeft||i.marker.inclusiveRight)&&fn(e,t,n))return!0}function $r(e){e=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 E=i.parent;E;i=E,E=i.parent)for(var B=0;B<E.children.length;++B){var K=E.children[B];if(K==i)break;t+=K.height}return t}function pn(e){if(e.height==0)return 0;for(var t=e.text.length,i,r=e;i=qt(r);){var n=i.find(0,!0);r=n.from.line,t+=n.from.ch-n.to.ch}for(r=e;i=Wt(r);){var E=i.find(0,!0);t-=r.text.length-E.from.ch,r=E.to.line,t+=r.text.length-E.to.ch}return t}function jn(e){var t=e.display,i=e.doc;t.maxLine=ht(i,i.first),t.maxLineLength=pn(t.maxLine),t.maxLineChanged=!0,i.iter(function(r){var n=pn(r);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var Pi=function(e,t,i){this.text=e,xi(this,t),this.height=i?i(this):1};Pi.prototype.lineNo=function(){return kt(this)},ue(Pi);function ua(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),dn(e),xi(e,i);var n=r?r(e):1;n!=e.height&&mr(e,n)}function pt(e){e.parent=null,dn(e)}var Ct={},yt={};function Lt(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?yt:Ct;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function Mt(e,t){var i=S("span",null,null,P?"padding-right: .1px":null),r={pre:S("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 E=n?t.rest[n-1]:t.line,B=void 0;r.pos=0,r.addToken=Pt,wt(e.display.measure)&&(B=et(E,e.doc.direction))&&(r.addToken=Cr(r.addToken,B)),r.map=[];var K=t!=e.display.externalMeasured&&kt(E);li(E,r,Oe(e,E,K)),E.styleClasses&&(E.styleClasses.bgClass&&(r.bgClass=X(E.styleClasses.bgClass,r.bgClass||"")),E.styleClasses.textClass&&(r.textClass=X(E.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(mt(e.display.measure))),n==0?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(P){var Y=r.content.lastChild;(/\bcm-tab\b/.test(Y.className)||Y.querySelector&&Y.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Te(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=X(r.pre.className,r.textClass||"")),r}function Gt(e){var t=o("span","\u2022","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Pt(e,t,i,r,n,E,B){if(!t)return;var K=e.splitSpaces?rr(t,e.trailingSpace):t,Y=e.cm.state.specialChars,J=!1,se;if(!Y.test(t))e.col+=t.length,se=document.createTextNode(K),e.map.push(e.pos,e.pos+t.length,se),H&&F<9&&(J=!0),e.pos+=t.length;else{se=document.createDocumentFragment();for(var he=0;;){Y.lastIndex=he;var be=Y.exec(t),ye=be?be.index-he:t.length-he;if(ye){var ke=document.createTextNode(K.slice(he,he+ye));H&&F<9?se.appendChild(o("span",[ke])):se.appendChild(ke),e.map.push(e.pos,e.pos+ye,ke),e.col+=ye,e.pos+=ye}if(!be)break;he+=ye+1;var Ne=void 0;if(be[0]==" "){var je=e.cm.options.tabSize,Xe=je-e.col%je;Ne=se.appendChild(o("span",oe(Xe),"cm-tab")),Ne.setAttribute("role","presentation"),Ne.setAttribute("cm-text"," "),e.col+=Xe}else be[0]=="\r"||be[0]==`
|
|
`?(Ne=se.appendChild(o("span",be[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Ne.setAttribute("cm-text",be[0]),e.col+=1):(Ne=e.cm.options.specialCharPlaceholder(be[0]),Ne.setAttribute("cm-text",be[0]),H&&F<9?se.appendChild(o("span",[Ne])):se.appendChild(Ne),e.col+=1);e.map.push(e.pos,e.pos+1,Ne),e.pos++}}if(e.trailingSpace=K.charCodeAt(t.length-1)==32,i||r||n||J||E||B){var nt=i||"";r&&(nt+=r),n&&(nt+=n);var Ye=o("span",[se],nt,E);if(B)for(var st in B)B.hasOwnProperty(st)&&st!="style"&&st!="class"&&Ye.setAttribute(st,B[st]);return e.content.appendChild(Ye)}e.content.appendChild(se)}function rr(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;n<e.length;n++){var E=e.charAt(n);E==" "&&i&&(n==e.length-1||e.charCodeAt(n+1)==32)&&(E="\xA0"),r+=E,i=E==" "}return r}function Cr(e,t){return function(i,r,n,E,B,K,Y){n=n?n+" cm-force-border":"cm-force-border";for(var J=i.pos,se=J+r.length;;){for(var he=void 0,be=0;be<t.length&&!(he=t[be],he.to>J&&he.from<=J);be++);if(he.to>=se)return e(i,r,n,E,B,K,Y);e(i,r.slice(0,he.to-J),n,E,null,K,Y),E=null,r=r.slice(he.to-J),J=he.to}}}function Dt(e,t,i,r){var n=!r&&i.widgetNode;n&&e.map.push(e.pos,e.pos+t,n),!r&&e.cm.display.input.needsContentAttribute&&(n||(n=e.content.appendChild(document.createElement("span"))),n.setAttribute("cm-marker",i.id)),n&&(e.cm.display.input.setUneditable(n),e.content.appendChild(n)),e.pos+=t,e.trailingSpace=!1}function li(e,t,i){var r=e.markedSpans,n=e.text,E=0;if(!r){for(var B=1;B<i.length;B+=2)t.addToken(t,n.slice(E,E=i[B]),Lt(i[B+1],t.cm.options));return}for(var K=n.length,Y=0,J=1,se="",he,be,ye=0,ke,Ne,je,Xe,nt;;){if(ye==Y){ke=Ne=je=be="",nt=null,Xe=null,ye=Infinity;for(var Ye=[],st=void 0,Et=0;Et<r.length;++Et){var gt=r[Et],At=gt.marker;if(At.type=="bookmark"&>.from==Y&&At.widgetNode)Ye.push(At);else if(gt.from<=Y&&(gt.to==null||gt.to>Y||At.collapsed&>.to==Y&>.from==Y)){if(gt.to!=null&>.to!=Y&&ye>gt.to&&(ye=gt.to,Ne=""),At.className&&(ke+=" "+At.className),At.css&&(be=(be?be+";":"")+At.css),At.startStyle&>.from==Y&&(je+=" "+At.startStyle),At.endStyle&>.to==ye&&(st||(st=[])).push(At.endStyle,gt.to),At.title&&((nt||(nt={})).title=At.title),At.attributes)for(var zt in At.attributes)(nt||(nt={}))[zt]=At.attributes[zt];At.collapsed&&(!Xe||dr(Xe.marker,At)<0)&&(Xe=gt)}else gt.from>Y&&ye>gt.from&&(ye=gt.from)}if(st)for(var lr=0;lr<st.length;lr+=2)st[lr+1]==ye&&(Ne+=" "+st[lr]);if(!Xe||Xe.from==Y)for(var Yt=0;Yt<Ye.length;++Yt)Dt(t,0,Ye[Yt]);if(Xe&&(Xe.from||0)==Y){if(Dt(t,(Xe.to==null?K+1:Xe.to)-Y,Xe.marker,Xe.from==null),Xe.to==null)return;Xe.to==Y&&(Xe=!1)}}if(Y>=K)break;for(var Mr=Math.min(K,ye);;){if(se){var kr=Y+se.length;if(!Xe){var er=kr>Mr?se.slice(0,Mr-Y):se;t.addToken(t,er,he?he+ke:ke,je,Y+er.length==ye?Ne:"",be,nt)}if(kr>=Mr){se=se.slice(Mr-Y),Y=Mr;break}Y=kr,je=""}se=n.slice(E,E=i[J++]),he=Lt(i[J++],t.cm.options)}}}function Ut(e,t,i){this.line=t,this.rest=Ei(t),this.size=this.rest?kt(Re(this.rest))-i+1:1,this.node=this.text=null,this.hidden=ri(e,t)}function wr(e,t,i){for(var r=[],n,E=t;E<i;E=n){var B=new Ut(e.doc,ht(e.doc,E),E);n=E+B.size,r.push(B)}return r}var yr=null;function zr(e){yr?yr.ops.push(e):e.ownsGroup=yr={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{yr=null,t(i)}}var mn=null;function cr(e,t){var i=lt(e,t);if(!i.length)return;var r=Array.prototype.slice.call(arguments,2),n;yr?n=yr.delayedCallbacks:mn?n=mn:(n=mn=[],setTimeout(Os,0));for(var E=function(K){n.push(function(){return i[K].apply(null,r)})},B=0;B<i.length;++B)E(B)}function Os(){var e=mn;mn=null;for(var t=0;t<e.length;++t)e[t]()}function Ya(e,t,i,r){for(var n=0;n<t.changes.length;n++){var E=t.changes[n];E=="text"?Ms(e,t):E=="gutter"?Za(e,t,i,r):E=="class"?ha(e,t):E=="widget"&&Is(e,t,r)}t.changes=null}function gn(e){return e.node==e.text&&(e.node=o("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),H&&F<8&&(e.node.style.zIndex=2)),e.node}function Ps(e,t){var i=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(i&&(i+=" CodeMirror-linebackground"),t.background)i?t.background.className=i:(t.background.parentNode.removeChild(t.background),t.background=null);else if(i){var r=gn(t);t.background=r.insertBefore(o("div",null,i),r.firstChild),e.display.input.setUneditable(t.background)}}function $a(e,t){var i=e.display.externalMeasured;return i&&i.line==t.line?(e.display.externalMeasured=null,t.measure=i.measure,i.built):Mt(e,t)}function Ms(e,t){var i=t.text.className,r=$a(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,ha(e,t)):i&&(t.text.className=i)}function ha(e,t){Ps(e,t),t.line.wrapClass?gn(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var i=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=i||""}function Za(e,t,i,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var n=gn(t);t.gutterBackground=o("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),n.insertBefore(t.gutterBackground,t.text)}var E=t.line.gutterMarkers;if(e.options.lineNumbers||E){var B=gn(t),K=t.gutter=o("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(K),B.insertBefore(K,t.text),t.line.gutterClass&&(K.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!E||!E["CodeMirror-linenumbers"])&&(t.lineNumber=K.appendChild(o("div",fi(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),E)for(var Y=0;Y<e.display.gutterSpecs.length;++Y){var J=e.display.gutterSpecs[Y].className,se=E.hasOwnProperty(J)&&E[J];se&&K.appendChild(o("div",[se],"CodeMirror-gutter-elt","left: "+r.gutterLeft[J]+"px; width: "+r.gutterWidth[J]+"px"))}}}function Is(e,t,i){t.alignable&&(t.alignable=null);for(var r=v("CodeMirror-linewidget"),n=t.node.firstChild,E=void 0;n;n=E)E=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 E=gn(i),B=0,K=t.widgets;B<K.length;++B){var Y=K[B],J=o("div",[Y.node],"CodeMirror-linewidget"+(Y.className?" "+Y.className:""));Y.handleMouseEvents||J.setAttribute("cm-ignore-events","true"),Bs(Y,J,i,r),e.display.input.setUneditable(J),n&&Y.above?E.insertBefore(J,i.gutter||i.text):E.appendChild(J),cr(Y,"redraw")}}function Bs(e,t,i,r){if(e.noHScroll){(i.alignable||(i.alignable=[])).push(t);var n=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(n-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=n+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function vn(e){if(e.height!=null)return e.height;var t=e.doc.cm;if(!t)return 0;if(!T(document.body,e.node)){var i="position: relative;";e.coverGutter&&(i+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(i+="width: "+t.display.wrapper.clientWidth+"px;"),d(t.display.measure,o("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function ui(e,t){for(var i=me(t);i!=e.wrapper;i=i.parentNode)if(!i||i.nodeType==1&&i.getAttribute("cm-ignore-events")=="true"||i.parentNode==e.sizer&&i!=e.mover)return!0}function Wn(e){return e.lineSpace.offsetTop}function da(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function qa(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=d(e.measure,o("pre","x","CodeMirror-line-like")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function ii(e){return ve-e.display.nativeBarWidth}function Mi(e){return e.display.scroller.clientWidth-ii(e)-e.display.barWidth}function ca(e){return e.display.scroller.clientHeight-ii(e)-e.display.barHeight}function Fs(e,t,i){var r=e.options.lineWrapping,n=r&&Mi(e);if(!t.measure.heights||r&&t.measure.width!=n){var E=t.measure.heights=[];if(r){t.measure.width=n;for(var B=t.text.firstChild.getClientRects(),K=0;K<B.length-1;K++){var Y=B[K],J=B[K+1];Math.abs(Y.bottom-J.bottom)>2&&E.push((Y.bottom+J.top)/2-i.top)}}E.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(kt(e.rest[n])>i)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Us(e,t){t=Er(t);var i=kt(t),r=e.display.externalMeasured=new Ut(e.doc,t,i);r.lineN=i;var n=r.built=Mt(e,r);return r.text=n.pre,d(e.display.lineMeasure,n.pre),r}function to(e,t,i,r){return ni(e,Xi(e,t),i,r)}function fa(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Bi(e,t)];var i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size)return i}function Xi(e,t){var i=kt(t),r=fa(e,i);r&&!r.text?r=null:r&&r.changes&&(Ya(e,r,i,ba(e)),e.curOp.forceUpdate=!0),r||(r=Us(e,t));var n=eo(r,t,i);return{line:t,view:r,rect:null,map:n.map,cache:n.cache,before:n.before,hasHeights:!1}}function ni(e,t,i,r,n){t.before&&(i=-1);var E=i+(r||""),B;return t.cache.hasOwnProperty(E)?B=t.cache[E]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Fs(e,t.view,t.rect),t.hasHeights=!0),B=Ws(e,t,i,r),B.bogus||(t.cache[E]=B)),{left:B.left,right:B.right,top:n?B.rtop:B.top,bottom:n?B.rbottom:B.bottom}}var ro={left:0,right:0,top:0,bottom:0};function io(e,t,i){for(var r,n,E,B,K,Y,J=0;J<e.length;J+=3)if(K=e[J],Y=e[J+1],t<K?(n=0,E=1,B="left"):t<Y?(n=t-K,E=n+1):(J==e.length-3||t==Y&&e[J+3]>t)&&(E=Y-K,n=E-1,t>=Y&&(B="right")),n!=null){if(r=e[J+2],K==Y&&i==(r.insertLeft?"left":"right")&&(B=i),i=="left"&&n==0)for(;J&&e[J-2]==e[J-3]&&e[J-1].insertLeft;)r=e[(J-=3)+2],B="left";if(i=="right"&&n==Y-K)for(;J<e.length-3&&e[J+3]==e[J+4]&&!e[J+5].insertLeft;)r=e[(J+=3)+2],B="right";break}return{node:r,start:n,end:E,collapse:B,coverStart:K,coverEnd:Y}}function js(e,t){var i=ro;if(t=="left")for(var r=0;r<e.length&&!((i=e[r]).left!=i.right);r++);else for(var n=e.length-1;n>=0&&!((i=e[n]).left!=i.right);n--);return i}function Ws(e,t,i,r){var n=io(t.map,i,r),E=n.node,B=n.start,K=n.end,Y=n.collapse,J;if(E.nodeType==3){for(var se=0;se<4;se++){for(;B&&Be(t.line.text.charAt(n.coverStart+B));)--B;for(;n.coverStart+K<n.coverEnd&&Be(t.line.text.charAt(n.coverStart+K));)++K;if(H&&F<9&&B==0&&K==n.coverEnd-n.coverStart?J=E.parentNode.getBoundingClientRect():J=js(y(E,B,K).getClientRects(),r),J.left||J.right||B==0)break;K=B,B=B-1,Y="right"}H&&F<11&&(J=Hs(e.display.measure,J))}else{B>0&&(Y=r="right");var he;e.options.lineWrapping&&(he=E.getClientRects()).length>1?J=he[r=="right"?he.length-1:0]:J=E.getBoundingClientRect()}if(H&&F<9&&!B&&(!J||!J.left&&!J.right)){var be=E.parentNode.getClientRects()[0];be?J={left:be.left,right:be.left+$i(e.display),top:be.top,bottom:be.bottom}:J=ro}for(var ye=J.top-t.rect.top,ke=J.bottom-t.rect.top,Ne=(ye+ke)/2,je=t.view.measure.heights,Xe=0;Xe<je.length-1&&!(Ne<je[Xe]);Xe++);var nt=Xe?je[Xe-1]:0,Ye=je[Xe],st={left:(Y=="right"?J.right:J.left)-t.rect.left,right:(Y=="left"?J.left:J.right)-t.rect.left,top:nt,bottom:Ye};return!J.left&&!J.right&&(st.bogus=!0),e.options.singleCursorHeightPerLine||(st.rtop=ye,st.rbottom=ke),st}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Zt(e))return t;var i=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*i,right:t.right*i,top:t.top*r,bottom:t.bottom*r}}function no(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function ao(e){e.display.externalMeasure=null,p(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)no(e.display.view[t])}function yn(e){ao(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function oo(){return b&&u?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function so(){return b&&u?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function pa(e){var t=0;if(e.widgets)for(var i=0;i<e.widgets.length;++i)e.widgets[i].above&&(t+=vn(e.widgets[i]));return t}function Hn(e,t,i,r,n){if(!n){var E=pa(t);i.top+=E,i.bottom+=E}if(r=="line")return i;r||(r="local");var B=$r(t);if(r=="local"?B+=Wn(e.display):B-=e.display.viewOffset,r=="page"||r=="window"){var K=e.display.lineSpace.getBoundingClientRect();B+=K.top+(r=="window"?0:so());var Y=K.left+(r=="window"?0:oo());i.left+=Y,i.right+=Y}return i.top+=B,i.bottom+=B,i}function lo(e,t,i){if(i=="div")return t;var r=t.left,n=t.top;if(i=="page")r-=oo(),n-=so();else if(i=="local"||!i){var E=e.display.sizer.getBoundingClientRect();r+=E.left,n+=E.top}var B=e.display.lineSpace.getBoundingClientRect();return{left:r-B.left,top:n-B.top}}function ma(e,t,i,r,n){return r||(r=ht(e.doc,t.line)),Hn(e,r,to(e,r,t.ch,n),i)}function Zr(e,t,i,r,n,E){r=r||ht(e.doc,t.line),n||(n=Xi(e,r));function B(ke,Ne){var je=ni(e,n,ke,Ne?"right":"left",E);return Ne?je.left=je.right:je.right=je.left,Hn(e,r,je,i)}var K=et(r,e.doc.direction),Y=t.ch,J=t.sticky;if(Y>=r.text.length?(Y=r.text.length,J="before"):Y<=0&&(Y=0,J="after"),!K)return B(J=="before"?Y-1:Y,J=="before");function se(ke,Ne,je){var Xe=K[Ne],nt=Xe.level==1;return B(je?ke-1:ke,nt!=je)}var he=qe(K,Y,J),be=Je,ye=se(Y,he,J=="before");return be!=null&&(ye.other=se(Y,be,J!="before")),ye}function uo(e,t){var i=0;t=s(e.doc,t),e.options.lineWrapping||(i=$i(e.display)*t.ch);var r=ht(e.doc,t.line),n=$r(r)+Wn(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function ga(e,t,i,r,n){var E=Ue(e,t,i);return E.xRel=n,r&&(E.outside=r),E}function va(e,t,i){var r=e.doc;if(i+=e.display.viewOffset,i<0)return ga(r.first,0,null,-1,-1);var n=Fr(r,i),E=r.first+r.size-1;if(n>E)return ga(r.first+r.size-1,ht(r,E).text.length,null,1,1);t<0&&(t=0);for(var B=ht(r,n);;){var K=Gs(e,B,n,t,i),Y=ti(B,K.ch+(K.xRel>0||K.outside>0?1:0));if(!Y)return K;var J=Y.find(1);if(J.line==n)return J;B=ht(r,n=J.line)}}function ho(e,t,i,r){r-=pa(t);var n=t.text.length,E=ot(function(B){return ni(e,i,B-1).bottom<=r},n,0);return n=ot(function(B){return ni(e,i,B).top>r},E,n),{begin:E,end:n}}function co(e,t,i,r){i||(i=Xi(e,t));var n=Hn(e,t,ni(e,i,r),"line").top;return ho(e,t,i,n)}function ya(e,t,i,r){return e.bottom<=i?!1:e.top>i?!0:(r?e.left:e.right)>t}function Gs(e,t,i,r,n){n-=$r(t);var E=Xi(e,t),B=pa(t),K=0,Y=t.text.length,J=!0,se=et(t,e.doc.direction);if(se){var he=(e.options.lineWrapping?Ks:zs)(e,t,i,E,se,r,n);J=he.level!=1,K=J?he.from:he.to-1,Y=J?he.to:he.from-1}var be=null,ye=null,ke=ot(function(Et){var gt=ni(e,E,Et);return gt.top+=B,gt.bottom+=B,ya(gt,r,n,!1)?(gt.top<=n&>.left<=r&&(be=Et,ye=gt),!0):!1},K,Y),Ne,je,Xe=!1;if(ye){var nt=r-ye.left<ye.right-r,Ye=nt==J;ke=be+(Ye?0:1),je=Ye?"after":"before",Ne=nt?ye.left:ye.right}else{!J&&(ke==Y||ke==K)&&ke++,je=ke==0?"after":ke==t.text.length?"before":ni(e,E,ke-(J?1:0)).bottom+B<=n==J?"after":"before";var st=Zr(e,Ue(i,ke,je),"line",t,E);Ne=st.left,Xe=n<st.top?-1:n>=st.bottom?1:0}return ke=Fe(t.text,ke,1),ga(i,ke,je,Xe,r-Ne)}function zs(e,t,i,r,n,E,B){var K=ot(function(he){var be=n[he],ye=be.level!=1;return ya(Zr(e,Ue(i,ye?be.to:be.from,ye?"before":"after"),"line",t,r),E,B,!0)},0,n.length-1),Y=n[K];if(K>0){var J=Y.level!=1,se=Zr(e,Ue(i,J?Y.from:Y.to,J?"after":"before"),"line",t,r);ya(se,E,B,!0)&&se.top>B&&(Y=n[K-1])}return Y}function Ks(e,t,i,r,n,E,B){var K=ho(e,t,r,B),Y=K.begin,J=K.end;/\s/.test(t.text.charAt(J-1))&&J--;for(var se=null,he=null,be=0;be<n.length;be++){var ye=n[be];if(ye.from>=J||ye.to<=Y)continue;var ke=ye.level!=1,Ne=ni(e,r,ke?Math.min(J,ye.to)-1:Math.max(Y,ye.from)).right,je=Ne<E?E-Ne+1e9:Ne-E;(!se||he>je)&&(se=ye,he=je)}return se||(se=n[n.length-1]),se.from<Y&&(se={from:Y,to:se.to,level:se.level}),se.to>J&&(se={from:se.from,to:J,level:se.level}),se}var Ii;function Yi(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Ii==null){Ii=o("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Ii.appendChild(document.createTextNode("x")),Ii.appendChild(o("br"));Ii.appendChild(document.createTextNode("x"))}d(e.measure,Ii);var i=Ii.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),p(e.measure),i||1}function $i(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=o("span","xxxxxxxxxx"),i=o("pre",[t],"CodeMirror-line-like");d(e.measure,i);var r=t.getBoundingClientRect(),n=(r.right-r.left)/10;return n>2&&(e.cachedCharWidth=n),n||10}function ba(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,E=t.gutters.firstChild,B=0;E;E=E.nextSibling,++B){var K=e.display.gutterSpecs[B].className;i[K]=E.offsetLeft+E.clientLeft+n,r[K]=E.clientWidth}return{fixedPos:xa(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function xa(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function fo(e){var t=Yi(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/$i(e.display)-3);return function(n){if(ri(e.doc,n))return 0;var E=0;if(n.widgets)for(var B=0;B<n.widgets.length;B++)n.widgets[B].height&&(E+=n.widgets[B].height);return i?E+(Math.ceil(n.text.length/r)||1)*t:E+t}}function Ea(e){var t=e.doc,i=fo(e);t.iter(function(r){var n=i(r);n!=r.height&&mr(r,n)})}function Ni(e,t,i,r){var n=e.display;if(!i&&me(t).getAttribute("cm-not-content")=="true")return null;var E,B,K=n.lineSpace.getBoundingClientRect();try{E=t.clientX-K.left,B=t.clientY-K.top}catch(he){return null}var Y=va(e,E,B),J;if(r&&Y.xRel>0&&(J=ht(e.doc,Y.line).text).length==Y.ch){var se=ee(J,J.length,e.options.tabSize)-J.length;Y=Ue(Y.line,Math.max(0,Math.round((E-qa(e.display).left)/$i(e.display))-se))}return Y}function Bi(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var i=e.display.view,r=0;r<i.length;r++)if(t-=i[r].size,t<0)return r}function Ar(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)nr&&cn(e.doc,t)<n.viewTo&&Ci(e);else if(i<=n.viewFrom)nr&&Si(e.doc,i+r)>n.viewFrom?Ci(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)Ci(e);else if(t<=n.viewFrom){var E=Gn(e,i,i+r,1);E?(n.view=n.view.slice(E.index),n.viewFrom=E.lineN,n.viewTo+=r):Ci(e)}else if(i>=n.viewTo){var B=Gn(e,t,t,-1);B?(n.view=n.view.slice(0,B.index),n.viewTo=B.lineN):Ci(e)}else{var K=Gn(e,t,t,-1),Y=Gn(e,i,i+r,1);K&&Y?(n.view=n.view.slice(0,K.index).concat(wr(e,K.lineN,Y.lineN)).concat(n.view.slice(Y.index)),n.viewTo+=r):Ci(e)}var J=n.externalMeasured;J&&(i<J.lineN?J.lineN+=r:t<J.lineN+J.size&&(n.externalMeasured=null))}function Ti(e,t,i){e.curOp.viewChanged=!0;var r=e.display,n=e.display.externalMeasured;if(n&&t>=n.lineN&&t<n.lineN+n.size&&(r.externalMeasured=null),t<r.viewFrom||t>=r.viewTo)return;var E=r.view[Bi(e,t)];if(E.node==null)return;var B=E.changes||(E.changes=[]);pe(B,i)==-1&&B.push(i)}function Ci(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Gn(e,t,i,r){var n=Bi(e,t),E,B=e.display.view;if(!nr||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var K=e.display.viewFrom,Y=0;Y<n;Y++)K+=B[Y].size;if(K!=t){if(r>0){if(n==B.length-1)return null;E=K+B[n].size-t,n++}else E=K-t;t+=E,i+=E}for(;cn(e.doc,i)!=i;){if(n==(r<0?0:B.length-1))return null;i+=r*B[n-(r<0?1:0)].size,n+=r}return{index:n,lineN:i}}function Vs(e,t,i){var r=e.display,n=r.view;n.length==0||t>=r.viewTo||i<=r.viewFrom?(r.view=wr(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=wr(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(Bi(e,t))),r.viewFrom=t,r.viewTo<i?r.view=r.view.concat(wr(e,r.viewTo,i)):r.viewTo>i&&(r.view=r.view.slice(0,Bi(e,i)))),r.viewTo=i}function po(e){for(var t=e.display.view,i=0,r=0;r<t.length;r++){var n=t[r];!n.hidden&&(!n.node||n.changes)&&++i}return i}function bn(e){e.display.input.showSelection(e.display.input.prepareSelection())}function mo(e,t){t===void 0&&(t=!0);for(var i=e.doc,r={},n=r.cursors=document.createDocumentFragment(),E=r.selection=document.createDocumentFragment(),B=0;B<i.sel.ranges.length;B++){if(!t&&B==i.sel.primIndex)continue;var K=i.sel.ranges[B];if(K.from().line>=e.display.viewTo||K.to().line<e.display.viewFrom)continue;var Y=K.empty();(Y||e.options.showCursorWhenSelecting)&&go(e,K.head,n),Y||Xs(e,K,E)}return r}function go(e,t,i){var r=Zr(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),n=i.appendChild(o("div","\xA0","CodeMirror-cursor"));if(n.style.left=r.left+"px",n.style.top=r.top+"px",n.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var E=i.appendChild(o("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));E.style.display="",E.style.left=r.other.left+"px",E.style.top=r.other.top+"px",E.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function zn(e,t){return e.top-t.top||e.left-t.left}function Xs(e,t,i){var r=e.display,n=e.doc,E=document.createDocumentFragment(),B=qa(e.display),K=B.left,Y=Math.max(r.sizerWidth,Mi(e)-r.sizer.offsetLeft)-B.right,J=n.direction=="ltr";function se(Ye,st,Et,gt){st<0&&(st=0),st=Math.round(st),gt=Math.round(gt),E.appendChild(o("div",null,"CodeMirror-selected","position: absolute; left: "+Ye+`px;
|
|
top: `+st+"px; width: "+(Et==null?Y-Ye:Et)+`px;
|
|
height: `+(gt-st)+"px"))}function he(Ye,st,Et){var gt=ht(n,Ye),At=gt.text.length,zt,lr;function Yt(er,_r){return ma(e,Ue(Ye,er),"div",gt,_r)}function Mr(er,_r,fr){var ir=co(e,gt,null,er),tr=_r=="ltr"==(fr=="after")?"left":"right",$t=fr=="after"?ir.begin:ir.end-(/\s/.test(gt.text.charAt(ir.end-1))?2:1);return Yt($t,tr)[tr]}var kr=et(gt,n.direction);return it(kr,st||0,Et==null?At:Et,function(er,_r,fr,ir){var tr=fr=="ltr",$t=Yt(er,tr?"left":"right"),Dr=Yt(_r-1,tr?"right":"left"),un=st==null&&er==0,Di=Et==null&&_r==At,xr=ir==0,ai=!kr||ir==kr.length-1;if(Dr.top-$t.top<=3){var ur=(J?un:Di)&&xr,Va=(J?Di:un)&&ai,di=ur?K:(tr?$t:Dr).left,Hi=Va?Y:(tr?Dr:$t).right;se(di,$t.top,Hi-di,$t.bottom)}else{var Gi,Tr,hn,Xa;tr?(Gi=J&&un&&xr?K:$t.left,Tr=J?Y:Mr(er,fr,"before"),hn=J?K:Mr(_r,fr,"after"),Xa=J&&Di&&ai?Y:Dr.right):(Gi=J?Mr(er,fr,"before"):K,Tr=!J&&un&&xr?Y:$t.right,hn=!J&&Di&&ai?K:Dr.left,Xa=J?Mr(_r,fr,"after"):Y),se(Gi,$t.top,Tr-Gi,$t.bottom),$t.bottom<Dr.top&&se(K,$t.bottom,null,Dr.top),se(hn,Dr.top,Xa-hn,Dr.bottom)}(!zt||zn($t,zt)<0)&&(zt=$t),zn(Dr,zt)<0&&(zt=Dr),(!lr||zn($t,lr)<0)&&(lr=$t),zn(Dr,lr)<0&&(lr=Dr)}),{start:zt,end:lr}}var be=t.from(),ye=t.to();if(be.line==ye.line)he(be.line,be.ch,ye.ch);else{var ke=ht(n,be.line),Ne=ht(n,ye.line),je=Er(ke)==Er(Ne),Xe=he(be.line,be.ch,je?ke.text.length+1:null).end,nt=he(ye.line,je?0:null,ye.ch).start;je&&(Xe.top<nt.top-2?(se(Xe.right,Xe.top,null,Xe.bottom),se(K,nt.top,nt.left,nt.bottom)):se(Xe.right,Xe.top,nt.left-Xe.right,Xe.bottom)),Xe.bottom<nt.top&&se(K,Xe.bottom,null,nt.top)}i.appendChild(E)}function Sa(e){if(!e.state.focused)return;var t=e.display;clearInterval(t.blinker);var i=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){e.hasFocus()||Zi(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function vo(e){e.state.focused||(e.display.input.focus(),Ta(e))}function yo(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Zi(e))},100)}function Ta(e,t){if(e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),e.options.readOnly=="nocursor")return;e.state.focused||(Te(e,"focus",e,t),e.state.focused=!0,G(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),P&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Sa(e)}function Zi(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(Te(e,"blur",e,t),e.state.focused=!1,f(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Kn(e){for(var t=e.display,i=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var n=t.view[r],E=e.options.lineWrapping,B=void 0,K=0;if(n.hidden)continue;if(H&&F<8){var Y=n.node.offsetTop+n.node.offsetHeight;B=Y-i,i=Y}else{var J=n.node.getBoundingClientRect();B=J.bottom-J.top,!E&&n.text.firstChild&&(K=n.text.firstChild.getBoundingClientRect().right-J.left-1)}var se=n.line.height-B;if((se>.005||se<-.005)&&(mr(n.line,B),bo(n.line),n.rest))for(var he=0;he<n.rest.length;he++)bo(n.rest[he]);if(K>e.display.sizerWidth){var be=Math.ceil(K/$i(e.display));be>e.display.maxLineLength&&(e.display.maxLineLength=be,e.display.maxLine=n.line,e.display.maxLineChanged=!0)}}}function bo(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t){var i=e.widgets[t],r=i.node.parentNode;r&&(i.height=r.offsetHeight)}}function Vn(e,t,i){var r=i&&i.top!=null?Math.max(0,i.top):e.scroller.scrollTop;r=Math.floor(r-Wn(e));var n=i&&i.bottom!=null?i.bottom:r+e.wrapper.clientHeight,E=Fr(t,r),B=Fr(t,n);if(i&&i.ensure){var K=i.ensure.from.line,Y=i.ensure.to.line;K<E?(E=K,B=Fr(t,$r(ht(t,K))+e.wrapper.clientHeight)):Math.min(Y,t.lastLine())>=B&&(E=Fr(t,$r(ht(t,Y))-e.wrapper.clientHeight),B=Y)}return{from:E,to:Math.max(B,E+1)}}function Ys(e,t){if(Le(e,"scrollCursorIntoView"))return;var i=e.display,r=i.sizer.getBoundingClientRect(),n=null;if(t.top+r.top<0?n=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(n=!1),n!=null&&!w){var E=o("div","\u200B",null,`position: absolute;
|
|
top: `+(t.top-i.viewOffset-Wn(e.display))+`px;
|
|
height: `+(t.bottom-t.top+ii(e)+i.barHeight)+`px;
|
|
left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(E),E.scrollIntoView(n),e.display.lineSpace.removeChild(E)}}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 E=0;E<5;E++){var B=!1,K=Zr(e,t),Y=!i||i==t?K:Zr(e,i);n={left:Math.min(K.left,Y.left),top:Math.min(K.top,Y.top)-r,right:Math.max(K.left,Y.left),bottom:Math.max(K.bottom,Y.bottom)+r};var J=Ca(e,n),se=e.doc.scrollTop,he=e.doc.scrollLeft;if(J.scrollTop!=null&&(En(e,J.scrollTop),Math.abs(e.doc.scrollTop-se)>1&&(B=!0)),J.scrollLeft!=null&&(Fi(e,J.scrollLeft),Math.abs(e.doc.scrollLeft-he)>1&&(B=!0)),!B)break}return n}function Zs(e,t){var i=Ca(e,t);i.scrollTop!=null&&En(e,i.scrollTop),i.scrollLeft!=null&&Fi(e,i.scrollLeft)}function Ca(e,t){var i=e.display,r=Yi(e.display);t.top<0&&(t.top=0);var n=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,E=ca(e),B={};t.bottom-t.top>E&&(t.bottom=t.top+E);var K=e.doc.height+da(i),Y=t.top<r,J=t.bottom>K-r;if(t.top<n)B.scrollTop=Y?0:t.top;else if(t.bottom>n+E){var se=Math.min(t.top,(J?K:t.bottom)-E);se!=n&&(B.scrollTop=se)}var he=e.options.fixedGutter?0:i.gutters.offsetWidth,be=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-he,ye=Mi(e)-i.gutters.offsetWidth,ke=t.right-t.left>ye;return ke&&(t.right=t.left+ye),t.left<10?B.scrollLeft=0:t.left<be?B.scrollLeft=Math.max(0,t.left+he-(ke?0:10)):t.right>ye+be-3&&(B.scrollLeft=t.right+(ke?0:10)-ye),B}function wa(e,t){if(t==null)return;Xn(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function Ji(e){Xn(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function xn(e,t,i){(t!=null||i!=null)&&Xn(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function Js(e,t){Xn(e),e.curOp.scrollToPos=t}function Xn(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=uo(e,t.from),r=uo(e,t.to);xo(e,i,r,t.margin)}}function xo(e,t,i,r){var n=Ca(e,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-r,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+r});xn(e,n.scrollLeft,n.scrollTop)}function En(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;_||La(e,{top:t}),Eo(e,t,!0),_&&La(e),Cn(e,100)}function Eo(e,t,i){if(t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!i)return;e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t)}function Fi(e,t,i,r){if(t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(i?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)return;e.doc.scrollLeft=t,Ao(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function Sn(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+da(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?i:0,docHeight:r,scrollHeight:r+ii(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var Ui=function(e,t,i){this.cm=i;var r=this.vert=o("div",[o("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=o("div",[o("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),we(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),we(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,H&&F<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Ui.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(i){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var n=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+n)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=i?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var E=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+E)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(r==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:i?r:0,bottom:t?r:0}},Ui.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Ui.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Ui.prototype.zeroWidthHack=function(){var e=l&&!L?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new ae,this.disableVert=new ae},Ui.prototype.enableZeroWidthBar=function(e,t,i){e.style.pointerEvents="auto";function r(){var n=e.getBoundingClientRect(),E=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);E!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},Ui.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Tn=function(){};Tn.prototype.update=function(){return{bottom:0,right:0}},Tn.prototype.setScrollLeft=function(){},Tn.prototype.setScrollTop=function(){},Tn.prototype.clear=function(){};function Qi(e,t){t||(t=Sn(e));var i=e.display.barWidth,r=e.display.barHeight;So(e,t);for(var n=0;n<4&&i!=e.display.barWidth||r!=e.display.barHeight;n++)i!=e.display.barWidth&&e.options.lineWrapping&&Kn(e),So(e,Sn(e)),i=e.display.barWidth,r=e.display.barHeight}function So(e,t){var i=e.display,r=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=r.right)+"px",i.sizer.style.paddingBottom=(i.barHeight=r.bottom)+"px",i.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=r.bottom+"px",i.scrollbarFiller.style.width=r.right+"px"):i.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=r.bottom+"px",i.gutterFiller.style.width=t.gutterWidth+"px"):i.gutterFiller.style.display=""}var To={native:Ui,null:Tn};function Co(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&f(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new To[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),we(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,i){i=="horizontal"?Fi(e,t):En(e,t)},e),e.display.scrollbars.addClass&&G(e.display.wrapper,e.display.scrollbars.addClass)}var Qs=0;function ji(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Qs},zr(e.curOp)}function Wi(e){var t=e.curOp;t&&Rs(t,function(i){for(var r=0;r<i.ops.length;r++)i.ops[r].cm.curOp=null;qs(i)})}function qs(e){for(var t=e.ops,i=0;i<t.length;i++)el(t[i]);for(var r=0;r<t.length;r++)tl(t[r]);for(var n=0;n<t.length;n++)rl(t[n]);for(var E=0;E<t.length;E++)il(t[E]);for(var B=0;B<t.length;B++)nl(t[B])}function el(e){var t=e.cm,i=t.display;ol(t),e.updateMaxLine&&jn(t),e.mustUpdate=e.viewChanged||e.forceUpdate||e.scrollTop!=null||e.scrollToPos&&(e.scrollToPos.from.line<i.viewFrom||e.scrollToPos.to.line>=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Yn(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function tl(e){e.updatedDisplay=e.mustUpdate&&Aa(e.cm,e.update)}function rl(e){var t=e.cm,i=t.display;e.updatedDisplay&&Kn(t),e.barMeasure=Sn(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=to(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+ii(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-Mi(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=i.input.prepareSelection())}function il(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Fi(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var i=e.focus&&e.focus==I();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,i),(e.updatedDisplay||e.startHeight!=t.doc.height)&&Qi(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,s(r,e.scrollToPos.from),s(r,e.scrollToPos.to),e.scrollToPos.margin);Ys(t,n)}var E=e.maybeHiddenMarkers,B=e.maybeUnhiddenMarkers;if(E)for(var K=0;K<E.length;++K)E[K].lines.length||Te(E[K],"hide");if(B)for(var Y=0;Y<B.length;++Y)B[Y].lines.length&&Te(B[Y],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Te(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Pr(e,t){if(e.curOp)return t();ji(e);try{return t()}finally{Wi(e)}}function or(e,t){return function(){if(e.curOp)return t.apply(e,arguments);ji(e);try{return t.apply(e,arguments)}finally{Wi(e)}}}function Sr(e){return function(){if(this.curOp)return e.apply(this,arguments);ji(this);try{return e.apply(this,arguments)}finally{Wi(this)}}}function sr(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);ji(t);try{return e.apply(this,arguments)}finally{Wi(t)}}}function Cn(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,z(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var i=+new Date+e.options.workTime,r=Ke(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(E){if(r.line>=e.display.viewFrom){var B=E.styles,K=E.text.length>e.options.maxHighlightLength?Br(t.mode,r.state):null,Y=ce(e,E,r,!0);K&&(r.state=K),E.styles=Y.styles;var J=E.styleClasses,se=Y.classes;se?E.styleClasses=se:J&&(E.styleClasses=null);for(var he=!B||B.length!=E.styles.length||J!=se&&(!J||!se||J.bgClass!=se.bgClass||J.textClass!=se.textClass),be=0;!he&&be<B.length;++be)he=B[be]!=E.styles[be];he&&n.push(r.line),E.stateAfter=r.save(),r.nextLine()}else E.text.length<=e.options.maxHighlightLength&&dt(e,E.text,r),E.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>i)return Cn(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),n.length&&Pr(e,function(){for(var E=0;E<n.length;E++)Ti(e,n[E],"text")})}var Yn=function(e,t,i){var r=e.display;this.viewport=t,this.visible=Vn(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=Mi(e),this.force=i,this.dims=ba(e),this.events=[]};Yn.prototype.signal=function(e,t){le(e,t)&&this.events.push(arguments)},Yn.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Te.apply(null,this.events[e])};function ol(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=ii(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=ii(e)+"px",t.scrollbarsClipped=!0)}function sl(e){if(e.hasFocus())return null;var t=I();if(!t||!T(e.display.lineDiv,t))return null;var i={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&T(e.display.lineDiv,r.anchorNode)&&(i.anchorNode=r.anchorNode,i.anchorOffset=r.anchorOffset,i.focusNode=r.focusNode,i.focusOffset=r.focusOffset)}return i}function ll(e){if(!e||!e.activeElt||e.activeElt==I())return;if(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&T(document.body,e.anchorNode)&&T(document.body,e.focusNode)){var t=window.getSelection(),i=document.createRange();i.setEnd(e.anchorNode,e.anchorOffset),i.collapse(!1),t.removeAllRanges(),t.addRange(i),t.extend(e.focusNode,e.focusOffset)}}function Aa(e,t){var i=e.display,r=e.doc;if(t.editorIsHidden)return Ci(e),!1;if(!t.force&&t.visible.from>=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&po(e)==0)return!1;Lo(e)&&(Ci(e),t.dims=ba(e));var n=r.first+r.size,E=Math.max(t.visible.from-e.options.viewportMargin,r.first),B=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFrom<E&&E-i.viewFrom<20&&(E=Math.max(r.first,i.viewFrom)),i.viewTo>B&&i.viewTo-B<20&&(B=Math.min(n,i.viewTo)),nr&&(E=cn(e.doc,E),B=Si(e.doc,B));var K=E!=i.viewFrom||B!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,E,B),i.viewOffset=$r(ht(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 J=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(J),p(i.cursorDiv),p(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,K&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,Cn(e,400)),i.updateLineNumbers=null,!0}function wo(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==Mi(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+da(e.display)-ca(e),i.top)}),t.visible=Vn(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Vn(e.display,e.doc,i));if(!Aa(e,t))break;Kn(e);var n=Sn(e);bn(e),Qi(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 La(e,t){var i=new Yn(e,t);if(Aa(e,i)){Kn(e),wo(e,i);var r=Sn(e);bn(e),Qi(e,r),_a(e,r),i.finish()}}function ul(e,t,i){var r=e.display,n=e.options.lineNumbers,E=r.lineDiv,B=E.firstChild;function K(ke){var Ne=ke.nextSibling;return P&&l&&e.display.currentWheelTarget==ke?ke.style.display="none":ke.parentNode.removeChild(ke),Ne}for(var Y=r.view,J=r.viewFrom,se=0;se<Y.length;se++){var he=Y[se];if(!he.hidden)if(!he.node||he.node.parentNode!=E){var be=Ns(e,he,J,i);E.insertBefore(be,B)}else{for(;B!=he.node;)B=K(B);var ye=n&&t!=null&&t<=J&&he.lineNumber;he.changes&&(pe(he.changes,"gutter")>-1&&(ye=!1),Ya(e,he,J,i)),ye&&(p(he.lineNumber),he.lineNumber.appendChild(document.createTextNode(fi(e.options,J)))),B=he.node.nextSibling}J+=he.size}for(;B;)B=K(B)}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+ii(e)+"px"}function Ao(e){var t=e.display,i=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;for(var r=xa(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,E=r+"px",B=0;B<i.length;B++)if(!i[B].hidden){e.options.fixedGutter&&(i[B].gutter&&(i[B].gutter.style.left=E),i[B].gutterBackground&&(i[B].gutterBackground.style.left=E));var K=i[B].alignable;if(K)for(var Y=0;Y<K.length;Y++)K[Y].style.left=E}e.options.fixedGutter&&(t.gutters.style.left=r+n+"px")}function Lo(e){if(!e.options.lineNumbers)return!1;var t=e.doc,i=fi(e.options,t.first+t.size-1),r=e.display;if(i.length!=r.lineNumChars){var n=r.measure.appendChild(o("div",[o("div",i)],"CodeMirror-linenumber CodeMirror-gutter-elt")),E=n.firstChild.offsetWidth,B=n.offsetWidth-E;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(E,r.lineGutter.offsetWidth-B)+1,r.lineNumWidth=r.lineNumInnerWidth+B,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 E=e[n],B=null;if(typeof E!="string"&&(B=E.style,E=E.className),E=="CodeMirror-linenumbers")if(t)r=!0;else continue;i.push({className:E,style:B})}return t&&!r&&i.push({className:"CodeMirror-linenumbers",style:null}),i}function ko(e){var t=e.gutters,i=e.gutterSpecs;p(t),e.lineGutter=null;for(var r=0;r<i.length;++r){var n=i[r],E=n.className,B=n.style,K=t.appendChild(o("div",null,"CodeMirror-gutter "+E));B&&(K.style.cssText=B),E=="CodeMirror-linenumbers"&&(e.lineGutter=K,K.style.width=(e.lineNumWidth||1)+"px")}t.style.display=i.length?"":"none",ka(e)}function wn(e){ko(e.display),Ar(e),Ao(e)}function hl(e,t,i,r){var n=this;this.input=i,n.scrollbarFiller=o("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=o("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=S("div",null,"CodeMirror-code"),n.selectionDiv=o("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=o("div",null,"CodeMirror-cursors"),n.measure=o("div",null,"CodeMirror-measure"),n.lineMeasure=o("div",null,"CodeMirror-measure"),n.lineSpace=S("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var E=S("div",[n.lineSpace],"CodeMirror-lines");n.mover=o("div",[E],null,"position: relative"),n.sizer=o("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=o("div",null,null,"position: absolute; height: "+ve+"px; width: 1px;"),n.gutters=o("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=o("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=o("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),H&&F<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!P&&!(_&&a)&&(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,n.gutterSpecs=Da(r.gutters,r.lineNumbers),ko(n),i.init(n)}var $n=0,jr=null;H?jr=-.53:_?jr=15:b?jr=-.7:D&&(jr=-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*=jr,t.y*=jr,t}function Do(e,t){var i=_o(t),r=i.x,n=i.y,E=e.display,B=E.scroller,K=B.scrollWidth>B.clientWidth,Y=B.scrollHeight>B.clientHeight;if(!(r&&K||n&&Y))return;if(n&&l&&P){e:for(var J=t.target,se=E.view;J!=B;J=J.parentNode)for(var he=0;he<se.length;he++)if(se[he].node==J){e.display.currentWheelTarget=J;break e}}if(r&&!_&&!A&&jr!=null){n&&Y&&En(e,Math.max(0,B.scrollTop+n*jr)),Fi(e,Math.max(0,B.scrollLeft+r*jr)),(!n||n&&Y)&&q(t),E.wheelStartX=null;return}if(n&&jr!=null){var be=n*jr,ye=e.doc.scrollTop,ke=ye+E.wrapper.clientHeight;be<0?ye=Math.max(0,ye+be-50):ke=Math.min(e.doc.height,ke+be+50),La(e,{top:ye,bottom:ke})}$n<20&&(E.wheelStartX==null?(E.wheelStartX=B.scrollLeft,E.wheelStartY=B.scrollTop,E.wheelDX=r,E.wheelDY=n,setTimeout(function(){if(E.wheelStartX==null)return;var Ne=B.scrollLeft-E.wheelStartX,je=B.scrollTop-E.wheelStartY,Xe=je&&E.wheelDY&&je/E.wheelDY||Ne&&E.wheelDX&&Ne/E.wheelDX;if(E.wheelStartX=E.wheelStartY=null,!Xe)return;jr=(jr*$n+Xe)/($n+1),++$n},200)):(E.wheelDX+=r,E.wheelDY+=n))}var Wr=function(e,t){this.ranges=e,this.primIndex=t};Wr.prototype.primary=function(){return this.ranges[this.primIndex]},Wr.prototype.equals=function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var i=this.ranges[t],r=e.ranges[t];if(!pi(i.anchor,r.anchor)||!pi(i.head,r.head))return!1}return!0},Wr.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new jt(mi(this.ranges[t].anchor),mi(this.ranges[t].head));return new Wr(e,this.primIndex)},Wr.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},Wr.prototype.contains=function(e,t){t||(t=e);for(var i=0;i<this.ranges.length;i++){var r=this.ranges[i];if(St(t,r.from())>=0&&St(e,r.to())<=0)return i}return-1};var jt=function(e,t){this.anchor=e,this.head=t};jt.prototype.from=function(){return vi(this.anchor,this.head)},jt.prototype.to=function(){return gi(this.anchor,this.head)},jt.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function Jr(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(be,ye){return St(be.from(),ye.from())}),i=pe(t,n);for(var E=1;E<t.length;E++){var B=t[E],K=t[E-1],Y=St(K.to(),B.from());if(r&&!B.empty()?Y>0:Y>=0){var J=vi(K.from(),B.from()),se=gi(K.to(),B.to()),he=K.empty()?B.from()==B.head:K.from()==K.head;E<=i&&--i,t.splice(--E,2,new jt(he?se:J,he?J:se))}}return new Wr(t,i)}function wi(e,t){return new Wr([new jt(e,t||e)],0)}function Ai(e){return e.text?Ue(e.from.line+e.text.length-1,Re(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Ro(e,t){if(St(e,t.from)<0)return e;if(St(e,t.to)<=0)return Ai(t);var i=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Ai(t).ch-t.to.ch),Ue(i,r)}function Ra(e,t){for(var i=[],r=0;r<e.sel.ranges.length;r++){var n=e.sel.ranges[r];i.push(new jt(Ro(n.anchor,t),Ro(n.head,t)))}return Jr(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),E=n,B=0;B<t.length;B++){var K=t[B],Y=Oo(K.from,n,E),J=Oo(Ai(K),n,E);if(n=K.to,E=J,i=="around"){var se=e.sel.ranges[B],he=St(se.head,se.anchor)<0;r[B]=new jt(he?J:Y,he?Y:J)}else r[B]=new jt(Y,Y)}return new Wr(r,e.sel.primIndex)}function Oa(e){e.doc.mode=Nr(e.options,e.doc.modeOption),An(e)}function An(e){e.doc.iter(function(t){t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null)}),e.doc.modeFrontier=e.doc.highlightFrontier=e.doc.first,Cn(e,100),e.state.modeGen++,e.curOp&&Ar(e)}function Po(e,t){return t.from.ch==0&&t.to.ch==0&&Re(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Pa(e,t,i,r){function n(nt){return i?i[nt]:null}function E(nt,Ye,st){ua(nt,Ye,st,r),cr(nt,"change",nt,t)}function B(nt,Ye){for(var st=[],Et=nt;Et<Ye;++Et)st.push(new Pi(J[Et],n(Et),r));return st}var K=t.from,Y=t.to,J=t.text,se=ht(e,K.line),he=ht(e,Y.line),be=Re(J),ye=n(J.length-1),ke=Y.line-K.line;if(t.full)e.insert(0,B(0,J.length)),e.remove(J.length,e.size-J.length);else if(Po(e,t)){var Ne=B(0,J.length-1);E(he,he.text,ye),ke&&e.remove(K.line,ke),Ne.length&&e.insert(K.line,Ne)}else if(se==he)if(J.length==1)E(se,se.text.slice(0,K.ch)+be+se.text.slice(Y.ch),ye);else{var je=B(1,J.length-1);je.push(new Pi(be+se.text.slice(Y.ch),ye,r)),E(se,se.text.slice(0,K.ch)+J[0],n(0)),e.insert(K.line+1,je)}else if(J.length==1)E(se,se.text.slice(0,K.ch)+J[0]+he.text.slice(Y.ch),n(0)),e.remove(K.line+1,ke);else{E(se,se.text.slice(0,K.ch)+J[0],n(0)),E(he,be+he.text.slice(Y.ch),ye);var Xe=B(1,J.length-1);ke>1&&e.remove(K.line+1,ke-1),e.insert(K.line+1,Xe)}cr(e,"change",e,t)}function Li(e,t,i){function r(n,E,B){if(n.linked)for(var K=0;K<n.linked.length;++K){var Y=n.linked[K];if(Y.doc==E)continue;var J=B&&Y.sharedHist;if(i&&!J)continue;t(Y.doc,J),r(Y.doc,n,J)}}r(e,null,!0)}function Mo(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,Ea(e),Oa(e),Io(e),e.options.lineWrapping||jn(e),e.options.mode=t.modeOption,Ar(e)}function Io(e){(e.doc.direction=="rtl"?G:f)(e.display.lineDiv,"CodeMirror-rtl")}function fl(e){Pr(e,function(){Io(e),Ar(e)})}function Zn(e){this.done=[],this.undone=[],this.undoDepth=Infinity,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Ma(e,t){var i={from:mi(t.from),to:Ai(t),text:Hr(e,t.from,t.to)};return Fo(e,i,t.from.line,t.to.line+1),Li(e,function(r){return Fo(r,i,t.from.line,t.to.line+1)},!0),i}function No(e){for(;e.length;){var t=Re(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return No(e.done),Re(e.done);if(e.done.length&&!Re(e.done).ranges)return Re(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),Re(e.done)}function Bo(e,t,i,r){var n=e.history;n.undone.length=0;var E=+new Date,B,K;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>E-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(B=pl(n,n.lastOp==r)))K=Re(B.changes),St(t.from,t.to)==0&&St(t.from,K.to)==0?K.to=Ai(t):B.changes.push(Ma(e,t));else{var Y=Re(n.done);for((!Y||!Y.ranges)&&Jn(e.sel,n.done),B={changes:[Ma(e,t)],generation:n.generation},n.done.push(B);n.done.length>n.undoDepth;)n.done.shift(),n.done[0].ranges||n.done.shift()}n.done.push(i),n.generation=++n.maxGeneration,n.lastModTime=n.lastSelTime=E,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,K||Te(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,E=r&&r.origin;i==n.lastSelOp||E&&n.lastSelOrigin==E&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==E||ml(e,E,Re(n.done),t))?n.done[n.done.length-1]=t:Jn(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=E,n.lastSelOp=i,r&&r.clearRedo!==!1&&No(n.undone)}function Jn(e,t){var i=Re(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Fo(e,t,i,r){var n=t["spans_"+e.id],E=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),function(B){B.markedSpans&&((n||(n=t["spans_"+e.id]={}))[E]=B.markedSpans),++E})}function vl(e){if(!e)return null;for(var t,i=0;i<e.length;++i)e[i].marker.explicitlyCleared?t||(t=e.slice(0,i)):t&&t.push(e[i]);return t?t.length?t:null:e}function yl(e,t){var i=t["spans_"+e.id];if(!i)return null;for(var r=[],n=0;n<t.text.length;++n)r.push(vl(i[n]));return r}function Uo(e,t){var i=yl(e,t),r=Yr(e,t);if(!i)return r;if(!r)return i;for(var n=0;n<i.length;++n){var E=i[n],B=r[n];if(E&&B){e:for(var K=0;K<B.length;++K){for(var Y=B[K],J=0;J<E.length;++J)if(E[J].marker==Y.marker)continue e;E.push(Y)}}else B&&(i[n]=B)}return i}function qi(e,t,i){for(var r=[],n=0;n<e.length;++n){var E=e[n];if(E.ranges){r.push(i?Wr.prototype.deepCopy.call(E):E);continue}var B=E.changes,K=[];r.push({changes:K});for(var Y=0;Y<B.length;++Y){var J=B[Y],se=void 0;if(K.push({from:J.from,to:J.to,text:J.text}),t)for(var he in J)(se=he.match(/^spans_(\d+)$/))&&(pe(t,Number(se[1]))>-1&&(Re(K)[he]=J[he],delete J[he]))}}return r}function Ia(e,t,i,r){if(r){var n=e.anchor;if(i){var E=St(t,n)<0;E!=St(i,n)<0?(n=t,t=i):E!=St(t,i)<0&&(t=i)}return new jt(n,t)}else return new jt(i||t,t)}function Qn(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),br(e,new Wr([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),E=0;E<e.sel.ranges.length;E++)r[E]=Ia(e.sel.ranges[E],t[E],null,n);var B=Jr(e.cm,r,e.sel.primIndex);br(e,B,i)}function Na(e,t,i,r){var n=e.sel.ranges.slice(0);n[t]=i,br(e,Jr(e.cm,n,e.sel.primIndex),r)}function Wo(e,t,i,r){br(e,wi(t,i),r)}function bl(e,t,i){var r={ranges:t.ranges,update:function(n){this.ranges=[];for(var E=0;E<n.length;E++)this.ranges[E]=new jt(s(e,n[E].anchor),s(e,n[E].head))},origin:i&&i.origin};return Te(e,"beforeSelectionChange",e,r),e.cm&&Te(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?Jr(e.cm,r.ranges,r.ranges.length-1):t}function Ho(e,t,i){var r=e.history.done,n=Re(r);n&&n.ranges?(r[r.length-1]=t,qn(e,t,i)):br(e,t,i)}function br(e,t,i){qn(e,t,i),gl(e,e.sel,e.cm?e.cm.curOp.id:NaN,i)}function qn(e,t,i){(le(e,"beforeSelectionChange")||e.cm&&le(e.cm,"beforeSelectionChange"))&&(t=bl(e,t,i));var r=i&&i.bias||(St(t.primary().head,e.sel.primary().head)<0?-1:1);Go(e,Ko(e,t,r,!0)),!(i&&i.scroll===!1)&&e.cm&&Ji(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,fe(e.cm)),cr(e,"cursorActivity",e)}function zo(e){Go(e,Ko(e,e.sel,null,!1))}function Ko(e,t,i,r){for(var n,E=0;E<t.ranges.length;E++){var B=t.ranges[E],K=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[E],Y=ea(e,B.anchor,K&&K.anchor,i,r),J=ea(e,B.head,K&&K.head,i,r);(n||Y!=B.anchor||J!=B.head)&&(n||(n=t.ranges.slice(0,E)),n[E]=new jt(Y,J))}return n?Jr(e.cm,n,t.primIndex):t}function en(e,t,i,r,n){var E=ht(e,t.line);if(E.markedSpans)for(var B=0;B<E.markedSpans.length;++B){var K=E.markedSpans[B],Y=K.marker,J="selectLeft"in Y?!Y.selectLeft:Y.inclusiveLeft,se="selectRight"in Y?!Y.selectRight:Y.inclusiveRight;if((K.from==null||(J?K.from<=t.ch:K.from<t.ch))&&(K.to==null||(se?K.to>=t.ch:K.to>t.ch))){if(n&&(Te(Y,"beforeCursorEnter"),Y.explicitlyCleared))if(E.markedSpans){--B;continue}else break;if(!Y.atomic)continue;if(i){var he=Y.find(r<0?1:-1),be=void 0;if((r<0?se:J)&&(he=Vo(e,he,-r,he&&he.line==t.line?E:null)),he&&he.line==t.line&&(be=St(he,i))&&(r<0?be<0:be>0))return en(e,he,t,r,n)}var ye=Y.find(r<0?-1:1);return(r<0?J:se)&&(ye=Vo(e,ye,r,ye.line==t.line?E:null)),ye?en(e,ye,t,r,n):null}}return t}function ea(e,t,i,r,n){var E=r||1,B=en(e,t,i,E,n)||!n&&en(e,t,i,E,!0)||en(e,t,i,-E,n)||!n&&en(e,t,i,-E,!0);return B||(e.cantEdit=!0,Ue(e.first,0))}function Vo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?s(e,Ue(t.line-1)):null:i>0&&t.ch==(r||ht(e,t.line)).text.length?t.line<e.first+e.size-1?Ue(t.line+1,0):null:new Ue(t.line,t.ch+i)}function Xo(e){e.setSelection(Ue(e.firstLine(),0),Ue(e.lastLine()),xe)}function Yo(e,t,i){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return r.canceled=!0}};return i&&(r.update=function(n,E,B,K){n&&(r.from=s(e,n)),E&&(r.to=s(e,E)),B&&(r.text=B),K!==void 0&&(r.origin=K)}),Te(e,"beforeChange",e,r),e.cm&&Te(e.cm,"beforeChange",e.cm,r),r.canceled?(e.cm&&(e.cm.curOp.updateInput=2),null):{from:r.from,to:r.to,text:r.text,origin:r.origin}}function tn(e,t,i){if(e.cm){if(!e.cm.curOp)return or(e.cm,tn)(e,t,i);if(e.cm.state.suppressEdits)return}if((le(e,"beforeChange")||e.cm&&le(e.cm,"beforeChange"))&&(t=Yo(e,t,!0),!t))return;var r=Ri&&!i&&bi(e,t.from,t.to);if(r)for(var n=r.length-1;n>=0;--n)$o(e,{from:r[n].from,to:r[n].to,text:n?[""]:t.text,origin:t.origin});else $o(e,t)}function $o(e,t){if(t.text.length==1&&t.text[0]==""&&St(t.from,t.to)==0)return;var i=Ra(e,t);Bo(e,t,i,e.cm?e.cm.curOp.id:NaN),Ln(e,t,i,Yr(e,t));var r=[];Li(e,function(n,E){!E&&pe(r,n.history)==-1&&(qo(n.history,t),r.push(n.history)),Ln(n,t,null,Yr(n,t))})}function ta(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(r&&!i)return;for(var n=e.history,E,B=e.sel,K=t=="undo"?n.done:n.undone,Y=t=="undo"?n.undone:n.done,J=0;J<K.length&&!(E=K[J],i?E.ranges&&!E.equals(e.sel):!E.ranges);J++);if(J==K.length)return;for(n.lastOrigin=n.lastSelOrigin=null;;)if(E=K.pop(),E.ranges){if(Jn(E,Y),i&&!E.equals(e.sel)){br(e,E,{clearRedo:!1});return}B=E}else if(r){K.push(E);return}else break;var se=[];Jn(B,Y),Y.push({changes:se,generation:n.generation}),n.generation=E.generation||++n.maxGeneration;for(var he=le(e,"beforeChange")||e.cm&&le(e.cm,"beforeChange"),be=function(Ne){var je=E.changes[Ne];if(je.origin=t,he&&!Yo(e,je,!1))return K.length=0,{};se.push(Ma(e,je));var Xe=Ne?Ra(e,je):Re(K);Ln(e,je,Xe,Uo(e,je)),!Ne&&e.cm&&e.cm.scrollIntoView({from:je.from,to:Ai(je)});var nt=[];Li(e,function(Ye,st){!st&&pe(nt,Ye.history)==-1&&(qo(Ye.history,je),nt.push(Ye.history)),Ln(Ye,je,null,Uo(Ye,je))})},ye=E.changes.length-1;ye>=0;--ye){var ke=be(ye);if(ke)return ke.v}}function Zo(e,t){if(t==0)return;if(e.first+=t,e.sel=new Wr(Ze(e.sel.ranges,function(n){return new jt(Ue(n.anchor.line+t,n.anchor.ch),Ue(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm){Ar(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;r<i.viewTo;r++)Ti(e.cm,r,"gutter")}}function Ln(e,t,i,r){if(e.cm&&!e.cm.curOp)return or(e.cm,Ln)(e,t,i,r);if(t.to.line<e.first){Zo(e,t.text.length-1-(t.to.line-t.from.line));return}if(t.from.line>e.lastLine())return;if(t.from.line<e.first){var n=t.text.length-1-(e.first-t.from.line);Zo(e,n),t={from:Ue(e.first,0),to:Ue(t.to.line+n,t.to.ch),text:[Re(t.text)],origin:t.origin}}var E=e.lastLine();t.to.line>E&&(t={from:t.from,to:Ue(E,ht(e,E).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Hr(e,t.from,t.to),i||(i=Ra(e,t)),e.cm?xl(e.cm,t,r):Pa(e,t,r),qn(e,i,xe),e.cantEdit&&ea(e,Ue(e.firstLine(),0))&&(e.cantEdit=!1)}function xl(e,t,i){var r=e.doc,n=e.display,E=t.from,B=t.to,K=!1,Y=E.line;e.options.lineWrapping||(Y=kt(Er(ht(r,E.line))),r.iter(Y,B.line+1,function(ye){if(ye==n.maxLine)return K=!0,!0})),r.sel.contains(t.from,t.to)>-1&&fe(e),Pa(r,t,i,fo(e)),e.options.lineWrapping||(r.iter(Y,E.line+t.text.length,function(ye){var ke=pn(ye);ke>n.maxLineLength&&(n.maxLine=ye,n.maxLineLength=ke,n.maxLineChanged=!0,K=!1)}),K&&(e.curOp.updateMaxLine=!0)),Xr(r,E.line),Cn(e,400);var J=t.text.length-(B.line-E.line)-1;t.full?Ar(e):E.line==B.line&&t.text.length==1&&!Po(e.doc,t)?Ti(e,E.line,"text"):Ar(e,E.line,B.line+1,J);var se=le(e,"changes"),he=le(e,"change");if(he||se){var be={from:E,to:B,text:t.text,removed:t.removed,origin:t.origin};he&&cr(e,"change",e,be),se&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(be)}e.display.selForContextMenu=null}function rn(e,t,i,r,n){var E;r||(r=i),St(r,i)<0&&(E=[r,i],i=E[0],r=E[1]),typeof t=="string"&&(t=e.splitLines(t)),tn(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 E=e[n],B=!0;if(E.ranges){E.copied||(E=e[n]=E.deepCopy(),E.copied=!0);for(var K=0;K<E.ranges.length;K++)Jo(E.ranges[K].anchor,t,i,r),Jo(E.ranges[K].head,t,i,r);continue}for(var Y=0;Y<E.changes.length;++Y){var J=E.changes[Y];if(i<J.from.line)J.from=Ue(J.from.line+r,J.from.ch),J.to=Ue(J.to.line+r,J.to.ch);else if(t<=J.to.line){B=!1;break}}B||(e.splice(0,n+1),n=0)}}function qo(e,t){var i=t.from.line,r=t.to.line,n=t.text.length-(r-i)-1;Qo(e.done,i,r,n),Qo(e.undone,i,r,n)}function kn(e,t,i,r){var n=t,E=t;return typeof t=="number"?E=ht(e,j(e,t)):n=kt(t),n==null?null:(r(E,n)&&e.cm&&Ti(e.cm,n,i),E)}function _n(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}_n.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,pt(n),cr(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 Dn(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}Dn.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 E=Math.min(t,n-e),B=r.height;if(r.removeInner(e,E),this.height-=B-r.height,n==E&&(this.children.splice(i--,1),r.parent=null),(t-=E)==0)break;e=0}else e-=n}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof _n))){var K=[];this.collapse(K),this.children=[new _n(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],E=n.chunkSize();if(e<=E){if(n.insertInner(e,t,i),n.lines&&n.lines.length>50){for(var B=n.lines.length%25+25,K=B;K<n.lines.length;){var Y=new _n(n.lines.slice(K,K+=25));n.height-=Y.height,this.children.splice(++r,0,Y),Y.parent=this}n.lines=n.lines.slice(0,B),this.maybeSpill()}break}e-=E}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),i=new Dn(t);if(e.parent){e.size-=i.size,e.height-=i.height;var n=pe(e.parent.children,e);e.parent.children.splice(n+1,0,i)}else{var r=new Dn(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],E=n.chunkSize();if(e<E){var B=Math.min(t,E-e);if(n.iterN(e,B,i))return!0;if((t-=B)==0)break;e=0}else e-=E}}};var Rn=function(e,t,i){if(i)for(var r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);this.doc=e,this.node=t};Rn.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,i=this.line,r=kt(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 E=vn(this);mr(i,Math.max(0,i.height-E)),e&&(Pr(e,function(){es(e,i,-E),Ti(e,r,"widget")}),cr(e,"lineWidgetCleared",e,this,r))},Rn.prototype.changed=function(){var e=this,t=this.height,i=this.doc.cm,r=this.line;this.height=null;var n=vn(this)-t;if(!n)return;ri(this.doc,r)||mr(r,r.height+n),i&&Pr(i,function(){i.curOp.forceUpdate=!0,es(i,r,n),cr(i,"lineWidgetChanged",i,e,kt(r))})},ue(Rn);function es(e,t,i){$r(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&wa(e,i)}function El(e,t,i,r){var n=new Rn(e,i,r),E=e.cm;return E&&n.noHScroll&&(E.display.alignWidgets=!0),kn(e,t,"widget",function(B){var K=B.widgets||(B.widgets=[]);if(n.insertAt==null?K.push(n):K.splice(Math.min(K.length-1,Math.max(0,n.insertAt)),0,n),n.line=B,E&&!ri(e,B)){var Y=$r(B)<e.scrollTop;mr(B,B.height+vn(n)),Y&&wa(E,n.height),E.curOp.forceUpdate=!0}return!0}),E&&cr(E,"lineWidgetAdded",E,n,typeof t=="number"?t:kt(t)),n}var ts=0,ki=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ts};ki.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;if(t&&ji(e),le(this,"clear")){var i=this.find();i&&cr(this,"clear",i.from,i.to)}for(var r=null,n=null,E=0;E<this.lines.length;++E){var B=this.lines[E],K=Or(B.markedSpans,this);e&&!this.collapsed?Ti(e,kt(B),"text"):e&&(K.to!=null&&(n=kt(B)),K.from!=null&&(r=kt(B))),B.markedSpans=Oi(B.markedSpans,K),K.from==null&&this.collapsed&&!ri(this.doc,B)&&e&&mr(B,Yi(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var Y=0;Y<this.lines.length;++Y){var J=Er(this.lines[Y]),se=pn(J);se>e.display.maxLineLength&&(e.display.maxLine=J,e.display.maxLineLength=se,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&Ar(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&&cr(e,"markerCleared",e,this,r,n),t&&Wi(e),this.parent&&this.parent.clear()},ki.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var i,r,n=0;n<this.lines.length;++n){var E=this.lines[n],B=Or(E.markedSpans,this);if(B.from!=null&&(i=Ue(t?E:kt(E),B.from),e==-1))return i;if(B.to!=null&&(r=Ue(t?E:kt(E),B.to),e==1))return r}return i&&{from:i,to:r}},ki.prototype.changed=function(){var e=this,t=this.find(-1,!0),i=this,r=this.doc.cm;if(!t||!r)return;Pr(r,function(){var n=t.line,E=kt(t.line),B=fa(r,E);if(B&&(no(B),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!ri(i.doc,n)&&i.height!=null){var K=i.height;i.height=null;var Y=vn(i)-K;Y&&mr(n,n.height+Y)}cr(r,"markerChanged",r,e)})},ki.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||pe(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},ki.prototype.detachLine=function(e){if(this.lines.splice(pe(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},ue(ki);function nn(e,t,i,r,n){if(r&&r.shared)return Sl(e,t,i,r,n);if(e.cm&&!e.cm.curOp)return or(e.cm,nn)(e,t,i,r,n);var E=new ki(e,n),B=St(t,i);if(r&&W(r,E,!1),B>0||B==0&&E.clearWhenEmpty!==!1)return E;if(E.replacedWith&&(E.collapsed=!0,E.widgetNode=S("span",[E.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||E.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(E.widgetNode.insertLeft=!0)),E.collapsed){if(ar(e,t.line,t,i,E)||t.line!=i.line&&ar(e,i.line,t,i,E))throw new Error("Inserting collapsed marker partially overlapping an existing one");oi()}E.addToHistory&&Bo(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var K=t.line,Y=e.cm,J;if(e.iter(K,i.line+1,function(he){Y&&E.collapsed&&!Y.options.lineWrapping&&Er(he)==Y.display.maxLine&&(J=!0),E.collapsed&&K!=t.line&&mr(he,0),yi(he,new si(E,K==t.line?t.ch:null,K==i.line?i.ch:null)),++K}),E.collapsed&&e.iter(t.line,i.line+1,function(he){ri(e,he)&&mr(he,0)}),E.clearOnEnter&&we(E,"beforeCursorEnter",function(){return E.clear()}),E.readOnly&&(Ur(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),E.collapsed&&(E.id=++ts,E.atomic=!0),Y){if(J&&(Y.curOp.updateMaxLine=!0),E.collapsed)Ar(Y,t.line,i.line+1);else if(E.className||E.startStyle||E.endStyle||E.css||E.attributes||E.title)for(var se=t.line;se<=i.line;se++)Ti(Y,se,"text");E.atomic&&zo(Y.doc),cr(Y,"markerAdded",Y,E)}return E}var On=function(e,t){this.markers=e,this.primary=t;for(var i=0;i<e.length;++i)e[i].parent=this};On.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();cr(this,"clear")},On.prototype.find=function(e,t){return this.primary.find(e,t)},ue(On);function Sl(e,t,i,r,n){r=W(r),r.shared=!1;var E=[nn(e,t,i,r,n)],B=E[0],K=r.widgetNode;return Li(e,function(Y){K&&(r.widgetNode=K.cloneNode(!0)),E.push(nn(Y,s(Y,t),s(Y,i),r,n));for(var J=0;J<Y.linked.length;++J)if(Y.linked[J].isParent)return;B=Re(E)}),new On(E,B)}function rs(e){return e.findMarks(Ue(e.first,0),e.clipPos(Ue(e.lastLine())),function(t){return t.parent})}function Tl(e,t){for(var i=0;i<t.length;i++){var r=t[i],n=r.find(),E=e.clipPos(n.from),B=e.clipPos(n.to);if(St(E,B)){var K=nn(e,E,B,r.primary,r.primary.type);r.markers.push(K),K.parent=r}}}function Cl(e){for(var t=function(r){var n=e[r],E=[n.primary.doc];Li(n.primary.doc,function(Y){return E.push(Y)});for(var B=0;B<n.markers.length;B++){var K=n.markers[B];pe(E,K.doc)==-1&&(K.parent=null,n.markers.splice(B--,1))}},i=0;i<e.length;i++)t(i)}var wl=0,Lr=function(e,t,i,r,n){if(!(this instanceof Lr))return new Lr(e,t,i,r,n);i==null&&(i=0),Dn.call(this,[new _n([new Pi("",null)])]),this.first=i,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=i;var E=Ue(i,0);this.sel=wi(E),this.history=new Zn(null),this.id=++wl,this.modeOption=t,this.lineSep=r,this.direction=n=="rtl"?"rtl":"ltr",this.extend=!1,typeof e=="string"&&(e=this.splitLines(e)),Pa(this,{from:E,to:E,text:e}),br(this,wi(E),xe)};Lr.prototype=$e(Dn.prototype,{constructor:Lr,iter:function(e,t,i){i?this.iterN(e-this.first,t-e,i):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var i=0,r=0;r<t.length;++r)i+=t[r].height;this.insertInner(e-this.first,t,i)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=ei(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:sr(function(e){var t=Ue(this.first,0),i=this.first+this.size-1;tn(this,{from:t,to:Ue(i,ht(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&xn(this.cm,0,0),br(this,wi(t),xe)}),replaceRange:function(e,t,i,r){t=s(this,t),i=i?s(this,i):t,rn(this,e,t,i,r)},getRange:function(e,t,i){var r=Hr(this,s(this,e),s(this,t));return i===!1?r:r.join(i||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(Vr(this,e))return ht(this,e)},getLineNumber:function(e){return kt(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=ht(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 s(this,e)},getCursor:function(e){var t=this.sel.primary(),i;return e==null||e=="head"?i=t.head:e=="anchor"?i=t.anchor:e=="end"||e=="to"||e===!1?i=t.to():i=t.from(),i},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:sr(function(e,t,i){Wo(this,s(this,typeof e=="number"?Ue(e,t||0):e),null,i)}),setSelection:sr(function(e,t,i){Wo(this,s(this,e),s(this,t||e),i)}),extendSelection:sr(function(e,t,i){Qn(this,s(this,e),t&&s(this,t),i)}),extendSelections:sr(function(e,t){jo(this,R(this,e),t)}),extendSelectionsBy:sr(function(e,t){var i=Ze(this.sel.ranges,e);jo(this,R(this,i),t)}),setSelections:sr(function(e,t,i){if(!e.length)return;for(var r=[],n=0;n<e.length;n++)r[n]=new jt(s(this,e[n].anchor),s(this,e[n].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),br(this,Jr(this.cm,r,t),i)}),addSelection:sr(function(e,t,i){var r=this.sel.ranges.slice(0);r.push(new jt(s(this,e),s(this,t||e))),br(this,Jr(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=Hr(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=Hr(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:sr(function(e,t,i){for(var r=[],n=this.sel,E=0;E<n.ranges.length;E++){var B=n.ranges[E];r[E]={from:B.from(),to:B.to(),text:this.splitLines(e[E]),origin:i}}for(var K=t&&t!="end"&&cl(this,r,t),Y=r.length-1;Y>=0;Y--)tn(this,r[Y]);K?Ho(this,K):this.cm&&Ji(this.cm)}),undo:sr(function(){ta(this,"undo")}),redo:sr(function(){ta(this,"redo")}),undoSelection:sr(function(){ta(this,"undo",!0)}),redoSelection:sr(function(){ta(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,i=0,r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++i;return{undo:t,redo:i}},clearHistory:function(){var e=this;this.history=new Zn(this.history.maxGeneration),Li(this,function(t){return t.history=e.history},!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:qi(this.history.done),undone:qi(this.history.undone)}},setHistory:function(e){var t=this.history=new Zn(this.history.maxGeneration);t.done=qi(e.done.slice(0),null,!0),t.undone=qi(e.undone.slice(0),null,!0)},setGutterMarker:sr(function(e,t,i){return kn(this,e,"gutter",function(r){var n=r.gutterMarkers||(r.gutterMarkers={});return n[t]=i,!i&&Ve(n)&&(r.gutterMarkers=null),!0})}),clearGutter:sr(function(e){var t=this;this.iter(function(i){i.gutterMarkers&&i.gutterMarkers[e]&&kn(t,i,"gutter",function(){return i.gutterMarkers[e]=null,Ve(i.gutterMarkers)&&(i.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if(typeof e=="number"){if(!Vr(this,e))return null;if(t=e,e=ht(this,e),!e)return null}else if(t=kt(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:sr(function(e,t,i){return kn(this,e,t=="gutter"?"gutter":"class",function(r){var n=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass";if(!r[n])r[n]=i;else{if(v(i).test(r[n]))return!1;r[n]+=" "+i}return!0})}),removeLineClass:sr(function(e,t,i){return kn(this,e,t=="gutter"?"gutter":"class",function(r){var n=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",E=r[n];if(E)if(i==null)r[n]=null;else{var B=E.match(v(i));if(!B)return!1;var K=B.index+B[0].length;r[n]=E.slice(0,B.index)+(!B.index||K==E.length?"":" ")+E.slice(K)||null}else return!1;return!0})}),addLineWidget:sr(function(e,t,i){return El(this,e,t,i)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,i){return nn(this,s(this,e),s(this,t),i,i&&i.type||"range")},setBookmark:function(e,t){var i={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return e=s(this,e),nn(this,e,e,i,"bookmark")},findMarksAt:function(e){e=s(this,e);var t=[],i=ht(this,e.line).markedSpans;if(i)for(var r=0;r<i.length;++r){var n=i[r];(n.from==null||n.from<=e.ch)&&(n.to==null||n.to>=e.ch)&&t.push(n.marker.parent||n.marker)}return t},findMarks:function(e,t,i){e=s(this,e),t=s(this,t);var r=[],n=e.line;return this.iter(e.line,t.line+1,function(E){var B=E.markedSpans;if(B)for(var K=0;K<B.length;K++){var Y=B[K];!(Y.to!=null&&n==e.line&&e.ch>=Y.to||Y.from==null&&n!=e.line||Y.from!=null&&n==t.line&&Y.from>=t.ch)&&(!i||i(Y.marker))&&r.push(Y.marker.parent||Y.marker)}++n}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var i=t.markedSpans;if(i)for(var r=0;r<i.length;++r)i[r].from!=null&&e.push(i[r].marker)}),e},posFromIndex:function(e){var t,i=this.first,r=this.lineSeparator().length;return this.iter(function(n){var E=n.text.length+r;if(E>e)return t=e,!0;e-=E,++i}),s(this,Ue(i,t))},indexFromPos:function(e){e=s(this,e);var t=e.ch;if(e.line<this.first||e.ch<0)return 0;var i=this.lineSeparator().length;return this.iter(this.first,e.line,function(r){t+=r.text.length+i}),t},copy:function(e){var t=new Lr(ei(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,i=this.first+this.size;e.from!=null&&e.from>t&&(t=e.from),e.to!=null&&e.to<i&&(i=e.to);var r=new Lr(ei(this,t,i),e.mode||this.modeOption,t,this.lineSep,this.direction);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Tl(r,rs(this)),r},unlinkDoc:function(e){if(e instanceof Vt&&(e=e.doc),this.linked)for(var t=0;t<this.linked.length;++t){var i=this.linked[t];if(i.doc!=e)continue;this.linked.splice(t,1),e.unlinkDoc(this),Cl(rs(this));break}if(e.history==this.history){var r=[e.id];Li(e,function(n){return r.push(n.id)},!0),e.history=new Zn(null),e.history.done=qi(this.history.done,r),e.history.undone=qi(this.history.undone,r)}},iterLinkedDocs:function(e){Li(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):Tt(e)},lineSeparator:function(){return this.lineSep||`
|
|
`},setDirection:sr(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)})}),Lr.prototype.eachLine=Lr.prototype.iter;var is=0;function Al(e){var t=this;if(ns(t),Le(t,e)||ui(t.display,e))return;q(e),H&&(is=+new Date);var i=Ni(t,e,!0),r=e.dataTransfer.files;if(!i||t.isReadOnly())return;if(r&&r.length&&window.FileReader&&window.File)for(var n=r.length,E=Array(n),B=0,K=function(){++B==n&&or(t,function(){i=s(t.doc,i);var ye={from:i,to:i,text:t.doc.splitLines(E.filter(function(ke){return ke!=null}).join(t.doc.lineSeparator())),origin:"paste"};tn(t.doc,ye),Ho(t.doc,wi(s(t.doc,i),s(t.doc,Ai(ye))))})()},Y=function(ye,ke){if(t.options.allowDropFileTypes&&pe(t.options.allowDropFileTypes,ye.type)==-1){K();return}var Ne=new FileReader;Ne.onerror=function(){return K()},Ne.onload=function(){var je=Ne.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(je)){K();return}E[ke]=je,K()},Ne.readAsText(ye)},J=0;J<r.length;J++)Y(r[J],J);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 se=e.dataTransfer.getData("Text");if(se){var he;if(t.state.draggingText&&!t.state.draggingText.copy&&(he=t.listSelections()),qn(t.doc,wi(i,i)),he)for(var be=0;be<he.length;++be)rn(t.doc,"",he[be].anchor,he[be].head,"drag");t.replaceSelection(se,"around","paste"),t.display.input.focus()}}catch(ye){}}}function Ll(e,t){if(H&&(!e.state.draggingText||+new Date-is<100)){de(t);return}if(Le(e,t)||ui(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!D){var i=o("img",null,null,"position: fixed; left: 0; top: 0;");i.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",A&&(i.width=i.height=1,e.display.wrapper.appendChild(i),i._top=i.offsetTop),t.dataTransfer.setDragImage(i,0,0),A&&i.parentNode.removeChild(i)}}function kl(e,t){var i=Ni(e,t);if(!i)return;var r=document.createDocumentFragment();go(e,i,r),e.display.dragCursor||(e.display.dragCursor=o("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),d(e.display.dragCursor,r)}function ns(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function as(e){if(!document.getElementsByClassName)return;for(var t=document.getElementsByClassName("CodeMirror"),i=[],r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&i.push(n)}i.length&&i[0].operation(function(){for(var E=0;E<i.length;E++)e(i[E])})}var os=!1;function _l(){if(os)return;Dl(),os=!0}function Dl(){var e;we(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,as(Rl)},100))}),we(window,"blur",function(){return as(Zi)})}function Rl(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var _i={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},Pn=0;Pn<10;Pn++)_i[Pn+48]=_i[Pn+96]=String(Pn);for(var ra=65;ra<=90;ra++)_i[ra]=String.fromCharCode(ra);for(var Mn=1;Mn<=12;Mn++)_i[Mn+111]=_i[Mn+63235]="F"+Mn;var hi={};hi.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},hi.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},hi.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},hi.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},hi.default=l?hi.macDefault:hi.pcDefault;function Ol(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var i,r,n,E,B=0;B<t.length-1;B++){var K=t[B];if(/^(cmd|meta|m)$/i.test(K))E=!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),E&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Pl(e){var t={};for(var i in e)if(e.hasOwnProperty(i)){var r=e[i];if(/^(name|fallthrough|(de|at)tach)$/.test(i))continue;if(r=="..."){delete e[i];continue}for(var n=Ze(i.split(" "),Ol),E=0;E<n.length;E++){var B=void 0,K=void 0;E==n.length-1?(K=n.join(" "),B=r):(K=n.slice(0,E+1).join(" "),B="...");var Y=t[K];if(!Y)t[K]=B;else if(Y!=B)throw new Error("Inconsistent bindings for "+K)}delete e[i]}for(var J in t)e[J]=t[J];return e}function an(e,t,i,r){t=ia(t);var n=t.call?t.call(e,r):t[e];if(n===!1)return"nothing";if(n==="...")return"multi";if(n!=null&&i(n))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return an(e,t.fallthrough,i,r);for(var E=0;E<t.fallthrough.length;E++){var B=an(e,t.fallthrough[E],i,r);if(B)return B}}}function ss(e){var t=typeof e=="string"?e:_i[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function ls(e,t,i){var r=e;return t.altKey&&r!="Alt"&&(e="Alt-"+e),(m?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(e="Ctrl-"+e),(m?t.ctrlKey:t.metaKey)&&r!="Mod"&&(e="Cmd-"+e),!i&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function us(e,t){if(A&&e.keyCode==34&&e.char)return!1;var i=_i[e.keyCode];return i==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(i=e.code),ls(i,e,t))}function ia(e){return typeof e=="string"?hi[e]:e}function on(e,t){for(var i=e.doc.sel.ranges,r=[],n=0;n<i.length;n++){for(var E=t(i[n]);r.length&&St(E.from,Re(r).to)<=0;){var B=r.pop();if(St(B.from,E.from)<0){E.from=B.from;break}}r.push(E)}Pr(e,function(){for(var K=r.length-1;K>=0;K--)rn(e.doc,"",r[K].from,r[K].to,"+delete");Ji(e)})}function Ba(e,t,i){var r=Fe(e.text,t+i,i);return r<0||r>e.text.length?null:r}function Fa(e,t,i){var r=Ba(e,t.ch,i);return r==null?null:new Ue(t.line,r,i<0?"after":"before")}function Ua(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var E=et(i,t.doc.direction);if(E){var B=n<0?Re(E):E[0],K=n<0==(B.level==1),Y=K?"after":"before",J;if(B.level>0||t.doc.direction=="rtl"){var se=Xi(t,i);J=n<0?i.text.length-1:0;var he=ni(t,se,J).top;J=ot(function(be){return ni(t,se,be).top==he},n<0==(B.level==1)?B.from:B.to-1,J),Y=="before"&&(J=Ba(i,J,1))}else J=n<0?B.to:B.from;return new Ue(r,J,Y)}}return new Ue(r,n<0?i.text.length:0,n<0?"before":"after")}function Ml(e,t,i,r){var n=et(t,e.doc.direction);if(!n)return Fa(t,i,r);i.ch>=t.text.length?(i.ch=t.text.length,i.sticky="before"):i.ch<=0&&(i.ch=0,i.sticky="after");var E=qe(n,i.ch,i.sticky),B=n[E];if(e.doc.direction=="ltr"&&B.level%2==0&&(r>0?B.to>i.ch:B.from<i.ch))return Fa(t,i,r);var K=function(Xe,nt){return Ba(t,Xe instanceof Ue?Xe.ch:Xe,nt)},Y,J=function(Xe){return e.options.lineWrapping?(Y=Y||Xi(e,t),co(e,t,Y,Xe)):{begin:0,end:t.text.length}},se=J(i.sticky=="before"?K(i,-1):i.ch);if(e.doc.direction=="rtl"||B.level==1){var he=B.level==1==r<0,be=K(i,he?1:-1);if(be!=null&&(he?be<=B.to&&be<=se.end:be>=B.from&&be>=se.begin)){var ye=he?"before":"after";return new Ue(i.line,be,ye)}}var ke=function(Xe,nt,Ye){for(var st=function(zt,lr){return lr?new Ue(i.line,K(zt,1),"before"):new Ue(i.line,zt,"after")};Xe>=0&&Xe<n.length;Xe+=nt){var Et=n[Xe],gt=nt>0==(Et.level!=1),At=gt?Ye.begin:K(Ye.end,-1);if(Et.from<=At&&At<Et.to)return st(At,gt);if(At=gt?Et.from:K(Et.to,-1),Ye.begin<=At&&At<Ye.end)return st(At,gt)}},Ne=ke(E+r,r,se);if(Ne)return Ne;var je=r>0?se.end:K(se.begin,-1);return je!=null&&!(r>0&&je==t.text.length)&&(Ne=ke(r>0?0:n.length-1,r,J(je)),Ne)?Ne:null}var In={selectAll:Xo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),xe)},killLine:function(e){return on(e,function(t){if(t.empty()){var i=ht(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line<e.lastLine()?{from:t.head,to:Ue(t.head.line+1,0)}:{from:t.head,to:Ue(t.head.line,i)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return on(e,function(t){return{from:Ue(t.from().line,0),to:s(e.doc,Ue(t.to().line+1,0))}})},delLineLeft:function(e){return on(e,function(t){return{from:Ue(t.from().line,0),to:t.from()}})},delWrappedLineLeft:function(e){return on(e,function(t){var i=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:i},"div");return{from:r,to:t.from()}})},delWrappedLineRight:function(e){return on(e,function(t){var i=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div");return{from:t.from(),to:r}})},undo:function(e){return e.undo()},redo:function(e){return e.redo()},undoSelection:function(e){return e.undoSelection()},redoSelection:function(e){return e.redoSelection()},goDocStart:function(e){return e.extendSelection(Ue(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(Ue(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return hs(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return ds(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){return e.extendSelectionsBy(function(t){return Il(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div")},Ae)},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")},Ae)},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},Ae)},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 E=i[n].from(),B=ee(e.getLine(E.line),E.ch,r);t.push(oe(r-B%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return Pr(e,function(){for(var t=e.listSelections(),i=[],r=0;r<t.length;r++){if(!t[r].empty())continue;var n=t[r].head,E=ht(e.doc,n.line).text;if(E){if(n.ch==E.length&&(n=new Ue(n.line,n.ch-1)),n.ch>0)n=new Ue(n.line,n.ch+1),e.replaceRange(E.charAt(n.ch-1)+E.charAt(n.ch-2),Ue(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var B=ht(e.doc,n.line-1).text;B&&(n=new Ue(n.line,1),e.replaceRange(E.charAt(0)+e.doc.lineSeparator()+B.charAt(B.length-1),Ue(n.line-1,B.length-1),n,"+transpose"))}}i.push(new jt(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return Pr(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);Ji(e)})},openLine:function(e){return e.replaceSelection(`
|
|
`,"start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function hs(e,t){var i=ht(e.doc,t),r=Er(i);return r!=i&&(t=kt(r)),Ua(!0,e,r,t,1)}function Il(e,t){var i=ht(e.doc,t),r=Vi(i);return r!=i&&(t=kt(r)),Ua(!0,e,i,t,-1)}function ds(e,t){var i=hs(e,t.line),r=ht(e.doc,i.line),n=et(r,e.doc.direction);if(!n||n[0].level==0){var E=Math.max(i.ch,r.text.search(/\S/)),B=t.line==i.line&&t.ch<=E&&t.ch;return Ue(i.line,B?0:E,i.sticky)}return i}function na(e,t,i){if(typeof t=="string"&&(t=In[t],!t))return!1;e.display.input.ensurePolled();var r=e.display.shift,n=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),i&&(e.display.shift=!1),n=t(e)!=De}finally{e.display.shift=r,e.state.suppressEdits=!1}return n}function Nl(e,t,i){for(var r=0;r<e.state.keyMaps.length;r++){var n=an(t,e.state.keyMaps[r],i,e);if(n)return n}return e.options.extraKeys&&an(t,e.options.extraKeys,i,e)||an(t,e.options.keyMap,i,e)}var Bl=new ae;function Nn(e,t,i,r){var n=e.state.keySeq;if(n){if(ss(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:Bl.set(50,function(){e.state.keySeq==n&&(e.state.keySeq=null,e.display.input.reset())}),cs(e,n+" "+t,i,r))return!0}return cs(e,t,i,r)}function cs(e,t,i,r){var n=Nl(e,t,r);return n=="multi"&&(e.state.keySeq=t),n=="handled"&&cr(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?Nn(e,"Shift-"+i,t,function(r){return na(e,r,!0)})||Nn(e,i,t,function(r){if(typeof r=="string"?/^go[A-Z]/.test(r):r.motion)return na(e,r)}):Nn(e,i,t,function(r){return na(e,r)}):!1}function Fl(e,t,i){return Nn(e,"'"+i+"'",t,function(r){return na(e,r,!0)})}var ja=null;function ps(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(t.curOp.focus=I(),Le(t,e))return;H&&F<11&&e.keyCode==27&&(e.returnValue=!1);var i=e.keyCode;t.display.shift=i==16||e.shiftKey;var r=fs(t,e);A&&(ja=r?i:null,!r&&i==88&&!Ft&&(l?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),_&&!l&&!r&&i==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),i==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Ul(t)}function Ul(e){var t=e.display.lineDiv;G(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(f(t,"CodeMirror-crosshair"),tt(document,"keyup",i),tt(document,"mouseover",i))}we(document,"keyup",i),we(document,"mouseover",i)}function ms(e){e.keyCode==16&&(this.doc.sel.shift=!1),Le(this,e)}function gs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(ui(t.display,e)||Le(t,e)||e.ctrlKey&&!e.altKey||l&&e.metaKey)return;var i=e.keyCode,r=e.charCode;if(A&&i==ja){ja=null,q(e);return}if(A&&(!e.which||e.which<10)&&fs(t,e))return;var n=String.fromCharCode(r==null?i:r);if(n=="\b")return;if(Fl(t,e,n))return;t.display.input.onKeyPress(e)}var jl=400,Wa=function(e,t,i){this.time=e,this.pos=t,this.button=i};Wa.prototype.compare=function(e,t,i){return this.time+jl>e&&St(t,this.pos)==0&&i==this.button};var Bn,Fn;function Wl(e,t){var i=+new Date;return Fn&&Fn.compare(i,e,t)?(Bn=Fn=null,"triple"):Bn&&Bn.compare(i,e,t)?(Fn=new Wa(i,e,t),Bn=null,"double"):(Bn=new Wa(i,e,t),Fn=null,"single")}function vs(e){var t=this,i=t.display;if(Le(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,ui(i,e)){P||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(Ha(t,e))return;var r=Ni(t,e),n=Ee(e),E=r?Wl(r,n):"single";if(window.focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,n,r,E,e))return;n==1?r?zl(t,r,E,e):me(e)==i.scroller&&q(e):n==2?(r&&Qn(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(k?t.display.input.onContextMenu(e):yo(t))}function Hl(e,t,i,r,n){var E="Click";return r=="double"?E="Double"+E:r=="triple"&&(E="Triple"+E),E=(t==1?"Left":t==2?"Middle":"Right")+E,Nn(e,ls(E,n),n,function(B){if(typeof B=="string"&&(B=In[B]),!B)return!1;var K=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),K=B(e,i)!=De}finally{e.state.suppressEdits=!1}return K})}function Gl(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var E=h?i.shiftKey&&i.metaKey:i.altKey;n.unit=E?"rectangle":t=="single"?"char":t=="double"?"word":"line"}return(n.extend==null||e.doc.extend)&&(n.extend=e.doc.extend||i.shiftKey),n.addNew==null&&(n.addNew=l?i.metaKey:i.ctrlKey),n.moveOnDrag==null&&(n.moveOnDrag=!(l?i.altKey:i.ctrlKey)),n}function zl(e,t,i,r){H?setTimeout(z(vo,e),0):e.curOp.focus=I();var n=Gl(e,i,r),E=e.doc.sel,B;e.options.dragDrop&&Pe&&!e.isReadOnly()&&i=="single"&&(B=E.contains(t))>-1&&(St((B=E.ranges[B]).from(),t)<0||t.xRel>0)&&(St(B.to(),t)>0||t.xRel<0)?Kl(e,r,t,n):Vl(e,r,t,n)}function Kl(e,t,i,r){var n=e.display,E=!1,B=or(e,function(J){P&&(n.scroller.draggable=!1),e.state.draggingText=!1,tt(n.wrapper.ownerDocument,"mouseup",B),tt(n.wrapper.ownerDocument,"mousemove",K),tt(n.scroller,"dragstart",Y),tt(n.scroller,"drop",B),E||(q(J),r.addNew||Qn(e.doc,i,null,null,r.extend),P&&!D||H&&F==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),K=function(J){E=E||Math.abs(t.clientX-J.clientX)+Math.abs(t.clientY-J.clientY)>=10},Y=function(){return E=!0};P&&(n.scroller.draggable=!0),e.state.draggingText=B,B.copy=!r.moveOnDrag,n.scroller.dragDrop&&n.scroller.dragDrop(),we(n.wrapper.ownerDocument,"mouseup",B),we(n.wrapper.ownerDocument,"mousemove",K),we(n.scroller,"dragstart",Y),we(n.scroller,"drop",B),yo(e),setTimeout(function(){return n.input.focus()},20)}function ys(e,t,i){if(i=="char")return new jt(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new jt(Ue(t.line,0),s(e.doc,Ue(t.line+1,0)));var r=i(e,t);return new jt(r.from,r.to)}function Vl(e,t,i,r){var n=e.display,E=e.doc;q(t);var B,K,Y=E.sel,J=Y.ranges;if(r.addNew&&!r.extend?(K=E.sel.contains(i),K>-1?B=J[K]:B=new jt(i,i)):(B=E.sel.primary(),K=E.sel.primIndex),r.unit=="rectangle")r.addNew||(B=new jt(i,i)),i=Ni(e,t,!0,!0),K=-1;else{var se=ys(e,i,r.unit);r.extend?B=Ia(B,se.anchor,se.head,r.extend):B=se}r.addNew?K==-1?(K=J.length,br(E,Jr(e,J.concat([B]),K),{scroll:!1,origin:"*mouse"})):J.length>1&&J[K].empty()&&r.unit=="char"&&!r.extend?(br(E,Jr(e,J.slice(0,K).concat(J.slice(K+1)),0),{scroll:!1,origin:"*mouse"}),Y=E.sel):Na(E,K,B,Ce):(K=0,br(E,new Wr([B],0),Ce),Y=E.sel);var he=i;function be(Ye){if(St(he,Ye)==0)return;if(he=Ye,r.unit=="rectangle"){for(var st=[],Et=e.options.tabSize,gt=ee(ht(E,i.line).text,i.ch,Et),At=ee(ht(E,Ye.line).text,Ye.ch,Et),zt=Math.min(gt,At),lr=Math.max(gt,At),Yt=Math.min(i.line,Ye.line),Mr=Math.min(e.lastLine(),Math.max(i.line,Ye.line));Yt<=Mr;Yt++){var kr=ht(E,Yt).text,er=Se(kr,zt,Et);zt==lr?st.push(new jt(Ue(Yt,er),Ue(Yt,er))):kr.length>er&&st.push(new jt(Ue(Yt,er),Ue(Yt,Se(kr,lr,Et))))}st.length||st.push(new jt(i,i)),br(E,Jr(e,Y.ranges.slice(0,K).concat(st),K),{origin:"*mouse",scroll:!1}),e.scrollIntoView(Ye)}else{var _r=B,fr=ys(e,Ye,r.unit),ir=_r.anchor,tr;St(fr.anchor,ir)>0?(tr=fr.head,ir=vi(_r.from(),fr.anchor)):(tr=fr.anchor,ir=gi(_r.to(),fr.head));var $t=Y.ranges.slice(0);$t[K]=Xl(e,new jt(s(E,ir),tr)),br(E,Jr(e,$t,K),Ce)}}var ye=n.wrapper.getBoundingClientRect(),ke=0;function Ne(Ye){var st=++ke,Et=Ni(e,Ye,!0,r.unit=="rectangle");if(!Et)return;if(St(Et,he)!=0){e.curOp.focus=I(),be(Et);var gt=Vn(n,E);(Et.line>=gt.to||Et.line<gt.from)&&setTimeout(or(e,function(){ke==st&&Ne(Ye)}),150)}else{var At=Ye.clientY<ye.top?-20:Ye.clientY>ye.bottom?20:0;At&&setTimeout(or(e,function(){if(ke!=st)return;n.scroller.scrollTop+=At,Ne(Ye)}),50)}}function je(Ye){e.state.selectingText=!1,ke=Infinity,Ye&&(q(Ye),n.input.focus()),tt(n.wrapper.ownerDocument,"mousemove",Xe),tt(n.wrapper.ownerDocument,"mouseup",nt),E.history.lastSelOrigin=null}var Xe=or(e,function(Ye){Ye.buttons===0||!Ee(Ye)?je(Ye):Ne(Ye)}),nt=or(e,je);e.state.selectingText=nt,we(n.wrapper.ownerDocument,"mousemove",Xe),we(n.wrapper.ownerDocument,"mouseup",nt)}function Xl(e,t){var i=t.anchor,r=t.head,n=ht(e.doc,i.line);if(St(i,r)==0&&i.sticky==r.sticky)return t;var E=et(n);if(!E)return t;var B=qe(E,i.ch,i.sticky),K=E[B];if(K.from!=i.ch&&K.to!=i.ch)return t;var Y=B+(K.from==i.ch==(K.level!=1)?0:1);if(Y==0||Y==E.length)return t;var J;if(r.line!=i.line)J=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var se=qe(E,r.ch,r.sticky),he=se-B||(r.ch-i.ch)*(K.level==1?-1:1);se==Y-1||se==Y?J=he<0:J=he>0}var be=E[Y+(J?-1:0)],ye=J==(be.level==1),ke=ye?be.from:be.to,Ne=ye?"after":"before";return i.ch==ke&&i.sticky==Ne?t:new jt(new Ue(i.line,ke,Ne),r)}function bs(e,t,i,r){var n,E;if(t.touches)n=t.touches[0].clientX,E=t.touches[0].clientY;else try{n=t.clientX,E=t.clientY}catch(be){return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&q(t);var B=e.display,K=B.lineDiv.getBoundingClientRect();if(E>K.bottom||!le(e,i))return ie(t);E-=K.top-B.viewOffset;for(var Y=0;Y<e.display.gutterSpecs.length;++Y){var J=B.gutters.childNodes[Y];if(J&&J.getBoundingClientRect().right>=n){var se=Fr(e.doc,E),he=e.display.gutterSpecs[Y];return Te(e,i,e,se,he.className,t),ie(t)}}}function Ha(e,t){return bs(e,t,"gutterClick",!0)}function xs(e,t){if(ui(e.display,t)||Yl(e,t))return;if(Le(e,t,"contextmenu"))return;k||e.display.input.onContextMenu(t)}function Yl(e,t){return le(e,"gutterContextMenu")?bs(e,t,"gutterContextMenu",!1):!1}function Es(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),yn(e)}var sn={toString:function(){return"CodeMirror.Init"}},Ss={},aa={};function $l(e){var t=e.optionHandlers;function i(r,n,E,B){e.defaults[r]=n,E&&(t[r]=B?function(K,Y,J){J!=sn&&E(K,Y,J)}:E)}e.defineOption=i,e.Init=sn,i("value","",function(r,n){return r.setValue(n)},!0),i("mode",null,function(r,n){r.doc.modeOption=n,Oa(r)},!0),i("indentUnit",2,Oa,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){An(r),yn(r),Ar(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!n)return;var E=[],B=r.doc.first;r.doc.iter(function(Y){for(var J=0;;){var se=Y.text.indexOf(n,J);if(se==-1)break;J=se+n.length,E.push(Ue(B,se))}B++});for(var K=E.length-1;K>=0;K--)rn(r.doc,n,E[K],Ue(E[K].line,E[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,E){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),E!=sn&&r.refresh()}),i("specialCharPlaceholder",Gt,function(r){return r.refresh()},!0),i("electricChars",!0),i("inputStyle",a?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),i("spellcheck",!1,function(r,n){return r.getInputField().spellcheck=n},!0),i("autocorrect",!1,function(r,n){return r.getInputField().autocorrect=n},!0),i("autocapitalize",!1,function(r,n){return r.getInputField().autocapitalize=n},!0),i("rtlMoveVisually",!C),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Es(r),wn(r)},!0),i("keyMap","default",function(r,n,E){var B=ia(n),K=E!=sn&&ia(E);K&&K.detach&&K.detach(r,B),B.attach&&B.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),wn(r)},!0),i("fixedGutter",!0,function(r,n){r.display.gutters.style.left=n?xa(r.display)+"px":"0",r.refresh()},!0),i("coverGutterNextToScrollbar",!1,function(r){return Qi(r)},!0),i("scrollbarStyle","native",function(r){Co(r),Qi(r),r.display.scrollbars.setScrollTop(r.doc.scrollTop),r.display.scrollbars.setScrollLeft(r.doc.scrollLeft)},!0),i("lineNumbers",!1,function(r,n){r.display.gutterSpecs=Da(r.options.gutters,n),wn(r)},!0),i("firstLineNumber",1,wn,!0),i("lineNumberFormatter",function(r){return r},wn,!0),i("showCursorWhenSelecting",!1,bn,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,function(r,n){n=="nocursor"&&(Zi(r),r.display.input.blur()),r.display.input.readOnlyChanged(n)}),i("screenReaderLabel",null,function(r,n){n=n===""?null:n,r.display.input.screenReaderLabelChanged(n)}),i("disableInput",!1,function(r,n){n||r.display.input.reset()},!0),i("dragDrop",!0,Zl),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,bn,!0),i("singleCursorHeightPerLine",!0,bn,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,An,!0),i("addModeClass",!1,An,!0),i("pollInterval",100),i("undoDepth",200,function(r,n){return r.doc.history.undoDepth=n}),i("historyEventDelay",1250),i("viewportMargin",10,function(r){return r.refresh()},!0),i("maxHighlightLength",1e4,An,!0),i("moveInputWithCursor",!0,function(r,n){n||r.display.input.resetPosition()}),i("tabindex",null,function(r,n){return r.display.input.getField().tabIndex=n||""}),i("autofocus",null),i("direction","ltr",function(r,n){return r.doc.setDirection(n)},!0),i("phrases",null)}function Zl(e,t,i){var r=i&&i!=sn;if(!t!=!r){var n=e.display.dragFunctions,E=t?we:tt;E(e.display.scroller,"dragstart",n.start),E(e.display.scroller,"dragenter",n.enter),E(e.display.scroller,"dragover",n.over),E(e.display.scroller,"dragleave",n.leave),E(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"),jn(e)),Ea(e),Ar(e),yn(e),setTimeout(function(){return Qi(e)},100)}function Vt(e,t){var i=this;if(!(this instanceof Vt))return new Vt(e,t);this.options=t=t?W(t):{},W(Ss,t,!1);var r=t.value;typeof r=="string"?r=new Lr(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new Vt.inputStyles[t.inputStyle](this),E=this.display=new hl(e,r,n,t);E.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 ae,keySeq:null,specialChars:null},t.autofocus&&!a&&E.input.focus(),H&&F<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Ql(this),_l(),ji(this),this.curOp.forceUpdate=!0,Mo(this,r),t.autofocus&&!a||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Ta(i)},20):Zi(this);for(var B in aa)aa.hasOwnProperty(B)&&aa[B](this,t[B],sn);Lo(this),t.finishInit&&t.finishInit(this);for(var K=0;K<Ga.length;++K)Ga[K](this);Wi(this),P&&t.lineWrapping&&getComputedStyle(E.lineDiv).textRendering=="optimizelegibility"&&(E.lineDiv.style.textRendering="auto")}Vt.defaults=Ss,Vt.optionHandlers=aa;function Ql(e){var t=e.display;we(t.scroller,"mousedown",or(e,vs)),H&&F<11?we(t.scroller,"dblclick",or(e,function(Y){if(Le(e,Y))return;var J=Ni(e,Y);if(!J||Ha(e,Y)||ui(e.display,Y))return;q(Y);var se=e.findWordAt(J);Qn(e.doc,se.anchor,se.head)})):we(t.scroller,"dblclick",function(Y){return Le(e,Y)||q(Y)}),we(t.scroller,"contextmenu",function(Y){return xs(e,Y)}),we(t.input.getField(),"contextmenu",function(Y){t.scroller.contains(Y.target)||xs(e,Y)});var i,r={end:0};function n(){t.activeTouch&&(i=setTimeout(function(){return t.activeTouch=null},1e3),r=t.activeTouch,r.end=+new Date)}function E(Y){if(Y.touches.length!=1)return!1;var J=Y.touches[0];return J.radiusX<=1&&J.radiusY<=1}function B(Y,J){if(J.left==null)return!0;var se=J.left-Y.left,he=J.top-Y.top;return se*se+he*he>20*20}we(t.scroller,"touchstart",function(Y){if(!Le(e,Y)&&!E(Y)&&!Ha(e,Y)){t.input.ensurePolled(),clearTimeout(i);var J=+new Date;t.activeTouch={start:J,moved:!1,prev:J-r.end<=300?r:null},Y.touches.length==1&&(t.activeTouch.left=Y.touches[0].pageX,t.activeTouch.top=Y.touches[0].pageY)}}),we(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),we(t.scroller,"touchend",function(Y){var J=t.activeTouch;if(J&&!ui(t,Y)&&J.left!=null&&!J.moved&&new Date-J.start<300){var se=e.coordsChar(t.activeTouch,"page"),he;!J.prev||B(J,J.prev)?he=new jt(se,se):!J.prev.prev||B(J,J.prev.prev)?he=e.findWordAt(se):he=new jt(Ue(se.line,0),s(e.doc,Ue(se.line+1,0))),e.setSelection(he.anchor,he.head),e.focus(),q(Y)}n()}),we(t.scroller,"touchcancel",n),we(t.scroller,"scroll",function(){t.scroller.clientHeight&&(En(e,t.scroller.scrollTop),Fi(e,t.scroller.scrollLeft,!0),Te(e,"scroll",e))}),we(t.scroller,"mousewheel",function(Y){return Do(e,Y)}),we(t.scroller,"DOMMouseScroll",function(Y){return Do(e,Y)}),we(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(Y){Le(e,Y)||de(Y)},over:function(Y){Le(e,Y)||(kl(e,Y),de(Y))},start:function(Y){return Ll(e,Y)},drop:or(e,Al),leave:function(Y){Le(e,Y)||ns(e)}};var K=t.input.getField();we(K,"keyup",function(Y){return ms.call(e,Y)}),we(K,"keydown",or(e,ps)),we(K,"keypress",or(e,gs)),we(K,"focus",function(Y){return Ta(e,Y)}),we(K,"blur",function(Y){return Zi(e,Y)})}var Ga=[];Vt.defineInitHook=function(e){return Ga.push(e)};function Un(e,t,i,r){var n=e.doc,E;i==null&&(i="add"),i=="smart"&&(n.mode.indent?E=Ke(e,t).state:i="prev");var B=e.options.tabSize,K=ht(n,t),Y=ee(K.text,null,B);K.stateAfter&&(K.stateAfter=null);var J=K.text.match(/^\s*/)[0],se;if(!r&&!/\S/.test(K.text))se=0,i="not";else if(i=="smart"&&(se=n.mode.indent(E,K.text.slice(J.length),K.text),se==De||se>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?se=ee(ht(n,t-1).text,null,B):se=0:i=="add"?se=Y+e.options.indentUnit:i=="subtract"?se=Y-e.options.indentUnit:typeof i=="number"&&(se=Y+i),se=Math.max(0,se);var he="",be=0;if(e.options.indentWithTabs)for(var ye=Math.floor(se/B);ye;--ye)be+=B,he+=" ";if(be<se&&(he+=oe(se-be)),he!=J)return rn(n,he,Ue(t,0),Ue(t,J.length),"+input"),K.stateAfter=null,!0;for(var ke=0;ke<n.sel.ranges.length;ke++){var Ne=n.sel.ranges[ke];if(Ne.head.line==t&&Ne.head.ch<J.length){var je=Ue(t,J.length);Na(n,ke,new jt(je,je));break}}}var Qr=null;function oa(e){Qr=e}function za(e,t,i,r,n){var E=e.doc;e.display.shift=!1,r||(r=E.sel);var B=+new Date-200,K=n=="paste"||e.state.pasteIncoming>B,Y=Tt(t),J=null;if(K&&r.ranges.length>1)if(Qr&&Qr.text.join(`
|
|
`)==t){if(r.ranges.length%Qr.text.length==0){J=[];for(var se=0;se<Qr.text.length;se++)J.push(E.splitLines(Qr.text[se]))}}else Y.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(J=Ze(Y,function(Xe){return[Xe]}));for(var he=e.curOp.updateInput,be=r.ranges.length-1;be>=0;be--){var ye=r.ranges[be],ke=ye.from(),Ne=ye.to();ye.empty()&&(i&&i>0?ke=Ue(ke.line,ke.ch-i):e.state.overwrite&&!K?Ne=Ue(Ne.line,Math.min(ht(E,Ne.line).text.length,Ne.ch+Re(Y).length)):K&&Qr&&Qr.lineWise&&Qr.text.join(`
|
|
`)==Y.join(`
|
|
`)&&(ke=Ne=Ue(ke.line,0)));var je={from:ke,to:Ne,text:J?J[be%J.length]:Y,origin:n||(K?"paste":e.state.cutIncoming>B?"cut":"+input")};tn(e.doc,je),cr(e,"inputRead",e,je)}t&&!K&&Cs(e,t),Ji(e),e.curOp.updateInput<2&&(e.curOp.updateInput=he),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&&Pr(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 E=e.getModeAt(n.head),B=!1;if(E.electricChars){for(var K=0;K<E.electricChars.length;K++)if(t.indexOf(E.electricChars.charAt(K))>-1){B=Un(e,n.head.line,"smart");break}}else E.electricInput&&(E.electricInput.test(ht(e.doc,n.head.line).text.slice(0,n.head.ch))&&(B=Un(e,n.head.line,"smart")));B&&cr(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,E={anchor:Ue(n,0),head:Ue(n+1,0)};i.push(E),t.push(e.getRange(E.anchor,E.head))}return{text:t,ranges:i}}function As(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function Ls(){var e=o("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=o("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return P?e.style.width="1000px":e.setAttribute("wrap","off"),x&&(e.style.border="1px solid black"),As(e),t}function ql(e){var t=e.optionHandlers,i=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(r,n){var E=this.options,B=E[r];if(E[r]==n&&r!="mode")return;E[r]=n,t.hasOwnProperty(r)&&or(this,t[r])(this,n,B),Te(this,"optionChange",this,r)},getOption:function(r){return this.options[r]},getDoc:function(){return this.doc},addKeyMap:function(r,n){this.state.keyMaps[n?"push":"unshift"](ia(r))},removeKeyMap:function(r){for(var n=this.state.keyMaps,E=0;E<n.length;++E)if(n[E]==r||n[E].name==r)return n.splice(E,1),!0},addOverlay:Sr(function(r,n){var E=r.token?r:e.getMode(this.options,r);if(E.startState)throw new Error("Overlays may not be stateful.");He(this.state.overlays,{mode:E,modeSpec:r,opaque:n&&n.opaque,priority:n&&n.priority||0},function(B){return B.priority}),this.state.modeGen++,Ar(this)}),removeOverlay:Sr(function(r){for(var n=this.state.overlays,E=0;E<n.length;++E){var B=n[E].modeSpec;if(B==r||typeof r=="string"&&B.name==r){n.splice(E,1),this.state.modeGen++,Ar(this);return}}}),indentLine:Sr(function(r,n,E){typeof n!="string"&&typeof n!="number"&&(n==null?n=this.options.smartIndent?"smart":"prev":n=n?"add":"subtract"),Vr(this.doc,r)&&Un(this,r,n,E)}),indentSelection:Sr(function(r){for(var n=this.doc.sel.ranges,E=-1,B=0;B<n.length;B++){var K=n[B];if(K.empty())K.head.line>E&&(Un(this,K.head.line,r,!0),E=K.head.line,B==this.doc.sel.primIndex&&Ji(this));else{var Y=K.from(),J=K.to(),se=Math.max(E,Y.line);E=Math.min(this.lastLine(),J.line-(J.ch?0:1))+1;for(var he=se;he<E;++he)Un(this,he,r);var be=this.doc.sel.ranges;Y.ch==0&&n.length==be.length&&be[B].from().ch>0&&Na(this.doc,B,new jt(Y,be[B].to()),xe)}}}),getTokenAt:function(r,n){return Kt(this,r,n)},getLineTokens:function(r,n){return Kt(this,Ue(r),n,!0)},getTokenTypeAt:function(r){r=s(this.doc,r);var n=Oe(this,ht(this.doc,r.line)),E=0,B=(n.length-1)/2,K=r.ch,Y;if(K==0)Y=n[2];else for(;;){var J=E+B>>1;if((J?n[J*2-1]:0)>=K)B=J;else if(n[J*2+1]<K)E=J+1;else{Y=n[J*2+2];break}}var se=Y?Y.indexOf("overlay "):-1;return se<0?Y:se==0?null:Y.slice(0,se-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 E=[];if(!i.hasOwnProperty(n))return E;var B=i[n],K=this.getModeAt(r);if(typeof K[n]=="string")B[K[n]]&&E.push(B[K[n]]);else if(K[n])for(var Y=0;Y<K[n].length;Y++){var J=B[K[n][Y]];J&&E.push(J)}else K.helperType&&B[K.helperType]?E.push(B[K.helperType]):B[K.name]&&E.push(B[K.name]);for(var se=0;se<B._global.length;se++){var he=B._global[se];he.pred(K,this)&&pe(E,he.val)==-1&&E.push(he.val)}return E},getStateAfter:function(r,n){var E=this.doc;return r=j(E,r==null?E.first+E.size-1:r),Ke(this,r+1,n).state},cursorCoords:function(r,n){var E,B=this.doc.sel.primary();return r==null?E=B.head:typeof r=="object"?E=s(this.doc,r):E=r?B.from():B.to(),Zr(this,E,n||"page")},charCoords:function(r,n){return ma(this,s(this.doc,r),n||"page")},coordsChar:function(r,n){return r=lo(this,r,n||"page"),va(this,r.left,r.top)},lineAtHeight:function(r,n){return r=lo(this,{top:r,left:0},n||"page").top,Fr(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,n,E){var B=!1,K;if(typeof r=="number"){var Y=this.doc.first+this.doc.size-1;r<this.doc.first?r=this.doc.first:r>Y&&(r=Y,B=!0),K=ht(this.doc,r)}else K=r;return Hn(this,K,{top:0,left:0},n||"page",E||B).top+(B?this.doc.height-$r(K):0)},defaultTextHeight:function(){return Yi(this.display)},defaultCharWidth:function(){return $i(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,n,E,B,K){var Y=this.display;r=Zr(this,s(this.doc,r));var J=r.bottom,se=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),Y.sizer.appendChild(n),B=="over")J=r.top;else if(B=="above"||B=="near"){var he=Math.max(Y.wrapper.clientHeight,this.doc.height),be=Math.max(Y.sizer.clientWidth,Y.lineSpace.clientWidth);(B=="above"||r.bottom+n.offsetHeight>he)&&r.top>n.offsetHeight?J=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=he&&(J=r.bottom),se+n.offsetWidth>be&&(se=be-n.offsetWidth)}n.style.top=J+"px",n.style.left=n.style.right="",K=="right"?(se=Y.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(K=="left"?se=0:K=="middle"&&(se=(Y.sizer.clientWidth-n.offsetWidth)/2),n.style.left=se+"px"),E&&Zs(this,{left:se,top:J,right:se+n.offsetWidth,bottom:J+n.offsetHeight})},triggerOnKeyDown:Sr(ps),triggerOnKeyPress:Sr(gs),triggerOnKeyUp:ms,triggerOnMouseDown:Sr(vs),execCommand:function(r){if(In.hasOwnProperty(r))return In[r].call(null,this)},triggerElectric:Sr(function(r){Cs(this,r)}),findPosH:function(r,n,E,B){var K=1;n<0&&(K=-1,n=-n);for(var Y=s(this.doc,r),J=0;J<n&&!(Y=Ka(this.doc,Y,K,E,B),Y.hitSide);++J);return Y},moveH:Sr(function(r,n){var E=this;this.extendSelectionsBy(function(B){return E.display.shift||E.doc.extend||B.empty()?Ka(E.doc,B.head,r,n,E.options.rtlMoveVisually):r<0?B.from():B.to()},Ae)}),deleteH:Sr(function(r,n){var E=this.doc.sel,B=this.doc;E.somethingSelected()?B.replaceSelection("",null,"+delete"):on(this,function(K){var Y=Ka(B,K.head,r,n,!1);return r<0?{from:Y,to:K.head}:{from:K.head,to:Y}})}),findPosV:function(r,n,E,B){var K=1,Y=B;n<0&&(K=-1,n=-n);for(var J=s(this.doc,r),se=0;se<n;++se){var he=Zr(this,J,"div");if(Y==null?Y=he.left:he.left=Y,J=ks(this,he,K,E),J.hitSide)break}return J},moveV:Sr(function(r,n){var E=this,B=this.doc,K=[],Y=!this.display.shift&&!B.extend&&B.sel.somethingSelected();if(B.extendSelectionsBy(function(se){if(Y)return r<0?se.from():se.to();var he=Zr(E,se.head,"div");se.goalColumn!=null&&(he.left=se.goalColumn),K.push(he.left);var be=ks(E,he,r,n);return n=="page"&&se==B.sel.primary()&&wa(E,ma(E,be,"div").top-he.top),be},Ae),K.length)for(var J=0;J<B.sel.ranges.length;J++)B.sel.ranges[J].goalColumn=K[J]}),findWordAt:function(r){var n=this.doc,E=ht(n,r.line).text,B=r.ch,K=r.ch;if(E){var Y=this.getHelper(r,"wordChars");(r.sticky=="before"||K==E.length)&&B?--B:++K;for(var J=E.charAt(B),se=We(J,Y)?function(he){return We(he,Y)}:/\s/.test(J)?function(he){return/\s/.test(he)}:function(he){return!/\s/.test(he)&&!We(he)};B>0&&se(E.charAt(B-1));)--B;for(;K<E.length&&se(E.charAt(K));)++K}return new jt(Ue(r.line,B),Ue(r.line,K))},toggleOverwrite:function(r){if(r!=null&&r==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?G(this.display.cursorDiv,"CodeMirror-overwrite"):f(this.display.cursorDiv,"CodeMirror-overwrite"),Te(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==I()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:Sr(function(r,n){xn(this,r,n)}),getScrollInfo:function(){var r=this.display.scroller;return{left:r.scrollLeft,top:r.scrollTop,height:r.scrollHeight-ii(this)-this.display.barHeight,width:r.scrollWidth-ii(this)-this.display.barWidth,clientHeight:ca(this),clientWidth:Mi(this)}},scrollIntoView:Sr(function(r,n){r==null?(r={from:this.doc.sel.primary().head,to:null},n==null&&(n=this.options.cursorScrollMargin)):typeof r=="number"?r={from: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:Sr(function(r,n){var E=this,B=function(Y){return typeof Y=="number"||/^\d+$/.test(String(Y))?Y+"px":Y};r!=null&&(this.display.wrapper.style.width=B(r)),n!=null&&(this.display.wrapper.style.height=B(n)),this.options.lineWrapping&&ao(this);var K=this.display.viewFrom;this.doc.iter(K,this.display.viewTo,function(Y){if(Y.widgets){for(var J=0;J<Y.widgets.length;J++)if(Y.widgets[J].noHScroll){Ti(E,K,"widget");break}}++K}),this.curOp.forceUpdate=!0,Te(this,"refresh",this)}),operation:function(r){return Pr(this,r)},startOperation:function(){return ji(this)},endOperation:function(){return Wi(this)},refresh:Sr(function(){var r=this.display.cachedTextHeight;Ar(this),this.curOp.forceUpdate=!0,yn(this),xn(this,this.doc.scrollLeft,this.doc.scrollTop),ka(this.display),(r==null||Math.abs(r-Yi(this.display))>.5||this.options.lineWrapping)&&Ea(this),Te(this,"refresh",this)}),swapDoc:Sr(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),Mo(this,r),yn(this),this.display.input.reset(),xn(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,cr(this,"swapDoc",this,n),n}),phrase:function(r){var n=this.options.phrases;return n&&Object.prototype.hasOwnProperty.call(n,r)?n[r]:r},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},ue(e),e.registerHelper=function(r,n,E){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=E},e.registerGlobalHelper=function(r,n,E,B){e.registerHelper(r,n,B),i[r]._global.push({pred:E,val:B})}}function Ka(e,t,i,r,n){var E=t,B=i,K=ht(e,t.line),Y=n&&e.direction=="rtl"?-i:i;function J(){var nt=t.line+Y;return nt<e.first||nt>=e.first+e.size?!1:(t=new Ue(nt,t.ch,t.sticky),K=ht(e,nt))}function se(nt){var Ye;if(r=="codepoint"){var st=K.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(st)?Ye=null:Ye=new Ue(t.line,Math.max(0,Math.min(K.text.length,t.ch+i*(st>=55296&&st<56320?2:1))),-i)}else n?Ye=Ml(e.cm,K,t,i):Ye=Fa(K,t,i);if(Ye==null)if(!nt&&J())t=Ua(n,e.cm,K,t.line,Y);else return!1;else t=Ye;return!0}if(r=="char"||r=="codepoint")se();else if(r=="column")se(!0);else if(r=="word"||r=="group")for(var he=null,be=r=="group",ye=e.cm&&e.cm.getHelper(t,"wordChars"),ke=!0;!(i<0&&!se(!ke));ke=!1){var Ne=K.text.charAt(t.ch)||`
|
|
`,je=We(Ne,ye)?"w":be&&Ne==`
|
|
`?"n":!be||/\s/.test(Ne)?null:"p";if(be&&!ke&&!je&&(je="s"),he&&he!=je){i<0&&(i=1,se(),t.sticky="after");break}if(je&&(he=je),i>0&&!se(!ke))break}var Xe=ea(e,t,E,B,!0);return pi(E,Xe)&&(Xe.hitSide=!0),Xe}function ks(e,t,i,r){var n=e.doc,E=t.left,B;if(r=="page"){var K=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),Y=Math.max(K-.5*Yi(e.display),3);B=(i>0?t.bottom:t.top)+i*Y}else r=="line"&&(B=i>0?t.bottom+3:t.top-3);for(var J;!(J=va(e,E,B),!J.outside);){if(i<0?B<=0:B>=n.height){J.hitSide=!0;break}B+=i*5}return J}var Ht=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new ae,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Ht.prototype.init=function(e){var t=this,i=this,r=i.cm,n=i.div=e.lineDiv;As(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function E(K){for(var Y=K.target;Y;Y=Y.parentNode){if(Y==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(Y.className))break}return!1}we(n,"paste",function(K){if(!E(K)||Le(r,K)||Ts(K,r))return;F<=11&&setTimeout(or(r,function(){return t.updateFromDOM()}),20)}),we(n,"compositionstart",function(K){t.composing={data:K.data,done:!1}}),we(n,"compositionupdate",function(K){t.composing||(t.composing={data:K.data,done:!1})}),we(n,"compositionend",function(K){t.composing&&(K.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),we(n,"touchstart",function(){return i.forceCompositionEnd()}),we(n,"input",function(){t.composing||t.readFromDOMSoon()});function B(K){if(!E(K)||Le(r,K))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()}),K.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var Y=ws(r);oa({lineWise:!0,text:Y.text}),K.type=="cut"&&r.operation(function(){r.setSelections(Y.ranges,0,xe),r.replaceSelection("",null,"cut")})}else return;if(K.clipboardData){K.clipboardData.clearData();var J=Qr.text.join(`
|
|
`);if(K.clipboardData.setData("Text",J),K.clipboardData.getData("Text")==J){K.preventDefault();return}}var se=Ls(),he=se.firstChild;r.display.lineSpace.insertBefore(se,r.display.lineSpace.firstChild),he.value=Qr.text.join(`
|
|
`);var be=document.activeElement;Q(he),setTimeout(function(){r.display.lineSpace.removeChild(se),be.focus(),be==n&&i.showPrimarySelection()},50)}we(n,"copy",B),we(n,"cut",B)},Ht.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},Ht.prototype.prepareSelection=function(){var e=mo(this.cm,!1);return e.focus=document.activeElement==this.div,e},Ht.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},Ht.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Ht.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 E=sa(t,e.anchorNode,e.anchorOffset),B=sa(t,e.focusNode,e.focusOffset);if(E&&!E.bad&&B&&!B.bad&&St(vi(E,B),r)==0&&St(gi(E,B),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},J=n.line<t.display.viewTo&&_s(t,n);if(!J){var se=K[K.length-1].measure,he=se.maps?se.maps[se.maps.length-1]:se.map;J={node:he[he.length-1],offset:he[he.length-2]-he[he.length-3]}}if(!Y||!J){e.removeAllRanges();return}var be=e.rangeCount&&e.getRangeAt(0),ye;try{ye=y(Y.node,Y.offset,J.offset,J.node)}catch(ke){}ye&&(!_&&t.state.focused?(e.collapse(Y.node,Y.offset),ye.collapsed||(e.removeAllRanges(),e.addRange(ye))):(e.removeAllRanges(),e.addRange(ye)),be&&e.anchorNode==null?e.addRange(be):_&&this.startGracePeriod()),this.rememberSelection()},Ht.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)},Ht.prototype.showMultipleSelections=function(e){d(this.cm.display.cursorDiv,e.cursors),d(this.cm.display.selectionDiv,e.selection)},Ht.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},Ht.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return T(this.div,t)},Ht.prototype.focus=function(){this.cm.options.readOnly!="nocursor"&&((!this.selectionInEditor()||document.activeElement!=this.div)&&this.showSelection(this.prepareSelection(),!0),this.div.focus())},Ht.prototype.blur=function(){this.div.blur()},Ht.prototype.getField=function(){return this.div},Ht.prototype.supportsTouch=function(){return!0},Ht.prototype.receivedFocus=function(){var e=this;this.selectionInEditor()?this.pollSelection():Pr(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)},Ht.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},Ht.prototype.pollSelection=function(){if(this.readDOMTimeout!=null||this.gracePeriod||!this.selectionChanged())return;var e=this.getSelection(),t=this.cm;if(u&&b&&this.cm.display.gutterSpecs.length&&eu(e.anchorNode)){this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),this.focus();return}if(this.composing)return;this.rememberSelection();var i=sa(t,e.anchorNode,e.anchorOffset),r=sa(t,e.focusNode,e.focusOffset);i&&r&&Pr(t,function(){br(t.doc,wi(i,r),xe),(i.bad||r.bad)&&(t.curOp.selectionChanged=!0)})},Ht.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,ht(e.doc,r.line-1).length)),n.ch==ht(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 E,B,K;r.line==t.viewFrom||(E=Bi(e,r.line))==0?(B=kt(t.view[0].line),K=t.view[0].node):(B=kt(t.view[E].line),K=t.view[E-1].node.nextSibling);var Y=Bi(e,n.line),J,se;if(Y==t.view.length-1?(J=t.viewTo-1,se=t.lineDiv.lastChild):(J=kt(t.view[Y+1].line)-1,se=t.view[Y+1].node.previousSibling),!K)return!1;for(var he=e.doc.splitLines(tu(e,K,se,B,J)),be=Hr(e.doc,Ue(B,0),Ue(J,ht(e.doc,J).text.length));he.length>1&&be.length>1;)if(Re(he)==Re(be))he.pop(),be.pop(),J--;else if(he[0]==be[0])he.shift(),be.shift(),B++;else break;for(var ye=0,ke=0,Ne=he[0],je=be[0],Xe=Math.min(Ne.length,je.length);ye<Xe&&Ne.charCodeAt(ye)==je.charCodeAt(ye);)++ye;for(var nt=Re(he),Ye=Re(be),st=Math.min(nt.length-(he.length==1?ye:0),Ye.length-(be.length==1?ye:0));ke<st&&nt.charCodeAt(nt.length-ke-1)==Ye.charCodeAt(Ye.length-ke-1);)++ke;if(he.length==1&&be.length==1&&B==r.line)for(;ye&&ye>r.ch&&nt.charCodeAt(nt.length-ke-1)==Ye.charCodeAt(Ye.length-ke-1);)ye--,ke++;he[he.length-1]=nt.slice(0,nt.length-ke).replace(/^\u200b+/,""),he[0]=he[0].slice(ye).replace(/\u200b+$/,"");var Et=Ue(B,ye),gt=Ue(J,be.length?Re(be).length-ke:0);if(he.length>1||he[0]||St(Et,gt))return rn(e.doc,he,Et,gt,"+input"),!0},Ht.prototype.ensurePolled=function(){this.forceCompositionEnd()},Ht.prototype.reset=function(){this.forceCompositionEnd()},Ht.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},Ht.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)},Ht.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&Pr(this.cm,function(){return Ar(e.cm)})},Ht.prototype.setUneditable=function(e){e.contentEditable="false"},Ht.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault(),this.cm.isReadOnly()||or(this.cm,za)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},Ht.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},Ht.prototype.onContextMenu=function(){},Ht.prototype.resetPosition=function(){},Ht.prototype.needsContentAttribute=!0;function _s(e,t){var i=fa(e,t.line);if(!i||i.hidden)return null;var r=ht(e.doc,t.line),n=eo(i,r,t.line),E=et(r,e.doc.direction),B="left";if(E){var K=qe(E,t.ch);B=K%2?"right":"left"}var Y=io(n.map,t.ch,B);return Y.offset=Y.collapse=="right"?Y.end:Y.start,Y}function eu(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function ln(e,t){return t&&(e.bad=!0),e}function tu(e,t,i,r,n){var E="",B=!1,K=e.doc.lineSeparator(),Y=!1;function J(ye){return function(ke){return ke.id==ye}}function se(){B&&(E+=K,Y&&(E+=K),B=Y=!1)}function he(ye){ye&&(se(),E+=ye)}function be(ye){if(ye.nodeType==1){var ke=ye.getAttribute("cm-text");if(ke){he(ke);return}var Ne=ye.getAttribute("cm-marker"),je;if(Ne){var Xe=e.findMarks(Ue(r,0),Ue(n+1,0),J(+Ne));Xe.length&&(je=Xe[0].find(0))&&he(Hr(e.doc,je.from,je.to).join(K));return}if(ye.getAttribute("contenteditable")=="false")return;var nt=/^(pre|div|p|li|table|br)$/i.test(ye.nodeName);if(!/^br$/i.test(ye.nodeName)&&ye.textContent.length==0)return;nt&&se();for(var Ye=0;Ye<ye.childNodes.length;Ye++)be(ye.childNodes[Ye]);/^(pre|p)$/i.test(ye.nodeName)&&(Y=!0),nt&&(B=!0)}else ye.nodeType==3&&he(ye.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(be(t),t==i);)t=t.nextSibling,Y=!1;return E}function sa(e,t,i){var r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[i],!r)return ln(e.clipPos(Ue(e.display.viewTo-1)),!0);t=null,i=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(var n=0;n<e.display.view.length;n++){var E=e.display.view[n];if(E.node==r)return ru(E,t,i)}}function ru(e,t,i){var r=e.text.firstChild,n=!1;if(!t||!T(r,t))return ln(Ue(kt(e.line),0),!0);if(t==r&&(n=!0,t=r.childNodes[i],i=0,!t)){var E=e.rest?Re(e.rest):e.line;return ln(Ue(kt(E),E.text.length),n)}var B=t.nodeType==3?t:null,K=t;for(!B&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(B=t.firstChild,i&&(i=B.nodeValue.length));K.parentNode!=r;)K=K.parentNode;var Y=e.measure,J=Y.maps;function se(je,Xe,nt){for(var Ye=-1;Ye<(J?J.length:0);Ye++)for(var st=Ye<0?Y.map:J[Ye],Et=0;Et<st.length;Et+=3){var gt=st[Et+2];if(gt==je||gt==Xe){var At=kt(Ye<0?e.line:e.rest[Ye]),zt=st[Et]+nt;return(nt<0||gt!=je)&&(zt=st[Et+(nt?1:0)]),Ue(At,zt)}}}var he=se(B,K,i);if(he)return ln(he,n);for(var be=K.nextSibling,ye=B?B.nodeValue.length-i:0;be;be=be.nextSibling){if(he=se(be,be.firstChild,0),he)return ln(Ue(he.line,he.ch-ye),n);ye+=be.textContent.length}for(var ke=K.previousSibling,Ne=i;ke;ke=ke.previousSibling){if(he=se(ke,ke.firstChild,-1),he)return ln(Ue(he.line,he.ch+Ne),n);Ne+=ke.textContent.length}}var Qt=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new ae,this.hasSelection=!1,this.composing=null};Qt.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"),we(n,"input",function(){H&&F>=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),we(n,"paste",function(B){if(Le(r,B)||Ts(B,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function E(B){if(Le(r,B))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var K=ws(r);oa({lineWise:!0,text:K.text}),B.type=="cut"?r.setSelections(K.ranges,null,xe):(i.prevInput="",n.value=K.text.join(`
|
|
`),Q(n))}else return;B.type=="cut"&&(r.state.cutIncoming=+new Date)}we(n,"cut",E),we(n,"copy",E),we(e.scroller,"paste",function(B){if(ui(e,B)||Le(r,B))return;if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var K=new Event("paste");K.clipboardData=B.clipboardData,n.dispatchEvent(K)}),we(e.lineSpace,"selectstart",function(B){ui(e,B)||q(B)}),we(n,"compositionstart",function(){var B=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:B,range:r.markText(B,r.getCursor("to"),{className:"CodeMirror-composing"})}}),we(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},Qt.prototype.createField=function(e){this.wrapper=Ls(),this.textarea=this.wrapper.firstChild},Qt.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},Qt.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=mo(e);if(e.options.moveInputWithCursor){var n=Zr(e,i.sel.primary().head,"div"),E=t.wrapper.getBoundingClientRect(),B=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+B.top-E.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+B.left-E.left))}return r},Qt.prototype.showSelection=function(e){var t=this.cm,i=t.display;d(i.cursorDiv,e.cursors),d(i.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},Qt.prototype.reset=function(e){if(this.contextMenuPending||this.composing)return;var t=this.cm;if(t.somethingSelected()){this.prevInput="";var i=t.getSelection();this.textarea.value=i,t.state.focused&&Q(this.textarea),H&&F>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",H&&F>=9&&(this.hasSelection=null))},Qt.prototype.getField=function(){return this.textarea},Qt.prototype.supportsTouch=function(){return!1},Qt.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!a||I()!=this.textarea))try{this.textarea.focus()}catch(e){}},Qt.prototype.blur=function(){this.textarea.blur()},Qt.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Qt.prototype.receivedFocus=function(){this.slowPoll()},Qt.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()})},Qt.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)},Qt.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||ut(i)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var n=i.value;if(n==r&&!t.somethingSelected())return!1;if(H&&F>=9&&this.hasSelection===n||l&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var E=n.charCodeAt(0);if(E==8203&&!r&&(r="\u200B"),E==8666)return this.reset(),this.cm.execCommand("undo")}for(var B=0,K=Math.min(r.length,n.length);B<K&&r.charCodeAt(B)==n.charCodeAt(B);)++B;return Pr(t,function(){za(t,n.slice(B),r.length-B,null,e.composing?"*compose":null),n.length>1e3||n.indexOf(`
|
|
`)>-1?i.value=e.prevInput="":e.prevInput=n,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},Qt.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Qt.prototype.onKeyPress=function(){H&&F>=9&&(this.hasSelection=null),this.fastPoll()},Qt.prototype.onContextMenu=function(e){var t=this,i=t.cm,r=i.display,n=t.textarea;t.contextMenuPending&&t.contextMenuPending();var E=Ni(i,e),B=r.scroller.scrollTop;if(!E||A)return;var K=i.options.resetSelectionOnContextMenu;K&&i.doc.sel.contains(E)==-1&&or(i,br)(i.doc,wi(E),xe);var Y=n.style.cssText,J=t.wrapper.style.cssText,se=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;
|
|
top: `+(e.clientY-se.top-5)+"px; left: "+(e.clientX-se.left-5)+`px;
|
|
z-index: 1000; background: `+(H?"rgba(255, 255, 255, .05)":"transparent")+`;
|
|
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var he;P&&(he=window.scrollY),r.input.focus(),P&&window.scrollTo(null,he),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=ye,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function be(){if(n.selectionStart!=null){var Ne=i.somethingSelected(),je="\u200B"+(Ne?n.value:"");n.value="\u21DA",n.value=je,t.prevInput=Ne?"":"\u200B",n.selectionStart=1,n.selectionEnd=je.length,r.selForContextMenu=i.doc.sel}}function ye(){if(t.contextMenuPending!=ye)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=J,n.style.cssText=Y,H&&F<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=B),n.selectionStart!=null){(!H||H&&F<9)&&be();var Ne=0,je=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?or(i,Xo)(i):Ne++<10?r.detectingSelectAll=setTimeout(je,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(je,200)}}if(H&&F>=9&&be(),k){de(e);var ke=function(){tt(window,"mouseup",ke),setTimeout(ye,20)};we(window,"mouseup",ke)}else setTimeout(ye,50)},Qt.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},Qt.prototype.setUneditable=function(){},Qt.prototype.needsContentAttribute=!1;function iu(e,t){if(t=t?W(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){var i=I();t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=K.getValue()}var n;if(e.form&&(we(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var E=e.form;n=E.submit;try{var B=E.submit=function(){r(),E.submit=n,E.submit(),E.submit=B}}catch(Y){}}t.finishInit=function(Y){Y.save=r,Y.getTextArea=function(){return e},Y.toTextArea=function(){Y.toTextArea=isNaN,r(),e.parentNode.removeChild(Y.getWrapperElement()),e.style.display="",e.form&&(tt(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var K=Vt(function(Y){return e.parentNode.insertBefore(Y,e.nextSibling)},t);return K}function nu(e){e.off=tt,e.on=we,e.wheelEventPixels=dl,e.Doc=Lr,e.splitLines=Tt,e.countColumn=ee,e.findColumn=Se,e.isWordChar=Ie,e.Pass=De,e.signal=Te,e.Line=Pi,e.changeEnd=Ai,e.scrollbarModel=To,e.Pos=Ue,e.cmpPos=St,e.modes=Xt,e.mimeModes=Rt,e.resolveMode=bt,e.getMode=Nr,e.modeExtensions=hr,e.extendMode=pr,e.copyState=Br,e.startState=qr,e.innerMode=ci,e.commands=In,e.keyMap=hi,e.keyName=us,e.isModifierKey=ss,e.lookupKey=an,e.normalizeKeyMap=Pl,e.StringStream=It,e.SharedTextMarker=On,e.TextMarker=ki,e.LineWidget=Rn,e.e_preventDefault=q,e.e_stopPropagation=te,e.e_stop=de,e.addClass=G,e.contains=T,e.rmClass=f,e.keyNames=_i}$l(Vt),ql(Vt);var au="iter insert remove copy getEditor constructor".split(" ");for(var la in Lr.prototype)Lr.prototype.hasOwnProperty(la)&&pe(au,la)<0&&(Vt.prototype[la]=function(e){return function(){return e.apply(this.doc,arguments)}}(Lr.prototype[la]));return ue(Lr),Vt.inputStyles={textarea:Qt,contenteditable:Ht},Vt.defineMode=function(e){!Vt.defaults.mode&&e!="null"&&(Vt.defaults.mode=e),Ir.apply(this,arguments)},Vt.defineMIME=Kr,Vt.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Vt.defineMIME("text/plain","null"),Vt.defineExtension=function(e,t){Vt.prototype[e]=t},Vt.defineDocExtension=function(e,t){Lr.prototype[e]=t},Vt.fromTextArea=iu,nu(Vt),Vt.version="5.58.2",Vt})},Y1PL:function(xt,at,re){"use strict";re.r(at),re.d(at,"ResizableTextArea",function(){return pe});var ne=re("wx14"),$=re("1OyB"),_=re("vuIU"),V=re("Ji7U"),N=re("LK+K"),M=re("q1tI"),H=re("VTBJ"),F=re("rePB"),P=re("Zm9Q"),O=re("Kwbf"),b=re("c+Xe"),A=re("m+aA"),D=re("bdgK"),L=new Map;function w(xe){xe.forEach(function(Ce){var Ae,Se=Ce.target;(Ae=L.get(Se))===null||Ae===void 0||Ae.forEach(function(ge){return ge(Se)})})}var x=new D.default(w),u=null,a=null;function l(xe,Ce){L.has(xe)||(L.set(xe,new Set),x.observe(xe)),L.get(xe).add(Ce)}function h(xe,Ce){L.has(xe)&&(L.get(xe).delete(Ce),L.get(xe).size||(x.unobserve(xe),L.delete(xe)))}var C=function(xe){Object(V.a)(Ae,xe);var Ce=Object(N.a)(Ae);function Ae(){return Object($.a)(this,Ae),Ce.apply(this,arguments)}return Object(_.a)(Ae,[{key:"render",value:function(){return this.props.children}}]),Ae}(M.Component),g=M.createContext(null);function m(xe){var Ce=xe.children,Ae=xe.onBatchResize,Se=M.useRef(0),ge=M.useRef([]),oe=M.useContext(g),Re=M.useCallback(function(Ze,He,Ge){Se.current+=1;var $e=Se.current;ge.current.push({size:Ze,element:He,data:Ge}),Promise.resolve().then(function(){$e===Se.current&&(Ae==null||Ae(ge.current),ge.current=[])}),oe==null||oe(Ze,He,Ge)},[Ae,oe]);return M.createElement(g.Provider,{value:Re},Ce)}function k(xe){var Ce=xe.children,Ae=xe.disabled,Se=M.useRef(null),ge=M.useRef(null),oe=M.useContext(g),Re=M.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),Ze=M.isValidElement(Ce)&&Object(b.c)(Ce),He=Ze?Ce.ref:null,Ge=M.useMemo(function(){return Object(b.a)(He,Se)},[He,Se]),$e=M.useRef(xe);$e.current=xe;var _e=M.useCallback(function(Ie){var We=$e.current,Ve=We.onResize,ze=We.data,Be=Ie.getBoundingClientRect(),Fe=Be.width,ot=Be.height,it=Ie.offsetWidth,Je=Ie.offsetHeight,qe=Math.floor(Fe),ct=Math.floor(ot);if(Re.current.width!==qe||Re.current.height!==ct||Re.current.offsetWidth!==it||Re.current.offsetHeight!==Je){var et={width:qe,height:ct,offsetWidth:it,offsetHeight:Je};Re.current=et;var Qe=it===Math.round(Fe)?Fe:it,we=Je===Math.round(ot)?ot:Je,lt=Object(H.a)(Object(H.a)({},et),{},{offsetWidth:Qe,offsetHeight:we});oe==null||oe(lt,Ie,ze),Ve&&Promise.resolve().then(function(){Ve(lt,Ie)})}},[]);return M.useEffect(function(){var Ie=Object(A.a)(Se.current)||Object(A.a)(ge.current);return Ie&&!Ae&&l(Ie,_e),function(){return h(Ie,_e)}},[Se.current,Ae]),M.createElement(C,{ref:ge},Ze?M.cloneElement(Ce,{ref:Ge}):Ce)}var v="rc-observer-key";function f(xe){var Ce=xe.children,Ae=Object(P.a)(Ce);return Ae.map(function(Se,ge){var oe=(Se==null?void 0:Se.key)||"".concat(v,"-").concat(ge);return M.createElement(k,Object(ne.a)({},xe,{key:oe}),Se)})}f.Collection=m;var p=f,d=re("bT9E"),o=re("TSYQ"),S=re.n(o),y=`
|
|
min-height:0 !important;
|
|
max-height:none !important;
|
|
height:0 !important;
|
|
visibility:hidden !important;
|
|
overflow:hidden !important;
|
|
position:absolute !important;
|
|
z-index:-1000 !important;
|
|
top:0 !important;
|
|
right:0 !important
|
|
`,T=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","font-variant","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing","word-break"],I={},G;function X(xe){var Ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Ae=xe.getAttribute("id")||xe.getAttribute("data-reactid")||xe.getAttribute("name");if(Ce&&I[Ae])return I[Ae];var Se=window.getComputedStyle(xe),ge=Se.getPropertyValue("box-sizing")||Se.getPropertyValue("-moz-box-sizing")||Se.getPropertyValue("-webkit-box-sizing"),oe=parseFloat(Se.getPropertyValue("padding-bottom"))+parseFloat(Se.getPropertyValue("padding-top")),Re=parseFloat(Se.getPropertyValue("border-bottom-width"))+parseFloat(Se.getPropertyValue("border-top-width")),Ze=T.map(function(Ge){return"".concat(Ge,":").concat(Se.getPropertyValue(Ge))}).join(";"),He={sizingStyle:Ze,paddingSize:oe,borderSize:Re,boxSizing:ge};return Ce&&Ae&&(I[Ae]=He),He}function Q(xe){var Ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Ae=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,Se=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;G||(G=document.createElement("textarea"),G.setAttribute("tab-index","-1"),G.setAttribute("aria-hidden","true"),document.body.appendChild(G)),xe.getAttribute("wrap")?G.setAttribute("wrap",xe.getAttribute("wrap")):G.removeAttribute("wrap");var ge=X(xe,Ce),oe=ge.paddingSize,Re=ge.borderSize,Ze=ge.boxSizing,He=ge.sizingStyle;G.setAttribute("style","".concat(He,";").concat(y)),G.value=xe.value||xe.placeholder||"";var Ge=Number.MIN_SAFE_INTEGER,$e=Number.MAX_SAFE_INTEGER,_e=G.scrollHeight,Ie;if(Ze==="border-box"?_e+=Re:Ze==="content-box"&&(_e-=oe),Ae!==null||Se!==null){G.value=" ";var We=G.scrollHeight-oe;Ae!==null&&(Ge=We*Ae,Ze==="border-box"&&(Ge=Ge+oe+Re),_e=Math.max(Ge,_e)),Se!==null&&($e=We*Se,Ze==="border-box"&&($e=$e+oe+Re),Ie=_e>$e?"":"hidden",_e=Math.min($e,_e))}return{height:_e,minHeight:Ge,maxHeight:$e,overflowY:Ie,resize:"none"}}var z=re("Gytx"),W=re.n(z),ee;(function(xe){xe[xe.NONE=0]="NONE",xe[xe.RESIZING=1]="RESIZING",xe[xe.RESIZED=2]="RESIZED"})(ee||(ee={}));var ae=function(xe){Object(V.a)(Ae,xe);var Ce=Object(N.a)(Ae);function Ae(Se){var ge;return Object($.a)(this,Ae),ge=Ce.call(this,Se),ge.nextFrameActionId=void 0,ge.resizeFrameId=void 0,ge.textArea=void 0,ge.saveTextArea=function(oe){ge.textArea=oe},ge.handleResize=function(oe){var Re=ge.state.resizeStatus,Ze=ge.props,He=Ze.autoSize,Ge=Ze.onResize;if(Re!==ee.NONE)return;typeof Ge=="function"&&Ge(oe),He&&ge.resizeOnNextFrame()},ge.resizeOnNextFrame=function(){cancelAnimationFrame(ge.nextFrameActionId),ge.nextFrameActionId=requestAnimationFrame(ge.resizeTextarea)},ge.resizeTextarea=function(){var oe=ge.props.autoSize;if(!oe||!ge.textArea)return;var Re=oe.minRows,Ze=oe.maxRows,He=Q(ge.textArea,!1,Re,Ze);ge.setState({textareaStyles:He,resizeStatus:ee.RESIZING},function(){cancelAnimationFrame(ge.resizeFrameId),ge.resizeFrameId=requestAnimationFrame(function(){ge.setState({resizeStatus:ee.RESIZED},function(){ge.resizeFrameId=requestAnimationFrame(function(){ge.setState({resizeStatus:ee.NONE}),ge.fixFirefoxAutoScroll()})})})})},ge.renderTextArea=function(){var oe=ge.props,Re=oe.prefixCls,Ze=Re===void 0?"rc-textarea":Re,He=oe.autoSize,Ge=oe.onResize,$e=oe.className,_e=oe.disabled,Ie=ge.state,We=Ie.textareaStyles,Ve=Ie.resizeStatus,ze=Object(d.a)(ge.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Be=S()(Ze,$e,Object(F.a)({},"".concat(Ze,"-disabled"),_e));"value"in ze&&(ze.value=ze.value||"");var Fe=Object(H.a)(Object(H.a)(Object(H.a)({},ge.props.style),We),Ve===ee.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return M.createElement(p,{onResize:ge.handleResize,disabled:!(He||Ge)},M.createElement("textarea",Object(ne.a)({},ze,{className:Be,style:Fe,ref:ge.saveTextArea})))},ge.state={textareaStyles:{},resizeStatus:ee.NONE},ge}return Object(_.a)(Ae,[{key:"componentDidUpdate",value:function(ge){(ge.value!==this.props.value||!W()(ge.autoSize,this.props.autoSize))&&this.resizeTextarea()}},{key:"componentWillUnmount",value:function(){cancelAnimationFrame(this.nextFrameActionId),cancelAnimationFrame(this.resizeFrameId)}},{key:"fixFirefoxAutoScroll",value:function(){try{if(document.activeElement===this.textArea){var ge=this.textArea.selectionStart,oe=this.textArea.selectionEnd;this.textArea.setSelectionRange(ge,oe)}}catch(Re){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Ae}(M.Component),pe=ae,ve=function(xe){Object(V.a)(Ae,xe);var Ce=Object(N.a)(Ae);function Ae(Se){var ge;Object($.a)(this,Ae),ge=Ce.call(this,Se),ge.resizableTextArea=void 0,ge.focus=function(){ge.resizableTextArea.textArea.focus()},ge.saveTextArea=function(Re){ge.resizableTextArea=Re},ge.handleChange=function(Re){var Ze=ge.props.onChange;ge.setValue(Re.target.value,function(){ge.resizableTextArea.resizeTextarea()}),Ze&&Ze(Re)},ge.handleKeyDown=function(Re){var Ze=ge.props,He=Ze.onPressEnter,Ge=Ze.onKeyDown;Re.keyCode===13&&He&&He(Re),Ge&&Ge(Re)};var oe=typeof Se.value=="undefined"||Se.value===null?Se.defaultValue:Se.value;return ge.state={value:oe},ge}return Object(_.a)(Ae,[{key:"setValue",value:function(ge,oe){"value"in this.props||this.setState({value:ge},oe)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return M.createElement(pe,Object(ne.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(ge){return"value"in ge?{value:ge.value}:null}}]),Ae}(M.Component),De=at.default=ve},ZpRC:function(xt,at,re){"use strict";function ne(b){return typeof b=="object"&&b!=null&&b.nodeType===1}function $(b,A){return(!A||b!=="hidden")&&b!=="visible"&&b!=="clip"}function _(b,A){if(b.clientHeight<b.scrollHeight||b.clientWidth<b.scrollWidth){var D=getComputedStyle(b,null);return $(D.overflowY,A)||$(D.overflowX,A)||function(L){var w=function(x){if(!x.ownerDocument||!x.ownerDocument.defaultView)return null;try{return x.ownerDocument.defaultView.frameElement}catch(u){return null}}(L);return!!w&&(w.clientHeight<L.scrollHeight||w.clientWidth<L.scrollWidth)}(b)}return!1}function V(b,A,D,L,w,x,u,a){return x<b&&u>A||x>b&&u<A?0:x<=b&&a<=D||u>=A&&a>=D?x-b-L:u>A&&a<D||x<b&&a>D?u-A+w:0}var N=function(b,A){var D=window,L=A.scrollMode,w=A.block,x=A.inline,u=A.boundary,a=A.skipOverflowHiddenElements,l=typeof u=="function"?u:function(We){return We!==u};if(!ne(b))throw new TypeError("Invalid target");for(var h=document.scrollingElement||document.documentElement,C=[],g=b;ne(g)&&l(g);){if((g=g.parentElement)===h){C.push(g);break}g!=null&&g===document.body&&_(g)&&!_(document.documentElement)||g!=null&&_(g,a)&&C.push(g)}for(var m=D.visualViewport?D.visualViewport.width:innerWidth,k=D.visualViewport?D.visualViewport.height:innerHeight,v=window.scrollX||pageXOffset,f=window.scrollY||pageYOffset,p=b.getBoundingClientRect(),d=p.height,o=p.width,S=p.top,y=p.right,T=p.bottom,I=p.left,G=w==="start"||w==="nearest"?S:w==="end"?T:S+d/2,X=x==="center"?I+o/2:x==="end"?y:I,Q=[],z=0;z<C.length;z++){var W=C[z],ee=W.getBoundingClientRect(),ae=ee.height,pe=ee.width,ve=ee.top,De=ee.right,xe=ee.bottom,Ce=ee.left;if(L==="if-needed"&&S>=0&&I>=0&&T<=k&&y<=m&&S>=ve&&T<=xe&&I>=Ce&&y<=De)return Q;var Ae=getComputedStyle(W),Se=parseInt(Ae.borderLeftWidth,10),ge=parseInt(Ae.borderTopWidth,10),oe=parseInt(Ae.borderRightWidth,10),Re=parseInt(Ae.borderBottomWidth,10),Ze=0,He=0,Ge="offsetWidth"in W?W.offsetWidth-W.clientWidth-Se-oe:0,$e="offsetHeight"in W?W.offsetHeight-W.clientHeight-ge-Re:0;if(h===W)Ze=w==="start"?G:w==="end"?G-k:w==="nearest"?V(f,f+k,k,ge,Re,f+G,f+G+d,d):G-k/2,He=x==="start"?X:x==="center"?X-m/2:x==="end"?X-m:V(v,v+m,m,Se,oe,v+X,v+X+o,o),Ze=Math.max(0,Ze+f),He=Math.max(0,He+v);else{Ze=w==="start"?G-ve-ge:w==="end"?G-xe+Re+$e:w==="nearest"?V(ve,xe,ae,ge,Re+$e,G,G+d,d):G-(ve+ae/2)+$e/2,He=x==="start"?X-Ce-Se:x==="center"?X-(Ce+pe/2)+Ge/2:x==="end"?X-De+oe+Ge:V(Ce,De,pe,Se,oe+Ge,X,X+o,o);var _e=W.scrollLeft,Ie=W.scrollTop;G+=Ie-(Ze=Math.max(0,Math.min(Ie+Ze,W.scrollHeight-ae+$e))),X+=_e-(He=Math.max(0,Math.min(_e+He,W.scrollWidth-pe+Ge)))}Q.push({el:W,top:Ze,left:He})}return Q};function M(b){return b===Object(b)&&Object.keys(b).length!==0}function H(b,A){A===void 0&&(A="auto");var D="scrollBehavior"in document.body.style;b.forEach(function(L){var w=L.el,x=L.top,u=L.left;w.scroll&&D?w.scroll({top:x,left:u,behavior:A}):(w.scrollTop=x,w.scrollLeft=u)})}function F(b){return b===!1?{block:"end",inline:"nearest"}:M(b)?b:{block:"start",inline:"nearest"}}function P(b,A){var D=!b.ownerDocument.documentElement.contains(b);if(M(A)&&typeof A.behavior=="function")return A.behavior(D?[]:N(b,A));if(D)return;var L=F(A);return H(N(b,L),L.behavior)}var O=at.a=P},bNIU:function(xt,at,re){xt.exports={flex_box_center:"flex_box_center___4ZFPv",flex_space_between:"flex_space_between___1poVp",flex_box_vertical_center:"flex_box_vertical_center___2vHuy",flex_box_center_end:"flex_box_center_end___3AGfr",flex_box_column:"flex_box_column___9QgjS",bg:"bg___2D1BG",flexRow:"flexRow___3qWci",flexJustifyCenter:"flexJustifyCenter___ONt7G",flexAlignEnd:"flexAlignEnd___XXRbD",flexAlingCenter:"flexAlingCenter___3bK98",flexAlignCenter:"flexAlignCenter___2Ct2A",flexColumn:"flexColumn___JTR6P",formWrap:"formWrap___3QUHG",titleWrap:"titleWrap___1MIxp",fieldWrap:"fieldWrap___YXlbk",mdWrap:"mdWrap___ZlPmu",backgroundFa:"backgroundFa___2s4Lu",button:"button___KQ_S9",icons:"icons___zqUcb",navBar:"navBar___3taGH",active:"active____5MwL",tipWrap:"tipWrap___2wfhG",tip:"tip___3fuVl",width300:"width300___1tL-J",popover:"popover___2mWr7",groupWrap:"groupWrap___2zY7s",check:"check___3Eies"}},bT9E:function(xt,at,re){"use strict";re.d(at,"a",function(){return $});var ne=re("VTBJ");function $(_,V){var N=Object(ne.a)({},_);return Array.isArray(V)&&V.forEach(function(M){delete N[M]}),N}},c5Ni:function(xt,at,re){},dejd:function(xt,at,re){},dmUQ:function(xt,at,re){"use strict";var ne=re("Ff2n"),$=re("rePB"),_=re("1OyB"),V=re("vuIU"),N=re("Ji7U"),M=re("md7G"),H=re("foSv"),F=re("q1tI"),P=re.n(F),O=re("TSYQ"),b=re.n(O),A=re("4IlW");function D(d,o){var S=Object.keys(d);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(d);o&&(y=y.filter(function(T){return Object.getOwnPropertyDescriptor(d,T).enumerable})),S.push.apply(S,y)}return S}function L(d){for(var o=1;o<arguments.length;o++){var S=arguments[o]!=null?arguments[o]:{};o%2?D(Object(S),!0).forEach(function(y){Object($.a)(d,y,S[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(S)):D(Object(S)).forEach(function(y){Object.defineProperty(d,y,Object.getOwnPropertyDescriptor(S,y))})}return d}function w(d){var o=x();return function(){var y=Object(H.a)(d),T;if(o){var I=Object(H.a)(this).constructor;T=Reflect.construct(y,arguments,I)}else T=y.apply(this,arguments);return Object(M.a)(this,T)}}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(d){return!1}}function u(){}function a(d){d.preventDefault()}var l=function(o){return o.replace(/[^\w.-]+/g,"")},h=200,C=600,g=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,m=function(o){return o!=null},k=function(o,S){return S===o||typeof S=="number"&&typeof o=="number"&&isNaN(S)&&isNaN(o)},v=function(d){Object(N.a)(S,d);var o=w(S);function S(y){var T;Object(_.a)(this,S),T=o.call(this,y),T.onKeyDown=function(X){var Q=T.props,z=Q.onKeyDown,W=Q.onPressEnter;if(X.keyCode===A.a.UP){var ee=T.getRatio(X);T.up(X,ee,null),T.stop()}else if(X.keyCode===A.a.DOWN){var ae=T.getRatio(X);T.down(X,ae,null),T.stop()}else X.keyCode===A.a.ENTER&&W&&W(X);if(T.recordCursorPosition(),T.lastKeyCode=X.keyCode,z){for(var pe=arguments.length,ve=new Array(pe>1?pe-1:0),De=1;De<pe;De++)ve[De-1]=arguments[De];z.apply(void 0,[X].concat(ve))}},T.onKeyUp=function(X){var Q=T.props.onKeyUp;if(T.stop(),T.recordCursorPosition(),Q){for(var z=arguments.length,W=new Array(z>1?z-1:0),ee=1;ee<z;ee++)W[ee-1]=arguments[ee];Q.apply(void 0,[X].concat(W))}},T.onChange=function(X){var Q=T.props.onChange;T.state.focused&&(T.inputting=!0),T.rawInput=T.props.parser(T.getValueFromEvent(X)),T.setState({inputValue:T.rawInput}),Q(T.toNumber(T.rawInput))},T.onMouseUp=function(){var X=T.props.onMouseUp;T.recordCursorPosition(),X&&X.apply(void 0,arguments)},T.onFocus=function(){var X;T.setState({focused:!0}),(X=T.props).onFocus.apply(X,arguments)},T.onBlur=function(){var X=T.props.onBlur;T.inputting=!1,T.setState({focused:!1});var Q=T.getCurrentValidValue(T.state.inputValue),z=T.setValue(Q,u);if(X){var W=T.input.value,ee=T.getInputDisplayValue({focus:!1,value:z});T.input.value=ee&&Number(ee),X.apply(void 0,arguments),T.input.value=W}},T.getRatio=function(X){var Q=1;return X.metaKey||X.ctrlKey?Q=.1:X.shiftKey&&(Q=10),Q},T.getFullNum=function(X){return isNaN(X)?X:/e/i.test(String(X))?Number(X).toFixed(18).replace(/\.?0+$/,""):X},T.getPrecision=function(X){if(m(T.props.precision))return T.props.precision;var Q=String(X);if(Q.indexOf("e-")>=0)return parseInt(Q.slice(Q.indexOf("e-")+2),10);var z=0;return Q.indexOf(".")>=0&&(z=Q.length-Q.indexOf(".")-1),z},T.getInputDisplayValue=function(X){var Q=X||T.state,z=Q.focused,W=Q.inputValue,ee=Q.value,ae;z?ae=W:ae=T.toPrecisionAsStep(ee),ae==null&&(ae="");var pe=T.formatWrapper(ae);return m(T.props.decimalSeparator)&&(pe=pe.toString().replace(".",T.props.decimalSeparator)),pe},T.recordCursorPosition=function(){try{T.cursorStart=T.input.selectionStart,T.cursorEnd=T.input.selectionEnd,T.currentValue=T.input.value,T.cursorBefore=T.input.value.substring(0,T.cursorStart),T.cursorAfter=T.input.value.substring(T.cursorEnd)}catch(X){}},T.restoreByAfter=function(X){if(X===void 0)return!1;var Q=T.input.value,z=Q.lastIndexOf(X);if(z===-1)return!1;var W=T.cursorBefore.length;return T.lastKeyCode===A.a.DELETE&&T.cursorBefore.charAt(W-1)===X[0]?(T.fixCaret(W,W),!0):z+X.length===Q.length?(T.fixCaret(z,z),!0):!1},T.partRestoreByAfter=function(X){return X===void 0?!1:Array.prototype.some.call(X,function(Q,z){var W=X.substring(z);return T.restoreByAfter(W)})},T.isNotCompleteNumber=function(X){return isNaN(X)||X===""||X===null||X&&X.toString().indexOf(".")===X.toString().length-1},T.stop=function(){T.autoStepTimer&&clearTimeout(T.autoStepTimer)},T.down=function(X,Q,z){T.pressingUpOrDown=!0,T.step("down",X,Q,z)},T.up=function(X,Q,z){T.pressingUpOrDown=!0,T.step("up",X,Q,z)},T.saveInput=function(X){T.input=X};var I=y.value;I===void 0&&(I=y.defaultValue),T.state={focused:y.autoFocus};var G=T.getValidValue(T.toNumber(I));return T.state=L(L({},T.state),{},{inputValue:T.toPrecisionAsStep(G),value:G}),T}return Object(V.a)(S,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(T){var I=this.props,G=I.value,X=I.onChange,Q=I.max,z=I.min,W=this.state.focused;if(T){if(!k(T.value,G)||!k(T.max,Q)||!k(T.min,z)){var ee=W?G:this.getValidValue(G),ae;this.pressingUpOrDown?ae=ee:this.inputting?ae=this.rawInput:ae=this.toPrecisionAsStep(ee),this.setState({value:ee,inputValue:ae})}var pe="value"in this.props?G:this.state.value;"max"in this.props&&T.max!==Q&&typeof pe=="number"&&pe>Q&&X&&X(Q),"min"in this.props&&T.min!==z&&typeof pe=="number"&&pe<z&&X&&X(z)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var ve=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===A.a.BACKSPACE?ve=this.cursorStart-1:this.lastKeyCode===A.a.DELETE&&(ve=this.cursorStart):ve=this.input.value.length,this.fixCaret(ve,ve)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case A.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case A.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(De){}if(this.lastKeyCode=null,!this.pressingUpOrDown)return;this.props.focusOnUpDown&&this.state.focused&&(document.activeElement!==this.input&&this.focus())}},{key:"componentWillUnmount",value:function(){this.stop()}},{key:"getCurrentValidValue",value:function(T){var I=T;return I===""?I="":this.isNotCompleteNumber(parseFloat(I))?I=this.state.value:I=this.getValidValue(I),this.toNumber(I)}},{key:"getValueFromEvent",value:function(T){var I=T.target.value.trim().replace(/。/g,".");return m(this.props.decimalSeparator)&&(I=I.replace(this.props.decimalSeparator,".")),I}},{key:"getValidValue",value:function(T){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.props.min,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,X=parseFloat(T);return isNaN(X)?T:(X<I&&(X=I),X>G&&(X=G),X)}},{key:"setValue",value:function(T,I){var G=this.props.precision,X=this.isNotCompleteNumber(parseFloat(T))?null:parseFloat(T),Q=this.state.value,z=Q===void 0?null:Q,W=this.state.inputValue,ee=W===void 0?null:W,ae=typeof X=="number"?X.toFixed(G):"".concat(X),pe=X!==z||ae!=="".concat(ee);return"value"in this.props?(ee=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:ee},I)):this.setState({value:X,inputValue:this.toPrecisionAsStep(T)},I),pe&&this.props.onChange(X),X}},{key:"getMaxPrecision",value:function(T){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.props,X=G.precision,Q=G.step;if(m(X))return X;var z=this.getPrecision(I),W=this.getPrecision(Q),ee=this.getPrecision(T);return T?Math.max(ee,z+W):z+W}},{key:"getPrecisionFactor",value:function(T){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.getMaxPrecision(T,I);return Math.pow(10,G)}},{key:"focus",value:function(){this.input.focus(),this.recordCursorPosition()}},{key:"blur",value:function(){this.input.blur()}},{key:"select",value:function(){this.input.select()}},{key:"formatWrapper",value:function(T){return this.props.formatter?this.props.formatter(T):T}},{key:"toPrecisionAsStep",value:function(T){if(this.isNotCompleteNumber(T)||T==="")return T;var I=Math.abs(this.getMaxPrecision(T));return isNaN(I)?T.toString():Number(T).toFixed(I)}},{key:"toNumber",value:function(T){var I=this.props.precision,G=this.state.focused,X=T&&T.length>16&&G;return this.isNotCompleteNumber(T)||X?T:m(I)?Math.round(T*Math.pow(10,I))/Math.pow(10,I):Number(T)}},{key:"upStep",value:function(T,I){var G=this.props.step,X=this.getPrecisionFactor(T,I),Q=Math.abs(this.getMaxPrecision(T,I)),z=((X*T+X*G*I)/X).toFixed(Q);return this.toNumber(z)}},{key:"downStep",value:function(T,I){var G=this.props.step,X=this.getPrecisionFactor(T,I),Q=Math.abs(this.getMaxPrecision(T,I)),z=((X*T-X*G*I)/X).toFixed(Q);return this.toNumber(z)}},{key:"step",value:function(T,I){var G=this,X=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,Q=arguments.length>3?arguments[3]:void 0;this.stop(),I&&(I.persist(),I.preventDefault());var z=this.props;if(z.disabled)return;var W=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(W))return;var ee=this["".concat(T,"Step")](W,X),ae=ee>z.max||ee<z.min;if(ee>z.max?ee=z.max:ee<z.min&&(ee=z.min),this.setValue(ee,null),this.setState({focused:!0},function(){G.pressingUpOrDown=!1}),ae)return;this.autoStepTimer=setTimeout(function(){G[T](I,X,!0)},Q?h:C)}},{key:"fixCaret",value:function(T,I){if(T===void 0||I===void 0||!this.input||!this.input.value)return;try{var G=this.input.selectionStart,X=this.input.selectionEnd;(T!==G||I!==X)&&this.input.setSelectionRange(T,I)}catch(Q){}}},{key:"render",value:function(){var T,I=this.props,G=I.prefixCls,X=I.disabled,Q=I.readOnly,z=I.useTouch,W=I.autoComplete,ee=I.upHandler,ae=I.downHandler,pe=I.className,ve=I.max,De=I.min,xe=I.style,Ce=I.title,Ae=I.onMouseEnter,Se=I.onMouseLeave,ge=I.onMouseOver,oe=I.onMouseOut,Re=I.required,Ze=I.onClick,He=I.tabIndex,Ge=I.type,$e=I.placeholder,_e=I.id,Ie=I.inputMode,We=I.pattern,Ve=I.step,ze=I.maxLength,Be=I.autoFocus,Fe=I.name,ot=I.onPaste,it=I.onInput,Je=Object(ne.a)(I,["prefixCls","disabled","readOnly","useTouch","autoComplete","upHandler","downHandler","className","max","min","style","title","onMouseEnter","onMouseLeave","onMouseOver","onMouseOut","required","onClick","tabIndex","type","placeholder","id","inputMode","pattern","step","maxLength","autoFocus","name","onPaste","onInput"]),qe=this.state,ct=qe.value,et=qe.focused,Qe=b()(G,(T={},Object($.a)(T,pe,!!pe),Object($.a)(T,"".concat(G,"-disabled"),X),Object($.a)(T,"".concat(G,"-focused"),et),T)),we={};Object.keys(Je).forEach(function(de){(de.substr(0,5)==="data-"||de.substr(0,5)==="aria-"||de==="role")&&(we[de]=Je[de])});var lt=!Q&&!X,tt=this.getInputDisplayValue(null),Te=(ct||ct===0)&&(isNaN(ct)||Number(ct)>=ve),Le=(ct||ct===0)&&(isNaN(ct)||Number(ct)<=De),fe=Te||X||Q,le=Le||X||Q,ue=b()("".concat(G,"-handler"),"".concat(G,"-handler-up"),Object($.a)({},"".concat(G,"-handler-up-disabled"),fe)),q=b()("".concat(G,"-handler"),"".concat(G,"-handler-down"),Object($.a)({},"".concat(G,"-handler-down-disabled"),le)),te=z?{onTouchStart:fe?u:this.up,onTouchEnd:this.stop}:{onMouseDown:fe?u:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},ie=z?{onTouchStart:le?u:this.down,onTouchEnd:this.stop}:{onMouseDown:le?u:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return P.a.createElement("div",{className:Qe,style:xe,title:Ce,onMouseEnter:Ae,onMouseLeave:Se,onMouseOver:ge,onMouseOut:oe,onFocus:function(){return null},onBlur:function(){return null}},P.a.createElement("div",{className:"".concat(G,"-handler-wrap")},P.a.createElement("span",Object.assign({unselectable:"on"},te,{role:"button","aria-label":"Increase Value","aria-disabled":fe,className:ue}),ee||P.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-up-inner"),onClick:a})),P.a.createElement("span",Object.assign({unselectable:"on"},ie,{role:"button","aria-label":"Decrease Value","aria-disabled":le,className:q}),ae||P.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-down-inner"),onClick:a}))),P.a.createElement("div",{className:"".concat(G,"-input-wrap")},P.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":De,"aria-valuemax":ve,"aria-valuenow":ct,required:Re,type:Ge,placeholder:$e,onPaste:ot,onClick:Ze,onMouseUp:this.onMouseUp,className:"".concat(G,"-input"),tabIndex:He,autoComplete:W,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:lt?this.onKeyDown:u,onKeyUp:lt?this.onKeyUp:u,autoFocus:Be,maxLength:ze,readOnly:Q,disabled:X,max:ve,min:De,step:Ve,name:Fe,title:Ce,id:_e,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(tt),pattern:We,inputMode:Ie,onInput:it},we))))}}]),S}(P.a.Component);v.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:g,min:-g,step:1,style:{},onChange:u,onKeyDown:u,onPressEnter:u,onFocus:u,onBlur:u,parser:l,required:!1,autoComplete:"off"};var f=v,p=at.a=f},fnXi:function(xt,at,re){"use strict";var ne=re("2qtc"),$=re("kLXV"),_=re("q1tI"),V=re.n(_),N=re("Ty5D"),M=re("9kvl"),H=re("93VE"),F=re.n(H),P=function(b){var A=b.activeIndex,D=b.isEdit,L=D===void 0?!0:D,w=b.dispatch,x=b.practiceSetting,u=Object(N.i)(),a=u.id,l=u.challengesId,h=Object(_.useMemo)(function(){return[{name:"\u672C\u5173\u4EFB\u52A1",url:"/shixuns/".concat(a,"/edit/").concat(l,"/editcheckpoint")},{name:"\u8BC4\u6D4B\u8BBE\u7F6E",url:"/shixuns/".concat(a,"/edit/").concat(l,"/tab=2")},{name:"\u53C2\u8003\u7B54\u6848",url:"/shixuns/".concat(a,"/edit/").concat(l,"/tab=3")},{name:"\u5173\u5361\u6392\u884C\u699C",url:"/shixuns/".concat(a,"/edit/").concat(l,"/tab=4")}]},[a,l]),C=function(m){var k,v=function(){M.d.push(m),w({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})};x!=null&&(k=x.sideBar)!==null&&k!==void 0&&k.confirmLeave?$.a.confirm({title:"\u79BB\u5F00\u6B64\u9875\u63D0\u793A",content:"\u7CFB\u7EDF\u53EF\u80FD\u4E0D\u4F1A\u4FDD\u5B58\u60A8\u6240\u505A\u7684\u66F4\u6539\u3002",okText:"\u79BB\u5F00",cancelText:"\u53D6\u6D88",onOk:function(){v()}}):v()};return V.a.createElement("ul",{className:"challenge-nav"},L?h.map(function(g,m){return A===m?V.a.createElement("li",{key:g.url}," ",V.a.createElement("a",{className:"active"},g.name)," "):V.a.createElement("li",{key:g.url}," ",V.a.createElement("a",{onClick:function(){return C(g.url)}},g.name)," ")}):V.a.createElement("li",{key:h[0].url}," ",V.a.createElement("a",{className:"active"},h[0].name)," "))};at.a=Object(M.a)(function(O){var b=O.globalSetting,A=O.practiceSetting;return{globalSetting:b,practiceSetting:A}})(P)},kSUc:function(xt,at,re){},lZu9:function(xt,at,re){(function(ne){ne(re("VrN/"),re("1eCo"),re("8EBN"))})(function(ne){"use strict";ne.defineMode("markdown",function($,_){var V=ne.getMode($,"text/html"),N=V.name=="null";function M(z){if(ne.findModeByName){var W=ne.findModeByName(z);W&&(z=W.mime||W.mimes[0])}var ee=ne.getMode($,z);return ee.name=="null"?null:ee}_.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 H={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"image",imageAltText:"image-alt-text",imageMarker:"image-marker",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough",emoji:"builtin"};for(var F in H)H.hasOwnProperty(F)&&_.tokenTypeOverrides[F]&&(H[F]=_.tokenTypeOverrides[F]);var P=/^([*\-_])(?:\s*\1){2,}\s*$/,O=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,b=/^\[(x| )\](?=\s)/i,A=_.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,D=/^ {0,3}(?:\={1,}|-{2,})\s*$/,L=/^[^#!\[\]*_\\<>` "'(~:]+/,w=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,x=/^\s*\[[^\]]+?\]:.*$/,u=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/,a=" ";function l(z,W,ee){return W.f=W.inline=ee,ee(z,W)}function h(z,W,ee){return W.f=W.block=ee,ee(z,W)}function C(z){return!z||!/\S/.test(z.string)}function g(z){if(z.linkTitle=!1,z.linkHref=!1,z.linkText=!1,z.em=!1,z.strong=!1,z.strikethrough=!1,z.quote=0,z.indentedCode=!1,z.f==k){var W=N;if(!W){var ee=ne.innerMode(V,z.htmlState);W=ee.mode.name=="xml"&&ee.state.tagStart===null&&!ee.state.context&&ee.state.tokenize.isInText}W&&(z.f=d,z.block=m,z.htmlState=null)}return z.trailingSpace=0,z.trailingSpaceNewLine=!1,z.prevLine=z.thisLine,z.thisLine={stream:null},null}function m(z,W){var ee=z.column()===W.indentation,ae=C(W.prevLine.stream),pe=W.indentedCode,ve=W.prevLine.hr,De=W.list!==!1,xe=(W.listStack[W.listStack.length-1]||0)+3;W.indentedCode=!1;var Ce=W.indentation;if(W.indentationDiff===null&&(W.indentationDiff=W.indentation,De)){for(W.list=null;Ce<W.listStack[W.listStack.length-1];)W.listStack.pop(),W.listStack.length?W.indentation=W.listStack[W.listStack.length-1]:W.list=!1;W.list!==!1&&(W.indentationDiff=Ce-W.listStack[W.listStack.length-1])}var Ae=!ae&&!ve&&!W.prevLine.header&&(!De||!pe)&&!W.prevLine.fencedCodeEnd,Se=(W.list===!1||ve||ae)&&W.indentation<=xe&&z.match(P),ge=null;if(W.indentationDiff>=4&&(pe||W.prevLine.fencedCodeEnd||W.prevLine.header||ae))return z.skipToEnd(),W.indentedCode=!0,H.code;if(z.eatSpace())return null;if(ee&&W.indentation<=xe&&(ge=z.match(A))&&ge[1].length<=6)return W.quote=0,W.header=ge[1].length,W.thisLine.header=!0,_.highlightFormatting&&(W.formatting="header"),W.f=W.inline,f(W);if(W.indentation<=xe&&z.eat(">"))return W.quote=ee?1:W.quote+1,_.highlightFormatting&&(W.formatting="quote"),z.eatSpace(),f(W);if(!Se&&!W.setext&&ee&&W.indentation<=xe&&(ge=z.match(O))){var oe=ge[1]?"ol":"ul";return W.indentation=Ce+z.current().length,W.list=!0,W.quote=0,W.listStack.push(W.indentation),W.em=!1,W.strong=!1,W.code=!1,W.strikethrough=!1,_.taskLists&&z.match(b,!1)&&(W.taskList=!0),W.f=W.inline,_.highlightFormatting&&(W.formatting=["list","list-"+oe]),f(W)}else{if(ee&&W.indentation<=xe&&(ge=z.match(w,!0)))return W.quote=0,W.fencedEndRE=new RegExp(ge[1]+"+ *$"),W.localMode=_.fencedCodeBlockHighlighting&&M(ge[2]||_.fencedCodeBlockDefaultMode),W.localMode&&(W.localState=ne.startState(W.localMode)),W.f=W.block=v,_.highlightFormatting&&(W.formatting="code-block"),W.code=-1,f(W);if(W.setext||(!Ae||!De)&&!W.quote&&W.list===!1&&!W.code&&!Se&&!x.test(z.string)&&(ge=z.lookAhead(1))&&(ge=ge.match(D)))return W.setext?(W.header=W.setext,W.setext=0,z.skipToEnd(),_.highlightFormatting&&(W.formatting="header")):(W.header=ge[0].charAt(0)=="="?1:2,W.setext=W.header),W.thisLine.header=!0,W.f=W.inline,f(W);if(Se)return z.skipToEnd(),W.hr=!0,W.thisLine.hr=!0,H.hr;if(z.peek()==="[")return l(z,W,I)}return l(z,W,W.inline)}function k(z,W){var ee=V.token(z,W.htmlState);if(!N){var ae=ne.innerMode(V,W.htmlState);(ae.mode.name=="xml"&&ae.state.tagStart===null&&!ae.state.context&&ae.state.tokenize.isInText||W.md_inside&&z.current().indexOf(">")>-1)&&(W.f=d,W.block=m,W.htmlState=null)}return ee}function v(z,W){var ee=W.listStack[W.listStack.length-1]||0,ae=W.indentation<ee,pe=ee+3;if(W.fencedEndRE&&W.indentation<=pe&&(ae||z.match(W.fencedEndRE))){_.highlightFormatting&&(W.formatting="code-block");var ve;return ae||(ve=f(W)),W.localMode=W.localState=null,W.block=m,W.f=d,W.fencedEndRE=null,W.code=0,W.thisLine.fencedCodeEnd=!0,ae?h(z,W,W.block):ve}else return W.localMode?W.localMode.token(z,W.localState):(z.skipToEnd(),H.code)}function f(z){var W=[];if(z.formatting){W.push(H.formatting),typeof z.formatting=="string"&&(z.formatting=[z.formatting]);for(var ee=0;ee<z.formatting.length;ee++)W.push(H.formatting+"-"+z.formatting[ee]),z.formatting[ee]==="header"&&W.push(H.formatting+"-"+z.formatting[ee]+"-"+z.header),z.formatting[ee]==="quote"&&(!_.maxBlockquoteDepth||_.maxBlockquoteDepth>=z.quote?W.push(H.formatting+"-"+z.formatting[ee]+"-"+z.quote):W.push("error"))}if(z.taskOpen)return W.push("meta"),W.length?W.join(" "):null;if(z.taskClosed)return W.push("property"),W.length?W.join(" "):null;if(z.linkHref?W.push(H.linkHref,"url"):(z.strong&&W.push(H.strong),z.em&&W.push(H.em),z.strikethrough&&W.push(H.strikethrough),z.emoji&&W.push(H.emoji),z.linkText&&W.push(H.linkText),z.code&&W.push(H.code),z.image&&W.push(H.image),z.imageAltText&&W.push(H.imageAltText,"link"),z.imageMarker&&W.push(H.imageMarker)),z.header&&W.push(H.header,H.header+"-"+z.header),z.quote&&(W.push(H.quote),!_.maxBlockquoteDepth||_.maxBlockquoteDepth>=z.quote?W.push(H.quote+"-"+z.quote):W.push(H.quote+"-"+_.maxBlockquoteDepth)),z.list!==!1){var ae=(z.listStack.length-1)%3;ae?ae===1?W.push(H.list2):W.push(H.list3):W.push(H.list1)}return z.trailingSpaceNewLine?W.push("trailing-space-new-line"):z.trailingSpace&&W.push("trailing-space-"+(z.trailingSpace%2?"a":"b")),W.length?W.join(" "):null}function p(z,W){return z.match(L,!0)?f(W):void 0}function d(z,W){var ee=W.text(z,W);if(typeof ee!="undefined")return ee;if(W.list)return W.list=null,f(W);if(W.taskList){var ae=z.match(b,!0)[1]===" ";return ae?W.taskOpen=!0:W.taskClosed=!0,_.highlightFormatting&&(W.formatting="task"),W.taskList=!1,f(W)}if(W.taskOpen=!1,W.taskClosed=!1,W.header&&z.match(/^#+$/,!0))return _.highlightFormatting&&(W.formatting="header"),f(W);var pe=z.next();if(W.linkTitle){W.linkTitle=!1;var ve=pe;pe==="("&&(ve=")"),ve=(ve+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var De="^\\s*(?:[^"+ve+"\\\\]+|\\\\\\\\|\\\\.)"+ve;if(z.match(new RegExp(De),!0))return H.linkHref}if(pe==="`"){var xe=W.formatting;_.highlightFormatting&&(W.formatting="code"),z.eatWhile("`");var Ce=z.current().length;if(W.code==0&&(!W.quote||Ce==1))return W.code=Ce,f(W);if(Ce==W.code){var Ae=f(W);return W.code=0,Ae}else return W.formatting=xe,f(W)}else if(W.code)return f(W);if(pe==="\\"&&(z.next(),_.highlightFormatting)){var Se=f(W),ge=H.formatting+"-escape";return Se?Se+" "+ge:ge}if(pe==="!"&&z.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return W.imageMarker=!0,W.image=!0,_.highlightFormatting&&(W.formatting="image"),f(W);if(pe==="["&&W.imageMarker&&z.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return W.imageMarker=!1,W.imageAltText=!0,_.highlightFormatting&&(W.formatting="image"),f(W);if(pe==="]"&&W.imageAltText){_.highlightFormatting&&(W.formatting="image");var Se=f(W);return W.imageAltText=!1,W.image=!1,W.inline=W.f=S,Se}if(pe==="["&&!W.image)return W.linkText&&z.match(/^.*?\]/)||(W.linkText=!0,_.highlightFormatting&&(W.formatting="link")),f(W);if(pe==="]"&&W.linkText){_.highlightFormatting&&(W.formatting="link");var Se=f(W);return W.linkText=!1,W.inline=W.f=z.match(/\(.*?\)| ?\[.*?\]/,!1)?S:d,Se}if(pe==="<"&&z.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){W.f=W.inline=o,_.highlightFormatting&&(W.formatting="link");var Se=f(W);return Se?Se+=" ":Se="",Se+H.linkInline}if(pe==="<"&&z.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){W.f=W.inline=o,_.highlightFormatting&&(W.formatting="link");var Se=f(W);return Se?Se+=" ":Se="",Se+H.linkEmail}if(_.xml&&pe==="<"&&z.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var oe=z.string.indexOf(">",z.pos);if(oe!=-1){var Re=z.string.substring(z.start,oe);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(Re)&&(W.md_inside=!0)}return z.backUp(1),W.htmlState=ne.startState(V),h(z,W,k)}if(_.xml&&pe==="<"&&z.match(/^\/\w*?>/))return W.md_inside=!1,"tag";if(pe==="*"||pe==="_"){for(var Ze=1,He=z.pos==1?" ":z.string.charAt(z.pos-2);Ze<3&&z.eat(pe);)Ze++;var Ge=z.peek()||" ",$e=!/\s/.test(Ge)&&(!u.test(Ge)||/\s/.test(He)||u.test(He)),_e=!/\s/.test(He)&&(!u.test(He)||/\s/.test(Ge)||u.test(Ge)),Ie=null,We=null;if(Ze%2&&(!W.em&&$e&&(pe==="*"||!_e||u.test(He))?Ie=!0:W.em==pe&&_e&&(pe==="*"||!$e||u.test(Ge))&&(Ie=!1)),Ze>1&&(!W.strong&&$e&&(pe==="*"||!_e||u.test(He))?We=!0:W.strong==pe&&_e&&(pe==="*"||!$e||u.test(Ge))&&(We=!1)),We!=null||Ie!=null){_.highlightFormatting&&(W.formatting=Ie==null?"strong":We==null?"em":"strong em"),Ie===!0&&(W.em=pe),We===!0&&(W.strong=pe);var Ae=f(W);return Ie===!1&&(W.em=!1),We===!1&&(W.strong=!1),Ae}}else if(pe===" "&&(z.eat("*")||z.eat("_"))){if(z.peek()===" ")return f(W);z.backUp(1)}if(_.strikethrough){if(pe==="~"&&z.eatWhile(pe)){if(W.strikethrough){_.highlightFormatting&&(W.formatting="strikethrough");var Ae=f(W);return W.strikethrough=!1,Ae}else if(z.match(/^[^\s]/,!1))return W.strikethrough=!0,_.highlightFormatting&&(W.formatting="strikethrough"),f(W)}else if(pe===" "&&z.match(/^~~/,!0)){if(z.peek()===" ")return f(W);z.backUp(2)}}if(_.emoji&&pe===":"&&z.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){W.emoji=!0,_.highlightFormatting&&(W.formatting="emoji");var Ve=f(W);return W.emoji=!1,Ve}return pe===" "&&(z.match(/^ +$/,!1)?W.trailingSpace++:W.trailingSpace&&(W.trailingSpaceNewLine=!0)),f(W)}function o(z,W){var ee=z.next();if(ee===">"){W.f=W.inline=d,_.highlightFormatting&&(W.formatting="link");var ae=f(W);return ae?ae+=" ":ae="",ae+H.linkInline}return z.match(/^[^>]+/,!0),H.linkInline}function S(z,W){if(z.eatSpace())return null;var ee=z.next();return ee==="("||ee==="["?(W.f=W.inline=T(ee==="("?")":"]"),_.highlightFormatting&&(W.formatting="link-string"),W.linkHref=!0,f(W)):"error"}var y={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function T(z){return function(W,ee){var ae=W.next();if(ae===z){ee.f=ee.inline=d,_.highlightFormatting&&(ee.formatting="link-string");var pe=f(ee);return ee.linkHref=!1,pe}return W.match(y[z]),ee.linkHref=!0,f(ee)}}function I(z,W){return z.match(/^([^\]\\]|\\.)*\]:/,!1)?(W.f=G,z.next(),_.highlightFormatting&&(W.formatting="link"),W.linkText=!0,f(W)):l(z,W,d)}function G(z,W){if(z.match(/^\]:/,!0)){W.f=W.inline=X,_.highlightFormatting&&(W.formatting="link");var ee=f(W);return W.linkText=!1,ee}return z.match(/^([^\]\\]|\\.)+/,!0),H.linkText}function X(z,W){return z.eatSpace()?null:(z.match(/^[^\s]+/,!0),z.peek()===void 0?W.linkTitle=!0:z.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),W.f=W.inline=d,H.linkHref+" url")}var Q={startState:function(){return{f:m,prevLine:{stream:null},thisLine:{stream:null},block:m,htmlState:null,indentation:0,inline:d,text:p,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(z){return{f:z.f,prevLine:z.prevLine,thisLine:z.thisLine,block:z.block,htmlState:z.htmlState&&ne.copyState(V,z.htmlState),indentation:z.indentation,localMode:z.localMode,localState:z.localMode?ne.copyState(z.localMode,z.localState):null,inline:z.inline,text:z.text,formatting:!1,linkText:z.linkText,linkTitle:z.linkTitle,linkHref:z.linkHref,code:z.code,em:z.em,strong:z.strong,strikethrough:z.strikethrough,emoji:z.emoji,header:z.header,setext:z.setext,hr:z.hr,taskList:z.taskList,list:z.list,listStack:z.listStack.slice(0),quote:z.quote,indentedCode:z.indentedCode,trailingSpace:z.trailingSpace,trailingSpaceNewLine:z.trailingSpaceNewLine,md_inside:z.md_inside,fencedEndRE:z.fencedEndRE}},token:function(z,W){if(W.formatting=!1,z!=W.thisLine.stream){if(W.header=0,W.hr=!1,z.match(/^\s*$/,!0))return g(W),null;if(W.prevLine=W.thisLine,W.thisLine={stream:z},W.taskList=!1,W.trailingSpace=0,W.trailingSpaceNewLine=!1,!W.localState&&(W.f=W.block,W.f!=k)){var ee=z.match(/^\s*/,!0)[0].replace(/\t/g,a).length;if(W.indentation=ee,W.indentationDiff=null,ee>0)return null}}return W.f(z,W)},innerMode:function(z){return z.block==k?{state:z.htmlState,mode:V}:z.localState?{state:z.localState,mode:z.localMode}:{state:z,mode:Q}},indent:function(z,W,ee){return z.block==k&&V.indent?V.indent(z.htmlState,W,ee):z.localState&&z.localMode.indent?z.localMode.indent(z.localState,W,ee):ne.Pass},blankLine:g,getType:f,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return Q},"xml"),ne.defineMIME("text/markdown","markdown"),ne.defineMIME("text/x-markdown","markdown")})},nuEh:function(xt,at,re){"use strict";var ne=re("T2oS"),$=re("W9HT"),_=re("q1tI"),V=re.n(_),N=re("F8wB"),M=re.n(N),H=function(P){var O=P.loading;return O?V.a.createElement("div",{className:M.a.loading},V.a.createElement($.a,null)):V.a.createElement(V.a.Fragment,null)};at.a=H},osHv:function(xt,at,re){(function(ne){ne(re("VrN/"))})(function(ne){"use strict";var $=ne.Pos;function _(u,a){return u.line-a.line||u.ch-a.ch}var V="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",N=V+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",M=new RegExp("<(/?)(["+V+"]["+N+"]*)","g");function H(u,a,l,h){this.line=a,this.ch=l,this.cm=u,this.text=u.getLine(a),this.min=h?Math.max(h.from,u.firstLine()):u.firstLine(),this.max=h?Math.min(h.to-1,u.lastLine()):u.lastLine()}function F(u,a){var l=u.cm.getTokenTypeAt($(u.line,a));return l&&/\btag\b/.test(l)}function P(u){return u.line>=u.max?void 0:(u.ch=0,u.text=u.cm.getLine(++u.line),!0)}function O(u){return u.line<=u.min?void 0:(u.text=u.cm.getLine(--u.line),u.ch=u.text.length,!0)}function b(u){for(;;){var a=u.text.indexOf(">",u.ch);if(a==-1){if(P(u))continue;return}if(!F(u,a+1)){u.ch=a+1;continue}var l=u.text.lastIndexOf("/",a),h=l>-1&&!/\S/.test(u.text.slice(l+1,a));return u.ch=a+1,h?"selfClose":"regular"}}function A(u){for(;;){var a=u.ch?u.text.lastIndexOf("<",u.ch-1):-1;if(a==-1){if(O(u))continue;return}if(!F(u,a+1)){u.ch=a;continue}M.lastIndex=a,u.ch=a;var l=M.exec(u.text);if(l&&l.index==a)return l}}function D(u){for(;;){M.lastIndex=u.ch;var a=M.exec(u.text);if(!a){if(P(u))continue;return}if(!F(u,a.index+1)){u.ch=a.index+1;continue}return u.ch=a.index+a[0].length,a}}function L(u){for(;;){var a=u.ch?u.text.lastIndexOf(">",u.ch-1):-1;if(a==-1){if(O(u))continue;return}if(!F(u,a+1)){u.ch=a;continue}var l=u.text.lastIndexOf("/",a),h=l>-1&&!/\S/.test(u.text.slice(l+1,a));return u.ch=a+1,h?"selfClose":"regular"}}function w(u,a){for(var l=[];;){var h=D(u),C,g=u.line,m=u.ch-(h?h[0].length:0);if(!h||!(C=b(u)))return;if(C=="selfClose")continue;if(h[1]){for(var k=l.length-1;k>=0;--k)if(l[k]==h[2]){l.length=k;break}if(k<0&&(!a||a==h[2]))return{tag:h[2],from:$(g,m),to:$(u.line,u.ch)}}else l.push(h[2])}}function x(u,a){for(var l=[];;){var h=L(u);if(!h)return;if(h=="selfClose"){A(u);continue}var C=u.line,g=u.ch,m=A(u);if(!m)return;if(m[1])l.push(m[2]);else{for(var k=l.length-1;k>=0;--k)if(l[k]==m[2]){l.length=k;break}if(k<0&&(!a||a==m[2]))return{tag:m[2],from:$(u.line,u.ch),to:$(C,g)}}}}ne.registerHelper("fold","xml",function(u,a){for(var l=new H(u,a.line,0);;){var h=D(l);if(!h||l.line!=a.line)return;var C=b(l);if(!C)return;if(!h[1]&&C!="selfClose"){var g=$(l.line,l.ch),m=w(l,h[2]);return m&&_(m.from,g)>0?{from:g,to:m.from}:null}}}),ne.findMatchingTag=function(u,a,l){var h=new H(u,a.line,a.ch,l);if(h.text.indexOf(">")==-1&&h.text.indexOf("<")==-1)return;var C=b(h),g=C&&$(h.line,h.ch),m=C&&A(h);if(!C||!m||_(h,a)>0)return;var k={from:$(h.line,h.ch),to:g,tag:m[2]};return C=="selfClose"?{open:k,close:null,at:"open"}:m[1]?{open:x(h,m[2]),close:k,at:"close"}:(h=new H(u,g.line,g.ch,l),{open:k,close:w(h,m[2]),at:"open"})},ne.findEnclosingTag=function(u,a,l,h){for(var C=new H(u,a.line,a.ch,l);;){var g=x(C,h);if(!g)break;var m=new H(u,a.line,a.ch,l),k=w(m,g.tag);if(k)return{open:g,close:k}}},ne.scanForClosingTag=function(u,a,l,h){var C=new H(u,a.line,a.ch,h?{from:0,to:h}:null);return w(C,l)}})},p5ED:function(xt,at,re){"use strict";var ne=re("+L6B"),$=re("2/Rp"),_=re("5Dmo"),V=re("3S7+"),N=re("k1fw"),M=re("tJVT"),H=re("q1tI"),F=re.n(H),P=re("vHTk"),O=re.n(P),b=re("yEEn"),A=re("ZW9T"),D=re("1vsH");at.a=function(L){var w=L.name,x=L.data,u=L.theme,a=L.type,l=L.filename,h=L.monacoEditor,C=L.className,g=L.style,m=L.close,k=L.onClose,v=L.hasMask,f=Object(H.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),p=Object(M.a)(f,2),d=p[0],o=p[1],S=Object(H.useState)(""),y=Object(M.a)(S,2),T=y[0],I=y[1],G,X=1024*1024,Q=10*X,z=Object(H.useRef)();a==="office"&&(G=Object(D.T)(x).filesize,G>Q&&(a="other")),l&&(h.filename=l),Object(H.useEffect)(function(){var ae,pe,ve=(ae=document.cookie)===null||ae===void 0||((pe=ae.replace(/\s/g,""))===null||pe===void 0)?void 0:pe.split(";");ve==null||ve.map(function(De){var xe=De.split("=");xe[0]==="_educoder_session"&&I(xe[1])})},[]);var W=function(){if(x.startsWith("http")||x.startsWith("/")){ee();return}Object(D.z)(l||"educoder",x,l)},ee=function(){Object(D.x)(l||w,x)};return console.log("data:",x,"fileanme:",l," name:",w),F.a.createElement("div",{style:Object(N.a)({},g||{}),className:"".concat(v&&O.a.bgBlack," ").concat(a?O.a.wrp:"hide")},m&&F.a.createElement("div",{className:O.a.close,ref:z},F.a.createElement(V.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return z.current}},F.a.createElement("span",{onClick:ee},F.a.createElement("i",{className:"icon-quxiaozhiding"}))),F.a.createElement(V.a,{title:"\u5173\u95ED",getPopupContainer:function(){return z.current}},F.a.createElement("span",{className:"",onClick:k},F.a.createElement("i",{className:"icon-guanbi1"})))),F.a.createElement("div",{className:"".concat(O.a[C]," ").concat(C," ").concat(O.a.monaco," ").concat(a==="txt"?"show":"hide")},a==="txt"&&F.a.createElement(A.b,h)),a==="audio"&&F.a.createElement("audio",{src:"".concat(x!=null&&x.startsWith("/")||(x==null?void 0:x.indexOf("https://"))>-1?x:"data:audio/mp3;base64,").concat(x),autoPlay:!0}),a==="video"&&F.a.createElement(F.a.Fragment,null,x!=null&&x.startsWith("/")?F.a.createElement("video",{controls:!0,src:"".concat(x),autoPlay:!0}):F.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(x),autoPlay:!0})),a==="html"&&F.a.createElement("iframe",{src:x+"&disposition=inline"}),a==="pdf"&&F.a.createElement("embed",{className:O.a.embed,src:x}),a==="image"&&F.a.createElement(F.a.Fragment,null,F.a.createElement("img",{src:"".concat(x!=null&&x.startsWith("/")||(x==null?void 0:x.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(x)})),a==="other"&&F.a.createElement("div",null,F.a.createElement($.a,{type:"primary",size:"large",onClick:W},F.a.createElement(b.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),(a==="download"||a==="office")&&F.a.createElement($.a,{type:"primary",size:"large",onClick:W},F.a.createElement(b.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(xt,at,re){},rUJ1:function(xt,at){const re=/[&<>"']/,ne=/[&<>"']/g,$=/[<>"']|&(?!#?\w+;)/,_=/[<>"']|&(?!#?\w+;)/g,V={"&":"&","<":"<",">":">",'"':""","'":"'"},N=v=>V[v];function M(v,f){if(f){if(re.test(v))return v.replace(ne,N)}else if($.test(v))return v.replace(_,N);return v}const H=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function F(v){return v.replace(H,(f,p)=>(p=p.toLowerCase(),p==="colon"?":":p.charAt(0)==="#"?p.charAt(1)==="x"?String.fromCharCode(parseInt(p.substring(2),16)):String.fromCharCode(+p.substring(1)):""))}const P=/(^|[^\[])\^/g;function O(v,f){v=v.source||v,f=f||"";const p={replace:(d,o)=>(o=o.source||o,o=o.replace(P,"$1"),v=v.replace(d,o),p),getRegex:()=>new RegExp(v,f)};return p}const b=/[^\w:]/g,A=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function D(v,f,p){if(v){let d;try{d=decodeURIComponent(F(p)).replace(b,"").toLowerCase()}catch(o){return null}if(d.indexOf("javascript:")===0||d.indexOf("vbscript:")===0||d.indexOf("data:")===0)return null}f&&!A.test(p)&&(p=a(f,p));try{p=encodeURI(p).replace(/%25/g,"%")}catch(d){return null}return p}const L={},w=/^[^:]+:\/*[^/]*$/,x=/^([^:]+:)[\s\S]*$/,u=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(v,f){L[" "+v]||(w.test(v)?L[" "+v]=v+"/":L[" "+v]=g(v,"/",!0)),v=L[" "+v];const p=v.indexOf(":")===-1;return f.substring(0,2)==="//"?p?f:v.replace(x,"$1")+f:f.charAt(0)==="/"?p?f:v.replace(u,"$1")+f:v+f}const l={exec:function(){}};function h(v){let f=1,p,d;for(;f<arguments.length;f++){p=arguments[f];for(d in p)Object.prototype.hasOwnProperty.call(p,d)&&(v[d]=p[d])}return v}function C(v,f){const p=v.replace(/\|/g,(S,y,T)=>{let I=!1,G=y;for(;--G>=0&&T[G]==="\\";)I=!I;return I?"|":" |"}),d=p.split(/ \|/);let o=0;if(d.length>f)d.splice(f);else for(;d.length<f;)d.push("");for(;o<d.length;o++)d[o]=d[o].trim().replace(/\\\|/g,"|");return d}function g(v,f,p){const d=v.length;if(d===0)return"";let o=0;for(;o<d;){const S=v.charAt(d-o-1);if(S===f&&!p)o++;else if(S!==f&&p)o++;else break}return v.substr(0,d-o)}function m(v,f){if(v.indexOf(f[1])===-1)return-1;const p=v.length;let d=0,o=0;for(;o<p;o++)if(v[o]==="\\")o++;else if(v[o]===f[0])d++;else if(v[o]===f[1]&&(d--,d<0))return o;return-1}function k(v){v&&v.sanitize&&!v.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}xt.exports={escape:M,unescape:F,edit:O,cleanUrl:D,resolveUrl:a,noopTest:l,merge:h,splitCells:C,rtrim:g,findClosingBracket:m,checkSanitizeDeprecation:k}},ulZh:function(xt,at,re){typeof window!="undefined"&&function($,_){xt.exports=_()}(this,function(){return function(ne){var $={};function _(V){if($[V])return $[V].exports;var N=$[V]={i:V,l:!1,exports:{}};return ne[V].call(N.exports,N,N.exports,_),N.l=!0,N.exports}return _.m=ne,_.c=$,_.d=function(V,N,M){_.o(V,N)||Object.defineProperty(V,N,{enumerable:!0,get:M})},_.r=function(V){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(V,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(V,"__esModule",{value:!0})},_.t=function(V,N){if(N&1&&(V=_(V)),N&8)return V;if(N&4&&typeof V=="object"&&V&&V.__esModule)return V;var M=Object.create(null);if(_.r(M),Object.defineProperty(M,"default",{enumerable:!0,value:V}),N&2&&typeof V!="string")for(var H in V)_.d(M,H,function(F){return V[F]}.bind(null,H));return M},_.n=function(V){var N=V&&V.__esModule?function(){return V.default}:function(){return V};return _.d(N,"a",N),N},_.o=function(V,N){return Object.prototype.hasOwnProperty.call(V,N)},_.p="/dist/",_(_.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(ne,$,_){"use strict";var V=Object.prototype.hasOwnProperty,N="~";function M(){}Object.create&&(M.prototype=Object.create(null),new M().__proto__||(N=!1));function H(b,A,D){this.fn=b,this.context=A,this.once=D||!1}function F(b,A,D,L,w){if(typeof D!="function")throw new TypeError("The listener must be a function");var x=new H(D,L||b,w),u=N?N+A:A;return b._events[u]?b._events[u].fn?b._events[u]=[b._events[u],x]:b._events[u].push(x):(b._events[u]=x,b._eventsCount++),b}function P(b,A){--b._eventsCount===0?b._events=new M:delete b._events[A]}function O(){this._events=new M,this._eventsCount=0}O.prototype.eventNames=function(){var A=[],D,L;if(this._eventsCount===0)return A;for(L in D=this._events)V.call(D,L)&&A.push(N?L.slice(1):L);return Object.getOwnPropertySymbols?A.concat(Object.getOwnPropertySymbols(D)):A},O.prototype.listeners=function(A){var D=N?N+A:A,L=this._events[D];if(!L)return[];if(L.fn)return[L.fn];for(var w=0,x=L.length,u=new Array(x);w<x;w++)u[w]=L[w].fn;return u},O.prototype.listenerCount=function(A){var D=N?N+A:A,L=this._events[D];return L?L.fn?1:L.length:0},O.prototype.emit=function(A,D,L,w,x,u){var a=N?N+A:A;if(!this._events[a])return!1;var l=this._events[a],h=arguments.length,C,g;if(l.fn){l.once&&this.removeListener(A,l.fn,void 0,!0);switch(h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,D),!0;case 3:return l.fn.call(l.context,D,L),!0;case 4:return l.fn.call(l.context,D,L,w),!0;case 5:return l.fn.call(l.context,D,L,w,x),!0;case 6:return l.fn.call(l.context,D,L,w,x,u),!0}for(g=1,C=new Array(h-1);g<h;g++)C[g-1]=arguments[g];l.fn.apply(l.context,C)}else{var m=l.length,k;for(g=0;g<m;g++){l[g].once&&this.removeListener(A,l[g].fn,void 0,!0);switch(h){case 1:l[g].fn.call(l[g].context);break;case 2:l[g].fn.call(l[g].context,D);break;case 3:l[g].fn.call(l[g].context,D,L);break;case 4:l[g].fn.call(l[g].context,D,L,w);break;default:if(!C)for(k=1,C=new Array(h-1);k<h;k++)C[k-1]=arguments[k];l[g].fn.apply(l[g].context,C)}}}return!0},O.prototype.on=function(A,D,L){return F(this,A,D,L,!1)},O.prototype.once=function(A,D,L){return F(this,A,D,L,!0)},O.prototype.removeListener=function(A,D,L,w){var x=N?N+A:A;if(!this._events[x])return this;if(!D)return P(this,x),this;var u=this._events[x];if(u.fn)u.fn===D&&(!w||u.once)&&(!L||u.context===L)&&P(this,x);else{for(var a=0,l=[],h=u.length;a<h;a++)(u[a].fn!==D||w&&!u[a].once||L&&u[a].context!==L)&&l.push(u[a]);l.length?this._events[x]=l.length===1?l[0]:l:P(this,x)}return this},O.prototype.removeAllListeners=function(A){var D;return A?(D=N?N+A:A,this._events[D]&&P(this,D)):(this._events=new M,this._eventsCount=0),this},O.prototype.off=O.prototype.removeListener,O.prototype.addListener=O.prototype.on,O.prefixed=N,O.EventEmitter=O,ne.exports=O},"./node_modules/url-toolkit/src/url-toolkit.js":function(ne,$,_){(function(V){var N=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,M=/^([^\/?#]*)([^]*)$/,H=/(?:\/|^)\.(?=\/)/g,F=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,P={buildAbsoluteURL:function(O,b,A){if(A=A||{},O=O.trim(),b=b.trim(),!b){if(!A.alwaysNormalize)return O;var D=P.parseURL(O);if(!D)throw new Error("Error trying to parse base URL.");return D.path=P.normalizePath(D.path),P.buildURLFromParts(D)}var L=P.parseURL(b);if(!L)throw new Error("Error trying to parse relative URL.");if(L.scheme)return A.alwaysNormalize?(L.path=P.normalizePath(L.path),P.buildURLFromParts(L)):b;var w=P.parseURL(O);if(!w)throw new Error("Error trying to parse base URL.");if(!w.netLoc&&w.path&&w.path[0]!=="/"){var x=M.exec(w.path);w.netLoc=x[1],w.path=x[2]}w.netLoc&&!w.path&&(w.path="/");var u={scheme:w.scheme,netLoc:L.netLoc,path:null,params:L.params,query:L.query,fragment:L.fragment};if(!L.netLoc&&(u.netLoc=w.netLoc,L.path[0]!=="/"))if(!L.path)u.path=w.path,L.params||(u.params=w.params,L.query||(u.query=w.query));else{var a=w.path,l=a.substring(0,a.lastIndexOf("/")+1)+L.path;u.path=P.normalizePath(l)}return u.path===null&&(u.path=A.alwaysNormalize?P.normalizePath(L.path):L.path),P.buildURLFromParts(u)},parseURL:function(O){var b=N.exec(O);return b?{scheme:b[1]||"",netLoc:b[2]||"",path:b[3]||"",params:b[4]||"",query:b[5]||"",fragment:b[6]||""}:null},normalizePath:function(O){for(O=O.split("").reverse().join("").replace(H,"");O.length!==(O=O.replace(F,"")).length;);return O.split("").reverse().join("")},buildURLFromParts:function(O){return O.scheme+O.netLoc+O.path+O.params+O.query+O.fragment}};ne.exports=P})(this)},"./node_modules/webworkify-webpack/index.js":function(ne,$,_){function V(A){var D={};function L(x){if(D[x])return D[x].exports;var u=D[x]={i:x,l:!1,exports:{}};return A[x].call(u.exports,u,u.exports,L),u.l=!0,u.exports}L.m=A,L.c=D,L.i=function(x){return x},L.d=function(x,u,a){L.o(x,u)||Object.defineProperty(x,u,{configurable:!1,enumerable:!0,get:a})},L.r=function(x){Object.defineProperty(x,"__esModule",{value:!0})},L.n=function(x){var u=x&&x.__esModule?function(){return x.default}:function(){return x};return L.d(u,"a",u),u},L.o=function(x,u){return Object.prototype.hasOwnProperty.call(x,u)},L.p="/",L.oe=function(x){throw console.error(x),x};var w=L(L.s=ENTRY_MODULE);return w.default||w}var N="[\\.|\\-|\\+|\\w|/|@]+",M="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+N+").*?\\)";function H(A){return(A+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function F(A){return!isNaN(1*A)}function P(A,D,L){var w={};w[L]=[];var x=D.toString(),u=x.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return w;for(var a=u[1],l=new RegExp("(\\\\n|\\W)"+H(a)+M,"g"),h;h=l.exec(x);){if(h[3]==="dll-reference")continue;w[L].push(h[3])}for(l=new RegExp("\\("+H(a)+'\\("(dll-reference\\s('+N+'))"\\)\\)'+M,"g");h=l.exec(x);)A[h[2]]||(w[L].push(h[1]),A[h[2]]=_(h[1]).m),w[h[2]]=w[h[2]]||[],w[h[2]].push(h[4]);for(var C=Object.keys(w),g=0;g<C.length;g++)for(var m=0;m<w[C[g]].length;m++)F(w[C[g]][m])&&(w[C[g]][m]=1*w[C[g]][m]);return w}function O(A){var D=Object.keys(A);return D.reduce(function(L,w){return L||A[w].length>0},!1)}function b(A,D){for(var L={main:[D]},w={main:[]},x={main:{}};O(L);)for(var u=Object.keys(L),a=0;a<u.length;a++){var l=u[a],h=L[l],C=h.pop();if(x[l]=x[l]||{},x[l][C]||!A[l][C])continue;x[l][C]=!0,w[l]=w[l]||[],w[l].push(C);for(var g=P(A,A[l][C],l),m=Object.keys(g),k=0;k<m.length;k++)L[m[k]]=L[m[k]]||[],L[m[k]]=L[m[k]].concat(g[m[k]])}return w}ne.exports=function(A,D){D=D||{};var L={main:_.m},w=D.all?{main:Object.keys(L.main)}:b(L,A),x="";Object.keys(w).filter(function(C){return C!=="main"}).forEach(function(C){for(var g=0;w[C][g];)g++;w[C].push(g),L[C][g]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",x=x+"var "+C+" = ("+V.toString().replace("ENTRY_MODULE",JSON.stringify(g))+")({"+w[C].map(function(m){return""+JSON.stringify(m)+": "+L[C][m].toString()}).join(",")+`});
|
|
`}),x=x+"new (("+V.toString().replace("ENTRY_MODULE",JSON.stringify(A))+")({"+w.main.map(function(C){return""+JSON.stringify(C)+": "+L.main[C].toString()}).join(",")+"}))(self);";var u=new window.Blob([x],{type:"text/javascript"});if(D.bare)return u;var a=window.URL||window.webkitURL||window.mozURL||window.msURL,l=a.createObjectURL(u),h=new window.Worker(l);return h.objectURL=l,h}},"./src/config.ts":function(ne,$,_){"use strict";_.r($),_.d($,"hlsDefaultConfig",function(){return k}),_.d($,"mergeConfig",function(){return f}),_.d($,"enableStreamingMode",function(){return p});var V=_("./src/controller/abr-controller.ts"),N=_("./src/controller/audio-stream-controller.ts"),M=_("./src/controller/audio-track-controller.ts"),H=_("./src/controller/subtitle-stream-controller.ts"),F=_("./src/controller/subtitle-track-controller.ts"),P=_("./src/controller/buffer-controller.ts"),O=_("./src/controller/timeline-controller.ts"),b=_("./src/controller/cap-level-controller.ts"),A=_("./src/controller/fps-controller.ts"),D=_("./src/controller/eme-controller.ts"),L=_("./src/controller/cmcd-controller.ts"),w=_("./src/utils/xhr-loader.ts"),x=_("./src/utils/fetch-loader.ts"),u=_("./src/utils/cues.ts"),a=_("./src/utils/mediakeys-helper.ts"),l=_("./src/utils/logger.ts");function h(){return h=Object.assign||function(d){for(var o=1;o<arguments.length;o++){var S=arguments[o];for(var y in S)Object.prototype.hasOwnProperty.call(S,y)&&(d[y]=S[y])}return d},h.apply(this,arguments)}function C(d,o){var S=Object.keys(d);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(d);o&&(y=y.filter(function(T){return Object.getOwnPropertyDescriptor(d,T).enumerable})),S.push.apply(S,y)}return S}function g(d){for(var o=1;o<arguments.length;o++){var S=arguments[o]!=null?arguments[o]:{};o%2?C(Object(S),!0).forEach(function(y){m(d,y,S[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(S)):C(Object(S)).forEach(function(y){Object.defineProperty(d,y,Object.getOwnPropertyDescriptor(S,y))})}return d}function m(d,o,S){return o in d?Object.defineProperty(d,o,{value:S,enumerable:!0,configurable:!0,writable:!0}):d[o]=S,d}var k=g(g({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:Infinity,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:Infinity,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:w.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:V.default,bufferController:P.default,capLevelController:b.default,fpsController:A.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:a.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},v()),{},{subtitleStreamController:H.SubtitleStreamController,subtitleTrackController:F.default,timelineController:O.TimelineController,audioStreamController:N.default,audioTrackController:M.default,emeController:D.default,cmcdController:L.default});function v(){return{cueHandler:u.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function f(d,o){if((o.liveSyncDurationCount||o.liveMaxLatencyDurationCount)&&(o.liveSyncDuration||o.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(o.liveMaxLatencyDurationCount!==void 0&&(o.liveSyncDurationCount===void 0||o.liveMaxLatencyDurationCount<=o.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(o.liveMaxLatencyDuration!==void 0&&(o.liveSyncDuration===void 0||o.liveMaxLatencyDuration<=o.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return h({},d,o)}function p(d){var o=d.loader;if(o!==x.default&&o!==w.default)l.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),d.progressive=!1;else{var S=Object(x.fetchSupported)();S&&(d.loader=x.default,d.progressive=!0,d.enableSoftwareAES=!0,l.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/polyfills/number.ts"),N=_("./src/utils/ewma-bandwidth-estimator.ts"),M=_("./src/events.ts"),H=_("./src/utils/buffer-helper.ts"),F=_("./src/errors.ts"),P=_("./src/types/loader.ts"),O=_("./src/utils/logger.ts");function b(L,w){for(var x=0;x<w.length;x++){var u=w[x];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(L,u.key,u)}}function A(L,w,x){return w&&b(L.prototype,w),x&&b(L,x),L}var D=function(){function L(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 u=x.config;this.bwEstimator=new N.default(u.abrEwmaSlowVoD,u.abrEwmaFastVoD,u.abrEwmaDefaultEstimate),this.registerListeners()}var w=L.prototype;return w.registerListeners=function(){var u=this.hls;u.on(M.Events.FRAG_LOADING,this.onFragLoading,this),u.on(M.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(M.Events.ERROR,this.onError,this)},w.unregisterListeners=function(){var u=this.hls;u.off(M.Events.FRAG_LOADING,this.onFragLoading,this),u.off(M.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(M.Events.ERROR,this.onError,this)},w.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},w.onFragLoading=function(u,a){var l=a.frag;if(l.type===P.PlaylistLevelType.MAIN&&!this.timer){var h;this.fragCurrent=l,this.partCurrent=(h=a.part)!=null?h:null,this.timer=self.setInterval(this.onCheck,100)}},w.onLevelLoaded=function(u,a){var l=this.hls.config;a.details.live?this.bwEstimator.update(l.abrEwmaSlowLive,l.abrEwmaFastLive):this.bwEstimator.update(l.abrEwmaSlowVoD,l.abrEwmaFastVoD)},w._abandonRulesCheck=function(){var u=this.fragCurrent,a=this.partCurrent,l=this.hls,h=l.autoLevelEnabled,C=l.config,g=l.media;if(!u||!g)return;var m=a?a.stats:u.stats,k=a?a.duration:u.duration;if(m.aborted){O.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!h||g.paused||!g.playbackRate||!g.readyState)return;var v=performance.now()-m.loading.start,f=Math.abs(g.playbackRate);if(v<=500*k/f)return;var p=l.levels,d=l.minAutoLevel,o=p[u.level],S=m.total||Math.max(m.loaded,Math.round(k*o.maxBitrate/8)),y=Math.max(1,m.bwEstimate?m.bwEstimate/8:m.loaded*1e3/v),T=(S-m.loaded)/y,I=g.currentTime,G=(H.BufferHelper.bufferInfo(g,I,C.maxBufferHole).end-I)/f;if(G>=2*k/f||T<=G)return;var X=Number.POSITIVE_INFINITY,Q;for(Q=u.level-1;Q>d;Q--){var z=p[Q].maxBitrate;if(X=k*z/(8*.8*y),X<G)break}if(X>=T)return;var W=this.bwEstimator.getEstimate();O.logger.warn("Fragment "+u.sn+(a?" part "+a.index:"")+" of level "+u.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+Q+`
|
|
Current BW estimate: `+(Object(V.isFiniteNumber)(W)?(W/1024).toFixed(3):"Unknown")+` Kb/s
|
|
Estimated load time for current fragment: `+T.toFixed(3)+` s
|
|
Estimated load time for the next fragment: `+X.toFixed(3)+` s
|
|
Time to underbuffer: `+G.toFixed(3)+" s"),l.nextLoadLevel=Q,this.bwEstimator.sample(v,m.loaded),this.clearTimer(),u.loader&&(this.fragCurrent=this.partCurrent=null,u.loader.abort()),l.trigger(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:u,part:a,stats:m})},w.onFragLoaded=function(u,a){var l=a.frag,h=a.part;if(l.type===P.PlaylistLevelType.MAIN&&Object(V.isFiniteNumber)(l.sn)){var C=h?h.stats:l.stats,g=h?h.duration:l.duration;if(this.clearTimer(),this.lastLoadedFragLevel=l.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var m=this.hls.levels[l.level],k=(m.loaded?m.loaded.bytes:0)+C.loaded,v=(m.loaded?m.loaded.duration:0)+g;m.loaded={bytes:k,duration:v},m.realBitrate=Math.round(8*k/v)}if(l.bitrateTest){var f={stats:C,frag:l,part:h,id:l.type};this.onFragBuffered(M.Events.FRAG_BUFFERED,f),l.bitrateTest=!1}}},w.onFragBuffered=function(u,a){var l=a.frag,h=a.part,C=h?h.stats:l.stats;if(C.aborted)return;if(l.type!==P.PlaylistLevelType.MAIN||l.sn==="initSegment")return;var g=C.parsing.end-C.loading.start;this.bwEstimator.sample(g,C.loaded),C.bwEstimate=this.bwEstimator.getEstimate(),l.bitrateTest?this.bitrateTestDelay=g/1e3:this.bitrateTestDelay=0},w.onError=function(u,a){switch(a.details){case F.ErrorDetails.FRAG_LOAD_ERROR:case F.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},w.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},w.getNextABRAutoLevel=function(){var u=this.fragCurrent,a=this.partCurrent,l=this.hls,h=l.maxAutoLevel,C=l.config,g=l.minAutoLevel,m=l.media,k=a?a.duration:u?u.duration:0,v=m?m.currentTime:0,f=m&&m.playbackRate!==0?Math.abs(m.playbackRate):1,p=this.bwEstimator?this.bwEstimator.getEstimate():C.abrEwmaDefaultEstimate,d=(H.BufferHelper.bufferInfo(m,v,C.maxBufferHole).end-v)/f,o=this.findBestLevel(p,g,h,d,C.abrBandWidthFactor,C.abrBandWidthUpFactor);if(o>=0)return o;O.logger.trace((d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var S=k?Math.min(k,C.maxStarvationDelay):C.maxStarvationDelay,y=C.abrBandWidthFactor,T=C.abrBandWidthUpFactor;if(!d){var I=this.bitrateTestDelay;if(I){var G=k?Math.min(k,C.maxLoadingDelay):C.maxLoadingDelay;S=G-I,O.logger.trace("bitrate test took "+Math.round(1e3*I)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*S)+" ms"),y=T=1}}return o=this.findBestLevel(p,g,h,d+S,y,T),Math.max(o,0)},w.findBestLevel=function(u,a,l,h,C,g){for(var m,k=this.fragCurrent,v=this.partCurrent,f=this.lastLoadedFragLevel,p=this.hls.levels,d=p[f],o=!!(d!=null&&(m=d.details)!==null&&m!==void 0&&m.live),S=d==null?void 0:d.codecSet,y=v?v.duration:k?k.duration:0,T=l;T>=a;T--){var I=p[T];if(!I||S&&I.codecSet!==S)continue;var G=I.details,X=(v?G==null?void 0:G.partTarget:G==null?void 0:G.averagetargetduration)||y,Q=void 0;T<=f?Q=C*u:Q=g*u;var z=p[T].maxBitrate,W=z*X/Q;if(O.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+T+"/"+Math.round(Q)+"/"+z+"/"+X+"/"+h+"/"+W),Q>z&&(!W||o&&!this.bitrateTestDelay||W<h))return T}return-1},A(L,[{key:"nextAutoLevel",get:function(){var u=this._nextAutoLevel,a=this.bwEstimator;if(u!==-1&&(!a||!a.canEstimate()))return u;var l=this.getNextABRAutoLevel();return u!==-1&&(l=Math.min(u,l)),l},set:function(u){this._nextAutoLevel=u}}]),L}();$.default=D},"./src/controller/audio-stream-controller.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/polyfills/number.ts"),N=_("./src/controller/base-stream-controller.ts"),M=_("./src/events.ts"),H=_("./src/utils/buffer-helper.ts"),F=_("./src/controller/fragment-tracker.ts"),P=_("./src/types/level.ts"),O=_("./src/types/loader.ts"),b=_("./src/loader/fragment.ts"),A=_("./src/demux/chunk-cache.ts"),D=_("./src/demux/transmuxer-interface.ts"),L=_("./src/types/transmuxer.ts"),w=_("./src/controller/fragment-finders.ts"),x=_("./src/utils/discontinuities.ts"),u=_("./src/errors.ts"),a=_("./src/utils/logger.ts");function l(){return l=Object.assign||function(k){for(var v=1;v<arguments.length;v++){var f=arguments[v];for(var p in f)Object.prototype.hasOwnProperty.call(f,p)&&(k[p]=f[p])}return k},l.apply(this,arguments)}function h(k,v){k.prototype=Object.create(v.prototype),k.prototype.constructor=k,C(k,v)}function C(k,v){return C=Object.setPrototypeOf||function(p,d){return p.__proto__=d,p},C(k,v)}var g=100,m=function(k){h(v,k);function v(p,d){var o;return o=k.call(this,p,d,"[audio-stream-controller]")||this,o.videoBuffer=null,o.videoTrackCC=-1,o.waitingVideoCC=-1,o.audioSwitch=!1,o.trackId=-1,o.waitingData=null,o.mainDetails=null,o.bufferFlushed=!1,o._registerListeners(),o}var f=v.prototype;return f.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},f._registerListeners=function(){var d=this.hls;d.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(M.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),d.on(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.on(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.on(M.Events.ERROR,this.onError,this),d.on(M.Events.BUFFER_RESET,this.onBufferReset,this),d.on(M.Events.BUFFER_CREATED,this.onBufferCreated,this),d.on(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.on(M.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},f._unregisterListeners=function(){var d=this.hls;d.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(M.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),d.off(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.off(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.off(M.Events.ERROR,this.onError,this),d.off(M.Events.BUFFER_RESET,this.onBufferReset,this),d.off(M.Events.BUFFER_CREATED,this.onBufferCreated,this),d.off(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.off(M.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},f.onInitPtsFound=function(d,o){var S=o.frag,y=o.id,T=o.initPTS;if(y==="main"){var I=S.cc;this.initPTS[S.cc]=T,this.log("InitPTS for cc: "+I+" found from main: "+T),this.videoTrackCC=I,this.state===N.State.WAITING_INIT_PTS&&this.tick()}},f.startLoad=function(d){if(!this.levels){this.startPosition=d,this.state=N.State.STOPPED;return}var o=this.lastCurrentTime;this.stopLoad(),this.setInterval(g),this.fragLoadError=0,o>0&&d===-1?(this.log("Override startPosition with lastCurrentTime @"+o.toFixed(3)),this.state=N.State.IDLE):(this.loadedmetadata=!1,this.state=N.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=d,this.tick()},f.doTick=function(){switch(this.state){case N.State.IDLE:this.doTickIdle();break;case N.State.WAITING_TRACK:{var d,o=this.levels,S=this.trackId,y=o==null||((d=o[S])===null||d===void 0)?void 0:d.details;if(y){if(this.waitForCdnTuneIn(y))break;this.state=N.State.WAITING_INIT_PTS}break}case N.State.FRAG_LOADING_WAITING_RETRY:{var T,I=performance.now(),G=this.retryDate;(!G||I>=G||(T=this.media)!==null&&T!==void 0&&T.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=N.State.IDLE);break}case N.State.WAITING_INIT_PTS:{var X=this.waitingData;if(X){var Q=X.frag,z=X.part,W=X.cache,ee=X.complete;if(this.initPTS[Q.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=N.State.FRAG_LOADING;var ae=W.flush(),pe={frag:Q,part:z,payload:ae,networkDetails:null};this._handleFragmentLoadProgress(pe),ee&&k.prototype._handleFragmentLoadComplete.call(this,pe)}else if(this.videoTrackCC!==this.waitingVideoCC)a.logger.log("Waiting fragment cc ("+Q.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var ve=this.getLoadPosition(),De=H.BufferHelper.bufferInfo(this.mediaBuffer,ve,this.config.maxBufferHole),xe=Object(w.fragmentWithinToleranceTest)(De.end,this.config.maxFragLookUpTolerance,Q);xe<0&&(a.logger.log("Waiting fragment cc ("+Q.cc+") @ "+Q.start+" cancelled because another fragment at "+De.end+" is needed"),this.clearWaitingFragment())}}else this.state=N.State.IDLE}}this.onTickEnd()},f.clearWaitingFragment=function(){var d=this.waitingData;d&&(this.fragmentTracker.removeFragment(d.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=N.State.IDLE)},f.onTickEnd=function(){var d=this.media;if(!d||!d.readyState)return;var o=this.mediaBuffer?this.mediaBuffer:d,S=o.buffered;!this.loadedmetadata&&S.length&&(this.loadedmetadata=!0),this.lastCurrentTime=d.currentTime},f.doTickIdle=function(){var d,o,S=this.hls,y=this.levels,T=this.media,I=this.trackId,G=S.config;if(!y||!y[I])return;if(!T&&(this.startFragRequested||!G.startFragPrefetch))return;var X=y[I],Q=X.details;if(!Q||Q.live&&this.levelLastLoaded!==I||this.waitForCdnTuneIn(Q)){this.state=N.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,b.ElementaryStreamTypes.AUDIO,O.PlaylistLevelType.AUDIO));var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,O.PlaylistLevelType.AUDIO);if(z===null)return;var W=z.len,ee=this.getMaxBufferLength(),ae=this.audioSwitch;if(W>=ee&&!ae)return;if(!ae&&this._streamEnded(z,Q)){S.trigger(M.Events.BUFFER_EOS,{type:"audio"}),this.state=N.State.ENDED;return}var pe=Q.fragments,ve=pe[0].start,De=z.end;if(ae){var xe=this.getLoadPosition();De=xe,Q.PTSKnown&&xe<ve&&((z.end>ve||z.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),T.currentTime=ve+.05))}var Ce=this.getNextFragment(De,Q);if(!Ce){this.bufferFlushed=!0;return}((d=Ce.decryptdata)===null||d===void 0?void 0:d.keyFormat)==="identity"&&!((o=Ce.decryptdata)!==null&&o!==void 0&&o.key)?this.loadKey(Ce,Q):this.loadFragment(Ce,Q,De)},f.getMaxBufferLength=function(){var d=k.prototype.getMaxBufferLength.call(this),o=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,O.PlaylistLevelType.MAIN);return o===null?d:Math.max(d,o.len)},f.onMediaDetaching=function(){this.videoBuffer=null,k.prototype.onMediaDetaching.call(this)},f.onAudioTracksUpdated=function(d,o){var S=o.audioTracks;this.resetTransmuxer(),this.levels=S.map(function(y){return new P.Level(y)})},f.onAudioTrackSwitching=function(d,o){var S=!!o.url;this.trackId=o.id;var y=this.fragCurrent;y!=null&&y.loader&&y.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),S?this.setInterval(g):this.resetTransmuxer(),S?(this.audioSwitch=!0,this.state=N.State.IDLE):this.state=N.State.STOPPED,this.tick()},f.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},f.onLevelLoaded=function(d,o){this.mainDetails=o.details},f.onAudioTrackLoaded=function(d,o){var S,y=this.levels,T=o.details,I=o.id;if(!y){this.warn("Audio tracks were reset while loading level "+I);return}this.log("Track "+I+" loaded ["+T.startSN+","+T.endSN+"],duration:"+T.totalduration);var G=y[I],X=0;if(T.live||(S=G.details)!==null&&S!==void 0&&S.live){var Q=this.mainDetails;if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed||!Q)return;!G.details&&T.hasProgramDateTime&&Q.hasProgramDateTime?(Object(x.alignMediaPlaylistByPDT)(T,Q),X=T.fragments[0].start):X=this.alignPlaylists(T,G.details)}G.details=T,this.levelLastLoaded=I,!this.startFragRequested&&(this.mainDetails||!T.live)&&this.setStartPosition(G.details,X),this.state===N.State.WAITING_TRACK&&!this.waitForCdnTuneIn(T)&&(this.state=N.State.IDLE),this.tick()},f._handleFragmentLoadProgress=function(d){var o,S=d.frag,y=d.part,T=d.payload,I=this.config,G=this.trackId,X=this.levels;if(!X){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+S.sn+" of level "+S.level+" will not be buffered");return}var Q=X[G];console.assert(Q,"Audio track is defined on fragment load progress");var z=Q.details;console.assert(z,"Audio track details are defined on fragment load progress");var W=I.defaultAudioCodec||Q.audioCodec||"mp4a.40.2",ee=this.transmuxer;ee||(ee=this.transmuxer=new D.default(this.hls,O.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var ae=this.initPTS[S.cc],pe=(o=S.initSegment)===null||o===void 0?void 0:o.data;if(ae!==void 0){var ve=!1,De=y?y.index:-1,xe=De!==-1,Ce=new L.ChunkMetadata(S.level,S.sn,S.stats.chunkCount,T.byteLength,De,xe);ee.push(T,pe,W,"",S,y,z.totalduration,ve,Ce,ae)}else{a.logger.log("Unknown video PTS for cc "+S.cc+", waiting for video PTS before demuxing audio frag "+S.sn+" of ["+z.startSN+" ,"+z.endSN+"],track "+G);var Ae=this.waitingData=this.waitingData||{frag:S,part:y,cache:new A.default,complete:!1},Se=Ae.cache;Se.push(new Uint8Array(T)),this.waitingVideoCC=this.videoTrackCC,this.state=N.State.WAITING_INIT_PTS}},f._handleFragmentLoadComplete=function(d){if(this.waitingData){this.waitingData.complete=!0;return}k.prototype._handleFragmentLoadComplete.call(this,d)},f.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},f.onBufferCreated=function(d,o){var S=o.tracks.audio;S&&(this.mediaBuffer=S.buffer),o.tracks.video&&(this.videoBuffer=o.tracks.video.buffer)},f.onFragBuffered=function(d,o){var S=o.frag,y=o.part;if(S.type!==O.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(S)){this.warn("Fragment "+S.sn+(y?" p: "+y.index:"")+" of level "+S.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}S.sn!=="initSegment"&&(this.fragPrevious=S,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(S,y)},f.onError=function(d,o){switch(o.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(O.PlaylistLevelType.AUDIO,o);break;case u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==N.State.ERROR&&this.state!==N.State.STOPPED&&(this.state=o.fatal?N.State.ERROR:N.State.IDLE,this.warn(o.details+" while loading frag, switching to "+this.state+" state"));break;case u.ErrorDetails.BUFFER_FULL_ERROR:if(o.parent==="audio"&&(this.state===N.State.PARSING||this.state===N.State.PARSED)){var S=!0,y=this.getFwdBufferInfo(this.mediaBuffer,O.PlaylistLevelType.AUDIO);y&&y.len>.5&&(S=!this.reduceMaxBufferLength(y.len)),S&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,k.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},f.onBufferFlushed=function(d,o){var S=o.type;S===b.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},f._handleTransmuxComplete=function(d){var o,S="audio",y=this.hls,T=d.remuxResult,I=d.chunkMeta,G=this.getCurrentContext(I);if(!G){this.warn("The loading context changed while buffering fragment "+I.sn+" of level "+I.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(I.level);return}var X=G.frag,Q=G.part,z=T.audio,W=T.text,ee=T.id3,ae=T.initSegment;if(this.fragContextChanged(X))return;if(this.state=N.State.PARSING,this.audioSwitch&&z&&this.completeAudioSwitch(),ae!=null&&ae.tracks&&(this._bufferInitSegment(ae.tracks,X,I),y.trigger(M.Events.FRAG_PARSING_INIT_SEGMENT,{frag:X,id:S,tracks:ae.tracks})),z){var pe=z.startPTS,ve=z.endPTS,De=z.startDTS,xe=z.endDTS;Q&&(Q.elementaryStreams[b.ElementaryStreamTypes.AUDIO]={startPTS:pe,endPTS:ve,startDTS:De,endDTS:xe}),X.setElementaryStreamInfo(b.ElementaryStreamTypes.AUDIO,pe,ve,De,xe),this.bufferFragmentData(z,X,Q,I)}if(ee!=null&&(o=ee.samples)!==null&&o!==void 0&&o.length){var Ce=l({frag:X,id:S},ee);y.trigger(M.Events.FRAG_PARSING_METADATA,Ce)}if(W){var Ae=l({frag:X,id:S},W);y.trigger(M.Events.FRAG_PARSING_USERDATA,Ae)}},f._bufferInitSegment=function(d,o,S){if(this.state!==N.State.PARSING)return;d.video&&delete d.video;var y=d.audio;if(!y)return;y.levelCodec=y.codec,y.id="audio",this.log("Init audio buffer, container:"+y.container+", codecs[parsed]=["+y.codec+"]"),this.hls.trigger(M.Events.BUFFER_CODECS,d);var T=y.initSegment;if(T!=null&&T.byteLength){var I={type:"audio",frag:o,part:null,chunkMeta:S,parent:o.type,data:T};this.hls.trigger(M.Events.BUFFER_APPENDING,I)}this.tick()},f.loadFragment=function(d,o,S){var y=this.fragmentTracker.getState(d);this.fragCurrent=d,(this.audioSwitch||y===F.FragmentState.NOT_LOADED||y===F.FragmentState.PARTIAL)&&(d.sn==="initSegment"?this._loadInitSegment(d):o.live&&!Object(V.isFiniteNumber)(this.initPTS[d.cc])?(this.log("Waiting for video PTS in continuity counter "+d.cc+" of live stream before loading audio fragment "+d.sn+" of level "+this.trackId),this.state=N.State.WAITING_INIT_PTS):(this.startFragRequested=!0,k.prototype.loadFragment.call(this,d,o,S)))},f.completeAudioSwitch=function(){var d=this.hls,o=this.media,S=this.trackId;o&&(this.log("Switching audio track : flushing all audio"),k.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,d.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:S})},v}(N.default);$.default=m},"./src/controller/audio-track-controller.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/events.ts"),N=_("./src/errors.ts"),M=_("./src/controller/base-playlist-controller.ts"),H=_("./src/types/loader.ts");function F(D,L){for(var w=0;w<L.length;w++){var x=L[w];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(D,x.key,x)}}function P(D,L,w){return L&&F(D.prototype,L),w&&F(D,w),D}function O(D,L){D.prototype=Object.create(L.prototype),D.prototype.constructor=D,b(D,L)}function b(D,L){return b=Object.setPrototypeOf||function(x,u){return x.__proto__=u,x},b(D,L)}var A=function(D){O(L,D);function L(x){var u;return u=D.call(this,x,"[audio-track-controller]")||this,u.tracks=[],u.groupId=null,u.tracksInGroup=[],u.trackId=-1,u.trackName="",u.selectDefaultTrack=!0,u.registerListeners(),u}var w=L.prototype;return w.registerListeners=function(){var u=this.hls;u.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.on(V.Events.LEVEL_LOADING,this.onLevelLoading,this),u.on(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.on(V.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(V.Events.ERROR,this.onError,this)},w.unregisterListeners=function(){var u=this.hls;u.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.off(V.Events.LEVEL_LOADING,this.onLevelLoading,this),u.off(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.off(V.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(V.Events.ERROR,this.onError,this)},w.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,D.prototype.destroy.call(this)},w.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},w.onManifestParsed=function(u,a){this.tracks=a.audioTracks||[]},w.onAudioTrackLoaded=function(u,a){var l=a.id,h=a.details,C=this.tracksInGroup[l];if(!C){this.warn("Invalid audio track id "+l);return}var g=C.details;C.details=a.details,this.log("audioTrack "+l+" loaded ["+h.startSN+"-"+h.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,a,g))},w.onLevelLoading=function(u,a){this.switchLevel(a.level)},w.onLevelSwitching=function(u,a){this.switchLevel(a.level)},w.switchLevel=function(u){var a=this.hls.levels[u];if(!(a!=null&&a.audioGroupIds))return;var l=a.audioGroupIds[a.urlId];if(this.groupId!==l){this.groupId=l;var h=this.tracks.filter(function(g){return!l||g.groupId===l});this.selectDefaultTrack&&!h.some(function(g){return g.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=h;var C={audioTracks:h};this.log("Updating audio tracks, "+h.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(V.Events.AUDIO_TRACKS_UPDATED,C),this.selectInitialTrack()}},w.onError=function(u,a){if(D.prototype.onError.call(this,u,a),a.fatal||!a.context)return;a.context.type===H.PlaylistContextType.AUDIO_TRACK&&a.context.id===this.trackId&&a.context.groupId===this.groupId&&this.retryLoadingOrFail(a)},w.setAudioTrack=function(u){var a=this.tracksInGroup;if(u<0||u>=a.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var l=a[this.trackId];this.log("Now switching to audio-track index "+u);var h=a[u],C=h.id,g=h.groupId,m=g===void 0?"":g,k=h.name,v=h.type,f=h.url;if(this.trackId=u,this.trackName=k,this.selectDefaultTrack=!1,this.hls.trigger(V.Events.AUDIO_TRACK_SWITCHING,{id:C,groupId:m,name:k,type:v,url:f}),h.details&&!h.details.live)return;var p=this.switchParams(h.url,l==null?void 0:l.details);this.loadPlaylist(p)},w.selectInitialTrack=function(){var u=this.tracksInGroup;console.assert(u.length,"Initial audio track should be selected when tracks are known");var a=this.trackName,l=this.findTrackId(a)||this.findTrackId();l!==-1?this.setAudioTrack(l):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},w.findTrackId=function(u){for(var a=this.tracksInGroup,l=0;l<a.length;l++){var h=a[l];if((!this.selectDefaultTrack||h.default)&&(!u||u===h.name))return h.id}return-1},w.loadPlaylist=function(u){var a=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(a)){var l=a.id,h=a.groupId,C=a.url;if(u)try{C=u.addDirectives(C)}catch(g){this.warn("Could not construct new URL with HLS Delivery Directives: "+g)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(V.Events.AUDIO_TRACK_LOADING,{url:C,id:l,groupId:h,deliveryDirectives:u||null})}},P(L,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(u){this.selectDefaultTrack=!1,this.setAudioTrack(u)}}]),L}(M.default);$.default=A},"./src/controller/base-playlist-controller.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return P});var V=_("./src/polyfills/number.ts"),N=_("./src/types/level.ts"),M=_("./src/controller/level-helper.ts"),H=_("./src/utils/logger.ts"),F=_("./src/errors.ts"),P=function(){function O(A,D){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=H.logger.log.bind(H.logger,D+":"),this.warn=H.logger.warn.bind(H.logger,D+":"),this.hls=A}var b=O.prototype;return b.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},b.onError=function(D,L){L.fatal&&L.type===F.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},b.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},b.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},b.stopLoad=function(){this.canLoad=!1,this.clearTimer()},b.switchParams=function(D,L){var w=L==null?void 0:L.renditionReports;if(w)for(var x=0;x<w.length;x++){var u=w[x],a=""+u.URI;if(a===D.substr(-a.length)){var l=parseInt(u["LAST-MSN"]),h=parseInt(u["LAST-PART"]);if(L&&this.hls.config.lowLatencyMode){var C=Math.min(L.age-L.partTarget,L.targetduration);h!==void 0&&C>L.partTarget&&(h+=1)}if(Object(V.isFiniteNumber)(l))return new N.HlsUrlParameters(l,Object(V.isFiniteNumber)(h)?h:void 0,N.HlsSkip.No)}}},b.loadPlaylist=function(D){},b.shouldLoadTrack=function(D){return this.canLoad&&D&&!!D.url&&(!D.details||D.details.live)},b.playlistLoaded=function(D,L,w){var x=this,u=L.details,a=L.stats,l=a.loading.end?Math.max(0,self.performance.now()-a.loading.end):0;if(u.advancedDateTime=Date.now()-l,u.live||w!=null&&w.live){if(u.reloaded(w),w&&this.log("live playlist "+D+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:"MISSED")),w&&u.fragments.length>0&&Object(M.mergeDetails)(w,u),!this.canLoad||!u.live)return;var h,C=void 0,g=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var m=this.hls.config.lowLatencyMode,k=u.lastPartSn,v=u.endSN,f=u.lastPartIndex,p=f!==-1,d=k===v,o=m?0:f;p?(C=d?v+1:k,g=d?o:f+1):C=v+1;var S=u.age,y=S+u.ageHeader,T=Math.min(y-u.partTarget,u.targetduration*1.5);if(T>0){if(w&&T>w.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+w.tuneInGoal+" to: "+T+" with playlist age: "+u.age),T=0;else{var I=Math.floor(T/u.targetduration);if(C+=I,g!==void 0){var G=Math.round(T%u.targetduration/u.partTarget);g+=G}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+S.toFixed(2)+"s goal: "+T+" skip sn "+I+" to part "+g)}u.tuneInGoal=T}if(h=this.getDeliveryDirectives(u,L.deliveryDirectives,C,g),m||!d){this.loadPlaylist(h);return}}else h=this.getDeliveryDirectives(u,L.deliveryDirectives,C,g);var X=Object(M.computeReloadInterval)(u,a);C!==void 0&&u.canBlockReload&&(X-=u.partTarget||1),this.log("reload live playlist "+D+" in "+Math.round(X)+" ms"),this.timer=self.setTimeout(function(){return x.loadPlaylist(h)},X)}else this.clearTimer()},b.getDeliveryDirectives=function(D,L,w,x){var u=Object(N.getSkipValue)(D,w);return L!=null&&L.skip&&D.deltaUpdateFailed&&(w=L.msn,x=L.part,u=N.HlsSkip.No),new N.HlsUrlParameters(w,x,u)},b.retryLoadingOrFail=function(D){var L=this,w=this.hls.config,x=this.retryCount<w.levelLoadingMaxRetry;if(x){var u;if(this.retryCount++,D.details.indexOf("LoadTimeOut")>-1&&(u=D.context)!==null&&u!==void 0&&u.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+D.details+'"'),this.loadPlaylist();else{var a=Math.min(Math.pow(2,this.retryCount)*w.levelLoadingRetryDelay,w.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return L.loadPlaylist()},a),this.warn("retry playlist loading #"+this.retryCount+" in "+a+' ms after "'+D.details+'"')}}else this.warn('cannot recover from error "'+D.details+'"'),this.clearTimer(),D.fatal=!0;return x},O}()},"./src/controller/base-stream-controller.ts":function(ne,$,_){"use strict";_.r($),_.d($,"State",function(){return v}),_.d($,"default",function(){return f});var V=_("./src/polyfills/number.ts"),N=_("./src/task-loop.ts"),M=_("./src/controller/fragment-tracker.ts"),H=_("./src/utils/buffer-helper.ts"),F=_("./src/utils/logger.ts"),P=_("./src/events.ts"),O=_("./src/errors.ts"),b=_("./src/types/transmuxer.ts"),A=_("./src/utils/mp4-tools.ts"),D=_("./src/utils/discontinuities.ts"),L=_("./src/controller/fragment-finders.ts"),w=_("./src/controller/level-helper.ts"),x=_("./src/loader/fragment-loader.ts"),u=_("./src/crypt/decrypter.ts"),a=_("./src/utils/time-ranges.ts"),l=_("./src/types/loader.ts");function h(p,d){for(var o=0;o<d.length;o++){var S=d[o];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(p,S.key,S)}}function C(p,d,o){return d&&h(p.prototype,d),o&&h(p,o),p}function g(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function m(p,d){p.prototype=Object.create(d.prototype),p.prototype.constructor=p,k(p,d)}function k(p,d){return k=Object.setPrototypeOf||function(S,y){return S.__proto__=y,S},k(p,d)}var v={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},f=function(p){m(d,p);function d(S,y,T){var I;return I=p.call(this)||this,I.hls=void 0,I.fragPrevious=null,I.fragCurrent=null,I.fragmentTracker=void 0,I.transmuxer=null,I._state=v.STOPPED,I.media=void 0,I.mediaBuffer=void 0,I.config=void 0,I.bitrateTest=!1,I.lastCurrentTime=0,I.nextLoadPosition=0,I.startPosition=0,I.loadedmetadata=!1,I.fragLoadError=0,I.retryDate=0,I.levels=null,I.fragmentLoader=void 0,I.levelLastLoaded=null,I.startFragRequested=!1,I.decrypter=void 0,I.initPTS=[],I.onvseeking=null,I.onvended=null,I.logPrefix="",I.log=void 0,I.warn=void 0,I.logPrefix=T,I.log=F.logger.log.bind(F.logger,T+":"),I.warn=F.logger.warn.bind(F.logger,T+":"),I.hls=S,I.fragmentLoader=new x.default(S.config),I.fragmentTracker=y,I.config=S.config,I.decrypter=new u.default(S,S.config),S.on(P.Events.KEY_LOADED,I.onKeyLoaded,g(I)),I}var o=d.prototype;return o.doTick=function(){this.onTickEnd()},o.onTickEnd=function(){},o.startLoad=function(y){},o.stopLoad=function(){this.fragmentLoader.abort();var y=this.fragCurrent;y&&this.fragmentTracker.removeFragment(y),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=v.STOPPED},o._streamEnded=function(y,T){var I=this.fragCurrent,G=this.fragmentTracker;if(!T.live&&I&&I.sn===T.endSN&&!y.nextStart){var X=G.getState(I);return X===M.FragmentState.PARTIAL||X===M.FragmentState.OK}return!1},o.onMediaAttached=function(y,T){var I=this.media=this.mediaBuffer=T.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),I.addEventListener("seeking",this.onvseeking),I.addEventListener("ended",this.onvended);var G=this.config;this.levels&&G.autoStartLoad&&this.state===v.STOPPED&&this.startLoad(G.startPosition)},o.onMediaDetaching=function(){var y=this.media;y!=null&&y.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),y&&(y.removeEventListener("seeking",this.onvseeking),y.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},o.onMediaSeeking=function(){var y=this.config,T=this.fragCurrent,I=this.media,G=this.mediaBuffer,X=this.state,Q=I?I.currentTime:0,z=H.BufferHelper.bufferInfo(G||I,Q,y.maxBufferHole);if(this.log("media seeking to "+(Object(V.isFiniteNumber)(Q)?Q.toFixed(3):Q)+", state: "+X),X===v.ENDED)this.resetLoadingState();else if(T&&!z.len){var W=y.maxFragLookUpTolerance,ee=T.start-W,ae=T.start+T.duration+W,pe=Q>ae;(Q<ee||pe)&&(pe&&T.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),T.loader.abort()),this.resetLoadingState())}I&&(this.lastCurrentTime=Q),!this.loadedmetadata&&!z.len&&(this.nextLoadPosition=this.startPosition=Q),this.tickImmediate()},o.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},o.onKeyLoaded=function(y,T){if(this.state!==v.KEY_LOADING||T.frag!==this.fragCurrent||!this.levels)return;this.state=v.IDLE;var I=this.levels[T.frag.level].details;I&&this.loadFragment(T.frag,I,T.frag.start)},o.onHandlerDestroying=function(){this.stopLoad(),p.prototype.onHandlerDestroying.call(this)},o.onHandlerDestroyed=function(){this.state=v.STOPPED,this.hls.off(P.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,p.prototype.onHandlerDestroyed.call(this)},o.loadKey=function(y,T){this.log("Loading key for "+y.sn+" of ["+T.startSN+"-"+T.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+y.level),this.state=v.KEY_LOADING,this.fragCurrent=y,this.hls.trigger(P.Events.KEY_LOADING,{frag:y})},o.loadFragment=function(y,T,I){this._loadFragForPlayback(y,T,I)},o._loadFragForPlayback=function(y,T,I){var G=this,X=function(z){if(G.fragContextChanged(y)){G.warn("Fragment "+y.sn+(z.part?" p: "+z.part.index:"")+" of level "+y.level+" was dropped during download."),G.fragmentTracker.removeFragment(y);return}y.stats.chunkCount++,G._handleFragmentLoadProgress(z)};this._doFragLoad(y,T,I,X).then(function(Q){if(!Q)return;G.fragLoadError=0;var z=G.state;if(G.fragContextChanged(y)){(z===v.FRAG_LOADING||z===v.BACKTRACKING||!G.fragCurrent&&z===v.PARSING)&&(G.fragmentTracker.removeFragment(y),G.state=v.IDLE);return}if("payload"in Q&&(G.log("Loaded fragment "+y.sn+" of level "+y.level),G.hls.trigger(P.Events.FRAG_LOADED,Q),G.state===v.BACKTRACKING)){G.fragmentTracker.backtrack(y,Q),G.resetFragmentLoading(y);return}G._handleFragmentLoadComplete(Q)}).catch(function(Q){G.warn(Q),G.resetFragmentLoading(y)})},o.flushMainBuffer=function(y,T,I){if(I===void 0&&(I=null),!(y-T))return;var G={startOffset:y,endOffset:T,type:I};this.fragLoadError=0,this.hls.trigger(P.Events.BUFFER_FLUSHING,G)},o._loadInitSegment=function(y){var T=this;this._doFragLoad(y).then(function(I){if(!I||T.fragContextChanged(y)||!T.levels)throw new Error("init load aborted");return I}).then(function(I){var G=T.hls,X=I.payload,Q=y.decryptdata;if(X&&X.byteLength>0&&Q&&Q.key&&Q.iv&&Q.method==="AES-128"){var z=self.performance.now();return T.decrypter.webCryptoDecrypt(new Uint8Array(X),Q.key.buffer,Q.iv.buffer).then(function(W){var ee=self.performance.now();return G.trigger(P.Events.FRAG_DECRYPTED,{frag:y,payload:W,stats:{tstart:z,tdecrypt:ee}}),I.payload=W,I})}return I}).then(function(I){var G=T.fragCurrent,X=T.hls,Q=T.levels;if(!Q)throw new Error("init load aborted, missing levels");var z=Q[y.level].details;console.assert(z,"Level details are defined when init segment is loaded");var W=y.stats;T.state=v.IDLE,T.fragLoadError=0,y.data=new Uint8Array(I.payload),W.parsing.start=W.buffering.start=self.performance.now(),W.parsing.end=W.buffering.end=self.performance.now(),I.frag===G&&X.trigger(P.Events.FRAG_BUFFERED,{stats:W,frag:G,part:null,id:y.type}),T.tick()}).catch(function(I){T.warn(I),T.resetFragmentLoading(y)})},o.fragContextChanged=function(y){var T=this.fragCurrent;return!y||!T||y.level!==T.level||y.sn!==T.sn||y.urlId!==T.urlId},o.fragBufferedComplete=function(y,T){var I=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+y.type+" sn: "+y.sn+(T?" part: "+T.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+y.level+" "+a.default.toString(H.BufferHelper.getBuffered(I))),this.state=v.IDLE,this.tick()},o._handleFragmentLoadComplete=function(y){var T=this.transmuxer;if(!T)return;var I=y.frag,G=y.part,X=y.partsLoaded,Q=!X||X.length===0||X.some(function(W){return!W}),z=new b.ChunkMetadata(I.level,I.sn,I.stats.chunkCount+1,0,G?G.index:-1,!Q);T.flush(z)},o._handleFragmentLoadProgress=function(y){},o._doFragLoad=function(y,T,I,G){var X=this;if(I===void 0&&(I=null),!this.levels)throw new Error("frag load aborted, missing levels");if(I=Math.max(y.start,I||0),this.config.lowLatencyMode&&T){var Q=T.partList;if(Q&&G){I>y.end&&T.fragmentHint&&(y=T.fragmentHint);var z=this.getNextPart(Q,y,I);if(z>-1){var W=Q[z];return this.log("Loading part sn: "+y.sn+" p: "+W.index+" cc: "+y.cc+" of playlist ["+T.startSN+"-"+T.endSN+"] parts [0-"+z+"-"+(Q.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+y.level+", target: "+parseFloat(I.toFixed(3))),this.nextLoadPosition=W.start+W.duration,this.state=v.FRAG_LOADING,this.hls.trigger(P.Events.FRAG_LOADING,{frag:y,part:Q[z],targetBufferTime:I}),this.doFragPartsLoad(y,Q,z,G).catch(function(ee){return X.handleFragLoadError(ee)})}else if(!y.url||this.loadedEndOfParts(Q,I))return Promise.resolve(null)}}return this.log("Loading fragment "+y.sn+" cc: "+y.cc+" "+(T?"of ["+T.startSN+"-"+T.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+y.level+", target: "+parseFloat(I.toFixed(3))),Object(V.isFiniteNumber)(y.sn)&&!this.bitrateTest&&(this.nextLoadPosition=y.start+y.duration),this.state=v.FRAG_LOADING,this.hls.trigger(P.Events.FRAG_LOADING,{frag:y,targetBufferTime:I}),this.fragmentLoader.load(y,G).catch(function(ee){return X.handleFragLoadError(ee)})},o.doFragPartsLoad=function(y,T,I,G){var X=this;return new Promise(function(Q,z){var W=[],ee=function ae(pe){var ve=T[pe];X.fragmentLoader.loadPart(y,ve,G).then(function(De){W[ve.index]=De;var xe=De.part;X.hls.trigger(P.Events.FRAG_LOADED,De);var Ce=T[pe+1];if(Ce&&Ce.fragment===y)ae(pe+1);else return Q({frag:y,part:xe,partsLoaded:W})}).catch(z)};ee(I)})},o.handleFragLoadError=function(y){var T=y.data;return T&&T.details===O.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(T.frag,T.part):this.hls.trigger(P.Events.ERROR,T),null},o._handleTransmuxerFlush=function(y){var T=this.getCurrentContext(y);if(!T||this.state!==v.PARSING){this.fragCurrent||(this.state=v.IDLE);return}var I=T.frag,G=T.part,X=T.level,Q=self.performance.now();I.stats.parsing.end=Q,G&&(G.stats.parsing.end=Q),this.updateLevelTiming(I,G,X,y.partial)},o.getCurrentContext=function(y){var T=this.levels,I=y.level,G=y.sn,X=y.part;if(!T||!T[I])return this.warn("Levels object was unset while buffering fragment "+G+" of level "+I+". The current chunk will not be buffered."),null;var Q=T[I],z=X>-1?Object(w.getPartWith)(Q,G,X):null,W=z?z.fragment:Object(w.getFragmentWithSN)(Q,G,this.fragCurrent);return W?{frag:W,part:z,level:Q}:null},o.bufferFragmentData=function(y,T,I,G){if(!y||this.state!==v.PARSING)return;var X=y.data1,Q=y.data2,z=X;if(X&&Q&&(z=Object(A.appendUint8Array)(X,Q)),!z||!z.length)return;var W={type:y.type,frag:T,part:I,chunkMeta:G,parent:T.type,data:z};this.hls.trigger(P.Events.BUFFER_APPENDING,W),y.dropped&&y.independent&&!I&&this.flushBufferGap(T)},o.flushBufferGap=function(y){var T=this.media;if(!T)return;if(!H.BufferHelper.isBuffered(T,T.currentTime)){this.flushMainBuffer(0,y.start);return}var I=T.currentTime,G=H.BufferHelper.bufferInfo(T,I,0),X=y.duration,Q=Math.min(this.config.maxFragLookUpTolerance*2,X*.25),z=Math.max(Math.min(y.start-Q,G.end-Q),I+Q);y.start-z>Q&&this.flushMainBuffer(z,y.start)},o.getFwdBufferInfo=function(y,T){var I=this.config,G=this.getLoadPosition();if(!Object(V.isFiniteNumber)(G))return null;var X=H.BufferHelper.bufferInfo(y,G,I.maxBufferHole);if(X.len===0&&X.nextStart!==void 0){var Q=this.fragmentTracker.getBufferedFrag(G,T);if(Q&&X.nextStart<Q.end)return H.BufferHelper.bufferInfo(y,G,Math.max(X.nextStart,I.maxBufferHole))}return X},o.getMaxBufferLength=function(y){var T=this.config,I;return y?I=Math.max(8*T.maxBufferSize/y,T.maxBufferLength):I=T.maxBufferLength,Math.min(I,T.maxMaxBufferLength)},o.reduceMaxBufferLength=function(y){var T=this.config,I=y||T.maxBufferLength;return T.maxMaxBufferLength>=I?(T.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+T.maxMaxBufferLength+"s"),!0):!1},o.getNextFragment=function(y,T){var I,G,X=T.fragments,Q=X.length;if(!Q)return null;var z=this.config,W=X[0].start,ee;if(T.live){var ae=z.initialLiveManifestSize;if(Q<ae)return this.warn("Not enough fragments to start playback (have: "+Q+", need: "+ae+")"),null;!T.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(ee=this.getInitialLiveFragment(T,X),this.startPosition=ee?this.hls.liveSyncPosition||ee.start:y)}else y<=W&&(ee=X[0]);if(!ee){var pe=z.lowLatencyMode?T.partEnd:T.fragmentEnd;ee=this.getFragmentAtPosition(y,pe,T)}return(I=ee)!==null&&I!==void 0&&I.initSegment&&!((G=ee)!==null&&G!==void 0&&G.initSegment.data)&&!this.bitrateTest&&(ee=ee.initSegment),ee},o.getNextPart=function(y,T,I){for(var G=-1,X=!1,Q=!0,z=0,W=y.length;z<W;z++){var ee=y[z];if(Q=Q&&!ee.independent,G>-1&&I<ee.start)break;var ae=ee.loaded;!ae&&(X||ee.independent||Q)&&ee.fragment===T&&(G=z),X=ae}return G},o.loadedEndOfParts=function(y,T){var I=y[y.length-1];return I&&T>I.start&&I.loaded},o.getInitialLiveFragment=function(y,T){var I=this.fragPrevious,G=null;if(I){if(y.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+I.programDateTime),G=Object(L.findFragmentByPDT)(T,I.endProgramDateTime,this.config.maxFragLookUpTolerance)),!G){var X=I.sn+1;if(X>=y.startSN&&X<=y.endSN){var Q=T[X-y.startSN];I.cc===Q.cc&&(G=Q,this.log("Live playlist, switching playlist, load frag with next SN: "+G.sn))}G||(G=Object(L.findFragWithCC)(T,I.cc),G&&this.log("Live playlist, switching playlist, load frag with same CC: "+G.sn))}}else{var z=this.hls.liveSyncPosition;z!==null&&(G=this.getFragmentAtPosition(z,this.bitrateTest?y.fragmentEnd:y.edge,y))}return G},o.getFragmentAtPosition=function(y,T,I){var G=this.config,X=this.fragPrevious,Q=I.fragments,z=I.endSN,W=I.fragmentHint,ee=G.maxFragLookUpTolerance,ae=!!(G.lowLatencyMode&&I.partList&&W);ae&&W&&!this.bitrateTest&&(Q=Q.concat(W),z=W.sn);var pe;if(y<T){var ve=y>T-ee?0:ee;pe=Object(L.findFragmentByPTS)(X,Q,y,ve)}else pe=Q[Q.length-1];if(pe){var De=pe.sn-I.startSN,xe=X&&pe.level===X.level,Ce=Q[De+1],Ae=this.fragmentTracker.getState(pe);if(Ae===M.FragmentState.BACKTRACKED){pe=null;for(var Se=De;Q[Se]&&this.fragmentTracker.getState(Q[Se])===M.FragmentState.BACKTRACKED;)X?pe=Q[Se--]:pe=Q[--Se];pe||(pe=Ce)}else X&&pe.sn===X.sn&&!ae&&(xe&&(pe.sn<z&&this.fragmentTracker.getState(Ce)!==M.FragmentState.OK?(this.log("SN "+pe.sn+" just loaded, load next one: "+Ce.sn),pe=Ce):pe=null))}return pe},o.synchronizeToLiveEdge=function(y){var T=this.config,I=this.media;if(!I)return;var G=this.hls.liveSyncPosition,X=I.currentTime,Q=y.fragments[0].start,z=y.edge,W=X>=Q-T.maxFragLookUpTolerance&&X<=z;if(G!==null&&I.duration>G&&(X<G||!W)){var ee=T.liveMaxLatencyDuration!==void 0?T.liveMaxLatencyDuration:T.liveMaxLatencyDurationCount*y.targetduration;(!W&&I.readyState<4||X<z-ee)&&(this.loadedmetadata||(this.nextLoadPosition=G),I.readyState&&(this.warn("Playback: "+X.toFixed(3)+" is located too far from the end of live sliding playlist: "+z+", reset currentTime to : "+G.toFixed(3)),I.currentTime=G))}},o.alignPlaylists=function(y,T){var I=this.levels,G=this.levelLastLoaded,X=this.fragPrevious,Q=G!==null?I[G]:null,z=y.fragments.length;if(!z)return this.warn("No fragments in live playlist"),0;var W=y.fragments[0].start,ee=!T,ae=y.alignedSliding&&Object(V.isFiniteNumber)(W);if(ee||!ae&&!W){Object(D.alignStream)(X,Q,y);var pe=y.fragments[0].start;return this.log("Live playlist sliding: "+pe.toFixed(2)+" start-sn: "+(T?T.startSN:"na")+"->"+y.startSN+" prev-sn: "+(X?X.sn:"na")+" fragments: "+z),pe}return W},o.waitForCdnTuneIn=function(y){var T=3;return y.live&&y.canBlockReload&&y.tuneInGoal>Math.max(y.partHoldBack,y.partTarget*T)},o.setStartPosition=function(y,T){var I=this.startPosition;if(I<T&&(I=-1),I===-1||this.lastCurrentTime===-1){var G=y.startTimeOffset;Object(V.isFiniteNumber)(G)?(I=T+G,G<0&&(I+=y.totalduration),I=Math.min(Math.max(T,I),T+y.totalduration),this.log("Start time offset "+G+" found in playlist, adjust startPosition to "+I),this.startPosition=I):y.live?I=this.hls.liveSyncPosition||T:this.startPosition=I=0,this.lastCurrentTime=I}this.nextLoadPosition=I},o.getLoadPosition=function(){var y=this.media,T=0;return this.loadedmetadata&&y?T=y.currentTime:this.nextLoadPosition&&(T=this.nextLoadPosition),T},o.handleFragLoadAborted=function(y,T){this.transmuxer&&y.sn!=="initSegment"&&y.stats.aborted&&(this.warn("Fragment "+y.sn+(T?" part"+T.index:"")+" of level "+y.level+" was aborted"),this.resetFragmentLoading(y))},o.resetFragmentLoading=function(y){(!this.fragCurrent||!this.fragContextChanged(y))&&(this.state=v.IDLE)},o.onFragmentOrKeyLoadError=function(y,T){if(T.fatal)return;var I=T.frag;if(!I||I.type!==y)return;var G=this.fragCurrent;console.assert(G&&I.sn===G.sn&&I.level===G.level&&I.urlId===G.urlId,"Frag load error must match current frag to retry");var X=this.config;if(this.fragLoadError+1<=X.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(I.level))return;var Q=Math.min(Math.pow(2,this.fragLoadError)*X.fragLoadingRetryDelay,X.fragLoadingMaxRetryTimeout);this.warn("Fragment "+I.sn+" of "+y+" "+I.level+" failed to load, retrying in "+Q+"ms"),this.retryDate=self.performance.now()+Q,this.fragLoadError++,this.state=v.FRAG_LOADING_WAITING_RETRY}else T.levelRetry?(y===l.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=v.IDLE):(F.logger.error(T.details+" reaches max retry, redispatch as fatal ..."),T.fatal=!0,this.hls.stopLoad(),this.state=v.ERROR)},o.afterBufferFlushed=function(y,T,I){if(!y)return;var G=H.BufferHelper.getBuffered(y);this.fragmentTracker.detectEvictedFragments(T,G,I),this.state===v.ENDED&&this.resetLoadingState()},o.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=v.IDLE},o.resetLiveStartWhenNotLoaded=function(y){if(!this.loadedmetadata){this.startFragRequested=!1;var T=this.levels?this.levels[y].details:null;if(T!=null&&T.live)return this.startPosition=-1,this.setStartPosition(T,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},o.updateLevelTiming=function(y,T,I,G){var X=this,Q=I.details;console.assert(!!Q,"level.details must be defined");var z=Object.keys(y.elementaryStreams).reduce(function(W,ee){var ae=y.elementaryStreams[ee];if(ae){var pe=ae.endPTS-ae.startPTS;if(pe<=0)return X.warn("Could not parse fragment "+y.sn+" "+ee+" duration reliably ("+pe+") resetting transmuxer to fallback to playlist timing"),X.resetTransmuxer(),W||!1;var ve=G?0:Object(w.updateFragPTSDTS)(Q,y,ae.startPTS,ae.endPTS,ae.startDTS,ae.endDTS);return X.hls.trigger(P.Events.LEVEL_PTS_UPDATED,{details:Q,level:I,drift:ve,type:ee,frag:y,start:ae.startPTS,end:ae.endPTS}),!0}return W},!1);z?(this.state=v.PARSED,this.hls.trigger(P.Events.FRAG_PARSED,{frag:y,part:T})):this.resetLoadingState()},o.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},C(d,[{key:"state",get:function(){return this._state},set:function(y){var T=this._state;T!==y&&(this._state=y,this.log(T+"->"+y))}}]),d}(N.default)},"./src/controller/buffer-controller.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return L});var V=_("./src/polyfills/number.ts"),N=_("./src/events.ts"),M=_("./src/utils/logger.ts"),H=_("./src/errors.ts"),F=_("./src/utils/buffer-helper.ts"),P=_("./src/utils/mediasource-helper.ts"),O=_("./src/loader/fragment.ts"),b=_("./src/controller/buffer-operation-queue.ts"),A=Object(P.getMediaSource)(),D=/([ha]vc.)(?:\.[^.,]+)+/,L=function(){function w(u){var a=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var l=a.hls,h=a.media,C=a.mediaSource;M.logger.log("[buffer-controller]: Media source opened"),h&&(a.updateMediaElementDuration(),l.trigger(N.Events.MEDIA_ATTACHED,{media:h})),C&&C.removeEventListener("sourceopen",a._onMediaSourceOpen),a.checkPendingTracks()},this._onMediaSourceClose=function(){M.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){M.logger.log("[buffer-controller]: Media source ended")},this.hls=u,this._initSourceBuffer(),this.registerListeners()}var x=w.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 a=this.hls;a.on(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(N.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(N.Events.BUFFER_RESET,this.onBufferReset,this),a.on(N.Events.BUFFER_APPENDING,this.onBufferAppending,this),a.on(N.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.on(N.Events.BUFFER_EOS,this.onBufferEos,this),a.on(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),a.on(N.Events.LEVEL_UPDATED,this.onLevelUpdated,this),a.on(N.Events.FRAG_PARSED,this.onFragParsed,this),a.on(N.Events.FRAG_CHANGED,this.onFragChanged,this)},x.unregisterListeners=function(){var a=this.hls;a.off(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(N.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(N.Events.BUFFER_RESET,this.onBufferReset,this),a.off(N.Events.BUFFER_APPENDING,this.onBufferAppending,this),a.off(N.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.off(N.Events.BUFFER_EOS,this.onBufferEos,this),a.off(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),a.off(N.Events.LEVEL_UPDATED,this.onLevelUpdated,this),a.off(N.Events.FRAG_PARSED,this.onFragParsed,this),a.off(N.Events.FRAG_CHANGED,this.onFragChanged,this)},x._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new b.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},x.onManifestParsed=function(a,l){var h=2;(l.audio&&!l.video||!l.altAudio)&&(h=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=h,this.details=null,M.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},x.onMediaAttaching=function(a,l){var h=this.media=l.media;if(h&&A){var C=this.mediaSource=new A;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 a=this.media,l=this.mediaSource,h=this._objectUrl;if(l){if(M.logger.log("[buffer-controller]: media source detaching"),l.readyState==="open")try{l.endOfStream()}catch(C){M.logger.warn("[buffer-controller]: onMediaDetaching: "+C.message+" while calling endOfStream")}this.onBufferReset(),l.removeEventListener("sourceopen",this._onMediaSourceOpen),l.removeEventListener("sourceended",this._onMediaSourceEnded),l.removeEventListener("sourceclose",this._onMediaSourceClose),a&&(h&&self.URL.revokeObjectURL(h),a.src===h?(a.removeAttribute("src"),a.load()):M.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(N.Events.MEDIA_DETACHED,void 0)},x.onBufferReset=function(){var a=this;this.getSourceBufferTypes().forEach(function(l){var h=a.sourceBuffer[l];try{h&&(a.removeBufferListeners(l),a.mediaSource&&a.mediaSource.removeSourceBuffer(h),a.sourceBuffer[l]=void 0)}catch(C){M.logger.warn("[buffer-controller]: Failed to reset the "+l+" buffer",C)}}),this._initSourceBuffer()},x.onBufferCodecs=function(a,l){var h=this,C=this.getSourceBufferTypes().length;if(Object.keys(l).forEach(function(g){if(C){var m=h.tracks[g];if(m&&typeof m.buffer.changeType=="function"){var k=l[g],v=k.codec,f=k.levelCodec,p=k.container,d=(m.levelCodec||m.codec).replace(D,"$1"),o=(f||v).replace(D,"$1");if(d!==o){var S=p+";codecs="+(f||v);h.appendChangeType(g,S)}}}else h.pendingTracks[g]=l[g]}),C)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},x.appendChangeType=function(a,l){var h=this,C=this.operationQueue,g={execute:function(){var k=h.sourceBuffer[a];k&&(M.logger.log("[buffer-controller]: changing "+a+" sourceBuffer type to "+l),k.changeType(l)),C.shiftAndExecuteNext(a)},onStart:function(){},onComplete:function(){},onError:function(k){M.logger.warn("[buffer-controller]: Failed to change "+a+" SourceBuffer type",k)}};C.append(g,a)},x.onBufferAppending=function(a,l){var h=this,C=this.hls,g=this.operationQueue,m=this.tracks,k=l.data,v=l.type,f=l.frag,p=l.part,d=l.chunkMeta,o=d.buffering[v],S=self.performance.now();o.start=S;var y=f.stats.buffering,T=p?p.stats.buffering:null;y.start===0&&(y.start=S),T&&T.start===0&&(T.start=S);var I=m.audio,G=v==="audio"&&d.id===1&&(I==null?void 0:I.container)==="audio/mpeg",X={execute:function(){if(o.executeStart=self.performance.now(),G){var z=h.sourceBuffer[v];if(z){var W=f.start-z.timestampOffset;Math.abs(W)>=.1&&(M.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+f.start+" (delta: "+W+") sn: "+f.sn+")"),z.timestampOffset=f.start)}}h.appendExecutor(k,v)},onStart:function(){},onComplete:function(){var z=self.performance.now();o.executeEnd=o.end=z,y.first===0&&(y.first=z),T&&T.first===0&&(T.first=z);var W=h.sourceBuffer,ee={};for(var ae in W)ee[ae]=F.BufferHelper.getBuffered(W[ae]);h.appendError=0,h.hls.trigger(N.Events.BUFFER_APPENDED,{type:v,frag:f,part:p,chunkMeta:d,parent:f.type,timeRanges:ee})},onError:function(z){M.logger.error("[buffer-controller]: Error encountered while trying to append to the "+v+" SourceBuffer",z);var W={type:H.ErrorTypes.MEDIA_ERROR,parent:f.type,details:H.ErrorDetails.BUFFER_APPEND_ERROR,err:z,fatal:!1};z.code===DOMException.QUOTA_EXCEEDED_ERR?W.details=H.ErrorDetails.BUFFER_FULL_ERROR:(h.appendError++,W.details=H.ErrorDetails.BUFFER_APPEND_ERROR,h.appendError>C.config.appendErrorMaxRetry&&(M.logger.error("[buffer-controller]: Failed "+C.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),W.fatal=!0)),C.trigger(N.Events.ERROR,W)}};g.append(X,v)},x.onBufferFlushing=function(a,l){var h=this,C=this.operationQueue,g=function(k){return{execute:h.removeExecutor.bind(h,k,l.startOffset,l.endOffset),onStart:function(){},onComplete:function(){h.hls.trigger(N.Events.BUFFER_FLUSHED,{type:k})},onError:function(f){M.logger.warn("[buffer-controller]: Failed to remove from "+k+" SourceBuffer",f)}}};l.type?C.append(g(l.type),l.type):this.getSourceBufferTypes().forEach(function(m){C.append(g(m),m)})},x.onFragParsed=function(a,l){var h=this,C=l.frag,g=l.part,m=[],k=g?g.elementaryStreams:C.elementaryStreams;k[O.ElementaryStreamTypes.AUDIOVIDEO]?m.push("audiovideo"):(k[O.ElementaryStreamTypes.AUDIO]&&m.push("audio"),k[O.ElementaryStreamTypes.VIDEO]&&m.push("video"));var v=function(){var p=self.performance.now();C.stats.buffering.end=p,g&&(g.stats.buffering.end=p);var d=g?g.stats:C.stats;h.hls.trigger(N.Events.FRAG_BUFFERED,{frag:C,part:g,stats:d,id:C.type})};m.length===0&&M.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+C.type+" level: "+C.level+" sn: "+C.sn),this.blockBuffers(v,m)},x.onFragChanged=function(a,l){this.flushBackBuffer()},x.onBufferEos=function(a,l){var h=this,C=this.getSourceBufferTypes().reduce(function(g,m){var k=h.sourceBuffer[m];return(!l.type||l.type===m)&&(k&&!k.ended&&(k.ended=!0,M.logger.log("[buffer-controller]: "+m+" sourceBuffer now EOS"))),g&&!!(!k||k.ended)},!0);C&&this.blockBuffers(function(){var g=h.mediaSource;if(!g||g.readyState!=="open")return;g.endOfStream()})},x.onLevelUpdated=function(a,l){var h=l.details;if(!h.fragments.length)return;this.details=h,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},x.flushBackBuffer=function(){var a=this.hls,l=this.details,h=this.media,C=this.sourceBuffer;if(!h||l===null)return;var g=this.getSourceBufferTypes();if(!g.length)return;var m=l.live&&a.config.liveBackBufferLength!==null?a.config.liveBackBufferLength:a.config.backBufferLength;if(!Object(V.isFiniteNumber)(m)||m<0)return;var k=h.currentTime,v=l.levelTargetDuration,f=Math.max(m,v),p=Math.floor(k/v)*v-f;g.forEach(function(d){var o=C[d];if(o){var S=F.BufferHelper.getBuffered(o);S.length>0&&p>S.start(0)&&(a.trigger(N.Events.BACK_BUFFER_REACHED,{bufferEnd:p}),l.live&&a.trigger(N.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:p}),a.trigger(N.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:p,type:d}))}})},x.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var a=this.details,l=this.hls,h=this.media,C=this.mediaSource,g=a.fragments[0].start+a.totalduration,m=h.duration,k=Object(V.isFiniteNumber)(C.duration)?C.duration:0;a.live&&l.config.liveDurationInfinity?(M.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),C.duration=Infinity,this.updateSeekableRange(a)):(g>k&&g>m||!Object(V.isFiniteNumber)(m))&&(M.logger.log("[buffer-controller]: Updating Media Source duration to "+g.toFixed(3)),C.duration=g)},x.updateSeekableRange=function(a){var l=this.mediaSource,h=a.fragments,C=h.length;if(C&&a.live&&l!==null&&l!==void 0&&l.setLiveSeekableRange){var g=Math.max(0,h[0].start),m=Math.max(g,g+a.totalduration);l.setLiveSeekableRange(g,m)}},x.checkPendingTracks=function(){var a=this.bufferCodecEventsExpected,l=this.operationQueue,h=this.pendingTracks,C=Object.keys(h).length;if(C&&!a||C===2){this.createSourceBuffers(h),this.pendingTracks={};var g=this.getSourceBufferTypes();if(g.length===0){this.hls.trigger(N.Events.ERROR,{type:H.ErrorTypes.MEDIA_ERROR,details:H.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}g.forEach(function(m){l.executeNext(m)})}},x.createSourceBuffers=function(a){var l=this.sourceBuffer,h=this.mediaSource;if(!h)throw Error("createSourceBuffers called when mediaSource was null");var C=0;for(var g in a)if(!l[g]){var m=a[g];if(!m)throw Error("source buffer exists for track "+g+", however track does not");var k=m.levelCodec||m.codec,v=m.container+";codecs="+k;M.logger.log("[buffer-controller]: creating sourceBuffer("+v+")");try{var f=l[g]=h.addSourceBuffer(v),p=g;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[g]={buffer:f,codec:k,container:m.container,levelCodec:m.levelCodec,id:m.id},C++}catch(d){M.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+d.message),this.hls.trigger(N.Events.ERROR,{type:H.ErrorTypes.MEDIA_ERROR,details:H.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,mimeType:v})}}C&&this.hls.trigger(N.Events.BUFFER_CREATED,{tracks:this.tracks})},x._onSBUpdateStart=function(a){var l=this.operationQueue,h=l.current(a);h.onStart()},x._onSBUpdateEnd=function(a){var l=this.operationQueue,h=l.current(a);h.onComplete(),l.shiftAndExecuteNext(a)},x._onSBUpdateError=function(a,l){M.logger.error("[buffer-controller]: "+a+" SourceBuffer error",l),this.hls.trigger(N.Events.ERROR,{type:H.ErrorTypes.MEDIA_ERROR,details:H.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var h=this.operationQueue.current(a);h&&h.onError(l)},x.removeExecutor=function(a,l,h){var C=this.media,g=this.mediaSource,m=this.operationQueue,k=this.sourceBuffer,v=k[a];if(!C||!g||!v){M.logger.warn("[buffer-controller]: Attempting to remove from the "+a+" SourceBuffer, but it does not exist"),m.shiftAndExecuteNext(a);return}var f=Object(V.isFiniteNumber)(C.duration)?C.duration:Infinity,p=Object(V.isFiniteNumber)(g.duration)?g.duration:Infinity,d=Math.max(0,l),o=Math.min(h,f,p);o>d?(M.logger.log("[buffer-controller]: Removing ["+d+","+o+"] from the "+a+" SourceBuffer"),console.assert(!v.updating,a+" sourceBuffer must not be updating"),v.remove(d,o)):m.shiftAndExecuteNext(a)},x.appendExecutor=function(a,l){var h=this.operationQueue,C=this.sourceBuffer,g=C[l];if(!g){M.logger.warn("[buffer-controller]: Attempting to append to the "+l+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(l);return}g.ended=!1,console.assert(!g.updating,l+" sourceBuffer must not be updating"),g.appendBuffer(a)},x.blockBuffers=function(a,l){var h=this;if(l===void 0&&(l=this.getSourceBufferTypes()),!l.length){M.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(a);return}var C=this.operationQueue,g=l.map(function(m){return C.appendBlocker(m)});Promise.all(g).then(function(){a(),l.forEach(function(m){var k=h.sourceBuffer[m];(!k||!k.updating)&&C.shiftAndExecuteNext(m)})})},x.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},x.addBufferListener=function(a,l,h){var C=this.sourceBuffer[a];if(!C)return;var g=h.bind(this,a);this.listeners[a].push({event:l,listener:g}),C.addEventListener(l,g)},x.removeBufferListeners=function(a){var l=this.sourceBuffer[a];if(!l)return;this.listeners[a].forEach(function(h){l.removeEventListener(h.event,h.listener)})},w}()},"./src/controller/buffer-operation-queue.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return N});var V=_("./src/utils/logger.ts"),N=function(){function M(F){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=F}var H=M.prototype;return H.append=function(P,O){var b=this.queues[O];b.push(P),b.length===1&&this.buffers[O]&&this.executeNext(O)},H.insertAbort=function(P,O){var b=this.queues[O];b.unshift(P),this.executeNext(O)},H.appendBlocker=function(P){var O,b=new Promise(function(D){O=D}),A={execute:O,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(A,P),b},H.executeNext=function(P){var O=this.buffers,b=this.queues,A=O[P],D=b[P];if(D.length){var L=D[0];try{L.execute()}catch(w){V.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),L.onError(w),(!A||!A.updating)&&(D.shift(),this.executeNext(P))}}},H.shiftAndExecuteNext=function(P){this.queues[P].shift(),this.executeNext(P)},H.current=function(P){return this.queues[P][0]},M}()},"./src/controller/cap-level-controller.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/events.ts");function N(F,P){for(var O=0;O<P.length;O++){var b=P[O];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(F,b.key,b)}}function M(F,P,O){return P&&N(F.prototype,P),O&&N(F,O),F}var H=function(){function F(O){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=O,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var P=F.prototype;return P.setStreamController=function(b){this.streamController=b},P.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},P.registerListeners=function(){var b=this.hls;b.on(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),b.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),b.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),b.on(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),b.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},P.unregisterListener=function(){var b=this.hls;b.off(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),b.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),b.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),b.off(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),b.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},P.onFpsDropLevelCapping=function(b,A){F.isLevelAllowed(A.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(A.droppedLevel)},P.onMediaAttaching=function(b,A){this.media=A.media instanceof HTMLVideoElement?A.media:null},P.onManifestParsed=function(b,A){var D=this.hls;this.restrictedLevels=[],this.firstLevel=A.firstLevel,D.config.capLevelToPlayerSize&&A.video&&this.startCapping()},P.onBufferCodecs=function(b,A){var D=this.hls;D.config.capLevelToPlayerSize&&A.video&&this.startCapping()},P.onMediaDetaching=function(){this.stopCapping()},P.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var b=this.hls.levels;if(b.length){var A=this.hls;A.autoLevelCapping=this.getMaxLevel(b.length-1),A.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=A.autoLevelCapping}}},P.getMaxLevel=function(b){var A=this,D=this.hls.levels;if(!D.length)return-1;var L=D.filter(function(w,x){return F.isLevelAllowed(x,A.restrictedLevels)&&x<=b});return this.clientRect=null,F.getMaxLevelByMediaSize(L,this.mediaWidth,this.mediaHeight)},P.startCapping=function(){if(this.timer)return;this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize()},P.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},P.getDimensions=function(){if(this.clientRect)return this.clientRect;var b=this.media,A={width:0,height:0};if(b){var D=b.getBoundingClientRect();A.width=D.width,A.height=D.height,!A.width&&!A.height&&(A.width=D.right-D.left||b.width||0,A.height=D.bottom-D.top||b.height||0)}return this.clientRect=A,A},F.isLevelAllowed=function(b,A){return A===void 0&&(A=[]),A.indexOf(b)===-1},F.getMaxLevelByMediaSize=function(b,A,D){if(!b||!b.length)return-1;for(var L=function(l,h){return h?l.width!==h.width||l.height!==h.height:!0},w=b.length-1,x=0;x<b.length;x+=1){var u=b[x];if((u.width>=A||u.height>=D)&&L(u,b[x+1])){w=x;break}}return w},M(F,[{key:"mediaWidth",get:function(){return this.getDimensions().width*F.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*F.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var b=1;try{b=self.devicePixelRatio}catch(A){}return b}}]),F}();$.default=H},"./src/controller/cmcd-controller.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return L});var V=_("./src/events.ts"),N=_("./src/types/cmcd.ts"),M=_("./src/utils/buffer-helper.ts"),H=_("./src/utils/logger.ts");function F(w,x){for(var u=0;u<x.length;u++){var a=x[u];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(w,a.key,a)}}function P(w,x,u){return x&&F(w.prototype,x),u&&F(w,u),w}function O(w,x){var u=typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(u)return(u=u.call(w)).next.bind(u);if(Array.isArray(w)||(u=b(w))||x&&w&&typeof w.length=="number"){u&&(w=u);var a=0;return function(){return a>=w.length?{done:!0}:{done:!1,value:w[a++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function b(w,x){if(!w)return;if(typeof w=="string")return A(w,x);var u=Object.prototype.toString.call(w).slice(8,-1);if(u==="Object"&&w.constructor&&(u=w.constructor.name),u==="Map"||u==="Set")return Array.from(w);if(u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))return A(w,x)}function A(w,x){(x==null||x>w.length)&&(x=w.length);for(var u=0,a=new Array(x);u<x;u++)a[u]=w[u];return a}function D(){return D=Object.assign||function(w){for(var x=1;x<arguments.length;x++){var u=arguments[x];for(var a in u)Object.prototype.hasOwnProperty.call(u,a)&&(w[a]=u[a])}return w},D.apply(this,arguments)}var L=function(){function w(u){var a=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){a.initialized&&(a.starved=!0),a.buffering=!0},this.onPlaying=function(){a.initialized||(a.initialized=!0),a.buffering=!1},this.applyPlaylistData=function(C){try{a.apply(C,{ot:N.CMCDObjectType.MANIFEST,su:!a.initialized})}catch(g){H.logger.warn("Could not generate manifest CMCD data.",g)}},this.applyFragmentData=function(C){try{var g=C.frag,m=a.hls.levels[g.level],k=a.getObjectType(g),v={d:g.duration*1e3,ot:k};(k===N.CMCDObjectType.VIDEO||k===N.CMCDObjectType.AUDIO||k==N.CMCDObjectType.MUXED)&&(v.br=m.bitrate/1e3,v.tb=a.getTopBandwidth(k),v.bl=a.getBufferLength(k)),a.apply(C,v)}catch(f){H.logger.warn("Could not generate segment CMCD data.",f)}},this.hls=u;var l=this.config=u.config,h=l.cmcd;h!=null&&(l.pLoader=this.createPlaylistLoader(),l.fLoader=this.createFragmentLoader(),this.sid=h.sessionId||w.uuid(),this.cid=h.contentId,this.useHeaders=h.useHeaders===!0,this.registerListeners())}var x=w.prototype;return x.registerListeners=function(){var a=this.hls;a.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.on(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),a.on(V.Events.BUFFER_CREATED,this.onBufferCreated,this)},x.unregisterListeners=function(){var a=this.hls;a.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.off(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),a.off(V.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},x.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},x.onMediaAttached=function(a,l){this.media=l.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(a,l){var h,C;this.audioBuffer=(h=l.tracks.audio)===null||h===void 0?void 0:h.buffer,this.videoBuffer=(C=l.tracks.video)===null||C===void 0?void 0:C.buffer},x.createData=function(){var a;return{v:N.CMCDVersion,sf:N.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(a=this.media)===null||a===void 0?void 0:a.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},x.apply=function(a,l){l===void 0&&(l={}),D(l,this.createData());var h=l.ot===N.CMCDObjectType.INIT||l.ot===N.CMCDObjectType.VIDEO||l.ot===N.CMCDObjectType.MUXED;if(this.starved&&h&&(l.bs=!0,l.su=!0,this.starved=!1),l.su==null&&(l.su=this.buffering),this.useHeaders){var C=w.toHeaders(l);if(!Object.keys(C).length)return;a.headers||(a.headers={}),D(a.headers,C)}else{var g=w.toQuery(l);if(!g)return;a.url=w.appendQueryToUri(a.url,g)}},x.getObjectType=function(a){var l=a.type;return l==="subtitle"?N.CMCDObjectType.TIMED_TEXT:a.sn==="initSegment"?N.CMCDObjectType.INIT:l==="audio"?N.CMCDObjectType.AUDIO:l==="main"?this.hls.audioTracks.length?N.CMCDObjectType.VIDEO:N.CMCDObjectType.MUXED:void 0},x.getTopBandwidth=function(a){for(var l=0,h=a===N.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,C=O(h),g;!(g=C()).done;){var m=g.value;m.bitrate>l&&(l=m.bitrate)}return l>0?l:NaN},x.getBufferLength=function(a){var l=this.hls.media,h=a===N.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!h||!l)return NaN;var C=M.BufferHelper.bufferInfo(h,l.currentTime,this.config.maxBufferHole);return C.len*1e3},x.createPlaylistLoader=function(){var a=this.config.pLoader,l=this.applyPlaylistData,h=a||this.config.loader;return function(){function C(m){this.loader=void 0,this.loader=new h(m)}var g=C.prototype;return g.destroy=function(){this.loader.destroy()},g.abort=function(){this.loader.abort()},g.load=function(k,v,f){l(k),this.loader.load(k,v,f)},P(C,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),C}()},x.createFragmentLoader=function(){var a=this.config.fLoader,l=this.applyFragmentData,h=a||this.config.loader;return function(){function C(m){this.loader=void 0,this.loader=new h(m)}var g=C.prototype;return g.destroy=function(){this.loader.destroy()},g.abort=function(){this.loader.abort()},g.load=function(k,v,f){l(k),this.loader.load(k,v,f)},P(C,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),C}()},w.uuid=function(){var a=URL.createObjectURL(new Blob),l=a.toString();return URL.revokeObjectURL(a),l.substr(l.lastIndexOf("/")+1)},w.serialize=function(a){for(var l=[],h=function(G){return!Number.isNaN(G)&&G!=null&&G!==""&&G!==!1},C=function(G){return Math.round(G)},g=function(G){return C(G/100)*100},m=function(G){return encodeURIComponent(G)},k={br:C,d:C,bl:g,dl:g,mtp:g,nor:m,rtp:g,tb:C},v=Object.keys(a||{}).sort(),f=O(v),p;!(p=f()).done;){var d=p.value,o=a[d];if(!h(o))continue;if(d==="v"&&o===1)continue;if(d=="pr"&&o===1)continue;var S=k[d];S&&(o=S(o));var y=typeof o,T=void 0;d==="ot"||d==="sf"||d==="st"?T=d+"="+o:y==="boolean"?T=d:y==="number"?T=d+"="+o:T=d+"="+JSON.stringify(o),l.push(T)}return l.join(",")},w.toHeaders=function(a){for(var l=Object.keys(a),h={},C=["Object","Request","Session","Status"],g=[{},{},{},{}],m={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},k=0,v=l;k<v.length;k++){var f=v[k],p=m[f]!=null?m[f]:1;g[p][f]=a[f]}for(var d=0;d<g.length;d++){var o=w.serialize(g[d]);o&&(h["CMCD-"+C[d]]=o)}return h},w.toQuery=function(a){return"CMCD="+encodeURIComponent(w.serialize(a))},w.appendQueryToUri=function(a,l){if(!l)return a;var h=a.includes("?")?"&":"?";return""+a+h+l},w}()},"./src/controller/eme-controller.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/events.ts"),N=_("./src/errors.ts"),M=_("./src/utils/logger.ts"),H=_("./src/utils/mediakeys-helper.ts");function F(L,w){for(var x=0;x<w.length;x++){var u=w[x];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(L,u.key,u)}}function P(L,w,x){return w&&F(L.prototype,w),x&&F(L,x),L}var O=3,b=function(w,x,u){var a={audioCapabilities:[],videoCapabilities:[]};return w.forEach(function(l){a.audioCapabilities.push({contentType:'audio/mp4; codecs="'+l+'"',robustness:u.audioRobustness||""})}),x.forEach(function(l){a.videoCapabilities.push({contentType:'video/mp4; codecs="'+l+'"',robustness:u.videoRobustness||""})}),[a]},A=function(w,x,u,a){switch(w){case H.KeySystems.WIDEVINE:return b(x,u,a);default:throw new Error("Unknown key-system: "+w)}},D=function(){function L(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 w=L.prototype;return w.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},w._registerListeners=function(){this.hls.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this)},w._unregisterListeners=function(){this.hls.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this)},w.getLicenseServerUrl=function(u){switch(u){case H.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+u+'"')},w._attemptKeySystemAccess=function(u,a,l){var h=this,C=A(u,a,l,this._drmSystemOptions);M.logger.log("Requesting encrypted media key-system access");var g=this.requestMediaKeySystemAccess(u,C);this.mediaKeysPromise=g.then(function(m){return h._onMediaKeySystemAccessObtained(u,m)}),g.catch(function(m){M.logger.error('Failed to obtain key-system "'+u+'" access:',m)})},w._onMediaKeySystemAccessObtained=function(u,a){var l=this;M.logger.log('Access for key-system "'+u+'" obtained');var h={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:a,mediaKeySystemDomain:u};this._mediaKeysList.push(h);var C=Promise.resolve().then(function(){return a.createMediaKeys()}).then(function(g){return h.mediaKeys=g,M.logger.log('Media-keys created for key-system "'+u+'"'),l._onMediaKeysCreated(),g});return C.catch(function(g){M.logger.error("Failed to create media-keys:",g)}),C},w._onMediaKeysCreated=function(){var u=this;this._mediaKeysList.forEach(function(a){a.mediaKeysSession||(a.mediaKeysSession=a.mediaKeys.createSession(),u._onNewMediaKeySession(a.mediaKeysSession))})},w._onNewMediaKeySession=function(u){var a=this;M.logger.log("New key-system session "+u.sessionId),u.addEventListener("message",function(l){a._onKeySessionMessage(u,l.message)},!1)},w._onKeySessionMessage=function(u,a){M.logger.log("Got EME message event, creating license request"),this._requestLicense(a,function(l){M.logger.log("Received license data (length: "+(l&&l.byteLength)+"), updating key-session"),u.update(l)})},w.onMediaEncrypted=function(u){var a=this;if(M.logger.log('Media is encrypted using "'+u.initDataType+'" init data type'),!this.mediaKeysPromise){M.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var l=function(C){if(!a._media)return;a._attemptSetMediaKeys(C),a._generateRequestWithPreferredKeySession(u.initDataType,u.initData)};this.mediaKeysPromise.then(l).catch(l)},w._attemptSetMediaKeys=function(u){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var a=this._mediaKeysList[0];if(!a||!a.mediaKeys){M.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}M.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(a.mediaKeys),this._hasSetMediaKeys=!0}},w._generateRequestWithPreferredKeySession=function(u,a){var l=this,h=this._mediaKeysList[0];if(!h){M.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(h.mediaKeysSessionInitialized){M.logger.warn("Key-Session already initialized but requested again");return}var C=h.mediaKeysSession;if(!C){M.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!a){M.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}M.logger.log('Generating key-session request for "'+u+'" init data type'),h.mediaKeysSessionInitialized=!0,C.generateRequest(u,a).then(function(){M.logger.debug("Key-session generation succeeded")}).catch(function(g){M.logger.error("Error generating key-session request:",g),l.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},w._createLicenseXhr=function(u,a,l){var h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,h,u,a,l);var C=this._licenseXhrSetup;if(C)try{C.call(this.hls,h,u),C=void 0}catch(g){M.logger.error(g)}try{h.readyState||h.open("POST",u,!0),C&&C.call(this.hls,h,u)}catch(g){throw new Error("issue setting up KeySystem license XHR "+g)}return h},w._onLicenseRequestReadyStageChange=function(u,a,l,h){switch(u.readyState){case 4:if(u.status===200){this._requestLicenseFailureCount=0,M.logger.log("License request succeeded");var C=u.response,g=this._licenseResponseCallback;if(g)try{C=g.call(this.hls,u,a)}catch(k){M.logger.error(k)}h(C)}else{if(M.logger.error("License Request XHR failed ("+a+"). Status: "+u.status+" ("+u.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>O){this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var m=O-this._requestLicenseFailureCount+1;M.logger.warn("Retrying license request, "+m+" attempts left"),this._requestLicense(l,h)}break}},w._generateLicenseRequestChallenge=function(u,a){switch(u.mediaKeySystemDomain){case H.KeySystems.WIDEVINE:return a}throw new Error("unsupported key-system: "+u.mediaKeySystemDomain)},w._requestLicense=function(u,a){M.logger.log("Requesting content license for key-system");var l=this._mediaKeysList[0];if(!l){M.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var h=this.getLicenseServerUrl(l.mediaKeySystemDomain),C=this._createLicenseXhr(h,u,a);M.logger.log("Sending license request to URL: "+h);var g=this._generateLicenseRequestChallenge(l,u);C.send(g)}catch(m){M.logger.error("Failure requesting DRM license: "+m),this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},w.onMediaAttached=function(u,a){if(!this._emeEnabled)return;var l=a.media;this._media=l,l.addEventListener("encrypted",this._onMediaEncrypted)},w.onMediaDetached=function(){var u=this._media,a=this._mediaKeysList;if(!u)return;u.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(a.map(function(l){if(l.mediaKeysSession)return l.mediaKeysSession.close().catch(function(){})})).then(function(){return u.setMediaKeys(null)}).catch(function(){})},w.onManifestParsed=function(u,a){if(!this._emeEnabled)return;var l=a.levels.map(function(C){return C.audioCodec}).filter(function(C){return!!C}),h=a.levels.map(function(C){return C.videoCodec}).filter(function(C){return!!C});this._attemptKeySystemAccess(H.KeySystems.WIDEVINE,l,h)},P(L,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),L}();$.default=D},"./src/controller/fps-controller.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/events.ts"),N=_("./src/utils/logger.ts"),M=function(){function H(P){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=P,this.registerListeners()}var F=H.prototype;return F.setStreamController=function(O){this.streamController=O},F.registerListeners=function(){this.hls.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},F.unregisterListeners=function(){this.hls.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching)},F.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},F.onMediaAttaching=function(O,b){var A=this.hls.config;if(A.capLevelOnFPSDrop){var D=b.media instanceof self.HTMLVideoElement?b.media:null;this.media=D,D&&typeof D.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),A.fpsDroppedMonitoringPeriod)}},F.checkFPS=function(O,b,A){var D=performance.now();if(b){if(this.lastTime){var L=D-this.lastTime,w=A-this.lastDroppedFrames,x=b-this.lastDecodedFrames,u=1e3*w/L,a=this.hls;if(a.trigger(V.Events.FPS_DROP,{currentDropped:w,currentDecoded:x,totalDroppedFrames:A}),u>0&&w>a.config.fpsDroppedMonitoringThreshold*x){var l=a.currentLevel;N.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(a.autoLevelCapping===-1||a.autoLevelCapping>=l)&&(l=l-1,a.trigger(V.Events.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:a.currentLevel}),a.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=D,this.lastDroppedFrames=A,this.lastDecodedFrames=b}},F.checkFPSInterval=function(){var O=this.media;if(O)if(this.isVideoPlaybackQualityAvailable){var b=O.getVideoPlaybackQuality();this.checkFPS(O,b.totalVideoFrames,b.droppedVideoFrames)}else this.checkFPS(O,O.webkitDecodedFrameCount,O.webkitDroppedFrameCount)},H}();$.default=M},"./src/controller/fragment-finders.ts":function(ne,$,_){"use strict";_.r($),_.d($,"findFragmentByPDT",function(){return M}),_.d($,"findFragmentByPTS",function(){return H}),_.d($,"fragmentWithinToleranceTest",function(){return F}),_.d($,"pdtWithinToleranceTest",function(){return P}),_.d($,"findFragWithCC",function(){return O});var V=_("./src/polyfills/number.ts"),N=_("./src/utils/binary-search.ts");function M(b,A,D){if(A===null||!Array.isArray(b)||!b.length||!Object(V.isFiniteNumber)(A))return null;var L=b[0].programDateTime;if(A<(L||0))return null;var w=b[b.length-1].endProgramDateTime;if(A>=(w||0))return null;D=D||0;for(var x=0;x<b.length;++x){var u=b[x];if(P(A,D,u))return u}return null}function H(b,A,D,L){D===void 0&&(D=0),L===void 0&&(L=0);var w=null;if(b?w=A[b.sn-A[0].sn+1]||null:D===0&&A[0].start===0&&(w=A[0]),w&&F(D,L,w)===0)return w;var x=N.default.search(A,F.bind(null,D,L));return x||w}function F(b,A,D){b===void 0&&(b=0),A===void 0&&(A=0);var L=Math.min(A,D.duration+(D.deltaPTS?D.deltaPTS:0));return D.start+D.duration-L<=b?1:D.start-L>b&&D.start?-1:0}function P(b,A,D){var L=Math.min(A,D.duration+(D.deltaPTS?D.deltaPTS:0))*1e3,w=D.endProgramDateTime||0;return w-L>b}function O(b,A){return N.default.search(b,function(D){return D.cc<A?1:D.cc>A?-1:0})}},"./src/controller/fragment-tracker.ts":function(ne,$,_){"use strict";_.r($),_.d($,"FragmentState",function(){return M}),_.d($,"FragmentTracker",function(){return H});var V=_("./src/events.ts"),N=_("./src/types/loader.ts"),M;(function(O){O.NOT_LOADED="NOT_LOADED",O.BACKTRACKED="BACKTRACKED",O.APPENDING="APPENDING",O.PARTIAL="PARTIAL",O.OK="OK"})(M||(M={}));var H=function(){function O(A){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=A,this._registerListeners()}var b=O.prototype;return b._registerListeners=function(){var D=this.hls;D.on(V.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.on(V.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.on(V.Events.FRAG_LOADED,this.onFragLoaded,this)},b._unregisterListeners=function(){var D=this.hls;D.off(V.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.off(V.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.off(V.Events.FRAG_LOADED,this.onFragLoaded,this)},b.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},b.getAppendedFrag=function(D,L){if(L===N.PlaylistLevelType.MAIN){var w=this.activeFragment,x=this.activeParts;if(!w)return null;if(x)for(var u=x.length;u--;){var a=x[u],l=a?a.end:w.appendedPTS;if(a.start<=D&&l!==void 0&&D<=l)return u>9&&(this.activeParts=x.slice(u-9)),a}else if(w.start<=D&&w.appendedPTS!==void 0&&D<=w.appendedPTS)return w}return this.getBufferedFrag(D,L)},b.getBufferedFrag=function(D,L){for(var w=this.fragments,x=Object.keys(w),u=x.length;u--;){var a=w[x[u]];if((a==null?void 0:a.body.type)===L&&a.buffered){var l=a.body;if(l.start<=D&&D<=l.end)return l}}return null},b.detectEvictedFragments=function(D,L,w){var x=this;Object.keys(this.fragments).forEach(function(u){var a=x.fragments[u];if(!a)return;if(!a.buffered){a.body.type===w&&x.removeFragment(a.body);return}var l=a.range[D];if(!l)return;l.time.some(function(h){var C=!x.isTimeBuffered(h.startPTS,h.endPTS,L);return C&&x.removeFragment(a.body),C})})},b.detectPartialFragments=function(D){var L=this,w=this.timeRanges,x=D.frag,u=D.part;if(!w||x.sn==="initSegment")return;var a=P(x),l=this.fragments[a];if(!l)return;Object.keys(w).forEach(function(h){var C=x.elementaryStreams[h];if(!C)return;var g=w[h],m=u!==null||C.partial===!0;l.range[h]=L.getBufferedTimes(x,u,m,g)}),l.backtrack=l.loaded=null,Object.keys(l.range).length?l.buffered=!0:this.removeFragment(l.body)},b.fragBuffered=function(D){var L=P(D),w=this.fragments[L];w&&(w.backtrack=w.loaded=null,w.buffered=!0)},b.getBufferedTimes=function(D,L,w,x){for(var u={time:[],partial:w},a=L?L.start:D.start,l=L?L.end:D.end,h=D.minEndPTS||l,C=D.maxStartPTS||a,g=0;g<x.length;g++){var m=x.start(g)-this.bufferPadding,k=x.end(g)+this.bufferPadding;if(C>=m&&h<=k){u.time.push({startPTS:Math.max(a,x.start(g)),endPTS:Math.min(l,x.end(g))});break}else if(a<k&&l>m)u.partial=!0,u.time.push({startPTS:Math.max(a,x.start(g)),endPTS:Math.min(l,x.end(g))});else if(l<=m)break}return u},b.getPartialFragment=function(D){var L=null,w,x,u,a=0,l=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(C){var g=h[C];if(!g)return;F(g)&&(x=g.body.start-l,u=g.body.end+l,D>=x&&D<=u&&(w=Math.min(D-x,u-D),a<=w&&(L=g.body,a=w)))}),L},b.getState=function(D){var L=P(D),w=this.fragments[L];return w?w.buffered?F(w)?M.PARTIAL:M.OK:w.backtrack?M.BACKTRACKED:M.APPENDING:M.NOT_LOADED},b.backtrack=function(D,L){var w=P(D),x=this.fragments[w];if(!x||x.backtrack)return null;var u=x.backtrack=L||x.loaded;return x.loaded=null,u},b.getBacktrackData=function(D){var L=P(D),w=this.fragments[L];if(w){var x,u=w.backtrack;if(u!=null&&(x=u.payload)!==null&&x!==void 0&&x.byteLength)return u;this.removeFragment(D)}return null},b.isTimeBuffered=function(D,L,w){for(var x,u,a=0;a<w.length;a++){if(x=w.start(a)-this.bufferPadding,u=w.end(a)+this.bufferPadding,D>=x&&L<=u)return!0;if(L<=x)return!1}return!1},b.onFragLoaded=function(D,L){var w=L.frag,x=L.part;if(w.sn==="initSegment"||w.bitrateTest||x)return;var u=P(w);this.fragments[u]={body:w,loaded:L,backtrack:null,buffered:!1,range:Object.create(null)}},b.onBufferAppended=function(D,L){var w=this,x=L.frag,u=L.part,a=L.timeRanges;if(x.type===N.PlaylistLevelType.MAIN)if(this.activeFragment=x,u){var l=this.activeParts;l||(this.activeParts=l=[]),l.push(u)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach(function(h){var C=a[h];if(w.detectEvictedFragments(h,C),!u)for(var g=0;g<C.length;g++)x.appendedPTS=Math.max(C.end(g),x.appendedPTS||0)})},b.onFragBuffered=function(D,L){this.detectPartialFragments(L)},b.hasFragment=function(D){var L=P(D);return!!this.fragments[L]},b.removeFragmentsInRange=function(D,L,w){var x=this;Object.keys(this.fragments).forEach(function(u){var a=x.fragments[u];if(!a)return;if(a.buffered){var l=a.body;l.type===w&&l.start<L&&l.end>D&&x.removeFragment(l)}})},b.removeFragment=function(D){var L=P(D);D.stats.loaded=0,D.clearElementaryStreamInfo(),delete this.fragments[L]},b.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},O}();function F(O){var b,A;return O.buffered&&(((b=O.range.video)===null||b===void 0?void 0:b.partial)||((A=O.range.audio)===null||A===void 0?void 0:A.partial))}function P(O){return O.type+"_"+O.level+"_"+O.urlId+"_"+O.sn}},"./src/controller/gap-controller.ts":function(ne,$,_){"use strict";_.r($),_.d($,"STALL_MINIMUM_DURATION_MS",function(){return F}),_.d($,"MAX_START_GAP_JUMP",function(){return P}),_.d($,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return O}),_.d($,"SKIP_BUFFER_RANGE_START",function(){return b}),_.d($,"default",function(){return A});var V=_("./src/utils/buffer-helper.ts"),N=_("./src/errors.ts"),M=_("./src/events.ts"),H=_("./src/utils/logger.ts"),F=250,P=2,O=.1,b=.05,A=function(){function D(w,x,u,a){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=w,this.media=x,this.fragmentTracker=u,this.hls=a}var L=D.prototype;return L.destroy=function(){this.hls=this.fragmentTracker=this.media=null},L.poll=function(x){var u=this.config,a=this.media,l=this.stalled,h=a.currentTime,C=a.seeking,g=this.seeking&&!C,m=!this.seeking&&C;if(this.seeking=C,h!==x){if(this.moved=!0,l!==null){if(this.stallReported){var k=self.performance.now()-l;H.logger.warn("playback not stuck anymore @"+h+", after "+Math.round(k)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((m||g)&&(this.stalled=null),a.paused||a.ended||a.playbackRate===0||!V.BufferHelper.getBuffered(a).length)return;var v=V.BufferHelper.bufferInfo(a,h,0),f=v.len>0,p=v.nextStart||0;if(!f&&!p)return;if(C){var d=v.len>P,o=!p||p-h>P&&!this.fragmentTracker.getPartialFragment(h);if(d||o)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var S,y=Math.max(p,v.start||0)-h,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,I=T==null||((S=T.details)===null||S===void 0)?void 0:S.live,G=I?T.details.targetduration*2:P;if(y>0&&y<=G){this._trySkipBufferHole(null);return}}var X=self.performance.now();if(l===null){this.stalled=X;return}var Q=X-l;!C&&Q>=F&&this._reportStall(v.len);var z=V.BufferHelper.bufferInfo(a,h,u.maxBufferHole);this._tryFixBufferStall(z,Q)},L._tryFixBufferStall=function(x,u){var a=this.config,l=this.fragmentTracker,h=this.media,C=h.currentTime,g=l.getPartialFragment(C);if(g){var m=this._trySkipBufferHole(g);if(m)return}x.len>a.maxBufferHole&&u>a.highBufferWatchdogPeriod*1e3&&(H.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},L._reportStall=function(x){var u=this.hls,a=this.media,l=this.stallReported;l||(this.stallReported=!0,H.logger.warn("Playback stalling at @"+a.currentTime+" due to low buffer (buffer="+x+")"),u.trigger(M.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:x}))},L._trySkipBufferHole=function(x){for(var u=this.config,a=this.hls,l=this.media,h=l.currentTime,C=0,g=V.BufferHelper.getBuffered(l),m=0;m<g.length;m++){var k=g.start(m);if(h+u.maxBufferHole>=C&&h<k){var v=Math.max(k+b,l.currentTime+O);return H.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+v),this.moved=!0,this.stalled=null,l.currentTime=v,x&&a.trigger(M.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+v,frag:x}),v}C=g.end(m)}return 0},L._tryNudgeBuffer=function(){var x=this.config,u=this.hls,a=this.media,l=a.currentTime,h=(this.nudgeRetry||0)+1;if(this.nudgeRetry=h,h<x.nudgeMaxRetry){var C=l+h*x.nudgeOffset;H.logger.warn("Nudging 'currentTime' from "+l+" to "+C),a.currentTime=C,u.trigger(M.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else H.logger.error("Playhead still not moving while enough data buffered @"+l+" after "+x.nudgeMaxRetry+" nudges"),u.trigger(M.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},D}()},"./src/controller/id3-track-controller.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/events.ts"),N=_("./src/utils/texttrack-utils.ts"),M=_("./src/demux/id3.ts"),H=.25,F=function(){function P(b){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=b,this._registerListeners()}var O=P.prototype;return O.destroy=function(){this._unregisterListeners()},O._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.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),A.on(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},O._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.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),A.off(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},O.onMediaAttached=function(A,D){this.media=D.media},O.onMediaDetaching=function(){if(!this.id3Track)return;Object(N.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},O.getID3Track=function(A){if(!this.media)return;for(var D=0;D<A.length;D++){var L=A[D];if(L.kind==="metadata"&&L.label==="id3")return Object(N.sendAddTrackEvent)(L,this.media),L}return this.media.addTextTrack("metadata","id3")},O.onFragParsingMetadata=function(A,D){if(!this.media)return;var L=D.frag,w=D.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var x=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,u=0;u<w.length;u++){var a=M.getID3Frames(w[u].data);if(a){var l=w[u].pts,h=u<w.length-1?w[u+1].pts:L.end,C=h-l;C<=0&&(h=l+H);for(var g=0;g<a.length;g++){var m=a[g];if(!M.isTimeStampFrame(m)){var k=new x(l,h,"");k.value=m,this.id3Track.addCue(k)}}}}},O.onBufferFlushing=function(A,D){var L=D.startOffset,w=D.endOffset,x=D.type;if(!x||x==="audio"){var u=this.id3Track;u&&Object(N.removeCuesInRange)(u,L,w)}},P}();$.default=F},"./src/controller/latency-controller.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return P});var V=_("./src/errors.ts"),N=_("./src/events.ts"),M=_("./src/utils/logger.ts");function H(O,b){for(var A=0;A<b.length;A++){var D=b[A];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(O,D.key,D)}}function F(O,b,A){return b&&H(O.prototype,b),A&&H(O,A),O}var P=function(){function O(A){var D=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 D.timeupdate()},this.hls=A,this.config=A.config,this.registerListeners()}var b=O.prototype;return b.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},b.registerListeners=function(){this.hls.on(N.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(N.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(N.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){this.hls.off(N.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(N.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(N.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(N.Events.ERROR,this.onError)},b.onMediaAttached=function(D,L){this.media=L.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},b.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},b.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},b.onLevelUpdated=function(D,L){var w=L.details;this.levelDetails=w,w.advanced&&this.timeupdate(),!w.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},b.onError=function(D,L){if(L.details!==V.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,M.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},b.timeupdate=function(){var D=this.media,L=this.levelDetails;if(!D||!L)return;this.currentTime=D.currentTime;var w=this.computeLatency();if(w===null)return;this._latency=w;var x=this.config,u=x.lowLatencyMode,a=x.maxLiveSyncPlaybackRate;if(!u||a===1)return;var l=this.targetLatency;if(l===null)return;var h=w-l,C=Math.min(this.maxLatency,l+L.targetduration),g=h<C;if(L.live&&g&&h>.05&&this.forwardBufferLength>1){var m=Math.min(2,Math.max(1,a)),k=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;D.playbackRate=Math.min(m,Math.max(1,k))}else D.playbackRate!==1&&D.playbackRate!==0&&(D.playbackRate=1)},b.estimateLiveEdge=function(){var D=this.levelDetails;return D===null?null:D.edge+D.age},b.computeLatency=function(){var D=this.estimateLiveEdge();return D===null?null:D-this.currentTime},F(O,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var D=this.config,L=this.levelDetails;return D.liveMaxLatencyDuration!==void 0?D.liveMaxLatencyDuration:L?D.liveMaxLatencyDurationCount*L.targetduration:0}},{key:"targetLatency",get:function(){var D=this.levelDetails;if(D===null)return null;var L=D.holdBack,w=D.partHoldBack,x=D.targetduration,u=this.config,a=u.liveSyncDuration,l=u.liveSyncDurationCount,h=u.lowLatencyMode,C=this.hls.userConfig,g=h&&w||L;(C.liveSyncDuration||C.liveSyncDurationCount||g===0)&&(g=a!==void 0?a:l*x);var m=x,k=1;return g+Math.min(this.stallCount*k,m)}},{key:"liveSyncPosition",get:function(){var D=this.estimateLiveEdge(),L=this.targetLatency,w=this.levelDetails;if(D===null||L===null||w===null)return null;var x=w.edge,u=D-L-this.edgeStalled,a=x-w.totalduration,l=x-(this.config.lowLatencyMode&&w.partTarget||w.targetduration);return Math.min(Math.max(a,u),l)}},{key:"drift",get:function(){var D=this.levelDetails;return D===null?1:D.drift}},{key:"edgeStalled",get:function(){var D=this.levelDetails;if(D===null)return 0;var L=(this.config.lowLatencyMode&&D.partTarget||D.targetduration)*3;return Math.max(D.age-L,0)}},{key:"forwardBufferLength",get:function(){var D=this.media,L=this.levelDetails;if(!D||!L)return 0;var w=D.buffered.length;return w?D.buffered.end(w-1):L.edge-this.currentTime}}]),O}()},"./src/controller/level-controller.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return u});var V=_("./src/types/level.ts"),N=_("./src/events.ts"),M=_("./src/errors.ts"),H=_("./src/utils/codecs.ts"),F=_("./src/controller/level-helper.ts"),P=_("./src/controller/base-playlist-controller.ts"),O=_("./src/types/loader.ts");function b(){return b=Object.assign||function(a){for(var l=1;l<arguments.length;l++){var h=arguments[l];for(var C in h)Object.prototype.hasOwnProperty.call(h,C)&&(a[C]=h[C])}return a},b.apply(this,arguments)}function A(a,l){for(var h=0;h<l.length;h++){var C=l[h];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(a,C.key,C)}}function D(a,l,h){return l&&A(a.prototype,l),h&&A(a,h),a}function L(a,l){a.prototype=Object.create(l.prototype),a.prototype.constructor=a,w(a,l)}function w(a,l){return w=Object.setPrototypeOf||function(C,g){return C.__proto__=g,C},w(a,l)}var x=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),u=function(a){L(l,a);function l(C){var g;return g=a.call(this,C,"[level-controller]")||this,g._levels=[],g._firstLevel=-1,g._startLevel=void 0,g.currentLevelIndex=-1,g.manualLevelIndex=-1,g.onParsedComplete=void 0,g._registerListeners(),g}var h=l.prototype;return h._registerListeners=function(){var g=this.hls;g.on(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),g.on(N.Events.LEVEL_LOADED,this.onLevelLoaded,this),g.on(N.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),g.on(N.Events.FRAG_LOADED,this.onFragLoaded,this),g.on(N.Events.ERROR,this.onError,this)},h._unregisterListeners=function(){var g=this.hls;g.off(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),g.off(N.Events.LEVEL_LOADED,this.onLevelLoaded,this),g.off(N.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),g.off(N.Events.FRAG_LOADED,this.onFragLoaded,this),g.off(N.Events.ERROR,this.onError,this)},h.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,a.prototype.destroy.call(this)},h.startLoad=function(){var g=this._levels;g.forEach(function(m){m.loadError=0}),a.prototype.startLoad.call(this)},h.onManifestLoaded=function(g,m){var k=[],v=[],f=[],p,d={},o,S=!1,y=!1,T=!1;if(m.levels.forEach(function(Q){var z=Q.attrs;S=S||!!(Q.width&&Q.height),y=y||!!Q.videoCodec,T=T||!!Q.audioCodec,x&&Q.audioCodec&&Q.audioCodec.indexOf("mp4a.40.34")!==-1&&(Q.audioCodec=void 0);var W=Q.bitrate+"-"+Q.attrs.RESOLUTION+"-"+Q.attrs.CODECS;o=d[W],o?o.url.push(Q.url):(o=new V.Level(Q),d[W]=o,k.push(o)),z&&(z.AUDIO&&Object(F.addGroupId)(o,"audio",z.AUDIO),z.SUBTITLES&&Object(F.addGroupId)(o,"text",z.SUBTITLES))}),(S||y)&&T&&(k=k.filter(function(Q){var z=Q.videoCodec,W=Q.width,ee=Q.height;return!!z||!!(W&&ee)})),k=k.filter(function(Q){var z=Q.audioCodec,W=Q.videoCodec;return(!z||Object(H.isCodecSupportedInMp4)(z,"audio"))&&(!W||Object(H.isCodecSupportedInMp4)(W,"video"))}),m.audioTracks&&(v=m.audioTracks.filter(function(Q){return!Q.audioCodec||Object(H.isCodecSupportedInMp4)(Q.audioCodec,"audio")}),Object(F.assignTrackIdsByGroup)(v)),m.subtitles&&(f=m.subtitles,Object(F.assignTrackIdsByGroup)(f)),k.length>0){p=k[0].bitrate,k.sort(function(Q,z){return Q.bitrate-z.bitrate}),this._levels=k;for(var I=0;I<k.length;I++)if(k[I].bitrate===p){this._firstLevel=I,this.log("manifest loaded, "+k.length+" level(s) found, first bitrate: "+p);break}var G=T&&!y,X={levels:k,audioTracks:v,subtitleTracks:f,firstLevel:this._firstLevel,stats:m.stats,audio:T,video:y,altAudio:!G&&v.some(function(Q){return!!Q.url})};this.hls.trigger(N.Events.MANIFEST_PARSED,X),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(N.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:m.url,reason:"no level with compatible codecs found in manifest"})},h.onError=function(g,m){if(a.prototype.onError.call(this,g,m),m.fatal)return;var k=m.context,v=this._levels[this.currentLevelIndex];if(k&&(k.type===O.PlaylistContextType.AUDIO_TRACK&&v.audioGroupIds&&k.groupId===v.audioGroupIds[v.urlId]||k.type===O.PlaylistContextType.SUBTITLE_TRACK&&v.textGroupIds&&k.groupId===v.textGroupIds[v.urlId])){this.redundantFailover(this.currentLevelIndex);return}var f=!1,p=!0,d;switch(m.details){case M.ErrorDetails.FRAG_LOAD_ERROR:case M.ErrorDetails.FRAG_LOAD_TIMEOUT:case M.ErrorDetails.KEY_LOAD_ERROR:case M.ErrorDetails.KEY_LOAD_TIMEOUT:if(m.frag){var o=this._levels[m.frag.level];o?(o.fragmentError++,o.fragmentError>this.hls.config.fragLoadingMaxRetry&&(d=m.frag.level)):d=m.frag.level}break;case M.ErrorDetails.LEVEL_LOAD_ERROR:case M.ErrorDetails.LEVEL_LOAD_TIMEOUT:k&&(k.deliveryDirectives&&(p=!1),d=k.level),f=!0;break;case M.ErrorDetails.REMUX_ALLOC_ERROR:d=m.level,f=!0;break}d!==void 0&&this.recoverLevel(m,d,f,p)},h.recoverLevel=function(g,m,k,v){var f=g.details,p=this._levels[m];if(p.loadError++,k){var d=this.retryLoadingOrFail(g);if(d)g.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(v){var o=p.url.length;if(o>1&&p.loadError<o)g.levelRetry=!0,this.redundantFailover(m);else if(this.manualLevelIndex===-1){var S=m===0?this._levels.length-1:m-1;this.currentLevelIndex!==S&&this._levels[S].loadError===0&&(this.warn(f+": switch to "+S),g.levelRetry=!0,this.hls.nextAutoLevel=S)}}},h.redundantFailover=function(g){var m=this._levels[g],k=m.url.length;if(k>1){var v=(m.urlId+1)%k;this.warn("Switching to redundant URL-id "+v),this._levels.forEach(function(f){f.urlId=v}),this.level=g}},h.onFragLoaded=function(g,m){var k=m.frag;if(k!==void 0&&k.type===O.PlaylistLevelType.MAIN){var v=this._levels[k.level];v!==void 0&&(v.fragmentError=0,v.loadError=0)}},h.onLevelLoaded=function(g,m){var k,v=m.level,f=m.details,p=this._levels[v];if(!p){var d;this.warn("Invalid level index "+v),(d=m.deliveryDirectives)!==null&&d!==void 0&&d.skip&&(f.deltaUpdateFailed=!0);return}v===this.currentLevelIndex?(p.fragmentError===0&&(p.loadError=0,this.retryCount=0),this.playlistLoaded(v,m,p.details)):(k=m.deliveryDirectives)!==null&&k!==void 0&&k.skip&&(f.deltaUpdateFailed=!0)},h.onAudioTrackSwitched=function(g,m){var k=this.hls.levels[this.currentLevelIndex];if(!k)return;if(k.audioGroupIds){for(var v=-1,f=this.hls.audioTracks[m.id].groupId,p=0;p<k.audioGroupIds.length;p++)if(k.audioGroupIds[p]===f){v=p;break}v!==k.urlId&&(k.urlId=v,this.startLoad())}},h.loadPlaylist=function(g){var m=this.currentLevelIndex,k=this._levels[m];if(this.canLoad&&k&&k.url.length>0){var v=k.urlId,f=k.url[v];if(g)try{f=g.addDirectives(f)}catch(p){this.warn("Could not construct new URL with HLS Delivery Directives: "+p)}this.log("Attempt loading level index "+m+(g?" at sn "+g.msn+" part "+g.part:"")+" with URL-id "+v+" "+f),this.clearTimer(),this.hls.trigger(N.Events.LEVEL_LOADING,{url:f,level:m,id:v,deliveryDirectives:g||null})}},h.removeLevel=function(g,m){var k=function(p,d){return d!==m},v=this._levels.filter(function(f,p){return p!==g?!0:f.url.length>1&&m!==void 0?(f.url=f.url.filter(k),f.audioGroupIds&&(f.audioGroupIds=f.audioGroupIds.filter(k)),f.textGroupIds&&(f.textGroupIds=f.textGroupIds.filter(k)),f.urlId=0,!0):!1}).map(function(f,p){var d=f.details;return d!=null&&d.fragments&&d.fragments.forEach(function(o){o.level=p}),f});this._levels=v,this.hls.trigger(N.Events.LEVELS_UPDATED,{levels:v})},D(l,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(g){var m,k=this._levels;if(k.length===0)return;if(this.currentLevelIndex===g&&(m=k[g])!==null&&m!==void 0&&m.details)return;if(g<0||g>=k.length){var v=g<0;if(this.hls.trigger(N.Events.ERROR,{type:M.ErrorTypes.OTHER_ERROR,details:M.ErrorDetails.LEVEL_SWITCH_ERROR,level:g,fatal:v,reason:"invalid level idx"}),v)return;g=Math.min(g,k.length-1)}this.clearTimer();var f=this.currentLevelIndex,p=k[f],d=k[g];this.log("switching to level "+g+" from "+f),this.currentLevelIndex=g;var o=b({},d,{level:g,maxBitrate:d.maxBitrate,uri:d.uri,urlId:d.urlId});delete o._urlId,this.hls.trigger(N.Events.LEVEL_SWITCHING,o);var S=d.details;if(!S||S.live){var y=this.switchParams(d.uri,p==null?void 0:p.details);this.loadPlaylist(y)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(g){this.manualLevelIndex=g,this._startLevel===void 0&&(this._startLevel=g),g!==-1&&(this.level=g)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(g){this._firstLevel=g}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var g=this.hls.config.startLevel;return g!==void 0?g:this._firstLevel}else return this._startLevel},set:function(g){this._startLevel=g}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(g){this.level=g,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=g)}}]),l}(P.default)},"./src/controller/level-helper.ts":function(ne,$,_){"use strict";_.r($),_.d($,"addGroupId",function(){return M}),_.d($,"assignTrackIdsByGroup",function(){return H}),_.d($,"updatePTS",function(){return F}),_.d($,"updateFragPTSDTS",function(){return O}),_.d($,"mergeDetails",function(){return b}),_.d($,"mapPartIntersection",function(){return A}),_.d($,"mapFragmentIntersection",function(){return D}),_.d($,"adjustSliding",function(){return L}),_.d($,"addSliding",function(){return w}),_.d($,"computeReloadInterval",function(){return x}),_.d($,"getFragmentWithSN",function(){return u}),_.d($,"getPartWith",function(){return a});var V=_("./src/polyfills/number.ts"),N=_("./src/utils/logger.ts");function M(l,h,C){switch(h){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(C);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(C);break}}function H(l){var h={};l.forEach(function(C){var g=C.groupId||"";C.id=h[g]=h[g]||0,h[g]++})}function F(l,h,C){var g=l[h],m=l[C];P(g,m)}function P(l,h){var C=h.startPTS;if(Object(V.isFiniteNumber)(C)){var g=0,m;h.sn>l.sn?(g=C-l.start,m=l):(g=l.start-C,m=h),m.duration!==g&&(m.duration=g)}else if(h.sn>l.sn){var k=l.cc===h.cc;k&&l.minEndPTS?h.start=l.start+(l.minEndPTS-l.start):h.start=l.start+l.duration}else h.start=Math.max(l.start-h.duration,0)}function O(l,h,C,g,m,k){var v=g-C;v<=0&&(N.logger.warn("Fragment should have a positive duration",h),g=C+h.duration,k=m+h.duration);var f=C,p=g,d=h.startPTS,o=h.endPTS;if(Object(V.isFiniteNumber)(d)){var S=Math.abs(d-C);Object(V.isFiniteNumber)(h.deltaPTS)?h.deltaPTS=Math.max(S,h.deltaPTS):h.deltaPTS=S,f=Math.max(C,d),C=Math.min(C,d),m=Math.min(m,h.startDTS),p=Math.min(g,o),g=Math.max(g,o),k=Math.max(k,h.endDTS)}h.duration=g-C;var y=C-h.start;h.appendedPTS=g,h.start=h.startPTS=C,h.maxStartPTS=f,h.startDTS=m,h.endPTS=g,h.minEndPTS=p,h.endDTS=k;var T=h.sn;if(!l||T<l.startSN||T>l.endSN)return 0;var I,G=T-l.startSN,X=l.fragments;for(X[G]=h,I=G;I>0;I--)P(X[I],X[I-1]);for(I=G;I<X.length-1;I++)P(X[I],X[I+1]);return l.fragmentHint&&P(X[X.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,y}function b(l,h){for(var C=null,g=l.fragments,m=g.length-1;m>=0;m--){var k=g[m].initSegment;if(k){C=k;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var v=0,f;if(D(l,h,function(I,G){I.relurl&&(v=I.cc-G.cc),Object(V.isFiniteNumber)(I.startPTS)&&Object(V.isFiniteNumber)(I.endPTS)&&(G.start=G.startPTS=I.startPTS,G.startDTS=I.startDTS,G.appendedPTS=I.appendedPTS,G.maxStartPTS=I.maxStartPTS,G.endPTS=I.endPTS,G.endDTS=I.endDTS,G.minEndPTS=I.minEndPTS,G.duration=I.endPTS-I.startPTS,G.duration&&(f=G),h.PTSKnown=h.alignedSliding=!0),G.elementaryStreams=I.elementaryStreams,G.loader=I.loader,G.stats=I.stats,G.urlId=I.urlId,I.initSegment&&(G.initSegment=I.initSegment,C=I.initSegment)}),C){var p=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments;p.forEach(function(I){var G;(!I.initSegment||I.initSegment.relurl===((G=C)===null||G===void 0?void 0:G.relurl))&&(I.initSegment=C)})}if(h.skippedSegments&&(h.deltaUpdateFailed=h.fragments.some(function(I){return!I}),h.deltaUpdateFailed)){N.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=h.skippedSegments;d--;)h.fragments.shift();h.startSN=h.fragments[0].sn,h.startCC=h.fragments[0].cc}var o=h.fragments;if(v){N.logger.warn("discontinuity sliding from playlist, take drift into account");for(var S=0;S<o.length;S++)o[S].cc+=v}h.skippedSegments&&(h.startCC=h.fragments[0].cc),A(l.partList,h.partList,function(I,G){G.elementaryStreams=I.elementaryStreams,G.stats=I.stats}),f?O(h,f,f.startPTS,f.endPTS,f.startDTS,f.endDTS):L(l,h),o.length&&(h.totalduration=h.edge-o[0].start),h.driftStartTime=l.driftStartTime,h.driftStart=l.driftStart;var y=h.advancedDateTime;if(h.advanced&&y){var T=h.edge;h.driftStart||(h.driftStartTime=y,h.driftStart=T),h.driftEndTime=y,h.driftEnd=T}else h.driftEndTime=l.driftEndTime,h.driftEnd=l.driftEnd,h.advancedDateTime=l.advancedDateTime}function A(l,h,C){if(l&&h)for(var g=0,m=0,k=l.length;m<=k;m++){var v=l[m],f=h[m+g];v&&f&&v.index===f.index&&v.fragment.sn===f.fragment.sn?C(v,f):g--}}function D(l,h,C){for(var g=h.skippedSegments,m=Math.max(l.startSN,h.startSN)-h.startSN,k=(l.fragmentHint?1:0)+(g?h.endSN:Math.min(l.endSN,h.endSN))-h.startSN,v=h.startSN-l.startSN,f=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments,p=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,d=m;d<=k;d++){var o=p[v+d],S=f[d];g&&!S&&d<g&&(S=h.fragments[d]=o),o&&S&&C(o,S)}}function L(l,h){var C=h.startSN+h.skippedSegments-l.startSN,g=l.fragments;if(C<0||C>=g.length)return;w(h,g[C].start)}function w(l,h){if(h){for(var C=l.fragments,g=l.skippedSegments;g<C.length;g++)C[g].start+=h;l.fragmentHint&&(l.fragmentHint.start+=h)}}function x(l,h){var C=1e3*l.levelTargetDuration,g=C/2,m=l.age,k=m>0&&m<C*3,v=h.loading.end-h.loading.start,f,p=l.availabilityDelay;if(l.updated===!1)if(k){var d=333*l.misses;f=Math.max(Math.min(g,v*2),d),l.availabilityDelay=(l.availabilityDelay||0)+f}else f=g;else k?(p=Math.min(p||C/2,m),l.availabilityDelay=p,f=p+C-m):f=C-v;return Math.round(f)}function u(l,h,C){if(!l||!l.details)return null;var g=l.details,m=g.fragments[h-g.startSN];return m||(m=g.fragmentHint,m&&m.sn===h?m:h<g.startSN&&C&&C.sn===h?C:null)}function a(l,h,C){if(!l||!l.details)return null;var g=l.details.partList;if(g)for(var m=g.length;m--;){var k=g[m];if(k.index===C&&k.fragment.sn===h)return k}return null}},"./src/controller/stream-controller.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return g});var V=_("./src/polyfills/number.ts"),N=_("./src/controller/base-stream-controller.ts"),M=_("./src/is-supported.ts"),H=_("./src/events.ts"),F=_("./src/utils/buffer-helper.ts"),P=_("./src/controller/fragment-tracker.ts"),O=_("./src/types/loader.ts"),b=_("./src/loader/fragment.ts"),A=_("./src/demux/transmuxer-interface.ts"),D=_("./src/types/transmuxer.ts"),L=_("./src/controller/gap-controller.ts"),w=_("./src/errors.ts"),x=_("./src/utils/logger.ts");function u(m,k){for(var v=0;v<k.length;v++){var f=k[v];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(m,f.key,f)}}function a(m,k,v){return k&&u(m.prototype,k),v&&u(m,v),m}function l(m,k){m.prototype=Object.create(k.prototype),m.prototype.constructor=m,h(m,k)}function h(m,k){return h=Object.setPrototypeOf||function(f,p){return f.__proto__=p,f},h(m,k)}var C=100,g=function(m){l(k,m);function k(f,p){var d;return d=m.call(this,f,p,"[stream-controller]")||this,d.audioCodecSwap=!1,d.gapController=null,d.level=-1,d._forceStartLoad=!1,d.altAudio=!1,d.audioOnly=!1,d.fragPlaying=null,d.onvplaying=null,d.onvseeked=null,d.fragLastKbps=0,d.stalled=!1,d.couldBacktrack=!1,d.audioCodecSwitch=!1,d.videoBuffer=null,d._registerListeners(),d}var v=k.prototype;return v._registerListeners=function(){var p=this.hls;p.on(H.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.on(H.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.on(H.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.on(H.Events.MANIFEST_PARSED,this.onManifestParsed,this),p.on(H.Events.LEVEL_LOADING,this.onLevelLoading,this),p.on(H.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.on(H.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),p.on(H.Events.ERROR,this.onError,this),p.on(H.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),p.on(H.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),p.on(H.Events.BUFFER_CREATED,this.onBufferCreated,this),p.on(H.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),p.on(H.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),p.on(H.Events.FRAG_BUFFERED,this.onFragBuffered,this)},v._unregisterListeners=function(){var p=this.hls;p.off(H.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.off(H.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.off(H.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.off(H.Events.MANIFEST_PARSED,this.onManifestParsed,this),p.off(H.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.off(H.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),p.off(H.Events.ERROR,this.onError,this),p.off(H.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),p.off(H.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),p.off(H.Events.BUFFER_CREATED,this.onBufferCreated,this),p.off(H.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),p.off(H.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),p.off(H.Events.FRAG_BUFFERED,this.onFragBuffered,this)},v.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},v.startLoad=function(p){if(this.levels){var d=this.lastCurrentTime,o=this.hls;if(this.stopLoad(),this.setInterval(C),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var S=o.startLevel;S===-1&&(o.config.testBandwidth?(S=0,this.bitrateTest=!0):S=o.nextAutoLevel),this.level=o.nextLoadLevel=S,this.loadedmetadata=!1}d>0&&p===-1&&(this.log("Override startPosition with lastCurrentTime @"+d.toFixed(3)),p=d),this.state=N.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=p,this.tick()}else this._forceStartLoad=!0,this.state=N.State.STOPPED},v.stopLoad=function(){this._forceStartLoad=!1,m.prototype.stopLoad.call(this)},v.doTick=function(){switch(this.state){case N.State.IDLE:this.doTickIdle();break;case N.State.WAITING_LEVEL:{var p,d=this.levels,o=this.level,S=d==null||((p=d[o])===null||p===void 0)?void 0:p.details;if(S&&(!S.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(S))break;this.state=N.State.IDLE;break}break}case N.State.FRAG_LOADING_WAITING_RETRY:{var y,T=self.performance.now(),I=this.retryDate;(!I||T>=I||(y=this.media)!==null&&y!==void 0&&y.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=N.State.IDLE)}break;default:break}this.onTickEnd()},v.onTickEnd=function(){m.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},v.doTickIdle=function(){var p,d,o=this.hls,S=this.levelLastLoaded,y=this.levels,T=this.media,I=o.config,G=o.nextLoadLevel;if(S===null||!T&&(this.startFragRequested||!I.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!y||!y[G])return;var X=y[G];this.level=o.nextLoadLevel=G;var Q=X.details;if(!Q||this.state===N.State.WAITING_LEVEL||Q.live&&this.levelLastLoaded!==G){this.state=N.State.WAITING_LEVEL;return}var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:T,O.PlaylistLevelType.MAIN);if(z===null)return;var W=z.len,ee=this.getMaxBufferLength(X.maxBitrate);if(W>=ee)return;if(this._streamEnded(z,Q)){var ae={};this.altAudio&&(ae.type="video"),this.hls.trigger(H.Events.BUFFER_EOS,ae),this.state=N.State.ENDED;return}var pe=z.end,ve=this.getNextFragment(pe,Q);if(this.couldBacktrack&&!this.fragPrevious&&ve&&ve.sn!=="initSegment"){var De=ve.sn-Q.startSN;De>1&&(ve=Q.fragments[De-1],this.fragmentTracker.removeFragment(ve))}if(ve&&this.fragmentTracker.getState(ve)===P.FragmentState.OK&&this.nextLoadPosition>pe){var xe=this.audioOnly&&!this.altAudio?b.ElementaryStreamTypes.AUDIO:b.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(T,xe,O.PlaylistLevelType.MAIN),ve=this.getNextFragment(this.nextLoadPosition,Q)}if(!ve)return;ve.initSegment&&!ve.initSegment.data&&!this.bitrateTest&&(ve=ve.initSegment),((p=ve.decryptdata)===null||p===void 0?void 0:p.keyFormat)==="identity"&&!((d=ve.decryptdata)!==null&&d!==void 0&&d.key)?this.loadKey(ve,Q):this.loadFragment(ve,Q,pe)},v.loadFragment=function(p,d,o){var S,y=this.fragmentTracker.getState(p);if(this.fragCurrent=p,y===P.FragmentState.BACKTRACKED){var T=this.fragmentTracker.getBacktrackData(p);if(T){this._handleFragmentLoadProgress(T),this._handleFragmentLoadComplete(T);return}else y=P.FragmentState.NOT_LOADED}y===P.FragmentState.NOT_LOADED||y===P.FragmentState.PARTIAL?p.sn==="initSegment"?this._loadInitSegment(p):this.bitrateTest?(p.bitrateTest=!0,this.log("Fragment "+p.sn+" of level "+p.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(p)):(this.startFragRequested=!0,m.prototype.loadFragment.call(this,p,d,o)):y===P.FragmentState.APPENDING?this.reduceMaxBufferLength(p.duration)&&this.fragmentTracker.removeFragment(p):((S=this.media)===null||S===void 0?void 0:S.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},v.getAppendedFrag=function(p){var d=this.fragmentTracker.getAppendedFrag(p,O.PlaylistLevelType.MAIN);return d&&"fragment"in d?d.fragment:d},v.getBufferedFrag=function(p){return this.fragmentTracker.getBufferedFrag(p,O.PlaylistLevelType.MAIN)},v.followingBufferedFrag=function(p){return p?this.getBufferedFrag(p.end+.5):null},v.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},v.nextLevelSwitch=function(){var p=this.levels,d=this.media;if(d!=null&&d.readyState){var o,S=this.getAppendedFrag(d.currentTime);if(S&&S.start>1&&this.flushMainBuffer(0,S.start-1),!d.paused&&p){var y=this.hls.nextLoadLevel,T=p[y],I=this.fragLastKbps;I&&this.fragCurrent?o=this.fragCurrent.duration*T.maxBitrate/(1e3*I)+1:o=0}else o=0;var G=this.getBufferedFrag(d.currentTime+o);if(G){var X=this.followingBufferedFrag(G);if(X){this.abortCurrentFrag();var Q=X.maxStartPTS?X.maxStartPTS:X.start,z=X.duration,W=Math.max(G.end,Q+Math.min(Math.max(z-this.config.maxFragLookUpTolerance,z*.5),z*.75));this.flushMainBuffer(W,Number.POSITIVE_INFINITY)}}}},v.abortCurrentFrag=function(){var p=this.fragCurrent;this.fragCurrent=null,p!=null&&p.loader&&p.loader.abort(),this.state===N.State.KEY_LOADING&&(this.state=N.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},v.flushMainBuffer=function(p,d){m.prototype.flushMainBuffer.call(this,p,d,this.altAudio?"video":null)},v.onMediaAttached=function(p,d){m.prototype.onMediaAttached.call(this,p,d);var o=d.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),o.addEventListener("playing",this.onvplaying),o.addEventListener("seeked",this.onvseeked),this.gapController=new L.default(this.config,o,this.fragmentTracker,this.hls)},v.onMediaDetaching=function(){var p=this.media;p&&(p.removeEventListener("playing",this.onvplaying),p.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),m.prototype.onMediaDetaching.call(this)},v.onMediaPlaying=function(){this.tick()},v.onMediaSeeked=function(){var p=this.media,d=p?p.currentTime:null;Object(V.isFiniteNumber)(d)&&this.log("Media seeked to "+d.toFixed(3)),this.tick()},v.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(H.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},v.onManifestParsed=function(p,d){var o=!1,S=!1,y;d.levels.forEach(function(T){y=T.audioCodec,y&&(y.indexOf("mp4a.40.2")!==-1&&(o=!0),y.indexOf("mp4a.40.5")!==-1&&(S=!0))}),this.audioCodecSwitch=o&&S&&!Object(M.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=d.levels,this.startFragRequested=!1},v.onLevelLoading=function(p,d){var o=this.levels;if(!o||this.state!==N.State.IDLE)return;var S=o[d.level];(!S.details||S.details.live&&this.levelLastLoaded!==d.level||this.waitForCdnTuneIn(S.details))&&(this.state=N.State.WAITING_LEVEL)},v.onLevelLoaded=function(p,d){var o,S=this.levels,y=d.level,T=d.details,I=T.totalduration;if(!S){this.warn("Levels were reset while loading level "+y);return}this.log("Level "+y+" loaded ["+T.startSN+","+T.endSN+"], cc ["+T.startCC+", "+T.endCC+"] duration:"+I);var G=this.fragCurrent;G&&(this.state===N.State.FRAG_LOADING||this.state===N.State.FRAG_LOADING_WAITING_RETRY)&&(G.level!==d.level&&G.loader&&(this.state=N.State.IDLE,G.loader.abort()));var X=S[y],Q=0;if(T.live||(o=X.details)!==null&&o!==void 0&&o.live){if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed)return;Q=this.alignPlaylists(T,X.details)}if(X.details=T,this.levelLastLoaded=y,this.hls.trigger(H.Events.LEVEL_UPDATED,{details:T,level:y}),this.state===N.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(T))return;this.state=N.State.IDLE}this.startFragRequested?T.live&&this.synchronizeToLiveEdge(T):this.setStartPosition(T,Q),this.tick()},v._handleFragmentLoadProgress=function(p){var d,o=p.frag,S=p.part,y=p.payload,T=this.levels;if(!T){this.warn("Levels were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered");return}var I=T[o.level],G=I.details;if(!G){this.warn("Dropping fragment "+o.sn+" of level "+o.level+" after level details were reset");return}var X=I.videoCodec,Q=G.PTSKnown||!G.live,z=(d=o.initSegment)===null||d===void 0?void 0:d.data,W=this._getAudioCodec(I),ee=this.transmuxer=this.transmuxer||new A.default(this.hls,O.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),ae=S?S.index:-1,pe=ae!==-1,ve=new D.ChunkMetadata(o.level,o.sn,o.stats.chunkCount,y.byteLength,ae,pe),De=this.initPTS[o.cc];ee.push(y,z,W,X,o,S,G.totalduration,Q,ve,De)},v.onAudioTrackSwitching=function(p,d){var o=this.altAudio,S=!!d.url,y=d.id;if(!S){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var T=this.fragCurrent;T!=null&&T.loader&&(this.log("Switching to main audio track, cancel main fragment load"),T.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var I=this.hls;o&&I.trigger(H.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),I.trigger(H.Events.AUDIO_TRACK_SWITCHED,{id:y})}},v.onAudioTrackSwitched=function(p,d){var o=d.id,S=!!this.hls.audioTracks[o].url;if(S){var y=this.videoBuffer;y&&this.mediaBuffer!==y&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=y)}this.altAudio=S,this.tick()},v.onBufferCreated=function(p,d){var o=d.tracks,S,y,T=!1;for(var I in o){var G=o[I];if(G.id==="main"){if(y=I,S=G,I==="video"){var X=o[I];X&&(this.videoBuffer=X.buffer)}}else T=!0}T&&S?(this.log("Alternate track found, use "+y+".buffered to schedule main fragment loading"),this.mediaBuffer=S.buffer):this.mediaBuffer=this.media},v.onFragBuffered=function(p,d){var o=d.frag,S=d.part;if(o&&o.type!==O.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(o)){this.warn("Fragment "+o.sn+(S?" p: "+S.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state),this.state===N.State.PARSED&&(this.state=N.State.IDLE);return}var y=S?S.stats:o.stats;this.fragLastKbps=Math.round(8*y.total/(y.buffering.end-y.loading.first)),o.sn!=="initSegment"&&(this.fragPrevious=o),this.fragBufferedComplete(o,S)},v.onError=function(p,d){switch(d.details){case w.ErrorDetails.FRAG_LOAD_ERROR:case w.ErrorDetails.FRAG_LOAD_TIMEOUT:case w.ErrorDetails.KEY_LOAD_ERROR:case w.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(O.PlaylistLevelType.MAIN,d);break;case w.ErrorDetails.LEVEL_LOAD_ERROR:case w.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==N.State.ERROR&&(d.fatal?(this.warn(""+d.details),this.state=N.State.ERROR):!d.levelRetry&&this.state===N.State.WAITING_LEVEL&&(this.state=N.State.IDLE));break;case w.ErrorDetails.BUFFER_FULL_ERROR:if(d.parent==="main"&&(this.state===N.State.PARSING||this.state===N.State.PARSED)){var o=!0,S=this.getFwdBufferInfo(this.media,O.PlaylistLevelType.MAIN);S&&S.len>.5&&(o=!this.reduceMaxBufferLength(S.len)),o&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},v.checkBuffer=function(){var p=this.media,d=this.gapController;if(!p||!d||!p.readyState)return;var o=F.BufferHelper.getBuffered(p);!this.loadedmetadata&&o.length?(this.loadedmetadata=!0,this.seekToStartPos()):d.poll(this.lastCurrentTime),this.lastCurrentTime=p.currentTime},v.onFragLoadEmergencyAborted=function(){this.state=N.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},v.onBufferFlushed=function(p,d){var o=d.type;if(o!==b.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var S=(o===b.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(S,o,O.PlaylistLevelType.MAIN)}},v.onLevelsUpdated=function(p,d){this.levels=d.levels},v.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},v.seekToStartPos=function(){var p=this.media,d=p.currentTime,o=this.startPosition;if(o>=0&&d<o){if(p.seeking){x.logger.log("could not seek to "+o+", already seeking at "+d);return}var S=F.BufferHelper.getBuffered(p),y=S.length?S.start(0):0,T=y-o;T>0&&(T<this.config.maxBufferHole||T<this.config.maxFragLookUpTolerance)&&(x.logger.log("adjusting start position by "+T+" to match buffer start"),o+=T,this.startPosition=o),this.log("seek to target start position "+o+" from current time "+d),p.currentTime=o}},v._getAudioCodec=function(p){var d=this.config.defaultAudioCodec||p.audioCodec;return this.audioCodecSwap&&d&&(this.log("Swapping audio codec"),d.indexOf("mp4a.40.5")!==-1?d="mp4a.40.2":d="mp4a.40.5"),d},v._loadBitrateTestFrag=function(p){var d=this;this._doFragLoad(p).then(function(o){var S=d.hls;if(!o||S.nextLoadLevel||d.fragContextChanged(p))return;d.fragLoadError=0,d.state=N.State.IDLE,d.startFragRequested=!1,d.bitrateTest=!1;var y=p.stats;y.parsing.start=y.parsing.end=y.buffering.start=y.buffering.end=self.performance.now(),S.trigger(H.Events.FRAG_LOADED,o)})},v._handleTransmuxComplete=function(p){var d,o="main",S=this.hls,y=p.remuxResult,T=p.chunkMeta,I=this.getCurrentContext(T);if(!I){this.warn("The loading context changed while buffering fragment "+T.sn+" of level "+T.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(T.level);return}var G=I.frag,X=I.part,Q=I.level,z=y.video,W=y.text,ee=y.id3,ae=y.initSegment,pe=this.altAudio?void 0:y.audio;if(this.fragContextChanged(G))return;if(this.state=N.State.PARSING,ae){ae.tracks&&(this._bufferInitSegment(Q,ae.tracks,G,T),S.trigger(H.Events.FRAG_PARSING_INIT_SEGMENT,{frag:G,id:o,tracks:ae.tracks}));var ve=ae.initPTS,De=ae.timescale;Object(V.isFiniteNumber)(ve)&&(this.initPTS[G.cc]=ve,S.trigger(H.Events.INIT_PTS_FOUND,{frag:G,id:o,initPTS:ve,timescale:De}))}if(z&&y.independent!==!1){if(Q.details){var xe=z.startPTS,Ce=z.endPTS,Ae=z.startDTS,Se=z.endDTS;if(X)X.elementaryStreams[z.type]={startPTS:xe,endPTS:Ce,startDTS:Ae,endDTS:Se};else if(z.firstKeyFrame&&z.independent&&(this.couldBacktrack=!0),z.dropped&&z.independent){var ge=this.getLoadPosition()+this.config.maxBufferHole;if(ge<xe){this.backtrack(G);return}G.setElementaryStreamInfo(z.type,G.start,Ce,G.start,Se,!0)}G.setElementaryStreamInfo(z.type,xe,Ce,Ae,Se),this.bufferFragmentData(z,G,X,T)}}else if(y.independent===!1){this.backtrack(G);return}if(pe){var oe=pe.startPTS,Re=pe.endPTS,Ze=pe.startDTS,He=pe.endDTS;X&&(X.elementaryStreams[b.ElementaryStreamTypes.AUDIO]={startPTS:oe,endPTS:Re,startDTS:Ze,endDTS:He}),G.setElementaryStreamInfo(b.ElementaryStreamTypes.AUDIO,oe,Re,Ze,He),this.bufferFragmentData(pe,G,X,T)}if(ee!=null&&(d=ee.samples)!==null&&d!==void 0&&d.length){var Ge={frag:G,id:o,samples:ee.samples};S.trigger(H.Events.FRAG_PARSING_METADATA,Ge)}if(W){var $e={frag:G,id:o,samples:W.samples};S.trigger(H.Events.FRAG_PARSING_USERDATA,$e)}},v._bufferInitSegment=function(p,d,o,S){var y=this;if(this.state!==N.State.PARSING)return;this.audioOnly=!!d.audio&&!d.video,this.altAudio&&!this.audioOnly&&delete d.audio;var T=d.audio,I=d.video,G=d.audiovideo;if(T){var X=p.audioCodec,Q=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(X&&(X.indexOf("mp4a.40.5")!==-1?X="mp4a.40.2":X="mp4a.40.5"),T.metadata.channelCount!==1&&Q.indexOf("firefox")===-1&&(X="mp4a.40.5")),Q.indexOf("android")!==-1&&T.container!=="audio/mpeg"&&(X="mp4a.40.2",this.log("Android: force audio codec to "+X)),p.audioCodec&&p.audioCodec!==X&&this.log('Swapping manifest audio codec "'+p.audioCodec+'" for "'+X+'"'),T.levelCodec=X,T.id="main",this.log("Init audio buffer, container:"+T.container+", codecs[selected/level/parsed]=["+(X||"")+"/"+(p.audioCodec||"")+"/"+T.codec+"]")}I&&(I.levelCodec=p.videoCodec,I.id="main",this.log("Init video buffer, container:"+I.container+", codecs[level/parsed]=["+(p.videoCodec||"")+"/"+I.codec+"]")),G&&this.log("Init audiovideo buffer, container:"+G.container+", codecs[level/parsed]=["+(p.attrs.CODECS||"")+"/"+G.codec+"]"),this.hls.trigger(H.Events.BUFFER_CODECS,d),Object.keys(d).forEach(function(z){var W=d[z],ee=W.initSegment;ee!=null&&ee.byteLength&&y.hls.trigger(H.Events.BUFFER_APPENDING,{type:z,data:ee,frag:o,part:null,chunkMeta:S,parent:o.type})}),this.tick()},v.backtrack=function(p){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(p);var d=this.fragmentTracker.backtrack(p);this.fragPrevious=null,this.nextLoadPosition=p.start,d?this.resetFragmentLoading(p):this.state=N.State.BACKTRACKING},v.checkFragmentChanged=function(){var p=this.media,d=null;if(p&&p.readyState>1&&p.seeking===!1){var o=p.currentTime;if(F.BufferHelper.isBuffered(p,o)?d=this.getAppendedFrag(o):F.BufferHelper.isBuffered(p,o+.1)&&(d=this.getAppendedFrag(o+.1)),d){var S=this.fragPlaying,y=d.level;(!S||d.sn!==S.sn||S.level!==y||d.urlId!==S.urlId)&&(this.hls.trigger(H.Events.FRAG_CHANGED,{frag:d}),(!S||S.level!==y)&&this.hls.trigger(H.Events.LEVEL_SWITCHED,{level:y}),this.fragPlaying=d)}}},a(k,[{key:"nextLevel",get:function(){var p=this.nextBufferedFrag;return p?p.level:-1}},{key:"currentLevel",get:function(){var p=this.media;if(p){var d=this.getAppendedFrag(p.currentTime);if(d)return d.level}return-1}},{key:"nextBufferedFrag",get:function(){var p=this.media;if(p){var d=this.getAppendedFrag(p.currentTime);return this.followingBufferedFrag(d)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),k}(N.default)},"./src/controller/subtitle-stream-controller.ts":function(ne,$,_){"use strict";_.r($),_.d($,"SubtitleStreamController",function(){return l});var V=_("./src/events.ts"),N=_("./src/utils/logger.ts"),M=_("./src/utils/buffer-helper.ts"),H=_("./src/controller/fragment-finders.ts"),F=_("./src/utils/discontinuities.ts"),P=_("./src/controller/level-helper.ts"),O=_("./src/controller/fragment-tracker.ts"),b=_("./src/controller/base-stream-controller.ts"),A=_("./src/types/loader.ts"),D=_("./src/types/level.ts");function L(h,C){for(var g=0;g<C.length;g++){var m=C[g];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(h,m.key,m)}}function w(h,C,g){return C&&L(h.prototype,C),g&&L(h,g),h}function x(h,C){h.prototype=Object.create(C.prototype),h.prototype.constructor=h,u(h,C)}function u(h,C){return u=Object.setPrototypeOf||function(m,k){return m.__proto__=k,m},u(h,C)}var a=500,l=function(h){x(C,h);function C(m,k){var v;return v=h.call(this,m,k,"[subtitle-stream-controller]")||this,v.levels=[],v.currentTrackId=-1,v.tracksBuffered=[],v.mainDetails=null,v._registerListeners(),v}var g=C.prototype;return g.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},g._registerListeners=function(){var k=this.hls;k.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),k.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),k.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),k.on(V.Events.LEVEL_LOADED,this.onLevelLoaded,this),k.on(V.Events.ERROR,this.onError,this),k.on(V.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),k.on(V.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),k.on(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),k.on(V.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),k.on(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},g._unregisterListeners=function(){var k=this.hls;k.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),k.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),k.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),k.off(V.Events.LEVEL_LOADED,this.onLevelLoaded,this),k.off(V.Events.ERROR,this.onError,this),k.off(V.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),k.off(V.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),k.off(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),k.off(V.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),k.off(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},g.startLoad=function(){this.stopLoad(),this.state=b.State.IDLE,this.setInterval(a),this.tick()},g.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},g.onLevelLoaded=function(k,v){this.mainDetails=v.details},g.onSubtitleFragProcessed=function(k,v){var f=v.frag,p=v.success;if(this.fragPrevious=f,this.state=b.State.IDLE,!p)return;var d=this.tracksBuffered[this.currentTrackId];if(!d)return;for(var o,S=f.start,y=0;y<d.length;y++)if(S>=d[y].start&&S<=d[y].end){o=d[y];break}var T=f.start+f.duration;o?o.end=T:(o={start:S,end:T},d.push(o)),this.fragmentTracker.fragBuffered(f)},g.onBufferFlushing=function(k,v){var f=v.startOffset,p=v.endOffset;if(f===0&&p!==Number.POSITIVE_INFINITY){var d=this.currentTrackId,o=this.levels;if(!o.length||!o[d]||!o[d].details)return;var S=o[d].details,y=S.targetduration,T=p-y;if(T<=0)return;v.endOffsetSubtitles=Math.max(0,T),this.tracksBuffered.forEach(function(I){for(var G=0;G<I.length;){if(I[G].end<=T){I.shift();continue}else if(I[G].start<T)I[G].start=T;else break;G++}}),this.fragmentTracker.removeFragmentsInRange(f,T,A.PlaylistLevelType.SUBTITLE)}},g.onError=function(k,v){var f,p=v.frag;if(!p||p.type!==A.PlaylistLevelType.SUBTITLE)return;(f=this.fragCurrent)!==null&&f!==void 0&&f.loader&&this.fragCurrent.loader.abort(),this.state=b.State.IDLE},g.onSubtitleTracksUpdated=function(k,v){var f=this,p=v.subtitleTracks;this.tracksBuffered=[],this.levels=p.map(function(d){return new D.Level(d)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(d){f.tracksBuffered[d.id]=[]}),this.mediaBuffer=null},g.onSubtitleTrackSwitch=function(k,v){if(this.currentTrackId=v.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var f=this.levels[this.currentTrackId];f!=null&&f.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,f&&this.setInterval(a)},g.onSubtitleTrackLoaded=function(k,v){var f,p=v.details,d=v.id,o=this.currentTrackId,S=this.levels;if(!S.length)return;var y=S[o];if(d>=S.length||d!==o||!y)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,p.live||(f=y.details)!==null&&f!==void 0&&f.live){var T=this.mainDetails;if(p.deltaUpdateFailed||!T)return;var I=T.fragments[0];if(!y.details)p.hasProgramDateTime&&T.hasProgramDateTime?Object(F.alignMediaPlaylistByPDT)(p,T):I&&Object(P.addSliding)(p,I.start);else{var G=this.alignPlaylists(p,y.details);G===0&&I&&Object(P.addSliding)(p,I.start)}}if(y.details=p,this.levelLastLoaded=d,this.tick(),p.live&&!this.fragCurrent&&this.media&&this.state===b.State.IDLE){var X=Object(H.findFragmentByPTS)(null,p.fragments,this.media.currentTime,0);X||(this.warn("Subtitle playlist not aligned with playback"),y.details=void 0)}},g._handleFragmentLoadComplete=function(k){var v=k.frag,f=k.payload,p=v.decryptdata,d=this.hls;if(this.fragContextChanged(v))return;if(f&&f.byteLength>0&&p&&p.key&&p.iv&&p.method==="AES-128"){var o=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(f),p.key.buffer,p.iv.buffer).then(function(S){var y=performance.now();d.trigger(V.Events.FRAG_DECRYPTED,{frag:v,payload:S,stats:{tstart:o,tdecrypt:y}})})}},g.doTick=function(){if(!this.media){this.state=b.State.IDLE;return}if(this.state===b.State.IDLE){var k,v=this.currentTrackId,f=this.levels;if(!f.length||!f[v]||!f[v].details)return;var p=f[v].details,d=p.targetduration,o=this.config,S=this.media,y=M.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,S.currentTime-d,o.maxBufferHole),T=y.end,I=y.len,G=this.getMaxBufferLength()+d;if(I>G)return;console.assert(p,"Subtitle track details are defined on idle subtitle stream controller tick");var X=p.fragments,Q=X.length,z=p.edge,W,ee=this.fragPrevious;if(T<z){var ae=o.maxFragLookUpTolerance;ee&&p.hasProgramDateTime&&(W=Object(H.findFragmentByPDT)(X,ee.endProgramDateTime,ae)),W||(W=Object(H.findFragmentByPTS)(ee,X,T,ae),!W&&ee&&ee.start<X[0].start&&(W=X[0]))}else W=X[Q-1];(k=W)!==null&&k!==void 0&&k.encrypted?(N.logger.log("Loading key for "+W.sn),this.state=b.State.KEY_LOADING,this.hls.trigger(V.Events.KEY_LOADING,{frag:W})):W&&this.fragmentTracker.getState(W)===O.FragmentState.NOT_LOADED&&this.loadFragment(W,p,T)}},g.loadFragment=function(k,v,f){this.fragCurrent=k,h.prototype.loadFragment.call(this,k,v,f)},w(C,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),C}(b.default)},"./src/controller/subtitle-track-controller.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/events.ts"),N=_("./src/utils/texttrack-utils.ts"),M=_("./src/controller/base-playlist-controller.ts"),H=_("./src/types/loader.ts");function F(L,w){for(var x=0;x<w.length;x++){var u=w[x];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(L,u.key,u)}}function P(L,w,x){return w&&F(L.prototype,w),x&&F(L,x),L}function O(L,w){L.prototype=Object.create(w.prototype),L.prototype.constructor=L,b(L,w)}function b(L,w){return b=Object.setPrototypeOf||function(u,a){return u.__proto__=a,u},b(L,w)}var A=function(L){O(w,L);function w(u){var a;return a=L.call(this,u,"[subtitle-track-controller]")||this,a.media=null,a.tracks=[],a.groupId=null,a.tracksInGroup=[],a.trackId=-1,a.selectDefaultTrack=!0,a.queuedDefaultTrack=-1,a.trackChangeListener=function(){return a.onTextTracksChanged()},a.asyncPollTrackChange=function(){return a.pollTrackChange(0)},a.useTextTrackPolling=!1,a.subtitlePollingInterval=-1,a.subtitleDisplay=!0,a.registerListeners(),a}var x=w.prototype;return x.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,L.prototype.destroy.call(this)},x.registerListeners=function(){var a=this.hls;a.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(V.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.on(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),a.on(V.Events.ERROR,this.onError,this)},x.unregisterListeners=function(){var a=this.hls;a.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(V.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.off(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),a.off(V.Events.ERROR,this.onError,this)},x.onMediaAttached=function(a,l){if(this.media=l.media,!this.media)return;this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)},x.pollTrackChange=function(a){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,a)},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 a=D(this.media.textTracks);a.forEach(function(l){Object(N.clearCurrentCues)(l)}),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(a,l){this.tracks=l.subtitleTracks},x.onSubtitleTrackLoaded=function(a,l){var h=l.id,C=l.details,g=this.trackId,m=this.tracksInGroup[g];if(!m){this.warn("Invalid subtitle track id "+h);return}var k=m.details;m.details=l.details,this.log("subtitle track "+h+" loaded ["+C.startSN+"-"+C.endSN+"]"),h===this.trackId&&(this.retryCount=0,this.playlistLoaded(h,l,k))},x.onLevelLoading=function(a,l){this.switchLevel(l.level)},x.onLevelSwitching=function(a,l){this.switchLevel(l.level)},x.switchLevel=function(a){var l=this.hls.levels[a];if(!(l!=null&&l.textGroupIds))return;var h=l.textGroupIds[l.urlId];if(this.groupId!==h){var C=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,g=this.tracks.filter(function(v){return!h||v.groupId===h});this.tracksInGroup=g;var m=this.findTrackId(C==null?void 0:C.name)||this.findTrackId();this.groupId=h;var k={subtitleTracks:g};this.log("Updating subtitle tracks, "+g.length+' track(s) found in "'+h+'" group-id'),this.hls.trigger(V.Events.SUBTITLE_TRACKS_UPDATED,k),m!==-1&&this.setSubtitleTrack(m,C)}},x.findTrackId=function(a){for(var l=this.tracksInGroup,h=0;h<l.length;h++){var C=l[h];if((!this.selectDefaultTrack||C.default)&&(!a||a===C.name))return C.id}return-1},x.onError=function(a,l){if(L.prototype.onError.call(this,a,l),l.fatal||!l.context)return;l.context.type===H.PlaylistContextType.SUBTITLE_TRACK&&l.context.id===this.trackId&&l.context.groupId===this.groupId&&this.retryLoadingOrFail(l)},x.loadPlaylist=function(a){var l=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(l)){var h=l.id,C=l.groupId,g=l.url;if(a)try{g=a.addDirectives(g)}catch(m){this.warn("Could not construct new URL with HLS Delivery Directives: "+m)}this.log("Loading subtitle playlist for id "+h),this.hls.trigger(V.Events.SUBTITLE_TRACK_LOADING,{url:g,id:h,groupId:C,deliveryDirectives:a||null})}},x.toggleTrackModes=function(a){var l=this,h=this.media,C=this.subtitleDisplay,g=this.trackId;if(!h)return;var m=D(h.textTracks),k=m.filter(function(p){return p.groupId===l.groupId});if(a===-1)[].slice.call(m).forEach(function(p){p.mode="disabled"});else{var v=k[g];v&&(v.mode="disabled")}var f=k[a];f&&(f.mode=C?"showing":"hidden")},x.setSubtitleTrack=function(a,l){var h,C=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=a;return}if(this.trackId!==a&&this.toggleTrackModes(a),this.trackId===a&&(a===-1||(h=C[a])!==null&&h!==void 0&&h.details)||a<-1||a>=C.length)return;this.clearTimer();var g=C[a];if(this.log("Switching to subtitle track "+a),this.trackId=a,g){var m=g.id,k=g.groupId,v=k===void 0?"":k,f=g.name,p=g.type,d=g.url;this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:m,groupId:v,name:f,type:p,url:d});var o=this.switchParams(g.url,l==null?void 0:l.details);this.loadPlaylist(o)}else this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:a})},x.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var a=-1,l=D(this.media.textTracks),h=0;h<l.length;h++)if(l[h].mode==="hidden")a=h;else if(l[h].mode==="showing"){a=h;break}this.subtitleTrack!==a&&(this.subtitleTrack=a)},P(w,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(a){this.selectDefaultTrack=!1;var l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(a,l)}}]),w}(M.default);function D(L){for(var w=[],x=0;x<L.length;x++){var u=L[x];u.kind==="subtitles"&&u.label&&w.push(L[x])}return w}$.default=A},"./src/controller/timeline-controller.ts":function(ne,$,_){"use strict";_.r($),_.d($,"TimelineController",function(){return D});var V=_("./src/polyfills/number.ts"),N=_("./src/events.ts"),M=_("./src/utils/cea-608-parser.ts"),H=_("./src/utils/output-filter.ts"),F=_("./src/utils/webvtt-parser.ts"),P=_("./src/utils/texttrack-utils.ts"),O=_("./src/utils/imsc1-ttml-parser.ts"),b=_("./src/types/loader.ts"),A=_("./src/utils/logger.ts"),D=function(){function u(l){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=x(),this.captionsProperties=void 0,this.hls=l,this.config=l.config,this.Cues=l.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var h=new H.default(this,"textTrack1"),C=new H.default(this,"textTrack2"),g=new H.default(this,"textTrack3"),m=new H.default(this,"textTrack4");this.cea608Parser1=new M.default(1,h,C),this.cea608Parser2=new M.default(3,g,m)}l.on(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),l.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(N.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(N.Events.FRAG_LOADING,this.onFragLoading,this),l.on(N.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(N.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),l.on(N.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),l.on(N.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.on(N.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),l.on(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var a=u.prototype;return a.destroy=function(){var h=this.hls;h.off(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),h.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),h.off(N.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.off(N.Events.FRAG_LOADING,this.onFragLoading,this),h.off(N.Events.FRAG_LOADED,this.onFragLoaded,this),h.off(N.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),h.off(N.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),h.off(N.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.off(N.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),h.off(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},a.addCues=function(h,C,g,m,k){for(var v=!1,f=k.length;f--;){var p=k[f],d=w(p[0],p[1],C,g);if(d>=0&&(p[0]=Math.min(p[0],C),p[1]=Math.max(p[1],g),v=!0,d/(g-C)>.5))return}if(v||k.push([C,g]),this.config.renderTextTracksNatively){var o=this.captionsTracks[h];this.Cues.newCue(o,C,g,m)}else{var S=this.Cues.newCue(null,C,g,m);this.hls.trigger(N.Events.CUES_PARSED,{type:"captions",cues:S,track:h})}},a.onInitPtsFound=function(h,C){var g=this,m=C.frag,k=C.id,v=C.initPTS,f=C.timescale,p=this.unparsedVttFrags;k==="main"&&(this.initPTS[m.cc]=v,this.timescale[m.cc]=f),p.length&&(this.unparsedVttFrags=[],p.forEach(function(d){g.onFragLoaded(N.Events.FRAG_LOADED,d)}))},a.getExistingTrack=function(h){var C=this.media;if(C)for(var g=0;g<C.textTracks.length;g++){var m=C.textTracks[g];if(m[h])return m}return null},a.createCaptionsTrack=function(h){this.config.renderTextTracksNatively?this.createNativeTrack(h):this.createNonNativeTrack(h)},a.createNativeTrack=function(h){if(this.captionsTracks[h])return;var C=this.captionsProperties,g=this.captionsTracks,m=this.media,k=C[h],v=k.label,f=k.languageCode,p=this.getExistingTrack(h);if(p)g[h]=p,Object(P.clearCurrentCues)(g[h]),Object(P.sendAddTrackEvent)(g[h],m);else{var d=this.createTextTrack("captions",v,f);d&&(d[h]=!0,g[h]=d)}},a.createNonNativeTrack=function(h){if(this.nonNativeCaptionsTracks[h])return;var C=this.captionsProperties[h];if(!C)return;var g=C.label,m={_id:h,label:g,kind:"captions",default:C.media?!!C.media.default:!1,closedCaptions:C.media};this.nonNativeCaptionsTracks[h]=m,this.hls.trigger(N.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[m]})},a.createTextTrack=function(h,C,g){var m=this.media;return m?m.addTextTrack(h,C,g):void 0},a.onMediaAttaching=function(h,C){this.media=C.media,this._cleanTracks()},a.onMediaDetaching=function(){var h=this.captionsTracks;Object.keys(h).forEach(function(C){Object(P.clearCurrentCues)(h[C]),delete h[C]}),this.nonNativeCaptionsTracks={}},a.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())},a._cleanTracks=function(){var h=this.media;if(!h)return;var C=h.textTracks;if(C)for(var g=0;g<C.length;g++)Object(P.clearCurrentCues)(C[g])},a.onSubtitleTracksUpdated=function(h,C){var g=this;this.textTracks=[];var m=C.subtitleTracks||[],k=m.some(function(d){return d.textCodec===O.IMSC1_CODEC});if(this.config.enableWebVTT||k&&this.config.enableIMSC1){var v=this.tracks&&m&&this.tracks.length===m.length;if(this.tracks=m||[],this.config.renderTextTracksNatively){var f=this.media?this.media.textTracks:[];this.tracks.forEach(function(d,o){var S;if(o<f.length){for(var y=null,T=0;T<f.length;T++)if(L(f[T],d)){y=f[T];break}y&&(S=y)}S?Object(P.clearCurrentCues)(S):(S=g.createTextTrack("subtitles",d.name,d.lang),S&&(S.mode="disabled")),S&&(S.groupId=d.groupId,g.textTracks.push(S))})}else if(!v&&this.tracks&&this.tracks.length){var p=this.tracks.map(function(d){return{label:d.name,kind:d.type.toLowerCase(),default:d.default,subtitleTrack:d}});this.hls.trigger(N.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:p})}}},a.onManifestLoaded=function(h,C){var g=this;this.config.enableCEA708Captions&&C.captions&&C.captions.forEach(function(m){var k=/(?:CC|SERVICE)([1-4])/.exec(m.instreamId);if(!k)return;var v="textTrack"+k[1],f=g.captionsProperties[v];if(!f)return;f.label=m.name,m.lang&&(f.languageCode=m.lang),f.media=m})},a.onFragLoading=function(h,C){var g=this.cea608Parser1,m=this.cea608Parser2,k=this.lastSn,v=this.lastPartIndex;if(!this.enabled||!(g&&m))return;if(C.frag.type===b.PlaylistLevelType.MAIN){var f,p,d=C.frag.sn,o=(f=C==null||((p=C.part)===null||p===void 0)?void 0:p.index)!=null?f:-1;d===k+1||d===k&&o===v+1||(g.reset(),m.reset()),this.lastSn=d,this.lastPartIndex=o}},a.onFragLoaded=function(h,C){var g=C.frag,m=C.payload,k=this.initPTS,v=this.unparsedVttFrags;if(g.type===b.PlaylistLevelType.SUBTITLE)if(m.byteLength){if(!Object(V.isFiniteNumber)(k[g.cc])){v.push(C),k.length&&this.hls.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:new Error("Missing initial subtitle PTS")});return}var f=g.decryptdata;if(f==null||f.key==null||f.method!=="AES-128"){var p=this.tracks[g.level],d=this.vttCCs;d[g.cc]||(d[g.cc]={start:g.start,prevCC:this.prevCC,new:!0},this.prevCC=g.cc),p&&p.textCodec===O.IMSC1_CODEC?this._parseIMSC1(g,m):this._parseVTTs(g,m,d)}}else this.hls.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:new Error("Empty subtitle payload")})},a._parseIMSC1=function(h,C){var g=this,m=this.hls;Object(O.parseIMSC1)(C,this.initPTS[h.cc],this.timescale[h.cc],function(k){g._appendCues(k,h.level),m.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(k){A.logger.log("Failed to parse IMSC1: "+k),m.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:k})})},a._parseVTTs=function(h,C,g){var m=this,k=this.hls;Object(F.parseWebVTT)(C,this.initPTS[h.cc],this.timescale[h.cc],g,h.cc,h.start,function(v){m._appendCues(v,h.level),k.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(v){m._fallbackToIMSC1(h,C),A.logger.log("Failed to parse VTT cue: "+v),k.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:v})})},a._fallbackToIMSC1=function(h,C){var g=this,m=this.tracks[h.level];m.textCodec||Object(O.parseIMSC1)(C,this.initPTS[h.cc],this.timescale[h.cc],function(){m.textCodec=O.IMSC1_CODEC,g._parseIMSC1(h,C)},function(){m.textCodec="wvtt"})},a._appendCues=function(h,C){var g=this.hls;if(this.config.renderTextTracksNatively){var m=this.textTracks[C];if(m.mode==="disabled")return;h.forEach(function(f){return Object(P.addCueToTrack)(m,f)})}else{var k=this.tracks[C],v=k.default?"default":"subtitles"+C;g.trigger(N.Events.CUES_PARSED,{type:"subtitles",cues:h,track:v})}},a.onFragDecrypted=function(h,C){var g=C.frag;if(g.type===b.PlaylistLevelType.SUBTITLE){if(!Object(V.isFiniteNumber)(this.initPTS[g.cc])){this.unparsedVttFrags.push(C);return}this.onFragLoaded(N.Events.FRAG_LOADED,C)}},a.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},a.onFragParsingUserdata=function(h,C){var g=this.cea608Parser1,m=this.cea608Parser2;if(!this.enabled||!(g&&m))return;for(var k=0;k<C.samples.length;k++){var v=C.samples[k].bytes;if(v){var f=this.extractCea608Data(v);g.addData(C.samples[k].pts,f[0]),m.addData(C.samples[k].pts,f[1])}}},a.onBufferFlushing=function(h,C){var g=C.startOffset,m=C.endOffset,k=C.endOffsetSubtitles,v=C.type,f=this.media;if(!f||f.currentTime<m)return;if(!v||v==="video"){var p=this.captionsTracks;Object.keys(p).forEach(function(o){return Object(P.removeCuesInRange)(p[o],g,m)})}if(this.config.renderTextTracksNatively&&(g===0&&k!==void 0)){var d=this.textTracks;Object.keys(d).forEach(function(o){return Object(P.removeCuesInRange)(d[o],g,k)})}},a.extractCea608Data=function(h){for(var C=h[0]&31,g=2,m=[[],[]],k=0;k<C;k++){var v=h[g++],f=127&h[g++],p=127&h[g++],d=(4&v)!==0,o=3&v;if(f===0&&p===0)continue;d&&((o===0||o===1)&&(m[o].push(f),m[o].push(p)))}return m},u}();function L(u,a){return u&&u.label===a.name&&!(u.textTrack1||u.textTrack2)}function w(u,a,l,h){return Math.min(a,h)-Math.max(u,l)}function x(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return V});var V=function(){function N(H,F){this.subtle=void 0,this.aesIV=void 0,this.subtle=H,this.aesIV=F}var M=N.prototype;return M.decrypt=function(F,P){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},P,F)},N}()},"./src/crypt/aes-decryptor.ts":function(ne,$,_){"use strict";_.r($),_.d($,"removePadding",function(){return N}),_.d($,"default",function(){return M});var V=_("./src/utils/typed-array.ts");function N(H){var F=H.byteLength,P=F&&new DataView(H.buffer).getUint8(F-1);return P?Object(V.sliceUint8)(H,0,F-P):H}var M=function(){function H(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var F=H.prototype;return F.uint8ArrayToUint32Array_=function(O){for(var b=new DataView(O),A=new Uint32Array(4),D=0;D<4;D++)A[D]=b.getUint32(D*4);return A},F.initTable=function(){var O=this.sBox,b=this.invSBox,A=this.subMix,D=A[0],L=A[1],w=A[2],x=A[3],u=this.invSubMix,a=u[0],l=u[1],h=u[2],C=u[3],g=new Uint32Array(256),m=0,k=0,v=0;for(v=0;v<256;v++)v<128?g[v]=v<<1:g[v]=v<<1^283;for(v=0;v<256;v++){var f=k^k<<1^k<<2^k<<3^k<<4;f=f>>>8^f&255^99,O[m]=f,b[f]=m;var p=g[m],d=g[p],o=g[d],S=g[f]*257^f*16843008;D[m]=S<<24|S>>>8,L[m]=S<<16|S>>>16,w[m]=S<<8|S>>>24,x[m]=S,S=o*16843009^d*65537^p*257^m*16843008,a[f]=S<<24|S>>>8,l[f]=S<<16|S>>>16,h[f]=S<<8|S>>>24,C[f]=S,m?(m=p^g[g[g[o^p]]],k^=g[g[k]]):m=k=1}},F.expandKey=function(O){for(var b=this.uint8ArrayToUint32Array_(O),A=!0,D=0;D<b.length&&A;)A=b[D]===this.key[D],D++;if(A)return;this.key=b;var L=this.keySize=b.length;if(L!==4&&L!==6&&L!==8)throw new Error("Invalid aes key size="+L);var w=this.ksRows=(L+6+1)*4,x,u,a=this.keySchedule=new Uint32Array(w),l=this.invKeySchedule=new Uint32Array(w),h=this.sBox,C=this.rcon,g=this.invSubMix,m=g[0],k=g[1],v=g[2],f=g[3],p,d;for(x=0;x<w;x++){if(x<L){p=a[x]=b[x];continue}d=p,x%L===0?(d=d<<8|d>>>24,d=h[d>>>24]<<24|h[d>>>16&255]<<16|h[d>>>8&255]<<8|h[d&255],d^=C[x/L|0]<<24):L>6&&x%L===4&&(d=h[d>>>24]<<24|h[d>>>16&255]<<16|h[d>>>8&255]<<8|h[d&255]),a[x]=p=(a[x-L]^d)>>>0}for(u=0;u<w;u++)x=w-u,u&3?d=a[x]:d=a[x-4],u<4||x<=4?l[u]=d:l[u]=m[h[d>>>24]]^k[h[d>>>16&255]]^v[h[d>>>8&255]]^f[h[d&255]],l[u]=l[u]>>>0},F.networkToHostOrderSwap=function(O){return O<<24|(O&65280)<<8|(O&16711680)>>8|O>>>24},F.decrypt=function(O,b,A){for(var D=this.keySize+6,L=this.invKeySchedule,w=this.invSBox,x=this.invSubMix,u=x[0],a=x[1],l=x[2],h=x[3],C=this.uint8ArrayToUint32Array_(A),g=C[0],m=C[1],k=C[2],v=C[3],f=new Int32Array(O),p=new Int32Array(f.length),d,o,S,y,T,I,G,X,Q,z,W,ee,ae,pe,ve=this.networkToHostOrderSwap;b<f.length;){for(Q=ve(f[b]),z=ve(f[b+1]),W=ve(f[b+2]),ee=ve(f[b+3]),T=Q^L[0],I=ee^L[1],G=W^L[2],X=z^L[3],ae=4,pe=1;pe<D;pe++)d=u[T>>>24]^a[I>>16&255]^l[G>>8&255]^h[X&255]^L[ae],o=u[I>>>24]^a[G>>16&255]^l[X>>8&255]^h[T&255]^L[ae+1],S=u[G>>>24]^a[X>>16&255]^l[T>>8&255]^h[I&255]^L[ae+2],y=u[X>>>24]^a[T>>16&255]^l[I>>8&255]^h[G&255]^L[ae+3],T=d,I=o,G=S,X=y,ae=ae+4;d=w[T>>>24]<<24^w[I>>16&255]<<16^w[G>>8&255]<<8^w[X&255]^L[ae],o=w[I>>>24]<<24^w[G>>16&255]<<16^w[X>>8&255]<<8^w[T&255]^L[ae+1],S=w[G>>>24]<<24^w[X>>16&255]<<16^w[T>>8&255]<<8^w[I&255]^L[ae+2],y=w[X>>>24]<<24^w[T>>16&255]<<16^w[I>>8&255]<<8^w[G&255]^L[ae+3],p[b]=ve(d^g),p[b+1]=ve(y^m),p[b+2]=ve(S^k),p[b+3]=ve(o^v),g=Q,m=z,k=W,v=ee,b=b+4}return p.buffer},H}()},"./src/crypt/decrypter.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return b});var V=_("./src/crypt/aes-crypto.ts"),N=_("./src/crypt/fast-aes-key.ts"),M=_("./src/crypt/aes-decryptor.ts"),H=_("./src/utils/logger.ts"),F=_("./src/utils/mp4-tools.ts"),P=_("./src/utils/typed-array.ts"),O=16,b=function(){function A(L,w,x){var u=x===void 0?{}:x,a=u.removePKCS7Padding,l=a===void 0?!0:a;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=L,this.config=w,this.removePKCS7Padding=l,l)try{var h=self.crypto;h&&(this.subtle=h.subtle||h.webkitSubtle)}catch(C){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var D=A.prototype;return D.destroy=function(){this.observer=null},D.isSync=function(){return this.config.enableSoftwareAES},D.flush=function(){var w=this.currentResult;if(!w){this.reset();return}var x=new Uint8Array(w);return this.reset(),this.removePKCS7Padding?Object(M.removePadding)(x):x},D.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},D.decrypt=function(w,x,u,a){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(w),x,u);var l=this.flush();l&&a(l.buffer)}else this.webCryptoDecrypt(new Uint8Array(w),x,u).then(a)},D.softwareDecrypt=function(w,x,u){var a=this.currentIV,l=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(w=Object(F.appendUint8Array)(h,w),this.remainderData=null);var C=this.getValidChunk(w);if(!C.length)return null;a&&(u=a);var g=this.softwareDecrypter;g||(g=this.softwareDecrypter=new M.default),g.expandKey(x);var m=l;return this.currentResult=g.decrypt(C.buffer,0,u),this.currentIV=Object(P.sliceUint8)(C,-16).buffer,m||null},D.webCryptoDecrypt=function(w,x,u){var a=this,l=this.subtle;return(this.key!==x||!this.fastAesKey)&&(this.key=x,this.fastAesKey=new N.default(l,x)),this.fastAesKey.expandKey().then(function(h){if(!l)return Promise.reject(new Error("web crypto not initialized"));var C=new V.default(l,u);return C.decrypt(w.buffer,h)}).catch(function(h){return a.onWebCryptoError(h,w,x,u)})},D.onWebCryptoError=function(w,x,u,a){return H.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",w),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(x,u,a)},D.getValidChunk=function(w){var x=w,u=w.length-w.length%O;return u!==w.length&&(x=Object(P.sliceUint8)(w,0,u),this.remainderData=Object(P.sliceUint8)(w,u)),x},D.logOnce=function(w){if(!this.logEnabled)return;H.logger.log("[decrypter.ts]: "+w),this.logEnabled=!1},A}()},"./src/crypt/fast-aes-key.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return V});var V=function(){function N(H,F){this.subtle=void 0,this.key=void 0,this.subtle=H,this.key=F}var M=N.prototype;return M.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},N}()},"./src/demux/aacdemuxer.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/demux/base-audio-demuxer.ts"),N=_("./src/demux/adts.ts"),M=_("./src/utils/logger.ts"),H=_("./src/demux/id3.ts");function F(b,A){b.prototype=Object.create(A.prototype),b.prototype.constructor=b,P(b,A)}function P(b,A){return P=Object.setPrototypeOf||function(L,w){return L.__proto__=w,L},P(b,A)}var O=function(b){F(A,b);function A(L,w){var x;return x=b.call(this)||this,x.observer=void 0,x.config=void 0,x.observer=L,x.config=w,x}var D=A.prototype;return D.resetInitSegment=function(w,x,u){b.prototype.resetInitSegment.call(this,w,x,u),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:w,duration:u,inputTimeScale:9e4,dropped:0}},A.probe=function(w){if(!w)return!1;for(var x=H.getID3Data(w,0)||[],u=x.length,a=w.length;u<a;u++)if(N.probe(w,u))return M.logger.log("ADTS sync word found !"),!0;return!1},D.canParse=function(w,x){return N.canParse(w,x)},D.appendFrame=function(w,x,u){N.initTrackConfig(w,this.observer,x,u,w.manifestCodec);var a=N.appendFrame(w,x,u,this.initPTS,this.frameIndex);if(a&&a.missing===0)return a},A}(V.default);O.minProbeByteLength=9,$.default=O},"./src/demux/adts.ts":function(ne,$,_){"use strict";_.r($),_.d($,"getAudioConfig",function(){return H}),_.d($,"isHeaderPattern",function(){return F}),_.d($,"getHeaderLength",function(){return P}),_.d($,"getFullFrameLength",function(){return O}),_.d($,"canGetFrameLength",function(){return b}),_.d($,"isHeader",function(){return A}),_.d($,"canParse",function(){return D}),_.d($,"probe",function(){return L}),_.d($,"initTrackConfig",function(){return w}),_.d($,"getFrameDuration",function(){return x}),_.d($,"parseFrameHeader",function(){return u}),_.d($,"appendFrame",function(){return a});var V=_("./src/utils/logger.ts"),N=_("./src/errors.ts"),M=_("./src/events.ts");function H(l,h,C,g){var m,k,v,f,p=navigator.userAgent.toLowerCase(),d=g,o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];m=((h[C+2]&192)>>>6)+1;var S=(h[C+2]&60)>>>2;if(S>o.length-1){l.trigger(M.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+S});return}return v=(h[C+2]&1)<<2,v|=(h[C+3]&192)>>>6,V.logger.log("manifest codec:"+g+", ADTS type:"+m+", samplingIndex:"+S),/firefox/i.test(p)?S>=6?(m=5,f=new Array(4),k=S-3):(m=2,f=new Array(2),k=S):p.indexOf("android")!==-1?(m=2,f=new Array(2),k=S):(m=5,f=new Array(4),g&&(g.indexOf("mp4a.40.29")!==-1||g.indexOf("mp4a.40.5")!==-1)||!g&&S>=6?k=S-3:((g&&g.indexOf("mp4a.40.2")!==-1&&(S>=6&&v===1||/vivaldi/i.test(p))||!g&&v===1)&&(m=2,f=new Array(2)),k=S)),f[0]=m<<3,f[0]|=(S&14)>>1,f[1]|=(S&1)<<7,f[1]|=v<<3,m===5&&(f[1]|=(k&14)>>1,f[2]=(k&1)<<7,f[2]|=2<<2,f[3]=0),{config:f,samplerate:o[S],channelCount:v,codec:"mp4a.40."+m,manifestCodec:d}}function F(l,h){return l[h]===255&&(l[h+1]&246)===240}function P(l,h){return l[h+1]&1?7:9}function O(l,h){return(l[h+3]&3)<<11|l[h+4]<<3|(l[h+5]&224)>>>5}function b(l,h){return h+5<l.length}function A(l,h){return h+1<l.length&&F(l,h)}function D(l,h){return b(l,h)&&F(l,h)&&O(l,h)<=l.length-h}function L(l,h){if(A(l,h)){var C=P(l,h);if(h+C>=l.length)return!1;var g=O(l,h);if(g<=C)return!1;var m=h+g;return m===l.length||A(l,m)}return!1}function w(l,h,C,g,m){if(!l.samplerate){var k=H(h,C,g,m);if(!k)return;l.config=k.config,l.samplerate=k.samplerate,l.channelCount=k.channelCount,l.codec=k.codec,l.manifestCodec=k.manifestCodec,V.logger.log("parsed codec:"+l.codec+", rate:"+k.samplerate+", channels:"+k.channelCount)}}function x(l){return 1024*9e4/l}function u(l,h,C,g,m){var k=P(l,h),v=O(l,h);if(v-=k,v>0){var f=C+g*m;return{headerLength:k,frameLength:v,stamp:f}}}function a(l,h,C,g,m){var k=x(l.samplerate),v=u(h,C,g,m,k);if(v){var f=v.frameLength,p=v.headerLength,d=v.stamp,o=p+f,S=Math.max(0,C+o-h.length),y;S?(y=new Uint8Array(o-p),y.set(h.subarray(C+p,h.length),0)):y=h.subarray(C+p,C+o);var T={unit:y,pts:d};return S||l.samples.push(T),{sample:T,length:o,missing:S}}}},"./src/demux/base-audio-demuxer.ts":function(ne,$,_){"use strict";_.r($),_.d($,"initPTSFn",function(){return O});var V=_("./src/polyfills/number.ts"),N=_("./src/demux/id3.ts"),M=_("./src/demux/dummy-demuxed-track.ts"),H=_("./src/utils/mp4-tools.ts"),F=_("./src/utils/typed-array.ts"),P=function(){function b(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var A=b.prototype;return A.resetInitSegment=function(L,w,x){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},A.resetTimeStamp=function(){},A.resetContiguity=function(){},A.canParse=function(L,w){return!1},A.appendFrame=function(L,w,x){},A.demux=function(L,w){this.cachedData&&(L=Object(H.appendUint8Array)(this.cachedData,L),this.cachedData=null);var x=N.getID3Data(L,0),u=x?x.length:0,a,l,h=this._audioTrack,C=this._id3Track,g=x?N.getTimeStamp(x):void 0,m=L.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=O(g,w)),x&&x.length>0&&C.samples.push({pts:this.initPTS,dts:this.initPTS,data:x}),l=this.initPTS;u<m;){if(this.canParse(L,u)){var k=this.appendFrame(h,L,u);k?(this.frameIndex++,l=k.sample.pts,u+=k.length,a=u):u=m}else N.canParse(L,u)?(x=N.getID3Data(L,u),C.samples.push({pts:l,dts:l,data:x}),u+=x.length,a=u):u++;if(u===m&&a!==m){var v=Object(F.sliceUint8)(L,a);this.cachedData?this.cachedData=Object(H.appendUint8Array)(this.cachedData,v):this.cachedData=v}}return{audioTrack:h,avcTrack:Object(M.dummyTrack)(),id3Track:C,textTrack:Object(M.dummyTrack)()}},A.demuxSampleAes=function(L,w,x){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},A.flush=function(L){var w=this.cachedData;return w&&(this.cachedData=null,this.demux(w,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(M.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(M.dummyTrack)()}},A.destroy=function(){},b}(),O=function(A,D){return Object(V.isFiniteNumber)(A)?A*90:D*9e4};$.default=P},"./src/demux/chunk-cache.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return V});var V=function(){function M(){this.chunks=[],this.dataLength=0}var H=M.prototype;return H.push=function(P){this.chunks.push(P),this.dataLength+=P.length},H.flush=function(){var P=this.chunks,O=this.dataLength,b;if(P.length)P.length===1?b=P[0]:b=N(P,O);else return new Uint8Array(0);return this.reset(),b},H.reset=function(){this.chunks.length=0,this.dataLength=0},M}();function N(M,H){for(var F=new Uint8Array(H),P=0,O=0;O<M.length;O++){var b=M[O];F.set(b,P),P+=b.length}return F}},"./src/demux/dummy-demuxed-track.ts":function(ne,$,_){"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(ne,$,_){"use strict";_.r($);var V=_("./src/utils/logger.ts"),N=function(){function M(F){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=F,this.bytesAvailable=F.byteLength,this.word=0,this.bitsAvailable=0}var H=M.prototype;return H.loadWord=function(){var P=this.data,O=this.bytesAvailable,b=P.byteLength-O,A=new Uint8Array(4),D=Math.min(4,O);if(D===0)throw new Error("no bytes available");A.set(P.subarray(b,b+D)),this.word=new DataView(A.buffer).getUint32(0),this.bitsAvailable=D*8,this.bytesAvailable-=D},H.skipBits=function(P){var O;this.bitsAvailable>P?(this.word<<=P,this.bitsAvailable-=P):(P-=this.bitsAvailable,O=P>>3,P-=O>>3,this.bytesAvailable-=O,this.loadWord(),this.word<<=P,this.bitsAvailable-=P)},H.readBits=function(P){var O=Math.min(this.bitsAvailable,P),b=this.word>>>32-O;return P>32&&V.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=O,this.bitsAvailable>0?this.word<<=O:this.bytesAvailable>0&&this.loadWord(),O=P-O,O>0&&this.bitsAvailable?b<<O|this.readBits(O):b},H.skipLZ=function(){var P;for(P=0;P<this.bitsAvailable;++P)if((this.word&2147483648>>>P)!==0)return this.word<<=P,this.bitsAvailable-=P,P;return this.loadWord(),P+this.skipLZ()},H.skipUEG=function(){this.skipBits(1+this.skipLZ())},H.skipEG=function(){this.skipBits(1+this.skipLZ())},H.readUEG=function(){var P=this.skipLZ();return this.readBits(P+1)-1},H.readEG=function(){var P=this.readUEG();return 1&P?1+P>>>1:-1*(P>>>1)},H.readBoolean=function(){return this.readBits(1)===1},H.readUByte=function(){return this.readBits(8)},H.readUShort=function(){return this.readBits(16)},H.readUInt=function(){return this.readBits(32)},H.skipScalingList=function(P){for(var O=8,b=8,A,D=0;D<P;D++)b!==0&&(A=this.readEG(),b=(O+A+256)%256),O=b===0?O:b},H.readSPS=function(){var P=0,O=0,b=0,A=0,D,L,w,x=this.readUByte.bind(this),u=this.readBits.bind(this),a=this.readUEG.bind(this),l=this.readBoolean.bind(this),h=this.skipBits.bind(this),C=this.skipEG.bind(this),g=this.skipUEG.bind(this),m=this.skipScalingList.bind(this);x();var k=x();if(u(5),h(3),x(),g(),k===100||k===110||k===122||k===244||k===44||k===83||k===86||k===118||k===128){var v=a();if(v===3&&h(1),g(),g(),h(1),l())for(L=v!==3?8:12,w=0;w<L;w++)l()&&(w<6?m(16):m(64))}g();var f=a();if(f===0)a();else if(f===1)for(h(1),C(),C(),D=a(),w=0;w<D;w++)C();g(),h(1);var p=a(),d=a(),o=u(1);o===0&&h(1),h(1),l()&&(P=a(),O=a(),b=a(),A=a());var S=[1,1];if(l()&&l()){var y=x();switch(y){case 1:S=[1,1];break;case 2:S=[12,11];break;case 3:S=[10,11];break;case 4:S=[16,11];break;case 5:S=[40,33];break;case 6:S=[24,11];break;case 7:S=[20,11];break;case 8:S=[32,11];break;case 9:S=[80,33];break;case 10:S=[18,11];break;case 11:S=[15,11];break;case 12:S=[64,33];break;case 13:S=[160,99];break;case 14:S=[4,3];break;case 15:S=[3,2];break;case 16:S=[2,1];break;case 255:{S=[x()<<8|x(),x()<<8|x()];break}}}return{width:Math.ceil((p+1)*16-P*2-O*2),height:(2-o)*(d+1)*16-(o?2:4)*(b+A),pixelRatio:S}},H.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},M}();$.default=N},"./src/demux/id3.ts":function(ne,$,_){"use strict";_.r($),_.d($,"isHeader",function(){return V}),_.d($,"isFooter",function(){return N}),_.d($,"getID3Data",function(){return M}),_.d($,"canParse",function(){return F}),_.d($,"getTimeStamp",function(){return P}),_.d($,"isTimeStampFrame",function(){return O}),_.d($,"getID3Frames",function(){return A}),_.d($,"decodeFrame",function(){return D}),_.d($,"utf8ArrayToStr",function(){return a}),_.d($,"testables",function(){return l});var V=function(m,k){return k+10<=m.length&&(m[k]===73&&m[k+1]===68&&m[k+2]===51&&(m[k+3]<255&&m[k+4]<255&&(m[k+6]<128&&m[k+7]<128&&m[k+8]<128&&m[k+9]<128)))},N=function(m,k){return k+10<=m.length&&(m[k]===51&&m[k+1]===68&&m[k+2]===73&&(m[k+3]<255&&m[k+4]<255&&(m[k+6]<128&&m[k+7]<128&&m[k+8]<128&&m[k+9]<128)))},M=function(m,k){for(var v=k,f=0;V(m,k);){f+=10;var p=H(m,k+6);f+=p,N(m,k+10)&&(f+=10),k+=f}return f>0?m.subarray(v,v+f):void 0},H=function(m,k){var v=0;return v=(m[k]&127)<<21,v|=(m[k+1]&127)<<14,v|=(m[k+2]&127)<<7,v|=m[k+3]&127,v},F=function(m,k){return V(m,k)&&H(m,k+6)+10<=m.length-k},P=function(m){for(var k=A(m),v=0;v<k.length;v++){var f=k[v];if(O(f))return u(f)}return},O=function(m){return m&&m.key==="PRIV"&&m.info==="com.apple.streaming.transportStreamTimestamp"},b=function(m){var k=String.fromCharCode(m[0],m[1],m[2],m[3]),v=H(m,4),f=10;return{type:k,size:v,data:m.subarray(f,f+v)}},A=function(m){for(var k=0,v=[];V(m,k);){var f=H(m,k+6);k+=10;for(var p=k+f;k+8<p;){var d=b(m.subarray(k)),o=D(d);o&&v.push(o),k+=d.size+10}N(m,k)&&(k+=10)}return v},D=function(m){return m.type==="PRIV"?L(m):m.type[0]==="W"?x(m):w(m)},L=function(m){if(m.size<2)return;var k=a(m.data,!0),v=new Uint8Array(m.data.subarray(k.length+1));return{key:m.type,info:k,data:v.buffer}},w=function(m){if(m.size<2)return;if(m.type==="TXXX"){var k=1,v=a(m.data.subarray(k),!0);k+=v.length+1;var f=a(m.data.subarray(k));return{key:m.type,info:v,data:f}}var p=a(m.data.subarray(1));return{key:m.type,data:p}},x=function(m){if(m.type==="WXXX"){if(m.size<2)return;var k=1,v=a(m.data.subarray(k),!0);k+=v.length+1;var f=a(m.data.subarray(k));return{key:m.type,info:v,data:f}}var p=a(m.data);return{key:m.type,data:p}},u=function(m){if(m.data.byteLength===8){var k=new Uint8Array(m.data),v=k[3]&1,f=(k[4]<<23)+(k[5]<<15)+(k[6]<<7)+k[7];return f/=45,v&&(f+=4772185884e-2),Math.round(f)}return},a=function(m,k){k===void 0&&(k=!1);var v=C();if(v){var f=v.decode(m);if(k){var p=f.indexOf("\0");return p!==-1?f.substring(0,p):f}return f.replace(/\0/g,"")}for(var d=m.length,o,S,y,T="",I=0;I<d;){if(o=m[I++],o===0&&k)return T;if(o===0||o===3)continue;switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:T+=String.fromCharCode(o);break;case 12:case 13:S=m[I++],T+=String.fromCharCode((o&31)<<6|S&63);break;case 14:S=m[I++],y=m[I++],T+=String.fromCharCode((o&15)<<12|(S&63)<<6|(y&63)<<0);break;default:}}return T},l={decodeTextFrame:w},h;function C(){return!h&&typeof self.TextDecoder!="undefined"&&(h=new self.TextDecoder("utf-8")),h}},"./src/demux/mp3demuxer.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/demux/base-audio-demuxer.ts"),N=_("./src/demux/id3.ts"),M=_("./src/utils/logger.ts"),H=_("./src/demux/mpegaudio.ts");function F(b,A){b.prototype=Object.create(A.prototype),b.prototype.constructor=b,P(b,A)}function P(b,A){return P=Object.setPrototypeOf||function(L,w){return L.__proto__=w,L},P(b,A)}var O=function(b){F(A,b);function A(){return b.apply(this,arguments)||this}var D=A.prototype;return D.resetInitSegment=function(w,x,u){b.prototype.resetInitSegment.call(this,w,x,u),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:w,duration:u,inputTimeScale:9e4,dropped:0}},A.probe=function(w){if(!w)return!1;for(var x=N.getID3Data(w,0)||[],u=x.length,a=w.length;u<a;u++)if(H.probe(w,u))return M.logger.log("MPEG Audio sync word found !"),!0;return!1},D.canParse=function(w,x){return H.canParse(w,x)},D.appendFrame=function(w,x,u){return this.initPTS===null?void 0:H.appendFrame(w,x,u,this.initPTS,this.frameIndex)},A}(V.default);O.minProbeByteLength=4,$.default=O},"./src/demux/mp4demuxer.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/utils/mp4-tools.ts"),N=_("./src/demux/dummy-demuxed-track.ts"),M=function(){function H(P,O){this.remainderData=null,this.config=void 0,this.config=O}var F=H.prototype;return F.resetTimeStamp=function(){},F.resetInitSegment=function(){},F.resetContiguity=function(){},H.probe=function(O){return Object(V.findBox)({data:O,start:0,end:Math.min(O.length,16384)},["moof"]).length>0},F.demux=function(O){var b=O,A=Object(N.dummyTrack)();if(this.config.progressive){this.remainderData&&(b=Object(V.appendUint8Array)(this.remainderData,O));var D=Object(V.segmentValidRange)(b);this.remainderData=D.remainder,A.samples=D.valid||new Uint8Array}else A.samples=b;return{audioTrack:Object(N.dummyTrack)(),avcTrack:A,id3Track:Object(N.dummyTrack)(),textTrack:Object(N.dummyTrack)()}},F.flush=function(){var O=Object(N.dummyTrack)();return O.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(N.dummyTrack)(),avcTrack:O,id3Track:Object(N.dummyTrack)(),textTrack:Object(N.dummyTrack)()}},F.demuxSampleAes=function(O,b,A){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},F.destroy=function(){},H}();M.minProbeByteLength=1024,$.default=M},"./src/demux/mpegaudio.ts":function(ne,$,_){"use strict";_.r($),_.d($,"appendFrame",function(){return P}),_.d($,"parseHeader",function(){return O}),_.d($,"isHeaderPattern",function(){return b}),_.d($,"isHeader",function(){return A}),_.d($,"canParse",function(){return D}),_.d($,"probe",function(){return L});var V=null,N=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],M=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],H=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],F=[0,1,1,4];function P(w,x,u,a,l){if(u+24>x.length)return;var h=O(x,u);if(h&&u+h.frameLength<=x.length){var C=h.samplesPerFrame*9e4/h.sampleRate,g=a+l*C,m={unit:x.subarray(u,u+h.frameLength),pts:g,dts:g};return w.config=[],w.channelCount=h.channelCount,w.samplerate=h.sampleRate,w.samples.push(m),{sample:m,length:h.frameLength,missing:0}}}function O(w,x){var u=w[x+1]>>3&3,a=w[x+1]>>1&3,l=w[x+2]>>4&15,h=w[x+2]>>2&3;if(u!==1&&l!==0&&l!==15&&h!==3){var C=w[x+2]>>1&1,g=w[x+3]>>6,m=u===3?3-a:a===3?3:4,k=N[m*14+l-1]*1e3,v=u===3?0:u===2?1:2,f=M[v*3+h],p=g===3?1:2,d=H[u][a],o=F[a],S=d*8*o,y=Math.floor(d*k/f+C)*o;if(V===null){var T=navigator.userAgent||"",I=T.match(/Chrome\/(\d+)/i);V=I?parseInt(I[1]):0}var G=!!V&&V<=87;return G&&a===2&&k>=224e3&&g===0&&(w[x+3]=w[x+3]|128),{sampleRate:f,channelCount:p,frameLength:y,samplesPerFrame:S}}}function b(w,x){return w[x]===255&&(w[x+1]&224)===224&&(w[x+1]&6)!==0}function A(w,x){return x+1<w.length&&b(w,x)}function D(w,x){var u=4;return b(w,x)&&u<=w.length-x}function L(w,x){if(x+1<w.length&&b(w,x)){var u=4,a=O(w,x),l=u;a!=null&&a.frameLength&&(l=a.frameLength);var h=x+l;return h===w.length||A(w,h)}return!1}},"./src/demux/sample-aes.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/crypt/decrypter.ts"),N=_("./src/demux/tsdemuxer.ts"),M=function(){function H(P,O,b){this.keyData=void 0,this.decrypter=void 0,this.keyData=b,this.decrypter=new V.default(P,O,{removePKCS7Padding:!1})}var F=H.prototype;return F.decryptBuffer=function(O,b){this.decrypter.decrypt(O,this.keyData.key.buffer,this.keyData.iv.buffer,b)},F.decryptAacSample=function(O,b,A,D){var L=O[b].unit,w=L.subarray(16,L.length-L.length%16),x=w.buffer.slice(w.byteOffset,w.byteOffset+w.length),u=this;this.decryptBuffer(x,function(a){var l=new Uint8Array(a);L.set(l,16),D||u.decryptAacSamples(O,b+1,A)})},F.decryptAacSamples=function(O,b,A){for(;;b++){if(b>=O.length){A();return}if(O[b].unit.length<32)continue;var D=this.decrypter.isSync();if(this.decryptAacSample(O,b,A,D),!D)return}},F.getAvcEncryptedData=function(O){for(var b=Math.floor((O.length-48)/160)*16+16,A=new Int8Array(b),D=0,L=32;L<=O.length-16;L+=160,D+=16)A.set(O.subarray(L,L+16),D);return A},F.getAvcDecryptedUnit=function(O,b){for(var A=new Uint8Array(b),D=0,L=32;L<=O.length-16;L+=160,D+=16)O.set(A.subarray(D,D+16),L);return O},F.decryptAvcSample=function(O,b,A,D,L,w){var x=Object(N.discardEPB)(L.data),u=this.getAvcEncryptedData(x),a=this;this.decryptBuffer(u.buffer,function(l){L.data=a.getAvcDecryptedUnit(x,l),w||a.decryptAvcSamples(O,b,A+1,D)})},F.decryptAvcSamples=function(O,b,A,D){if(O instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;b++,A=0){if(b>=O.length){D();return}for(var L=O[b].units;!(A>=L.length);A++){var w=L[A];if(w.data.length<=48||w.type!==1&&w.type!==5)continue;var x=this.decrypter.isSync();if(this.decryptAvcSample(O,b,A,D,w,x),!x)return}}},H}();$.default=M},"./src/demux/transmuxer-interface.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return L});var V=_("./node_modules/webworkify-webpack/index.js"),N=_.n(V),M=_("./src/events.ts"),H=_("./src/demux/transmuxer.ts"),F=_("./src/utils/logger.ts"),P=_("./src/errors.ts"),O=_("./src/utils/mediasource-helper.ts"),b=_("./node_modules/eventemitter3/index.js"),A=_.n(b),D=Object(O.getMediaSource)()||{isTypeSupported:function(){return!1}},L=function(){function w(u,a,l,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=u,this.id=a,this.onTransmuxComplete=l,this.onFlush=h;var g=u.config,m=function(d,o){o=o||{},o.frag=C.frag,o.id=C.id,u.trigger(d,o)};this.observer=new b.EventEmitter,this.observer.on(M.Events.FRAG_DECRYPTED,m),this.observer.on(M.Events.ERROR,m);var k={mp4:D.isTypeSupported("video/mp4"),mpeg:D.isTypeSupported("audio/mpeg"),mp3:D.isTypeSupported('audio/mp4; codecs="mp3"')},v=navigator.vendor;if(g.enableWorker&&typeof Worker!="undefined"){F.logger.log("demuxing in webworker");var f;try{f=this.worker=V("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),f.addEventListener("message",this.onwmsg),f.onerror=function(p){u.trigger(M.Events.ERROR,{type:P.ErrorTypes.OTHER_ERROR,details:P.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(p.message+" ("+p.filename+":"+p.lineno+")")})},f.postMessage({cmd:"init",typeSupported:k,vendor:v,id:a,config:JSON.stringify(g)})}catch(p){F.logger.warn("Error in worker:",p),F.logger.error("Error while initializing DemuxerWorker, fallback to inline"),f&&self.URL.revokeObjectURL(f.objectURL),this.transmuxer=new H.default(this.observer,k,g,v,a),this.worker=null}}else this.transmuxer=new H.default(this.observer,k,g,v,a)}var x=w.prototype;return x.destroy=function(){var a=this.worker;if(a)a.removeEventListener("message",this.onwmsg),a.terminate(),this.worker=null;else{var l=this.transmuxer;l&&(l.destroy(),this.transmuxer=null)}var h=this.observer;h&&h.removeAllListeners(),this.observer=null},x.push=function(a,l,h,C,g,m,k,v,f,p){var d=this;f.transmuxing.start=self.performance.now();var o=this.transmuxer,S=this.worker,y=m?m.start:g.start,T=g.decryptdata,I=this.frag,G=!(I&&g.cc===I.cc),X=!(I&&f.level===I.level),Q=I?f.sn-I.sn:-1,z=this.part?f.part-this.part.index:1,W=!X&&(Q===1||Q===0&&z===1),ee=self.performance.now();(X||Q||g.stats.parsing.start===0)&&(g.stats.parsing.start=ee),m&&(z||!W)&&(m.stats.parsing.start=ee);var ae=new H.TransmuxState(G,W,v,X,y);if(!W||G){F.logger.log("[transmuxer-interface, "+g.type+"]: Starting new transmux session for sn: "+f.sn+" p: "+f.part+" level: "+f.level+" id: "+f.id+`
|
|
discontinuity: `+G+`
|
|
trackSwitch: `+X+`
|
|
contiguous: `+W+`
|
|
accurateTimeOffset: `+v+`
|
|
timeOffset: `+y);var pe=new H.TransmuxConfig(h,C,l,k,p);this.configureTransmuxer(pe)}if(this.frag=g,this.part=m,S)S.postMessage({cmd:"demux",data:a,decryptdata:T,chunkMeta:f,state:ae},a instanceof ArrayBuffer?[a]:[]);else if(o){var ve=o.push(a,T,f,ae);Object(H.isPromise)(ve)?ve.then(function(De){d.handleTransmuxComplete(De)}):this.handleTransmuxComplete(ve)}},x.flush=function(a){var l=this;a.transmuxing.start=self.performance.now();var h=this.transmuxer,C=this.worker;if(C)C.postMessage({cmd:"flush",chunkMeta:a});else if(h){var g=h.flush(a);Object(H.isPromise)(g)?g.then(function(m){l.handleFlushResult(m,a)}):this.handleFlushResult(g,a)}},x.handleFlushResult=function(a,l){var h=this;a.forEach(function(C){h.handleTransmuxComplete(C)}),this.onFlush(l)},x.onWorkerMessage=function(a){var l=a.data,h=this.hls;switch(l.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(l.data);break}case"flush":{this.onFlush(l.data);break}default:{l.data=l.data||{},l.data.frag=this.frag,l.data.id=this.id,h.trigger(l.event,l.data);break}}},x.configureTransmuxer=function(a){var l=this.worker,h=this.transmuxer;l?l.postMessage({cmd:"configure",config:a}):h&&h.configure(a)},x.handleTransmuxComplete=function(a){a.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(a)},w}()},"./src/demux/transmuxer-worker.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return P});var V=_("./src/demux/transmuxer.ts"),N=_("./src/events.ts"),M=_("./src/utils/logger.ts"),H=_("./node_modules/eventemitter3/index.js"),F=_.n(H);function P(L){var w=new H.EventEmitter,x=function(a,l){L.postMessage({event:a,data:l})};w.on(N.Events.FRAG_DECRYPTED,x),w.on(N.Events.ERROR,x),L.addEventListener("message",function(u){var a=u.data;switch(a.cmd){case"init":{var l=JSON.parse(a.config);L.transmuxer=new V.default(w,a.typeSupported,l,a.vendor,a.id),Object(M.enableLogs)(l.debug),x("init",null);break}case"configure":{L.transmuxer.configure(a.config);break}case"demux":{var h=L.transmuxer.push(a.data,a.decryptdata,a.chunkMeta,a.state);Object(V.isPromise)(h)?h.then(function(m){O(L,m)}):O(L,h);break}case"flush":{var C=a.chunkMeta,g=L.transmuxer.flush(C);Object(V.isPromise)(g)?g.then(function(m){A(L,m,C)}):A(L,g,C);break}default:break}})}function O(L,w){if(D(w.remuxResult))return;var x=[],u=w.remuxResult,a=u.audio,l=u.video;a&&b(x,a),l&&b(x,l),L.postMessage({event:"transmuxComplete",data:w},x)}function b(L,w){w.data1&&L.push(w.data1.buffer),w.data2&&L.push(w.data2.buffer)}function A(L,w,x){w.forEach(function(u){O(L,u)}),L.postMessage({event:"flush",data:x})}function D(L){return!L.audio&&!L.video&&!L.text&&!L.id3&&!L.initSegment}},"./src/demux/transmuxer.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return l}),_.d($,"isPromise",function(){return g}),_.d($,"TransmuxConfig",function(){return m}),_.d($,"TransmuxState",function(){return k});var V=_("./src/events.ts"),N=_("./src/errors.ts"),M=_("./src/crypt/decrypter.ts"),H=_("./src/demux/aacdemuxer.ts"),F=_("./src/demux/mp4demuxer.ts"),P=_("./src/demux/tsdemuxer.ts"),O=_("./src/demux/mp3demuxer.ts"),b=_("./src/remux/mp4-remuxer.ts"),A=_("./src/remux/passthrough-remuxer.ts"),D=_("./src/demux/chunk-cache.ts"),L=_("./src/utils/mp4-tools.ts"),w=_("./src/utils/logger.ts"),x;try{x=self.performance.now.bind(self.performance)}catch(v){w.logger.debug("Unable to use Performance API on this environment"),x=self.Date.now}var u=[{demux:P.default,remux:b.default},{demux:F.default,remux:A.default},{demux:H.default,remux:b.default},{demux:O.default,remux:b.default}],a=1024;u.forEach(function(v){var f=v.demux;a=Math.max(a,f.minProbeByteLength)});var l=function(){function v(p,d,o,S,y){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new D.default,this.observer=p,this.typeSupported=d,this.config=o,this.vendor=S,this.id=y}var f=v.prototype;return f.configure=function(d){this.transmuxConfig=d,this.decrypter&&this.decrypter.reset()},f.push=function(d,o,S,y){var T=this,I=S.transmuxing;I.executeStart=x();var G=new Uint8Array(d),X=this.cache,Q=this.config,z=this.currentTransmuxState,W=this.transmuxConfig;y&&(this.currentTransmuxState=y);var ee=h(G,o);if(ee&&ee.method==="AES-128"){var ae=this.getDecrypter();if(Q.enableSoftwareAES){var pe=ae.softwareDecrypt(G,ee.key.buffer,ee.iv.buffer);if(!pe)return I.executeEnd=x(),C(S);G=new Uint8Array(pe)}else return this.decryptionPromise=ae.webCryptoDecrypt(G,ee.key.buffer,ee.iv.buffer).then(function(Ie){var We=T.push(Ie,null,S);return T.decryptionPromise=null,We}),this.decryptionPromise}var ve=y||z,De=ve.contiguous,xe=ve.discontinuity,Ce=ve.trackSwitch,Ae=ve.accurateTimeOffset,Se=ve.timeOffset,ge=W.audioCodec,oe=W.videoCodec,Re=W.defaultInitPts,Ze=W.duration,He=W.initSegmentData;if((xe||Ce)&&this.resetInitSegment(He,ge,oe,Ze),xe&&this.resetInitialTimestamp(Re),De||this.resetContiguity(),this.needsProbing(G,xe,Ce)){if(X.dataLength){var Ge=X.flush();G=Object(L.appendUint8Array)(Ge,G)}this.configureTransmuxer(G,W)}var $e=this.transmux(G,ee,Se,Ae,S),_e=this.currentTransmuxState;return _e.contiguous=!0,_e.discontinuity=!1,_e.trackSwitch=!1,I.executeEnd=x(),$e},f.flush=function(d){var o=this,S=d.transmuxing;S.executeStart=x();var y=this.decrypter,T=this.cache,I=this.currentTransmuxState,G=this.decryptionPromise;if(G)return G.then(function(){return o.flush(d)});var X=[],Q=I.timeOffset;if(y){var z=y.flush();z&&X.push(this.push(z,null,d))}var W=T.dataLength;T.reset();var ee=this.demuxer,ae=this.remuxer;if(!ee||!ae)return W>=a&&this.observer.emit(V.Events.ERROR,V.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),S.executeEnd=x(),[C(d)];var pe=ee.flush(Q);return g(pe)?pe.then(function(ve){return o.flushRemux(X,ve,d),X}):(this.flushRemux(X,pe,d),X)},f.flushRemux=function(d,o,S){var y=o.audioTrack,T=o.avcTrack,I=o.id3Track,G=o.textTrack,X=this.currentTransmuxState,Q=X.accurateTimeOffset,z=X.timeOffset;w.logger.log("[transmuxer.ts]: Flushed fragment "+S.sn+(S.part>-1?" p: "+S.part:"")+" of level "+S.level);var W=this.remuxer.remux(y,T,I,G,z,Q,!0,this.id);d.push({remuxResult:W,chunkMeta:S}),S.transmuxing.executeEnd=x()},f.resetInitialTimestamp=function(d){var o=this.demuxer,S=this.remuxer;if(!o||!S)return;o.resetTimeStamp(d),S.resetTimeStamp(d)},f.resetContiguity=function(){var d=this.demuxer,o=this.remuxer;if(!d||!o)return;d.resetContiguity(),o.resetNextTimestamp()},f.resetInitSegment=function(d,o,S,y){var T=this.demuxer,I=this.remuxer;if(!T||!I)return;T.resetInitSegment(o,S,y),I.resetInitSegment(d,o,S)},f.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},f.transmux=function(d,o,S,y,T){var I;return o&&o.method==="SAMPLE-AES"?I=this.transmuxSampleAes(d,o,S,y,T):I=this.transmuxUnencrypted(d,S,y,T),I},f.transmuxUnencrypted=function(d,o,S,y){var T=this.demuxer.demux(d,o,!1,!this.config.progressive),I=T.audioTrack,G=T.avcTrack,X=T.id3Track,Q=T.textTrack,z=this.remuxer.remux(I,G,X,Q,o,S,!1,this.id);return{remuxResult:z,chunkMeta:y}},f.transmuxSampleAes=function(d,o,S,y,T){var I=this;return this.demuxer.demuxSampleAes(d,o,S).then(function(G){var X=I.remuxer.remux(G.audioTrack,G.avcTrack,G.id3Track,G.textTrack,S,y,!1,I.id);return{remuxResult:X,chunkMeta:T}})},f.configureTransmuxer=function(d,o){for(var S=this.config,y=this.observer,T=this.typeSupported,I=this.vendor,G=o.audioCodec,X=o.defaultInitPts,Q=o.duration,z=o.initSegmentData,W=o.videoCodec,ee,ae=0,pe=u.length;ae<pe;ae++)if(u[ae].demux.probe(d)){ee=u[ae];break}ee||(w.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),ee={demux:F.default,remux:A.default});var ve=this.demuxer,De=this.remuxer,xe=ee.remux,Ce=ee.demux;(!De||!(De instanceof xe))&&(this.remuxer=new xe(y,S,T,I)),(!ve||!(ve instanceof Ce))&&(this.demuxer=new Ce(y,S,T),this.probe=Ce.probe),this.resetInitSegment(z,G,W,Q),this.resetInitialTimestamp(X)},f.needsProbing=function(d,o,S){return!this.demuxer||!this.remuxer||o||S},f.getDecrypter=function(){var d=this.decrypter;return d||(d=this.decrypter=new M.default(this.observer,this.config)),d},v}();function h(v,f){var p=null;return v.byteLength>0&&f!=null&&f.key!=null&&f.iv!==null&&f.method!=null&&(p=f),p}var C=function(f){return{remuxResult:{},chunkMeta:f}};function g(v){return"then"in v&&v.then instanceof Function}var m=function(f,p,d,o,S){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=f,this.videoCodec=p,this.initSegmentData=d,this.duration=o,this.defaultInitPts=S},k=function(f,p,d,o,S){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=f,this.contiguous=p,this.accurateTimeOffset=d,this.trackSwitch=o,this.timeOffset=S}},"./src/demux/tsdemuxer.ts":function(ne,$,_){"use strict";_.r($),_.d($,"discardEPB",function(){return C});var V=_("./src/demux/adts.ts"),N=_("./src/demux/mpegaudio.ts"),M=_("./src/demux/exp-golomb.ts"),H=_("./src/demux/id3.ts"),F=_("./src/demux/sample-aes.ts"),P=_("./src/events.ts"),O=_("./src/utils/mp4-tools.ts"),b=_("./src/utils/logger.ts"),A=_("./src/errors.ts"),D={video:1,audio:2,id3:3,text:4},L=function(){function g(k,v,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=k,this.config=v,this.typeSupported=f}g.probe=function(v){var f=g.syncOffset(v);return f<0?!1:(f&&b.logger.warn("MPEG2-TS detected but first sync word found @ offset "+f+", junk ahead ?"),!0)},g.syncOffset=function(v){for(var f=Math.min(1e3,v.length-3*188),p=0;p<f;){if(v[p]===71&&v[p+188]===71&&v[p+2*188]===71)return p;p++}return-1},g.createTrack=function(v,f){return{container:v==="video"||v==="audio"?"video/mp2t":void 0,type:v,id:D[v],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:v==="audio"?f:void 0}};var m=g.prototype;return m.resetInitSegment=function(v,f,p){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=g.createTrack("video",p),this._audioTrack=g.createTrack("audio",p),this._id3Track=g.createTrack("id3",p),this._txtTrack=g.createTrack("text",p),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=v,this.videoCodec=f,this._duration=p},m.resetTimeStamp=function(){},m.resetContiguity=function(){var v=this._audioTrack,f=this._avcTrack,p=this._id3Track;v&&(v.pesData=null),f&&(f.pesData=null),p&&(p.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},m.demux=function(v,f,p,d){p===void 0&&(p=!1),d===void 0&&(d=!1),p||(this.sampleAes=null);var o,S=this._avcTrack,y=this._audioTrack,T=this._id3Track,I=S.pid,G=S.pesData,X=y.pid,Q=T.pid,z=y.pesData,W=T.pesData,ee=!1,ae=this.pmtParsed,pe=this._pmtId,ve=v.length;if(this.remainderData&&(v=Object(O.appendUint8Array)(this.remainderData,v),ve=v.length,this.remainderData=null),ve<188&&!d)return this.remainderData=v,{audioTrack:y,avcTrack:S,id3Track:T,textTrack:this._txtTrack};var De=Math.max(0,g.syncOffset(v));ve-=(ve+De)%188,ve<v.byteLength&&!d&&(this.remainderData=new Uint8Array(v.buffer,ve,v.buffer.byteLength-ve));for(var xe=De;xe<ve;xe+=188)if(v[xe]===71){var Ce=!!(v[xe+1]&64),Ae=((v[xe+1]&31)<<8)+v[xe+2],Se=(v[xe+3]&48)>>4,ge=void 0;if(Se>1){if(ge=xe+5+v[xe+4],ge===xe+188)continue}else ge=xe+4;switch(Ae){case I:Ce&&(G&&(o=a(G))&&this.parseAVCPES(o,!1),G={data:[],size:0}),G&&(G.data.push(v.subarray(ge,xe+188)),G.size+=xe+188-ge);break;case X:Ce&&(z&&(o=a(z))&&(y.isAAC?this.parseAACPES(o):this.parseMPEGPES(o)),z={data:[],size:0}),z&&(z.data.push(v.subarray(ge,xe+188)),z.size+=xe+188-ge);break;case Q:Ce&&(W&&(o=a(W))&&this.parseID3PES(o),W={data:[],size:0}),W&&(W.data.push(v.subarray(ge,xe+188)),W.size+=xe+188-ge);break;case 0:Ce&&(ge+=v[ge]+1),pe=this._pmtId=x(v,ge);break;case pe:{Ce&&(ge+=v[ge]+1);var oe=u(v,ge,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,p);I=oe.avc,I>0&&(S.pid=I),X=oe.audio,X>0&&(y.pid=X,y.isAAC=oe.isAAC),Q=oe.id3,Q>0&&(T.pid=Q),ee&&!ae&&(b.logger.log("reparse from beginning"),ee=!1,xe=De-188),ae=this.pmtParsed=!0;break}case 17:case 8191:break;default:ee=!0;break}}else this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});S.pesData=G,y.pesData=z,T.pesData=W;var Re={audioTrack:y,avcTrack:S,id3Track:T,textTrack:this._txtTrack};return d&&this.extractRemainingSamples(Re),Re},m.flush=function(){var v=this.remainderData;this.remainderData=null;var f;return v?f=this.demux(v,-1,!1,!0):f={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(f),this.sampleAes?this.decrypt(f,this.sampleAes):f},m.extractRemainingSamples=function(v){var f=v.audioTrack,p=v.avcTrack,d=v.id3Track,o=p.pesData,S=f.pesData,y=d.pesData,T;o&&(T=a(o))?(this.parseAVCPES(T,!0),p.pesData=null):p.pesData=o,S&&(T=a(S))?(f.isAAC?this.parseAACPES(T):this.parseMPEGPES(T),f.pesData=null):(S!=null&&S.size&&b.logger.log("last AAC PES packet truncated,might overlap between fragments"),f.pesData=S),y&&(T=a(y))?(this.parseID3PES(T),d.pesData=null):d.pesData=y},m.demuxSampleAes=function(v,f,p){var d=this.demux(v,p,!0,!this.config.progressive),o=this.sampleAes=new F.default(this.observer,this.config,f);return this.decrypt(d,o)},m.decrypt=function(v,f){return new Promise(function(p){var d=v.audioTrack,o=v.avcTrack;d.samples&&d.isAAC?f.decryptAacSamples(d.samples,0,function(){o.samples?f.decryptAvcSamples(o.samples,0,0,function(){p(v)}):p(v)}):o.samples&&f.decryptAvcSamples(o.samples,0,0,function(){p(v)})})},m.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},m.parseAVCPES=function(v,f){var p=this,d=this._avcTrack,o=this.parseAVCNALu(v.data),S=!1,y=this.avcSample,T,I=!1;v.data=null,y&&o.length&&!d.audFound&&(l(y,d),y=this.avcSample=w(!1,v.pts,v.dts,"")),o.forEach(function(G){switch(G.type){case 1:{T=!0,y||(y=p.avcSample=w(!0,v.pts,v.dts,"")),S&&(y.debug+="NDR "),y.frame=!0;var X=G.data;if(I&&X.length>4){var Q=new M.default(X).readSliceType();(Q===2||Q===4||Q===7||Q===9)&&(y.key=!0)}break}case 5:T=!0,y||(y=p.avcSample=w(!0,v.pts,v.dts,"")),S&&(y.debug+="IDR "),y.key=!0,y.frame=!0;break;case 6:{T=!0,S&&y&&(y.debug+="SEI ");var z=new M.default(C(G.data));z.readUByte();for(var W=0,ee=0,ae=!1,pe=0;!ae&&z.bytesAvailable>1;){W=0;do pe=z.readUByte(),W+=pe;while(pe===255);ee=0;do pe=z.readUByte(),ee+=pe;while(pe===255);if(W===4&&z.bytesAvailable!==0){ae=!0;var ve=z.readUByte();if(ve===181){var De=z.readUShort();if(De===49){var xe=z.readUInt();if(xe===1195456820){var Ce=z.readUByte();if(Ce===3){for(var Ae=z.readUByte(),Se=z.readUByte(),ge=31&Ae,oe=[Ae,Se],Re=0;Re<ge;Re++)oe.push(z.readUByte()),oe.push(z.readUByte()),oe.push(z.readUByte());h(p._txtTrack.samples,{type:3,pts:v.pts,bytes:oe})}}}}}else if(W===5&&z.bytesAvailable!==0){if(ae=!0,ee>16){for(var Ze=[],He=0;He<16;He++)Ze.push(z.readUByte().toString(16)),(He===3||He===5||He===7||He===9)&&Ze.push("-");for(var Ge=ee-16,$e=new Uint8Array(Ge),_e=0;_e<Ge;_e++)$e[_e]=z.readUByte();h(p._txtTrack.samples,{pts:v.pts,payloadType:W,uuid:Ze.join(""),userData:Object(H.utf8ArrayToStr)($e),userDataBytes:$e})}}else if(ee<z.bytesAvailable)for(var Ie=0;Ie<ee;Ie++)z.readUByte()}break}case 7:if(T=!0,I=!0,S&&y&&(y.debug+="SPS "),!d.sps){var We=new M.default(G.data),Ve=We.readSPS();d.width=Ve.width,d.height=Ve.height,d.pixelRatio=Ve.pixelRatio,d.sps=[G.data],d.duration=p._duration;for(var ze=G.data.subarray(1,4),Be="avc1.",Fe=0;Fe<3;Fe++){var ot=ze[Fe].toString(16);ot.length<2&&(ot="0"+ot),Be+=ot}d.codec=Be}break;case 8:T=!0,S&&y&&(y.debug+="PPS "),d.pps||(d.pps=[G.data]);break;case 9:T=!1,d.audFound=!0,y&&l(y,d),y=p.avcSample=w(!1,v.pts,v.dts,S?"AUD ":"");break;case 12:T=!1;break;default:T=!1,y&&(y.debug+="unknown NAL "+G.type+" ");break}if(y&&T){var it=y.units;it.push(G)}}),f&&y&&(l(y,d),this.avcSample=null)},m.getLastNalUnit=function(){var v,f=this.avcSample,p;if(!f||f.units.length===0){var d=this._avcTrack.samples;f=d[d.length-1]}if((v=f)!==null&&v!==void 0&&v.units){var o=f.units;p=o[o.length-1]}return p},m.parseAVCNALu=function(v){var f=v.byteLength,p=this._avcTrack,d=p.naluState||0,o=d,S=[],y=0,T,I,G,X=-1,Q=0;for(d===-1&&(X=0,Q=v[0]&31,d=0,y=1);y<f;){if(T=v[y++],!d){d=T?0:1;continue}if(d===1){d=T?0:2;continue}if(!T)d=3;else if(T===1){if(X>=0){var z={data:v.subarray(X,y-d-1),type:Q};S.push(z)}else{var W=this.getLastNalUnit();if(W&&(o&&y<=4-o&&(W.state&&(W.data=W.data.subarray(0,W.data.byteLength-o))),I=y-d-1,I>0)){var ee=new Uint8Array(W.data.byteLength+I);ee.set(W.data,0),ee.set(v.subarray(0,I),W.data.byteLength),W.data=ee,W.state=0}}y<f?(G=v[y]&31,X=y,Q=G,d=0):d=-1}else d=0}if(X>=0&&d>=0){var ae={data:v.subarray(X,f),type:Q,state:d};S.push(ae)}if(S.length===0){var pe=this.getLastNalUnit();if(pe){var ve=new Uint8Array(pe.data.byteLength+v.byteLength);ve.set(pe.data,0),ve.set(v,pe.data.byteLength),pe.data=ve}}return p.naluState=d,S},m.parseAACPES=function(v){var f=0,p=this._audioTrack,d=this.aacOverFlow,o=v.data;if(d){this.aacOverFlow=null;var S=d.sample.unit.byteLength,y=Math.min(d.missing,S),T=S-y;d.sample.unit.set(o.subarray(0,y),T),p.samples.push(d.sample),f=d.missing}var I,G;for(I=f,G=o.length;I<G-1&&!V.isHeader(o,I);I++);if(I!==f){var X,Q;if(I<G-1?(X="AAC PES did not start with ADTS header,offset:"+I,Q=!1):(X="no ADTS header found in AAC PES",Q=!0),b.logger.warn("parsing error:"+X),this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:Q,reason:X}),Q)return}V.initTrackConfig(p,this.observer,o,I,this.audioCodec);var z;if(v.pts!==void 0)z=v.pts;else if(d){var W=V.getFrameDuration(p.samplerate);z=d.sample.pts+W}else{b.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var ee=0;I<G;)if(V.isHeader(o,I)){if(I+5<G){var ae=V.appendFrame(p,o,I,z,ee);if(ae)if(ae.missing)this.aacOverFlow=ae;else{I+=ae.length,ee++;continue}}break}else I++},m.parseMPEGPES=function(v){var f=v.data,p=f.length,d=0,o=0,S=v.pts;if(S===void 0){b.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;o<p;)if(N.isHeader(f,o)){var y=N.appendFrame(this._audioTrack,f,o,S,d);if(y)o+=y.length,d++;else break}else o++},m.parseID3PES=function(v){if(v.pts===void 0){b.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(v)},g}();L.minProbeByteLength=188;function w(g,m,k,v){return{key:g,frame:!1,pts:m,dts:k,units:[],debug:v,length:0}}function x(g,m){return(g[m+10]&31)<<8|g[m+11]}function u(g,m,k,v){var f={audio:-1,avc:-1,id3:-1,isAAC:!0},p=(g[m+1]&15)<<8|g[m+2],d=m+3+p-4,o=(g[m+10]&15)<<8|g[m+11];for(m+=12+o;m<d;){var S=(g[m+1]&31)<<8|g[m+2];switch(g[m]){case 207:if(!v){b.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:f.audio===-1&&(f.audio=S);break;case 21:f.id3===-1&&(f.id3=S);break;case 219:if(!v){b.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:f.avc===-1&&(f.avc=S);break;case 3:case 4:k?f.audio===-1&&(f.audio=S,f.isAAC=!1):b.logger.log("MPEG audio found, not supported in this browser");break;case 36:b.logger.warn("Unsupported HEVC stream type found");break;default:break}m+=((g[m+3]&15)<<8|g[m+4])+5}return f}function a(g){var m=0,k,v,f,p,d,o=g.data;if(!g||g.size===0)return null;for(;o[0].length<19&&o.length>1;){var S=new Uint8Array(o[0].length+o[1].length);S.set(o[0]),S.set(o[1],o[0].length),o[0]=S,o.splice(1,1)}k=o[0];var y=(k[0]<<16)+(k[1]<<8)+k[2];if(y===1){if(v=(k[4]<<8)+k[5],v&&v>g.size-6)return null;var T=k[7];T&192&&(p=(k[9]&14)*536870912+(k[10]&255)*4194304+(k[11]&254)*16384+(k[12]&255)*128+(k[13]&254)/2,T&64?(d=(k[14]&14)*536870912+(k[15]&255)*4194304+(k[16]&254)*16384+(k[17]&255)*128+(k[18]&254)/2,p-d>60*9e4&&(b.logger.warn(Math.round((p-d)/9e4)+"s delta between PTS and DTS, align them"),p=d)):d=p),f=k[8];var I=f+9;if(g.size<=I)return null;g.size-=I;for(var G=new Uint8Array(g.size),X=0,Q=o.length;X<Q;X++){k=o[X];var z=k.byteLength;if(I)if(I>z){I-=z;continue}else k=k.subarray(I),z-=I,I=0;G.set(k,m),m+=z}return v&&(v-=f+3),{data:G,pts:p,dts:d,len:v}}return null}function l(g,m){if(g.units.length&&g.frame){if(g.pts===void 0){var k=m.samples,v=k.length;if(v){var f=k[v-1];g.pts=f.pts,g.dts=f.dts}else{m.dropped++;return}}m.samples.push(g)}g.debug.length&&b.logger.log(g.pts+"/"+g.dts+":"+g.debug)}function h(g,m){var k=g.length;if(k>0){if(m.pts>=g[k-1].pts)g.push(m);else for(var v=k-1;v>=0;v--)if(m.pts<g[v].pts){g.splice(v,0,m);break}}else g.push(m)}function C(g){for(var m=g.byteLength,k=[],v=1;v<m-2;)g[v]===0&&g[v+1]===0&&g[v+2]===3?(k.push(v+2),v+=2):v++;if(k.length===0)return g;var f=m-k.length,p=new Uint8Array(f),d=0;for(v=0;v<f;d++,v++)d===k[0]&&(d++,k.shift()),p[v]=g[d];return p}$.default=L},"./src/errors.ts":function(ne,$,_){"use strict";_.r($),_.d($,"ErrorTypes",function(){return V}),_.d($,"ErrorDetails",function(){return N});var V;(function(M){M.NETWORK_ERROR="networkError",M.MEDIA_ERROR="mediaError",M.KEY_SYSTEM_ERROR="keySystemError",M.MUX_ERROR="muxError",M.OTHER_ERROR="otherError"})(V||(V={}));var N;(function(M){M.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",M.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",M.KEY_SYSTEM_NO_SESSION="keySystemNoSession",M.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",M.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",M.MANIFEST_LOAD_ERROR="manifestLoadError",M.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",M.MANIFEST_PARSING_ERROR="manifestParsingError",M.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",M.LEVEL_EMPTY_ERROR="levelEmptyError",M.LEVEL_LOAD_ERROR="levelLoadError",M.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",M.LEVEL_SWITCH_ERROR="levelSwitchError",M.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",M.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",M.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",M.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",M.FRAG_LOAD_ERROR="fragLoadError",M.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",M.FRAG_DECRYPT_ERROR="fragDecryptError",M.FRAG_PARSING_ERROR="fragParsingError",M.REMUX_ALLOC_ERROR="remuxAllocError",M.KEY_LOAD_ERROR="keyLoadError",M.KEY_LOAD_TIMEOUT="keyLoadTimeOut",M.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",M.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",M.BUFFER_APPEND_ERROR="bufferAppendError",M.BUFFER_APPENDING_ERROR="bufferAppendingError",M.BUFFER_STALLED_ERROR="bufferStalledError",M.BUFFER_FULL_ERROR="bufferFullError",M.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",M.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",M.INTERNAL_EXCEPTION="internalException",M.INTERNAL_ABORTED="aborted",M.UNKNOWN="unknown"})(N||(N={}))},"./src/events.ts":function(ne,$,_){"use strict";_.r($),_.d($,"Events",function(){return V});var V;(function(N){N.MEDIA_ATTACHING="hlsMediaAttaching",N.MEDIA_ATTACHED="hlsMediaAttached",N.MEDIA_DETACHING="hlsMediaDetaching",N.MEDIA_DETACHED="hlsMediaDetached",N.BUFFER_RESET="hlsBufferReset",N.BUFFER_CODECS="hlsBufferCodecs",N.BUFFER_CREATED="hlsBufferCreated",N.BUFFER_APPENDING="hlsBufferAppending",N.BUFFER_APPENDED="hlsBufferAppended",N.BUFFER_EOS="hlsBufferEos",N.BUFFER_FLUSHING="hlsBufferFlushing",N.BUFFER_FLUSHED="hlsBufferFlushed",N.MANIFEST_LOADING="hlsManifestLoading",N.MANIFEST_LOADED="hlsManifestLoaded",N.MANIFEST_PARSED="hlsManifestParsed",N.LEVEL_SWITCHING="hlsLevelSwitching",N.LEVEL_SWITCHED="hlsLevelSwitched",N.LEVEL_LOADING="hlsLevelLoading",N.LEVEL_LOADED="hlsLevelLoaded",N.LEVEL_UPDATED="hlsLevelUpdated",N.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",N.LEVELS_UPDATED="hlsLevelsUpdated",N.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",N.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",N.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",N.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",N.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",N.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",N.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",N.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",N.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",N.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",N.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",N.CUES_PARSED="hlsCuesParsed",N.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",N.INIT_PTS_FOUND="hlsInitPtsFound",N.FRAG_LOADING="hlsFragLoading",N.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",N.FRAG_LOADED="hlsFragLoaded",N.FRAG_DECRYPTED="hlsFragDecrypted",N.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",N.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",N.FRAG_PARSING_METADATA="hlsFragParsingMetadata",N.FRAG_PARSED="hlsFragParsed",N.FRAG_BUFFERED="hlsFragBuffered",N.FRAG_CHANGED="hlsFragChanged",N.FPS_DROP="hlsFpsDrop",N.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",N.ERROR="hlsError",N.DESTROYING="hlsDestroying",N.KEY_LOADING="hlsKeyLoading",N.KEY_LOADED="hlsKeyLoaded",N.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",N.BACK_BUFFER_REACHED="hlsBackBufferReached"})(V||(V={}))},"./src/hls.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return g});var V=_("./node_modules/url-toolkit/src/url-toolkit.js"),N=_.n(V),M=_("./src/loader/playlist-loader.ts"),H=_("./src/loader/key-loader.ts"),F=_("./src/controller/id3-track-controller.ts"),P=_("./src/controller/latency-controller.ts"),O=_("./src/controller/level-controller.ts"),b=_("./src/controller/fragment-tracker.ts"),A=_("./src/controller/stream-controller.ts"),D=_("./src/is-supported.ts"),L=_("./src/utils/logger.ts"),w=_("./src/config.ts"),x=_("./node_modules/eventemitter3/index.js"),u=_.n(x),a=_("./src/events.ts"),l=_("./src/errors.ts");function h(m,k){for(var v=0;v<k.length;v++){var f=k[v];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(m,f.key,f)}}function C(m,k,v){return k&&h(m.prototype,k),v&&h(m,v),m}var g=function(){m.isSupported=function(){return Object(D.isSupported)()};function m(v){v===void 0&&(v={}),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(w.mergeConfig)(m.DefaultConfig,v);this.userConfig=v,Object(L.enableLogs)(f.debug),this._autoLevelCapping=-1,f.progressive&&Object(w.enableStreamingMode)(f);var p=f.abrController,d=f.bufferController,o=f.capLevelController,S=f.fpsController,y=this.abrController=new p(this),T=this.bufferController=new d(this),I=this.capLevelController=new o(this),G=new S(this),X=new M.default(this),Q=new H.default(this),z=new F.default(this),W=this.levelController=new O.default(this),ee=new b.FragmentTracker(this),ae=this.streamController=new A.default(this,ee);I.setStreamController(ae),G.setStreamController(ae);var pe=[W,ae];this.networkControllers=pe;var ve=[X,Q,y,T,I,G,z,ee];this.audioTrackController=this.createController(f.audioTrackController,null,pe),this.createController(f.audioStreamController,ee,pe),this.subtitleTrackController=this.createController(f.subtitleTrackController,null,pe),this.createController(f.subtitleStreamController,ee,pe),this.createController(f.timelineController,null,ve),this.emeController=this.createController(f.emeController,null,ve),this.cmcdController=this.createController(f.cmcdController,null,ve),this.latencyController=this.createController(P.default,null,ve),this.coreComponents=ve}var k=m.prototype;return k.createController=function(f,p,d){if(f){var o=p?new f(this,p):new f(this);return d&&d.push(o),o}return null},k.on=function(f,p,d){d===void 0&&(d=this),this._emitter.on(f,p,d)},k.once=function(f,p,d){d===void 0&&(d=this),this._emitter.once(f,p,d)},k.removeAllListeners=function(f){this._emitter.removeAllListeners(f)},k.off=function(f,p,d,o){d===void 0&&(d=this),this._emitter.off(f,p,d,o)},k.listeners=function(f){return this._emitter.listeners(f)},k.emit=function(f,p,d){return this._emitter.emit(f,p,d)},k.trigger=function(f,p){if(this.config.debug)return this.emit(f,f,p);try{return this.emit(f,f,p)}catch(d){L.logger.error("An internal error happened while handling event "+f+'. Error message: "'+d.message+'". Here is a stacktrace:',d),this.trigger(a.Events.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:f,error:d})}return!1},k.listenerCount=function(f){return this._emitter.listenerCount(f)},k.destroy=function(){L.logger.log("destroy"),this.trigger(a.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(f){return f.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(f){return f.destroy()}),this.coreComponents.length=0},k.attachMedia=function(f){L.logger.log("attachMedia"),this._media=f,this.trigger(a.Events.MEDIA_ATTACHING,{media:f})},k.detachMedia=function(){L.logger.log("detachMedia"),this.trigger(a.Events.MEDIA_DETACHING,void 0),this._media=null},k.loadSource=function(f){this.stopLoad();var p=this.media,d=this.url,o=this.url=V.buildAbsoluteURL(self.location.href,f,{alwaysNormalize:!0});L.logger.log("loadSource:"+o),p&&d&&d!==o&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(p)),this.trigger(a.Events.MANIFEST_LOADING,{url:f})},k.startLoad=function(f){f===void 0&&(f=-1),L.logger.log("startLoad("+f+")"),this.networkControllers.forEach(function(p){p.startLoad(f)})},k.stopLoad=function(){L.logger.log("stopLoad"),this.networkControllers.forEach(function(f){f.stopLoad()})},k.swapAudioCodec=function(){L.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},k.recoverMediaError=function(){L.logger.log("recoverMediaError");var f=this._media;this.detachMedia(),f&&this.attachMedia(f)},k.removeLevel=function(f,p){p===void 0&&(p=0),this.levelController.removeLevel(f,p)},C(m,[{key:"levels",get:function(){var f=this.levelController.levels;return f||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(f){L.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){L.logger.log("set nextLevel:"+f),this.levelController.manualLevel=f,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(f){L.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){L.logger.log("set firstLevel:"+f),this.levelController.firstLevel=f}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(f){L.logger.log("set startLevel:"+f),f!==-1&&(f=Math.max(f,this.minAutoLevel)),this.levelController.startLevel=f}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(f){var p=!!f;p!==this.config.capLevelToPlayerSize&&(p?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=p)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(f){this._autoLevelCapping!==f&&(L.logger.log("set autoLevelCapping:"+f),this._autoLevelCapping=f)}},{key:"bandwidthEstimate",get:function(){var f=this.abrController.bwEstimator;return f?f.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var f=this.levels,p=this.config.minAutoBitrate;if(!f)return 0;for(var d=f.length,o=0;o<d;o++)if(f[o].maxBitrate>p)return o;return 0}},{key:"maxAutoLevel",get:function(){var f=this.levels,p=this.autoLevelCapping,d;return p===-1&&f&&f.length?d=f.length-1:d=p,d}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(f){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,f)}},{key:"audioTracks",get:function(){var f=this.audioTrackController;return f?f.audioTracks:[]}},{key:"audioTrack",get:function(){var f=this.audioTrackController;return f?f.audioTrack:-1},set:function(f){var p=this.audioTrackController;p&&(p.audioTrack=f)}},{key:"subtitleTracks",get:function(){var f=this.subtitleTrackController;return f?f.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var f=this.subtitleTrackController;return f?f.subtitleTrack:-1},set:function(f){var p=this.subtitleTrackController;p&&(p.subtitleTrack=f)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var f=this.subtitleTrackController;return f?f.subtitleDisplay:!1},set:function(f){var p=this.subtitleTrackController;p&&(p.subtitleDisplay=f)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(f){this.config.lowLatencyMode=f}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return a.Events}},{key:"ErrorTypes",get:function(){return l.ErrorTypes}},{key:"ErrorDetails",get:function(){return l.ErrorDetails}},{key:"DefaultConfig",get:function(){return m.defaultConfig?m.defaultConfig:w.hlsDefaultConfig},set:function(f){m.defaultConfig=f}}]),m}();g.defaultConfig=void 0},"./src/is-supported.ts":function(ne,$,_){"use strict";_.r($),_.d($,"isSupported",function(){return M}),_.d($,"changeTypeSupported",function(){return H});var V=_("./src/utils/mediasource-helper.ts");function N(){return self.SourceBuffer||self.WebKitSourceBuffer}function M(){var F=Object(V.getMediaSource)();if(!F)return!1;var P=N(),O=F&&typeof F.isTypeSupported=="function"&&F.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),b=!P||P.prototype&&typeof P.prototype.appendBuffer=="function"&&typeof P.prototype.remove=="function";return!!O&&!!b}function H(){var F,P=N();return typeof(P==null||((F=P.prototype)===null||F===void 0)?void 0:F.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return L}),_.d($,"LoadError",function(){return x});var V=_("./src/polyfills/number.ts"),N=_("./src/errors.ts");function M(u,a){u.prototype=Object.create(a.prototype),u.prototype.constructor=u,b(u,a)}function H(u){var a=typeof Map=="function"?new Map:void 0;return H=function(h){if(h===null||!O(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a!="undefined"){if(a.has(h))return a.get(h);a.set(h,C)}function C(){return F(h,arguments,A(this).constructor)}return C.prototype=Object.create(h.prototype,{constructor:{value:C,enumerable:!1,writable:!0,configurable:!0}}),b(C,h)},H(u)}function F(u,a,l){return P()?F=Reflect.construct:F=function(C,g,m){var k=[null];k.push.apply(k,g);var v=Function.bind.apply(C,k),f=new v;return m&&b(f,m.prototype),f},F.apply(null,arguments)}function P(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(u){return!1}}function O(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function b(u,a){return b=Object.setPrototypeOf||function(h,C){return h.__proto__=C,h},b(u,a)}function A(u){return A=Object.setPrototypeOf?Object.getPrototypeOf:function(l){return l.__proto__||Object.getPrototypeOf(l)},A(u)}var D=Math.pow(2,17),L=function(){function u(l){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=l}var a=u.prototype;return a.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},a.abort=function(){this.loader&&this.loader.abort()},a.load=function(h,C){var g=this,m=h.url;if(!m)return Promise.reject(new x({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,networkDetails:null},"Fragment does not have a "+(m?"part list":"url")));this.abort();var k=this.config,v=k.fLoader,f=k.loader;return new Promise(function(p,d){g.loader&&g.loader.destroy();var o=g.loader=h.loader=v?new v(k):new f(k),S=w(h),y={timeout:k.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:k.fragLoadingMaxRetryTimeout,highWaterMark:D};h.stats=o.stats,o.load(S,y,{onSuccess:function(I,G,X,Q){g.resetLoader(h,o),p({frag:h,part:null,payload:I.data,networkDetails:Q})},onError:function(I,G,X){g.resetLoader(h,o),d(new x({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,response:I,networkDetails:X}))},onAbort:function(I,G,X){g.resetLoader(h,o),d(new x({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,networkDetails:X}))},onTimeout:function(I,G,X){g.resetLoader(h,o),d(new x({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,networkDetails:X}))},onProgress:function(I,G,X,Q){C&&C({frag:h,part:null,payload:X,networkDetails:Q})}})})},a.loadPart=function(h,C,g){var m=this;this.abort();var k=this.config,v=k.fLoader,f=k.loader;return new Promise(function(p,d){m.loader&&m.loader.destroy();var o=m.loader=h.loader=v?new v(k):new f(k),S=w(h,C),y={timeout:k.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:k.fragLoadingMaxRetryTimeout,highWaterMark:D};C.stats=o.stats,o.load(S,y,{onSuccess:function(I,G,X,Q){m.resetLoader(h,o),m.updateStatsFromPart(h,C);var z={frag:h,part:C,payload:I.data,networkDetails:Q};g(z),p(z)},onError:function(I,G,X){m.resetLoader(h,o),d(new x({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,part:C,response:I,networkDetails:X}))},onAbort:function(I,G,X){h.stats.aborted=C.stats.aborted,m.resetLoader(h,o),d(new x({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,part:C,networkDetails:X}))},onTimeout:function(I,G,X){m.resetLoader(h,o),d(new x({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,part:C,networkDetails:X}))}})})},a.updateStatsFromPart=function(h,C){var g=h.stats,m=C.stats,k=m.total;if(g.loaded+=m.loaded,k){var v=Math.round(h.duration/C.duration),f=Math.min(Math.round(g.loaded/k),v),p=v-f,d=p*Math.round(g.loaded/f);g.total=g.loaded+d}else g.total=Math.max(g.loaded,g.total);var o=g.loading,S=m.loading;o.start?o.first+=S.first-S.start:(o.start=S.start,o.first=S.first),o.end=S.end},a.resetLoader=function(h,C){h.loader=null,this.loader===C&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),C.destroy()},u}();function w(u,a){a===void 0&&(a=null);var l=a||u,h={frag:u,part:a,responseType:"arraybuffer",url:l.url,headers:{},rangeStart:0,rangeEnd:0},C=l.byteRangeStartOffset,g=l.byteRangeEndOffset;return Object(V.isFiniteNumber)(C)&&Object(V.isFiniteNumber)(g)&&(h.rangeStart=C,h.rangeEnd=g),h}var x=function(u){M(a,u);function a(l){for(var h,C=arguments.length,g=new Array(C>1?C-1:0),m=1;m<C;m++)g[m-1]=arguments[m];return h=u.call.apply(u,[this].concat(g))||this,h.data=void 0,h.data=l,h}return a}(H(Error))},"./src/loader/fragment.ts":function(ne,$,_){"use strict";_.r($),_.d($,"ElementaryStreamTypes",function(){return L}),_.d($,"BaseSegment",function(){return w}),_.d($,"Fragment",function(){return x}),_.d($,"Part",function(){return u});var V=_("./src/polyfills/number.ts"),N=_("./node_modules/url-toolkit/src/url-toolkit.js"),M=_.n(N),H=_("./src/utils/logger.ts"),F=_("./src/loader/level-key.ts"),P=_("./src/loader/load-stats.ts");function O(a,l){a.prototype=Object.create(l.prototype),a.prototype.constructor=a,b(a,l)}function b(a,l){return b=Object.setPrototypeOf||function(C,g){return C.__proto__=g,C},b(a,l)}function A(a,l){for(var h=0;h<l.length;h++){var C=l[h];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(a,C.key,C)}}function D(a,l,h){return l&&A(a.prototype,l),h&&A(a,h),a}var L;(function(a){a.AUDIO="audio",a.VIDEO="video",a.AUDIOVIDEO="audiovideo"})(L||(L={}));var w=function(){function a(h){var C;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(C={},C[L.AUDIO]=null,C[L.VIDEO]=null,C[L.AUDIOVIDEO]=null,C),this.baseurl=h}var l=a.prototype;return l.setByteRange=function(C,g){var m=C.split("@",2),k=[];m.length===1?k[0]=g?g.byteRangeEndOffset:0:k[0]=parseInt(m[1]),k[1]=parseInt(m[0])+k[0],this._byteRange=k},D(a,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(N.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(C){this._url=C}}]),a}(),x=function(a){O(l,a);function l(C,g){var m;return m=a.call(this,g)||this,m._decryptdata=null,m.rawProgramDateTime=null,m.programDateTime=null,m.tagList=[],m.duration=0,m.sn=0,m.levelkey=void 0,m.type=void 0,m.loader=null,m.level=-1,m.cc=0,m.startPTS=void 0,m.endPTS=void 0,m.appendedPTS=void 0,m.startDTS=void 0,m.endDTS=void 0,m.start=0,m.deltaPTS=void 0,m.maxStartPTS=void 0,m.minEndPTS=void 0,m.stats=new P.LoadStats,m.urlId=0,m.data=void 0,m.bitrateTest=!1,m.title=null,m.initSegment=null,m.type=C,m}var h=l.prototype;return h.createInitializationVector=function(g){for(var m=new Uint8Array(16),k=12;k<16;k++)m[k]=g>>8*(15-k)&255;return m},h.setDecryptDataFromLevelKey=function(g,m){var k=g;return(g==null?void 0:g.method)==="AES-128"&&g.uri&&!g.iv&&(k=F.LevelKey.fromURI(g.uri),k.method=g.method,k.iv=this.createInitializationVector(m),k.keyFormat="identity"),k},h.setElementaryStreamInfo=function(g,m,k,v,f,p){p===void 0&&(p=!1);var d=this.elementaryStreams,o=d[g];if(!o){d[g]={startPTS:m,endPTS:k,startDTS:v,endDTS:f,partial:p};return}o.startPTS=Math.min(o.startPTS,m),o.endPTS=Math.max(o.endPTS,k),o.startDTS=Math.min(o.startDTS,v),o.endDTS=Math.max(o.endDTS,f)},h.clearElementaryStreamInfo=function(){var g=this.elementaryStreams;g[L.AUDIO]=null,g[L.VIDEO]=null,g[L.AUDIOVIDEO]=null},D(l,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var g=this.sn;typeof g!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&H.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),g=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,g)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(V.isFiniteNumber)(this.programDateTime))return null;var g=Object(V.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+g*1e3}},{key:"encrypted",get:function(){var g;return!!((g=this.decryptdata)!==null&&g!==void 0&&g.keyFormat&&this.decryptdata.uri)}}]),l}(w),u=function(a){O(l,a);function l(h,C,g,m,k){var v;v=a.call(this,g)||this,v.fragOffset=0,v.duration=0,v.gap=!1,v.independent=!1,v.relurl=void 0,v.fragment=void 0,v.index=void 0,v.stats=new P.LoadStats,v.duration=h.decimalFloatingPoint("DURATION"),v.gap=h.bool("GAP"),v.independent=h.bool("INDEPENDENT"),v.relurl=h.enumeratedString("URI"),v.fragment=C,v.index=m;var f=h.enumeratedString("BYTERANGE");return f&&v.setByteRange(f,k),k&&(v.fragOffset=k.fragOffset+k.duration),v}return D(l,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var C=this.elementaryStreams;return!!(C.audio||C.video||C.audiovideo)}}]),l}(w)},"./src/loader/key-loader.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return H});var V=_("./src/events.ts"),N=_("./src/errors.ts"),M=_("./src/utils/logger.ts"),H=function(){function F(O){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=O,this._registerListeners()}var P=F.prototype;return P._registerListeners=function(){this.hls.on(V.Events.KEY_LOADING,this.onKeyLoading,this)},P._unregisterListeners=function(){this.hls.off(V.Events.KEY_LOADING,this.onKeyLoading)},P.destroy=function(){this._unregisterListeners();for(var b in this.loaders){var A=this.loaders[b];A&&A.destroy()}this.loaders={}},P.onKeyLoading=function(b,A){var D=A.frag,L=D.type,w=this.loaders[L];if(!D.decryptdata){M.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var x=D.decryptdata.uri;if(x!==this.decrypturl||this.decryptkey===null){var u=this.hls.config;if(w&&(M.logger.warn("abort previous key loader for type:"+L),w.abort()),!x){M.logger.warn("key uri is falsy");return}var a=u.loader,l=D.loader=this.loaders[L]=new a(u);this.decrypturl=x,this.decryptkey=null;var h={url:x,frag:D,responseType:"arraybuffer"},C={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:u.fragLoadingRetryDelay,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:0},g={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};l.load(h,C,g)}else this.decryptkey&&(D.decryptdata.key=this.decryptkey,this.hls.trigger(V.Events.KEY_LOADED,{frag:D}))},P.loadsuccess=function(b,A,D){var L=D.frag;if(!L.decryptdata){M.logger.error("after key load, decryptdata unset");return}this.decryptkey=L.decryptdata.key=new Uint8Array(b.data),L.loader=null,delete this.loaders[L.type],this.hls.trigger(V.Events.KEY_LOADED,{frag:L})},P.loaderror=function(b,A){var D=A.frag,L=D.loader;L&&L.abort(),delete this.loaders[D.type],this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:D,response:b})},P.loadtimeout=function(b,A){var D=A.frag,L=D.loader;L&&L.abort(),delete this.loaders[D.type],this.hls.trigger(V.Events.ERROR,{type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:D})},F}()},"./src/loader/level-details.ts":function(ne,$,_){"use strict";_.r($),_.d($,"LevelDetails",function(){return F});var V=_("./src/polyfills/number.ts");function N(P,O){for(var b=0;b<O.length;b++){var A=O[b];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(P,A.key,A)}}function M(P,O,b){return O&&N(P.prototype,O),b&&N(P,b),P}var H=10,F=function(){function P(b){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.url=b}var O=P.prototype;return O.reloaded=function(A){if(!A){this.advanced=!0,this.updated=!0;return}var D=this.lastPartSn-A.lastPartSn,L=this.lastPartIndex-A.lastPartIndex;this.updated=this.endSN!==A.endSN||!!L||!!D,this.advanced=this.endSN>A.endSN||D>0||D===0&&L>0,this.updated||this.advanced?this.misses=Math.floor(A.misses*.6):this.misses=A.misses+1,this.availabilityDelay=A.availabilityDelay},M(P,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(V.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||H}},{key:"drift",get:function(){var A=this.driftEndTime-this.driftStartTime;if(A>0){var D=this.driftEnd-this.driftStart;return D*1e3/A}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var A;return(A=this.fragments)!==null&&A!==void 0&&A.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 A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),P}()},"./src/loader/level-key.ts":function(ne,$,_){"use strict";_.r($),_.d($,"LevelKey",function(){return F});var V=_("./node_modules/url-toolkit/src/url-toolkit.js"),N=_.n(V);function M(P,O){for(var b=0;b<O.length;b++){var A=O[b];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(P,A.key,A)}}function H(P,O,b){return O&&M(P.prototype,O),b&&M(P,b),P}var F=function(){P.fromURL=function(b,A){return new P(b,A)},P.fromURI=function(b){return new P(b)};function P(O,b){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,b?this._uri=Object(V.buildAbsoluteURL)(O,b,{alwaysNormalize:!0}):this._uri=O}return H(P,[{key:"uri",get:function(){return this._uri}}]),P}()},"./src/loader/load-stats.ts":function(ne,$,_){"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(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return l});var V=_("./src/polyfills/number.ts"),N=_("./node_modules/url-toolkit/src/url-toolkit.js"),M=_.n(N),H=_("./src/loader/fragment.ts"),F=_("./src/loader/level-details.ts"),P=_("./src/loader/level-key.ts"),O=_("./src/utils/attr-list.ts"),b=_("./src/utils/logger.ts"),A=_("./src/utils/codecs.ts"),D=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,L=/#EXT-X-MEDIA:(.*)/g,w=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),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("|")),u=/\.(mp4|m4s|m4v|m4a)$/i;function a(k){var v,f;return u.test((v=(f=N.parseURL(k))===null||f===void 0?void 0:f.path)!=null?v:"")}var l=function(){function k(){}return k.findGroup=function(f,p){for(var d=0;d<f.length;d++){var o=f[d];if(o.id===p)return o}},k.convertAVC1ToAVCOTI=function(f){var p=f.split(".");if(p.length>2){var d=p.shift()+".";return d+=parseInt(p.shift()).toString(16),d+=("000"+parseInt(p.shift()).toString(16)).substr(-4),d}return f},k.resolve=function(f,p){return N.buildAbsoluteURL(p,f,{alwaysNormalize:!0})},k.parseMasterPlaylist=function(f,p){var d=[],o={},S=!1;D.lastIndex=0;for(var y;(y=D.exec(f))!=null;)if(y[1]){var T=new O.AttrList(y[1]),I={attrs:T,bitrate:T.decimalInteger("AVERAGE-BANDWIDTH")||T.decimalInteger("BANDWIDTH"),name:T.NAME,url:k.resolve(y[2],p)},G=T.decimalResolution("RESOLUTION");G&&(I.width=G.width,I.height=G.height),h((T.CODECS||"").split(/[ ,]+/).filter(function(Q){return Q}),I),I.videoCodec&&I.videoCodec.indexOf("avc1")!==-1&&(I.videoCodec=k.convertAVC1ToAVCOTI(I.videoCodec)),d.push(I)}else if(y[3]){var X=new O.AttrList(y[3]);X["DATA-ID"]&&(S=!0,o[X["DATA-ID"]]=X)}return{levels:d,sessionData:S?o:null}},k.parseMasterPlaylistMedia=function(f,p,d,o){o===void 0&&(o=[]);var S,y=[],T=0;for(L.lastIndex=0;(S=L.exec(f))!==null;){var I=new O.AttrList(S[1]);if(I.TYPE===d){var G={attrs:I,bitrate:0,id:T++,groupId:I["GROUP-ID"],instreamId:I["INSTREAM-ID"],name:I.NAME||I.LANGUAGE||"",type:d,default:I.bool("DEFAULT"),autoselect:I.bool("AUTOSELECT"),forced:I.bool("FORCED"),lang:I.LANGUAGE,url:I.URI?k.resolve(I.URI,p):""};if(o.length){var X=k.findGroup(o,G.groupId)||o[0];C(G,X,"audioCodec"),C(G,X,"textCodec")}y.push(G)}}return y},k.parseLevelPlaylist=function(f,p,d,o,S){var y=new F.LevelDetails(p),T=y.fragments,I=null,G=0,X=0,Q=0,z=0,W=null,ee=new H.Fragment(o,p),ae,pe,ve,De=-1,xe=!1;for(w.lastIndex=0,y.m3u8=f;(ae=w.exec(f))!==null;){xe&&(xe=!1,ee=new H.Fragment(o,p),ee.start=Q,ee.sn=G,ee.cc=z,ee.level=d,I&&(ee.initSegment=I,ee.rawProgramDateTime=I.rawProgramDateTime));var Ce=ae[1];if(Ce){ee.duration=parseFloat(Ce);var Ae=(" "+ae[2]).slice(1);ee.title=Ae||null,ee.tagList.push(Ae?["INF",Ce,Ae]:["INF",Ce])}else if(ae[3])Object(V.isFiniteNumber)(ee.duration)&&(ee.start=Q,ve&&(ee.levelkey=ve),ee.sn=G,ee.level=d,ee.cc=z,ee.urlId=S,T.push(ee),ee.relurl=(" "+ae[3]).slice(1),m(ee,W),W=ee,Q+=ee.duration,G++,X=0,xe=!0);else if(ae[4]){var Se=(" "+ae[4]).slice(1);W?ee.setByteRange(Se,W):ee.setByteRange(Se)}else if(ae[5])ee.rawProgramDateTime=(" "+ae[5]).slice(1),ee.tagList.push(["PROGRAM-DATE-TIME",ee.rawProgramDateTime]),De===-1&&(De=T.length);else{if(ae=ae[0].match(x),!ae){b.logger.warn("No matches on slow regex match for level playlist!");continue}for(pe=1;pe<ae.length&&!(typeof ae[pe]!="undefined");pe++);var ge=(" "+ae[pe]).slice(1),oe=(" "+ae[pe+1]).slice(1),Re=ae[pe+2]?(" "+ae[pe+2]).slice(1):"";switch(ge){case"PLAYLIST-TYPE":y.type=oe.toUpperCase();break;case"MEDIA-SEQUENCE":G=y.startSN=parseInt(oe);break;case"SKIP":{var Ze=new O.AttrList(oe),He=Ze.decimalInteger("SKIPPED-SEGMENTS");if(Object(V.isFiniteNumber)(He)){y.skippedSegments=He;for(var Ge=He;Ge--;)T.unshift(null);G+=He}var $e=Ze.enumeratedString("RECENTLY-REMOVED-DATERANGES");$e&&(y.recentlyRemovedDateranges=$e.split(" "));break}case"TARGETDURATION":y.targetduration=parseFloat(oe);break;case"VERSION":y.version=parseInt(oe);break;case"EXTM3U":break;case"ENDLIST":y.live=!1;break;case"#":(oe||Re)&&ee.tagList.push(Re?[oe,Re]:[oe]);break;case"DIS":z++;case"GAP":ee.tagList.push([ge]);break;case"BITRATE":ee.tagList.push([ge,oe]);break;case"DISCONTINUITY-SEQ":z=parseInt(oe);break;case"KEY":{var _e,Ie=new O.AttrList(oe),We=Ie.enumeratedString("METHOD"),Ve=Ie.URI,ze=Ie.hexadecimalInteger("IV"),Be=Ie.enumeratedString("KEYFORMATVERSIONS"),Fe=Ie.enumeratedString("KEYID"),ot=(_e=Ie.enumeratedString("KEYFORMAT"))!=null?_e:"identity",it=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(it.indexOf(ot)>-1){b.logger.warn("Keyformat "+ot+" is not supported from the manifest");continue}else if(ot!=="identity")continue;We&&(ve=P.LevelKey.fromURL(p,Ve),Ve&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(We)>=0&&(ve.method=We,ve.keyFormat=ot,Fe&&(ve.keyID=Fe),Be&&(ve.keyFormatVersions=Be),ve.iv=ze));break}case"START":{var Je=new O.AttrList(oe),qe=Je.decimalFloatingPoint("TIME-OFFSET");Object(V.isFiniteNumber)(qe)&&(y.startTimeOffset=qe);break}case"MAP":{var ct=new O.AttrList(oe);ee.relurl=ct.URI,ct.BYTERANGE&&ee.setByteRange(ct.BYTERANGE),ee.level=d,ee.sn="initSegment",ve&&(ee.levelkey=ve),ee.initSegment=null,I=ee,xe=!0;break}case"SERVER-CONTROL":{var et=new O.AttrList(oe);y.canBlockReload=et.bool("CAN-BLOCK-RELOAD"),y.canSkipUntil=et.optionalFloat("CAN-SKIP-UNTIL",0),y.canSkipDateRanges=y.canSkipUntil>0&&et.bool("CAN-SKIP-DATERANGES"),y.partHoldBack=et.optionalFloat("PART-HOLD-BACK",0),y.holdBack=et.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Qe=new O.AttrList(oe);y.partTarget=Qe.decimalFloatingPoint("PART-TARGET");break}case"PART":{var we=y.partList;we||(we=y.partList=[]);var lt=X>0?we[we.length-1]:void 0,tt=X++,Te=new H.Part(new O.AttrList(oe),ee,p,tt,lt);we.push(Te),ee.duration+=Te.duration;break}case"PRELOAD-HINT":{var Le=new O.AttrList(oe);y.preloadHint=Le;break}case"RENDITION-REPORT":{var fe=new O.AttrList(oe);y.renditionReports=y.renditionReports||[],y.renditionReports.push(fe);break}default:b.logger.warn("line parsed but not handled: "+ae);break}}}W&&!W.relurl?(T.pop(),Q-=W.duration,y.partList&&(y.fragmentHint=W)):y.partList&&(m(ee,W),ee.cc=z,y.fragmentHint=ee);var le=T.length,ue=T[0],q=T[le-1];if(Q+=y.skippedSegments*y.targetduration,Q>0&&le&&q){y.averagetargetduration=Q/le;var te=q.sn;y.endSN=te!=="initSegment"?te:0,ue&&(y.startCC=ue.cc,ue.initSegment||y.fragments.every(function(ie){return ie.relurl&&a(ie.relurl)})&&(b.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),ee=new H.Fragment(o,p),ee.relurl=q.relurl,ee.level=d,ee.sn="initSegment",ue.initSegment=ee,y.needSidxRanges=!0))}else y.endSN=0,y.startCC=0;return y.fragmentHint&&(Q+=y.fragmentHint.duration),y.totalduration=Q,y.endCC=z,De>0&&g(T,De),y},k}();function h(k,v){["video","audio","text"].forEach(function(f){var p=k.filter(function(o){return Object(A.isCodecType)(o,f)});if(p.length){var d=p.filter(function(o){return o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0});v[f+"Codec"]=d.length>0?d[0]:p[0],k=k.filter(function(o){return p.indexOf(o)===-1})}}),v.unknownCodecs=k}function C(k,v,f){var p=v[f];p&&(k[f]=p)}function g(k,v){for(var f=k[v],p=v;p--;){var d=k[p];if(!d)return;d.programDateTime=f.programDateTime-d.duration*1e3,f=d}}function m(k,v){k.rawProgramDateTime?k.programDateTime=Date.parse(k.rawProgramDateTime):v!=null&&v.programDateTime&&(k.programDateTime=v.endProgramDateTime),Object(V.isFiniteNumber)(k.programDateTime)||(k.programDateTime=null,k.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/polyfills/number.ts"),N=_("./src/events.ts"),M=_("./src/errors.ts"),H=_("./src/utils/logger.ts"),F=_("./src/utils/mp4-tools.ts"),P=_("./src/loader/m3u8-parser.ts"),O=_("./src/types/loader.ts"),b=_("./src/utils/attr-list.ts");function A(w){var x=w.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 D(w,x){var u=w.url;return(u===void 0||u.indexOf("data:")===0)&&(u=x.url),u}var L=function(){function w(u){this.hls=void 0,this.loaders=Object.create(null),this.hls=u,this.registerListeners()}var x=w.prototype;return x.registerListeners=function(){var a=this.hls;a.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(N.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(N.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.on(N.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},x.unregisterListeners=function(){var a=this.hls;a.off(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(N.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(N.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.off(N.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},x.createInternalLoader=function(a){var l=this.hls.config,h=l.pLoader,C=l.loader,g=h||C,m=new g(l);return a.loader=m,this.loaders[a.type]=m,m},x.getInternalLoader=function(a){return this.loaders[a.type]},x.resetInternalLoader=function(a){this.loaders[a]&&delete this.loaders[a]},x.destroyInternalLoaders=function(){for(var a in this.loaders){var l=this.loaders[a];l&&l.destroy(),this.resetInternalLoader(a)}},x.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},x.onManifestLoading=function(a,l){var h=l.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:O.PlaylistContextType.MANIFEST,url:h,deliveryDirectives:null})},x.onLevelLoading=function(a,l){var h=l.id,C=l.level,g=l.url,m=l.deliveryDirectives;this.load({id:h,groupId:null,level:C,responseType:"text",type:O.PlaylistContextType.LEVEL,url:g,deliveryDirectives:m})},x.onAudioTrackLoading=function(a,l){var h=l.id,C=l.groupId,g=l.url,m=l.deliveryDirectives;this.load({id:h,groupId:C,level:null,responseType:"text",type:O.PlaylistContextType.AUDIO_TRACK,url:g,deliveryDirectives:m})},x.onSubtitleTrackLoading=function(a,l){var h=l.id,C=l.groupId,g=l.url,m=l.deliveryDirectives;this.load({id:h,groupId:C,level:null,responseType:"text",type:O.PlaylistContextType.SUBTITLE_TRACK,url:g,deliveryDirectives:m})},x.load=function(a){var l,h=this.hls.config,C=this.getInternalLoader(a);if(C){var g=C.context;if(g&&g.url===a.url){H.logger.trace("[playlist-loader]: playlist request ongoing");return}H.logger.log("[playlist-loader]: aborting previous loader for type: "+a.type),C.abort()}var m,k,v,f;switch(a.type){case O.PlaylistContextType.MANIFEST:m=h.manifestLoadingMaxRetry,k=h.manifestLoadingTimeOut,v=h.manifestLoadingRetryDelay,f=h.manifestLoadingMaxRetryTimeout;break;case O.PlaylistContextType.LEVEL:case O.PlaylistContextType.AUDIO_TRACK:case O.PlaylistContextType.SUBTITLE_TRACK:m=0,k=h.levelLoadingTimeOut;break;default:m=h.levelLoadingMaxRetry,k=h.levelLoadingTimeOut,v=h.levelLoadingRetryDelay,f=h.levelLoadingMaxRetryTimeout;break}if(C=this.createInternalLoader(a),(l=a.deliveryDirectives)!==null&&l!==void 0&&l.part){var p;if(a.type===O.PlaylistContextType.LEVEL&&a.level!==null?p=this.hls.levels[a.level].details:a.type===O.PlaylistContextType.AUDIO_TRACK&&a.id!==null?p=this.hls.audioTracks[a.id].details:a.type===O.PlaylistContextType.SUBTITLE_TRACK&&a.id!==null&&(p=this.hls.subtitleTracks[a.id].details),p){var d=p.partTarget,o=p.targetduration;d&&o&&(k=Math.min(Math.max(d*3,o*.8)*1e3,k))}}var S={timeout:k,maxRetry:m,retryDelay:v,maxRetryDelay:f,highWaterMark:0},y={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};C.load(a,S,y)},x.loadsuccess=function(a,l,h,C){if(C===void 0&&(C=null),h.isSidxRequest){this.handleSidxRequest(a,h),this.handlePlaylistLoaded(a,l,h,C);return}this.resetInternalLoader(h.type);var g=a.data;if(g.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(a,h,"no EXTM3U delimiter",C);return}l.parsing.start=performance.now(),g.indexOf("#EXTINF:")>0||g.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(a,l,h,C):this.handleMasterPlaylist(a,l,h,C)},x.loaderror=function(a,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!1,a)},x.loadtimeout=function(a,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!0)},x.handleMasterPlaylist=function(a,l,h,C){var g=this.hls,m=a.data,k=D(a,h),v=P.default.parseMasterPlaylist(m,k),f=v.levels,p=v.sessionData;if(!f.length){this.handleManifestParsingError(a,h,"no level found in manifest",C);return}var d=f.map(function(G){return{id:G.attrs.AUDIO,audioCodec:G.audioCodec}}),o=f.map(function(G){return{id:G.attrs.SUBTITLES,textCodec:G.textCodec}}),S=P.default.parseMasterPlaylistMedia(m,k,"AUDIO",d),y=P.default.parseMasterPlaylistMedia(m,k,"SUBTITLES",o),T=P.default.parseMasterPlaylistMedia(m,k,"CLOSED-CAPTIONS");if(S.length){var I=S.some(function(G){return!G.url});!I&&f[0].audioCodec&&!f[0].attrs.AUDIO&&(H.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),S.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new b.AttrList({}),bitrate:0,url:""}))}g.trigger(N.Events.MANIFEST_LOADED,{levels:f,audioTracks:S,subtitles:y,captions:T,url:k,stats:l,networkDetails:C,sessionData:p})},x.handleTrackOrLevelPlaylist=function(a,l,h,C){var g=this.hls,m=h.id,k=h.level,v=h.type,f=D(a,h),p=Object(V.isFiniteNumber)(m)?m:0,d=Object(V.isFiniteNumber)(k)?k:p,o=A(h),S=P.default.parseLevelPlaylist(a.data,f,d,o,p);if(!S.fragments.length){g.trigger(N.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.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(v===O.PlaylistContextType.MANIFEST){var y={attrs:new b.AttrList({}),bitrate:0,details:S,name:"",url:f};g.trigger(N.Events.MANIFEST_LOADED,{levels:[y],audioTracks:[],url:f,stats:l,networkDetails:C,sessionData:null})}if(l.parsing.end=performance.now(),S.needSidxRanges){var T,I=(T=S.fragments[0].initSegment)===null||T===void 0?void 0:T.url;this.load({url:I,isSidxRequest:!0,type:v,level:k,levelDetails:S,id:m,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}h.levelDetails=S,this.handlePlaylistLoaded(a,l,h,C)},x.handleSidxRequest=function(a,l){var h=Object(F.parseSegmentIndex)(new Uint8Array(a.data));if(!h)return;var C=h.references,g=l.levelDetails;C.forEach(function(m,k){var v=m.info,f=g.fragments[k];f.byteRange.length===0&&f.setByteRange(String(1+v.end-v.start)+"@"+String(v.start)),f.initSegment&&f.initSegment.setByteRange(String(h.moovEndOffset)+"@0")})},x.handleManifestParsingError=function(a,l,h,C){this.hls.trigger(N.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:l.type===O.PlaylistContextType.MANIFEST,url:a.url,reason:h,response:a,context:l,networkDetails:C})},x.handleNetworkError=function(a,l,h,C){h===void 0&&(h=!1),H.logger.warn("[playlist-loader]: A network "+(h?"timeout":"error")+" occurred while loading "+a.type+" level: "+a.level+" id: "+a.id+' group-id: "'+a.groupId+'"');var g=M.ErrorDetails.UNKNOWN,m=!1,k=this.getInternalLoader(a);switch(a.type){case O.PlaylistContextType.MANIFEST:g=h?M.ErrorDetails.MANIFEST_LOAD_TIMEOUT:M.ErrorDetails.MANIFEST_LOAD_ERROR,m=!0;break;case O.PlaylistContextType.LEVEL:g=h?M.ErrorDetails.LEVEL_LOAD_TIMEOUT:M.ErrorDetails.LEVEL_LOAD_ERROR,m=!1;break;case O.PlaylistContextType.AUDIO_TRACK:g=h?M.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:M.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,m=!1;break;case O.PlaylistContextType.SUBTITLE_TRACK:g=h?M.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:M.ErrorDetails.SUBTITLE_LOAD_ERROR,m=!1;break}k&&this.resetInternalLoader(a.type);var v={type:M.ErrorTypes.NETWORK_ERROR,details:g,fatal:m,url:a.url,loader:k,context:a,networkDetails:l};C&&(v.response=C),this.hls.trigger(N.Events.ERROR,v)},x.handlePlaylistLoaded=function(a,l,h,C){var g=h.type,m=h.level,k=h.id,v=h.groupId,f=h.loader,p=h.levelDetails,d=h.deliveryDirectives;if(!(p!=null&&p.targetduration)){this.handleManifestParsingError(a,h,"invalid target duration",C);return}if(!f)return;p.live&&(f.getCacheAge&&(p.ageHeader=f.getCacheAge()||0),(!f.getCacheAge||isNaN(p.ageHeader))&&(p.ageHeader=0));switch(g){case O.PlaylistContextType.MANIFEST:case O.PlaylistContextType.LEVEL:this.hls.trigger(N.Events.LEVEL_LOADED,{details:p,level:m||0,id:k||0,stats:l,networkDetails:C,deliveryDirectives:d});break;case O.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(N.Events.AUDIO_TRACK_LOADED,{details:p,id:k||0,groupId:v||"",stats:l,networkDetails:C,deliveryDirectives:d});break;case O.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(N.Events.SUBTITLE_TRACK_LOADED,{details:p,id:k||0,groupId:v||"",stats:l,networkDetails:C,deliveryDirectives:d});break}},w}();$.default=L},"./src/polyfills/number.ts":function(ne,$,_){"use strict";_.r($),_.d($,"isFiniteNumber",function(){return V}),_.d($,"MAX_SAFE_INTEGER",function(){return N});var V=Number.isFinite||function(M){return typeof M=="number"&&isFinite(M)},N=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(ne,$,_){"use strict";_.r($);var V=function(){function N(){}return N.getSilentFrame=function(H,F){switch(H){case"mp4a.40.2":if(F===1)return new Uint8Array([0,200,0,128,35,128]);if(F===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(F===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(F===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(F===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(F===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(F===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(F===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(F===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return},N}();$.default=V},"./src/remux/mp4-generator.ts":function(ne,$,_){"use strict";_.r($);var V=Math.pow(2,32)-1,N=function(){function M(){}return M.init=function(){M.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var F;for(F in M.types)M.types.hasOwnProperty(F)&&(M.types[F]=[F.charCodeAt(0),F.charCodeAt(1),F.charCodeAt(2),F.charCodeAt(3)]);var P=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),O=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);M.HDLR_TYPES={video:P,audio:O};var b=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),A=new Uint8Array([0,0,0,0,0,0,0,0]);M.STTS=M.STSC=M.STCO=A,M.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),M.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),M.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),M.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var D=new Uint8Array([105,115,111,109]),L=new Uint8Array([97,118,99,49]),w=new Uint8Array([0,0,0,1]);M.FTYP=M.box(M.types.ftyp,D,w,D,L),M.DINF=M.box(M.types.dinf,M.box(M.types.dref,b))},M.box=function(F){for(var P=8,O=arguments.length,b=new Array(O>1?O-1:0),A=1;A<O;A++)b[A-1]=arguments[A];for(var D=b.length,L=D;D--;)P+=b[D].byteLength;var w=new Uint8Array(P);for(w[0]=P>>24&255,w[1]=P>>16&255,w[2]=P>>8&255,w[3]=P&255,w.set(F,4),D=0,P=8;D<L;D++)w.set(b[D],P),P+=b[D].byteLength;return w},M.hdlr=function(F){return M.box(M.types.hdlr,M.HDLR_TYPES[F])},M.mdat=function(F){return M.box(M.types.mdat,F)},M.mdhd=function(F,P){P*=F;var O=Math.floor(P/(V+1)),b=Math.floor(P%(V+1));return M.box(M.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,F>>24&255,F>>16&255,F>>8&255,F&255,O>>24,O>>16&255,O>>8&255,O&255,b>>24,b>>16&255,b>>8&255,b&255,85,196,0,0]))},M.mdia=function(F){return M.box(M.types.mdia,M.mdhd(F.timescale,F.duration),M.hdlr(F.type),M.minf(F))},M.mfhd=function(F){return M.box(M.types.mfhd,new Uint8Array([0,0,0,0,F>>24,F>>16&255,F>>8&255,F&255]))},M.minf=function(F){return F.type==="audio"?M.box(M.types.minf,M.box(M.types.smhd,M.SMHD),M.DINF,M.stbl(F)):M.box(M.types.minf,M.box(M.types.vmhd,M.VMHD),M.DINF,M.stbl(F))},M.moof=function(F,P,O){return M.box(M.types.moof,M.mfhd(F),M.traf(O,P))},M.moov=function(F){for(var P=F.length,O=[];P--;)O[P]=M.trak(F[P]);return M.box.apply(null,[M.types.moov,M.mvhd(F[0].timescale,F[0].duration)].concat(O).concat(M.mvex(F)))},M.mvex=function(F){for(var P=F.length,O=[];P--;)O[P]=M.trex(F[P]);return M.box.apply(null,[M.types.mvex].concat(O))},M.mvhd=function(F,P){P*=F;var O=Math.floor(P/(V+1)),b=Math.floor(P%(V+1)),A=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,F>>24&255,F>>16&255,F>>8&255,F&255,O>>24,O>>16&255,O>>8&255,O&255,b>>24,b>>16&255,b>>8&255,b&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return M.box(M.types.mvhd,A)},M.sdtp=function(F){var P=F.samples||[],O=new Uint8Array(4+P.length),b,A;for(b=0;b<P.length;b++)A=P[b].flags,O[b+4]=A.dependsOn<<4|A.isDependedOn<<2|A.hasRedundancy;return M.box(M.types.sdtp,O)},M.stbl=function(F){return M.box(M.types.stbl,M.stsd(F),M.box(M.types.stts,M.STTS),M.box(M.types.stsc,M.STSC),M.box(M.types.stsz,M.STSZ),M.box(M.types.stco,M.STCO))},M.avc1=function(F){var P=[],O=[],b,A,D;for(b=0;b<F.sps.length;b++)A=F.sps[b],D=A.byteLength,P.push(D>>>8&255),P.push(D&255),P=P.concat(Array.prototype.slice.call(A));for(b=0;b<F.pps.length;b++)A=F.pps[b],D=A.byteLength,O.push(D>>>8&255),O.push(D&255),O=O.concat(Array.prototype.slice.call(A));var L=M.box(M.types.avcC,new Uint8Array([1,P[3],P[4],P[5],252|3,224|F.sps.length].concat(P).concat([F.pps.length]).concat(O))),w=F.width,x=F.height,u=F.pixelRatio[0],a=F.pixelRatio[1];return M.box(M.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,w>>8&255,w&255,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]),L,M.box(M.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),M.box(M.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,a>>24,a>>16&255,a>>8&255,a&255])))},M.esds=function(F){var P=F.config.length;return new Uint8Array([0,0,0,0,3,23+P,0,1,0,4,15+P,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([P]).concat(F.config).concat([6,1,2]))},M.mp4a=function(F){var P=F.samplerate;return M.box(M.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,F.channelCount,0,16,0,0,0,0,P>>8&255,P&255,0,0]),M.box(M.types.esds,M.esds(F)))},M.mp3=function(F){var P=F.samplerate;return M.box(M.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,F.channelCount,0,16,0,0,0,0,P>>8&255,P&255,0,0]))},M.stsd=function(F){return F.type==="audio"?!F.isAAC&&F.codec==="mp3"?M.box(M.types.stsd,M.STSD,M.mp3(F)):M.box(M.types.stsd,M.STSD,M.mp4a(F)):M.box(M.types.stsd,M.STSD,M.avc1(F))},M.tkhd=function(F){var P=F.id,O=F.duration*F.timescale,b=F.width,A=F.height,D=Math.floor(O/(V+1)),L=Math.floor(O%(V+1));return M.box(M.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,P>>24&255,P>>16&255,P>>8&255,P&255,0,0,0,0,D>>24,D>>16&255,D>>8&255,D&255,L>>24,L>>16&255,L>>8&255,L&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,b>>8&255,b&255,0,0,A>>8&255,A&255,0,0]))},M.traf=function(F,P){var O=M.sdtp(F),b=F.id,A=Math.floor(P/(V+1)),D=Math.floor(P%(V+1));return M.box(M.types.traf,M.box(M.types.tfhd,new Uint8Array([0,0,0,0,b>>24,b>>16&255,b>>8&255,b&255])),M.box(M.types.tfdt,new Uint8Array([1,0,0,0,A>>24,A>>16&255,A>>8&255,A&255,D>>24,D>>16&255,D>>8&255,D&255])),M.trun(F,O.length+16+20+8+16+8+8),O)},M.trak=function(F){return F.duration=F.duration||4294967295,M.box(M.types.trak,M.tkhd(F),M.mdia(F))},M.trex=function(F){var P=F.id;return M.box(M.types.trex,new Uint8Array([0,0,0,0,P>>24,P>>16&255,P>>8&255,P&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},M.trun=function(F,P){var O=F.samples||[],b=O.length,A=12+16*b,D=new Uint8Array(A),L,w,x,u,a,l;for(P+=8+A,D.set([0,0,15,1,b>>>24&255,b>>>16&255,b>>>8&255,b&255,P>>>24&255,P>>>16&255,P>>>8&255,P&255],0),L=0;L<b;L++)w=O[L],x=w.duration,u=w.size,a=w.flags,l=w.cts,D.set([x>>>24&255,x>>>16&255,x>>>8&255,x&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,a.isLeading<<2|a.dependsOn,a.isDependedOn<<6|a.hasRedundancy<<4|a.paddingValue<<1|a.isNonSync,a.degradPrio&240<<8,a.degradPrio&15,l>>>24&255,l>>>16&255,l>>>8&255,l&255],12+16*L);return M.box(M.types.trun,D)},M.initSegment=function(F){M.types||M.init();var P=M.moov(F),O=new Uint8Array(M.FTYP.byteLength+P.byteLength);return O.set(M.FTYP),O.set(P,M.FTYP.byteLength),O},M}();N.types=void 0,N.HDLR_TYPES=void 0,N.STTS=void 0,N.STSC=void 0,N.STCO=void 0,N.STSZ=void 0,N.VMHD=void 0,N.SMHD=void 0,N.STSD=void 0,N.FTYP=void 0,N.DINF=void 0,$.default=N},"./src/remux/mp4-remuxer.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return l}),_.d($,"normalizePts",function(){return h});var V=_("./src/polyfills/number.ts"),N=_("./src/remux/aac-helper.ts"),M=_("./src/remux/mp4-generator.ts"),H=_("./src/events.ts"),F=_("./src/errors.ts"),P=_("./src/utils/logger.ts"),O=_("./src/types/loader.ts"),b=_("./src/utils/timescale-conversion.ts");function A(){return A=Object.assign||function(k){for(var v=1;v<arguments.length;v++){var f=arguments[v];for(var p in f)Object.prototype.hasOwnProperty.call(f,p)&&(k[p]=f[p])}return k},A.apply(this,arguments)}var D=10*1e3,L=1024,w=1152,x=null,u=null,a=!1,l=function(){function k(f,p,d,o){if(o===void 0&&(o=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=f,this.config=p,this.typeSupported=d,this.ISGenerated=!1,x===null){var S=navigator.userAgent||"",y=S.match(/Chrome\/(\d+)/i);x=y?parseInt(y[1]):0}if(u===null){var T=navigator.userAgent.match(/Safari\/(\d+)/i);u=T?parseInt(T[1]):0}a=!!x&&x<75||!!u&&u<600}var v=k.prototype;return v.destroy=function(){},v.resetTimeStamp=function(p){P.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=p},v.resetNextTimestamp=function(){P.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},v.resetInitSegment=function(){P.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},v.getVideoStartPts=function(p){var d=!1,o=p.reduce(function(S,y){var T=y.pts-S;return T<-4294967296?(d=!0,h(S,y.pts)):T>0?S:y.pts},p[0].pts);return d&&P.logger.debug("PTS rollover detected"),o},v.remux=function(p,d,o,S,y,T,I,G){var X,Q,z,W,ee,ae,pe=y,ve=y,De=p.pid>-1,xe=d.pid>-1,Ce=d.samples.length,Ae=p.samples.length>0,Se=Ce>1,ge=(!De||Ae)&&(!xe||Se)||this.ISGenerated||I;if(ge){this.ISGenerated||(z=this.generateIS(p,d,y));var oe=this.isVideoContiguous,Re=-1;if(Se&&(Re=C(d.samples),!oe&&this.config.forceKeyFrameOnDiscontinuity))if(ae=!0,Re>0){P.logger.warn("[mp4-remuxer]: Dropped "+Re+" out of "+Ce+" video samples due to a missing keyframe");var Ze=this.getVideoStartPts(d.samples);d.samples=d.samples.slice(Re),d.dropped+=Re,ve+=(d.samples[0].pts-Ze)/(d.timescale||9e4)}else Re===-1&&(P.logger.warn("[mp4-remuxer]: No keyframe found out of "+Ce+" video samples"),ae=!1);if(this.ISGenerated){if(Ae&&Se){var He=this.getVideoStartPts(d.samples),Ge=h(p.samples[0].pts,He)-He,$e=Ge/d.inputTimeScale;pe+=Math.max(0,$e),ve+=Math.max(0,-$e)}if(Ae){if(p.samplerate||(P.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),z=this.generateIS(p,d,y)),Q=this.remuxAudio(p,pe,this.isAudioContiguous,T,xe||Se||G===O.PlaylistLevelType.AUDIO?ve:void 0),Se){var _e=Q?Q.endPTS-Q.startPTS:0;d.inputTimeScale||(P.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),z=this.generateIS(p,d,y)),X=this.remuxVideo(d,ve,oe,_e)}}else Se&&(X=this.remuxVideo(d,ve,oe,0));X&&(X.firstKeyFrame=Re,X.independent=Re!==-1)}}return this.ISGenerated&&(o.samples.length&&(ee=this.remuxID3(o,y)),S.samples.length&&(W=this.remuxText(S,y))),{audio:Q,video:X,initSegment:z,independent:ae,text:W,id3:ee}},v.generateIS=function(p,d,o){var S=p.samples,y=d.samples,T=this.typeSupported,I={},G=!Object(V.isFiniteNumber)(this._initPTS),X="audio/mp4",Q,z,W;if(G&&(Q=z=Infinity),p.config&&S.length&&(p.timescale=p.samplerate,p.isAAC||(T.mpeg?(X="audio/mpeg",p.codec=""):T.mp3&&(p.codec="mp3")),I.audio={id:"audio",container:X,codec:p.codec,initSegment:!p.isAAC&&T.mpeg?new Uint8Array(0):M.default.initSegment([p]),metadata:{channelCount:p.channelCount}},G&&(W=p.inputTimeScale,Q=z=S[0].pts-Math.round(W*o))),d.sps&&d.pps&&y.length&&(d.timescale=d.inputTimeScale,I.video={id:"main",container:"video/mp4",codec:d.codec,initSegment:M.default.initSegment([d]),metadata:{width:d.width,height:d.height}},G)){W=d.inputTimeScale;var ee=this.getVideoStartPts(y),ae=Math.round(W*o);z=Math.min(z,h(y[0].dts,ee)-ae),Q=Math.min(Q,ee-ae)}if(Object.keys(I).length)return this.ISGenerated=!0,G&&(this._initPTS=Q,this._initDTS=z),{tracks:I,initPTS:Q,timescale:W}},v.remuxVideo=function(p,d,o,S){var y=p.inputTimeScale,T=p.samples,I=[],G=T.length,X=this._initPTS,Q=this.nextAvcDts,z=8,W,ee,ae,pe=Number.POSITIVE_INFINITY,ve=Number.NEGATIVE_INFINITY,De=0,xe=!1;if(!o||Q===null){var Ce=d*y,Ae=T[0].pts-h(T[0].dts,T[0].pts);Q=Ce-Ae}for(var Se=0;Se<G;Se++){var ge=T[Se];if(ge.pts=h(ge.pts-X,Q),ge.dts=h(ge.dts-X,Q),ge.dts>ge.pts){var oe=9e4*.2;De=Math.max(Math.min(De,ge.pts-ge.dts),-1*oe)}ge.dts<T[Se>0?Se-1:Se].dts&&(xe=!0)}xe&&T.sort(function(wt,Tt){var ut=wt.dts-Tt.dts,Ft=wt.pts-Tt.pts;return ut||Ft}),ee=T[0].dts,ae=T[T.length-1].dts;var Re=Math.round((ae-ee)/(G-1));if(De<0){if(De<Re*-2){P.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(b.toMsFromMpegTsClock)(-Re,!0)+" ms");for(var Ze=De,He=0;He<G;He++)T[He].dts=Ze=Math.max(Ze,T[He].pts-Re),T[He].pts=Math.max(Ze,T[He].pts)}else{P.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(b.toMsFromMpegTsClock)(De,!0)+" ms to overcome this issue");for(var Ge=0;Ge<G;Ge++)T[Ge].dts=T[Ge].dts+De}ee=T[0].dts}if(o){var $e=ee-Q,_e=$e>Re,Ie=$e<-1;if(_e||Ie){_e?P.logger.warn("AVC: "+Object(b.toMsFromMpegTsClock)($e,!0)+" ms ("+$e+"dts) hole between fragments detected, filling it"):P.logger.warn("AVC: "+Object(b.toMsFromMpegTsClock)(-$e,!0)+" ms ("+$e+"dts) overlapping between fragments detected"),ee=Q;var We=T[0].pts-$e;T[0].dts=ee,T[0].pts=We,P.logger.log("Video: First PTS/DTS adjusted: "+Object(b.toMsFromMpegTsClock)(We,!0)+"/"+Object(b.toMsFromMpegTsClock)(ee,!0)+", delta: "+Object(b.toMsFromMpegTsClock)($e,!0)+" ms")}}a&&(ee=Math.max(0,ee));for(var Ve=0,ze=0,Be=0;Be<G;Be++){for(var Fe=T[Be],ot=Fe.units,it=ot.length,Je=0,qe=0;qe<it;qe++)Je+=ot[qe].data.length;ze+=Je,Ve+=it,Fe.length=Je,Fe.dts=Math.max(Fe.dts,ee),Fe.pts=Math.max(Fe.pts,Fe.dts,0),pe=Math.min(Fe.pts,pe),ve=Math.max(Fe.pts,ve)}ae=T[G-1].dts;var ct=ze+4*Ve+8,et;try{et=new Uint8Array(ct)}catch(wt){this.observer.emit(H.Events.ERROR,H.Events.ERROR,{type:F.ErrorTypes.MUX_ERROR,details:F.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ct,reason:"fail allocating video mdat "+ct});return}var Qe=new DataView(et.buffer);Qe.setUint32(0,ct),et.set(M.default.types.mdat,4);for(var we=0;we<G;we++){for(var lt=T[we],tt=lt.units,Te=0,Le=0,fe=tt.length;Le<fe;Le++){var le=tt[Le],ue=le.data,q=le.data.byteLength;Qe.setUint32(z,q),z+=4,et.set(ue,z),z+=q,Te+=4+q}if(we<G-1)W=T[we+1].dts-lt.dts;else{var te=this.config,ie=lt.dts-T[we>0?we-1:we].dts;if(te.stretchShortVideoTrack&&this.nextAudioPts!==null){var de=Math.floor(te.maxBufferHole*y),me=(S?pe+S*y:this.nextAudioPts)-lt.pts;me>de?(W=me-ie,W<0&&(W=ie),P.logger.log("[mp4-remuxer]: It is approximately "+me/90+" ms to the next segment; using duration "+W/90+" ms for the last video frame.")):W=ie}else W=ie}var Ee=Math.round(lt.pts-lt.dts);I.push(new g(lt.key,W,Te,Ee))}if(I.length&&x&&x<70){var Pe=I[0].flags;Pe.dependsOn=2,Pe.isNonSync=0}console.assert(W!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=Q=ae+W,this.isVideoContiguous=!0;var rt=M.default.moof(p.sequenceNumber++,ee,A({},p,{samples:I})),mt="video",ft={data1:rt,data2:et,startPTS:pe/y,endPTS:(ve+W)/y,startDTS:ee/y,endDTS:Q/y,type:mt,hasAudio:!1,hasVideo:!0,nb:I.length,dropped:p.dropped};return p.samples=[],p.dropped=0,console.assert(et.length,"MDAT length must not be zero"),ft},v.remuxAudio=function(p,d,o,S,y){var T=p.inputTimeScale,I=p.samplerate?p.samplerate:T,G=T/I,X=p.isAAC?L:w,Q=X*G,z=this._initPTS,W=!p.isAAC&&this.typeSupported.mpeg,ee=[],ae=p.samples,pe=W?0:8,ve=this.nextAudioPts||-1,De=d*T;if(this.isAudioContiguous=o=o||ae.length&&ve>0&&(S&&Math.abs(De-ve)<9e3||Math.abs(h(ae[0].pts-z,De)-ve)<20*Q),ae.forEach(function(ue){ue.pts=h(ue.pts-z,De)}),!o||ve<0){if(ae=ae.filter(function(ue){return ue.pts>=0}),!ae.length)return;y===0?ve=0:S?ve=Math.max(0,De):ve=ae[0].pts}if(p.isAAC)for(var xe=y!==void 0,Ce=this.config.maxAudioFramesDrift,Ae=0,Se=ve;Ae<ae.length;Ae++){var ge=ae[Ae],oe=ge.pts,Re=oe-Se,Ze=Math.abs(1e3*Re/T);if(Re<=-Ce*Q&&xe)Ae===0&&(P.logger.warn("Audio frame @ "+(oe/T).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*Re/T)+" ms."),this.nextAudioPts=ve=Se=oe);else if(Re>=Ce*Q&&Ze<D&&xe){var He=Math.round(Re/Q);Se=oe-He*Q,Se<0&&(He--,Se+=Q),Ae===0&&(this.nextAudioPts=ve=Se),P.logger.warn("[mp4-remuxer]: Injecting "+He+" audio frame @ "+(Se/T).toFixed(3)+"s due to "+Math.round(1e3*Re/T)+" ms gap.");for(var Ge=0;Ge<He;Ge++){var $e=Math.max(Se,0),_e=N.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount);_e||(P.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),_e=ge.unit.subarray()),ae.splice(Ae,0,{unit:_e,pts:$e}),Se+=Q,Ae++}}ge.pts=Se,Se+=Q}for(var Ie=null,We=null,Ve,ze=0,Be=ae.length;Be--;)ze+=ae[Be].unit.byteLength;for(var Fe=0,ot=ae.length;Fe<ot;Fe++){var it=ae[Fe],Je=it.unit,qe=it.pts;if(We!==null){var ct=ee[Fe-1];ct.duration=Math.round((qe-We)/G)}else if(o&&p.isAAC&&(qe=ve),Ie=qe,ze>0){ze+=pe;try{Ve=new Uint8Array(ze)}catch(ue){this.observer.emit(H.Events.ERROR,H.Events.ERROR,{type:F.ErrorTypes.MUX_ERROR,details:F.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ze,reason:"fail allocating audio mdat "+ze});return}if(!W){var et=new DataView(Ve.buffer);et.setUint32(0,ze),Ve.set(M.default.types.mdat,4)}}else return;Ve.set(Je,pe);var Qe=Je.byteLength;pe+=Qe,ee.push(new g(!0,X,Qe,0)),We=qe}var we=ee.length;if(!we)return;var lt=ee[ee.length-1];this.nextAudioPts=ve=We+G*lt.duration;var tt=W?new Uint8Array(0):M.default.moof(p.sequenceNumber++,Ie/G,A({},p,{samples:ee}));p.samples=[];var Te=Ie/T,Le=ve/T,fe="audio",le={data1:tt,data2:Ve,startPTS:Te,endPTS:Le,startDTS:Te,endDTS:Le,type:fe,hasAudio:!0,hasVideo:!1,nb:we};return this.isAudioContiguous=!0,console.assert(Ve.length,"MDAT length must not be zero"),le},v.remuxEmptyAudio=function(p,d,o,S){var y=p.inputTimeScale,T=p.samplerate?p.samplerate:y,I=y/T,G=this.nextAudioPts,X=(G!==null?G:S.startDTS*y)+this._initDTS,Q=S.endDTS*y+this._initDTS,z=I*L,W=Math.ceil((Q-X)/z),ee=N.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount);if(P.logger.warn("[mp4-remuxer]: remux empty Audio"),!ee){P.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var ae=[],pe=0;pe<W;pe++){var ve=X+pe*z;ae.push({unit:ee,pts:ve,dts:ve})}return p.samples=ae,this.remuxAudio(p,d,o,!1)},v.remuxID3=function(p,d){var o=p.samples.length;if(!o)return;for(var S=p.inputTimeScale,y=this._initPTS,T=this._initDTS,I=0;I<o;I++){var G=p.samples[I];G.pts=h(G.pts-y,d*S)/S,G.dts=h(G.dts-T,d*S)/S}var X=p.samples;return p.samples=[],{samples:X}},v.remuxText=function(p,d){var o=p.samples.length;if(!o)return;for(var S=p.inputTimeScale,y=this._initPTS,T=0;T<o;T++){var I=p.samples[T];I.pts=h(I.pts-y,d*S)/S}p.samples.sort(function(X,Q){return X.pts-Q.pts});var G=p.samples;return p.samples=[],{samples:G}},k}();function h(k,v){var f;if(v===null)return k;for(v<k?f=-8589934592:f=8589934592;Math.abs(k-v)>4294967296;)k+=f;return k}function C(k){for(var v=0;v<k.length;v++)if(k[v].key)return v;return-1}var g=function(v,f,p,d){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=f,this.size=p,this.cts=d,this.flags=new m(v)},m=function(v){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=v?2:1,this.isNonSync=v?0:1}},"./src/remux/passthrough-remuxer.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/polyfills/number.ts"),N=_("./src/utils/mp4-tools.ts"),M=_("./src/loader/fragment.ts"),H=_("./src/utils/logger.ts"),F=function(){function b(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var A=b.prototype;return A.destroy=function(){},A.resetTimeStamp=function(L){this.initPTS=L,this.lastEndDTS=null},A.resetNextTimestamp=function(){this.lastEndDTS=null},A.resetInitSegment=function(L,w,x){this.audioCodec=w,this.videoCodec=x,this.generateInitSegment(L),this.emitInitSegment=!0},A.generateInitSegment=function(L){var w=this.audioCodec,x=this.videoCodec;if(!L||!L.byteLength){this.initTracks=void 0,this.initData=void 0;return}var u=this.initData=Object(N.parseInitSegment)(L);w||(w=O(u.audio,M.ElementaryStreamTypes.AUDIO)),x||(x=O(u.video,M.ElementaryStreamTypes.VIDEO));var a={};u.audio&&u.video?a.audiovideo={container:"video/mp4",codec:w+","+x,initSegment:L,id:"main"}:u.audio?a.audio={container:"audio/mp4",codec:w,initSegment:L,id:"audio"}:u.video?a.video={container:"video/mp4",codec:x,initSegment:L,id:"main"}:H.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a},A.remux=function(L,w,x,u,a){var l=this.initPTS,h=this.lastEndDTS,C={audio:void 0,video:void 0,text:u,id3:x,initSegment:void 0};Object(V.isFiniteNumber)(h)||(h=this.lastEndDTS=a||0);var g=w.samples;if(!g||!g.length)return C;var m={initPTS:void 0,timescale:1},k=this.initData;if((!k||!k.length)&&(this.generateInitSegment(g),k=this.initData),!k||!k.length)return H.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),C;this.emitInitSegment&&(m.tracks=this.initTracks,this.emitInitSegment=!1),Object(V.isFiniteNumber)(l)||(this.initPTS=m.initPTS=l=P(k,g,h));var v=Object(N.getDuration)(g,k),f=h,p=v+f;Object(N.offsetStartDTS)(k,g,l),v>0?this.lastEndDTS=p:(H.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var d=!!k.audio,o=!!k.video,S="";d&&(S+="audio"),o&&(S+="video");var y={data1:g,startPTS:f,startDTS:f,endPTS:p,endDTS:p,type:S,hasAudio:d,hasVideo:o,nb:1,dropped:0};return C.audio=y.type==="audio"?y:void 0,C.video=y.type!=="audio"?y:void 0,C.text=u,C.id3=x,C.initSegment=m,C},b}(),P=function(A,D,L){return Object(N.getStartDTS)(A,D)-L};function O(b,A){var D=b==null?void 0:b.codec;return D&&D.length>4?D:D==="hvc1"?"hvc1.1.c.L120.90":D==="av01"?"av01.0.04M.08":D==="avc1"||A===M.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}$.default=F},"./src/task-loop.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return V});var V=function(){function N(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var M=N.prototype;return M.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},M.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},M.onHandlerDestroyed=function(){},M.hasInterval=function(){return!!this._tickInterval},M.hasNextTick=function(){return!!this._tickTimer},M.setInterval=function(F){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,F),!0)},M.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},M.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},M.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},M.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},M.doTick=function(){},N}()},"./src/types/cmcd.ts":function(ne,$,_){"use strict";_.r($),_.d($,"CMCDVersion",function(){return V}),_.d($,"CMCDObjectType",function(){return N}),_.d($,"CMCDStreamingFormat",function(){return M}),_.d($,"CMCDStreamType",function(){return H});var V=1,N;(function(F){F.MANIFEST="m",F.AUDIO="a",F.VIDEO="v",F.MUXED="av",F.INIT="i",F.CAPTION="c",F.TIMED_TEXT="tt",F.KEY="k",F.OTHER="o"})(N||(N={}));var M;(function(F){F.DASH="d",F.HLS="h",F.SMOOTH="s",F.OTHER="o"})(M||(M={}));var H;(function(F){F.VOD="v",F.LIVE="l"})(H||(H={}))},"./src/types/level.ts":function(ne,$,_){"use strict";_.r($),_.d($,"HlsSkip",function(){return M}),_.d($,"getSkipValue",function(){return H}),_.d($,"HlsUrlParameters",function(){return F}),_.d($,"Level",function(){return P});function V(O,b){for(var A=0;A<b.length;A++){var D=b[A];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(O,D.key,D)}}function N(O,b,A){return b&&V(O.prototype,b),A&&V(O,A),O}var M;(function(O){O.No="",O.Yes="YES",O.v2="v2"})(M||(M={}));function H(O,b){var A=O.canSkipUntil,D=O.canSkipDateRanges,L=O.endSN,w=b!==void 0?b-L:0;return A&&w<A?D?M.v2:M.Yes:M.No}var F=function(){function O(A,D,L){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=A,this.part=D,this.skip=L}var b=O.prototype;return b.addDirectives=function(D){var L=new self.URL(D);return this.msn!==void 0&&L.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&L.searchParams.set("_HLS_part",this.part.toString()),this.skip&&L.searchParams.set("_HLS_skip",this.skip),L.toString()},O}(),P=function(){function O(b){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[b.url],this.attrs=b.attrs,this.bitrate=b.bitrate,b.details&&(this.details=b.details),this.id=b.id||0,this.name=b.name,this.width=b.width||0,this.height=b.height||0,this.audioCodec=b.audioCodec,this.videoCodec=b.videoCodec,this.unknownCodecs=b.unknownCodecs,this.codecSet=[b.videoCodec,b.audioCodec].filter(function(A){return A}).join(",").replace(/\.[^.,]+/g,"")}return N(O,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(A){var D=A%this.url.length;this._urlId!==D&&(this.details=void 0,this._urlId=D)}}]),O}()},"./src/types/loader.ts":function(ne,$,_){"use strict";_.r($),_.d($,"PlaylistContextType",function(){return V}),_.d($,"PlaylistLevelType",function(){return N});var V;(function(M){M.MANIFEST="manifest",M.LEVEL="level",M.AUDIO_TRACK="audioTrack",M.SUBTITLE_TRACK="subtitleTrack"})(V||(V={}));var N;(function(M){M.MAIN="main",M.AUDIO="audio",M.SUBTITLE="subtitle"})(N||(N={}))},"./src/types/transmuxer.ts":function(ne,$,_){"use strict";_.r($),_.d($,"ChunkMetadata",function(){return V});var V=function(H,F,P,O,b,A){O===void 0&&(O=0),b===void 0&&(b=-1),A===void 0&&(A=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=N(),this.buffering={audio:N(),video:N(),audiovideo:N()},this.level=H,this.sn=F,this.id=P,this.size=O,this.part=b,this.partial=A};function N(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(ne,$,_){"use strict";_.r($),_.d($,"AttrList",function(){return M});var V=/^(\d+)x(\d+)$/,N=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,M=function(){function H(P){typeof P=="string"&&(P=H.parseAttrList(P));for(var O in P)P.hasOwnProperty(O)&&(this[O]=P[O])}var F=H.prototype;return F.decimalInteger=function(O){var b=parseInt(this[O],10);return b>Number.MAX_SAFE_INTEGER?Infinity:b},F.hexadecimalInteger=function(O){if(this[O]){var b=(this[O]||"0x").slice(2);b=(b.length&1?"0":"")+b;for(var A=new Uint8Array(b.length/2),D=0;D<b.length/2;D++)A[D]=parseInt(b.slice(D*2,D*2+2),16);return A}else return null},F.hexadecimalIntegerAsNumber=function(O){var b=parseInt(this[O],16);return b>Number.MAX_SAFE_INTEGER?Infinity:b},F.decimalFloatingPoint=function(O){return parseFloat(this[O])},F.optionalFloat=function(O,b){var A=this[O];return A?parseFloat(A):b},F.enumeratedString=function(O){return this[O]},F.bool=function(O){return this[O]==="YES"},F.decimalResolution=function(O){var b=V.exec(this[O]);return b===null?void 0:{width:parseInt(b[1],10),height:parseInt(b[2],10)}},H.parseAttrList=function(O){var b,A={},D='"';for(N.lastIndex=0;(b=N.exec(O))!==null;){var L=b[2];L.indexOf(D)===0&&L.lastIndexOf(D)===L.length-1&&(L=L.slice(1,-1)),A[b[1]]=L}return A},H}()},"./src/utils/binary-search.ts":function(ne,$,_){"use strict";_.r($);var V={search:function(M,H){for(var F=0,P=M.length-1,O=null,b=null;F<=P;){O=(F+P)/2|0,b=M[O];var A=H(b);if(A>0)F=O+1;else if(A<0)P=O-1;else return b}return null}};$.default=V},"./src/utils/buffer-helper.ts":function(ne,$,_){"use strict";_.r($),_.d($,"BufferHelper",function(){return M});var V=_("./src/utils/logger.ts"),N={length:0,start:function(){return 0},end:function(){return 0}},M=function(){function H(){}return H.isBuffered=function(P,O){try{if(P){for(var b=H.getBuffered(P),A=0;A<b.length;A++)if(O>=b.start(A)&&O<=b.end(A))return!0}}catch(D){}return!1},H.bufferInfo=function(P,O,b){try{if(P){var A=H.getBuffered(P),D=[],L;for(L=0;L<A.length;L++)D.push({start:A.start(L),end:A.end(L)});return this.bufferedInfo(D,O,b)}}catch(w){}return{len:0,start:O,end:O,nextStart:void 0}},H.bufferedInfo=function(P,O,b){O=Math.max(0,O),P.sort(function(m,k){var v=m.start-k.start;return v||k.end-m.end});var A=[];if(b)for(var D=0;D<P.length;D++){var L=A.length;if(L){var w=A[L-1].end;P[D].start-w<b?P[D].end>w&&(A[L-1].end=P[D].end):A.push(P[D])}else A.push(P[D])}else A=P;for(var x=0,u,a=O,l=O,h=0;h<A.length;h++){var C=A[h].start,g=A[h].end;if(O+b>=C&&O<g)a=C,l=g,x=l-O;else if(O+b<C){u=C;break}}return{len:x,start:a||0,end:l||0,nextStart:u}},H.getBuffered=function(P){try{return P.buffered}catch(O){return V.logger.log("failed to get media.buffered",O),N}},H}()},"./src/utils/cea-608-parser.ts":function(ne,$,_){"use strict";_.r($),_.d($,"Row",function(){return l}),_.d($,"CaptionScreen",function(){return h});var V=_("./src/utils/logger.ts"),N={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},M=function(p){var d=p;return N.hasOwnProperty(p)&&(d=N[p]),String.fromCharCode(d)},H=15,F=100,P={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},O={17:2,18:4,21:6,22:8,23:10,19:13,20:15},b={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},A={25:2,26:4,29:6,30:8,31:10,27:13,28:15},D=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],L;(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"})(L||(L={}));var w=function(){function f(){this.time=null,this.verboseLevel=L.ERROR}var p=f.prototype;return p.log=function(o,S){this.verboseLevel>=o&&V.logger.log(this.time+" ["+o+"] "+S)},f}(),x=function(p){for(var d=[],o=0;o<p.length;o++)d.push(p[o].toString(16));return d},u=function(){function f(d,o,S,y,T){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=d||"white",this.underline=o||!1,this.italics=S||!1,this.background=y||"black",this.flash=T||!1}var p=f.prototype;return p.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},p.setStyles=function(o){for(var S=["foreground","underline","italics","background","flash"],y=0;y<S.length;y++){var T=S[y];o.hasOwnProperty(T)&&(this[T]=o[T])}},p.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},p.equals=function(o){return this.foreground===o.foreground&&this.underline===o.underline&&this.italics===o.italics&&this.background===o.background&&this.flash===o.flash},p.copy=function(o){this.foreground=o.foreground,this.underline=o.underline,this.italics=o.italics,this.background=o.background,this.flash=o.flash},p.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},f}(),a=function(){function f(d,o,S,y,T,I){this.uchar=void 0,this.penState=void 0,this.uchar=d||" ",this.penState=new u(o,S,y,T,I)}var p=f.prototype;return p.reset=function(){this.uchar=" ",this.penState.reset()},p.setChar=function(o,S){this.uchar=o,this.penState.copy(S)},p.setPenState=function(o){this.penState.copy(o)},p.equals=function(o){return this.uchar===o.uchar&&this.penState.equals(o.penState)},p.copy=function(o){this.uchar=o.uchar,this.penState.copy(o.penState)},p.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},f}(),l=function(){function f(d){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var o=0;o<F;o++)this.chars.push(new a);this.logger=d,this.pos=0,this.currPenState=new u}var p=f.prototype;return p.equals=function(o){for(var S=!0,y=0;y<F;y++)if(!this.chars[y].equals(o.chars[y])){S=!1;break}return S},p.copy=function(o){for(var S=0;S<F;S++)this.chars[S].copy(o.chars[S])},p.isEmpty=function(){for(var o=!0,S=0;S<F;S++)if(!this.chars[S].isEmpty()){o=!1;break}return o},p.setCursor=function(o){this.pos!==o&&(this.pos=o),this.pos<0?(this.logger.log(L.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>F&&(this.logger.log(L.DEBUG,"Too large cursor position "+this.pos),this.pos=F)},p.moveCursor=function(o){var S=this.pos+o;if(o>1)for(var y=this.pos+1;y<S+1;y++)this.chars[y].setPenState(this.currPenState);this.setCursor(S)},p.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},p.insertChar=function(o){o>=144&&this.backSpace();var S=M(o);if(this.pos>=F){this.logger.log(L.ERROR,"Cannot insert "+o.toString(16)+" ("+S+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(S,this.currPenState),this.moveCursor(1)},p.clearFromPos=function(o){var S;for(S=o;S<F;S++)this.chars[S].reset()},p.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},p.clearToEndOfRow=function(){this.clearFromPos(this.pos)},p.getTextString=function(){for(var o=[],S=!0,y=0;y<F;y++){var T=this.chars[y].uchar;T!==" "&&(S=!1),o.push(T)}return S?"":o.join("")},p.setPenStyles=function(o){this.currPenState.setStyles(o);var S=this.chars[this.pos];S.setPenState(this.currPenState)},f}(),h=function(){function f(d){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var o=0;o<H;o++)this.rows.push(new l(d));this.logger=d,this.currRow=H-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var p=f.prototype;return p.reset=function(){for(var o=0;o<H;o++)this.rows[o].clear();this.currRow=H-1},p.equals=function(o){for(var S=!0,y=0;y<H;y++)if(!this.rows[y].equals(o.rows[y])){S=!1;break}return S},p.copy=function(o){for(var S=0;S<H;S++)this.rows[S].copy(o.rows[S])},p.isEmpty=function(){for(var o=!0,S=0;S<H;S++)if(!this.rows[S].isEmpty()){o=!1;break}return o},p.backSpace=function(){var o=this.rows[this.currRow];o.backSpace()},p.clearToEndOfRow=function(){var o=this.rows[this.currRow];o.clearToEndOfRow()},p.insertChar=function(o){var S=this.rows[this.currRow];S.insertChar(o)},p.setPen=function(o){var S=this.rows[this.currRow];S.setPenStyles(o)},p.moveCursor=function(o){var S=this.rows[this.currRow];S.moveCursor(o)},p.setCursor=function(o){this.logger.log(L.INFO,"setCursor: "+o);var S=this.rows[this.currRow];S.setCursor(o)},p.setPAC=function(o){this.logger.log(L.INFO,"pacData = "+JSON.stringify(o));var S=o.row-1;if(this.nrRollUpRows&&S<this.nrRollUpRows-1&&(S=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==S){for(var y=0;y<H;y++)this.rows[y].clear();var T=this.currRow+1-this.nrRollUpRows,I=this.lastOutputScreen;if(I){var G=I.rows[T].cueStartTime,X=this.logger.time;if(G&&X!==null&&G<X)for(var Q=0;Q<this.nrRollUpRows;Q++)this.rows[S-this.nrRollUpRows+Q+1].copy(I.rows[T+Q])}}this.currRow=S;var z=this.rows[this.currRow];if(o.indent!==null){var W=o.indent,ee=Math.max(W-1,0);z.setCursor(o.indent),o.color=z.chars[ee].penState.foreground}var ae={foreground:o.color,underline:o.underline,italics:o.italics,background:"black",flash:!1};this.setPen(ae)},p.setBkgData=function(o){this.logger.log(L.INFO,"bkgData = "+JSON.stringify(o)),this.backSpace(),this.setPen(o),this.insertChar(32)},p.setRollUpRows=function(o){this.nrRollUpRows=o},p.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(L.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(L.TEXT,this.getDisplayText());var o=this.currRow+1-this.nrRollUpRows,S=this.rows.splice(o,1)[0];S.clear(),this.rows.splice(this.currRow,0,S),this.logger.log(L.INFO,"Rolling up")},p.getDisplayText=function(o){o=o||!1;for(var S=[],y="",T=-1,I=0;I<H;I++){var G=this.rows[I].getTextString();G&&(T=I+1,o?S.push("Row "+T+": '"+G+"'"):S.push(G.trim()))}return S.length>0&&(o?y="["+S.join(" | ")+"]":y=S.join(`
|
|
`)),y},p.getTextAndFormat=function(){return this.rows},f}(),C=function(){function f(d,o,S){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=d,this.outputFilter=o,this.mode=null,this.verbose=0,this.displayedMemory=new h(S),this.nonDisplayedMemory=new h(S),this.lastOutputScreen=new h(S),this.currRollUpRow=this.displayedMemory.rows[H-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=S}var p=f.prototype;return p.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[H-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},p.getHandler=function(){return this.outputFilter},p.setHandler=function(o){this.outputFilter=o},p.setPAC=function(o){this.writeScreen.setPAC(o)},p.setBkgData=function(o){this.writeScreen.setBkgData(o)},p.setMode=function(o){if(o===this.mode)return;this.mode=o,this.logger.log(L.INFO,"MODE="+o),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=o},p.insertChars=function(o){for(var S=0;S<o.length;S++)this.writeScreen.insertChar(o[S]);var y=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(L.INFO,y+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(L.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},p.ccRCL=function(){this.logger.log(L.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},p.ccBS=function(){if(this.logger.log(L.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},p.ccAOF=function(){},p.ccAON=function(){},p.ccDER=function(){this.logger.log(L.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},p.ccRU=function(o){this.logger.log(L.INFO,"RU("+o+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(o)},p.ccFON=function(){this.logger.log(L.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},p.ccRDC=function(){this.logger.log(L.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},p.ccTR=function(){this.logger.log(L.INFO,"TR"),this.setMode("MODE_TEXT")},p.ccRTD=function(){this.logger.log(L.INFO,"RTD"),this.setMode("MODE_TEXT")},p.ccEDM=function(){this.logger.log(L.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},p.ccCR=function(){this.logger.log(L.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},p.ccENM=function(){this.logger.log(L.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},p.ccEOC=function(){if(this.logger.log(L.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var o=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=o,this.writeScreen=this.nonDisplayedMemory,this.logger.log(L.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},p.ccTO=function(o){this.logger.log(L.INFO,"TO("+o+") - Tab Offset"),this.writeScreen.moveCursor(o)},p.ccMIDROW=function(o){var S={flash:!1};if(S.underline=o%2===1,S.italics=o>=46,S.italics)S.foreground="white";else{var y=Math.floor(o/2)-16,T=["white","green","blue","cyan","red","yellow","magenta"];S.foreground=T[y]}this.logger.log(L.INFO,"MIDROW: "+JSON.stringify(S)),this.writeScreen.setPen(S)},p.outputDataUpdate=function(o){o===void 0&&(o=!1);var S=this.logger.time;if(S===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=S:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,S,this.lastOutputScreen),o&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:S),this.lastOutputScreen.copy(this.displayedMemory))},p.cueSplitAtTime=function(o){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,o,this.displayedMemory),this.cueStartTime=o))},f}(),g=function(){function f(d,o,S){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var y=new w;this.channels=[null,new C(d,o,y),new C(d+1,S,y)],this.cmdHistory=v(),this.logger=y}var p=f.prototype;return p.getHandler=function(o){return this.channels[o].getHandler()},p.setHandler=function(o,S){this.channels[o].setHandler(S)},p.addData=function(o,S){var y,T,I,G=!1;this.logger.time=o;for(var X=0;X<S.length;X+=2){if(T=S[X]&127,I=S[X+1]&127,T===0&&I===0)continue;if(this.logger.log(L.DATA,"["+x([S[X],S[X+1]])+"] -> ("+x([T,I])+")"),y=this.parseCmd(T,I),y||(y=this.parseMidrow(T,I)),y||(y=this.parsePAC(T,I)),y||(y=this.parseBackgroundAttributes(T,I)),!y&&(G=this.parseChars(T,I),G)){var Q=this.currentChannel;if(Q&&Q>0){var z=this.channels[Q];z.insertChars(G)}else this.logger.log(L.WARNING,"No channel found yet. TEXT-MODE?")}!y&&!G&&this.logger.log(L.WARNING,"Couldn't parse cleaned data "+x([T,I])+" orig: "+x([S[X],S[X+1]]))}},p.parseCmd=function(o,S){var y=this.cmdHistory,T=(o===20||o===28||o===21||o===29)&&S>=32&&S<=47,I=(o===23||o===31)&&S>=33&&S<=35;if(!(T||I))return!1;if(k(o,S,y))return m(null,null,y),this.logger.log(L.DEBUG,"Repeated command ("+x([o,S])+") is dropped"),!0;var G=o===20||o===21||o===23?1:2,X=this.channels[G];return o===20||o===21||o===28||o===29?S===32?X.ccRCL():S===33?X.ccBS():S===34?X.ccAOF():S===35?X.ccAON():S===36?X.ccDER():S===37?X.ccRU(2):S===38?X.ccRU(3):S===39?X.ccRU(4):S===40?X.ccFON():S===41?X.ccRDC():S===42?X.ccTR():S===43?X.ccRTD():S===44?X.ccEDM():S===45?X.ccCR():S===46?X.ccENM():S===47&&X.ccEOC():X.ccTO(S-32),m(o,S,y),this.currentChannel=G,!0},p.parseMidrow=function(o,S){var y=0;if((o===17||o===25)&&S>=32&&S<=47){if(o===17?y=1:y=2,y!==this.currentChannel)return this.logger.log(L.ERROR,"Mismatch channel in midrow parsing"),!1;var T=this.channels[y];return T?(T.ccMIDROW(S),this.logger.log(L.DEBUG,"MIDROW ("+x([o,S])+")"),!0):!1}return!1},p.parsePAC=function(o,S){var y,T=this.cmdHistory,I=(o>=17&&o<=23||o>=25&&o<=31)&&S>=64&&S<=127,G=(o===16||o===24)&&S>=64&&S<=95;if(!(I||G))return!1;if(k(o,S,T))return m(null,null,T),!0;var X=o<=23?1:2;S>=64&&S<=95?y=X===1?P[o]:b[o]:y=X===1?O[o]:A[o];var Q=this.channels[X];return Q?(Q.setPAC(this.interpretPAC(y,S)),m(o,S,T),this.currentChannel=X,!0):!1},p.interpretPAC=function(o,S){var y,T={color:null,italics:!1,indent:null,underline:!1,row:o};return S>95?y=S-96:y=S-64,T.underline=(y&1)===1,y<=13?T.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(y/2)]:y<=15?(T.italics=!0,T.color="white"):T.indent=Math.floor((y-16)/2)*4,T},p.parseChars=function(o,S){var y,T=null,I=null;if(o>=25?(y=2,I=o-8):(y=1,I=o),I>=17&&I<=19){var G;I===17?G=S+80:I===18?G=S+112:G=S+144,this.logger.log(L.INFO,"Special char '"+M(G)+"' in channel "+y),T=[G]}else o>=32&&o<=127&&(T=S===0?[o]:[o,S]);if(T){var X=x(T);this.logger.log(L.DEBUG,"Char codes = "+X.join(",")),m(o,S,this.cmdHistory)}return T},p.parseBackgroundAttributes=function(o,S){var y=(o===16||o===24)&&S>=32&&S<=47,T=(o===23||o===31)&&S>=45&&S<=47;if(!(y||T))return!1;var I,G={};o===16||o===24?(I=Math.floor((S-32)/2),G.background=D[I],S%2===1&&(G.background=G.background+"_semi")):S===45?G.background="transparent":(G.foreground="black",S===47&&(G.underline=!0));var X=o<=23?1:2,Q=this.channels[X];return Q.setBkgData(G),m(o,S,this.cmdHistory),!0},p.reset=function(){for(var o=0;o<Object.keys(this.channels).length;o++){var S=this.channels[o];S&&S.reset()}this.cmdHistory=v()},p.cueSplitAtTime=function(o){for(var S=0;S<this.channels.length;S++){var y=this.channels[S];y&&y.cueSplitAtTime(o)}},f}();function m(f,p,d){d.a=f,d.b=p}function k(f,p,d){return d.a===f&&d.b===p}function v(){return{a:null,b:null}}$.default=g},"./src/utils/codecs.ts":function(ne,$,_){"use strict";_.r($),_.d($,"isCodecType",function(){return N}),_.d($,"isCodecSupportedInMp4",function(){return M});var V={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function N(H,F){var P=V[F];return!!P&&P[H.slice(0,4)]===!0}function M(H,F){return MediaSource.isTypeSupported((F||"video")+'/mp4;codecs="'+H+'"')}},"./src/utils/cues.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/utils/vttparser.ts"),N=_("./src/utils/webvtt-parser.ts"),M=_("./src/utils/texttrack-utils.ts"),H=/\s/,F={newCue:function(O,b,A,D){for(var L=[],w,x,u,a,l,h=self.VTTCue||self.TextTrackCue,C=0;C<D.rows.length;C++)if(w=D.rows[C],u=!0,a=0,l="",!w.isEmpty()){for(var g=0;g<w.chars.length;g++)H.test(w.chars[g].uchar)&&u?a++:(l+=w.chars[g].uchar,u=!1);w.cueStartTime=b,b===A&&(A+=1e-4),a>=16?a--:a++;var m=Object(V.fixLineBreaks)(l.trim()),k=Object(N.generateCueId)(b,A,m);(!O||!O.cues||!O.cues.getCueById(k))&&(x=new h(b,A,m),x.id=k,x.line=C+1,x.align="left",x.position=10+Math.min(80,Math.floor(a*8/32)*10),L.push(x))}return O&&L.length&&(L.sort(function(v,f){return v.line==="auto"||f.line==="auto"?0:v.line>8&&f.line>8?f.line-v.line:v.line-f.line}),L.forEach(function(v){return Object(M.addCueToTrack)(O,v)})),L}};$.default=F},"./src/utils/discontinuities.ts":function(ne,$,_){"use strict";_.r($),_.d($,"findFirstFragWithCC",function(){return H}),_.d($,"shouldAlignOnDiscontinuities",function(){return F}),_.d($,"findDiscontinuousReferenceFrag",function(){return P}),_.d($,"adjustSlidingStart",function(){return b}),_.d($,"alignStream",function(){return A}),_.d($,"alignPDT",function(){return L}),_.d($,"alignFragmentByPDTDelta",function(){return w}),_.d($,"alignMediaPlaylistByPDT",function(){return x});var V=_("./src/polyfills/number.ts"),N=_("./src/utils/logger.ts"),M=_("./src/controller/level-helper.ts");function H(u,a){for(var l=null,h=0,C=u.length;h<C;h++){var g=u[h];if(g&&g.cc===a){l=g;break}}return l}function F(u,a,l){return!!(a.details&&(l.endCC>l.startCC||u&&u.cc<l.startCC))}function P(u,a){var l=u.fragments,h=a.fragments;if(!h.length||!l.length){N.logger.log("No fragments to align");return}var C=H(l,h[0].cc);if(!C||C&&!C.startPTS){N.logger.log("No frag in previous level to align on");return}return C}function O(u,a){if(u){var l=u.start+a;u.start=u.startPTS=l,u.endPTS=l+u.duration}}function b(u,a){for(var l=a.fragments,h=0,C=l.length;h<C;h++)O(l[h],u);a.fragmentHint&&O(a.fragmentHint,u),a.alignedSliding=!0}function A(u,a,l){if(!a)return;D(u,l,a),!l.alignedSliding&&a.details&&L(l,a.details),!l.alignedSliding&&a.details&&!l.skippedSegments&&Object(M.adjustSliding)(a.details,l)}function D(u,a,l){if(F(u,l,a)){var h=P(l.details,a);h&&Object(V.isFiniteNumber)(h.start)&&(N.logger.log("Adjusting PTS using last level due to CC increase within current level "+a.url),b(h.start,a))}}function L(u,a){if(!a.fragments.length||!u.hasProgramDateTime||!a.hasProgramDateTime)return;var l=a.fragments[0].programDateTime,h=u.fragments[0].programDateTime,C=(h-l)/1e3+a.fragments[0].start;C&&Object(V.isFiniteNumber)(C)&&(N.logger.log("Adjusting PTS using programDateTime delta "+(h-l)+"ms, sliding:"+C.toFixed(3)+" "+u.url+" "),b(C,u))}function w(u,a){var l=u.programDateTime;if(!l)return;var h=(l-a)/1e3;u.start=u.startPTS=h,u.endPTS=h+u.duration}function x(u,a){if(!a.fragments.length||!u.hasProgramDateTime||!a.hasProgramDateTime)return;var l=a.fragments[0].programDateTime,h=a.fragments[0].start,C=l-h*1e3;u.fragments.forEach(function(g){w(g,C)}),u.fragmentHint&&w(u.fragmentHint,C),u.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/utils/ewma.ts"),N=function(){function M(F,P,O){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=O,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new V.default(F),this.fast_=new V.default(P)}var H=M.prototype;return H.update=function(P,O){var b=this.slow_,A=this.fast_;this.slow_.halfLife!==P&&(this.slow_=new V.default(P,b.getEstimate(),b.getTotalWeight())),this.fast_.halfLife!==O&&(this.fast_=new V.default(O,A.getEstimate(),A.getTotalWeight()))},H.sample=function(P,O){P=Math.max(P,this.minDelayMs_);var b=8*O,A=P/1e3,D=b/A;this.fast_.sample(A,D),this.slow_.sample(A,D)},H.canEstimate=function(){var P=this.fast_;return P&&P.getTotalWeight()>=this.minWeight_},H.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},H.destroy=function(){},M}();$.default=N},"./src/utils/ewma.ts":function(ne,$,_){"use strict";_.r($);var V=function(){function N(H,F,P){F===void 0&&(F=0),P===void 0&&(P=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=H,this.alpha_=H?Math.exp(Math.log(.5)/H):0,this.estimate_=F,this.totalWeight_=P}var M=N.prototype;return M.sample=function(F,P){var O=Math.pow(this.alpha_,F);this.estimate_=P*(1-O)+O*this.estimate_,this.totalWeight_+=F},M.getTotalWeight=function(){return this.totalWeight_},M.getEstimate=function(){if(this.alpha_){var F=1-Math.pow(this.alpha_,this.totalWeight_);if(F)return this.estimate_/F}return this.estimate_},N}();$.default=V},"./src/utils/fetch-loader.ts":function(ne,$,_){"use strict";_.r($),_.d($,"fetchSupported",function(){return w});var V=_("./src/polyfills/number.ts"),N=_("./src/loader/load-stats.ts"),M=_("./src/demux/chunk-cache.ts");function H(h,C){h.prototype=Object.create(C.prototype),h.prototype.constructor=h,A(h,C)}function F(h){var C=typeof Map=="function"?new Map:void 0;return F=function(m){if(m===null||!b(m))return m;if(typeof m!="function")throw new TypeError("Super expression must either be null or a function");if(typeof C!="undefined"){if(C.has(m))return C.get(m);C.set(m,k)}function k(){return P(m,arguments,D(this).constructor)}return k.prototype=Object.create(m.prototype,{constructor:{value:k,enumerable:!1,writable:!0,configurable:!0}}),A(k,m)},F(h)}function P(h,C,g){return O()?P=Reflect.construct:P=function(k,v,f){var p=[null];p.push.apply(p,v);var d=Function.bind.apply(k,p),o=new d;return f&&A(o,f.prototype),o},P.apply(null,arguments)}function O(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(h){return!1}}function b(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function A(h,C){return A=Object.setPrototypeOf||function(m,k){return m.__proto__=k,m},A(h,C)}function D(h){return D=Object.setPrototypeOf?Object.getPrototypeOf:function(g){return g.__proto__||Object.getPrototypeOf(g)},D(h)}function L(){return L=Object.assign||function(h){for(var C=1;C<arguments.length;C++){var g=arguments[C];for(var m in g)Object.prototype.hasOwnProperty.call(g,m)&&(h[m]=g[m])}return h},L.apply(this,arguments)}function w(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(h){}return!1}var x=function(){function h(g){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=g.fetchSetup||a,this.controller=new self.AbortController,this.stats=new N.LoadStats}var C=h.prototype;return C.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},C.abortInternal=function(){var m=this.response;(!m||!m.ok)&&(this.stats.aborted=!0,this.controller.abort())},C.abort=function(){var m;this.abortInternal(),(m=this.callbacks)!==null&&m!==void 0&&m.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},C.load=function(m,k,v){var f=this,p=this.stats;if(p.loading.start)throw new Error("Loader can only be used once.");p.loading.start=self.performance.now();var d=u(m,this.controller.signal),o=v.onProgress,S=m.responseType==="arraybuffer",y=S?"byteLength":"length";this.context=m,this.config=k,this.callbacks=v,this.request=this.fetchSetup(m,d),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){f.abortInternal(),v.onTimeout(p,m,f.response)},k.timeout),self.fetch(this.request).then(function(T){if(f.response=f.loader=T,!T.ok){var I=T.status,G=T.statusText;throw new l(G||"fetch, bad network response",I,T)}return p.loading.first=Math.max(self.performance.now(),p.loading.start),p.total=parseInt(T.headers.get("Content-Length")||"0"),o&&Object(V.isFiniteNumber)(k.highWaterMark)?f.loadProgressively(T,p,m,k.highWaterMark,o):S?T.arrayBuffer():T.text()}).then(function(T){var I=f.response;self.clearTimeout(f.requestTimeout),p.loading.end=Math.max(self.performance.now(),p.loading.first),p.loaded=p.total=T[y];var G={url:I.url,data:T};o&&!Object(V.isFiniteNumber)(k.highWaterMark)&&o(p,m,T,I),v.onSuccess(G,p,m,I)}).catch(function(T){if(self.clearTimeout(f.requestTimeout),p.aborted)return;var I=T.code||0;v.onError({code:I,text:T.message},m,T.details)})},C.getCacheAge=function(){var m=null;if(this.response){var k=this.response.headers.get("age");m=k?parseFloat(k):null}return m},C.loadProgressively=function(m,k,v,f,p){f===void 0&&(f=0);var d=new M.default,o=m.body.getReader(),S=function y(){return o.read().then(function(T){if(T.done)return d.dataLength&&p(k,v,d.flush(),m),Promise.resolve(new ArrayBuffer(0));var I=T.value,G=I.length;return k.loaded+=G,G<f||d.dataLength?(d.push(I),d.dataLength>=f&&p(k,v,d.flush(),m)):p(k,v,I,m),y()}).catch(function(){return Promise.reject()})};return S()},h}();function u(h,C){var g={method:"GET",mode:"cors",credentials:"same-origin",signal:C,headers:new self.Headers(L({},h.headers))};return h.rangeEnd&&g.headers.set("Range","bytes="+h.rangeStart+"-"+String(h.rangeEnd-1)),g}function a(h,C){return new self.Request(h.url,C)}var l=function(h){H(C,h);function C(g,m,k){var v;return v=h.call(this,g)||this,v.code=void 0,v.details=void 0,v.code=m,v.details=k,v}return C}(F(Error));$.default=x},"./src/utils/imsc1-ttml-parser.ts":function(ne,$,_){"use strict";_.r($),_.d($,"IMSC1_CODEC",function(){return b}),_.d($,"parseIMSC1",function(){return w});var V=_("./src/utils/mp4-tools.ts"),N=_("./src/utils/vttparser.ts"),M=_("./src/utils/vttcue.ts"),H=_("./src/demux/id3.ts"),F=_("./src/utils/timescale-conversion.ts"),P=_("./src/utils/webvtt-parser.ts");function O(){return O=Object.assign||function(f){for(var p=1;p<arguments.length;p++){var d=arguments[p];for(var o in d)Object.prototype.hasOwnProperty.call(d,o)&&(f[o]=d[o])}return f},O.apply(this,arguments)}var b="stpp.ttml.im1t",A=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,D=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,L={left:"start",center:"center",right:"end",start:"start",end:"end"};function w(f,p,d,o,S){var y=Object(V.findBox)(new Uint8Array(f),["mdat"]);if(y.length===0){S(new Error("Could not parse IMSC1 mdat"));return}var T=y[0],I=Object(H.utf8ArrayToStr)(new Uint8Array(f,T.start,T.end-T.start)),G=Object(F.toTimescaleFromScale)(p,1,d);try{o(x(I,G))}catch(X){S(X)}}function x(f,p){var d=new DOMParser,o=d.parseFromString(f,"text/xml"),S=o.getElementsByTagName("tt")[0];if(!S)throw new Error("Invalid ttml");var y={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},T=Object.keys(y).reduce(function(z,W){return z[W]=S.getAttribute("ttp:"+W)||y[W],z},{}),I=S.getAttribute("xml:space")!=="preserve",G=a(u(S,"styling","style")),X=a(u(S,"layout","region")),Q=u(S,"body","[begin]");return[].map.call(Q,function(z){var W=l(z,I);if(!W||!z.hasAttribute("begin"))return null;var ee=m(z.getAttribute("begin"),T),ae=m(z.getAttribute("dur"),T),pe=m(z.getAttribute("end"),T);if(ee===null)throw g(z);if(pe===null){if(ae===null)throw g(z);pe=ee+ae}var ve=new M.default(ee-p,pe-p,W);ve.id=Object(P.generateCueId)(ve.startTime,ve.endTime,ve.text);var De=X[z.getAttribute("region")],xe=G[z.getAttribute("style")];ve.position=10,ve.size=80;var Ce=h(De,xe),Ae=Ce.textAlign;if(Ae){var Se=L[Ae];Se&&(ve.lineAlign=Se),ve.align=Ae}return O(ve,Ce),ve}).filter(function(z){return z!==null})}function u(f,p,d){var o=f.getElementsByTagName(p)[0];return o?[].slice.call(o.querySelectorAll(d)):[]}function a(f){return f.reduce(function(p,d){var o=d.getAttribute("xml:id");return o&&(p[o]=d),p},{})}function l(f,p){return[].slice.call(f.childNodes).reduce(function(d,o,S){var y;return o.nodeName==="br"&&S?d+`
|
|
`:(y=o.childNodes)!==null&&y!==void 0&&y.length?l(o,p):p?d+o.textContent.trim().replace(/\s+/g," "):d+o.textContent},"")}function h(f,p){var d="http://www.w3.org/ns/ttml#styling",o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return o.reduce(function(S,y){var T=C(p,d,y)||C(f,d,y);return T&&(S[y]=T),S},{})}function C(f,p,d){return f.hasAttributeNS(p,d)?f.getAttributeNS(p,d):null}function g(f){return new Error("Could not parse ttml timestamp "+f)}function m(f,p){if(!f)return null;var d=Object(N.parseTimeStamp)(f);return d===null&&(A.test(f)?d=k(f,p):D.test(f)&&(d=v(f,p))),d}function k(f,p){var d=A.exec(f),o=(d[4]|0)+(d[5]|0)/p.subFrameRate;return(d[1]|0)*3600+(d[2]|0)*60+(d[3]|0)+o/p.frameRate}function v(f,p){var d=D.exec(f),o=Number(d[1]),S=d[2];switch(S){case"h":return o*3600;case"m":return o*60;case"ms":return o*1e3;case"f":return o/p.frameRate;case"t":return o/p.tickRate}return o}},"./src/utils/logger.ts":function(ne,$,_){"use strict";_.r($),_.d($,"enableLogs",function(){return P}),_.d($,"logger",function(){return O});var V=function(){},N={trace:V,debug:V,log:V,warn:V,info:V,error:V},M=N;function H(b){var A=self.console[b];return A?A.bind(self.console,"["+b+"] >"):V}function F(b){for(var A=arguments.length,D=new Array(A>1?A-1:0),L=1;L<A;L++)D[L-1]=arguments[L];D.forEach(function(w){M[w]=b[w]?b[w].bind(b):H(w)})}function P(b){if(self.console&&b===!0||typeof b=="object"){F(b,"debug","log","info","warn","error");try{M.log()}catch(A){M=N}}else M=N}var O=M},"./src/utils/mediakeys-helper.ts":function(ne,$,_){"use strict";_.r($),_.d($,"KeySystems",function(){return V}),_.d($,"requestMediaKeySystemAccess",function(){return N});var V;(function(M){M.WIDEVINE="com.widevine.alpha",M.PLAYREADY="com.microsoft.playready"})(V||(V={}));var N=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(ne,$,_){"use strict";_.r($),_.d($,"getMediaSource",function(){return V});function V(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(ne,$,_){"use strict";_.r($),_.d($,"bin2str",function(){return F}),_.d($,"readUint16",function(){return P}),_.d($,"readUint32",function(){return O}),_.d($,"writeUint32",function(){return b}),_.d($,"findBox",function(){return A}),_.d($,"parseSegmentIndex",function(){return D}),_.d($,"parseInitSegment",function(){return L}),_.d($,"getStartDTS",function(){return w}),_.d($,"getDuration",function(){return x}),_.d($,"computeRawDurationFromSamples",function(){return u}),_.d($,"offsetStartDTS",function(){return a}),_.d($,"segmentValidRange",function(){return l}),_.d($,"appendUint8Array",function(){return h});var V=_("./src/utils/typed-array.ts"),N=_("./src/loader/fragment.ts"),M=Math.pow(2,32)-1,H=[].push;function F(C){return String.fromCharCode.apply(null,C)}function P(C,g){"data"in C&&(g+=C.start,C=C.data);var m=C[g]<<8|C[g+1];return m<0?65536+m:m}function O(C,g){"data"in C&&(g+=C.start,C=C.data);var m=C[g]<<24|C[g+1]<<16|C[g+2]<<8|C[g+3];return m<0?4294967296+m:m}function b(C,g,m){"data"in C&&(g+=C.start,C=C.data),C[g]=m>>24,C[g+1]=m>>16&255,C[g+2]=m>>8&255,C[g+3]=m&255}function A(C,g){var m=[];if(!g.length)return m;var k,v,f;"data"in C?(k=C.data,v=C.start,f=C.end):(k=C,v=0,f=k.byteLength);for(var p=v;p<f;){var d=O(k,p),o=F(k.subarray(p+4,p+8)),S=d>1?p+d:f;if(o===g[0])if(g.length===1)m.push({data:k,start:p+8,end:S});else{var y=A({data:k,start:p+8,end:S},g.slice(1));y.length&&H.apply(m,y)}p=S}return m}function D(C){var g=A(C,["moov"]),m=g[0],k=m?m.end:null,v=A(C,["sidx"]);if(!v||!v[0])return null;var f=[],p=v[0],d=p.data[0],o=d===0?8:16,S=O(p,o);o+=4;var y=0,T=0;d===0?o+=8:o+=16,o+=2;var I=p.end+T,G=P(p,o);o+=2;for(var X=0;X<G;X++){var Q=o,z=O(p,Q);Q+=4;var W=z&2147483647,ee=(z&2147483648)>>>31;if(ee===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var ae=O(p,Q);Q+=4,f.push({referenceSize:W,subsegmentDuration:ae,info:{duration:ae/S,start:I,end:I+W-1}}),I+=W,Q+=4,o=Q}return{earliestPresentationTime:y,timescale:S,version:d,referencesCount:G,references:f,moovEndOffset:k}}function L(C){for(var g=[],m=A(C,["moov","trak"]),k=0;k<m.length;k++){var v=m[k],f=A(v,["tkhd"])[0];if(f){var p=f.data[f.start],d=p===0?12:20,o=O(f,d),S=A(v,["mdia","mdhd"])[0];if(S){p=S.data[S.start],d=p===0?12:20;var y=O(S,d),T=A(v,["mdia","hdlr"])[0];if(T){var I=F(T.data.subarray(T.start+8,T.start+12)),G={soun:N.ElementaryStreamTypes.AUDIO,vide:N.ElementaryStreamTypes.VIDEO}[I];if(G){var X=A(v,["mdia","minf","stbl","stsd"])[0],Q=void 0;X&&(Q=F(X.data.subarray(X.start+12,X.start+16))),g[o]={timescale:y,type:G},g[G]={timescale:y,id:o,codec:Q}}}}}}var z=A(C,["moov","mvex","trex"]);return z.forEach(function(W){var ee=O(W,4),ae=g[ee];ae&&(ae.default={duration:O(W,12),flags:O(W,20)})}),g}function w(C,g){return A(g,["moof","traf"]).reduce(function(m,k){var v=A(k,["tfdt"])[0],f=v.data[v.start],p=A(k,["tfhd"]).reduce(function(d,o){var S=O(o,4),y=C[S];if(y){var T=O(v,4);f===1&&(T*=Math.pow(2,32),T+=O(v,8));var I=y.timescale||9e4,G=T/I;if(isFinite(G)&&(d===null||G<d))return G}return d},null);return p!==null&&isFinite(p)&&(m===null||p<m)?p:m},null)||0}function x(C,g){for(var m=0,k=0,v=0,f=A(C,["moof","traf"]),p=0;p<f.length;p++){var d=f[p],o=A(d,["tfhd"])[0],S=O(o,4),y=g[S];if(!y)continue;var T=y.default,I=O(o,0)|(T==null?void 0:T.flags),G=T==null?void 0:T.duration;I&8&&(I&2?G=O(o,12):G=O(o,8));for(var X=y.timescale||9e4,Q=A(d,["trun"]),z=0;z<Q.length;z++){if(G){var W=O(Q[z],4);m=G*W}else m=u(Q[z]);y.type===N.ElementaryStreamTypes.VIDEO?k+=m/X:y.type===N.ElementaryStreamTypes.AUDIO&&(v+=m/X)}}if(k===0&&v===0){var ee=D(C);if(ee!=null&&ee.references)return ee.references.reduce(function(ae,pe){return ae+pe.info.duration||0},0)}return k||v}function u(C){var g=O(C,0),m=8;g&1&&(m+=4),g&4&&(m+=4);for(var k=0,v=O(C,4),f=0;f<v;f++){if(g&256){var p=O(C,m);k+=p,m+=4}g&512&&(m+=4),g&1024&&(m+=4),g&2048&&(m+=4)}return k}function a(C,g,m){A(g,["moof","traf"]).forEach(function(k){A(k,["tfhd"]).forEach(function(v){var f=O(v,4),p=C[f];if(!p)return;var d=p.timescale||9e4;A(k,["tfdt"]).forEach(function(o){var S=o.data[o.start],y=O(o,4);if(S===0)b(o,4,y-m*d);else{y*=Math.pow(2,32),y+=O(o,8),y-=m*d,y=Math.max(y,0);var T=Math.floor(y/(M+1)),I=Math.floor(y%(M+1));b(o,4,T),b(o,8,I)}})})})}function l(C){var g={valid:null,remainder:null},m=A(C,["moof"]);if(m){if(m.length<2)return g.remainder=C,g}else return g;var k=m[m.length-1];return g.valid=Object(V.sliceUint8)(C,0,k.start-8),g.remainder=Object(V.sliceUint8)(C,k.start-8),g}function h(C,g){var m=new Uint8Array(C.length+g.length);return m.set(C),m.set(g,C.length),m}},"./src/utils/output-filter.ts":function(ne,$,_){"use strict";_.r($),_.d($,"default",function(){return V});var V=function(){function N(H,F){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=H,this.trackName=F}var M=N.prototype;return M.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},M.newCue=function(F,P,O){(this.startTime===null||this.startTime>F)&&(this.startTime=F),this.endTime=P,this.screen=O,this.timelineController.createCaptionsTrack(this.trackName)},M.reset=function(){this.cueRanges=[]},N}()},"./src/utils/texttrack-utils.ts":function(ne,$,_){"use strict";_.r($),_.d($,"sendAddTrackEvent",function(){return N}),_.d($,"addCueToTrack",function(){return M}),_.d($,"clearCurrentCues",function(){return H}),_.d($,"removeCuesInRange",function(){return F}),_.d($,"getCuesInRange",function(){return O});var V=_("./src/utils/logger.ts");function N(b,A){var D;try{D=new Event("addtrack")}catch(L){D=document.createEvent("Event"),D.initEvent("addtrack",!1,!1)}D.track=b,A.dispatchEvent(D)}function M(b,A){var D=b.mode;if(D==="disabled"&&(b.mode="hidden"),b.cues&&!b.cues.getCueById(A.id))try{if(b.addCue(A),!b.cues.getCueById(A.id))throw new Error("addCue is failed for: "+A)}catch(w){V.logger.debug("[texttrack-utils]: "+w);var L=new self.TextTrackCue(A.startTime,A.endTime,A.text);L.id=A.id,b.addCue(L)}D==="disabled"&&(b.mode=D)}function H(b){var A=b.mode;if(A==="disabled"&&(b.mode="hidden"),b.cues)for(var D=b.cues.length;D--;)b.removeCue(b.cues[D]);A==="disabled"&&(b.mode=A)}function F(b,A,D){var L=b.mode;if(L==="disabled"&&(b.mode="hidden"),b.cues&&b.cues.length>0)for(var w=O(b.cues,A,D),x=0;x<w.length;x++)b.removeCue(w[x]);L==="disabled"&&(b.mode=L)}function P(b,A){if(A<b[0].startTime)return 0;var D=b.length-1;if(A>b[D].endTime)return-1;for(var L=0,w=D;L<=w;){var x=Math.floor((w+L)/2);if(A<b[x].startTime)w=x-1;else if(A>b[x].startTime&&L<D)L=x+1;else return x}return b[L].startTime-A<A-b[w].startTime?L:w}function O(b,A,D){var L=[],w=P(b,A);if(w>-1)for(var x=w,u=b.length;x<u;x++){var a=b[x];if(a.startTime>=A&&a.endTime<=D)L.push(a);else if(a.startTime>D)return L}return L}},"./src/utils/time-ranges.ts":function(ne,$,_){"use strict";_.r($);var V={toString:function(M){for(var H="",F=M.length,P=0;P<F;P++)H+="["+M.start(P).toFixed(3)+","+M.end(P).toFixed(3)+"]";return H}};$.default=V},"./src/utils/timescale-conversion.ts":function(ne,$,_){"use strict";_.r($),_.d($,"toTimescaleFromBase",function(){return N}),_.d($,"toTimescaleFromScale",function(){return M}),_.d($,"toMsFromMpegTsClock",function(){return H}),_.d($,"toMpegTsClockFromTimescale",function(){return F});var V=9e4;function N(P,O,b,A){b===void 0&&(b=1),A===void 0&&(A=!1);var D=P*O*b;return A?Math.round(D):D}function M(P,O,b,A){return b===void 0&&(b=1),A===void 0&&(A=!1),N(P,O,1/b,A)}function H(P,O){return O===void 0&&(O=!1),N(P,1e3,1/V,O)}function F(P,O){return O===void 0&&(O=1),N(P,V,1/O)}},"./src/utils/typed-array.ts":function(ne,$,_){"use strict";_.r($),_.d($,"sliceUint8",function(){return V});function V(N,M,H){return Uint8Array.prototype.slice?N.slice(M,H):new Uint8Array(Array.prototype.slice.call(N,M,H))}},"./src/utils/vttcue.ts":function(ne,$,_){"use strict";_.r($),$.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var V=["","lr","rl"],N=["start","middle","end","left","right"];function M(b,A){if(typeof A!="string")return!1;if(!Array.isArray(b))return!1;var D=A.toLowerCase();return~b.indexOf(D)?D:!1}function H(b){return M(V,b)}function F(b){return M(N,b)}function P(b){for(var A=arguments.length,D=new Array(A>1?A-1:0),L=1;L<A;L++)D[L-1]=arguments[L];for(var w=1;w<arguments.length;w++){var x=arguments[w];for(var u in x)b[u]=x[u]}return b}function O(b,A,D){var L=this,w={enumerable:!0};L.hasBeenReset=!1;var x="",u=!1,a=b,l=A,h=D,C=null,g="",m=!0,k="auto",v="start",f=50,p="middle",d=50,o="middle";Object.defineProperty(L,"id",P({},w,{get:function(){return x},set:function(y){x=""+y}})),Object.defineProperty(L,"pauseOnExit",P({},w,{get:function(){return u},set:function(y){u=!!y}})),Object.defineProperty(L,"startTime",P({},w,{get:function(){return a},set:function(y){if(typeof y!="number")throw new TypeError("Start time must be set to a number.");a=y,this.hasBeenReset=!0}})),Object.defineProperty(L,"endTime",P({},w,{get:function(){return l},set:function(y){if(typeof y!="number")throw new TypeError("End time must be set to a number.");l=y,this.hasBeenReset=!0}})),Object.defineProperty(L,"text",P({},w,{get:function(){return h},set:function(y){h=""+y,this.hasBeenReset=!0}})),Object.defineProperty(L,"region",P({},w,{get:function(){return C},set:function(y){C=y,this.hasBeenReset=!0}})),Object.defineProperty(L,"vertical",P({},w,{get:function(){return g},set:function(y){var T=H(y);if(T===!1)throw new SyntaxError("An invalid or illegal string was specified.");g=T,this.hasBeenReset=!0}})),Object.defineProperty(L,"snapToLines",P({},w,{get:function(){return m},set:function(y){m=!!y,this.hasBeenReset=!0}})),Object.defineProperty(L,"line",P({},w,{get:function(){return k},set:function(y){if(typeof y!="number"&&y!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");k=y,this.hasBeenReset=!0}})),Object.defineProperty(L,"lineAlign",P({},w,{get:function(){return v},set:function(y){var T=F(y);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");v=T,this.hasBeenReset=!0}})),Object.defineProperty(L,"position",P({},w,{get:function(){return f},set:function(y){if(y<0||y>100)throw new Error("Position must be between 0 and 100.");f=y,this.hasBeenReset=!0}})),Object.defineProperty(L,"positionAlign",P({},w,{get:function(){return p},set:function(y){var T=F(y);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");p=T,this.hasBeenReset=!0}})),Object.defineProperty(L,"size",P({},w,{get:function(){return d},set:function(y){if(y<0||y>100)throw new Error("Size must be between 0 and 100.");d=y,this.hasBeenReset=!0}})),Object.defineProperty(L,"align",P({},w,{get:function(){return o},set:function(y){var T=F(y);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");o=T,this.hasBeenReset=!0}})),L.displayState=void 0}return O.prototype.getCueAsHTML=function(){var b=self.WebVTT;return b.convertCueToDOMTree(self,this.text)},O}()},"./src/utils/vttparser.ts":function(ne,$,_){"use strict";_.r($),_.d($,"parseTimeStamp",function(){return M}),_.d($,"fixLineBreaks",function(){return A}),_.d($,"VTTParser",function(){return D});var V=_("./src/utils/vttcue.ts"),N=function(){function L(){}var w=L.prototype;return w.decode=function(u,a){if(!u)return"";if(typeof u!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(u))},L}();function M(L){function w(u,a,l,h){return(u|0)*3600+(a|0)*60+(l|0)+parseFloat(h||0)}var x=L.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return x?parseFloat(x[2])>59?w(x[2],x[3],0,x[4]):w(x[1],x[2],x[3],x[4]):null}var H=function(){function L(){this.values=Object.create(null)}var w=L.prototype;return w.set=function(u,a){!this.get(u)&&a!==""&&(this.values[u]=a)},w.get=function(u,a,l){return l?this.has(u)?this.values[u]:a[l]:this.has(u)?this.values[u]:a},w.has=function(u){return u in this.values},w.alt=function(u,a,l){for(var h=0;h<l.length;++h)if(a===l[h]){this.set(u,a);break}},w.integer=function(u,a){/^-?\d+$/.test(a)&&this.set(u,parseInt(a,10))},w.percent=function(u,a){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(a)){var l=parseFloat(a);if(l>=0&&l<=100)return this.set(u,l),!0}return!1},L}();function F(L,w,x,u){var a=u?L.split(u):[L];for(var l in a){if(typeof a[l]!="string")continue;var h=a[l].split(x);if(h.length!==2)continue;var C=h[0],g=h[1];w(C,g)}}var P=new V.default(0,0,""),O=P.align==="middle"?"middle":"center";function b(L,w,x){var u=L;function a(){var C=M(L);if(C===null)throw new Error("Malformed timestamp: "+u);return L=L.replace(/^[^\sa-zA-Z-]+/,""),C}function l(C,g){var m=new H;F(C,function(f,p){var d;switch(f){case"region":for(var o=x.length-1;o>=0;o--)if(x[o].id===p){m.set(f,x[o].region);break}break;case"vertical":m.alt(f,p,["rl","lr"]);break;case"line":d=p.split(","),m.integer(f,d[0]),m.percent(f,d[0])&&m.set("snapToLines",!1),m.alt(f,d[0],["auto"]),d.length===2&&m.alt("lineAlign",d[1],["start",O,"end"]);break;case"position":d=p.split(","),m.percent(f,d[0]),d.length===2&&m.alt("positionAlign",d[1],["start",O,"end","line-left","line-right","auto"]);break;case"size":m.percent(f,p);break;case"align":m.alt(f,p,["start",O,"end","left","right"]);break}},/:/,/\s/),g.region=m.get("region",null),g.vertical=m.get("vertical","");var k=m.get("line","auto");k==="auto"&&P.line===-1&&(k=-1),g.line=k,g.lineAlign=m.get("lineAlign","start"),g.snapToLines=m.get("snapToLines",!0),g.size=m.get("size",100),g.align=m.get("align",O);var v=m.get("position","auto");v==="auto"&&P.position===50&&(v=g.align==="start"||g.align==="left"?0:g.align==="end"||g.align==="right"?100:50),g.position=v}function h(){L=L.replace(/^\s+/,"")}if(h(),w.startTime=a(),h(),L.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+u);L=L.substr(3),h(),w.endTime=a(),h(),l(L,w)}function A(L){return L.replace(/<br(?: \/)?>/gi,`
|
|
`)}var D=function(){function L(){this.state="INITIAL",this.buffer="",this.decoder=new N,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var w=L.prototype;return w.parse=function(u){var a=this;u&&(a.buffer+=a.decoder.decode(u,{stream:!0}));function l(){var v=a.buffer,f=0;for(v=A(v);f<v.length&&v[f]!=="\r"&&v[f]!==`
|
|
`;)++f;var p=v.substr(0,f);return v[f]==="\r"&&++f,v[f]===`
|
|
`&&++f,a.buffer=v.substr(f),p}function h(v){F(v,function(f,p){},/:/)}try{var C="";if(a.state==="INITIAL"){if(!/\r\n|\n/.test(a.buffer))return this;C=l();var g=C.match(/^()?WEBVTT([ \t].*)?$/);if(!g||!g[0])throw new Error("Malformed WebVTT signature.");a.state="HEADER"}for(var m=!1;a.buffer;){if(!/\r\n|\n/.test(a.buffer))return this;m?m=!1:C=l();switch(a.state){case"HEADER":/:/.test(C)?h(C):C||(a.state="ID");continue;case"NOTE":C||(a.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(C)){a.state="NOTE";break}if(!C)continue;if(a.cue=new V.default(0,0,""),a.state="CUE",C.indexOf("-->")===-1){a.cue.id=C;continue}case"CUE":if(!a.cue){a.state="BADCUE";continue}try{b(C,a.cue,a.regionList)}catch(v){a.cue=null,a.state="BADCUE";continue}a.state="CUETEXT";continue;case"CUETEXT":{var k=C.indexOf("-->")!==-1;if(!C||k&&(m=!0)){a.oncue&&a.cue&&a.oncue(a.cue),a.cue=null,a.state="ID";continue}if(a.cue===null)continue;a.cue.text&&(a.cue.text+=`
|
|
`),a.cue.text+=C}continue;case"BADCUE":C||(a.state="ID")}}}catch(v){a.state==="CUETEXT"&&a.cue&&a.oncue&&a.oncue(a.cue),a.cue=null,a.state=a.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},w.flush=function(){var u=this;try{if((u.cue||u.state==="HEADER")&&(u.buffer+=`
|
|
|
|
`,u.parse()),u.state==="INITIAL"||u.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(a){u.onparsingerror&&u.onparsingerror(a)}return u.onflush&&u.onflush(),this},L}()},"./src/utils/webvtt-parser.ts":function(ne,$,_){"use strict";_.r($),_.d($,"generateCueId",function(){return D}),_.d($,"parseWebVTT",function(){return w});var V=_("./src/polyfills/number.ts"),N=_("./src/utils/vttparser.ts"),M=_("./src/demux/id3.ts"),H=_("./src/utils/timescale-conversion.ts"),F=_("./src/remux/mp4-remuxer.ts"),P=/\r\n|\n\r|\n|\r/g,O=function(u,a,l){return l===void 0&&(l=0),u.substr(l,a.length)===a},b=function(u){var a=parseInt(u.substr(-3)),l=parseInt(u.substr(-6,2)),h=parseInt(u.substr(-9,2)),C=u.length>9?parseInt(u.substr(0,u.indexOf(":"))):0;if(!Object(V.isFiniteNumber)(a)||!Object(V.isFiniteNumber)(l)||!Object(V.isFiniteNumber)(h)||!Object(V.isFiniteNumber)(C))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+u);return a+=1e3*l,a+=60*1e3*h,a+=60*60*1e3*C,a},A=function(u){for(var a=5381,l=u.length;l;)a=a*33^u.charCodeAt(--l);return(a>>>0).toString()};function D(x,u,a){return A(x.toString())+A(u.toString())+A(a)}var L=function(u,a,l){var h=u[a],C=u[h.prevCC];if(!C||!C.new&&h.new){u.ccOffset=u.presentationOffset=h.start,h.new=!1;return}for(;(g=C)!==null&&g!==void 0&&g.new;){var g;u.ccOffset+=h.start-C.start,h.new=!1,h=C,C=u[h.prevCC]}u.presentationOffset=l};function w(x,u,a,l,h,C,g,m){var k=new N.VTTParser,v=Object(M.utf8ArrayToStr)(new Uint8Array(x)).trim().replace(P,`
|
|
`).split(`
|
|
`),f=[],p=Object(H.toMpegTsClockFromTimescale)(u,a),d="00:00.000",o=0,S=0,y,T=!0,I=!1;k.oncue=function(G){var X=l[h],Q=l.ccOffset,z=(o-p)/9e4;if(X!=null&&X.new&&(S!==void 0?Q=l.ccOffset=X.start:L(l,h,z)),z&&(Q=z-l.presentationOffset),I){var W=G.endTime-G.startTime,ee=Object(F.normalizePts)((G.startTime+Q-S)*9e4,C*9e4)/9e4;G.startTime=ee,G.endTime=ee+W}var ae=G.text.trim();G.text=decodeURIComponent(encodeURIComponent(ae)),G.id||(G.id=D(G.startTime,G.endTime,ae)),G.endTime>0&&f.push(G)},k.onparsingerror=function(G){y=G},k.onflush=function(){if(y){m(y);return}g(f)},v.forEach(function(G){if(T)if(O(G,"X-TIMESTAMP-MAP=")){T=!1,I=!0,G.substr(16).split(",").forEach(function(X){O(X,"LOCAL:")?d=X.substr(6):O(X,"MPEGTS:")&&(o=parseInt(X.substr(7)))});try{S=b(d)/1e3}catch(X){I=!1,y=X}return}else G===""&&(T=!1);k.parse(G+`
|
|
`)}),k.flush()}},"./src/utils/xhr-loader.ts":function(ne,$,_){"use strict";_.r($);var V=_("./src/utils/logger.ts"),N=_("./src/loader/load-stats.ts"),M=/^age:\s*[\d.]+\s*$/m,H=function(){function F(O){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=O?O.xhrSetup:null,this.stats=new N.LoadStats,this.retryDelay=0}var P=F.prototype;return P.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},P.abortInternal=function(){var b=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),b&&(b.onreadystatechange=null,b.onprogress=null,b.readyState!==4&&(this.stats.aborted=!0,b.abort()))},P.abort=function(){var b;this.abortInternal(),(b=this.callbacks)!==null&&b!==void 0&&b.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},P.load=function(b,A,D){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=b,this.config=A,this.callbacks=D,this.retryDelay=A.retryDelay,this.loadInternal()},P.loadInternal=function(){var b=this.config,A=this.context;if(!b)return;var D=this.loader=new self.XMLHttpRequest,L=this.stats;L.loading.first=0,L.loaded=0;var w=this.xhrSetup;try{if(w)try{w(D,A.url)}catch(a){D.open("GET",A.url,!0),w(D,A.url)}D.readyState||D.open("GET",A.url,!0);var x=this.context.headers;if(x)for(var u in x)D.setRequestHeader(u,x[u])}catch(a){this.callbacks.onError({code:D.status,text:a.message},A,D);return}A.rangeEnd&&D.setRequestHeader("Range","bytes="+A.rangeStart+"-"+(A.rangeEnd-1)),D.onreadystatechange=this.readystatechange.bind(this),D.onprogress=this.loadprogress.bind(this),D.responseType=A.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),b.timeout),D.send()},P.readystatechange=function(){var b=this.context,A=this.loader,D=this.stats;if(!b||!A)return;var L=A.readyState,w=this.config;if(D.aborted)return;if(L>=2)if(self.clearTimeout(this.requestTimeout),D.loading.first===0&&(D.loading.first=Math.max(self.performance.now(),D.loading.start)),L===4){A.onreadystatechange=null,A.onprogress=null;var x=A.status;if(x>=200&&x<300){D.loading.end=Math.max(self.performance.now(),D.loading.first);var u,a;if(b.responseType==="arraybuffer"?(u=A.response,a=u.byteLength):(u=A.responseText,a=u.length),D.loaded=D.total=a,!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(D,b,u,A),!this.callbacks)return;var h={url:A.responseURL,data:u};this.callbacks.onSuccess(h,D,b,A)}else D.retry>=w.maxRetry||x>=400&&x<499?(V.logger.error(x+" while loading "+b.url),this.callbacks.onError({code:x,text:A.statusText},b,A)):(V.logger.warn(x+" while loading "+b.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,w.maxRetryDelay),D.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),w.timeout)},P.loadtimeout=function(){V.logger.warn("timeout while loading "+this.context.url);var b=this.callbacks;b&&(this.abortInternal(),b.onTimeout(this.stats,this.context,this.loader))},P.loadprogress=function(b){var A=this.stats;A.loaded=b.loaded,b.lengthComputable&&(A.total=b.total)},P.getCacheAge=function(){var b=null;if(this.loader&&M.test(this.loader.getAllResponseHeaders())){var A=this.loader.getResponseHeader("age");b=A?parseFloat(A):null}return b},F}();$.default=H}}).default})},vHTk:function(xt,at,re){xt.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);
|