(window.webpackJsonp=window.webpackJsonp||[]).push([[198,7,8],{"+NIl":function(At,ht,re){(function(ae){ae(re("VrN/"))})(function(ae){"use strict";ae.defineMode("stex",function($,R){"use strict";function X(T,A){T.cmdState.push(A)}function N(T){return T.cmdState.length>0?T.cmdState[T.cmdState.length-1]:null}function I(T){var A=T.cmdState.pop();A&&A.closeBracket()}function z(T){for(var A=T.cmdState,C=A.length-1;C>=0;C--){var h=A[C];if(h.name=="DEFAULT")continue;return h}return{styleIdentifier:function(){return null}}}function B(T,A,C){return function(){this.name=T,this.bracketNo=0,this.style=A,this.styles=C,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var O={};O.importmodule=B("importmodule","tag",["string","builtin"]),O.documentclass=B("documentclass","tag",["","atom"]),O.usepackage=B("usepackage","tag",["atom"]),O.begin=B("begin","tag",["atom"]),O.end=B("end","tag",["atom"]),O.label=B("label","tag",["atom"]),O.ref=B("ref","tag",["atom"]),O.eqref=B("eqref","tag",["atom"]),O.cite=B("cite","tag",["atom"]),O.bibitem=B("bibitem","tag",["atom"]),O.Bibitem=B("Bibitem","tag",["atom"]),O.RBibitem=B("RBibitem","tag",["atom"]),O.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function D(T,A){T.f=A}function E(T,A){var C;if(T.match(/^\\[a-zA-Z@]+/)){var h=T.current().slice(1);return C=O.hasOwnProperty(h)?O[h]:O.DEFAULT,C=new C,X(A,C),D(A,k),C.style}if(T.match(/^\\[$&%#{}_]/))return"tag";if(T.match(/^\\[,;!\/\\]/))return"tag";if(T.match("\\["))return D(A,function(c,d){return L(c,d,"\\]")}),"keyword";if(T.match("\\("))return D(A,function(c,d){return L(c,d,"\\)")}),"keyword";if(T.match("$$"))return D(A,function(c,d){return L(c,d,"$$")}),"keyword";if(T.match("$"))return D(A,function(c,d){return L(c,d,"$")}),"keyword";var o=T.next();if(o=="%")return T.skipToEnd(),"comment";if(o=="}"||o=="]"){if(C=N(A),C)C.closeBracket(o),D(A,k);else return"error";return"bracket"}else return o=="{"||o=="["?(C=O.DEFAULT,C=new C,X(A,C),"bracket"):/\d/.test(o)?(T.eatWhile(/[\w.%]/),"atom"):(T.eatWhile(/[\w\-_]/),C=z(A),C.name=="begin"&&(C.argument=T.current()),C.styleIdentifier())}function L(T,A,C){if(T.eatSpace())return null;if(C&&T.match(C))return D(A,E),"keyword";if(T.match(/^\\[a-zA-Z@]+/))return"tag";if(T.match(/^[a-zA-Z]+/))return"variable-2";if(T.match(/^\\[$&%#{}_]/))return"tag";if(T.match(/^\\[,;!\/]/))return"tag";if(T.match(/^[\^_&]/))return"tag";if(T.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(T.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var h=T.next();return h=="{"||h=="}"||h=="["||h=="]"||h=="("||h==")"?"bracket":h=="%"?(T.skipToEnd(),"comment"):"error"}function k(T,A){var C=T.peek(),h;return C=="{"||C=="["?(h=N(A),h.openBracket(C),T.eat(C),D(A,E),"bracket"):/[ \t\r]/.test(C)?(T.eat(C),null):(D(A,E),I(A),E(T,A))}return{startState:function(){var T=R.inMathMode?function(A,C){return L(A,C)}:E;return{cmdState:[],f:T}},copyState:function(T){return{cmdState:T.cmdState.slice(),f:T.f}},token:function(T,A){return A.f(T,A)},blankLine:function(T){T.f=E,T.cmdState.length=0},lineComment:"%"}}),ae.defineMIME("text/x-stex","stex"),ae.defineMIME("text/x-latex","stex")})},"+yhJ":function(At,ht,re){At.exports=re.p+"static/xixi.d492fb65.svg"},"0eGx":function(At,ht,re){At.exports=re.p+"static/zhong.c1924b73.svg"},"19Vz":function(At,ht,re){(function(ae){ae(re("VrN/"))})(function(ae){ae.defineOption("placeholder","",function(B,O,D){var E=D&&D!=ae.Init;if(O&&!E)B.on("blur",N),B.on("change",I),B.on("swapDoc",I),ae.on(B.getInputField(),"compositionupdate",B.state.placeholderCompose=function(){X(B)}),I(B);else if(!O&&E){B.off("blur",N),B.off("change",I),B.off("swapDoc",I),ae.off(B.getInputField(),"compositionupdate",B.state.placeholderCompose),$(B);var L=B.getWrapperElement();L.className=L.className.replace(" CodeMirror-empty","")}O&&!B.hasFocus()&&N(B)});function $(B){B.state.placeholder&&(B.state.placeholder.parentNode.removeChild(B.state.placeholder),B.state.placeholder=null)}function R(B){$(B);var O=B.state.placeholder=document.createElement("pre");O.style.cssText="height: 0; overflow: visible",O.style.direction=B.getOption("direction"),O.className="CodeMirror-placeholder CodeMirror-line-like";var D=B.getOption("placeholder");typeof D=="string"&&(D=document.createTextNode(D)),O.appendChild(D),B.display.lineSpace.insertBefore(O,B.display.lineSpace.firstChild)}function X(B){setTimeout(function(){var O=!1,D=B.getInputField();D.nodeName=="TEXTAREA"?O=!D.value:B.lineCount()==1&&(O=!/[^\u200b]/.test(D.querySelector(".CodeMirror-line").textContent)),O?R(B):$(B)},20)}function N(B){z(B)&&R(B)}function I(B){var O=B.getWrapperElement(),D=z(B);O.className=O.className.replace(" CodeMirror-empty","")+(D?" CodeMirror-empty":""),D?R(B):$(B)}function z(B){return B.lineCount()===1&&B.getLine(0)===""}})},"1eCo":function(At,ht,re){(function(ae){ae(re("VrN/"))})(function(ae){"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},R={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};ae.defineMode("xml",function(X,N){var I=X.indentUnit,z={},B=N.htmlMode?$:R;for(var O in B)z[O]=B[O];for(var O in N)z[O]=N[O];var D,E;function L(a,b){function v(H){return b.tokenize=H,H(a,b)}var S=a.next();if(S=="<")return a.eat("!")?a.eat("[")?a.match("CDATA[")?v(A("atom","]]>")):null:a.match("--")?v(A("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),v(C(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),b.tokenize=A("meta","?>"),"meta"):(D=a.eat("/")?"closeTag":"openTag",b.tokenize=k,"tag bracket");if(S=="&"){var M;return a.eat("#")?a.eat("x")?M=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):M=a.eatWhile(/[\d]/)&&a.eat(";"):M=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),M?"atom":"error"}else return a.eatWhile(/[^&<]/),null}L.isInText=!0;function k(a,b){var v=a.next();if(v==">"||v=="/"&&a.eat(">"))return b.tokenize=L,D=v==">"?"endTag":"selfcloseTag","tag bracket";if(v=="=")return D="equals",null;if(v=="<"){b.tokenize=L,b.state=d,b.tagName=b.tagStart=null;var S=b.tokenize(a,b);return S?S+" tag error":"tag error"}else return/[\'\"]/.test(v)?(b.tokenize=T(v),b.stringStartCol=a.column(),b.tokenize(a,b)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function T(a){var b=function(v,S){for(;!v.eol();)if(v.next()==a){S.tokenize=k;break}return"string"};return b.isInAttribute=!0,b}function A(a,b){return function(v,S){for(;!v.eol();){if(v.match(b)){S.tokenize=L;break}v.next()}return a}}function C(a){return function(b,v){for(var S;(S=b.next())!=null;){if(S=="<")return v.tokenize=C(a+1),v.tokenize(b,v);if(S==">")if(a==1){v.tokenize=L;break}else return v.tokenize=C(a-1),v.tokenize(b,v)}return"meta"}}function h(a,b,v){this.prev=a.context,this.tagName=b,this.indent=a.indented,this.startOfLine=v,(z.doNotIndent.hasOwnProperty(b)||a.context&&a.context.noIndent)&&(this.noIndent=!0)}function o(a){a.context&&(a.context=a.context.prev)}function c(a,b){for(var v;;){if(!a.context)return;if(v=a.context.tagName,!z.contextGrabbers.hasOwnProperty(v)||!z.contextGrabbers[v].hasOwnProperty(b))return;o(a)}}function d(a,b,v){return a=="openTag"?(v.tagStart=b.column(),_):a=="closeTag"?y:d}function _(a,b,v){return a=="word"?(v.tagName=b.current(),E="tag",x):z.allowMissingTagName&&a=="endTag"?(E="tag bracket",x(a,b,v)):(E="error",_)}function y(a,b,v){if(a=="word"){var S=b.current();return v.context&&v.context.tagName!=S&&z.implicitlyClosed.hasOwnProperty(v.context.tagName)&&o(v),v.context&&v.context.tagName==S||z.matchClosing===!1?(E="tag",m):(E="tag error",l)}else return z.allowMissingTagName&&a=="endTag"?(E="tag bracket",m(a,b,v)):(E="error",l)}function m(a,b,v){return a!="endTag"?(E="error",m):(o(v),d)}function l(a,b,v){return E="error",m(a,b,v)}function x(a,b,v){if(a=="word")return E="attribute",f;if(a=="endTag"||a=="selfcloseTag"){var S=v.tagName,M=v.tagStart;return v.tagName=v.tagStart=null,a=="selfcloseTag"||z.autoSelfClosers.hasOwnProperty(S)?c(v,S):(c(v,S),v.context=new h(v,S,M==v.indented)),d}return E="error",x}function f(a,b,v){return a=="equals"?p:(z.allowMissing||(E="error"),x(a,b,v))}function p(a,b,v){return a=="string"?s:a=="word"&&z.allowUnquoted?(E="string",x):(E="error",x(a,b,v))}function s(a,b,v){return a=="string"?s:x(a,b,v)}return{startState:function(a){var b={tokenize:L,state:d,indented:a||0,tagName:null,tagStart:null,context:null};return a!=null&&(b.baseIndent=a),b},token:function(a,b){if(!b.tagName&&a.sol()&&(b.indented=a.indentation()),a.eatSpace())return null;D=null;var v=b.tokenize(a,b);return(v||D)&&v!="comment"&&(E=null,b.state=b.state(D||v,a,b),E&&(v=E=="error"?v+" error":E)),v},indent:function(a,b,v){var S=a.context;if(a.tokenize.isInAttribute)return a.tagStart==a.indented?a.stringStartCol+1:a.indented+I;if(S&&S.noIndent)return ae.Pass;if(a.tokenize!=k&&a.tokenize!=L)return v?v.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&&/$/,blockCommentStart:"",configuration:z.htmlMode?"html":"xml",helperType:z.htmlMode?"html":"xml",skipAttribute:function(a){a.state==p&&(a.state=x)},xmlCurrentTag:function(a){return a.tagName?{name:a.tagName,close:a.type=="closeTag"}:null},xmlCurrentContext:function(a){for(var b=[],v=a.context;v;v=v.prev)v.tagName&&b.push(v.tagName);return b.reverse()}}}),ae.defineMIME("text/xml","xml"),ae.defineMIME("application/xml","xml"),ae.mimeModes.hasOwnProperty("text/html")||ae.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"6+eU":function(At,ht,re){"use strict";re.d(ht,"a",function(){return m});var ae=re("wx14"),$=re("rePB"),R=re("VTBJ"),X=re("1OyB"),N=re("vuIU"),I=re("Ji7U"),z=re("LK+K"),B=re("q1tI"),O=re.n(B),D=re("TSYQ"),E=re.n(D),L=function(x){var f,p="".concat(x.rootPrefixCls,"-item"),s=E()(p,"".concat(p,"-").concat(x.page),(f={},Object($.a)(f,"".concat(p,"-active"),x.active),Object($.a)(f,x.className,!!x.className),Object($.a)(f,"".concat(p,"-disabled"),!x.page),f)),a=function(){x.onClick(x.page)},b=function(S){x.onKeyPress(S,x.onClick,x.page)};return O.a.createElement("li",{title:x.showTitle?x.page:null,className:s,onClick:a,onKeyPress:b,tabIndex:"0"},x.itemRender(x.page,"page",O.a.createElement("a",{rel:"nofollow"},x.page)))},k=L,T={ZERO:48,NINE:57,NUMPAD_ZERO:96,NUMPAD_NINE:105,BACKSPACE:8,DELETE:46,ENTER:13,ARROW_UP:38,ARROW_DOWN:40},A=function(l){Object(I.a)(f,l);var x=Object(z.a)(f);function f(){var p;Object(X.a)(this,f);for(var s=arguments.length,a=new Array(s),b=0;b=0||v.relatedTarget.className.indexOf("".concat(V,"-next"))>=0))return;p.setState({goInputText:""}),H(p.getValidValue())},p.go=function(v){var S=p.state.goInputText;if(S==="")return;(v.keyCode===T.ENTER||v.type==="click")&&(p.setState({goInputText:""}),p.props.quickGo(p.getValidValue()))},p}return Object(N.a)(f,[{key:"getValidValue",value:function(){var s=this.state,a=s.goInputText,b=s.current;return!a||isNaN(a)?b:Number(a)}},{key:"getPageSizeOptions",value:function(){var s=this.props,a=s.pageSize,b=s.pageSizeOptions;return b.some(function(v){return v.toString()===a.toString()})?b:b.concat([a.toString()]).sort(function(v,S){var M=isNaN(Number(v))?0:Number(v),H=isNaN(Number(S))?0:Number(S);return M-H})}},{key:"render",value:function(){var s=this,a=this.props,b=a.pageSize,v=a.locale,S=a.rootPrefixCls,M=a.changeSize,H=a.quickGo,V=a.goButton,Q=a.selectComponentClass,G=a.buildOptionText,W=a.selectPrefixCls,q=a.disabled,oe=this.state.goInputText,fe="".concat(S,"-options"),ve=Q,De=null,Ee=null,_e=null;if(!M&&!H)return null;var Te=this.getPageSizeOptions();if(M&&ve){var Ce=Te.map(function(me,ne){return O.a.createElement(ve.Option,{key:ne,value:me.toString()},(G||s.buildOptionText)(me))});De=O.a.createElement(ve,{disabled:q,prefixCls:W,showSearch:!1,className:"".concat(fe,"-size-changer"),optionLabelProp:"children",dropdownMatchSelectWidth:!1,value:(b||Te[0]).toString(),onChange:this.changeSize,getPopupContainer:function(ne){return ne.parentNode}},Ce)}return H&&(V&&(_e=typeof V=="boolean"?O.a.createElement("button",{type:"button",onClick:this.go,onKeyUp:this.go,disabled:q,className:"".concat(fe,"-quick-jumper-button")},v.jump_to_confirm):O.a.createElement("span",{onClick:this.go,onKeyUp:this.go},V)),Ee=O.a.createElement("div",{className:"".concat(fe,"-quick-jumper")},v.jump_to,O.a.createElement("input",{disabled:q,type:"text",value:oe,onChange:this.handleChange,onKeyUp:this.go,onBlur:this.handleBlur}),v.page,_e)),O.a.createElement("li",{className:"".concat(fe)},De,Ee)}}]),f}(O.a.Component);A.defaultProps={pageSizeOptions:["10","20","50","100"]};var C=A,h=re("N2Kk");function o(){}function c(l){return typeof l=="number"&&isFinite(l)&&Math.floor(l)===l}function d(l,x,f){return f}function _(l,x,f){var p=typeof l=="undefined"?x.pageSize:l;return Math.floor((f.total-1)/p)+1}var y=function(l){Object(I.a)(f,l);var x=Object(z.a)(f);function f(p){var s;Object(X.a)(this,f),s=x.call(this,p),s.getJumpPrevPage=function(){return Math.max(1,s.state.current-(s.props.showLessItems?3:5))},s.getJumpNextPage=function(){return Math.min(_(void 0,s.state,s.props),s.state.current+(s.props.showLessItems?3:5))},s.getItemIcon=function(M,H){var V=s.props.prefixCls,Q=M||O.a.createElement("button",{type:"button","aria-label":H,className:"".concat(V,"-item-link")});return typeof M=="function"&&(Q=O.a.createElement(M,Object(R.a)({},s.props))),Q},s.savePaginationNode=function(M){s.paginationNode=M},s.isValid=function(M){return c(M)&&M!==s.state.current},s.shouldDisplayQuickJumper=function(){var M=s.props,H=M.showQuickJumper,V=M.pageSize,Q=M.total;return Q<=V?!1:H},s.handleKeyDown=function(M){(M.keyCode===T.ARROW_UP||M.keyCode===T.ARROW_DOWN)&&M.preventDefault()},s.handleKeyUp=function(M){var H=s.getValidValue(M),V=s.state.currentInputValue;H!==V&&s.setState({currentInputValue:H}),M.keyCode===T.ENTER?s.handleChange(H):M.keyCode===T.ARROW_UP?s.handleChange(H-1):M.keyCode===T.ARROW_DOWN&&s.handleChange(H+1)},s.changePageSize=function(M){var H=s.state.current,V=_(M,s.state,s.props);H=H>V?V:H,V===0&&(H=s.state.current),typeof M=="number"&&("pageSize"in s.props||s.setState({pageSize:M}),"current"in s.props||s.setState({current:H,currentInputValue:H})),s.props.onShowSizeChange(H,M),"onChange"in s.props&&s.props.onChange&&s.props.onChange(H,M)},s.handleChange=function(M){var H=s.props.disabled,V=M;if(s.isValid(V)&&!H){var Q=_(void 0,s.state,s.props);V>Q?V=Q: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<_(void 0,s.state,s.props)},s.runIfEnter=function(M,H){if(M.key==="Enter"||M.charCode===13){for(var V=arguments.length,Q=new Array(V>2?V-2:0),G=2;G=b?S=b:S=Number(a),S}},{key:"getShowSizeChanger",value:function(){var s=this.props,a=s.showSizeChanger,b=s.total,v=s.totalBoundaryShowSizeChanger;return typeof a!="undefined"?a:b>v}},{key:"renderPrev",value:function(s){var a=this.props,b=a.prevIcon,v=a.itemRender,S=v(s,"prev",this.getItemIcon(b,"prev page")),M=!this.hasPrev();return Object(B.isValidElement)(S)?Object(B.cloneElement)(S,{disabled:M}):S}},{key:"renderNext",value:function(s){var a=this.props,b=a.nextIcon,v=a.itemRender,S=v(s,"next",this.getItemIcon(b,"next page")),M=!this.hasNext();return Object(B.isValidElement)(S)?Object(B.cloneElement)(S,{disabled:M}):S}},{key:"render",value:function(){var s=this,a=this.props,b=a.prefixCls,v=a.className,S=a.style,M=a.disabled,H=a.hideOnSinglePage,V=a.total,Q=a.locale,G=a.showQuickJumper,W=a.showLessItems,q=a.showTitle,oe=a.showTotal,fe=a.simple,ve=a.itemRender,De=a.showPrevNextJumpers,Ee=a.jumpPrevIcon,_e=a.jumpNextIcon,Te=a.selectComponentClass,Ce=a.selectPrefixCls,me=a.pageSizeOptions,ne=this.state,Ae=ne.current,rt=ne.pageSize,$e=ne.currentInputValue;if(H===!0&&V<=rt)return null;var Xe=_(void 0,this.state,this.props),Ve=[],Le=null,Me=null,ze=null,Ge=null,He=null,Be=G&&G.goButton,Pe=W?1:2,pt=Ae-1>0?Ae-1:0,it=Ae+1=Pe*2&&Ae!==1+2&&(Ve[0]=Object(B.cloneElement)(Ve[0],{className:"".concat(b,"-item-after-jump-prev")}),Ve.unshift(Le)),Xe-Ae>=Pe*2&&Ae!==Xe-2&&(Ve[Ve.length-1]=Object(B.cloneElement)(Ve[Ve.length-1],{className:"".concat(b,"-item-before-jump-next")}),Ve.push(Me)),gt!==1&&Ve.unshift(ze),lt!==Xe&&Ve.push(Ge)}var ge=null;oe&&(ge=O.a.createElement("li",{className:"".concat(b,"-total-text")},oe(V,[V===0?0:(Ae-1)*rt+1,Ae*rt>V?V:Ae*rt])));var de=!this.hasPrev()||!Xe,pe=!this.hasNext()||!Xe;return O.a.createElement("ul",Object(ae.a)({className:E()(b,v,Object($.a)({},"".concat(b,"-disabled"),M)),style:S,unselectable:"unselectable",ref:this.savePaginationNode},et),ge,O.a.createElement("li",{title:q?Q.prev_page:null,onClick:this.prev,tabIndex:de?null:0,onKeyPress:this.runIfEnterPrev,className:E()("".concat(b,"-prev"),Object($.a)({},"".concat(b,"-disabled"),de)),"aria-disabled":de},this.renderPrev(pt)),Ve,O.a.createElement("li",{title:q?Q.next_page:null,onClick:this.next,tabIndex:pe?null:0,onKeyPress:this.runIfEnterNext,className:E()("".concat(b,"-next"),Object($.a)({},"".concat(b,"-disabled"),pe)),"aria-disabled":pe},this.renderNext(it)),O.a.createElement(C,{disabled:M,locale:Q,rootPrefixCls:b,selectComponentClass:Te,selectPrefixCls:Ce,changeSize:this.getShowSizeChanger()?this.changePageSize:null,current:Ae,pageSize:rt,pageSizeOptions:me,quickGo:this.shouldDisplayQuickJumper()?this.handleChange:null,goButton:Be}))}}],[{key:"getDerivedStateFromProps",value:function(s,a){var b={};if("current"in s&&(b.current=s.current,s.current!==a.current&&(b.currentInputValue=b.current)),"pageSize"in s&&s.pageSize!==a.pageSize){var v=a.current,S=_(s.pageSize,a,s);v=v>S?S:v,"current"in s||(b.current=v,b.currentInputValue=v),b.pageSize=s.pageSize}return b}}]),f}(O.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 m=y},"6K3P":function(At,ht,re){At.exports=re.p+"static/jinshi.9b74f304.svg"},"7Cbv":function(At,ht,re){"use strict";var ae=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),$=new Uint8Array(16);function R(){if(!ae)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ae($)}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(k){return typeof k=="string"&&X.test(k)}for(var I=N,z=[],B=0;B<256;++B)z.push((B+256).toString(16).substr(1));function O(k){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,A=(z[k[T+0]]+z[k[T+1]]+z[k[T+2]]+z[k[T+3]]+"-"+z[k[T+4]]+z[k[T+5]]+"-"+z[k[T+6]]+z[k[T+7]]+"-"+z[k[T+8]]+z[k[T+9]]+"-"+z[k[T+10]]+z[k[T+11]]+z[k[T+12]]+z[k[T+13]]+z[k[T+14]]+z[k[T+15]]).toLowerCase();if(!I(A))throw TypeError("Stringified UUID is invalid");return A}var D=O;function E(k,T,A){k=k||{};var C=k.random||(k.rng||R)();if(C[6]=C[6]&15|64,C[8]=C[8]&63|128,T){A=A||0;for(var h=0;h<16;++h)T[A+h]=C[h];return T}return D(C)}var L=ht.a=E},"7ahc":function(At,ht,re){"use strict";re.d(ht,"a",function(){return _});var ae=re("k1fw"),$=re("0Owb"),R=re("+L6B"),X=re("2/Rp"),N=re("y8nQ"),I=re("Vl3Y"),z=re("tJVT"),B=re("OaEy"),O=re("2fM7"),D=re("q1tI"),E=re.n(D),L=re("VrN/"),k=re.n(L),T=re("p77/"),A=re.n(T),C=re("c5Ni"),h=re.n(C),o=O.a.Option,c={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 m=y.callback,l=y.onCancel,x=Object(D.useState)("python"),f=Object(z.a)(x,2),p=f[0],s=f[1];function a(v){s(d[v][1])}function b(v){m(v)}return E.a.createElement(I.a,Object($.a)({},c,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:b}),E.a.createElement(I.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},E.a.createElement(O.a,{onChange:a},Object.keys(d).map(function(v){return E.a.createElement(o,{key:v,value:v},d[v][0])}))),E.a.createElement(I.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},E.a.createElement(_,{mode:p})),E.a.createElement("div",{className:"flex-container flex-end"},E.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),E.a.createElement(X.a,{type:"ghost",onClick:l},"\u53D6\u6D88")))};function _(y){var m=y.value,l=y.onChange,x=y.mode,f=y.options,p=f===void 0?{}:f,s=Object(D.useRef)(),a=Object(D.useState)(),b=Object(z.a)(a,2),v=b[0],S=b[1];return Object(D.useEffect)(function(){if(v){function M(H){var V=H.getValue();l&&l(V)}return v.on("change",M),function(){v.off("change",M)}}},[v,l]),Object(D.useEffect)(function(){v&&v.setOption("mode",x)},[v,x]),Object(D.useEffect)(function(){v&&((m!==v.getValue()||m==="")&&setTimeout(function(){v.setValue(m||" ")},300))},[v,m]),Object(D.useEffect)(function(){if(s.current&&!v){var M=k.a.fromTextArea(s.current,Object(ae.a)({mode:x,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},p));S(M)}},[s.current,v]),E.a.createElement("div",{className:"my-codemirror-container"},E.a.createElement("textarea",{ref:s}))}},"7ixt":function(At,ht,re){"use strict";re.d(ht,"a",function(){return R});var ae={adjustX:1,adjustY:1},$=[0,0],R={left:{points:["cr","cl"],overflow:ae,offset:[-4,0],targetOffset:$},right:{points:["cl","cr"],overflow:ae,offset:[4,0],targetOffset:$},top:{points:["bc","tc"],overflow:ae,offset:[0,-4],targetOffset:$},bottom:{points:["tc","bc"],overflow:ae,offset:[0,4],targetOffset:$},topLeft:{points:["bl","tl"],overflow:ae,offset:[0,-4],targetOffset:$},leftTop:{points:["tr","tl"],overflow:ae,offset:[-4,0],targetOffset:$},topRight:{points:["br","tr"],overflow:ae,offset:[0,-4],targetOffset:$},rightTop:{points:["tl","tr"],overflow:ae,offset:[4,0],targetOffset:$},bottomRight:{points:["tr","br"],overflow:ae,offset:[0,4],targetOffset:$},rightBottom:{points:["bl","br"],overflow:ae,offset:[4,0],targetOffset:$},bottomLeft:{points:["tl","bl"],overflow:ae,offset:[0,4],targetOffset:$},leftBottom:{points:["br","bl"],overflow:ae,offset:[-4,0],targetOffset:$}},X=R},"7qnI":function(At,ht,re){"use strict";var ae=re("5Dmo"),$=re("3S7+"),R=re("fWQN"),X=re("mtLc"),N=re("yKVA"),I=re("879j"),z=re("5NDa"),B=re("5rEg"),O=re("q1tI"),D=re.n(O),E=re("O2Wb"),L=re.n(E),k=B.a.TextArea,T=function(A){Object(N.a)(h,A);var C=Object(I.a)(h);function h(){return Object(R.a)(this,h),C.apply(this,arguments)}return Object(X.a)(h,[{key:"render",value:function(){var c=this,d=this.props,_=d.index,y=d.onAnswerChange,m=d.addChildAnswer,l=d.exerciseIsPublish,x=d.answers,f=d.activeOptionErrorIndex,p=d.flex,s=p===void 0?"0 0 1000px":p;return D.a.createElement("div",{className:L.a.flex},D.a.createElement("div",{className:"".concat(L.a.color666," mb5 mt6"),style:{flex:"0 0 90px"}},"\u7B54\u6848(\u586B\u7A7A",_+1,"):"),D.a.createElement("div",{className:"".concat(L.a.flex," ").concat(L.a.flex1),style:{flexDirection:"column"}},x.map(function(a,b){var v="".concat(_,"-").concat(b);return D.a.createElement("div",{className:"".concat(L.a.flex," ").concat(L.a.flex1),key:b},D.a.createElement("div",{className:L.a.flex1,style:{flex:s}},D.a.createElement("div",null,D.a.createElement(k,{className:v===f?L.a.error:"",spellCheck:!1,rows:4,value:a||"",defaultValue:"\u8BF7\u8F93\u5165\u53C2\u8003\u7B54\u6848".concat(b==0?"":"(\u53EF\u9009)"),onChange:function(M){return y(_,b,M.target.value)},style:{minHeight:95}}))),!l&&D.a.createElement(D.a.Fragment,null,b!=0&&D.a.createElement($.a,{title:"\u5220\u9664"},D.a.createElement("i",{className:"".concat(L.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){return c.props.deleteChildAnswer(_,b)},style:{float:"right"}})),b===0&&D.a.createElement($.a,{title:"\u5220\u9664"},D.a.createElement("i",{className:"".concat(L.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){return c.props.deleteChildAnswermain(_,b)},style:{float:"right"}})),D.a.createElement($.a,{title:"\u65B0\u589E\u53C2\u8003\u7B54\u6848"},D.a.createElement("i",{className:"".concat(L.a.addIcon," iconfont icon-roundaddfill ml6"),onClick:function(){return m(_)},style:{float:"right",visibility:b==x.length-1?"":"hidden"}}))))})))}}]),h}(O.Component);ht.a=T},"8EBN":function(At,ht,re){(function(ae){ae(re("VrN/"))})(function(ae){"use strict";ae.modeInfo=[{name:"APL",mime:"text/apl",mode:"apl",ext:["dyalog","apl"]},{name:"PGP",mimes:["application/pgp","application/pgp-encrypted","application/pgp-keys","application/pgp-signature"],mode:"asciiarmor",ext:["asc","pgp","sig"]},{name:"ASN.1",mime:"text/x-ttcn-asn",mode:"asn.1",ext:["asn","asn1"]},{name:"Asterisk",mime:"text/x-asterisk",mode:"asterisk",file:/^extensions\.conf$/i},{name:"Brainfuck",mime:"text/x-brainfuck",mode:"brainfuck",ext:["b","bf"]},{name:"C",mime:"text/x-csrc",mode:"clike",ext:["c","h","ino"]},{name:"C++",mime:"text/x-c++src",mode:"clike",ext:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],alias:["cpp"]},{name:"Cobol",mime:"text/x-cobol",mode:"cobol",ext:["cob","cpy"]},{name:"C#",mime:"text/x-csharp",mode:"clike",ext:["cs"],alias:["csharp","cs"]},{name:"Clojure",mime:"text/x-clojure",mode:"clojure",ext:["clj","cljc","cljx"]},{name:"ClojureScript",mime:"text/x-clojurescript",mode:"clojure",ext:["cljs"]},{name:"Closure Stylesheets (GSS)",mime:"text/x-gss",mode:"css",ext:["gss"]},{name:"CMake",mime:"text/x-cmake",mode:"cmake",ext:["cmake","cmake.in"],file:/^CMakeLists\.txt$/},{name:"CoffeeScript",mimes:["application/vnd.coffeescript","text/coffeescript","text/x-coffeescript"],mode:"coffeescript",ext:["coffee"],alias:["coffee","coffee-script"]},{name:"Common Lisp",mime:"text/x-common-lisp",mode:"commonlisp",ext:["cl","lisp","el"],alias:["lisp"]},{name:"Cypher",mime:"application/x-cypher-query",mode:"cypher",ext:["cyp","cypher"]},{name:"Cython",mime:"text/x-cython",mode:"python",ext:["pyx","pxd","pxi"]},{name:"Crystal",mime:"text/x-crystal",mode:"crystal",ext:["cr"]},{name:"CSS",mime:"text/css",mode:"css",ext:["css"]},{name:"CQL",mime:"text/x-cassandra",mode:"sql",ext:["cql"]},{name:"D",mime:"text/x-d",mode:"d",ext:["d"]},{name:"Dart",mimes:["application/dart","text/x-dart"],mode:"dart",ext:["dart"]},{name:"diff",mime:"text/x-diff",mode:"diff",ext:["diff","patch"]},{name:"Django",mime:"text/x-django",mode:"django"},{name:"Dockerfile",mime:"text/x-dockerfile",mode:"dockerfile",file:/^Dockerfile$/},{name:"DTD",mime:"application/xml-dtd",mode:"dtd",ext:["dtd"]},{name:"Dylan",mime:"text/x-dylan",mode:"dylan",ext:["dylan","dyl","intr"]},{name:"EBNF",mime:"text/x-ebnf",mode:"ebnf"},{name:"ECL",mime:"text/x-ecl",mode:"ecl",ext:["ecl"]},{name:"edn",mime:"application/edn",mode:"clojure",ext:["edn"]},{name:"Eiffel",mime:"text/x-eiffel",mode:"eiffel",ext:["e"]},{name:"Elm",mime:"text/x-elm",mode:"elm",ext:["elm"]},{name:"Embedded Javascript",mime:"application/x-ejs",mode:"htmlembedded",ext:["ejs"]},{name:"Embedded Ruby",mime:"application/x-erb",mode:"htmlembedded",ext:["erb"]},{name:"Erlang",mime:"text/x-erlang",mode:"erlang",ext:["erl"]},{name:"Esper",mime:"text/x-esper",mode:"sql"},{name:"Factor",mime:"text/x-factor",mode:"factor",ext:["factor"]},{name:"FCL",mime:"text/x-fcl",mode:"fcl"},{name:"Forth",mime:"text/x-forth",mode:"forth",ext:["forth","fth","4th"]},{name:"Fortran",mime:"text/x-fortran",mode:"fortran",ext:["f","for","f77","f90","f95"]},{name:"F#",mime:"text/x-fsharp",mode:"mllike",ext:["fs"],alias:["fsharp"]},{name:"Gas",mime:"text/x-gas",mode:"gas",ext:["s"]},{name:"Gherkin",mime:"text/x-feature",mode:"gherkin",ext:["feature"]},{name:"GitHub Flavored Markdown",mime:"text/x-gfm",mode:"gfm",file:/^(readme|contributing|history)\.md$/i},{name:"Go",mime:"text/x-go",mode:"go",ext:["go"]},{name:"Groovy",mime:"text/x-groovy",mode:"groovy",ext:["groovy","gradle"],file:/^Jenkinsfile$/},{name:"HAML",mime:"text/x-haml",mode:"haml",ext:["haml"]},{name:"Haskell",mime:"text/x-haskell",mode:"haskell",ext:["hs"]},{name:"Haskell (Literate)",mime:"text/x-literate-haskell",mode:"haskell-literate",ext:["lhs"]},{name:"Haxe",mime:"text/x-haxe",mode:"haxe",ext:["hx"]},{name:"HXML",mime:"text/x-hxml",mode:"haxe",ext:["hxml"]},{name:"ASP.NET",mime:"application/x-aspx",mode:"htmlembedded",ext:["aspx"],alias:["asp","aspx"]},{name:"HTML",mime:"text/html",mode:"htmlmixed",ext:["html","htm","handlebars","hbs"],alias:["xhtml"]},{name:"HTTP",mime:"message/http",mode:"http"},{name:"IDL",mime:"text/x-idl",mode:"idl",ext:["pro"]},{name:"Pug",mime:"text/x-pug",mode:"pug",ext:["jade","pug"],alias:["jade"]},{name:"Java",mime:"text/x-java",mode:"clike",ext:["java"]},{name:"Java Server Pages",mime:"application/x-jsp",mode:"htmlembedded",ext:["jsp"],alias:["jsp"]},{name:"JavaScript",mimes:["text/javascript","text/ecmascript","application/javascript","application/x-javascript","application/ecmascript"],mode:"javascript",ext:["js"],alias:["ecmascript","js","node"]},{name:"JSON",mimes:["application/json","application/x-json"],mode:"javascript",ext:["json","map"],alias:["json5"]},{name:"JSON-LD",mime:"application/ld+json",mode:"javascript",ext:["jsonld"],alias:["jsonld"]},{name:"JSX",mime:"text/jsx",mode:"jsx",ext:["jsx"]},{name:"Jinja2",mime:"text/jinja2",mode:"jinja2",ext:["j2","jinja","jinja2"]},{name:"Julia",mime:"text/x-julia",mode:"julia",ext:["jl"]},{name:"Kotlin",mime:"text/x-kotlin",mode:"clike",ext:["kt"]},{name:"LESS",mime:"text/x-less",mode:"css",ext:["less"]},{name:"LiveScript",mime:"text/x-livescript",mode:"livescript",ext:["ls"],alias:["ls"]},{name:"Lua",mime:"text/x-lua",mode:"lua",ext:["lua"]},{name:"Markdown",mime:"text/x-markdown",mode:"markdown",ext:["markdown","md","mkd"]},{name:"mIRC",mime:"text/mirc",mode:"mirc"},{name:"MariaDB SQL",mime:"text/x-mariadb",mode:"sql"},{name:"Mathematica",mime:"text/x-mathematica",mode:"mathematica",ext:["m","nb","wl","wls"]},{name:"Modelica",mime:"text/x-modelica",mode:"modelica",ext:["mo"]},{name:"MUMPS",mime:"text/x-mumps",mode:"mumps",ext:["mps"]},{name:"MS SQL",mime:"text/x-mssql",mode:"sql"},{name:"mbox",mime:"application/mbox",mode:"mbox",ext:["mbox"]},{name:"MySQL",mime:"text/x-mysql",mode:"sql"},{name:"Nginx",mime:"text/x-nginx-conf",mode:"nginx",file:/nginx.*\.conf$/i},{name:"NSIS",mime:"text/x-nsis",mode:"nsis",ext:["nsh","nsi"]},{name:"NTriples",mimes:["application/n-triples","application/n-quads","text/n-triples"],mode:"ntriples",ext:["nt","nq"]},{name:"Objective-C",mime:"text/x-objectivec",mode:"clike",ext:["m"],alias:["objective-c","objc"]},{name:"Objective-C++",mime:"text/x-objectivec++",mode:"clike",ext:["mm"],alias:["objective-c++","objc++"]},{name:"OCaml",mime:"text/x-ocaml",mode:"mllike",ext:["ml","mli","mll","mly"]},{name:"Octave",mime:"text/x-octave",mode:"octave",ext:["m"]},{name:"Oz",mime:"text/x-oz",mode:"oz",ext:["oz"]},{name:"Pascal",mime:"text/x-pascal",mode:"pascal",ext:["p","pas"]},{name:"PEG.js",mime:"null",mode:"pegjs",ext:["jsonld"]},{name:"Perl",mime:"text/x-perl",mode:"perl",ext:["pl","pm"]},{name:"PHP",mimes:["text/x-php","application/x-httpd-php","application/x-httpd-php-open"],mode:"php",ext:["php","php3","php4","php5","php7","phtml"]},{name:"Pig",mime:"text/x-pig",mode:"pig",ext:["pig"]},{name:"Plain Text",mime:"text/plain",mode:"null",ext:["txt","text","conf","def","list","log"]},{name:"PLSQL",mime:"text/x-plsql",mode:"sql",ext:["pls"]},{name:"PostgreSQL",mime:"text/x-pgsql",mode:"sql"},{name:"PowerShell",mime:"application/x-powershell",mode:"powershell",ext:["ps1","psd1","psm1"]},{name:"Properties files",mime:"text/x-properties",mode:"properties",ext:["properties","ini","in"],alias:["ini","properties"]},{name:"ProtoBuf",mime:"text/x-protobuf",mode:"protobuf",ext:["proto"]},{name:"Python",mime:"text/x-python",mode:"python",ext:["BUILD","bzl","py","pyw"],file:/^(BUCK|BUILD)$/},{name:"Puppet",mime:"text/x-puppet",mode:"puppet",ext:["pp"]},{name:"Q",mime:"text/x-q",mode:"q",ext:["q"]},{name:"R",mime:"text/x-rsrc",mode:"r",ext:["r","R"],alias:["rscript"]},{name:"reStructuredText",mime:"text/x-rst",mode:"rst",ext:["rst"],alias:["rst"]},{name:"RPM Changes",mime:"text/x-rpm-changes",mode:"rpm"},{name:"RPM Spec",mime:"text/x-rpm-spec",mode:"rpm",ext:["spec"]},{name:"Ruby",mime:"text/x-ruby",mode:"ruby",ext:["rb"],alias:["jruby","macruby","rake","rb","rbx"]},{name:"Rust",mime:"text/x-rustsrc",mode:"rust",ext:["rs"]},{name:"SAS",mime:"text/x-sas",mode:"sas",ext:["sas"]},{name:"Sass",mime:"text/x-sass",mode:"sass",ext:["sass"]},{name:"Scala",mime:"text/x-scala",mode:"clike",ext:["scala"]},{name:"Scheme",mime:"text/x-scheme",mode:"scheme",ext:["scm","ss"]},{name:"SCSS",mime:"text/x-scss",mode:"css",ext:["scss"]},{name:"Shell",mimes:["text/x-sh","application/x-sh"],mode:"shell",ext:["sh","ksh","bash"],alias:["bash","sh","zsh"],file:/^PKGBUILD$/},{name:"Sieve",mime:"application/sieve",mode:"sieve",ext:["siv","sieve"]},{name:"Slim",mimes:["text/x-slim","application/x-slim"],mode:"slim",ext:["slim"]},{name:"Smalltalk",mime:"text/x-stsrc",mode:"smalltalk",ext:["st"]},{name:"Smarty",mime:"text/x-smarty",mode:"smarty",ext:["tpl"]},{name:"Solr",mime:"text/x-solr",mode:"solr"},{name:"SML",mime:"text/x-sml",mode:"mllike",ext:["sml","sig","fun","smackspec"]},{name:"Soy",mime:"text/x-soy",mode:"soy",ext:["soy"],alias:["closure template"]},{name:"SPARQL",mime:"application/sparql-query",mode:"sparql",ext:["rq","sparql"],alias:["sparul"]},{name:"Spreadsheet",mime:"text/x-spreadsheet",mode:"spreadsheet",alias:["excel","formula"]},{name:"SQL",mime:"text/x-sql",mode:"sql",ext:["sql"]},{name:"SQLite",mime:"text/x-sqlite",mode:"sql"},{name:"Squirrel",mime:"text/x-squirrel",mode:"clike",ext:["nut"]},{name:"Stylus",mime:"text/x-styl",mode:"stylus",ext:["styl"]},{name:"Swift",mime:"text/x-swift",mode:"swift",ext:["swift"]},{name:"sTeX",mime:"text/x-stex",mode:"stex"},{name:"LaTeX",mime:"text/x-latex",mode:"stex",ext:["text","ltx","tex"],alias:["tex"]},{name:"SystemVerilog",mime:"text/x-systemverilog",mode:"verilog",ext:["v","sv","svh"]},{name:"Tcl",mime:"text/x-tcl",mode:"tcl",ext:["tcl"]},{name:"Textile",mime:"text/x-textile",mode:"textile",ext:["textile"]},{name:"TiddlyWiki",mime:"text/x-tiddlywiki",mode:"tiddlywiki"},{name:"Tiki wiki",mime:"text/tiki",mode:"tiki"},{name:"TOML",mime:"text/x-toml",mode:"toml",ext:["toml"]},{name:"Tornado",mime:"text/x-tornado",mode:"tornado"},{name:"troff",mime:"text/troff",mode:"troff",ext:["1","2","3","4","5","6","7","8","9"]},{name:"TTCN",mime:"text/x-ttcn",mode:"ttcn",ext:["ttcn","ttcn3","ttcnpp"]},{name:"TTCN_CFG",mime:"text/x-ttcn-cfg",mode:"ttcn-cfg",ext:["cfg"]},{name:"Turtle",mime:"text/turtle",mode:"turtle",ext:["ttl"]},{name:"TypeScript",mime:"application/typescript",mode:"javascript",ext:["ts"],alias:["ts"]},{name:"TypeScript-JSX",mime:"text/typescript-jsx",mode:"jsx",ext:["tsx"],alias:["tsx"]},{name:"Twig",mime:"text/x-twig",mode:"twig"},{name:"Web IDL",mime:"text/x-webidl",mode:"webidl",ext:["webidl"]},{name:"VB.NET",mime:"text/x-vb",mode:"vb",ext:["vb"]},{name:"VBScript",mime:"text/vbscript",mode:"vbscript",ext:["vbs"]},{name:"Velocity",mime:"text/velocity",mode:"velocity",ext:["vtl"]},{name:"Verilog",mime:"text/x-verilog",mode:"verilog",ext:["v"]},{name:"VHDL",mime:"text/x-vhdl",mode:"vhdl",ext:["vhd","vhdl"]},{name:"Vue.js Component",mimes:["script/x-vue","text/x-vue"],mode:"vue",ext:["vue"]},{name:"XML",mimes:["application/xml","text/xml"],mode:"xml",ext:["xml","xsl","xsd","svg"],alias:["rss","wsdl","xsd"]},{name:"XQuery",mime:"application/xquery",mode:"xquery",ext:["xy","xquery"]},{name:"Yacas",mime:"text/x-yacas",mode:"yacas",ext:["ys"]},{name:"YAML",mimes:["text/x-yaml","text/yaml"],mode:"yaml",ext:["yaml","yml"],alias:["yml"]},{name:"Z80",mime:"text/x-z80",mode:"z80",ext:["z80"]},{name:"mscgen",mime:"text/x-mscgen",mode:"mscgen",ext:["mscgen","mscin","msc"]},{name:"xu",mime:"text/x-xu",mode:"mscgen",ext:["xu"]},{name:"msgenny",mime:"text/x-msgenny",mode:"mscgen",ext:["msgenny"]},{name:"WebAssembly",mime:"text/webassembly",mode:"wast",ext:["wat","wast"]}];for(var $=0;$-1&&X.substring(z+1,X.length);if(B)return ae.findModeByExtension(B)},ae.findModeByName=function(X){X=X.toLowerCase();for(var N=0;N=P.length?J.slice(P.length):J}).join(` `)}var h=[],o=["
    "],c=new T.a.Renderer,d=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function _(){h.length=0,o=["
      "]}var y={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function m(U,u,g,P){if(u>=U.length||U[u].level<=g)return u;var J=U[u];P.push("
    • "+J.text+""),u++;var j=[];return u=m(U,u,J.level,j),j.length>0&&(P.push("
        "),j.forEach(function(ce){P.push(ce)}),P.push("
      ")),P.push("
    • "),u=m(U,u,g,P),u}function l(){return m(h,0,0,o),o.push("
    "),o.join("")}var x={heading:function(u){var g=d.exec(u);if(g)return{type:"heading",raw:g[0],depth:g[1].length,text:g[2]}},fences:function(u){var g=this.rules.block.fences.exec(u);if(g){var P=g[0],J=C(P,g[3]||""),j=g[2]?g[2].trim():g[2];if(["latex","katex","math"].indexOf(j)>=0){var ce=s(),Ne=J;J=ce,a[ce]={type:"block",expression:Ne}}return{type:"code",raw:P,lang:j,text:J}}}},f=/(?:\${2})([^\n`]+?)(?:\${2})/gi,p=0,s=function(){return"__special_katext_id_".concat(p++,"__")},a={};function b(){return a}function v(){p=0,a={}}function S(U){return U=U.replace(f,function(u,g){var P=s();return a[P]={type:"inline",expression:g},P}),U}var M=c.listitem;c.listitem=function(U){return M(S(U))};var H=c.paragraph;c.paragraph=function(U){return H(S(U))};var V=c.tablecell;c.tablecell=function(U,u){return V(S(U),u)},c.code=function(U,u,g){var P=(u||"").match(/\S*/)[0];return P?["latex","katex","math"].indexOf(P)>=0?"

    ".concat(U,"

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

    [TOC]

    ",l()),_()),Ht=Ht.replace(/(__special_katext_id_\d+__)/g,function(vn,Nr){var Yr=br[Nr],Yn=Yr.type,An=Yr.expression;return Object(fe.renderToString)(dn(An)||"",{displayMode:Yn==="block",throwOnError:!1,output:"html"})}),Ht=Ht.replace(/▁/g,"\u2581\u2581\u2581"),v(),ce){var lr=document.createElement("div");return lr.innerHTML=Ht,lr.innerText}return setTimeout(function(){return Sr()},500),Ht},[Mr]),hr=Object(D.useRef)();y.WebkitLineClamp=Ne,Ne&&(er=Object(N.a)(Object(N.a)({},er),y));function Lr(or){var tr=or.target;if(tr.tagName.toUpperCase()==="IMG"){if(Tt){var pr=tr.getAttribute("src");be(pr),vt("image")}}else if(tr.tagName.toUpperCase()==="A"){var Ht=tr.getAttribute("href");if(Ht.indexOf("office")>-1)or.preventDefault(),be(Ht),vt("office");else if(Ht.indexOf("application/pdf")>-1)or.preventDefault(),be(Ht),vt("pdf");else if(Ht.indexOf("text/html")>-1)or.preventDefault(),be(Ht),vt("html");else if(Ht.startsWith("#")){or.preventDefault();var br=document.getElementById(Ht.replace("#",""));br&&br.scrollIntoView(!0)}}}var Sr=function(){var tr,pr=(tr=hr.current)===null||tr===void 0?void 0:tr.querySelectorAll("video");pr==null||pr.forEach(function(Ht){if(Ht.oncontextmenu=function(){return!1},Ht.src.indexOf(".m3u8")>-1&&!Ht.canPlayType("application/vnd.apple.mpegurl")){if(q.a.isSupported()){var br=new q.a;br.loadSource(Ht.src),br.attachMedia(Ht)}}})};Object(D.useEffect)(function(){if(hr.current&&cr&&(cr.match(un)&&window.PR.prettyPrint()),hr.current)return hr.current.addEventListener("click",Lr),function(){hr.current.removeEventListener("click",Lr),v(),_()}},[cr,hr.current,Lr]);var Wr=function(tr){if(!J)return;tr.target.nodeName==="IMG"?(Ir.current.style.zIndex=1,Ir.current.style.display="flex",Ir.current.style.width=tr.target.clientWidth+"px",Ir.current.style.height=tr.target.clientHeight+"px",Ir.current.style.top=tr.target.offsetTop+"px",Ir.current.style.left=tr.target.offsetLeft+"px",cn.current.src=tr.target.getAttribute("src")):Ir.current.style.display="none"};return E.a.createElement("div",{style:{position:"relative"}},E.a.createElement("div",{ref:hr,style:Object(N.a)({},er),className:"".concat(j||""," markdown-body ").concat(Dr.a.mdBody),onMouseOver:Wr,dangerouslySetInnerHTML:{__html:cr}}),E.a.createElement("div",{ref:Ir,className:Dr.a.button},E.a.createElement($.a,null,E.a.createElement(X.a,{onClick:function(){return It()}},"\u88C1\u526A"),E.a.createElement(X.a,{onClick:function(){return gr()}},"\u7F16\u8F91"))),E.a.createElement("img",{ref:cn,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),E.a.createElement(ve.a,{close:!0,data:nt,type:nt!=null&&nt.length?mt:"",style:Object(N.a)({},Gr),onClose:function(){return be("")}}))}},"9VGf":function(At,ht,re){"use strict";re.d(ht,"a",function(){return R});var ae=re("q1tI"),$=re.n(ae);function R(X,N){var I=Object(ae.useRef)();Object(ae.useEffect)(function(){I.current=X}),Object(ae.useEffect)(function(){function z(){I.current()}if(N!==null){var B=setInterval(z,N);return function(){return clearInterval(B)}}},[N])}},Bd2K:function(At,ht,re){(function(ae){ae(re("VrN/"),re("osHv"))})(function(ae){ae.defineOption("autoCloseTags",!1,function(O,D,E){if(E!=ae.Init&&E&&O.removeKeyMap("autoCloseTags"),!D)return;var L={name:"autoCloseTags"};(typeof D!="object"||D.whenClosing!==!1)&&(L["'/'"]=function(k){return I(k)}),(typeof D!="object"||D.whenOpening!==!1)&&(L["'>'"]=function(k){return X(k)}),O.addKeyMap(L)});var $=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],R=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];function X(O){if(O.getOption("disableInput"))return ae.Pass;for(var D=O.listSelections(),E=[],L=O.getOption("autoCloseTags"),k=0;kT.ch&&(c=c.slice(0,c.length-A.end+T.ch));var m=c.toLowerCase();if(!c||A.type=="string"&&(A.end!=T.ch||!/[\"\']/.test(A.string.charAt(A.string.length-1))||A.string.length==1)||A.type=="tag"&&o.close||A.string.indexOf("/")==T.ch-A.start-1||_&&z(_,m)>-1||B(O,C.mode.xmlCurrentContext&&C.mode.xmlCurrentContext(h)||[],c,T,!0))return ae.Pass;var l=typeof L=="object"&&L.emptyTags;if(l&&z(l,c)>-1){E[k]={text:"/>",newPos:ae.Pos(T.line,T.ch+2)};continue}var x=y&&z(y,m)>-1;E[k]={indent:x,text:">"+(x?` `:"")+"",newPos:x?ae.Pos(T.line+1,0):ae.Pos(T.line,T.ch+1)}}for(var f=typeof L=="object"&&L.dontIndentOnAutoClose,k=D.length-1;k>=0;k--){var p=E[k];O.replaceRange(p.text,D[k].head,D[k].anchor,"+insert");var s=O.listSelections().slice(0);s[k]={head:p.newPos,anchor:p.newPos},O.setSelections(s),!f&&p.indent&&(O.indentLine(p.newPos.line,null,!0),O.indentLine(p.newPos.line+1,null,!0))}}function N(O,D){for(var E=O.listSelections(),L=[],k=D?"/":""&&(_+=">"),L[C]=_}if(O.replaceSelections(L),E=O.listSelections(),!A)for(var C=0;C=0&&D[h]==E;h--)++C;L=A.to;for(var h=1;h0){for(var D=0;D1&&arguments[1]!==void 0?arguments[1]:"",D=[],E=0;Ege.length)&&(de=ge.length);for(var pe=0,ee=new Array(de);pe=ge.length?{done:!0}:{done:!1,value:ge[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 pe=ge[Symbol.iterator](),pe.next.bind(pe)}function I(ge,de){return de={exports:{}},ge(de,de.exports),de.exports}var z=I(function(ge){function de(){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 pe(ee){ge.exports.defaults=ee}ge.exports={defaults:de(),getDefaults:de,changeDefaults:pe}}),B=z.defaults,O=z.getDefaults,D=z.changeDefaults,E=/[&<>"']/,L=/[&<>"']/g,k=/[<>"']|&(?!#?\w+;)/,T=/[<>"']|&(?!#?\w+;)/g,A={"&":"&","<":"<",">":">",'"':""","'":"'"},C=function(de){return A[de]};function h(ge,de){if(de){if(E.test(ge))return ge.replace(L,C)}else if(k.test(ge))return ge.replace(T,C);return ge}var o=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function c(ge){return ge.replace(o,function(de,pe){return pe=pe.toLowerCase(),pe==="colon"?":":pe.charAt(0)==="#"?pe.charAt(1)==="x"?String.fromCharCode(parseInt(pe.substring(2),16)):String.fromCharCode(+pe.substring(1)):""})}var d=/(^|[^\[])\^/g;function _(ge,de){ge=ge.source||ge,de=de||"";var pe={replace:function(te,ie){return ie=ie.source||ie,ie=ie.replace(d,"$1"),ge=ge.replace(te,ie),pe},getRegex:function(){return new RegExp(ge,de)}};return pe}var y=/[^\w:]/g,m=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function l(ge,de,pe){if(ge){var ee;try{ee=decodeURIComponent(c(pe)).replace(y,"").toLowerCase()}catch(te){return null}if(ee.indexOf("javascript:")===0||ee.indexOf("vbscript:")===0||ee.indexOf("data:")===0)return null}de&&!m.test(pe)&&(pe=a(de,pe));try{pe=encodeURI(pe).replace(/%25/g,"%")}catch(te){return null}return pe}var x={},f=/^[^:]+:\/*[^/]*$/,p=/^([^:]+:)[\s\S]*$/,s=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(ge,de){x[" "+ge]||(f.test(ge)?x[" "+ge]=ge+"/":x[" "+ge]=M(ge,"/",!0)),ge=x[" "+ge];var pe=ge.indexOf(":")===-1;return de.substring(0,2)==="//"?pe?de:ge.replace(p,"$1")+de:de.charAt(0)==="/"?pe?de:ge.replace(s,"$1")+de:ge+de}var b={exec:function(){}};function v(ge){for(var de=1,pe,ee;de=0&&ue[ke]==="\\";)Se=!Se;return Se?"|":" |"}),ee=pe.split(/ \|/),te=0;if(ee.length>de)ee.splice(de);else for(;ee.length=ee.length?te.slice(ee.length):te}).join(` `)}var Ee=function(){function ge(pe){this.options=pe||G}var de=ge.prototype;return de.space=function(ee){var te=this.rules.block.newline.exec(ee);if(te)return te[0].length>1?{type:"space",raw:te[0]}:{raw:` `}},de.code=function(ee,te){var ie=this.rules.block.code.exec(ee);if(ie){var se=te[te.length-1];if(se&&se.type==="paragraph")return{raw:ie[0],text:ie[0].trimRight()};var ue=ie[0].replace(/^ {4}/gm,"");return{type:"code",raw:ie[0],codeBlockStyle:"indented",text:this.options.pedantic?ue:W(ue,` `)}}},de.fences=function(ee){var te=this.rules.block.fences.exec(ee);if(te){var ie=te[0],se=De(ie,te[3]||"");return{type:"code",raw:ie,lang:te[2]?te[2].trim():te[2],text:se}}},de.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]}},de.nptable=function(ee){var te=this.rules.block.nptable.exec(ee);if(te){var ie={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(ie.header.length===ie.align.length){var se=ie.align.length,ue;for(ue=0;ue ?/gm,"");return{type:"blockquote",raw:te[0],text:ie}}},de.list=function(ee){var te=this.rules.block.list.exec(ee);if(te){for(var ie=te[0],se=te[2],ue=se.length>1,Se=se[se.length-1]===")",ke={type:"list",raw:ie,ordered:ue,start:ue?+se.slice(0,-1):"",loose:!1,items:[]},Je=te[0].match(this.rules.block.item),Qe=!1,bt,Dt,Ze,ut,Ft,Ct,jt,$t=Je.length,Lt=0;Lt<$t;Lt++)bt=Je[Lt],ie=bt,Dt=bt.length,bt=bt.replace(/^ *([*+-]|\d+[.)]) */,""),~bt.indexOf(` `)&&(Dt-=bt.length,bt=this.options.pedantic?bt.replace(/^ {1,4}/gm,""):bt.replace(new RegExp("^ {1,"+Dt+"}","gm"),"")),Lt!==$t-1&&(Ze=this.rules.block.bullet.exec(Je[Lt+1])[0],(ue?Ze.length===1||!Se&&Ze[Ze.length-1]===")":Ze.length>1||this.options.smartLists&&Ze!==se)&&(ut=Je.slice(Lt+1).join(` `),ke.raw=ke.raw.substring(0,ke.raw.length-ut.length),Lt=$t-1)),Ft=Qe||/\n\n(?!\s*$)/.test(bt),Lt!==$t-1&&(Qe=bt.charAt(bt.length-1)===` `,Ft||(Ft=Qe)),Ft&&(ke.loose=!0),Ct=/^\[[ xX]\] /.test(bt),jt=void 0,Ct&&(jt=bt[1]!==" ",bt=bt.replace(/^\[[ xX]\] +/,"")),ke.items.push({type:"list_item",raw:ie,task:Ct,checked:jt,loose:Ft,text:bt});return ke}},de.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]):oe(te[0]):te[0]}},de.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 ie=te[1].toLowerCase().replace(/\s+/g," ");return{tag:ie,raw:te[0],href:te[2],title:te[3]}}},de.table=function(ee){var te=this.rules.block.table.exec(ee);if(te){var ie={type:"table",header:q(te[1].replace(/^ *| *\| *$/g,"")),align:te[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:te[3]?te[3].replace(/\n$/,"").split(` `):[]};if(ie.header.length===ie.align.length){ie.raw=te[0];var se=ie.align.length,ue;for(ue=0;ue/i.test(se[0])&&(te=!1),!ie&&/^<(pre|code|kbd|script)(\s|>)/i.test(se[0])?ie=!0:ie&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(se[0])&&(ie=!1),{type:this.options.sanitize?"text":"html",raw:se[0],inLink:te,inRawBlock:ie,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(se[0]):oe(se[0]):se[0]}},de.link=function(ee){var te=this.rules.inline.link.exec(ee);if(te){var ie=fe(te[2],"()");if(ie>-1){var se=te[0].indexOf("!")===0?5:4,ue=se+te[1].length+ie;te[2]=te[2].substring(0,ie),te[0]=te[0].substring(0,ue).trim(),te[3]=""}var Se=te[2],ke="";if(this.options.pedantic){var Je=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(Se);Je?(Se=Je[1],ke=Je[3]):ke=""}else ke=te[3]?te[3].slice(1,-1):"";Se=Se.trim().replace(/^<([\s\S]*)>$/,"$1");var Qe=ve(te,{href:Se&&Se.replace(this.rules.inline._escapes,"$1"),title:ke&&ke.replace(this.rules.inline._escapes,"$1")},te[0]);return Qe}},de.reflink=function(ee,te){var ie;if((ie=this.rules.inline.reflink.exec(ee))||(ie=this.rules.inline.nolink.exec(ee))){var se=(ie[2]||ie[1]).replace(/\s+/g," ");if(se=te[se.toLowerCase()],!se||!se.href){var ue=ie[0].charAt(0);return{type:"text",raw:ue,text:ue}}var Se=ve(ie,se,ie[0]);return Se}},de.strong=function(ee,te,ie){ie===void 0&&(ie="");var se=this.rules.inline.strong.start.exec(ee);if(se&&(!se[1]||se[1]&&(ie===""||this.rules.inline.punctuation.exec(ie)))){te=te.slice(-1*ee.length);var ue=se[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;ue.lastIndex=0;for(var Se;(se=ue.exec(te))!=null;)if(Se=this.rules.inline.strong.middle.exec(te.slice(0,se.index+3)),Se)return{type:"strong",raw:ee.slice(0,Se[0].length),text:ee.slice(2,Se[0].length-2)}}},de.em=function(ee,te,ie){ie===void 0&&(ie="");var se=this.rules.inline.em.start.exec(ee);if(se&&(!se[1]||se[1]&&(ie===""||this.rules.inline.punctuation.exec(ie)))){te=te.slice(-1*ee.length);var ue=se[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;ue.lastIndex=0;for(var Se;(se=ue.exec(te))!=null;)if(Se=this.rules.inline.em.middle.exec(te.slice(0,se.index+2)),Se)return{type:"em",raw:ee.slice(0,Se[0].length),text:ee.slice(1,Se[0].length-1)}}},de.codespan=function(ee){var te=this.rules.inline.code.exec(ee);if(te){var ie=te[2].replace(/\n/g," "),se=/[^ ]/.test(ie),ue=ie.startsWith(" ")&&ie.endsWith(" ");return se&&ue&&(ie=ie.substring(1,ie.length-1)),ie=oe(ie,!0),{type:"codespan",raw:te[0],text:ie}}},de.br=function(ee){var te=this.rules.inline.br.exec(ee);if(te)return{type:"br",raw:te[0]}},de.del=function(ee){var te=this.rules.inline.del.exec(ee);if(te)return{type:"del",raw:te[0],text:te[1]}},de.autolink=function(ee,te){var ie=this.rules.inline.autolink.exec(ee);if(ie){var se,ue;return ie[2]==="@"?(se=oe(this.options.mangle?te(ie[1]):ie[1]),ue="mailto:"+se):(se=oe(ie[1]),ue=se),{type:"link",raw:ie[0],text:se,href:ue,tokens:[{type:"text",raw:se,text:se}]}}},de.url=function(ee,te){var ie;if(ie=this.rules.inline.url.exec(ee)){var se,ue;if(ie[2]==="@")se=oe(this.options.mangle?te(ie[0]):ie[0]),ue="mailto:"+se;else{var Se;do Se=ie[0],ie[0]=this.rules.inline._backpedal.exec(ie[0])[0];while(Se!==ie[0]);se=oe(ie[0]),ie[1]==="www."?ue="http://"+se:ue=se}return{type:"link",raw:ie[0],text:se,href:ue,tokens:[{type:"text",raw:se,text:se}]}}},de.inlineText=function(ee,te,ie){var se=this.rules.inline.text.exec(ee);if(se){var ue;return te?ue=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(se[0]):oe(se[0]):se[0]:ue=oe(this.options.smartypants?ie(se[0]):se[0]),{type:"text",raw:se[0],text:ue}}},ge}(),_e=Q.noopTest,Te=Q.edit,Ce=Q.merge,me={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|\\n*|\\n*|)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:_e,table:_e,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};me._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,me._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,me.def=Te(me.def).replace("label",me._label).replace("title",me._title).getRegex(),me.bullet=/(?:[*+-]|\d{1,9}[.)])/,me.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,me.item=Te(me.item,"gm").replace(/bull/g,me.bullet).getRegex(),me.list=Te(me.list).replace(/bull/g,me.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+me.def.source+")").getRegex(),me._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",me._comment=//,me.html=Te(me.html,"i").replace("comment",me._comment).replace("tag",me._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),me.paragraph=Te(me._paragraph).replace("hr",me.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|!--)").replace("tag",me._tag).getRegex(),me.blockquote=Te(me.blockquote).replace("paragraph",me.paragraph).getRegex(),me.normal=Ce({},me),me.gfm=Ce({},me.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n *([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n *\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),me.gfm.nptable=Te(me.gfm.nptable).replace("hr",me.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|!--)").replace("tag",me._tag).getRegex(),me.gfm.table=Te(me.gfm.table).replace("hr",me.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|!--)").replace("tag",me._tag).getRegex(),me.pedantic=Ce({},me.normal,{html:Te(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",me._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:_e,paragraph:Te(me.normal._paragraph).replace("hr",me.hr).replace("heading",` *#{1,6} *[^ ]`).replace("lheading",me.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var ne={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:_e,tag:"^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",strong:{start:/^(?:(\*\*(?=[*punctuation]))|\*\*)(?![\s])|__/,middle:/^\*\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*\*$|^__(?![\s])((?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?)__$/,endAst:/[^punctuation\s]\*\*(?!\*)|[punctuation]\*\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]__(?!_)(?:(?=[punctuation\s])|$)/},em:{start:/^(?:(\*(?=[punctuation]))|\*)(?![*\s])|_/,middle:/^\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*$|^_(?![_\s])(?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?_$/,endAst:/[^punctuation\s]\*(?!\*)|[punctuation]\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]_(?!_)(?:(?=[punctuation\s])|$)/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:_e,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\?@\\[\\]`^{|}~",ne.punctuation=Te(ne.punctuation).replace(/punctuation/g,ne._punctuation).getRegex(),ne._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",ne._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",ne.em.start=Te(ne.em.start).replace(/punctuation/g,ne._punctuation).getRegex(),ne.em.middle=Te(ne.em.middle).replace(/punctuation/g,ne._punctuation).replace(/overlapSkip/g,ne._overlapSkip).getRegex(),ne.em.endAst=Te(ne.em.endAst,"g").replace(/punctuation/g,ne._punctuation).getRegex(),ne.em.endUnd=Te(ne.em.endUnd,"g").replace(/punctuation/g,ne._punctuation).getRegex(),ne.strong.start=Te(ne.strong.start).replace(/punctuation/g,ne._punctuation).getRegex(),ne.strong.middle=Te(ne.strong.middle).replace(/punctuation/g,ne._punctuation).replace(/blockSkip/g,ne._blockSkip).getRegex(),ne.strong.endAst=Te(ne.strong.endAst,"g").replace(/punctuation/g,ne._punctuation).getRegex(),ne.strong.endUnd=Te(ne.strong.endUnd,"g").replace(/punctuation/g,ne._punctuation).getRegex(),ne.blockSkip=Te(ne._blockSkip,"g").getRegex(),ne.overlapSkip=Te(ne._overlapSkip,"g").getRegex(),ne._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ne._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ne._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])?)+(?![-_])/,ne.autolink=Te(ne.autolink).replace("scheme",ne._scheme).replace("email",ne._email).getRegex(),ne._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ne.tag=Te(ne.tag).replace("comment",me._comment).replace("attribute",ne._attribute).getRegex(),ne._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ne._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,ne._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ne.link=Te(ne.link).replace("label",ne._label).replace("href",ne._href).replace("title",ne._title).getRegex(),ne.reflink=Te(ne.reflink).replace("label",ne._label).getRegex(),ne.reflinkSearch=Te(ne.reflinkSearch,"g").replace("reflink",ne.reflink).replace("nolink",ne.nolink).getRegex(),ne.normal=Ce({},ne),ne.pedantic=Ce({},ne.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",ne._label).getRegex(),reflink:Te(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ne._label).getRegex()}),ne.gfm=Ce({},ne.normal,{escape:Te(ne.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\.5&&(ee="x"+ee.toString(16)),de+="&#"+ee+";";return de}var Me=function(){function ge(pe){this.tokens=[],this.tokens.links=Object.create(null),this.options=pe||rt,this.options.tokenizer=this.options.tokenizer||new Ee,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var ee={block:$e.normal,inline:Xe.normal};this.options.pedantic?(ee.block=$e.pedantic,ee.inline=Xe.pedantic):this.options.gfm&&(ee.block=$e.gfm,this.options.breaks?ee.inline=Xe.breaks:ee.inline=Xe.gfm),this.tokenizer.rules=ee}ge.lex=function(ee,te){var ie=new ge(te);return ie.lex(ee)};var de=ge.prototype;return de.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},de.blockTokens=function(ee,te,ie){te===void 0&&(te=[]),ie===void 0&&(ie=!0),ee=ee.replace(/^ +$/gm,"");for(var se,ue,Se,ke;ee;){if(se=this.tokenizer.space(ee)){ee=ee.substring(se.raw.length),se.type&&te.push(se);continue}if(se=this.tokenizer.code(ee,te)){ee=ee.substring(se.raw.length),se.type?te.push(se):(ke=te[te.length-1],ke.raw+=` `+se.raw,ke.text+=` `+se.text);continue}if(se=this.tokenizer.fences(ee)){ee=ee.substring(se.raw.length),te.push(se);continue}if(se=this.tokenizer.heading(ee)){ee=ee.substring(se.raw.length),te.push(se);continue}if(se=this.tokenizer.nptable(ee)){ee=ee.substring(se.raw.length),te.push(se);continue}if(se=this.tokenizer.hr(ee)){ee=ee.substring(se.raw.length),te.push(se);continue}if(se=this.tokenizer.blockquote(ee)){ee=ee.substring(se.raw.length),se.tokens=this.blockTokens(se.text,[],ie),te.push(se);continue}if(se=this.tokenizer.list(ee)){for(ee=ee.substring(se.raw.length),Se=se.items.length,ue=0;ue0)for(;(Je=this.tokenizer.rules.inline.reflinkSearch.exec(ke))!=null;)Qe.includes(Je[0].slice(Je[0].lastIndexOf("[")+1,-1))&&(ke=ke.slice(0,Je.index)+"["+"a".repeat(Je[0].length-2)+"]"+ke.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(Je=this.tokenizer.rules.inline.blockSkip.exec(ke))!=null;)ke=ke.slice(0,Je.index)+"["+"a".repeat(Je[0].length-2)+"]"+ke.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,ie,se)){ee=ee.substring(Se.raw.length),ie=Se.inLink,se=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,se)),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,se)),te.push(Se);continue}if(Se=this.tokenizer.strong(ee,ke,ue)){ee=ee.substring(Se.raw.length),Se.tokens=this.inlineTokens(Se.text,[],ie,se),te.push(Se);continue}if(Se=this.tokenizer.em(ee,ke,ue)){ee=ee.substring(Se.raw.length),Se.tokens=this.inlineTokens(Se.text,[],ie,se),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,[],ie,se),te.push(Se);continue}if(Se=this.tokenizer.autolink(ee,Le)){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(!ie&&(Se=this.tokenizer.url(ee,Le))){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(Se=this.tokenizer.inlineText(ee,se,Ve)){ee=ee.substring(Se.raw.length),ue=Se.raw.slice(-1),te.push(Se);continue}if(ee){var bt="Infinite loop on byte: "+ee.charCodeAt(0);if(this.options.silent){console.error(bt);break}else throw new Error(bt)}}return te},$(ge,null,[{key:"rules",get:function(){return{block:$e,inline:Xe}}}]),ge}(),ze=z.defaults,Ge=Q.cleanUrl,He=Q.escape,Be=function(){function ge(pe){this.options=pe||ze}var de=ge.prototype;return de.code=function(ee,te,ie){var se=(te||"").match(/\S*/)[0];if(this.options.highlight){var ue=this.options.highlight(ee,se);ue!=null&&ue!==ee&&(ie=!0,ee=ue)}return se?'
    '+(ie?ee:He(ee,!0))+`
    `:"
    "+(ie?ee:He(ee,!0))+`
    `},de.blockquote=function(ee){return`
    `+ee+`
    `},de.html=function(ee){return ee},de.heading=function(ee,te,ie,se){return this.options.headerIds?"'+ee+" `:""+ee+" `},de.hr=function(){return this.options.xhtml?`
    `:`
    `},de.list=function(ee,te,ie){var se=te?"ol":"ul",ue=te&&ie!==1?' start="'+ie+'"':"";return"<"+se+ue+`> `+ee+" `},de.listitem=function(ee){return"
  • "+ee+`
  • `},de.checkbox=function(ee){return" "},de.paragraph=function(ee){return"

    "+ee+`

    `},de.table=function(ee,te){return te&&(te=""+te+""),` `+ee+` `+te+`
    `},de.tablerow=function(ee){return` `+ee+` `},de.tablecell=function(ee,te){var ie=te.header?"th":"td",se=te.align?"<"+ie+' align="'+te.align+'">':"<"+ie+">";return se+ee+" `},de.strong=function(ee){return""+ee+""},de.em=function(ee){return""+ee+""},de.codespan=function(ee){return""+ee+""},de.br=function(){return this.options.xhtml?"
    ":"
    "},de.del=function(ee){return""+ee+""},de.link=function(ee,te,ie){if(ee=Ge(this.options.sanitize,this.options.baseUrl,ee),ee===null)return ie;var se='",se},de.image=function(ee,te,ie){if(ee=Ge(this.options.sanitize,this.options.baseUrl,ee),ee===null)return ie;var se=''+ie+'":">",se},de.text=function(ee){return ee},ge}(),Pe=function(){function ge(){}var de=ge.prototype;return de.strong=function(ee){return ee},de.em=function(ee){return ee},de.codespan=function(ee){return ee},de.del=function(ee){return ee},de.html=function(ee){return ee},de.text=function(ee){return ee},de.link=function(ee,te,ie){return""+ie},de.image=function(ee,te,ie){return""+ie},de.br=function(){return""},ge}(),pt=function(){function ge(){this.seen={}}var de=ge.prototype;return de.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 ie=te;do this.seen[ie]++,te=ie+"-"+this.seen[ie];while(this.seen.hasOwnProperty(te))}return this.seen[te]=0,te},ge}(),it=z.defaults,et=Q.unescape,at=function(){function ge(pe){this.options=pe||it,this.options.renderer=this.options.renderer||new Be,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Pe,this.slugger=new pt}ge.parse=function(ee,te){var ie=new ge(te);return ie.parse(ee)};var de=ge.prototype;return de.parse=function(ee,te){te===void 0&&(te=!0);var ie="",se,ue,Se,ke,Je,Qe,bt,Dt,Ze,ut,Ft,Ct,jt,$t,Lt,Qt,Zt,ft,Xt=ee.length;for(se=0;se0&&Lt.tokens[0].type==="text"?(Lt.tokens[0].text=ft+" "+Lt.tokens[0].text,Lt.tokens[0].tokens&&Lt.tokens[0].tokens.length>0&&Lt.tokens[0].tokens[0].type==="text"&&(Lt.tokens[0].tokens[0].text=ft+" "+Lt.tokens[0].tokens[0].text)):Lt.tokens.unshift({type:"text",text:ft}):$t+=ft),$t+=this.parse(Lt.tokens,jt),Ze+=this.renderer.listitem($t,Zt,Qt);ie+=this.renderer.list(Ze,Ft,Ct);continue}case"html":{ie+=this.renderer.html(ut.text);continue}case"paragraph":{ie+=this.renderer.paragraph(this.parseInline(ut.tokens));continue}case"text":{for(Ze=ut.tokens?this.parseInline(ut.tokens):ut.text;se+1An error occurred:

    "+dt(Se.message+"",!0)+"
    ";throw Se}}Re.options=Re.setOptions=function(ge){return Et(Re.defaults,ge),gt(Re.defaults),Re},Re.getDefaults=we,Re.defaults=lt,Re.use=function(ge){var de=Et({},ge);if(ge.renderer&&function(){var ee=Re.defaults.renderer||new Be,te=function(ue){var Se=ee[ue];ee[ue]=function(){for(var ke=arguments.length,Je=new Array(ke),Qe=0;Qe`,triples:"",explode:"[]{}"},R=ae.Pos;ae.defineOption("autoCloseBrackets",!1,function(A,C,h){h&&h!=ae.Init&&(A.removeKeyMap(N),A.state.closeBrackets=null),C&&(I(X(C,"pairs")),A.state.closeBrackets=C,A.addKeyMap(N))});function X(A,C){return C=="pairs"&&typeof A=="string"?A:typeof A=="object"&&A[C]!=null?A[C]:$[C]}var N={Backspace:O,Enter:D};function I(A){for(var C=0;C=0;c--){var _=o[c].head;A.replaceRange("",R(_.line,_.ch-1),R(_.line,_.ch+1),"+delete")}}function D(A){var C=B(A),h=C&&X(C,"explode");if(!h||A.getOption("disableInput"))return ae.Pass;for(var o=A.listSelections(),c=0;c0;return{anchor:new R(A.anchor.line,A.anchor.ch+(C?-1:1)),head:new R(A.head.line,A.head.ch+(C?1:-1))}}function L(A,C){var h=B(A);if(!h||A.getOption("disableInput"))return ae.Pass;var o=X(h,"pairs"),c=o.indexOf(C);if(c==-1)return ae.Pass;for(var d=X(h,"closeBefore"),_=X(h,"triples"),y=o.charAt(c+1)==C,m=A.listSelections(),l=c%2==0,x,f=0;f=0&&A.getRange(s,R(s.line,s.ch+3))==C+C+C?a="skipThree":a="skip";else if(y&&s.ch>1&&_.indexOf(C)>=0&&A.getRange(R(s.line,s.ch-2),s)==C+C){if(s.ch>2&&/\bstring/.test(A.getTokenTypeAt(R(s.line,s.ch-2))))return ae.Pass;a="addFour"}else if(y){var v=s.ch==0?" ":A.getRange(R(s.line,s.ch-1),s);if(!ae.isWordChar(b)&&v!=C&&!ae.isWordChar(v))a="both";else return ae.Pass}else if(l&&(b.length===0||/\s/.test(b)||d.indexOf(b)>-1))a="both";else return ae.Pass;if(!x)x=a;else if(x!=a)return ae.Pass}var S=c%2?o.charAt(c-1):C,M=c%2?C:o.charAt(c+1);A.operation(function(){if(x=="skip")A.execCommand("goCharRight");else if(x=="skipThree")for(var H=0;H<3;H++)A.execCommand("goCharRight");else if(x=="surround"){for(var V=A.getSelections(),H=0;H1&&arguments[1]!==void 0?arguments[1]:1,pe=Pe.length,ee=0;ee1&&arguments[1]!==void 0?arguments[1]:!1;return Object(l.a)(W).map(function(oe,fe){if(!N.isValidElement(oe)||!oe.type)return null;var ve=oe.type.isSelectOptGroup,De=oe.key,Ee=oe.props,_e=Ee.children,Te=Object(z.a)(Ee,["children"]);return q||!ve?x(oe):Object(m.a)(Object(m.a)({key:"__RC_SELECT_GRP__".concat(De===null?fe:De,"__"),label:De},Te),{},{options:f(_e)})}).filter(function(oe){return oe})}var p=re("2Qr1"),s=re("qNPg"),a=re("U8pU"),b=re("Kwbf"),v=re("WKfj");function S(W){var q=W.mode,oe=W.options,fe=W.children,ve=W.backfill,De=W.allowClear,Ee=W.placeholder,_e=W.getInputElement,Te=W.showSearch,Ce=W.onSearch,me=W.defaultOpen,ne=W.autoFocus,Ae=W.labelInValue,rt=W.value,$e=W.inputValue,Xe=W.optionLabelProp,Ve=q==="multiple"||q==="tags",Le=Te!==void 0?Te:Ve||q==="combobox",Me=oe||f(fe);if(Object(b.a)(q!=="tags"||Me.every(function(Be){return!Be.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),q==="tags"||q==="combobox"){var ze=Me.some(function(Be){return Be.options?Be.options.some(function(Pe){return typeof("value"in Pe?Pe.value:Pe.key)=="number"}):typeof("value"in Be?Be.value:Be.key)=="number"});Object(b.a)(!ze,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(b.a)(q!=="combobox"||!Xe,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(b.a)(q==="combobox"||!ve,"`backfill` only works with `combobox` mode."),Object(b.a)(q==="combobox"||!_e,"`getInputElement` only work with `combobox` mode."),Object(b.b)(q!=="combobox"||!_e||!De||!Ee,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),Ce&&!Le&&q!=="combobox"&&q!=="tags"&&Object(b.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(b.b)(!me||ne,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),rt!=null){var Ge=Object(v.d)(rt);Object(b.a)(!Ae||Ge.every(function(Be){return Object(a.a)(Be)==="object"&&("key"in Be||"value"in Be)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(b.a)(!Ve||Array.isArray(rt),"`value` should be array when `mode` is `multiple` or `tags`")}if(fe){var He=null;Object(l.a)(fe).some(function(Be){if(!N.isValidElement(Be)||!Be.type)return!1;var Pe=Be.type;if(Pe.isSelectOption)return!1;if(Pe.isSelectOptGroup){var pt=Object(l.a)(Be.props.children).every(function(it){return!N.isValidElement(it)||!Be.type||it.type.isSelectOption?!0:(He=it.type,!1)});return!pt}return He=Pe,!0}),He&&Object(b.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(He.displayName||He.name||He,"`.")),Object(b.a)($e===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var M=S,H=Object(s.a)({prefixCls:"rc-select",components:{optionList:o},convertChildrenToData:f,flattenOptions:p.d,getLabeledValue:p.e,filterOptions:p.b,isValueDisabled:p.g,findValueOption:p.c,warningProps:M,fillOptionsWithMissingValue:p.a}),V=function(W){Object(R.a)(oe,W);var q=Object(X.a)(oe);function oe(){var fe;return Object(ae.a)(this,oe),fe=q.apply(this,arguments),fe.selectRef=N.createRef(),fe.focus=function(){fe.selectRef.current.focus()},fe.blur=function(){fe.selectRef.current.blur()},fe}return Object($.a)(oe,[{key:"render",value:function(){return N.createElement(H,Object.assign({ref:this.selectRef},this.props))}}]),oe}(N.Component);V.Option=d,V.OptGroup=y;var Q=V,G=ht.c=Q},M8RZ:function(At,ht,re){"use strict";re.d(ht,"a",function(){return O});var ae=re("fWQN"),$=re("mtLc"),R=re("yKVA"),X=re("879j"),N=re("q1tI"),I=re.n(N),z=re("i8i4"),B=re.n(z),O=function(D){Object(R.a)(L,D);var E=Object(X.a)(L);function L(k){var T;Object(ae.a)(this,L),T=E.call(this,k);var A=window.document;return T.node=A.createElement("div"),A.body.appendChild(T.node),T}return Object($.a)(L,[{key:"render",value:function(){var T=this.props.children;return Object(z.createPortal)(T,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),L}(I.a.Component)},O2Wb:function(At,ht,re){At.exports={flex:"flex___2gmSR",flex1:"flex1___3Tu1g",color666:"color666___2uyGL",error:"error___yJ86W",deleteIcon:"deleteIcon___1D2tg",addIcon:"addIcon___2VIYB"}},OLES:function(At,ht,re){"use strict";var ae=re("U8pU"),$=re("VTBJ"),R=re("Ff2n"),X=re("q1tI"),N=re("uciX"),I=re("7ixt"),z=function(k){var T=k.overlay,A=k.prefixCls,C=k.id,h=k.overlayInnerStyle;return X.createElement("div",{className:"".concat(A,"-inner"),id:C,role:"tooltip",style:h},typeof T=="function"?T():T)},B=z,O=function(k,T){var A=k.overlayClassName,C=k.trigger,h=C===void 0?["hover"]:C,o=k.mouseEnterDelay,c=o===void 0?0:o,d=k.mouseLeaveDelay,_=d===void 0?.1:d,y=k.overlayStyle,m=k.prefixCls,l=m===void 0?"rc-tooltip":m,x=k.children,f=k.onVisibleChange,p=k.afterVisibleChange,s=k.transitionName,a=k.animation,b=k.placement,v=b===void 0?"right":b,S=k.align,M=S===void 0?{}:S,H=k.destroyTooltipOnHide,V=H===void 0?!1:H,Q=k.defaultVisible,G=k.getTooltipContainer,W=k.overlayInnerStyle,q=Object(R.a)(k,["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer","overlayInnerStyle"]),oe=Object(X.useRef)(null);Object(X.useImperativeHandle)(T,function(){return oe.current});var fe=Object($.a)({},q);"visible"in k&&(fe.popupVisible=k.visible);var ve=function(){var Ce=k.arrowContent,me=Ce===void 0?null:Ce,ne=k.overlay,Ae=k.id;return[X.createElement("div",{className:"".concat(l,"-arrow"),key:"arrow"},me),X.createElement(B,{key:"content",prefixCls:l,id:Ae,overlay:ne,overlayInnerStyle:W})]},De=!1,Ee=!1;if(typeof V=="boolean")De=V;else if(V&&Object(ae.a)(V)==="object"){var _e=V.keepParent;De=_e===!0,Ee=_e===!1}return X.createElement(N.a,Object.assign({popupClassName:A,prefixCls:l,popup:ve,action:h,builtinPlacements:I.a,popupPlacement:v,ref:oe,popupAlign:M,getPopupContainer:G,onPopupVisibleChange:f,afterPopupVisibleChange:p,popupTransitionName:s,popupAnimation:a,defaultPopupVisible:Q,destroyPopupOnHide:De,autoDestroy:Ee,mouseLeaveDelay:_,popupStyle:y,mouseEnterDelay:c},fe),x)},D=Object(X.forwardRef)(O),E=ht.a=D},Ot1p:function(At,ht,re){"use strict";var ae=re("2qtc"),$=re("kLXV"),R=re("rAM+"),X=re("miYZ"),N=re("tsqr"),I=re("9og8"),z=re("tJVT"),B=re("jrin"),O=re("WmNS"),D=re.n(O),E=re("q1tI"),L=re.n(E),k=re("VrN/"),T=re.n(k),A=re("bdgK"),C=re("p77/"),h=re("Bd2K"),o=re("ELLl"),c=re("19Vz"),d=re("lZu9"),_=re("+NIl"),y=re("kSUc"),m=re("9Bee"),l=function(ue){var Se=ue.value,ke=Se===void 0?"":Se,Je=ue.className,Qe=ue.showTextOnly,bt=ue.showLines,Dt=ue.style,Ze=Dt===void 0?{}:Dt,ut=Object(E.useMemo)(function(){return""},[ke]);return L.a.createElement(L.a.Fragment,null,L.a.createElement("div",{dangerouslySetInnerHTML:{__html:ut}}))},x=re("0Owb"),f=re("dejd"),p=re("C+DQ"),s=re("1vsH"),a=re("m3rI"),b=[{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 v(ue){var Se=ue.onActionCallback,ke=ue.title,Je=ue.icon,Qe=ue.actionName,bt=ue.className,Dt=bt===void 0?"":bt,Ze=ue.children;function ut(){Se(Qe)}return L.a.createElement("a",{title:ke,className:Dt,onClick:ut},L.a.createElement("i",{className:"md-iconfont ".concat(Je)}),Ze)}var S=function(ue){var Se=ue.watch,ke=ue.showNullButton,Je=ue.onActionCallback,Qe=ue.fullScreen,bt=ue.insertTemp,Dt=ue.hidetoolBar,Ze=ue.uuid,ut=ue.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(s.F)("_educoder_session_login"),"&_educoder_session=").concat(Object(s.F)("_educoder_session"),"&key=").concat(Ze,"&api=").concat(encodeURIComponent(a.a.PROXY_SERVER)));var Ft=[].concat(b,[{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 L.a.createElement("ul",{className:"markdown-toolbar-container"},!Dt&&Ft.map(function(Ct,jt){return L.a.createElement("li",{key:jt},Ct.actionName?L.a.createElement(v,Object(x.a)({},Ct,{onActionCallback:Je})):L.a.createElement("span",{className:"v-line"}))}),ke?L.a.createElement("li",null,L.a.createElement(v,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:Je},L.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,bt&&L.a.createElement("li",null,L.a.createElement(v,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(bt),onActionCallback:Je},L.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),L.a.createElement("li",{className:"btn-full-screen"},L.a.createElement(v,{icon:"".concat(Qe?"icon-shrink":"icon-enlarge"),title:Qe?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:Je})))},M=re("M8RZ"),H=re("+L6B"),V=re("2/Rp"),Q=re("y8nQ"),G=re("Vl3Y"),W=re("5NDa"),q=re("5rEg"),oe={labelCol:{span:4},wrapperCol:{span:20}},fe=function(ue){var Se=ue.callback,ke=ue.onCancel;function Je(Qe){Se(Qe)}return L.a.createElement(G.a,Object(x.a)({},oe,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:Je}),L.a.createElement(G.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},L.a.createElement(q.a,null)),L.a.createElement(G.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},L.a.createElement(q.a,null)),L.a.createElement("div",{className:"flex-container flex-end"},L.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),L.a.createElement(V.a,{type:"ghost",onClick:ke},"\u53D6\u6D88")))},ve=re("7ahc"),De=re("HmJG"),Ee=re("BjJ7"),_e=G.a.useForm,Te={width:280,marginRight:10},Ce={labelCol:{span:5},wrapperCol:{span:19}},me=function(ue){var Se=ue.callback,ke=ue.onCancel,Je=_e(),Qe=Object(z.a)(Je,1),bt=Qe[0];function Dt(Ft){Se(Ft)}function Ze(Ft,Ct){if(Ft.status===-1){N.b.error(Ft.message);return}bt.setFieldsValue({src:"/api/attachments/".concat(Ft.id),type:Ct.type})}function ut(Ft){var Ct=Ft.target.files[0];Ae(Ct,Ze)}return L.a.createElement(G.a,Object(x.a)({form:bt},Ce,{className:"upload-image-panel",onFinish:Dt}),L.a.createElement(G.a.Item,{label:"\u56FE\u7247\u5730\u5740",required:!0},L.a.createElement("div",{className:"flex-container"},L.a.createElement(G.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740"}]},L.a.createElement(q.a,{style:Te})),L.a.createElement(ne,{onFileChange:ut}))),L.a.createElement(G.a.Item,{label:"\u56FE\u7247\u63CF\u8FF0",name:"alt"},L.a.createElement(q.a,{style:{width:264}})),L.a.createElement(G.a.Item,{style:{textAlign:"right"}},L.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),L.a.createElement(V.a,{type:"ghost",onClick:ke},"\u53D6\u6D88")))};function ne(ue){var Se=ue.onFileChange;return L.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",L.a.createElement("input",{type:"file",onChange:Se}))}function Ae(ue,Se){if(!ue)throw new String("\u6CA1\u6709\u6587\u4EF6");var ke=new FormData;ke.append("editormd-image-file",ue),ke.append("file_param_name","editormd-image-file"),ke.append("byxhr","true");var Je=new window.XMLHttpRequest;Je.withCredentials=!0,Je.addEventListener("load",function(Qe){Se(JSON.parse(Qe.target.responseText),ue)},!1),Je.addEventListener("error",function(Qe){console.error(Qe)},!1),Je.open("POST","".concat(Ee.a,"/api/attachments.json")),Je.send(ke)}var rt=re("giR+"),$e=re("fyUT"),Xe=re("7Kak"),Ve=re("9yH6"),Le=Ve.a.Group,Me={margin:"0 8px"},ze=function(ue){var Se=ue.callback,ke=ue.onCancel;function Je(Qe){Se(Qe)}return L.a.createElement(G.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:Je},L.a.createElement("div",{className:"flex-container",style:{alignItems:"baseline"}},L.a.createElement("span",{style:Me},"\u5355\u5143\u683C\u6570\uFF1A"),L.a.createElement("span",{style:Me},"\u884C\u6570"),L.a.createElement(G.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},L.a.createElement($e.a,null)),L.a.createElement("span",{style:Me},"\u5217\u6570"),L.a.createElement(G.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},L.a.createElement($e.a,null))),L.a.createElement("div",{className:"flex-container",style:{marginTop:12,alignItems:"baseline"}},L.a.createElement("span",{style:Me},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),L.a.createElement(G.a.Item,{name:"align"},L.a.createElement(Le,null,L.a.createElement(Ve.a,{value:"default"},L.a.createElement("i",{className:"fa fa-align-justify"})),L.a.createElement(Ve.a,{value:"left"},L.a.createElement("i",{className:"fa fa-align-left"})),L.a.createElement(Ve.a,{value:"center"},L.a.createElement("i",{className:"fa fa-align-center"})),L.a.createElement(Ve.a,{value:"right"},L.a.createElement("i",{className:"fa fa-align-right"}))))),L.a.createElement("div",{className:"flex-container flex-end"},L.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),L.a.createElement(V.a,{type:"ghost",onClick:ke},"\u53D6\u6D88")))},Ge=re("ErOA"),He=re("7Cbv"),Be="link",Pe="upload-image",pt="code-block",it="add-table",et="------------",at={default:et,left:":".concat(et),center:":".concat(et,":"),right:"".concat(et,":")},Et=re("9VGf"),ct,dt;function we(){}var gt=0,lt=1e4,Re="\u2581",je=` **\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 ge(ue){return/^\d+$/.test(ue)?"".concat(ue,"px"):ue}var de=navigator.platform.toUpperCase().indexOf("MAC")>=0,pe=de?"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=(ct={},Object(B.a)(ct,pe+"-B","bold"),Object(B.a)(ct,pe+"-I","italic"),ct),ie=(dt={},Object(B.a)(dt,Be,"\u6DFB\u52A0\u94FE\u63A5"),Object(B.a)(dt,pt,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(B.a)(dt,Pe,"\u6DFB\u52A0\u6587\u4EF6"),Object(B.a)(dt,it,"\u6DFB\u52A0\u8868\u683C"),dt),se=ht.a=function(ue){var Se=ue.defaultValue,ke=Se===void 0?"":Se,Je=ue.onChange,Qe=ue.width,bt=Qe===void 0?"100%":Qe,Dt=ue.height,Ze=Dt===void 0?400:Dt,ut=ue.miniToolbar,Ft=ut===void 0?!1:ut,Ct=ue.isFocus,jt=Ct===void 0?!1:Ct,$t=ue.watch,Lt=ue.insertTemp,Qt=ue.mode,Zt=Qt===void 0?"markdown":Qt,ft=ue.id,Xt=ft===void 0?"markdown-editor-id":ft,zt=ue.showResizeBar,Gt=zt===void 0?!1:zt,Ut=ue.noStorage,Mt=Ut===void 0?!1:Ut,St=ue.showNullButton,tt=St===void 0?!1:St,Fe=ue.hidetoolBar,nr=Fe===void 0?!1:Fe,Vt=ue.fullScreen,qt=Vt===void 0?!1:Vt,Wt=ue.onBlur,Tr=ue.onCMBeforeChange,ir=ue.onFullScreen,Rt=ue.className,Ie=Rt===void 0?"":Rt,xt=ue.disablePaste,Dr=xt===void 0?!1:xt,un=ue.placeholder,dn=un===void 0?"":un,xr=ue.values,U=xr===void 0?"":xr,u=Object(E.useState)(null),g=Object(z.a)(u,2),P=g[0],J=g[1],j=Object(E.useState)(ke),ce=Object(z.a)(j,2),Ne=ce[0],qe=ce[1],Tt=Object(E.useState)($t),Ue=Object(z.a)(Tt,2),Pt=Ue[0],er=Ue[1],fr=Object(E.useState)(qt),Gr=Object(z.a)(fr,2),Mr=Gr[0],Ir=Gr[1],cn=Object(E.useState)(""),Sn=Object(z.a)(cn,2),wr=Sn[0],nt=Sn[1],be=Object(E.useState)(0),Ke=Object(z.a)(be,2),wt=Ke[0],mt=Ke[1],vt=Object(E.useState)(Ze),It=Object(z.a)(vt,2),gr=It[0],cr=It[1],hr=Object(E.useState)(!1),Lr=Object(z.a)(hr,2),Sr=Lr[0],Wr=Lr[1],or=Object(E.useRef)(Object(He.a)()),tr=Object(E.useRef)(!1),pr=Object(E.useRef)(),Ht=Object(E.useRef)(),br=Object(E.useRef)(),lr=Object(E.useRef)(),vn=Object(E.useRef)(),Nr=function(){var kt=Object(I.a)(D.a.mark(function Kt(){var Nt,Jt;return D.a.wrap(function(vr){for(;;)switch(vr.prev=vr.next){case 0:return vr.next=2,Object(Ge.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:or.current}});case 2:Jt=vr.sent,Jt!=null&&(Nt=Jt.attachments)!==null&&Nt!==void 0&&Nt.length&&(console.log("cm:",P,Ht),Jt.attachments.map(function(ar){ar.content_type.indexOf("image")>-1?P.replaceSelection("![,](/api/attachments/".concat(ar.id,"?type=").concat(ar.content_type,")")):ar.content_type.indexOf("video")>-1?P.replaceSelection('')):ar.content_type.indexOf("pdf")>-1?P.replaceSelection('
    ').concat(ar.name,"")):P.replaceSelection("[".concat(ar.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(ar.id,"?type=").concat(ar.content_type,")"))}));case 4:case"end":return vr.stop()}},Kt)}));return function(){return kt.apply(this,arguments)}}();Object(E.useEffect)(function(){qe(U),P==null||P.setValue(U)},[U]),Object(E.useEffect)(function(){ir==null||ir(Mr)},[Mr]),Object(E.useEffect)(function(){if(Ht.current){var kt=T.a.fromTextArea(Ht.current,{mode:Zt,lineNumbers:!Ft,lineWrapping:!0,value:ke,autoCloseTags:!0,autoCloseBrackets:!0});jt&&kt.focus();function Kt(Nt,Jt){if(Dr){Jt.preventDefault();return}var sr=Jt.clipboardData;if(sr){var vr=sr.types.toString(),ar=sr.items;if(vr==="Files"||sr.types.indexOf("Files")>-1){if(Jt.preventDefault(),Zt=="stex")return;try{var Pr,Qr=ar[1];((Pr=ar[0])===null||Pr===void 0?void 0:Pr.kind)==="file"&&(Qr=ar[0]);var rr=Qr.getAsFile(),Cn=rr.name.split(".").pop();Ae(rr,function(ur){if(ur.id){var Zr,Kr,hn;(rr==null||((Zr=rr.type)===null||Zr===void 0)?void 0:Zr.indexOf("image"))>-1?kt.replaceSelection("![,](/api/attachments/".concat(ur.id,"?type=").concat(ur.content_type,")")):(rr==null||((Kr=rr.type)===null||Kr===void 0)?void 0:Kr.indexOf("video"))>-1?kt.replaceSelection('')):(rr==null||((hn=rr.type)===null||hn===void 0)?void 0:hn.indexOf("pdf"))>-1?kt.replaceSelection('').concat(rr.name,"")):ee.includes(Cn)?kt.replaceSelection('').concat(rr.name,"")):kt.replaceSelection("[".concat(rr.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(ur.id,"?type=").concat(ur.content_type,")"))}else(ur==null?void 0:ur.status)===401&&(document.location.href="/user/login")})}catch(ur){N.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return kt.on("paste",Kt),kt.on("dragleave",function(Nt,Jt){br.current.classList.remove("mouse-hover-md")}),kt.on("dragover",function(Nt,Jt){br.current.classList.add("mouse-hover-md")}),kt.on("drop",function(Nt,Jt){br.current.classList.add("mouse-hover-md");var sr;if(sr=Jt.dataTransfer.files,sr.length>0){Jt.preventDefault(),Jt.stopPropagation();for(var vr=function(Qr){var rr=sr[Qr],Cn=rr.name.split(".").pop();Ae(rr,function(ur){if(ur.id){var Zr,Kr,hn;(rr==null||((Zr=rr.type)===null||Zr===void 0)?void 0:Zr.indexOf("image"))>-1?kt.replaceSelection("![,](/api/attachments/".concat(ur.id,"?type=").concat(ur.content_type,")")):(rr==null||((Kr=rr.type)===null||Kr===void 0)?void 0:Kr.indexOf("video"))>-1?kt.replaceSelection('')):(rr==null||((hn=rr.type)===null||hn===void 0)?void 0:hn.indexOf("pdf"))>-1?kt.replaceSelection('').concat(rr.name,"")):ee.includes(Cn)?kt.replaceSelection('').concat(rr.name,"")):kt.replaceSelection("[".concat(rr.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(ur.id,"?type=").concat(ur.content_type,")"))}else(ur==null?void 0:ur.status)===401&&(document.location.href="/user/login")})},ar=0;ar0||ar.target.offsetWidth>0)&&(Yr(),P.setSize("100%","100%"),P.refresh())}}catch(Pr){sr.e(Pr)}finally{sr.f()}});return Nt.observe(Ht.current.parentElement),Nt}if(P){var Kt=kt();return function(){Kt.unobserve(Ht.current.parentElement)}}},[P,Yr]),Object(E.useEffect)(function(){if(P){for(var kt=[],Kt=function(){var ar=Jt[Nt];sr=Object(z.a)(ar,2);var Pr=sr[0],Qr=sr[1],rr=Object(B.a)({},Pr,function(){Yn(Qr)});kt.push(rr),P.addKeyMap(rr)},Nt=0,Jt=Object.entries(te);Nt0){var kt=new Date().getTime(),Kt=window.sessionStorage.getItem(Xt);kt>=wt+lt&&(!Kt||Kt!==Ne)&&(window.sessionStorage.setItem(Xt,Ne),Wr(!0))}},lt),Object(E.useEffect)(function(){er($t)},[P,$t]),Object(E.useEffect)(function(){P&&(jt&&P.focus())},[P,jt]),Object(E.useEffect)(function(){if(Pt&&P){var kt=P.getScrollerElement();function Kt(Nt){var Jt=Nt.target;if(vn.current){var sr=Jt.scrollTop/Jt.scrollHeight;vn.current.scrollTop=vn.current.scrollHeight*sr}}return kt.addEventListener("scroll",Kt),function(){kt.removeEventListener("scroll",Kt)}}},[P,Pt]),Object(E.useEffect)(function(){if(P&&Tr){function kt(Kt,Nt){Tr(Kt,Nt)}return P.on("beforeChange",kt),function(){P.off("beforeChange",kt)}}},[P,Tr]),Object(E.useEffect)(function(){if(P&&Wt){function kt(){Wt(P.getValue())}return P.on("blur",kt),function(){P.off("blur",kt)}}},[P,Wt]),Object(E.useEffect)(function(){if(P){function kt(Kt){var Nt=Kt.getValue();qe(Nt),mt(new Date().getTime()),Kt.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),Je&&Je(Nt)}return P.on("change",kt),function(){P.off("change",kt)}}},[P,Je]),Object(E.useEffect)(function(){P&&(ke==null?(P.setValue(""),qe("")):ke!==P.getValue()&&(P.setValue(ke),qe(ke),P.setCursor(P.lineCount(),0)))},[P,ke]);var Yn=Object(E.useCallback)(function(kt){var Kt=P.getCursor(),Nt=P.getSelection(),Jt=Nt.split(` `);switch(kt){case"bold":return P.replaceSelection("**"+Nt+"**"),Nt===""&&P.setCursor(Kt.line,Kt.ch+2),P.focus();case"italic":return P.replaceSelection("*"+Nt+"*"),Nt===""&&P.setCursor(Kt.line,Kt.ch+1),P.focus();case"code":return P.replaceSelection("`"+Nt+"`"),Nt===""&&P.setCursor(Kt.line,Kt.ch+1),P.focus();case"inline-latex":return P.replaceSelection("`$$"+Nt+"$$`"),Nt===""&&P.setCursor(Kt.line,Kt.ch+3),P.focus();case"latex":return P.replaceSelection("```latex\n"+Nt+"\n```"),P.setCursor(Kt.line+1,Nt.length+1),P.focus();case"line-break":return P.replaceSelection(`
    `),P.focus();case"list-ul":return Nt===""?P.replaceSelection("- "+Nt):P.replaceSelection(Jt.map(function(sr){return sr===""?"":"- ".concat(sr)}).join(` `)),P.focus();case"list-ol":return Nt===""?P.replaceSelection("1. "+Nt):P.replaceSelection(Jt.map(function(sr,vr){return sr===""?"":"".concat(vr+1,". ").concat(sr)}).join(` `)),P.focus();case"add-null-ch":return Nt===""&&P.setCursor(Kt.line,Kt.ch+1),P.replaceSelection(Re),P.focus();case"inster-template-1":return Nt===""&&P.setCursor(Kt.line,Kt.ch),P.replaceSelection(je),P.focus();case"eraser":return P.setValue(""),P.focus();case"trigger-watch":return er(!Pt),P.focus();case"trigger-full-screen":return Ir(!Mr),P.focus();case Be:nt(Be);return;case pt:nt(pt);return;case Pe:nt(Pe);return;case it:nt(it);return;default:throw new Error}},[P,Pt,Mr]),An=Object(E.useCallback)(function(kt){nt("");switch(wr){case Be:var Kt=kt.title,Nt=kt.link;return P.replaceSelection("[".concat(Kt,"](").concat(Nt,")")),P.focus();case pt:var Jt=kt.language,sr=kt.content;return P.replaceSelection(["```"+Jt,sr,"```"].join(` `)),P.focus();case Pe:var vr=kt.src,ar=kt.alt;return ar?P.replaceSelection("![ ".concat(ar," ]( ").concat(vr,' "').concat(ar,'" )')):P.replaceSelection("![,](".concat(vr,")")),P.focus();case it:for(var Pr=kt.row,Qr=kt.col,rr=kt.align,Cn=` `,ur=0;ur300&&(Pr=300);var Qr=Ze+Pr+"px";cr(Qr)}}return kt.addEventListener("mousedown",Jt),document.addEventListener("mousemove",vr),document.addEventListener("mouseup",sr),function(){kt.removeEventListener("mousedown",Jt),document.removeEventListener("mousemove",vr),document.removeEventListener("mouseup",sr)}}},[P,lr]),Object(E.useEffect)(function(){cr(Ze)},[Ze]);var yn=ge(bt),fi=ge(gr),fn={width:yn,height:fi},pi=Object(E.useMemo)(function(){if(wt){var kt=new Date(wt),Kt=kt.getHours(),Nt=kt.getMinutes(),Jt=kt.getSeconds();return Kt=Kt<10?"0"+Kt:Kt,Nt=Nt<10?"0"+Nt:Nt,Jt=Jt<10?"0"+Jt:Jt,"".concat(Kt,":").concat(Nt,":").concat(Jt)}return 0},[wt]);function ji(){window.sessionStorage.removeItem(Xt),Wr(!1),mt(0)}function Un(){Wr(!1),mt(0),P.setValue(window.sessionStorage.getItem(Xt))}function ua(kt,Kt){var Nt=P.getValue();Nt=Nt.replace(kt,Kt),qe(Nt),P==null||P.setValue(Nt)}return L.a.createElement(E.Fragment,null,L.a.createElement("div",{className:"markdown-editor-wrapper",ref:br},L.a.createElement("div",{className:"markdown-editor-container ".concat(Ie," ").concat(Pt?"on-preview":""," ").concat(Ft?"mini":""," ").concat(Mr?"full-screen":""),style:fn},L.a.createElement(S,{insertTemp:Lt,watch:Pt,fullScreen:Mr,showNullButton:tt,onActionCallback:Yn,hidetoolBar:nr,uuid:or.current,setOpenPhones:function(){tr.current=!0}}),L.a.createElement("div",{className:"markdown-editor-body"},L.a.createElement("div",{className:"codemirror-container"},L.a.createElement("textarea",{ref:Ht,placeholder:dn})),Pt?L.a.createElement("div",{ref:vn,className:"preview-container"},Zt==="stex"&&L.a.createElement(l,{value:Ne}),Zt!=="stex"&&L.a.createElement(m.a,{edit:!0,value:Ne,replaces:ua})):null))),Gt?L.a.createElement("a",{ref:lr,className:"editor-resize"}):null,L.a.createElement(M.a,null,ie[wr]?L.a.createElement($.a,{centered:!0,title:ie[wr],visible:!0,onCancel:Ln,footer:null,className:"markdown-popup-form"},hi):null))}},PGNT:function(At,ht,re){At.exports={wrap:"wrap___orWmH",modal:"modal___142IN",titleWrap:"titleWrap___2UWGN",required:"required___lXOtq",title:"title___2wqMf",colorGray:"colorGray___3FkLm",choiceWrap:"choiceWrap___3pbic",answer:"answer___30LSv",activeAnswer:"activeAnswer___3ayAN",deleteIcon:"deleteIcon___2HHly",addIcon:"addIcon___29vcx",editorWrap:"editorWrap___ANVP6",htmlWrap:"htmlWrap___38sLf",radio:"radio___15wok",color333:"color333___sNPjh",color999:"color999___1ofkl",fold:"fold___6rnoE",head:"head___2muph"}},PsQE:function(At,ht,re){At.exports={flex_box_center:"flex_box_center___2PkN_",flex_space_between:"flex_space_between___36cDA",flex_box_vertical_center:"flex_box_vertical_center___2c88u",flex_box_center_end:"flex_box_center_end___14cXO",flex_box_column:"flex_box_column___3nalt",wrap:"wrap___3xZrs",left:"left___19hOK",title:"title___3Ti2k",total:"total___3MRC5",list:"list___3pdfL",name:"name___2IcTs",b:"b___2W0Sn",r:"r___2Tpj8",l:"l___1rMKQ",tag:"tag___jj2X5",right:"right___16831",examName:"examName___2TmgX",t:"t___1CJZd",num:"num___1qX6C",topWarp:"topWarp___3WuSr",head:"head___3z9Hq",so:"so___m2B6Z",btn:"btn___20VL7",content:"content___2tTuo",titleWrap:"titleWrap___1cYdQ",single:"single___1BKtz",analysis:"analysis___1qm4Y",text:"text___1JQUf",btnsElse:"btnsElse___2IzAs",btnsWrap:"btnsWrap___3ib37",btns:"btns___2DbBT",modalColumn:"modalColumn___1zs36",modalRow:"modalRow___14b2N",sup:"sup___1CIjI",popover:"popover___Mmcvb"}},"RZ/O":function(At,ht,re){At.exports=re.p+"static/bi.9c9b0364.svg"},SJMd:function(At,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,ae,$,R=!1,X,N;window.PR_SHOULD_USE_CONTINUATION=!0;var I,z;(function(){var B=window,O=["break,continue,do,else,for,if,return,while"],D=[O,"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"],E=[D,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],L=[E,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],k=[E,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],T=[E,"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"],A="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",C=[E,"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=[O,"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"],c=[O,"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=[O,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],_=[L,T,k,C,h,o,c,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/,m="str",l="kwd",x="com",f="typ",p="lit",s="pun",a="pln",b="tag",v="dec",S="src",M="atn",H="atv",V="nocode",Q="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function G(Le){for(var Me=0,ze=!1,Ge=!1,He=0,Be=Le.length;He122||(ee<65||pe>90||gt.push([Math.max(65,pe)|32,Math.min(ee,90)|32]),ee<97||pe>122||gt.push([Math.max(97,pe)&~32,Math.min(ee,122)&~32]))}}gt.sort(function(ue,Se){return ue[0]-Se[0]||Se[1]-ue[1]});for(var te=[],ie=[],je=0;jese[0]&&(se[1]+1>se[0]&&Re.push("-"),Re.push(et(se[1])))}return Re.push("]"),Re.join("")}function Et(dt){for(var we=dt.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")),gt=we.length,lt=[],Re=0,je=0;Re=2&&pe==="["?we[Re]=at(ge):pe!=="\\"&&(we[Re]=ge.replace(/[a-zA-Z]/g,function(ie){var se=ie.charCodeAt(0);return"["+String.fromCharCode(se&~32,se|32)+"]"}))}return we.join("")}for(var ct=[],He=0,Be=Le.length;He=0;)ze[ct.charAt(dt)]=Et;var we=Et[1],gt=""+we;it.hasOwnProperty(gt)||(pt.push(we),it[gt]=null)}pt.push(/[\0-\uffff]/),Ge=G(pt)})();var He=Me.length,Be=function(Pe){for(var pt=Pe.sourceCode,it=Pe.basePos,et=Pe.sourceNode,at=[it,a],Et=0,ct=pt.match(Ge)||[],dt={},we=0,gt=ct.length;we=5&&Re.substring(0,5)==="lang-",ge&&!(je&&typeof je[1]=="string")&&(ge=!1,Re=S),ge||(dt[lt]=Re)}var ee=Et;if(Et+=lt.length,!ge)at.push(it+ee,Re);else{var te=je[1],ie=lt.indexOf(te),se=ie+te.length;je[2]&&(se=lt.length-je[2].length,ie=se-te.length);var ue=Re.substring(5);q(et,it+ee,lt.substring(0,ie),Be,at),q(et,it+ee+ie,te,ne(ue,te),at),q(et,it+ee+se,lt.substring(se),Be,at)}}Pe.decorations=at};return Be}function De(Le){var Me=[],ze=[];Le.tripleQuotedStrings?Me.push([m,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):Le.multiLineStrings?Me.push([m,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Me.push([m,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),Le.verbatimStrings&&ze.push([m,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Ge=Le.hashComments;Ge&&(Le.cStyleComments?(Ge>1?Me.push([x,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Me.push([x,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),ze.push([m,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Me.push([x,/^#[^\r\n]*/,null,"#"])),Le.cStyleComments&&(ze.push([x,/^\/\/[^\r\n]*/,null]),ze.push([x,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var He=Le.regexLiterals;if(He){var Be=He>1?"":` \r`,Pe=Be?".":"[\\S\\s]",pt="/(?=[^/*"+Be+"])(?:[^/\\x5B\\x5C"+Be+"]|\\x5C"+Pe+"|\\x5B(?:[^\\x5C\\x5D"+Be+"]|\\x5C"+Pe+")*(?:\\x5D|$))+/";ze.push(["lang-regex",RegExp("^"+Q+"("+pt+")")])}var it=Le.types;it&&ze.push([f,it]);var et=(""+Le.keywords).replace(/^ | $/g,"");et.length&&ze.push([l,new RegExp("^(?:"+et.replace(/[\s,]+/g,"|")+")\\b"),null]),Me.push([a,/^\s+/,null,` \r \xA0`]);var at="^.[^\\s\\w.$@'\"`/\\\\]*";return Le.regexLiterals&&(at+="(?!s*/)"),ze.push([p,/^@[a-z_$][a-z_$@0-9]*/i,null],[f,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[a,/^[a-z_$][a-z_$@0-9]*/i,null],[p,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(at),null]),ve(Me,ze)}var Ee=De({keywords:_,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function _e(Le,Me,ze){for(var Ge=/(?:^|\s)nocode(?:\s|$)/,He=/\r\n?|\n/,Be=Le.ownerDocument,Pe=Be.createElement("li");Le.firstChild;)Pe.appendChild(Le.firstChild);var pt=[Pe];function it(we){var gt=we.nodeType;if(gt==1&&!Ge.test(we.className))if(we.nodeName==="br")et(we),we.parentNode&&we.parentNode.removeChild(we);else for(var lt=we.firstChild;lt;lt=lt.nextSibling)it(lt);else if((gt==3||gt==4)&&ze){var Re=we.nodeValue,je=Re.match(He);if(je){var ge=Re.substring(0,je.index);we.nodeValue=ge;var de=Re.substring(je.index+je[0].length);if(de){var pe=we.parentNode;pe.insertBefore(Be.createTextNode(de),we.nextSibling)}et(we),ge||we.parentNode.removeChild(we)}}}function et(we){for(;!we.nextSibling;)if(we=we.parentNode,!we)return;function gt(je,ge){var de=ge?je.cloneNode(!1):je,pe=je.parentNode;if(pe){var ee=gt(pe,1),te=je.nextSibling;ee.appendChild(de);for(var ie=te;ie;ie=te)te=ie.nextSibling,ee.appendChild(ie)}return de}for(var lt=gt(we.nextSibling,0),Re;(Re=lt.parentNode)&&Re.nodeType===1;)lt=Re;pt.push(lt)}for(var at=0;at=pe&&(it+=2),Be>=ee&&(Et+=2)}}finally{Re&&(Re.style.display=je)}}var Ce={};function me(Le,Me){for(var ze=Me.length;--ze>=0;){var Ge=Me[ze];Ce.hasOwnProperty(Ge)?B.console&&console.warn("cannot override language handler %s",Ge):Ce[Ge]=Le}}function ne(Le,Me){return Le&&Ce.hasOwnProperty(Le)||(Le=/^\s*]*(?:>|$)/],[x,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[s,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]),me(ve([[a,/^[\s]+/,null,` \r `],[H,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[b,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[M,/^(?!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"]),me(ve([],[[H,/^[\s\S]+/]]),["uq.val"]),me(De({keywords:L,hashComments:!0,cStyleComments:!0,types:y}),["c","cc","cpp","cxx","cyc","m"]),me(De({keywords:"null,true,false"}),["json"]),me(De({keywords:T,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:y}),["cs"]),me(De({keywords:k,cStyleComments:!0}),["java"]),me(De({keywords:d,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),me(De({keywords:o,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),me(De({keywords:h,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),me(De({keywords:c,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),me(De({keywords:C,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),me(De({keywords:A,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),me(ve([],[[m,/^[\s\S]+/]]),["regex"]);function Ae(Le){var Me=Le.langExtension;try{var ze=W(Le.sourceNode,Le.pre),Ge=ze.sourceCode;Le.sourceCode=Ge,Le.spans=ze.spans,Le.basePos=0,ne(Me,Ge)(Le),Te(Le)}catch(He){B.console&&console.log(He&&He.stack||He)}}function rt(Le,Me,ze){var Ge=ze||!1,He=Me||null,Be=document.createElement("div");Be.innerHTML="
    "+Le+"
    ",Be=Be.firstChild,Ge&&_e(Be,Ge,!0);var Pe={langExtension:He,numberLines:Ge,sourceNode:Be,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return Ae(Pe),Be.innerHTML}function $e(Le,Me){var ze=Me||document.body,Ge=ze.ownerDocument||document;function He(de){return ze.getElementsByTagName(de)}for(var Be=[He("pre"),He("code"),He("xmp")],Pe=[],pt=0;pt=15&&(L=!1,O=!0);var m=c&&(D||L&&(y==null||y<12.11)),l=R||z&&B>=9;function x(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var f=function(e,t){var n=e.className,r=x(t).exec(n);if(r){var i=n.slice(r.index+r[0].length);e.className=n.slice(0,r.index)+(i?r[1]+i:"")}};function p(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function s(e,t){return p(e).appendChild(t)}function a(e,t,n,r){var i=document.createElement(e);if(n&&(i.className=n),r&&(i.style.cssText=r),typeof t=="string")i.appendChild(document.createTextNode(t));else if(t)for(var w=0;w=t)return F+(t-w);F+=K-w,F+=n-F%n,w=K+1}}var oe=function(){this.id=null,this.f=null,this.time=0,this.handler=G(this.onTimeout,this)};oe.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},oe.prototype.set=function(e,t){this.f=t;var n=+new Date+e;(!this.id||n=t)return r+Math.min(F,t-i);if(i+=w-r,i+=n-i%n,r=w+1,i>=t)return r}}var me=[""];function ne(e){for(;me.length<=e;)me.push(Ae(me)+" ");return me[e]}function Ae(e){return e[e.length-1]}function rt(e,t){for(var n=[],r=0;r"\x80"&&(e.toUpperCase()!=e.toLowerCase()||Le.test(e))}function ze(e,t){return t?t.source.indexOf("\\w")>-1&&Me(e)?!0:t.test(e):Me(e)}function Ge(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var He=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function Be(e){return e.charCodeAt(0)>=768&&He.test(e)}function Pe(e,t,n){for(;(n<0?t>0:tn?-1:1;;){if(t==n)return t;var i=(t+n)/2,w=r<0?Math.ceil(i):Math.floor(i);if(w==t)return e(w)?t:n;e(w)?n=w:t=w+r}}function it(e,t,n,r){if(!e)return r(t,n,"ltr",0);for(var i=!1,w=0;wt||t==n&&F.to==t)&&(r(Math.max(F.from,t),Math.min(F.to,n),F.level==1?"rtl":"ltr",w),i=!0)}i||r(t,n,"ltr")}var et=null;function at(e,t,n){var r;et=null;for(var i=0;it)return i;w.to==t&&(w.from!=w.to&&n=="before"?r=i:et=i),w.from==t&&(w.from!=w.to&&n!="before"?r=i:et=i)}return r!=null?r:et}var Et=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function n(Z){return Z<=247?e.charAt(Z):1424<=Z&&Z<=1524?"R":1536<=Z&&Z<=1785?t.charAt(Z-1536):1774<=Z&&Z<=2220?"r":8192<=Z&&Z<=8203?"w":Z==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,i=/[stwN]/,w=/[LRr]/,F=/[Lb1n]/,K=/[1n]/;function Y(Z,le,he){this.level=Z,this.from=le,this.to=he}return function(Z,le){var he=le=="ltr"?"L":"R";if(Z.length==0||le=="ltr"&&!r.test(Z))return!1;for(var xe=Z.length,ye=[],Oe=0;Oe-1&&(r[t]=i.slice(0,w).concat(i.slice(w+1)))}}}function Re(e,t){var n=gt(e,t);if(!n.length)return;for(var r=Array.prototype.slice.call(arguments,2),i=0;i0}function pe(e){e.prototype.on=function(t,n){we(this,t,n)},e.prototype.off=function(t,n){lt(this,t,n)}}function ee(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function te(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function ie(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function se(e){ee(e),te(e)}function ue(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)),c&&e.ctrlKey&&t==1&&(t=3),t}var ke=function(){if(z&&B<9)return!1;var e=a("div");return"draggable"in e||"dragDrop"in e}(),Je;function Qe(e){if(Je==null){var t=a("span","\u200B");s(e,a("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(Je=t.offsetWidth<=1&&t.offsetHeight>2&&!(z&&B<8))}var n=Je?a("span","\u200B"):a("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}var bt;function Dt(e){if(bt!=null)return bt;var t=s(e,document.createTextNode("A\u062EA")),n=v(t,0,1).getBoundingClientRect(),r=v(t,1,2).getBoundingClientRect();return p(e),!n||n.left==n.right?!1:bt=r.right-n.right<3}var Ze=` b`.split(/\n/).length!=3?function(e){for(var t=0,n=[],r=e.length;t<=r;){var i=e.indexOf(` `,t);i==-1&&(i=e.length);var w=e.slice(t,e.charAt(i-1)=="\r"?i-1:i),F=w.indexOf("\r");F!=-1?(n.push(w.slice(0,F)),t+=F+1):(n.push(w),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},ut=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(n){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},Ft=function(){var e=a("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),Ct=null;function jt(e){if(Ct!=null)return Ct;var t=s(e,a("span","x")),n=t.getBoundingClientRect(),r=v(t,0,1).getBoundingClientRect();return Ct=Math.abs(n.left-r.left)>1}var $t={},Lt={};function Qt(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),$t[e]=t}function Zt(e,t){Lt[e]=t}function ft(e){if(typeof e=="string"&&Lt.hasOwnProperty(e))e=Lt[e];else if(e&&typeof e.name=="string"&&Lt.hasOwnProperty(e.name)){var t=Lt[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 ft("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return ft("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function Xt(e,t){t=ft(t);var n=$t[t.name];if(!n)return Xt(e,"text/plain");var r=n(e,t);if(zt.hasOwnProperty(t.name)){var i=zt[t.name];for(var w in i){if(!i.hasOwnProperty(w))continue;r.hasOwnProperty(w)&&(r["_"+w]=r[w]),r[w]=i[w]}}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var F in t.modeProps)r[F]=t.modeProps[F];return r}var zt={};function Gt(e,t){var n=zt.hasOwnProperty(e)?zt[e]:zt[e]={};W(t,n)}function Ut(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n}function Mt(e,t){for(var n;e.innerMode&&!(n=e.innerMode(t),!n||n.mode==e);)t=n.state,e=n.mode;return n||{mode:e,state:t}}function St(e,t,n){return e.startState?e.startState(t,n):!0}var tt=function(e,t,n){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=n};tt.prototype.eol=function(){return this.pos>=this.string.length},tt.prototype.sol=function(){return this.pos==this.lineStart},tt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},tt.prototype.next=function(){if(this.post},tt.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},tt.prototype.skipToEnd=function(){this.pos=this.string.length},tt.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},tt.prototype.backUp=function(e){this.pos-=e},tt.prototype.column=function(){return this.lastColumnPos0?null:(w&&t!==!1&&(this.pos+=w[0].length),w)}},tt.prototype.current=function(){return this.string.slice(this.start,this.pos)},tt.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},tt.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},tt.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function Fe(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 n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],w=i.chunkSize();if(t=e.first&&tn?Ie(n,Fe(e,n).text.length):g(t,Fe(e,t.line).text.length)}function g(e,t){var n=e.ch;return n==null||n>t?Ie(e.line,t):n<0?Ie(e.line,0):e}function P(e,t){for(var n=[],r=0;rthis.maxLookAhead&&(this.maxLookAhead=e),t},j.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}},j.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},j.fromSaved=function(e,t,n){return t instanceof J?new j(e,Ut(e.mode,t.state),n,t.lookAhead):new j(e,Ut(e.mode,t),n)},j.prototype.save=function(e){var t=e!==!1?Ut(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new J(t,this.maxLookAhead):t};function ce(e,t,n,r){var i=[e.state.modeGen],w={};Mr(e,t.text,e.doc.mode,n,function(Z,le){return i.push(Z,le)},w,r);for(var F=n.state,K=function(Z){n.baseTokens=i;var le=e.state.overlays[Z],he=1,xe=0;n.state=!0,Mr(e,t.text,le.mode,n,function(ye,Oe){for(var We=he;xeye&&i.splice(he,1,ye,i[he+1],Ye),he+=2,xe=Math.min(ye,Ye)}if(!Oe)return;if(le.opaque)i.splice(We,he-We,ye,"overlay "+Oe),he=We+2;else for(;Wee.options.maxHighlightLength&&Ut(e.doc.mode,r.state),w=ce(e,t,r);i&&(r.state=i),t.stateAfter=r.save(!i),t.styles=w.styles,w.classes?t.styleClasses=w.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function qe(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return new j(r,!0,t);var w=Ir(e,t,n),F=w>r.first&&Fe(r,w-1).stateAfter,K=F?j.fromSaved(r,F,w):new j(r,St(r.mode),w);return r.iter(w,t,function(Y){Tt(e,Y.text,K);var Z=K.line;Y.stateAfter=Z==t-1||Z%5==0||Z>=i.viewFrom&&Zt.start)return w}throw new Error("Mode "+e.name+" failed to advance stream.")}var er=function(e,t,n){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=n};function fr(e,t,n,r){var i=e.doc,w=i.mode,F;t=u(i,t);var K=Fe(i,t.line),Y=qe(e,t.line,n),Z=new tt(K.text,e.options.tabSize,Y),le;for(r&&(le=[]);(r||Z.pose.options.maxHighlightLength?(K=!1,F&&Tt(e,t,r,le.pos),le.pos=t.length,he=null):he=Gr(Pt(n,le,r.state,xe),w),xe){var ye=xe[0].name;ye&&(he="m-"+(he?ye+" "+he:ye))}if(!K||Z!=he){for(;YF;--K){if(K<=w.first)return w.first;var Y=Fe(w,K-1),Z=Y.stateAfter;if(Z&&(!n||K+(Z instanceof J?Z.lookAhead:0)<=w.modeFrontier))return K;var le=q(Y.text,null,e.options.tabSize);(i==null||r>le)&&(i=K-1,r=le)}return i}function cn(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),e.highlightFrontiern;r--){var i=Fe(e,r).stateAfter;if(i&&(!(i instanceof J)||r+i.lookAhead=t:w.to>t);(r||(r=[])).push(new Ke(F,w.from,Y?null:w.to))}}return r}function gr(e,t,n){var r;if(e)for(var i=0;i=t:w.to>t);if(K||w.from==t&&F.type=="bookmark"&&(!n||w.marker.insertLeft)){var Y=w.from==null||(F.inclusiveLeft?w.from<=t:w.from0&&K)for(var _t=0;_t0)continue;var le=[Y,1],he=xt(Z.from,K.from),xe=xt(Z.to,K.to);(he<0||!F.inclusiveLeft&&!he)&&le.push({from:Z.from,to:K.from}),(xe>0||!F.inclusiveRight&&!xe)&&le.push({from:K.to,to:Z.to}),i.splice.apply(i,le),Y+=le.length-3}return i}function Sr(e){var t=e.markedSpans;if(!t)return;for(var n=0;nt)&&(!r||pr(r,w.marker)<0)&&(r=w.marker)}return r}function Nr(e,t,n,r,i){var w=Fe(e,t),F=wr&&w.markedSpans;if(F)for(var K=0;K=0&&he<=0||le<=0&&he>=0)continue;if(le<=0&&(Y.marker.inclusiveRight&&i.inclusiveLeft?xt(Z.to,n)>=0:xt(Z.to,n)>0)||le>=0&&(Y.marker.inclusiveRight&&i.inclusiveLeft?xt(Z.from,r)<=0:xt(Z.from,r)<0))return!0}}function Yr(e){for(var t;t=br(e);)e=t.find(-1,!0).line;return e}function Yn(e){for(var t;t=lr(e);)e=t.find(1,!0).line;return e}function An(e){for(var t,n;t=lr(e);)e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function hi(e,t){var n=Fe(e,t),r=Yr(n);return n==r?t:Wt(r)}function Ln(e,t){if(t>e.lastLine())return t;var n=Fe(e,t),r;if(!yn(e,n))return t;for(;r=lr(n);)n=r.find(1,!0).line;return Wt(n)+1}function yn(e,t){var n=wr&&t.markedSpans;if(n)for(var r=void 0,i=0;it.maxLineLength&&(t.maxLineLength=i,t.maxLine=r)})}var Un=function(e,t,n){this.text=e,Wr(this,t),this.height=n?n(this):1};Un.prototype.lineNo=function(){return Wt(this)},pe(Un);function ua(e,t,n,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),Sr(e),Wr(e,n);var i=r?r(e):1;i!=e.height&&qt(e,i)}function kt(e){e.parent=null,Sr(e)}var Kt={},Nt={};function Jt(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?Nt:Kt;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function sr(e,t){var n=b("span",null,null,O?"padding-right: .1px":null),r={pre:b("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var w=i?t.rest[i-1]:t.line,F=void 0;r.pos=0,r.addToken=ar,Dt(e.display.measure)&&(F=ct(w,e.doc.direction))&&(r.addToken=Qr(r.addToken,F)),r.map=[];var K=t!=e.display.externalMeasured&&Wt(w);Cn(w,r,Ne(e,w,K)),w.styleClasses&&(w.styleClasses.bgClass&&(r.bgClass=V(w.styleClasses.bgClass,r.bgClass||"")),w.styleClasses.textClass&&(r.textClass=V(w.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(Qe(e.display.measure))),i==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(O){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 Re(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=V(r.pre.className,r.textClass||"")),r}function vr(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 ar(e,t,n,r,i,w,F){if(!t)return;var K=e.splitSpaces?Pr(t,e.trailingSpace):t,Y=e.cm.state.specialChars,Z=!1,le;if(!Y.test(t))e.col+=t.length,le=document.createTextNode(K),e.map.push(e.pos,e.pos+t.length,le),z&&B<9&&(Z=!0),e.pos+=t.length;else{le=document.createDocumentFragment();for(var he=0;;){Y.lastIndex=he;var xe=Y.exec(t),ye=xe?xe.index-he:t.length-he;if(ye){var Oe=document.createTextNode(K.slice(he,he+ye));z&&B<9?le.appendChild(a("span",[Oe])):le.appendChild(Oe),e.map.push(e.pos,e.pos+ye,Oe),e.col+=ye,e.pos+=ye}if(!xe)break;he+=ye+1;var We=void 0;if(xe[0]==" "){var Ye=e.cm.options.tabSize,ot=Ye-e.col%Ye;We=le.appendChild(a("span",ne(ot),"cm-tab")),We.setAttribute("role","presentation"),We.setAttribute("cm-text"," "),e.col+=ot}else xe[0]=="\r"||xe[0]==` `?(We=le.appendChild(a("span",xe[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),We.setAttribute("cm-text",xe[0]),e.col+=1):(We=e.cm.options.specialCharPlaceholder(xe[0]),We.setAttribute("cm-text",xe[0]),z&&B<9?le.appendChild(a("span",[We])):le.appendChild(We),e.col+=1);e.map.push(e.pos,e.pos+1,We),e.pos++}}if(e.trailingSpace=K.charCodeAt(t.length-1)==32,n||r||i||Z||w||F){var yt=n||"";r&&(yt+=r),i&&(yt+=i);var st=a("span",[le],yt,w);if(F)for(var _t in F)F.hasOwnProperty(_t)&&_t!="style"&&_t!="class"&&st.setAttribute(_t,F[_t]);return e.content.appendChild(st)}e.content.appendChild(le)}function Pr(e,t){if(e.length>1&&!/ /.test(e))return e;for(var n=t,r="",i=0;iZ&&he.from<=Z);xe++);if(he.to>=le)return e(n,r,i,w,F,K,Y);e(n,r.slice(0,he.to-Z),i,w,null,K,Y),w=null,r=r.slice(he.to-Z),Z=he.to}}}function rr(e,t,n,r){var i=!r&&n.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!r&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",n.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t,e.trailingSpace=!1}function Cn(e,t,n){var r=e.markedSpans,i=e.text,w=0;if(!r){for(var F=1;FY||Yt.collapsed&&Ot.to==Y&&Ot.from==Y)){if(Ot.to!=null&&Ot.to!=Y&&ye>Ot.to&&(ye=Ot.to,We=""),Yt.className&&(Oe+=" "+Yt.className),Yt.css&&(xe=(xe?xe+";":"")+Yt.css),Yt.startStyle&&Ot.from==Y&&(Ye+=" "+Yt.startStyle),Yt.endStyle&&Ot.to==ye&&(_t||(_t=[])).push(Yt.endStyle,Ot.to),Yt.title&&((yt||(yt={})).title=Yt.title),Yt.attributes)for(var yr in Yt.attributes)(yt||(yt={}))[yr]=Yt.attributes[yr];Yt.collapsed&&(!ot||pr(ot.marker,Yt)<0)&&(ot=Ot)}else Ot.from>Y&&ye>Ot.from&&(ye=Ot.from)}if(_t)for(var Fr=0;Fr<_t.length;Fr+=2)_t[Fr+1]==ye&&(We+=" "+_t[Fr]);if(!ot||ot.from==Y)for(var Cr=0;Cr=K)break;for(var on=Math.min(K,ye);;){if(le){var tn=Y+le.length;if(!ot){var Rr=tn>on?le.slice(0,on-Y):le;t.addToken(t,Rr,he?he+Oe:Oe,Ye,Y+Rr.length==ye?We:"",xe,yt)}if(tn>=on){le=le.slice(on-Y),Y=on;break}Y=tn,Ye=""}le=i.slice(w,w=n[Z++]),he=Jt(n[Z++],t.cm.options)}}}function ur(e,t,n){this.line=t,this.rest=An(t),this.size=this.rest?Wt(Ae(this.rest))-n+1:1,this.node=this.text=null,this.hidden=yn(e,t)}function Zr(e,t,n){for(var r=[],i,w=t;w2&&w.push((Y.bottom+Z.top)/2-n.top)}}w.push(n.bottom-n.top)}}function eo(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;rn)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function Fs(e,t){t=Yr(t);var n=Wt(t),r=e.display.externalMeasured=new ur(e.doc,t,n);r.lineN=n;var i=r.built=sr(e,r);return r.text=i.pre,s(e.display.lineMeasure,i.pre),r}function to(e,t,n,r){return En(e,$n(e,t),n,r)}function fa(e,t){if(t>=e.display.viewFrom&&t=n.lineN&&tt)&&(w=Y-K,i=w-1,t>=Y&&(F="right")),i!=null){if(r=e[Z+2],K==Y&&n==(r.insertLeft?"left":"right")&&(F=n),n=="left"&&i==0)for(;Z&&e[Z-2]==e[Z-3]&&e[Z-1].insertLeft;)r=e[(Z-=3)+2],F="left";if(n=="right"&&i==Y-K)for(;Z=0&&!((n=e[i]).left!=n.right);i--);return n}function Ws(e,t,n,r){var i=no(t.map,n,r),w=i.node,F=i.start,K=i.end,Y=i.collapse,Z;if(w.nodeType==3){for(var le=0;le<4;le++){for(;F&&Be(t.line.text.charAt(i.coverStart+F));)--F;for(;i.coverStart+K0&&(Y=r="right");var he;e.options.lineWrapping&&(he=w.getClientRects()).length>1?Z=he[r=="right"?he.length-1:0]:Z=w.getBoundingClientRect()}if(z&&B<9&&!F&&(!Z||!Z.left&&!Z.right)){var xe=w.parentNode.getClientRects()[0];xe?Z={left:xe.left,right:xe.left+Qn(e.display),top:xe.top,bottom:xe.bottom}:Z=ro}for(var ye=Z.top-t.rect.top,Oe=Z.bottom-t.rect.top,We=(ye+Oe)/2,Ye=t.view.measure.heights,ot=0;ot=r.text.length?(Y=r.text.length,Z="before"):Y<=0&&(Y=0,Z="after"),!K)return F(Z=="before"?Y-1:Y,Z=="before");function le(Oe,We,Ye){var ot=K[We],yt=ot.level==1;return F(Ye?Oe-1:Oe,yt!=Ye)}var he=at(K,Y,Z),xe=et,ye=le(Y,he,Z=="before");return xe!=null&&(ye.other=le(Y,xe,Z!="before")),ye}function uo(e,t){var n=0;t=u(e.doc,t),e.options.lineWrapping||(n=Qn(e.display)*t.ch);var r=Fe(e.doc,t.line),i=fn(r)+Wi(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function ga(e,t,n,r,i){var w=Ie(e,t,n);return w.xRel=i,r&&(w.outside=r),w}function va(e,t,n){var r=e.doc;if(n+=e.display.viewOffset,n<0)return ga(r.first,0,null,-1,-1);var i=Tr(r,n),w=r.first+r.size-1;if(i>w)return ga(r.first+r.size-1,Fe(r,w).text.length,null,1,1);t<0&&(t=0);for(var F=Fe(r,i);;){var K=zs(e,F,i,t,n),Y=vn(F,K.ch+(K.xRel>0||K.outside>0?1:0));if(!Y)return K;var Z=Y.find(1);if(Z.line==i)return Z;F=Fe(r,i=Z.line)}}function co(e,t,n,r){r-=pa(t);var i=t.text.length,w=pt(function(F){return En(e,n,F-1).bottom<=r},i,0);return i=pt(function(F){return En(e,n,F).top>r},w,i),{begin:w,end:i}}function ho(e,t,n,r){n||(n=$n(e,t));var i=Hi(e,t,En(e,n,r),"line").top;return co(e,t,n,i)}function ya(e,t,n,r){return e.bottom<=n?!1:e.top>n?!0:(r?e.left:e.right)>t}function zs(e,t,n,r,i){i-=fn(t);var w=$n(e,t),F=pa(t),K=0,Y=t.text.length,Z=!0,le=ct(t,e.doc.direction);if(le){var he=(e.options.lineWrapping?Ks:Gs)(e,t,n,w,le,r,i);Z=he.level!=1,K=Z?he.from:he.to-1,Y=Z?he.to:he.from-1}var xe=null,ye=null,Oe=pt(function(Bt){var Ot=En(e,w,Bt);return Ot.top+=F,Ot.bottom+=F,ya(Ot,r,i,!1)?(Ot.top<=i&&Ot.left<=r&&(xe=Bt,ye=Ot),!0):!1},K,Y),We,Ye,ot=!1;if(ye){var yt=r-ye.left=_t.bottom?1:0}return Oe=Pe(t.text,Oe,1),ga(n,Oe,Ye,ot,r-We)}function Gs(e,t,n,r,i,w,F){var K=pt(function(he){var xe=i[he],ye=xe.level!=1;return ya(pn(e,Ie(n,ye?xe.to:xe.from,ye?"before":"after"),"line",t,r),w,F,!0)},0,i.length-1),Y=i[K];if(K>0){var Z=Y.level!=1,le=pn(e,Ie(n,Z?Y.from:Y.to,Z?"after":"before"),"line",t,r);ya(le,w,F,!0)&&le.top>F&&(Y=i[K-1])}return Y}function Ks(e,t,n,r,i,w,F){var K=co(e,t,r,F),Y=K.begin,Z=K.end;/\s/.test(t.text.charAt(Z-1))&&Z--;for(var le=null,he=null,xe=0;xe=Z||ye.to<=Y)continue;var Oe=ye.level!=1,We=En(e,r,Oe?Math.min(Z,ye.to)-1:Math.max(Y,ye.from)).right,Ye=WeYe)&&(le=ye,he=Ye)}return le||(le=i[i.length-1]),le.fromZ&&(le={from:le.from,to:Z,level:le.level}),le}var Fn;function Jn(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Fn==null){Fn=a("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Fn.appendChild(document.createTextNode("x")),Fn.appendChild(a("br"));Fn.appendChild(document.createTextNode("x"))}s(e.measure,Fn);var n=Fn.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),p(e.measure),n||1}function Qn(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=a("span","xxxxxxxxxx"),n=a("pre",[t],"CodeMirror-line-like");s(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function ba(e){for(var t=e.display,n={},r={},i=t.gutters.clientLeft,w=t.gutters.firstChild,F=0;w;w=w.nextSibling,++F){var K=e.display.gutterSpecs[F].className;n[K]=w.offsetLeft+w.clientLeft+i,r[K]=w.clientWidth}return{fixedPos:Ea(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Ea(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function fo(e){var t=Jn(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/Qn(e.display)-3);return function(i){if(yn(e.doc,i))return 0;var w=0;if(i.widgets)for(var F=0;F0&&(Z=Fe(e.doc,Y.line).text).length==Y.ch){var le=q(Z,Z.length,e.options.tabSize)-Z.length;Y=Ie(Y.line,Math.max(0,Math.round((w-qa(e.display).left)/Qn(e.display))-le))}return Y}function Wn(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var n=e.display.view,r=0;rt)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)wr&&hi(e.doc,t)i.viewFrom?kn(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)kn(e);else if(t<=i.viewFrom){var w=zi(e,n,n+r,1);w?(i.view=i.view.slice(w.index),i.viewFrom=w.lineN,i.viewTo+=r):kn(e)}else if(n>=i.viewTo){var F=zi(e,t,t,-1);F?(i.view=i.view.slice(0,F.index),i.viewTo=F.lineN):kn(e)}else{var K=zi(e,t,t,-1),Y=zi(e,n,n+r,1);K&&Y?(i.view=i.view.slice(0,K.index).concat(Zr(e,K.lineN,Y.lineN)).concat(i.view.slice(Y.index)),i.viewTo+=r):kn(e)}var Z=i.externalMeasured;Z&&(n=i.lineN&&t=r.viewTo)return;var w=r.view[Wn(e,t)];if(w.node==null)return;var F=w.changes||(w.changes=[]);fe(F,n)==-1&&F.push(n)}function kn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function zi(e,t,n,r){var i=Wn(e,t),w,F=e.display.view;if(!wr||n==e.doc.first+e.doc.size)return{index:i,lineN:n};for(var K=e.display.viewFrom,Y=0;Y0){if(i==F.length-1)return null;w=K+F[i].size-t,i++}else w=K-t;t+=w,n+=w}for(;hi(e.doc,n)!=n;){if(i==(r<0?0:F.length-1))return null;n+=r*F[i-(r<0?1:0)].size,i+=r}return{index:i,lineN:n}}function Vs(e,t,n){var r=e.display,i=r.view;i.length==0||t>=r.viewTo||n<=r.viewFrom?(r.view=Zr(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=Zr(e,t,r.viewFrom).concat(r.view):r.viewFromn&&(r.view=r.view.slice(0,Wn(e,n)))),r.viewTo=n}function po(e){for(var t=e.display.view,n=0,r=0;r=e.display.viewTo||K.to().line0?t.blinker=setInterval(function(){e.hasFocus()||Zn(e),t.cursorDiv.style.visibility=(n=!n)?"":"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,Zn(e))},100)}function Ca(e,t){if(e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),e.options.readOnly=="nocursor")return;e.state.focused||(Re(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(),O&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Sa(e)}function Zn(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(Re(e,"blur",e,t),e.state.focused=!1,f(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Ki(e){for(var t=e.display,n=t.lineDiv.offsetTop,r=0;r.005||le<-.005)&&(qt(i.line,F),bo(i.line),i.rest))for(var he=0;hee.display.sizerWidth){var xe=Math.ceil(K/Qn(e.display));xe>e.display.maxLineLength&&(e.display.maxLineLength=xe,e.display.maxLine=i.line,e.display.maxLineChanged=!0)}}}function bo(e){if(e.widgets)for(var t=0;t=F&&(w=Tr(t,fn(Fe(t,Y))-e.wrapper.clientHeight),F=Y)}return{from:w,to:Math.max(F,w+1)}}function Ys(e,t){if(je(e,"scrollCursorIntoView"))return;var n=e.display,r=n.sizer.getBoundingClientRect(),i=null;if(t.top+r.top<0?i=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),i!=null&&!A){var w=a("div","\u200B",null,`position: absolute; top: `+(t.top-n.viewOffset-Wi(e.display))+`px; height: `+(t.bottom-t.top+bn(e)+n.barHeight)+`px; left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(w),w.scrollIntoView(i),e.display.lineSpace.removeChild(w)}}function $s(e,t,n,r){r==null&&(r=0);var i;!e.options.lineWrapping&&t==n&&(t=t.ch?Ie(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,n=t.sticky=="before"?Ie(t.line,t.ch+1,"before"):t);for(var w=0;w<5;w++){var F=!1,K=pn(e,t),Y=!n||n==t?K:pn(e,n);i={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 Z=_a(e,i),le=e.doc.scrollTop,he=e.doc.scrollLeft;if(Z.scrollTop!=null&&(xi(e,Z.scrollTop),Math.abs(e.doc.scrollTop-le)>1&&(F=!0)),Z.scrollLeft!=null&&(Hn(e,Z.scrollLeft),Math.abs(e.doc.scrollLeft-he)>1&&(F=!0)),!F)break}return i}function Js(e,t){var n=_a(e,t);n.scrollTop!=null&&xi(e,n.scrollTop),n.scrollLeft!=null&&Hn(e,n.scrollLeft)}function _a(e,t){var n=e.display,r=Jn(e.display);t.top<0&&(t.top=0);var i=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:n.scroller.scrollTop,w=ha(e),F={};t.bottom-t.top>w&&(t.bottom=t.top+w);var K=e.doc.height+ca(n),Y=t.topK-r;if(t.topi+w){var le=Math.min(t.top,(Z?K:t.bottom)-w);le!=i&&(F.scrollTop=le)}var he=e.options.fixedGutter?0:n.gutters.offsetWidth,xe=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:n.scroller.scrollLeft-he,ye=Bn(e)-n.gutters.offsetWidth,Oe=t.right-t.left>ye;return Oe&&(t.right=t.left+ye),t.left<10?F.scrollLeft=0:t.leftye+xe-3&&(F.scrollLeft=t.right+(Oe?0:10)-ye),F}function Ta(e,t){if(t==null)return;Xi(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function qn(e){Xi(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function Ei(e,t,n){(t!=null||n!=null)&&Xi(e),t!=null&&(e.curOp.scrollLeft=t),n!=null&&(e.curOp.scrollTop=n)}function Qs(e,t){Xi(e),e.curOp.scrollToPos=t}function Xi(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=uo(e,t.from),r=uo(e,t.to);Eo(e,n,r,t.margin)}}function Eo(e,t,n,r){var i=_a(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-r,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+r});Ei(e,i.scrollLeft,i.scrollTop)}function xi(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;R||Aa(e,{top:t}),xo(e,t,!0),R&&Aa(e),_i(e,100)}function xo(e,t,n){if(t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!n)return;e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t)}function Hn(e,t,n,r){if(t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)return;e.doc.scrollLeft=t,wo(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function Si(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+ca(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:r,scrollHeight:r+bn(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}var zn=function(e,t,n){this.cm=n;var r=this.vert=a("div",[a("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=a("div",[a("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=i.tabIndex=-1,e(r),e(i),we(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),we(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,z&&B<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};zn.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var i=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var w=e.viewWidth-e.barLeft-(n?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+w)+"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:n?r:0,bottom:t?r:0}},zn.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},zn.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},zn.prototype.zeroWidthHack=function(){var e=c&&!T?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new oe,this.disableVert=new oe},zn.prototype.enableZeroWidthBar=function(e,t,n){e.style.pointerEvents="auto";function r(){var i=e.getBoundingClientRect(),w=n=="vert"?document.elementFromPoint(i.right-1,(i.top+i.bottom)/2):document.elementFromPoint((i.right+i.left)/2,i.bottom-1);w!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},zn.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Ci=function(){};Ci.prototype.update=function(){return{bottom:0,right:0}},Ci.prototype.setScrollLeft=function(){},Ci.prototype.setScrollTop=function(){},Ci.prototype.clear=function(){};function ei(e,t){t||(t=Si(e));var n=e.display.barWidth,r=e.display.barHeight;So(e,t);for(var i=0;i<4&&n!=e.display.barWidth||r!=e.display.barHeight;i++)n!=e.display.barWidth&&e.options.lineWrapping&&Ki(e),So(e,Si(e)),n=e.display.barWidth,r=e.display.barHeight}function So(e,t){var n=e.display,r=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=r.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=r.bottom)+"px",n.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=r.bottom+"px",n.scrollbarFiller.style.width=r.right+"px"):n.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}var Co={native:zn,null:Ci};function _o(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&f(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,n){n=="horizontal"?Hn(e,t):xi(e,t)},e),e.display.scrollbars.addClass&&H(e.display.wrapper,e.display.scrollbars.addClass)}var Zs=0;function Gn(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:++Zs},hn(e.curOp)}function Kn(e){var t=e.curOp;t&&Ds(t,function(n){for(var r=0;r=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Yi(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function tl(e){e.updatedDisplay=e.mustUpdate&&wa(e.cm,e.update)}function rl(e){var t=e.cm,n=t.display;e.updatedDisplay&&Ki(t),e.barMeasure=Si(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=to(t,n.maxLine,n.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+e.adjustWidthTo+bn(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-Bn(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection())}function nl(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft=e.display.viewTo)return;var n=+new Date+e.options.workTime,r=qe(e,t.highlightFrontier),i=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(w){if(r.line>=e.display.viewFrom){var F=w.styles,K=w.text.length>e.options.maxHighlightLength?Ut(t.mode,r.state):null,Y=ce(e,w,r,!0);K&&(r.state=K),w.styles=Y.styles;var Z=w.styleClasses,le=Y.classes;le?w.styleClasses=le:Z&&(w.styleClasses=null);for(var he=!F||F.length!=w.styles.length||Z!=le&&(!Z||!le||Z.bgClass!=le.bgClass||Z.textClass!=le.textClass),xe=0;!he&&xen)return _i(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),i.length&&an(e,function(){for(var w=0;w=n.viewFrom&&t.visible.to<=n.viewTo&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&po(e)==0)return!1;Ao(e)&&(kn(e),t.dims=ba(e));var i=r.first+r.size,w=Math.max(t.visible.from-e.options.viewportMargin,r.first),F=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFromF&&n.viewTo-F<20&&(F=Math.min(i,n.viewTo)),wr&&(w=hi(e.doc,w),F=Ln(e.doc,F));var K=w!=n.viewFrom||F!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;Vs(e,w,F),n.viewOffset=fn(Fe(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var Y=po(e);if(!K&&Y==0&&!t.force&&n.renderedView==n.view&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo))return!1;var Z=sl(e);return Y>4&&(n.lineDiv.style.display="none"),ul(e,n.updateLineNumbers,t.dims),Y>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,ll(Z),p(n.cursorDiv),p(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,K&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,_i(e,400)),n.updateLineNumbers=null,!0}function To(e,t){for(var n=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==Bn(e)){if(n&&n.top!=null&&(n={top:Math.min(e.doc.height+ca(e.display)-ha(e),n.top)}),t.visible=Vi(e.display,e.doc,n),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Vi(e.display,e.doc,n));if(!wa(e,t))break;Ki(e);var i=Si(e);bi(e),ei(e,i),Ra(e,i),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 n=new Yi(e,t);if(wa(e,n)){Ki(e),To(e,n);var r=Si(e);bi(e),ei(e,r),Ra(e,r),n.finish()}}function ul(e,t,n){var r=e.display,i=e.options.lineNumbers,w=r.lineDiv,F=w.firstChild;function K(Oe){var We=Oe.nextSibling;return O&&c&&e.display.currentWheelTarget==Oe?Oe.style.display="none":Oe.parentNode.removeChild(Oe),We}for(var Y=r.view,Z=r.viewFrom,le=0;le-1&&(ye=!1),Ya(e,he,Z,n)),ye&&(p(he.lineNumber),he.lineNumber.appendChild(document.createTextNode(Rt(e.options,Z)))),F=he.node.nextSibling}Z+=he.size}for(;F;)F=K(F)}function La(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function Ra(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+bn(e)+"px"}function wo(e){var t=e.display,n=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;for(var r=Ea(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,w=r+"px",F=0;FF.clientWidth,Y=F.scrollHeight>F.clientHeight;if(!(r&&K||i&&Y))return;if(i&&c&&O){e:for(var Z=t.target,le=w.view;Z!=F;Z=Z.parentNode)for(var he=0;he=0&&xt(e,r.to())<=0)return n}return-1};var dr=function(e,t){this.anchor=e,this.head=t};dr.prototype.from=function(){return xr(this.anchor,this.head)},dr.prototype.to=function(){return dn(this.anchor,this.head)},dr.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function mn(e,t,n){var r=e&&e.options.selectionsMayTouch,i=t[n];t.sort(function(xe,ye){return xt(xe.from(),ye.from())}),n=fe(t,i);for(var w=1;w0:Y>=0){var Z=xr(K.from(),F.from()),le=dn(K.to(),F.to()),he=K.empty()?F.from()==F.head:K.from()==K.head;w<=n&&--n,t.splice(--w,2,new dr(he?le:Z,he?Z:le))}}return new ln(t,n)}function Dn(e,t){return new ln([new dr(e,t||e)],0)}function Pn(e){return e.text?Ie(e.from.line+e.text.length-1,Ae(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Do(e,t){if(xt(e,t.from)<0)return e;if(xt(e,t.to)<=0)return Pn(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Pn(t).ch-t.to.ch),Ie(n,r)}function Da(e,t){for(var n=[],r=0;r1&&e.remove(K.line+1,Oe-1),e.insert(K.line+1,ot)}Hr(e,"change",e,t)}function On(e,t,n){function r(i,w,F){if(i.linked)for(var K=0;K1&&!e.done[e.done.length-2].ranges)return e.done.pop(),Ae(e.done)}function Uo(e,t,n,r){var i=e.history;i.undone.length=0;var w=+new Date,F,K;if((i.lastOp==r||i.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&i.lastModTime>w-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(F=pl(i,i.lastOp==r)))K=Ae(F.changes),xt(t.from,t.to)==0&&xt(t.from,K.to)==0?K.to=Pn(t):F.changes.push(Ma(e,t));else{var Y=Ae(i.done);for((!Y||!Y.ranges)&&Qi(e.sel,i.done),F={changes:[Ma(e,t)],generation:i.generation},i.done.push(F);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=w,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,K||Re(e,"historyAdded")}function ml(e,t,n,r){var i=t.charAt(0);return i=="*"||i=="+"&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function gl(e,t,n,r){var i=e.history,w=r&&r.origin;n==i.lastSelOp||w&&i.lastSelOrigin==w&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==w||ml(e,w,Ae(i.done),t))?i.done[i.done.length-1]=t:Qi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=w,i.lastSelOp=n,r&&r.clearRedo!==!1&&No(i.undone)}function Qi(e,t){var n=Ae(t);n&&n.ranges&&n.equals(e)||t.push(e)}function Bo(e,t,n,r){var i=t["spans_"+e.id],w=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),function(F){F.markedSpans&&((i||(i=t["spans_"+e.id]={}))[w]=F.markedSpans),++w})}function vl(e){if(!e)return null;for(var t,n=0;n-1&&(Ae(K)[he]=Z[he],delete Z[he]))}}return r}function Ia(e,t,n,r){if(r){var i=e.anchor;if(n){var w=xt(t,i)<0;w!=xt(n,i)<0?(i=t,t=n):w!=xt(t,n)<0&&(t=n)}return new dr(i,t)}else return new dr(n||t,t)}function Zi(e,t,n,r,i){i==null&&(i=e.cm&&(e.cm.display.shift||e.extend)),Vr(e,new ln([Ia(e.sel.primary(),t,n,i)],0),r)}function jo(e,t,n){for(var r=[],i=e.cm&&(e.cm.display.shift||e.extend),w=0;w=t.ch:K.to>t.ch))){if(i&&(Re(Y,"beforeCursorEnter"),Y.explicitlyCleared))if(w.markedSpans){--F;continue}else break;if(!Y.atomic)continue;if(n){var he=Y.find(r<0?1:-1),xe=void 0;if((r<0?le:Z)&&(he=Vo(e,he,-r,he&&he.line==t.line?w:null)),he&&he.line==t.line&&(xe=xt(he,n))&&(r<0?xe<0:xe>0))return ri(e,he,t,r,i)}var ye=Y.find(r<0?-1:1);return(r<0?Z:le)&&(ye=Vo(e,ye,r,ye.line==t.line?w:null)),ye?ri(e,ye,t,r,i):null}}return t}function ea(e,t,n,r,i){var w=r||1,F=ri(e,t,n,w,i)||!i&&ri(e,t,n,w,!0)||ri(e,t,n,-w,i)||!i&&ri(e,t,n,-w,!0);return F||(e.cantEdit=!0,Ie(e.first,0))}function Vo(e,t,n,r){return n<0&&t.ch==0?t.line>e.first?u(e,Ie(t.line-1)):null:n>0&&t.ch==(r||Fe(e,t.line)).text.length?t.line=0;--i)$o(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text,origin:t.origin});else $o(e,t)}function $o(e,t){if(t.text.length==1&&t.text[0]==""&&xt(t.from,t.to)==0)return;var n=Da(e,t);Uo(e,t,n,e.cm?e.cm.curOp.id:NaN),Ai(e,t,n,cr(e,t));var r=[];On(e,function(i,w){!w&&fe(r,i.history)==-1&&(qo(i.history,t),r.push(i.history)),Ai(i,t,null,cr(i,t))})}function ta(e,t,n){var r=e.cm&&e.cm.state.suppressEdits;if(r&&!n)return;for(var i=e.history,w,F=e.sel,K=t=="undo"?i.done:i.undone,Y=t=="undo"?i.undone:i.done,Z=0;Z=0;--ye){var Oe=xe(ye);if(Oe)return Oe.v}}function Jo(e,t){if(t==0)return;if(e.first+=t,e.sel=new ln(rt(e.sel.ranges,function(i){return new dr(Ie(i.anchor.line+t,i.anchor.ch),Ie(i.head.line+t,i.head.ch))}),e.sel.primIndex),e.cm){qr(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;re.lastLine())return;if(t.from.linew&&(t={from:t.from,to:Ie(w,Fe(e,w).text.length),text:[t.text[0]],origin:t.origin}),t.removed=nr(e,t.from,t.to),n||(n=Da(e,t)),e.cm?El(e.cm,t,r):Oa(e,t,r),qi(e,n,Ee),e.cantEdit&&ea(e,Ie(e.firstLine(),0))&&(e.cantEdit=!1)}function El(e,t,n){var r=e.doc,i=e.display,w=t.from,F=t.to,K=!1,Y=w.line;e.options.lineWrapping||(Y=Wt(Yr(Fe(r,w.line))),r.iter(Y,F.line+1,function(ye){if(ye==i.maxLine)return K=!0,!0})),r.sel.contains(t.from,t.to)>-1&&ge(e),Oa(r,t,n,fo(e)),e.options.lineWrapping||(r.iter(Y,w.line+t.text.length,function(ye){var Oe=pi(ye);Oe>i.maxLineLength&&(i.maxLine=ye,i.maxLineLength=Oe,i.maxLineChanged=!0,K=!1)}),K&&(e.curOp.updateMaxLine=!0)),cn(r,w.line),_i(e,400);var Z=t.text.length-(F.line-w.line)-1;t.full?qr(e):w.line==F.line&&t.text.length==1&&!Oo(e.doc,t)?Rn(e,w.line,"text"):qr(e,w.line,F.line+1,Z);var le=de(e,"changes"),he=de(e,"change");if(he||le){var xe={from:w,to:F,text:t.text,removed:t.removed,origin:t.origin};he&&Hr(e,"change",e,xe),le&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(xe)}e.display.selForContextMenu=null}function ii(e,t,n,r,i){var w;r||(r=n),xt(r,n)<0&&(w=[r,n],n=w[0],r=w[1]),typeof t=="string"&&(t=e.splitLines(t)),ni(e,{from:n,to:r,text:t,origin:i})}function Qo(e,t,n,r){n1||!(this.children[0]instanceof Ri))){var K=[];this.collapse(K),this.children=[new Ri(K)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t50){for(var F=i.lines.length%25+25,K=F;K10);e.parent.maybeSpill()},iterN:function(e,t,n){for(var r=0;re.display.maxLineLength&&(e.display.maxLine=Z,e.display.maxLineLength=le,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&qr(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Go(e.doc)),e&&Hr(e,"markerCleared",e,this,r,i),t&&Kn(e),this.parent&&this.parent.clear()},Mn.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var n,r,i=0;i0||F==0&&w.clearWhenEmpty!==!1)return w;if(w.replacedWith&&(w.collapsed=!0,w.widgetNode=b("span",[w.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||w.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(w.widgetNode.insertLeft=!0)),w.collapsed){if(Nr(e,t.line,t,n,w)||t.line!=n.line&&Nr(e,n.line,t,n,w))throw new Error("Inserting collapsed marker partially overlapping an existing one");be()}w.addToHistory&&Uo(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var K=t.line,Y=e.cm,Z;if(e.iter(K,n.line+1,function(he){Y&&w.collapsed&&!Y.options.lineWrapping&&Yr(he)==Y.display.maxLine&&(Z=!0),w.collapsed&&K!=t.line&&qt(he,0),vt(he,new Ke(w,K==t.line?t.ch:null,K==n.line?n.ch:null)),++K}),w.collapsed&&e.iter(t.line,n.line+1,function(he){yn(e,he)&&qt(he,0)}),w.clearOnEnter&&we(w,"beforeCursorEnter",function(){return w.clear()}),w.readOnly&&(nt(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),w.collapsed&&(w.id=++ts,w.atomic=!0),Y){if(Z&&(Y.curOp.updateMaxLine=!0),w.collapsed)qr(Y,t.line,n.line+1);else if(w.className||w.startStyle||w.endStyle||w.css||w.attributes||w.title)for(var le=t.line;le<=n.line;le++)Rn(Y,le,"text");w.atomic&&Go(Y.doc),Hr(Y,"markerAdded",Y,w)}return w}var Pi=function(e,t){this.markers=e,this.primary=t;for(var n=0;n=0;Y--)ni(this,r[Y]);K?Ho(this,K):this.cm&&qn(this.cm)}),undo:Br(function(){ta(this,"undo")}),redo:Br(function(){ta(this,"redo")}),undoSelection:Br(function(){ta(this,"undo",!0)}),redoSelection:Br(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,n=0,r=0;r=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,n){e=u(this,e),t=u(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,function(w){var F=w.markedSpans;if(F)for(var K=0;K=Y.to||Y.from==null&&i!=e.line||Y.from!=null&&i==t.line&&Y.from>=t.ch)&&(!n||n(Y.marker))&&r.push(Y.marker.parent||Y.marker)}++i}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var n=t.markedSpans;if(n)for(var r=0;re)return t=e,!0;e-=w,++n}),u(this,Ie(n,t))},indexFromPos:function(e){e=u(this,e);var t=e.ch;if(e.linet&&(t=e.from),e.to!=null&&e.to-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var le=e.dataTransfer.getData("Text");if(le){var he;if(t.state.draggingText&&!t.state.draggingText.copy&&(he=t.listSelections()),qi(t.doc,Dn(n,n)),he)for(var xe=0;xe=0;K--)ii(e.doc,"",r[K].from,r[K].to,"+delete");qn(e)})}function Ua(e,t,n){var r=Pe(e.text,t+n,n);return r<0||r>e.text.length?null:r}function Ba(e,t,n){var r=Ua(e,t.ch,n);return r==null?null:new Ie(t.line,r,n<0?"after":"before")}function Fa(e,t,n,r,i){if(e){t.doc.direction=="rtl"&&(i=-i);var w=ct(n,t.doc.direction);if(w){var F=i<0?Ae(w):w[0],K=i<0==(F.level==1),Y=K?"after":"before",Z;if(F.level>0||t.doc.direction=="rtl"){var le=$n(t,n);Z=i<0?n.text.length-1:0;var he=En(t,le,Z).top;Z=pt(function(xe){return En(t,le,xe).top==he},i<0==(F.level==1)?F.from:F.to-1,Z),Y=="before"&&(Z=Ua(n,Z,1))}else Z=i<0?F.to:F.from;return new Ie(r,Z,Y)}}return new Ie(r,i<0?n.text.length:0,i<0?"before":"after")}function Ml(e,t,n,r){var i=ct(t,e.doc.direction);if(!i)return Ba(t,n,r);n.ch>=t.text.length?(n.ch=t.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var w=at(i,n.ch,n.sticky),F=i[w];if(e.doc.direction=="ltr"&&F.level%2==0&&(r>0?F.to>n.ch:F.from=F.from&&xe>=le.begin)){var ye=he?"before":"after";return new Ie(n.line,xe,ye)}}var Oe=function(ot,yt,st){for(var _t=function(yr,Fr){return Fr?new Ie(n.line,K(yr,1),"before"):new Ie(n.line,yr,"after")};ot>=0&&ot0==(Bt.level!=1),Yt=Ot?st.begin:K(st.end,-1);if(Bt.from<=Yt&&Yt0?le.end:K(le.begin,-1);return Ye!=null&&!(r>0&&Ye==t.text.length)&&(We=Oe(r>0?0:i.length-1,r,Z(Ye)),We)?We:null}var Ii={selectAll:Xo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Ee)},killLine:function(e){return si(e,function(t){if(t.empty()){var n=Fe(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line0)i=new Ie(i.line,i.ch+1),e.replaceRange(w.charAt(i.ch-1)+w.charAt(i.ch-2),Ie(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var F=Fe(e.doc,i.line-1).text;F&&(i=new Ie(i.line,1),e.replaceRange(w.charAt(0)+e.doc.lineSeparator()+F.charAt(F.length-1),Ie(i.line-1,F.length-1),i,"+transpose"))}}n.push(new dr(i,i))}e.setSelections(n)})},newlineAndIndent:function(e){return an(e,function(){for(var t=e.listSelections(),n=t.length-1;n>=0;n--)e.replaceRange(e.doc.lineSeparator(),t[n].anchor,t[n].head,"+input");t=e.listSelections();for(var r=0;re&&xt(t,this.pos)==0&&n==this.button};var Ui,Bi;function Wl(e,t){var n=+new Date;return Bi&&Bi.compare(n,e,t)?(Ui=Bi=null,"triple"):Ui&&Ui.compare(n,e,t)?(Bi=new Wa(n,e,t),Ui=null,"double"):(Ui=new Wa(n,e,t),Bi=null,"single")}function vs(e){var t=this,n=t.display;if(je(t,e)||n.activeTouch&&n.input.supportsTouch())return;if(n.input.ensurePolled(),n.shift=e.shiftKey,_n(n,e)){O||(n.scroller.draggable=!1,setTimeout(function(){return n.scroller.draggable=!0},100));return}if(Ha(t,e))return;var r=jn(t,e),i=Se(e),w=r?Wl(r,i):"single";if(window.focus(),i==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,i,r,w,e))return;i==1?r?Gl(t,r,w,e):ue(e)==n.scroller&&ee(e):i==2?(r&&Zi(t.doc,r),setTimeout(function(){return n.input.focus()},20)):i==3&&(l?t.display.input.onContextMenu(e):yo(t))}function Hl(e,t,n,r,i){var w="Click";return r=="double"?w="Double"+w:r=="triple"&&(w="Triple"+w),w=(t==1?"Left":t==2?"Middle":"Right")+w,Ni(e,ls(w,i),i,function(F){if(typeof F=="string"&&(F=Ii[F]),!F)return!1;var K=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),K=F(e,n)!=De}finally{e.state.suppressEdits=!1}return K})}function zl(e,t,n){var r=e.getOption("configureMouse"),i=r?r(e,t,n):{};if(i.unit==null){var w=d?n.shiftKey&&n.metaKey:n.altKey;i.unit=w?"rectangle":t=="single"?"char":t=="double"?"word":"line"}return(i.extend==null||e.doc.extend)&&(i.extend=e.doc.extend||n.shiftKey),i.addNew==null&&(i.addNew=c?n.metaKey:n.ctrlKey),i.moveOnDrag==null&&(i.moveOnDrag=!(c?n.altKey:n.ctrlKey)),i}function Gl(e,t,n,r){z?setTimeout(G(vo,e),0):e.curOp.focus=M();var i=zl(e,n,r),w=e.doc.sel,F;e.options.dragDrop&&ke&&!e.isReadOnly()&&n=="single"&&(F=w.contains(t))>-1&&(xt((F=w.ranges[F]).from(),t)<0||t.xRel>0)&&(xt(F.to(),t)>0||t.xRel<0)?Kl(e,r,t,i):Vl(e,r,t,i)}function Kl(e,t,n,r){var i=e.display,w=!1,F=Ur(e,function(Z){O&&(i.scroller.draggable=!1),e.state.draggingText=!1,lt(i.wrapper.ownerDocument,"mouseup",F),lt(i.wrapper.ownerDocument,"mousemove",K),lt(i.scroller,"dragstart",Y),lt(i.scroller,"drop",F),w||(ee(Z),r.addNew||Zi(e.doc,n,null,null,r.extend),O&&!k||z&&B==9?setTimeout(function(){i.wrapper.ownerDocument.body.focus({preventScroll:!0}),i.input.focus()},20):i.input.focus())}),K=function(Z){w=w||Math.abs(t.clientX-Z.clientX)+Math.abs(t.clientY-Z.clientY)>=10},Y=function(){return w=!0};O&&(i.scroller.draggable=!0),e.state.draggingText=F,F.copy=!r.moveOnDrag,i.scroller.dragDrop&&i.scroller.dragDrop(),we(i.wrapper.ownerDocument,"mouseup",F),we(i.wrapper.ownerDocument,"mousemove",K),we(i.scroller,"dragstart",Y),we(i.scroller,"drop",F),yo(e),setTimeout(function(){return i.input.focus()},20)}function ys(e,t,n){if(n=="char")return new dr(t,t);if(n=="word")return e.findWordAt(t);if(n=="line")return new dr(Ie(t.line,0),u(e.doc,Ie(t.line+1,0)));var r=n(e,t);return new dr(r.from,r.to)}function Vl(e,t,n,r){var i=e.display,w=e.doc;ee(t);var F,K,Y=w.sel,Z=Y.ranges;if(r.addNew&&!r.extend?(K=w.sel.contains(n),K>-1?F=Z[K]:F=new dr(n,n)):(F=w.sel.primary(),K=w.sel.primIndex),r.unit=="rectangle")r.addNew||(F=new dr(n,n)),n=jn(e,t,!0,!0),K=-1;else{var le=ys(e,n,r.unit);r.extend?F=Ia(F,le.anchor,le.head,r.extend):F=le}r.addNew?K==-1?(K=Z.length,Vr(w,mn(e,Z.concat([F]),K),{scroll:!1,origin:"*mouse"})):Z.length>1&&Z[K].empty()&&r.unit=="char"&&!r.extend?(Vr(w,mn(e,Z.slice(0,K).concat(Z.slice(K+1)),0),{scroll:!1,origin:"*mouse"}),Y=w.sel):Na(w,K,F,_e):(K=0,Vr(w,new ln([F],0),_e),Y=w.sel);var he=n;function xe(st){if(xt(he,st)==0)return;if(he=st,r.unit=="rectangle"){for(var _t=[],Bt=e.options.tabSize,Ot=q(Fe(w,n.line).text,n.ch,Bt),Yt=q(Fe(w,st.line).text,st.ch,Bt),yr=Math.min(Ot,Yt),Fr=Math.max(Ot,Yt),Cr=Math.min(n.line,st.line),on=Math.min(e.lastLine(),Math.max(n.line,st.line));Cr<=on;Cr++){var tn=Fe(w,Cr).text,Rr=Ce(tn,yr,Bt);yr==Fr?_t.push(new dr(Ie(Cr,Rr),Ie(Cr,Rr))):tn.length>Rr&&_t.push(new dr(Ie(Cr,Rr),Ie(Cr,Ce(tn,Fr,Bt))))}_t.length||_t.push(new dr(n,n)),Vr(w,mn(e,Y.ranges.slice(0,K).concat(_t),K),{origin:"*mouse",scroll:!1}),e.scrollIntoView(st)}else{var rn=F,zr=ys(e,st,r.unit),Or=rn.anchor,kr;xt(zr.anchor,Or)>0?(kr=zr.head,Or=xr(rn.from(),zr.anchor)):(kr=zr.anchor,Or=dn(rn.to(),zr.head));var _r=Y.ranges.slice(0);_r[K]=Xl(e,new dr(u(w,Or),kr)),Vr(w,mn(e,_r,K),_e)}}var ye=i.wrapper.getBoundingClientRect(),Oe=0;function We(st){var _t=++Oe,Bt=jn(e,st,!0,r.unit=="rectangle");if(!Bt)return;if(xt(Bt,he)!=0){e.curOp.focus=M(),xe(Bt);var Ot=Vi(i,w);(Bt.line>=Ot.to||Bt.lineye.bottom?20:0;Yt&&setTimeout(Ur(e,function(){if(Oe!=_t)return;i.scroller.scrollTop+=Yt,We(st)}),50)}}function Ye(st){e.state.selectingText=!1,Oe=Infinity,st&&(ee(st),i.input.focus()),lt(i.wrapper.ownerDocument,"mousemove",ot),lt(i.wrapper.ownerDocument,"mouseup",yt),w.history.lastSelOrigin=null}var ot=Ur(e,function(st){st.buttons===0||!Se(st)?Ye(st):We(st)}),yt=Ur(e,Ye);e.state.selectingText=yt,we(i.wrapper.ownerDocument,"mousemove",ot),we(i.wrapper.ownerDocument,"mouseup",yt)}function Xl(e,t){var n=t.anchor,r=t.head,i=Fe(e.doc,n.line);if(xt(n,r)==0&&n.sticky==r.sticky)return t;var w=ct(i);if(!w)return t;var F=at(w,n.ch,n.sticky),K=w[F];if(K.from!=n.ch&&K.to!=n.ch)return t;var Y=F+(K.from==n.ch==(K.level!=1)?0:1);if(Y==0||Y==w.length)return t;var Z;if(r.line!=n.line)Z=(r.line-n.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var le=at(w,r.ch,r.sticky),he=le-F||(r.ch-n.ch)*(K.level==1?-1:1);le==Y-1||le==Y?Z=he<0:Z=he>0}var xe=w[Y+(Z?-1:0)],ye=Z==(xe.level==1),Oe=ye?xe.from:xe.to,We=ye?"after":"before";return n.ch==Oe&&n.sticky==We?t:new dr(new Ie(n.line,Oe,We),r)}function bs(e,t,n,r){var i,w;if(t.touches)i=t.touches[0].clientX,w=t.touches[0].clientY;else try{i=t.clientX,w=t.clientY}catch(xe){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&ee(t);var F=e.display,K=F.lineDiv.getBoundingClientRect();if(w>K.bottom||!de(e,n))return ie(t);w-=K.top-F.viewOffset;for(var Y=0;Y=i){var le=Tr(e.doc,w),he=e.display.gutterSpecs[Y];return Re(e,n,e,le,he.className,t),ie(t)}}}function Ha(e,t){return bs(e,t,"gutterClick",!0)}function Es(e,t){if(_n(e.display,t)||Yl(e,t))return;if(je(e,t,"contextmenu"))return;l||e.display.input.onContextMenu(t)}function Yl(e,t){return de(e,"gutterContextMenu")?bs(e,t,"gutterContextMenu",!1):!1}function xs(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),yi(e)}var li={toString:function(){return"CodeMirror.Init"}},Ss={},aa={};function $l(e){var t=e.optionHandlers;function n(r,i,w,F){e.defaults[r]=i,w&&(t[r]=F?function(K,Y,Z){Z!=li&&w(K,Y,Z)}:w)}e.defineOption=n,e.Init=li,n("value","",function(r,i){return r.setValue(i)},!0),n("mode",null,function(r,i){r.doc.modeOption=i,Pa(r)},!0),n("indentUnit",2,Pa,!0),n("indentWithTabs",!1),n("smartIndent",!0),n("tabSize",4,function(r){wi(r),yi(r),qr(r)},!0),n("lineSeparator",null,function(r,i){if(r.doc.lineSep=i,!i)return;var w=[],F=r.doc.first;r.doc.iter(function(Y){for(var Z=0;;){var le=Y.text.indexOf(i,Z);if(le==-1)break;Z=le+i.length,w.push(Ie(F,le))}F++});for(var K=w.length-1;K>=0;K--)ii(r.doc,i,w[K],Ie(w[K].line,w[K].ch+i.length))}),n("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(r,i,w){r.state.specialChars=new RegExp(i.source+(i.test(" ")?"":"| "),"g"),w!=li&&r.refresh()}),n("specialCharPlaceholder",vr,function(r){return r.refresh()},!0),n("electricChars",!0),n("inputStyle",o?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),n("spellcheck",!1,function(r,i){return r.getInputField().spellcheck=i},!0),n("autocorrect",!1,function(r,i){return r.getInputField().autocorrect=i},!0),n("autocapitalize",!1,function(r,i){return r.getInputField().autocapitalize=i},!0),n("rtlMoveVisually",!_),n("wholeLineUpdateBefore",!0),n("theme","default",function(r){xs(r),Ti(r)},!0),n("keyMap","default",function(r,i,w){var F=na(i),K=w!=li&&na(w);K&&K.detach&&K.detach(r,F),F.attach&&F.attach(r,K||null)}),n("extraKeys",null),n("configureMouse",null),n("lineWrapping",!1,Ql,!0),n("gutters",[],function(r,i){r.display.gutterSpecs=ka(i,r.options.lineNumbers),Ti(r)},!0),n("fixedGutter",!0,function(r,i){r.display.gutters.style.left=i?Ea(r.display)+"px":"0",r.refresh()},!0),n("coverGutterNextToScrollbar",!1,function(r){return ei(r)},!0),n("scrollbarStyle","native",function(r){_o(r),ei(r),r.display.scrollbars.setScrollTop(r.doc.scrollTop),r.display.scrollbars.setScrollLeft(r.doc.scrollLeft)},!0),n("lineNumbers",!1,function(r,i){r.display.gutterSpecs=ka(r.options.gutters,i),Ti(r)},!0),n("firstLineNumber",1,Ti,!0),n("lineNumberFormatter",function(r){return r},Ti,!0),n("showCursorWhenSelecting",!1,bi,!0),n("resetSelectionOnContextMenu",!0),n("lineWiseCopyCut",!0),n("pasteLinesPerSelection",!0),n("selectionsMayTouch",!1),n("readOnly",!1,function(r,i){i=="nocursor"&&(Zn(r),r.display.input.blur()),r.display.input.readOnlyChanged(i)}),n("screenReaderLabel",null,function(r,i){i=i===""?null:i,r.display.input.screenReaderLabelChanged(i)}),n("disableInput",!1,function(r,i){i||r.display.input.reset()},!0),n("dragDrop",!0,Jl),n("allowDropFileTypes",null),n("cursorBlinkRate",530),n("cursorScrollMargin",0),n("cursorHeight",1,bi,!0),n("singleCursorHeightPerLine",!0,bi,!0),n("workTime",100),n("workDelay",100),n("flattenSpans",!0,wi,!0),n("addModeClass",!1,wi,!0),n("pollInterval",100),n("undoDepth",200,function(r,i){return r.doc.history.undoDepth=i}),n("historyEventDelay",1250),n("viewportMargin",10,function(r){return r.refresh()},!0),n("maxHighlightLength",1e4,wi,!0),n("moveInputWithCursor",!0,function(r,i){i||r.display.input.resetPosition()}),n("tabindex",null,function(r,i){return r.display.input.getField().tabIndex=i||""}),n("autofocus",null),n("direction","ltr",function(r,i){return r.doc.setDirection(i)},!0),n("phrases",null)}function Jl(e,t,n){var r=n&&n!=li;if(!t!=!r){var i=e.display.dragFunctions,w=t?we:lt;w(e.display.scroller,"dragstart",i.start),w(e.display.scroller,"dragenter",i.enter),w(e.display.scroller,"dragover",i.over),w(e.display.scroller,"dragleave",i.leave),w(e.display.scroller,"drop",i.drop)}}function Ql(e){e.options.lineWrapping?(H(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(f(e.display.wrapper,"CodeMirror-wrap"),ji(e)),xa(e),qr(e),yi(e),setTimeout(function(){return ei(e)},100)}function Er(e,t){var n=this;if(!(this instanceof Er))return new Er(e,t);this.options=t=t?W(t):{},W(Ss,t,!1);var r=t.value;typeof r=="string"?r=new en(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var i=new Er.inputStyles[t.inputStyle](this),w=this.display=new dl(e,r,i,t);w.wrapper.CodeMirror=this,xs(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),_o(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new oe,keySeq:null,specialChars:null},t.autofocus&&!o&&w.input.focus(),z&&B<11&&setTimeout(function(){return n.display.input.reset(!0)},20),Zl(this),Rl(),Gn(this),this.curOp.forceUpdate=!0,Mo(this,r),t.autofocus&&!o||this.hasFocus()?setTimeout(function(){n.hasFocus()&&!n.state.focused&&Ca(n)},20):Zn(this);for(var F in aa)aa.hasOwnProperty(F)&&aa[F](this,t[F],li);Ao(this),t.finishInit&&t.finishInit(this);for(var K=0;K20*20}we(t.scroller,"touchstart",function(Y){if(!je(e,Y)&&!w(Y)&&!Ha(e,Y)){t.input.ensurePolled(),clearTimeout(n);var Z=+new Date;t.activeTouch={start:Z,moved:!1,prev:Z-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 Z=t.activeTouch;if(Z&&!_n(t,Y)&&Z.left!=null&&!Z.moved&&new Date-Z.start<300){var le=e.coordsChar(t.activeTouch,"page"),he;!Z.prev||F(Z,Z.prev)?he=new dr(le,le):!Z.prev.prev||F(Z,Z.prev.prev)?he=e.findWordAt(le):he=new dr(Ie(le.line,0),u(e.doc,Ie(le.line+1,0))),e.setSelection(he.anchor,he.head),e.focus(),ee(Y)}i()}),we(t.scroller,"touchcancel",i),we(t.scroller,"scroll",function(){t.scroller.clientHeight&&(xi(e,t.scroller.scrollTop),Hn(e,t.scroller.scrollLeft,!0),Re(e,"scroll",e))}),we(t.scroller,"mousewheel",function(Y){return ko(e,Y)}),we(t.scroller,"DOMMouseScroll",function(Y){return ko(e,Y)}),we(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(Y){je(e,Y)||se(Y)},over:function(Y){je(e,Y)||(Ll(e,Y),se(Y))},start:function(Y){return Al(e,Y)},drop:Ur(e,wl),leave:function(Y){je(e,Y)||is(e)}};var K=t.input.getField();we(K,"keyup",function(Y){return ms.call(e,Y)}),we(K,"keydown",Ur(e,ps)),we(K,"keypress",Ur(e,gs)),we(K,"focus",function(Y){return Ca(e,Y)}),we(K,"blur",function(Y){return Zn(e,Y)})}var za=[];Er.defineInitHook=function(e){return za.push(e)};function Fi(e,t,n,r){var i=e.doc,w;n==null&&(n="add"),n=="smart"&&(i.mode.indent?w=qe(e,t).state:n="prev");var F=e.options.tabSize,K=Fe(i,t),Y=q(K.text,null,F);K.stateAfter&&(K.stateAfter=null);var Z=K.text.match(/^\s*/)[0],le;if(!r&&!/\S/.test(K.text))le=0,n="not";else if(n=="smart"&&(le=i.mode.indent(w,K.text.slice(Z.length),K.text),le==De||le>150)){if(!r)return;n="prev"}n=="prev"?t>i.first?le=q(Fe(i,t-1).text,null,F):le=0:n=="add"?le=Y+e.options.indentUnit:n=="subtract"?le=Y-e.options.indentUnit:typeof n=="number"&&(le=Y+n),le=Math.max(0,le);var he="",xe=0;if(e.options.indentWithTabs)for(var ye=Math.floor(le/F);ye;--ye)xe+=F,he+=" ";if(xeF,Y=Ze(t),Z=null;if(K&&r.ranges.length>1)if(gn&&gn.text.join(` `)==t){if(r.ranges.length%gn.text.length==0){Z=[];for(var le=0;le=0;xe--){var ye=r.ranges[xe],Oe=ye.from(),We=ye.to();ye.empty()&&(n&&n>0?Oe=Ie(Oe.line,Oe.ch-n):e.state.overwrite&&!K?We=Ie(We.line,Math.min(Fe(w,We.line).text.length,We.ch+Ae(Y).length)):K&&gn&&gn.lineWise&&gn.text.join(` `)==Y.join(` `)&&(Oe=We=Ie(Oe.line,0)));var Ye={from:Oe,to:We,text:Z?Z[xe%Z.length]:Y,origin:i||(K?"paste":e.state.cutIncoming>F?"cut":"+input")};ni(e.doc,Ye),Hr(e,"inputRead",e,Ye)}t&&!K&&_s(e,t),qn(e),e.curOp.updateInput<2&&(e.curOp.updateInput=he),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Cs(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");if(n)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&an(t,function(){return Ga(t,n,0,null,"paste")}),!0}function _s(e,t){if(!e.options.electricChars||!e.options.smartIndent)return;for(var n=e.doc.sel,r=n.ranges.length-1;r>=0;r--){var i=n.ranges[r];if(i.head.ch>100||r&&n.ranges[r-1].head.line==i.head.line)continue;var w=e.getModeAt(i.head),F=!1;if(w.electricChars){for(var K=0;K-1){F=Fi(e,i.head.line,"smart");break}}else w.electricInput&&(w.electricInput.test(Fe(e.doc,i.head.line).text.slice(0,i.head.ch))&&(F=Fi(e,i.head.line,"smart")));F&&Hr(e,"electricInput",e,i.head.line)}}function Ts(e){for(var t=[],n=[],r=0;rw&&(Fi(this,K.head.line,r,!0),w=K.head.line,F==this.doc.sel.primIndex&&qn(this));else{var Y=K.from(),Z=K.to(),le=Math.max(w,Y.line);w=Math.min(this.lastLine(),Z.line-(Z.ch?0:1))+1;for(var he=le;he0&&Na(this.doc,F,new dr(Y,xe[F].to()),Ee)}}}),getTokenAt:function(r,i){return fr(this,r,i)},getLineTokens:function(r,i){return fr(this,Ie(r),i,!0)},getTokenTypeAt:function(r){r=u(this.doc,r);var i=Ne(this,Fe(this.doc,r.line)),w=0,F=(i.length-1)/2,K=r.ch,Y;if(K==0)Y=i[2];else for(;;){var Z=w+F>>1;if((Z?i[Z*2-1]:0)>=K)F=Z;else if(i[Z*2+1]Y&&(r=Y,F=!0),K=Fe(this.doc,r)}else K=r;return Hi(this,K,{top:0,left:0},i||"page",w||F).top+(F?this.doc.height-fn(K):0)},defaultTextHeight:function(){return Jn(this.display)},defaultCharWidth:function(){return Qn(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,i,w,F,K){var Y=this.display;r=pn(this,u(this.doc,r));var Z=r.bottom,le=r.left;if(i.style.position="absolute",i.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(i),Y.sizer.appendChild(i),F=="over")Z=r.top;else if(F=="above"||F=="near"){var he=Math.max(Y.wrapper.clientHeight,this.doc.height),xe=Math.max(Y.sizer.clientWidth,Y.lineSpace.clientWidth);(F=="above"||r.bottom+i.offsetHeight>he)&&r.top>i.offsetHeight?Z=r.top-i.offsetHeight:r.bottom+i.offsetHeight<=he&&(Z=r.bottom),le+i.offsetWidth>xe&&(le=xe-i.offsetWidth)}i.style.top=Z+"px",i.style.left=i.style.right="",K=="right"?(le=Y.sizer.clientWidth-i.offsetWidth,i.style.right="0px"):(K=="left"?le=0:K=="middle"&&(le=(Y.sizer.clientWidth-i.offsetWidth)/2),i.style.left=le+"px"),w&&Js(this,{left:le,top:Z,right:le+i.offsetWidth,bottom:Z+i.offsetHeight})},triggerOnKeyDown:$r(ps),triggerOnKeyPress:$r(gs),triggerOnKeyUp:ms,triggerOnMouseDown:$r(vs),execCommand:function(r){if(Ii.hasOwnProperty(r))return Ii[r].call(null,this)},triggerElectric:$r(function(r){_s(this,r)}),findPosH:function(r,i,w,F){var K=1;i<0&&(K=-1,i=-i);for(var Y=u(this.doc,r),Z=0;Z0&&le(w.charAt(F-1));)--F;for(;K.5||this.options.lineWrapping)&&xa(this),Re(this,"refresh",this)}),swapDoc:$r(function(r){var i=this.doc;return i.cm=null,this.state.selectingText&&this.state.selectingText(),Mo(this,r),yi(this),this.display.input.reset(),Ei(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,Hr(this,"swapDoc",this,i),i}),phrase:function(r){var i=this.options.phrases;return i&&Object.prototype.hasOwnProperty.call(i,r)?i[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}},pe(e),e.registerHelper=function(r,i,w){n.hasOwnProperty(r)||(n[r]=e[r]={_global:[]}),n[r][i]=w},e.registerGlobalHelper=function(r,i,w,F){e.registerHelper(r,i,F),n[r]._global.push({pred:w,val:F})}}function Ka(e,t,n,r,i){var w=t,F=n,K=Fe(e,t.line),Y=i&&e.direction=="rtl"?-n:n;function Z(){var yt=t.line+Y;return yt=e.first+e.size?!1:(t=new Ie(yt,t.ch,t.sticky),K=Fe(e,yt))}function le(yt){var st;if(r=="codepoint"){var _t=K.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(_t)?st=null:st=new Ie(t.line,Math.max(0,Math.min(K.text.length,t.ch+n*(_t>=55296&&_t<56320?2:1))),-n)}else i?st=Ml(e.cm,K,t,n):st=Ba(K,t,n);if(st==null)if(!yt&&Z())t=Fa(i,e.cm,K,t.line,Y);else return!1;else t=st;return!0}if(r=="char"||r=="codepoint")le();else if(r=="column")le(!0);else if(r=="word"||r=="group")for(var he=null,xe=r=="group",ye=e.cm&&e.cm.getHelper(t,"wordChars"),Oe=!0;!(n<0&&!le(!Oe));Oe=!1){var We=K.text.charAt(t.ch)||` `,Ye=ze(We,ye)?"w":xe&&We==` `?"n":!xe||/\s/.test(We)?null:"p";if(xe&&!Oe&&!Ye&&(Ye="s"),he&&he!=Ye){n<0&&(n=1,le(),t.sticky="after");break}if(Ye&&(he=Ye),n>0&&!le(!Oe))break}var ot=ea(e,t,w,F,!0);return Dr(w,ot)&&(ot.hitSide=!0),ot}function Ls(e,t,n,r){var i=e.doc,w=t.left,F;if(r=="page"){var K=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),Y=Math.max(K-.5*Jn(e.display),3);F=(n>0?t.bottom:t.top)+n*Y}else r=="line"&&(F=n>0?t.bottom+3:t.top-3);for(var Z;!(Z=va(e,w,F),!Z.outside);){if(n<0?F<=0:F>=i.height){Z.hitSide=!0;break}F+=n*5}return Z}var mr=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new oe,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};mr.prototype.init=function(e){var t=this,n=this,r=n.cm,i=n.div=e.lineDiv;ws(i,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function w(K){for(var Y=K.target;Y;Y=Y.parentNode){if(Y==i)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(Y.className))break}return!1}we(i,"paste",function(K){if(!w(K)||je(r,K)||Cs(K,r))return;B<=11&&setTimeout(Ur(r,function(){return t.updateFromDOM()}),20)}),we(i,"compositionstart",function(K){t.composing={data:K.data,done:!1}}),we(i,"compositionupdate",function(K){t.composing||(t.composing={data:K.data,done:!1})}),we(i,"compositionend",function(K){t.composing&&(K.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),we(i,"touchstart",function(){return n.forceCompositionEnd()}),we(i,"input",function(){t.composing||t.readFromDOMSoon()});function F(K){if(!w(K)||je(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=Ts(r);oa({lineWise:!0,text:Y.text}),K.type=="cut"&&r.operation(function(){r.setSelections(Y.ranges,0,Ee),r.replaceSelection("",null,"cut")})}else return;if(K.clipboardData){K.clipboardData.clearData();var Z=gn.text.join(` `);if(K.clipboardData.setData("Text",Z),K.clipboardData.getData("Text")==Z){K.preventDefault();return}}var le=As(),he=le.firstChild;r.display.lineSpace.insertBefore(le,r.display.lineSpace.firstChild),he.value=gn.text.join(` `);var xe=document.activeElement;Q(he),setTimeout(function(){r.display.lineSpace.removeChild(le),xe.focus(),xe==i&&n.showPrimarySelection()},50)}we(i,"copy",F),we(i,"cut",F)},mr.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},mr.prototype.prepareSelection=function(){var e=mo(this.cm,!1);return e.focus=document.activeElement==this.div,e},mr.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},mr.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},mr.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,n=t.doc.sel.primary(),r=n.from(),i=n.to();if(t.display.viewTo==t.display.viewFrom||r.line>=t.display.viewTo||i.line=t.display.viewFrom&&Rs(t,r)||{node:K[0].measure.map[2],offset:0},Z=i.linee.firstLine()&&(r=Ie(r.line-1,Fe(e.doc,r.line-1).length)),i.ch==Fe(e.doc,i.line).text.length&&i.linet.viewTo-1)return!1;var w,F,K;r.line==t.viewFrom||(w=Wn(e,r.line))==0?(F=Wt(t.view[0].line),K=t.view[0].node):(F=Wt(t.view[w].line),K=t.view[w-1].node.nextSibling);var Y=Wn(e,i.line),Z,le;if(Y==t.view.length-1?(Z=t.viewTo-1,le=t.lineDiv.lastChild):(Z=Wt(t.view[Y+1].line)-1,le=t.view[Y+1].node.previousSibling),!K)return!1;for(var he=e.doc.splitLines(tu(e,K,le,F,Z)),xe=nr(e.doc,Ie(F,0),Ie(Z,Fe(e.doc,Z).text.length));he.length>1&&xe.length>1;)if(Ae(he)==Ae(xe))he.pop(),xe.pop(),Z--;else if(he[0]==xe[0])he.shift(),xe.shift(),F++;else break;for(var ye=0,Oe=0,We=he[0],Ye=xe[0],ot=Math.min(We.length,Ye.length);yer.ch&&yt.charCodeAt(yt.length-Oe-1)==st.charCodeAt(st.length-Oe-1);)ye--,Oe++;he[he.length-1]=yt.slice(0,yt.length-Oe).replace(/^\u200b+/,""),he[0]=he[0].slice(ye).replace(/\u200b+$/,"");var Bt=Ie(F,ye),Ot=Ie(Z,xe.length?Ae(xe).length-Oe:0);if(he.length>1||he[0]||xt(Bt,Ot))return ii(e.doc,he,Bt,Ot,"+input"),!0},mr.prototype.ensurePolled=function(){this.forceCompositionEnd()},mr.prototype.reset=function(){this.forceCompositionEnd()},mr.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},mr.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)},mr.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&an(this.cm,function(){return qr(e.cm)})},mr.prototype.setUneditable=function(e){e.contentEditable="false"},mr.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault(),this.cm.isReadOnly()||Ur(this.cm,Ga)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},mr.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},mr.prototype.onContextMenu=function(){},mr.prototype.resetPosition=function(){},mr.prototype.needsContentAttribute=!0;function Rs(e,t){var n=fa(e,t.line);if(!n||n.hidden)return null;var r=Fe(e.doc,t.line),i=eo(n,r,t.line),w=ct(r,e.doc.direction),F="left";if(w){var K=at(w,t.ch);F=K%2?"right":"left"}var Y=no(i.map,t.ch,F);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 ui(e,t){return t&&(e.bad=!0),e}function tu(e,t,n,r,i){var w="",F=!1,K=e.doc.lineSeparator(),Y=!1;function Z(ye){return function(Oe){return Oe.id==ye}}function le(){F&&(w+=K,Y&&(w+=K),F=Y=!1)}function he(ye){ye&&(le(),w+=ye)}function xe(ye){if(ye.nodeType==1){var Oe=ye.getAttribute("cm-text");if(Oe){he(Oe);return}var We=ye.getAttribute("cm-marker"),Ye;if(We){var ot=e.findMarks(Ie(r,0),Ie(i+1,0),Z(+We));ot.length&&(Ye=ot[0].find(0))&&he(nr(e.doc,Ye.from,Ye.to).join(K));return}if(ye.getAttribute("contenteditable")=="false")return;var yt=/^(pre|div|p|li|table|br)$/i.test(ye.nodeName);if(!/^br$/i.test(ye.nodeName)&&ye.textContent.length==0)return;yt&&le();for(var st=0;st=9&&t.hasSelection&&(t.hasSelection=null),n.poll()}),we(i,"paste",function(F){if(je(r,F)||Cs(F,r))return;r.state.pasteIncoming=+new Date,n.fastPoll()});function w(F){if(je(r,F))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var K=Ts(r);oa({lineWise:!0,text:K.text}),F.type=="cut"?r.setSelections(K.ranges,null,Ee):(n.prevInput="",i.value=K.text.join(` `),Q(i))}else return;F.type=="cut"&&(r.state.cutIncoming=+new Date)}we(i,"cut",w),we(i,"copy",w),we(e.scroller,"paste",function(F){if(_n(e,F)||je(r,F))return;if(!i.dispatchEvent){r.state.pasteIncoming=+new Date,n.focus();return}var K=new Event("paste");K.clipboardData=F.clipboardData,i.dispatchEvent(K)}),we(e.lineSpace,"selectstart",function(F){_n(e,F)||ee(F)}),we(i,"compositionstart",function(){var F=r.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:F,range:r.markText(F,r.getCursor("to"),{className:"CodeMirror-composing"})}}),we(i,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},Ar.prototype.createField=function(e){this.wrapper=As(),this.textarea=this.wrapper.firstChild},Ar.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},Ar.prototype.prepareSelection=function(){var e=this.cm,t=e.display,n=e.doc,r=mo(e);if(e.options.moveInputWithCursor){var i=pn(e,n.sel.primary().head,"div"),w=t.wrapper.getBoundingClientRect(),F=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+F.top-w.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+F.left-w.left))}return r},Ar.prototype.showSelection=function(e){var t=this.cm,n=t.display;s(n.cursorDiv,e.cursors),s(n.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},Ar.prototype.reset=function(e){if(this.contextMenuPending||this.composing)return;var t=this.cm;if(t.somethingSelected()){this.prevInput="";var n=t.getSelection();this.textarea.value=n,t.state.focused&&Q(this.textarea),z&&B>=9&&(this.hasSelection=n)}else e||(this.prevInput=this.textarea.value="",z&&B>=9&&(this.hasSelection=null))},Ar.prototype.getField=function(){return this.textarea},Ar.prototype.supportsTouch=function(){return!1},Ar.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!o||M()!=this.textarea))try{this.textarea.focus()}catch(e){}},Ar.prototype.blur=function(){this.textarea.blur()},Ar.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Ar.prototype.receivedFocus=function(){this.slowPoll()},Ar.prototype.slowPoll=function(){var e=this;if(this.pollingFast)return;this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},Ar.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0;function n(){var r=t.poll();!r&&!e?(e=!0,t.polling.set(60,n)):(t.pollingFast=!1,t.slowPoll())}t.polling.set(20,n)},Ar.prototype.poll=function(){var e=this,t=this.cm,n=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||ut(n)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var i=n.value;if(i==r&&!t.somethingSelected())return!1;if(z&&B>=9&&this.hasSelection===i||c&&/[\uf700-\uf7ff]/.test(i))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var w=i.charCodeAt(0);if(w==8203&&!r&&(r="\u200B"),w==8666)return this.reset(),this.cm.execCommand("undo")}for(var F=0,K=Math.min(r.length,i.length);F1e3||i.indexOf(` `)>-1?n.value=e.prevInput="":e.prevInput=i,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},Ar.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Ar.prototype.onKeyPress=function(){z&&B>=9&&(this.hasSelection=null),this.fastPoll()},Ar.prototype.onContextMenu=function(e){var t=this,n=t.cm,r=n.display,i=t.textarea;t.contextMenuPending&&t.contextMenuPending();var w=jn(n,e),F=r.scroller.scrollTop;if(!w||L)return;var K=n.options.resetSelectionOnContextMenu;K&&n.doc.sel.contains(w)==-1&&Ur(n,Vr)(n.doc,Dn(w),Ee);var Y=i.style.cssText,Z=t.wrapper.style.cssText,le=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",i.style.cssText=`position: absolute; width: 30px; height: 30px; top: `+(e.clientY-le.top-5)+"px; left: "+(e.clientX-le.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 he;O&&(he=window.scrollY),r.input.focus(),O&&window.scrollTo(null,he),r.input.reset(),n.somethingSelected()||(i.value=t.prevInput=" "),t.contextMenuPending=ye,r.selForContextMenu=n.doc.sel,clearTimeout(r.detectingSelectAll);function xe(){if(i.selectionStart!=null){var We=n.somethingSelected(),Ye="\u200B"+(We?i.value:"");i.value="\u21DA",i.value=Ye,t.prevInput=We?"":"\u200B",i.selectionStart=1,i.selectionEnd=Ye.length,r.selForContextMenu=n.doc.sel}}function ye(){if(t.contextMenuPending!=ye)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=Z,i.style.cssText=Y,z&&B<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=F),i.selectionStart!=null){(!z||z&&B<9)&&xe();var We=0,Ye=function(){r.selForContextMenu==n.doc.sel&&i.selectionStart==0&&i.selectionEnd>0&&t.prevInput=="\u200B"?Ur(n,Xo)(n):We++<10?r.detectingSelectAll=setTimeout(Ye,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(Ye,200)}}if(z&&B>=9&&xe(),l){se(e);var Oe=function(){lt(window,"mouseup",Oe),setTimeout(ye,20)};we(window,"mouseup",Oe)}else setTimeout(ye,50)},Ar.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},Ar.prototype.setUneditable=function(){},Ar.prototype.needsContentAttribute=!1;function nu(e,t){if(t=t?W(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){var n=M();t.autofocus=n==e||e.getAttribute("autofocus")!=null&&n==document.body}function r(){e.value=K.getValue()}var i;if(e.form&&(we(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var w=e.form;i=w.submit;try{var F=w.submit=function(){r(),w.submit=i,w.submit(),w.submit=F}}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&&(lt(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=i))}},e.style.display="none";var K=Er(function(Y){return e.parentNode.insertBefore(Y,e.nextSibling)},t);return K}function iu(e){e.off=lt,e.on=we,e.wheelEventPixels=cl,e.Doc=en,e.splitLines=Ze,e.countColumn=q,e.findColumn=Ce,e.isWordChar=Me,e.Pass=De,e.signal=Re,e.Line=Un,e.changeEnd=Pn,e.scrollbarModel=Co,e.Pos=Ie,e.cmpPos=xt,e.modes=$t,e.mimeModes=Lt,e.resolveMode=ft,e.getMode=Xt,e.modeExtensions=zt,e.extendMode=Gt,e.copyState=Ut,e.startState=St,e.innerMode=Mt,e.commands=Ii,e.keyMap=Tn,e.keyName=us,e.isModifierKey=ss,e.lookupKey=oi,e.normalizeKeyMap=Ol,e.StringStream=tt,e.SharedTextMarker=Pi,e.TextMarker=Mn,e.LineWidget=Di,e.e_preventDefault=ee,e.e_stopPropagation=te,e.e_stop=se,e.addClass=H,e.contains=S,e.rmClass=f,e.keyNames=In}$l(Er),ql(Er);var au="iter insert remove copy getEditor constructor".split(" ");for(var la in en.prototype)en.prototype.hasOwnProperty(la)&&fe(au,la)<0&&(Er.prototype[la]=function(e){return function(){return e.apply(this.doc,arguments)}}(en.prototype[la]));return pe(en),Er.inputStyles={textarea:Ar,contenteditable:mr},Er.defineMode=function(e){!Er.defaults.mode&&e!="null"&&(Er.defaults.mode=e),Qt.apply(this,arguments)},Er.defineMIME=Zt,Er.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Er.defineMIME("text/plain","null"),Er.defineExtension=function(e,t){Er.prototype[e]=t},Er.defineDocExtension=function(e,t){en.prototype[e]=t},Er.fromTextArea=nu,iu(Er),Er.version="5.58.2",Er})},Y1PL:function(At,ht,re){"use strict";re.r(ht),re.d(ht,"ResizableTextArea",function(){return fe});var ae=re("wx14"),$=re("1OyB"),R=re("vuIU"),X=re("Ji7U"),N=re("LK+K"),I=re("q1tI"),z=re("VTBJ"),B=re("rePB"),O=re("Zm9Q"),D=re("Kwbf"),E=re("c+Xe"),L=re("m+aA"),k=re("bdgK"),T=new Map;function A(Ee){Ee.forEach(function(_e){var Te,Ce=_e.target;(Te=T.get(Ce))===null||Te===void 0||Te.forEach(function(me){return me(Ce)})})}var C=new k.default(A),h=null,o=null;function c(Ee,_e){T.has(Ee)||(T.set(Ee,new Set),C.observe(Ee)),T.get(Ee).add(_e)}function d(Ee,_e){T.has(Ee)&&(T.get(Ee).delete(_e),T.get(Ee).size||(C.unobserve(Ee),T.delete(Ee)))}var _=function(Ee){Object(X.a)(Te,Ee);var _e=Object(N.a)(Te);function Te(){return Object($.a)(this,Te),_e.apply(this,arguments)}return Object(R.a)(Te,[{key:"render",value:function(){return this.props.children}}]),Te}(I.Component),y=I.createContext(null);function m(Ee){var _e=Ee.children,Te=Ee.onBatchResize,Ce=I.useRef(0),me=I.useRef([]),ne=I.useContext(y),Ae=I.useCallback(function(rt,$e,Xe){Ce.current+=1;var Ve=Ce.current;me.current.push({size:rt,element:$e,data:Xe}),Promise.resolve().then(function(){Ve===Ce.current&&(Te==null||Te(me.current),me.current=[])}),ne==null||ne(rt,$e,Xe)},[Te,ne]);return I.createElement(y.Provider,{value:Ae},_e)}function l(Ee){var _e=Ee.children,Te=Ee.disabled,Ce=I.useRef(null),me=I.useRef(null),ne=I.useContext(y),Ae=I.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),rt=I.isValidElement(_e)&&Object(E.c)(_e),$e=rt?_e.ref:null,Xe=I.useMemo(function(){return Object(E.a)($e,Ce)},[$e,Ce]),Ve=I.useRef(Ee);Ve.current=Ee;var Le=I.useCallback(function(Me){var ze=Ve.current,Ge=ze.onResize,He=ze.data,Be=Me.getBoundingClientRect(),Pe=Be.width,pt=Be.height,it=Me.offsetWidth,et=Me.offsetHeight,at=Math.floor(Pe),Et=Math.floor(pt);if(Ae.current.width!==at||Ae.current.height!==Et||Ae.current.offsetWidth!==it||Ae.current.offsetHeight!==et){var ct={width:at,height:Et,offsetWidth:it,offsetHeight:et};Ae.current=ct;var dt=it===Math.round(Pe)?Pe:it,we=et===Math.round(pt)?pt:et,gt=Object(z.a)(Object(z.a)({},ct),{},{offsetWidth:dt,offsetHeight:we});ne==null||ne(gt,Me,He),Ge&&Promise.resolve().then(function(){Ge(gt,Me)})}},[]);return I.useEffect(function(){var Me=Object(L.a)(Ce.current)||Object(L.a)(me.current);return Me&&!Te&&c(Me,Le),function(){return d(Me,Le)}},[Ce.current,Te]),I.createElement(_,{ref:me},rt?I.cloneElement(_e,{ref:Xe}):_e)}var x="rc-observer-key";function f(Ee){var _e=Ee.children,Te=Object(O.a)(_e);return Te.map(function(Ce,me){var ne=(Ce==null?void 0:Ce.key)||"".concat(x,"-").concat(me);return I.createElement(l,Object(ae.a)({},Ee,{key:ne}),Ce)})}f.Collection=m;var p=f,s=re("bT9E"),a=re("TSYQ"),b=re.n(a),v=` min-height:0 !important; max-height:none !important; height:0 !important; visibility:hidden !important; overflow:hidden !important; position:absolute !important; z-index:-1000 !important; top:0 !important; right:0 !important `,S=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","font-variant","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing","word-break"],M={},H;function V(Ee){var _e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Te=Ee.getAttribute("id")||Ee.getAttribute("data-reactid")||Ee.getAttribute("name");if(_e&&M[Te])return M[Te];var Ce=window.getComputedStyle(Ee),me=Ce.getPropertyValue("box-sizing")||Ce.getPropertyValue("-moz-box-sizing")||Ce.getPropertyValue("-webkit-box-sizing"),ne=parseFloat(Ce.getPropertyValue("padding-bottom"))+parseFloat(Ce.getPropertyValue("padding-top")),Ae=parseFloat(Ce.getPropertyValue("border-bottom-width"))+parseFloat(Ce.getPropertyValue("border-top-width")),rt=S.map(function(Xe){return"".concat(Xe,":").concat(Ce.getPropertyValue(Xe))}).join(";"),$e={sizingStyle:rt,paddingSize:ne,borderSize:Ae,boxSizing:me};return _e&&Te&&(M[Te]=$e),$e}function Q(Ee){var _e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,Ce=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)),Ee.getAttribute("wrap")?H.setAttribute("wrap",Ee.getAttribute("wrap")):H.removeAttribute("wrap");var me=V(Ee,_e),ne=me.paddingSize,Ae=me.borderSize,rt=me.boxSizing,$e=me.sizingStyle;H.setAttribute("style","".concat($e,";").concat(v)),H.value=Ee.value||Ee.placeholder||"";var Xe=Number.MIN_SAFE_INTEGER,Ve=Number.MAX_SAFE_INTEGER,Le=H.scrollHeight,Me;if(rt==="border-box"?Le+=Ae:rt==="content-box"&&(Le-=ne),Te!==null||Ce!==null){H.value=" ";var ze=H.scrollHeight-ne;Te!==null&&(Xe=ze*Te,rt==="border-box"&&(Xe=Xe+ne+Ae),Le=Math.max(Xe,Le)),Ce!==null&&(Ve=ze*Ce,rt==="border-box"&&(Ve=Ve+ne+Ae),Me=Le>Ve?"":"hidden",Le=Math.min(Ve,Le))}return{height:Le,minHeight:Xe,maxHeight:Ve,overflowY:Me,resize:"none"}}var G=re("Gytx"),W=re.n(G),q;(function(Ee){Ee[Ee.NONE=0]="NONE",Ee[Ee.RESIZING=1]="RESIZING",Ee[Ee.RESIZED=2]="RESIZED"})(q||(q={}));var oe=function(Ee){Object(X.a)(Te,Ee);var _e=Object(N.a)(Te);function Te(Ce){var me;return Object($.a)(this,Te),me=_e.call(this,Ce),me.nextFrameActionId=void 0,me.resizeFrameId=void 0,me.textArea=void 0,me.saveTextArea=function(ne){me.textArea=ne},me.handleResize=function(ne){var Ae=me.state.resizeStatus,rt=me.props,$e=rt.autoSize,Xe=rt.onResize;if(Ae!==q.NONE)return;typeof Xe=="function"&&Xe(ne),$e&&me.resizeOnNextFrame()},me.resizeOnNextFrame=function(){cancelAnimationFrame(me.nextFrameActionId),me.nextFrameActionId=requestAnimationFrame(me.resizeTextarea)},me.resizeTextarea=function(){var ne=me.props.autoSize;if(!ne||!me.textArea)return;var Ae=ne.minRows,rt=ne.maxRows,$e=Q(me.textArea,!1,Ae,rt);me.setState({textareaStyles:$e,resizeStatus:q.RESIZING},function(){cancelAnimationFrame(me.resizeFrameId),me.resizeFrameId=requestAnimationFrame(function(){me.setState({resizeStatus:q.RESIZED},function(){me.resizeFrameId=requestAnimationFrame(function(){me.setState({resizeStatus:q.NONE}),me.fixFirefoxAutoScroll()})})})})},me.renderTextArea=function(){var ne=me.props,Ae=ne.prefixCls,rt=Ae===void 0?"rc-textarea":Ae,$e=ne.autoSize,Xe=ne.onResize,Ve=ne.className,Le=ne.disabled,Me=me.state,ze=Me.textareaStyles,Ge=Me.resizeStatus,He=Object(s.a)(me.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Be=b()(rt,Ve,Object(B.a)({},"".concat(rt,"-disabled"),Le));"value"in He&&(He.value=He.value||"");var Pe=Object(z.a)(Object(z.a)(Object(z.a)({},me.props.style),ze),Ge===q.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return I.createElement(p,{onResize:me.handleResize,disabled:!($e||Xe)},I.createElement("textarea",Object(ae.a)({},He,{className:Be,style:Pe,ref:me.saveTextArea})))},me.state={textareaStyles:{},resizeStatus:q.NONE},me}return Object(R.a)(Te,[{key:"componentDidUpdate",value:function(me){(me.value!==this.props.value||!W()(me.autoSize,this.props.autoSize))&&this.resizeTextarea()}},{key:"componentWillUnmount",value:function(){cancelAnimationFrame(this.nextFrameActionId),cancelAnimationFrame(this.resizeFrameId)}},{key:"fixFirefoxAutoScroll",value:function(){try{if(document.activeElement===this.textArea){var me=this.textArea.selectionStart,ne=this.textArea.selectionEnd;this.textArea.setSelectionRange(me,ne)}}catch(Ae){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Te}(I.Component),fe=oe,ve=function(Ee){Object(X.a)(Te,Ee);var _e=Object(N.a)(Te);function Te(Ce){var me;Object($.a)(this,Te),me=_e.call(this,Ce),me.resizableTextArea=void 0,me.focus=function(){me.resizableTextArea.textArea.focus()},me.saveTextArea=function(Ae){me.resizableTextArea=Ae},me.handleChange=function(Ae){var rt=me.props.onChange;me.setValue(Ae.target.value,function(){me.resizableTextArea.resizeTextarea()}),rt&&rt(Ae)},me.handleKeyDown=function(Ae){var rt=me.props,$e=rt.onPressEnter,Xe=rt.onKeyDown;Ae.keyCode===13&&$e&&$e(Ae),Xe&&Xe(Ae)};var ne=typeof Ce.value=="undefined"||Ce.value===null?Ce.defaultValue:Ce.value;return me.state={value:ne},me}return Object(R.a)(Te,[{key:"setValue",value:function(me,ne){"value"in this.props||this.setState({value:me},ne)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return I.createElement(fe,Object(ae.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(me){return"value"in me?{value:me.value}:null}}]),Te}(I.Component),De=ht.default=ve},ZWs3:function(At,ht,re){"use strict";re.d(ht,"a",function(){return E});var ae=re("+L6B"),$=re("2/Rp"),R=re("0Owb"),X=re("9og8"),N=re("tJVT"),I=re("PpiC"),z=re("WmNS"),B=re.n(z),O=re("q1tI"),D=re.n(O),E=function(k){var T=k.children,A=Object(I.a)(k,["children"]),C=Object(O.useState)(!1),h=Object(N.a)(C,2),o=h[0],c=h[1];return D.a.createElement($.a,Object(R.a)({},A,{loading:o,onClick:function(){var d=Object(X.a)(B.a.mark(function _(y){return B.a.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.prev=0,c(!0),l.next=4,A.onClick(y);case 4:c(!1),l.next=10;break;case 7:l.prev=7,l.t0=l.catch(0),c(!1);case 10:case"end":return l.stop()}},_,null,[[0,7]])}));return function(_){return d.apply(this,arguments)}}()}),T)}},ZpRC:function(At,ht,re){"use strict";function ae(E){return typeof E=="object"&&E!=null&&E.nodeType===1}function $(E,L){return(!L||E!=="hidden")&&E!=="visible"&&E!=="clip"}function R(E,L){if(E.clientHeightL||C>E&&h=L&&o>=k?C-E-T:h>L&&ok?h-L+A:0}var N=function(E,L){var k=window,T=L.scrollMode,A=L.block,C=L.inline,h=L.boundary,o=L.skipOverflowHiddenElements,c=typeof h=="function"?h:function(ze){return ze!==h};if(!ae(E))throw new TypeError("Invalid target");for(var d=document.scrollingElement||document.documentElement,_=[],y=E;ae(y)&&c(y);){if((y=y.parentElement)===d){_.push(y);break}y!=null&&y===document.body&&R(y)&&!R(document.documentElement)||y!=null&&R(y,o)&&_.push(y)}for(var m=k.visualViewport?k.visualViewport.width:innerWidth,l=k.visualViewport?k.visualViewport.height:innerHeight,x=window.scrollX||pageXOffset,f=window.scrollY||pageYOffset,p=E.getBoundingClientRect(),s=p.height,a=p.width,b=p.top,v=p.right,S=p.bottom,M=p.left,H=A==="start"||A==="nearest"?b:A==="end"?S:b+s/2,V=C==="center"?M+a/2:C==="end"?v:M,Q=[],G=0;G<_.length;G++){var W=_[G],q=W.getBoundingClientRect(),oe=q.height,fe=q.width,ve=q.top,De=q.right,Ee=q.bottom,_e=q.left;if(T==="if-needed"&&b>=0&&M>=0&&S<=l&&v<=m&&b>=ve&&S<=Ee&&M>=_e&&v<=De)return Q;var Te=getComputedStyle(W),Ce=parseInt(Te.borderLeftWidth,10),me=parseInt(Te.borderTopWidth,10),ne=parseInt(Te.borderRightWidth,10),Ae=parseInt(Te.borderBottomWidth,10),rt=0,$e=0,Xe="offsetWidth"in W?W.offsetWidth-W.clientWidth-Ce-ne:0,Ve="offsetHeight"in W?W.offsetHeight-W.clientHeight-me-Ae:0;if(d===W)rt=A==="start"?H:A==="end"?H-l:A==="nearest"?X(f,f+l,l,me,Ae,f+H,f+H+s,s):H-l/2,$e=C==="start"?V:C==="center"?V-m/2:C==="end"?V-m:X(x,x+m,m,Ce,ne,x+V,x+V+a,a),rt=Math.max(0,rt+f),$e=Math.max(0,$e+x);else{rt=A==="start"?H-ve-me:A==="end"?H-Ee+Ae+Ve:A==="nearest"?X(ve,Ee,oe,me,Ae+Ve,H,H+s,s):H-(ve+oe/2)+Ve/2,$e=C==="start"?V-_e-Ce:C==="center"?V-(_e+fe/2)+Xe/2:C==="end"?V-De+ne+Xe:X(_e,De,fe,Ce,ne+Xe,V,V+a,a);var Le=W.scrollLeft,Me=W.scrollTop;H+=Me-(rt=Math.max(0,Math.min(Me+rt,W.scrollHeight-oe+Ve))),V+=Le-($e=Math.max(0,Math.min(Le+$e,W.scrollWidth-fe+Xe)))}Q.push({el:W,top:rt,left:$e})}return Q};function I(E){return E===Object(E)&&Object.keys(E).length!==0}function z(E,L){L===void 0&&(L="auto");var k="scrollBehavior"in document.body.style;E.forEach(function(T){var A=T.el,C=T.top,h=T.left;A.scroll&&k?A.scroll({top:C,left:h,behavior:L}):(A.scrollTop=C,A.scrollLeft=h)})}function B(E){return E===!1?{block:"end",inline:"nearest"}:I(E)?E:{block:"start",inline:"nearest"}}function O(E,L){var k=!E.ownerDocument.documentElement.contains(E);if(I(L)&&typeof L.behavior=="function")return L.behavior(k?[]:N(E,L));if(k)return;var T=B(L);return z(N(E,T),T.behavior)}var D=ht.a=O},bT9E:function(At,ht,re){"use strict";re.d(ht,"a",function(){return $});var ae=re("VTBJ");function $(R,X){var N=Object(ae.a)({},R);return Array.isArray(X)&&X.forEach(function(I){delete N[I]}),N}},c5Ni:function(At,ht,re){},dejd:function(At,ht,re){},dmUQ:function(At,ht,re){"use strict";var ae=re("Ff2n"),$=re("rePB"),R=re("1OyB"),X=re("vuIU"),N=re("Ji7U"),I=re("md7G"),z=re("foSv"),B=re("q1tI"),O=re.n(B),D=re("TSYQ"),E=re.n(D),L=re("4IlW");function k(s,a){var b=Object.keys(s);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(s);a&&(v=v.filter(function(S){return Object.getOwnPropertyDescriptor(s,S).enumerable})),b.push.apply(b,v)}return b}function T(s){for(var a=1;a1?fe-1:0),De=1;De1?G-1:0),q=1;q=0)return parseInt(Q.slice(Q.indexOf("e-")+2),10);var G=0;return Q.indexOf(".")>=0&&(G=Q.length-Q.indexOf(".")-1),G},S.getInputDisplayValue=function(V){var Q=V||S.state,G=Q.focused,W=Q.inputValue,q=Q.value,oe;G?oe=W:oe=S.toPrecisionAsStep(q),oe==null&&(oe="");var fe=S.formatWrapper(oe);return m(S.props.decimalSeparator)&&(fe=fe.toString().replace(".",S.props.decimalSeparator)),fe},S.recordCursorPosition=function(){try{S.cursorStart=S.input.selectionStart,S.cursorEnd=S.input.selectionEnd,S.currentValue=S.input.value,S.cursorBefore=S.input.value.substring(0,S.cursorStart),S.cursorAfter=S.input.value.substring(S.cursorEnd)}catch(V){}},S.restoreByAfter=function(V){if(V===void 0)return!1;var Q=S.input.value,G=Q.lastIndexOf(V);if(G===-1)return!1;var W=S.cursorBefore.length;return S.lastKeyCode===L.a.DELETE&&S.cursorBefore.charAt(W-1)===V[0]?(S.fixCaret(W,W),!0):G+V.length===Q.length?(S.fixCaret(G,G),!0):!1},S.partRestoreByAfter=function(V){return V===void 0?!1:Array.prototype.some.call(V,function(Q,G){var W=V.substring(G);return S.restoreByAfter(W)})},S.isNotCompleteNumber=function(V){return isNaN(V)||V===""||V===null||V&&V.toString().indexOf(".")===V.toString().length-1},S.stop=function(){S.autoStepTimer&&clearTimeout(S.autoStepTimer)},S.down=function(V,Q,G){S.pressingUpOrDown=!0,S.step("down",V,Q,G)},S.up=function(V,Q,G){S.pressingUpOrDown=!0,S.step("up",V,Q,G)},S.saveInput=function(V){S.input=V};var M=v.value;M===void 0&&(M=v.defaultValue),S.state={focused:v.autoFocus};var H=S.getValidValue(S.toNumber(M));return S.state=T(T({},S.state),{},{inputValue:S.toPrecisionAsStep(H),value:H}),S}return Object(X.a)(b,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(S){var M=this.props,H=M.value,V=M.onChange,Q=M.max,G=M.min,W=this.state.focused;if(S){if(!l(S.value,H)||!l(S.max,Q)||!l(S.min,G)){var q=W?H:this.getValidValue(H),oe;this.pressingUpOrDown?oe=q:this.inputting?oe=this.rawInput:oe=this.toPrecisionAsStep(q),this.setState({value:q,inputValue:oe})}var fe="value"in this.props?H:this.state.value;"max"in this.props&&S.max!==Q&&typeof fe=="number"&&fe>Q&&V&&V(Q),"min"in this.props&&S.min!==G&&typeof fe=="number"&&fe1&&arguments[1]!==void 0?arguments[1]:this.props.min,H=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,V=parseFloat(S);return isNaN(V)?S:(VH&&(V=H),V)}},{key:"setValue",value:function(S,M){var H=this.props.precision,V=this.isNotCompleteNumber(parseFloat(S))?null:parseFloat(S),Q=this.state.value,G=Q===void 0?null:Q,W=this.state.inputValue,q=W===void 0?null:W,oe=typeof V=="number"?V.toFixed(H):"".concat(V),fe=V!==G||oe!=="".concat(q);return"value"in this.props?(q=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:q},M)):this.setState({value:V,inputValue:this.toPrecisionAsStep(S)},M),fe&&this.props.onChange(V),V}},{key:"getMaxPrecision",value:function(S){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,H=this.props,V=H.precision,Q=H.step;if(m(V))return V;var G=this.getPrecision(M),W=this.getPrecision(Q),q=this.getPrecision(S);return S?Math.max(q,G+W):G+W}},{key:"getPrecisionFactor",value:function(S){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,H=this.getMaxPrecision(S,M);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(S){return this.props.formatter?this.props.formatter(S):S}},{key:"toPrecisionAsStep",value:function(S){if(this.isNotCompleteNumber(S)||S==="")return S;var M=Math.abs(this.getMaxPrecision(S));return isNaN(M)?S.toString():Number(S).toFixed(M)}},{key:"toNumber",value:function(S){var M=this.props.precision,H=this.state.focused,V=S&&S.length>16&&H;return this.isNotCompleteNumber(S)||V?S:m(M)?Math.round(S*Math.pow(10,M))/Math.pow(10,M):Number(S)}},{key:"upStep",value:function(S,M){var H=this.props.step,V=this.getPrecisionFactor(S,M),Q=Math.abs(this.getMaxPrecision(S,M)),G=((V*S+V*H*M)/V).toFixed(Q);return this.toNumber(G)}},{key:"downStep",value:function(S,M){var H=this.props.step,V=this.getPrecisionFactor(S,M),Q=Math.abs(this.getMaxPrecision(S,M)),G=((V*S-V*H*M)/V).toFixed(Q);return this.toNumber(G)}},{key:"step",value:function(S,M){var H=this,V=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,Q=arguments.length>3?arguments[3]:void 0;this.stop(),M&&(M.persist(),M.preventDefault());var G=this.props;if(G.disabled)return;var W=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(W))return;var q=this["".concat(S,"Step")](W,V),oe=q>G.max||qG.max?q=G.max:q=ve),je=(Et||Et===0)&&(isNaN(Et)||Number(Et)<=De),ge=Re||V||Q,de=je||V||Q,pe=E()("".concat(H,"-handler"),"".concat(H,"-handler-up"),Object($.a)({},"".concat(H,"-handler-up-disabled"),ge)),ee=E()("".concat(H,"-handler"),"".concat(H,"-handler-down"),Object($.a)({},"".concat(H,"-handler-down-disabled"),de)),te=G?{onTouchStart:ge?h:this.up,onTouchEnd:this.stop}:{onMouseDown:ge?h:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},ie=G?{onTouchStart:de?h:this.down,onTouchEnd:this.stop}:{onMouseDown:de?h:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return O.a.createElement("div",{className:dt,style:Ee,title:_e,onMouseEnter:Te,onMouseLeave:Ce,onMouseOver:me,onMouseOut:ne,onFocus:function(){return null},onBlur:function(){return null}},O.a.createElement("div",{className:"".concat(H,"-handler-wrap")},O.a.createElement("span",Object.assign({unselectable:"on"},te,{role:"button","aria-label":"Increase Value","aria-disabled":ge,className:pe}),q||O.a.createElement("span",{unselectable:"on",className:"".concat(H,"-handler-up-inner"),onClick:o})),O.a.createElement("span",Object.assign({unselectable:"on"},ie,{role:"button","aria-label":"Decrease Value","aria-disabled":de,className:ee}),oe||O.a.createElement("span",{unselectable:"on",className:"".concat(H,"-handler-down-inner"),onClick:o}))),O.a.createElement("div",{className:"".concat(H,"-input-wrap")},O.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":De,"aria-valuemax":ve,"aria-valuenow":Et,required:Ae,type:Xe,placeholder:Ve,onPaste:pt,onClick:rt,onMouseUp:this.onMouseUp,className:"".concat(H,"-input"),tabIndex:$e,autoComplete:W,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:gt?this.onKeyDown:h,onKeyUp:gt?this.onKeyUp:h,autoFocus:Be,maxLength:He,readOnly:Q,disabled:V,max:ve,min:De,step:Ge,name:Pe,title:_e,id:Le,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(lt),pattern:ze,inputMode:Me,onInput:it},we))))}}]),b}(O.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:c,required:!1,autoComplete:"off"};var f=x,p=ht.a=f},kSUc:function(At,ht,re){},kqOp:function(At,ht,re){"use strict";re.d(ht,"a",function(){return D});var ae=re("0Owb"),$=re("fWQN"),R=re("mtLc"),X=re("yKVA"),N=re("879j"),I=re("q1tI"),z=re.n(I),B=re("Ot1p"),O="\u2581",D=function(E){Object(X.a)(k,E);var L=Object(N.a)(k);function k(){var T;Object($.a)(this,k);for(var A=arguments.length,C=new Array(A),h=0;h` "'(~:]+/,A=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,C=/^\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 c(G,W,q){return W.f=W.inline=q,q(G,W)}function d(G,W,q){return W.f=W.block=q,q(G,W)}function _(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==l){var W=N;if(!W){var q=ae.innerMode(X,G.htmlState);W=q.mode.name=="xml"&&q.state.tagStart===null&&!q.state.context&&q.state.tokenize.isInText}W&&(G.f=s,G.block=m,G.htmlState=null)}return G.trailingSpace=0,G.trailingSpaceNewLine=!1,G.prevLine=G.thisLine,G.thisLine={stream:null},null}function m(G,W){var q=G.column()===W.indentation,oe=_(W.prevLine.stream),fe=W.indentedCode,ve=W.prevLine.hr,De=W.list!==!1,Ee=(W.listStack[W.listStack.length-1]||0)+3;W.indentedCode=!1;var _e=W.indentation;if(W.indentationDiff===null&&(W.indentationDiff=W.indentation,De)){for(W.list=null;_e=4&&(fe||W.prevLine.fencedCodeEnd||W.prevLine.header||oe))return G.skipToEnd(),W.indentedCode=!0,z.code;if(G.eatSpace())return null;if(q&&W.indentation<=Ee&&(me=G.match(L))&&me[1].length<=6)return W.quote=0,W.header=me[1].length,W.thisLine.header=!0,R.highlightFormatting&&(W.formatting="header"),W.f=W.inline,f(W);if(W.indentation<=Ee&&G.eat(">"))return W.quote=q?1:W.quote+1,R.highlightFormatting&&(W.formatting="quote"),G.eatSpace(),f(W);if(!Ce&&!W.setext&&q&&W.indentation<=Ee&&(me=G.match(D))){var ne=me[1]?"ol":"ul";return W.indentation=_e+G.current().length,W.list=!0,W.quote=0,W.listStack.push(W.indentation),W.em=!1,W.strong=!1,W.code=!1,W.strikethrough=!1,R.taskLists&&G.match(E,!1)&&(W.taskList=!0),W.f=W.inline,R.highlightFormatting&&(W.formatting=["list","list-"+ne]),f(W)}else{if(q&&W.indentation<=Ee&&(me=G.match(A,!0)))return W.quote=0,W.fencedEndRE=new RegExp(me[1]+"+ *$"),W.localMode=R.fencedCodeBlockHighlighting&&I(me[2]||R.fencedCodeBlockDefaultMode),W.localMode&&(W.localState=ae.startState(W.localMode)),W.f=W.block=x,R.highlightFormatting&&(W.formatting="code-block"),W.code=-1,f(W);if(W.setext||(!Te||!De)&&!W.quote&&W.list===!1&&!W.code&&!Ce&&!C.test(G.string)&&(me=G.lookAhead(1))&&(me=me.match(k)))return W.setext?(W.header=W.setext,W.setext=0,G.skipToEnd(),R.highlightFormatting&&(W.formatting="header")):(W.header=me[0].charAt(0)=="="?1:2,W.setext=W.header),W.thisLine.header=!0,W.f=W.inline,f(W);if(Ce)return G.skipToEnd(),W.hr=!0,W.thisLine.hr=!0,z.hr;if(G.peek()==="[")return c(G,W,M)}return c(G,W,W.inline)}function l(G,W){var q=X.token(G,W.htmlState);if(!N){var oe=ae.innerMode(X,W.htmlState);(oe.mode.name=="xml"&&oe.state.tagStart===null&&!oe.state.context&&oe.state.tokenize.isInText||W.md_inside&&G.current().indexOf(">")>-1)&&(W.f=s,W.block=m,W.htmlState=null)}return q}function x(G,W){var q=W.listStack[W.listStack.length-1]||0,oe=W.indentation=G.quote?W.push(z.formatting+"-"+G.formatting[q]+"-"+G.quote):W.push("error"))}if(G.taskOpen)return W.push("meta"),W.length?W.join(" "):null;if(G.taskClosed)return W.push("property"),W.length?W.join(" "):null;if(G.linkHref?W.push(z.linkHref,"url"):(G.strong&&W.push(z.strong),G.em&&W.push(z.em),G.strikethrough&&W.push(z.strikethrough),G.emoji&&W.push(z.emoji),G.linkText&&W.push(z.linkText),G.code&&W.push(z.code),G.image&&W.push(z.image),G.imageAltText&&W.push(z.imageAltText,"link"),G.imageMarker&&W.push(z.imageMarker)),G.header&&W.push(z.header,z.header+"-"+G.header),G.quote&&(W.push(z.quote),!R.maxBlockquoteDepth||R.maxBlockquoteDepth>=G.quote?W.push(z.quote+"-"+G.quote):W.push(z.quote+"-"+R.maxBlockquoteDepth)),G.list!==!1){var oe=(G.listStack.length-1)%3;oe?oe===1?W.push(z.list2):W.push(z.list3):W.push(z.list1)}return G.trailingSpaceNewLine?W.push("trailing-space-new-line"):G.trailingSpace&&W.push("trailing-space-"+(G.trailingSpace%2?"a":"b")),W.length?W.join(" "):null}function p(G,W){return G.match(T,!0)?f(W):void 0}function s(G,W){var q=W.text(G,W);if(typeof q!="undefined")return q;if(W.list)return W.list=null,f(W);if(W.taskList){var oe=G.match(E,!0)[1]===" ";return oe?W.taskOpen=!0:W.taskClosed=!0,R.highlightFormatting&&(W.formatting="task"),W.taskList=!1,f(W)}if(W.taskOpen=!1,W.taskClosed=!1,W.header&&G.match(/^#+$/,!0))return R.highlightFormatting&&(W.formatting="header"),f(W);var fe=G.next();if(W.linkTitle){W.linkTitle=!1;var ve=fe;fe==="("&&(ve=")"),ve=(ve+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var De="^\\s*(?:[^"+ve+"\\\\]+|\\\\\\\\|\\\\.)"+ve;if(G.match(new RegExp(De),!0))return z.linkHref}if(fe==="`"){var Ee=W.formatting;R.highlightFormatting&&(W.formatting="code"),G.eatWhile("`");var _e=G.current().length;if(W.code==0&&(!W.quote||_e==1))return W.code=_e,f(W);if(_e==W.code){var Te=f(W);return W.code=0,Te}else return W.formatting=Ee,f(W)}else if(W.code)return f(W);if(fe==="\\"&&(G.next(),R.highlightFormatting)){var Ce=f(W),me=z.formatting+"-escape";return Ce?Ce+" "+me:me}if(fe==="!"&&G.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return W.imageMarker=!0,W.image=!0,R.highlightFormatting&&(W.formatting="image"),f(W);if(fe==="["&&W.imageMarker&&G.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return W.imageMarker=!1,W.imageAltText=!0,R.highlightFormatting&&(W.formatting="image"),f(W);if(fe==="]"&&W.imageAltText){R.highlightFormatting&&(W.formatting="image");var Ce=f(W);return W.imageAltText=!1,W.image=!1,W.inline=W.f=b,Ce}if(fe==="["&&!W.image)return W.linkText&&G.match(/^.*?\]/)||(W.linkText=!0,R.highlightFormatting&&(W.formatting="link")),f(W);if(fe==="]"&&W.linkText){R.highlightFormatting&&(W.formatting="link");var Ce=f(W);return W.linkText=!1,W.inline=W.f=G.match(/\(.*?\)| ?\[.*?\]/,!1)?b:s,Ce}if(fe==="<"&&G.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){W.f=W.inline=a,R.highlightFormatting&&(W.formatting="link");var Ce=f(W);return Ce?Ce+=" ":Ce="",Ce+z.linkInline}if(fe==="<"&&G.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){W.f=W.inline=a,R.highlightFormatting&&(W.formatting="link");var Ce=f(W);return Ce?Ce+=" ":Ce="",Ce+z.linkEmail}if(R.xml&&fe==="<"&&G.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var ne=G.string.indexOf(">",G.pos);if(ne!=-1){var Ae=G.string.substring(G.start,ne);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(Ae)&&(W.md_inside=!0)}return G.backUp(1),W.htmlState=ae.startState(X),d(G,W,l)}if(R.xml&&fe==="<"&&G.match(/^\/\w*?>/))return W.md_inside=!1,"tag";if(fe==="*"||fe==="_"){for(var rt=1,$e=G.pos==1?" ":G.string.charAt(G.pos-2);rt<3&&G.eat(fe);)rt++;var Xe=G.peek()||" ",Ve=!/\s/.test(Xe)&&(!h.test(Xe)||/\s/.test($e)||h.test($e)),Le=!/\s/.test($e)&&(!h.test($e)||/\s/.test(Xe)||h.test(Xe)),Me=null,ze=null;if(rt%2&&(!W.em&&Ve&&(fe==="*"||!Le||h.test($e))?Me=!0:W.em==fe&&Le&&(fe==="*"||!Ve||h.test(Xe))&&(Me=!1)),rt>1&&(!W.strong&&Ve&&(fe==="*"||!Le||h.test($e))?ze=!0:W.strong==fe&&Le&&(fe==="*"||!Ve||h.test(Xe))&&(ze=!1)),ze!=null||Me!=null){R.highlightFormatting&&(W.formatting=Me==null?"strong":ze==null?"em":"strong em"),Me===!0&&(W.em=fe),ze===!0&&(W.strong=fe);var Te=f(W);return Me===!1&&(W.em=!1),ze===!1&&(W.strong=!1),Te}}else if(fe===" "&&(G.eat("*")||G.eat("_"))){if(G.peek()===" ")return f(W);G.backUp(1)}if(R.strikethrough){if(fe==="~"&&G.eatWhile(fe)){if(W.strikethrough){R.highlightFormatting&&(W.formatting="strikethrough");var Te=f(W);return W.strikethrough=!1,Te}else if(G.match(/^[^\s]/,!1))return W.strikethrough=!0,R.highlightFormatting&&(W.formatting="strikethrough"),f(W)}else if(fe===" "&&G.match(/^~~/,!0)){if(G.peek()===" ")return f(W);G.backUp(2)}}if(R.emoji&&fe===":"&&G.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){W.emoji=!0,R.highlightFormatting&&(W.formatting="emoji");var Ge=f(W);return W.emoji=!1,Ge}return fe===" "&&(G.match(/^ +$/,!1)?W.trailingSpace++:W.trailingSpace&&(W.trailingSpaceNewLine=!0)),f(W)}function a(G,W){var q=G.next();if(q===">"){W.f=W.inline=s,R.highlightFormatting&&(W.formatting="link");var oe=f(W);return oe?oe+=" ":oe="",oe+z.linkInline}return G.match(/^[^>]+/,!0),z.linkInline}function b(G,W){if(G.eatSpace())return null;var q=G.next();return q==="("||q==="["?(W.f=W.inline=S(q==="("?")":"]"),R.highlightFormatting&&(W.formatting="link-string"),W.linkHref=!0,f(W)):"error"}var v={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function S(G){return function(W,q){var oe=W.next();if(oe===G){q.f=q.inline=s,R.highlightFormatting&&(q.formatting="link-string");var fe=f(q);return q.linkHref=!1,fe}return W.match(v[G]),q.linkHref=!0,f(q)}}function M(G,W){return G.match(/^([^\]\\]|\\.)*\]:/,!1)?(W.f=H,G.next(),R.highlightFormatting&&(W.formatting="link"),W.linkText=!0,f(W)):c(G,W,s)}function H(G,W){if(G.match(/^\]:/,!0)){W.f=W.inline=V,R.highlightFormatting&&(W.formatting="link");var q=f(W);return W.linkText=!1,q}return G.match(/^([^\]\\]|\\.)+/,!0),z.linkText}function V(G,W){return G.eatSpace()?null:(G.match(/^[^\s]+/,!0),G.peek()===void 0?W.linkTitle=!0:G.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),W.f=W.inline=s,z.linkHref+" url")}var Q={startState:function(){return{f:m,prevLine:{stream:null},thisLine:{stream:null},block:m,htmlState:null,indentation:0,inline:s,text:p,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(G){return{f:G.f,prevLine:G.prevLine,thisLine:G.thisLine,block:G.block,htmlState:G.htmlState&&ae.copyState(X,G.htmlState),indentation:G.indentation,localMode:G.localMode,localState:G.localMode?ae.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,W){if(W.formatting=!1,G!=W.thisLine.stream){if(W.header=0,W.hr=!1,G.match(/^\s*$/,!0))return y(W),null;if(W.prevLine=W.thisLine,W.thisLine={stream:G},W.taskList=!1,W.trailingSpace=0,W.trailingSpaceNewLine=!1,!W.localState&&(W.f=W.block,W.f!=l)){var q=G.match(/^\s*/,!0)[0].replace(/\t/g,o).length;if(W.indentation=q,W.indentationDiff=null,q>0)return null}}return W.f(G,W)},innerMode:function(G){return G.block==l?{state:G.htmlState,mode:X}:G.localState?{state:G.localState,mode:G.localMode}:{state:G,mode:Q}},indent:function(G,W,q){return G.block==l&&X.indent?X.indent(G.htmlState,W,q):G.localState&&G.localMode.indent?G.localMode.indent(G.localState,W,q):ae.Pass},blankLine:y,getType:f,blockCommentStart:"",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return Q},"xml"),ae.defineMIME("text/markdown","markdown"),ae.defineMIME("text/x-markdown","markdown")})},osHv:function(At,ht,re){(function(ae){ae(re("VrN/"))})(function(ae){"use strict";var $=ae.Pos;function R(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,c,d){this.line=o,this.ch=c,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 B(h,o){var c=h.cm.getTokenTypeAt($(h.line,o));return c&&/\btag\b/.test(c)}function O(h){return h.line>=h.max?void 0:(h.ch=0,h.text=h.cm.getLine(++h.line),!0)}function D(h){return h.line<=h.min?void 0:(h.text=h.cm.getLine(--h.line),h.ch=h.text.length,!0)}function E(h){for(;;){var o=h.text.indexOf(">",h.ch);if(o==-1){if(O(h))continue;return}if(!B(h,o+1)){h.ch=o+1;continue}var c=h.text.lastIndexOf("/",o),d=c>-1&&!/\S/.test(h.text.slice(c+1,o));return h.ch=o+1,d?"selfClose":"regular"}}function L(h){for(;;){var o=h.ch?h.text.lastIndexOf("<",h.ch-1):-1;if(o==-1){if(D(h))continue;return}if(!B(h,o+1)){h.ch=o;continue}I.lastIndex=o,h.ch=o;var c=I.exec(h.text);if(c&&c.index==o)return c}}function k(h){for(;;){I.lastIndex=h.ch;var o=I.exec(h.text);if(!o){if(O(h))continue;return}if(!B(h,o.index+1)){h.ch=o.index+1;continue}return h.ch=o.index+o[0].length,o}}function T(h){for(;;){var o=h.ch?h.text.lastIndexOf(">",h.ch-1):-1;if(o==-1){if(D(h))continue;return}if(!B(h,o+1)){h.ch=o;continue}var c=h.text.lastIndexOf("/",o),d=c>-1&&!/\S/.test(h.text.slice(c+1,o));return h.ch=o+1,d?"selfClose":"regular"}}function A(h,o){for(var c=[];;){var d=k(h),_,y=h.line,m=h.ch-(d?d[0].length:0);if(!d||!(_=E(h)))return;if(_=="selfClose")continue;if(d[1]){for(var l=c.length-1;l>=0;--l)if(c[l]==d[2]){c.length=l;break}if(l<0&&(!o||o==d[2]))return{tag:d[2],from:$(y,m),to:$(h.line,h.ch)}}else c.push(d[2])}}function C(h,o){for(var c=[];;){var d=T(h);if(!d)return;if(d=="selfClose"){L(h);continue}var _=h.line,y=h.ch,m=L(h);if(!m)return;if(m[1])c.push(m[2]);else{for(var l=c.length-1;l>=0;--l)if(c[l]==m[2]){c.length=l;break}if(l<0&&(!o||o==m[2]))return{tag:m[2],from:$(h.line,h.ch),to:$(_,y)}}}}ae.registerHelper("fold","xml",function(h,o){for(var c=new z(h,o.line,0);;){var d=k(c);if(!d||c.line!=o.line)return;var _=E(c);if(!_)return;if(!d[1]&&_!="selfClose"){var y=$(c.line,c.ch),m=A(c,d[2]);return m&&R(m.from,y)>0?{from:y,to:m.from}:null}}}),ae.findMatchingTag=function(h,o,c){var d=new z(h,o.line,o.ch,c);if(d.text.indexOf(">")==-1&&d.text.indexOf("<")==-1)return;var _=E(d),y=_&&$(d.line,d.ch),m=_&&L(d);if(!_||!m||R(d,o)>0)return;var l={from:$(d.line,d.ch),to:y,tag:m[2]};return _=="selfClose"?{open:l,close:null,at:"open"}:m[1]?{open:C(d,m[2]),close:l,at:"close"}:(d=new z(h,y.line,y.ch,c),{open:l,close:A(d,m[2]),at:"open"})},ae.findEnclosingTag=function(h,o,c,d){for(var _=new z(h,o.line,o.ch,c);;){var y=C(_,d);if(!y)break;var m=new z(h,o.line,o.ch,c),l=A(m,y.tag);if(l)return{open:y,close:l}}},ae.scanForClosingTag=function(h,o,c,d){var _=new z(h,o.line,o.ch,d?{from:0,to:d}:null);return A(_,c)}})},p5ED:function(At,ht,re){"use strict";var ae=re("+L6B"),$=re("2/Rp"),R=re("5Dmo"),X=re("3S7+"),N=re("k1fw"),I=re("tJVT"),z=re("q1tI"),B=re.n(z),O=re("vHTk"),D=re.n(O),E=re("yEEn"),L=re("ZW9T"),k=re("1vsH");ht.a=function(T){var A=T.name,C=T.data,h=T.theme,o=T.type,c=T.filename,d=T.monacoEditor,_=T.className,y=T.style,m=T.close,l=T.onClose,x=T.hasMask,f=Object(z.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),p=Object(I.a)(f,2),s=p[0],a=p[1],b=Object(z.useState)(""),v=Object(I.a)(b,2),S=v[0],M=v[1],H,V=1024*1024,Q=10*V,G=Object(z.useRef)();o==="office"&&(H=Object(k.T)(C).filesize,H>Q&&(o="other")),c&&(d.filename=c),Object(z.useEffect)(function(){var oe,fe,ve=(oe=document.cookie)===null||oe===void 0||((fe=oe.replace(/\s/g,""))===null||fe===void 0)?void 0:fe.split(";");ve==null||ve.map(function(De){var Ee=De.split("=");Ee[0]==="_educoder_session"&&M(Ee[1])})},[]);var W=function(){if(C.startsWith("http")||C.startsWith("/")){q();return}Object(k.z)(c||"educoder",C,c)},q=function(){Object(k.x)(c||A,C)};return console.log("data:",C,"fileanme:",c," name:",A),B.a.createElement("div",{style:Object(N.a)({},y||{}),className:"".concat(x&&D.a.bgBlack," ").concat(o?D.a.wrp:"hide")},m&&B.a.createElement("div",{className:D.a.close,ref:G},B.a.createElement(X.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return G.current}},B.a.createElement("span",{onClick:q},B.a.createElement("i",{className:"icon-quxiaozhiding"}))),B.a.createElement(X.a,{title:"\u5173\u95ED",getPopupContainer:function(){return G.current}},B.a.createElement("span",{className:"",onClick:l},B.a.createElement("i",{className:"icon-guanbi1"})))),B.a.createElement("div",{className:"".concat(D.a[_]," ").concat(_," ").concat(D.a.monaco," ").concat(o==="txt"?"show":"hide")},o==="txt"&&B.a.createElement(L.b,d)),o==="audio"&&B.a.createElement("audio",{src:"".concat(C!=null&&C.startsWith("/")||(C==null?void 0:C.indexOf("https://"))>-1?C:"data:audio/mp3;base64,").concat(C),autoPlay:!0}),o==="video"&&B.a.createElement(B.a.Fragment,null,C!=null&&C.startsWith("/")?B.a.createElement("video",{controls:!0,src:"".concat(C),autoPlay:!0}):B.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(C),autoPlay:!0})),o==="html"&&B.a.createElement("iframe",{src:C+"&disposition=inline"}),o==="pdf"&&B.a.createElement("embed",{className:D.a.embed,src:C}),o==="image"&&B.a.createElement(B.a.Fragment,null,B.a.createElement("img",{src:"".concat(C!=null&&C.startsWith("/")||(C==null?void 0:C.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(C)})),o==="other"&&B.a.createElement("div",null,B.a.createElement($.a,{type:"primary",size:"large",onClick:W},B.a.createElement(E.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),(o==="download"||o==="office")&&B.a.createElement($.a,{type:"primary",size:"large",onClick:W},B.a.createElement(E.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(At,ht,re){},rUJ1:function(At,ht){const re=/[&<>"']/,ae=/[&<>"']/g,$=/[<>"']|&(?!#?\w+;)/,R=/[<>"']|&(?!#?\w+;)/g,X={"&":"&","<":"<",">":">",'"':""","'":"'"},N=x=>X[x];function I(x,f){if(f){if(re.test(x))return x.replace(ae,N)}else if($.test(x))return x.replace(R,N);return x}const z=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function B(x){return x.replace(z,(f,p)=>(p=p.toLowerCase(),p==="colon"?":":p.charAt(0)==="#"?p.charAt(1)==="x"?String.fromCharCode(parseInt(p.substring(2),16)):String.fromCharCode(+p.substring(1)):""))}const O=/(^|[^\[])\^/g;function D(x,f){x=x.source||x,f=f||"";const p={replace:(s,a)=>(a=a.source||a,a=a.replace(O,"$1"),x=x.replace(s,a),p),getRegex:()=>new RegExp(x,f)};return p}const E=/[^\w:]/g,L=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function k(x,f,p){if(x){let s;try{s=decodeURIComponent(B(p)).replace(E,"").toLowerCase()}catch(a){return null}if(s.indexOf("javascript:")===0||s.indexOf("vbscript:")===0||s.indexOf("data:")===0)return null}f&&!L.test(p)&&(p=o(f,p));try{p=encodeURI(p).replace(/%25/g,"%")}catch(s){return null}return p}const T={},A=/^[^:]+:\/*[^/]*$/,C=/^([^:]+:)[\s\S]*$/,h=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(x,f){T[" "+x]||(A.test(x)?T[" "+x]=x+"/":T[" "+x]=y(x,"/",!0)),x=T[" "+x];const p=x.indexOf(":")===-1;return f.substring(0,2)==="//"?p?f:x.replace(C,"$1")+f:f.charAt(0)==="/"?p?f:x.replace(h,"$1")+f:x+f}const c={exec:function(){}};function d(x){let f=1,p,s;for(;f{let M=!1,H=v;for(;--H>=0&&S[H]==="\\";)M=!M;return M?"|":" |"}),s=p.split(/ \|/);let a=0;if(s.length>f)s.splice(f);else for(;s.length0&&He[0]!==void 0?He[0]:0,console.log(Ce),Pe.next=4,Object(A.a)("/api/exercises/".concat(Ce.categoryId,"/preview_random_exercise.json"),{method:"get",params:{num:ze}});case 4:Ge=Pe.sent,W(!1),Te(Ae(Ge));case 7:case"end":return Pe.stop()}},Me)}));return function(){return Le.apply(this,arguments)}}(),Ae=function(Me){var ze={1:"\u4E00",2:"\u4E8C",3:"\u4E09",4:"\u56DB",5:"\u4E94",6:"\u516D",7:"\u4E03"};if(!Me)return;var Ge=Me||{},He=Ge.exam,Be=Ge.single_questions,Pe=Ge.multiple_questions,pt=Ge.judgement_questions,it=Ge.program_questions,et=Ge.completion_questions,at=Ge.subjective_questions,Et=Ge.practical_questions,ct=Ge.combination_questions,dt=[Object(R.a)({type:"SINGLE",name:"\u5355\u9009\u9898"},Be),Object(R.a)({type:"MULTIPLE",name:"\u591A\u9009\u9898"},Pe),Object(R.a)({type:"COMPLETION",name:"\u586B\u7A7A\u9898"},et),Object(R.a)({type:"JUDGMENT",name:"\u5224\u65AD\u9898"},pt),Object(R.a)({type:"SUBJECTIVE",name:"\u7B80\u7B54\u9898"},at),Object(R.a)({type:"PROGRAM",name:"\u7F16\u7A0B\u9898"},it),Object(R.a)({type:"PRACTICAL",name:"\u5B9E\u8BAD\u9898"},Et),Object(R.a)({type:"COMBINATION",name:"\u7EC4\u5408\u9898"},ct)],we=[],gt=0,lt=0,Re=dt.filter(function(je){return je.questions_count>0}).map(function(je,ge){var de;return(de=je.questions)===null||de===void 0||de.forEach(function(pe){we.push(pe.id),gt=gt+pe.score,lt=lt+1}),Object(R.a)(Object(R.a)({},je),{number:ze[ge+1]})});return{all_questions_count:lt,all_score:gt,questionList:Re,ids:we,exam:He}},rt=function(){E.d.push("/classrooms/".concat(Ce.coursesId,"/exercise"))},$e=function(){alert("\u4FDD\u5B58")},Xe=function(){var Le=Object(X.a)(z.a.mark(function Me(ze,Ge){var He,Be,Pe;return z.a.wrap(function(it){for(;;)switch(it.prev=it.next){case 0:return it.next=2,Object(A.a)("/api/exercises/".concat(Ce.categoryId,"/toggle_random_question.json"),{method:"post",body:{question_id:ze==null?void 0:ze.single_question_id}});case 2:He=it.sent,He!=null&&He.question&&(Pe=Object(C.cloneDeep)(_e),Pe.questionList=Pe==null||((Be=Pe.questionList)===null||Be===void 0)?void 0:Be.map(function(et){if(et.type===Ge.type){var at=Object(C.cloneDeep)(et==null?void 0:et.questions);return at.splice(Ge.index,1,He==null?void 0:He.question),Object(R.a)(Object(R.a)({},et),{},{questions:at})}return et}),Te(Pe));case 4:case"end":return it.stop()}},Me)}));return function(ze,Ge){return Le.apply(this,arguments)}}(),Ve=function(){var Le=Object(X.a)(z.a.mark(function Me(ze){return z.a.wrap(function(He){for(;;)switch(He.prev=He.next){case 0:document.body.scrollIntoView(),ne(ze),ve(ze);case 3:case"end":return He.stop()}},Me)}));return function(ze){return Le.apply(this,arguments)}}();return console.log(Object(D.h)(),"location333"),O.a.createElement("section",{className:k.a.wrap},O.a.createElement($.a,{loading:G,active:!0,paragraph:{rows:5}},((y=Object(D.h)())===null||y===void 0||((m=y.pathname)===null||m===void 0)?void 0:m.includes("preview"))&&O.a.createElement("div",{className:k.a.crumbs},O.a.createElement("b",null),O.a.createElement("span",{className:"current",onClick:function(){return E.d.push("/classrooms/".concat(Ce.coursesId,"/exercise"))}},"".concat(me==null||((l=me.course)===null||l===void 0)?void 0:l.course_name,">")),O.a.createElement("span",{className:"current",onClick:function(){return E.d.push("/classrooms/".concat(Ce.coursesId,"/exercise"))}},"\u8BD5\u5377\u5217\u8868>"),O.a.createElement("span",{style:{color:"#bebebe"}},"\u9884\u89C8")),O.a.createElement(T.a,{loading:M,submit:$e,goBack:rt,data:_e,selectValue:fe,editPreview:!0,onExchange:Xe,onSkipExamination:Ve})))};ht.default=Object(E.a)(function(c){var d=c.paperlibrary,_=c.user,y=c.globalSetting;return{paperlibrary:d,user:_,globalSetting:y}})(o)},sbIO:function(At,ht,re){"use strict";var ae=re("DjyN"),$=re("NUBc"),R=re("5Dmo"),X=re("3S7+"),N=re("/zsF"),I=re("PArb"),z=re("Q9mQ"),B=re("diRs"),O=re("+L6B"),D=re("2/Rp"),E=re("5NDa"),L=re("5rEg"),k=re("miYZ"),T=re("tsqr"),A=re("9og8"),C=re("giR+"),h=re("fyUT"),o=re("2qtc"),c=re("kLXV"),d=re("tJVT"),_=re("WmNS"),y=re.n(_),m=re("q1tI"),l=re.n(m),x=re("PsQE"),f=re.n(x),p=re("0eGx"),s=re.n(p),a=re("9Bee"),b=re("Ty5D"),v=re("9kvl"),S=re("ErOA"),M=re("+yhJ"),H=re.n(M),V=re("RZ/O"),Q=re.n(V),G=re("LvDl"),W=re("6K3P"),q=re.n(W),oe=re("sRBo"),fe=re("kaz8"),ve=re("oBTY"),De=re("PpiC"),Ee=re("Ot1p"),_e=re("kqOp"),Te=re("7qnI"),Ce=re("1vsH"),me=re("PGNT"),ne=re.n(me),Ae=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],rt=function(ie,se){var ue=ie.globalSetting,Se=ie.loading,ke=ie.dispatch,Je=ie.isEdit,Qe=ie.editData,bt=Object(De.a)(ie,["globalSetting","loading","dispatch","isEdit","editData"]),Dt=Object(m.useState)(""),Ze=Object(d.a)(Dt,2),ut=Ze[0],Ft=Ze[1],Ct=Object(m.useState)(""),jt=Object(d.a)(Ct,2),$t=jt[0],Lt=jt[1],Qt=Object(m.useState)([]),Zt=Object(d.a)(Qt,2),ft=Zt[0],Xt=Zt[1],zt=Object(m.useState)(""),Gt=Object(d.a)(zt,2),Ut=Gt[0],Mt=Gt[1],St=Object(m.useState)(),tt=Object(d.a)(St,2),Fe=tt[0],nr=tt[1],Vt=Object(m.useState)(!1),qt=Object(d.a)(Vt,2),Wt=qt[0],Tr=qt[1];Object(m.useEffect)(function(){if(!Qe||!Je)return;Ft(Qe==null?void 0:Qe.name),Lt(Qe==null?void 0:Qe.analysis),nr(Qe==null?void 0:Qe.is_ordered),Tr(!0)},[Qe]),Object(m.useEffect)(function(){if(!Wt)return;var xr=Qe==null?void 0:Qe.standard_answer.map(function(U){return U.answer_text});Xt(xr),Tr(!1)},[Wt]),Object(m.useImperativeHandle)(se,function(){return{onSave:ir,Clear:Rt}});var ir=function(){var U=[],u=!1;return ut?(ft.forEach(function(g,P){U.push({position:P+1,answer_text:[]}),g.forEach(function(J,j){U[P].answer_text.push(J),(!J||!Object(Ce.db)(J,1e4))&&(Mt("".concat(P,"-").concat(j)),T.b.info(J?"\u7B54\u6848\u4E0D\u80FD\u8D85\u8FC710000\u5B57\u7B26":"\u7B54\u6848\uFF1A\u4E0D\u80FD\u4E3A\u7A7A"),u=!0)})}),u?!1:(U==null?void 0:U.length)>20?(T.b.warn("\u586B\u7A7A\u9898\u6807\u51C6\u7B54\u6848\u4E0D\u80FD\u4E3A\u7A7A/\u4E0D\u80FD\u8D85\u8FC720\u4E2A\uFF01"),!1):{name:ut,analysis:$t,standard_answers:U,is_ordered:Fe}):(T.b.info("\u8BF7\u60A8\u8F93\u5165\u9898\u5E72"),!1)},Rt=function(){Ft(""),Lt(""),Xt([]),nr(!1)},Ie=function(U,u,g){var P=ft.slice();if(u&&P.splice(U,u),g)for(var J=0;J1&&l.a.createElement("span",null,l.a.createElement(fe.a,{checked:Fe,onChange:function(U){return nr(U.target.checked)},className:"".concat(ne.a.color333," font14")},"\u591A\u4E2A\u586B\u7A7A\u7684\u7B54\u6848\u6709\u987A\u5E8F\u8981\u6C42"),l.a.createElement("span",{className:"".concat(ne.a.color999," font12")},"\uFF08\u9009\u4E2D\uFF0C\u6BCF\u4E2A\u586B\u7A7A\u7684\u7B54\u6848\u987A\u5E8F\u5FC5\u987B\u4E0E\u53C2\u8003\u7B54\u6848\u4E00\u81F4\uFF09"))),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.title},"\u9898\u76EE\u89E3\u6790\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-answer",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790",defaultValue:$t,onChange:function(U){return Lt(U)}}))},$e=Object(v.a)(function(te){var ie=te.loading,se=te.globalSetting;return{globalSetting:se,loading:ie.effects}},null,null,{forwardRef:!0})(Object(m.forwardRef)(rt)),Xe=re("7Kak"),Ve=re("9yH6"),Le=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],Me=function(ie,se){var ue=ie.globalSetting,Se=ie.loading,ke=ie.editData,Je=ie.dispatch,Qe=ie.onRef,bt=Qe===void 0?function(){}:Qe,Dt=ie.isEdit,Ze=Object(De.a)(ie,["globalSetting","loading","editData","dispatch","onRef","isEdit"]),ut=Object(m.useState)(),Ft=Object(d.a)(ut,2),Ct=Ft[0],jt=Ft[1],$t=Object(m.useState)(""),Lt=Object(d.a)($t,2),Qt=Lt[0],Zt=Lt[1],ft=Object(m.useState)(""),Xt=Object(d.a)(ft,2),zt=Xt[0],Gt=Xt[1];Object(m.useEffect)(function(){if(!ke||!Dt)return;Zt(ke==null?void 0:ke.name),Gt(ke==null?void 0:ke.analysis);var St=ke==null?void 0:ke.choices.find(function(tt){return tt.is_answer});jt(St.choice_text==="\u6B63\u786E"?"0":"1")},[ke]),Object(m.useImperativeHandle)(se,function(){return{onSave:Ut,Clear:Mt}});var Ut=function(){if(!Qt)return T.b.info("\u8BF7\u60A8\u8F93\u5165\u9898\u5E72"),!1;if(!Ct)return T.b.info("\u8BF7\u5148\u70B9\u51FB\u9009\u62E9\u672C\u9009\u62E9\u9898\u7684\u6B63\u786E\u9009\u9879"),!1;var tt=[{choice_text:"\u6B63\u786E",is_answer:Ct==="0"?1:0},{choice_text:"\u9519\u8BEF",is_answer:Ct==="1"?1:0}];return{name:Qt,choices:tt,analysis:zt}},Mt=function(){Zt(""),Gt(""),jt("")};return l.a.createElement("section",{className:ne.a.wrap},l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u9898\u5E72\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-title",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u5E72",defaultValue:Qt,onChange:function(tt){return Zt(tt)}}),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u7B54\u6848\u9009\u9879\uFF1A",l.a.createElement("span",{className:ne.a.colorGray},"\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848"))),l.a.createElement(Ve.a.Group,{buttonStyle:"solid",value:Ct,onChange:function(tt){return jt(tt.target.value)}},l.a.createElement(Ve.a.Button,{value:"0",className:"".concat(ne.a.radio," mr40")},"\u6B63\u786E"),l.a.createElement(Ve.a.Button,{value:"1",className:ne.a.radio},"\u9519\u8BEF")),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.title},"\u9898\u76EE\u89E3\u6790\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-answer",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790",defaultValue:zt,onChange:function(tt){return Gt(tt)}}))},ze=Object(v.a)(function(te){var ie=te.loading,se=te.globalSetting;return{globalSetting:se,loading:ie.effects}},null,null,{forwardRef:!0})(Object(m.forwardRef)(Me)),Ge=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],He=function(ie,se){var ue=ie.editData,Se=ie.globalSetting,ke=ie.loading,Je=ie.dispatch,Qe=ie.onRef,bt=Qe===void 0?function(){}:Qe,Dt=ie.isEdit,Ze=Object(De.a)(ie,["editData","globalSetting","loading","dispatch","onRef","isEdit"]),ut=Object(m.useState)([]),Ft=Object(d.a)(ut,2),Ct=Ft[0],jt=Ft[1],$t=Object(m.useState)(),Lt=Object(d.a)($t,2),Qt=Lt[0],Zt=Lt[1],ft=Object(m.useState)([]),Xt=Object(d.a)(ft,2),zt=Xt[0],Gt=Xt[1],Ut=Object(m.useState)(""),Mt=Object(d.a)(Ut,2),St=Mt[0],tt=Mt[1],Fe=Object(m.useState)(""),nr=Object(d.a)(Fe,2),Vt=nr[0],qt=nr[1];Object(m.useEffect)(function(){jt(["","","",""])},[]),Object(m.useEffect)(function(){if(!ue||!Dt)return;tt(ue==null?void 0:ue.name),qt(ue==null?void 0:ue.analysis),jt(ue==null?void 0:ue.choices.map(function(Rt){return Rt.choice_text}));var ir=[];ue==null||ue.choices.map(function(Rt,Ie){Rt.is_answer&&ir.push(Ie)}),Gt(ir)},[ue]),Object(m.useImperativeHandle)(se,function(){return{onSave:Wt,Clear:Tr}});var Wt=function(){if(!St)return T.b.info("\u8BF7\u60A8\u8F93\u5165\u9898\u5E72"),!1;var Rt=Ct.findIndex(function(xt){return!xt});if(Rt>-1)return T.b.info("\u8BF7\u5148\u8F93\u5165 ".concat(Ge[Rt]," \u9009\u9879\u7684\u5185\u5BB9")),!1;if(!zt.length)return T.b.info("\u8BF7\u8BBE\u7F6E\u672C\u9898\u7684\u6B63\u786E\u7B54\u6848\uFF0C\u70B9\u51FB\u9009\u9879A/B...\u5373\u53EF\u5B8C\u6210\u8BBE\u7F6E"),!1;if(zt.length<2)return T.b.info("\u591A\u9009\u9898\u6700\u5C0F\u6B63\u786E\u9009\u9879\u4E3A2\u4E2A"),!1;var Ie=Ct.map(function(xt,Dr){return{choice_text:xt,is_answer:zt.includes(Dr)?1:0}});return{name:St,choices:Ie,analysis:Vt}},Tr=function(){jt(["","","",""]),tt(""),qt(""),Gt("")};return l.a.createElement("section",{className:ne.a.wrap},l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u9898\u5E72\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-title",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u5E72",defaultValue:St,onChange:function(Rt){return tt(Rt)}}),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u7B54\u6848\u9009\u9879\uFF1A",l.a.createElement("span",{className:ne.a.colorGray},"\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848"))),Ct.map(function(ir,Rt){return l.a.createElement("div",{className:ne.a.choiceWrap,key:Rt},l.a.createElement(X.a,{title:"\u70B9\u51FB\u8BBE\u7F6E\u4E3A\u6807\u51C6\u7B54\u6848",placement:"left"},l.a.createElement("div",{className:"".concat(ne.a.answer," ").concat(zt.includes(Rt)?ne.a.activeAnswer:""),onClick:function(){zt.includes(Rt)?Gt(zt.filter(function(xt){return xt!==Rt})):Gt([].concat(Object(ve.a)(zt),[Rt]))}},Ge[Rt])),l.a.createElement("div",{className:ne.a.editorWrap},Qt===Rt?l.a.createElement(Ee.a,{id:"single-question-option-".concat(Rt),watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9009\u9879",defaultValue:ir,onChange:function(xt){Ct[Rt]=xt,jt(Ct)}}):l.a.createElement("div",{className:ne.a.htmlWrap,onClick:function(){return Zt(Rt)}},l.a.createElement(a.a,{value:ir}))),Rt>1&&l.a.createElement(X.a,{title:"\u5220\u9664"},l.a.createElement("i",{className:"".concat(ne.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){jt(Ct.filter(function(xt,Dr){return Dr!==Rt})),zt.includes(Rt)?Gt(zt.filter(function(xt){return xt!==Rt})):Gt([].concat(Object(ve.a)(zt),[Rt]))}})),Rt<7&&Rt===Ct.length-1&&l.a.createElement(X.a,{title:"\u65B0\u589E\u53C2\u8003\u7B54\u6848"},l.a.createElement("i",{className:"".concat(ne.a.addIcon," iconfont icon-roundaddfill ml6"),onClick:function(){return jt([].concat(Object(ve.a)(Ct),[""]))}})))}),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.title},"\u9898\u76EE\u89E3\u6790\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-answer",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790",defaultValue:Vt,onChange:function(Rt){return qt(Rt)}}))},Be=Object(v.a)(function(te){var ie=te.loading,se=te.globalSetting;return{globalSetting:se,loading:ie.effects}},null,null,{forwardRef:!0})(Object(m.forwardRef)(He)),Pe=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],pt=function(ie,se){var ue=ie.editData,Se=ie.globalSetting,ke=ie.loading,Je=ie.dispatch,Qe=ie.onRef,bt=Qe===void 0?function(){}:Qe,Dt=ie.isEdit,Ze=Object(De.a)(ie,["editData","globalSetting","loading","dispatch","onRef","isEdit"]),ut=Object(m.useState)([]),Ft=Object(d.a)(ut,2),Ct=Ft[0],jt=Ft[1],$t=Object(m.useState)(),Lt=Object(d.a)($t,2),Qt=Lt[0],Zt=Lt[1],ft=Object(m.useState)(),Xt=Object(d.a)(ft,2),zt=Xt[0],Gt=Xt[1],Ut=Object(m.useState)(""),Mt=Object(d.a)(Ut,2),St=Mt[0],tt=Mt[1],Fe=Object(m.useState)(""),nr=Object(d.a)(Fe,2),Vt=nr[0],qt=nr[1];Object(m.useEffect)(function(){jt(["","","",""])},[]),Object(m.useEffect)(function(){if(!ue||!Dt)return;tt(ue==null?void 0:ue.name),qt(ue==null?void 0:ue.analysis),jt(ue==null?void 0:ue.choices.map(function(ir){return ir.choice_text})),Gt(ue==null?void 0:ue.choices.findIndex(function(ir){return ir.is_answer}))},[ue]),Object(m.useImperativeHandle)(se,function(){return{onSave:Wt,Clear:Tr}});var Wt=function(){if(!St)return T.b.info("\u8BF7\u60A8\u8F93\u5165\u9898\u5E72"),!1;var Rt=Ct.findIndex(function(xt){return!xt});if(Rt>-1)return T.b.info("\u8BF7\u5148\u8F93\u5165 ".concat(Pe[Rt]," \u9009\u9879\u7684\u5185\u5BB9")),!1;if(console.log("activeAnswer: ",zt),!(typeof zt=="number"))return T.b.info("\u8BF7\u8BBE\u7F6E\u672C\u9898\u7684\u6B63\u786E\u7B54\u6848\uFF0C\u70B9\u51FB\u9009\u9879A/B...\u5373\u53EF\u5B8C\u6210\u8BBE\u7F6E"),!1;var Ie=Ct.map(function(xt,Dr){return{choice_text:xt,is_answer:zt===Dr?1:0}});return{name:St,choices:Ie,analysis:Vt}},Tr=function(){jt(["","","",""]),tt(""),qt(""),Gt("")};return l.a.createElement("section",{className:ne.a.wrap},l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u9898\u5E72\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-title",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u5E72",defaultValue:St,onChange:function(Rt){return tt(Rt)}}),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u7B54\u6848\u9009\u9879\uFF1A",l.a.createElement("span",{className:ne.a.colorGray},"\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848"))),Ct.map(function(ir,Rt){return l.a.createElement("div",{className:ne.a.choiceWrap,key:Rt},l.a.createElement(X.a,{title:"\u70B9\u51FB\u8BBE\u7F6E\u4E3A\u6807\u51C6\u7B54\u6848",placement:"left"},l.a.createElement("div",{className:"".concat(ne.a.answer," ").concat(zt===Rt?ne.a.activeAnswer:""),onClick:function(){return Gt(Rt)}},Pe[Rt])),l.a.createElement("div",{className:ne.a.editorWrap},Qt===Rt?l.a.createElement(Ee.a,{id:"single-question-option-".concat(Rt),watch:!0,height:155,isFocus:!0,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9009\u9879",defaultValue:ir,onChange:function(xt){Ct[Rt]=xt,jt(Ct)}}):l.a.createElement("div",{className:ne.a.htmlWrap,onClick:function(){return Zt(Rt)}},l.a.createElement(a.a,{value:ir}))),Rt>1&&l.a.createElement(X.a,{title:"\u5220\u9664"},l.a.createElement("i",{className:"".concat(ne.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){jt(Ct.filter(function(xt,Dr){return Dr!==Rt})),Rt===zt&&Gt(null)}})),Rt<7&&Rt===Ct.length-1&&l.a.createElement(X.a,{title:"\u65B0\u589E\u53C2\u8003\u7B54\u6848"},l.a.createElement("i",{className:"".concat(ne.a.addIcon," iconfont icon-roundaddfill ml6"),onClick:function(){return jt([].concat(Object(ve.a)(Ct),[""]))}})))}),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.title},"\u9898\u76EE\u89E3\u6790\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-answer",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790",defaultValue:Vt,onChange:function(Rt){return qt(Rt)}}))},it=Object(v.a)(function(te){var ie=te.loading,se=te.globalSetting;return{globalSetting:se,loading:ie.effects}},null,null,{forwardRef:!0})(Object(m.forwardRef)(pt)),et=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],at=function(ie,se){var ue=ie.editData,Se=ie.globalSetting,ke=ie.loading,Je=ie.dispatch,Qe=ie.onRef,bt=Qe===void 0?function(){}:Qe,Dt=ie.isEdit,Ze=Object(De.a)(ie,["editData","globalSetting","loading","dispatch","onRef","isEdit"]),ut=Object(m.useState)(""),Ft=Object(d.a)(ut,2),Ct=Ft[0],jt=Ft[1],$t=Object(m.useState)(""),Lt=Object(d.a)($t,2),Qt=Lt[0],Zt=Lt[1],ft=Object(m.useState)(""),Xt=Object(d.a)(ft,2),zt=Xt[0],Gt=Xt[1];Object(m.useEffect)(function(){var St;if(!ue||!Dt)return;jt(ue==null?void 0:ue.name),Zt(ue==null?void 0:ue.analysis),Gt(ue==null||((St=ue.answer_texts)===null||St===void 0)?void 0:St[0])},[ue]),Object(m.useImperativeHandle)(se,function(){return{onSave:Ut,Clear:Mt}});var Ut=function(){return Ct?zt?{name:Ct,answer_texts:[zt],analysis:Qt}:(T.b.info("\u8BF7\u60A8\u8F93\u5165\u53C2\u8003\u7B54\u6848"),!1):(T.b.info("\u8BF7\u60A8\u8F93\u5165\u9898\u5E72"),!1)},Mt=function(){jt(""),Zt(""),Gt("")};return l.a.createElement("section",{className:ne.a.wrap},l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u9898\u5E72\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-title",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u5E72",defaultValue:Ct,onChange:function(tt){return jt(tt)}}),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.title},"\u53C2\u8003\u7B54\u6848\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-reference-answer",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u53C2\u8003\u7B54\u6848",defaultValue:zt,onChange:function(tt){return Gt(tt)}}),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.title},"\u9898\u76EE\u89E3\u6790\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-answer",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790",defaultValue:Qt,onChange:function(tt){return Zt(tt)}}))},Et=Object(v.a)(function(te){var ie=te.loading,se=te.globalSetting;return{globalSetting:se,loading:ie.effects}},null,null,{forwardRef:!0})(Object(m.forwardRef)(at)),ct=re("k1fw"),dt=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],we=function(ie,se){var ue=ie.globalSetting,Se=ie.loading,ke=ie.dispatch,Je=ie.editData,Qe=ie.onRef,bt=Qe===void 0?function(){}:Qe,Dt=ie.isEdit,Ze=Object(De.a)(ie,["globalSetting","loading","dispatch","editData","onRef","isEdit"]),ut=Object(m.useState)(""),Ft=Object(d.a)(ut,2),Ct=Ft[0],jt=Ft[1],$t=Object(m.useState)([]),Lt=Object(d.a)($t,2),Qt=Lt[0],Zt=Lt[1];console.log(Qt),Object(m.useEffect)(function(){var Ut;if(!Je||!Dt)return;jt(Je==null?void 0:Je.name);var Mt=Je==null||((Ut=Je.sub_item_banks)===null||Ut===void 0)?void 0:Ut.map(function(St){var tt,Fe,nr;return Object(ct.a)(Object(ct.a)({},St),{},{id:St.id,open:!1,qusList:St==null||((tt=St.choices)===null||tt===void 0)?void 0:tt.map(function(Vt){return Vt.choice_text}),activeQusEditor:null,qusAnswer:(Fe=[St==null||((nr=St.choices)===null||nr===void 0)?void 0:nr.findIndex(function(Vt){return Vt.is_answer})])===null||Fe===void 0?void 0:Fe.filter(function(Vt){return Vt!==-1})})});Zt(Mt)},[Je]),Object(m.useImperativeHandle)(se,function(){return{onSave:ft,Clear:Xt}});var ft=function(){if(!Ct)return T.b.info("\u8BF7\u60A8\u8F93\u5165\u9898\u5E72"),!1;if(Qt.length===0)return T.b.info("\u8BF7\u60A8\u6DFB\u52A0\u5C0F\u9898"),!1;for(var Mt=0;Mt-1)return T.b.info("\u8BF7\u5148\u8F93\u5165\u7B2C".concat(Mt+1,"\u5C0F\u9898").concat(dt[Fe],"\u9009\u9879\u7684\u5185\u5BB9")),!1;if(!(tt!=null&&tt.qusAnswer.length))return T.b.info("\u8BF7\u8BBE\u7F6E\u7B2C".concat(Mt+1,"\u5C0F\u9898\u7684\u6B63\u786E\u7B54\u6848\uFF0C\u70B9\u51FB\u9009\u9879A/B...\u5373\u53EF\u5B8C\u6210\u8BBE\u7F6E")),!1}var nr=Qt.map(function(Vt){return{id:Vt.id>1?Vt.id:null,name:Vt.name,item_type:Vt.item_type,analysis:Vt.analysis,choices:Vt.qusList.map(function(qt,Wt){return{choice_text:qt,is_answer:Vt.qusAnswer[0]===Wt?1:0}})}});return{name:Ct,sub_item_banks:nr}},Xt=function(){jt(""),Zt([])},zt=function(){var Mt={id:Math.random(),item_type:"SINGLE",open:!1,name:"",qusList:["","","",""],activeQusEditor:null,qusAnswer:[],analysis:""};Zt(Qt.concat(Mt))},Gt=function(Mt,St,tt){var Fe=Object(G.cloneDeep)(Qt);if(Mt==="open"&&(Fe[St].open=!Fe[St].open),Mt==="delete"&&Fe.splice(St,1),Mt==="value"&&(Fe[St].name=tt),Mt==="answer"&&(Fe[St].qusAnswer=[tt]),Mt==="edit"&&(Fe[St].activeQusEditor=tt),Mt==="details"&&(Fe[St].qusList[Fe[St].activeQusEditor]=tt),Mt==="addQus"&&(Fe[St].qusList=Fe[St].qusList.concat("")),Mt==="deleteQus"){var nr;Fe[St].qusList=Fe[St].qusList.filter(function(Vt,qt){return qt!==tt}),Fe[St].qusAnswer=(nr=Fe[St].qusAnswer)===null||nr===void 0?void 0:nr.filter(function(Vt){return Vt!==tt})}Mt==="analysis"&&(Fe[St].analysis=tt),Zt(Fe)};return l.a.createElement("section",{className:ne.a.wrap},l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u9898\u5E72\uFF1A")),l.a.createElement(Ee.a,{id:"combination-question-title",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u5E72",defaultValue:Ct,onChange:function(Mt){return jt(Mt)}}),Qt==null?void 0:Qt.map(function(Ut,Mt){var St;return l.a.createElement("div",{className:ne.a.fold,key:Ut.id},l.a.createElement("div",{onClick:function(){return Gt("open",Mt)},className:ne.a.head},l.a.createElement("i",{className:"iconfont icon-sanjiaoxing",style:{transform:Ut.open?"initial":"rotate(270deg) translate(2px, 4px)"}}),l.a.createElement("span",null,"\u7B2C",Mt+1,"\u5C0F\u9898\uFF08\u5355\u9009\u9898\uFF09"),l.a.createElement("b",{style:{visibility:"hidden"},onClick:function(Fe){Fe.stopPropagation(),Gt("delete",Mt)},className:"iconfont icon-shanchu8"})),l.a.createElement("div",{className:"mb10",style:{display:Ut.open?"block":"none"}},l.a.createElement(Ee.a,{watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u5E72",defaultValue:Ut==null?void 0:Ut.name,onChange:function(Fe){return Gt("value",Mt,Fe)}}),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u7B54\u6848\u9009\u9879\uFF1A",l.a.createElement("span",{className:ne.a.colorGray},"\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848"))),Ut==null||((St=Ut.qusList)===null||St===void 0)?void 0:St.map(function(tt,Fe){var nr,Vt;return l.a.createElement("div",{className:ne.a.choiceWrap,key:Fe},l.a.createElement(X.a,{title:"\u70B9\u51FB\u8BBE\u7F6E\u4E3A\u6807\u51C6\u7B54\u6848",placement:"left"},l.a.createElement("div",{className:"".concat(ne.a.answer," ").concat(Ut!=null&&(nr=Ut.qusAnswer)!==null&&nr!==void 0&&nr.includes(Fe)?ne.a.activeAnswer:""),onClick:function(){return Gt("answer",Mt,Fe)}},dt[Fe])),l.a.createElement("div",{className:ne.a.editorWrap},(Ut==null?void 0:Ut.activeQusEditor)===Fe?l.a.createElement(Ee.a,{id:"single-question-option-".concat(Fe),watch:!0,height:155,isFocus:!0,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9009\u9879",defaultValue:tt,onChange:function(Wt){return Gt("details",Mt,Wt)}}):l.a.createElement("div",{className:ne.a.htmlWrap,onClick:function(){return Gt("edit",Mt,Fe)}},l.a.createElement(a.a,{value:tt}))),Fe>1&&l.a.createElement(X.a,{title:"\u5220\u9664"},l.a.createElement("i",{className:"".concat(ne.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){return Gt("deleteQus",Mt,Fe)}})),Fe<7&&Fe===(Ut==null||((Vt=Ut.qusList)===null||Vt===void 0)?void 0:Vt.length)-1&&l.a.createElement(X.a,{title:"\u65B0\u589E\u53C2\u8003\u7B54\u6848"},l.a.createElement("i",{className:"".concat(ne.a.addIcon," iconfont icon-roundaddfill ml6"),onClick:function(){return Gt("addQus",Mt)}})))}),l.a.createElement("p",{className:"mb10 mt10"},l.a.createElement("span",{className:ne.a.title},"\u9898\u76EE\u89E3\u6790\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-answer",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790",defaultValue:Ut.analysis,onChange:function(Fe){return Gt("analysis",Mt,Fe)}})))}))},gt=Object(v.a)(function(te){var ie=te.loading,se=te.globalSetting;return{globalSetting:se,loading:ie.effects}},null,null,{forwardRef:!0})(Object(m.forwardRef)(we)),lt=re("14J3"),Re=re("BMrR"),je=re("ZWs3"),ge=function(ie){var se=ie.visible,ue=ie.onCancel,Se=ie.onRandomExchange,ke=ie.selectFromProblemSet;return l.a.createElement(c.a,{title:"\u8BF7\u9009\u62E9\u66FF\u6362\u65B9\u5F0F",visible:se,onCancel:ue,centered:!0,maskClosable:!0,footer:null},l.a.createElement(Re.a,{justify:"center"},l.a.createElement(je.a,{onClick:Se},"\u968F\u673A\u66F4\u6362"),l.a.createElement(D.a,{style:{marginLeft:24},onClick:ke},"\u4ECE\u9898\u5E93\u4E2D\u9009\u62E9")))},de=ge,pe=function(ie){var se,ue,Se,ke,Je,Qe,bt,Dt,Ze=ie.data,ut=ie.submit,Ft=ie.goBack,Ct=ie.loading,jt=ie.onTypeScore,$t=ie.editPreview,Lt=$t===void 0?!1:$t,Qt=ie.onSkipExamination,Zt=ie.selectValue,ft=ie.onExchange,Xt=Object(m.useRef)(),zt=Object(m.useRef)(Object(G.debounce)(function(){return xr()},100,{leading:!0,trailing:!0})),Gt=Object(m.useState)(null),Ut=Object(d.a)(Gt,2),Mt=Ut[0],St=Ut[1],tt=Object(m.useState)(!1),Fe=Object(d.a)(tt,2),nr=Fe[0],Vt=Fe[1],qt=Object(m.useState)(!1),Wt=Object(d.a)(qt,2),Tr=Wt[0],ir=Wt[1],Rt=Object(m.useRef)(),Ie=Object(b.i)();Object(m.useEffect)(function(){return window.addEventListener("scroll",zt==null?void 0:zt.current),function(){window.removeEventListener("scroll",zt==null?void 0:zt.current)}},[]),Object(m.useEffect)(function(){Vt(!0)},[]),Object(m.useEffect)(function(){var nt,be,Ke,wt,mt=(nt=document.getElementById("examName"))===null||nt===void 0||((be=nt.getElementsByClassName("ant-pagination-options-quick-jumper"))===null||be===void 0||((Ke=be[0])===null||Ke===void 0||((wt=Ke.childNodes)===null||wt===void 0)))?void 0:wt[2];mt&&(mt.nodeValue="\u4EFD")},[Ze]);var xt=function(be){var Ke=parseInt(be);return isNaN(Ke)?"":Ke};function Dr(){var nt=0,be=0,Ke=0;return document.body&&(be=document.body.scrollTop),document.documentElement&&(Ke=document.documentElement.scrollTop),nt=be-Ke>0?be:Ke,nt}function un(){var nt=0,be=0,Ke=0;return document.body&&(be=document.body.scrollHeight),document.documentElement&&(Ke=document.documentElement.scrollHeight),nt=be-Ke>0?be:Ke,nt}function dn(){var nt=0;return document.compatMode=="CSS1Compat"?nt=document.documentElement.clientHeight:nt=document.body.clientHeight,nt}var xr=function(){var be=document.getElementById("preview_btns"),Ke=document.getElementById("preview_btns_else");Dr()+dn()>=un()-68?(be.style.visibility="hidden",Ke.style.visibility="visible"):(be.style.visibility="visible",Ke.style.visibility="hidden")},U=["\u5BB9\u6613","\u7B80\u5355","\u9002\u4E2D","\u56F0\u96BE"],u=function(be){var Ke,wt=[];return l.a.createElement(l.a.Fragment,null,l.a.createElement("aside",{className:f.a.single},be==null||((Ke=be.choices)===null||Ke===void 0)?void 0:Ke.map(function(mt,vt){return mt.is_answer&&wt.push(ce[vt]),l.a.createElement("ul",{key:vt},l.a.createElement("li",null,ce[vt],"\u3001"),l.a.createElement("li",null,l.a.createElement(a.a,{value:mt.choice_text})))})),l.a.createElement("div",{className:f.a.analysis},l.a.createElement("div",null,"\u6B63\u786E\u7B54\u6848\uFF1A",wt.join(""),l.a.createElement("span",{className:"ml30"},"\u96BE\u5EA6\uFF1A",U[be.difficulty])),l.a.createElement("aside",null,l.a.createElement("span",{className:f.a.text},"\u89E3\u6790:"),l.a.createElement(a.a,{value:be.analysis?be.analysis:"\u6682\u65E0\u89E3\u6790"})),l.a.createElement("ul",null,l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#007AFF",marginRight:10}},"\u65B9\u5411&\u8BFE\u7A0B:"),"".concat(be==null?void 0:be.discipline_name,"/").concat(be==null?void 0:be.sub_discipline_name)),l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#5AB891",marginRight:10}},"\u77E5\u8BC6\u70B9:"),be==null?void 0:be.tag_discipline_name))))},g=function(be){var Ke,wt=be==null||((Ke=be.standard_answer)===null||Ke===void 0)?void 0:Ke.map(function(mt){var vt;return"\u7B54\u6848\uFF08\u586B\u7A7A".concat(mt.position,"\uFF09\uFF1A").concat(mt==null||((vt=mt.answer_text)===null||vt===void 0)?void 0:vt.join("\u3001"))});return l.a.createElement(l.a.Fragment,null,l.a.createElement("div",{className:f.a.analysis},l.a.createElement("div",null,"\u6B63\u786E\u7B54\u6848\uFF1A",wt),l.a.createElement("aside",null,l.a.createElement("span",{className:f.a.text},"\u89E3\u6790:"),l.a.createElement(a.a,{value:be.analysis?be.analysis:"\u6682\u65E0\u89E3\u6790"})),l.a.createElement("ul",null,l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#007AFF",marginRight:10}},"\u65B9\u5411&\u8BFE\u7A0B:"),"".concat(be==null?void 0:be.discipline_name,"/").concat(be==null?void 0:be.sub_discipline_name)),l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#5AB891",marginRight:10}},"\u77E5\u8BC6\u70B9:"),be==null?void 0:be.tag_discipline_name))))},P=function(be){var Ke;return l.a.createElement("div",{className:f.a.analysis},l.a.createElement("div",null,"\u6B63\u786E\u7B54\u6848\uFF1A",be==null||((Ke=be.answer_texts)===null||Ke===void 0)?void 0:Ke[0]),l.a.createElement("aside",null,l.a.createElement("span",{className:f.a.text},"\u89E3\u6790:"),l.a.createElement(a.a,{value:be.analysis?be.analysis:"\u6682\u65E0\u89E3\u6790"})),l.a.createElement("ul",null,l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#007AFF",marginRight:10}},"\u65B9\u5411&\u8BFE\u7A0B:"),"".concat(be==null?void 0:be.discipline_name,"/").concat(be==null?void 0:be.sub_discipline_name)),l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#5AB891",marginRight:10}},"\u77E5\u8BC6\u70B9:"),be==null?void 0:be.tag_discipline_name)))},J=function(be){var Ke;return l.a.createElement("div",{className:f.a.analysis},l.a.createElement("aside",null,l.a.createElement("span",{className:f.a.text},"\u9884\u671F\u8F93\u51FA:"),l.a.createElement(a.a,{value:be==null||((Ke=be.program_attr)===null||Ke===void 0)?void 0:Ke.description})),l.a.createElement("ul",null,l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#007AFF",marginRight:10}},"\u65B9\u5411&\u8BFE\u7A0B:"),"".concat(be==null?void 0:be.discipline_name,"/").concat(be==null?void 0:be.sub_discipline_name)),l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#5AB891",marginRight:10}},"\u77E5\u8BC6\u70B9:"),be==null?void 0:be.tag_discipline_name)))},j=function(be,Ke){var wt;return l.a.createElement("div",null,be==null||((wt=be.sub_item_banks)===null||wt===void 0)?void 0:wt.map(function(mt,vt){var It,gr=[];return l.a.createElement(l.a.Fragment,null,l.a.createElement("div",{style:{marginLeft:25,fontSize:"16px",color:"#333"}},Ke+1+"."+(vt+1),"\uFF08\u5355\u9009\u9898\uFF09",mt.name),l.a.createElement("aside",{className:f.a.single},mt==null||((It=mt.choices)===null||It===void 0)?void 0:It.map(function(cr,hr){return cr.is_answer&&gr.push(ce[hr]),l.a.createElement("ul",{key:hr},l.a.createElement("li",null,ce[hr],"\u3001"),l.a.createElement("li",null,l.a.createElement(a.a,{value:cr.choice_text})))})),l.a.createElement("div",{className:f.a.analysis},l.a.createElement("div",null,"\u6B63\u786E\u7B54\u6848\uFF1A",gr.join(""),l.a.createElement("span",{className:"ml30"},"\u96BE\u5EA6\uFF1A",U[mt.difficulty])),l.a.createElement("aside",null,l.a.createElement("span",{className:f.a.text},"\u89E3\u6790:"),l.a.createElement(a.a,{value:mt.analysis?mt.analysis:"\u6682\u65E0\u89E3\u6790"})),l.a.createElement("ul",null,l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#007AFF",marginRight:10}},"\u65B9\u5411&\u8BFE\u7A0B:"),"".concat(be==null?void 0:be.discipline_name,"/").concat(be==null?void 0:be.sub_discipline_name)),l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#5AB891",marginRight:10}},"\u77E5\u8BC6\u70B9:"),be==null?void 0:be.tag_discipline_name))))}))},ce=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],Ne=function(be){var Ke,wt=[];be==null||((Ke=be.questions)===null||Ke===void 0)||Ke.map(function(vt){var It;return vt==null||((It=vt.sub_item_banks)===null||It===void 0)?void 0:It.map(function(gr){wt.push(gr)})});var mt=0;be.type==="COMBINATION"?mt=be.questions_score/wt.length:mt=be.questions_score/be.questions_count,c.a.confirm({icon:null,className:"custom-modal-divider",centered:!0,title:"\u5206\u6570\u8BBE\u7F6E",content:l.a.createElement("div",{className:f.a.modalColumn},l.a.createElement("div",{className:f.a.modalRow,style:{justifyContent:"flex-start"}},l.a.createElement("sup",{className:f.a.sup},"*"),l.a.createElement("span",null,be==null?void 0:be.name,(be==null?void 0:be.type)==="COMBINATION"&&"\u4E2D\u7684\u6BCF\u5C0F\u9898","\uFF1A"),l.a.createElement(h.a,{min:1,parser:xt,defaultValue:mt,onChange:function(It){mt=It}}),l.a.createElement("span",{className:"ml5"},"\u5206/\u9898"))),okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88",onOk:function(){var vt=Object(A.a)(y.a.mark(function gr(){var cr,hr;return y.a.wrap(function(Sr){for(;;)switch(Sr.prev=Sr.next){case 0:if(mt){Sr.next=3;break}return T.b.warn("\u5206\u6570\u4E0D\u80FD\u4E3A\u7A7A\u6216\u4E3A0"),Sr.abrupt("return",Promise.reject());case 3:be.type==="COMBINATION"?(cr={type:be==null?void 0:be.type,score:mt,scoreTotal:mt*(wt==null?void 0:wt.length)},jt(cr)):(hr={type:be==null?void 0:be.type,score:mt,scoreTotal:mt*be.questions_count},jt(hr));case 4:case"end":return Sr.stop()}},gr)}));function It(){return vt.apply(this,arguments)}return It}()})},qe=function(){var be="";c.a.confirm({icon:null,className:"custom-modal-divider",centered:!0,title:"\u4FDD\u5B58\u8BD5\u5377",content:l.a.createElement("div",{className:f.a.modalColumn},l.a.createElement("div",{style:{color:"#676A6C",display:"flex"},className:"font14 mt20"},l.a.createElement("img",{style:{marginRight:5},src:q.a}),"\u4FDD\u5B58\u540E\u5355\u72EC\u751F\u6210\u4E00\u4EFD\u4EBA\u5DE5\u7EC4\u5377\u7C7B\u578B\u7684\u56FA\u5B9A\u8BD5\u5377\u3002"),l.a.createElement("div",{className:f.a.modalRow,style:{marginTop:20}},l.a.createElement("sup",{className:f.a.sup},"*"),l.a.createElement("span",{style:{flexShrink:0}},"\u8BD5\u5377\u540D\u79F0\uFF1A"),l.a.createElement(L.a,{placeholder:"\u8BF7\u8F93\u5165\u8BD5\u5377\u540D\u79F0",min:0,maxLength:60,defaultValue:be,onChange:function(wt){be=wt.target.value}}))),okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88",onOk:function(){var Ke=Object(A.a)(y.a.mark(function mt(){var vt,It,gr,cr,hr;return y.a.wrap(function(Sr){for(;;)switch(Sr.prev=Sr.next){case 0:if(be){Sr.next=3;break}return T.b.warn("\u8BD5\u5377\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A"),Sr.abrupt("return",Promise.reject());case 3:return It=[],gr=[],cr=[],Ze==null||((vt=Ze.questionList)===null||vt===void 0)||vt.forEach(function(Wr){var or;(or=Wr.questions)===null||or===void 0||or.forEach(function(tr){It.push(tr.id),gr.push(Wr.questions_score/Wr.questions_count),Wr.type==="COMBINATION"&&cr.push({id:tr.id,sub_item_bank_ids:tr.sub_item_banks.map(function(pr){return pr.id})})})}),console.log("-----",cr),hr={item_bank_ids:It,item_bank_scores:gr,name:be,combination_item_banks:cr},Sr.next=11,ut(hr);case 11:case"end":return Sr.stop()}},mt)}));function wt(){return Ke.apply(this,arguments)}return wt}()})},Tt=function(be,Ke,wt,mt){var vt,It="".concat(location.pathname).concat(location.search),gr=(vt=mt.questions)===null||vt===void 0?void 0:vt.map(function(hr){return hr.id});if(It.includes("exercise"))Rt.current={id:be,ids:gr,type:Ke,index:wt},ir(!0);else var cr=c.a.confirm({icon:null,className:"custom-modal-divider",centered:!0,title:"\u6E29\u99A8\u63D0\u793A",content:"\u786E\u8BA4\u8981\u66F4\u6362\u8BE5\u8BD5\u9898\u5417\uFF1F",cancelButtonProps:{disabled:!1},maskClosable:!0,keyboard:!1,okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88",onOk:function(){var hr=Object(A.a)(y.a.mark(function Sr(){return y.a.wrap(function(or){for(;;)switch(or.prev=or.next){case 0:return cr.update({cancelButtonProps:{disabled:!0}}),or.next=3,ft({single_question_id:be,seleted_item_bank_ids:gr},{type:Ke,index:wt});case 3:cr.update({cancelButtonProps:{disabled:!1}}),T.b.success("\u5DF2\u91CD\u65B0\u968F\u673A\u751F\u6210\u8BD5\u9898");case 5:case"end":return or.stop()}},Sr)}));function Lr(){return hr.apply(this,arguments)}return Lr}()})},Ue=function(be){var Ke,wt=(Ke=be.questions)===null||Ke===void 0?void 0:Ke.map(function(It){return It.id}),mt=be.name,vt=c.a.confirm({icon:null,className:"custom-modal-divider",centered:!0,title:"\u6E29\u99A8\u63D0\u793A",content:"\u786E\u8BA4\u66F4\u6362".concat(mt,"\u4E2D\u7684\u6240\u6709\u8BD5\u9898\u5417\uFF1F"),cancelButtonProps:{disabled:!1},maskClosable:!1,keyboard:!1,okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88",onOk:function(){var It=Object(A.a)(y.a.mark(function cr(){return y.a.wrap(function(Lr){for(;;)switch(Lr.prev=Lr.next){case 0:return vt.update({cancelButtonProps:{disabled:!0}}),Lr.next=3,ft({seleted_item_bank_ids:wt},{type:be.type});case 3:vt.update({cancelButtonProps:{disabled:!1}}),T.b.success("\u5DF2\u91CD\u65B0\u968F\u673A\u751F\u6210".concat(mt,"\u8BD5\u9898"));case 5:case"end":return Lr.stop()}},cr)}));function gr(){return It.apply(this,arguments)}return gr}()})},Pt=function(){var be=c.a.confirm({icon:null,className:"custom-modal-divider",centered:!0,title:"\u6E29\u99A8\u63D0\u793A",content:"\u786E\u8BA4\u66F4\u6362\u9884\u89C8\u4E2D\u7684\u6240\u6709\u8BD5\u9898\u5417\uFF1F",cancelButtonProps:{disabled:!1},maskClosable:!1,keyboard:!1,okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88",onOk:function(){var Ke=Object(A.a)(y.a.mark(function mt(){return y.a.wrap(function(It){for(;;)switch(It.prev=It.next){case 0:return be.update({cancelButtonProps:{disabled:!0}}),It.next=3,ft();case 3:be.update({cancelButtonProps:{disabled:!1}}),T.b.success("\u5DF2\u91CD\u65B0\u968F\u673A\u751F\u6210\u6574\u5F20\u8BD5\u9898");case 5:case"end":return It.stop()}},mt)}));function wt(){return Ke.apply(this,arguments)}return wt}()})},er=function(be){console.log(be,"key"),Qt(be-1)},fr=function(){return l.a.createElement(l.a.Fragment,null,l.a.createElement(B.a,{color:"#55575D",overlayClassName:f.a.popover,visible:nr,getPopupContainer:function(Ke){return Ke==null?void 0:Ke.parentNode},content:"\u5982\u60A8\u5BF9\u6B64\u4EFD\u8BD5\u9898\u6EE1\u610F\uFF0C\u53EF\u5C06\u6B64\u4EFD\u8BD5\u9898\u4FDD\u5B58\u4E3A\u56FA\u5B9A\u8BD5\u5377"},l.a.createElement(D.a,{onMouseEnter:function(){return Vt(!0)},onMouseLeave:function(){return Vt(!1)},onClick:function(){qe()}},"\u4FDD\u5B58")),l.a.createElement(D.a,{onClick:function(){document.body.scrollIntoView(),Ft()}},"\u8FD4\u56DE"),l.a.createElement(D.a,{loading:Ct,onClick:function(){return ut()},type:"primary"},"\u63D0\u4EA4"))},Gr=function(){var be;return l.a.createElement(l.a.Fragment,null,l.a.createElement(D.a,{onClick:Ft},"\u8FD4\u56DE"),Zt>0&&l.a.createElement(D.a,{onClick:function(){return er(Zt)},type:"primary"},"\u4E0A\u4E00\u4EFD"),Zt<(Ze==null||((be=Ze.exam)===null||be===void 0)?void 0:be.total_num)-1&&l.a.createElement(D.a,{onClick:function(){return er(Zt+2)}},"\u4E0B\u4E00\u4EFD"))},Mr=function(be,Ke){if(Ke==="SINGLE")return l.a.createElement(l.a.Fragment,null,l.a.createElement(it,{ref:Xt,editData:be,isEdit:!0}),l.a.createElement(I.a,null));if(Ke==="MULTIPLE")return l.a.createElement(l.a.Fragment,null,l.a.createElement(Be,{ref:Xt,editData:be,isEdit:!0}),l.a.createElement(I.a,null));if(Ke==="JUDGMENT")return l.a.createElement(l.a.Fragment,null,l.a.createElement(ze,{ref:Xt,editData:be,isEdit:!0}),l.a.createElement(I.a,null));if(Ke==="COMPLETION")return l.a.createElement(l.a.Fragment,null,l.a.createElement($e,{ref:Xt,editData:be,isEdit:!0}),l.a.createElement(I.a,null));if(Ke==="SUBJECTIVE")return l.a.createElement(l.a.Fragment,null,l.a.createElement(Et,{ref:Xt,editData:be,isEdit:!0}),l.a.createElement(I.a,null));if(Ke==="COMBINATION")return l.a.createElement(l.a.Fragment,null,l.a.createElement(gt,{ref:Xt,editData:be,isEdit:!0}),l.a.createElement(I.a,null));if(Ke==="PROGRAM"){var wt;v.d.push("/problems/".concat(be==null||((wt=be.program_attr)===null||wt===void 0)?void 0:wt.identifier,"/edit?type=exercises&express_id=").concat(Ie.categoryId,"&question_id=").concat(be==null?void 0:be.id,"&score=").concat(be==null?void 0:be.score,"&callback_url=").concat(location.pathname,"&select=").concat(Zt,"&exercise=true"))}},Ir=function(){var nt=Object(A.a)(y.a.mark(function be(Ke,wt){var mt,vt,It,gr,cr,hr,Lr,Sr,Wr,or;return y.a.wrap(function(pr){for(;;)switch(pr.prev=pr.next){case 0:return pr.next=2,(mt=Xt.current)===null||mt===void 0?void 0:mt.onSave();case 2:if(vt=pr.sent,vt){pr.next=5;break}return pr.abrupt("return");case 5:return It={question_score:wt.score,analysis:vt.analysis},(Ke==="SINGLE"||Ke==="MULTIPLE"||Ke==="JUDGMENT")&&(cr=[],hr=[],It.question_type=Ke==="JUDGMENT"?2:1,It.question_title=vt==null?void 0:vt.name,vt==null||((gr=vt.choices)===null||gr===void 0)||gr.forEach(function(Ht,br){cr.push(Ht.choice_text),Ht!=null&&Ht.is_answer&&hr.push(br+1)}),It.question_choices=cr,It.standard_answers=hr),Ke==="COMPLETION"&&(It.is_ordered=vt.is_ordered,It.question_title=vt==null?void 0:vt.name,It.question_type=3,Sr=[],vt==null||((Lr=vt.standard_answers)===null||Lr===void 0)||Lr.forEach(function(Ht,br){Sr.push({choice_id:Ht.position,answer_text:Ht.answer_text})}),It.standard_answers=Sr),Ke==="SUBJECTIVE"&&(It.question_title=vt==null?void 0:vt.name,It.question_type=3,It.standard_answers=vt==null?void 0:vt.answer_texts),Ke==="COMBINATION"&&(It.question_title=vt==null?void 0:vt.name,It.question_type=7,It.sub_questions=vt==null||((Wr=vt.sub_item_banks)===null||Wr===void 0)?void 0:Wr.map(function(Ht,br){return{id:Ht.id,question_title:Ht.name,question_type:1,question_choices:Ht.choices.map(function(lr){return lr.choice_text}),standard_answers:[Ht.choices.findIndex(function(lr){return lr.is_answer})+1],analysis:Ht.analysis}}),delete It.analysis),pr.next=12,Object(S.a)("/api/exercise_questions/".concat(wt.id,".json"),{method:"put",body:It});case 12:or=pr.sent,(or==null?void 0:or.status)===0&&(T.b.success("\u7F16\u8F91\u6210\u529F"),er(Zt+1)),St(null);case 15:case"end":return pr.stop()}},be)}));return function(Ke,wt){return nt.apply(this,arguments)}}(),cn=function(){for(var be=[],Ke=0;Ke<(Ze==null||((wt=Ze.exam)===null||wt===void 0)?void 0:wt.total_num);Ke++){var wt;be.push({})}return be},Sn=Ze==null||((se=Ze.questionList)===null||se===void 0)?void 0:se.reduce(function(nt,be){return nt+be.questions_score},0),wr=Lt&&(Ze==null||((ue=Ze.exam)===null||ue===void 0)?void 0:ue.exercise_status)!==1;return l.a.createElement("section",{className:f.a.wrap},l.a.createElement("div",{id:"id_left_preview",className:f.a.left,onMouseEnter:function(be){var Ke=document.getElementById("id_left_preview");Ke.style.overflowY="auto"},onMouseLeave:function(be){var Ke=document.getElementById("id_left_preview");Ke.style.overflowY="hidden"}},l.a.createElement("div",{className:f.a.title},l.a.createElement("div",null,l.a.createElement("b",null),l.a.createElement("span",null,"\u7B54\u9898\u5361"))),l.a.createElement("div",{className:f.a.total},l.a.createElement("div",null,l.a.createElement("img",{src:H.a}),l.a.createElement("span",null,"\u9898\u6570(\u9053)"),l.a.createElement("aside",null,Ze==null?void 0:Ze.all_questions_count)),l.a.createElement("div",{className:"mr30 ml30"},l.a.createElement("img",{src:Q.a}),l.a.createElement("span",null,"\u603B\u5206(\u5206)"),l.a.createElement("aside",null,Sn)),l.a.createElement("div",null,l.a.createElement("img",{src:s.a}),l.a.createElement("span",null,"\u65F6\u957F(\u5206)"),l.a.createElement("aside",null,Ze==null||((Se=Ze.exam)===null||Se===void 0)?void 0:Se.time))),Ze==null||((ke=Ze.questionList)===null||ke===void 0)?void 0:ke.map(function(nt,be){var Ke;return l.a.createElement("div",{className:f.a.list,key:be},l.a.createElement("div",{className:f.a.name},l.a.createElement("b",null),l.a.createElement("span",null,nt.name)),l.a.createElement("aside",null,l.a.createElement("div",null,"\u5171",l.a.createElement("span",{className:f.a.b},nt.questions_count),"\u9898 ",l.a.createElement("span",{className:f.a.l},"|"),"\u5171",l.a.createElement("span",{className:f.a.r},nt.questions_score),"\u5206"),l.a.createElement("div",{className:f.a.answerSheet},nt==null||((Ke=nt.questions)===null||Ke===void 0)?void 0:Ke.map(function(wt,mt){return l.a.createElement("div",{onClick:function(){var It="Anchor_".concat(wt.id),gr=document.getElementById(It);gr&&setTimeout(function(){return gr.scrollIntoView({block:"center",behavior:"smooth"})})},key:wt.id,className:f.a.tag},mt+1)}))))})),l.a.createElement("div",{className:f.a.right},l.a.createElement("div",{className:f.a.examName,id:"examName"},l.a.createElement("div",{className:f.a.name},l.a.createElement(X.a,{title:Ze==null||((Je=Ze.exam)===null||Je===void 0)?void 0:Je.name,getPopupContainer:function(be){return be.parentNode}},l.a.createElement("span",{className:f.a.t},Ze==null||((Qe=Ze.exam)===null||Qe===void 0)?void 0:Qe.name))),Lt?l.a.createElement($.a,{showTotal:function(be){return l.a.createElement("span",{style:{color:"#656F87",fontSize:14}},"\u5171\u8BA1",l.a.createElement("span",{className:"c-light-primary"},be),"\u4EFD\u8BD5\u5377")},total:Ze==null||((bt=Ze.exam)===null||bt===void 0)?void 0:bt.total_num,pageSize:1,current:Zt+1,showSizeChanger:!1,onChange:er,showQuickJumper:!0,hideOnSinglePage:!1}):l.a.createElement(D.a,{onClick:Pt,type:"primary"},"\u968F\u673A\u66F4\u6362")),l.a.createElement("div",{className:f.a.topWarp},Ze==null||((Dt=Ze.questionList)===null||Dt===void 0)?void 0:Dt.map(function(nt,be){var Ke,wt;return l.a.createElement(l.a.Fragment,{key:be},l.a.createElement("div",{className:f.a.head,style:be===0?{border:0,marginTop:-16}:{}},l.a.createElement("div",{className:f.a.name},l.a.createElement("b",null),l.a.createElement("span",null,nt.name)),l.a.createElement("div",{className:f.a.so},"\u5171",l.a.createElement("span",{className:f.a.b},nt.questions_count," "),"\u9898 ",nt.type==="COMBINATION"&&"\uFF08\u5305\u542B".concat(nt==null||((Ke=nt.questions)===null||Ke===void 0)?void 0:Ke.map(function(mt){var vt;return mt==null||((vt=mt.sub_item_banks)===null||vt===void 0)?void 0:vt.length}).reduce(function(mt,vt){return mt+vt}),"\u5C0F\u9898\uFF09"),l.a.createElement("span",{className:f.a.l},"|"),"\u5171",l.a.createElement("span",{className:f.a.r},nt.questions_score),"\u5206"),!Lt&&l.a.createElement("div",{className:f.a.btn},l.a.createElement(D.a,{onClick:function(){Ne(nt)},type:"primary",ghost:!0,className:"mr20"},"\u8BBE\u7F6E\u5F97\u5206"),l.a.createElement(D.a,{onClick:function(){return Ue(nt)},type:"primary",ghost:!0},"\u968F\u673A\u66F4\u6362"))),nt==null||((wt=nt.questions)===null||wt===void 0)?void 0:wt.map(function(mt,vt){return Mt===mt.id?l.a.createElement("div",{id:"Anchor_".concat(mt.id),className:f.a.content,style:{padding:0,marginTop:10},key:mt.id},l.a.createElement("div",{style:{float:"right",marginTop:-6}},l.a.createElement(D.a,{onClick:function(){return St(null)},className:"mr20",type:"primary",ghost:!0},"\u53D6\u6D88"),l.a.createElement(D.a,{onClick:function(){return Ir(nt==null?void 0:nt.type,mt)},type:"primary"},"\u4FDD\u5B58")),Mr(mt,nt.type)):l.a.createElement("div",{id:"Anchor_".concat(mt.id),className:f.a.content,key:mt.id},l.a.createElement("div",{className:f.a.titleWrap},l.a.createElement(a.a,{style:{paddingRight:10},className:f.a.titleHtml,value:vt+1+"\u3001"+"".concat((mt==null?void 0:mt.item_type)==="combination"?"\uFF08\u9898\u5E72\uFF09":"")+mt.name}),Lt&&l.a.createElement(D.a,{disabled:wr,onClick:function(){if(Mt){T.b.warn("\u5148\u4FDD\u5B58\u6216\u53D6\u6D88\u5F53\u524D\u6B63\u5728\u7F16\u8F91\u7684\u8BD5\u9898");return}St(mt.id)},type:"primary",className:"mr20",style:{marginLeft:"auto"},ghost:!0},"\u7F16\u8F91"),l.a.createElement(D.a,{disabled:wr,onClick:function(){return Tt(mt.id,nt.type,vt,nt)},type:"primary",ghost:!0},"\u6362\u4E00\u9898")),(nt.type==="SINGLE"||nt.type==="JUDGMENT"||nt.type==="MULTIPLE")&&u(mt),nt.type==="COMPLETION"&&g(mt),nt.type==="SUBJECTIVE"&&P(mt),nt.type==="PROGRAM"&&J(mt),nt.type==="COMBINATION"&&j(mt,vt),l.a.createElement("div",null))}))})),l.a.createElement("div",{className:f.a.btnsElse,id:"preview_btns_else"},Lt?Gr():fr()),l.a.createElement("div",{className:f.a.btnsWrap,id:"preview_btns"},l.a.createElement("div",{className:f.a.btns},Lt?Gr():fr()))),l.a.createElement(de,{visible:Tr,onRandomExchange:Object(A.a)(y.a.mark(function nt(){var be;return y.a.wrap(function(wt){for(;;)switch(wt.prev=wt.next){case 0:return be=Rt.current,wt.next=3,ft({single_question_id:be.id,seleted_item_bank_ids:be.ids},{type:be.type,index:be.index});case 3:ir(!1);case 4:case"end":return wt.stop()}},nt)})),selectFromProblemSet:function(){var be=Rt.current,Ke="".concat(location.pathname).concat(location.search);Ke.includes("exercise")&&v.d.push("/paperlibrary/exchangequestion?type=exercise&qid=".concat(be.id,"&qtype=").concat(be.type,"&exerciseid=").concat(Ie.categoryId,"&from=").concat(Ke))},onCancel:function(){ir(!1)}}))},ee=ht.a=pe},ulZh:function(At,ht,re){typeof window!="undefined"&&function($,R){At.exports=R()}(this,function(){return function(ae){var $={};function R(X){if($[X])return $[X].exports;var N=$[X]={i:X,l:!1,exports:{}};return ae[X].call(N.exports,N,N.exports,R),N.l=!0,N.exports}return R.m=ae,R.c=$,R.d=function(X,N,I){R.o(X,N)||Object.defineProperty(X,N,{enumerable:!0,get:I})},R.r=function(X){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(X,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(X,"__esModule",{value:!0})},R.t=function(X,N){if(N&1&&(X=R(X)),N&8)return X;if(N&4&&typeof X=="object"&&X&&X.__esModule)return X;var I=Object.create(null);if(R.r(I),Object.defineProperty(I,"default",{enumerable:!0,value:X}),N&2&&typeof X!="string")for(var z in X)R.d(I,z,function(B){return X[B]}.bind(null,z));return I},R.n=function(X){var N=X&&X.__esModule?function(){return X.default}:function(){return X};return R.d(N,"a",N),N},R.o=function(X,N){return Object.prototype.hasOwnProperty.call(X,N)},R.p="/dist/",R(R.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(ae,$,R){"use strict";var X=Object.prototype.hasOwnProperty,N="~";function I(){}Object.create&&(I.prototype=Object.create(null),new I().__proto__||(N=!1));function z(E,L,k){this.fn=E,this.context=L,this.once=k||!1}function B(E,L,k,T,A){if(typeof k!="function")throw new TypeError("The listener must be a function");var C=new z(k,T||E,A),h=N?N+L:L;return E._events[h]?E._events[h].fn?E._events[h]=[E._events[h],C]:E._events[h].push(C):(E._events[h]=C,E._eventsCount++),E}function O(E,L){--E._eventsCount===0?E._events=new I:delete E._events[L]}function D(){this._events=new I,this._eventsCount=0}D.prototype.eventNames=function(){var L=[],k,T;if(this._eventsCount===0)return L;for(T in k=this._events)X.call(k,T)&&L.push(N?T.slice(1):T);return Object.getOwnPropertySymbols?L.concat(Object.getOwnPropertySymbols(k)):L},D.prototype.listeners=function(L){var k=N?N+L:L,T=this._events[k];if(!T)return[];if(T.fn)return[T.fn];for(var A=0,C=T.length,h=new Array(C);A0},!1)}function E(L,k){for(var T={main:[k]},A={main:[]},C={main:{}};D(T);)for(var h=Object.keys(T),o=0;o=2*l/f||S<=H)return;var V=Number.POSITIVE_INFINITY,Q;for(Q=h.level-1;Q>s;Q--){var G=p[Q].maxBitrate;if(V=l*G/(8*.8*v),V=S)return;var W=this.bwEstimator.getEstimate();D.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 "+Q+` Current BW estimate: `+(Object(X.isFiniteNumber)(W)?(W/1024).toFixed(3):"Unknown")+` Kb/s Estimated load time for current fragment: `+S.toFixed(3)+` s Estimated load time for the next fragment: `+V.toFixed(3)+` s Time to underbuffer: `+H.toFixed(3)+" s"),c.nextLoadLevel=Q,this.bwEstimator.sample(x,m.loaded),this.clearTimer(),h.loader&&(this.fragCurrent=this.partCurrent=null,h.loader.abort()),c.trigger(I.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:h,part:o,stats:m})},A.onFragLoaded=function(h,o){var c=o.frag,d=o.part;if(c.type===O.PlaylistLevelType.MAIN&&Object(X.isFiniteNumber)(c.sn)){var _=d?d.stats:c.stats,y=d?d.duration:c.duration;if(this.clearTimer(),this.lastLoadedFragLevel=c.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var m=this.hls.levels[c.level],l=(m.loaded?m.loaded.bytes:0)+_.loaded,x=(m.loaded?m.loaded.duration:0)+y;m.loaded={bytes:l,duration:x},m.realBitrate=Math.round(8*l/x)}if(c.bitrateTest){var f={stats:_,frag:c,part:d,id:c.type};this.onFragBuffered(I.Events.FRAG_BUFFERED,f),c.bitrateTest=!1}}},A.onFragBuffered=function(h,o){var c=o.frag,d=o.part,_=d?d.stats:c.stats;if(_.aborted)return;if(c.type!==O.PlaylistLevelType.MAIN||c.sn==="initSegment")return;var y=_.parsing.end-_.loading.start;this.bwEstimator.sample(y,_.loaded),_.bwEstimate=this.bwEstimator.getEstimate(),c.bitrateTest?this.bitrateTestDelay=y/1e3:this.bitrateTestDelay=0},A.onError=function(h,o){switch(o.details){case B.ErrorDetails.FRAG_LOAD_ERROR:case B.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},A.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},A.getNextABRAutoLevel=function(){var h=this.fragCurrent,o=this.partCurrent,c=this.hls,d=c.maxAutoLevel,_=c.config,y=c.minAutoLevel,m=c.media,l=o?o.duration:h?h.duration:0,x=m?m.currentTime:0,f=m&&m.playbackRate!==0?Math.abs(m.playbackRate):1,p=this.bwEstimator?this.bwEstimator.getEstimate():_.abrEwmaDefaultEstimate,s=(z.BufferHelper.bufferInfo(m,x,_.maxBufferHole).end-x)/f,a=this.findBestLevel(p,y,d,s,_.abrBandWidthFactor,_.abrBandWidthUpFactor);if(a>=0)return a;D.logger.trace((s?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var b=l?Math.min(l,_.maxStarvationDelay):_.maxStarvationDelay,v=_.abrBandWidthFactor,S=_.abrBandWidthUpFactor;if(!s){var M=this.bitrateTestDelay;if(M){var H=l?Math.min(l,_.maxLoadingDelay):_.maxLoadingDelay;b=H-M,D.logger.trace("bitrate test took "+Math.round(1e3*M)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*b)+" ms"),v=S=1}}return a=this.findBestLevel(p,y,d,s+b,v,S),Math.max(a,0)},A.findBestLevel=function(h,o,c,d,_,y){for(var m,l=this.fragCurrent,x=this.partCurrent,f=this.lastLoadedFragLevel,p=this.hls.levels,s=p[f],a=!!(s!=null&&(m=s.details)!==null&&m!==void 0&&m.live),b=s==null?void 0:s.codecSet,v=x?x.duration:l?l.duration:0,S=c;S>=o;S--){var M=p[S];if(!M||b&&M.codecSet!==b)continue;var H=M.details,V=(x?H==null?void 0:H.partTarget:H==null?void 0:H.averagetargetduration)||v,Q=void 0;S<=f?Q=_*h:Q=y*h;var G=p[S].maxBitrate,W=G*V/Q;if(D.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+S+"/"+Math.round(Q)+"/"+G+"/"+V+"/"+d+"/"+W),Q>G&&(!W||a&&!this.bitrateTestDelay||W0&&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()},f.doTick=function(){switch(this.state){case N.State.IDLE:this.doTickIdle();break;case N.State.WAITING_TRACK:{var s,a=this.levels,b=this.trackId,v=a==null||((s=a[b])===null||s===void 0)?void 0:s.details;if(v){if(this.waitForCdnTuneIn(v))break;this.state=N.State.WAITING_INIT_PTS}break}case N.State.FRAG_LOADING_WAITING_RETRY:{var S,M=performance.now(),H=this.retryDate;(!H||M>=H||(S=this.media)!==null&&S!==void 0&&S.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 Q=V.frag,G=V.part,W=V.cache,q=V.complete;if(this.initPTS[Q.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=N.State.FRAG_LOADING;var oe=W.flush(),fe={frag:Q,part:G,payload:oe,networkDetails:null};this._handleFragmentLoadProgress(fe),q&&l.prototype._handleFragmentLoadComplete.call(this,fe)}else if(this.videoTrackCC!==this.waitingVideoCC)o.logger.log("Waiting fragment cc ("+Q.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var ve=this.getLoadPosition(),De=z.BufferHelper.bufferInfo(this.mediaBuffer,ve,this.config.maxBufferHole),Ee=Object(A.fragmentWithinToleranceTest)(De.end,this.config.maxFragLookUpTolerance,Q);Ee<0&&(o.logger.log("Waiting fragment cc ("+Q.cc+") @ "+Q.start+" cancelled because another fragment at "+De.end+" is needed"),this.clearWaitingFragment())}}else this.state=N.State.IDLE}}this.onTickEnd()},f.clearWaitingFragment=function(){var s=this.waitingData;s&&(this.fragmentTracker.removeFragment(s.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=N.State.IDLE)},f.onTickEnd=function(){var s=this.media;if(!s||!s.readyState)return;var a=this.mediaBuffer?this.mediaBuffer:s,b=a.buffered;!this.loadedmetadata&&b.length&&(this.loadedmetadata=!0),this.lastCurrentTime=s.currentTime},f.doTickIdle=function(){var s,a,b=this.hls,v=this.levels,S=this.media,M=this.trackId,H=b.config;if(!v||!v[M])return;if(!S&&(this.startFragRequested||!H.startFragPrefetch))return;var V=v[M],Q=V.details;if(!Q||Q.live&&this.levelLastLoaded!==M||this.waitForCdnTuneIn(Q)){this.state=N.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,E.ElementaryStreamTypes.AUDIO,D.PlaylistLevelType.AUDIO));var G=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,D.PlaylistLevelType.AUDIO);if(G===null)return;var W=G.len,q=this.getMaxBufferLength(),oe=this.audioSwitch;if(W>=q&&!oe)return;if(!oe&&this._streamEnded(G,Q)){b.trigger(I.Events.BUFFER_EOS,{type:"audio"}),this.state=N.State.ENDED;return}var fe=Q.fragments,ve=fe[0].start,De=G.end;if(oe){var Ee=this.getLoadPosition();De=Ee,Q.PTSKnown&&Eeve||G.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),S.currentTime=ve+.05))}var _e=this.getNextFragment(De,Q);if(!_e){this.bufferFlushed=!0;return}((s=_e.decryptdata)===null||s===void 0?void 0:s.keyFormat)==="identity"&&!((a=_e.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(_e,Q):this.loadFragment(_e,Q,De)},f.getMaxBufferLength=function(){var s=l.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,D.PlaylistLevelType.MAIN);return a===null?s:Math.max(s,a.len)},f.onMediaDetaching=function(){this.videoBuffer=null,l.prototype.onMediaDetaching.call(this)},f.onAudioTracksUpdated=function(s,a){var b=a.audioTracks;this.resetTransmuxer(),this.levels=b.map(function(v){return new O.Level(v)})},f.onAudioTrackSwitching=function(s,a){var b=!!a.url;this.trackId=a.id;var v=this.fragCurrent;v!=null&&v.loader&&v.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),b?this.setInterval(y):this.resetTransmuxer(),b?(this.audioSwitch=!0,this.state=N.State.IDLE):this.state=N.State.STOPPED,this.tick()},f.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},f.onLevelLoaded=function(s,a){this.mainDetails=a.details},f.onAudioTrackLoaded=function(s,a){var b,v=this.levels,S=a.details,M=a.id;if(!v){this.warn("Audio tracks were reset while loading level "+M);return}this.log("Track "+M+" loaded ["+S.startSN+","+S.endSN+"],duration:"+S.totalduration);var H=v[M],V=0;if(S.live||(b=H.details)!==null&&b!==void 0&&b.live){var Q=this.mainDetails;if(S.fragments[0]||(S.deltaUpdateFailed=!0),S.deltaUpdateFailed||!Q)return;!H.details&&S.hasProgramDateTime&&Q.hasProgramDateTime?(Object(C.alignMediaPlaylistByPDT)(S,Q),V=S.fragments[0].start):V=this.alignPlaylists(S,H.details)}H.details=S,this.levelLastLoaded=M,!this.startFragRequested&&(this.mainDetails||!S.live)&&this.setStartPosition(H.details,V),this.state===N.State.WAITING_TRACK&&!this.waitForCdnTuneIn(S)&&(this.state=N.State.IDLE),this.tick()},f._handleFragmentLoadProgress=function(s){var a,b=s.frag,v=s.part,S=s.payload,M=this.config,H=this.trackId,V=this.levels;if(!V){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+b.sn+" of level "+b.level+" will not be buffered");return}var Q=V[H];console.assert(Q,"Audio track is defined on fragment load progress");var G=Q.details;console.assert(G,"Audio track details are defined on fragment load progress");var W=M.defaultAudioCodec||Q.audioCodec||"mp4a.40.2",q=this.transmuxer;q||(q=this.transmuxer=new k.default(this.hls,D.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var oe=this.initPTS[b.cc],fe=(a=b.initSegment)===null||a===void 0?void 0:a.data;if(oe!==void 0){var ve=!1,De=v?v.index:-1,Ee=De!==-1,_e=new T.ChunkMetadata(b.level,b.sn,b.stats.chunkCount,S.byteLength,De,Ee);q.push(S,fe,W,"",b,v,G.totalduration,ve,_e,oe)}else{o.logger.log("Unknown video PTS for cc "+b.cc+", waiting for video PTS before demuxing audio frag "+b.sn+" of ["+G.startSN+" ,"+G.endSN+"],track "+H);var Te=this.waitingData=this.waitingData||{frag:b,part:v,cache:new L.default,complete:!1},Ce=Te.cache;Ce.push(new Uint8Array(S)),this.waitingVideoCC=this.videoTrackCC,this.state=N.State.WAITING_INIT_PTS}},f._handleFragmentLoadComplete=function(s){if(this.waitingData){this.waitingData.complete=!0;return}l.prototype._handleFragmentLoadComplete.call(this,s)},f.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},f.onBufferCreated=function(s,a){var b=a.tracks.audio;b&&(this.mediaBuffer=b.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},f.onFragBuffered=function(s,a){var b=a.frag,v=a.part;if(b.type!==D.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(b)){this.warn("Fragment "+b.sn+(v?" p: "+v.index:"")+" of level "+b.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}b.sn!=="initSegment"&&(this.fragPrevious=b,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(I.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(b,v)},f.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(D.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 b=!0,v=this.getFwdBufferInfo(this.mediaBuffer,D.PlaylistLevelType.AUDIO);v&&v.len>.5&&(b=!this.reduceMaxBufferLength(v.len)),b&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,l.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},f.onBufferFlushed=function(s,a){var b=a.type;b===E.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},f._handleTransmuxComplete=function(s){var a,b="audio",v=this.hls,S=s.remuxResult,M=s.chunkMeta,H=this.getCurrentContext(M);if(!H){this.warn("The loading context changed while buffering fragment "+M.sn+" of level "+M.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(M.level);return}var V=H.frag,Q=H.part,G=S.audio,W=S.text,q=S.id3,oe=S.initSegment;if(this.fragContextChanged(V))return;if(this.state=N.State.PARSING,this.audioSwitch&&G&&this.completeAudioSwitch(),oe!=null&&oe.tracks&&(this._bufferInitSegment(oe.tracks,V,M),v.trigger(I.Events.FRAG_PARSING_INIT_SEGMENT,{frag:V,id:b,tracks:oe.tracks})),G){var fe=G.startPTS,ve=G.endPTS,De=G.startDTS,Ee=G.endDTS;Q&&(Q.elementaryStreams[E.ElementaryStreamTypes.AUDIO]={startPTS:fe,endPTS:ve,startDTS:De,endDTS:Ee}),V.setElementaryStreamInfo(E.ElementaryStreamTypes.AUDIO,fe,ve,De,Ee),this.bufferFragmentData(G,V,Q,M)}if(q!=null&&(a=q.samples)!==null&&a!==void 0&&a.length){var _e=c({frag:V,id:b},q);v.trigger(I.Events.FRAG_PARSING_METADATA,_e)}if(W){var Te=c({frag:V,id:b},W);v.trigger(I.Events.FRAG_PARSING_USERDATA,Te)}},f._bufferInitSegment=function(s,a,b){if(this.state!==N.State.PARSING)return;s.video&&delete s.video;var v=s.audio;if(!v)return;v.levelCodec=v.codec,v.id="audio",this.log("Init audio buffer, container:"+v.container+", codecs[parsed]=["+v.codec+"]"),this.hls.trigger(I.Events.BUFFER_CODECS,s);var S=v.initSegment;if(S!=null&&S.byteLength){var M={type:"audio",frag:a,part:null,chunkMeta:b,parent:a.type,data:S};this.hls.trigger(I.Events.BUFFER_APPENDING,M)}this.tick()},f.loadFragment=function(s,a,b){var v=this.fragmentTracker.getState(s);this.fragCurrent=s,(this.audioSwitch||v===B.FragmentState.NOT_LOADED||v===B.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,l.prototype.loadFragment.call(this,s,a,b)))},f.completeAudioSwitch=function(){var s=this.hls,a=this.media,b=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),l.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,s.trigger(I.Events.AUDIO_TRACK_SWITCHED,{id:b})},x}(N.default);$.default=m},"./src/controller/audio-track-controller.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/events.ts"),N=R("./src/errors.ts"),I=R("./src/controller/base-playlist-controller.ts"),z=R("./src/types/loader.ts");function B(k,T){for(var A=0;A=o.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var c=o[this.trackId];this.log("Now switching to audio-track index "+h);var d=o[h],_=d.id,y=d.groupId,m=y===void 0?"":y,l=d.name,x=d.type,f=d.url;if(this.trackId=h,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(X.Events.AUDIO_TRACK_SWITCHING,{id:_,groupId:m,name:l,type:x,url:f}),d.details&&!d.details.live)return;var p=this.switchParams(d.url,c==null?void 0:c.details);this.loadPlaylist(p)},A.selectInitialTrack=function(){var h=this.tracksInGroup;console.assert(h.length,"Initial audio track should be selected when tracks are known");var o=this.trackName,c=this.findTrackId(o)||this.findTrackId();c!==-1?this.setAudioTrack(c):(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}))},A.findTrackId=function(h){for(var o=this.tracksInGroup,c=0;cT.partTarget&&(d+=1)}if(Object(X.isFiniteNumber)(c))return new N.HlsUrlParameters(c,Object(X.isFiniteNumber)(d)?d:void 0,N.HlsSkip.No)}}},E.loadPlaylist=function(k){},E.shouldLoadTrack=function(k){return this.canLoad&&k&&!!k.url&&(!k.details||k.details.live)},E.playlistLoaded=function(k,T,A){var C=this,h=T.details,o=T.stats,c=o.loading.end?Math.max(0,self.performance.now()-o.loading.end):0;if(h.advancedDateTime=Date.now()-c,h.live||A!=null&&A.live){if(h.reloaded(A),A&&this.log("live playlist "+k+" "+(h.advanced?"REFRESHED "+h.lastPartSn+"-"+h.lastPartIndex:"MISSED")),A&&h.fragments.length>0&&Object(I.mergeDetails)(A,h),!this.canLoad||!h.live)return;var d,_=void 0,y=void 0;if(h.canBlockReload&&h.endSN&&h.advanced){var m=this.hls.config.lowLatencyMode,l=h.lastPartSn,x=h.endSN,f=h.lastPartIndex,p=f!==-1,s=l===x,a=m?0:f;p?(_=s?x+1:l,y=s?a:f+1):_=x+1;var b=h.age,v=b+h.ageHeader,S=Math.min(v-h.partTarget,h.targetduration*1.5);if(S>0){if(A&&S>A.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+A.tuneInGoal+" to: "+S+" with playlist age: "+h.age),S=0;else{var M=Math.floor(S/h.targetduration);if(_+=M,y!==void 0){var H=Math.round(S%h.targetduration/h.partTarget);y+=H}this.log("CDN Tune-in age: "+h.ageHeader+"s last advanced "+b.toFixed(2)+"s goal: "+S+" skip sn "+M+" to part "+y)}h.tuneInGoal=S}if(d=this.getDeliveryDirectives(h,T.deliveryDirectives,_,y),m||!s){this.loadPlaylist(d);return}}else d=this.getDeliveryDirectives(h,T.deliveryDirectives,_,y);var V=Object(I.computeReloadInterval)(h,o);_!==void 0&&h.canBlockReload&&(V-=h.partTarget||1),this.log("reload live playlist "+k+" in "+Math.round(V)+" ms"),this.timer=self.setTimeout(function(){return C.loadPlaylist(d)},V)}else this.clearTimer()},E.getDeliveryDirectives=function(k,T,A,C){var h=Object(N.getSkipValue)(k,A);return T!=null&&T.skip&&k.deltaUpdateFailed&&(A=T.msn,C=T.part,h=N.HlsSkip.No),new N.HlsUrlParameters(A,C,h)},E.retryLoadingOrFail=function(k){var T=this,A=this.hls.config,C=this.retryCount-1&&(h=k.context)!==null&&h!==void 0&&h.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+k.details+'"'),this.loadPlaylist();else{var o=Math.min(Math.pow(2,this.retryCount)*A.levelLoadingRetryDelay,A.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return T.loadPlaylist()},o),this.warn("retry playlist loading #"+this.retryCount+" in "+o+' ms after "'+k.details+'"')}}else this.warn('cannot recover from error "'+k.details+'"'),this.clearTimer(),k.fatal=!0;return C},D}()},"./src/controller/base-stream-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"State",function(){return x}),R.d($,"default",function(){return f});var X=R("./src/polyfills/number.ts"),N=R("./src/task-loop.ts"),I=R("./src/controller/fragment-tracker.ts"),z=R("./src/utils/buffer-helper.ts"),B=R("./src/utils/logger.ts"),O=R("./src/events.ts"),D=R("./src/errors.ts"),E=R("./src/types/transmuxer.ts"),L=R("./src/utils/mp4-tools.ts"),k=R("./src/utils/discontinuities.ts"),T=R("./src/controller/fragment-finders.ts"),A=R("./src/controller/level-helper.ts"),C=R("./src/loader/fragment-loader.ts"),h=R("./src/crypt/decrypter.ts"),o=R("./src/utils/time-ranges.ts"),c=R("./src/types/loader.ts");function d(p,s){for(var a=0;aoe;(Q0&&Q&&Q.key&&Q.iv&&Q.method==="AES-128"){var G=self.performance.now();return S.decrypter.webCryptoDecrypt(new Uint8Array(V),Q.key.buffer,Q.iv.buffer).then(function(W){var q=self.performance.now();return H.trigger(O.Events.FRAG_DECRYPTED,{frag:v,payload:W,stats:{tstart:G,tdecrypt:q}}),M.payload=W,M})}return M}).then(function(M){var H=S.fragCurrent,V=S.hls,Q=S.levels;if(!Q)throw new Error("init load aborted, missing levels");var G=Q[v.level].details;console.assert(G,"Level details are defined when init segment is loaded");var W=v.stats;S.state=x.IDLE,S.fragLoadError=0,v.data=new Uint8Array(M.payload),W.parsing.start=W.buffering.start=self.performance.now(),W.parsing.end=W.buffering.end=self.performance.now(),M.frag===H&&V.trigger(O.Events.FRAG_BUFFERED,{stats:W,frag:H,part:null,id:v.type}),S.tick()}).catch(function(M){S.warn(M),S.resetFragmentLoading(v)})},a.fragContextChanged=function(v){var S=this.fragCurrent;return!v||!S||v.level!==S.level||v.sn!==S.sn||v.urlId!==S.urlId},a.fragBufferedComplete=function(v,S){var M=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+v.type+" sn: "+v.sn+(S?" part: "+S.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level+" "+o.default.toString(z.BufferHelper.getBuffered(M))),this.state=x.IDLE,this.tick()},a._handleFragmentLoadComplete=function(v){var S=this.transmuxer;if(!S)return;var M=v.frag,H=v.part,V=v.partsLoaded,Q=!V||V.length===0||V.some(function(W){return!W}),G=new E.ChunkMetadata(M.level,M.sn,M.stats.chunkCount+1,0,H?H.index:-1,!Q);S.flush(G)},a._handleFragmentLoadProgress=function(v){},a._doFragLoad=function(v,S,M,H){var V=this;if(M===void 0&&(M=null),!this.levels)throw new Error("frag load aborted, missing levels");if(M=Math.max(v.start,M||0),this.config.lowLatencyMode&&S){var Q=S.partList;if(Q&&H){M>v.end&&S.fragmentHint&&(v=S.fragmentHint);var G=this.getNextPart(Q,v,M);if(G>-1){var W=Q[G];return this.log("Loading part sn: "+v.sn+" p: "+W.index+" cc: "+v.cc+" of playlist ["+S.startSN+"-"+S.endSN+"] parts [0-"+G+"-"+(Q.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(M.toFixed(3))),this.nextLoadPosition=W.start+W.duration,this.state=x.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:v,part:Q[G],targetBufferTime:M}),this.doFragPartsLoad(v,Q,G,H).catch(function(q){return V.handleFragLoadError(q)})}else if(!v.url||this.loadedEndOfParts(Q,M))return Promise.resolve(null)}}return this.log("Loading fragment "+v.sn+" cc: "+v.cc+" "+(S?"of ["+S.startSN+"-"+S.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(M.toFixed(3))),Object(X.isFiniteNumber)(v.sn)&&!this.bitrateTest&&(this.nextLoadPosition=v.start+v.duration),this.state=x.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:v,targetBufferTime:M}),this.fragmentLoader.load(v,H).catch(function(q){return V.handleFragLoadError(q)})},a.doFragPartsLoad=function(v,S,M,H){var V=this;return new Promise(function(Q,G){var W=[],q=function oe(fe){var ve=S[fe];V.fragmentLoader.loadPart(v,ve,H).then(function(De){W[ve.index]=De;var Ee=De.part;V.hls.trigger(O.Events.FRAG_LOADED,De);var _e=S[fe+1];if(_e&&_e.fragment===v)oe(fe+1);else return Q({frag:v,part:Ee,partsLoaded:W})}).catch(G)};q(M)})},a.handleFragLoadError=function(v){var S=v.data;return S&&S.details===D.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(S.frag,S.part):this.hls.trigger(O.Events.ERROR,S),null},a._handleTransmuxerFlush=function(v){var S=this.getCurrentContext(v);if(!S||this.state!==x.PARSING){this.fragCurrent||(this.state=x.IDLE);return}var M=S.frag,H=S.part,V=S.level,Q=self.performance.now();M.stats.parsing.end=Q,H&&(H.stats.parsing.end=Q),this.updateLevelTiming(M,H,V,v.partial)},a.getCurrentContext=function(v){var S=this.levels,M=v.level,H=v.sn,V=v.part;if(!S||!S[M])return this.warn("Levels object was unset while buffering fragment "+H+" of level "+M+". The current chunk will not be buffered."),null;var Q=S[M],G=V>-1?Object(A.getPartWith)(Q,H,V):null,W=G?G.fragment:Object(A.getFragmentWithSN)(Q,H,this.fragCurrent);return W?{frag:W,part:G,level:Q}:null},a.bufferFragmentData=function(v,S,M,H){if(!v||this.state!==x.PARSING)return;var V=v.data1,Q=v.data2,G=V;if(V&&Q&&(G=Object(L.appendUint8Array)(V,Q)),!G||!G.length)return;var W={type:v.type,frag:S,part:M,chunkMeta:H,parent:S.type,data:G};this.hls.trigger(O.Events.BUFFER_APPENDING,W),v.dropped&&v.independent&&!M&&this.flushBufferGap(S)},a.flushBufferGap=function(v){var S=this.media;if(!S)return;if(!z.BufferHelper.isBuffered(S,S.currentTime)){this.flushMainBuffer(0,v.start);return}var M=S.currentTime,H=z.BufferHelper.bufferInfo(S,M,0),V=v.duration,Q=Math.min(this.config.maxFragLookUpTolerance*2,V*.25),G=Math.max(Math.min(v.start-Q,H.end-Q),M+Q);v.start-G>Q&&this.flushMainBuffer(G,v.start)},a.getFwdBufferInfo=function(v,S){var M=this.config,H=this.getLoadPosition();if(!Object(X.isFiniteNumber)(H))return null;var V=z.BufferHelper.bufferInfo(v,H,M.maxBufferHole);if(V.len===0&&V.nextStart!==void 0){var Q=this.fragmentTracker.getBufferedFrag(H,S);if(Q&&V.nextStart=M?(S.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+S.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(v,S){var M,H,V=S.fragments,Q=V.length;if(!Q)return null;var G=this.config,W=V[0].start,q;if(S.live){var oe=G.initialLiveManifestSize;if(Q-1&&MM.start&&M.loaded},a.getInitialLiveFragment=function(v,S){var M=this.fragPrevious,H=null;if(M){if(v.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+M.programDateTime),H=Object(T.findFragmentByPDT)(S,M.endProgramDateTime,this.config.maxFragLookUpTolerance)),!H){var V=M.sn+1;if(V>=v.startSN&&V<=v.endSN){var Q=S[V-v.startSN];M.cc===Q.cc&&(H=Q,this.log("Live playlist, switching playlist, load frag with next SN: "+H.sn))}H||(H=Object(T.findFragWithCC)(S,M.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?v.fragmentEnd:v.edge,v))}return H},a.getFragmentAtPosition=function(v,S,M){var H=this.config,V=this.fragPrevious,Q=M.fragments,G=M.endSN,W=M.fragmentHint,q=H.maxFragLookUpTolerance,oe=!!(H.lowLatencyMode&&M.partList&&W);oe&&W&&!this.bitrateTest&&(Q=Q.concat(W),G=W.sn);var fe;if(vS-q?0:q;fe=Object(T.findFragmentByPTS)(V,Q,v,ve)}else fe=Q[Q.length-1];if(fe){var De=fe.sn-M.startSN,Ee=V&&fe.level===V.level,_e=Q[De+1],Te=this.fragmentTracker.getState(fe);if(Te===I.FragmentState.BACKTRACKED){fe=null;for(var Ce=De;Q[Ce]&&this.fragmentTracker.getState(Q[Ce])===I.FragmentState.BACKTRACKED;)V?fe=Q[Ce--]:fe=Q[--Ce];fe||(fe=_e)}else V&&fe.sn===V.sn&&!oe&&(Ee&&(fe.sn=Q-S.maxFragLookUpTolerance&&V<=G;if(H!==null&&M.duration>H&&(V"+v.startSN+" prev-sn: "+(V?V.sn:"na")+" fragments: "+G),fe}return W},a.waitForCdnTuneIn=function(v){var S=3;return v.live&&v.canBlockReload&&v.tuneInGoal>Math.max(v.partHoldBack,v.partTarget*S)},a.setStartPosition=function(v,S){var M=this.startPosition;if(M"+v))}}]),s}(N.default)},"./src/controller/buffer-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return T});var X=R("./src/polyfills/number.ts"),N=R("./src/events.ts"),I=R("./src/utils/logger.ts"),z=R("./src/errors.ts"),B=R("./src/utils/buffer-helper.ts"),O=R("./src/utils/mediasource-helper.ts"),D=R("./src/loader/fragment.ts"),E=R("./src/controller/buffer-operation-queue.ts"),L=Object(O.getMediaSource)(),k=/([ha]vc.)(?:\.[^.,]+)+/,T=function(){function A(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 c=o.hls,d=o.media,_=o.mediaSource;I.logger.log("[buffer-controller]: Media source opened"),d&&(o.updateMediaElementDuration(),c.trigger(N.Events.MEDIA_ATTACHED,{media:d})),_&&_.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 C=A.prototype;return C.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},C.destroy=function(){this.unregisterListeners(),this.details=null},C.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)},C.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)},C._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new E.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},C.onManifestParsed=function(o,c){var d=2;(c.audio&&!c.video||!c.altAudio)&&(d=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=d,this.details=null,I.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},C.onMediaAttaching=function(o,c){var d=this.media=c.media;if(d&&L){var _=this.mediaSource=new L;_.addEventListener("sourceopen",this._onMediaSourceOpen),_.addEventListener("sourceended",this._onMediaSourceEnded),_.addEventListener("sourceclose",this._onMediaSourceClose),d.src=self.URL.createObjectURL(_),this._objectUrl=d.src}},C.onMediaDetaching=function(){var o=this.media,c=this.mediaSource,d=this._objectUrl;if(c){if(I.logger.log("[buffer-controller]: media source detaching"),c.readyState==="open")try{c.endOfStream()}catch(_){I.logger.warn("[buffer-controller]: onMediaDetaching: "+_.message+" while calling endOfStream")}this.onBufferReset(),c.removeEventListener("sourceopen",this._onMediaSourceOpen),c.removeEventListener("sourceended",this._onMediaSourceEnded),c.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)},C.onBufferReset=function(){var o=this;this.getSourceBufferTypes().forEach(function(c){var d=o.sourceBuffer[c];try{d&&(o.removeBufferListeners(c),o.mediaSource&&o.mediaSource.removeSourceBuffer(d),o.sourceBuffer[c]=void 0)}catch(_){I.logger.warn("[buffer-controller]: Failed to reset the "+c+" buffer",_)}}),this._initSourceBuffer()},C.onBufferCodecs=function(o,c){var d=this,_=this.getSourceBufferTypes().length;if(Object.keys(c).forEach(function(y){if(_){var m=d.tracks[y];if(m&&typeof m.buffer.changeType=="function"){var l=c[y],x=l.codec,f=l.levelCodec,p=l.container,s=(m.levelCodec||m.codec).replace(k,"$1"),a=(f||x).replace(k,"$1");if(s!==a){var b=p+";codecs="+(f||x);d.appendChangeType(y,b)}}}else d.pendingTracks[y]=c[y]}),_)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},C.appendChangeType=function(o,c){var d=this,_=this.operationQueue,y={execute:function(){var l=d.sourceBuffer[o];l&&(I.logger.log("[buffer-controller]: changing "+o+" sourceBuffer type to "+c),l.changeType(c)),_.shiftAndExecuteNext(o)},onStart:function(){},onComplete:function(){},onError:function(l){I.logger.warn("[buffer-controller]: Failed to change "+o+" SourceBuffer type",l)}};_.append(y,o)},C.onBufferAppending=function(o,c){var d=this,_=this.hls,y=this.operationQueue,m=this.tracks,l=c.data,x=c.type,f=c.frag,p=c.part,s=c.chunkMeta,a=s.buffering[x],b=self.performance.now();a.start=b;var v=f.stats.buffering,S=p?p.stats.buffering:null;v.start===0&&(v.start=b),S&&S.start===0&&(S.start=b);var M=m.audio,H=x==="audio"&&s.id===1&&(M==null?void 0:M.container)==="audio/mpeg",V={execute:function(){if(a.executeStart=self.performance.now(),H){var G=d.sourceBuffer[x];if(G){var W=f.start-G.timestampOffset;Math.abs(W)>=.1&&(I.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+f.start+" (delta: "+W+") sn: "+f.sn+")"),G.timestampOffset=f.start)}}d.appendExecutor(l,x)},onStart:function(){},onComplete:function(){var G=self.performance.now();a.executeEnd=a.end=G,v.first===0&&(v.first=G),S&&S.first===0&&(S.first=G);var W=d.sourceBuffer,q={};for(var oe in W)q[oe]=B.BufferHelper.getBuffered(W[oe]);d.appendError=0,d.hls.trigger(N.Events.BUFFER_APPENDED,{type:x,frag:f,part:p,chunkMeta:s,parent:f.type,timeRanges:q})},onError:function(G){I.logger.error("[buffer-controller]: Error encountered while trying to append to the "+x+" SourceBuffer",G);var W={type:z.ErrorTypes.MEDIA_ERROR,parent:f.type,details:z.ErrorDetails.BUFFER_APPEND_ERROR,err:G,fatal:!1};G.code===DOMException.QUOTA_EXCEEDED_ERR?W.details=z.ErrorDetails.BUFFER_FULL_ERROR:(d.appendError++,W.details=z.ErrorDetails.BUFFER_APPEND_ERROR,d.appendError>_.config.appendErrorMaxRetry&&(I.logger.error("[buffer-controller]: Failed "+_.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),W.fatal=!0)),_.trigger(N.Events.ERROR,W)}};y.append(V,x)},C.onBufferFlushing=function(o,c){var d=this,_=this.operationQueue,y=function(l){return{execute:d.removeExecutor.bind(d,l,c.startOffset,c.endOffset),onStart:function(){},onComplete:function(){d.hls.trigger(N.Events.BUFFER_FLUSHED,{type:l})},onError:function(f){I.logger.warn("[buffer-controller]: Failed to remove from "+l+" SourceBuffer",f)}}};c.type?_.append(y(c.type),c.type):this.getSourceBufferTypes().forEach(function(m){_.append(y(m),m)})},C.onFragParsed=function(o,c){var d=this,_=c.frag,y=c.part,m=[],l=y?y.elementaryStreams:_.elementaryStreams;l[D.ElementaryStreamTypes.AUDIOVIDEO]?m.push("audiovideo"):(l[D.ElementaryStreamTypes.AUDIO]&&m.push("audio"),l[D.ElementaryStreamTypes.VIDEO]&&m.push("video"));var x=function(){var p=self.performance.now();_.stats.buffering.end=p,y&&(y.stats.buffering.end=p);var s=y?y.stats:_.stats;d.hls.trigger(N.Events.FRAG_BUFFERED,{frag:_,part:y,stats:s,id:_.type})};m.length===0&&I.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+_.type+" level: "+_.level+" sn: "+_.sn),this.blockBuffers(x,m)},C.onFragChanged=function(o,c){this.flushBackBuffer()},C.onBufferEos=function(o,c){var d=this,_=this.getSourceBufferTypes().reduce(function(y,m){var l=d.sourceBuffer[m];return(!c.type||c.type===m)&&(l&&!l.ended&&(l.ended=!0,I.logger.log("[buffer-controller]: "+m+" sourceBuffer now EOS"))),y&&!!(!l||l.ended)},!0);_&&this.blockBuffers(function(){var y=d.mediaSource;if(!y||y.readyState!=="open")return;y.endOfStream()})},C.onLevelUpdated=function(o,c){var d=c.details;if(!d.fragments.length)return;this.details=d,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},C.flushBackBuffer=function(){var o=this.hls,c=this.details,d=this.media,_=this.sourceBuffer;if(!d||c===null)return;var y=this.getSourceBufferTypes();if(!y.length)return;var m=c.live&&o.config.liveBackBufferLength!==null?o.config.liveBackBufferLength:o.config.backBufferLength;if(!Object(X.isFiniteNumber)(m)||m<0)return;var l=d.currentTime,x=c.levelTargetDuration,f=Math.max(m,x),p=Math.floor(l/x)*x-f;y.forEach(function(s){var a=_[s];if(a){var b=B.BufferHelper.getBuffered(a);b.length>0&&p>b.start(0)&&(o.trigger(N.Events.BACK_BUFFER_REACHED,{bufferEnd:p}),c.live&&o.trigger(N.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:p}),o.trigger(N.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:p,type:s}))}})},C.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var o=this.details,c=this.hls,d=this.media,_=this.mediaSource,y=o.fragments[0].start+o.totalduration,m=d.duration,l=Object(X.isFiniteNumber)(_.duration)?_.duration:0;o.live&&c.config.liveDurationInfinity?(I.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),_.duration=Infinity,this.updateSeekableRange(o)):(y>l&&y>m||!Object(X.isFiniteNumber)(m))&&(I.logger.log("[buffer-controller]: Updating Media Source duration to "+y.toFixed(3)),_.duration=y)},C.updateSeekableRange=function(o){var c=this.mediaSource,d=o.fragments,_=d.length;if(_&&o.live&&c!==null&&c!==void 0&&c.setLiveSeekableRange){var y=Math.max(0,d[0].start),m=Math.max(y,y+o.totalduration);c.setLiveSeekableRange(y,m)}},C.checkPendingTracks=function(){var o=this.bufferCodecEventsExpected,c=this.operationQueue,d=this.pendingTracks,_=Object.keys(d).length;if(_&&!o||_===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(m){c.executeNext(m)})}},C.createSourceBuffers=function(o){var c=this.sourceBuffer,d=this.mediaSource;if(!d)throw Error("createSourceBuffers called when mediaSource was null");var _=0;for(var y in o)if(!c[y]){var m=o[y];if(!m)throw Error("source buffer exists for track "+y+", however track does not");var l=m.levelCodec||m.codec,x=m.container+";codecs="+l;I.logger.log("[buffer-controller]: creating sourceBuffer("+x+")");try{var f=c[y]=d.addSourceBuffer(x),p=y;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[y]={buffer:f,codec:l,container:m.container,levelCodec:m.levelCodec,id:m.id},_++}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})}}_&&this.hls.trigger(N.Events.BUFFER_CREATED,{tracks:this.tracks})},C._onSBUpdateStart=function(o){var c=this.operationQueue,d=c.current(o);d.onStart()},C._onSBUpdateEnd=function(o){var c=this.operationQueue,d=c.current(o);d.onComplete(),c.shiftAndExecuteNext(o)},C._onSBUpdateError=function(o,c){I.logger.error("[buffer-controller]: "+o+" SourceBuffer error",c),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(c)},C.removeExecutor=function(o,c,d){var _=this.media,y=this.mediaSource,m=this.operationQueue,l=this.sourceBuffer,x=l[o];if(!_||!y||!x){I.logger.warn("[buffer-controller]: Attempting to remove from the "+o+" SourceBuffer, but it does not exist"),m.shiftAndExecuteNext(o);return}var f=Object(X.isFiniteNumber)(_.duration)?_.duration:Infinity,p=Object(X.isFiniteNumber)(y.duration)?y.duration:Infinity,s=Math.max(0,c),a=Math.min(d,f,p);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)):m.shiftAndExecuteNext(o)},C.appendExecutor=function(o,c){var d=this.operationQueue,_=this.sourceBuffer,y=_[c];if(!y){I.logger.warn("[buffer-controller]: Attempting to append to the "+c+" SourceBuffer, but it does not exist"),d.shiftAndExecuteNext(c);return}y.ended=!1,console.assert(!y.updating,c+" sourceBuffer must not be updating"),y.appendBuffer(o)},C.blockBuffers=function(o,c){var d=this;if(c===void 0&&(c=this.getSourceBufferTypes()),!c.length){I.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(o);return}var _=this.operationQueue,y=c.map(function(m){return _.appendBlocker(m)});Promise.all(y).then(function(){o(),c.forEach(function(m){var l=d.sourceBuffer[m];(!l||!l.updating)&&_.shiftAndExecuteNext(m)})})},C.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},C.addBufferListener=function(o,c,d){var _=this.sourceBuffer[o];if(!_)return;var y=d.bind(this,o);this.listeners[o].push({event:c,listener:y}),_.addEventListener(c,y)},C.removeBufferListeners=function(o){var c=this.sourceBuffer[o];if(!c)return;this.listeners[o].forEach(function(d){c.removeEventListener(d.event,d.listener)})},A}()},"./src/controller/buffer-operation-queue.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return N});var X=R("./src/utils/logger.ts"),N=function(){function I(B){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=B}var z=I.prototype;return z.append=function(O,D){var E=this.queues[D];E.push(O),E.length===1&&this.buffers[D]&&this.executeNext(D)},z.insertAbort=function(O,D){var E=this.queues[D];E.unshift(O),this.executeNext(D)},z.appendBlocker=function(O){var D,E=new Promise(function(k){D=k}),L={execute:D,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(L,O),E},z.executeNext=function(O){var D=this.buffers,E=this.queues,L=D[O],k=E[O];if(k.length){var T=k[0];try{T.execute()}catch(A){X.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),T.onError(A),(!L||!L.updating)&&(k.shift(),this.executeNext(O))}}},z.shiftAndExecuteNext=function(O){this.queues[O].shift(),this.executeNext(O)},z.current=function(O){return this.queues[O][0]},I}()},"./src/controller/cap-level-controller.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/events.ts");function N(B,O){for(var D=0;D0&&this.mediaWidth>0){var E=this.hls.levels;if(E.length){var L=this.hls;L.autoLevelCapping=this.getMaxLevel(E.length-1),L.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=L.autoLevelCapping}}},O.getMaxLevel=function(E){var L=this,k=this.hls.levels;if(!k.length)return-1;var T=k.filter(function(A,C){return B.isLevelAllowed(C,L.restrictedLevels)&&C<=E});return this.clientRect=null,B.getMaxLevelByMediaSize(T,this.mediaWidth,this.mediaHeight)},O.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()},O.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},O.getDimensions=function(){if(this.clientRect)return this.clientRect;var E=this.media,L={width:0,height:0};if(E){var k=E.getBoundingClientRect();L.width=k.width,L.height=k.height,!L.width&&!L.height&&(L.width=k.right-k.left||E.width||0,L.height=k.bottom-k.top||E.height||0)}return this.clientRect=L,L},B.isLevelAllowed=function(E,L){return L===void 0&&(L=[]),L.indexOf(E)===-1},B.getMaxLevelByMediaSize=function(E,L,k){if(!E||!E.length)return-1;for(var T=function(c,d){return d?c.width!==d.width||c.height!==d.height:!0},A=E.length-1,C=0;C=L||h.height>=k)&&T(h,E[C+1])){A=C;break}}return A},I(B,[{key:"mediaWidth",get:function(){return this.getDimensions().width*B.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*B.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var E=1;try{E=self.devicePixelRatio}catch(L){}return E}}]),B}();$.default=z},"./src/controller/cmcd-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return T});var X=R("./src/events.ts"),N=R("./src/types/cmcd.ts"),I=R("./src/utils/buffer-helper.ts"),z=R("./src/utils/logger.ts");function B(A,C){for(var h=0;h=A.length?{done:!0}:{done:!1,value:A[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 E(A,C){if(!A)return;if(typeof A=="string")return L(A,C);var h=Object.prototype.toString.call(A).slice(8,-1);if(h==="Object"&&A.constructor&&(h=A.constructor.name),h==="Map"||h==="Set")return Array.from(A);if(h==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(h))return L(A,C)}function L(A,C){(C==null||C>A.length)&&(C=A.length);for(var h=0,o=new Array(C);hc&&(c=m.bitrate)}return c>0?c:NaN},C.getBufferLength=function(o){var c=this.hls.media,d=o===N.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!d||!c)return NaN;var _=I.BufferHelper.bufferInfo(d,c.currentTime,this.config.maxBufferHole);return _.len*1e3},C.createPlaylistLoader=function(){var o=this.config.pLoader,c=this.applyPlaylistData,d=o||this.config.loader;return function(){function _(m){this.loader=void 0,this.loader=new d(m)}var y=_.prototype;return y.destroy=function(){this.loader.destroy()},y.abort=function(){this.loader.abort()},y.load=function(l,x,f){c(l),this.loader.load(l,x,f)},O(_,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),_}()},C.createFragmentLoader=function(){var o=this.config.fLoader,c=this.applyFragmentData,d=o||this.config.loader;return function(){function _(m){this.loader=void 0,this.loader=new d(m)}var y=_.prototype;return y.destroy=function(){this.loader.destroy()},y.abort=function(){this.loader.abort()},y.load=function(l,x,f){c(l),this.loader.load(l,x,f)},O(_,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),_}()},A.uuid=function(){var o=URL.createObjectURL(new Blob),c=o.toString();return URL.revokeObjectURL(o),c.substr(c.lastIndexOf("/")+1)},A.serialize=function(o){for(var c=[],d=function(H){return!Number.isNaN(H)&&H!=null&&H!==""&&H!==!1},_=function(H){return Math.round(H)},y=function(H){return _(H/100)*100},m=function(H){return encodeURIComponent(H)},l={br:_,d:_,bl:y,dl:y,mtp:y,nor:m,rtp:y,tb:_},x=Object.keys(o||{}).sort(),f=D(x),p;!(p=f()).done;){var s=p.value,a=o[s];if(!d(a))continue;if(s==="v"&&a===1)continue;if(s=="pr"&&a===1)continue;var b=l[s];b&&(a=b(a));var v=typeof a,S=void 0;s==="ot"||s==="sf"||s==="st"?S=s+"="+a:v==="boolean"?S=s:v==="number"?S=s+"="+a:S=s+"="+JSON.stringify(a),c.push(S)}return c.join(",")},A.toHeaders=function(o){for(var c=Object.keys(o),d={},_=["Object","Request","Session","Status"],y=[{},{},{},{}],m={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},l=0,x=c;lD){this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var m=D-this._requestLicenseFailureCount+1;I.logger.warn("Retrying license request, "+m+" attempts left"),this._requestLicense(c,d)}break}},A._generateLicenseRequestChallenge=function(h,o){switch(h.mediaKeySystemDomain){case z.KeySystems.WIDEVINE:return o}throw new Error("unsupported key-system: "+h.mediaKeySystemDomain)},A._requestLicense=function(h,o){I.logger.log("Requesting content license for key-system");var c=this._mediaKeysList[0];if(!c){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(c.mediaKeySystemDomain),_=this._createLicenseXhr(d,h,o);I.logger.log("Sending license request to URL: "+d);var y=this._generateLicenseRequestChallenge(c,h);_.send(y)}catch(m){I.logger.error("Failure requesting DRM license: "+m),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},A.onMediaAttached=function(h,o){if(!this._emeEnabled)return;var c=o.media;this._media=c,c.addEventListener("encrypted",this._onMediaEncrypted)},A.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(c){if(c.mediaKeysSession)return c.mediaKeysSession.close().catch(function(){})})).then(function(){return h.setMediaKeys(null)}).catch(function(){})},A.onManifestParsed=function(h,o){if(!this._emeEnabled)return;var c=o.levels.map(function(_){return _.audioCodec}).filter(function(_){return!!_}),d=o.levels.map(function(_){return _.videoCodec}).filter(function(_){return!!_});this._attemptKeySystemAccess(z.KeySystems.WIDEVINE,c,d)},O(T,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),T}();$.default=k},"./src/controller/fps-controller.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/events.ts"),N=R("./src/utils/logger.ts"),I=function(){function z(O){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=O,this.registerListeners()}var B=z.prototype;return B.setStreamController=function(D){this.streamController=D},B.registerListeners=function(){this.hls.on(X.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},B.unregisterListeners=function(){this.hls.off(X.Events.MEDIA_ATTACHING,this.onMediaAttaching)},B.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},B.onMediaAttaching=function(D,E){var L=this.hls.config;if(L.capLevelOnFPSDrop){var k=E.media instanceof self.HTMLVideoElement?E.media:null;this.media=k,k&&typeof k.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),L.fpsDroppedMonitoringPeriod)}},B.checkFPS=function(D,E,L){var k=performance.now();if(E){if(this.lastTime){var T=k-this.lastTime,A=L-this.lastDroppedFrames,C=E-this.lastDecodedFrames,h=1e3*A/T,o=this.hls;if(o.trigger(X.Events.FPS_DROP,{currentDropped:A,currentDecoded:C,totalDroppedFrames:L}),h>0&&A>o.config.fpsDroppedMonitoringThreshold*C){var c=o.currentLevel;N.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(o.autoLevelCapping===-1||o.autoLevelCapping>=c)&&(c=c-1,o.trigger(X.Events.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:o.currentLevel}),o.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=k,this.lastDroppedFrames=L,this.lastDecodedFrames=E}},B.checkFPSInterval=function(){var D=this.media;if(D)if(this.isVideoPlaybackQualityAvailable){var E=D.getVideoPlaybackQuality();this.checkFPS(D,E.totalVideoFrames,E.droppedVideoFrames)}else this.checkFPS(D,D.webkitDecodedFrameCount,D.webkitDroppedFrameCount)},z}();$.default=I},"./src/controller/fragment-finders.ts":function(ae,$,R){"use strict";R.r($),R.d($,"findFragmentByPDT",function(){return I}),R.d($,"findFragmentByPTS",function(){return z}),R.d($,"fragmentWithinToleranceTest",function(){return B}),R.d($,"pdtWithinToleranceTest",function(){return O}),R.d($,"findFragWithCC",function(){return D});var X=R("./src/polyfills/number.ts"),N=R("./src/utils/binary-search.ts");function I(E,L,k){if(L===null||!Array.isArray(E)||!E.length||!Object(X.isFiniteNumber)(L))return null;var T=E[0].programDateTime;if(L<(T||0))return null;var A=E[E.length-1].endProgramDateTime;if(L>=(A||0))return null;k=k||0;for(var C=0;CE&&k.start?-1:0}function O(E,L,k){var T=Math.min(L,k.duration+(k.deltaPTS?k.deltaPTS:0))*1e3,A=k.endProgramDateTime||0;return A-T>E}function D(E,L){return N.default.search(E,function(k){return k.ccL?-1:0})}},"./src/controller/fragment-tracker.ts":function(ae,$,R){"use strict";R.r($),R.d($,"FragmentState",function(){return I}),R.d($,"FragmentTracker",function(){return z});var X=R("./src/events.ts"),N=R("./src/types/loader.ts"),I;(function(D){D.NOT_LOADED="NOT_LOADED",D.BACKTRACKED="BACKTRACKED",D.APPENDING="APPENDING",D.PARTIAL="PARTIAL",D.OK="OK"})(I||(I={}));var z=function(){function D(L){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=L,this._registerListeners()}var E=D.prototype;return E._registerListeners=function(){var k=this.hls;k.on(X.Events.BUFFER_APPENDED,this.onBufferAppended,this),k.on(X.Events.FRAG_BUFFERED,this.onFragBuffered,this),k.on(X.Events.FRAG_LOADED,this.onFragLoaded,this)},E._unregisterListeners=function(){var k=this.hls;k.off(X.Events.BUFFER_APPENDED,this.onBufferAppended,this),k.off(X.Events.FRAG_BUFFERED,this.onFragBuffered,this),k.off(X.Events.FRAG_LOADED,this.onFragLoaded,this)},E.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},E.getAppendedFrag=function(k,T){if(T===N.PlaylistLevelType.MAIN){var A=this.activeFragment,C=this.activeParts;if(!A)return null;if(C)for(var h=C.length;h--;){var o=C[h],c=o?o.end:A.appendedPTS;if(o.start<=k&&c!==void 0&&k<=c)return h>9&&(this.activeParts=C.slice(h-9)),o}else if(A.start<=k&&A.appendedPTS!==void 0&&k<=A.appendedPTS)return A}return this.getBufferedFrag(k,T)},E.getBufferedFrag=function(k,T){for(var A=this.fragments,C=Object.keys(A),h=C.length;h--;){var o=A[C[h]];if((o==null?void 0:o.body.type)===T&&o.buffered){var c=o.body;if(c.start<=k&&k<=c.end)return c}}return null},E.detectEvictedFragments=function(k,T,A){var C=this;Object.keys(this.fragments).forEach(function(h){var o=C.fragments[h];if(!o)return;if(!o.buffered){o.body.type===A&&C.removeFragment(o.body);return}var c=o.range[k];if(!c)return;c.time.some(function(d){var _=!C.isTimeBuffered(d.startPTS,d.endPTS,T);return _&&C.removeFragment(o.body),_})})},E.detectPartialFragments=function(k){var T=this,A=this.timeRanges,C=k.frag,h=k.part;if(!A||C.sn==="initSegment")return;var o=O(C),c=this.fragments[o];if(!c)return;Object.keys(A).forEach(function(d){var _=C.elementaryStreams[d];if(!_)return;var y=A[d],m=h!==null||_.partial===!0;c.range[d]=T.getBufferedTimes(C,h,m,y)}),c.backtrack=c.loaded=null,Object.keys(c.range).length?c.buffered=!0:this.removeFragment(c.body)},E.fragBuffered=function(k){var T=O(k),A=this.fragments[T];A&&(A.backtrack=A.loaded=null,A.buffered=!0)},E.getBufferedTimes=function(k,T,A,C){for(var h={time:[],partial:A},o=T?T.start:k.start,c=T?T.end:k.end,d=k.minEndPTS||c,_=k.maxStartPTS||o,y=0;y=m&&d<=l){h.time.push({startPTS:Math.max(o,C.start(y)),endPTS:Math.min(c,C.end(y))});break}else if(om)h.partial=!0,h.time.push({startPTS:Math.max(o,C.start(y)),endPTS:Math.min(c,C.end(y))});else if(c<=m)break}return h},E.getPartialFragment=function(k){var T=null,A,C,h,o=0,c=this.bufferPadding,d=this.fragments;return Object.keys(d).forEach(function(_){var y=d[_];if(!y)return;B(y)&&(C=y.body.start-c,h=y.body.end+c,k>=C&&k<=h&&(A=Math.min(k-C,h-k),o<=A&&(T=y.body,o=A)))}),T},E.getState=function(k){var T=O(k),A=this.fragments[T];return A?A.buffered?B(A)?I.PARTIAL:I.OK:A.backtrack?I.BACKTRACKED:I.APPENDING:I.NOT_LOADED},E.backtrack=function(k,T){var A=O(k),C=this.fragments[A];if(!C||C.backtrack)return null;var h=C.backtrack=T||C.loaded;return C.loaded=null,h},E.getBacktrackData=function(k){var T=O(k),A=this.fragments[T];if(A){var C,h=A.backtrack;if(h!=null&&(C=h.payload)!==null&&C!==void 0&&C.byteLength)return h;this.removeFragment(k)}return null},E.isTimeBuffered=function(k,T,A){for(var C,h,o=0;o=C&&T<=h)return!0;if(T<=C)return!1}return!1},E.onFragLoaded=function(k,T){var A=T.frag,C=T.part;if(A.sn==="initSegment"||A.bitrateTest||C)return;var h=O(A);this.fragments[h]={body:A,loaded:T,backtrack:null,buffered:!1,range:Object.create(null)}},E.onBufferAppended=function(k,T){var A=this,C=T.frag,h=T.part,o=T.timeRanges;if(C.type===N.PlaylistLevelType.MAIN)if(this.activeFragment=C,h){var c=this.activeParts;c||(this.activeParts=c=[]),c.push(h)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach(function(d){var _=o[d];if(A.detectEvictedFragments(d,_),!h)for(var y=0;y<_.length;y++)C.appendedPTS=Math.max(_.end(y),C.appendedPTS||0)})},E.onFragBuffered=function(k,T){this.detectPartialFragments(T)},E.hasFragment=function(k){var T=O(k);return!!this.fragments[T]},E.removeFragmentsInRange=function(k,T,A){var C=this;Object.keys(this.fragments).forEach(function(h){var o=C.fragments[h];if(!o)return;if(o.buffered){var c=o.body;c.type===A&&c.startk&&C.removeFragment(c)}})},E.removeFragment=function(k){var T=O(k);k.stats.loaded=0,k.clearElementaryStreamInfo(),delete this.fragments[T]},E.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},D}();function B(D){var E,L;return D.buffered&&(((E=D.range.video)===null||E===void 0?void 0:E.partial)||((L=D.range.audio)===null||L===void 0?void 0:L.partial))}function O(D){return D.type+"_"+D.level+"_"+D.urlId+"_"+D.sn}},"./src/controller/gap-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"STALL_MINIMUM_DURATION_MS",function(){return B}),R.d($,"MAX_START_GAP_JUMP",function(){return O}),R.d($,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return D}),R.d($,"SKIP_BUFFER_RANGE_START",function(){return E}),R.d($,"default",function(){return L});var X=R("./src/utils/buffer-helper.ts"),N=R("./src/errors.ts"),I=R("./src/events.ts"),z=R("./src/utils/logger.ts"),B=250,O=2,D=.1,E=.05,L=function(){function k(A,C,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=A,this.media=C,this.fragmentTracker=h,this.hls=o}var T=k.prototype;return T.destroy=function(){this.hls=this.fragmentTracker=this.media=null},T.poll=function(C){var h=this.config,o=this.media,c=this.stalled,d=o.currentTime,_=o.seeking,y=this.seeking&&!_,m=!this.seeking&&_;if(this.seeking=_,d!==C){if(this.moved=!0,c!==null){if(this.stallReported){var l=self.performance.now()-c;z.logger.warn("playback not stuck anymore @"+d+", after "+Math.round(l)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((m||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),f=x.len>0,p=x.nextStart||0;if(!f&&!p)return;if(_){var s=x.len>O,a=!p||p-d>O&&!this.fragmentTracker.getPartialFragment(d);if(s||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var b,v=Math.max(p,x.start||0)-d,S=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,M=S==null||((b=S.details)===null||b===void 0)?void 0:b.live,H=M?S.details.targetduration*2:O;if(v>0&&v<=H){this._trySkipBufferHole(null);return}}var V=self.performance.now();if(c===null){this.stalled=V;return}var Q=V-c;!_&&Q>=B&&this._reportStall(x.len);var G=X.BufferHelper.bufferInfo(o,d,h.maxBufferHole);this._tryFixBufferStall(G,Q)},T._tryFixBufferStall=function(C,h){var o=this.config,c=this.fragmentTracker,d=this.media,_=d.currentTime,y=c.getPartialFragment(_);if(y){var m=this._trySkipBufferHole(y);if(m)return}C.len>o.maxBufferHole&&h>o.highBufferWatchdogPeriod*1e3&&(z.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},T._reportStall=function(C){var h=this.hls,o=this.media,c=this.stallReported;c||(this.stallReported=!0,z.logger.warn("Playback stalling at @"+o.currentTime+" due to low buffer (buffer="+C+")"),h.trigger(I.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:C}))},T._trySkipBufferHole=function(C){for(var h=this.config,o=this.hls,c=this.media,d=c.currentTime,_=0,y=X.BufferHelper.getBuffered(c),m=0;m=_&&d.05&&this.forwardBufferLength>1){var m=Math.min(2,Math.max(1,o)),l=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;k.playbackRate=Math.min(m,Math.max(1,l))}else k.playbackRate!==1&&k.playbackRate!==0&&(k.playbackRate=1)},E.estimateLiveEdge=function(){var k=this.levelDetails;return k===null?null:k.edge+k.age},E.computeLatency=function(){var k=this.estimateLiveEdge();return k===null?null:k-this.currentTime},B(D,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var k=this.config,T=this.levelDetails;return k.liveMaxLatencyDuration!==void 0?k.liveMaxLatencyDuration:T?k.liveMaxLatencyDurationCount*T.targetduration:0}},{key:"targetLatency",get:function(){var k=this.levelDetails;if(k===null)return null;var T=k.holdBack,A=k.partHoldBack,C=k.targetduration,h=this.config,o=h.liveSyncDuration,c=h.liveSyncDurationCount,d=h.lowLatencyMode,_=this.hls.userConfig,y=d&&A||T;(_.liveSyncDuration||_.liveSyncDurationCount||y===0)&&(y=o!==void 0?o:c*C);var m=C,l=1;return y+Math.min(this.stallCount*l,m)}},{key:"liveSyncPosition",get:function(){var k=this.estimateLiveEdge(),T=this.targetLatency,A=this.levelDetails;if(k===null||T===null||A===null)return null;var C=A.edge,h=k-T-this.edgeStalled,o=C-A.totalduration,c=C-(this.config.lowLatencyMode&&A.partTarget||A.targetduration);return Math.min(Math.max(o,h),c)}},{key:"drift",get:function(){var k=this.levelDetails;return k===null?1:k.drift}},{key:"edgeStalled",get:function(){var k=this.levelDetails;if(k===null)return 0;var T=(this.config.lowLatencyMode&&k.partTarget||k.targetduration)*3;return Math.max(k.age-T,0)}},{key:"forwardBufferLength",get:function(){var k=this.media,T=this.levelDetails;if(!k||!T)return 0;var A=k.buffered.length;return A?k.buffered.end(A-1):T.edge-this.currentTime}}]),D}()},"./src/controller/level-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return h});var X=R("./src/types/level.ts"),N=R("./src/events.ts"),I=R("./src/errors.ts"),z=R("./src/utils/codecs.ts"),B=R("./src/controller/level-helper.ts"),O=R("./src/controller/base-playlist-controller.ts"),D=R("./src/types/loader.ts");function E(){return E=Object.assign||function(o){for(var c=1;c0){p=l[0].bitrate,l.sort(function(Q,G){return Q.bitrate-G.bitrate}),this._levels=l;for(var M=0;Mthis.hls.config.fragLoadingMaxRetry&&(s=m.frag.level)):s=m.frag.level}break;case I.ErrorDetails.LEVEL_LOAD_ERROR:case I.ErrorDetails.LEVEL_LOAD_TIMEOUT:l&&(l.deliveryDirectives&&(p=!1),s=l.level),f=!0;break;case I.ErrorDetails.REMUX_ALLOC_ERROR:s=m.level,f=!0;break}s!==void 0&&this.recoverLevel(m,s,f,p)},d.recoverLevel=function(y,m,l,x){var f=y.details,p=this._levels[m];if(p.loadError++,l){var s=this.retryLoadingOrFail(y);if(s)y.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(x){var a=p.url.length;if(a>1&&p.loadError1){var x=(m.urlId+1)%l;this.warn("Switching to redundant URL-id "+x),this._levels.forEach(function(f){f.urlId=x}),this.level=y}},d.onFragLoaded=function(y,m){var l=m.frag;if(l!==void 0&&l.type===D.PlaylistLevelType.MAIN){var x=this._levels[l.level];x!==void 0&&(x.fragmentError=0,x.loadError=0)}},d.onLevelLoaded=function(y,m){var l,x=m.level,f=m.details,p=this._levels[x];if(!p){var s;this.warn("Invalid level index "+x),(s=m.deliveryDirectives)!==null&&s!==void 0&&s.skip&&(f.deltaUpdateFailed=!0);return}x===this.currentLevelIndex?(p.fragmentError===0&&(p.loadError=0,this.retryCount=0),this.playlistLoaded(x,m,p.details)):(l=m.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(f.deltaUpdateFailed=!0)},d.onAudioTrackSwitched=function(y,m){var l=this.hls.levels[this.currentLevelIndex];if(!l)return;if(l.audioGroupIds){for(var x=-1,f=this.hls.audioTracks[m.id].groupId,p=0;p0){var x=l.urlId,f=l.url[x];if(y)try{f=y.addDirectives(f)}catch(p){this.warn("Could not construct new URL with HLS Delivery Directives: "+p)}this.log("Attempt loading level index "+m+(y?" at sn "+y.msn+" part "+y.part:"")+" with URL-id "+x+" "+f),this.clearTimer(),this.hls.trigger(N.Events.LEVEL_LOADING,{url:f,level:m,id:x,deliveryDirectives:y||null})}},d.removeLevel=function(y,m){var l=function(p,s){return s!==m},x=this._levels.filter(function(f,p){return p!==y?!0:f.url.length>1&&m!==void 0?(f.url=f.url.filter(l),f.audioGroupIds&&(f.audioGroupIds=f.audioGroupIds.filter(l)),f.textGroupIds&&(f.textGroupIds=f.textGroupIds.filter(l)),f.urlId=0,!0):!1}).map(function(f,p){var s=f.details;return s!=null&&s.fragments&&s.fragments.forEach(function(a){a.level=p}),f});this._levels=x,this.hls.trigger(N.Events.LEVELS_UPDATED,{levels:x})},k(c,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(y){var m,l=this._levels;if(l.length===0)return;if(this.currentLevelIndex===y&&(m=l[y])!==null&&m!==void 0&&m.details)return;if(y<0||y>=l.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,l.length-1)}this.clearTimer();var f=this.currentLevelIndex,p=l[f],s=l[y];this.log("switching to level "+y+" from "+f),this.currentLevelIndex=y;var a=E({},s,{level:y,maxBitrate:s.maxBitrate,uri:s.uri,urlId:s.urlId});delete a._urlId,this.hls.trigger(N.Events.LEVEL_SWITCHING,a);var b=s.details;if(!b||b.live){var v=this.switchParams(s.uri,p==null?void 0:p.details);this.loadPlaylist(v)}}},{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)}}]),c}(O.default)},"./src/controller/level-helper.ts":function(ae,$,R){"use strict";R.r($),R.d($,"addGroupId",function(){return I}),R.d($,"assignTrackIdsByGroup",function(){return z}),R.d($,"updatePTS",function(){return B}),R.d($,"updateFragPTSDTS",function(){return D}),R.d($,"mergeDetails",function(){return E}),R.d($,"mapPartIntersection",function(){return L}),R.d($,"mapFragmentIntersection",function(){return k}),R.d($,"adjustSliding",function(){return T}),R.d($,"addSliding",function(){return A}),R.d($,"computeReloadInterval",function(){return C}),R.d($,"getFragmentWithSN",function(){return h}),R.d($,"getPartWith",function(){return o});var X=R("./src/polyfills/number.ts"),N=R("./src/utils/logger.ts");function I(c,d,_){switch(d){case"audio":c.audioGroupIds||(c.audioGroupIds=[]),c.audioGroupIds.push(_);break;case"text":c.textGroupIds||(c.textGroupIds=[]),c.textGroupIds.push(_);break}}function z(c){var d={};c.forEach(function(_){var y=_.groupId||"";_.id=d[y]=d[y]||0,d[y]++})}function B(c,d,_){var y=c[d],m=c[_];O(y,m)}function O(c,d){var _=d.startPTS;if(Object(X.isFiniteNumber)(_)){var y=0,m;d.sn>c.sn?(y=_-c.start,m=c):(y=c.start-_,m=d),m.duration!==y&&(m.duration=y)}else if(d.sn>c.sn){var l=c.cc===d.cc;l&&c.minEndPTS?d.start=c.start+(c.minEndPTS-c.start):d.start=c.start+c.duration}else d.start=Math.max(c.start-d.duration,0)}function D(c,d,_,y,m,l){var x=y-_;x<=0&&(N.logger.warn("Fragment should have a positive duration",d),y=_+d.duration,l=m+d.duration);var f=_,p=y,s=d.startPTS,a=d.endPTS;if(Object(X.isFiniteNumber)(s)){var b=Math.abs(s-_);Object(X.isFiniteNumber)(d.deltaPTS)?d.deltaPTS=Math.max(b,d.deltaPTS):d.deltaPTS=b,f=Math.max(_,s),_=Math.min(_,s),m=Math.min(m,d.startDTS),p=Math.min(y,a),y=Math.max(y,a),l=Math.max(l,d.endDTS)}d.duration=y-_;var v=_-d.start;d.appendedPTS=y,d.start=d.startPTS=_,d.maxStartPTS=f,d.startDTS=m,d.endPTS=y,d.minEndPTS=p,d.endDTS=l;var S=d.sn;if(!c||Sc.endSN)return 0;var M,H=S-c.startSN,V=c.fragments;for(V[H]=d,M=H;M>0;M--)O(V[M],V[M-1]);for(M=H;M=0;m--){var l=y[m].initSegment;if(l){_=l;break}}c.fragmentHint&&delete c.fragmentHint.endPTS;var x=0,f;if(k(c,d,function(M,H){M.relurl&&(x=M.cc-H.cc),Object(X.isFiniteNumber)(M.startPTS)&&Object(X.isFiniteNumber)(M.endPTS)&&(H.start=H.startPTS=M.startPTS,H.startDTS=M.startDTS,H.appendedPTS=M.appendedPTS,H.maxStartPTS=M.maxStartPTS,H.endPTS=M.endPTS,H.endDTS=M.endDTS,H.minEndPTS=M.minEndPTS,H.duration=M.endPTS-M.startPTS,H.duration&&(f=H),d.PTSKnown=d.alignedSliding=!0),H.elementaryStreams=M.elementaryStreams,H.loader=M.loader,H.stats=M.stats,H.urlId=M.urlId,M.initSegment&&(H.initSegment=M.initSegment,_=M.initSegment)}),_){var p=d.fragmentHint?d.fragments.concat(d.fragmentHint):d.fragments;p.forEach(function(M){var H;(!M.initSegment||M.initSegment.relurl===((H=_)===null||H===void 0?void 0:H.relurl))&&(M.initSegment=_)})}if(d.skippedSegments&&(d.deltaUpdateFailed=d.fragments.some(function(M){return!M}),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 b=0;b=y.length)return;A(d,y[_].start)}function A(c,d){if(d){for(var _=c.fragments,y=c.skippedSegments;y<_.length;y++)_[y].start+=d;c.fragmentHint&&(c.fragmentHint.start+=d)}}function C(c,d){var _=1e3*c.levelTargetDuration,y=_/2,m=c.age,l=m>0&&m<_*3,x=d.loading.end-d.loading.start,f,p=c.availabilityDelay;if(c.updated===!1)if(l){var s=333*c.misses;f=Math.max(Math.min(y,x*2),s),c.availabilityDelay=(c.availabilityDelay||0)+f}else f=y;else l?(p=Math.min(p||_/2,m),c.availabilityDelay=p,f=p+_-m):f=_-x;return Math.round(f)}function h(c,d,_){if(!c||!c.details)return null;var y=c.details,m=y.fragments[d-y.startSN];return m||(m=y.fragmentHint,m&&m.sn===d?m:d0&&p===-1&&(this.log("Override startPosition with lastCurrentTime @"+s.toFixed(3)),p=s),this.state=N.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=p,this.tick()}else this._forceStartLoad=!0,this.state=N.State.STOPPED},x.stopLoad=function(){this._forceStartLoad=!1,m.prototype.stopLoad.call(this)},x.doTick=function(){switch(this.state){case N.State.IDLE:this.doTickIdle();break;case N.State.WAITING_LEVEL:{var p,s=this.levels,a=this.level,b=s==null||((p=s[a])===null||p===void 0)?void 0:p.details;if(b&&(!b.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(b))break;this.state=N.State.IDLE;break}break}case N.State.FRAG_LOADING_WAITING_RETRY:{var v,S=self.performance.now(),M=this.retryDate;(!M||S>=M||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=N.State.IDLE)}break;default:break}this.onTickEnd()},x.onTickEnd=function(){m.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},x.doTickIdle=function(){var p,s,a=this.hls,b=this.levelLastLoaded,v=this.levels,S=this.media,M=a.config,H=a.nextLoadLevel;if(b===null||!S&&(this.startFragRequested||!M.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!v||!v[H])return;var V=v[H];this.level=a.nextLoadLevel=H;var Q=V.details;if(!Q||this.state===N.State.WAITING_LEVEL||Q.live&&this.levelLastLoaded!==H){this.state=N.State.WAITING_LEVEL;return}var G=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:S,D.PlaylistLevelType.MAIN);if(G===null)return;var W=G.len,q=this.getMaxBufferLength(V.maxBitrate);if(W>=q)return;if(this._streamEnded(G,Q)){var oe={};this.altAudio&&(oe.type="video"),this.hls.trigger(z.Events.BUFFER_EOS,oe),this.state=N.State.ENDED;return}var fe=G.end,ve=this.getNextFragment(fe,Q);if(this.couldBacktrack&&!this.fragPrevious&&ve&&ve.sn!=="initSegment"){var De=ve.sn-Q.startSN;De>1&&(ve=Q.fragments[De-1],this.fragmentTracker.removeFragment(ve))}if(ve&&this.fragmentTracker.getState(ve)===O.FragmentState.OK&&this.nextLoadPosition>fe){var Ee=this.audioOnly&&!this.altAudio?E.ElementaryStreamTypes.AUDIO:E.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(S,Ee,D.PlaylistLevelType.MAIN),ve=this.getNextFragment(this.nextLoadPosition,Q)}if(!ve)return;ve.initSegment&&!ve.initSegment.data&&!this.bitrateTest&&(ve=ve.initSegment),((p=ve.decryptdata)===null||p===void 0?void 0:p.keyFormat)==="identity"&&!((s=ve.decryptdata)!==null&&s!==void 0&&s.key)?this.loadKey(ve,Q):this.loadFragment(ve,Q,fe)},x.loadFragment=function(p,s,a){var b,v=this.fragmentTracker.getState(p);if(this.fragCurrent=p,v===O.FragmentState.BACKTRACKED){var S=this.fragmentTracker.getBacktrackData(p);if(S){this._handleFragmentLoadProgress(S),this._handleFragmentLoadComplete(S);return}else v=O.FragmentState.NOT_LOADED}v===O.FragmentState.NOT_LOADED||v===O.FragmentState.PARTIAL?p.sn==="initSegment"?this._loadInitSegment(p):this.bitrateTest?(p.bitrateTest=!0,this.log("Fragment "+p.sn+" of level "+p.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(p)):(this.startFragRequested=!0,m.prototype.loadFragment.call(this,p,s,a)):v===O.FragmentState.APPENDING?this.reduceMaxBufferLength(p.duration)&&this.fragmentTracker.removeFragment(p):((b=this.media)===null||b===void 0?void 0:b.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},x.getAppendedFrag=function(p){var s=this.fragmentTracker.getAppendedFrag(p,D.PlaylistLevelType.MAIN);return s&&"fragment"in s?s.fragment:s},x.getBufferedFrag=function(p){return this.fragmentTracker.getBufferedFrag(p,D.PlaylistLevelType.MAIN)},x.followingBufferedFrag=function(p){return p?this.getBufferedFrag(p.end+.5):null},x.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},x.nextLevelSwitch=function(){var p=this.levels,s=this.media;if(s!=null&&s.readyState){var a,b=this.getAppendedFrag(s.currentTime);if(b&&b.start>1&&this.flushMainBuffer(0,b.start-1),!s.paused&&p){var v=this.hls.nextLoadLevel,S=p[v],M=this.fragLastKbps;M&&this.fragCurrent?a=this.fragCurrent.duration*S.maxBitrate/(1e3*M)+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 Q=V.maxStartPTS?V.maxStartPTS:V.start,G=V.duration,W=Math.max(H.end,Q+Math.min(Math.max(G-this.config.maxFragLookUpTolerance,G*.5),G*.75));this.flushMainBuffer(W,Number.POSITIVE_INFINITY)}}}},x.abortCurrentFrag=function(){var p=this.fragCurrent;this.fragCurrent=null,p!=null&&p.loader&&p.loader.abort(),this.state===N.State.KEY_LOADING&&(this.state=N.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},x.flushMainBuffer=function(p,s){m.prototype.flushMainBuffer.call(this,p,s,this.altAudio?"video":null)},x.onMediaAttached=function(p,s){m.prototype.onMediaAttached.call(this,p,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 T.default(this.config,a,this.fragmentTracker,this.hls)},x.onMediaDetaching=function(){var p=this.media;p&&(p.removeEventListener("playing",this.onvplaying),p.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),m.prototype.onMediaDetaching.call(this)},x.onMediaPlaying=function(){this.tick()},x.onMediaSeeked=function(){var p=this.media,s=p?p.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(p,s){var a=!1,b=!1,v;s.levels.forEach(function(S){v=S.audioCodec,v&&(v.indexOf("mp4a.40.2")!==-1&&(a=!0),v.indexOf("mp4a.40.5")!==-1&&(b=!0))}),this.audioCodecSwitch=a&&b&&!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(p,s){var a=this.levels;if(!a||this.state!==N.State.IDLE)return;var b=a[s.level];(!b.details||b.details.live&&this.levelLastLoaded!==s.level||this.waitForCdnTuneIn(b.details))&&(this.state=N.State.WAITING_LEVEL)},x.onLevelLoaded=function(p,s){var a,b=this.levels,v=s.level,S=s.details,M=S.totalduration;if(!b){this.warn("Levels were reset while loading level "+v);return}this.log("Level "+v+" loaded ["+S.startSN+","+S.endSN+"], cc ["+S.startCC+", "+S.endCC+"] duration:"+M);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=b[v],Q=0;if(S.live||(a=V.details)!==null&&a!==void 0&&a.live){if(S.fragments[0]||(S.deltaUpdateFailed=!0),S.deltaUpdateFailed)return;Q=this.alignPlaylists(S,V.details)}if(V.details=S,this.levelLastLoaded=v,this.hls.trigger(z.Events.LEVEL_UPDATED,{details:S,level:v}),this.state===N.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(S))return;this.state=N.State.IDLE}this.startFragRequested?S.live&&this.synchronizeToLiveEdge(S):this.setStartPosition(S,Q),this.tick()},x._handleFragmentLoadProgress=function(p){var s,a=p.frag,b=p.part,v=p.payload,S=this.levels;if(!S){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var M=S[a.level],H=M.details;if(!H){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var V=M.videoCodec,Q=H.PTSKnown||!H.live,G=(s=a.initSegment)===null||s===void 0?void 0:s.data,W=this._getAudioCodec(M),q=this.transmuxer=this.transmuxer||new L.default(this.hls,D.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),oe=b?b.index:-1,fe=oe!==-1,ve=new k.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,v.byteLength,oe,fe),De=this.initPTS[a.cc];q.push(v,G,W,V,a,b,H.totalduration,Q,ve,De)},x.onAudioTrackSwitching=function(p,s){var a=this.altAudio,b=!!s.url,v=s.id;if(!b){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var S=this.fragCurrent;S!=null&&S.loader&&(this.log("Switching to main audio track, cancel main fragment load"),S.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var M=this.hls;a&&M.trigger(z.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),M.trigger(z.Events.AUDIO_TRACK_SWITCHED,{id:v})}},x.onAudioTrackSwitched=function(p,s){var a=s.id,b=!!this.hls.audioTracks[a].url;if(b){var v=this.videoBuffer;v&&this.mediaBuffer!==v&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=v)}this.altAudio=b,this.tick()},x.onBufferCreated=function(p,s){var a=s.tracks,b,v,S=!1;for(var M in a){var H=a[M];if(H.id==="main"){if(v=M,b=H,M==="video"){var V=a[M];V&&(this.videoBuffer=V.buffer)}}else S=!0}S&&b?(this.log("Alternate track found, use "+v+".buffered to schedule main fragment loading"),this.mediaBuffer=b.buffer):this.mediaBuffer=this.media},x.onFragBuffered=function(p,s){var a=s.frag,b=s.part;if(a&&a.type!==D.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(b?" p: "+b.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 v=b?b.stats:a.stats;this.fragLastKbps=Math.round(8*v.total/(v.buffering.end-v.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,b)},x.onError=function(p,s){switch(s.details){case A.ErrorDetails.FRAG_LOAD_ERROR:case A.ErrorDetails.FRAG_LOAD_TIMEOUT:case A.ErrorDetails.KEY_LOAD_ERROR:case A.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(D.PlaylistLevelType.MAIN,s);break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.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 A.ErrorDetails.BUFFER_FULL_ERROR:if(s.parent==="main"&&(this.state===N.State.PARSING||this.state===N.State.PARSED)){var a=!0,b=this.getFwdBufferInfo(this.media,D.PlaylistLevelType.MAIN);b&&b.len>.5&&(a=!this.reduceMaxBufferLength(b.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 p=this.media,s=this.gapController;if(!p||!s||!p.readyState)return;var a=B.BufferHelper.getBuffered(p);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):s.poll(this.lastCurrentTime),this.lastCurrentTime=p.currentTime},x.onFragLoadEmergencyAborted=function(){this.state=N.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},x.onBufferFlushed=function(p,s){var a=s.type;if(a!==E.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var b=(a===E.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(b,a,D.PlaylistLevelType.MAIN)}},x.onLevelsUpdated=function(p,s){this.levels=s.levels},x.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},x.seekToStartPos=function(){var p=this.media,s=p.currentTime,a=this.startPosition;if(a>=0&&s0&&(S1&&p.seeking===!1){var a=p.currentTime;if(B.BufferHelper.isBuffered(p,a)?s=this.getAppendedFrag(a):B.BufferHelper.isBuffered(p,a+.1)&&(s=this.getAppendedFrag(a+.1)),s){var b=this.fragPlaying,v=s.level;(!b||s.sn!==b.sn||b.level!==v||s.urlId!==b.urlId)&&(this.hls.trigger(z.Events.FRAG_CHANGED,{frag:s}),(!b||b.level!==v)&&this.hls.trigger(z.Events.LEVEL_SWITCHED,{level:v}),this.fragPlaying=s)}}},o(l,[{key:"nextLevel",get:function(){var p=this.nextBufferedFrag;return p?p.level:-1}},{key:"currentLevel",get:function(){var p=this.media;if(p){var s=this.getAppendedFrag(p.currentTime);if(s)return s.level}return-1}},{key:"nextBufferedFrag",get:function(){var p=this.media;if(p){var s=this.getAppendedFrag(p.currentTime);return this.followingBufferedFrag(s)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),l}(N.default)},"./src/controller/subtitle-stream-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"SubtitleStreamController",function(){return c});var X=R("./src/events.ts"),N=R("./src/utils/logger.ts"),I=R("./src/utils/buffer-helper.ts"),z=R("./src/controller/fragment-finders.ts"),B=R("./src/utils/discontinuities.ts"),O=R("./src/controller/level-helper.ts"),D=R("./src/controller/fragment-tracker.ts"),E=R("./src/controller/base-stream-controller.ts"),L=R("./src/types/loader.ts"),k=R("./src/types/level.ts");function T(d,_){for(var y=0;y<_.length;y++){var m=_[y];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(d,m.key,m)}}function A(d,_,y){return _&&T(d.prototype,_),y&&T(d,y),d}function C(d,_){d.prototype=Object.create(_.prototype),d.prototype.constructor=d,h(d,_)}function h(d,_){return h=Object.setPrototypeOf||function(m,l){return m.__proto__=l,m},h(d,_)}var o=500,c=function(d){C(_,d);function _(m,l){var x;return x=d.call(this,m,l,"[subtitle-stream-controller]")||this,x.levels=[],x.currentTrackId=-1,x.tracksBuffered=[],x.mainDetails=null,x._registerListeners(),x}var y=_.prototype;return y.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},y._registerListeners=function(){var l=this.hls;l.on(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.on(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(X.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(X.Events.ERROR,this.onError,this),l.on(X.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(X.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.on(X.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.on(X.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.on(X.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},y._unregisterListeners=function(){var l=this.hls;l.off(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.off(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.off(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(X.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(X.Events.ERROR,this.onError,this),l.off(X.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.off(X.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.off(X.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.off(X.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.off(X.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},y.startLoad=function(){this.stopLoad(),this.state=E.State.IDLE,this.setInterval(o),this.tick()},y.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},y.onLevelLoaded=function(l,x){this.mainDetails=x.details},y.onSubtitleFragProcessed=function(l,x){var f=x.frag,p=x.success;if(this.fragPrevious=f,this.state=E.State.IDLE,!p)return;var s=this.tracksBuffered[this.currentTrackId];if(!s)return;for(var a,b=f.start,v=0;v=s[v].start&&b<=s[v].end){a=s[v];break}var S=f.start+f.duration;a?a.end=S:(a={start:b,end:S},s.push(a)),this.fragmentTracker.fragBuffered(f)},y.onBufferFlushing=function(l,x){var f=x.startOffset,p=x.endOffset;if(f===0&&p!==Number.POSITIVE_INFINITY){var s=this.currentTrackId,a=this.levels;if(!a.length||!a[s]||!a[s].details)return;var b=a[s].details,v=b.targetduration,S=p-v;if(S<=0)return;x.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(M){for(var H=0;H=b.length||s!==a||!v)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,p.live||(f=v.details)!==null&&f!==void 0&&f.live){var S=this.mainDetails;if(p.deltaUpdateFailed||!S)return;var M=S.fragments[0];if(!v.details)p.hasProgramDateTime&&S.hasProgramDateTime?Object(B.alignMediaPlaylistByPDT)(p,S):M&&Object(O.addSliding)(p,M.start);else{var H=this.alignPlaylists(p,v.details);H===0&&M&&Object(O.addSliding)(p,M.start)}}if(v.details=p,this.levelLastLoaded=s,this.tick(),p.live&&!this.fragCurrent&&this.media&&this.state===E.State.IDLE){var V=Object(z.findFragmentByPTS)(null,p.fragments,this.media.currentTime,0);V||(this.warn("Subtitle playlist not aligned with playback"),v.details=void 0)}},y._handleFragmentLoadComplete=function(l){var x=l.frag,f=l.payload,p=x.decryptdata,s=this.hls;if(this.fragContextChanged(x))return;if(f&&f.byteLength>0&&p&&p.key&&p.iv&&p.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(f),p.key.buffer,p.iv.buffer).then(function(b){var v=performance.now();s.trigger(X.Events.FRAG_DECRYPTED,{frag:x,payload:b,stats:{tstart:a,tdecrypt:v}})})}},y.doTick=function(){if(!this.media){this.state=E.State.IDLE;return}if(this.state===E.State.IDLE){var l,x=this.currentTrackId,f=this.levels;if(!f.length||!f[x]||!f[x].details)return;var p=f[x].details,s=p.targetduration,a=this.config,b=this.media,v=I.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,b.currentTime-s,a.maxBufferHole),S=v.end,M=v.len,H=this.getMaxBufferLength()+s;if(M>H)return;console.assert(p,"Subtitle track details are defined on idle subtitle stream controller tick");var V=p.fragments,Q=V.length,G=p.edge,W,q=this.fragPrevious;if(S-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)},C.pollTrackChange=function(o){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,o)},C.onMediaDetaching=function(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var o=k(this.media.textTracks);o.forEach(function(c){Object(N.clearCurrentCues)(c)}),this.subtitleTrack=-1,this.media=null},C.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},C.onManifestParsed=function(o,c){this.tracks=c.subtitleTracks},C.onSubtitleTrackLoaded=function(o,c){var d=c.id,_=c.details,y=this.trackId,m=this.tracksInGroup[y];if(!m){this.warn("Invalid subtitle track id "+d);return}var l=m.details;m.details=c.details,this.log("subtitle track "+d+" loaded ["+_.startSN+"-"+_.endSN+"]"),d===this.trackId&&(this.retryCount=0,this.playlistLoaded(d,c,l))},C.onLevelLoading=function(o,c){this.switchLevel(c.level)},C.onLevelSwitching=function(o,c){this.switchLevel(c.level)},C.switchLevel=function(o){var c=this.hls.levels[o];if(!(c!=null&&c.textGroupIds))return;var d=c.textGroupIds[c.urlId];if(this.groupId!==d){var _=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,y=this.tracks.filter(function(x){return!d||x.groupId===d});this.tracksInGroup=y;var m=this.findTrackId(_==null?void 0:_.name)||this.findTrackId();this.groupId=d;var l={subtitleTracks:y};this.log("Updating subtitle tracks, "+y.length+' track(s) found in "'+d+'" group-id'),this.hls.trigger(X.Events.SUBTITLE_TRACKS_UPDATED,l),m!==-1&&this.setSubtitleTrack(m,_)}},C.findTrackId=function(o){for(var c=this.tracksInGroup,d=0;d=_.length)return;this.clearTimer();var y=_[o];if(this.log("Switching to subtitle track "+o),this.trackId=o,y){var m=y.id,l=y.groupId,x=l===void 0?"":l,f=y.name,p=y.type,s=y.url;this.hls.trigger(X.Events.SUBTITLE_TRACK_SWITCH,{id:m,groupId:x,name:f,type:p,url:s});var a=this.switchParams(y.url,c==null?void 0:c.details);this.loadPlaylist(a)}else this.hls.trigger(X.Events.SUBTITLE_TRACK_SWITCH,{id:o})},C.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var o=-1,c=k(this.media.textTracks),d=0;d=0&&(p[0]=Math.min(p[0],_),p[1]=Math.max(p[1],y),x=!0,s/(y-_)>.5))return}if(x||l.push([_,y]),this.config.renderTextTracksNatively){var a=this.captionsTracks[d];this.Cues.newCue(a,_,y,m)}else{var b=this.Cues.newCue(null,_,y,m);this.hls.trigger(N.Events.CUES_PARSED,{type:"captions",cues:b,track:d})}},o.onInitPtsFound=function(d,_){var y=this,m=_.frag,l=_.id,x=_.initPTS,f=_.timescale,p=this.unparsedVttFrags;l==="main"&&(this.initPTS[m.cc]=x,this.timescale[m.cc]=f),p.length&&(this.unparsedVttFrags=[],p.forEach(function(s){y.onFragLoaded(N.Events.FRAG_LOADED,s)}))},o.getExistingTrack=function(d){var _=this.media;if(_)for(var y=0;y<_.textTracks.length;y++){var m=_.textTracks[y];if(m[d])return m}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 _=this.captionsProperties,y=this.captionsTracks,m=this.media,l=_[d],x=l.label,f=l.languageCode,p=this.getExistingTrack(d);if(p)y[d]=p,Object(O.clearCurrentCues)(y[d]),Object(O.sendAddTrackEvent)(y[d],m);else{var s=this.createTextTrack("captions",x,f);s&&(s[d]=!0,y[d]=s)}},o.createNonNativeTrack=function(d){if(this.nonNativeCaptionsTracks[d])return;var _=this.captionsProperties[d];if(!_)return;var y=_.label,m={_id:d,label:y,kind:"captions",default:_.media?!!_.media.default:!1,closedCaptions:_.media};this.nonNativeCaptionsTracks[d]=m,this.hls.trigger(N.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[m]})},o.createTextTrack=function(d,_,y){var m=this.media;return m?m.addTextTrack(d,_,y):void 0},o.onMediaAttaching=function(d,_){this.media=_.media,this._cleanTracks()},o.onMediaDetaching=function(){var d=this.captionsTracks;Object.keys(d).forEach(function(_){Object(O.clearCurrentCues)(d[_]),delete d[_]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=C(),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 _=d.textTracks;if(_)for(var y=0;y<_.length;y++)Object(O.clearCurrentCues)(_[y])},o.onSubtitleTracksUpdated=function(d,_){var y=this;this.textTracks=[];var m=_.subtitleTracks||[],l=m.some(function(s){return s.textCodec===D.IMSC1_CODEC});if(this.config.enableWebVTT||l&&this.config.enableIMSC1){var x=this.tracks&&m&&this.tracks.length===m.length;if(this.tracks=m||[],this.config.renderTextTracksNatively){var f=this.media?this.media.textTracks:[];this.tracks.forEach(function(s,a){var b;if(a>>8^f&255^99,D[m]=f,E[f]=m;var p=y[m],s=y[p],a=y[s],b=y[f]*257^f*16843008;k[m]=b<<24|b>>>8,T[m]=b<<16|b>>>16,A[m]=b<<8|b>>>24,C[m]=b,b=a*16843009^s*65537^p*257^m*16843008,o[f]=b<<24|b>>>8,c[f]=b<<16|b>>>16,d[f]=b<<8|b>>>24,_[f]=b,m?(m=p^y[y[y[a^p]]],l^=y[y[l]]):m=l=1}},B.expandKey=function(D){for(var E=this.uint8ArrayToUint32Array_(D),L=!0,k=0;k>>6)+1;var b=(d[_+2]&60)>>>2;if(b>a.length-1){c.trigger(I.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+b});return}return x=(d[_+2]&1)<<2,x|=(d[_+3]&192)>>>6,X.logger.log("manifest codec:"+y+", ADTS type:"+m+", samplingIndex:"+b),/firefox/i.test(p)?b>=6?(m=5,f=new Array(4),l=b-3):(m=2,f=new Array(2),l=b):p.indexOf("android")!==-1?(m=2,f=new Array(2),l=b):(m=5,f=new Array(4),y&&(y.indexOf("mp4a.40.29")!==-1||y.indexOf("mp4a.40.5")!==-1)||!y&&b>=6?l=b-3:((y&&y.indexOf("mp4a.40.2")!==-1&&(b>=6&&x===1||/vivaldi/i.test(p))||!y&&x===1)&&(m=2,f=new Array(2)),l=b)),f[0]=m<<3,f[0]|=(b&14)>>1,f[1]|=(b&1)<<7,f[1]|=x<<3,m===5&&(f[1]|=(l&14)>>1,f[2]=(l&1)<<7,f[2]|=2<<2,f[3]=0),{config:f,samplerate:a[b],channelCount:x,codec:"mp4a.40."+m,manifestCodec:s}}function B(c,d){return c[d]===255&&(c[d+1]&246)===240}function O(c,d){return c[d+1]&1?7:9}function D(c,d){return(c[d+3]&3)<<11|c[d+4]<<3|(c[d+5]&224)>>>5}function E(c,d){return d+5=c.length)return!1;var y=D(c,d);if(y<=_)return!1;var m=d+y;return m===c.length||L(c,m)}return!1}function A(c,d,_,y,m){if(!c.samplerate){var l=z(d,_,y,m);if(!l)return;c.config=l.config,c.samplerate=l.samplerate,c.channelCount=l.channelCount,c.codec=l.codec,c.manifestCodec=l.manifestCodec,X.logger.log("parsed codec:"+c.codec+", rate:"+l.samplerate+", channels:"+l.channelCount)}}function C(c){return 1024*9e4/c}function h(c,d,_,y,m){var l=O(c,d),x=D(c,d);if(x-=l,x>0){var f=_+y*m;return{headerLength:l,frameLength:x,stamp:f}}}function o(c,d,_,y,m){var l=C(c.samplerate),x=h(d,_,y,m,l);if(x){var f=x.frameLength,p=x.headerLength,s=x.stamp,a=p+f,b=Math.max(0,_+a-d.length),v;b?(v=new Uint8Array(a-p),v.set(d.subarray(_+p,d.length),0)):v=d.subarray(_+p,_+a);var S={unit:v,pts:s};return b||c.samples.push(S),{sample:S,length:a,missing:b}}}},"./src/demux/base-audio-demuxer.ts":function(ae,$,R){"use strict";R.r($),R.d($,"initPTSFn",function(){return D});var X=R("./src/polyfills/number.ts"),N=R("./src/demux/id3.ts"),I=R("./src/demux/dummy-demuxed-track.ts"),z=R("./src/utils/mp4-tools.ts"),B=R("./src/utils/typed-array.ts"),O=function(){function E(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var L=E.prototype;return L.resetInitSegment=function(T,A,C){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},L.resetTimeStamp=function(){},L.resetContiguity=function(){},L.canParse=function(T,A){return!1},L.appendFrame=function(T,A,C){},L.demux=function(T,A){this.cachedData&&(T=Object(z.appendUint8Array)(this.cachedData,T),this.cachedData=null);var C=N.getID3Data(T,0),h=C?C.length:0,o,c,d=this._audioTrack,_=this._id3Track,y=C?N.getTimeStamp(C):void 0,m=T.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=D(y,A)),C&&C.length>0&&_.samples.push({pts:this.initPTS,dts:this.initPTS,data:C}),c=this.initPTS;hO?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,D=O>>3,O-=D>>3,this.bytesAvailable-=D,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},z.readBits=function(O){var D=Math.min(this.bitsAvailable,O),E=this.word>>>32-D;return O>32&&X.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=D,this.bitsAvailable>0?this.word<<=D:this.bytesAvailable>0&&this.loadWord(),D=O-D,D>0&&this.bitsAvailable?E<>>O)!==0)return this.word<<=O,this.bitsAvailable-=O,O;return this.loadWord(),O+this.skipLZ()},z.skipUEG=function(){this.skipBits(1+this.skipLZ())},z.skipEG=function(){this.skipBits(1+this.skipLZ())},z.readUEG=function(){var O=this.skipLZ();return this.readBits(O+1)-1},z.readEG=function(){var O=this.readUEG();return 1&O?1+O>>>1:-1*(O>>>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(O){for(var D=8,E=8,L,k=0;k0?m.subarray(x,x+f):void 0},z=function(m,l){var x=0;return x=(m[l]&127)<<21,x|=(m[l+1]&127)<<14,x|=(m[l+2]&127)<<7,x|=m[l+3]&127,x},B=function(m,l){return X(m,l)&&z(m,l+6)+10<=m.length-l},O=function(m){for(var l=L(m),x=0;x>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:S+=String.fromCharCode(a);break;case 12:case 13:b=m[M++],S+=String.fromCharCode((a&31)<<6|b&63);break;case 14:b=m[M++],v=m[M++],S+=String.fromCharCode((a&15)<<12|(b&63)<<6|(v&63)<<0);break;default:}}return S},c={decodeTextFrame:A},d;function _(){return!d&&typeof self.TextDecoder!="undefined"&&(d=new self.TextDecoder("utf-8")),d}},"./src/demux/mp3demuxer.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/demux/base-audio-demuxer.ts"),N=R("./src/demux/id3.ts"),I=R("./src/utils/logger.ts"),z=R("./src/demux/mpegaudio.ts");function B(E,L){E.prototype=Object.create(L.prototype),E.prototype.constructor=E,O(E,L)}function O(E,L){return O=Object.setPrototypeOf||function(T,A){return T.__proto__=A,T},O(E,L)}var D=function(E){B(L,E);function L(){return E.apply(this,arguments)||this}var k=L.prototype;return k.resetInitSegment=function(A,C,h){E.prototype.resetInitSegment.call(this,A,C,h),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:A,duration:h,inputTimeScale:9e4,dropped:0}},L.probe=function(A){if(!A)return!1;for(var C=N.getID3Data(A,0)||[],h=C.length,o=A.length;h0},B.demux=function(D){var E=D,L=Object(N.dummyTrack)();if(this.config.progressive){this.remainderData&&(E=Object(X.appendUint8Array)(this.remainderData,D));var k=Object(X.segmentValidRange)(E);this.remainderData=k.remainder,L.samples=k.valid||new Uint8Array}else L.samples=E;return{audioTrack:Object(N.dummyTrack)(),avcTrack:L,id3Track:Object(N.dummyTrack)(),textTrack:Object(N.dummyTrack)()}},B.flush=function(){var D=Object(N.dummyTrack)();return D.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(N.dummyTrack)(),avcTrack:D,id3Track:Object(N.dummyTrack)(),textTrack:Object(N.dummyTrack)()}},B.demuxSampleAes=function(D,E,L){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},B.destroy=function(){},z}();I.minProbeByteLength=1024,$.default=I},"./src/demux/mpegaudio.ts":function(ae,$,R){"use strict";R.r($),R.d($,"appendFrame",function(){return O}),R.d($,"parseHeader",function(){return D}),R.d($,"isHeaderPattern",function(){return E}),R.d($,"isHeader",function(){return L}),R.d($,"canParse",function(){return k}),R.d($,"probe",function(){return T});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]],B=[0,1,1,4];function O(A,C,h,o,c){if(h+24>C.length)return;var d=D(C,h);if(d&&h+d.frameLength<=C.length){var _=d.samplesPerFrame*9e4/d.sampleRate,y=o+c*_,m={unit:C.subarray(h,h+d.frameLength),pts:y,dts:y};return A.config=[],A.channelCount=d.channelCount,A.samplerate=d.sampleRate,A.samples.push(m),{sample:m,length:d.frameLength,missing:0}}}function D(A,C){var h=A[C+1]>>3&3,o=A[C+1]>>1&3,c=A[C+2]>>4&15,d=A[C+2]>>2&3;if(h!==1&&c!==0&&c!==15&&d!==3){var _=A[C+2]>>1&1,y=A[C+3]>>6,m=h===3?3-o:o===3?3:4,l=N[m*14+c-1]*1e3,x=h===3?0:h===2?1:2,f=I[x*3+d],p=y===3?1:2,s=z[h][o],a=B[o],b=s*8*a,v=Math.floor(s*l/f+_)*a;if(X===null){var S=navigator.userAgent||"",M=S.match(/Chrome\/(\d+)/i);X=M?parseInt(M[1]):0}var H=!!X&&X<=87;return H&&o===2&&l>=224e3&&y===0&&(A[C+3]=A[C+3]|128),{sampleRate:f,channelCount:p,frameLength:v,samplesPerFrame:b}}}function E(A,C){return A[C]===255&&(A[C+1]&224)===224&&(A[C+1]&6)!==0}function L(A,C){return C+1=D.length){L();return}if(D[E].unit.length<32)continue;var k=this.decrypter.isSync();if(this.decryptAacSample(D,E,L,k),!k)return}},B.getAvcEncryptedData=function(D){for(var E=Math.floor((D.length-48)/160)*16+16,L=new Int8Array(E),k=0,T=32;T<=D.length-16;T+=160,k+=16)L.set(D.subarray(T,T+16),k);return L},B.getAvcDecryptedUnit=function(D,E){for(var L=new Uint8Array(E),k=0,T=32;T<=D.length-16;T+=160,k+=16)D.set(L.subarray(k,k+16),T);return D},B.decryptAvcSample=function(D,E,L,k,T,A){var C=Object(N.discardEPB)(T.data),h=this.getAvcEncryptedData(C),o=this;this.decryptBuffer(h.buffer,function(c){T.data=o.getAvcDecryptedUnit(C,c),A||o.decryptAvcSamples(D,E,L+1,k)})},B.decryptAvcSamples=function(D,E,L,k){if(D instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;E++,L=0){if(E>=D.length){k();return}for(var T=D[E].units;!(L>=T.length);L++){var A=T[L];if(A.data.length<=48||A.type!==1&&A.type!==5)continue;var C=this.decrypter.isSync();if(this.decryptAvcSample(D,E,L,k,A,C),!C)return}}},z}();$.default=I},"./src/demux/transmuxer-interface.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return T});var X=R("./node_modules/webworkify-webpack/index.js"),N=R.n(X),I=R("./src/events.ts"),z=R("./src/demux/transmuxer.ts"),B=R("./src/utils/logger.ts"),O=R("./src/errors.ts"),D=R("./src/utils/mediasource-helper.ts"),E=R("./node_modules/eventemitter3/index.js"),L=R.n(E),k=Object(D.getMediaSource)()||{isTypeSupported:function(){return!1}},T=function(){function A(h,o,c,d){var _=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=c,this.onFlush=d;var y=h.config,m=function(s,a){a=a||{},a.frag=_.frag,a.id=_.id,h.trigger(s,a)};this.observer=new E.EventEmitter,this.observer.on(I.Events.FRAG_DECRYPTED,m),this.observer.on(I.Events.ERROR,m);var l={mp4:k.isTypeSupported("video/mp4"),mpeg:k.isTypeSupported("audio/mpeg"),mp3:k.isTypeSupported('audio/mp4; codecs="mp3"')},x=navigator.vendor;if(y.enableWorker&&typeof Worker!="undefined"){B.logger.log("demuxing in webworker");var f;try{f=this.worker=X("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),f.addEventListener("message",this.onwmsg),f.onerror=function(p){h.trigger(I.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(p.message+" ("+p.filename+":"+p.lineno+")")})},f.postMessage({cmd:"init",typeSupported:l,vendor:x,id:o,config:JSON.stringify(y)})}catch(p){B.logger.warn("Error in worker:",p),B.logger.error("Error while initializing DemuxerWorker, fallback to inline"),f&&self.URL.revokeObjectURL(f.objectURL),this.transmuxer=new z.default(this.observer,l,y,x,o),this.worker=null}}else this.transmuxer=new z.default(this.observer,l,y,x,o)}var C=A.prototype;return C.destroy=function(){var o=this.worker;if(o)o.removeEventListener("message",this.onwmsg),o.terminate(),this.worker=null;else{var c=this.transmuxer;c&&(c.destroy(),this.transmuxer=null)}var d=this.observer;d&&d.removeAllListeners(),this.observer=null},C.push=function(o,c,d,_,y,m,l,x,f,p){var s=this;f.transmuxing.start=self.performance.now();var a=this.transmuxer,b=this.worker,v=m?m.start:y.start,S=y.decryptdata,M=this.frag,H=!(M&&y.cc===M.cc),V=!(M&&f.level===M.level),Q=M?f.sn-M.sn:-1,G=this.part?f.part-this.part.index:1,W=!V&&(Q===1||Q===0&&G===1),q=self.performance.now();(V||Q||y.stats.parsing.start===0)&&(y.stats.parsing.start=q),m&&(G||!W)&&(m.stats.parsing.start=q);var oe=new z.TransmuxState(H,W,x,V,v);if(!W||H){B.logger.log("[transmuxer-interface, "+y.type+"]: Starting new transmux session for sn: "+f.sn+" p: "+f.part+" level: "+f.level+" id: "+f.id+` discontinuity: `+H+` trackSwitch: `+V+` contiguous: `+W+` accurateTimeOffset: `+x+` timeOffset: `+v);var fe=new z.TransmuxConfig(d,_,c,l,p);this.configureTransmuxer(fe)}if(this.frag=y,this.part=m,b)b.postMessage({cmd:"demux",data:o,decryptdata:S,chunkMeta:f,state:oe},o instanceof ArrayBuffer?[o]:[]);else if(a){var ve=a.push(o,S,f,oe);Object(z.isPromise)(ve)?ve.then(function(De){s.handleTransmuxComplete(De)}):this.handleTransmuxComplete(ve)}},C.flush=function(o){var c=this;o.transmuxing.start=self.performance.now();var d=this.transmuxer,_=this.worker;if(_)_.postMessage({cmd:"flush",chunkMeta:o});else if(d){var y=d.flush(o);Object(z.isPromise)(y)?y.then(function(m){c.handleFlushResult(m,o)}):this.handleFlushResult(y,o)}},C.handleFlushResult=function(o,c){var d=this;o.forEach(function(_){d.handleTransmuxComplete(_)}),this.onFlush(c)},C.onWorkerMessage=function(o){var c=o.data,d=this.hls;switch(c.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(c.data);break}case"flush":{this.onFlush(c.data);break}default:{c.data=c.data||{},c.data.frag=this.frag,c.data.id=this.id,d.trigger(c.event,c.data);break}}},C.configureTransmuxer=function(o){var c=this.worker,d=this.transmuxer;c?c.postMessage({cmd:"configure",config:o}):d&&d.configure(o)},C.handleTransmuxComplete=function(o){o.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(o)},A}()},"./src/demux/transmuxer-worker.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return O});var X=R("./src/demux/transmuxer.ts"),N=R("./src/events.ts"),I=R("./src/utils/logger.ts"),z=R("./node_modules/eventemitter3/index.js"),B=R.n(z);function O(T){var A=new z.EventEmitter,C=function(o,c){T.postMessage({event:o,data:c})};A.on(N.Events.FRAG_DECRYPTED,C),A.on(N.Events.ERROR,C),T.addEventListener("message",function(h){var o=h.data;switch(o.cmd){case"init":{var c=JSON.parse(o.config);T.transmuxer=new X.default(A,o.typeSupported,c,o.vendor,o.id),Object(I.enableLogs)(c.debug),C("init",null);break}case"configure":{T.transmuxer.configure(o.config);break}case"demux":{var d=T.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(X.isPromise)(d)?d.then(function(m){D(T,m)}):D(T,d);break}case"flush":{var _=o.chunkMeta,y=T.transmuxer.flush(_);Object(X.isPromise)(y)?y.then(function(m){L(T,m,_)}):L(T,y,_);break}default:break}})}function D(T,A){if(k(A.remuxResult))return;var C=[],h=A.remuxResult,o=h.audio,c=h.video;o&&E(C,o),c&&E(C,c),T.postMessage({event:"transmuxComplete",data:A},C)}function E(T,A){A.data1&&T.push(A.data1.buffer),A.data2&&T.push(A.data2.buffer)}function L(T,A,C){A.forEach(function(h){D(T,h)}),T.postMessage({event:"flush",data:C})}function k(T){return!T.audio&&!T.video&&!T.text&&!T.id3&&!T.initSegment}},"./src/demux/transmuxer.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return c}),R.d($,"isPromise",function(){return y}),R.d($,"TransmuxConfig",function(){return m}),R.d($,"TransmuxState",function(){return l});var X=R("./src/events.ts"),N=R("./src/errors.ts"),I=R("./src/crypt/decrypter.ts"),z=R("./src/demux/aacdemuxer.ts"),B=R("./src/demux/mp4demuxer.ts"),O=R("./src/demux/tsdemuxer.ts"),D=R("./src/demux/mp3demuxer.ts"),E=R("./src/remux/mp4-remuxer.ts"),L=R("./src/remux/passthrough-remuxer.ts"),k=R("./src/demux/chunk-cache.ts"),T=R("./src/utils/mp4-tools.ts"),A=R("./src/utils/logger.ts"),C;try{C=self.performance.now.bind(self.performance)}catch(x){A.logger.debug("Unable to use Performance API on this environment"),C=self.Date.now}var h=[{demux:O.default,remux:E.default},{demux:B.default,remux:L.default},{demux:z.default,remux:E.default},{demux:D.default,remux:E.default}],o=1024;h.forEach(function(x){var f=x.demux;o=Math.max(o,f.minProbeByteLength)});var c=function(){function x(p,s,a,b,v){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new k.default,this.observer=p,this.typeSupported=s,this.config=a,this.vendor=b,this.id=v}var f=x.prototype;return f.configure=function(s){this.transmuxConfig=s,this.decrypter&&this.decrypter.reset()},f.push=function(s,a,b,v){var S=this,M=b.transmuxing;M.executeStart=C();var H=new Uint8Array(s),V=this.cache,Q=this.config,G=this.currentTransmuxState,W=this.transmuxConfig;v&&(this.currentTransmuxState=v);var q=d(H,a);if(q&&q.method==="AES-128"){var oe=this.getDecrypter();if(Q.enableSoftwareAES){var fe=oe.softwareDecrypt(H,q.key.buffer,q.iv.buffer);if(!fe)return M.executeEnd=C(),_(b);H=new Uint8Array(fe)}else return this.decryptionPromise=oe.webCryptoDecrypt(H,q.key.buffer,q.iv.buffer).then(function(Me){var ze=S.push(Me,null,b);return S.decryptionPromise=null,ze}),this.decryptionPromise}var ve=v||G,De=ve.contiguous,Ee=ve.discontinuity,_e=ve.trackSwitch,Te=ve.accurateTimeOffset,Ce=ve.timeOffset,me=W.audioCodec,ne=W.videoCodec,Ae=W.defaultInitPts,rt=W.duration,$e=W.initSegmentData;if((Ee||_e)&&this.resetInitSegment($e,me,ne,rt),Ee&&this.resetInitialTimestamp(Ae),De||this.resetContiguity(),this.needsProbing(H,Ee,_e)){if(V.dataLength){var Xe=V.flush();H=Object(T.appendUint8Array)(Xe,H)}this.configureTransmuxer(H,W)}var Ve=this.transmux(H,q,Ce,Te,b),Le=this.currentTransmuxState;return Le.contiguous=!0,Le.discontinuity=!1,Le.trackSwitch=!1,M.executeEnd=C(),Ve},f.flush=function(s){var a=this,b=s.transmuxing;b.executeStart=C();var v=this.decrypter,S=this.cache,M=this.currentTransmuxState,H=this.decryptionPromise;if(H)return H.then(function(){return a.flush(s)});var V=[],Q=M.timeOffset;if(v){var G=v.flush();G&&V.push(this.push(G,null,s))}var W=S.dataLength;S.reset();var q=this.demuxer,oe=this.remuxer;if(!q||!oe)return W>=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"}),b.executeEnd=C(),[_(s)];var fe=q.flush(Q);return y(fe)?fe.then(function(ve){return a.flushRemux(V,ve,s),V}):(this.flushRemux(V,fe,s),V)},f.flushRemux=function(s,a,b){var v=a.audioTrack,S=a.avcTrack,M=a.id3Track,H=a.textTrack,V=this.currentTransmuxState,Q=V.accurateTimeOffset,G=V.timeOffset;A.logger.log("[transmuxer.ts]: Flushed fragment "+b.sn+(b.part>-1?" p: "+b.part:"")+" of level "+b.level);var W=this.remuxer.remux(v,S,M,H,G,Q,!0,this.id);s.push({remuxResult:W,chunkMeta:b}),b.transmuxing.executeEnd=C()},f.resetInitialTimestamp=function(s){var a=this.demuxer,b=this.remuxer;if(!a||!b)return;a.resetTimeStamp(s),b.resetTimeStamp(s)},f.resetContiguity=function(){var s=this.demuxer,a=this.remuxer;if(!s||!a)return;s.resetContiguity(),a.resetNextTimestamp()},f.resetInitSegment=function(s,a,b,v){var S=this.demuxer,M=this.remuxer;if(!S||!M)return;S.resetInitSegment(a,b,v),M.resetInitSegment(s,a,b)},f.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},f.transmux=function(s,a,b,v,S){var M;return a&&a.method==="SAMPLE-AES"?M=this.transmuxSampleAes(s,a,b,v,S):M=this.transmuxUnencrypted(s,b,v,S),M},f.transmuxUnencrypted=function(s,a,b,v){var S=this.demuxer.demux(s,a,!1,!this.config.progressive),M=S.audioTrack,H=S.avcTrack,V=S.id3Track,Q=S.textTrack,G=this.remuxer.remux(M,H,V,Q,a,b,!1,this.id);return{remuxResult:G,chunkMeta:v}},f.transmuxSampleAes=function(s,a,b,v,S){var M=this;return this.demuxer.demuxSampleAes(s,a,b).then(function(H){var V=M.remuxer.remux(H.audioTrack,H.avcTrack,H.id3Track,H.textTrack,b,v,!1,M.id);return{remuxResult:V,chunkMeta:S}})},f.configureTransmuxer=function(s,a){for(var b=this.config,v=this.observer,S=this.typeSupported,M=this.vendor,H=a.audioCodec,V=a.defaultInitPts,Q=a.duration,G=a.initSegmentData,W=a.videoCodec,q,oe=0,fe=h.length;oe0&&f!=null&&f.key!=null&&f.iv!==null&&f.method!=null&&(p=f),p}var _=function(f){return{remuxResult:{},chunkMeta:f}};function y(x){return"then"in x&&x.then instanceof Function}var m=function(f,p,s,a,b){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=f,this.videoCodec=p,this.initSegmentData=s,this.duration=a,this.defaultInitPts=b},l=function(f,p,s,a,b){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=f,this.contiguous=p,this.accurateTimeOffset=s,this.trackSwitch=a,this.timeOffset=b}},"./src/demux/tsdemuxer.ts":function(ae,$,R){"use strict";R.r($),R.d($,"discardEPB",function(){return _});var X=R("./src/demux/adts.ts"),N=R("./src/demux/mpegaudio.ts"),I=R("./src/demux/exp-golomb.ts"),z=R("./src/demux/id3.ts"),B=R("./src/demux/sample-aes.ts"),O=R("./src/events.ts"),D=R("./src/utils/mp4-tools.ts"),E=R("./src/utils/logger.ts"),L=R("./src/errors.ts"),k={video:1,audio:2,id3:3,text:4},T=function(){function y(l,x,f){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=l,this.config=x,this.typeSupported=f}y.probe=function(x){var f=y.syncOffset(x);return f<0?!1:(f&&E.logger.warn("MPEG2-TS detected but first sync word found @ offset "+f+", junk ahead ?"),!0)},y.syncOffset=function(x){for(var f=Math.min(1e3,x.length-3*188),p=0;p>4,me=void 0;if(Ce>1){if(me=Ee+5+x[Ee+4],me===Ee+188)continue}else me=Ee+4;switch(Te){case M:_e&&(H&&(a=o(H))&&this.parseAVCPES(a,!1),H={data:[],size:0}),H&&(H.data.push(x.subarray(me,Ee+188)),H.size+=Ee+188-me);break;case V:_e&&(G&&(a=o(G))&&(v.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),G={data:[],size:0}),G&&(G.data.push(x.subarray(me,Ee+188)),G.size+=Ee+188-me);break;case Q:_e&&(W&&(a=o(W))&&this.parseID3PES(a),W={data:[],size:0}),W&&(W.data.push(x.subarray(me,Ee+188)),W.size+=Ee+188-me);break;case 0:_e&&(me+=x[me]+1),fe=this._pmtId=C(x,me);break;case fe:{_e&&(me+=x[me]+1);var ne=h(x,me,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,p);M=ne.avc,M>0&&(b.pid=M),V=ne.audio,V>0&&(v.pid=V,v.isAAC=ne.isAAC),Q=ne.id3,Q>0&&(S.pid=Q),q&&!oe&&(E.logger.log("reparse from beginning"),q=!1,Ee=De-188),oe=this.pmtParsed=!0;break}case 17:case 8191:break;default:q=!0;break}}else this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});b.pesData=H,v.pesData=G,S.pesData=W;var Ae={audioTrack:v,avcTrack:b,id3Track:S,textTrack:this._txtTrack};return s&&this.extractRemainingSamples(Ae),Ae},m.flush=function(){var x=this.remainderData;this.remainderData=null;var f;return x?f=this.demux(x,-1,!1,!0):f={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(f),this.sampleAes?this.decrypt(f,this.sampleAes):f},m.extractRemainingSamples=function(x){var f=x.audioTrack,p=x.avcTrack,s=x.id3Track,a=p.pesData,b=f.pesData,v=s.pesData,S;a&&(S=o(a))?(this.parseAVCPES(S,!0),p.pesData=null):p.pesData=a,b&&(S=o(b))?(f.isAAC?this.parseAACPES(S):this.parseMPEGPES(S),f.pesData=null):(b!=null&&b.size&&E.logger.log("last AAC PES packet truncated,might overlap between fragments"),f.pesData=b),v&&(S=o(v))?(this.parseID3PES(S),s.pesData=null):s.pesData=v},m.demuxSampleAes=function(x,f,p){var s=this.demux(x,p,!0,!this.config.progressive),a=this.sampleAes=new B.default(this.observer,this.config,f);return this.decrypt(s,a)},m.decrypt=function(x,f){return new Promise(function(p){var s=x.audioTrack,a=x.avcTrack;s.samples&&s.isAAC?f.decryptAacSamples(s.samples,0,function(){a.samples?f.decryptAvcSamples(a.samples,0,0,function(){p(x)}):p(x)}):a.samples&&f.decryptAvcSamples(a.samples,0,0,function(){p(x)})})},m.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},m.parseAVCPES=function(x,f){var p=this,s=this._avcTrack,a=this.parseAVCNALu(x.data),b=!1,v=this.avcSample,S,M=!1;x.data=null,v&&a.length&&!s.audFound&&(c(v,s),v=this.avcSample=A(!1,x.pts,x.dts,"")),a.forEach(function(H){switch(H.type){case 1:{S=!0,v||(v=p.avcSample=A(!0,x.pts,x.dts,"")),b&&(v.debug+="NDR "),v.frame=!0;var V=H.data;if(M&&V.length>4){var Q=new I.default(V).readSliceType();(Q===2||Q===4||Q===7||Q===9)&&(v.key=!0)}break}case 5:S=!0,v||(v=p.avcSample=A(!0,x.pts,x.dts,"")),b&&(v.debug+="IDR "),v.key=!0,v.frame=!0;break;case 6:{S=!0,b&&v&&(v.debug+="SEI ");var G=new I.default(_(H.data));G.readUByte();for(var W=0,q=0,oe=!1,fe=0;!oe&&G.bytesAvailable>1;){W=0;do fe=G.readUByte(),W+=fe;while(fe===255);q=0;do fe=G.readUByte(),q+=fe;while(fe===255);if(W===4&&G.bytesAvailable!==0){oe=!0;var ve=G.readUByte();if(ve===181){var De=G.readUShort();if(De===49){var Ee=G.readUInt();if(Ee===1195456820){var _e=G.readUByte();if(_e===3){for(var Te=G.readUByte(),Ce=G.readUByte(),me=31&Te,ne=[Te,Ce],Ae=0;Ae16){for(var rt=[],$e=0;$e<16;$e++)rt.push(G.readUByte().toString(16)),($e===3||$e===5||$e===7||$e===9)&&rt.push("-");for(var Xe=q-16,Ve=new Uint8Array(Xe),Le=0;Le=0){var G={data:x.subarray(V,v-s-1),type:Q};b.push(G)}else{var W=this.getLastNalUnit();if(W&&(a&&v<=4-a&&(W.state&&(W.data=W.data.subarray(0,W.data.byteLength-a))),M=v-s-1,M>0)){var q=new Uint8Array(W.data.byteLength+M);q.set(W.data,0),q.set(x.subarray(0,M),W.data.byteLength),W.data=q,W.state=0}}v=0&&s>=0){var oe={data:x.subarray(V,f),type:Q,state:s};b.push(oe)}if(b.length===0){var fe=this.getLastNalUnit();if(fe){var ve=new Uint8Array(fe.data.byteLength+x.byteLength);ve.set(fe.data,0),ve.set(x,fe.data.byteLength),fe.data=ve}}return p.naluState=s,b},m.parseAACPES=function(x){var f=0,p=this._audioTrack,s=this.aacOverFlow,a=x.data;if(s){this.aacOverFlow=null;var b=s.sample.unit.byteLength,v=Math.min(s.missing,b),S=b-v;s.sample.unit.set(a.subarray(0,v),S),p.samples.push(s.sample),f=s.missing}var M,H;for(M=f,H=a.length;M1;){var b=new Uint8Array(a[0].length+a[1].length);b.set(a[0]),b.set(a[1],a[0].length),a[0]=b,a.splice(1,1)}l=a[0];var v=(l[0]<<16)+(l[1]<<8)+l[2];if(v===1){if(x=(l[4]<<8)+l[5],x&&x>y.size-6)return null;var S=l[7];S&192&&(p=(l[9]&14)*536870912+(l[10]&255)*4194304+(l[11]&254)*16384+(l[12]&255)*128+(l[13]&254)/2,S&64?(s=(l[14]&14)*536870912+(l[15]&255)*4194304+(l[16]&254)*16384+(l[17]&255)*128+(l[18]&254)/2,p-s>60*9e4&&(E.logger.warn(Math.round((p-s)/9e4)+"s delta between PTS and DTS, align them"),p=s)):s=p),f=l[8];var M=f+9;if(y.size<=M)return null;y.size-=M;for(var H=new Uint8Array(y.size),V=0,Q=a.length;VG){M-=G;continue}else l=l.subarray(M),G-=M,M=0;H.set(l,m),m+=G}return x&&(x-=f+3),{data:H,pts:p,dts:s,len:x}}return null}function c(y,m){if(y.units.length&&y.frame){if(y.pts===void 0){var l=m.samples,x=l.length;if(x){var f=l[x-1];y.pts=f.pts,y.dts=f.dts}else{m.dropped++;return}}m.samples.push(y)}y.debug.length&&E.logger.log(y.pts+"/"+y.dts+":"+y.debug)}function d(y,m){var l=y.length;if(l>0){if(m.pts>=y[l-1].pts)y.push(m);else for(var x=l-1;x>=0;x--)if(m.ptsp)return a;return 0}},{key:"maxAutoLevel",get:function(){var f=this.levels,p=this.autoLevelCapping,s;return p===-1&&f&&f.length?s=f.length-1:s=p,s}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(f){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,f)}},{key:"audioTracks",get:function(){var f=this.audioTrackController;return f?f.audioTracks:[]}},{key:"audioTrack",get:function(){var f=this.audioTrackController;return f?f.audioTrack:-1},set:function(f){var p=this.audioTrackController;p&&(p.audioTrack=f)}},{key:"subtitleTracks",get:function(){var f=this.subtitleTrackController;return f?f.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var f=this.subtitleTrackController;return f?f.subtitleTrack:-1},set:function(f){var p=this.subtitleTrackController;p&&(p.subtitleTrack=f)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var f=this.subtitleTrackController;return f?f.subtitleDisplay:!1},set:function(f){var p=this.subtitleTrackController;p&&(p.subtitleDisplay=f)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(f){this.config.lowLatencyMode=f}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return o.Events}},{key:"ErrorTypes",get:function(){return c.ErrorTypes}},{key:"ErrorDetails",get:function(){return c.ErrorDetails}},{key:"DefaultConfig",get:function(){return m.defaultConfig?m.defaultConfig:A.hlsDefaultConfig},set:function(f){m.defaultConfig=f}}]),m}();y.defaultConfig=void 0},"./src/is-supported.ts":function(ae,$,R){"use strict";R.r($),R.d($,"isSupported",function(){return I}),R.d($,"changeTypeSupported",function(){return z});var X=R("./src/utils/mediasource-helper.ts");function N(){return self.SourceBuffer||self.WebKitSourceBuffer}function I(){var B=Object(X.getMediaSource)();if(!B)return!1;var O=N(),D=B&&typeof B.isTypeSupported=="function"&&B.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),E=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!D&&!!E}function z(){var B,O=N();return typeof(O==null||((B=O.prototype)===null||B===void 0)?void 0:B.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return T}),R.d($,"LoadError",function(){return C});var X=R("./src/polyfills/number.ts"),N=R("./src/errors.ts");function I(h,o){h.prototype=Object.create(o.prototype),h.prototype.constructor=h,E(h,o)}function z(h){var o=typeof Map=="function"?new Map:void 0;return z=function(d){if(d===null||!D(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,_)}function _(){return B(d,arguments,L(this).constructor)}return _.prototype=Object.create(d.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),E(_,d)},z(h)}function B(h,o,c){return O()?B=Reflect.construct:B=function(_,y,m){var l=[null];l.push.apply(l,y);var x=Function.bind.apply(_,l),f=new x;return m&&E(f,m.prototype),f},B.apply(null,arguments)}function O(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(h){return!1}}function D(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function E(h,o){return E=Object.setPrototypeOf||function(d,_){return d.__proto__=_,d},E(h,o)}function L(h){return L=Object.setPrototypeOf?Object.getPrototypeOf:function(c){return c.__proto__||Object.getPrototypeOf(c)},L(h)}var k=Math.pow(2,17),T=function(){function h(c){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=c}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,_){var y=this,m=d.url;if(!m)return Promise.reject(new C({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,networkDetails:null},"Fragment does not have a "+(m?"part list":"url")));this.abort();var l=this.config,x=l.fLoader,f=l.loader;return new Promise(function(p,s){y.loader&&y.loader.destroy();var a=y.loader=d.loader=x?new x(l):new f(l),b=A(d),v={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:k};d.stats=a.stats,a.load(b,v,{onSuccess:function(M,H,V,Q){y.resetLoader(d,a),p({frag:d,part:null,payload:M.data,networkDetails:Q})},onError:function(M,H,V){y.resetLoader(d,a),s(new C({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,response:M,networkDetails:V}))},onAbort:function(M,H,V){y.resetLoader(d,a),s(new C({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:d,networkDetails:V}))},onTimeout:function(M,H,V){y.resetLoader(d,a),s(new C({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:d,networkDetails:V}))},onProgress:function(M,H,V,Q){_&&_({frag:d,part:null,payload:V,networkDetails:Q})}})})},o.loadPart=function(d,_,y){var m=this;this.abort();var l=this.config,x=l.fLoader,f=l.loader;return new Promise(function(p,s){m.loader&&m.loader.destroy();var a=m.loader=d.loader=x?new x(l):new f(l),b=A(d,_),v={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:k};_.stats=a.stats,a.load(b,v,{onSuccess:function(M,H,V,Q){m.resetLoader(d,a),m.updateStatsFromPart(d,_);var G={frag:d,part:_,payload:M.data,networkDetails:Q};y(G),p(G)},onError:function(M,H,V){m.resetLoader(d,a),s(new C({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,part:_,response:M,networkDetails:V}))},onAbort:function(M,H,V){d.stats.aborted=_.stats.aborted,m.resetLoader(d,a),s(new C({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:d,part:_,networkDetails:V}))},onTimeout:function(M,H,V){m.resetLoader(d,a),s(new C({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:d,part:_,networkDetails:V}))}})})},o.updateStatsFromPart=function(d,_){var y=d.stats,m=_.stats,l=m.total;if(y.loaded+=m.loaded,l){var x=Math.round(d.duration/_.duration),f=Math.min(Math.round(y.loaded/l),x),p=x-f,s=p*Math.round(y.loaded/f);y.total=y.loaded+s}else y.total=Math.max(y.loaded,y.total);var a=y.loading,b=m.loading;a.start?a.first+=b.first-b.start:(a.start=b.start,a.first=b.first),a.end=b.end},o.resetLoader=function(d,_){d.loader=null,this.loader===_&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),_.destroy()},h}();function A(h,o){o===void 0&&(o=null);var c=o||h,d={frag:h,part:o,responseType:"arraybuffer",url:c.url,headers:{},rangeStart:0,rangeEnd:0},_=c.byteRangeStartOffset,y=c.byteRangeEndOffset;return Object(X.isFiniteNumber)(_)&&Object(X.isFiniteNumber)(y)&&(d.rangeStart=_,d.rangeEnd=y),d}var C=function(h){I(o,h);function o(c){for(var d,_=arguments.length,y=new Array(_>1?_-1:0),m=1;m<_;m++)y[m-1]=arguments[m];return d=h.call.apply(h,[this].concat(y))||this,d.data=void 0,d.data=c,d}return o}(z(Error))},"./src/loader/fragment.ts":function(ae,$,R){"use strict";R.r($),R.d($,"ElementaryStreamTypes",function(){return T}),R.d($,"BaseSegment",function(){return A}),R.d($,"Fragment",function(){return C}),R.d($,"Part",function(){return h});var X=R("./src/polyfills/number.ts"),N=R("./node_modules/url-toolkit/src/url-toolkit.js"),I=R.n(N),z=R("./src/utils/logger.ts"),B=R("./src/loader/level-key.ts"),O=R("./src/loader/load-stats.ts");function D(o,c){o.prototype=Object.create(c.prototype),o.prototype.constructor=o,E(o,c)}function E(o,c){return E=Object.setPrototypeOf||function(_,y){return _.__proto__=y,_},E(o,c)}function L(o,c){for(var d=0;d>8*(15-l)&255;return m},d.setDecryptDataFromLevelKey=function(y,m){var l=y;return(y==null?void 0:y.method)==="AES-128"&&y.uri&&!y.iv&&(l=B.LevelKey.fromURI(y.uri),l.method=y.method,l.iv=this.createInitializationVector(m),l.keyFormat="identity"),l},d.setElementaryStreamInfo=function(y,m,l,x,f,p){p===void 0&&(p=!1);var s=this.elementaryStreams,a=s[y];if(!a){s[y]={startPTS:m,endPTS:l,startDTS:x,endDTS:f,partial:p};return}a.startPTS=Math.min(a.startPTS,m),a.endPTS=Math.max(a.endPTS,l),a.startDTS=Math.min(a.startDTS,x),a.endDTS=Math.max(a.endDTS,f)},d.clearElementaryStreamInfo=function(){var y=this.elementaryStreams;y[T.AUDIO]=null,y[T.VIDEO]=null,y[T.AUDIOVIDEO]=null},k(c,[{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)}}]),c}(A),h=function(o){D(c,o);function c(d,_,y,m,l){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 O.LoadStats,x.duration=d.decimalFloatingPoint("DURATION"),x.gap=d.bool("GAP"),x.independent=d.bool("INDEPENDENT"),x.relurl=d.enumeratedString("URI"),x.fragment=_,x.index=m;var f=d.enumeratedString("BYTERANGE");return f&&x.setByteRange(f,l),l&&(x.fragOffset=l.fragOffset+l.duration),x}return k(c,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var _=this.elementaryStreams;return!!(_.audio||_.video||_.audiovideo)}}]),c}(A)},"./src/loader/key-loader.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return z});var X=R("./src/events.ts"),N=R("./src/errors.ts"),I=R("./src/utils/logger.ts"),z=function(){function B(D){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=D,this._registerListeners()}var O=B.prototype;return O._registerListeners=function(){this.hls.on(X.Events.KEY_LOADING,this.onKeyLoading,this)},O._unregisterListeners=function(){this.hls.off(X.Events.KEY_LOADING,this.onKeyLoading)},O.destroy=function(){this._unregisterListeners();for(var E in this.loaders){var L=this.loaders[E];L&&L.destroy()}this.loaders={}},O.onKeyLoading=function(E,L){var k=L.frag,T=k.type,A=this.loaders[T];if(!k.decryptdata){I.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var C=k.decryptdata.uri;if(C!==this.decrypturl||this.decryptkey===null){var h=this.hls.config;if(A&&(I.logger.warn("abort previous key loader for type:"+T),A.abort()),!C){I.logger.warn("key uri is falsy");return}var o=h.loader,c=k.loader=this.loaders[T]=new o(h);this.decrypturl=C,this.decryptkey=null;var d={url:C,frag:k,responseType:"arraybuffer"},_={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)};c.load(d,_,y)}else this.decryptkey&&(k.decryptdata.key=this.decryptkey,this.hls.trigger(X.Events.KEY_LOADED,{frag:k}))},O.loadsuccess=function(E,L,k){var T=k.frag;if(!T.decryptdata){I.logger.error("after key load, decryptdata unset");return}this.decryptkey=T.decryptdata.key=new Uint8Array(E.data),T.loader=null,delete this.loaders[T.type],this.hls.trigger(X.Events.KEY_LOADED,{frag:T})},O.loaderror=function(E,L){var k=L.frag,T=k.loader;T&&T.abort(),delete this.loaders[k.type],this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:k,response:E})},O.loadtimeout=function(E,L){var k=L.frag,T=k.loader;T&&T.abort(),delete this.loaders[k.type],this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:k})},B}()},"./src/loader/level-details.ts":function(ae,$,R){"use strict";R.r($),R.d($,"LevelDetails",function(){return B});var X=R("./src/polyfills/number.ts");function N(O,D){for(var E=0;EL.endSN||k>0||k===0&&T>0,this.updated||this.advanced?this.misses=Math.floor(L.misses*.6):this.misses=L.misses+1,this.availabilityDelay=L.availabilityDelay},I(O,[{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 L=this.driftEndTime-this.driftStartTime;if(L>0){var k=this.driftEnd-this.driftStart;return k*1e3/L}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var L;return(L=this.partList)!==null&&L!==void 0&&L.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var L;return(L=this.fragments)!==null&&L!==void 0&&L.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 L;return(L=this.partList)!==null&&L!==void 0&&L.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var L;return(L=this.partList)!==null&&L!==void 0&&L.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),O}()},"./src/loader/level-key.ts":function(ae,$,R){"use strict";R.r($),R.d($,"LevelKey",function(){return B});var X=R("./node_modules/url-toolkit/src/url-toolkit.js"),N=R.n(X);function I(O,D){for(var E=0;E2){var s=p.shift()+".";return s+=parseInt(p.shift()).toString(16),s+=("000"+parseInt(p.shift()).toString(16)).substr(-4),s}return f},l.resolve=function(f,p){return N.buildAbsoluteURL(p,f,{alwaysNormalize:!0})},l.parseMasterPlaylist=function(f,p){var s=[],a={},b=!1;k.lastIndex=0;for(var v;(v=k.exec(f))!=null;)if(v[1]){var S=new D.AttrList(v[1]),M={attrs:S,bitrate:S.decimalInteger("AVERAGE-BANDWIDTH")||S.decimalInteger("BANDWIDTH"),name:S.NAME,url:l.resolve(v[2],p)},H=S.decimalResolution("RESOLUTION");H&&(M.width=H.width,M.height=H.height),d((S.CODECS||"").split(/[ ,]+/).filter(function(Q){return Q}),M),M.videoCodec&&M.videoCodec.indexOf("avc1")!==-1&&(M.videoCodec=l.convertAVC1ToAVCOTI(M.videoCodec)),s.push(M)}else if(v[3]){var V=new D.AttrList(v[3]);V["DATA-ID"]&&(b=!0,a[V["DATA-ID"]]=V)}return{levels:s,sessionData:b?a:null}},l.parseMasterPlaylistMedia=function(f,p,s,a){a===void 0&&(a=[]);var b,v=[],S=0;for(T.lastIndex=0;(b=T.exec(f))!==null;){var M=new D.AttrList(b[1]);if(M.TYPE===s){var H={attrs:M,bitrate:0,id:S++,groupId:M["GROUP-ID"],instreamId:M["INSTREAM-ID"],name:M.NAME||M.LANGUAGE||"",type:s,default:M.bool("DEFAULT"),autoselect:M.bool("AUTOSELECT"),forced:M.bool("FORCED"),lang:M.LANGUAGE,url:M.URI?l.resolve(M.URI,p):""};if(a.length){var V=l.findGroup(a,H.groupId)||a[0];_(H,V,"audioCodec"),_(H,V,"textCodec")}v.push(H)}}return v},l.parseLevelPlaylist=function(f,p,s,a,b){var v=new B.LevelDetails(p),S=v.fragments,M=null,H=0,V=0,Q=0,G=0,W=null,q=new z.Fragment(a,p),oe,fe,ve,De=-1,Ee=!1;for(A.lastIndex=0,v.m3u8=f;(oe=A.exec(f))!==null;){Ee&&(Ee=!1,q=new z.Fragment(a,p),q.start=Q,q.sn=H,q.cc=G,q.level=s,M&&(q.initSegment=M,q.rawProgramDateTime=M.rawProgramDateTime));var _e=oe[1];if(_e){q.duration=parseFloat(_e);var Te=(" "+oe[2]).slice(1);q.title=Te||null,q.tagList.push(Te?["INF",_e,Te]:["INF",_e])}else if(oe[3])Object(X.isFiniteNumber)(q.duration)&&(q.start=Q,ve&&(q.levelkey=ve),q.sn=H,q.level=s,q.cc=G,q.urlId=b,S.push(q),q.relurl=(" "+oe[3]).slice(1),m(q,W),W=q,Q+=q.duration,H++,V=0,Ee=!0);else if(oe[4]){var Ce=(" "+oe[4]).slice(1);W?q.setByteRange(Ce,W):q.setByteRange(Ce)}else if(oe[5])q.rawProgramDateTime=(" "+oe[5]).slice(1),q.tagList.push(["PROGRAM-DATE-TIME",q.rawProgramDateTime]),De===-1&&(De=S.length);else{if(oe=oe[0].match(C),!oe){E.logger.warn("No matches on slow regex match for level playlist!");continue}for(fe=1;fe-1){E.logger.warn("Keyformat "+pt+" is not supported from the manifest");continue}else if(pt!=="identity")continue;ze&&(ve=O.LevelKey.fromURL(p,Ge),Ge&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(ze)>=0&&(ve.method=ze,ve.keyFormat=pt,Pe&&(ve.keyID=Pe),Be&&(ve.keyFormatVersions=Be),ve.iv=He));break}case"START":{var et=new D.AttrList(ne),at=et.decimalFloatingPoint("TIME-OFFSET");Object(X.isFiniteNumber)(at)&&(v.startTimeOffset=at);break}case"MAP":{var Et=new D.AttrList(ne);q.relurl=Et.URI,Et.BYTERANGE&&q.setByteRange(Et.BYTERANGE),q.level=s,q.sn="initSegment",ve&&(q.levelkey=ve),q.initSegment=null,M=q,Ee=!0;break}case"SERVER-CONTROL":{var ct=new D.AttrList(ne);v.canBlockReload=ct.bool("CAN-BLOCK-RELOAD"),v.canSkipUntil=ct.optionalFloat("CAN-SKIP-UNTIL",0),v.canSkipDateRanges=v.canSkipUntil>0&&ct.bool("CAN-SKIP-DATERANGES"),v.partHoldBack=ct.optionalFloat("PART-HOLD-BACK",0),v.holdBack=ct.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var dt=new D.AttrList(ne);v.partTarget=dt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var we=v.partList;we||(we=v.partList=[]);var gt=V>0?we[we.length-1]:void 0,lt=V++,Re=new z.Part(new D.AttrList(ne),q,p,lt,gt);we.push(Re),q.duration+=Re.duration;break}case"PRELOAD-HINT":{var je=new D.AttrList(ne);v.preloadHint=je;break}case"RENDITION-REPORT":{var ge=new D.AttrList(ne);v.renditionReports=v.renditionReports||[],v.renditionReports.push(ge);break}default:E.logger.warn("line parsed but not handled: "+oe);break}}}W&&!W.relurl?(S.pop(),Q-=W.duration,v.partList&&(v.fragmentHint=W)):v.partList&&(m(q,W),q.cc=G,v.fragmentHint=q);var de=S.length,pe=S[0],ee=S[de-1];if(Q+=v.skippedSegments*v.targetduration,Q>0&&de&&ee){v.averagetargetduration=Q/de;var te=ee.sn;v.endSN=te!=="initSegment"?te:0,pe&&(v.startCC=pe.cc,pe.initSegment||v.fragments.every(function(ie){return ie.relurl&&o(ie.relurl)})&&(E.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),q=new z.Fragment(a,p),q.relurl=ee.relurl,q.level=s,q.sn="initSegment",pe.initSegment=q,v.needSidxRanges=!0))}else v.endSN=0,v.startCC=0;return v.fragmentHint&&(Q+=v.fragmentHint.duration),v.totalduration=Q,v.endCC=G,De>0&&y(S,De),v},l}();function d(l,x){["video","audio","text"].forEach(function(f){var p=l.filter(function(a){return Object(L.isCodecType)(a,f)});if(p.length){var s=p.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});x[f+"Codec"]=s.length>0?s[0]:p[0],l=l.filter(function(a){return p.indexOf(a)===-1})}}),x.unknownCodecs=l}function _(l,x,f){var p=x[f];p&&(l[f]=p)}function y(l,x){for(var f=l[x],p=x;p--;){var s=l[p];if(!s)return;s.programDateTime=f.programDateTime-s.duration*1e3,f=s}}function m(l,x){l.rawProgramDateTime?l.programDateTime=Date.parse(l.rawProgramDateTime):x!=null&&x.programDateTime&&(l.programDateTime=x.endProgramDateTime),Object(X.isFiniteNumber)(l.programDateTime)||(l.programDateTime=null,l.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/polyfills/number.ts"),N=R("./src/events.ts"),I=R("./src/errors.ts"),z=R("./src/utils/logger.ts"),B=R("./src/utils/mp4-tools.ts"),O=R("./src/loader/m3u8-parser.ts"),D=R("./src/types/loader.ts"),E=R("./src/utils/attr-list.ts");function L(A){var C=A.type;switch(C){case D.PlaylistContextType.AUDIO_TRACK:return D.PlaylistLevelType.AUDIO;case D.PlaylistContextType.SUBTITLE_TRACK:return D.PlaylistLevelType.SUBTITLE;default:return D.PlaylistLevelType.MAIN}}function k(A,C){var h=A.url;return(h===void 0||h.indexOf("data:")===0)&&(h=C.url),h}var T=function(){function A(h){this.hls=void 0,this.loaders=Object.create(null),this.hls=h,this.registerListeners()}var C=A.prototype;return C.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)},C.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)},C.createInternalLoader=function(o){var c=this.hls.config,d=c.pLoader,_=c.loader,y=d||_,m=new y(c);return o.loader=m,this.loaders[o.type]=m,m},C.getInternalLoader=function(o){return this.loaders[o.type]},C.resetInternalLoader=function(o){this.loaders[o]&&delete this.loaders[o]},C.destroyInternalLoaders=function(){for(var o in this.loaders){var c=this.loaders[o];c&&c.destroy(),this.resetInternalLoader(o)}},C.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},C.onManifestLoading=function(o,c){var d=c.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:D.PlaylistContextType.MANIFEST,url:d,deliveryDirectives:null})},C.onLevelLoading=function(o,c){var d=c.id,_=c.level,y=c.url,m=c.deliveryDirectives;this.load({id:d,groupId:null,level:_,responseType:"text",type:D.PlaylistContextType.LEVEL,url:y,deliveryDirectives:m})},C.onAudioTrackLoading=function(o,c){var d=c.id,_=c.groupId,y=c.url,m=c.deliveryDirectives;this.load({id:d,groupId:_,level:null,responseType:"text",type:D.PlaylistContextType.AUDIO_TRACK,url:y,deliveryDirectives:m})},C.onSubtitleTrackLoading=function(o,c){var d=c.id,_=c.groupId,y=c.url,m=c.deliveryDirectives;this.load({id:d,groupId:_,level:null,responseType:"text",type:D.PlaylistContextType.SUBTITLE_TRACK,url:y,deliveryDirectives:m})},C.load=function(o){var c,d=this.hls.config,_=this.getInternalLoader(o);if(_){var y=_.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),_.abort()}var m,l,x,f;switch(o.type){case D.PlaylistContextType.MANIFEST:m=d.manifestLoadingMaxRetry,l=d.manifestLoadingTimeOut,x=d.manifestLoadingRetryDelay,f=d.manifestLoadingMaxRetryTimeout;break;case D.PlaylistContextType.LEVEL:case D.PlaylistContextType.AUDIO_TRACK:case D.PlaylistContextType.SUBTITLE_TRACK:m=0,l=d.levelLoadingTimeOut;break;default:m=d.levelLoadingMaxRetry,l=d.levelLoadingTimeOut,x=d.levelLoadingRetryDelay,f=d.levelLoadingMaxRetryTimeout;break}if(_=this.createInternalLoader(o),(c=o.deliveryDirectives)!==null&&c!==void 0&&c.part){var p;if(o.type===D.PlaylistContextType.LEVEL&&o.level!==null?p=this.hls.levels[o.level].details:o.type===D.PlaylistContextType.AUDIO_TRACK&&o.id!==null?p=this.hls.audioTracks[o.id].details:o.type===D.PlaylistContextType.SUBTITLE_TRACK&&o.id!==null&&(p=this.hls.subtitleTracks[o.id].details),p){var s=p.partTarget,a=p.targetduration;s&&a&&(l=Math.min(Math.max(s*3,a*.8)*1e3,l))}}var b={timeout:l,maxRetry:m,retryDelay:x,maxRetryDelay:f,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};_.load(o,b,v)},C.loadsuccess=function(o,c,d,_){if(_===void 0&&(_=null),d.isSidxRequest){this.handleSidxRequest(o,d),this.handlePlaylistLoaded(o,c,d,_);return}this.resetInternalLoader(d.type);var y=o.data;if(y.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(o,d,"no EXTM3U delimiter",_);return}c.parsing.start=performance.now(),y.indexOf("#EXTINF:")>0||y.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(o,c,d,_):this.handleMasterPlaylist(o,c,d,_)},C.loaderror=function(o,c,d){d===void 0&&(d=null),this.handleNetworkError(c,d,!1,o)},C.loadtimeout=function(o,c,d){d===void 0&&(d=null),this.handleNetworkError(c,d,!0)},C.handleMasterPlaylist=function(o,c,d,_){var y=this.hls,m=o.data,l=k(o,d),x=O.default.parseMasterPlaylist(m,l),f=x.levels,p=x.sessionData;if(!f.length){this.handleManifestParsingError(o,d,"no level found in manifest",_);return}var s=f.map(function(H){return{id:H.attrs.AUDIO,audioCodec:H.audioCodec}}),a=f.map(function(H){return{id:H.attrs.SUBTITLES,textCodec:H.textCodec}}),b=O.default.parseMasterPlaylistMedia(m,l,"AUDIO",s),v=O.default.parseMasterPlaylistMedia(m,l,"SUBTITLES",a),S=O.default.parseMasterPlaylistMedia(m,l,"CLOSED-CAPTIONS");if(b.length){var M=b.some(function(H){return!H.url});!M&&f[0].audioCodec&&!f[0].attrs.AUDIO&&(z.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),b.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new E.AttrList({}),bitrate:0,url:""}))}y.trigger(N.Events.MANIFEST_LOADED,{levels:f,audioTracks:b,subtitles:v,captions:S,url:l,stats:c,networkDetails:_,sessionData:p})},C.handleTrackOrLevelPlaylist=function(o,c,d,_){var y=this.hls,m=d.id,l=d.level,x=d.type,f=k(o,d),p=Object(X.isFiniteNumber)(m)?m:0,s=Object(X.isFiniteNumber)(l)?l:p,a=L(d),b=O.default.parseLevelPlaylist(o.data,f,s,a,p);if(!b.fragments.length){y.trigger(N.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:f,reason:"no fragments found in level",level:typeof d.level=="number"?d.level:void 0});return}if(x===D.PlaylistContextType.MANIFEST){var v={attrs:new E.AttrList({}),bitrate:0,details:b,name:"",url:f};y.trigger(N.Events.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:f,stats:c,networkDetails:_,sessionData:null})}if(c.parsing.end=performance.now(),b.needSidxRanges){var S,M=(S=b.fragments[0].initSegment)===null||S===void 0?void 0:S.url;this.load({url:M,isSidxRequest:!0,type:x,level:l,levelDetails:b,id:m,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}d.levelDetails=b,this.handlePlaylistLoaded(o,c,d,_)},C.handleSidxRequest=function(o,c){var d=Object(B.parseSegmentIndex)(new Uint8Array(o.data));if(!d)return;var _=d.references,y=c.levelDetails;_.forEach(function(m,l){var x=m.info,f=y.fragments[l];f.byteRange.length===0&&f.setByteRange(String(1+x.end-x.start)+"@"+String(x.start)),f.initSegment&&f.initSegment.setByteRange(String(d.moovEndOffset)+"@0")})},C.handleManifestParsingError=function(o,c,d,_){this.hls.trigger(N.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:c.type===D.PlaylistContextType.MANIFEST,url:o.url,reason:d,response:o,context:c,networkDetails:_})},C.handleNetworkError=function(o,c,d,_){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,m=!1,l=this.getInternalLoader(o);switch(o.type){case D.PlaylistContextType.MANIFEST:y=d?I.ErrorDetails.MANIFEST_LOAD_TIMEOUT:I.ErrorDetails.MANIFEST_LOAD_ERROR,m=!0;break;case D.PlaylistContextType.LEVEL:y=d?I.ErrorDetails.LEVEL_LOAD_TIMEOUT:I.ErrorDetails.LEVEL_LOAD_ERROR,m=!1;break;case D.PlaylistContextType.AUDIO_TRACK:y=d?I.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:I.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,m=!1;break;case D.PlaylistContextType.SUBTITLE_TRACK:y=d?I.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:I.ErrorDetails.SUBTITLE_LOAD_ERROR,m=!1;break}l&&this.resetInternalLoader(o.type);var x={type:I.ErrorTypes.NETWORK_ERROR,details:y,fatal:m,url:o.url,loader:l,context:o,networkDetails:c};_&&(x.response=_),this.hls.trigger(N.Events.ERROR,x)},C.handlePlaylistLoaded=function(o,c,d,_){var y=d.type,m=d.level,l=d.id,x=d.groupId,f=d.loader,p=d.levelDetails,s=d.deliveryDirectives;if(!(p!=null&&p.targetduration)){this.handleManifestParsingError(o,d,"invalid target duration",_);return}if(!f)return;p.live&&(f.getCacheAge&&(p.ageHeader=f.getCacheAge()||0),(!f.getCacheAge||isNaN(p.ageHeader))&&(p.ageHeader=0));switch(y){case D.PlaylistContextType.MANIFEST:case D.PlaylistContextType.LEVEL:this.hls.trigger(N.Events.LEVEL_LOADED,{details:p,level:m||0,id:l||0,stats:c,networkDetails:_,deliveryDirectives:s});break;case D.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(N.Events.AUDIO_TRACK_LOADED,{details:p,id:l||0,groupId:x||"",stats:c,networkDetails:_,deliveryDirectives:s});break;case D.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(N.Events.SUBTITLE_TRACK_LOADED,{details:p,id:l||0,groupId:x||"",stats:c,networkDetails:_,deliveryDirectives:s});break}},A}();$.default=T},"./src/polyfills/number.ts":function(ae,$,R){"use strict";R.r($),R.d($,"isFiniteNumber",function(){return X}),R.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(ae,$,R){"use strict";R.r($);var X=function(){function N(){}return N.getSilentFrame=function(z,B){switch(z){case"mp4a.40.2":if(B===1)return new Uint8Array([0,200,0,128,35,128]);if(B===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(B===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(B===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(B===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(B===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(B===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(B===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(B===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(ae,$,R){"use strict";R.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 B;for(B in I.types)I.types.hasOwnProperty(B)&&(I.types[B]=[B.charCodeAt(0),B.charCodeAt(1),B.charCodeAt(2),B.charCodeAt(3)]);var O=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]),D=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:O,audio:D};var E=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),L=new Uint8Array([0,0,0,0,0,0,0,0]);I.STTS=I.STSC=I.STCO=L,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 k=new Uint8Array([105,115,111,109]),T=new Uint8Array([97,118,99,49]),A=new Uint8Array([0,0,0,1]);I.FTYP=I.box(I.types.ftyp,k,A,k,T),I.DINF=I.box(I.types.dinf,I.box(I.types.dref,E))},I.box=function(B){for(var O=8,D=arguments.length,E=new Array(D>1?D-1:0),L=1;L>24&255,A[1]=O>>16&255,A[2]=O>>8&255,A[3]=O&255,A.set(B,4),k=0,O=8;k>24&255,B>>16&255,B>>8&255,B&255,D>>24,D>>16&255,D>>8&255,D&255,E>>24,E>>16&255,E>>8&255,E&255,85,196,0,0]))},I.mdia=function(B){return I.box(I.types.mdia,I.mdhd(B.timescale,B.duration),I.hdlr(B.type),I.minf(B))},I.mfhd=function(B){return I.box(I.types.mfhd,new Uint8Array([0,0,0,0,B>>24,B>>16&255,B>>8&255,B&255]))},I.minf=function(B){return B.type==="audio"?I.box(I.types.minf,I.box(I.types.smhd,I.SMHD),I.DINF,I.stbl(B)):I.box(I.types.minf,I.box(I.types.vmhd,I.VMHD),I.DINF,I.stbl(B))},I.moof=function(B,O,D){return I.box(I.types.moof,I.mfhd(B),I.traf(D,O))},I.moov=function(B){for(var O=B.length,D=[];O--;)D[O]=I.trak(B[O]);return I.box.apply(null,[I.types.moov,I.mvhd(B[0].timescale,B[0].duration)].concat(D).concat(I.mvex(B)))},I.mvex=function(B){for(var O=B.length,D=[];O--;)D[O]=I.trex(B[O]);return I.box.apply(null,[I.types.mvex].concat(D))},I.mvhd=function(B,O){O*=B;var D=Math.floor(O/(X+1)),E=Math.floor(O%(X+1)),L=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,B>>24&255,B>>16&255,B>>8&255,B&255,D>>24,D>>16&255,D>>8&255,D&255,E>>24,E>>16&255,E>>8&255,E&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,L)},I.sdtp=function(B){var O=B.samples||[],D=new Uint8Array(4+O.length),E,L;for(E=0;E>>8&255),O.push(k&255),O=O.concat(Array.prototype.slice.call(L));for(E=0;E>>8&255),D.push(k&255),D=D.concat(Array.prototype.slice.call(L));var T=I.box(I.types.avcC,new Uint8Array([1,O[3],O[4],O[5],252|3,224|B.sps.length].concat(O).concat([B.pps.length]).concat(D))),A=B.width,C=B.height,h=B.pixelRatio[0],o=B.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,A>>8&255,A&255,C>>8&255,C&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]),T,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(B){var O=B.config.length;return new Uint8Array([0,0,0,0,3,23+O,0,1,0,4,15+O,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([O]).concat(B.config).concat([6,1,2]))},I.mp4a=function(B){var O=B.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,B.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]),I.box(I.types.esds,I.esds(B)))},I.mp3=function(B){var O=B.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,B.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]))},I.stsd=function(B){return B.type==="audio"?!B.isAAC&&B.codec==="mp3"?I.box(I.types.stsd,I.STSD,I.mp3(B)):I.box(I.types.stsd,I.STSD,I.mp4a(B)):I.box(I.types.stsd,I.STSD,I.avc1(B))},I.tkhd=function(B){var O=B.id,D=B.duration*B.timescale,E=B.width,L=B.height,k=Math.floor(D/(X+1)),T=Math.floor(D%(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,O>>24&255,O>>16&255,O>>8&255,O&255,0,0,0,0,k>>24,k>>16&255,k>>8&255,k&255,T>>24,T>>16&255,T>>8&255,T&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,E>>8&255,E&255,0,0,L>>8&255,L&255,0,0]))},I.traf=function(B,O){var D=I.sdtp(B),E=B.id,L=Math.floor(O/(X+1)),k=Math.floor(O%(X+1));return I.box(I.types.traf,I.box(I.types.tfhd,new Uint8Array([0,0,0,0,E>>24,E>>16&255,E>>8&255,E&255])),I.box(I.types.tfdt,new Uint8Array([1,0,0,0,L>>24,L>>16&255,L>>8&255,L&255,k>>24,k>>16&255,k>>8&255,k&255])),I.trun(B,D.length+16+20+8+16+8+8),D)},I.trak=function(B){return B.duration=B.duration||4294967295,I.box(I.types.trak,I.tkhd(B),I.mdia(B))},I.trex=function(B){var O=B.id;return I.box(I.types.trex,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},I.trun=function(B,O){var D=B.samples||[],E=D.length,L=12+16*E,k=new Uint8Array(L),T,A,C,h,o,c;for(O+=8+L,k.set([0,0,15,1,E>>>24&255,E>>>16&255,E>>>8&255,E&255,O>>>24&255,O>>>16&255,O>>>8&255,O&255],0),T=0;T>>24&255,C>>>16&255,C>>>8&255,C&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,c>>>24&255,c>>>16&255,c>>>8&255,c&255],12+16*T);return I.box(I.types.trun,k)},I.initSegment=function(B){I.types||I.init();var O=I.moov(B),D=new Uint8Array(I.FTYP.byteLength+O.byteLength);return D.set(I.FTYP),D.set(O,I.FTYP.byteLength),D},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(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return c}),R.d($,"normalizePts",function(){return d});var X=R("./src/polyfills/number.ts"),N=R("./src/remux/aac-helper.ts"),I=R("./src/remux/mp4-generator.ts"),z=R("./src/events.ts"),B=R("./src/errors.ts"),O=R("./src/utils/logger.ts"),D=R("./src/types/loader.ts"),E=R("./src/utils/timescale-conversion.ts");function L(){return L=Object.assign||function(l){for(var x=1;x0?b:v.pts},p[0].pts);return s&&O.logger.debug("PTS rollover detected"),a},x.remux=function(p,s,a,b,v,S,M,H){var V,Q,G,W,q,oe,fe=v,ve=v,De=p.pid>-1,Ee=s.pid>-1,_e=s.samples.length,Te=p.samples.length>0,Ce=_e>1,me=(!De||Te)&&(!Ee||Ce)||this.ISGenerated||M;if(me){this.ISGenerated||(G=this.generateIS(p,s,v));var ne=this.isVideoContiguous,Ae=-1;if(Ce&&(Ae=_(s.samples),!ne&&this.config.forceKeyFrameOnDiscontinuity))if(oe=!0,Ae>0){O.logger.warn("[mp4-remuxer]: Dropped "+Ae+" out of "+_e+" video samples due to a missing keyframe");var rt=this.getVideoStartPts(s.samples);s.samples=s.samples.slice(Ae),s.dropped+=Ae,ve+=(s.samples[0].pts-rt)/(s.timescale||9e4)}else Ae===-1&&(O.logger.warn("[mp4-remuxer]: No keyframe found out of "+_e+" video samples"),oe=!1);if(this.ISGenerated){if(Te&&Ce){var $e=this.getVideoStartPts(s.samples),Xe=d(p.samples[0].pts,$e)-$e,Ve=Xe/s.inputTimeScale;fe+=Math.max(0,Ve),ve+=Math.max(0,-Ve)}if(Te){if(p.samplerate||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),G=this.generateIS(p,s,v)),Q=this.remuxAudio(p,fe,this.isAudioContiguous,S,Ee||Ce||H===D.PlaylistLevelType.AUDIO?ve:void 0),Ce){var Le=Q?Q.endPTS-Q.startPTS:0;s.inputTimeScale||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),G=this.generateIS(p,s,v)),V=this.remuxVideo(s,ve,ne,Le)}}else Ce&&(V=this.remuxVideo(s,ve,ne,0));V&&(V.firstKeyFrame=Ae,V.independent=Ae!==-1)}}return this.ISGenerated&&(a.samples.length&&(q=this.remuxID3(a,v)),b.samples.length&&(W=this.remuxText(b,v))),{audio:Q,video:V,initSegment:G,independent:oe,text:W,id3:q}},x.generateIS=function(p,s,a){var b=p.samples,v=s.samples,S=this.typeSupported,M={},H=!Object(X.isFiniteNumber)(this._initPTS),V="audio/mp4",Q,G,W;if(H&&(Q=G=Infinity),p.config&&b.length&&(p.timescale=p.samplerate,p.isAAC||(S.mpeg?(V="audio/mpeg",p.codec=""):S.mp3&&(p.codec="mp3")),M.audio={id:"audio",container:V,codec:p.codec,initSegment:!p.isAAC&&S.mpeg?new Uint8Array(0):I.default.initSegment([p]),metadata:{channelCount:p.channelCount}},H&&(W=p.inputTimeScale,Q=G=b[0].pts-Math.round(W*a))),s.sps&&s.pps&&v.length&&(s.timescale=s.inputTimeScale,M.video={id:"main",container:"video/mp4",codec:s.codec,initSegment:I.default.initSegment([s]),metadata:{width:s.width,height:s.height}},H)){W=s.inputTimeScale;var q=this.getVideoStartPts(v),oe=Math.round(W*a);G=Math.min(G,d(v[0].dts,q)-oe),Q=Math.min(Q,q-oe)}if(Object.keys(M).length)return this.ISGenerated=!0,H&&(this._initPTS=Q,this._initDTS=G),{tracks:M,initPTS:Q,timescale:W}},x.remuxVideo=function(p,s,a,b){var v=p.inputTimeScale,S=p.samples,M=[],H=S.length,V=this._initPTS,Q=this.nextAvcDts,G=8,W,q,oe,fe=Number.POSITIVE_INFINITY,ve=Number.NEGATIVE_INFINITY,De=0,Ee=!1;if(!a||Q===null){var _e=s*v,Te=S[0].pts-d(S[0].dts,S[0].pts);Q=_e-Te}for(var Ce=0;Ceme.pts){var ne=9e4*.2;De=Math.max(Math.min(De,me.pts-me.dts),-1*ne)}me.dts0?Ce-1:Ce].dts&&(Ee=!0)}Ee&&S.sort(function(Dt,Ze){var ut=Dt.dts-Ze.dts,Ft=Dt.pts-Ze.pts;return ut||Ft}),q=S[0].dts,oe=S[S.length-1].dts;var Ae=Math.round((oe-q)/(H-1));if(De<0){if(DeAe,Me=Ve<-1;if(Le||Me){Le?O.logger.warn("AVC: "+Object(E.toMsFromMpegTsClock)(Ve,!0)+" ms ("+Ve+"dts) hole between fragments detected, filling it"):O.logger.warn("AVC: "+Object(E.toMsFromMpegTsClock)(-Ve,!0)+" ms ("+Ve+"dts) overlapping between fragments detected"),q=Q;var ze=S[0].pts-Ve;S[0].dts=q,S[0].pts=ze,O.logger.log("Video: First PTS/DTS adjusted: "+Object(E.toMsFromMpegTsClock)(ze,!0)+"/"+Object(E.toMsFromMpegTsClock)(q,!0)+", delta: "+Object(E.toMsFromMpegTsClock)(Ve,!0)+" ms")}}o&&(q=Math.max(0,q));for(var Ge=0,He=0,Be=0;Be0?we-1:we].dts;if(te.stretchShortVideoTrack&&this.nextAudioPts!==null){var se=Math.floor(te.maxBufferHole*v),ue=(b?fe+b*v:this.nextAudioPts)-gt.pts;ue>se?(W=ue-ie,W<0&&(W=ie),O.logger.log("[mp4-remuxer]: It is approximately "+ue/90+" ms to the next segment; using duration "+W/90+" ms for the last video frame.")):W=ie}else W=ie}var Se=Math.round(gt.pts-gt.dts);M.push(new y(gt.key,W,Re,Se))}if(M.length&&C&&C<70){var ke=M[0].flags;ke.dependsOn=2,ke.isNonSync=0}console.assert(W!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=Q=oe+W,this.isVideoContiguous=!0;var Je=I.default.moof(p.sequenceNumber++,q,L({},p,{samples:M})),Qe="video",bt={data1:Je,data2:ct,startPTS:fe/v,endPTS:(ve+W)/v,startDTS:q/v,endDTS:Q/v,type:Qe,hasAudio:!1,hasVideo:!0,nb:M.length,dropped:p.dropped};return p.samples=[],p.dropped=0,console.assert(ct.length,"MDAT length must not be zero"),bt},x.remuxAudio=function(p,s,a,b,v){var S=p.inputTimeScale,M=p.samplerate?p.samplerate:S,H=S/M,V=p.isAAC?T:A,Q=V*H,G=this._initPTS,W=!p.isAAC&&this.typeSupported.mpeg,q=[],oe=p.samples,fe=W?0:8,ve=this.nextAudioPts||-1,De=s*S;if(this.isAudioContiguous=a=a||oe.length&&ve>0&&(b&&Math.abs(De-ve)<9e3||Math.abs(d(oe[0].pts-G,De)-ve)<20*Q),oe.forEach(function(pe){pe.pts=d(pe.pts-G,De)}),!a||ve<0){if(oe=oe.filter(function(pe){return pe.pts>=0}),!oe.length)return;v===0?ve=0:b?ve=Math.max(0,De):ve=oe[0].pts}if(p.isAAC)for(var Ee=v!==void 0,_e=this.config.maxAudioFramesDrift,Te=0,Ce=ve;Te=_e*Q&&rt0){He+=fe;try{Ge=new Uint8Array(He)}catch(pe){this.observer.emit(z.Events.ERROR,z.Events.ERROR,{type:B.ErrorTypes.MUX_ERROR,details:B.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:He,reason:"fail allocating audio mdat "+He});return}if(!W){var ct=new DataView(Ge.buffer);ct.setUint32(0,He),Ge.set(I.default.types.mdat,4)}}else return;Ge.set(et,fe);var dt=et.byteLength;fe+=dt,q.push(new y(!0,V,dt,0)),ze=at}var we=q.length;if(!we)return;var gt=q[q.length-1];this.nextAudioPts=ve=ze+H*gt.duration;var lt=W?new Uint8Array(0):I.default.moof(p.sequenceNumber++,Me/H,L({},p,{samples:q}));p.samples=[];var Re=Me/S,je=ve/S,ge="audio",de={data1:lt,data2:Ge,startPTS:Re,endPTS:je,startDTS:Re,endDTS:je,type:ge,hasAudio:!0,hasVideo:!1,nb:we};return this.isAudioContiguous=!0,console.assert(Ge.length,"MDAT length must not be zero"),de},x.remuxEmptyAudio=function(p,s,a,b){var v=p.inputTimeScale,S=p.samplerate?p.samplerate:v,M=v/S,H=this.nextAudioPts,V=(H!==null?H:b.startDTS*v)+this._initDTS,Q=b.endDTS*v+this._initDTS,G=M*T,W=Math.ceil((Q-V)/G),q=N.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount);if(O.logger.warn("[mp4-remuxer]: remux empty Audio"),!q){O.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var oe=[],fe=0;fe4294967296;)l+=f;return l}function _(l){for(var x=0;x0?this.lastEndDTS=p:(z.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var s=!!l.audio,a=!!l.video,b="";s&&(b+="audio"),a&&(b+="video");var v={data1:y,startPTS:f,startDTS:f,endPTS:p,endDTS:p,type:b,hasAudio:s,hasVideo:a,nb:1,dropped:0};return _.audio=v.type==="audio"?v:void 0,_.video=v.type!=="audio"?v:void 0,_.text=h,_.id3=C,_.initSegment=m,_},E}(),O=function(L,k,T){return Object(N.getStartDTS)(L,k)-T};function D(E,L){var k=E==null?void 0:E.codec;return k&&k.length>4?k:k==="hvc1"?"hvc1.1.c.L120.90":k==="av01"?"av01.0.04M.08":k==="avc1"||L===I.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}$.default=B},"./src/task-loop.ts":function(ae,$,R){"use strict";R.r($),R.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(B){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,B),!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(ae,$,R){"use strict";R.r($),R.d($,"CMCDVersion",function(){return X}),R.d($,"CMCDObjectType",function(){return N}),R.d($,"CMCDStreamingFormat",function(){return I}),R.d($,"CMCDStreamType",function(){return z});var X=1,N;(function(B){B.MANIFEST="m",B.AUDIO="a",B.VIDEO="v",B.MUXED="av",B.INIT="i",B.CAPTION="c",B.TIMED_TEXT="tt",B.KEY="k",B.OTHER="o"})(N||(N={}));var I;(function(B){B.DASH="d",B.HLS="h",B.SMOOTH="s",B.OTHER="o"})(I||(I={}));var z;(function(B){B.VOD="v",B.LIVE="l"})(z||(z={}))},"./src/types/level.ts":function(ae,$,R){"use strict";R.r($),R.d($,"HlsSkip",function(){return I}),R.d($,"getSkipValue",function(){return z}),R.d($,"HlsUrlParameters",function(){return B}),R.d($,"Level",function(){return O});function X(D,E){for(var L=0;LNumber.MAX_SAFE_INTEGER?Infinity:E},B.hexadecimalInteger=function(D){if(this[D]){var E=(this[D]||"0x").slice(2);E=(E.length&1?"0":"")+E;for(var L=new Uint8Array(E.length/2),k=0;kNumber.MAX_SAFE_INTEGER?Infinity:E},B.decimalFloatingPoint=function(D){return parseFloat(this[D])},B.optionalFloat=function(D,E){var L=this[D];return L?parseFloat(L):E},B.enumeratedString=function(D){return this[D]},B.bool=function(D){return this[D]==="YES"},B.decimalResolution=function(D){var E=X.exec(this[D]);return E===null?void 0:{width:parseInt(E[1],10),height:parseInt(E[2],10)}},z.parseAttrList=function(D){var E,L={},k='"';for(N.lastIndex=0;(E=N.exec(D))!==null;){var T=E[2];T.indexOf(k)===0&&T.lastIndexOf(k)===T.length-1&&(T=T.slice(1,-1)),L[E[1]]=T}return L},z}()},"./src/utils/binary-search.ts":function(ae,$,R){"use strict";R.r($);var X={search:function(I,z){for(var B=0,O=I.length-1,D=null,E=null;B<=O;){D=(B+O)/2|0,E=I[D];var L=z(E);if(L>0)B=D+1;else if(L<0)O=D-1;else return E}return null}};$.default=X},"./src/utils/buffer-helper.ts":function(ae,$,R){"use strict";R.r($),R.d($,"BufferHelper",function(){return I});var X=R("./src/utils/logger.ts"),N={length:0,start:function(){return 0},end:function(){return 0}},I=function(){function z(){}return z.isBuffered=function(O,D){try{if(O){for(var E=z.getBuffered(O),L=0;L=E.start(L)&&D<=E.end(L))return!0}}catch(k){}return!1},z.bufferInfo=function(O,D,E){try{if(O){var L=z.getBuffered(O),k=[],T;for(T=0;TA&&(L[T-1].end=O[k].end):L.push(O[k])}else L.push(O[k])}else L=O;for(var C=0,h,o=D,c=D,d=0;d=_&&D=a&&X.logger.log(this.time+" ["+a+"] "+b)},f}(),C=function(p){for(var s=[],a=0;aB&&(this.logger.log(T.DEBUG,"Too large cursor position "+this.pos),this.pos=B)},p.moveCursor=function(a){var b=this.pos+a;if(a>1)for(var v=this.pos+1;v=144&&this.backSpace();var b=I(a);if(this.pos>=B){this.logger.log(T.ERROR,"Cannot insert "+a.toString(16)+" ("+b+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(b,this.currPenState),this.moveCursor(1)},p.clearFromPos=function(a){var b;for(b=a;b0&&(a?v="["+b.join(" | ")+"]":v=b.join(` `)),v},p.getTextAndFormat=function(){return this.rows},f}(),_=function(){function f(s,a,b){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(b),this.nonDisplayedMemory=new d(b),this.lastOutputScreen=new d(b),this.currRollUpRow=this.displayedMemory.rows[z-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=b}var p=f.prototype;return p.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[z-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},p.getHandler=function(){return this.outputFilter},p.setHandler=function(a){this.outputFilter=a},p.setPAC=function(a){this.writeScreen.setPAC(a)},p.setBkgData=function(a){this.writeScreen.setBkgData(a)},p.setMode=function(a){if(a===this.mode)return;this.mode=a,this.logger.log(T.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},p.insertChars=function(a){for(var b=0;b=46,b.italics)b.foreground="white";else{var v=Math.floor(a/2)-16,S=["white","green","blue","cyan","red","yellow","magenta"];b.foreground=S[v]}this.logger.log(T.INFO,"MIDROW: "+JSON.stringify(b)),this.writeScreen.setPen(b)},p.outputDataUpdate=function(a){a===void 0&&(a=!1);var b=this.logger.time;if(b===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=b:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,b,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:b),this.lastOutputScreen.copy(this.displayedMemory))},p.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},f}(),y=function(){function f(s,a,b){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var v=new A;this.channels=[null,new _(s,a,v),new _(s+1,b,v)],this.cmdHistory=x(),this.logger=v}var p=f.prototype;return p.getHandler=function(a){return this.channels[a].getHandler()},p.setHandler=function(a,b){this.channels[a].setHandler(b)},p.addData=function(a,b){var v,S,M,H=!1;this.logger.time=a;for(var V=0;V ("+C([S,M])+")"),v=this.parseCmd(S,M),v||(v=this.parseMidrow(S,M)),v||(v=this.parsePAC(S,M)),v||(v=this.parseBackgroundAttributes(S,M)),!v&&(H=this.parseChars(S,M),H)){var Q=this.currentChannel;if(Q&&Q>0){var G=this.channels[Q];G.insertChars(H)}else this.logger.log(T.WARNING,"No channel found yet. TEXT-MODE?")}!v&&!H&&this.logger.log(T.WARNING,"Couldn't parse cleaned data "+C([S,M])+" orig: "+C([b[V],b[V+1]]))}},p.parseCmd=function(a,b){var v=this.cmdHistory,S=(a===20||a===28||a===21||a===29)&&b>=32&&b<=47,M=(a===23||a===31)&&b>=33&&b<=35;if(!(S||M))return!1;if(l(a,b,v))return m(null,null,v),this.logger.log(T.DEBUG,"Repeated command ("+C([a,b])+") 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?b===32?V.ccRCL():b===33?V.ccBS():b===34?V.ccAOF():b===35?V.ccAON():b===36?V.ccDER():b===37?V.ccRU(2):b===38?V.ccRU(3):b===39?V.ccRU(4):b===40?V.ccFON():b===41?V.ccRDC():b===42?V.ccTR():b===43?V.ccRTD():b===44?V.ccEDM():b===45?V.ccCR():b===46?V.ccENM():b===47&&V.ccEOC():V.ccTO(b-32),m(a,b,v),this.currentChannel=H,!0},p.parseMidrow=function(a,b){var v=0;if((a===17||a===25)&&b>=32&&b<=47){if(a===17?v=1:v=2,v!==this.currentChannel)return this.logger.log(T.ERROR,"Mismatch channel in midrow parsing"),!1;var S=this.channels[v];return S?(S.ccMIDROW(b),this.logger.log(T.DEBUG,"MIDROW ("+C([a,b])+")"),!0):!1}return!1},p.parsePAC=function(a,b){var v,S=this.cmdHistory,M=(a>=17&&a<=23||a>=25&&a<=31)&&b>=64&&b<=127,H=(a===16||a===24)&&b>=64&&b<=95;if(!(M||H))return!1;if(l(a,b,S))return m(null,null,S),!0;var V=a<=23?1:2;b>=64&&b<=95?v=V===1?O[a]:E[a]:v=V===1?D[a]:L[a];var Q=this.channels[V];return Q?(Q.setPAC(this.interpretPAC(v,b)),m(a,b,S),this.currentChannel=V,!0):!1},p.interpretPAC=function(a,b){var v,S={color:null,italics:!1,indent:null,underline:!1,row:a};return b>95?v=b-96:v=b-64,S.underline=(v&1)===1,v<=13?S.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(v/2)]:v<=15?(S.italics=!0,S.color="white"):S.indent=Math.floor((v-16)/2)*4,S},p.parseChars=function(a,b){var v,S=null,M=null;if(a>=25?(v=2,M=a-8):(v=1,M=a),M>=17&&M<=19){var H;M===17?H=b+80:M===18?H=b+112:H=b+144,this.logger.log(T.INFO,"Special char '"+I(H)+"' in channel "+v),S=[H]}else a>=32&&a<=127&&(S=b===0?[a]:[a,b]);if(S){var V=C(S);this.logger.log(T.DEBUG,"Char codes = "+V.join(",")),m(a,b,this.cmdHistory)}return S},p.parseBackgroundAttributes=function(a,b){var v=(a===16||a===24)&&b>=32&&b<=47,S=(a===23||a===31)&&b>=45&&b<=47;if(!(v||S))return!1;var M,H={};a===16||a===24?(M=Math.floor((b-32)/2),H.background=k[M],b%2===1&&(H.background=H.background+"_semi")):b===45?H.background="transparent":(H.foreground="black",b===47&&(H.underline=!0));var V=a<=23?1:2,Q=this.channels[V];return Q.setBkgData(H),m(a,b,this.cmdHistory),!0},p.reset=function(){for(var a=0;a=16?o--:o++;var m=Object(X.fixLineBreaks)(c.trim()),l=Object(N.generateCueId)(E,L,m);(!D||!D.cues||!D.cues.getCueById(l))&&(C=new d(E,L,m),C.id=l,C.line=_+1,C.align="left",C.position=10+Math.min(80,Math.floor(o*8/32)*10),T.push(C))}return D&&T.length&&(T.sort(function(x,f){return x.line==="auto"||f.line==="auto"?0:x.line>8&&f.line>8?f.line-x.line:x.line-f.line}),T.forEach(function(x){return Object(I.addCueToTrack)(D,x)})),T}};$.default=B},"./src/utils/discontinuities.ts":function(ae,$,R){"use strict";R.r($),R.d($,"findFirstFragWithCC",function(){return z}),R.d($,"shouldAlignOnDiscontinuities",function(){return B}),R.d($,"findDiscontinuousReferenceFrag",function(){return O}),R.d($,"adjustSlidingStart",function(){return E}),R.d($,"alignStream",function(){return L}),R.d($,"alignPDT",function(){return T}),R.d($,"alignFragmentByPDTDelta",function(){return A}),R.d($,"alignMediaPlaylistByPDT",function(){return C});var X=R("./src/polyfills/number.ts"),N=R("./src/utils/logger.ts"),I=R("./src/controller/level-helper.ts");function z(h,o){for(var c=null,d=0,_=h.length;d<_;d++){var y=h[d];if(y&&y.cc===o){c=y;break}}return c}function B(h,o,c){return!!(o.details&&(c.endCC>c.startCC||h&&h.cc=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(ae,$,R){"use strict";R.r($);var X=function(){function N(z,B,O){B===void 0&&(B=0),O===void 0&&(O=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_=B,this.totalWeight_=O}var I=N.prototype;return I.sample=function(B,O){var D=Math.pow(this.alpha_,B);this.estimate_=O*(1-D)+D*this.estimate_,this.totalWeight_+=B},I.getTotalWeight=function(){return this.totalWeight_},I.getEstimate=function(){if(this.alpha_){var B=1-Math.pow(this.alpha_,this.totalWeight_);if(B)return this.estimate_/B}return this.estimate_},N}();$.default=X},"./src/utils/fetch-loader.ts":function(ae,$,R){"use strict";R.r($),R.d($,"fetchSupported",function(){return A});var X=R("./src/polyfills/number.ts"),N=R("./src/loader/load-stats.ts"),I=R("./src/demux/chunk-cache.ts");function z(d,_){d.prototype=Object.create(_.prototype),d.prototype.constructor=d,L(d,_)}function B(d){var _=typeof Map=="function"?new Map:void 0;return B=function(m){if(m===null||!E(m))return m;if(typeof m!="function")throw new TypeError("Super expression must either be null or a function");if(typeof _!="undefined"){if(_.has(m))return _.get(m);_.set(m,l)}function l(){return O(m,arguments,k(this).constructor)}return l.prototype=Object.create(m.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),L(l,m)},B(d)}function O(d,_,y){return D()?O=Reflect.construct:O=function(l,x,f){var p=[null];p.push.apply(p,x);var s=Function.bind.apply(l,p),a=new s;return f&&L(a,f.prototype),a},O.apply(null,arguments)}function D(){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 E(d){return Function.toString.call(d).indexOf("[native code]")!==-1}function L(d,_){return L=Object.setPrototypeOf||function(m,l){return m.__proto__=l,m},L(d,_)}function k(d){return k=Object.setPrototypeOf?Object.getPrototypeOf:function(y){return y.__proto__||Object.getPrototypeOf(y)},k(d)}function T(){return T=Object.assign||function(d){for(var _=1;_=f&&p(l,x,s.flush(),m)):p(l,x,M,m),v()}).catch(function(){return Promise.reject()})};return b()},d}();function h(d,_){var y={method:"GET",mode:"cors",credentials:"same-origin",signal:_,headers:new self.Headers(T({},d.headers))};return d.rangeEnd&&y.headers.set("Range","bytes="+d.rangeStart+"-"+String(d.rangeEnd-1)),y}function o(d,_){return new self.Request(d.url,_)}var c=function(d){z(_,d);function _(y,m,l){var x;return x=d.call(this,y)||this,x.code=void 0,x.details=void 0,x.code=m,x.details=l,x}return _}(B(Error));$.default=C},"./src/utils/imsc1-ttml-parser.ts":function(ae,$,R){"use strict";R.r($),R.d($,"IMSC1_CODEC",function(){return E}),R.d($,"parseIMSC1",function(){return A});var X=R("./src/utils/mp4-tools.ts"),N=R("./src/utils/vttparser.ts"),I=R("./src/utils/vttcue.ts"),z=R("./src/demux/id3.ts"),B=R("./src/utils/timescale-conversion.ts"),O=R("./src/utils/webvtt-parser.ts");function D(){return D=Object.assign||function(f){for(var p=1;p"):X}function B(E){for(var L=arguments.length,k=new Array(L>1?L-1:0),T=1;T>24,_[y+1]=m>>16&255,_[y+2]=m>>8&255,_[y+3]=m&255}function L(_,y){var m=[];if(!y.length)return m;var l,x,f;"data"in _?(l=_.data,x=_.start,f=_.end):(l=_,x=0,f=l.byteLength);for(var p=x;p1?p+s:f;if(a===y[0])if(y.length===1)m.push({data:l,start:p+8,end:b});else{var v=L({data:l,start:p+8,end:b},y.slice(1));v.length&&z.apply(m,v)}p=b}return m}function k(_){var y=L(_,["moov"]),m=y[0],l=m?m.end:null,x=L(_,["sidx"]);if(!x||!x[0])return null;var f=[],p=x[0],s=p.data[0],a=s===0?8:16,b=D(p,a);a+=4;var v=0,S=0;s===0?a+=8:a+=16,a+=2;var M=p.end+S,H=O(p,a);a+=2;for(var V=0;V>>31;if(q===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var oe=D(p,Q);Q+=4,f.push({referenceSize:W,subsegmentDuration:oe,info:{duration:oe/b,start:M,end:M+W-1}}),M+=W,Q+=4,a=Q}return{earliestPresentationTime:v,timescale:b,version:s,referencesCount:H,references:f,moovEndOffset:l}}function T(_){for(var y=[],m=L(_,["moov","trak"]),l=0;lB)&&(this.startTime=B),this.endTime=O,this.screen=D,this.timelineController.createCaptionsTrack(this.trackName)},I.reset=function(){this.cueRanges=[]},N}()},"./src/utils/texttrack-utils.ts":function(ae,$,R){"use strict";R.r($),R.d($,"sendAddTrackEvent",function(){return N}),R.d($,"addCueToTrack",function(){return I}),R.d($,"clearCurrentCues",function(){return z}),R.d($,"removeCuesInRange",function(){return B}),R.d($,"getCuesInRange",function(){return D});var X=R("./src/utils/logger.ts");function N(E,L){var k;try{k=new Event("addtrack")}catch(T){k=document.createEvent("Event"),k.initEvent("addtrack",!1,!1)}k.track=E,L.dispatchEvent(k)}function I(E,L){var k=E.mode;if(k==="disabled"&&(E.mode="hidden"),E.cues&&!E.cues.getCueById(L.id))try{if(E.addCue(L),!E.cues.getCueById(L.id))throw new Error("addCue is failed for: "+L)}catch(A){X.logger.debug("[texttrack-utils]: "+A);var T=new self.TextTrackCue(L.startTime,L.endTime,L.text);T.id=L.id,E.addCue(T)}k==="disabled"&&(E.mode=k)}function z(E){var L=E.mode;if(L==="disabled"&&(E.mode="hidden"),E.cues)for(var k=E.cues.length;k--;)E.removeCue(E.cues[k]);L==="disabled"&&(E.mode=L)}function B(E,L,k){var T=E.mode;if(T==="disabled"&&(E.mode="hidden"),E.cues&&E.cues.length>0)for(var A=D(E.cues,L,k),C=0;CE[k].endTime)return-1;for(var T=0,A=k;T<=A;){var C=Math.floor((A+T)/2);if(LE[C].startTime&&T-1)for(var C=A,h=E.length;C=L&&o.endTime<=k)T.push(o);else if(o.startTime>k)return T}return T}},"./src/utils/time-ranges.ts":function(ae,$,R){"use strict";R.r($);var X={toString:function(I){for(var z="",B=I.length,O=0;O1?L-1:0),T=1;T100)throw new Error("Position must be between 0 and 100.");f=v,this.hasBeenReset=!0}})),Object.defineProperty(T,"positionAlign",O({},A,{get:function(){return p},set:function(v){var S=B(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");p=S,this.hasBeenReset=!0}})),Object.defineProperty(T,"size",O({},A,{get:function(){return s},set:function(v){if(v<0||v>100)throw new Error("Size must be between 0 and 100.");s=v,this.hasBeenReset=!0}})),Object.defineProperty(T,"align",O({},A,{get:function(){return a},set:function(v){var S=B(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");a=S,this.hasBeenReset=!0}})),T.displayState=void 0}return D.prototype.getCueAsHTML=function(){var E=self.WebVTT;return E.convertCueToDOMTree(self,this.text)},D}()},"./src/utils/vttparser.ts":function(ae,$,R){"use strict";R.r($),R.d($,"parseTimeStamp",function(){return I}),R.d($,"fixLineBreaks",function(){return L}),R.d($,"VTTParser",function(){return k});var X=R("./src/utils/vttcue.ts"),N=function(){function T(){}var A=T.prototype;return A.decode=function(h,o){if(!h)return"";if(typeof h!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(h))},T}();function I(T){function A(h,o,c,d){return(h|0)*3600+(o|0)*60+(c|0)+parseFloat(d||0)}var C=T.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return C?parseFloat(C[2])>59?A(C[2],C[3],0,C[4]):A(C[1],C[2],C[3],C[4]):null}var z=function(){function T(){this.values=Object.create(null)}var A=T.prototype;return A.set=function(h,o){!this.get(h)&&o!==""&&(this.values[h]=o)},A.get=function(h,o,c){return c?this.has(h)?this.values[h]:o[c]:this.has(h)?this.values[h]:o},A.has=function(h){return h in this.values},A.alt=function(h,o,c){for(var d=0;d=0&&c<=100)return this.set(h,c),!0}return!1},T}();function B(T,A,C,h){var o=h?T.split(h):[T];for(var c in o){if(typeof o[c]!="string")continue;var d=o[c].split(C);if(d.length!==2)continue;var _=d[0],y=d[1];A(_,y)}}var O=new X.default(0,0,""),D=O.align==="middle"?"middle":"center";function E(T,A,C){var h=T;function o(){var _=I(T);if(_===null)throw new Error("Malformed timestamp: "+h);return T=T.replace(/^[^\sa-zA-Z-]+/,""),_}function c(_,y){var m=new z;B(_,function(f,p){var s;switch(f){case"region":for(var a=C.length-1;a>=0;a--)if(C[a].id===p){m.set(f,C[a].region);break}break;case"vertical":m.alt(f,p,["rl","lr"]);break;case"line":s=p.split(","),m.integer(f,s[0]),m.percent(f,s[0])&&m.set("snapToLines",!1),m.alt(f,s[0],["auto"]),s.length===2&&m.alt("lineAlign",s[1],["start",D,"end"]);break;case"position":s=p.split(","),m.percent(f,s[0]),s.length===2&&m.alt("positionAlign",s[1],["start",D,"end","line-left","line-right","auto"]);break;case"size":m.percent(f,p);break;case"align":m.alt(f,p,["start",D,"end","left","right"]);break}},/:/,/\s/),y.region=m.get("region",null),y.vertical=m.get("vertical","");var l=m.get("line","auto");l==="auto"&&O.line===-1&&(l=-1),y.line=l,y.lineAlign=m.get("lineAlign","start"),y.snapToLines=m.get("snapToLines",!0),y.size=m.get("size",100),y.align=m.get("align",D);var x=m.get("position","auto");x==="auto"&&O.position===50&&(x=y.align==="start"||y.align==="left"?0:y.align==="end"||y.align==="right"?100:50),y.position=x}function d(){T=T.replace(/^\s+/,"")}if(d(),A.startTime=o(),d(),T.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+h);T=T.substr(3),d(),A.endTime=o(),d(),c(T,A)}function L(T){return T.replace(//gi,` `)}var k=function(){function T(){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 A=T.prototype;return A.parse=function(h){var o=this;h&&(o.buffer+=o.decoder.decode(h,{stream:!0}));function c(){var x=o.buffer,f=0;for(x=L(x);f")===-1){o.cue.id=_;continue}case"CUE":if(!o.cue){o.state="BADCUE";continue}try{E(_,o.cue,o.regionList)}catch(x){o.cue=null,o.state="BADCUE";continue}o.state="CUETEXT";continue;case"CUETEXT":{var l=_.indexOf("-->")!==-1;if(!_||l&&(m=!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+=_}continue;case"BADCUE":_||(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},A.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},T}()},"./src/utils/webvtt-parser.ts":function(ae,$,R){"use strict";R.r($),R.d($,"generateCueId",function(){return k}),R.d($,"parseWebVTT",function(){return A});var X=R("./src/polyfills/number.ts"),N=R("./src/utils/vttparser.ts"),I=R("./src/demux/id3.ts"),z=R("./src/utils/timescale-conversion.ts"),B=R("./src/remux/mp4-remuxer.ts"),O=/\r\n|\n\r|\n|\r/g,D=function(h,o,c){return c===void 0&&(c=0),h.substr(c,o.length)===o},E=function(h){var o=parseInt(h.substr(-3)),c=parseInt(h.substr(-6,2)),d=parseInt(h.substr(-9,2)),_=h.length>9?parseInt(h.substr(0,h.indexOf(":"))):0;if(!Object(X.isFiniteNumber)(o)||!Object(X.isFiniteNumber)(c)||!Object(X.isFiniteNumber)(d)||!Object(X.isFiniteNumber)(_))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+h);return o+=1e3*c,o+=60*1e3*d,o+=60*60*1e3*_,o},L=function(h){for(var o=5381,c=h.length;c;)o=o*33^h.charCodeAt(--c);return(o>>>0).toString()};function k(C,h,o){return L(C.toString())+L(h.toString())+L(o)}var T=function(h,o,c){var d=h[o],_=h[d.prevCC];if(!_||!_.new&&d.new){h.ccOffset=h.presentationOffset=d.start,d.new=!1;return}for(;(y=_)!==null&&y!==void 0&&y.new;){var y;h.ccOffset+=d.start-_.start,d.new=!1,d=_,_=h[d.prevCC]}h.presentationOffset=c};function A(C,h,o,c,d,_,y,m){var l=new N.VTTParser,x=Object(I.utf8ArrayToStr)(new Uint8Array(C)).trim().replace(O,` `).split(` `),f=[],p=Object(z.toMpegTsClockFromTimescale)(h,o),s="00:00.000",a=0,b=0,v,S=!0,M=!1;l.oncue=function(H){var V=c[d],Q=c.ccOffset,G=(a-p)/9e4;if(V!=null&&V.new&&(b!==void 0?Q=c.ccOffset=V.start:T(c,d,G)),G&&(Q=G-c.presentationOffset),M){var W=H.endTime-H.startTime,q=Object(B.normalizePts)((H.startTime+Q-b)*9e4,_*9e4)/9e4;H.startTime=q,H.endTime=q+W}var oe=H.text.trim();H.text=decodeURIComponent(encodeURIComponent(oe)),H.id||(H.id=k(H.startTime,H.endTime,oe)),H.endTime>0&&f.push(H)},l.onparsingerror=function(H){v=H},l.onflush=function(){if(v){m(v);return}y(f)},x.forEach(function(H){if(S)if(D(H,"X-TIMESTAMP-MAP=")){S=!1,M=!0,H.substr(16).split(",").forEach(function(V){D(V,"LOCAL:")?s=V.substr(6):D(V,"MPEGTS:")&&(a=parseInt(V.substr(7)))});try{b=E(s)/1e3}catch(V){M=!1,v=V}return}else H===""&&(S=!1);l.parse(H+` `)}),l.flush()}},"./src/utils/xhr-loader.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/utils/logger.ts"),N=R("./src/loader/load-stats.ts"),I=/^age:\s*[\d.]+\s*$/m,z=function(){function B(D){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=D?D.xhrSetup:null,this.stats=new N.LoadStats,this.retryDelay=0}var O=B.prototype;return O.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},O.abortInternal=function(){var E=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),E&&(E.onreadystatechange=null,E.onprogress=null,E.readyState!==4&&(this.stats.aborted=!0,E.abort()))},O.abort=function(){var E;this.abortInternal(),(E=this.callbacks)!==null&&E!==void 0&&E.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},O.load=function(E,L,k){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=E,this.config=L,this.callbacks=k,this.retryDelay=L.retryDelay,this.loadInternal()},O.loadInternal=function(){var E=this.config,L=this.context;if(!E)return;var k=this.loader=new self.XMLHttpRequest,T=this.stats;T.loading.first=0,T.loaded=0;var A=this.xhrSetup;try{if(A)try{A(k,L.url)}catch(o){k.open("GET",L.url,!0),A(k,L.url)}k.readyState||k.open("GET",L.url,!0);var C=this.context.headers;if(C)for(var h in C)k.setRequestHeader(h,C[h])}catch(o){this.callbacks.onError({code:k.status,text:o.message},L,k);return}L.rangeEnd&&k.setRequestHeader("Range","bytes="+L.rangeStart+"-"+(L.rangeEnd-1)),k.onreadystatechange=this.readystatechange.bind(this),k.onprogress=this.loadprogress.bind(this),k.responseType=L.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),E.timeout),k.send()},O.readystatechange=function(){var E=this.context,L=this.loader,k=this.stats;if(!E||!L)return;var T=L.readyState,A=this.config;if(k.aborted)return;if(T>=2)if(self.clearTimeout(this.requestTimeout),k.loading.first===0&&(k.loading.first=Math.max(self.performance.now(),k.loading.start)),T===4){L.onreadystatechange=null,L.onprogress=null;var C=L.status;if(C>=200&&C<300){k.loading.end=Math.max(self.performance.now(),k.loading.first);var h,o;if(E.responseType==="arraybuffer"?(h=L.response,o=h.byteLength):(h=L.responseText,o=h.length),k.loaded=k.total=o,!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(k,E,h,L),!this.callbacks)return;var d={url:L.responseURL,data:h};this.callbacks.onSuccess(d,k,E,L)}else k.retry>=A.maxRetry||C>=400&&C<499?(X.logger.error(C+" while loading "+E.url),this.callbacks.onError({code:C,text:L.statusText},E,L)):(X.logger.warn(C+" while loading "+E.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,A.maxRetryDelay),k.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),A.timeout)},O.loadtimeout=function(){X.logger.warn("timeout while loading "+this.context.url);var E=this.callbacks;E&&(this.abortInternal(),E.onTimeout(this.stats,this.context,this.loader))},O.loadprogress=function(E){var L=this.stats;L.loaded=E.loaded,E.lengthComputable&&(L.total=E.total)},O.getCacheAge=function(){var E=null;if(this.loader&&I.test(this.loader.getAllResponseHeaders())){var L=this.loader.getResponseHeader("age");E=L?parseFloat(L):null}return E},B}();$.default=z}}).default})},vHTk:function(At,ht,re){At.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);