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
917 KiB
361 lines
917 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[303,7,8],{"+NIl":function(wt,ht,re){(function(ne){ne(re("VrN/"))})(function(ne){"use strict";ne.defineMode("stex",function($,D){"use strict";function X(L,w){L.cmdState.push(w)}function N(L){return L.cmdState.length>0?L.cmdState[L.cmdState.length-1]:null}function I(L){var w=L.cmdState.pop();w&&w.closeBracket()}function z(L){for(var w=L.cmdState,S=w.length-1;S>=0;S--){var h=w[S];if(h.name=="DEFAULT")continue;return h}return{styleIdentifier:function(){return null}}}function U(L,w,S){return function(){this.name=L,this.bracketNo=0,this.style=w,this.styles=S,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=U("importmodule","tag",["string","builtin"]),P.documentclass=U("documentclass","tag",["","atom"]),P.usepackage=U("usepackage","tag",["atom"]),P.begin=U("begin","tag",["atom"]),P.end=U("end","tag",["atom"]),P.label=U("label","tag",["atom"]),P.ref=U("ref","tag",["atom"]),P.eqref=U("eqref","tag",["atom"]),P.cite=U("cite","tag",["atom"]),P.bibitem=U("bibitem","tag",["atom"]),P.Bibitem=U("Bibitem","tag",["atom"]),P.RBibitem=U("RBibitem","tag",["atom"]),P.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function M(L,w){L.f=w}function b(L,w){var S;if(L.match(/^\\[a-zA-Z@]+/)){var h=L.current().slice(1);return S=P.hasOwnProperty(h)?P[h]:P.DEFAULT,S=new S,X(w,S),M(w,R),S.style}if(L.match(/^\\[$&%#{}_]/))return"tag";if(L.match(/^\\[,;!\/\\]/))return"tag";if(L.match("\\["))return M(w,function(u,d){return A(u,d,"\\]")}),"keyword";if(L.match("\\("))return M(w,function(u,d){return A(u,d,"\\)")}),"keyword";if(L.match("$$"))return M(w,function(u,d){return A(u,d,"$$")}),"keyword";if(L.match("$"))return M(w,function(u,d){return A(u,d,"$")}),"keyword";var o=L.next();if(o=="%")return L.skipToEnd(),"comment";if(o=="}"||o=="]"){if(S=N(w),S)S.closeBracket(o),M(w,R);else return"error";return"bracket"}else return o=="{"||o=="["?(S=P.DEFAULT,S=new S,X(w,S),"bracket"):/\d/.test(o)?(L.eatWhile(/[\w.%]/),"atom"):(L.eatWhile(/[\w\-_]/),S=z(w),S.name=="begin"&&(S.argument=L.current()),S.styleIdentifier())}function A(L,w,S){if(L.eatSpace())return null;if(S&&L.match(S))return M(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 h=L.next();return h=="{"||h=="}"||h=="["||h=="]"||h=="("||h==")"?"bracket":h=="%"?(L.skipToEnd(),"comment"):"error"}function R(L,w){var S=L.peek(),h;return S=="{"||S=="["?(h=N(w),h.openBracket(S),L.eat(S),M(w,b),"bracket"):/[ \t\r]/.test(S)?(L.eat(S),null):(M(w,b),I(w),b(L,w))}return{startState:function(){var L=D.inMathMode?function(w,S){return A(w,S)}: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(wt,ht,re){(function(ne){ne(re("VrN/"))})(function(ne){ne.defineOption("placeholder","",function(U,P,M){var b=M&&M!=ne.Init;if(P&&!b)U.on("blur",N),U.on("change",I),U.on("swapDoc",I),ne.on(U.getInputField(),"compositionupdate",U.state.placeholderCompose=function(){X(U)}),I(U);else if(!P&&b){U.off("blur",N),U.off("change",I),U.off("swapDoc",I),ne.off(U.getInputField(),"compositionupdate",U.state.placeholderCompose),$(U);var A=U.getWrapperElement();A.className=A.className.replace(" CodeMirror-empty","")}P&&!U.hasFocus()&&N(U)});function $(U){U.state.placeholder&&(U.state.placeholder.parentNode.removeChild(U.state.placeholder),U.state.placeholder=null)}function D(U){$(U);var P=U.state.placeholder=document.createElement("pre");P.style.cssText="height: 0; overflow: visible",P.style.direction=U.getOption("direction"),P.className="CodeMirror-placeholder CodeMirror-line-like";var M=U.getOption("placeholder");typeof M=="string"&&(M=document.createTextNode(M)),P.appendChild(M),U.display.lineSpace.insertBefore(P,U.display.lineSpace.firstChild)}function X(U){setTimeout(function(){var P=!1,M=U.getInputField();M.nodeName=="TEXTAREA"?P=!M.value:U.lineCount()==1&&(P=!/[^\u200b]/.test(M.querySelector(".CodeMirror-line").textContent)),P?D(U):$(U)},20)}function N(U){z(U)&&D(U)}function I(U){var P=U.getWrapperElement(),M=z(U);P.className=P.className.replace(" CodeMirror-empty","")+(M?" CodeMirror-empty":""),M?D(U):$(U)}function z(U){return U.lineCount()===1&&U.getLine(0)===""}})},"1eCo":function(wt,ht,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},D={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};ne.defineMode("xml",function(X,N){var I=X.indentUnit,z={},U=N.htmlMode?$:D;for(var P in U)z[P]=U[P];for(var P in N)z[P]=N[P];var M,b;function A(a,v){function g(H){return v.tokenize=H,H(a,v)}var E=a.next();if(E=="<")return a.eat("!")?a.eat("[")?a.match("CDATA[")?g(w("atom","]]>")):null:a.match("--")?g(w("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),g(S(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),v.tokenize=w("meta","?>"),"meta"):(M=a.eat("/")?"closeTag":"openTag",v.tokenize=R,"tag bracket");if(E=="&"){var _;return a.eat("#")?a.eat("x")?_=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):_=a.eatWhile(/[\d]/)&&a.eat(";"):_=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),_?"atom":"error"}else return a.eatWhile(/[^&<]/),null}A.isInText=!0;function R(a,v){var g=a.next();if(g==">"||g=="/"&&a.eat(">"))return v.tokenize=A,M=g==">"?"endTag":"selfcloseTag","tag bracket";if(g=="=")return M="equals",null;if(g=="<"){v.tokenize=A,v.state=d,v.tagName=v.tagStart=null;var E=v.tokenize(a,v);return E?E+" tag error":"tag error"}else return/[\'\"]/.test(g)?(v.tokenize=L(g),v.stringStartCol=a.column(),v.tokenize(a,v)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function L(a){var v=function(g,E){for(;!g.eol();)if(g.next()==a){E.tokenize=R;break}return"string"};return v.isInAttribute=!0,v}function w(a,v){return function(g,E){for(;!g.eol();){if(g.match(v)){E.tokenize=A;break}g.next()}return a}}function S(a){return function(v,g){for(var E;(E=v.next())!=null;){if(E=="<")return g.tokenize=S(a+1),g.tokenize(v,g);if(E==">")if(a==1){g.tokenize=A;break}else return g.tokenize=S(a-1),g.tokenize(v,g)}return"meta"}}function h(a,v,g){this.prev=a.context,this.tagName=v,this.indent=a.indented,this.startOfLine=g,(z.doNotIndent.hasOwnProperty(v)||a.context&&a.context.noIndent)&&(this.noIndent=!0)}function o(a){a.context&&(a.context=a.context.prev)}function u(a,v){for(var g;;){if(!a.context)return;if(g=a.context.tagName,!z.contextGrabbers.hasOwnProperty(g)||!z.contextGrabbers[g].hasOwnProperty(v))return;o(a)}}function d(a,v,g){return a=="openTag"?(g.tagStart=v.column(),T):a=="closeTag"?y:d}function T(a,v,g){return a=="word"?(g.tagName=v.current(),b="tag",x):z.allowMissingTagName&&a=="endTag"?(b="tag bracket",x(a,v,g)):(b="error",T)}function y(a,v,g){if(a=="word"){var E=v.current();return g.context&&g.context.tagName!=E&&z.implicitlyClosed.hasOwnProperty(g.context.tagName)&&o(g),g.context&&g.context.tagName==E||z.matchClosing===!1?(b="tag",f):(b="tag error",k)}else return z.allowMissingTagName&&a=="endTag"?(b="tag bracket",f(a,v,g)):(b="error",k)}function f(a,v,g){return a!="endTag"?(b="error",f):(o(g),d)}function k(a,v,g){return b="error",f(a,v,g)}function x(a,v,g){if(a=="word")return b="attribute",p;if(a=="endTag"||a=="selfcloseTag"){var E=g.tagName,_=g.tagStart;return g.tagName=g.tagStart=null,a=="selfcloseTag"||z.autoSelfClosers.hasOwnProperty(E)?u(g,E):(u(g,E),g.context=new h(g,E,_==g.indented)),d}return b="error",x}function p(a,v,g){return a=="equals"?c:(z.allowMissing||(b="error"),x(a,v,g))}function c(a,v,g){return a=="string"?s:a=="word"&&z.allowUnquoted?(b="string",x):(b="error",x(a,v,g))}function s(a,v,g){return a=="string"?s:x(a,v,g)}return{startState:function(a){var v={tokenize:A,state:d,indented:a||0,tagName:null,tagStart:null,context:null};return a!=null&&(v.baseIndent=a),v},token:function(a,v){if(!v.tagName&&a.sol()&&(v.indented=a.indentation()),a.eatSpace())return null;M=null;var g=v.tokenize(a,v);return(g||M)&&g!="comment"&&(b=null,v.state=v.state(M||g,a,v),b&&(g=b=="error"?g+" error":b)),g},indent:function(a,v,g){var E=a.context;if(a.tokenize.isInAttribute)return a.tagStart==a.indented?a.stringStartCol+1:a.indented+I;if(E&&E.noIndent)return ne.Pass;if(a.tokenize!=R&&a.tokenize!=A)return g?g.match(/^(\s*)/)[0].length:0;if(a.tagName)return z.multilineTagIndentPastTag!==!1?a.tagStart+a.tagName.length+2:a.tagStart+I*(z.multilineTagIndentFactor||1);if(z.alignCDATA&&/<!\[CDATA\[/.test(v))return 0;var _=v&&/^<(\/)?([\w_:\.-]*)/.exec(v);if(_&&_[1])for(;E;)if(E.tagName==_[2]){E=E.prev;break}else if(z.implicitlyClosed.hasOwnProperty(E.tagName))E=E.prev;else break;else if(_)for(;E;){var H=z.contextGrabbers[E.tagName];if(H&&H.hasOwnProperty(_[2]))E=E.prev;else break}for(;E&&E.prev&&!E.startOfLine;)E=E.prev;return E?E.indent+I:a.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:z.htmlMode?"html":"xml",helperType:z.htmlMode?"html":"xml",skipAttribute:function(a){a.state==c&&(a.state=x)},xmlCurrentTag:function(a){return a.tagName?{name:a.tagName,close:a.type=="closeTag"}:null},xmlCurrentContext:function(a){for(var v=[],g=a.context;g;g=g.prev)g.tagName&&v.push(g.tagName);return v.reverse()}}}),ne.defineMIME("text/xml","xml"),ne.defineMIME("application/xml","xml"),ne.mimeModes.hasOwnProperty("text/html")||ne.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"6+eU":function(wt,ht,re){"use strict";re.d(ht,"a",function(){return f});var ne=re("wx14"),$=re("rePB"),D=re("VTBJ"),X=re("1OyB"),N=re("vuIU"),I=re("Ji7U"),z=re("LK+K"),U=re("cDcd"),P=re.n(U),M=re("TSYQ"),b=re.n(M),A=function(x){var p,c="".concat(x.rootPrefixCls,"-item"),s=b()(c,"".concat(c,"-").concat(x.page),(p={},Object($.a)(p,"".concat(c,"-active"),x.active),Object($.a)(p,x.className,!!x.className),Object($.a)(p,"".concat(c,"-disabled"),!x.page),p)),a=function(){x.onClick(x.page)},v=function(E){x.onKeyPress(E,x.onClick,x.page)};return P.a.createElement("li",{title:x.showTitle?x.page:null,className:s,onClick:a,onKeyPress:v,tabIndex:"0"},x.itemRender(x.page,"page",P.a.createElement("a",{rel:"nofollow"},x.page)))},R=A,L={ZERO:48,NINE:57,NUMPAD_ZERO:96,NUMPAD_NINE:105,BACKSPACE:8,DELETE:46,ENTER:13,ARROW_UP:38,ARROW_DOWN:40},w=function(k){Object(I.a)(p,k);var x=Object(z.a)(p);function p(){var c;Object(X.a)(this,p);for(var s=arguments.length,a=new Array(s),v=0;v<s;v++)a[v]=arguments[v];return c=x.call.apply(x,[this].concat(a)),c.state={goInputText:""},c.buildOptionText=function(g){return"".concat(g," ").concat(c.props.locale.items_per_page)},c.changeSize=function(g){c.props.changeSize(Number(g))},c.handleChange=function(g){c.setState({goInputText:g.target.value})},c.handleBlur=function(g){var E=c.props,_=E.goButton,H=E.quickGo,V=E.rootPrefixCls,Z=c.state.goInputText;if(_||Z==="")return;if(g.relatedTarget&&(g.relatedTarget.className.indexOf("".concat(V,"-prev"))>=0||g.relatedTarget.className.indexOf("".concat(V,"-next"))>=0))return;c.setState({goInputText:""}),H(c.getValidValue())},c.go=function(g){var E=c.state.goInputText;if(E==="")return;(g.keyCode===L.ENTER||g.type==="click")&&(c.setState({goInputText:""}),c.props.quickGo(c.getValidValue()))},c}return Object(N.a)(p,[{key:"getValidValue",value:function(){var s=this.state,a=s.goInputText,v=s.current;return!a||isNaN(a)?v:Number(a)}},{key:"getPageSizeOptions",value:function(){var s=this.props,a=s.pageSize,v=s.pageSizeOptions;return v.some(function(g){return g.toString()===a.toString()})?v:v.concat([a.toString()]).sort(function(g,E){var _=isNaN(Number(g))?0:Number(g),H=isNaN(Number(E))?0:Number(E);return _-H})}},{key:"render",value:function(){var s=this,a=this.props,v=a.pageSize,g=a.locale,E=a.rootPrefixCls,_=a.changeSize,H=a.quickGo,V=a.goButton,Z=a.selectComponentClass,G=a.buildOptionText,j=a.selectPrefixCls,q=a.disabled,ie=this.state.goInputText,ce="".concat(E,"-options"),ve=Z,ke=null,xe=null,Ce=null;if(!_&&!H)return null;var Te=this.getPageSizeOptions();if(_&&ve){var Ee=Te.map(function(pe,se){return P.a.createElement(ve.Option,{key:se,value:pe.toString()},(G||s.buildOptionText)(pe))});ke=P.a.createElement(ve,{disabled:q,prefixCls:j,showSearch:!1,className:"".concat(ce,"-size-changer"),optionLabelProp:"children",dropdownMatchSelectWidth:!1,value:(v||Te[0]).toString(),onChange:this.changeSize,getPopupContainer:function(se){return se.parentNode}},Ee)}return H&&(V&&(Ce=typeof V=="boolean"?P.a.createElement("button",{type:"button",onClick:this.go,onKeyUp:this.go,disabled:q,className:"".concat(ce,"-quick-jumper-button")},g.jump_to_confirm):P.a.createElement("span",{onClick:this.go,onKeyUp:this.go},V)),xe=P.a.createElement("div",{className:"".concat(ce,"-quick-jumper")},g.jump_to,P.a.createElement("input",{disabled:q,type:"text",value:ie,onChange:this.handleChange,onKeyUp:this.go,onBlur:this.handleBlur}),g.page,Ce)),P.a.createElement("li",{className:"".concat(ce)},ke,xe)}}]),p}(P.a.Component);w.defaultProps={pageSizeOptions:["10","20","50","100"]};var S=w,h=re("N2Kk");function o(){}function u(k){return typeof k=="number"&&isFinite(k)&&Math.floor(k)===k}function d(k,x,p){return p}function T(k,x,p){var c=typeof k=="undefined"?x.pageSize:k;return Math.floor((p.total-1)/c)+1}var y=function(k){Object(I.a)(p,k);var x=Object(z.a)(p);function p(c){var s;Object(X.a)(this,p),s=x.call(this,c),s.getJumpPrevPage=function(){return Math.max(1,s.state.current-(s.props.showLessItems?3:5))},s.getJumpNextPage=function(){return Math.min(T(void 0,s.state,s.props),s.state.current+(s.props.showLessItems?3:5))},s.getItemIcon=function(_,H){var V=s.props.prefixCls,Z=_||P.a.createElement("button",{type:"button","aria-label":H,className:"".concat(V,"-item-link")});return typeof _=="function"&&(Z=P.a.createElement(_,Object(D.a)({},s.props))),Z},s.savePaginationNode=function(_){s.paginationNode=_},s.isValid=function(_){return u(_)&&_!==s.state.current},s.shouldDisplayQuickJumper=function(){var _=s.props,H=_.showQuickJumper,V=_.pageSize,Z=_.total;return Z<=V?!1:H},s.handleKeyDown=function(_){(_.keyCode===L.ARROW_UP||_.keyCode===L.ARROW_DOWN)&&_.preventDefault()},s.handleKeyUp=function(_){var H=s.getValidValue(_),V=s.state.currentInputValue;H!==V&&s.setState({currentInputValue:H}),_.keyCode===L.ENTER?s.handleChange(H):_.keyCode===L.ARROW_UP?s.handleChange(H-1):_.keyCode===L.ARROW_DOWN&&s.handleChange(H+1)},s.changePageSize=function(_){var H=s.state.current,V=T(_,s.state,s.props);H=H>V?V:H,V===0&&(H=s.state.current),typeof _=="number"&&("pageSize"in s.props||s.setState({pageSize:_}),"current"in s.props||s.setState({current:H,currentInputValue:H})),s.props.onShowSizeChange(H,_),"onChange"in s.props&&s.props.onChange&&s.props.onChange(H,_)},s.handleChange=function(_){var H=s.props.disabled,V=_;if(s.isValid(V)&&!H){var Z=T(void 0,s.state,s.props);V>Z?V=Z:V<1&&(V=1),"current"in s.props||s.setState({current:V,currentInputValue:V});var G=s.state.pageSize;return s.props.onChange(V,G),V}return s.state.current},s.prev=function(){s.hasPrev()&&s.handleChange(s.state.current-1)},s.next=function(){s.hasNext()&&s.handleChange(s.state.current+1)},s.jumpPrev=function(){s.handleChange(s.getJumpPrevPage())},s.jumpNext=function(){s.handleChange(s.getJumpNextPage())},s.hasPrev=function(){return s.state.current>1},s.hasNext=function(){return s.state.current<T(void 0,s.state,s.props)},s.runIfEnter=function(_,H){if(_.key==="Enter"||_.charCode===13){for(var V=arguments.length,Z=new Array(V>2?V-2:0),G=2;G<V;G++)Z[G-2]=arguments[G];H.apply(void 0,Z)}},s.runIfEnterPrev=function(_){s.runIfEnter(_,s.prev)},s.runIfEnterNext=function(_){s.runIfEnter(_,s.next)},s.runIfEnterJumpPrev=function(_){s.runIfEnter(_,s.jumpPrev)},s.runIfEnterJumpNext=function(_){s.runIfEnter(_,s.jumpNext)},s.handleGoTO=function(_){(_.keyCode===L.ENTER||_.type==="click")&&s.handleChange(s.state.currentInputValue)};var a=c.onChange!==o,v="current"in c;v&&!a&&console.warn("Warning: You provided a `current` prop to a Pagination component without an `onChange` handler. This will render a read-only component.");var g=c.defaultCurrent;"current"in c&&(g=c.current);var E=c.defaultPageSize;return"pageSize"in c&&(E=c.pageSize),g=Math.min(g,T(E,void 0,c)),s.state={current:g,currentInputValue:g,pageSize:E},s}return Object(N.a)(p,[{key:"componentDidUpdate",value:function(s,a){var v=this.props.prefixCls;if(a.current!==this.state.current&&this.paginationNode){var g=this.paginationNode.querySelector(".".concat(v,"-item-").concat(a.current));g&&document.activeElement===g&&g.blur()}}},{key:"getValidValue",value:function(s){var a=s.target.value,v=T(void 0,this.state,this.props),g=this.state.currentInputValue,E;return a===""?E=a:isNaN(Number(a))?E=g:a>=v?E=v:E=Number(a),E}},{key:"getShowSizeChanger",value:function(){var s=this.props,a=s.showSizeChanger,v=s.total,g=s.totalBoundaryShowSizeChanger;return typeof a!="undefined"?a:v>g}},{key:"renderPrev",value:function(s){var a=this.props,v=a.prevIcon,g=a.itemRender,E=g(s,"prev",this.getItemIcon(v,"prev page")),_=!this.hasPrev();return Object(U.isValidElement)(E)?Object(U.cloneElement)(E,{disabled:_}):E}},{key:"renderNext",value:function(s){var a=this.props,v=a.nextIcon,g=a.itemRender,E=g(s,"next",this.getItemIcon(v,"next page")),_=!this.hasNext();return Object(U.isValidElement)(E)?Object(U.cloneElement)(E,{disabled:_}):E}},{key:"render",value:function(){var s=this,a=this.props,v=a.prefixCls,g=a.className,E=a.style,_=a.disabled,H=a.hideOnSinglePage,V=a.total,Z=a.locale,G=a.showQuickJumper,j=a.showLessItems,q=a.showTitle,ie=a.showTotal,ce=a.simple,ve=a.itemRender,ke=a.showPrevNextJumpers,xe=a.jumpPrevIcon,Ce=a.jumpNextIcon,Te=a.selectComponentClass,Ee=a.selectPrefixCls,pe=a.pageSizeOptions,se=this.state,Le=se.current,Xe=se.pageSize,Ge=se.currentInputValue;if(H===!0&&V<=Xe)return null;var Ke=T(void 0,this.state,this.props),Ve=[],De=null,Pe=null,He=null,$e=null,Fe=null,Ne=G&&G.goButton,Me=j?1:2,at=Le-1>0?Le-1:0,qe=Le+1<Ke?Le+1:Ke,Qe=Object.keys(this.props).reduce(function(ee,te){return(te.substr(0,5)==="data-"||te.substr(0,5)==="aria-"||te==="role")&&(ee[te]=s.props[te]),ee},{});if(ce)return Ne&&(typeof Ne=="boolean"?Fe=P.a.createElement("button",{type:"button",onClick:this.handleGoTO,onKeyUp:this.handleGoTO},Z.jump_to_confirm):Fe=P.a.createElement("span",{onClick:this.handleGoTO,onKeyUp:this.handleGoTO},Ne),Fe=P.a.createElement("li",{title:q?"".concat(Z.jump_to).concat(Le,"/").concat(Ke):null,className:"".concat(v,"-simple-pager")},Fe)),P.a.createElement("ul",Object(ne.a)({className:b()(v,"".concat(v,"-simple"),Object($.a)({},"".concat(v,"-disabled"),_),g),style:E,ref:this.savePaginationNode},Qe),P.a.createElement("li",{title:q?Z.prev_page:null,onClick:this.prev,tabIndex:this.hasPrev()?0:null,onKeyPress:this.runIfEnterPrev,className:b()("".concat(v,"-prev"),Object($.a)({},"".concat(v,"-disabled"),!this.hasPrev())),"aria-disabled":!this.hasPrev()},this.renderPrev(at)),P.a.createElement("li",{title:q?"".concat(Le,"/").concat(Ke):null,className:"".concat(v,"-simple-pager")},P.a.createElement("input",{type:"text",value:Ge,disabled:_,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,onChange:this.handleKeyUp,size:"3"}),P.a.createElement("span",{className:"".concat(v,"-slash")},"/"),Ke),P.a.createElement("li",{title:q?Z.next_page:null,onClick:this.next,tabIndex:this.hasPrev()?0:null,onKeyPress:this.runIfEnterNext,className:b()("".concat(v,"-next"),Object($.a)({},"".concat(v,"-disabled"),!this.hasNext())),"aria-disabled":!this.hasNext()},this.renderNext(qe)),Fe);if(Ke<=3+Me*2){var tt={locale:Z,rootPrefixCls:v,onClick:this.handleChange,onKeyPress:this.runIfEnter,showTitle:q,itemRender:ve};Ke||Ve.push(P.a.createElement(R,Object(ne.a)({},tt,{key:"noPager",page:Ke,className:"".concat(v,"-disabled")})));for(var ut=1;ut<=Ke;ut+=1){var rt=Le===ut;Ve.push(P.a.createElement(R,Object(ne.a)({},tt,{key:ut,page:ut,active:rt})))}}else{var it=j?Z.prev_3:Z.prev_5,we=j?Z.next_3:Z.next_5;ke&&(De=P.a.createElement("li",{title:q?it:null,key:"prev",onClick:this.jumpPrev,tabIndex:"0",onKeyPress:this.runIfEnterJumpPrev,className:b()("".concat(v,"-jump-prev"),Object($.a)({},"".concat(v,"-jump-prev-custom-icon"),!!xe))},ve(this.getJumpPrevPage(),"jump-prev",this.getItemIcon(xe,"prev page"))),Pe=P.a.createElement("li",{title:q?we:null,key:"next",tabIndex:"0",onClick:this.jumpNext,onKeyPress:this.runIfEnterJumpNext,className:b()("".concat(v,"-jump-next"),Object($.a)({},"".concat(v,"-jump-next-custom-icon"),!!Ce))},ve(this.getJumpNextPage(),"jump-next",this.getItemIcon(Ce,"next page")))),$e=P.a.createElement(R,{locale:Z,last:!0,rootPrefixCls:v,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:Ke,page:Ke,active:!1,showTitle:q,itemRender:ve}),He=P.a.createElement(R,{locale:Z,rootPrefixCls:v,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:1,page:1,active:!1,showTitle:q,itemRender:ve});var lt=Math.max(1,Le-Me),et=Math.min(Le+Me,Ke);Le-1<=Me&&(et=1+Me*2),Ke-Le<=Me&&(lt=Ke-Me*2);for(var Ae=lt;Ae<=et;Ae+=1){var Ue=Le===Ae;Ve.push(P.a.createElement(R,{locale:Z,rootPrefixCls:v,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:Ae,page:Ae,active:Ue,showTitle:q,itemRender:ve}))}Le-1>=Me*2&&Le!==1+2&&(Ve[0]=Object(U.cloneElement)(Ve[0],{className:"".concat(v,"-item-after-jump-prev")}),Ve.unshift(De)),Ke-Le>=Me*2&&Le!==Ke-2&&(Ve[Ve.length-1]=Object(U.cloneElement)(Ve[Ve.length-1],{className:"".concat(v,"-item-before-jump-next")}),Ve.push(Pe)),lt!==1&&Ve.unshift(He),et!==Ke&&Ve.push($e)}var me=null;ie&&(me=P.a.createElement("li",{className:"".concat(v,"-total-text")},ie(V,[V===0?0:(Le-1)*Xe+1,Le*Xe>V?V:Le*Xe])));var he=!this.hasPrev()||!Ke,fe=!this.hasNext()||!Ke;return P.a.createElement("ul",Object(ne.a)({className:b()(v,g,Object($.a)({},"".concat(v,"-disabled"),_)),style:E,unselectable:"unselectable",ref:this.savePaginationNode},Qe),me,P.a.createElement("li",{title:q?Z.prev_page:null,onClick:this.prev,tabIndex:he?null:0,onKeyPress:this.runIfEnterPrev,className:b()("".concat(v,"-prev"),Object($.a)({},"".concat(v,"-disabled"),he)),"aria-disabled":he},this.renderPrev(at)),Ve,P.a.createElement("li",{title:q?Z.next_page:null,onClick:this.next,tabIndex:fe?null:0,onKeyPress:this.runIfEnterNext,className:b()("".concat(v,"-next"),Object($.a)({},"".concat(v,"-disabled"),fe)),"aria-disabled":fe},this.renderNext(qe)),P.a.createElement(S,{disabled:_,locale:Z,rootPrefixCls:v,selectComponentClass:Te,selectPrefixCls:Ee,changeSize:this.getShowSizeChanger()?this.changePageSize:null,current:Le,pageSize:Xe,pageSizeOptions:pe,quickGo:this.shouldDisplayQuickJumper()?this.handleChange:null,goButton:Ne}))}}],[{key:"getDerivedStateFromProps",value:function(s,a){var v={};if("current"in s&&(v.current=s.current,s.current!==a.current&&(v.currentInputValue=v.current)),"pageSize"in s&&s.pageSize!==a.pageSize){var g=a.current,E=T(s.pageSize,a,s);g=g>E?E:g,"current"in s||(v.current=g,v.currentInputValue=g),v.pageSize=s.pageSize}return v}}]),p}(P.a.Component);y.defaultProps={defaultCurrent:1,total:0,defaultPageSize:10,onChange:o,className:"",selectPrefixCls:"rc-select",prefixCls:"rc-pagination",selectComponentClass:null,hideOnSinglePage:!1,showPrevNextJumpers:!0,showQuickJumper:!1,showLessItems:!1,showTitle:!0,onShowSizeChange:o,locale:h.a,style:{},itemRender:d,totalBoundaryShowSizeChanger:50};var f=y},"7Cbv":function(wt,ht,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 D(){if(!ne)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ne($)}var X=/^(?:[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(R){return typeof R=="string"&&X.test(R)}for(var I=N,z=[],U=0;U<256;++U)z.push((U+256).toString(16).substr(1));function P(R){var L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,w=(z[R[L+0]]+z[R[L+1]]+z[R[L+2]]+z[R[L+3]]+"-"+z[R[L+4]]+z[R[L+5]]+"-"+z[R[L+6]]+z[R[L+7]]+"-"+z[R[L+8]]+z[R[L+9]]+"-"+z[R[L+10]]+z[R[L+11]]+z[R[L+12]]+z[R[L+13]]+z[R[L+14]]+z[R[L+15]]).toLowerCase();if(!I(w))throw TypeError("Stringified UUID is invalid");return w}var M=P;function b(R,L,w){R=R||{};var S=R.random||(R.rng||D)();if(S[6]=S[6]&15|64,S[8]=S[8]&63|128,L){w=w||0;for(var h=0;h<16;++h)L[w+h]=S[h];return L}return M(S)}var A=ht.a=b},"7ahc":function(wt,ht,re){"use strict";re.d(ht,"a",function(){return T});var ne=re("k1fw"),$=re("0Owb"),D=re("+L6B"),X=re("2/Rp"),N=re("y8nQ"),I=re("Vl3Y"),z=re("tJVT"),U=re("OaEy"),P=re("2fM7"),M=re("cDcd"),b=re.n(M),A=re("VrN/"),R=re.n(A),L=re("p77/"),w=re.n(L),S=re("c5Ni"),h=re.n(S),o=P.a.Option,u={labelCol:{span:4},wrapperCol:{span:20}},d={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"]};ht.b=function(y){var f=y.callback,k=y.onCancel,x=Object(M.useState)("python"),p=Object(z.a)(x,2),c=p[0],s=p[1];function a(g){s(d[g][1])}function v(g){f(g)}return b.a.createElement(I.a,Object($.a)({},u,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:v}),b.a.createElement(I.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},b.a.createElement(P.a,{onChange:a},Object.keys(d).map(function(g){return b.a.createElement(o,{key:g,value:g},d[g][0])}))),b.a.createElement(I.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},b.a.createElement(T,{mode:c})),b.a.createElement("div",{className:"flex-container flex-end"},b.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),b.a.createElement(X.a,{type:"ghost",onClick:k},"\u53D6\u6D88")))};function T(y){var f=y.value,k=y.onChange,x=y.mode,p=y.options,c=p===void 0?{}:p,s=Object(M.useRef)(),a=Object(M.useState)(),v=Object(z.a)(a,2),g=v[0],E=v[1];return Object(M.useEffect)(function(){if(g){function _(H){var V=H.getValue();k&&k(V)}return g.on("change",_),function(){g.off("change",_)}}},[g,k]),Object(M.useEffect)(function(){g&&g.setOption("mode",x)},[g,x]),Object(M.useEffect)(function(){g&&((f!==g.getValue()||f==="")&&setTimeout(function(){g.setValue(f||" ")},300))},[g,f]),Object(M.useEffect)(function(){if(s.current&&!g){var _=R.a.fromTextArea(s.current,Object(ne.a)({mode:x,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},c));E(_)}},[s.current,g]),b.a.createElement("div",{className:"my-codemirror-container"},b.a.createElement("textarea",{ref:s}))}},"7ixt":function(wt,ht,re){"use strict";re.d(ht,"a",function(){return D});var ne={adjustX:1,adjustY:1},$=[0,0],D={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:$}},X=D},"8EBN":function(wt,ht,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 D=ne.modeInfo[$];D.mimes&&(D.mime=D.mimes[0])}ne.findModeByMIME=function(X){X=X.toLowerCase();for(var N=0;N<ne.modeInfo.length;N++){var I=ne.modeInfo[N];if(I.mime==X)return I;if(I.mimes){for(var z=0;z<I.mimes.length;z++)if(I.mimes[z]==X)return I}}if(/\+xml$/.test(X))return ne.findModeByMIME("application/xml");if(/\+json$/.test(X))return ne.findModeByMIME("application/json")},ne.findModeByExtension=function(X){X=X.toLowerCase();for(var N=0;N<ne.modeInfo.length;N++){var I=ne.modeInfo[N];if(I.ext){for(var z=0;z<I.ext.length;z++)if(I.ext[z]==X)return I}}},ne.findModeByFileName=function(X){for(var N=0;N<ne.modeInfo.length;N++){var I=ne.modeInfo[N];if(I.file&&I.file.test(X))return I}var z=X.lastIndexOf("."),U=z>-1&&X.substring(z+1,X.length);if(U)return ne.findModeByExtension(U)},ne.findModeByName=function(X){X=X.toLowerCase();for(var N=0;N<ne.modeInfo.length;N++){var I=ne.modeInfo[N];if(I.name.toLowerCase()==X)return I;if(I.alias){for(var z=0;z<I.alias.length;z++)if(I.alias[z].toLowerCase()==X)return I}}}})},"8hTe":function(wt,ht,re){wt.exports={button:"button___1wy9m"}},"9Bee":function(wt,ht,re){"use strict";var ne=re("DYRE"),$=re("zeV3"),D=re("+L6B"),X=re("2/Rp"),N=re("k1fw"),I=re("9og8"),z=re("tJVT"),U=re("WmNS"),P=re.n(U),M=re("cDcd"),b=re.n(M),A=re("vg9a"),R=re("DlQD"),L=re.n(R),w=re("rUJ1");function S(W,l){var m=W.match(/^(\s+)(?:```)/);if(m===null)return l;var O=m[1];return l.split(`
|
|
`).map(function(J){var F=J.match(/^\s+/);if(F===null)return J;var de=Object(z.a)(F,1),_e=de[0];return _e.length>=O.length?J.slice(O.length):J}).join(`
|
|
`)}var h=[],o=["<ul>"],u=new L.a.Renderer,d=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function T(){h.length=0,o=["<ul>"]}var y={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function f(W,l,m,O){if(l>=W.length||W[l].level<=m)return l;var J=W[l];O.push("<li><a href='#"+J.anchor+"'>"+J.text+"</a>"),l++;var F=[];return l=f(W,l,J.level,F),F.length>0&&(O.push("<ul>"),F.forEach(function(de){O.push(de)}),O.push("</ul>")),O.push("</li>"),l=f(W,l,m,O),l}function k(){return f(h,0,0,o),o.push("</ul>"),o.join("")}var x={heading:function(l){var m=d.exec(l);if(m)return{type:"heading",raw:m[0],depth:m[1].length,text:m[2]}},fences:function(l){var m=this.rules.block.fences.exec(l);if(m){var O=m[0],J=S(O,m[3]||""),F=m[2]?m[2].trim():m[2];if(["latex","katex","math"].indexOf(F)>=0){var de=s(),_e=J;J=de,a[de]={type:"block",expression:_e}}return{type:"code",raw:O,lang:F,text:J}}}},p=/(?:\${2})([^\n`]+?)(?:\${2})/gi,c=0,s=function(){return"__special_katext_id_".concat(c++,"__")},a={};function v(){return a}function g(){c=0,a={}}function E(W){return W=W.replace(p,function(l,m){var O=s();return a[O]={type:"inline",expression:m},O}),W}var _=u.listitem;u.listitem=function(W){return _(E(W))};var H=u.paragraph;u.paragraph=function(W){return H(E(W))};var V=u.tablecell;u.tablecell=function(W,l){return V(E(W),l)},u.code=function(W,l,m){var O=(l||"").match(/\S*/)[0];return O?["latex","katex","math"].indexOf(O)>=0?"<p class='editormd-tex'>".concat(W,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(l,'">').concat(m?W:Object(w.escape)(W,!0),`</code></pre>
|
|
`):'<pre class="prettyprint linenums"><code>'+(m?W:Object(w.escape)(W,!0))+"</code></pre>"},u.heading=function(W,l,m){var O=this.options.headerPrefix+m.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return h.push({anchor:O,level:l,text:W}),"<h"+l+' id="'+O+'">'+W+"</h"+l+">"},L.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),L.a.use({tokenizer:x,renderer:u});var Z=L.a,G=re("SJMd"),j=re("ulZh"),q=re.n(j),ie=re("m3rI"),ce=re("Oy/b"),ve=re("p5ED"),ke=re("ErOA");/*! *****************************************************************************
|
|
Copyright (c) Microsoft Corporation.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
***************************************************************************** */var xe=function(W,l){return(xe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,O){m.__proto__=O}||function(m,O){for(var J in O)Object.prototype.hasOwnProperty.call(O,J)&&(m[J]=O[J])})(W,l)};function Ce(W,l){function m(){this.constructor=W}xe(W,l),W.prototype=l===null?Object.create(l):(m.prototype=l.prototype,new m)}function Te(W,l,m,O){return new(m||(m=Promise))(function(J,F){function de(mt){try{Ye(O.next(mt))}catch(Ie){F(Ie)}}function _e(mt){try{Ye(O.throw(mt))}catch(Ie){F(Ie)}}function Ye(mt){var Ie;mt.done?J(mt.value):(Ie=mt.value,Ie instanceof m?Ie:new m(function(St){St(Ie)})).then(de,_e)}Ye((O=O.apply(W,l||[])).next())})}function Ee(W,l){var m,O,J,F,de={label:0,sent:function(){if(1&J[0])throw J[1];return J[1]},trys:[],ops:[]};return F={next:_e(0),throw:_e(1),return:_e(2)},typeof Symbol=="function"&&(F[Symbol.iterator]=function(){return this}),F;function _e(Ye){return function(mt){return function(Ie){if(m)throw new TypeError("Generator is already executing.");for(;de;)try{if(m=1,O&&(J=2&Ie[0]?O.return:Ie[0]?O.throw||((J=O.return)&&J.call(O),0):O.next)&&!(J=J.call(O,Ie[1])).done)return J;switch(O=0,J&&(Ie=[2&Ie[0],J.value]),Ie[0]){case 0:case 1:J=Ie;break;case 4:return de.label++,{value:Ie[1],done:!1};case 5:de.label++,O=Ie[1],Ie=[0];continue;case 7:Ie=de.ops.pop(),de.trys.pop();continue;default:if(!(J=de.trys,(J=J.length>0&&J[J.length-1])||Ie[0]!==6&&Ie[0]!==2)){de=0;continue}if(Ie[0]===3&&(!J||Ie[1]>J[0]&&Ie[1]<J[3])){de.label=Ie[1];break}if(Ie[0]===6&&de.label<J[1]){de.label=J[1],J=Ie;break}if(J&&de.label<J[2]){de.label=J[2],de.ops.push(Ie);break}J[2]&&de.ops.pop(),de.trys.pop();continue}Ie=l.call(W,de)}catch(St){Ie=[6,St],O=0}finally{m=J=0}if(5&Ie[0])throw Ie[1];return{value:Ie[0]?Ie[1]:void 0,done:!0}}([Ye,mt])}}}function pe(){for(var W=0,l=0,m=arguments.length;l<m;l++)W+=arguments[l].length;var O=Array(W),J=0;for(l=0;l<m;l++)for(var F=arguments[l],de=0,_e=F.length;de<_e;de++,J++)O[J]=F[de];return O}var se=function(){function W(){}return W.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},W.setAttributes=function(l,m){for(var O=0,J=m;O<J.length;O++){var F=J[O],de=F[0],_e=F[1];l.setAttribute(de,_e)}},W.createRect=function(l,m,O){var J=document.createElementNS("http://www.w3.org/2000/svg","rect");return J.setAttribute("width",l.toString()),J.setAttribute("height",m.toString()),O&&W.setAttributes(J,O),J},W.createLine=function(l,m,O,J,F){var de=document.createElementNS("http://www.w3.org/2000/svg","line");return de.setAttribute("x1",l.toString()),de.setAttribute("y1",m.toString()),de.setAttribute("x2",O.toString()),de.setAttribute("y2",J.toString()),F&&W.setAttributes(de,F),de},W.createPolygon=function(l,m){var O=document.createElementNS("http://www.w3.org/2000/svg","polygon");return O.setAttribute("points",l),m&&W.setAttributes(O,m),O},W.createCircle=function(l,m){var O=document.createElementNS("http://www.w3.org/2000/svg","circle");return O.setAttribute("cx",(l/2).toString()),O.setAttribute("cy",(l/2).toString()),O.setAttribute("r",l.toString()),m&&W.setAttributes(O,m),O},W.createEllipse=function(l,m,O){var J=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return J.setAttribute("cx",(l/2).toString()),J.setAttribute("cy",(m/2).toString()),J.setAttribute("rx",(l/2).toString()),J.setAttribute("ry",(m/2).toString()),O&&W.setAttributes(J,O),J},W.createGroup=function(l){var m=document.createElementNS("http://www.w3.org/2000/svg","g");return l&&W.setAttributes(m,l),m},W.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},W.createMarker=function(l,m,O,J,F,de,_e){var Ye=document.createElementNS("http://www.w3.org/2000/svg","marker");return W.setAttributes(Ye,[["id",l],["orient",m],["markerWidth",O.toString()],["markerHeight",J.toString()],["refX",F.toString()],["refY",de.toString()]]),Ye.appendChild(_e),Ye},W.createText=function(l){var m=document.createElementNS("http://www.w3.org/2000/svg","text");return m.setAttribute("x","0"),m.setAttribute("y","0"),l&&W.setAttributes(m,l),m},W.createTSpan=function(l,m){var O=document.createElementNS("http://www.w3.org/2000/svg","tspan");return O.textContent=l,m&&W.setAttributes(O,m),O},W.createImage=function(l){var m=document.createElementNS("http://www.w3.org/2000/svg","image");return l&&W.setAttributes(m,l),m},W.createPoint=function(l,m){var O=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return O.x=l,O.y=m,O},W.createPath=function(l,m){var O=document.createElementNS("http://www.w3.org/2000/svg","path");return O.setAttribute("d",l),m&&W.setAttributes(O,m),O},W}(),Le=function(){function W(){}return W.addKey=function(l){W.key=l},Object.defineProperty(W,"isLicensed",{get:function(){return!!W.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(W.key)},enumerable:!1,configurable:!0}),W}(),Xe=function(){function W(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return W.prototype.rasterize=function(l,m,O){var J=this;return new Promise(function(F){var de=O!==void 0?O:document.createElement("canvas");l===null&&(J.markersOnly=!0,J.naturalSize=!1);var _e=document.createElementNS("http://www.w3.org/2000/svg","svg");_e.setAttribute("xmlns","http://www.w3.org/2000/svg"),_e.setAttribute("width",m.width.baseVal.valueAsString),_e.setAttribute("height",m.height.baseVal.valueAsString),_e.setAttribute("viewBox","0 0 "+m.viewBox.baseVal.width.toString()+" "+m.viewBox.baseVal.height.toString()),_e.innerHTML=m.innerHTML,J.naturalSize===!0?(_e.width.baseVal.value=l.naturalWidth,_e.height.baseVal.value=l.naturalHeight):J.width!==void 0&&J.height!==void 0&&(_e.width.baseVal.value=J.width,_e.height.baseVal.value=J.height),de.width=_e.width.baseVal.value,de.height=_e.height.baseVal.value;var Ye=_e.outerHTML,mt=de.getContext("2d");J.markersOnly!==!0&&mt.drawImage(l,0,0,de.width,de.height);var Ie=window.URL,St=new Image(de.width,de.height);St.setAttribute("crossOrigin","anonymous");var Ft=new Blob([Ye],{type:"image/svg+xml"}),Xt=Ie.createObjectURL(Ft);St.onload=function(){mt.drawImage(St,0,0),Ie.revokeObjectURL(Xt);var Or=de.toDataURL(J.imageType,J.imageQuality);F(Or)},St.src=Xt})},W}(),Ge=function(){},Ke=function(){function W(l){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+l+"_"}return Object.defineProperty(W.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#ffffff",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarColor:"#eeeeee",toolbarHeight:40,toolboxColor:"#eeeeee",toolboxAccentColor:"#3080c3",undoButtonVisible:!0,redoButtonVisible:!1,zoomButtonVisible:!1,zoomOutButtonVisible:!1,clearButtonVisible:!1,resultButtonBlockVisible:!0,logoPosition:"left"}},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),W.prototype.addClass=function(l){return this.styleSheet===void 0&&this.addStyleSheet(),l.name=""+this.classNamePrefix+l.localName,this.classes.push(l),this.styleSheet.sheet.insertRule("."+l.name+" {"+l.style+"}",this.styleSheet.sheet.cssRules.length),l},W.prototype.addRule=function(l){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(l),this.styleSheet.sheet.insertRule(l.selector+" {"+l.style+"}",this.styleSheet.sheet.cssRules.length)},W.prototype.addStyleSheet=function(){var l;this.styleSheet=document.createElement("style"),((l=this.styleSheetRoot)!==null&&l!==void 0?l:document.head).appendChild(this.styleSheet),this.addRule(new Ve("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new Ve("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new Ve("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new De("fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new De("fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},W.prototype.removeStyleSheet=function(){var l;this.styleSheet&&(((l=this.styleSheetRoot)!==null&&l!==void 0?l:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},W}(),Ve=function(W,l){this.selector=W,this.style=l},De=function(W,l){this.localName=W,this.style=l},Pe=function(){function W(l,m,O,J,F){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=l,this.displayMode=m,this.markerItems=O,this.uiStyleSettings=J,this.styles=F,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return W.prototype.show=function(l){var m=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=l,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var O=document.createElement("div");O.className=this.toolbarBlockStyleClass.name,O.style.whiteSpace="nowrap",this.uiContainer.appendChild(O),this.addActionButton(O,'<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(O,'<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(O,'<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(O,'<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(O,'<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(O,'<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(O,'<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(O,'<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(F){var de=document.createElement("div");de.className=""+m.toolbarButtonStyleClass.name,de.setAttribute("data-type-name",F.typeName),de.innerHTML=F.icon,de.addEventListener("click",function(){m.markerToolbarButtonClicked(de,F)}),m.buttons.push(de),m.markerButtons.push(de)}),this.overflowButton=document.createElement("div"),this.overflowButton.className=this.toolbarButtonStyleClass.name+" "+(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name),this.overflowButton.innerHTML='<svg viewBox="0 0 24 24"><path d="M12 16a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2z"/></svg>',this.overflowButton.addEventListener("click",this.overflowButtonClicked),this.markerButtonBlock.appendChild(this.overflowButton));var J=document.createElement("div");J.className=this.toolbarBlockStyleClass.name,J.style.whiteSpace="nowrap",J.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(J),this.addActionButton(J,'<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(J,'<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"close"),this.markerjsContainer.appendChild(this.uiContainer),this.setSelectMode(),this.setCurrentMarker(),this.adjustLayout()},W.prototype.addButtonClickListener=function(l){this.buttonClickListeners.push(l)},W.prototype.removeButtonClickListener=function(l){this.buttonClickListeners.indexOf(l)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(l),1)},W.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},W.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var l=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var m=0;m<this.markerButtons.length;m++)m<l||m===l&&this.markerButtons.length-1===l?this.markerButtonBlock.appendChild(this.markerButtons[m]):(m===l&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[m]))}},W.prototype.overflowButtonClicked=function(){this.markerButtonOverflowBlock.style.display!=="none"?(this.markerButtonOverflowBlock.className=this.markerButtonOverflowBlock.className.replace(this.styles.fadeInAnimationClassName,""),this.markerButtonOverflowBlock.style.display="none"):(this.markerButtonOverflowBlock.className+=" "+this.styles.fadeInAnimationClassName,this.markerButtonOverflowBlock.style.top=this.uiContainer.offsetTop+this.overflowButton.offsetHeight+"px",this.markerButtonOverflowBlock.style.right=this.uiContainer.offsetWidth-this.overflowButton.offsetLeft-this.overflowButton.offsetWidth+2*this.uiContainer.offsetLeft+"px",this.markerButtonOverflowBlock.style.display="inline-block")},W.prototype.resetButtonStyles=function(){var l=this;this.buttons.forEach(function(m){m.className=m.className.replace(l.uiStyleSettings.toolbarButtonStyleColorsClassName?l.uiStyleSettings.toolbarButtonStyleColorsClassName:l.toolbarButtonStyleColorsClass.name,"").trim(),m.className=m.className.replace(l.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?l.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:l.toolbarActiveButtonStyleColorsClass.name,"").trim(),m.className+=" "+(l.uiStyleSettings.toolbarButtonStyleColorsClassName?l.uiStyleSettings.toolbarButtonStyleColorsClassName:l.toolbarButtonStyleColorsClass.name)})},W.prototype.addActionButton=function(l,m,O){var J=this,F=document.createElement("div");switch(F.className=""+this.toolbarButtonStyleClass.name,F.innerHTML=m,F.setAttribute("data-action",O),F.addEventListener("click",function(){J.actionToolbarButtonClicked(F,O)}),O){case"select":F.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":F.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":F.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":F.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":F.style.fill=this.uiStyleSettings.closeButtonColor}l.appendChild(F),this.buttons.push(F)},W.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new De("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 De("toolbar_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new De("toolbar-block",`
|
|
display: inline-block;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new De("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 De("toolbar-overflow-block_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`));var l=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new De("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*l)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*l)+`px;
|
|
padding: `+l+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new De("toolbar_button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new De("toolbar_active_button",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new Ve("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new Ve("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`))},W.prototype.markerToolbarButtonClicked=function(l,m){this.setActiveButton(l),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(O){return O("marker",m)}),this.markerButtonOverflowBlock.style.display="none"},W.prototype.actionToolbarButtonClicked=function(l,m){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(O){return O("action",m)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},W.prototype.setActiveButton=function(l){this.resetButtonStyles(),l.className=l.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),l.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},W.prototype.setActiveMarkerButton=function(l){var m=this.markerButtons.find(function(O){return O.getAttribute("data-type-name")===l});m&&this.setActiveButton(m)},W.prototype.setCurrentMarker=function(l){var m=this;this.currentMarker=l,this.buttons.filter(function(O){return/delete|notes/.test(O.getAttribute("data-action"))}).forEach(function(O){m.currentMarker===void 0?(O.style.fillOpacity="0.4",O.style.pointerEvents="none"):(O.style.fillOpacity="1",O.style.pointerEvents="all")})},W}(),He=function(){function W(l,m,O,J){this.panels=[],this.panelButtons=[],this.markerjsContainer=l,this.displayMode=m,this.uiStyleSettings=O,this.styles=J,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return W.prototype.addStyles=function(){var l;this.toolboxStyleClass=this.styles.addClass(new De("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 De("toolbox_colors",`
|
|
color: `+this.uiStyleSettings.toolboxColor+`;
|
|
`));var m=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new De("toolbox-button-row",`
|
|
display: flex;
|
|
cursor: default;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new De("toolbox-button-row_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new De("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 De("toolbox-panel-row_colors",`
|
|
background-color: `+((l=this.uiStyleSettings.toolboxBackgroundColor)!==null&&l!==void 0?l:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
|
|
`)),this.toolboxButtonStyleClass=this.styles.addClass(new De("toolbox_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*m)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*m)+`px;
|
|
padding: `+m+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new De("toolbox-button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new De("toolbox-active-button_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.styles.addRule(new Ve("."+this.toolboxButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new Ve("."+this.toolboxButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`))},W.prototype.show=function(l){var m;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=l,this.uiContainer.className=this.toolboxStyleClass.name+" "+((m=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&m!==void 0?m:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},W.prototype.setPanelButtons=function(l){var m,O,J=this;this.panels=l,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((m=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&m!==void 0?m:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((O=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&O!==void 0?O:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(F){var de;F.uiStyleSettings=J.uiStyleSettings;var _e=document.createElement("div");_e.className=J.toolboxButtonStyleClass.name+" "+((de=J.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&de!==void 0?de:J.toolboxButtonStyleColorsClass.name),_e.innerHTML=F.icon,_e.title=F.title,_e.addEventListener("click",function(){J.panelButtonClick(F)}),J.panelButtons.push(_e),J.buttonRow.appendChild(_e)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},W.prototype.panelButtonClick=function(l){var m=this,O=-1;if(l!==this.activePanel){O=this.panels.indexOf(l),this.panelRow.innerHTML="";var J=l.getUi();J.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(J),this.panelRow.style.display="flex",this.panelRow.style.visibility="visible",this.panelRow.className=this.panelRow.className.replace(this.styles.fadeOutAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeInAnimationClassName,this.activePanel=l}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){m.displayMode==="inline"?m.panelRow.style.display="none":m.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(F,de){var _e,Ye;F.className=m.toolboxButtonStyleClass.name+" "+(de===O?""+((_e=m.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&_e!==void 0?_e:m.toolboxActiveButtonStyleColorsClass.name):""+((Ye=m.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Ye!==void 0?Ye:m.toolboxButtonStyleColorsClass.name))})},W}(),$e=function(W,l){this.title=W,this.icon=l},Fe=function(W){function l(m,O,J,F){var de=W.call(this,m,F||'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 01-1.5-1.5A1.5 1.5 0 0117.5 9a1.5 1.5 0 011.5 1.5 1.5 1.5 0 01-1.5 1.5m-3-4A1.5 1.5 0 0113 6.5 1.5 1.5 0 0114.5 5 1.5 1.5 0 0116 6.5 1.5 1.5 0 0114.5 8m-5 0A1.5 1.5 0 018 6.5 1.5 1.5 0 019.5 5 1.5 1.5 0 0111 6.5 1.5 1.5 0 019.5 8m-3 4A1.5 1.5 0 015 10.5 1.5 1.5 0 016.5 9 1.5 1.5 0 018 10.5 1.5 1.5 0 016.5 12M12 3a9 9 0 00-9 9 9 9 0 009 9 1.5 1.5 0 001.5-1.5c0-.39-.15-.74-.39-1-.23-.27-.38-.62-.38-1a1.5 1.5 0 011.5-1.5H16a5 5 0 005-5c0-4.42-4.03-8-9-8z"/></svg>')||this;return de.colors=[],de.addTransparent=!1,de.colorBoxes=[],de.colors=O,de.currentColor=J,de.setCurrentColor=de.setCurrentColor.bind(de),de.getColorBox=de.getColorBox.bind(de),de}return Ce(l,W),l.prototype.getUi=function(){var m=this,O=document.createElement("div");return O.style.overflow="hidden",O.style.whiteSpace="nowrap",this.colors.forEach(function(J){var F=m.getColorBox(J);O.appendChild(F),m.colorBoxes.push(F)}),O},l.prototype.getColorBox=function(m){var O=this,J=this.uiStyleSettings.toolbarHeight/4,F=this.uiStyleSettings.toolbarHeight-J,de=document.createElement("div");de.style.display="inline-block",de.style.boxSizing="content-box",de.style.width=F-2+"px",de.style.height=F-2+"px",de.style.padding="1px",de.style.marginRight="2px",de.style.marginBottom="2px",de.style.borderWidth="2px",de.style.borderStyle="solid",de.style.borderRadius=(F+2)/2+"px",de.style.borderColor=m===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",de.addEventListener("click",function(){O.setCurrentColor(m,de)});var _e=document.createElement("div");return _e.style.display="inline-block",_e.style.width=F-2+"px",_e.style.height=F-2+"px",_e.style.backgroundColor=m,_e.style.borderRadius=F/2+"px",m==="transparent"&&(_e.style.fill=this.uiStyleSettings.toolboxAccentColor,_e.innerHTML=`<svg viewBox="0 0 24 24">
|
|
<path d="M2,5.27L3.28,4L20,20.72L18.73,22L15.65,18.92C14.5,19.3 13.28,19.5 12,19.5C7,19.5 2.73,16.39 1,12C1.69,10.24 2.79,8.69 4.19,7.46L2,5.27M12,9A3,3 0 0,1 15,12C15,12.35 14.94,12.69 14.83,13L11,9.17C11.31,9.06 11.65,9 12,9M12,4.5C17,4.5 21.27,7.61 23,12C22.18,14.08 20.79,15.88 19,17.19L17.58,15.76C18.94,14.82 20.06,13.54 20.82,12C19.17,8.64 15.76,6.5 12,6.5C10.91,6.5 9.84,6.68 8.84,7L7.3,5.47C8.74,4.85 10.33,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C12.69,17.5 13.37,17.43 14,17.29L11.72,15C10.29,14.85 9.15,13.71 9,12.28L5.6,8.87C4.61,9.72 3.78,10.78 3.18,12Z" />
|
|
</svg>`),de.appendChild(_e),de},l.prototype.setCurrentColor=function(m,O){var J=this;this.currentColor=m,this.colorBoxes.forEach(function(F){F.style.borderColor=F===O?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(m)},l}($e),Ne=function(){function W(l,m,O){this._state="new",this._isSelected=!1,this._container=l,this._overlayContainer=m,this.globalSettings=O,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(W.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),W.prototype.ownsTarget=function(l){return!1},Object.defineProperty(W.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),W.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},W.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},W.prototype.pointerDown=function(l,m){},W.prototype.dblClick=function(l,m){},W.prototype.manipulate=function(l){},W.prototype.pointerUp=function(l){this.stateChanged()},W.prototype.dispose=function(){},W.prototype.addMarkerVisualToContainer=function(l){this.container.childNodes.length>0?this.container.insertBefore(l,this.container.childNodes[0]):this.container.appendChild(l)},W.prototype.getState=function(){return{typeName:W.typeName,state:this.state,notes:this.notes}},W.prototype.restoreState=function(l){this._state=l.state,this.notes=l.notes},W.prototype.scale=function(l,m){},W.prototype.colorChanged=function(l){this.onColorChanged&&this.onColorChanged(l),this.stateChanged()},W.prototype.fillColorChanged=function(l){this.onFillColorChanged&&this.onFillColorChanged(l),this.stateChanged()},W.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var l=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),l.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(l)&&this.onStateChanged(this)}},W.typeName="MarkerBase",W}(),Me=function(){function W(){this.findGripByVisual=this.findGripByVisual.bind(this)}return W.prototype.findGripByVisual=function(l){return this.topLeft.ownsTarget(l)?this.topLeft:this.topCenter.ownsTarget(l)?this.topCenter:this.topRight.ownsTarget(l)?this.topRight:this.centerLeft.ownsTarget(l)?this.centerLeft:this.centerRight.ownsTarget(l)?this.centerRight:this.bottomLeft.ownsTarget(l)?this.bottomLeft:this.bottomCenter.ownsTarget(l)?this.bottomCenter:this.bottomRight.ownsTarget(l)?this.bottomRight:void 0},W}(),at=function(){function W(){this.GRIP_SIZE=10,this.visual=se.createGroup(),this.visual.appendChild(se.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(se.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return W.prototype.ownsTarget=function(l){return l===this.visual||l===this.visual.childNodes[0]||l===this.visual.childNodes[1]},W}(),qe=function(){function W(){}return W.toITransformMatrix=function(l){return{a:l.a,b:l.b,c:l.c,d:l.d,e:l.e,f:l.f}},W.toSVGMatrix=function(l,m){return l.a=m.a,l.b=m.b,l.c=m.c,l.d=m.d,l.e=m.e,l.f=m.f,l},W}(),Qe=function(W){function l(m,O,J){var F=W.call(this,m,O,J)||this;return F.left=0,F.top=0,F.width=0,F.height=0,F.defaultSize={x:50,y:20},F.offsetX=0,F.offsetY=0,F.rotationAngle=0,F.CB_DISTANCE=10,F._suppressMarkerCreateEvent=!1,F.container.transform.baseVal.appendItem(se.createTransform()),F.setupControlBox(),F}return Ce(l,W),Object.defineProperty(l.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"visual",{get:function(){return this._visual},set:function(m){this._visual=m;var O=se.createTransform();this._visual.transform.baseVal.appendItem(O)},enumerable:!1,configurable:!0}),l.prototype.ownsTarget=function(m){return!!W.prototype.ownsTarget.call(this,m)||!!(this.controlGrips.findGripByVisual(m)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(m))},l.prototype.pointerDown=function(m,O){W.prototype.pointerDown.call(this,m,O),this.state==="new"&&(this.left=m.x,this.top=m.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var J=this.unrotatePoint(m);if(this.manipulationStartX=J.x,this.manipulationStartY=J.y,this.offsetX=J.x-this.left,this.offsetY=J.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(O),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(O)){this.activeGrip=this.rotatorGrip;var F=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=F.x-this.width/2,this.top=F.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var de=this.container.transform.baseVal.getItem(0);de.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(de,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},l.prototype.pointerUp=function(m){var O=this.state;W.prototype.pointerUp.call(this,m),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(m),this._state="select",O==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},l.prototype.moveVisual=function(m){this.visual.style.transform="translate("+m.x+"px, "+m.y+"px)"},l.prototype.manipulate=function(m){var O=this.unrotatePoint(m);this.state==="creating"?this.resize(m):this.state==="move"?(this.left=this.manipulationStartLeft+(O.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(O.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(O):this.state==="rotate"&&this.rotate(m)},l.prototype.resize=function(m){var O=this.manipulationStartLeft,J=this.manipulationStartWidth,F=this.manipulationStartTop,de=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:O=this.manipulationStartLeft+m.x-this.manipulationStartX,J=this.manipulationStartWidth+this.manipulationStartLeft-O;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:J=this.manipulationStartWidth+m.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:F=this.manipulationStartTop+m.y-this.manipulationStartY,de=this.manipulationStartHeight+this.manipulationStartTop-F;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:de=this.manipulationStartHeight+m.y-this.manipulationStartY}J>=0?(this.left=O,this.width=J):(this.left=O+J,this.width=-J),de>=0?(this.top=F,this.height=de):(this.top=F+de,this.height=-de),this.setSize()},l.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},l.prototype.rotate=function(m){if(Math.abs(m.x-this.centerX)>.1){var O=Math.sign(m.x-this.centerX);this.rotationAngle=180*Math.atan((m.y-this.centerY)/(m.x-this.centerX))/Math.PI+90*O,this.applyRotation()}},l.prototype.applyRotation=function(){var m=this.container.transform.baseVal.getItem(0);m.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(m,0)},l.prototype.rotatePoint=function(m){if(this.rotationAngle===0)return m;var O=this.container.getCTM(),J=se.createPoint(m.x,m.y);return{x:(J=J.matrixTransform(O)).x,y:J.y}},l.prototype.unrotatePoint=function(m){if(this.rotationAngle===0)return m;var O=this.container.getCTM();O=O.inverse();var J=se.createPoint(m.x,m.y);return{x:(J=J.matrixTransform(O)).x,y:J.y}},l.prototype.select=function(){W.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},l.prototype.deselect=function(){W.prototype.deselect.call(this),this.controlBox.style.display="none"},l.prototype.setupControlBox=function(){this.controlBox=se.createGroup();var m=se.createTransform();m.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(m),this.container.appendChild(this.controlBox),this.controlRect=se.createRect(this.width+this.CB_DISTANCE,this.height+this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"],["fill","transparent"],["pointer-events","none"]]),this.controlBox.appendChild(this.controlRect),this.globalSettings.disableRotation!==!0&&(this.rotatorGripLine=se.createLine((this.width+2*this.CB_DISTANCE)/2,this.top-this.CB_DISTANCE,(this.width+2*this.CB_DISTANCE)/2,this.top-3*this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.appendChild(this.rotatorGripLine)),this.controlGrips=new Me,this.addControlGrips(),this.controlBox.style.display="none"},l.prototype.adjustControlBox=function(){var m=this.controlBox.transform.baseVal.getItem(0);m.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(m,0),this.controlRect.setAttribute("width",(this.width+this.CB_DISTANCE).toString()),this.controlRect.setAttribute("height",(this.height+this.CB_DISTANCE).toString()),this.rotatorGripLine!==void 0&&(this.rotatorGripLine.setAttribute("x1",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y1",(-this.CB_DISTANCE/2).toString()),this.rotatorGripLine.setAttribute("x2",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y2",(3*-this.CB_DISTANCE).toString())),this.positionGrips()},l.prototype.addControlGrips=function(){this.controlGrips.topLeft=this.createGrip(),this.controlGrips.topCenter=this.createGrip(),this.controlGrips.topRight=this.createGrip(),this.controlGrips.centerLeft=this.createGrip(),this.controlGrips.centerRight=this.createGrip(),this.controlGrips.bottomLeft=this.createGrip(),this.controlGrips.bottomCenter=this.createGrip(),this.controlGrips.bottomRight=this.createGrip(),this.globalSettings.disableRotation!==!0&&(this.rotatorGrip=this.createGrip()),this.positionGrips()},l.prototype.createGrip=function(){var m=new at;return m.visual.transform.baseVal.appendItem(se.createTransform()),this.controlBox.appendChild(m.visual),m},l.prototype.positionGrips=function(){var m=this.controlGrips.topLeft.GRIP_SIZE,O=-m/2,J=O,F=(this.width+this.CB_DISTANCE)/2-m/2,de=(this.height+this.CB_DISTANCE)/2-m/2,_e=this.height+this.CB_DISTANCE-m/2,Ye=this.width+this.CB_DISTANCE-m/2;this.positionGrip(this.controlGrips.topLeft.visual,O,J),this.positionGrip(this.controlGrips.topCenter.visual,F,J),this.positionGrip(this.controlGrips.topRight.visual,Ye,J),this.positionGrip(this.controlGrips.centerLeft.visual,O,de),this.positionGrip(this.controlGrips.centerRight.visual,Ye,de),this.positionGrip(this.controlGrips.bottomLeft.visual,O,_e),this.positionGrip(this.controlGrips.bottomCenter.visual,F,_e),this.positionGrip(this.controlGrips.bottomRight.visual,Ye,_e),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,F,J-3*this.CB_DISTANCE)},l.prototype.positionGrip=function(m,O,J){var F=m.transform.baseVal.getItem(0);F.setTranslate(O,J),m.transform.baseVal.replaceItem(F,0)},l.prototype.hideControlBox=function(){this.controlBox.style.display="none"},l.prototype.showControlBox=function(){this.controlBox.style.display=""},l.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:qe.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:qe.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},W.prototype.getState.call(this))},l.prototype.restoreState=function(m){W.prototype.restoreState.call(this,m);var O=m;this.left=O.left,this.top=O.top,this.width=O.width,this.height=O.height,this.rotationAngle=O.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(qe.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,O.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(qe.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,O.containerTransformMatrix))},l.prototype.scale=function(m,O){W.prototype.scale.call(this,m,O);var J=this.rotatePoint({x:this.left,y:this.top}),F=this.unrotatePoint({x:J.x*m,y:J.y*O});this.left=F.x,this.top=F.y,this.width=this.width*m,this.height=this.height*O,this.adjustControlBox()},l}(Ne),tt=function(W){function l(m,O,J){var F=W.call(this,m,O,J)||this;return F.fillColor="transparent",F.strokeColor="transparent",F.strokeWidth=0,F.strokeDasharray="",F.opacity=1,F.setStrokeColor=F.setStrokeColor.bind(F),F.setFillColor=F.setFillColor.bind(F),F.setStrokeWidth=F.setStrokeWidth.bind(F),F.setStrokeDasharray=F.setStrokeDasharray.bind(F),F.createVisual=F.createVisual.bind(F),F}return Ce(l,W),l.prototype.ownsTarget=function(m){return!(!W.prototype.ownsTarget.call(this,m)&&m!==this.visual)},l.prototype.createVisual=function(){this.visual=se.createRect(1,1,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},l.prototype.pointerDown=function(m,O){W.prototype.pointerDown.call(this,m,O),this.state==="new"&&(this.createVisual(),this.moveVisual(m),this._state="creating")},l.prototype.manipulate=function(m){W.prototype.manipulate.call(this,m)},l.prototype.resize=function(m){W.prototype.resize.call(this,m),this.setSize()},l.prototype.setSize=function(){W.prototype.setSize.call(this),se.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},l.prototype.pointerUp=function(m){W.prototype.pointerUp.call(this,m),this.setSize()},l.prototype.setStrokeColor=function(m){this.strokeColor=m,this.visual&&se.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(m),this.stateChanged()},l.prototype.setFillColor=function(m){this.fillColor=m,this.visual&&se.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},l.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.visual&&se.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},l.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.visual&&se.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},l.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},W.prototype.getState.call(this))},l.prototype.restoreState=function(m){var O=m;this.fillColor=O.fillColor,this.strokeColor=O.strokeColor,this.strokeWidth=O.strokeWidth,this.strokeDasharray=O.strokeDasharray,this.opacity=O.opacity,this.createVisual(),W.prototype.restoreState.call(this,m),this.setSize()},l.prototype.scale=function(m,O){W.prototype.scale.call(this,m,O),this.setSize()},l.title="Rectangle marker",l}(Qe),ut=function(W){function l(m,O,J,F){var de=W.call(this,m,F||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return de.widths=[],de.widthBoxes=[],de.widths=O,de.currentWidth=J,de.setCurrentWidth=de.setCurrentWidth.bind(de),de}return Ce(l,W),l.prototype.getUi=function(){var m=this,O=document.createElement("div");return O.style.display="flex",O.style.overflow="hidden",O.style.flexGrow="2",this.widths.forEach(function(J){var F=document.createElement("div");F.style.display="flex",F.style.flexGrow="2",F.style.alignItems="center",F.style.justifyContent="space-between",F.style.padding="5px",F.style.borderWidth="2px",F.style.borderStyle="solid",F.style.borderColor=J===m.currentWidth?m.uiStyleSettings.toolboxAccentColor:"transparent",F.addEventListener("click",function(){m.setCurrentWidth(J,F)}),O.appendChild(F);var de=document.createElement("div");de.innerText=J.toString(),de.style.marginRight="5px",F.appendChild(de);var _e=document.createElement("div");_e.style.minHeight="20px",_e.style.flexGrow="2",_e.style.display="flex",_e.style.alignItems="center";var Ye=document.createElement("hr");Ye.style.minWidth="20px",Ye.style.border="0px",Ye.style.borderTop=J+"px solid "+m.uiStyleSettings.toolboxColor,Ye.style.flexGrow="2",_e.appendChild(Ye),F.appendChild(_e),m.widthBoxes.push(F)}),O},l.prototype.setCurrentWidth=function(m,O){var J=this;this.currentWidth=m,this.widthBoxes.forEach(function(F){F.style.borderColor=F===O?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},l}($e),rt=function(W){function l(m,O,J,F){var de=W.call(this,m,F||'<svg viewBox="0 0 24 24"><path d="M3 16h5v-2H3v2m6.5 0h5v-2h-5v2m6.5 0h5v-2h-5v2M3 20h2v-2H3v2m4 0h2v-2H7v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2M3 12h8v-2H3v2m10 0h8v-2h-8v2M3 4v4h18V4H3z"/></svg>')||this;return de.styles=[],de.styleBoxes=[],de.styles=O,de.currentStyle=J,de.setCurrentStyle=de.setCurrentStyle.bind(de),de}return Ce(l,W),l.prototype.getUi=function(){var m=this,O=document.createElement("div");return O.style.display="flex",O.style.overflow="hidden",O.style.flexGrow="2",this.styles.forEach(function(J){var F=document.createElement("div");F.style.display="flex",F.style.alignItems="center",F.style.justifyContent="space-between",F.style.padding="5px",F.style.borderWidth="2px",F.style.borderStyle="solid",F.style.overflow="hidden",F.style.maxWidth=100/m.styles.length-5+"%",F.style.borderColor=J===m.currentStyle?m.uiStyleSettings.toolboxAccentColor:"transparent",F.addEventListener("click",function(){m.setCurrentStyle(J,F)}),O.appendChild(F);var de=document.createElement("div");de.style.minHeight="20px",de.style.flexGrow="2",de.style.overflow="hidden";var _e=`<svg width="100" height="20">
|
|
<line x1="0" y1="10" x2="100" y2="10" stroke="`+m.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(J!==""?'stroke-dasharray="'+J+'"':"")+` />
|
|
</svg>`;de.innerHTML=_e,F.appendChild(de),m.styleBoxes.push(F)}),O},l.prototype.setCurrentStyle=function(m,O){var J=this;this.currentStyle=m,this.styleBoxes.forEach(function(F){F.style.borderColor=F===O?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},l}($e),it=function(W){function l(m,O,J){var F=W.call(this,m,O,J)||this;return F.strokeColor=J.defaultColor,F.strokeWidth=J.defaultStrokeWidth,F.strokeDasharray=J.defaultStrokeDasharray,F.strokePanel=new Fe("Line color",J.defaultColorSet,J.defaultColor),F.strokePanel.onColorChanged=F.setStrokeColor,F.strokeWidthPanel=new ut("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),F.strokeWidthPanel.onWidthChanged=F.setStrokeWidth,F.strokeStylePanel=new rt("Line style",J.defaultStrokeDasharrays,J.defaultStrokeDasharray),F.strokeStylePanel.onStyleChanged=F.setStrokeDasharray,F}return Ce(l,W),Object.defineProperty(l.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),l.prototype.getState=function(){var m=W.prototype.getState.call(this);return m.typeName=l.typeName,m},l.typeName="FrameMarker",l.title="Frame marker",l.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',l}(tt),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(W){function l(m,O,J){var F=W.call(this,m,O,J)||this;return F.x1=0,F.y1=0,F.x2=0,F.y2=0,F.defaultLength=50,F.manipulationStartX=0,F.manipulationStartY=0,F.manipulationStartX1=0,F.manipulationStartY1=0,F.manipulationStartX2=0,F.manipulationStartY2=0,F.setupControlBox(),F}return Ce(l,W),l.prototype.ownsTarget=function(m){return!!W.prototype.ownsTarget.call(this,m)||!(!this.grip1.ownsTarget(m)&&!this.grip2.ownsTarget(m))},l.prototype.pointerDown=function(m,O){W.prototype.pointerDown.call(this,m,O),this.manipulationStartX=m.x,this.manipulationStartY=m.y,this.state==="new"&&(this.x1=m.x,this.y1=m.y,this.x2=m.x,this.y2=m.y),this.manipulationStartX1=this.x1,this.manipulationStartY1=this.y1,this.manipulationStartX2=this.x2,this.manipulationStartY2=this.y2,this.state!=="new"&&(this.select(),this.grip1.ownsTarget(O)?this.activeGrip=this.grip1:this.grip2.ownsTarget(O)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},l.prototype.pointerUp=function(m){var O=this.state;W.prototype.pointerUp.call(this,m),this.state==="creating"&&Math.abs(this.x1-this.x2)<10&&Math.abs(this.y1-this.y2)<10?(this.x2=this.x1+this.defaultLength,this.adjustVisual(),this.adjustControlBox()):this.manipulate(m),this._state="select",O==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},l.prototype.adjustVisual=function(){},l.prototype.manipulate=function(m){this.state==="creating"?this.resize(m):this.state==="move"?(this.x1=this.manipulationStartX1+m.x-this.manipulationStartX,this.y1=this.manipulationStartY1+m.y-this.manipulationStartY,this.x2=this.manipulationStartX2+m.x-this.manipulationStartX,this.y2=this.manipulationStartY2+m.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(m)},l.prototype.resize=function(m){switch(this.activeGrip){case this.grip1:this.x1=m.x,this.y1=m.y;break;case this.grip2:case void 0:this.x2=m.x,this.y2=m.y}this.adjustVisual(),this.adjustControlBox()},l.prototype.select=function(){W.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},l.prototype.deselect=function(){W.prototype.deselect.call(this),this.controlBox.style.display="none"},l.prototype.setupControlBox=function(){this.controlBox=se.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},l.prototype.adjustControlBox=function(){this.positionGrips()},l.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},l.prototype.createGrip=function(){var m=new at;return m.visual.transform.baseVal.appendItem(se.createTransform()),this.controlBox.appendChild(m.visual),m},l.prototype.positionGrips=function(){var m=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-m/2,this.y1-m/2),this.positionGrip(this.grip2.visual,this.x2-m/2,this.y2-m/2)},l.prototype.positionGrip=function(m,O,J){var F=m.transform.baseVal.getItem(0);F.setTranslate(O,J),m.transform.baseVal.replaceItem(F,0)},l.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},W.prototype.getState.call(this))},l.prototype.restoreState=function(m){W.prototype.restoreState.call(this,m);var O=m;this.x1=O.x1,this.y1=O.y1,this.x2=O.x2,this.y2=O.y2},l.prototype.scale=function(m,O){W.prototype.scale.call(this,m,O),this.x1=this.x1*m,this.y1=this.y1*O,this.x2=this.x2*m,this.y2=this.y2*O,this.adjustVisual(),this.adjustControlBox()},l}(Ne),et=function(W){function l(m,O,J){var F=W.call(this,m,O,J)||this;return F.strokeColor="transparent",F.strokeWidth=0,F.strokeDasharray="",F.setStrokeColor=F.setStrokeColor.bind(F),F.setStrokeWidth=F.setStrokeWidth.bind(F),F.setStrokeDasharray=F.setStrokeDasharray.bind(F),F.strokeColor=J.defaultColor,F.strokeWidth=J.defaultStrokeWidth,F.strokeDasharray=J.defaultStrokeDasharray,F.strokePanel=new Fe("Line color",J.defaultColorSet,J.defaultColor),F.strokePanel.onColorChanged=F.setStrokeColor,F.strokeWidthPanel=new ut("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),F.strokeWidthPanel.onWidthChanged=F.setStrokeWidth,F.strokeStylePanel=new rt("Line style",J.defaultStrokeDasharrays,J.defaultStrokeDasharray),F.strokeStylePanel.onStyleChanged=F.setStrokeDasharray,F}return Ce(l,W),l.prototype.ownsTarget=function(m){return!(!W.prototype.ownsTarget.call(this,m)&&m!==this.visual&&m!==this.selectorLine&&m!==this.visibleLine)},l.prototype.createVisual=function(){this.visual=se.createGroup(),this.selectorLine=se.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=se.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.visual.appendChild(this.selectorLine),this.visual.appendChild(this.visibleLine),this.addMarkerVisualToContainer(this.visual)},l.prototype.pointerDown=function(m,O){W.prototype.pointerDown.call(this,m,O),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},l.prototype.adjustVisual=function(){this.selectorLine&&this.visibleLine&&(this.selectorLine.setAttribute("x1",this.x1.toString()),this.selectorLine.setAttribute("y1",this.y1.toString()),this.selectorLine.setAttribute("x2",this.x2.toString()),this.selectorLine.setAttribute("y2",this.y2.toString()),this.visibleLine.setAttribute("x1",this.x1.toString()),this.visibleLine.setAttribute("y1",this.y1.toString()),this.visibleLine.setAttribute("x2",this.x2.toString()),this.visibleLine.setAttribute("y2",this.y2.toString()),se.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),se.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),se.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},l.prototype.setStrokeColor=function(m){this.strokeColor=m,this.adjustVisual(),this.colorChanged(m)},l.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.adjustVisual()},l.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.adjustVisual(),this.stateChanged()},Object.defineProperty(l.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),l.prototype.getState=function(){var m=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},W.prototype.getState.call(this));return m.typeName=l.typeName,m},l.prototype.restoreState=function(m){W.prototype.restoreState.call(this,m);var O=m;this.strokeColor=O.strokeColor,this.strokeWidth=O.strokeWidth,this.strokeDasharray=O.strokeDasharray,this.createVisual(),this.adjustVisual()},l.typeName="LineMarker",l.title="Line marker",l.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',l}(lt),Ae=function(W){function l(m,O,J,F){var de=W.call(this,m,F||'<svg viewBox="0 0 24 24"><path d="M17 8h3v12h1v1h-4v-1h1v-3h-4l-1.5 3H14v1h-4v-1h1l6-12m1 1l-3.5 7H18V9M5 3h5c1.11 0 2 .89 2 2v11H9v-5H6v5H3V5c0-1.11.89-2 2-2m1 2v4h3V5H6z"/></svg>')||this;return de.fonts=[],de.fontBoxes=[],de.fonts=O,de.currentFont=J,de.setCurrentFont=de.setCurrentFont.bind(de),de}return Ce(l,W),l.prototype.getUi=function(){var m=this,O=document.createElement("div");return O.style.overflow="hidden",O.style.flexGrow="2",this.fonts.forEach(function(J){var F=document.createElement("div");F.style.display="inline-block",F.style.alignItems="center",F.style.justifyContent="space-between",F.style.padding="5px",F.style.borderWidth="2px",F.style.borderStyle="solid",F.style.overflow="hidden",F.style.maxWidth=100/m.fonts.length-5+"%",F.style.borderColor=J===m.currentFont?m.uiStyleSettings.toolboxAccentColor:"transparent",F.addEventListener("click",function(){m.setCurrentFont(J,F)}),O.appendChild(F);var de=document.createElement("div");de.style.display="flex",de.style.minHeight="20px",de.style.flexGrow="2",de.style.fontFamily=J,de.style.overflow="hidden";var _e=document.createElement("div");_e.style.whiteSpace="nowrap",_e.style.overflow="hidden",_e.style.textOverflow="ellipsis",_e.innerHTML="The quick brown fox jumps over the lazy dog",de.appendChild(_e),F.appendChild(de),m.fontBoxes.push(F)}),O},l.prototype.setCurrentFont=function(m,O){var J=this;this.currentFont=m,this.fontBoxes.forEach(function(F){F.style.borderColor=F===O?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},l}($e),Ue=function(W){function l(m,O,J){var F=W.call(this,m,O,J)||this;return F.color="transparent",F.padding=5,F.DEFAULT_TEXT="your text here",F.text=F.DEFAULT_TEXT,F.isMoved=!1,F.color=J.defaultColor,F.fontFamily=J.defaultFontFamily,F.defaultSize={x:100,y:30},F.setColor=F.setColor.bind(F),F.setFont=F.setFont.bind(F),F.renderText=F.renderText.bind(F),F.sizeText=F.sizeText.bind(F),F.textEditDivClicked=F.textEditDivClicked.bind(F),F.showTextEditor=F.showTextEditor.bind(F),F.setSize=F.setSize.bind(F),F.positionTextEditor=F.positionTextEditor.bind(F),F.colorPanel=new Fe("Color",J.defaultColorSet,J.defaultColor),F.colorPanel.onColorChanged=F.setColor,F.fontFamilyPanel=new Ae("Font",J.defaultFontFamilies,J.defaultFontFamily),F.fontFamilyPanel.onFontChanged=F.setFont,F}return Ce(l,W),l.prototype.ownsTarget=function(m){if(W.prototype.ownsTarget.call(this,m)||m===this.visual||m===this.textElement||m===this.bgRectangle)return!0;var O=!1;return this.textElement.childNodes.forEach(function(J){J===m&&(O=!0)}),O},l.prototype.createVisual=function(){this.visual=se.createGroup(),this.bgRectangle=se.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=se.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(se.createTransform()),this.textElement.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},l.prototype.pointerDown=function(m,O){W.prototype.pointerDown.call(this,m,O),this.isMoved=!1,this.pointerDownPoint=m,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(m),this._state="creating")},l.prototype.renderText=function(){var m=this;if(this.textElement){for(;this.textElement.lastChild;)this.textElement.removeChild(this.textElement.lastChild);this.text.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/).forEach(function(O){m.textElement.appendChild(se.createTSpan(O.trim()===""?" ":O.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},l.prototype.getTextScale=function(){var m=this.textElement.getBBox(),O=1;if(m.width>0&&m.height>0){var J=(1*this.width-this.width*this.padding*2/100)/m.width,F=(1*this.height-this.height*this.padding*2/100)/m.height;O=Math.min(J,F)}return O},l.prototype.getTextPosition=function(m){var O=this.textElement.getBBox(),J=0,F=0;return O.width>0&&O.height>0&&(J=(this.width-O.width*m)/2,F=this.height/2-O.height*m/2),{x:J,y:F}},l.prototype.sizeText=function(){var m=this.textElement.getBBox(),O=this.getTextScale(),J=this.getTextPosition(O);J.y-=m.y*O,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+J.x+"px, "+J.y+"px) scale("+O+", "+O+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(J.x,J.y),this.textElement.transform.baseVal.getItem(1).setScale(O,O))},l.prototype.manipulate=function(m){W.prototype.manipulate.call(this,m),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(m.x-this.pointerDownPoint.x)>5||Math.abs(m.y-this.pointerDownPoint.y)>5)},l.prototype.resize=function(m){W.prototype.resize.call(this,m),this.isMoved=!0,this.setSize(),this.sizeText()},l.prototype.setSize=function(){W.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(se.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),se.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},l.prototype.pointerUp=function(m){var O=this.state;O==="creating"&&(this._suppressMarkerCreateEvent=!0),W.prototype.pointerUp.call(this,m),this.setSize(),(O==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},l.prototype.showTextEditor=function(){var m=this;this._state="edit",this.overlayContainer.innerHTML="",this.textEditDiv=document.createElement("div"),this.textEditDiv.style.flexGrow="2",this.textEditDiv.style.alignItems="center",this.textEditDiv.style.justifyContent="center",this.textEditDiv.style.pointerEvents="auto",this.textEditDiv.style.overflow="hidden",this.textEditor=document.createElement("div"),this.textEditor.style.position="absolute",this.textEditor.style.fontFamily=this.fontFamily,this.textEditor.style.lineHeight="1em",this.textEditor.innerText=this.text,this.textEditor.contentEditable="true",this.textEditor.style.color=this.color,this.textEditor.style.whiteSpace="pre",this.positionTextEditor(),this.textEditor.addEventListener("pointerup",function(O){O.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var O=Number.parseFloat(m.textEditor.style.fontSize);m.textEditor.clientWidth>=Number.parseInt(m.textEditor.style.maxWidth)&&O>.9;)O-=.1,m.textEditor.style.fontSize=Math.max(O,.9)+"em"}),this.textEditor.addEventListener("keyup",function(O){O.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(O){if(O.clipboardData){var J=O.clipboardData.getData("text"),F=window.getSelection();if(!F.rangeCount)return!1;F.deleteFromDocument(),F.getRangeAt(0).insertNode(document.createTextNode(J)),O.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){m.textEditDivClicked(m.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},l.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var m=this.getTextScale(),O=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),J=this.textElement.getBBox(),F={x:J.width*m,y:J.height*m};O.x-=F.x/2,O.y-=F.y/2,this.textEditor.style.top=O.y+"px",this.textEditor.style.left=O.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-O.x+"px",this.textEditor.style.fontSize=Math.max(16*m,12)+"px",this.textElement.style.display="none"}},l.prototype.textEditDivClicked=function(m){this.text=m.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},l.prototype.select=function(){W.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},l.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),W.prototype.deselect.call(this)},l.prototype.dblClick=function(m,O){W.prototype.dblClick.call(this,m,O),this.showTextEditor()},l.prototype.setColor=function(m){this.textElement&&se.setAttributes(this.textElement,[["fill",m]]),this.color=m,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(m)},l.prototype.setFont=function(m){this.textElement&&se.setAttributes(this.textElement,[["font-family",m]]),this.fontFamily=m,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},l.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},l.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(l.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),l.prototype.getState=function(){var m=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},W.prototype.getState.call(this));return m.typeName=l.typeName,m},l.prototype.restoreState=function(m){var O=m;this.color=O.color,this.fontFamily=O.fontFamily,this.padding=O.padding,this.text=O.text,this.createVisual(),W.prototype.restoreState.call(this,m),this.setSize()},l.prototype.scale=function(m,O){W.prototype.scale.call(this,m,O),this.setSize(),this.sizeText(),this.positionTextEditor()},l.typeName="TextMarker",l.title="Text marker",l.icon='<svg viewBox="0 0 24 24"><path d="M9.6 14L12 7.7l2.4 6.3M11 5L5.5 19h2.2l1.1-3H15l1.1 3h2.2L13 5h-2z"/></svg>',l}(Qe),me=function(W){function l(m,O,J){var F=W.call(this,m,O,J)||this;return F.color="transparent",F.lineWidth=3,F.drawing=!1,F.pixelRatio=1,F.color=J.defaultColor,F.lineWidth=J.defaultStrokeWidth,F.pixelRatio=J.freehandPixelRatio,F.setColor=F.setColor.bind(F),F.addCanvas=F.addCanvas.bind(F),F.finishCreation=F.finishCreation.bind(F),F.setLineWidth=F.setLineWidth.bind(F),F.colorPanel=new Fe("Color",J.defaultColorSet,J.defaultColor),F.colorPanel.onColorChanged=F.setColor,F.lineWidthPanel=new ut("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),F.lineWidthPanel.onWidthChanged=F.setLineWidth,F}return Ce(l,W),l.prototype.ownsTarget=function(m){return!(!W.prototype.ownsTarget.call(this,m)&&m!==this.visual&&m!==this.drawingImage)},l.prototype.createVisual=function(){this.visual=se.createGroup(),this.drawingImage=se.createImage(),this.visual.appendChild(this.drawingImage);var m=se.createTransform();this.visual.transform.baseVal.appendItem(m),this.addMarkerVisualToContainer(this.visual)},l.prototype.pointerDown=function(m,O){this.state==="new"&&(this.addCanvas(),this.createVisual(),this._state="creating"),this.state==="creating"?(this.canvasContext.strokeStyle=this.color,this.canvasContext.lineWidth=this.lineWidth,this.canvasContext.beginPath(),this.canvasContext.moveTo(m.x,m.y),this.drawing=!0):W.prototype.pointerDown.call(this,m,O)},l.prototype.manipulate=function(m){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(m.x,m.y),this.canvasContext.stroke()):W.prototype.manipulate.call(this,m)},l.prototype.resize=function(m){W.prototype.resize.call(this,m),se.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),se.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},l.prototype.pointerUp=function(m){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):W.prototype.pointerUp.call(this,m)},l.prototype.addCanvas=function(){this.overlayContainer.innerHTML="",this.canvasElement=document.createElement("canvas"),this.canvasElement.width=this.overlayContainer.clientWidth*this.pixelRatio,this.canvasElement.height=this.overlayContainer.clientHeight*this.pixelRatio,this.canvasContext=this.canvasElement.getContext("2d"),this.canvasContext.scale(this.pixelRatio,this.pixelRatio),this.overlayContainer.appendChild(this.canvasElement)},l.prototype.select=function(){this.state==="creating"&&this.finishCreation(),W.prototype.select.call(this)},l.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),W.prototype.deselect.call(this)},l.prototype.finishCreation=function(){for(var m=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),O=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],J=O[0],F=O[1],de=O[2],_e=O[3],Ye=!1,mt=0;mt<this.canvasElement.height;mt++)for(var Ie=0;Ie<this.canvasElement.width;Ie++)m.data[mt*this.canvasElement.width*4+4*Ie+3]>0&&(Ye=!0,mt<F&&(F=mt),Ie<J&&(J=Ie),mt>_e&&(_e=mt),Ie>de&&(de=Ie));if(Ye){this.left=J/this.pixelRatio,this.top=F/this.pixelRatio,this.width=(de-J)/this.pixelRatio,this.height=(_e-F)/this.pixelRatio;var St=document.createElement("canvas");St.width=de-J,St.height=_e-F,St.getContext("2d").putImageData(this.canvasContext.getImageData(J,F,de-J,_e-F),0,0),this.drawingImgUrl=St.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},l.prototype.setDrawingImage=function(){se.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),se.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},l.prototype.setColor=function(m){this.color=m,this.colorChanged(m)},l.prototype.setLineWidth=function(m){this.lineWidth=m},Object.defineProperty(l.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),l.prototype.getState=function(){var m=Object.assign({drawingImgUrl:this.drawingImgUrl},W.prototype.getState.call(this));return m.typeName=l.typeName,m},l.prototype.restoreState=function(m){this.createVisual(),W.prototype.restoreState.call(this,m),this.drawingImgUrl=m.drawingImgUrl,this.setDrawingImage()},l.prototype.scale=function(m,O){W.prototype.scale.call(this,m,O),this.setDrawingImage()},l.typeName="FreehandMarker",l.title="Freehand marker",l.icon='<svg viewBox="0 0 24 24"><path d="M9.75 20.85c1.78-.7 1.39-2.63.49-3.85-.89-1.25-2.12-2.11-3.36-2.94A9.817 9.817 0 014.54 12c-.28-.33-.85-.94-.27-1.06.59-.12 1.61.46 2.13.68.91.38 1.81.82 2.65 1.34l1.01-1.7C8.5 10.23 6.5 9.32 4.64 9.05c-1.06-.16-2.18.06-2.54 1.21-.32.99.19 1.99.77 2.77 1.37 1.83 3.5 2.71 5.09 4.29.34.33.75.72.95 1.18.21.44.16.47-.31.47-1.24 0-2.79-.97-3.8-1.61l-1.01 1.7c1.53.94 4.09 2.41 5.96 1.79m11.09-15.6c.22-.22.22-.58 0-.79l-1.3-1.3a.562.562 0 00-.78 0l-1.02 1.02 2.08 2.08M11 10.92V13h2.08l6.15-6.15-2.08-2.08L11 10.92z"/></svg>',l}(Qe),he=function(W){function l(m,O,J){var F=W.call(this,m,J||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return F.typeBoxes=[],F.currentType=O,F.setCurrentType=F.setCurrentType.bind(F),F}return Ce(l,W),l.prototype.getUi=function(){var m=this,O=document.createElement("div");O.style.display="flex",O.style.overflow="hidden",O.style.flexGrow="2";for(var J=function(_e){var Ye="both";switch(_e){case 0:Ye="both";break;case 1:Ye="start";break;case 2:Ye="end";break;case 3:Ye="none"}var mt=document.createElement("div");if(mt.style.display="flex",mt.style.flexGrow="2",mt.style.alignItems="center",mt.style.justifyContent="space-between",mt.style.padding="5px",mt.style.borderWidth="2px",mt.style.borderStyle="solid",mt.style.borderColor=Ye===F.currentType?F.uiStyleSettings.toolboxAccentColor:"transparent",mt.addEventListener("click",function(){m.setCurrentType(Ye,mt)}),O.appendChild(mt),Ye==="both"||Ye==="start"){var Ie=document.createElement("div");Ie.style.display="flex",Ie.style.alignItems="center",Ie.style.minHeight="20px",Ie.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
|
|
<polygon points="0,5 10,0 10,10" fill="`+(F.uiStyleSettings!==void 0?F.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,Ie.style.marginLeft="5px",mt.appendChild(Ie)}var St=document.createElement("div");St.style.display="flex",St.style.alignItems="center",St.style.minHeight="20px",St.style.flexGrow="2";var Ft=document.createElement("hr");if(Ft.style.minWidth="20px",Ft.style.border="0px",Ft.style.borderTop="3px solid "+(F.uiStyleSettings!==void 0?F.uiStyleSettings.toolboxColor:"#eeeeee"),Ft.style.flexGrow="2",St.appendChild(Ft),mt.appendChild(St),Ye==="both"||Ye==="end"){var Xt=document.createElement("div");Xt.style.display="flex",Xt.style.alignItems="center",Xt.style.minHeight="20px",Xt.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="`+(F.uiStyleSettings!==void 0?F.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,Xt.style.marginRight="5px",mt.appendChild(Xt)}F.typeBoxes.push(mt)},F=this,de=0;de<4;de++)J(de);return O},l.prototype.setCurrentType=function(m,O){var J=this;this.currentType=m,this.typeBoxes.forEach(function(F){F.style.borderColor=F===O?J.uiStyleSettings!==void 0?J.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},l}($e),fe=function(W){function l(m,O,J){var F=W.call(this,m,O,J)||this;return F.arrowType="end",F.arrowBaseHeight=10,F.arrowBaseWidth=10,F.getArrowPoints=F.getArrowPoints.bind(F),F.setArrowType=F.setArrowType.bind(F),F.arrowTypePanel=new he("Arrow type","end"),F.arrowTypePanel.onArrowTypeChanged=F.setArrowType,F}return Ce(l,W),l.prototype.ownsTarget=function(m){return!(!W.prototype.ownsTarget.call(this,m)&&m!==this.arrow1&&m!==this.arrow2)},l.prototype.getArrowPoints=function(m,O){var J=this.arrowBaseWidth+2*this.strokeWidth,F=this.arrowBaseHeight+2*this.strokeWidth;return m-J/2+","+(O+F/2)+" "+m+","+(O-F/2)+" "+(m+J/2)+","+(O+F/2)},l.prototype.createTips=function(){this.arrow1=se.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=se.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.arrow2)},l.prototype.pointerDown=function(m,O){W.prototype.pointerDown.call(this,m,O),this.state==="creating"&&this.createTips()},l.prototype.adjustVisual=function(){if(W.prototype.adjustVisual.call(this),this.arrow1&&this.arrow2&&(this.arrow1.style.display=this.arrowType==="both"||this.arrowType==="start"?"":"none",this.arrow2.style.display=this.arrowType==="both"||this.arrowType==="end"?"":"none",se.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),se.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var m=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),O=this.arrow1.transform.baseVal.getItem(0);O.setRotate(m,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(O,0);var J=this.arrow2.transform.baseVal.getItem(0);J.setRotate(m+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(J,0)}},l.prototype.setArrowType=function(m){this.arrowType=m,this.adjustVisual(),this.stateChanged()},Object.defineProperty(l.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),l.prototype.getState=function(){var m=Object.assign({arrowType:this.arrowType},W.prototype.getState.call(this));return m.typeName=l.typeName,m},l.prototype.restoreState=function(m){W.prototype.restoreState.call(this,m);var O=m;this.arrowType=O.arrowType,this.createTips(),this.adjustVisual()},l.typeName="ArrowMarker",l.title="Arrow marker",l.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',l}(et),ee=function(W){function l(m,O,J){var F=W.call(this,m,O,J)||this;return F.fillColor=J.defaultFillColor,F.strokeWidth=0,F.fillPanel=new Fe("Color",J.defaultColorSet,J.defaultFillColor),F.fillPanel.onColorChanged=F.setFillColor,F}return Ce(l,W),Object.defineProperty(l.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),l.prototype.getState=function(){var m=W.prototype.getState.call(this);return m.typeName=l.typeName,m},l.typeName="CoverMarker",l.title="Cover marker",l.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',l}(tt),te=function(W){function l(m,O,J,F){var de=W.call(this,m,F||'<svg viewBox="0 0 24 24"><path d="M17.66 8L12 2.35 6.34 8A8.02 8.02 0 004 13.64c0 2 .78 4.11 2.34 5.67a7.99 7.99 0 0011.32 0c1.56-1.56 2.34-3.67 2.34-5.67S19.22 9.56 17.66 8M6 14c0-2 .62-3.27 1.76-4.4L12 5.27l4.24 4.38C17.38 10.77 18 12 18 14H6z"/></svg>')||this;return de.opacities=[],de.opacityBoxes=[],de.opacities=O,de.currentOpacity=J,de.setCurrentOpacity=de.setCurrentOpacity.bind(de),de}return Ce(l,W),l.prototype.getUi=function(){var m=this,O=document.createElement("div");return O.style.display="flex",O.style.overflow="hidden",O.style.flexGrow="2",O.style.justifyContent="space-between",this.opacities.forEach(function(J){var F=document.createElement("div");F.style.display="flex",F.style.alignItems="center",F.style.justifyContent="center",F.style.padding="5px",F.style.borderWidth="2px",F.style.borderStyle="solid",F.style.borderColor=J===m.currentOpacity?m.uiStyleSettings.toolboxAccentColor:"transparent",F.addEventListener("click",function(){m.setCurrentOpacity(J,F)}),O.appendChild(F);var de=document.createElement("div");de.innerText=100*J+"%",F.appendChild(de),m.opacityBoxes.push(F)}),O},l.prototype.setCurrentOpacity=function(m,O){var J=this;this.currentOpacity=m,this.opacityBoxes.forEach(function(F){F.style.borderColor=F===O?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},l}($e),ae=function(W){function l(m,O,J){var F=W.call(this,m,O,J)||this;return F.setOpacity=F.setOpacity.bind(F),F.fillColor=J.defaultHighlightColor,F.strokeWidth=0,F.opacity=J.defaultHighlightOpacity,F.fillPanel=new Fe("Color",J.defaultColorSet,F.fillColor),F.fillPanel.onColorChanged=F.setFillColor,F.opacityPanel=new te("Opacity",J.defaultOpacitySteps,F.opacity),F.opacityPanel.onOpacityChanged=F.setOpacity,F}return Ce(l,W),l.prototype.setOpacity=function(m){this.opacity=m,this.visual&&se.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(l.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),l.prototype.getState=function(){var m=W.prototype.getState.call(this);return m.typeName=l.typeName,m},l.typeName="HighlightMarker",l.title="Highlight marker",l.icon='<svg viewBox="0 0 24 24"><path d="M18.5 1.15c-.53 0-1.04.19-1.43.58l-5.81 5.82 5.65 5.65 5.82-5.81c.77-.78.77-2.04 0-2.83l-2.84-2.83c-.39-.39-.89-.58-1.39-.58M10.3 8.5l-5.96 5.96c-.78.78-.78 2.04.02 2.85C3.14 18.54 1.9 19.77.67 21h5.66l.86-.86c.78.76 2.03.75 2.81-.02l5.95-5.96"/></svg>',l}(ee),ue='<svg viewBox="0 0 24 24"><path d="M19 11.5s-2 2.17-2 3.5a2 2 0 002 2 2 2 0 002-2c0-1.33-2-3.5-2-3.5M5.21 10L10 5.21 14.79 10m1.77-1.06L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.56-.59 1.53 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.59.59-1.56 0-2.12z"/></svg>',ge=function(W){function l(m,O,J){var F=W.call(this,m,O,J)||this;return F.bgColor="transparent",F.tipPosition={x:0,y:0},F.tipBase1Position={x:0,y:0},F.tipBase2Position={x:0,y:0},F.tipMoving=!1,F.color=J.defaultStrokeColor,F.bgColor=J.defaultFillColor,F.fontFamily=J.defaultFontFamily,F.defaultSize={x:100,y:30},F.setBgColor=F.setBgColor.bind(F),F.getTipPoints=F.getTipPoints.bind(F),F.positionTip=F.positionTip.bind(F),F.setTipPoints=F.setTipPoints.bind(F),F.colorPanel=new Fe("Text color",J.defaultColorSet,F.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>'),F.colorPanel.onColorChanged=F.setColor,F.bgColorPanel=new Fe("Fill color",J.defaultColorSet,F.bgColor,ue),F.bgColorPanel.onColorChanged=F.setBgColor,F.fontFamilyPanel=new Ae("Font",J.defaultFontFamilies,J.defaultFontFamily),F.fontFamilyPanel.onFontChanged=F.setFont,F.tipGrip=new at,F.tipGrip.visual.transform.baseVal.appendItem(se.createTransform()),F.controlBox.appendChild(F.tipGrip.visual),F}return Ce(l,W),l.prototype.ownsTarget=function(m){return W.prototype.ownsTarget.call(this,m)||this.tipGrip.ownsTarget(m)||this.tip===m},l.prototype.createTip=function(){se.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=se.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},l.prototype.pointerDown=function(m,O){this.state==="new"&&W.prototype.pointerDown.call(this,m,O),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(O)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):W.prototype.pointerDown.call(this,m,O)},l.prototype.pointerUp=function(m){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,W.prototype.pointerUp.call(this,m);else{var O=this.state==="creating";W.prototype.pointerUp.call(this,m),this.setTipPoints(O),this.positionTip()}},l.prototype.manipulate=function(m){if(this.tipMoving){var O=this.unrotatePoint(m);this.tipPosition={x:O.x-this.manipulationStartLeft,y:O.y-this.manipulationStartTop},this.positionTip()}else W.prototype.manipulate.call(this,m)},l.prototype.setBgColor=function(m){this.bgRectangle&&this.tip&&(se.setAttributes(this.bgRectangle,[["fill",m]]),se.setAttributes(this.tip,[["fill",m]])),this.bgColor=m,this.fillColorChanged(m)},l.prototype.getTipPoints=function(){return this.setTipPoints(this.state==="creating"),this.tipBase1Position.x+","+this.tipBase1Position.y+" "+this.tipBase2Position.x+","+this.tipBase2Position.y+" "+this.tipPosition.x+","+this.tipPosition.y},l.prototype.setTipPoints=function(m){m===void 0&&(m=!1);var O=Math.min(this.height/2,15),J=this.height/5;m&&(this.tipPosition={x:O+J/2,y:this.height+20});var F=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?F<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(J=this.width/5,O=Math.min(this.width/2,15),this.tipBase1Position={x:O,y:0},this.tipBase2Position={x:O+J,y:0}):(this.tipBase1Position={x:0,y:O},this.tipBase2Position={x:0,y:O+J}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?F<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(J=this.width/5,O=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-O-J,y:0},this.tipBase2Position={x:this.width-O,y:0}):(this.tipBase1Position={x:this.width,y:O},this.tipBase2Position={x:this.width,y:O+J}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?F<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(J=this.width/5,O=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-O-J,y:this.height},this.tipBase2Position={x:this.width-O,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-O-J},this.tipBase2Position={x:this.width,y:this.height-O}):F<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(J=this.width/5,O=Math.min(this.width/2,15),this.tipBase1Position={x:O,y:this.height},this.tipBase2Position={x:O+J,y:this.height}):(this.tipBase1Position={x:0,y:this.height-O},this.tipBase2Position={x:0,y:this.height-O-J})},l.prototype.resize=function(m){W.prototype.resize.call(this,m),this.positionTip()},l.prototype.positionTip=function(){se.setAttributes(this.tip,[["points",this.getTipPoints()]]);var m=this.tipGrip.visual.transform.baseVal.getItem(0);m.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(m,0)},Object.defineProperty(l.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),l.prototype.select=function(){this.positionTip(),W.prototype.select.call(this)},l.prototype.getState=function(){var m=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},W.prototype.getState.call(this));return m.typeName=l.typeName,m},l.prototype.restoreState=function(m){var O=m;this.bgColor=O.bgColor,this.tipPosition=O.tipPosition,W.prototype.restoreState.call(this,m),this.createTip(),this.setTipPoints()},l.prototype.scale=function(m,O){W.prototype.scale.call(this,m,O),this.tipPosition={x:this.tipPosition.x*m,y:this.tipPosition.y*O},this.positionTip()},l.typeName="CalloutMarker",l.title="Callout marker",l.icon='<svg viewBox="0 0 24 24"><path d="M4 2h16a2 2 0 012 2v12a2 2 0 01-2 2h-4l-4 4-4-4H4a2 2 0 01-2-2V4a2 2 0 012-2m0 2v12h4.83L12 19.17 15.17 16H20V4H4m2 3h12v2H6V7m0 4h10v2H6v-2z"/></svg>',l}(Ue),Se=function(W){function l(m,O,J){var F=W.call(this,m,O,J)||this;return F.fillColor="transparent",F.strokeColor="transparent",F.strokeWidth=0,F.strokeDasharray="",F.opacity=1,F.strokeColor=J.defaultColor,F.strokeWidth=J.defaultStrokeWidth,F.strokeDasharray=J.defaultStrokeDasharray,F.fillColor=J.defaultFillColor,F.setStrokeColor=F.setStrokeColor.bind(F),F.setFillColor=F.setFillColor.bind(F),F.setStrokeWidth=F.setStrokeWidth.bind(F),F.setStrokeDasharray=F.setStrokeDasharray.bind(F),F.setOpacity=F.setOpacity.bind(F),F.createVisual=F.createVisual.bind(F),F.strokePanel=new Fe("Line color",pe(J.defaultColorSet,["transparent"]),J.defaultColor),F.strokePanel.onColorChanged=F.setStrokeColor,F.fillPanel=new Fe("Fill color",pe(J.defaultColorSet,["transparent"]),F.fillColor,ue),F.fillPanel.onColorChanged=F.setFillColor,F.strokeWidthPanel=new ut("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),F.strokeWidthPanel.onWidthChanged=F.setStrokeWidth,F.strokeStylePanel=new rt("Line style",J.defaultStrokeDasharrays,J.defaultStrokeDasharray),F.strokeStylePanel.onStyleChanged=F.setStrokeDasharray,F.opacityPanel=new te("Opacity",J.defaultOpacitySteps,F.opacity),F.opacityPanel.onOpacityChanged=F.setOpacity,F}return Ce(l,W),l.prototype.ownsTarget=function(m){return!(!W.prototype.ownsTarget.call(this,m)&&m!==this.visual)},l.prototype.createVisual=function(){this.visual=se.createEllipse(this.width/2,this.height/2,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},l.prototype.pointerDown=function(m,O){W.prototype.pointerDown.call(this,m,O),this.state==="new"&&(this.createVisual(),this.moveVisual(m),this._state="creating")},l.prototype.manipulate=function(m){W.prototype.manipulate.call(this,m)},l.prototype.resize=function(m){W.prototype.resize.call(this,m),this.setSize()},l.prototype.setSize=function(){W.prototype.setSize.call(this),se.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},l.prototype.pointerUp=function(m){W.prototype.pointerUp.call(this,m),this.setSize()},l.prototype.setStrokeColor=function(m){this.strokeColor=m,this.visual&&se.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(m),this.stateChanged()},l.prototype.setFillColor=function(m){this.fillColor=m,this.visual&&se.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(m),this.stateChanged()},l.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.visual&&se.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},l.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.visual&&se.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},l.prototype.setOpacity=function(m){this.opacity=m,this.visual&&se.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(l.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),l.prototype.getState=function(){var m=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},W.prototype.getState.call(this));return m.typeName=l.typeName,m},l.prototype.restoreState=function(m){var O=m;this.fillColor=O.fillColor,this.strokeColor=O.strokeColor,this.strokeWidth=O.strokeWidth,this.strokeDasharray=O.strokeDasharray,this.opacity=O.opacity,this.createVisual(),W.prototype.restoreState.call(this,m),this.setSize()},l.prototype.scale=function(m,O){W.prototype.scale.call(this,m,O),this.setSize()},l.typeName="EllipseMarker",l.title="Ellipse marker",l.icon='<svg viewBox="0 0 24 24"><path d="M12 4C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',l}(Qe),Oe=function(W){function l(m,O,J){return W.call(this,m,O,J)||this}return Ce(l,W),Object.defineProperty(l.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),l.prototype.ownsTarget=function(m){return!(!W.prototype.ownsTarget.call(this,m)&&m!==this.tip1&&m!==this.tip2)},l.prototype.createTips=function(){this.tip1=se.createLine(this.x1-this.tipLength/2,this.y1,this.x1+this.tipLength/2,this.y1,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip1.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.tip1),this.tip2=se.createLine(this.x2-this.tipLength/2,this.y2,this.x2+this.tipLength/2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip2.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.tip2)},l.prototype.pointerDown=function(m,O){W.prototype.pointerDown.call(this,m,O),this.state==="creating"&&this.createTips()},l.prototype.adjustVisual=function(){if(W.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(se.setAttributes(this.tip1,[["x1",(this.x1-this.tipLength/2).toString()],["y1",this.y1.toString()],["x2",(this.x1+this.tipLength/2).toString()],["y2",this.y1.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),se.setAttributes(this.tip2,[["x1",(this.x2-this.tipLength/2).toString()],["y1",this.y2.toString()],["x2",(this.x2+this.tipLength/2).toString()],["y2",this.y2.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),Math.abs(this.x1-this.x2)>.1)){var m=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),O=this.tip1.transform.baseVal.getItem(0);O.setRotate(m,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(O,0);var J=this.tip2.transform.baseVal.getItem(0);J.setRotate(m+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(J,0)}},Object.defineProperty(l.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),l.prototype.getState=function(){var m=W.prototype.getState.call(this);return m.typeName=l.typeName,m},l.prototype.restoreState=function(m){W.prototype.restoreState.call(this,m),this.createTips(),this.adjustVisual()},l.typeName="MeasurementMarker",l.title="Measurement marker",l.icon='<svg viewBox="0 0 24 24"><path d="M1.39 18.36l1.77-1.76L4.58 18l1.06-1.05-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.42 1.41L10.59 12l-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.41 1.41 1.07-1.06-1.42-1.41 1.42-1.42L18 6.7l1.07-1.06-2.47-2.48 1.76-1.77 4.25 4.25L5.64 22.61l-4.25-4.25z"/></svg>',l}(et),nt=function(W){function l(m,O,J){var F=W.call(this,m,O,J)||this;return F.strokePanel.colors=J.defaultColorSet,F.fillColor="transparent",F}return Ce(l,W),Object.defineProperty(l.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),l.prototype.getState=function(){var m=W.prototype.getState.call(this);return m.typeName=l.typeName,m},l.typeName="EllipseFrameMarker",l.title="Ellipse frame marker",l.icon='<svg viewBox="0 0 24 24"><path d="M12 6c4.41 0 8 2.69 8 6s-3.59 6-8 6-8-2.69-8-6 3.59-6 8-6m0-2C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',l}(Se),gt=function(){function W(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(W.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),W.prototype.addUndoStep=function(l){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(l)||(this.undoStack.push(l),JSON.stringify(this.lastRedoStep)!==JSON.stringify(l)&&this.redoStack.splice(0,this.redoStack.length))},W.prototype.replaceLastUndoStep=function(l){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=l)},W.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},W.prototype.undo=function(){if(this.undoStack.length>1){var l=this.undoStack.pop();return l!==void 0&&this.redoStack.push(l),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},W.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},W}(),ct=function(W){function l(m,O,J){var F=W.call(this,m,O,J)||this;return F.strokeColor="transparent",F.strokeWidth=0,F.strokeDasharray="",F.curveX=0,F.curveY=0,F.manipulationStartCurveX=0,F.manipulationStartCurveY=0,F.setStrokeColor=F.setStrokeColor.bind(F),F.setStrokeWidth=F.setStrokeWidth.bind(F),F.setStrokeDasharray=F.setStrokeDasharray.bind(F),F.positionGrips=F.positionGrips.bind(F),F.addControlGrips=F.addControlGrips.bind(F),F.adjustVisual=F.adjustVisual.bind(F),F.setupControlBox=F.setupControlBox.bind(F),F.resize=F.resize.bind(F),F.strokeColor=J.defaultColor,F.strokeWidth=J.defaultStrokeWidth,F.strokeDasharray=J.defaultStrokeDasharray,F.strokePanel=new Fe("Line color",J.defaultColorSet,J.defaultColor),F.strokePanel.onColorChanged=F.setStrokeColor,F.strokeWidthPanel=new ut("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),F.strokeWidthPanel.onWidthChanged=F.setStrokeWidth,F.strokeStylePanel=new rt("Line style",J.defaultStrokeDasharrays,J.defaultStrokeDasharray),F.strokeStylePanel.onStyleChanged=F.setStrokeDasharray,F}return Ce(l,W),l.prototype.ownsTarget=function(m){return!(!W.prototype.ownsTarget.call(this,m)&&m!==this.visual&&m!==this.selectorCurve&&m!==this.visibleCurve&&!this.curveGrip.ownsTarget(m))},l.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},l.prototype.createVisual=function(){this.visual=se.createGroup(),this.selectorCurve=se.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=se.createPath(this.getPathD(),[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["fill","transparent"]]),this.visual.appendChild(this.selectorCurve),this.visual.appendChild(this.visibleCurve),this.addMarkerVisualToContainer(this.visual)},l.prototype.pointerDown=function(m,O){W.prototype.pointerDown.call(this,m,O),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=m.x,this.curveY=m.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(O)&&(this.activeGrip=this.curveGrip,this._state="resize")},l.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),se.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),se.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),se.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},l.prototype.setupControlBox=function(){W.prototype.setupControlBox.call(this),this.curveControlLine1=se.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=se.createLine(this.x2,this.y2,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.insertBefore(this.curveControlLine1,this.controlBox.firstChild),this.controlBox.insertBefore(this.curveControlLine2,this.controlBox.firstChild)},l.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,W.prototype.addControlGrips.call(this)},l.prototype.positionGrips=function(){W.prototype.positionGrips.call(this);var m=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-m/2,this.curveY-m/2),this.curveControlLine1&&this.curveControlLine2&&(this.curveControlLine1.setAttribute("x1",this.x1.toString()),this.curveControlLine1.setAttribute("y1",this.y1.toString()),this.curveControlLine1.setAttribute("x2",this.curveX.toString()),this.curveControlLine1.setAttribute("y2",this.curveY.toString()),this.curveControlLine2.setAttribute("x1",this.x2.toString()),this.curveControlLine2.setAttribute("y1",this.y2.toString()),this.curveControlLine2.setAttribute("x2",this.curveX.toString()),this.curveControlLine2.setAttribute("y2",this.curveY.toString()))},l.prototype.manipulate=function(m){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+m.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+m.y-this.manipulationStartY),W.prototype.manipulate.call(this,m)},l.prototype.resize=function(m){this.activeGrip===this.curveGrip&&(this.curveX=m.x,this.curveY=m.y),W.prototype.resize.call(this,m),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},l.prototype.setStrokeColor=function(m){this.strokeColor=m,this.adjustVisual(),this.colorChanged(m)},l.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.adjustVisual()},l.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.adjustVisual()},l.prototype.scale=function(m,O){this.curveX=this.curveX*m,this.curveY=this.curveY*O,W.prototype.scale.call(this,m,O)},Object.defineProperty(l.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),l.prototype.getState=function(){var m=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},W.prototype.getState.call(this));return m.typeName=l.typeName,m},l.prototype.restoreState=function(m){W.prototype.restoreState.call(this,m);var O=m;this.strokeColor=O.strokeColor,this.strokeWidth=O.strokeWidth,this.strokeDasharray=O.strokeDasharray,this.curveX=O.curveX,this.curveY=O.curveY,this.createVisual(),this.adjustVisual()},l.typeName="CurveMarker",l.title="Curve marker",l.icon='<svg viewBox="0 0 24 24"><path d="M18.5 2A1.5 1.5 0 0120 3.5 1.5 1.5 0 0118.5 5c-.23 0-.45-.05-.65-.15l-3.69 3.7.34.45c2.19-1.26 4.76-2 7.5-2l1 .03v2.01L22 9c-2.58 0-5 .75-7 2.04A3.96 3.96 0 0111.04 15C9.75 17 9 19.42 9 22l.04 1H7.03L7 22c0-2.74.74-5.31 2-7.5l-.45-.34-3.7 3.69c.1.2.15.42.15.65A1.5 1.5 0 013.5 20 1.5 1.5 0 012 18.5 1.5 1.5 0 013.5 17c.23 0 .45.05.65.15l3.69-3.7C7.31 12.78 7 11.92 7 11a4 4 0 014-4c.92 0 1.78.31 2.45.84l3.7-3.69c-.1-.2-.15-.42-.15-.65A1.5 1.5 0 0118.5 2M11 9a2 2 0 00-2 2 2 2 0 002 2 2 2 0 002-2 2 2 0 00-2-2z"/></svg>',l}(lt),kt=function(){function W(l,m){m===void 0&&(m=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=l,this.cancelable=m}return Object.defineProperty(W.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),W.prototype.preventDefault=function(){this._defaultPrevented=!0},W}(),ot=function(W){function l(m,O,J){var F=W.call(this,m,!1)||this;return F.dataUrl=O,F.state=J,F}return Ce(l,W),l}(kt),We=function(W){function l(m,O,J){J===void 0&&(J=!1);var F=W.call(this,m,J)||this;return F.marker=O,F}return Ce(l,W),l}(kt),yt=function(){function W(){this.render=[],this.beforeclose=[],this.close=[],this.show=[],this.restorestate=[],this.statechange=[],this.markerselect=[],this.markerdeselect=[],this.markercreating=[],this.markercreate=[],this.markerbeforedelete=[],this.markerdelete=[],this.markerchange=[],this.focus=[],this.blur=[]}return W.prototype.addEventListener=function(l,m){this[l].push(m)},W.prototype.removeEventListener=function(l,m){var O=this[l].indexOf(m);O>-1&&this[l].splice(O,1)},W}(),ft=function(){function W(l){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new we,this._isOpen=!1,this.undoRedoManager=new gt,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 yt,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=W.instanceCounter++,this.styles=new Ke(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=l,this.targetRoot=document.body,this.width=l.clientWidth,this.height=l.clientHeight,this.styles.removeStyleSheet(),this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.toolbarButtonClicked=this.toolbarButtonClicked.bind(this),this.createNewMarker=this.createNewMarker.bind(this),this.addNewMarker=this.addNewMarker.bind(this),this.markerCreated=this.markerCreated.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onDblClick=this.onDblClick.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOut=this.onPointerOut.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.deleteSelectedMarker=this.deleteSelectedMarker.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.removeMarker=this.removeMarker.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this),this.onPopupTargetResize=this.onPopupTargetResize.bind(this),this.showNotesEditor=this.showNotesEditor.bind(this),this.hideNotesEditor=this.hideNotesEditor.bind(this),this.stepZoom=this.stepZoom.bind(this),this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.markerStateChanged=this.markerStateChanged.bind(this),this.switchToSelectMode=this.switchToSelectMode.bind(this),this.addDefs=this.addDefs.bind(this),this.addDefsToImage=this.addDefsToImage.bind(this)}return Object.defineProperty(W.prototype,"ALL_MARKER_TYPES",{get:function(){return[it,me,fe,Ue,nt,Se,ae,ge,Oe,ee,et,ct]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[it,me,fe,Ue,Se,ae,ge]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"BASIC_MARKER_TYPES",{get:function(){return[it,me,fe,Ue,ae]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(l){var m=this;this._availableMarkerTypes.splice(0),l.forEach(function(O){if(typeof O=="string"){var J=m.ALL_MARKER_TYPES.find(function(F){return F.typeName===O});J!==void 0&&m._availableMarkerTypes.push(J)}else m._availableMarkerTypes.push(O)})},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(l){this._zoomLevel=l,this.editorCanvas&&this.contentDiv&&(this.editorCanvas.style.transform="scale("+this._zoomLevel+")",this.contentDiv.scrollTo({left:(this.editorCanvas.clientWidth*this._zoomLevel-this.contentDiv.clientWidth)/2,top:(this.editorCanvas.clientHeight*this._zoomLevel-this.contentDiv.clientHeight)/2}))},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),W.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),Le.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},W.prototype.show=function(){var l=this;this.styles.styleSheetRoot===void 0&&Ge.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=Ge.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(m){return m(new kt(l))})},W.prototype.render=function(){return Te(this,void 0,void 0,function(){var l;return Ee(this,function(m){switch(m.label){case 0:return this.setCurrentMarker(),(l=new Xe).naturalSize=this.renderAtNaturalSize,l.imageType=this.renderImageType,l.imageQuality=this.renderImageQuality,l.markersOnly=this.renderMarkersOnly,l.width=this.renderWidth,l.height=this.renderHeight,[4,l.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return m.sent(),[4,l.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,m.sent()]}})})},W.prototype.close=function(l){var m=this;if(l===void 0&&(l=!1),this.isOpen){var O=!1;l||this.eventListeners.beforeclose.forEach(function(J){var F=new kt(m,!0);J(F),F.defaultPrevented&&(O=!0)}),O||(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(J){return J(new kt(m))}),this.detachEvents(),this._isOpen=!1)}},W.prototype.addMarkersToToolbar=function(){for(var l,m=[],O=0;O<arguments.length;O++)m[O]=arguments[O];(l=this._availableMarkerTypes).push.apply(l,m)},W.prototype.addRenderEventListener=function(l){this.addEventListener("render",function(m){l(m.dataUrl,m.state)})},W.prototype.removeRenderEventListener=function(l){},W.prototype.addCloseEventListener=function(l){this.addEventListener("close",function(){l()})},W.prototype.removeCloseEventListener=function(l){},W.prototype.setupResizeObserver=function(){var l=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){l.resize(l.target.clientWidth,l.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return l.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},W.prototype.onPopupTargetResize=function(){var l=1*this.target.clientWidth/this.target.clientHeight,m=this.editorCanvas.clientWidth/l>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*l:this.editorCanvas.clientWidth,O=m<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/l;this.resize(m,O)},W.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},W.prototype.resize=function(l,m){this._isResizing=!0;var O=l/this.imageWidth,J=m/this.imageHeight;this.imageWidth=Math.round(l),this.imageHeight=Math.round(m),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(O,J),this._isResizing=!1},W.prototype.scaleMarkers=function(l,m){var O,J=this;this._currentMarker&&this._currentMarker instanceof Ue?this._currentMarker.scale(l,m):(O=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(F){F!==J._currentMarker&&F.scale(l,m)}),O!==void 0&&this.setCurrentMarker(O)},W.prototype.setEditingTarget=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px"},W.prototype.setTopLeft=function(){var l=this.editingTarget.getBoundingClientRect(),m=this.editorCanvas.getBoundingClientRect();this.left=l.left-m.left,this.top=l.top-m.top},W.prototype.initMarkerCanvas=function(){this.markerImageHolder=document.createElement("div"),this.markerImageHolder.style.setProperty("touch-action","pinch-zoom"),this.markerImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.markerImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImage.style.pointerEvents="auto",this.markerImageHolder.style.position="absolute",this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.markerImageHolder.style.transformOrigin="top left",this.positionMarkerImage(),this.markerImageHolder.appendChild(this.markerImage),this.editorCanvas.appendChild(this.markerImageHolder)},W.prototype.addDefs=function(){for(var l,m=[],O=0;O<arguments.length;O++)m[O]=arguments[O];this.defs=se.createDefs(),this.addDefsToImage(),(l=this.defs).append.apply(l,m)},W.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},W.prototype.initOverlay=function(){this.overlayContainer=document.createElement("div"),this.overlayContainer.style.position="absolute",this.overlayContainer.style.left="0px",this.overlayContainer.style.top="0px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.overlayContainer.style.display="flex",this.markerImageHolder.appendChild(this.overlayContainer)},W.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},W.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},W.prototype.attachWindowEvents=function(){window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp),window.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("pointerout",this.onPointerOut),window.addEventListener("pointerleave",this.onPointerUp),window.addEventListener("resize",this.onWindowResize),window.addEventListener("keyup",this.onKeyUp)},W.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},W.prototype.detachWindowEvents=function(){window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("pointerout",this.onPointerOut),window.removeEventListener("pointerleave",this.onPointerUp),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("keyup",this.onKeyUp)},W.prototype.addLogo=function(){this.logoUI=document.createElement("div"),this.logoUI.style.display="inline-block",this.logoUI.style.margin="0px",this.logoUI.style.padding="0px",this.logoUI.style.fill="#333333";var l=document.createElement("a");l.href="https://markerjs.com/",l.target="_blank",l.innerHTML='<svg viewBox="0 0 112 96" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path fill="#e5f20d" fill-opacity=".647" d="M0 40.386h111.96V95.62H0z"/><path d="M93.61 61.452c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.591 1.048-1.481 0-2.222-.74-2.222-2.22 0-16.617-.533-29.347-1.604-38.192-1.068-8.842-2.92-13.265-5.552-13.265-4.443 0-10.94 15.509-19.497 46.52v.124c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.592 1.048-1.48 0-2.22-.74-2.22-2.22 0-3.29.165-8.392.493-15.302.33-7.732.494-13.82.494-18.262 0-6.17-.186-10.55-.556-13.142-.37-2.591-1.172-3.887-2.406-3.887-2.796 0-6.333 5.12-10.612 15.363C38.494 34.367 34.01 46.44 29.32 60.34l-1.11 3.209a5.714 5.714 0 01-1.42 2.097c-.617.578-1.295.864-2.036.864-.987 0-1.644-.081-1.974-.247-.328-.162-.533-.656-.617-1.48-.41-4.03-.74-9.418-.987-16.165-.163-1.728-.329-4.566-.494-8.515-.822-13.901-1.562-23.3-2.221-28.196-.657-4.893-.987-7.628-.987-8.205 0-.657.33-1.44.987-2.345.659-.903 1.276-1.357 1.85-1.357 1.319 0 2.387.947 3.21 2.838.411.906.863 4.526 1.357 10.859.493 6.335.905 14.19 1.233 23.568l.617 18.88c4.527-13.983 9.216-26.673 14.068-38.068C45.65 6.686 50.093.988 54.123.988c2.715 0 4.566 1.974 5.553 5.923.987 3.949 1.481 9.667 1.481 17.152 0 3.949-.081 9.625-.247 17.029l-.123 5.676c3.373-11.762 6.725-21.634 10.057-29.615 3.331-7.979 6.685-11.97 10.056-11.97 8.475 0 12.71 18.757 12.71 56.269z" fill-rule="nonzero"/></svg>',l.title="Powered by marker.js",l.style.display="grid",l.style.alignItems="center",l.style.justifyItems="center",l.style.padding="3px",l.style.width="20px",l.style.height="20px",this.logoUI.appendChild(l),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},W.prototype.positionLogo=function(){this.logoUI&&(this.uiStyleSettings.logoPosition!=="right"?this.logoUI.style.left=this.markerImageHolder.offsetLeft+10+"px":this.logoUI.style.left=this.markerImageHolder.offsetLeft+this.markerImageHolder.offsetWidth-this.logoUI.clientWidth-10+"px",this.logoUI.style.top=this.markerImageHolder.offsetTop+this.markerImageHolder.offsetHeight-this.logoUI.clientHeight-10+"px")},W.prototype.overrideOverflow=function(){this.scrollXState=window.scrollX,this.scrollYState=window.scrollY,this.bodyOverflowState=document.body.style.overflow,window.scroll({top:0,left:0}),document.body.style.overflow="hidden"},W.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},W.prototype.showUI=function(){switch(this.settings.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.style.visibility=this._silentRenderMode?"hidden":"visible",this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.coverDiv.style.userSelect="none",this.settings.displayMode){case"inline":this.coverDiv.style.position="absolute";var l=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=l+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px",this.coverDiv.style.width=this.target.offsetWidth.toString()+"px",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.settings.displayMode==="popup"?this.settings.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.toolbar=new Pe(this.uiDiv,this.settings.displayMode,this._availableMarkerTypes,this.uiStyleSettings,this.styles),this.toolbar.addButtonClickListener(this.toolbarButtonClicked),this.toolbar.show(this._silentRenderMode||this.uiStyleSettings.hideToolbar?"hidden":"visible"),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.settings.displayMode==="popup"&&(this.contentDiv.style.backgroundColor=this.uiStyleSettings.canvasBackgroundColor,this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.uiStyleSettings.toolbarHeight+"px",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.settings.popupMargin+"px)"),this.contentDiv.style.overflow="auto",this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.settings.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.editorCanvas.style.transformOrigin="left top",this.editorCanvas.style.transform="scale("+this.zoomLevel+")",this.contentDiv.appendChild(this.editorCanvas),this.editingTarget=this.target instanceof HTMLImageElement?document.createElement("img"):document.createElement("canvas"),this.target.getClientRects().item(0).y<this.styles.settings.toolbarHeight&&(this.editingTarget.style.marginTop=this.target.offsetTop-this.styles.settings.toolbarHeight+"px"),this.editorCanvas.appendChild(this.editingTarget),this.toolbox=new He(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},W.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},W.prototype.removeMarker=function(l){this.markerImage.removeChild(l.container),this.markers.indexOf(l)>-1&&this.markers.splice(this.markers.indexOf(l),1),l.dispose()},W.prototype.switchToSelectMode=function(){this.mode="select",this.hideNotesEditor(),this._currentMarker!==void 0&&(this._currentMarker.state!=="new"?this._currentMarker.select():(this.removeMarker(this._currentMarker),this.setCurrentMarker(),this.markerImage.style.cursor="default"),this.addUndoStep())},W.prototype.toolbarButtonClicked=function(l,m){if(l==="marker"&&m!==void 0)this.createNewMarker(m);else if(l==="action")switch(m){case"select":this.switchToSelectMode(),this.switchToSelectMode();break;case"delete":this.deleteSelectedMarker();break;case"clear":this.clear();break;case"undo":this.undo();break;case"redo":this.redo();break;case"zoom":this.stepZoom();break;case"zoom-out":this.zoomLevel=1;break;case"notes":this.notesArea===void 0?(this.switchToSelectMode(),this.zoomLevel=1,this.showNotesEditor()):this.switchToSelectMode();break;case"close":this.close();break;case"render":this.switchToSelectMode(),this.startRenderAndClose()}},W.prototype.deleteSelectedMarker=function(){var l=this;if(this._currentMarker!==void 0){var m=!1;if(this.eventListeners.markerbeforedelete.forEach(function(J){var F=new We(l,l._currentMarker,!0);J(F),F.defaultPrevented&&(m=!0)}),!m){var O=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(J){return J(new We(l,O))})}}},W.prototype.clear=function(){var l=this,m=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(de){var _e=new We(l,void 0,!0);de(_e),_e.defaultPrevented&&(m=!0)}),!m)){this.setCurrentMarker();for(var O=function(de){var _e=J.markers[de];J.setCurrentMarker(J.markers[de]),J._currentMarker.dispose(),J.markerImage.removeChild(J._currentMarker.container),J.markers.splice(J.markers.indexOf(J._currentMarker),1),J.eventListeners.markerdelete.forEach(function(Ye){return Ye(new We(l,_e))})},J=this,F=this.markers.length-1;F>=0;F--)O(F);this.addUndoStep()}},Object.defineProperty(W.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),W.prototype.showNotesEditor=function(){var l;this._currentMarker!==void 0&&(this.overlayContainer.innerHTML="",this.notesArea=document.createElement("textarea"),this.notesArea.className=this.uiStyleSettings.notesAreaStyleClassName,this.notesArea.style.pointerEvents="auto",this.notesArea.style.alignSelf="stretch",this.notesArea.style.width="100%",this.notesArea.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.notesArea.value=(l=this._currentMarker.notes)!==null&&l!==void 0?l:"",this.overlayContainer.appendChild(this.notesArea))},W.prototype.hideNotesEditor=function(){this.isNotesAreaOpen&&(this._currentMarker!==void 0&&(this._currentMarker.notes=this.notesArea.value.trim()!==""?this.notesArea.value:void 0),this.overlayContainer.removeChild(this.notesArea),this.notesArea=void 0)},W.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},W.prototype.addUndoStep=function(){var l=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var m=this.getState(),O=this.undoRedoManager.getLastUndoStep();if(!O||O.width===m.width&&O.height===m.height){var J=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(m),J<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(F){return F(new kt(l))})}else this.undoRedoManager.replaceLastUndoStep(m),this.eventListeners.statechange.forEach(function(F){return F(new kt(l))})}},W.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},W.prototype.undoStep=function(){var l=this,m=this.undoRedoManager.undo();m!==void 0&&(this.restoreState(m),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(O){return O(new kt(l))}))},W.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},W.prototype.redoStep=function(){var l=this,m=this.undoRedoManager.redo();m!==void 0&&(this.restoreState(m),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(O){return O(new kt(l))}))},W.prototype.stepZoom=function(){var l=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=l<this.zoomSteps.length-1?this.zoomSteps[l+1]:this.zoomSteps[0]},W.prototype.panTo=function(l){this.contentDiv.scrollBy({left:this.prevPanPoint.x-l.x,top:this.prevPanPoint.y-l.y}),this.prevPanPoint=l},W.prototype.startRenderAndClose=function(){return Te(this,void 0,void 0,function(){var l,m,O=this;return Ee(this,function(J){switch(J.label){case 0:return[4,this.render()];case 1:return l=J.sent(),m=this.getState(),this.eventListeners.render.forEach(function(F){return F(new ot(O,l,m))}),this.close(!0),[2]}})})},W.prototype.getState=function(l){l===!0&&this.setCurrentMarker();var m={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(O){return m.markers.push(O.getState())}),m},W.prototype.restoreState=function(l){var m=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);l.markers.forEach(function(O){var J=m._availableMarkerTypes.find(function(de){return de.typeName===O.typeName});if(J!==void 0){var F=m.addNewMarker(J);F.restoreState(O),m.markers.push(F)}}),l.width&&l.height&&(l.width!==this.imageWidth||l.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/l.width,this.imageHeight/l.height),this.eventListeners.restorestate.forEach(function(O){return O(new kt(m))})},W.prototype.addNewMarker=function(l){var m=se.createGroup();return this.markerImage.appendChild(m),new l(m,this.overlayContainer,this.settings)},W.prototype.createNewMarker=function(l){var m,O=this;(m=typeof l=="string"?this._availableMarkerTypes.find(function(J){return J.typeName===l}):l)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(m),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(m.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(J){return J(new We(O,O._currentMarker))}))},W.prototype.markerCreated=function(l){var m=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(l),this.setCurrentMarker(l),l instanceof me&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(me):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(O){return O(new We(m,m._currentMarker))})},W.prototype.colorChanged=function(l){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=l,this.settings.defaultStrokeColor=l)},W.prototype.fillColorChanged=function(l){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=l)},W.prototype.markerStateChanged=function(l){var m=this;this.eventListeners.markerchange.forEach(function(O){return O(new We(m,l))})},W.prototype.setCurrentMarker=function(l){var m=this;this._currentMarker!==l&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(O){return O(new We(m,m._currentMarker))})),this._currentMarker=l,this._currentMarker===void 0||this._currentMarker.isSelected||(this._currentMarker.state!=="new"&&this._currentMarker.select(),this.toolbar.setCurrentMarker(this._currentMarker),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this._isResizing||this.eventListeners.markerselect.forEach(function(O){return O(new We(m,m._currentMarker))}))},W.prototype.onPointerDown=function(l){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||l.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var m=this.markers.find(function(O){return O.ownsTarget(l.target)});m!==void 0?(this.setCurrentMarker(m),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(l.clientX,l.clientY),l.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:l.clientX,y:l.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(l.clientX,l.clientY))},W.prototype.onDblClick=function(l){if(this._isFocused||this.focus(),this.mode==="select"){var m=this.markers.find(function(O){return O.ownsTarget(l.target)});m!==void 0&&m!==this._currentMarker&&this.setCurrentMarker(m),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(l.clientX,l.clientY),l.target):this.setCurrentMarker()}},W.prototype.onPointerMove=function(l){this.touchPoints!==1&&l.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||l.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(l.clientX,l.clientY)):this.zoomLevel>1&&this.panTo({x:l.clientX,y:l.clientY}))},W.prototype.onPointerUp=function(l){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(l.clientX,l.clientY)),this.isDragging=!1,this.addUndoStep()},W.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},W.prototype.onKeyUp=function(l){this._currentMarker===void 0||this.notesArea!==void 0||l.key!=="Delete"&&l.key!=="Backspace"||this.deleteSelectedMarker()},W.prototype.clientToLocalCoordinates=function(l,m){var O=this.markerImage.getBoundingClientRect();return{x:(l-O.left)/this.zoomLevel,y:(m-O.top)/this.zoomLevel}},W.prototype.onWindowResize=function(){this.positionUI()},W.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var l=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=l+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.styles.settings.toolbarHeight+"px"}this.positionMarkerImage(),this.positionLogo()},W.prototype.addLicenseKey=function(l){Le.addKey(l)},W.prototype.addEventListener=function(l,m){this.eventListeners.addEventListener(l,m)},W.prototype.removeEventListener=function(l,m){this.eventListeners.removeEventListener(l,m)},W.prototype.renderState=function(l){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(l),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(W.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),W.prototype.focus=function(){var l=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(m){return m(new kt(l))}))},W.prototype.blur=function(){var l=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(m){return m(new kt(l))}))},W.instanceCounter=0,W}();/* **********************************
|
|
cropro version 1.2.0
|
|
@license SEE LICENSE IN LICENSE
|
|
|
|
copyright Alan Mendelevich
|
|
see README and LICENSE for details
|
|
********************************** *//*! *****************************************************************************
|
|
Copyright (c) Microsoft Corporation.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
***************************************************************************** */var _t=function(W,l){return(_t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,O){m.__proto__=O}||function(m,O){for(var J in O)Object.prototype.hasOwnProperty.call(O,J)&&(m[J]=O[J])})(W,l)};function xt(W,l){if(typeof l!="function"&&l!==null)throw new TypeError("Class extends value "+String(l)+" is not a constructor or null");function m(){this.constructor=W}_t(W,l),W.prototype=l===null?Object.create(l):(m.prototype=l.prototype,new m)}function Dt(W,l,m,O){return new(m||(m=Promise))(function(J,F){function de(mt){try{Ye(O.next(mt))}catch(Ie){F(Ie)}}function _e(mt){try{Ye(O.throw(mt))}catch(Ie){F(Ie)}}function Ye(mt){var Ie;mt.done?J(mt.value):(Ie=mt.value,Ie instanceof m?Ie:new m(function(St){St(Ie)})).then(de,_e)}Ye((O=O.apply(W,l||[])).next())})}function Er(W,l){var m,O,J,F,de={label:0,sent:function(){if(1&J[0])throw J[1];return J[1]},trys:[],ops:[]};return F={next:_e(0),throw:_e(1),return:_e(2)},typeof Symbol=="function"&&(F[Symbol.iterator]=function(){return this}),F;function _e(Ye){return function(mt){return function(Ie){if(m)throw new TypeError("Generator is already executing.");for(;de;)try{if(m=1,O&&(J=2&Ie[0]?O.return:Ie[0]?O.throw||((J=O.return)&&J.call(O),0):O.next)&&!(J=J.call(O,Ie[1])).done)return J;switch(O=0,J&&(Ie=[2&Ie[0],J.value]),Ie[0]){case 0:case 1:J=Ie;break;case 4:return de.label++,{value:Ie[1],done:!1};case 5:de.label++,O=Ie[1],Ie=[0];continue;case 7:Ie=de.ops.pop(),de.trys.pop();continue;default:if(!(J=de.trys,(J=J.length>0&&J[J.length-1])||Ie[0]!==6&&Ie[0]!==2)){de=0;continue}if(Ie[0]===3&&(!J||Ie[1]>J[0]&&Ie[1]<J[3])){de.label=Ie[1];break}if(Ie[0]===6&&de.label<J[1]){de.label=J[1],J=Ie;break}if(J&&de.label<J[2]){de.label=J[2],de.ops.push(Ie);break}J[2]&&de.ops.pop(),de.trys.pop();continue}Ie=l.call(W,de)}catch(St){Ie=[6,St],O=0}finally{m=J=0}if(5&Ie[0])throw Ie[1];return{value:Ie[0]?Ie[1]:void 0,done:!0}}([Ye,mt])}}}var Hr=function(){function W(){}return W.addKey=function(l){W.key=l},Object.defineProperty(W,"isLicensed",{get:function(){return!!W.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(W.key)},enumerable:!1,configurable:!0}),W}(),bt=function(){function W(){}return W.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},W.setAttributes=function(l,m){for(var O=0,J=m;O<J.length;O++){var F=J[O],de=F[0],_e=F[1];l.setAttribute(de,_e)}},W.createRect=function(l,m,O){var J=document.createElementNS("http://www.w3.org/2000/svg","rect");return J.setAttribute("width",l.toString()),J.setAttribute("height",m.toString()),O&&W.setAttributes(J,O),J},W.createLine=function(l,m,O,J,F){var de=document.createElementNS("http://www.w3.org/2000/svg","line");return de.setAttribute("x1",l.toString()),de.setAttribute("y1",m.toString()),de.setAttribute("x2",O.toString()),de.setAttribute("y2",J.toString()),F&&W.setAttributes(de,F),de},W.createPolygon=function(l,m){var O=document.createElementNS("http://www.w3.org/2000/svg","polygon");return O.setAttribute("points",l),m&&W.setAttributes(O,m),O},W.createCircle=function(l,m){var O=document.createElementNS("http://www.w3.org/2000/svg","circle");return O.setAttribute("cx",(l/2).toString()),O.setAttribute("cy",(l/2).toString()),O.setAttribute("r",l.toString()),m&&W.setAttributes(O,m),O},W.createEllipse=function(l,m,O){var J=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return J.setAttribute("cx",(l/2).toString()),J.setAttribute("cy",(m/2).toString()),J.setAttribute("rx",(l/2).toString()),J.setAttribute("ry",(m/2).toString()),O&&W.setAttributes(J,O),J},W.createGroup=function(l){var m=document.createElementNS("http://www.w3.org/2000/svg","g");return l&&W.setAttributes(m,l),m},W.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},W.createMarker=function(l,m,O,J,F,de,_e){var Ye=document.createElementNS("http://www.w3.org/2000/svg","marker");return W.setAttributes(Ye,[["id",l],["orient",m],["markerWidth",O.toString()],["markerHeight",J.toString()],["refX",F.toString()],["refY",de.toString()]]),Ye.appendChild(_e),Ye},W.createText=function(l){var m=document.createElementNS("http://www.w3.org/2000/svg","text");return m.setAttribute("x","0"),m.setAttribute("y","0"),l&&W.setAttributes(m,l),m},W.createTSpan=function(l,m){var O=document.createElementNS("http://www.w3.org/2000/svg","tspan");return O.textContent=l,m&&W.setAttributes(O,m),O},W.createImage=function(l){var m=document.createElementNS("http://www.w3.org/2000/svg","image");return l&&W.setAttributes(m,l),m},W.createPoint=function(l,m){var O=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return O.x=l,O.y=m,O},W.createPath=function(l,m){var O=document.createElementNS("http://www.w3.org/2000/svg","path");return O.setAttribute("d",l),m&&W.setAttributes(O,m),O},W.createElement=function(l,m){var O=document.createElementNS("http://www.w3.org/2000/svg",l);return m&&W.setAttributes(O,m),O},W.getHollowRectanglePath=function(l,m,O,J,F,de,_e,Ye){return"M"+l+","+m+"V"+(m+J)+"H"+(l+O)+"V"+m+"H"+F+"V"+de+"H"+(F+_e)+"V"+(de+Ye)+"H"+F+"V"+m+"Z"},W}(),Nr=function(){function W(l){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+l+"_"}return Object.defineProperty(W.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#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(W.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),W.prototype.addClass=function(l){return this.styleSheet===void 0&&this.addStyleSheet(),l.name=""+this.classNamePrefix+l.localName,this.classes.push(l),this.styleSheet.sheet.insertRule("."+l.name+" {"+l.style+"}",this.styleSheet.sheet.cssRules.length),l},W.prototype.addRule=function(l){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(l),this.styleSheet.sheet.insertRule(l.selector+" {"+l.style+"}",this.styleSheet.sheet.cssRules.length)},W.prototype.addStyleSheet=function(){var l;this.styleSheet=document.createElement("style"),((l=this.styleSheetRoot)!==null&&l!==void 0?l:document.head).appendChild(this.styleSheet),this.addRule(new 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;
|
|
`))},W.prototype.removeStyleSheet=function(){var l;this.styleSheet&&(((l=this.styleSheetRoot)!==null&&l!==void 0?l:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},W}(),hr=function(W,l){this.selector=W,this.style=l},pr=function(W,l){this.localName=W,this.style=l},Br=function(){function W(){this.blocks=[],this.display=""}return W.prototype.addButtonBlock=function(l){l.className=this.blockClassName,l.buttonClassName=this.buttonClassName,l.buttonColorsClassName=this.buttonColorsClassName,l.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(l)},W.prototype.addElementBlock=function(l){l.className===void 0&&(l.className=this.blockClassName),this.blocks.push(l)},W.prototype.getUI=function(){var l=document.createElement("div");return l.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,l.style.display=this.display,this.blocks.forEach(function(m){return l.appendChild(m.getUI())}),l},W}(),ci=function(){function W(){}return W.prototype.getUI=function(){var l=document.createElement("div");if(l.className=this.className,this.minWidth!==void 0&&(l.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":l.style.justifyContent="flex-start";break;case"center":l.style.justifyContent="center";break;case"end":l.style.justifyContent="flex-end"}return l.style.whiteSpace="nowrap",l},W}(),qr=function(W){function l(){var m=W!==null&&W.apply(this,arguments)||this;return m.buttons=[],m}return xt(l,W),l.prototype.addButton=function(m){m.className=this.buttonClassName,m.colorsClassName=this.buttonColorsClassName,m.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(m)},l.prototype.getUI=function(){var m=W.prototype.getUI.call(this);return this.buttons.forEach(function(O){return m.appendChild(O.getUI())}),m},l}(ci),Ut=function(){function W(l,m){this._isActive=!1,this._isHidden=!1,this._icon=l,this.title=m,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(W.prototype,"icon",{get:function(){return this._icon},set:function(l){this._icon=l,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isActive",{get:function(){return this._isActive},set:function(l){this._isActive=l,this.adjustClassName()},enumerable:!1,configurable:!0}),W.prototype.getUI=function(){var l=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 l.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},W.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,"")))},W.prototype.hide=function(){this._isHidden=!0},W}(),pt=function(W){function l(){var m=W!==null&&W.apply(this,arguments)||this;return m.elements=[],m}return xt(l,W),l.prototype.addElement=function(m){this.elements.push(m)},l.prototype.getUI=function(){var m=W.prototype.getUI.call(this);return this.elements.forEach(function(O){return m.appendChild(O)}),m},l}(ci),zr=function(){function W(l,m){this.horizontal=l,this.vertical=m}return Object.defineProperty(W.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),W.prototype.getVerticalLength=function(l){return l/this.ratio},W.prototype.getHorizontalLength=function(l){return l*this.ratio},W}(),ei=function(){function W(){}return W.getIcon=function(l,m){if(l>0&&m>0){var O=new zr(l,m),J=O.ratio>=1?20:O.getHorizontalLength(20),F=O.ratio<1?20:O.getVerticalLength(20),de=document.createElementNS("http://www.w3.org/2000/svg","svg");de.setAttribute("xmlns","http://www.w3.org/2000/svg"),de.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(de);var _e=bt.createDefs();de.appendChild(_e);var Ye=bt.createElement("clipPath",[["id","text-bg-clip"]]);_e.appendChild(Ye);var mt=bt.createPath(bt.getHollowRectanglePath((24-J)/2,(24-F)/2,J,F,(24-J)/2+2,(24-F)/2+2,J-4,F-4));de.appendChild(mt);var Ie=bt.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Ie.appendChild(bt.createTSpan(l+":"+m)),de.appendChild(Ie);var St=Ie.getBBox();bt.setAttributes(Ie,[["x",((24-St.width)/2).toString()],["y",((24-St.height)/2-St.y).toString()]]);var Ft=bt.createPath(bt.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(St.width))/2,(24-Math.ceil(St.height))/2,Math.ceil(St.width),Math.ceil(St.height)));return Ye.appendChild(Ft),bt.setAttributes(mt,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(de),de.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>'},W}(),mr=function(W){function l(m,O,J){var F=W.call(this,m,O)||this;return F.isDropdownOpen=!1,F.onClick=F.dropdownButtonClicked,F.dropdownButtons=J,F}return xt(l,W),l.prototype.setupDropdown=function(){var m=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(O){O.className=m.className,O.colorsClassName=m.colorsClassName,m.dropdownBlock.appendChild(O.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},l.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},l.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},l.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},l.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},l.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},l}(Ut),Pt=function(){function W(l,m){this.GRIP_SIZE=10,this.color=l,this.fillColor=m,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 W.prototype.ownsTarget=function(l){return l===this.visual||l===this.visual.childNodes[0]||l===this.visual.childNodes[1]},W.prototype.setCenter=function(l,m){this.visual.childNodes.forEach(function(O){return bt.setAttributes(O,[["cx",l.toString()],["cy",m.toString()]])})},W}(),Ur=function(){function W(l,m,O,J){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=l,this.canvasHeight=m,this.margin=O,this.container=J,this.attachEvents=this.attachEvents.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.resize=this.resize.bind(this),this.adjustCropRect=this.adjustCropRect.bind(this),this.scaleCanvas=this.scaleCanvas.bind(this),this.getRescaledRect=this.getRescaledRect.bind(this)}return Object.defineProperty(W.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(l){this._aspectRatio=l,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(l){this._isGridVisible=l,this.gridContainer&&bt.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(l){this._zoomFactor=l,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),W.prototype.open=function(){var l=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 m=0;m<this.numberOfGridLines;m++)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(O){return l.gridContainer.appendChild(O)}),this.verticalGridLines.forEach(function(O){return l.gridContainer.appendChild(O)}),this.cropRectElement=bt.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new Pt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new Pt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new Pt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new Pt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},W.prototype.setCropRectangle=function(l){this.cropRect=l;var m=Object.assign({},this.cropRect);this.zoomFactor!==1&&(m.width=this.cropRect.width*this.zoomFactor,m.height=this.cropRect.height*this.zoomFactor,m.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-m.width/2,m.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-m.height/2),bt.setAttributes(this.cropRectElement,[["x",m.x.toString()],["y",m.y.toString()],["width",m.width.toString()],["height",m.height.toString()]]);var O=m.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(F,de){var _e=m.y+O*(de+1);bt.setAttributes(F,[["x1",""+m.x],["y1",""+_e],["x2",""+(m.x+m.width)],["y2",""+_e]])});var J=m.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(F,de){var _e=m.x+J*(de+1);bt.setAttributes(F,[["x1",""+_e],["y1",""+m.y],["x2",""+_e],["y2",""+(m.y+m.height)]])}),bt.setAttributes(this.cropShadeElement,[["d",bt.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,m.x,m.y,m.width,m.height)]]),this.topLeftGrip.setCenter(m.x,m.y),this.topRightGrip.setCenter(m.x+m.width,m.y),this.bottomLeftGrip.setCenter(m.x,m.y+m.height),this.bottomRightGrip.setCenter(m.x+m.width,m.y+m.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},W.prototype.attachEvents=function(){this.container.style.touchAction="none",this.container.addEventListener("pointerdown",this.onPointerDown),this.container.addEventListener("pointermove",this.onPointerMove),this.container.addEventListener("pointerup",this.onPointerUp)},W.prototype.clientToLocalCoordinates=function(l,m){var O=this.container.getBoundingClientRect();return{x:l-O.left+this.margin,y:m-O.top+this.margin}},W.prototype.onPointerDown=function(l){this.container.setPointerCapture(l.pointerId),this.previousPoint=this.clientToLocalCoordinates(l.clientX,l.clientY),this.cropRectElement===l.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(l.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(l.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(l.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(l.target)&&(this.activeGrip=this.bottomRightGrip)},W.prototype.onPointerMove=function(l){if(this.isMoving)this.move(this.clientToLocalCoordinates(l.clientX,l.clientY));else if(this.activeGrip){var m=this.clientToLocalCoordinates(l.clientX,l.clientY);this.resize(m)}l.preventDefault()},W.prototype.onPointerUp=function(l){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(l.pointerId)},W.prototype.move=function(l){var m=l.x-this.previousPoint.x,O=l.y-this.previousPoint.y;this.zoomFactor!==1&&(m=-m/this.zoomFactor,O=-O/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+m),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+O),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=l},W.prototype.resize=function(l){var m=Object.assign({},this.cropRect),O=l.x-this.previousPoint.x,J=l.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:m.x+O<this.margin&&(O=this.margin-m.x),m.x+=O,m.width=this.cropRect.x+this.cropRect.width-m.x;break;case this.bottomRightGrip:case this.topRightGrip:m.width+O>this.canvasWidth*this.zoomFactor&&(O=this.canvasWidth*this.zoomFactor-m.width),m.width+=O}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(m.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(O),m.height=this.aspectRatio.getVerticalLength(m.width)):(m.y+=J,m.height=this.cropRect.y+this.cropRect.height-m.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?m.height=this.aspectRatio.getVerticalLength(m.width):m.height+=J}m.width<10&&(m.x=this.cropRect.x,m.width=10),m.height<10&&(m.y=this.cropRect.y,m.height=10),this.previousPoint=l,m.x>=this.margin&&m.y>=this.margin&&m.x-this.margin+m.width<=this.canvasWidth&&m.y-this.margin+m.height<=this.canvasHeight&&(this.cropRect=m,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},W.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var l=this.cropRect.x+this.cropRect.width/2,m=this.cropRect.y+this.cropRect.height/2,O=this.aspectRatio.getHorizontalLength(this.cropRect.height),J=this.aspectRatio.getVerticalLength(this.cropRect.width);O/this.canvasWidth<J/this.canvasHeight?this.cropRect.width=O:this.cropRect.height=J,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=l-this.cropRect.width/2,this.cropRect.y=m-this.cropRect.height/2,this.cropRect.x+this.cropRect.width>this.margin+this.canvasWidth&&(this.cropRect.x=this.margin+this.canvasWidth-this.cropRect.width),this.cropRect.y+this.cropRect.height>this.margin+this.canvasHeight&&(this.cropRect.y=this.margin+this.canvasHeight-this.cropRect.height),this.cropRect.x=Math.max(this.cropRect.x,this.margin),this.cropRect.y=Math.max(this.cropRect.y,this.margin)}},W.prototype.getRescaledRect=function(l,m,O,J,F,de){var _e=O/l,Ye=J/m;return{x:(F.x-de)*_e+de,y:(F.y-de)*Ye+de,width:F.width*_e,height:F.height*Ye}},W.prototype.scaleCanvas=function(l,m){var O=this.getRescaledRect(this.canvasWidth,this.canvasHeight,l,m,this.cropRect,this.margin);this.canvasWidth=l,this.canvasHeight=m,this.onCropChange&&this.onCropChange(O),this.setCropRectangle(O)},W}(),Vr=function(){function W(l){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=l,this.uiContainer=document.createElement("div"),this.getUI=this.getUI.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.setAngleLabel=this.setAngleLabel.bind(this),this.positionScaleShape=this.positionScaleShape.bind(this)}return Object.defineProperty(W.prototype,"angle",{get:function(){return this._angle},set:function(l){this._angle=l,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),W.prototype.getUI=function(){return this.controlContainer=document.createElement("div"),this.controlContainer.title=this.title,this.controlContainer.className=this.className+" "+this.colorsClassName,this.controlContainer.appendChild(this.getVisual()),this.controlContainer.addEventListener("pointerdown",this.onPointerDown),this.controlContainer.addEventListener("pointermove",this.onPointerMove),this.controlContainer.addEventListener("pointerup",this.onPointerUp),this.uiContainer.appendChild(this.controlContainer),this.uiContainer.style.display="inline-block",this.uiContainer.style.touchAction="none",this.setAngleLabel(),this.positionScaleShape(),this.uiContainer},W.prototype.onPointerDown=function(l){this.controlContainer.setPointerCapture(l.pointerId),this.isDragging=!0,this.previousPoint={x:l.clientX,y:l.clientY}},W.prototype.onPointerMove=function(l){this.isDragging&&(this.onAngleChange&&this.onAngleChange((l.clientX-this.previousPoint.x)/5),this.previousPoint.x=l.clientX)},W.prototype.onPointerUp=function(l){this.isDragging&&this.onAngleChange&&this.onAngleChange((l.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(l.pointerId)},W.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var l=this.angleLabelText.getBBox();bt.setAttributes(this.angleLabelElement,[["x",((this.width-l.width)/2).toString()],["y",(this.height/2).toString()]])}},W.prototype.positionScaleShape=function(){if(this.scaleShape){var l=this.scaleShape.transform.baseVal.getItem(0);l.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(l,0)}},W.prototype.getVisual=function(){var l=document.createElementNS("http://www.w3.org/2000/svg","svg");l.setAttribute("xmlns","http://www.w3.org/2000/svg"),l.setAttribute("width",this.width+"px"),l.setAttribute("height",this.height+"px"),l.setAttribute("viewBox","0 0 "+this.width+" "+this.height),l.style.flexShrink="0",document.body.appendChild(l);for(var m="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,O=1;O<=this.width/5+10;O++){var J=O%5==0?this.height/3:this.height/6;m+="h4v"+-J+"h1v"+J}m+="v1H0Z",this.scaleShape=bt.createPath(m);var F=bt.createTransform();this.scaleShape.transform.baseVal.appendItem(F),l.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 de=bt.createTSpan("");return de.innerHTML="°",this.angleLabelElement.appendChild(de),l.appendChild(this.angleLabelElement),document.body.removeChild(l),l},W}(),fi=function(){function W(){this.naturalSize=!1,this.imageType="image/png"}return W.prototype.rasterize=function(l,m,O,J,F,de,_e){var Ye=this;return new Promise(function(mt){var Ie=document.createElement("canvas");Ie.width=l.width.baseVal.value-2*J,Ie.height=l.height.baseVal.value-2*J;var St=1,Ft=1;Ye.naturalSize===!0?(St=m.naturalWidth/(l.width.baseVal.value-2*J)/de,Ft=m.naturalHeight/(l.height.baseVal.value-2*J)/_e,Ie.width=m.naturalWidth/de,Ie.height=m.naturalHeight/_e):Ye.width!==void 0&&Ye.height!==void 0&&(St=Ye.width/O.width,Ft=Ye.height/O.height,Ie.width*=St,Ie.height*=Ft);var Xt=Ie.getContext("2d");Xt.translate(Ie.width/2,Ie.height/2),Xt.rotate(F*Math.PI/180),Xt.scale(de,_e),Xt.translate(-Ie.width/2,-Ie.height/2),Xt.drawImage(m,0,0,Ie.width,Ie.height);var Or=document.createElement("canvas");Or.width=O.width*St,Or.height=O.height*Ft,Or.getContext("2d").putImageData(Xt.getImageData((O.x-J)*St,(O.y-J)*Ft,O.width*St,O.height*Ft),0,0),mt(Or.toDataURL(Ye.imageType,Ye.imageQuality))})},W}(),je=function(){function W(l){this._zoomToCropEnabled=!0,this.zoomFactor=1,this.flippedHorizontally=!1,this.flippedVertically=!1,this._isGridVisible=!0,this._gridLines=2,this._rotationAngle=0,this.scaleFactor=1,this.renderEventListeners=[],this.closeEventListeners=[],this._isOpen=!1,this.CANVAS_MARGIN=20,this.renderAtNaturalSize=!1,this.renderImageType="image/png",this.displayMode="inline",this.popupMargin=30,this.toolbarHeight=40,this.aspectRatios=[{horizontal:0,vertical:0},{horizontal:4,vertical:3},{horizontal:3,vertical:2},{horizontal:16,vertical:9},{horizontal:1,vertical:1},{horizontal:3,vertical:4},{horizontal:2,vertical:3},{horizontal:9,vertical:16}],this._instanceNo=W.instanceCounter++,this.styles=new Nr(this.instanceNo),this.target=l,this.targetRoot=document.body,this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.rotateBy=this.rotateBy.bind(this),this.applyRotation=this.applyRotation.bind(this),this.cropRectChanged=this.cropRectChanged.bind(this),this.zoomToCrop=this.zoomToCrop.bind(this),this.unzoomFromCrop=this.unzoomFromCrop.bind(this),this.rotateLeftButtonClicked=this.rotateLeftButtonClicked.bind(this),this.rotateRightButtonClicked=this.rotateRightButtonClicked.bind(this),this.flipHorizontallyButtonClicked=this.flipHorizontallyButtonClicked.bind(this),this.flipVerticallyButtonClicked=this.flipVerticallyButtonClicked.bind(this),this.applyFlip=this.applyFlip.bind(this),this.startRenderAndClose=this.startRenderAndClose.bind(this),this.render=this.render.bind(this),this.onPopupResize=this.onPopupResize.bind(this),this.applyAspectRatio=this.applyAspectRatio.bind(this)}return Object.defineProperty(W.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(l){this._zoomToCropEnabled=l,l?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(l){this._isGridVisible=l,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"gridLines",{get:function(){return this._gridLines},set:function(l){this._gridLines=l,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(l){this._rotationAngle=l,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"aspectRatio",{get:function(){var l;return(l=this._aspectRatio)!==null&&l!==void 0?l:this.aspectRatios[0]},set:function(l){this._aspectRatio=l},enumerable:!1,configurable:!0}),W.prototype.open=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.setupResizeObserver(),this.initCropCanvas(),this.setEditingTarget(),this.setTopLeft(),this.initCropLayer(),this.attachEvents(),this.applyAspectRatio(),this.displayMode==="popup"&&this.onPopupResize(),this._isOpen=!0},W.prototype.show=function(){this.showUI(),this.open()},W.prototype.close=function(l){l===void 0&&(l=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),l||this.closeEventListeners.forEach(function(m){return m()}),this._isOpen=!1)},W.prototype.addRenderEventListener=function(l){this.renderEventListeners.push(l)},W.prototype.removeRenderEventListener=function(l){this.renderEventListeners.indexOf(l)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(l),1)},W.prototype.addCloseEventListener=function(l){this.closeEventListeners.push(l)},W.prototype.removeCloseEventListener=function(l){this.closeEventListeners.indexOf(l)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(l),1)},W.prototype.setupResizeObserver=function(){var l=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){l.resize(l.target.clientWidth,l.target.clientHeight)}),this.targetObserver.observe(this.target)):this.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(this.onPopupResize),this.targetObserver.observe(this.contentDiv)),window.addEventListener("resize",this.setWindowHeight))},W.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var l=1*this.target.clientWidth/this.target.clientHeight,m=this.contentDiv.clientWidth/l>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*l:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,O=m+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/l;this.resize(m,O)}},W.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},W.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"},W.prototype.resize=function(l,m){this.imageWidth=Math.round(l),this.imageHeight=Math.round(m),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()},W.prototype.setEditingTarget=function(){var l=document.createElement("canvas");l.width=this.target.naturalWidth,l.height=this.target.naturalHeight,l.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var m=l.toDataURL();bt.setAttributes(this.editingTarget,[["href",m]]),this.setEditingTargetSize()},W.prototype.setTopLeft=function(){var l=this.target.getBoundingClientRect(),m=this.editorCanvas.getBoundingClientRect();this.left=l.left-m.left-this.CANVAS_MARGIN,this.top=l.top-m.top-this.CANVAS_MARGIN},W.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 l=bt.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(l);var m=bt.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(m),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)},W.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},W.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 Ur(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()},W.prototype.zoomToCrop=function(){if(this.cropRect){var l=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,m=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=l+"px "+m+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-l+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-m+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},W.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)},W.prototype.cropRectChanged=function(l){this.cropRect=l,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},W.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},W.prototype.overrideOverflow=function(){this.scrollXState=window.scrollX,this.scrollYState=window.scrollY,this.bodyOverflowState=document.body.style.overflow,window.scroll({top:0,left:0}),document.body.style.overflow="hidden"},W.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},W.prototype.showUI=function(){switch(this.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 l=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,m=this.target.offsetTop>l+this.CANVAS_MARGIN?this.target.offsetTop-(l+this.CANVAS_MARGIN):0;this.coverDiv.style.top=m+"px",this.coverDiv.style.left=(this.target.offsetLeft>this.CANVAS_MARGIN?this.target.offsetLeft-this.CANVAS_MARGIN:0)+"px",this.coverDiv.style.width=this.target.offsetWidth+this.CANVAS_MARGIN+"px",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.displayMode==="popup"?this.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.addToolbars(),this.uiDiv.appendChild(this.topToolbar.getUI()),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.alignItems="center",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.contentDiv.style.overflow="hidden",this.contentDiv.style.backgroundColor=this.styles.settings.canvasBackgroundColor,this.displayMode==="popup"&&(this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.popupMargin+"px)"),this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.contentDiv.appendChild(this.editorCanvas),this.uiDiv.appendChild(this.bottomToolbar.getUI()),this.straightener.angle=this.rotationAngle},W.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},W.prototype.addTopToolbar=function(){var l=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 m=new qr;m.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(m);var O=[];this.aspectRatios.forEach(function(Ft){var Xt=new Ut(ei.getIcon(Ft.horizontal,Ft.vertical),Ft.horizontal===0&&Ft.vertical===0?"FREE":Ft.horizontal+":"+Ft.vertical);Xt.onClick=function(){return l.ratioButtonClicked(Ft)},O.push(Xt)}),this.aspectRatioButton=new mr(ei.getIcon(0,0),"Aspect ratio",O),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,m.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var J=new Ut('<svg viewBox="0 0 24 24"><path d="M10 4v4h4V4h-4m6 0v4h4V4h-4m0 6v4h4v-4h-4m0 6v4h4v-4h-4m-2 4v-4h-4v4h4m-6 0v-4H4v4h4m0-6v-4H4v4h4m0-6V4H4v4h4m2 6h4v-4h-4v4M4 2h16a2 2 0 012 2v16a2 2 0 01-2 2H4c-1.08 0-2-.9-2-2V4a2 2 0 012-2z"/></svg>',"Toggle grid");J.isActive=this.isGridVisible,J.onClick=function(){l.isGridVisible=!l.isGridVisible,J.isActive=l.isGridVisible},m.addButton(J);var F=new Ut('<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"Zoom to selection");if(F.isActive=this.zoomToCropEnabled,F.onClick=function(){l.zoomToCropEnabled=!l.zoomToCropEnabled,F.isActive=l.zoomToCropEnabled},m.addButton(F),!Hr.isLicensed){var de=new pt;this.topToolbar.addElementBlock(de);var _e=document.createElement("div");_e.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var Ye=document.createElement("a");Ye.style.color="currentColor",Ye.href="https://markerjs.com/products/cropro",Ye.target="_blank",Ye.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>',_e.appendChild(Ye),de.addElement(_e)}var mt=new qr;mt.minWidth=3*this.toolbarHeight+"px",mt.contentAlign="end",this.topToolbar.addButtonBlock(mt);var Ie=new Ut('<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"OK");Ie.onClick=this.startRenderAndClose,mt.addButton(Ie),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Ie.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var St=new Ut('<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"Close");St.onClick=this.close,mt.addButton(St),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(St.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},W.prototype.addBottomToolbar=function(){var l=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 m=new qr;m.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(m);var O=new Ut('<svg viewBox="0 0 24 24"><path d="M13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93M7.1 18.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32M6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47m1.02-4.47L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47z"/></svg>',"Rotate left");O.onClick=this.rotateLeftButtonClicked,m.addButton(O);var J=new Ut('<svg viewBox="0 0 24 24"><path d="M16.89 15.5l1.42 1.39c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.5M13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03m6.93-6.9a7.906 7.906 0 00-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47m-2.36-5.45L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45z"/></svg>',"Rotate right");J.onClick=this.rotateRightButtonClicked,m.addButton(J);var F=new pt;F.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(F),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(mt){l.rotateBy(mt),l.straightener.angle=l.rotationAngle},F.addElement(this.straightener.getUI());var de=new qr;de.minWidth=2*this.toolbarHeight+"px",de.contentAlign="end",this.bottomToolbar.addButtonBlock(de);var _e=new Ut('<svg viewBox="0 0 24 24"><path d="M15 21h2v-2h-2m4-10h2V7h-2M3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2m16-2v2h2c0-1.1-.9-2-2-2m-8 20h2V1h-2m8 16h2v-2h-2M15 5h2V3h-2m4 10h2v-2h-2m0 10c1.1 0 2-.9 2-2h-2z"/></svg>',"Flip horizontal");_e.onClick=this.flipHorizontallyButtonClicked,de.addButton(_e);var Ye=new Ut('<svg viewBox="0 0 24 24"><path d="M3 15v2h2v-2m10 4v2h2v-2m2-16H5c-1.1 0-2 .9-2 2v4h2V5h14v4h2V5c0-1.1-.9-2-2-2m2 16h-2v2c1.1 0 2-.9 2-2M1 11v2h22v-2M7 19v2h2v-2m10-4v2h2v-2m-10 4v2h2v-2M3 19c0 1.1.9 2 2 2v-2z"/></svg>',"Flip vertical");Ye.onClick=this.flipVerticallyButtonClicked,de.addButton(Ye)},W.prototype.ratioButtonClicked=function(l){this.aspectRatio=l,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},W.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=ei.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},W.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new zr(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},W.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},W.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},W.prototype.restoreState=function(l){if(l){var m=this.cropLayer.getRescaledRect(l.width,l.height,this.imageWidth,this.imageHeight,l.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(m),this.cropRectChanged(m),this.flippedHorizontally=l.flippedHorizontally,this.flippedVertically=l.flippedVertically,this.applyFlip(),this.rotationAngle=l.rotationAngle,this.applyRotation()}},W.prototype.clientToLocalCoordinates=function(l,m){var O=this.cropImage.getBoundingClientRect();return{x:l-O.left,y:m-O.top}},W.prototype.onWindowResize=function(){this.positionUI()},W.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var l=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=l+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)"}this.positionCropImage()},W.prototype.rotateLeftButtonClicked=function(){var l=this.rotationAngle-90;this.rotationAngle%90!=0&&(l+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(l)},W.prototype.rotateRightButtonClicked=function(){var l=this.rotationAngle+90;this.rotationAngle%90!=0&&(l-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(l)},W.prototype.rotateTo=function(l){l=(l=l>180?l-360:l)<=-180?l+360:l,this.rotationAngle=l,this.applyRotation()},W.prototype.rotateBy=function(l){this.rotateTo((this.rotationAngle+l)%360)},W.prototype.applyRotation=function(){var l=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var m=this.editingTargetRotationContainer.transform.baseVal.getItem(0);m.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(m,0);var O=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/O.width,this.imageHeight/O.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=l},W.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},W.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},W.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},W.prototype.startRenderAndClose=function(){return Dt(this,void 0,void 0,function(){var l,m;return Er(this,function(O){switch(O.label){case 0:return[4,this.render()];case 1:return l=O.sent(),m=this.getState(),this.renderEventListeners.forEach(function(J){return J(l,m)}),this.close(!0),[2]}})})},W.prototype.render=function(){return Dt(this,void 0,void 0,function(){var l;return Er(this,function(m){switch(m.label){case 0:return(l=new fi).naturalSize=this.renderAtNaturalSize,l.imageType=this.renderImageType,l.imageQuality=this.renderImageQuality,l.width=this.renderWidth,l.height=this.renderHeight,this.unzoomFromCrop(),bt.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,l.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 1:return m.sent(),[4,l.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 2:return[2,m.sent()]}})})},W.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new 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 l=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new pr("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.toolbarHeight-2*l)+`px;
|
|
height: `+(this.toolbarHeight-2*l)+`px;
|
|
padding: `+l+`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*l)+`px;
|
|
padding: `+l+`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;
|
|
`))},W.instanceCounter=0,W}(),Lt=re("8hTe"),pi=re.n(Lt),mi=/<pre[^>]*>/g;function gi(W){var l=document.createElement("div");return l.innerHTML=W,l.childNodes.length===0?"":l.childNodes[0].nodeValue}var vi=ht.a=function(W){var l=W.value,m=l===void 0?"":l,O=W.edit,J=O===void 0?!1:O,F=W.className,de=W.showTextOnly,_e=W.showLines,Ye=W.replaces,mt=W.zoomImg,Ie=W.hasMask,St=W.style,Ft=St===void 0?{}:St,Xt=W.stylesPrev,Or=Xt===void 0?{}:Xt,gr=String(m),vr=Object(M.useRef)(),Xr=Object(M.useRef)(),_i=Object(M.useState)(""),nr=Object(z.a)(_i,2),Fr=nr[0],oi=nr[1],si=Object(M.useState)("office"),Pr=Object(z.a)(si,2),Oi=Pr[0],yi=Pr[1],Gi=function(){var jt=new je(Xr.current);jt.displayMode="popup",jt.addRenderEventListener(function(){var dr=Object(I.a)(P.a.mark(function Mt(qt){var zt;return P.a.wrap(function(ar){for(;;)switch(ar.prev=ar.next){case 0:return vr.current.style.display="none",ar.next=3,Object(ke.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:qt}});case 3:zt=ar.sent,zt!=null&&zt.id&&Ye(Xr.current.getAttribute("src").replace(ie.a.API_SERVER,""),"/api/attachments/".concat(zt==null?void 0:zt.id,"?type=").concat(zt.content_type));case 5:case"end":return ar.stop()}},Mt)}));return function(Mt){return dr.apply(this,arguments)}}()),jt.show()},Ki=function(){var jt=new ft(Xr.current);jt.settings.displayMode="popup",jt.addEventListener("render",function(){var dr=Object(I.a)(P.a.mark(function Mt(qt){var zt;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(ke.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:qt.dataUrl}});case 4:zt=ar.sent,zt!=null&&zt.id&&Ye(Xr.current.getAttribute("src").replace(ie.a.API_SERVER,""),"/api/attachments/".concat(zt==null?void 0:zt.id,"?type=").concat(zt.content_type));case 6:case"end":return ar.stop()}},Mt)}));return function(Mt){return dr.apply(this,arguments)}}()),jt.show(),window.markerArea=jt},Yr=Object(M.useMemo)(function(){vr.current&&(vr.current.style.zIndex=-1);try{var Zt=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,jt=/\"\/api\/attachments\/|\"\/attachments\/download\//g,dr=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;gr=gr.replace(Zt,"("+ie.a.API_SERVER+"/api/attachments/").replace(jt,'"'+ie.a.API_SERVER+"/api/attachments/").replace(dr,'"'+ie.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 Mt=Z(gr),qt=v();if(gr.match(/\[TOC\]/)&&(Mt=Mt.replace("<p>[TOC]</p>",k()),T()),Mt=Mt.replace(/(__special_katext_id_\d+__)/g,function(ti,ar){var Sr=qt[ar],Vi=Sr.type,Ei=Sr.expression;return Object(ce.renderToString)(gi(Ei)||"",{displayMode:Vi==="block",throwOnError:!1,output:"html"})}),Mt=Mt.replace(/▁/g,"\u2581\u2581\u2581"),g(),de){var zt=document.createElement("div");return zt.innerHTML=Mt,zt.innerText}return setTimeout(function(){return dn()},500),Mt},[gr]),Gr=Object(M.useRef)();y.WebkitLineClamp=_e,_e&&(Ft=Object(N.a)(Object(N.a)({},Ft),y));function bi(Zt){var jt=Zt.target;if(jt.tagName.toUpperCase()==="IMG"){if(mt){var dr=jt.getAttribute("src");oi(dr),yi("image")}}else if(jt.tagName.toUpperCase()==="A"){var Mt=jt.getAttribute("href");if(Mt.indexOf("office")>-1)Zt.preventDefault(),oi(Mt),yi("office");else if(Mt.indexOf("application/pdf")>-1)Zt.preventDefault(),oi(Mt),yi("pdf");else if(Mt.indexOf("text/html")>-1)Zt.preventDefault(),oi(Mt),yi("html");else if(Mt.startsWith("#")){Zt.preventDefault();var qt=document.getElementById(Mt.replace("#",""));qt&&qt.scrollIntoView(!0)}}}var dn=function(){var jt,dr=(jt=Gr.current)===null||jt===void 0?void 0:jt.querySelectorAll("video");dr==null||dr.forEach(function(Mt){if(Mt.oncontextmenu=function(){return!1},Mt.src.indexOf(".m3u8")>-1&&!Mt.canPlayType("application/vnd.apple.mpegurl")){if(q.a.isSupported()){var qt=new q.a;qt.loadSource(Mt.src),qt.attachMedia(Mt)}}})};Object(M.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),g(),T()}},[Yr,Gr.current,bi]);var xi=function(jt){if(!J)return;jt.target.nodeName==="IMG"?(vr.current.style.zIndex=1,vr.current.style.display="flex",vr.current.style.width=jt.target.clientWidth+"px",vr.current.style.height=jt.target.clientHeight+"px",vr.current.style.top=jt.target.offsetTop+"px",vr.current.style.left=jt.target.offsetLeft+"px",Xr.current.src=jt.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)({},Ft),className:"".concat(F||""," 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(X.a,{onClick:function(){return Gi()}},"\u88C1\u526A"),b.a.createElement(X.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:Fr,type:Fr!=null&&Fr.length?Oi:"",style:Object(N.a)({},Or),onClose:function(){return oi("")}}))}},"9VGf":function(wt,ht,re){"use strict";re.d(ht,"a",function(){return D});var ne=re("cDcd"),$=re.n(ne);function D(X,N){var I=Object(ne.useRef)();Object(ne.useEffect)(function(){I.current=X}),Object(ne.useEffect)(function(){function z(){I.current()}if(N!==null){var U=setInterval(z,N);return function(){return clearInterval(U)}}},[N])}},Bd2K:function(wt,ht,re){(function(ne){ne(re("VrN/"),re("osHv"))})(function(ne){ne.defineOption("autoCloseTags",!1,function(P,M,b){if(b!=ne.Init&&b&&P.removeKeyMap("autoCloseTags"),!M)return;var A={name:"autoCloseTags"};(typeof M!="object"||M.whenClosing!==!1)&&(A["'/'"]=function(R){return I(R)}),(typeof M!="object"||M.whenOpening!==!1)&&(A["'>'"]=function(R){return X(R)}),P.addKeyMap(A)});var $=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],D=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];function X(P){if(P.getOption("disableInput"))return ne.Pass;for(var M=P.listSelections(),b=[],A=P.getOption("autoCloseTags"),R=0;R<M.length;R++){if(!M[R].empty())return ne.Pass;var L=M[R].head,w=P.getTokenAt(L),S=ne.innerMode(P.getMode(),w.state),h=S.state,o=S.mode.xmlCurrentTag&&S.mode.xmlCurrentTag(h),u=o&&o.name;if(!u)return ne.Pass;var d=S.mode.configuration=="html",T=typeof A=="object"&&A.dontCloseTags||d&&$,y=typeof A=="object"&&A.indentTags||d&&D;w.end>L.ch&&(u=u.slice(0,u.length-w.end+L.ch));var f=u.toLowerCase();if(!u||w.type=="string"&&(w.end!=L.ch||!/[\"\']/.test(w.string.charAt(w.string.length-1))||w.string.length==1)||w.type=="tag"&&o.close||w.string.indexOf("/")==L.ch-w.start-1||T&&z(T,f)>-1||U(P,S.mode.xmlCurrentContext&&S.mode.xmlCurrentContext(h)||[],u,L,!0))return ne.Pass;var k=typeof A=="object"&&A.emptyTags;if(k&&z(k,u)>-1){b[R]={text:"/>",newPos:ne.Pos(L.line,L.ch+2)};continue}var x=y&&z(y,f)>-1;b[R]={indent:x,text:">"+(x?`
|
|
|
|
`:"")+"</"+u+">",newPos:x?ne.Pos(L.line+1,0):ne.Pos(L.line,L.ch+1)}}for(var p=typeof A=="object"&&A.dontIndentOnAutoClose,R=M.length-1;R>=0;R--){var c=b[R];P.replaceRange(c.text,M[R].head,M[R].anchor,"+insert");var s=P.listSelections().slice(0);s[R]={head:c.newPos,anchor:c.newPos},P.setSelections(s),!p&&c.indent&&(P.indentLine(c.newPos.line,null,!0),P.indentLine(c.newPos.line+1,null,!0))}}function N(P,M){for(var b=P.listSelections(),A=[],R=M?"/":"</",L=P.getOption("autoCloseTags"),w=typeof L=="object"&&L.dontIndentOnSlash,S=0;S<b.length;S++){if(!b[S].empty())return ne.Pass;var h=b[S].head,o=P.getTokenAt(h),u=ne.innerMode(P.getMode(),o.state),d=u.state;if(M&&(o.type=="string"||o.string.charAt(0)!="<"||o.start!=h.ch-1))return ne.Pass;var T,y=u.mode.name!="xml"&&P.getMode().name=="htmlmixed";if(y&&u.mode.name=="javascript")T=R+"script";else if(y&&u.mode.name=="css")T=R+"style";else{var f=u.mode.xmlCurrentContext&&u.mode.xmlCurrentContext(d);if(!f||f.length&&U(P,f,f[f.length-1],h))return ne.Pass;T=R+f[f.length-1]}P.getLine(h.line).charAt(o.end)!=">"&&(T+=">"),A[S]=T}if(P.replaceSelections(A),b=P.listSelections(),!w)for(var S=0;S<b.length;S++)(S==b.length-1||b[S].head.line<b[S+1].head.line)&&P.indentLine(b[S].head.line)}function I(P){return P.getOption("disableInput")?ne.Pass:N(P,!0)}ne.commands.closeTag=function(P){return N(P)};function z(P,M){if(P.indexOf)return P.indexOf(M);for(var b=0,A=P.length;b<A;++b)if(P[b]==M)return b;return-1}function U(P,M,b,A,R){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 S=R?1:0,h=M.length-1;h>=0&&M[h]==b;h--)++S;A=w.to;for(var h=1;h<S;h++){var o=ne.scanForClosingTag(P,A,null,L);if(!o||o.tag!=b)return!1;A=o.to}return!0}})},BdwD:function(wt,ht,re){"use strict";var ne=re("+L6B"),$=re("2/Rp"),D=re("0Owb"),X=re("k1fw"),N=re("cDcd"),I=re.n(N),z=re("FOrL"),U=re.n(z),P=function(b){var A=b.buttonProps,R=A===void 0?{}:A,L=b.styles,w=L===void 0?{}:L,S=b.customText,h=b.ButtonText,o=b.ButtonClick,u=b.Buttonclass,d=b.ButtonTwo;return I.a.createElement("section",{className:"tc animated fadeIn",style:Object(X.a)(Object(X.a)({},{color:"#999",margin:"200px auto"}),w)},I.a.createElement("img",{src:U.a}),I.a.createElement("p",{className:"mt20 font14"},S||"\u6682\u65F6\u8FD8\u6CA1\u6709\u76F8\u5173\u6570\u636E\u54E6!"),h&&I.a.createElement($.a,Object(D.a)({className:u,onClick:o},R),h),d&&d)};ht.a=P},BjJ7:function(wt,ht,re){"use strict";re.d(ht,"d",function(){return $}),re.d(ht,"c",function(){return D}),re.d(ht,"e",function(){return X}),re.d(ht,"b",function(){return N}),re.d(ht,"a",function(){return z});var ne=re("m3rI");function $(U){var P=!0;if(U.length>0){for(var M=0;M<U.length;M++)if(U[M].compile_success==0||!U[M].compile_success){P=!1;break}}else P=!1;return P}function D(U){for(var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",M=[],b=0;b<U.length;b++){var A=U[b],R=P?"".concat(P,"/").concat(A.name):"".concat(A.name);M.push({title:A.name,isLeaf:!(A.type==="tree"),key:R})}return M}function X(U,P,M){for(var b=0;b<U.length;b++){var A=U[b];if(A.key===P){A.children=M;break}A.children&&X(A.children,P,M)}return U}function N(U,P,M){var b;return function(){var A=this,R=arguments,L=function(){b=null,M||U.apply(A,R)},w=M&&!b;clearTimeout(b),b=setTimeout(L,P),w&&U.apply(A,R)}}var I=!0,z=ne.a.API_SERVER},"C+DQ":function(wt,ht,re){},DlQD:function(wt,ht,re){(function(ne,$){wt.exports=$()})(this,function(){"use strict";function ne(me,he){for(var fe=0;fe<he.length;fe++){var ee=he[fe];ee.enumerable=ee.enumerable||!1,ee.configurable=!0,"value"in ee&&(ee.writable=!0),Object.defineProperty(me,ee.key,ee)}}function $(me,he,fe){return he&&ne(me.prototype,he),fe&&ne(me,fe),me}function D(me,he){if(!me)return;if(typeof me=="string")return X(me,he);var fe=Object.prototype.toString.call(me).slice(8,-1);if(fe==="Object"&&me.constructor&&(fe=me.constructor.name),fe==="Map"||fe==="Set")return Array.from(me);if(fe==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(fe))return X(me,he)}function X(me,he){(he==null||he>me.length)&&(he=me.length);for(var fe=0,ee=new Array(he);fe<he;fe++)ee[fe]=me[fe];return ee}function N(me,he){var fe;if(typeof Symbol=="undefined"||me[Symbol.iterator]==null){if(Array.isArray(me)||(fe=D(me))||he&&me&&typeof me.length=="number"){fe&&(me=fe);var ee=0;return function(){return ee>=me.length?{done:!0}:{done:!1,value:me[ee++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}return fe=me[Symbol.iterator](),fe.next.bind(fe)}function I(me,he){return he={exports:{}},me(he,he.exports),he.exports}var z=I(function(me){function he(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}function fe(ee){me.exports.defaults=ee}me.exports={defaults:he(),getDefaults:he,changeDefaults:fe}}),U=z.defaults,P=z.getDefaults,M=z.changeDefaults,b=/[&<>"']/,A=/[&<>"']/g,R=/[<>"']|&(?!#?\w+;)/,L=/[<>"']|&(?!#?\w+;)/g,w={"&":"&","<":"<",">":">",'"':""","'":"'"},S=function(he){return w[he]};function h(me,he){if(he){if(b.test(me))return me.replace(A,S)}else if(R.test(me))return me.replace(L,S);return me}var o=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function u(me){return me.replace(o,function(he,fe){return fe=fe.toLowerCase(),fe==="colon"?":":fe.charAt(0)==="#"?fe.charAt(1)==="x"?String.fromCharCode(parseInt(fe.substring(2),16)):String.fromCharCode(+fe.substring(1)):""})}var d=/(^|[^\[])\^/g;function T(me,he){me=me.source||me,he=he||"";var fe={replace:function(te,ae){return ae=ae.source||ae,ae=ae.replace(d,"$1"),me=me.replace(te,ae),fe},getRegex:function(){return new RegExp(me,he)}};return fe}var y=/[^\w:]/g,f=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function k(me,he,fe){if(me){var ee;try{ee=decodeURIComponent(u(fe)).replace(y,"").toLowerCase()}catch(te){return null}if(ee.indexOf("javascript:")===0||ee.indexOf("vbscript:")===0||ee.indexOf("data:")===0)return null}he&&!f.test(fe)&&(fe=a(he,fe));try{fe=encodeURI(fe).replace(/%25/g,"%")}catch(te){return null}return fe}var x={},p=/^[^:]+:\/*[^/]*$/,c=/^([^:]+:)[\s\S]*$/,s=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(me,he){x[" "+me]||(p.test(me)?x[" "+me]=me+"/":x[" "+me]=_(me,"/",!0)),me=x[" "+me];var fe=me.indexOf(":")===-1;return he.substring(0,2)==="//"?fe?he:me.replace(c,"$1")+he:he.charAt(0)==="/"?fe?he:me.replace(s,"$1")+he:me+he}var v={exec:function(){}};function g(me){for(var he=1,fe,ee;he<arguments.length;he++){fe=arguments[he];for(ee in fe)Object.prototype.hasOwnProperty.call(fe,ee)&&(me[ee]=fe[ee])}return me}function E(me,he){var fe=me.replace(/\|/g,function(ae,ue,ge){for(var Se=!1,Oe=ue;--Oe>=0&&ge[Oe]==="\\";)Se=!Se;return Se?"|":" |"}),ee=fe.split(/ \|/),te=0;if(ee.length>he)ee.splice(he);else for(;ee.length<he;)ee.push("");for(;te<ee.length;te++)ee[te]=ee[te].trim().replace(/\\\|/g,"|");return ee}function _(me,he,fe){var ee=me.length;if(ee===0)return"";for(var te=0;te<ee;){var ae=me.charAt(ee-te-1);if(ae===he&&!fe)te++;else if(ae!==he&&fe)te++;else break}return me.substr(0,ee-te)}function H(me,he){if(me.indexOf(he[1])===-1)return-1;for(var fe=me.length,ee=0,te=0;te<fe;te++)if(me[te]==="\\")te++;else if(me[te]===he[0])ee++;else if(me[te]===he[1]&&(ee--,ee<0))return te;return-1}function V(me){me&&me.sanitize&&!me.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 Z={escape:h,unescape:u,edit:T,cleanUrl:k,resolveUrl:a,noopTest:v,merge:g,splitCells:E,rtrim:_,findClosingBracket:H,checkSanitizeDeprecation:V},G=z.defaults,j=Z.rtrim,q=Z.splitCells,ie=Z.escape,ce=Z.findClosingBracket;function ve(me,he,fe){var ee=he.href,te=he.title?ie(he.title):null,ae=me[1].replace(/\\([\[\]])/g,"$1");return me[0].charAt(0)!=="!"?{type:"link",raw:fe,href:ee,title:te,text:ae}:{type:"image",raw:fe,href:ee,title:te,text:ie(ae)}}function ke(me,he){var fe=me.match(/^(\s+)(?:```)/);if(fe===null)return he;var ee=fe[1];return he.split(`
|
|
`).map(function(te){var ae=te.match(/^\s+/);if(ae===null)return te;var ue=ae[0];return ue.length>=ee.length?te.slice(ee.length):te}).join(`
|
|
`)}var xe=function(){function me(fe){this.options=fe||G}var he=me.prototype;return he.space=function(ee){var te=this.rules.block.newline.exec(ee);if(te)return te[0].length>1?{type:"space",raw:te[0]}:{raw:`
|
|
`}},he.code=function(ee,te){var ae=this.rules.block.code.exec(ee);if(ae){var ue=te[te.length-1];if(ue&&ue.type==="paragraph")return{raw:ae[0],text:ae[0].trimRight()};var ge=ae[0].replace(/^ {4}/gm,"");return{type:"code",raw:ae[0],codeBlockStyle:"indented",text:this.options.pedantic?ge:j(ge,`
|
|
`)}}},he.fences=function(ee){var te=this.rules.block.fences.exec(ee);if(te){var ae=te[0],ue=ke(ae,te[3]||"");return{type:"code",raw:ae,lang:te[2]?te[2].trim():te[2],text:ue}}},he.heading=function(ee){var te=this.rules.block.heading.exec(ee);if(te)return{type:"heading",raw:te[0],depth:te[1].length,text:te[2]}},he.nptable=function(ee){var te=this.rules.block.nptable.exec(ee);if(te){var ae={type:"table",header:q(te[1].replace(/^ *| *\| *$/g,"")),align:te[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:te[3]?te[3].replace(/\n$/,"").split(`
|
|
`):[],raw:te[0]};if(ae.header.length===ae.align.length){var ue=ae.align.length,ge;for(ge=0;ge<ue;ge++)/^ *-+: *$/.test(ae.align[ge])?ae.align[ge]="right":/^ *:-+: *$/.test(ae.align[ge])?ae.align[ge]="center":/^ *:-+ *$/.test(ae.align[ge])?ae.align[ge]="left":ae.align[ge]=null;for(ue=ae.cells.length,ge=0;ge<ue;ge++)ae.cells[ge]=q(ae.cells[ge],ae.header.length);return ae}}},he.hr=function(ee){var te=this.rules.block.hr.exec(ee);if(te)return{type:"hr",raw:te[0]}},he.blockquote=function(ee){var te=this.rules.block.blockquote.exec(ee);if(te){var ae=te[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:te[0],text:ae}}},he.list=function(ee){var te=this.rules.block.list.exec(ee);if(te){for(var ae=te[0],ue=te[2],ge=ue.length>1,Se=ue[ue.length-1]===")",Oe={type:"list",raw:ae,ordered:ge,start:ge?+ue.slice(0,-1):"",loose:!1,items:[]},nt=te[0].match(this.rules.block.item),gt=!1,ct,kt,ot,We,yt,ft,_t,xt=nt.length,Dt=0;Dt<xt;Dt++)ct=nt[Dt],ae=ct,kt=ct.length,ct=ct.replace(/^ *([*+-]|\d+[.)]) */,""),~ct.indexOf(`
|
|
`)&&(kt-=ct.length,ct=this.options.pedantic?ct.replace(/^ {1,4}/gm,""):ct.replace(new RegExp("^ {1,"+kt+"}","gm"),"")),Dt!==xt-1&&(ot=this.rules.block.bullet.exec(nt[Dt+1])[0],(ge?ot.length===1||!Se&&ot[ot.length-1]===")":ot.length>1||this.options.smartLists&&ot!==ue)&&(We=nt.slice(Dt+1).join(`
|
|
`),Oe.raw=Oe.raw.substring(0,Oe.raw.length-We.length),Dt=xt-1)),yt=gt||/\n\n(?!\s*$)/.test(ct),Dt!==xt-1&&(gt=ct.charAt(ct.length-1)===`
|
|
`,yt||(yt=gt)),yt&&(Oe.loose=!0),ft=/^\[[ xX]\] /.test(ct),_t=void 0,ft&&(_t=ct[1]!==" ",ct=ct.replace(/^\[[ xX]\] +/,"")),Oe.items.push({type:"list_item",raw:ae,task:ft,checked:_t,loose:yt,text:ct});return Oe}},he.html=function(ee){var te=this.rules.block.html.exec(ee);if(te)return{type:this.options.sanitize?"paragraph":"html",raw:te[0],pre:!this.options.sanitizer&&(te[1]==="pre"||te[1]==="script"||te[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(te[0]):ie(te[0]):te[0]}},he.def=function(ee){var te=this.rules.block.def.exec(ee);if(te){te[3]&&(te[3]=te[3].substring(1,te[3].length-1));var ae=te[1].toLowerCase().replace(/\s+/g," ");return{tag:ae,raw:te[0],href:te[2],title:te[3]}}},he.table=function(ee){var te=this.rules.block.table.exec(ee);if(te){var ae={type:"table",header:q(te[1].replace(/^ *| *\| *$/g,"")),align:te[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:te[3]?te[3].replace(/\n$/,"").split(`
|
|
`):[]};if(ae.header.length===ae.align.length){ae.raw=te[0];var ue=ae.align.length,ge;for(ge=0;ge<ue;ge++)/^ *-+: *$/.test(ae.align[ge])?ae.align[ge]="right":/^ *:-+: *$/.test(ae.align[ge])?ae.align[ge]="center":/^ *:-+ *$/.test(ae.align[ge])?ae.align[ge]="left":ae.align[ge]=null;for(ue=ae.cells.length,ge=0;ge<ue;ge++)ae.cells[ge]=q(ae.cells[ge].replace(/^ *\| *| *\| *$/g,""),ae.header.length);return ae}}},he.lheading=function(ee){var te=this.rules.block.lheading.exec(ee);if(te)return{type:"heading",raw:te[0],depth:te[2].charAt(0)==="="?1:2,text:te[1]}},he.paragraph=function(ee){var te=this.rules.block.paragraph.exec(ee);if(te)return{type:"paragraph",raw:te[0],text:te[1].charAt(te[1].length-1)===`
|
|
`?te[1].slice(0,-1):te[1]}},he.text=function(ee,te){var ae=this.rules.block.text.exec(ee);if(ae){var ue=te[te.length-1];return ue&&ue.type==="text"?{raw:ae[0],text:ae[0]}:{type:"text",raw:ae[0],text:ae[0]}}},he.escape=function(ee){var te=this.rules.inline.escape.exec(ee);if(te)return{type:"escape",raw:te[0],text:ie(te[1])}},he.tag=function(ee,te,ae){var ue=this.rules.inline.tag.exec(ee);if(ue)return!te&&/^<a /i.test(ue[0])?te=!0:te&&/^<\/a>/i.test(ue[0])&&(te=!1),!ae&&/^<(pre|code|kbd|script)(\s|>)/i.test(ue[0])?ae=!0:ae&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(ue[0])&&(ae=!1),{type:this.options.sanitize?"text":"html",raw:ue[0],inLink:te,inRawBlock:ae,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ue[0]):ie(ue[0]):ue[0]}},he.link=function(ee){var te=this.rules.inline.link.exec(ee);if(te){var ae=ce(te[2],"()");if(ae>-1){var ue=te[0].indexOf("!")===0?5:4,ge=ue+te[1].length+ae;te[2]=te[2].substring(0,ae),te[0]=te[0].substring(0,ge).trim(),te[3]=""}var Se=te[2],Oe="";if(this.options.pedantic){var nt=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(Se);nt?(Se=nt[1],Oe=nt[3]):Oe=""}else Oe=te[3]?te[3].slice(1,-1):"";Se=Se.trim().replace(/^<([\s\S]*)>$/,"$1");var gt=ve(te,{href:Se&&Se.replace(this.rules.inline._escapes,"$1"),title:Oe&&Oe.replace(this.rules.inline._escapes,"$1")},te[0]);return gt}},he.reflink=function(ee,te){var ae;if((ae=this.rules.inline.reflink.exec(ee))||(ae=this.rules.inline.nolink.exec(ee))){var ue=(ae[2]||ae[1]).replace(/\s+/g," ");if(ue=te[ue.toLowerCase()],!ue||!ue.href){var ge=ae[0].charAt(0);return{type:"text",raw:ge,text:ge}}var Se=ve(ae,ue,ae[0]);return Se}},he.strong=function(ee,te,ae){ae===void 0&&(ae="");var ue=this.rules.inline.strong.start.exec(ee);if(ue&&(!ue[1]||ue[1]&&(ae===""||this.rules.inline.punctuation.exec(ae)))){te=te.slice(-1*ee.length);var ge=ue[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;ge.lastIndex=0;for(var Se;(ue=ge.exec(te))!=null;)if(Se=this.rules.inline.strong.middle.exec(te.slice(0,ue.index+3)),Se)return{type:"strong",raw:ee.slice(0,Se[0].length),text:ee.slice(2,Se[0].length-2)}}},he.em=function(ee,te,ae){ae===void 0&&(ae="");var ue=this.rules.inline.em.start.exec(ee);if(ue&&(!ue[1]||ue[1]&&(ae===""||this.rules.inline.punctuation.exec(ae)))){te=te.slice(-1*ee.length);var ge=ue[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;ge.lastIndex=0;for(var Se;(ue=ge.exec(te))!=null;)if(Se=this.rules.inline.em.middle.exec(te.slice(0,ue.index+2)),Se)return{type:"em",raw:ee.slice(0,Se[0].length),text:ee.slice(1,Se[0].length-1)}}},he.codespan=function(ee){var te=this.rules.inline.code.exec(ee);if(te){var ae=te[2].replace(/\n/g," "),ue=/[^ ]/.test(ae),ge=ae.startsWith(" ")&&ae.endsWith(" ");return ue&&ge&&(ae=ae.substring(1,ae.length-1)),ae=ie(ae,!0),{type:"codespan",raw:te[0],text:ae}}},he.br=function(ee){var te=this.rules.inline.br.exec(ee);if(te)return{type:"br",raw:te[0]}},he.del=function(ee){var te=this.rules.inline.del.exec(ee);if(te)return{type:"del",raw:te[0],text:te[1]}},he.autolink=function(ee,te){var ae=this.rules.inline.autolink.exec(ee);if(ae){var ue,ge;return ae[2]==="@"?(ue=ie(this.options.mangle?te(ae[1]):ae[1]),ge="mailto:"+ue):(ue=ie(ae[1]),ge=ue),{type:"link",raw:ae[0],text:ue,href:ge,tokens:[{type:"text",raw:ue,text:ue}]}}},he.url=function(ee,te){var ae;if(ae=this.rules.inline.url.exec(ee)){var ue,ge;if(ae[2]==="@")ue=ie(this.options.mangle?te(ae[0]):ae[0]),ge="mailto:"+ue;else{var Se;do Se=ae[0],ae[0]=this.rules.inline._backpedal.exec(ae[0])[0];while(Se!==ae[0]);ue=ie(ae[0]),ae[1]==="www."?ge="http://"+ue:ge=ue}return{type:"link",raw:ae[0],text:ue,href:ge,tokens:[{type:"text",raw:ue,text:ue}]}}},he.inlineText=function(ee,te,ae){var ue=this.rules.inline.text.exec(ee);if(ue){var ge;return te?ge=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ue[0]):ie(ue[0]):ue[0]:ge=ie(this.options.smartypants?ae(ue[0]):ue[0]),{type:"text",raw:ue[0],text:ge}}},me}(),Ce=Z.noopTest,Te=Z.edit,Ee=Z.merge,pe={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]+/};pe._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,pe._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,pe.def=Te(pe.def).replace("label",pe._label).replace("title",pe._title).getRegex(),pe.bullet=/(?:[*+-]|\d{1,9}[.)])/,pe.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,pe.item=Te(pe.item,"gm").replace(/bull/g,pe.bullet).getRegex(),pe.list=Te(pe.list).replace(/bull/g,pe.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+pe.def.source+")").getRegex(),pe._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",pe._comment=/<!--(?!-?>)[\s\S]*?-->/,pe.html=Te(pe.html,"i").replace("comment",pe._comment).replace("tag",pe._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),pe.paragraph=Te(pe._paragraph).replace("hr",pe.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",pe._tag).getRegex(),pe.blockquote=Te(pe.blockquote).replace("paragraph",pe.paragraph).getRegex(),pe.normal=Ee({},pe),pe.gfm=Ee({},pe.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*|$)"}),pe.gfm.nptable=Te(pe.gfm.nptable).replace("hr",pe.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",pe._tag).getRegex(),pe.gfm.table=Te(pe.gfm.table).replace("hr",pe.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",pe._tag).getRegex(),pe.pedantic=Ee({},pe.normal,{html:Te(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",pe._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:Te(pe.normal._paragraph).replace("hr",pe.hr).replace("heading",` *#{1,6} *[^
|
|
]`).replace("lheading",pe.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var se={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ce,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",strong:{start:/^(?:(\*\*(?=[*punctuation]))|\*\*)(?![\s])|__/,middle:/^\*\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*\*$|^__(?![\s])((?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?)__$/,endAst:/[^punctuation\s]\*\*(?!\*)|[punctuation]\*\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]__(?!_)(?:(?=[punctuation\s])|$)/},em:{start:/^(?:(\*(?=[punctuation]))|\*)(?![*\s])|_/,middle:/^\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*$|^_(?![_\s])(?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?_$/,endAst:/[^punctuation\s]\*(?!\*)|[punctuation]\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]_(?!_)(?:(?=[punctuation\s])|$)/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Ce,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};se._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",se.punctuation=Te(se.punctuation).replace(/punctuation/g,se._punctuation).getRegex(),se._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",se._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",se.em.start=Te(se.em.start).replace(/punctuation/g,se._punctuation).getRegex(),se.em.middle=Te(se.em.middle).replace(/punctuation/g,se._punctuation).replace(/overlapSkip/g,se._overlapSkip).getRegex(),se.em.endAst=Te(se.em.endAst,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.em.endUnd=Te(se.em.endUnd,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.strong.start=Te(se.strong.start).replace(/punctuation/g,se._punctuation).getRegex(),se.strong.middle=Te(se.strong.middle).replace(/punctuation/g,se._punctuation).replace(/blockSkip/g,se._blockSkip).getRegex(),se.strong.endAst=Te(se.strong.endAst,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.strong.endUnd=Te(se.strong.endUnd,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.blockSkip=Te(se._blockSkip,"g").getRegex(),se.overlapSkip=Te(se._overlapSkip,"g").getRegex(),se._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,se._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,se._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,se.autolink=Te(se.autolink).replace("scheme",se._scheme).replace("email",se._email).getRegex(),se._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,se.tag=Te(se.tag).replace("comment",pe._comment).replace("attribute",se._attribute).getRegex(),se._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,se._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,se._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,se.link=Te(se.link).replace("label",se._label).replace("href",se._href).replace("title",se._title).getRegex(),se.reflink=Te(se.reflink).replace("label",se._label).getRegex(),se.reflinkSearch=Te(se.reflinkSearch,"g").replace("reflink",se.reflink).replace("nolink",se.nolink).getRegex(),se.normal=Ee({},se),se.pedantic=Ee({},se.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Te(/^!?\[(label)\]\((.*?)\)/).replace("label",se._label).getRegex(),reflink:Te(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",se._label).getRegex()}),se.gfm=Ee({},se.normal,{escape:Te(se.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/}),se.gfm.url=Te(se.gfm.url,"i").replace("email",se.gfm._extended_email).getRegex(),se.breaks=Ee({},se.gfm,{br:Te(se.br).replace("{2,}","*").getRegex(),text:Te(se.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var Le={block:pe,inline:se},Xe=z.defaults,Ge=Le.block,Ke=Le.inline;function Ve(me){return me.replace(/---/g,"\u2014").replace(/--/g,"\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1\u2018").replace(/'/g,"\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1\u201C").replace(/"/g,"\u201D").replace(/\.{3}/g,"\u2026")}function De(me){var he="",fe,ee,te=me.length;for(fe=0;fe<te;fe++)ee=me.charCodeAt(fe),Math.random()>.5&&(ee="x"+ee.toString(16)),he+="&#"+ee+";";return he}var Pe=function(){function me(fe){this.tokens=[],this.tokens.links=Object.create(null),this.options=fe||Xe,this.options.tokenizer=this.options.tokenizer||new xe,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var ee={block:Ge.normal,inline:Ke.normal};this.options.pedantic?(ee.block=Ge.pedantic,ee.inline=Ke.pedantic):this.options.gfm&&(ee.block=Ge.gfm,this.options.breaks?ee.inline=Ke.breaks:ee.inline=Ke.gfm),this.tokenizer.rules=ee}me.lex=function(ee,te){var ae=new me(te);return ae.lex(ee)};var he=me.prototype;return he.lex=function(ee){return ee=ee.replace(/\r\n|\r/g,`
|
|
`).replace(/\t/g," "),this.blockTokens(ee,this.tokens,!0),this.inline(this.tokens),this.tokens},he.blockTokens=function(ee,te,ae){te===void 0&&(te=[]),ae===void 0&&(ae=!0),ee=ee.replace(/^ +$/gm,"");for(var ue,ge,Se,Oe;ee;){if(ue=this.tokenizer.space(ee)){ee=ee.substring(ue.raw.length),ue.type&&te.push(ue);continue}if(ue=this.tokenizer.code(ee,te)){ee=ee.substring(ue.raw.length),ue.type?te.push(ue):(Oe=te[te.length-1],Oe.raw+=`
|
|
`+ue.raw,Oe.text+=`
|
|
`+ue.text);continue}if(ue=this.tokenizer.fences(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.heading(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.nptable(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.hr(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.blockquote(ee)){ee=ee.substring(ue.raw.length),ue.tokens=this.blockTokens(ue.text,[],ae),te.push(ue);continue}if(ue=this.tokenizer.list(ee)){for(ee=ee.substring(ue.raw.length),Se=ue.items.length,ge=0;ge<Se;ge++)ue.items[ge].tokens=this.blockTokens(ue.items[ge].text,[],!1);te.push(ue);continue}if(ue=this.tokenizer.html(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ae&&(ue=this.tokenizer.def(ee))){ee=ee.substring(ue.raw.length),this.tokens.links[ue.tag]||(this.tokens.links[ue.tag]={href:ue.href,title:ue.title});continue}if(ue=this.tokenizer.table(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.lheading(ee)){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ae&&(ue=this.tokenizer.paragraph(ee))){ee=ee.substring(ue.raw.length),te.push(ue);continue}if(ue=this.tokenizer.text(ee,te)){ee=ee.substring(ue.raw.length),ue.type?te.push(ue):(Oe=te[te.length-1],Oe.raw+=`
|
|
`+ue.raw,Oe.text+=`
|
|
`+ue.text);continue}if(ee){var nt="Infinite loop on byte: "+ee.charCodeAt(0);if(this.options.silent){console.error(nt);break}else throw new Error(nt)}}return te},he.inline=function(ee){var te,ae,ue,ge,Se,Oe,nt=ee.length;for(te=0;te<nt;te++){Oe=ee[te];switch(Oe.type){case"paragraph":case"text":case"heading":{Oe.tokens=[],this.inlineTokens(Oe.text,Oe.tokens);break}case"table":{for(Oe.tokens={header:[],cells:[]},ge=Oe.header.length,ae=0;ae<ge;ae++)Oe.tokens.header[ae]=[],this.inlineTokens(Oe.header[ae],Oe.tokens.header[ae]);for(ge=Oe.cells.length,ae=0;ae<ge;ae++)for(Se=Oe.cells[ae],Oe.tokens.cells[ae]=[],ue=0;ue<Se.length;ue++)Oe.tokens.cells[ae][ue]=[],this.inlineTokens(Se[ue],Oe.tokens.cells[ae][ue]);break}case"blockquote":{this.inline(Oe.tokens);break}case"list":{for(ge=Oe.items.length,ae=0;ae<ge;ae++)this.inline(Oe.items[ae].tokens);break}}}return ee},he.inlineTokens=function(ee,te,ae,ue,ge){te===void 0&&(te=[]),ae===void 0&&(ae=!1),ue===void 0&&(ue=!1),ge===void 0&&(ge="");var Se,Oe=ee,nt;if(this.tokens.links){var gt=Object.keys(this.tokens.links);if(gt.length>0)for(;(nt=this.tokenizer.rules.inline.reflinkSearch.exec(Oe))!=null;)gt.includes(nt[0].slice(nt[0].lastIndexOf("[")+1,-1))&&(Oe=Oe.slice(0,nt.index)+"["+"a".repeat(nt[0].length-2)+"]"+Oe.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(nt=this.tokenizer.rules.inline.blockSkip.exec(Oe))!=null;)Oe=Oe.slice(0,nt.index)+"["+"a".repeat(nt[0].length-2)+"]"+Oe.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;ee;){if(Se=this.tokenizer.escape(ee)){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(Se=this.tokenizer.tag(ee,ae,ue)){ee=ee.substring(Se.raw.length),ae=Se.inLink,ue=Se.inRawBlock,te.push(Se);continue}if(Se=this.tokenizer.link(ee)){ee=ee.substring(Se.raw.length),Se.type==="link"&&(Se.tokens=this.inlineTokens(Se.text,[],!0,ue)),te.push(Se);continue}if(Se=this.tokenizer.reflink(ee,this.tokens.links)){ee=ee.substring(Se.raw.length),Se.type==="link"&&(Se.tokens=this.inlineTokens(Se.text,[],!0,ue)),te.push(Se);continue}if(Se=this.tokenizer.strong(ee,Oe,ge)){ee=ee.substring(Se.raw.length),Se.tokens=this.inlineTokens(Se.text,[],ae,ue),te.push(Se);continue}if(Se=this.tokenizer.em(ee,Oe,ge)){ee=ee.substring(Se.raw.length),Se.tokens=this.inlineTokens(Se.text,[],ae,ue),te.push(Se);continue}if(Se=this.tokenizer.codespan(ee)){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(Se=this.tokenizer.br(ee)){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(Se=this.tokenizer.del(ee)){ee=ee.substring(Se.raw.length),Se.tokens=this.inlineTokens(Se.text,[],ae,ue),te.push(Se);continue}if(Se=this.tokenizer.autolink(ee,De)){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(!ae&&(Se=this.tokenizer.url(ee,De))){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(Se=this.tokenizer.inlineText(ee,ue,Ve)){ee=ee.substring(Se.raw.length),ge=Se.raw.slice(-1),te.push(Se);continue}if(ee){var ct="Infinite loop on byte: "+ee.charCodeAt(0);if(this.options.silent){console.error(ct);break}else throw new Error(ct)}}return te},$(me,null,[{key:"rules",get:function(){return{block:Ge,inline:Ke}}}]),me}(),He=z.defaults,$e=Z.cleanUrl,Fe=Z.escape,Ne=function(){function me(fe){this.options=fe||He}var he=me.prototype;return he.code=function(ee,te,ae){var ue=(te||"").match(/\S*/)[0];if(this.options.highlight){var ge=this.options.highlight(ee,ue);ge!=null&&ge!==ee&&(ae=!0,ee=ge)}return ue?'<pre><code class="'+this.options.langPrefix+Fe(ue,!0)+'">'+(ae?ee:Fe(ee,!0))+`</code></pre>
|
|
`:"<pre><code>"+(ae?ee:Fe(ee,!0))+`</code></pre>
|
|
`},he.blockquote=function(ee){return`<blockquote>
|
|
`+ee+`</blockquote>
|
|
`},he.html=function(ee){return ee},he.heading=function(ee,te,ae,ue){return this.options.headerIds?"<h"+te+' id="'+this.options.headerPrefix+ue.slug(ae)+'">'+ee+"</h"+te+`>
|
|
`:"<h"+te+">"+ee+"</h"+te+`>
|
|
`},he.hr=function(){return this.options.xhtml?`<hr/>
|
|
`:`<hr>
|
|
`},he.list=function(ee,te,ae){var ue=te?"ol":"ul",ge=te&&ae!==1?' start="'+ae+'"':"";return"<"+ue+ge+`>
|
|
`+ee+"</"+ue+`>
|
|
`},he.listitem=function(ee){return"<li>"+ee+`</li>
|
|
`},he.checkbox=function(ee){return"<input "+(ee?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},he.paragraph=function(ee){return"<p>"+ee+`</p>
|
|
`},he.table=function(ee,te){return te&&(te="<tbody>"+te+"</tbody>"),`<table>
|
|
<thead>
|
|
`+ee+`</thead>
|
|
`+te+`</table>
|
|
`},he.tablerow=function(ee){return`<tr>
|
|
`+ee+`</tr>
|
|
`},he.tablecell=function(ee,te){var ae=te.header?"th":"td",ue=te.align?"<"+ae+' align="'+te.align+'">':"<"+ae+">";return ue+ee+"</"+ae+`>
|
|
`},he.strong=function(ee){return"<strong>"+ee+"</strong>"},he.em=function(ee){return"<em>"+ee+"</em>"},he.codespan=function(ee){return"<code>"+ee+"</code>"},he.br=function(){return this.options.xhtml?"<br/>":"<br>"},he.del=function(ee){return"<del>"+ee+"</del>"},he.link=function(ee,te,ae){if(ee=$e(this.options.sanitize,this.options.baseUrl,ee),ee===null)return ae;var ue='<a href="'+Fe(ee)+'"';return te&&(ue+=' title="'+te+'"'),ue+=">"+ae+"</a>",ue},he.image=function(ee,te,ae){if(ee=$e(this.options.sanitize,this.options.baseUrl,ee),ee===null)return ae;var ue='<img src="'+ee+'" alt="'+ae+'"';return te&&(ue+=' title="'+te+'"'),ue+=this.options.xhtml?"/>":">",ue},he.text=function(ee){return ee},me}(),Me=function(){function me(){}var he=me.prototype;return he.strong=function(ee){return ee},he.em=function(ee){return ee},he.codespan=function(ee){return ee},he.del=function(ee){return ee},he.html=function(ee){return ee},he.text=function(ee){return ee},he.link=function(ee,te,ae){return""+ae},he.image=function(ee,te,ae){return""+ae},he.br=function(){return""},me}(),at=function(){function me(){this.seen={}}var he=me.prototype;return he.slug=function(ee){var te=ee.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(te)){var ae=te;do this.seen[ae]++,te=ae+"-"+this.seen[ae];while(this.seen.hasOwnProperty(te))}return this.seen[te]=0,te},me}(),qe=z.defaults,Qe=Z.unescape,tt=function(){function me(fe){this.options=fe||qe,this.options.renderer=this.options.renderer||new Ne,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Me,this.slugger=new at}me.parse=function(ee,te){var ae=new me(te);return ae.parse(ee)};var he=me.prototype;return he.parse=function(ee,te){te===void 0&&(te=!0);var ae="",ue,ge,Se,Oe,nt,gt,ct,kt,ot,We,yt,ft,_t,xt,Dt,Er,Hr,bt,Nr=ee.length;for(ue=0;ue<Nr;ue++){We=ee[ue];switch(We.type){case"space":continue;case"hr":{ae+=this.renderer.hr();continue}case"heading":{ae+=this.renderer.heading(this.parseInline(We.tokens),We.depth,Qe(this.parseInline(We.tokens,this.textRenderer)),this.slugger);continue}case"code":{ae+=this.renderer.code(We.text,We.lang,We.escaped);continue}case"table":{for(kt="",ct="",Oe=We.header.length,ge=0;ge<Oe;ge++)ct+=this.renderer.tablecell(this.parseInline(We.tokens.header[ge]),{header:!0,align:We.align[ge]});for(kt+=this.renderer.tablerow(ct),ot="",Oe=We.cells.length,ge=0;ge<Oe;ge++){for(gt=We.tokens.cells[ge],ct="",nt=gt.length,Se=0;Se<nt;Se++)ct+=this.renderer.tablecell(this.parseInline(gt[Se]),{header:!1,align:We.align[Se]});ot+=this.renderer.tablerow(ct)}ae+=this.renderer.table(kt,ot);continue}case"blockquote":{ot=this.parse(We.tokens),ae+=this.renderer.blockquote(ot);continue}case"list":{for(yt=We.ordered,ft=We.start,_t=We.loose,Oe=We.items.length,ot="",ge=0;ge<Oe;ge++)Dt=We.items[ge],Er=Dt.checked,Hr=Dt.task,xt="",Dt.task&&(bt=this.renderer.checkbox(Er),_t?Dt.tokens.length>0&&Dt.tokens[0].type==="text"?(Dt.tokens[0].text=bt+" "+Dt.tokens[0].text,Dt.tokens[0].tokens&&Dt.tokens[0].tokens.length>0&&Dt.tokens[0].tokens[0].type==="text"&&(Dt.tokens[0].tokens[0].text=bt+" "+Dt.tokens[0].tokens[0].text)):Dt.tokens.unshift({type:"text",text:bt}):xt+=bt),xt+=this.parse(Dt.tokens,_t),ot+=this.renderer.listitem(xt,Hr,Er);ae+=this.renderer.list(ot,yt,ft);continue}case"html":{ae+=this.renderer.html(We.text);continue}case"paragraph":{ae+=this.renderer.paragraph(this.parseInline(We.tokens));continue}case"text":{for(ot=We.tokens?this.parseInline(We.tokens):We.text;ue+1<Nr&&ee[ue+1].type==="text";)We=ee[++ue],ot+=`
|
|
`+(We.tokens?this.parseInline(We.tokens):We.text);ae+=te?this.renderer.paragraph(ot):ot;continue}default:{var hr='Token with "'+We.type+'" type was not found.';if(this.options.silent){console.error(hr);return}else throw new Error(hr)}}}return ae},he.parseInline=function(ee,te){te=te||this.renderer;var ae="",ue,ge,Se=ee.length;for(ue=0;ue<Se;ue++){ge=ee[ue];switch(ge.type){case"escape":{ae+=te.text(ge.text);break}case"html":{ae+=te.html(ge.text);break}case"link":{ae+=te.link(ge.href,ge.title,this.parseInline(ge.tokens,te));break}case"image":{ae+=te.image(ge.href,ge.title,ge.text);break}case"strong":{ae+=te.strong(this.parseInline(ge.tokens,te));break}case"em":{ae+=te.em(this.parseInline(ge.tokens,te));break}case"codespan":{ae+=te.codespan(ge.text);break}case"br":{ae+=te.br();break}case"del":{ae+=te.del(this.parseInline(ge.tokens,te));break}case"text":{ae+=te.text(ge.text);break}default:{var Oe='Token with "'+ge.type+'" type was not found.';if(this.options.silent){console.error(Oe);return}else throw new Error(Oe)}}}return ae},me}(),ut=Z.merge,rt=Z.checkSanitizeDeprecation,it=Z.escape,we=z.getDefaults,lt=z.changeDefaults,et=z.defaults;function Ae(me,he,fe){if(typeof me=="undefined"||me===null)throw new Error("marked(): input parameter is undefined or null");if(typeof me!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(me)+", string expected");if(typeof he=="function"&&(fe=he,he=null),he=ut({},Ae.defaults,he||{}),rt(he),fe){var ee=he.highlight,te;try{te=Pe.lex(me,he)}catch(Se){return fe(Se)}var ae=function(Oe){var nt;if(!Oe)try{nt=tt.parse(te,he)}catch(gt){Oe=gt}return he.highlight=ee,Oe?fe(Oe):fe(null,nt)};if(!ee||ee.length<3)return ae();if(delete he.highlight,!te.length)return ae();var ue=0;Ae.walkTokens(te,function(Se){Se.type==="code"&&(ue++,setTimeout(function(){ee(Se.text,Se.lang,function(Oe,nt){if(Oe)return ae(Oe);nt!=null&&nt!==Se.text&&(Se.text=nt,Se.escaped=!0),ue--,ue===0&&ae()})},0))}),ue===0&&ae();return}try{var ge=Pe.lex(me,he);return he.walkTokens&&Ae.walkTokens(ge,he.walkTokens),tt.parse(ge,he)}catch(Se){if(Se.message+=`
|
|
Please report this to https://github.com/markedjs/marked.`,he.silent)return"<p>An error occurred:</p><pre>"+it(Se.message+"",!0)+"</pre>";throw Se}}Ae.options=Ae.setOptions=function(me){return ut(Ae.defaults,me),lt(Ae.defaults),Ae},Ae.getDefaults=we,Ae.defaults=et,Ae.use=function(me){var he=ut({},me);if(me.renderer&&function(){var ee=Ae.defaults.renderer||new Ne,te=function(ge){var Se=ee[ge];ee[ge]=function(){for(var Oe=arguments.length,nt=new Array(Oe),gt=0;gt<Oe;gt++)nt[gt]=arguments[gt];var ct=me.renderer[ge].apply(ee,nt);return ct===!1&&(ct=Se.apply(ee,nt)),ct}};for(var ae in me.renderer)te(ae);he.renderer=ee}(),me.tokenizer&&function(){var ee=Ae.defaults.tokenizer||new xe,te=function(ge){var Se=ee[ge];ee[ge]=function(){for(var Oe=arguments.length,nt=new Array(Oe),gt=0;gt<Oe;gt++)nt[gt]=arguments[gt];var ct=me.tokenizer[ge].apply(ee,nt);return ct===!1&&(ct=Se.apply(ee,nt)),ct}};for(var ae in me.tokenizer)te(ae);he.tokenizer=ee}(),me.walkTokens){var fe=Ae.defaults.walkTokens;he.walkTokens=function(ee){me.walkTokens(ee),fe&&fe(ee)}}Ae.setOptions(he)},Ae.walkTokens=function(me,he){for(var fe=N(me),ee;!(ee=fe()).done;){var te=ee.value;he(te);switch(te.type){case"table":{for(var ae=N(te.tokens.header),ue;!(ue=ae()).done;){var ge=ue.value;Ae.walkTokens(ge,he)}for(var Se=N(te.tokens.cells),Oe;!(Oe=Se()).done;)for(var nt=Oe.value,gt=N(nt),ct;!(ct=gt()).done;){var kt=ct.value;Ae.walkTokens(kt,he)}break}case"list":{Ae.walkTokens(te.items,he);break}default:te.tokens&&Ae.walkTokens(te.tokens,he)}}},Ae.Parser=tt,Ae.parser=tt.parse,Ae.Renderer=Ne,Ae.TextRenderer=Me,Ae.Lexer=Pe,Ae.lexer=Pe.lex,Ae.Tokenizer=xe,Ae.Slugger=at,Ae.parse=Ae;var Ue=Ae;return Ue})},ELLl:function(wt,ht,re){(function(ne){ne(re("VrN/"))})(function(ne){var $={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},D=ne.Pos;ne.defineOption("autoCloseBrackets",!1,function(w,S,h){h&&h!=ne.Init&&(w.removeKeyMap(N),w.state.closeBrackets=null),S&&(I(X(S,"pairs")),w.state.closeBrackets=S,w.addKeyMap(N))});function X(w,S){return S=="pairs"&&typeof w=="string"?w:typeof w=="object"&&w[S]!=null?w[S]:$[S]}var N={Backspace:P,Enter:M};function I(w){for(var S=0;S<w.length;S++){var h=w.charAt(S),o="'"+h+"'";N[o]||(N[o]=z(h))}}I($.pairs+"`");function z(w){return function(S){return A(S,w)}}function U(w){var S=w.state.closeBrackets;if(!S||S.override)return S;var h=w.getModeAt(w.getCursor());return h.closeBrackets||S}function P(w){var S=U(w);if(!S||w.getOption("disableInput"))return ne.Pass;for(var h=X(S,"pairs"),o=w.listSelections(),u=0;u<o.length;u++){if(!o[u].empty())return ne.Pass;var d=R(w,o[u].head);if(!d||h.indexOf(d)%2!=0)return ne.Pass}for(var u=o.length-1;u>=0;u--){var T=o[u].head;w.replaceRange("",D(T.line,T.ch-1),D(T.line,T.ch+1),"+delete")}}function M(w){var S=U(w),h=S&&X(S,"explode");if(!h||w.getOption("disableInput"))return ne.Pass;for(var o=w.listSelections(),u=0;u<o.length;u++){if(!o[u].empty())return ne.Pass;var d=R(w,o[u].head);if(!d||h.indexOf(d)%2!=0)return ne.Pass}w.operation(function(){var T=w.lineSeparator()||`
|
|
`;w.replaceSelection(T+T,null),w.execCommand("goCharLeft"),o=w.listSelections();for(var y=0;y<o.length;y++){var f=o[y].head.line;w.indentLine(f,null,!0),w.indentLine(f+1,null,!0)}})}function b(w){var S=ne.cmpPos(w.anchor,w.head)>0;return{anchor:new D(w.anchor.line,w.anchor.ch+(S?-1:1)),head:new D(w.head.line,w.head.ch+(S?1:-1))}}function A(w,S){var h=U(w);if(!h||w.getOption("disableInput"))return ne.Pass;var o=X(h,"pairs"),u=o.indexOf(S);if(u==-1)return ne.Pass;for(var d=X(h,"closeBefore"),T=X(h,"triples"),y=o.charAt(u+1)==S,f=w.listSelections(),k=u%2==0,x,p=0;p<f.length;p++){var c=f[p],s=c.head,a,v=w.getRange(s,D(s.line,s.ch+1));if(k&&!c.empty())a="surround";else if((y||!k)&&v==S)y&&L(w,s)?a="both":T.indexOf(S)>=0&&w.getRange(s,D(s.line,s.ch+3))==S+S+S?a="skipThree":a="skip";else if(y&&s.ch>1&&T.indexOf(S)>=0&&w.getRange(D(s.line,s.ch-2),s)==S+S){if(s.ch>2&&/\bstring/.test(w.getTokenTypeAt(D(s.line,s.ch-2))))return ne.Pass;a="addFour"}else if(y){var g=s.ch==0?" ":w.getRange(D(s.line,s.ch-1),s);if(!ne.isWordChar(v)&&g!=S&&!ne.isWordChar(g))a="both";else return ne.Pass}else if(k&&(v.length===0||/\s/.test(v)||d.indexOf(v)>-1))a="both";else return ne.Pass;if(!x)x=a;else if(x!=a)return ne.Pass}var E=u%2?o.charAt(u-1):S,_=u%2?S:o.charAt(u+1);w.operation(function(){if(x=="skip")w.execCommand("goCharRight");else if(x=="skipThree")for(var H=0;H<3;H++)w.execCommand("goCharRight");else if(x=="surround"){for(var V=w.getSelections(),H=0;H<V.length;H++)V[H]=E+V[H]+_;w.replaceSelections(V,"around"),V=w.listSelections().slice();for(var H=0;H<V.length;H++)V[H]=b(V[H]);w.setSelections(V)}else x=="both"?(w.replaceSelection(E+_,null),w.triggerElectric(E+_),w.execCommand("goCharLeft")):x=="addFour"&&(w.replaceSelection(E+E+E+E,"before"),w.execCommand("goCharRight"))})}function R(w,S){var h=w.getRange(D(S.line,S.ch-1),D(S.line,S.ch+1));return h.length==2?h:null}function L(w,S){var h=w.getTokenAt(D(S.line,S.ch+1));return/\bstring/.test(h.type)&&h.start==S.ch&&(S.ch==0||!/\bstring/.test(w.getTokenTypeAt(S)))}})},FOrL:function(wt,ht,re){wt.exports=re.p+"static/nodata.a6b3f948.png"},Gytx:function(wt,ht){wt.exports=function(ne,$,D,X){var N=D?D.call(X,ne,$):void 0;if(N!==void 0)return!!N;if(ne===$)return!0;if(typeof ne!="object"||!ne||typeof $!="object"||!$)return!1;var I=Object.keys(ne),z=Object.keys($);if(I.length!==z.length)return!1;for(var U=Object.prototype.hasOwnProperty.bind($),P=0;P<I.length;P++){var M=I[P];if(!U(M))return!1;var b=ne[M],A=$[M];if(N=D?D.call(X,b,A,M):void 0,N===!1||N===void 0&&b!==A)return!1}return!0}},HmJG:function(wt,ht,re){},LdHM:function(wt,ht,re){"use strict";re.d(ht,"b",function(){return d}),re.d(ht,"a",function(){return y});var ne=re("1OyB"),$=re("vuIU"),D=re("Ji7U"),X=re("LK+K"),N=re("cDcd"),I=re("rePB"),z=re("Ff2n"),U=re("ODXe"),P=re("4IlW"),M=re("bX4T"),b=re("YrtM"),A=re("TSYQ"),R=re.n(A),L=re("+nKL"),w=re("8OUc"),S=function(q,ie){var ce=q.prefixCls,ve=q.id,ke=q.flattenOptions,xe=q.childrenAsData,Ce=q.values,Te=q.searchValue,Ee=q.multiple,pe=q.defaultActiveFirstOption,se=q.height,Le=q.itemHeight,Xe=q.notFoundContent,Ge=q.open,Ke=q.menuItemSelectedIcon,Ve=q.virtual,De=q.onSelect,Pe=q.onToggleOpen,He=q.onActiveValue,$e=q.onScroll,Fe=q.onMouseEnter,Ne="".concat(ce,"-item"),Me=Object(b.a)(function(){return ke},[Ge,ke],function(Ue,me){return me[0]&&Ue[1]!==me[1]}),at=N.useRef(null),qe=function(me){me.preventDefault()},Qe=function(me){at.current&&at.current.scrollTo({index:me})},tt=function(me){for(var he=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,fe=Me.length,ee=0;ee<fe;ee+=1){var te=(me+ee*he+fe)%fe,ae=Me[te],ue=ae.group,ge=ae.data;if(!ue&&!ge.disabled)return te}return-1},ut=N.useState(function(){return tt(0)}),rt=Object(U.a)(ut,2),it=rt[0],we=rt[1],lt=function(me){we(me);var he=Me[me];if(!he){He(null,-1);return}He(he.data.value,me)};N.useEffect(function(){lt(pe!==!1?tt(0):-1)},[Me.length,Te]),N.useEffect(function(){var Ue=setTimeout(function(){if(!Ee&&Ge&&Ce.size===1){var me=Array.from(Ce)[0],he=Me.findIndex(function(fe){var ee=fe.data;return ee.value===me});lt(he),Qe(he)}});return function(){return clearTimeout(Ue)}},[Ge]);var et=function(me){me!==void 0&&De(me,{selected:!Ce.has(me)}),Ee||Pe(!1)};if(N.useImperativeHandle(ie,function(){return{onKeyDown:function(me){var he=me.which;switch(he){case P.a.UP:case P.a.DOWN:{var fe=0;if(he===P.a.UP?fe=-1:he===P.a.DOWN&&(fe=1),fe!==0){var ee=tt(it+fe,fe);Qe(ee),lt(ee)}break}case P.a.ENTER:{var te=Me[it];te&&!te.data.disabled?et(te.data.value):et(void 0),Ge&&me.preventDefault();break}case P.a.ESC:Pe(!1)}},onKeyUp:function(){},scrollTo:function(me){Qe(me)}}}),Me.length===0)return N.createElement("div",{role:"listbox",id:"".concat(ve,"_list"),className:"".concat(Ne,"-empty"),onMouseDown:qe},Xe);function Ae(Ue){var me=Me[Ue];if(!me)return null;var he=me.data||{},fe=he.value,ee=he.label,te=he.children,ae=Object(M.a)(he,!0),ue=xe?te:ee;return me?N.createElement("div",Object.assign({"aria-label":typeof ue=="string"?ue:null},ae,{key:Ue,role:"option",id:"".concat(ve,"_list_").concat(Ue),"aria-selected":Ce.has(fe)}),fe):null}return N.createElement(N.Fragment,null,N.createElement("div",{role:"listbox",id:"".concat(ve,"_list"),style:{height:0,width:0,overflow:"hidden"}},Ae(it-1),Ae(it),Ae(it+1)),N.createElement(L.a,{itemKey:"key",ref:at,data:Me,height:se,itemHeight:Le,fullHeight:!1,onMouseDown:qe,onScroll:$e,virtual:Ve,onMouseEnter:Fe},function(Ue,me){var he,fe=Ue.group,ee=Ue.groupOption,te=Ue.data,ae=te.label,ue=te.key;if(fe)return N.createElement("div",{className:R()(Ne,"".concat(Ne,"-group"))},ae!==void 0?ae:ue);var ge=te.disabled,Se=te.value,Oe=te.title,nt=te.children,gt=te.style,ct=te.className,kt=Object(z.a)(te,["disabled","value","title","children","style","className"]),ot=Ce.has(Se),We="".concat(Ne,"-option"),yt=R()(Ne,We,ct,(he={},Object(I.a)(he,"".concat(We,"-grouped"),ee),Object(I.a)(he,"".concat(We,"-active"),it===me&&!ge),Object(I.a)(he,"".concat(We,"-disabled"),ge),Object(I.a)(he,"".concat(We,"-selected"),ot),he)),ft=xe?nt:ae,_t=!Ke||typeof Ke=="function"||ot;return N.createElement("div",Object.assign({},kt,{"aria-selected":ot,className:yt,title:Oe,onMouseMove:function(){if(it===me||ge)return;lt(me)},onClick:function(){ge||et(Se)},style:gt}),N.createElement("div",{className:"".concat(We,"-content")},ft||Se),N.isValidElement(Ke)||ot,_t&&N.createElement(w.a,{className:"".concat(Ne,"-option-state"),customizeIcon:Ke,customizeIconProps:{isSelected:ot}},ot?"\u2713":null))}))},h=N.forwardRef(S);h.displayName="OptionList";var o=h,u=function(){return null};u.isSelectOption=!0;var d=u,T=function(){return null};T.isSelectOptGroup=!0;var y=T,f=re("VTBJ"),k=re("Zm9Q");function x(j){var q=j.key,ie=j.props,ce=ie.children,ve=ie.value,ke=Object(z.a)(ie,["children","value"]);return Object(f.a)({key:q,value:ve!==void 0?ve:q,children:ce},ke)}function p(j){var q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(k.a)(j).map(function(ie,ce){if(!N.isValidElement(ie)||!ie.type)return null;var ve=ie.type.isSelectOptGroup,ke=ie.key,xe=ie.props,Ce=xe.children,Te=Object(z.a)(xe,["children"]);return q||!ve?x(ie):Object(f.a)(Object(f.a)({key:"__RC_SELECT_GRP__".concat(ke===null?ce:ke,"__"),label:ke},Te),{},{options:p(Ce)})}).filter(function(ie){return ie})}var c=re("2Qr1"),s=re("qNPg"),a=re("U8pU"),v=re("Kwbf"),g=re("WKfj");function E(j){var q=j.mode,ie=j.options,ce=j.children,ve=j.backfill,ke=j.allowClear,xe=j.placeholder,Ce=j.getInputElement,Te=j.showSearch,Ee=j.onSearch,pe=j.defaultOpen,se=j.autoFocus,Le=j.labelInValue,Xe=j.value,Ge=j.inputValue,Ke=j.optionLabelProp,Ve=q==="multiple"||q==="tags",De=Te!==void 0?Te:Ve||q==="combobox",Pe=ie||p(ce);if(Object(v.a)(q!=="tags"||Pe.every(function(Ne){return!Ne.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),q==="tags"||q==="combobox"){var He=Pe.some(function(Ne){return Ne.options?Ne.options.some(function(Me){return typeof("value"in Me?Me.value:Me.key)=="number"}):typeof("value"in Ne?Ne.value:Ne.key)=="number"});Object(v.a)(!He,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(v.a)(q!=="combobox"||!Ke,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(v.a)(q==="combobox"||!ve,"`backfill` only works with `combobox` mode."),Object(v.a)(q==="combobox"||!Ce,"`getInputElement` only work with `combobox` mode."),Object(v.b)(q!=="combobox"||!Ce||!ke||!xe,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),Ee&&!De&&q!=="combobox"&&q!=="tags"&&Object(v.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(v.b)(!pe||se,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),Xe!=null){var $e=Object(g.d)(Xe);Object(v.a)(!Le||$e.every(function(Ne){return Object(a.a)(Ne)==="object"&&("key"in Ne||"value"in Ne)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(v.a)(!Ve||Array.isArray(Xe),"`value` should be array when `mode` is `multiple` or `tags`")}if(ce){var Fe=null;Object(k.a)(ce).some(function(Ne){if(!N.isValidElement(Ne)||!Ne.type)return!1;var Me=Ne.type;if(Me.isSelectOption)return!1;if(Me.isSelectOptGroup){var at=Object(k.a)(Ne.props.children).every(function(qe){return!N.isValidElement(qe)||!Ne.type||qe.type.isSelectOption?!0:(Fe=qe.type,!1)});return!at}return Fe=Me,!0}),Fe&&Object(v.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(Fe.displayName||Fe.name||Fe,"`.")),Object(v.a)(Ge===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var _=E,H=Object(s.a)({prefixCls:"rc-select",components:{optionList:o},convertChildrenToData:p,flattenOptions:c.d,getLabeledValue:c.e,filterOptions:c.b,isValueDisabled:c.g,findValueOption:c.c,warningProps:_,fillOptionsWithMissingValue:c.a}),V=function(j){Object(D.a)(ie,j);var q=Object(X.a)(ie);function ie(){var ce;return Object(ne.a)(this,ie),ce=q.apply(this,arguments),ce.selectRef=N.createRef(),ce.focus=function(){ce.selectRef.current.focus()},ce.blur=function(){ce.selectRef.current.blur()},ce}return Object($.a)(ie,[{key:"render",value:function(){return N.createElement(H,Object.assign({ref:this.selectRef},this.props))}}]),ie}(N.Component);V.Option=d,V.OptGroup=y;var Z=V,G=ht.c=Z},M8RZ:function(wt,ht,re){"use strict";re.d(ht,"a",function(){return P});var ne=re("fWQN"),$=re("mtLc"),D=re("yKVA"),X=re("879j"),N=re("cDcd"),I=re.n(N),z=re("faye"),U=re.n(z),P=function(M){Object(D.a)(A,M);var b=Object(X.a)(A);function A(R){var L;Object(ne.a)(this,A),L=b.call(this,R);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(z.createPortal)(L,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),A}(I.a.Component)},OLES:function(wt,ht,re){"use strict";var ne=re("U8pU"),$=re("VTBJ"),D=re("Ff2n"),X=re("cDcd"),N=re("uciX"),I=re("7ixt"),z=function(R){var L=R.overlay,w=R.prefixCls,S=R.id,h=R.overlayInnerStyle;return X.createElement("div",{className:"".concat(w,"-inner"),id:S,role:"tooltip",style:h},typeof L=="function"?L():L)},U=z,P=function(R,L){var w=R.overlayClassName,S=R.trigger,h=S===void 0?["hover"]:S,o=R.mouseEnterDelay,u=o===void 0?0:o,d=R.mouseLeaveDelay,T=d===void 0?.1:d,y=R.overlayStyle,f=R.prefixCls,k=f===void 0?"rc-tooltip":f,x=R.children,p=R.onVisibleChange,c=R.afterVisibleChange,s=R.transitionName,a=R.animation,v=R.placement,g=v===void 0?"right":v,E=R.align,_=E===void 0?{}:E,H=R.destroyTooltipOnHide,V=H===void 0?!1:H,Z=R.defaultVisible,G=R.getTooltipContainer,j=R.overlayInnerStyle,q=Object(D.a)(R,["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer","overlayInnerStyle"]),ie=Object(X.useRef)(null);Object(X.useImperativeHandle)(L,function(){return ie.current});var ce=Object($.a)({},q);"visible"in R&&(ce.popupVisible=R.visible);var ve=function(){var Ee=R.arrowContent,pe=Ee===void 0?null:Ee,se=R.overlay,Le=R.id;return[X.createElement("div",{className:"".concat(k,"-arrow"),key:"arrow"},pe),X.createElement(U,{key:"content",prefixCls:k,id:Le,overlay:se,overlayInnerStyle:j})]},ke=!1,xe=!1;if(typeof V=="boolean")ke=V;else if(V&&Object(ne.a)(V)==="object"){var Ce=V.keepParent;ke=Ce===!0,xe=Ce===!1}return X.createElement(N.a,Object.assign({popupClassName:w,prefixCls:k,popup:ve,action:h,builtinPlacements:I.a,popupPlacement:g,ref:ie,popupAlign:_,getPopupContainer:G,onPopupVisibleChange:p,afterPopupVisibleChange:c,popupTransitionName:s,popupAnimation:a,defaultPopupVisible:Z,destroyPopupOnHide:ke,autoDestroy:xe,mouseLeaveDelay:T,popupStyle:y,mouseEnterDelay:u},ce),x)},M=Object(X.forwardRef)(P),b=ht.a=M},Ot1p:function(wt,ht,re){"use strict";var ne=re("2qtc"),$=re("kLXV"),D=re("rAM+"),X=re("miYZ"),N=re("tsqr"),I=re("9og8"),z=re("tJVT"),U=re("jrin"),P=re("WmNS"),M=re.n(P),b=re("cDcd"),A=re.n(b),R=re("VrN/"),L=re.n(R),w=re("bdgK"),S=re("p77/"),h=re("Bd2K"),o=re("ELLl"),u=re("19Vz"),d=re("lZu9"),T=re("+NIl"),y=re("kSUc"),f=re("9Bee"),k=function(ge){var Se=ge.value,Oe=Se===void 0?"":Se,nt=ge.className,gt=ge.showTextOnly,ct=ge.showLines,kt=ge.style,ot=kt===void 0?{}:kt,We=Object(b.useMemo)(function(){return""},[Oe]);return A.a.createElement(A.a.Fragment,null,A.a.createElement("div",{dangerouslySetInnerHTML:{__html:We}}))},x=re("0Owb"),p=re("dejd"),c=re("C+DQ"),s=re("1vsH"),a=re("m3rI"),v=[{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 g(ge){var Se=ge.onActionCallback,Oe=ge.title,nt=ge.icon,gt=ge.actionName,ct=ge.className,kt=ct===void 0?"":ct,ot=ge.children;function We(){Se(gt)}return A.a.createElement("a",{title:Oe,className:kt,onClick:We},A.a.createElement("i",{className:"md-iconfont ".concat(nt)}),ot)}var E=function(ge){var Se=ge.watch,Oe=ge.showNullButton,nt=ge.onActionCallback,gt=ge.fullScreen,ct=ge.insertTemp,kt=ge.hidetoolBar,ot=ge.uuid,We=ge.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(s.G)("_educoder_session_login"),"&_educoder_session=").concat(Object(s.G)("_educoder_session"),"&key=").concat(ot,"&api=").concat(encodeURIComponent(a.a.PROXY_SERVER)));var yt=[].concat(v,[{title:"".concat(Se?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(Se?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return A.a.createElement("ul",{className:"markdown-toolbar-container"},!kt&&yt.map(function(ft,_t){return A.a.createElement("li",{key:_t},ft.actionName?A.a.createElement(g,Object(x.a)({},ft,{onActionCallback:nt})):A.a.createElement("span",{className:"v-line"}))}),Oe?A.a.createElement("li",null,A.a.createElement(g,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:nt},A.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,ct&&A.a.createElement("li",null,A.a.createElement(g,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(ct),onActionCallback:nt},A.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),A.a.createElement("li",{className:"btn-full-screen"},A.a.createElement(g,{icon:"".concat(gt?"icon-shrink":"icon-enlarge"),title:gt?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:nt})))},_=re("M8RZ"),H=re("+L6B"),V=re("2/Rp"),Z=re("y8nQ"),G=re("Vl3Y"),j=re("5NDa"),q=re("5rEg"),ie={labelCol:{span:4},wrapperCol:{span:20}},ce=function(ge){var Se=ge.callback,Oe=ge.onCancel;function nt(gt){Se(gt)}return A.a.createElement(G.a,Object(x.a)({},ie,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:nt}),A.a.createElement(G.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},A.a.createElement(q.a,null)),A.a.createElement(G.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},A.a.createElement(q.a,null)),A.a.createElement("div",{className:"flex-container flex-end"},A.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),A.a.createElement(V.a,{type:"ghost",onClick:Oe},"\u53D6\u6D88")))},ve=re("7ahc"),ke=re("HmJG"),xe=re("BjJ7"),Ce=G.a.useForm,Te={width:280,marginRight:10},Ee={labelCol:{span:5},wrapperCol:{span:19}},pe=function(ge){var Se=ge.callback,Oe=ge.onCancel,nt=Ce(),gt=Object(z.a)(nt,1),ct=gt[0];function kt(yt){Se(yt)}function ot(yt,ft){if(yt.status===-1){N.b.error(yt.message);return}ct.setFieldsValue({src:"/api/attachments/".concat(yt.id),type:ft.type})}function We(yt){var ft=yt.target.files[0];Le(ft,ot)}return A.a.createElement(G.a,Object(x.a)({form:ct},Ee,{className:"upload-image-panel",onFinish:kt}),A.a.createElement(G.a.Item,{label:"\u56FE\u7247\u5730\u5740",required:!0},A.a.createElement("div",{className:"flex-container"},A.a.createElement(G.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740"}]},A.a.createElement(q.a,{style:Te})),A.a.createElement(se,{onFileChange:We}))),A.a.createElement(G.a.Item,{label:"\u56FE\u7247\u63CF\u8FF0",name:"alt"},A.a.createElement(q.a,{style:{width:264}})),A.a.createElement(G.a.Item,{style:{textAlign:"right"}},A.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),A.a.createElement(V.a,{type:"ghost",onClick:Oe},"\u53D6\u6D88")))};function se(ge){var Se=ge.onFileChange;return A.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",A.a.createElement("input",{type:"file",onChange:Se}))}function Le(ge,Se){if(!ge)throw new String("\u6CA1\u6709\u6587\u4EF6");var Oe=new FormData;Oe.append("editormd-image-file",ge),Oe.append("file_param_name","editormd-image-file"),Oe.append("byxhr","true");var nt=new window.XMLHttpRequest;nt.withCredentials=!0,nt.addEventListener("load",function(gt){Se(JSON.parse(gt.target.responseText),ge)},!1),nt.addEventListener("error",function(gt){console.error(gt)},!1),nt.open("POST","".concat(xe.a,"/api/attachments.json")),nt.send(Oe)}var Xe=re("giR+"),Ge=re("fyUT"),Ke=re("7Kak"),Ve=re("9yH6"),De=Ve.a.Group,Pe={margin:"0 8px"},He=function(ge){var Se=ge.callback,Oe=ge.onCancel;function nt(gt){Se(gt)}return A.a.createElement(G.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:nt},A.a.createElement("div",{className:"flex-container",style:{alignItems:"baseline"}},A.a.createElement("span",{style:Pe},"\u5355\u5143\u683C\u6570\uFF1A"),A.a.createElement("span",{style:Pe},"\u884C\u6570"),A.a.createElement(G.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},A.a.createElement(Ge.a,null)),A.a.createElement("span",{style:Pe},"\u5217\u6570"),A.a.createElement(G.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},A.a.createElement(Ge.a,null))),A.a.createElement("div",{className:"flex-container",style:{marginTop:12,alignItems:"baseline"}},A.a.createElement("span",{style:Pe},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),A.a.createElement(G.a.Item,{name:"align"},A.a.createElement(De,null,A.a.createElement(Ve.a,{value:"default"},A.a.createElement("i",{className:"fa fa-align-justify"})),A.a.createElement(Ve.a,{value:"left"},A.a.createElement("i",{className:"fa fa-align-left"})),A.a.createElement(Ve.a,{value:"center"},A.a.createElement("i",{className:"fa fa-align-center"})),A.a.createElement(Ve.a,{value:"right"},A.a.createElement("i",{className:"fa fa-align-right"}))))),A.a.createElement("div",{className:"flex-container flex-end"},A.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),A.a.createElement(V.a,{type:"ghost",onClick:Oe},"\u53D6\u6D88")))},$e=re("ErOA"),Fe=re("7Cbv"),Ne="link",Me="upload-image",at="code-block",qe="add-table",Qe="------------",tt={default:Qe,left:":".concat(Qe),center:":".concat(Qe,":"),right:"".concat(Qe,":")},ut=re("9VGf"),rt,it;function we(){}var lt=0,et=1e4,Ae="\u2581",Ue=`
|
|
**\u6A21\u677F\u6807\u9898**
|
|
\u6A21\u677F\u6B63\u6587\u5185\u5BB9\uFF0C\u53EF\u8F93\u5165\u6587\u672C\u5185\u5BB9\u548C\u7C98\u8D34\u56FE\u7247\u7B49\u64CD\u4F5C`;function me(ge){return/^\d+$/.test(ge)?"".concat(ge,"px"):ge}var he=navigator.platform.toUpperCase().indexOf("MAC")>=0,fe=he?"Cmd":"Ctrl",ee=["pptm","pptx","ppt","pot","pps","ppa","potx","ppsx","ppam","pptm","potm","ppsm","doc","docx","dot","dotx","docm","dotm","xls","xlsx","csv","xlt","xla","xltx","xlsm","xltm","xlam","xlsb"],te=(rt={},Object(U.a)(rt,fe+"-B","bold"),Object(U.a)(rt,fe+"-I","italic"),rt),ae=(it={},Object(U.a)(it,Ne,"\u6DFB\u52A0\u94FE\u63A5"),Object(U.a)(it,at,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(U.a)(it,Me,"\u6DFB\u52A0\u6587\u4EF6"),Object(U.a)(it,qe,"\u6DFB\u52A0\u8868\u683C"),it),ue=ht.a=function(ge){var Se=ge.defaultValue,Oe=Se===void 0?"":Se,nt=ge.onChange,gt=ge.width,ct=gt===void 0?"100%":gt,kt=ge.height,ot=kt===void 0?400:kt,We=ge.miniToolbar,yt=We===void 0?!1:We,ft=ge.isFocus,_t=ft===void 0?!1:ft,xt=ge.watch,Dt=ge.insertTemp,Er=ge.mode,Hr=Er===void 0?"markdown":Er,bt=ge.id,Nr=bt===void 0?"markdown-editor-id":bt,hr=ge.showResizeBar,pr=hr===void 0?!1:hr,Br=ge.noStorage,ci=Br===void 0?!1:Br,qr=ge.showNullButton,Ut=qr===void 0?!1:qr,pt=ge.hidetoolBar,zr=pt===void 0?!1:pt,ei=ge.fullScreen,mr=ei===void 0?!1:ei,Pt=ge.onBlur,Ur=ge.onCMBeforeChange,Vr=ge.onFullScreen,fi=ge.className,je=fi===void 0?"":fi,Lt=ge.disablePaste,pi=Lt===void 0?!1:Lt,mi=ge.placeholder,gi=mi===void 0?"":mi,vi=ge.values,W=vi===void 0?"":vi,l=Object(b.useState)(null),m=Object(z.a)(l,2),O=m[0],J=m[1],F=Object(b.useState)(Oe),de=Object(z.a)(F,2),_e=de[0],Ye=de[1],mt=Object(b.useState)(xt),Ie=Object(z.a)(mt,2),St=Ie[0],Ft=Ie[1],Xt=Object(b.useState)(mr),Or=Object(z.a)(Xt,2),gr=Or[0],vr=Or[1],Xr=Object(b.useState)(""),_i=Object(z.a)(Xr,2),nr=_i[0],Fr=_i[1],oi=Object(b.useState)(0),si=Object(z.a)(oi,2),Pr=si[0],Oi=si[1],yi=Object(b.useState)(ot),Gi=Object(z.a)(yi,2),Ki=Gi[0],Yr=Gi[1],Gr=Object(b.useState)(!1),bi=Object(z.a)(Gr,2),dn=bi[0],xi=bi[1],Zt=Object(b.useRef)(Object(Fe.a)()),jt=Object(b.useRef)(!1),dr=Object(b.useRef)(),Mt=Object(b.useRef)(),qt=Object(b.useRef)(),zt=Object(b.useRef)(),ti=Object(b.useRef)(),ar=function(){var vt=Object(I.a)(M.a.mark(function At(){var Ct,Ot;return M.a.wrap(function(Kt){for(;;)switch(Kt.prev=Kt.next){case 0:return Kt.next=2,Object($e.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:Zt.current}});case 2:Ot=Kt.sent,Ot!=null&&(Ct=Ot.attachments)!==null&&Ct!==void 0&&Ct.length&&(console.log("cm:",O,Mt),Ot.attachments.map(function(Nt){Nt.content_type.indexOf("image")>-1?O.replaceSelection(".concat(Nt.content_type,")")):Nt.content_type.indexOf("video")>-1?O.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):Nt.content_type.indexOf("pdf")>-1?O.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Nt.id,"?type=").concat(Nt.content_type,'&disposition=inline" target="_blank">').concat(Nt.name,"</a>")):O.replaceSelection("[".concat(Nt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Nt.id,"?type=").concat(Nt.content_type,")"))}));case 4:case"end":return Kt.stop()}},At)}));return function(){return vt.apply(this,arguments)}}();Object(b.useEffect)(function(){Ye(W),O==null||O.setValue(W)},[W]),Object(b.useEffect)(function(){Vr==null||Vr(gr)},[gr]),Object(b.useEffect)(function(){if(Mt.current){var vt=L.a.fromTextArea(Mt.current,{mode:Hr,lineNumbers:!yt,lineWrapping:!0,value:Oe,autoCloseTags:!0,autoCloseBrackets:!0});_t&&vt.focus();function At(Ct,Ot){if(pi){Ot.preventDefault();return}var Bt=Ot.clipboardData;if(Bt){var Kt=Bt.types.toString(),Nt=Bt.items;if(Kt==="Files"||Bt.types.indexOf("Files")>-1){if(Ot.preventDefault(),Hr=="stex")return;try{var rr,wr=Nt[1];((rr=Nt[0])===null||rr===void 0?void 0:rr.kind)==="file"&&(wr=Nt[0]);var It=wr.getAsFile(),li=It.name.split(".").pop();Le(It,function(Wt){if(Wt.id){var Lr,yr,Kr;(It==null||((Lr=It.type)===null||Lr===void 0)?void 0:Lr.indexOf("image"))>-1?vt.replaceSelection(".concat(Wt.content_type,")")):(It==null||((yr=It.type)===null||yr===void 0)?void 0:yr.indexOf("video"))>-1?vt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,'"></video>')):(It==null||((Kr=It.type)===null||Kr===void 0)?void 0:Kr.indexOf("pdf"))>-1?vt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,"?type=").concat(It.type,'&disposition=inline" target="_blank">').concat(It.name,"</a>")):ee.includes(li)?vt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,'?type=office&disposition=inline" target="_blank">').concat(It.name,"</a>")):vt.replaceSelection("[".concat(It.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,"?type=").concat(Wt.content_type,")"))}else(Wt==null?void 0:Wt.status)===401&&(document.location.href="/user/login")})}catch(Wt){N.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return vt.on("paste",At),vt.on("dragleave",function(Ct,Ot){qt.current.classList.remove("mouse-hover-md")}),vt.on("dragover",function(Ct,Ot){qt.current.classList.add("mouse-hover-md")}),vt.on("drop",function(Ct,Ot){qt.current.classList.add("mouse-hover-md");var Bt;if(Bt=Ot.dataTransfer.files,Bt.length>0){Ot.preventDefault(),Ot.stopPropagation();for(var Kt=function(wr){var It=Bt[wr],li=It.name.split(".").pop();Le(It,function(Wt){if(Wt.id){var Lr,yr,Kr;(It==null||((Lr=It.type)===null||Lr===void 0)?void 0:Lr.indexOf("image"))>-1?vt.replaceSelection(".concat(Wt.content_type,")")):(It==null||((yr=It.type)===null||yr===void 0)?void 0:yr.indexOf("video"))>-1?vt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,'"></video>')):(It==null||((Kr=It.type)===null||Kr===void 0)?void 0:Kr.indexOf("pdf"))>-1?vt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,"?type=").concat(It.type,'&disposition=inline" target="_blank">').concat(It.name,"</a>")):ee.includes(li)?vt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,'?type=office&disposition=inline" target="_blank">').concat(It.name,"</a>")):vt.replaceSelection("[".concat(It.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,"?type=").concat(Wt.content_type,")"))}else(Wt==null?void 0:Wt.status)===401&&(document.location.href="/user/login")})},Nt=0;Nt<Bt.length;Nt++)Kt(Nt)}}),J(vt),function(){vt.off("paste",At)}}},[]);var Sr=Object(b.useCallback)(function(){if(qt.current)try{}catch(vt){console.log(vt,"---- to set md editor body height")}},[Ki,qt,gr]);Object(b.useEffect)(function(){function vt(){var Ct=new w.default(function(Ot){var Bt=Object(D.a)(Ot),Kt;try{for(Bt.s();!(Kt=Bt.n()).done;){var Nt=Kt.value;(Nt.target.offsetHeight>0||Nt.target.offsetWidth>0)&&(Sr(),O.setSize("100%","100%"),O.refresh())}}catch(rr){Bt.e(rr)}finally{Bt.f()}});return Ct.observe(Mt.current.parentElement),Ct}if(O){var At=vt();return function(){At.unobserve(Mt.current.parentElement)}}},[O,Sr]),Object(b.useEffect)(function(){if(O){for(var vt=[],At=function(){var Nt=Ot[Ct];Bt=Object(z.a)(Nt,2);var rr=Bt[0],wr=Bt[1],It=Object(U.a)({},rr,function(){Vi(wr)});vt.push(It),O.addKeyMap(It)},Ct=0,Ot=Object.entries(te);Ct<Ot.length;Ct++){var Bt;At()}return dr.current=setInterval(function(){jt.current&&ar()},4e3),function(){clearInterval(dr.current);var Kt=Object(D.a)(vt),Nt;try{for(Kt.s();!(Nt=Kt.n()).done;){var rr=Nt.value;O.removeKeyMap(rr)}}catch(wr){Kt.e(wr)}finally{Kt.f()}}}},[O]),Object(b.useEffect)(function(){mr!==gr&&vr(mr)},[mr]),Object(ut.a)(function(){if(!ci&&Pr>0){var vt=new Date().getTime(),At=window.sessionStorage.getItem(Nr);vt>=Pr+et&&(!At||At!==_e)&&(window.sessionStorage.setItem(Nr,_e),xi(!0))}},et),Object(b.useEffect)(function(){Ft(xt)},[O,xt]),Object(b.useEffect)(function(){O&&(_t&&O.focus())},[O,_t]),Object(b.useEffect)(function(){if(St&&O){var vt=O.getScrollerElement();function At(Ct){var Ot=Ct.target;if(ti.current){var Bt=Ot.scrollTop/Ot.scrollHeight;ti.current.scrollTop=ti.current.scrollHeight*Bt}}return vt.addEventListener("scroll",At),function(){vt.removeEventListener("scroll",At)}}},[O,St]),Object(b.useEffect)(function(){if(O&&Ur){function vt(At,Ct){Ur(At,Ct)}return O.on("beforeChange",vt),function(){O.off("beforeChange",vt)}}},[O,Ur]),Object(b.useEffect)(function(){if(O&&Pt){function vt(){Pt(O.getValue())}return O.on("blur",vt),function(){O.off("blur",vt)}}},[O,Pt]),Object(b.useEffect)(function(){if(O){function vt(At){var Ct=At.getValue();Ye(Ct),Oi(new Date().getTime()),At.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),nt&&nt(Ct)}return O.on("change",vt),function(){O.off("change",vt)}}},[O,nt]),Object(b.useEffect)(function(){O&&(Oe==null?(O.setValue(""),Ye("")):Oe!==O.getValue()&&(O.setValue(Oe),Ye(Oe),O.setCursor(O.lineCount(),0)))},[O,Oe]);var Vi=Object(b.useCallback)(function(vt){var At=O.getCursor(),Ct=O.getSelection(),Ot=Ct.split(`
|
|
`);switch(vt){case"bold":return O.replaceSelection("**"+Ct+"**"),Ct===""&&O.setCursor(At.line,At.ch+2),O.focus();case"italic":return O.replaceSelection("*"+Ct+"*"),Ct===""&&O.setCursor(At.line,At.ch+1),O.focus();case"code":return O.replaceSelection("`"+Ct+"`"),Ct===""&&O.setCursor(At.line,At.ch+1),O.focus();case"inline-latex":return O.replaceSelection("`$$"+Ct+"$$`"),Ct===""&&O.setCursor(At.line,At.ch+3),O.focus();case"latex":return O.replaceSelection("```latex\n"+Ct+"\n```"),O.setCursor(At.line+1,Ct.length+1),O.focus();case"line-break":return O.replaceSelection(`<br/>
|
|
`),O.focus();case"list-ul":return Ct===""?O.replaceSelection("- "+Ct):O.replaceSelection(Ot.map(function(Bt){return Bt===""?"":"- ".concat(Bt)}).join(`
|
|
`)),O.focus();case"list-ol":return Ct===""?O.replaceSelection("1. "+Ct):O.replaceSelection(Ot.map(function(Bt,Kt){return Bt===""?"":"".concat(Kt+1,". ").concat(Bt)}).join(`
|
|
`)),O.focus();case"add-null-ch":return Ct===""&&O.setCursor(At.line,At.ch+1),O.replaceSelection(Ae),O.focus();case"inster-template-1":return Ct===""&&O.setCursor(At.line,At.ch),O.replaceSelection(Ue),O.focus();case"eraser":return O.setValue(""),O.focus();case"trigger-watch":return Ft(!St),O.focus();case"trigger-full-screen":return vr(!gr),O.focus();case Ne:Fr(Ne);return;case at:Fr(at);return;case Me:Fr(Me);return;case qe:Fr(qe);return;default:throw new Error}},[O,St,gr]),Ei=Object(b.useCallback)(function(vt){Fr("");switch(nr){case Ne:var At=vt.title,Ct=vt.link;return O.replaceSelection("[".concat(At,"](").concat(Ct,")")),O.focus();case at:var Ot=vt.language,Bt=vt.content;return O.replaceSelection(["```"+Ot,Bt,"```"].join(`
|
|
`)),O.focus();case Me:var Kt=vt.src,Nt=vt.alt;return Nt?O.replaceSelection(".concat(Kt,' "').concat(Nt,'" )')):O.replaceSelection("")),O.focus();case qe:for(var rr=vt.row,wr=vt.col,It=vt.align,li=`
|
|
`,Wt=0;Wt<rr;Wt++){for(var Lr=[],yr=[],Kr=0;Kr<wr;Kr++)Wt===1&&yr.push(tt[It]),Lr.push(" ");Wt===1&&(li+="| ".concat(yr.join(" | "),` |
|
|
`)),li+="| ".concat(Lr.join(wr===1?"":" | "),` |
|
|
`)}return O.replaceSelection(li+`
|
|
`),O.focus();default:throw new Error}},[O,nr]),cn=Object(b.useMemo)(function(){switch(nr){case Ne:return A.a.createElement(ce,{callback:Ei,onCancel:Si});case at:return A.a.createElement(ve.b,{callback:Ei,onCancel:Si});case Me:return A.a.createElement(pe,{callback:Ei,onCancel:Si});case qe:return A.a.createElement(He,{callback:Ei,onCancel:Si});default:return null}},[nr]);function Si(){Fr("")}Object(b.useEffect)(function(){if(zt.current){var vt=zt.current,At=!1,Ct=0;function Ot(Nt){At=!0,Ct=Nt.pageY}function Bt(){At=!1}function Kt(Nt){if(At){var rr=Nt.pageY-Ct;rr<0&&(rr=0),rr>300&&(rr=300);var wr=ot+rr+"px";Yr(wr)}}return vt.addEventListener("mousedown",Ot),document.addEventListener("mousemove",Kt),document.addEventListener("mouseup",Bt),function(){vt.removeEventListener("mousedown",Ot),document.removeEventListener("mousemove",Kt),document.removeEventListener("mouseup",Bt)}}},[O,zt]),Object(b.useEffect)(function(){Yr(ot)},[ot]);var ri=me(ct),fn=me(Ki),$r={width:ri,height:fn},pn=Object(b.useMemo)(function(){if(Pr){var vt=new Date(Pr),At=vt.getHours(),Ct=vt.getMinutes(),Ot=vt.getSeconds();return At=At<10?"0"+At:At,Ct=Ct<10?"0"+Ct:Ct,Ot=Ot<10?"0"+Ot:Ot,"".concat(At,":").concat(Ct,":").concat(Ot)}return 0},[Pr]);function jn(){window.sessionStorage.removeItem(Nr),xi(!1),Oi(0)}function Pi(){xi(!1),Oi(0),O.setValue(window.sessionStorage.getItem(Nr))}function ua(vt,At){var Ct=O.getValue();Ct=Ct.replace(vt,At),Ye(Ct),O==null||O.setValue(Ct)}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(je," ").concat(St?"on-preview":""," ").concat(yt?"mini":""," ").concat(gr?"full-screen":""),style:$r},A.a.createElement(E,{insertTemp:Dt,watch:St,fullScreen:gr,showNullButton:Ut,onActionCallback:Vi,hidetoolBar:zr,uuid:Zt.current,setOpenPhones:function(){jt.current=!0}}),A.a.createElement("div",{className:"markdown-editor-body"},A.a.createElement("div",{className:"codemirror-container"},A.a.createElement("textarea",{ref:Mt,placeholder:gi})),St?A.a.createElement("div",{ref:ti,className:"preview-container"},Hr==="stex"&&A.a.createElement(k,{value:_e}),Hr!=="stex"&&A.a.createElement(f.a,{edit:!0,value:_e,replaces:ua})):null))),pr?A.a.createElement("a",{ref:zt,className:"editor-resize"}):null,A.a.createElement(_.a,null,ae[nr]?A.a.createElement($.a,{centered:!0,title:ae[nr],visible:!0,onCancel:Si,footer:null,className:"markdown-popup-form"},cn):null))}},SJMd:function(wt,ht){/**
|
|
* @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,$,D=!1,X,N;window.PR_SHOULD_USE_CONTINUATION=!0;var I,z;(function(){var U=window,P=["break,continue,do,else,for,if,return,while"],M=[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=[M,"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"],R=[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",S=[b,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],h="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",o=[P,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],u=[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"],d=[P,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],T=[A,L,R,S,h,o,u,d],y=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,f="str",k="kwd",x="com",p="typ",c="lit",s="pun",a="pln",v="tag",g="dec",E="src",_="atn",H="atv",V="nocode",Z="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function G(De){for(var Pe=0,He=!1,$e=!1,Fe=0,Ne=De.length;Fe<Ne;++Fe){var Me=De[Fe];if(Me.ignoreCase)$e=!0;else if(/[a-z]/i.test(Me.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){He=!0,$e=!1;break}}var at={b:8,t:9,n:10,v:11,f:12,r:13};function qe(it){var we=it.charCodeAt(0);if(we!==92)return we;var lt=it.charAt(1);return we=at[lt],we||("0"<=lt&<<="7"?parseInt(it.substring(1),8):lt==="u"||lt==="x"?parseInt(it.substring(2),16):it.charCodeAt(1))}function Qe(it){if(it<32)return(it<16?"\\x0":"\\x")+it.toString(16);var we=String.fromCharCode(it);return we==="\\"||we==="-"||we==="]"||we==="^"?"\\"+we:we}function tt(it){var we=it.substring(1,it.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=[],et=we[0]==="^",Ae=["["];et&&Ae.push("^");for(var Ue=et?1:0,me=we.length;Ue<me;++Ue){var he=we[Ue];if(/\\[bdsw]/i.test(he))Ae.push(he);else{var fe=qe(he),ee;Ue+2<me&&we[Ue+1]==="-"?(ee=qe(we[Ue+2]),Ue+=2):ee=fe,lt.push([fe,ee]),ee<65||fe>122||(ee<65||fe>90||lt.push([Math.max(65,fe)|32,Math.min(ee,90)|32]),ee<97||fe>122||lt.push([Math.max(97,fe)&~32,Math.min(ee,122)&~32]))}}lt.sort(function(ge,Se){return ge[0]-Se[0]||Se[1]-ge[1]});for(var te=[],ae=[],Ue=0;Ue<lt.length;++Ue){var ue=lt[Ue];ue[0]<=ae[1]+1?ae[1]=Math.max(ae[1],ue[1]):te.push(ae=ue)}for(var Ue=0;Ue<te.length;++Ue){var ue=te[Ue];Ae.push(Qe(ue[0])),ue[1]>ue[0]&&(ue[1]+1>ue[0]&&Ae.push("-"),Ae.push(Qe(ue[1])))}return Ae.push("]"),Ae.join("")}function ut(it){for(var we=it.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),lt=we.length,et=[],Ae=0,Ue=0;Ae<lt;++Ae){var me=we[Ae];if(me==="(")++Ue;else if(me.charAt(0)==="\\"){var he=+me.substring(1);he&&(he<=Ue?et[he]=-1:we[Ae]=Qe(he))}}for(var Ae=1;Ae<et.length;++Ae)et[Ae]===-1&&(et[Ae]=++Pe);for(var Ae=0,Ue=0;Ae<lt;++Ae){var me=we[Ae];if(me==="(")++Ue,et[Ue]||(we[Ae]="(?:");else if(me.charAt(0)==="\\"){var he=+me.substring(1);he&&he<=Ue&&(we[Ae]="\\"+et[he])}}for(var Ae=0;Ae<lt;++Ae)we[Ae]==="^"&&we[Ae+1]!=="^"&&(we[Ae]="");if(it.ignoreCase&&He)for(var Ae=0;Ae<lt;++Ae){var me=we[Ae],fe=me.charAt(0);me.length>=2&&fe==="["?we[Ae]=tt(me):fe!=="\\"&&(we[Ae]=me.replace(/[a-zA-Z]/g,function(ae){var ue=ae.charCodeAt(0);return"["+String.fromCharCode(ue&~32,ue|32)+"]"}))}return we.join("")}for(var rt=[],Fe=0,Ne=De.length;Fe<Ne;++Fe){var Me=De[Fe];if(Me.global||Me.multiline)throw new Error(""+Me);rt.push("(?:"+ut(Me)+")")}return new RegExp(rt.join("|"),$e?"gi":"g")}function j(De,Pe){var He=/(?:^|\s)nocode(?:\s|$)/,$e=[],Fe=0,Ne=[],Me=0;function at(qe){var Qe=qe.nodeType;if(Qe==1){if(He.test(qe.className))return;for(var tt=qe.firstChild;tt;tt=tt.nextSibling)at(tt);var ut=qe.nodeName.toLowerCase();(ut==="br"||ut==="li")&&($e[Me]=`
|
|
`,Ne[Me<<1]=Fe++,Ne[Me++<<1|1]=qe)}else if(Qe==3||Qe==4){var rt=qe.nodeValue;rt.length&&(Pe?rt=rt.replace(/\r\n?/g,`
|
|
`):rt=rt.replace(/[ \t\r\n]+/g," "),$e[Me]=rt,Ne[Me<<1]=Fe,Fe+=rt.length,Ne[Me++<<1|1]=qe)}}return at(De),{sourceCode:$e.join("").replace(/\n$/,""),spans:Ne}}function q(De,Pe,He,$e,Fe){if(!He)return;var Ne={sourceNode:De,pre:1,langExtension:null,numberLines:null,sourceCode:He,spans:null,basePos:Pe,decorations:null};$e(Ne),Fe.push.apply(Fe,Ne.decorations)}var ie=/\S/;function ce(De){for(var Pe=void 0,He=De.firstChild;He;He=He.nextSibling){var $e=He.nodeType;Pe=$e===1?Pe?De:He:$e===3&&ie.test(He.nodeValue)?De:Pe}return Pe===De?void 0:Pe}function ve(De,Pe){var He={},$e;(function(){for(var Me=De.concat(Pe),at=[],qe={},Qe=0,tt=Me.length;Qe<tt;++Qe){var ut=Me[Qe],rt=ut[3];if(rt)for(var it=rt.length;--it>=0;)He[rt.charAt(it)]=ut;var we=ut[1],lt=""+we;qe.hasOwnProperty(lt)||(at.push(we),qe[lt]=null)}at.push(/[\0-\uffff]/),$e=G(at)})();var Fe=Pe.length,Ne=function(Me){for(var at=Me.sourceCode,qe=Me.basePos,Qe=Me.sourceNode,tt=[qe,a],ut=0,rt=at.match($e)||[],it={},we=0,lt=rt.length;we<lt;++we){var et=rt[we],Ae=it[et],Ue=void 0,me;if(typeof Ae=="string")me=!1;else{var he=He[et.charAt(0)];if(he)Ue=et.match(he[1]),Ae=he[0];else{for(var fe=0;fe<Fe;++fe)if(he=Pe[fe],Ue=et.match(he[1]),Ue){Ae=he[0];break}Ue||(Ae=a)}me=Ae.length>=5&&Ae.substring(0,5)==="lang-",me&&!(Ue&&typeof Ue[1]=="string")&&(me=!1,Ae=E),me||(it[et]=Ae)}var ee=ut;if(ut+=et.length,!me)tt.push(qe+ee,Ae);else{var te=Ue[1],ae=et.indexOf(te),ue=ae+te.length;Ue[2]&&(ue=et.length-Ue[2].length,ae=ue-te.length);var ge=Ae.substring(5);q(Qe,qe+ee,et.substring(0,ae),Ne,tt),q(Qe,qe+ee+ae,te,se(ge,te),tt),q(Qe,qe+ee+ue,et.substring(ue),Ne,tt)}}Me.decorations=tt};return Ne}function ke(De){var Pe=[],He=[];De.tripleQuotedStrings?Pe.push([f,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):De.multiLineStrings?Pe.push([f,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Pe.push([f,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),De.verbatimStrings&&He.push([f,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var $e=De.hashComments;$e&&(De.cStyleComments?($e>1?Pe.push([x,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Pe.push([x,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),He.push([f,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Pe.push([x,/^#[^\r\n]*/,null,"#"])),De.cStyleComments&&(He.push([x,/^\/\/[^\r\n]*/,null]),He.push([x,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var Fe=De.regexLiterals;if(Fe){var Ne=Fe>1?"":`
|
|
\r`,Me=Ne?".":"[\\S\\s]",at="/(?=[^/*"+Ne+"])(?:[^/\\x5B\\x5C"+Ne+"]|\\x5C"+Me+"|\\x5B(?:[^\\x5C\\x5D"+Ne+"]|\\x5C"+Me+")*(?:\\x5D|$))+/";He.push(["lang-regex",RegExp("^"+Z+"("+at+")")])}var qe=De.types;qe&&He.push([p,qe]);var Qe=(""+De.keywords).replace(/^ | $/g,"");Qe.length&&He.push([k,new RegExp("^(?:"+Qe.replace(/[\s,]+/g,"|")+")\\b"),null]),Pe.push([a,/^\s+/,null,` \r
|
|
\xA0`]);var tt="^.[^\\s\\w.$@'\"`/\\\\]*";return De.regexLiterals&&(tt+="(?!s*/)"),He.push([c,/^@[a-z_$][a-z_$@0-9]*/i,null],[p,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[a,/^[a-z_$][a-z_$@0-9]*/i,null],[c,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[a,/^\\[\s\S]?/,null],[s,new RegExp(tt),null]),ve(Pe,He)}var xe=ke({keywords:T,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function Ce(De,Pe,He){for(var $e=/(?:^|\s)nocode(?:\s|$)/,Fe=/\r\n?|\n/,Ne=De.ownerDocument,Me=Ne.createElement("li");De.firstChild;)Me.appendChild(De.firstChild);var at=[Me];function qe(we){var lt=we.nodeType;if(lt==1&&!$e.test(we.className))if(we.nodeName==="br")Qe(we),we.parentNode&&we.parentNode.removeChild(we);else for(var et=we.firstChild;et;et=et.nextSibling)qe(et);else if((lt==3||lt==4)&&He){var Ae=we.nodeValue,Ue=Ae.match(Fe);if(Ue){var me=Ae.substring(0,Ue.index);we.nodeValue=me;var he=Ae.substring(Ue.index+Ue[0].length);if(he){var fe=we.parentNode;fe.insertBefore(Ne.createTextNode(he),we.nextSibling)}Qe(we),me||we.parentNode.removeChild(we)}}}function Qe(we){for(;!we.nextSibling;)if(we=we.parentNode,!we)return;function lt(Ue,me){var he=me?Ue.cloneNode(!1):Ue,fe=Ue.parentNode;if(fe){var ee=lt(fe,1),te=Ue.nextSibling;ee.appendChild(he);for(var ae=te;ae;ae=te)te=ae.nextSibling,ee.appendChild(ae)}return he}for(var et=lt(we.nextSibling,0),Ae;(Ae=et.parentNode)&&Ae.nodeType===1;)et=Ae;at.push(et)}for(var tt=0;tt<at.length;++tt)qe(at[tt]);Pe===(Pe|0)&&at[0].setAttribute("value",Pe);var ut=Ne.createElement("ol");ut.className="linenums";for(var rt=Math.max(0,Pe-1|0)||0,tt=0,it=at.length;tt<it;++tt)Me=at[tt],Me.className="L"+(tt+rt)%10,Me.firstChild||Me.appendChild(Ne.createTextNode("\xA0")),ut.appendChild(Me);De.appendChild(ut)}function Te(De){var Pe=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Pe=Pe&&+Pe[1]<=8;var He=/\n/g,$e=De.sourceCode,Fe=$e.length,Ne=0,Me=De.spans,at=Me.length,qe=0,Qe=De.decorations,tt=Qe.length,ut=0;Qe[tt]=Fe;var rt,it;for(it=rt=0;it<tt;)Qe[it]!==Qe[it+2]?(Qe[rt++]=Qe[it++],Qe[rt++]=Qe[it++]):it+=2;for(tt=rt,it=rt=0;it<tt;){for(var we=Qe[it],lt=Qe[it+1],et=it+2;et+2<=tt&&Qe[et+1]===lt;)et+=2;Qe[rt++]=we,Qe[rt++]=lt,it=et}tt=Qe.length=rt;var Ae=De.sourceNode,Ue="";Ae&&(Ue=Ae.style.display,Ae.style.display="none");try{for(var me=null;qe<at;){var he=Me[qe],fe=Me[qe+2]||Fe,ee=Qe[ut+2]||Fe,et=Math.min(fe,ee),te=Me[qe+1],ae;if(te.nodeType!==1&&(ae=$e.substring(Ne,et))){Pe&&(ae=ae.replace(He,"\r")),te.nodeValue=ae;var ue=te.ownerDocument,ge=ue.createElement("span");ge.className=Qe[ut+1];var Se=te.parentNode;Se.replaceChild(ge,te),ge.appendChild(te),Ne<fe&&(Me[qe+1]=te=ue.createTextNode($e.substring(et,fe)),Se.insertBefore(te,ge.nextSibling))}Ne=et,Ne>=fe&&(qe+=2),Ne>=ee&&(ut+=2)}}finally{Ae&&(Ae.style.display=Ue)}}var Ee={};function pe(De,Pe){for(var He=Pe.length;--He>=0;){var $e=Pe[He];Ee.hasOwnProperty($e)?U.console&&console.warn("cannot override language handler %s",$e):Ee[$e]=De}}function se(De,Pe){return De&&Ee.hasOwnProperty(De)||(De=/^\s*</.test(Pe)?"default-markup":"default-code"),Ee[De]}pe(xe,["default-code"]),pe(ve([],[[a,/^[^<?]+/],[g,/^<!\w[^>]*(?:>|$)/],[x,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[s,/^(?:<[%?]|[%?]>)/],["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"]),pe(ve([[a,/^[\s]+/,null,` \r
|
|
`],[H,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[v,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[_,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[s,/^[=<>\/]+/],["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"]),pe(ve([],[[H,/^[\s\S]+/]]),["uq.val"]),pe(ke({keywords:A,hashComments:!0,cStyleComments:!0,types:y}),["c","cc","cpp","cxx","cyc","m"]),pe(ke({keywords:"null,true,false"}),["json"]),pe(ke({keywords:L,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:y}),["cs"]),pe(ke({keywords:R,cStyleComments:!0}),["java"]),pe(ke({keywords:d,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),pe(ke({keywords:o,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),pe(ke({keywords:h,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),pe(ke({keywords:u,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),pe(ke({keywords:S,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),pe(ke({keywords:w,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),pe(ve([],[[f,/^[\s\S]+/]]),["regex"]);function Le(De){var Pe=De.langExtension;try{var He=j(De.sourceNode,De.pre),$e=He.sourceCode;De.sourceCode=$e,De.spans=He.spans,De.basePos=0,se(Pe,$e)(De),Te(De)}catch(Fe){U.console&&console.log(Fe&&Fe.stack||Fe)}}function Xe(De,Pe,He){var $e=He||!1,Fe=Pe||null,Ne=document.createElement("div");Ne.innerHTML="<pre>"+De+"</pre>",Ne=Ne.firstChild,$e&&Ce(Ne,$e,!0);var Me={langExtension:Fe,numberLines:$e,sourceNode:Ne,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return Le(Me),Ne.innerHTML}function Ge(De,Pe){var He=Pe||document.body,$e=He.ownerDocument||document;function Fe(he){return He.getElementsByTagName(he)}for(var Ne=[Fe("pre"),Fe("code"),Fe("xmp")],Me=[],at=0;at<Ne.length;++at)for(var qe=0,Qe=Ne[at].length;qe<Qe;++qe)Me.push(Ne[at][qe]);Ne=null;var tt=Date;tt.now||(tt={now:function(){return+new Date}});var ut=0,rt=/\blang(?:uage)?-([\w.]+)(?!\S)/,it=/\bprettyprint\b/,we=/\bprettyprinted\b/,lt=/pre|xmp/i,et=/^code$/i,Ae=/^(?:pre|code|xmp)$/i,Ue={};function me(){for(var he=U.PR_SHOULD_USE_CONTINUATION?tt.now()+250:Infinity;ut<Me.length&&tt.now()<he;ut++){for(var fe=Me[ut],ee=Ue,te=fe;te=te.previousSibling;){var ae=te.nodeType,ue=(ae===7||ae===8)&&te.nodeValue;if(ue?!/^\??prettify\b/.test(ue):ae!==3||/\S/.test(te.nodeValue))break;if(ue){ee={},ue.replace(/\b(\w+)=([\w:.%+-]+)/g,function(xt,Dt,Er){ee[Dt]=Er});break}}var ge=fe.className;if((ee!==Ue||it.test(ge))&&!we.test(ge)){for(var Se=!1,Oe=fe.parentNode;Oe;Oe=Oe.parentNode){var nt=Oe.tagName;if(Ae.test(nt)&&Oe.className&&it.test(Oe.className)){Se=!0;break}}if(!Se){fe.className+=" prettyprinted";var gt=ee.lang;if(!gt){gt=ge.match(rt);var ct;!gt&&(ct=ce(fe))&&et.test(ct.tagName)&&(gt=ct.className.match(rt)),gt&&(gt=gt[1])}var kt;if(lt.test(fe.tagName))kt=1;else{var ot=fe.currentStyle,We=$e.defaultView,yt=ot?ot.whiteSpace:We&&We.getComputedStyle?We.getComputedStyle(fe,null).getPropertyValue("white-space"):0;kt=yt&&yt.substring(0,3)==="pre"}var ft=ee.linenums;(ft=ft==="true"||+ft)||(ft=ge.match(/\blinenums\b(?::(\d+))?/),ft=ft?ft[1]&&ft[1].length?+ft[1]:!0:!1),ft&&Ce(fe,ft,kt);var _t={langExtension:gt,sourceNode:fe,numberLines:ft,pre:kt,sourceCode:null,basePos:null,spans:null,decorations:null};Le(_t)}}}ut<Me.length?U.setTimeout(me,250):typeof De=="function"&&De()}me()}var Ke=U.PR={createSimpleLexer:ve,registerLangHandler:pe,sourceDecorator:ke,PR_ATTRIB_NAME:_,PR_ATTRIB_VALUE:H,PR_COMMENT:x,PR_DECLARATION:g,PR_KEYWORD:k,PR_LITERAL:c,PR_NOCODE:V,PR_PLAIN:a,PR_PUNCTUATION:s,PR_SOURCE:E,PR_STRING:f,PR_TAG:v,PR_TYPE:p,prettyPrintOne:D?U.prettyPrintOne=Xe:I=Xe,prettyPrint:z=D?U.prettyPrint=Ge:z=Ge},Ve=U.define;typeof Ve=="function"&&Ve.amd&&Ve("google-code-prettify",[],function(){return Ke})})()},UZu5:function(wt,ht,re){},"VrN/":function(wt,ht,re){(function(ne,$){wt.exports=$()})(this,function(){"use strict";var ne=navigator.userAgent,$=navigator.platform,D=/gecko\/\d/i.test(ne),X=/MSIE \d/.test(ne),N=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ne),I=/Edge\/(\d+)/.exec(ne),z=X||N||I,U=z&&(X?document.documentMode||6:+(I||N)[1]),P=!I&&/WebKit\//.test(ne),M=P&&/Qt\/\d+\.\d+/.test(ne),b=!I&&/Chrome\//.test(ne),A=/Opera\//.test(ne),R=/Apple Computer/.test(navigator.vendor),L=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(ne),w=/PhantomJS/.test(ne),S=!I&&/AppleWebKit/.test(ne)&&/Mobile\/\w+/.test(ne),h=/Android/.test(ne),o=S||h||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(ne),u=S||/Mac/.test($),d=/\bCrOS\b/.test(ne),T=/win/i.test($),y=A&&ne.match(/Version\/(\d*\.\d*)/);y&&(y=Number(y[1])),y&&y>=15&&(A=!1,P=!0);var f=u&&(M||A&&(y==null||y<12.11)),k=D||z&&U>=9;function x(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var p=function(e,t){var i=e.className,r=x(t).exec(i);if(r){var n=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(n?r[1]+n:"")}};function c(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function s(e,t){return c(e).appendChild(t)}function a(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var C=0;C<t.length;++C)n.appendChild(t[C]);return n}function v(e,t,i,r){var n=a(e,t,i,r);return n.setAttribute("role","presentation"),n}var g;document.createRange?g=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:g=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 E(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 _(){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 H(e,t){var i=e.className;x(t).test(i)||(e.className+=(i?" ":"")+t)}function V(e,t){for(var i=e.split(" "),r=0;r<i.length;r++)i[r]&&!x(i[r]).test(t)&&(t+=" "+i[r]);return t}var Z=function(e){e.select()};S?Z=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:z&&(Z=function(e){try{e.select()}catch(t){}});function G(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function j(e,t,i){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(i!==!1||!t.hasOwnProperty(r))&&(t[r]=e[r]);return t}function q(e,t,i,r,n){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var C=r||0,B=n||0;;){var K=e.indexOf(" ",C);if(K<0||K>=t)return B+(t-C);B+=K-C,B+=i-B%i,C=K+1}}var ie=function(){this.id=null,this.f=null,this.time=0,this.handler=G(this.onTimeout,this)};ie.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},ie.prototype.set=function(e,t){this.f=t;var i=+new Date+e;(!this.id||i<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,e),this.time=i)};function ce(e,t){for(var i=0;i<e.length;++i)if(e[i]==t)return i;return-1}var ve=50,ke={toString:function(){return"CodeMirror.Pass"}},xe={scroll:!1},Ce={origin:"*mouse"},Te={origin:"+move"};function Ee(e,t,i){for(var r=0,n=0;;){var C=e.indexOf(" ",r);C==-1&&(C=e.length);var B=C-r;if(C==e.length||n+B>=t)return r+Math.min(B,t-n);if(n+=C-r,n+=i-n%i,r=C+1,n>=t)return r}}var pe=[""];function se(e){for(;pe.length<=e;)pe.push(Le(pe)+" ");return pe[e]}function Le(e){return e[e.length-1]}function Xe(e,t){for(var i=[],r=0;r<e.length;r++)i[r]=t(e[r],r);return i}function Ge(e,t,i){for(var r=0,n=i(t);r<e.length&&i(e[r])<=n;)r++;e.splice(r,0,t)}function Ke(){}function Ve(e,t){var i;return Object.create?i=Object.create(e):(Ke.prototype=e,i=new Ke),t&&j(t,i),i}var De=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function Pe(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||De.test(e))}function He(e,t){return t?t.source.indexOf("\\w")>-1&&Pe(e)?!0:t.test(e):Pe(e)}function $e(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var Fe=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function Ne(e){return e.charCodeAt(0)>=768&&Fe.test(e)}function Me(e,t,i){for(;(i<0?t>0:t<e.length)&&Ne(e.charAt(t));)t+=i;return t}function at(e,t,i){for(var r=t>i?-1:1;;){if(t==i)return t;var n=(t+i)/2,C=r<0?Math.ceil(n):Math.floor(n);if(C==t)return e(C)?t:i;e(C)?i=C:t=C+r}}function qe(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,C=0;C<e.length;++C){var B=e[C];(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",C),n=!0)}n||r(t,i,"ltr")}var Qe=null;function tt(e,t,i){var r;Qe=null;for(var n=0;n<e.length;++n){var C=e[n];if(C.from<t&&C.to>t)return n;C.to==t&&(C.from!=C.to&&i=="before"?r=n:Qe=n),C.from==t&&(C.from!=C.to&&i!="before"?r=n:Qe=n)}return r!=null?r:Qe}var ut=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(Q){return Q<=247?e.charAt(Q):1424<=Q&&Q<=1524?"R":1536<=Q&&Q<=1785?t.charAt(Q-1536):1774<=Q&&Q<=2220?"r":8192<=Q&&Q<=8203?"w":Q==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,C=/[LRr]/,B=/[Lb1n]/,K=/[1n]/;function Y(Q,oe,le){this.level=Q,this.from=oe,this.to=le}return function(Q,oe){var le=oe=="ltr"?"L":"R";if(Q.length==0||oe=="ltr"&&!r.test(Q))return!1;for(var be=Q.length,ye=[],Re=0;Re<be;++Re)ye.push(i(Q.charCodeAt(Re)));for(var Be=0,ze=le;Be<be;++Be){var Je=ye[Be];Je=="m"?ye[Be]=ze:ze=Je}for(var st=0,Ze=le;st<be;++st){var dt=ye[st];dt=="1"&&Ze=="r"?ye[st]="n":C.test(dt)&&(Ze=dt,dt=="r"&&(ye[st]="R"))}for(var Tt=1,Et=ye[0];Tt<be-1;++Tt){var Rt=ye[Tt];Rt=="+"&&Et=="1"&&ye[Tt+1]=="1"?ye[Tt]="1":Rt==","&&Et==ye[Tt+1]&&(Et=="1"||Et=="n")&&(ye[Tt]=Et),Et=Rt}for(var Vt=0;Vt<be;++Vt){var lr=ye[Vt];if(lr==",")ye[Vt]="N";else if(lr=="%"){var $t=void 0;for($t=Vt+1;$t<be&&ye[$t]=="%";++$t);for(var Ir=Vt&&ye[Vt-1]=="!"||$t<be&&ye[$t]=="1"?"1":"N",Dr=Vt;Dr<$t;++Dr)ye[Dr]=Ir;Vt=$t-1}}for(var er=0,Rr=le;er<be;++er){var fr=ye[er];Rr=="L"&&fr=="1"?ye[er]="L":C.test(fr)&&(Rr=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 Jt=(ir?ye[ir-1]:le)=="L",_r=(tr<be?ye[tr]:le)=="L",un=Jt==_r?Jt?"L":"R":le,Ri=ir;Ri<tr;++Ri)ye[Ri]=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,zi=oe=="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+=zi);var hn=Tr;for(++Tr;Tr<ur&&K.test(ye[Tr]);++Tr);xr.splice(Hi,0,new Y(2,hn,Tr)),Hi+=zi,di=Tr}else++Tr;di<ur&&xr.splice(Hi,0,new Y(1,di,ur))}return oe=="ltr"&&(xr[0].level==1&&(ai=Q.match(/^\s+/))&&(xr[0].from=ai[0].length,xr.unshift(new Y(0,0,ai[0].length))),Le(xr).level==1&&(ai=Q.match(/\s+$/))&&(Le(xr).to-=ai[0].length,xr.push(new Y(0,be-ai[0].length,be)))),oe=="rtl"?xr.reverse():xr}}();function rt(e,t){var i=e.order;return i==null&&(i=e.order=ut(e.text,t)),i}var it=[],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]||it).concat(i)}};function lt(e,t){return e._handlers&&e._handlers[t]||it}function et(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 C=ce(n,i);C>-1&&(r[t]=n.slice(0,C).concat(n.slice(C+1)))}}}function Ae(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 Ue(e,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Ae(e,i||t.type,e,t),ae(t)||t.codemirrorIgnore}function me(e){var t=e._handlers&&e._handlers.cursorActivity;if(!t)return;for(var i=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),r=0;r<t.length;++r)ce(i,t[r])==-1&&i.push(t[r])}function he(e,t){return lt(e,t).length>0}function fe(e){e.prototype.on=function(t,i){we(this,t,i)},e.prototype.off=function(t,i){et(this,t,i)}}function ee(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function te(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function ae(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function ue(e){ee(e),te(e)}function ge(e){return e.target||e.srcElement}function Se(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),u&&e.ctrlKey&&t==1&&(t=3),t}var Oe=function(){if(z&&U<9)return!1;var e=a("div");return"draggable"in e||"dragDrop"in e}(),nt;function gt(e){if(nt==null){var t=a("span","\u200B");s(e,a("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(nt=t.offsetWidth<=1&&t.offsetHeight>2&&!(z&&U<8))}var i=nt?a("span","\u200B"):a("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var ct;function kt(e){if(ct!=null)return ct;var t=s(e,document.createTextNode("A\u062EA")),i=g(t,0,1).getBoundingClientRect(),r=g(t,1,2).getBoundingClientRect();return c(e),!i||i.left==i.right?!1:ct=r.right-i.right<3}var ot=`
|
|
|
|
b`.split(/\n/).length!=3?function(e){for(var t=0,i=[],r=e.length;t<=r;){var n=e.indexOf(`
|
|
`,t);n==-1&&(n=e.length);var C=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),B=C.indexOf("\r");B!=-1?(i.push(C.slice(0,B)),t+=B+1):(i.push(C),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},We=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},yt=function(){var e=a("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),ft=null;function _t(e){if(ft!=null)return ft;var t=s(e,a("span","x")),i=t.getBoundingClientRect(),r=g(t,0,1).getBoundingClientRect();return ft=Math.abs(i.left-r.left)>1}var xt={},Dt={};function Er(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),xt[e]=t}function Hr(e,t){Dt[e]=t}function bt(e){if(typeof e=="string"&&Dt.hasOwnProperty(e))e=Dt[e];else if(e&&typeof e.name=="string"&&Dt.hasOwnProperty(e.name)){var t=Dt[e.name];typeof t=="string"&&(t={name:t}),e=Ve(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 C in n){if(!n.hasOwnProperty(C))continue;r.hasOwnProperty(C)&&(r["_"+C]=r[C]),r[C]=n[C]}}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]={};j(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 Ut=function(e,t,i){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=i};Ut.prototype.eol=function(){return this.pos>=this.string.length},Ut.prototype.sol=function(){return this.pos==this.lineStart},Ut.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Ut.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},Ut.prototype.eat=function(e){var t=this.string.charAt(this.pos),i;if(typeof e=="string"?i=t==e:i=t&&(e.test?e.test(t):e(t)),i)return++this.pos,t},Ut.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},Ut.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Ut.prototype.skipToEnd=function(){this.pos=this.string.length},Ut.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Ut.prototype.backUp=function(e){this.pos-=e},Ut.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=q(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?q(this.string,this.lineStart,this.tabSize):0)},Ut.prototype.indentation=function(){return q(this.string,null,this.tabSize)-(this.lineStart?q(this.string,this.lineStart,this.tabSize):0)},Ut.prototype.match=function(e,t,i){if(typeof e=="string"){var r=function(B){return i?B.toLowerCase():B},n=this.string.substr(this.pos,e.length);if(r(n)==r(e))return t!==!1&&(this.pos+=e.length),!0}else{var C=this.string.slice(this.pos).match(e);return C&&C.index>0?null:(C&&t!==!1&&(this.pos+=C[0].length),C)}},Ut.prototype.current=function(){return this.string.slice(this.start,this.pos)},Ut.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Ut.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Ut.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function pt(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],C=n.chunkSize();if(t<C){i=n;break}t-=C}return i.lines[t]}function zr(e,t,i){var r=[],n=t.line;return e.iter(t.line,i.line+1,function(C){var B=C.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 Pt(e){if(e.parent==null)return null;for(var t=e.parent,i=ce(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var n=0;!(r.children[n]==t);++n)i+=r.children[n].chunkSize();return i+t.first}function Ur(e,t){var i=e.first;e:do{for(var r=0;r<e.children.length;++r){var n=e.children[r],C=n.height;if(t<C){e=n;continue e}t-=C,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 je(e,t,i){if(i===void 0&&(i=null),!(this instanceof je))return new je(e,t,i);this.line=e,this.ch=t,this.sticky=i}function Lt(e,t){return e.line-t.line||e.ch-t.ch}function pi(e,t){return e.sticky==t.sticky&&Lt(e,t)==0}function mi(e){return je(e.line,e.ch)}function gi(e,t){return Lt(e,t)<0?t:e}function vi(e,t){return Lt(e,t)<0?e:t}function W(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function l(e,t){if(t.line<e.first)return je(e.first,0);var i=e.first+e.size-1;return t.line>i?je(i,pt(e,i).text.length):m(t,pt(e,t.line).text.length)}function m(e,t){var i=e.ch;return i==null||i>t?je(e.line,t):i<0?je(e.line,0):e}function O(e,t){for(var i=[],r=0;r<t.length;r++)i[r]=l(e,t[r]);return i}var J=function(e,t){this.state=e,this.lookAhead=t},F=function(e,t,i,r){this.state=t,this.doc=e,this.line=i,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};F.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},F.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}},F.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},F.fromSaved=function(e,t,i){return t instanceof J?new F(e,Br(e.mode,t.state),i,t.lookAhead):new F(e,Br(e.mode,t),i)},F.prototype.save=function(e){var t=e!==!1?Br(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new J(t,this.maxLookAhead):t};function de(e,t,i,r){var n=[e.state.modeGen],C={};gr(e,t.text,e.doc.mode,i,function(Q,oe){return n.push(Q,oe)},C,r);for(var B=i.state,K=function(Q){i.baseTokens=n;var oe=e.state.overlays[Q],le=1,be=0;i.state=!0,gr(e,t.text,oe.mode,i,function(ye,Re){for(var Be=le;be<ye;){var ze=n[le];ze>ye&&n.splice(le,1,ye,n[le+1],ze),le+=2,be=Math.min(ye,ze)}if(!Re)return;if(oe.opaque)n.splice(Be,le-Be,ye,"overlay "+Re),le=Be+2;else for(;Be<le;Be+=2){var Je=n[Be+1];n[Be+1]=(Je?Je+" ":"")+"overlay "+Re}},C),i.state=B,i.baseTokens=null,i.baseTokenPos=1},Y=0;Y<e.state.overlays.length;++Y)K(Y);return{styles:n,classes:C.bgClass||C.textClass?C:null}}function _e(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=Ye(e,Pt(t)),n=t.text.length>e.options.maxHighlightLength&&Br(e.doc.mode,r.state),C=de(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=C.styles,C.classes?t.styleClasses=C.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 Ye(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new F(r,!0,t);var C=vr(e,t,i),B=C>r.first&&pt(r,C-1).stateAfter,K=B?F.fromSaved(r,B,C):new F(r,qr(r.mode),C);return r.iter(C,t,function(Y){mt(e,Y.text,K);var Q=K.line;Y.stateAfter=Q==t-1||Q%5==0||Q>=n.viewFrom&&Q<n.viewTo?K.save():null,K.nextLine()}),i&&(r.modeFrontier=K.line),K}function mt(e,t,i,r){var n=e.doc.mode,C=new Ut(t,e.options.tabSize,i);for(C.start=C.pos=r||0,t==""&&Ie(n,i.state);!C.eol();)St(n,C,i.state),C.start=C.pos}function Ie(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var i=ci(e,t);if(i.mode.blankLine)return i.mode.blankLine(i.state)}function St(e,t,i,r){for(var n=0;n<10;n++){r&&(r[0]=ci(e,i).mode);var C=e.token(t,i);if(t.pos>t.start)return C}throw new Error("Mode "+e.name+" failed to advance stream.")}var Ft=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function Xt(e,t,i,r){var n=e.doc,C=n.mode,B;t=l(n,t);var K=pt(n,t.line),Y=Ye(e,t.line,i),Q=new Ut(K.text,e.options.tabSize,Y),oe;for(r&&(oe=[]);(r||Q.pos<t.ch)&&!Q.eol();)Q.start=Q.pos,B=St(C,Q,Y.state),r&&oe.push(new Ft(Q,B,Br(n.mode,Y.state)));return r?oe:new Ft(Q,B,Y.state)}function Or(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,C,B){var K=i.flattenSpans;K==null&&(K=e.options.flattenSpans);var Y=0,Q=null,oe=new Ut(t,e.options.tabSize,r),le,be=e.options.addModeClass&&[null];for(t==""&&Or(Ie(i,r.state),C);!oe.eol();){if(oe.pos>e.options.maxHighlightLength?(K=!1,B&&mt(e,t,r,oe.pos),oe.pos=t.length,le=null):le=Or(St(i,oe,r.state,be),C),be){var ye=be[0].name;ye&&(le="m-"+(le?ye+" "+le:ye))}if(!K||Q!=le){for(;Y<oe.start;)Y=Math.min(oe.start,Y+5e3),n(Y,Q);Q=le}oe.start=oe.pos}for(;Y<oe.pos;){var Re=Math.min(oe.pos,Y+5e3);n(Re,Q),Y=Re}}function vr(e,t,i){for(var r,n,C=e.doc,B=i?-1:t-(e.doc.mode.innerMode?1e3:100),K=t;K>B;--K){if(K<=C.first)return C.first;var Y=pt(C,K-1),Q=Y.stateAfter;if(Q&&(!i||K+(Q instanceof J?Q.lookAhead:0)<=C.modeFrontier))return K;var oe=q(Y.text,null,e.options.tabSize);(n==null||r>oe)&&(n=K-1,r=oe)}return n}function Xr(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),e.highlightFrontier<t-10)return;for(var i=e.first,r=t-1;r>i;r--){var n=pt(e,r).stateAfter;if(n&&(!(n instanceof J)||r+n.lookAhead<t)){i=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)}var _i=!1,nr=!1;function Fr(){_i=!0}function oi(){nr=!0}function si(e,t,i){this.marker=e,this.from=t,this.to=i}function Pr(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 Gi(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var C=e[n],B=C.marker,K=C.from==null||(B.inclusiveLeft?C.from<=t:C.from<t);if(K||C.from==t&&B.type=="bookmark"&&(!i||!C.marker.insertLeft)){var Y=C.to==null||(B.inclusiveRight?C.to>=t:C.to>t);(r||(r=[])).push(new si(B,C.from,Y?null:C.to))}}return r}function Ki(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var C=e[n],B=C.marker,K=C.to==null||(B.inclusiveRight?C.to>=t:C.to>t);if(K||C.from==t&&B.type=="bookmark"&&(!i||C.marker.insertLeft)){var Y=C.from==null||(B.inclusiveLeft?C.from<=t:C.from<t);(r||(r=[])).push(new si(B,Y?null:C.from-t,C.to==null?null:C.to-t))}}return r}function Yr(e,t){if(t.full)return null;var i=Vr(e,t.from.line)&&pt(e,t.from.line).markedSpans,r=Vr(e,t.to.line)&&pt(e,t.to.line).markedSpans;if(!i&&!r)return null;var n=t.from.ch,C=t.to.ch,B=Lt(t.from,t.to)==0,K=Gi(i,n,B),Y=Ki(r,C,B),Q=t.text.length==1,oe=Le(t.text).length+(Q?n:0);if(K)for(var le=0;le<K.length;++le){var be=K[le];if(be.to==null){var ye=Pr(Y,be.marker);ye?Q&&(be.to=ye.to==null?null:ye.to+oe):be.to=n}}if(Y)for(var Re=0;Re<Y.length;++Re){var Be=Y[Re];if(Be.to!=null&&(Be.to+=oe),Be.from==null){var ze=Pr(K,Be.marker);ze||(Be.from=oe,Q&&(K||(K=[])).push(Be))}else Be.from+=oe,Q&&(K||(K=[])).push(Be)}K&&(K=Gr(K)),Y&&Y!=K&&(Y=Gr(Y));var Je=[K];if(!Q){var st=t.text.length-2,Ze;if(st>0&&K)for(var dt=0;dt<K.length;++dt)K[dt].to==null&&(Ze||(Ze=[])).push(new si(K[dt].marker,null,null));for(var Tt=0;Tt<st;++Tt)Je.push(Ze);Je.push(Y)}return Je}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 Re=0;Re<ye.markedSpans.length;++Re){var Be=ye.markedSpans[Re].marker;Be.readOnly&&(!r||ce(r,Be)==-1)&&(r||(r=[])).push(Be)}}),!r)return null;for(var n=[{from:t,to:i}],C=0;C<r.length;++C)for(var B=r[C],K=B.find(0),Y=0;Y<n.length;++Y){var Q=n[Y];if(Lt(Q.to,K.from)<0||Lt(Q.from,K.to)>0)continue;var oe=[Y,1],le=Lt(Q.from,K.from),be=Lt(Q.to,K.to);(le<0||!B.inclusiveLeft&&!le)&&oe.push({from:Q.from,to:K.from}),(be>0||!B.inclusiveRight&&!be)&&oe.push({from:K.to,to:Q.to}),n.splice.apply(n,oe),Y+=oe.length-3}return n}function dn(e){var t=e.markedSpans;if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.detachLine(e);e.markedSpans=null}function xi(e,t){if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.attachLine(e);e.markedSpans=t}function Zt(e){return e.inclusiveLeft?-1:0}function jt(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(),C=Lt(r.from,n.from)||Zt(e)-Zt(t);if(C)return-C;var B=Lt(r.to,n.to)||jt(e)-jt(t);return B||t.id-e.id}function Mt(e,t){var i=nr&&e.markedSpans,r;if(i)for(var n=void 0,C=0;C<i.length;++C)n=i[C],n.marker.collapsed&&(t?n.from:n.to)==null&&(!r||dr(r,n.marker)<0)&&(r=n.marker);return r}function qt(e){return Mt(e,!0)}function zt(e){return Mt(e,!1)}function ti(e,t){var i=nr&&e.markedSpans,r;if(i)for(var n=0;n<i.length;++n){var C=i[n];C.marker.collapsed&&(C.from==null||C.from<t)&&(C.to==null||C.to>t)&&(!r||dr(r,C.marker)<0)&&(r=C.marker)}return r}function ar(e,t,i,r,n){var C=pt(e,t),B=nr&&C.markedSpans;if(B)for(var K=0;K<B.length;++K){var Y=B[K];if(!Y.marker.collapsed)continue;var Q=Y.marker.find(0),oe=Lt(Q.from,i)||Zt(Y.marker)-Zt(n),le=Lt(Q.to,r)||jt(Y.marker)-jt(n);if(oe>=0&&le<=0||oe<=0&&le>=0)continue;if(oe<=0&&(Y.marker.inclusiveRight&&n.inclusiveLeft?Lt(Q.to,i)>=0:Lt(Q.to,i)>0)||oe>=0&&(Y.marker.inclusiveRight&&n.inclusiveLeft?Lt(Q.from,r)<=0:Lt(Q.from,r)<0))return!0}}function Sr(e){for(var t;t=qt(e);)e=t.find(-1,!0).line;return e}function Vi(e){for(var t;t=zt(e);)e=t.find(1,!0).line;return e}function Ei(e){for(var t,i;t=zt(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function cn(e,t){var i=pt(e,t),r=Sr(i);return i==r?t:Pt(r)}function Si(e,t){if(t>e.lastLine())return t;var i=pt(e,t),r;if(!ri(e,i))return t;for(;r=zt(i);)i=r.find(1,!0).line;return Pt(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,Pr(r.line.markedSpans,i.marker))}if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(var n=void 0,C=0;C<t.markedSpans.length;++C)if(n=t.markedSpans[C],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=Sr(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 C=i.parent;C;i=C,C=i.parent)for(var B=0;B<C.children.length;++B){var K=C.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=zt(r);){var C=i.find(0,!0);t-=r.text.length-C.from.ch,r=C.to.line,t+=r.text.length-C.to.ch}return t}function jn(e){var t=e.display,i=e.doc;t.maxLine=pt(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 Pt(this)},fe(Pi);function ua(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),dn(e),xi(e,i);var n=r?r(e):1;n!=e.height&&mr(e,n)}function vt(e){e.parent=null,dn(e)}var At={},Ct={};function Ot(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?Ct:At;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function Bt(e,t){var i=v("span",null,null,P?"padding-right: .1px":null),r={pre:v("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 C=n?t.rest[n-1]:t.line,B=void 0;r.pos=0,r.addToken=Nt,kt(e.display.measure)&&(B=rt(C,e.doc.direction))&&(r.addToken=wr(r.addToken,B)),r.map=[];var K=t!=e.display.externalMeasured&&Pt(C);li(C,r,_e(e,C,K)),C.styleClasses&&(C.styleClasses.bgClass&&(r.bgClass=V(C.styleClasses.bgClass,r.bgClass||"")),C.styleClasses.textClass&&(r.textClass=V(C.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(gt(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 Ae(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=V(r.pre.className,r.textClass||"")),r}function Kt(e){var t=a("span","\u2022","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Nt(e,t,i,r,n,C,B){if(!t)return;var K=e.splitSpaces?rr(t,e.trailingSpace):t,Y=e.cm.state.specialChars,Q=!1,oe;if(!Y.test(t))e.col+=t.length,oe=document.createTextNode(K),e.map.push(e.pos,e.pos+t.length,oe),z&&U<9&&(Q=!0),e.pos+=t.length;else{oe=document.createDocumentFragment();for(var le=0;;){Y.lastIndex=le;var be=Y.exec(t),ye=be?be.index-le:t.length-le;if(ye){var Re=document.createTextNode(K.slice(le,le+ye));z&&U<9?oe.appendChild(a("span",[Re])):oe.appendChild(Re),e.map.push(e.pos,e.pos+ye,Re),e.col+=ye,e.pos+=ye}if(!be)break;le+=ye+1;var Be=void 0;if(be[0]==" "){var ze=e.cm.options.tabSize,Je=ze-e.col%ze;Be=oe.appendChild(a("span",se(Je),"cm-tab")),Be.setAttribute("role","presentation"),Be.setAttribute("cm-text"," "),e.col+=Je}else be[0]=="\r"||be[0]==`
|
|
`?(Be=oe.appendChild(a("span",be[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Be.setAttribute("cm-text",be[0]),e.col+=1):(Be=e.cm.options.specialCharPlaceholder(be[0]),Be.setAttribute("cm-text",be[0]),z&&U<9?oe.appendChild(a("span",[Be])):oe.appendChild(Be),e.col+=1);e.map.push(e.pos,e.pos+1,Be),e.pos++}}if(e.trailingSpace=K.charCodeAt(t.length-1)==32,i||r||n||Q||C||B){var st=i||"";r&&(st+=r),n&&(st+=n);var Ze=a("span",[oe],st,C);if(B)for(var dt in B)B.hasOwnProperty(dt)&&dt!="style"&&dt!="class"&&Ze.setAttribute(dt,B[dt]);return e.content.appendChild(Ze)}e.content.appendChild(oe)}function rr(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;n<e.length;n++){var C=e.charAt(n);C==" "&&i&&(n==e.length-1||e.charCodeAt(n+1)==32)&&(C="\xA0"),r+=C,i=C==" "}return r}function wr(e,t){return function(i,r,n,C,B,K,Y){n=n?n+" cm-force-border":"cm-force-border";for(var Q=i.pos,oe=Q+r.length;;){for(var le=void 0,be=0;be<t.length&&!(le=t[be],le.to>Q&&le.from<=Q);be++);if(le.to>=oe)return e(i,r,n,C,B,K,Y);e(i,r.slice(0,le.to-Q),n,C,null,K,Y),C=null,r=r.slice(le.to-Q),Q=le.to}}}function It(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,C=0;if(!r){for(var B=1;B<i.length;B+=2)t.addToken(t,n.slice(C,C=i[B]),Ot(i[B+1],t.cm.options));return}for(var K=n.length,Y=0,Q=1,oe="",le,be,ye=0,Re,Be,ze,Je,st;;){if(ye==Y){Re=Be=ze=be="",st=null,Je=null,ye=Infinity;for(var Ze=[],dt=void 0,Tt=0;Tt<r.length;++Tt){var Et=r[Tt],Rt=Et.marker;if(Rt.type=="bookmark"&&Et.from==Y&&Rt.widgetNode)Ze.push(Rt);else if(Et.from<=Y&&(Et.to==null||Et.to>Y||Rt.collapsed&&Et.to==Y&&Et.from==Y)){if(Et.to!=null&&Et.to!=Y&&ye>Et.to&&(ye=Et.to,Be=""),Rt.className&&(Re+=" "+Rt.className),Rt.css&&(be=(be?be+";":"")+Rt.css),Rt.startStyle&&Et.from==Y&&(ze+=" "+Rt.startStyle),Rt.endStyle&&Et.to==ye&&(dt||(dt=[])).push(Rt.endStyle,Et.to),Rt.title&&((st||(st={})).title=Rt.title),Rt.attributes)for(var Vt in Rt.attributes)(st||(st={}))[Vt]=Rt.attributes[Vt];Rt.collapsed&&(!Je||dr(Je.marker,Rt)<0)&&(Je=Et)}else Et.from>Y&&ye>Et.from&&(ye=Et.from)}if(dt)for(var lr=0;lr<dt.length;lr+=2)dt[lr+1]==ye&&(Be+=" "+dt[lr]);if(!Je||Je.from==Y)for(var $t=0;$t<Ze.length;++$t)It(t,0,Ze[$t]);if(Je&&(Je.from||0)==Y){if(It(t,(Je.to==null?K+1:Je.to)-Y,Je.marker,Je.from==null),Je.to==null)return;Je.to==Y&&(Je=!1)}}if(Y>=K)break;for(var Ir=Math.min(K,ye);;){if(oe){var Dr=Y+oe.length;if(!Je){var er=Dr>Ir?oe.slice(0,Ir-Y):oe;t.addToken(t,er,le?le+Re:Re,ze,Y+er.length==ye?Be:"",be,st)}if(Dr>=Ir){oe=oe.slice(Ir-Y),Y=Ir;break}Y=Dr,ze=""}oe=n.slice(C,C=i[Q++]),le=Ot(i[Q++],t.cm.options)}}}function Wt(e,t,i){this.line=t,this.rest=Ei(t),this.size=this.rest?Pt(Le(this.rest))-i+1:1,this.node=this.text=null,this.hidden=ri(e,t)}function Lr(e,t,i){for(var r=[],n,C=t;C<i;C=n){var B=new Wt(e.doc,pt(e.doc,C),C);n=C+B.size,r.push(B)}return r}var yr=null;function Kr(e){yr?yr.ops.push(e):e.ownsGroup=yr={ops:[e],delayedCallbacks:[]}}function Rs(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 _s(e,t){var i=e.ownsGroup;if(!i)return;try{Rs(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 C=function(K){n.push(function(){return i[K].apply(null,r)})},B=0;B<i.length;++B)C(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 C=t.changes[n];C=="text"?Ms(e,t):C=="gutter"?Ja(e,t,i,r):C=="class"?ha(e,t):C=="widget"&&Is(e,t,r)}t.changes=null}function gn(e){return e.node==e.text&&(e.node=a("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),z&&U<8&&(e.node.style.zIndex=2)),e.node}function Ps(e,t){var i=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(i&&(i+=" CodeMirror-linebackground"),t.background)i?t.background.className=i:(t.background.parentNode.removeChild(t.background),t.background=null);else if(i){var r=gn(t);t.background=r.insertBefore(a("div",null,i),r.firstChild),e.display.input.setUneditable(t.background)}}function $a(e,t){var i=e.display.externalMeasured;return i&&i.line==t.line?(e.display.externalMeasured=null,t.measure=i.measure,i.built):Bt(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 Ja(e,t,i,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var n=gn(t);t.gutterBackground=a("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),n.insertBefore(t.gutterBackground,t.text)}var C=t.line.gutterMarkers;if(e.options.lineNumbers||C){var B=gn(t),K=t.gutter=a("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(K),B.insertBefore(K,t.text),t.line.gutterClass&&(K.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!C||!C["CodeMirror-linenumbers"])&&(t.lineNumber=K.appendChild(a("div",fi(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),C)for(var Y=0;Y<e.display.gutterSpecs.length;++Y){var Q=e.display.gutterSpecs[Y].className,oe=C.hasOwnProperty(Q)&&C[Q];oe&&K.appendChild(a("div",[oe],"CodeMirror-gutter-elt","left: "+r.gutterLeft[Q]+"px; width: "+r.gutterWidth[Q]+"px"))}}}function Is(e,t,i){t.alignable&&(t.alignable=null);for(var r=x("CodeMirror-linewidget"),n=t.node.firstChild,C=void 0;n;n=C)C=n.nextSibling,r.test(n.className)&&t.node.removeChild(n);Za(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),Ja(e,t,i,r),Za(e,t,r),t.node}function Za(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 C=gn(i),B=0,K=t.widgets;B<K.length;++B){var Y=K[B],Q=a("div",[Y.node],"CodeMirror-linewidget"+(Y.className?" "+Y.className:""));Y.handleMouseEvents||Q.setAttribute("cm-ignore-events","true"),Bs(Y,Q,i,r),e.display.input.setUneditable(Q),n&&Y.above?C.insertBefore(Q,i.gutter||i.text):C.appendChild(Q),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(!E(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;"),s(t.display.measure,a("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function ui(e,t){for(var i=ge(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=s(e.measure,a("pre","x","CodeMirror-line-like")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function ii(e){return ve-e.display.nativeBarWidth}function Mi(e){return e.display.scroller.clientWidth-ii(e)-e.display.barWidth}function ca(e){return e.display.scroller.clientHeight-ii(e)-e.display.barHeight}function Us(e,t,i){var r=e.options.lineWrapping,n=r&&Mi(e);if(!t.measure.heights||r&&t.measure.width!=n){var C=t.measure.heights=[];if(r){t.measure.width=n;for(var B=t.text.firstChild.getClientRects(),K=0;K<B.length-1;K++){var Y=B[K],Q=B[K+1];Math.abs(Y.bottom-Q.bottom)>2&&C.push((Y.bottom+Q.top)/2-i.top)}}C.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(Pt(e.rest[n])>i)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Fs(e,t){t=Sr(t);var i=Pt(t),r=e.display.externalMeasured=new Wt(e.doc,t,i);r.lineN=i;var n=r.built=Bt(e,r);return r.text=n.pre,s(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=Pt(t),r=fa(e,i);r&&!r.text?r=null:r&&r.changes&&(Ya(e,r,i,ba(e)),e.curOp.forceUpdate=!0),r||(r=Fs(e,t));var n=eo(r,t,i);return{line:t,view:r,rect:null,map:n.map,cache:n.cache,before:n.before,hasHeights:!1}}function ni(e,t,i,r,n){t.before&&(i=-1);var C=i+(r||""),B;return t.cache.hasOwnProperty(C)?B=t.cache[C]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Us(e,t.view,t.rect),t.hasHeights=!0),B=Ws(e,t,i,r),B.bogus||(t.cache[C]=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,C,B,K,Y,Q=0;Q<e.length;Q+=3)if(K=e[Q],Y=e[Q+1],t<K?(n=0,C=1,B="left"):t<Y?(n=t-K,C=n+1):(Q==e.length-3||t==Y&&e[Q+3]>t)&&(C=Y-K,n=C-1,t>=Y&&(B="right")),n!=null){if(r=e[Q+2],K==Y&&i==(r.insertLeft?"left":"right")&&(B=i),i=="left"&&n==0)for(;Q&&e[Q-2]==e[Q-3]&&e[Q-1].insertLeft;)r=e[(Q-=3)+2],B="left";if(i=="right"&&n==Y-K)for(;Q<e.length-3&&e[Q+3]==e[Q+4]&&!e[Q+5].insertLeft;)r=e[(Q+=3)+2],B="right";break}return{node:r,start:n,end:C,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),C=n.node,B=n.start,K=n.end,Y=n.collapse,Q;if(C.nodeType==3){for(var oe=0;oe<4;oe++){for(;B&&Ne(t.line.text.charAt(n.coverStart+B));)--B;for(;n.coverStart+K<n.coverEnd&&Ne(t.line.text.charAt(n.coverStart+K));)++K;if(z&&U<9&&B==0&&K==n.coverEnd-n.coverStart?Q=C.parentNode.getBoundingClientRect():Q=js(g(C,B,K).getClientRects(),r),Q.left||Q.right||B==0)break;K=B,B=B-1,Y="right"}z&&U<11&&(Q=Hs(e.display.measure,Q))}else{B>0&&(Y=r="right");var le;e.options.lineWrapping&&(le=C.getClientRects()).length>1?Q=le[r=="right"?le.length-1:0]:Q=C.getBoundingClientRect()}if(z&&U<9&&!B&&(!Q||!Q.left&&!Q.right)){var be=C.parentNode.getClientRects()[0];be?Q={left:be.left,right:be.left+$i(e.display),top:be.top,bottom:be.bottom}:Q=ro}for(var ye=Q.top-t.rect.top,Re=Q.bottom-t.rect.top,Be=(ye+Re)/2,ze=t.view.measure.heights,Je=0;Je<ze.length-1&&!(Be<ze[Je]);Je++);var st=Je?ze[Je-1]:0,Ze=ze[Je],dt={left:(Y=="right"?Q.right:Q.left)-t.rect.left,right:(Y=="left"?Q.left:Q.right)-t.rect.left,top:st,bottom:Ze};return!Q.left&&!Q.right&&(dt.bogus=!0),e.options.singleCursorHeightPerLine||(dt.rtop=ye,dt.rbottom=Re),dt}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!_t(e))return t;var i=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*i,right:t.right*i,top:t.top*r,bottom:t.bottom*r}}function no(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function ao(e){e.display.externalMeasure=null,c(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&&h?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function so(){return b&&h?-(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 C=pa(t);i.top+=C,i.bottom+=C}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 C=e.display.sizer.getBoundingClientRect();r+=C.left,n+=C.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=pt(e.doc,t.line)),Hn(e,r,to(e,r,t.ch,n),i)}function Jr(e,t,i,r,n,C){r=r||pt(e.doc,t.line),n||(n=Xi(e,r));function B(Re,Be){var ze=ni(e,n,Re,Be?"right":"left",C);return Be?ze.left=ze.right:ze.right=ze.left,Hn(e,r,ze,i)}var K=rt(r,e.doc.direction),Y=t.ch,Q=t.sticky;if(Y>=r.text.length?(Y=r.text.length,Q="before"):Y<=0&&(Y=0,Q="after"),!K)return B(Q=="before"?Y-1:Y,Q=="before");function oe(Re,Be,ze){var Je=K[Be],st=Je.level==1;return B(ze?Re-1:Re,st!=ze)}var le=tt(K,Y,Q),be=Qe,ye=oe(Y,le,Q=="before");return be!=null&&(ye.other=oe(Y,be,Q!="before")),ye}function uo(e,t){var i=0;t=l(e.doc,t),e.options.lineWrapping||(i=$i(e.display)*t.ch);var r=pt(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 C=je(e,t,i);return C.xRel=n,r&&(C.outside=r),C}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=Ur(r,i),C=r.first+r.size-1;if(n>C)return ga(r.first+r.size-1,pt(r,C).text.length,null,1,1);t<0&&(t=0);for(var B=pt(r,n);;){var K=zs(e,B,n,t,i),Y=ti(B,K.ch+(K.xRel>0||K.outside>0?1:0));if(!Y)return K;var Q=Y.find(1);if(Q.line==n)return Q;B=pt(r,n=Q.line)}}function ho(e,t,i,r){r-=pa(t);var n=t.text.length,C=at(function(B){return ni(e,i,B-1).bottom<=r},n,0);return n=at(function(B){return ni(e,i,B).top>r},C,n),{begin:C,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 zs(e,t,i,r,n){n-=$r(t);var C=Xi(e,t),B=pa(t),K=0,Y=t.text.length,Q=!0,oe=rt(t,e.doc.direction);if(oe){var le=(e.options.lineWrapping?Ks:Gs)(e,t,i,C,oe,r,n);Q=le.level!=1,K=Q?le.from:le.to-1,Y=Q?le.to:le.from-1}var be=null,ye=null,Re=at(function(Tt){var Et=ni(e,C,Tt);return Et.top+=B,Et.bottom+=B,ya(Et,r,n,!1)?(Et.top<=n&&Et.left<=r&&(be=Tt,ye=Et),!0):!1},K,Y),Be,ze,Je=!1;if(ye){var st=r-ye.left<ye.right-r,Ze=st==Q;Re=be+(Ze?0:1),ze=Ze?"after":"before",Be=st?ye.left:ye.right}else{!Q&&(Re==Y||Re==K)&&Re++,ze=Re==0?"after":Re==t.text.length?"before":ni(e,C,Re-(Q?1:0)).bottom+B<=n==Q?"after":"before";var dt=Jr(e,je(i,Re,ze),"line",t,C);Be=dt.left,Je=n<dt.top?-1:n>=dt.bottom?1:0}return Re=Me(t.text,Re,1),ga(i,Re,ze,Je,r-Be)}function Gs(e,t,i,r,n,C,B){var K=at(function(le){var be=n[le],ye=be.level!=1;return ya(Jr(e,je(i,ye?be.to:be.from,ye?"before":"after"),"line",t,r),C,B,!0)},0,n.length-1),Y=n[K];if(K>0){var Q=Y.level!=1,oe=Jr(e,je(i,Q?Y.from:Y.to,Q?"after":"before"),"line",t,r);ya(oe,C,B,!0)&&oe.top>B&&(Y=n[K-1])}return Y}function Ks(e,t,i,r,n,C,B){var K=ho(e,t,r,B),Y=K.begin,Q=K.end;/\s/.test(t.text.charAt(Q-1))&&Q--;for(var oe=null,le=null,be=0;be<n.length;be++){var ye=n[be];if(ye.from>=Q||ye.to<=Y)continue;var Re=ye.level!=1,Be=ni(e,r,Re?Math.min(Q,ye.to)-1:Math.max(Y,ye.from)).right,ze=Be<C?C-Be+1e9:Be-C;(!oe||le>ze)&&(oe=ye,le=ze)}return oe||(oe=n[n.length-1]),oe.from<Y&&(oe={from:Y,to:oe.to,level:oe.level}),oe.to>Q&&(oe={from:oe.from,to:Q,level:oe.level}),oe}var Ii;function Yi(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Ii==null){Ii=a("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Ii.appendChild(document.createTextNode("x")),Ii.appendChild(a("br"));Ii.appendChild(document.createTextNode("x"))}s(e.measure,Ii);var i=Ii.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),c(e.measure),i||1}function $i(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=a("span","xxxxxxxxxx"),i=a("pre",[t],"CodeMirror-line-like");s(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,C=t.gutters.firstChild,B=0;C;C=C.nextSibling,++B){var K=e.display.gutterSpecs[B].className;i[K]=C.offsetLeft+C.clientLeft+n,r[K]=C.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 C=0;if(n.widgets)for(var B=0;B<n.widgets.length;B++)n.widgets[B].height&&(C+=n.widgets[B].height);return i?C+(Math.ceil(n.text.length/r)||1)*t:C+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&&ge(t).getAttribute("cm-not-content")=="true")return null;var C,B,K=n.lineSpace.getBoundingClientRect();try{C=t.clientX-K.left,B=t.clientY-K.top}catch(le){return null}var Y=va(e,C,B),Q;if(r&&Y.xRel>0&&(Q=pt(e.doc,Y.line).text).length==Y.ch){var oe=q(Q,Q.length,e.options.tabSize)-Q.length;Y=je(Y.line,Math.max(0,Math.round((C-qa(e.display).left)/$i(e.display))-oe))}return Y}function Bi(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var i=e.display.view,r=0;r<i.length;r++)if(t-=i[r].size,t<0)return r}function 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&&Ti(e);else if(i<=n.viewFrom)nr&&Si(e.doc,i+r)>n.viewFrom?Ti(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)Ti(e);else if(t<=n.viewFrom){var C=zn(e,i,i+r,1);C?(n.view=n.view.slice(C.index),n.viewFrom=C.lineN,n.viewTo+=r):Ti(e)}else if(i>=n.viewTo){var B=zn(e,t,t,-1);B?(n.view=n.view.slice(0,B.index),n.viewTo=B.lineN):Ti(e)}else{var K=zn(e,t,t,-1),Y=zn(e,i,i+r,1);K&&Y?(n.view=n.view.slice(0,K.index).concat(Lr(e,K.lineN,Y.lineN)).concat(n.view.slice(Y.index)),n.viewTo+=r):Ti(e)}var Q=n.externalMeasured;Q&&(i<Q.lineN?Q.lineN+=r:t<Q.lineN+Q.size&&(n.externalMeasured=null))}function Ci(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 C=r.view[Bi(e,t)];if(C.node==null)return;var B=C.changes||(C.changes=[]);ce(B,i)==-1&&B.push(i)}function Ti(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function zn(e,t,i,r){var n=Bi(e,t),C,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;C=K+B[n].size-t,n++}else C=K-t;t+=C,i+=C}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=Lr(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=Lr(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(Lr(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(),C=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,C)}return r}function go(e,t,i){var r=Jr(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),n=i.appendChild(a("div","\xA0","CodeMirror-cursor"));if(n.style.left=r.left+"px",n.style.top=r.top+"px",n.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var C=i.appendChild(a("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));C.style.display="",C.style.left=r.other.left+"px",C.style.top=r.other.top+"px",C.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function Gn(e,t){return e.top-t.top||e.left-t.left}function Xs(e,t,i){var r=e.display,n=e.doc,C=document.createDocumentFragment(),B=qa(e.display),K=B.left,Y=Math.max(r.sizerWidth,Mi(e)-r.sizer.offsetLeft)-B.right,Q=n.direction=="ltr";function oe(Ze,dt,Tt,Et){dt<0&&(dt=0),dt=Math.round(dt),Et=Math.round(Et),C.appendChild(a("div",null,"CodeMirror-selected","position: absolute; left: "+Ze+`px;
|
|
top: `+dt+"px; width: "+(Tt==null?Y-Ze:Tt)+`px;
|
|
height: `+(Et-dt)+"px"))}function le(Ze,dt,Tt){var Et=pt(n,Ze),Rt=Et.text.length,Vt,lr;function $t(er,Rr){return ma(e,je(Ze,er),"div",Et,Rr)}function Ir(er,Rr,fr){var ir=co(e,Et,null,er),tr=Rr=="ltr"==(fr=="after")?"left":"right",Jt=fr=="after"?ir.begin:ir.end-(/\s/.test(Et.text.charAt(ir.end-1))?2:1);return $t(Jt,tr)[tr]}var Dr=rt(Et,n.direction);return qe(Dr,dt||0,Tt==null?Rt:Tt,function(er,Rr,fr,ir){var tr=fr=="ltr",Jt=$t(er,tr?"left":"right"),_r=$t(Rr-1,tr?"right":"left"),un=dt==null&&er==0,Ri=Tt==null&&Rr==Rt,xr=ir==0,ai=!Dr||ir==Dr.length-1;if(_r.top-Jt.top<=3){var ur=(Q?un:Ri)&&xr,Va=(Q?Ri:un)&&ai,di=ur?K:(tr?Jt:_r).left,Hi=Va?Y:(tr?_r:Jt).right;oe(di,Jt.top,Hi-di,Jt.bottom)}else{var zi,Tr,hn,Xa;tr?(zi=Q&&un&&xr?K:Jt.left,Tr=Q?Y:Ir(er,fr,"before"),hn=Q?K:Ir(Rr,fr,"after"),Xa=Q&&Ri&&ai?Y:_r.right):(zi=Q?Ir(er,fr,"before"):K,Tr=!Q&&un&&xr?Y:Jt.right,hn=!Q&&Ri&&ai?K:_r.left,Xa=Q?Ir(Rr,fr,"after"):Y),oe(zi,Jt.top,Tr-zi,Jt.bottom),Jt.bottom<_r.top&&oe(K,Jt.bottom,null,_r.top),oe(hn,_r.top,Xa-hn,_r.bottom)}(!Vt||Gn(Jt,Vt)<0)&&(Vt=Jt),Gn(_r,Vt)<0&&(Vt=_r),(!lr||Gn(Jt,lr)<0)&&(lr=Jt),Gn(_r,lr)<0&&(lr=_r)}),{start:Vt,end:lr}}var be=t.from(),ye=t.to();if(be.line==ye.line)le(be.line,be.ch,ye.ch);else{var Re=pt(n,be.line),Be=pt(n,ye.line),ze=Sr(Re)==Sr(Be),Je=le(be.line,be.ch,ze?Re.text.length+1:null).end,st=le(ye.line,ze?0:null,ye.ch).start;ze&&(Je.top<st.top-2?(oe(Je.right,Je.top,null,Je.bottom),oe(K,st.top,st.left,st.bottom)):oe(Je.right,Je.top,st.left-Je.right,Je.bottom)),Je.bottom<st.top&&oe(K,Je.bottom,null,st.top)}i.appendChild(C)}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()||Ji(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(),Ca(e))}function yo(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Ji(e))},100)}function Ca(e,t){if(e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),e.options.readOnly=="nocursor")return;e.state.focused||(Ae(e,"focus",e,t),e.state.focused=!0,H(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 Ji(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(Ae(e,"blur",e,t),e.state.focused=!1,p(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],C=e.options.lineWrapping,B=void 0,K=0;if(n.hidden)continue;if(z&&U<8){var Y=n.node.offsetTop+n.node.offsetHeight;B=Y-i,i=Y}else{var Q=n.node.getBoundingClientRect();B=Q.bottom-Q.top,!C&&n.text.firstChild&&(K=n.text.firstChild.getBoundingClientRect().right-Q.left-1)}var oe=n.line.height-B;if((oe>.005||oe<-.005)&&(mr(n.line,B),bo(n.line),n.rest))for(var le=0;le<n.rest.length;le++)bo(n.rest[le]);if(K>e.display.sizerWidth){var be=Math.ceil(K/$i(e.display));be>e.display.maxLineLength&&(e.display.maxLineLength=be,e.display.maxLine=n.line,e.display.maxLineChanged=!0)}}}function bo(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t){var i=e.widgets[t],r=i.node.parentNode;r&&(i.height=r.offsetHeight)}}function Vn(e,t,i){var r=i&&i.top!=null?Math.max(0,i.top):e.scroller.scrollTop;r=Math.floor(r-Wn(e));var n=i&&i.bottom!=null?i.bottom:r+e.wrapper.clientHeight,C=Ur(t,r),B=Ur(t,n);if(i&&i.ensure){var K=i.ensure.from.line,Y=i.ensure.to.line;K<C?(C=K,B=Ur(t,$r(pt(t,K))+e.wrapper.clientHeight)):Math.min(Y,t.lastLine())>=B&&(C=Ur(t,$r(pt(t,Y))-e.wrapper.clientHeight),B=Y)}return{from:C,to:Math.max(B,C+1)}}function Ys(e,t){if(Ue(e,"scrollCursorIntoView"))return;var i=e.display,r=i.sizer.getBoundingClientRect(),n=null;if(t.top+r.top<0?n=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(n=!1),n!=null&&!w){var C=a("div","\u200B",null,`position: absolute;
|
|
top: `+(t.top-i.viewOffset-Wn(e.display))+`px;
|
|
height: `+(t.bottom-t.top+ii(e)+i.barHeight)+`px;
|
|
left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(C),C.scrollIntoView(n),e.display.lineSpace.removeChild(C)}}function $s(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(t=t.ch?je(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,i=t.sticky=="before"?je(t.line,t.ch+1,"before"):t);for(var C=0;C<5;C++){var B=!1,K=Jr(e,t),Y=!i||i==t?K:Jr(e,i);n={left:Math.min(K.left,Y.left),top:Math.min(K.top,Y.top)-r,right:Math.max(K.left,Y.left),bottom:Math.max(K.bottom,Y.bottom)+r};var Q=Ta(e,n),oe=e.doc.scrollTop,le=e.doc.scrollLeft;if(Q.scrollTop!=null&&(En(e,Q.scrollTop),Math.abs(e.doc.scrollTop-oe)>1&&(B=!0)),Q.scrollLeft!=null&&(Ui(e,Q.scrollLeft),Math.abs(e.doc.scrollLeft-le)>1&&(B=!0)),!B)break}return n}function Js(e,t){var i=Ta(e,t);i.scrollTop!=null&&En(e,i.scrollTop),i.scrollLeft!=null&&Ui(e,i.scrollLeft)}function Ta(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,C=ca(e),B={};t.bottom-t.top>C&&(t.bottom=t.top+C);var K=e.doc.height+da(i),Y=t.top<r,Q=t.bottom>K-r;if(t.top<n)B.scrollTop=Y?0:t.top;else if(t.bottom>n+C){var oe=Math.min(t.top,(Q?K:t.bottom)-C);oe!=n&&(B.scrollTop=oe)}var le=e.options.fixedGutter?0:i.gutters.offsetWidth,be=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-le,ye=Mi(e)-i.gutters.offsetWidth,Re=t.right-t.left>ye;return Re&&(t.right=t.left+ye),t.left<10?B.scrollLeft=0:t.left<be?B.scrollLeft=Math.max(0,t.left+le-(Re?0:10)):t.right>ye+be-3&&(B.scrollLeft=t.right+(Re?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 Zi(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 Zs(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=Ta(e,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-r,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+r});xn(e,n.scrollLeft,n.scrollTop)}function En(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;D||Aa(e,{top:t}),Eo(e,t,!0),D&&Aa(e),Tn(e,100)}function Eo(e,t,i){if(t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!i)return;e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t)}function Ui(e,t,i,r){if(t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(i?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)return;e.doc.scrollLeft=t,Lo(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function Sn(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+da(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?i:0,docHeight:r,scrollHeight:r+ii(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var Fi=function(e,t,i){this.cm=i;var r=this.vert=a("div",[a("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=a("div",[a("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),we(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),we(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,z&&U<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Fi.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(i){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var n=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+n)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=i?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var C=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+C)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(r==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:i?r:0,bottom:t?r:0}},Fi.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Fi.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Fi.prototype.zeroWidthHack=function(){var e=u&&!L?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new ie,this.disableVert=new ie},Fi.prototype.enableZeroWidthBar=function(e,t,i){e.style.pointerEvents="auto";function r(){var n=e.getBoundingClientRect(),C=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);C!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},Fi.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Cn=function(){};Cn.prototype.update=function(){return{bottom:0,right:0}},Cn.prototype.setScrollLeft=function(){},Cn.prototype.setScrollTop=function(){},Cn.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 Co={native:Fi,null:Cn};function To(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&p(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Co[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),we(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,i){i=="horizontal"?Ui(e,t):En(e,t)},e),e.display.scrollbars.addClass&&H(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},Kr(e.curOp)}function Wi(e){var t=e.curOp;t&&_s(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 C=0;C<t.length;C++)il(t[C]);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&&La(e.cm,e.update)}function rl(e){var t=e.cm,i=t.display;e.updatedDisplay&&Kn(t),e.barMeasure=Sn(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=to(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+ii(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-Mi(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=i.input.prepareSelection())}function il(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Ui(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var i=e.focus&&e.focus==_();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,i),(e.updatedDisplay||e.startHeight!=t.doc.height)&&Qi(t,e.barMeasure),e.updatedDisplay&&Da(t,e.barMeasure),e.selectionChanged&&Sa(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),i&&vo(e.cm)}function nl(e){var t=e.cm,i=t.display,r=t.doc;if(e.updatedDisplay&&wo(t,e.update),i.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(i.wheelStartX=i.wheelStartY=null),e.scrollTop!=null&&Eo(t,e.scrollTop,e.forceScroll),e.scrollLeft!=null&&Ui(t,e.scrollLeft,!0,!0),e.scrollToPos){var n=$s(t,l(r,e.scrollToPos.from),l(r,e.scrollToPos.to),e.scrollToPos.margin);Ys(t,n)}var C=e.maybeHiddenMarkers,B=e.maybeUnhiddenMarkers;if(C)for(var K=0;K<C.length;++K)C[K].lines.length||Ae(C[K],"hide");if(B)for(var Y=0;Y<B.length;++Y)B[Y].lines.length&&Ae(B[Y],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Ae(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Mr(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 Cr(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 Tn(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,G(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var i=+new Date+e.options.workTime,r=Ye(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(C){if(r.line>=e.display.viewFrom){var B=C.styles,K=C.text.length>e.options.maxHighlightLength?Br(t.mode,r.state):null,Y=de(e,C,r,!0);K&&(r.state=K),C.styles=Y.styles;var Q=C.styleClasses,oe=Y.classes;oe?C.styleClasses=oe:Q&&(C.styleClasses=null);for(var le=!B||B.length!=C.styles.length||Q!=oe&&(!Q||!oe||Q.bgClass!=oe.bgClass||Q.textClass!=oe.textClass),be=0;!le&&be<B.length;++be)le=B[be]!=C.styles[be];le&&n.push(r.line),C.stateAfter=r.save(),r.nextLine()}else C.text.length<=e.options.maxHighlightLength&&mt(e,C.text,r),C.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>i)return Tn(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),n.length&&Mr(e,function(){for(var C=0;C<n.length;C++)Ci(e,n[C],"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){he(e,t)&&this.events.push(arguments)},Yn.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Ae.apply(null,this.events[e])};function ol(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=ii(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=ii(e)+"px",t.scrollbarsClipped=!0)}function sl(e){if(e.hasFocus())return null;var t=_();if(!t||!E(e.display.lineDiv,t))return null;var i={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&E(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==_())return;if(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&E(document.body,e.anchorNode)&&E(document.body,e.focusNode)){var t=window.getSelection(),i=document.createRange();i.setEnd(e.anchorNode,e.anchorOffset),i.collapse(!1),t.removeAllRanges(),t.addRange(i),t.extend(e.focusNode,e.focusOffset)}}function La(e,t){var i=e.display,r=e.doc;if(t.editorIsHidden)return Ti(e),!1;if(!t.force&&t.visible.from>=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&po(e)==0)return!1;Ao(e)&&(Ti(e),t.dims=ba(e));var n=r.first+r.size,C=Math.max(t.visible.from-e.options.viewportMargin,r.first),B=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFrom<C&&C-i.viewFrom<20&&(C=Math.max(r.first,i.viewFrom)),i.viewTo>B&&i.viewTo-B<20&&(B=Math.min(n,i.viewTo)),nr&&(C=cn(e.doc,C),B=Si(e.doc,B));var K=C!=i.viewFrom||B!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,C,B),i.viewOffset=$r(pt(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var Y=po(e);if(!K&&Y==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var Q=sl(e);return Y>4&&(i.lineDiv.style.display="none"),ul(e,i.updateLineNumbers,t.dims),Y>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,ll(Q),c(i.cursorDiv),c(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,K&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,Tn(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(!La(e,t))break;Kn(e);var n=Sn(e);bn(e),Qi(e,n),Da(e,n),t.force=!1}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function Aa(e,t){var i=new Yn(e,t);if(La(e,i)){Kn(e),wo(e,i);var r=Sn(e);bn(e),Qi(e,r),Da(e,r),i.finish()}}function ul(e,t,i){var r=e.display,n=e.options.lineNumbers,C=r.lineDiv,B=C.firstChild;function K(Re){var Be=Re.nextSibling;return P&&u&&e.display.currentWheelTarget==Re?Re.style.display="none":Re.parentNode.removeChild(Re),Be}for(var Y=r.view,Q=r.viewFrom,oe=0;oe<Y.length;oe++){var le=Y[oe];if(!le.hidden)if(!le.node||le.node.parentNode!=C){var be=Ns(e,le,Q,i);C.insertBefore(be,B)}else{for(;B!=le.node;)B=K(B);var ye=n&&t!=null&&t<=Q&&le.lineNumber;le.changes&&(ce(le.changes,"gutter")>-1&&(ye=!1),Ya(e,le,Q,i)),ye&&(c(le.lineNumber),le.lineNumber.appendChild(document.createTextNode(fi(e.options,Q)))),B=le.node.nextSibling}Q+=le.size}for(;B;)B=K(B)}function ka(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function Da(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+ii(e)+"px"}function Lo(e){var t=e.display,i=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;for(var r=xa(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,C=r+"px",B=0;B<i.length;B++)if(!i[B].hidden){e.options.fixedGutter&&(i[B].gutter&&(i[B].gutter.style.left=C),i[B].gutterBackground&&(i[B].gutterBackground.style.left=C));var K=i[B].alignable;if(K)for(var Y=0;Y<K.length;Y++)K[Y].style.left=C}e.options.fixedGutter&&(t.gutters.style.left=r+n+"px")}function Ao(e){if(!e.options.lineNumbers)return!1;var t=e.doc,i=fi(e.options,t.first+t.size-1),r=e.display;if(i.length!=r.lineNumChars){var n=r.measure.appendChild(a("div",[a("div",i)],"CodeMirror-linenumber CodeMirror-gutter-elt")),C=n.firstChild.offsetWidth,B=n.offsetWidth-C;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(C,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 Ra(e,t){for(var i=[],r=!1,n=0;n<e.length;n++){var C=e[n],B=null;if(typeof C!="string"&&(B=C.style,C=C.className),C=="CodeMirror-linenumbers")if(t)r=!0;else continue;i.push({className:C,style:B})}return t&&!r&&i.push({className:"CodeMirror-linenumbers",style:null}),i}function ko(e){var t=e.gutters,i=e.gutterSpecs;c(t),e.lineGutter=null;for(var r=0;r<i.length;++r){var n=i[r],C=n.className,B=n.style,K=t.appendChild(a("div",null,"CodeMirror-gutter "+C));B&&(K.style.cssText=B),C=="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),Lo(e)}function hl(e,t,i,r){var n=this;this.input=i,n.scrollbarFiller=a("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=a("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=v("div",null,"CodeMirror-code"),n.selectionDiv=a("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=a("div",null,"CodeMirror-cursors"),n.measure=a("div",null,"CodeMirror-measure"),n.lineMeasure=a("div",null,"CodeMirror-measure"),n.lineSpace=v("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var C=v("div",[n.lineSpace],"CodeMirror-lines");n.mover=a("div",[C],null,"position: relative"),n.sizer=a("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=a("div",null,null,"position: absolute; height: "+ve+"px; width: 1px;"),n.gutters=a("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=a("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=a("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),z&&U<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!P&&!(D&&o)&&(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,n.gutterSpecs=Ra(r.gutters,r.lineNumbers),ko(n),i.init(n)}var $n=0,jr=null;z?jr=-.53:D?jr=15:b?jr=-.7:R&&(jr=-1/3);function Do(e){var t=e.wheelDeltaX,i=e.wheelDeltaY;return t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),i==null&&e.detail&&e.axis==e.VERTICAL_AXIS?i=e.detail:i==null&&(i=e.wheelDelta),{x:t,y:i}}function dl(e){var t=Do(e);return t.x*=jr,t.y*=jr,t}function Ro(e,t){var i=Do(t),r=i.x,n=i.y,C=e.display,B=C.scroller,K=B.scrollWidth>B.clientWidth,Y=B.scrollHeight>B.clientHeight;if(!(r&&K||n&&Y))return;if(n&&u&&P){e:for(var Q=t.target,oe=C.view;Q!=B;Q=Q.parentNode)for(var le=0;le<oe.length;le++)if(oe[le].node==Q){e.display.currentWheelTarget=Q;break e}}if(r&&!D&&!A&&jr!=null){n&&Y&&En(e,Math.max(0,B.scrollTop+n*jr)),Ui(e,Math.max(0,B.scrollLeft+r*jr)),(!n||n&&Y)&&ee(t),C.wheelStartX=null;return}if(n&&jr!=null){var be=n*jr,ye=e.doc.scrollTop,Re=ye+C.wrapper.clientHeight;be<0?ye=Math.max(0,ye+be-50):Re=Math.min(e.doc.height,Re+be+50),Aa(e,{top:ye,bottom:Re})}$n<20&&(C.wheelStartX==null?(C.wheelStartX=B.scrollLeft,C.wheelStartY=B.scrollTop,C.wheelDX=r,C.wheelDY=n,setTimeout(function(){if(C.wheelStartX==null)return;var Be=B.scrollLeft-C.wheelStartX,ze=B.scrollTop-C.wheelStartY,Je=ze&&C.wheelDY&&ze/C.wheelDY||Be&&C.wheelDX&&Be/C.wheelDX;if(C.wheelStartX=C.wheelStartY=null,!Je)return;jr=(jr*$n+Je)/($n+1),++$n},200)):(C.wheelDX+=r,C.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 Ht(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(Lt(t,r.from())>=0&&Lt(e,r.to())<=0)return i}return-1};var Ht=function(e,t){this.anchor=e,this.head=t};Ht.prototype.from=function(){return vi(this.anchor,this.head)},Ht.prototype.to=function(){return gi(this.anchor,this.head)},Ht.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function Zr(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(be,ye){return Lt(be.from(),ye.from())}),i=ce(t,n);for(var C=1;C<t.length;C++){var B=t[C],K=t[C-1],Y=Lt(K.to(),B.from());if(r&&!B.empty()?Y>0:Y>=0){var Q=vi(K.from(),B.from()),oe=gi(K.to(),B.to()),le=K.empty()?B.from()==B.head:K.from()==K.head;C<=i&&--i,t.splice(--C,2,new Ht(le?oe:Q,le?Q:oe))}}return new Wr(t,i)}function wi(e,t){return new Wr([new Ht(e,t||e)],0)}function Li(e){return e.text?je(e.from.line+e.text.length-1,Le(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function _o(e,t){if(Lt(e,t.from)<0)return e;if(Lt(e,t.to)<=0)return Li(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+=Li(t).ch-t.to.ch),je(i,r)}function _a(e,t){for(var i=[],r=0;r<e.sel.ranges.length;r++){var n=e.sel.ranges[r];i.push(new Ht(_o(n.anchor,t),_o(n.head,t)))}return Zr(e.cm,i,e.sel.primIndex)}function Oo(e,t,i){return e.line==t.line?je(i.line,e.ch-t.ch+i.ch):je(i.line+(e.line-t.line),e.ch)}function cl(e,t,i){for(var r=[],n=je(e.first,0),C=n,B=0;B<t.length;B++){var K=t[B],Y=Oo(K.from,n,C),Q=Oo(Li(K),n,C);if(n=K.to,C=Q,i=="around"){var oe=e.sel.ranges[B],le=Lt(oe.head,oe.anchor)<0;r[B]=new Ht(le?Q:Y,le?Y:Q)}else r[B]=new Ht(Y,Y)}return new Wr(r,e.sel.primIndex)}function Oa(e){e.doc.mode=Nr(e.options,e.doc.modeOption),Ln(e)}function Ln(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,Tn(e,100),e.state.modeGen++,e.curOp&&Ar(e)}function Po(e,t){return t.from.ch==0&&t.to.ch==0&&Le(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Pa(e,t,i,r){function n(st){return i?i[st]:null}function C(st,Ze,dt){ua(st,Ze,dt,r),cr(st,"change",st,t)}function B(st,Ze){for(var dt=[],Tt=st;Tt<Ze;++Tt)dt.push(new Pi(Q[Tt],n(Tt),r));return dt}var K=t.from,Y=t.to,Q=t.text,oe=pt(e,K.line),le=pt(e,Y.line),be=Le(Q),ye=n(Q.length-1),Re=Y.line-K.line;if(t.full)e.insert(0,B(0,Q.length)),e.remove(Q.length,e.size-Q.length);else if(Po(e,t)){var Be=B(0,Q.length-1);C(le,le.text,ye),Re&&e.remove(K.line,Re),Be.length&&e.insert(K.line,Be)}else if(oe==le)if(Q.length==1)C(oe,oe.text.slice(0,K.ch)+be+oe.text.slice(Y.ch),ye);else{var ze=B(1,Q.length-1);ze.push(new Pi(be+oe.text.slice(Y.ch),ye,r)),C(oe,oe.text.slice(0,K.ch)+Q[0],n(0)),e.insert(K.line+1,ze)}else if(Q.length==1)C(oe,oe.text.slice(0,K.ch)+Q[0]+le.text.slice(Y.ch),n(0)),e.remove(K.line+1,Re);else{C(oe,oe.text.slice(0,K.ch)+Q[0],n(0)),C(le,be+le.text.slice(Y.ch),ye);var Je=B(1,Q.length-1);Re>1&&e.remove(K.line+1,Re-1),e.insert(K.line+1,Je)}cr(e,"change",e,t)}function Ai(e,t,i){function r(n,C,B){if(n.linked)for(var K=0;K<n.linked.length;++K){var Y=n.linked[K];if(Y.doc==C)continue;var Q=B&&Y.sharedHist;if(i&&!Q)continue;t(Y.doc,Q),r(Y.doc,n,Q)}}r(e,null,!0)}function Mo(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,Ea(e),Oa(e),Io(e),e.options.lineWrapping||jn(e),e.options.mode=t.modeOption,Ar(e)}function Io(e){(e.doc.direction=="rtl"?H:p)(e.display.lineDiv,"CodeMirror-rtl")}function fl(e){Mr(e,function(){Io(e),Ar(e)})}function Jn(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:Li(t),text:zr(e,t.from,t.to)};return Uo(e,i,t.from.line,t.to.line+1),Ai(e,function(r){return Uo(r,i,t.from.line,t.to.line+1)},!0),i}function No(e){for(;e.length;){var t=Le(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return No(e.done),Le(e.done);if(e.done.length&&!Le(e.done).ranges)return Le(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),Le(e.done)}function Bo(e,t,i,r){var n=e.history;n.undone.length=0;var C=+new Date,B,K;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>C-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(B=pl(n,n.lastOp==r)))K=Le(B.changes),Lt(t.from,t.to)==0&&Lt(t.from,K.to)==0?K.to=Li(t):B.changes.push(Ma(e,t));else{var Y=Le(n.done);for((!Y||!Y.ranges)&&Zn(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=C,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,K||Ae(e,"historyAdded")}function ml(e,t,i,r){var n=t.charAt(0);return n=="*"||n=="+"&&i.ranges.length==r.ranges.length&&i.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function gl(e,t,i,r){var n=e.history,C=r&&r.origin;i==n.lastSelOp||C&&n.lastSelOrigin==C&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==C||ml(e,C,Le(n.done),t))?n.done[n.done.length-1]=t:Zn(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=C,n.lastSelOp=i,r&&r.clearRedo!==!1&&No(n.undone)}function Zn(e,t){var i=Le(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Uo(e,t,i,r){var n=t["spans_"+e.id],C=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]={}))[C]=B.markedSpans),++C})}function vl(e){if(!e)return null;for(var t,i=0;i<e.length;++i)e[i].marker.explicitlyCleared?t||(t=e.slice(0,i)):t&&t.push(e[i]);return t?t.length?t:null:e}function yl(e,t){var i=t["spans_"+e.id];if(!i)return null;for(var r=[],n=0;n<t.text.length;++n)r.push(vl(i[n]));return r}function Fo(e,t){var i=yl(e,t),r=Yr(e,t);if(!i)return r;if(!r)return i;for(var n=0;n<i.length;++n){var C=i[n],B=r[n];if(C&&B){e:for(var K=0;K<B.length;++K){for(var Y=B[K],Q=0;Q<C.length;++Q)if(C[Q].marker==Y.marker)continue e;C.push(Y)}}else B&&(i[n]=B)}return i}function qi(e,t,i){for(var r=[],n=0;n<e.length;++n){var C=e[n];if(C.ranges){r.push(i?Wr.prototype.deepCopy.call(C):C);continue}var B=C.changes,K=[];r.push({changes:K});for(var Y=0;Y<B.length;++Y){var Q=B[Y],oe=void 0;if(K.push({from:Q.from,to:Q.to,text:Q.text}),t)for(var le in Q)(oe=le.match(/^spans_(\d+)$/))&&(ce(t,Number(oe[1]))>-1&&(Le(K)[le]=Q[le],delete Q[le]))}}return r}function Ia(e,t,i,r){if(r){var n=e.anchor;if(i){var C=Lt(t,n)<0;C!=Lt(i,n)<0?(n=t,t=i):C!=Lt(t,i)<0&&(t=i)}return new Ht(n,t)}else return new Ht(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),C=0;C<e.sel.ranges.length;C++)r[C]=Ia(e.sel.ranges[C],t[C],null,n);var B=Zr(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,Zr(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 C=0;C<n.length;C++)this.ranges[C]=new Ht(l(e,n[C].anchor),l(e,n[C].head))},origin:i&&i.origin};return Ae(e,"beforeSelectionChange",e,r),e.cm&&Ae(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?Zr(e.cm,r.ranges,r.ranges.length-1):t}function Ho(e,t,i){var r=e.history.done,n=Le(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){(he(e,"beforeSelectionChange")||e.cm&&he(e.cm,"beforeSelectionChange"))&&(t=bl(e,t,i));var r=i&&i.bias||(Lt(t.primary().head,e.sel.primary().head)<0?-1:1);zo(e,Ko(e,t,r,!0)),!(i&&i.scroll===!1)&&e.cm&&Zi(e.cm)}function zo(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,me(e.cm)),cr(e,"cursorActivity",e)}function Go(e){zo(e,Ko(e,e.sel,null,!1))}function Ko(e,t,i,r){for(var n,C=0;C<t.ranges.length;C++){var B=t.ranges[C],K=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[C],Y=ea(e,B.anchor,K&&K.anchor,i,r),Q=ea(e,B.head,K&&K.head,i,r);(n||Y!=B.anchor||Q!=B.head)&&(n||(n=t.ranges.slice(0,C)),n[C]=new Ht(Y,Q))}return n?Zr(e.cm,n,t.primIndex):t}function en(e,t,i,r,n){var C=pt(e,t.line);if(C.markedSpans)for(var B=0;B<C.markedSpans.length;++B){var K=C.markedSpans[B],Y=K.marker,Q="selectLeft"in Y?!Y.selectLeft:Y.inclusiveLeft,oe="selectRight"in Y?!Y.selectRight:Y.inclusiveRight;if((K.from==null||(Q?K.from<=t.ch:K.from<t.ch))&&(K.to==null||(oe?K.to>=t.ch:K.to>t.ch))){if(n&&(Ae(Y,"beforeCursorEnter"),Y.explicitlyCleared))if(C.markedSpans){--B;continue}else break;if(!Y.atomic)continue;if(i){var le=Y.find(r<0?1:-1),be=void 0;if((r<0?oe:Q)&&(le=Vo(e,le,-r,le&&le.line==t.line?C:null)),le&&le.line==t.line&&(be=Lt(le,i))&&(r<0?be<0:be>0))return en(e,le,t,r,n)}var ye=Y.find(r<0?-1:1);return(r<0?Q:oe)&&(ye=Vo(e,ye,r,ye.line==t.line?C:null)),ye?en(e,ye,t,r,n):null}}return t}function ea(e,t,i,r,n){var C=r||1,B=en(e,t,i,C,n)||!n&&en(e,t,i,C,!0)||en(e,t,i,-C,n)||!n&&en(e,t,i,-C,!0);return B||(e.cantEdit=!0,je(e.first,0))}function Vo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?l(e,je(t.line-1)):null:i>0&&t.ch==(r||pt(e,t.line)).text.length?t.line<e.first+e.size-1?je(t.line+1,0):null:new je(t.line,t.ch+i)}function Xo(e){e.setSelection(je(e.firstLine(),0),je(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,C,B,K){n&&(r.from=l(e,n)),C&&(r.to=l(e,C)),B&&(r.text=B),K!==void 0&&(r.origin=K)}),Ae(e,"beforeChange",e,r),e.cm&&Ae(e.cm,"beforeChange",e.cm,r),r.canceled?(e.cm&&(e.cm.curOp.updateInput=2),null):{from:r.from,to:r.to,text:r.text,origin:r.origin}}function tn(e,t,i){if(e.cm){if(!e.cm.curOp)return or(e.cm,tn)(e,t,i);if(e.cm.state.suppressEdits)return}if((he(e,"beforeChange")||e.cm&&he(e.cm,"beforeChange"))&&(t=Yo(e,t,!0),!t))return;var r=_i&&!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]==""&&Lt(t.from,t.to)==0)return;var i=_a(e,t);Bo(e,t,i,e.cm?e.cm.curOp.id:NaN),An(e,t,i,Yr(e,t));var r=[];Ai(e,function(n,C){!C&&ce(r,n.history)==-1&&(qo(n.history,t),r.push(n.history)),An(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,C,B=e.sel,K=t=="undo"?n.done:n.undone,Y=t=="undo"?n.undone:n.done,Q=0;Q<K.length&&!(C=K[Q],i?C.ranges&&!C.equals(e.sel):!C.ranges);Q++);if(Q==K.length)return;for(n.lastOrigin=n.lastSelOrigin=null;;)if(C=K.pop(),C.ranges){if(Zn(C,Y),i&&!C.equals(e.sel)){br(e,C,{clearRedo:!1});return}B=C}else if(r){K.push(C);return}else break;var oe=[];Zn(B,Y),Y.push({changes:oe,generation:n.generation}),n.generation=C.generation||++n.maxGeneration;for(var le=he(e,"beforeChange")||e.cm&&he(e.cm,"beforeChange"),be=function(Be){var ze=C.changes[Be];if(ze.origin=t,le&&!Yo(e,ze,!1))return K.length=0,{};oe.push(Ma(e,ze));var Je=Be?_a(e,ze):Le(K);An(e,ze,Je,Fo(e,ze)),!Be&&e.cm&&e.cm.scrollIntoView({from:ze.from,to:Li(ze)});var st=[];Ai(e,function(Ze,dt){!dt&&ce(st,Ze.history)==-1&&(qo(Ze.history,ze),st.push(Ze.history)),An(Ze,ze,null,Fo(Ze,ze))})},ye=C.changes.length-1;ye>=0;--ye){var Re=be(ye);if(Re)return Re.v}}function Jo(e,t){if(t==0)return;if(e.first+=t,e.sel=new Wr(Xe(e.sel.ranges,function(n){return new Ht(je(n.anchor.line+t,n.anchor.ch),je(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++)Ci(e.cm,r,"gutter")}}function An(e,t,i,r){if(e.cm&&!e.cm.curOp)return or(e.cm,An)(e,t,i,r);if(t.to.line<e.first){Jo(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);Jo(e,n),t={from:je(e.first,0),to:je(t.to.line+n,t.to.ch),text:[Le(t.text)],origin:t.origin}}var C=e.lastLine();t.to.line>C&&(t={from:t.from,to:je(C,pt(e,C).text.length),text:[t.text[0]],origin:t.origin}),t.removed=zr(e,t.from,t.to),i||(i=_a(e,t)),e.cm?xl(e.cm,t,r):Pa(e,t,r),qn(e,i,xe),e.cantEdit&&ea(e,je(e.firstLine(),0))&&(e.cantEdit=!1)}function xl(e,t,i){var r=e.doc,n=e.display,C=t.from,B=t.to,K=!1,Y=C.line;e.options.lineWrapping||(Y=Pt(Sr(pt(r,C.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&&me(e),Pa(r,t,i,fo(e)),e.options.lineWrapping||(r.iter(Y,C.line+t.text.length,function(ye){var Re=pn(ye);Re>n.maxLineLength&&(n.maxLine=ye,n.maxLineLength=Re,n.maxLineChanged=!0,K=!1)}),K&&(e.curOp.updateMaxLine=!0)),Xr(r,C.line),Tn(e,400);var Q=t.text.length-(B.line-C.line)-1;t.full?Ar(e):C.line==B.line&&t.text.length==1&&!Po(e.doc,t)?Ci(e,C.line,"text"):Ar(e,C.line,B.line+1,Q);var oe=he(e,"changes"),le=he(e,"change");if(le||oe){var be={from:C,to:B,text:t.text,removed:t.removed,origin:t.origin};le&&cr(e,"change",e,be),oe&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(be)}e.display.selForContextMenu=null}function rn(e,t,i,r,n){var C;r||(r=i),Lt(r,i)<0&&(C=[r,i],i=C[0],r=C[1]),typeof t=="string"&&(t=e.splitLines(t)),tn(e,{from:i,to:r,text:t,origin:n})}function Zo(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 C=e[n],B=!0;if(C.ranges){C.copied||(C=e[n]=C.deepCopy(),C.copied=!0);for(var K=0;K<C.ranges.length;K++)Zo(C.ranges[K].anchor,t,i,r),Zo(C.ranges[K].head,t,i,r);continue}for(var Y=0;Y<C.changes.length;++Y){var Q=C.changes[Y];if(i<Q.from.line)Q.from=je(Q.from.line+r,Q.from.ch),Q.to=je(Q.to.line+r,Q.to.ch);else if(t<=Q.to.line){B=!1;break}}B||(e.splice(0,n+1),n=0)}}function qo(e,t){var i=t.from.line,r=t.to.line,n=t.text.length-(r-i)-1;Qo(e.done,i,r,n),Qo(e.undone,i,r,n)}function kn(e,t,i,r){var n=t,C=t;return typeof t=="number"?C=pt(e,W(e,t)):n=Pt(t),n==null?null:(r(C,n)&&e.cm&&Ci(e.cm,n,i),C)}function Dn(e){this.lines=e,this.parent=null;for(var t=0,i=0;i<e.length;++i)e[i].parent=this,t+=e[i].height;this.height=t}Dn.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var i=e,r=e+t;i<r;++i){var n=this.lines[i];this.height-=n.height,vt(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 Rn(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}Rn.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 C=Math.min(t,n-e),B=r.height;if(r.removeInner(e,C),this.height-=B-r.height,n==C&&(this.children.splice(i--,1),r.parent=null),(t-=C)==0)break;e=0}else e-=n}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Dn))){var K=[];this.collapse(K),this.children=[new Dn(K)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,i){this.size+=t.length,this.height+=i;for(var r=0;r<this.children.length;++r){var n=this.children[r],C=n.chunkSize();if(e<=C){if(n.insertInner(e,t,i),n.lines&&n.lines.length>50){for(var B=n.lines.length%25+25,K=B;K<n.lines.length;){var Y=new Dn(n.lines.slice(K,K+=25));n.height-=Y.height,this.children.splice(++r,0,Y),Y.parent=this}n.lines=n.lines.slice(0,B),this.maybeSpill()}break}e-=C}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),i=new Rn(t);if(e.parent){e.size-=i.size,e.height-=i.height;var n=ce(e.parent.children,e);e.parent.children.splice(n+1,0,i)}else{var r=new Rn(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],C=n.chunkSize();if(e<C){var B=Math.min(t,C-e);if(n.iterN(e,B,i))return!0;if((t-=B)==0)break;e=0}else e-=C}}};var _n=function(e,t,i){if(i)for(var r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);this.doc=e,this.node=t};_n.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,i=this.line,r=Pt(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 C=vn(this);mr(i,Math.max(0,i.height-C)),e&&(Mr(e,function(){es(e,i,-C),Ci(e,r,"widget")}),cr(e,"lineWidgetCleared",e,this,r))},_n.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&&Mr(i,function(){i.curOp.forceUpdate=!0,es(i,r,n),cr(i,"lineWidgetChanged",i,e,Pt(r))})},fe(_n);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 _n(e,i,r),C=e.cm;return C&&n.noHScroll&&(C.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,C&&!ri(e,B)){var Y=$r(B)<e.scrollTop;mr(B,B.height+vn(n)),Y&&wa(C,n.height),C.curOp.forceUpdate=!0}return!0}),C&&cr(C,"lineWidgetAdded",C,n,typeof t=="number"?t:Pt(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),he(this,"clear")){var i=this.find();i&&cr(this,"clear",i.from,i.to)}for(var r=null,n=null,C=0;C<this.lines.length;++C){var B=this.lines[C],K=Pr(B.markedSpans,this);e&&!this.collapsed?Ci(e,Pt(B),"text"):e&&(K.to!=null&&(n=Pt(B)),K.from!=null&&(r=Pt(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 Q=Sr(this.lines[Y]),oe=pn(Q);oe>e.display.maxLineLength&&(e.display.maxLine=Q,e.display.maxLineLength=oe,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&Ar(e,r,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Go(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 C=this.lines[n],B=Pr(C.markedSpans,this);if(B.from!=null&&(i=je(t?C:Pt(C),B.from),e==-1))return i;if(B.to!=null&&(r=je(t?C:Pt(C),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;Mr(r,function(){var n=t.line,C=Pt(t.line),B=fa(r,C);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||ce(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},ki.prototype.detachLine=function(e){if(this.lines.splice(ce(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},fe(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 C=new ki(e,n),B=Lt(t,i);if(r&&j(r,C,!1),B>0||B==0&&C.clearWhenEmpty!==!1)return C;if(C.replacedWith&&(C.collapsed=!0,C.widgetNode=v("span",[C.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||C.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(C.widgetNode.insertLeft=!0)),C.collapsed){if(ar(e,t.line,t,i,C)||t.line!=i.line&&ar(e,i.line,t,i,C))throw new Error("Inserting collapsed marker partially overlapping an existing one");oi()}C.addToHistory&&Bo(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var K=t.line,Y=e.cm,Q;if(e.iter(K,i.line+1,function(le){Y&&C.collapsed&&!Y.options.lineWrapping&&Sr(le)==Y.display.maxLine&&(Q=!0),C.collapsed&&K!=t.line&&mr(le,0),yi(le,new si(C,K==t.line?t.ch:null,K==i.line?i.ch:null)),++K}),C.collapsed&&e.iter(t.line,i.line+1,function(le){ri(e,le)&&mr(le,0)}),C.clearOnEnter&&we(C,"beforeCursorEnter",function(){return C.clear()}),C.readOnly&&(Fr(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),C.collapsed&&(C.id=++ts,C.atomic=!0),Y){if(Q&&(Y.curOp.updateMaxLine=!0),C.collapsed)Ar(Y,t.line,i.line+1);else if(C.className||C.startStyle||C.endStyle||C.css||C.attributes||C.title)for(var oe=t.line;oe<=i.line;oe++)Ci(Y,oe,"text");C.atomic&&Go(Y.doc),cr(Y,"markerAdded",Y,C)}return C}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)},fe(On);function Sl(e,t,i,r,n){r=j(r),r.shared=!1;var C=[nn(e,t,i,r,n)],B=C[0],K=r.widgetNode;return Ai(e,function(Y){K&&(r.widgetNode=K.cloneNode(!0)),C.push(nn(Y,l(Y,t),l(Y,i),r,n));for(var Q=0;Q<Y.linked.length;++Q)if(Y.linked[Q].isParent)return;B=Le(C)}),new On(C,B)}function rs(e){return e.findMarks(je(e.first,0),e.clipPos(je(e.lastLine())),function(t){return t.parent})}function Cl(e,t){for(var i=0;i<t.length;i++){var r=t[i],n=r.find(),C=e.clipPos(n.from),B=e.clipPos(n.to);if(Lt(C,B)){var K=nn(e,C,B,r.primary,r.primary.type);r.markers.push(K),K.parent=r}}}function Tl(e){for(var t=function(r){var n=e[r],C=[n.primary.doc];Ai(n.primary.doc,function(Y){return C.push(Y)});for(var B=0;B<n.markers.length;B++){var K=n.markers[B];ce(C,K.doc)==-1&&(K.parent=null,n.markers.splice(B--,1))}},i=0;i<e.length;i++)t(i)}var wl=0,kr=function(e,t,i,r,n){if(!(this instanceof kr))return new kr(e,t,i,r,n);i==null&&(i=0),Rn.call(this,[new Dn([new Pi("",null)])]),this.first=i,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=i;var C=je(i,0);this.sel=wi(C),this.history=new Jn(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:C,to:C,text:e}),br(this,wi(C),xe)};kr.prototype=Ve(Rn.prototype,{constructor:kr,iter:function(e,t,i){i?this.iterN(e-this.first,t-e,i):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var i=0,r=0;r<t.length;++r)i+=t[r].height;this.insertInner(e-this.first,t,i)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=ei(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:sr(function(e){var t=je(this.first,0),i=this.first+this.size-1;tn(this,{from:t,to:je(i,pt(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=l(this,t),i=i?l(this,i):t,rn(this,e,t,i,r)},getRange:function(e,t,i){var r=zr(this,l(this,e),l(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 pt(this,e)},getLineNumber:function(e){return Pt(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=pt(this,e)),Sr(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return l(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,l(this,typeof e=="number"?je(e,t||0):e),null,i)}),setSelection:sr(function(e,t,i){Wo(this,l(this,e),l(this,t||e),i)}),extendSelection:sr(function(e,t,i){Qn(this,l(this,e),t&&l(this,t),i)}),extendSelections:sr(function(e,t){jo(this,O(this,e),t)}),extendSelectionsBy:sr(function(e,t){var i=Xe(this.sel.ranges,e);jo(this,O(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 Ht(l(this,e[n].anchor),l(this,e[n].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),br(this,Zr(this.cm,r,t),i)}),addSelection:sr(function(e,t,i){var r=this.sel.ranges.slice(0);r.push(new Ht(l(this,e),l(this,t||e))),br(this,Zr(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=zr(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=zr(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,C=0;C<n.ranges.length;C++){var B=n.ranges[C];r[C]={from:B.from(),to:B.to(),text:this.splitLines(e[C]),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&&Zi(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 Jn(this.history.maxGeneration),Ai(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 Jn(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&&$e(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,$e(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=pt(this,e),!e)return null}else if(t=Pt(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(x(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",C=r[n];if(C)if(i==null)r[n]=null;else{var B=C.match(x(i));if(!B)return!1;var K=B.index+B[0].length;r[n]=C.slice(0,B.index)+(!B.index||K==C.length?"":" ")+C.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,l(this,e),l(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=l(this,e),nn(this,e,e,i,"bookmark")},findMarksAt:function(e){e=l(this,e);var t=[],i=pt(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=l(this,e),t=l(this,t);var r=[],n=e.line;return this.iter(e.line,t.line+1,function(C){var B=C.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 C=n.text.length+r;if(C>e)return t=e,!0;e-=C,++i}),l(this,je(i,t))},indexFromPos:function(e){e=l(this,e);var t=e.ch;if(e.line<this.first||e.ch<0)return 0;var i=this.lineSeparator().length;return this.iter(this.first,e.line,function(r){t+=r.text.length+i}),t},copy:function(e){var t=new kr(ei(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,i=this.first+this.size;e.from!=null&&e.from>t&&(t=e.from),e.to!=null&&e.to<i&&(i=e.to);var r=new kr(ei(this,t,i),e.mode||this.modeOption,t,this.lineSep,this.direction);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Cl(r,rs(this)),r},unlinkDoc:function(e){if(e instanceof Yt&&(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),Tl(rs(this));break}if(e.history==this.history){var r=[e.id];Ai(e,function(n){return r.push(n.id)},!0),e.history=new Jn(null),e.history.done=qi(this.history.done,r),e.history.undone=qi(this.history.undone,r)}},iterLinkedDocs:function(e){Ai(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):ot(e)},lineSeparator:function(){return this.lineSep||`
|
|
`},setDirection: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)})}),kr.prototype.eachLine=kr.prototype.iter;var is=0;function Ll(e){var t=this;if(ns(t),Ue(t,e)||ui(t.display,e))return;ee(e),z&&(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,C=Array(n),B=0,K=function(){++B==n&&or(t,function(){i=l(t.doc,i);var ye={from:i,to:i,text:t.doc.splitLines(C.filter(function(Re){return Re!=null}).join(t.doc.lineSeparator())),origin:"paste"};tn(t.doc,ye),Ho(t.doc,wi(l(t.doc,i),l(t.doc,Li(ye))))})()},Y=function(ye,Re){if(t.options.allowDropFileTypes&&ce(t.options.allowDropFileTypes,ye.type)==-1){K();return}var Be=new FileReader;Be.onerror=function(){return K()},Be.onload=function(){var ze=Be.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(ze)){K();return}C[Re]=ze,K()},Be.readAsText(ye)},Q=0;Q<r.length;Q++)Y(r[Q],Q);else{if(t.state.draggingText&&t.doc.sel.contains(i)>-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var oe=e.dataTransfer.getData("Text");if(oe){var le;if(t.state.draggingText&&!t.state.draggingText.copy&&(le=t.listSelections()),qn(t.doc,wi(i,i)),le)for(var be=0;be<le.length;++be)rn(t.doc,"",le[be].anchor,le[be].head,"drag");t.replaceSelection(oe,"around","paste"),t.display.input.focus()}}catch(ye){}}}function Al(e,t){if(z&&(!e.state.draggingText||+new Date-is<100)){ue(t);return}if(Ue(e,t)||ui(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!R){var i=a("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=a("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),s(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 C=0;C<i.length;C++)e(i[C])})}var os=!1;function Dl(){if(os)return;Rl(),os=!0}function Rl(){var e;we(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,as(_l)},100))}),we(window,"blur",function(){return as(Ji)})}function _l(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var Di={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},Pn=0;Pn<10;Pn++)Di[Pn+48]=Di[Pn+96]=String(Pn);for(var ra=65;ra<=90;ra++)Di[ra]=String.fromCharCode(ra);for(var Mn=1;Mn<=12;Mn++)Di[Mn+111]=Di[Mn+63235]="F"+Mn;var hi={};hi.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},hi.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},hi.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},hi.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},hi.default=u?hi.macDefault:hi.pcDefault;function Ol(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var i,r,n,C,B=0;B<t.length-1;B++){var K=t[B];if(/^(cmd|meta|m)$/i.test(K))C=!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),C&&(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=Xe(i.split(" "),Ol),C=0;C<n.length;C++){var B=void 0,K=void 0;C==n.length-1?(K=n.join(" "),B=r):(K=n.slice(0,C+1).join(" "),B="...");var Y=t[K];if(!Y)t[K]=B;else if(Y!=B)throw new Error("Inconsistent bindings for "+K)}delete e[i]}for(var Q in t)e[Q]=t[Q];return e}function an(e,t,i,r){t=ia(t);var n=t.call?t.call(e,r):t[e];if(n===!1)return"nothing";if(n==="...")return"multi";if(n!=null&&i(n))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return an(e,t.fallthrough,i,r);for(var C=0;C<t.fallthrough.length;C++){var B=an(e,t.fallthrough[C],i,r);if(B)return B}}}function ss(e){var t=typeof e=="string"?e:Di[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function ls(e,t,i){var r=e;return t.altKey&&r!="Alt"&&(e="Alt-"+e),(f?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(e="Ctrl-"+e),(f?t.ctrlKey:t.metaKey)&&r!="Mod"&&(e="Cmd-"+e),!i&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function us(e,t){if(A&&e.keyCode==34&&e.char)return!1;var i=Di[e.keyCode];return i==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(i=e.code),ls(i,e,t))}function ia(e){return typeof e=="string"?hi[e]:e}function on(e,t){for(var i=e.doc.sel.ranges,r=[],n=0;n<i.length;n++){for(var C=t(i[n]);r.length&&Lt(C.from,Le(r).to)<=0;){var B=r.pop();if(Lt(B.from,C.from)<0){C.from=B.from;break}}r.push(C)}Mr(e,function(){for(var K=r.length-1;K>=0;K--)rn(e.doc,"",r[K].from,r[K].to,"+delete");Zi(e)})}function Ba(e,t,i){var r=Me(e.text,t+i,i);return r<0||r>e.text.length?null:r}function Ua(e,t,i){var r=Ba(e,t.ch,i);return r==null?null:new je(t.line,r,i<0?"after":"before")}function Fa(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var C=rt(i,t.doc.direction);if(C){var B=n<0?Le(C):C[0],K=n<0==(B.level==1),Y=K?"after":"before",Q;if(B.level>0||t.doc.direction=="rtl"){var oe=Xi(t,i);Q=n<0?i.text.length-1:0;var le=ni(t,oe,Q).top;Q=at(function(be){return ni(t,oe,be).top==le},n<0==(B.level==1)?B.from:B.to-1,Q),Y=="before"&&(Q=Ba(i,Q,1))}else Q=n<0?B.to:B.from;return new je(r,Q,Y)}}return new je(r,n<0?i.text.length:0,n<0?"before":"after")}function Ml(e,t,i,r){var n=rt(t,e.doc.direction);if(!n)return Ua(t,i,r);i.ch>=t.text.length?(i.ch=t.text.length,i.sticky="before"):i.ch<=0&&(i.ch=0,i.sticky="after");var C=tt(n,i.ch,i.sticky),B=n[C];if(e.doc.direction=="ltr"&&B.level%2==0&&(r>0?B.to>i.ch:B.from<i.ch))return Ua(t,i,r);var K=function(Je,st){return Ba(t,Je instanceof je?Je.ch:Je,st)},Y,Q=function(Je){return e.options.lineWrapping?(Y=Y||Xi(e,t),co(e,t,Y,Je)):{begin:0,end:t.text.length}},oe=Q(i.sticky=="before"?K(i,-1):i.ch);if(e.doc.direction=="rtl"||B.level==1){var le=B.level==1==r<0,be=K(i,le?1:-1);if(be!=null&&(le?be<=B.to&&be<=oe.end:be>=B.from&&be>=oe.begin)){var ye=le?"before":"after";return new je(i.line,be,ye)}}var Re=function(Je,st,Ze){for(var dt=function(Vt,lr){return lr?new je(i.line,K(Vt,1),"before"):new je(i.line,Vt,"after")};Je>=0&&Je<n.length;Je+=st){var Tt=n[Je],Et=st>0==(Tt.level!=1),Rt=Et?Ze.begin:K(Ze.end,-1);if(Tt.from<=Rt&&Rt<Tt.to)return dt(Rt,Et);if(Rt=Et?Tt.from:K(Tt.to,-1),Ze.begin<=Rt&&Rt<Ze.end)return dt(Rt,Et)}},Be=Re(C+r,r,oe);if(Be)return Be;var ze=r>0?oe.end:K(oe.begin,-1);return ze!=null&&!(r>0&&ze==t.text.length)&&(Be=Re(r>0?0:n.length-1,r,Q(ze)),Be)?Be:null}var In={selectAll:Xo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),xe)},killLine:function(e){return on(e,function(t){if(t.empty()){var i=pt(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line<e.lastLine()?{from:t.head,to:je(t.head.line+1,0)}:{from:t.head,to:je(t.head.line,i)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return on(e,function(t){return{from:je(t.from().line,0),to:l(e.doc,je(t.to().line+1,0))}})},delLineLeft:function(e){return on(e,function(t){return{from:je(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(je(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(je(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")},Te)},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")},Te)},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},Te)},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 C=i[n].from(),B=q(e.getLine(C.line),C.ch,r);t.push(se(r-B%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return Mr(e,function(){for(var t=e.listSelections(),i=[],r=0;r<t.length;r++){if(!t[r].empty())continue;var n=t[r].head,C=pt(e.doc,n.line).text;if(C){if(n.ch==C.length&&(n=new je(n.line,n.ch-1)),n.ch>0)n=new je(n.line,n.ch+1),e.replaceRange(C.charAt(n.ch-1)+C.charAt(n.ch-2),je(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var B=pt(e.doc,n.line-1).text;B&&(n=new je(n.line,1),e.replaceRange(C.charAt(0)+e.doc.lineSeparator()+B.charAt(B.length-1),je(n.line-1,B.length-1),n,"+transpose"))}}i.push(new Ht(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return Mr(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);Zi(e)})},openLine:function(e){return e.replaceSelection(`
|
|
`,"start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function hs(e,t){var i=pt(e.doc,t),r=Sr(i);return r!=i&&(t=Pt(r)),Fa(!0,e,r,t,1)}function Il(e,t){var i=pt(e.doc,t),r=Vi(i);return r!=i&&(t=Pt(r)),Fa(!0,e,i,t,-1)}function ds(e,t){var i=hs(e,t.line),r=pt(e.doc,i.line),n=rt(r,e.doc.direction);if(!n||n[0].level==0){var C=Math.max(i.ch,r.text.search(/\S/)),B=t.line==i.line&&t.ch<=C&&t.ch;return je(i.line,B?0:C,i.sticky)}return i}function na(e,t,i){if(typeof t=="string"&&(t=In[t],!t))return!1;e.display.input.ensurePolled();var r=e.display.shift,n=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),i&&(e.display.shift=!1),n=t(e)!=ke}finally{e.display.shift=r,e.state.suppressEdits=!1}return n}function Nl(e,t,i){for(var r=0;r<e.state.keyMaps.length;r++){var n=an(t,e.state.keyMaps[r],i,e);if(n)return n}return e.options.extraKeys&&an(t,e.options.extraKeys,i,e)||an(t,e.options.keyMap,i,e)}var Bl=new ie;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")&&(ee(i),Sa(e)),!!n}function fs(e,t){var i=us(t,!0);return i?t.shiftKey&&!e.state.keySeq?Nn(e,"Shift-"+i,t,function(r){return na(e,r,!0)})||Nn(e,i,t,function(r){if(typeof r=="string"?/^go[A-Z]/.test(r):r.motion)return na(e,r)}):Nn(e,i,t,function(r){return na(e,r)}):!1}function Ul(e,t,i){return Nn(e,"'"+i+"'",t,function(r){return na(e,r,!0)})}var ja=null;function ps(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(t.curOp.focus=_(),Ue(t,e))return;z&&U<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&&!yt&&(u?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),D&&!u&&!r&&i==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),i==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Fl(t)}function Fl(e){var t=e.display.lineDiv;H(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(p(t,"CodeMirror-crosshair"),et(document,"keyup",i),et(document,"mouseover",i))}we(document,"keyup",i),we(document,"mouseover",i)}function ms(e){e.keyCode==16&&(this.doc.sel.shift=!1),Ue(this,e)}function gs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(ui(t.display,e)||Ue(t,e)||e.ctrlKey&&!e.altKey||u&&e.metaKey)return;var i=e.keyCode,r=e.charCode;if(A&&i==ja){ja=null,ee(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(Ul(t,e,n))return;t.display.input.onKeyPress(e)}var jl=400,Wa=function(e,t,i){this.time=e,this.pos=t,this.button=i};Wa.prototype.compare=function(e,t,i){return this.time+jl>e&&Lt(t,this.pos)==0&&i==this.button};var Bn,Un;function Wl(e,t){var i=+new Date;return Un&&Un.compare(i,e,t)?(Bn=Un=null,"triple"):Bn&&Bn.compare(i,e,t)?(Un=new Wa(i,e,t),Bn=null,"double"):(Bn=new Wa(i,e,t),Un=null,"single")}function vs(e){var t=this,i=t.display;if(Ue(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,ui(i,e)){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=Se(e),C=r?Wl(r,n):"single";if(window.focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,n,r,C,e))return;n==1?r?Gl(t,r,C,e):ge(e)==i.scroller&&ee(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 C="Click";return r=="double"?C="Double"+C:r=="triple"&&(C="Triple"+C),C=(t==1?"Left":t==2?"Middle":"Right")+C,Nn(e,ls(C,n),n,function(B){if(typeof B=="string"&&(B=In[B]),!B)return!1;var K=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),K=B(e,i)!=ke}finally{e.state.suppressEdits=!1}return K})}function zl(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var C=d?i.shiftKey&&i.metaKey:i.altKey;n.unit=C?"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=u?i.metaKey:i.ctrlKey),n.moveOnDrag==null&&(n.moveOnDrag=!(u?i.altKey:i.ctrlKey)),n}function Gl(e,t,i,r){z?setTimeout(G(vo,e),0):e.curOp.focus=_();var n=zl(e,i,r),C=e.doc.sel,B;e.options.dragDrop&&Oe&&!e.isReadOnly()&&i=="single"&&(B=C.contains(t))>-1&&(Lt((B=C.ranges[B]).from(),t)<0||t.xRel>0)&&(Lt(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,C=!1,B=or(e,function(Q){P&&(n.scroller.draggable=!1),e.state.draggingText=!1,et(n.wrapper.ownerDocument,"mouseup",B),et(n.wrapper.ownerDocument,"mousemove",K),et(n.scroller,"dragstart",Y),et(n.scroller,"drop",B),C||(ee(Q),r.addNew||Qn(e.doc,i,null,null,r.extend),P&&!R||z&&U==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),K=function(Q){C=C||Math.abs(t.clientX-Q.clientX)+Math.abs(t.clientY-Q.clientY)>=10},Y=function(){return C=!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 Ht(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new Ht(je(t.line,0),l(e.doc,je(t.line+1,0)));var r=i(e,t);return new Ht(r.from,r.to)}function Vl(e,t,i,r){var n=e.display,C=e.doc;ee(t);var B,K,Y=C.sel,Q=Y.ranges;if(r.addNew&&!r.extend?(K=C.sel.contains(i),K>-1?B=Q[K]:B=new Ht(i,i)):(B=C.sel.primary(),K=C.sel.primIndex),r.unit=="rectangle")r.addNew||(B=new Ht(i,i)),i=Ni(e,t,!0,!0),K=-1;else{var oe=ys(e,i,r.unit);r.extend?B=Ia(B,oe.anchor,oe.head,r.extend):B=oe}r.addNew?K==-1?(K=Q.length,br(C,Zr(e,Q.concat([B]),K),{scroll:!1,origin:"*mouse"})):Q.length>1&&Q[K].empty()&&r.unit=="char"&&!r.extend?(br(C,Zr(e,Q.slice(0,K).concat(Q.slice(K+1)),0),{scroll:!1,origin:"*mouse"}),Y=C.sel):Na(C,K,B,Ce):(K=0,br(C,new Wr([B],0),Ce),Y=C.sel);var le=i;function be(Ze){if(Lt(le,Ze)==0)return;if(le=Ze,r.unit=="rectangle"){for(var dt=[],Tt=e.options.tabSize,Et=q(pt(C,i.line).text,i.ch,Tt),Rt=q(pt(C,Ze.line).text,Ze.ch,Tt),Vt=Math.min(Et,Rt),lr=Math.max(Et,Rt),$t=Math.min(i.line,Ze.line),Ir=Math.min(e.lastLine(),Math.max(i.line,Ze.line));$t<=Ir;$t++){var Dr=pt(C,$t).text,er=Ee(Dr,Vt,Tt);Vt==lr?dt.push(new Ht(je($t,er),je($t,er))):Dr.length>er&&dt.push(new Ht(je($t,er),je($t,Ee(Dr,lr,Tt))))}dt.length||dt.push(new Ht(i,i)),br(C,Zr(e,Y.ranges.slice(0,K).concat(dt),K),{origin:"*mouse",scroll:!1}),e.scrollIntoView(Ze)}else{var Rr=B,fr=ys(e,Ze,r.unit),ir=Rr.anchor,tr;Lt(fr.anchor,ir)>0?(tr=fr.head,ir=vi(Rr.from(),fr.anchor)):(tr=fr.anchor,ir=gi(Rr.to(),fr.head));var Jt=Y.ranges.slice(0);Jt[K]=Xl(e,new Ht(l(C,ir),tr)),br(C,Zr(e,Jt,K),Ce)}}var ye=n.wrapper.getBoundingClientRect(),Re=0;function Be(Ze){var dt=++Re,Tt=Ni(e,Ze,!0,r.unit=="rectangle");if(!Tt)return;if(Lt(Tt,le)!=0){e.curOp.focus=_(),be(Tt);var Et=Vn(n,C);(Tt.line>=Et.to||Tt.line<Et.from)&&setTimeout(or(e,function(){Re==dt&&Be(Ze)}),150)}else{var Rt=Ze.clientY<ye.top?-20:Ze.clientY>ye.bottom?20:0;Rt&&setTimeout(or(e,function(){if(Re!=dt)return;n.scroller.scrollTop+=Rt,Be(Ze)}),50)}}function ze(Ze){e.state.selectingText=!1,Re=Infinity,Ze&&(ee(Ze),n.input.focus()),et(n.wrapper.ownerDocument,"mousemove",Je),et(n.wrapper.ownerDocument,"mouseup",st),C.history.lastSelOrigin=null}var Je=or(e,function(Ze){Ze.buttons===0||!Se(Ze)?ze(Ze):Be(Ze)}),st=or(e,ze);e.state.selectingText=st,we(n.wrapper.ownerDocument,"mousemove",Je),we(n.wrapper.ownerDocument,"mouseup",st)}function Xl(e,t){var i=t.anchor,r=t.head,n=pt(e.doc,i.line);if(Lt(i,r)==0&&i.sticky==r.sticky)return t;var C=rt(n);if(!C)return t;var B=tt(C,i.ch,i.sticky),K=C[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==C.length)return t;var Q;if(r.line!=i.line)Q=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var oe=tt(C,r.ch,r.sticky),le=oe-B||(r.ch-i.ch)*(K.level==1?-1:1);oe==Y-1||oe==Y?Q=le<0:Q=le>0}var be=C[Y+(Q?-1:0)],ye=Q==(be.level==1),Re=ye?be.from:be.to,Be=ye?"after":"before";return i.ch==Re&&i.sticky==Be?t:new Ht(new je(i.line,Re,Be),r)}function bs(e,t,i,r){var n,C;if(t.touches)n=t.touches[0].clientX,C=t.touches[0].clientY;else try{n=t.clientX,C=t.clientY}catch(be){return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&ee(t);var B=e.display,K=B.lineDiv.getBoundingClientRect();if(C>K.bottom||!he(e,i))return ae(t);C-=K.top-B.viewOffset;for(var Y=0;Y<e.display.gutterSpecs.length;++Y){var Q=B.gutters.childNodes[Y];if(Q&&Q.getBoundingClientRect().right>=n){var oe=Ur(e.doc,C),le=e.display.gutterSpecs[Y];return Ae(e,i,e,oe,le.className,t),ae(t)}}}function Ha(e,t){return bs(e,t,"gutterClick",!0)}function xs(e,t){if(ui(e.display,t)||Yl(e,t))return;if(Ue(e,t,"contextmenu"))return;k||e.display.input.onContextMenu(t)}function Yl(e,t){return he(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,C,B){e.defaults[r]=n,C&&(t[r]=B?function(K,Y,Q){Q!=sn&&C(K,Y,Q)}:C)}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){Ln(r),yn(r),Ar(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!n)return;var C=[],B=r.doc.first;r.doc.iter(function(Y){for(var Q=0;;){var oe=Y.text.indexOf(n,Q);if(oe==-1)break;Q=oe+n.length,C.push(je(B,oe))}B++});for(var K=C.length-1;K>=0;K--)rn(r.doc,n,C[K],je(C[K].line,C[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,C){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),C!=sn&&r.refresh()}),i("specialCharPlaceholder",Kt,function(r){return r.refresh()},!0),i("electricChars",!0),i("inputStyle",o?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),i("spellcheck",!1,function(r,n){return r.getInputField().spellcheck=n},!0),i("autocorrect",!1,function(r,n){return r.getInputField().autocorrect=n},!0),i("autocapitalize",!1,function(r,n){return r.getInputField().autocapitalize=n},!0),i("rtlMoveVisually",!T),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Es(r),wn(r)},!0),i("keyMap","default",function(r,n,C){var B=ia(n),K=C!=sn&&ia(C);K&&K.detach&&K.detach(r,B),B.attach&&B.attach(r,K||null)}),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,Zl,!0),i("gutters",[],function(r,n){r.display.gutterSpecs=Ra(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){To(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=Ra(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"&&(Ji(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,Jl),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,Ln,!0),i("addModeClass",!1,Ln,!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,Ln,!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 Jl(e,t,i){var r=i&&i!=sn;if(!t!=!r){var n=e.display.dragFunctions,C=t?we:et;C(e.display.scroller,"dragstart",n.start),C(e.display.scroller,"dragenter",n.enter),C(e.display.scroller,"dragover",n.over),C(e.display.scroller,"dragleave",n.leave),C(e.display.scroller,"drop",n.drop)}}function Zl(e){e.options.lineWrapping?(H(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(p(e.display.wrapper,"CodeMirror-wrap"),jn(e)),Ea(e),Ar(e),yn(e),setTimeout(function(){return Qi(e)},100)}function Yt(e,t){var i=this;if(!(this instanceof Yt))return new Yt(e,t);this.options=t=t?j(t):{},j(Ss,t,!1);var r=t.value;typeof r=="string"?r=new kr(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new Yt.inputStyles[t.inputStyle](this),C=this.display=new hl(e,r,n,t);C.wrapper.CodeMirror=this,Es(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),To(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 ie,keySeq:null,specialChars:null},t.autofocus&&!o&&C.input.focus(),z&&U<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Ql(this),Dl(),ji(this),this.curOp.forceUpdate=!0,Mo(this,r),t.autofocus&&!o||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Ca(i)},20):Ji(this);for(var B in aa)aa.hasOwnProperty(B)&&aa[B](this,t[B],sn);Ao(this),t.finishInit&&t.finishInit(this);for(var K=0;K<za.length;++K)za[K](this);Wi(this),P&&t.lineWrapping&&getComputedStyle(C.lineDiv).textRendering=="optimizelegibility"&&(C.lineDiv.style.textRendering="auto")}Yt.defaults=Ss,Yt.optionHandlers=aa;function Ql(e){var t=e.display;we(t.scroller,"mousedown",or(e,vs)),z&&U<11?we(t.scroller,"dblclick",or(e,function(Y){if(Ue(e,Y))return;var Q=Ni(e,Y);if(!Q||Ha(e,Y)||ui(e.display,Y))return;ee(Y);var oe=e.findWordAt(Q);Qn(e.doc,oe.anchor,oe.head)})):we(t.scroller,"dblclick",function(Y){return Ue(e,Y)||ee(Y)}),we(t.scroller,"contextmenu",function(Y){return xs(e,Y)}),we(t.input.getField(),"contextmenu",function(Y){t.scroller.contains(Y.target)||xs(e,Y)});var i,r={end:0};function n(){t.activeTouch&&(i=setTimeout(function(){return t.activeTouch=null},1e3),r=t.activeTouch,r.end=+new Date)}function C(Y){if(Y.touches.length!=1)return!1;var Q=Y.touches[0];return Q.radiusX<=1&&Q.radiusY<=1}function B(Y,Q){if(Q.left==null)return!0;var oe=Q.left-Y.left,le=Q.top-Y.top;return oe*oe+le*le>20*20}we(t.scroller,"touchstart",function(Y){if(!Ue(e,Y)&&!C(Y)&&!Ha(e,Y)){t.input.ensurePolled(),clearTimeout(i);var Q=+new Date;t.activeTouch={start:Q,moved:!1,prev:Q-r.end<=300?r:null},Y.touches.length==1&&(t.activeTouch.left=Y.touches[0].pageX,t.activeTouch.top=Y.touches[0].pageY)}}),we(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),we(t.scroller,"touchend",function(Y){var Q=t.activeTouch;if(Q&&!ui(t,Y)&&Q.left!=null&&!Q.moved&&new Date-Q.start<300){var oe=e.coordsChar(t.activeTouch,"page"),le;!Q.prev||B(Q,Q.prev)?le=new Ht(oe,oe):!Q.prev.prev||B(Q,Q.prev.prev)?le=e.findWordAt(oe):le=new Ht(je(oe.line,0),l(e.doc,je(oe.line+1,0))),e.setSelection(le.anchor,le.head),e.focus(),ee(Y)}n()}),we(t.scroller,"touchcancel",n),we(t.scroller,"scroll",function(){t.scroller.clientHeight&&(En(e,t.scroller.scrollTop),Ui(e,t.scroller.scrollLeft,!0),Ae(e,"scroll",e))}),we(t.scroller,"mousewheel",function(Y){return Ro(e,Y)}),we(t.scroller,"DOMMouseScroll",function(Y){return Ro(e,Y)}),we(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(Y){Ue(e,Y)||ue(Y)},over:function(Y){Ue(e,Y)||(kl(e,Y),ue(Y))},start:function(Y){return Al(e,Y)},drop:or(e,Ll),leave:function(Y){Ue(e,Y)||ns(e)}};var K=t.input.getField();we(K,"keyup",function(Y){return ms.call(e,Y)}),we(K,"keydown",or(e,ps)),we(K,"keypress",or(e,gs)),we(K,"focus",function(Y){return Ca(e,Y)}),we(K,"blur",function(Y){return Ji(e,Y)})}var za=[];Yt.defineInitHook=function(e){return za.push(e)};function Fn(e,t,i,r){var n=e.doc,C;i==null&&(i="add"),i=="smart"&&(n.mode.indent?C=Ye(e,t).state:i="prev");var B=e.options.tabSize,K=pt(n,t),Y=q(K.text,null,B);K.stateAfter&&(K.stateAfter=null);var Q=K.text.match(/^\s*/)[0],oe;if(!r&&!/\S/.test(K.text))oe=0,i="not";else if(i=="smart"&&(oe=n.mode.indent(C,K.text.slice(Q.length),K.text),oe==ke||oe>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?oe=q(pt(n,t-1).text,null,B):oe=0:i=="add"?oe=Y+e.options.indentUnit:i=="subtract"?oe=Y-e.options.indentUnit:typeof i=="number"&&(oe=Y+i),oe=Math.max(0,oe);var le="",be=0;if(e.options.indentWithTabs)for(var ye=Math.floor(oe/B);ye;--ye)be+=B,le+=" ";if(be<oe&&(le+=se(oe-be)),le!=Q)return rn(n,le,je(t,0),je(t,Q.length),"+input"),K.stateAfter=null,!0;for(var Re=0;Re<n.sel.ranges.length;Re++){var Be=n.sel.ranges[Re];if(Be.head.line==t&&Be.head.ch<Q.length){var ze=je(t,Q.length);Na(n,Re,new Ht(ze,ze));break}}}var Qr=null;function oa(e){Qr=e}function Ga(e,t,i,r,n){var C=e.doc;e.display.shift=!1,r||(r=C.sel);var B=+new Date-200,K=n=="paste"||e.state.pasteIncoming>B,Y=ot(t),Q=null;if(K&&r.ranges.length>1)if(Qr&&Qr.text.join(`
|
|
`)==t){if(r.ranges.length%Qr.text.length==0){Q=[];for(var oe=0;oe<Qr.text.length;oe++)Q.push(C.splitLines(Qr.text[oe]))}}else Y.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(Q=Xe(Y,function(Je){return[Je]}));for(var le=e.curOp.updateInput,be=r.ranges.length-1;be>=0;be--){var ye=r.ranges[be],Re=ye.from(),Be=ye.to();ye.empty()&&(i&&i>0?Re=je(Re.line,Re.ch-i):e.state.overwrite&&!K?Be=je(Be.line,Math.min(pt(C,Be.line).text.length,Be.ch+Le(Y).length)):K&&Qr&&Qr.lineWise&&Qr.text.join(`
|
|
`)==Y.join(`
|
|
`)&&(Re=Be=je(Re.line,0)));var ze={from:Re,to:Be,text:Q?Q[be%Q.length]:Y,origin:n||(K?"paste":e.state.cutIncoming>B?"cut":"+input")};tn(e.doc,ze),cr(e,"inputRead",e,ze)}t&&!K&&Ts(e,t),Zi(e),e.curOp.updateInput<2&&(e.curOp.updateInput=le),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Cs(e,t){var i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&Mr(t,function(){return Ga(t,i,0,null,"paste")}),!0}function Ts(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 C=e.getModeAt(n.head),B=!1;if(C.electricChars){for(var K=0;K<C.electricChars.length;K++)if(t.indexOf(C.electricChars.charAt(K))>-1){B=Fn(e,n.head.line,"smart");break}}else C.electricInput&&(C.electricInput.test(pt(e.doc,n.head.line).text.slice(0,n.head.ch))&&(B=Fn(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,C={anchor:je(n,0),head:je(n+1,0)};i.push(C),t.push(e.getRange(C.anchor,C.head))}return{text:t,ranges:i}}function Ls(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function As(){var e=a("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=a("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return P?e.style.width="1000px":e.setAttribute("wrap","off"),S&&(e.style.border="1px solid black"),Ls(e),t}function ql(e){var t=e.optionHandlers,i=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(r,n){var C=this.options,B=C[r];if(C[r]==n&&r!="mode")return;C[r]=n,t.hasOwnProperty(r)&&or(this,t[r])(this,n,B),Ae(this,"optionChange",this,r)},getOption:function(r){return this.options[r]},getDoc:function(){return this.doc},addKeyMap:function(r,n){this.state.keyMaps[n?"push":"unshift"](ia(r))},removeKeyMap:function(r){for(var n=this.state.keyMaps,C=0;C<n.length;++C)if(n[C]==r||n[C].name==r)return n.splice(C,1),!0},addOverlay:Cr(function(r,n){var C=r.token?r:e.getMode(this.options,r);if(C.startState)throw new Error("Overlays may not be stateful.");Ge(this.state.overlays,{mode:C,modeSpec:r,opaque:n&&n.opaque,priority:n&&n.priority||0},function(B){return B.priority}),this.state.modeGen++,Ar(this)}),removeOverlay:Cr(function(r){for(var n=this.state.overlays,C=0;C<n.length;++C){var B=n[C].modeSpec;if(B==r||typeof r=="string"&&B.name==r){n.splice(C,1),this.state.modeGen++,Ar(this);return}}}),indentLine:Cr(function(r,n,C){typeof n!="string"&&typeof n!="number"&&(n==null?n=this.options.smartIndent?"smart":"prev":n=n?"add":"subtract"),Vr(this.doc,r)&&Fn(this,r,n,C)}),indentSelection:Cr(function(r){for(var n=this.doc.sel.ranges,C=-1,B=0;B<n.length;B++){var K=n[B];if(K.empty())K.head.line>C&&(Fn(this,K.head.line,r,!0),C=K.head.line,B==this.doc.sel.primIndex&&Zi(this));else{var Y=K.from(),Q=K.to(),oe=Math.max(C,Y.line);C=Math.min(this.lastLine(),Q.line-(Q.ch?0:1))+1;for(var le=oe;le<C;++le)Fn(this,le,r);var be=this.doc.sel.ranges;Y.ch==0&&n.length==be.length&&be[B].from().ch>0&&Na(this.doc,B,new Ht(Y,be[B].to()),xe)}}}),getTokenAt:function(r,n){return Xt(this,r,n)},getLineTokens:function(r,n){return Xt(this,je(r),n,!0)},getTokenTypeAt:function(r){r=l(this.doc,r);var n=_e(this,pt(this.doc,r.line)),C=0,B=(n.length-1)/2,K=r.ch,Y;if(K==0)Y=n[2];else for(;;){var Q=C+B>>1;if((Q?n[Q*2-1]:0)>=K)B=Q;else if(n[Q*2+1]<K)C=Q+1;else{Y=n[Q*2+2];break}}var oe=Y?Y.indexOf("overlay "):-1;return oe<0?Y:oe==0?null:Y.slice(0,oe-1)},getModeAt:function(r){var n=this.doc.mode;return n.innerMode?e.innerMode(n,this.getTokenAt(r).state).mode:n},getHelper:function(r,n){return this.getHelpers(r,n)[0]},getHelpers:function(r,n){var C=[];if(!i.hasOwnProperty(n))return C;var B=i[n],K=this.getModeAt(r);if(typeof K[n]=="string")B[K[n]]&&C.push(B[K[n]]);else if(K[n])for(var Y=0;Y<K[n].length;Y++){var Q=B[K[n][Y]];Q&&C.push(Q)}else K.helperType&&B[K.helperType]?C.push(B[K.helperType]):B[K.name]&&C.push(B[K.name]);for(var oe=0;oe<B._global.length;oe++){var le=B._global[oe];le.pred(K,this)&&ce(C,le.val)==-1&&C.push(le.val)}return C},getStateAfter:function(r,n){var C=this.doc;return r=W(C,r==null?C.first+C.size-1:r),Ye(this,r+1,n).state},cursorCoords:function(r,n){var C,B=this.doc.sel.primary();return r==null?C=B.head:typeof r=="object"?C=l(this.doc,r):C=r?B.from():B.to(),Jr(this,C,n||"page")},charCoords:function(r,n){return ma(this,l(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,Ur(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,n,C){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=pt(this.doc,r)}else K=r;return Hn(this,K,{top:0,left:0},n||"page",C||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,C,B,K){var Y=this.display;r=Jr(this,l(this.doc,r));var Q=r.bottom,oe=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),Y.sizer.appendChild(n),B=="over")Q=r.top;else if(B=="above"||B=="near"){var le=Math.max(Y.wrapper.clientHeight,this.doc.height),be=Math.max(Y.sizer.clientWidth,Y.lineSpace.clientWidth);(B=="above"||r.bottom+n.offsetHeight>le)&&r.top>n.offsetHeight?Q=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=le&&(Q=r.bottom),oe+n.offsetWidth>be&&(oe=be-n.offsetWidth)}n.style.top=Q+"px",n.style.left=n.style.right="",K=="right"?(oe=Y.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(K=="left"?oe=0:K=="middle"&&(oe=(Y.sizer.clientWidth-n.offsetWidth)/2),n.style.left=oe+"px"),C&&Js(this,{left:oe,top:Q,right:oe+n.offsetWidth,bottom:Q+n.offsetHeight})},triggerOnKeyDown:Cr(ps),triggerOnKeyPress:Cr(gs),triggerOnKeyUp:ms,triggerOnMouseDown:Cr(vs),execCommand:function(r){if(In.hasOwnProperty(r))return In[r].call(null,this)},triggerElectric:Cr(function(r){Ts(this,r)}),findPosH:function(r,n,C,B){var K=1;n<0&&(K=-1,n=-n);for(var Y=l(this.doc,r),Q=0;Q<n&&!(Y=Ka(this.doc,Y,K,C,B),Y.hitSide);++Q);return Y},moveH:Cr(function(r,n){var C=this;this.extendSelectionsBy(function(B){return C.display.shift||C.doc.extend||B.empty()?Ka(C.doc,B.head,r,n,C.options.rtlMoveVisually):r<0?B.from():B.to()},Te)}),deleteH:Cr(function(r,n){var C=this.doc.sel,B=this.doc;C.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,C,B){var K=1,Y=B;n<0&&(K=-1,n=-n);for(var Q=l(this.doc,r),oe=0;oe<n;++oe){var le=Jr(this,Q,"div");if(Y==null?Y=le.left:le.left=Y,Q=ks(this,le,K,C),Q.hitSide)break}return Q},moveV:Cr(function(r,n){var C=this,B=this.doc,K=[],Y=!this.display.shift&&!B.extend&&B.sel.somethingSelected();if(B.extendSelectionsBy(function(oe){if(Y)return r<0?oe.from():oe.to();var le=Jr(C,oe.head,"div");oe.goalColumn!=null&&(le.left=oe.goalColumn),K.push(le.left);var be=ks(C,le,r,n);return n=="page"&&oe==B.sel.primary()&&wa(C,ma(C,be,"div").top-le.top),be},Te),K.length)for(var Q=0;Q<B.sel.ranges.length;Q++)B.sel.ranges[Q].goalColumn=K[Q]}),findWordAt:function(r){var n=this.doc,C=pt(n,r.line).text,B=r.ch,K=r.ch;if(C){var Y=this.getHelper(r,"wordChars");(r.sticky=="before"||K==C.length)&&B?--B:++K;for(var Q=C.charAt(B),oe=He(Q,Y)?function(le){return He(le,Y)}:/\s/.test(Q)?function(le){return/\s/.test(le)}:function(le){return!/\s/.test(le)&&!He(le)};B>0&&oe(C.charAt(B-1));)--B;for(;K<C.length&&oe(C.charAt(K));)++K}return new Ht(je(r.line,B),je(r.line,K))},toggleOverwrite:function(r){if(r!=null&&r==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?H(this.display.cursorDiv,"CodeMirror-overwrite"):p(this.display.cursorDiv,"CodeMirror-overwrite"),Ae(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==_()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:Cr(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:Cr(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:je(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?Zs(this,r):xo(this,r.from,r.to,r.margin)}),setSize:Cr(function(r,n){var C=this,B=function(Y){return typeof Y=="number"||/^\d+$/.test(String(Y))?Y+"px":Y};r!=null&&(this.display.wrapper.style.width=B(r)),n!=null&&(this.display.wrapper.style.height=B(n)),this.options.lineWrapping&&ao(this);var K=this.display.viewFrom;this.doc.iter(K,this.display.viewTo,function(Y){if(Y.widgets){for(var Q=0;Q<Y.widgets.length;Q++)if(Y.widgets[Q].noHScroll){Ci(C,K,"widget");break}}++K}),this.curOp.forceUpdate=!0,Ae(this,"refresh",this)}),operation:function(r){return Mr(this,r)},startOperation:function(){return ji(this)},endOperation:function(){return Wi(this)},refresh:Cr(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),Ae(this,"refresh",this)}),swapDoc:Cr(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}},fe(e),e.registerHelper=function(r,n,C){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=C},e.registerGlobalHelper=function(r,n,C,B){e.registerHelper(r,n,B),i[r]._global.push({pred:C,val:B})}}function Ka(e,t,i,r,n){var C=t,B=i,K=pt(e,t.line),Y=n&&e.direction=="rtl"?-i:i;function Q(){var st=t.line+Y;return st<e.first||st>=e.first+e.size?!1:(t=new je(st,t.ch,t.sticky),K=pt(e,st))}function oe(st){var Ze;if(r=="codepoint"){var dt=K.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(dt)?Ze=null:Ze=new je(t.line,Math.max(0,Math.min(K.text.length,t.ch+i*(dt>=55296&&dt<56320?2:1))),-i)}else n?Ze=Ml(e.cm,K,t,i):Ze=Ua(K,t,i);if(Ze==null)if(!st&&Q())t=Fa(n,e.cm,K,t.line,Y);else return!1;else t=Ze;return!0}if(r=="char"||r=="codepoint")oe();else if(r=="column")oe(!0);else if(r=="word"||r=="group")for(var le=null,be=r=="group",ye=e.cm&&e.cm.getHelper(t,"wordChars"),Re=!0;!(i<0&&!oe(!Re));Re=!1){var Be=K.text.charAt(t.ch)||`
|
|
`,ze=He(Be,ye)?"w":be&&Be==`
|
|
`?"n":!be||/\s/.test(Be)?null:"p";if(be&&!Re&&!ze&&(ze="s"),le&&le!=ze){i<0&&(i=1,oe(),t.sticky="after");break}if(ze&&(le=ze),i>0&&!oe(!Re))break}var Je=ea(e,t,C,B,!0);return pi(C,Je)&&(Je.hitSide=!0),Je}function ks(e,t,i,r){var n=e.doc,C=t.left,B;if(r=="page"){var K=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),Y=Math.max(K-.5*Yi(e.display),3);B=(i>0?t.bottom:t.top)+i*Y}else r=="line"&&(B=i>0?t.bottom+3:t.top-3);for(var Q;!(Q=va(e,C,B),!Q.outside);){if(i<0?B<=0:B>=n.height){Q.hitSide=!0;break}B+=i*5}return Q}var Gt=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new ie,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Gt.prototype.init=function(e){var t=this,i=this,r=i.cm,n=i.div=e.lineDiv;Ls(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function C(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(!C(K)||Ue(r,K)||Cs(K,r))return;U<=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(!C(K)||Ue(r,K))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()}),K.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var Y=ws(r);oa({lineWise:!0,text:Y.text}),K.type=="cut"&&r.operation(function(){r.setSelections(Y.ranges,0,xe),r.replaceSelection("",null,"cut")})}else return;if(K.clipboardData){K.clipboardData.clearData();var Q=Qr.text.join(`
|
|
`);if(K.clipboardData.setData("Text",Q),K.clipboardData.getData("Text")==Q){K.preventDefault();return}}var oe=As(),le=oe.firstChild;r.display.lineSpace.insertBefore(oe,r.display.lineSpace.firstChild),le.value=Qr.text.join(`
|
|
`);var be=document.activeElement;Z(le),setTimeout(function(){r.display.lineSpace.removeChild(oe),be.focus(),be==n&&i.showPrimarySelection()},50)}we(n,"copy",B),we(n,"cut",B)},Gt.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},Gt.prototype.prepareSelection=function(){var e=mo(this.cm,!1);return e.focus=document.activeElement==this.div,e},Gt.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},Gt.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Gt.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 C=sa(t,e.anchorNode,e.anchorOffset),B=sa(t,e.focusNode,e.focusOffset);if(C&&!C.bad&&B&&!B.bad&&Lt(vi(C,B),r)==0&&Lt(gi(C,B),n)==0)return;var K=t.display.view,Y=r.line>=t.display.viewFrom&&Ds(t,r)||{node:K[0].measure.map[2],offset:0},Q=n.line<t.display.viewTo&&Ds(t,n);if(!Q){var oe=K[K.length-1].measure,le=oe.maps?oe.maps[oe.maps.length-1]:oe.map;Q={node:le[le.length-1],offset:le[le.length-2]-le[le.length-3]}}if(!Y||!Q){e.removeAllRanges();return}var be=e.rangeCount&&e.getRangeAt(0),ye;try{ye=g(Y.node,Y.offset,Q.offset,Q.node)}catch(Re){}ye&&(!D&&t.state.focused?(e.collapse(Y.node,Y.offset),ye.collapsed||(e.removeAllRanges(),e.addRange(ye))):(e.removeAllRanges(),e.addRange(ye)),be&&e.anchorNode==null?e.addRange(be):D&&this.startGracePeriod()),this.rememberSelection()},Gt.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)},Gt.prototype.showMultipleSelections=function(e){s(this.cm.display.cursorDiv,e.cursors),s(this.cm.display.selectionDiv,e.selection)},Gt.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},Gt.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return E(this.div,t)},Gt.prototype.focus=function(){this.cm.options.readOnly!="nocursor"&&((!this.selectionInEditor()||document.activeElement!=this.div)&&this.showSelection(this.prepareSelection(),!0),this.div.focus())},Gt.prototype.blur=function(){this.div.blur()},Gt.prototype.getField=function(){return this.div},Gt.prototype.supportsTouch=function(){return!0},Gt.prototype.receivedFocus=function(){var e=this;this.selectionInEditor()?this.pollSelection():Mr(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)},Gt.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},Gt.prototype.pollSelection=function(){if(this.readDOMTimeout!=null||this.gracePeriod||!this.selectionChanged())return;var e=this.getSelection(),t=this.cm;if(h&&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&&Mr(t,function(){br(t.doc,wi(i,r),xe),(i.bad||r.bad)&&(t.curOp.selectionChanged=!0)})},Gt.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=je(r.line-1,pt(e.doc,r.line-1).length)),n.ch==pt(e.doc,n.line).text.length&&n.line<e.lastLine()&&(n=je(n.line+1,0)),r.line<t.viewFrom||n.line>t.viewTo-1)return!1;var C,B,K;r.line==t.viewFrom||(C=Bi(e,r.line))==0?(B=Pt(t.view[0].line),K=t.view[0].node):(B=Pt(t.view[C].line),K=t.view[C-1].node.nextSibling);var Y=Bi(e,n.line),Q,oe;if(Y==t.view.length-1?(Q=t.viewTo-1,oe=t.lineDiv.lastChild):(Q=Pt(t.view[Y+1].line)-1,oe=t.view[Y+1].node.previousSibling),!K)return!1;for(var le=e.doc.splitLines(tu(e,K,oe,B,Q)),be=zr(e.doc,je(B,0),je(Q,pt(e.doc,Q).text.length));le.length>1&&be.length>1;)if(Le(le)==Le(be))le.pop(),be.pop(),Q--;else if(le[0]==be[0])le.shift(),be.shift(),B++;else break;for(var ye=0,Re=0,Be=le[0],ze=be[0],Je=Math.min(Be.length,ze.length);ye<Je&&Be.charCodeAt(ye)==ze.charCodeAt(ye);)++ye;for(var st=Le(le),Ze=Le(be),dt=Math.min(st.length-(le.length==1?ye:0),Ze.length-(be.length==1?ye:0));Re<dt&&st.charCodeAt(st.length-Re-1)==Ze.charCodeAt(Ze.length-Re-1);)++Re;if(le.length==1&&be.length==1&&B==r.line)for(;ye&&ye>r.ch&&st.charCodeAt(st.length-Re-1)==Ze.charCodeAt(Ze.length-Re-1);)ye--,Re++;le[le.length-1]=st.slice(0,st.length-Re).replace(/^\u200b+/,""),le[0]=le[0].slice(ye).replace(/\u200b+$/,"");var Tt=je(B,ye),Et=je(Q,be.length?Le(be).length-Re:0);if(le.length>1||le[0]||Lt(Tt,Et))return rn(e.doc,le,Tt,Et,"+input"),!0},Gt.prototype.ensurePolled=function(){this.forceCompositionEnd()},Gt.prototype.reset=function(){this.forceCompositionEnd()},Gt.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},Gt.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)},Gt.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&Mr(this.cm,function(){return Ar(e.cm)})},Gt.prototype.setUneditable=function(e){e.contentEditable="false"},Gt.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault(),this.cm.isReadOnly()||or(this.cm,Ga)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},Gt.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},Gt.prototype.onContextMenu=function(){},Gt.prototype.resetPosition=function(){},Gt.prototype.needsContentAttribute=!0;function Ds(e,t){var i=fa(e,t.line);if(!i||i.hidden)return null;var r=pt(e.doc,t.line),n=eo(i,r,t.line),C=rt(r,e.doc.direction),B="left";if(C){var K=tt(C,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 C="",B=!1,K=e.doc.lineSeparator(),Y=!1;function Q(ye){return function(Re){return Re.id==ye}}function oe(){B&&(C+=K,Y&&(C+=K),B=Y=!1)}function le(ye){ye&&(oe(),C+=ye)}function be(ye){if(ye.nodeType==1){var Re=ye.getAttribute("cm-text");if(Re){le(Re);return}var Be=ye.getAttribute("cm-marker"),ze;if(Be){var Je=e.findMarks(je(r,0),je(n+1,0),Q(+Be));Je.length&&(ze=Je[0].find(0))&&le(zr(e.doc,ze.from,ze.to).join(K));return}if(ye.getAttribute("contenteditable")=="false")return;var st=/^(pre|div|p|li|table|br)$/i.test(ye.nodeName);if(!/^br$/i.test(ye.nodeName)&&ye.textContent.length==0)return;st&&oe();for(var Ze=0;Ze<ye.childNodes.length;Ze++)be(ye.childNodes[Ze]);/^(pre|p)$/i.test(ye.nodeName)&&(Y=!0),st&&(B=!0)}else ye.nodeType==3&&le(ye.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(be(t),t==i);)t=t.nextSibling,Y=!1;return C}function sa(e,t,i){var r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[i],!r)return ln(e.clipPos(je(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 C=e.display.view[n];if(C.node==r)return ru(C,t,i)}}function ru(e,t,i){var r=e.text.firstChild,n=!1;if(!t||!E(r,t))return ln(je(Pt(e.line),0),!0);if(t==r&&(n=!0,t=r.childNodes[i],i=0,!t)){var C=e.rest?Le(e.rest):e.line;return ln(je(Pt(C),C.text.length),n)}var B=t.nodeType==3?t:null,K=t;for(!B&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(B=t.firstChild,i&&(i=B.nodeValue.length));K.parentNode!=r;)K=K.parentNode;var Y=e.measure,Q=Y.maps;function oe(ze,Je,st){for(var Ze=-1;Ze<(Q?Q.length:0);Ze++)for(var dt=Ze<0?Y.map:Q[Ze],Tt=0;Tt<dt.length;Tt+=3){var Et=dt[Tt+2];if(Et==ze||Et==Je){var Rt=Pt(Ze<0?e.line:e.rest[Ze]),Vt=dt[Tt]+st;return(st<0||Et!=ze)&&(Vt=dt[Tt+(st?1:0)]),je(Rt,Vt)}}}var le=oe(B,K,i);if(le)return ln(le,n);for(var be=K.nextSibling,ye=B?B.nodeValue.length-i:0;be;be=be.nextSibling){if(le=oe(be,be.firstChild,0),le)return ln(je(le.line,le.ch-ye),n);ye+=be.textContent.length}for(var Re=K.previousSibling,Be=i;Re;Re=Re.previousSibling){if(le=oe(Re,Re.firstChild,-1),le)return ln(je(le.line,le.ch+Be),n);Be+=Re.textContent.length}}var Qt=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new ie,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),S&&(n.style.width="0px"),we(n,"input",function(){z&&U>=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),we(n,"paste",function(B){if(Ue(r,B)||Cs(B,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function C(B){if(Ue(r,B))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var K=ws(r);oa({lineWise:!0,text:K.text}),B.type=="cut"?r.setSelections(K.ranges,null,xe):(i.prevInput="",n.value=K.text.join(`
|
|
`),Z(n))}else return;B.type=="cut"&&(r.state.cutIncoming=+new Date)}we(n,"cut",C),we(n,"copy",C),we(e.scroller,"paste",function(B){if(ui(e,B)||Ue(r,B))return;if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var K=new Event("paste");K.clipboardData=B.clipboardData,n.dispatchEvent(K)}),we(e.lineSpace,"selectstart",function(B){ui(e,B)||ee(B)}),we(n,"compositionstart",function(){var B=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:B,range:r.markText(B,r.getCursor("to"),{className:"CodeMirror-composing"})}}),we(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},Qt.prototype.createField=function(e){this.wrapper=As(),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=Jr(e,i.sel.primary().head,"div"),C=t.wrapper.getBoundingClientRect(),B=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+B.top-C.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+B.left-C.left))}return r},Qt.prototype.showSelection=function(e){var t=this.cm,i=t.display;s(i.cursorDiv,e.cursors),s(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&&Z(this.textarea),z&&U>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",z&&U>=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"&&(!o||_()!=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||We(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(z&&U>=9&&this.hasSelection===n||u&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var C=n.charCodeAt(0);if(C==8203&&!r&&(r="\u200B"),C==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 Mr(t,function(){Ga(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(){z&&U>=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 C=Ni(i,e),B=r.scroller.scrollTop;if(!C||A)return;var K=i.options.resetSelectionOnContextMenu;K&&i.doc.sel.contains(C)==-1&&or(i,br)(i.doc,wi(C),xe);var Y=n.style.cssText,Q=t.wrapper.style.cssText,oe=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;
|
|
top: `+(e.clientY-oe.top-5)+"px; left: "+(e.clientX-oe.left-5)+`px;
|
|
z-index: 1000; background: `+(z?"rgba(255, 255, 255, .05)":"transparent")+`;
|
|
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var le;P&&(le=window.scrollY),r.input.focus(),P&&window.scrollTo(null,le),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=ye,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function be(){if(n.selectionStart!=null){var Be=i.somethingSelected(),ze="\u200B"+(Be?n.value:"");n.value="\u21DA",n.value=ze,t.prevInput=Be?"":"\u200B",n.selectionStart=1,n.selectionEnd=ze.length,r.selForContextMenu=i.doc.sel}}function ye(){if(t.contextMenuPending!=ye)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=Q,n.style.cssText=Y,z&&U<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=B),n.selectionStart!=null){(!z||z&&U<9)&&be();var Be=0,ze=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?or(i,Xo)(i):Be++<10?r.detectingSelectAll=setTimeout(ze,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(ze,200)}}if(z&&U>=9&&be(),k){ue(e);var Re=function(){et(window,"mouseup",Re),setTimeout(ye,20)};we(window,"mouseup",Re)}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?j(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){var i=_();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 C=e.form;n=C.submit;try{var B=C.submit=function(){r(),C.submit=n,C.submit(),C.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&&(et(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var K=Yt(function(Y){return e.parentNode.insertBefore(Y,e.nextSibling)},t);return K}function nu(e){e.off=et,e.on=we,e.wheelEventPixels=dl,e.Doc=kr,e.splitLines=ot,e.countColumn=q,e.findColumn=Ee,e.isWordChar=Pe,e.Pass=ke,e.signal=Ae,e.Line=Pi,e.changeEnd=Li,e.scrollbarModel=Co,e.Pos=je,e.cmpPos=Lt,e.modes=xt,e.mimeModes=Dt,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=Ut,e.SharedTextMarker=On,e.TextMarker=ki,e.LineWidget=_n,e.e_preventDefault=ee,e.e_stopPropagation=te,e.e_stop=ue,e.addClass=H,e.contains=E,e.rmClass=p,e.keyNames=Di}$l(Yt),ql(Yt);var au="iter insert remove copy getEditor constructor".split(" ");for(var la in kr.prototype)kr.prototype.hasOwnProperty(la)&&ce(au,la)<0&&(Yt.prototype[la]=function(e){return function(){return e.apply(this.doc,arguments)}}(kr.prototype[la]));return fe(kr),Yt.inputStyles={textarea:Qt,contenteditable:Gt},Yt.defineMode=function(e){!Yt.defaults.mode&&e!="null"&&(Yt.defaults.mode=e),Er.apply(this,arguments)},Yt.defineMIME=Hr,Yt.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Yt.defineMIME("text/plain","null"),Yt.defineExtension=function(e,t){Yt.prototype[e]=t},Yt.defineDocExtension=function(e,t){kr.prototype[e]=t},Yt.fromTextArea=iu,nu(Yt),Yt.version="5.58.2",Yt})},Y1PL:function(wt,ht,re){"use strict";re.r(ht),re.d(ht,"ResizableTextArea",function(){return ce});var ne=re("wx14"),$=re("1OyB"),D=re("vuIU"),X=re("Ji7U"),N=re("LK+K"),I=re("cDcd"),z=re("VTBJ"),U=re("rePB"),P=re("Zm9Q"),M=re("Kwbf"),b=re("c+Xe"),A=re("m+aA"),R=re("bdgK"),L=new Map;function w(xe){xe.forEach(function(Ce){var Te,Ee=Ce.target;(Te=L.get(Ee))===null||Te===void 0||Te.forEach(function(pe){return pe(Ee)})})}var S=new R.default(w),h=null,o=null;function u(xe,Ce){L.has(xe)||(L.set(xe,new Set),S.observe(xe)),L.get(xe).add(Ce)}function d(xe,Ce){L.has(xe)&&(L.get(xe).delete(Ce),L.get(xe).size||(S.unobserve(xe),L.delete(xe)))}var T=function(xe){Object(X.a)(Te,xe);var Ce=Object(N.a)(Te);function Te(){return Object($.a)(this,Te),Ce.apply(this,arguments)}return Object(D.a)(Te,[{key:"render",value:function(){return this.props.children}}]),Te}(I.Component),y=I.createContext(null);function f(xe){var Ce=xe.children,Te=xe.onBatchResize,Ee=I.useRef(0),pe=I.useRef([]),se=I.useContext(y),Le=I.useCallback(function(Xe,Ge,Ke){Ee.current+=1;var Ve=Ee.current;pe.current.push({size:Xe,element:Ge,data:Ke}),Promise.resolve().then(function(){Ve===Ee.current&&(Te==null||Te(pe.current),pe.current=[])}),se==null||se(Xe,Ge,Ke)},[Te,se]);return I.createElement(y.Provider,{value:Le},Ce)}function k(xe){var Ce=xe.children,Te=xe.disabled,Ee=I.useRef(null),pe=I.useRef(null),se=I.useContext(y),Le=I.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),Xe=I.isValidElement(Ce)&&Object(b.c)(Ce),Ge=Xe?Ce.ref:null,Ke=I.useMemo(function(){return Object(b.a)(Ge,Ee)},[Ge,Ee]),Ve=I.useRef(xe);Ve.current=xe;var De=I.useCallback(function(Pe){var He=Ve.current,$e=He.onResize,Fe=He.data,Ne=Pe.getBoundingClientRect(),Me=Ne.width,at=Ne.height,qe=Pe.offsetWidth,Qe=Pe.offsetHeight,tt=Math.floor(Me),ut=Math.floor(at);if(Le.current.width!==tt||Le.current.height!==ut||Le.current.offsetWidth!==qe||Le.current.offsetHeight!==Qe){var rt={width:tt,height:ut,offsetWidth:qe,offsetHeight:Qe};Le.current=rt;var it=qe===Math.round(Me)?Me:qe,we=Qe===Math.round(at)?at:Qe,lt=Object(z.a)(Object(z.a)({},rt),{},{offsetWidth:it,offsetHeight:we});se==null||se(lt,Pe,Fe),$e&&Promise.resolve().then(function(){$e(lt,Pe)})}},[]);return I.useEffect(function(){var Pe=Object(A.a)(Ee.current)||Object(A.a)(pe.current);return Pe&&!Te&&u(Pe,De),function(){return d(Pe,De)}},[Ee.current,Te]),I.createElement(T,{ref:pe},Xe?I.cloneElement(Ce,{ref:Ke}):Ce)}var x="rc-observer-key";function p(xe){var Ce=xe.children,Te=Object(P.a)(Ce);return Te.map(function(Ee,pe){var se=(Ee==null?void 0:Ee.key)||"".concat(x,"-").concat(pe);return I.createElement(k,Object(ne.a)({},xe,{key:se}),Ee)})}p.Collection=f;var c=p,s=re("bT9E"),a=re("TSYQ"),v=re.n(a),g=`
|
|
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
|
|
`,E=["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"],_={},H;function V(xe){var Ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Te=xe.getAttribute("id")||xe.getAttribute("data-reactid")||xe.getAttribute("name");if(Ce&&_[Te])return _[Te];var Ee=window.getComputedStyle(xe),pe=Ee.getPropertyValue("box-sizing")||Ee.getPropertyValue("-moz-box-sizing")||Ee.getPropertyValue("-webkit-box-sizing"),se=parseFloat(Ee.getPropertyValue("padding-bottom"))+parseFloat(Ee.getPropertyValue("padding-top")),Le=parseFloat(Ee.getPropertyValue("border-bottom-width"))+parseFloat(Ee.getPropertyValue("border-top-width")),Xe=E.map(function(Ke){return"".concat(Ke,":").concat(Ee.getPropertyValue(Ke))}).join(";"),Ge={sizingStyle:Xe,paddingSize:se,borderSize:Le,boxSizing:pe};return Ce&&Te&&(_[Te]=Ge),Ge}function Z(xe){var Ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,Ee=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;H||(H=document.createElement("textarea"),H.setAttribute("tab-index","-1"),H.setAttribute("aria-hidden","true"),document.body.appendChild(H)),xe.getAttribute("wrap")?H.setAttribute("wrap",xe.getAttribute("wrap")):H.removeAttribute("wrap");var pe=V(xe,Ce),se=pe.paddingSize,Le=pe.borderSize,Xe=pe.boxSizing,Ge=pe.sizingStyle;H.setAttribute("style","".concat(Ge,";").concat(g)),H.value=xe.value||xe.placeholder||"";var Ke=Number.MIN_SAFE_INTEGER,Ve=Number.MAX_SAFE_INTEGER,De=H.scrollHeight,Pe;if(Xe==="border-box"?De+=Le:Xe==="content-box"&&(De-=se),Te!==null||Ee!==null){H.value=" ";var He=H.scrollHeight-se;Te!==null&&(Ke=He*Te,Xe==="border-box"&&(Ke=Ke+se+Le),De=Math.max(Ke,De)),Ee!==null&&(Ve=He*Ee,Xe==="border-box"&&(Ve=Ve+se+Le),Pe=De>Ve?"":"hidden",De=Math.min(Ve,De))}return{height:De,minHeight:Ke,maxHeight:Ve,overflowY:Pe,resize:"none"}}var G=re("Gytx"),j=re.n(G),q;(function(xe){xe[xe.NONE=0]="NONE",xe[xe.RESIZING=1]="RESIZING",xe[xe.RESIZED=2]="RESIZED"})(q||(q={}));var ie=function(xe){Object(X.a)(Te,xe);var Ce=Object(N.a)(Te);function Te(Ee){var pe;return Object($.a)(this,Te),pe=Ce.call(this,Ee),pe.nextFrameActionId=void 0,pe.resizeFrameId=void 0,pe.textArea=void 0,pe.saveTextArea=function(se){pe.textArea=se},pe.handleResize=function(se){var Le=pe.state.resizeStatus,Xe=pe.props,Ge=Xe.autoSize,Ke=Xe.onResize;if(Le!==q.NONE)return;typeof Ke=="function"&&Ke(se),Ge&&pe.resizeOnNextFrame()},pe.resizeOnNextFrame=function(){cancelAnimationFrame(pe.nextFrameActionId),pe.nextFrameActionId=requestAnimationFrame(pe.resizeTextarea)},pe.resizeTextarea=function(){var se=pe.props.autoSize;if(!se||!pe.textArea)return;var Le=se.minRows,Xe=se.maxRows,Ge=Z(pe.textArea,!1,Le,Xe);pe.setState({textareaStyles:Ge,resizeStatus:q.RESIZING},function(){cancelAnimationFrame(pe.resizeFrameId),pe.resizeFrameId=requestAnimationFrame(function(){pe.setState({resizeStatus:q.RESIZED},function(){pe.resizeFrameId=requestAnimationFrame(function(){pe.setState({resizeStatus:q.NONE}),pe.fixFirefoxAutoScroll()})})})})},pe.renderTextArea=function(){var se=pe.props,Le=se.prefixCls,Xe=Le===void 0?"rc-textarea":Le,Ge=se.autoSize,Ke=se.onResize,Ve=se.className,De=se.disabled,Pe=pe.state,He=Pe.textareaStyles,$e=Pe.resizeStatus,Fe=Object(s.a)(pe.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Ne=v()(Xe,Ve,Object(U.a)({},"".concat(Xe,"-disabled"),De));"value"in Fe&&(Fe.value=Fe.value||"");var Me=Object(z.a)(Object(z.a)(Object(z.a)({},pe.props.style),He),$e===q.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return I.createElement(c,{onResize:pe.handleResize,disabled:!(Ge||Ke)},I.createElement("textarea",Object(ne.a)({},Fe,{className:Ne,style:Me,ref:pe.saveTextArea})))},pe.state={textareaStyles:{},resizeStatus:q.NONE},pe}return Object(D.a)(Te,[{key:"componentDidUpdate",value:function(pe){(pe.value!==this.props.value||!j()(pe.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 pe=this.textArea.selectionStart,se=this.textArea.selectionEnd;this.textArea.setSelectionRange(pe,se)}}catch(Le){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Te}(I.Component),ce=ie,ve=function(xe){Object(X.a)(Te,xe);var Ce=Object(N.a)(Te);function Te(Ee){var pe;Object($.a)(this,Te),pe=Ce.call(this,Ee),pe.resizableTextArea=void 0,pe.focus=function(){pe.resizableTextArea.textArea.focus()},pe.saveTextArea=function(Le){pe.resizableTextArea=Le},pe.handleChange=function(Le){var Xe=pe.props.onChange;pe.setValue(Le.target.value,function(){pe.resizableTextArea.resizeTextarea()}),Xe&&Xe(Le)},pe.handleKeyDown=function(Le){var Xe=pe.props,Ge=Xe.onPressEnter,Ke=Xe.onKeyDown;Le.keyCode===13&&Ge&&Ge(Le),Ke&&Ke(Le)};var se=typeof Ee.value=="undefined"||Ee.value===null?Ee.defaultValue:Ee.value;return pe.state={value:se},pe}return Object(D.a)(Te,[{key:"setValue",value:function(pe,se){"value"in this.props||this.setState({value:pe},se)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return I.createElement(ce,Object(ne.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(pe){return"value"in pe?{value:pe.value}:null}}]),Te}(I.Component),ke=ht.default=ve},ZpRC:function(wt,ht,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 D(b,A){if(b.clientHeight<b.scrollHeight||b.clientWidth<b.scrollWidth){var R=getComputedStyle(b,null);return $(R.overflowY,A)||$(R.overflowX,A)||function(L){var w=function(S){if(!S.ownerDocument||!S.ownerDocument.defaultView)return null;try{return S.ownerDocument.defaultView.frameElement}catch(h){return null}}(L);return!!w&&(w.clientHeight<L.scrollHeight||w.clientWidth<L.scrollWidth)}(b)}return!1}function X(b,A,R,L,w,S,h,o){return S<b&&h>A||S>b&&h<A?0:S<=b&&o<=R||h>=A&&o>=R?S-b-L:h>A&&o<R||S<b&&o>R?h-A+w:0}var N=function(b,A){var R=window,L=A.scrollMode,w=A.block,S=A.inline,h=A.boundary,o=A.skipOverflowHiddenElements,u=typeof h=="function"?h:function(He){return He!==h};if(!ne(b))throw new TypeError("Invalid target");for(var d=document.scrollingElement||document.documentElement,T=[],y=b;ne(y)&&u(y);){if((y=y.parentElement)===d){T.push(y);break}y!=null&&y===document.body&&D(y)&&!D(document.documentElement)||y!=null&&D(y,o)&&T.push(y)}for(var f=R.visualViewport?R.visualViewport.width:innerWidth,k=R.visualViewport?R.visualViewport.height:innerHeight,x=window.scrollX||pageXOffset,p=window.scrollY||pageYOffset,c=b.getBoundingClientRect(),s=c.height,a=c.width,v=c.top,g=c.right,E=c.bottom,_=c.left,H=w==="start"||w==="nearest"?v:w==="end"?E:v+s/2,V=S==="center"?_+a/2:S==="end"?g:_,Z=[],G=0;G<T.length;G++){var j=T[G],q=j.getBoundingClientRect(),ie=q.height,ce=q.width,ve=q.top,ke=q.right,xe=q.bottom,Ce=q.left;if(L==="if-needed"&&v>=0&&_>=0&&E<=k&&g<=f&&v>=ve&&E<=xe&&_>=Ce&&g<=ke)return Z;var Te=getComputedStyle(j),Ee=parseInt(Te.borderLeftWidth,10),pe=parseInt(Te.borderTopWidth,10),se=parseInt(Te.borderRightWidth,10),Le=parseInt(Te.borderBottomWidth,10),Xe=0,Ge=0,Ke="offsetWidth"in j?j.offsetWidth-j.clientWidth-Ee-se:0,Ve="offsetHeight"in j?j.offsetHeight-j.clientHeight-pe-Le:0;if(d===j)Xe=w==="start"?H:w==="end"?H-k:w==="nearest"?X(p,p+k,k,pe,Le,p+H,p+H+s,s):H-k/2,Ge=S==="start"?V:S==="center"?V-f/2:S==="end"?V-f:X(x,x+f,f,Ee,se,x+V,x+V+a,a),Xe=Math.max(0,Xe+p),Ge=Math.max(0,Ge+x);else{Xe=w==="start"?H-ve-pe:w==="end"?H-xe+Le+Ve:w==="nearest"?X(ve,xe,ie,pe,Le+Ve,H,H+s,s):H-(ve+ie/2)+Ve/2,Ge=S==="start"?V-Ce-Ee:S==="center"?V-(Ce+ce/2)+Ke/2:S==="end"?V-ke+se+Ke:X(Ce,ke,ce,Ee,se+Ke,V,V+a,a);var De=j.scrollLeft,Pe=j.scrollTop;H+=Pe-(Xe=Math.max(0,Math.min(Pe+Xe,j.scrollHeight-ie+Ve))),V+=De-(Ge=Math.max(0,Math.min(De+Ge,j.scrollWidth-ce+Ke)))}Z.push({el:j,top:Xe,left:Ge})}return Z};function I(b){return b===Object(b)&&Object.keys(b).length!==0}function z(b,A){A===void 0&&(A="auto");var R="scrollBehavior"in document.body.style;b.forEach(function(L){var w=L.el,S=L.top,h=L.left;w.scroll&&R?w.scroll({top:S,left:h,behavior:A}):(w.scrollTop=S,w.scrollLeft=h)})}function U(b){return b===!1?{block:"end",inline:"nearest"}:I(b)?b:{block:"start",inline:"nearest"}}function P(b,A){var R=!b.ownerDocument.documentElement.contains(b);if(I(A)&&typeof A.behavior=="function")return A.behavior(R?[]:N(b,A));if(R)return;var L=U(A);return z(N(b,L),L.behavior)}var M=ht.a=P},bT9E:function(wt,ht,re){"use strict";re.d(ht,"a",function(){return $});var ne=re("VTBJ");function $(D,X){var N=Object(ne.a)({},D);return Array.isArray(X)&&X.forEach(function(I){delete N[I]}),N}},c5Ni:function(wt,ht,re){},dejd:function(wt,ht,re){},dmUQ:function(wt,ht,re){"use strict";var ne=re("Ff2n"),$=re("rePB"),D=re("1OyB"),X=re("vuIU"),N=re("Ji7U"),I=re("md7G"),z=re("foSv"),U=re("cDcd"),P=re.n(U),M=re("TSYQ"),b=re.n(M),A=re("4IlW");function R(s,a){var v=Object.keys(s);if(Object.getOwnPropertySymbols){var g=Object.getOwnPropertySymbols(s);a&&(g=g.filter(function(E){return Object.getOwnPropertyDescriptor(s,E).enumerable})),v.push.apply(v,g)}return v}function L(s){for(var a=1;a<arguments.length;a++){var v=arguments[a]!=null?arguments[a]:{};a%2?R(Object(v),!0).forEach(function(g){Object($.a)(s,g,v[g])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(v)):R(Object(v)).forEach(function(g){Object.defineProperty(s,g,Object.getOwnPropertyDescriptor(v,g))})}return s}function w(s){var a=S();return function(){var g=Object(z.a)(s),E;if(a){var _=Object(z.a)(this).constructor;E=Reflect.construct(g,arguments,_)}else E=g.apply(this,arguments);return Object(I.a)(this,E)}}function S(){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(s){return!1}}function h(){}function o(s){s.preventDefault()}var u=function(a){return a.replace(/[^\w.-]+/g,"")},d=200,T=600,y=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,f=function(a){return a!=null},k=function(a,v){return v===a||typeof v=="number"&&typeof a=="number"&&isNaN(v)&&isNaN(a)},x=function(s){Object(N.a)(v,s);var a=w(v);function v(g){var E;Object(D.a)(this,v),E=a.call(this,g),E.onKeyDown=function(V){var Z=E.props,G=Z.onKeyDown,j=Z.onPressEnter;if(V.keyCode===A.a.UP){var q=E.getRatio(V);E.up(V,q,null),E.stop()}else if(V.keyCode===A.a.DOWN){var ie=E.getRatio(V);E.down(V,ie,null),E.stop()}else V.keyCode===A.a.ENTER&&j&&j(V);if(E.recordCursorPosition(),E.lastKeyCode=V.keyCode,G){for(var ce=arguments.length,ve=new Array(ce>1?ce-1:0),ke=1;ke<ce;ke++)ve[ke-1]=arguments[ke];G.apply(void 0,[V].concat(ve))}},E.onKeyUp=function(V){var Z=E.props.onKeyUp;if(E.stop(),E.recordCursorPosition(),Z){for(var G=arguments.length,j=new Array(G>1?G-1:0),q=1;q<G;q++)j[q-1]=arguments[q];Z.apply(void 0,[V].concat(j))}},E.onChange=function(V){var Z=E.props.onChange;E.state.focused&&(E.inputting=!0),E.rawInput=E.props.parser(E.getValueFromEvent(V)),E.setState({inputValue:E.rawInput}),Z(E.toNumber(E.rawInput))},E.onMouseUp=function(){var V=E.props.onMouseUp;E.recordCursorPosition(),V&&V.apply(void 0,arguments)},E.onFocus=function(){var V;E.setState({focused:!0}),(V=E.props).onFocus.apply(V,arguments)},E.onBlur=function(){var V=E.props.onBlur;E.inputting=!1,E.setState({focused:!1});var Z=E.getCurrentValidValue(E.state.inputValue),G=E.setValue(Z,h);if(V){var j=E.input.value,q=E.getInputDisplayValue({focus:!1,value:G});E.input.value=q&&Number(q),V.apply(void 0,arguments),E.input.value=j}},E.getRatio=function(V){var Z=1;return V.metaKey||V.ctrlKey?Z=.1:V.shiftKey&&(Z=10),Z},E.getFullNum=function(V){return isNaN(V)?V:/e/i.test(String(V))?Number(V).toFixed(18).replace(/\.?0+$/,""):V},E.getPrecision=function(V){if(f(E.props.precision))return E.props.precision;var Z=String(V);if(Z.indexOf("e-")>=0)return parseInt(Z.slice(Z.indexOf("e-")+2),10);var G=0;return Z.indexOf(".")>=0&&(G=Z.length-Z.indexOf(".")-1),G},E.getInputDisplayValue=function(V){var Z=V||E.state,G=Z.focused,j=Z.inputValue,q=Z.value,ie;G?ie=j:ie=E.toPrecisionAsStep(q),ie==null&&(ie="");var ce=E.formatWrapper(ie);return f(E.props.decimalSeparator)&&(ce=ce.toString().replace(".",E.props.decimalSeparator)),ce},E.recordCursorPosition=function(){try{E.cursorStart=E.input.selectionStart,E.cursorEnd=E.input.selectionEnd,E.currentValue=E.input.value,E.cursorBefore=E.input.value.substring(0,E.cursorStart),E.cursorAfter=E.input.value.substring(E.cursorEnd)}catch(V){}},E.restoreByAfter=function(V){if(V===void 0)return!1;var Z=E.input.value,G=Z.lastIndexOf(V);if(G===-1)return!1;var j=E.cursorBefore.length;return E.lastKeyCode===A.a.DELETE&&E.cursorBefore.charAt(j-1)===V[0]?(E.fixCaret(j,j),!0):G+V.length===Z.length?(E.fixCaret(G,G),!0):!1},E.partRestoreByAfter=function(V){return V===void 0?!1:Array.prototype.some.call(V,function(Z,G){var j=V.substring(G);return E.restoreByAfter(j)})},E.isNotCompleteNumber=function(V){return isNaN(V)||V===""||V===null||V&&V.toString().indexOf(".")===V.toString().length-1},E.stop=function(){E.autoStepTimer&&clearTimeout(E.autoStepTimer)},E.down=function(V,Z,G){E.pressingUpOrDown=!0,E.step("down",V,Z,G)},E.up=function(V,Z,G){E.pressingUpOrDown=!0,E.step("up",V,Z,G)},E.saveInput=function(V){E.input=V};var _=g.value;_===void 0&&(_=g.defaultValue),E.state={focused:g.autoFocus};var H=E.getValidValue(E.toNumber(_));return E.state=L(L({},E.state),{},{inputValue:E.toPrecisionAsStep(H),value:H}),E}return Object(X.a)(v,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(E){var _=this.props,H=_.value,V=_.onChange,Z=_.max,G=_.min,j=this.state.focused;if(E){if(!k(E.value,H)||!k(E.max,Z)||!k(E.min,G)){var q=j?H:this.getValidValue(H),ie;this.pressingUpOrDown?ie=q:this.inputting?ie=this.rawInput:ie=this.toPrecisionAsStep(q),this.setState({value:q,inputValue:ie})}var ce="value"in this.props?H:this.state.value;"max"in this.props&&E.max!==Z&&typeof ce=="number"&&ce>Z&&V&&V(Z),"min"in this.props&&E.min!==G&&typeof ce=="number"&&ce<G&&V&&V(G)}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(ke){}if(this.lastKeyCode=null,!this.pressingUpOrDown)return;this.props.focusOnUpDown&&this.state.focused&&(document.activeElement!==this.input&&this.focus())}},{key:"componentWillUnmount",value:function(){this.stop()}},{key:"getCurrentValidValue",value:function(E){var _=E;return _===""?_="":this.isNotCompleteNumber(parseFloat(_))?_=this.state.value:_=this.getValidValue(_),this.toNumber(_)}},{key:"getValueFromEvent",value:function(E){var _=E.target.value.trim().replace(/。/g,".");return f(this.props.decimalSeparator)&&(_=_.replace(this.props.decimalSeparator,".")),_}},{key:"getValidValue",value:function(E){var _=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.props.min,H=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,V=parseFloat(E);return isNaN(V)?E:(V<_&&(V=_),V>H&&(V=H),V)}},{key:"setValue",value:function(E,_){var H=this.props.precision,V=this.isNotCompleteNumber(parseFloat(E))?null:parseFloat(E),Z=this.state.value,G=Z===void 0?null:Z,j=this.state.inputValue,q=j===void 0?null:j,ie=typeof V=="number"?V.toFixed(H):"".concat(V),ce=V!==G||ie!=="".concat(q);return"value"in this.props?(q=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:q},_)):this.setState({value:V,inputValue:this.toPrecisionAsStep(E)},_),ce&&this.props.onChange(V),V}},{key:"getMaxPrecision",value:function(E){var _=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,H=this.props,V=H.precision,Z=H.step;if(f(V))return V;var G=this.getPrecision(_),j=this.getPrecision(Z),q=this.getPrecision(E);return E?Math.max(q,G+j):G+j}},{key:"getPrecisionFactor",value:function(E){var _=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,H=this.getMaxPrecision(E,_);return Math.pow(10,H)}},{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(E){return this.props.formatter?this.props.formatter(E):E}},{key:"toPrecisionAsStep",value:function(E){if(this.isNotCompleteNumber(E)||E==="")return E;var _=Math.abs(this.getMaxPrecision(E));return isNaN(_)?E.toString():Number(E).toFixed(_)}},{key:"toNumber",value:function(E){var _=this.props.precision,H=this.state.focused,V=E&&E.length>16&&H;return this.isNotCompleteNumber(E)||V?E:f(_)?Math.round(E*Math.pow(10,_))/Math.pow(10,_):Number(E)}},{key:"upStep",value:function(E,_){var H=this.props.step,V=this.getPrecisionFactor(E,_),Z=Math.abs(this.getMaxPrecision(E,_)),G=((V*E+V*H*_)/V).toFixed(Z);return this.toNumber(G)}},{key:"downStep",value:function(E,_){var H=this.props.step,V=this.getPrecisionFactor(E,_),Z=Math.abs(this.getMaxPrecision(E,_)),G=((V*E-V*H*_)/V).toFixed(Z);return this.toNumber(G)}},{key:"step",value:function(E,_){var H=this,V=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,Z=arguments.length>3?arguments[3]:void 0;this.stop(),_&&(_.persist(),_.preventDefault());var G=this.props;if(G.disabled)return;var j=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(j))return;var q=this["".concat(E,"Step")](j,V),ie=q>G.max||q<G.min;if(q>G.max?q=G.max:q<G.min&&(q=G.min),this.setValue(q,null),this.setState({focused:!0},function(){H.pressingUpOrDown=!1}),ie)return;this.autoStepTimer=setTimeout(function(){H[E](_,V,!0)},Z?d:T)}},{key:"fixCaret",value:function(E,_){if(E===void 0||_===void 0||!this.input||!this.input.value)return;try{var H=this.input.selectionStart,V=this.input.selectionEnd;(E!==H||_!==V)&&this.input.setSelectionRange(E,_)}catch(Z){}}},{key:"render",value:function(){var E,_=this.props,H=_.prefixCls,V=_.disabled,Z=_.readOnly,G=_.useTouch,j=_.autoComplete,q=_.upHandler,ie=_.downHandler,ce=_.className,ve=_.max,ke=_.min,xe=_.style,Ce=_.title,Te=_.onMouseEnter,Ee=_.onMouseLeave,pe=_.onMouseOver,se=_.onMouseOut,Le=_.required,Xe=_.onClick,Ge=_.tabIndex,Ke=_.type,Ve=_.placeholder,De=_.id,Pe=_.inputMode,He=_.pattern,$e=_.step,Fe=_.maxLength,Ne=_.autoFocus,Me=_.name,at=_.onPaste,qe=_.onInput,Qe=Object(ne.a)(_,["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"]),tt=this.state,ut=tt.value,rt=tt.focused,it=b()(H,(E={},Object($.a)(E,ce,!!ce),Object($.a)(E,"".concat(H,"-disabled"),V),Object($.a)(E,"".concat(H,"-focused"),rt),E)),we={};Object.keys(Qe).forEach(function(ue){(ue.substr(0,5)==="data-"||ue.substr(0,5)==="aria-"||ue==="role")&&(we[ue]=Qe[ue])});var lt=!Z&&!V,et=this.getInputDisplayValue(null),Ae=(ut||ut===0)&&(isNaN(ut)||Number(ut)>=ve),Ue=(ut||ut===0)&&(isNaN(ut)||Number(ut)<=ke),me=Ae||V||Z,he=Ue||V||Z,fe=b()("".concat(H,"-handler"),"".concat(H,"-handler-up"),Object($.a)({},"".concat(H,"-handler-up-disabled"),me)),ee=b()("".concat(H,"-handler"),"".concat(H,"-handler-down"),Object($.a)({},"".concat(H,"-handler-down-disabled"),he)),te=G?{onTouchStart:me?h:this.up,onTouchEnd:this.stop}:{onMouseDown:me?h:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},ae=G?{onTouchStart:he?h:this.down,onTouchEnd:this.stop}:{onMouseDown:he?h:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return P.a.createElement("div",{className:it,style:xe,title:Ce,onMouseEnter:Te,onMouseLeave:Ee,onMouseOver:pe,onMouseOut:se,onFocus:function(){return null},onBlur:function(){return null}},P.a.createElement("div",{className:"".concat(H,"-handler-wrap")},P.a.createElement("span",Object.assign({unselectable:"on"},te,{role:"button","aria-label":"Increase Value","aria-disabled":me,className:fe}),q||P.a.createElement("span",{unselectable:"on",className:"".concat(H,"-handler-up-inner"),onClick:o})),P.a.createElement("span",Object.assign({unselectable:"on"},ae,{role:"button","aria-label":"Decrease Value","aria-disabled":he,className:ee}),ie||P.a.createElement("span",{unselectable:"on",className:"".concat(H,"-handler-down-inner"),onClick:o}))),P.a.createElement("div",{className:"".concat(H,"-input-wrap")},P.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":ke,"aria-valuemax":ve,"aria-valuenow":ut,required:Le,type:Ke,placeholder:Ve,onPaste:at,onClick:Xe,onMouseUp:this.onMouseUp,className:"".concat(H,"-input"),tabIndex:Ge,autoComplete:j,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:lt?this.onKeyDown:h,onKeyUp:lt?this.onKeyUp:h,autoFocus:Ne,maxLength:Fe,readOnly:Z,disabled:V,max:ve,min:ke,step:$e,name:Me,title:Ce,id:De,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(et),pattern:He,inputMode:Pe,onInput:qe},we))))}}]),v}(P.a.Component);x.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:y,min:-y,step:1,style:{},onChange:h,onKeyDown:h,onPressEnter:h,onFocus:h,onBlur:h,parser:u,required:!1,autoComplete:"off"};var p=x,c=ht.a=p},kSUc:function(wt,ht,re){},"kaH+":function(wt,ht,re){"use strict";var ne=re("+L6B"),$=re("2/Rp"),D=re("tJVT"),X=re("cDcd"),N=re.n(X),I=re("UZu5"),z=re.n(I),U=re("dhSg"),P=re("rLCj"),M=re("dF/Y"),b=re("4i/N");ht.a=function(){var A=Object(X.useState)(""),R=Object(D.a)(A,2),L=R[0],w=R[1],S=Object(X.useState)(0),h=Object(D.a)(S,2),o=h[0],u=h[1],d=Object(X.useRef)("");Object(X.useEffect)(function(){var c=U.a.subscribe("preview-image",function(s){w(s),document.body.style.overflow="hidden"});return c},[]),Object(X.useEffect)(function(){return document.addEventListener("keydown",T),function(){document.removeEventListener("keydown",T)}},[]),Object(X.useEffect)(function(){d.current=L},[L]);function T(c){c.keyCode==27&&d.current&&y()}function y(){document.body.style.overflow="auto",w("")}function f(){u(o+90)}var k=Object(X.useRef)(),x=Object(X.useRef)(),p=function(s){(s.nativeEvent.target===k.current||s.nativeEvent.target===x.current)&&y()};return N.a.createElement(X.Fragment,null,L?N.a.createElement("div",{className:"image-preview-container",ref:k,onClick:p},N.a.createElement("div",{className:"button-group"},N.a.createElement($.a,{onClick:f},"\u65CB\u8F6C",N.a.createElement(P.a,null)),N.a.createElement($.a,{href:L},"\u4E0B\u8F7D",N.a.createElement(M.a,null)),N.a.createElement($.a,{onClick:y},"\u5173\u95ED",N.a.createElement(b.a,null))),N.a.createElement("div",{className:"preview-wrp-group",ref:x},N.a.createElement("img",{className:"image-preview",src:L,alt:"\u9884\u89C8\u5927\u56FE",style:{transform:"rotate(".concat(o,"deg)")}}))):null)}},lZu9:function(wt,ht,re){(function(ne){ne(re("VrN/"),re("1eCo"),re("8EBN"))})(function(ne){"use strict";ne.defineMode("markdown",function($,D){var X=ne.getMode($,"text/html"),N=X.name=="null";function I(G){if(ne.findModeByName){var j=ne.findModeByName(G);j&&(G=j.mime||j.mimes[0])}var q=ne.getMode($,G);return q.name=="null"?null:q}D.highlightFormatting===void 0&&(D.highlightFormatting=!1),D.maxBlockquoteDepth===void 0&&(D.maxBlockquoteDepth=0),D.taskLists===void 0&&(D.taskLists=!1),D.strikethrough===void 0&&(D.strikethrough=!1),D.emoji===void 0&&(D.emoji=!1),D.fencedCodeBlockHighlighting===void 0&&(D.fencedCodeBlockHighlighting=!0),D.fencedCodeBlockDefaultMode===void 0&&(D.fencedCodeBlockDefaultMode="text/plain"),D.xml===void 0&&(D.xml=!0),D.tokenTypeOverrides===void 0&&(D.tokenTypeOverrides={});var z={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"image",imageAltText:"image-alt-text",imageMarker:"image-marker",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough",emoji:"builtin"};for(var U in z)z.hasOwnProperty(U)&&D.tokenTypeOverrides[U]&&(z[U]=D.tokenTypeOverrides[U]);var P=/^([*\-_])(?:\s*\1){2,}\s*$/,M=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,b=/^\[(x| )\](?=\s)/i,A=D.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,R=/^ {0,3}(?:\={1,}|-{2,})\s*$/,L=/^[^#!\[\]*_\\<>` "'(~:]+/,w=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,S=/^\s*\[[^\]]+?\]:.*$/,h=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/,o=" ";function u(G,j,q){return j.f=j.inline=q,q(G,j)}function d(G,j,q){return j.f=j.block=q,q(G,j)}function T(G){return!G||!/\S/.test(G.string)}function y(G){if(G.linkTitle=!1,G.linkHref=!1,G.linkText=!1,G.em=!1,G.strong=!1,G.strikethrough=!1,G.quote=0,G.indentedCode=!1,G.f==k){var j=N;if(!j){var q=ne.innerMode(X,G.htmlState);j=q.mode.name=="xml"&&q.state.tagStart===null&&!q.state.context&&q.state.tokenize.isInText}j&&(G.f=s,G.block=f,G.htmlState=null)}return G.trailingSpace=0,G.trailingSpaceNewLine=!1,G.prevLine=G.thisLine,G.thisLine={stream:null},null}function f(G,j){var q=G.column()===j.indentation,ie=T(j.prevLine.stream),ce=j.indentedCode,ve=j.prevLine.hr,ke=j.list!==!1,xe=(j.listStack[j.listStack.length-1]||0)+3;j.indentedCode=!1;var Ce=j.indentation;if(j.indentationDiff===null&&(j.indentationDiff=j.indentation,ke)){for(j.list=null;Ce<j.listStack[j.listStack.length-1];)j.listStack.pop(),j.listStack.length?j.indentation=j.listStack[j.listStack.length-1]:j.list=!1;j.list!==!1&&(j.indentationDiff=Ce-j.listStack[j.listStack.length-1])}var Te=!ie&&!ve&&!j.prevLine.header&&(!ke||!ce)&&!j.prevLine.fencedCodeEnd,Ee=(j.list===!1||ve||ie)&&j.indentation<=xe&&G.match(P),pe=null;if(j.indentationDiff>=4&&(ce||j.prevLine.fencedCodeEnd||j.prevLine.header||ie))return G.skipToEnd(),j.indentedCode=!0,z.code;if(G.eatSpace())return null;if(q&&j.indentation<=xe&&(pe=G.match(A))&&pe[1].length<=6)return j.quote=0,j.header=pe[1].length,j.thisLine.header=!0,D.highlightFormatting&&(j.formatting="header"),j.f=j.inline,p(j);if(j.indentation<=xe&&G.eat(">"))return j.quote=q?1:j.quote+1,D.highlightFormatting&&(j.formatting="quote"),G.eatSpace(),p(j);if(!Ee&&!j.setext&&q&&j.indentation<=xe&&(pe=G.match(M))){var se=pe[1]?"ol":"ul";return j.indentation=Ce+G.current().length,j.list=!0,j.quote=0,j.listStack.push(j.indentation),j.em=!1,j.strong=!1,j.code=!1,j.strikethrough=!1,D.taskLists&&G.match(b,!1)&&(j.taskList=!0),j.f=j.inline,D.highlightFormatting&&(j.formatting=["list","list-"+se]),p(j)}else{if(q&&j.indentation<=xe&&(pe=G.match(w,!0)))return j.quote=0,j.fencedEndRE=new RegExp(pe[1]+"+ *$"),j.localMode=D.fencedCodeBlockHighlighting&&I(pe[2]||D.fencedCodeBlockDefaultMode),j.localMode&&(j.localState=ne.startState(j.localMode)),j.f=j.block=x,D.highlightFormatting&&(j.formatting="code-block"),j.code=-1,p(j);if(j.setext||(!Te||!ke)&&!j.quote&&j.list===!1&&!j.code&&!Ee&&!S.test(G.string)&&(pe=G.lookAhead(1))&&(pe=pe.match(R)))return j.setext?(j.header=j.setext,j.setext=0,G.skipToEnd(),D.highlightFormatting&&(j.formatting="header")):(j.header=pe[0].charAt(0)=="="?1:2,j.setext=j.header),j.thisLine.header=!0,j.f=j.inline,p(j);if(Ee)return G.skipToEnd(),j.hr=!0,j.thisLine.hr=!0,z.hr;if(G.peek()==="[")return u(G,j,_)}return u(G,j,j.inline)}function k(G,j){var q=X.token(G,j.htmlState);if(!N){var ie=ne.innerMode(X,j.htmlState);(ie.mode.name=="xml"&&ie.state.tagStart===null&&!ie.state.context&&ie.state.tokenize.isInText||j.md_inside&&G.current().indexOf(">")>-1)&&(j.f=s,j.block=f,j.htmlState=null)}return q}function x(G,j){var q=j.listStack[j.listStack.length-1]||0,ie=j.indentation<q,ce=q+3;if(j.fencedEndRE&&j.indentation<=ce&&(ie||G.match(j.fencedEndRE))){D.highlightFormatting&&(j.formatting="code-block");var ve;return ie||(ve=p(j)),j.localMode=j.localState=null,j.block=f,j.f=s,j.fencedEndRE=null,j.code=0,j.thisLine.fencedCodeEnd=!0,ie?d(G,j,j.block):ve}else return j.localMode?j.localMode.token(G,j.localState):(G.skipToEnd(),z.code)}function p(G){var j=[];if(G.formatting){j.push(z.formatting),typeof G.formatting=="string"&&(G.formatting=[G.formatting]);for(var q=0;q<G.formatting.length;q++)j.push(z.formatting+"-"+G.formatting[q]),G.formatting[q]==="header"&&j.push(z.formatting+"-"+G.formatting[q]+"-"+G.header),G.formatting[q]==="quote"&&(!D.maxBlockquoteDepth||D.maxBlockquoteDepth>=G.quote?j.push(z.formatting+"-"+G.formatting[q]+"-"+G.quote):j.push("error"))}if(G.taskOpen)return j.push("meta"),j.length?j.join(" "):null;if(G.taskClosed)return j.push("property"),j.length?j.join(" "):null;if(G.linkHref?j.push(z.linkHref,"url"):(G.strong&&j.push(z.strong),G.em&&j.push(z.em),G.strikethrough&&j.push(z.strikethrough),G.emoji&&j.push(z.emoji),G.linkText&&j.push(z.linkText),G.code&&j.push(z.code),G.image&&j.push(z.image),G.imageAltText&&j.push(z.imageAltText,"link"),G.imageMarker&&j.push(z.imageMarker)),G.header&&j.push(z.header,z.header+"-"+G.header),G.quote&&(j.push(z.quote),!D.maxBlockquoteDepth||D.maxBlockquoteDepth>=G.quote?j.push(z.quote+"-"+G.quote):j.push(z.quote+"-"+D.maxBlockquoteDepth)),G.list!==!1){var ie=(G.listStack.length-1)%3;ie?ie===1?j.push(z.list2):j.push(z.list3):j.push(z.list1)}return G.trailingSpaceNewLine?j.push("trailing-space-new-line"):G.trailingSpace&&j.push("trailing-space-"+(G.trailingSpace%2?"a":"b")),j.length?j.join(" "):null}function c(G,j){return G.match(L,!0)?p(j):void 0}function s(G,j){var q=j.text(G,j);if(typeof q!="undefined")return q;if(j.list)return j.list=null,p(j);if(j.taskList){var ie=G.match(b,!0)[1]===" ";return ie?j.taskOpen=!0:j.taskClosed=!0,D.highlightFormatting&&(j.formatting="task"),j.taskList=!1,p(j)}if(j.taskOpen=!1,j.taskClosed=!1,j.header&&G.match(/^#+$/,!0))return D.highlightFormatting&&(j.formatting="header"),p(j);var ce=G.next();if(j.linkTitle){j.linkTitle=!1;var ve=ce;ce==="("&&(ve=")"),ve=(ve+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var ke="^\\s*(?:[^"+ve+"\\\\]+|\\\\\\\\|\\\\.)"+ve;if(G.match(new RegExp(ke),!0))return z.linkHref}if(ce==="`"){var xe=j.formatting;D.highlightFormatting&&(j.formatting="code"),G.eatWhile("`");var Ce=G.current().length;if(j.code==0&&(!j.quote||Ce==1))return j.code=Ce,p(j);if(Ce==j.code){var Te=p(j);return j.code=0,Te}else return j.formatting=xe,p(j)}else if(j.code)return p(j);if(ce==="\\"&&(G.next(),D.highlightFormatting)){var Ee=p(j),pe=z.formatting+"-escape";return Ee?Ee+" "+pe:pe}if(ce==="!"&&G.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return j.imageMarker=!0,j.image=!0,D.highlightFormatting&&(j.formatting="image"),p(j);if(ce==="["&&j.imageMarker&&G.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return j.imageMarker=!1,j.imageAltText=!0,D.highlightFormatting&&(j.formatting="image"),p(j);if(ce==="]"&&j.imageAltText){D.highlightFormatting&&(j.formatting="image");var Ee=p(j);return j.imageAltText=!1,j.image=!1,j.inline=j.f=v,Ee}if(ce==="["&&!j.image)return j.linkText&&G.match(/^.*?\]/)||(j.linkText=!0,D.highlightFormatting&&(j.formatting="link")),p(j);if(ce==="]"&&j.linkText){D.highlightFormatting&&(j.formatting="link");var Ee=p(j);return j.linkText=!1,j.inline=j.f=G.match(/\(.*?\)| ?\[.*?\]/,!1)?v:s,Ee}if(ce==="<"&&G.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){j.f=j.inline=a,D.highlightFormatting&&(j.formatting="link");var Ee=p(j);return Ee?Ee+=" ":Ee="",Ee+z.linkInline}if(ce==="<"&&G.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){j.f=j.inline=a,D.highlightFormatting&&(j.formatting="link");var Ee=p(j);return Ee?Ee+=" ":Ee="",Ee+z.linkEmail}if(D.xml&&ce==="<"&&G.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var se=G.string.indexOf(">",G.pos);if(se!=-1){var Le=G.string.substring(G.start,se);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(Le)&&(j.md_inside=!0)}return G.backUp(1),j.htmlState=ne.startState(X),d(G,j,k)}if(D.xml&&ce==="<"&&G.match(/^\/\w*?>/))return j.md_inside=!1,"tag";if(ce==="*"||ce==="_"){for(var Xe=1,Ge=G.pos==1?" ":G.string.charAt(G.pos-2);Xe<3&&G.eat(ce);)Xe++;var Ke=G.peek()||" ",Ve=!/\s/.test(Ke)&&(!h.test(Ke)||/\s/.test(Ge)||h.test(Ge)),De=!/\s/.test(Ge)&&(!h.test(Ge)||/\s/.test(Ke)||h.test(Ke)),Pe=null,He=null;if(Xe%2&&(!j.em&&Ve&&(ce==="*"||!De||h.test(Ge))?Pe=!0:j.em==ce&&De&&(ce==="*"||!Ve||h.test(Ke))&&(Pe=!1)),Xe>1&&(!j.strong&&Ve&&(ce==="*"||!De||h.test(Ge))?He=!0:j.strong==ce&&De&&(ce==="*"||!Ve||h.test(Ke))&&(He=!1)),He!=null||Pe!=null){D.highlightFormatting&&(j.formatting=Pe==null?"strong":He==null?"em":"strong em"),Pe===!0&&(j.em=ce),He===!0&&(j.strong=ce);var Te=p(j);return Pe===!1&&(j.em=!1),He===!1&&(j.strong=!1),Te}}else if(ce===" "&&(G.eat("*")||G.eat("_"))){if(G.peek()===" ")return p(j);G.backUp(1)}if(D.strikethrough){if(ce==="~"&&G.eatWhile(ce)){if(j.strikethrough){D.highlightFormatting&&(j.formatting="strikethrough");var Te=p(j);return j.strikethrough=!1,Te}else if(G.match(/^[^\s]/,!1))return j.strikethrough=!0,D.highlightFormatting&&(j.formatting="strikethrough"),p(j)}else if(ce===" "&&G.match(/^~~/,!0)){if(G.peek()===" ")return p(j);G.backUp(2)}}if(D.emoji&&ce===":"&&G.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){j.emoji=!0,D.highlightFormatting&&(j.formatting="emoji");var $e=p(j);return j.emoji=!1,$e}return ce===" "&&(G.match(/^ +$/,!1)?j.trailingSpace++:j.trailingSpace&&(j.trailingSpaceNewLine=!0)),p(j)}function a(G,j){var q=G.next();if(q===">"){j.f=j.inline=s,D.highlightFormatting&&(j.formatting="link");var ie=p(j);return ie?ie+=" ":ie="",ie+z.linkInline}return G.match(/^[^>]+/,!0),z.linkInline}function v(G,j){if(G.eatSpace())return null;var q=G.next();return q==="("||q==="["?(j.f=j.inline=E(q==="("?")":"]"),D.highlightFormatting&&(j.formatting="link-string"),j.linkHref=!0,p(j)):"error"}var g={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function E(G){return function(j,q){var ie=j.next();if(ie===G){q.f=q.inline=s,D.highlightFormatting&&(q.formatting="link-string");var ce=p(q);return q.linkHref=!1,ce}return j.match(g[G]),q.linkHref=!0,p(q)}}function _(G,j){return G.match(/^([^\]\\]|\\.)*\]:/,!1)?(j.f=H,G.next(),D.highlightFormatting&&(j.formatting="link"),j.linkText=!0,p(j)):u(G,j,s)}function H(G,j){if(G.match(/^\]:/,!0)){j.f=j.inline=V,D.highlightFormatting&&(j.formatting="link");var q=p(j);return j.linkText=!1,q}return G.match(/^([^\]\\]|\\.)+/,!0),z.linkText}function V(G,j){return G.eatSpace()?null:(G.match(/^[^\s]+/,!0),G.peek()===void 0?j.linkTitle=!0:G.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),j.f=j.inline=s,z.linkHref+" url")}var Z={startState:function(){return{f,prevLine:{stream:null},thisLine:{stream:null},block:f,htmlState:null,indentation:0,inline:s,text:c,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(G){return{f:G.f,prevLine:G.prevLine,thisLine:G.thisLine,block:G.block,htmlState:G.htmlState&&ne.copyState(X,G.htmlState),indentation:G.indentation,localMode:G.localMode,localState:G.localMode?ne.copyState(G.localMode,G.localState):null,inline:G.inline,text:G.text,formatting:!1,linkText:G.linkText,linkTitle:G.linkTitle,linkHref:G.linkHref,code:G.code,em:G.em,strong:G.strong,strikethrough:G.strikethrough,emoji:G.emoji,header:G.header,setext:G.setext,hr:G.hr,taskList:G.taskList,list:G.list,listStack:G.listStack.slice(0),quote:G.quote,indentedCode:G.indentedCode,trailingSpace:G.trailingSpace,trailingSpaceNewLine:G.trailingSpaceNewLine,md_inside:G.md_inside,fencedEndRE:G.fencedEndRE}},token:function(G,j){if(j.formatting=!1,G!=j.thisLine.stream){if(j.header=0,j.hr=!1,G.match(/^\s*$/,!0))return y(j),null;if(j.prevLine=j.thisLine,j.thisLine={stream:G},j.taskList=!1,j.trailingSpace=0,j.trailingSpaceNewLine=!1,!j.localState&&(j.f=j.block,j.f!=k)){var q=G.match(/^\s*/,!0)[0].replace(/\t/g,o).length;if(j.indentation=q,j.indentationDiff=null,q>0)return null}}return j.f(G,j)},innerMode:function(G){return G.block==k?{state:G.htmlState,mode:X}:G.localState?{state:G.localState,mode:G.localMode}:{state:G,mode:Z}},indent:function(G,j,q){return G.block==k&&X.indent?X.indent(G.htmlState,j,q):G.localState&&G.localMode.indent?G.localMode.indent(G.localState,j,q):ne.Pass},blankLine:y,getType:p,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return Z},"xml"),ne.defineMIME("text/markdown","markdown"),ne.defineMIME("text/x-markdown","markdown")})},osHv:function(wt,ht,re){(function(ne){ne(re("VrN/"))})(function(ne){"use strict";var $=ne.Pos;function D(h,o){return h.line-o.line||h.ch-o.ch}var X="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",N=X+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",I=new RegExp("<(/?)(["+X+"]["+N+"]*)","g");function z(h,o,u,d){this.line=o,this.ch=u,this.cm=h,this.text=h.getLine(o),this.min=d?Math.max(d.from,h.firstLine()):h.firstLine(),this.max=d?Math.min(d.to-1,h.lastLine()):h.lastLine()}function U(h,o){var u=h.cm.getTokenTypeAt($(h.line,o));return u&&/\btag\b/.test(u)}function P(h){return h.line>=h.max?void 0:(h.ch=0,h.text=h.cm.getLine(++h.line),!0)}function M(h){return h.line<=h.min?void 0:(h.text=h.cm.getLine(--h.line),h.ch=h.text.length,!0)}function b(h){for(;;){var o=h.text.indexOf(">",h.ch);if(o==-1){if(P(h))continue;return}if(!U(h,o+1)){h.ch=o+1;continue}var u=h.text.lastIndexOf("/",o),d=u>-1&&!/\S/.test(h.text.slice(u+1,o));return h.ch=o+1,d?"selfClose":"regular"}}function A(h){for(;;){var o=h.ch?h.text.lastIndexOf("<",h.ch-1):-1;if(o==-1){if(M(h))continue;return}if(!U(h,o+1)){h.ch=o;continue}I.lastIndex=o,h.ch=o;var u=I.exec(h.text);if(u&&u.index==o)return u}}function R(h){for(;;){I.lastIndex=h.ch;var o=I.exec(h.text);if(!o){if(P(h))continue;return}if(!U(h,o.index+1)){h.ch=o.index+1;continue}return h.ch=o.index+o[0].length,o}}function L(h){for(;;){var o=h.ch?h.text.lastIndexOf(">",h.ch-1):-1;if(o==-1){if(M(h))continue;return}if(!U(h,o+1)){h.ch=o;continue}var u=h.text.lastIndexOf("/",o),d=u>-1&&!/\S/.test(h.text.slice(u+1,o));return h.ch=o+1,d?"selfClose":"regular"}}function w(h,o){for(var u=[];;){var d=R(h),T,y=h.line,f=h.ch-(d?d[0].length:0);if(!d||!(T=b(h)))return;if(T=="selfClose")continue;if(d[1]){for(var k=u.length-1;k>=0;--k)if(u[k]==d[2]){u.length=k;break}if(k<0&&(!o||o==d[2]))return{tag:d[2],from:$(y,f),to:$(h.line,h.ch)}}else u.push(d[2])}}function S(h,o){for(var u=[];;){var d=L(h);if(!d)return;if(d=="selfClose"){A(h);continue}var T=h.line,y=h.ch,f=A(h);if(!f)return;if(f[1])u.push(f[2]);else{for(var k=u.length-1;k>=0;--k)if(u[k]==f[2]){u.length=k;break}if(k<0&&(!o||o==f[2]))return{tag:f[2],from:$(h.line,h.ch),to:$(T,y)}}}}ne.registerHelper("fold","xml",function(h,o){for(var u=new z(h,o.line,0);;){var d=R(u);if(!d||u.line!=o.line)return;var T=b(u);if(!T)return;if(!d[1]&&T!="selfClose"){var y=$(u.line,u.ch),f=w(u,d[2]);return f&&D(f.from,y)>0?{from:y,to:f.from}:null}}}),ne.findMatchingTag=function(h,o,u){var d=new z(h,o.line,o.ch,u);if(d.text.indexOf(">")==-1&&d.text.indexOf("<")==-1)return;var T=b(d),y=T&&$(d.line,d.ch),f=T&&A(d);if(!T||!f||D(d,o)>0)return;var k={from:$(d.line,d.ch),to:y,tag:f[2]};return T=="selfClose"?{open:k,close:null,at:"open"}:f[1]?{open:S(d,f[2]),close:k,at:"close"}:(d=new z(h,y.line,y.ch,u),{open:k,close:w(d,f[2]),at:"open"})},ne.findEnclosingTag=function(h,o,u,d){for(var T=new z(h,o.line,o.ch,u);;){var y=S(T,d);if(!y)break;var f=new z(h,o.line,o.ch,u),k=w(f,y.tag);if(k)return{open:y,close:k}}},ne.scanForClosingTag=function(h,o,u,d){var T=new z(h,o.line,o.ch,d?{from:0,to:d}:null);return w(T,u)}})},p5ED:function(wt,ht,re){"use strict";var ne=re("+L6B"),$=re("2/Rp"),D=re("5Dmo"),X=re("3S7+"),N=re("k1fw"),I=re("tJVT"),z=re("cDcd"),U=re.n(z),P=re("vHTk"),M=re.n(P),b=re("yEEn"),A=re("ZW9T"),R=re("1vsH");ht.a=function(L){var w=L.name,S=L.data,h=L.theme,o=L.type,u=L.filename,d=L.monacoEditor,T=L.className,y=L.style,f=L.close,k=L.onClose,x=L.hasMask,p=Object(z.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),c=Object(I.a)(p,2),s=c[0],a=c[1],v=Object(z.useState)(""),g=Object(I.a)(v,2),E=g[0],_=g[1],H,V=1024*1024,Z=10*V,G=Object(z.useRef)();o==="office"&&(H=Object(R.V)(S).filesize,H>Z&&(o="other")),u&&(d.filename=u),Object(z.useEffect)(function(){var ie,ce,ve=(ie=document.cookie)===null||ie===void 0||((ce=ie.replace(/\s/g,""))===null||ce===void 0)?void 0:ce.split(";");ve==null||ve.map(function(ke){var xe=ke.split("=");xe[0]==="_educoder_session"&&_(xe[1])})},[]);var j=function(){if(S.startsWith("http")||S.startsWith("/")){q();return}Object(R.z)(u||"educoder",S,u)},q=function(){Object(R.x)(u||w,S)};return console.log("data:",S,"fileanme:",u," name:",w),U.a.createElement("div",{style:Object(N.a)({},y||{}),className:"".concat(x&&M.a.bgBlack," ").concat(o?M.a.wrp:"hide")},f&&U.a.createElement("div",{className:M.a.close,ref:G},U.a.createElement(X.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return G.current}},U.a.createElement("span",{onClick:q},U.a.createElement("i",{className:"icon-quxiaozhiding"}))),U.a.createElement(X.a,{title:"\u5173\u95ED",getPopupContainer:function(){return G.current}},U.a.createElement("span",{className:"",onClick:k},U.a.createElement("i",{className:"icon-guanbi1"})))),U.a.createElement("div",{className:"".concat(M.a[T]," ").concat(T," ").concat(M.a.monaco," ").concat(o==="txt"?"show":"hide")},o==="txt"&&U.a.createElement(A.b,d)),o==="audio"&&U.a.createElement("audio",{src:"".concat(S!=null&&S.startsWith("/")||(S==null?void 0:S.indexOf("https://"))>-1?S:"data:audio/mp3;base64,").concat(S),autoPlay:!0}),o==="video"&&U.a.createElement(U.a.Fragment,null,S!=null&&S.startsWith("/")?U.a.createElement("video",{controls:!0,src:"".concat(S),autoPlay:!0}):U.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(S),autoPlay:!0})),o==="html"&&U.a.createElement("iframe",{src:S+"&disposition=inline"}),o==="pdf"&&U.a.createElement("embed",{className:M.a.embed,src:S}),o==="image"&&U.a.createElement(U.a.Fragment,null,U.a.createElement("img",{src:"".concat(S!=null&&S.startsWith("/")||(S==null?void 0:S.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(S)})),o==="other"&&U.a.createElement("div",null,U.a.createElement($.a,{type:"primary",size:"large",onClick:j},U.a.createElement(b.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),(o==="download"||o==="office")&&U.a.createElement($.a,{type:"primary",size:"large",onClick:j},U.a.createElement(b.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(wt,ht,re){},rUJ1:function(wt,ht){const re=/[&<>"']/,ne=/[&<>"']/g,$=/[<>"']|&(?!#?\w+;)/,D=/[<>"']|&(?!#?\w+;)/g,X={"&":"&","<":"<",">":">",'"':""","'":"'"},N=x=>X[x];function I(x,p){if(p){if(re.test(x))return x.replace(ne,N)}else if($.test(x))return x.replace(D,N);return x}const z=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function U(x){return x.replace(z,(p,c)=>(c=c.toLowerCase(),c==="colon"?":":c.charAt(0)==="#"?c.charAt(1)==="x"?String.fromCharCode(parseInt(c.substring(2),16)):String.fromCharCode(+c.substring(1)):""))}const P=/(^|[^\[])\^/g;function M(x,p){x=x.source||x,p=p||"";const c={replace:(s,a)=>(a=a.source||a,a=a.replace(P,"$1"),x=x.replace(s,a),c),getRegex:()=>new RegExp(x,p)};return c}const b=/[^\w:]/g,A=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function R(x,p,c){if(x){let s;try{s=decodeURIComponent(U(c)).replace(b,"").toLowerCase()}catch(a){return null}if(s.indexOf("javascript:")===0||s.indexOf("vbscript:")===0||s.indexOf("data:")===0)return null}p&&!A.test(c)&&(c=o(p,c));try{c=encodeURI(c).replace(/%25/g,"%")}catch(s){return null}return c}const L={},w=/^[^:]+:\/*[^/]*$/,S=/^([^:]+:)[\s\S]*$/,h=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(x,p){L[" "+x]||(w.test(x)?L[" "+x]=x+"/":L[" "+x]=y(x,"/",!0)),x=L[" "+x];const c=x.indexOf(":")===-1;return p.substring(0,2)==="//"?c?p:x.replace(S,"$1")+p:p.charAt(0)==="/"?c?p:x.replace(h,"$1")+p:x+p}const u={exec:function(){}};function d(x){let p=1,c,s;for(;p<arguments.length;p++){c=arguments[p];for(s in c)Object.prototype.hasOwnProperty.call(c,s)&&(x[s]=c[s])}return x}function T(x,p){const c=x.replace(/\|/g,(v,g,E)=>{let _=!1,H=g;for(;--H>=0&&E[H]==="\\";)_=!_;return _?"|":" |"}),s=c.split(/ \|/);let a=0;if(s.length>p)s.splice(p);else for(;s.length<p;)s.push("");for(;a<s.length;a++)s[a]=s[a].trim().replace(/\\\|/g,"|");return s}function y(x,p,c){const s=x.length;if(s===0)return"";let a=0;for(;a<s;){const v=x.charAt(s-a-1);if(v===p&&!c)a++;else if(v!==p&&c)a++;else break}return x.substr(0,s-a)}function f(x,p){if(x.indexOf(p[1])===-1)return-1;const c=x.length;let s=0,a=0;for(;a<c;a++)if(x[a]==="\\")a++;else if(x[a]===p[0])s++;else if(x[a]===p[1]&&(s--,s<0))return a;return-1}function k(x){x&&x.sanitize&&!x.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}wt.exports={escape:I,unescape:U,edit:M,cleanUrl:R,resolveUrl:o,noopTest:u,merge:d,splitCells:T,rtrim:y,findClosingBracket:f,checkSanitizeDeprecation:k}},"s/Zd":function(wt,ht,re){"use strict";re.r(ht);var ne=re("cWXX"),$=re("/ezw"),D=re("DjyN"),X=re("NUBc"),N=re("/zsF"),I=re("PArb"),z=re("5NDa"),U=re("5rEg"),P=re("+L6B"),M=re("2/Rp"),b=re("5Dmo"),A=re("3S7+"),R=re("miYZ"),L=re("tsqr"),w=re("2qtc"),S=re("kLXV"),h=re("k1fw"),o=re("9og8"),u=re("tJVT"),d=re("WmNS"),T=re.n(d),y=re("cDcd"),f=re.n(y),k=re("Ty5D"),x=re("9kvl"),p=re("Ot1p"),c=re("9Bee"),s=re("ErOA"),a=function(ie){var ce=ie.classroomList,ve=ie.dispatch,ke=Object(k.i)();return ke.id=ke.coursesId,f.a.createElement(S.a,{centered:!0,title:"\u63D0\u793A",visible:ce.actionTabs.key==="\u5220\u9664",okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",onOk:Object(o.a)(T.a.mark(function xe(){var Ce;return T.a.wrap(function(Ee){for(;;)switch(Ee.prev=Ee.next){case 0:return Ee.next=2,Object(s.a)("/api/courses/".concat(ke.id,"/delete_informs.json"),{method:"delete",body:{inform_id:ce.actionTabs.selectArrs}});case 2:Ce=Ee.sent,Ce.status===0&&(L.b.success("\u5220\u9664\u6210\u529F"),ve({type:"classroomList/setActionTabs",payload:{}}),ve({type:"classroomList/getAnnouncementList",payload:Object(h.a)({},ke)}),ve({type:"classroomList/getClassroomLeftMenus",payload:{id:ke.coursesId}}));case 4:case"end":return Ee.stop()}},xe)})),onCancel:function(){ve({type:"classroomList/setActionTabs",payload:{}})}},f.a.createElement("p",null,"\u662F\u5426\u786E\u8BA4\u5220\u9664\uFF1F"))},v=Object(x.a)(function(q){var ie=q.classroomList;return{classroomList:ie}})(a),g=re("BdwD"),E=re("xKgJ"),_=re("xLg1"),H=re.n(_),V=re("kaH+"),Z=re("dhSg"),G=function(ie){var ce=ie.classroomList,ve=ie.globalSetting,ke=ie.dispatch,xe=ie.virtualSpaces,Ce=Object(y.useState)(-1),Te=Object(u.a)(Ce,2),Ee=Te[0],pe=Te[1],se=Object(y.useState)(!1),Le=Object(u.a)(se,2),Xe=Le[0],Ge=Le[1],Ke=Object(y.useState)(!1),Ve=Object(u.a)(Ke,2),De=Ve[0],Pe=Ve[1],He=Object(y.useState)({name:"",description:""}),$e=Object(u.a)(He,2),Fe=$e[0],Ne=$e[1],Me=Object(y.useState)([]),at=Object(u.a)(Me,2),qe=at[0],Qe=at[1],tt=Object(y.useState)(0),ut=Object(u.a)(tt,2),rt=ut[0],it=ut[1],we=Object(y.useState)(!0),lt=Object(u.a)(we,2),et=lt[0],Ae=lt[1],Ue=xe.virtualSpacesDetails,me=Object(k.i)(),he=Object(y.useState)({page:1,limit:100,virtual_classroom_id:me.virtual_spacesId}),fe=Object(u.a)(he,2),ee=fe[0],te=fe[1];Object(y.useEffect)(function(){ae(ee)},[]);var ae=function(){var ot=Object(o.a)(T.a.mark(function We(yt){var ft;return T.a.wrap(function(xt){for(;;)switch(xt.prev=xt.next){case 0:return Ae(!0),xt.next=3,Object(s.a)("/api/virtual_classrooms/".concat(me.virtual_spacesId,"/informs.json"),{method:"get",params:yt});case 3:ft=xt.sent,ft!=null&&ft.informs&&(Qe((ft==null?void 0:ft.informs)||[]),it(ft==null?void 0:ft.total_count)),Ae(!1);case 6:case"end":return xt.stop()}},We)}));return function(yt){return ot.apply(this,arguments)}}(),ue=function(We){document.body.scrollIntoView(),ee.page=We,te(Object(h.a)({},ee)),ae(ee)},ge=function(We,yt){S.a.confirm({centered:!0,width:424,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",title:"\u63D0\u793A",icon:null,className:"custom-modal-divider",content:f.a.createElement("div",{className:"font14"},"\u786E\u8BA4\u5220\u9664\u5417\uFF1F"),onOk:function(){var ft=Object(o.a)(T.a.mark(function xt(){var Dt,Er;return T.a.wrap(function(bt){for(;;)switch(bt.prev=bt.next){case 0:return bt.next=2,Object(s.a)("/api/virtual_classrooms/".concat(me.virtual_spacesId,"/informs/").concat(yt,".json"),{method:"delete",body:{}});case 2:Dt=bt.sent,(Dt==null?void 0:Dt.status)===0&&(Er=qe.length===1&&ee.page>1?ee.page-1:ee.page,ee.page=Er,te(Object(h.a)({},ee)),ae(ee),L.b.success("\u5220\u9664\u6210\u529F"));case 4:case"end":return bt.stop()}},xt)}));function _t(){return ft.apply(this,arguments)}return _t}()})},Se=function(){var ot=Object(o.a)(T.a.mark(function We(yt,ft){return T.a.wrap(function(xt){for(;;)switch(xt.prev=xt.next){case 0:xt.t0=ft,xt.next=xt.t0==="up"?3:xt.t0==="down"?6:xt.t0==="del"?9:xt.t0==="edit"?11:18;break;case 3:return xt.next=5,ke({type:"announcement/informUp",payload:Object(h.a)({inform_id:yt.id},ee)});case 5:return xt.abrupt("break",18);case 6:return xt.next=8,ke({type:"announcement/informDown",payload:Object(h.a)({inform_id:yt.id},ee)});case 8:return xt.abrupt("break",18);case 9:return ge(yt,yt.id),xt.abrupt("break",18);case 11:if(!Xe){xt.next=14;break}return L.b.warn("\u5F53\u524D\u6709\u6B63\u5728\u65B0\u5EFA\u7684\u901A\u77E5\u516C\u544A\uFF0C\u8BF7\u5148\u53D6\u6D88\u6216\u8005\u4FDD\u5B58\uFF01"),xt.abrupt("return");case 14:return Fe.name=yt.name,Fe.description=yt.description,pe(yt.key),xt.abrupt("break",18);case 18:(ft==="down"||ft==="up")&&ke({type:"classroomList/getAnnouncementList",payload:Object(h.a)({},ee)});case 19:case"end":return xt.stop()}},We)}));return function(yt,ft){return ot.apply(this,arguments)}}(),Oe=function(We,yt){return We.key=yt,f.a.createElement("section",null,(We==null?void 0:We.can_remove)&&f.a.createElement("aside",null,f.a.createElement(A.a,{placement:"bottom",title:"\u5220\u9664"},f.a.createElement("span",{className:"iconfont c-blue current ml30 icon-shanchu",onClick:function(){Se(We,"del")}})),f.a.createElement(A.a,{placement:"bottom",title:"\u7F16\u8F91"},f.a.createElement("span",{className:"iconfont c-blue current ml30 icon-bianjishijuan3x",onClick:function(){Se(We,"edit")}}))))},nt=function(){var ot=Object(o.a)(T.a.mark(function We(){var yt;return T.a.wrap(function(_t){for(;;)switch(_t.prev=_t.next){case 0:if(!(Fe.name==="")){_t.next=4;break}L.b.error("\u8BF7\u8F93\u5165\u6807\u9898"),_t.next=14;break;case 4:if(!(Fe.description==="")){_t.next=8;break}L.b.error("\u8BF7\u8F93\u5165\u5185\u5BB9"),_t.next=14;break;case 8:return Pe(!0),_t.next=11,Object(s.a)("/api/virtual_classrooms/".concat(me.virtual_spacesId,"/informs.json"),{method:"post",body:Object(h.a)({},Fe)});case 11:yt=_t.sent,yt.status===0&&(L.b.success("\u53D1\u5E03\u6210\u529F"),ae(ee),Ge(!1),Ne({name:"",description:""})),Pe(!1);case 14:case"end":return _t.stop()}},We)}));return function(){return ot.apply(this,arguments)}}(),gt=function(){var ot=Object(o.a)(T.a.mark(function We(yt){var ft;return T.a.wrap(function(xt){for(;;)switch(xt.prev=xt.next){case 0:if(!(Fe.name==="")){xt.next=4;break}L.b.error("\u8BF7\u8F93\u5165\u6807\u9898"),xt.next=12;break;case 4:if(!(Fe.description==="")){xt.next=8;break}L.b.error("\u8BF7\u8F93\u5165\u5185\u5BB9"),xt.next=12;break;case 8:return xt.next=10,Object(s.a)("/api/virtual_classrooms/".concat(me.virtual_spacesId,"/informs/").concat(yt.id,".json"),{method:"put",body:Object(h.a)(Object(h.a)(Object(h.a)({},ee),Fe),{},{inform_id:yt.id})});case 10:ft=xt.sent,ft.status===0&&(L.b.success("\u66F4\u65B0\u6210\u529F"),pe(-1),ae(ee));case 12:case"end":return xt.stop()}},We)}));return function(yt){return ot.apply(this,arguments)}}(),ct=function(We){var yt=We.target,ft=yt.nodeName,_t=yt.src;ft==="IMG"&&(Z.a.publish("preview-image",_t),console.log("src:",_t))},kt=(Ue==null?void 0:Ue.is_member)||Object(E.v)();return f.a.createElement("section",{style:{width:965}},f.a.createElement("aside",{className:H.a.bg},f.a.createElement("div",{className:H.a.containerTitle},f.a.createElement("div",{className:"font16"},"\u901A\u77E5\u516C\u544A"),f.a.createElement("div",{className:H.a.titleRightMenu},kt&&f.a.createElement(M.a,{onClick:function(){if(Ee!==-1){L.b.warn("\u5F53\u524D\u6709\u6B63\u5728\u4FEE\u6539\u7684\u901A\u77E5\u516C\u544A\uFF0C\u8BF7\u5148\u53D6\u6D88\u6216\u8005\u4FDD\u5B58\uFF01");return}Ge(!0)},style:{marginLeft:"auto"},ghost:!0,type:"primary"},f.a.createElement("i",{className:"iconfont icon-tianjia1 font14 mr5"}),"\u65B0\u589E\u901A\u77E5\u516C\u544A")))),f.a.createElement("aside",{className:"bg-white pl30 pr30 pt30 pb20"},Xe&&f.a.createElement("div",{className:"pb30"},f.a.createElement(U.a,{maxLength:60,onChange:function(We){Fe.name=We.target.value,Ne(Object(h.a)({},Fe))},suffix:f.a.createElement("span",null,Fe.name.length,"/60"),size:"large",placeholder:"\u8BF7\u5728\u6B64\u8F93\u5165\u6807\u9898\uFF0C\u6700\u591A60\u4E2A\u5B57\u7B26"}),f.a.createElement("div",{className:"mt15"},f.a.createElement(p.a,{watch:!0,onChange:function(We){Fe.description=We},placeholder:"\u8BF7\u5728\u6B64\u8F93\u5165\u5185\u5BB9\uFF0C\u6700\u591A5000\u4E2A\u5B57\u7B26"})),f.a.createElement("div",{className:H.a.actionButton},f.a.createElement(M.a,{className:"mr10",type:"primary",onClick:function(){Ne({name:"",description:""}),Ge(!1)},ghost:!0},"\u53D6\u6D88"),f.a.createElement(M.a,{loading:De,type:"primary",onClick:function(){return nt()}},"\u63D0\u4EA4"))),f.a.createElement($.a,{loading:et,active:!0,paragraph:{rows:5},className:"mt30"},rt===0&&!Xe&&f.a.createElement("div",{className:"pb30"},f.a.createElement(g.a,null)),qe&&qe.map(function(ot,We){return f.a.createElement("div",{className:H.a.listItem,key:We},Ee===We&&f.a.createElement("div",null,f.a.createElement(U.a,{max:60,onChange:function(ft){Fe.name=ft.target.value,Ne(Object(h.a)({},Fe))},suffix:f.a.createElement("span",null,Fe.name.length,"/60"),defaultValue:ot.name,size:"large",placeholder:"\u8BF7\u5728\u6B64\u8F93\u5165\u6807\u9898\uFF0C\u6700\u591A60\u4E2A\u5B57\u7B26"}),f.a.createElement("div",{className:"mt15"},f.a.createElement(p.a,{watch:!0,onChange:function(ft){Fe.description=ft},placeholder:"\u8BF7\u5728\u6B64\u8F93\u5165\u5185\u5BB9\uFF0C\u6700\u591A5000\u4E2A\u5B57\u7B26",defaultValue:ot.description})),f.a.createElement("div",{className:H.a.actionButton},f.a.createElement(M.a,{className:"mr10",type:"primary",onClick:function(){return pe(-1)},ghost:!0},"\u53D6\u6D88"),f.a.createElement(M.a,{type:"primary",onClick:function(){return gt(ot)}},"\u63D0\u4EA4"))),Ee!==We&&f.a.createElement("div",null,f.a.createElement("div",{className:H.a.listItemTitle},f.a.createElement("div",{className:"font20 c-black bold"},ot.name),!Xe&&Oe(ot,We)),f.a.createElement("div",{onClick:ct,className:H.a.info},f.a.createElement(c.a,{value:ot.description}))),f.a.createElement(I.a,null))}),f.a.createElement(X.a,{hideOnSinglePage:!0,onChange:function(We){return ue(We)},current:ee.page,pageSize:ee.limit,total:rt,showQuickJumper:!0,showSizeChanger:!1,showTotal:function(We){return f.a.createElement("span",{className:"mr10"},"\u5171",f.a.createElement("span",{className:"c-orange"},We),"\u6761\u6570\u636E")},className:"tr pb20"}))),f.a.createElement(v,null),f.a.createElement(V.a,null))},j=ht.default=Object(x.a)(function(q){var ie=q.classroomList,ce=q.virtualSpaces,ve=q.globalSetting;return{classroomList:ie,globalSetting:ve,virtualSpaces:ce}})(G)},ulZh:function(wt,ht,re){typeof window!="undefined"&&function($,D){wt.exports=D()}(this,function(){return function(ne){var $={};function D(X){if($[X])return $[X].exports;var N=$[X]={i:X,l:!1,exports:{}};return ne[X].call(N.exports,N,N.exports,D),N.l=!0,N.exports}return D.m=ne,D.c=$,D.d=function(X,N,I){D.o(X,N)||Object.defineProperty(X,N,{enumerable:!0,get:I})},D.r=function(X){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(X,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(X,"__esModule",{value:!0})},D.t=function(X,N){if(N&1&&(X=D(X)),N&8)return X;if(N&4&&typeof X=="object"&&X&&X.__esModule)return X;var I=Object.create(null);if(D.r(I),Object.defineProperty(I,"default",{enumerable:!0,value:X}),N&2&&typeof X!="string")for(var z in X)D.d(I,z,function(U){return X[U]}.bind(null,z));return I},D.n=function(X){var N=X&&X.__esModule?function(){return X.default}:function(){return X};return D.d(N,"a",N),N},D.o=function(X,N){return Object.prototype.hasOwnProperty.call(X,N)},D.p="/dist/",D(D.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(ne,$,D){"use strict";var X=Object.prototype.hasOwnProperty,N="~";function I(){}Object.create&&(I.prototype=Object.create(null),new I().__proto__||(N=!1));function z(b,A,R){this.fn=b,this.context=A,this.once=R||!1}function U(b,A,R,L,w){if(typeof R!="function")throw new TypeError("The listener must be a function");var S=new z(R,L||b,w),h=N?N+A:A;return b._events[h]?b._events[h].fn?b._events[h]=[b._events[h],S]:b._events[h].push(S):(b._events[h]=S,b._eventsCount++),b}function P(b,A){--b._eventsCount===0?b._events=new I:delete b._events[A]}function M(){this._events=new I,this._eventsCount=0}M.prototype.eventNames=function(){var A=[],R,L;if(this._eventsCount===0)return A;for(L in R=this._events)X.call(R,L)&&A.push(N?L.slice(1):L);return Object.getOwnPropertySymbols?A.concat(Object.getOwnPropertySymbols(R)):A},M.prototype.listeners=function(A){var R=N?N+A:A,L=this._events[R];if(!L)return[];if(L.fn)return[L.fn];for(var w=0,S=L.length,h=new Array(S);w<S;w++)h[w]=L[w].fn;return h},M.prototype.listenerCount=function(A){var R=N?N+A:A,L=this._events[R];return L?L.fn?1:L.length:0},M.prototype.emit=function(A,R,L,w,S,h){var o=N?N+A:A;if(!this._events[o])return!1;var u=this._events[o],d=arguments.length,T,y;if(u.fn){u.once&&this.removeListener(A,u.fn,void 0,!0);switch(d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,R),!0;case 3:return u.fn.call(u.context,R,L),!0;case 4:return u.fn.call(u.context,R,L,w),!0;case 5:return u.fn.call(u.context,R,L,w,S),!0;case 6:return u.fn.call(u.context,R,L,w,S,h),!0}for(y=1,T=new Array(d-1);y<d;y++)T[y-1]=arguments[y];u.fn.apply(u.context,T)}else{var f=u.length,k;for(y=0;y<f;y++){u[y].once&&this.removeListener(A,u[y].fn,void 0,!0);switch(d){case 1:u[y].fn.call(u[y].context);break;case 2:u[y].fn.call(u[y].context,R);break;case 3:u[y].fn.call(u[y].context,R,L);break;case 4:u[y].fn.call(u[y].context,R,L,w);break;default:if(!T)for(k=1,T=new Array(d-1);k<d;k++)T[k-1]=arguments[k];u[y].fn.apply(u[y].context,T)}}}return!0},M.prototype.on=function(A,R,L){return U(this,A,R,L,!1)},M.prototype.once=function(A,R,L){return U(this,A,R,L,!0)},M.prototype.removeListener=function(A,R,L,w){var S=N?N+A:A;if(!this._events[S])return this;if(!R)return P(this,S),this;var h=this._events[S];if(h.fn)h.fn===R&&(!w||h.once)&&(!L||h.context===L)&&P(this,S);else{for(var o=0,u=[],d=h.length;o<d;o++)(h[o].fn!==R||w&&!h[o].once||L&&h[o].context!==L)&&u.push(h[o]);u.length?this._events[S]=u.length===1?u[0]:u:P(this,S)}return this},M.prototype.removeAllListeners=function(A){var R;return A?(R=N?N+A:A,this._events[R]&&P(this,R)):(this._events=new I,this._eventsCount=0),this},M.prototype.off=M.prototype.removeListener,M.prototype.addListener=M.prototype.on,M.prefixed=N,M.EventEmitter=M,ne.exports=M},"./node_modules/url-toolkit/src/url-toolkit.js":function(ne,$,D){(function(X){var N=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,I=/^([^\/?#]*)([^]*)$/,z=/(?:\/|^)\.(?=\/)/g,U=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,P={buildAbsoluteURL:function(M,b,A){if(A=A||{},M=M.trim(),b=b.trim(),!b){if(!A.alwaysNormalize)return M;var R=P.parseURL(M);if(!R)throw new Error("Error trying to parse base URL.");return R.path=P.normalizePath(R.path),P.buildURLFromParts(R)}var L=P.parseURL(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(M);if(!w)throw new Error("Error trying to parse base URL.");if(!w.netLoc&&w.path&&w.path[0]!=="/"){var S=I.exec(w.path);w.netLoc=S[1],w.path=S[2]}w.netLoc&&!w.path&&(w.path="/");var h={scheme:w.scheme,netLoc:L.netLoc,path:null,params:L.params,query:L.query,fragment:L.fragment};if(!L.netLoc&&(h.netLoc=w.netLoc,L.path[0]!=="/"))if(!L.path)h.path=w.path,L.params||(h.params=w.params,L.query||(h.query=w.query));else{var o=w.path,u=o.substring(0,o.lastIndexOf("/")+1)+L.path;h.path=P.normalizePath(u)}return h.path===null&&(h.path=A.alwaysNormalize?P.normalizePath(L.path):L.path),P.buildURLFromParts(h)},parseURL:function(M){var b=N.exec(M);return b?{scheme:b[1]||"",netLoc:b[2]||"",path:b[3]||"",params:b[4]||"",query:b[5]||"",fragment:b[6]||""}:null},normalizePath:function(M){for(M=M.split("").reverse().join("").replace(z,"");M.length!==(M=M.replace(U,"")).length;);return M.split("").reverse().join("")},buildURLFromParts:function(M){return M.scheme+M.netLoc+M.path+M.params+M.query+M.fragment}};ne.exports=P})(this)},"./node_modules/webworkify-webpack/index.js":function(ne,$,D){function X(A){var R={};function L(S){if(R[S])return R[S].exports;var h=R[S]={i:S,l:!1,exports:{}};return A[S].call(h.exports,h,h.exports,L),h.l=!0,h.exports}L.m=A,L.c=R,L.i=function(S){return S},L.d=function(S,h,o){L.o(S,h)||Object.defineProperty(S,h,{configurable:!1,enumerable:!0,get:o})},L.r=function(S){Object.defineProperty(S,"__esModule",{value:!0})},L.n=function(S){var h=S&&S.__esModule?function(){return S.default}:function(){return S};return L.d(h,"a",h),h},L.o=function(S,h){return Object.prototype.hasOwnProperty.call(S,h)},L.p="/",L.oe=function(S){throw console.error(S),S};var w=L(L.s=ENTRY_MODULE);return w.default||w}var N="[\\.|\\-|\\+|\\w|/|@]+",I="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+N+").*?\\)";function z(A){return(A+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function U(A){return!isNaN(1*A)}function P(A,R,L){var w={};w[L]=[];var S=R.toString(),h=S.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!h)return w;for(var o=h[1],u=new RegExp("(\\\\n|\\W)"+z(o)+I,"g"),d;d=u.exec(S);){if(d[3]==="dll-reference")continue;w[L].push(d[3])}for(u=new RegExp("\\("+z(o)+'\\("(dll-reference\\s('+N+'))"\\)\\)'+I,"g");d=u.exec(S);)A[d[2]]||(w[L].push(d[1]),A[d[2]]=D(d[1]).m),w[d[2]]=w[d[2]]||[],w[d[2]].push(d[4]);for(var T=Object.keys(w),y=0;y<T.length;y++)for(var f=0;f<w[T[y]].length;f++)U(w[T[y]][f])&&(w[T[y]][f]=1*w[T[y]][f]);return w}function M(A){var R=Object.keys(A);return R.reduce(function(L,w){return L||A[w].length>0},!1)}function b(A,R){for(var L={main:[R]},w={main:[]},S={main:{}};M(L);)for(var h=Object.keys(L),o=0;o<h.length;o++){var u=h[o],d=L[u],T=d.pop();if(S[u]=S[u]||{},S[u][T]||!A[u][T])continue;S[u][T]=!0,w[u]=w[u]||[],w[u].push(T);for(var y=P(A,A[u][T],u),f=Object.keys(y),k=0;k<f.length;k++)L[f[k]]=L[f[k]]||[],L[f[k]]=L[f[k]].concat(y[f[k]])}return w}ne.exports=function(A,R){R=R||{};var L={main:D.m},w=R.all?{main:Object.keys(L.main)}:b(L,A),S="";Object.keys(w).filter(function(T){return T!=="main"}).forEach(function(T){for(var y=0;w[T][y];)y++;w[T].push(y),L[T][y]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",S=S+"var "+T+" = ("+X.toString().replace("ENTRY_MODULE",JSON.stringify(y))+")({"+w[T].map(function(f){return""+JSON.stringify(f)+": "+L[T][f].toString()}).join(",")+`});
|
|
`}),S=S+"new (("+X.toString().replace("ENTRY_MODULE",JSON.stringify(A))+")({"+w.main.map(function(T){return""+JSON.stringify(T)+": "+L.main[T].toString()}).join(",")+"}))(self);";var h=new window.Blob([S],{type:"text/javascript"});if(R.bare)return h;var o=window.URL||window.webkitURL||window.mozURL||window.msURL,u=o.createObjectURL(h),d=new window.Worker(u);return d.objectURL=u,d}},"./src/config.ts":function(ne,$,D){"use strict";D.r($),D.d($,"hlsDefaultConfig",function(){return k}),D.d($,"mergeConfig",function(){return p}),D.d($,"enableStreamingMode",function(){return c});var X=D("./src/controller/abr-controller.ts"),N=D("./src/controller/audio-stream-controller.ts"),I=D("./src/controller/audio-track-controller.ts"),z=D("./src/controller/subtitle-stream-controller.ts"),U=D("./src/controller/subtitle-track-controller.ts"),P=D("./src/controller/buffer-controller.ts"),M=D("./src/controller/timeline-controller.ts"),b=D("./src/controller/cap-level-controller.ts"),A=D("./src/controller/fps-controller.ts"),R=D("./src/controller/eme-controller.ts"),L=D("./src/controller/cmcd-controller.ts"),w=D("./src/utils/xhr-loader.ts"),S=D("./src/utils/fetch-loader.ts"),h=D("./src/utils/cues.ts"),o=D("./src/utils/mediakeys-helper.ts"),u=D("./src/utils/logger.ts");function d(){return d=Object.assign||function(s){for(var a=1;a<arguments.length;a++){var v=arguments[a];for(var g in v)Object.prototype.hasOwnProperty.call(v,g)&&(s[g]=v[g])}return s},d.apply(this,arguments)}function T(s,a){var v=Object.keys(s);if(Object.getOwnPropertySymbols){var g=Object.getOwnPropertySymbols(s);a&&(g=g.filter(function(E){return Object.getOwnPropertyDescriptor(s,E).enumerable})),v.push.apply(v,g)}return v}function y(s){for(var a=1;a<arguments.length;a++){var v=arguments[a]!=null?arguments[a]:{};a%2?T(Object(v),!0).forEach(function(g){f(s,g,v[g])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(v)):T(Object(v)).forEach(function(g){Object.defineProperty(s,g,Object.getOwnPropertyDescriptor(v,g))})}return s}function f(s,a,v){return a in s?Object.defineProperty(s,a,{value:v,enumerable:!0,configurable:!0,writable:!0}):s[a]=v,s}var k=y(y({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:X.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:o.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},x()),{},{subtitleStreamController:z.SubtitleStreamController,subtitleTrackController:U.default,timelineController:M.TimelineController,audioStreamController:N.default,audioTrackController:I.default,emeController:R.default,cmcdController:L.default});function x(){return{cueHandler:h.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 p(s,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return d({},s,a)}function c(s){var a=s.loader;if(a!==S.default&&a!==w.default)u.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1;else{var v=Object(S.fetchSupported)();v&&(s.loader=S.default,s.progressive=!0,s.enableSoftwareAES=!0,u.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/polyfills/number.ts"),N=D("./src/utils/ewma-bandwidth-estimator.ts"),I=D("./src/events.ts"),z=D("./src/utils/buffer-helper.ts"),U=D("./src/errors.ts"),P=D("./src/types/loader.ts"),M=D("./src/utils/logger.ts");function b(L,w){for(var S=0;S<w.length;S++){var h=w[S];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(L,h.key,h)}}function A(L,w,S){return w&&b(L.prototype,w),S&&b(L,S),L}var R=function(){function L(S){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=S;var h=S.config;this.bwEstimator=new N.default(h.abrEwmaSlowVoD,h.abrEwmaFastVoD,h.abrEwmaDefaultEstimate),this.registerListeners()}var w=L.prototype;return w.registerListeners=function(){var h=this.hls;h.on(I.Events.FRAG_LOADING,this.onFragLoading,this),h.on(I.Events.FRAG_LOADED,this.onFragLoaded,this),h.on(I.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(I.Events.ERROR,this.onError,this)},w.unregisterListeners=function(){var h=this.hls;h.off(I.Events.FRAG_LOADING,this.onFragLoading,this),h.off(I.Events.FRAG_LOADED,this.onFragLoaded,this),h.off(I.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(I.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(h,o){var u=o.frag;if(u.type===P.PlaylistLevelType.MAIN&&!this.timer){var d;this.fragCurrent=u,this.partCurrent=(d=o.part)!=null?d:null,this.timer=self.setInterval(this.onCheck,100)}},w.onLevelLoaded=function(h,o){var u=this.hls.config;o.details.live?this.bwEstimator.update(u.abrEwmaSlowLive,u.abrEwmaFastLive):this.bwEstimator.update(u.abrEwmaSlowVoD,u.abrEwmaFastVoD)},w._abandonRulesCheck=function(){var h=this.fragCurrent,o=this.partCurrent,u=this.hls,d=u.autoLevelEnabled,T=u.config,y=u.media;if(!h||!y)return;var f=o?o.stats:h.stats,k=o?o.duration:h.duration;if(f.aborted){M.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!d||y.paused||!y.playbackRate||!y.readyState)return;var x=performance.now()-f.loading.start,p=Math.abs(y.playbackRate);if(x<=500*k/p)return;var c=u.levels,s=u.minAutoLevel,a=c[h.level],v=f.total||Math.max(f.loaded,Math.round(k*a.maxBitrate/8)),g=Math.max(1,f.bwEstimate?f.bwEstimate/8:f.loaded*1e3/x),E=(v-f.loaded)/g,_=y.currentTime,H=(z.BufferHelper.bufferInfo(y,_,T.maxBufferHole).end-_)/p;if(H>=2*k/p||E<=H)return;var V=Number.POSITIVE_INFINITY,Z;for(Z=h.level-1;Z>s;Z--){var G=c[Z].maxBitrate;if(V=k*G/(8*.8*g),V<H)break}if(V>=E)return;var j=this.bwEstimator.getEstimate();M.logger.warn("Fragment "+h.sn+(o?" part "+o.index:"")+" of level "+h.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+Z+`
|
|
Current BW estimate: `+(Object(X.isFiniteNumber)(j)?(j/1024).toFixed(3):"Unknown")+` Kb/s
|
|
Estimated load time for current fragment: `+E.toFixed(3)+` s
|
|
Estimated load time for the next fragment: `+V.toFixed(3)+` s
|
|
Time to underbuffer: `+H.toFixed(3)+" s"),u.nextLoadLevel=Z,this.bwEstimator.sample(x,f.loaded),this.clearTimer(),h.loader&&(this.fragCurrent=this.partCurrent=null,h.loader.abort()),u.trigger(I.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:h,part:o,stats:f})},w.onFragLoaded=function(h,o){var u=o.frag,d=o.part;if(u.type===P.PlaylistLevelType.MAIN&&Object(X.isFiniteNumber)(u.sn)){var T=d?d.stats:u.stats,y=d?d.duration:u.duration;if(this.clearTimer(),this.lastLoadedFragLevel=u.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var f=this.hls.levels[u.level],k=(f.loaded?f.loaded.bytes:0)+T.loaded,x=(f.loaded?f.loaded.duration:0)+y;f.loaded={bytes:k,duration:x},f.realBitrate=Math.round(8*k/x)}if(u.bitrateTest){var p={stats:T,frag:u,part:d,id:u.type};this.onFragBuffered(I.Events.FRAG_BUFFERED,p),u.bitrateTest=!1}}},w.onFragBuffered=function(h,o){var u=o.frag,d=o.part,T=d?d.stats:u.stats;if(T.aborted)return;if(u.type!==P.PlaylistLevelType.MAIN||u.sn==="initSegment")return;var y=T.parsing.end-T.loading.start;this.bwEstimator.sample(y,T.loaded),T.bwEstimate=this.bwEstimator.getEstimate(),u.bitrateTest?this.bitrateTestDelay=y/1e3:this.bitrateTestDelay=0},w.onError=function(h,o){switch(o.details){case U.ErrorDetails.FRAG_LOAD_ERROR:case U.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},w.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},w.getNextABRAutoLevel=function(){var h=this.fragCurrent,o=this.partCurrent,u=this.hls,d=u.maxAutoLevel,T=u.config,y=u.minAutoLevel,f=u.media,k=o?o.duration:h?h.duration:0,x=f?f.currentTime:0,p=f&&f.playbackRate!==0?Math.abs(f.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():T.abrEwmaDefaultEstimate,s=(z.BufferHelper.bufferInfo(f,x,T.maxBufferHole).end-x)/p,a=this.findBestLevel(c,y,d,s,T.abrBandWidthFactor,T.abrBandWidthUpFactor);if(a>=0)return a;M.logger.trace((s?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var v=k?Math.min(k,T.maxStarvationDelay):T.maxStarvationDelay,g=T.abrBandWidthFactor,E=T.abrBandWidthUpFactor;if(!s){var _=this.bitrateTestDelay;if(_){var H=k?Math.min(k,T.maxLoadingDelay):T.maxLoadingDelay;v=H-_,M.logger.trace("bitrate test took "+Math.round(1e3*_)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*v)+" ms"),g=E=1}}return a=this.findBestLevel(c,y,d,s+v,g,E),Math.max(a,0)},w.findBestLevel=function(h,o,u,d,T,y){for(var f,k=this.fragCurrent,x=this.partCurrent,p=this.lastLoadedFragLevel,c=this.hls.levels,s=c[p],a=!!(s!=null&&(f=s.details)!==null&&f!==void 0&&f.live),v=s==null?void 0:s.codecSet,g=x?x.duration:k?k.duration:0,E=u;E>=o;E--){var _=c[E];if(!_||v&&_.codecSet!==v)continue;var H=_.details,V=(x?H==null?void 0:H.partTarget:H==null?void 0:H.averagetargetduration)||g,Z=void 0;E<=p?Z=T*h:Z=y*h;var G=c[E].maxBitrate,j=G*V/Z;if(M.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+E+"/"+Math.round(Z)+"/"+G+"/"+V+"/"+d+"/"+j),Z>G&&(!j||a&&!this.bitrateTestDelay||j<d))return E}return-1},A(L,[{key:"nextAutoLevel",get:function(){var h=this._nextAutoLevel,o=this.bwEstimator;if(h!==-1&&(!o||!o.canEstimate()))return h;var u=this.getNextABRAutoLevel();return h!==-1&&(u=Math.min(h,u)),u},set:function(h){this._nextAutoLevel=h}}]),L}();$.default=R},"./src/controller/audio-stream-controller.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/polyfills/number.ts"),N=D("./src/controller/base-stream-controller.ts"),I=D("./src/events.ts"),z=D("./src/utils/buffer-helper.ts"),U=D("./src/controller/fragment-tracker.ts"),P=D("./src/types/level.ts"),M=D("./src/types/loader.ts"),b=D("./src/loader/fragment.ts"),A=D("./src/demux/chunk-cache.ts"),R=D("./src/demux/transmuxer-interface.ts"),L=D("./src/types/transmuxer.ts"),w=D("./src/controller/fragment-finders.ts"),S=D("./src/utils/discontinuities.ts"),h=D("./src/errors.ts"),o=D("./src/utils/logger.ts");function u(){return u=Object.assign||function(k){for(var x=1;x<arguments.length;x++){var p=arguments[x];for(var c in p)Object.prototype.hasOwnProperty.call(p,c)&&(k[c]=p[c])}return k},u.apply(this,arguments)}function d(k,x){k.prototype=Object.create(x.prototype),k.prototype.constructor=k,T(k,x)}function T(k,x){return T=Object.setPrototypeOf||function(c,s){return c.__proto__=s,c},T(k,x)}var y=100,f=function(k){d(x,k);function x(c,s){var a;return a=k.call(this,c,s,"[audio-stream-controller]")||this,a.videoBuffer=null,a.videoTrackCC=-1,a.waitingVideoCC=-1,a.audioSwitch=!1,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.bufferFlushed=!1,a._registerListeners(),a}var p=x.prototype;return p.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},p._registerListeners=function(){var s=this.hls;s.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),s.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),s.on(I.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),s.on(I.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),s.on(I.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),s.on(I.Events.ERROR,this.onError,this),s.on(I.Events.BUFFER_RESET,this.onBufferReset,this),s.on(I.Events.BUFFER_CREATED,this.onBufferCreated,this),s.on(I.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),s.on(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),s.on(I.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p._unregisterListeners=function(){var s=this.hls;s.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),s.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),s.off(I.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),s.off(I.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),s.off(I.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),s.off(I.Events.ERROR,this.onError,this),s.off(I.Events.BUFFER_RESET,this.onBufferReset,this),s.off(I.Events.BUFFER_CREATED,this.onBufferCreated,this),s.off(I.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),s.off(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),s.off(I.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p.onInitPtsFound=function(s,a){var v=a.frag,g=a.id,E=a.initPTS;if(g==="main"){var _=v.cc;this.initPTS[v.cc]=E,this.log("InitPTS for cc: "+_+" found from main: "+E),this.videoTrackCC=_,this.state===N.State.WAITING_INIT_PTS&&this.tick()}},p.startLoad=function(s){if(!this.levels){this.startPosition=s,this.state=N.State.STOPPED;return}var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(y),this.fragLoadError=0,a>0&&s===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),this.state=N.State.IDLE):(this.loadedmetadata=!1,this.state=N.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=s,this.tick()},p.doTick=function(){switch(this.state){case N.State.IDLE:this.doTickIdle();break;case N.State.WAITING_TRACK:{var s,a=this.levels,v=this.trackId,g=a==null||((s=a[v])===null||s===void 0)?void 0:s.details;if(g){if(this.waitForCdnTuneIn(g))break;this.state=N.State.WAITING_INIT_PTS}break}case N.State.FRAG_LOADING_WAITING_RETRY:{var E,_=performance.now(),H=this.retryDate;(!H||_>=H||(E=this.media)!==null&&E!==void 0&&E.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=N.State.IDLE);break}case N.State.WAITING_INIT_PTS:{var V=this.waitingData;if(V){var Z=V.frag,G=V.part,j=V.cache,q=V.complete;if(this.initPTS[Z.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=N.State.FRAG_LOADING;var ie=j.flush(),ce={frag:Z,part:G,payload:ie,networkDetails:null};this._handleFragmentLoadProgress(ce),q&&k.prototype._handleFragmentLoadComplete.call(this,ce)}else if(this.videoTrackCC!==this.waitingVideoCC)o.logger.log("Waiting fragment cc ("+Z.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var ve=this.getLoadPosition(),ke=z.BufferHelper.bufferInfo(this.mediaBuffer,ve,this.config.maxBufferHole),xe=Object(w.fragmentWithinToleranceTest)(ke.end,this.config.maxFragLookUpTolerance,Z);xe<0&&(o.logger.log("Waiting fragment cc ("+Z.cc+") @ "+Z.start+" cancelled because another fragment at "+ke.end+" is needed"),this.clearWaitingFragment())}}else this.state=N.State.IDLE}}this.onTickEnd()},p.clearWaitingFragment=function(){var s=this.waitingData;s&&(this.fragmentTracker.removeFragment(s.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=N.State.IDLE)},p.onTickEnd=function(){var s=this.media;if(!s||!s.readyState)return;var a=this.mediaBuffer?this.mediaBuffer:s,v=a.buffered;!this.loadedmetadata&&v.length&&(this.loadedmetadata=!0),this.lastCurrentTime=s.currentTime},p.doTickIdle=function(){var s,a,v=this.hls,g=this.levels,E=this.media,_=this.trackId,H=v.config;if(!g||!g[_])return;if(!E&&(this.startFragRequested||!H.startFragPrefetch))return;var V=g[_],Z=V.details;if(!Z||Z.live&&this.levelLastLoaded!==_||this.waitForCdnTuneIn(Z)){this.state=N.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,b.ElementaryStreamTypes.AUDIO,M.PlaylistLevelType.AUDIO));var G=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,M.PlaylistLevelType.AUDIO);if(G===null)return;var j=G.len,q=this.getMaxBufferLength(),ie=this.audioSwitch;if(j>=q&&!ie)return;if(!ie&&this._streamEnded(G,Z)){v.trigger(I.Events.BUFFER_EOS,{type:"audio"}),this.state=N.State.ENDED;return}var ce=Z.fragments,ve=ce[0].start,ke=G.end;if(ie){var xe=this.getLoadPosition();ke=xe,Z.PTSKnown&&xe<ve&&((G.end>ve||G.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),E.currentTime=ve+.05))}var Ce=this.getNextFragment(ke,Z);if(!Ce){this.bufferFlushed=!0;return}((s=Ce.decryptdata)===null||s===void 0?void 0:s.keyFormat)==="identity"&&!((a=Ce.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(Ce,Z):this.loadFragment(Ce,Z,ke)},p.getMaxBufferLength=function(){var s=k.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,M.PlaylistLevelType.MAIN);return a===null?s:Math.max(s,a.len)},p.onMediaDetaching=function(){this.videoBuffer=null,k.prototype.onMediaDetaching.call(this)},p.onAudioTracksUpdated=function(s,a){var v=a.audioTracks;this.resetTransmuxer(),this.levels=v.map(function(g){return new P.Level(g)})},p.onAudioTrackSwitching=function(s,a){var v=!!a.url;this.trackId=a.id;var g=this.fragCurrent;g!=null&&g.loader&&g.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),v?this.setInterval(y):this.resetTransmuxer(),v?(this.audioSwitch=!0,this.state=N.State.IDLE):this.state=N.State.STOPPED,this.tick()},p.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},p.onLevelLoaded=function(s,a){this.mainDetails=a.details},p.onAudioTrackLoaded=function(s,a){var v,g=this.levels,E=a.details,_=a.id;if(!g){this.warn("Audio tracks were reset while loading level "+_);return}this.log("Track "+_+" loaded ["+E.startSN+","+E.endSN+"],duration:"+E.totalduration);var H=g[_],V=0;if(E.live||(v=H.details)!==null&&v!==void 0&&v.live){var Z=this.mainDetails;if(E.fragments[0]||(E.deltaUpdateFailed=!0),E.deltaUpdateFailed||!Z)return;!H.details&&E.hasProgramDateTime&&Z.hasProgramDateTime?(Object(S.alignMediaPlaylistByPDT)(E,Z),V=E.fragments[0].start):V=this.alignPlaylists(E,H.details)}H.details=E,this.levelLastLoaded=_,!this.startFragRequested&&(this.mainDetails||!E.live)&&this.setStartPosition(H.details,V),this.state===N.State.WAITING_TRACK&&!this.waitForCdnTuneIn(E)&&(this.state=N.State.IDLE),this.tick()},p._handleFragmentLoadProgress=function(s){var a,v=s.frag,g=s.part,E=s.payload,_=this.config,H=this.trackId,V=this.levels;if(!V){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+v.sn+" of level "+v.level+" will not be buffered");return}var Z=V[H];console.assert(Z,"Audio track is defined on fragment load progress");var G=Z.details;console.assert(G,"Audio track details are defined on fragment load progress");var j=_.defaultAudioCodec||Z.audioCodec||"mp4a.40.2",q=this.transmuxer;q||(q=this.transmuxer=new R.default(this.hls,M.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var ie=this.initPTS[v.cc],ce=(a=v.initSegment)===null||a===void 0?void 0:a.data;if(ie!==void 0){var ve=!1,ke=g?g.index:-1,xe=ke!==-1,Ce=new L.ChunkMetadata(v.level,v.sn,v.stats.chunkCount,E.byteLength,ke,xe);q.push(E,ce,j,"",v,g,G.totalduration,ve,Ce,ie)}else{o.logger.log("Unknown video PTS for cc "+v.cc+", waiting for video PTS before demuxing audio frag "+v.sn+" of ["+G.startSN+" ,"+G.endSN+"],track "+H);var Te=this.waitingData=this.waitingData||{frag:v,part:g,cache:new A.default,complete:!1},Ee=Te.cache;Ee.push(new Uint8Array(E)),this.waitingVideoCC=this.videoTrackCC,this.state=N.State.WAITING_INIT_PTS}},p._handleFragmentLoadComplete=function(s){if(this.waitingData){this.waitingData.complete=!0;return}k.prototype._handleFragmentLoadComplete.call(this,s)},p.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},p.onBufferCreated=function(s,a){var v=a.tracks.audio;v&&(this.mediaBuffer=v.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},p.onFragBuffered=function(s,a){var v=a.frag,g=a.part;if(v.type!==M.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(v)){this.warn("Fragment "+v.sn+(g?" p: "+g.index:"")+" of level "+v.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}v.sn!=="initSegment"&&(this.fragPrevious=v,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(I.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(v,g)},p.onError=function(s,a){switch(a.details){case h.ErrorDetails.FRAG_LOAD_ERROR:case h.ErrorDetails.FRAG_LOAD_TIMEOUT:case h.ErrorDetails.KEY_LOAD_ERROR:case h.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(M.PlaylistLevelType.AUDIO,a);break;case h.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case h.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==N.State.ERROR&&this.state!==N.State.STOPPED&&(this.state=a.fatal?N.State.ERROR:N.State.IDLE,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case h.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===N.State.PARSING||this.state===N.State.PARSED)){var v=!0,g=this.getFwdBufferInfo(this.mediaBuffer,M.PlaylistLevelType.AUDIO);g&&g.len>.5&&(v=!this.reduceMaxBufferLength(g.len)),v&&(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}},p.onBufferFlushed=function(s,a){var v=a.type;v===b.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},p._handleTransmuxComplete=function(s){var a,v="audio",g=this.hls,E=s.remuxResult,_=s.chunkMeta,H=this.getCurrentContext(_);if(!H){this.warn("The loading context changed while buffering fragment "+_.sn+" of level "+_.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(_.level);return}var V=H.frag,Z=H.part,G=E.audio,j=E.text,q=E.id3,ie=E.initSegment;if(this.fragContextChanged(V))return;if(this.state=N.State.PARSING,this.audioSwitch&&G&&this.completeAudioSwitch(),ie!=null&&ie.tracks&&(this._bufferInitSegment(ie.tracks,V,_),g.trigger(I.Events.FRAG_PARSING_INIT_SEGMENT,{frag:V,id:v,tracks:ie.tracks})),G){var ce=G.startPTS,ve=G.endPTS,ke=G.startDTS,xe=G.endDTS;Z&&(Z.elementaryStreams[b.ElementaryStreamTypes.AUDIO]={startPTS:ce,endPTS:ve,startDTS:ke,endDTS:xe}),V.setElementaryStreamInfo(b.ElementaryStreamTypes.AUDIO,ce,ve,ke,xe),this.bufferFragmentData(G,V,Z,_)}if(q!=null&&(a=q.samples)!==null&&a!==void 0&&a.length){var Ce=u({frag:V,id:v},q);g.trigger(I.Events.FRAG_PARSING_METADATA,Ce)}if(j){var Te=u({frag:V,id:v},j);g.trigger(I.Events.FRAG_PARSING_USERDATA,Te)}},p._bufferInitSegment=function(s,a,v){if(this.state!==N.State.PARSING)return;s.video&&delete s.video;var g=s.audio;if(!g)return;g.levelCodec=g.codec,g.id="audio",this.log("Init audio buffer, container:"+g.container+", codecs[parsed]=["+g.codec+"]"),this.hls.trigger(I.Events.BUFFER_CODECS,s);var E=g.initSegment;if(E!=null&&E.byteLength){var _={type:"audio",frag:a,part:null,chunkMeta:v,parent:a.type,data:E};this.hls.trigger(I.Events.BUFFER_APPENDING,_)}this.tick()},p.loadFragment=function(s,a,v){var g=this.fragmentTracker.getState(s);this.fragCurrent=s,(this.audioSwitch||g===U.FragmentState.NOT_LOADED||g===U.FragmentState.PARTIAL)&&(s.sn==="initSegment"?this._loadInitSegment(s):a.live&&!Object(X.isFiniteNumber)(this.initPTS[s.cc])?(this.log("Waiting for video PTS in continuity counter "+s.cc+" of live stream before loading audio fragment "+s.sn+" of level "+this.trackId),this.state=N.State.WAITING_INIT_PTS):(this.startFragRequested=!0,k.prototype.loadFragment.call(this,s,a,v)))},p.completeAudioSwitch=function(){var s=this.hls,a=this.media,v=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),k.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,s.trigger(I.Events.AUDIO_TRACK_SWITCHED,{id:v})},x}(N.default);$.default=f},"./src/controller/audio-track-controller.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/events.ts"),N=D("./src/errors.ts"),I=D("./src/controller/base-playlist-controller.ts"),z=D("./src/types/loader.ts");function U(R,L){for(var w=0;w<L.length;w++){var S=L[w];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(R,S.key,S)}}function P(R,L,w){return L&&U(R.prototype,L),w&&U(R,w),R}function M(R,L){R.prototype=Object.create(L.prototype),R.prototype.constructor=R,b(R,L)}function b(R,L){return b=Object.setPrototypeOf||function(S,h){return S.__proto__=h,S},b(R,L)}var A=function(R){M(L,R);function L(S){var h;return h=R.call(this,S,"[audio-track-controller]")||this,h.tracks=[],h.groupId=null,h.tracksInGroup=[],h.trackId=-1,h.trackName="",h.selectDefaultTrack=!0,h.registerListeners(),h}var w=L.prototype;return w.registerListeners=function(){var h=this.hls;h.on(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),h.on(X.Events.LEVEL_LOADING,this.onLevelLoading,this),h.on(X.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),h.on(X.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.on(X.Events.ERROR,this.onError,this)},w.unregisterListeners=function(){var h=this.hls;h.off(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),h.off(X.Events.LEVEL_LOADING,this.onLevelLoading,this),h.off(X.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),h.off(X.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.off(X.Events.ERROR,this.onError,this)},w.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,R.prototype.destroy.call(this)},w.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},w.onManifestParsed=function(h,o){this.tracks=o.audioTracks||[]},w.onAudioTrackLoaded=function(h,o){var u=o.id,d=o.details,T=this.tracksInGroup[u];if(!T){this.warn("Invalid audio track id "+u);return}var y=T.details;T.details=o.details,this.log("audioTrack "+u+" loaded ["+d.startSN+"-"+d.endSN+"]"),u===this.trackId&&(this.retryCount=0,this.playlistLoaded(u,o,y))},w.onLevelLoading=function(h,o){this.switchLevel(o.level)},w.onLevelSwitching=function(h,o){this.switchLevel(o.level)},w.switchLevel=function(h){var o=this.hls.levels[h];if(!(o!=null&&o.audioGroupIds))return;var u=o.audioGroupIds[o.urlId];if(this.groupId!==u){this.groupId=u;var d=this.tracks.filter(function(y){return!u||y.groupId===u});this.selectDefaultTrack&&!d.some(function(y){return y.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=d;var T={audioTracks:d};this.log("Updating audio tracks, "+d.length+' track(s) found in "'+u+'" group-id'),this.hls.trigger(X.Events.AUDIO_TRACKS_UPDATED,T),this.selectInitialTrack()}},w.onError=function(h,o){if(R.prototype.onError.call(this,h,o),o.fatal||!o.context)return;o.context.type===z.PlaylistContextType.AUDIO_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},w.setAudioTrack=function(h){var o=this.tracksInGroup;if(h<0||h>=o.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var u=o[this.trackId];this.log("Now switching to audio-track index "+h);var d=o[h],T=d.id,y=d.groupId,f=y===void 0?"":y,k=d.name,x=d.type,p=d.url;if(this.trackId=h,this.trackName=k,this.selectDefaultTrack=!1,this.hls.trigger(X.Events.AUDIO_TRACK_SWITCHING,{id:T,groupId:f,name:k,type:x,url:p}),d.details&&!d.details.live)return;var c=this.switchParams(d.url,u==null?void 0:u.details);this.loadPlaylist(c)},w.selectInitialTrack=function(){var h=this.tracksInGroup;console.assert(h.length,"Initial audio track should be selected when tracks are known");var o=this.trackName,u=this.findTrackId(o)||this.findTrackId();u!==-1?this.setAudioTrack(u):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},w.findTrackId=function(h){for(var o=this.tracksInGroup,u=0;u<o.length;u++){var d=o[u];if((!this.selectDefaultTrack||d.default)&&(!h||h===d.name))return d.id}return-1},w.loadPlaylist=function(h){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var u=o.id,d=o.groupId,T=o.url;if(h)try{T=h.addDirectives(T)}catch(y){this.warn("Could not construct new URL with HLS Delivery Directives: "+y)}this.log("loading audio-track playlist for id: "+u),this.clearTimer(),this.hls.trigger(X.Events.AUDIO_TRACK_LOADING,{url:T,id:u,groupId:d,deliveryDirectives:h||null})}},P(L,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(h){this.selectDefaultTrack=!1,this.setAudioTrack(h)}}]),L}(I.default);$.default=A},"./src/controller/base-playlist-controller.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return P});var X=D("./src/polyfills/number.ts"),N=D("./src/types/level.ts"),I=D("./src/controller/level-helper.ts"),z=D("./src/utils/logger.ts"),U=D("./src/errors.ts"),P=function(){function M(A,R){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=z.logger.log.bind(z.logger,R+":"),this.warn=z.logger.warn.bind(z.logger,R+":"),this.hls=A}var b=M.prototype;return b.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},b.onError=function(R,L){L.fatal&&L.type===U.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(R,L){var w=L==null?void 0:L.renditionReports;if(w)for(var S=0;S<w.length;S++){var h=w[S],o=""+h.URI;if(o===R.substr(-o.length)){var u=parseInt(h["LAST-MSN"]),d=parseInt(h["LAST-PART"]);if(L&&this.hls.config.lowLatencyMode){var T=Math.min(L.age-L.partTarget,L.targetduration);d!==void 0&&T>L.partTarget&&(d+=1)}if(Object(X.isFiniteNumber)(u))return new N.HlsUrlParameters(u,Object(X.isFiniteNumber)(d)?d:void 0,N.HlsSkip.No)}}},b.loadPlaylist=function(R){},b.shouldLoadTrack=function(R){return this.canLoad&&R&&!!R.url&&(!R.details||R.details.live)},b.playlistLoaded=function(R,L,w){var S=this,h=L.details,o=L.stats,u=o.loading.end?Math.max(0,self.performance.now()-o.loading.end):0;if(h.advancedDateTime=Date.now()-u,h.live||w!=null&&w.live){if(h.reloaded(w),w&&this.log("live playlist "+R+" "+(h.advanced?"REFRESHED "+h.lastPartSn+"-"+h.lastPartIndex:"MISSED")),w&&h.fragments.length>0&&Object(I.mergeDetails)(w,h),!this.canLoad||!h.live)return;var d,T=void 0,y=void 0;if(h.canBlockReload&&h.endSN&&h.advanced){var f=this.hls.config.lowLatencyMode,k=h.lastPartSn,x=h.endSN,p=h.lastPartIndex,c=p!==-1,s=k===x,a=f?0:p;c?(T=s?x+1:k,y=s?a:p+1):T=x+1;var v=h.age,g=v+h.ageHeader,E=Math.min(g-h.partTarget,h.targetduration*1.5);if(E>0){if(w&&E>w.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+w.tuneInGoal+" to: "+E+" with playlist age: "+h.age),E=0;else{var _=Math.floor(E/h.targetduration);if(T+=_,y!==void 0){var H=Math.round(E%h.targetduration/h.partTarget);y+=H}this.log("CDN Tune-in age: "+h.ageHeader+"s last advanced "+v.toFixed(2)+"s goal: "+E+" skip sn "+_+" to part "+y)}h.tuneInGoal=E}if(d=this.getDeliveryDirectives(h,L.deliveryDirectives,T,y),f||!s){this.loadPlaylist(d);return}}else d=this.getDeliveryDirectives(h,L.deliveryDirectives,T,y);var V=Object(I.computeReloadInterval)(h,o);T!==void 0&&h.canBlockReload&&(V-=h.partTarget||1),this.log("reload live playlist "+R+" in "+Math.round(V)+" ms"),this.timer=self.setTimeout(function(){return S.loadPlaylist(d)},V)}else this.clearTimer()},b.getDeliveryDirectives=function(R,L,w,S){var h=Object(N.getSkipValue)(R,w);return L!=null&&L.skip&&R.deltaUpdateFailed&&(w=L.msn,S=L.part,h=N.HlsSkip.No),new N.HlsUrlParameters(w,S,h)},b.retryLoadingOrFail=function(R){var L=this,w=this.hls.config,S=this.retryCount<w.levelLoadingMaxRetry;if(S){var h;if(this.retryCount++,R.details.indexOf("LoadTimeOut")>-1&&(h=R.context)!==null&&h!==void 0&&h.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+R.details+'"'),this.loadPlaylist();else{var o=Math.min(Math.pow(2,this.retryCount)*w.levelLoadingRetryDelay,w.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return L.loadPlaylist()},o),this.warn("retry playlist loading #"+this.retryCount+" in "+o+' ms after "'+R.details+'"')}}else this.warn('cannot recover from error "'+R.details+'"'),this.clearTimer(),R.fatal=!0;return S},M}()},"./src/controller/base-stream-controller.ts":function(ne,$,D){"use strict";D.r($),D.d($,"State",function(){return x}),D.d($,"default",function(){return p});var X=D("./src/polyfills/number.ts"),N=D("./src/task-loop.ts"),I=D("./src/controller/fragment-tracker.ts"),z=D("./src/utils/buffer-helper.ts"),U=D("./src/utils/logger.ts"),P=D("./src/events.ts"),M=D("./src/errors.ts"),b=D("./src/types/transmuxer.ts"),A=D("./src/utils/mp4-tools.ts"),R=D("./src/utils/discontinuities.ts"),L=D("./src/controller/fragment-finders.ts"),w=D("./src/controller/level-helper.ts"),S=D("./src/loader/fragment-loader.ts"),h=D("./src/crypt/decrypter.ts"),o=D("./src/utils/time-ranges.ts"),u=D("./src/types/loader.ts");function d(c,s){for(var a=0;a<s.length;a++){var v=s[a];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(c,v.key,v)}}function T(c,s,a){return s&&d(c.prototype,s),a&&d(c,a),c}function y(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function f(c,s){c.prototype=Object.create(s.prototype),c.prototype.constructor=c,k(c,s)}function k(c,s){return k=Object.setPrototypeOf||function(v,g){return v.__proto__=g,v},k(c,s)}var x={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},p=function(c){f(s,c);function s(v,g,E){var _;return _=c.call(this)||this,_.hls=void 0,_.fragPrevious=null,_.fragCurrent=null,_.fragmentTracker=void 0,_.transmuxer=null,_._state=x.STOPPED,_.media=void 0,_.mediaBuffer=void 0,_.config=void 0,_.bitrateTest=!1,_.lastCurrentTime=0,_.nextLoadPosition=0,_.startPosition=0,_.loadedmetadata=!1,_.fragLoadError=0,_.retryDate=0,_.levels=null,_.fragmentLoader=void 0,_.levelLastLoaded=null,_.startFragRequested=!1,_.decrypter=void 0,_.initPTS=[],_.onvseeking=null,_.onvended=null,_.logPrefix="",_.log=void 0,_.warn=void 0,_.logPrefix=E,_.log=U.logger.log.bind(U.logger,E+":"),_.warn=U.logger.warn.bind(U.logger,E+":"),_.hls=v,_.fragmentLoader=new S.default(v.config),_.fragmentTracker=g,_.config=v.config,_.decrypter=new h.default(v,v.config),v.on(P.Events.KEY_LOADED,_.onKeyLoaded,y(_)),_}var a=s.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(g){},a.stopLoad=function(){this.fragmentLoader.abort();var g=this.fragCurrent;g&&this.fragmentTracker.removeFragment(g),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=x.STOPPED},a._streamEnded=function(g,E){var _=this.fragCurrent,H=this.fragmentTracker;if(!E.live&&_&&_.sn===E.endSN&&!g.nextStart){var V=H.getState(_);return V===I.FragmentState.PARTIAL||V===I.FragmentState.OK}return!1},a.onMediaAttached=function(g,E){var _=this.media=this.mediaBuffer=E.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),_.addEventListener("seeking",this.onvseeking),_.addEventListener("ended",this.onvended);var H=this.config;this.levels&&H.autoStartLoad&&this.state===x.STOPPED&&this.startLoad(H.startPosition)},a.onMediaDetaching=function(){var g=this.media;g!=null&&g.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),g&&(g.removeEventListener("seeking",this.onvseeking),g.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var g=this.config,E=this.fragCurrent,_=this.media,H=this.mediaBuffer,V=this.state,Z=_?_.currentTime:0,G=z.BufferHelper.bufferInfo(H||_,Z,g.maxBufferHole);if(this.log("media seeking to "+(Object(X.isFiniteNumber)(Z)?Z.toFixed(3):Z)+", state: "+V),V===x.ENDED)this.resetLoadingState();else if(E&&!G.len){var j=g.maxFragLookUpTolerance,q=E.start-j,ie=E.start+E.duration+j,ce=Z>ie;(Z<q||ce)&&(ce&&E.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),E.loader.abort()),this.resetLoadingState())}_&&(this.lastCurrentTime=Z),!this.loadedmetadata&&!G.len&&(this.nextLoadPosition=this.startPosition=Z),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(g,E){if(this.state!==x.KEY_LOADING||E.frag!==this.fragCurrent||!this.levels)return;this.state=x.IDLE;var _=this.levels[E.frag.level].details;_&&this.loadFragment(E.frag,_,E.frag.start)},a.onHandlerDestroying=function(){this.stopLoad(),c.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=x.STOPPED,this.hls.off(P.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,c.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(g,E){this.log("Loading key for "+g.sn+" of ["+E.startSN+"-"+E.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+g.level),this.state=x.KEY_LOADING,this.fragCurrent=g,this.hls.trigger(P.Events.KEY_LOADING,{frag:g})},a.loadFragment=function(g,E,_){this._loadFragForPlayback(g,E,_)},a._loadFragForPlayback=function(g,E,_){var H=this,V=function(G){if(H.fragContextChanged(g)){H.warn("Fragment "+g.sn+(G.part?" p: "+G.part.index:"")+" of level "+g.level+" was dropped during download."),H.fragmentTracker.removeFragment(g);return}g.stats.chunkCount++,H._handleFragmentLoadProgress(G)};this._doFragLoad(g,E,_,V).then(function(Z){if(!Z)return;H.fragLoadError=0;var G=H.state;if(H.fragContextChanged(g)){(G===x.FRAG_LOADING||G===x.BACKTRACKING||!H.fragCurrent&&G===x.PARSING)&&(H.fragmentTracker.removeFragment(g),H.state=x.IDLE);return}if("payload"in Z&&(H.log("Loaded fragment "+g.sn+" of level "+g.level),H.hls.trigger(P.Events.FRAG_LOADED,Z),H.state===x.BACKTRACKING)){H.fragmentTracker.backtrack(g,Z),H.resetFragmentLoading(g);return}H._handleFragmentLoadComplete(Z)}).catch(function(Z){H.warn(Z),H.resetFragmentLoading(g)})},a.flushMainBuffer=function(g,E,_){if(_===void 0&&(_=null),!(g-E))return;var H={startOffset:g,endOffset:E,type:_};this.fragLoadError=0,this.hls.trigger(P.Events.BUFFER_FLUSHING,H)},a._loadInitSegment=function(g){var E=this;this._doFragLoad(g).then(function(_){if(!_||E.fragContextChanged(g)||!E.levels)throw new Error("init load aborted");return _}).then(function(_){var H=E.hls,V=_.payload,Z=g.decryptdata;if(V&&V.byteLength>0&&Z&&Z.key&&Z.iv&&Z.method==="AES-128"){var G=self.performance.now();return E.decrypter.webCryptoDecrypt(new Uint8Array(V),Z.key.buffer,Z.iv.buffer).then(function(j){var q=self.performance.now();return H.trigger(P.Events.FRAG_DECRYPTED,{frag:g,payload:j,stats:{tstart:G,tdecrypt:q}}),_.payload=j,_})}return _}).then(function(_){var H=E.fragCurrent,V=E.hls,Z=E.levels;if(!Z)throw new Error("init load aborted, missing levels");var G=Z[g.level].details;console.assert(G,"Level details are defined when init segment is loaded");var j=g.stats;E.state=x.IDLE,E.fragLoadError=0,g.data=new Uint8Array(_.payload),j.parsing.start=j.buffering.start=self.performance.now(),j.parsing.end=j.buffering.end=self.performance.now(),_.frag===H&&V.trigger(P.Events.FRAG_BUFFERED,{stats:j,frag:H,part:null,id:g.type}),E.tick()}).catch(function(_){E.warn(_),E.resetFragmentLoading(g)})},a.fragContextChanged=function(g){var E=this.fragCurrent;return!g||!E||g.level!==E.level||g.sn!==E.sn||g.urlId!==E.urlId},a.fragBufferedComplete=function(g,E){var _=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+g.type+" sn: "+g.sn+(E?" part: "+E.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+g.level+" "+o.default.toString(z.BufferHelper.getBuffered(_))),this.state=x.IDLE,this.tick()},a._handleFragmentLoadComplete=function(g){var E=this.transmuxer;if(!E)return;var _=g.frag,H=g.part,V=g.partsLoaded,Z=!V||V.length===0||V.some(function(j){return!j}),G=new b.ChunkMetadata(_.level,_.sn,_.stats.chunkCount+1,0,H?H.index:-1,!Z);E.flush(G)},a._handleFragmentLoadProgress=function(g){},a._doFragLoad=function(g,E,_,H){var V=this;if(_===void 0&&(_=null),!this.levels)throw new Error("frag load aborted, missing levels");if(_=Math.max(g.start,_||0),this.config.lowLatencyMode&&E){var Z=E.partList;if(Z&&H){_>g.end&&E.fragmentHint&&(g=E.fragmentHint);var G=this.getNextPart(Z,g,_);if(G>-1){var j=Z[G];return this.log("Loading part sn: "+g.sn+" p: "+j.index+" cc: "+g.cc+" of playlist ["+E.startSN+"-"+E.endSN+"] parts [0-"+G+"-"+(Z.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+g.level+", target: "+parseFloat(_.toFixed(3))),this.nextLoadPosition=j.start+j.duration,this.state=x.FRAG_LOADING,this.hls.trigger(P.Events.FRAG_LOADING,{frag:g,part:Z[G],targetBufferTime:_}),this.doFragPartsLoad(g,Z,G,H).catch(function(q){return V.handleFragLoadError(q)})}else if(!g.url||this.loadedEndOfParts(Z,_))return Promise.resolve(null)}}return this.log("Loading fragment "+g.sn+" cc: "+g.cc+" "+(E?"of ["+E.startSN+"-"+E.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+g.level+", target: "+parseFloat(_.toFixed(3))),Object(X.isFiniteNumber)(g.sn)&&!this.bitrateTest&&(this.nextLoadPosition=g.start+g.duration),this.state=x.FRAG_LOADING,this.hls.trigger(P.Events.FRAG_LOADING,{frag:g,targetBufferTime:_}),this.fragmentLoader.load(g,H).catch(function(q){return V.handleFragLoadError(q)})},a.doFragPartsLoad=function(g,E,_,H){var V=this;return new Promise(function(Z,G){var j=[],q=function ie(ce){var ve=E[ce];V.fragmentLoader.loadPart(g,ve,H).then(function(ke){j[ve.index]=ke;var xe=ke.part;V.hls.trigger(P.Events.FRAG_LOADED,ke);var Ce=E[ce+1];if(Ce&&Ce.fragment===g)ie(ce+1);else return Z({frag:g,part:xe,partsLoaded:j})}).catch(G)};q(_)})},a.handleFragLoadError=function(g){var E=g.data;return E&&E.details===M.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(E.frag,E.part):this.hls.trigger(P.Events.ERROR,E),null},a._handleTransmuxerFlush=function(g){var E=this.getCurrentContext(g);if(!E||this.state!==x.PARSING){this.fragCurrent||(this.state=x.IDLE);return}var _=E.frag,H=E.part,V=E.level,Z=self.performance.now();_.stats.parsing.end=Z,H&&(H.stats.parsing.end=Z),this.updateLevelTiming(_,H,V,g.partial)},a.getCurrentContext=function(g){var E=this.levels,_=g.level,H=g.sn,V=g.part;if(!E||!E[_])return this.warn("Levels object was unset while buffering fragment "+H+" of level "+_+". The current chunk will not be buffered."),null;var Z=E[_],G=V>-1?Object(w.getPartWith)(Z,H,V):null,j=G?G.fragment:Object(w.getFragmentWithSN)(Z,H,this.fragCurrent);return j?{frag:j,part:G,level:Z}:null},a.bufferFragmentData=function(g,E,_,H){if(!g||this.state!==x.PARSING)return;var V=g.data1,Z=g.data2,G=V;if(V&&Z&&(G=Object(A.appendUint8Array)(V,Z)),!G||!G.length)return;var j={type:g.type,frag:E,part:_,chunkMeta:H,parent:E.type,data:G};this.hls.trigger(P.Events.BUFFER_APPENDING,j),g.dropped&&g.independent&&!_&&this.flushBufferGap(E)},a.flushBufferGap=function(g){var E=this.media;if(!E)return;if(!z.BufferHelper.isBuffered(E,E.currentTime)){this.flushMainBuffer(0,g.start);return}var _=E.currentTime,H=z.BufferHelper.bufferInfo(E,_,0),V=g.duration,Z=Math.min(this.config.maxFragLookUpTolerance*2,V*.25),G=Math.max(Math.min(g.start-Z,H.end-Z),_+Z);g.start-G>Z&&this.flushMainBuffer(G,g.start)},a.getFwdBufferInfo=function(g,E){var _=this.config,H=this.getLoadPosition();if(!Object(X.isFiniteNumber)(H))return null;var V=z.BufferHelper.bufferInfo(g,H,_.maxBufferHole);if(V.len===0&&V.nextStart!==void 0){var Z=this.fragmentTracker.getBufferedFrag(H,E);if(Z&&V.nextStart<Z.end)return z.BufferHelper.bufferInfo(g,H,Math.max(V.nextStart,_.maxBufferHole))}return V},a.getMaxBufferLength=function(g){var E=this.config,_;return g?_=Math.max(8*E.maxBufferSize/g,E.maxBufferLength):_=E.maxBufferLength,Math.min(_,E.maxMaxBufferLength)},a.reduceMaxBufferLength=function(g){var E=this.config,_=g||E.maxBufferLength;return E.maxMaxBufferLength>=_?(E.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+E.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(g,E){var _,H,V=E.fragments,Z=V.length;if(!Z)return null;var G=this.config,j=V[0].start,q;if(E.live){var ie=G.initialLiveManifestSize;if(Z<ie)return this.warn("Not enough fragments to start playback (have: "+Z+", need: "+ie+")"),null;!E.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(q=this.getInitialLiveFragment(E,V),this.startPosition=q?this.hls.liveSyncPosition||q.start:g)}else g<=j&&(q=V[0]);if(!q){var ce=G.lowLatencyMode?E.partEnd:E.fragmentEnd;q=this.getFragmentAtPosition(g,ce,E)}return(_=q)!==null&&_!==void 0&&_.initSegment&&!((H=q)!==null&&H!==void 0&&H.initSegment.data)&&!this.bitrateTest&&(q=q.initSegment),q},a.getNextPart=function(g,E,_){for(var H=-1,V=!1,Z=!0,G=0,j=g.length;G<j;G++){var q=g[G];if(Z=Z&&!q.independent,H>-1&&_<q.start)break;var ie=q.loaded;!ie&&(V||q.independent||Z)&&q.fragment===E&&(H=G),V=ie}return H},a.loadedEndOfParts=function(g,E){var _=g[g.length-1];return _&&E>_.start&&_.loaded},a.getInitialLiveFragment=function(g,E){var _=this.fragPrevious,H=null;if(_){if(g.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+_.programDateTime),H=Object(L.findFragmentByPDT)(E,_.endProgramDateTime,this.config.maxFragLookUpTolerance)),!H){var V=_.sn+1;if(V>=g.startSN&&V<=g.endSN){var Z=E[V-g.startSN];_.cc===Z.cc&&(H=Z,this.log("Live playlist, switching playlist, load frag with next SN: "+H.sn))}H||(H=Object(L.findFragWithCC)(E,_.cc),H&&this.log("Live playlist, switching playlist, load frag with same CC: "+H.sn))}}else{var G=this.hls.liveSyncPosition;G!==null&&(H=this.getFragmentAtPosition(G,this.bitrateTest?g.fragmentEnd:g.edge,g))}return H},a.getFragmentAtPosition=function(g,E,_){var H=this.config,V=this.fragPrevious,Z=_.fragments,G=_.endSN,j=_.fragmentHint,q=H.maxFragLookUpTolerance,ie=!!(H.lowLatencyMode&&_.partList&&j);ie&&j&&!this.bitrateTest&&(Z=Z.concat(j),G=j.sn);var ce;if(g<E){var ve=g>E-q?0:q;ce=Object(L.findFragmentByPTS)(V,Z,g,ve)}else ce=Z[Z.length-1];if(ce){var ke=ce.sn-_.startSN,xe=V&&ce.level===V.level,Ce=Z[ke+1],Te=this.fragmentTracker.getState(ce);if(Te===I.FragmentState.BACKTRACKED){ce=null;for(var Ee=ke;Z[Ee]&&this.fragmentTracker.getState(Z[Ee])===I.FragmentState.BACKTRACKED;)V?ce=Z[Ee--]:ce=Z[--Ee];ce||(ce=Ce)}else V&&ce.sn===V.sn&&!ie&&(xe&&(ce.sn<G&&this.fragmentTracker.getState(Ce)!==I.FragmentState.OK?(this.log("SN "+ce.sn+" just loaded, load next one: "+Ce.sn),ce=Ce):ce=null))}return ce},a.synchronizeToLiveEdge=function(g){var E=this.config,_=this.media;if(!_)return;var H=this.hls.liveSyncPosition,V=_.currentTime,Z=g.fragments[0].start,G=g.edge,j=V>=Z-E.maxFragLookUpTolerance&&V<=G;if(H!==null&&_.duration>H&&(V<H||!j)){var q=E.liveMaxLatencyDuration!==void 0?E.liveMaxLatencyDuration:E.liveMaxLatencyDurationCount*g.targetduration;(!j&&_.readyState<4||V<G-q)&&(this.loadedmetadata||(this.nextLoadPosition=H),_.readyState&&(this.warn("Playback: "+V.toFixed(3)+" is located too far from the end of live sliding playlist: "+G+", reset currentTime to : "+H.toFixed(3)),_.currentTime=H))}},a.alignPlaylists=function(g,E){var _=this.levels,H=this.levelLastLoaded,V=this.fragPrevious,Z=H!==null?_[H]:null,G=g.fragments.length;if(!G)return this.warn("No fragments in live playlist"),0;var j=g.fragments[0].start,q=!E,ie=g.alignedSliding&&Object(X.isFiniteNumber)(j);if(q||!ie&&!j){Object(R.alignStream)(V,Z,g);var ce=g.fragments[0].start;return this.log("Live playlist sliding: "+ce.toFixed(2)+" start-sn: "+(E?E.startSN:"na")+"->"+g.startSN+" prev-sn: "+(V?V.sn:"na")+" fragments: "+G),ce}return j},a.waitForCdnTuneIn=function(g){var E=3;return g.live&&g.canBlockReload&&g.tuneInGoal>Math.max(g.partHoldBack,g.partTarget*E)},a.setStartPosition=function(g,E){var _=this.startPosition;if(_<E&&(_=-1),_===-1||this.lastCurrentTime===-1){var H=g.startTimeOffset;Object(X.isFiniteNumber)(H)?(_=E+H,H<0&&(_+=g.totalduration),_=Math.min(Math.max(E,_),E+g.totalduration),this.log("Start time offset "+H+" found in playlist, adjust startPosition to "+_),this.startPosition=_):g.live?_=this.hls.liveSyncPosition||E:this.startPosition=_=0,this.lastCurrentTime=_}this.nextLoadPosition=_},a.getLoadPosition=function(){var g=this.media,E=0;return this.loadedmetadata&&g?E=g.currentTime:this.nextLoadPosition&&(E=this.nextLoadPosition),E},a.handleFragLoadAborted=function(g,E){this.transmuxer&&g.sn!=="initSegment"&&g.stats.aborted&&(this.warn("Fragment "+g.sn+(E?" part"+E.index:"")+" of level "+g.level+" was aborted"),this.resetFragmentLoading(g))},a.resetFragmentLoading=function(g){(!this.fragCurrent||!this.fragContextChanged(g))&&(this.state=x.IDLE)},a.onFragmentOrKeyLoadError=function(g,E){if(E.fatal)return;var _=E.frag;if(!_||_.type!==g)return;var H=this.fragCurrent;console.assert(H&&_.sn===H.sn&&_.level===H.level&&_.urlId===H.urlId,"Frag load error must match current frag to retry");var V=this.config;if(this.fragLoadError+1<=V.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(_.level))return;var Z=Math.min(Math.pow(2,this.fragLoadError)*V.fragLoadingRetryDelay,V.fragLoadingMaxRetryTimeout);this.warn("Fragment "+_.sn+" of "+g+" "+_.level+" failed to load, retrying in "+Z+"ms"),this.retryDate=self.performance.now()+Z,this.fragLoadError++,this.state=x.FRAG_LOADING_WAITING_RETRY}else E.levelRetry?(g===u.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=x.IDLE):(U.logger.error(E.details+" reaches max retry, redispatch as fatal ..."),E.fatal=!0,this.hls.stopLoad(),this.state=x.ERROR)},a.afterBufferFlushed=function(g,E,_){if(!g)return;var H=z.BufferHelper.getBuffered(g);this.fragmentTracker.detectEvictedFragments(E,H,_),this.state===x.ENDED&&this.resetLoadingState()},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=x.IDLE},a.resetLiveStartWhenNotLoaded=function(g){if(!this.loadedmetadata){this.startFragRequested=!1;var E=this.levels?this.levels[g].details:null;if(E!=null&&E.live)return this.startPosition=-1,this.setStartPosition(E,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},a.updateLevelTiming=function(g,E,_,H){var V=this,Z=_.details;console.assert(!!Z,"level.details must be defined");var G=Object.keys(g.elementaryStreams).reduce(function(j,q){var ie=g.elementaryStreams[q];if(ie){var ce=ie.endPTS-ie.startPTS;if(ce<=0)return V.warn("Could not parse fragment "+g.sn+" "+q+" duration reliably ("+ce+") resetting transmuxer to fallback to playlist timing"),V.resetTransmuxer(),j||!1;var ve=H?0:Object(w.updateFragPTSDTS)(Z,g,ie.startPTS,ie.endPTS,ie.startDTS,ie.endDTS);return V.hls.trigger(P.Events.LEVEL_PTS_UPDATED,{details:Z,level:_,drift:ve,type:q,frag:g,start:ie.startPTS,end:ie.endPTS}),!0}return j},!1);G?(this.state=x.PARSED,this.hls.trigger(P.Events.FRAG_PARSED,{frag:g,part:E})):this.resetLoadingState()},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},T(s,[{key:"state",get:function(){return this._state},set:function(g){var E=this._state;E!==g&&(this._state=g,this.log(E+"->"+g))}}]),s}(N.default)},"./src/controller/buffer-controller.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return L});var X=D("./src/polyfills/number.ts"),N=D("./src/events.ts"),I=D("./src/utils/logger.ts"),z=D("./src/errors.ts"),U=D("./src/utils/buffer-helper.ts"),P=D("./src/utils/mediasource-helper.ts"),M=D("./src/loader/fragment.ts"),b=D("./src/controller/buffer-operation-queue.ts"),A=Object(P.getMediaSource)(),R=/([ha]vc.)(?:\.[^.,]+)+/,L=function(){function w(h){var o=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var u=o.hls,d=o.media,T=o.mediaSource;I.logger.log("[buffer-controller]: Media source opened"),d&&(o.updateMediaElementDuration(),u.trigger(N.Events.MEDIA_ATTACHED,{media:d})),T&&T.removeEventListener("sourceopen",o._onMediaSourceOpen),o.checkPendingTracks()},this._onMediaSourceClose=function(){I.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){I.logger.log("[buffer-controller]: Media source ended")},this.hls=h,this._initSourceBuffer(),this.registerListeners()}var S=w.prototype;return S.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},S.destroy=function(){this.unregisterListeners(),this.details=null},S.registerListeners=function(){var o=this.hls;o.on(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(N.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(N.Events.BUFFER_RESET,this.onBufferReset,this),o.on(N.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.on(N.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.on(N.Events.BUFFER_EOS,this.onBufferEos,this),o.on(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.on(N.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.on(N.Events.FRAG_PARSED,this.onFragParsed,this),o.on(N.Events.FRAG_CHANGED,this.onFragChanged,this)},S.unregisterListeners=function(){var o=this.hls;o.off(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(N.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(N.Events.BUFFER_RESET,this.onBufferReset,this),o.off(N.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.off(N.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.off(N.Events.BUFFER_EOS,this.onBufferEos,this),o.off(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.off(N.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.off(N.Events.FRAG_PARSED,this.onFragParsed,this),o.off(N.Events.FRAG_CHANGED,this.onFragChanged,this)},S._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new b.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},S.onManifestParsed=function(o,u){var d=2;(u.audio&&!u.video||!u.altAudio)&&(d=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=d,this.details=null,I.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},S.onMediaAttaching=function(o,u){var d=this.media=u.media;if(d&&A){var T=this.mediaSource=new A;T.addEventListener("sourceopen",this._onMediaSourceOpen),T.addEventListener("sourceended",this._onMediaSourceEnded),T.addEventListener("sourceclose",this._onMediaSourceClose),d.src=self.URL.createObjectURL(T),this._objectUrl=d.src}},S.onMediaDetaching=function(){var o=this.media,u=this.mediaSource,d=this._objectUrl;if(u){if(I.logger.log("[buffer-controller]: media source detaching"),u.readyState==="open")try{u.endOfStream()}catch(T){I.logger.warn("[buffer-controller]: onMediaDetaching: "+T.message+" while calling endOfStream")}this.onBufferReset(),u.removeEventListener("sourceopen",this._onMediaSourceOpen),u.removeEventListener("sourceended",this._onMediaSourceEnded),u.removeEventListener("sourceclose",this._onMediaSourceClose),o&&(d&&self.URL.revokeObjectURL(d),o.src===d?(o.removeAttribute("src"),o.load()):I.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)},S.onBufferReset=function(){var o=this;this.getSourceBufferTypes().forEach(function(u){var d=o.sourceBuffer[u];try{d&&(o.removeBufferListeners(u),o.mediaSource&&o.mediaSource.removeSourceBuffer(d),o.sourceBuffer[u]=void 0)}catch(T){I.logger.warn("[buffer-controller]: Failed to reset the "+u+" buffer",T)}}),this._initSourceBuffer()},S.onBufferCodecs=function(o,u){var d=this,T=this.getSourceBufferTypes().length;if(Object.keys(u).forEach(function(y){if(T){var f=d.tracks[y];if(f&&typeof f.buffer.changeType=="function"){var k=u[y],x=k.codec,p=k.levelCodec,c=k.container,s=(f.levelCodec||f.codec).replace(R,"$1"),a=(p||x).replace(R,"$1");if(s!==a){var v=c+";codecs="+(p||x);d.appendChangeType(y,v)}}}else d.pendingTracks[y]=u[y]}),T)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},S.appendChangeType=function(o,u){var d=this,T=this.operationQueue,y={execute:function(){var k=d.sourceBuffer[o];k&&(I.logger.log("[buffer-controller]: changing "+o+" sourceBuffer type to "+u),k.changeType(u)),T.shiftAndExecuteNext(o)},onStart:function(){},onComplete:function(){},onError:function(k){I.logger.warn("[buffer-controller]: Failed to change "+o+" SourceBuffer type",k)}};T.append(y,o)},S.onBufferAppending=function(o,u){var d=this,T=this.hls,y=this.operationQueue,f=this.tracks,k=u.data,x=u.type,p=u.frag,c=u.part,s=u.chunkMeta,a=s.buffering[x],v=self.performance.now();a.start=v;var g=p.stats.buffering,E=c?c.stats.buffering:null;g.start===0&&(g.start=v),E&&E.start===0&&(E.start=v);var _=f.audio,H=x==="audio"&&s.id===1&&(_==null?void 0:_.container)==="audio/mpeg",V={execute:function(){if(a.executeStart=self.performance.now(),H){var G=d.sourceBuffer[x];if(G){var j=p.start-G.timestampOffset;Math.abs(j)>=.1&&(I.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+p.start+" (delta: "+j+") sn: "+p.sn+")"),G.timestampOffset=p.start)}}d.appendExecutor(k,x)},onStart:function(){},onComplete:function(){var G=self.performance.now();a.executeEnd=a.end=G,g.first===0&&(g.first=G),E&&E.first===0&&(E.first=G);var j=d.sourceBuffer,q={};for(var ie in j)q[ie]=U.BufferHelper.getBuffered(j[ie]);d.appendError=0,d.hls.trigger(N.Events.BUFFER_APPENDED,{type:x,frag:p,part:c,chunkMeta:s,parent:p.type,timeRanges:q})},onError:function(G){I.logger.error("[buffer-controller]: Error encountered while trying to append to the "+x+" SourceBuffer",G);var j={type:z.ErrorTypes.MEDIA_ERROR,parent:p.type,details:z.ErrorDetails.BUFFER_APPEND_ERROR,err:G,fatal:!1};G.code===DOMException.QUOTA_EXCEEDED_ERR?j.details=z.ErrorDetails.BUFFER_FULL_ERROR:(d.appendError++,j.details=z.ErrorDetails.BUFFER_APPEND_ERROR,d.appendError>T.config.appendErrorMaxRetry&&(I.logger.error("[buffer-controller]: Failed "+T.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),j.fatal=!0)),T.trigger(N.Events.ERROR,j)}};y.append(V,x)},S.onBufferFlushing=function(o,u){var d=this,T=this.operationQueue,y=function(k){return{execute:d.removeExecutor.bind(d,k,u.startOffset,u.endOffset),onStart:function(){},onComplete:function(){d.hls.trigger(N.Events.BUFFER_FLUSHED,{type:k})},onError:function(p){I.logger.warn("[buffer-controller]: Failed to remove from "+k+" SourceBuffer",p)}}};u.type?T.append(y(u.type),u.type):this.getSourceBufferTypes().forEach(function(f){T.append(y(f),f)})},S.onFragParsed=function(o,u){var d=this,T=u.frag,y=u.part,f=[],k=y?y.elementaryStreams:T.elementaryStreams;k[M.ElementaryStreamTypes.AUDIOVIDEO]?f.push("audiovideo"):(k[M.ElementaryStreamTypes.AUDIO]&&f.push("audio"),k[M.ElementaryStreamTypes.VIDEO]&&f.push("video"));var x=function(){var c=self.performance.now();T.stats.buffering.end=c,y&&(y.stats.buffering.end=c);var s=y?y.stats:T.stats;d.hls.trigger(N.Events.FRAG_BUFFERED,{frag:T,part:y,stats:s,id:T.type})};f.length===0&&I.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+T.type+" level: "+T.level+" sn: "+T.sn),this.blockBuffers(x,f)},S.onFragChanged=function(o,u){this.flushBackBuffer()},S.onBufferEos=function(o,u){var d=this,T=this.getSourceBufferTypes().reduce(function(y,f){var k=d.sourceBuffer[f];return(!u.type||u.type===f)&&(k&&!k.ended&&(k.ended=!0,I.logger.log("[buffer-controller]: "+f+" sourceBuffer now EOS"))),y&&!!(!k||k.ended)},!0);T&&this.blockBuffers(function(){var y=d.mediaSource;if(!y||y.readyState!=="open")return;y.endOfStream()})},S.onLevelUpdated=function(o,u){var d=u.details;if(!d.fragments.length)return;this.details=d,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},S.flushBackBuffer=function(){var o=this.hls,u=this.details,d=this.media,T=this.sourceBuffer;if(!d||u===null)return;var y=this.getSourceBufferTypes();if(!y.length)return;var f=u.live&&o.config.liveBackBufferLength!==null?o.config.liveBackBufferLength:o.config.backBufferLength;if(!Object(X.isFiniteNumber)(f)||f<0)return;var k=d.currentTime,x=u.levelTargetDuration,p=Math.max(f,x),c=Math.floor(k/x)*x-p;y.forEach(function(s){var a=T[s];if(a){var v=U.BufferHelper.getBuffered(a);v.length>0&&c>v.start(0)&&(o.trigger(N.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),u.live&&o.trigger(N.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c}),o.trigger(N.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:s}))}})},S.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var o=this.details,u=this.hls,d=this.media,T=this.mediaSource,y=o.fragments[0].start+o.totalduration,f=d.duration,k=Object(X.isFiniteNumber)(T.duration)?T.duration:0;o.live&&u.config.liveDurationInfinity?(I.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),T.duration=Infinity,this.updateSeekableRange(o)):(y>k&&y>f||!Object(X.isFiniteNumber)(f))&&(I.logger.log("[buffer-controller]: Updating Media Source duration to "+y.toFixed(3)),T.duration=y)},S.updateSeekableRange=function(o){var u=this.mediaSource,d=o.fragments,T=d.length;if(T&&o.live&&u!==null&&u!==void 0&&u.setLiveSeekableRange){var y=Math.max(0,d[0].start),f=Math.max(y,y+o.totalduration);u.setLiveSeekableRange(y,f)}},S.checkPendingTracks=function(){var o=this.bufferCodecEventsExpected,u=this.operationQueue,d=this.pendingTracks,T=Object.keys(d).length;if(T&&!o||T===2){this.createSourceBuffers(d),this.pendingTracks={};var y=this.getSourceBufferTypes();if(y.length===0){this.hls.trigger(N.Events.ERROR,{type:z.ErrorTypes.MEDIA_ERROR,details:z.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}y.forEach(function(f){u.executeNext(f)})}},S.createSourceBuffers=function(o){var u=this.sourceBuffer,d=this.mediaSource;if(!d)throw Error("createSourceBuffers called when mediaSource was null");var T=0;for(var y in o)if(!u[y]){var f=o[y];if(!f)throw Error("source buffer exists for track "+y+", however track does not");var k=f.levelCodec||f.codec,x=f.container+";codecs="+k;I.logger.log("[buffer-controller]: creating sourceBuffer("+x+")");try{var p=u[y]=d.addSourceBuffer(x),c=y;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[y]={buffer:p,codec:k,container:f.container,levelCodec:f.levelCodec,id:f.id},T++}catch(s){I.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+s.message),this.hls.trigger(N.Events.ERROR,{type:z.ErrorTypes.MEDIA_ERROR,details:z.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:s,mimeType:x})}}T&&this.hls.trigger(N.Events.BUFFER_CREATED,{tracks:this.tracks})},S._onSBUpdateStart=function(o){var u=this.operationQueue,d=u.current(o);d.onStart()},S._onSBUpdateEnd=function(o){var u=this.operationQueue,d=u.current(o);d.onComplete(),u.shiftAndExecuteNext(o)},S._onSBUpdateError=function(o,u){I.logger.error("[buffer-controller]: "+o+" SourceBuffer error",u),this.hls.trigger(N.Events.ERROR,{type:z.ErrorTypes.MEDIA_ERROR,details:z.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var d=this.operationQueue.current(o);d&&d.onError(u)},S.removeExecutor=function(o,u,d){var T=this.media,y=this.mediaSource,f=this.operationQueue,k=this.sourceBuffer,x=k[o];if(!T||!y||!x){I.logger.warn("[buffer-controller]: Attempting to remove from the "+o+" SourceBuffer, but it does not exist"),f.shiftAndExecuteNext(o);return}var p=Object(X.isFiniteNumber)(T.duration)?T.duration:Infinity,c=Object(X.isFiniteNumber)(y.duration)?y.duration:Infinity,s=Math.max(0,u),a=Math.min(d,p,c);a>s?(I.logger.log("[buffer-controller]: Removing ["+s+","+a+"] from the "+o+" SourceBuffer"),console.assert(!x.updating,o+" sourceBuffer must not be updating"),x.remove(s,a)):f.shiftAndExecuteNext(o)},S.appendExecutor=function(o,u){var d=this.operationQueue,T=this.sourceBuffer,y=T[u];if(!y){I.logger.warn("[buffer-controller]: Attempting to append to the "+u+" SourceBuffer, but it does not exist"),d.shiftAndExecuteNext(u);return}y.ended=!1,console.assert(!y.updating,u+" sourceBuffer must not be updating"),y.appendBuffer(o)},S.blockBuffers=function(o,u){var d=this;if(u===void 0&&(u=this.getSourceBufferTypes()),!u.length){I.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(o);return}var T=this.operationQueue,y=u.map(function(f){return T.appendBlocker(f)});Promise.all(y).then(function(){o(),u.forEach(function(f){var k=d.sourceBuffer[f];(!k||!k.updating)&&T.shiftAndExecuteNext(f)})})},S.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},S.addBufferListener=function(o,u,d){var T=this.sourceBuffer[o];if(!T)return;var y=d.bind(this,o);this.listeners[o].push({event:u,listener:y}),T.addEventListener(u,y)},S.removeBufferListeners=function(o){var u=this.sourceBuffer[o];if(!u)return;this.listeners[o].forEach(function(d){u.removeEventListener(d.event,d.listener)})},w}()},"./src/controller/buffer-operation-queue.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return N});var X=D("./src/utils/logger.ts"),N=function(){function I(U){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=U}var z=I.prototype;return z.append=function(P,M){var b=this.queues[M];b.push(P),b.length===1&&this.buffers[M]&&this.executeNext(M)},z.insertAbort=function(P,M){var b=this.queues[M];b.unshift(P),this.executeNext(M)},z.appendBlocker=function(P){var M,b=new Promise(function(R){M=R}),A={execute:M,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(A,P),b},z.executeNext=function(P){var M=this.buffers,b=this.queues,A=M[P],R=b[P];if(R.length){var L=R[0];try{L.execute()}catch(w){X.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),L.onError(w),(!A||!A.updating)&&(R.shift(),this.executeNext(P))}}},z.shiftAndExecuteNext=function(P){this.queues[P].shift(),this.executeNext(P)},z.current=function(P){return this.queues[P][0]},I}()},"./src/controller/cap-level-controller.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/events.ts");function N(U,P){for(var M=0;M<P.length;M++){var b=P[M];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(U,b.key,b)}}function I(U,P,M){return P&&N(U.prototype,P),M&&N(U,M),U}var z=function(){function U(M){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=M,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var P=U.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(X.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),b.on(X.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),b.on(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),b.on(X.Events.BUFFER_CODECS,this.onBufferCodecs,this),b.on(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},P.unregisterListener=function(){var b=this.hls;b.off(X.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),b.off(X.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),b.off(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),b.off(X.Events.BUFFER_CODECS,this.onBufferCodecs,this),b.off(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},P.onFpsDropLevelCapping=function(b,A){U.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 R=this.hls;this.restrictedLevels=[],this.firstLevel=A.firstLevel,R.config.capLevelToPlayerSize&&A.video&&this.startCapping()},P.onBufferCodecs=function(b,A){var R=this.hls;R.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,R=this.hls.levels;if(!R.length)return-1;var L=R.filter(function(w,S){return U.isLevelAllowed(S,A.restrictedLevels)&&S<=b});return this.clientRect=null,U.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 R=b.getBoundingClientRect();A.width=R.width,A.height=R.height,!A.width&&!A.height&&(A.width=R.right-R.left||b.width||0,A.height=R.bottom-R.top||b.height||0)}return this.clientRect=A,A},U.isLevelAllowed=function(b,A){return A===void 0&&(A=[]),A.indexOf(b)===-1},U.getMaxLevelByMediaSize=function(b,A,R){if(!b||!b.length)return-1;for(var L=function(u,d){return d?u.width!==d.width||u.height!==d.height:!0},w=b.length-1,S=0;S<b.length;S+=1){var h=b[S];if((h.width>=A||h.height>=R)&&L(h,b[S+1])){w=S;break}}return w},I(U,[{key:"mediaWidth",get:function(){return this.getDimensions().width*U.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*U.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var b=1;try{b=self.devicePixelRatio}catch(A){}return b}}]),U}();$.default=z},"./src/controller/cmcd-controller.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return L});var X=D("./src/events.ts"),N=D("./src/types/cmcd.ts"),I=D("./src/utils/buffer-helper.ts"),z=D("./src/utils/logger.ts");function U(w,S){for(var h=0;h<S.length;h++){var o=S[h];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(w,o.key,o)}}function P(w,S,h){return S&&U(w.prototype,S),h&&U(w,h),w}function M(w,S){var h=typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(h)return(h=h.call(w)).next.bind(h);if(Array.isArray(w)||(h=b(w))||S&&w&&typeof w.length=="number"){h&&(w=h);var o=0;return function(){return o>=w.length?{done:!0}:{done:!1,value:w[o++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function b(w,S){if(!w)return;if(typeof w=="string")return A(w,S);var h=Object.prototype.toString.call(w).slice(8,-1);if(h==="Object"&&w.constructor&&(h=w.constructor.name),h==="Map"||h==="Set")return Array.from(w);if(h==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(h))return A(w,S)}function A(w,S){(S==null||S>w.length)&&(S=w.length);for(var h=0,o=new Array(S);h<S;h++)o[h]=w[h];return o}function R(){return R=Object.assign||function(w){for(var S=1;S<arguments.length;S++){var h=arguments[S];for(var o in h)Object.prototype.hasOwnProperty.call(h,o)&&(w[o]=h[o])}return w},R.apply(this,arguments)}var L=function(){function w(h){var o=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){o.initialized&&(o.starved=!0),o.buffering=!0},this.onPlaying=function(){o.initialized||(o.initialized=!0),o.buffering=!1},this.applyPlaylistData=function(T){try{o.apply(T,{ot:N.CMCDObjectType.MANIFEST,su:!o.initialized})}catch(y){z.logger.warn("Could not generate manifest CMCD data.",y)}},this.applyFragmentData=function(T){try{var y=T.frag,f=o.hls.levels[y.level],k=o.getObjectType(y),x={d:y.duration*1e3,ot:k};(k===N.CMCDObjectType.VIDEO||k===N.CMCDObjectType.AUDIO||k==N.CMCDObjectType.MUXED)&&(x.br=f.bitrate/1e3,x.tb=o.getTopBandwidth(k),x.bl=o.getBufferLength(k)),o.apply(T,x)}catch(p){z.logger.warn("Could not generate segment CMCD data.",p)}},this.hls=h;var u=this.config=h.config,d=u.cmcd;d!=null&&(u.pLoader=this.createPlaylistLoader(),u.fLoader=this.createFragmentLoader(),this.sid=d.sessionId||w.uuid(),this.cid=d.contentId,this.useHeaders=d.useHeaders===!0,this.registerListeners())}var S=w.prototype;return S.registerListeners=function(){var o=this.hls;o.on(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(X.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.on(X.Events.BUFFER_CREATED,this.onBufferCreated,this)},S.unregisterListeners=function(){var o=this.hls;o.off(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(X.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.off(X.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},S.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},S.onMediaAttached=function(o,u){this.media=u.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},S.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},S.onBufferCreated=function(o,u){var d,T;this.audioBuffer=(d=u.tracks.audio)===null||d===void 0?void 0:d.buffer,this.videoBuffer=(T=u.tracks.video)===null||T===void 0?void 0:T.buffer},S.createData=function(){var o;return{v:N.CMCDVersion,sf:N.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(o=this.media)===null||o===void 0?void 0:o.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},S.apply=function(o,u){u===void 0&&(u={}),R(u,this.createData());var d=u.ot===N.CMCDObjectType.INIT||u.ot===N.CMCDObjectType.VIDEO||u.ot===N.CMCDObjectType.MUXED;if(this.starved&&d&&(u.bs=!0,u.su=!0,this.starved=!1),u.su==null&&(u.su=this.buffering),this.useHeaders){var T=w.toHeaders(u);if(!Object.keys(T).length)return;o.headers||(o.headers={}),R(o.headers,T)}else{var y=w.toQuery(u);if(!y)return;o.url=w.appendQueryToUri(o.url,y)}},S.getObjectType=function(o){var u=o.type;return u==="subtitle"?N.CMCDObjectType.TIMED_TEXT:o.sn==="initSegment"?N.CMCDObjectType.INIT:u==="audio"?N.CMCDObjectType.AUDIO:u==="main"?this.hls.audioTracks.length?N.CMCDObjectType.VIDEO:N.CMCDObjectType.MUXED:void 0},S.getTopBandwidth=function(o){for(var u=0,d=o===N.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,T=M(d),y;!(y=T()).done;){var f=y.value;f.bitrate>u&&(u=f.bitrate)}return u>0?u:NaN},S.getBufferLength=function(o){var u=this.hls.media,d=o===N.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!d||!u)return NaN;var T=I.BufferHelper.bufferInfo(d,u.currentTime,this.config.maxBufferHole);return T.len*1e3},S.createPlaylistLoader=function(){var o=this.config.pLoader,u=this.applyPlaylistData,d=o||this.config.loader;return function(){function T(f){this.loader=void 0,this.loader=new d(f)}var y=T.prototype;return y.destroy=function(){this.loader.destroy()},y.abort=function(){this.loader.abort()},y.load=function(k,x,p){u(k),this.loader.load(k,x,p)},P(T,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),T}()},S.createFragmentLoader=function(){var o=this.config.fLoader,u=this.applyFragmentData,d=o||this.config.loader;return function(){function T(f){this.loader=void 0,this.loader=new d(f)}var y=T.prototype;return y.destroy=function(){this.loader.destroy()},y.abort=function(){this.loader.abort()},y.load=function(k,x,p){u(k),this.loader.load(k,x,p)},P(T,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),T}()},w.uuid=function(){var o=URL.createObjectURL(new Blob),u=o.toString();return URL.revokeObjectURL(o),u.substr(u.lastIndexOf("/")+1)},w.serialize=function(o){for(var u=[],d=function(H){return!Number.isNaN(H)&&H!=null&&H!==""&&H!==!1},T=function(H){return Math.round(H)},y=function(H){return T(H/100)*100},f=function(H){return encodeURIComponent(H)},k={br:T,d:T,bl:y,dl:y,mtp:y,nor:f,rtp:y,tb:T},x=Object.keys(o||{}).sort(),p=M(x),c;!(c=p()).done;){var s=c.value,a=o[s];if(!d(a))continue;if(s==="v"&&a===1)continue;if(s=="pr"&&a===1)continue;var v=k[s];v&&(a=v(a));var g=typeof a,E=void 0;s==="ot"||s==="sf"||s==="st"?E=s+"="+a:g==="boolean"?E=s:g==="number"?E=s+"="+a:E=s+"="+JSON.stringify(a),u.push(E)}return u.join(",")},w.toHeaders=function(o){for(var u=Object.keys(o),d={},T=["Object","Request","Session","Status"],y=[{},{},{},{}],f={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},k=0,x=u;k<x.length;k++){var p=x[k],c=f[p]!=null?f[p]:1;y[c][p]=o[p]}for(var s=0;s<y.length;s++){var a=w.serialize(y[s]);a&&(d["CMCD-"+T[s]]=a)}return d},w.toQuery=function(o){return"CMCD="+encodeURIComponent(w.serialize(o))},w.appendQueryToUri=function(o,u){if(!u)return o;var d=o.includes("?")?"&":"?";return""+o+d+u},w}()},"./src/controller/eme-controller.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/events.ts"),N=D("./src/errors.ts"),I=D("./src/utils/logger.ts"),z=D("./src/utils/mediakeys-helper.ts");function U(L,w){for(var S=0;S<w.length;S++){var h=w[S];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(L,h.key,h)}}function P(L,w,S){return w&&U(L.prototype,w),S&&U(L,S),L}var M=3,b=function(w,S,h){var o={audioCapabilities:[],videoCapabilities:[]};return w.forEach(function(u){o.audioCapabilities.push({contentType:'audio/mp4; codecs="'+u+'"',robustness:h.audioRobustness||""})}),S.forEach(function(u){o.videoCapabilities.push({contentType:'video/mp4; codecs="'+u+'"',robustness:h.videoRobustness||""})}),[o]},A=function(w,S,h,o){switch(w){case z.KeySystems.WIDEVINE:return b(S,h,o);default:throw new Error("Unknown key-system: "+w)}},R=function(){function L(S){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=S,this._config=S.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(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(X.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(X.Events.MANIFEST_PARSED,this.onManifestParsed,this)},w._unregisterListeners=function(){this.hls.off(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(X.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(X.Events.MANIFEST_PARSED,this.onManifestParsed,this)},w.getLicenseServerUrl=function(h){switch(h){case z.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+h+'"')},w._attemptKeySystemAccess=function(h,o,u){var d=this,T=A(h,o,u,this._drmSystemOptions);I.logger.log("Requesting encrypted media key-system access");var y=this.requestMediaKeySystemAccess(h,T);this.mediaKeysPromise=y.then(function(f){return d._onMediaKeySystemAccessObtained(h,f)}),y.catch(function(f){I.logger.error('Failed to obtain key-system "'+h+'" access:',f)})},w._onMediaKeySystemAccessObtained=function(h,o){var u=this;I.logger.log('Access for key-system "'+h+'" obtained');var d={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:o,mediaKeySystemDomain:h};this._mediaKeysList.push(d);var T=Promise.resolve().then(function(){return o.createMediaKeys()}).then(function(y){return d.mediaKeys=y,I.logger.log('Media-keys created for key-system "'+h+'"'),u._onMediaKeysCreated(),y});return T.catch(function(y){I.logger.error("Failed to create media-keys:",y)}),T},w._onMediaKeysCreated=function(){var h=this;this._mediaKeysList.forEach(function(o){o.mediaKeysSession||(o.mediaKeysSession=o.mediaKeys.createSession(),h._onNewMediaKeySession(o.mediaKeysSession))})},w._onNewMediaKeySession=function(h){var o=this;I.logger.log("New key-system session "+h.sessionId),h.addEventListener("message",function(u){o._onKeySessionMessage(h,u.message)},!1)},w._onKeySessionMessage=function(h,o){I.logger.log("Got EME message event, creating license request"),this._requestLicense(o,function(u){I.logger.log("Received license data (length: "+(u&&u.byteLength)+"), updating key-session"),h.update(u)})},w.onMediaEncrypted=function(h){var o=this;if(I.logger.log('Media is encrypted using "'+h.initDataType+'" init data type'),!this.mediaKeysPromise){I.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var u=function(T){if(!o._media)return;o._attemptSetMediaKeys(T),o._generateRequestWithPreferredKeySession(h.initDataType,h.initData)};this.mediaKeysPromise.then(u).catch(u)},w._attemptSetMediaKeys=function(h){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var o=this._mediaKeysList[0];if(!o||!o.mediaKeys){I.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}I.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(o.mediaKeys),this._hasSetMediaKeys=!0}},w._generateRequestWithPreferredKeySession=function(h,o){var u=this,d=this._mediaKeysList[0];if(!d){I.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(d.mediaKeysSessionInitialized){I.logger.warn("Key-Session already initialized but requested again");return}var T=d.mediaKeysSession;if(!T){I.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!o){I.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}I.logger.log('Generating key-session request for "'+h+'" init data type'),d.mediaKeysSessionInitialized=!0,T.generateRequest(h,o).then(function(){I.logger.debug("Key-session generation succeeded")}).catch(function(y){I.logger.error("Error generating key-session request:",y),u.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},w._createLicenseXhr=function(h,o,u){var d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,d,h,o,u);var T=this._licenseXhrSetup;if(T)try{T.call(this.hls,d,h),T=void 0}catch(y){I.logger.error(y)}try{d.readyState||d.open("POST",h,!0),T&&T.call(this.hls,d,h)}catch(y){throw new Error("issue setting up KeySystem license XHR "+y)}return d},w._onLicenseRequestReadyStageChange=function(h,o,u,d){switch(h.readyState){case 4:if(h.status===200){this._requestLicenseFailureCount=0,I.logger.log("License request succeeded");var T=h.response,y=this._licenseResponseCallback;if(y)try{T=y.call(this.hls,h,o)}catch(k){I.logger.error(k)}d(T)}else{if(I.logger.error("License Request XHR failed ("+o+"). Status: "+h.status+" ("+h.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>M){this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var f=M-this._requestLicenseFailureCount+1;I.logger.warn("Retrying license request, "+f+" attempts left"),this._requestLicense(u,d)}break}},w._generateLicenseRequestChallenge=function(h,o){switch(h.mediaKeySystemDomain){case z.KeySystems.WIDEVINE:return o}throw new Error("unsupported key-system: "+h.mediaKeySystemDomain)},w._requestLicense=function(h,o){I.logger.log("Requesting content license for key-system");var u=this._mediaKeysList[0];if(!u){I.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var d=this.getLicenseServerUrl(u.mediaKeySystemDomain),T=this._createLicenseXhr(d,h,o);I.logger.log("Sending license request to URL: "+d);var y=this._generateLicenseRequestChallenge(u,h);T.send(y)}catch(f){I.logger.error("Failure requesting DRM license: "+f),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},w.onMediaAttached=function(h,o){if(!this._emeEnabled)return;var u=o.media;this._media=u,u.addEventListener("encrypted",this._onMediaEncrypted)},w.onMediaDetached=function(){var h=this._media,o=this._mediaKeysList;if(!h)return;h.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(o.map(function(u){if(u.mediaKeysSession)return u.mediaKeysSession.close().catch(function(){})})).then(function(){return h.setMediaKeys(null)}).catch(function(){})},w.onManifestParsed=function(h,o){if(!this._emeEnabled)return;var u=o.levels.map(function(T){return T.audioCodec}).filter(function(T){return!!T}),d=o.levels.map(function(T){return T.videoCodec}).filter(function(T){return!!T});this._attemptKeySystemAccess(z.KeySystems.WIDEVINE,u,d)},P(L,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),L}();$.default=R},"./src/controller/fps-controller.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/events.ts"),N=D("./src/utils/logger.ts"),I=function(){function z(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 U=z.prototype;return U.setStreamController=function(M){this.streamController=M},U.registerListeners=function(){this.hls.on(X.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},U.unregisterListeners=function(){this.hls.off(X.Events.MEDIA_ATTACHING,this.onMediaAttaching)},U.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},U.onMediaAttaching=function(M,b){var A=this.hls.config;if(A.capLevelOnFPSDrop){var R=b.media instanceof self.HTMLVideoElement?b.media:null;this.media=R,R&&typeof R.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),A.fpsDroppedMonitoringPeriod)}},U.checkFPS=function(M,b,A){var R=performance.now();if(b){if(this.lastTime){var L=R-this.lastTime,w=A-this.lastDroppedFrames,S=b-this.lastDecodedFrames,h=1e3*w/L,o=this.hls;if(o.trigger(X.Events.FPS_DROP,{currentDropped:w,currentDecoded:S,totalDroppedFrames:A}),h>0&&w>o.config.fpsDroppedMonitoringThreshold*S){var u=o.currentLevel;N.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(o.autoLevelCapping===-1||o.autoLevelCapping>=u)&&(u=u-1,o.trigger(X.Events.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:o.currentLevel}),o.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=R,this.lastDroppedFrames=A,this.lastDecodedFrames=b}},U.checkFPSInterval=function(){var M=this.media;if(M)if(this.isVideoPlaybackQualityAvailable){var b=M.getVideoPlaybackQuality();this.checkFPS(M,b.totalVideoFrames,b.droppedVideoFrames)}else this.checkFPS(M,M.webkitDecodedFrameCount,M.webkitDroppedFrameCount)},z}();$.default=I},"./src/controller/fragment-finders.ts":function(ne,$,D){"use strict";D.r($),D.d($,"findFragmentByPDT",function(){return I}),D.d($,"findFragmentByPTS",function(){return z}),D.d($,"fragmentWithinToleranceTest",function(){return U}),D.d($,"pdtWithinToleranceTest",function(){return P}),D.d($,"findFragWithCC",function(){return M});var X=D("./src/polyfills/number.ts"),N=D("./src/utils/binary-search.ts");function I(b,A,R){if(A===null||!Array.isArray(b)||!b.length||!Object(X.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;R=R||0;for(var S=0;S<b.length;++S){var h=b[S];if(P(A,R,h))return h}return null}function z(b,A,R,L){R===void 0&&(R=0),L===void 0&&(L=0);var w=null;if(b?w=A[b.sn-A[0].sn+1]||null:R===0&&A[0].start===0&&(w=A[0]),w&&U(R,L,w)===0)return w;var S=N.default.search(A,U.bind(null,R,L));return S||w}function U(b,A,R){b===void 0&&(b=0),A===void 0&&(A=0);var L=Math.min(A,R.duration+(R.deltaPTS?R.deltaPTS:0));return R.start+R.duration-L<=b?1:R.start-L>b&&R.start?-1:0}function P(b,A,R){var L=Math.min(A,R.duration+(R.deltaPTS?R.deltaPTS:0))*1e3,w=R.endProgramDateTime||0;return w-L>b}function M(b,A){return N.default.search(b,function(R){return R.cc<A?1:R.cc>A?-1:0})}},"./src/controller/fragment-tracker.ts":function(ne,$,D){"use strict";D.r($),D.d($,"FragmentState",function(){return I}),D.d($,"FragmentTracker",function(){return z});var X=D("./src/events.ts"),N=D("./src/types/loader.ts"),I;(function(M){M.NOT_LOADED="NOT_LOADED",M.BACKTRACKED="BACKTRACKED",M.APPENDING="APPENDING",M.PARTIAL="PARTIAL",M.OK="OK"})(I||(I={}));var z=function(){function M(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=M.prototype;return b._registerListeners=function(){var R=this.hls;R.on(X.Events.BUFFER_APPENDED,this.onBufferAppended,this),R.on(X.Events.FRAG_BUFFERED,this.onFragBuffered,this),R.on(X.Events.FRAG_LOADED,this.onFragLoaded,this)},b._unregisterListeners=function(){var R=this.hls;R.off(X.Events.BUFFER_APPENDED,this.onBufferAppended,this),R.off(X.Events.FRAG_BUFFERED,this.onFragBuffered,this),R.off(X.Events.FRAG_LOADED,this.onFragLoaded,this)},b.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},b.getAppendedFrag=function(R,L){if(L===N.PlaylistLevelType.MAIN){var w=this.activeFragment,S=this.activeParts;if(!w)return null;if(S)for(var h=S.length;h--;){var o=S[h],u=o?o.end:w.appendedPTS;if(o.start<=R&&u!==void 0&&R<=u)return h>9&&(this.activeParts=S.slice(h-9)),o}else if(w.start<=R&&w.appendedPTS!==void 0&&R<=w.appendedPTS)return w}return this.getBufferedFrag(R,L)},b.getBufferedFrag=function(R,L){for(var w=this.fragments,S=Object.keys(w),h=S.length;h--;){var o=w[S[h]];if((o==null?void 0:o.body.type)===L&&o.buffered){var u=o.body;if(u.start<=R&&R<=u.end)return u}}return null},b.detectEvictedFragments=function(R,L,w){var S=this;Object.keys(this.fragments).forEach(function(h){var o=S.fragments[h];if(!o)return;if(!o.buffered){o.body.type===w&&S.removeFragment(o.body);return}var u=o.range[R];if(!u)return;u.time.some(function(d){var T=!S.isTimeBuffered(d.startPTS,d.endPTS,L);return T&&S.removeFragment(o.body),T})})},b.detectPartialFragments=function(R){var L=this,w=this.timeRanges,S=R.frag,h=R.part;if(!w||S.sn==="initSegment")return;var o=P(S),u=this.fragments[o];if(!u)return;Object.keys(w).forEach(function(d){var T=S.elementaryStreams[d];if(!T)return;var y=w[d],f=h!==null||T.partial===!0;u.range[d]=L.getBufferedTimes(S,h,f,y)}),u.backtrack=u.loaded=null,Object.keys(u.range).length?u.buffered=!0:this.removeFragment(u.body)},b.fragBuffered=function(R){var L=P(R),w=this.fragments[L];w&&(w.backtrack=w.loaded=null,w.buffered=!0)},b.getBufferedTimes=function(R,L,w,S){for(var h={time:[],partial:w},o=L?L.start:R.start,u=L?L.end:R.end,d=R.minEndPTS||u,T=R.maxStartPTS||o,y=0;y<S.length;y++){var f=S.start(y)-this.bufferPadding,k=S.end(y)+this.bufferPadding;if(T>=f&&d<=k){h.time.push({startPTS:Math.max(o,S.start(y)),endPTS:Math.min(u,S.end(y))});break}else if(o<k&&u>f)h.partial=!0,h.time.push({startPTS:Math.max(o,S.start(y)),endPTS:Math.min(u,S.end(y))});else if(u<=f)break}return h},b.getPartialFragment=function(R){var L=null,w,S,h,o=0,u=this.bufferPadding,d=this.fragments;return Object.keys(d).forEach(function(T){var y=d[T];if(!y)return;U(y)&&(S=y.body.start-u,h=y.body.end+u,R>=S&&R<=h&&(w=Math.min(R-S,h-R),o<=w&&(L=y.body,o=w)))}),L},b.getState=function(R){var L=P(R),w=this.fragments[L];return w?w.buffered?U(w)?I.PARTIAL:I.OK:w.backtrack?I.BACKTRACKED:I.APPENDING:I.NOT_LOADED},b.backtrack=function(R,L){var w=P(R),S=this.fragments[w];if(!S||S.backtrack)return null;var h=S.backtrack=L||S.loaded;return S.loaded=null,h},b.getBacktrackData=function(R){var L=P(R),w=this.fragments[L];if(w){var S,h=w.backtrack;if(h!=null&&(S=h.payload)!==null&&S!==void 0&&S.byteLength)return h;this.removeFragment(R)}return null},b.isTimeBuffered=function(R,L,w){for(var S,h,o=0;o<w.length;o++){if(S=w.start(o)-this.bufferPadding,h=w.end(o)+this.bufferPadding,R>=S&&L<=h)return!0;if(L<=S)return!1}return!1},b.onFragLoaded=function(R,L){var w=L.frag,S=L.part;if(w.sn==="initSegment"||w.bitrateTest||S)return;var h=P(w);this.fragments[h]={body:w,loaded:L,backtrack:null,buffered:!1,range:Object.create(null)}},b.onBufferAppended=function(R,L){var w=this,S=L.frag,h=L.part,o=L.timeRanges;if(S.type===N.PlaylistLevelType.MAIN)if(this.activeFragment=S,h){var u=this.activeParts;u||(this.activeParts=u=[]),u.push(h)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach(function(d){var T=o[d];if(w.detectEvictedFragments(d,T),!h)for(var y=0;y<T.length;y++)S.appendedPTS=Math.max(T.end(y),S.appendedPTS||0)})},b.onFragBuffered=function(R,L){this.detectPartialFragments(L)},b.hasFragment=function(R){var L=P(R);return!!this.fragments[L]},b.removeFragmentsInRange=function(R,L,w){var S=this;Object.keys(this.fragments).forEach(function(h){var o=S.fragments[h];if(!o)return;if(o.buffered){var u=o.body;u.type===w&&u.start<L&&u.end>R&&S.removeFragment(u)}})},b.removeFragment=function(R){var L=P(R);R.stats.loaded=0,R.clearElementaryStreamInfo(),delete this.fragments[L]},b.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},M}();function U(M){var b,A;return M.buffered&&(((b=M.range.video)===null||b===void 0?void 0:b.partial)||((A=M.range.audio)===null||A===void 0?void 0:A.partial))}function P(M){return M.type+"_"+M.level+"_"+M.urlId+"_"+M.sn}},"./src/controller/gap-controller.ts":function(ne,$,D){"use strict";D.r($),D.d($,"STALL_MINIMUM_DURATION_MS",function(){return U}),D.d($,"MAX_START_GAP_JUMP",function(){return P}),D.d($,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return M}),D.d($,"SKIP_BUFFER_RANGE_START",function(){return b}),D.d($,"default",function(){return A});var X=D("./src/utils/buffer-helper.ts"),N=D("./src/errors.ts"),I=D("./src/events.ts"),z=D("./src/utils/logger.ts"),U=250,P=2,M=.1,b=.05,A=function(){function R(w,S,h,o){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=w,this.media=S,this.fragmentTracker=h,this.hls=o}var L=R.prototype;return L.destroy=function(){this.hls=this.fragmentTracker=this.media=null},L.poll=function(S){var h=this.config,o=this.media,u=this.stalled,d=o.currentTime,T=o.seeking,y=this.seeking&&!T,f=!this.seeking&&T;if(this.seeking=T,d!==S){if(this.moved=!0,u!==null){if(this.stallReported){var k=self.performance.now()-u;z.logger.warn("playback not stuck anymore @"+d+", after "+Math.round(k)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((f||y)&&(this.stalled=null),o.paused||o.ended||o.playbackRate===0||!X.BufferHelper.getBuffered(o).length)return;var x=X.BufferHelper.bufferInfo(o,d,0),p=x.len>0,c=x.nextStart||0;if(!p&&!c)return;if(T){var s=x.len>P,a=!c||c-d>P&&!this.fragmentTracker.getPartialFragment(d);if(s||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var v,g=Math.max(c,x.start||0)-d,E=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,_=E==null||((v=E.details)===null||v===void 0)?void 0:v.live,H=_?E.details.targetduration*2:P;if(g>0&&g<=H){this._trySkipBufferHole(null);return}}var V=self.performance.now();if(u===null){this.stalled=V;return}var Z=V-u;!T&&Z>=U&&this._reportStall(x.len);var G=X.BufferHelper.bufferInfo(o,d,h.maxBufferHole);this._tryFixBufferStall(G,Z)},L._tryFixBufferStall=function(S,h){var o=this.config,u=this.fragmentTracker,d=this.media,T=d.currentTime,y=u.getPartialFragment(T);if(y){var f=this._trySkipBufferHole(y);if(f)return}S.len>o.maxBufferHole&&h>o.highBufferWatchdogPeriod*1e3&&(z.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},L._reportStall=function(S){var h=this.hls,o=this.media,u=this.stallReported;u||(this.stallReported=!0,z.logger.warn("Playback stalling at @"+o.currentTime+" due to low buffer (buffer="+S+")"),h.trigger(I.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:S}))},L._trySkipBufferHole=function(S){for(var h=this.config,o=this.hls,u=this.media,d=u.currentTime,T=0,y=X.BufferHelper.getBuffered(u),f=0;f<y.length;f++){var k=y.start(f);if(d+h.maxBufferHole>=T&&d<k){var x=Math.max(k+b,u.currentTime+M);return z.logger.warn("skipping hole, adjusting currentTime from "+d+" to "+x),this.moved=!0,this.stalled=null,u.currentTime=x,S&&o.trigger(I.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+d+" to "+x,frag:S}),x}T=y.end(f)}return 0},L._tryNudgeBuffer=function(){var S=this.config,h=this.hls,o=this.media,u=o.currentTime,d=(this.nudgeRetry||0)+1;if(this.nudgeRetry=d,d<S.nudgeMaxRetry){var T=u+d*S.nudgeOffset;z.logger.warn("Nudging 'currentTime' from "+u+" to "+T),o.currentTime=T,h.trigger(I.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else z.logger.error("Playhead still not moving while enough data buffered @"+u+" after "+S.nudgeMaxRetry+" nudges"),h.trigger(I.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},R}()},"./src/controller/id3-track-controller.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/events.ts"),N=D("./src/utils/texttrack-utils.ts"),I=D("./src/demux/id3.ts"),z=.25,U=function(){function P(b){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=b,this._registerListeners()}var M=P.prototype;return M.destroy=function(){this._unregisterListeners()},M._registerListeners=function(){var A=this.hls;A.on(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),A.on(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),A.on(X.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),A.on(X.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},M._unregisterListeners=function(){var A=this.hls;A.off(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),A.off(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),A.off(X.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),A.off(X.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},M.onMediaAttached=function(A,R){this.media=R.media},M.onMediaDetaching=function(){if(!this.id3Track)return;Object(N.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},M.getID3Track=function(A){if(!this.media)return;for(var R=0;R<A.length;R++){var L=A[R];if(L.kind==="metadata"&&L.label==="id3")return Object(N.sendAddTrackEvent)(L,this.media),L}return this.media.addTextTrack("metadata","id3")},M.onFragParsingMetadata=function(A,R){if(!this.media)return;var L=R.frag,w=R.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var S=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,h=0;h<w.length;h++){var o=I.getID3Frames(w[h].data);if(o){var u=w[h].pts,d=h<w.length-1?w[h+1].pts:L.end,T=d-u;T<=0&&(d=u+z);for(var y=0;y<o.length;y++){var f=o[y];if(!I.isTimeStampFrame(f)){var k=new S(u,d,"");k.value=f,this.id3Track.addCue(k)}}}}},M.onBufferFlushing=function(A,R){var L=R.startOffset,w=R.endOffset,S=R.type;if(!S||S==="audio"){var h=this.id3Track;h&&Object(N.removeCuesInRange)(h,L,w)}},P}();$.default=U},"./src/controller/latency-controller.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return P});var X=D("./src/errors.ts"),N=D("./src/events.ts"),I=D("./src/utils/logger.ts");function z(M,b){for(var A=0;A<b.length;A++){var R=b[A];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(M,R.key,R)}}function U(M,b,A){return b&&z(M.prototype,b),A&&z(M,A),M}var P=function(){function M(A){var R=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return R.timeupdate()},this.hls=A,this.config=A.config,this.registerListeners()}var b=M.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(R,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(R,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(R,L){if(L.details!==X.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,I.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},b.timeupdate=function(){var R=this.media,L=this.levelDetails;if(!R||!L)return;this.currentTime=R.currentTime;var w=this.computeLatency();if(w===null)return;this._latency=w;var S=this.config,h=S.lowLatencyMode,o=S.maxLiveSyncPlaybackRate;if(!h||o===1)return;var u=this.targetLatency;if(u===null)return;var d=w-u,T=Math.min(this.maxLatency,u+L.targetduration),y=d<T;if(L.live&&y&&d>.05&&this.forwardBufferLength>1){var f=Math.min(2,Math.max(1,o)),k=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;R.playbackRate=Math.min(f,Math.max(1,k))}else R.playbackRate!==1&&R.playbackRate!==0&&(R.playbackRate=1)},b.estimateLiveEdge=function(){var R=this.levelDetails;return R===null?null:R.edge+R.age},b.computeLatency=function(){var R=this.estimateLiveEdge();return R===null?null:R-this.currentTime},U(M,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var R=this.config,L=this.levelDetails;return R.liveMaxLatencyDuration!==void 0?R.liveMaxLatencyDuration:L?R.liveMaxLatencyDurationCount*L.targetduration:0}},{key:"targetLatency",get:function(){var R=this.levelDetails;if(R===null)return null;var L=R.holdBack,w=R.partHoldBack,S=R.targetduration,h=this.config,o=h.liveSyncDuration,u=h.liveSyncDurationCount,d=h.lowLatencyMode,T=this.hls.userConfig,y=d&&w||L;(T.liveSyncDuration||T.liveSyncDurationCount||y===0)&&(y=o!==void 0?o:u*S);var f=S,k=1;return y+Math.min(this.stallCount*k,f)}},{key:"liveSyncPosition",get:function(){var R=this.estimateLiveEdge(),L=this.targetLatency,w=this.levelDetails;if(R===null||L===null||w===null)return null;var S=w.edge,h=R-L-this.edgeStalled,o=S-w.totalduration,u=S-(this.config.lowLatencyMode&&w.partTarget||w.targetduration);return Math.min(Math.max(o,h),u)}},{key:"drift",get:function(){var R=this.levelDetails;return R===null?1:R.drift}},{key:"edgeStalled",get:function(){var R=this.levelDetails;if(R===null)return 0;var L=(this.config.lowLatencyMode&&R.partTarget||R.targetduration)*3;return Math.max(R.age-L,0)}},{key:"forwardBufferLength",get:function(){var R=this.media,L=this.levelDetails;if(!R||!L)return 0;var w=R.buffered.length;return w?R.buffered.end(w-1):L.edge-this.currentTime}}]),M}()},"./src/controller/level-controller.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return h});var X=D("./src/types/level.ts"),N=D("./src/events.ts"),I=D("./src/errors.ts"),z=D("./src/utils/codecs.ts"),U=D("./src/controller/level-helper.ts"),P=D("./src/controller/base-playlist-controller.ts"),M=D("./src/types/loader.ts");function b(){return b=Object.assign||function(o){for(var u=1;u<arguments.length;u++){var d=arguments[u];for(var T in d)Object.prototype.hasOwnProperty.call(d,T)&&(o[T]=d[T])}return o},b.apply(this,arguments)}function A(o,u){for(var d=0;d<u.length;d++){var T=u[d];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(o,T.key,T)}}function R(o,u,d){return u&&A(o.prototype,u),d&&A(o,d),o}function L(o,u){o.prototype=Object.create(u.prototype),o.prototype.constructor=o,w(o,u)}function w(o,u){return w=Object.setPrototypeOf||function(T,y){return T.__proto__=y,T},w(o,u)}var S=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),h=function(o){L(u,o);function u(T){var y;return y=o.call(this,T,"[level-controller]")||this,y._levels=[],y._firstLevel=-1,y._startLevel=void 0,y.currentLevelIndex=-1,y.manualLevelIndex=-1,y.onParsedComplete=void 0,y._registerListeners(),y}var d=u.prototype;return d._registerListeners=function(){var y=this.hls;y.on(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),y.on(N.Events.LEVEL_LOADED,this.onLevelLoaded,this),y.on(N.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),y.on(N.Events.FRAG_LOADED,this.onFragLoaded,this),y.on(N.Events.ERROR,this.onError,this)},d._unregisterListeners=function(){var y=this.hls;y.off(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),y.off(N.Events.LEVEL_LOADED,this.onLevelLoaded,this),y.off(N.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),y.off(N.Events.FRAG_LOADED,this.onFragLoaded,this),y.off(N.Events.ERROR,this.onError,this)},d.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,o.prototype.destroy.call(this)},d.startLoad=function(){var y=this._levels;y.forEach(function(f){f.loadError=0}),o.prototype.startLoad.call(this)},d.onManifestLoaded=function(y,f){var k=[],x=[],p=[],c,s={},a,v=!1,g=!1,E=!1;if(f.levels.forEach(function(Z){var G=Z.attrs;v=v||!!(Z.width&&Z.height),g=g||!!Z.videoCodec,E=E||!!Z.audioCodec,S&&Z.audioCodec&&Z.audioCodec.indexOf("mp4a.40.34")!==-1&&(Z.audioCodec=void 0);var j=Z.bitrate+"-"+Z.attrs.RESOLUTION+"-"+Z.attrs.CODECS;a=s[j],a?a.url.push(Z.url):(a=new X.Level(Z),s[j]=a,k.push(a)),G&&(G.AUDIO&&Object(U.addGroupId)(a,"audio",G.AUDIO),G.SUBTITLES&&Object(U.addGroupId)(a,"text",G.SUBTITLES))}),(v||g)&&E&&(k=k.filter(function(Z){var G=Z.videoCodec,j=Z.width,q=Z.height;return!!G||!!(j&&q)})),k=k.filter(function(Z){var G=Z.audioCodec,j=Z.videoCodec;return(!G||Object(z.isCodecSupportedInMp4)(G,"audio"))&&(!j||Object(z.isCodecSupportedInMp4)(j,"video"))}),f.audioTracks&&(x=f.audioTracks.filter(function(Z){return!Z.audioCodec||Object(z.isCodecSupportedInMp4)(Z.audioCodec,"audio")}),Object(U.assignTrackIdsByGroup)(x)),f.subtitles&&(p=f.subtitles,Object(U.assignTrackIdsByGroup)(p)),k.length>0){c=k[0].bitrate,k.sort(function(Z,G){return Z.bitrate-G.bitrate}),this._levels=k;for(var _=0;_<k.length;_++)if(k[_].bitrate===c){this._firstLevel=_,this.log("manifest loaded, "+k.length+" level(s) found, first bitrate: "+c);break}var H=E&&!g,V={levels:k,audioTracks:x,subtitleTracks:p,firstLevel:this._firstLevel,stats:f.stats,audio:E,video:g,altAudio:!H&&x.some(function(Z){return!!Z.url})};this.hls.trigger(N.Events.MANIFEST_PARSED,V),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(N.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:f.url,reason:"no level with compatible codecs found in manifest"})},d.onError=function(y,f){if(o.prototype.onError.call(this,y,f),f.fatal)return;var k=f.context,x=this._levels[this.currentLevelIndex];if(k&&(k.type===M.PlaylistContextType.AUDIO_TRACK&&x.audioGroupIds&&k.groupId===x.audioGroupIds[x.urlId]||k.type===M.PlaylistContextType.SUBTITLE_TRACK&&x.textGroupIds&&k.groupId===x.textGroupIds[x.urlId])){this.redundantFailover(this.currentLevelIndex);return}var p=!1,c=!0,s;switch(f.details){case I.ErrorDetails.FRAG_LOAD_ERROR:case I.ErrorDetails.FRAG_LOAD_TIMEOUT:case I.ErrorDetails.KEY_LOAD_ERROR:case I.ErrorDetails.KEY_LOAD_TIMEOUT:if(f.frag){var a=this._levels[f.frag.level];a?(a.fragmentError++,a.fragmentError>this.hls.config.fragLoadingMaxRetry&&(s=f.frag.level)):s=f.frag.level}break;case I.ErrorDetails.LEVEL_LOAD_ERROR:case I.ErrorDetails.LEVEL_LOAD_TIMEOUT:k&&(k.deliveryDirectives&&(c=!1),s=k.level),p=!0;break;case I.ErrorDetails.REMUX_ALLOC_ERROR:s=f.level,p=!0;break}s!==void 0&&this.recoverLevel(f,s,p,c)},d.recoverLevel=function(y,f,k,x){var p=y.details,c=this._levels[f];if(c.loadError++,k){var s=this.retryLoadingOrFail(y);if(s)y.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(x){var a=c.url.length;if(a>1&&c.loadError<a)y.levelRetry=!0,this.redundantFailover(f);else if(this.manualLevelIndex===-1){var v=f===0?this._levels.length-1:f-1;this.currentLevelIndex!==v&&this._levels[v].loadError===0&&(this.warn(p+": switch to "+v),y.levelRetry=!0,this.hls.nextAutoLevel=v)}}},d.redundantFailover=function(y){var f=this._levels[y],k=f.url.length;if(k>1){var x=(f.urlId+1)%k;this.warn("Switching to redundant URL-id "+x),this._levels.forEach(function(p){p.urlId=x}),this.level=y}},d.onFragLoaded=function(y,f){var k=f.frag;if(k!==void 0&&k.type===M.PlaylistLevelType.MAIN){var x=this._levels[k.level];x!==void 0&&(x.fragmentError=0,x.loadError=0)}},d.onLevelLoaded=function(y,f){var k,x=f.level,p=f.details,c=this._levels[x];if(!c){var s;this.warn("Invalid level index "+x),(s=f.deliveryDirectives)!==null&&s!==void 0&&s.skip&&(p.deltaUpdateFailed=!0);return}x===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0,this.retryCount=0),this.playlistLoaded(x,f,c.details)):(k=f.deliveryDirectives)!==null&&k!==void 0&&k.skip&&(p.deltaUpdateFailed=!0)},d.onAudioTrackSwitched=function(y,f){var k=this.hls.levels[this.currentLevelIndex];if(!k)return;if(k.audioGroupIds){for(var x=-1,p=this.hls.audioTracks[f.id].groupId,c=0;c<k.audioGroupIds.length;c++)if(k.audioGroupIds[c]===p){x=c;break}x!==k.urlId&&(k.urlId=x,this.startLoad())}},d.loadPlaylist=function(y){var f=this.currentLevelIndex,k=this._levels[f];if(this.canLoad&&k&&k.url.length>0){var x=k.urlId,p=k.url[x];if(y)try{p=y.addDirectives(p)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Attempt loading level index "+f+(y?" at sn "+y.msn+" part "+y.part:"")+" with URL-id "+x+" "+p),this.clearTimer(),this.hls.trigger(N.Events.LEVEL_LOADING,{url:p,level:f,id:x,deliveryDirectives:y||null})}},d.removeLevel=function(y,f){var k=function(c,s){return s!==f},x=this._levels.filter(function(p,c){return c!==y?!0:p.url.length>1&&f!==void 0?(p.url=p.url.filter(k),p.audioGroupIds&&(p.audioGroupIds=p.audioGroupIds.filter(k)),p.textGroupIds&&(p.textGroupIds=p.textGroupIds.filter(k)),p.urlId=0,!0):!1}).map(function(p,c){var s=p.details;return s!=null&&s.fragments&&s.fragments.forEach(function(a){a.level=c}),p});this._levels=x,this.hls.trigger(N.Events.LEVELS_UPDATED,{levels:x})},R(u,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(y){var f,k=this._levels;if(k.length===0)return;if(this.currentLevelIndex===y&&(f=k[y])!==null&&f!==void 0&&f.details)return;if(y<0||y>=k.length){var x=y<0;if(this.hls.trigger(N.Events.ERROR,{type:I.ErrorTypes.OTHER_ERROR,details:I.ErrorDetails.LEVEL_SWITCH_ERROR,level:y,fatal:x,reason:"invalid level idx"}),x)return;y=Math.min(y,k.length-1)}this.clearTimer();var p=this.currentLevelIndex,c=k[p],s=k[y];this.log("switching to level "+y+" from "+p),this.currentLevelIndex=y;var a=b({},s,{level:y,maxBitrate:s.maxBitrate,uri:s.uri,urlId:s.urlId});delete a._urlId,this.hls.trigger(N.Events.LEVEL_SWITCHING,a);var v=s.details;if(!v||v.live){var g=this.switchParams(s.uri,c==null?void 0:c.details);this.loadPlaylist(g)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(y){this.manualLevelIndex=y,this._startLevel===void 0&&(this._startLevel=y),y!==-1&&(this.level=y)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(y){this._firstLevel=y}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var y=this.hls.config.startLevel;return y!==void 0?y:this._firstLevel}else return this._startLevel},set:function(y){this._startLevel=y}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(y){this.level=y,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=y)}}]),u}(P.default)},"./src/controller/level-helper.ts":function(ne,$,D){"use strict";D.r($),D.d($,"addGroupId",function(){return I}),D.d($,"assignTrackIdsByGroup",function(){return z}),D.d($,"updatePTS",function(){return U}),D.d($,"updateFragPTSDTS",function(){return M}),D.d($,"mergeDetails",function(){return b}),D.d($,"mapPartIntersection",function(){return A}),D.d($,"mapFragmentIntersection",function(){return R}),D.d($,"adjustSliding",function(){return L}),D.d($,"addSliding",function(){return w}),D.d($,"computeReloadInterval",function(){return S}),D.d($,"getFragmentWithSN",function(){return h}),D.d($,"getPartWith",function(){return o});var X=D("./src/polyfills/number.ts"),N=D("./src/utils/logger.ts");function I(u,d,T){switch(d){case"audio":u.audioGroupIds||(u.audioGroupIds=[]),u.audioGroupIds.push(T);break;case"text":u.textGroupIds||(u.textGroupIds=[]),u.textGroupIds.push(T);break}}function z(u){var d={};u.forEach(function(T){var y=T.groupId||"";T.id=d[y]=d[y]||0,d[y]++})}function U(u,d,T){var y=u[d],f=u[T];P(y,f)}function P(u,d){var T=d.startPTS;if(Object(X.isFiniteNumber)(T)){var y=0,f;d.sn>u.sn?(y=T-u.start,f=u):(y=u.start-T,f=d),f.duration!==y&&(f.duration=y)}else if(d.sn>u.sn){var k=u.cc===d.cc;k&&u.minEndPTS?d.start=u.start+(u.minEndPTS-u.start):d.start=u.start+u.duration}else d.start=Math.max(u.start-d.duration,0)}function M(u,d,T,y,f,k){var x=y-T;x<=0&&(N.logger.warn("Fragment should have a positive duration",d),y=T+d.duration,k=f+d.duration);var p=T,c=y,s=d.startPTS,a=d.endPTS;if(Object(X.isFiniteNumber)(s)){var v=Math.abs(s-T);Object(X.isFiniteNumber)(d.deltaPTS)?d.deltaPTS=Math.max(v,d.deltaPTS):d.deltaPTS=v,p=Math.max(T,s),T=Math.min(T,s),f=Math.min(f,d.startDTS),c=Math.min(y,a),y=Math.max(y,a),k=Math.max(k,d.endDTS)}d.duration=y-T;var g=T-d.start;d.appendedPTS=y,d.start=d.startPTS=T,d.maxStartPTS=p,d.startDTS=f,d.endPTS=y,d.minEndPTS=c,d.endDTS=k;var E=d.sn;if(!u||E<u.startSN||E>u.endSN)return 0;var _,H=E-u.startSN,V=u.fragments;for(V[H]=d,_=H;_>0;_--)P(V[_],V[_-1]);for(_=H;_<V.length-1;_++)P(V[_],V[_+1]);return u.fragmentHint&&P(V[V.length-1],u.fragmentHint),u.PTSKnown=u.alignedSliding=!0,g}function b(u,d){for(var T=null,y=u.fragments,f=y.length-1;f>=0;f--){var k=y[f].initSegment;if(k){T=k;break}}u.fragmentHint&&delete u.fragmentHint.endPTS;var x=0,p;if(R(u,d,function(_,H){_.relurl&&(x=_.cc-H.cc),Object(X.isFiniteNumber)(_.startPTS)&&Object(X.isFiniteNumber)(_.endPTS)&&(H.start=H.startPTS=_.startPTS,H.startDTS=_.startDTS,H.appendedPTS=_.appendedPTS,H.maxStartPTS=_.maxStartPTS,H.endPTS=_.endPTS,H.endDTS=_.endDTS,H.minEndPTS=_.minEndPTS,H.duration=_.endPTS-_.startPTS,H.duration&&(p=H),d.PTSKnown=d.alignedSliding=!0),H.elementaryStreams=_.elementaryStreams,H.loader=_.loader,H.stats=_.stats,H.urlId=_.urlId,_.initSegment&&(H.initSegment=_.initSegment,T=_.initSegment)}),T){var c=d.fragmentHint?d.fragments.concat(d.fragmentHint):d.fragments;c.forEach(function(_){var H;(!_.initSegment||_.initSegment.relurl===((H=T)===null||H===void 0?void 0:H.relurl))&&(_.initSegment=T)})}if(d.skippedSegments&&(d.deltaUpdateFailed=d.fragments.some(function(_){return!_}),d.deltaUpdateFailed)){N.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var s=d.skippedSegments;s--;)d.fragments.shift();d.startSN=d.fragments[0].sn,d.startCC=d.fragments[0].cc}var a=d.fragments;if(x){N.logger.warn("discontinuity sliding from playlist, take drift into account");for(var v=0;v<a.length;v++)a[v].cc+=x}d.skippedSegments&&(d.startCC=d.fragments[0].cc),A(u.partList,d.partList,function(_,H){H.elementaryStreams=_.elementaryStreams,H.stats=_.stats}),p?M(d,p,p.startPTS,p.endPTS,p.startDTS,p.endDTS):L(u,d),a.length&&(d.totalduration=d.edge-a[0].start),d.driftStartTime=u.driftStartTime,d.driftStart=u.driftStart;var g=d.advancedDateTime;if(d.advanced&&g){var E=d.edge;d.driftStart||(d.driftStartTime=g,d.driftStart=E),d.driftEndTime=g,d.driftEnd=E}else d.driftEndTime=u.driftEndTime,d.driftEnd=u.driftEnd,d.advancedDateTime=u.advancedDateTime}function A(u,d,T){if(u&&d)for(var y=0,f=0,k=u.length;f<=k;f++){var x=u[f],p=d[f+y];x&&p&&x.index===p.index&&x.fragment.sn===p.fragment.sn?T(x,p):y--}}function R(u,d,T){for(var y=d.skippedSegments,f=Math.max(u.startSN,d.startSN)-d.startSN,k=(u.fragmentHint?1:0)+(y?d.endSN:Math.min(u.endSN,d.endSN))-d.startSN,x=d.startSN-u.startSN,p=d.fragmentHint?d.fragments.concat(d.fragmentHint):d.fragments,c=u.fragmentHint?u.fragments.concat(u.fragmentHint):u.fragments,s=f;s<=k;s++){var a=c[x+s],v=p[s];y&&!v&&s<y&&(v=d.fragments[s]=a),a&&v&&T(a,v)}}function L(u,d){var T=d.startSN+d.skippedSegments-u.startSN,y=u.fragments;if(T<0||T>=y.length)return;w(d,y[T].start)}function w(u,d){if(d){for(var T=u.fragments,y=u.skippedSegments;y<T.length;y++)T[y].start+=d;u.fragmentHint&&(u.fragmentHint.start+=d)}}function S(u,d){var T=1e3*u.levelTargetDuration,y=T/2,f=u.age,k=f>0&&f<T*3,x=d.loading.end-d.loading.start,p,c=u.availabilityDelay;if(u.updated===!1)if(k){var s=333*u.misses;p=Math.max(Math.min(y,x*2),s),u.availabilityDelay=(u.availabilityDelay||0)+p}else p=y;else k?(c=Math.min(c||T/2,f),u.availabilityDelay=c,p=c+T-f):p=T-x;return Math.round(p)}function h(u,d,T){if(!u||!u.details)return null;var y=u.details,f=y.fragments[d-y.startSN];return f||(f=y.fragmentHint,f&&f.sn===d?f:d<y.startSN&&T&&T.sn===d?T:null)}function o(u,d,T){if(!u||!u.details)return null;var y=u.details.partList;if(y)for(var f=y.length;f--;){var k=y[f];if(k.index===T&&k.fragment.sn===d)return k}return null}},"./src/controller/stream-controller.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return y});var X=D("./src/polyfills/number.ts"),N=D("./src/controller/base-stream-controller.ts"),I=D("./src/is-supported.ts"),z=D("./src/events.ts"),U=D("./src/utils/buffer-helper.ts"),P=D("./src/controller/fragment-tracker.ts"),M=D("./src/types/loader.ts"),b=D("./src/loader/fragment.ts"),A=D("./src/demux/transmuxer-interface.ts"),R=D("./src/types/transmuxer.ts"),L=D("./src/controller/gap-controller.ts"),w=D("./src/errors.ts"),S=D("./src/utils/logger.ts");function h(f,k){for(var x=0;x<k.length;x++){var p=k[x];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(f,p.key,p)}}function o(f,k,x){return k&&h(f.prototype,k),x&&h(f,x),f}function u(f,k){f.prototype=Object.create(k.prototype),f.prototype.constructor=f,d(f,k)}function d(f,k){return d=Object.setPrototypeOf||function(p,c){return p.__proto__=c,p},d(f,k)}var T=100,y=function(f){u(k,f);function k(p,c){var s;return s=f.call(this,p,c,"[stream-controller]")||this,s.audioCodecSwap=!1,s.gapController=null,s.level=-1,s._forceStartLoad=!1,s.altAudio=!1,s.audioOnly=!1,s.fragPlaying=null,s.onvplaying=null,s.onvseeked=null,s.fragLastKbps=0,s.stalled=!1,s.couldBacktrack=!1,s.audioCodecSwitch=!1,s.videoBuffer=null,s._registerListeners(),s}var x=k.prototype;return x._registerListeners=function(){var c=this.hls;c.on(z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(z.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(z.Events.MANIFEST_PARSED,this.onManifestParsed,this),c.on(z.Events.LEVEL_LOADING,this.onLevelLoading,this),c.on(z.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(z.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),c.on(z.Events.ERROR,this.onError,this),c.on(z.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.on(z.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),c.on(z.Events.BUFFER_CREATED,this.onBufferCreated,this),c.on(z.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.on(z.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),c.on(z.Events.FRAG_BUFFERED,this.onFragBuffered,this)},x._unregisterListeners=function(){var c=this.hls;c.off(z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(z.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(z.Events.MANIFEST_PARSED,this.onManifestParsed,this),c.off(z.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(z.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),c.off(z.Events.ERROR,this.onError,this),c.off(z.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.off(z.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),c.off(z.Events.BUFFER_CREATED,this.onBufferCreated,this),c.off(z.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.off(z.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),c.off(z.Events.FRAG_BUFFERED,this.onFragBuffered,this)},x.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},x.startLoad=function(c){if(this.levels){var s=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(T),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var v=a.startLevel;v===-1&&(a.config.testBandwidth?(v=0,this.bitrateTest=!0):v=a.nextAutoLevel),this.level=a.nextLoadLevel=v,this.loadedmetadata=!1}s>0&&c===-1&&(this.log("Override startPosition with lastCurrentTime @"+s.toFixed(3)),c=s),this.state=N.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=c,this.tick()}else this._forceStartLoad=!0,this.state=N.State.STOPPED},x.stopLoad=function(){this._forceStartLoad=!1,f.prototype.stopLoad.call(this)},x.doTick=function(){switch(this.state){case N.State.IDLE:this.doTickIdle();break;case N.State.WAITING_LEVEL:{var c,s=this.levels,a=this.level,v=s==null||((c=s[a])===null||c===void 0)?void 0:c.details;if(v&&(!v.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(v))break;this.state=N.State.IDLE;break}break}case N.State.FRAG_LOADING_WAITING_RETRY:{var g,E=self.performance.now(),_=this.retryDate;(!_||E>=_||(g=this.media)!==null&&g!==void 0&&g.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=N.State.IDLE)}break;default:break}this.onTickEnd()},x.onTickEnd=function(){f.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},x.doTickIdle=function(){var c,s,a=this.hls,v=this.levelLastLoaded,g=this.levels,E=this.media,_=a.config,H=a.nextLoadLevel;if(v===null||!E&&(this.startFragRequested||!_.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!g||!g[H])return;var V=g[H];this.level=a.nextLoadLevel=H;var Z=V.details;if(!Z||this.state===N.State.WAITING_LEVEL||Z.live&&this.levelLastLoaded!==H){this.state=N.State.WAITING_LEVEL;return}var G=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:E,M.PlaylistLevelType.MAIN);if(G===null)return;var j=G.len,q=this.getMaxBufferLength(V.maxBitrate);if(j>=q)return;if(this._streamEnded(G,Z)){var ie={};this.altAudio&&(ie.type="video"),this.hls.trigger(z.Events.BUFFER_EOS,ie),this.state=N.State.ENDED;return}var ce=G.end,ve=this.getNextFragment(ce,Z);if(this.couldBacktrack&&!this.fragPrevious&&ve&&ve.sn!=="initSegment"){var ke=ve.sn-Z.startSN;ke>1&&(ve=Z.fragments[ke-1],this.fragmentTracker.removeFragment(ve))}if(ve&&this.fragmentTracker.getState(ve)===P.FragmentState.OK&&this.nextLoadPosition>ce){var xe=this.audioOnly&&!this.altAudio?b.ElementaryStreamTypes.AUDIO:b.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(E,xe,M.PlaylistLevelType.MAIN),ve=this.getNextFragment(this.nextLoadPosition,Z)}if(!ve)return;ve.initSegment&&!ve.initSegment.data&&!this.bitrateTest&&(ve=ve.initSegment),((c=ve.decryptdata)===null||c===void 0?void 0:c.keyFormat)==="identity"&&!((s=ve.decryptdata)!==null&&s!==void 0&&s.key)?this.loadKey(ve,Z):this.loadFragment(ve,Z,ce)},x.loadFragment=function(c,s,a){var v,g=this.fragmentTracker.getState(c);if(this.fragCurrent=c,g===P.FragmentState.BACKTRACKED){var E=this.fragmentTracker.getBacktrackData(c);if(E){this._handleFragmentLoadProgress(E),this._handleFragmentLoadComplete(E);return}else g=P.FragmentState.NOT_LOADED}g===P.FragmentState.NOT_LOADED||g===P.FragmentState.PARTIAL?c.sn==="initSegment"?this._loadInitSegment(c):this.bitrateTest?(c.bitrateTest=!0,this.log("Fragment "+c.sn+" of level "+c.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(c)):(this.startFragRequested=!0,f.prototype.loadFragment.call(this,c,s,a)):g===P.FragmentState.APPENDING?this.reduceMaxBufferLength(c.duration)&&this.fragmentTracker.removeFragment(c):((v=this.media)===null||v===void 0?void 0:v.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},x.getAppendedFrag=function(c){var s=this.fragmentTracker.getAppendedFrag(c,M.PlaylistLevelType.MAIN);return s&&"fragment"in s?s.fragment:s},x.getBufferedFrag=function(c){return this.fragmentTracker.getBufferedFrag(c,M.PlaylistLevelType.MAIN)},x.followingBufferedFrag=function(c){return c?this.getBufferedFrag(c.end+.5):null},x.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},x.nextLevelSwitch=function(){var c=this.levels,s=this.media;if(s!=null&&s.readyState){var a,v=this.getAppendedFrag(s.currentTime);if(v&&v.start>1&&this.flushMainBuffer(0,v.start-1),!s.paused&&c){var g=this.hls.nextLoadLevel,E=c[g],_=this.fragLastKbps;_&&this.fragCurrent?a=this.fragCurrent.duration*E.maxBitrate/(1e3*_)+1:a=0}else a=0;var H=this.getBufferedFrag(s.currentTime+a);if(H){var V=this.followingBufferedFrag(H);if(V){this.abortCurrentFrag();var Z=V.maxStartPTS?V.maxStartPTS:V.start,G=V.duration,j=Math.max(H.end,Z+Math.min(Math.max(G-this.config.maxFragLookUpTolerance,G*.5),G*.75));this.flushMainBuffer(j,Number.POSITIVE_INFINITY)}}}},x.abortCurrentFrag=function(){var c=this.fragCurrent;this.fragCurrent=null,c!=null&&c.loader&&c.loader.abort(),this.state===N.State.KEY_LOADING&&(this.state=N.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},x.flushMainBuffer=function(c,s){f.prototype.flushMainBuffer.call(this,c,s,this.altAudio?"video":null)},x.onMediaAttached=function(c,s){f.prototype.onMediaAttached.call(this,c,s);var a=s.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),a.addEventListener("playing",this.onvplaying),a.addEventListener("seeked",this.onvseeked),this.gapController=new L.default(this.config,a,this.fragmentTracker,this.hls)},x.onMediaDetaching=function(){var c=this.media;c&&(c.removeEventListener("playing",this.onvplaying),c.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),f.prototype.onMediaDetaching.call(this)},x.onMediaPlaying=function(){this.tick()},x.onMediaSeeked=function(){var c=this.media,s=c?c.currentTime:null;Object(X.isFiniteNumber)(s)&&this.log("Media seeked to "+s.toFixed(3)),this.tick()},x.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(z.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},x.onManifestParsed=function(c,s){var a=!1,v=!1,g;s.levels.forEach(function(E){g=E.audioCodec,g&&(g.indexOf("mp4a.40.2")!==-1&&(a=!0),g.indexOf("mp4a.40.5")!==-1&&(v=!0))}),this.audioCodecSwitch=a&&v&&!Object(I.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=s.levels,this.startFragRequested=!1},x.onLevelLoading=function(c,s){var a=this.levels;if(!a||this.state!==N.State.IDLE)return;var v=a[s.level];(!v.details||v.details.live&&this.levelLastLoaded!==s.level||this.waitForCdnTuneIn(v.details))&&(this.state=N.State.WAITING_LEVEL)},x.onLevelLoaded=function(c,s){var a,v=this.levels,g=s.level,E=s.details,_=E.totalduration;if(!v){this.warn("Levels were reset while loading level "+g);return}this.log("Level "+g+" loaded ["+E.startSN+","+E.endSN+"], cc ["+E.startCC+", "+E.endCC+"] duration:"+_);var H=this.fragCurrent;H&&(this.state===N.State.FRAG_LOADING||this.state===N.State.FRAG_LOADING_WAITING_RETRY)&&(H.level!==s.level&&H.loader&&(this.state=N.State.IDLE,H.loader.abort()));var V=v[g],Z=0;if(E.live||(a=V.details)!==null&&a!==void 0&&a.live){if(E.fragments[0]||(E.deltaUpdateFailed=!0),E.deltaUpdateFailed)return;Z=this.alignPlaylists(E,V.details)}if(V.details=E,this.levelLastLoaded=g,this.hls.trigger(z.Events.LEVEL_UPDATED,{details:E,level:g}),this.state===N.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(E))return;this.state=N.State.IDLE}this.startFragRequested?E.live&&this.synchronizeToLiveEdge(E):this.setStartPosition(E,Z),this.tick()},x._handleFragmentLoadProgress=function(c){var s,a=c.frag,v=c.part,g=c.payload,E=this.levels;if(!E){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var _=E[a.level],H=_.details;if(!H){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var V=_.videoCodec,Z=H.PTSKnown||!H.live,G=(s=a.initSegment)===null||s===void 0?void 0:s.data,j=this._getAudioCodec(_),q=this.transmuxer=this.transmuxer||new A.default(this.hls,M.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),ie=v?v.index:-1,ce=ie!==-1,ve=new R.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,g.byteLength,ie,ce),ke=this.initPTS[a.cc];q.push(g,G,j,V,a,v,H.totalduration,Z,ve,ke)},x.onAudioTrackSwitching=function(c,s){var a=this.altAudio,v=!!s.url,g=s.id;if(!v){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var E=this.fragCurrent;E!=null&&E.loader&&(this.log("Switching to main audio track, cancel main fragment load"),E.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var _=this.hls;a&&_.trigger(z.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),_.trigger(z.Events.AUDIO_TRACK_SWITCHED,{id:g})}},x.onAudioTrackSwitched=function(c,s){var a=s.id,v=!!this.hls.audioTracks[a].url;if(v){var g=this.videoBuffer;g&&this.mediaBuffer!==g&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=g)}this.altAudio=v,this.tick()},x.onBufferCreated=function(c,s){var a=s.tracks,v,g,E=!1;for(var _ in a){var H=a[_];if(H.id==="main"){if(g=_,v=H,_==="video"){var V=a[_];V&&(this.videoBuffer=V.buffer)}}else E=!0}E&&v?(this.log("Alternate track found, use "+g+".buffered to schedule main fragment loading"),this.mediaBuffer=v.buffer):this.mediaBuffer=this.media},x.onFragBuffered=function(c,s){var a=s.frag,v=s.part;if(a&&a.type!==M.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(v?" p: "+v.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===N.State.PARSED&&(this.state=N.State.IDLE);return}var g=v?v.stats:a.stats;this.fragLastKbps=Math.round(8*g.total/(g.buffering.end-g.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,v)},x.onError=function(c,s){switch(s.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(M.PlaylistLevelType.MAIN,s);break;case w.ErrorDetails.LEVEL_LOAD_ERROR:case w.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==N.State.ERROR&&(s.fatal?(this.warn(""+s.details),this.state=N.State.ERROR):!s.levelRetry&&this.state===N.State.WAITING_LEVEL&&(this.state=N.State.IDLE));break;case w.ErrorDetails.BUFFER_FULL_ERROR:if(s.parent==="main"&&(this.state===N.State.PARSING||this.state===N.State.PARSED)){var a=!0,v=this.getFwdBufferInfo(this.media,M.PlaylistLevelType.MAIN);v&&v.len>.5&&(a=!this.reduceMaxBufferLength(v.len)),a&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},x.checkBuffer=function(){var c=this.media,s=this.gapController;if(!c||!s||!c.readyState)return;var a=U.BufferHelper.getBuffered(c);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):s.poll(this.lastCurrentTime),this.lastCurrentTime=c.currentTime},x.onFragLoadEmergencyAborted=function(){this.state=N.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},x.onBufferFlushed=function(c,s){var a=s.type;if(a!==b.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var v=(a===b.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(v,a,M.PlaylistLevelType.MAIN)}},x.onLevelsUpdated=function(c,s){this.levels=s.levels},x.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},x.seekToStartPos=function(){var c=this.media,s=c.currentTime,a=this.startPosition;if(a>=0&&s<a){if(c.seeking){S.logger.log("could not seek to "+a+", already seeking at "+s);return}var v=U.BufferHelper.getBuffered(c),g=v.length?v.start(0):0,E=g-a;E>0&&(E<this.config.maxBufferHole||E<this.config.maxFragLookUpTolerance)&&(S.logger.log("adjusting start position by "+E+" to match buffer start"),a+=E,this.startPosition=a),this.log("seek to target start position "+a+" from current time "+s),c.currentTime=a}},x._getAudioCodec=function(c){var s=this.config.defaultAudioCodec||c.audioCodec;return this.audioCodecSwap&&s&&(this.log("Swapping audio codec"),s.indexOf("mp4a.40.5")!==-1?s="mp4a.40.2":s="mp4a.40.5"),s},x._loadBitrateTestFrag=function(c){var s=this;this._doFragLoad(c).then(function(a){var v=s.hls;if(!a||v.nextLoadLevel||s.fragContextChanged(c))return;s.fragLoadError=0,s.state=N.State.IDLE,s.startFragRequested=!1,s.bitrateTest=!1;var g=c.stats;g.parsing.start=g.parsing.end=g.buffering.start=g.buffering.end=self.performance.now(),v.trigger(z.Events.FRAG_LOADED,a)})},x._handleTransmuxComplete=function(c){var s,a="main",v=this.hls,g=c.remuxResult,E=c.chunkMeta,_=this.getCurrentContext(E);if(!_){this.warn("The loading context changed while buffering fragment "+E.sn+" of level "+E.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(E.level);return}var H=_.frag,V=_.part,Z=_.level,G=g.video,j=g.text,q=g.id3,ie=g.initSegment,ce=this.altAudio?void 0:g.audio;if(this.fragContextChanged(H))return;if(this.state=N.State.PARSING,ie){ie.tracks&&(this._bufferInitSegment(Z,ie.tracks,H,E),v.trigger(z.Events.FRAG_PARSING_INIT_SEGMENT,{frag:H,id:a,tracks:ie.tracks}));var ve=ie.initPTS,ke=ie.timescale;Object(X.isFiniteNumber)(ve)&&(this.initPTS[H.cc]=ve,v.trigger(z.Events.INIT_PTS_FOUND,{frag:H,id:a,initPTS:ve,timescale:ke}))}if(G&&g.independent!==!1){if(Z.details){var xe=G.startPTS,Ce=G.endPTS,Te=G.startDTS,Ee=G.endDTS;if(V)V.elementaryStreams[G.type]={startPTS:xe,endPTS:Ce,startDTS:Te,endDTS:Ee};else if(G.firstKeyFrame&&G.independent&&(this.couldBacktrack=!0),G.dropped&&G.independent){var pe=this.getLoadPosition()+this.config.maxBufferHole;if(pe<xe){this.backtrack(H);return}H.setElementaryStreamInfo(G.type,H.start,Ce,H.start,Ee,!0)}H.setElementaryStreamInfo(G.type,xe,Ce,Te,Ee),this.bufferFragmentData(G,H,V,E)}}else if(g.independent===!1){this.backtrack(H);return}if(ce){var se=ce.startPTS,Le=ce.endPTS,Xe=ce.startDTS,Ge=ce.endDTS;V&&(V.elementaryStreams[b.ElementaryStreamTypes.AUDIO]={startPTS:se,endPTS:Le,startDTS:Xe,endDTS:Ge}),H.setElementaryStreamInfo(b.ElementaryStreamTypes.AUDIO,se,Le,Xe,Ge),this.bufferFragmentData(ce,H,V,E)}if(q!=null&&(s=q.samples)!==null&&s!==void 0&&s.length){var Ke={frag:H,id:a,samples:q.samples};v.trigger(z.Events.FRAG_PARSING_METADATA,Ke)}if(j){var Ve={frag:H,id:a,samples:j.samples};v.trigger(z.Events.FRAG_PARSING_USERDATA,Ve)}},x._bufferInitSegment=function(c,s,a,v){var g=this;if(this.state!==N.State.PARSING)return;this.audioOnly=!!s.audio&&!s.video,this.altAudio&&!this.audioOnly&&delete s.audio;var E=s.audio,_=s.video,H=s.audiovideo;if(E){var V=c.audioCodec,Z=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(V&&(V.indexOf("mp4a.40.5")!==-1?V="mp4a.40.2":V="mp4a.40.5"),E.metadata.channelCount!==1&&Z.indexOf("firefox")===-1&&(V="mp4a.40.5")),Z.indexOf("android")!==-1&&E.container!=="audio/mpeg"&&(V="mp4a.40.2",this.log("Android: force audio codec to "+V)),c.audioCodec&&c.audioCodec!==V&&this.log('Swapping manifest audio codec "'+c.audioCodec+'" for "'+V+'"'),E.levelCodec=V,E.id="main",this.log("Init audio buffer, container:"+E.container+", codecs[selected/level/parsed]=["+(V||"")+"/"+(c.audioCodec||"")+"/"+E.codec+"]")}_&&(_.levelCodec=c.videoCodec,_.id="main",this.log("Init video buffer, container:"+_.container+", codecs[level/parsed]=["+(c.videoCodec||"")+"/"+_.codec+"]")),H&&this.log("Init audiovideo buffer, container:"+H.container+", codecs[level/parsed]=["+(c.attrs.CODECS||"")+"/"+H.codec+"]"),this.hls.trigger(z.Events.BUFFER_CODECS,s),Object.keys(s).forEach(function(G){var j=s[G],q=j.initSegment;q!=null&&q.byteLength&&g.hls.trigger(z.Events.BUFFER_APPENDING,{type:G,data:q,frag:a,part:null,chunkMeta:v,parent:a.type})}),this.tick()},x.backtrack=function(c){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(c);var s=this.fragmentTracker.backtrack(c);this.fragPrevious=null,this.nextLoadPosition=c.start,s?this.resetFragmentLoading(c):this.state=N.State.BACKTRACKING},x.checkFragmentChanged=function(){var c=this.media,s=null;if(c&&c.readyState>1&&c.seeking===!1){var a=c.currentTime;if(U.BufferHelper.isBuffered(c,a)?s=this.getAppendedFrag(a):U.BufferHelper.isBuffered(c,a+.1)&&(s=this.getAppendedFrag(a+.1)),s){var v=this.fragPlaying,g=s.level;(!v||s.sn!==v.sn||v.level!==g||s.urlId!==v.urlId)&&(this.hls.trigger(z.Events.FRAG_CHANGED,{frag:s}),(!v||v.level!==g)&&this.hls.trigger(z.Events.LEVEL_SWITCHED,{level:g}),this.fragPlaying=s)}}},o(k,[{key:"nextLevel",get:function(){var c=this.nextBufferedFrag;return c?c.level:-1}},{key:"currentLevel",get:function(){var c=this.media;if(c){var s=this.getAppendedFrag(c.currentTime);if(s)return s.level}return-1}},{key:"nextBufferedFrag",get:function(){var c=this.media;if(c){var s=this.getAppendedFrag(c.currentTime);return this.followingBufferedFrag(s)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),k}(N.default)},"./src/controller/subtitle-stream-controller.ts":function(ne,$,D){"use strict";D.r($),D.d($,"SubtitleStreamController",function(){return u});var X=D("./src/events.ts"),N=D("./src/utils/logger.ts"),I=D("./src/utils/buffer-helper.ts"),z=D("./src/controller/fragment-finders.ts"),U=D("./src/utils/discontinuities.ts"),P=D("./src/controller/level-helper.ts"),M=D("./src/controller/fragment-tracker.ts"),b=D("./src/controller/base-stream-controller.ts"),A=D("./src/types/loader.ts"),R=D("./src/types/level.ts");function L(d,T){for(var y=0;y<T.length;y++){var f=T[y];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}function w(d,T,y){return T&&L(d.prototype,T),y&&L(d,y),d}function S(d,T){d.prototype=Object.create(T.prototype),d.prototype.constructor=d,h(d,T)}function h(d,T){return h=Object.setPrototypeOf||function(f,k){return f.__proto__=k,f},h(d,T)}var o=500,u=function(d){S(T,d);function T(f,k){var x;return x=d.call(this,f,k,"[subtitle-stream-controller]")||this,x.levels=[],x.currentTrackId=-1,x.tracksBuffered=[],x.mainDetails=null,x._registerListeners(),x}var y=T.prototype;return y.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},y._registerListeners=function(){var k=this.hls;k.on(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),k.on(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),k.on(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),k.on(X.Events.LEVEL_LOADED,this.onLevelLoaded,this),k.on(X.Events.ERROR,this.onError,this),k.on(X.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),k.on(X.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),k.on(X.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),k.on(X.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),k.on(X.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},y._unregisterListeners=function(){var k=this.hls;k.off(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),k.off(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),k.off(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),k.off(X.Events.LEVEL_LOADED,this.onLevelLoaded,this),k.off(X.Events.ERROR,this.onError,this),k.off(X.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),k.off(X.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),k.off(X.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),k.off(X.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),k.off(X.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},y.startLoad=function(){this.stopLoad(),this.state=b.State.IDLE,this.setInterval(o),this.tick()},y.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},y.onLevelLoaded=function(k,x){this.mainDetails=x.details},y.onSubtitleFragProcessed=function(k,x){var p=x.frag,c=x.success;if(this.fragPrevious=p,this.state=b.State.IDLE,!c)return;var s=this.tracksBuffered[this.currentTrackId];if(!s)return;for(var a,v=p.start,g=0;g<s.length;g++)if(v>=s[g].start&&v<=s[g].end){a=s[g];break}var E=p.start+p.duration;a?a.end=E:(a={start:v,end:E},s.push(a)),this.fragmentTracker.fragBuffered(p)},y.onBufferFlushing=function(k,x){var p=x.startOffset,c=x.endOffset;if(p===0&&c!==Number.POSITIVE_INFINITY){var s=this.currentTrackId,a=this.levels;if(!a.length||!a[s]||!a[s].details)return;var v=a[s].details,g=v.targetduration,E=c-g;if(E<=0)return;x.endOffsetSubtitles=Math.max(0,E),this.tracksBuffered.forEach(function(_){for(var H=0;H<_.length;){if(_[H].end<=E){_.shift();continue}else if(_[H].start<E)_[H].start=E;else break;H++}}),this.fragmentTracker.removeFragmentsInRange(p,E,A.PlaylistLevelType.SUBTITLE)}},y.onError=function(k,x){var p,c=x.frag;if(!c||c.type!==A.PlaylistLevelType.SUBTITLE)return;(p=this.fragCurrent)!==null&&p!==void 0&&p.loader&&this.fragCurrent.loader.abort(),this.state=b.State.IDLE},y.onSubtitleTracksUpdated=function(k,x){var p=this,c=x.subtitleTracks;this.tracksBuffered=[],this.levels=c.map(function(s){return new R.Level(s)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(s){p.tracksBuffered[s.id]=[]}),this.mediaBuffer=null},y.onSubtitleTrackSwitch=function(k,x){if(this.currentTrackId=x.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var p=this.levels[this.currentTrackId];p!=null&&p.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,p&&this.setInterval(o)},y.onSubtitleTrackLoaded=function(k,x){var p,c=x.details,s=x.id,a=this.currentTrackId,v=this.levels;if(!v.length)return;var g=v[a];if(s>=v.length||s!==a||!g)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,c.live||(p=g.details)!==null&&p!==void 0&&p.live){var E=this.mainDetails;if(c.deltaUpdateFailed||!E)return;var _=E.fragments[0];if(!g.details)c.hasProgramDateTime&&E.hasProgramDateTime?Object(U.alignMediaPlaylistByPDT)(c,E):_&&Object(P.addSliding)(c,_.start);else{var H=this.alignPlaylists(c,g.details);H===0&&_&&Object(P.addSliding)(c,_.start)}}if(g.details=c,this.levelLastLoaded=s,this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===b.State.IDLE){var V=Object(z.findFragmentByPTS)(null,c.fragments,this.media.currentTime,0);V||(this.warn("Subtitle playlist not aligned with playback"),g.details=void 0)}},y._handleFragmentLoadComplete=function(k){var x=k.frag,p=k.payload,c=x.decryptdata,s=this.hls;if(this.fragContextChanged(x))return;if(p&&p.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(p),c.key.buffer,c.iv.buffer).then(function(v){var g=performance.now();s.trigger(X.Events.FRAG_DECRYPTED,{frag:x,payload:v,stats:{tstart:a,tdecrypt:g}})})}},y.doTick=function(){if(!this.media){this.state=b.State.IDLE;return}if(this.state===b.State.IDLE){var k,x=this.currentTrackId,p=this.levels;if(!p.length||!p[x]||!p[x].details)return;var c=p[x].details,s=c.targetduration,a=this.config,v=this.media,g=I.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,v.currentTime-s,a.maxBufferHole),E=g.end,_=g.len,H=this.getMaxBufferLength()+s;if(_>H)return;console.assert(c,"Subtitle track details are defined on idle subtitle stream controller tick");var V=c.fragments,Z=V.length,G=c.edge,j,q=this.fragPrevious;if(E<G){var ie=a.maxFragLookUpTolerance;q&&c.hasProgramDateTime&&(j=Object(z.findFragmentByPDT)(V,q.endProgramDateTime,ie)),j||(j=Object(z.findFragmentByPTS)(q,V,E,ie),!j&&q&&q.start<V[0].start&&(j=V[0]))}else j=V[Z-1];(k=j)!==null&&k!==void 0&&k.encrypted?(N.logger.log("Loading key for "+j.sn),this.state=b.State.KEY_LOADING,this.hls.trigger(X.Events.KEY_LOADING,{frag:j})):j&&this.fragmentTracker.getState(j)===M.FragmentState.NOT_LOADED&&this.loadFragment(j,c,E)}},y.loadFragment=function(k,x,p){this.fragCurrent=k,d.prototype.loadFragment.call(this,k,x,p)},w(T,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),T}(b.default)},"./src/controller/subtitle-track-controller.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/events.ts"),N=D("./src/utils/texttrack-utils.ts"),I=D("./src/controller/base-playlist-controller.ts"),z=D("./src/types/loader.ts");function U(L,w){for(var S=0;S<w.length;S++){var h=w[S];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(L,h.key,h)}}function P(L,w,S){return w&&U(L.prototype,w),S&&U(L,S),L}function M(L,w){L.prototype=Object.create(w.prototype),L.prototype.constructor=L,b(L,w)}function b(L,w){return b=Object.setPrototypeOf||function(h,o){return h.__proto__=o,h},b(L,w)}var A=function(L){M(w,L);function w(h){var o;return o=L.call(this,h,"[subtitle-track-controller]")||this,o.media=null,o.tracks=[],o.groupId=null,o.tracksInGroup=[],o.trackId=-1,o.selectDefaultTrack=!0,o.queuedDefaultTrack=-1,o.trackChangeListener=function(){return o.onTextTracksChanged()},o.asyncPollTrackChange=function(){return o.pollTrackChange(0)},o.useTextTrackPolling=!1,o.subtitlePollingInterval=-1,o.subtitleDisplay=!0,o.registerListeners(),o}var S=w.prototype;return S.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,L.prototype.destroy.call(this)},S.registerListeners=function(){var o=this.hls;o.on(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(X.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(X.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.on(X.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on(X.Events.ERROR,this.onError,this)},S.unregisterListeners=function(){var o=this.hls;o.off(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(X.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(X.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.off(X.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off(X.Events.ERROR,this.onError,this)},S.onMediaAttached=function(o,u){if(this.media=u.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)},S.pollTrackChange=function(o){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,o)},S.onMediaDetaching=function(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var o=R(this.media.textTracks);o.forEach(function(u){Object(N.clearCurrentCues)(u)}),this.subtitleTrack=-1,this.media=null},S.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},S.onManifestParsed=function(o,u){this.tracks=u.subtitleTracks},S.onSubtitleTrackLoaded=function(o,u){var d=u.id,T=u.details,y=this.trackId,f=this.tracksInGroup[y];if(!f){this.warn("Invalid subtitle track id "+d);return}var k=f.details;f.details=u.details,this.log("subtitle track "+d+" loaded ["+T.startSN+"-"+T.endSN+"]"),d===this.trackId&&(this.retryCount=0,this.playlistLoaded(d,u,k))},S.onLevelLoading=function(o,u){this.switchLevel(u.level)},S.onLevelSwitching=function(o,u){this.switchLevel(u.level)},S.switchLevel=function(o){var u=this.hls.levels[o];if(!(u!=null&&u.textGroupIds))return;var d=u.textGroupIds[u.urlId];if(this.groupId!==d){var T=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,y=this.tracks.filter(function(x){return!d||x.groupId===d});this.tracksInGroup=y;var f=this.findTrackId(T==null?void 0:T.name)||this.findTrackId();this.groupId=d;var k={subtitleTracks:y};this.log("Updating subtitle tracks, "+y.length+' track(s) found in "'+d+'" group-id'),this.hls.trigger(X.Events.SUBTITLE_TRACKS_UPDATED,k),f!==-1&&this.setSubtitleTrack(f,T)}},S.findTrackId=function(o){for(var u=this.tracksInGroup,d=0;d<u.length;d++){var T=u[d];if((!this.selectDefaultTrack||T.default)&&(!o||o===T.name))return T.id}return-1},S.onError=function(o,u){if(L.prototype.onError.call(this,o,u),u.fatal||!u.context)return;u.context.type===z.PlaylistContextType.SUBTITLE_TRACK&&u.context.id===this.trackId&&u.context.groupId===this.groupId&&this.retryLoadingOrFail(u)},S.loadPlaylist=function(o){var u=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(u)){var d=u.id,T=u.groupId,y=u.url;if(o)try{y=o.addDirectives(y)}catch(f){this.warn("Could not construct new URL with HLS Delivery Directives: "+f)}this.log("Loading subtitle playlist for id "+d),this.hls.trigger(X.Events.SUBTITLE_TRACK_LOADING,{url:y,id:d,groupId:T,deliveryDirectives:o||null})}},S.toggleTrackModes=function(o){var u=this,d=this.media,T=this.subtitleDisplay,y=this.trackId;if(!d)return;var f=R(d.textTracks),k=f.filter(function(c){return c.groupId===u.groupId});if(o===-1)[].slice.call(f).forEach(function(c){c.mode="disabled"});else{var x=k[y];x&&(x.mode="disabled")}var p=k[o];p&&(p.mode=T?"showing":"hidden")},S.setSubtitleTrack=function(o,u){var d,T=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=o;return}if(this.trackId!==o&&this.toggleTrackModes(o),this.trackId===o&&(o===-1||(d=T[o])!==null&&d!==void 0&&d.details)||o<-1||o>=T.length)return;this.clearTimer();var y=T[o];if(this.log("Switching to subtitle track "+o),this.trackId=o,y){var f=y.id,k=y.groupId,x=k===void 0?"":k,p=y.name,c=y.type,s=y.url;this.hls.trigger(X.Events.SUBTITLE_TRACK_SWITCH,{id:f,groupId:x,name:p,type:c,url:s});var a=this.switchParams(y.url,u==null?void 0:u.details);this.loadPlaylist(a)}else this.hls.trigger(X.Events.SUBTITLE_TRACK_SWITCH,{id:o})},S.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var o=-1,u=R(this.media.textTracks),d=0;d<u.length;d++)if(u[d].mode==="hidden")o=d;else if(u[d].mode==="showing"){o=d;break}this.subtitleTrack!==o&&(this.subtitleTrack=o)},P(w,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(o){this.selectDefaultTrack=!1;var u=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(o,u)}}]),w}(I.default);function R(L){for(var w=[],S=0;S<L.length;S++){var h=L[S];h.kind==="subtitles"&&h.label&&w.push(L[S])}return w}$.default=A},"./src/controller/timeline-controller.ts":function(ne,$,D){"use strict";D.r($),D.d($,"TimelineController",function(){return R});var X=D("./src/polyfills/number.ts"),N=D("./src/events.ts"),I=D("./src/utils/cea-608-parser.ts"),z=D("./src/utils/output-filter.ts"),U=D("./src/utils/webvtt-parser.ts"),P=D("./src/utils/texttrack-utils.ts"),M=D("./src/utils/imsc1-ttml-parser.ts"),b=D("./src/types/loader.ts"),A=D("./src/utils/logger.ts"),R=function(){function h(u){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=S(),this.captionsProperties=void 0,this.hls=u,this.config=u.config,this.Cues=u.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 d=new z.default(this,"textTrack1"),T=new z.default(this,"textTrack2"),y=new z.default(this,"textTrack3"),f=new z.default(this,"textTrack4");this.cea608Parser1=new I.default(1,d,T),this.cea608Parser2=new I.default(3,y,f)}u.on(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),u.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),u.on(N.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),u.on(N.Events.FRAG_LOADING,this.onFragLoading,this),u.on(N.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(N.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),u.on(N.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),u.on(N.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),u.on(N.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),u.on(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=h.prototype;return o.destroy=function(){var d=this.hls;d.off(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),d.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.off(N.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),d.off(N.Events.FRAG_LOADING,this.onFragLoading,this),d.off(N.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(N.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),d.off(N.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),d.off(N.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.off(N.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),d.off(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(d,T,y,f,k){for(var x=!1,p=k.length;p--;){var c=k[p],s=w(c[0],c[1],T,y);if(s>=0&&(c[0]=Math.min(c[0],T),c[1]=Math.max(c[1],y),x=!0,s/(y-T)>.5))return}if(x||k.push([T,y]),this.config.renderTextTracksNatively){var a=this.captionsTracks[d];this.Cues.newCue(a,T,y,f)}else{var v=this.Cues.newCue(null,T,y,f);this.hls.trigger(N.Events.CUES_PARSED,{type:"captions",cues:v,track:d})}},o.onInitPtsFound=function(d,T){var y=this,f=T.frag,k=T.id,x=T.initPTS,p=T.timescale,c=this.unparsedVttFrags;k==="main"&&(this.initPTS[f.cc]=x,this.timescale[f.cc]=p),c.length&&(this.unparsedVttFrags=[],c.forEach(function(s){y.onFragLoaded(N.Events.FRAG_LOADED,s)}))},o.getExistingTrack=function(d){var T=this.media;if(T)for(var y=0;y<T.textTracks.length;y++){var f=T.textTracks[y];if(f[d])return f}return null},o.createCaptionsTrack=function(d){this.config.renderTextTracksNatively?this.createNativeTrack(d):this.createNonNativeTrack(d)},o.createNativeTrack=function(d){if(this.captionsTracks[d])return;var T=this.captionsProperties,y=this.captionsTracks,f=this.media,k=T[d],x=k.label,p=k.languageCode,c=this.getExistingTrack(d);if(c)y[d]=c,Object(P.clearCurrentCues)(y[d]),Object(P.sendAddTrackEvent)(y[d],f);else{var s=this.createTextTrack("captions",x,p);s&&(s[d]=!0,y[d]=s)}},o.createNonNativeTrack=function(d){if(this.nonNativeCaptionsTracks[d])return;var T=this.captionsProperties[d];if(!T)return;var y=T.label,f={_id:d,label:y,kind:"captions",default:T.media?!!T.media.default:!1,closedCaptions:T.media};this.nonNativeCaptionsTracks[d]=f,this.hls.trigger(N.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[f]})},o.createTextTrack=function(d,T,y){var f=this.media;return f?f.addTextTrack(d,T,y):void 0},o.onMediaAttaching=function(d,T){this.media=T.media,this._cleanTracks()},o.onMediaDetaching=function(){var d=this.captionsTracks;Object.keys(d).forEach(function(T){Object(P.clearCurrentCues)(d[T]),delete d[T]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=S(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var d=this.media;if(!d)return;var T=d.textTracks;if(T)for(var y=0;y<T.length;y++)Object(P.clearCurrentCues)(T[y])},o.onSubtitleTracksUpdated=function(d,T){var y=this;this.textTracks=[];var f=T.subtitleTracks||[],k=f.some(function(s){return s.textCodec===M.IMSC1_CODEC});if(this.config.enableWebVTT||k&&this.config.enableIMSC1){var x=this.tracks&&f&&this.tracks.length===f.length;if(this.tracks=f||[],this.config.renderTextTracksNatively){var p=this.media?this.media.textTracks:[];this.tracks.forEach(function(s,a){var v;if(a<p.length){for(var g=null,E=0;E<p.length;E++)if(L(p[E],s)){g=p[E];break}g&&(v=g)}v?Object(P.clearCurrentCues)(v):(v=y.createTextTrack("subtitles",s.name,s.lang),v&&(v.mode="disabled")),v&&(v.groupId=s.groupId,y.textTracks.push(v))})}else if(!x&&this.tracks&&this.tracks.length){var c=this.tracks.map(function(s){return{label:s.name,kind:s.type.toLowerCase(),default:s.default,subtitleTrack:s}});this.hls.trigger(N.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:c})}}},o.onManifestLoaded=function(d,T){var y=this;this.config.enableCEA708Captions&&T.captions&&T.captions.forEach(function(f){var k=/(?:CC|SERVICE)([1-4])/.exec(f.instreamId);if(!k)return;var x="textTrack"+k[1],p=y.captionsProperties[x];if(!p)return;p.label=f.name,f.lang&&(p.languageCode=f.lang),p.media=f})},o.onFragLoading=function(d,T){var y=this.cea608Parser1,f=this.cea608Parser2,k=this.lastSn,x=this.lastPartIndex;if(!this.enabled||!(y&&f))return;if(T.frag.type===b.PlaylistLevelType.MAIN){var p,c,s=T.frag.sn,a=(p=T==null||((c=T.part)===null||c===void 0)?void 0:c.index)!=null?p:-1;s===k+1||s===k&&a===x+1||(y.reset(),f.reset()),this.lastSn=s,this.lastPartIndex=a}},o.onFragLoaded=function(d,T){var y=T.frag,f=T.payload,k=this.initPTS,x=this.unparsedVttFrags;if(y.type===b.PlaylistLevelType.SUBTITLE)if(f.byteLength){if(!Object(X.isFiniteNumber)(k[y.cc])){x.push(T),k.length&&this.hls.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:y,error:new Error("Missing initial subtitle PTS")});return}var p=y.decryptdata;if(p==null||p.key==null||p.method!=="AES-128"){var c=this.tracks[y.level],s=this.vttCCs;s[y.cc]||(s[y.cc]={start:y.start,prevCC:this.prevCC,new:!0},this.prevCC=y.cc),c&&c.textCodec===M.IMSC1_CODEC?this._parseIMSC1(y,f):this._parseVTTs(y,f,s)}}else this.hls.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:y,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(d,T){var y=this,f=this.hls;Object(M.parseIMSC1)(T,this.initPTS[d.cc],this.timescale[d.cc],function(k){y._appendCues(k,d.level),f.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:d})},function(k){A.logger.log("Failed to parse IMSC1: "+k),f.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:k})})},o._parseVTTs=function(d,T,y){var f=this,k=this.hls;Object(U.parseWebVTT)(T,this.initPTS[d.cc],this.timescale[d.cc],y,d.cc,d.start,function(x){f._appendCues(x,d.level),k.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:d})},function(x){f._fallbackToIMSC1(d,T),A.logger.log("Failed to parse VTT cue: "+x),k.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:x})})},o._fallbackToIMSC1=function(d,T){var y=this,f=this.tracks[d.level];f.textCodec||Object(M.parseIMSC1)(T,this.initPTS[d.cc],this.timescale[d.cc],function(){f.textCodec=M.IMSC1_CODEC,y._parseIMSC1(d,T)},function(){f.textCodec="wvtt"})},o._appendCues=function(d,T){var y=this.hls;if(this.config.renderTextTracksNatively){var f=this.textTracks[T];if(f.mode==="disabled")return;d.forEach(function(p){return Object(P.addCueToTrack)(f,p)})}else{var k=this.tracks[T],x=k.default?"default":"subtitles"+T;y.trigger(N.Events.CUES_PARSED,{type:"subtitles",cues:d,track:x})}},o.onFragDecrypted=function(d,T){var y=T.frag;if(y.type===b.PlaylistLevelType.SUBTITLE){if(!Object(X.isFiniteNumber)(this.initPTS[y.cc])){this.unparsedVttFrags.push(T);return}this.onFragLoaded(N.Events.FRAG_LOADED,T)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(d,T){var y=this.cea608Parser1,f=this.cea608Parser2;if(!this.enabled||!(y&&f))return;for(var k=0;k<T.samples.length;k++){var x=T.samples[k].bytes;if(x){var p=this.extractCea608Data(x);y.addData(T.samples[k].pts,p[0]),f.addData(T.samples[k].pts,p[1])}}},o.onBufferFlushing=function(d,T){var y=T.startOffset,f=T.endOffset,k=T.endOffsetSubtitles,x=T.type,p=this.media;if(!p||p.currentTime<f)return;if(!x||x==="video"){var c=this.captionsTracks;Object.keys(c).forEach(function(a){return Object(P.removeCuesInRange)(c[a],y,f)})}if(this.config.renderTextTracksNatively&&(y===0&&k!==void 0)){var s=this.textTracks;Object.keys(s).forEach(function(a){return Object(P.removeCuesInRange)(s[a],y,k)})}},o.extractCea608Data=function(d){for(var T=d[0]&31,y=2,f=[[],[]],k=0;k<T;k++){var x=d[y++],p=127&d[y++],c=127&d[y++],s=(4&x)!==0,a=3&x;if(p===0&&c===0)continue;s&&((a===0||a===1)&&(f[a].push(p),f[a].push(c)))}return f},h}();function L(h,o){return h&&h.label===o.name&&!(h.textTrack1||h.textTrack2)}function w(h,o,u,d){return Math.min(o,d)-Math.max(h,u)}function S(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return X});var X=function(){function N(z,U){this.subtle=void 0,this.aesIV=void 0,this.subtle=z,this.aesIV=U}var I=N.prototype;return I.decrypt=function(U,P){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},P,U)},N}()},"./src/crypt/aes-decryptor.ts":function(ne,$,D){"use strict";D.r($),D.d($,"removePadding",function(){return N}),D.d($,"default",function(){return I});var X=D("./src/utils/typed-array.ts");function N(z){var U=z.byteLength,P=U&&new DataView(z.buffer).getUint8(U-1);return P?Object(X.sliceUint8)(z,0,U-P):z}var I=function(){function z(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var U=z.prototype;return U.uint8ArrayToUint32Array_=function(M){for(var b=new DataView(M),A=new Uint32Array(4),R=0;R<4;R++)A[R]=b.getUint32(R*4);return A},U.initTable=function(){var M=this.sBox,b=this.invSBox,A=this.subMix,R=A[0],L=A[1],w=A[2],S=A[3],h=this.invSubMix,o=h[0],u=h[1],d=h[2],T=h[3],y=new Uint32Array(256),f=0,k=0,x=0;for(x=0;x<256;x++)x<128?y[x]=x<<1:y[x]=x<<1^283;for(x=0;x<256;x++){var p=k^k<<1^k<<2^k<<3^k<<4;p=p>>>8^p&255^99,M[f]=p,b[p]=f;var c=y[f],s=y[c],a=y[s],v=y[p]*257^p*16843008;R[f]=v<<24|v>>>8,L[f]=v<<16|v>>>16,w[f]=v<<8|v>>>24,S[f]=v,v=a*16843009^s*65537^c*257^f*16843008,o[p]=v<<24|v>>>8,u[p]=v<<16|v>>>16,d[p]=v<<8|v>>>24,T[p]=v,f?(f=c^y[y[y[a^c]]],k^=y[y[k]]):f=k=1}},U.expandKey=function(M){for(var b=this.uint8ArrayToUint32Array_(M),A=!0,R=0;R<b.length&&A;)A=b[R]===this.key[R],R++;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,S,h,o=this.keySchedule=new Uint32Array(w),u=this.invKeySchedule=new Uint32Array(w),d=this.sBox,T=this.rcon,y=this.invSubMix,f=y[0],k=y[1],x=y[2],p=y[3],c,s;for(S=0;S<w;S++){if(S<L){c=o[S]=b[S];continue}s=c,S%L===0?(s=s<<8|s>>>24,s=d[s>>>24]<<24|d[s>>>16&255]<<16|d[s>>>8&255]<<8|d[s&255],s^=T[S/L|0]<<24):L>6&&S%L===4&&(s=d[s>>>24]<<24|d[s>>>16&255]<<16|d[s>>>8&255]<<8|d[s&255]),o[S]=c=(o[S-L]^s)>>>0}for(h=0;h<w;h++)S=w-h,h&3?s=o[S]:s=o[S-4],h<4||S<=4?u[h]=s:u[h]=f[d[s>>>24]]^k[d[s>>>16&255]]^x[d[s>>>8&255]]^p[d[s&255]],u[h]=u[h]>>>0},U.networkToHostOrderSwap=function(M){return M<<24|(M&65280)<<8|(M&16711680)>>8|M>>>24},U.decrypt=function(M,b,A){for(var R=this.keySize+6,L=this.invKeySchedule,w=this.invSBox,S=this.invSubMix,h=S[0],o=S[1],u=S[2],d=S[3],T=this.uint8ArrayToUint32Array_(A),y=T[0],f=T[1],k=T[2],x=T[3],p=new Int32Array(M),c=new Int32Array(p.length),s,a,v,g,E,_,H,V,Z,G,j,q,ie,ce,ve=this.networkToHostOrderSwap;b<p.length;){for(Z=ve(p[b]),G=ve(p[b+1]),j=ve(p[b+2]),q=ve(p[b+3]),E=Z^L[0],_=q^L[1],H=j^L[2],V=G^L[3],ie=4,ce=1;ce<R;ce++)s=h[E>>>24]^o[_>>16&255]^u[H>>8&255]^d[V&255]^L[ie],a=h[_>>>24]^o[H>>16&255]^u[V>>8&255]^d[E&255]^L[ie+1],v=h[H>>>24]^o[V>>16&255]^u[E>>8&255]^d[_&255]^L[ie+2],g=h[V>>>24]^o[E>>16&255]^u[_>>8&255]^d[H&255]^L[ie+3],E=s,_=a,H=v,V=g,ie=ie+4;s=w[E>>>24]<<24^w[_>>16&255]<<16^w[H>>8&255]<<8^w[V&255]^L[ie],a=w[_>>>24]<<24^w[H>>16&255]<<16^w[V>>8&255]<<8^w[E&255]^L[ie+1],v=w[H>>>24]<<24^w[V>>16&255]<<16^w[E>>8&255]<<8^w[_&255]^L[ie+2],g=w[V>>>24]<<24^w[E>>16&255]<<16^w[_>>8&255]<<8^w[H&255]^L[ie+3],c[b]=ve(s^y),c[b+1]=ve(g^f),c[b+2]=ve(v^k),c[b+3]=ve(a^x),y=Z,f=G,k=j,x=q,b=b+4}return c.buffer},z}()},"./src/crypt/decrypter.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return b});var X=D("./src/crypt/aes-crypto.ts"),N=D("./src/crypt/fast-aes-key.ts"),I=D("./src/crypt/aes-decryptor.ts"),z=D("./src/utils/logger.ts"),U=D("./src/utils/mp4-tools.ts"),P=D("./src/utils/typed-array.ts"),M=16,b=function(){function A(L,w,S){var h=S===void 0?{}:S,o=h.removePKCS7Padding,u=o===void 0?!0:o;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=L,this.config=w,this.removePKCS7Padding=u,u)try{var d=self.crypto;d&&(this.subtle=d.subtle||d.webkitSubtle)}catch(T){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var R=A.prototype;return R.destroy=function(){this.observer=null},R.isSync=function(){return this.config.enableSoftwareAES},R.flush=function(){var w=this.currentResult;if(!w){this.reset();return}var S=new Uint8Array(w);return this.reset(),this.removePKCS7Padding?Object(I.removePadding)(S):S},R.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},R.decrypt=function(w,S,h,o){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(w),S,h);var u=this.flush();u&&o(u.buffer)}else this.webCryptoDecrypt(new Uint8Array(w),S,h).then(o)},R.softwareDecrypt=function(w,S,h){var o=this.currentIV,u=this.currentResult,d=this.remainderData;this.logOnce("JS AES decrypt"),d&&(w=Object(U.appendUint8Array)(d,w),this.remainderData=null);var T=this.getValidChunk(w);if(!T.length)return null;o&&(h=o);var y=this.softwareDecrypter;y||(y=this.softwareDecrypter=new I.default),y.expandKey(S);var f=u;return this.currentResult=y.decrypt(T.buffer,0,h),this.currentIV=Object(P.sliceUint8)(T,-16).buffer,f||null},R.webCryptoDecrypt=function(w,S,h){var o=this,u=this.subtle;return(this.key!==S||!this.fastAesKey)&&(this.key=S,this.fastAesKey=new N.default(u,S)),this.fastAesKey.expandKey().then(function(d){if(!u)return Promise.reject(new Error("web crypto not initialized"));var T=new X.default(u,h);return T.decrypt(w.buffer,d)}).catch(function(d){return o.onWebCryptoError(d,w,S,h)})},R.onWebCryptoError=function(w,S,h,o){return z.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",w),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(S,h,o)},R.getValidChunk=function(w){var S=w,h=w.length-w.length%M;return h!==w.length&&(S=Object(P.sliceUint8)(w,0,h),this.remainderData=Object(P.sliceUint8)(w,h)),S},R.logOnce=function(w){if(!this.logEnabled)return;z.logger.log("[decrypter.ts]: "+w),this.logEnabled=!1},A}()},"./src/crypt/fast-aes-key.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return X});var X=function(){function N(z,U){this.subtle=void 0,this.key=void 0,this.subtle=z,this.key=U}var I=N.prototype;return I.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},N}()},"./src/demux/aacdemuxer.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/demux/base-audio-demuxer.ts"),N=D("./src/demux/adts.ts"),I=D("./src/utils/logger.ts"),z=D("./src/demux/id3.ts");function U(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 M=function(b){U(A,b);function A(L,w){var S;return S=b.call(this)||this,S.observer=void 0,S.config=void 0,S.observer=L,S.config=w,S}var R=A.prototype;return R.resetInitSegment=function(w,S,h){b.prototype.resetInitSegment.call(this,w,S,h),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:w,duration:h,inputTimeScale:9e4,dropped:0}},A.probe=function(w){if(!w)return!1;for(var S=z.getID3Data(w,0)||[],h=S.length,o=w.length;h<o;h++)if(N.probe(w,h))return I.logger.log("ADTS sync word found !"),!0;return!1},R.canParse=function(w,S){return N.canParse(w,S)},R.appendFrame=function(w,S,h){N.initTrackConfig(w,this.observer,S,h,w.manifestCodec);var o=N.appendFrame(w,S,h,this.initPTS,this.frameIndex);if(o&&o.missing===0)return o},A}(X.default);M.minProbeByteLength=9,$.default=M},"./src/demux/adts.ts":function(ne,$,D){"use strict";D.r($),D.d($,"getAudioConfig",function(){return z}),D.d($,"isHeaderPattern",function(){return U}),D.d($,"getHeaderLength",function(){return P}),D.d($,"getFullFrameLength",function(){return M}),D.d($,"canGetFrameLength",function(){return b}),D.d($,"isHeader",function(){return A}),D.d($,"canParse",function(){return R}),D.d($,"probe",function(){return L}),D.d($,"initTrackConfig",function(){return w}),D.d($,"getFrameDuration",function(){return S}),D.d($,"parseFrameHeader",function(){return h}),D.d($,"appendFrame",function(){return o});var X=D("./src/utils/logger.ts"),N=D("./src/errors.ts"),I=D("./src/events.ts");function z(u,d,T,y){var f,k,x,p,c=navigator.userAgent.toLowerCase(),s=y,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];f=((d[T+2]&192)>>>6)+1;var v=(d[T+2]&60)>>>2;if(v>a.length-1){u.trigger(I.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+v});return}return x=(d[T+2]&1)<<2,x|=(d[T+3]&192)>>>6,X.logger.log("manifest codec:"+y+", ADTS type:"+f+", samplingIndex:"+v),/firefox/i.test(c)?v>=6?(f=5,p=new Array(4),k=v-3):(f=2,p=new Array(2),k=v):c.indexOf("android")!==-1?(f=2,p=new Array(2),k=v):(f=5,p=new Array(4),y&&(y.indexOf("mp4a.40.29")!==-1||y.indexOf("mp4a.40.5")!==-1)||!y&&v>=6?k=v-3:((y&&y.indexOf("mp4a.40.2")!==-1&&(v>=6&&x===1||/vivaldi/i.test(c))||!y&&x===1)&&(f=2,p=new Array(2)),k=v)),p[0]=f<<3,p[0]|=(v&14)>>1,p[1]|=(v&1)<<7,p[1]|=x<<3,f===5&&(p[1]|=(k&14)>>1,p[2]=(k&1)<<7,p[2]|=2<<2,p[3]=0),{config:p,samplerate:a[v],channelCount:x,codec:"mp4a.40."+f,manifestCodec:s}}function U(u,d){return u[d]===255&&(u[d+1]&246)===240}function P(u,d){return u[d+1]&1?7:9}function M(u,d){return(u[d+3]&3)<<11|u[d+4]<<3|(u[d+5]&224)>>>5}function b(u,d){return d+5<u.length}function A(u,d){return d+1<u.length&&U(u,d)}function R(u,d){return b(u,d)&&U(u,d)&&M(u,d)<=u.length-d}function L(u,d){if(A(u,d)){var T=P(u,d);if(d+T>=u.length)return!1;var y=M(u,d);if(y<=T)return!1;var f=d+y;return f===u.length||A(u,f)}return!1}function w(u,d,T,y,f){if(!u.samplerate){var k=z(d,T,y,f);if(!k)return;u.config=k.config,u.samplerate=k.samplerate,u.channelCount=k.channelCount,u.codec=k.codec,u.manifestCodec=k.manifestCodec,X.logger.log("parsed codec:"+u.codec+", rate:"+k.samplerate+", channels:"+k.channelCount)}}function S(u){return 1024*9e4/u}function h(u,d,T,y,f){var k=P(u,d),x=M(u,d);if(x-=k,x>0){var p=T+y*f;return{headerLength:k,frameLength:x,stamp:p}}}function o(u,d,T,y,f){var k=S(u.samplerate),x=h(d,T,y,f,k);if(x){var p=x.frameLength,c=x.headerLength,s=x.stamp,a=c+p,v=Math.max(0,T+a-d.length),g;v?(g=new Uint8Array(a-c),g.set(d.subarray(T+c,d.length),0)):g=d.subarray(T+c,T+a);var E={unit:g,pts:s};return v||u.samples.push(E),{sample:E,length:a,missing:v}}}},"./src/demux/base-audio-demuxer.ts":function(ne,$,D){"use strict";D.r($),D.d($,"initPTSFn",function(){return M});var X=D("./src/polyfills/number.ts"),N=D("./src/demux/id3.ts"),I=D("./src/demux/dummy-demuxed-track.ts"),z=D("./src/utils/mp4-tools.ts"),U=D("./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,S){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,S){},A.demux=function(L,w){this.cachedData&&(L=Object(z.appendUint8Array)(this.cachedData,L),this.cachedData=null);var S=N.getID3Data(L,0),h=S?S.length:0,o,u,d=this._audioTrack,T=this._id3Track,y=S?N.getTimeStamp(S):void 0,f=L.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=M(y,w)),S&&S.length>0&&T.samples.push({pts:this.initPTS,dts:this.initPTS,data:S}),u=this.initPTS;h<f;){if(this.canParse(L,h)){var k=this.appendFrame(d,L,h);k?(this.frameIndex++,u=k.sample.pts,h+=k.length,o=h):h=f}else N.canParse(L,h)?(S=N.getID3Data(L,h),T.samples.push({pts:u,dts:u,data:S}),h+=S.length,o=h):h++;if(h===f&&o!==f){var x=Object(U.sliceUint8)(L,o);this.cachedData?this.cachedData=Object(z.appendUint8Array)(this.cachedData,x):this.cachedData=x}}return{audioTrack:d,avcTrack:Object(I.dummyTrack)(),id3Track:T,textTrack:Object(I.dummyTrack)()}},A.demuxSampleAes=function(L,w,S){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(I.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(I.dummyTrack)()}},A.destroy=function(){},b}(),M=function(A,R){return Object(X.isFiniteNumber)(A)?A*90:R*9e4};$.default=P},"./src/demux/chunk-cache.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return X});var X=function(){function I(){this.chunks=[],this.dataLength=0}var z=I.prototype;return z.push=function(P){this.chunks.push(P),this.dataLength+=P.length},z.flush=function(){var P=this.chunks,M=this.dataLength,b;if(P.length)P.length===1?b=P[0]:b=N(P,M);else return new Uint8Array(0);return this.reset(),b},z.reset=function(){this.chunks.length=0,this.dataLength=0},I}();function N(I,z){for(var U=new Uint8Array(z),P=0,M=0;M<I.length;M++){var b=I[M];U.set(b,P),P+=b.length}return U}},"./src/demux/dummy-demuxed-track.ts":function(ne,$,D){"use strict";D.r($),D.d($,"dummyTrack",function(){return X});function X(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/utils/logger.ts"),N=function(){function I(U){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=U,this.bytesAvailable=U.byteLength,this.word=0,this.bitsAvailable=0}var z=I.prototype;return z.loadWord=function(){var P=this.data,M=this.bytesAvailable,b=P.byteLength-M,A=new Uint8Array(4),R=Math.min(4,M);if(R===0)throw new Error("no bytes available");A.set(P.subarray(b,b+R)),this.word=new DataView(A.buffer).getUint32(0),this.bitsAvailable=R*8,this.bytesAvailable-=R},z.skipBits=function(P){var M;this.bitsAvailable>P?(this.word<<=P,this.bitsAvailable-=P):(P-=this.bitsAvailable,M=P>>3,P-=M>>3,this.bytesAvailable-=M,this.loadWord(),this.word<<=P,this.bitsAvailable-=P)},z.readBits=function(P){var M=Math.min(this.bitsAvailable,P),b=this.word>>>32-M;return P>32&&X.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=M,this.bitsAvailable>0?this.word<<=M:this.bytesAvailable>0&&this.loadWord(),M=P-M,M>0&&this.bitsAvailable?b<<M|this.readBits(M):b},z.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()},z.skipUEG=function(){this.skipBits(1+this.skipLZ())},z.skipEG=function(){this.skipBits(1+this.skipLZ())},z.readUEG=function(){var P=this.skipLZ();return this.readBits(P+1)-1},z.readEG=function(){var P=this.readUEG();return 1&P?1+P>>>1:-1*(P>>>1)},z.readBoolean=function(){return this.readBits(1)===1},z.readUByte=function(){return this.readBits(8)},z.readUShort=function(){return this.readBits(16)},z.readUInt=function(){return this.readBits(32)},z.skipScalingList=function(P){for(var M=8,b=8,A,R=0;R<P;R++)b!==0&&(A=this.readEG(),b=(M+A+256)%256),M=b===0?M:b},z.readSPS=function(){var P=0,M=0,b=0,A=0,R,L,w,S=this.readUByte.bind(this),h=this.readBits.bind(this),o=this.readUEG.bind(this),u=this.readBoolean.bind(this),d=this.skipBits.bind(this),T=this.skipEG.bind(this),y=this.skipUEG.bind(this),f=this.skipScalingList.bind(this);S();var k=S();if(h(5),d(3),S(),y(),k===100||k===110||k===122||k===244||k===44||k===83||k===86||k===118||k===128){var x=o();if(x===3&&d(1),y(),y(),d(1),u())for(L=x!==3?8:12,w=0;w<L;w++)u()&&(w<6?f(16):f(64))}y();var p=o();if(p===0)o();else if(p===1)for(d(1),T(),T(),R=o(),w=0;w<R;w++)T();y(),d(1);var c=o(),s=o(),a=h(1);a===0&&d(1),d(1),u()&&(P=o(),M=o(),b=o(),A=o());var v=[1,1];if(u()&&u()){var g=S();switch(g){case 1:v=[1,1];break;case 2:v=[12,11];break;case 3:v=[10,11];break;case 4:v=[16,11];break;case 5:v=[40,33];break;case 6:v=[24,11];break;case 7:v=[20,11];break;case 8:v=[32,11];break;case 9:v=[80,33];break;case 10:v=[18,11];break;case 11:v=[15,11];break;case 12:v=[64,33];break;case 13:v=[160,99];break;case 14:v=[4,3];break;case 15:v=[3,2];break;case 16:v=[2,1];break;case 255:{v=[S()<<8|S(),S()<<8|S()];break}}}return{width:Math.ceil((c+1)*16-P*2-M*2),height:(2-a)*(s+1)*16-(a?2:4)*(b+A),pixelRatio:v}},z.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},I}();$.default=N},"./src/demux/id3.ts":function(ne,$,D){"use strict";D.r($),D.d($,"isHeader",function(){return X}),D.d($,"isFooter",function(){return N}),D.d($,"getID3Data",function(){return I}),D.d($,"canParse",function(){return U}),D.d($,"getTimeStamp",function(){return P}),D.d($,"isTimeStampFrame",function(){return M}),D.d($,"getID3Frames",function(){return A}),D.d($,"decodeFrame",function(){return R}),D.d($,"utf8ArrayToStr",function(){return o}),D.d($,"testables",function(){return u});var X=function(f,k){return k+10<=f.length&&(f[k]===73&&f[k+1]===68&&f[k+2]===51&&(f[k+3]<255&&f[k+4]<255&&(f[k+6]<128&&f[k+7]<128&&f[k+8]<128&&f[k+9]<128)))},N=function(f,k){return k+10<=f.length&&(f[k]===51&&f[k+1]===68&&f[k+2]===73&&(f[k+3]<255&&f[k+4]<255&&(f[k+6]<128&&f[k+7]<128&&f[k+8]<128&&f[k+9]<128)))},I=function(f,k){for(var x=k,p=0;X(f,k);){p+=10;var c=z(f,k+6);p+=c,N(f,k+10)&&(p+=10),k+=p}return p>0?f.subarray(x,x+p):void 0},z=function(f,k){var x=0;return x=(f[k]&127)<<21,x|=(f[k+1]&127)<<14,x|=(f[k+2]&127)<<7,x|=f[k+3]&127,x},U=function(f,k){return X(f,k)&&z(f,k+6)+10<=f.length-k},P=function(f){for(var k=A(f),x=0;x<k.length;x++){var p=k[x];if(M(p))return h(p)}return},M=function(f){return f&&f.key==="PRIV"&&f.info==="com.apple.streaming.transportStreamTimestamp"},b=function(f){var k=String.fromCharCode(f[0],f[1],f[2],f[3]),x=z(f,4),p=10;return{type:k,size:x,data:f.subarray(p,p+x)}},A=function(f){for(var k=0,x=[];X(f,k);){var p=z(f,k+6);k+=10;for(var c=k+p;k+8<c;){var s=b(f.subarray(k)),a=R(s);a&&x.push(a),k+=s.size+10}N(f,k)&&(k+=10)}return x},R=function(f){return f.type==="PRIV"?L(f):f.type[0]==="W"?S(f):w(f)},L=function(f){if(f.size<2)return;var k=o(f.data,!0),x=new Uint8Array(f.data.subarray(k.length+1));return{key:f.type,info:k,data:x.buffer}},w=function(f){if(f.size<2)return;if(f.type==="TXXX"){var k=1,x=o(f.data.subarray(k),!0);k+=x.length+1;var p=o(f.data.subarray(k));return{key:f.type,info:x,data:p}}var c=o(f.data.subarray(1));return{key:f.type,data:c}},S=function(f){if(f.type==="WXXX"){if(f.size<2)return;var k=1,x=o(f.data.subarray(k),!0);k+=x.length+1;var p=o(f.data.subarray(k));return{key:f.type,info:x,data:p}}var c=o(f.data);return{key:f.type,data:c}},h=function(f){if(f.data.byteLength===8){var k=new Uint8Array(f.data),x=k[3]&1,p=(k[4]<<23)+(k[5]<<15)+(k[6]<<7)+k[7];return p/=45,x&&(p+=4772185884e-2),Math.round(p)}return},o=function(f,k){k===void 0&&(k=!1);var x=T();if(x){var p=x.decode(f);if(k){var c=p.indexOf("\0");return c!==-1?p.substring(0,c):p}return p.replace(/\0/g,"")}for(var s=f.length,a,v,g,E="",_=0;_<s;){if(a=f[_++],a===0&&k)return E;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:E+=String.fromCharCode(a);break;case 12:case 13:v=f[_++],E+=String.fromCharCode((a&31)<<6|v&63);break;case 14:v=f[_++],g=f[_++],E+=String.fromCharCode((a&15)<<12|(v&63)<<6|(g&63)<<0);break;default:}}return E},u={decodeTextFrame:w},d;function T(){return!d&&typeof self.TextDecoder!="undefined"&&(d=new self.TextDecoder("utf-8")),d}},"./src/demux/mp3demuxer.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/demux/base-audio-demuxer.ts"),N=D("./src/demux/id3.ts"),I=D("./src/utils/logger.ts"),z=D("./src/demux/mpegaudio.ts");function U(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 M=function(b){U(A,b);function A(){return b.apply(this,arguments)||this}var R=A.prototype;return R.resetInitSegment=function(w,S,h){b.prototype.resetInitSegment.call(this,w,S,h),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:w,duration:h,inputTimeScale:9e4,dropped:0}},A.probe=function(w){if(!w)return!1;for(var S=N.getID3Data(w,0)||[],h=S.length,o=w.length;h<o;h++)if(z.probe(w,h))return I.logger.log("MPEG Audio sync word found !"),!0;return!1},R.canParse=function(w,S){return z.canParse(w,S)},R.appendFrame=function(w,S,h){return this.initPTS===null?void 0:z.appendFrame(w,S,h,this.initPTS,this.frameIndex)},A}(X.default);M.minProbeByteLength=4,$.default=M},"./src/demux/mp4demuxer.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/utils/mp4-tools.ts"),N=D("./src/demux/dummy-demuxed-track.ts"),I=function(){function z(P,M){this.remainderData=null,this.config=void 0,this.config=M}var U=z.prototype;return U.resetTimeStamp=function(){},U.resetInitSegment=function(){},U.resetContiguity=function(){},z.probe=function(M){return Object(X.findBox)({data:M,start:0,end:Math.min(M.length,16384)},["moof"]).length>0},U.demux=function(M){var b=M,A=Object(N.dummyTrack)();if(this.config.progressive){this.remainderData&&(b=Object(X.appendUint8Array)(this.remainderData,M));var R=Object(X.segmentValidRange)(b);this.remainderData=R.remainder,A.samples=R.valid||new Uint8Array}else A.samples=b;return{audioTrack:Object(N.dummyTrack)(),avcTrack:A,id3Track:Object(N.dummyTrack)(),textTrack:Object(N.dummyTrack)()}},U.flush=function(){var M=Object(N.dummyTrack)();return M.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(N.dummyTrack)(),avcTrack:M,id3Track:Object(N.dummyTrack)(),textTrack:Object(N.dummyTrack)()}},U.demuxSampleAes=function(M,b,A){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},U.destroy=function(){},z}();I.minProbeByteLength=1024,$.default=I},"./src/demux/mpegaudio.ts":function(ne,$,D){"use strict";D.r($),D.d($,"appendFrame",function(){return P}),D.d($,"parseHeader",function(){return M}),D.d($,"isHeaderPattern",function(){return b}),D.d($,"isHeader",function(){return A}),D.d($,"canParse",function(){return R}),D.d($,"probe",function(){return L});var X=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],I=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],z=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],U=[0,1,1,4];function P(w,S,h,o,u){if(h+24>S.length)return;var d=M(S,h);if(d&&h+d.frameLength<=S.length){var T=d.samplesPerFrame*9e4/d.sampleRate,y=o+u*T,f={unit:S.subarray(h,h+d.frameLength),pts:y,dts:y};return w.config=[],w.channelCount=d.channelCount,w.samplerate=d.sampleRate,w.samples.push(f),{sample:f,length:d.frameLength,missing:0}}}function M(w,S){var h=w[S+1]>>3&3,o=w[S+1]>>1&3,u=w[S+2]>>4&15,d=w[S+2]>>2&3;if(h!==1&&u!==0&&u!==15&&d!==3){var T=w[S+2]>>1&1,y=w[S+3]>>6,f=h===3?3-o:o===3?3:4,k=N[f*14+u-1]*1e3,x=h===3?0:h===2?1:2,p=I[x*3+d],c=y===3?1:2,s=z[h][o],a=U[o],v=s*8*a,g=Math.floor(s*k/p+T)*a;if(X===null){var E=navigator.userAgent||"",_=E.match(/Chrome\/(\d+)/i);X=_?parseInt(_[1]):0}var H=!!X&&X<=87;return H&&o===2&&k>=224e3&&y===0&&(w[S+3]=w[S+3]|128),{sampleRate:p,channelCount:c,frameLength:g,samplesPerFrame:v}}}function b(w,S){return w[S]===255&&(w[S+1]&224)===224&&(w[S+1]&6)!==0}function A(w,S){return S+1<w.length&&b(w,S)}function R(w,S){var h=4;return b(w,S)&&h<=w.length-S}function L(w,S){if(S+1<w.length&&b(w,S)){var h=4,o=M(w,S),u=h;o!=null&&o.frameLength&&(u=o.frameLength);var d=S+u;return d===w.length||A(w,d)}return!1}},"./src/demux/sample-aes.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/crypt/decrypter.ts"),N=D("./src/demux/tsdemuxer.ts"),I=function(){function z(P,M,b){this.keyData=void 0,this.decrypter=void 0,this.keyData=b,this.decrypter=new X.default(P,M,{removePKCS7Padding:!1})}var U=z.prototype;return U.decryptBuffer=function(M,b){this.decrypter.decrypt(M,this.keyData.key.buffer,this.keyData.iv.buffer,b)},U.decryptAacSample=function(M,b,A,R){var L=M[b].unit,w=L.subarray(16,L.length-L.length%16),S=w.buffer.slice(w.byteOffset,w.byteOffset+w.length),h=this;this.decryptBuffer(S,function(o){var u=new Uint8Array(o);L.set(u,16),R||h.decryptAacSamples(M,b+1,A)})},U.decryptAacSamples=function(M,b,A){for(;;b++){if(b>=M.length){A();return}if(M[b].unit.length<32)continue;var R=this.decrypter.isSync();if(this.decryptAacSample(M,b,A,R),!R)return}},U.getAvcEncryptedData=function(M){for(var b=Math.floor((M.length-48)/160)*16+16,A=new Int8Array(b),R=0,L=32;L<=M.length-16;L+=160,R+=16)A.set(M.subarray(L,L+16),R);return A},U.getAvcDecryptedUnit=function(M,b){for(var A=new Uint8Array(b),R=0,L=32;L<=M.length-16;L+=160,R+=16)M.set(A.subarray(R,R+16),L);return M},U.decryptAvcSample=function(M,b,A,R,L,w){var S=Object(N.discardEPB)(L.data),h=this.getAvcEncryptedData(S),o=this;this.decryptBuffer(h.buffer,function(u){L.data=o.getAvcDecryptedUnit(S,u),w||o.decryptAvcSamples(M,b,A+1,R)})},U.decryptAvcSamples=function(M,b,A,R){if(M instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;b++,A=0){if(b>=M.length){R();return}for(var L=M[b].units;!(A>=L.length);A++){var w=L[A];if(w.data.length<=48||w.type!==1&&w.type!==5)continue;var S=this.decrypter.isSync();if(this.decryptAvcSample(M,b,A,R,w,S),!S)return}}},z}();$.default=I},"./src/demux/transmuxer-interface.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return L});var X=D("./node_modules/webworkify-webpack/index.js"),N=D.n(X),I=D("./src/events.ts"),z=D("./src/demux/transmuxer.ts"),U=D("./src/utils/logger.ts"),P=D("./src/errors.ts"),M=D("./src/utils/mediasource-helper.ts"),b=D("./node_modules/eventemitter3/index.js"),A=D.n(b),R=Object(M.getMediaSource)()||{isTypeSupported:function(){return!1}},L=function(){function w(h,o,u,d){var T=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=h,this.id=o,this.onTransmuxComplete=u,this.onFlush=d;var y=h.config,f=function(s,a){a=a||{},a.frag=T.frag,a.id=T.id,h.trigger(s,a)};this.observer=new b.EventEmitter,this.observer.on(I.Events.FRAG_DECRYPTED,f),this.observer.on(I.Events.ERROR,f);var k={mp4:R.isTypeSupported("video/mp4"),mpeg:R.isTypeSupported("audio/mpeg"),mp3:R.isTypeSupported('audio/mp4; codecs="mp3"')},x=navigator.vendor;if(y.enableWorker&&typeof Worker!="undefined"){U.logger.log("demuxing in webworker");var p;try{p=this.worker=X("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),p.addEventListener("message",this.onwmsg),p.onerror=function(c){h.trigger(I.Events.ERROR,{type:P.ErrorTypes.OTHER_ERROR,details:P.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},p.postMessage({cmd:"init",typeSupported:k,vendor:x,id:o,config:JSON.stringify(y)})}catch(c){U.logger.warn("Error in worker:",c),U.logger.error("Error while initializing DemuxerWorker, fallback to inline"),p&&self.URL.revokeObjectURL(p.objectURL),this.transmuxer=new z.default(this.observer,k,y,x,o),this.worker=null}}else this.transmuxer=new z.default(this.observer,k,y,x,o)}var S=w.prototype;return S.destroy=function(){var o=this.worker;if(o)o.removeEventListener("message",this.onwmsg),o.terminate(),this.worker=null;else{var u=this.transmuxer;u&&(u.destroy(),this.transmuxer=null)}var d=this.observer;d&&d.removeAllListeners(),this.observer=null},S.push=function(o,u,d,T,y,f,k,x,p,c){var s=this;p.transmuxing.start=self.performance.now();var a=this.transmuxer,v=this.worker,g=f?f.start:y.start,E=y.decryptdata,_=this.frag,H=!(_&&y.cc===_.cc),V=!(_&&p.level===_.level),Z=_?p.sn-_.sn:-1,G=this.part?p.part-this.part.index:1,j=!V&&(Z===1||Z===0&&G===1),q=self.performance.now();(V||Z||y.stats.parsing.start===0)&&(y.stats.parsing.start=q),f&&(G||!j)&&(f.stats.parsing.start=q);var ie=new z.TransmuxState(H,j,x,V,g);if(!j||H){U.logger.log("[transmuxer-interface, "+y.type+"]: Starting new transmux session for sn: "+p.sn+" p: "+p.part+" level: "+p.level+" id: "+p.id+`
|
|
discontinuity: `+H+`
|
|
trackSwitch: `+V+`
|
|
contiguous: `+j+`
|
|
accurateTimeOffset: `+x+`
|
|
timeOffset: `+g);var ce=new z.TransmuxConfig(d,T,u,k,c);this.configureTransmuxer(ce)}if(this.frag=y,this.part=f,v)v.postMessage({cmd:"demux",data:o,decryptdata:E,chunkMeta:p,state:ie},o instanceof ArrayBuffer?[o]:[]);else if(a){var ve=a.push(o,E,p,ie);Object(z.isPromise)(ve)?ve.then(function(ke){s.handleTransmuxComplete(ke)}):this.handleTransmuxComplete(ve)}},S.flush=function(o){var u=this;o.transmuxing.start=self.performance.now();var d=this.transmuxer,T=this.worker;if(T)T.postMessage({cmd:"flush",chunkMeta:o});else if(d){var y=d.flush(o);Object(z.isPromise)(y)?y.then(function(f){u.handleFlushResult(f,o)}):this.handleFlushResult(y,o)}},S.handleFlushResult=function(o,u){var d=this;o.forEach(function(T){d.handleTransmuxComplete(T)}),this.onFlush(u)},S.onWorkerMessage=function(o){var u=o.data,d=this.hls;switch(u.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(u.data);break}case"flush":{this.onFlush(u.data);break}default:{u.data=u.data||{},u.data.frag=this.frag,u.data.id=this.id,d.trigger(u.event,u.data);break}}},S.configureTransmuxer=function(o){var u=this.worker,d=this.transmuxer;u?u.postMessage({cmd:"configure",config:o}):d&&d.configure(o)},S.handleTransmuxComplete=function(o){o.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(o)},w}()},"./src/demux/transmuxer-worker.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return P});var X=D("./src/demux/transmuxer.ts"),N=D("./src/events.ts"),I=D("./src/utils/logger.ts"),z=D("./node_modules/eventemitter3/index.js"),U=D.n(z);function P(L){var w=new z.EventEmitter,S=function(o,u){L.postMessage({event:o,data:u})};w.on(N.Events.FRAG_DECRYPTED,S),w.on(N.Events.ERROR,S),L.addEventListener("message",function(h){var o=h.data;switch(o.cmd){case"init":{var u=JSON.parse(o.config);L.transmuxer=new X.default(w,o.typeSupported,u,o.vendor,o.id),Object(I.enableLogs)(u.debug),S("init",null);break}case"configure":{L.transmuxer.configure(o.config);break}case"demux":{var d=L.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(X.isPromise)(d)?d.then(function(f){M(L,f)}):M(L,d);break}case"flush":{var T=o.chunkMeta,y=L.transmuxer.flush(T);Object(X.isPromise)(y)?y.then(function(f){A(L,f,T)}):A(L,y,T);break}default:break}})}function M(L,w){if(R(w.remuxResult))return;var S=[],h=w.remuxResult,o=h.audio,u=h.video;o&&b(S,o),u&&b(S,u),L.postMessage({event:"transmuxComplete",data:w},S)}function b(L,w){w.data1&&L.push(w.data1.buffer),w.data2&&L.push(w.data2.buffer)}function A(L,w,S){w.forEach(function(h){M(L,h)}),L.postMessage({event:"flush",data:S})}function R(L){return!L.audio&&!L.video&&!L.text&&!L.id3&&!L.initSegment}},"./src/demux/transmuxer.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return u}),D.d($,"isPromise",function(){return y}),D.d($,"TransmuxConfig",function(){return f}),D.d($,"TransmuxState",function(){return k});var X=D("./src/events.ts"),N=D("./src/errors.ts"),I=D("./src/crypt/decrypter.ts"),z=D("./src/demux/aacdemuxer.ts"),U=D("./src/demux/mp4demuxer.ts"),P=D("./src/demux/tsdemuxer.ts"),M=D("./src/demux/mp3demuxer.ts"),b=D("./src/remux/mp4-remuxer.ts"),A=D("./src/remux/passthrough-remuxer.ts"),R=D("./src/demux/chunk-cache.ts"),L=D("./src/utils/mp4-tools.ts"),w=D("./src/utils/logger.ts"),S;try{S=self.performance.now.bind(self.performance)}catch(x){w.logger.debug("Unable to use Performance API on this environment"),S=self.Date.now}var h=[{demux:P.default,remux:b.default},{demux:U.default,remux:A.default},{demux:z.default,remux:b.default},{demux:M.default,remux:b.default}],o=1024;h.forEach(function(x){var p=x.demux;o=Math.max(o,p.minProbeByteLength)});var u=function(){function x(c,s,a,v,g){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new R.default,this.observer=c,this.typeSupported=s,this.config=a,this.vendor=v,this.id=g}var p=x.prototype;return p.configure=function(s){this.transmuxConfig=s,this.decrypter&&this.decrypter.reset()},p.push=function(s,a,v,g){var E=this,_=v.transmuxing;_.executeStart=S();var H=new Uint8Array(s),V=this.cache,Z=this.config,G=this.currentTransmuxState,j=this.transmuxConfig;g&&(this.currentTransmuxState=g);var q=d(H,a);if(q&&q.method==="AES-128"){var ie=this.getDecrypter();if(Z.enableSoftwareAES){var ce=ie.softwareDecrypt(H,q.key.buffer,q.iv.buffer);if(!ce)return _.executeEnd=S(),T(v);H=new Uint8Array(ce)}else return this.decryptionPromise=ie.webCryptoDecrypt(H,q.key.buffer,q.iv.buffer).then(function(Pe){var He=E.push(Pe,null,v);return E.decryptionPromise=null,He}),this.decryptionPromise}var ve=g||G,ke=ve.contiguous,xe=ve.discontinuity,Ce=ve.trackSwitch,Te=ve.accurateTimeOffset,Ee=ve.timeOffset,pe=j.audioCodec,se=j.videoCodec,Le=j.defaultInitPts,Xe=j.duration,Ge=j.initSegmentData;if((xe||Ce)&&this.resetInitSegment(Ge,pe,se,Xe),xe&&this.resetInitialTimestamp(Le),ke||this.resetContiguity(),this.needsProbing(H,xe,Ce)){if(V.dataLength){var Ke=V.flush();H=Object(L.appendUint8Array)(Ke,H)}this.configureTransmuxer(H,j)}var Ve=this.transmux(H,q,Ee,Te,v),De=this.currentTransmuxState;return De.contiguous=!0,De.discontinuity=!1,De.trackSwitch=!1,_.executeEnd=S(),Ve},p.flush=function(s){var a=this,v=s.transmuxing;v.executeStart=S();var g=this.decrypter,E=this.cache,_=this.currentTransmuxState,H=this.decryptionPromise;if(H)return H.then(function(){return a.flush(s)});var V=[],Z=_.timeOffset;if(g){var G=g.flush();G&&V.push(this.push(G,null,s))}var j=E.dataLength;E.reset();var q=this.demuxer,ie=this.remuxer;if(!q||!ie)return j>=o&&this.observer.emit(X.Events.ERROR,X.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),v.executeEnd=S(),[T(s)];var ce=q.flush(Z);return y(ce)?ce.then(function(ve){return a.flushRemux(V,ve,s),V}):(this.flushRemux(V,ce,s),V)},p.flushRemux=function(s,a,v){var g=a.audioTrack,E=a.avcTrack,_=a.id3Track,H=a.textTrack,V=this.currentTransmuxState,Z=V.accurateTimeOffset,G=V.timeOffset;w.logger.log("[transmuxer.ts]: Flushed fragment "+v.sn+(v.part>-1?" p: "+v.part:"")+" of level "+v.level);var j=this.remuxer.remux(g,E,_,H,G,Z,!0,this.id);s.push({remuxResult:j,chunkMeta:v}),v.transmuxing.executeEnd=S()},p.resetInitialTimestamp=function(s){var a=this.demuxer,v=this.remuxer;if(!a||!v)return;a.resetTimeStamp(s),v.resetTimeStamp(s)},p.resetContiguity=function(){var s=this.demuxer,a=this.remuxer;if(!s||!a)return;s.resetContiguity(),a.resetNextTimestamp()},p.resetInitSegment=function(s,a,v,g){var E=this.demuxer,_=this.remuxer;if(!E||!_)return;E.resetInitSegment(a,v,g),_.resetInitSegment(s,a,v)},p.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},p.transmux=function(s,a,v,g,E){var _;return a&&a.method==="SAMPLE-AES"?_=this.transmuxSampleAes(s,a,v,g,E):_=this.transmuxUnencrypted(s,v,g,E),_},p.transmuxUnencrypted=function(s,a,v,g){var E=this.demuxer.demux(s,a,!1,!this.config.progressive),_=E.audioTrack,H=E.avcTrack,V=E.id3Track,Z=E.textTrack,G=this.remuxer.remux(_,H,V,Z,a,v,!1,this.id);return{remuxResult:G,chunkMeta:g}},p.transmuxSampleAes=function(s,a,v,g,E){var _=this;return this.demuxer.demuxSampleAes(s,a,v).then(function(H){var V=_.remuxer.remux(H.audioTrack,H.avcTrack,H.id3Track,H.textTrack,v,g,!1,_.id);return{remuxResult:V,chunkMeta:E}})},p.configureTransmuxer=function(s,a){for(var v=this.config,g=this.observer,E=this.typeSupported,_=this.vendor,H=a.audioCodec,V=a.defaultInitPts,Z=a.duration,G=a.initSegmentData,j=a.videoCodec,q,ie=0,ce=h.length;ie<ce;ie++)if(h[ie].demux.probe(s)){q=h[ie];break}q||(w.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),q={demux:U.default,remux:A.default});var ve=this.demuxer,ke=this.remuxer,xe=q.remux,Ce=q.demux;(!ke||!(ke instanceof xe))&&(this.remuxer=new xe(g,v,E,_)),(!ve||!(ve instanceof Ce))&&(this.demuxer=new Ce(g,v,E),this.probe=Ce.probe),this.resetInitSegment(G,H,j,Z),this.resetInitialTimestamp(V)},p.needsProbing=function(s,a,v){return!this.demuxer||!this.remuxer||a||v},p.getDecrypter=function(){var s=this.decrypter;return s||(s=this.decrypter=new I.default(this.observer,this.config)),s},x}();function d(x,p){var c=null;return x.byteLength>0&&p!=null&&p.key!=null&&p.iv!==null&&p.method!=null&&(c=p),c}var T=function(p){return{remuxResult:{},chunkMeta:p}};function y(x){return"then"in x&&x.then instanceof Function}var f=function(p,c,s,a,v){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=p,this.videoCodec=c,this.initSegmentData=s,this.duration=a,this.defaultInitPts=v},k=function(p,c,s,a,v){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=p,this.contiguous=c,this.accurateTimeOffset=s,this.trackSwitch=a,this.timeOffset=v}},"./src/demux/tsdemuxer.ts":function(ne,$,D){"use strict";D.r($),D.d($,"discardEPB",function(){return T});var X=D("./src/demux/adts.ts"),N=D("./src/demux/mpegaudio.ts"),I=D("./src/demux/exp-golomb.ts"),z=D("./src/demux/id3.ts"),U=D("./src/demux/sample-aes.ts"),P=D("./src/events.ts"),M=D("./src/utils/mp4-tools.ts"),b=D("./src/utils/logger.ts"),A=D("./src/errors.ts"),R={video:1,audio:2,id3:3,text:4},L=function(){function y(k,x,p){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=x,this.typeSupported=p}y.probe=function(x){var p=y.syncOffset(x);return p<0?!1:(p&&b.logger.warn("MPEG2-TS detected but first sync word found @ offset "+p+", junk ahead ?"),!0)},y.syncOffset=function(x){for(var p=Math.min(1e3,x.length-3*188),c=0;c<p;){if(x[c]===71&&x[c+188]===71&&x[c+2*188]===71)return c;c++}return-1},y.createTrack=function(x,p){return{container:x==="video"||x==="audio"?"video/mp2t":void 0,type:x,id:R[x],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:x==="audio"?p:void 0}};var f=y.prototype;return f.resetInitSegment=function(x,p,c){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=y.createTrack("video",c),this._audioTrack=y.createTrack("audio",c),this._id3Track=y.createTrack("id3",c),this._txtTrack=y.createTrack("text",c),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=x,this.videoCodec=p,this._duration=c},f.resetTimeStamp=function(){},f.resetContiguity=function(){var x=this._audioTrack,p=this._avcTrack,c=this._id3Track;x&&(x.pesData=null),p&&(p.pesData=null),c&&(c.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},f.demux=function(x,p,c,s){c===void 0&&(c=!1),s===void 0&&(s=!1),c||(this.sampleAes=null);var a,v=this._avcTrack,g=this._audioTrack,E=this._id3Track,_=v.pid,H=v.pesData,V=g.pid,Z=E.pid,G=g.pesData,j=E.pesData,q=!1,ie=this.pmtParsed,ce=this._pmtId,ve=x.length;if(this.remainderData&&(x=Object(M.appendUint8Array)(this.remainderData,x),ve=x.length,this.remainderData=null),ve<188&&!s)return this.remainderData=x,{audioTrack:g,avcTrack:v,id3Track:E,textTrack:this._txtTrack};var ke=Math.max(0,y.syncOffset(x));ve-=(ve+ke)%188,ve<x.byteLength&&!s&&(this.remainderData=new Uint8Array(x.buffer,ve,x.buffer.byteLength-ve));for(var xe=ke;xe<ve;xe+=188)if(x[xe]===71){var Ce=!!(x[xe+1]&64),Te=((x[xe+1]&31)<<8)+x[xe+2],Ee=(x[xe+3]&48)>>4,pe=void 0;if(Ee>1){if(pe=xe+5+x[xe+4],pe===xe+188)continue}else pe=xe+4;switch(Te){case _:Ce&&(H&&(a=o(H))&&this.parseAVCPES(a,!1),H={data:[],size:0}),H&&(H.data.push(x.subarray(pe,xe+188)),H.size+=xe+188-pe);break;case V:Ce&&(G&&(a=o(G))&&(g.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),G={data:[],size:0}),G&&(G.data.push(x.subarray(pe,xe+188)),G.size+=xe+188-pe);break;case Z:Ce&&(j&&(a=o(j))&&this.parseID3PES(a),j={data:[],size:0}),j&&(j.data.push(x.subarray(pe,xe+188)),j.size+=xe+188-pe);break;case 0:Ce&&(pe+=x[pe]+1),ce=this._pmtId=S(x,pe);break;case ce:{Ce&&(pe+=x[pe]+1);var se=h(x,pe,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,c);_=se.avc,_>0&&(v.pid=_),V=se.audio,V>0&&(g.pid=V,g.isAAC=se.isAAC),Z=se.id3,Z>0&&(E.pid=Z),q&&!ie&&(b.logger.log("reparse from beginning"),q=!1,xe=ke-188),ie=this.pmtParsed=!0;break}case 17:case 8191:break;default:q=!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"});v.pesData=H,g.pesData=G,E.pesData=j;var Le={audioTrack:g,avcTrack:v,id3Track:E,textTrack:this._txtTrack};return s&&this.extractRemainingSamples(Le),Le},f.flush=function(){var x=this.remainderData;this.remainderData=null;var p;return x?p=this.demux(x,-1,!1,!0):p={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(p),this.sampleAes?this.decrypt(p,this.sampleAes):p},f.extractRemainingSamples=function(x){var p=x.audioTrack,c=x.avcTrack,s=x.id3Track,a=c.pesData,v=p.pesData,g=s.pesData,E;a&&(E=o(a))?(this.parseAVCPES(E,!0),c.pesData=null):c.pesData=a,v&&(E=o(v))?(p.isAAC?this.parseAACPES(E):this.parseMPEGPES(E),p.pesData=null):(v!=null&&v.size&&b.logger.log("last AAC PES packet truncated,might overlap between fragments"),p.pesData=v),g&&(E=o(g))?(this.parseID3PES(E),s.pesData=null):s.pesData=g},f.demuxSampleAes=function(x,p,c){var s=this.demux(x,c,!0,!this.config.progressive),a=this.sampleAes=new U.default(this.observer,this.config,p);return this.decrypt(s,a)},f.decrypt=function(x,p){return new Promise(function(c){var s=x.audioTrack,a=x.avcTrack;s.samples&&s.isAAC?p.decryptAacSamples(s.samples,0,function(){a.samples?p.decryptAvcSamples(a.samples,0,0,function(){c(x)}):c(x)}):a.samples&&p.decryptAvcSamples(a.samples,0,0,function(){c(x)})})},f.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},f.parseAVCPES=function(x,p){var c=this,s=this._avcTrack,a=this.parseAVCNALu(x.data),v=!1,g=this.avcSample,E,_=!1;x.data=null,g&&a.length&&!s.audFound&&(u(g,s),g=this.avcSample=w(!1,x.pts,x.dts,"")),a.forEach(function(H){switch(H.type){case 1:{E=!0,g||(g=c.avcSample=w(!0,x.pts,x.dts,"")),v&&(g.debug+="NDR "),g.frame=!0;var V=H.data;if(_&&V.length>4){var Z=new I.default(V).readSliceType();(Z===2||Z===4||Z===7||Z===9)&&(g.key=!0)}break}case 5:E=!0,g||(g=c.avcSample=w(!0,x.pts,x.dts,"")),v&&(g.debug+="IDR "),g.key=!0,g.frame=!0;break;case 6:{E=!0,v&&g&&(g.debug+="SEI ");var G=new I.default(T(H.data));G.readUByte();for(var j=0,q=0,ie=!1,ce=0;!ie&&G.bytesAvailable>1;){j=0;do ce=G.readUByte(),j+=ce;while(ce===255);q=0;do ce=G.readUByte(),q+=ce;while(ce===255);if(j===4&&G.bytesAvailable!==0){ie=!0;var ve=G.readUByte();if(ve===181){var ke=G.readUShort();if(ke===49){var xe=G.readUInt();if(xe===1195456820){var Ce=G.readUByte();if(Ce===3){for(var Te=G.readUByte(),Ee=G.readUByte(),pe=31&Te,se=[Te,Ee],Le=0;Le<pe;Le++)se.push(G.readUByte()),se.push(G.readUByte()),se.push(G.readUByte());d(c._txtTrack.samples,{type:3,pts:x.pts,bytes:se})}}}}}else if(j===5&&G.bytesAvailable!==0){if(ie=!0,q>16){for(var Xe=[],Ge=0;Ge<16;Ge++)Xe.push(G.readUByte().toString(16)),(Ge===3||Ge===5||Ge===7||Ge===9)&&Xe.push("-");for(var Ke=q-16,Ve=new Uint8Array(Ke),De=0;De<Ke;De++)Ve[De]=G.readUByte();d(c._txtTrack.samples,{pts:x.pts,payloadType:j,uuid:Xe.join(""),userData:Object(z.utf8ArrayToStr)(Ve),userDataBytes:Ve})}}else if(q<G.bytesAvailable)for(var Pe=0;Pe<q;Pe++)G.readUByte()}break}case 7:if(E=!0,_=!0,v&&g&&(g.debug+="SPS "),!s.sps){var He=new I.default(H.data),$e=He.readSPS();s.width=$e.width,s.height=$e.height,s.pixelRatio=$e.pixelRatio,s.sps=[H.data],s.duration=c._duration;for(var Fe=H.data.subarray(1,4),Ne="avc1.",Me=0;Me<3;Me++){var at=Fe[Me].toString(16);at.length<2&&(at="0"+at),Ne+=at}s.codec=Ne}break;case 8:E=!0,v&&g&&(g.debug+="PPS "),s.pps||(s.pps=[H.data]);break;case 9:E=!1,s.audFound=!0,g&&u(g,s),g=c.avcSample=w(!1,x.pts,x.dts,v?"AUD ":"");break;case 12:E=!1;break;default:E=!1,g&&(g.debug+="unknown NAL "+H.type+" ");break}if(g&&E){var qe=g.units;qe.push(H)}}),p&&g&&(u(g,s),this.avcSample=null)},f.getLastNalUnit=function(){var x,p=this.avcSample,c;if(!p||p.units.length===0){var s=this._avcTrack.samples;p=s[s.length-1]}if((x=p)!==null&&x!==void 0&&x.units){var a=p.units;c=a[a.length-1]}return c},f.parseAVCNALu=function(x){var p=x.byteLength,c=this._avcTrack,s=c.naluState||0,a=s,v=[],g=0,E,_,H,V=-1,Z=0;for(s===-1&&(V=0,Z=x[0]&31,s=0,g=1);g<p;){if(E=x[g++],!s){s=E?0:1;continue}if(s===1){s=E?0:2;continue}if(!E)s=3;else if(E===1){if(V>=0){var G={data:x.subarray(V,g-s-1),type:Z};v.push(G)}else{var j=this.getLastNalUnit();if(j&&(a&&g<=4-a&&(j.state&&(j.data=j.data.subarray(0,j.data.byteLength-a))),_=g-s-1,_>0)){var q=new Uint8Array(j.data.byteLength+_);q.set(j.data,0),q.set(x.subarray(0,_),j.data.byteLength),j.data=q,j.state=0}}g<p?(H=x[g]&31,V=g,Z=H,s=0):s=-1}else s=0}if(V>=0&&s>=0){var ie={data:x.subarray(V,p),type:Z,state:s};v.push(ie)}if(v.length===0){var ce=this.getLastNalUnit();if(ce){var ve=new Uint8Array(ce.data.byteLength+x.byteLength);ve.set(ce.data,0),ve.set(x,ce.data.byteLength),ce.data=ve}}return c.naluState=s,v},f.parseAACPES=function(x){var p=0,c=this._audioTrack,s=this.aacOverFlow,a=x.data;if(s){this.aacOverFlow=null;var v=s.sample.unit.byteLength,g=Math.min(s.missing,v),E=v-g;s.sample.unit.set(a.subarray(0,g),E),c.samples.push(s.sample),p=s.missing}var _,H;for(_=p,H=a.length;_<H-1&&!X.isHeader(a,_);_++);if(_!==p){var V,Z;if(_<H-1?(V="AAC PES did not start with ADTS header,offset:"+_,Z=!1):(V="no ADTS header found in AAC PES",Z=!0),b.logger.warn("parsing error:"+V),this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:Z,reason:V}),Z)return}X.initTrackConfig(c,this.observer,a,_,this.audioCodec);var G;if(x.pts!==void 0)G=x.pts;else if(s){var j=X.getFrameDuration(c.samplerate);G=s.sample.pts+j}else{b.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var q=0;_<H;)if(X.isHeader(a,_)){if(_+5<H){var ie=X.appendFrame(c,a,_,G,q);if(ie)if(ie.missing)this.aacOverFlow=ie;else{_+=ie.length,q++;continue}}break}else _++},f.parseMPEGPES=function(x){var p=x.data,c=p.length,s=0,a=0,v=x.pts;if(v===void 0){b.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<c;)if(N.isHeader(p,a)){var g=N.appendFrame(this._audioTrack,p,a,v,s);if(g)a+=g.length,s++;else break}else a++},f.parseID3PES=function(x){if(x.pts===void 0){b.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(x)},y}();L.minProbeByteLength=188;function w(y,f,k,x){return{key:y,frame:!1,pts:f,dts:k,units:[],debug:x,length:0}}function S(y,f){return(y[f+10]&31)<<8|y[f+11]}function h(y,f,k,x){var p={audio:-1,avc:-1,id3:-1,isAAC:!0},c=(y[f+1]&15)<<8|y[f+2],s=f+3+c-4,a=(y[f+10]&15)<<8|y[f+11];for(f+=12+a;f<s;){var v=(y[f+1]&31)<<8|y[f+2];switch(y[f]){case 207:if(!x){b.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:p.audio===-1&&(p.audio=v);break;case 21:p.id3===-1&&(p.id3=v);break;case 219:if(!x){b.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:p.avc===-1&&(p.avc=v);break;case 3:case 4:k?p.audio===-1&&(p.audio=v,p.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}f+=((y[f+3]&15)<<8|y[f+4])+5}return p}function o(y){var f=0,k,x,p,c,s,a=y.data;if(!y||y.size===0)return null;for(;a[0].length<19&&a.length>1;){var v=new Uint8Array(a[0].length+a[1].length);v.set(a[0]),v.set(a[1],a[0].length),a[0]=v,a.splice(1,1)}k=a[0];var g=(k[0]<<16)+(k[1]<<8)+k[2];if(g===1){if(x=(k[4]<<8)+k[5],x&&x>y.size-6)return null;var E=k[7];E&192&&(c=(k[9]&14)*536870912+(k[10]&255)*4194304+(k[11]&254)*16384+(k[12]&255)*128+(k[13]&254)/2,E&64?(s=(k[14]&14)*536870912+(k[15]&255)*4194304+(k[16]&254)*16384+(k[17]&255)*128+(k[18]&254)/2,c-s>60*9e4&&(b.logger.warn(Math.round((c-s)/9e4)+"s delta between PTS and DTS, align them"),c=s)):s=c),p=k[8];var _=p+9;if(y.size<=_)return null;y.size-=_;for(var H=new Uint8Array(y.size),V=0,Z=a.length;V<Z;V++){k=a[V];var G=k.byteLength;if(_)if(_>G){_-=G;continue}else k=k.subarray(_),G-=_,_=0;H.set(k,f),f+=G}return x&&(x-=p+3),{data:H,pts:c,dts:s,len:x}}return null}function u(y,f){if(y.units.length&&y.frame){if(y.pts===void 0){var k=f.samples,x=k.length;if(x){var p=k[x-1];y.pts=p.pts,y.dts=p.dts}else{f.dropped++;return}}f.samples.push(y)}y.debug.length&&b.logger.log(y.pts+"/"+y.dts+":"+y.debug)}function d(y,f){var k=y.length;if(k>0){if(f.pts>=y[k-1].pts)y.push(f);else for(var x=k-1;x>=0;x--)if(f.pts<y[x].pts){y.splice(x,0,f);break}}else y.push(f)}function T(y){for(var f=y.byteLength,k=[],x=1;x<f-2;)y[x]===0&&y[x+1]===0&&y[x+2]===3?(k.push(x+2),x+=2):x++;if(k.length===0)return y;var p=f-k.length,c=new Uint8Array(p),s=0;for(x=0;x<p;s++,x++)s===k[0]&&(s++,k.shift()),c[x]=y[s];return c}$.default=L},"./src/errors.ts":function(ne,$,D){"use strict";D.r($),D.d($,"ErrorTypes",function(){return X}),D.d($,"ErrorDetails",function(){return N});var X;(function(I){I.NETWORK_ERROR="networkError",I.MEDIA_ERROR="mediaError",I.KEY_SYSTEM_ERROR="keySystemError",I.MUX_ERROR="muxError",I.OTHER_ERROR="otherError"})(X||(X={}));var N;(function(I){I.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",I.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",I.KEY_SYSTEM_NO_SESSION="keySystemNoSession",I.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",I.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",I.MANIFEST_LOAD_ERROR="manifestLoadError",I.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",I.MANIFEST_PARSING_ERROR="manifestParsingError",I.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",I.LEVEL_EMPTY_ERROR="levelEmptyError",I.LEVEL_LOAD_ERROR="levelLoadError",I.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",I.LEVEL_SWITCH_ERROR="levelSwitchError",I.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",I.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",I.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",I.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",I.FRAG_LOAD_ERROR="fragLoadError",I.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",I.FRAG_DECRYPT_ERROR="fragDecryptError",I.FRAG_PARSING_ERROR="fragParsingError",I.REMUX_ALLOC_ERROR="remuxAllocError",I.KEY_LOAD_ERROR="keyLoadError",I.KEY_LOAD_TIMEOUT="keyLoadTimeOut",I.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",I.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",I.BUFFER_APPEND_ERROR="bufferAppendError",I.BUFFER_APPENDING_ERROR="bufferAppendingError",I.BUFFER_STALLED_ERROR="bufferStalledError",I.BUFFER_FULL_ERROR="bufferFullError",I.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",I.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",I.INTERNAL_EXCEPTION="internalException",I.INTERNAL_ABORTED="aborted",I.UNKNOWN="unknown"})(N||(N={}))},"./src/events.ts":function(ne,$,D){"use strict";D.r($),D.d($,"Events",function(){return X});var X;(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"})(X||(X={}))},"./src/hls.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return y});var X=D("./node_modules/url-toolkit/src/url-toolkit.js"),N=D.n(X),I=D("./src/loader/playlist-loader.ts"),z=D("./src/loader/key-loader.ts"),U=D("./src/controller/id3-track-controller.ts"),P=D("./src/controller/latency-controller.ts"),M=D("./src/controller/level-controller.ts"),b=D("./src/controller/fragment-tracker.ts"),A=D("./src/controller/stream-controller.ts"),R=D("./src/is-supported.ts"),L=D("./src/utils/logger.ts"),w=D("./src/config.ts"),S=D("./node_modules/eventemitter3/index.js"),h=D.n(S),o=D("./src/events.ts"),u=D("./src/errors.ts");function d(f,k){for(var x=0;x<k.length;x++){var p=k[x];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(f,p.key,p)}}function T(f,k,x){return k&&d(f.prototype,k),x&&d(f,x),f}var y=function(){f.isSupported=function(){return Object(R.isSupported)()};function f(x){x===void 0&&(x={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new S.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 p=this.config=Object(w.mergeConfig)(f.DefaultConfig,x);this.userConfig=x,Object(L.enableLogs)(p.debug),this._autoLevelCapping=-1,p.progressive&&Object(w.enableStreamingMode)(p);var c=p.abrController,s=p.bufferController,a=p.capLevelController,v=p.fpsController,g=this.abrController=new c(this),E=this.bufferController=new s(this),_=this.capLevelController=new a(this),H=new v(this),V=new I.default(this),Z=new z.default(this),G=new U.default(this),j=this.levelController=new M.default(this),q=new b.FragmentTracker(this),ie=this.streamController=new A.default(this,q);_.setStreamController(ie),H.setStreamController(ie);var ce=[j,ie];this.networkControllers=ce;var ve=[V,Z,g,E,_,H,G,q];this.audioTrackController=this.createController(p.audioTrackController,null,ce),this.createController(p.audioStreamController,q,ce),this.subtitleTrackController=this.createController(p.subtitleTrackController,null,ce),this.createController(p.subtitleStreamController,q,ce),this.createController(p.timelineController,null,ve),this.emeController=this.createController(p.emeController,null,ve),this.cmcdController=this.createController(p.cmcdController,null,ve),this.latencyController=this.createController(P.default,null,ve),this.coreComponents=ve}var k=f.prototype;return k.createController=function(p,c,s){if(p){var a=c?new p(this,c):new p(this);return s&&s.push(a),a}return null},k.on=function(p,c,s){s===void 0&&(s=this),this._emitter.on(p,c,s)},k.once=function(p,c,s){s===void 0&&(s=this),this._emitter.once(p,c,s)},k.removeAllListeners=function(p){this._emitter.removeAllListeners(p)},k.off=function(p,c,s,a){s===void 0&&(s=this),this._emitter.off(p,c,s,a)},k.listeners=function(p){return this._emitter.listeners(p)},k.emit=function(p,c,s){return this._emitter.emit(p,c,s)},k.trigger=function(p,c){if(this.config.debug)return this.emit(p,p,c);try{return this.emit(p,p,c)}catch(s){L.logger.error("An internal error happened while handling event "+p+'. Error message: "'+s.message+'". Here is a stacktrace:',s),this.trigger(o.Events.ERROR,{type:u.ErrorTypes.OTHER_ERROR,details:u.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:p,error:s})}return!1},k.listenerCount=function(p){return this._emitter.listenerCount(p)},k.destroy=function(){L.logger.log("destroy"),this.trigger(o.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(p){return p.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(p){return p.destroy()}),this.coreComponents.length=0},k.attachMedia=function(p){L.logger.log("attachMedia"),this._media=p,this.trigger(o.Events.MEDIA_ATTACHING,{media:p})},k.detachMedia=function(){L.logger.log("detachMedia"),this.trigger(o.Events.MEDIA_DETACHING,void 0),this._media=null},k.loadSource=function(p){this.stopLoad();var c=this.media,s=this.url,a=this.url=X.buildAbsoluteURL(self.location.href,p,{alwaysNormalize:!0});L.logger.log("loadSource:"+a),c&&s&&s!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(c)),this.trigger(o.Events.MANIFEST_LOADING,{url:p})},k.startLoad=function(p){p===void 0&&(p=-1),L.logger.log("startLoad("+p+")"),this.networkControllers.forEach(function(c){c.startLoad(p)})},k.stopLoad=function(){L.logger.log("stopLoad"),this.networkControllers.forEach(function(p){p.stopLoad()})},k.swapAudioCodec=function(){L.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},k.recoverMediaError=function(){L.logger.log("recoverMediaError");var p=this._media;this.detachMedia(),p&&this.attachMedia(p)},k.removeLevel=function(p,c){c===void 0&&(c=0),this.levelController.removeLevel(p,c)},T(f,[{key:"levels",get:function(){var p=this.levelController.levels;return p||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(p){L.logger.log("set currentLevel:"+p),this.loadLevel=p,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(p){L.logger.log("set nextLevel:"+p),this.levelController.manualLevel=p,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(p){L.logger.log("set loadLevel:"+p),this.levelController.manualLevel=p}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(p){this.levelController.nextLoadLevel=p}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(p){L.logger.log("set firstLevel:"+p),this.levelController.firstLevel=p}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(p){L.logger.log("set startLevel:"+p),p!==-1&&(p=Math.max(p,this.minAutoLevel)),this.levelController.startLevel=p}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(p){var c=!!p;c!==this.config.capLevelToPlayerSize&&(c?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=c)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(p){this._autoLevelCapping!==p&&(L.logger.log("set autoLevelCapping:"+p),this._autoLevelCapping=p)}},{key:"bandwidthEstimate",get:function(){var p=this.abrController.bwEstimator;return p?p.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var p=this.levels,c=this.config.minAutoBitrate;if(!p)return 0;for(var s=p.length,a=0;a<s;a++)if(p[a].maxBitrate>c)return a;return 0}},{key:"maxAutoLevel",get:function(){var p=this.levels,c=this.autoLevelCapping,s;return c===-1&&p&&p.length?s=p.length-1:s=c,s}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(p){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,p)}},{key:"audioTracks",get:function(){var p=this.audioTrackController;return p?p.audioTracks:[]}},{key:"audioTrack",get:function(){var p=this.audioTrackController;return p?p.audioTrack:-1},set:function(p){var c=this.audioTrackController;c&&(c.audioTrack=p)}},{key:"subtitleTracks",get:function(){var p=this.subtitleTrackController;return p?p.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var p=this.subtitleTrackController;return p?p.subtitleTrack:-1},set:function(p){var c=this.subtitleTrackController;c&&(c.subtitleTrack=p)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var p=this.subtitleTrackController;return p?p.subtitleDisplay:!1},set:function(p){var c=this.subtitleTrackController;c&&(c.subtitleDisplay=p)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(p){this.config.lowLatencyMode=p}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return o.Events}},{key:"ErrorTypes",get:function(){return u.ErrorTypes}},{key:"ErrorDetails",get:function(){return u.ErrorDetails}},{key:"DefaultConfig",get:function(){return f.defaultConfig?f.defaultConfig:w.hlsDefaultConfig},set:function(p){f.defaultConfig=p}}]),f}();y.defaultConfig=void 0},"./src/is-supported.ts":function(ne,$,D){"use strict";D.r($),D.d($,"isSupported",function(){return I}),D.d($,"changeTypeSupported",function(){return z});var X=D("./src/utils/mediasource-helper.ts");function N(){return self.SourceBuffer||self.WebKitSourceBuffer}function I(){var U=Object(X.getMediaSource)();if(!U)return!1;var P=N(),M=U&&typeof U.isTypeSupported=="function"&&U.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),b=!P||P.prototype&&typeof P.prototype.appendBuffer=="function"&&typeof P.prototype.remove=="function";return!!M&&!!b}function z(){var U,P=N();return typeof(P==null||((U=P.prototype)===null||U===void 0)?void 0:U.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return L}),D.d($,"LoadError",function(){return S});var X=D("./src/polyfills/number.ts"),N=D("./src/errors.ts");function I(h,o){h.prototype=Object.create(o.prototype),h.prototype.constructor=h,b(h,o)}function z(h){var o=typeof Map=="function"?new Map:void 0;return z=function(d){if(d===null||!M(d))return d;if(typeof d!="function")throw new TypeError("Super expression must either be null or a function");if(typeof o!="undefined"){if(o.has(d))return o.get(d);o.set(d,T)}function T(){return U(d,arguments,A(this).constructor)}return T.prototype=Object.create(d.prototype,{constructor:{value:T,enumerable:!1,writable:!0,configurable:!0}}),b(T,d)},z(h)}function U(h,o,u){return P()?U=Reflect.construct:U=function(T,y,f){var k=[null];k.push.apply(k,y);var x=Function.bind.apply(T,k),p=new x;return f&&b(p,f.prototype),p},U.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(h){return!1}}function M(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function b(h,o){return b=Object.setPrototypeOf||function(d,T){return d.__proto__=T,d},b(h,o)}function A(h){return A=Object.setPrototypeOf?Object.getPrototypeOf:function(u){return u.__proto__||Object.getPrototypeOf(u)},A(h)}var R=Math.pow(2,17),L=function(){function h(u){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=u}var o=h.prototype;return o.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},o.abort=function(){this.loader&&this.loader.abort()},o.load=function(d,T){var y=this,f=d.url;if(!f)return Promise.reject(new S({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,networkDetails:null},"Fragment does not have a "+(f?"part list":"url")));this.abort();var k=this.config,x=k.fLoader,p=k.loader;return new Promise(function(c,s){y.loader&&y.loader.destroy();var a=y.loader=d.loader=x?new x(k):new p(k),v=w(d),g={timeout:k.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:k.fragLoadingMaxRetryTimeout,highWaterMark:R};d.stats=a.stats,a.load(v,g,{onSuccess:function(_,H,V,Z){y.resetLoader(d,a),c({frag:d,part:null,payload:_.data,networkDetails:Z})},onError:function(_,H,V){y.resetLoader(d,a),s(new S({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,response:_,networkDetails:V}))},onAbort:function(_,H,V){y.resetLoader(d,a),s(new S({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:d,networkDetails:V}))},onTimeout:function(_,H,V){y.resetLoader(d,a),s(new S({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:d,networkDetails:V}))},onProgress:function(_,H,V,Z){T&&T({frag:d,part:null,payload:V,networkDetails:Z})}})})},o.loadPart=function(d,T,y){var f=this;this.abort();var k=this.config,x=k.fLoader,p=k.loader;return new Promise(function(c,s){f.loader&&f.loader.destroy();var a=f.loader=d.loader=x?new x(k):new p(k),v=w(d,T),g={timeout:k.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:k.fragLoadingMaxRetryTimeout,highWaterMark:R};T.stats=a.stats,a.load(v,g,{onSuccess:function(_,H,V,Z){f.resetLoader(d,a),f.updateStatsFromPart(d,T);var G={frag:d,part:T,payload:_.data,networkDetails:Z};y(G),c(G)},onError:function(_,H,V){f.resetLoader(d,a),s(new S({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,part:T,response:_,networkDetails:V}))},onAbort:function(_,H,V){d.stats.aborted=T.stats.aborted,f.resetLoader(d,a),s(new S({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:d,part:T,networkDetails:V}))},onTimeout:function(_,H,V){f.resetLoader(d,a),s(new S({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:d,part:T,networkDetails:V}))}})})},o.updateStatsFromPart=function(d,T){var y=d.stats,f=T.stats,k=f.total;if(y.loaded+=f.loaded,k){var x=Math.round(d.duration/T.duration),p=Math.min(Math.round(y.loaded/k),x),c=x-p,s=c*Math.round(y.loaded/p);y.total=y.loaded+s}else y.total=Math.max(y.loaded,y.total);var a=y.loading,v=f.loading;a.start?a.first+=v.first-v.start:(a.start=v.start,a.first=v.first),a.end=v.end},o.resetLoader=function(d,T){d.loader=null,this.loader===T&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),T.destroy()},h}();function w(h,o){o===void 0&&(o=null);var u=o||h,d={frag:h,part:o,responseType:"arraybuffer",url:u.url,headers:{},rangeStart:0,rangeEnd:0},T=u.byteRangeStartOffset,y=u.byteRangeEndOffset;return Object(X.isFiniteNumber)(T)&&Object(X.isFiniteNumber)(y)&&(d.rangeStart=T,d.rangeEnd=y),d}var S=function(h){I(o,h);function o(u){for(var d,T=arguments.length,y=new Array(T>1?T-1:0),f=1;f<T;f++)y[f-1]=arguments[f];return d=h.call.apply(h,[this].concat(y))||this,d.data=void 0,d.data=u,d}return o}(z(Error))},"./src/loader/fragment.ts":function(ne,$,D){"use strict";D.r($),D.d($,"ElementaryStreamTypes",function(){return L}),D.d($,"BaseSegment",function(){return w}),D.d($,"Fragment",function(){return S}),D.d($,"Part",function(){return h});var X=D("./src/polyfills/number.ts"),N=D("./node_modules/url-toolkit/src/url-toolkit.js"),I=D.n(N),z=D("./src/utils/logger.ts"),U=D("./src/loader/level-key.ts"),P=D("./src/loader/load-stats.ts");function M(o,u){o.prototype=Object.create(u.prototype),o.prototype.constructor=o,b(o,u)}function b(o,u){return b=Object.setPrototypeOf||function(T,y){return T.__proto__=y,T},b(o,u)}function A(o,u){for(var d=0;d<u.length;d++){var T=u[d];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(o,T.key,T)}}function R(o,u,d){return u&&A(o.prototype,u),d&&A(o,d),o}var L;(function(o){o.AUDIO="audio",o.VIDEO="video",o.AUDIOVIDEO="audiovideo"})(L||(L={}));var w=function(){function o(d){var T;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(T={},T[L.AUDIO]=null,T[L.VIDEO]=null,T[L.AUDIOVIDEO]=null,T),this.baseurl=d}var u=o.prototype;return u.setByteRange=function(T,y){var f=T.split("@",2),k=[];f.length===1?k[0]=y?y.byteRangeEndOffset:0:k[0]=parseInt(f[1]),k[1]=parseInt(f[0])+k[0],this._byteRange=k},R(o,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(N.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(T){this._url=T}}]),o}(),S=function(o){M(u,o);function u(T,y){var f;return f=o.call(this,y)||this,f._decryptdata=null,f.rawProgramDateTime=null,f.programDateTime=null,f.tagList=[],f.duration=0,f.sn=0,f.levelkey=void 0,f.type=void 0,f.loader=null,f.level=-1,f.cc=0,f.startPTS=void 0,f.endPTS=void 0,f.appendedPTS=void 0,f.startDTS=void 0,f.endDTS=void 0,f.start=0,f.deltaPTS=void 0,f.maxStartPTS=void 0,f.minEndPTS=void 0,f.stats=new P.LoadStats,f.urlId=0,f.data=void 0,f.bitrateTest=!1,f.title=null,f.initSegment=null,f.type=T,f}var d=u.prototype;return d.createInitializationVector=function(y){for(var f=new Uint8Array(16),k=12;k<16;k++)f[k]=y>>8*(15-k)&255;return f},d.setDecryptDataFromLevelKey=function(y,f){var k=y;return(y==null?void 0:y.method)==="AES-128"&&y.uri&&!y.iv&&(k=U.LevelKey.fromURI(y.uri),k.method=y.method,k.iv=this.createInitializationVector(f),k.keyFormat="identity"),k},d.setElementaryStreamInfo=function(y,f,k,x,p,c){c===void 0&&(c=!1);var s=this.elementaryStreams,a=s[y];if(!a){s[y]={startPTS:f,endPTS:k,startDTS:x,endDTS:p,partial:c};return}a.startPTS=Math.min(a.startPTS,f),a.endPTS=Math.max(a.endPTS,k),a.startDTS=Math.min(a.startDTS,x),a.endDTS=Math.max(a.endDTS,p)},d.clearElementaryStreamInfo=function(){var y=this.elementaryStreams;y[L.AUDIO]=null,y[L.VIDEO]=null,y[L.AUDIOVIDEO]=null},R(u,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var y=this.sn;typeof y!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&z.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),y=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,y)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(X.isFiniteNumber)(this.programDateTime))return null;var y=Object(X.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+y*1e3}},{key:"encrypted",get:function(){var y;return!!((y=this.decryptdata)!==null&&y!==void 0&&y.keyFormat&&this.decryptdata.uri)}}]),u}(w),h=function(o){M(u,o);function u(d,T,y,f,k){var x;x=o.call(this,y)||this,x.fragOffset=0,x.duration=0,x.gap=!1,x.independent=!1,x.relurl=void 0,x.fragment=void 0,x.index=void 0,x.stats=new P.LoadStats,x.duration=d.decimalFloatingPoint("DURATION"),x.gap=d.bool("GAP"),x.independent=d.bool("INDEPENDENT"),x.relurl=d.enumeratedString("URI"),x.fragment=T,x.index=f;var p=d.enumeratedString("BYTERANGE");return p&&x.setByteRange(p,k),k&&(x.fragOffset=k.fragOffset+k.duration),x}return R(u,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var T=this.elementaryStreams;return!!(T.audio||T.video||T.audiovideo)}}]),u}(w)},"./src/loader/key-loader.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return z});var X=D("./src/events.ts"),N=D("./src/errors.ts"),I=D("./src/utils/logger.ts"),z=function(){function U(M){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=M,this._registerListeners()}var P=U.prototype;return P._registerListeners=function(){this.hls.on(X.Events.KEY_LOADING,this.onKeyLoading,this)},P._unregisterListeners=function(){this.hls.off(X.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 R=A.frag,L=R.type,w=this.loaders[L];if(!R.decryptdata){I.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var S=R.decryptdata.uri;if(S!==this.decrypturl||this.decryptkey===null){var h=this.hls.config;if(w&&(I.logger.warn("abort previous key loader for type:"+L),w.abort()),!S){I.logger.warn("key uri is falsy");return}var o=h.loader,u=R.loader=this.loaders[L]=new o(h);this.decrypturl=S,this.decryptkey=null;var d={url:S,frag:R,responseType:"arraybuffer"},T={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:h.fragLoadingRetryDelay,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:0},y={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};u.load(d,T,y)}else this.decryptkey&&(R.decryptdata.key=this.decryptkey,this.hls.trigger(X.Events.KEY_LOADED,{frag:R}))},P.loadsuccess=function(b,A,R){var L=R.frag;if(!L.decryptdata){I.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(X.Events.KEY_LOADED,{frag:L})},P.loaderror=function(b,A){var R=A.frag,L=R.loader;L&&L.abort(),delete this.loaders[R.type],this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:R,response:b})},P.loadtimeout=function(b,A){var R=A.frag,L=R.loader;L&&L.abort(),delete this.loaders[R.type],this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:R})},U}()},"./src/loader/level-details.ts":function(ne,$,D){"use strict";D.r($),D.d($,"LevelDetails",function(){return U});var X=D("./src/polyfills/number.ts");function N(P,M){for(var b=0;b<M.length;b++){var A=M[b];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(P,A.key,A)}}function I(P,M,b){return M&&N(P.prototype,M),b&&N(P,b),P}var z=10,U=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 M=P.prototype;return M.reloaded=function(A){if(!A){this.advanced=!0,this.updated=!0;return}var R=this.lastPartSn-A.lastPartSn,L=this.lastPartIndex-A.lastPartIndex;this.updated=this.endSN!==A.endSN||!!L||!!R,this.advanced=this.endSN>A.endSN||R>0||R===0&&L>0,this.updated||this.advanced?this.misses=Math.floor(A.misses*.6):this.misses=A.misses+1,this.availabilityDelay=A.availabilityDelay},I(P,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(X.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||z}},{key:"drift",get:function(){var A=this.driftEndTime-this.driftStartTime;if(A>0){var R=this.driftEnd-this.driftStart;return R*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,$,D){"use strict";D.r($),D.d($,"LevelKey",function(){return U});var X=D("./node_modules/url-toolkit/src/url-toolkit.js"),N=D.n(X);function I(P,M){for(var b=0;b<M.length;b++){var A=M[b];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(P,A.key,A)}}function z(P,M,b){return M&&I(P.prototype,M),b&&I(P,b),P}var U=function(){P.fromURL=function(b,A){return new P(b,A)},P.fromURI=function(b){return new P(b)};function P(M,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(X.buildAbsoluteURL)(M,b,{alwaysNormalize:!0}):this._uri=M}return z(P,[{key:"uri",get:function(){return this._uri}}]),P}()},"./src/loader/load-stats.ts":function(ne,$,D){"use strict";D.r($),D.d($,"LoadStats",function(){return X});var X=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,$,D){"use strict";D.r($),D.d($,"default",function(){return u});var X=D("./src/polyfills/number.ts"),N=D("./node_modules/url-toolkit/src/url-toolkit.js"),I=D.n(N),z=D("./src/loader/fragment.ts"),U=D("./src/loader/level-details.ts"),P=D("./src/loader/level-key.ts"),M=D("./src/utils/attr-list.ts"),b=D("./src/utils/logger.ts"),A=D("./src/utils/codecs.ts"),R=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,L=/#EXT-X-MEDIA:(.*)/g,w=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),S=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("|")),h=/\.(mp4|m4s|m4v|m4a)$/i;function o(k){var x,p;return h.test((x=(p=N.parseURL(k))===null||p===void 0?void 0:p.path)!=null?x:"")}var u=function(){function k(){}return k.findGroup=function(p,c){for(var s=0;s<p.length;s++){var a=p[s];if(a.id===c)return a}},k.convertAVC1ToAVCOTI=function(p){var c=p.split(".");if(c.length>2){var s=c.shift()+".";return s+=parseInt(c.shift()).toString(16),s+=("000"+parseInt(c.shift()).toString(16)).substr(-4),s}return p},k.resolve=function(p,c){return N.buildAbsoluteURL(c,p,{alwaysNormalize:!0})},k.parseMasterPlaylist=function(p,c){var s=[],a={},v=!1;R.lastIndex=0;for(var g;(g=R.exec(p))!=null;)if(g[1]){var E=new M.AttrList(g[1]),_={attrs:E,bitrate:E.decimalInteger("AVERAGE-BANDWIDTH")||E.decimalInteger("BANDWIDTH"),name:E.NAME,url:k.resolve(g[2],c)},H=E.decimalResolution("RESOLUTION");H&&(_.width=H.width,_.height=H.height),d((E.CODECS||"").split(/[ ,]+/).filter(function(Z){return Z}),_),_.videoCodec&&_.videoCodec.indexOf("avc1")!==-1&&(_.videoCodec=k.convertAVC1ToAVCOTI(_.videoCodec)),s.push(_)}else if(g[3]){var V=new M.AttrList(g[3]);V["DATA-ID"]&&(v=!0,a[V["DATA-ID"]]=V)}return{levels:s,sessionData:v?a:null}},k.parseMasterPlaylistMedia=function(p,c,s,a){a===void 0&&(a=[]);var v,g=[],E=0;for(L.lastIndex=0;(v=L.exec(p))!==null;){var _=new M.AttrList(v[1]);if(_.TYPE===s){var H={attrs:_,bitrate:0,id:E++,groupId:_["GROUP-ID"],instreamId:_["INSTREAM-ID"],name:_.NAME||_.LANGUAGE||"",type:s,default:_.bool("DEFAULT"),autoselect:_.bool("AUTOSELECT"),forced:_.bool("FORCED"),lang:_.LANGUAGE,url:_.URI?k.resolve(_.URI,c):""};if(a.length){var V=k.findGroup(a,H.groupId)||a[0];T(H,V,"audioCodec"),T(H,V,"textCodec")}g.push(H)}}return g},k.parseLevelPlaylist=function(p,c,s,a,v){var g=new U.LevelDetails(c),E=g.fragments,_=null,H=0,V=0,Z=0,G=0,j=null,q=new z.Fragment(a,c),ie,ce,ve,ke=-1,xe=!1;for(w.lastIndex=0,g.m3u8=p;(ie=w.exec(p))!==null;){xe&&(xe=!1,q=new z.Fragment(a,c),q.start=Z,q.sn=H,q.cc=G,q.level=s,_&&(q.initSegment=_,q.rawProgramDateTime=_.rawProgramDateTime));var Ce=ie[1];if(Ce){q.duration=parseFloat(Ce);var Te=(" "+ie[2]).slice(1);q.title=Te||null,q.tagList.push(Te?["INF",Ce,Te]:["INF",Ce])}else if(ie[3])Object(X.isFiniteNumber)(q.duration)&&(q.start=Z,ve&&(q.levelkey=ve),q.sn=H,q.level=s,q.cc=G,q.urlId=v,E.push(q),q.relurl=(" "+ie[3]).slice(1),f(q,j),j=q,Z+=q.duration,H++,V=0,xe=!0);else if(ie[4]){var Ee=(" "+ie[4]).slice(1);j?q.setByteRange(Ee,j):q.setByteRange(Ee)}else if(ie[5])q.rawProgramDateTime=(" "+ie[5]).slice(1),q.tagList.push(["PROGRAM-DATE-TIME",q.rawProgramDateTime]),ke===-1&&(ke=E.length);else{if(ie=ie[0].match(S),!ie){b.logger.warn("No matches on slow regex match for level playlist!");continue}for(ce=1;ce<ie.length&&!(typeof ie[ce]!="undefined");ce++);var pe=(" "+ie[ce]).slice(1),se=(" "+ie[ce+1]).slice(1),Le=ie[ce+2]?(" "+ie[ce+2]).slice(1):"";switch(pe){case"PLAYLIST-TYPE":g.type=se.toUpperCase();break;case"MEDIA-SEQUENCE":H=g.startSN=parseInt(se);break;case"SKIP":{var Xe=new M.AttrList(se),Ge=Xe.decimalInteger("SKIPPED-SEGMENTS");if(Object(X.isFiniteNumber)(Ge)){g.skippedSegments=Ge;for(var Ke=Ge;Ke--;)E.unshift(null);H+=Ge}var Ve=Xe.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ve&&(g.recentlyRemovedDateranges=Ve.split(" "));break}case"TARGETDURATION":g.targetduration=parseFloat(se);break;case"VERSION":g.version=parseInt(se);break;case"EXTM3U":break;case"ENDLIST":g.live=!1;break;case"#":(se||Le)&&q.tagList.push(Le?[se,Le]:[se]);break;case"DIS":G++;case"GAP":q.tagList.push([pe]);break;case"BITRATE":q.tagList.push([pe,se]);break;case"DISCONTINUITY-SEQ":G=parseInt(se);break;case"KEY":{var De,Pe=new M.AttrList(se),He=Pe.enumeratedString("METHOD"),$e=Pe.URI,Fe=Pe.hexadecimalInteger("IV"),Ne=Pe.enumeratedString("KEYFORMATVERSIONS"),Me=Pe.enumeratedString("KEYID"),at=(De=Pe.enumeratedString("KEYFORMAT"))!=null?De:"identity",qe=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(qe.indexOf(at)>-1){b.logger.warn("Keyformat "+at+" is not supported from the manifest");continue}else if(at!=="identity")continue;He&&(ve=P.LevelKey.fromURL(c,$e),$e&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(He)>=0&&(ve.method=He,ve.keyFormat=at,Me&&(ve.keyID=Me),Ne&&(ve.keyFormatVersions=Ne),ve.iv=Fe));break}case"START":{var Qe=new M.AttrList(se),tt=Qe.decimalFloatingPoint("TIME-OFFSET");Object(X.isFiniteNumber)(tt)&&(g.startTimeOffset=tt);break}case"MAP":{var ut=new M.AttrList(se);q.relurl=ut.URI,ut.BYTERANGE&&q.setByteRange(ut.BYTERANGE),q.level=s,q.sn="initSegment",ve&&(q.levelkey=ve),q.initSegment=null,_=q,xe=!0;break}case"SERVER-CONTROL":{var rt=new M.AttrList(se);g.canBlockReload=rt.bool("CAN-BLOCK-RELOAD"),g.canSkipUntil=rt.optionalFloat("CAN-SKIP-UNTIL",0),g.canSkipDateRanges=g.canSkipUntil>0&&rt.bool("CAN-SKIP-DATERANGES"),g.partHoldBack=rt.optionalFloat("PART-HOLD-BACK",0),g.holdBack=rt.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var it=new M.AttrList(se);g.partTarget=it.decimalFloatingPoint("PART-TARGET");break}case"PART":{var we=g.partList;we||(we=g.partList=[]);var lt=V>0?we[we.length-1]:void 0,et=V++,Ae=new z.Part(new M.AttrList(se),q,c,et,lt);we.push(Ae),q.duration+=Ae.duration;break}case"PRELOAD-HINT":{var Ue=new M.AttrList(se);g.preloadHint=Ue;break}case"RENDITION-REPORT":{var me=new M.AttrList(se);g.renditionReports=g.renditionReports||[],g.renditionReports.push(me);break}default:b.logger.warn("line parsed but not handled: "+ie);break}}}j&&!j.relurl?(E.pop(),Z-=j.duration,g.partList&&(g.fragmentHint=j)):g.partList&&(f(q,j),q.cc=G,g.fragmentHint=q);var he=E.length,fe=E[0],ee=E[he-1];if(Z+=g.skippedSegments*g.targetduration,Z>0&&he&&ee){g.averagetargetduration=Z/he;var te=ee.sn;g.endSN=te!=="initSegment"?te:0,fe&&(g.startCC=fe.cc,fe.initSegment||g.fragments.every(function(ae){return ae.relurl&&o(ae.relurl)})&&(b.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),q=new z.Fragment(a,c),q.relurl=ee.relurl,q.level=s,q.sn="initSegment",fe.initSegment=q,g.needSidxRanges=!0))}else g.endSN=0,g.startCC=0;return g.fragmentHint&&(Z+=g.fragmentHint.duration),g.totalduration=Z,g.endCC=G,ke>0&&y(E,ke),g},k}();function d(k,x){["video","audio","text"].forEach(function(p){var c=k.filter(function(a){return Object(A.isCodecType)(a,p)});if(c.length){var s=c.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});x[p+"Codec"]=s.length>0?s[0]:c[0],k=k.filter(function(a){return c.indexOf(a)===-1})}}),x.unknownCodecs=k}function T(k,x,p){var c=x[p];c&&(k[p]=c)}function y(k,x){for(var p=k[x],c=x;c--;){var s=k[c];if(!s)return;s.programDateTime=p.programDateTime-s.duration*1e3,p=s}}function f(k,x){k.rawProgramDateTime?k.programDateTime=Date.parse(k.rawProgramDateTime):x!=null&&x.programDateTime&&(k.programDateTime=x.endProgramDateTime),Object(X.isFiniteNumber)(k.programDateTime)||(k.programDateTime=null,k.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/polyfills/number.ts"),N=D("./src/events.ts"),I=D("./src/errors.ts"),z=D("./src/utils/logger.ts"),U=D("./src/utils/mp4-tools.ts"),P=D("./src/loader/m3u8-parser.ts"),M=D("./src/types/loader.ts"),b=D("./src/utils/attr-list.ts");function A(w){var S=w.type;switch(S){case M.PlaylistContextType.AUDIO_TRACK:return M.PlaylistLevelType.AUDIO;case M.PlaylistContextType.SUBTITLE_TRACK:return M.PlaylistLevelType.SUBTITLE;default:return M.PlaylistLevelType.MAIN}}function R(w,S){var h=w.url;return(h===void 0||h.indexOf("data:")===0)&&(h=S.url),h}var L=function(){function w(h){this.hls=void 0,this.loaders=Object.create(null),this.hls=h,this.registerListeners()}var S=w.prototype;return S.registerListeners=function(){var o=this.hls;o.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(N.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(N.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.on(N.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},S.unregisterListeners=function(){var o=this.hls;o.off(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(N.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(N.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.off(N.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},S.createInternalLoader=function(o){var u=this.hls.config,d=u.pLoader,T=u.loader,y=d||T,f=new y(u);return o.loader=f,this.loaders[o.type]=f,f},S.getInternalLoader=function(o){return this.loaders[o.type]},S.resetInternalLoader=function(o){this.loaders[o]&&delete this.loaders[o]},S.destroyInternalLoaders=function(){for(var o in this.loaders){var u=this.loaders[o];u&&u.destroy(),this.resetInternalLoader(o)}},S.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},S.onManifestLoading=function(o,u){var d=u.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:M.PlaylistContextType.MANIFEST,url:d,deliveryDirectives:null})},S.onLevelLoading=function(o,u){var d=u.id,T=u.level,y=u.url,f=u.deliveryDirectives;this.load({id:d,groupId:null,level:T,responseType:"text",type:M.PlaylistContextType.LEVEL,url:y,deliveryDirectives:f})},S.onAudioTrackLoading=function(o,u){var d=u.id,T=u.groupId,y=u.url,f=u.deliveryDirectives;this.load({id:d,groupId:T,level:null,responseType:"text",type:M.PlaylistContextType.AUDIO_TRACK,url:y,deliveryDirectives:f})},S.onSubtitleTrackLoading=function(o,u){var d=u.id,T=u.groupId,y=u.url,f=u.deliveryDirectives;this.load({id:d,groupId:T,level:null,responseType:"text",type:M.PlaylistContextType.SUBTITLE_TRACK,url:y,deliveryDirectives:f})},S.load=function(o){var u,d=this.hls.config,T=this.getInternalLoader(o);if(T){var y=T.context;if(y&&y.url===o.url){z.logger.trace("[playlist-loader]: playlist request ongoing");return}z.logger.log("[playlist-loader]: aborting previous loader for type: "+o.type),T.abort()}var f,k,x,p;switch(o.type){case M.PlaylistContextType.MANIFEST:f=d.manifestLoadingMaxRetry,k=d.manifestLoadingTimeOut,x=d.manifestLoadingRetryDelay,p=d.manifestLoadingMaxRetryTimeout;break;case M.PlaylistContextType.LEVEL:case M.PlaylistContextType.AUDIO_TRACK:case M.PlaylistContextType.SUBTITLE_TRACK:f=0,k=d.levelLoadingTimeOut;break;default:f=d.levelLoadingMaxRetry,k=d.levelLoadingTimeOut,x=d.levelLoadingRetryDelay,p=d.levelLoadingMaxRetryTimeout;break}if(T=this.createInternalLoader(o),(u=o.deliveryDirectives)!==null&&u!==void 0&&u.part){var c;if(o.type===M.PlaylistContextType.LEVEL&&o.level!==null?c=this.hls.levels[o.level].details:o.type===M.PlaylistContextType.AUDIO_TRACK&&o.id!==null?c=this.hls.audioTracks[o.id].details:o.type===M.PlaylistContextType.SUBTITLE_TRACK&&o.id!==null&&(c=this.hls.subtitleTracks[o.id].details),c){var s=c.partTarget,a=c.targetduration;s&&a&&(k=Math.min(Math.max(s*3,a*.8)*1e3,k))}}var v={timeout:k,maxRetry:f,retryDelay:x,maxRetryDelay:p,highWaterMark:0},g={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};T.load(o,v,g)},S.loadsuccess=function(o,u,d,T){if(T===void 0&&(T=null),d.isSidxRequest){this.handleSidxRequest(o,d),this.handlePlaylistLoaded(o,u,d,T);return}this.resetInternalLoader(d.type);var y=o.data;if(y.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(o,d,"no EXTM3U delimiter",T);return}u.parsing.start=performance.now(),y.indexOf("#EXTINF:")>0||y.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(o,u,d,T):this.handleMasterPlaylist(o,u,d,T)},S.loaderror=function(o,u,d){d===void 0&&(d=null),this.handleNetworkError(u,d,!1,o)},S.loadtimeout=function(o,u,d){d===void 0&&(d=null),this.handleNetworkError(u,d,!0)},S.handleMasterPlaylist=function(o,u,d,T){var y=this.hls,f=o.data,k=R(o,d),x=P.default.parseMasterPlaylist(f,k),p=x.levels,c=x.sessionData;if(!p.length){this.handleManifestParsingError(o,d,"no level found in manifest",T);return}var s=p.map(function(H){return{id:H.attrs.AUDIO,audioCodec:H.audioCodec}}),a=p.map(function(H){return{id:H.attrs.SUBTITLES,textCodec:H.textCodec}}),v=P.default.parseMasterPlaylistMedia(f,k,"AUDIO",s),g=P.default.parseMasterPlaylistMedia(f,k,"SUBTITLES",a),E=P.default.parseMasterPlaylistMedia(f,k,"CLOSED-CAPTIONS");if(v.length){var _=v.some(function(H){return!H.url});!_&&p[0].audioCodec&&!p[0].attrs.AUDIO&&(z.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),v.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new b.AttrList({}),bitrate:0,url:""}))}y.trigger(N.Events.MANIFEST_LOADED,{levels:p,audioTracks:v,subtitles:g,captions:E,url:k,stats:u,networkDetails:T,sessionData:c})},S.handleTrackOrLevelPlaylist=function(o,u,d,T){var y=this.hls,f=d.id,k=d.level,x=d.type,p=R(o,d),c=Object(X.isFiniteNumber)(f)?f:0,s=Object(X.isFiniteNumber)(k)?k:c,a=A(d),v=P.default.parseLevelPlaylist(o.data,p,s,a,c);if(!v.fragments.length){y.trigger(N.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:p,reason:"no fragments found in level",level:typeof d.level=="number"?d.level:void 0});return}if(x===M.PlaylistContextType.MANIFEST){var g={attrs:new b.AttrList({}),bitrate:0,details:v,name:"",url:p};y.trigger(N.Events.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:p,stats:u,networkDetails:T,sessionData:null})}if(u.parsing.end=performance.now(),v.needSidxRanges){var E,_=(E=v.fragments[0].initSegment)===null||E===void 0?void 0:E.url;this.load({url:_,isSidxRequest:!0,type:x,level:k,levelDetails:v,id:f,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}d.levelDetails=v,this.handlePlaylistLoaded(o,u,d,T)},S.handleSidxRequest=function(o,u){var d=Object(U.parseSegmentIndex)(new Uint8Array(o.data));if(!d)return;var T=d.references,y=u.levelDetails;T.forEach(function(f,k){var x=f.info,p=y.fragments[k];p.byteRange.length===0&&p.setByteRange(String(1+x.end-x.start)+"@"+String(x.start)),p.initSegment&&p.initSegment.setByteRange(String(d.moovEndOffset)+"@0")})},S.handleManifestParsingError=function(o,u,d,T){this.hls.trigger(N.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:u.type===M.PlaylistContextType.MANIFEST,url:o.url,reason:d,response:o,context:u,networkDetails:T})},S.handleNetworkError=function(o,u,d,T){d===void 0&&(d=!1),z.logger.warn("[playlist-loader]: A network "+(d?"timeout":"error")+" occurred while loading "+o.type+" level: "+o.level+" id: "+o.id+' group-id: "'+o.groupId+'"');var y=I.ErrorDetails.UNKNOWN,f=!1,k=this.getInternalLoader(o);switch(o.type){case M.PlaylistContextType.MANIFEST:y=d?I.ErrorDetails.MANIFEST_LOAD_TIMEOUT:I.ErrorDetails.MANIFEST_LOAD_ERROR,f=!0;break;case M.PlaylistContextType.LEVEL:y=d?I.ErrorDetails.LEVEL_LOAD_TIMEOUT:I.ErrorDetails.LEVEL_LOAD_ERROR,f=!1;break;case M.PlaylistContextType.AUDIO_TRACK:y=d?I.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:I.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,f=!1;break;case M.PlaylistContextType.SUBTITLE_TRACK:y=d?I.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:I.ErrorDetails.SUBTITLE_LOAD_ERROR,f=!1;break}k&&this.resetInternalLoader(o.type);var x={type:I.ErrorTypes.NETWORK_ERROR,details:y,fatal:f,url:o.url,loader:k,context:o,networkDetails:u};T&&(x.response=T),this.hls.trigger(N.Events.ERROR,x)},S.handlePlaylistLoaded=function(o,u,d,T){var y=d.type,f=d.level,k=d.id,x=d.groupId,p=d.loader,c=d.levelDetails,s=d.deliveryDirectives;if(!(c!=null&&c.targetduration)){this.handleManifestParsingError(o,d,"invalid target duration",T);return}if(!p)return;c.live&&(p.getCacheAge&&(c.ageHeader=p.getCacheAge()||0),(!p.getCacheAge||isNaN(c.ageHeader))&&(c.ageHeader=0));switch(y){case M.PlaylistContextType.MANIFEST:case M.PlaylistContextType.LEVEL:this.hls.trigger(N.Events.LEVEL_LOADED,{details:c,level:f||0,id:k||0,stats:u,networkDetails:T,deliveryDirectives:s});break;case M.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(N.Events.AUDIO_TRACK_LOADED,{details:c,id:k||0,groupId:x||"",stats:u,networkDetails:T,deliveryDirectives:s});break;case M.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(N.Events.SUBTITLE_TRACK_LOADED,{details:c,id:k||0,groupId:x||"",stats:u,networkDetails:T,deliveryDirectives:s});break}},w}();$.default=L},"./src/polyfills/number.ts":function(ne,$,D){"use strict";D.r($),D.d($,"isFiniteNumber",function(){return X}),D.d($,"MAX_SAFE_INTEGER",function(){return N});var X=Number.isFinite||function(I){return typeof I=="number"&&isFinite(I)},N=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(ne,$,D){"use strict";D.r($);var X=function(){function N(){}return N.getSilentFrame=function(z,U){switch(z){case"mp4a.40.2":if(U===1)return new Uint8Array([0,200,0,128,35,128]);if(U===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(U===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(U===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(U===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(U===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(U===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(U===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(U===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return},N}();$.default=X},"./src/remux/mp4-generator.ts":function(ne,$,D){"use strict";D.r($);var X=Math.pow(2,32)-1,N=function(){function I(){}return I.init=function(){I.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var U;for(U in I.types)I.types.hasOwnProperty(U)&&(I.types[U]=[U.charCodeAt(0),U.charCodeAt(1),U.charCodeAt(2),U.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]),M=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]);I.HDLR_TYPES={video:P,audio:M};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]);I.STTS=I.STSC=I.STCO=A,I.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),I.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),I.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),I.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var R=new Uint8Array([105,115,111,109]),L=new Uint8Array([97,118,99,49]),w=new Uint8Array([0,0,0,1]);I.FTYP=I.box(I.types.ftyp,R,w,R,L),I.DINF=I.box(I.types.dinf,I.box(I.types.dref,b))},I.box=function(U){for(var P=8,M=arguments.length,b=new Array(M>1?M-1:0),A=1;A<M;A++)b[A-1]=arguments[A];for(var R=b.length,L=R;R--;)P+=b[R].byteLength;var w=new Uint8Array(P);for(w[0]=P>>24&255,w[1]=P>>16&255,w[2]=P>>8&255,w[3]=P&255,w.set(U,4),R=0,P=8;R<L;R++)w.set(b[R],P),P+=b[R].byteLength;return w},I.hdlr=function(U){return I.box(I.types.hdlr,I.HDLR_TYPES[U])},I.mdat=function(U){return I.box(I.types.mdat,U)},I.mdhd=function(U,P){P*=U;var M=Math.floor(P/(X+1)),b=Math.floor(P%(X+1));return I.box(I.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,U>>24&255,U>>16&255,U>>8&255,U&255,M>>24,M>>16&255,M>>8&255,M&255,b>>24,b>>16&255,b>>8&255,b&255,85,196,0,0]))},I.mdia=function(U){return I.box(I.types.mdia,I.mdhd(U.timescale,U.duration),I.hdlr(U.type),I.minf(U))},I.mfhd=function(U){return I.box(I.types.mfhd,new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,U&255]))},I.minf=function(U){return U.type==="audio"?I.box(I.types.minf,I.box(I.types.smhd,I.SMHD),I.DINF,I.stbl(U)):I.box(I.types.minf,I.box(I.types.vmhd,I.VMHD),I.DINF,I.stbl(U))},I.moof=function(U,P,M){return I.box(I.types.moof,I.mfhd(U),I.traf(M,P))},I.moov=function(U){for(var P=U.length,M=[];P--;)M[P]=I.trak(U[P]);return I.box.apply(null,[I.types.moov,I.mvhd(U[0].timescale,U[0].duration)].concat(M).concat(I.mvex(U)))},I.mvex=function(U){for(var P=U.length,M=[];P--;)M[P]=I.trex(U[P]);return I.box.apply(null,[I.types.mvex].concat(M))},I.mvhd=function(U,P){P*=U;var M=Math.floor(P/(X+1)),b=Math.floor(P%(X+1)),A=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,U>>24&255,U>>16&255,U>>8&255,U&255,M>>24,M>>16&255,M>>8&255,M&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 I.box(I.types.mvhd,A)},I.sdtp=function(U){var P=U.samples||[],M=new Uint8Array(4+P.length),b,A;for(b=0;b<P.length;b++)A=P[b].flags,M[b+4]=A.dependsOn<<4|A.isDependedOn<<2|A.hasRedundancy;return I.box(I.types.sdtp,M)},I.stbl=function(U){return I.box(I.types.stbl,I.stsd(U),I.box(I.types.stts,I.STTS),I.box(I.types.stsc,I.STSC),I.box(I.types.stsz,I.STSZ),I.box(I.types.stco,I.STCO))},I.avc1=function(U){var P=[],M=[],b,A,R;for(b=0;b<U.sps.length;b++)A=U.sps[b],R=A.byteLength,P.push(R>>>8&255),P.push(R&255),P=P.concat(Array.prototype.slice.call(A));for(b=0;b<U.pps.length;b++)A=U.pps[b],R=A.byteLength,M.push(R>>>8&255),M.push(R&255),M=M.concat(Array.prototype.slice.call(A));var L=I.box(I.types.avcC,new Uint8Array([1,P[3],P[4],P[5],252|3,224|U.sps.length].concat(P).concat([U.pps.length]).concat(M))),w=U.width,S=U.height,h=U.pixelRatio[0],o=U.pixelRatio[1];return I.box(I.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,S>>8&255,S&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,I.box(I.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),I.box(I.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,o>>24,o>>16&255,o>>8&255,o&255])))},I.esds=function(U){var P=U.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(U.config).concat([6,1,2]))},I.mp4a=function(U){var P=U.samplerate;return I.box(I.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,U.channelCount,0,16,0,0,0,0,P>>8&255,P&255,0,0]),I.box(I.types.esds,I.esds(U)))},I.mp3=function(U){var P=U.samplerate;return I.box(I.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,U.channelCount,0,16,0,0,0,0,P>>8&255,P&255,0,0]))},I.stsd=function(U){return U.type==="audio"?!U.isAAC&&U.codec==="mp3"?I.box(I.types.stsd,I.STSD,I.mp3(U)):I.box(I.types.stsd,I.STSD,I.mp4a(U)):I.box(I.types.stsd,I.STSD,I.avc1(U))},I.tkhd=function(U){var P=U.id,M=U.duration*U.timescale,b=U.width,A=U.height,R=Math.floor(M/(X+1)),L=Math.floor(M%(X+1));return I.box(I.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,P>>24&255,P>>16&255,P>>8&255,P&255,0,0,0,0,R>>24,R>>16&255,R>>8&255,R&255,L>>24,L>>16&255,L>>8&255,L&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,b>>8&255,b&255,0,0,A>>8&255,A&255,0,0]))},I.traf=function(U,P){var M=I.sdtp(U),b=U.id,A=Math.floor(P/(X+1)),R=Math.floor(P%(X+1));return I.box(I.types.traf,I.box(I.types.tfhd,new Uint8Array([0,0,0,0,b>>24,b>>16&255,b>>8&255,b&255])),I.box(I.types.tfdt,new Uint8Array([1,0,0,0,A>>24,A>>16&255,A>>8&255,A&255,R>>24,R>>16&255,R>>8&255,R&255])),I.trun(U,M.length+16+20+8+16+8+8),M)},I.trak=function(U){return U.duration=U.duration||4294967295,I.box(I.types.trak,I.tkhd(U),I.mdia(U))},I.trex=function(U){var P=U.id;return I.box(I.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]))},I.trun=function(U,P){var M=U.samples||[],b=M.length,A=12+16*b,R=new Uint8Array(A),L,w,S,h,o,u;for(P+=8+A,R.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=M[L],S=w.duration,h=w.size,o=w.flags,u=w.cts,R.set([S>>>24&255,S>>>16&255,S>>>8&255,S&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,o.degradPrio&240<<8,o.degradPrio&15,u>>>24&255,u>>>16&255,u>>>8&255,u&255],12+16*L);return I.box(I.types.trun,R)},I.initSegment=function(U){I.types||I.init();var P=I.moov(U),M=new Uint8Array(I.FTYP.byteLength+P.byteLength);return M.set(I.FTYP),M.set(P,I.FTYP.byteLength),M},I}();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,$,D){"use strict";D.r($),D.d($,"default",function(){return u}),D.d($,"normalizePts",function(){return d});var X=D("./src/polyfills/number.ts"),N=D("./src/remux/aac-helper.ts"),I=D("./src/remux/mp4-generator.ts"),z=D("./src/events.ts"),U=D("./src/errors.ts"),P=D("./src/utils/logger.ts"),M=D("./src/types/loader.ts"),b=D("./src/utils/timescale-conversion.ts");function A(){return A=Object.assign||function(k){for(var x=1;x<arguments.length;x++){var p=arguments[x];for(var c in p)Object.prototype.hasOwnProperty.call(p,c)&&(k[c]=p[c])}return k},A.apply(this,arguments)}var R=10*1e3,L=1024,w=1152,S=null,h=null,o=!1,u=function(){function k(p,c,s,a){if(a===void 0&&(a=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=p,this.config=c,this.typeSupported=s,this.ISGenerated=!1,S===null){var v=navigator.userAgent||"",g=v.match(/Chrome\/(\d+)/i);S=g?parseInt(g[1]):0}if(h===null){var E=navigator.userAgent.match(/Safari\/(\d+)/i);h=E?parseInt(E[1]):0}o=!!S&&S<75||!!h&&h<600}var x=k.prototype;return x.destroy=function(){},x.resetTimeStamp=function(c){P.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=c},x.resetNextTimestamp=function(){P.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},x.resetInitSegment=function(){P.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},x.getVideoStartPts=function(c){var s=!1,a=c.reduce(function(v,g){var E=g.pts-v;return E<-4294967296?(s=!0,d(v,g.pts)):E>0?v:g.pts},c[0].pts);return s&&P.logger.debug("PTS rollover detected"),a},x.remux=function(c,s,a,v,g,E,_,H){var V,Z,G,j,q,ie,ce=g,ve=g,ke=c.pid>-1,xe=s.pid>-1,Ce=s.samples.length,Te=c.samples.length>0,Ee=Ce>1,pe=(!ke||Te)&&(!xe||Ee)||this.ISGenerated||_;if(pe){this.ISGenerated||(G=this.generateIS(c,s,g));var se=this.isVideoContiguous,Le=-1;if(Ee&&(Le=T(s.samples),!se&&this.config.forceKeyFrameOnDiscontinuity))if(ie=!0,Le>0){P.logger.warn("[mp4-remuxer]: Dropped "+Le+" out of "+Ce+" video samples due to a missing keyframe");var Xe=this.getVideoStartPts(s.samples);s.samples=s.samples.slice(Le),s.dropped+=Le,ve+=(s.samples[0].pts-Xe)/(s.timescale||9e4)}else Le===-1&&(P.logger.warn("[mp4-remuxer]: No keyframe found out of "+Ce+" video samples"),ie=!1);if(this.ISGenerated){if(Te&&Ee){var Ge=this.getVideoStartPts(s.samples),Ke=d(c.samples[0].pts,Ge)-Ge,Ve=Ke/s.inputTimeScale;ce+=Math.max(0,Ve),ve+=Math.max(0,-Ve)}if(Te){if(c.samplerate||(P.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),G=this.generateIS(c,s,g)),Z=this.remuxAudio(c,ce,this.isAudioContiguous,E,xe||Ee||H===M.PlaylistLevelType.AUDIO?ve:void 0),Ee){var De=Z?Z.endPTS-Z.startPTS:0;s.inputTimeScale||(P.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),G=this.generateIS(c,s,g)),V=this.remuxVideo(s,ve,se,De)}}else Ee&&(V=this.remuxVideo(s,ve,se,0));V&&(V.firstKeyFrame=Le,V.independent=Le!==-1)}}return this.ISGenerated&&(a.samples.length&&(q=this.remuxID3(a,g)),v.samples.length&&(j=this.remuxText(v,g))),{audio:Z,video:V,initSegment:G,independent:ie,text:j,id3:q}},x.generateIS=function(c,s,a){var v=c.samples,g=s.samples,E=this.typeSupported,_={},H=!Object(X.isFiniteNumber)(this._initPTS),V="audio/mp4",Z,G,j;if(H&&(Z=G=Infinity),c.config&&v.length&&(c.timescale=c.samplerate,c.isAAC||(E.mpeg?(V="audio/mpeg",c.codec=""):E.mp3&&(c.codec="mp3")),_.audio={id:"audio",container:V,codec:c.codec,initSegment:!c.isAAC&&E.mpeg?new Uint8Array(0):I.default.initSegment([c]),metadata:{channelCount:c.channelCount}},H&&(j=c.inputTimeScale,Z=G=v[0].pts-Math.round(j*a))),s.sps&&s.pps&&g.length&&(s.timescale=s.inputTimeScale,_.video={id:"main",container:"video/mp4",codec:s.codec,initSegment:I.default.initSegment([s]),metadata:{width:s.width,height:s.height}},H)){j=s.inputTimeScale;var q=this.getVideoStartPts(g),ie=Math.round(j*a);G=Math.min(G,d(g[0].dts,q)-ie),Z=Math.min(Z,q-ie)}if(Object.keys(_).length)return this.ISGenerated=!0,H&&(this._initPTS=Z,this._initDTS=G),{tracks:_,initPTS:Z,timescale:j}},x.remuxVideo=function(c,s,a,v){var g=c.inputTimeScale,E=c.samples,_=[],H=E.length,V=this._initPTS,Z=this.nextAvcDts,G=8,j,q,ie,ce=Number.POSITIVE_INFINITY,ve=Number.NEGATIVE_INFINITY,ke=0,xe=!1;if(!a||Z===null){var Ce=s*g,Te=E[0].pts-d(E[0].dts,E[0].pts);Z=Ce-Te}for(var Ee=0;Ee<H;Ee++){var pe=E[Ee];if(pe.pts=d(pe.pts-V,Z),pe.dts=d(pe.dts-V,Z),pe.dts>pe.pts){var se=9e4*.2;ke=Math.max(Math.min(ke,pe.pts-pe.dts),-1*se)}pe.dts<E[Ee>0?Ee-1:Ee].dts&&(xe=!0)}xe&&E.sort(function(kt,ot){var We=kt.dts-ot.dts,yt=kt.pts-ot.pts;return We||yt}),q=E[0].dts,ie=E[E.length-1].dts;var Le=Math.round((ie-q)/(H-1));if(ke<0){if(ke<Le*-2){P.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(b.toMsFromMpegTsClock)(-Le,!0)+" ms");for(var Xe=ke,Ge=0;Ge<H;Ge++)E[Ge].dts=Xe=Math.max(Xe,E[Ge].pts-Le),E[Ge].pts=Math.max(Xe,E[Ge].pts)}else{P.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(b.toMsFromMpegTsClock)(ke,!0)+" ms to overcome this issue");for(var Ke=0;Ke<H;Ke++)E[Ke].dts=E[Ke].dts+ke}q=E[0].dts}if(a){var Ve=q-Z,De=Ve>Le,Pe=Ve<-1;if(De||Pe){De?P.logger.warn("AVC: "+Object(b.toMsFromMpegTsClock)(Ve,!0)+" ms ("+Ve+"dts) hole between fragments detected, filling it"):P.logger.warn("AVC: "+Object(b.toMsFromMpegTsClock)(-Ve,!0)+" ms ("+Ve+"dts) overlapping between fragments detected"),q=Z;var He=E[0].pts-Ve;E[0].dts=q,E[0].pts=He,P.logger.log("Video: First PTS/DTS adjusted: "+Object(b.toMsFromMpegTsClock)(He,!0)+"/"+Object(b.toMsFromMpegTsClock)(q,!0)+", delta: "+Object(b.toMsFromMpegTsClock)(Ve,!0)+" ms")}}o&&(q=Math.max(0,q));for(var $e=0,Fe=0,Ne=0;Ne<H;Ne++){for(var Me=E[Ne],at=Me.units,qe=at.length,Qe=0,tt=0;tt<qe;tt++)Qe+=at[tt].data.length;Fe+=Qe,$e+=qe,Me.length=Qe,Me.dts=Math.max(Me.dts,q),Me.pts=Math.max(Me.pts,Me.dts,0),ce=Math.min(Me.pts,ce),ve=Math.max(Me.pts,ve)}ie=E[H-1].dts;var ut=Fe+4*$e+8,rt;try{rt=new Uint8Array(ut)}catch(kt){this.observer.emit(z.Events.ERROR,z.Events.ERROR,{type:U.ErrorTypes.MUX_ERROR,details:U.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ut,reason:"fail allocating video mdat "+ut});return}var it=new DataView(rt.buffer);it.setUint32(0,ut),rt.set(I.default.types.mdat,4);for(var we=0;we<H;we++){for(var lt=E[we],et=lt.units,Ae=0,Ue=0,me=et.length;Ue<me;Ue++){var he=et[Ue],fe=he.data,ee=he.data.byteLength;it.setUint32(G,ee),G+=4,rt.set(fe,G),G+=ee,Ae+=4+ee}if(we<H-1)j=E[we+1].dts-lt.dts;else{var te=this.config,ae=lt.dts-E[we>0?we-1:we].dts;if(te.stretchShortVideoTrack&&this.nextAudioPts!==null){var ue=Math.floor(te.maxBufferHole*g),ge=(v?ce+v*g:this.nextAudioPts)-lt.pts;ge>ue?(j=ge-ae,j<0&&(j=ae),P.logger.log("[mp4-remuxer]: It is approximately "+ge/90+" ms to the next segment; using duration "+j/90+" ms for the last video frame.")):j=ae}else j=ae}var Se=Math.round(lt.pts-lt.dts);_.push(new y(lt.key,j,Ae,Se))}if(_.length&&S&&S<70){var Oe=_[0].flags;Oe.dependsOn=2,Oe.isNonSync=0}console.assert(j!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=Z=ie+j,this.isVideoContiguous=!0;var nt=I.default.moof(c.sequenceNumber++,q,A({},c,{samples:_})),gt="video",ct={data1:nt,data2:rt,startPTS:ce/g,endPTS:(ve+j)/g,startDTS:q/g,endDTS:Z/g,type:gt,hasAudio:!1,hasVideo:!0,nb:_.length,dropped:c.dropped};return c.samples=[],c.dropped=0,console.assert(rt.length,"MDAT length must not be zero"),ct},x.remuxAudio=function(c,s,a,v,g){var E=c.inputTimeScale,_=c.samplerate?c.samplerate:E,H=E/_,V=c.isAAC?L:w,Z=V*H,G=this._initPTS,j=!c.isAAC&&this.typeSupported.mpeg,q=[],ie=c.samples,ce=j?0:8,ve=this.nextAudioPts||-1,ke=s*E;if(this.isAudioContiguous=a=a||ie.length&&ve>0&&(v&&Math.abs(ke-ve)<9e3||Math.abs(d(ie[0].pts-G,ke)-ve)<20*Z),ie.forEach(function(fe){fe.pts=d(fe.pts-G,ke)}),!a||ve<0){if(ie=ie.filter(function(fe){return fe.pts>=0}),!ie.length)return;g===0?ve=0:v?ve=Math.max(0,ke):ve=ie[0].pts}if(c.isAAC)for(var xe=g!==void 0,Ce=this.config.maxAudioFramesDrift,Te=0,Ee=ve;Te<ie.length;Te++){var pe=ie[Te],se=pe.pts,Le=se-Ee,Xe=Math.abs(1e3*Le/E);if(Le<=-Ce*Z&&xe)Te===0&&(P.logger.warn("Audio frame @ "+(se/E).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*Le/E)+" ms."),this.nextAudioPts=ve=Ee=se);else if(Le>=Ce*Z&&Xe<R&&xe){var Ge=Math.round(Le/Z);Ee=se-Ge*Z,Ee<0&&(Ge--,Ee+=Z),Te===0&&(this.nextAudioPts=ve=Ee),P.logger.warn("[mp4-remuxer]: Injecting "+Ge+" audio frame @ "+(Ee/E).toFixed(3)+"s due to "+Math.round(1e3*Le/E)+" ms gap.");for(var Ke=0;Ke<Ge;Ke++){var Ve=Math.max(Ee,0),De=N.default.getSilentFrame(c.manifestCodec||c.codec,c.channelCount);De||(P.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),De=pe.unit.subarray()),ie.splice(Te,0,{unit:De,pts:Ve}),Ee+=Z,Te++}}pe.pts=Ee,Ee+=Z}for(var Pe=null,He=null,$e,Fe=0,Ne=ie.length;Ne--;)Fe+=ie[Ne].unit.byteLength;for(var Me=0,at=ie.length;Me<at;Me++){var qe=ie[Me],Qe=qe.unit,tt=qe.pts;if(He!==null){var ut=q[Me-1];ut.duration=Math.round((tt-He)/H)}else if(a&&c.isAAC&&(tt=ve),Pe=tt,Fe>0){Fe+=ce;try{$e=new Uint8Array(Fe)}catch(fe){this.observer.emit(z.Events.ERROR,z.Events.ERROR,{type:U.ErrorTypes.MUX_ERROR,details:U.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Fe,reason:"fail allocating audio mdat "+Fe});return}if(!j){var rt=new DataView($e.buffer);rt.setUint32(0,Fe),$e.set(I.default.types.mdat,4)}}else return;$e.set(Qe,ce);var it=Qe.byteLength;ce+=it,q.push(new y(!0,V,it,0)),He=tt}var we=q.length;if(!we)return;var lt=q[q.length-1];this.nextAudioPts=ve=He+H*lt.duration;var et=j?new Uint8Array(0):I.default.moof(c.sequenceNumber++,Pe/H,A({},c,{samples:q}));c.samples=[];var Ae=Pe/E,Ue=ve/E,me="audio",he={data1:et,data2:$e,startPTS:Ae,endPTS:Ue,startDTS:Ae,endDTS:Ue,type:me,hasAudio:!0,hasVideo:!1,nb:we};return this.isAudioContiguous=!0,console.assert($e.length,"MDAT length must not be zero"),he},x.remuxEmptyAudio=function(c,s,a,v){var g=c.inputTimeScale,E=c.samplerate?c.samplerate:g,_=g/E,H=this.nextAudioPts,V=(H!==null?H:v.startDTS*g)+this._initDTS,Z=v.endDTS*g+this._initDTS,G=_*L,j=Math.ceil((Z-V)/G),q=N.default.getSilentFrame(c.manifestCodec||c.codec,c.channelCount);if(P.logger.warn("[mp4-remuxer]: remux empty Audio"),!q){P.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var ie=[],ce=0;ce<j;ce++){var ve=V+ce*G;ie.push({unit:q,pts:ve,dts:ve})}return c.samples=ie,this.remuxAudio(c,s,a,!1)},x.remuxID3=function(c,s){var a=c.samples.length;if(!a)return;for(var v=c.inputTimeScale,g=this._initPTS,E=this._initDTS,_=0;_<a;_++){var H=c.samples[_];H.pts=d(H.pts-g,s*v)/v,H.dts=d(H.dts-E,s*v)/v}var V=c.samples;return c.samples=[],{samples:V}},x.remuxText=function(c,s){var a=c.samples.length;if(!a)return;for(var v=c.inputTimeScale,g=this._initPTS,E=0;E<a;E++){var _=c.samples[E];_.pts=d(_.pts-g,s*v)/v}c.samples.sort(function(V,Z){return V.pts-Z.pts});var H=c.samples;return c.samples=[],{samples:H}},k}();function d(k,x){var p;if(x===null)return k;for(x<k?p=-8589934592:p=8589934592;Math.abs(k-x)>4294967296;)k+=p;return k}function T(k){for(var x=0;x<k.length;x++)if(k[x].key)return x;return-1}var y=function(x,p,c,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=p,this.size=c,this.cts=s,this.flags=new f(x)},f=function(x){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=x?2:1,this.isNonSync=x?0:1}},"./src/remux/passthrough-remuxer.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/polyfills/number.ts"),N=D("./src/utils/mp4-tools.ts"),I=D("./src/loader/fragment.ts"),z=D("./src/utils/logger.ts"),U=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,S){this.audioCodec=w,this.videoCodec=S,this.generateInitSegment(L),this.emitInitSegment=!0},A.generateInitSegment=function(L){var w=this.audioCodec,S=this.videoCodec;if(!L||!L.byteLength){this.initTracks=void 0,this.initData=void 0;return}var h=this.initData=Object(N.parseInitSegment)(L);w||(w=M(h.audio,I.ElementaryStreamTypes.AUDIO)),S||(S=M(h.video,I.ElementaryStreamTypes.VIDEO));var o={};h.audio&&h.video?o.audiovideo={container:"video/mp4",codec:w+","+S,initSegment:L,id:"main"}:h.audio?o.audio={container:"audio/mp4",codec:w,initSegment:L,id:"audio"}:h.video?o.video={container:"video/mp4",codec:S,initSegment:L,id:"main"}:z.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},A.remux=function(L,w,S,h,o){var u=this.initPTS,d=this.lastEndDTS,T={audio:void 0,video:void 0,text:h,id3:S,initSegment:void 0};Object(X.isFiniteNumber)(d)||(d=this.lastEndDTS=o||0);var y=w.samples;if(!y||!y.length)return T;var f={initPTS:void 0,timescale:1},k=this.initData;if((!k||!k.length)&&(this.generateInitSegment(y),k=this.initData),!k||!k.length)return z.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),T;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1),Object(X.isFiniteNumber)(u)||(this.initPTS=f.initPTS=u=P(k,y,d));var x=Object(N.getDuration)(y,k),p=d,c=x+p;Object(N.offsetStartDTS)(k,y,u),x>0?this.lastEndDTS=c:(z.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var s=!!k.audio,a=!!k.video,v="";s&&(v+="audio"),a&&(v+="video");var g={data1:y,startPTS:p,startDTS:p,endPTS:c,endDTS:c,type:v,hasAudio:s,hasVideo:a,nb:1,dropped:0};return T.audio=g.type==="audio"?g:void 0,T.video=g.type!=="audio"?g:void 0,T.text=h,T.id3=S,T.initSegment=f,T},b}(),P=function(A,R,L){return Object(N.getStartDTS)(A,R)-L};function M(b,A){var R=b==null?void 0:b.codec;return R&&R.length>4?R:R==="hvc1"?"hvc1.1.c.L120.90":R==="av01"?"av01.0.04M.08":R==="avc1"||A===I.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}$.default=U},"./src/task-loop.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return X});var X=function(){function N(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var I=N.prototype;return I.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},I.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},I.onHandlerDestroyed=function(){},I.hasInterval=function(){return!!this._tickInterval},I.hasNextTick=function(){return!!this._tickTimer},I.setInterval=function(U){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,U),!0)},I.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},I.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},I.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},I.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},I.doTick=function(){},N}()},"./src/types/cmcd.ts":function(ne,$,D){"use strict";D.r($),D.d($,"CMCDVersion",function(){return X}),D.d($,"CMCDObjectType",function(){return N}),D.d($,"CMCDStreamingFormat",function(){return I}),D.d($,"CMCDStreamType",function(){return z});var X=1,N;(function(U){U.MANIFEST="m",U.AUDIO="a",U.VIDEO="v",U.MUXED="av",U.INIT="i",U.CAPTION="c",U.TIMED_TEXT="tt",U.KEY="k",U.OTHER="o"})(N||(N={}));var I;(function(U){U.DASH="d",U.HLS="h",U.SMOOTH="s",U.OTHER="o"})(I||(I={}));var z;(function(U){U.VOD="v",U.LIVE="l"})(z||(z={}))},"./src/types/level.ts":function(ne,$,D){"use strict";D.r($),D.d($,"HlsSkip",function(){return I}),D.d($,"getSkipValue",function(){return z}),D.d($,"HlsUrlParameters",function(){return U}),D.d($,"Level",function(){return P});function X(M,b){for(var A=0;A<b.length;A++){var R=b[A];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(M,R.key,R)}}function N(M,b,A){return b&&X(M.prototype,b),A&&X(M,A),M}var I;(function(M){M.No="",M.Yes="YES",M.v2="v2"})(I||(I={}));function z(M,b){var A=M.canSkipUntil,R=M.canSkipDateRanges,L=M.endSN,w=b!==void 0?b-L:0;return A&&w<A?R?I.v2:I.Yes:I.No}var U=function(){function M(A,R,L){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=A,this.part=R,this.skip=L}var b=M.prototype;return b.addDirectives=function(R){var L=new self.URL(R);return this.msn!==void 0&&L.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&L.searchParams.set("_HLS_part",this.part.toString()),this.skip&&L.searchParams.set("_HLS_skip",this.skip),L.toString()},M}(),P=function(){function M(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(M,[{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 R=A%this.url.length;this._urlId!==R&&(this.details=void 0,this._urlId=R)}}]),M}()},"./src/types/loader.ts":function(ne,$,D){"use strict";D.r($),D.d($,"PlaylistContextType",function(){return X}),D.d($,"PlaylistLevelType",function(){return N});var X;(function(I){I.MANIFEST="manifest",I.LEVEL="level",I.AUDIO_TRACK="audioTrack",I.SUBTITLE_TRACK="subtitleTrack"})(X||(X={}));var N;(function(I){I.MAIN="main",I.AUDIO="audio",I.SUBTITLE="subtitle"})(N||(N={}))},"./src/types/transmuxer.ts":function(ne,$,D){"use strict";D.r($),D.d($,"ChunkMetadata",function(){return X});var X=function(z,U,P,M,b,A){M===void 0&&(M=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=z,this.sn=U,this.id=P,this.size=M,this.part=b,this.partial=A};function N(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(ne,$,D){"use strict";D.r($),D.d($,"AttrList",function(){return I});var X=/^(\d+)x(\d+)$/,N=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,I=function(){function z(P){typeof P=="string"&&(P=z.parseAttrList(P));for(var M in P)P.hasOwnProperty(M)&&(this[M]=P[M])}var U=z.prototype;return U.decimalInteger=function(M){var b=parseInt(this[M],10);return b>Number.MAX_SAFE_INTEGER?Infinity:b},U.hexadecimalInteger=function(M){if(this[M]){var b=(this[M]||"0x").slice(2);b=(b.length&1?"0":"")+b;for(var A=new Uint8Array(b.length/2),R=0;R<b.length/2;R++)A[R]=parseInt(b.slice(R*2,R*2+2),16);return A}else return null},U.hexadecimalIntegerAsNumber=function(M){var b=parseInt(this[M],16);return b>Number.MAX_SAFE_INTEGER?Infinity:b},U.decimalFloatingPoint=function(M){return parseFloat(this[M])},U.optionalFloat=function(M,b){var A=this[M];return A?parseFloat(A):b},U.enumeratedString=function(M){return this[M]},U.bool=function(M){return this[M]==="YES"},U.decimalResolution=function(M){var b=X.exec(this[M]);return b===null?void 0:{width:parseInt(b[1],10),height:parseInt(b[2],10)}},z.parseAttrList=function(M){var b,A={},R='"';for(N.lastIndex=0;(b=N.exec(M))!==null;){var L=b[2];L.indexOf(R)===0&&L.lastIndexOf(R)===L.length-1&&(L=L.slice(1,-1)),A[b[1]]=L}return A},z}()},"./src/utils/binary-search.ts":function(ne,$,D){"use strict";D.r($);var X={search:function(I,z){for(var U=0,P=I.length-1,M=null,b=null;U<=P;){M=(U+P)/2|0,b=I[M];var A=z(b);if(A>0)U=M+1;else if(A<0)P=M-1;else return b}return null}};$.default=X},"./src/utils/buffer-helper.ts":function(ne,$,D){"use strict";D.r($),D.d($,"BufferHelper",function(){return I});var X=D("./src/utils/logger.ts"),N={length:0,start:function(){return 0},end:function(){return 0}},I=function(){function z(){}return z.isBuffered=function(P,M){try{if(P){for(var b=z.getBuffered(P),A=0;A<b.length;A++)if(M>=b.start(A)&&M<=b.end(A))return!0}}catch(R){}return!1},z.bufferInfo=function(P,M,b){try{if(P){var A=z.getBuffered(P),R=[],L;for(L=0;L<A.length;L++)R.push({start:A.start(L),end:A.end(L)});return this.bufferedInfo(R,M,b)}}catch(w){}return{len:0,start:M,end:M,nextStart:void 0}},z.bufferedInfo=function(P,M,b){M=Math.max(0,M),P.sort(function(f,k){var x=f.start-k.start;return x||k.end-f.end});var A=[];if(b)for(var R=0;R<P.length;R++){var L=A.length;if(L){var w=A[L-1].end;P[R].start-w<b?P[R].end>w&&(A[L-1].end=P[R].end):A.push(P[R])}else A.push(P[R])}else A=P;for(var S=0,h,o=M,u=M,d=0;d<A.length;d++){var T=A[d].start,y=A[d].end;if(M+b>=T&&M<y)o=T,u=y,S=u-M;else if(M+b<T){h=T;break}}return{len:S,start:o||0,end:u||0,nextStart:h}},z.getBuffered=function(P){try{return P.buffered}catch(M){return X.logger.log("failed to get media.buffered",M),N}},z}()},"./src/utils/cea-608-parser.ts":function(ne,$,D){"use strict";D.r($),D.d($,"Row",function(){return u}),D.d($,"CaptionScreen",function(){return d});var X=D("./src/utils/logger.ts"),N={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},I=function(c){var s=c;return N.hasOwnProperty(c)&&(s=N[c]),String.fromCharCode(s)},z=15,U=100,P={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},M={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},R=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],L;(function(p){p[p.ERROR=0]="ERROR",p[p.TEXT=1]="TEXT",p[p.WARNING=2]="WARNING",p[p.INFO=2]="INFO",p[p.DEBUG=3]="DEBUG",p[p.DATA=3]="DATA"})(L||(L={}));var w=function(){function p(){this.time=null,this.verboseLevel=L.ERROR}var c=p.prototype;return c.log=function(a,v){this.verboseLevel>=a&&X.logger.log(this.time+" ["+a+"] "+v)},p}(),S=function(c){for(var s=[],a=0;a<c.length;a++)s.push(c[a].toString(16));return s},h=function(){function p(s,a,v,g,E){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=s||"white",this.underline=a||!1,this.italics=v||!1,this.background=g||"black",this.flash=E||!1}var c=p.prototype;return c.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},c.setStyles=function(a){for(var v=["foreground","underline","italics","background","flash"],g=0;g<v.length;g++){var E=v[g];a.hasOwnProperty(E)&&(this[E]=a[E])}},c.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},c.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},c.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},c.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},p}(),o=function(){function p(s,a,v,g,E,_){this.uchar=void 0,this.penState=void 0,this.uchar=s||" ",this.penState=new h(a,v,g,E,_)}var c=p.prototype;return c.reset=function(){this.uchar=" ",this.penState.reset()},c.setChar=function(a,v){this.uchar=a,this.penState.copy(v)},c.setPenState=function(a){this.penState.copy(a)},c.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},c.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},c.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},p}(),u=function(){function p(s){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var a=0;a<U;a++)this.chars.push(new o);this.logger=s,this.pos=0,this.currPenState=new h}var c=p.prototype;return c.equals=function(a){for(var v=!0,g=0;g<U;g++)if(!this.chars[g].equals(a.chars[g])){v=!1;break}return v},c.copy=function(a){for(var v=0;v<U;v++)this.chars[v].copy(a.chars[v])},c.isEmpty=function(){for(var a=!0,v=0;v<U;v++)if(!this.chars[v].isEmpty()){a=!1;break}return a},c.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(L.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>U&&(this.logger.log(L.DEBUG,"Too large cursor position "+this.pos),this.pos=U)},c.moveCursor=function(a){var v=this.pos+a;if(a>1)for(var g=this.pos+1;g<v+1;g++)this.chars[g].setPenState(this.currPenState);this.setCursor(v)},c.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},c.insertChar=function(a){a>=144&&this.backSpace();var v=I(a);if(this.pos>=U){this.logger.log(L.ERROR,"Cannot insert "+a.toString(16)+" ("+v+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(v,this.currPenState),this.moveCursor(1)},c.clearFromPos=function(a){var v;for(v=a;v<U;v++)this.chars[v].reset()},c.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},c.clearToEndOfRow=function(){this.clearFromPos(this.pos)},c.getTextString=function(){for(var a=[],v=!0,g=0;g<U;g++){var E=this.chars[g].uchar;E!==" "&&(v=!1),a.push(E)}return v?"":a.join("")},c.setPenStyles=function(a){this.currPenState.setStyles(a);var v=this.chars[this.pos];v.setPenState(this.currPenState)},p}(),d=function(){function p(s){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var a=0;a<z;a++)this.rows.push(new u(s));this.logger=s,this.currRow=z-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var c=p.prototype;return c.reset=function(){for(var a=0;a<z;a++)this.rows[a].clear();this.currRow=z-1},c.equals=function(a){for(var v=!0,g=0;g<z;g++)if(!this.rows[g].equals(a.rows[g])){v=!1;break}return v},c.copy=function(a){for(var v=0;v<z;v++)this.rows[v].copy(a.rows[v])},c.isEmpty=function(){for(var a=!0,v=0;v<z;v++)if(!this.rows[v].isEmpty()){a=!1;break}return a},c.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},c.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},c.insertChar=function(a){var v=this.rows[this.currRow];v.insertChar(a)},c.setPen=function(a){var v=this.rows[this.currRow];v.setPenStyles(a)},c.moveCursor=function(a){var v=this.rows[this.currRow];v.moveCursor(a)},c.setCursor=function(a){this.logger.log(L.INFO,"setCursor: "+a);var v=this.rows[this.currRow];v.setCursor(a)},c.setPAC=function(a){this.logger.log(L.INFO,"pacData = "+JSON.stringify(a));var v=a.row-1;if(this.nrRollUpRows&&v<this.nrRollUpRows-1&&(v=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==v){for(var g=0;g<z;g++)this.rows[g].clear();var E=this.currRow+1-this.nrRollUpRows,_=this.lastOutputScreen;if(_){var H=_.rows[E].cueStartTime,V=this.logger.time;if(H&&V!==null&&H<V)for(var Z=0;Z<this.nrRollUpRows;Z++)this.rows[v-this.nrRollUpRows+Z+1].copy(_.rows[E+Z])}}this.currRow=v;var G=this.rows[this.currRow];if(a.indent!==null){var j=a.indent,q=Math.max(j-1,0);G.setCursor(a.indent),a.color=G.chars[q].penState.foreground}var ie={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(ie)},c.setBkgData=function(a){this.logger.log(L.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},c.setRollUpRows=function(a){this.nrRollUpRows=a},c.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(L.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(L.TEXT,this.getDisplayText());var a=this.currRow+1-this.nrRollUpRows,v=this.rows.splice(a,1)[0];v.clear(),this.rows.splice(this.currRow,0,v),this.logger.log(L.INFO,"Rolling up")},c.getDisplayText=function(a){a=a||!1;for(var v=[],g="",E=-1,_=0;_<z;_++){var H=this.rows[_].getTextString();H&&(E=_+1,a?v.push("Row "+E+": '"+H+"'"):v.push(H.trim()))}return v.length>0&&(a?g="["+v.join(" | ")+"]":g=v.join(`
|
|
`)),g},c.getTextAndFormat=function(){return this.rows},p}(),T=function(){function p(s,a,v){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=s,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new d(v),this.nonDisplayedMemory=new d(v),this.lastOutputScreen=new d(v),this.currRollUpRow=this.displayedMemory.rows[z-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=v}var c=p.prototype;return c.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[z-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},c.getHandler=function(){return this.outputFilter},c.setHandler=function(a){this.outputFilter=a},c.setPAC=function(a){this.writeScreen.setPAC(a)},c.setBkgData=function(a){this.writeScreen.setBkgData(a)},c.setMode=function(a){if(a===this.mode)return;this.mode=a,this.logger.log(L.INFO,"MODE="+a),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=a},c.insertChars=function(a){for(var v=0;v<a.length;v++)this.writeScreen.insertChar(a[v]);var g=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(L.INFO,g+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(L.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},c.ccRCL=function(){this.logger.log(L.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},c.ccBS=function(){if(this.logger.log(L.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},c.ccAOF=function(){},c.ccAON=function(){},c.ccDER=function(){this.logger.log(L.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},c.ccRU=function(a){this.logger.log(L.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},c.ccFON=function(){this.logger.log(L.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},c.ccRDC=function(){this.logger.log(L.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},c.ccTR=function(){this.logger.log(L.INFO,"TR"),this.setMode("MODE_TEXT")},c.ccRTD=function(){this.logger.log(L.INFO,"RTD"),this.setMode("MODE_TEXT")},c.ccEDM=function(){this.logger.log(L.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},c.ccCR=function(){this.logger.log(L.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},c.ccENM=function(){this.logger.log(L.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},c.ccEOC=function(){if(this.logger.log(L.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var a=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=a,this.writeScreen=this.nonDisplayedMemory,this.logger.log(L.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},c.ccTO=function(a){this.logger.log(L.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},c.ccMIDROW=function(a){var v={flash:!1};if(v.underline=a%2===1,v.italics=a>=46,v.italics)v.foreground="white";else{var g=Math.floor(a/2)-16,E=["white","green","blue","cyan","red","yellow","magenta"];v.foreground=E[g]}this.logger.log(L.INFO,"MIDROW: "+JSON.stringify(v)),this.writeScreen.setPen(v)},c.outputDataUpdate=function(a){a===void 0&&(a=!1);var v=this.logger.time;if(v===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=v:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,v,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:v),this.lastOutputScreen.copy(this.displayedMemory))},c.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},p}(),y=function(){function p(s,a,v){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var g=new w;this.channels=[null,new T(s,a,g),new T(s+1,v,g)],this.cmdHistory=x(),this.logger=g}var c=p.prototype;return c.getHandler=function(a){return this.channels[a].getHandler()},c.setHandler=function(a,v){this.channels[a].setHandler(v)},c.addData=function(a,v){var g,E,_,H=!1;this.logger.time=a;for(var V=0;V<v.length;V+=2){if(E=v[V]&127,_=v[V+1]&127,E===0&&_===0)continue;if(this.logger.log(L.DATA,"["+S([v[V],v[V+1]])+"] -> ("+S([E,_])+")"),g=this.parseCmd(E,_),g||(g=this.parseMidrow(E,_)),g||(g=this.parsePAC(E,_)),g||(g=this.parseBackgroundAttributes(E,_)),!g&&(H=this.parseChars(E,_),H)){var Z=this.currentChannel;if(Z&&Z>0){var G=this.channels[Z];G.insertChars(H)}else this.logger.log(L.WARNING,"No channel found yet. TEXT-MODE?")}!g&&!H&&this.logger.log(L.WARNING,"Couldn't parse cleaned data "+S([E,_])+" orig: "+S([v[V],v[V+1]]))}},c.parseCmd=function(a,v){var g=this.cmdHistory,E=(a===20||a===28||a===21||a===29)&&v>=32&&v<=47,_=(a===23||a===31)&&v>=33&&v<=35;if(!(E||_))return!1;if(k(a,v,g))return f(null,null,g),this.logger.log(L.DEBUG,"Repeated command ("+S([a,v])+") is dropped"),!0;var H=a===20||a===21||a===23?1:2,V=this.channels[H];return a===20||a===21||a===28||a===29?v===32?V.ccRCL():v===33?V.ccBS():v===34?V.ccAOF():v===35?V.ccAON():v===36?V.ccDER():v===37?V.ccRU(2):v===38?V.ccRU(3):v===39?V.ccRU(4):v===40?V.ccFON():v===41?V.ccRDC():v===42?V.ccTR():v===43?V.ccRTD():v===44?V.ccEDM():v===45?V.ccCR():v===46?V.ccENM():v===47&&V.ccEOC():V.ccTO(v-32),f(a,v,g),this.currentChannel=H,!0},c.parseMidrow=function(a,v){var g=0;if((a===17||a===25)&&v>=32&&v<=47){if(a===17?g=1:g=2,g!==this.currentChannel)return this.logger.log(L.ERROR,"Mismatch channel in midrow parsing"),!1;var E=this.channels[g];return E?(E.ccMIDROW(v),this.logger.log(L.DEBUG,"MIDROW ("+S([a,v])+")"),!0):!1}return!1},c.parsePAC=function(a,v){var g,E=this.cmdHistory,_=(a>=17&&a<=23||a>=25&&a<=31)&&v>=64&&v<=127,H=(a===16||a===24)&&v>=64&&v<=95;if(!(_||H))return!1;if(k(a,v,E))return f(null,null,E),!0;var V=a<=23?1:2;v>=64&&v<=95?g=V===1?P[a]:b[a]:g=V===1?M[a]:A[a];var Z=this.channels[V];return Z?(Z.setPAC(this.interpretPAC(g,v)),f(a,v,E),this.currentChannel=V,!0):!1},c.interpretPAC=function(a,v){var g,E={color:null,italics:!1,indent:null,underline:!1,row:a};return v>95?g=v-96:g=v-64,E.underline=(g&1)===1,g<=13?E.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(g/2)]:g<=15?(E.italics=!0,E.color="white"):E.indent=Math.floor((g-16)/2)*4,E},c.parseChars=function(a,v){var g,E=null,_=null;if(a>=25?(g=2,_=a-8):(g=1,_=a),_>=17&&_<=19){var H;_===17?H=v+80:_===18?H=v+112:H=v+144,this.logger.log(L.INFO,"Special char '"+I(H)+"' in channel "+g),E=[H]}else a>=32&&a<=127&&(E=v===0?[a]:[a,v]);if(E){var V=S(E);this.logger.log(L.DEBUG,"Char codes = "+V.join(",")),f(a,v,this.cmdHistory)}return E},c.parseBackgroundAttributes=function(a,v){var g=(a===16||a===24)&&v>=32&&v<=47,E=(a===23||a===31)&&v>=45&&v<=47;if(!(g||E))return!1;var _,H={};a===16||a===24?(_=Math.floor((v-32)/2),H.background=R[_],v%2===1&&(H.background=H.background+"_semi")):v===45?H.background="transparent":(H.foreground="black",v===47&&(H.underline=!0));var V=a<=23?1:2,Z=this.channels[V];return Z.setBkgData(H),f(a,v,this.cmdHistory),!0},c.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var v=this.channels[a];v&&v.reset()}this.cmdHistory=x()},c.cueSplitAtTime=function(a){for(var v=0;v<this.channels.length;v++){var g=this.channels[v];g&&g.cueSplitAtTime(a)}},p}();function f(p,c,s){s.a=p,s.b=c}function k(p,c,s){return s.a===p&&s.b===c}function x(){return{a:null,b:null}}$.default=y},"./src/utils/codecs.ts":function(ne,$,D){"use strict";D.r($),D.d($,"isCodecType",function(){return N}),D.d($,"isCodecSupportedInMp4",function(){return I});var X={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(z,U){var P=X[U];return!!P&&P[z.slice(0,4)]===!0}function I(z,U){return MediaSource.isTypeSupported((U||"video")+'/mp4;codecs="'+z+'"')}},"./src/utils/cues.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/utils/vttparser.ts"),N=D("./src/utils/webvtt-parser.ts"),I=D("./src/utils/texttrack-utils.ts"),z=/\s/,U={newCue:function(M,b,A,R){for(var L=[],w,S,h,o,u,d=self.VTTCue||self.TextTrackCue,T=0;T<R.rows.length;T++)if(w=R.rows[T],h=!0,o=0,u="",!w.isEmpty()){for(var y=0;y<w.chars.length;y++)z.test(w.chars[y].uchar)&&h?o++:(u+=w.chars[y].uchar,h=!1);w.cueStartTime=b,b===A&&(A+=1e-4),o>=16?o--:o++;var f=Object(X.fixLineBreaks)(u.trim()),k=Object(N.generateCueId)(b,A,f);(!M||!M.cues||!M.cues.getCueById(k))&&(S=new d(b,A,f),S.id=k,S.line=T+1,S.align="left",S.position=10+Math.min(80,Math.floor(o*8/32)*10),L.push(S))}return M&&L.length&&(L.sort(function(x,p){return x.line==="auto"||p.line==="auto"?0:x.line>8&&p.line>8?p.line-x.line:x.line-p.line}),L.forEach(function(x){return Object(I.addCueToTrack)(M,x)})),L}};$.default=U},"./src/utils/discontinuities.ts":function(ne,$,D){"use strict";D.r($),D.d($,"findFirstFragWithCC",function(){return z}),D.d($,"shouldAlignOnDiscontinuities",function(){return U}),D.d($,"findDiscontinuousReferenceFrag",function(){return P}),D.d($,"adjustSlidingStart",function(){return b}),D.d($,"alignStream",function(){return A}),D.d($,"alignPDT",function(){return L}),D.d($,"alignFragmentByPDTDelta",function(){return w}),D.d($,"alignMediaPlaylistByPDT",function(){return S});var X=D("./src/polyfills/number.ts"),N=D("./src/utils/logger.ts"),I=D("./src/controller/level-helper.ts");function z(h,o){for(var u=null,d=0,T=h.length;d<T;d++){var y=h[d];if(y&&y.cc===o){u=y;break}}return u}function U(h,o,u){return!!(o.details&&(u.endCC>u.startCC||h&&h.cc<u.startCC))}function P(h,o){var u=h.fragments,d=o.fragments;if(!d.length||!u.length){N.logger.log("No fragments to align");return}var T=z(u,d[0].cc);if(!T||T&&!T.startPTS){N.logger.log("No frag in previous level to align on");return}return T}function M(h,o){if(h){var u=h.start+o;h.start=h.startPTS=u,h.endPTS=u+h.duration}}function b(h,o){for(var u=o.fragments,d=0,T=u.length;d<T;d++)M(u[d],h);o.fragmentHint&&M(o.fragmentHint,h),o.alignedSliding=!0}function A(h,o,u){if(!o)return;R(h,u,o),!u.alignedSliding&&o.details&&L(u,o.details),!u.alignedSliding&&o.details&&!u.skippedSegments&&Object(I.adjustSliding)(o.details,u)}function R(h,o,u){if(U(h,u,o)){var d=P(u.details,o);d&&Object(X.isFiniteNumber)(d.start)&&(N.logger.log("Adjusting PTS using last level due to CC increase within current level "+o.url),b(d.start,o))}}function L(h,o){if(!o.fragments.length||!h.hasProgramDateTime||!o.hasProgramDateTime)return;var u=o.fragments[0].programDateTime,d=h.fragments[0].programDateTime,T=(d-u)/1e3+o.fragments[0].start;T&&Object(X.isFiniteNumber)(T)&&(N.logger.log("Adjusting PTS using programDateTime delta "+(d-u)+"ms, sliding:"+T.toFixed(3)+" "+h.url+" "),b(T,h))}function w(h,o){var u=h.programDateTime;if(!u)return;var d=(u-o)/1e3;h.start=h.startPTS=d,h.endPTS=d+h.duration}function S(h,o){if(!o.fragments.length||!h.hasProgramDateTime||!o.hasProgramDateTime)return;var u=o.fragments[0].programDateTime,d=o.fragments[0].start,T=u-d*1e3;h.fragments.forEach(function(y){w(y,T)}),h.fragmentHint&&w(h.fragmentHint,T),h.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/utils/ewma.ts"),N=function(){function I(U,P,M){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=M,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new X.default(U),this.fast_=new X.default(P)}var z=I.prototype;return z.update=function(P,M){var b=this.slow_,A=this.fast_;this.slow_.halfLife!==P&&(this.slow_=new X.default(P,b.getEstimate(),b.getTotalWeight())),this.fast_.halfLife!==M&&(this.fast_=new X.default(M,A.getEstimate(),A.getTotalWeight()))},z.sample=function(P,M){P=Math.max(P,this.minDelayMs_);var b=8*M,A=P/1e3,R=b/A;this.fast_.sample(A,R),this.slow_.sample(A,R)},z.canEstimate=function(){var P=this.fast_;return P&&P.getTotalWeight()>=this.minWeight_},z.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},z.destroy=function(){},I}();$.default=N},"./src/utils/ewma.ts":function(ne,$,D){"use strict";D.r($);var X=function(){function N(z,U,P){U===void 0&&(U=0),P===void 0&&(P=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=z,this.alpha_=z?Math.exp(Math.log(.5)/z):0,this.estimate_=U,this.totalWeight_=P}var I=N.prototype;return I.sample=function(U,P){var M=Math.pow(this.alpha_,U);this.estimate_=P*(1-M)+M*this.estimate_,this.totalWeight_+=U},I.getTotalWeight=function(){return this.totalWeight_},I.getEstimate=function(){if(this.alpha_){var U=1-Math.pow(this.alpha_,this.totalWeight_);if(U)return this.estimate_/U}return this.estimate_},N}();$.default=X},"./src/utils/fetch-loader.ts":function(ne,$,D){"use strict";D.r($),D.d($,"fetchSupported",function(){return w});var X=D("./src/polyfills/number.ts"),N=D("./src/loader/load-stats.ts"),I=D("./src/demux/chunk-cache.ts");function z(d,T){d.prototype=Object.create(T.prototype),d.prototype.constructor=d,A(d,T)}function U(d){var T=typeof Map=="function"?new Map:void 0;return U=function(f){if(f===null||!b(f))return f;if(typeof f!="function")throw new TypeError("Super expression must either be null or a function");if(typeof T!="undefined"){if(T.has(f))return T.get(f);T.set(f,k)}function k(){return P(f,arguments,R(this).constructor)}return k.prototype=Object.create(f.prototype,{constructor:{value:k,enumerable:!1,writable:!0,configurable:!0}}),A(k,f)},U(d)}function P(d,T,y){return M()?P=Reflect.construct:P=function(k,x,p){var c=[null];c.push.apply(c,x);var s=Function.bind.apply(k,c),a=new s;return p&&A(a,p.prototype),a},P.apply(null,arguments)}function M(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(d){return!1}}function b(d){return Function.toString.call(d).indexOf("[native code]")!==-1}function A(d,T){return A=Object.setPrototypeOf||function(f,k){return f.__proto__=k,f},A(d,T)}function R(d){return R=Object.setPrototypeOf?Object.getPrototypeOf:function(y){return y.__proto__||Object.getPrototypeOf(y)},R(d)}function L(){return L=Object.assign||function(d){for(var T=1;T<arguments.length;T++){var y=arguments[T];for(var f in y)Object.prototype.hasOwnProperty.call(y,f)&&(d[f]=y[f])}return d},L.apply(this,arguments)}function w(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(d){}return!1}var S=function(){function d(y){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=y.fetchSetup||o,this.controller=new self.AbortController,this.stats=new N.LoadStats}var T=d.prototype;return T.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},T.abortInternal=function(){var f=this.response;(!f||!f.ok)&&(this.stats.aborted=!0,this.controller.abort())},T.abort=function(){var f;this.abortInternal(),(f=this.callbacks)!==null&&f!==void 0&&f.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},T.load=function(f,k,x){var p=this,c=this.stats;if(c.loading.start)throw new Error("Loader can only be used once.");c.loading.start=self.performance.now();var s=h(f,this.controller.signal),a=x.onProgress,v=f.responseType==="arraybuffer",g=v?"byteLength":"length";this.context=f,this.config=k,this.callbacks=x,this.request=this.fetchSetup(f,s),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){p.abortInternal(),x.onTimeout(c,f,p.response)},k.timeout),self.fetch(this.request).then(function(E){if(p.response=p.loader=E,!E.ok){var _=E.status,H=E.statusText;throw new u(H||"fetch, bad network response",_,E)}return c.loading.first=Math.max(self.performance.now(),c.loading.start),c.total=parseInt(E.headers.get("Content-Length")||"0"),a&&Object(X.isFiniteNumber)(k.highWaterMark)?p.loadProgressively(E,c,f,k.highWaterMark,a):v?E.arrayBuffer():E.text()}).then(function(E){var _=p.response;self.clearTimeout(p.requestTimeout),c.loading.end=Math.max(self.performance.now(),c.loading.first),c.loaded=c.total=E[g];var H={url:_.url,data:E};a&&!Object(X.isFiniteNumber)(k.highWaterMark)&&a(c,f,E,_),x.onSuccess(H,c,f,_)}).catch(function(E){if(self.clearTimeout(p.requestTimeout),c.aborted)return;var _=E.code||0;x.onError({code:_,text:E.message},f,E.details)})},T.getCacheAge=function(){var f=null;if(this.response){var k=this.response.headers.get("age");f=k?parseFloat(k):null}return f},T.loadProgressively=function(f,k,x,p,c){p===void 0&&(p=0);var s=new I.default,a=f.body.getReader(),v=function g(){return a.read().then(function(E){if(E.done)return s.dataLength&&c(k,x,s.flush(),f),Promise.resolve(new ArrayBuffer(0));var _=E.value,H=_.length;return k.loaded+=H,H<p||s.dataLength?(s.push(_),s.dataLength>=p&&c(k,x,s.flush(),f)):c(k,x,_,f),g()}).catch(function(){return Promise.reject()})};return v()},d}();function h(d,T){var y={method:"GET",mode:"cors",credentials:"same-origin",signal:T,headers:new self.Headers(L({},d.headers))};return d.rangeEnd&&y.headers.set("Range","bytes="+d.rangeStart+"-"+String(d.rangeEnd-1)),y}function o(d,T){return new self.Request(d.url,T)}var u=function(d){z(T,d);function T(y,f,k){var x;return x=d.call(this,y)||this,x.code=void 0,x.details=void 0,x.code=f,x.details=k,x}return T}(U(Error));$.default=S},"./src/utils/imsc1-ttml-parser.ts":function(ne,$,D){"use strict";D.r($),D.d($,"IMSC1_CODEC",function(){return b}),D.d($,"parseIMSC1",function(){return w});var X=D("./src/utils/mp4-tools.ts"),N=D("./src/utils/vttparser.ts"),I=D("./src/utils/vttcue.ts"),z=D("./src/demux/id3.ts"),U=D("./src/utils/timescale-conversion.ts"),P=D("./src/utils/webvtt-parser.ts");function M(){return M=Object.assign||function(p){for(var c=1;c<arguments.length;c++){var s=arguments[c];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(p[a]=s[a])}return p},M.apply(this,arguments)}var b="stpp.ttml.im1t",A=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,R=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,L={left:"start",center:"center",right:"end",start:"start",end:"end"};function w(p,c,s,a,v){var g=Object(X.findBox)(new Uint8Array(p),["mdat"]);if(g.length===0){v(new Error("Could not parse IMSC1 mdat"));return}var E=g[0],_=Object(z.utf8ArrayToStr)(new Uint8Array(p,E.start,E.end-E.start)),H=Object(U.toTimescaleFromScale)(c,1,s);try{a(S(_,H))}catch(V){v(V)}}function S(p,c){var s=new DOMParser,a=s.parseFromString(p,"text/xml"),v=a.getElementsByTagName("tt")[0];if(!v)throw new Error("Invalid ttml");var g={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},E=Object.keys(g).reduce(function(G,j){return G[j]=v.getAttribute("ttp:"+j)||g[j],G},{}),_=v.getAttribute("xml:space")!=="preserve",H=o(h(v,"styling","style")),V=o(h(v,"layout","region")),Z=h(v,"body","[begin]");return[].map.call(Z,function(G){var j=u(G,_);if(!j||!G.hasAttribute("begin"))return null;var q=f(G.getAttribute("begin"),E),ie=f(G.getAttribute("dur"),E),ce=f(G.getAttribute("end"),E);if(q===null)throw y(G);if(ce===null){if(ie===null)throw y(G);ce=q+ie}var ve=new I.default(q-c,ce-c,j);ve.id=Object(P.generateCueId)(ve.startTime,ve.endTime,ve.text);var ke=V[G.getAttribute("region")],xe=H[G.getAttribute("style")];ve.position=10,ve.size=80;var Ce=d(ke,xe),Te=Ce.textAlign;if(Te){var Ee=L[Te];Ee&&(ve.lineAlign=Ee),ve.align=Te}return M(ve,Ce),ve}).filter(function(G){return G!==null})}function h(p,c,s){var a=p.getElementsByTagName(c)[0];return a?[].slice.call(a.querySelectorAll(s)):[]}function o(p){return p.reduce(function(c,s){var a=s.getAttribute("xml:id");return a&&(c[a]=s),c},{})}function u(p,c){return[].slice.call(p.childNodes).reduce(function(s,a,v){var g;return a.nodeName==="br"&&v?s+`
|
|
`:(g=a.childNodes)!==null&&g!==void 0&&g.length?u(a,c):c?s+a.textContent.trim().replace(/\s+/g," "):s+a.textContent},"")}function d(p,c){var s="http://www.w3.org/ns/ttml#styling",a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return a.reduce(function(v,g){var E=T(c,s,g)||T(p,s,g);return E&&(v[g]=E),v},{})}function T(p,c,s){return p.hasAttributeNS(c,s)?p.getAttributeNS(c,s):null}function y(p){return new Error("Could not parse ttml timestamp "+p)}function f(p,c){if(!p)return null;var s=Object(N.parseTimeStamp)(p);return s===null&&(A.test(p)?s=k(p,c):R.test(p)&&(s=x(p,c))),s}function k(p,c){var s=A.exec(p),a=(s[4]|0)+(s[5]|0)/c.subFrameRate;return(s[1]|0)*3600+(s[2]|0)*60+(s[3]|0)+a/c.frameRate}function x(p,c){var s=R.exec(p),a=Number(s[1]),v=s[2];switch(v){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/c.frameRate;case"t":return a/c.tickRate}return a}},"./src/utils/logger.ts":function(ne,$,D){"use strict";D.r($),D.d($,"enableLogs",function(){return P}),D.d($,"logger",function(){return M});var X=function(){},N={trace:X,debug:X,log:X,warn:X,info:X,error:X},I=N;function z(b){var A=self.console[b];return A?A.bind(self.console,"["+b+"] >"):X}function U(b){for(var A=arguments.length,R=new Array(A>1?A-1:0),L=1;L<A;L++)R[L-1]=arguments[L];R.forEach(function(w){I[w]=b[w]?b[w].bind(b):z(w)})}function P(b){if(self.console&&b===!0||typeof b=="object"){U(b,"debug","log","info","warn","error");try{I.log()}catch(A){I=N}}else I=N}var M=I},"./src/utils/mediakeys-helper.ts":function(ne,$,D){"use strict";D.r($),D.d($,"KeySystems",function(){return X}),D.d($,"requestMediaKeySystemAccess",function(){return N});var X;(function(I){I.WIDEVINE="com.widevine.alpha",I.PLAYREADY="com.microsoft.playready"})(X||(X={}));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,$,D){"use strict";D.r($),D.d($,"getMediaSource",function(){return X});function X(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(ne,$,D){"use strict";D.r($),D.d($,"bin2str",function(){return U}),D.d($,"readUint16",function(){return P}),D.d($,"readUint32",function(){return M}),D.d($,"writeUint32",function(){return b}),D.d($,"findBox",function(){return A}),D.d($,"parseSegmentIndex",function(){return R}),D.d($,"parseInitSegment",function(){return L}),D.d($,"getStartDTS",function(){return w}),D.d($,"getDuration",function(){return S}),D.d($,"computeRawDurationFromSamples",function(){return h}),D.d($,"offsetStartDTS",function(){return o}),D.d($,"segmentValidRange",function(){return u}),D.d($,"appendUint8Array",function(){return d});var X=D("./src/utils/typed-array.ts"),N=D("./src/loader/fragment.ts"),I=Math.pow(2,32)-1,z=[].push;function U(T){return String.fromCharCode.apply(null,T)}function P(T,y){"data"in T&&(y+=T.start,T=T.data);var f=T[y]<<8|T[y+1];return f<0?65536+f:f}function M(T,y){"data"in T&&(y+=T.start,T=T.data);var f=T[y]<<24|T[y+1]<<16|T[y+2]<<8|T[y+3];return f<0?4294967296+f:f}function b(T,y,f){"data"in T&&(y+=T.start,T=T.data),T[y]=f>>24,T[y+1]=f>>16&255,T[y+2]=f>>8&255,T[y+3]=f&255}function A(T,y){var f=[];if(!y.length)return f;var k,x,p;"data"in T?(k=T.data,x=T.start,p=T.end):(k=T,x=0,p=k.byteLength);for(var c=x;c<p;){var s=M(k,c),a=U(k.subarray(c+4,c+8)),v=s>1?c+s:p;if(a===y[0])if(y.length===1)f.push({data:k,start:c+8,end:v});else{var g=A({data:k,start:c+8,end:v},y.slice(1));g.length&&z.apply(f,g)}c=v}return f}function R(T){var y=A(T,["moov"]),f=y[0],k=f?f.end:null,x=A(T,["sidx"]);if(!x||!x[0])return null;var p=[],c=x[0],s=c.data[0],a=s===0?8:16,v=M(c,a);a+=4;var g=0,E=0;s===0?a+=8:a+=16,a+=2;var _=c.end+E,H=P(c,a);a+=2;for(var V=0;V<H;V++){var Z=a,G=M(c,Z);Z+=4;var j=G&2147483647,q=(G&2147483648)>>>31;if(q===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var ie=M(c,Z);Z+=4,p.push({referenceSize:j,subsegmentDuration:ie,info:{duration:ie/v,start:_,end:_+j-1}}),_+=j,Z+=4,a=Z}return{earliestPresentationTime:g,timescale:v,version:s,referencesCount:H,references:p,moovEndOffset:k}}function L(T){for(var y=[],f=A(T,["moov","trak"]),k=0;k<f.length;k++){var x=f[k],p=A(x,["tkhd"])[0];if(p){var c=p.data[p.start],s=c===0?12:20,a=M(p,s),v=A(x,["mdia","mdhd"])[0];if(v){c=v.data[v.start],s=c===0?12:20;var g=M(v,s),E=A(x,["mdia","hdlr"])[0];if(E){var _=U(E.data.subarray(E.start+8,E.start+12)),H={soun:N.ElementaryStreamTypes.AUDIO,vide:N.ElementaryStreamTypes.VIDEO}[_];if(H){var V=A(x,["mdia","minf","stbl","stsd"])[0],Z=void 0;V&&(Z=U(V.data.subarray(V.start+12,V.start+16))),y[a]={timescale:g,type:H},y[H]={timescale:g,id:a,codec:Z}}}}}}var G=A(T,["moov","mvex","trex"]);return G.forEach(function(j){var q=M(j,4),ie=y[q];ie&&(ie.default={duration:M(j,12),flags:M(j,20)})}),y}function w(T,y){return A(y,["moof","traf"]).reduce(function(f,k){var x=A(k,["tfdt"])[0],p=x.data[x.start],c=A(k,["tfhd"]).reduce(function(s,a){var v=M(a,4),g=T[v];if(g){var E=M(x,4);p===1&&(E*=Math.pow(2,32),E+=M(x,8));var _=g.timescale||9e4,H=E/_;if(isFinite(H)&&(s===null||H<s))return H}return s},null);return c!==null&&isFinite(c)&&(f===null||c<f)?c:f},null)||0}function S(T,y){for(var f=0,k=0,x=0,p=A(T,["moof","traf"]),c=0;c<p.length;c++){var s=p[c],a=A(s,["tfhd"])[0],v=M(a,4),g=y[v];if(!g)continue;var E=g.default,_=M(a,0)|(E==null?void 0:E.flags),H=E==null?void 0:E.duration;_&8&&(_&2?H=M(a,12):H=M(a,8));for(var V=g.timescale||9e4,Z=A(s,["trun"]),G=0;G<Z.length;G++){if(H){var j=M(Z[G],4);f=H*j}else f=h(Z[G]);g.type===N.ElementaryStreamTypes.VIDEO?k+=f/V:g.type===N.ElementaryStreamTypes.AUDIO&&(x+=f/V)}}if(k===0&&x===0){var q=R(T);if(q!=null&&q.references)return q.references.reduce(function(ie,ce){return ie+ce.info.duration||0},0)}return k||x}function h(T){var y=M(T,0),f=8;y&1&&(f+=4),y&4&&(f+=4);for(var k=0,x=M(T,4),p=0;p<x;p++){if(y&256){var c=M(T,f);k+=c,f+=4}y&512&&(f+=4),y&1024&&(f+=4),y&2048&&(f+=4)}return k}function o(T,y,f){A(y,["moof","traf"]).forEach(function(k){A(k,["tfhd"]).forEach(function(x){var p=M(x,4),c=T[p];if(!c)return;var s=c.timescale||9e4;A(k,["tfdt"]).forEach(function(a){var v=a.data[a.start],g=M(a,4);if(v===0)b(a,4,g-f*s);else{g*=Math.pow(2,32),g+=M(a,8),g-=f*s,g=Math.max(g,0);var E=Math.floor(g/(I+1)),_=Math.floor(g%(I+1));b(a,4,E),b(a,8,_)}})})})}function u(T){var y={valid:null,remainder:null},f=A(T,["moof"]);if(f){if(f.length<2)return y.remainder=T,y}else return y;var k=f[f.length-1];return y.valid=Object(X.sliceUint8)(T,0,k.start-8),y.remainder=Object(X.sliceUint8)(T,k.start-8),y}function d(T,y){var f=new Uint8Array(T.length+y.length);return f.set(T),f.set(y,T.length),f}},"./src/utils/output-filter.ts":function(ne,$,D){"use strict";D.r($),D.d($,"default",function(){return X});var X=function(){function N(z,U){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=z,this.trackName=U}var I=N.prototype;return I.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},I.newCue=function(U,P,M){(this.startTime===null||this.startTime>U)&&(this.startTime=U),this.endTime=P,this.screen=M,this.timelineController.createCaptionsTrack(this.trackName)},I.reset=function(){this.cueRanges=[]},N}()},"./src/utils/texttrack-utils.ts":function(ne,$,D){"use strict";D.r($),D.d($,"sendAddTrackEvent",function(){return N}),D.d($,"addCueToTrack",function(){return I}),D.d($,"clearCurrentCues",function(){return z}),D.d($,"removeCuesInRange",function(){return U}),D.d($,"getCuesInRange",function(){return M});var X=D("./src/utils/logger.ts");function N(b,A){var R;try{R=new Event("addtrack")}catch(L){R=document.createEvent("Event"),R.initEvent("addtrack",!1,!1)}R.track=b,A.dispatchEvent(R)}function I(b,A){var R=b.mode;if(R==="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){X.logger.debug("[texttrack-utils]: "+w);var L=new self.TextTrackCue(A.startTime,A.endTime,A.text);L.id=A.id,b.addCue(L)}R==="disabled"&&(b.mode=R)}function z(b){var A=b.mode;if(A==="disabled"&&(b.mode="hidden"),b.cues)for(var R=b.cues.length;R--;)b.removeCue(b.cues[R]);A==="disabled"&&(b.mode=A)}function U(b,A,R){var L=b.mode;if(L==="disabled"&&(b.mode="hidden"),b.cues&&b.cues.length>0)for(var w=M(b.cues,A,R),S=0;S<w.length;S++)b.removeCue(w[S]);L==="disabled"&&(b.mode=L)}function P(b,A){if(A<b[0].startTime)return 0;var R=b.length-1;if(A>b[R].endTime)return-1;for(var L=0,w=R;L<=w;){var S=Math.floor((w+L)/2);if(A<b[S].startTime)w=S-1;else if(A>b[S].startTime&&L<R)L=S+1;else return S}return b[L].startTime-A<A-b[w].startTime?L:w}function M(b,A,R){var L=[],w=P(b,A);if(w>-1)for(var S=w,h=b.length;S<h;S++){var o=b[S];if(o.startTime>=A&&o.endTime<=R)L.push(o);else if(o.startTime>R)return L}return L}},"./src/utils/time-ranges.ts":function(ne,$,D){"use strict";D.r($);var X={toString:function(I){for(var z="",U=I.length,P=0;P<U;P++)z+="["+I.start(P).toFixed(3)+","+I.end(P).toFixed(3)+"]";return z}};$.default=X},"./src/utils/timescale-conversion.ts":function(ne,$,D){"use strict";D.r($),D.d($,"toTimescaleFromBase",function(){return N}),D.d($,"toTimescaleFromScale",function(){return I}),D.d($,"toMsFromMpegTsClock",function(){return z}),D.d($,"toMpegTsClockFromTimescale",function(){return U});var X=9e4;function N(P,M,b,A){b===void 0&&(b=1),A===void 0&&(A=!1);var R=P*M*b;return A?Math.round(R):R}function I(P,M,b,A){return b===void 0&&(b=1),A===void 0&&(A=!1),N(P,M,1/b,A)}function z(P,M){return M===void 0&&(M=!1),N(P,1e3,1/X,M)}function U(P,M){return M===void 0&&(M=1),N(P,X,1/M)}},"./src/utils/typed-array.ts":function(ne,$,D){"use strict";D.r($),D.d($,"sliceUint8",function(){return X});function X(N,I,z){return Uint8Array.prototype.slice?N.slice(I,z):new Uint8Array(Array.prototype.slice.call(N,I,z))}},"./src/utils/vttcue.ts":function(ne,$,D){"use strict";D.r($),$.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var X=["","lr","rl"],N=["start","middle","end","left","right"];function I(b,A){if(typeof A!="string")return!1;if(!Array.isArray(b))return!1;var R=A.toLowerCase();return~b.indexOf(R)?R:!1}function z(b){return I(X,b)}function U(b){return I(N,b)}function P(b){for(var A=arguments.length,R=new Array(A>1?A-1:0),L=1;L<A;L++)R[L-1]=arguments[L];for(var w=1;w<arguments.length;w++){var S=arguments[w];for(var h in S)b[h]=S[h]}return b}function M(b,A,R){var L=this,w={enumerable:!0};L.hasBeenReset=!1;var S="",h=!1,o=b,u=A,d=R,T=null,y="",f=!0,k="auto",x="start",p=50,c="middle",s=50,a="middle";Object.defineProperty(L,"id",P({},w,{get:function(){return S},set:function(g){S=""+g}})),Object.defineProperty(L,"pauseOnExit",P({},w,{get:function(){return h},set:function(g){h=!!g}})),Object.defineProperty(L,"startTime",P({},w,{get:function(){return o},set:function(g){if(typeof g!="number")throw new TypeError("Start time must be set to a number.");o=g,this.hasBeenReset=!0}})),Object.defineProperty(L,"endTime",P({},w,{get:function(){return u},set:function(g){if(typeof g!="number")throw new TypeError("End time must be set to a number.");u=g,this.hasBeenReset=!0}})),Object.defineProperty(L,"text",P({},w,{get:function(){return d},set:function(g){d=""+g,this.hasBeenReset=!0}})),Object.defineProperty(L,"region",P({},w,{get:function(){return T},set:function(g){T=g,this.hasBeenReset=!0}})),Object.defineProperty(L,"vertical",P({},w,{get:function(){return y},set:function(g){var E=z(g);if(E===!1)throw new SyntaxError("An invalid or illegal string was specified.");y=E,this.hasBeenReset=!0}})),Object.defineProperty(L,"snapToLines",P({},w,{get:function(){return f},set:function(g){f=!!g,this.hasBeenReset=!0}})),Object.defineProperty(L,"line",P({},w,{get:function(){return k},set:function(g){if(typeof g!="number"&&g!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");k=g,this.hasBeenReset=!0}})),Object.defineProperty(L,"lineAlign",P({},w,{get:function(){return x},set:function(g){var E=U(g);if(!E)throw new SyntaxError("An invalid or illegal string was specified.");x=E,this.hasBeenReset=!0}})),Object.defineProperty(L,"position",P({},w,{get:function(){return p},set:function(g){if(g<0||g>100)throw new Error("Position must be between 0 and 100.");p=g,this.hasBeenReset=!0}})),Object.defineProperty(L,"positionAlign",P({},w,{get:function(){return c},set:function(g){var E=U(g);if(!E)throw new SyntaxError("An invalid or illegal string was specified.");c=E,this.hasBeenReset=!0}})),Object.defineProperty(L,"size",P({},w,{get:function(){return s},set:function(g){if(g<0||g>100)throw new Error("Size must be between 0 and 100.");s=g,this.hasBeenReset=!0}})),Object.defineProperty(L,"align",P({},w,{get:function(){return a},set:function(g){var E=U(g);if(!E)throw new SyntaxError("An invalid or illegal string was specified.");a=E,this.hasBeenReset=!0}})),L.displayState=void 0}return M.prototype.getCueAsHTML=function(){var b=self.WebVTT;return b.convertCueToDOMTree(self,this.text)},M}()},"./src/utils/vttparser.ts":function(ne,$,D){"use strict";D.r($),D.d($,"parseTimeStamp",function(){return I}),D.d($,"fixLineBreaks",function(){return A}),D.d($,"VTTParser",function(){return R});var X=D("./src/utils/vttcue.ts"),N=function(){function L(){}var w=L.prototype;return w.decode=function(h,o){if(!h)return"";if(typeof h!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(h))},L}();function I(L){function w(h,o,u,d){return(h|0)*3600+(o|0)*60+(u|0)+parseFloat(d||0)}var S=L.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return S?parseFloat(S[2])>59?w(S[2],S[3],0,S[4]):w(S[1],S[2],S[3],S[4]):null}var z=function(){function L(){this.values=Object.create(null)}var w=L.prototype;return w.set=function(h,o){!this.get(h)&&o!==""&&(this.values[h]=o)},w.get=function(h,o,u){return u?this.has(h)?this.values[h]:o[u]:this.has(h)?this.values[h]:o},w.has=function(h){return h in this.values},w.alt=function(h,o,u){for(var d=0;d<u.length;++d)if(o===u[d]){this.set(h,o);break}},w.integer=function(h,o){/^-?\d+$/.test(o)&&this.set(h,parseInt(o,10))},w.percent=function(h,o){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(o)){var u=parseFloat(o);if(u>=0&&u<=100)return this.set(h,u),!0}return!1},L}();function U(L,w,S,h){var o=h?L.split(h):[L];for(var u in o){if(typeof o[u]!="string")continue;var d=o[u].split(S);if(d.length!==2)continue;var T=d[0],y=d[1];w(T,y)}}var P=new X.default(0,0,""),M=P.align==="middle"?"middle":"center";function b(L,w,S){var h=L;function o(){var T=I(L);if(T===null)throw new Error("Malformed timestamp: "+h);return L=L.replace(/^[^\sa-zA-Z-]+/,""),T}function u(T,y){var f=new z;U(T,function(p,c){var s;switch(p){case"region":for(var a=S.length-1;a>=0;a--)if(S[a].id===c){f.set(p,S[a].region);break}break;case"vertical":f.alt(p,c,["rl","lr"]);break;case"line":s=c.split(","),f.integer(p,s[0]),f.percent(p,s[0])&&f.set("snapToLines",!1),f.alt(p,s[0],["auto"]),s.length===2&&f.alt("lineAlign",s[1],["start",M,"end"]);break;case"position":s=c.split(","),f.percent(p,s[0]),s.length===2&&f.alt("positionAlign",s[1],["start",M,"end","line-left","line-right","auto"]);break;case"size":f.percent(p,c);break;case"align":f.alt(p,c,["start",M,"end","left","right"]);break}},/:/,/\s/),y.region=f.get("region",null),y.vertical=f.get("vertical","");var k=f.get("line","auto");k==="auto"&&P.line===-1&&(k=-1),y.line=k,y.lineAlign=f.get("lineAlign","start"),y.snapToLines=f.get("snapToLines",!0),y.size=f.get("size",100),y.align=f.get("align",M);var x=f.get("position","auto");x==="auto"&&P.position===50&&(x=y.align==="start"||y.align==="left"?0:y.align==="end"||y.align==="right"?100:50),y.position=x}function d(){L=L.replace(/^\s+/,"")}if(d(),w.startTime=o(),d(),L.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+h);L=L.substr(3),d(),w.endTime=o(),d(),u(L,w)}function A(L){return L.replace(/<br(?: \/)?>/gi,`
|
|
`)}var R=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(h){var o=this;h&&(o.buffer+=o.decoder.decode(h,{stream:!0}));function u(){var x=o.buffer,p=0;for(x=A(x);p<x.length&&x[p]!=="\r"&&x[p]!==`
|
|
`;)++p;var c=x.substr(0,p);return x[p]==="\r"&&++p,x[p]===`
|
|
`&&++p,o.buffer=x.substr(p),c}function d(x){U(x,function(p,c){},/:/)}try{var T="";if(o.state==="INITIAL"){if(!/\r\n|\n/.test(o.buffer))return this;T=u();var y=T.match(/^()?WEBVTT([ \t].*)?$/);if(!y||!y[0])throw new Error("Malformed WebVTT signature.");o.state="HEADER"}for(var f=!1;o.buffer;){if(!/\r\n|\n/.test(o.buffer))return this;f?f=!1:T=u();switch(o.state){case"HEADER":/:/.test(T)?d(T):T||(o.state="ID");continue;case"NOTE":T||(o.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(T)){o.state="NOTE";break}if(!T)continue;if(o.cue=new X.default(0,0,""),o.state="CUE",T.indexOf("-->")===-1){o.cue.id=T;continue}case"CUE":if(!o.cue){o.state="BADCUE";continue}try{b(T,o.cue,o.regionList)}catch(x){o.cue=null,o.state="BADCUE";continue}o.state="CUETEXT";continue;case"CUETEXT":{var k=T.indexOf("-->")!==-1;if(!T||k&&(f=!0)){o.oncue&&o.cue&&o.oncue(o.cue),o.cue=null,o.state="ID";continue}if(o.cue===null)continue;o.cue.text&&(o.cue.text+=`
|
|
`),o.cue.text+=T}continue;case"BADCUE":T||(o.state="ID")}}}catch(x){o.state==="CUETEXT"&&o.cue&&o.oncue&&o.oncue(o.cue),o.cue=null,o.state=o.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},w.flush=function(){var h=this;try{if((h.cue||h.state==="HEADER")&&(h.buffer+=`
|
|
|
|
`,h.parse()),h.state==="INITIAL"||h.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(o){h.onparsingerror&&h.onparsingerror(o)}return h.onflush&&h.onflush(),this},L}()},"./src/utils/webvtt-parser.ts":function(ne,$,D){"use strict";D.r($),D.d($,"generateCueId",function(){return R}),D.d($,"parseWebVTT",function(){return w});var X=D("./src/polyfills/number.ts"),N=D("./src/utils/vttparser.ts"),I=D("./src/demux/id3.ts"),z=D("./src/utils/timescale-conversion.ts"),U=D("./src/remux/mp4-remuxer.ts"),P=/\r\n|\n\r|\n|\r/g,M=function(h,o,u){return u===void 0&&(u=0),h.substr(u,o.length)===o},b=function(h){var o=parseInt(h.substr(-3)),u=parseInt(h.substr(-6,2)),d=parseInt(h.substr(-9,2)),T=h.length>9?parseInt(h.substr(0,h.indexOf(":"))):0;if(!Object(X.isFiniteNumber)(o)||!Object(X.isFiniteNumber)(u)||!Object(X.isFiniteNumber)(d)||!Object(X.isFiniteNumber)(T))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+h);return o+=1e3*u,o+=60*1e3*d,o+=60*60*1e3*T,o},A=function(h){for(var o=5381,u=h.length;u;)o=o*33^h.charCodeAt(--u);return(o>>>0).toString()};function R(S,h,o){return A(S.toString())+A(h.toString())+A(o)}var L=function(h,o,u){var d=h[o],T=h[d.prevCC];if(!T||!T.new&&d.new){h.ccOffset=h.presentationOffset=d.start,d.new=!1;return}for(;(y=T)!==null&&y!==void 0&&y.new;){var y;h.ccOffset+=d.start-T.start,d.new=!1,d=T,T=h[d.prevCC]}h.presentationOffset=u};function w(S,h,o,u,d,T,y,f){var k=new N.VTTParser,x=Object(I.utf8ArrayToStr)(new Uint8Array(S)).trim().replace(P,`
|
|
`).split(`
|
|
`),p=[],c=Object(z.toMpegTsClockFromTimescale)(h,o),s="00:00.000",a=0,v=0,g,E=!0,_=!1;k.oncue=function(H){var V=u[d],Z=u.ccOffset,G=(a-c)/9e4;if(V!=null&&V.new&&(v!==void 0?Z=u.ccOffset=V.start:L(u,d,G)),G&&(Z=G-u.presentationOffset),_){var j=H.endTime-H.startTime,q=Object(U.normalizePts)((H.startTime+Z-v)*9e4,T*9e4)/9e4;H.startTime=q,H.endTime=q+j}var ie=H.text.trim();H.text=decodeURIComponent(encodeURIComponent(ie)),H.id||(H.id=R(H.startTime,H.endTime,ie)),H.endTime>0&&p.push(H)},k.onparsingerror=function(H){g=H},k.onflush=function(){if(g){f(g);return}y(p)},x.forEach(function(H){if(E)if(M(H,"X-TIMESTAMP-MAP=")){E=!1,_=!0,H.substr(16).split(",").forEach(function(V){M(V,"LOCAL:")?s=V.substr(6):M(V,"MPEGTS:")&&(a=parseInt(V.substr(7)))});try{v=b(s)/1e3}catch(V){_=!1,g=V}return}else H===""&&(E=!1);k.parse(H+`
|
|
`)}),k.flush()}},"./src/utils/xhr-loader.ts":function(ne,$,D){"use strict";D.r($);var X=D("./src/utils/logger.ts"),N=D("./src/loader/load-stats.ts"),I=/^age:\s*[\d.]+\s*$/m,z=function(){function U(M){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=M?M.xhrSetup:null,this.stats=new N.LoadStats,this.retryDelay=0}var P=U.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,R){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=R,this.retryDelay=A.retryDelay,this.loadInternal()},P.loadInternal=function(){var b=this.config,A=this.context;if(!b)return;var R=this.loader=new self.XMLHttpRequest,L=this.stats;L.loading.first=0,L.loaded=0;var w=this.xhrSetup;try{if(w)try{w(R,A.url)}catch(o){R.open("GET",A.url,!0),w(R,A.url)}R.readyState||R.open("GET",A.url,!0);var S=this.context.headers;if(S)for(var h in S)R.setRequestHeader(h,S[h])}catch(o){this.callbacks.onError({code:R.status,text:o.message},A,R);return}A.rangeEnd&&R.setRequestHeader("Range","bytes="+A.rangeStart+"-"+(A.rangeEnd-1)),R.onreadystatechange=this.readystatechange.bind(this),R.onprogress=this.loadprogress.bind(this),R.responseType=A.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),b.timeout),R.send()},P.readystatechange=function(){var b=this.context,A=this.loader,R=this.stats;if(!b||!A)return;var L=A.readyState,w=this.config;if(R.aborted)return;if(L>=2)if(self.clearTimeout(this.requestTimeout),R.loading.first===0&&(R.loading.first=Math.max(self.performance.now(),R.loading.start)),L===4){A.onreadystatechange=null,A.onprogress=null;var S=A.status;if(S>=200&&S<300){R.loading.end=Math.max(self.performance.now(),R.loading.first);var h,o;if(b.responseType==="arraybuffer"?(h=A.response,o=h.byteLength):(h=A.responseText,o=h.length),R.loaded=R.total=o,!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(R,b,h,A),!this.callbacks)return;var d={url:A.responseURL,data:h};this.callbacks.onSuccess(d,R,b,A)}else R.retry>=w.maxRetry||S>=400&&S<499?(X.logger.error(S+" while loading "+b.url),this.callbacks.onError({code:S,text:A.statusText},b,A)):(X.logger.warn(S+" 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),R.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),w.timeout)},P.loadtimeout=function(){X.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&&I.test(this.loader.getAllResponseHeaders())){var A=this.loader.getResponseHeader("age");b=A?parseFloat(A):null}return b},U}();$.default=z}}).default})},vHTk:function(wt,ht,re){wt.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}},xLg1:function(wt,ht,re){wt.exports={flex_box_center:"flex_box_center___VP07O",flex_space_between:"flex_space_between___1tUm5",flex_box_vertical_center:"flex_box_vertical_center___-bBDj",flex_box_center_end:"flex_box_center_end___3_Ayd",flex_box_column:"flex_box_column___l_UhF",bg:"bg___3DxGz",containerTitle:"containerTitle___188k6",titleRightMenu:"titleRightMenu___1RGtC",containerDesc:"containerDesc___bV5s4",listItem:"listItem___3_fX7",listItemTitle:"listItemTitle___2YLo6",info:"info___3AkTH",actionButton:"actionButton___3p1cN"}}}]);
|