|
|
(window.webpackJsonp=window.webpackJsonp||[]).push([[148,5,6,7,17],{"+NIl":
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./node_modules/codemirror/mode/stex/stex.js ***!
|
|
|
\***************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){!function(t){"use strict";t.defineMode("stex",(function(t,e){function r(t,e){t.cmdState.push(e)}function i(t){return t.cmdState.length>0?t.cmdState[t.cmdState.length-1]:null}function n(t,e,r){return function(){this.name=t,this.bracketNo=0,this.style=e,this.styles=r,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={};function s(t,e){t.f=e}function a(t,e){var n;if(t.match(/^\\[a-zA-Z@]+/)){var a=t.current().slice(1);return r(e,n=new(n=o.hasOwnProperty(a)?o[a]:o.DEFAULT)),s(e,c),n.style}if(t.match(/^\\[$&%#{}_]/))return"tag";if(t.match(/^\\[,;!\/\\]/))return"tag";if(t.match("\\["))return s(e,(function(t,e){return l(t,e,"\\]")})),"keyword";if(t.match("\\("))return s(e,(function(t,e){return l(t,e,"\\)")})),"keyword";if(t.match("$$"))return s(e,(function(t,e){return l(t,e,"$$")})),"keyword";if(t.match("$"))return s(e,(function(t,e){return l(t,e,"$")})),"keyword";var u=t.next();return"%"==u?(t.skipToEnd(),"comment"):"}"==u||"]"==u?(n=i(e))?(n.closeBracket(u),s(e,c),"bracket"):"error":"{"==u||"["==u?(r(e,n=new(n=o.DEFAULT)),"bracket"):/\d/.test(u)?(t.eatWhile(/[\w.%]/),"atom"):(t.eatWhile(/[\w\-_]/),"begin"==(n=function(t){for(var e=t.cmdState,r=e.length-1;r>=0;r--){var i=e[r];if("DEFAULT"!=i.name)return i}return{styleIdentifier:function(){return null}}}(e)).name&&(n.argument=t.current()),n.styleIdentifier())}function l(t,e,r){if(t.eatSpace())return null;if(r&&t.match(r))return s(e,a),"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 i=t.next();return"{"==i||"}"==i||"["==i||"]"==i||"("==i||")"==i?"bracket":"%"==i?(t.skipToEnd(),"comment"):"error"}function c(t,e){var r=t.peek();return"{"==r||"["==r?(i(e).openBracket(r),t.eat(r),s(e,a),"bracket"):/[ \t\r]/.test(r)?(t.eat(r),null):(s(e,a),function(t){var e=t.cmdState.pop();e&&e.closeBracket()}(e),a(t,e))}return o.importmodule=n("importmodule","tag",["string","builtin"]),o.documentclass=n("documentclass","tag",["","atom"]),o.usepackage=n("usepackage","tag",["atom"]),o.begin=n("begin","tag",["atom"]),o.end=n("end","tag",["atom"]),o.label=n("label","tag",["atom"]),o.ref=n("ref","tag",["atom"]),o.eqref=n("eqref","tag",["atom"]),o.cite=n("cite","tag",["atom"]),o.bibitem=n("bibitem","tag",["atom"]),o.Bibitem=n("Bibitem","tag",["atom"]),o.RBibitem=n("RBibitem","tag",["atom"]),o.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}},{startState:function(){return{cmdState:[],f:e.inMathMode?function(t,e){return l(t,e)}:a}},copyState:function(t){return{cmdState:t.cmdState.slice(),f:t.f}},token:function(t,e){return e.f(t,e)},blankLine:function(t){t.f=a,t.cmdState.length=0},lineComment:"%"}})),t.defineMIME("text/x-stex","stex"),t.defineMIME("text/x-latex","stex")}(r(/*! ../../lib/codemirror */"VrN/"))},"19Vz":
|
|
|
/*!**************************************************************!*\
|
|
|
!*** ./node_modules/codemirror/addon/display/placeholder.js ***!
|
|
|
\**************************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){!function(t){function e(t){t.state.placeholder&&(t.state.placeholder.parentNode.removeChild(t.state.placeholder),t.state.placeholder=null)}function r(t){e(t);var r=t.state.placeholder=document.createElement("pre");r.style.cssText="height: 0; overflow: visible",r.style.direction=t.getOption("direction"),r.className="CodeMirror-placeholder CodeMirror-line-like";var i=t.getOption("placeholder");"string"==typeof i&&(i=document.createTextNode(i)),r.appendChild(i),t.display.lineSpace.insertBefore(r,t.display.lineSpace.firstChild)}function i(t){o(t)&&r(t)}function n(t){var i=t.getWrapperElement(),n=o(t);i.className=i.className.replace(" CodeMirror-empty","")+(n?" CodeMirror-empty":""),n?r(t):e(t)}function o(t){return 1===t.lineCount()&&""===t.getLine(0)}t.defineOption("placeholder","",(function(o,s,a){var l=a&&a!=t.Init;if(s&&!l)o.on("blur",i),o.on("change",n),o.on("swapDoc",n),t.on(o.getInputField(),"compositionupdate",o.state.placeholderCompose=function(){!function(t){setTimeout((function(){var i=!1,n=t.getInputField();"TEXTAREA"==n.nodeName?i=!n.value:1==t.lineCount()&&(i=!/[^\u200b]/.test(n.querySelector(".CodeMirror-line").textContent)),i?r(t):e(t)}),20)}(o)}),n(o);else if(!s&&l){o.off("blur",i),o.off("change",n),o.off("swapDoc",n),t.off(o.getInputField(),"compositionupdate",o.state.placeholderCompose),e(o);var c=o.getWrapperElement();c.className=c.className.replace(" CodeMirror-empty","")}s&&!o.hasFocus()&&i(o)}))}(r(/*! ../../lib/codemirror */"VrN/"))},"1eCo":
|
|
|
/*!*************************************************!*\
|
|
|
!*** ./node_modules/codemirror/mode/xml/xml.js ***!
|
|
|
\*************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){!function(t){"use strict";var e={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};t.defineMode("xml",(function(i,n){var o,s,a=i.indentUnit,l={},c=n.htmlMode?e:r;for(var u in c)l[u]=c[u];for(var u in n)l[u]=n[u];function h(t,e){function r(r){return e.tokenize=r,r(t,e)}var i=t.next();return"<"==i?t.eat("!")?t.eat("[")?t.match("CDATA[")?r(f("atom","]]>")):null:t.match("--")?r(f("comment","--\x3e")):t.match("DOCTYPE",!0,!0)?(t.eatWhile(/[\w\._\-]/),r(function t(e){return function(r,i){for(var n;null!=(n=r.next());){if("<"==n)return i.tokenize=t(e+1),i.tokenize(r,i);if(">"==n){if(1==e){i.tokenize=h;break}return i.tokenize=t(e-1),i.tokenize(r,i)}}return"meta"}}(1))):null:t.eat("?")?(t.eatWhile(/[\w\._\-]/),e.tokenize=f("meta","?>"),"meta"):(o=t.eat("/")?"closeTag":"openTag",e.tokenize=d,"tag bracket"):"&"==i?(t.eat("#")?t.eat("x")?t.eatWhile(/[a-fA-F\d]/)&&t.eat(";"):t.eatWhile(/[\d]/)&&t.eat(";"):t.eatWhile(/[\w\.\-:]/)&&t.eat(";"))?"atom":"error":(t.eatWhile(/[^&<]/),null)}function d(t,e){var r,i,n=t.next();if(">"==n||"/"==n&&t.eat(">"))return e.tokenize=h,o=">"==n?"endTag":"selfcloseTag","tag bracket";if("="==n)return o="equals",null;if("<"==n){e.tokenize=h,e.state=v,e.tagName=e.tagStart=null;var s=e.tokenize(t,e);return s?s+" tag error":"tag error"}return/[\'\"]/.test(n)?(e.tokenize=(r=n,(i=function(t,e){for(;!t.eol();)if(t.next()==r){e.tokenize=d;break}return"string"}).isInAttribute=!0,i),e.stringStartCol=t.column(),e.tokenize(t,e)):(t.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function f(t,e){return function(r,i){for(;!r.eol();){if(r.match(e)){i.tokenize=h;break}r.next()}return t}}function p(t,e,r){this.prev=t.context,this.tagName=e,this.indent=t.indented,this.startOfLine=r,(l.doNotIndent.hasOwnProperty(e)||t.context&&t.context.noIndent)&&(this.noIndent=!0)}function g(t){t.context&&(t.context=t.context.prev)}function m(t,e){for(var r;;){if(!t.context)return;if(r=t.context.tagName,!l.contextGrabbers.hasOwnProperty(r)||!l.contextGrabbers[r].hasOwnProperty(e))return;g(t)}}function v(t,e,r){return"openTag"==t?(r.tagStart=e.column(),y):"closeTag"==t?b:v}function y(t,e,r){return"word"==t?(r.tagName=e.current(),s="tag",C):l.allowMissingTagName&&"endTag"==t?(s="tag bracket",C(t,0,r)):(s="error",y)}function b(t,e,r){if("word"==t){var i=e.current();return r.context&&r.context.tagName!=i&&l.implicitlyClosed.hasOwnProperty(r.context.tagName)&&g(r),r.context&&r.context.tagName==i||!1===l.matchClosing?(s="tag",x):(s="tag error",S)}return l.allowMissingTagName&&"endTag"==t?(s="tag bracket",x(t,0,r)):(s="error",S)}function x(t,e,r){return"endTag"!=t?(s="error",x):(g(r),v)}function S(t,e,r){return s="error",x(t,0,r)}function C(t,e,r){if("word"==t)return s="attribute",w;if("endTag"==t||"selfcloseTag"==t){var i=r.tagName,n=r.tagStart;return r.tagName=r.tagStart=null,"selfcloseTag"==t||l.autoSelfClosers.hasOwnProperty(i)?m(r,i):(m(r,i),r.context=new p(r,i,n==r.indented)),v}return s="error",C}function w(t,e,r){return"equals"==t?k:(l.allowMissing||(s="error"),C(t,0,r))}function k(t,e,r){return"string"==t?E:"word"==t&&l.allowUnquoted?(s="string",C):(s="error",C(t,0,r))}function E(t,e,r){return"string"==t?E:C(t,0,r)}return h.isInText=!0,{startState:function(t){var e={tokenize:h,state:v,indented:t||0,tagName:null,tagStart:null,context:null};return null!=t&&(e.baseIndent=t),e},token:function(t,e){if(!e.tagName&&t.sol()&&(e.indented=t.indentation()),t.eatSpace())return null;o=null;var r=e.tokenize(t,e);return(r||o)&&"comment"!=r&&(s=null,e.state=e.state(o||r,t,e),s&&(r="error"==s?r+" error":s)),r},indent:function(e,r,i){var n=e.context;if(e.tokenize.isInAttribute)return e.tagStart==e.indented?e.stringStartCol+1:e.indented+a;if(n&&n.noIndent)return t.Pass;if(e.tokenize!=d&&e.tokenize!=h)return i?i.match(/^(\s*)/)[0].length:0;if(e.tagName)return!1!==l.multilineTagIndentPastTag?e.tagStart+e.tagName.length+2:e.tagStart+a*(l.multilineTagIndentFactor||1);if(l.alignCDATA&&/<!\[CDATA\[/.test(r))return 0;var o=r&&/^<(\/)?([\w_:\.-]*)/.exec(r);if(o&&o[1])for(;n;){if(n.tagName==o[2]){n=n.prev;break}if(!l.implicitlyClosed.hasOwnProperty(n.tagName))break;n=n.prev}else if(o)for(;n;){var s=l.contextGrabbers[n.tagName];if(!s||!s.hasOwnProperty(o[2]))break;n=n.prev}for(;n&&n.prev&&!n.startOfLine;)n=n.prev;return n?n.indent+a:e.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"\x3c!--",blockCommentEnd:"--\x3e",configuration:l.htmlMode?"html":"xml",helperType:l.htmlMode?"html":"xml",skipAttribute:function(t){t.state==k&&(t.state=C)},xmlCurrentTag:function(t){return t.tagName?{name:t.tagName,close:"closeTag"==t.type}:null},xmlCurrentContext:function(t){for(var e=[],r=t.context;r;r=r.prev)r.tagName&&e.push(r.tagName);return e.reverse()}}})),t.defineMIME("text/xml","xml"),t.defineMIME("application/xml","xml"),t.mimeModes.hasOwnProperty("text/html")||t.defineMIME("text/html",{name:"xml",htmlMode:!0})}(r(/*! ../../lib/codemirror */"VrN/"))},"500L":
|
|
|
/*!**********************************************!*\
|
|
|
!*** ./src/components/MultiUpload/index.tsx ***!
|
|
|
\**********************************************/
|
|
|
/*! exports provided: coverToFileList, default */
|
|
|
/*! exports used: coverToFileList, default */function(t,e,r){"use strict";r.d(e,"a",(function(){return x}));r(/*! antd/es/button/style */"+L6B");var i=r(/*! antd/es/button */"2/Rp"),n=(r(/*! antd/es/modal/style */"2qtc"),r(/*! antd/es/modal */"kLXV")),o=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/asyncToGenerator */"9og8"),s=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2 */"k1fw"),a=(r(/*! antd/es/message/style */"miYZ"),r(/*! antd/es/message */"tsqr")),l=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/toConsumableArray */"oBTY"),c=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray */"tJVT"),u=(r(/*! antd/es/upload/style */"DZo9"),r(/*! antd/es/upload */"8z0m")),h=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/regenerator */"WmNS"),d=r.n(h),f=r(/*! react */"q1tI"),p=r.n(f),g=r(/*! @/utils/env */"m3rI"),m=r(/*! @/pages/MoopCases/FormPanel/service */"wzkS"),v=r(/*! ../SingleUpload */"y5JW"),y=r(/*! @ant-design/icons */"LtfV"),b=u.a.Dragger;function x(t){var e=[];return t&&t.length>0&&(e=t.map((function(t){return{uid:t.id,id:t.id,name:t.title+v.c+t.filesize,url:t.url,filesize:t.filesize,status:"done",response:{id:t.id}}}))),e}e.b=function(t){var e=t.value,r=t.onChange,h=t.action,x=t.className,S=t.maxSize,C=void 0===S?150:S,w=t.title,k=void 0===w?"上传附件":w,E=t.showRemoveModal,T=void 0!==E&&E,L=t.accept,A=void 0===L?"":L,D=t.additionalText,O=t.isDragger,R=t.number,_=void 0===R?1e3:R,I=t.aloneClear,M=void 0!==I&&I,P=t.restrict,N=void 0===P||P,F=Object(f.useState)(!1),B=Object(c.a)(F,2),j=B[0],U=B[1],H=Object(f.useState)(e||[]),G=Object(c.a)(H,2),z=G[0],W=G[1];Object(f.useEffect)((function(){e&&(W(Object(l.a)(e)),_===(null==e?void 0:e.length)&&U(!0))}),[e]);var V,K=function(){setTimeout((function(){z.pop(),W(Object(l.a)(z))}),500)},q={multiple:!0,disabled:j,accept:A,withCredentials:!0,fileList:z,beforeUpload:function(t,e){var r=t.size/1024/1024;return z.concat(e).length>_?(z.pop(),W(Object(l.a)(z)),a.b.error("最多只能上传".concat(_,"个文件")),M?Promise.reject():(K(),!1)):r<C||(a.b.error("该文件无法上传。超过文件大小限制(".concat(C,"MB).")),M?Promise.reject():(K(),!1))},action:h||"".concat(g.a.API_SERVER,"/api/attachments.json"),onChange:function(t){var e=Object(l.a)(t.fileList);e.length>=_?U(!0):U(!1),W(Object(l.a)(e)),e=e.map((function(t){var e,r;null!=t&&null!==(e=t.response)&&void 0!==e&&e.id&&(t.url="/api/attachments/".concat(null==t||null===(r=t.response)||void 0===r?void 0:r.id));return-1===t.name.indexOf(v.c)&&(t.name="".concat(t.name).concat(v.c).concat(Object(v.a)(t.size))),Object(s.a)({},t)})),console.log("info:",t),r(e)},onRemove:(V=Object(o.a)(d.a.mark((function t(e){var r;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=function(){var t=Object(o.a)(d.a.mark((function t(){var r;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e.response?e.response.id:e.id)){t.next=8;break}return t.next=4,Object(m.d)(e.response?e.response.id:e.uid);case 4:return r=t.sent,t.abrupt("return",r);case 8:return t.abrupt("return",!0);case 9:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),!T){t.next=5;break}return t.abrupt("return",new Promise((function(t,e){var i;n.a.confirm({centered:!0,width:530,okText:"确定",cancelText:"取消",title:"提示",content:p.a.createElement("div",{className:"tc font16"},"是否确认删除?"),onOk:(i=Object(o.a)(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r();case 2:e.sent,a.b.success("删除成功"),t(!0);case 5:case"end":return e.stop()}}),e)}))),function(){return i.apply(this,arguments)}),onCancel:function(){return t(!1)}})})));case 5:return t.next=7,r();case 7:return t.abrupt("return",t.sent);case 8:case"end":return t.stop()}}),t)}))),function(t){return V.apply(this,arguments)})};return p.a.createElement("div",{className:"multi-upload ".concat(x||"")},O&&p.a.createElement(b,q,p.a.createElement("p",{className:"ant-upload-drag-icon"},p.a.createElement(y.a,null)),p.a.createElement("p",{className:"ant-upload-text"},"点击上传图标,选择要上传的文件或将文件拖拽到此",p.a.createElement("br",null),p.a.createElement("span",{style:{display:N?"block":"none"}},"(单个文件最大限制为",C,"MB) ")),D),!O&&p.a.createElement(u.a,q,p.a.createElement(i.a,{disabled:j},k),p.a.createElement("span",{onClick:function(t){t.preventDefault(),t.stopPropagation()},style:{marginLeft:10,color:"#FA6400",display:N?"block":"none"}},"(单个文件最大",C,"MB) ")))}},"55Ip":
|
|
|
/*!***************************************************************!*\
|
|
|
!*** ./node_modules/react-router-dom/esm/react-router-dom.js ***!
|
|
|
\***************************************************************/
|
|
|
/*! exports provided: MemoryRouter, Prompt, Redirect, Route, Router, StaticRouter, Switch, generatePath, matchPath, useHistory, useLocation, useParams, useRouteMatch, withRouter, BrowserRouter, HashRouter, Link, NavLink */
|
|
|
/*! exports used: Link, NavLink */function(t,e,r){"use strict";r.d(e,"a",(function(){return m})),r.d(e,"b",(function(){return b}));var i=r(/*! react-router */"Ty5D"),n=r(/*! @babel/runtime/helpers/esm/inheritsLoose */"dI71"),o=r(/*! react */"q1tI"),s=r.n(o),a=r(/*! history */"YS25"),l=(r(/*! prop-types */"17x9"),r(/*! @babel/runtime/helpers/esm/extends */"wx14")),c=r(/*! @babel/runtime/helpers/esm/objectWithoutPropertiesLoose */"zLVn"),u=r(/*! tiny-invariant */"9R94");s.a.Component;s.a.Component;var h=function(t,e){return"function"==typeof t?t(e):t},d=function(t,e){return"string"==typeof t?Object(a.c)(t,null,null,e):t},f=function(t){return t},p=s.a.forwardRef;void 0===p&&(p=f);var g=p((function(t,e){var r=t.innerRef,i=t.navigate,n=t.onClick,o=Object(c.a)(t,["innerRef","navigate","onClick"]),a=o.target,u=Object(l.a)({},o,{onClick:function(t){try{n&&n(t)}catch(e){throw t.preventDefault(),e}t.defaultPrevented||0!==t.button||a&&"_self"!==a||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||(t.preventDefault(),i())}});return u.ref=f!==p&&e||r,s.a.createElement("a",u)}));var m=p((function(t,e){var r=t.component,n=void 0===r?g:r,o=t.replace,a=t.to,m=t.innerRef,v=Object(c.a)(t,["component","replace","to","innerRef"]);return s.a.createElement(i.e.Consumer,null,(function(t){t||Object(u.a)(!1);var r=t.history,i=d(h(a,t.location),t.location),c=i?r.createHref(i):"",g=Object(l.a)({},v,{href:c,navigate:function(){var e=h(a,t.location);(o?r.replace:r.push)(e)}});return f!==p?g.ref=e||m:g.innerRef=m,s.a.createElement(n,g)}))})),v=function(t){return t},y=s.a.forwardRef;void 0===y&&(y=v);var b=y((function(t,e){var r=t["aria-current"],n=void 0===r?"page":r,o=t.activeClassName,a=void 0===o?"active":o,f=t.activeStyle,p=t.className,g=t.exact,b=t.isActive,x=t.location,S=t.sensitive,C=t.strict,w=t.style,k=t.to,E=t.innerRef,T=Object(c.a)(t,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return s.a.createElement(i.e.Consumer,null,(function(t){t||Object(u.a)(!1);var r=x||t.location,o=d(h(k,r),r),c=o.pathname,L=c&&c.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),A=L?Object(i.f)(r.pathname,{path:L,exact:g,sensitive:S,strict:C}):null,D=!!(b?b(A,r):A),O=D?function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.filter((function(t){return t})).join(" ")}(p,a):p,R=D?Object(l.a)({},w,{},f):w,_=Object(l.a)({"aria-current":D&&n||null,className:O,style:R,to:o},T);return v!==y?_.ref=e||E:_.innerRef=E,s.a.createElement(m,_)}))}))},"7/Dv":
|
|
|
/*!*************************************************!*\
|
|
|
!*** ./src/pages/Forums/New/index.less?modules ***!
|
|
|
\*************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){t.exports={bg:"bg___2rJyo",flexRow:"flexRow___2xuIa",flexJustifyCenter:"flexJustifyCenter___Z3bJt",flexAlignEnd:"flexAlignEnd___v7Ww-",flexAlignCenter:"flexAlignCenter___223DA",flexColumn:"flexColumn___3CNqR",formWrap:"formWrap___2b6uL",titleWrap:"titleWrap___1CMQA",fieldWrap:"fieldWrap___2BRrD",mdWrap:"mdWrap___3UYzt",backgroundFa:"backgroundFa___32wpj",button:"button___MHDAn"}},"7Cbv":
|
|
|
/*!**************************************************************!*\
|
|
|
!*** ./node_modules/uuid/dist/esm-browser/v4.js + 4 modules ***!
|
|
|
\**************************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,r){"use strict";var i="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),n=new Uint8Array(16);function o(){if(!i)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(n)}var s=/^(?:[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;for(var a=function(t){return"string"==typeof t&&s.test(t)},l=[],c=0;c<256;++c)l.push((c+256).toString(16).substr(1));var u=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(l[t[e+0]]+l[t[e+1]]+l[t[e+2]]+l[t[e+3]]+"-"+l[t[e+4]]+l[t[e+5]]+"-"+l[t[e+6]]+l[t[e+7]]+"-"+l[t[e+8]]+l[t[e+9]]+"-"+l[t[e+10]]+l[t[e+11]]+l[t[e+12]]+l[t[e+13]]+l[t[e+14]]+l[t[e+15]]).toLowerCase();if(!a(r))throw TypeError("Stringified UUID is invalid");return r};e.a=function(t,e,r){var i=(t=t||{}).random||(t.rng||o)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e){r=r||0;for(var n=0;n<16;++n)e[r+n]=i[n];return e}return u(i)}},"7ahc":
|
|
|
/*!*************************************************************!*\
|
|
|
!*** ./src/components/markdown-editor/code-block/index.tsx ***!
|
|
|
\*************************************************************/
|
|
|
/*! exports provided: default, MyCodeMirror */
|
|
|
/*! exports used: MyCodeMirror, default */function(t,e,r){"use strict";r.d(e,"a",(function(){return m}));var i=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2 */"k1fw"),n=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/extends */"0Owb"),o=(r(/*! antd/es/button/style */"+L6B"),r(/*! antd/es/button */"2/Rp")),s=(r(/*! antd/es/form/style */"y8nQ"),r(/*! antd/es/form */"Vl3Y")),a=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray */"tJVT"),l=(r(/*! antd/es/select/style */"OaEy"),r(/*! antd/es/select */"2fM7")),c=r(/*! react */"q1tI"),u=r.n(c),h=r(/*! codemirror */"VrN/"),d=r.n(h),f=(r(/*! codemirror/lib/codemirror.css */"p77/"),r(/*! codemirror/theme/blackboard.css */"c5Ni"),l.a.Option),p={labelCol:{span:4},wrapperCol:{span:20}},g={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"]};function m(t){var e=t.value,r=t.onChange,n=t.mode,o=t.options,s=void 0===o?{}:o,l=Object(c.useRef)(),h=Object(c.useState)(),f=Object(a.a)(h,2),p=f[0],g=f[1];return Object(c.useEffect)((function(){if(p){function t(t){var e=t.getValue();r&&r(e)}return p.on("change",t),function(){p.off("change",t)}}}),[p,r]),Object(c.useEffect)((function(){p&&p.setOption("mode",n)}),[p,n]),Object(c.useEffect)((function(){p&&(e===p.getValue()&&""!==e||setTimeout((function(){p.setValue(e||" ")}),300))}),[p,e]),Object(c.useEffect)((function(){if(l.current&&!p){var t=d.a.fromTextArea(l.current,Object(i.a)({mode:n,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},s));g(t)}}),[l.current,p]),u.a.createElement("div",{className:"my-codemirror-container"},u.a.createElement("textarea",{ref:l}))}e.b=function(t){var e=t.callback,r=t.onCancel,i=Object(c.useState)("python"),h=Object(a.a)(i,2),d=h[0],v=h[1];return u.a.createElement(s.a,Object(n.a)({},p,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:function(t){e(t)}}),u.a.createElement(s.a.Item,{label:"代码语言",name:"language"},u.a.createElement(l.a,{onChange:function(t){v(g[t][1])}},Object.keys(g).map((function(t){return u.a.createElement(f,{key:t,value:t},g[t][0])})))),u.a.createElement(s.a.Item,{label:"代码内容",name:"content",rules:[{required:!0,message:"请输入代码内容"}]},u.a.createElement(m,{mode:d})),u.a.createElement("div",{className:"flex-container flex-end"},u.a.createElement(o.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"确定"),u.a.createElement(o.a,{type:"ghost",onClick:r},"取消")))}},"8EBN":
|
|
|
/*!**********************************************!*\
|
|
|
!*** ./node_modules/codemirror/mode/meta.js ***!
|
|
|
\**********************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){!function(t){"use strict";t.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 e=0;e<t.modeInfo.length;e++){var r=t.modeInfo[e];r.mimes&&(r.mime=r.mimes[0])}t.findModeByMIME=function(e){e=e.toLowerCase();for(var r=0;r<t.modeInfo.length;r++){var i=t.modeInfo[r];if(i.mime==e)return i;if(i.mimes)for(var n=0;n<i.mimes.length;n++)if(i.mimes[n]==e)return i}return/\+xml$/.test(e)?t.findModeByMIME("application/xml"):/\+json$/.test(e)?t.findModeByMIME("application/json"):void 0},t.findModeByExtension=function(e){e=e.toLowerCase();for(var r=0;r<t.modeInfo.length;r++){var i=t.modeInfo[r];if(i.ext)for(var n=0;n<i.ext.length;n++)if(i.ext[n]==e)return i}},t.findModeByFileName=function(e){for(var r=0;r<t.modeInfo.length;r++){var i=t.modeInfo[r];if(i.file&&i.file.test(e))return i}var n=e.lastIndexOf("."),o=n>-1&&e.substring(n+1,e.length);if(o)return t.findModeByExtension(o)},t.findModeByName=function(e){e=e.toLowerCase();for(var r=0;r<t.modeInfo.length;r++){var i=t.modeInfo[r];if(i.name.toLowerCase()==e)return i;if(i.alias)for(var n=0;n<i.alias.length;n++)if(i.alias[n].toLowerCase()==e)return i}}}(r(/*! ../lib/codemirror */"VrN/"))},"8hTe":
|
|
|
/*!******************************************************!*\
|
|
|
!*** ./src/components/RenderHtml/index.less?modules ***!
|
|
|
\******************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){t.exports={button:"button___1wy9m"}},"9Bee":
|
|
|
/*!*********************************************************!*\
|
|
|
!*** ./src/components/RenderHtml/index.tsx + 3 modules ***!
|
|
|
\*********************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/regenerator/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/RenderHtml/index.less?modules (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/PreviewAll/index.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/env.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/fetch.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/button/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/button/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/space/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/space/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/hls.js/dist/hls.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/katex/dist/katex.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/marked/lib/marked.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/marked/src/helpers.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */function(t,e,r){"use strict";r("DYRE");var i=r("zeV3"),n=(r("+L6B"),r("2/Rp")),o=r("k1fw"),s=r("9og8"),a=r("tJVT"),l=r("WmNS"),c=r.n(l),u=r("q1tI"),h=r.n(u),d=(r("vg9a"),r("DlQD")),f=r.n(d),p=r("rUJ1");var g=[],m=["<ul>"],v=new f.a.Renderer,y=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function b(){g.length=0,m=["<ul>"]}var x={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function S(){return function t(e,r,i,n){if(r>=e.length||e[r].level<=i)return r;var o=e[r];n.push("<li><a href='#"+o.anchor+"'>"+o.text+"</a>");var s=[];return r=t(e,++r,o.level,s),s.length>0&&(n.push("<ul>"),s.forEach((function(t){n.push(t)})),n.push("</ul>")),n.push("</li>"),r=t(e,r,i,n)}(g,0,0,m),m.push("</ul>"),m.join("")}var C={heading:function(t){var e=y.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[1].length,text:e[2]}},fences:function(t){var e=this.rules.block.fences.exec(t);if(e){var r=e[0],i=function(t,e){var r=t.match(/^(\s+)(?:```)/);if(null===r)return e;var i=r[1];return e.split("\n").map((function(t){var e=t.match(/^\s+/);return null===e?t:Object(a.a)(e,1)[0].length>=i.length?t.slice(i.length):t})).join("\n")}(r,e[3]||""),n=e[2]?e[2].trim():e[2];if(["latex","katex","math"].indexOf(n)>=0){var o=E(),s=i;i=o,T[o]={type:"block",expression:s}}return{type:"code",raw:r,lang:n,text:i}}}},w=/(?:\${2})([^\n`]+?)(?:\${2})/gi,k=0,E=function(){return"__special_katext_id_".concat(k++,"__")},T={};function L(){k=0,T={}}function A(t){return t=t.replace(w,(function(t,e){var r=E();return T[r]={type:"inline",expression:e},r}))}var D=v.listitem;v.listitem=function(t){return D(A(t))};var O=v.paragraph;v.paragraph=function(t){return O(A(t))};var R=v.tablecell;v.tablecell=function(t,e){return R(A(t),e)},v.code=function(t,e,r){var i=(e||"").match(/\S*/)[0];return i?["latex","katex","math"].indexOf(i)>=0?"<p class='editormd-tex'>".concat(t,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(e,'">').concat(r?t:Object(p.escape)(t,!0),"</code></pre>\n"):'<pre class="prettyprint linenums"><code>'+(r?t:Object(p.escape)(t,!0))+"</code></pre>"},v.heading=function(t,e,r){var i=this.options.headerPrefix+r.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return g.push({anchor:i,level:e,text:t}),"<h"+e+' id="'+i+'">'+t+"</h"+e+">"},f.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),f.a.use({tokenizer:C,renderer:v});var _=f.a,I=(r("SJMd"),r("ulZh")),M=r.n(I),P=r("m3rI"),N=r("Oy/b"),F=r("p5ED"),B=r("ErOA"),j=function(t,e){return(j=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};function U(t,e){function r(){this.constructor=t}j(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function H(t,e,r,i){return new(r||(r=Promise))((function(n,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))}function G(t,e){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function z(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var i=Array(t),n=0;for(e=0;e<r;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,n++)i[n]=o[s];return i}var W=function(){function t(){}return t.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},t.setAttributes=function(t,e){for(var r=0,i=e;r<i.length;r++){var n=i[r],o=n[0],s=n[1];t.setAttribute(o,s)}},t.createRect=function(e,r,i){var n=document.createElementNS("http://www.w3.org/2000/svg","rect");return n.setAttribute("width",e.toString()),n.setAttribute("height",r.toString()),i&&t.setAttributes(n,i),n},t.createLine=function(e,r,i,n,o){var s=document.createElementNS("http://www.w3.org/2000/svg","line");return s.setAttribute("x1",e.toString()),s.setAttribute("y1",r.toString()),s.setAttribute("x2",i.toString()),s.setAttribute("y2",n.toString()),o&&t.setAttributes(s,o),s},t.createPolygon=function(e,r){var i=document.createElementNS("http://www.w3.org/2000/svg","polygon");return i.setAttribute("points",e),r&&t.setAttributes(i,r),i},t.createCircle=function(e,r){var i=document.createElementNS("http://www.w3.org/2000/svg","circle");return i.setAttribute("cx",(e/2).toString()),i.setAttribute("cy",(e/2).toString()),i.setAttribute("r",e.toString()),r&&t.setAttributes(i,r),i},t.createEllipse=function(e,r,i){var n=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return n.setAttribute("cx",(e/2).toString()),n.setAttribute("cy",(r/2).toString()),n.setAttribute("rx",(e/2).toString()),n.setAttribute("ry",(r/2).toString()),i&&t.setAttributes(n,i),n},t.createGroup=function(e){var r=document.createElementNS("http://www.w3.org/2000/svg","g");return e&&t.setAttributes(r,e),r},t.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},t.createMarker=function(e,r,i,n,o,s,a){var l=document.createElementNS("http://www.w3.org/2000/svg","marker");return t.setAttributes(l,[["id",e],["orient",r],["markerWidth",i.toString()],["markerHeight",n.toString()],["refX",o.toString()],["refY",s.toString()]]),l.appendChild(a),l},t.createText=function(e){var r=document.createElementNS("http://www.w3.org/2000/svg","text");return r.setAttribute("x","0"),r.setAttribute("y","0"),e&&t.setAttributes(r,e),r},t.createTSpan=function(e,r){var i=document.createElementNS("http://www.w3.org/2000/svg","tspan");return i.textContent=e,r&&t.setAttributes(i,r),i},t.createImage=function(e){var r=document.createElementNS("http://www.w3.org/2000/svg","image");return e&&t.setAttributes(r,e),r},t.createPoint=function(t,e){var r=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return r.x=t,r.y=e,r},t.createPath=function(e,r){var i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("d",e),r&&t.setAttributes(i,r),i},t}(),V=function(){function t(){}return t.addKey=function(e){t.key=e},Object.defineProperty(t,"isLicensed",{get:function(){return!!t.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(t.key)},enumerable:!1,configurable:!0}),t}(),K=function(){function t(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return t.prototype.rasterize=function(t,e,r){var i=this;return new Promise((function(n){var o=void 0!==r?r:document.createElement("canvas");null===t&&(i.markersOnly=!0,i.naturalSize=!1);var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("xmlns","http://www.w3.org/2000/svg"),s.setAttribute("width",e.width.baseVal.valueAsString),s.setAttribute("height",e.height.baseVal.valueAsString),s.setAttribute("viewBox","0 0 "+e.viewBox.baseVal.width.toString()+" "+e.viewBox.baseVal.height.toString()),s.innerHTML=e.innerHTML,!0===i.naturalSize?(s.width.baseVal.value=t.naturalWidth,s.height.baseVal.value=t.naturalHeight):void 0!==i.width&&void 0!==i.height&&(s.width.baseVal.value=i.width,s.height.baseVal.value=i.height),o.width=s.width.baseVal.value,o.height=s.height.baseVal.value;var a=s.outerHTML,l=o.getContext("2d");!0!==i.markersOnly&&l.drawImage(t,0,0,o.width,o.height);var c=window.URL,u=new Image(o.width,o.height);u.setAttribute("crossOrigin","anonymous");var h=new Blob([a],{type:"image/svg+xml"}),d=c.createObjectURL(h);u.onload=function(){l.drawImage(u,0,0),c.revokeObjectURL(d);var t=o.toDataURL(i.imageType,i.imageQuality);n(t)},u.src=d}))},t}(),q=function(){},Y=function(){function t(t){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+t+"_"}return Object.defineProperty(t.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#ffffff",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarColor:"#eeeeee",toolbarHeight:40,toolboxColor:"#eeeeee",toolboxAccentColor:"#3080c3",undoButtonVisible:!0,redoButtonVisible:!1,zoomButtonVisible:!1,zoomOutButtonVisible:!1,clearButtonVisible:!1,resultButtonBlockVisible:!0,logoPosition:"left"}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),t.prototype.addClass=function(t){return void 0===this.styleSheet&&this.addStyleSheet(),t.name=""+this.classNamePrefix+t.localName,this.classes.push(t),this.styleSheet.sheet.insertRule("."+t.name+" {"+t.style+"}",this.styleSheet.sheet.cssRules.length),t},t.prototype.addRule=function(t){void 0===this.styleSheet&&this.addStyleSheet(),this.rules.push(t),this.styleSheet.sheet.insertRule(t.selector+" {"+t.style+"}",this.styleSheet.sheet.cssRules.length)},t.prototype.addStyleSheet=function(){var t;this.styleSheet=document.createElement("style"),(null!==(t=this.styleSheetRoot)&&void 0!==t?t:document.head).appendChild(this.styleSheet),this.addRule(new X("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new X("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames","\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n ")),this.addRule(new X("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames","\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n ")),this.addClass(new $("fade_in","\n animation-duration: 0.3s;\n animation-name: "+this.classNamePrefix+"_fade_in_animation_frames;\n ")),this.addClass(new $("fade_out","\n animation-duration: 0.3s;\n animation-name: "+this.classNamePrefix+"_fade_out_animation_frames;\n "))},t.prototype.removeStyleSheet=function(){var t;this.styleSheet&&((null!==(t=this.styleSheetRoot)&&void 0!==t?t:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},t}(),X=function(t,e){this.selector=t,this.style=e},$=function(t,e){this.localName=t,this.style=e},Z=function(){function t(t,e,r,i,n){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=t,this.displayMode=e,this.markerItems=r,this.uiStyleSettings=i,this.styles=n,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return t.prototype.show=function(t){var e=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=t,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var r=document.createElement("div");r.className=this.toolbarBlockStyleClass.name,r.style.whiteSpace="nowrap",this.uiContainer.appendChild(r),this.addActionButton(r,'<svg viewBox="0 0 24 24"><path d="M10.07 14.27a.997.997 0 011.33.48l2.3 4.99 1.8-.85-2.31-4.98c-.24-.5-.02-1.1.48-1.33l.28-.08 2.3-.45L8 5.12V15.9l1.82-1.47.25-.16m3.57 7.7a.99.99 0 01-1.33-.47l-2.18-4.74-2.51 2.02c-.17.14-.38.22-.62.22a1 1 0 01-1-1V3a1 1 0 011-1c.24 0 .47.09.64.23l.01-.01 11.49 9.64a1.001 1.001 0 01-.44 1.75l-3.16.62 2.2 4.73c.26.5.02 1.09-.48 1.32l-3.62 1.69z"/></svg>',"select"),this.addActionButton(r,'<svg viewBox="0 0 24 24"><path d="M9 3v1H4v2h1v13a2 2 0 002 2h10a2 2 0 002-2V6h1V4h-5V3H9M7 6h10v13H7V6m2 2v9h2V8H9m4 0v9h2V8h-2z"/></svg>',"delete"),this.uiStyleSettings.clearButtonVisible&&this.addActionButton(r,'<svg viewBox="0 0 24 24"><path d="M19.36 2.72l1.42 1.42-5.72 5.71c1.07 1.54 1.22 3.39.32 4.59L9.06 8.12c1.2-.9 3.05-.75 4.59.32l5.71-5.72M5.93 17.57c-2.01-2.01-3.24-4.41-3.58-6.65l4.88-2.09 7.44 7.44-2.09 4.88c-2.24-.34-4.64-1.57-6.65-3.58z"/></svg>',"clear"),this.uiStyleSettings.undoButtonVisible&&this.addActionButton(r,'<svg viewBox="0 0 24 24"><path d="M12.5 8c-2.65 0-5.05 1-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"/></svg>',"undo"),this.uiStyleSettings.redoButtonVisible&&this.addActionButton(r,'<svg viewBox="0 0 24 24"><path d="M18.4 10.6C16.55 9 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16a8.002 8.002 0 017.6-5.5c1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"/></svg>',"redo"),this.uiStyleSettings.zoomButtonVisible&&this.addActionButton(r,'<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"zoom"),this.uiStyleSettings.zoomButtonVisible&&this.uiStyleSettings.zoomOutButtonVisible&&this.addActionButton(r,'<svg viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0016 9.5 6.5 6.5 0 009.5 3 6.5 6.5 0 003 9.5 6.5 6.5 0 009.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 5 1.5-1.5-5-5m-6 0C7 14 5 12 5 9.5S7 5 9.5 5 14 7 14 9.5 12 14 9.5 14M7 9h5v1H7V9z"/></svg>',"zoom-out"),this.uiStyleSettings.notesButtonVisible&&this.addActionButton(r,'<svg viewBox="0 0 24 24"><path d="M18.13 12l1.26-1.26c.44-.44 1-.68 1.61-.74V9l-6-6H5c-1.11 0-2 .89-2 2v14a2 2 0 002 2h6v-1.87l.13-.13H5V5h7v7h6.13M14 4.5l5.5 5.5H14V4.5m5.13 9.33l2.04 2.04L15.04 22H13v-2.04l6.13-6.13m3.72.36l-.98.98-2.04-2.04.98-.98c.19-.2.52-.2.72 0l1.32 1.32c.2.2.2.53 0 .72z"/></svg>',"notes"),this.markerButtonBlock=document.createElement("div"),this.markerButtonBlock.className=this.toolbarBlockStyleClass.name,this.markerButtonBlock.style.flexGrow="2",this.markerButtonBlock.style.textAlign="center",this.uiContainer.appendChild(this.markerButtonBlock),this.markerButtonOverflowBlock=document.createElement("div"),this.markerButtonOverflowBlock.className=this.toolbarOverflowBlockStyleClass.name+" "+(this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName?this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName:this.toolbarOverflowBlockStyleColorsClass.name),this.markerButtonOverflowBlock.style.display="none",this.uiContainer.appendChild(this.markerButtonOverflowBlock),this.markerItems&&(this.markerItems.forEach((function(t){var r=document.createElement("div");r.className=""+e.toolbarButtonStyleClass.name,r.setAttribute("data-type-name",t.typeName),r.innerHTML=t.icon,r.addEventListener("click",(function(){e.markerToolbarButtonClicked(r,t)})),e.buttons.push(r),e.markerButtons.push(r)})),this.overflowButton=document.createElement("div"),this.overflowButton.className=this.toolbarButtonStyleClass.name+" "+(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name),this.overflowButton.innerHTML='<svg viewBox="0 0 24 24"><path d="M12 16a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2z"/></svg>',this.overflowButton.addEventListener("click",this.overflowButtonClicked),this.markerButtonBlock.appendChild(this.overflowButton));var i=document.createElement("div");i.className=this.toolbarBlockStyleClass.name,i.style.whiteSpace="nowrap",i.style.display=!1!==this.uiStyleSettings.resultButtonBlockVisible?"":"none",this.uiContainer.appendChild(i),this.addActionButton(i,'<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"render"),this.addActionButton(i,'<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"close"),this.markerjsContainer.appendChild(this.uiContainer),this.setSelectMode(),this.setCurrentMarker(),this.adjustLayout()},t.prototype.addButtonClickListener=function(t){this.buttonClickListeners.push(t)},t.prototype.removeButtonClickListener=function(t){this.buttonClickListeners.indexOf(t)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(t),1)},t.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},t.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var t=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var e=0;e<this.markerButtons.length;e++)e<t||e===t&&this.markerButtons.length-1===t?this.markerButtonBlock.appendChild(this.markerButtons[e]):(e===t&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[e]))}},t.prototype.overflowButtonClicked=function(){"none"!==this.markerButtonOverflowBlock.style.display?(this.markerButtonOverflowBlock.className=this.markerButtonOverflowBlock.className.replace(this.styles.fadeInAnimationClassName,""),this.markerButtonOverflowBlock.style.display="none"):(this.markerButtonOverflowBlock.className+=" "+this.styles.fadeInAnimationClassName,this.markerButtonOverflowBlock.style.top=this.uiContainer.offsetTop+this.overflowButton.offsetHeight+"px",this.markerButtonOverflowBlock.style.right=this.uiContainer.offsetWidth-this.overflowButton.offsetLeft-this.overflowButton.offsetWidth+2*this.uiContainer.offsetLeft+"px",this.markerButtonOverflowBlock.style.display="inline-block")},t.prototype.resetButtonStyles=function(){var t=this;this.buttons.forEach((function(e){e.className=e.className.replace(t.uiStyleSettings.toolbarButtonStyleColorsClassName?t.uiStyleSettings.toolbarButtonStyleColorsClassName:t.toolbarButtonStyleColorsClass.name,"").trim(),e.className=e.className.replace(t.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?t.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:t.toolbarActiveButtonStyleColorsClass.name,"").trim(),e.className+=" "+(t.uiStyleSettings.toolbarButtonStyleColorsClassName?t.uiStyleSettings.toolbarButtonStyleColorsClassName:t.toolbarButtonStyleColorsClass.name)}))},t.prototype.addActionButton=function(t,e,r){var i=this,n=document.createElement("div");switch(n.className=""+this.toolbarButtonStyleClass.name,n.innerHTML=e,n.setAttribute("data-action",r),n.addEventListener("click",(function(){i.actionToolbarButtonClicked(n,r)})),r){case"select":n.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":n.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":n.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":n.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":n.style.fill=this.uiStyleSettings.closeButtonColor}t.appendChild(n),this.buttons.push(n)},t.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new $("toolbar","\n width: 100%;\n flex-shrink: 0;\n display: flex;\n flex-direction: row;\n justify-content: space-between; \n height: "+this.uiStyleSettings.toolbarHeight+"px;\n box-sizing: content-box;\n "+("inline"===this.displayMode?"border-top-left-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+"\n "+("inline"===this.displayMode?"border-top-right-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+"\n overflow: hidden;\n ")),this.toolbarStyleColorsClass=this.styles.addClass(new $("toolbar_colors","\n background-color: "+this.uiStyleSettings.toolbarBackgroundColor+";\n box-shadow: 0px 3px rgba(33, 33, 33, 0.1);\n ")),this.toolbarBlockStyleClass=this.styles.addClass(new $("toolbar-block","\n display: inline-block;\n box-sizing: content-box;\n ")),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new $("toolbar-overflow-block","\n position: absolute;\n top: "+this.uiStyleSettings.toolbarHeight+"px;\n max-width: "+2*this.uiStyleSettings.toolbarHeight+"px;\n z-index: 10;\n box-sizing: content-box;\n ")),this.toolbarOverflowBlockStyleColorsClass=this.styles.addClass(new $("toolbar-overflow-block_colors","\n background-color: "+this.uiStyleSettings.toolbarBackgroundColor+";\n "));var t=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new $("toolbar_button","\n display: inline-block;\n width: "+(this.uiStyleSettings.toolbarHeight-2*t)+"px;\n height: "+(this.uiStyleSettings.toolbarHeight-2*t)+"px;\n padding: "+t+"px;\n box-sizing: content-box;\n ")),this.toolbarButtonStyleColorsClass=this.styles.addClass(new $("toolbar_button_colors","\n fill: "+this.uiStyleSettings.toolbarColor+";\n ")),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new $("toolbar_active_button","\n fill: "+this.uiStyleSettings.toolbarColor+";\n background-color: "+this.uiStyleSettings.toolbarBackgroundHoverColor+"\n ")),this.styles.addRule(new X("."+this.toolbarButtonStyleClass.name+" svg","\n height: "+this.uiStyleSettings.toolbarHeight/2+"px;\n ")),this.styles.addRule(new X("."+this.toolbarButtonStyleColorsClass.name+":hover","\n background-color: "+this.uiStyleSettings.toolbarBackgroundHoverColor+"\n "))},t.prototype.markerToolbarButtonClicked=function(t,e){this.setActiveButton(t),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach((function(t){return t("marker",e)})),this.markerButtonOverflowBlock.style.display="none"},t.prototype.actionToolbarButtonClicked=function(t,e){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach((function(t){return t("action",e)})),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},t.prototype.setActiveButton=function(t){this.resetButtonStyles(),t.className=t.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),t.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},t.prototype.setActiveMarkerButton=function(t){var e=this.markerButtons.find((function(e){return e.getAttribute("data-type-name")===t}));e&&this.setActiveButton(e)},t.prototype.setCurrentMarker=function(t){var e=this;this.currentMarker=t,this.buttons.filter((function(t){return/delete|notes/.test(t.getAttribute("data-action"))})).forEach((function(t){void 0===e.currentMarker?(t.style.fillOpacity="0.4",t.style.pointerEvents="none"):(t.style.fillOpacity="1",t.style.pointerEvents="all")}))},t}(),Q=function(){function t(t,e,r,i){this.panels=[],this.panelButtons=[],this.markerjsContainer=t,this.displayMode=e,this.uiStyleSettings=r,this.styles=i,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return t.prototype.addStyles=function(){var t;this.toolboxStyleClass=this.styles.addClass(new $("toolbox","\n width: 100%;\n flex-shrink: 0;\n display: flex;\n flex-direction: column;\n font-family: sans-serif;\n "+("popup"===this.displayMode?"height:"+2.5*this.uiStyleSettings.toolbarHeight+"px;":"")+"\n box-sizing: content-box;\n "+("popup"===this.displayMode?"background-color: "+this.uiStyleSettings.canvasBackgroundColor+";":"")+"\n "+("inline"===this.displayMode?"border-bottom-left-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+"\n "+("inline"===this.displayMode?"border-bottom-right-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+"\n overflow: hidden;\n ")),this.toolboxStyleColorsClass=this.styles.addClass(new $("toolbox_colors","\n color: "+this.uiStyleSettings.toolboxColor+";\n "));var e=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new $("toolbox-button-row","\n display: flex;\n cursor: default;\n box-sizing: content-box;\n ")),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new $("toolbox-button-row_colors","\n background-color: "+this.uiStyleSettings.toolbarBackgroundColor+";\n ")),this.toolboxPanelRowStyleClass=this.styles.addClass(new $("toolbox-panel-row","\n display: flex;\n "+("inline"===this.displayMode?"position: absolute;":"")+"\n "+("inline"===this.displayMode?"bottom: "+this.uiStyleSettings.toolbarHeight+"px;":"")+"\n cursor: default;\n height: "+1.5*this.uiStyleSettings.toolbarHeight+"px;\n "+("inline"===this.displayMode?"width: 100%;":"")+"\n box-sizing: content-box;\n ")),this.toolboxPanelRowStyleColorsClass=this.styles.addClass(new $("toolbox-panel-row_colors","\n background-color: "+(null!==(t=this.uiStyleSettings.toolboxBackgroundColor)&&void 0!==t?t:this.uiStyleSettings.toolbarBackgroundHoverColor)+";\n ")),this.toolboxButtonStyleClass=this.styles.addClass(new $("toolbox_button","\n display: inline-block;\n width: "+(this.uiStyleSettings.toolbarHeight-2*e)+"px;\n height: "+(this.uiStyleSettings.toolbarHeight-2*e)+"px;\n padding: "+e+"px;\n box-sizing: content-box;\n ")),this.toolboxButtonStyleColorsClass=this.styles.addClass(new $("toolbox-button_colors","\n fill: "+this.uiStyleSettings.toolbarColor+";\n ")),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new $("toolbox-active-button_colors","\n background-color: "+this.uiStyleSettings.toolbarBackgroundHoverColor+";\n fill: "+this.uiStyleSettings.toolbarColor+";\n ")),this.styles.addRule(new X("."+this.toolboxButtonStyleColorsClass.name+":hover","\n background-color: "+this.uiStyleSettings.toolbarBackgroundHoverColor+"\n ")),this.styles.addRule(new X("."+this.toolboxButtonStyleClass.name+" svg","\n height: "+this.uiStyleSettings.toolbarHeight/2+"px;\n "))},t.prototype.show=function(t){var e;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=t,this.uiContainer.className=this.toolboxStyleClass.name+" "+(null!==(e=this.uiStyleSettings.toolboxStyleColorsClassName)&&void 0!==e?e:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},t.prototype.setPanelButtons=function(t){var e,r,i=this;this.panels=t,void 0!==this.uiContainer&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+(null!==(e=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)&&void 0!==e?e:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+(null!==(r=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)&&void 0!==r?r:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach((function(t){var e;t.uiStyleSettings=i.uiStyleSettings;var r=document.createElement("div");r.className=i.toolboxButtonStyleClass.name+" "+(null!==(e=i.uiStyleSettings.toolboxButtonStyleColorsClassName)&&void 0!==e?e:i.toolboxButtonStyleColorsClass.name),r.innerHTML=t.icon,r.title=t.title,r.addEventListener("click",(function(){i.panelButtonClick(t)})),i.panelButtons.push(r),i.buttonRow.appendChild(r)})),"inline"===this.displayMode?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},t.prototype.panelButtonClick=function(t){var e=this,r=-1;if(t!==this.activePanel){r=this.panels.indexOf(t),this.panelRow.innerHTML="";var i=t.getUi();i.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(i),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=t}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout((function(){"inline"===e.displayMode?e.panelRow.style.display="none":e.panelRow.style.visibility="hidden"}),200);this.panelButtons.forEach((function(t,i){var n,o;t.className=e.toolboxButtonStyleClass.name+" "+(i===r?""+(null!==(n=e.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)&&void 0!==n?n:e.toolboxActiveButtonStyleColorsClass.name):""+(null!==(o=e.uiStyleSettings.toolboxButtonStyleColorsClassName)&&void 0!==o?o:e.toolboxButtonStyleColorsClass.name))}))},t}(),J=function(t,e){this.title=t,this.icon=e},tt=function(t){function e(e,r,i,n){var o=t.call(this,e,n||'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 01-1.5-1.5A1.5 1.5 0 0117.5 9a1.5 1.5 0 011.5 1.5 1.5 1.5 0 01-1.5 1.5m-3-4A1.5 1.5 0 0113 6.5 1.5 1.5 0 0114.5 5 1.5 1.5 0 0116 6.5 1.5 1.5 0 0114.5 8m-5 0A1.5 1.5 0 018 6.5 1.5 1.5 0 019.5 5 1.5 1.5 0 0111 6.5 1.5 1.5 0 019.5 8m-3 4A1.5 1.5 0 015 10.5 1.5 1.5 0 016.5 9 1.5 1.5 0 018 10.5 1.5 1.5 0 016.5 12M12 3a9 9 0 00-9 9 9 9 0 009 9 1.5 1.5 0 001.5-1.5c0-.39-.15-.74-.39-1-.23-.27-.38-.62-.38-1a1.5 1.5 0 011.5-1.5H16a5 5 0 005-5c0-4.42-4.03-8-9-8z"/></svg>')||this;return o.colors=[],o.addTransparent=!1,o.colorBoxes=[],o.colors=r,o.currentColor=i,o.setCurrentColor=o.setCurrentColor.bind(o),o.getColorBox=o.getColorBox.bind(o),o}return U(e,t),e.prototype.getUi=function(){var t=this,e=document.createElement("div");return e.style.overflow="hidden",e.style.whiteSpace="nowrap",this.colors.forEach((function(r){var i=t.getColorBox(r);e.appendChild(i),t.colorBoxes.push(i)})),e},e.prototype.getColorBox=function(t){var e=this,r=this.uiStyleSettings.toolbarHeight/4,i=this.uiStyleSettings.toolbarHeight-r,n=document.createElement("div");n.style.display="inline-block",n.style.boxSizing="content-box",n.style.width=i-2+"px",n.style.height=i-2+"px",n.style.padding="1px",n.style.marginRight="2px",n.style.marginBottom="2px",n.style.borderWidth="2px",n.style.borderStyle="solid",n.style.borderRadius=(i+2)/2+"px",n.style.borderColor=t===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",n.addEventListener("click",(function(){e.setCurrentColor(t,n)}));var o=document.createElement("div");return o.style.display="inline-block",o.style.width=i-2+"px",o.style.height=i-2+"px",o.style.backgroundColor=t,o.style.borderRadius=i/2+"px","transparent"===t&&(o.style.fill=this.uiStyleSettings.toolboxAccentColor,o.innerHTML='<svg viewBox="0 0 24 24">\n <path d="M2,5.27L3.28,4L20,20.72L18.73,22L15.65,18.92C14.5,19.3 13.28,19.5 12,19.5C7,19.5 2.73,16.39 1,12C1.69,10.24 2.79,8.69 4.19,7.46L2,5.27M12,9A3,3 0 0,1 15,12C15,12.35 14.94,12.69 14.83,13L11,9.17C11.31,9.06 11.65,9 12,9M12,4.5C17,4.5 21.27,7.61 23,12C22.18,14.08 20.79,15.88 19,17.19L17.58,15.76C18.94,14.82 20.06,13.54 20.82,12C19.17,8.64 15.76,6.5 12,6.5C10.91,6.5 9.84,6.68 8.84,7L7.3,5.47C8.74,4.85 10.33,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C12.69,17.5 13.37,17.43 14,17.29L11.72,15C10.29,14.85 9.15,13.71 9,12.28L5.6,8.87C4.61,9.72 3.78,10.78 3.18,12Z" />\n </svg>'),n.appendChild(o),n},e.prototype.setCurrentColor=function(t,e){var r=this;this.currentColor=t,this.colorBoxes.forEach((function(t){t.style.borderColor=t===e?r.uiStyleSettings.toolboxAccentColor:"transparent"})),this.onColorChanged&&this.onColorChanged(t)},e}(J),et=function(){function t(t,e,r){this._state="new",this._isSelected=!1,this._container=t,this._overlayContainer=e,this.globalSettings=r,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(t.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),t.prototype.ownsTarget=function(t){return!1},Object.defineProperty(t.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),t.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},t.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},t.prototype.pointerDown=function(t,e){},t.prototype.dblClick=function(t,e){},t.prototype.manipulate=function(t){},t.prototype.pointerUp=function(t){this.stateChanged()},t.prototype.dispose=function(){},t.prototype.addMarkerVisualToContainer=function(t){this.container.childNodes.length>0?this.container.insertBefore(t,this.container.childNodes[0]):this.container.appendChild(t)},t.prototype.getState=function(){return{typeName:t.typeName,state:this.state,notes:this.notes}},t.prototype.restoreState=function(t){this._state=t.state,this.notes=t.notes},t.prototype.scale=function(t,e){},t.prototype.colorChanged=function(t){this.onColorChanged&&this.onColorChanged(t),this.stateChanged()},t.prototype.fillColorChanged=function(t){this.onFillColorChanged&&this.onFillColorChanged(t),this.stateChanged()},t.prototype.stateChanged=function(){if(this.onStateChanged&&"creating"!==this.state&&"new"!==this.state){var t=this.getState();void 0!==this.manipulationStartState&&(this.manipulationStartState.state="select"),t.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(t)&&this.onStateChanged(this)}},t.typeName="MarkerBase",t}(),rt=function(){function t(){this.findGripByVisual=this.findGripByVisual.bind(this)}return t.prototype.findGripByVisual=function(t){return this.topLeft.ownsTarget(t)?this.topLeft:this.topCenter.ownsTarget(t)?this.topCenter:this.topRight.ownsTarget(t)?this.topRight:this.centerLeft.ownsTarget(t)?this.centerLeft:this.centerRight.ownsTarget(t)?this.centerRight:this.bottomLeft.ownsTarget(t)?this.bottomLeft:this.bottomCenter.ownsTarget(t)?this.bottomCenter:this.bottomRight.ownsTarget(t)?this.bottomRight:void 0},t}(),it=function(){function t(){this.GRIP_SIZE=10,this.visual=W.createGroup(),this.visual.appendChild(W.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(W.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return t.prototype.ownsTarget=function(t){return t===this.visual||t===this.visual.childNodes[0]||t===this.visual.childNodes[1]},t}(),nt=function(){function t(){}return t.toITransformMatrix=function(t){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}},t.toSVGMatrix=function(t,e){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.e=e.e,t.f=e.f,t},t}(),ot=function(t){function e(e,r,i){var n=t.call(this,e,r,i)||this;return n.left=0,n.top=0,n.width=0,n.height=0,n.defaultSize={x:50,y:20},n.offsetX=0,n.offsetY=0,n.rotationAngle=0,n.CB_DISTANCE=10,n._suppressMarkerCreateEvent=!1,n.container.transform.baseVal.appendItem(W.createTransform()),n.setupControlBox(),n}return U(e,t),Object.defineProperty(e.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"visual",{get:function(){return this._visual},set:function(t){this._visual=t;var e=W.createTransform();this._visual.transform.baseVal.appendItem(e)},enumerable:!1,configurable:!0}),e.prototype.ownsTarget=function(e){return!!t.prototype.ownsTarget.call(this,e)||!!(void 0!==this.controlGrips.findGripByVisual(e)||void 0!==this.rotatorGrip&&this.rotatorGrip.ownsTarget(e))},e.prototype.pointerDown=function(e,r){t.prototype.pointerDown.call(this,e,r),"new"===this.state&&(this.left=e.x,this.top=e.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var i=this.unrotatePoint(e);if(this.manipulationStartX=i.x,this.manipulationStartY=i.y,this.offsetX=i.x-this.left,this.offsetY=i.y-this.top,"new"!==this.state)if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(r),void 0!==this.activeGrip)this._state="resize";else if(void 0!==this.rotatorGrip&&this.rotatorGrip.ownsTarget(r)){this.activeGrip=this.rotatorGrip;var n=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=n.x-this.width/2,this.top=n.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var o=this.container.transform.baseVal.getItem(0);o.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(o,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},e.prototype.pointerUp=function(e){var r=this.state;t.prototype.pointerUp.call(this,e),"creating"===this.state&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(e),this._state="select","creating"===r&&this.onMarkerCreated&&!1===this._suppressMarkerCreateEvent&&this.onMarkerCreated(this)},e.prototype.moveVisual=function(t){this.visual.style.transform="translate("+t.x+"px, "+t.y+"px)"},e.prototype.manipulate=function(t){var e=this.unrotatePoint(t);"creating"===this.state?this.resize(t):"move"===this.state?(this.left=this.manipulationStartLeft+(e.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(e.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):"resize"===this.state?this.resize(e):"rotate"===this.state&&this.rotate(t)},e.prototype.resize=function(t){var e=this.manipulationStartLeft,r=this.manipulationStartWidth,i=this.manipulationStartTop,n=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:e=this.manipulationStartLeft+t.x-this.manipulationStartX,r=this.manipulationStartWidth+this.manipulationStartLeft-e;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:r=this.manipulationStartWidth+t.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:i=this.manipulationStartTop+t.y-this.manipulationStartY,n=this.manipulationStartHeight+this.manipulationStartTop-i;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:n=this.manipulationStartHeight+t.y-this.manipulationStartY}r>=0?(this.left=e,this.width=r):(this.left=e+r,this.width=-r),n>=0?(this.top=i,this.height=n):(this.top=i+n,this.height=-n),this.setSize()},e.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},e.prototype.rotate=function(t){if(Math.abs(t.x-this.centerX)>.1){var e=Math.sign(t.x-this.centerX);this.rotationAngle=180*Math.atan((t.y-this.centerY)/(t.x-this.centerX))/Math.PI+90*e,this.applyRotation()}},e.prototype.applyRotation=function(){var t=this.container.transform.baseVal.getItem(0);t.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(t,0)},e.prototype.rotatePoint=function(t){if(0===this.rotationAngle)return t;var e=this.container.getCTM(),r=W.createPoint(t.x,t.y);return{x:(r=r.matrixTransform(e)).x,y:r.y}},e.prototype.unrotatePoint=function(t){if(0===this.rotationAngle)return t;var e=this.container.getCTM();e=e.inverse();var r=W.createPoint(t.x,t.y);return{x:(r=r.matrixTransform(e)).x,y:r.y}},e.prototype.select=function(){t.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},e.prototype.deselect=function(){t.prototype.deselect.call(this),this.controlBox.style.display="none"},e.prototype.setupControlBox=function(){this.controlBox=W.createGroup();var t=W.createTransform();t.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(t),this.container.appendChild(this.controlBox),this.controlRect=W.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),!0!==this.globalSettings.disableRotation&&(this.rotatorGripLine=W.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 rt,this.addControlGrips(),this.controlBox.style.display="none"},e.prototype.adjustControlBox=function(){var t=this.controlBox.transform.baseVal.getItem(0);t.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(t,0),this.controlRect.setAttribute("width",(this.width+this.CB_DISTANCE).toString()),this.controlRect.setAttribute("height",(this.height+this.CB_DISTANCE).toString()),void 0!==this.rotatorGripLine&&(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()},e.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(),!0!==this.globalSettings.disableRotation&&(this.rotatorGrip=this.createGrip()),this.positionGrips()},e.prototype.createGrip=function(){var t=new it;return t.visual.transform.baseVal.appendItem(W.createTransform()),this.controlBox.appendChild(t.visual),t},e.prototype.positionGrips=function(){var t=this.controlGrips.topLeft.GRIP_SIZE,e=-t/2,r=e,i=(this.width+this.CB_DISTANCE)/2-t/2,n=(this.height+this.CB_DISTANCE)/2-t/2,o=this.height+this.CB_DISTANCE-t/2,s=this.width+this.CB_DISTANCE-t/2;this.positionGrip(this.controlGrips.topLeft.visual,e,r),this.positionGrip(this.controlGrips.topCenter.visual,i,r),this.positionGrip(this.controlGrips.topRight.visual,s,r),this.positionGrip(this.controlGrips.centerLeft.visual,e,n),this.positionGrip(this.controlGrips.centerRight.visual,s,n),this.positionGrip(this.controlGrips.bottomLeft.visual,e,o),this.positionGrip(this.controlGrips.bottomCenter.visual,i,o),this.positionGrip(this.controlGrips.bottomRight.visual,s,o),void 0!==this.rotatorGrip&&this.positionGrip(this.rotatorGrip.visual,i,r-3*this.CB_DISTANCE)},e.prototype.positionGrip=function(t,e,r){var i=t.transform.baseVal.getItem(0);i.setTranslate(e,r),t.transform.baseVal.replaceItem(i,0)},e.prototype.hideControlBox=function(){this.controlBox.style.display="none"},e.prototype.showControlBox=function(){this.controlBox.style.display=""},e.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:nt.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:nt.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},t.prototype.getState.call(this))},e.prototype.restoreState=function(e){t.prototype.restoreState.call(this,e);var r=e;this.left=r.left,this.top=r.top,this.width=r.width,this.height=r.height,this.rotationAngle=r.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(nt.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,r.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(nt.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,r.containerTransformMatrix))},e.prototype.scale=function(e,r){t.prototype.scale.call(this,e,r);var i=this.rotatePoint({x:this.left,y:this.top}),n=this.unrotatePoint({x:i.x*e,y:i.y*r});this.left=n.x,this.top=n.y,this.width=this.width*e,this.height=this.height*r,this.adjustControlBox()},e}(et),st=function(t){function e(e,r,i){var n=t.call(this,e,r,i)||this;return n.fillColor="transparent",n.strokeColor="transparent",n.strokeWidth=0,n.strokeDasharray="",n.opacity=1,n.setStrokeColor=n.setStrokeColor.bind(n),n.setFillColor=n.setFillColor.bind(n),n.setStrokeWidth=n.setStrokeWidth.bind(n),n.setStrokeDasharray=n.setStrokeDasharray.bind(n),n.createVisual=n.createVisual.bind(n),n}return U(e,t),e.prototype.ownsTarget=function(e){return!(!t.prototype.ownsTarget.call(this,e)&&e!==this.visual)},e.prototype.createVisual=function(){this.visual=W.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)},e.prototype.pointerDown=function(e,r){t.prototype.pointerDown.call(this,e,r),"new"===this.state&&(this.createVisual(),this.moveVisual(e),this._state="creating")},e.prototype.manipulate=function(e){t.prototype.manipulate.call(this,e)},e.prototype.resize=function(e){t.prototype.resize.call(this,e),this.setSize()},e.prototype.setSize=function(){t.prototype.setSize.call(this),W.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},e.prototype.pointerUp=function(e){t.prototype.pointerUp.call(this,e),this.setSize()},e.prototype.setStrokeColor=function(t){this.strokeColor=t,this.visual&&W.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(t),this.stateChanged()},e.prototype.setFillColor=function(t){this.fillColor=t,this.visual&&W.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},e.prototype.setStrokeWidth=function(t){this.strokeWidth=t,this.visual&&W.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},e.prototype.setStrokeDasharray=function(t){this.strokeDasharray=t,this.visual&&W.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},e.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},t.prototype.getState.call(this))},e.prototype.restoreState=function(e){var r=e;this.fillColor=r.fillColor,this.strokeColor=r.strokeColor,this.strokeWidth=r.strokeWidth,this.strokeDasharray=r.strokeDasharray,this.opacity=r.opacity,this.createVisual(),t.prototype.restoreState.call(this,e),this.setSize()},e.prototype.scale=function(e,r){t.prototype.scale.call(this,e,r),this.setSize()},e.title="Rectangle marker",e}(ot),at=function(t){function e(e,r,i,n){var o=t.call(this,e,n||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return o.widths=[],o.widthBoxes=[],o.widths=r,o.currentWidth=i,o.setCurrentWidth=o.setCurrentWidth.bind(o),o}return U(e,t),e.prototype.getUi=function(){var t=this,e=document.createElement("div");return e.style.display="flex",e.style.overflow="hidden",e.style.flexGrow="2",this.widths.forEach((function(r){var i=document.createElement("div");i.style.display="flex",i.style.flexGrow="2",i.style.alignItems="center",i.style.justifyContent="space-between",i.style.padding="5px",i.style.borderWidth="2px",i.style.borderStyle="solid",i.style.borderColor=r===t.currentWidth?t.uiStyleSettings.toolboxAccentColor:"transparent",i.addEventListener("click",(function(){t.setCurrentWidth(r,i)})),e.appendChild(i);var n=document.createElement("div");n.innerText=r.toString(),n.style.marginRight="5px",i.appendChild(n);var o=document.createElement("div");o.style.minHeight="20px",o.style.flexGrow="2",o.style.display="flex",o.style.alignItems="center";var s=document.createElement("hr");s.style.minWidth="20px",s.style.border="0px",s.style.borderTop=r+"px solid "+t.uiStyleSettings.toolboxColor,s.style.flexGrow="2",o.appendChild(s),i.appendChild(o),t.widthBoxes.push(i)})),e},e.prototype.setCurrentWidth=function(t,e){var r=this;this.currentWidth=t,this.widthBoxes.forEach((function(t){t.style.borderColor=t===e?r.uiStyleSettings.toolboxAccentColor:"transparent"})),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},e}(J),lt=function(t){function e(e,r,i,n){var o=t.call(this,e,n||'<svg viewBox="0 0 24 24"><path d="M3 16h5v-2H3v2m6.5 0h5v-2h-5v2m6.5 0h5v-2h-5v2M3 20h2v-2H3v2m4 0h2v-2H7v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2M3 12h8v-2H3v2m10 0h8v-2h-8v2M3 4v4h18V4H3z"/></svg>')||this;return o.styles=[],o.styleBoxes=[],o.styles=r,o.currentStyle=i,o.setCurrentStyle=o.setCurrentStyle.bind(o),o}return U(e,t),e.prototype.getUi=function(){var t=this,e=document.createElement("div");return e.style.display="flex",e.style.overflow="hidden",e.style.flexGrow="2",this.styles.forEach((function(r){var i=document.createElement("div");i.style.display="flex",i.style.alignItems="center",i.style.justifyContent="space-between",i.style.padding="5px",i.style.borderWidth="2px",i.style.borderStyle="solid",i.style.overflow="hidden",i.style.maxWidth=100/t.styles.length-5+"%",i.style.borderColor=r===t.currentStyle?t.uiStyleSettings.toolboxAccentColor:"transparent",i.addEventListener("click",(function(){t.setCurrentStyle(r,i)})),e.appendChild(i);var n=document.createElement("div");n.style.minHeight="20px",n.style.flexGrow="2",n.style.overflow="hidden";var o='<svg width="100" height="20">\n <line x1="0" y1="10" x2="100" y2="10" stroke="'+t.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(""!==r?'stroke-dasharray="'+r+'"':"")+" />\n </svg>";n.innerHTML=o,i.appendChild(n),t.styleBoxes.push(i)})),e},e.prototype.setCurrentStyle=function(t,e){var r=this;this.currentStyle=t,this.styleBoxes.forEach((function(t){t.style.borderColor=t===e?r.uiStyleSettings.toolboxAccentColor:"transparent"})),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},e}(J),ct=function(t){function e(e,r,i){var n=t.call(this,e,r,i)||this;return n.strokeColor=i.defaultColor,n.strokeWidth=i.defaultStrokeWidth,n.strokeDasharray=i.defaultStrokeDasharray,n.strokePanel=new tt("Line color",i.defaultColorSet,i.defaultColor),n.strokePanel.onColorChanged=n.setStrokeColor,n.strokeWidthPanel=new at("Line width",i.defaultStrokeWidths,i.defaultStrokeWidth),n.strokeWidthPanel.onWidthChanged=n.setStrokeWidth,n.strokeStylePanel=new lt("Line style",i.defaultStrokeDasharrays,i.defaultStrokeDasharray),n.strokeStylePanel.onStyleChanged=n.setStrokeDasharray,n}return U(e,t),Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var r=t.prototype.getState.call(this);return r.typeName=e.typeName,r},e.typeName="FrameMarker",e.title="Frame marker",e.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',e}(st),ut=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},ht=function(t){function e(e,r,i){var n=t.call(this,e,r,i)||this;return n.x1=0,n.y1=0,n.x2=0,n.y2=0,n.defaultLength=50,n.manipulationStartX=0,n.manipulationStartY=0,n.manipulationStartX1=0,n.manipulationStartY1=0,n.manipulationStartX2=0,n.manipulationStartY2=0,n.setupControlBox(),n}return U(e,t),e.prototype.ownsTarget=function(e){return!!t.prototype.ownsTarget.call(this,e)||!(!this.grip1.ownsTarget(e)&&!this.grip2.ownsTarget(e))},e.prototype.pointerDown=function(e,r){t.prototype.pointerDown.call(this,e,r),this.manipulationStartX=e.x,this.manipulationStartY=e.y,"new"===this.state&&(this.x1=e.x,this.y1=e.y,this.x2=e.x,this.y2=e.y),this.manipulationStartX1=this.x1,this.manipulationStartY1=this.y1,this.manipulationStartX2=this.x2,this.manipulationStartY2=this.y2,"new"!==this.state&&(this.select(),this.grip1.ownsTarget(r)?this.activeGrip=this.grip1:this.grip2.ownsTarget(r)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},e.prototype.pointerUp=function(e){var r=this.state;t.prototype.pointerUp.call(this,e),"creating"===this.state&&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(e),this._state="select","creating"===r&&this.onMarkerCreated&&this.onMarkerCreated(this)},e.prototype.adjustVisual=function(){},e.prototype.manipulate=function(t){"creating"===this.state?this.resize(t):"move"===this.state?(this.x1=this.manipulationStartX1+t.x-this.manipulationStartX,this.y1=this.manipulationStartY1+t.y-this.manipulationStartY,this.x2=this.manipulationStartX2+t.x-this.manipulationStartX,this.y2=this.manipulationStartY2+t.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):"resize"===this.state&&this.resize(t)},e.prototype.resize=function(t){switch(this.activeGrip){case this.grip1:this.x1=t.x,this.y1=t.y;break;case this.grip2:case void 0:this.x2=t.x,this.y2=t.y}this.adjustVisual(),this.adjustControlBox()},e.prototype.select=function(){t.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},e.prototype.deselect=function(){t.prototype.deselect.call(this),this.controlBox.style.display="none"},e.prototype.setupControlBox=function(){this.controlBox=W.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},e.prototype.adjustControlBox=function(){this.positionGrips()},e.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},e.prototype.createGrip=function(){var t=new it;return t.visual.transform.baseVal.appendItem(W.createTransform()),this.controlBox.appendChild(t.visual),t},e.prototype.positionGrips=function(){var t=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-t/2,this.y1-t/2),this.positionGrip(this.grip2.visual,this.x2-t/2,this.y2-t/2)},e.prototype.positionGrip=function(t,e,r){var i=t.transform.baseVal.getItem(0);i.setTranslate(e,r),t.transform.baseVal.replaceItem(i,0)},e.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},t.prototype.getState.call(this))},e.prototype.restoreState=function(e){t.prototype.restoreState.call(this,e);var r=e;this.x1=r.x1,this.y1=r.y1,this.x2=r.x2,this.y2=r.y2},e.prototype.scale=function(e,r){t.prototype.scale.call(this,e,r),this.x1=this.x1*e,this.y1=this.y1*r,this.x2=this.x2*e,this.y2=this.y2*r,this.adjustVisual(),this.adjustControlBox()},e}(et),dt=function(t){function e(e,r,i){var n=t.call(this,e,r,i)||this;return n.strokeColor="transparent",n.strokeWidth=0,n.strokeDasharray="",n.setStrokeColor=n.setStrokeColor.bind(n),n.setStrokeWidth=n.setStrokeWidth.bind(n),n.setStrokeDasharray=n.setStrokeDasharray.bind(n),n.strokeColor=i.defaultColor,n.strokeWidth=i.defaultStrokeWidth,n.strokeDasharray=i.defaultStrokeDasharray,n.strokePanel=new tt("Line color",i.defaultColorSet,i.defaultColor),n.strokePanel.onColorChanged=n.setStrokeColor,n.strokeWidthPanel=new at("Line width",i.defaultStrokeWidths,i.defaultStrokeWidth),n.strokeWidthPanel.onWidthChanged=n.setStrokeWidth,n.strokeStylePanel=new lt("Line style",i.defaultStrokeDasharrays,i.defaultStrokeDasharray),n.strokeStylePanel.onStyleChanged=n.setStrokeDasharray,n}return U(e,t),e.prototype.ownsTarget=function(e){return!(!t.prototype.ownsTarget.call(this,e)&&e!==this.visual&&e!==this.selectorLine&&e!==this.visibleLine)},e.prototype.createVisual=function(){this.visual=W.createGroup(),this.selectorLine=W.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=W.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)},e.prototype.pointerDown=function(e,r){t.prototype.pointerDown.call(this,e,r),"new"===this.state&&(this.createVisual(),this.adjustVisual(),this._state="creating")},e.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()),W.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),W.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),W.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},e.prototype.setStrokeColor=function(t){this.strokeColor=t,this.adjustVisual(),this.colorChanged(t)},e.prototype.setStrokeWidth=function(t){this.strokeWidth=t,this.adjustVisual()},e.prototype.setStrokeDasharray=function(t){this.strokeDasharray=t,this.adjustVisual(),this.stateChanged()},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var r=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},t.prototype.getState.call(this));return r.typeName=e.typeName,r},e.prototype.restoreState=function(e){t.prototype.restoreState.call(this,e);var r=e;this.strokeColor=r.strokeColor,this.strokeWidth=r.strokeWidth,this.strokeDasharray=r.strokeDasharray,this.createVisual(),this.adjustVisual()},e.typeName="LineMarker",e.title="Line marker",e.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',e}(ht),ft=function(t){function e(e,r,i,n){var o=t.call(this,e,n||'<svg viewBox="0 0 24 24"><path d="M17 8h3v12h1v1h-4v-1h1v-3h-4l-1.5 3H14v1h-4v-1h1l6-12m1 1l-3.5 7H18V9M5 3h5c1.11 0 2 .89 2 2v11H9v-5H6v5H3V5c0-1.11.89-2 2-2m1 2v4h3V5H6z"/></svg>')||this;return o.fonts=[],o.fontBoxes=[],o.fonts=r,o.currentFont=i,o.setCurrentFont=o.setCurrentFont.bind(o),o}return U(e,t),e.prototype.getUi=function(){var t=this,e=document.createElement("div");return e.style.overflow="hidden",e.style.flexGrow="2",this.fonts.forEach((function(r){var i=document.createElement("div");i.style.display="inline-block",i.style.alignItems="center",i.style.justifyContent="space-between",i.style.padding="5px",i.style.borderWidth="2px",i.style.borderStyle="solid",i.style.overflow="hidden",i.style.maxWidth=100/t.fonts.length-5+"%",i.style.borderColor=r===t.currentFont?t.uiStyleSettings.toolboxAccentColor:"transparent",i.addEventListener("click",(function(){t.setCurrentFont(r,i)})),e.appendChild(i);var n=document.createElement("div");n.style.display="flex",n.style.minHeight="20px",n.style.flexGrow="2",n.style.fontFamily=r,n.style.overflow="hidden";var o=document.createElement("div");o.style.whiteSpace="nowrap",o.style.overflow="hidden",o.style.textOverflow="ellipsis",o.innerHTML="The quick brown fox jumps over the lazy dog",n.appendChild(o),i.appendChild(n),t.fontBoxes.push(i)})),e},e.prototype.setCurrentFont=function(t,e){var r=this;this.currentFont=t,this.fontBoxes.forEach((function(t){t.style.borderColor=t===e?r.uiStyleSettings.toolboxAccentColor:"transparent"})),this.onFontChanged&&this.onFontChanged(this.currentFont)},e}(J),pt=function(t){function e(e,r,i){var n=t.call(this,e,r,i)||this;return n.color="transparent",n.padding=5,n.DEFAULT_TEXT="your text here",n.text=n.DEFAULT_TEXT,n.isMoved=!1,n.color=i.defaultColor,n.fontFamily=i.defaultFontFamily,n.defaultSize={x:100,y:30},n.setColor=n.setColor.bind(n),n.setFont=n.setFont.bind(n),n.renderText=n.renderText.bind(n),n.sizeText=n.sizeText.bind(n),n.textEditDivClicked=n.textEditDivClicked.bind(n),n.showTextEditor=n.showTextEditor.bind(n),n.setSize=n.setSize.bind(n),n.positionTextEditor=n.positionTextEditor.bind(n),n.colorPanel=new tt("Color",i.defaultColorSet,i.defaultColor),n.colorPanel.onColorChanged=n.setColor,n.fontFamilyPanel=new ft("Font",i.defaultFontFamilies,i.defaultFontFamily),n.fontFamilyPanel.onFontChanged=n.setFont,n}return U(e,t),e.prototype.ownsTarget=function(e){if(t.prototype.ownsTarget.call(this,e)||e===this.visual||e===this.textElement||e===this.bgRectangle)return!0;var r=!1;return this.textElement.childNodes.forEach((function(t){t===e&&(r=!0)})),r},e.prototype.createVisual=function(){this.visual=W.createGroup(),this.bgRectangle=W.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=W.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(W.createTransform()),this.textElement.transform.baseVal.appendItem(W.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},e.prototype.pointerDown=function(e,r){t.prototype.pointerDown.call(this,e,r),this.isMoved=!1,this.pointerDownPoint=e,this.pointerDownTimestamp=Date.now(),"new"===this.state&&(this.createVisual(),this.moveVisual(e),this._state="creating")},e.prototype.renderText=function(){var t=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(e){t.textElement.appendChild(W.createTSpan(""===e.trim()?" ":e.trim(),[["x","0"],["dy","1.2em"]]))})),setTimeout(this.sizeText,10)}},e.prototype.getTextScale=function(){var t=this.textElement.getBBox(),e=1;if(t.width>0&&t.height>0){var r=(1*this.width-this.width*this.padding*2/100)/t.width,i=(1*this.height-this.height*this.padding*2/100)/t.height;e=Math.min(r,i)}return e},e.prototype.getTextPosition=function(t){var e=this.textElement.getBBox(),r=0,i=0;return e.width>0&&e.height>0&&(r=(this.width-e.width*t)/2,i=this.height/2-e.height*t/2),{x:r,y:i}},e.prototype.sizeText=function(){var t=this.textElement.getBBox(),e=this.getTextScale(),r=this.getTextPosition(e);r.y-=t.y*e,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+r.x+"px, "+r.y+"px) scale("+e+", "+e+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(r.x,r.y),this.textElement.transform.baseVal.getItem(1).setScale(e,e))},e.prototype.manipulate=function(e){t.prototype.manipulate.call(this,e),void 0!==this.pointerDownPoint&&(this.isMoved=Math.abs(e.x-this.pointerDownPoint.x)>5||Math.abs(e.y-this.pointerDownPoint.y)>5)},e.prototype.resize=function(e){t.prototype.resize.call(this,e),this.isMoved=!0,this.setSize(),this.sizeText()},e.prototype.setSize=function(){t.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(W.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),W.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},e.prototype.pointerUp=function(e){var r=this.state;"creating"===r&&(this._suppressMarkerCreateEvent=!0),t.prototype.pointerUp.call(this,e),this.setSize(),("creating"===r||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},e.prototype.showTextEditor=function(){var t=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(t){t.stopPropagation()})),this.textEditor.addEventListener("input",(function(){for(var e=Number.parseFloat(t.textEditor.style.fontSize);t.textEditor.clientWidth>=Number.parseInt(t.textEditor.style.maxWidth)&&e>.9;)e-=.1,t.textEditor.style.fontSize=Math.max(e,.9)+"em"})),this.textEditor.addEventListener("keyup",(function(t){t.cancelBubble=!0})),this.textEditor.addEventListener("paste",(function(t){if(t.clipboardData){var e=t.clipboardData.getData("text"),r=window.getSelection();if(!r.rangeCount)return!1;r.deleteFromDocument(),r.getRangeAt(0).insertNode(document.createTextNode(e)),t.preventDefault()}})),this.textEditDiv.addEventListener("pointerup",(function(){t.textEditDivClicked(t.textEditor.innerText)})),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},e.prototype.positionTextEditor=function(){if("edit"===this.state)if(void 0===this.textEditor)this.showTextEditor();else{this.textElement.style.display="";var t=this.getTextScale(),e=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),r=this.textElement.getBBox(),i={x:r.width*t,y:r.height*t};e.x-=i.x/2,e.y-=i.y/2,this.textEditor.style.top=e.y+"px",this.textEditor.style.left=e.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-e.x+"px",this.textEditor.style.fontSize=Math.max(16*t,12)+"px",this.textElement.style.display="none"}},e.prototype.textEditDivClicked=function(t){this.text=t.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},e.prototype.select=function(){t.prototype.select.call(this),"edit"===this.state&&this.textEditDivClicked(this.textEditor.innerText)},e.prototype.deselect=function(){"edit"===this.state&&this.textEditDivClicked(this.textEditor.innerText),t.prototype.deselect.call(this)},e.prototype.dblClick=function(e,r){t.prototype.dblClick.call(this,e,r),this.showTextEditor()},e.prototype.setColor=function(t){this.textElement&&W.setAttributes(this.textElement,[["fill",t]]),this.color=t,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(t)},e.prototype.setFont=function(t){this.textElement&&W.setAttributes(this.textElement,[["font-family",t]]),this.fontFamily=t,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},e.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},e.prototype.showVisual=function(){"edit"===this.state&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var r=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},t.prototype.getState.call(this));return r.typeName=e.typeName,r},e.prototype.restoreState=function(e){var r=e;this.color=r.color,this.fontFamily=r.fontFamily,this.padding=r.padding,this.text=r.text,this.createVisual(),t.prototype.restoreState.call(this,e),this.setSize()},e.prototype.scale=function(e,r){t.prototype.scale.call(this,e,r),this.setSize(),this.sizeText(),this.positionTextEditor()},e.typeName="TextMarker",e.title="Text marker",e.icon='<svg viewBox="0 0 24 24"><path d="M9.6 14L12 7.7l2.4 6.3M11 5L5.5 19h2.2l1.1-3H15l1.1 3h2.2L13 5h-2z"/></svg>',e}(ot),gt=function(t){function e(e,r,i){var n=t.call(this,e,r,i)||this;return n.color="transparent",n.lineWidth=3,n.drawing=!1,n.pixelRatio=1,n.color=i.defaultColor,n.lineWidth=i.defaultStrokeWidth,n.pixelRatio=i.freehandPixelRatio,n.setColor=n.setColor.bind(n),n.addCanvas=n.addCanvas.bind(n),n.finishCreation=n.finishCreation.bind(n),n.setLineWidth=n.setLineWidth.bind(n),n.colorPanel=new tt("Color",i.defaultColorSet,i.defaultColor),n.colorPanel.onColorChanged=n.setColor,n.lineWidthPanel=new at("Line width",i.defaultStrokeWidths,i.defaultStrokeWidth),n.lineWidthPanel.onWidthChanged=n.setLineWidth,n}return U(e,t),e.prototype.ownsTarget=function(e){return!(!t.prototype.ownsTarget.call(this,e)&&e!==this.visual&&e!==this.drawingImage)},e.prototype.createVisual=function(){this.visual=W.createGroup(),this.drawingImage=W.createImage(),this.visual.appendChild(this.drawingImage);var t=W.createTransform();this.visual.transform.baseVal.appendItem(t),this.addMarkerVisualToContainer(this.visual)},e.prototype.pointerDown=function(e,r){"new"===this.state&&(this.addCanvas(),this.createVisual(),this._state="creating"),"creating"===this.state?(this.canvasContext.strokeStyle=this.color,this.canvasContext.lineWidth=this.lineWidth,this.canvasContext.beginPath(),this.canvasContext.moveTo(e.x,e.y),this.drawing=!0):t.prototype.pointerDown.call(this,e,r)},e.prototype.manipulate=function(e){"creating"===this.state?this.drawing&&(this.canvasContext.lineTo(e.x,e.y),this.canvasContext.stroke()):t.prototype.manipulate.call(this,e)},e.prototype.resize=function(e){t.prototype.resize.call(this,e),W.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),W.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},e.prototype.pointerUp=function(e){"creating"===this._state?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):t.prototype.pointerUp.call(this,e)},e.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)},e.prototype.select=function(){"creating"===this.state&&this.finishCreation(),t.prototype.select.call(this)},e.prototype.deselect=function(){"creating"===this.state&&this.finishCreation(),t.prototype.deselect.call(this)},e.prototype.finishCreation=function(){for(var t=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),e=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],r=e[0],i=e[1],n=e[2],o=e[3],s=!1,a=0;a<this.canvasElement.height;a++)for(var l=0;l<this.canvasElement.width;l++)t.data[a*this.canvasElement.width*4+4*l+3]>0&&(s=!0,a<i&&(i=a),l<r&&(r=l),a>o&&(o=a),l>n&&(n=l));if(s){this.left=r/this.pixelRatio,this.top=i/this.pixelRatio,this.width=(n-r)/this.pixelRatio,this.height=(o-i)/this.pixelRatio;var c=document.createElement("canvas");c.width=n-r,c.height=o-i,c.getContext("2d").putImageData(this.canvasContext.getImageData(r,i,n-r,o-i),0,0),this.drawingImgUrl=c.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},e.prototype.setDrawingImage=function(){W.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),W.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},e.prototype.setColor=function(t){this.color=t,this.colorChanged(t)},e.prototype.setLineWidth=function(t){this.lineWidth=t},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return"new"===this.state||"creating"===this.state?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var r=Object.assign({drawingImgUrl:this.drawingImgUrl},t.prototype.getState.call(this));return r.typeName=e.typeName,r},e.prototype.restoreState=function(e){this.createVisual(),t.prototype.restoreState.call(this,e),this.drawingImgUrl=e.drawingImgUrl,this.setDrawingImage()},e.prototype.scale=function(e,r){t.prototype.scale.call(this,e,r),this.setDrawingImage()},e.typeName="FreehandMarker",e.title="Freehand marker",e.icon='<svg viewBox="0 0 24 24"><path d="M9.75 20.85c1.78-.7 1.39-2.63.49-3.85-.89-1.25-2.12-2.11-3.36-2.94A9.817 9.817 0 014.54 12c-.28-.33-.85-.94-.27-1.06.59-.12 1.61.46 2.13.68.91.38 1.81.82 2.65 1.34l1.01-1.7C8.5 10.23 6.5 9.32 4.64 9.05c-1.06-.16-2.18.06-2.54 1.21-.32.99.19 1.99.77 2.77 1.37 1.83 3.5 2.71 5.09 4.29.34.33.75.72.95 1.18.21.44.16.47-.31.47-1.24 0-2.79-.97-3.8-1.61l-1.01 1.7c1.53.94 4.09 2.41 5.96 1.79m11.09-15.6c.22-.22.22-.58 0-.79l-1.3-1.3a.562.562 0 00-.78 0l-1.02 1.02 2.08 2.08M11 10.92V13h2.08l6.15-6.15-2.08-2.08L11 10.92z"/></svg>',e}(ot),mt=function(t){function e(e,r,i){var n=t.call(this,e,i||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return n.typeBoxes=[],n.currentType=r,n.setCurrentType=n.setCurrentType.bind(n),n}return U(e,t),e.prototype.getUi=function(){var t=this,e=document.createElement("div");e.style.display="flex",e.style.overflow="hidden",e.style.flexGrow="2";for(var r=function(r){var n="both";switch(r){case 0:n="both";break;case 1:n="start";break;case 2:n="end";break;case 3:n="none"}var o=document.createElement("div");if(o.style.display="flex",o.style.flexGrow="2",o.style.alignItems="center",o.style.justifyContent="space-between",o.style.padding="5px",o.style.borderWidth="2px",o.style.borderStyle="solid",o.style.borderColor=n===i.currentType?i.uiStyleSettings.toolboxAccentColor:"transparent",o.addEventListener("click",(function(){t.setCurrentType(n,o)})),e.appendChild(o),"both"===n||"start"===n){var s=document.createElement("div");s.style.display="flex",s.style.alignItems="center",s.style.minHeight="20px",s.innerHTML='<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">\n <polygon points="0,5 10,0 10,10" fill="'+(void 0!==i.uiStyleSettings?i.uiStyleSettings.toolboxColor:"#eeeeee")+'" />\n </svg>',s.style.marginLeft="5px",o.appendChild(s)}var a=document.createElement("div");a.style.display="flex",a.style.alignItems="center",a.style.minHeight="20px",a.style.flexGrow="2";var l=document.createElement("hr");if(l.style.minWidth="20px",l.style.border="0px",l.style.borderTop="3px solid "+(void 0!==i.uiStyleSettings?i.uiStyleSettings.toolboxColor:"#eeeeee"),l.style.flexGrow="2",a.appendChild(l),o.appendChild(a),"both"===n||"end"===n){var c=document.createElement("div");c.style.display="flex",c.style.alignItems="center",c.style.minHeight="20px",c.innerHTML='<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">\n <polygon points="0,0 10,5 0,10" fill="'+(void 0!==i.uiStyleSettings?i.uiStyleSettings.toolboxColor:"#eeeeee")+'" />\n </svg>',c.style.marginRight="5px",o.appendChild(c)}i.typeBoxes.push(o)},i=this,n=0;n<4;n++)r(n);return e},e.prototype.setCurrentType=function(t,e){var r=this;this.currentType=t,this.typeBoxes.forEach((function(t){t.style.borderColor=t===e?void 0!==r.uiStyleSettings?r.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"})),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},e}(J),vt=function(t){function e(e,r,i){var n=t.call(this,e,r,i)||this;return n.arrowType="end",n.arrowBaseHeight=10,n.arrowBaseWidth=10,n.getArrowPoints=n.getArrowPoints.bind(n),n.setArrowType=n.setArrowType.bind(n),n.arrowTypePanel=new mt("Arrow type","end"),n.arrowTypePanel.onArrowTypeChanged=n.setArrowType,n}return U(e,t),e.prototype.ownsTarget=function(e){return!(!t.prototype.ownsTarget.call(this,e)&&e!==this.arrow1&&e!==this.arrow2)},e.prototype.getArrowPoints=function(t,e){var r=this.arrowBaseWidth+2*this.strokeWidth,i=this.arrowBaseHeight+2*this.strokeWidth;return t-r/2+","+(e+i/2)+" "+t+","+(e-i/2)+" "+(t+r/2)+","+(e+i/2)},e.prototype.createTips=function(){this.arrow1=W.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(W.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=W.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(W.createTransform()),this.visual.appendChild(this.arrow2)},e.prototype.pointerDown=function(e,r){t.prototype.pointerDown.call(this,e,r),"creating"===this.state&&this.createTips()},e.prototype.adjustVisual=function(){if(t.prototype.adjustVisual.call(this),this.arrow1&&this.arrow2&&(this.arrow1.style.display="both"===this.arrowType||"start"===this.arrowType?"":"none",this.arrow2.style.display="both"===this.arrowType||"end"===this.arrowType?"":"none",W.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),W.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var e=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),r=this.arrow1.transform.baseVal.getItem(0);r.setRotate(e,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(r,0);var i=this.arrow2.transform.baseVal.getItem(0);i.setRotate(e+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(i,0)}},e.prototype.setArrowType=function(t){this.arrowType=t,this.adjustVisual(),this.stateChanged()},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var r=Object.assign({arrowType:this.arrowType},t.prototype.getState.call(this));return r.typeName=e.typeName,r},e.prototype.restoreState=function(e){t.prototype.restoreState.call(this,e);var r=e;this.arrowType=r.arrowType,this.createTips(),this.adjustVisual()},e.typeName="ArrowMarker",e.title="Arrow marker",e.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',e}(dt),yt=function(t){function e(e,r,i){var n=t.call(this,e,r,i)||this;return n.fillColor=i.defaultFillColor,n.strokeWidth=0,n.fillPanel=new tt("Color",i.defaultColorSet,i.defaultFillColor),n.fillPanel.onColorChanged=n.setFillColor,n}return U(e,t),Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var r=t.prototype.getState.call(this);return r.typeName=e.typeName,r},e.typeName="CoverMarker",e.title="Cover marker",e.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',e}(st),bt=function(t){function e(e,r,i,n){var o=t.call(this,e,n||'<svg viewBox="0 0 24 24"><path d="M17.66 8L12 2.35 6.34 8A8.02 8.02 0 004 13.64c0 2 .78 4.11 2.34 5.67a7.99 7.99 0 0011.32 0c1.56-1.56 2.34-3.67 2.34-5.67S19.22 9.56 17.66 8M6 14c0-2 .62-3.27 1.76-4.4L12 5.27l4.24 4.38C17.38 10.77 18 12 18 14H6z"/></svg>')||this;return o.opacities=[],o.opacityBoxes=[],o.opacities=r,o.currentOpacity=i,o.setCurrentOpacity=o.setCurrentOpacity.bind(o),o}return U(e,t),e.prototype.getUi=function(){var t=this,e=document.createElement("div");return e.style.display="flex",e.style.overflow="hidden",e.style.flexGrow="2",e.style.justifyContent="space-between",this.opacities.forEach((function(r){var i=document.createElement("div");i.style.display="flex",i.style.alignItems="center",i.style.justifyContent="center",i.style.padding="5px",i.style.borderWidth="2px",i.style.borderStyle="solid",i.style.borderColor=r===t.currentOpacity?t.uiStyleSettings.toolboxAccentColor:"transparent",i.addEventListener("click",(function(){t.setCurrentOpacity(r,i)})),e.appendChild(i);var n=document.createElement("div");n.innerText=100*r+"%",i.appendChild(n),t.opacityBoxes.push(i)})),e},e.prototype.setCurrentOpacity=function(t,e){var r=this;this.currentOpacity=t,this.opacityBoxes.forEach((function(t){t.style.borderColor=t===e?r.uiStyleSettings.toolboxAccentColor:"transparent"})),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},e}(J),xt=function(t){function e(e,r,i){var n=t.call(this,e,r,i)||this;return n.setOpacity=n.setOpacity.bind(n),n.fillColor=i.defaultHighlightColor,n.strokeWidth=0,n.opacity=i.defaultHighlightOpacity,n.fillPanel=new tt("Color",i.defaultColorSet,n.fillColor),n.fillPanel.onColorChanged=n.setFillColor,n.opacityPanel=new bt("Opacity",i.defaultOpacitySteps,n.opacity),n.opacityPanel.onOpacityChanged=n.setOpacity,n}return U(e,t),e.prototype.setOpacity=function(t){this.opacity=t,this.visual&&W.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var r=t.prototype.getState.call(this);return r.typeName=e.typeName,r},e.typeName="HighlightMarker",e.title="Highlight marker",e.icon='<svg viewBox="0 0 24 24"><path d="M18.5 1.15c-.53 0-1.04.19-1.43.58l-5.81 5.82 5.65 5.65 5.82-5.81c.77-.78.77-2.04 0-2.83l-2.84-2.83c-.39-.39-.89-.58-1.39-.58M10.3 8.5l-5.96 5.96c-.78.78-.78 2.04.02 2.85C3.14 18.54 1.9 19.77.67 21h5.66l.86-.86c.78.76 2.03.75 2.81-.02l5.95-5.96"/></svg>',e}(yt),St='<svg viewBox="0 0 24 24"><path d="M19 11.5s-2 2.17-2 3.5a2 2 0 002 2 2 2 0 002-2c0-1.33-2-3.5-2-3.5M5.21 10L10 5.21 14.79 10m1.77-1.06L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.56-.59 1.53 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.59.59-1.56 0-2.12z"/></svg>',Ct=function(t){function e(e,r,i){var n=t.call(this,e,r,i)||this;return n.bgColor="transparent",n.tipPosition={x:0,y:0},n.tipBase1Position={x:0,y:0},n.tipBase2Position={x:0,y:0},n.tipMoving=!1,n.color=i.defaultStrokeColor,n.bgColor=i.defaultFillColor,n.fontFamily=i.defaultFontFamily,n.defaultSize={x:100,y:30},n.setBgColor=n.setBgColor.bind(n),n.getTipPoints=n.getTipPoints.bind(n),n.positionTip=n.positionTip.bind(n),n.setTipPoints=n.setTipPoints.bind(n),n.colorPanel=new tt("Text color",i.defaultColorSet,n.color,'<svg viewBox="0 0 24 24"><path d="M9.62 12L12 5.67 14.37 12M11 3L5.5 17h2.25l1.12-3h6.25l1.13 3h2.25L13 3h-2z"/></svg>'),n.colorPanel.onColorChanged=n.setColor,n.bgColorPanel=new tt("Fill color",i.defaultColorSet,n.bgColor,St),n.bgColorPanel.onColorChanged=n.setBgColor,n.fontFamilyPanel=new ft("Font",i.defaultFontFamilies,i.defaultFontFamily),n.fontFamilyPanel.onFontChanged=n.setFont,n.tipGrip=new it,n.tipGrip.visual.transform.baseVal.appendItem(W.createTransform()),n.controlBox.appendChild(n.tipGrip.visual),n}return U(e,t),e.prototype.ownsTarget=function(e){return t.prototype.ownsTarget.call(this,e)||this.tipGrip.ownsTarget(e)||this.tip===e},e.prototype.createTip=function(){W.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=W.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},e.prototype.pointerDown=function(e,r){"new"===this.state&&t.prototype.pointerDown.call(this,e,r),"creating"===this.state?this.createTip():this.tipGrip.ownsTarget(r)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):t.prototype.pointerDown.call(this,e,r)},e.prototype.pointerUp=function(e){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,t.prototype.pointerUp.call(this,e);else{var r="creating"===this.state;t.prototype.pointerUp.call(this,e),this.setTipPoints(r),this.positionTip()}},e.prototype.manipulate=function(e){if(this.tipMoving){var r=this.unrotatePoint(e);this.tipPosition={x:r.x-this.manipulationStartLeft,y:r.y-this.manipulationStartTop},this.positionTip()}else t.prototype.manipulate.call(this,e)},e.prototype.setBgColor=function(t){this.bgRectangle&&this.tip&&(W.setAttributes(this.bgRectangle,[["fill",t]]),W.setAttributes(this.tip,[["fill",t]])),this.bgColor=t,this.fillColorChanged(t)},e.prototype.getTipPoints=function(){return this.setTipPoints("creating"===this.state),this.tipBase1Position.x+","+this.tipBase1Position.y+" "+this.tipBase2Position.x+","+this.tipBase2Position.y+" "+this.tipPosition.x+","+this.tipPosition.y},e.prototype.setTipPoints=function(t){void 0===t&&(t=!1);var e=Math.min(this.height/2,15),r=this.height/5;t&&(this.tipPosition={x:e+r/2,y:this.height+20});var i=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?i<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(r=this.width/5,e=Math.min(this.width/2,15),this.tipBase1Position={x:e,y:0},this.tipBase2Position={x:e+r,y:0}):(this.tipBase1Position={x:0,y:e},this.tipBase2Position={x:0,y:e+r}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?i<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(r=this.width/5,e=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-e-r,y:0},this.tipBase2Position={x:this.width-e,y:0}):(this.tipBase1Position={x:this.width,y:e},this.tipBase2Position={x:this.width,y:e+r}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?i<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(r=this.width/5,e=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-e-r,y:this.height},this.tipBase2Position={x:this.width-e,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-e-r},this.tipBase2Position={x:this.width,y:this.height-e}):i<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(r=this.width/5,e=Math.min(this.width/2,15),this.tipBase1Position={x:e,y:this.height},this.tipBase2Position={x:e+r,y:this.height}):(this.tipBase1Position={x:0,y:this.height-e},this.tipBase2Position={x:0,y:this.height-e-r})},e.prototype.resize=function(e){t.prototype.resize.call(this,e),this.positionTip()},e.prototype.positionTip=function(){W.setAttributes(this.tip,[["points",this.getTipPoints()]]);var t=this.tipGrip.visual.transform.baseVal.getItem(0);t.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(t,0)},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),e.prototype.select=function(){this.positionTip(),t.prototype.select.call(this)},e.prototype.getState=function(){var r=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},t.prototype.getState.call(this));return r.typeName=e.typeName,r},e.prototype.restoreState=function(e){var r=e;this.bgColor=r.bgColor,this.tipPosition=r.tipPosition,t.prototype.restoreState.call(this,e),this.createTip(),this.setTipPoints()},e.prototype.scale=function(e,r){t.prototype.scale.call(this,e,r),this.tipPosition={x:this.tipPosition.x*e,y:this.tipPosition.y*r},this.positionTip()},e.typeName="CalloutMarker",e.title="Callout marker",e.icon='<svg viewBox="0 0 24 24"><path d="M4 2h16a2 2 0 012 2v12a2 2 0 01-2 2h-4l-4 4-4-4H4a2 2 0 01-2-2V4a2 2 0 012-2m0 2v12h4.83L12 19.17 15.17 16H20V4H4m2 3h12v2H6V7m0 4h10v2H6v-2z"/></svg>',e}(pt),wt=function(t){function e(e,r,i){var n=t.call(this,e,r,i)||this;return n.fillColor="transparent",n.strokeColor="transparent",n.strokeWidth=0,n.strokeDasharray="",n.opacity=1,n.strokeColor=i.defaultColor,n.strokeWidth=i.defaultStrokeWidth,n.strokeDasharray=i.defaultStrokeDasharray,n.fillColor=i.defaultFillColor,n.setStrokeColor=n.setStrokeColor.bind(n),n.setFillColor=n.setFillColor.bind(n),n.setStrokeWidth=n.setStrokeWidth.bind(n),n.setStrokeDasharray=n.setStrokeDasharray.bind(n),n.setOpacity=n.setOpacity.bind(n),n.createVisual=n.createVisual.bind(n),n.strokePanel=new tt("Line color",z(i.defaultColorSet,["transparent"]),i.defaultColor),n.strokePanel.onColorChanged=n.setStrokeColor,n.fillPanel=new tt("Fill color",z(i.defaultColorSet,["transparent"]),n.fillColor,St),n.fillPanel.onColorChanged=n.setFillColor,n.strokeWidthPanel=new at("Line width",i.defaultStrokeWidths,i.defaultStrokeWidth),n.strokeWidthPanel.onWidthChanged=n.setStrokeWidth,n.strokeStylePanel=new lt("Line style",i.defaultStrokeDasharrays,i.defaultStrokeDasharray),n.strokeStylePanel.onStyleChanged=n.setStrokeDasharray,n.opacityPanel=new bt("Opacity",i.defaultOpacitySteps,n.opacity),n.opacityPanel.onOpacityChanged=n.setOpacity,n}return U(e,t),e.prototype.ownsTarget=function(e){return!(!t.prototype.ownsTarget.call(this,e)&&e!==this.visual)},e.prototype.createVisual=function(){this.visual=W.createEllipse(this.width/2,this.height/2,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},e.prototype.pointerDown=function(e,r){t.prototype.pointerDown.call(this,e,r),"new"===this.state&&(this.createVisual(),this.moveVisual(e),this._state="creating")},e.prototype.manipulate=function(e){t.prototype.manipulate.call(this,e)},e.prototype.resize=function(e){t.prototype.resize.call(this,e),this.setSize()},e.prototype.setSize=function(){t.prototype.setSize.call(this),W.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},e.prototype.pointerUp=function(e){t.prototype.pointerUp.call(this,e),this.setSize()},e.prototype.setStrokeColor=function(t){this.strokeColor=t,this.visual&&W.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(t),this.stateChanged()},e.prototype.setFillColor=function(t){this.fillColor=t,this.visual&&W.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(t),this.stateChanged()},e.prototype.setStrokeWidth=function(t){this.strokeWidth=t,this.visual&&W.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},e.prototype.setStrokeDasharray=function(t){this.strokeDasharray=t,this.visual&&W.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},e.prototype.setOpacity=function(t){this.opacity=t,this.visual&&W.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var r=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},t.prototype.getState.call(this));return r.typeName=e.typeName,r},e.prototype.restoreState=function(e){var r=e;this.fillColor=r.fillColor,this.strokeColor=r.strokeColor,this.strokeWidth=r.strokeWidth,this.strokeDasharray=r.strokeDasharray,this.opacity=r.opacity,this.createVisual(),t.prototype.restoreState.call(this,e),this.setSize()},e.prototype.scale=function(e,r){t.prototype.scale.call(this,e,r),this.setSize()},e.typeName="EllipseMarker",e.title="Ellipse marker",e.icon='<svg viewBox="0 0 24 24"><path d="M12 4C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',e}(ot),kt=function(t){function e(e,r,i){return t.call(this,e,r,i)||this}return U(e,t),Object.defineProperty(e.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),e.prototype.ownsTarget=function(e){return!(!t.prototype.ownsTarget.call(this,e)&&e!==this.tip1&&e!==this.tip2)},e.prototype.createTips=function(){this.tip1=W.createLine(this.x1-this.tipLength/2,this.y1,this.x1+this.tipLength/2,this.y1,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip1.transform.baseVal.appendItem(W.createTransform()),this.visual.appendChild(this.tip1),this.tip2=W.createLine(this.x2-this.tipLength/2,this.y2,this.x2+this.tipLength/2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip2.transform.baseVal.appendItem(W.createTransform()),this.visual.appendChild(this.tip2)},e.prototype.pointerDown=function(e,r){t.prototype.pointerDown.call(this,e,r),"creating"===this.state&&this.createTips()},e.prototype.adjustVisual=function(){if(t.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(W.setAttributes(this.tip1,[["x1",(this.x1-this.tipLength/2).toString()],["y1",this.y1.toString()],["x2",(this.x1+this.tipLength/2).toString()],["y2",this.y1.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),W.setAttributes(this.tip2,[["x1",(this.x2-this.tipLength/2).toString()],["y1",this.y2.toString()],["x2",(this.x2+this.tipLength/2).toString()],["y2",this.y2.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),Math.abs(this.x1-this.x2)>.1)){var e=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),r=this.tip1.transform.baseVal.getItem(0);r.setRotate(e,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(r,0);var i=this.tip2.transform.baseVal.getItem(0);i.setRotate(e+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(i,0)}},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var r=t.prototype.getState.call(this);return r.typeName=e.typeName,r},e.prototype.restoreState=function(e){t.prototype.restoreState.call(this,e),this.createTips(),this.adjustVisual()},e.typeName="MeasurementMarker",e.title="Measurement marker",e.icon='<svg viewBox="0 0 24 24"><path d="M1.39 18.36l1.77-1.76L4.58 18l1.06-1.05-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.42 1.41L10.59 12l-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.41 1.41 1.07-1.06-1.42-1.41 1.42-1.42L18 6.7l1.07-1.06-2.47-2.48 1.76-1.77 4.25 4.25L5.64 22.61l-4.25-4.25z"/></svg>',e}(dt),Et=function(t){function e(e,r,i){var n=t.call(this,e,r,i)||this;return n.strokePanel.colors=i.defaultColorSet,n.fillColor="transparent",n}return U(e,t),Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var r=t.prototype.getState.call(this);return r.typeName=e.typeName,r},e.typeName="EllipseFrameMarker",e.title="Ellipse frame marker",e.icon='<svg viewBox="0 0 24 24"><path d="M12 6c4.41 0 8 2.69 8 6s-3.59 6-8 6-8-2.69-8-6 3.59-6 8-6m0-2C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',e}(wt),Tt=function(){function t(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(t.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),t.prototype.addUndoStep=function(t){0!==this.undoStack.length&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(t)||(this.undoStack.push(t),JSON.stringify(this.lastRedoStep)!==JSON.stringify(t)&&this.redoStack.splice(0,this.redoStack.length))},t.prototype.replaceLastUndoStep=function(t){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=t)},t.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},t.prototype.undo=function(){if(this.undoStack.length>1){var t=this.undoStack.pop();return void 0!==t&&this.redoStack.push(t),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},t.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},t}(),Lt=function(t){function e(e,r,i){var n=t.call(this,e,r,i)||this;return n.strokeColor="transparent",n.strokeWidth=0,n.strokeDasharray="",n.curveX=0,n.curveY=0,n.manipulationStartCurveX=0,n.manipulationStartCurveY=0,n.setStrokeColor=n.setStrokeColor.bind(n),n.setStrokeWidth=n.setStrokeWidth.bind(n),n.setStrokeDasharray=n.setStrokeDasharray.bind(n),n.positionGrips=n.positionGrips.bind(n),n.addControlGrips=n.addControlGrips.bind(n),n.adjustVisual=n.adjustVisual.bind(n),n.setupControlBox=n.setupControlBox.bind(n),n.resize=n.resize.bind(n),n.strokeColor=i.defaultColor,n.strokeWidth=i.defaultStrokeWidth,n.strokeDasharray=i.defaultStrokeDasharray,n.strokePanel=new tt("Line color",i.defaultColorSet,i.defaultColor),n.strokePanel.onColorChanged=n.setStrokeColor,n.strokeWidthPanel=new at("Line width",i.defaultStrokeWidths,i.defaultStrokeWidth),n.strokeWidthPanel.onWidthChanged=n.setStrokeWidth,n.strokeStylePanel=new lt("Line style",i.defaultStrokeDasharrays,i.defaultStrokeDasharray),n.strokeStylePanel.onStyleChanged=n.setStrokeDasharray,n}return U(e,t),e.prototype.ownsTarget=function(e){return!(!t.prototype.ownsTarget.call(this,e)&&e!==this.visual&&e!==this.selectorCurve&&e!==this.visibleCurve&&!this.curveGrip.ownsTarget(e))},e.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},e.prototype.createVisual=function(){this.visual=W.createGroup(),this.selectorCurve=W.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=W.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)},e.prototype.pointerDown=function(e,r){t.prototype.pointerDown.call(this,e,r),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,"new"===this.state&&(this.curveX=e.x,this.curveY=e.y),"new"===this.state?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(r)&&(this.activeGrip=this.curveGrip,this._state="resize")},e.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),W.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),W.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),W.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},e.prototype.setupControlBox=function(){t.prototype.setupControlBox.call(this),this.curveControlLine1=W.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=W.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)},e.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,t.prototype.addControlGrips.call(this)},e.prototype.positionGrips=function(){t.prototype.positionGrips.call(this);var e=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-e/2,this.curveY-e/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()))},e.prototype.manipulate=function(e){"move"===this.state&&(this.curveX=this.manipulationStartCurveX+e.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+e.y-this.manipulationStartY),t.prototype.manipulate.call(this,e)},e.prototype.resize=function(e){this.activeGrip===this.curveGrip&&(this.curveX=e.x,this.curveY=e.y),t.prototype.resize.call(this,e),"creating"===this.state&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},e.prototype.setStrokeColor=function(t){this.strokeColor=t,this.adjustVisual(),this.colorChanged(t)},e.prototype.setStrokeWidth=function(t){this.strokeWidth=t,this.adjustVisual()},e.prototype.setStrokeDasharray=function(t){this.strokeDasharray=t,this.adjustVisual()},e.prototype.scale=function(e,r){this.curveX=this.curveX*e,this.curveY=this.curveY*r,t.prototype.scale.call(this,e,r)},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var r=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},t.prototype.getState.call(this));return r.typeName=e.typeName,r},e.prototype.restoreState=function(e){t.prototype.restoreState.call(this,e);var r=e;this.strokeColor=r.strokeColor,this.strokeWidth=r.strokeWidth,this.strokeDasharray=r.strokeDasharray,this.curveX=r.curveX,this.curveY=r.curveY,this.createVisual(),this.adjustVisual()},e.typeName="CurveMarker",e.title="Curve marker",e.icon='<svg viewBox="0 0 24 24"><path d="M18.5 2A1.5 1.5 0 0120 3.5 1.5 1.5 0 0118.5 5c-.23 0-.45-.05-.65-.15l-3.69 3.7.34.45c2.19-1.26 4.76-2 7.5-2l1 .03v2.01L22 9c-2.58 0-5 .75-7 2.04A3.96 3.96 0 0111.04 15C9.75 17 9 19.42 9 22l.04 1H7.03L7 22c0-2.74.74-5.31 2-7.5l-.45-.34-3.7 3.69c.1.2.15.42.15.65A1.5 1.5 0 013.5 20 1.5 1.5 0 012 18.5 1.5 1.5 0 013.5 17c.23 0 .45.05.65.15l3.69-3.7C7.31 12.78 7 11.92 7 11a4 4 0 014-4c.92 0 1.78.31 2.45.84l3.7-3.69c-.1-.2-.15-.42-.15-.65A1.5 1.5 0 0118.5 2M11 9a2 2 0 00-2 2 2 2 0 002 2 2 2 0 002-2 2 2 0 00-2-2z"/></svg>',e}(ht),At=function(){function t(t,e){void 0===e&&(e=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=t,this.cancelable=e}return Object.defineProperty(t.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),t.prototype.preventDefault=function(){this._defaultPrevented=!0},t}(),Dt=function(t){function e(e,r,i){var n=t.call(this,e,!1)||this;return n.dataUrl=r,n.state=i,n}return U(e,t),e}(At),Ot=function(t){function e(e,r,i){void 0===i&&(i=!1);var n=t.call(this,e,i)||this;return n.marker=r,n}return U(e,t),e}(At),Rt=function(){function t(){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 t.prototype.addEventListener=function(t,e){this[t].push(e)},t.prototype.removeEventListener=function(t,e){var r=this[t].indexOf(e);r>-1&&this[t].splice(r,1)},t}(),_t=function(){function t(e){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new ut,this._isOpen=!1,this.undoRedoManager=new Tt,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 Rt,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=t.instanceCounter++,this.styles=new Y(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=e,this.targetRoot=document.body,this.width=e.clientWidth,this.height=e.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(t.prototype,"ALL_MARKER_TYPES",{get:function(){return[ct,gt,vt,pt,Et,wt,xt,Ct,kt,yt,dt,Lt]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[ct,gt,vt,pt,wt,xt,Ct]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"BASIC_MARKER_TYPES",{get:function(){return[ct,gt,vt,pt,xt]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(t){var e=this;this._availableMarkerTypes.splice(0),t.forEach((function(t){if("string"==typeof t){var r=e.ALL_MARKER_TYPES.find((function(e){return e.typeName===t}));void 0!==r&&e._availableMarkerTypes.push(r)}else e._availableMarkerTypes.push(t)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(t){this._zoomLevel=t,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(t.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),t.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),"popup"===this.settings.displayMode&&this.onPopupTargetResize(),V.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},t.prototype.show=function(){var t=this;void 0===this.styles.styleSheetRoot&&void 0!==q.styleSheetRoot&&(this.styles.styleSheetRoot=q.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach((function(e){return e(new At(t))}))},t.prototype.render=function(){return H(this,void 0,void 0,(function(){var t;return G(this,(function(e){switch(e.label){case 0:return this.setCurrentMarker(),(t=new K).naturalSize=this.renderAtNaturalSize,t.imageType=this.renderImageType,t.imageQuality=this.renderImageQuality,t.markersOnly=this.renderMarkersOnly,t.width=this.renderWidth,t.height=this.renderHeight,[4,t.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return e.sent(),[4,t.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,e.sent()]}}))}))},t.prototype.close=function(t){var e=this;if(void 0===t&&(t=!1),this.isOpen){var r=!1;t||this.eventListeners.beforeclose.forEach((function(t){var i=new At(e,!0);t(i),i.defaultPrevented&&(r=!0)})),r||(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),"popup"===this.settings.displayMode&&window.removeEventListener("resize",this.setWindowHeight),this.eventListeners.close.forEach((function(t){return t(new At(e))})),this.detachEvents(),this._isOpen=!1)}},t.prototype.addMarkersToToolbar=function(){for(var t,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];(t=this._availableMarkerTypes).push.apply(t,e)},t.prototype.addRenderEventListener=function(t){this.addEventListener("render",(function(e){t(e.dataUrl,e.state)}))},t.prototype.removeRenderEventListener=function(t){},t.prototype.addCloseEventListener=function(t){this.addEventListener("close",(function(){t()}))},t.prototype.removeCloseEventListener=function(t){},t.prototype.setupResizeObserver=function(){var t=this;"inline"===this.settings.displayMode?window.ResizeObserver&&(this.targetObserver=new ResizeObserver((function(){t.resize(t.target.clientWidth,t.target.clientHeight)})),this.targetObserver.observe(this.target)):"popup"===this.settings.displayMode&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver((function(){return t.onPopupTargetResize()})),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},t.prototype.onPopupTargetResize=function(){var t=1*this.target.clientWidth/this.target.clientHeight,e=this.editorCanvas.clientWidth/t>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*t:this.editorCanvas.clientWidth,r=e<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/t;this.resize(e,r)},t.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},t.prototype.resize=function(t,e){this._isResizing=!0;var r=t/this.imageWidth,i=e/this.imageHeight;this.imageWidth=Math.round(t),this.imageHeight=Math.round(e),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px",this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px","popup"!==this.settings.displayMode?this.coverDiv.style.width=this.imageWidth.toString()+"px":(this.setTopLeft(),this.positionMarkerImage()),void 0!==this.toolbar&&this.toolbar.adjustLayout(),this.positionLogo(),this.scaleMarkers(r,i),this._isResizing=!1},t.prototype.scaleMarkers=function(t,e){var r,i=this;this._currentMarker&&this._currentMarker instanceof pt?this._currentMarker.scale(t,e):(r=this._currentMarker,this.setCurrentMarker()),this.markers.forEach((function(r){r!==i._currentMarker&&r.scale(t,e)})),void 0!==r&&this.setCurrentMarker(r)},t.prototype.setEditingTarget=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px"},t.prototype.setTopLeft=function(){var t=this.editingTarget.getBoundingClientRect(),e=this.editorCanvas.getBoundingClientRect();this.left=t.left-e.left,this.top=t.top-e.top},t.prototype.initMarkerCanvas=function(){this.markerImageHolder=document.createElement("div"),this.markerImageHolder.style.setProperty("touch-action","pinch-zoom"),this.markerImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.markerImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImage.style.pointerEvents="auto",this.markerImageHolder.style.position="absolute",this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.markerImageHolder.style.transformOrigin="top left",this.positionMarkerImage(),this.markerImageHolder.appendChild(this.markerImage),this.editorCanvas.appendChild(this.markerImageHolder)},t.prototype.addDefs=function(){for(var t,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];this.defs=W.createDefs(),this.addDefsToImage(),(t=this.defs).append.apply(t,e)},t.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},t.prototype.initOverlay=function(){this.overlayContainer=document.createElement("div"),this.overlayContainer.style.position="absolute",this.overlayContainer.style.left="0px",this.overlayContainer.style.top="0px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.overlayContainer.style.display="flex",this.markerImageHolder.appendChild(this.overlayContainer)},t.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},t.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},t.prototype.attachWindowEvents=function(){window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp),window.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("pointerout",this.onPointerOut),window.addEventListener("pointerleave",this.onPointerUp),window.addEventListener("resize",this.onWindowResize),window.addEventListener("keyup",this.onKeyUp)},t.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},t.prototype.detachWindowEvents=function(){window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("pointerout",this.onPointerOut),window.removeEventListener("pointerleave",this.onPointerUp),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("keyup",this.onKeyUp)},t.prototype.addLogo=function(){this.logoUI=document.createElement("div"),this.logoUI.style.display="inline-block",this.logoUI.style.margin="0px",this.logoUI.style.padding="0px",this.logoUI.style.fill="#333333";var t=document.createElement("a");t.href="https://markerjs.com/",t.target="_blank",t.innerHTML='<svg viewBox="0 0 112 96" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path fill="#e5f20d" fill-opacity=".647" d="M0 40.386h111.96V95.62H0z"/><path d="M93.61 61.452c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.591 1.048-1.481 0-2.222-.74-2.222-2.22 0-16.617-.533-29.347-1.604-38.192-1.068-8.842-2.92-13.265-5.552-13.265-4.443 0-10.94 15.509-19.497 46.52v.124c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.592 1.048-1.48 0-2.22-.74-2.22-2.22 0-3.29.165-8.392.493-15.302.33-7.732.494-13.82.494-18.262 0-6.17-.186-10.55-.556-13.142-.37-2.591-1.172-3.887-2.406-3.887-2.796 0-6.333 5.12-10.612 15.363C38.494 34.367 34.01 46.44 29.32 60.34l-1.11 3.209a5.714 5.714 0 01-1.42 2.097c-.617.578-1.295.864-2.036.864-.987 0-1.644-.081-1.974-.247-.328-.162-.533-.656-.617-1.48-.41-4.03-.74-9.418-.987-16.165-.163-1.728-.329-4.566-.494-8.515-.822-13.901-1.562-23.3-2.221-28.196-.657-4.893-.987-7.628-.987-8.205 0-.657.33-1.44.987-2.345.659-.903 1.276-1.357 1.85-1.357 1.319 0 2.387.947 3.21 2.838.411.906.863 4.526 1.357 10.859.493 6.335.905 14.19 1.233 23.568l.617 18.88c4.527-13.983 9.216-26.673 14.068-38.068C45.65 6.686 50.093.988 54.123.988c2.715 0 4.566 1.974 5.553 5.923.987 3.949 1.481 9.667 1.481 17.152 0 3.949-.081 9.625-.247 17.029l-.123 5.676c3.373-11.762 6.725-21.634 10.057-29.615 3.331-7.979 6.685-11.97 10.056-11.97 8.475 0 12.71 18.757 12.71 56.269z" fill-rule="nonzero"/></svg>',t.title="Powered by marker.js",t.style.display="grid",t.style.alignItems="center",t.style.justifyItems="center",t.style.padding="3px",t.style.width="20px",t.style.height="20px",this.logoUI.appendChild(t),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},t.prototype.positionLogo=function(){this.logoUI&&("right"!==this.uiStyleSettings.logoPosition?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")},t.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"},t.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},t.prototype.showUI=function(){switch("popup"===this.settings.displayMode&&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 t=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=t+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px",this.coverDiv.style.width=this.target.offsetWidth.toString()+"px",this.coverDiv.style.zIndex=void 0!==this.uiStyleSettings.zIndex?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=void 0!==this.uiStyleSettings.zIndex?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="popup"===this.settings.displayMode?this.settings.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.toolbar=new Z(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","popup"===this.settings.displayMode&&(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","popup"===this.settings.displayMode&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.editorCanvas.style.transformOrigin="left top",this.editorCanvas.style.transform="scale("+this.zoomLevel+")",this.contentDiv.appendChild(this.editorCanvas),this.editingTarget=this.target instanceof HTMLImageElement?document.createElement("img"):document.createElement("canvas"),this.target.getClientRects().item(0).y<this.styles.settings.toolbarHeight&&(this.editingTarget.style.marginTop=this.target.offsetTop-this.styles.settings.toolbarHeight+"px"),this.editorCanvas.appendChild(this.editingTarget),this.toolbox=new Q(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},t.prototype.closeUI=function(){"popup"===this.settings.displayMode&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},t.prototype.removeMarker=function(t){this.markerImage.removeChild(t.container),this.markers.indexOf(t)>-1&&this.markers.splice(this.markers.indexOf(t),1),t.dispose()},t.prototype.switchToSelectMode=function(){this.mode="select",this.hideNotesEditor(),void 0!==this._currentMarker&&("new"!==this._currentMarker.state?this._currentMarker.select():(this.removeMarker(this._currentMarker),this.setCurrentMarker(),this.markerImage.style.cursor="default"),this.addUndoStep())},t.prototype.toolbarButtonClicked=function(t,e){if("marker"===t&&void 0!==e)this.createNewMarker(e);else if("action"===t)switch(e){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":void 0===this.notesArea?(this.switchToSelectMode(),this.zoomLevel=1,this.showNotesEditor()):this.switchToSelectMode();break;case"close":this.close();break;case"render":this.switchToSelectMode(),this.startRenderAndClose()}},t.prototype.deleteSelectedMarker=function(){var t=this;if(void 0!==this._currentMarker){var e=!1;if(this.eventListeners.markerbeforedelete.forEach((function(r){var i=new Ot(t,t._currentMarker,!0);r(i),i.defaultPrevented&&(e=!0)})),!e){var r=this._currentMarker;this._currentMarker.dispose(),this.markerImage.removeChild(this._currentMarker.container),this.markers.splice(this.markers.indexOf(this._currentMarker),1),this.setCurrentMarker(),this.addUndoStep(),this.eventListeners.markerdelete.forEach((function(e){return e(new Ot(t,r))}))}}},t.prototype.clear=function(){var t=this,e=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach((function(r){var i=new Ot(t,void 0,!0);r(i),i.defaultPrevented&&(e=!0)})),!e)){this.setCurrentMarker();for(var r=function(e){var r=i.markers[e];i.setCurrentMarker(i.markers[e]),i._currentMarker.dispose(),i.markerImage.removeChild(i._currentMarker.container),i.markers.splice(i.markers.indexOf(i._currentMarker),1),i.eventListeners.markerdelete.forEach((function(e){return e(new Ot(t,r))}))},i=this,n=this.markers.length-1;n>=0;n--)r(n);this.addUndoStep()}},Object.defineProperty(t.prototype,"isNotesAreaOpen",{get:function(){return void 0!==this.notesArea},enumerable:!1,configurable:!0}),t.prototype.showNotesEditor=function(){var t;void 0!==this._currentMarker&&(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=null!==(t=this._currentMarker.notes)&&void 0!==t?t:"",this.overlayContainer.appendChild(this.notesArea))},t.prototype.hideNotesEditor=function(){this.isNotesAreaOpen&&(void 0!==this._currentMarker&&(this._currentMarker.notes=""!==this.notesArea.value.trim()?this.notesArea.value:void 0),this.overlayContainer.removeChild(this.notesArea),this.notesArea=void 0)},t.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},t.prototype.addUndoStep=function(){var t=this;if(void 0===this._currentMarker||"edit"!==this._currentMarker.state){var e=this.getState(),r=this.undoRedoManager.getLastUndoStep();if(!r||r.width===e.width&&r.height===e.height){var i=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(e),i<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach((function(e){return e(new At(t))}))}else this.undoRedoManager.replaceLastUndoStep(e),this.eventListeners.statechange.forEach((function(e){return e(new At(t))}))}},t.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},t.prototype.undoStep=function(){var t=this,e=this.undoRedoManager.undo();void 0!==e&&(this.restoreState(e),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach((function(e){return e(new At(t))})))},t.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},t.prototype.redoStep=function(){var t=this,e=this.undoRedoManager.redo();void 0!==e&&(this.restoreState(e),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach((function(e){return e(new At(t))})))},t.prototype.stepZoom=function(){var t=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=t<this.zoomSteps.length-1?this.zoomSteps[t+1]:this.zoomSteps[0]},t.prototype.panTo=function(t){this.contentDiv.scrollBy({left:this.prevPanPoint.x-t.x,top:this.prevPanPoint.y-t.y}),this.prevPanPoint=t},t.prototype.startRenderAndClose=function(){return H(this,void 0,void 0,(function(){var t,e,r=this;return G(this,(function(i){switch(i.label){case 0:return[4,this.render()];case 1:return t=i.sent(),e=this.getState(),this.eventListeners.render.forEach((function(i){return i(new Dt(r,t,e))})),this.close(!0),[2]}}))}))},t.prototype.getState=function(t){!0===t&&this.setCurrentMarker();var e={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach((function(t){return e.markers.push(t.getState())})),e},t.prototype.restoreState=function(t){var e=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);t.markers.forEach((function(t){var r=e._availableMarkerTypes.find((function(e){return e.typeName===t.typeName}));if(void 0!==r){var i=e.addNewMarker(r);i.restoreState(t),e.markers.push(i)}})),t.width&&t.height&&(t.width!==this.imageWidth||t.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/t.width,this.imageHeight/t.height),this.eventListeners.restorestate.forEach((function(t){return t(new At(e))}))},t.prototype.addNewMarker=function(t){var e=W.createGroup();return this.markerImage.appendChild(e),new t(e,this.overlayContainer,this.settings)},t.prototype.createNewMarker=function(t){var e,r=this;(e="string"==typeof t?this._availableMarkerTypes.find((function(e){return e.typeName===t})):t)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(e),this._currentMarker.onMarkerCreated=this.markerCreated,this._currentMarker.onColorChanged=this.colorChanged,this._currentMarker.onFillColorChanged=this.fillColorChanged,this._currentMarker.onStateChanged=this.markerStateChanged,this.markerImage.style.cursor="crosshair",this.toolbar.setActiveMarkerButton(e.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach((function(t){return t(new Ot(r,r._currentMarker))})))},t.prototype.markerCreated=function(t){var e=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(t),this.setCurrentMarker(t),t instanceof gt&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(gt):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach((function(t){return t(new Ot(e,e._currentMarker))}))},t.prototype.colorChanged=function(t){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=t,this.settings.defaultStrokeColor=t)},t.prototype.fillColorChanged=function(t){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=t)},t.prototype.markerStateChanged=function(t){var e=this;this.eventListeners.markerchange.forEach((function(r){return r(new Ot(e,t))}))},t.prototype.setCurrentMarker=function(t){var e=this;this._currentMarker!==t&&void 0!==this._currentMarker&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach((function(t){return t(new Ot(e,e._currentMarker))}))),this._currentMarker=t,void 0===this._currentMarker||this._currentMarker.isSelected||("new"!==this._currentMarker.state&&this._currentMarker.select(),this.toolbar.setCurrentMarker(this._currentMarker),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this._isResizing||this.eventListeners.markerselect.forEach((function(t){return t(new Ot(e,e._currentMarker))})))},t.prototype.onPointerDown=function(t){if(this._isFocused||this.focus(),this.touchPoints++,1===this.touchPoints||"touch"!==t.pointerType)if(void 0===this._currentMarker||"new"!==this._currentMarker.state&&"creating"!==this._currentMarker.state){if("select"===this.mode){var e=this.markers.find((function(e){return e.ownsTarget(t.target)}));void 0!==e?(this.setCurrentMarker(e),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(t.clientX,t.clientY),t.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:t.clientX,y:t.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(t.clientX,t.clientY))},t.prototype.onDblClick=function(t){if(this._isFocused||this.focus(),"select"===this.mode){var e=this.markers.find((function(e){return e.ownsTarget(t.target)}));void 0!==e&&e!==this._currentMarker&&this.setCurrentMarker(e),void 0!==this._currentMarker?this._currentMarker.dblClick(this.clientToLocalCoordinates(t.clientX,t.clientY),t.target):this.setCurrentMarker()}},t.prototype.onPointerMove=function(t){1!==this.touchPoints&&"touch"===t.pointerType||(void 0!==this._currentMarker||this.isDragging)&&(void 0!==this._currentMarker&&"edit"===this._currentMarker.state||t.preventDefault(),void 0!==this._currentMarker?this._currentMarker.manipulate(this.clientToLocalCoordinates(t.clientX,t.clientY)):this.zoomLevel>1&&this.panTo({x:t.clientX,y:t.clientY}))},t.prototype.onPointerUp=function(t){this.touchPoints>0&&this.touchPoints--,0===this.touchPoints&&this.isDragging&&void 0!==this._currentMarker&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(t.clientX,t.clientY)),this.isDragging=!1,this.addUndoStep()},t.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},t.prototype.onKeyUp=function(t){void 0===this._currentMarker||void 0!==this.notesArea||"Delete"!==t.key&&"Backspace"!==t.key||this.deleteSelectedMarker()},t.prototype.clientToLocalCoordinates=function(t,e){var r=this.markerImage.getBoundingClientRect();return{x:(t-r.left)/this.zoomLevel,y:(e-r.top)/this.zoomLevel}},t.prototype.onWindowResize=function(){this.positionUI()},t.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var t=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=t+"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()},t.prototype.addLicenseKey=function(t){V.addKey(t)},t.prototype.addEventListener=function(t,e){this.eventListeners.addEventListener(t,e)},t.prototype.removeEventListener=function(t,e){this.eventListeners.removeEventListener(t,e)},t.prototype.renderState=function(t){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(t),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(t.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),t.prototype.focus=function(){var t=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,void 0!==this._previousCurrentMarker&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach((function(e){return e(new At(t))})))},t.prototype.blur=function(){var t=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach((function(e){return e(new At(t))})))},t.instanceCounter=0,t}(),It=function(t,e){return(It=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};
|
|
|
/* **********************************
|
|
|
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.
|
|
|
***************************************************************************** */function Mt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}It(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function Pt(t,e,r,i){return new(r||(r=Promise))((function(n,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))}function Nt(t,e){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}var Ft=function(){function t(){}return t.addKey=function(e){t.key=e},Object.defineProperty(t,"isLicensed",{get:function(){return!!t.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(t.key)},enumerable:!1,configurable:!0}),t}(),Bt=function(){function t(){}return t.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},t.setAttributes=function(t,e){for(var r=0,i=e;r<i.length;r++){var n=i[r],o=n[0],s=n[1];t.setAttribute(o,s)}},t.createRect=function(e,r,i){var n=document.createElementNS("http://www.w3.org/2000/svg","rect");return n.setAttribute("width",e.toString()),n.setAttribute("height",r.toString()),i&&t.setAttributes(n,i),n},t.createLine=function(e,r,i,n,o){var s=document.createElementNS("http://www.w3.org/2000/svg","line");return s.setAttribute("x1",e.toString()),s.setAttribute("y1",r.toString()),s.setAttribute("x2",i.toString()),s.setAttribute("y2",n.toString()),o&&t.setAttributes(s,o),s},t.createPolygon=function(e,r){var i=document.createElementNS("http://www.w3.org/2000/svg","polygon");return i.setAttribute("points",e),r&&t.setAttributes(i,r),i},t.createCircle=function(e,r){var i=document.createElementNS("http://www.w3.org/2000/svg","circle");return i.setAttribute("cx",(e/2).toString()),i.setAttribute("cy",(e/2).toString()),i.setAttribute("r",e.toString()),r&&t.setAttributes(i,r),i},t.createEllipse=function(e,r,i){var n=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return n.setAttribute("cx",(e/2).toString()),n.setAttribute("cy",(r/2).toString()),n.setAttribute("rx",(e/2).toString()),n.setAttribute("ry",(r/2).toString()),i&&t.setAttributes(n,i),n},t.createGroup=function(e){var r=document.createElementNS("http://www.w3.org/2000/svg","g");return e&&t.setAttributes(r,e),r},t.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},t.createMarker=function(e,r,i,n,o,s,a){var l=document.createElementNS("http://www.w3.org/2000/svg","marker");return t.setAttributes(l,[["id",e],["orient",r],["markerWidth",i.toString()],["markerHeight",n.toString()],["refX",o.toString()],["refY",s.toString()]]),l.appendChild(a),l},t.createText=function(e){var r=document.createElementNS("http://www.w3.org/2000/svg","text");return r.setAttribute("x","0"),r.setAttribute("y","0"),e&&t.setAttributes(r,e),r},t.createTSpan=function(e,r){var i=document.createElementNS("http://www.w3.org/2000/svg","tspan");return i.textContent=e,r&&t.setAttributes(i,r),i},t.createImage=function(e){var r=document.createElementNS("http://www.w3.org/2000/svg","image");return e&&t.setAttributes(r,e),r},t.createPoint=function(t,e){var r=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return r.x=t,r.y=e,r},t.createPath=function(e,r){var i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("d",e),r&&t.setAttributes(i,r),i},t.createElement=function(e,r){var i=document.createElementNS("http://www.w3.org/2000/svg",e);return r&&t.setAttributes(i,r),i},t.getHollowRectanglePath=function(t,e,r,i,n,o,s,a){return"M"+t+","+e+"V"+(e+i)+"H"+(t+r)+"V"+e+"H"+n+"V"+o+"H"+(n+s)+"V"+(o+a)+"H"+n+"V"+e+"Z"},t}(),jt=function(){function t(t){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+t+"_"}return Object.defineProperty(t.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#333333",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarBackgroundActiveColor:"#282828",toolbarColor:"#eeeeee",cropShadeColor:"#ffffff",cropFrameColor:"#ffffff",gripColor:"#333333",gripFillColor:"#cccccc",toolbarHeight:40}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),t.prototype.addClass=function(t){return void 0===this.styleSheet&&this.addStyleSheet(),t.name=""+this.classNamePrefix+t.localName,this.classes.push(t),this.styleSheet.sheet.insertRule("."+t.name+" {"+t.style+"}",this.styleSheet.sheet.cssRules.length),t},t.prototype.addRule=function(t){void 0===this.styleSheet&&this.addStyleSheet(),this.rules.push(t),this.styleSheet.sheet.insertRule(t.selector+" {"+t.style+"}",this.styleSheet.sheet.cssRules.length)},t.prototype.addStyleSheet=function(){var t;this.styleSheet=document.createElement("style"),(null!==(t=this.styleSheetRoot)&&void 0!==t?t:document.head).appendChild(this.styleSheet),this.addRule(new Ut("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new Ut("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames","\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n ")),this.addRule(new Ut("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames","\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n ")),this.addClass(new Ht("_fade_in","\n animation-duration: 0.3s;\n animation-name: "+this.classNamePrefix+"_fade_in_animation_frames;\n ")),this.addClass(new Ht("_fade_out","\n animation-duration: 0.3s;\n animation-name: "+this.classNamePrefix+"_fade_out_animation_frames;\n "))},t.prototype.removeStyleSheet=function(){var t;this.styleSheet&&((null!==(t=this.styleSheetRoot)&&void 0!==t?t:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},t}(),Ut=function(t,e){this.selector=t,this.style=e},Ht=function(t,e){this.localName=t,this.style=e},Gt=function(){function t(){this.blocks=[],this.display=""}return t.prototype.addButtonBlock=function(t){t.className=this.blockClassName,t.buttonClassName=this.buttonClassName,t.buttonColorsClassName=this.buttonColorsClassName,t.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(t)},t.prototype.addElementBlock=function(t){void 0===t.className&&(t.className=this.blockClassName),this.blocks.push(t)},t.prototype.getUI=function(){var t=document.createElement("div");return t.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,t.style.display=this.display,this.blocks.forEach((function(e){return t.appendChild(e.getUI())})),t},t}(),zt=function(){function t(){}return t.prototype.getUI=function(){var t=document.createElement("div");if(t.className=this.className,void 0!==this.minWidth&&(t.style.minWidth=this.minWidth),void 0!==this.contentAlign)switch(this.contentAlign){case"start":t.style.justifyContent="flex-start";break;case"center":t.style.justifyContent="center";break;case"end":t.style.justifyContent="flex-end"}return t.style.whiteSpace="nowrap",t},t}(),Wt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.buttons=[],e}return Mt(e,t),e.prototype.addButton=function(t){t.className=this.buttonClassName,t.colorsClassName=this.buttonColorsClassName,t.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(t)},e.prototype.getUI=function(){var e=t.prototype.getUI.call(this);return this.buttons.forEach((function(t){return e.appendChild(t.getUI())})),e},e}(zt),Vt=function(){function t(t,e){this._isActive=!1,this._isHidden=!1,this._icon=t,this.title=e,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(t.prototype,"icon",{get:function(){return this._icon},set:function(t){this._icon=t,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isActive",{get:function(){return this._isActive},set:function(t){this._isActive=t,this.adjustClassName()},enumerable:!1,configurable:!0}),t.prototype.getUI=function(){var t=this;return this.buttonContainer=document.createElement("div"),this.buttonContainer.title=this.title,this.buttonContainer.className=this.className+" "+this.colorsClassName,this.adjustClassName(),this.buttonContainer.innerHTML=this._icon,this.onClick&&this.buttonContainer.addEventListener("click",(function(){return t.onClick()})),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},t.prototype.adjustClassName=function(){this.activeColorsClassName&&(this._isActive&&this.buttonContainer.className.indexOf(this.activeColorsClassName)<0?this.buttonContainer.className+=" "+this.activeColorsClassName:this._isActive||(this.buttonContainer.className=this.buttonContainer.className.replace(this.activeColorsClassName,"")))},t.prototype.hide=function(){this._isHidden=!0},t}(),Kt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.elements=[],e}return Mt(e,t),e.prototype.addElement=function(t){this.elements.push(t)},e.prototype.getUI=function(){var e=t.prototype.getUI.call(this);return this.elements.forEach((function(t){return e.appendChild(t)})),e},e}(zt),qt=function(){function t(t,e){this.horizontal=t,this.vertical=e}return Object.defineProperty(t.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),t.prototype.getVerticalLength=function(t){return t/this.ratio},t.prototype.getHorizontalLength=function(t){return t*this.ratio},t}(),Yt=function(){function t(){}return t.getIcon=function(t,e){if(t>0&&e>0){var r=new qt(t,e),i=r.ratio>=1?20:r.getHorizontalLength(20),n=r.ratio<1?20:r.getVerticalLength(20),o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("xmlns","http://www.w3.org/2000/svg"),o.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(o);var s=Bt.createDefs();o.appendChild(s);var a=Bt.createElement("clipPath",[["id","text-bg-clip"]]);s.appendChild(a);var l=Bt.createPath(Bt.getHollowRectanglePath((24-i)/2,(24-n)/2,i,n,(24-i)/2+2,(24-n)/2+2,i-4,n-4));o.appendChild(l);var c=Bt.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);c.appendChild(Bt.createTSpan(t+":"+e)),o.appendChild(c);var u=c.getBBox();Bt.setAttributes(c,[["x",((24-u.width)/2).toString()],["y",((24-u.height)/2-u.y).toString()]]);var h=Bt.createPath(Bt.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(u.width))/2,(24-Math.ceil(u.height))/2,Math.ceil(u.width),Math.ceil(u.height)));return a.appendChild(h),Bt.setAttributes(l,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(o),o.outerHTML}return'<svg viewBox="0 0 24 24"><path d="M19 12h-2v3h-3v2h5v-5M7 9h3V7H5v5h2V9m14-6H3a2 2 0 00-2 2v14a2 2 0 002 2h18a2 2 0 002-2V5a2 2 0 00-2-2m0 16H3V5h18v14z"/></svg>'},t}(),Xt=function(t){function e(e,r,i){var n=t.call(this,e,r)||this;return n.isDropdownOpen=!1,n.onClick=n.dropdownButtonClicked,n.dropdownButtons=i,n}return Mt(e,t),e.prototype.setupDropdown=function(){var t=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach((function(e){e.className=t.className,e.colorsClassName=t.colorsClassName,t.dropdownBlock.appendChild(e.getUI())})),this.uiContainer.appendChild(this.dropdownBlock)},e.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},e.prototype.dropdownButtonClicked=function(){void 0===this.dropdownBlock&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},e.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},e.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},e.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},e}(Vt),$t=function(){function t(t,e){this.GRIP_SIZE=10,this.color=t,this.fillColor=e,this.visual=Bt.createGroup(),this.visual.appendChild(Bt.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(Bt.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return t.prototype.ownsTarget=function(t){return t===this.visual||t===this.visual.childNodes[0]||t===this.visual.childNodes[1]},t.prototype.setCenter=function(t,e){this.visual.childNodes.forEach((function(r){return Bt.setAttributes(r,[["cx",t.toString()],["cy",e.toString()]])}))},t}(),Zt=function(){function t(t,e,r,i){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=t,this.canvasHeight=e,this.margin=r,this.container=i,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(t.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(t){this._aspectRatio=t,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(t){this._isGridVisible=t,this.gridContainer&&Bt.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(t){this._zoomFactor=t,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),t.prototype.open=function(){var t=this;this.cropShadeElement=Bt.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=Bt.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var e=0;e<this.numberOfGridLines;e++)this.horizontalGridLines.push(Bt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(Bt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach((function(e){return t.gridContainer.appendChild(e)})),this.verticalGridLines.forEach((function(e){return t.gridContainer.appendChild(e)})),this.cropRectElement=Bt.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new $t(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new $t(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new $t(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new $t(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},t.prototype.setCropRectangle=function(t){this.cropRect=t;var e=Object.assign({},this.cropRect);1!==this.zoomFactor&&(e.width=this.cropRect.width*this.zoomFactor,e.height=this.cropRect.height*this.zoomFactor,e.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-e.width/2,e.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-e.height/2),Bt.setAttributes(this.cropRectElement,[["x",e.x.toString()],["y",e.y.toString()],["width",e.width.toString()],["height",e.height.toString()]]);var r=e.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach((function(t,i){var n=e.y+r*(i+1);Bt.setAttributes(t,[["x1",""+e.x],["y1",""+n],["x2",""+(e.x+e.width)],["y2",""+n]])}));var i=e.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach((function(t,r){var n=e.x+i*(r+1);Bt.setAttributes(t,[["x1",""+n],["y1",""+e.y],["x2",""+n],["y2",""+(e.y+e.height)]])})),Bt.setAttributes(this.cropShadeElement,[["d",Bt.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,e.x,e.y,e.width,e.height)]]),this.topLeftGrip.setCenter(e.x,e.y),this.topRightGrip.setCenter(e.x+e.width,e.y),this.bottomLeftGrip.setCenter(e.x,e.y+e.height),this.bottomRightGrip.setCenter(e.x+e.width,e.y+e.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},t.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)},t.prototype.clientToLocalCoordinates=function(t,e){var r=this.container.getBoundingClientRect();return{x:t-r.left+this.margin,y:e-r.top+this.margin}},t.prototype.onPointerDown=function(t){this.container.setPointerCapture(t.pointerId),this.previousPoint=this.clientToLocalCoordinates(t.clientX,t.clientY),this.cropRectElement===t.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(t.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(t.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(t.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(t.target)&&(this.activeGrip=this.bottomRightGrip)},t.prototype.onPointerMove=function(t){if(this.isMoving)this.move(this.clientToLocalCoordinates(t.clientX,t.clientY));else if(this.activeGrip){var e=this.clientToLocalCoordinates(t.clientX,t.clientY);this.resize(e)}t.preventDefault()},t.prototype.onPointerUp=function(t){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(t.pointerId)},t.prototype.move=function(t){var e=t.x-this.previousPoint.x,r=t.y-this.previousPoint.y;1!==this.zoomFactor&&(e=-e/this.zoomFactor,r=-r/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+e),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+r),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=t},t.prototype.resize=function(t){var e=Object.assign({},this.cropRect),r=t.x-this.previousPoint.x,i=t.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:e.x+r<this.margin&&(r=this.margin-e.x),e.x+=r,e.width=this.cropRect.x+this.cropRect.width-e.x;break;case this.bottomRightGrip:case this.topRightGrip:e.width+r>this.canvasWidth*this.zoomFactor&&(r=this.canvasWidth*this.zoomFactor-e.width),e.width+=r}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(e.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(r),e.height=this.aspectRatio.getVerticalLength(e.width)):(e.y+=i,e.height=this.cropRect.y+this.cropRect.height-e.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?e.height=this.aspectRatio.getVerticalLength(e.width):e.height+=i}e.width<10&&(e.x=this.cropRect.x,e.width=10),e.height<10&&(e.y=this.cropRect.y,e.height=10),this.previousPoint=t,e.x>=this.margin&&e.y>=this.margin&&e.x-this.margin+e.width<=this.canvasWidth&&e.y-this.margin+e.height<=this.canvasHeight&&(this.cropRect=e,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},t.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var t=this.cropRect.x+this.cropRect.width/2,e=this.cropRect.y+this.cropRect.height/2,r=this.aspectRatio.getHorizontalLength(this.cropRect.height),i=this.aspectRatio.getVerticalLength(this.cropRect.width);r/this.canvasWidth<i/this.canvasHeight?this.cropRect.width=r:this.cropRect.height=i,this.cropRect.width>this.canvasWidth&&(this.cropRect.height/=this.cropRect.width/this.canvasWidth,this.cropRect.width=this.canvasWidth),this.cropRect.height>this.canvasHeight&&(this.cropRect.width/=this.cropRect.height/this.canvasHeight,this.cropRect.height=this.canvasHeight),this.cropRect.x=t-this.cropRect.width/2,this.cropRect.y=e-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)}},t.prototype.getRescaledRect=function(t,e,r,i,n,o){var s=r/t,a=i/e;return{x:(n.x-o)*s+o,y:(n.y-o)*a+o,width:n.width*s,height:n.height*a}},t.prototype.scaleCanvas=function(t,e){var r=this.getRescaledRect(this.canvasWidth,this.canvasHeight,t,e,this.cropRect,this.margin);this.canvasWidth=t,this.canvasHeight=e,this.onCropChange&&this.onCropChange(r),this.setCropRectangle(r)},t}(),Qt=function(){function t(t){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=t,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(t.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),t.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},t.prototype.onPointerDown=function(t){this.controlContainer.setPointerCapture(t.pointerId),this.isDragging=!0,this.previousPoint={x:t.clientX,y:t.clientY}},t.prototype.onPointerMove=function(t){this.isDragging&&(this.onAngleChange&&this.onAngleChange((t.clientX-this.previousPoint.x)/5),this.previousPoint.x=t.clientX)},t.prototype.onPointerUp=function(t){this.isDragging&&this.onAngleChange&&this.onAngleChange((t.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(t.pointerId)},t.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var t=this.angleLabelText.getBBox();Bt.setAttributes(this.angleLabelElement,[["x",((this.width-t.width)/2).toString()],["y",(this.height/2).toString()]])}},t.prototype.positionScaleShape=function(){if(this.scaleShape){var t=this.scaleShape.transform.baseVal.getItem(0);t.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(t,0)}},t.prototype.getVisual=function(){var t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("xmlns","http://www.w3.org/2000/svg"),t.setAttribute("width",this.width+"px"),t.setAttribute("height",this.height+"px"),t.setAttribute("viewBox","0 0 "+this.width+" "+this.height),t.style.flexShrink="0",document.body.appendChild(t);for(var e="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,r=1;r<=this.width/5+10;r++){var i=r%5==0?this.height/3:this.height/6;e+="h4v"+-i+"h1v"+i}e+="v1H0Z",this.scaleShape=Bt.createPath(e);var n=Bt.createTransform();this.scaleShape.transform.baseVal.appendItem(n),t.appendChild(this.scaleShape),this.angleLabelElement=Bt.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=Bt.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var o=Bt.createTSpan("");return o.innerHTML="°",this.angleLabelElement.appendChild(o),t.appendChild(this.angleLabelElement),document.body.removeChild(t),t},t}(),Jt=function(){function t(){this.naturalSize=!1,this.imageType="image/png"}return t.prototype.rasterize=function(t,e,r,i,n,o,s){var a=this;return new Promise((function(l){var c=document.createElement("canvas");c.width=t.width.baseVal.value-2*i,c.height=t.height.baseVal.value-2*i;var u=1,h=1;!0===a.naturalSize?(u=e.naturalWidth/(t.width.baseVal.value-2*i)/o,h=e.naturalHeight/(t.height.baseVal.value-2*i)/s,c.width=e.naturalWidth/o,c.height=e.naturalHeight/s):void 0!==a.width&&void 0!==a.height&&(u=a.width/r.width,h=a.height/r.height,c.width*=u,c.height*=h);var d=c.getContext("2d");d.translate(c.width/2,c.height/2),d.rotate(n*Math.PI/180),d.scale(o,s),d.translate(-c.width/2,-c.height/2),d.drawImage(e,0,0,c.width,c.height);var f=document.createElement("canvas");f.width=r.width*u,f.height=r.height*h,f.getContext("2d").putImageData(d.getImageData((r.x-i)*u,(r.y-i)*h,r.width*u,r.height*h),0,0),l(f.toDataURL(a.imageType,a.imageQuality))}))},t}(),te=function(){function t(e){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=t.instanceCounter++,this.styles=new jt(this.instanceNo),this.target=e,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(t.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(t){this._zoomToCropEnabled=t,t?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(t){this._isGridVisible=t,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gridLines",{get:function(){return this._gridLines},set:function(t){this._gridLines=t,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(t){this._rotationAngle=t,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"aspectRatio",{get:function(){var t;return null!==(t=this._aspectRatio)&&void 0!==t?t:this.aspectRatios[0]},set:function(t){this._aspectRatio=t},enumerable:!1,configurable:!0}),t.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(),"popup"===this.displayMode&&this.onPopupResize(),this._isOpen=!0},t.prototype.show=function(){this.showUI(),this.open()},t.prototype.close=function(t){void 0===t&&(t=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),"popup"===this.displayMode&&window.removeEventListener("resize",this.setWindowHeight),t||this.closeEventListeners.forEach((function(t){return t()})),this._isOpen=!1)},t.prototype.addRenderEventListener=function(t){this.renderEventListeners.push(t)},t.prototype.removeRenderEventListener=function(t){this.renderEventListeners.indexOf(t)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(t),1)},t.prototype.addCloseEventListener=function(t){this.closeEventListeners.push(t)},t.prototype.removeCloseEventListener=function(t){this.closeEventListeners.indexOf(t)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(t),1)},t.prototype.setupResizeObserver=function(){var t=this;"inline"===this.displayMode?window.ResizeObserver&&(this.targetObserver=new ResizeObserver((function(){t.resize(t.target.clientWidth,t.target.clientHeight)})),this.targetObserver.observe(this.target)):"popup"===this.displayMode&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(this.onPopupResize),this.targetObserver.observe(this.contentDiv)),window.addEventListener("resize",this.setWindowHeight))},t.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var t=1*this.target.clientWidth/this.target.clientHeight,e=this.contentDiv.clientWidth/t>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*t:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,r=e+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/t;this.resize(e,r)}},t.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},t.prototype.setEditingTargetSize=function(){this.editorCanvas.style.width=this.imageWidth+2*this.CANVAS_MARGIN+"px",this.editorCanvas.style.height=this.imageHeight+2*this.CANVAS_MARGIN+"px",Bt.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},t.prototype.resize=function(t,e){this.imageWidth=Math.round(t),this.imageHeight=Math.round(e),this.setEditingTargetSize(),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px","popup"!==this.displayMode?this.coverDiv.style.width=this.paddedImageWidth+"px":(this.setTopLeft(),this.positionCropImage()),this.cropLayer.scaleCanvas(this.imageWidth,this.imageHeight),this.applyRotation()},t.prototype.setEditingTarget=function(){var t=document.createElement("canvas");t.width=this.target.naturalWidth,t.height=this.target.naturalHeight,t.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var e=t.toDataURL();Bt.setAttributes(this.editingTarget,[["href",e]]),this.setEditingTargetSize()},t.prototype.setTopLeft=function(){var t=this.target.getBoundingClientRect(),e=this.editorCanvas.getBoundingClientRect();this.left=t.left-e.left-this.CANVAS_MARGIN,this.top=t.top-e.top-this.CANVAS_MARGIN},t.prototype.initCropCanvas=function(){this.cropImageHolder=document.createElement("div"),this.cropImageHolder.style.setProperty("touch-action","none"),this.cropImageHolder.style.setProperty("-ms-touch-action","none"),this.cropImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.cropImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImage.style.pointerEvents="auto",this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.cropImageHolder.style.transformOrigin="top left",this.positionCropImage(),this.defs=Bt.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=Bt.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=Bt.createGroup(),this.editingTargetRotationScaleContainer=Bt.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var t=Bt.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(t);var e=Bt.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(e),this.editingTargetContainer=Bt.createGroup(),this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px)",this.editingTargetContainer.appendChild(this.editingTargetRotationContainer),this.cropImage.appendChild(this.editingTargetContainer),this.cropImageHolder.appendChild(this.cropImage),this.editorCanvas.appendChild(this.cropImageHolder)},t.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},t.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=Bt.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new Zt(this.imageWidth,this.imageHeight,this.CANVAS_MARGIN,this.cropLayerContainer),this.cropLayer.onCropChange=this.cropRectChanged,this.cropLayer.numberOfGridLines=this.gridLines,this.cropLayer.isGridVisible=this.isGridVisible,this.cropLayer.cropShadeColor=this.styles.settings.cropShadeColor,this.cropLayer.cropFrameColor=this.styles.settings.cropFrameColor,this.cropLayer.gripColor=this.styles.settings.gripColor,this.cropLayer.gripFillColor=this.styles.settings.gripFillColor,this.cropLayer.open(),this.cropLayer.setCropRectangle(this.cropRect),this.zoomToCropEnabled&&this.zoomToCrop()},t.prototype.zoomToCrop=function(){if(this.cropRect){var t=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,e=this.cropRect.y-this.CANVAS_MARGIN+this.cropRect.height/2;this.zoomFactor=Math.min(this.imageWidth/this.cropRect.width,this.imageHeight/this.cropRect.height),this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin=t+"px "+e+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-t+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-e+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},t.prototype.unzoomFromCrop=function(){this.zoomFactor=1,this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin="center",this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px) scale(1)",this.cropLayer.zoomFactor=this.zoomFactor)},t.prototype.cropRectChanged=function(t){this.cropRect=t,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},t.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},t.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"},t.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},t.prototype.showUI=function(){switch(this.addStyles(),"popup"===this.displayMode&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.displayMode){case"inline":this.coverDiv.style.position="absolute";var t=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,e=this.target.offsetTop>t+this.CANVAS_MARGIN?this.target.offsetTop-(t+this.CANVAS_MARGIN):0;this.coverDiv.style.top=e+"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=void 0!==this.styles.settings.zIndex?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=void 0!==this.styles.settings.zIndex?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="popup"===this.displayMode?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,"popup"===this.displayMode&&(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","popup"===this.displayMode&&(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},t.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},t.prototype.addTopToolbar=function(){var t=this;this.topToolbar=new Gt,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 e=new Wt;e.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(e);var r=[];this.aspectRatios.forEach((function(e){var i=new Vt(Yt.getIcon(e.horizontal,e.vertical),0===e.horizontal&&0===e.vertical?"FREE":e.horizontal+":"+e.vertical);i.onClick=function(){return t.ratioButtonClicked(e)},r.push(i)})),this.aspectRatioButton=new Xt(Yt.getIcon(0,0),"Aspect ratio",r),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,e.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var i=new Vt('<svg viewBox="0 0 24 24"><path d="M10 4v4h4V4h-4m6 0v4h4V4h-4m0 6v4h4v-4h-4m0 6v4h4v-4h-4m-2 4v-4h-4v4h4m-6 0v-4H4v4h4m0-6v-4H4v4h4m0-6V4H4v4h4m2 6h4v-4h-4v4M4 2h16a2 2 0 012 2v16a2 2 0 01-2 2H4c-1.08 0-2-.9-2-2V4a2 2 0 012-2z"/></svg>',"Toggle grid");i.isActive=this.isGridVisible,i.onClick=function(){t.isGridVisible=!t.isGridVisible,i.isActive=t.isGridVisible},e.addButton(i);var n=new Vt('<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"Zoom to selection");if(n.isActive=this.zoomToCropEnabled,n.onClick=function(){t.zoomToCropEnabled=!t.zoomToCropEnabled,n.isActive=t.zoomToCropEnabled},e.addButton(n),!Ft.isLicensed){var o=new Kt;this.topToolbar.addElementBlock(o);var s=document.createElement("div");s.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var a=document.createElement("a");a.style.color="currentColor",a.href="https://markerjs.com/products/cropro",a.target="_blank",a.innerHTML='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2"><path d="M16.326 14.895c0 1.126-.558 1.688-1.673 1.688H9.931c-1.116 0-1.674-.562-1.674-1.688V3.733c0-1.126.558-1.688 1.674-1.688h4.722c1.115 0 1.673.562 1.673 1.688v2.899h-1.957V3.793h-4.124v11.042h4.124v-3.242h1.957v3.302z" fill="currentColor"/><path d="M15.94 7.364a.783.783 0 00-1.065-.304l-11.01 6.126a.783.783 0 00-.303 1.065l4.498 8.085a.783.783 0 001.065.304l11.01-6.126a.783.783 0 00.303-1.065L15.94 7.364zM5.311 14.173l3.737 6.718 9.641-5.364-3.737-6.718-9.641 5.364z" fill="#eef762"/></svg>',s.appendChild(a),o.addElement(s)}var l=new Wt;l.minWidth=3*this.toolbarHeight+"px",l.contentAlign="end",this.topToolbar.addButtonBlock(l);var c=new Vt('<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"OK");c.onClick=this.startRenderAndClose,l.addButton(c),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(c.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var u=new Vt('<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"Close");u.onClick=this.close,l.addButton(u),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(u.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},t.prototype.addBottomToolbar=function(){var t=this;this.bottomToolbar=new Gt,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 e=new Wt;e.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(e);var r=new Vt('<svg viewBox="0 0 24 24"><path d="M13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93M7.1 18.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32M6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47m1.02-4.47L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47z"/></svg>',"Rotate left");r.onClick=this.rotateLeftButtonClicked,e.addButton(r);var i=new Vt('<svg viewBox="0 0 24 24"><path d="M16.89 15.5l1.42 1.39c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.5M13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03m6.93-6.9a7.906 7.906 0 00-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47m-2.36-5.45L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45z"/></svg>',"Rotate right");i.onClick=this.rotateRightButtonClicked,e.addButton(i);var n=new Kt;n.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(n),this.straightener=new Qt("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(e){t.rotateBy(e),t.straightener.angle=t.rotationAngle},n.addElement(this.straightener.getUI());var o=new Wt;o.minWidth=2*this.toolbarHeight+"px",o.contentAlign="end",this.bottomToolbar.addButtonBlock(o);var s=new Vt('<svg viewBox="0 0 24 24"><path d="M15 21h2v-2h-2m4-10h2V7h-2M3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2m16-2v2h2c0-1.1-.9-2-2-2m-8 20h2V1h-2m8 16h2v-2h-2M15 5h2V3h-2m4 10h2v-2h-2m0 10c1.1 0 2-.9 2-2h-2z"/></svg>',"Flip horizontal");s.onClick=this.flipHorizontallyButtonClicked,o.addButton(s);var a=new Vt('<svg viewBox="0 0 24 24"><path d="M3 15v2h2v-2m10 4v2h2v-2m2-16H5c-1.1 0-2 .9-2 2v4h2V5h14v4h2V5c0-1.1-.9-2-2-2m2 16h-2v2c1.1 0 2-.9 2-2M1 11v2h22v-2M7 19v2h2v-2m10-4v2h2v-2m-10 4v2h2v-2M3 19c0 1.1.9 2 2 2v-2z"/></svg>',"Flip vertical");a.onClick=this.flipVerticallyButtonClicked,o.addButton(a)},t.prototype.ratioButtonClicked=function(t){this.aspectRatio=t,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},t.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=Yt.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},t.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&0!==this.aspectRatio.horizontal&&0!==this.aspectRatio.vertical?this.cropLayer.aspectRatio=new qt(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},t.prototype.closeUI=function(){"popup"===this.displayMode&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},t.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},t.prototype.restoreState=function(t){if(t){var e=this.cropLayer.getRescaledRect(t.width,t.height,this.imageWidth,this.imageHeight,t.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(e),this.cropRectChanged(e),this.flippedHorizontally=t.flippedHorizontally,this.flippedVertically=t.flippedVertically,this.applyFlip(),this.rotationAngle=t.rotationAngle,this.applyRotation()}},t.prototype.clientToLocalCoordinates=function(t,e){var r=this.cropImage.getBoundingClientRect();return{x:t-r.left,y:e-r.top}},t.prototype.onWindowResize=function(){this.positionUI()},t.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var t=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=t+"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()},t.prototype.rotateLeftButtonClicked=function(){var t=this.rotationAngle-90;this.rotationAngle%90!=0&&(t+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(t)},t.prototype.rotateRightButtonClicked=function(){var t=this.rotationAngle+90;this.rotationAngle%90!=0&&(t-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(t)},t.prototype.rotateTo=function(t){t=(t=t>180?t-360:t)<=-180?t+360:t,this.rotationAngle=t,this.applyRotation()},t.prototype.rotateBy=function(t){this.rotateTo((this.rotationAngle+t)%360)},t.prototype.applyRotation=function(){var t=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var e=this.editingTargetRotationContainer.transform.baseVal.getItem(0);e.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(e,0);var r=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/r.width,this.imageHeight/r.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=t},t.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},t.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},t.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},t.prototype.startRenderAndClose=function(){return Pt(this,void 0,void 0,(function(){var t,e;return Nt(this,(function(r){switch(r.label){case 0:return[4,this.render()];case 1:return t=r.sent(),e=this.getState(),this.renderEventListeners.forEach((function(r){return r(t,e)})),this.close(!0),[2]}}))}))},t.prototype.render=function(){return Pt(this,void 0,void 0,(function(){var t;return Nt(this,(function(e){switch(e.label){case 0:return(t=new Jt).naturalSize=this.renderAtNaturalSize,t.imageType=this.renderImageType,t.imageQuality=this.renderImageQuality,t.width=this.renderWidth,t.height=this.renderHeight,this.unzoomFromCrop(),Bt.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,t.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 e.sent(),[4,t.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,e.sent()]}}))}))},t.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new Ht("toolbar","\n width: "+("inline"===this.displayMode?"100%":"calc(100vw - "+2*this.popupMargin+"px)")+";\n flex-shrink: 0;\n display: flex;\n flex-direction: row;\n justify-content: space-between; \n height: "+this.toolbarHeight+"px;\n box-sizing: content-box;\n overflow: hidden;\n line-height: 0px;\n ")),this.toolbarStyleColorsClass=this.styles.addClass(new Ht("toolbar_colors","\n background-color: "+this.styles.settings.toolbarBackgroundColor+";\n ")),this.toolbarBlockStyleClass=this.styles.addClass(new Ht("toolbar-block","\n display: flex;\n align-items: center;\n box-sizing: content-box;\n "));var t=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new Ht("toolbar_button","\n display: inline-block;\n width: "+(this.toolbarHeight-2*t)+"px;\n height: "+(this.toolbarHeight-2*t)+"px;\n padding: "+t+"px;\n cursor: default;\n user-select: none;\n box-sizing: content-box;\n ")),this.toolbarButtonStyleColorsClass=this.styles.addClass(new Ht("toolbar_button_colors","\n color: "+this.styles.settings.toolbarColor+";\n fill: currentColor;\n ")),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new Ht("toolbar_active_button","\n color: "+this.styles.settings.toolbarColor+";\n fill: currentColor;\n background-color: "+this.styles.settings.toolbarBackgroundActiveColor+"\n ")),this.styles.addRule(new Ut("."+this.toolbarButtonStyleClass.name+" svg","\n height: "+this.toolbarHeight/2+"px;\n ")),this.styles.addRule(new Ut("."+this.toolbarButtonStyleColorsClass.name+":hover","\n background-color: "+this.styles.settings.toolbarBackgroundHoverColor+"\n ")),this.toolbarDropdownStyleClass=this.styles.addClass(new Ht("toolbar_dropdown","\n position: absolute;\n max-width: "+4*this.toolbarHeight+"px;\n z-index: 20;\n white-space: normal;\n box-sizing: content-box;\n box-shadow: 3px 3px rgba(33, 33, 33, 0.1);\n margin: "+("inline"===this.displayMode?"0":this.popupMargin)+"px;\n line-height: 0px;\n ")),this.toolbarDropdownStyleColorsClass=this.styles.addClass(new Ht("toolbar_dropdown_colors","\n background-color: "+this.styles.settings.toolbarBackgroundColor+";\n ")),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new Ht("toolbar_straightener_block","\n display: flex;\n overflow: hidden;\n justify-content: center;\n -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%);\n ")),this.toolbarStraightenerStyleClass=this.styles.addClass(new Ht("toolbar_straightener","\n display: flex;\n overflow: hidden;\n justify-content: center;\n height: "+(this.toolbarHeight-2*t)+"px;\n padding: "+t+"px;\n cursor: default;\n user-select: none;\n box-sizing: content-box;\n ")),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new Ht("toolbar_straightener_colors","\n color: "+this.styles.settings.toolbarColor+";\n fill: currentColor;\n "))},t.instanceCounter=0,t}(),ee=r("8hTe"),re=r.n(ee),ie=/<pre[^>]*>/g;e.a=function(t){var e=t.value,r=void 0===e?"":e,l=t.edit,d=void 0!==l&&l,f=t.className,p=t.showTextOnly,g=t.showLines,m=t.replaces,v=t.zoomImg,y=t.hasMask,C=t.style,w=void 0===C?{}:C,k=t.stylesPrev,E=void 0===k?{}:k,A=String(r),D=Object(u.useRef)(),O=Object(u.useRef)(),R=Object(u.useState)(""),I=Object(a.a)(R,2),j=I[0],U=I[1],H=Object(u.useState)("office"),G=Object(a.a)(H,2),z=G[0],W=G[1],V=Object(u.useMemo)((function(){try{A=(A=A.replace(/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,"("+P.a.API_SERVER+"/api/attachments/").replace(/\"\/api\/attachments\/|\"\/attachments\/download\//g,'"'+P.a.API_SERVER+"/api/attachments/").replace(/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g,'"'+P.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,"\n")).replace(new RegExp("(?<!\\n)\\n(?!\\n)","g")," \n")}catch(t){}var t=_(A),e=T;if(A.match(/\[TOC\]/)&&(t=t.replace("<p>[TOC]</p>",S()),b()),t=(t=t.replace(/(__special_katext_id_\d+__)/g,(function(t,r){var i=e[r],n=i.type,o=i.expression;return Object(N.renderToString)(function(t){var e=document.createElement("div");return e.innerHTML=t,0===e.childNodes.length?"":e.childNodes[0].nodeValue}(o)||"",{displayMode:"block"===n,throwOnError:!1,output:"html"})}))).replace(/▁/g,"▁▁▁"),L(),p){var r=document.createElement("div");return r.innerHTML=t,r.innerText}return setTimeout((function(){return Y()}),500),t}),[A]),K=Object(u.useRef)();function q(t){var e=t.target;if("IMG"===e.tagName.toUpperCase()){if(v){var r=e.getAttribute("src");U(r),W("image")}}else if("A"===e.tagName.toUpperCase()){var i=e.getAttribute("href");if(i.indexOf("office")>-1)t.preventDefault(),U(i),W("office");else if(i.indexOf("application/pdf")>-1)t.preventDefault(),U(i),W("pdf");else if(i.indexOf("type=text")>-1)t.preventDefault(),U(i),W("html");else if(i.startsWith("#")){t.preventDefault();var n=document.getElementById(i.replace("#",""));n&&n.scrollIntoView(!0)}}}x.WebkitLineClamp=g,g&&(w=Object(o.a)(Object(o.a)({},w),x));var Y=function(){var t,e=null===(t=K.current)||void 0===t?void 0:t.querySelectorAll("video");null==e||e.forEach((function(t){if(t.oncontextmenu=function(){return!1},t.src.indexOf(".m3u8")>-1)if(t.canPlayType("application/vnd.apple.mpegurl"));else if(M.a.isSupported()){var e=new M.a;e.loadSource(t.src),e.attachMedia(t)}}))};Object(u.useEffect)((function(){if(K.current&&V&&V.match(ie)&&window.PR.prettyPrint(),K.current)return K.current.addEventListener("click",q),function(){K.current.removeEventListener("click",q),L(),b()}}),[V,K.current,q]);return h.a.createElement("div",{style:{position:"relative"}},h.a.createElement("div",{ref:K,style:Object(o.a)({},w),className:"".concat(f||""," markdown-body ").concat(re.a.mdBody),onMouseOver:function(t){d&&("IMG"===t.target.nodeName?(D.current.style.display="flex",D.current.style.width=t.target.clientWidth+"px",D.current.style.height=t.target.clientHeight+"px",D.current.style.top=t.target.offsetTop+"px",D.current.style.left=t.target.offsetLeft+"px",O.current.src=t.target.getAttribute("src")):D.current.style.display="none")},dangerouslySetInnerHTML:{__html:V}}),h.a.createElement("div",{ref:D,className:re.a.button},h.a.createElement(i.a,null,h.a.createElement(n.a,{onClick:function(){return(t=new te(O.current)).displayMode="popup",t.addRenderEventListener(function(){var t=Object(s.a)(c.a.mark((function t(e){var r;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return D.current.style.display="none",t.next=3,Object(B.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:e}});case 3:null!=(r=t.sent)&&r.id&&m(O.current.getAttribute("src").replace(P.a.API_SERVER,""),"/api/attachments/".concat(null==r?void 0:r.id,"?type=").concat(r.content_type));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),void t.show();var t}},"裁剪"),h.a.createElement(n.a,{onClick:function(){return(t=new _t(O.current)).settings.displayMode="popup",t.addEventListener("render",function(){var t=Object(s.a)(c.a.mark((function t(e){var r;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(D.current.style.display="none",!O.current){t.next=6;break}return t.next=4,Object(B.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:e.dataUrl}});case 4:null!=(r=t.sent)&&r.id&&m(O.current.getAttribute("src").replace(P.a.API_SERVER,""),"/api/attachments/".concat(null==r?void 0:r.id,"?type=").concat(r.content_type));case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),t.show(),void(window.markerArea=t);var t}},"编辑"))),h.a.createElement("img",{ref:O,src:"https://ali-cdn.educoder.net/images/avatars/PortalImage/170?t=1659681136",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),h.a.createElement(F.a,{close:!0,data:j,hasMask:y,type:null!=j&&j.length?z:"",style:Object(o.a)({},E),onClose:function(){return U("")}}))}},"9VGf":
|
|
|
/*!****************************************!*\
|
|
|
!*** ./src/components/useInterval.tsx ***!
|
|
|
\****************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,r){"use strict";r.d(e,"a",(function(){return n}));var i=r(/*! react */"q1tI");function n(t,e){var r=Object(i.useRef)();Object(i.useEffect)((function(){r.current=t})),Object(i.useEffect)((function(){if(null!==e){var t=setInterval((function(){r.current()}),e);return function(){return clearInterval(t)}}}),[e])}},BU3w:
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./node_modules/rc-util/es/Dom/dynamicCSS.js ***!
|
|
|
\***************************************************/
|
|
|
/*! exports provided: injectCSS, updateCSS */
|
|
|
/*! exports used: updateCSS */function(t,e,r){"use strict";r.d(e,"a",(function(){return a}));var i=r(/*! ./canUseDom */"MNnm");function n(t){return t.attachTo?t.attachTo:document.querySelector("head")||document.body}function o(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Object(i.a)())return null;var o,s=document.createElement("style");(null===(e=r.csp)||void 0===e?void 0:e.nonce)&&(s.nonce=null===(o=r.csp)||void 0===o?void 0:o.nonce);s.innerHTML=t;var a=n(r),l=a.firstChild;return r.prepend&&a.prepend?a.prepend(s):r.prepend&&l?a.insertBefore(s,l):a.appendChild(s),s}var s=new Map;function a(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=n(r);if(!s.has(i)){var a=o("",r),l=a.parentNode;s.set(i,l),l.removeChild(a)}var c=Array.from(s.get(i).children).find((function(t){return"STYLE"===t.tagName&&t["rc-util-key"]===e}));if(c){var u,h,d;if((null===(u=r.csp)||void 0===u?void 0:u.nonce)&&c.nonce!==(null===(h=r.csp)||void 0===h?void 0:h.nonce))c.nonce=null===(d=r.csp)||void 0===d?void 0:d.nonce;return c.innerHTML!==t&&(c.innerHTML=t),c}var f=o(t,r);return f["rc-util-key"]=e,f}},Bd2K:
|
|
|
/*!********************************************************!*\
|
|
|
!*** ./node_modules/codemirror/addon/edit/closetag.js ***!
|
|
|
\********************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){!function(t){t.defineOption("autoCloseTags",!1,(function(s,a,l){if(l!=t.Init&&l&&s.removeKeyMap("autoCloseTags"),a){var c={name:"autoCloseTags"};"object"==typeof a&&!1===a.whenClosing||(c["'/'"]=function(e){return function(e){return e.getOption("disableInput")?t.Pass:i(e,!0)}(e)}),"object"==typeof a&&!1===a.whenOpening||(c["'>'"]=function(i){return function(i){if(i.getOption("disableInput"))return t.Pass;for(var s=i.listSelections(),a=[],l=i.getOption("autoCloseTags"),c=0;c<s.length;c++){if(!s[c].empty())return t.Pass;var u=s[c].head,h=i.getTokenAt(u),d=t.innerMode(i.getMode(),h.state),f=d.state,p=d.mode.xmlCurrentTag&&d.mode.xmlCurrentTag(f),g=p&&p.name;if(!g)return t.Pass;var m="html"==d.mode.configuration,v="object"==typeof l&&l.dontCloseTags||m&&e,y="object"==typeof l&&l.indentTags||m&&r;h.end>u.ch&&(g=g.slice(0,g.length-h.end+u.ch));var b=g.toLowerCase();if(!g||"string"==h.type&&(h.end!=u.ch||!/[\"\']/.test(h.string.charAt(h.string.length-1))||1==h.string.length)||"tag"==h.type&&p.close||h.string.indexOf("/")==u.ch-h.start-1||v&&n(v,b)>-1||o(i,d.mode.xmlCurrentContext&&d.mode.xmlCurrentContext(f)||[],g,u,!0))return t.Pass;var x="object"==typeof l&&l.emptyTags;if(x&&n(x,g)>-1)a[c]={text:"/>",newPos:t.Pos(u.line,u.ch+2)};else{var S=y&&n(y,b)>-1;a[c]={indent:S,text:">"+(S?"\n\n":"")+"</"+g+">",newPos:S?t.Pos(u.line+1,0):t.Pos(u.line,u.ch+1)}}}var C="object"==typeof l&&l.dontIndentOnAutoClose;for(c=s.length-1;c>=0;c--){var w=a[c];i.replaceRange(w.text,s[c].head,s[c].anchor,"+insert");var k=i.listSelections().slice(0);k[c]={head:w.newPos,anchor:w.newPos},i.setSelections(k),!C&&w.indent&&(i.indentLine(w.newPos.line,null,!0),i.indentLine(w.newPos.line+1,null,!0))}}(i)}),s.addKeyMap(c)}}));var e=["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 i(e,r){for(var i=e.listSelections(),n=[],s=r?"/":"</",a=e.getOption("autoCloseTags"),l="object"==typeof a&&a.dontIndentOnSlash,c=0;c<i.length;c++){if(!i[c].empty())return t.Pass;var u=i[c].head,h=e.getTokenAt(u),d=t.innerMode(e.getMode(),h.state),f=d.state;if(r&&("string"==h.type||"<"!=h.string.charAt(0)||h.start!=u.ch-1))return t.Pass;var p,g="xml"!=d.mode.name&&"htmlmixed"==e.getMode().name;if(g&&"javascript"==d.mode.name)p=s+"script";else if(g&&"css"==d.mode.name)p=s+"style";else{var m=d.mode.xmlCurrentContext&&d.mode.xmlCurrentContext(f);if(!m||m.length&&o(e,m,m[m.length-1],u))return t.Pass;p=s+m[m.length-1]}">"!=e.getLine(u.line).charAt(h.end)&&(p+=">"),n[c]=p}if(e.replaceSelections(n),i=e.listSelections(),!l)for(c=0;c<i.length;c++)(c==i.length-1||i[c].head.line<i[c+1].head.line)&&e.indentLine(i[c].head.line)}function n(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,i=t.length;r<i;++r)if(t[r]==e)return r;return-1}function o(e,r,i,n,o){if(!t.scanForClosingTag)return!1;var s=Math.min(e.lastLine()+1,n.line+500),a=t.scanForClosingTag(e,n,null,s);if(!a||a.tag!=i)return!1;for(var l=o?1:0,c=r.length-1;c>=0&&r[c]==i;c--)++l;for(n=a.to,c=1;c<l;c++){var u=t.scanForClosingTag(e,n,null,s);if(!u||u.tag!=i)return!1;n=u.to}return!0}t.commands.closeTag=function(t){return i(t)}}(r(/*! ../../lib/codemirror */"VrN/"),r(/*! ../fold/xml-fold */"osHv"))},BjJ7:
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/pages/tasks/util.js ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: isCompileOk, getTreeData, processTreeData, debounce, isProd, apiPref */
|
|
|
/*! exports used: apiPref, debounce, getTreeData, isCompileOk, processTreeData */function(t,e,r){"use strict";function i(t){var e=!0;if(t.length>0){for(var r=0;r<t.length;r++)if(0==t[r].compile_success||!t[r].compile_success){e=!1;break}}else e=!1;return e}function n(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=[],i=0;i<t.length;i++){var n=t[i],o=e?"".concat(e,"/").concat(n.name):"".concat(n.name);r.push({title:n.name,isLeaf:"tree"!==n.type,key:o})}return r}function o(t,e,r){for(var i=0;i<t.length;i++){var n=t[i];if(n.key===e){n.children=r;break}n.children&&o(n.children,e,r)}return t}function s(t,e,r){var i;return function(){var n=this,o=arguments,s=function(){i=null,r||t.apply(n,o)},a=r&&!i;clearTimeout(i),i=setTimeout(s,e),a&&t.apply(n,o)}}r.d(e,"d",(function(){return i})),r.d(e,"c",(function(){return n})),r.d(e,"e",(function(){return o})),r.d(e,"b",(function(){return s})),r.d(e,"a",(function(){return a}));var a=r(/*! @/utils/env */"m3rI").a.API_SERVER},"C+DQ":
|
|
|
/*!*********************************************************!*\
|
|
|
!*** ./src/components/markdown-editor/css/iconfont.css ***!
|
|
|
\*********************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){},CKgm:
|
|
|
/*!****************************************!*\
|
|
|
!*** ./src/pages/Forums/New/index.tsx ***!
|
|
|
\****************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./src/.umi-production/core/routes.ts (referenced with import()) */function(t,e,r){"use strict";r.r(e);r(/*! antd/es/button/style */"+L6B");var i=r(/*! antd/es/button */"2/Rp"),n=(r(/*! antd/es/input/style */"5NDa"),r(/*! antd/es/input */"5rEg")),o=(r(/*! antd/es/breadcrumb/style */"sPJy"),r(/*! antd/es/breadcrumb */"bE4q")),s=(r(/*! antd/es/message/style */"miYZ"),r(/*! antd/es/message */"tsqr")),a=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/asyncToGenerator */"9og8"),l=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2 */"k1fw"),c=(r(/*! antd/es/form/style */"y8nQ"),r(/*! antd/es/form */"Vl3Y")),u=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray */"tJVT"),h=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties */"PpiC"),d=(r(/*! antd/es/select/style */"OaEy"),r(/*! antd/es/select */"2fM7")),f=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/regenerator */"WmNS"),p=r.n(f),g=r(/*! react */"q1tI"),m=r.n(g),v=r(/*! umi */"Ty5D"),y=r(/*! umi */"9kvl"),b=r(/*! umi */"55Ip"),x=r(/*! @/components/markdown-editor */"Ot1p"),S=r(/*! @/components/MultiUpload */"500L"),C=r(/*! @/service/forums */"h+Ho"),w=r(/*! ./index.less?modules */"7/Dv"),k=r.n(w),E=d.a.Option;e.default=Object(y.a)((function(t){var e=t.forumsDetail,r=t.loading;return{forumsDetail:e,globalSetting:t.globalSetting,loading:r.models.forumsDetail}}))((function(t){t.forumsDetail,t.globalSetting,t.loading,t.dispatch,Object(h.a)(t,["forumsDetail","globalSetting","loading","dispatch"]);var e,r,f,w=Object(v.i)(),T=c.a.useForm(),L=Object(u.a)(T,1)[0],A=Object(g.useState)({}),D=Object(u.a)(A,2),O=D[0],R=D[1],_=Object(g.useState)(0),I=Object(u.a)(_,2),M=I[0],P=I[1],N=Object(g.useState)(!1),F=Object(u.a)(N,2),B=F[0],j=F[1],U=Object(g.useState)({}),H=Object(u.a)(U,2),G=H[0],z=H[1],W=Object(g.useState)(1),V=Object(u.a)(W,2),K=V[0],q=V[1];Object(g.useEffect)((function(){if(Y(),w.memoId)j(!0),X();else{j(!1);var t={forum_id:5};R(Object(l.a)({},t)),L.setFieldsValue(Object(l.a)({},t))}}),[w.memoId]);var Y=function(){var t=Object(a.a)(p.a.mark((function t(){var e;return p.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(C.f)({});case 2:e=t.sent,z(e||{});case 4:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),X=function(){var t=Object(a.a)(p.a.mark((function t(){var e,r,i;return p.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(C.e)({id:w.memoId});case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0={};case 5:r=t.t0,i={subject:r.subject,content:r.content,attachments:Object(S.a)(r.attachments),forum_id:r.forum_id,memo_tags:null===(e=r.memo_tags)||void 0===e?void 0:e.map((function(t){return t.id}))},R(Object(l.a)({},i)),L.setFieldsValue(Object(l.a)({},i));case 9:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),$=function(){var t=Object(a.a)(p.a.mark((function t(e){var r,i,n,o;return p.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Object(l.a)(Object(l.a)({id:B?w.memoId:null},O),{},{attachment_ids:null===(r=O.attachments)||void 0===r||null===(i=r.filter((function(t){var e;return null===(e=t.response)||void 0===e?void 0:e.id})))||void 0===i?void 0:i.map((function(t){var e;return null===(e=t.response)||void 0===e?void 0:e.id})),tags:O.memo_tags}),!B){t.next=7;break}return t.next=4,Object(C.n)(n);case 4:t.t0=t.sent,t.next=10;break;case 7:return t.next=9,Object(C.j)(n);case 9:t.t0=t.sent;case 10:o=t.t0,P(0),0===(null==o?void 0:o.status)&&(s.b.success(null==o?void 0:o.message),1===K?y.d.push("/forums/".concat(B?null==w?void 0:w.memoId:null==o?void 0:o.memo_id)):y.d.push("/forums/".concat(B?null==w?void 0:w.memoId:null==o?void 0:o.memo_id,"/edit")));case 13:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();return m.a.createElement("section",{className:k.a.bg},m.a.createElement("section",{className:"animated fadeIn mb10"},m.a.createElement("aside",{className:"mt10"},m.a.createElement(o.a,{separator:"/"},m.a.createElement(o.a.Item,null,m.a.createElement(b.a,{to:"/forums"},"交流问答")),m.a.createElement(o.a.Item,null,"详情")))),m.a.createElement("aside",{className:"bg-white font16 pt20 pb20 pl20"},B?"编辑话题":"发布话题"),m.a.createElement(c.a,{form:L,className:k.a.formWrap,scrollToFirstError:!0,layout:"vertical",onValuesChange:function(t,e){console.log(e,"values"),R(Object(l.a)(Object(l.a)({},O),t))},onFinish:$,onFinishFailed:function(){P(0)}},m.a.createElement("div",{className:k.a.fieldWrap},m.a.createElement(c.a.Item,{name:"subject",label:m.a.createElement("span",{className:"font16"},"话题名称: "),rules:[{required:!0,message:"请先输入话题名称"}]},m.a.createElement(n.a,{maxLength:50,suffix:"".concat((null===(e=O.subject)||void 0===e?void 0:e.length)||0,"/50")}))),m.a.createElement("div",{className:k.a.mdWrap},m.a.createElement(c.a.Item,{name:"content",label:m.a.createElement("span",{className:"font16"},"内容: "),rules:[{required:!0,message:"请先输入话题内容"}]},m.a.createElement(x.a,{height:600,id:"forums-new-content",watch:!0,defaultValue:O.content})),m.a.createElement("div",null,m.a.createElement(c.a.Item,{name:"attachments",style:{width:350}},m.a.createElement(S.b,{showRemoveModal:!0})))),m.a.createElement("div",{className:k.a.mdWrap},m.a.createElement(c.a.Item,{name:"forum_id",label:m.a.createElement("span",{className:"font16"},"话题类型: "),rules:[{required:!0,message:"请先选择话题类型"}]},m.a.createElement(d.a,{style:{width:300}},null==G||null===(r=G.forums)||void 0===r?void 0:r.map((function(t){return m.a.createElement(E,{key:t.id,value:t.id},t.name)}))))),5===O.forum_id&&m.a.createElement("div",{className:k.a.mdWrap},m.a.createElement(c.a.Item,{name:"memo_tags",label:m.a.createElement("span",{className:"font16"},"技术标签: "),rules:[{required:!0,message:"请先选择技术标签"}]},m.a.createElement(d.a,{style:{width:300},placeholder:"请选择技术标签",mode:"multiple",tokenSeparators:[";"],filterOption:function(t,e){return-1!=e.props.children.toLocaleLowerCase().indexOf(t.toLocaleLowerCase())}},null==G||null===(f=G.tag_list)||void 0===f?void 0:f.map((function(t){return m.a.createElement(E,{key:t.id,value:t.id},t.name)}))))),m.a.createElement("div",{className:k.a.backgroundFa},m.a.createElement("div",{className:"pt40 mb30"},m.a.createElement(c.a.Item,null,m.a.createElement(i.a,{size:"large",type:"primary",className:"".concat(k.a.button," mr20"),htmlType:"submit",loading:1===M,onClick:function(){q(1),P(1)}},"提交"),m.a.createElement(i.a,{size:"large",type:"primary",className:"".concat(k.a.button," mr20"),htmlType:"submit",loading:2===M,onClick:function(){q(2),P(2)}},"保存"),m.a.createElement(i.a,{size:"large",type:"primary",ghost:!0,className:"".concat(k.a.button," mr20"),onClick:function(){document.body.scrollIntoView(),window.location.href.includes("new")?y.d.goBack():y.d.push("/forums/".concat(w.memoId))}},"取消"))))))}))},D1Df:
|
|
|
/*!************************************************!*\
|
|
|
!*** ./node_modules/qrcode.react/lib/index.js ***!
|
|
|
\************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){"use strict";function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(){return(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(r,!0).forEach((function(e){m(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(r).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function a(t,e){if(null==t)return{};var r,i,n=function(t,e){if(null==t)return{};var r,i,n={},o=Object.keys(t);for(i=0;i<o.length;i++)r=o[i],e.indexOf(r)>=0||(n[r]=t[r]);return n}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(i=0;i<o.length;i++)r=o[i],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}function l(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function c(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function u(t,e,r){return e&&c(t.prototype,e),r&&c(t,r),t}function h(t,e){return!e||"object"!==i(e)&&"function"!=typeof e?f(t):e}function d(t){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function f(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function p(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&g(t,e)}function g(t,e){return(g=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function m(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var v=r(/*! react */"q1tI"),y=(r(/*! prop-types */"17x9"),r(/*! qr.js/lib/QRCode */"H38U")),b=r(/*! qr.js/lib/ErrorCorrectLevel */"aRTE");function x(t){for(var e="",r=0;r<t.length;r++){var i=t.charCodeAt(r);i<128?e+=String.fromCharCode(i):i<2048?(e+=String.fromCharCode(192|i>>6),e+=String.fromCharCode(128|63&i)):i<55296||i>=57344?(e+=String.fromCharCode(224|i>>12),e+=String.fromCharCode(128|i>>6&63),e+=String.fromCharCode(128|63&i)):(r++,i=65536+((1023&i)<<10|1023&t.charCodeAt(r)),e+=String.fromCharCode(240|i>>18),e+=String.fromCharCode(128|i>>12&63),e+=String.fromCharCode(128|i>>6&63),e+=String.fromCharCode(128|63&i))}return e}var S={size:128,level:"L",bgColor:"#FFFFFF",fgColor:"#000000",includeMargin:!1};function C(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=[];return t.forEach((function(t,i){var n=null;t.forEach((function(o,s){if(!o&&null!==n)return r.push("M".concat(n+e," ").concat(i+e,"h").concat(s-n,"v1H").concat(n+e,"z")),void(n=null);if(s!==t.length-1)o&&null===n&&(n=s);else{if(!o)return;null===n?r.push("M".concat(s+e,",").concat(i+e," h1v1H").concat(s+e,"z")):r.push("M".concat(n+e,",").concat(i+e," h").concat(s+1-n,"v1H").concat(n+e,"z"))}}))})),r.join("")}function w(t,e){return t.slice().map((function(t,r){return r<e.y||r>=e.y+e.h?t:t.map((function(t,r){return(r<e.x||r>=e.x+e.w)&&t}))}))}function k(t,e){var r=t.imageSettings,i=t.size,n=t.includeMargin;if(null==r)return null;var o=n?4:0,s=e.length+2*o,a=Math.floor(.1*i),l=s/i,c=(r.width||a)*l,u=(r.height||a)*l,h=null==r.x?e.length/2-c/2:r.x*l,d=null==r.y?e.length/2-u/2:r.y*l,f=null;if(r.excavate){var p=Math.floor(h),g=Math.floor(d);f={x:p,y:g,w:Math.ceil(c+h-p),h:Math.ceil(u+d-g)}}return{x:h,y:d,h:u,w:c,excavation:f}}var E=function(){try{(new Path2D).addPath(new Path2D)}catch(t){return!1}return!0}(),T=function(t){function e(){var t,r;l(this,e);for(var i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];return m(f(r=h(this,(t=d(e)).call.apply(t,[this].concat(n)))),"_canvas",void 0),m(f(r),"_image",void 0),m(f(r),"state",{imgLoaded:!1}),m(f(r),"handleImageLoad",(function(){r.setState({imgLoaded:!0})})),r}return p(e,t),u(e,[{key:"componentDidMount",value:function(){this.update()}},{key:"componentDidUpdate",value:function(){this.update()}},{key:"update",value:function(){var t=this.props,e=t.value,r=t.size,i=t.level,n=t.bgColor,o=t.fgColor,s=t.includeMargin,a=t.imageSettings,l=new y(-1,b[i]);if(l.addData(x(e)),l.make(),null!=this._canvas){var c=this._canvas,u=c.getContext("2d");if(!u)return;var h=l.modules;if(null===h)return;var d=s?4:0,f=h.length+2*d,p=k(this.props,h);null!=a&&null!=p&&null!=p.excavation&&(h=w(h,p.excavation));var g=window.devicePixelRatio||1;c.height=c.width=r*g;var m=r/f*g;u.scale(m,m),u.fillStyle=n,u.fillRect(0,0,f,f),u.fillStyle=o,E?u.fill(new Path2D(C(h,d))):h.forEach((function(t,e){t.forEach((function(t,r){t&&u.fillRect(r+d,e+d,1,1)}))})),this.state.imgLoaded&&this._image&&null!=p&&u.drawImage(this._image,p.x+d,p.y+d,p.w,p.h)}}},{key:"render",value:function(){var t=this,e=this.props,r=(e.value,e.size),i=(e.level,e.bgColor,e.fgColor,e.style),o=(e.includeMargin,e.imageSettings),l=a(e,["value","size","level","bgColor","fgColor","style","includeMargin","imageSettings"]),c=s({height:r,width:r},i),u=null,h=o&&o.src;return null!=o&&null!=h&&(u=v.createElement("img",{src:h,style:{display:"none"},onLoad:this.handleImageLoad,ref:function(e){return t._image=e}})),v.createElement(v.Fragment,null,v.createElement("canvas",n({style:c,height:r,width:r,ref:function(e){return t._canvas=e}},l)),u)}}]),e}(v.PureComponent);m(T,"defaultProps",S);var L=function(t){function e(){return l(this,e),h(this,d(e).apply(this,arguments))}return p(e,t),u(e,[{key:"render",value:function(){var t=this.props,e=t.value,r=t.size,i=t.level,o=t.bgColor,s=t.fgColor,l=t.includeMargin,c=t.imageSettings,u=a(t,["value","size","level","bgColor","fgColor","includeMargin","imageSettings"]),h=new y(-1,b[i]);h.addData(x(e)),h.make();var d=h.modules;if(null===d)return null;var f=l?4:0,p=d.length+2*f,g=k(this.props,d),m=null;null!=c&&null!=g&&(null!=g.excavation&&(d=w(d,g.excavation)),m=v.createElement("image",{xlinkHref:c.src,height:g.h,width:g.w,x:g.x+f,y:g.y+f,preserveAspectRatio:"none"}));var S=C(d,f);return v.createElement("svg",n({shapeRendering:"crispEdges",height:r,width:r,viewBox:"0 0 ".concat(p," ").concat(p)},u),v.createElement("path",{fill:o,d:"M0,0 h".concat(p,"v").concat(p,"H0z")}),v.createElement("path",{fill:s,d:S}),m)}}]),e}(v.PureComponent);m(L,"defaultProps",S);var A=function(t){var e=t.renderAs,r=a(t,["renderAs"]),i="svg"===e?L:T;return v.createElement(i,r)};A.defaultProps=s({renderAs:"canvas"},S),t.exports=A},DlQD:
|
|
|
/*!*******************************************!*\
|
|
|
!*** ./node_modules/marked/lib/marked.js ***!
|
|
|
\*******************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){t.exports=function(){"use strict";function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}function r(t,r){var i;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(i=function(t,r){if(t){if("string"==typeof t)return e(t,r);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?e(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){i&&(t=i);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(i=t[Symbol.iterator]()).next.bind(i)}var i=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){function e(){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}}t.exports={defaults:{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},getDefaults:e,changeDefaults:function(e){t.exports.defaults=e}}})),n=(i.defaults,i.getDefaults,i.changeDefaults,/[&<>"']/),o=/[&<>"']/g,s=/[<>"']|&(?!#?\w+;)/,a=/[<>"']|&(?!#?\w+;)/g,l={"&":"&","<":"<",">":">",'"':""","'":"'"},c=function(t){return l[t]},u=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function h(t){return t.replace(u,(function(t,e){return"colon"===(e=e.toLowerCase())?":":"#"===e.charAt(0)?"x"===e.charAt(1)?String.fromCharCode(parseInt(e.substring(2),16)):String.fromCharCode(+e.substring(1)):""}))}var d=/(^|[^\[])\^/g,f=/[^\w:]/g,p=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i,g={},m=/^[^:]+:\/*[^/]*$/,v=/^([^:]+:)[\s\S]*$/,y=/^([^:]+:\/*[^/]*)[\s\S]*$/;function b(t,e){g[" "+t]||(m.test(t)?g[" "+t]=t+"/":g[" "+t]=x(t,"/",!0));var r=-1===(t=g[" "+t]).indexOf(":");return"//"===e.substring(0,2)?r?e:t.replace(v,"$1")+e:"/"===e.charAt(0)?r?e:t.replace(y,"$1")+e:t+e}function x(t,e,r){var i=t.length;if(0===i)return"";for(var n=0;n<i;){var o=t.charAt(i-n-1);if(o!==e||r){if(o===e||!r)break;n++}else n++}return t.substr(0,i-n)}var S=function(t,e){if(e){if(n.test(t))return t.replace(o,c)}else if(s.test(t))return t.replace(a,c);return t},C=h,w=function(t,e){t=t.source||t,e=e||"";var r={replace:function(e,i){return i=(i=i.source||i).replace(d,"$1"),t=t.replace(e,i),r},getRegex:function(){return new RegExp(t,e)}};return r},k=function(t,e,r){if(t){var i;try{i=decodeURIComponent(h(r)).replace(f,"").toLowerCase()}catch(t){return null}if(0===i.indexOf("javascript:")||0===i.indexOf("vbscript:")||0===i.indexOf("data:"))return null}e&&!p.test(r)&&(r=b(e,r));try{r=encodeURI(r).replace(/%25/g,"%")}catch(t){return null}return r},E={exec:function(){}},T=function(t){for(var e,r,i=1;i<arguments.length;i++)for(r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},L=function(t,e){var r=t.replace(/\|/g,(function(t,e,r){for(var i=!1,n=e;--n>=0&&"\\"===r[n];)i=!i;return i?"|":" |"})).split(/ \|/),i=0;if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(/\\\|/g,"|");return r},A=x,D=function(t,e){if(-1===t.indexOf(e[1]))return-1;for(var r=t.length,i=0,n=0;n<r;n++)if("\\"===t[n])n++;else if(t[n]===e[0])i++;else if(t[n]===e[1]&&--i<0)return n;return-1},O=function(t){t&&t.sanitize&&!t.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")},R=i.defaults,_=A,I=L,M=S,P=D;function N(t,e,r){var i=e.href,n=e.title?M(e.title):null,o=t[1].replace(/\\([\[\]])/g,"$1");return"!"!==t[0].charAt(0)?{type:"link",raw:r,href:i,title:n,text:o}:{type:"image",raw:r,href:i,title:n,text:M(o)}}var F=function(){function t(t){this.options=t||R}var e=t.prototype;return e.space=function(t){var e=this.rules.block.newline.exec(t);if(e)return e[0].length>1?{type:"space",raw:e[0]}:{raw:"\n"}},e.code=function(t,e){var r=this.rules.block.code.exec(t);if(r){var i=e[e.length-1];if(i&&"paragraph"===i.type)return{raw:r[0],text:r[0].trimRight()};var n=r[0].replace(/^ {4}/gm,"");return{type:"code",raw:r[0],codeBlockStyle:"indented",text:this.options.pedantic?n:_(n,"\n")}}},e.fences=function(t){var e=this.rules.block.fences.exec(t);if(e){var r=e[0],i=function(t,e){var r=t.match(/^(\s+)(?:```)/);if(null===r)return e;var i=r[1];return e.split("\n").map((function(t){var e=t.match(/^\s+/);return null===e?t:e[0].length>=i.length?t.slice(i.length):t})).join("\n")}(r,e[3]||"");return{type:"code",raw:r,lang:e[2]?e[2].trim():e[2],text:i}}},e.heading=function(t){var e=this.rules.block.heading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[1].length,text:e[2]}},e.nptable=function(t){var e=this.rules.block.nptable.exec(t);if(e){var r={type:"table",header:I(e[1].replace(/^ *| *\| *$/g,"")),align:e[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:e[3]?e[3].replace(/\n$/,"").split("\n"):[],raw:e[0]};if(r.header.length===r.align.length){var i,n=r.align.length;for(i=0;i<n;i++)/^ *-+: *$/.test(r.align[i])?r.align[i]="right":/^ *:-+: *$/.test(r.align[i])?r.align[i]="center":/^ *:-+ *$/.test(r.align[i])?r.align[i]="left":r.align[i]=null;for(n=r.cells.length,i=0;i<n;i++)r.cells[i]=I(r.cells[i],r.header.length);return r}}},e.hr=function(t){var e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:e[0]}},e.blockquote=function(t){var e=this.rules.block.blockquote.exec(t);if(e){var r=e[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:e[0],text:r}}},e.list=function(t){var e=this.rules.block.list.exec(t);if(e){for(var r,i,n,o,s,a,l,c=e[0],u=e[2],h=u.length>1,d=")"===u[u.length-1],f={type:"list",raw:c,ordered:h,start:h?+u.slice(0,-1):"",loose:!1,items:[]},p=e[0].match(this.rules.block.item),g=!1,m=p.length,v=0;v<m;v++)c=r=p[v],i=r.length,~(r=r.replace(/^ *([*+-]|\d+[.)]) */,"")).indexOf("\n ")&&(i-=r.length,r=this.options.pedantic?r.replace(/^ {1,4}/gm,""):r.replace(new RegExp("^ {1,"+i+"}","gm"),"")),v!==m-1&&(n=this.rules.block.bullet.exec(p[v+1])[0],(h?1===n.length||!d&&")"===n[n.length-1]:n.length>1||this.options.smartLists&&n!==u)&&(o=p.slice(v+1).join("\n"),f.raw=f.raw.substring(0,f.raw.length-o.length),v=m-1)),s=g||/\n\n(?!\s*$)/.test(r),v!==m-1&&(g="\n"===r.charAt(r.length-1),s||(s=g)),s&&(f.loose=!0),l=void 0,(a=/^\[[ xX]\] /.test(r))&&(l=" "!==r[1],r=r.replace(/^\[[ xX]\] +/,"")),f.items.push({type:"list_item",raw:c,task:a,checked:l,loose:s,text:r});return f}},e.html=function(t){var e=this.rules.block.html.exec(t);if(e)return{type:this.options.sanitize?"paragraph":"html",raw:e[0],pre:!this.options.sanitizer&&("pre"===e[1]||"script"===e[1]||"style"===e[1]),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(e[0]):M(e[0]):e[0]}},e.def=function(t){var e=this.rules.block.def.exec(t);if(e)return e[3]&&(e[3]=e[3].substring(1,e[3].length-1)),{tag:e[1].toLowerCase().replace(/\s+/g," "),raw:e[0],href:e[2],title:e[3]}},e.table=function(t){var e=this.rules.block.table.exec(t);if(e){var r={type:"table",header:I(e[1].replace(/^ *| *\| *$/g,"")),align:e[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:e[3]?e[3].replace(/\n$/,"").split("\n"):[]};if(r.header.length===r.align.length){r.raw=e[0];var i,n=r.align.length;for(i=0;i<n;i++)/^ *-+: *$/.test(r.align[i])?r.align[i]="right":/^ *:-+: *$/.test(r.align[i])?r.align[i]="center":/^ *:-+ *$/.test(r.align[i])?r.align[i]="left":r.align[i]=null;for(n=r.cells.length,i=0;i<n;i++)r.cells[i]=I(r.cells[i].replace(/^ *\| *| *\| *$/g,""),r.header.length);return r}}},e.lheading=function(t){var e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:"="===e[2].charAt(0)?1:2,text:e[1]}},e.paragraph=function(t){var e=this.rules.block.paragraph.exec(t);if(e)return{type:"paragraph",raw:e[0],text:"\n"===e[1].charAt(e[1].length-1)?e[1].slice(0,-1):e[1]}},e.text=function(t,e){var r=this.rules.block.text.exec(t);if(r){var i=e[e.length-1];return i&&"text"===i.type?{raw:r[0],text:r[0]}:{type:"text",raw:r[0],text:r[0]}}},e.escape=function(t){var e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:M(e[1])}},e.tag=function(t,e,r){var i=this.rules.inline.tag.exec(t);if(i)return!e&&/^<a /i.test(i[0])?e=!0:e&&/^<\/a>/i.test(i[0])&&(e=!1),!r&&/^<(pre|code|kbd|script)(\s|>)/i.test(i[0])?r=!0:r&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(i[0])&&(r=!1),{type:this.options.sanitize?"text":"html",raw:i[0],inLink:e,inRawBlock:r,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):M(i[0]):i[0]}},e.link=function(t){var e=this.rules.inline.link.exec(t);if(e){var r=P(e[2],"()");if(r>-1){var i=(0===e[0].indexOf("!")?5:4)+e[1].length+r;e[2]=e[2].substring(0,r),e[0]=e[0].substring(0,i).trim(),e[3]=""}var n=e[2],o="";if(this.options.pedantic){var s=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);s?(n=s[1],o=s[3]):o=""}else o=e[3]?e[3].slice(1,-1):"";return N(e,{href:(n=n.trim().replace(/^<([\s\S]*)>$/,"$1"))?n.replace(this.rules.inline._escapes,"$1"):n,title:o?o.replace(this.rules.inline._escapes,"$1"):o},e[0])}},e.reflink=function(t,e){var r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){var i=(r[2]||r[1]).replace(/\s+/g," ");if(!(i=e[i.toLowerCase()])||!i.href){var n=r[0].charAt(0);return{type:"text",raw:n,text:n}}return N(r,i,r[0])}},e.strong=function(t,e,r){void 0===r&&(r="");var i=this.rules.inline.strong.start.exec(t);if(i&&(!i[1]||i[1]&&(""===r||this.rules.inline.punctuation.exec(r)))){e=e.slice(-1*t.length);var n,o="**"===i[0]?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;for(o.lastIndex=0;null!=(i=o.exec(e));)if(n=this.rules.inline.strong.middle.exec(e.slice(0,i.index+3)))return{type:"strong",raw:t.slice(0,n[0].length),text:t.slice(2,n[0].length-2)}}},e.em=function(t,e,r){void 0===r&&(r="");var i=this.rules.inline.em.start.exec(t);if(i&&(!i[1]||i[1]&&(""===r||this.rules.inline.punctuation.exec(r)))){e=e.slice(-1*t.length);var n,o="*"===i[0]?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;for(o.lastIndex=0;null!=(i=o.exec(e));)if(n=this.rules.inline.em.middle.exec(e.slice(0,i.index+2)))return{type:"em",raw:t.slice(0,n[0].length),text:t.slice(1,n[0].length-1)}}},e.codespan=function(t){var e=this.rules.inline.code.exec(t);if(e){var r=e[2].replace(/\n/g," "),i=/[^ ]/.test(r),n=r.startsWith(" ")&&r.endsWith(" ");return i&&n&&(r=r.substring(1,r.length-1)),r=M(r,!0),{type:"codespan",raw:e[0],text:r}}},e.br=function(t){var e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}},e.del=function(t){var e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[1]}},e.autolink=function(t,e){var r,i,n=this.rules.inline.autolink.exec(t);if(n)return i="@"===n[2]?"mailto:"+(r=M(this.options.mangle?e(n[1]):n[1])):r=M(n[1]),{type:"link",raw:n[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}},e.url=function(t,e){var r;if(r=this.rules.inline.url.exec(t)){var i,n;if("@"===r[2])n="mailto:"+(i=M(this.options.mangle?e(r[0]):r[0]));else{var o;do{o=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0]}while(o!==r[0]);i=M(r[0]),n="www."===r[1]?"http://"+i:i}return{type:"link",raw:r[0],text:i,href:n,tokens:[{type:"text",raw:i,text:i}]}}},e.inlineText=function(t,e,r){var i,n=this.rules.inline.text.exec(t);if(n)return i=e?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):M(n[0]):n[0]:M(this.options.smartypants?r(n[0]):n[0]),{type:"text",raw:n[0],text:i}},t}(),B=E,j=w,U=T,H={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:B,table:B,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/,_label:/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,_title:/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/};H.def=j(H.def).replace("label",H._label).replace("title",H._title).getRegex(),H.bullet=/(?:[*+-]|\d{1,9}[.)])/,H.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,H.item=j(H.item,"gm").replace(/bull/g,H.bullet).getRegex(),H.list=j(H.list).replace(/bull/g,H.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+H.def.source+")").getRegex(),H._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",H._comment=/<!--(?!-?>)[\s\S]*?-->/,H.html=j(H.html,"i").replace("comment",H._comment).replace("tag",H._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),H.paragraph=j(H._paragraph).replace("hr",H.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",H._tag).getRegex(),H.blockquote=j(H.blockquote).replace("paragraph",H.paragraph).getRegex(),H.normal=U({},H),H.gfm=U({},H.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*|$)"}),H.gfm.nptable=j(H.gfm.nptable).replace("hr",H.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",H._tag).getRegex(),H.gfm.table=j(H.gfm.table).replace("hr",H.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",H._tag).getRegex(),H.pedantic=U({},H.normal,{html:j("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",H._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:B,paragraph:j(H.normal._paragraph).replace("hr",H.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",H.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var G={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:B,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",strong:{start:/^(?:(\*\*(?=[*punctuation]))|\*\*)(?![\s])|__/,middle:/^\*\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*\*$|^__(?![\s])((?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?)__$/,endAst:/[^punctuation\s]\*\*(?!\*)|[punctuation]\*\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]__(?!_)(?:(?=[punctuation\s])|$)/},em:{start:/^(?:(\*(?=[punctuation]))|\*)(?![*\s])|_/,middle:/^\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*$|^_(?![_\s])(?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?_$/,endAst:/[^punctuation\s]\*(?!\*)|[punctuation]\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]_(?!_)(?:(?=[punctuation\s])|$)/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:B,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/,_punctuation:"!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~"};G.punctuation=j(G.punctuation).replace(/punctuation/g,G._punctuation).getRegex(),G._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",G._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",G.em.start=j(G.em.start).replace(/punctuation/g,G._punctuation).getRegex(),G.em.middle=j(G.em.middle).replace(/punctuation/g,G._punctuation).replace(/overlapSkip/g,G._overlapSkip).getRegex(),G.em.endAst=j(G.em.endAst,"g").replace(/punctuation/g,G._punctuation).getRegex(),G.em.endUnd=j(G.em.endUnd,"g").replace(/punctuation/g,G._punctuation).getRegex(),G.strong.start=j(G.strong.start).replace(/punctuation/g,G._punctuation).getRegex(),G.strong.middle=j(G.strong.middle).replace(/punctuation/g,G._punctuation).replace(/blockSkip/g,G._blockSkip).getRegex(),G.strong.endAst=j(G.strong.endAst,"g").replace(/punctuation/g,G._punctuation).getRegex(),G.strong.endUnd=j(G.strong.endUnd,"g").replace(/punctuation/g,G._punctuation).getRegex(),G.blockSkip=j(G._blockSkip,"g").getRegex(),G.overlapSkip=j(G._overlapSkip,"g").getRegex(),G._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,G._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,G._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])?)+(?![-_])/,G.autolink=j(G.autolink).replace("scheme",G._scheme).replace("email",G._email).getRegex(),G._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,G.tag=j(G.tag).replace("comment",H._comment).replace("attribute",G._attribute).getRegex(),G._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,G._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,G._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,G.link=j(G.link).replace("label",G._label).replace("href",G._href).replace("title",G._title).getRegex(),G.reflink=j(G.reflink).replace("label",G._label).getRegex(),G.reflinkSearch=j(G.reflinkSearch,"g").replace("reflink",G.reflink).replace("nolink",G.nolink).getRegex(),G.normal=U({},G),G.pedantic=U({},G.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:j(/^!?\[(label)\]\((.*?)\)/).replace("label",G._label).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",G._label).getRegex()}),G.gfm=U({},G.normal,{escape:j(G.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/}),G.gfm.url=j(G.gfm.url,"i").replace("email",G.gfm._extended_email).getRegex(),G.breaks=U({},G.gfm,{br:j(G.br).replace("{2,}","*").getRegex(),text:j(G.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var z={block:H,inline:G},W=i.defaults,V=z.block,K=z.inline;function q(t){return t.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function Y(t){var e,r,i="",n=t.length;for(e=0;e<n;e++)r=t.charCodeAt(e),Math.random()>.5&&(r="x"+r.toString(16)),i+="&#"+r+";";return i}var X=function(){function e(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||W,this.options.tokenizer=this.options.tokenizer||new F,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var e={block:V.normal,inline:K.normal};this.options.pedantic?(e.block=V.pedantic,e.inline=K.pedantic):this.options.gfm&&(e.block=V.gfm,this.options.breaks?e.inline=K.breaks:e.inline=K.gfm),this.tokenizer.rules=e}e.lex=function(t,r){return new e(r).lex(t)};var r,i,n,o=e.prototype;return o.lex=function(t){return t=t.replace(/\r\n|\r/g,"\n").replace(/\t/g," "),this.blockTokens(t,this.tokens,!0),this.inline(this.tokens),this.tokens},o.blockTokens=function(t,e,r){var i,n,o,s;for(void 0===e&&(e=[]),void 0===r&&(r=!0),t=t.replace(/^ +$/gm,"");t;)if(i=this.tokenizer.space(t))t=t.substring(i.raw.length),i.type&&e.push(i);else if(i=this.tokenizer.code(t,e))t=t.substring(i.raw.length),i.type?e.push(i):((s=e[e.length-1]).raw+="\n"+i.raw,s.text+="\n"+i.text);else if(i=this.tokenizer.fences(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.heading(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.nptable(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.hr(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.blockquote(t))t=t.substring(i.raw.length),i.tokens=this.blockTokens(i.text,[],r),e.push(i);else if(i=this.tokenizer.list(t)){for(t=t.substring(i.raw.length),o=i.items.length,n=0;n<o;n++)i.items[n].tokens=this.blockTokens(i.items[n].text,[],!1);e.push(i)}else if(i=this.tokenizer.html(t))t=t.substring(i.raw.length),e.push(i);else if(r&&(i=this.tokenizer.def(t)))t=t.substring(i.raw.length),this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title});else if(i=this.tokenizer.table(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.lheading(t))t=t.substring(i.raw.length),e.push(i);else if(r&&(i=this.tokenizer.paragraph(t)))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.text(t,e))t=t.substring(i.raw.length),i.type?e.push(i):((s=e[e.length-1]).raw+="\n"+i.raw,s.text+="\n"+i.text);else if(t){var a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}throw new Error(a)}return e},o.inline=function(t){var e,r,i,n,o,s,a=t.length;for(e=0;e<a;e++)switch((s=t[e]).type){case"paragraph":case"text":case"heading":s.tokens=[],this.inlineTokens(s.text,s.tokens);break;case"table":for(s.tokens={header:[],cells:[]},n=s.header.length,r=0;r<n;r++)s.tokens.header[r]=[],this.inlineTokens(s.header[r],s.tokens.header[r]);for(n=s.cells.length,r=0;r<n;r++)for(o=s.cells[r],s.tokens.cells[r]=[],i=0;i<o.length;i++)s.tokens.cells[r][i]=[],this.inlineTokens(o[i],s.tokens.cells[r][i]);break;case"blockquote":this.inline(s.tokens);break;case"list":for(n=s.items.length,r=0;r<n;r++)this.inline(s.items[r].tokens)}return t},o.inlineTokens=function(t,e,r,i,n){var o;void 0===e&&(e=[]),void 0===r&&(r=!1),void 0===i&&(i=!1),void 0===n&&(n="");var s,a=t;if(this.tokens.links){var l=Object.keys(this.tokens.links);if(l.length>0)for(;null!=(s=this.tokenizer.rules.inline.reflinkSearch.exec(a));)l.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(s=this.tokenizer.rules.inline.blockSkip.exec(a));)a=a.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;t;)if(o=this.tokenizer.escape(t))t=t.substring(o.raw.length),e.push(o);else if(o=this.tokenizer.tag(t,r,i))t=t.substring(o.raw.length),r=o.inLink,i=o.inRawBlock,e.push(o);else if(o=this.tokenizer.link(t))t=t.substring(o.raw.length),"link"===o.type&&(o.tokens=this.inlineTokens(o.text,[],!0,i)),e.push(o);else if(o=this.tokenizer.reflink(t,this.tokens.links))t=t.substring(o.raw.length),"link"===o.type&&(o.tokens=this.inlineTokens(o.text,[],!0,i)),e.push(o);else if(o=this.tokenizer.strong(t,a,n))t=t.substring(o.raw.length),o.tokens=this.inlineTokens(o.text,[],r,i),e.push(o);else if(o=this.tokenizer.em(t,a,n))t=t.substring(o.raw.length),o.tokens=this.inlineTokens(o.text,[],r,i),e.push(o);else if(o=this.tokenizer.codespan(t))t=t.substring(o.raw.length),e.push(o);else if(o=this.tokenizer.br(t))t=t.substring(o.raw.length),e.push(o);else if(o=this.tokenizer.del(t))t=t.substring(o.raw.length),o.tokens=this.inlineTokens(o.text,[],r,i),e.push(o);else if(o=this.tokenizer.autolink(t,Y))t=t.substring(o.raw.length),e.push(o);else if(r||!(o=this.tokenizer.url(t,Y))){if(o=this.tokenizer.inlineText(t,i,q))t=t.substring(o.raw.length),n=o.raw.slice(-1),e.push(o);else if(t){var c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}throw new Error(c)}}else t=t.substring(o.raw.length),e.push(o);return e},r=e,n=[{key:"rules",get:function(){return{block:V,inline:K}}}],(i=null)&&t(r.prototype,i),n&&t(r,n),e}(),$=i.defaults,Z=k,Q=S,J=function(){function t(t){this.options=t||$}var e=t.prototype;return e.code=function(t,e,r){var i=(e||"").match(/\S*/)[0];if(this.options.highlight){var n=this.options.highlight(t,i);null!=n&&n!==t&&(r=!0,t=n)}return i?'<pre><code class="'+this.options.langPrefix+Q(i,!0)+'">'+(r?t:Q(t,!0))+"</code></pre>\n":"<pre><code>"+(r?t:Q(t,!0))+"</code></pre>\n"},e.blockquote=function(t){return"<blockquote>\n"+t+"</blockquote>\n"},e.html=function(t){return t},e.heading=function(t,e,r,i){return this.options.headerIds?"<h"+e+' id="'+this.options.headerPrefix+i.slug(r)+'">'+t+"</h"+e+">\n":"<h"+e+">"+t+"</h"+e+">\n"},e.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},e.list=function(t,e,r){var i=e?"ol":"ul";return"<"+i+(e&&1!==r?' start="'+r+'"':"")+">\n"+t+"</"+i+">\n"},e.listitem=function(t){return"<li>"+t+"</li>\n"},e.checkbox=function(t){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},e.paragraph=function(t){return"<p>"+t+"</p>\n"},e.table=function(t,e){return e&&(e="<tbody>"+e+"</tbody>"),"<table>\n<thead>\n"+t+"</thead>\n"+e+"</table>\n"},e.tablerow=function(t){return"<tr>\n"+t+"</tr>\n"},e.tablecell=function(t,e){var r=e.header?"th":"td";return(e.align?"<"+r+' align="'+e.align+'">':"<"+r+">")+t+"</"+r+">\n"},e.strong=function(t){return"<strong>"+t+"</strong>"},e.em=function(t){return"<em>"+t+"</em>"},e.codespan=function(t){return"<code>"+t+"</code>"},e.br=function(){return this.options.xhtml?"<br/>":"<br>"},e.del=function(t){return"<del>"+t+"</del>"},e.link=function(t,e,r){if(null===(t=Z(this.options.sanitize,this.options.baseUrl,t)))return r;var i='<a href="'+Q(t)+'"';return e&&(i+=' title="'+e+'"'),i+=">"+r+"</a>"},e.image=function(t,e,r){if(null===(t=Z(this.options.sanitize,this.options.baseUrl,t)))return r;var i='<img src="'+t+'" alt="'+r+'"';return e&&(i+=' title="'+e+'"'),i+=this.options.xhtml?"/>":">"},e.text=function(t){return t},t}(),tt=function(){function t(){}var e=t.prototype;return e.strong=function(t){return t},e.em=function(t){return t},e.codespan=function(t){return t},e.del=function(t){return t},e.html=function(t){return t},e.text=function(t){return t},e.link=function(t,e,r){return""+r},e.image=function(t,e,r){return""+r},e.br=function(){return""},t}(),et=function(){function t(){this.seen={}}return t.prototype.slug=function(t){var e=t.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(e)){var r=e;do{this.seen[r]++,e=r+"-"+this.seen[r]}while(this.seen.hasOwnProperty(e))}return this.seen[e]=0,e},t}(),rt=i.defaults,it=C,nt=function(){function t(t){this.options=t||rt,this.options.renderer=this.options.renderer||new J,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new tt,this.slugger=new et}t.parse=function(e,r){return new t(r).parse(e)};var e=t.prototype;return e.parse=function(t,e){void 0===e&&(e=!0);var r,i,n,o,s,a,l,c,u,h,d,f,p,g,m,v,y,b,x="",S=t.length;for(r=0;r<S;r++)switch((h=t[r]).type){case"space":continue;case"hr":x+=this.renderer.hr();continue;case"heading":x+=this.renderer.heading(this.parseInline(h.tokens),h.depth,it(this.parseInline(h.tokens,this.textRenderer)),this.slugger);continue;case"code":x+=this.renderer.code(h.text,h.lang,h.escaped);continue;case"table":for(c="",l="",o=h.header.length,i=0;i<o;i++)l+=this.renderer.tablecell(this.parseInline(h.tokens.header[i]),{header:!0,align:h.align[i]});for(c+=this.renderer.tablerow(l),u="",o=h.cells.length,i=0;i<o;i++){for(l="",s=(a=h.tokens.cells[i]).length,n=0;n<s;n++)l+=this.renderer.tablecell(this.parseInline(a[n]),{header:!1,align:h.align[n]});u+=this.renderer.tablerow(l)}x+=this.renderer.table(c,u);continue;case"blockquote":u=this.parse(h.tokens),x+=this.renderer.blockquote(u);continue;case"list":for(d=h.ordered,f=h.start,p=h.loose,o=h.items.length,u="",i=0;i<o;i++)v=(m=h.items[i]).checked,y=m.task,g="",m.task&&(b=this.renderer.checkbox(v),p?m.tokens.length>0&&"text"===m.tokens[0].type?(m.tokens[0].text=b+" "+m.tokens[0].text,m.tokens[0].tokens&&m.tokens[0].tokens.length>0&&"text"===m.tokens[0].tokens[0].type&&(m.tokens[0].tokens[0].text=b+" "+m.tokens[0].tokens[0].text)):m.tokens.unshift({type:"text",text:b}):g+=b),g+=this.parse(m.tokens,p),u+=this.renderer.listitem(g,y,v);x+=this.renderer.list(u,d,f);continue;case"html":x+=this.renderer.html(h.text);continue;case"paragraph":x+=this.renderer.paragraph(this.parseInline(h.tokens));continue;case"text":for(u=h.tokens?this.parseInline(h.tokens):h.text;r+1<S&&"text"===t[r+1].type;)u+="\n"+((h=t[++r]).tokens?this.parseInline(h.tokens):h.text);x+=e?this.renderer.paragraph(u):u;continue;default:var C='Token with "'+h.type+'" type was not found.';if(this.options.silent)return void console.error(C);throw new Error(C)}return x},e.parseInline=function(t,e){e=e||this.renderer;var r,i,n="",o=t.length;for(r=0;r<o;r++)switch((i=t[r]).type){case"escape":n+=e.text(i.text);break;case"html":n+=e.html(i.text);break;case"link":n+=e.link(i.href,i.title,this.parseInline(i.tokens,e));break;case"image":n+=e.image(i.href,i.title,i.text);break;case"strong":n+=e.strong(this.parseInline(i.tokens,e));break;case"em":n+=e.em(this.parseInline(i.tokens,e));break;case"codespan":n+=e.codespan(i.text);break;case"br":n+=e.br();break;case"del":n+=e.del(this.parseInline(i.tokens,e));break;case"text":n+=e.text(i.text);break;default:var s='Token with "'+i.type+'" type was not found.';if(this.options.silent)return void console.error(s);throw new Error(s)}return n},t}(),ot=T,st=O,at=S,lt=i.getDefaults,ct=i.changeDefaults,ut=i.defaults;function ht(t,e,r){if(null==t)throw new Error("marked(): input parameter is undefined or null");if("string"!=typeof t)throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected");if("function"==typeof e&&(r=e,e=null),e=ot({},ht.defaults,e||{}),st(e),r){var i,n=e.highlight;try{i=X.lex(t,e)}catch(t){return r(t)}var o=function(t){var o;if(!t)try{o=nt.parse(i,e)}catch(e){t=e}return e.highlight=n,t?r(t):r(null,o)};if(!n||n.length<3)return o();if(delete e.highlight,!i.length)return o();var s=0;return ht.walkTokens(i,(function(t){"code"===t.type&&(s++,setTimeout((function(){n(t.text,t.lang,(function(e,r){if(e)return o(e);null!=r&&r!==t.text&&(t.text=r,t.escaped=!0),0==--s&&o()}))}),0))})),void(0===s&&o())}try{var a=X.lex(t,e);return e.walkTokens&&ht.walkTokens(a,e.walkTokens),nt.parse(a,e)}catch(t){if(t.message+="\nPlease report this to https://github.com/markedjs/marked.",e.silent)return"<p>An error occurred:</p><pre>"+at(t.message+"",!0)+"</pre>";throw t}}return ht.options=ht.setOptions=function(t){return ot(ht.defaults,t),ct(ht.defaults),ht},ht.getDefaults=lt,ht.defaults=ut,ht.use=function(t){var e=ot({},t);if(t.renderer&&function(){var r=ht.defaults.renderer||new J,i=function(e){var i=r[e];r[e]=function(){for(var n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];var a=t.renderer[e].apply(r,o);return!1===a&&(a=i.apply(r,o)),a}};for(var n in t.renderer)i(n);e.renderer=r}(),t.tokenizer&&function(){var r=ht.defaults.tokenizer||new F,i=function(e){var i=r[e];r[e]=function(){for(var n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];var a=t.tokenizer[e].apply(r,o);return!1===a&&(a=i.apply(r,o)),a}};for(var n in t.tokenizer)i(n);e.tokenizer=r}(),t.walkTokens){var r=ht.defaults.walkTokens;e.walkTokens=function(e){t.walkTokens(e),r&&r(e)}}ht.setOptions(e)},ht.walkTokens=function(t,e){for(var i,n=r(t);!(i=n()).done;){var o=i.value;switch(e(o),o.type){case"table":for(var s,a=r(o.tokens.header);!(s=a()).done;){var l=s.value;ht.walkTokens(l,e)}for(var c,u=r(o.tokens.cells);!(c=u()).done;)for(var h,d=r(c.value);!(h=d()).done;){var f=h.value;ht.walkTokens(f,e)}break;case"list":ht.walkTokens(o.items,e);break;default:o.tokens&&ht.walkTokens(o.tokens,e)}}},ht.Parser=nt,ht.parser=nt.parse,ht.Renderer=J,ht.TextRenderer=tt,ht.Lexer=X,ht.lexer=X.lex,ht.Tokenizer=F,ht.Slugger=et,ht.parse=ht,ht}()},ELLl:
|
|
|
/*!*************************************************************!*\
|
|
|
!*** ./node_modules/codemirror/addon/edit/closebrackets.js ***!
|
|
|
\*************************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){!function(t){var e={pairs:"()[]{}''\"\"",closeBefore:")]}'\":;>",triples:"",explode:"[]{}"},r=t.Pos;function i(t,r){return"pairs"==r&&"string"==typeof t?t:"object"==typeof t&&null!=t[r]?t[r]:e[r]}t.defineOption("autoCloseBrackets",!1,(function(e,r,s){s&&s!=t.Init&&(e.removeKeyMap(n),e.state.closeBrackets=null),r&&(o(i(r,"pairs")),e.state.closeBrackets=r,e.addKeyMap(n))}));var n={Backspace:function(e){var n=a(e);if(!n||e.getOption("disableInput"))return t.Pass;for(var o=i(n,"pairs"),s=e.listSelections(),c=0;c<s.length;c++){if(!s[c].empty())return t.Pass;var u=l(e,s[c].head);if(!u||o.indexOf(u)%2!=0)return t.Pass}for(c=s.length-1;c>=0;c--){var h=s[c].head;e.replaceRange("",r(h.line,h.ch-1),r(h.line,h.ch+1),"+delete")}},Enter:function(e){var r=a(e),n=r&&i(r,"explode");if(!n||e.getOption("disableInput"))return t.Pass;for(var o=e.listSelections(),s=0;s<o.length;s++){if(!o[s].empty())return t.Pass;var c=l(e,o[s].head);if(!c||n.indexOf(c)%2!=0)return t.Pass}e.operation((function(){var t=e.lineSeparator()||"\n";e.replaceSelection(t+t,null),e.execCommand("goCharLeft"),o=e.listSelections();for(var r=0;r<o.length;r++){var i=o[r].head.line;e.indentLine(i,null,!0),e.indentLine(i+1,null,!0)}}))}};function o(t){for(var e=0;e<t.length;e++){var r=t.charAt(e),i="'"+r+"'";n[i]||(n[i]=s(r))}}function s(e){return function(n){return function(e,n){var o=a(e);if(!o||e.getOption("disableInput"))return t.Pass;var s=i(o,"pairs"),l=s.indexOf(n);if(-1==l)return t.Pass;for(var u,h=i(o,"closeBefore"),d=i(o,"triples"),f=s.charAt(l+1)==n,p=e.listSelections(),g=l%2==0,m=0;m<p.length;m++){var v,y=p[m],b=y.head,x=e.getRange(b,r(b.line,b.ch+1));if(g&&!y.empty())v="surround";else if(!f&&g||x!=n)if(f&&b.ch>1&&d.indexOf(n)>=0&&e.getRange(r(b.line,b.ch-2),b)==n+n){if(b.ch>2&&/\bstring/.test(e.getTokenTypeAt(r(b.line,b.ch-2))))return t.Pass;v="addFour"}else if(f){var S=0==b.ch?" ":e.getRange(r(b.line,b.ch-1),b);if(t.isWordChar(x)||S==n||t.isWordChar(S))return t.Pass;v="both"}else{if(!g||!(0===x.length||/\s/.test(x)||h.indexOf(x)>-1))return t.Pass;v="both"}else v=f&&c(e,b)?"both":d.indexOf(n)>=0&&e.getRange(b,r(b.line,b.ch+3))==n+n+n?"skipThree":"skip";if(u){if(u!=v)return t.Pass}else u=v}var C=l%2?s.charAt(l-1):n,w=l%2?n:s.charAt(l+1);e.operation((function(){if("skip"==u)e.execCommand("goCharRight");else if("skipThree"==u)for(var i=0;i<3;i++)e.execCommand("goCharRight");else if("surround"==u){var n=e.getSelections();for(i=0;i<n.length;i++)n[i]=C+n[i]+w;for(e.replaceSelections(n,"around"),n=e.listSelections().slice(),i=0;i<n.length;i++)n[i]=(o=n[i],s=void 0,s=t.cmpPos(o.anchor,o.head)>0,{anchor:new r(o.anchor.line,o.anchor.ch+(s?-1:1)),head:new r(o.head.line,o.head.ch+(s?1:-1))});e.setSelections(n)}else"both"==u?(e.replaceSelection(C+w,null),e.triggerElectric(C+w),e.execCommand("goCharLeft")):"addFour"==u&&(e.replaceSelection(C+C+C+C,"before"),e.execCommand("goCharRight"));var o,s}))}(n,e)}}function a(t){var e=t.state.closeBrackets;return!e||e.override?e:t.getModeAt(t.getCursor()).closeBrackets||e}function l(t,e){var i=t.getRange(r(e.line,e.ch-1),r(e.line,e.ch+1));return 2==i.length?i:null}function c(t,e){var i=t.getTokenAt(r(e.line,e.ch+1));return/\bstring/.test(i.type)&&i.start==e.ch&&(0==e.ch||!/\bstring/.test(t.getTokenTypeAt(e)))}o(e.pairs+"`")}(r(/*! ../../lib/codemirror */"VrN/"))},GfqC:
|
|
|
/*!********************************************************!*\
|
|
|
!*** ./node_modules/rc-upload/es/index.js + 6 modules ***!
|
|
|
\********************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/classnames/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */function(t,e,r){"use strict";var i=r("q1tI"),n=r.n(i),o=r("TSYQ"),s=r.n(o);function a(t){var e=t.responseText||t.response;if(!e)return e;try{return JSON.parse(e)}catch(t){return e}}function l(t){var e=new XMLHttpRequest;t.onProgress&&e.upload&&(e.upload.onprogress=function(e){e.total>0&&(e.percent=e.loaded/e.total*100),t.onProgress(e)});var r=new FormData;t.data&&Object.keys(t.data).forEach((function(e){var i=t.data[e];Array.isArray(i)?i.forEach((function(t){r.append(e+"[]",t)})):r.append(e,t.data[e])})),t.file instanceof Blob?r.append(t.filename,t.file,t.file.name):r.append(t.filename,t.file),e.onerror=function(e){t.onError(e)},e.onload=function(){return e.status<200||e.status>=300?t.onError(function(t,e){var r="cannot "+t.method+" "+t.action+" "+e.status+"'",i=new Error(r);return i.status=e.status,i.method=t.method,i.url=t.action,i}(t,e),a(e)):t.onSuccess(a(e),e)},e.open(t.method,t.action,!0),t.withCredentials&&"withCredentials"in e&&(e.withCredentials=!0);var i=t.headers||{};return null!==i["X-Requested-With"]&&e.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys(i).forEach((function(t){null!==i[t]&&e.setRequestHeader(t,i[t])})),e.send(r),{abort:function(){e.abort()}}}var c=+new Date,u=0;function h(){return"rc-upload-"+c+"-"+ ++u}var d=function(t,e){if(t&&e){var r=Array.isArray(e)?e:e.split(","),i=t.name||"",n=t.type||"",o=n.replace(/\/.*$/,"");return r.some((function(t){var e,r,s=t.trim();return"."===s.charAt(0)?(e=i.toLowerCase(),r=s.toLowerCase(),-1!==e.indexOf(r,e.length-r.length)):/\/\*$/.test(s)?o===s.replace(/\/.*$/,""):n===s}))}return!0};var f=function(t,e,r){var i=function t(i,n){n=n||"",i.isFile?i.file((function(t){r(t)&&(i.fullPath&&!t.webkitRelativePath&&(Object.defineProperties(t,{webkitRelativePath:{writable:!0}}),t.webkitRelativePath=i.fullPath.replace(/^\//,""),Object.defineProperties(t,{webkitRelativePath:{writable:!1}})),e([t]))})):i.isDirectory&&function(t,e){var r=t.createReader(),i=[];!function t(){r.readEntries((function(r){var n=Array.prototype.slice.apply(r);i=i.concat(n),!n.length?e(i):t()}))}()}(i,(function(e){e.forEach((function(e){t(e,""+n+i.name+"/")}))}))};t.forEach((function(t){i(t.webkitGetAsEntry())}))},p=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},g=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var r=[],i=!0,n=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(i=(s=a.next()).done)&&(r.push(s.value),!e||r.length!==e);i=!0);}catch(t){n=!0,o=t}finally{try{!i&&a.return&&a.return()}finally{if(n)throw o}}return r}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},m=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}();function v(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function y(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function b(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}var x=function(t){function e(){var t,r,i;y(this,e);for(var n=arguments.length,o=Array(n),s=0;s<n;s++)o[s]=arguments[s];return r=i=b(this,(t=e.__proto__||Object.getPrototypeOf(e)).call.apply(t,[this].concat(o))),i.state={uid:h()},i.reqs={},i.onChange=function(t){var e=t.target.files;i.uploadFiles(e),i.reset()},i.onClick=function(t){var e=i.fileInput;if(e){var r=i.props,n=r.children,o=r.onClick;n&&"button"===n.type&&(e.parentNode.focus(),e.parentNode.querySelector("button").blur()),e.click(),o&&o(t)}},i.onKeyDown=function(t){"Enter"===t.key&&i.onClick()},i.onFileDrop=function(t){var e=i.props.multiple;if(t.preventDefault(),"dragover"!==t.type)if(i.props.directory)f(Array.prototype.slice.call(t.dataTransfer.items),i.uploadFiles,(function(t){return d(t,i.props.accept)}));else{var r=Array.prototype.slice.call(t.dataTransfer.files).filter((function(t){return d(t,i.props.accept)}));!1===e&&(r=r.slice(0,1)),i.uploadFiles(r)}},i.uploadFiles=function(t){var e=Array.prototype.slice.call(t);e.map((function(t){return t.uid=h(),t})).forEach((function(t){i.upload(t,e)}))},i.saveFileInput=function(t){i.fileInput=t},b(i,r)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),m(e,[{key:"componentDidMount",value:function(){this._isMounted=!0}},{key:"componentWillUnmount",value:function(){this._isMounted=!1,this.abort()}},{key:"upload",value:function(t,e){var r=this,i=this.props;if(!i.beforeUpload)return setTimeout((function(){return r.post(t)}),0);var n=i.beforeUpload(t,e);n&&n.then?n.then((function(e){var i=Object.prototype.toString.call(e);return"[object File]"===i||"[object Blob]"===i?r.post(e):r.post(t)})).catch((function(t){console.log(t)})):!1!==n&&setTimeout((function(){return r.post(t)}),0)}},{key:"post",value:function(t){var e=this;if(this._isMounted){var r=this.props,i=r.onStart,n=r.onProgress,o=r.transformFile,s=void 0===o?function(t){return t}:o;new Promise((function(e){var i=r.action;return"function"==typeof i&&(i=i(t)),e(i)})).then((function(o){var a=t.uid,c=r.customRequest||l;Promise.resolve(s(t)).then((function(t){var e=r.data;return"function"==typeof e&&(e=e(t)),Promise.all([t,e])})).catch((function(t){console.error(t)})).then((function(s){var l=g(s,2),u=l[0],h=l[1],d={action:o,filename:r.name,data:h,file:u,headers:r.headers,withCredentials:r.withCredentials,method:r.method||"post",onProgress:n?function(e){n(e,t)}:null,onSuccess:function(i,n){delete e.reqs[a],r.onSuccess(i,t,n)},onError:function(i,n){delete e.reqs[a],r.onError(i,n,t)}};i(t),e.reqs[a]=c(d)}))}))}}},{key:"reset",value:function(){this.setState({uid:h()})}},{key:"abort",value:function(t){var e=this.reqs;if(t){var r=t;t&&t.uid&&(r=t.uid),e[r]&&e[r].abort&&e[r].abort(),delete e[r]}else Object.keys(e).forEach((function(t){e[t]&&e[t].abort&&e[t].abort(),delete e[t]}))}},{key:"render",value:function(){var t,e,r=this.props,i=r.component,o=r.prefixCls,a=r.className,l=r.disabled,c=r.id,u=r.style,h=r.multiple,d=r.accept,f=r.children,g=r.directory,m=r.openFileDialogOnClick,y=r.onMouseEnter,b=r.onMouseLeave,x=function(t,e){var r={};for(var i in t)e.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=t[i]);return r}(r,["component","prefixCls","className","disabled","id","style","multiple","accept","children","directory","openFileDialogOnClick","onMouseEnter","onMouseLeave"]),S=s()((v(t={},o,!0),v(t,o+"-disabled",l),v(t,a,a),t)),C=l?{}:{onClick:m?this.onClick:function(){},onKeyDown:m?this.onKeyDown:function(){},onMouseEnter:y,onMouseLeave:b,onDrop:this.onFileDrop,onDragOver:this.onFileDrop,tabIndex:"0"};return n.a.createElement(i,p({},C,{className:S,role:"button",style:u}),n.a.createElement("input",p({},(e=x,Object.keys(e).reduce((function(t,r){return"data-"!==r.substr(0,5)&&"aria-"!==r.substr(0,5)&&"role"!==r||(t[r]=e[r]),t}),{})),{id:c,type:"file",ref:this.saveFileInput,onClick:function(t){return t.stopPropagation()},key:this.state.uid,style:{display:"none"},accept:d,directory:g?"directory":null,webkitdirectory:g?"webkitdirectory":null,multiple:h,onChange:this.onChange})),f)}}]),e}(i.Component),S=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},C=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}();function w(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function k(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function E(){}var T=function(t){function e(){var t,r,i;w(this,e);for(var n=arguments.length,o=Array(n),s=0;s<n;s++)o[s]=arguments[s];return r=i=k(this,(t=e.__proto__||Object.getPrototypeOf(e)).call.apply(t,[this].concat(o))),i.saveUploader=function(t){i.uploader=t},k(i,r)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),C(e,[{key:"abort",value:function(t){this.uploader.abort(t)}},{key:"render",value:function(){return n.a.createElement(x,S({},this.props,{ref:this.saveUploader}))}}]),e}(i.Component);T.defaultProps={component:"span",prefixCls:"rc-upload",data:{},headers:{},name:"file",multipart:!1,onStart:E,onError:E,onSuccess:E,multiple:!1,beforeUpload:null,customRequest:null,withCredentials:!1,openFileDialogOnClick:!0};var L=T;e.a=L},H38U:
|
|
|
/*!******************************************!*\
|
|
|
!*** ./node_modules/qr.js/lib/QRCode.js ***!
|
|
|
\******************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){var i=r(/*! ./8BitByte */"f4xo"),n=r(/*! ./RSBlock */"rcnY"),o=r(/*! ./BitBuffer */"wU8J"),s=r(/*! ./util */"Iq15"),a=r(/*! ./Polynomial */"dWSS");function l(t,e){this.typeNumber=t,this.errorCorrectLevel=e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}var c=l.prototype;c.addData=function(t){var e=new i(t);this.dataList.push(e),this.dataCache=null},c.isDark=function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);return this.modules[t][e]},c.getModuleCount=function(){return this.moduleCount},c.make=function(){if(this.typeNumber<1){var t=1;for(t=1;t<40;t++){for(var e=n.getRSBlocks(t,this.errorCorrectLevel),r=new o,i=0,a=0;a<e.length;a++)i+=e[a].dataCount;for(a=0;a<this.dataList.length;a++){var l=this.dataList[a];r.put(l.mode,4),r.put(l.getLength(),s.getLengthInBits(l.mode,t)),l.write(r)}if(r.getLengthInBits()<=8*i)break}this.typeNumber=t}this.makeImpl(!1,this.getBestMaskPattern())},c.makeImpl=function(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var r=0;r<this.moduleCount;r++){this.modules[r]=new Array(this.moduleCount);for(var i=0;i<this.moduleCount;i++)this.modules[r][i]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(t,e),this.typeNumber>=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=l.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},c.setupPositionProbePattern=function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var i=-1;i<=7;i++)e+i<=-1||this.moduleCount<=e+i||(this.modules[t+r][e+i]=0<=r&&r<=6&&(0==i||6==i)||0<=i&&i<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=i&&i<=4)},c.getBestMaskPattern=function(){for(var t=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var i=s.getLostPoint(this);(0==r||t>i)&&(t=i,e=r)}return e},c.createMovieClip=function(t,e,r){var i=t.createEmptyMovieClip(e,r);this.make();for(var n=0;n<this.modules.length;n++)for(var o=1*n,s=0;s<this.modules[n].length;s++){var a=1*s;this.modules[n][s]&&(i.beginFill(0,100),i.moveTo(a,o),i.lineTo(a+1,o),i.lineTo(a+1,o+1),i.lineTo(a,o+1),i.endFill())}return i},c.setupTimingPattern=function(){for(var t=8;t<this.moduleCount-8;t++)null==this.modules[t][6]&&(this.modules[t][6]=t%2==0);for(var e=8;e<this.moduleCount-8;e++)null==this.modules[6][e]&&(this.modules[6][e]=e%2==0)},c.setupPositionAdjustPattern=function(){for(var t=s.getPatternPosition(this.typeNumber),e=0;e<t.length;e++)for(var r=0;r<t.length;r++){var i=t[e],n=t[r];if(null==this.modules[i][n])for(var o=-2;o<=2;o++)for(var a=-2;a<=2;a++)this.modules[i+o][n+a]=-2==o||2==o||-2==a||2==a||0==o&&0==a}},c.setupTypeNumber=function(t){for(var e=s.getBCHTypeNumber(this.typeNumber),r=0;r<18;r++){var i=!t&&1==(e>>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=i}for(r=0;r<18;r++){i=!t&&1==(e>>r&1);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=i}},c.setupTypeInfo=function(t,e){for(var r=this.errorCorrectLevel<<3|e,i=s.getBCHTypeInfo(r),n=0;n<15;n++){var o=!t&&1==(i>>n&1);n<6?this.modules[n][8]=o:n<8?this.modules[n+1][8]=o:this.modules[this.moduleCount-15+n][8]=o}for(n=0;n<15;n++){o=!t&&1==(i>>n&1);n<8?this.modules[8][this.moduleCount-n-1]=o:n<9?this.modules[8][15-n-1+1]=o:this.modules[8][15-n-1]=o}this.modules[this.moduleCount-8][8]=!t},c.mapData=function(t,e){for(var r=-1,i=this.moduleCount-1,n=7,o=0,a=this.moduleCount-1;a>0;a-=2)for(6==a&&a--;;){for(var l=0;l<2;l++)if(null==this.modules[i][a-l]){var c=!1;o<t.length&&(c=1==(t[o]>>>n&1)),s.getMask(e,i,a-l)&&(c=!c),this.modules[i][a-l]=c,-1==--n&&(o++,n=7)}if((i+=r)<0||this.moduleCount<=i){i-=r,r=-r;break}}},l.PAD0=236,l.PAD1=17,l.createData=function(t,e,r){for(var i=n.getRSBlocks(t,e),a=new o,c=0;c<r.length;c++){var u=r[c];a.put(u.mode,4),a.put(u.getLength(),s.getLengthInBits(u.mode,t)),u.write(a)}var h=0;for(c=0;c<i.length;c++)h+=i[c].dataCount;if(a.getLengthInBits()>8*h)throw new Error("code length overflow. ("+a.getLengthInBits()+">"+8*h+")");for(a.getLengthInBits()+4<=8*h&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(!1);for(;!(a.getLengthInBits()>=8*h||(a.put(l.PAD0,8),a.getLengthInBits()>=8*h));)a.put(l.PAD1,8);return l.createBytes(a,i)},l.createBytes=function(t,e){for(var r=0,i=0,n=0,o=new Array(e.length),l=new Array(e.length),c=0;c<e.length;c++){var u=e[c].dataCount,h=e[c].totalCount-u;i=Math.max(i,u),n=Math.max(n,h),o[c]=new Array(u);for(var d=0;d<o[c].length;d++)o[c][d]=255&t.buffer[d+r];r+=u;var f=s.getErrorCorrectPolynomial(h),p=new a(o[c],f.getLength()-1).mod(f);l[c]=new Array(f.getLength()-1);for(d=0;d<l[c].length;d++){var g=d+p.getLength()-l[c].length;l[c][d]=g>=0?p.get(g):0}}var m=0;for(d=0;d<e.length;d++)m+=e[d].totalCount;var v=new Array(m),y=0;for(d=0;d<i;d++)for(c=0;c<e.length;c++)d<o[c].length&&(v[y++]=o[c][d]);for(d=0;d<n;d++)for(c=0;c<e.length;c++)d<l[c].length&&(v[y++]=l[c][d]);return v},t.exports=l},HmJG:
|
|
|
/*!****************************************************************!*\
|
|
|
!*** ./src/components/markdown-editor/upload-image/index.less ***!
|
|
|
\****************************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){},Iq15:
|
|
|
/*!****************************************!*\
|
|
|
!*** ./node_modules/qr.js/lib/util.js ***!
|
|
|
\****************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){var i=r(/*! ./mode */"nVVt"),n=r(/*! ./Polynomial */"dWSS"),o=r(/*! ./math */"dQei"),s=0,a=1,l=2,c=3,u=4,h=5,d=6,f=7,p={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;p.getBCHDigit(e)-p.getBCHDigit(p.G15)>=0;)e^=p.G15<<p.getBCHDigit(e)-p.getBCHDigit(p.G15);return(t<<10|e)^p.G15_MASK},getBCHTypeNumber:function(t){for(var e=t<<12;p.getBCHDigit(e)-p.getBCHDigit(p.G18)>=0;)e^=p.G18<<p.getBCHDigit(e)-p.getBCHDigit(p.G18);return t<<12|e},getBCHDigit:function(t){for(var e=0;0!=t;)e++,t>>>=1;return e},getPatternPosition:function(t){return p.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case s:return(e+r)%2==0;case a:return e%2==0;case l:return r%3==0;case c:return(e+r)%3==0;case u:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case h:return e*r%2+e*r%3==0;case d:return(e*r%2+e*r%3)%2==0;case f:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new n([1],0),r=0;r<t;r++)e=e.multiply(new n([1,o.gexp(r)],0));return e},getLengthInBits:function(t,e){if(1<=e&&e<10)switch(t){case i.MODE_NUMBER:return 10;case i.MODE_ALPHA_NUM:return 9;case i.MODE_8BIT_BYTE:case i.MODE_KANJI:return 8;default:throw new Error("mode:"+t)}else if(e<27)switch(t){case i.MODE_NUMBER:return 12;case i.MODE_ALPHA_NUM:return 11;case i.MODE_8BIT_BYTE:return 16;case i.MODE_KANJI:return 10;default:throw new Error("mode:"+t)}else{if(!(e<41))throw new Error("type:"+e);switch(t){case i.MODE_NUMBER:return 14;case i.MODE_ALPHA_NUM:return 13;case i.MODE_8BIT_BYTE:return 16;case i.MODE_KANJI:return 12;default:throw new Error("mode:"+t)}}},getLostPoint:function(t){for(var e=t.getModuleCount(),r=0,i=0;i<e;i++)for(var n=0;n<e;n++){for(var o=0,s=t.isDark(i,n),a=-1;a<=1;a++)if(!(i+a<0||e<=i+a))for(var l=-1;l<=1;l++)n+l<0||e<=n+l||0==a&&0==l||s==t.isDark(i+a,n+l)&&o++;o>5&&(r+=3+o-5)}for(i=0;i<e-1;i++)for(n=0;n<e-1;n++){var c=0;t.isDark(i,n)&&c++,t.isDark(i+1,n)&&c++,t.isDark(i,n+1)&&c++,t.isDark(i+1,n+1)&&c++,0!=c&&4!=c||(r+=3)}for(i=0;i<e;i++)for(n=0;n<e-6;n++)t.isDark(i,n)&&!t.isDark(i,n+1)&&t.isDark(i,n+2)&&t.isDark(i,n+3)&&t.isDark(i,n+4)&&!t.isDark(i,n+5)&&t.isDark(i,n+6)&&(r+=40);for(n=0;n<e;n++)for(i=0;i<e-6;i++)t.isDark(i,n)&&!t.isDark(i+1,n)&&t.isDark(i+2,n)&&t.isDark(i+3,n)&&t.isDark(i+4,n)&&!t.isDark(i+5,n)&&t.isDark(i+6,n)&&(r+=40);var u=0;for(n=0;n<e;n++)for(i=0;i<e;i++)t.isDark(i,n)&&u++;return r+=10*(Math.abs(100*u/e/e-50)/5)}};t.exports=p},LdHM:
|
|
|
/*!********************************************************!*\
|
|
|
!*** ./node_modules/rc-select/es/index.js + 6 modules ***!
|
|
|
\********************************************************/
|
|
|
/*! exports provided: Option, OptGroup, default */
|
|
|
/*! exports used: OptGroup, Option, default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createClass.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createSuper.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/defineProperty.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/inherits.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/typeof.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/classnames/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-select/es/TransBtn.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-select/es/generate.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-select/es/utils/commonUtil.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-select/es/utils/valueUtil.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/Children/toArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/KeyCode.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/hooks/useMemo.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/pickAttrs.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/warning.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-virtual-list/es/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */function(t,e,r){"use strict";r.d(e,"b",(function(){return S})),r.d(e,"a",(function(){return w}));var i=r("1OyB"),n=r("vuIU"),o=r("Ji7U"),s=r("LK+K"),a=r("q1tI"),l=r("rePB"),c=r("Ff2n"),u=r("ODXe"),h=r("4IlW"),d=r("bX4T"),f=r("YrtM"),p=r("TSYQ"),g=r.n(p),m=r("+nKL"),v=r("8OUc"),y=a.forwardRef((function(t,e){var r=t.prefixCls,i=t.id,n=t.flattenOptions,o=t.childrenAsData,s=t.values,p=t.searchValue,y=t.multiple,b=t.defaultActiveFirstOption,x=t.height,S=t.itemHeight,C=t.notFoundContent,w=t.open,k=t.menuItemSelectedIcon,E=t.virtual,T=t.onSelect,L=t.onToggleOpen,A=t.onActiveValue,D=t.onScroll,O=t.onMouseEnter,R="".concat(r,"-item"),_=Object(f.a)((function(){return n}),[w,n],(function(t,e){return e[0]&&t[1]!==e[1]})),I=a.useRef(null),M=function(t){t.preventDefault()},P=function(t){I.current&&I.current.scrollTo({index:t})},N=function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=_.length,i=0;i<r;i+=1){var n=(t+i*e+r)%r,o=_[n],s=o.group,a=o.data;if(!s&&!a.disabled)return n}return-1},F=a.useState((function(){return N(0)})),B=Object(u.a)(F,2),j=B[0],U=B[1],H=function(t){U(t);var e=_[t];e?A(e.data.value,t):A(null,-1)};a.useEffect((function(){H(!1!==b?N(0):-1)}),[_.length,p]),a.useEffect((function(){var t=setTimeout((function(){if(!y&&w&&1===s.size){var t=Array.from(s)[0],e=_.findIndex((function(e){return e.data.value===t}));H(e),P(e)}}));return function(){return clearTimeout(t)}}),[w]);var G=function(t){void 0!==t&&T(t,{selected:!s.has(t)}),y||L(!1)};if(a.useImperativeHandle(e,(function(){return{onKeyDown:function(t){var e=t.which;switch(e){case h.a.UP:case h.a.DOWN:var r=0;if(e===h.a.UP?r=-1:e===h.a.DOWN&&(r=1),0!==r){var i=N(j+r,r);P(i),H(i)}break;case h.a.ENTER:var n=_[j];n&&!n.data.disabled?G(n.data.value):G(void 0),w&&t.preventDefault();break;case h.a.ESC:L(!1)}},onKeyUp:function(){},scrollTo:function(t){P(t)}}})),0===_.length)return a.createElement("div",{role:"listbox",id:"".concat(i,"_list"),className:"".concat(R,"-empty"),onMouseDown:M},C);function z(t){var e=_[t];if(!e)return null;var r=e.data||{},n=r.value,l=r.label,c=r.children,u=Object(d.a)(r,!0),h=o?c:l;return e?a.createElement("div",Object.assign({"aria-label":"string"==typeof h?h:null},u,{key:t,role:"option",id:"".concat(i,"_list_").concat(t),"aria-selected":s.has(n)}),n):null}return a.createElement(a.Fragment,null,a.createElement("div",{role:"listbox",id:"".concat(i,"_list"),style:{height:0,width:0,overflow:"hidden"}},z(j-1),z(j),z(j+1)),a.createElement(m.a,{itemKey:"key",ref:I,data:_,height:x,itemHeight:S,fullHeight:!1,onMouseDown:M,onScroll:D,virtual:E,onMouseEnter:O},(function(t,e){var r,i=t.group,n=t.groupOption,u=t.data,h=u.label,d=u.key;if(i)return a.createElement("div",{className:g()(R,"".concat(R,"-group"))},void 0!==h?h:d);var f=u.disabled,p=u.value,m=u.title,y=u.children,b=u.style,x=u.className,S=Object(c.a)(u,["disabled","value","title","children","style","className"]),C=s.has(p),w="".concat(R,"-option"),E=g()(R,w,x,(r={},Object(l.a)(r,"".concat(w,"-grouped"),n),Object(l.a)(r,"".concat(w,"-active"),j===e&&!f),Object(l.a)(r,"".concat(w,"-disabled"),f),Object(l.a)(r,"".concat(w,"-selected"),C),r)),T=o?y:h,L=!k||"function"==typeof k||C;return a.createElement("div",Object.assign({},S,{"aria-selected":C,className:E,title:m,onMouseMove:function(){j===e||f||H(e)},onClick:function(){f||G(p)},style:b}),a.createElement("div",{className:"".concat(w,"-content")},T||p),a.isValidElement(k)||C,L&&a.createElement(v.a,{className:"".concat(R,"-option-state"),customizeIcon:k,customizeIconProps:{isSelected:C}},C?"✓":null))})))}));y.displayName="OptionList";var b=y,x=function(){return null};x.isSelectOption=!0;var S=x,C=function(){return null};C.isSelectOptGroup=!0;var w=C,k=r("VTBJ"),E=r("Zm9Q");function T(t){var e=t.key,r=t.props,i=r.children,n=r.value,o=Object(c.a)(r,["children","value"]);return Object(k.a)({key:e,value:void 0!==n?n:e,children:i},o)}function L(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Object(E.a)(t).map((function(t,r){if(!a.isValidElement(t)||!t.type)return null;var i=t.type.isSelectOptGroup,n=t.key,o=t.props,s=o.children,l=Object(c.a)(o,["children"]);return e||!i?T(t):Object(k.a)(Object(k.a)({key:"__RC_SELECT_GRP__".concat(null===n?r:n,"__"),label:n},l),{},{options:L(s)})})).filter((function(t){return t}))}var A=r("2Qr1"),D=r("qNPg"),O=r("U8pU"),R=r("Kwbf"),_=r("WKfj");var I=function(t){var e=t.mode,r=t.options,i=t.children,n=t.backfill,o=t.allowClear,s=t.placeholder,l=t.getInputElement,c=t.showSearch,u=t.onSearch,h=t.defaultOpen,d=t.autoFocus,f=t.labelInValue,p=t.value,g=t.inputValue,m=t.optionLabelProp,v="multiple"===e||"tags"===e,y=void 0!==c?c:v||"combobox"===e,b=r||L(i);if(Object(R.a)("tags"!==e||b.every((function(t){return!t.disabled})),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),"tags"===e||"combobox"===e){var x=b.some((function(t){return t.options?t.options.some((function(t){return"number"==typeof("value"in t?t.value:t.key)})):"number"==typeof("value"in t?t.value:t.key)}));Object(R.a)(!x,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(R.a)("combobox"!==e||!m,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(R.a)("combobox"===e||!n,"`backfill` only works with `combobox` mode."),Object(R.a)("combobox"===e||!l,"`getInputElement` only work with `combobox` mode."),Object(R.b)("combobox"!==e||!l||!o||!s,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),u&&!y&&"combobox"!==e&&"tags"!==e&&Object(R.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(R.b)(!h||d,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),null!=p){var S=Object(_.d)(p);Object(R.a)(!f||S.every((function(t){return"object"===Object(O.a)(t)&&("key"in t||"value"in t)})),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(R.a)(!v||Array.isArray(p),"`value` should be array when `mode` is `multiple` or `tags`")}if(i){var C=null;Object(E.a)(i).some((function(t){if(!a.isValidElement(t)||!t.type)return!1;var e=t.type;return!e.isSelectOption&&(e.isSelectOptGroup?!Object(E.a)(t.props.children).every((function(e){return!(a.isValidElement(e)&&t.type&&!e.type.isSelectOption)||(C=e.type,!1)})):(C=e,!0))})),C&&Object(R.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(C.displayName||C.name||C,"`.")),Object(R.a)(void 0===g,"`inputValue` is deprecated, please use `searchValue` instead.")}},M=Object(D.a)({prefixCls:"rc-select",components:{optionList:b},convertChildrenToData:L,flattenOptions:A.d,getLabeledValue:A.e,filterOptions:A.b,isValueDisabled:A.g,findValueOption:A.c,warningProps:I,fillOptionsWithMissingValue:A.a}),P=function(t){Object(o.a)(r,t);var e=Object(s.a)(r);function r(){var t;return Object(i.a)(this,r),(t=e.apply(this,arguments)).selectRef=a.createRef(),t.focus=function(){t.selectRef.current.focus()},t.blur=function(){t.selectRef.current.blur()},t}return Object(n.a)(r,[{key:"render",value:function(){return a.createElement(M,Object.assign({ref:this.selectRef},this.props))}}]),r}(a.Component);P.Option=S,P.OptGroup=w;var N=P;e.c=N},M8RZ:
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/components/modal.tsx ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,r){"use strict";r.d(e,"a",(function(){return u}));var i=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/classCallCheck */"fWQN"),n=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createClass */"mtLc"),o=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/inherits */"yKVA"),s=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createSuper */"879j"),a=r(/*! react */"q1tI"),l=r.n(a),c=r(/*! react-dom */"i8i4"),u=function(t){Object(o.a)(r,t);var e=Object(s.a)(r);function r(t){var n;Object(i.a)(this,r),n=e.call(this,t);var o=window.document;return n.node=o.createElement("div"),o.body.appendChild(n.node),n}return Object(n.a)(r,[{key:"render",value:function(){var t=this.props.children;return Object(c.createPortal)(t,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),r}(l.a.Component)},Ot1p:
|
|
|
/*!**************************************************************!*\
|
|
|
!*** ./src/components/markdown-editor/index.tsx + 6 modules ***!
|
|
|
\**************************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/defineProperty.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/extends.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/regenerator/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/RenderHtml/index.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/markdown-editor/code-block/index.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/modal.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/useInterval.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/pages/tasks/util.js because of ./src/pages/tasks/index.jsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/env.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/fetch.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/util.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/button/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/button/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/form/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/form/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/input-number/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/input-number/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/input/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/input/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/message/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/message/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/modal/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/modal/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/popover/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/popover/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/radio/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/radio/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/codemirror/lib/codemirror.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/qrcode.react/lib/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js (<- Module uses injected variables (global)) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/uuid/dist/esm-browser/v4.js */function(t,e,r){"use strict";r("2qtc");var i=r("kLXV"),n=r("rAM+"),o=(r("miYZ"),r("tsqr")),s=r("9og8"),a=r("tJVT"),l=r("jrin"),c=r("WmNS"),u=r.n(c),h=r("q1tI"),d=r.n(h),f=r("VrN/"),p=r.n(f),g=r("bdgK"),m=(r("p77/"),r("Bd2K"),r("ELLl"),r("19Vz"),r("lZu9"),r("+NIl"),r("kSUc"),r("9Bee")),v=function(t){var e=t.value,r=void 0===e?"":e,i=(t.className,t.showTextOnly,t.showLines,t.style,Object(h.useMemo)((function(){return""}),[r]));return d.a.createElement(d.a.Fragment,null,d.a.createElement("div",{dangerouslySetInnerHTML:{__html:i}}))},y=(r("Q9mQ"),r("diRs")),b=r("0Owb"),x=(r("dejd"),r("C+DQ"),r("D1Df")),S=r.n(x),C=r("1vsH"),w=r("m3rI"),k=[{title:"粗体",icon:"icon-bold",actionName:"bold"},{title:"斜体",icon:"icon-italic",actionName:"italic"},"|",{title:"无序列表",icon:"icon-unorder-list",actionName:"list-ul"},{title:"有序列表",icon:"icon-order-list",actionName:"list-ol"},"|",{title:"行内代码",icon:"icon-code",actionName:"code"},{title:"代码块(多语言风格)",icon:"icon-file-code",actionName:"code-block"},{title:"链接",icon:"icon-link",actionName:"link"},"|",{title:"行内公式",icon:"icon-sum",actionName:"inline-latex"},{title:"多行公式",icon:"icon-formula",actionName:"latex"},"|",{title:"添加图片",icon:"icon-picture",actionName:"upload-image"},{title:"表格",icon:"icon-table",actionName:"add-table"},"|",{title:"换行",icon:"icon-minus",actionName:"line-break"},{title:"清空",icon:"icon-eraser",actionName:"eraser"}];function E(t){var e=t.onActionCallback,r=t.title,i=t.icon,n=t.actionName,o=t.className,s=void 0===o?"":o,a=t.children;return d.a.createElement("a",{title:r,className:s,onClick:function(){e(n)}},d.a.createElement("i",{className:"md-iconfont ".concat(i)}),a)}var T=function(t){var e=t.watch,r=t.showNullButton,i=t.onActionCallback,n=t.fullScreen,o=t.insertTemp,s=t.hidetoolBar,a=t.uuid,l=t.setOpenPhones,c=Object(C.E)("_educoder_session_login"),u=Object(C.E)("_educoder_session"),h=[].concat(k,[{title:"".concat(e?"关闭实时预览":"开启实时预览"),icon:"".concat(e?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return d.a.createElement("ul",{className:"markdown-toolbar-container"},!s&&h.map((function(t,e){return d.a.createElement("li",{key:e},t.actionName?d.a.createElement(E,Object(b.a)({},t,{onActionCallback:i})):d.a.createElement("span",{className:"v-line"}))})),r?d.a.createElement("li",null,d.a.createElement(E,{icon:"icon-edit",className:"btn-null",title:"增加填空",actionName:"add-null-ch",onActionCallback:i},d.a.createElement("span",{className:"fill-tip"},"点击插入\b填空项"))):null,o&&d.a.createElement("li",null,d.a.createElement(E,{icon:"icon-edit",className:"btn-null",title:"插入模板",actionName:"inster-template-".concat(o),onActionCallback:i},d.a.createElement("span",{className:"fill-tip"},"插入模板"))),d.a.createElement("li",null,d.a.createElement(y.a,{title:"打开手机扫一扫",content:d.a.createElement("div",null,d.a.createElement("span",{style:{display:"none"}},"test----",location.origin+"/upload.html?_educoder_session_login="+c+"&_educoder_session="+u+"&key="+a+"&api="+encodeURIComponent(w.a.API_SERVER)),d.a.createElement(S.a,{size:150,fgColor:"#000",value:location.origin+"/upload.html?_educoder_session_login="+c+"&_educoder_session="+u+"&key="+a+"&api="+encodeURIComponent(w.a.API_SERVER)}))},d.a.createElement("span",{className:"fill-tip",onMouseOver:function(){return l(!0)}},"手机上传文件"))),d.a.createElement("li",{className:"btn-full-screen"},d.a.createElement(E,{icon:"".concat(n?"icon-shrink":"icon-enlarge"),title:n?"关闭全屏":"开启全屏",actionName:"trigger-full-screen",onActionCallback:i})))},L=r("M8RZ"),A=(r("+L6B"),r("2/Rp")),D=(r("y8nQ"),r("Vl3Y")),O=(r("5NDa"),r("5rEg")),R={labelCol:{span:4},wrapperCol:{span:20}},_=function(t){var e=t.callback,r=t.onCancel;return d.a.createElement(D.a,Object(b.a)({},R,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:function(t){e(t)}}),d.a.createElement(D.a.Item,{label:"链接地址",name:"link",rules:[{required:!0,message:"请输入链接地址"}]},d.a.createElement(O.a,null)),d.a.createElement(D.a.Item,{label:"链接标题",name:"title",rules:[{required:!0,message:"请输入链接标题"}]},d.a.createElement(O.a,null)),d.a.createElement("div",{className:"flex-container flex-end"},d.a.createElement(A.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"确定"),d.a.createElement(A.a,{type:"ghost",onClick:r},"取消")))},I=r("7ahc"),M=r("k1fw"),P=(r("HmJG"),r("BjJ7")),N=D.a.useForm,F={width:280,marginRight:10},B={labelCol:{span:5},wrapperCol:{span:19}},j=function(t){var e=t.callback,r=t.onCancel,i=N(),n=Object(a.a)(i,1)[0],o=Object(h.useRef)();function s(t,e){n.setFieldsValue({src:"/api/attachments/".concat(t.id,"?type=").concat(t.content_type),type:e.type})}return d.a.createElement(D.a,Object(b.a)({form:n},B,{className:"upload-image-panel",onFinish:function(t){e(Object(M.a)(Object(M.a)({},t),{},{name:o.current}))}}),d.a.createElement(D.a.Item,{label:"文件地址",required:!0},d.a.createElement("div",{className:"flex-container"},d.a.createElement(D.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"请输入文件地址"}]},d.a.createElement(O.a,{style:F})),d.a.createElement(U,{onFileChange:function(t){var e=t.target.files[0];o.current=e.name,H(e,s)}}))),d.a.createElement(D.a.Item,{label:"文件描述",name:"alt"},d.a.createElement(O.a,{style:{width:264}})),d.a.createElement(D.a.Item,{style:{textAlign:"right"}},d.a.createElement(A.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"确定"),d.a.createElement(A.a,{type:"ghost",onClick:r},"取消")))};function U(t){var e=t.onFileChange;return d.a.createElement("a",{className:"upload-button"},"本地上传",d.a.createElement("input",{type:"file",onChange:e}))}function H(t,e){if(!t)throw new String("没有文件");var r=new FormData;r.append("editormd-image-file",t),r.append("file_param_name","editormd-image-file"),r.append("byxhr","true");var i=new window.XMLHttpRequest;i.withCredentials=!0,i.addEventListener("load",(function(r){e(JSON.parse(r.target.responseText),t)}),!1),i.addEventListener("error",(function(t){console.error(t)}),!1),i.open("POST","".concat(P.a,"/api/attachments.json")),i.send(r)}r("giR+");var G,z,W=r("fyUT"),V=(r("7Kak"),r("9yH6")),K=V.a.Group,q={margin:"0 8px"},Y=function(t){var e=t.callback,r=t.onCancel;return d.a.createElement(D.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:function(t){e(t)}},d.a.createElement("div",{className:"flex-container"},d.a.createElement("span",{style:q},"单元格数:"),d.a.createElement("span",{style:q},"行数"),d.a.createElement(D.a.Item,{name:"row",rules:[{required:!0,message:"请输入行数"}]},d.a.createElement(W.a,null)),d.a.createElement("span",{style:q},"列数"),d.a.createElement(D.a.Item,{name:"col",rules:[{required:!0,message:"请输入列数"}]},d.a.createElement(W.a,null))),d.a.createElement("div",{className:"flex-container",style:{marginTop:12}},d.a.createElement("span",{style:q},"对齐方式:"),d.a.createElement(D.a.Item,{name:"align"},d.a.createElement(K,null,d.a.createElement(V.a,{value:"default"},d.a.createElement("i",{className:"fa fa-align-justify"})),d.a.createElement(V.a,{value:"left"},d.a.createElement("i",{className:"fa fa-align-left"})),d.a.createElement(V.a,{value:"center"},d.a.createElement("i",{className:"fa fa-align-center"})),d.a.createElement(V.a,{value:"right"},d.a.createElement("i",{className:"fa fa-align-right"}))))),d.a.createElement("div",{className:"flex-container flex-end"},d.a.createElement(A.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"确定"),d.a.createElement(A.a,{type:"ghost",onClick:r},"取消")))},X=r("ErOA"),$=r("7Cbv"),Z="------------",Q={default:Z,left:":".concat(Z),center:":".concat(Z,":"),right:"".concat(Z,":")},J=r("9VGf");function tt(t){return/^\d+$/.test(t)?"".concat(t,"px"):t}var et=navigator.platform.toUpperCase().indexOf("MAC")>=0?"Cmd":"Ctrl",rt=["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"],it=(G={},Object(l.a)(G,et+"-B","bold"),Object(l.a)(G,et+"-I","italic"),G),nt=(z={},Object(l.a)(z,"link","添加链接"),Object(l.a)(z,"code-block","添加代码块"),Object(l.a)(z,"upload-image","添加文件"),Object(l.a)(z,"add-table","添加表格"),z);e.a=function(t){var e=t.defaultValue,r=void 0===e?"":e,c=t.onChange,f=t.width,y=void 0===f?"100%":f,b=t.height,x=void 0===b?400:b,S=t.miniToolbar,C=void 0!==S&&S,k=t.isFocus,E=void 0!==k&&k,A=t.watch,D=t.insertTemp,O=t.mode,R=void 0===O?"markdown":O,M=t.id,P=void 0===M?"markdown-editor-id":M,N=t.showResizeBar,F=void 0!==N&&N,B=t.noStorage,U=void 0!==B&&B,G=t.showNullButton,z=void 0!==G&&G,W=t.hidetoolBar,V=void 0!==W&&W,K=t.fullScreen,q=void 0!==K&&K,Z=t.onBlur,et=t.onCMBeforeChange,ot=t.onFullScreen,st=t.className,at=void 0===st?"":st,lt=t.disablePaste,ct=void 0!==lt&<,ut=t.placeholder,ht=void 0===ut?"":ut,dt=t.values,ft=void 0===dt?"":dt,pt=Object(h.useState)(null),gt=Object(a.a)(pt,2),mt=gt[0],vt=gt[1],yt=Object(h.useState)(r),bt=Object(a.a)(yt,2),xt=bt[0],St=bt[1],Ct=Object(h.useState)(A),wt=Object(a.a)(Ct,2),kt=wt[0],Et=wt[1],Tt=Object(h.useState)(q),Lt=Object(a.a)(Tt,2),At=Lt[0],Dt=Lt[1],Ot=Object(h.useState)(""),Rt=Object(a.a)(Ot,2),_t=Rt[0],It=Rt[1],Mt=Object(h.useState)(0),Pt=Object(a.a)(Mt,2),Nt=Pt[0],Ft=Pt[1],Bt=Object(h.useState)(x),jt=Object(a.a)(Bt,2),Ut=jt[0],Ht=jt[1],Gt=Object(h.useState)(!1),zt=Object(a.a)(Gt,2),Wt=(zt[0],zt[1]),Vt=Object(h.useRef)(Object($.a)()),Kt=Object(h.useRef)(!1),qt=Object(h.useRef)(),Yt=Object(h.useRef)(),Xt=Object(h.useRef)(),$t=Object(h.useRef)(),Zt=Object(h.useRef)(),Qt=function(){var t=Object(s.a)(u.a.mark((function t(){var e,r;return u.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(X.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:Vt.current}});case 2:null!=(r=t.sent)&&null!==(e=r.attachments)&&void 0!==e&&e.length&&(console.log("cm:",mt,Yt),r.attachments.map((function(t){t.content_type.indexOf("image")>-1?mt.replaceSelection(".concat(t.content_type,")")):t.content_type.indexOf("video")>-1?mt.replaceSelection('<video width="100%" controls src="'.concat(w.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):t.content_type.indexOf("pdf")>-1?mt.replaceSelection('<a href="'.concat(w.a.API_SERVER,"/api/attachments/").concat(t.id,"?type=").concat(t.content_type,'&disposition=inline" target="_blank">').concat(t.name,"</a>")):mt.replaceSelection("[".concat(t.name,"](").concat(w.a.API_SERVER,"/api/attachments/").concat(t.id,"?type=").concat(t.content_type,")"))})));case 4:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();Object(h.useEffect)((function(){St(ft),null==mt||mt.setValue(ft)}),[ft]),Object(h.useEffect)((function(){null==ot||ot(At)}),[At]),Object(h.useEffect)((function(){if(Yt.current){var t=p.a.fromTextArea(Yt.current,{mode:R,lineNumbers:!C,lineWrapping:!0,value:r,autoCloseTags:!0,autoCloseBrackets:!0});function e(e,r){if(!ct){var i=r.clipboardData;if(i){var n=i.types.toString(),s=i.items;if("Files"===n||i.types.indexOf("Files")>-1){if(r.preventDefault(),"stex"==R)return;try{var a,l=s[1];"file"===(null===(a=s[0])||void 0===a?void 0:a.kind)&&(l=s[0]);var c=l.getAsFile(),u=c.name.split(".").pop();H(c,(function(e){var r,i,n;e.id?(null==c||null===(r=c.type)||void 0===r?void 0:r.indexOf("image"))>-1?t.replaceSelection(".concat(e.content_type,")")):(null==c||null===(i=c.type)||void 0===i?void 0:i.indexOf("video"))>-1?t.replaceSelection('<video width="100%" controls src="'.concat(w.a.API_SERVER,"/api/attachments/").concat(e.id,'"></video>')):(null==c||null===(n=c.type)||void 0===n?void 0:n.indexOf("pdf"))>-1?t.replaceSelection('<a href="'.concat(w.a.API_SERVER,"/api/attachments/").concat(e.id,"?type=").concat(c.type,'&disposition=inline" target="_blank">').concat(c.name,"</a>")):rt.includes(u)?t.replaceSelection('<a href="'.concat(w.a.API_SERVER,"/api/attachments/").concat(e.id,'?type=office&disposition=inline" target="_blank">').concat(c.name,"</a>")):t.replaceSelection("[".concat(c.name,"](").concat(w.a.API_SERVER,"/api/attachments/").concat(e.id,"?type=").concat(e.content_type,")")):401===(null==e?void 0:e.status)&&(document.location.href="/user/login")}))}catch(r){o.b.warn("请使用chrome浏览器粘贴")}return!0}return!0}return!0}r.preventDefault()}return E&&t.focus(),t.on("paste",e),t.on("dragleave",(function(t,e){Xt.current.classList.remove("mouse-hover-md")})),t.on("dragover",(function(t,e){Xt.current.classList.add("mouse-hover-md")})),t.on("drop",(function(e,r){var i;if(Xt.current.classList.add("mouse-hover-md"),(i=r.dataTransfer.files).length>0){r.preventDefault(),r.stopPropagation();for(var n=function(e){var r=i[e],n=r.name.split(".").pop();H(r,(function(e){var i,o,s;e.id?(null==r||null===(i=r.type)||void 0===i?void 0:i.indexOf("image"))>-1?t.replaceSelection(".concat(e.content_type,")")):(null==r||null===(o=r.type)||void 0===o?void 0:o.indexOf("video"))>-1?t.replaceSelection('<video width="100%" controls src="'.concat(w.a.API_SERVER,"/api/attachments/").concat(e.id,'"></video>')):(null==r||null===(s=r.type)||void 0===s?void 0:s.indexOf("pdf"))>-1?t.replaceSelection('<a href="'.concat(w.a.API_SERVER,"/api/attachments/").concat(e.id,"?type=").concat(r.type,'&disposition=inline" target="_blank">').concat(r.name,"</a>")):rt.includes(n)?t.replaceSelection('<a href="'.concat(w.a.API_SERVER,"/api/attachments/").concat(e.id,'?type=office&disposition=inline" target="_blank">').concat(r.name,"</a>")):t.replaceSelection("[".concat(r.name,"](").concat(w.a.API_SERVER,"/api/attachments/").concat(e.id,"?type=").concat(e.content_type,")")):401===(null==e?void 0:e.status)&&(document.location.href="/user/login")}))},o=0;o<i.length;o++)n(o)}})),vt(t),function(){t.off("paste",e)}}}),[]);var Jt=Object(h.useCallback)((function(){Xt.current}),[Ut,Xt,At]);Object(h.useEffect)((function(){if(mt){var t=function(){var t=new g.default((function(t){var e,r=Object(n.a)(t);try{for(r.s();!(e=r.n()).done;){var i=e.value;(i.target.offsetHeight>0||i.target.offsetWidth>0)&&(Jt(),mt.setSize("100%","100%"),mt.refresh())}}catch(t){r.e(t)}finally{r.f()}}));return t.observe(Yt.current.parentElement),t}();return function(){t.unobserve(Yt.current.parentElement)}}}),[mt,Jt]),Object(h.useEffect)((function(){if(mt){for(var t=[],e=function(){var e=i[r],n=(o=Object(a.a)(e,2))[0],s=o[1],c=Object(l.a)({},n,(function(){te(s)}));t.push(c),mt.addKeyMap(c)},r=0,i=Object.entries(it);r<i.length;r++){var o;e()}return qt.current=setInterval((function(){Kt.current&&Qt()}),4e3),function(){clearInterval(qt.current);var e,r=Object(n.a)(t);try{for(r.s();!(e=r.n()).done;){var i=e.value;mt.removeKeyMap(i)}}catch(t){r.e(t)}finally{r.f()}}}}),[mt]),Object(h.useEffect)((function(){q!==At&&Dt(q)}),[q]),Object(J.a)((function(){if(!U&&Nt>0){var t=(new Date).getTime(),e=window.sessionStorage.getItem(P);t>=Nt+1e4&&(!e||e!==xt)&&(window.sessionStorage.setItem(P,xt),Wt(!0))}}),1e4),Object(h.useEffect)((function(){Et(A)}),[mt,A]),Object(h.useEffect)((function(){mt&&E&&mt.focus()}),[mt,E]),Object(h.useEffect)((function(){if(kt&&mt){var t=mt.getScrollerElement();function e(t){var e=t.target;if(Zt.current){var r=e.scrollTop/e.scrollHeight;Zt.current.scrollTop=Zt.current.scrollHeight*r}}return t.addEventListener("scroll",e),function(){t.removeEventListener("scroll",e)}}}),[mt,kt]),Object(h.useEffect)((function(){if(mt&&et){function t(t,e){et(t,e)}return mt.on("beforeChange",t),function(){mt.off("beforeChange",t)}}}),[mt,et]),Object(h.useEffect)((function(){if(mt&&Z){function t(){Z(mt.getValue())}return mt.on("blur",t),function(){mt.off("blur",t)}}}),[mt,Z]),Object(h.useEffect)((function(){if(mt){function t(t){var e=t.getValue();St(e),Ft((new Date).getTime()),t.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),c&&c(e)}return mt.on("change",t),function(){mt.off("change",t)}}}),[mt,c]),Object(h.useEffect)((function(){mt&&(null==r?(mt.setValue(""),St("")):r!==mt.getValue()&&(mt.setValue(r),St(r),mt.setCursor(mt.lineCount(),0)))}),[mt,r]);var te=Object(h.useCallback)((function(t){var e=mt.getCursor(),r=mt.getSelection(),i=r.split("\n");switch(t){case"bold":return mt.replaceSelection("**"+r+"**"),""===r&&mt.setCursor(e.line,e.ch+2),mt.focus();case"italic":return mt.replaceSelection("*"+r+"*"),""===r&&mt.setCursor(e.line,e.ch+1),mt.focus();case"code":return mt.replaceSelection("`"+r+"`"),""===r&&mt.setCursor(e.line,e.ch+1),mt.focus();case"inline-latex":return mt.replaceSelection("`$$"+r+"$$`"),""===r&&mt.setCursor(e.line,e.ch+3),mt.focus();case"latex":return mt.replaceSelection("```latex\n"+r+"\n```"),mt.setCursor(e.line+1,r.length+1),mt.focus();case"line-break":return mt.replaceSelection("<br/>\n"),mt.focus();case"list-ul":return""===r?mt.replaceSelection("- "+r):mt.replaceSelection(i.map((function(t){return""===t?"":"- ".concat(t)})).join("\n")),mt.focus();case"list-ol":return""===r?mt.replaceSelection("1. "+r):mt.replaceSelection(i.map((function(t,e){return""===t?"":"".concat(e+1,". ").concat(t)})).join("\n")),mt.focus();case"add-null-ch":return""===r&&mt.setCursor(e.line,e.ch+1),mt.replaceSelection("▁"),mt.focus();case"inster-template-1":return""===r&&mt.setCursor(e.line,e.ch),mt.replaceSelection("\n**模板标题**\n模板正文内容,可输入文本内容和粘贴图片等操作"),mt.focus();case"eraser":return mt.setValue(""),mt.focus();case"trigger-watch":return Et(!kt),mt.focus();case"trigger-full-screen":return Dt(!At),mt.focus();case"link":return void It("link");case"code-block":return void It("code-block");case"upload-image":return void It("upload-image");case"add-table":return void It("add-table");default:throw new Error}}),[mt,kt,At]),ee=Object(h.useCallback)((function(t){switch(It(""),_t){case"link":var e=t.title,r=t.link;return mt.replaceSelection("[".concat(e,"](").concat(r,")")),mt.focus();case"code-block":var i=t.language,n=t.content;return mt.replaceSelection(["```"+i,n,"```"].join("\n")),mt.focus();case"upload-image":var o=t.src,s=t.alt,a=t.name;return o.indexOf("type=image")>-1?mt.replaceSelection(".concat(o,' "').concat(s||"",'" )')):o.indexOf("type=application/pdf")>-1?mt.replaceSelection('<a href="'.concat(o,'&disposition=inline" target="_blank">').concat(a,"</a>")):mt.replaceSelection('<a href="'.concat(o,'" target="_blank">').concat(a,"</a>")),mt.focus();case"add-table":for(var l=t.row,c=t.col,u=t.align,h="\n",d=0;d<l;d++){for(var f=[],p=[],g=0;g<c;g++)1===d&&p.push(Q[u]),f.push(" ");1===d&&(h+="| ".concat(p.join(" | ")," |\n")),h+="| ".concat(f.join(1===c?"":" | ")," |\n")}return mt.replaceSelection(h+"\n"),mt.focus();default:throw new Error}}),[mt,_t]),re=Object(h.useMemo)((function(){switch(_t){case"link":return d.a.createElement(_,{callback:ee,onCancel:ie});case"code-block":return d.a.createElement(I.b,{callback:ee,onCancel:ie});case"upload-image":return d.a.createElement(j,{callback:ee,onCancel:ie});case"add-table":return d.a.createElement(Y,{callback:ee,onCancel:ie});default:return null}}),[_t]);function ie(){It("")}Object(h.useEffect)((function(){if($t.current){var t=$t.current,e=!1,r=0;function i(t){e=!0,r=t.pageY}function n(){e=!1}function o(t){if(e){var i=t.pageY-r;i<0&&(i=0),i>300&&(i=300),Ht(x+i+"px")}}return t.addEventListener("mousedown",i),document.addEventListener("mousemove",o),document.addEventListener("mouseup",n),function(){t.removeEventListener("mousedown",i),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",n)}}}),[mt,$t]),Object(h.useEffect)((function(){Ht(x)}),[x]);var ne={width:tt(y),height:tt(Ut)};Object(h.useMemo)((function(){if(Nt){var t=new Date(Nt),e=t.getHours(),r=t.getMinutes(),i=t.getSeconds();return r=r<10?"0"+r:r,i=i<10?"0"+i:i,"".concat(e=e<10?"0"+e:e,":").concat(r,":").concat(i)}return 0}),[Nt]);return d.a.createElement(h.Fragment,null,d.a.createElement("div",{className:"markdown-editor-wrapper",ref:Xt},d.a.createElement("div",{className:"markdown-editor-container ".concat(at," ").concat(kt?"on-preview":""," ").concat(C?"mini":""," ").concat(At?"full-screen":""),style:ne},d.a.createElement(T,{insertTemp:D,watch:kt,fullScreen:At,showNullButton:z,onActionCallback:te,hidetoolBar:V,uuid:Vt.current,setOpenPhones:function(){Kt.current=!0}}),d.a.createElement("div",{className:"markdown-editor-body"},d.a.createElement("div",{className:"codemirror-container"},d.a.createElement("textarea",{ref:Yt,placeholder:ht})),kt?d.a.createElement("div",{ref:Zt,className:"preview-container"},"stex"===R&&d.a.createElement(v,{value:xt}),"stex"!==R&&d.a.createElement(m.a,{edit:!0,value:xt,replaces:function(t,e){var r=mt.getValue();r=r.replace(t,e),St(r),null==mt||mt.setValue(r)}})):null))),F?d.a.createElement("a",{ref:$t,className:"editor-resize"}):null,d.a.createElement(L.a,null,nt[_t]?d.a.createElement(i.a,{centered:!0,title:nt[_t],visible:!0,onCancel:ie,footer:null},re):null))}},SJMd:
|
|
|
/*!****************************************************!*\
|
|
|
!*** ./node_modules/code-prettify/src/prettify.js ***!
|
|
|
\****************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e){window.PR_SHOULD_USE_CONTINUATION=!0,function(){var t=window,e=["break,continue,do,else,for,if,return,while"],r=[[e,"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"],"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],i=[r,"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"],n=[r,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],o=[r,"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"],s=[r,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],a="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",l=[e,"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=[e,"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"],u=[e,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],h=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/;function d(t,e,r,i,n){if(r){var o={sourceNode:t,pre:1,langExtension:null,numberLines:null,sourceCode:r,spans:null,basePos:e,decorations:null};i(o),n.push.apply(n,o.decorations)}}var f=/\S/;function p(t){for(var e=void 0,r=t.firstChild;r;r=r.nextSibling){var i=r.nodeType;e=1===i?e?t:r:3===i&&f.test(r.nodeValue)?t:e}return e===t?void 0:e}function g(t,e){var r,i={};!function(){for(var n=t.concat(e),o=[],s={},a=0,l=n.length;a<l;++a){var c=n[a],u=c[3];if(u)for(var h=u.length;--h>=0;)i[u.charAt(h)]=c;var d=c[1],f=""+d;s.hasOwnProperty(f)||(o.push(d),s[f]=null)}o.push(/[\0-\uffff]/),r=function(t){for(var e=0,r=!1,i=!1,n=0,o=t.length;n<o;++n){if((d=t[n]).ignoreCase)i=!0;else if(/[a-z]/i.test(d.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){r=!0,i=!1;break}}var s={b:8,t:9,n:10,v:11,f:12,r:13};function a(t){var e=t.charCodeAt(0);if(92!==e)return e;var r=t.charAt(1);return(e=s[r])||("0"<=r&&r<="7"?parseInt(t.substring(1),8):"u"===r||"x"===r?parseInt(t.substring(2),16):t.charCodeAt(1))}function l(t){if(t<32)return(t<16?"\\x0":"\\x")+t.toString(16);var e=String.fromCharCode(t);return"\\"===e||"-"===e||"]"===e||"^"===e?"\\"+e:e}function c(t){var e=t.substring(1,t.length-1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g")),r=[],i="^"===e[0],n=["["];i&&n.push("^");for(var o=i?1:0,s=e.length;o<s;++o){var c=e[o];if(/\\[bdsw]/i.test(c))n.push(c);else{var u,h=a(c);o+2<s&&"-"===e[o+1]?(u=a(e[o+2]),o+=2):u=h,r.push([h,u]),u<65||h>122||(u<65||h>90||r.push([32|Math.max(65,h),32|Math.min(u,90)]),u<97||h>122||r.push([-33&Math.max(97,h),-33&Math.min(u,122)]))}}r.sort((function(t,e){return t[0]-e[0]||e[1]-t[1]}));var d=[],f=[];for(o=0;o<r.length;++o){(p=r[o])[0]<=f[1]+1?f[1]=Math.max(f[1],p[1]):d.push(f=p)}for(o=0;o<d.length;++o){var p=d[o];n.push(l(p[0])),p[1]>p[0]&&(p[1]+1>p[0]&&n.push("-"),n.push(l(p[1])))}return n.push("]"),n.join("")}function u(t){for(var i=t.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")),n=i.length,o=[],s=0,a=0;s<n;++s){if("("===(h=i[s]))++a;else if("\\"===h.charAt(0)){(u=+h.substring(1))&&(u<=a?o[u]=-1:i[s]=l(u))}}for(s=1;s<o.length;++s)-1===o[s]&&(o[s]=++e);for(s=0,a=0;s<n;++s){if("("===(h=i[s]))o[++a]||(i[s]="(?:");else if("\\"===h.charAt(0)){var u;(u=+h.substring(1))&&u<=a&&(i[s]="\\"+o[u])}}for(s=0;s<n;++s)"^"===i[s]&&"^"!==i[s+1]&&(i[s]="");if(t.ignoreCase&&r)for(s=0;s<n;++s){var h,d=(h=i[s]).charAt(0);h.length>=2&&"["===d?i[s]=c(h):"\\"!==d&&(i[s]=h.replace(/[a-zA-Z]/g,(function(t){var e=t.charCodeAt(0);return"["+String.fromCharCode(-33&e,32|e)+"]"})))}return i.join("")}var h=[];for(n=0,o=t.length;n<o;++n){var d;if((d=t[n]).global||d.multiline)throw new Error(""+d);h.push("(?:"+u(d)+")")}return new RegExp(h.join("|"),i?"gi":"g")}(o)}();var n=e.length,o=function(t){for(var s=t.sourceCode,a=t.basePos,l=t.sourceNode,c=[a,"pln"],u=0,h=s.match(r)||[],f={},p=0,g=h.length;p<g;++p){var m,v=h[p],y=f[v],b=void 0;if("string"==typeof y)m=!1;else{var x=i[v.charAt(0)];if(x)b=v.match(x[1]),y=x[0];else{for(var C=0;C<n;++C)if(x=e[C],b=v.match(x[1])){y=x[0];break}b||(y="pln")}!(m=y.length>=5&&"lang-"===y.substring(0,5))||b&&"string"==typeof b[1]||(m=!1,y="src"),m||(f[v]=y)}var w=u;if(u+=v.length,m){var k=b[1],E=v.indexOf(k),T=E+k.length;b[2]&&(E=(T=v.length-b[2].length)-k.length);var L=y.substring(5);d(l,a+w,v.substring(0,E),o,c),d(l,a+w+E,k,S(L,k),c),d(l,a+w+T,v.substring(T),o,c)}else c.push(a+w,y)}t.decorations=c};return o}function m(t){var e=[],r=[];t.tripleQuotedStrings?e.push(["str",/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""]):t.multiLineStrings?e.push(["str",/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):e.push(["str",/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"]),t.verbatimStrings&&r.push(["str",/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var i=t.hashComments;i&&(t.cStyleComments?(i>1?e.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):e.push(["com",/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),r.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):e.push(["com",/^#[^\r\n]*/,null,"#"])),t.cStyleComments&&(r.push(["com",/^\/\/[^\r\n]*/,null]),r.push(["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var n=t.regexLiterals;if(n){var o=n>1?"":"\n\r",s=o?".":"[\\S\\s]",a="/(?=[^/*"+o+"])(?:[^/\\x5B\\x5C"+o+"]|\\x5C"+s+"|\\x5B(?:[^\\x5C\\x5D"+o+"]|\\x5C"+s+")*(?:\\x5D|$))+/";r.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+a+")")])}var l=t.types;l&&r.push(["typ",l]);var c=(""+t.keywords).replace(/^ | $/g,"");c.length&&r.push(["kwd",new RegExp("^(?:"+c.replace(/[\s,]+/g,"|")+")\\b"),null]),e.push(["pln",/^\s+/,null," \r\n\t "]);var u="^.[^\\s\\w.$@'\"`/\\\\]*";return t.regexLiterals&&(u+="(?!s*/)"),r.push(["lit",/^@[a-z_$][a-z_$@0-9]*/i,null],["typ",/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],["pln",/^[a-z_$][a-z_$@0-9]*/i,null],["lit",new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],["pln",/^\\[\s\S]?/,null],["pun",new RegExp(u),null]),g(e,r)}var v=m({keywords:[i,o,n,s,a,l,c,u],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function y(t,e,r){for(var i=/(?:^|\s)nocode(?:\s|$)/,n=/\r\n?|\n/,o=t.ownerDocument,s=o.createElement("li");t.firstChild;)s.appendChild(t.firstChild);var a=[s];function l(t){var e=t.nodeType;if(1!=e||i.test(t.className)){if((3==e||4==e)&&r){var s=t.nodeValue,a=s.match(n);if(a){var u=s.substring(0,a.index);t.nodeValue=u;var h=s.substring(a.index+a[0].length);if(h)t.parentNode.insertBefore(o.createTextNode(h),t.nextSibling);c(t),u||t.parentNode.removeChild(t)}}}else if("br"===t.nodeName)c(t),t.parentNode&&t.parentNode.removeChild(t);else for(var d=t.firstChild;d;d=d.nextSibling)l(d)}function c(t){for(;!t.nextSibling;)if(!(t=t.parentNode))return;for(var e,r=function t(e,r){var i=r?e.cloneNode(!1):e,n=e.parentNode;if(n){var o=t(n,1),s=e.nextSibling;o.appendChild(i);for(var a=s;a;a=s)s=a.nextSibling,o.appendChild(a)}return i}(t.nextSibling,0);(e=r.parentNode)&&1===e.nodeType;)r=e;a.push(r)}for(var u=0;u<a.length;++u)l(a[u]);e===(0|e)&&a[0].setAttribute("value",e);var h=o.createElement("ol");h.className="linenums";for(var d=Math.max(0,e-1|0)||0,f=(u=0,a.length);u<f;++u)(s=a[u]).className="L"+(u+d)%10,s.firstChild||s.appendChild(o.createTextNode(" ")),h.appendChild(s);t.appendChild(h)}var b={};function x(e,r){for(var i=r.length;--i>=0;){var n=r[i];b.hasOwnProperty(n)?t.console&&console.warn("cannot override language handler %s",n):b[n]=e}}function S(t,e){return t&&b.hasOwnProperty(t)||(t=/^\s*</.test(e)?"default-markup":"default-code"),b[t]}function C(e){var r,i,n,o,s,a,l,c=e.langExtension;try{var u=(r=e.sourceNode,i=e.pre,n=/(?:^|\s)nocode(?:\s|$)/,o=[],s=0,a=[],l=0,function t(e){var r=e.nodeType;if(1==r){if(n.test(e.className))return;for(var c=e.firstChild;c;c=c.nextSibling)t(c);var u=e.nodeName.toLowerCase();"br"!==u&&"li"!==u||(o[l]="\n",a[l<<1]=s++,a[l++<<1|1]=e)}else if(3==r||4==r){var h=e.nodeValue;h.length&&(h=i?h.replace(/\r\n?/g,"\n"):h.replace(/[ \t\r\n]+/g," "),o[l]=h,a[l<<1]=s,s+=h.length,a[l++<<1|1]=e)}}(r),{sourceCode:o.join("").replace(/\n$/,""),spans:a}),h=u.sourceCode;e.sourceCode=h,e.spans=u.spans,e.basePos=0,S(c,h)(e),function(t){var e=/\bMSIE\s(\d+)/.exec(navigator.userAgent);e=e&&+e[1]<=8;var r,i,n=/\n/g,o=t.sourceCode,s=o.length,a=0,l=t.spans,c=l.length,u=0,h=t.decorations,d=h.length,f=0;for(h[d]=s,i=r=0;i<d;)h[i]!==h[i+2]?(h[r++]=h[i++],h[r++]=h[i++]):i+=2;for(d=r,i=r=0;i<d;){for(var p=h[i],g=h[i+1],m=i+2;m+2<=d&&h[m+1]===g;)m+=2;h[r++]=p,h[r++]=g,i=m}d=h.length=r;var v=t.sourceNode,y="";v&&(y=v.style.display,v.style.display="none");try{for(;u<c;){l[u];var b,x=l[u+2]||s,S=h[f+2]||s,C=(m=Math.min(x,S),l[u+1]);if(1!==C.nodeType&&(b=o.substring(a,m))){e&&(b=b.replace(n,"\r")),C.nodeValue=b;var w=C.ownerDocument,k=w.createElement("span");k.className=h[f+1];var E=C.parentNode;E.replaceChild(k,C),k.appendChild(C),a<x&&(l[u+1]=C=w.createTextNode(o.substring(m,x)),E.insertBefore(C,k.nextSibling))}(a=m)>=x&&(u+=2),a>=S&&(f+=2)}}finally{v&&(v.style.display=y)}}(e)}catch(e){t.console&&console.log(e&&e.stack||e)}}function w(t,e,r){var i=r||!1,n=e||null,o=document.createElement("div");return o.innerHTML="<pre>"+t+"</pre>",o=o.firstChild,i&&y(o,i,!0),C({langExtension:n,numberLines:i,sourceNode:o,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null}),o.innerHTML}function k(e,r){var i=r||document.body,n=i.ownerDocument||document;function o(t){return i.getElementsByTagName(t)}for(var s=[o("pre"),o("code"),o("xmp")],a=[],l=0;l<s.length;++l)for(var c=0,u=s[l].length;c<u;++c)a.push(s[l][c]);s=null;var h=Date;h.now||(h={now:function(){return+new Date}});var d=0,f=/\blang(?:uage)?-([\w.]+)(?!\S)/,g=/\bprettyprint\b/,m=/\bprettyprinted\b/,v=/pre|xmp/i,b=/^code$/i,x=/^(?:pre|code|xmp)$/i,S={};!function r(){for(var i=t.PR_SHOULD_USE_CONTINUATION?h.now()+250:1/0;d<a.length&&h.now()<i;d++){for(var o=a[d],s=S,l=o;l=l.previousSibling;){var c=l.nodeType,u=(7===c||8===c)&&l.nodeValue;if(u?!/^\??prettify\b/.test(u):3!==c||/\S/.test(l.nodeValue))break;if(u){s={},u.replace(/\b(\w+)=([\w:.%+-]+)/g,(function(t,e,r){s[e]=r}));break}}var w=o.className;if((s!==S||g.test(w))&&!m.test(w)){for(var k=!1,E=o.parentNode;E;E=E.parentNode){var T=E.tagName;if(x.test(T)&&E.className&&g.test(E.className)){k=!0;break}}if(!k){o.className+=" prettyprinted";var L,A,D=s.lang;if(!D)!(D=w.match(f))&&(L=p(o))&&b.test(L.tagName)&&(D=L.className.match(f)),D&&(D=D[1]);if(v.test(o.tagName))A=1;else{var O=o.currentStyle,R=n.defaultView,_=O?O.whiteSpace:R&&R.getComputedStyle?R.getComputedStyle(o,null).getPropertyValue("white-space"):0;A=_&&"pre"===_.substring(0,3)}var I=s.linenums;(I="true"===I||+I)||(I=!!(I=w.match(/\blinenums\b(?::(\d+))?/))&&(!I[1]||!I[1].length||+I[1])),I&&y(o,I,A),C({langExtension:D,sourceNode:o,numberLines:I,pre:A,sourceCode:null,basePos:null,spans:null,decorations:null})}}}d<a.length?t.setTimeout(r,250):"function"==typeof e&&e()}()}x(v,["default-code"]),x(g([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]),x(g([["pln",/^[\s]+/,null," \t\r\n"],["atv",/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],["pun",/^[=<>\/]+/],["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"]),x(g([],[["atv",/^[\s\S]+/]]),["uq.val"]),x(m({keywords:i,hashComments:!0,cStyleComments:!0,types:h}),["c","cc","cpp","cxx","cyc","m"]),x(m({keywords:"null,true,false"}),["json"]),x(m({keywords:o,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:h}),["cs"]),x(m({keywords:n,cStyleComments:!0}),["java"]),x(m({keywords:u,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),x(m({keywords:l,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),x(m({keywords:a,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),x(m({keywords:c,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),x(m({keywords:s,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),x(m({keywords:"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",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),x(g([],[["str",/^[\s\S]+/]]),["regex"]);var E=t.PR={createSimpleLexer:g,registerLangHandler:x,sourceDecorator:m,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:w,prettyPrint:k},T=t.define;"function"==typeof T&&T.amd&&T("google-code-prettify",[],(function(){return E}))}()},"VrN/":
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./node_modules/codemirror/lib/codemirror.js ***!
|
|
|
\***************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){t.exports=function(){"use strict";var t=navigator.userAgent,e=navigator.platform,r=/gecko\/\d/i.test(t),i=/MSIE \d/.test(t),n=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(t),o=/Edge\/(\d+)/.exec(t),s=i||n||o,a=s&&(i?document.documentMode||6:+(o||n)[1]),l=!o&&/WebKit\//.test(t),c=l&&/Qt\/\d+\.\d+/.test(t),u=!o&&/Chrome\//.test(t),h=/Opera\//.test(t),d=/Apple Computer/.test(navigator.vendor),f=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(t),p=/PhantomJS/.test(t),g=!o&&/AppleWebKit/.test(t)&&/Mobile\/\w+/.test(t),m=/Android/.test(t),v=g||m||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(t),y=g||/Mac/.test(e),b=/\bCrOS\b/.test(t),x=/win/i.test(e),S=h&&t.match(/Version\/(\d*\.\d*)/);S&&(S=Number(S[1])),S&&S>=15&&(h=!1,l=!0);var C=y&&(c||h&&(null==S||S<12.11)),w=r||s&&a>=9;function k(t){return new RegExp("(^|\\s)"+t+"(?:$|\\s)\\s*")}var E,T=function(t,e){var r=t.className,i=k(e).exec(r);if(i){var n=r.slice(i.index+i[0].length);t.className=r.slice(0,i.index)+(n?i[1]+n:"")}};function L(t){for(var e=t.childNodes.length;e>0;--e)t.removeChild(t.firstChild);return t}function A(t,e){return L(t).appendChild(e)}function D(t,e,r,i){var n=document.createElement(t);if(r&&(n.className=r),i&&(n.style.cssText=i),"string"==typeof e)n.appendChild(document.createTextNode(e));else if(e)for(var o=0;o<e.length;++o)n.appendChild(e[o]);return n}function O(t,e,r,i){var n=D(t,e,r,i);return n.setAttribute("role","presentation"),n}function R(t,e){if(3==e.nodeType&&(e=e.parentNode),t.contains)return t.contains(e);do{if(11==e.nodeType&&(e=e.host),e==t)return!0}while(e=e.parentNode)}function _(){var t;try{t=document.activeElement}catch(e){t=document.body||null}for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t}function I(t,e){var r=t.className;k(e).test(r)||(t.className+=(r?" ":"")+e)}function M(t,e){for(var r=t.split(" "),i=0;i<r.length;i++)r[i]&&!k(r[i]).test(e)&&(e+=" "+r[i]);return e}E=document.createRange?function(t,e,r,i){var n=document.createRange();return n.setEnd(i||t,r),n.setStart(t,e),n}:function(t,e,r){var i=document.body.createTextRange();try{i.moveToElementText(t.parentNode)}catch(t){return i}return i.collapse(!0),i.moveEnd("character",r),i.moveStart("character",e),i};var P=function(t){t.select()};function N(t){var e=Array.prototype.slice.call(arguments,1);return function(){return t.apply(null,e)}}function F(t,e,r){for(var i in e||(e={}),t)!t.hasOwnProperty(i)||!1===r&&e.hasOwnProperty(i)||(e[i]=t[i]);return e}function B(t,e,r,i,n){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);for(var o=i||0,s=n||0;;){var a=t.indexOf("\t",o);if(a<0||a>=e)return s+(e-o);s+=a-o,s+=r-s%r,o=a+1}}g?P=function(t){t.selectionStart=0,t.selectionEnd=t.value.length}:s&&(P=function(t){try{t.select()}catch(t){}});var j=function(){this.id=null,this.f=null,this.time=0,this.handler=N(this.onTimeout,this)};function U(t,e){for(var r=0;r<t.length;++r)if(t[r]==e)return r;return-1}j.prototype.onTimeout=function(t){t.id=0,t.time<=+new Date?t.f():setTimeout(t.handler,t.time-+new Date)},j.prototype.set=function(t,e){this.f=e;var r=+new Date+t;(!this.id||r<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,t),this.time=r)};var H={toString:function(){return"CodeMirror.Pass"}},G={scroll:!1},z={origin:"*mouse"},W={origin:"+move"};function V(t,e,r){for(var i=0,n=0;;){var o=t.indexOf("\t",i);-1==o&&(o=t.length);var s=o-i;if(o==t.length||n+s>=e)return i+Math.min(s,e-n);if(n+=o-i,i=o+1,(n+=r-n%r)>=e)return i}}var K=[""];function q(t){for(;K.length<=t;)K.push(Y(K)+" ");return K[t]}function Y(t){return t[t.length-1]}function X(t,e){for(var r=[],i=0;i<t.length;i++)r[i]=e(t[i],i);return r}function $(){}function Z(t,e){var r;return Object.create?r=Object.create(t):($.prototype=t,r=new $),e&&F(e,r),r}var Q=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function J(t){return/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||Q.test(t))}function tt(t,e){return e?!!(e.source.indexOf("\\w")>-1&&J(t))||e.test(t):J(t)}function et(t){for(var e in t)if(t.hasOwnProperty(e)&&t[e])return!1;return!0}var rt=/[\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 it(t){return t.charCodeAt(0)>=768&&rt.test(t)}function nt(t,e,r){for(;(r<0?e>0:e<t.length)&&it(t.charAt(e));)e+=r;return e}function ot(t,e,r){for(var i=e>r?-1:1;;){if(e==r)return e;var n=(e+r)/2,o=i<0?Math.ceil(n):Math.floor(n);if(o==e)return t(o)?e:r;t(o)?r=o:e=o+i}}var st=null;function at(t,e,r){var i;st=null;for(var n=0;n<t.length;++n){var o=t[n];if(o.from<e&&o.to>e)return n;o.to==e&&(o.from!=o.to&&"before"==r?i=n:st=n),o.from==e&&(o.from!=o.to&&"before"!=r?i=n:st=n)}return null!=i?i:st}var lt=function(){var t=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,e=/[stwN]/,r=/[LRr]/,i=/[Lb1n]/,n=/[1n]/;function o(t,e,r){this.level=t,this.from=e,this.to=r}return function(s,a){var l="ltr"==a?"L":"R";if(0==s.length||"ltr"==a&&!t.test(s))return!1;for(var c,u=s.length,h=[],d=0;d<u;++d)h.push((c=s.charCodeAt(d))<=247?"bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN".charAt(c):1424<=c&&c<=1524?"R":1536<=c&&c<=1785?"nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111".charAt(c-1536):1774<=c&&c<=2220?"r":8192<=c&&c<=8203?"w":8204==c?"b":"L");for(var f=0,p=l;f<u;++f){var g=h[f];"m"==g?h[f]=p:p=g}for(var m=0,v=l;m<u;++m){var y=h[m];"1"==y&&"r"==v?h[m]="n":r.test(y)&&(v=y,"r"==y&&(h[m]="R"))}for(var b=1,x=h[0];b<u-1;++b){var S=h[b];"+"==S&&"1"==x&&"1"==h[b+1]?h[b]="1":","!=S||x!=h[b+1]||"1"!=x&&"n"!=x||(h[b]=x),x=S}for(var C=0;C<u;++C){var w=h[C];if(","==w)h[C]="N";else if("%"==w){var k=void 0;for(k=C+1;k<u&&"%"==h[k];++k);for(var E=C&&"!"==h[C-1]||k<u&&"1"==h[k]?"1":"N",T=C;T<k;++T)h[T]=E;C=k-1}}for(var L=0,A=l;L<u;++L){var D=h[L];"L"==A&&"1"==D?h[L]="L":r.test(D)&&(A=D)}for(var O=0;O<u;++O)if(e.test(h[O])){var R=void 0;for(R=O+1;R<u&&e.test(h[R]);++R);for(var _="L"==(O?h[O-1]:l),I=_==("L"==(R<u?h[R]:l))?_?"L":"R":l,M=O;M<R;++M)h[M]=I;O=R-1}for(var P,N=[],F=0;F<u;)if(i.test(h[F])){var B=F;for(++F;F<u&&i.test(h[F]);++F);N.push(new o(0,B,F))}else{var j=F,U=N.length,H="rtl"==a?1:0;for(++F;F<u&&"L"!=h[F];++F);for(var G=j;G<F;)if(n.test(h[G])){j<G&&(N.splice(U,0,new o(1,j,G)),U+=H);var z=G;for(++G;G<F&&n.test(h[G]);++G);N.splice(U,0,new o(2,z,G)),U+=H,j=G}else++G;j<F&&N.splice(U,0,new o(1,j,F))}return"ltr"==a&&(1==N[0].level&&(P=s.match(/^\s+/))&&(N[0].from=P[0].length,N.unshift(new o(0,0,P[0].length))),1==Y(N).level&&(P=s.match(/\s+$/))&&(Y(N).to-=P[0].length,N.push(new o(0,u-P[0].length,u)))),"rtl"==a?N.reverse():N}}();function ct(t,e){var r=t.order;return null==r&&(r=t.order=lt(t.text,e)),r}var ut=[],ht=function(t,e,r){if(t.addEventListener)t.addEventListener(e,r,!1);else if(t.attachEvent)t.attachEvent("on"+e,r);else{var i=t._handlers||(t._handlers={});i[e]=(i[e]||ut).concat(r)}};function dt(t,e){return t._handlers&&t._handlers[e]||ut}function ft(t,e,r){if(t.removeEventListener)t.removeEventListener(e,r,!1);else if(t.detachEvent)t.detachEvent("on"+e,r);else{var i=t._handlers,n=i&&i[e];if(n){var o=U(n,r);o>-1&&(i[e]=n.slice(0,o).concat(n.slice(o+1)))}}}function pt(t,e){var r=dt(t,e);if(r.length)for(var i=Array.prototype.slice.call(arguments,2),n=0;n<r.length;++n)r[n].apply(null,i)}function gt(t,e,r){return"string"==typeof e&&(e={type:e,preventDefault:function(){this.defaultPrevented=!0}}),pt(t,r||e.type,t,e),St(e)||e.codemirrorIgnore}function mt(t){var e=t._handlers&&t._handlers.cursorActivity;if(e)for(var r=t.curOp.cursorActivityHandlers||(t.curOp.cursorActivityHandlers=[]),i=0;i<e.length;++i)-1==U(r,e[i])&&r.push(e[i])}function vt(t,e){return dt(t,e).length>0}function yt(t){t.prototype.on=function(t,e){ht(this,t,e)},t.prototype.off=function(t,e){ft(this,t,e)}}function bt(t){t.preventDefault?t.preventDefault():t.returnValue=!1}function xt(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0}function St(t){return null!=t.defaultPrevented?t.defaultPrevented:0==t.returnValue}function Ct(t){bt(t),xt(t)}function wt(t){return t.target||t.srcElement}function kt(t){var e=t.which;return null==e&&(1&t.button?e=1:2&t.button?e=3:4&t.button&&(e=2)),y&&t.ctrlKey&&1==e&&(e=3),e}var Et,Tt,Lt=function(){if(s&&a<9)return!1;var t=D("div");return"draggable"in t||"dragDrop"in t}();function At(t){if(null==Et){var e=D("span","");A(t,D("span",[e,document.createTextNode("x")])),0!=t.firstChild.offsetHeight&&(Et=e.offsetWidth<=1&&e.offsetHeight>2&&!(s&&a<8))}var r=Et?D("span",""):D("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function Dt(t){if(null!=Tt)return Tt;var e=A(t,document.createTextNode("AخA")),r=E(e,0,1).getBoundingClientRect(),i=E(e,1,2).getBoundingClientRect();return L(t),!(!r||r.left==r.right)&&(Tt=i.right-r.right<3)}var Ot,Rt=3!="\n\nb".split(/\n/).length?function(t){for(var e=0,r=[],i=t.length;e<=i;){var n=t.indexOf("\n",e);-1==n&&(n=t.length);var o=t.slice(e,"\r"==t.charAt(n-1)?n-1:n),s=o.indexOf("\r");-1!=s?(r.push(o.slice(0,s)),e+=s+1):(r.push(o),e=n+1)}return r}:function(t){return t.split(/\r\n?|\n/)},_t=window.getSelection?function(t){try{return t.selectionStart!=t.selectionEnd}catch(t){return!1}}:function(t){var e;try{e=t.ownerDocument.selection.createRange()}catch(t){}return!(!e||e.parentElement()!=t)&&0!=e.compareEndPoints("StartToEnd",e)},It="oncopy"in(Ot=D("div"))||(Ot.setAttribute("oncopy","return;"),"function"==typeof Ot.oncopy),Mt=null,Pt={},Nt={};function Ft(t,e){arguments.length>2&&(e.dependencies=Array.prototype.slice.call(arguments,2)),Pt[t]=e}function Bt(t){if("string"==typeof t&&Nt.hasOwnProperty(t))t=Nt[t];else if(t&&"string"==typeof t.name&&Nt.hasOwnProperty(t.name)){var e=Nt[t.name];"string"==typeof e&&(e={name:e}),(t=Z(e,t)).name=e.name}else{if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return Bt("application/xml");if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+json$/.test(t))return Bt("application/json")}return"string"==typeof t?{name:t}:t||{name:"null"}}function jt(t,e){e=Bt(e);var r=Pt[e.name];if(!r)return jt(t,"text/plain");var i=r(t,e);if(Ut.hasOwnProperty(e.name)){var n=Ut[e.name];for(var o in n)n.hasOwnProperty(o)&&(i.hasOwnProperty(o)&&(i["_"+o]=i[o]),i[o]=n[o])}if(i.name=e.name,e.helperType&&(i.helperType=e.helperType),e.modeProps)for(var s in e.modeProps)i[s]=e.modeProps[s];return i}var Ut={};function Ht(t,e){F(e,Ut.hasOwnProperty(t)?Ut[t]:Ut[t]={})}function Gt(t,e){if(!0===e)return e;if(t.copyState)return t.copyState(e);var r={};for(var i in e){var n=e[i];n instanceof Array&&(n=n.concat([])),r[i]=n}return r}function zt(t,e){for(var r;t.innerMode&&(r=t.innerMode(e))&&r.mode!=t;)e=r.state,t=r.mode;return r||{mode:t,state:e}}function Wt(t,e,r){return!t.startState||t.startState(e,r)}var Vt=function(t,e,r){this.pos=this.start=0,this.string=t,this.tabSize=e||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=r};function Kt(t,e){if((e-=t.first)<0||e>=t.size)throw new Error("There is no line "+(e+t.first)+" in the document.");for(var r=t;!r.lines;)for(var i=0;;++i){var n=r.children[i],o=n.chunkSize();if(e<o){r=n;break}e-=o}return r.lines[e]}function qt(t,e,r){var i=[],n=e.line;return t.iter(e.line,r.line+1,(function(t){var o=t.text;n==r.line&&(o=o.slice(0,r.ch)),n==e.line&&(o=o.slice(e.ch)),i.push(o),++n})),i}function Yt(t,e,r){var i=[];return t.iter(e,r,(function(t){i.push(t.text)})),i}function Xt(t,e){var r=e-t.height;if(r)for(var i=t;i;i=i.parent)i.height+=r}function $t(t){if(null==t.parent)return null;for(var e=t.parent,r=U(e.lines,t),i=e.parent;i;e=i,i=i.parent)for(var n=0;i.children[n]!=e;++n)r+=i.children[n].chunkSize();return r+e.first}function Zt(t,e){var r=t.first;t:do{for(var i=0;i<t.children.length;++i){var n=t.children[i],o=n.height;if(e<o){t=n;continue t}e-=o,r+=n.chunkSize()}return r}while(!t.lines);for(var s=0;s<t.lines.length;++s){var a=t.lines[s].height;if(e<a)break;e-=a}return r+s}function Qt(t,e){return e>=t.first&&e<t.first+t.size}function Jt(t,e){return String(t.lineNumberFormatter(e+t.firstLineNumber))}function te(t,e,r){if(void 0===r&&(r=null),!(this instanceof te))return new te(t,e,r);this.line=t,this.ch=e,this.sticky=r}function ee(t,e){return t.line-e.line||t.ch-e.ch}function re(t,e){return t.sticky==e.sticky&&0==ee(t,e)}function ie(t){return te(t.line,t.ch)}function ne(t,e){return ee(t,e)<0?e:t}function oe(t,e){return ee(t,e)<0?t:e}function se(t,e){return Math.max(t.first,Math.min(e,t.first+t.size-1))}function ae(t,e){if(e.line<t.first)return te(t.first,0);var r=t.first+t.size-1;return e.line>r?te(r,Kt(t,r).text.length):function(t,e){var r=t.ch;return null==r||r>e?te(t.line,e):r<0?te(t.line,0):t}(e,Kt(t,e.line).text.length)}function le(t,e){for(var r=[],i=0;i<e.length;i++)r[i]=ae(t,e[i]);return r}Vt.prototype.eol=function(){return this.pos>=this.string.length},Vt.prototype.sol=function(){return this.pos==this.lineStart},Vt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Vt.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},Vt.prototype.eat=function(t){var e=this.string.charAt(this.pos);if("string"==typeof t?e==t:e&&(t.test?t.test(e):t(e)))return++this.pos,e},Vt.prototype.eatWhile=function(t){for(var e=this.pos;this.eat(t););return this.pos>e},Vt.prototype.eatSpace=function(){for(var t=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t},Vt.prototype.skipToEnd=function(){this.pos=this.string.length},Vt.prototype.skipTo=function(t){var e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0},Vt.prototype.backUp=function(t){this.pos-=t},Vt.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=B(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?B(this.string,this.lineStart,this.tabSize):0)},Vt.prototype.indentation=function(){return B(this.string,null,this.tabSize)-(this.lineStart?B(this.string,this.lineStart,this.tabSize):0)},Vt.prototype.match=function(t,e,r){if("string"!=typeof t){var i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&!1!==e&&(this.pos+=i[0].length),i)}var n=function(t){return r?t.toLowerCase():t};if(n(this.string.substr(this.pos,t.length))==n(t))return!1!==e&&(this.pos+=t.length),!0},Vt.prototype.current=function(){return this.string.slice(this.start,this.pos)},Vt.prototype.hideFirstChars=function(t,e){this.lineStart+=t;try{return e()}finally{this.lineStart-=t}},Vt.prototype.lookAhead=function(t){var e=this.lineOracle;return e&&e.lookAhead(t)},Vt.prototype.baseToken=function(){var t=this.lineOracle;return t&&t.baseToken(this.pos)};var ce=function(t,e){this.state=t,this.lookAhead=e},ue=function(t,e,r,i){this.state=e,this.doc=t,this.line=r,this.maxLookAhead=i||0,this.baseTokens=null,this.baseTokenPos=1};function he(t,e,r,i){var n=[t.state.modeGen],o={};xe(t,e.text,t.doc.mode,r,(function(t,e){return n.push(t,e)}),o,i);for(var s=r.state,a=function(i){r.baseTokens=n;var a=t.state.overlays[i],l=1,c=0;r.state=!0,xe(t,e.text,a.mode,r,(function(t,e){for(var r=l;c<t;){var i=n[l];i>t&&n.splice(l,1,t,n[l+1],i),l+=2,c=Math.min(t,i)}if(e)if(a.opaque)n.splice(r,l-r,t,"overlay "+e),l=r+2;else for(;r<l;r+=2){var o=n[r+1];n[r+1]=(o?o+" ":"")+"overlay "+e}}),o),r.state=s,r.baseTokens=null,r.baseTokenPos=1},l=0;l<t.state.overlays.length;++l)a(l);return{styles:n,classes:o.bgClass||o.textClass?o:null}}function de(t,e,r){if(!e.styles||e.styles[0]!=t.state.modeGen){var i=fe(t,$t(e)),n=e.text.length>t.options.maxHighlightLength&&Gt(t.doc.mode,i.state),o=he(t,e,i);n&&(i.state=n),e.stateAfter=i.save(!n),e.styles=o.styles,o.classes?e.styleClasses=o.classes:e.styleClasses&&(e.styleClasses=null),r===t.doc.highlightFrontier&&(t.doc.modeFrontier=Math.max(t.doc.modeFrontier,++t.doc.highlightFrontier))}return e.styles}function fe(t,e,r){var i=t.doc,n=t.display;if(!i.mode.startState)return new ue(i,!0,e);var o=function(t,e,r){for(var i,n,o=t.doc,s=r?-1:e-(t.doc.mode.innerMode?1e3:100),a=e;a>s;--a){if(a<=o.first)return o.first;var l=Kt(o,a-1),c=l.stateAfter;if(c&&(!r||a+(c instanceof ce?c.lookAhead:0)<=o.modeFrontier))return a;var u=B(l.text,null,t.options.tabSize);(null==n||i>u)&&(n=a-1,i=u)}return n}(t,e,r),s=o>i.first&&Kt(i,o-1).stateAfter,a=s?ue.fromSaved(i,s,o):new ue(i,Wt(i.mode),o);return i.iter(o,e,(function(r){pe(t,r.text,a);var i=a.line;r.stateAfter=i==e-1||i%5==0||i>=n.viewFrom&&i<n.viewTo?a.save():null,a.nextLine()})),r&&(i.modeFrontier=a.line),a}function pe(t,e,r,i){var n=t.doc.mode,o=new Vt(e,t.options.tabSize,r);for(o.start=o.pos=i||0,""==e&&ge(n,r.state);!o.eol();)me(n,o,r.state),o.start=o.pos}function ge(t,e){if(t.blankLine)return t.blankLine(e);if(t.innerMode){var r=zt(t,e);return r.mode.blankLine?r.mode.blankLine(r.state):void 0}}function me(t,e,r,i){for(var n=0;n<10;n++){i&&(i[0]=zt(t,r).mode);var o=t.token(e,r);if(e.pos>e.start)return o}throw new Error("Mode "+t.name+" failed to advance stream.")}ue.prototype.lookAhead=function(t){var e=this.doc.getLine(this.line+t);return null!=e&&t>this.maxLookAhead&&(this.maxLookAhead=t),e},ue.prototype.baseToken=function(t){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=t;)this.baseTokenPos+=2;var e=this.baseTokens[this.baseTokenPos+1];return{type:e&&e.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-t}},ue.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},ue.fromSaved=function(t,e,r){return e instanceof ce?new ue(t,Gt(t.mode,e.state),r,e.lookAhead):new ue(t,Gt(t.mode,e),r)},ue.prototype.save=function(t){var e=!1!==t?Gt(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new ce(e,this.maxLookAhead):e};var ve=function(t,e,r){this.start=t.start,this.end=t.pos,this.string=t.current(),this.type=e||null,this.state=r};function ye(t,e,r,i){var n,o,s=t.doc,a=s.mode,l=Kt(s,(e=ae(s,e)).line),c=fe(t,e.line,r),u=new Vt(l.text,t.options.tabSize,c);for(i&&(o=[]);(i||u.pos<e.ch)&&!u.eol();)u.start=u.pos,n=me(a,u,c.state),i&&o.push(new ve(u,n,Gt(s.mode,c.state)));return i?o:new ve(u,n,c.state)}function be(t,e){if(t)for(;;){var r=t.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!r)break;t=t.slice(0,r.index)+t.slice(r.index+r[0].length);var i=r[1]?"bgClass":"textClass";null==e[i]?e[i]=r[2]:new RegExp("(?:^|\\s)"+r[2]+"(?:$|\\s)").test(e[i])||(e[i]+=" "+r[2])}return t}function xe(t,e,r,i,n,o,s){var a=r.flattenSpans;null==a&&(a=t.options.flattenSpans);var l,c=0,u=null,h=new Vt(e,t.options.tabSize,i),d=t.options.addModeClass&&[null];for(""==e&&be(ge(r,i.state),o);!h.eol();){if(h.pos>t.options.maxHighlightLength?(a=!1,s&&pe(t,e,i,h.pos),h.pos=e.length,l=null):l=be(me(r,h,i.state,d),o),d){var f=d[0].name;f&&(l="m-"+(l?f+" "+l:f))}if(!a||u!=l){for(;c<h.start;)n(c=Math.min(h.start,c+5e3),u);u=l}h.start=h.pos}for(;c<h.pos;){var p=Math.min(h.pos,c+5e3);n(p,u),c=p}}var Se=!1,Ce=!1;function we(t,e,r){this.marker=t,this.from=e,this.to=r}function ke(t,e){if(t)for(var r=0;r<t.length;++r){var i=t[r];if(i.marker==e)return i}}function Ee(t,e){for(var r,i=0;i<t.length;++i)t[i]!=e&&(r||(r=[])).push(t[i]);return r}function Te(t,e){if(e.full)return null;var r=Qt(t,e.from.line)&&Kt(t,e.from.line).markedSpans,i=Qt(t,e.to.line)&&Kt(t,e.to.line).markedSpans;if(!r&&!i)return null;var n=e.from.ch,o=e.to.ch,s=0==ee(e.from,e.to),a=function(t,e,r){var i;if(t)for(var n=0;n<t.length;++n){var o=t[n],s=o.marker;if(null==o.from||(s.inclusiveLeft?o.from<=e:o.from<e)||o.from==e&&"bookmark"==s.type&&(!r||!o.marker.insertLeft)){var a=null==o.to||(s.inclusiveRight?o.to>=e:o.to>e);(i||(i=[])).push(new we(s,o.from,a?null:o.to))}}return i}(r,n,s),l=function(t,e,r){var i;if(t)for(var n=0;n<t.length;++n){var o=t[n],s=o.marker;if(null==o.to||(s.inclusiveRight?o.to>=e:o.to>e)||o.from==e&&"bookmark"==s.type&&(!r||o.marker.insertLeft)){var a=null==o.from||(s.inclusiveLeft?o.from<=e:o.from<e);(i||(i=[])).push(new we(s,a?null:o.from-e,null==o.to?null:o.to-e))}}return i}(i,o,s),c=1==e.text.length,u=Y(e.text).length+(c?n:0);if(a)for(var h=0;h<a.length;++h){var d=a[h];if(null==d.to){var f=ke(l,d.marker);f?c&&(d.to=null==f.to?null:f.to+u):d.to=n}}if(l)for(var p=0;p<l.length;++p){var g=l[p];null!=g.to&&(g.to+=u),null==g.from?ke(a,g.marker)||(g.from=u,c&&(a||(a=[])).push(g)):(g.from+=u,c&&(a||(a=[])).push(g))}a&&(a=Le(a)),l&&l!=a&&(l=Le(l));var m=[a];if(!c){var v,y=e.text.length-2;if(y>0&&a)for(var b=0;b<a.length;++b)null==a[b].to&&(v||(v=[])).push(new we(a[b].marker,null,null));for(var x=0;x<y;++x)m.push(v);m.push(l)}return m}function Le(t){for(var e=0;e<t.length;++e){var r=t[e];null!=r.from&&r.from==r.to&&!1!==r.marker.clearWhenEmpty&&t.splice(e--,1)}return t.length?t:null}function Ae(t){var e=t.markedSpans;if(e){for(var r=0;r<e.length;++r)e[r].marker.detachLine(t);t.markedSpans=null}}function De(t,e){if(e){for(var r=0;r<e.length;++r)e[r].marker.attachLine(t);t.markedSpans=e}}function Oe(t){return t.inclusiveLeft?-1:0}function Re(t){return t.inclusiveRight?1:0}function _e(t,e){var r=t.lines.length-e.lines.length;if(0!=r)return r;var i=t.find(),n=e.find(),o=ee(i.from,n.from)||Oe(t)-Oe(e);if(o)return-o;var s=ee(i.to,n.to)||Re(t)-Re(e);return s||e.id-t.id}function Ie(t,e){var r,i=Ce&&t.markedSpans;if(i)for(var n=void 0,o=0;o<i.length;++o)(n=i[o]).marker.collapsed&&null==(e?n.from:n.to)&&(!r||_e(r,n.marker)<0)&&(r=n.marker);return r}function Me(t){return Ie(t,!0)}function Pe(t){return Ie(t,!1)}function Ne(t,e){var r,i=Ce&&t.markedSpans;if(i)for(var n=0;n<i.length;++n){var o=i[n];o.marker.collapsed&&(null==o.from||o.from<e)&&(null==o.to||o.to>e)&&(!r||_e(r,o.marker)<0)&&(r=o.marker)}return r}function Fe(t,e,r,i,n){var o=Kt(t,e),s=Ce&&o.markedSpans;if(s)for(var a=0;a<s.length;++a){var l=s[a];if(l.marker.collapsed){var c=l.marker.find(0),u=ee(c.from,r)||Oe(l.marker)-Oe(n),h=ee(c.to,i)||Re(l.marker)-Re(n);if(!(u>=0&&h<=0||u<=0&&h>=0)&&(u<=0&&(l.marker.inclusiveRight&&n.inclusiveLeft?ee(c.to,r)>=0:ee(c.to,r)>0)||u>=0&&(l.marker.inclusiveRight&&n.inclusiveLeft?ee(c.from,i)<=0:ee(c.from,i)<0)))return!0}}}function Be(t){for(var e;e=Me(t);)t=e.find(-1,!0).line;return t}function je(t,e){var r=Kt(t,e),i=Be(r);return r==i?e:$t(i)}function Ue(t,e){if(e>t.lastLine())return e;var r,i=Kt(t,e);if(!He(t,i))return e;for(;r=Pe(i);)i=r.find(1,!0).line;return $t(i)+1}function He(t,e){var r=Ce&&e.markedSpans;if(r)for(var i=void 0,n=0;n<r.length;++n)if((i=r[n]).marker.collapsed){if(null==i.from)return!0;if(!i.marker.widgetNode&&0==i.from&&i.marker.inclusiveLeft&&Ge(t,e,i))return!0}}function Ge(t,e,r){if(null==r.to){var i=r.marker.find(1,!0);return Ge(t,i.line,ke(i.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==e.text.length)return!0;for(var n=void 0,o=0;o<e.markedSpans.length;++o)if((n=e.markedSpans[o]).marker.collapsed&&!n.marker.widgetNode&&n.from==r.to&&(null==n.to||n.to!=r.from)&&(n.marker.inclusiveLeft||r.marker.inclusiveRight)&&Ge(t,e,n))return!0}function ze(t){for(var e=0,r=(t=Be(t)).parent,i=0;i<r.lines.length;++i){var n=r.lines[i];if(n==t)break;e+=n.height}for(var o=r.parent;o;o=(r=o).parent)for(var s=0;s<o.children.length;++s){var a=o.children[s];if(a==r)break;e+=a.height}return e}function We(t){if(0==t.height)return 0;for(var e,r=t.text.length,i=t;e=Me(i);){var n=e.find(0,!0);i=n.from.line,r+=n.from.ch-n.to.ch}for(i=t;e=Pe(i);){var o=e.find(0,!0);r-=i.text.length-o.from.ch,r+=(i=o.to.line).text.length-o.to.ch}return r}function Ve(t){var e=t.display,r=t.doc;e.maxLine=Kt(r,r.first),e.maxLineLength=We(e.maxLine),e.maxLineChanged=!0,r.iter((function(t){var r=We(t);r>e.maxLineLength&&(e.maxLineLength=r,e.maxLine=t)}))}var Ke=function(t,e,r){this.text=t,De(this,e),this.height=r?r(this):1};function qe(t){t.parent=null,Ae(t)}Ke.prototype.lineNo=function(){return $t(this)},yt(Ke);var Ye={},Xe={};function $e(t,e){if(!t||/^\s*$/.test(t))return null;var r=e.addModeClass?Xe:Ye;return r[t]||(r[t]=t.replace(/\S+/g,"cm-$&"))}function Ze(t,e){var r=O("span",null,null,l?"padding-right: .1px":null),i={pre:O("pre",[r],"CodeMirror-line"),content:r,col:0,pos:0,cm:t,trailingSpace:!1,splitSpaces:t.getOption("lineWrapping")};e.measure={};for(var n=0;n<=(e.rest?e.rest.length:0);n++){var o=n?e.rest[n-1]:e.line,s=void 0;i.pos=0,i.addToken=Je,Dt(t.display.measure)&&(s=ct(o,t.doc.direction))&&(i.addToken=tr(i.addToken,s)),i.map=[],rr(o,i,de(t,o,e!=t.display.externalMeasured&&$t(o))),o.styleClasses&&(o.styleClasses.bgClass&&(i.bgClass=M(o.styleClasses.bgClass,i.bgClass||"")),o.styleClasses.textClass&&(i.textClass=M(o.styleClasses.textClass,i.textClass||""))),0==i.map.length&&i.map.push(0,0,i.content.appendChild(At(t.display.measure))),0==n?(e.measure.map=i.map,e.measure.cache={}):((e.measure.maps||(e.measure.maps=[])).push(i.map),(e.measure.caches||(e.measure.caches=[])).push({}))}if(l){var a=i.content.lastChild;(/\bcm-tab\b/.test(a.className)||a.querySelector&&a.querySelector(".cm-tab"))&&(i.content.className="cm-tab-wrap-hack")}return pt(t,"renderLine",t,e.line,i.pre),i.pre.className&&(i.textClass=M(i.pre.className,i.textClass||"")),i}function Qe(t){var e=D("span","•","cm-invalidchar");return e.title="\\u"+t.charCodeAt(0).toString(16),e.setAttribute("aria-label",e.title),e}function Je(t,e,r,i,n,o,l){if(e){var c,u=t.splitSpaces?function(t,e){if(t.length>1&&!/ /.test(t))return t;for(var r=e,i="",n=0;n<t.length;n++){var o=t.charAt(n);" "!=o||!r||n!=t.length-1&&32!=t.charCodeAt(n+1)||(o=" "),i+=o,r=" "==o}return i}(e,t.trailingSpace):e,h=t.cm.state.specialChars,d=!1;if(h.test(e)){c=document.createDocumentFragment();for(var f=0;;){h.lastIndex=f;var p=h.exec(e),g=p?p.index-f:e.length-f;if(g){var m=document.createTextNode(u.slice(f,f+g));s&&a<9?c.appendChild(D("span",[m])):c.appendChild(m),t.map.push(t.pos,t.pos+g,m),t.col+=g,t.pos+=g}if(!p)break;f+=g+1;var v=void 0;if("\t"==p[0]){var y=t.cm.options.tabSize,b=y-t.col%y;(v=c.appendChild(D("span",q(b),"cm-tab"))).setAttribute("role","presentation"),v.setAttribute("cm-text","\t"),t.col+=b}else"\r"==p[0]||"\n"==p[0]?((v=c.appendChild(D("span","\r"==p[0]?"␍":"","cm-invalidchar"))).setAttribute("cm-text",p[0]),t.col+=1):((v=t.cm.options.specialCharPlaceholder(p[0])).setAttribute("cm-text",p[0]),s&&a<9?c.appendChild(D("span",[v])):c.appendChild(v),t.col+=1);t.map.push(t.pos,t.pos+1,v),t.pos++}}else t.col+=e.length,c=document.createTextNode(u),t.map.push(t.pos,t.pos+e.length,c),s&&a<9&&(d=!0),t.pos+=e.length;if(t.trailingSpace=32==u.charCodeAt(e.length-1),r||i||n||d||o||l){var x=r||"";i&&(x+=i),n&&(x+=n);var S=D("span",[c],x,o);if(l)for(var C in l)l.hasOwnProperty(C)&&"style"!=C&&"class"!=C&&S.setAttribute(C,l[C]);return t.content.appendChild(S)}t.content.appendChild(c)}}function tr(t,e){return function(r,i,n,o,s,a,l){n=n?n+" cm-force-border":"cm-force-border";for(var c=r.pos,u=c+i.length;;){for(var h=void 0,d=0;d<e.length&&!((h=e[d]).to>c&&h.from<=c);d++);if(h.to>=u)return t(r,i,n,o,s,a,l);t(r,i.slice(0,h.to-c),n,o,null,a,l),o=null,i=i.slice(h.to-c),c=h.to}}}function er(t,e,r,i){var n=!i&&r.widgetNode;n&&t.map.push(t.pos,t.pos+e,n),!i&&t.cm.display.input.needsContentAttribute&&(n||(n=t.content.appendChild(document.createElement("span"))),n.setAttribute("cm-marker",r.id)),n&&(t.cm.display.input.setUneditable(n),t.content.appendChild(n)),t.pos+=e,t.trailingSpace=!1}function rr(t,e,r){var i=t.markedSpans,n=t.text,o=0;if(i)for(var s,a,l,c,u,h,d,f=n.length,p=0,g=1,m="",v=0;;){if(v==p){l=c=u=a="",d=null,h=null,v=1/0;for(var y=[],b=void 0,x=0;x<i.length;++x){var S=i[x],C=S.marker;if("bookmark"==C.type&&S.from==p&&C.widgetNode)y.push(C);else if(S.from<=p&&(null==S.to||S.to>p||C.collapsed&&S.to==p&&S.from==p)){if(null!=S.to&&S.to!=p&&v>S.to&&(v=S.to,c=""),C.className&&(l+=" "+C.className),C.css&&(a=(a?a+";":"")+C.css),C.startStyle&&S.from==p&&(u+=" "+C.startStyle),C.endStyle&&S.to==v&&(b||(b=[])).push(C.endStyle,S.to),C.title&&((d||(d={})).title=C.title),C.attributes)for(var w in C.attributes)(d||(d={}))[w]=C.attributes[w];C.collapsed&&(!h||_e(h.marker,C)<0)&&(h=S)}else S.from>p&&v>S.from&&(v=S.from)}if(b)for(var k=0;k<b.length;k+=2)b[k+1]==v&&(c+=" "+b[k]);if(!h||h.from==p)for(var E=0;E<y.length;++E)er(e,0,y[E]);if(h&&(h.from||0)==p){if(er(e,(null==h.to?f+1:h.to)-p,h.marker,null==h.from),null==h.to)return;h.to==p&&(h=!1)}}if(p>=f)break;for(var T=Math.min(f,v);;){if(m){var L=p+m.length;if(!h){var A=L>T?m.slice(0,T-p):m;e.addToken(e,A,s?s+l:l,u,p+A.length==v?c:"",a,d)}if(L>=T){m=m.slice(T-p),p=T;break}p=L,u=""}m=n.slice(o,o=r[g++]),s=$e(r[g++],e.cm.options)}}else for(var D=1;D<r.length;D+=2)e.addToken(e,n.slice(o,o=r[D]),$e(r[D+1],e.cm.options))}function ir(t,e,r){this.line=e,this.rest=function(t){for(var e,r;e=Pe(t);)t=e.find(1,!0).line,(r||(r=[])).push(t);return r}(e),this.size=this.rest?$t(Y(this.rest))-r+1:1,this.node=this.text=null,this.hidden=He(t,e)}function nr(t,e,r){for(var i,n=[],o=e;o<r;o=i){var s=new ir(t.doc,Kt(t.doc,o),o);i=o+s.size,n.push(s)}return n}var or=null,sr=null;function ar(t,e){var r=dt(t,e);if(r.length){var i,n=Array.prototype.slice.call(arguments,2);or?i=or.delayedCallbacks:sr?i=sr:(i=sr=[],setTimeout(lr,0));for(var o=function(t){i.push((function(){return r[t].apply(null,n)}))},s=0;s<r.length;++s)o(s)}}function lr(){var t=sr;sr=null;for(var e=0;e<t.length;++e)t[e]()}function cr(t,e,r,i){for(var n=0;n<e.changes.length;n++){var o=e.changes[n];"text"==o?dr(t,e):"gutter"==o?pr(t,e,r,i):"class"==o?fr(t,e):"widget"==o&&gr(t,e,i)}e.changes=null}function ur(t){return t.node==t.text&&(t.node=D("div",null,null,"position: relative"),t.text.parentNode&&t.text.parentNode.replaceChild(t.node,t.text),t.node.appendChild(t.text),s&&a<8&&(t.node.style.zIndex=2)),t.node}function hr(t,e){var r=t.display.externalMeasured;return r&&r.line==e.line?(t.display.externalMeasured=null,e.measure=r.measure,r.built):Ze(t,e)}function dr(t,e){var r=e.text.className,i=hr(t,e);e.text==e.node&&(e.node=i.pre),e.text.parentNode.replaceChild(i.pre,e.text),e.text=i.pre,i.bgClass!=e.bgClass||i.textClass!=e.textClass?(e.bgClass=i.bgClass,e.textClass=i.textClass,fr(t,e)):r&&(e.text.className=r)}function fr(t,e){!function(t,e){var r=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(r&&(r+=" CodeMirror-linebackground"),e.background)r?e.background.className=r:(e.background.parentNode.removeChild(e.background),e.background=null);else if(r){var i=ur(e);e.background=i.insertBefore(D("div",null,r),i.firstChild),t.display.input.setUneditable(e.background)}}(t,e),e.line.wrapClass?ur(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var r=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=r||""}function pr(t,e,r,i){if(e.gutter&&(e.node.removeChild(e.gutter),e.gutter=null),e.gutterBackground&&(e.node.removeChild(e.gutterBackground),e.gutterBackground=null),e.line.gutterClass){var n=ur(e);e.gutterBackground=D("div",null,"CodeMirror-gutter-background "+e.line.gutterClass,"left: "+(t.options.fixedGutter?i.fixedPos:-i.gutterTotalWidth)+"px; width: "+i.gutterTotalWidth+"px"),t.display.input.setUneditable(e.gutterBackground),n.insertBefore(e.gutterBackground,e.text)}var o=e.line.gutterMarkers;if(t.options.lineNumbers||o){var s=ur(e),a=e.gutter=D("div",null,"CodeMirror-gutter-wrapper","left: "+(t.options.fixedGutter?i.fixedPos:-i.gutterTotalWidth)+"px");if(t.display.input.setUneditable(a),s.insertBefore(a,e.text),e.line.gutterClass&&(a.className+=" "+e.line.gutterClass),!t.options.lineNumbers||o&&o["CodeMirror-linenumbers"]||(e.lineNumber=a.appendChild(D("div",Jt(t.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+i.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+t.display.lineNumInnerWidth+"px"))),o)for(var l=0;l<t.display.gutterSpecs.length;++l){var c=t.display.gutterSpecs[l].className,u=o.hasOwnProperty(c)&&o[c];u&&a.appendChild(D("div",[u],"CodeMirror-gutter-elt","left: "+i.gutterLeft[c]+"px; width: "+i.gutterWidth[c]+"px"))}}}function gr(t,e,r){e.alignable&&(e.alignable=null);for(var i=k("CodeMirror-linewidget"),n=e.node.firstChild,o=void 0;n;n=o)o=n.nextSibling,i.test(n.className)&&e.node.removeChild(n);vr(t,e,r)}function mr(t,e,r,i){var n=hr(t,e);return e.text=e.node=n.pre,n.bgClass&&(e.bgClass=n.bgClass),n.textClass&&(e.textClass=n.textClass),fr(t,e),pr(t,e,r,i),vr(t,e,i),e.node}function vr(t,e,r){if(yr(t,e.line,e,r,!0),e.rest)for(var i=0;i<e.rest.length;i++)yr(t,e.rest[i],e,r,!1)}function yr(t,e,r,i,n){if(e.widgets)for(var o=ur(r),s=0,a=e.widgets;s<a.length;++s){var l=a[s],c=D("div",[l.node],"CodeMirror-linewidget"+(l.className?" "+l.className:""));l.handleMouseEvents||c.setAttribute("cm-ignore-events","true"),br(l,c,r,i),t.display.input.setUneditable(c),n&&l.above?o.insertBefore(c,r.gutter||r.text):o.appendChild(c),ar(l,"redraw")}}function br(t,e,r,i){if(t.noHScroll){(r.alignable||(r.alignable=[])).push(e);var n=i.wrapperWidth;e.style.left=i.fixedPos+"px",t.coverGutter||(n-=i.gutterTotalWidth,e.style.paddingLeft=i.gutterTotalWidth+"px"),e.style.width=n+"px"}t.coverGutter&&(e.style.zIndex=5,e.style.position="relative",t.noHScroll||(e.style.marginLeft=-i.gutterTotalWidth+"px"))}function xr(t){if(null!=t.height)return t.height;var e=t.doc.cm;if(!e)return 0;if(!R(document.body,t.node)){var r="position: relative;";t.coverGutter&&(r+="margin-left: -"+e.display.gutters.offsetWidth+"px;"),t.noHScroll&&(r+="width: "+e.display.wrapper.clientWidth+"px;"),A(e.display.measure,D("div",[t.node],null,r))}return t.height=t.node.parentNode.offsetHeight}function Sr(t,e){for(var r=wt(e);r!=t.wrapper;r=r.parentNode)if(!r||1==r.nodeType&&"true"==r.getAttribute("cm-ignore-events")||r.parentNode==t.sizer&&r!=t.mover)return!0}function Cr(t){return t.lineSpace.offsetTop}function wr(t){return t.mover.offsetHeight-t.lineSpace.offsetHeight}function kr(t){if(t.cachedPaddingH)return t.cachedPaddingH;var e=A(t.measure,D("pre","x","CodeMirror-line-like")),r=window.getComputedStyle?window.getComputedStyle(e):e.currentStyle,i={left:parseInt(r.paddingLeft),right:parseInt(r.paddingRight)};return isNaN(i.left)||isNaN(i.right)||(t.cachedPaddingH=i),i}function Er(t){return 50-t.display.nativeBarWidth}function Tr(t){return t.display.scroller.clientWidth-Er(t)-t.display.barWidth}function Lr(t){return t.display.scroller.clientHeight-Er(t)-t.display.barHeight}function Ar(t,e,r){if(t.line==e)return{map:t.measure.map,cache:t.measure.cache};for(var i=0;i<t.rest.length;i++)if(t.rest[i]==e)return{map:t.measure.maps[i],cache:t.measure.caches[i]};for(var n=0;n<t.rest.length;n++)if($t(t.rest[n])>r)return{map:t.measure.maps[n],cache:t.measure.caches[n],before:!0}}function Dr(t,e,r,i){return _r(t,Rr(t,e),r,i)}function Or(t,e){if(e>=t.display.viewFrom&&e<t.display.viewTo)return t.display.view[ci(t,e)];var r=t.display.externalMeasured;return r&&e>=r.lineN&&e<r.lineN+r.size?r:void 0}function Rr(t,e){var r=$t(e),i=Or(t,r);i&&!i.text?i=null:i&&i.changes&&(cr(t,i,r,ni(t)),t.curOp.forceUpdate=!0),i||(i=function(t,e){var r=$t(e=Be(e)),i=t.display.externalMeasured=new ir(t.doc,e,r);i.lineN=r;var n=i.built=Ze(t,i);return i.text=n.pre,A(t.display.lineMeasure,n.pre),i}(t,e));var n=Ar(i,e,r);return{line:e,view:i,rect:null,map:n.map,cache:n.cache,before:n.before,hasHeights:!1}}function _r(t,e,r,i,n){e.before&&(r=-1);var o,l=r+(i||"");return e.cache.hasOwnProperty(l)?o=e.cache[l]:(e.rect||(e.rect=e.view.text.getBoundingClientRect()),e.hasHeights||(function(t,e,r){var i=t.options.lineWrapping,n=i&&Tr(t);if(!e.measure.heights||i&&e.measure.width!=n){var o=e.measure.heights=[];if(i){e.measure.width=n;for(var s=e.text.firstChild.getClientRects(),a=0;a<s.length-1;a++){var l=s[a],c=s[a+1];Math.abs(l.bottom-c.bottom)>2&&o.push((l.bottom+c.top)/2-r.top)}}o.push(r.bottom-r.top)}}(t,e.view,e.rect),e.hasHeights=!0),(o=function(t,e,r,i){var n,o=Pr(e.map,r,i),l=o.node,c=o.start,u=o.end,h=o.collapse;if(3==l.nodeType){for(var d=0;d<4;d++){for(;c&&it(e.line.text.charAt(o.coverStart+c));)--c;for(;o.coverStart+u<o.coverEnd&&it(e.line.text.charAt(o.coverStart+u));)++u;if((n=s&&a<9&&0==c&&u==o.coverEnd-o.coverStart?l.parentNode.getBoundingClientRect():Nr(E(l,c,u).getClientRects(),i)).left||n.right||0==c)break;u=c,c-=1,h="right"}s&&a<11&&(n=function(t,e){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!function(t){if(null!=Mt)return Mt;var e=A(t,D("span","x")),r=e.getBoundingClientRect(),i=E(e,0,1).getBoundingClientRect();return Mt=Math.abs(r.left-i.left)>1}(t))return e;var r=screen.logicalXDPI/screen.deviceXDPI,i=screen.logicalYDPI/screen.deviceYDPI;return{left:e.left*r,right:e.right*r,top:e.top*i,bottom:e.bottom*i}}(t.display.measure,n))}else{var f;c>0&&(h=i="right"),n=t.options.lineWrapping&&(f=l.getClientRects()).length>1?f["right"==i?f.length-1:0]:l.getBoundingClientRect()}if(s&&a<9&&!c&&(!n||!n.left&&!n.right)){var p=l.parentNode.getClientRects()[0];n=p?{left:p.left,right:p.left+ii(t.display),top:p.top,bottom:p.bottom}:Mr}for(var g=n.top-e.rect.top,m=n.bottom-e.rect.top,v=(g+m)/2,y=e.view.measure.heights,b=0;b<y.length-1&&!(v<y[b]);b++);var x=b?y[b-1]:0,S=y[b],C={left:("right"==h?n.right:n.left)-e.rect.left,right:("left"==h?n.left:n.right)-e.rect.left,top:x,bottom:S};return n.left||n.right||(C.bogus=!0),t.options.singleCursorHeightPerLine||(C.rtop=g,C.rbottom=m),C}(t,e,r,i)).bogus||(e.cache[l]=o)),{left:o.left,right:o.right,top:n?o.rtop:o.top,bottom:n?o.rbottom:o.bottom}}var Ir,Mr={left:0,right:0,top:0,bottom:0};function Pr(t,e,r){for(var i,n,o,s,a,l,c=0;c<t.length;c+=3)if(a=t[c],l=t[c+1],e<a?(n=0,o=1,s="left"):e<l?o=1+(n=e-a):(c==t.length-3||e==l&&t[c+3]>e)&&(n=(o=l-a)-1,e>=l&&(s="right")),null!=n){if(i=t[c+2],a==l&&r==(i.insertLeft?"left":"right")&&(s=r),"left"==r&&0==n)for(;c&&t[c-2]==t[c-3]&&t[c-1].insertLeft;)i=t[2+(c-=3)],s="left";if("right"==r&&n==l-a)for(;c<t.length-3&&t[c+3]==t[c+4]&&!t[c+5].insertLeft;)i=t[(c+=3)+2],s="right";break}return{node:i,start:n,end:o,collapse:s,coverStart:a,coverEnd:l}}function Nr(t,e){var r=Mr;if("left"==e)for(var i=0;i<t.length&&(r=t[i]).left==r.right;i++);else for(var n=t.length-1;n>=0&&(r=t[n]).left==r.right;n--);return r}function Fr(t){if(t.measure&&(t.measure.cache={},t.measure.heights=null,t.rest))for(var e=0;e<t.rest.length;e++)t.measure.caches[e]={}}function Br(t){t.display.externalMeasure=null,L(t.display.lineMeasure);for(var e=0;e<t.display.view.length;e++)Fr(t.display.view[e])}function jr(t){Br(t),t.display.cachedCharWidth=t.display.cachedTextHeight=t.display.cachedPaddingH=null,t.options.lineWrapping||(t.display.maxLineChanged=!0),t.display.lineNumChars=null}function Ur(){return u&&m?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function Hr(){return u&&m?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function Gr(t){var e=0;if(t.widgets)for(var r=0;r<t.widgets.length;++r)t.widgets[r].above&&(e+=xr(t.widgets[r]));return e}function zr(t,e,r,i,n){if(!n){var o=Gr(e);r.top+=o,r.bottom+=o}if("line"==i)return r;i||(i="local");var s=ze(e);if("local"==i?s+=Cr(t.display):s-=t.display.viewOffset,"page"==i||"window"==i){var a=t.display.lineSpace.getBoundingClientRect();s+=a.top+("window"==i?0:Hr());var l=a.left+("window"==i?0:Ur());r.left+=l,r.right+=l}return r.top+=s,r.bottom+=s,r}function Wr(t,e,r){if("div"==r)return e;var i=e.left,n=e.top;if("page"==r)i-=Ur(),n-=Hr();else if("local"==r||!r){var o=t.display.sizer.getBoundingClientRect();i+=o.left,n+=o.top}var s=t.display.lineSpace.getBoundingClientRect();return{left:i-s.left,top:n-s.top}}function Vr(t,e,r,i,n){return i||(i=Kt(t.doc,e.line)),zr(t,i,Dr(t,i,e.ch,n),r)}function Kr(t,e,r,i,n,o){function s(e,s){var a=_r(t,n,e,s?"right":"left",o);return s?a.left=a.right:a.right=a.left,zr(t,i,a,r)}i=i||Kt(t.doc,e.line),n||(n=Rr(t,i));var a=ct(i,t.doc.direction),l=e.ch,c=e.sticky;if(l>=i.text.length?(l=i.text.length,c="before"):l<=0&&(l=0,c="after"),!a)return s("before"==c?l-1:l,"before"==c);function u(t,e,r){return s(r?t-1:t,1==a[e].level!=r)}var h=at(a,l,c),d=st,f=u(l,h,"before"==c);return null!=d&&(f.other=u(l,d,"before"!=c)),f}function qr(t,e){var r=0;e=ae(t.doc,e),t.options.lineWrapping||(r=ii(t.display)*e.ch);var i=Kt(t.doc,e.line),n=ze(i)+Cr(t.display);return{left:r,right:r,top:n,bottom:n+i.height}}function Yr(t,e,r,i,n){var o=te(t,e,r);return o.xRel=n,i&&(o.outside=i),o}function Xr(t,e,r){var i=t.doc;if((r+=t.display.viewOffset)<0)return Yr(i.first,0,null,-1,-1);var n=Zt(i,r),o=i.first+i.size-1;if(n>o)return Yr(i.first+i.size-1,Kt(i,o).text.length,null,1,1);e<0&&(e=0);for(var s=Kt(i,n);;){var a=Jr(t,s,n,e,r),l=Ne(s,a.ch+(a.xRel>0||a.outside>0?1:0));if(!l)return a;var c=l.find(1);if(c.line==n)return c;s=Kt(i,n=c.line)}}function $r(t,e,r,i){i-=Gr(e);var n=e.text.length,o=ot((function(e){return _r(t,r,e-1).bottom<=i}),n,0);return{begin:o,end:n=ot((function(e){return _r(t,r,e).top>i}),o,n)}}function Zr(t,e,r,i){return r||(r=Rr(t,e)),$r(t,e,r,zr(t,e,_r(t,r,i),"line").top)}function Qr(t,e,r,i){return!(t.bottom<=r)&&(t.top>r||(i?t.left:t.right)>e)}function Jr(t,e,r,i,n){n-=ze(e);var o=Rr(t,e),s=Gr(e),a=0,l=e.text.length,c=!0,u=ct(e,t.doc.direction);if(u){var h=(t.options.lineWrapping?ei:ti)(t,e,r,o,u,i,n);a=(c=1!=h.level)?h.from:h.to-1,l=c?h.to:h.from-1}var d,f,p=null,g=null,m=ot((function(e){var r=_r(t,o,e);return r.top+=s,r.bottom+=s,!!Qr(r,i,n,!1)&&(r.top<=n&&r.left<=i&&(p=e,g=r),!0)}),a,l),v=!1;if(g){var y=i-g.left<g.right-i,b=y==c;m=p+(b?0:1),f=b?"after":"before",d=y?g.left:g.right}else{c||m!=l&&m!=a||m++,f=0==m?"after":m==e.text.length?"before":_r(t,o,m-(c?1:0)).bottom+s<=n==c?"after":"before";var x=Kr(t,te(r,m,f),"line",e,o);d=x.left,v=n<x.top?-1:n>=x.bottom?1:0}return Yr(r,m=nt(e.text,m,1),f,v,i-d)}function ti(t,e,r,i,n,o,s){var a=ot((function(a){var l=n[a],c=1!=l.level;return Qr(Kr(t,te(r,c?l.to:l.from,c?"before":"after"),"line",e,i),o,s,!0)}),0,n.length-1),l=n[a];if(a>0){var c=1!=l.level,u=Kr(t,te(r,c?l.from:l.to,c?"after":"before"),"line",e,i);Qr(u,o,s,!0)&&u.top>s&&(l=n[a-1])}return l}function ei(t,e,r,i,n,o,s){var a=$r(t,e,i,s),l=a.begin,c=a.end;/\s/.test(e.text.charAt(c-1))&&c--;for(var u=null,h=null,d=0;d<n.length;d++){var f=n[d];if(!(f.from>=c||f.to<=l)){var p=_r(t,i,1!=f.level?Math.min(c,f.to)-1:Math.max(l,f.from)).right,g=p<o?o-p+1e9:p-o;(!u||h>g)&&(u=f,h=g)}}return u||(u=n[n.length-1]),u.from<l&&(u={from:l,to:u.to,level:u.level}),u.to>c&&(u={from:u.from,to:c,level:u.level}),u}function ri(t){if(null!=t.cachedTextHeight)return t.cachedTextHeight;if(null==Ir){Ir=D("pre",null,"CodeMirror-line-like");for(var e=0;e<49;++e)Ir.appendChild(document.createTextNode("x")),Ir.appendChild(D("br"));Ir.appendChild(document.createTextNode("x"))}A(t.measure,Ir);var r=Ir.offsetHeight/50;return r>3&&(t.cachedTextHeight=r),L(t.measure),r||1}function ii(t){if(null!=t.cachedCharWidth)return t.cachedCharWidth;var e=D("span","xxxxxxxxxx"),r=D("pre",[e],"CodeMirror-line-like");A(t.measure,r);var i=e.getBoundingClientRect(),n=(i.right-i.left)/10;return n>2&&(t.cachedCharWidth=n),n||10}function ni(t){for(var e=t.display,r={},i={},n=e.gutters.clientLeft,o=e.gutters.firstChild,s=0;o;o=o.nextSibling,++s){var a=t.display.gutterSpecs[s].className;r[a]=o.offsetLeft+o.clientLeft+n,i[a]=o.clientWidth}return{fixedPos:oi(e),gutterTotalWidth:e.gutters.offsetWidth,gutterLeft:r,gutterWidth:i,wrapperWidth:e.wrapper.clientWidth}}function oi(t){return t.scroller.getBoundingClientRect().left-t.sizer.getBoundingClientRect().left}function si(t){var e=ri(t.display),r=t.options.lineWrapping,i=r&&Math.max(5,t.display.scroller.clientWidth/ii(t.display)-3);return function(n){if(He(t.doc,n))return 0;var o=0;if(n.widgets)for(var s=0;s<n.widgets.length;s++)n.widgets[s].height&&(o+=n.widgets[s].height);return r?o+(Math.ceil(n.text.length/i)||1)*e:o+e}}function ai(t){var e=t.doc,r=si(t);e.iter((function(t){var e=r(t);e!=t.height&&Xt(t,e)}))}function li(t,e,r,i){var n=t.display;if(!r&&"true"==wt(e).getAttribute("cm-not-content"))return null;var o,s,a=n.lineSpace.getBoundingClientRect();try{o=e.clientX-a.left,s=e.clientY-a.top}catch(t){return null}var l,c=Xr(t,o,s);if(i&&c.xRel>0&&(l=Kt(t.doc,c.line).text).length==c.ch){var u=B(l,l.length,t.options.tabSize)-l.length;c=te(c.line,Math.max(0,Math.round((o-kr(t.display).left)/ii(t.display))-u))}return c}function ci(t,e){if(e>=t.display.viewTo)return null;if((e-=t.display.viewFrom)<0)return null;for(var r=t.display.view,i=0;i<r.length;i++)if((e-=r[i].size)<0)return i}function ui(t,e,r,i){null==e&&(e=t.doc.first),null==r&&(r=t.doc.first+t.doc.size),i||(i=0);var n=t.display;if(i&&r<n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>e)&&(n.updateLineNumbers=e),t.curOp.viewChanged=!0,e>=n.viewTo)Ce&&je(t.doc,e)<n.viewTo&&di(t);else if(r<=n.viewFrom)Ce&&Ue(t.doc,r+i)>n.viewFrom?di(t):(n.viewFrom+=i,n.viewTo+=i);else if(e<=n.viewFrom&&r>=n.viewTo)di(t);else if(e<=n.viewFrom){var o=fi(t,r,r+i,1);o?(n.view=n.view.slice(o.index),n.viewFrom=o.lineN,n.viewTo+=i):di(t)}else if(r>=n.viewTo){var s=fi(t,e,e,-1);s?(n.view=n.view.slice(0,s.index),n.viewTo=s.lineN):di(t)}else{var a=fi(t,e,e,-1),l=fi(t,r,r+i,1);a&&l?(n.view=n.view.slice(0,a.index).concat(nr(t,a.lineN,l.lineN)).concat(n.view.slice(l.index)),n.viewTo+=i):di(t)}var c=n.externalMeasured;c&&(r<c.lineN?c.lineN+=i:e<c.lineN+c.size&&(n.externalMeasured=null))}function hi(t,e,r){t.curOp.viewChanged=!0;var i=t.display,n=t.display.externalMeasured;if(n&&e>=n.lineN&&e<n.lineN+n.size&&(i.externalMeasured=null),!(e<i.viewFrom||e>=i.viewTo)){var o=i.view[ci(t,e)];if(null!=o.node){var s=o.changes||(o.changes=[]);-1==U(s,r)&&s.push(r)}}}function di(t){t.display.viewFrom=t.display.viewTo=t.doc.first,t.display.view=[],t.display.viewOffset=0}function fi(t,e,r,i){var n,o=ci(t,e),s=t.display.view;if(!Ce||r==t.doc.first+t.doc.size)return{index:o,lineN:r};for(var a=t.display.viewFrom,l=0;l<o;l++)a+=s[l].size;if(a!=e){if(i>0){if(o==s.length-1)return null;n=a+s[o].size-e,o++}else n=a-e;e+=n,r+=n}for(;je(t.doc,r)!=r;){if(o==(i<0?0:s.length-1))return null;r+=i*s[o-(i<0?1:0)].size,o+=i}return{index:o,lineN:r}}function pi(t){for(var e=t.display.view,r=0,i=0;i<e.length;i++){var n=e[i];n.hidden||n.node&&!n.changes||++r}return r}function gi(t){t.display.input.showSelection(t.display.input.prepareSelection())}function mi(t,e){void 0===e&&(e=!0);for(var r=t.doc,i={},n=i.cursors=document.createDocumentFragment(),o=i.selection=document.createDocumentFragment(),s=0;s<r.sel.ranges.length;s++)if(e||s!=r.sel.primIndex){var a=r.sel.ranges[s];if(!(a.from().line>=t.display.viewTo||a.to().line<t.display.viewFrom)){var l=a.empty();(l||t.options.showCursorWhenSelecting)&&vi(t,a.head,n),l||bi(t,a,o)}}return i}function vi(t,e,r){var i=Kr(t,e,"div",null,null,!t.options.singleCursorHeightPerLine),n=r.appendChild(D("div"," ","CodeMirror-cursor"));if(n.style.left=i.left+"px",n.style.top=i.top+"px",n.style.height=Math.max(0,i.bottom-i.top)*t.options.cursorHeight+"px",i.other){var o=r.appendChild(D("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=i.other.left+"px",o.style.top=i.other.top+"px",o.style.height=.85*(i.other.bottom-i.other.top)+"px"}}function yi(t,e){return t.top-e.top||t.left-e.left}function bi(t,e,r){var i=t.display,n=t.doc,o=document.createDocumentFragment(),s=kr(t.display),a=s.left,l=Math.max(i.sizerWidth,Tr(t)-i.sizer.offsetLeft)-s.right,c="ltr"==n.direction;function u(t,e,r,i){e<0&&(e=0),e=Math.round(e),i=Math.round(i),o.appendChild(D("div",null,"CodeMirror-selected","position: absolute; left: "+t+"px;\n top: "+e+"px; width: "+(null==r?l-t:r)+"px;\n height: "+(i-e)+"px"))}function h(e,r,i){var o,s,h=Kt(n,e),d=h.text.length;function f(r,i){return Vr(t,te(e,r),"div",h,i)}function p(e,r,i){var n=Zr(t,h,null,e),o="ltr"==r==("after"==i)?"left":"right";return f("after"==i?n.begin:n.end-(/\s/.test(h.text.charAt(n.end-1))?2:1),o)[o]}var g=ct(h,n.direction);return function(t,e,r,i){if(!t)return i(e,r,"ltr",0);for(var n=!1,o=0;o<t.length;++o){var s=t[o];(s.from<r&&s.to>e||e==r&&s.to==e)&&(i(Math.max(s.from,e),Math.min(s.to,r),1==s.level?"rtl":"ltr",o),n=!0)}n||i(e,r,"ltr")}(g,r||0,null==i?d:i,(function(t,e,n,h){var m="ltr"==n,v=f(t,m?"left":"right"),y=f(e-1,m?"right":"left"),b=null==r&&0==t,x=null==i&&e==d,S=0==h,C=!g||h==g.length-1;if(y.top-v.top<=3){var w=(c?x:b)&&C,k=(c?b:x)&&S?a:(m?v:y).left,E=w?l:(m?y:v).right;u(k,v.top,E-k,v.bottom)}else{var T,L,A,D;m?(T=c&&b&&S?a:v.left,L=c?l:p(t,n,"before"),A=c?a:p(e,n,"after"),D=c&&x&&C?l:y.right):(T=c?p(t,n,"before"):a,L=!c&&b&&S?l:v.right,A=!c&&x&&C?a:y.left,D=c?p(e,n,"after"):l),u(T,v.top,L-T,v.bottom),v.bottom<y.top&&u(a,v.bottom,null,y.top),u(A,y.top,D-A,y.bottom)}(!o||yi(v,o)<0)&&(o=v),yi(y,o)<0&&(o=y),(!s||yi(v,s)<0)&&(s=v),yi(y,s)<0&&(s=y)})),{start:o,end:s}}var d=e.from(),f=e.to();if(d.line==f.line)h(d.line,d.ch,f.ch);else{var p=Kt(n,d.line),g=Kt(n,f.line),m=Be(p)==Be(g),v=h(d.line,d.ch,m?p.text.length+1:null).end,y=h(f.line,m?0:null,f.ch).start;m&&(v.top<y.top-2?(u(v.right,v.top,null,v.bottom),u(a,y.top,y.left,y.bottom)):u(v.right,v.top,y.left-v.right,v.bottom)),v.bottom<y.top&&u(a,v.bottom,null,y.top)}r.appendChild(o)}function xi(t){if(t.state.focused){var e=t.display;clearInterval(e.blinker);var r=!0;e.cursorDiv.style.visibility="",t.options.cursorBlinkRate>0?e.blinker=setInterval((function(){t.hasFocus()||ki(t),e.cursorDiv.style.visibility=(r=!r)?"":"hidden"}),t.options.cursorBlinkRate):t.options.cursorBlinkRate<0&&(e.cursorDiv.style.visibility="hidden")}}function Si(t){t.state.focused||(t.display.input.focus(),wi(t))}function Ci(t){t.state.delayingBlurEvent=!0,setTimeout((function(){t.state.delayingBlurEvent&&(t.state.delayingBlurEvent=!1,ki(t))}),100)}function wi(t,e){t.state.delayingBlurEvent&&(t.state.delayingBlurEvent=!1),"nocursor"!=t.options.readOnly&&(t.state.focused||(pt(t,"focus",t,e),t.state.focused=!0,I(t.display.wrapper,"CodeMirror-focused"),t.curOp||t.display.selForContextMenu==t.doc.sel||(t.display.input.reset(),l&&setTimeout((function(){return t.display.input.reset(!0)}),20)),t.display.input.receivedFocus()),xi(t))}function ki(t,e){t.state.delayingBlurEvent||(t.state.focused&&(pt(t,"blur",t,e),t.state.focused=!1,T(t.display.wrapper,"CodeMirror-focused")),clearInterval(t.display.blinker),setTimeout((function(){t.state.focused||(t.display.shift=!1)}),150))}function Ei(t){for(var e=t.display,r=e.lineDiv.offsetTop,i=0;i<e.view.length;i++){var n=e.view[i],o=t.options.lineWrapping,l=void 0,c=0;if(!n.hidden){if(s&&a<8){var u=n.node.offsetTop+n.node.offsetHeight;l=u-r,r=u}else{var h=n.node.getBoundingClientRect();l=h.bottom-h.top,!o&&n.text.firstChild&&(c=n.text.firstChild.getBoundingClientRect().right-h.left-1)}var d=n.line.height-l;if((d>.005||d<-.005)&&(Xt(n.line,l),Ti(n.line),n.rest))for(var f=0;f<n.rest.length;f++)Ti(n.rest[f]);if(c>t.display.sizerWidth){var p=Math.ceil(c/ii(t.display));p>t.display.maxLineLength&&(t.display.maxLineLength=p,t.display.maxLine=n.line,t.display.maxLineChanged=!0)}}}}function Ti(t){if(t.widgets)for(var e=0;e<t.widgets.length;++e){var r=t.widgets[e],i=r.node.parentNode;i&&(r.height=i.offsetHeight)}}function Li(t,e,r){var i=r&&null!=r.top?Math.max(0,r.top):t.scroller.scrollTop;i=Math.floor(i-Cr(t));var n=r&&null!=r.bottom?r.bottom:i+t.wrapper.clientHeight,o=Zt(e,i),s=Zt(e,n);if(r&&r.ensure){var a=r.ensure.from.line,l=r.ensure.to.line;a<o?(o=a,s=Zt(e,ze(Kt(e,a))+t.wrapper.clientHeight)):Math.min(l,e.lastLine())>=s&&(o=Zt(e,ze(Kt(e,l))-t.wrapper.clientHeight),s=l)}return{from:o,to:Math.max(s,o+1)}}function Ai(t,e){var r=t.display,i=ri(t.display);e.top<0&&(e.top=0);var n=t.curOp&&null!=t.curOp.scrollTop?t.curOp.scrollTop:r.scroller.scrollTop,o=Lr(t),s={};e.bottom-e.top>o&&(e.bottom=e.top+o);var a=t.doc.height+wr(r),l=e.top<i,c=e.bottom>a-i;if(e.top<n)s.scrollTop=l?0:e.top;else if(e.bottom>n+o){var u=Math.min(e.top,(c?a:e.bottom)-o);u!=n&&(s.scrollTop=u)}var h=t.options.fixedGutter?0:r.gutters.offsetWidth,d=t.curOp&&null!=t.curOp.scrollLeft?t.curOp.scrollLeft:r.scroller.scrollLeft-h,f=Tr(t)-r.gutters.offsetWidth,p=e.right-e.left>f;return p&&(e.right=e.left+f),e.left<10?s.scrollLeft=0:e.left<d?s.scrollLeft=Math.max(0,e.left+h-(p?0:10)):e.right>f+d-3&&(s.scrollLeft=e.right+(p?0:10)-f),s}function Di(t,e){null!=e&&(_i(t),t.curOp.scrollTop=(null==t.curOp.scrollTop?t.doc.scrollTop:t.curOp.scrollTop)+e)}function Oi(t){_i(t);var e=t.getCursor();t.curOp.scrollToPos={from:e,to:e,margin:t.options.cursorScrollMargin}}function Ri(t,e,r){null==e&&null==r||_i(t),null!=e&&(t.curOp.scrollLeft=e),null!=r&&(t.curOp.scrollTop=r)}function _i(t){var e=t.curOp.scrollToPos;e&&(t.curOp.scrollToPos=null,Ii(t,qr(t,e.from),qr(t,e.to),e.margin))}function Ii(t,e,r,i){var n=Ai(t,{left:Math.min(e.left,r.left),top:Math.min(e.top,r.top)-i,right:Math.max(e.right,r.right),bottom:Math.max(e.bottom,r.bottom)+i});Ri(t,n.scrollLeft,n.scrollTop)}function Mi(t,e){Math.abs(t.doc.scrollTop-e)<2||(r||ln(t,{top:e}),Pi(t,e,!0),r&&ln(t),rn(t,100))}function Pi(t,e,r){e=Math.max(0,Math.min(t.display.scroller.scrollHeight-t.display.scroller.clientHeight,e)),(t.display.scroller.scrollTop!=e||r)&&(t.doc.scrollTop=e,t.display.scrollbars.setScrollTop(e),t.display.scroller.scrollTop!=e&&(t.display.scroller.scrollTop=e))}function Ni(t,e,r,i){e=Math.max(0,Math.min(e,t.display.scroller.scrollWidth-t.display.scroller.clientWidth)),(r?e==t.doc.scrollLeft:Math.abs(t.doc.scrollLeft-e)<2)&&!i||(t.doc.scrollLeft=e,hn(t),t.display.scroller.scrollLeft!=e&&(t.display.scroller.scrollLeft=e),t.display.scrollbars.setScrollLeft(e))}function Fi(t){var e=t.display,r=e.gutters.offsetWidth,i=Math.round(t.doc.height+wr(t.display));return{clientHeight:e.scroller.clientHeight,viewHeight:e.wrapper.clientHeight,scrollWidth:e.scroller.scrollWidth,clientWidth:e.scroller.clientWidth,viewWidth:e.wrapper.clientWidth,barLeft:t.options.fixedGutter?r:0,docHeight:i,scrollHeight:i+Er(t)+e.barHeight,nativeBarWidth:e.nativeBarWidth,gutterWidth:r}}var Bi=function(t,e,r){this.cm=r;var i=this.vert=D("div",[D("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=D("div",[D("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");i.tabIndex=n.tabIndex=-1,t(i),t(n),ht(i,"scroll",(function(){i.clientHeight&&e(i.scrollTop,"vertical")})),ht(n,"scroll",(function(){n.clientWidth&&e(n.scrollLeft,"horizontal")})),this.checkedZeroWidth=!1,s&&a<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Bi.prototype.update=function(t){var e=t.scrollWidth>t.clientWidth+1,r=t.scrollHeight>t.clientHeight+1,i=t.nativeBarWidth;if(r){this.vert.style.display="block",this.vert.style.bottom=e?i+"px":"0";var n=t.viewHeight-(e?i:0);this.vert.firstChild.style.height=Math.max(0,t.scrollHeight-t.clientHeight+n)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(e){this.horiz.style.display="block",this.horiz.style.right=r?i+"px":"0",this.horiz.style.left=t.barLeft+"px";var o=t.viewWidth-t.barLeft-(r?i:0);this.horiz.firstChild.style.width=Math.max(0,t.scrollWidth-t.clientWidth+o)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&t.clientHeight>0&&(0==i&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:r?i:0,bottom:e?i:0}},Bi.prototype.setScrollLeft=function(t){this.horiz.scrollLeft!=t&&(this.horiz.scrollLeft=t),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Bi.prototype.setScrollTop=function(t){this.vert.scrollTop!=t&&(this.vert.scrollTop=t),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Bi.prototype.zeroWidthHack=function(){var t=y&&!f?"12px":"18px";this.horiz.style.height=this.vert.style.width=t,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new j,this.disableVert=new j},Bi.prototype.enableZeroWidthBar=function(t,e,r){t.style.pointerEvents="auto",e.set(1e3,(function i(){var n=t.getBoundingClientRect();("vert"==r?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1))!=t?t.style.pointerEvents="none":e.set(1e3,i)}))},Bi.prototype.clear=function(){var t=this.horiz.parentNode;t.removeChild(this.horiz),t.removeChild(this.vert)};var ji=function(){};function Ui(t,e){e||(e=Fi(t));var r=t.display.barWidth,i=t.display.barHeight;Hi(t,e);for(var n=0;n<4&&r!=t.display.barWidth||i!=t.display.barHeight;n++)r!=t.display.barWidth&&t.options.lineWrapping&&Ei(t),Hi(t,Fi(t)),r=t.display.barWidth,i=t.display.barHeight}function Hi(t,e){var r=t.display,i=r.scrollbars.update(e);r.sizer.style.paddingRight=(r.barWidth=i.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=i.bottom)+"px",r.heightForcer.style.borderBottom=i.bottom+"px solid transparent",i.right&&i.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=i.bottom+"px",r.scrollbarFiller.style.width=i.right+"px"):r.scrollbarFiller.style.display="",i.bottom&&t.options.coverGutterNextToScrollbar&&t.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=i.bottom+"px",r.gutterFiller.style.width=e.gutterWidth+"px"):r.gutterFiller.style.display=""}ji.prototype.update=function(){return{bottom:0,right:0}},ji.prototype.setScrollLeft=function(){},ji.prototype.setScrollTop=function(){},ji.prototype.clear=function(){};var Gi={native:Bi,null:ji};function zi(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&T(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new Gi[t.options.scrollbarStyle]((function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),ht(e,"mousedown",(function(){t.state.focused&&setTimeout((function(){return t.display.input.focus()}),0)})),e.setAttribute("cm-not-content","true")}),(function(e,r){"horizontal"==r?Ni(t,e):Mi(t,e)}),t),t.display.scrollbars.addClass&&I(t.display.wrapper,t.display.scrollbars.addClass)}var Wi=0;function Vi(t){var e;t.curOp={cm:t,viewChanged:!1,startHeight:t.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:++Wi},e=t.curOp,or?or.ops.push(e):e.ownsGroup=or={ops:[e],delayedCallbacks:[]}}function Ki(t){var e=t.curOp;e&&function(t,e){var r=t.ownsGroup;if(r)try{!function(t){var e=t.delayedCallbacks,r=0;do{for(;r<e.length;r++)e[r].call(null);for(var i=0;i<t.ops.length;i++){var n=t.ops[i];if(n.cursorActivityHandlers)for(;n.cursorActivityCalled<n.cursorActivityHandlers.length;)n.cursorActivityHandlers[n.cursorActivityCalled++].call(null,n.cm)}}while(r<e.length)}(r)}finally{or=null,e(r)}}(e,(function(t){for(var e=0;e<t.ops.length;e++)t.ops[e].cm.curOp=null;!function(t){for(var e=t.ops,r=0;r<e.length;r++)qi(e[r]);for(var i=0;i<e.length;i++)Yi(e[i]);for(var n=0;n<e.length;n++)Xi(e[n]);for(var o=0;o<e.length;o++)$i(e[o]);for(var s=0;s<e.length;s++)Zi(e[s])}(t)}))}function qi(t){var e=t.cm,r=e.display;!function(t){var e=t.display;!e.scrollbarsClipped&&e.scroller.offsetWidth&&(e.nativeBarWidth=e.scroller.offsetWidth-e.scroller.clientWidth,e.heightForcer.style.height=Er(t)+"px",e.sizer.style.marginBottom=-e.nativeBarWidth+"px",e.sizer.style.borderRightWidth=Er(t)+"px",e.scrollbarsClipped=!0)}(e),t.updateMaxLine&&Ve(e),t.mustUpdate=t.viewChanged||t.forceUpdate||null!=t.scrollTop||t.scrollToPos&&(t.scrollToPos.from.line<r.viewFrom||t.scrollToPos.to.line>=r.viewTo)||r.maxLineChanged&&e.options.lineWrapping,t.update=t.mustUpdate&&new on(e,t.mustUpdate&&{top:t.scrollTop,ensure:t.scrollToPos},t.forceUpdate)}function Yi(t){t.updatedDisplay=t.mustUpdate&&sn(t.cm,t.update)}function Xi(t){var e=t.cm,r=e.display;t.updatedDisplay&&Ei(e),t.barMeasure=Fi(e),r.maxLineChanged&&!e.options.lineWrapping&&(t.adjustWidthTo=Dr(e,r.maxLine,r.maxLine.text.length).left+3,e.display.sizerWidth=t.adjustWidthTo,t.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+t.adjustWidthTo+Er(e)+e.display.barWidth),t.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+t.adjustWidthTo-Tr(e))),(t.updatedDisplay||t.selectionChanged)&&(t.preparedSelection=r.input.prepareSelection())}function $i(t){var e=t.cm;null!=t.adjustWidthTo&&(e.display.sizer.style.minWidth=t.adjustWidthTo+"px",t.maxScrollLeft<e.doc.scrollLeft&&Ni(e,Math.min(e.display.scroller.scrollLeft,t.maxScrollLeft),!0),e.display.maxLineChanged=!1);var r=t.focus&&t.focus==_();t.preparedSelection&&e.display.input.showSelection(t.preparedSelection,r),(t.updatedDisplay||t.startHeight!=e.doc.height)&&Ui(e,t.barMeasure),t.updatedDisplay&&un(e,t.barMeasure),t.selectionChanged&&xi(e),e.state.focused&&t.updateInput&&e.display.input.reset(t.typing),r&&Si(t.cm)}function Zi(t){var e=t.cm,r=e.display,i=e.doc;t.updatedDisplay&&an(e,t.update),null==r.wheelStartX||null==t.scrollTop&&null==t.scrollLeft&&!t.scrollToPos||(r.wheelStartX=r.wheelStartY=null),null!=t.scrollTop&&Pi(e,t.scrollTop,t.forceScroll),null!=t.scrollLeft&&Ni(e,t.scrollLeft,!0,!0),t.scrollToPos&&function(t,e){if(!gt(t,"scrollCursorIntoView")){var r=t.display,i=r.sizer.getBoundingClientRect(),n=null;if(e.top+i.top<0?n=!0:e.bottom+i.top>(window.innerHeight||document.documentElement.clientHeight)&&(n=!1),null!=n&&!p){var o=D("div","",null,"position: absolute;\n top: "+(e.top-r.viewOffset-Cr(t.display))+"px;\n height: "+(e.bottom-e.top+Er(t)+r.barHeight)+"px;\n left: "+e.left+"px; width: "+Math.max(2,e.right-e.left)+"px;");t.display.lineSpace.appendChild(o),o.scrollIntoView(n),t.display.lineSpace.removeChild(o)}}}(e,function(t,e,r,i){var n;null==i&&(i=0),t.options.lineWrapping||e!=r||(r="before"==(e=e.ch?te(e.line,"before"==e.sticky?e.ch-1:e.ch,"after"):e).sticky?te(e.line,e.ch+1,"before"):e);for(var o=0;o<5;o++){var s=!1,a=Kr(t,e),l=r&&r!=e?Kr(t,r):a,c=Ai(t,n={left:Math.min(a.left,l.left),top:Math.min(a.top,l.top)-i,right:Math.max(a.left,l.left),bottom:Math.max(a.bottom,l.bottom)+i}),u=t.doc.scrollTop,h=t.doc.scrollLeft;if(null!=c.scrollTop&&(Mi(t,c.scrollTop),Math.abs(t.doc.scrollTop-u)>1&&(s=!0)),null!=c.scrollLeft&&(Ni(t,c.scrollLeft),Math.abs(t.doc.scrollLeft-h)>1&&(s=!0)),!s)break}return n}(e,ae(i,t.scrollToPos.from),ae(i,t.scrollToPos.to),t.scrollToPos.margin));var n=t.maybeHiddenMarkers,o=t.maybeUnhiddenMarkers;if(n)for(var s=0;s<n.length;++s)n[s].lines.length||pt(n[s],"hide");if(o)for(var a=0;a<o.length;++a)o[a].lines.length&&pt(o[a],"unhide");r.wrapper.offsetHeight&&(i.scrollTop=e.display.scroller.scrollTop),t.changeObjs&&pt(e,"changes",e,t.changeObjs),t.update&&t.update.finish()}function Qi(t,e){if(t.curOp)return e();Vi(t);try{return e()}finally{Ki(t)}}function Ji(t,e){return function(){if(t.curOp)return e.apply(t,arguments);Vi(t);try{return e.apply(t,arguments)}finally{Ki(t)}}}function tn(t){return function(){if(this.curOp)return t.apply(this,arguments);Vi(this);try{return t.apply(this,arguments)}finally{Ki(this)}}}function en(t){return function(){var e=this.cm;if(!e||e.curOp)return t.apply(this,arguments);Vi(e);try{return t.apply(this,arguments)}finally{Ki(e)}}}function rn(t,e){t.doc.highlightFrontier<t.display.viewTo&&t.state.highlight.set(e,N(nn,t))}function nn(t){var e=t.doc;if(!(e.highlightFrontier>=t.display.viewTo)){var r=+new Date+t.options.workTime,i=fe(t,e.highlightFrontier),n=[];e.iter(i.line,Math.min(e.first+e.size,t.display.viewTo+500),(function(o){if(i.line>=t.display.viewFrom){var s=o.styles,a=o.text.length>t.options.maxHighlightLength?Gt(e.mode,i.state):null,l=he(t,o,i,!0);a&&(i.state=a),o.styles=l.styles;var c=o.styleClasses,u=l.classes;u?o.styleClasses=u:c&&(o.styleClasses=null);for(var h=!s||s.length!=o.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),d=0;!h&&d<s.length;++d)h=s[d]!=o.styles[d];h&&n.push(i.line),o.stateAfter=i.save(),i.nextLine()}else o.text.length<=t.options.maxHighlightLength&&pe(t,o.text,i),o.stateAfter=i.line%5==0?i.save():null,i.nextLine();if(+new Date>r)return rn(t,t.options.workDelay),!0})),e.highlightFrontier=i.line,e.modeFrontier=Math.max(e.modeFrontier,i.line),n.length&&Qi(t,(function(){for(var e=0;e<n.length;e++)hi(t,n[e],"text")}))}}var on=function(t,e,r){var i=t.display;this.viewport=e,this.visible=Li(i,t.doc,e),this.editorIsHidden=!i.wrapper.offsetWidth,this.wrapperHeight=i.wrapper.clientHeight,this.wrapperWidth=i.wrapper.clientWidth,this.oldDisplayWidth=Tr(t),this.force=r,this.dims=ni(t),this.events=[]};function sn(t,e){var r=t.display,i=t.doc;if(e.editorIsHidden)return di(t),!1;if(!e.force&&e.visible.from>=r.viewFrom&&e.visible.to<=r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&0==pi(t))return!1;dn(t)&&(di(t),e.dims=ni(t));var n=i.first+i.size,o=Math.max(e.visible.from-t.options.viewportMargin,i.first),s=Math.min(n,e.visible.to+t.options.viewportMargin);r.viewFrom<o&&o-r.viewFrom<20&&(o=Math.max(i.first,r.viewFrom)),r.viewTo>s&&r.viewTo-s<20&&(s=Math.min(n,r.viewTo)),Ce&&(o=je(t.doc,o),s=Ue(t.doc,s));var a=o!=r.viewFrom||s!=r.viewTo||r.lastWrapHeight!=e.wrapperHeight||r.lastWrapWidth!=e.wrapperWidth;!function(t,e,r){var i=t.display;0==i.view.length||e>=i.viewTo||r<=i.viewFrom?(i.view=nr(t,e,r),i.viewFrom=e):(i.viewFrom>e?i.view=nr(t,e,i.viewFrom).concat(i.view):i.viewFrom<e&&(i.view=i.view.slice(ci(t,e))),i.viewFrom=e,i.viewTo<r?i.view=i.view.concat(nr(t,i.viewTo,r)):i.viewTo>r&&(i.view=i.view.slice(0,ci(t,r)))),i.viewTo=r}(t,o,s),r.viewOffset=ze(Kt(t.doc,r.viewFrom)),t.display.mover.style.top=r.viewOffset+"px";var c=pi(t);if(!a&&0==c&&!e.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var u=function(t){if(t.hasFocus())return null;var e=_();if(!e||!R(t.display.lineDiv,e))return null;var r={activeElt:e};if(window.getSelection){var i=window.getSelection();i.anchorNode&&i.extend&&R(t.display.lineDiv,i.anchorNode)&&(r.anchorNode=i.anchorNode,r.anchorOffset=i.anchorOffset,r.focusNode=i.focusNode,r.focusOffset=i.focusOffset)}return r}(t);return c>4&&(r.lineDiv.style.display="none"),function(t,e,r){var i=t.display,n=t.options.lineNumbers,o=i.lineDiv,s=o.firstChild;function a(e){var r=e.nextSibling;return l&&y&&t.display.currentWheelTarget==e?e.style.display="none":e.parentNode.removeChild(e),r}for(var c=i.view,u=i.viewFrom,h=0;h<c.length;h++){var d=c[h];if(d.hidden);else if(d.node&&d.node.parentNode==o){for(;s!=d.node;)s=a(s);var f=n&&null!=e&&e<=u&&d.lineNumber;d.changes&&(U(d.changes,"gutter")>-1&&(f=!1),cr(t,d,u,r)),f&&(L(d.lineNumber),d.lineNumber.appendChild(document.createTextNode(Jt(t.options,u)))),s=d.node.nextSibling}else{var p=mr(t,d,u,r);o.insertBefore(p,s)}u+=d.size}for(;s;)s=a(s)}(t,r.updateLineNumbers,e.dims),c>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,function(t){if(t&&t.activeElt&&t.activeElt!=_()&&(t.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(t.activeElt.nodeName)&&t.anchorNode&&R(document.body,t.anchorNode)&&R(document.body,t.focusNode))){var e=window.getSelection(),r=document.createRange();r.setEnd(t.anchorNode,t.anchorOffset),r.collapse(!1),e.removeAllRanges(),e.addRange(r),e.extend(t.focusNode,t.focusOffset)}}(u),L(r.cursorDiv),L(r.selectionDiv),r.gutters.style.height=r.sizer.style.minHeight=0,a&&(r.lastWrapHeight=e.wrapperHeight,r.lastWrapWidth=e.wrapperWidth,rn(t,400)),r.updateLineNumbers=null,!0}function an(t,e){for(var r=e.viewport,i=!0;;i=!1){if(i&&t.options.lineWrapping&&e.oldDisplayWidth!=Tr(t))i&&(e.visible=Li(t.display,t.doc,r));else if(r&&null!=r.top&&(r={top:Math.min(t.doc.height+wr(t.display)-Lr(t),r.top)}),e.visible=Li(t.display,t.doc,r),e.visible.from>=t.display.viewFrom&&e.visible.to<=t.display.viewTo)break;if(!sn(t,e))break;Ei(t);var n=Fi(t);gi(t),Ui(t,n),un(t,n),e.force=!1}e.signal(t,"update",t),t.display.viewFrom==t.display.reportedViewFrom&&t.display.viewTo==t.display.reportedViewTo||(e.signal(t,"viewportChange",t,t.display.viewFrom,t.display.viewTo),t.display.reportedViewFrom=t.display.viewFrom,t.display.reportedViewTo=t.display.viewTo)}function ln(t,e){var r=new on(t,e);if(sn(t,r)){Ei(t),an(t,r);var i=Fi(t);gi(t),Ui(t,i),un(t,i),r.finish()}}function cn(t){var e=t.gutters.offsetWidth;t.sizer.style.marginLeft=e+"px"}function un(t,e){t.display.sizer.style.minHeight=e.docHeight+"px",t.display.heightForcer.style.top=e.docHeight+"px",t.display.gutters.style.height=e.docHeight+t.display.barHeight+Er(t)+"px"}function hn(t){var e=t.display,r=e.view;if(e.alignWidgets||e.gutters.firstChild&&t.options.fixedGutter){for(var i=oi(e)-e.scroller.scrollLeft+t.doc.scrollLeft,n=e.gutters.offsetWidth,o=i+"px",s=0;s<r.length;s++)if(!r[s].hidden){t.options.fixedGutter&&(r[s].gutter&&(r[s].gutter.style.left=o),r[s].gutterBackground&&(r[s].gutterBackground.style.left=o));var a=r[s].alignable;if(a)for(var l=0;l<a.length;l++)a[l].style.left=o}t.options.fixedGutter&&(e.gutters.style.left=i+n+"px")}}function dn(t){if(!t.options.lineNumbers)return!1;var e=t.doc,r=Jt(t.options,e.first+e.size-1),i=t.display;if(r.length!=i.lineNumChars){var n=i.measure.appendChild(D("div",[D("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=n.firstChild.offsetWidth,s=n.offsetWidth-o;return i.lineGutter.style.width="",i.lineNumInnerWidth=Math.max(o,i.lineGutter.offsetWidth-s)+1,i.lineNumWidth=i.lineNumInnerWidth+s,i.lineNumChars=i.lineNumInnerWidth?r.length:-1,i.lineGutter.style.width=i.lineNumWidth+"px",cn(t.display),!0}return!1}function fn(t,e){for(var r=[],i=!1,n=0;n<t.length;n++){var o=t[n],s=null;if("string"!=typeof o&&(s=o.style,o=o.className),"CodeMirror-linenumbers"==o){if(!e)continue;i=!0}r.push({className:o,style:s})}return e&&!i&&r.push({className:"CodeMirror-linenumbers",style:null}),r}function pn(t){var e=t.gutters,r=t.gutterSpecs;L(e),t.lineGutter=null;for(var i=0;i<r.length;++i){var n=r[i],o=n.className,s=n.style,a=e.appendChild(D("div",null,"CodeMirror-gutter "+o));s&&(a.style.cssText=s),"CodeMirror-linenumbers"==o&&(t.lineGutter=a,a.style.width=(t.lineNumWidth||1)+"px")}e.style.display=r.length?"":"none",cn(t)}function gn(t){pn(t.display),ui(t),hn(t)}function mn(t,e,i,n){var o=this;this.input=i,o.scrollbarFiller=D("div",null,"CodeMirror-scrollbar-filler"),o.scrollbarFiller.setAttribute("cm-not-content","true"),o.gutterFiller=D("div",null,"CodeMirror-gutter-filler"),o.gutterFiller.setAttribute("cm-not-content","true"),o.lineDiv=O("div",null,"CodeMirror-code"),o.selectionDiv=D("div",null,null,"position: relative; z-index: 1"),o.cursorDiv=D("div",null,"CodeMirror-cursors"),o.measure=D("div",null,"CodeMirror-measure"),o.lineMeasure=D("div",null,"CodeMirror-measure"),o.lineSpace=O("div",[o.measure,o.lineMeasure,o.selectionDiv,o.cursorDiv,o.lineDiv],null,"position: relative; outline: none");var c=O("div",[o.lineSpace],"CodeMirror-lines");o.mover=D("div",[c],null,"position: relative"),o.sizer=D("div",[o.mover],"CodeMirror-sizer"),o.sizerWidth=null,o.heightForcer=D("div",null,null,"position: absolute; height: 50px; width: 1px;"),o.gutters=D("div",null,"CodeMirror-gutters"),o.lineGutter=null,o.scroller=D("div",[o.sizer,o.heightForcer,o.gutters],"CodeMirror-scroll"),o.scroller.setAttribute("tabIndex","-1"),o.wrapper=D("div",[o.scrollbarFiller,o.gutterFiller,o.scroller],"CodeMirror"),s&&a<8&&(o.gutters.style.zIndex=-1,o.scroller.style.paddingRight=0),l||r&&v||(o.scroller.draggable=!0),t&&(t.appendChild?t.appendChild(o.wrapper):t(o.wrapper)),o.viewFrom=o.viewTo=e.first,o.reportedViewFrom=o.reportedViewTo=e.first,o.view=[],o.renderedView=null,o.externalMeasured=null,o.viewOffset=0,o.lastWrapHeight=o.lastWrapWidth=0,o.updateLineNumbers=null,o.nativeBarWidth=o.barHeight=o.barWidth=0,o.scrollbarsClipped=!1,o.lineNumWidth=o.lineNumInnerWidth=o.lineNumChars=null,o.alignWidgets=!1,o.cachedCharWidth=o.cachedTextHeight=o.cachedPaddingH=null,o.maxLine=null,o.maxLineLength=0,o.maxLineChanged=!1,o.wheelDX=o.wheelDY=o.wheelStartX=o.wheelStartY=null,o.shift=!1,o.selForContextMenu=null,o.activeTouch=null,o.gutterSpecs=fn(n.gutters,n.lineNumbers),pn(o),i.init(o)}on.prototype.signal=function(t,e){vt(t,e)&&this.events.push(arguments)},on.prototype.finish=function(){for(var t=0;t<this.events.length;t++)pt.apply(null,this.events[t])};var vn=0,yn=null;function bn(t){var e=t.wheelDeltaX,r=t.wheelDeltaY;return null==e&&t.detail&&t.axis==t.HORIZONTAL_AXIS&&(e=t.detail),null==r&&t.detail&&t.axis==t.VERTICAL_AXIS?r=t.detail:null==r&&(r=t.wheelDelta),{x:e,y:r}}function xn(t){var e=bn(t);return e.x*=yn,e.y*=yn,e}function Sn(t,e){var i=bn(e),n=i.x,o=i.y,s=t.display,a=s.scroller,c=a.scrollWidth>a.clientWidth,u=a.scrollHeight>a.clientHeight;if(n&&c||o&&u){if(o&&y&&l)t:for(var d=e.target,f=s.view;d!=a;d=d.parentNode)for(var p=0;p<f.length;p++)if(f[p].node==d){t.display.currentWheelTarget=d;break t}if(n&&!r&&!h&&null!=yn)return o&&u&&Mi(t,Math.max(0,a.scrollTop+o*yn)),Ni(t,Math.max(0,a.scrollLeft+n*yn)),(!o||o&&u)&&bt(e),void(s.wheelStartX=null);if(o&&null!=yn){var g=o*yn,m=t.doc.scrollTop,v=m+s.wrapper.clientHeight;g<0?m=Math.max(0,m+g-50):v=Math.min(t.doc.height,v+g+50),ln(t,{top:m,bottom:v})}vn<20&&(null==s.wheelStartX?(s.wheelStartX=a.scrollLeft,s.wheelStartY=a.scrollTop,s.wheelDX=n,s.wheelDY=o,setTimeout((function(){if(null!=s.wheelStartX){var t=a.scrollLeft-s.wheelStartX,e=a.scrollTop-s.wheelStartY,r=e&&s.wheelDY&&e/s.wheelDY||t&&s.wheelDX&&t/s.wheelDX;s.wheelStartX=s.wheelStartY=null,r&&(yn=(yn*vn+r)/(vn+1),++vn)}}),200)):(s.wheelDX+=n,s.wheelDY+=o))}}s?yn=-.53:r?yn=15:u?yn=-.7:d&&(yn=-1/3);var Cn=function(t,e){this.ranges=t,this.primIndex=e};Cn.prototype.primary=function(){return this.ranges[this.primIndex]},Cn.prototype.equals=function(t){if(t==this)return!0;if(t.primIndex!=this.primIndex||t.ranges.length!=this.ranges.length)return!1;for(var e=0;e<this.ranges.length;e++){var r=this.ranges[e],i=t.ranges[e];if(!re(r.anchor,i.anchor)||!re(r.head,i.head))return!1}return!0},Cn.prototype.deepCopy=function(){for(var t=[],e=0;e<this.ranges.length;e++)t[e]=new wn(ie(this.ranges[e].anchor),ie(this.ranges[e].head));return new Cn(t,this.primIndex)},Cn.prototype.somethingSelected=function(){for(var t=0;t<this.ranges.length;t++)if(!this.ranges[t].empty())return!0;return!1},Cn.prototype.contains=function(t,e){e||(e=t);for(var r=0;r<this.ranges.length;r++){var i=this.ranges[r];if(ee(e,i.from())>=0&&ee(t,i.to())<=0)return r}return-1};var wn=function(t,e){this.anchor=t,this.head=e};function kn(t,e,r){var i=t&&t.options.selectionsMayTouch,n=e[r];e.sort((function(t,e){return ee(t.from(),e.from())})),r=U(e,n);for(var o=1;o<e.length;o++){var s=e[o],a=e[o-1],l=ee(a.to(),s.from());if(i&&!s.empty()?l>0:l>=0){var c=oe(a.from(),s.from()),u=ne(a.to(),s.to()),h=a.empty()?s.from()==s.head:a.from()==a.head;o<=r&&--r,e.splice(--o,2,new wn(h?u:c,h?c:u))}}return new Cn(e,r)}function En(t,e){return new Cn([new wn(t,e||t)],0)}function Tn(t){return t.text?te(t.from.line+t.text.length-1,Y(t.text).length+(1==t.text.length?t.from.ch:0)):t.to}function Ln(t,e){if(ee(t,e.from)<0)return t;if(ee(t,e.to)<=0)return Tn(e);var r=t.line+e.text.length-(e.to.line-e.from.line)-1,i=t.ch;return t.line==e.to.line&&(i+=Tn(e).ch-e.to.ch),te(r,i)}function An(t,e){for(var r=[],i=0;i<t.sel.ranges.length;i++){var n=t.sel.ranges[i];r.push(new wn(Ln(n.anchor,e),Ln(n.head,e)))}return kn(t.cm,r,t.sel.primIndex)}function Dn(t,e,r){return t.line==e.line?te(r.line,t.ch-e.ch+r.ch):te(r.line+(t.line-e.line),t.ch)}function On(t){t.doc.mode=jt(t.options,t.doc.modeOption),Rn(t)}function Rn(t){t.doc.iter((function(t){t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null)})),t.doc.modeFrontier=t.doc.highlightFrontier=t.doc.first,rn(t,100),t.state.modeGen++,t.curOp&&ui(t)}function _n(t,e){return 0==e.from.ch&&0==e.to.ch&&""==Y(e.text)&&(!t.cm||t.cm.options.wholeLineUpdateBefore)}function In(t,e,r,i){function n(t){return r?r[t]:null}function o(t,r,n){!function(t,e,r,i){t.text=e,t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null),null!=t.order&&(t.order=null),Ae(t),De(t,r);var n=i?i(t):1;n!=t.height&&Xt(t,n)}(t,r,n,i),ar(t,"change",t,e)}function s(t,e){for(var r=[],o=t;o<e;++o)r.push(new Ke(c[o],n(o),i));return r}var a=e.from,l=e.to,c=e.text,u=Kt(t,a.line),h=Kt(t,l.line),d=Y(c),f=n(c.length-1),p=l.line-a.line;if(e.full)t.insert(0,s(0,c.length)),t.remove(c.length,t.size-c.length);else if(_n(t,e)){var g=s(0,c.length-1);o(h,h.text,f),p&&t.remove(a.line,p),g.length&&t.insert(a.line,g)}else if(u==h)if(1==c.length)o(u,u.text.slice(0,a.ch)+d+u.text.slice(l.ch),f);else{var m=s(1,c.length-1);m.push(new Ke(d+u.text.slice(l.ch),f,i)),o(u,u.text.slice(0,a.ch)+c[0],n(0)),t.insert(a.line+1,m)}else if(1==c.length)o(u,u.text.slice(0,a.ch)+c[0]+h.text.slice(l.ch),n(0)),t.remove(a.line+1,p);else{o(u,u.text.slice(0,a.ch)+c[0],n(0)),o(h,d+h.text.slice(l.ch),f);var v=s(1,c.length-1);p>1&&t.remove(a.line+1,p-1),t.insert(a.line+1,v)}ar(t,"change",t,e)}function Mn(t,e,r){!function t(i,n,o){if(i.linked)for(var s=0;s<i.linked.length;++s){var a=i.linked[s];if(a.doc!=n){var l=o&&a.sharedHist;r&&!l||(e(a.doc,l),t(a.doc,i,l))}}}(t,null,!0)}function Pn(t,e){if(e.cm)throw new Error("This document is already in use.");t.doc=e,e.cm=t,ai(t),On(t),Nn(t),t.options.lineWrapping||Ve(t),t.options.mode=e.modeOption,ui(t)}function Nn(t){("rtl"==t.doc.direction?I:T)(t.display.lineDiv,"CodeMirror-rtl")}function Fn(t){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=t||1}function Bn(t,e){var r={from:ie(e.from),to:Tn(e),text:qt(t,e.from,e.to)};return zn(t,r,e.from.line,e.to.line+1),Mn(t,(function(t){return zn(t,r,e.from.line,e.to.line+1)}),!0),r}function jn(t){for(;t.length&&Y(t).ranges;)t.pop()}function Un(t,e,r,i){var n=t.history;n.undone.length=0;var o,s,a=+new Date;if((n.lastOp==i||n.lastOrigin==e.origin&&e.origin&&("+"==e.origin.charAt(0)&&n.lastModTime>a-(t.cm?t.cm.options.historyEventDelay:500)||"*"==e.origin.charAt(0)))&&(o=function(t,e){return e?(jn(t.done),Y(t.done)):t.done.length&&!Y(t.done).ranges?Y(t.done):t.done.length>1&&!t.done[t.done.length-2].ranges?(t.done.pop(),Y(t.done)):void 0}(n,n.lastOp==i)))s=Y(o.changes),0==ee(e.from,e.to)&&0==ee(e.from,s.to)?s.to=Tn(e):o.changes.push(Bn(t,e));else{var l=Y(n.done);for(l&&l.ranges||Gn(t.sel,n.done),o={changes:[Bn(t,e)],generation:n.generation},n.done.push(o);n.done.length>n.undoDepth;)n.done.shift(),n.done[0].ranges||n.done.shift()}n.done.push(r),n.generation=++n.maxGeneration,n.lastModTime=n.lastSelTime=a,n.lastOp=n.lastSelOp=i,n.lastOrigin=n.lastSelOrigin=e.origin,s||pt(t,"historyAdded")}function Hn(t,e,r,i){var n=t.history,o=i&&i.origin;r==n.lastSelOp||o&&n.lastSelOrigin==o&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==o||function(t,e,r,i){var n=e.charAt(0);return"*"==n||"+"==n&&r.ranges.length==i.ranges.length&&r.somethingSelected()==i.somethingSelected()&&new Date-t.history.lastSelTime<=(t.cm?t.cm.options.historyEventDelay:500)}(t,o,Y(n.done),e))?n.done[n.done.length-1]=e:Gn(e,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=o,n.lastSelOp=r,i&&!1!==i.clearRedo&&jn(n.undone)}function Gn(t,e){var r=Y(e);r&&r.ranges&&r.equals(t)||e.push(t)}function zn(t,e,r,i){var n=e["spans_"+t.id],o=0;t.iter(Math.max(t.first,r),Math.min(t.first+t.size,i),(function(r){r.markedSpans&&((n||(n=e["spans_"+t.id]={}))[o]=r.markedSpans),++o}))}function Wn(t){if(!t)return null;for(var e,r=0;r<t.length;++r)t[r].marker.explicitlyCleared?e||(e=t.slice(0,r)):e&&e.push(t[r]);return e?e.length?e:null:t}function Vn(t,e){var r=function(t,e){var r=e["spans_"+t.id];if(!r)return null;for(var i=[],n=0;n<e.text.length;++n)i.push(Wn(r[n]));return i}(t,e),i=Te(t,e);if(!r)return i;if(!i)return r;for(var n=0;n<r.length;++n){var o=r[n],s=i[n];if(o&&s)t:for(var a=0;a<s.length;++a){for(var l=s[a],c=0;c<o.length;++c)if(o[c].marker==l.marker)continue t;o.push(l)}else s&&(r[n]=s)}return r}function Kn(t,e,r){for(var i=[],n=0;n<t.length;++n){var o=t[n];if(o.ranges)i.push(r?Cn.prototype.deepCopy.call(o):o);else{var s=o.changes,a=[];i.push({changes:a});for(var l=0;l<s.length;++l){var c=s[l],u=void 0;if(a.push({from:c.from,to:c.to,text:c.text}),e)for(var h in c)(u=h.match(/^spans_(\d+)$/))&&U(e,Number(u[1]))>-1&&(Y(a)[h]=c[h],delete c[h])}}}return i}function qn(t,e,r,i){if(i){var n=t.anchor;if(r){var o=ee(e,n)<0;o!=ee(r,n)<0?(n=e,e=r):o!=ee(e,r)<0&&(e=r)}return new wn(n,e)}return new wn(r||e,e)}function Yn(t,e,r,i,n){null==n&&(n=t.cm&&(t.cm.display.shift||t.extend)),Jn(t,new Cn([qn(t.sel.primary(),e,r,n)],0),i)}function Xn(t,e,r){for(var i=[],n=t.cm&&(t.cm.display.shift||t.extend),o=0;o<t.sel.ranges.length;o++)i[o]=qn(t.sel.ranges[o],e[o],null,n);Jn(t,kn(t.cm,i,t.sel.primIndex),r)}function $n(t,e,r,i){var n=t.sel.ranges.slice(0);n[e]=r,Jn(t,kn(t.cm,n,t.sel.primIndex),i)}function Zn(t,e,r,i){Jn(t,En(e,r),i)}function Qn(t,e,r){var i=t.history.done,n=Y(i);n&&n.ranges?(i[i.length-1]=e,to(t,e,r)):Jn(t,e,r)}function Jn(t,e,r){to(t,e,r),Hn(t,t.sel,t.cm?t.cm.curOp.id:NaN,r)}function to(t,e,r){(vt(t,"beforeSelectionChange")||t.cm&&vt(t.cm,"beforeSelectionChange"))&&(e=function(t,e,r){var i={ranges:e.ranges,update:function(e){this.ranges=[];for(var r=0;r<e.length;r++)this.ranges[r]=new wn(ae(t,e[r].anchor),ae(t,e[r].head))},origin:r&&r.origin};return pt(t,"beforeSelectionChange",t,i),t.cm&&pt(t.cm,"beforeSelectionChange",t.cm,i),i.ranges!=e.ranges?kn(t.cm,i.ranges,i.ranges.length-1):e}(t,e,r));var i=r&&r.bias||(ee(e.primary().head,t.sel.primary().head)<0?-1:1);eo(t,io(t,e,i,!0)),r&&!1===r.scroll||!t.cm||Oi(t.cm)}function eo(t,e){e.equals(t.sel)||(t.sel=e,t.cm&&(t.cm.curOp.updateInput=1,t.cm.curOp.selectionChanged=!0,mt(t.cm)),ar(t,"cursorActivity",t))}function ro(t){eo(t,io(t,t.sel,null,!1))}function io(t,e,r,i){for(var n,o=0;o<e.ranges.length;o++){var s=e.ranges[o],a=e.ranges.length==t.sel.ranges.length&&t.sel.ranges[o],l=oo(t,s.anchor,a&&a.anchor,r,i),c=oo(t,s.head,a&&a.head,r,i);(n||l!=s.anchor||c!=s.head)&&(n||(n=e.ranges.slice(0,o)),n[o]=new wn(l,c))}return n?kn(t.cm,n,e.primIndex):e}function no(t,e,r,i,n){var o=Kt(t,e.line);if(o.markedSpans)for(var s=0;s<o.markedSpans.length;++s){var a=o.markedSpans[s],l=a.marker,c="selectLeft"in l?!l.selectLeft:l.inclusiveLeft,u="selectRight"in l?!l.selectRight:l.inclusiveRight;if((null==a.from||(c?a.from<=e.ch:a.from<e.ch))&&(null==a.to||(u?a.to>=e.ch:a.to>e.ch))){if(n&&(pt(l,"beforeCursorEnter"),l.explicitlyCleared)){if(o.markedSpans){--s;continue}break}if(!l.atomic)continue;if(r){var h=l.find(i<0?1:-1),d=void 0;if((i<0?u:c)&&(h=so(t,h,-i,h&&h.line==e.line?o:null)),h&&h.line==e.line&&(d=ee(h,r))&&(i<0?d<0:d>0))return no(t,h,e,i,n)}var f=l.find(i<0?-1:1);return(i<0?c:u)&&(f=so(t,f,i,f.line==e.line?o:null)),f?no(t,f,e,i,n):null}}return e}function oo(t,e,r,i,n){var o=i||1,s=no(t,e,r,o,n)||!n&&no(t,e,r,o,!0)||no(t,e,r,-o,n)||!n&&no(t,e,r,-o,!0);return s||(t.cantEdit=!0,te(t.first,0))}function so(t,e,r,i){return r<0&&0==e.ch?e.line>t.first?ae(t,te(e.line-1)):null:r>0&&e.ch==(i||Kt(t,e.line)).text.length?e.line<t.first+t.size-1?te(e.line+1,0):null:new te(e.line,e.ch+r)}function ao(t){t.setSelection(te(t.firstLine(),0),te(t.lastLine()),G)}function lo(t,e,r){var i={canceled:!1,from:e.from,to:e.to,text:e.text,origin:e.origin,cancel:function(){return i.canceled=!0}};return r&&(i.update=function(e,r,n,o){e&&(i.from=ae(t,e)),r&&(i.to=ae(t,r)),n&&(i.text=n),void 0!==o&&(i.origin=o)}),pt(t,"beforeChange",t,i),t.cm&&pt(t.cm,"beforeChange",t.cm,i),i.canceled?(t.cm&&(t.cm.curOp.updateInput=2),null):{from:i.from,to:i.to,text:i.text,origin:i.origin}}function co(t,e,r){if(t.cm){if(!t.cm.curOp)return Ji(t.cm,co)(t,e,r);if(t.cm.state.suppressEdits)return}if(!(vt(t,"beforeChange")||t.cm&&vt(t.cm,"beforeChange"))||(e=lo(t,e,!0))){var i=Se&&!r&&function(t,e,r){var i=null;if(t.iter(e.line,r.line+1,(function(t){if(t.markedSpans)for(var e=0;e<t.markedSpans.length;++e){var r=t.markedSpans[e].marker;!r.readOnly||i&&-1!=U(i,r)||(i||(i=[])).push(r)}})),!i)return null;for(var n=[{from:e,to:r}],o=0;o<i.length;++o)for(var s=i[o],a=s.find(0),l=0;l<n.length;++l){var c=n[l];if(!(ee(c.to,a.from)<0||ee(c.from,a.to)>0)){var u=[l,1],h=ee(c.from,a.from),d=ee(c.to,a.to);(h<0||!s.inclusiveLeft&&!h)&&u.push({from:c.from,to:a.from}),(d>0||!s.inclusiveRight&&!d)&&u.push({from:a.to,to:c.to}),n.splice.apply(n,u),l+=u.length-3}}return n}(t,e.from,e.to);if(i)for(var n=i.length-1;n>=0;--n)uo(t,{from:i[n].from,to:i[n].to,text:n?[""]:e.text,origin:e.origin});else uo(t,e)}}function uo(t,e){if(1!=e.text.length||""!=e.text[0]||0!=ee(e.from,e.to)){var r=An(t,e);Un(t,e,r,t.cm?t.cm.curOp.id:NaN),po(t,e,r,Te(t,e));var i=[];Mn(t,(function(t,r){r||-1!=U(i,t.history)||(yo(t.history,e),i.push(t.history)),po(t,e,null,Te(t,e))}))}}function ho(t,e,r){var i=t.cm&&t.cm.state.suppressEdits;if(!i||r){for(var n,o=t.history,s=t.sel,a="undo"==e?o.done:o.undone,l="undo"==e?o.undone:o.done,c=0;c<a.length&&(n=a[c],r?!n.ranges||n.equals(t.sel):n.ranges);c++);if(c!=a.length){for(o.lastOrigin=o.lastSelOrigin=null;;){if(!(n=a.pop()).ranges){if(i)return void a.push(n);break}if(Gn(n,l),r&&!n.equals(t.sel))return void Jn(t,n,{clearRedo:!1});s=n}var u=[];Gn(s,l),l.push({changes:u,generation:o.generation}),o.generation=n.generation||++o.maxGeneration;for(var h=vt(t,"beforeChange")||t.cm&&vt(t.cm,"beforeChange"),d=function(r){var i=n.changes[r];if(i.origin=e,h&&!lo(t,i,!1))return a.length=0,{};u.push(Bn(t,i));var o=r?An(t,i):Y(a);po(t,i,o,Vn(t,i)),!r&&t.cm&&t.cm.scrollIntoView({from:i.from,to:Tn(i)});var s=[];Mn(t,(function(t,e){e||-1!=U(s,t.history)||(yo(t.history,i),s.push(t.history)),po(t,i,null,Vn(t,i))}))},f=n.changes.length-1;f>=0;--f){var p=d(f);if(p)return p.v}}}}function fo(t,e){if(0!=e&&(t.first+=e,t.sel=new Cn(X(t.sel.ranges,(function(t){return new wn(te(t.anchor.line+e,t.anchor.ch),te(t.head.line+e,t.head.ch))})),t.sel.primIndex),t.cm)){ui(t.cm,t.first,t.first-e,e);for(var r=t.cm.display,i=r.viewFrom;i<r.viewTo;i++)hi(t.cm,i,"gutter")}}function po(t,e,r,i){if(t.cm&&!t.cm.curOp)return Ji(t.cm,po)(t,e,r,i);if(e.to.line<t.first)fo(t,e.text.length-1-(e.to.line-e.from.line));else if(!(e.from.line>t.lastLine())){if(e.from.line<t.first){var n=e.text.length-1-(t.first-e.from.line);fo(t,n),e={from:te(t.first,0),to:te(e.to.line+n,e.to.ch),text:[Y(e.text)],origin:e.origin}}var o=t.lastLine();e.to.line>o&&(e={from:e.from,to:te(o,Kt(t,o).text.length),text:[e.text[0]],origin:e.origin}),e.removed=qt(t,e.from,e.to),r||(r=An(t,e)),t.cm?function(t,e,r){var i=t.doc,n=t.display,o=e.from,s=e.to,a=!1,l=o.line;t.options.lineWrapping||(l=$t(Be(Kt(i,o.line))),i.iter(l,s.line+1,(function(t){if(t==n.maxLine)return a=!0,!0}))),i.sel.contains(e.from,e.to)>-1&&mt(t),In(i,e,r,si(t)),t.options.lineWrapping||(i.iter(l,o.line+e.text.length,(function(t){var e=We(t);e>n.maxLineLength&&(n.maxLine=t,n.maxLineLength=e,n.maxLineChanged=!0,a=!1)})),a&&(t.curOp.updateMaxLine=!0)),function(t,e){if(t.modeFrontier=Math.min(t.modeFrontier,e),!(t.highlightFrontier<e-10)){for(var r=t.first,i=e-1;i>r;i--){var n=Kt(t,i).stateAfter;if(n&&(!(n instanceof ce)||i+n.lookAhead<e)){r=i+1;break}}t.highlightFrontier=Math.min(t.highlightFrontier,r)}}(i,o.line),rn(t,400);var c=e.text.length-(s.line-o.line)-1;e.full?ui(t):o.line!=s.line||1!=e.text.length||_n(t.doc,e)?ui(t,o.line,s.line+1,c):hi(t,o.line,"text");var u=vt(t,"changes"),h=vt(t,"change");if(h||u){var d={from:o,to:s,text:e.text,removed:e.removed,origin:e.origin};h&&ar(t,"change",t,d),u&&(t.curOp.changeObjs||(t.curOp.changeObjs=[])).push(d)}t.display.selForContextMenu=null}(t.cm,e,i):In(t,e,i),to(t,r,G),t.cantEdit&&oo(t,te(t.firstLine(),0))&&(t.cantEdit=!1)}}function go(t,e,r,i,n){var o;i||(i=r),ee(i,r)<0&&(r=(o=[i,r])[0],i=o[1]),"string"==typeof e&&(e=t.splitLines(e)),co(t,{from:r,to:i,text:e,origin:n})}function mo(t,e,r,i){r<t.line?t.line+=i:e<t.line&&(t.line=e,t.ch=0)}function vo(t,e,r,i){for(var n=0;n<t.length;++n){var o=t[n],s=!0;if(o.ranges){o.copied||((o=t[n]=o.deepCopy()).copied=!0);for(var a=0;a<o.ranges.length;a++)mo(o.ranges[a].anchor,e,r,i),mo(o.ranges[a].head,e,r,i)}else{for(var l=0;l<o.changes.length;++l){var c=o.changes[l];if(r<c.from.line)c.from=te(c.from.line+i,c.from.ch),c.to=te(c.to.line+i,c.to.ch);else if(e<=c.to.line){s=!1;break}}s||(t.splice(0,n+1),n=0)}}}function yo(t,e){var r=e.from.line,i=e.to.line,n=e.text.length-(i-r)-1;vo(t.done,r,i,n),vo(t.undone,r,i,n)}function bo(t,e,r,i){var n=e,o=e;return"number"==typeof e?o=Kt(t,se(t,e)):n=$t(e),null==n?null:(i(o,n)&&t.cm&&hi(t.cm,n,r),o)}function xo(t){this.lines=t,this.parent=null;for(var e=0,r=0;r<t.length;++r)t[r].parent=this,e+=t[r].height;this.height=e}function So(t){this.children=t;for(var e=0,r=0,i=0;i<t.length;++i){var n=t[i];e+=n.chunkSize(),r+=n.height,n.parent=this}this.size=e,this.height=r,this.parent=null}wn.prototype.from=function(){return oe(this.anchor,this.head)},wn.prototype.to=function(){return ne(this.anchor,this.head)},wn.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch},xo.prototype={chunkSize:function(){return this.lines.length},removeInner:function(t,e){for(var r=t,i=t+e;r<i;++r){var n=this.lines[r];this.height-=n.height,qe(n),ar(n,"delete")}this.lines.splice(t,e)},collapse:function(t){t.push.apply(t,this.lines)},insertInner:function(t,e,r){this.height+=r,this.lines=this.lines.slice(0,t).concat(e).concat(this.lines.slice(t));for(var i=0;i<e.length;++i)e[i].parent=this},iterN:function(t,e,r){for(var i=t+e;t<i;++t)if(r(this.lines[t]))return!0}},So.prototype={chunkSize:function(){return this.size},removeInner:function(t,e){this.size-=e;for(var r=0;r<this.children.length;++r){var i=this.children[r],n=i.chunkSize();if(t<n){var o=Math.min(e,n-t),s=i.height;if(i.removeInner(t,o),this.height-=s-i.height,n==o&&(this.children.splice(r--,1),i.parent=null),0==(e-=o))break;t=0}else t-=n}if(this.size-e<25&&(this.children.length>1||!(this.children[0]instanceof xo))){var a=[];this.collapse(a),this.children=[new xo(a)],this.children[0].parent=this}},collapse:function(t){for(var e=0;e<this.children.length;++e)this.children[e].collapse(t)},insertInner:function(t,e,r){this.size+=e.length,this.height+=r;for(var i=0;i<this.children.length;++i){var n=this.children[i],o=n.chunkSize();if(t<=o){if(n.insertInner(t,e,r),n.lines&&n.lines.length>50){for(var s=n.lines.length%25+25,a=s;a<n.lines.length;){var l=new xo(n.lines.slice(a,a+=25));n.height-=l.height,this.children.splice(++i,0,l),l.parent=this}n.lines=n.lines.slice(0,s),this.maybeSpill()}break}t-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var t=this;do{var e=new So(t.children.splice(t.children.length-5,5));if(t.parent){t.size-=e.size,t.height-=e.height;var r=U(t.parent.children,t);t.parent.children.splice(r+1,0,e)}else{var i=new So(t.children);i.parent=t,t.children=[i,e],t=i}e.parent=t.parent}while(t.children.length>10);t.parent.maybeSpill()}},iterN:function(t,e,r){for(var i=0;i<this.children.length;++i){var n=this.children[i],o=n.chunkSize();if(t<o){var s=Math.min(e,o-t);if(n.iterN(t,s,r))return!0;if(0==(e-=s))break;t=0}else t-=o}}};var Co=function(t,e,r){if(r)for(var i in r)r.hasOwnProperty(i)&&(this[i]=r[i]);this.doc=t,this.node=e};function wo(t,e,r){ze(e)<(t.curOp&&t.curOp.scrollTop||t.doc.scrollTop)&&Di(t,r)}Co.prototype.clear=function(){var t=this.doc.cm,e=this.line.widgets,r=this.line,i=$t(r);if(null!=i&&e){for(var n=0;n<e.length;++n)e[n]==this&&e.splice(n--,1);e.length||(r.widgets=null);var o=xr(this);Xt(r,Math.max(0,r.height-o)),t&&(Qi(t,(function(){wo(t,r,-o),hi(t,i,"widget")})),ar(t,"lineWidgetCleared",t,this,i))}},Co.prototype.changed=function(){var t=this,e=this.height,r=this.doc.cm,i=this.line;this.height=null;var n=xr(this)-e;n&&(He(this.doc,i)||Xt(i,i.height+n),r&&Qi(r,(function(){r.curOp.forceUpdate=!0,wo(r,i,n),ar(r,"lineWidgetChanged",r,t,$t(i))})))},yt(Co);var ko=0,Eo=function(t,e){this.lines=[],this.type=e,this.doc=t,this.id=++ko};function To(t,e,r,i,n){if(i&&i.shared)return function(t,e,r,i,n){(i=F(i)).shared=!1;var o=[To(t,e,r,i,n)],s=o[0],a=i.widgetNode;return Mn(t,(function(t){a&&(i.widgetNode=a.cloneNode(!0)),o.push(To(t,ae(t,e),ae(t,r),i,n));for(var l=0;l<t.linked.length;++l)if(t.linked[l].isParent)return;s=Y(o)})),new Lo(o,s)}(t,e,r,i,n);if(t.cm&&!t.cm.curOp)return Ji(t.cm,To)(t,e,r,i,n);var o=new Eo(t,n),s=ee(e,r);if(i&&F(i,o,!1),s>0||0==s&&!1!==o.clearWhenEmpty)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=O("span",[o.replacedWith],"CodeMirror-widget"),i.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),i.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(Fe(t,e.line,e,r,o)||e.line!=r.line&&Fe(t,r.line,e,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Ce=!0}o.addToHistory&&Un(t,{from:e,to:r,origin:"markText"},t.sel,NaN);var a,l=e.line,c=t.cm;if(t.iter(l,r.line+1,(function(t){c&&o.collapsed&&!c.options.lineWrapping&&Be(t)==c.display.maxLine&&(a=!0),o.collapsed&&l!=e.line&&Xt(t,0),function(t,e){t.markedSpans=t.markedSpans?t.markedSpans.concat([e]):[e],e.marker.attachLine(t)}(t,new we(o,l==e.line?e.ch:null,l==r.line?r.ch:null)),++l})),o.collapsed&&t.iter(e.line,r.line+1,(function(e){He(t,e)&&Xt(e,0)})),o.clearOnEnter&&ht(o,"beforeCursorEnter",(function(){return o.clear()})),o.readOnly&&(Se=!0,(t.history.done.length||t.history.undone.length)&&t.clearHistory()),o.collapsed&&(o.id=++ko,o.atomic=!0),c){if(a&&(c.curOp.updateMaxLine=!0),o.collapsed)ui(c,e.line,r.line+1);else if(o.className||o.startStyle||o.endStyle||o.css||o.attributes||o.title)for(var u=e.line;u<=r.line;u++)hi(c,u,"text");o.atomic&&ro(c.doc),ar(c,"markerAdded",c,o)}return o}Eo.prototype.clear=function(){if(!this.explicitlyCleared){var t=this.doc.cm,e=t&&!t.curOp;if(e&&Vi(t),vt(this,"clear")){var r=this.find();r&&ar(this,"clear",r.from,r.to)}for(var i=null,n=null,o=0;o<this.lines.length;++o){var s=this.lines[o],a=ke(s.markedSpans,this);t&&!this.collapsed?hi(t,$t(s),"text"):t&&(null!=a.to&&(n=$t(s)),null!=a.from&&(i=$t(s))),s.markedSpans=Ee(s.markedSpans,a),null==a.from&&this.collapsed&&!He(this.doc,s)&&t&&Xt(s,ri(t.display))}if(t&&this.collapsed&&!t.options.lineWrapping)for(var l=0;l<this.lines.length;++l){var c=Be(this.lines[l]),u=We(c);u>t.display.maxLineLength&&(t.display.maxLine=c,t.display.maxLineLength=u,t.display.maxLineChanged=!0)}null!=i&&t&&this.collapsed&&ui(t,i,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&ro(t.doc)),t&&ar(t,"markerCleared",t,this,i,n),e&&Ki(t),this.parent&&this.parent.clear()}},Eo.prototype.find=function(t,e){var r,i;null==t&&"bookmark"==this.type&&(t=1);for(var n=0;n<this.lines.length;++n){var o=this.lines[n],s=ke(o.markedSpans,this);if(null!=s.from&&(r=te(e?o:$t(o),s.from),-1==t))return r;if(null!=s.to&&(i=te(e?o:$t(o),s.to),1==t))return i}return r&&{from:r,to:i}},Eo.prototype.changed=function(){var t=this,e=this.find(-1,!0),r=this,i=this.doc.cm;e&&i&&Qi(i,(function(){var n=e.line,o=$t(e.line),s=Or(i,o);if(s&&(Fr(s),i.curOp.selectionChanged=i.curOp.forceUpdate=!0),i.curOp.updateMaxLine=!0,!He(r.doc,n)&&null!=r.height){var a=r.height;r.height=null;var l=xr(r)-a;l&&Xt(n,n.height+l)}ar(i,"markerChanged",i,t)}))},Eo.prototype.attachLine=function(t){if(!this.lines.length&&this.doc.cm){var e=this.doc.cm.curOp;e.maybeHiddenMarkers&&-1!=U(e.maybeHiddenMarkers,this)||(e.maybeUnhiddenMarkers||(e.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(t)},Eo.prototype.detachLine=function(t){if(this.lines.splice(U(this.lines,t),1),!this.lines.length&&this.doc.cm){var e=this.doc.cm.curOp;(e.maybeHiddenMarkers||(e.maybeHiddenMarkers=[])).push(this)}},yt(Eo);var Lo=function(t,e){this.markers=t,this.primary=e;for(var r=0;r<t.length;++r)t[r].parent=this};function Ao(t){return t.findMarks(te(t.first,0),t.clipPos(te(t.lastLine())),(function(t){return t.parent}))}function Do(t){for(var e=function(e){var r=t[e],i=[r.primary.doc];Mn(r.primary.doc,(function(t){return i.push(t)}));for(var n=0;n<r.markers.length;n++){var o=r.markers[n];-1==U(i,o.doc)&&(o.parent=null,r.markers.splice(n--,1))}},r=0;r<t.length;r++)e(r)}Lo.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var t=0;t<this.markers.length;++t)this.markers[t].clear();ar(this,"clear")}},Lo.prototype.find=function(t,e){return this.primary.find(t,e)},yt(Lo);var Oo=0,Ro=function(t,e,r,i,n){if(!(this instanceof Ro))return new Ro(t,e,r,i,n);null==r&&(r=0),So.call(this,[new xo([new Ke("",null)])]),this.first=r,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=r;var o=te(r,0);this.sel=En(o),this.history=new Fn(null),this.id=++Oo,this.modeOption=e,this.lineSep=i,this.direction="rtl"==n?"rtl":"ltr",this.extend=!1,"string"==typeof t&&(t=this.splitLines(t)),In(this,{from:o,to:o,text:t}),Jn(this,En(o),G)};Ro.prototype=Z(So.prototype,{constructor:Ro,iter:function(t,e,r){r?this.iterN(t-this.first,e-t,r):this.iterN(this.first,this.first+this.size,t)},insert:function(t,e){for(var r=0,i=0;i<e.length;++i)r+=e[i].height;this.insertInner(t-this.first,e,r)},remove:function(t,e){this.removeInner(t-this.first,e)},getValue:function(t){var e=Yt(this,this.first,this.first+this.size);return!1===t?e:e.join(t||this.lineSeparator())},setValue:en((function(t){var e=te(this.first,0),r=this.first+this.size-1;co(this,{from:e,to:te(r,Kt(this,r).text.length),text:this.splitLines(t),origin:"setValue",full:!0},!0),this.cm&&Ri(this.cm,0,0),Jn(this,En(e),G)})),replaceRange:function(t,e,r,i){go(this,t,e=ae(this,e),r=r?ae(this,r):e,i)},getRange:function(t,e,r){var i=qt(this,ae(this,t),ae(this,e));return!1===r?i:i.join(r||this.lineSeparator())},getLine:function(t){var e=this.getLineHandle(t);return e&&e.text},getLineHandle:function(t){if(Qt(this,t))return Kt(this,t)},getLineNumber:function(t){return $t(t)},getLineHandleVisualStart:function(t){return"number"==typeof t&&(t=Kt(this,t)),Be(t)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(t){return ae(this,t)},getCursor:function(t){var e=this.sel.primary();return null==t||"head"==t?e.head:"anchor"==t?e.anchor:"end"==t||"to"==t||!1===t?e.to():e.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:en((function(t,e,r){Zn(this,ae(this,"number"==typeof t?te(t,e||0):t),null,r)})),setSelection:en((function(t,e,r){Zn(this,ae(this,t),ae(this,e||t),r)})),extendSelection:en((function(t,e,r){Yn(this,ae(this,t),e&&ae(this,e),r)})),extendSelections:en((function(t,e){Xn(this,le(this,t),e)})),extendSelectionsBy:en((function(t,e){Xn(this,le(this,X(this.sel.ranges,t)),e)})),setSelections:en((function(t,e,r){if(t.length){for(var i=[],n=0;n<t.length;n++)i[n]=new wn(ae(this,t[n].anchor),ae(this,t[n].head));null==e&&(e=Math.min(t.length-1,this.sel.primIndex)),Jn(this,kn(this.cm,i,e),r)}})),addSelection:en((function(t,e,r){var i=this.sel.ranges.slice(0);i.push(new wn(ae(this,t),ae(this,e||t))),Jn(this,kn(this.cm,i,i.length-1),r)})),getSelection:function(t){for(var e,r=this.sel.ranges,i=0;i<r.length;i++){var n=qt(this,r[i].from(),r[i].to());e=e?e.concat(n):n}return!1===t?e:e.join(t||this.lineSeparator())},getSelections:function(t){for(var e=[],r=this.sel.ranges,i=0;i<r.length;i++){var n=qt(this,r[i].from(),r[i].to());!1!==t&&(n=n.join(t||this.lineSeparator())),e[i]=n}return e},replaceSelection:function(t,e,r){for(var i=[],n=0;n<this.sel.ranges.length;n++)i[n]=t;this.replaceSelections(i,e,r||"+input")},replaceSelections:en((function(t,e,r){for(var i=[],n=this.sel,o=0;o<n.ranges.length;o++){var s=n.ranges[o];i[o]={from:s.from(),to:s.to(),text:this.splitLines(t[o]),origin:r}}for(var a=e&&"end"!=e&&function(t,e,r){for(var i=[],n=te(t.first,0),o=n,s=0;s<e.length;s++){var a=e[s],l=Dn(a.from,n,o),c=Dn(Tn(a),n,o);if(n=a.to,o=c,"around"==r){var u=t.sel.ranges[s],h=ee(u.head,u.anchor)<0;i[s]=new wn(h?c:l,h?l:c)}else i[s]=new wn(l,l)}return new Cn(i,t.sel.primIndex)}(this,i,e),l=i.length-1;l>=0;l--)co(this,i[l]);a?Qn(this,a):this.cm&&Oi(this.cm)})),undo:en((function(){ho(this,"undo")})),redo:en((function(){ho(this,"redo")})),undoSelection:en((function(){ho(this,"undo",!0)})),redoSelection:en((function(){ho(this,"redo",!0)})),setExtending:function(t){this.extend=t},getExtending:function(){return this.extend},historySize:function(){for(var t=this.history,e=0,r=0,i=0;i<t.done.length;i++)t.done[i].ranges||++e;for(var n=0;n<t.undone.length;n++)t.undone[n].ranges||++r;return{undo:e,redo:r}},clearHistory:function(){var t=this;this.history=new Fn(this.history.maxGeneration),Mn(this,(function(e){return e.history=t.history}),!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(t){return t&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(t){return this.history.generation==(t||this.cleanGeneration)},getHistory:function(){return{done:Kn(this.history.done),undone:Kn(this.history.undone)}},setHistory:function(t){var e=this.history=new Fn(this.history.maxGeneration);e.done=Kn(t.done.slice(0),null,!0),e.undone=Kn(t.undone.slice(0),null,!0)},setGutterMarker:en((function(t,e,r){return bo(this,t,"gutter",(function(t){var i=t.gutterMarkers||(t.gutterMarkers={});return i[e]=r,!r&&et(i)&&(t.gutterMarkers=null),!0}))})),clearGutter:en((function(t){var e=this;this.iter((function(r){r.gutterMarkers&&r.gutterMarkers[t]&&bo(e,r,"gutter",(function(){return r.gutterMarkers[t]=null,et(r.gutterMarkers)&&(r.gutterMarkers=null),!0}))}))})),lineInfo:function(t){var e;if("number"==typeof t){if(!Qt(this,t))return null;if(e=t,!(t=Kt(this,t)))return null}else if(null==(e=$t(t)))return null;return{line:e,handle:t,text:t.text,gutterMarkers:t.gutterMarkers,textClass:t.textClass,bgClass:t.bgClass,wrapClass:t.wrapClass,widgets:t.widgets}},addLineClass:en((function(t,e,r){return bo(this,t,"gutter"==e?"gutter":"class",(function(t){var i="text"==e?"textClass":"background"==e?"bgClass":"gutter"==e?"gutterClass":"wrapClass";if(t[i]){if(k(r).test(t[i]))return!1;t[i]+=" "+r}else t[i]=r;return!0}))})),removeLineClass:en((function(t,e,r){return bo(this,t,"gutter"==e?"gutter":"class",(function(t){var i="text"==e?"textClass":"background"==e?"bgClass":"gutter"==e?"gutterClass":"wrapClass",n=t[i];if(!n)return!1;if(null==r)t[i]=null;else{var o=n.match(k(r));if(!o)return!1;var s=o.index+o[0].length;t[i]=n.slice(0,o.index)+(o.index&&s!=n.length?" ":"")+n.slice(s)||null}return!0}))})),addLineWidget:en((function(t,e,r){return function(t,e,r,i){var n=new Co(t,r,i),o=t.cm;return o&&n.noHScroll&&(o.display.alignWidgets=!0),bo(t,e,"widget",(function(e){var r=e.widgets||(e.widgets=[]);if(null==n.insertAt?r.push(n):r.splice(Math.min(r.length-1,Math.max(0,n.insertAt)),0,n),n.line=e,o&&!He(t,e)){var i=ze(e)<t.scrollTop;Xt(e,e.height+xr(n)),i&&Di(o,n.height),o.curOp.forceUpdate=!0}return!0})),o&&ar(o,"lineWidgetAdded",o,n,"number"==typeof e?e:$t(e)),n}(this,t,e,r)})),removeLineWidget:function(t){t.clear()},markText:function(t,e,r){return To(this,ae(this,t),ae(this,e),r,r&&r.type||"range")},setBookmark:function(t,e){var r={replacedWith:e&&(null==e.nodeType?e.widget:e),insertLeft:e&&e.insertLeft,clearWhenEmpty:!1,shared:e&&e.shared,handleMouseEvents:e&&e.handleMouseEvents};return To(this,t=ae(this,t),t,r,"bookmark")},findMarksAt:function(t){var e=[],r=Kt(this,(t=ae(this,t)).line).markedSpans;if(r)for(var i=0;i<r.length;++i){var n=r[i];(null==n.from||n.from<=t.ch)&&(null==n.to||n.to>=t.ch)&&e.push(n.marker.parent||n.marker)}return e},findMarks:function(t,e,r){t=ae(this,t),e=ae(this,e);var i=[],n=t.line;return this.iter(t.line,e.line+1,(function(o){var s=o.markedSpans;if(s)for(var a=0;a<s.length;a++){var l=s[a];null!=l.to&&n==t.line&&t.ch>=l.to||null==l.from&&n!=t.line||null!=l.from&&n==e.line&&l.from>=e.ch||r&&!r(l.marker)||i.push(l.marker.parent||l.marker)}++n})),i},getAllMarks:function(){var t=[];return this.iter((function(e){var r=e.markedSpans;if(r)for(var i=0;i<r.length;++i)null!=r[i].from&&t.push(r[i].marker)})),t},posFromIndex:function(t){var e,r=this.first,i=this.lineSeparator().length;return this.iter((function(n){var o=n.text.length+i;if(o>t)return e=t,!0;t-=o,++r})),ae(this,te(r,e))},indexFromPos:function(t){var e=(t=ae(this,t)).ch;if(t.line<this.first||t.ch<0)return 0;var r=this.lineSeparator().length;return this.iter(this.first,t.line,(function(t){e+=t.text.length+r})),e},copy:function(t){var e=new Ro(Yt(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return e.scrollTop=this.scrollTop,e.scrollLeft=this.scrollLeft,e.sel=this.sel,e.extend=!1,t&&(e.history.undoDepth=this.history.undoDepth,e.setHistory(this.getHistory())),e},linkedDoc:function(t){t||(t={});var e=this.first,r=this.first+this.size;null!=t.from&&t.from>e&&(e=t.from),null!=t.to&&t.to<r&&(r=t.to);var i=new Ro(Yt(this,e,r),t.mode||this.modeOption,e,this.lineSep,this.direction);return t.sharedHist&&(i.history=this.history),(this.linked||(this.linked=[])).push({doc:i,sharedHist:t.sharedHist}),i.linked=[{doc:this,isParent:!0,sharedHist:t.sharedHist}],function(t,e){for(var r=0;r<e.length;r++){var i=e[r],n=i.find(),o=t.clipPos(n.from),s=t.clipPos(n.to);if(ee(o,s)){var a=To(t,o,s,i.primary,i.primary.type);i.markers.push(a),a.parent=i}}}(i,Ao(this)),i},unlinkDoc:function(t){if(t instanceof Ls&&(t=t.doc),this.linked)for(var e=0;e<this.linked.length;++e)if(this.linked[e].doc==t){this.linked.splice(e,1),t.unlinkDoc(this),Do(Ao(this));break}if(t.history==this.history){var r=[t.id];Mn(t,(function(t){return r.push(t.id)}),!0),t.history=new Fn(null),t.history.done=Kn(this.history.done,r),t.history.undone=Kn(this.history.undone,r)}},iterLinkedDocs:function(t){Mn(this,t)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(t){return this.lineSep?t.split(this.lineSep):Rt(t)},lineSeparator:function(){return this.lineSep||"\n"},setDirection:en((function(t){var e;"rtl"!=t&&(t="ltr"),t!=this.direction&&(this.direction=t,this.iter((function(t){return t.order=null})),this.cm&&Qi(e=this.cm,(function(){Nn(e),ui(e)})))}))}),Ro.prototype.eachLine=Ro.prototype.iter;var _o=0;function Io(t){var e=this;if(Mo(e),!gt(e,t)&&!Sr(e.display,t)){bt(t),s&&(_o=+new Date);var r=li(e,t,!0),i=t.dataTransfer.files;if(r&&!e.isReadOnly())if(i&&i.length&&window.FileReader&&window.File)for(var n=i.length,o=Array(n),a=0,l=function(){++a==n&&Ji(e,(function(){var t={from:r=ae(e.doc,r),to:r,text:e.doc.splitLines(o.filter((function(t){return null!=t})).join(e.doc.lineSeparator())),origin:"paste"};co(e.doc,t),Qn(e.doc,En(ae(e.doc,r),ae(e.doc,Tn(t))))}))()},c=function(t,r){if(e.options.allowDropFileTypes&&-1==U(e.options.allowDropFileTypes,t.type))l();else{var i=new FileReader;i.onerror=function(){return l()},i.onload=function(){var t=i.result;/[\x00-\x08\x0e-\x1f]{2}/.test(t)||(o[r]=t),l()},i.readAsText(t)}},u=0;u<i.length;u++)c(i[u],u);else{if(e.state.draggingText&&e.doc.sel.contains(r)>-1)return e.state.draggingText(t),void setTimeout((function(){return e.display.input.focus()}),20);try{var h=t.dataTransfer.getData("Text");if(h){var d;if(e.state.draggingText&&!e.state.draggingText.copy&&(d=e.listSelections()),to(e.doc,En(r,r)),d)for(var f=0;f<d.length;++f)go(e.doc,"",d[f].anchor,d[f].head,"drag");e.replaceSelection(h,"around","paste"),e.display.input.focus()}}catch(t){}}}}function Mo(t){t.display.dragCursor&&(t.display.lineSpace.removeChild(t.display.dragCursor),t.display.dragCursor=null)}function Po(t){if(document.getElementsByClassName){for(var e=document.getElementsByClassName("CodeMirror"),r=[],i=0;i<e.length;i++){var n=e[i].CodeMirror;n&&r.push(n)}r.length&&r[0].operation((function(){for(var e=0;e<r.length;e++)t(r[e])}))}}var No=!1;function Fo(){var t;No||(ht(window,"resize",(function(){null==t&&(t=setTimeout((function(){t=null,Po(Bo)}),100))})),ht(window,"blur",(function(){return Po(ki)})),No=!0)}function Bo(t){var e=t.display;e.cachedCharWidth=e.cachedTextHeight=e.cachedPaddingH=null,e.scrollbarsClipped=!1,t.setSize()}for(var jo={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},Uo=0;Uo<10;Uo++)jo[Uo+48]=jo[Uo+96]=String(Uo);for(var Ho=65;Ho<=90;Ho++)jo[Ho]=String.fromCharCode(Ho);for(var Go=1;Go<=12;Go++)jo[Go+111]=jo[Go+63235]="F"+Go;var zo={};function Wo(t){var e,r,i,n,o=t.split(/-(?!$)/);t=o[o.length-1];for(var s=0;s<o.length-1;s++){var a=o[s];if(/^(cmd|meta|m)$/i.test(a))n=!0;else if(/^a(lt)?$/i.test(a))e=!0;else if(/^(c|ctrl|control)$/i.test(a))r=!0;else{if(!/^s(hift)?$/i.test(a))throw new Error("Unrecognized modifier name: "+a);i=!0}}return e&&(t="Alt-"+t),r&&(t="Ctrl-"+t),n&&(t="Cmd-"+t),i&&(t="Shift-"+t),t}function Vo(t){var e={};for(var r in t)if(t.hasOwnProperty(r)){var i=t[r];if(/^(name|fallthrough|(de|at)tach)$/.test(r))continue;if("..."==i){delete t[r];continue}for(var n=X(r.split(" "),Wo),o=0;o<n.length;o++){var s=void 0,a=void 0;o==n.length-1?(a=n.join(" "),s=i):(a=n.slice(0,o+1).join(" "),s="...");var l=e[a];if(l){if(l!=s)throw new Error("Inconsistent bindings for "+a)}else e[a]=s}delete t[r]}for(var c in e)t[c]=e[c];return t}function Ko(t,e,r,i){var n=(e=$o(e)).call?e.call(t,i):e[t];if(!1===n)return"nothing";if("..."===n)return"multi";if(null!=n&&r(n))return"handled";if(e.fallthrough){if("[object Array]"!=Object.prototype.toString.call(e.fallthrough))return Ko(t,e.fallthrough,r,i);for(var o=0;o<e.fallthrough.length;o++){var s=Ko(t,e.fallthrough[o],r,i);if(s)return s}}}function qo(t){var e="string"==typeof t?t:jo[t.keyCode];return"Ctrl"==e||"Alt"==e||"Shift"==e||"Mod"==e}function Yo(t,e,r){var i=t;return e.altKey&&"Alt"!=i&&(t="Alt-"+t),(C?e.metaKey:e.ctrlKey)&&"Ctrl"!=i&&(t="Ctrl-"+t),(C?e.ctrlKey:e.metaKey)&&"Mod"!=i&&(t="Cmd-"+t),!r&&e.shiftKey&&"Shift"!=i&&(t="Shift-"+t),t}function Xo(t,e){if(h&&34==t.keyCode&&t.char)return!1;var r=jo[t.keyCode];return null!=r&&!t.altGraphKey&&(3==t.keyCode&&t.code&&(r=t.code),Yo(r,t,e))}function $o(t){return"string"==typeof t?zo[t]:t}function Zo(t,e){for(var r=t.doc.sel.ranges,i=[],n=0;n<r.length;n++){for(var o=e(r[n]);i.length&&ee(o.from,Y(i).to)<=0;){var s=i.pop();if(ee(s.from,o.from)<0){o.from=s.from;break}}i.push(o)}Qi(t,(function(){for(var e=i.length-1;e>=0;e--)go(t.doc,"",i[e].from,i[e].to,"+delete");Oi(t)}))}function Qo(t,e,r){var i=nt(t.text,e+r,r);return i<0||i>t.text.length?null:i}function Jo(t,e,r){var i=Qo(t,e.ch,r);return null==i?null:new te(e.line,i,r<0?"after":"before")}function ts(t,e,r,i,n){if(t){"rtl"==e.doc.direction&&(n=-n);var o=ct(r,e.doc.direction);if(o){var s,a=n<0?Y(o):o[0],l=n<0==(1==a.level)?"after":"before";if(a.level>0||"rtl"==e.doc.direction){var c=Rr(e,r);s=n<0?r.text.length-1:0;var u=_r(e,c,s).top;s=ot((function(t){return _r(e,c,t).top==u}),n<0==(1==a.level)?a.from:a.to-1,s),"before"==l&&(s=Qo(r,s,1))}else s=n<0?a.to:a.from;return new te(i,s,l)}}return new te(i,n<0?r.text.length:0,n<0?"before":"after")}zo.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},zo.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},zo.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},zo.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},zo.default=y?zo.macDefault:zo.pcDefault;var es={selectAll:ao,singleSelection:function(t){return t.setSelection(t.getCursor("anchor"),t.getCursor("head"),G)},killLine:function(t){return Zo(t,(function(e){if(e.empty()){var r=Kt(t.doc,e.head.line).text.length;return e.head.ch==r&&e.head.line<t.lastLine()?{from:e.head,to:te(e.head.line+1,0)}:{from:e.head,to:te(e.head.line,r)}}return{from:e.from(),to:e.to()}}))},deleteLine:function(t){return Zo(t,(function(e){return{from:te(e.from().line,0),to:ae(t.doc,te(e.to().line+1,0))}}))},delLineLeft:function(t){return Zo(t,(function(t){return{from:te(t.from().line,0),to:t.from()}}))},delWrappedLineLeft:function(t){return Zo(t,(function(e){var r=t.charCoords(e.head,"div").top+5;return{from:t.coordsChar({left:0,top:r},"div"),to:e.from()}}))},delWrappedLineRight:function(t){return Zo(t,(function(e){var r=t.charCoords(e.head,"div").top+5,i=t.coordsChar({left:t.display.lineDiv.offsetWidth+100,top:r},"div");return{from:e.from(),to:i}}))},undo:function(t){return t.undo()},redo:function(t){return t.redo()},undoSelection:function(t){return t.undoSelection()},redoSelection:function(t){return t.redoSelection()},goDocStart:function(t){return t.extendSelection(te(t.firstLine(),0))},goDocEnd:function(t){return t.extendSelection(te(t.lastLine()))},goLineStart:function(t){return t.extendSelectionsBy((function(e){return rs(t,e.head.line)}),{origin:"+move",bias:1})},goLineStartSmart:function(t){return t.extendSelectionsBy((function(e){return is(t,e.head)}),{origin:"+move",bias:1})},goLineEnd:function(t){return t.extendSelectionsBy((function(e){return function(t,e){var r=Kt(t.doc,e),i=function(t){for(var e;e=Pe(t);)t=e.find(1,!0).line;return t}(r);return i!=r&&(e=$t(i)),ts(!0,t,r,e,-1)}(t,e.head.line)}),{origin:"+move",bias:-1})},goLineRight:function(t){return t.extendSelectionsBy((function(e){var r=t.cursorCoords(e.head,"div").top+5;return t.coordsChar({left:t.display.lineDiv.offsetWidth+100,top:r},"div")}),W)},goLineLeft:function(t){return t.extendSelectionsBy((function(e){var r=t.cursorCoords(e.head,"div").top+5;return t.coordsChar({left:0,top:r},"div")}),W)},goLineLeftSmart:function(t){return t.extendSelectionsBy((function(e){var r=t.cursorCoords(e.head,"div").top+5,i=t.coordsChar({left:0,top:r},"div");return i.ch<t.getLine(i.line).search(/\S/)?is(t,e.head):i}),W)},goLineUp:function(t){return t.moveV(-1,"line")},goLineDown:function(t){return t.moveV(1,"line")},goPageUp:function(t){return t.moveV(-1,"page")},goPageDown:function(t){return t.moveV(1,"page")},goCharLeft:function(t){return t.moveH(-1,"char")},goCharRight:function(t){return t.moveH(1,"char")},goColumnLeft:function(t){return t.moveH(-1,"column")},goColumnRight:function(t){return t.moveH(1,"column")},goWordLeft:function(t){return t.moveH(-1,"word")},goGroupRight:function(t){return t.moveH(1,"group")},goGroupLeft:function(t){return t.moveH(-1,"group")},goWordRight:function(t){return t.moveH(1,"word")},delCharBefore:function(t){return t.deleteH(-1,"codepoint")},delCharAfter:function(t){return t.deleteH(1,"char")},delWordBefore:function(t){return t.deleteH(-1,"word")},delWordAfter:function(t){return t.deleteH(1,"word")},delGroupBefore:function(t){return t.deleteH(-1,"group")},delGroupAfter:function(t){return t.deleteH(1,"group")},indentAuto:function(t){return t.indentSelection("smart")},indentMore:function(t){return t.indentSelection("add")},indentLess:function(t){return t.indentSelection("subtract")},insertTab:function(t){return t.replaceSelection("\t")},insertSoftTab:function(t){for(var e=[],r=t.listSelections(),i=t.options.tabSize,n=0;n<r.length;n++){var o=r[n].from(),s=B(t.getLine(o.line),o.ch,i);e.push(q(i-s%i))}t.replaceSelections(e)},defaultTab:function(t){t.somethingSelected()?t.indentSelection("add"):t.execCommand("insertTab")},transposeChars:function(t){return Qi(t,(function(){for(var e=t.listSelections(),r=[],i=0;i<e.length;i++)if(e[i].empty()){var n=e[i].head,o=Kt(t.doc,n.line).text;if(o)if(n.ch==o.length&&(n=new te(n.line,n.ch-1)),n.ch>0)n=new te(n.line,n.ch+1),t.replaceRange(o.charAt(n.ch-1)+o.charAt(n.ch-2),te(n.line,n.ch-2),n,"+transpose");else if(n.line>t.doc.first){var s=Kt(t.doc,n.line-1).text;s&&(n=new te(n.line,1),t.replaceRange(o.charAt(0)+t.doc.lineSeparator()+s.charAt(s.length-1),te(n.line-1,s.length-1),n,"+transpose"))}r.push(new wn(n,n))}t.setSelections(r)}))},newlineAndIndent:function(t){return Qi(t,(function(){for(var e=t.listSelections(),r=e.length-1;r>=0;r--)t.replaceRange(t.doc.lineSeparator(),e[r].anchor,e[r].head,"+input");e=t.listSelections();for(var i=0;i<e.length;i++)t.indentLine(e[i].from().line,null,!0);Oi(t)}))},openLine:function(t){return t.replaceSelection("\n","start")},toggleOverwrite:function(t){return t.toggleOverwrite()}};function rs(t,e){var r=Kt(t.doc,e),i=Be(r);return i!=r&&(e=$t(i)),ts(!0,t,i,e,1)}function is(t,e){var r=rs(t,e.line),i=Kt(t.doc,r.line),n=ct(i,t.doc.direction);if(!n||0==n[0].level){var o=Math.max(r.ch,i.text.search(/\S/)),s=e.line==r.line&&e.ch<=o&&e.ch;return te(r.line,s?0:o,r.sticky)}return r}function ns(t,e,r){if("string"==typeof e&&!(e=es[e]))return!1;t.display.input.ensurePolled();var i=t.display.shift,n=!1;try{t.isReadOnly()&&(t.state.suppressEdits=!0),r&&(t.display.shift=!1),n=e(t)!=H}finally{t.display.shift=i,t.state.suppressEdits=!1}return n}var os=new j;function ss(t,e,r,i){var n=t.state.keySeq;if(n){if(qo(e))return"handled";if(/\'$/.test(e)?t.state.keySeq=null:os.set(50,(function(){t.state.keySeq==n&&(t.state.keySeq=null,t.display.input.reset())})),as(t,n+" "+e,r,i))return!0}return as(t,e,r,i)}function as(t,e,r,i){var n=function(t,e,r){for(var i=0;i<t.state.keyMaps.length;i++){var n=Ko(e,t.state.keyMaps[i],r,t);if(n)return n}return t.options.extraKeys&&Ko(e,t.options.extraKeys,r,t)||Ko(e,t.options.keyMap,r,t)}(t,e,i);return"multi"==n&&(t.state.keySeq=e),"handled"==n&&ar(t,"keyHandled",t,e,r),"handled"!=n&&"multi"!=n||(bt(r),xi(t)),!!n}function ls(t,e){var r=Xo(e,!0);return!!r&&(e.shiftKey&&!t.state.keySeq?ss(t,"Shift-"+r,e,(function(e){return ns(t,e,!0)}))||ss(t,r,e,(function(e){if("string"==typeof e?/^go[A-Z]/.test(e):e.motion)return ns(t,e)})):ss(t,r,e,(function(e){return ns(t,e)})))}var cs=null;function us(t){var e=this;if(!(t.target&&t.target!=e.display.input.getField()||(e.curOp.focus=_(),gt(e,t)))){s&&a<11&&27==t.keyCode&&(t.returnValue=!1);var i=t.keyCode;e.display.shift=16==i||t.shiftKey;var n=ls(e,t);h&&(cs=n?i:null,n||88!=i||It||!(y?t.metaKey:t.ctrlKey)||e.replaceSelection("",null,"cut")),r&&!y&&!n&&46==i&&t.shiftKey&&!t.ctrlKey&&document.execCommand&&document.execCommand("cut"),18!=i||/\bCodeMirror-crosshair\b/.test(e.display.lineDiv.className)||function(t){var e=t.display.lineDiv;function r(t){18!=t.keyCode&&t.altKey||(T(e,"CodeMirror-crosshair"),ft(document,"keyup",r),ft(document,"mouseover",r))}I(e,"CodeMirror-crosshair"),ht(document,"keyup",r),ht(document,"mouseover",r)}(e)}}function hs(t){16==t.keyCode&&(this.doc.sel.shift=!1),gt(this,t)}function ds(t){var e=this;if(!(t.target&&t.target!=e.display.input.getField()||Sr(e.display,t)||gt(e,t)||t.ctrlKey&&!t.altKey||y&&t.metaKey)){var r=t.keyCode,i=t.charCode;if(h&&r==cs)return cs=null,void bt(t);if(!h||t.which&&!(t.which<10)||!ls(e,t)){var n=String.fromCharCode(null==i?r:i);"\b"!=n&&(function(t,e,r){return ss(t,"'"+r+"'",e,(function(e){return ns(t,e,!0)}))}(e,t,n)||e.display.input.onKeyPress(t))}}}var fs,ps,gs=function(t,e,r){this.time=t,this.pos=e,this.button=r};function ms(t){var e=this,r=e.display;if(!(gt(e,t)||r.activeTouch&&r.input.supportsTouch()))if(r.input.ensurePolled(),r.shift=t.shiftKey,Sr(r,t))l||(r.scroller.draggable=!1,setTimeout((function(){return r.scroller.draggable=!0}),100));else if(!bs(e,t)){var i=li(e,t),n=kt(t),o=i?function(t,e){var r=+new Date;return ps&&ps.compare(r,t,e)?(fs=ps=null,"triple"):fs&&fs.compare(r,t,e)?(ps=new gs(r,t,e),fs=null,"double"):(fs=new gs(r,t,e),ps=null,"single")}(i,n):"single";window.focus(),1==n&&e.state.selectingText&&e.state.selectingText(t),i&&function(t,e,r,i,n){var o="Click";return"double"==i?o="Double"+o:"triple"==i&&(o="Triple"+o),ss(t,Yo(o=(1==e?"Left":2==e?"Middle":"Right")+o,n),n,(function(e){if("string"==typeof e&&(e=es[e]),!e)return!1;var i=!1;try{t.isReadOnly()&&(t.state.suppressEdits=!0),i=e(t,r)!=H}finally{t.state.suppressEdits=!1}return i}))}(e,n,i,o,t)||(1==n?i?function(t,e,r,i){s?setTimeout(N(Si,t),0):t.curOp.focus=_();var n,o=function(t,e,r){var i=t.getOption("configureMouse"),n=i?i(t,e,r):{};if(null==n.unit){var o=b?r.shiftKey&&r.metaKey:r.altKey;n.unit=o?"rectangle":"single"==e?"char":"double"==e?"word":"line"}return(null==n.extend||t.doc.extend)&&(n.extend=t.doc.extend||r.shiftKey),null==n.addNew&&(n.addNew=y?r.metaKey:r.ctrlKey),null==n.moveOnDrag&&(n.moveOnDrag=!(y?r.altKey:r.ctrlKey)),n}(t,r,i),c=t.doc.sel;t.options.dragDrop&&Lt&&!t.isReadOnly()&&"single"==r&&(n=c.contains(e))>-1&&(ee((n=c.ranges[n]).from(),e)<0||e.xRel>0)&&(ee(n.to(),e)>0||e.xRel<0)?function(t,e,r,i){var n=t.display,o=!1,c=Ji(t,(function(e){l&&(n.scroller.draggable=!1),t.state.draggingText=!1,ft(n.wrapper.ownerDocument,"mouseup",c),ft(n.wrapper.ownerDocument,"mousemove",u),ft(n.scroller,"dragstart",h),ft(n.scroller,"drop",c),o||(bt(e),i.addNew||Yn(t.doc,r,null,null,i.extend),l&&!d||s&&9==a?setTimeout((function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()}),20):n.input.focus())})),u=function(t){o=o||Math.abs(e.clientX-t.clientX)+Math.abs(e.clientY-t.clientY)>=10},h=function(){return o=!0};l&&(n.scroller.draggable=!0),t.state.draggingText=c,c.copy=!i.moveOnDrag,n.scroller.dragDrop&&n.scroller.dragDrop(),ht(n.wrapper.ownerDocument,"mouseup",c),ht(n.wrapper.ownerDocument,"mousemove",u),ht(n.scroller,"dragstart",h),ht(n.scroller,"drop",c),Ci(t),setTimeout((function(){return n.input.focus()}),20)}(t,i,e,o):function(t,e,r,i){var n=t.display,o=t.doc;bt(e);var s,a,l=o.sel,c=l.ranges;if(i.addNew&&!i.extend?(a=o.sel.contains(r),s=a>-1?c[a]:new wn(r,r)):(s=o.sel.primary(),a=o.sel.primIndex),"rectangle"==i.unit)i.addNew||(s=new wn(r,r)),r=li(t,e,!0,!0),a=-1;else{var u=vs(t,r,i.unit);s=i.extend?qn(s,u.anchor,u.head,i.extend):u}i.addNew?-1==a?(a=c.length,Jn(o,kn(t,c.concat([s]),a),{scroll:!1,origin:"*mouse"})):c.length>1&&c[a].empty()&&"char"==i.unit&&!i.extend?(Jn(o,kn(t,c.slice(0,a).concat(c.slice(a+1)),0),{scroll:!1,origin:"*mouse"}),l=o.sel):$n(o,a,s,z):(a=0,Jn(o,new Cn([s],0),z),l=o.sel);var h=r;function d(e){if(0!=ee(h,e))if(h=e,"rectangle"==i.unit){for(var n=[],c=t.options.tabSize,u=B(Kt(o,r.line).text,r.ch,c),d=B(Kt(o,e.line).text,e.ch,c),f=Math.min(u,d),p=Math.max(u,d),g=Math.min(r.line,e.line),m=Math.min(t.lastLine(),Math.max(r.line,e.line));g<=m;g++){var v=Kt(o,g).text,y=V(v,f,c);f==p?n.push(new wn(te(g,y),te(g,y))):v.length>y&&n.push(new wn(te(g,y),te(g,V(v,p,c))))}n.length||n.push(new wn(r,r)),Jn(o,kn(t,l.ranges.slice(0,a).concat(n),a),{origin:"*mouse",scroll:!1}),t.scrollIntoView(e)}else{var b,x=s,S=vs(t,e,i.unit),C=x.anchor;ee(S.anchor,C)>0?(b=S.head,C=oe(x.from(),S.anchor)):(b=S.anchor,C=ne(x.to(),S.head));var w=l.ranges.slice(0);w[a]=function(t,e){var r=e.anchor,i=e.head,n=Kt(t.doc,r.line);if(0==ee(r,i)&&r.sticky==i.sticky)return e;var o=ct(n);if(!o)return e;var s=at(o,r.ch,r.sticky),a=o[s];if(a.from!=r.ch&&a.to!=r.ch)return e;var l,c=s+(a.from==r.ch==(1!=a.level)?0:1);if(0==c||c==o.length)return e;if(i.line!=r.line)l=(i.line-r.line)*("ltr"==t.doc.direction?1:-1)>0;else{var u=at(o,i.ch,i.sticky),h=u-s||(i.ch-r.ch)*(1==a.level?-1:1);l=u==c-1||u==c?h<0:h>0}var d=o[c+(l?-1:0)],f=l==(1==d.level),p=f?d.from:d.to,g=f?"after":"before";return r.ch==p&&r.sticky==g?e:new wn(new te(r.line,p,g),i)}(t,new wn(ae(o,C),b)),Jn(o,kn(t,w,a),z)}}var f=n.wrapper.getBoundingClientRect(),p=0;function g(e){t.state.selectingText=!1,p=1/0,e&&(bt(e),n.input.focus()),ft(n.wrapper.ownerDocument,"mousemove",m),ft(n.wrapper.ownerDocument,"mouseup",v),o.history.lastSelOrigin=null}var m=Ji(t,(function(e){0!==e.buttons&&kt(e)?function e(r){var s=++p,a=li(t,r,!0,"rectangle"==i.unit);if(a)if(0!=ee(a,h)){t.curOp.focus=_(),d(a);var l=Li(n,o);(a.line>=l.to||a.line<l.from)&&setTimeout(Ji(t,(function(){p==s&&e(r)})),150)}else{var c=r.clientY<f.top?-20:r.clientY>f.bottom?20:0;c&&setTimeout(Ji(t,(function(){p==s&&(n.scroller.scrollTop+=c,e(r))})),50)}}(e):g(e)})),v=Ji(t,g);t.state.selectingText=v,ht(n.wrapper.ownerDocument,"mousemove",m),ht(n.wrapper.ownerDocument,"mouseup",v)}(t,i,e,o)}(e,i,o,t):wt(t)==r.scroller&&bt(t):2==n?(i&&Yn(e.doc,i),setTimeout((function(){return r.input.focus()}),20)):3==n&&(w?e.display.input.onContextMenu(t):Ci(e)))}}function vs(t,e,r){if("char"==r)return new wn(e,e);if("word"==r)return t.findWordAt(e);if("line"==r)return new wn(te(e.line,0),ae(t.doc,te(e.line+1,0)));var i=r(t,e);return new wn(i.from,i.to)}function ys(t,e,r,i){var n,o;if(e.touches)n=e.touches[0].clientX,o=e.touches[0].clientY;else try{n=e.clientX,o=e.clientY}catch(t){return!1}if(n>=Math.floor(t.display.gutters.getBoundingClientRect().right))return!1;i&&bt(e);var s=t.display,a=s.lineDiv.getBoundingClientRect();if(o>a.bottom||!vt(t,r))return St(e);o-=a.top-s.viewOffset;for(var l=0;l<t.display.gutterSpecs.length;++l){var c=s.gutters.childNodes[l];if(c&&c.getBoundingClientRect().right>=n)return pt(t,r,t,Zt(t.doc,o),t.display.gutterSpecs[l].className,e),St(e)}}function bs(t,e){return ys(t,e,"gutterClick",!0)}function xs(t,e){Sr(t.display,e)||function(t,e){return!!vt(t,"gutterContextMenu")&&ys(t,e,"gutterContextMenu",!1)}(t,e)||gt(t,e,"contextmenu")||w||t.display.input.onContextMenu(e)}function Ss(t){t.display.wrapper.className=t.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+t.options.theme.replace(/(^|\s)\s*/g," cm-s-"),jr(t)}gs.prototype.compare=function(t,e,r){return this.time+400>t&&0==ee(e,this.pos)&&r==this.button};var Cs={toString:function(){return"CodeMirror.Init"}},ws={},ks={};function Es(t,e,r){if(!e!=!(r&&r!=Cs)){var i=t.display.dragFunctions,n=e?ht:ft;n(t.display.scroller,"dragstart",i.start),n(t.display.scroller,"dragenter",i.enter),n(t.display.scroller,"dragover",i.over),n(t.display.scroller,"dragleave",i.leave),n(t.display.scroller,"drop",i.drop)}}function Ts(t){t.options.lineWrapping?(I(t.display.wrapper,"CodeMirror-wrap"),t.display.sizer.style.minWidth="",t.display.sizerWidth=null):(T(t.display.wrapper,"CodeMirror-wrap"),Ve(t)),ai(t),ui(t),jr(t),setTimeout((function(){return Ui(t)}),100)}function Ls(t,e){var r=this;if(!(this instanceof Ls))return new Ls(t,e);this.options=e=e?F(e):{},F(ws,e,!1);var i=e.value;"string"==typeof i?i=new Ro(i,e.mode,null,e.lineSeparator,e.direction):e.mode&&(i.modeOption=e.mode),this.doc=i;var n=new Ls.inputStyles[e.inputStyle](this),o=this.display=new mn(t,i,n,e);for(var c in o.wrapper.CodeMirror=this,Ss(this),e.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),zi(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 j,keySeq:null,specialChars:null},e.autofocus&&!v&&o.input.focus(),s&&a<11&&setTimeout((function(){return r.display.input.reset(!0)}),20),function(t){var e=t.display;ht(e.scroller,"mousedown",Ji(t,ms)),ht(e.scroller,"dblclick",s&&a<11?Ji(t,(function(e){if(!gt(t,e)){var r=li(t,e);if(r&&!bs(t,e)&&!Sr(t.display,e)){bt(e);var i=t.findWordAt(r);Yn(t.doc,i.anchor,i.head)}}})):function(e){return gt(t,e)||bt(e)}),ht(e.scroller,"contextmenu",(function(e){return xs(t,e)})),ht(e.input.getField(),"contextmenu",(function(r){e.scroller.contains(r.target)||xs(t,r)}));var r,i={end:0};function n(){e.activeTouch&&(r=setTimeout((function(){return e.activeTouch=null}),1e3),(i=e.activeTouch).end=+new Date)}function o(t,e){if(null==e.left)return!0;var r=e.left-t.left,i=e.top-t.top;return r*r+i*i>400}ht(e.scroller,"touchstart",(function(n){if(!gt(t,n)&&!function(t){if(1!=t.touches.length)return!1;var e=t.touches[0];return e.radiusX<=1&&e.radiusY<=1}(n)&&!bs(t,n)){e.input.ensurePolled(),clearTimeout(r);var o=+new Date;e.activeTouch={start:o,moved:!1,prev:o-i.end<=300?i:null},1==n.touches.length&&(e.activeTouch.left=n.touches[0].pageX,e.activeTouch.top=n.touches[0].pageY)}})),ht(e.scroller,"touchmove",(function(){e.activeTouch&&(e.activeTouch.moved=!0)})),ht(e.scroller,"touchend",(function(r){var i=e.activeTouch;if(i&&!Sr(e,r)&&null!=i.left&&!i.moved&&new Date-i.start<300){var s,a=t.coordsChar(e.activeTouch,"page");s=!i.prev||o(i,i.prev)?new wn(a,a):!i.prev.prev||o(i,i.prev.prev)?t.findWordAt(a):new wn(te(a.line,0),ae(t.doc,te(a.line+1,0))),t.setSelection(s.anchor,s.head),t.focus(),bt(r)}n()})),ht(e.scroller,"touchcancel",n),ht(e.scroller,"scroll",(function(){e.scroller.clientHeight&&(Mi(t,e.scroller.scrollTop),Ni(t,e.scroller.scrollLeft,!0),pt(t,"scroll",t))})),ht(e.scroller,"mousewheel",(function(e){return Sn(t,e)})),ht(e.scroller,"DOMMouseScroll",(function(e){return Sn(t,e)})),ht(e.wrapper,"scroll",(function(){return e.wrapper.scrollTop=e.wrapper.scrollLeft=0})),e.dragFunctions={enter:function(e){gt(t,e)||Ct(e)},over:function(e){gt(t,e)||(function(t,e){var r=li(t,e);if(r){var i=document.createDocumentFragment();vi(t,r,i),t.display.dragCursor||(t.display.dragCursor=D("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),t.display.lineSpace.insertBefore(t.display.dragCursor,t.display.cursorDiv)),A(t.display.dragCursor,i)}}(t,e),Ct(e))},start:function(e){return function(t,e){if(s&&(!t.state.draggingText||+new Date-_o<100))Ct(e);else if(!gt(t,e)&&!Sr(t.display,e)&&(e.dataTransfer.setData("Text",t.getSelection()),e.dataTransfer.effectAllowed="copyMove",e.dataTransfer.setDragImage&&!d)){var r=D("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",h&&(r.width=r.height=1,t.display.wrapper.appendChild(r),r._top=r.offsetTop),e.dataTransfer.setDragImage(r,0,0),h&&r.parentNode.removeChild(r)}}(t,e)},drop:Ji(t,Io),leave:function(e){gt(t,e)||Mo(t)}};var l=e.input.getField();ht(l,"keyup",(function(e){return hs.call(t,e)})),ht(l,"keydown",Ji(t,us)),ht(l,"keypress",Ji(t,ds)),ht(l,"focus",(function(e){return wi(t,e)})),ht(l,"blur",(function(e){return ki(t,e)}))}(this),Fo(),Vi(this),this.curOp.forceUpdate=!0,Pn(this,i),e.autofocus&&!v||this.hasFocus()?setTimeout((function(){r.hasFocus()&&!r.state.focused&&wi(r)}),20):ki(this),ks)ks.hasOwnProperty(c)&&ks[c](this,e[c],Cs);dn(this),e.finishInit&&e.finishInit(this);for(var u=0;u<As.length;++u)As[u](this);Ki(this),l&&e.lineWrapping&&"optimizelegibility"==getComputedStyle(o.lineDiv).textRendering&&(o.lineDiv.style.textRendering="auto")}Ls.defaults=ws,Ls.optionHandlers=ks;var As=[];function Ds(t,e,r,i){var n,o=t.doc;null==r&&(r="add"),"smart"==r&&(o.mode.indent?n=fe(t,e).state:r="prev");var s=t.options.tabSize,a=Kt(o,e),l=B(a.text,null,s);a.stateAfter&&(a.stateAfter=null);var c,u=a.text.match(/^\s*/)[0];if(i||/\S/.test(a.text)){if("smart"==r&&((c=o.mode.indent(n,a.text.slice(u.length),a.text))==H||c>150)){if(!i)return;r="prev"}}else c=0,r="not";"prev"==r?c=e>o.first?B(Kt(o,e-1).text,null,s):0:"add"==r?c=l+t.options.indentUnit:"subtract"==r?c=l-t.options.indentUnit:"number"==typeof r&&(c=l+r),c=Math.max(0,c);var h="",d=0;if(t.options.indentWithTabs)for(var f=Math.floor(c/s);f;--f)d+=s,h+="\t";if(d<c&&(h+=q(c-d)),h!=u)return go(o,h,te(e,0),te(e,u.length),"+input"),a.stateAfter=null,!0;for(var p=0;p<o.sel.ranges.length;p++){var g=o.sel.ranges[p];if(g.head.line==e&&g.head.ch<u.length){var m=te(e,u.length);$n(o,p,new wn(m,m));break}}}Ls.defineInitHook=function(t){return As.push(t)};var Os=null;function Rs(t){Os=t}function _s(t,e,r,i,n){var o=t.doc;t.display.shift=!1,i||(i=o.sel);var s=+new Date-200,a="paste"==n||t.state.pasteIncoming>s,l=Rt(e),c=null;if(a&&i.ranges.length>1)if(Os&&Os.text.join("\n")==e){if(i.ranges.length%Os.text.length==0){c=[];for(var u=0;u<Os.text.length;u++)c.push(o.splitLines(Os.text[u]))}}else l.length==i.ranges.length&&t.options.pasteLinesPerSelection&&(c=X(l,(function(t){return[t]})));for(var h=t.curOp.updateInput,d=i.ranges.length-1;d>=0;d--){var f=i.ranges[d],p=f.from(),g=f.to();f.empty()&&(r&&r>0?p=te(p.line,p.ch-r):t.state.overwrite&&!a?g=te(g.line,Math.min(Kt(o,g.line).text.length,g.ch+Y(l).length)):a&&Os&&Os.lineWise&&Os.text.join("\n")==l.join("\n")&&(p=g=te(p.line,0)));var m={from:p,to:g,text:c?c[d%c.length]:l,origin:n||(a?"paste":t.state.cutIncoming>s?"cut":"+input")};co(t.doc,m),ar(t,"inputRead",t,m)}e&&!a&&Ms(t,e),Oi(t),t.curOp.updateInput<2&&(t.curOp.updateInput=h),t.curOp.typing=!0,t.state.pasteIncoming=t.state.cutIncoming=-1}function Is(t,e){var r=t.clipboardData&&t.clipboardData.getData("Text");if(r)return t.preventDefault(),e.isReadOnly()||e.options.disableInput||Qi(e,(function(){return _s(e,r,0,null,"paste")})),!0}function Ms(t,e){if(t.options.electricChars&&t.options.smartIndent)for(var r=t.doc.sel,i=r.ranges.length-1;i>=0;i--){var n=r.ranges[i];if(!(n.head.ch>100||i&&r.ranges[i-1].head.line==n.head.line)){var o=t.getModeAt(n.head),s=!1;if(o.electricChars){for(var a=0;a<o.electricChars.length;a++)if(e.indexOf(o.electricChars.charAt(a))>-1){s=Ds(t,n.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Kt(t.doc,n.head.line).text.slice(0,n.head.ch))&&(s=Ds(t,n.head.line,"smart"));s&&ar(t,"electricInput",t,n.head.line)}}}function Ps(t){for(var e=[],r=[],i=0;i<t.doc.sel.ranges.length;i++){var n=t.doc.sel.ranges[i].head.line,o={anchor:te(n,0),head:te(n+1,0)};r.push(o),e.push(t.getRange(o.anchor,o.head))}return{text:e,ranges:r}}function Ns(t,e,r,i){t.setAttribute("autocorrect",r?"":"off"),t.setAttribute("autocapitalize",i?"":"off"),t.setAttribute("spellcheck",!!e)}function Fs(){var t=D("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),e=D("div",[t],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return l?t.style.width="1000px":t.setAttribute("wrap","off"),g&&(t.style.border="1px solid black"),Ns(t),e}function Bs(t,e,r,i,n){var o=e,s=r,a=Kt(t,e.line),l=n&&"rtl"==t.direction?-r:r;function c(o){var s,c;if("codepoint"==i){var u=a.text.charCodeAt(e.ch+(i>0?0:-1));s=isNaN(u)?null:new te(e.line,Math.max(0,Math.min(a.text.length,e.ch+r*(u>=55296&&u<56320?2:1))),-r)}else s=n?function(t,e,r,i){var n=ct(e,t.doc.direction);if(!n)return Jo(e,r,i);r.ch>=e.text.length?(r.ch=e.text.length,r.sticky="before"):r.ch<=0&&(r.ch=0,r.sticky="after");var o=at(n,r.ch,r.sticky),s=n[o];if("ltr"==t.doc.direction&&s.level%2==0&&(i>0?s.to>r.ch:s.from<r.ch))return Jo(e,r,i);var a,l=function(t,r){return Qo(e,t instanceof te?t.ch:t,r)},c=function(r){return t.options.lineWrapping?(a=a||Rr(t,e),Zr(t,e,a,r)):{begin:0,end:e.text.length}},u=c("before"==r.sticky?l(r,-1):r.ch);if("rtl"==t.doc.direction||1==s.level){var h=1==s.level==i<0,d=l(r,h?1:-1);if(null!=d&&(h?d<=s.to&&d<=u.end:d>=s.from&&d>=u.begin)){var f=h?"before":"after";return new te(r.line,d,f)}}var p=function(t,e,i){for(var o=function(t,e){return e?new te(r.line,l(t,1),"before"):new te(r.line,t,"after")};t>=0&&t<n.length;t+=e){var s=n[t],a=e>0==(1!=s.level),c=a?i.begin:l(i.end,-1);if(s.from<=c&&c<s.to)return o(c,a);if(c=a?s.from:l(s.to,-1),i.begin<=c&&c<i.end)return o(c,a)}},g=p(o+i,i,u);if(g)return g;var m=i>0?u.end:l(u.begin,-1);return null==m||i>0&&m==e.text.length||!(g=p(i>0?0:n.length-1,i,c(m)))?null:g}(t.cm,a,e,r):Jo(a,e,r);if(null==s){if(o||(c=e.line+l)<t.first||c>=t.first+t.size||(e=new te(c,e.ch,e.sticky),!(a=Kt(t,c))))return!1;e=ts(n,t.cm,a,e.line,l)}else e=s;return!0}if("char"==i||"codepoint"==i)c();else if("column"==i)c(!0);else if("word"==i||"group"==i)for(var u=null,h="group"==i,d=t.cm&&t.cm.getHelper(e,"wordChars"),f=!0;!(r<0)||c(!f);f=!1){var p=a.text.charAt(e.ch)||"\n",g=tt(p,d)?"w":h&&"\n"==p?"n":!h||/\s/.test(p)?null:"p";if(!h||f||g||(g="s"),u&&u!=g){r<0&&(r=1,c(),e.sticky="after");break}if(g&&(u=g),r>0&&!c(!f))break}var m=oo(t,e,o,s,!0);return re(o,m)&&(m.hitSide=!0),m}function js(t,e,r,i){var n,o,s=t.doc,a=e.left;if("page"==i){var l=Math.min(t.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),c=Math.max(l-.5*ri(t.display),3);n=(r>0?e.bottom:e.top)+r*c}else"line"==i&&(n=r>0?e.bottom+3:e.top-3);for(;(o=Xr(t,a,n)).outside;){if(r<0?n<=0:n>=s.height){o.hitSide=!0;break}n+=5*r}return o}var Us=function(t){this.cm=t,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new j,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};function Hs(t,e){var r=Or(t,e.line);if(!r||r.hidden)return null;var i=Kt(t.doc,e.line),n=Ar(r,i,e.line),o=ct(i,t.doc.direction),s="left";o&&(s=at(o,e.ch)%2?"right":"left");var a=Pr(n.map,e.ch,s);return a.offset="right"==a.collapse?a.end:a.start,a}function Gs(t,e){return e&&(t.bad=!0),t}function zs(t,e,r){var i;if(e==t.display.lineDiv){if(!(i=t.display.lineDiv.childNodes[r]))return Gs(t.clipPos(te(t.display.viewTo-1)),!0);e=null,r=0}else for(i=e;;i=i.parentNode){if(!i||i==t.display.lineDiv)return null;if(i.parentNode&&i.parentNode==t.display.lineDiv)break}for(var n=0;n<t.display.view.length;n++){var o=t.display.view[n];if(o.node==i)return Ws(o,e,r)}}function Ws(t,e,r){var i=t.text.firstChild,n=!1;if(!e||!R(i,e))return Gs(te($t(t.line),0),!0);if(e==i&&(n=!0,e=i.childNodes[r],r=0,!e)){var o=t.rest?Y(t.rest):t.line;return Gs(te($t(o),o.text.length),n)}var s=3==e.nodeType?e:null,a=e;for(s||1!=e.childNodes.length||3!=e.firstChild.nodeType||(s=e.firstChild,r&&(r=s.nodeValue.length));a.parentNode!=i;)a=a.parentNode;var l=t.measure,c=l.maps;function u(e,r,i){for(var n=-1;n<(c?c.length:0);n++)for(var o=n<0?l.map:c[n],s=0;s<o.length;s+=3){var a=o[s+2];if(a==e||a==r){var u=$t(n<0?t.line:t.rest[n]),h=o[s]+i;return(i<0||a!=e)&&(h=o[s+(i?1:0)]),te(u,h)}}}var h=u(s,a,r);if(h)return Gs(h,n);for(var d=a.nextSibling,f=s?s.nodeValue.length-r:0;d;d=d.nextSibling){if(h=u(d,d.firstChild,0))return Gs(te(h.line,h.ch-f),n);f+=d.textContent.length}for(var p=a.previousSibling,g=r;p;p=p.previousSibling){if(h=u(p,p.firstChild,-1))return Gs(te(h.line,h.ch+g),n);g+=p.textContent.length}}Us.prototype.init=function(t){var e=this,r=this,i=r.cm,n=r.div=t.lineDiv;function o(t){for(var e=t.target;e;e=e.parentNode){if(e==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(e.className))break}return!1}function s(t){if(o(t)&&!gt(i,t)){if(i.somethingSelected())Rs({lineWise:!1,text:i.getSelections()}),"cut"==t.type&&i.replaceSelection("",null,"cut");else{if(!i.options.lineWiseCopyCut)return;var e=Ps(i);Rs({lineWise:!0,text:e.text}),"cut"==t.type&&i.operation((function(){i.setSelections(e.ranges,0,G),i.replaceSelection("",null,"cut")}))}if(t.clipboardData){t.clipboardData.clearData();var s=Os.text.join("\n");if(t.clipboardData.setData("Text",s),t.clipboardData.getData("Text")==s)return void t.preventDefault()}var a=Fs(),l=a.firstChild;i.display.lineSpace.insertBefore(a,i.display.lineSpace.firstChild),l.value=Os.text.join("\n");var c=document.activeElement;P(l),setTimeout((function(){i.display.lineSpace.removeChild(a),c.focus(),c==n&&r.showPrimarySelection()}),50)}}Ns(n,i.options.spellcheck,i.options.autocorrect,i.options.autocapitalize),ht(n,"paste",(function(t){!o(t)||gt(i,t)||Is(t,i)||a<=11&&setTimeout(Ji(i,(function(){return e.updateFromDOM()})),20)})),ht(n,"compositionstart",(function(t){e.composing={data:t.data,done:!1}})),ht(n,"compositionupdate",(function(t){e.composing||(e.composing={data:t.data,done:!1})})),ht(n,"compositionend",(function(t){e.composing&&(t.data!=e.composing.data&&e.readFromDOMSoon(),e.composing.done=!0)})),ht(n,"touchstart",(function(){return r.forceCompositionEnd()})),ht(n,"input",(function(){e.composing||e.readFromDOMSoon()})),ht(n,"copy",s),ht(n,"cut",s)},Us.prototype.screenReaderLabelChanged=function(t){t?this.div.setAttribute("aria-label",t):this.div.removeAttribute("aria-label")},Us.prototype.prepareSelection=function(){var t=mi(this.cm,!1);return t.focus=document.activeElement==this.div,t},Us.prototype.showSelection=function(t,e){t&&this.cm.display.view.length&&((t.focus||e)&&this.showPrimarySelection(),this.showMultipleSelections(t))},Us.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Us.prototype.showPrimarySelection=function(){var t=this.getSelection(),e=this.cm,i=e.doc.sel.primary(),n=i.from(),o=i.to();if(e.display.viewTo==e.display.viewFrom||n.line>=e.display.viewTo||o.line<e.display.viewFrom)t.removeAllRanges();else{var s=zs(e,t.anchorNode,t.anchorOffset),a=zs(e,t.focusNode,t.focusOffset);if(!s||s.bad||!a||a.bad||0!=ee(oe(s,a),n)||0!=ee(ne(s,a),o)){var l=e.display.view,c=n.line>=e.display.viewFrom&&Hs(e,n)||{node:l[0].measure.map[2],offset:0},u=o.line<e.display.viewTo&&Hs(e,o);if(!u){var h=l[l.length-1].measure,d=h.maps?h.maps[h.maps.length-1]:h.map;u={node:d[d.length-1],offset:d[d.length-2]-d[d.length-3]}}if(c&&u){var f,p=t.rangeCount&&t.getRangeAt(0);try{f=E(c.node,c.offset,u.offset,u.node)}catch(t){}f&&(!r&&e.state.focused?(t.collapse(c.node,c.offset),f.collapsed||(t.removeAllRanges(),t.addRange(f))):(t.removeAllRanges(),t.addRange(f)),p&&null==t.anchorNode?t.addRange(p):r&&this.startGracePeriod()),this.rememberSelection()}else t.removeAllRanges()}}},Us.prototype.startGracePeriod=function(){var t=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout((function(){t.gracePeriod=!1,t.selectionChanged()&&t.cm.operation((function(){return t.cm.curOp.selectionChanged=!0}))}),20)},Us.prototype.showMultipleSelections=function(t){A(this.cm.display.cursorDiv,t.cursors),A(this.cm.display.selectionDiv,t.selection)},Us.prototype.rememberSelection=function(){var t=this.getSelection();this.lastAnchorNode=t.anchorNode,this.lastAnchorOffset=t.anchorOffset,this.lastFocusNode=t.focusNode,this.lastFocusOffset=t.focusOffset},Us.prototype.selectionInEditor=function(){var t=this.getSelection();if(!t.rangeCount)return!1;var e=t.getRangeAt(0).commonAncestorContainer;return R(this.div,e)},Us.prototype.focus=function(){"nocursor"!=this.cm.options.readOnly&&(this.selectionInEditor()&&document.activeElement==this.div||this.showSelection(this.prepareSelection(),!0),this.div.focus())},Us.prototype.blur=function(){this.div.blur()},Us.prototype.getField=function(){return this.div},Us.prototype.supportsTouch=function(){return!0},Us.prototype.receivedFocus=function(){var t=this;this.selectionInEditor()?this.pollSelection():Qi(this.cm,(function(){return t.cm.curOp.selectionChanged=!0})),this.polling.set(this.cm.options.pollInterval,(function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}))},Us.prototype.selectionChanged=function(){var t=this.getSelection();return t.anchorNode!=this.lastAnchorNode||t.anchorOffset!=this.lastAnchorOffset||t.focusNode!=this.lastFocusNode||t.focusOffset!=this.lastFocusOffset},Us.prototype.pollSelection=function(){if(null==this.readDOMTimeout&&!this.gracePeriod&&this.selectionChanged()){var t=this.getSelection(),e=this.cm;if(m&&u&&this.cm.display.gutterSpecs.length&&function(t){for(var e=t;e;e=e.parentNode)if(/CodeMirror-gutter-wrapper/.test(e.className))return!0;return!1}(t.anchorNode))return this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),void this.focus();if(!this.composing){this.rememberSelection();var r=zs(e,t.anchorNode,t.anchorOffset),i=zs(e,t.focusNode,t.focusOffset);r&&i&&Qi(e,(function(){Jn(e.doc,En(r,i),G),(r.bad||i.bad)&&(e.curOp.selectionChanged=!0)}))}}},Us.prototype.pollContent=function(){null!=this.readDOMTimeout&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var t,e,r,i=this.cm,n=i.display,o=i.doc.sel.primary(),s=o.from(),a=o.to();if(0==s.ch&&s.line>i.firstLine()&&(s=te(s.line-1,Kt(i.doc,s.line-1).length)),a.ch==Kt(i.doc,a.line).text.length&&a.line<i.lastLine()&&(a=te(a.line+1,0)),s.line<n.viewFrom||a.line>n.viewTo-1)return!1;s.line==n.viewFrom||0==(t=ci(i,s.line))?(e=$t(n.view[0].line),r=n.view[0].node):(e=$t(n.view[t].line),r=n.view[t-1].node.nextSibling);var l,c,u=ci(i,a.line);if(u==n.view.length-1?(l=n.viewTo-1,c=n.lineDiv.lastChild):(l=$t(n.view[u+1].line)-1,c=n.view[u+1].node.previousSibling),!r)return!1;for(var h=i.doc.splitLines(function(t,e,r,i,n){var o="",s=!1,a=t.doc.lineSeparator(),l=!1;function c(){s&&(o+=a,l&&(o+=a),s=l=!1)}function u(t){t&&(c(),o+=t)}function h(e){if(1==e.nodeType){var r=e.getAttribute("cm-text");if(r)return void u(r);var o,d=e.getAttribute("cm-marker");if(d){var f=t.findMarks(te(i,0),te(n+1,0),(m=+d,function(t){return t.id==m}));return void(f.length&&(o=f[0].find(0))&&u(qt(t.doc,o.from,o.to).join(a)))}if("false"==e.getAttribute("contenteditable"))return;var p=/^(pre|div|p|li|table|br)$/i.test(e.nodeName);if(!/^br$/i.test(e.nodeName)&&0==e.textContent.length)return;p&&c();for(var g=0;g<e.childNodes.length;g++)h(e.childNodes[g]);/^(pre|p)$/i.test(e.nodeName)&&(l=!0),p&&(s=!0)}else 3==e.nodeType&&u(e.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "));var m}for(;h(e),e!=r;)e=e.nextSibling,l=!1;return o}(i,r,c,e,l)),d=qt(i.doc,te(e,0),te(l,Kt(i.doc,l).text.length));h.length>1&&d.length>1;)if(Y(h)==Y(d))h.pop(),d.pop(),l--;else{if(h[0]!=d[0])break;h.shift(),d.shift(),e++}for(var f=0,p=0,g=h[0],m=d[0],v=Math.min(g.length,m.length);f<v&&g.charCodeAt(f)==m.charCodeAt(f);)++f;for(var y=Y(h),b=Y(d),x=Math.min(y.length-(1==h.length?f:0),b.length-(1==d.length?f:0));p<x&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)++p;if(1==h.length&&1==d.length&&e==s.line)for(;f&&f>s.ch&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)f--,p++;h[h.length-1]=y.slice(0,y.length-p).replace(/^\u200b+/,""),h[0]=h[0].slice(f).replace(/\u200b+$/,"");var S=te(e,f),C=te(l,d.length?Y(d).length-p:0);return h.length>1||h[0]||ee(S,C)?(go(i.doc,h,S,C,"+input"),!0):void 0},Us.prototype.ensurePolled=function(){this.forceCompositionEnd()},Us.prototype.reset=function(){this.forceCompositionEnd()},Us.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},Us.prototype.readFromDOMSoon=function(){var t=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout((function(){if(t.readDOMTimeout=null,t.composing){if(!t.composing.done)return;t.composing=null}t.updateFromDOM()}),80))},Us.prototype.updateFromDOM=function(){var t=this;!this.cm.isReadOnly()&&this.pollContent()||Qi(this.cm,(function(){return ui(t.cm)}))},Us.prototype.setUneditable=function(t){t.contentEditable="false"},Us.prototype.onKeyPress=function(t){0==t.charCode||this.composing||(t.preventDefault(),this.cm.isReadOnly()||Ji(this.cm,_s)(this.cm,String.fromCharCode(null==t.charCode?t.keyCode:t.charCode),0))},Us.prototype.readOnlyChanged=function(t){this.div.contentEditable=String("nocursor"!=t)},Us.prototype.onContextMenu=function(){},Us.prototype.resetPosition=function(){},Us.prototype.needsContentAttribute=!0;var Vs=function(t){this.cm=t,this.prevInput="",this.pollingFast=!1,this.polling=new j,this.hasSelection=!1,this.composing=null};Vs.prototype.init=function(t){var e=this,r=this,i=this.cm;this.createField(t);var n=this.textarea;function o(t){if(!gt(i,t)){if(i.somethingSelected())Rs({lineWise:!1,text:i.getSelections()});else{if(!i.options.lineWiseCopyCut)return;var e=Ps(i);Rs({lineWise:!0,text:e.text}),"cut"==t.type?i.setSelections(e.ranges,null,G):(r.prevInput="",n.value=e.text.join("\n"),P(n))}"cut"==t.type&&(i.state.cutIncoming=+new Date)}}t.wrapper.insertBefore(this.wrapper,t.wrapper.firstChild),g&&(n.style.width="0px"),ht(n,"input",(function(){s&&a>=9&&e.hasSelection&&(e.hasSelection=null),r.poll()})),ht(n,"paste",(function(t){gt(i,t)||Is(t,i)||(i.state.pasteIncoming=+new Date,r.fastPoll())})),ht(n,"cut",o),ht(n,"copy",o),ht(t.scroller,"paste",(function(e){if(!Sr(t,e)&&!gt(i,e)){if(!n.dispatchEvent)return i.state.pasteIncoming=+new Date,void r.focus();var o=new Event("paste");o.clipboardData=e.clipboardData,n.dispatchEvent(o)}})),ht(t.lineSpace,"selectstart",(function(e){Sr(t,e)||bt(e)})),ht(n,"compositionstart",(function(){var t=i.getCursor("from");r.composing&&r.composing.range.clear(),r.composing={start:t,range:i.markText(t,i.getCursor("to"),{className:"CodeMirror-composing"})}})),ht(n,"compositionend",(function(){r.composing&&(r.poll(),r.composing.range.clear(),r.composing=null)}))},Vs.prototype.createField=function(t){this.wrapper=Fs(),this.textarea=this.wrapper.firstChild},Vs.prototype.screenReaderLabelChanged=function(t){t?this.textarea.setAttribute("aria-label",t):this.textarea.removeAttribute("aria-label")},Vs.prototype.prepareSelection=function(){var t=this.cm,e=t.display,r=t.doc,i=mi(t);if(t.options.moveInputWithCursor){var n=Kr(t,r.sel.primary().head,"div"),o=e.wrapper.getBoundingClientRect(),s=e.lineDiv.getBoundingClientRect();i.teTop=Math.max(0,Math.min(e.wrapper.clientHeight-10,n.top+s.top-o.top)),i.teLeft=Math.max(0,Math.min(e.wrapper.clientWidth-10,n.left+s.left-o.left))}return i},Vs.prototype.showSelection=function(t){var e=this.cm.display;A(e.cursorDiv,t.cursors),A(e.selectionDiv,t.selection),null!=t.teTop&&(this.wrapper.style.top=t.teTop+"px",this.wrapper.style.left=t.teLeft+"px")},Vs.prototype.reset=function(t){if(!this.contextMenuPending&&!this.composing){var e=this.cm;if(e.somethingSelected()){this.prevInput="";var r=e.getSelection();this.textarea.value=r,e.state.focused&&P(this.textarea),s&&a>=9&&(this.hasSelection=r)}else t||(this.prevInput=this.textarea.value="",s&&a>=9&&(this.hasSelection=null))}},Vs.prototype.getField=function(){return this.textarea},Vs.prototype.supportsTouch=function(){return!1},Vs.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!v||_()!=this.textarea))try{this.textarea.focus()}catch(t){}},Vs.prototype.blur=function(){this.textarea.blur()},Vs.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Vs.prototype.receivedFocus=function(){this.slowPoll()},Vs.prototype.slowPoll=function(){var t=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,(function(){t.poll(),t.cm.state.focused&&t.slowPoll()}))},Vs.prototype.fastPoll=function(){var t=!1,e=this;e.pollingFast=!0,e.polling.set(20,(function r(){e.poll()||t?(e.pollingFast=!1,e.slowPoll()):(t=!0,e.polling.set(60,r))}))},Vs.prototype.poll=function(){var t=this,e=this.cm,r=this.textarea,i=this.prevInput;if(this.contextMenuPending||!e.state.focused||_t(r)&&!i&&!this.composing||e.isReadOnly()||e.options.disableInput||e.state.keySeq)return!1;var n=r.value;if(n==i&&!e.somethingSelected())return!1;if(s&&a>=9&&this.hasSelection===n||y&&/[\uf700-\uf7ff]/.test(n))return e.display.input.reset(),!1;if(e.doc.sel==e.display.selForContextMenu){var o=n.charCodeAt(0);if(8203!=o||i||(i=""),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var l=0,c=Math.min(i.length,n.length);l<c&&i.charCodeAt(l)==n.charCodeAt(l);)++l;return Qi(e,(function(){_s(e,n.slice(l),i.length-l,null,t.composing?"*compose":null),n.length>1e3||n.indexOf("\n")>-1?r.value=t.prevInput="":t.prevInput=n,t.composing&&(t.composing.range.clear(),t.composing.range=e.markText(t.composing.start,e.getCursor("to"),{className:"CodeMirror-composing"}))})),!0},Vs.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Vs.prototype.onKeyPress=function(){s&&a>=9&&(this.hasSelection=null),this.fastPoll()},Vs.prototype.onContextMenu=function(t){var e=this,r=e.cm,i=r.display,n=e.textarea;e.contextMenuPending&&e.contextMenuPending();var o=li(r,t),c=i.scroller.scrollTop;if(o&&!h){r.options.resetSelectionOnContextMenu&&-1==r.doc.sel.contains(o)&&Ji(r,Jn)(r.doc,En(o),G);var u,d=n.style.cssText,f=e.wrapper.style.cssText,p=e.wrapper.offsetParent.getBoundingClientRect();if(e.wrapper.style.cssText="position: static",n.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(t.clientY-p.top-5)+"px; left: "+(t.clientX-p.left-5)+"px;\n z-index: 1000; background: "+(s?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",l&&(u=window.scrollY),i.input.focus(),l&&window.scrollTo(null,u),i.input.reset(),r.somethingSelected()||(n.value=e.prevInput=" "),e.contextMenuPending=v,i.selForContextMenu=r.doc.sel,clearTimeout(i.detectingSelectAll),s&&a>=9&&m(),w){Ct(t);var g=function(){ft(window,"mouseup",g),setTimeout(v,20)};ht(window,"mouseup",g)}else setTimeout(v,50)}function m(){if(null!=n.selectionStart){var t=r.somethingSelected(),o=""+(t?n.value:"");n.value="⇚",n.value=o,e.prevInput=t?"":"",n.selectionStart=1,n.selectionEnd=o.length,i.selForContextMenu=r.doc.sel}}function v(){if(e.contextMenuPending==v&&(e.contextMenuPending=!1,e.wrapper.style.cssText=f,n.style.cssText=d,s&&a<9&&i.scrollbars.setScrollTop(i.scroller.scrollTop=c),null!=n.selectionStart)){(!s||s&&a<9)&&m();var t=0,o=function(){i.selForContextMenu==r.doc.sel&&0==n.selectionStart&&n.selectionEnd>0&&""==e.prevInput?Ji(r,ao)(r):t++<10?i.detectingSelectAll=setTimeout(o,500):(i.selForContextMenu=null,i.input.reset())};i.detectingSelectAll=setTimeout(o,200)}}},Vs.prototype.readOnlyChanged=function(t){t||this.reset(),this.textarea.disabled="nocursor"==t,this.textarea.readOnly=!!t},Vs.prototype.setUneditable=function(){},Vs.prototype.needsContentAttribute=!1,function(t){var e=t.optionHandlers;function r(r,i,n,o){t.defaults[r]=i,n&&(e[r]=o?function(t,e,r){r!=Cs&&n(t,e,r)}:n)}t.defineOption=r,t.Init=Cs,r("value","",(function(t,e){return t.setValue(e)}),!0),r("mode",null,(function(t,e){t.doc.modeOption=e,On(t)}),!0),r("indentUnit",2,On,!0),r("indentWithTabs",!1),r("smartIndent",!0),r("tabSize",4,(function(t){Rn(t),jr(t),ui(t)}),!0),r("lineSeparator",null,(function(t,e){if(t.doc.lineSep=e,e){var r=[],i=t.doc.first;t.doc.iter((function(t){for(var n=0;;){var o=t.text.indexOf(e,n);if(-1==o)break;n=o+e.length,r.push(te(i,o))}i++}));for(var n=r.length-1;n>=0;n--)go(t.doc,e,r[n],te(r[n].line,r[n].ch+e.length))}})),r("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,(function(t,e,r){t.state.specialChars=new RegExp(e.source+(e.test("\t")?"":"|\t"),"g"),r!=Cs&&t.refresh()})),r("specialCharPlaceholder",Qe,(function(t){return t.refresh()}),!0),r("electricChars",!0),r("inputStyle",v?"contenteditable":"textarea",(function(){throw new Error("inputStyle can not (yet) be changed in a running editor")}),!0),r("spellcheck",!1,(function(t,e){return t.getInputField().spellcheck=e}),!0),r("autocorrect",!1,(function(t,e){return t.getInputField().autocorrect=e}),!0),r("autocapitalize",!1,(function(t,e){return t.getInputField().autocapitalize=e}),!0),r("rtlMoveVisually",!x),r("wholeLineUpdateBefore",!0),r("theme","default",(function(t){Ss(t),gn(t)}),!0),r("keyMap","default",(function(t,e,r){var i=$o(e),n=r!=Cs&&$o(r);n&&n.detach&&n.detach(t,i),i.attach&&i.attach(t,n||null)})),r("extraKeys",null),r("configureMouse",null),r("lineWrapping",!1,Ts,!0),r("gutters",[],(function(t,e){t.display.gutterSpecs=fn(e,t.options.lineNumbers),gn(t)}),!0),r("fixedGutter",!0,(function(t,e){t.display.gutters.style.left=e?oi(t.display)+"px":"0",t.refresh()}),!0),r("coverGutterNextToScrollbar",!1,(function(t){return Ui(t)}),!0),r("scrollbarStyle","native",(function(t){zi(t),Ui(t),t.display.scrollbars.setScrollTop(t.doc.scrollTop),t.display.scrollbars.setScrollLeft(t.doc.scrollLeft)}),!0),r("lineNumbers",!1,(function(t,e){t.display.gutterSpecs=fn(t.options.gutters,e),gn(t)}),!0),r("firstLineNumber",1,gn,!0),r("lineNumberFormatter",(function(t){return t}),gn,!0),r("showCursorWhenSelecting",!1,gi,!0),r("resetSelectionOnContextMenu",!0),r("lineWiseCopyCut",!0),r("pasteLinesPerSelection",!0),r("selectionsMayTouch",!1),r("readOnly",!1,(function(t,e){"nocursor"==e&&(ki(t),t.display.input.blur()),t.display.input.readOnlyChanged(e)})),r("screenReaderLabel",null,(function(t,e){e=""===e?null:e,t.display.input.screenReaderLabelChanged(e)})),r("disableInput",!1,(function(t,e){e||t.display.input.reset()}),!0),r("dragDrop",!0,Es),r("allowDropFileTypes",null),r("cursorBlinkRate",530),r("cursorScrollMargin",0),r("cursorHeight",1,gi,!0),r("singleCursorHeightPerLine",!0,gi,!0),r("workTime",100),r("workDelay",100),r("flattenSpans",!0,Rn,!0),r("addModeClass",!1,Rn,!0),r("pollInterval",100),r("undoDepth",200,(function(t,e){return t.doc.history.undoDepth=e})),r("historyEventDelay",1250),r("viewportMargin",10,(function(t){return t.refresh()}),!0),r("maxHighlightLength",1e4,Rn,!0),r("moveInputWithCursor",!0,(function(t,e){e||t.display.input.resetPosition()})),r("tabindex",null,(function(t,e){return t.display.input.getField().tabIndex=e||""})),r("autofocus",null),r("direction","ltr",(function(t,e){return t.doc.setDirection(e)}),!0),r("phrases",null)}(Ls),function(t){var e=t.optionHandlers,r=t.helpers={};t.prototype={constructor:t,focus:function(){window.focus(),this.display.input.focus()},setOption:function(t,r){var i=this.options,n=i[t];i[t]==r&&"mode"!=t||(i[t]=r,e.hasOwnProperty(t)&&Ji(this,e[t])(this,r,n),pt(this,"optionChange",this,t))},getOption:function(t){return this.options[t]},getDoc:function(){return this.doc},addKeyMap:function(t,e){this.state.keyMaps[e?"push":"unshift"]($o(t))},removeKeyMap:function(t){for(var e=this.state.keyMaps,r=0;r<e.length;++r)if(e[r]==t||e[r].name==t)return e.splice(r,1),!0},addOverlay:tn((function(e,r){var i=e.token?e:t.getMode(this.options,e);if(i.startState)throw new Error("Overlays may not be stateful.");!function(t,e,r){for(var i=0,n=r(e);i<t.length&&r(t[i])<=n;)i++;t.splice(i,0,e)}(this.state.overlays,{mode:i,modeSpec:e,opaque:r&&r.opaque,priority:r&&r.priority||0},(function(t){return t.priority})),this.state.modeGen++,ui(this)})),removeOverlay:tn((function(t){for(var e=this.state.overlays,r=0;r<e.length;++r){var i=e[r].modeSpec;if(i==t||"string"==typeof t&&i.name==t)return e.splice(r,1),this.state.modeGen++,void ui(this)}})),indentLine:tn((function(t,e,r){"string"!=typeof e&&"number"!=typeof e&&(e=null==e?this.options.smartIndent?"smart":"prev":e?"add":"subtract"),Qt(this.doc,t)&&Ds(this,t,e,r)})),indentSelection:tn((function(t){for(var e=this.doc.sel.ranges,r=-1,i=0;i<e.length;i++){var n=e[i];if(n.empty())n.head.line>r&&(Ds(this,n.head.line,t,!0),r=n.head.line,i==this.doc.sel.primIndex&&Oi(this));else{var o=n.from(),s=n.to(),a=Math.max(r,o.line);r=Math.min(this.lastLine(),s.line-(s.ch?0:1))+1;for(var l=a;l<r;++l)Ds(this,l,t);var c=this.doc.sel.ranges;0==o.ch&&e.length==c.length&&c[i].from().ch>0&&$n(this.doc,i,new wn(o,c[i].to()),G)}}})),getTokenAt:function(t,e){return ye(this,t,e)},getLineTokens:function(t,e){return ye(this,te(t),e,!0)},getTokenTypeAt:function(t){t=ae(this.doc,t);var e,r=de(this,Kt(this.doc,t.line)),i=0,n=(r.length-1)/2,o=t.ch;if(0==o)e=r[2];else for(;;){var s=i+n>>1;if((s?r[2*s-1]:0)>=o)n=s;else{if(!(r[2*s+1]<o)){e=r[2*s+2];break}i=s+1}}var a=e?e.indexOf("overlay "):-1;return a<0?e:0==a?null:e.slice(0,a-1)},getModeAt:function(e){var r=this.doc.mode;return r.innerMode?t.innerMode(r,this.getTokenAt(e).state).mode:r},getHelper:function(t,e){return this.getHelpers(t,e)[0]},getHelpers:function(t,e){var i=[];if(!r.hasOwnProperty(e))return i;var n=r[e],o=this.getModeAt(t);if("string"==typeof o[e])n[o[e]]&&i.push(n[o[e]]);else if(o[e])for(var s=0;s<o[e].length;s++){var a=n[o[e][s]];a&&i.push(a)}else o.helperType&&n[o.helperType]?i.push(n[o.helperType]):n[o.name]&&i.push(n[o.name]);for(var l=0;l<n._global.length;l++){var c=n._global[l];c.pred(o,this)&&-1==U(i,c.val)&&i.push(c.val)}return i},getStateAfter:function(t,e){var r=this.doc;return fe(this,(t=se(r,null==t?r.first+r.size-1:t))+1,e).state},cursorCoords:function(t,e){var r=this.doc.sel.primary();return Kr(this,null==t?r.head:"object"==typeof t?ae(this.doc,t):t?r.from():r.to(),e||"page")},charCoords:function(t,e){return Vr(this,ae(this.doc,t),e||"page")},coordsChar:function(t,e){return Xr(this,(t=Wr(this,t,e||"page")).left,t.top)},lineAtHeight:function(t,e){return t=Wr(this,{top:t,left:0},e||"page").top,Zt(this.doc,t+this.display.viewOffset)},heightAtLine:function(t,e,r){var i,n=!1;if("number"==typeof t){var o=this.doc.first+this.doc.size-1;t<this.doc.first?t=this.doc.first:t>o&&(t=o,n=!0),i=Kt(this.doc,t)}else i=t;return zr(this,i,{top:0,left:0},e||"page",r||n).top+(n?this.doc.height-ze(i):0)},defaultTextHeight:function(){return ri(this.display)},defaultCharWidth:function(){return ii(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(t,e,r,i,n){var o,s,a,l=this.display,c=(t=Kr(this,ae(this.doc,t))).bottom,u=t.left;if(e.style.position="absolute",e.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(e),l.sizer.appendChild(e),"over"==i)c=t.top;else if("above"==i||"near"==i){var h=Math.max(l.wrapper.clientHeight,this.doc.height),d=Math.max(l.sizer.clientWidth,l.lineSpace.clientWidth);("above"==i||t.bottom+e.offsetHeight>h)&&t.top>e.offsetHeight?c=t.top-e.offsetHeight:t.bottom+e.offsetHeight<=h&&(c=t.bottom),u+e.offsetWidth>d&&(u=d-e.offsetWidth)}e.style.top=c+"px",e.style.left=e.style.right="","right"==n?(u=l.sizer.clientWidth-e.offsetWidth,e.style.right="0px"):("left"==n?u=0:"middle"==n&&(u=(l.sizer.clientWidth-e.offsetWidth)/2),e.style.left=u+"px"),r&&(o=this,s={left:u,top:c,right:u+e.offsetWidth,bottom:c+e.offsetHeight},null!=(a=Ai(o,s)).scrollTop&&Mi(o,a.scrollTop),null!=a.scrollLeft&&Ni(o,a.scrollLeft))},triggerOnKeyDown:tn(us),triggerOnKeyPress:tn(ds),triggerOnKeyUp:hs,triggerOnMouseDown:tn(ms),execCommand:function(t){if(es.hasOwnProperty(t))return es[t].call(null,this)},triggerElectric:tn((function(t){Ms(this,t)})),findPosH:function(t,e,r,i){var n=1;e<0&&(n=-1,e=-e);for(var o=ae(this.doc,t),s=0;s<e&&!(o=Bs(this.doc,o,n,r,i)).hitSide;++s);return o},moveH:tn((function(t,e){var r=this;this.extendSelectionsBy((function(i){return r.display.shift||r.doc.extend||i.empty()?Bs(r.doc,i.head,t,e,r.options.rtlMoveVisually):t<0?i.from():i.to()}),W)})),deleteH:tn((function(t,e){var r=this.doc.sel,i=this.doc;r.somethingSelected()?i.replaceSelection("",null,"+delete"):Zo(this,(function(r){var n=Bs(i,r.head,t,e,!1);return t<0?{from:n,to:r.head}:{from:r.head,to:n}}))})),findPosV:function(t,e,r,i){var n=1,o=i;e<0&&(n=-1,e=-e);for(var s=ae(this.doc,t),a=0;a<e;++a){var l=Kr(this,s,"div");if(null==o?o=l.left:l.left=o,(s=js(this,l,n,r)).hitSide)break}return s},moveV:tn((function(t,e){var r=this,i=this.doc,n=[],o=!this.display.shift&&!i.extend&&i.sel.somethingSelected();if(i.extendSelectionsBy((function(s){if(o)return t<0?s.from():s.to();var a=Kr(r,s.head,"div");null!=s.goalColumn&&(a.left=s.goalColumn),n.push(a.left);var l=js(r,a,t,e);return"page"==e&&s==i.sel.primary()&&Di(r,Vr(r,l,"div").top-a.top),l}),W),n.length)for(var s=0;s<i.sel.ranges.length;s++)i.sel.ranges[s].goalColumn=n[s]})),findWordAt:function(t){var e=Kt(this.doc,t.line).text,r=t.ch,i=t.ch;if(e){var n=this.getHelper(t,"wordChars");"before"!=t.sticky&&i!=e.length||!r?++i:--r;for(var o=e.charAt(r),s=tt(o,n)?function(t){return tt(t,n)}:/\s/.test(o)?function(t){return/\s/.test(t)}:function(t){return!/\s/.test(t)&&!tt(t)};r>0&&s(e.charAt(r-1));)--r;for(;i<e.length&&s(e.charAt(i));)++i}return new wn(te(t.line,r),te(t.line,i))},toggleOverwrite:function(t){null!=t&&t==this.state.overwrite||((this.state.overwrite=!this.state.overwrite)?I(this.display.cursorDiv,"CodeMirror-overwrite"):T(this.display.cursorDiv,"CodeMirror-overwrite"),pt(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==_()},isReadOnly:function(){return!(!this.options.readOnly&&!this.doc.cantEdit)},scrollTo:tn((function(t,e){Ri(this,t,e)})),getScrollInfo:function(){var t=this.display.scroller;return{left:t.scrollLeft,top:t.scrollTop,height:t.scrollHeight-Er(this)-this.display.barHeight,width:t.scrollWidth-Er(this)-this.display.barWidth,clientHeight:Lr(this),clientWidth:Tr(this)}},scrollIntoView:tn((function(t,e){null==t?(t={from:this.doc.sel.primary().head,to:null},null==e&&(e=this.options.cursorScrollMargin)):"number"==typeof t?t={from:te(t,0),to:null}:null==t.from&&(t={from:t,to:null}),t.to||(t.to=t.from),t.margin=e||0,null!=t.from.line?function(t,e){_i(t),t.curOp.scrollToPos=e}(this,t):Ii(this,t.from,t.to,t.margin)})),setSize:tn((function(t,e){var r=this,i=function(t){return"number"==typeof t||/^\d+$/.test(String(t))?t+"px":t};null!=t&&(this.display.wrapper.style.width=i(t)),null!=e&&(this.display.wrapper.style.height=i(e)),this.options.lineWrapping&&Br(this);var n=this.display.viewFrom;this.doc.iter(n,this.display.viewTo,(function(t){if(t.widgets)for(var e=0;e<t.widgets.length;e++)if(t.widgets[e].noHScroll){hi(r,n,"widget");break}++n})),this.curOp.forceUpdate=!0,pt(this,"refresh",this)})),operation:function(t){return Qi(this,t)},startOperation:function(){return Vi(this)},endOperation:function(){return Ki(this)},refresh:tn((function(){var t=this.display.cachedTextHeight;ui(this),this.curOp.forceUpdate=!0,jr(this),Ri(this,this.doc.scrollLeft,this.doc.scrollTop),cn(this.display),(null==t||Math.abs(t-ri(this.display))>.5||this.options.lineWrapping)&&ai(this),pt(this,"refresh",this)})),swapDoc:tn((function(t){var e=this.doc;return e.cm=null,this.state.selectingText&&this.state.selectingText(),Pn(this,t),jr(this),this.display.input.reset(),Ri(this,t.scrollLeft,t.scrollTop),this.curOp.forceScroll=!0,ar(this,"swapDoc",this,e),e})),phrase:function(t){var e=this.options.phrases;return e&&Object.prototype.hasOwnProperty.call(e,t)?e[t]:t},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}},yt(t),t.registerHelper=function(e,i,n){r.hasOwnProperty(e)||(r[e]=t[e]={_global:[]}),r[e][i]=n},t.registerGlobalHelper=function(e,i,n,o){t.registerHelper(e,i,o),r[e]._global.push({pred:n,val:o})}}(Ls);var Ks="iter insert remove copy getEditor constructor".split(" ");for(var qs in Ro.prototype)Ro.prototype.hasOwnProperty(qs)&&U(Ks,qs)<0&&(Ls.prototype[qs]=function(t){return function(){return t.apply(this.doc,arguments)}}(Ro.prototype[qs]));return yt(Ro),Ls.inputStyles={textarea:Vs,contenteditable:Us},Ls.defineMode=function(t){Ls.defaults.mode||"null"==t||(Ls.defaults.mode=t),Ft.apply(this,arguments)},Ls.defineMIME=function(t,e){Nt[t]=e},Ls.defineMode("null",(function(){return{token:function(t){return t.skipToEnd()}}})),Ls.defineMIME("text/plain","null"),Ls.defineExtension=function(t,e){Ls.prototype[t]=e},Ls.defineDocExtension=function(t,e){Ro.prototype[t]=e},Ls.fromTextArea=function(t,e){if((e=e?F(e):{}).value=t.value,!e.tabindex&&t.tabIndex&&(e.tabindex=t.tabIndex),!e.placeholder&&t.placeholder&&(e.placeholder=t.placeholder),null==e.autofocus){var r=_();e.autofocus=r==t||null!=t.getAttribute("autofocus")&&r==document.body}function i(){t.value=a.getValue()}var n;if(t.form&&(ht(t.form,"submit",i),!e.leaveSubmitMethodAlone)){var o=t.form;n=o.submit;try{var s=o.submit=function(){i(),o.submit=n,o.submit(),o.submit=s}}catch(t){}}e.finishInit=function(r){r.save=i,r.getTextArea=function(){return t},r.toTextArea=function(){r.toTextArea=isNaN,i(),t.parentNode.removeChild(r.getWrapperElement()),t.style.display="",t.form&&(ft(t.form,"submit",i),e.leaveSubmitMethodAlone||"function"!=typeof t.form.submit||(t.form.submit=n))}},t.style.display="none";var a=Ls((function(e){return t.parentNode.insertBefore(e,t.nextSibling)}),e);return a},function(t){t.off=ft,t.on=ht,t.wheelEventPixels=xn,t.Doc=Ro,t.splitLines=Rt,t.countColumn=B,t.findColumn=V,t.isWordChar=J,t.Pass=H,t.signal=pt,t.Line=Ke,t.changeEnd=Tn,t.scrollbarModel=Gi,t.Pos=te,t.cmpPos=ee,t.modes=Pt,t.mimeModes=Nt,t.resolveMode=Bt,t.getMode=jt,t.modeExtensions=Ut,t.extendMode=Ht,t.copyState=Gt,t.startState=Wt,t.innerMode=zt,t.commands=es,t.keyMap=zo,t.keyName=Xo,t.isModifierKey=qo,t.lookupKey=Ko,t.normalizeKeyMap=Vo,t.StringStream=Vt,t.SharedTextMarker=Lo,t.TextMarker=Eo,t.LineWidget=Co,t.e_preventDefault=bt,t.e_stopPropagation=xt,t.e_stop=Ct,t.addClass=I,t.contains=R,t.rmClass=T,t.keyNames=jo}(Ls),Ls.version="5.58.2",Ls}()},Y1PL:
|
|
|
/*!**********************************************************!*\
|
|
|
!*** ./node_modules/rc-textarea/es/index.js + 7 modules ***!
|
|
|
\**********************************************************/
|
|
|
/*! exports provided: ResizableTextArea, default */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createClass.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createSuper.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/defineProperty.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/extends.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/inherits.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/classnames/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/Children/toArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/Dom/findDOMNode.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/omit.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/ref.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/warning.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js (<- Module uses injected variables (global)) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/shallowequal/index.js (<- Module is not an ECMAScript module) */function(t,e,r){"use strict";r.r(e),r.d(e,"ResizableTextArea",(function(){return I}));var i=r("wx14"),n=r("1OyB"),o=r("vuIU"),s=r("Ji7U"),a=r("LK+K"),l=r("q1tI"),c=r("VTBJ"),u=r("rePB"),h=r("Zm9Q"),d=(r("Kwbf"),r("c+Xe")),f=r("m+aA"),p=r("bdgK"),g=new Map;var m=new p.default((function(t){t.forEach((function(t){var e,r=t.target;null===(e=g.get(r))||void 0===e||e.forEach((function(t){return t(r)}))}))}));var v=function(t){Object(s.a)(r,t);var e=Object(a.a)(r);function r(){return Object(n.a)(this,r),e.apply(this,arguments)}return Object(o.a)(r,[{key:"render",value:function(){return this.props.children}}]),r}(l.Component),y=l.createContext(null);function b(t){var e=t.children,r=t.disabled,i=l.useRef(null),n=l.useRef(null),o=l.useContext(y),s=l.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),a=l.isValidElement(e)&&Object(d.c)(e),u=a?e.ref:null,h=l.useMemo((function(){return Object(d.a)(u,i)}),[u,i]),p=l.useRef(t);p.current=t;var b=l.useCallback((function(t){var e=p.current,r=e.onResize,i=e.data,n=t.getBoundingClientRect(),a=n.width,l=n.height,u=t.offsetWidth,h=t.offsetHeight,d=Math.floor(a),f=Math.floor(l);if(s.current.width!==d||s.current.height!==f||s.current.offsetWidth!==u||s.current.offsetHeight!==h){var g={width:d,height:f,offsetWidth:u,offsetHeight:h};s.current=g;var m=u===Math.round(a)?a:u,v=h===Math.round(l)?l:h,y=Object(c.a)(Object(c.a)({},g),{},{offsetWidth:m,offsetHeight:v});null==o||o(y,t,i),r&&Promise.resolve().then((function(){r(y,t)}))}}),[]);return l.useEffect((function(){var t,e,o=Object(f.a)(i.current)||Object(f.a)(n.current);return o&&!r&&(t=o,e=b,g.has(t)||(g.set(t,new Set),m.observe(t)),g.get(t).add(e)),function(){return function(t,e){g.has(t)&&(g.get(t).delete(e),g.get(t).size||(m.unobserve(t),g.delete(t)))}(o,b)}}),[i.current,r]),l.createElement(v,{ref:n},a?l.cloneElement(e,{ref:h}):e)}function x(t){var e=t.children;return Object(h.a)(e).map((function(e,r){var n=(null==e?void 0:e.key)||"".concat("rc-observer-key","-").concat(r);return l.createElement(b,Object(i.a)({},t,{key:n}),e)}))}x.Collection=function(t){var e=t.children,r=t.onBatchResize,i=l.useRef(0),n=l.useRef([]),o=l.useContext(y),s=l.useCallback((function(t,e,s){i.current+=1;var a=i.current;n.current.push({size:t,element:e,data:s}),Promise.resolve().then((function(){a===i.current&&(null==r||r(n.current),n.current=[])})),null==o||o(t,e,s)}),[r,o]);return l.createElement(y.Provider,{value:s},e)};var S,C=x,w=r("bT9E"),k=r("TSYQ"),E=r.n(k),T="\n min-height:0 !important;\n max-height:none !important;\n height:0 !important;\n visibility:hidden !important;\n overflow:hidden !important;\n position:absolute !important;\n z-index:-1000 !important;\n top:0 !important;\n right:0 !important\n",L=["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"],A={};function D(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=t.getAttribute("id")||t.getAttribute("data-reactid")||t.getAttribute("name");if(e&&A[r])return A[r];var i=window.getComputedStyle(t),n=i.getPropertyValue("box-sizing")||i.getPropertyValue("-moz-box-sizing")||i.getPropertyValue("-webkit-box-sizing"),o=parseFloat(i.getPropertyValue("padding-bottom"))+parseFloat(i.getPropertyValue("padding-top")),s=parseFloat(i.getPropertyValue("border-bottom-width"))+parseFloat(i.getPropertyValue("border-top-width")),a=L.map((function(t){return"".concat(t,":").concat(i.getPropertyValue(t))})).join(";"),l={sizingStyle:a,paddingSize:o,borderSize:s,boxSizing:n};return e&&r&&(A[r]=l),l}var O,R=r("Gytx"),_=r.n(R);!function(t){t[t.NONE=0]="NONE",t[t.RESIZING=1]="RESIZING",t[t.RESIZED=2]="RESIZED"}(O||(O={}));var I=function(t){Object(s.a)(r,t);var e=Object(a.a)(r);function r(t){var o;return Object(n.a)(this,r),(o=e.call(this,t)).nextFrameActionId=void 0,o.resizeFrameId=void 0,o.textArea=void 0,o.saveTextArea=function(t){o.textArea=t},o.handleResize=function(t){var e=o.state.resizeStatus,r=o.props,i=r.autoSize,n=r.onResize;e===O.NONE&&("function"==typeof n&&n(t),i&&o.resizeOnNextFrame())},o.resizeOnNextFrame=function(){cancelAnimationFrame(o.nextFrameActionId),o.nextFrameActionId=requestAnimationFrame(o.resizeTextarea)},o.resizeTextarea=function(){var t=o.props.autoSize;if(t&&o.textArea){var e=t.minRows,r=t.maxRows,i=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;S||((S=document.createElement("textarea")).setAttribute("tab-index","-1"),S.setAttribute("aria-hidden","true"),document.body.appendChild(S)),t.getAttribute("wrap")?S.setAttribute("wrap",t.getAttribute("wrap")):S.removeAttribute("wrap");var n=D(t,e),o=n.paddingSize,s=n.borderSize,a=n.boxSizing,l=n.sizingStyle;S.setAttribute("style","".concat(l,";").concat(T)),S.value=t.value||t.placeholder||"";var c,u=Number.MIN_SAFE_INTEGER,h=Number.MAX_SAFE_INTEGER,d=S.scrollHeight;if("border-box"===a?d+=s:"content-box"===a&&(d-=o),null!==r||null!==i){S.value=" ";var f=S.scrollHeight-o;null!==r&&(u=f*r,"border-box"===a&&(u=u+o+s),d=Math.max(u,d)),null!==i&&(h=f*i,"border-box"===a&&(h=h+o+s),c=d>h?"":"hidden",d=Math.min(h,d))}return{height:d,minHeight:u,maxHeight:h,overflowY:c,resize:"none"}}(o.textArea,!1,e,r);o.setState({textareaStyles:i,resizeStatus:O.RESIZING},(function(){cancelAnimationFrame(o.resizeFrameId),o.resizeFrameId=requestAnimationFrame((function(){o.setState({resizeStatus:O.RESIZED},(function(){o.resizeFrameId=requestAnimationFrame((function(){o.setState({resizeStatus:O.NONE}),o.fixFirefoxAutoScroll()}))}))}))}))}},o.renderTextArea=function(){var t=o.props,e=t.prefixCls,r=void 0===e?"rc-textarea":e,n=t.autoSize,s=t.onResize,a=t.className,h=t.disabled,d=o.state,f=d.textareaStyles,p=d.resizeStatus,g=Object(w.a)(o.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),m=E()(r,a,Object(u.a)({},"".concat(r,"-disabled"),h));"value"in g&&(g.value=g.value||"");var v=Object(c.a)(Object(c.a)(Object(c.a)({},o.props.style),f),p===O.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return l.createElement(C,{onResize:o.handleResize,disabled:!(n||s)},l.createElement("textarea",Object(i.a)({},g,{className:m,style:v,ref:o.saveTextArea})))},o.state={textareaStyles:{},resizeStatus:O.NONE},o}return Object(o.a)(r,[{key:"componentDidUpdate",value:function(t){t.value===this.props.value&&_()(t.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 t=this.textArea.selectionStart,e=this.textArea.selectionEnd;this.textArea.setSelectionRange(t,e)}}catch(t){}}},{key:"render",value:function(){return this.renderTextArea()}}]),r}(l.Component),M=function(t){Object(s.a)(r,t);var e=Object(a.a)(r);function r(t){var i;Object(n.a)(this,r),(i=e.call(this,t)).resizableTextArea=void 0,i.focus=function(){i.resizableTextArea.textArea.focus()},i.saveTextArea=function(t){i.resizableTextArea=t},i.handleChange=function(t){var e=i.props.onChange;i.setValue(t.target.value,(function(){i.resizableTextArea.resizeTextarea()})),e&&e(t)},i.handleKeyDown=function(t){var e=i.props,r=e.onPressEnter,n=e.onKeyDown;13===t.keyCode&&r&&r(t),n&&n(t)};var o=void 0===t.value||null===t.value?t.defaultValue:t.value;return i.state={value:o},i}return Object(o.a)(r,[{key:"setValue",value:function(t,e){"value"in this.props||this.setState({value:t},e)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return l.createElement(I,Object(i.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(t){return"value"in t?{value:t.value}:null}}]),r}(l.Component);e.default=M},ZW9T:
|
|
|
/*!************************************************************!*\
|
|
|
!*** ./src/components/monaco-editor/index.jsx + 1 modules ***!
|
|
|
\************************************************************/
|
|
|
/*! exports provided: getLanguageByMirrorName, default, DiffEditor */
|
|
|
/*! exports used: DiffEditor, default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/message/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/message/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js (<- Module uses injected variables (global)) */function(t,e,r){"use strict";r.d(e,"a",(function(){return v}));var i=r("k1fw"),n=(r("miYZ"),r("tsqr")),o=r("rAM+"),s=r("tJVT"),a=r("PpiC"),l=r("q1tI"),c=r.n(l),u=r("bdgK");function h(t,e,r,n,o){var s=e.getWordUntilPosition(r),a={startLineNumber:r.lineNumber,endLineNumber:r.lineNumber,startColumn:s.startColumn,endColumn:s.endColumn},l=n.map((function(e){return{label:e,kind:t.languages.CompletionItemKind.Keyword,insertText:e,insertTextRules:t.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:a}}));return o.map((function(t){l.push(Object(i.a)(Object(i.a)({},t),{},{range:a}))})),l}r("LvDl");function d(t){return/^\d+$/.test(t)?"".concat(t,"px"):t}function f(){}var p={"Python3.6":"python","Python2.7":"python",Dynamips:"cpp",Java:"java",Web:"php",Html:"html",Hive:"sql",Hadoop:"java",SDL:"cpp",PHP:"php",Matlab:"python",Git:"python",Python:"python","C/C++":"cpp","C++":"cpp",C:"cpp",Ruby:"ruby",Shell:"shell",JavaScript:"javascript",Perl6:"perl",Kotlin:"kotlin",Elixir:"elixir",Android:"java",JavaWeb:"java",Go:"go",Spark:"sql",MachineLearning:"python",Verilog:"xml","Verilog/VNC":"xml",Docker:"dockerfile","C#":"csharp",SQLite3:"sql",Oracle:"sql",Vhdl:"vhdl",R:"r",Swift:"swift",SQLServer:"mysql",MySQL:"mysql",Mongo:"sql",PostgreSql:"pgsql",Hbase:"powershell",Sqoop:"sql",Nasm:"cpp",Kafka:"java",Flink:"java",Sml:"javascript",OpenGL:"cpp",Perl5:"perl",Orange:"python"};function g(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=t;if(Array.isArray(t)){for(var r=0;r<t.length;r++){var i=p[t[r]];if(i)return i}return e[0]}return p[e]||e}var m=null;e.b=function(t){var e=t.width,p=void 0===e?"100%":e,v=t.height,y=void 0===v?"100%":v,b=t.value,x=t.language,S=void 0===x?"javascript":x,C=t.style,w=void 0===C?{}:C,k=t.options,E=void 0===k?{}:k,T=t.overrideServices,L=void 0===T?{}:T,A=t.theme,D=void 0===A?"vs-dark":A,O=t.onEditBlur,R=t.onSave,_=t.autoHeight,I=void 0!==_&&_,M=t.forbidCopy,P=void 0!==M&&M,N=t.onChange,F=void 0===N?f:N,B=t.editorDidMount,j=void 0===B?f:B,U=t.onFocus,H=void 0===U?f:U,G=t.filename,z=void 0===G?"educoder.txt":G,W=(Object(a.a)(t,["width","height","value","language","style","options","overrideServices","theme","onEditBlur","onSave","autoHeight","forbidCopy","onChange","editorDidMount","onFocus","filename"]),Object(l.useRef)()),V=Object(l.useRef)({}),K=Object(l.useRef)(),q=Object(l.useRef)(!1),Y=Object(l.useRef)(),X=Object(l.useState)(!1),$=Object(s.a)(X,2),Z=$[0],Q=$[1];function J(){n.b.warn(decodeURIComponent("该任务关卡设置了禁止复制粘贴,请手动输入代码。"))}function tt(){var t=V.current.instance;if(t){var e=t.getSelection(),r=V.current.pastePos||{},i=new m.Range(r.startLineNumber||e.endLineNumber,r.startColumn||e.endColumn,r.endLineNumber||e.endLineNumber,r.endColumn||e.endColumn);setTimeout((function(){t.executeEdits("",[{range:i,text:""}])}),300)}}function et(t){(window.navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)&&83==t.keyCode&&(t.preventDefault(),R())}Object(l.useEffect)((function(){K.current&&clearTimeout(K.current),K.current=setTimeout((function(){!function(){var t=V.current.instance;if(null!=b&&t&&Z){var e=t.getModel();e&&b!==e.getValue()&&(!0,e.setValue(b),t.layout(),!1)}}()}),500)}),[b,Z,V.current]);var rt=function(){if(I&&V.current.instance){var t=V.current.instance.getContentHeight();ut(t<y?y:t)}else ut(y)};function it(t,e){var r,i,n=window.URL||window.webkitURL||window,o=new Blob([e]),s=document.createElementNS("http://www.w3.org/1999/xhtml","a");s.href=n.createObjectURL(o),s.download=t,r=s,(i=document.createEvent("MouseEvents")).initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),r.dispatchEvent(i)}Object(l.useEffect)((function(){rt()}),[rt]),Object(l.useEffect)((function(){W.current&&!Z&&r.e(/*! import() | monaco-editor */27).then(r.t.bind(null,/*! monaco-editor/esm/vs/editor/editor.api.js */"M/lh",7)).then((function(t){try{m=t,V.current.instance=m.editor.create(W.current,{value:b,language:g(S),theme:D,requireConfig:{"vs/nls":{availableLanguages:{"*":"zh-cn"}}},wordWrap:!0},L);var e=V.current.instance;if(j(e,m),setTimeout((function(){rt(),V.current.instance.addAction({id:"d123123",label:"Download File",contextMenuGroupId:"9_cutcopypaste",run:function(){it(z||"educoder.txt",e.getValue())}})}),500),V.current.subscription=e.onDidChangeModelContent((function(t){q.current?clearTimeout(Y.current):(rt(),F(e.getValue(),t)),Y.current=setTimeout((function(){q.current=!1}),500)})),window.Monaco||function(t){var e={label:"ifelse",kind:t.languages.CompletionItemKind.Method,insertText:["if (${1:condition}) {","\t$0","} else {","\t","}"].join("\n"),insertTextRules:t.languages.CompletionItemInsertTextRule.InsertAsSnippet},r=["auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","int","long","register","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","inline","restrict","_Bool","_Complex","_Imaginary","_Alignas","_Alignof","_Atomic","_Static_assert","_Noreturn","_Thread_local","_Generic"];t.languages.registerCompletionItemProvider("cpp",{provideCompletionItems:function(i,n){return{suggestions:h(t,i,n,r,[e])}}});var i=["False","None","True","and","as","assert","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"];t.languages.registerCompletionItemProvider("python",{provideCompletionItems:function(e,r){var n=[{label:"print",kind:t.languages.CompletionItemKind.Snippet,insertText:["print($0)"].join("\n"),insertTextRules:t.languages.CompletionItemInsertTextRule.InsertAsSnippet}];return{suggestions:h(t,e,r,i,n)}}});var n=["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instance of","int","interface","long","native","new","package","private","protected","public","return","strictfp","short","static","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while"];t.languages.registerCompletionItemProvider("java",{provideCompletionItems:function(r,i){var o=[e,{label:"main",kind:t.languages.CompletionItemKind.Snippet,insertText:["public static void main(String[] args) {","\t$0","}"].join("\n"),insertTextRules:t.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"System.out.print",kind:t.languages.CompletionItemKind.Snippet,insertText:["System.out.print($0)"].join("\n"),insertTextRules:t.languages.CompletionItemInsertTextRule.InsertAsSnippet}];return{suggestions:h(t,r,i,n,o)}}})}(m),P&&(e.addCommand(m.KeyMod.CtrlCmd|m.KeyMod.Shift|m.KeyCode.KEY_V,(function(){return J(),null})),e.addCommand(m.KeyMod.CtrlCmd|m.KeyCode.KEY_C,(function(){return J(),null}))),window.Monaco=m,O&&e.onDidBlurEditorWidget((function(){O(e.getValue())})),H&&e.onDidFocusEditorText((function(){H(e.getValue())})),P){e.addCommand(m.KeyMod.CtrlCmd|m.KeyCode.KEY_V,(function(){return J(),null})),e.onDidPaste((function(t){V.current.pastePos=t}));try{window.addEventListener("paste",tt)}catch(t){}}var r=function(){var t;return W.current&&(t=new u.default((function(t){var e,r=Object(o.a)(t);try{for(r.s();!(e=r.n()).done;){var i=e.value;(i.target.offsetHeight>0||i.target.offsetWidth>0)&&V.current.instance.layout()}}catch(t){r.e(t)}finally{r.f()}}))).observe(W.current),t}();return Q(!0),function(){var t=V.current.instance;t.dispose();var e=t.getModel();e&&e.dispose(),V.current.subscription&&V.current.subscription.dispose(),P&&window.removeEventListener("paste",tt),r.unobserve(W.current)}}catch(t){}}))}),[]),Object(l.useEffect)((function(){if(V.current.instance&&Z)return document.addEventListener("keydown",et,!1),function(){document.removeEventListener("keydown",et)}}),[R,Z]),Object(l.useEffect)((function(){var t=V.current.instance;if(t&&Z){var e=g(S);m.editor.setModelLanguage(t.getModel(),e),console.log("language:",S,t.getModel(),e)}}),[S,Z]),Object(l.useEffect)((function(){V.current.instance&&Z&&m.editor.setTheme(D)}),[D,Z]),Object(l.useEffect)((function(){var t=V.current.instance;t&&Z&&(t.updateOptions(Object(i.a)({},E)),setTimeout((function(){t.getModel().updateOptions(Object(i.a)({},E))}),200))}),[JSON.stringify(E),Z]),Object(l.useEffect)((function(){var t=V.current.instance;t&&Z&&t.layout()}),[p,y,Z]);var nt=Object(l.useState)(d(p)),ot=Object(s.a)(nt,2),st=ot[0],at=(ot[1],Object(l.useState)(d(y))),lt=Object(s.a)(at,2),ct=lt[0],ut=lt[1],ht=Object(i.a)(Object(i.a)({},w),{},{width:st,height:ct});return c.a.createElement("div",{className:"my-monaco-editor",ref:W,style:ht})};function v(t){var e=t.width,n=void 0===e?"100%":e,a=t.height,h=void 0===a?"100%":a,f=t.original,p=t.modified,g=t.language,v=t.options,y=void 0===v?{}:v,b=Object(l.useRef)(),x=Object(l.useState)(null),S=Object(s.a)(x,2),C=S[0],w=S[1];Object(l.useEffect)((function(){b.current&&r.e(/*! import() | monaco-editor */27).then(r.t.bind(null,/*! monaco-editor/esm/vs/editor/editor.api.js */"M/lh",7)).then((function(t){var e=(m=t).editor.createDiffEditor(b.current,Object(i.a)(Object(i.a)({enableSplitViewResizing:!1,scrollBeyondLastLine:!1,roundedSelection:!1,renderIndicators:!1,useShadows:!1,horizontal:"hidden",lineNumbers:"off",ignoreTrimWhitespace:!1,followsCaret:!0,ignoreCharChanges:!0,minimap:{enabled:!1},readOnly:!0},y),{},{wordWrap:!0}));w(e);var r=function(t){var e;return b.current&&(e=new u.default((function(e){var r,i=Object(o.a)(e);try{for(i.s();!(r=i.n()).done;){var n=r.value;(n.target.offsetHeight>0||n.target.offsetWidth>0)&&t.layout()}}catch(t){i.e(t)}finally{i.f()}}))).observe(b.current),e}(e);return function(){e.dispose();var t=e.getModel();t&&t.dispose(),r.unobserve(b.current)}}))}),[]),Object(l.useEffect)((function(){C&&C.setModel({original:m.editor.createModel(f,g),modified:m.editor.createModel(p,g)})}),[f,p,g,C]);var k={width:d(n),height:d(h)};return c.a.createElement("div",{className:"my-diff-editor",ref:b,style:k})}},ZpRC:
|
|
|
/*!*************************************************************************!*\
|
|
|
!*** ./node_modules/scroll-into-view-if-needed/es/index.js + 1 modules ***!
|
|
|
\*************************************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,r){"use strict";function i(t){return"object"==typeof t&&null!=t&&1===t.nodeType}function n(t,e){return(!e||"hidden"!==t)&&"visible"!==t&&"clip"!==t}function o(t,e){if(t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth){var r=getComputedStyle(t,null);return n(r.overflowY,e)||n(r.overflowX,e)||function(t){var e=function(t){if(!t.ownerDocument||!t.ownerDocument.defaultView)return null;try{return t.ownerDocument.defaultView.frameElement}catch(t){return null}}(t);return!!e&&(e.clientHeight<t.scrollHeight||e.clientWidth<t.scrollWidth)}(t)}return!1}function s(t,e,r,i,n,o,s,a){return o<t&&s>e||o>t&&s<e?0:o<=t&&a<=r||s>=e&&a>=r?o-t-i:s>e&&a<r||o<t&&a>r?s-e+n:0}var a=function(t,e){var r=window,n=e.scrollMode,a=e.block,l=e.inline,c=e.boundary,u=e.skipOverflowHiddenElements,h="function"==typeof c?c:function(t){return t!==c};if(!i(t))throw new TypeError("Invalid target");for(var d=document.scrollingElement||document.documentElement,f=[],p=t;i(p)&&h(p);){if((p=p.parentElement)===d){f.push(p);break}null!=p&&p===document.body&&o(p)&&!o(document.documentElement)||null!=p&&o(p,u)&&f.push(p)}for(var g=r.visualViewport?r.visualViewport.width:innerWidth,m=r.visualViewport?r.visualViewport.height:innerHeight,v=window.scrollX||pageXOffset,y=window.scrollY||pageYOffset,b=t.getBoundingClientRect(),x=b.height,S=b.width,C=b.top,w=b.right,k=b.bottom,E=b.left,T="start"===a||"nearest"===a?C:"end"===a?k:C+x/2,L="center"===l?E+S/2:"end"===l?w:E,A=[],D=0;D<f.length;D++){var O=f[D],R=O.getBoundingClientRect(),_=R.height,I=R.width,M=R.top,P=R.right,N=R.bottom,F=R.left;if("if-needed"===n&&C>=0&&E>=0&&k<=m&&w<=g&&C>=M&&k<=N&&E>=F&&w<=P)return A;var B=getComputedStyle(O),j=parseInt(B.borderLeftWidth,10),U=parseInt(B.borderTopWidth,10),H=parseInt(B.borderRightWidth,10),G=parseInt(B.borderBottomWidth,10),z=0,W=0,V="offsetWidth"in O?O.offsetWidth-O.clientWidth-j-H:0,K="offsetHeight"in O?O.offsetHeight-O.clientHeight-U-G:0;if(d===O)z="start"===a?T:"end"===a?T-m:"nearest"===a?s(y,y+m,m,U,G,y+T,y+T+x,x):T-m/2,W="start"===l?L:"center"===l?L-g/2:"end"===l?L-g:s(v,v+g,g,j,H,v+L,v+L+S,S),z=Math.max(0,z+y),W=Math.max(0,W+v);else{z="start"===a?T-M-U:"end"===a?T-N+G+K:"nearest"===a?s(M,N,_,U,G+K,T,T+x,x):T-(M+_/2)+K/2,W="start"===l?L-F-j:"center"===l?L-(F+I/2)+V/2:"end"===l?L-P+H+V:s(F,P,I,j,H+V,L,L+S,S);var q=O.scrollLeft,Y=O.scrollTop;T+=Y-(z=Math.max(0,Math.min(Y+z,O.scrollHeight-_+K))),L+=q-(W=Math.max(0,Math.min(q+W,O.scrollWidth-I+V)))}A.push({el:O,top:z,left:W})}return A};function l(t){return t===Object(t)&&0!==Object.keys(t).length}e.a=function(t,e){var r=!t.ownerDocument.documentElement.contains(t);if(l(e)&&"function"==typeof e.behavior)return e.behavior(r?[]:a(t,e));if(!r){var i=function(t){return!1===t?{block:"end",inline:"nearest"}:l(t)?t:{block:"start",inline:"nearest"}}(e);return function(t,e){void 0===e&&(e="auto");var r="scrollBehavior"in document.body.style;t.forEach((function(t){var i=t.el,n=t.top,o=t.left;i.scroll&&r?i.scroll({top:n,left:o,behavior:e}):(i.scrollTop=n,i.scrollLeft=o)}))}(a(t,i),i.behavior)}}},Zss7:
|
|
|
/*!**********************************************!*\
|
|
|
!*** ./node_modules/tinycolor2/tinycolor.js ***!
|
|
|
\**********************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){var i;!function(n){var o=/^\s+/,s=/\s+$/,a=0,l=n.round,c=n.min,u=n.max,h=n.random;function d(t,e){if(e=e||{},(t=t||"")instanceof d)return t;if(!(this instanceof d))return new d(t,e);var r=function(t){var e={r:0,g:0,b:0},r=1,i=null,a=null,l=null,h=!1,d=!1;"string"==typeof t&&(t=function(t){t=t.replace(o,"").replace(s,"").toLowerCase();var e,r=!1;if(O[t])t=O[t],r=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};if(e=z.rgb.exec(t))return{r:e[1],g:e[2],b:e[3]};if(e=z.rgba.exec(t))return{r:e[1],g:e[2],b:e[3],a:e[4]};if(e=z.hsl.exec(t))return{h:e[1],s:e[2],l:e[3]};if(e=z.hsla.exec(t))return{h:e[1],s:e[2],l:e[3],a:e[4]};if(e=z.hsv.exec(t))return{h:e[1],s:e[2],v:e[3]};if(e=z.hsva.exec(t))return{h:e[1],s:e[2],v:e[3],a:e[4]};if(e=z.hex8.exec(t))return{r:P(e[1]),g:P(e[2]),b:P(e[3]),a:j(e[4]),format:r?"name":"hex8"};if(e=z.hex6.exec(t))return{r:P(e[1]),g:P(e[2]),b:P(e[3]),format:r?"name":"hex"};if(e=z.hex4.exec(t))return{r:P(e[1]+""+e[1]),g:P(e[2]+""+e[2]),b:P(e[3]+""+e[3]),a:j(e[4]+""+e[4]),format:r?"name":"hex8"};if(e=z.hex3.exec(t))return{r:P(e[1]+""+e[1]),g:P(e[2]+""+e[2]),b:P(e[3]+""+e[3]),format:r?"name":"hex"};return!1}(t));"object"==typeof t&&(W(t.r)&&W(t.g)&&W(t.b)?(f=t.r,p=t.g,g=t.b,e={r:255*I(f,255),g:255*I(p,255),b:255*I(g,255)},h=!0,d="%"===String(t.r).substr(-1)?"prgb":"rgb"):W(t.h)&&W(t.s)&&W(t.v)?(i=F(t.s),a=F(t.v),e=function(t,e,r){t=6*I(t,360),e=I(e,100),r=I(r,100);var i=n.floor(t),o=t-i,s=r*(1-e),a=r*(1-o*e),l=r*(1-(1-o)*e),c=i%6;return{r:255*[r,a,s,s,l,r][c],g:255*[l,r,r,a,s,s][c],b:255*[s,s,l,r,r,a][c]}}(t.h,i,a),h=!0,d="hsv"):W(t.h)&&W(t.s)&&W(t.l)&&(i=F(t.s),l=F(t.l),e=function(t,e,r){var i,n,o;function s(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=I(t,360),e=I(e,100),r=I(r,100),0===e)i=n=o=r;else{var a=r<.5?r*(1+e):r+e-r*e,l=2*r-a;i=s(l,a,t+1/3),n=s(l,a,t),o=s(l,a,t-1/3)}return{r:255*i,g:255*n,b:255*o}}(t.h,i,l),h=!0,d="hsl"),t.hasOwnProperty("a")&&(r=t.a));var f,p,g;return r=_(r),{ok:h,format:t.format||d,r:c(255,u(e.r,0)),g:c(255,u(e.g,0)),b:c(255,u(e.b,0)),a:r}}(t);this._originalInput=t,this._r=r.r,this._g=r.g,this._b=r.b,this._a=r.a,this._roundA=l(100*this._a)/100,this._format=e.format||r.format,this._gradientType=e.gradientType,this._r<1&&(this._r=l(this._r)),this._g<1&&(this._g=l(this._g)),this._b<1&&(this._b=l(this._b)),this._ok=r.ok,this._tc_id=a++}function f(t,e,r){t=I(t,255),e=I(e,255),r=I(r,255);var i,n,o=u(t,e,r),s=c(t,e,r),a=(o+s)/2;if(o==s)i=n=0;else{var l=o-s;switch(n=a>.5?l/(2-o-s):l/(o+s),o){case t:i=(e-r)/l+(e<r?6:0);break;case e:i=(r-t)/l+2;break;case r:i=(t-e)/l+4}i/=6}return{h:i,s:n,l:a}}function p(t,e,r){t=I(t,255),e=I(e,255),r=I(r,255);var i,n,o=u(t,e,r),s=c(t,e,r),a=o,l=o-s;if(n=0===o?0:l/o,o==s)i=0;else{switch(o){case t:i=(e-r)/l+(e<r?6:0);break;case e:i=(r-t)/l+2;break;case r:i=(t-e)/l+4}i/=6}return{h:i,s:n,v:a}}function g(t,e,r,i){var n=[N(l(t).toString(16)),N(l(e).toString(16)),N(l(r).toString(16))];return i&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0):n.join("")}function m(t,e,r,i){return[N(B(i)),N(l(t).toString(16)),N(l(e).toString(16)),N(l(r).toString(16))].join("")}function v(t,e){e=0===e?0:e||10;var r=d(t).toHsl();return r.s-=e/100,r.s=M(r.s),d(r)}function y(t,e){e=0===e?0:e||10;var r=d(t).toHsl();return r.s+=e/100,r.s=M(r.s),d(r)}function b(t){return d(t).desaturate(100)}function x(t,e){e=0===e?0:e||10;var r=d(t).toHsl();return r.l+=e/100,r.l=M(r.l),d(r)}function S(t,e){e=0===e?0:e||10;var r=d(t).toRgb();return r.r=u(0,c(255,r.r-l(-e/100*255))),r.g=u(0,c(255,r.g-l(-e/100*255))),r.b=u(0,c(255,r.b-l(-e/100*255))),d(r)}function C(t,e){e=0===e?0:e||10;var r=d(t).toHsl();return r.l-=e/100,r.l=M(r.l),d(r)}function w(t,e){var r=d(t).toHsl(),i=(r.h+e)%360;return r.h=i<0?360+i:i,d(r)}function k(t){var e=d(t).toHsl();return e.h=(e.h+180)%360,d(e)}function E(t){var e=d(t).toHsl(),r=e.h;return[d(t),d({h:(r+120)%360,s:e.s,l:e.l}),d({h:(r+240)%360,s:e.s,l:e.l})]}function T(t){var e=d(t).toHsl(),r=e.h;return[d(t),d({h:(r+90)%360,s:e.s,l:e.l}),d({h:(r+180)%360,s:e.s,l:e.l}),d({h:(r+270)%360,s:e.s,l:e.l})]}function L(t){var e=d(t).toHsl(),r=e.h;return[d(t),d({h:(r+72)%360,s:e.s,l:e.l}),d({h:(r+216)%360,s:e.s,l:e.l})]}function A(t,e,r){e=e||6,r=r||30;var i=d(t).toHsl(),n=360/r,o=[d(t)];for(i.h=(i.h-(n*e>>1)+720)%360;--e;)i.h=(i.h+n)%360,o.push(d(i));return o}function D(t,e){e=e||6;for(var r=d(t).toHsv(),i=r.h,n=r.s,o=r.v,s=[],a=1/e;e--;)s.push(d({h:i,s:n,v:o})),o=(o+a)%1;return s}d.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,r,i=this.toRgb();return t=i.r/255,e=i.g/255,r=i.b/255,.2126*(t<=.03928?t/12.92:n.pow((t+.055)/1.055,2.4))+.7152*(e<=.03928?e/12.92:n.pow((e+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:n.pow((r+.055)/1.055,2.4))},setAlpha:function(t){return this._a=_(t),this._roundA=l(100*this._a)/100,this},toHsv:function(){var t=p(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=p(this._r,this._g,this._b),e=l(360*t.h),r=l(100*t.s),i=l(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+i+"%)":"hsva("+e+", "+r+"%, "+i+"%, "+this._roundA+")"},toHsl:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=f(this._r,this._g,this._b),e=l(360*t.h),r=l(100*t.s),i=l(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+i+"%)":"hsla("+e+", "+r+"%, "+i+"%, "+this._roundA+")"},toHex:function(t){return g(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,i,n){var o=[N(l(t).toString(16)),N(l(e).toString(16)),N(l(r).toString(16)),N(B(i))];if(n&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:l(this._r),g:l(this._g),b:l(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+l(this._r)+", "+l(this._g)+", "+l(this._b)+")":"rgba("+l(this._r)+", "+l(this._g)+", "+l(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:l(100*I(this._r,255))+"%",g:l(100*I(this._g,255))+"%",b:l(100*I(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+l(100*I(this._r,255))+"%, "+l(100*I(this._g,255))+"%, "+l(100*I(this._b,255))+"%)":"rgba("+l(100*I(this._r,255))+"%, "+l(100*I(this._g,255))+"%, "+l(100*I(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(R[g(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+m(this._r,this._g,this._b,this._a),r=e,i=this._gradientType?"GradientType = 1, ":"";if(t){var n=d(t);r="#"+m(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,i=this._a<1&&this._a>=0;return e||!i||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return d(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(x,arguments)},brighten:function(){return this._applyModification(S,arguments)},darken:function(){return this._applyModification(C,arguments)},desaturate:function(){return this._applyModification(v,arguments)},saturate:function(){return this._applyModification(y,arguments)},greyscale:function(){return this._applyModification(b,arguments)},spin:function(){return this._applyModification(w,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(A,arguments)},complement:function(){return this._applyCombination(k,arguments)},monochromatic:function(){return this._applyCombination(D,arguments)},splitcomplement:function(){return this._applyCombination(L,arguments)},triad:function(){return this._applyCombination(E,arguments)},tetrad:function(){return this._applyCombination(T,arguments)}},d.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var i in t)t.hasOwnProperty(i)&&(r[i]="a"===i?t[i]:F(t[i]));t=r}return d(t,e)},d.equals=function(t,e){return!(!t||!e)&&d(t).toRgbString()==d(e).toRgbString()},d.random=function(){return d.fromRatio({r:h(),g:h(),b:h()})},d.mix=function(t,e,r){r=0===r?0:r||50;var i=d(t).toRgb(),n=d(e).toRgb(),o=r/100;return d({r:(n.r-i.r)*o+i.r,g:(n.g-i.g)*o+i.g,b:(n.b-i.b)*o+i.b,a:(n.a-i.a)*o+i.a})},d.readability=function(t,e){var r=d(t),i=d(e);return(n.max(r.getLuminance(),i.getLuminance())+.05)/(n.min(r.getLuminance(),i.getLuminance())+.05)},d.isReadable=function(t,e,r){var i,n,o=d.readability(t,e);switch(n=!1,(i=function(t){var e,r;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==r&&"large"!==r&&(r="small");return{level:e,size:r}}(r)).level+i.size){case"AAsmall":case"AAAlarge":n=o>=4.5;break;case"AAlarge":n=o>=3;break;case"AAAsmall":n=o>=7}return n},d.mostReadable=function(t,e,r){var i,n,o,s,a=null,l=0;n=(r=r||{}).includeFallbackColors,o=r.level,s=r.size;for(var c=0;c<e.length;c++)(i=d.readability(t,e[c]))>l&&(l=i,a=d(e[c]));return d.isReadable(t,a,{level:o,size:s})||!n?a:(r.includeFallbackColors=!1,d.mostReadable(t,["#fff","#000"],r))};var O=d.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},R=d.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(O);function _(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function I(t,e){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var r=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(t);return t=c(e,u(0,parseFloat(t))),r&&(t=parseInt(t*e,10)/100),n.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function M(t){return c(1,u(0,t))}function P(t){return parseInt(t,16)}function N(t){return 1==t.length?"0"+t:""+t}function F(t){return t<=1&&(t=100*t+"%"),t}function B(t){return n.round(255*parseFloat(t)).toString(16)}function j(t){return P(t)/255}var U,H,G,z=(H="[\\s|\\(]+("+(U="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+U+")[,|\\s]+("+U+")\\s*\\)?",G="[\\s|\\(]+("+U+")[,|\\s]+("+U+")[,|\\s]+("+U+")[,|\\s]+("+U+")\\s*\\)?",{CSS_UNIT:new RegExp(U),rgb:new RegExp("rgb"+H),rgba:new RegExp("rgba"+G),hsl:new RegExp("hsl"+H),hsla:new RegExp("hsla"+G),hsv:new RegExp("hsv"+H),hsva:new RegExp("hsva"+G),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function W(t){return!!z.CSS_UNIT.exec(t)}t.exports?t.exports=d:void 0===(i=function(){return d}.call(e,r,e,t))||(t.exports=i)}(Math)},aRTE:
|
|
|
/*!*****************************************************!*\
|
|
|
!*** ./node_modules/qr.js/lib/ErrorCorrectLevel.js ***!
|
|
|
\*****************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e){t.exports={L:1,M:0,Q:3,H:2}},bT9E:
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./node_modules/rc-util/es/omit.js ***!
|
|
|
\*****************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,r){"use strict";r.d(e,"a",(function(){return n}));var i=r(/*! @babel/runtime/helpers/esm/objectSpread2 */"VTBJ");function n(t,e){var r=Object(i.a)({},t);return Array.isArray(e)&&e.forEach((function(t){delete r[t]})),r}},c5Ni:
|
|
|
/*!******************************************************!*\
|
|
|
!*** ./node_modules/codemirror/theme/blackboard.css ***!
|
|
|
\******************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){},dQei:
|
|
|
/*!****************************************!*\
|
|
|
!*** ./node_modules/qr.js/lib/math.js ***!
|
|
|
\****************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e){for(var r={glog:function(t){if(t<1)throw new Error("glog("+t+")");return r.LOG_TABLE[t]},gexp:function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return r.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},i=0;i<8;i++)r.EXP_TABLE[i]=1<<i;for(i=8;i<256;i++)r.EXP_TABLE[i]=r.EXP_TABLE[i-4]^r.EXP_TABLE[i-5]^r.EXP_TABLE[i-6]^r.EXP_TABLE[i-8];for(i=0;i<255;i++)r.LOG_TABLE[r.EXP_TABLE[i]]=i;t.exports=r},dWSS:
|
|
|
/*!**********************************************!*\
|
|
|
!*** ./node_modules/qr.js/lib/Polynomial.js ***!
|
|
|
\**********************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){var i=r(/*! ./math */"dQei");function n(t,e){if(null==t.length)throw new Error(t.length+"/"+e);for(var r=0;r<t.length&&0==t[r];)r++;this.num=new Array(t.length-r+e);for(var i=0;i<t.length-r;i++)this.num[i]=t[i+r]}n.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),r=0;r<this.getLength();r++)for(var o=0;o<t.getLength();o++)e[r+o]^=i.gexp(i.glog(this.get(r))+i.glog(t.get(o)));return new n(e,0)},mod:function(t){if(this.getLength()-t.getLength()<0)return this;for(var e=i.glog(this.get(0))-i.glog(t.get(0)),r=new Array(this.getLength()),o=0;o<this.getLength();o++)r[o]=this.get(o);for(o=0;o<t.getLength();o++)r[o]^=i.gexp(i.glog(t.get(o))+e);return new n(r,0).mod(t)}},t.exports=n},dejd:
|
|
|
/*!***********************************************************!*\
|
|
|
!*** ./src/components/markdown-editor/toolbar/index.less ***!
|
|
|
\***********************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){},dmUQ:
|
|
|
/*!**************************************************************!*\
|
|
|
!*** ./node_modules/rc-input-number/es/index.js + 1 modules ***!
|
|
|
\**************************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createClass.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/defineProperty.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/inherits.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/classnames/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/KeyCode.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */function(t,e,r){"use strict";var i=r("Ff2n"),n=r("rePB"),o=r("1OyB"),s=r("vuIU"),a=r("Ji7U"),l=r("md7G"),c=r("foSv"),u=r("q1tI"),h=r.n(u),d=r("TSYQ"),f=r.n(d),p=r("4IlW");function g(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function m(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?g(Object(r),!0).forEach((function(e){Object(n.a)(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function v(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,i=Object(c.a)(t);if(e){var n=Object(c.a)(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return Object(l.a)(this,r)}}function y(){}function b(t){t.preventDefault()}var x=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,S=function(t){return null!=t},C=function(t,e){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},w=function(t){Object(a.a)(r,t);var e=v(r);function r(t){var i;Object(o.a)(this,r),(i=e.call(this,t)).onKeyDown=function(t){var e=i.props,r=e.onKeyDown,n=e.onPressEnter;if(t.keyCode===p.a.UP){var o=i.getRatio(t);i.up(t,o,null),i.stop()}else if(t.keyCode===p.a.DOWN){var s=i.getRatio(t);i.down(t,s,null),i.stop()}else t.keyCode===p.a.ENTER&&n&&n(t);if(i.recordCursorPosition(),i.lastKeyCode=t.keyCode,r){for(var a=arguments.length,l=new Array(a>1?a-1:0),c=1;c<a;c++)l[c-1]=arguments[c];r.apply(void 0,[t].concat(l))}},i.onKeyUp=function(t){var e=i.props.onKeyUp;if(i.stop(),i.recordCursorPosition(),e){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];e.apply(void 0,[t].concat(n))}},i.onChange=function(t){var e=i.props.onChange;i.state.focused&&(i.inputting=!0),i.rawInput=i.props.parser(i.getValueFromEvent(t)),i.setState({inputValue:i.rawInput}),e(i.toNumber(i.rawInput))},i.onMouseUp=function(){var t=i.props.onMouseUp;i.recordCursorPosition(),t&&t.apply(void 0,arguments)},i.onFocus=function(){var t;i.setState({focused:!0}),(t=i.props).onFocus.apply(t,arguments)},i.onBlur=function(){var t=i.props.onBlur;i.inputting=!1,i.setState({focused:!1});var e=i.getCurrentValidValue(i.state.inputValue),r=i.setValue(e,y);if(t){var n=i.input.value,o=i.getInputDisplayValue({focus:!1,value:r});i.input.value=o?Number(o):o,t.apply(void 0,arguments),i.input.value=n}},i.getRatio=function(t){var e=1;return t.metaKey||t.ctrlKey?e=.1:t.shiftKey&&(e=10),e},i.getFullNum=function(t){return isNaN(t)?t:/e/i.test(String(t))?Number(t).toFixed(18).replace(/\.?0+$/,""):t},i.getPrecision=function(t){if(S(i.props.precision))return i.props.precision;var e=String(t);if(e.indexOf("e-")>=0)return parseInt(e.slice(e.indexOf("e-")+2),10);var r=0;return e.indexOf(".")>=0&&(r=e.length-e.indexOf(".")-1),r},i.getInputDisplayValue=function(t){var e,r=t||i.state,n=r.focused,o=r.inputValue,s=r.value;null==(e=n?o:i.toPrecisionAsStep(s))&&(e="");var a=i.formatWrapper(e);return S(i.props.decimalSeparator)&&(a=a.toString().replace(".",i.props.decimalSeparator)),a},i.recordCursorPosition=function(){try{i.cursorStart=i.input.selectionStart,i.cursorEnd=i.input.selectionEnd,i.currentValue=i.input.value,i.cursorBefore=i.input.value.substring(0,i.cursorStart),i.cursorAfter=i.input.value.substring(i.cursorEnd)}catch(t){}},i.restoreByAfter=function(t){if(void 0===t)return!1;var e=i.input.value,r=e.lastIndexOf(t);if(-1===r)return!1;var n=i.cursorBefore.length;return i.lastKeyCode===p.a.DELETE&&i.cursorBefore.charAt(n-1)===t[0]?(i.fixCaret(n,n),!0):r+t.length===e.length&&(i.fixCaret(r,r),!0)},i.partRestoreByAfter=function(t){return void 0!==t&&Array.prototype.some.call(t,(function(e,r){var n=t.substring(r);return i.restoreByAfter(n)}))},i.isNotCompleteNumber=function(t){return isNaN(t)||""===t||null===t||t&&t.toString().indexOf(".")===t.toString().length-1},i.stop=function(){i.autoStepTimer&&clearTimeout(i.autoStepTimer)},i.down=function(t,e,r){i.pressingUpOrDown=!0,i.step("down",t,e,r)},i.up=function(t,e,r){i.pressingUpOrDown=!0,i.step("up",t,e,r)},i.saveInput=function(t){i.input=t};var n=t.value;void 0===n&&(n=t.defaultValue),i.state={focused:t.autoFocus};var s=i.getValidValue(i.toNumber(n));return i.state=m(m({},i.state),{},{inputValue:i.toPrecisionAsStep(s),value:s}),i}return Object(s.a)(r,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(t){var e=this.props,r=e.value,i=e.onChange,n=e.max,o=e.min,s=this.state.focused;if(t){if(!C(t.value,r)||!C(t.max,n)||!C(t.min,o)){var a,l=s?r:this.getValidValue(r);a=this.pressingUpOrDown?l:this.inputting?this.rawInput:this.toPrecisionAsStep(l),this.setState({value:l,inputValue:a})}var c="value"in this.props?r:this.state.value;"max"in this.props&&t.max!==n&&"number"==typeof c&&c>n&&i&&i(n),"min"in this.props&&t.min!==o&&"number"==typeof c&&c<o&&i&&i(o)}try{if(void 0!==this.cursorStart&&this.state.focused)if(this.partRestoreByAfter(this.cursorAfter)||this.state.value===this.props.value){if(this.currentValue===this.input.value)switch(this.lastKeyCode){case p.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case p.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1)}}else{var u=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===p.a.BACKSPACE?u=this.cursorStart-1:this.lastKeyCode===p.a.DELETE&&(u=this.cursorStart):u=this.input.value.length,this.fixCaret(u,u)}}catch(t){}this.lastKeyCode=null,this.pressingUpOrDown&&this.props.focusOnUpDown&&this.state.focused&&document.activeElement!==this.input&&this.focus()}},{key:"componentWillUnmount",value:function(){this.stop()}},{key:"getCurrentValidValue",value:function(t){var e=t;return e=""===e?"":this.isNotCompleteNumber(parseFloat(e))?this.state.value:this.getValidValue(e),this.toNumber(e)}},{key:"getValueFromEvent",value:function(t){var e=t.target.value.trim().replace(/。/g,".");return S(this.props.decimalSeparator)&&(e=e.replace(this.props.decimalSeparator,".")),e}},{key:"getValidValue",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.props.min,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.props.max,i=parseFloat(t);return isNaN(i)?t:(i<e&&(i=e),i>r&&(i=r),i)}},{key:"setValue",value:function(t,e){var r=this.props.precision,i=this.isNotCompleteNumber(parseFloat(t))?null:parseFloat(t),n=this.state.value,o=void 0===n?null:n,s=this.state.inputValue,a=void 0===s?null:s,l="number"==typeof i?i.toFixed(r):"".concat(i),c=i!==o||l!=="".concat(a);return"value"in this.props?(a=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:a},e)):this.setState({value:i,inputValue:this.toPrecisionAsStep(t)},e),c&&this.props.onChange(i),i}},{key:"getMaxPrecision",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=this.props,i=r.precision,n=r.step;if(S(i))return i;var o=this.getPrecision(e),s=this.getPrecision(n),a=this.getPrecision(t);return t?Math.max(a,o+s):o+s}},{key:"getPrecisionFactor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=this.getMaxPrecision(t,e);return Math.pow(10,r)}},{key:"focus",value:function(){this.input.focus(),this.recordCursorPosition()}},{key:"blur",value:function(){this.input.blur()}},{key:"select",value:function(){this.input.select()}},{key:"formatWrapper",value:function(t){return this.props.formatter?this.props.formatter(t):t}},{key:"toPrecisionAsStep",value:function(t){if(this.isNotCompleteNumber(t)||""===t)return t;var e=Math.abs(this.getMaxPrecision(t));return isNaN(e)?t.toString():Number(t).toFixed(e)}},{key:"toNumber",value:function(t){var e=this.props.precision,r=this.state.focused,i=t&&t.length>16&&r;return this.isNotCompleteNumber(t)||i?t:S(e)?Math.round(t*Math.pow(10,e))/Math.pow(10,e):Number(t)}},{key:"upStep",value:function(t,e){var r=this.props.step,i=this.getPrecisionFactor(t,e),n=Math.abs(this.getMaxPrecision(t,e)),o=((i*t+i*r*e)/i).toFixed(n);return this.toNumber(o)}},{key:"downStep",value:function(t,e){var r=this.props.step,i=this.getPrecisionFactor(t,e),n=Math.abs(this.getMaxPrecision(t,e)),o=((i*t-i*r*e)/i).toFixed(n);return this.toNumber(o)}},{key:"step",value:function(t,e){var r=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3?arguments[3]:void 0;this.stop(),e&&(e.persist(),e.preventDefault());var o=this.props;if(!o.disabled){var s=this.getCurrentValidValue(this.state.inputValue)||0;if(!this.isNotCompleteNumber(s)){var a=this["".concat(t,"Step")](s,i),l=a>o.max||a<o.min;a>o.max?a=o.max:a<o.min&&(a=o.min),this.setValue(a,null),this.setState({focused:!0},(function(){r.pressingUpOrDown=!1})),l||(this.autoStepTimer=setTimeout((function(){r[t](e,i,!0)}),n?200:600))}}}},{key:"fixCaret",value:function(t,e){if(void 0!==t&&void 0!==e&&this.input&&this.input.value)try{var r=this.input.selectionStart,i=this.input.selectionEnd;t===r&&e===i||this.input.setSelectionRange(t,e)}catch(t){}}},{key:"render",value:function(){var t,e=this.props,r=e.prefixCls,o=e.disabled,s=e.readOnly,a=e.useTouch,l=e.autoComplete,c=e.upHandler,u=e.downHandler,d=e.className,p=e.max,g=e.min,m=e.style,v=e.title,x=e.onMouseEnter,S=e.onMouseLeave,C=e.onMouseOver,w=e.onMouseOut,k=e.required,E=e.onClick,T=e.tabIndex,L=e.type,A=e.placeholder,D=e.id,O=e.inputMode,R=e.pattern,_=e.step,I=e.maxLength,M=e.autoFocus,P=e.name,N=e.onPaste,F=e.onInput,B=Object(i.a)(e,["prefixCls","disabled","readOnly","useTouch","autoComplete","upHandler","downHandler","className","max","min","style","title","onMouseEnter","onMouseLeave","onMouseOver","onMouseOut","required","onClick","tabIndex","type","placeholder","id","inputMode","pattern","step","maxLength","autoFocus","name","onPaste","onInput"]),j=this.state,U=j.value,H=j.focused,G=f()(r,(t={},Object(n.a)(t,d,!!d),Object(n.a)(t,"".concat(r,"-disabled"),o),Object(n.a)(t,"".concat(r,"-focused"),H),t)),z={};Object.keys(B).forEach((function(t){"data-"!==t.substr(0,5)&&"aria-"!==t.substr(0,5)&&"role"!==t||(z[t]=B[t])}));var W=!s&&!o,V=this.getInputDisplayValue(null),K=(U||0===U)&&(isNaN(U)||Number(U)>=p)||o||s,q=(U||0===U)&&(isNaN(U)||Number(U)<=g)||o||s,Y=f()("".concat(r,"-handler"),"".concat(r,"-handler-up"),Object(n.a)({},"".concat(r,"-handler-up-disabled"),K)),X=f()("".concat(r,"-handler"),"".concat(r,"-handler-down"),Object(n.a)({},"".concat(r,"-handler-down-disabled"),q)),$=a?{onTouchStart:K?y:this.up,onTouchEnd:this.stop}:{onMouseDown:K?y:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},Z=a?{onTouchStart:q?y:this.down,onTouchEnd:this.stop}:{onMouseDown:q?y:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return h.a.createElement("div",{className:G,style:m,title:v,onMouseEnter:x,onMouseLeave:S,onMouseOver:C,onMouseOut:w,onFocus:function(){return null},onBlur:function(){return null}},h.a.createElement("div",{className:"".concat(r,"-handler-wrap")},h.a.createElement("span",Object.assign({unselectable:"on"},$,{role:"button","aria-label":"Increase Value","aria-disabled":K,className:Y}),c||h.a.createElement("span",{unselectable:"on",className:"".concat(r,"-handler-up-inner"),onClick:b})),h.a.createElement("span",Object.assign({unselectable:"on"},Z,{role:"button","aria-label":"Decrease Value","aria-disabled":q,className:X}),u||h.a.createElement("span",{unselectable:"on",className:"".concat(r,"-handler-down-inner"),onClick:b}))),h.a.createElement("div",{className:"".concat(r,"-input-wrap")},h.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":g,"aria-valuemax":p,"aria-valuenow":U,required:k,type:L,placeholder:A,onPaste:N,onClick:E,onMouseUp:this.onMouseUp,className:"".concat(r,"-input"),tabIndex:T,autoComplete:l,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:W?this.onKeyDown:y,onKeyUp:W?this.onKeyUp:y,autoFocus:M,maxLength:I,readOnly:s,disabled:o,max:p,min:g,step:_,name:P,title:v,id:D,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(V),pattern:R,inputMode:O,onInput:F},z))))}}]),r}(h.a.Component);w.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:x,min:-x,step:1,style:{},onChange:y,onKeyDown:y,onPressEnter:y,onFocus:y,onBlur:y,parser:function(t){return t.replace(/[^\w.-]+/g,"")},required:!1,autoComplete:"off"};var k=w;e.a=k},f4xo:
|
|
|
/*!********************************************!*\
|
|
|
!*** ./node_modules/qr.js/lib/8BitByte.js ***!
|
|
|
\********************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){var i=r(/*! ./mode */"nVVt");function n(t){this.mode=i.MODE_8BIT_BYTE,this.data=t}n.prototype={getLength:function(t){return this.data.length},write:function(t){for(var e=0;e<this.data.length;e++)t.put(this.data.charCodeAt(e),8)}},t.exports=n},h78n:
|
|
|
/*!**********************************************************!*\
|
|
|
!*** ./node_modules/rc-progress/es/index.js + 3 modules ***!
|
|
|
\**********************************************************/
|
|
|
/*! exports provided: Line, Circle, default */
|
|
|
/*! exports used: Circle */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/classnames/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */function(t,e,r){"use strict";r.d(e,"a",(function(){return w}));var i=r("q1tI"),n=r.n(i),o=r("TSYQ"),s=r.n(o),a={className:"",percent:0,prefixCls:"rc-progress",strokeColor:"#2db7f5",strokeLinecap:"round",strokeWidth:1,style:{},trailColor:"#D9D9D9",trailWidth:1},l=function(t){var e=t.map((function(){return Object(i.useRef)()})),r=Object(i.useRef)();return Object(i.useEffect)((function(){var t=Date.now(),i=!1;Object.keys(e).forEach((function(n){var o=e[n].current;if(o){i=!0;var s=o.style;s.transitionDuration=".3s, .3s, .3s, .06s",r.current&&t-r.current<100&&(s.transitionDuration="0s, 0s")}})),i&&(r.current=Date.now())})),[e]};function c(){return(c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function u(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],i=!0,n=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(i=(s=a.next()).done)&&(r.push(s.value),!e||r.length!==e);i=!0);}catch(t){n=!0,o=t}finally{try{i||null==a.return||a.return()}finally{if(n)throw o}}return r}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return h(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}function d(t,e){if(null==t)return{};var r,i,n=function(t,e){if(null==t)return{};var r,i,n={},o=Object.keys(t);for(i=0;i<o.length;i++)r=o[i],e.indexOf(r)>=0||(n[r]=t[r]);return n}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(i=0;i<o.length;i++)r=o[i],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}var f=function(t){var e=t.className,r=t.percent,i=t.prefixCls,o=t.strokeColor,a=t.strokeLinecap,h=t.strokeWidth,f=t.style,p=t.trailColor,g=t.trailWidth,m=t.transition,v=d(t,["className","percent","prefixCls","strokeColor","strokeLinecap","strokeWidth","style","trailColor","trailWidth","transition"]);delete v.gapPosition;var y=Array.isArray(r)?r:[r],b=Array.isArray(o)?o:[o],x=u(l(y),1)[0],S=h/2,C=100-h/2,w="M ".concat("round"===a?S:0,",").concat(S,"\n L ").concat("round"===a?C:100,",").concat(S),k="0 0 100 ".concat(h),E=0;return n.a.createElement("svg",c({className:s()("".concat(i,"-line"),e),viewBox:k,preserveAspectRatio:"none",style:f},v),n.a.createElement("path",{className:"".concat(i,"-line-trail"),d:w,strokeLinecap:a,stroke:p,strokeWidth:g||h,fillOpacity:"0"}),y.map((function(t,e){var r={strokeDasharray:"".concat(t,"px, 100px"),strokeDashoffset:"-".concat(E,"px"),transition:m||"stroke-dashoffset 0.3s ease 0s, stroke-dasharray .3s ease 0s, stroke 0.3s linear"},o=b[e]||b[b.length-1];return E+=t,n.a.createElement("path",{key:e,className:"".concat(i,"-line-path"),d:w,strokeLinecap:a,stroke:o,strokeWidth:h,fillOpacity:"0",ref:x[e],style:r})})))};f.defaultProps=a;function p(){return(p=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function g(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],i=!0,n=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(i=(s=a.next()).done)&&(r.push(s.value),!e||r.length!==e);i=!0);}catch(t){n=!0,o=t}finally{try{i||null==a.return||a.return()}finally{if(n)throw o}}return r}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return m(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}function v(t,e){if(null==t)return{};var r,i,n=function(t,e){if(null==t)return{};var r,i,n={},o=Object.keys(t);for(i=0;i<o.length;i++)r=o[i],e.indexOf(r)>=0||(n[r]=t[r]);return n}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(i=0;i<o.length;i++)r=o[i],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}var y=0;function b(t){return+t.replace("%","")}function x(t){return Array.isArray(t)?t:[t]}function S(t,e,r,i){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5?arguments[5]:void 0,s=50-i/2,a=0,l=-s,c=0,u=-2*s;switch(o){case"left":a=-s,l=0,c=2*s,u=0;break;case"right":a=s,l=0,c=-2*s,u=0;break;case"bottom":l=s,u=2*s}var h="M 50,50 m ".concat(a,",").concat(l,"\n a ").concat(s,",").concat(s," 0 1 1 ").concat(c,",").concat(-u,"\n a ").concat(s,",").concat(s," 0 1 1 ").concat(-c,",").concat(u),d=2*Math.PI*s,f={stroke:r,strokeDasharray:"".concat(e/100*(d-n),"px ").concat(d,"px"),strokeDashoffset:"-".concat(n/2+t/100*(d-n),"px"),transition:"stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s"};return{pathString:h,pathStyle:f}}var C=function(t){var e,r=t.prefixCls,o=t.strokeWidth,a=t.trailWidth,c=t.gapDegree,u=t.gapPosition,h=t.trailColor,d=t.strokeLinecap,f=t.style,m=t.className,C=t.strokeColor,w=t.percent,k=v(t,["prefixCls","strokeWidth","trailWidth","gapDegree","gapPosition","trailColor","strokeLinecap","style","className","strokeColor","percent"]),E=Object(i.useMemo)((function(){return y+=1}),[]),T=S(0,100,h,o,c,u),L=T.pathString,A=T.pathStyle,D=x(w),O=x(C),R=O.find((function(t){return"[object Object]"===Object.prototype.toString.call(t)})),_=g(l(D),1)[0];return n.a.createElement("svg",p({className:s()("".concat(r,"-circle"),m),viewBox:"0 0 100 100",style:f},k),R&&n.a.createElement("defs",null,n.a.createElement("linearGradient",{id:"".concat(r,"-gradient-").concat(E),x1:"100%",y1:"0%",x2:"0%",y2:"0%"},Object.keys(R).sort((function(t,e){return b(t)-b(e)})).map((function(t,e){return n.a.createElement("stop",{key:e,offset:t,stopColor:R[t]})})))),n.a.createElement("path",{className:"".concat(r,"-circle-trail"),d:L,stroke:h,strokeLinecap:d,strokeWidth:a||o,fillOpacity:"0",style:A}),(e=0,D.map((function(t,i){var s=O[i]||O[O.length-1],a="[object Object]"===Object.prototype.toString.call(s)?"url(#".concat(r,"-gradient-").concat(E,")"):"",l=S(e,t,s,o,c,u);return e+=t,n.a.createElement("path",{key:i,className:"".concat(r,"-circle-path"),d:l.pathString,stroke:a,strokeLinecap:d,strokeWidth:o,opacity:0===t?0:1,fillOpacity:"0",style:l.pathStyle,ref:_[i]})}))).reverse())};C.defaultProps=a;var w=C},kSUc:
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./src/components/markdown-editor/index.less ***!
|
|
|
\***************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){},lZu9:
|
|
|
/*!***********************************************************!*\
|
|
|
!*** ./node_modules/codemirror/mode/markdown/markdown.js ***!
|
|
|
\***********************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){!function(t){"use strict";t.defineMode("markdown",(function(e,r){var i=t.getMode(e,"text/html"),n="null"==i.name;void 0===r.highlightFormatting&&(r.highlightFormatting=!1),void 0===r.maxBlockquoteDepth&&(r.maxBlockquoteDepth=0),void 0===r.taskLists&&(r.taskLists=!1),void 0===r.strikethrough&&(r.strikethrough=!1),void 0===r.emoji&&(r.emoji=!1),void 0===r.fencedCodeBlockHighlighting&&(r.fencedCodeBlockHighlighting=!0),void 0===r.fencedCodeBlockDefaultMode&&(r.fencedCodeBlockDefaultMode="text/plain"),void 0===r.xml&&(r.xml=!0),void 0===r.tokenTypeOverrides&&(r.tokenTypeOverrides={});var o={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"image",imageAltText:"image-alt-text",imageMarker:"image-marker",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough",emoji:"builtin"};for(var s in o)o.hasOwnProperty(s)&&r.tokenTypeOverrides[s]&&(o[s]=r.tokenTypeOverrides[s]);var a=/^([*\-_])(?:\s*\1){2,}\s*$/,l=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,c=/^\[(x| )\](?=\s)/i,u=r.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,h=/^ {0,3}(?:\={1,}|-{2,})\s*$/,d=/^[^#!\[\]*_\\<>` "'(~:]+/,f=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,p=/^\s*\[[^\]]+?\]:.*$/,g=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\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]/;function m(t,e,r){return e.f=e.inline=r,r(t,e)}function v(t,e,r){return e.f=e.block=r,r(t,e)}function y(e){if(e.linkTitle=!1,e.linkHref=!1,e.linkText=!1,e.em=!1,e.strong=!1,e.strikethrough=!1,e.quote=0,e.indentedCode=!1,e.f==x){var r=n;if(!r){var o=t.innerMode(i,e.htmlState);r="xml"==o.mode.name&&null===o.state.tagStart&&!o.state.context&&o.state.tokenize.isInText}r&&(e.f=k,e.block=b,e.htmlState=null)}return e.trailingSpace=0,e.trailingSpaceNewLine=!1,e.prevLine=e.thisLine,e.thisLine={stream:null},null}function b(i,n){var s,d=i.column()===n.indentation,g=!(s=n.prevLine.stream)||!/\S/.test(s.string),v=n.indentedCode,y=n.prevLine.hr,b=!1!==n.list,x=(n.listStack[n.listStack.length-1]||0)+3;n.indentedCode=!1;var w=n.indentation;if(null===n.indentationDiff&&(n.indentationDiff=n.indentation,b)){for(n.list=null;w<n.listStack[n.listStack.length-1];)n.listStack.pop(),n.listStack.length?n.indentation=n.listStack[n.listStack.length-1]:n.list=!1;!1!==n.list&&(n.indentationDiff=w-n.listStack[n.listStack.length-1])}var k=!(g||y||n.prevLine.header||b&&v||n.prevLine.fencedCodeEnd),E=(!1===n.list||y||g)&&n.indentation<=x&&i.match(a),T=null;if(n.indentationDiff>=4&&(v||n.prevLine.fencedCodeEnd||n.prevLine.header||g))return i.skipToEnd(),n.indentedCode=!0,o.code;if(i.eatSpace())return null;if(d&&n.indentation<=x&&(T=i.match(u))&&T[1].length<=6)return n.quote=0,n.header=T[1].length,n.thisLine.header=!0,r.highlightFormatting&&(n.formatting="header"),n.f=n.inline,C(n);if(n.indentation<=x&&i.eat(">"))return n.quote=d?1:n.quote+1,r.highlightFormatting&&(n.formatting="quote"),i.eatSpace(),C(n);if(!E&&!n.setext&&d&&n.indentation<=x&&(T=i.match(l))){var L=T[1]?"ol":"ul";return n.indentation=w+i.current().length,n.list=!0,n.quote=0,n.listStack.push(n.indentation),n.em=!1,n.strong=!1,n.code=!1,n.strikethrough=!1,r.taskLists&&i.match(c,!1)&&(n.taskList=!0),n.f=n.inline,r.highlightFormatting&&(n.formatting=["list","list-"+L]),C(n)}return d&&n.indentation<=x&&(T=i.match(f,!0))?(n.quote=0,n.fencedEndRE=new RegExp(T[1]+"+ *$"),n.localMode=r.fencedCodeBlockHighlighting&&function(r){if(t.findModeByName){var i=t.findModeByName(r);i&&(r=i.mime||i.mimes[0])}var n=t.getMode(e,r);return"null"==n.name?null:n}(T[2]||r.fencedCodeBlockDefaultMode),n.localMode&&(n.localState=t.startState(n.localMode)),n.f=n.block=S,r.highlightFormatting&&(n.formatting="code-block"),n.code=-1,C(n)):n.setext||!(k&&b||n.quote||!1!==n.list||n.code||E||p.test(i.string))&&(T=i.lookAhead(1))&&(T=T.match(h))?(n.setext?(n.header=n.setext,n.setext=0,i.skipToEnd(),r.highlightFormatting&&(n.formatting="header")):(n.header="="==T[0].charAt(0)?1:2,n.setext=n.header),n.thisLine.header=!0,n.f=n.inline,C(n)):E?(i.skipToEnd(),n.hr=!0,n.thisLine.hr=!0,o.hr):"["===i.peek()?m(i,n,A):m(i,n,n.inline)}function x(e,r){var o=i.token(e,r.htmlState);if(!n){var s=t.innerMode(i,r.htmlState);("xml"==s.mode.name&&null===s.state.tagStart&&!s.state.context&&s.state.tokenize.isInText||r.md_inside&&e.current().indexOf(">")>-1)&&(r.f=k,r.block=b,r.htmlState=null)}return o}function S(t,e){var i,n=e.listStack[e.listStack.length-1]||0,s=e.indentation<n,a=n+3;return e.fencedEndRE&&e.indentation<=a&&(s||t.match(e.fencedEndRE))?(r.highlightFormatting&&(e.formatting="code-block"),s||(i=C(e)),e.localMode=e.localState=null,e.block=b,e.f=k,e.fencedEndRE=null,e.code=0,e.thisLine.fencedCodeEnd=!0,s?v(t,e,e.block):i):e.localMode?e.localMode.token(t,e.localState):(t.skipToEnd(),o.code)}function C(t){var e=[];if(t.formatting){e.push(o.formatting),"string"==typeof t.formatting&&(t.formatting=[t.formatting]);for(var i=0;i<t.formatting.length;i++)e.push(o.formatting+"-"+t.formatting[i]),"header"===t.formatting[i]&&e.push(o.formatting+"-"+t.formatting[i]+"-"+t.header),"quote"===t.formatting[i]&&(!r.maxBlockquoteDepth||r.maxBlockquoteDepth>=t.quote?e.push(o.formatting+"-"+t.formatting[i]+"-"+t.quote):e.push("error"))}if(t.taskOpen)return e.push("meta"),e.length?e.join(" "):null;if(t.taskClosed)return e.push("property"),e.length?e.join(" "):null;if(t.linkHref?e.push(o.linkHref,"url"):(t.strong&&e.push(o.strong),t.em&&e.push(o.em),t.strikethrough&&e.push(o.strikethrough),t.emoji&&e.push(o.emoji),t.linkText&&e.push(o.linkText),t.code&&e.push(o.code),t.image&&e.push(o.image),t.imageAltText&&e.push(o.imageAltText,"link"),t.imageMarker&&e.push(o.imageMarker)),t.header&&e.push(o.header,o.header+"-"+t.header),t.quote&&(e.push(o.quote),!r.maxBlockquoteDepth||r.maxBlockquoteDepth>=t.quote?e.push(o.quote+"-"+t.quote):e.push(o.quote+"-"+r.maxBlockquoteDepth)),!1!==t.list){var n=(t.listStack.length-1)%3;n?1===n?e.push(o.list2):e.push(o.list3):e.push(o.list1)}return t.trailingSpaceNewLine?e.push("trailing-space-new-line"):t.trailingSpace&&e.push("trailing-space-"+(t.trailingSpace%2?"a":"b")),e.length?e.join(" "):null}function w(t,e){if(t.match(d,!0))return C(e)}function k(e,n){var s=n.text(e,n);if(void 0!==s)return s;if(n.list)return n.list=null,C(n);if(n.taskList)return" "===e.match(c,!0)[1]?n.taskOpen=!0:n.taskClosed=!0,r.highlightFormatting&&(n.formatting="task"),n.taskList=!1,C(n);if(n.taskOpen=!1,n.taskClosed=!1,n.header&&e.match(/^#+$/,!0))return r.highlightFormatting&&(n.formatting="header"),C(n);var a=e.next();if(n.linkTitle){n.linkTitle=!1;var l=a;"("===a&&(l=")");var u="^\\s*(?:[^"+(l=(l+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1"))+"\\\\]+|\\\\\\\\|\\\\.)"+l;if(e.match(new RegExp(u),!0))return o.linkHref}if("`"===a){var h=n.formatting;r.highlightFormatting&&(n.formatting="code"),e.eatWhile("`");var d=e.current().length;if(0!=n.code||n.quote&&1!=d){if(d==n.code){var f=C(n);return n.code=0,f}return n.formatting=h,C(n)}return n.code=d,C(n)}if(n.code)return C(n);if("\\"===a&&(e.next(),r.highlightFormatting)){var p=C(n),m=o.formatting+"-escape";return p?p+" "+m:m}if("!"===a&&e.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return n.imageMarker=!0,n.image=!0,r.highlightFormatting&&(n.formatting="image"),C(n);if("["===a&&n.imageMarker&&e.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return n.imageMarker=!1,n.imageAltText=!0,r.highlightFormatting&&(n.formatting="image"),C(n);if("]"===a&&n.imageAltText){r.highlightFormatting&&(n.formatting="image");var p=C(n);return n.imageAltText=!1,n.image=!1,n.inline=n.f=T,p}if("["===a&&!n.image)return n.linkText&&e.match(/^.*?\]/)||(n.linkText=!0,r.highlightFormatting&&(n.formatting="link")),C(n);if("]"===a&&n.linkText){r.highlightFormatting&&(n.formatting="link");var p=C(n);return n.linkText=!1,n.inline=n.f=e.match(/\(.*?\)| ?\[.*?\]/,!1)?T:k,p}if("<"===a&&e.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1))return n.f=n.inline=E,r.highlightFormatting&&(n.formatting="link"),(p=C(n))?p+=" ":p="",p+o.linkInline;if("<"===a&&e.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1))return n.f=n.inline=E,r.highlightFormatting&&(n.formatting="link"),(p=C(n))?p+=" ":p="",p+o.linkEmail;if(r.xml&&"<"===a&&e.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var y=e.string.indexOf(">",e.pos);if(-1!=y){var b=e.string.substring(e.start,y);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(b)&&(n.md_inside=!0)}return e.backUp(1),n.htmlState=t.startState(i),v(e,n,x)}if(r.xml&&"<"===a&&e.match(/^\/\w*?>/))return n.md_inside=!1,"tag";if("*"===a||"_"===a){for(var S=1,w=1==e.pos?" ":e.string.charAt(e.pos-2);S<3&&e.eat(a);)S++;var L=e.peek()||" ",A=!/\s/.test(L)&&(!g.test(L)||/\s/.test(w)||g.test(w)),D=!/\s/.test(w)&&(!g.test(w)||/\s/.test(L)||g.test(L)),O=null,R=null;if(S%2&&(n.em||!A||"*"!==a&&D&&!g.test(w)?n.em!=a||!D||"*"!==a&&A&&!g.test(L)||(O=!1):O=!0),S>1&&(n.strong||!A||"*"!==a&&D&&!g.test(w)?n.strong!=a||!D||"*"!==a&&A&&!g.test(L)||(R=!1):R=!0),null!=R||null!=O)return r.highlightFormatting&&(n.formatting=null==O?"strong":null==R?"em":"strong em"),!0===O&&(n.em=a),!0===R&&(n.strong=a),f=C(n),!1===O&&(n.em=!1),!1===R&&(n.strong=!1),f}else if(" "===a&&(e.eat("*")||e.eat("_"))){if(" "===e.peek())return C(n);e.backUp(1)}if(r.strikethrough)if("~"===a&&e.eatWhile(a)){if(n.strikethrough)return r.highlightFormatting&&(n.formatting="strikethrough"),f=C(n),n.strikethrough=!1,f;if(e.match(/^[^\s]/,!1))return n.strikethrough=!0,r.highlightFormatting&&(n.formatting="strikethrough"),C(n)}else if(" "===a&&e.match(/^~~/,!0)){if(" "===e.peek())return C(n);e.backUp(2)}if(r.emoji&&":"===a&&e.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){n.emoji=!0,r.highlightFormatting&&(n.formatting="emoji");var _=C(n);return n.emoji=!1,_}return" "===a&&(e.match(/^ +$/,!1)?n.trailingSpace++:n.trailingSpace&&(n.trailingSpaceNewLine=!0)),C(n)}function E(t,e){if(">"===t.next()){e.f=e.inline=k,r.highlightFormatting&&(e.formatting="link");var i=C(e);return i?i+=" ":i="",i+o.linkInline}return t.match(/^[^>]+/,!0),o.linkInline}function T(t,e){if(t.eatSpace())return null;var i,n=t.next();return"("===n||"["===n?(e.f=e.inline=(i="("===n?")":"]",function(t,e){if(t.next()===i){e.f=e.inline=k,r.highlightFormatting&&(e.formatting="link-string");var n=C(e);return e.linkHref=!1,n}return t.match(L[i]),e.linkHref=!0,C(e)}),r.highlightFormatting&&(e.formatting="link-string"),e.linkHref=!0,C(e)):"error"}var L={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function A(t,e){return t.match(/^([^\]\\]|\\.)*\]:/,!1)?(e.f=D,t.next(),r.highlightFormatting&&(e.formatting="link"),e.linkText=!0,C(e)):m(t,e,k)}function D(t,e){if(t.match(/^\]:/,!0)){e.f=e.inline=O,r.highlightFormatting&&(e.formatting="link");var i=C(e);return e.linkText=!1,i}return t.match(/^([^\]\\]|\\.)+/,!0),o.linkText}function O(t,e){return t.eatSpace()?null:(t.match(/^[^\s]+/,!0),void 0===t.peek()?e.linkTitle=!0:t.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),e.f=e.inline=k,o.linkHref+" url")}var R={startState:function(){return{f:b,prevLine:{stream:null},thisLine:{stream:null},block:b,htmlState:null,indentation:0,inline:k,text:w,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(e){return{f:e.f,prevLine:e.prevLine,thisLine:e.thisLine,block:e.block,htmlState:e.htmlState&&t.copyState(i,e.htmlState),indentation:e.indentation,localMode:e.localMode,localState:e.localMode?t.copyState(e.localMode,e.localState):null,inline:e.inline,text:e.text,formatting:!1,linkText:e.linkText,linkTitle:e.linkTitle,linkHref:e.linkHref,code:e.code,em:e.em,strong:e.strong,strikethrough:e.strikethrough,emoji:e.emoji,header:e.header,setext:e.setext,hr:e.hr,taskList:e.taskList,list:e.list,listStack:e.listStack.slice(0),quote:e.quote,indentedCode:e.indentedCode,trailingSpace:e.trailingSpace,trailingSpaceNewLine:e.trailingSpaceNewLine,md_inside:e.md_inside,fencedEndRE:e.fencedEndRE}},token:function(t,e){if(e.formatting=!1,t!=e.thisLine.stream){if(e.header=0,e.hr=!1,t.match(/^\s*$/,!0))return y(e),null;if(e.prevLine=e.thisLine,e.thisLine={stream:t},e.taskList=!1,e.trailingSpace=0,e.trailingSpaceNewLine=!1,!e.localState&&(e.f=e.block,e.f!=x)){var r=t.match(/^\s*/,!0)[0].replace(/\t/g," ").length;if(e.indentation=r,e.indentationDiff=null,r>0)return null}}return e.f(t,e)},innerMode:function(t){return t.block==x?{state:t.htmlState,mode:i}:t.localState?{state:t.localState,mode:t.localMode}:{state:t,mode:R}},indent:function(e,r,n){return e.block==x&&i.indent?i.indent(e.htmlState,r,n):e.localState&&e.localMode.indent?e.localMode.indent(e.localState,r,n):t.Pass},blankLine:y,getType:C,blockCommentStart:"\x3c!--",blockCommentEnd:"--\x3e",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return R}),"xml"),t.defineMIME("text/markdown","markdown"),t.defineMIME("text/x-markdown","markdown")}(r(/*! ../../lib/codemirror */"VrN/"),r(/*! ../xml/xml */"1eCo"),r(/*! ../meta */"8EBN"))},nVVt:
|
|
|
/*!****************************************!*\
|
|
|
!*** ./node_modules/qr.js/lib/mode.js ***!
|
|
|
\****************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e){t.exports={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8}},osHv:
|
|
|
/*!********************************************************!*\
|
|
|
!*** ./node_modules/codemirror/addon/fold/xml-fold.js ***!
|
|
|
\********************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){!function(t){"use strict";var e=t.Pos;function r(t,e){return t.line-e.line||t.ch-e.ch}var i="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=new RegExp("<(/?)(["+i+"]["+i+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*)","g");function o(t,e,r,i){this.line=e,this.ch=r,this.cm=t,this.text=t.getLine(e),this.min=i?Math.max(i.from,t.firstLine()):t.firstLine(),this.max=i?Math.min(i.to-1,t.lastLine()):t.lastLine()}function s(t,r){var i=t.cm.getTokenTypeAt(e(t.line,r));return i&&/\btag\b/.test(i)}function a(t){if(!(t.line>=t.max))return t.ch=0,t.text=t.cm.getLine(++t.line),!0}function l(t){if(!(t.line<=t.min))return t.text=t.cm.getLine(--t.line),t.ch=t.text.length,!0}function c(t){for(;;){var e=t.text.indexOf(">",t.ch);if(-1==e){if(a(t))continue;return}if(s(t,e+1)){var r=t.text.lastIndexOf("/",e),i=r>-1&&!/\S/.test(t.text.slice(r+1,e));return t.ch=e+1,i?"selfClose":"regular"}t.ch=e+1}}function u(t){for(;;){var e=t.ch?t.text.lastIndexOf("<",t.ch-1):-1;if(-1==e){if(l(t))continue;return}if(s(t,e+1)){n.lastIndex=e,t.ch=e;var r=n.exec(t.text);if(r&&r.index==e)return r}else t.ch=e}}function h(t){for(;;){n.lastIndex=t.ch;var e=n.exec(t.text);if(!e){if(a(t))continue;return}if(s(t,e.index+1))return t.ch=e.index+e[0].length,e;t.ch=e.index+1}}function d(t){for(;;){var e=t.ch?t.text.lastIndexOf(">",t.ch-1):-1;if(-1==e){if(l(t))continue;return}if(s(t,e+1)){var r=t.text.lastIndexOf("/",e),i=r>-1&&!/\S/.test(t.text.slice(r+1,e));return t.ch=e+1,i?"selfClose":"regular"}t.ch=e}}function f(t,r){for(var i=[];;){var n,o=h(t),s=t.line,a=t.ch-(o?o[0].length:0);if(!o||!(n=c(t)))return;if("selfClose"!=n)if(o[1]){for(var l=i.length-1;l>=0;--l)if(i[l]==o[2]){i.length=l;break}if(l<0&&(!r||r==o[2]))return{tag:o[2],from:e(s,a),to:e(t.line,t.ch)}}else i.push(o[2])}}function p(t,r){for(var i=[];;){var n=d(t);if(!n)return;if("selfClose"!=n){var o=t.line,s=t.ch,a=u(t);if(!a)return;if(a[1])i.push(a[2]);else{for(var l=i.length-1;l>=0;--l)if(i[l]==a[2]){i.length=l;break}if(l<0&&(!r||r==a[2]))return{tag:a[2],from:e(t.line,t.ch),to:e(o,s)}}}else u(t)}}t.registerHelper("fold","xml",(function(t,i){for(var n=new o(t,i.line,0);;){var s=h(n);if(!s||n.line!=i.line)return;var a=c(n);if(!a)return;if(!s[1]&&"selfClose"!=a){var l=e(n.line,n.ch),u=f(n,s[2]);return u&&r(u.from,l)>0?{from:l,to:u.from}:null}}})),t.findMatchingTag=function(t,i,n){var s=new o(t,i.line,i.ch,n);if(-1!=s.text.indexOf(">")||-1!=s.text.indexOf("<")){var a=c(s),l=a&&e(s.line,s.ch),h=a&&u(s);if(a&&h&&!(r(s,i)>0)){var d={from:e(s.line,s.ch),to:l,tag:h[2]};return"selfClose"==a?{open:d,close:null,at:"open"}:h[1]?{open:p(s,h[2]),close:d,at:"close"}:{open:d,close:f(s=new o(t,l.line,l.ch,n),h[2]),at:"open"}}}},t.findEnclosingTag=function(t,e,r,i){for(var n=new o(t,e.line,e.ch,r);;){var s=p(n,i);if(!s)break;var a=f(new o(t,e.line,e.ch,r),s.tag);if(a)return{open:s,close:a}}},t.scanForClosingTag=function(t,e,r,i){return f(new o(t,e.line,e.ch,i?{from:0,to:i}:null),r)}}(r(/*! ../../lib/codemirror */"VrN/"))},p5ED:
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./src/components/PreviewAll/index.tsx ***!
|
|
|
\*********************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,r){"use strict";r(/*! antd/es/button/style */"+L6B");var i=r(/*! antd/es/button */"2/Rp"),n=(r(/*! antd/es/tooltip/style */"5Dmo"),r(/*! antd/es/tooltip */"3S7+")),o=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2 */"k1fw"),s=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray */"tJVT"),a=r(/*! react */"q1tI"),l=r.n(a),c=r(/*! ./index.less?modules */"vHTk"),u=r.n(c),h=r(/*! @ant-design/icons */"yEEn"),d=r(/*! @/components/monaco-editor */"ZW9T"),f=r(/*! @/utils/util */"1vsH");e.a=function(t){var e=t.name,r=t.data,c=(t.theme,t.type),p=t.filename,g=t.monacoEditor,m=t.className,v=t.style,y=t.close,b=t.onClose,x=t.hasMask,S=Object(a.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),C=Object(s.a)(S,2),w=(C[0],C[1],Object(a.useState)("")),k=Object(s.a)(w,2),E=(k[0],k[1]),T=Object(a.useRef)();p&&(g.filename=p),Object(a.useEffect)((function(){var t,e,r=null===(t=document.cookie)||void 0===t||null===(e=t.replace(/\s/g,""))||void 0===e?void 0:e.split(";");null==r||r.map((function(t){var e=t.split("=");"_educoder_session"===e[0]&&E(e[1])}))}),[]);var L=function(){r.startsWith("http")||r.startsWith("/")?A():Object(f.x)(p||"educoder",r,p)},A=function(){Object(f.v)(p||e,r)};return console.log("data:",r,"fileanme:",p," name:",e),l.a.createElement("div",{style:Object(o.a)({},v||{}),className:"".concat(x&&u.a.bgBlack," ").concat(c?u.a.wrp:"hide")},y&&l.a.createElement("div",{className:u.a.close,ref:T},l.a.createElement(n.a,{title:"点击下载此文件",getPopupContainer:function(){return T.current}},l.a.createElement("span",{onClick:A},l.a.createElement("i",{className:"icon-quxiaozhiding"}))),l.a.createElement(n.a,{title:"关闭",getPopupContainer:function(){return T.current}},l.a.createElement("span",{className:"",onClick:b},l.a.createElement("i",{className:"icon-guanbi1"})))),l.a.createElement("div",{className:"".concat(u.a[m]," ").concat(m," ").concat(u.a.monaco," ").concat("txt"===c?"show":"hide")},"txt"===c&&l.a.createElement(d.b,g)),"audio"===c&&l.a.createElement("audio",{src:"".concat(null!=r&&r.startsWith("/")||(null==r?void 0:r.indexOf("https://"))>-1?r:"data:audio/mp3;base64,").concat(r),autoPlay:!0}),"video"===c&&l.a.createElement(l.a.Fragment,null,null!=r&&r.startsWith("/")?l.a.createElement("video",{controls:!0,src:"".concat(r),autoPlay:!0}):l.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(r),autoPlay:!0})),"html"===c&&l.a.createElement("iframe",{src:r+"&disposition=inline"}),"pdf"===c&&l.a.createElement("embed",{className:u.a.embed,src:r}),"pdfeditor"===c&&l.a.createElement("div",null,l.a.createElement("iframe",{src:"https://a1office.co/solutions/editor/pdf-editor/查重文档1-8839d79b81e8bda0d298ca058913ab88.pdf"}),l.a.createElement("div",{style:{position:"absolute",left:"1px",top:"1px",width:180,height:60,background:"#f9f9f9"}})),"image"===c&&l.a.createElement(l.a.Fragment,null,l.a.createElement("img",{src:"".concat(null!=r&&r.startsWith("/")||(null==r?void 0:r.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(r)})),"other"===c&&l.a.createElement("div",null,l.a.createElement(i.a,{type:"primary",size:"large",onClick:L},l.a.createElement(h.a,null),"点击下载")),("download"===c||"office"===c)&&l.a.createElement(i.a,{type:"primary",size:"large",onClick:L},l.a.createElement(h.a,null),"点击下载"))}},"p77/":
|
|
|
/*!****************************************************!*\
|
|
|
!*** ./node_modules/codemirror/lib/codemirror.css ***!
|
|
|
\****************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){},"rAM+":
|
|
|
/*!*******************************************************************************************************************!*\
|
|
|
!*** ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js ***!
|
|
|
\*******************************************************************************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,r){"use strict";r.d(e,"a",(function(){return n}));var i=r(/*! @babel/runtime/helpers/esm/unsupportedIterableToArray */"Qw5x");function n(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=Object(i.a)(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,l=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return a=t.done,t},e:function(t){l=!0,s=t},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw s}}}}},rUJ1:
|
|
|
/*!********************************************!*\
|
|
|
!*** ./node_modules/marked/src/helpers.js ***!
|
|
|
\********************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: escape */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e){const r=/[&<>"']/,i=/[&<>"']/g,n=/[<>"']|&(?!#?\w+;)/,o=/[<>"']|&(?!#?\w+;)/g,s={"&":"&","<":"<",">":">",'"':""","'":"'"},a=t=>s[t];const l=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function c(t){return t.replace(l,(t,e)=>"colon"===(e=e.toLowerCase())?":":"#"===e.charAt(0)?"x"===e.charAt(1)?String.fromCharCode(parseInt(e.substring(2),16)):String.fromCharCode(+e.substring(1)):"")}const u=/(^|[^\[])\^/g;const h=/[^\w:]/g,d=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;const f={},p=/^[^:]+:\/*[^/]*$/,g=/^([^:]+:)[\s\S]*$/,m=/^([^:]+:\/*[^/]*)[\s\S]*$/;function v(t,e){f[" "+t]||(p.test(t)?f[" "+t]=t+"/":f[" "+t]=y(t,"/",!0));const r=-1===(t=f[" "+t]).indexOf(":");return"//"===e.substring(0,2)?r?e:t.replace(g,"$1")+e:"/"===e.charAt(0)?r?e:t.replace(m,"$1")+e:t+e}function y(t,e,r){const i=t.length;if(0===i)return"";let n=0;for(;n<i;){const o=t.charAt(i-n-1);if(o!==e||r){if(o===e||!r)break;n++}else n++}return t.substr(0,i-n)}t.exports={escape:function(t,e){if(e){if(r.test(t))return t.replace(i,a)}else if(n.test(t))return t.replace(o,a);return t},unescape:c,edit:function(t,e){t=t.source||t,e=e||"";const r={replace:(e,i)=>(i=(i=i.source||i).replace(u,"$1"),t=t.replace(e,i),r),getRegex:()=>new RegExp(t,e)};return r},cleanUrl:function(t,e,r){if(t){let t;try{t=decodeURIComponent(c(r)).replace(h,"").toLowerCase()}catch(t){return null}if(0===t.indexOf("javascript:")||0===t.indexOf("vbscript:")||0===t.indexOf("data:"))return null}e&&!d.test(r)&&(r=v(e,r));try{r=encodeURI(r).replace(/%25/g,"%")}catch(t){return null}return r},resolveUrl:v,noopTest:{exec:function(){}},merge:function(t){let e,r,i=1;for(;i<arguments.length;i++)for(r in e=arguments[i],e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},splitCells:function(t,e){const r=t.replace(/\|/g,(t,e,r)=>{let i=!1,n=e;for(;--n>=0&&"\\"===r[n];)i=!i;return i?"|":" |"}).split(/ \|/);let i=0;if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(/\\\|/g,"|");return r},rtrim:y,findClosingBracket:function(t,e){if(-1===t.indexOf(e[1]))return-1;const r=t.length;let i=0,n=0;for(;n<r;n++)if("\\"===t[n])n++;else if(t[n]===e[0])i++;else if(t[n]===e[1]&&(i--,i<0))return n;return-1},checkSanitizeDeprecation:function(t){t&&t.sanitize&&!t.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}}},rcnY:
|
|
|
/*!*******************************************!*\
|
|
|
!*** ./node_modules/qr.js/lib/RSBlock.js ***!
|
|
|
\*******************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){var i=r(/*! ./ErrorCorrectLevel */"aRTE");function n(t,e){this.totalCount=t,this.dataCount=e}n.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],n.getRSBlocks=function(t,e){var r=n.getRsBlockTable(t,e);if(null==r)throw new Error("bad rs block @ typeNumber:"+t+"/errorCorrectLevel:"+e);for(var i=r.length/3,o=new Array,s=0;s<i;s++)for(var a=r[3*s+0],l=r[3*s+1],c=r[3*s+2],u=0;u<a;u++)o.push(new n(l,c));return o},n.getRsBlockTable=function(t,e){switch(e){case i.L:return n.RS_BLOCK_TABLE[4*(t-1)+0];case i.M:return n.RS_BLOCK_TABLE[4*(t-1)+1];case i.Q:return n.RS_BLOCK_TABLE[4*(t-1)+2];case i.H:return n.RS_BLOCK_TABLE[4*(t-1)+3];default:return}},t.exports=n},ulZh:
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./node_modules/hls.js/dist/hls.js ***!
|
|
|
\*****************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){var i;"undefined"!=typeof window&&(i=function(){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(i,n,function(e){return t[e]}.bind(null,n));return i},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/dist/",r(r.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./node_modules/eventemitter3/index.js ***!
|
|
|
\*********************************************/
|
|
|
/*! no static exports found */function(t,e,r){"use strict";var i=Object.prototype.hasOwnProperty,n="~";function o(){}function s(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function a(t,e,r,i,o){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new s(r,i||t,o),l=n?n+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],a]:t._events[l].push(a):(t._events[l]=a,t._eventsCount++),t}function l(t,e){0==--t._eventsCount?t._events=new o:delete t._events[e]}function c(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(n=!1)),c.prototype.eventNames=function(){var t,e,r=[];if(0===this._eventsCount)return r;for(e in t=this._events)i.call(t,e)&&r.push(n?e.slice(1):e);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},c.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,s=new Array(o);i<o;i++)s[i]=r[i].fn;return s},c.prototype.listenerCount=function(t){var e=n?n+t:t,r=this._events[e];return r?r.fn?1:r.length:0},c.prototype.emit=function(t,e,r,i,o,s){var a=n?n+t:t;if(!this._events[a])return!1;var l,c,u=this._events[a],h=arguments.length;if(u.fn){switch(u.once&&this.removeListener(t,u.fn,void 0,!0),h){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,e),!0;case 3:return u.fn.call(u.context,e,r),!0;case 4:return u.fn.call(u.context,e,r,i),!0;case 5:return u.fn.call(u.context,e,r,i,o),!0;case 6:return u.fn.call(u.context,e,r,i,o,s),!0}for(c=1,l=new Array(h-1);c<h;c++)l[c-1]=arguments[c];u.fn.apply(u.context,l)}else{var d,f=u.length;for(c=0;c<f;c++)switch(u[c].once&&this.removeListener(t,u[c].fn,void 0,!0),h){case 1:u[c].fn.call(u[c].context);break;case 2:u[c].fn.call(u[c].context,e);break;case 3:u[c].fn.call(u[c].context,e,r);break;case 4:u[c].fn.call(u[c].context,e,r,i);break;default:if(!l)for(d=1,l=new Array(h-1);d<h;d++)l[d-1]=arguments[d];u[c].fn.apply(u[c].context,l)}}return!0},c.prototype.on=function(t,e,r){return a(this,t,e,r,!1)},c.prototype.once=function(t,e,r){return a(this,t,e,r,!0)},c.prototype.removeListener=function(t,e,r,i){var o=n?n+t:t;if(!this._events[o])return this;if(!e)return l(this,o),this;var s=this._events[o];if(s.fn)s.fn!==e||i&&!s.once||r&&s.context!==r||l(this,o);else{for(var a=0,c=[],u=s.length;a<u;a++)(s[a].fn!==e||i&&!s[a].once||r&&s[a].context!==r)&&c.push(s[a]);c.length?this._events[o]=1===c.length?c[0]:c:l(this,o)}return this},c.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&l(this,e)):(this._events=new o,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,t.exports=c},"./node_modules/url-toolkit/src/url-toolkit.js":
|
|
|
/*!*****************************************************!*\
|
|
|
!*** ./node_modules/url-toolkit/src/url-toolkit.js ***!
|
|
|
\*****************************************************/
|
|
|
/*! no static exports found */function(t,e,r){var i,n,o,s,a;i=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,n=/^([^\/?#]*)([^]*)$/,o=/(?:\/|^)\.(?=\/)/g,s=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(t,e,r){if(r=r||{},t=t.trim(),!(e=e.trim())){if(!r.alwaysNormalize)return t;var i=a.parseURL(t);if(!i)throw new Error("Error trying to parse base URL.");return i.path=a.normalizePath(i.path),a.buildURLFromParts(i)}var o=a.parseURL(e);if(!o)throw new Error("Error trying to parse relative URL.");if(o.scheme)return r.alwaysNormalize?(o.path=a.normalizePath(o.path),a.buildURLFromParts(o)):e;var s=a.parseURL(t);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var l=n.exec(s.path);s.netLoc=l[1],s.path=l[2]}s.netLoc&&!s.path&&(s.path="/");var c={scheme:s.scheme,netLoc:o.netLoc,path:null,params:o.params,query:o.query,fragment:o.fragment};if(!o.netLoc&&(c.netLoc=s.netLoc,"/"!==o.path[0]))if(o.path){var u=s.path,h=u.substring(0,u.lastIndexOf("/")+1)+o.path;c.path=a.normalizePath(h)}else c.path=s.path,o.params||(c.params=s.params,o.query||(c.query=s.query));return null===c.path&&(c.path=r.alwaysNormalize?a.normalizePath(o.path):o.path),a.buildURLFromParts(c)},parseURL:function(t){var e=i.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(o,"");t.length!==(t=t.replace(s,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}},t.exports=a},"./node_modules/webworkify-webpack/index.js":
|
|
|
/*!**************************************************!*\
|
|
|
!*** ./node_modules/webworkify-webpack/index.js ***!
|
|
|
\**************************************************/
|
|
|
/*! no static exports found */function(t,e,r){function i(t){var e={};function r(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},r.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/",r.oe=function(t){throw console.error(t),t};var i=r(r.s=ENTRY_MODULE);return i.default||i}function n(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function o(t,e,i){var o={};o[i]=[];var s=e.toString(),a=s.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!a)return o;for(var l,c=a[1],u=new RegExp("(\\\\n|\\W)"+n(c)+"\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g");l=u.exec(s);)"dll-reference"!==l[3]&&o[i].push(l[3]);for(u=new RegExp("\\("+n(c)+'\\("(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))"\\)\\)\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)',"g");l=u.exec(s);)t[l[2]]||(o[i].push(l[1]),t[l[2]]=r(l[1]).m),o[l[2]]=o[l[2]]||[],o[l[2]].push(l[4]);for(var h,d=Object.keys(o),f=0;f<d.length;f++)for(var p=0;p<o[d[f]].length;p++)h=o[d[f]][p],isNaN(1*h)||(o[d[f]][p]=1*o[d[f]][p]);return o}function s(t){return Object.keys(t).reduce((function(e,r){return e||t[r].length>0}),!1)}t.exports=function(t,e){e=e||{};var n={main:r.m},a=e.all?{main:Object.keys(n.main)}:function(t,e){for(var r={main:[e]},i={main:[]},n={main:{}};s(r);)for(var a=Object.keys(r),l=0;l<a.length;l++){var c=a[l],u=r[c].pop();if(n[c]=n[c]||{},!n[c][u]&&t[c][u]){n[c][u]=!0,i[c]=i[c]||[],i[c].push(u);for(var h=o(t,t[c][u],c),d=Object.keys(h),f=0;f<d.length;f++)r[d[f]]=r[d[f]]||[],r[d[f]]=r[d[f]].concat(h[d[f]])}}return i}(n,t),l="";Object.keys(a).filter((function(t){return"main"!==t})).forEach((function(t){for(var e=0;a[t][e];)e++;a[t].push(e),n[t][e]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",l=l+"var "+t+" = ("+i.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+a[t].map((function(e){return JSON.stringify(e)+": "+n[t][e].toString()})).join(",")+"});\n"})),l=l+"new (("+i.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+a.main.map((function(t){return JSON.stringify(t)+": "+n.main[t].toString()})).join(",")+"}))(self);";var c=new window.Blob([l],{type:"text/javascript"});if(e.bare)return c;var u=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(c),h=new window.Worker(u);return h.objectURL=u,h}},"./src/config.ts":
|
|
|
/*!***********************!*\
|
|
|
!*** ./src/config.ts ***!
|
|
|
\***********************/
|
|
|
/*! exports provided: hlsDefaultConfig, mergeConfig, enableStreamingMode */function(t,e,r){"use strict";r.r(e),r.d(e,"hlsDefaultConfig",(function(){return w})),r.d(e,"mergeConfig",(function(){return k})),r.d(e,"enableStreamingMode",(function(){return E}));var i=r(/*! ./controller/abr-controller */"./src/controller/abr-controller.ts"),n=r(/*! ./controller/audio-stream-controller */"./src/controller/audio-stream-controller.ts"),o=r(/*! ./controller/audio-track-controller */"./src/controller/audio-track-controller.ts"),s=r(/*! ./controller/subtitle-stream-controller */"./src/controller/subtitle-stream-controller.ts"),a=r(/*! ./controller/subtitle-track-controller */"./src/controller/subtitle-track-controller.ts"),l=r(/*! ./controller/buffer-controller */"./src/controller/buffer-controller.ts"),c=r(/*! ./controller/timeline-controller */"./src/controller/timeline-controller.ts"),u=r(/*! ./controller/cap-level-controller */"./src/controller/cap-level-controller.ts"),h=r(/*! ./controller/fps-controller */"./src/controller/fps-controller.ts"),d=r(/*! ./controller/eme-controller */"./src/controller/eme-controller.ts"),f=r(/*! ./controller/cmcd-controller */"./src/controller/cmcd-controller.ts"),p=r(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts"),g=r(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts"),m=r(/*! ./utils/cues */"./src/utils/cues.ts"),v=r(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),y=r(/*! ./utils/logger */"./src/utils/logger.ts");function b(){return(b=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function x(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function S(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?x(Object(r),!0).forEach((function(e){C(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):x(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function C(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var w=S(S({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:p.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:i.default,bufferController:l.default,capLevelController:u.default,fpsController:h.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:v.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},{cueHandler:m.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:s.SubtitleStreamController,subtitleTrackController:a.default,timelineController:c.TimelineController,audioStreamController:n.default,audioTrackController:o.default,emeController:d.default,cmcdController:f.default});function k(t,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==e.liveMaxLatencyDurationCount&&(void 0===e.liveSyncDurationCount||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(void 0===e.liveSyncDuration||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return b({},t,e)}function E(t){var e=t.loader;e!==g.default&&e!==p.default?(y.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):Object(g.fetchSupported)()&&(t.loader=g.default,t.progressive=!0,t.enableSoftwareAES=!0,y.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}},"./src/controller/abr-controller.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/controller/abr-controller.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/ewma-bandwidth-estimator */"./src/utils/ewma-bandwidth-estimator.ts"),o=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),a=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../utils/logger */"./src/utils/logger.ts");function u(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var h=function(){function t(t){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;var e=t.config;this.bwEstimator=new n.default(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}var e,r,h,d=t.prototype;return d.registerListeners=function(){var t=this.hls;t.on(o.Events.FRAG_LOADING,this.onFragLoading,this),t.on(o.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(o.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.on(o.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(o.Events.ERROR,this.onError,this)},d.unregisterListeners=function(){var t=this.hls;t.off(o.Events.FRAG_LOADING,this.onFragLoading,this),t.off(o.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(o.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.off(o.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(o.Events.ERROR,this.onError,this)},d.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},d.onFragLoading=function(t,e){var r,i=e.frag;i.type===l.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=i,this.partCurrent=null!=(r=e.part)?r:null,this.timer=self.setInterval(this.onCheck,100)))},d.onLevelLoaded=function(t,e){var r=this.hls.config;e.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},d._abandonRulesCheck=function(){var t=this.fragCurrent,e=this.partCurrent,r=this.hls,n=r.autoLevelEnabled,a=r.config,l=r.media;if(t&&l){var u=e?e.stats:t.stats,h=e?e.duration:t.duration;if(u.aborted)return c.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),void(this._nextAutoLevel=-1);if(n&&!l.paused&&l.playbackRate&&l.readyState){var d=performance.now()-u.loading.start,f=Math.abs(l.playbackRate);if(!(d<=500*h/f)){var p=r.levels,g=r.minAutoLevel,m=p[t.level],v=u.total||Math.max(u.loaded,Math.round(h*m.maxBitrate/8)),y=Math.max(1,u.bwEstimate?u.bwEstimate/8:1e3*u.loaded/d),b=(v-u.loaded)/y,x=l.currentTime,S=(s.BufferHelper.bufferInfo(l,x,a.maxBufferHole).end-x)/f;if(!(S>=2*h/f||b<=S)){var C,w=Number.POSITIVE_INFINITY;for(C=t.level-1;C>g&&!((w=h*p[C].maxBitrate/(6.4*y))<S);C--);if(!(w>=b)){var k=this.bwEstimator.getEstimate();c.logger.warn("Fragment "+t.sn+(e?" part "+e.index:"")+" of level "+t.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+C+"\n Current BW estimate: "+(Object(i.isFiniteNumber)(k)?(k/1024).toFixed(3):"Unknown")+" Kb/s\n Estimated load time for current fragment: "+b.toFixed(3)+" s\n Estimated load time for the next fragment: "+w.toFixed(3)+" s\n Time to underbuffer: "+S.toFixed(3)+" s"),r.nextLoadLevel=C,this.bwEstimator.sample(d,u.loaded),this.clearTimer(),t.loader&&(this.fragCurrent=this.partCurrent=null,t.loader.abort()),r.trigger(o.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:u})}}}}}},d.onFragLoaded=function(t,e){var r=e.frag,n=e.part;if(r.type===l.PlaylistLevelType.MAIN&&Object(i.isFiniteNumber)(r.sn)){var s=n?n.stats:r.stats,a=n?n.duration:r.duration;if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var c=this.hls.levels[r.level],u=(c.loaded?c.loaded.bytes:0)+s.loaded,h=(c.loaded?c.loaded.duration:0)+a;c.loaded={bytes:u,duration:h},c.realBitrate=Math.round(8*u/h)}if(r.bitrateTest){var d={stats:s,frag:r,part:n,id:r.type};this.onFragBuffered(o.Events.FRAG_BUFFERED,d),r.bitrateTest=!1}}},d.onFragBuffered=function(t,e){var r=e.frag,i=e.part,n=i?i.stats:r.stats;if(!n.aborted&&r.type===l.PlaylistLevelType.MAIN&&"initSegment"!==r.sn){var o=n.parsing.end-n.loading.start;this.bwEstimator.sample(o,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=o/1e3:this.bitrateTestDelay=0}},d.onError=function(t,e){switch(e.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},d.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},d.getNextABRAutoLevel=function(){var t=this.fragCurrent,e=this.partCurrent,r=this.hls,i=r.maxAutoLevel,n=r.config,o=r.minAutoLevel,a=r.media,l=e?e.duration:t?t.duration:0,u=a?a.currentTime:0,h=a&&0!==a.playbackRate?Math.abs(a.playbackRate):1,d=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,f=(s.BufferHelper.bufferInfo(a,u,n.maxBufferHole).end-u)/h,p=this.findBestLevel(d,o,i,f,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(p>=0)return p;c.logger.trace((f?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var g=l?Math.min(l,n.maxStarvationDelay):n.maxStarvationDelay,m=n.abrBandWidthFactor,v=n.abrBandWidthUpFactor;if(!f){var y=this.bitrateTestDelay;y&&(g=(l?Math.min(l,n.maxLoadingDelay):n.maxLoadingDelay)-y,c.logger.trace("bitrate test took "+Math.round(1e3*y)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*g)+" ms"),m=v=1)}return p=this.findBestLevel(d,o,i,f+g,m,v),Math.max(p,0)},d.findBestLevel=function(t,e,r,i,n,o){for(var s,a=this.fragCurrent,l=this.partCurrent,u=this.lastLoadedFragLevel,h=this.hls.levels,d=h[u],f=!(null==d||null===(s=d.details)||void 0===s||!s.live),p=null==d?void 0:d.codecSet,g=l?l.duration:a?a.duration:0,m=r;m>=e;m--){var v=h[m];if(v&&(!p||v.codecSet===p)){var y=v.details,b=(l?null==y?void 0:y.partTarget:null==y?void 0:y.averagetargetduration)||g,x=void 0;x=m<=u?n*t:o*t;var S=h[m].maxBitrate,C=S*b/x;if(c.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+m+"/"+Math.round(x)+"/"+S+"/"+b+"/"+i+"/"+C),x>S&&(!C||f&&!this.bitrateTestDelay||C<i))return m}}return-1},e=t,(r=[{key:"nextAutoLevel",get:function(){var t=this._nextAutoLevel,e=this.bwEstimator;if(!(-1===t||e&&e.canEstimate()))return t;var r=this.getNextABRAutoLevel();return-1!==t&&(r=Math.min(t,r)),r},set:function(t){this._nextAutoLevel=t}}])&&u(e.prototype,r),h&&u(e,h),t}();e.default=h},"./src/controller/audio-stream-controller.ts":
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./src/controller/audio-stream-controller.ts ***!
|
|
|
\***************************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),o=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),a=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),l=r(/*! ../types/level */"./src/types/level.ts"),c=r(/*! ../types/loader */"./src/types/loader.ts"),u=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),h=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts"),d=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),f=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),p=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),g=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),m=r(/*! ../errors */"./src/errors.ts"),v=r(/*! ../utils/logger */"./src/utils/logger.ts");function y(){return(y=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function b(t,e){return(b=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var x=function(t){var e,r;function x(e,r){var i;return(i=t.call(this,e,r,"[audio-stream-controller]")||this).videoBuffer=null,i.videoTrackCC=-1,i.waitingVideoCC=-1,i.audioSwitch=!1,i.trackId=-1,i.waitingData=null,i.mainDetails=null,i.bufferFlushed=!1,i._registerListeners(),i}r=t,(e=x).prototype=Object.create(r.prototype),e.prototype.constructor=e,b(e,r);var S=x.prototype;return S.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},S._registerListeners=function(){var t=this.hls;t.on(o.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(o.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(o.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(o.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(o.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(o.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(o.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(o.Events.ERROR,this.onError,this),t.on(o.Events.BUFFER_RESET,this.onBufferReset,this),t.on(o.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(o.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(o.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(o.Events.FRAG_BUFFERED,this.onFragBuffered,this)},S._unregisterListeners=function(){var t=this.hls;t.off(o.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(o.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(o.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(o.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(o.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(o.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(o.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(o.Events.ERROR,this.onError,this),t.off(o.Events.BUFFER_RESET,this.onBufferReset,this),t.off(o.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(o.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(o.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(o.Events.FRAG_BUFFERED,this.onFragBuffered,this)},S.onInitPtsFound=function(t,e){var r=e.frag,i=e.id,o=e.initPTS;if("main"===i){var s=r.cc;this.initPTS[r.cc]=o,this.log("InitPTS for cc: "+s+" found from main: "+o),this.videoTrackCC=s,this.state===n.State.WAITING_INIT_PTS&&this.tick()}},S.startLoad=function(t){if(!this.levels)return this.startPosition=t,void(this.state=n.State.STOPPED);var e=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,e>0&&-1===t?(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),this.state=n.State.IDLE):(this.loadedmetadata=!1,this.state=n.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},S.doTick=function(){switch(this.state){case n.State.IDLE:this.doTickIdle();break;case n.State.WAITING_TRACK:var e,r=this.levels,i=this.trackId,o=null==r||null===(e=r[i])||void 0===e?void 0:e.details;if(o){if(this.waitForCdnTuneIn(o))break;this.state=n.State.WAITING_INIT_PTS}break;case n.State.FRAG_LOADING_WAITING_RETRY:var a,l=performance.now(),c=this.retryDate;(!c||l>=c||null!==(a=this.media)&&void 0!==a&&a.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=n.State.IDLE);break;case n.State.WAITING_INIT_PTS:var u=this.waitingData;if(u){var h=u.frag,d=u.part,f=u.cache,g=u.complete;if(void 0!==this.initPTS[h.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=n.State.FRAG_LOADING;var m={frag:h,part:d,payload:f.flush(),networkDetails:null};this._handleFragmentLoadProgress(m),g&&t.prototype._handleFragmentLoadComplete.call(this,m)}else if(this.videoTrackCC!==this.waitingVideoCC)v.logger.log("Waiting fragment cc ("+h.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var y=this.getLoadPosition(),b=s.BufferHelper.bufferInfo(this.mediaBuffer,y,this.config.maxBufferHole);Object(p.fragmentWithinToleranceTest)(b.end,this.config.maxFragLookUpTolerance,h)<0&&(v.logger.log("Waiting fragment cc ("+h.cc+") @ "+h.start+" cancelled because another fragment at "+b.end+" is needed"),this.clearWaitingFragment())}}else this.state=n.State.IDLE}this.onTickEnd()},S.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=n.State.IDLE)},S.onTickEnd=function(){var t=this.media;if(t&&t.readyState){var e=(this.mediaBuffer?this.mediaBuffer:t).buffered;!this.loadedmetadata&&e.length&&(this.loadedmetadata=!0),this.lastCurrentTime=t.currentTime}},S.doTickIdle=function(){var t,e,r=this.hls,i=this.levels,s=this.media,a=this.trackId,l=r.config;if(i&&i[a]&&(s||!this.startFragRequested&&l.startFragPrefetch)){var h=i[a].details;if(!h||h.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(h))this.state=n.State.WAITING_TRACK;else{this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,u.ElementaryStreamTypes.AUDIO,c.PlaylistLevelType.AUDIO));var d=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,c.PlaylistLevelType.AUDIO);if(null!==d){var f=d.len,p=this.getMaxBufferLength(),g=this.audioSwitch;if(!(f>=p)||g){if(!g&&this._streamEnded(d,h))return r.trigger(o.Events.BUFFER_EOS,{type:"audio"}),void(this.state=n.State.ENDED);var m=h.fragments[0].start,v=d.end;if(g){var y=this.getLoadPosition();v=y,h.PTSKnown&&y<m&&(d.end>m||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=m+.05)}var b=this.getNextFragment(v,h);b?"identity"!==(null===(t=b.decryptdata)||void 0===t?void 0:t.keyFormat)||null!==(e=b.decryptdata)&&void 0!==e&&e.key?this.loadFragment(b,h,v):this.loadKey(b,h):this.bufferFlushed=!0}}}}},S.getMaxBufferLength=function(){var e=t.prototype.getMaxBufferLength.call(this),r=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,c.PlaylistLevelType.MAIN);return null===r?e:Math.max(e,r.len)},S.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},S.onAudioTracksUpdated=function(t,e){var r=e.audioTracks;this.resetTransmuxer(),this.levels=r.map((function(t){return new l.Level(t)}))},S.onAudioTrackSwitching=function(t,e){var r=!!e.url;this.trackId=e.id;var i=this.fragCurrent;null!=i&&i.loader&&i.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.audioSwitch=!0,this.state=n.State.IDLE):this.state=n.State.STOPPED,this.tick()},S.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},S.onLevelLoaded=function(t,e){this.mainDetails=e.details},S.onAudioTrackLoaded=function(t,e){var r,i=this.levels,o=e.details,s=e.id;if(i){this.log("Track "+s+" loaded ["+o.startSN+","+o.endSN+"],duration:"+o.totalduration);var a=i[s],l=0;if(o.live||null!==(r=a.details)&&void 0!==r&&r.live){var c=this.mainDetails;if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed||!c)return;!a.details&&o.hasProgramDateTime&&c.hasProgramDateTime?(Object(g.alignMediaPlaylistByPDT)(o,c),l=o.fragments[0].start):l=this.alignPlaylists(o,a.details)}a.details=o,this.levelLastLoaded=s,this.startFragRequested||!this.mainDetails&&o.live||this.setStartPosition(a.details,l),this.state!==n.State.WAITING_TRACK||this.waitForCdnTuneIn(o)||(this.state=n.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+s)},S._handleFragmentLoadProgress=function(t){var e,r=t.frag,i=t.part,o=t.payload,s=this.config,a=this.trackId,l=this.levels;if(l){var u=l[a];console.assert(u,"Audio track is defined on fragment load progress");var p=u.details;console.assert(p,"Audio track details are defined on fragment load progress");var g=s.defaultAudioCodec||u.audioCodec||"mp4a.40.2",m=this.transmuxer;m||(m=this.transmuxer=new d.default(this.hls,c.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var y=this.initPTS[r.cc],b=null===(e=r.initSegment)||void 0===e?void 0:e.data;if(void 0!==y){var x=i?i.index:-1,S=-1!==x,C=new f.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,o.byteLength,x,S);m.push(o,b,g,"",r,i,p.totalduration,!1,C,y)}else v.logger.log("Unknown video PTS for cc "+r.cc+", waiting for video PTS before demuxing audio frag "+r.sn+" of ["+p.startSN+" ,"+p.endSN+"],track "+a),(this.waitingData=this.waitingData||{frag:r,part:i,cache:new h.default,complete:!1}).cache.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=n.State.WAITING_INIT_PTS}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},S._handleFragmentLoadComplete=function(e){this.waitingData?this.waitingData.complete=!0:t.prototype._handleFragmentLoadComplete.call(this,e)},S.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},S.onBufferCreated=function(t,e){var r=e.tracks.audio;r&&(this.mediaBuffer=r.buffer),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer)},S.onFragBuffered=function(t,e){var r=e.frag,i=e.part;r.type===c.PlaylistLevelType.AUDIO&&(this.fragContextChanged(r)?this.warn("Fragment "+r.sn+(i?" p: "+i.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):("initSegment"!==r.sn&&(this.fragPrevious=r,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(o.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(r,i)))},S.onError=function(e,r){switch(r.details){case m.ErrorDetails.FRAG_LOAD_ERROR:case m.ErrorDetails.FRAG_LOAD_TIMEOUT:case m.ErrorDetails.KEY_LOAD_ERROR:case m.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(c.PlaylistLevelType.AUDIO,r);break;case m.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case m.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==n.State.ERROR&&this.state!==n.State.STOPPED&&(this.state=r.fatal?n.State.ERROR:n.State.IDLE,this.warn(r.details+" while loading frag, switching to "+this.state+" state"));break;case m.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===r.parent&&(this.state===n.State.PARSING||this.state===n.State.PARSED)){var i=!0,o=this.getFwdBufferInfo(this.mediaBuffer,c.PlaylistLevelType.AUDIO);o&&o.len>.5&&(i=!this.reduceMaxBufferLength(o.len)),i&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}},S.onBufferFlushed=function(t,e){e.type===u.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},S._handleTransmuxComplete=function(t){var e,r="audio",i=this.hls,s=t.remuxResult,a=t.chunkMeta,l=this.getCurrentContext(a);if(!l)return this.warn("The loading context changed while buffering fragment "+a.sn+" of level "+a.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(a.level);var c=l.frag,h=l.part,d=s.audio,f=s.text,p=s.id3,g=s.initSegment;if(!this.fragContextChanged(c)){if(this.state=n.State.PARSING,this.audioSwitch&&d&&this.completeAudioSwitch(),null!=g&&g.tracks&&(this._bufferInitSegment(g.tracks,c,a),i.trigger(o.Events.FRAG_PARSING_INIT_SEGMENT,{frag:c,id:r,tracks:g.tracks})),d){var m=d.startPTS,v=d.endPTS,b=d.startDTS,x=d.endDTS;h&&(h.elementaryStreams[u.ElementaryStreamTypes.AUDIO]={startPTS:m,endPTS:v,startDTS:b,endDTS:x}),c.setElementaryStreamInfo(u.ElementaryStreamTypes.AUDIO,m,v,b,x),this.bufferFragmentData(d,c,h,a)}if(null!=p&&null!==(e=p.samples)&&void 0!==e&&e.length){var S=y({frag:c,id:r},p);i.trigger(o.Events.FRAG_PARSING_METADATA,S)}if(f){var C=y({frag:c,id:r},f);i.trigger(o.Events.FRAG_PARSING_USERDATA,C)}}},S._bufferInitSegment=function(t,e,r){if(this.state===n.State.PARSING){t.video&&delete t.video;var i=t.audio;if(i){i.levelCodec=i.codec,i.id="audio",this.log("Init audio buffer, container:"+i.container+", codecs[parsed]=["+i.codec+"]"),this.hls.trigger(o.Events.BUFFER_CODECS,t);var s=i.initSegment;if(null!=s&&s.byteLength){var a={type:"audio",frag:e,part:null,chunkMeta:r,parent:e.type,data:s};this.hls.trigger(o.Events.BUFFER_APPENDING,a)}this.tick()}}},S.loadFragment=function(e,r,o){var s=this.fragmentTracker.getState(e);this.fragCurrent=e,(this.audioSwitch||s===a.FragmentState.NOT_LOADED||s===a.FragmentState.PARTIAL)&&("initSegment"===e.sn?this._loadInitSegment(e):r.live&&!Object(i.isFiniteNumber)(this.initPTS[e.cc])?(this.log("Waiting for video PTS in continuity counter "+e.cc+" of live stream before loading audio fragment "+e.sn+" of level "+this.trackId),this.state=n.State.WAITING_INIT_PTS):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,e,r,o)))},S.completeAudioSwitch=function(){var e=this.hls,r=this.media,i=this.trackId;r&&(this.log("Switching audio track : flushing all audio"),t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,e.trigger(o.Events.AUDIO_TRACK_SWITCHED,{id:i})},x}(n.default);e.default=x},"./src/controller/audio-track-controller.ts":
|
|
|
/*!**************************************************!*\
|
|
|
!*** ./src/controller/audio-track-controller.ts ***!
|
|
|
\**************************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),s=r(/*! ../types/loader */"./src/types/loader.ts");function a(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var c=function(t){var e,r;function o(e){var r;return(r=t.call(this,e,"[audio-track-controller]")||this).tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.trackName="",r.selectDefaultTrack=!0,r.registerListeners(),r}r=t,(e=o).prototype=Object.create(r.prototype),e.prototype.constructor=e,l(e,r);var c,u,h,d=o.prototype;return d.registerListeners=function(){var t=this.hls;t.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(i.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(i.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(i.Events.ERROR,this.onError,this)},d.unregisterListeners=function(){var t=this.hls;t.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(i.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(i.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(i.Events.ERROR,this.onError,this)},d.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,t.prototype.destroy.call(this)},d.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},d.onManifestParsed=function(t,e){this.tracks=e.audioTracks||[]},d.onAudioTrackLoaded=function(t,e){var r=e.id,i=e.details,n=this.tracksInGroup[r];if(n){var o=n.details;n.details=e.details,this.log("audioTrack "+r+" loaded ["+i.startSN+"-"+i.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,e,o))}else this.warn("Invalid audio track id "+r)},d.onLevelLoading=function(t,e){this.switchLevel(e.level)},d.onLevelSwitching=function(t,e){this.switchLevel(e.level)},d.switchLevel=function(t){var e=this.hls.levels[t];if(null!=e&&e.audioGroupIds){var r=e.audioGroupIds[e.urlId];if(this.groupId!==r){this.groupId=r;var n=this.tracks.filter((function(t){return!r||t.groupId===r}));this.selectDefaultTrack&&!n.some((function(t){return t.default}))&&(this.selectDefaultTrack=!1),this.tracksInGroup=n;var o={audioTracks:n};this.log("Updating audio tracks, "+n.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(i.Events.AUDIO_TRACKS_UPDATED,o),this.selectInitialTrack()}}},d.onError=function(e,r){t.prototype.onError.call(this,e,r),!r.fatal&&r.context&&r.context.type===s.PlaylistContextType.AUDIO_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},d.setAudioTrack=function(t){var e=this.tracksInGroup;if(t<0||t>=e.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var r=e[this.trackId];this.log("Now switching to audio-track index "+t);var n=e[t],o=n.id,s=n.groupId,a=void 0===s?"":s,l=n.name,c=n.type,u=n.url;if(this.trackId=t,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(i.Events.AUDIO_TRACK_SWITCHING,{id:o,groupId:a,name:l,type:c,url:u}),!n.details||n.details.live){var h=this.switchParams(n.url,null==r?void 0:r.details);this.loadPlaylist(h)}}},d.selectInitialTrack=function(){var t=this.tracksInGroup;console.assert(t.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,r=this.findTrackId(e)||this.findTrackId();-1!==r?this.setAudioTrack(r):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},d.findTrackId=function(t){for(var e=this.tracksInGroup,r=0;r<e.length;r++){var i=e[r];if((!this.selectDefaultTrack||i.default)&&(!t||t===i.name))return i.id}return-1},d.loadPlaylist=function(t){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var r=e.id,n=e.groupId,o=e.url;if(t)try{o=t.addDirectives(o)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("loading audio-track playlist for id: "+r),this.clearTimer(),this.hls.trigger(i.Events.AUDIO_TRACK_LOADING,{url:o,id:r,groupId:n,deliveryDirectives:t||null})}},c=o,(u=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}}])&&a(c.prototype,u),h&&a(c,h),o}(o.default);e.default=c},"./src/controller/base-playlist-controller.ts":
|
|
|
/*!****************************************************!*\
|
|
|
!*** ./src/controller/base-playlist-controller.ts ***!
|
|
|
\****************************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return l}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../types/level */"./src/types/level.ts"),o=r(/*! ./level-helper */"./src/controller/level-helper.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../errors */"./src/errors.ts"),l=function(){function t(t,e){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=s.logger.log.bind(s.logger,e+":"),this.warn=s.logger.warn.bind(s.logger,e+":"),this.hls=t}var e=t.prototype;return e.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},e.onError=function(t,e){e.fatal&&e.type===a.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},e.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},e.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},e.stopLoad=function(){this.canLoad=!1,this.clearTimer()},e.switchParams=function(t,e){var r=null==e?void 0:e.renditionReports;if(r)for(var o=0;o<r.length;o++){var s=r[o],a=""+s.URI;if(a===t.substr(-a.length)){var l=parseInt(s["LAST-MSN"]),c=parseInt(s["LAST-PART"]);if(e&&this.hls.config.lowLatencyMode){var u=Math.min(e.age-e.partTarget,e.targetduration);void 0!==c&&u>e.partTarget&&(c+=1)}if(Object(i.isFiniteNumber)(l))return new n.HlsUrlParameters(l,Object(i.isFiniteNumber)(c)?c:void 0,n.HlsSkip.No)}}},e.loadPlaylist=function(t){},e.shouldLoadTrack=function(t){return this.canLoad&&t&&!!t.url&&(!t.details||t.details.live)},e.playlistLoaded=function(t,e,r){var i=this,n=e.details,s=e.stats,a=s.loading.end?Math.max(0,self.performance.now()-s.loading.end):0;if(n.advancedDateTime=Date.now()-a,n.live||null!=r&&r.live){if(n.reloaded(r),r&&this.log("live playlist "+t+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:"MISSED")),r&&n.fragments.length>0&&Object(o.mergeDetails)(r,n),!this.canLoad||!n.live)return;var l,c=void 0,u=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var h=this.hls.config.lowLatencyMode,d=n.lastPartSn,f=n.endSN,p=n.lastPartIndex,g=d===f;-1!==p?(c=g?f+1:d,u=g?h?0:p:p+1):c=f+1;var m=n.age,v=m+n.ageHeader,y=Math.min(v-n.partTarget,1.5*n.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+n.age),y=0;else{var b=Math.floor(y/n.targetduration);c+=b,void 0!==u&&(u+=Math.round(y%n.targetduration/n.partTarget)),this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+m.toFixed(2)+"s goal: "+y+" skip sn "+b+" to part "+u)}n.tuneInGoal=y}if(l=this.getDeliveryDirectives(n,e.deliveryDirectives,c,u),h||!g)return void this.loadPlaylist(l)}else l=this.getDeliveryDirectives(n,e.deliveryDirectives,c,u);var x=Object(o.computeReloadInterval)(n,s);void 0!==c&&n.canBlockReload&&(x-=n.partTarget||1),this.log("reload live playlist "+t+" in "+Math.round(x)+" ms"),this.timer=self.setTimeout((function(){return i.loadPlaylist(l)}),x)}else this.clearTimer()},e.getDeliveryDirectives=function(t,e,r,i){var o=Object(n.getSkipValue)(t,r);return null!=e&&e.skip&&t.deltaUpdateFailed&&(r=e.msn,i=e.part,o=n.HlsSkip.No),new n.HlsUrlParameters(r,i,o)},e.retryLoadingOrFail=function(t){var e,r=this,i=this.hls.config,n=this.retryCount<i.levelLoadingMaxRetry;if(n)if(this.retryCount++,t.details.indexOf("LoadTimeOut")>-1&&null!==(e=t.context)&&void 0!==e&&e.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+t.details+'"'),this.loadPlaylist();else{var o=Math.min(Math.pow(2,this.retryCount)*i.levelLoadingRetryDelay,i.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout((function(){return r.loadPlaylist()}),o),this.warn("retry playlist loading #"+this.retryCount+" in "+o+' ms after "'+t.details+'"')}else this.warn('cannot recover from error "'+t.details+'"'),this.clearTimer(),t.fatal=!0;return n},t}()},"./src/controller/base-stream-controller.ts":
|
|
|
/*!**************************************************!*\
|
|
|
!*** ./src/controller/base-stream-controller.ts ***!
|
|
|
\**************************************************/
|
|
|
/*! exports provided: State, default */function(t,e,r){"use strict";r.r(e),r.d(e,"State",(function(){return S})),r.d(e,"default",(function(){return C}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../task-loop */"./src/task-loop.ts"),o=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),l=r(/*! ../events */"./src/events.ts"),c=r(/*! ../errors */"./src/errors.ts"),u=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),h=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),d=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),f=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),p=r(/*! ./level-helper */"./src/controller/level-helper.ts"),g=r(/*! ../loader/fragment-loader */"./src/loader/fragment-loader.ts"),m=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),v=r(/*! ../utils/time-ranges */"./src/utils/time-ranges.ts"),y=r(/*! ../types/loader */"./src/types/loader.ts");function b(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function x(t,e){return(x=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var S={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},C=function(t){var e,r;function n(e,r,i){var n;return(n=t.call(this)||this).hls=void 0,n.fragPrevious=null,n.fragCurrent=null,n.fragmentTracker=void 0,n.transmuxer=null,n._state=S.STOPPED,n.media=void 0,n.mediaBuffer=void 0,n.config=void 0,n.bitrateTest=!1,n.lastCurrentTime=0,n.nextLoadPosition=0,n.startPosition=0,n.loadedmetadata=!1,n.fragLoadError=0,n.retryDate=0,n.levels=null,n.fragmentLoader=void 0,n.levelLastLoaded=null,n.startFragRequested=!1,n.decrypter=void 0,n.initPTS=[],n.onvseeking=null,n.onvended=null,n.logPrefix="",n.log=void 0,n.warn=void 0,n.logPrefix=i,n.log=a.logger.log.bind(a.logger,i+":"),n.warn=a.logger.warn.bind(a.logger,i+":"),n.hls=e,n.fragmentLoader=new g.default(e.config),n.fragmentTracker=r,n.config=e.config,n.decrypter=new m.default(e,e.config),e.on(l.Events.KEY_LOADED,n.onKeyLoaded,function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(n)),n}r=t,(e=n).prototype=Object.create(r.prototype),e.prototype.constructor=e,x(e,r);var C,w,k,E=n.prototype;return E.doTick=function(){this.onTickEnd()},E.onTickEnd=function(){},E.startLoad=function(t){},E.stopLoad=function(){this.fragmentLoader.abort();var t=this.fragCurrent;t&&this.fragmentTracker.removeFragment(t),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=S.STOPPED},E._streamEnded=function(t,e){var r=this.fragCurrent,i=this.fragmentTracker;if(!e.live&&r&&r.sn===e.endSN&&!t.nextStart){var n=i.getState(r);return n===o.FragmentState.PARTIAL||n===o.FragmentState.OK}return!1},E.onMediaAttached=function(t,e){var r=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);var i=this.config;this.levels&&i.autoStartLoad&&this.state===S.STOPPED&&this.startLoad(i.startPosition)},E.onMediaDetaching=function(){var t=this.media;null!=t&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},E.onMediaSeeking=function(){var t=this.config,e=this.fragCurrent,r=this.media,n=this.mediaBuffer,o=this.state,a=r?r.currentTime:0,l=s.BufferHelper.bufferInfo(n||r,a,t.maxBufferHole);if(this.log("media seeking to "+(Object(i.isFiniteNumber)(a)?a.toFixed(3):a)+", state: "+o),o===S.ENDED)this.resetLoadingState();else if(e&&!l.len){var c=t.maxFragLookUpTolerance,u=e.start-c,h=a>e.start+e.duration+c;(a<u||h)&&(h&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.loader.abort()),this.resetLoadingState())}r&&(this.lastCurrentTime=a),this.loadedmetadata||l.len||(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()},E.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},E.onKeyLoaded=function(t,e){if(this.state===S.KEY_LOADING&&e.frag===this.fragCurrent&&this.levels){this.state=S.IDLE;var r=this.levels[e.frag.level].details;r&&this.loadFragment(e.frag,r,e.frag.start)}},E.onHandlerDestroying=function(){this.stopLoad(),t.prototype.onHandlerDestroying.call(this)},E.onHandlerDestroyed=function(){this.state=S.STOPPED,this.hls.off(l.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,t.prototype.onHandlerDestroyed.call(this)},E.loadKey=function(t,e){this.log("Loading key for "+t.sn+" of ["+e.startSN+"-"+e.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level),this.state=S.KEY_LOADING,this.fragCurrent=t,this.hls.trigger(l.Events.KEY_LOADING,{frag:t})},E.loadFragment=function(t,e,r){this._loadFragForPlayback(t,e,r)},E._loadFragForPlayback=function(t,e,r){var i=this;this._doFragLoad(t,e,r,(function(e){if(i.fragContextChanged(t))return i.warn("Fragment "+t.sn+(e.part?" p: "+e.part.index:"")+" of level "+t.level+" was dropped during download."),void i.fragmentTracker.removeFragment(t);t.stats.chunkCount++,i._handleFragmentLoadProgress(e)})).then((function(e){if(e){i.fragLoadError=0;var r=i.state;if(!i.fragContextChanged(t))return"payload"in e&&(i.log("Loaded fragment "+t.sn+" of level "+t.level),i.hls.trigger(l.Events.FRAG_LOADED,e),i.state===S.BACKTRACKING)?(i.fragmentTracker.backtrack(t,e),void i.resetFragmentLoading(t)):void i._handleFragmentLoadComplete(e);(r===S.FRAG_LOADING||r===S.BACKTRACKING||!i.fragCurrent&&r===S.PARSING)&&(i.fragmentTracker.removeFragment(t),i.state=S.IDLE)}})).catch((function(e){i.warn(e),i.resetFragmentLoading(t)}))},E.flushMainBuffer=function(t,e,r){if(void 0===r&&(r=null),t-e){var i={startOffset:t,endOffset:e,type:r};this.fragLoadError=0,this.hls.trigger(l.Events.BUFFER_FLUSHING,i)}},E._loadInitSegment=function(t){var e=this;this._doFragLoad(t).then((function(r){if(!r||e.fragContextChanged(t)||!e.levels)throw new Error("init load aborted");return r})).then((function(r){var i=e.hls,n=r.payload,o=t.decryptdata;if(n&&n.byteLength>0&&o&&o.key&&o.iv&&"AES-128"===o.method){var s=self.performance.now();return e.decrypter.webCryptoDecrypt(new Uint8Array(n),o.key.buffer,o.iv.buffer).then((function(e){var n=self.performance.now();return i.trigger(l.Events.FRAG_DECRYPTED,{frag:t,payload:e,stats:{tstart:s,tdecrypt:n}}),r.payload=e,r}))}return r})).then((function(r){var i=e.fragCurrent,n=e.hls,o=e.levels;if(!o)throw new Error("init load aborted, missing levels");var s=o[t.level].details;console.assert(s,"Level details are defined when init segment is loaded");var a=t.stats;e.state=S.IDLE,e.fragLoadError=0,t.data=new Uint8Array(r.payload),a.parsing.start=a.buffering.start=self.performance.now(),a.parsing.end=a.buffering.end=self.performance.now(),r.frag===i&&n.trigger(l.Events.FRAG_BUFFERED,{stats:a,frag:i,part:null,id:t.type}),e.tick()})).catch((function(r){e.warn(r),e.resetFragmentLoading(t)}))},E.fragContextChanged=function(t){var e=this.fragCurrent;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId},E.fragBufferedComplete=function(t,e){var r=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+t.type+" sn: "+t.sn+(e?" part: "+e.index:"")+" of "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level+" "+v.default.toString(s.BufferHelper.getBuffered(r))),this.state=S.IDLE,this.tick()},E._handleFragmentLoadComplete=function(t){var e=this.transmuxer;if(e){var r=t.frag,i=t.part,n=t.partsLoaded,o=!n||0===n.length||n.some((function(t){return!t})),s=new u.ChunkMetadata(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!o);e.flush(s)}},E._handleFragmentLoadProgress=function(t){},E._doFragLoad=function(t,e,r,n){var o=this;if(void 0===r&&(r=null),!this.levels)throw new Error("frag load aborted, missing levels");if(r=Math.max(t.start,r||0),this.config.lowLatencyMode&&e){var s=e.partList;if(s&&n){r>t.end&&e.fragmentHint&&(t=e.fragmentHint);var a=this.getNextPart(s,t,r);if(a>-1){var c=s[a];return this.log("Loading part sn: "+t.sn+" p: "+c.index+" cc: "+t.cc+" of playlist ["+e.startSN+"-"+e.endSN+"] parts [0-"+a+"-"+(s.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=c.start+c.duration,this.state=S.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:t,part:s[a],targetBufferTime:r}),this.doFragPartsLoad(t,s,a,n).catch((function(t){return o.handleFragLoadError(t)}))}if(!t.url||this.loadedEndOfParts(s,r))return Promise.resolve(null)}}return this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(e?"of ["+e.startSN+"-"+e.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),Object(i.isFiniteNumber)(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=S.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:t,targetBufferTime:r}),this.fragmentLoader.load(t,n).catch((function(t){return o.handleFragLoadError(t)}))},E.doFragPartsLoad=function(t,e,r,i){var n=this;return new Promise((function(o,s){var a=[];!function r(c){var u=e[c];n.fragmentLoader.loadPart(t,u,i).then((function(i){a[u.index]=i;var s=i.part;n.hls.trigger(l.Events.FRAG_LOADED,i);var h=e[c+1];if(!h||h.fragment!==t)return o({frag:t,part:s,partsLoaded:a});r(c+1)})).catch(s)}(r)}))},E.handleFragLoadError=function(t){var e=t.data;return e&&e.details===c.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(l.Events.ERROR,e),null},E._handleTransmuxerFlush=function(t){var e=this.getCurrentContext(t);if(e&&this.state===S.PARSING){var r=e.frag,i=e.part,n=e.level,o=self.performance.now();r.stats.parsing.end=o,i&&(i.stats.parsing.end=o),this.updateLevelTiming(r,i,n,t.partial)}else this.fragCurrent||(this.state=S.IDLE)},E.getCurrentContext=function(t){var e=this.levels,r=t.level,i=t.sn,n=t.part;if(!e||!e[r])return this.warn("Levels object was unset while buffering fragment "+i+" of level "+r+". The current chunk will not be buffered."),null;var o=e[r],s=n>-1?Object(p.getPartWith)(o,i,n):null,a=s?s.fragment:Object(p.getFragmentWithSN)(o,i,this.fragCurrent);return a?{frag:a,part:s,level:o}:null},E.bufferFragmentData=function(t,e,r,i){if(t&&this.state===S.PARSING){var n=t.data1,o=t.data2,s=n;if(n&&o&&(s=Object(h.appendUint8Array)(n,o)),s&&s.length){var a={type:t.type,frag:e,part:r,chunkMeta:i,parent:e.type,data:s};this.hls.trigger(l.Events.BUFFER_APPENDING,a),t.dropped&&t.independent&&!r&&this.flushBufferGap(e)}}},E.flushBufferGap=function(t){var e=this.media;if(e)if(s.BufferHelper.isBuffered(e,e.currentTime)){var r=e.currentTime,i=s.BufferHelper.bufferInfo(e,r,0),n=t.duration,o=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),a=Math.max(Math.min(t.start-o,i.end-o),r+o);t.start-a>o&&this.flushMainBuffer(a,t.start)}else this.flushMainBuffer(0,t.start)},E.getFwdBufferInfo=function(t,e){var r=this.config,n=this.getLoadPosition();if(!Object(i.isFiniteNumber)(n))return null;var o=s.BufferHelper.bufferInfo(t,n,r.maxBufferHole);if(0===o.len&&void 0!==o.nextStart){var a=this.fragmentTracker.getBufferedFrag(n,e);if(a&&o.nextStart<a.end)return s.BufferHelper.bufferInfo(t,n,Math.max(o.nextStart,r.maxBufferHole))}return o},E.getMaxBufferLength=function(t){var e,r=this.config;return e=t?Math.max(8*r.maxBufferSize/t,r.maxBufferLength):r.maxBufferLength,Math.min(e,r.maxMaxBufferLength)},E.reduceMaxBufferLength=function(t){var e=this.config,r=t||e.maxBufferLength;return e.maxMaxBufferLength>=r&&(e.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+e.maxMaxBufferLength+"s"),!0)},E.getNextFragment=function(t,e){var r,i,n=e.fragments,o=n.length;if(!o)return null;var s,a=this.config,l=n[0].start;if(e.live){var c=a.initialLiveManifestSize;if(o<c)return this.warn("Not enough fragments to start playback (have: "+o+", need: "+c+")"),null;e.PTSKnown||this.startFragRequested||-1!==this.startPosition||(s=this.getInitialLiveFragment(e,n),this.startPosition=s?this.hls.liveSyncPosition||s.start:t)}else t<=l&&(s=n[0]);if(!s){var u=a.lowLatencyMode?e.partEnd:e.fragmentEnd;s=this.getFragmentAtPosition(t,u,e)}return null===(r=s)||void 0===r||!r.initSegment||null!==(i=s)&&void 0!==i&&i.initSegment.data||this.bitrateTest||(s=s.initSegment),s},E.getNextPart=function(t,e,r){for(var i=-1,n=!1,o=!0,s=0,a=t.length;s<a;s++){var l=t[s];if(o=o&&!l.independent,i>-1&&r<l.start)break;var c=l.loaded;!c&&(n||l.independent||o)&&l.fragment===e&&(i=s),n=c}return i},E.loadedEndOfParts=function(t,e){var r=t[t.length-1];return r&&e>r.start&&r.loaded},E.getInitialLiveFragment=function(t,e){var r=this.fragPrevious,i=null;if(r){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=Object(f.findFragmentByPDT)(e,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){var n=r.sn+1;if(n>=t.startSN&&n<=t.endSN){var o=e[n-t.startSN];r.cc===o.cc&&(i=o,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=Object(f.findFragWithCC)(e,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn)}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?t.fragmentEnd:t.edge,t))}return i},E.getFragmentAtPosition=function(t,e,r){var i,n=this.config,s=this.fragPrevious,a=r.fragments,l=r.endSN,c=r.fragmentHint,u=n.maxFragLookUpTolerance,h=!!(n.lowLatencyMode&&r.partList&&c);if(h&&c&&!this.bitrateTest&&(a=a.concat(c),l=c.sn),t<e){var d=t>e-u?0:u;i=Object(f.findFragmentByPTS)(s,a,t,d)}else i=a[a.length-1];if(i){var p=i.sn-r.startSN,g=s&&i.level===s.level,m=a[p+1];if(this.fragmentTracker.getState(i)===o.FragmentState.BACKTRACKED){i=null;for(var v=p;a[v]&&this.fragmentTracker.getState(a[v])===o.FragmentState.BACKTRACKED;)i=s?a[v--]:a[--v];i||(i=m)}else s&&i.sn===s.sn&&!h&&g&&(i.sn<l&&this.fragmentTracker.getState(m)!==o.FragmentState.OK?(this.log("SN "+i.sn+" just loaded, load next one: "+m.sn),i=m):i=null)}return i},E.synchronizeToLiveEdge=function(t){var e=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,n=r.currentTime,o=t.fragments[0].start,s=t.edge,a=n>=o-e.maxFragLookUpTolerance&&n<=s;if(null!==i&&r.duration>i&&(n<i||!a)){var l=void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!a&&r.readyState<4||n<s-l)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState&&(this.warn("Playback: "+n.toFixed(3)+" is located too far from the end of live sliding playlist: "+s+", reset currentTime to : "+i.toFixed(3)),r.currentTime=i))}}},E.alignPlaylists=function(t,e){var r=this.levels,n=this.levelLastLoaded,o=this.fragPrevious,s=null!==n?r[n]:null,a=t.fragments.length;if(!a)return this.warn("No fragments in live playlist"),0;var l=t.fragments[0].start,c=!e,u=t.alignedSliding&&Object(i.isFiniteNumber)(l);if(c||!u&&!l){Object(d.alignStream)(o,s,t);var h=t.fragments[0].start;return this.log("Live playlist sliding: "+h.toFixed(2)+" start-sn: "+(e?e.startSN:"na")+"->"+t.startSN+" prev-sn: "+(o?o.sn:"na")+" fragments: "+a),h}return l},E.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},E.setStartPosition=function(t,e){var r=this.startPosition;if(r<e&&(r=-1),-1===r||-1===this.lastCurrentTime){var n=t.startTimeOffset;Object(i.isFiniteNumber)(n)?(r=e+n,n<0&&(r+=t.totalduration),r=Math.min(Math.max(e,r),e+t.totalduration),this.log("Start time offset "+n+" found in playlist, adjust startPosition to "+r),this.startPosition=r):t.live?r=this.hls.liveSyncPosition||e:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},E.getLoadPosition=function(){var t=this.media,e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e},E.handleFragLoadAborted=function(t,e){this.transmuxer&&"initSegment"!==t.sn&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(e?" part"+e.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},E.resetFragmentLoading=function(t){this.fragCurrent&&this.fragContextChanged(t)||(this.state=S.IDLE)},E.onFragmentOrKeyLoadError=function(t,e){if(!e.fatal){var r=e.frag;if(r&&r.type===t){var i=this.fragCurrent;console.assert(i&&r.sn===i.sn&&r.level===i.level&&r.urlId===i.urlId,"Frag load error must match current frag to retry");var n=this.config;if(this.fragLoadError+1<=n.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(r.level))return;var o=Math.min(Math.pow(2,this.fragLoadError)*n.fragLoadingRetryDelay,n.fragLoadingMaxRetryTimeout);this.warn("Fragment "+r.sn+" of "+t+" "+r.level+" failed to load, retrying in "+o+"ms"),this.retryDate=self.performance.now()+o,this.fragLoadError++,this.state=S.FRAG_LOADING_WAITING_RETRY}else e.levelRetry?(t===y.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=S.IDLE):(a.logger.error(e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.hls.stopLoad(),this.state=S.ERROR)}}},E.afterBufferFlushed=function(t,e,r){if(t){var i=s.BufferHelper.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,i,r),this.state===S.ENDED&&this.resetLoadingState()}},E.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=S.IDLE},E.resetLiveStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var e=this.levels?this.levels[t].details:null;if(null!=e&&e.live)return this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},E.updateLevelTiming=function(t,e,r,i){var n=this,o=r.details;console.assert(!!o,"level.details must be defined"),Object.keys(t.elementaryStreams).reduce((function(e,s){var a=t.elementaryStreams[s];if(a){var c=a.endPTS-a.startPTS;if(c<=0)return n.warn("Could not parse fragment "+t.sn+" "+s+" duration reliably ("+c+") resetting transmuxer to fallback to playlist timing"),n.resetTransmuxer(),e||!1;var u=i?0:Object(p.updateFragPTSDTS)(o,t,a.startPTS,a.endPTS,a.startDTS,a.endDTS);return n.hls.trigger(l.Events.LEVEL_PTS_UPDATED,{details:o,level:r,drift:u,type:s,frag:t,start:a.startPTS,end:a.endPTS}),!0}return e}),!1)?(this.state=S.PARSED,this.hls.trigger(l.Events.FRAG_PARSED,{frag:t,part:e})):this.resetLoadingState()},E.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},C=n,(w=[{key:"state",get:function(){return this._state},set:function(t){var e=this._state;e!==t&&(this._state=t,this.log(e+"->"+t))}}])&&b(C.prototype,w),k&&b(C,k),n}(n.default)},"./src/controller/buffer-controller.ts":
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./src/controller/buffer-controller.ts ***!
|
|
|
\*********************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return f}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),c=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),u=r(/*! ./buffer-operation-queue */"./src/controller/buffer-operation-queue.ts"),h=Object(l.getMediaSource)(),d=/([ha]vc.)(?:\.[^.,]+)+/,f=function(){function t(t){var e=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 t=e.hls,r=e.media,i=e.mediaSource;o.logger.log("[buffer-controller]: Media source opened"),r&&(e.updateMediaElementDuration(),t.trigger(n.Events.MEDIA_ATTACHED,{media:r})),i&&i.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){o.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){o.logger.log("[buffer-controller]: Media source ended")},this.hls=t,this._initSourceBuffer(),this.registerListeners()}var e=t.prototype;return e.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},e.destroy=function(){this.unregisterListeners(),this.details=null},e.registerListeners=function(){var t=this.hls;t.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(n.Events.BUFFER_RESET,this.onBufferReset,this),t.on(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.on(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(n.Events.BUFFER_EOS,this.onBufferEos,this),t.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(n.Events.FRAG_PARSED,this.onFragParsed,this),t.on(n.Events.FRAG_CHANGED,this.onFragChanged,this)},e.unregisterListeners=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(n.Events.BUFFER_RESET,this.onBufferReset,this),t.off(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.off(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(n.Events.BUFFER_EOS,this.onBufferEos,this),t.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(n.Events.FRAG_PARSED,this.onFragParsed,this),t.off(n.Events.FRAG_CHANGED,this.onFragChanged,this)},e._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new u.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},e.onManifestParsed=function(t,e){var r=2;(e.audio&&!e.video||!e.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.details=null,o.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},e.onMediaAttaching=function(t,e){var r=this.media=e.media;if(r&&h){var i=this.mediaSource=new h;i.addEventListener("sourceopen",this._onMediaSourceOpen),i.addEventListener("sourceended",this._onMediaSourceEnded),i.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(i),this._objectUrl=r.src}},e.onMediaDetaching=function(){var t=this.media,e=this.mediaSource,r=this._objectUrl;if(e){if(o.logger.log("[buffer-controller]: media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(t){o.logger.warn("[buffer-controller]: onMediaDetaching: "+t.message+" while calling endOfStream")}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(r&&self.URL.revokeObjectURL(r),t.src===r?(t.removeAttribute("src"),t.load()):o.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)},e.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach((function(e){var r=t.sourceBuffer[e];try{r&&(t.removeBufferListeners(e),t.mediaSource&&t.mediaSource.removeSourceBuffer(r),t.sourceBuffer[e]=void 0)}catch(t){o.logger.warn("[buffer-controller]: Failed to reset the "+e+" buffer",t)}})),this._initSourceBuffer()},e.onBufferCodecs=function(t,e){var r=this,i=this.getSourceBufferTypes().length;Object.keys(e).forEach((function(t){if(i){var n=r.tracks[t];if(n&&"function"==typeof n.buffer.changeType){var o=e[t],s=o.codec,a=o.levelCodec,l=o.container;if((n.levelCodec||n.codec).replace(d,"$1")!==(a||s).replace(d,"$1")){var c=l+";codecs="+(a||s);r.appendChangeType(t,c)}}}else r.pendingTracks[t]=e[t]})),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},e.appendChangeType=function(t,e){var r=this,i=this.operationQueue,n={execute:function(){var n=r.sourceBuffer[t];n&&(o.logger.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+e),n.changeType(e)),i.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(e){o.logger.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",e)}};i.append(n,t)},e.onBufferAppending=function(t,e){var r=this,i=this.hls,l=this.operationQueue,c=this.tracks,u=e.data,h=e.type,d=e.frag,f=e.part,p=e.chunkMeta,g=p.buffering[h],m=self.performance.now();g.start=m;var v=d.stats.buffering,y=f?f.stats.buffering:null;0===v.start&&(v.start=m),y&&0===y.start&&(y.start=m);var b=c.audio,x="audio"===h&&1===p.id&&"audio/mpeg"===(null==b?void 0:b.container),S={execute:function(){if(g.executeStart=self.performance.now(),x){var t=r.sourceBuffer[h];if(t){var e=d.start-t.timestampOffset;Math.abs(e)>=.1&&(o.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+d.start+" (delta: "+e+") sn: "+d.sn+")"),t.timestampOffset=d.start)}}r.appendExecutor(u,h)},onStart:function(){},onComplete:function(){var t=self.performance.now();g.executeEnd=g.end=t,0===v.first&&(v.first=t),y&&0===y.first&&(y.first=t);var e=r.sourceBuffer,i={};for(var o in e)i[o]=a.BufferHelper.getBuffered(e[o]);r.appendError=0,r.hls.trigger(n.Events.BUFFER_APPENDED,{type:h,frag:d,part:f,chunkMeta:p,parent:d.type,timeRanges:i})},onError:function(t){o.logger.error("[buffer-controller]: Error encountered while trying to append to the "+h+" SourceBuffer",t);var e={type:s.ErrorTypes.MEDIA_ERROR,parent:d.type,details:s.ErrorDetails.BUFFER_APPEND_ERROR,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=s.ErrorDetails.BUFFER_FULL_ERROR:(r.appendError++,e.details=s.ErrorDetails.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(o.logger.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),e.fatal=!0)),i.trigger(n.Events.ERROR,e)}};l.append(S,h)},e.onBufferFlushing=function(t,e){var r=this,i=this.operationQueue,s=function(t){return{execute:r.removeExecutor.bind(r,t,e.startOffset,e.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(n.Events.BUFFER_FLUSHED,{type:t})},onError:function(e){o.logger.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",e)}}};e.type?i.append(s(e.type),e.type):this.getSourceBufferTypes().forEach((function(t){i.append(s(t),t)}))},e.onFragParsed=function(t,e){var r=this,i=e.frag,s=e.part,a=[],l=s?s.elementaryStreams:i.elementaryStreams;l[c.ElementaryStreamTypes.AUDIOVIDEO]?a.push("audiovideo"):(l[c.ElementaryStreamTypes.AUDIO]&&a.push("audio"),l[c.ElementaryStreamTypes.VIDEO]&&a.push("video")),0===a.length&&o.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers((function(){var t=self.performance.now();i.stats.buffering.end=t,s&&(s.stats.buffering.end=t);var e=s?s.stats:i.stats;r.hls.trigger(n.Events.FRAG_BUFFERED,{frag:i,part:s,stats:e,id:i.type})}),a)},e.onFragChanged=function(t,e){this.flushBackBuffer()},e.onBufferEos=function(t,e){var r=this;this.getSourceBufferTypes().reduce((function(t,i){var n=r.sourceBuffer[i];return e.type&&e.type!==i||n&&!n.ended&&(n.ended=!0,o.logger.log("[buffer-controller]: "+i+" sourceBuffer now EOS")),t&&!(n&&!n.ended)}),!0)&&this.blockBuffers((function(){var t=r.mediaSource;t&&"open"===t.readyState&&t.endOfStream()}))},e.onLevelUpdated=function(t,e){var r=e.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},e.flushBackBuffer=function(){var t=this.hls,e=this.details,r=this.media,o=this.sourceBuffer;if(r&&null!==e){var s=this.getSourceBufferTypes();if(s.length){var l=e.live&&null!==t.config.liveBackBufferLength?t.config.liveBackBufferLength:t.config.backBufferLength;if(Object(i.isFiniteNumber)(l)&&!(l<0)){var c=r.currentTime,u=e.levelTargetDuration,h=Math.max(l,u),d=Math.floor(c/u)*u-h;s.forEach((function(r){var i=o[r];if(i){var s=a.BufferHelper.getBuffered(i);s.length>0&&d>s.start(0)&&(t.trigger(n.Events.BACK_BUFFER_REACHED,{bufferEnd:d}),e.live&&t.trigger(n.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:d}),t.trigger(n.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:d,type:r}))}}))}}}},e.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var t=this.details,e=this.hls,r=this.media,n=this.mediaSource,s=t.fragments[0].start+t.totalduration,a=r.duration,l=Object(i.isFiniteNumber)(n.duration)?n.duration:0;t.live&&e.config.liveDurationInfinity?(o.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(t)):(s>l&&s>a||!Object(i.isFiniteNumber)(a))&&(o.logger.log("[buffer-controller]: Updating Media Source duration to "+s.toFixed(3)),n.duration=s)}},e.updateSeekableRange=function(t){var e=this.mediaSource,r=t.fragments;if(r.length&&t.live&&null!=e&&e.setLiveSeekableRange){var i=Math.max(0,r[0].start),n=Math.max(i,i+t.totalduration);e.setLiveSeekableRange(i,n)}},e.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,e=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&!t||2===i){this.createSourceBuffers(r),this.pendingTracks={};var o=this.getSourceBufferTypes();if(0===o.length)return void this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});o.forEach((function(t){e.executeNext(t)}))}},e.createSourceBuffers=function(t){var e=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");var i=0;for(var a in t)if(!e[a]){var l=t[a];if(!l)throw Error("source buffer exists for track "+a+", however track does not");var c=l.levelCodec||l.codec,u=l.container+";codecs="+c;o.logger.log("[buffer-controller]: creating sourceBuffer("+u+")");try{var h=e[a]=r.addSourceBuffer(u),d=a;this.addBufferListener(d,"updatestart",this._onSBUpdateStart),this.addBufferListener(d,"updateend",this._onSBUpdateEnd),this.addBufferListener(d,"error",this._onSBUpdateError),this.tracks[a]={buffer:h,codec:c,container:l.container,levelCodec:l.levelCodec,id:l.id},i++}catch(t){o.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:u})}}i&&this.hls.trigger(n.Events.BUFFER_CREATED,{tracks:this.tracks})},e._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},e._onSBUpdateEnd=function(t){var e=this.operationQueue;e.current(t).onComplete(),e.shiftAndExecuteNext(t)},e._onSBUpdateError=function(t,e){o.logger.error("[buffer-controller]: "+t+" SourceBuffer error",e),this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var r=this.operationQueue.current(t);r&&r.onError(e)},e.removeExecutor=function(t,e,r){var n=this.media,s=this.mediaSource,a=this.operationQueue,l=this.sourceBuffer[t];if(!n||!s||!l)return o.logger.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void a.shiftAndExecuteNext(t);var c=Object(i.isFiniteNumber)(n.duration)?n.duration:1/0,u=Object(i.isFiniteNumber)(s.duration)?s.duration:1/0,h=Math.max(0,e),d=Math.min(r,c,u);d>h?(o.logger.log("[buffer-controller]: Removing ["+h+","+d+"] from the "+t+" SourceBuffer"),console.assert(!l.updating,t+" sourceBuffer must not be updating"),l.remove(h,d)):a.shiftAndExecuteNext(t)},e.appendExecutor=function(t,e){var r=this.operationQueue,i=this.sourceBuffer[e];if(!i)return o.logger.warn("[buffer-controller]: Attempting to append to the "+e+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(e);i.ended=!1,console.assert(!i.updating,e+" sourceBuffer must not be updating"),i.appendBuffer(t)},e.blockBuffers=function(t,e){var r=this;if(void 0===e&&(e=this.getSourceBufferTypes()),!e.length)return o.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve(t);var i=this.operationQueue,n=e.map((function(t){return i.appendBlocker(t)}));Promise.all(n).then((function(){t(),e.forEach((function(t){var e=r.sourceBuffer[t];e&&e.updating||i.shiftAndExecuteNext(t)}))}))},e.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},e.addBufferListener=function(t,e,r){var i=this.sourceBuffer[t];if(i){var n=r.bind(this,t);this.listeners[t].push({event:e,listener:n}),i.addEventListener(e,n)}},e.removeBufferListeners=function(t){var e=this.sourceBuffer[t];e&&this.listeners[t].forEach((function(t){e.removeEventListener(t.event,t.listener)}))},t}()},"./src/controller/buffer-operation-queue.ts":
|
|
|
/*!**************************************************!*\
|
|
|
!*** ./src/controller/buffer-operation-queue.ts ***!
|
|
|
\**************************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return n}));var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=function(){function t(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}var e=t.prototype;return e.append=function(t,e){var r=this.queues[e];r.push(t),1===r.length&&this.buffers[e]&&this.executeNext(e)},e.insertAbort=function(t,e){this.queues[e].unshift(t),this.executeNext(e)},e.appendBlocker=function(t){var e,r=new Promise((function(t){e=t})),i={execute:e,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,t),r},e.executeNext=function(t){var e=this.buffers,r=this.queues,n=e[t],o=r[t];if(o.length){var s=o[0];try{s.execute()}catch(e){i.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),s.onError(e),n&&n.updating||(o.shift(),this.executeNext(t))}}},e.shiftAndExecuteNext=function(t){this.queues[t].shift(),this.executeNext(t)},e.current=function(t){return this.queues[t][0]},t}()},"./src/controller/cap-level-controller.ts":
|
|
|
/*!************************************************!*\
|
|
|
!*** ./src/controller/cap-level-controller.ts ***!
|
|
|
\************************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ../events */"./src/events.ts");function n(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var o=function(){function t(t){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var e,r,o,s=t.prototype;return s.setStreamController=function(t){this.streamController=t},s.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},s.registerListeners=function(){var t=this.hls;t.on(i.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListener=function(){var t=this.hls;t.off(i.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},s.onFpsDropLevelCapping=function(e,r){t.isLevelAllowed(r.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(r.droppedLevel)},s.onMediaAttaching=function(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null},s.onManifestParsed=function(t,e){var r=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,r.config.capLevelToPlayerSize&&e.video&&this.startCapping()},s.onBufferCodecs=function(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()},s.onMediaDetaching=function(){this.stopCapping()},s.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var t=this.hls.levels;if(t.length){var e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},s.getMaxLevel=function(e){var r=this,i=this.hls.levels;if(!i.length)return-1;var n=i.filter((function(i,n){return t.isLevelAllowed(n,r.restrictedLevels)&&n<=e}));return this.clientRect=null,t.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)},s.startCapping=function(){this.timer||(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())},s.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},s.getDimensions=function(){if(this.clientRect)return this.clientRect;var t=this.media,e={width:0,height:0};if(t){var r=t.getBoundingClientRect();e.width=r.width,e.height=r.height,e.width||e.height||(e.width=r.right-r.left||t.width||0,e.height=r.bottom-r.top||t.height||0)}return this.clientRect=e,e},t.isLevelAllowed=function(t,e){return void 0===e&&(e=[]),-1===e.indexOf(t)},t.getMaxLevelByMediaSize=function(t,e,r){if(!t||!t.length)return-1;for(var i,n,o=t.length-1,s=0;s<t.length;s+=1){var a=t[s];if((a.width>=e||a.height>=r)&&(i=a,!(n=t[s+1])||i.width!==n.width||i.height!==n.height)){o=s;break}}return o},e=t,o=[{key:"contentScaleFactor",get:function(){var t=1;try{t=self.devicePixelRatio}catch(t){}return t}}],(r=[{key:"mediaWidth",get:function(){return this.getDimensions().width*t.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*t.contentScaleFactor}}])&&n(e.prototype,r),o&&n(e,o),t}();e.default=o},"./src/controller/cmcd-controller.ts":
|
|
|
/*!*******************************************!*\
|
|
|
!*** ./src/controller/cmcd-controller.ts ***!
|
|
|
\*******************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return d}));var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../types/cmcd */"./src/types/cmcd.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts");function a(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function l(t,e,r){return e&&a(t.prototype,e),r&&a(t,r),t}function c(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return u(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}function h(){return(h=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}var d=function(){function t(e){var r=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(t){try{r.apply(t,{ot:n.CMCDObjectType.MANIFEST,su:!r.initialized})}catch(t){s.logger.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=function(t){try{var e=t.frag,i=r.hls.levels[e.level],o=r.getObjectType(e),a={d:1e3*e.duration,ot:o};o!==n.CMCDObjectType.VIDEO&&o!==n.CMCDObjectType.AUDIO&&o!=n.CMCDObjectType.MUXED||(a.br=i.bitrate/1e3,a.tb=r.getTopBandwidth(o),a.bl=r.getBufferLength(o)),r.apply(t,a)}catch(t){s.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=e;var i=this.config=e.config,o=i.cmcd;null!=o&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=o.sessionId||t.uuid(),this.cid=o.contentId,this.useHeaders=!0===o.useHeaders,this.registerListeners())}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;t.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),t.on(i.Events.BUFFER_CREATED,this.onBufferCreated,this)},e.unregisterListeners=function(){var t=this.hls;t.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),t.off(i.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},e.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},e.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},e.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},e.onBufferCreated=function(t,e){var r,i;this.audioBuffer=null===(r=e.tracks.audio)||void 0===r?void 0:r.buffer,this.videoBuffer=null===(i=e.tracks.video)||void 0===i?void 0:i.buffer},e.createData=function(){var t;return{v:n.CMCDVersion,sf:n.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:null===(t=this.media)||void 0===t?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},e.apply=function(e,r){void 0===r&&(r={}),h(r,this.createData());var i=r.ot===n.CMCDObjectType.INIT||r.ot===n.CMCDObjectType.VIDEO||r.ot===n.CMCDObjectType.MUXED;if(this.starved&&i&&(r.bs=!0,r.su=!0,this.starved=!1),null==r.su&&(r.su=this.buffering),this.useHeaders){var o=t.toHeaders(r);if(!Object.keys(o).length)return;e.headers||(e.headers={}),h(e.headers,o)}else{var s=t.toQuery(r);if(!s)return;e.url=t.appendQueryToUri(e.url,s)}},e.getObjectType=function(t){var e=t.type;return"subtitle"===e?n.CMCDObjectType.TIMED_TEXT:"initSegment"===t.sn?n.CMCDObjectType.INIT:"audio"===e?n.CMCDObjectType.AUDIO:"main"===e?this.hls.audioTracks.length?n.CMCDObjectType.VIDEO:n.CMCDObjectType.MUXED:void 0},e.getTopBandwidth=function(t){for(var e,r=0,i=c(t===n.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels);!(e=i()).done;){var o=e.value;o.bitrate>r&&(r=o.bitrate)}return r>0?r:NaN},e.getBufferLength=function(t){var e=this.hls.media,r=t===n.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;return r&&e?1e3*o.BufferHelper.bufferInfo(r,e.currentTime,this.config.maxBufferHole).len:NaN},e.createPlaylistLoader=function(){var t=this.config.pLoader,e=this.applyPlaylistData,r=t||this.config.loader;return function(){function t(t){this.loader=void 0,this.loader=new r(t)}var i=t.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(t,r,i){e(t),this.loader.load(t,r,i)},l(t,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),t}()},e.createFragmentLoader=function(){var t=this.config.fLoader,e=this.applyFragmentData,r=t||this.config.loader;return function(){function t(t){this.loader=void 0,this.loader=new r(t)}var i=t.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(t,r,i){e(t),this.loader.load(t,r,i)},l(t,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),t}()},t.uuid=function(){var t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.substr(e.lastIndexOf("/")+1)},t.serialize=function(t){for(var e,r=[],i=function(t){return!Number.isNaN(t)&&null!=t&&""!==t&&!1!==t},n=function(t){return Math.round(t)},o=function(t){return 100*n(t/100)},s={br:n,d:n,bl:o,dl:o,mtp:o,nor:function(t){return encodeURIComponent(t)},rtp:o,tb:n},a=c(Object.keys(t||{}).sort());!(e=a()).done;){var l=e.value,u=t[l];if(i(u)&&!("v"===l&&1===u||"pr"==l&&1===u)){var h=s[l];h&&(u=h(u));var d=typeof u,f=void 0;f="ot"===l||"sf"===l||"st"===l?l+"="+u:"boolean"===d?l:"number"===d?l+"="+u:l+"="+JSON.stringify(u),r.push(f)}}return r.join(",")},t.toHeaders=function(e){for(var r={},i=["Object","Request","Session","Status"],n=[{},{},{},{}],o={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},s=0,a=Object.keys(e);s<a.length;s++){var l=a[s];n[null!=o[l]?o[l]:1][l]=e[l]}for(var c=0;c<n.length;c++){var u=t.serialize(n[c]);u&&(r["CMCD-"+i[c]]=u)}return r},t.toQuery=function(e){return"CMCD="+encodeURIComponent(t.serialize(e))},t.appendQueryToUri=function(t,e){if(!e)return t;var r=t.includes("?")?"&":"?";return""+t+r+e},t}()},"./src/controller/eme-controller.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/controller/eme-controller.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts");function a(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var l=function(){function t(t){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=t,this._config=t.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var e,r,l,c=t.prototype;return c.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},c._registerListeners=function(){this.hls.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this)},c._unregisterListeners=function(){this.hls.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this)},c.getLicenseServerUrl=function(t){switch(t){case s.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+t+'"')},c._attemptKeySystemAccess=function(t,e,r){var i=this,n=function(t,e,r,i){switch(t){case s.KeySystems.WIDEVINE:return function(t,e,r){var i={audioCapabilities:[],videoCapabilities:[]};return t.forEach((function(t){i.audioCapabilities.push({contentType:'audio/mp4; codecs="'+t+'"',robustness:r.audioRobustness||""})})),e.forEach((function(t){i.videoCapabilities.push({contentType:'video/mp4; codecs="'+t+'"',robustness:r.videoRobustness||""})})),[i]}(e,r,i);default:throw new Error("Unknown key-system: "+t)}}(t,e,r,this._drmSystemOptions);o.logger.log("Requesting encrypted media key-system access");var a=this.requestMediaKeySystemAccess(t,n);this.mediaKeysPromise=a.then((function(e){return i._onMediaKeySystemAccessObtained(t,e)})),a.catch((function(e){o.logger.error('Failed to obtain key-system "'+t+'" access:',e)}))},c._onMediaKeySystemAccessObtained=function(t,e){var r=this;o.logger.log('Access for key-system "'+t+'" obtained');var i={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:t};this._mediaKeysList.push(i);var n=Promise.resolve().then((function(){return e.createMediaKeys()})).then((function(e){return i.mediaKeys=e,o.logger.log('Media-keys created for key-system "'+t+'"'),r._onMediaKeysCreated(),e}));return n.catch((function(t){o.logger.error("Failed to create media-keys:",t)})),n},c._onMediaKeysCreated=function(){var t=this;this._mediaKeysList.forEach((function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),t._onNewMediaKeySession(e.mediaKeysSession))}))},c._onNewMediaKeySession=function(t){var e=this;o.logger.log("New key-system session "+t.sessionId),t.addEventListener("message",(function(r){e._onKeySessionMessage(t,r.message)}),!1)},c._onKeySessionMessage=function(t,e){o.logger.log("Got EME message event, creating license request"),this._requestLicense(e,(function(e){o.logger.log("Received license data (length: "+(e?e.byteLength:e)+"), updating key-session"),t.update(e)}))},c.onMediaEncrypted=function(t){var e=this;if(o.logger.log('Media is encrypted using "'+t.initDataType+'" init data type'),!this.mediaKeysPromise)return o.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});var r=function(r){e._media&&(e._attemptSetMediaKeys(r),e._generateRequestWithPreferredKeySession(t.initDataType,t.initData))};this.mediaKeysPromise.then(r).catch(r)},c._attemptSetMediaKeys=function(t){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys)return o.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});o.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},c._generateRequestWithPreferredKeySession=function(t,e){var r=this,s=this._mediaKeysList[0];if(!s)return o.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});if(s.mediaKeysSessionInitialized)o.logger.warn("Key-Session already initialized but requested again");else{var a=s.mediaKeysSession;if(!a)return o.logger.error("Fatal: Media is encrypted but no key-session existing"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});if(!e)return o.logger.warn("Fatal: initData required for generating a key session is null"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});o.logger.log('Generating key-session request for "'+t+'" init data type'),s.mediaKeysSessionInitialized=!0,a.generateRequest(t,e).then((function(){o.logger.debug("Key-session generation succeeded")})).catch((function(t){o.logger.error("Error generating key-session request:",t),r.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})}))}},c._createLicenseXhr=function(t,e,r){var i=new XMLHttpRequest;i.responseType="arraybuffer",i.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,i,t,e,r);var n=this._licenseXhrSetup;if(n)try{n.call(this.hls,i,t),n=void 0}catch(t){o.logger.error(t)}try{i.readyState||i.open("POST",t,!0),n&&n.call(this.hls,i,t)}catch(t){throw new Error("issue setting up KeySystem license XHR "+t)}return i},c._onLicenseRequestReadyStageChange=function(t,e,r,s){switch(t.readyState){case 4:if(200===t.status){this._requestLicenseFailureCount=0,o.logger.log("License request succeeded");var a=t.response,l=this._licenseResponseCallback;if(l)try{a=l.call(this.hls,t,e)}catch(t){o.logger.error(t)}s(a)}else{if(o.logger.error("License Request XHR failed ("+e+"). Status: "+t.status+" ("+t.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>3)return void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});var c=3-this._requestLicenseFailureCount+1;o.logger.warn("Retrying license request, "+c+" attempts left"),this._requestLicense(r,s)}}},c._generateLicenseRequestChallenge=function(t,e){switch(t.mediaKeySystemDomain){case s.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+t.mediaKeySystemDomain)},c._requestLicense=function(t,e){o.logger.log("Requesting content license for key-system");var r=this._mediaKeysList[0];if(!r)return o.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var s=this.getLicenseServerUrl(r.mediaKeySystemDomain),a=this._createLicenseXhr(s,t,e);o.logger.log("Sending license request to URL: "+s);var l=this._generateLicenseRequestChallenge(r,t);a.send(l)}catch(t){o.logger.error("Failure requesting DRM license: "+t),this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},c.onMediaAttached=function(t,e){if(this._emeEnabled){var r=e.media;this._media=r,r.addEventListener("encrypted",this._onMediaEncrypted)}},c.onMediaDetached=function(){var t=this._media,e=this._mediaKeysList;t&&(t.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map((function(t){if(t.mediaKeysSession)return t.mediaKeysSession.close().catch((function(){}))}))).then((function(){return t.setMediaKeys(null)})).catch((function(){})))},c.onManifestParsed=function(t,e){if(this._emeEnabled){var r=e.levels.map((function(t){return t.audioCodec})).filter((function(t){return!!t})),i=e.levels.map((function(t){return t.videoCodec})).filter((function(t){return!!t}));this._attemptKeySystemAccess(s.KeySystems.WIDEVINE,r,i)}},e=t,(r=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&a(e.prototype,r),l&&a(e,l),t}();e.default=l},"./src/controller/fps-controller.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/controller/fps-controller.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=function(){function t(t){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=t,this.registerListeners()}var e=t.prototype;return e.setStreamController=function(t){this.streamController=t},e.registerListeners=function(){this.hls.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},e.unregisterListeners=function(){this.hls.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching)},e.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},e.onMediaAttaching=function(t,e){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=i,i&&"function"==typeof i.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},e.checkFPS=function(t,e,r){var o=performance.now();if(e){if(this.lastTime){var s=o-this.lastTime,a=r-this.lastDroppedFrames,l=e-this.lastDecodedFrames,c=1e3*a/s,u=this.hls;if(u.trigger(i.Events.FPS_DROP,{currentDropped:a,currentDecoded:l,totalDroppedFrames:r}),c>0&&a>u.config.fpsDroppedMonitoringThreshold*l){var h=u.currentLevel;n.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+h),h>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=h)&&(h-=1,u.trigger(i.Events.FPS_DROP_LEVEL_CAPPING,{level:h,droppedLevel:u.currentLevel}),u.autoLevelCapping=h,this.streamController.nextLevelSwitch())}}this.lastTime=o,this.lastDroppedFrames=r,this.lastDecodedFrames=e}},e.checkFPSInterval=function(){var t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){var e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},t}();e.default=o},"./src/controller/fragment-finders.ts":
|
|
|
/*!********************************************!*\
|
|
|
!*** ./src/controller/fragment-finders.ts ***!
|
|
|
\********************************************/
|
|
|
/*! exports provided: findFragmentByPDT, findFragmentByPTS, fragmentWithinToleranceTest, pdtWithinToleranceTest, findFragWithCC */function(t,e,r){"use strict";r.r(e),r.d(e,"findFragmentByPDT",(function(){return o})),r.d(e,"findFragmentByPTS",(function(){return s})),r.d(e,"fragmentWithinToleranceTest",(function(){return a})),r.d(e,"pdtWithinToleranceTest",(function(){return l})),r.d(e,"findFragWithCC",(function(){return c}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/binary-search */"./src/utils/binary-search.ts");function o(t,e,r){if(null===e||!Array.isArray(t)||!t.length||!Object(i.isFiniteNumber)(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;r=r||0;for(var n=0;n<t.length;++n){var o=t[n];if(l(e,r,o))return o}return null}function s(t,e,r,i){void 0===r&&(r=0),void 0===i&&(i=0);var o=null;if(t?o=e[t.sn-e[0].sn+1]||null:0===r&&0===e[0].start&&(o=e[0]),o&&0===a(r,i,o))return o;var s=n.default.search(e,a.bind(null,r,i));return s||o}function a(t,e,r){void 0===t&&(t=0),void 0===e&&(e=0);var i=Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=t?1:r.start-i>t&&r.start?-1:0}function l(t,e,r){var i=1e3*Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>t}function c(t,e){return n.default.search(t,(function(t){return t.cc<e?1:t.cc>e?-1:0}))}},"./src/controller/fragment-tracker.ts":
|
|
|
/*!********************************************!*\
|
|
|
!*** ./src/controller/fragment-tracker.ts ***!
|
|
|
\********************************************/
|
|
|
/*! exports provided: FragmentState, FragmentTracker */function(t,e,r){"use strict";r.r(e),r.d(e,"FragmentState",(function(){return i})),r.d(e,"FragmentTracker",(function(){return s}));var i,n=r(/*! ../events */"./src/events.ts"),o=r(/*! ../types/loader */"./src/types/loader.ts");!function(t){t.NOT_LOADED="NOT_LOADED",t.BACKTRACKED="BACKTRACKED",t.APPENDING="APPENDING",t.PARTIAL="PARTIAL",t.OK="OK"}(i||(i={}));var s=function(){function t(t){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=t,this._registerListeners()}var e=t.prototype;return e._registerListeners=function(){var t=this.hls;t.on(n.Events.BUFFER_APPENDED,this.onBufferAppended,this),t.on(n.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.on(n.Events.FRAG_LOADED,this.onFragLoaded,this)},e._unregisterListeners=function(){var t=this.hls;t.off(n.Events.BUFFER_APPENDED,this.onBufferAppended,this),t.off(n.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.off(n.Events.FRAG_LOADED,this.onFragLoaded,this)},e.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},e.getAppendedFrag=function(t,e){if(e===o.PlaylistLevelType.MAIN){var r=this.activeFragment,i=this.activeParts;if(!r)return null;if(i)for(var n=i.length;n--;){var s=i[n],a=s?s.end:r.appendedPTS;if(s.start<=t&&void 0!==a&&t<=a)return n>9&&(this.activeParts=i.slice(n-9)),s}else if(r.start<=t&&void 0!==r.appendedPTS&&t<=r.appendedPTS)return r}return this.getBufferedFrag(t,e)},e.getBufferedFrag=function(t,e){for(var r=this.fragments,i=Object.keys(r),n=i.length;n--;){var o=r[i[n]];if((null==o?void 0:o.body.type)===e&&o.buffered){var s=o.body;if(s.start<=t&&t<=s.end)return s}}return null},e.detectEvictedFragments=function(t,e,r){var i=this;Object.keys(this.fragments).forEach((function(n){var o=i.fragments[n];if(o)if(o.buffered){var s=o.range[t];s&&s.time.some((function(t){var r=!i.isTimeBuffered(t.startPTS,t.endPTS,e);return r&&i.removeFragment(o.body),r}))}else o.body.type===r&&i.removeFragment(o.body)}))},e.detectPartialFragments=function(t){var e=this,r=this.timeRanges,i=t.frag,n=t.part;if(r&&"initSegment"!==i.sn){var o=l(i),s=this.fragments[o];s&&(Object.keys(r).forEach((function(t){var o=i.elementaryStreams[t];if(o){var a=r[t],l=null!==n||!0===o.partial;s.range[t]=e.getBufferedTimes(i,n,l,a)}})),s.backtrack=s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body))}},e.fragBuffered=function(t){var e=l(t),r=this.fragments[e];r&&(r.backtrack=r.loaded=null,r.buffered=!0)},e.getBufferedTimes=function(t,e,r,i){for(var n={time:[],partial:r},o=e?e.start:t.start,s=e?e.end:t.end,a=t.minEndPTS||s,l=t.maxStartPTS||o,c=0;c<i.length;c++){var u=i.start(c)-this.bufferPadding,h=i.end(c)+this.bufferPadding;if(l>=u&&a<=h){n.time.push({startPTS:Math.max(o,i.start(c)),endPTS:Math.min(s,i.end(c))});break}if(o<h&&s>u)n.partial=!0,n.time.push({startPTS:Math.max(o,i.start(c)),endPTS:Math.min(s,i.end(c))});else if(s<=u)break}return n},e.getPartialFragment=function(t){var e,r,i,n=null,o=0,s=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach((function(c){var u=l[c];u&&a(u)&&(r=u.body.start-s,i=u.body.end+s,t>=r&&t<=i&&(e=Math.min(t-r,i-t),o<=e&&(n=u.body,o=e)))})),n},e.getState=function(t){var e=l(t),r=this.fragments[e];return r?r.buffered?a(r)?i.PARTIAL:i.OK:r.backtrack?i.BACKTRACKED:i.APPENDING:i.NOT_LOADED},e.backtrack=function(t,e){var r=l(t),i=this.fragments[r];if(!i||i.backtrack)return null;var n=i.backtrack=e||i.loaded;return i.loaded=null,n},e.getBacktrackData=function(t){var e=l(t),r=this.fragments[e];if(r){var i,n=r.backtrack;if(null!=n&&null!==(i=n.payload)&&void 0!==i&&i.byteLength)return n;this.removeFragment(t)}return null},e.isTimeBuffered=function(t,e,r){for(var i,n,o=0;o<r.length;o++){if(i=r.start(o)-this.bufferPadding,n=r.end(o)+this.bufferPadding,t>=i&&e<=n)return!0;if(e<=i)return!1}return!1},e.onFragLoaded=function(t,e){var r=e.frag,i=e.part;if("initSegment"!==r.sn&&!r.bitrateTest&&!i){var n=l(r);this.fragments[n]={body:r,loaded:e,backtrack:null,buffered:!1,range:Object.create(null)}}},e.onBufferAppended=function(t,e){var r=this,i=e.frag,n=e.part,s=e.timeRanges;if(i.type===o.PlaylistLevelType.MAIN)if(this.activeFragment=i,n){var a=this.activeParts;a||(this.activeParts=a=[]),a.push(n)}else this.activeParts=null;this.timeRanges=s,Object.keys(s).forEach((function(t){var e=s[t];if(r.detectEvictedFragments(t,e),!n)for(var o=0;o<e.length;o++)i.appendedPTS=Math.max(e.end(o),i.appendedPTS||0)}))},e.onFragBuffered=function(t,e){this.detectPartialFragments(e)},e.hasFragment=function(t){var e=l(t);return!!this.fragments[e]},e.removeFragmentsInRange=function(t,e,r){var i=this;Object.keys(this.fragments).forEach((function(n){var o=i.fragments[n];if(o&&o.buffered){var s=o.body;s.type===r&&s.start<e&&s.end>t&&i.removeFragment(s)}}))},e.removeFragment=function(t){var e=l(t);t.stats.loaded=0,t.clearElementaryStreamInfo(),delete this.fragments[e]},e.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},t}();function a(t){var e,r;return t.buffered&&((null===(e=t.range.video)||void 0===e?void 0:e.partial)||(null===(r=t.range.audio)||void 0===r?void 0:r.partial))}function l(t){return t.type+"_"+t.level+"_"+t.urlId+"_"+t.sn}},"./src/controller/gap-controller.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/controller/gap-controller.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: STALL_MINIMUM_DURATION_MS, MAX_START_GAP_JUMP, SKIP_BUFFER_HOLE_STEP_SECONDS, SKIP_BUFFER_RANGE_START, default */function(t,e,r){"use strict";r.r(e),r.d(e,"STALL_MINIMUM_DURATION_MS",(function(){return a})),r.d(e,"MAX_START_GAP_JUMP",(function(){return l})),r.d(e,"SKIP_BUFFER_HOLE_STEP_SECONDS",(function(){return c})),r.d(e,"SKIP_BUFFER_RANGE_START",(function(){return u})),r.d(e,"default",(function(){return h}));var i=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),n=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=250,l=2,c=.1,u=.05,h=function(){function t(t,e,r,i){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=t,this.media=e,this.fragmentTracker=r,this.hls=i}var e=t.prototype;return e.destroy=function(){this.hls=this.fragmentTracker=this.media=null},e.poll=function(t){var e=this.config,r=this.media,n=this.stalled,o=r.currentTime,c=r.seeking,u=this.seeking&&!c,h=!this.seeking&&c;if(this.seeking=c,o===t){if((h||u)&&(this.stalled=null),!r.paused&&!r.ended&&0!==r.playbackRate&&i.BufferHelper.getBuffered(r).length){var d=i.BufferHelper.bufferInfo(r,o,0),f=d.len>0,p=d.nextStart||0;if(f||p){if(c){var g=d.len>l,m=!p||p-o>l&&!this.fragmentTracker.getPartialFragment(o);if(g||m)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var v,y=Math.max(p,d.start||0)-o,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,x=(null==b||null===(v=b.details)||void 0===v?void 0:v.live)?2*b.details.targetduration:l;if(y>0&&y<=x)return void this._trySkipBufferHole(null)}var S=self.performance.now();if(null!==n){var C=S-n;!c&&C>=a&&this._reportStall(d.len);var w=i.BufferHelper.bufferInfo(r,o,e.maxBufferHole);this._tryFixBufferStall(w,C)}else this.stalled=S}}}else if(this.moved=!0,null!==n){if(this.stallReported){var k=self.performance.now()-n;s.logger.warn("playback not stuck anymore @"+o+", after "+Math.round(k)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},e._tryFixBufferStall=function(t,e){var r=this.config,i=this.fragmentTracker,n=this.media.currentTime,o=i.getPartialFragment(n);o&&this._trySkipBufferHole(o)||t.len>r.maxBufferHole&&e>1e3*r.highBufferWatchdogPeriod&&(s.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},e._reportStall=function(t){var e=this.hls,r=this.media;this.stallReported||(this.stallReported=!0,s.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer (buffer="+t+")"),e.trigger(o.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:t}))},e._trySkipBufferHole=function(t){for(var e=this.config,r=this.hls,a=this.media,l=a.currentTime,h=0,d=i.BufferHelper.getBuffered(a),f=0;f<d.length;f++){var p=d.start(f);if(l+e.maxBufferHole>=h&&l<p){var g=Math.max(p+u,a.currentTime+c);return s.logger.warn("skipping hole, adjusting currentTime from "+l+" to "+g),this.moved=!0,this.stalled=null,a.currentTime=g,t&&r.trigger(o.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+l+" to "+g,frag:t}),g}h=d.end(f)}return 0},e._tryNudgeBuffer=function(){var t=this.config,e=this.hls,r=this.media,i=r.currentTime,a=(this.nudgeRetry||0)+1;if(this.nudgeRetry=a,a<t.nudgeMaxRetry){var l=i+a*t.nudgeOffset;s.logger.warn("Nudging 'currentTime' from "+i+" to "+l),r.currentTime=l,e.trigger(o.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else s.logger.error("Playhead still not moving while enough data buffered @"+i+" after "+t.nudgeMaxRetry+" nudges"),e.trigger(o.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},t}()},"./src/controller/id3-track-controller.ts":
|
|
|
/*!************************************************!*\
|
|
|
!*** ./src/controller/id3-track-controller.ts ***!
|
|
|
\************************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),o=r(/*! ../demux/id3 */"./src/demux/id3.ts"),s=function(){function t(t){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=t,this._registerListeners()}var e=t.prototype;return e.destroy=function(){this._unregisterListeners()},e._registerListeners=function(){var t=this.hls;t.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(i.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},e._unregisterListeners=function(){var t=this.hls;t.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(i.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},e.onMediaAttached=function(t,e){this.media=e.media},e.onMediaDetaching=function(){this.id3Track&&(Object(n.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null)},e.getID3Track=function(t){if(this.media){for(var e=0;e<t.length;e++){var r=t[e];if("metadata"===r.kind&&"id3"===r.label)return Object(n.sendAddTrackEvent)(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},e.onFragParsingMetadata=function(t,e){if(this.media){var r=e.frag,i=e.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var n=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,s=0;s<i.length;s++){var a=o.getID3Frames(i[s].data);if(a){var l=i[s].pts,c=s<i.length-1?i[s+1].pts:r.end;c-l<=0&&(c=l+.25);for(var u=0;u<a.length;u++){var h=a[u];if(!o.isTimeStampFrame(h)){var d=new n(l,c,"");d.value=h,this.id3Track.addCue(d)}}}}}},e.onBufferFlushing=function(t,e){var r=e.startOffset,i=e.endOffset,o=e.type;if(!o||"audio"===o){var s=this.id3Track;s&&Object(n.removeCuesInRange)(s,r,i)}},t}();e.default=s},"./src/controller/latency-controller.ts":
|
|
|
/*!**********************************************!*\
|
|
|
!*** ./src/controller/latency-controller.ts ***!
|
|
|
\**********************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return a}));var i=r(/*! ../errors */"./src/errors.ts"),n=r(/*! ../events */"./src/events.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts");function s(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var a=function(){function t(t){var e=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return e.timeupdate()},this.hls=t,this.config=t.config,this.registerListeners()}var e,r,a,l=t.prototype;return l.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},l.registerListeners=function(){this.hls.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(n.Events.ERROR,this.onError,this)},l.unregisterListeners=function(){this.hls.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(n.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(n.Events.ERROR,this.onError)},l.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},l.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},l.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},l.onLevelUpdated=function(t,e){var r=e.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},l.onError=function(t,e){e.details===i.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,o.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},l.timeupdate=function(){var t=this.media,e=this.levelDetails;if(t&&e){this.currentTime=t.currentTime;var r=this.computeLatency();if(null!==r){this._latency=r;var i=this.config,n=i.lowLatencyMode,o=i.maxLiveSyncPlaybackRate;if(n&&1!==o){var s=this.targetLatency;if(null!==s){var a=r-s,l=a<Math.min(this.maxLatency,s+e.targetduration);if(e.live&&l&&a>.05&&this.forwardBufferLength>1){var c=Math.min(2,Math.max(1,o)),u=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20;t.playbackRate=Math.min(c,Math.max(1,u))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}}}}},l.estimateLiveEdge=function(){var t=this.levelDetails;return null===t?null:t.edge+t.age},l.computeLatency=function(){var t=this.estimateLiveEdge();return null===t?null:t-this.currentTime},e=t,(r=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config,e=this.levelDetails;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(null===t)return null;var e=t.holdBack,r=t.partHoldBack,i=t.targetduration,n=this.config,o=n.liveSyncDuration,s=n.liveSyncDurationCount,a=n.lowLatencyMode,l=this.hls.userConfig,c=a&&r||e;(l.liveSyncDuration||l.liveSyncDurationCount||0===c)&&(c=void 0!==o?o:s*i);var u=i;return c+Math.min(1*this.stallCount,u)}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),e=this.targetLatency,r=this.levelDetails;if(null===t||null===e||null===r)return null;var i=r.edge,n=t-e-this.edgeStalled,o=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(o,n),s)}},{key:"drift",get:function(){var t=this.levelDetails;return null===t?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;if(null===t)return 0;var e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration);return Math.max(t.age-e,0)}},{key:"forwardBufferLength",get:function(){var t=this.media,e=this.levelDetails;if(!t||!e)return 0;var r=t.buffered.length;return r?t.buffered.end(r-1):e.edge-this.currentTime}}])&&s(e.prototype,r),a&&s(e,a),t}()},"./src/controller/level-controller.ts":
|
|
|
/*!********************************************!*\
|
|
|
!*** ./src/controller/level-controller.ts ***!
|
|
|
\********************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return p}));var i=r(/*! ../types/level */"./src/types/level.ts"),n=r(/*! ../events */"./src/events.ts"),o=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../utils/codecs */"./src/utils/codecs.ts"),a=r(/*! ./level-helper */"./src/controller/level-helper.ts"),l=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),c=r(/*! ../types/loader */"./src/types/loader.ts");function u(){return(u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function h(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function d(t,e){return(d=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var f=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),p=function(t){var e,r;function l(e){var r;return(r=t.call(this,e,"[level-controller]")||this)._levels=[],r._firstLevel=-1,r._startLevel=void 0,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.onParsedComplete=void 0,r._registerListeners(),r}r=t,(e=l).prototype=Object.create(r.prototype),e.prototype.constructor=e,d(e,r);var p,g,m,v=l.prototype;return v._registerListeners=function(){var t=this.hls;t.on(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(n.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(n.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(n.Events.ERROR,this.onError,this)},v._unregisterListeners=function(){var t=this.hls;t.off(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(n.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(n.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(n.Events.ERROR,this.onError,this)},v.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,t.prototype.destroy.call(this)},v.startLoad=function(){this._levels.forEach((function(t){t.loadError=0})),t.prototype.startLoad.call(this)},v.onManifestLoaded=function(t,e){var r,l,c=[],u=[],h=[],d={},p=!1,g=!1,m=!1;if(e.levels.forEach((function(t){var e=t.attrs;p=p||!(!t.width||!t.height),g=g||!!t.videoCodec,m=m||!!t.audioCodec,f&&t.audioCodec&&-1!==t.audioCodec.indexOf("mp4a.40.34")&&(t.audioCodec=void 0);var r=t.bitrate+"-"+t.attrs.RESOLUTION+"-"+t.attrs.CODECS;(l=d[r])?l.url.push(t.url):(l=new i.Level(t),d[r]=l,c.push(l)),e&&(e.AUDIO&&Object(a.addGroupId)(l,"audio",e.AUDIO),e.SUBTITLES&&Object(a.addGroupId)(l,"text",e.SUBTITLES))})),(p||g)&&m&&(c=c.filter((function(t){var e=t.videoCodec,r=t.width,i=t.height;return!!e||!(!r||!i)}))),c=c.filter((function(t){var e=t.audioCodec,r=t.videoCodec;return(!e||Object(s.isCodecSupportedInMp4)(e,"audio"))&&(!r||Object(s.isCodecSupportedInMp4)(r,"video"))})),e.audioTracks&&(u=e.audioTracks.filter((function(t){return!t.audioCodec||Object(s.isCodecSupportedInMp4)(t.audioCodec,"audio")})),Object(a.assignTrackIdsByGroup)(u)),e.subtitles&&(h=e.subtitles,Object(a.assignTrackIdsByGroup)(h)),c.length>0){r=c[0].bitrate,c.sort((function(t,e){return t.bitrate-e.bitrate})),this._levels=c;for(var v=0;v<c.length;v++)if(c[v].bitrate===r){this._firstLevel=v,this.log("manifest loaded, "+c.length+" level(s) found, first bitrate: "+r);break}var y=m&&!g,b={levels:c,audioTracks:u,subtitleTracks:h,firstLevel:this._firstLevel,stats:e.stats,audio:m,video:g,altAudio:!y&&u.some((function(t){return!!t.url}))};this.hls.trigger(n.Events.MANIFEST_PARSED,b),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(n.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,reason:"no level with compatible codecs found in manifest"})},v.onError=function(e,r){if(t.prototype.onError.call(this,e,r),!r.fatal){var i=r.context,n=this._levels[this.currentLevelIndex];if(i&&(i.type===c.PlaylistContextType.AUDIO_TRACK&&n.audioGroupIds&&i.groupId===n.audioGroupIds[n.urlId]||i.type===c.PlaylistContextType.SUBTITLE_TRACK&&n.textGroupIds&&i.groupId===n.textGroupIds[n.urlId]))this.redundantFailover(this.currentLevelIndex);else{var s,a=!1,l=!0;switch(r.details){case o.ErrorDetails.FRAG_LOAD_ERROR:case o.ErrorDetails.FRAG_LOAD_TIMEOUT:case o.ErrorDetails.KEY_LOAD_ERROR:case o.ErrorDetails.KEY_LOAD_TIMEOUT:if(r.frag){var u=this._levels[r.frag.level];u?(u.fragmentError++,u.fragmentError>this.hls.config.fragLoadingMaxRetry&&(s=r.frag.level)):s=r.frag.level}break;case o.ErrorDetails.LEVEL_LOAD_ERROR:case o.ErrorDetails.LEVEL_LOAD_TIMEOUT:i&&(i.deliveryDirectives&&(l=!1),s=i.level),a=!0;break;case o.ErrorDetails.REMUX_ALLOC_ERROR:s=r.level,a=!0}void 0!==s&&this.recoverLevel(r,s,a,l)}}},v.recoverLevel=function(t,e,r,i){var n=t.details,o=this._levels[e];if(o.loadError++,r){if(!this.retryLoadingOrFail(t))return void(this.currentLevelIndex=-1);t.levelRetry=!0}if(i){var s=o.url.length;if(s>1&&o.loadError<s)t.levelRetry=!0,this.redundantFailover(e);else if(-1===this.manualLevelIndex){var a=0===e?this._levels.length-1:e-1;this.currentLevelIndex!==a&&0===this._levels[a].loadError&&(this.warn(n+": switch to "+a),t.levelRetry=!0,this.hls.nextAutoLevel=a)}}},v.redundantFailover=function(t){var e=this._levels[t],r=e.url.length;if(r>1){var i=(e.urlId+1)%r;this.warn("Switching to redundant URL-id "+i),this._levels.forEach((function(t){t.urlId=i})),this.level=t}},v.onFragLoaded=function(t,e){var r=e.frag;if(void 0!==r&&r.type===c.PlaylistLevelType.MAIN){var i=this._levels[r.level];void 0!==i&&(i.fragmentError=0,i.loadError=0)}},v.onLevelLoaded=function(t,e){var r,i,n=e.level,o=e.details,s=this._levels[n];if(!s)return this.warn("Invalid level index "+n),void(null!==(i=e.deliveryDirectives)&&void 0!==i&&i.skip&&(o.deltaUpdateFailed=!0));n===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0,this.retryCount=0),this.playlistLoaded(n,e,s.details)):null!==(r=e.deliveryDirectives)&&void 0!==r&&r.skip&&(o.deltaUpdateFailed=!0)},v.onAudioTrackSwitched=function(t,e){var r=this.hls.levels[this.currentLevelIndex];if(r&&r.audioGroupIds){for(var i=-1,n=this.hls.audioTracks[e.id].groupId,o=0;o<r.audioGroupIds.length;o++)if(r.audioGroupIds[o]===n){i=o;break}i!==r.urlId&&(r.urlId=i,this.startLoad())}},v.loadPlaylist=function(t){var e=this.currentLevelIndex,r=this._levels[e];if(this.canLoad&&r&&r.url.length>0){var i=r.urlId,o=r.url[i];if(t)try{o=t.addDirectives(o)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Attempt loading level index "+e+(t?" at sn "+t.msn+" part "+t.part:"")+" with URL-id "+i+" "+o),this.clearTimer(),this.hls.trigger(n.Events.LEVEL_LOADING,{url:o,level:e,id:i,deliveryDirectives:t||null})}},v.removeLevel=function(t,e){var r=function(t,r){return r!==e},i=this._levels.filter((function(i,n){return n!==t||i.url.length>1&&void 0!==e&&(i.url=i.url.filter(r),i.audioGroupIds&&(i.audioGroupIds=i.audioGroupIds.filter(r)),i.textGroupIds&&(i.textGroupIds=i.textGroupIds.filter(r)),i.urlId=0,!0)})).map((function(t,e){var r=t.details;return null!=r&&r.fragments&&r.fragments.forEach((function(t){t.level=e})),t}));this._levels=i,this.hls.trigger(n.Events.LEVELS_UPDATED,{levels:i})},p=l,(g=[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var e,r=this._levels;if(0!==r.length&&(this.currentLevelIndex!==t||null===(e=r[t])||void 0===e||!e.details)){if(t<0||t>=r.length){var i=t<0;if(this.hls.trigger(n.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.LEVEL_SWITCH_ERROR,level:t,fatal:i,reason:"invalid level idx"}),i)return;t=Math.min(t,r.length-1)}this.clearTimer();var s=this.currentLevelIndex,a=r[s],l=r[t];this.log("switching to level "+t+" from "+s),this.currentLevelIndex=t;var c=u({},l,{level:t,maxBitrate:l.maxBitrate,uri:l.uri,urlId:l.urlId});delete c._urlId,this.hls.trigger(n.Events.LEVEL_SWITCHING,c);var h=l.details;if(!h||h.live){var d=this.switchParams(l.uri,null==a?void 0:a.details);this.loadPlaylist(d)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}}])&&h(p.prototype,g),m&&h(p,m),l}(l.default)},"./src/controller/level-helper.ts":
|
|
|
/*!****************************************!*\
|
|
|
!*** ./src/controller/level-helper.ts ***!
|
|
|
\****************************************/
|
|
|
/*! exports provided: addGroupId, assignTrackIdsByGroup, updatePTS, updateFragPTSDTS, mergeDetails, mapPartIntersection, mapFragmentIntersection, adjustSliding, addSliding, computeReloadInterval, getFragmentWithSN, getPartWith */function(t,e,r){"use strict";r.r(e),r.d(e,"addGroupId",(function(){return o})),r.d(e,"assignTrackIdsByGroup",(function(){return s})),r.d(e,"updatePTS",(function(){return a})),r.d(e,"updateFragPTSDTS",(function(){return c})),r.d(e,"mergeDetails",(function(){return u})),r.d(e,"mapPartIntersection",(function(){return h})),r.d(e,"mapFragmentIntersection",(function(){return d})),r.d(e,"adjustSliding",(function(){return f})),r.d(e,"addSliding",(function(){return p})),r.d(e,"computeReloadInterval",(function(){return g})),r.d(e,"getFragmentWithSN",(function(){return m})),r.d(e,"getPartWith",(function(){return v}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/logger */"./src/utils/logger.ts");function o(t,e,r){switch(e){case"audio":t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds.push(r);break;case"text":t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds.push(r)}}function s(t){var e={};t.forEach((function(t){var r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++}))}function a(t,e,r){l(t[e],t[r])}function l(t,e){var r=e.startPTS;if(Object(i.isFiniteNumber)(r)){var n,o=0;e.sn>t.sn?(o=r-t.start,n=t):(o=t.start-r,n=e),n.duration!==o&&(n.duration=o)}else e.sn>t.sn?t.cc===e.cc&&t.minEndPTS?e.start=t.start+(t.minEndPTS-t.start):e.start=t.start+t.duration:e.start=Math.max(t.start-e.duration,0)}function c(t,e,r,o,s,a){o-r<=0&&(n.logger.warn("Fragment should have a positive duration",e),o=r+e.duration,a=s+e.duration);var c=r,u=o,h=e.startPTS,d=e.endPTS;if(Object(i.isFiniteNumber)(h)){var f=Math.abs(h-r);Object(i.isFiniteNumber)(e.deltaPTS)?e.deltaPTS=Math.max(f,e.deltaPTS):e.deltaPTS=f,c=Math.max(r,h),r=Math.min(r,h),s=Math.min(s,e.startDTS),u=Math.min(o,d),o=Math.max(o,d),a=Math.max(a,e.endDTS)}e.duration=o-r;var p=r-e.start;e.appendedPTS=o,e.start=e.startPTS=r,e.maxStartPTS=c,e.startDTS=s,e.endPTS=o,e.minEndPTS=u,e.endDTS=a;var g,m=e.sn;if(!t||m<t.startSN||m>t.endSN)return 0;var v=m-t.startSN,y=t.fragments;for(y[v]=e,g=v;g>0;g--)l(y[g],y[g-1]);for(g=v;g<y.length-1;g++)l(y[g],y[g+1]);return t.fragmentHint&&l(y[y.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,p}function u(t,e){for(var r=null,o=t.fragments,s=o.length-1;s>=0;s--){var a=o[s].initSegment;if(a){r=a;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var l,u=0;if(d(t,e,(function(t,n){t.relurl&&(u=t.cc-n.cc),Object(i.isFiniteNumber)(t.startPTS)&&Object(i.isFiniteNumber)(t.endPTS)&&(n.start=n.startPTS=t.startPTS,n.startDTS=t.startDTS,n.appendedPTS=t.appendedPTS,n.maxStartPTS=t.maxStartPTS,n.endPTS=t.endPTS,n.endDTS=t.endDTS,n.minEndPTS=t.minEndPTS,n.duration=t.endPTS-t.startPTS,n.duration&&(l=n),e.PTSKnown=e.alignedSliding=!0),n.elementaryStreams=t.elementaryStreams,n.loader=t.loader,n.stats=t.stats,n.urlId=t.urlId,t.initSegment&&(n.initSegment=t.initSegment,r=t.initSegment)})),r&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach((function(t){var e;t.initSegment&&t.initSegment.relurl!==(null===(e=r)||void 0===e?void 0:e.relurl)||(t.initSegment=r)})),e.skippedSegments&&(e.deltaUpdateFailed=e.fragments.some((function(t){return!t})),e.deltaUpdateFailed)){n.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var p=e.skippedSegments;p--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}var g=e.fragments;if(u){n.logger.warn("discontinuity sliding from playlist, take drift into account");for(var m=0;m<g.length;m++)g[m].cc+=u}e.skippedSegments&&(e.startCC=e.fragments[0].cc),h(t.partList,e.partList,(function(t,e){e.elementaryStreams=t.elementaryStreams,e.stats=t.stats})),l?c(e,l,l.startPTS,l.endPTS,l.startDTS,l.endDTS):f(t,e),g.length&&(e.totalduration=e.edge-g[0].start),e.driftStartTime=t.driftStartTime,e.driftStart=t.driftStart;var v=e.advancedDateTime;if(e.advanced&&v){var y=e.edge;e.driftStart||(e.driftStartTime=v,e.driftStart=y),e.driftEndTime=v,e.driftEnd=y}else e.driftEndTime=t.driftEndTime,e.driftEnd=t.driftEnd,e.advancedDateTime=t.advancedDateTime}function h(t,e,r){if(t&&e)for(var i=0,n=0,o=t.length;n<=o;n++){var s=t[n],a=e[n+i];s&&a&&s.index===a.index&&s.fragment.sn===a.fragment.sn?r(s,a):i--}}function d(t,e,r){for(var i=e.skippedSegments,n=Math.max(t.startSN,e.startSN)-e.startSN,o=(t.fragmentHint?1:0)+(i?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,s=e.startSN-t.startSN,a=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,c=n;c<=o;c++){var u=l[s+c],h=a[c];i&&!h&&c<i&&(h=e.fragments[c]=u),u&&h&&r(u,h)}}function f(t,e){var r=e.startSN+e.skippedSegments-t.startSN,i=t.fragments;r<0||r>=i.length||p(e,i[r].start)}function p(t,e){if(e){for(var r=t.fragments,i=t.skippedSegments;i<r.length;i++)r[i].start+=e;t.fragmentHint&&(t.fragmentHint.start+=e)}}function g(t,e){var r,i=1e3*t.levelTargetDuration,n=i/2,o=t.age,s=o>0&&o<3*i,a=e.loading.end-e.loading.start,l=t.availabilityDelay;if(!1===t.updated)if(s){var c=333*t.misses;r=Math.max(Math.min(n,2*a),c),t.availabilityDelay=(t.availabilityDelay||0)+r}else r=n;else s?(l=Math.min(l||i/2,o),t.availabilityDelay=l,r=l+i-o):r=i-a;return Math.round(r)}function m(t,e,r){if(!t||!t.details)return null;var i=t.details,n=i.fragments[e-i.startSN];return n||((n=i.fragmentHint)&&n.sn===e?n:e<i.startSN&&r&&r.sn===e?r:null)}function v(t,e,r){if(!t||!t.details)return null;var i=t.details.partList;if(i)for(var n=i.length;n--;){var o=i[n];if(o.index===r&&o.fragment.sn===e)return o}return null}},"./src/controller/stream-controller.ts":
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./src/controller/stream-controller.ts ***!
|
|
|
\*********************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return y}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),o=r(/*! ../is-supported */"./src/is-supported.ts"),s=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),c=r(/*! ../types/loader */"./src/types/loader.ts"),u=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),h=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),d=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),f=r(/*! ./gap-controller */"./src/controller/gap-controller.ts"),p=r(/*! ../errors */"./src/errors.ts"),g=r(/*! ../utils/logger */"./src/utils/logger.ts");function m(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function v(t,e){return(v=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var y=function(t){var e,r;function y(e,r){var i;return(i=t.call(this,e,r,"[stream-controller]")||this).audioCodecSwap=!1,i.gapController=null,i.level=-1,i._forceStartLoad=!1,i.altAudio=!1,i.audioOnly=!1,i.fragPlaying=null,i.onvplaying=null,i.onvseeked=null,i.fragLastKbps=0,i.stalled=!1,i.couldBacktrack=!1,i.audioCodecSwitch=!1,i.videoBuffer=null,i._registerListeners(),i}r=t,(e=y).prototype=Object.create(r.prototype),e.prototype.constructor=e,v(e,r);var b,x,S,C=y.prototype;return C._registerListeners=function(){var t=this.hls;t.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(s.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(s.Events.ERROR,this.onError,this),t.on(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(s.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(s.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(s.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},C._unregisterListeners=function(){var t=this.hls;t.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(s.Events.ERROR,this.onError,this),t.off(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(s.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(s.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(s.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},C.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},C.startLoad=function(t){if(this.levels){var e=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var i=r.startLevel;-1===i&&(r.config.testBandwidth?(i=0,this.bitrateTest=!0):i=r.nextAutoLevel),this.level=r.nextLoadLevel=i,this.loadedmetadata=!1}e>0&&-1===t&&(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e),this.state=n.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=n.State.STOPPED},C.stopLoad=function(){this._forceStartLoad=!1,t.prototype.stopLoad.call(this)},C.doTick=function(){switch(this.state){case n.State.IDLE:this.doTickIdle();break;case n.State.WAITING_LEVEL:var t,e=this.levels,r=this.level,i=null==e||null===(t=e[r])||void 0===t?void 0:t.details;if(i&&(!i.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(i))break;this.state=n.State.IDLE;break}break;case n.State.FRAG_LOADING_WAITING_RETRY:var o,s=self.performance.now(),a=this.retryDate;(!a||s>=a||null!==(o=this.media)&&void 0!==o&&o.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=n.State.IDLE)}this.onTickEnd()},C.onTickEnd=function(){t.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},C.doTickIdle=function(){var t,e,r=this.hls,i=this.levelLastLoaded,o=this.levels,a=this.media,h=r.config,d=r.nextLoadLevel;if(null!==i&&(a||!this.startFragRequested&&h.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&o&&o[d]){var f=o[d];this.level=r.nextLoadLevel=d;var p=f.details;if(!p||this.state===n.State.WAITING_LEVEL||p.live&&this.levelLastLoaded!==d)this.state=n.State.WAITING_LEVEL;else{var g=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:a,c.PlaylistLevelType.MAIN);if(null!==g&&!(g.len>=this.getMaxBufferLength(f.maxBitrate))){if(this._streamEnded(g,p)){var m={};return this.altAudio&&(m.type="video"),this.hls.trigger(s.Events.BUFFER_EOS,m),void(this.state=n.State.ENDED)}var v=g.end,y=this.getNextFragment(v,p);if(this.couldBacktrack&&!this.fragPrevious&&y&&"initSegment"!==y.sn){var b=y.sn-p.startSN;b>1&&(y=p.fragments[b-1],this.fragmentTracker.removeFragment(y))}if(y&&this.fragmentTracker.getState(y)===l.FragmentState.OK&&this.nextLoadPosition>v){var x=this.audioOnly&&!this.altAudio?u.ElementaryStreamTypes.AUDIO:u.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(a,x,c.PlaylistLevelType.MAIN),y=this.getNextFragment(this.nextLoadPosition,p)}y&&(!y.initSegment||y.initSegment.data||this.bitrateTest||(y=y.initSegment),"identity"!==(null===(t=y.decryptdata)||void 0===t?void 0:t.keyFormat)||null!==(e=y.decryptdata)&&void 0!==e&&e.key?this.loadFragment(y,p,v):this.loadKey(y,p))}}}},C.loadFragment=function(e,r,i){var n,o=this.fragmentTracker.getState(e);if(this.fragCurrent=e,o===l.FragmentState.BACKTRACKED){var s=this.fragmentTracker.getBacktrackData(e);if(s)return this._handleFragmentLoadProgress(s),void this._handleFragmentLoadComplete(s);o=l.FragmentState.NOT_LOADED}o===l.FragmentState.NOT_LOADED||o===l.FragmentState.PARTIAL?"initSegment"===e.sn?this._loadInitSegment(e):this.bitrateTest?(e.bitrateTest=!0,this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e)):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,e,r,i)):o===l.FragmentState.APPENDING?this.reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e):0===(null===(n=this.media)||void 0===n?void 0:n.buffered.length)&&this.fragmentTracker.removeAllFragments()},C.getAppendedFrag=function(t){var e=this.fragmentTracker.getAppendedFrag(t,c.PlaylistLevelType.MAIN);return e&&"fragment"in e?e.fragment:e},C.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,c.PlaylistLevelType.MAIN)},C.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},C.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},C.nextLevelSwitch=function(){var t=this.levels,e=this.media;if(null!=e&&e.readyState){var r,i=this.getAppendedFrag(e.currentTime);if(i&&i.start>1&&this.flushMainBuffer(0,i.start-1),!e.paused&&t){var n=t[this.hls.nextLoadLevel],o=this.fragLastKbps;r=o&&this.fragCurrent?this.fragCurrent.duration*n.maxBitrate/(1e3*o)+1:0}else r=0;var s=this.getBufferedFrag(e.currentTime+r);if(s){var a=this.followingBufferedFrag(s);if(a){this.abortCurrentFrag();var l=a.maxStartPTS?a.maxStartPTS:a.start,c=a.duration,u=Math.max(s.end,l+Math.min(Math.max(c-this.config.maxFragLookUpTolerance,.5*c),.75*c));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}},C.abortCurrentFrag=function(){var t=this.fragCurrent;this.fragCurrent=null,null!=t&&t.loader&&t.loader.abort(),this.state===n.State.KEY_LOADING&&(this.state=n.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},C.flushMainBuffer=function(e,r){t.prototype.flushMainBuffer.call(this,e,r,this.altAudio?"video":null)},C.onMediaAttached=function(e,r){t.prototype.onMediaAttached.call(this,e,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new f.default(this.config,i,this.fragmentTracker,this.hls)},C.onMediaDetaching=function(){var e=this.media;e&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),t.prototype.onMediaDetaching.call(this)},C.onMediaPlaying=function(){this.tick()},C.onMediaSeeked=function(){var t=this.media,e=t?t.currentTime:null;Object(i.isFiniteNumber)(e)&&this.log("Media seeked to "+e.toFixed(3)),this.tick()},C.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(s.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},C.onManifestParsed=function(t,e){var r,i=!1,n=!1;e.levels.forEach((function(t){(r=t.audioCodec)&&(-1!==r.indexOf("mp4a.40.2")&&(i=!0),-1!==r.indexOf("mp4a.40.5")&&(n=!0))})),this.audioCodecSwitch=i&&n&&!Object(o.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1},C.onLevelLoading=function(t,e){var r=this.levels;if(r&&this.state===n.State.IDLE){var i=r[e.level];(!i.details||i.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(i.details))&&(this.state=n.State.WAITING_LEVEL)}},C.onLevelLoaded=function(t,e){var r,i=this.levels,o=e.level,a=e.details,l=a.totalduration;if(i){this.log("Level "+o+" loaded ["+a.startSN+","+a.endSN+"], cc ["+a.startCC+", "+a.endCC+"] duration:"+l);var c=this.fragCurrent;!c||this.state!==n.State.FRAG_LOADING&&this.state!==n.State.FRAG_LOADING_WAITING_RETRY||c.level!==e.level&&c.loader&&(this.state=n.State.IDLE,c.loader.abort());var u=i[o],h=0;if(a.live||null!==(r=u.details)&&void 0!==r&&r.live){if(a.fragments[0]||(a.deltaUpdateFailed=!0),a.deltaUpdateFailed)return;h=this.alignPlaylists(a,u.details)}if(u.details=a,this.levelLastLoaded=o,this.hls.trigger(s.Events.LEVEL_UPDATED,{details:a,level:o}),this.state===n.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=n.State.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,h),this.tick()}else this.warn("Levels were reset while loading level "+o)},C._handleFragmentLoadProgress=function(t){var e,r=t.frag,i=t.part,n=t.payload,o=this.levels;if(o){var s=o[r.level],a=s.details;if(a){var l=s.videoCodec,u=a.PTSKnown||!a.live,f=null===(e=r.initSegment)||void 0===e?void 0:e.data,p=this._getAudioCodec(s),g=this.transmuxer=this.transmuxer||new h.default(this.hls,c.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=i?i.index:-1,v=-1!==m,y=new d.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,n.byteLength,m,v),b=this.initPTS[r.cc];g.push(n,f,p,l,r,i,a.totalduration,u,y,b)}else this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},C.onAudioTrackSwitching=function(t,e){var r=this.altAudio,i=!!e.url,n=e.id;if(!i){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var o=this.fragCurrent;null!=o&&o.loader&&(this.log("Switching to main audio track, cancel main fragment load"),o.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var a=this.hls;r&&a.trigger(s.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),a.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:n})}},C.onAudioTrackSwitched=function(t,e){var r=e.id,i=!!this.hls.audioTracks[r].url;if(i){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=i,this.tick()},C.onBufferCreated=function(t,e){var r,i,n=e.tracks,o=!1;for(var s in n){var a=n[s];if("main"===a.id){if(i=s,r=a,"video"===s){var l=n[s];l&&(this.videoBuffer=l.buffer)}}else o=!0}o&&r?(this.log("Alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},C.onFragBuffered=function(t,e){var r=e.frag,i=e.part;if(!r||r.type===c.PlaylistLevelType.MAIN){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(i?" p: "+i.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===n.State.PARSED&&(this.state=n.State.IDLE));var o=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}},C.onError=function(t,e){switch(e.details){case p.ErrorDetails.FRAG_LOAD_ERROR:case p.ErrorDetails.FRAG_LOAD_TIMEOUT:case p.ErrorDetails.KEY_LOAD_ERROR:case p.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(c.PlaylistLevelType.MAIN,e);break;case p.ErrorDetails.LEVEL_LOAD_ERROR:case p.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==n.State.ERROR&&(e.fatal?(this.warn(""+e.details),this.state=n.State.ERROR):e.levelRetry||this.state!==n.State.WAITING_LEVEL||(this.state=n.State.IDLE));break;case p.ErrorDetails.BUFFER_FULL_ERROR:if("main"===e.parent&&(this.state===n.State.PARSING||this.state===n.State.PARSED)){var r=!0,i=this.getFwdBufferInfo(this.media,c.PlaylistLevelType.MAIN);i&&i.len>.5&&(r=!this.reduceMaxBufferLength(i.len)),r&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}},C.checkBuffer=function(){var t=this.media,e=this.gapController;if(t&&e&&t.readyState){var r=a.BufferHelper.getBuffered(t);!this.loadedmetadata&&r.length?(this.loadedmetadata=!0,this.seekToStartPos()):e.poll(this.lastCurrentTime),this.lastCurrentTime=t.currentTime}},C.onFragLoadEmergencyAborted=function(){this.state=n.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},C.onBufferFlushed=function(t,e){var r=e.type;if(r!==u.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var i=(r===u.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,c.PlaylistLevelType.MAIN)}},C.onLevelsUpdated=function(t,e){this.levels=e.levels},C.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},C.seekToStartPos=function(){var t=this.media,e=t.currentTime,r=this.startPosition;if(r>=0&&e<r){if(t.seeking)return void g.logger.log("could not seek to "+r+", already seeking at "+e);var i=a.BufferHelper.getBuffered(t),n=(i.length?i.start(0):0)-r;n>0&&(n<this.config.maxBufferHole||n<this.config.maxFragLookUpTolerance)&&(g.logger.log("adjusting start position by "+n+" to match buffer start"),r+=n,this.startPosition=r),this.log("seek to target start position "+r+" from current time "+e),t.currentTime=r}},C._getAudioCodec=function(t){var e=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e=-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),e},C._loadBitrateTestFrag=function(t){var e=this;this._doFragLoad(t).then((function(r){var i=e.hls;if(r&&!i.nextLoadLevel&&!e.fragContextChanged(t)){e.fragLoadError=0,e.state=n.State.IDLE,e.startFragRequested=!1,e.bitrateTest=!1;var o=t.stats;o.parsing.start=o.parsing.end=o.buffering.start=o.buffering.end=self.performance.now(),i.trigger(s.Events.FRAG_LOADED,r)}}))},C._handleTransmuxComplete=function(t){var e,r="main",o=this.hls,a=t.remuxResult,l=t.chunkMeta,c=this.getCurrentContext(l);if(!c)return this.warn("The loading context changed while buffering fragment "+l.sn+" of level "+l.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(l.level);var h=c.frag,d=c.part,f=c.level,p=a.video,g=a.text,m=a.id3,v=a.initSegment,y=this.altAudio?void 0:a.audio;if(!this.fragContextChanged(h)){if(this.state=n.State.PARSING,v){v.tracks&&(this._bufferInitSegment(f,v.tracks,h,l),o.trigger(s.Events.FRAG_PARSING_INIT_SEGMENT,{frag:h,id:r,tracks:v.tracks}));var b=v.initPTS,x=v.timescale;Object(i.isFiniteNumber)(b)&&(this.initPTS[h.cc]=b,o.trigger(s.Events.INIT_PTS_FOUND,{frag:h,id:r,initPTS:b,timescale:x}))}if(p&&!1!==a.independent){if(f.details){var S=p.startPTS,C=p.endPTS,w=p.startDTS,k=p.endDTS;if(d)d.elementaryStreams[p.type]={startPTS:S,endPTS:C,startDTS:w,endDTS:k};else if(p.firstKeyFrame&&p.independent&&(this.couldBacktrack=!0),p.dropped&&p.independent){if(this.getLoadPosition()+this.config.maxBufferHole<S)return void this.backtrack(h);h.setElementaryStreamInfo(p.type,h.start,C,h.start,k,!0)}h.setElementaryStreamInfo(p.type,S,C,w,k),this.bufferFragmentData(p,h,d,l)}}else if(!1===a.independent)return void this.backtrack(h);if(y){var E=y.startPTS,T=y.endPTS,L=y.startDTS,A=y.endDTS;d&&(d.elementaryStreams[u.ElementaryStreamTypes.AUDIO]={startPTS:E,endPTS:T,startDTS:L,endDTS:A}),h.setElementaryStreamInfo(u.ElementaryStreamTypes.AUDIO,E,T,L,A),this.bufferFragmentData(y,h,d,l)}if(null!=m&&null!==(e=m.samples)&&void 0!==e&&e.length){var D={frag:h,id:r,samples:m.samples};o.trigger(s.Events.FRAG_PARSING_METADATA,D)}if(g){var O={frag:h,id:r,samples:g.samples};o.trigger(s.Events.FRAG_PARSING_USERDATA,O)}}},C._bufferInitSegment=function(t,e,r,i){var o=this;if(this.state===n.State.PARSING){this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;var a=e.audio,l=e.video,c=e.audiovideo;if(a){var u=t.audioCodec,h=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==a.metadata.channelCount&&-1===h.indexOf("firefox")&&(u="mp4a.40.5")),-1!==h.indexOf("android")&&"audio/mpeg"!==a.container&&(u="mp4a.40.2",this.log("Android: force audio codec to "+u)),t.audioCodec&&t.audioCodec!==u&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+u+'"'),a.levelCodec=u,a.id="main",this.log("Init audio buffer, container:"+a.container+", codecs[selected/level/parsed]=["+(u||"")+"/"+(t.audioCodec||"")+"/"+a.codec+"]")}l&&(l.levelCodec=t.videoCodec,l.id="main",this.log("Init video buffer, container:"+l.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+l.codec+"]")),c&&this.log("Init audiovideo buffer, container:"+c.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+c.codec+"]"),this.hls.trigger(s.Events.BUFFER_CODECS,e),Object.keys(e).forEach((function(t){var n=e[t].initSegment;null!=n&&n.byteLength&&o.hls.trigger(s.Events.BUFFER_APPENDING,{type:t,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})})),this.tick()}},C.backtrack=function(t){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(t);var e=this.fragmentTracker.backtrack(t);this.fragPrevious=null,this.nextLoadPosition=t.start,e?this.resetFragmentLoading(t):this.state=n.State.BACKTRACKING},C.checkFragmentChanged=function(){var t=this.media,e=null;if(t&&t.readyState>1&&!1===t.seeking){var r=t.currentTime;if(a.BufferHelper.isBuffered(t,r)?e=this.getAppendedFrag(r):a.BufferHelper.isBuffered(t,r+.1)&&(e=this.getAppendedFrag(r+.1)),e){var i=this.fragPlaying,n=e.level;i&&e.sn===i.sn&&i.level===n&&e.urlId===i.urlId||(this.hls.trigger(s.Events.FRAG_CHANGED,{frag:e}),i&&i.level===n||this.hls.trigger(s.Events.LEVEL_SWITCHED,{level:n}),this.fragPlaying=e)}}},b=y,(x=[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentLevel",get:function(){var t=this.media;if(t){var e=this.getAppendedFrag(t.currentTime);if(e)return e.level}return-1}},{key:"nextBufferedFrag",get:function(){var t=this.media;if(t){var e=this.getAppendedFrag(t.currentTime);return this.followingBufferedFrag(e)}return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&m(b.prototype,x),S&&m(b,S),y}(n.default)},"./src/controller/subtitle-stream-controller.ts":
|
|
|
/*!******************************************************!*\
|
|
|
!*** ./src/controller/subtitle-stream-controller.ts ***!
|
|
|
\******************************************************/
|
|
|
/*! exports provided: SubtitleStreamController */function(t,e,r){"use strict";r.r(e),r.d(e,"SubtitleStreamController",(function(){return g}));var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),s=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),a=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),l=r(/*! ./level-helper */"./src/controller/level-helper.ts"),c=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),h=r(/*! ../types/loader */"./src/types/loader.ts"),d=r(/*! ../types/level */"./src/types/level.ts");function f(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var g=function(t){var e,r;function g(e,r){var i;return(i=t.call(this,e,r,"[subtitle-stream-controller]")||this).levels=[],i.currentTrackId=-1,i.tracksBuffered=[],i.mainDetails=null,i._registerListeners(),i}r=t,(e=g).prototype=Object.create(r.prototype),e.prototype.constructor=e,p(e,r);var m,v,y,b=g.prototype;return b.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},b._registerListeners=function(){var t=this.hls;t.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(i.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(i.Events.ERROR,this.onError,this),t.on(i.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(i.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(i.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},b._unregisterListeners=function(){var t=this.hls;t.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(i.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(i.Events.ERROR,this.onError,this),t.off(i.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(i.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(i.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},b.startLoad=function(){this.stopLoad(),this.state=u.State.IDLE,this.setInterval(500),this.tick()},b.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},b.onLevelLoaded=function(t,e){this.mainDetails=e.details},b.onSubtitleFragProcessed=function(t,e){var r=e.frag,i=e.success;if(this.fragPrevious=r,this.state=u.State.IDLE,i){var n=this.tracksBuffered[this.currentTrackId];if(n){for(var o,s=r.start,a=0;a<n.length;a++)if(s>=n[a].start&&s<=n[a].end){o=n[a];break}var l=r.start+r.duration;o?o.end=l:(o={start:s,end:l},n.push(o)),this.fragmentTracker.fragBuffered(r)}}},b.onBufferFlushing=function(t,e){var r=e.startOffset,i=e.endOffset;if(0===r&&i!==Number.POSITIVE_INFINITY){var n=this.currentTrackId,o=this.levels;if(!o.length||!o[n]||!o[n].details)return;var s=i-o[n].details.targetduration;if(s<=0)return;e.endOffsetSubtitles=Math.max(0,s),this.tracksBuffered.forEach((function(t){for(var e=0;e<t.length;)if(t[e].end<=s)t.shift();else{if(!(t[e].start<s))break;t[e].start=s,e++}})),this.fragmentTracker.removeFragmentsInRange(r,s,h.PlaylistLevelType.SUBTITLE)}},b.onError=function(t,e){var r,i=e.frag;i&&i.type===h.PlaylistLevelType.SUBTITLE&&(null!==(r=this.fragCurrent)&&void 0!==r&&r.loader&&this.fragCurrent.loader.abort(),this.state=u.State.IDLE)},b.onSubtitleTracksUpdated=function(t,e){var r=this,i=e.subtitleTracks;this.tracksBuffered=[],this.levels=i.map((function(t){return new d.Level(t)})),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach((function(t){r.tracksBuffered[t.id]=[]})),this.mediaBuffer=null},b.onSubtitleTrackSwitch=function(t,e){if(this.currentTrackId=e.id,this.levels.length&&-1!==this.currentTrackId){var r=this.levels[this.currentTrackId];null!=r&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(500)}else this.clearInterval()},b.onSubtitleTrackLoaded=function(t,e){var r,i=e.details,n=e.id,o=this.currentTrackId,c=this.levels;if(c.length){var h=c[o];if(!(n>=c.length||n!==o)&&h){if(this.mediaBuffer=this.mediaBufferTimeRanges,i.live||null!==(r=h.details)&&void 0!==r&&r.live){var d=this.mainDetails;if(i.deltaUpdateFailed||!d)return;var f=d.fragments[0];h.details?0===this.alignPlaylists(i,h.details)&&f&&Object(l.addSliding)(i,f.start):i.hasProgramDateTime&&d.hasProgramDateTime?Object(a.alignMediaPlaylistByPDT)(i,d):f&&Object(l.addSliding)(i,f.start)}h.details=i,this.levelLastLoaded=n,this.tick(),i.live&&!this.fragCurrent&&this.media&&this.state===u.State.IDLE&&(Object(s.findFragmentByPTS)(null,i.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),h.details=void 0))}}},b._handleFragmentLoadComplete=function(t){var e=t.frag,r=t.payload,n=e.decryptdata,o=this.hls;if(!this.fragContextChanged(e)&&r&&r.byteLength>0&&n&&n.key&&n.iv&&"AES-128"===n.method){var s=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(r),n.key.buffer,n.iv.buffer).then((function(t){var r=performance.now();o.trigger(i.Events.FRAG_DECRYPTED,{frag:e,payload:t,stats:{tstart:s,tdecrypt:r}})}))}},b.doTick=function(){if(this.media){if(this.state===u.State.IDLE){var t,e=this.currentTrackId,r=this.levels;if(!r.length||!r[e]||!r[e].details)return;var a=r[e].details,l=a.targetduration,h=this.config,d=this.media,f=o.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,d.currentTime-l,h.maxBufferHole),p=f.end;if(f.len>this.getMaxBufferLength()+l)return;console.assert(a,"Subtitle track details are defined on idle subtitle stream controller tick");var g,m=a.fragments,v=m.length,y=a.edge,b=this.fragPrevious;if(p<y){var x=h.maxFragLookUpTolerance;b&&a.hasProgramDateTime&&(g=Object(s.findFragmentByPDT)(m,b.endProgramDateTime,x)),g||!(g=Object(s.findFragmentByPTS)(b,m,p,x))&&b&&b.start<m[0].start&&(g=m[0])}else g=m[v-1];null!==(t=g)&&void 0!==t&&t.encrypted?(n.logger.log("Loading key for "+g.sn),this.state=u.State.KEY_LOADING,this.hls.trigger(i.Events.KEY_LOADING,{frag:g})):g&&this.fragmentTracker.getState(g)===c.FragmentState.NOT_LOADED&&this.loadFragment(g,a,p)}}else this.state=u.State.IDLE},b.loadFragment=function(e,r,i){this.fragCurrent=e,t.prototype.loadFragment.call(this,e,r,i)},m=g,(v=[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}])&&f(m.prototype,v),y&&f(m,y),g}(u.default)},"./src/controller/subtitle-track-controller.ts":
|
|
|
/*!*****************************************************!*\
|
|
|
!*** ./src/controller/subtitle-track-controller.ts ***!
|
|
|
\*****************************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),o=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),s=r(/*! ../types/loader */"./src/types/loader.ts");function a(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var c=function(t){var e,r;function o(e){var r;return(r=t.call(this,e,"[subtitle-track-controller]")||this).media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r.subtitleDisplay=!0,r.registerListeners(),r}r=t,(e=o).prototype=Object.create(r.prototype),e.prototype.constructor=e,l(e,r);var c,h,d,f=o.prototype;return f.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,t.prototype.destroy.call(this)},f.registerListeners=function(){var t=this.hls;t.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(i.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(i.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var t=this.hls;t.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(i.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(i.Events.ERROR,this.onError,this)},f.onMediaAttached=function(t,e){this.media=e.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},f.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)},f.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),u(this.media.textTracks).forEach((function(t){Object(n.clearCurrentCues)(t)})),this.subtitleTrack=-1,this.media=null)},f.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},f.onManifestParsed=function(t,e){this.tracks=e.subtitleTracks},f.onSubtitleTrackLoaded=function(t,e){var r=e.id,i=e.details,n=this.trackId,o=this.tracksInGroup[n];if(o){var s=o.details;o.details=e.details,this.log("subtitle track "+r+" loaded ["+i.startSN+"-"+i.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,e,s))}else this.warn("Invalid subtitle track id "+r)},f.onLevelLoading=function(t,e){this.switchLevel(e.level)},f.onLevelSwitching=function(t,e){this.switchLevel(e.level)},f.switchLevel=function(t){var e=this.hls.levels[t];if(null!=e&&e.textGroupIds){var r=e.textGroupIds[e.urlId];if(this.groupId!==r){var n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,o=this.tracks.filter((function(t){return!r||t.groupId===r}));this.tracksInGroup=o;var s=this.findTrackId(null==n?void 0:n.name)||this.findTrackId();this.groupId=r;var a={subtitleTracks:o};this.log("Updating subtitle tracks, "+o.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(i.Events.SUBTITLE_TRACKS_UPDATED,a),-1!==s&&this.setSubtitleTrack(s,n)}}},f.findTrackId=function(t){for(var e=this.tracksInGroup,r=0;r<e.length;r++){var i=e[r];if((!this.selectDefaultTrack||i.default)&&(!t||t===i.name))return i.id}return-1},f.onError=function(e,r){t.prototype.onError.call(this,e,r),!r.fatal&&r.context&&r.context.type===s.PlaylistContextType.SUBTITLE_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},f.loadPlaylist=function(t){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var r=e.id,n=e.groupId,o=e.url;if(t)try{o=t.addDirectives(o)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Loading subtitle playlist for id "+r),this.hls.trigger(i.Events.SUBTITLE_TRACK_LOADING,{url:o,id:r,groupId:n,deliveryDirectives:t||null})}},f.toggleTrackModes=function(t){var e=this,r=this.media,i=this.subtitleDisplay,n=this.trackId;if(r){var o=u(r.textTracks),s=o.filter((function(t){return t.groupId===e.groupId}));if(-1===t)[].slice.call(o).forEach((function(t){t.mode="disabled"}));else{var a=s[n];a&&(a.mode="disabled")}var l=s[t];l&&(l.mode=i?"showing":"hidden")}},f.setSubtitleTrack=function(t,e){var r,n=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(-1===t||null!==(r=n[t])&&void 0!==r&&r.details)||t<-1||t>=n.length)){this.clearTimer();var o=n[t];if(this.log("Switching to subtitle track "+t),this.trackId=t,o){var s=o.id,a=o.groupId,l=void 0===a?"":a,c=o.name,u=o.type,h=o.url;this.hls.trigger(i.Events.SUBTITLE_TRACK_SWITCH,{id:s,groupId:l,name:c,type:u,url:h});var d=this.switchParams(o.url,null==e?void 0:e.details);this.loadPlaylist(d)}else this.hls.trigger(i.Events.SUBTITLE_TRACK_SWITCH,{id:t})}}else this.queuedDefaultTrack=t},f.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var t=-1,e=u(this.media.textTracks),r=0;r<e.length;r++)if("hidden"===e[r].mode)t=r;else if("showing"===e[r].mode){t=r;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}},c=o,(h=[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1;var e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,e)}}])&&a(c.prototype,h),d&&a(c,d),o}(o.default);function u(t){for(var e=[],r=0;r<t.length;r++){var i=t[r];"subtitles"===i.kind&&i.label&&e.push(t[r])}return e}e.default=c},"./src/controller/timeline-controller.ts":
|
|
|
/*!***********************************************!*\
|
|
|
!*** ./src/controller/timeline-controller.ts ***!
|
|
|
\***********************************************/
|
|
|
/*! exports provided: TimelineController */function(t,e,r){"use strict";r.r(e),r.d(e,"TimelineController",(function(){return d}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),o=r(/*! ../utils/cea-608-parser */"./src/utils/cea-608-parser.ts"),s=r(/*! ../utils/output-filter */"./src/utils/output-filter.ts"),a=r(/*! ../utils/webvtt-parser */"./src/utils/webvtt-parser.ts"),l=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),c=r(/*! ../utils/imsc1-ttml-parser */"./src/utils/imsc1-ttml-parser.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),h=r(/*! ../utils/logger */"./src/utils/logger.ts"),d=function(){function t(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var e=new s.default(this,"textTrack1"),r=new s.default(this,"textTrack2"),i=new s.default(this,"textTrack3"),a=new s.default(this,"textTrack4");this.cea608Parser1=new o.default(1,e,r),this.cea608Parser2=new o.default(3,i,a)}t.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(n.Events.FRAG_LOADING,this.onFragLoading,this),t.on(n.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(n.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(n.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(n.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(n.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var e=t.prototype;return e.destroy=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(n.Events.FRAG_LOADING,this.onFragLoading,this),t.off(n.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(n.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(n.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(n.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(n.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},e.addCues=function(t,e,r,i,o){for(var s,a,l,c,u=!1,h=o.length;h--;){var d=o[h],f=(s=d[0],a=d[1],l=e,c=r,Math.min(a,c)-Math.max(s,l));if(f>=0&&(d[0]=Math.min(d[0],e),d[1]=Math.max(d[1],r),u=!0,f/(r-e)>.5))return}if(u||o.push([e,r]),this.config.renderTextTracksNatively){var p=this.captionsTracks[t];this.Cues.newCue(p,e,r,i)}else{var g=this.Cues.newCue(null,e,r,i);this.hls.trigger(n.Events.CUES_PARSED,{type:"captions",cues:g,track:t})}},e.onInitPtsFound=function(t,e){var r=this,i=e.frag,o=e.id,s=e.initPTS,a=e.timescale,l=this.unparsedVttFrags;"main"===o&&(this.initPTS[i.cc]=s,this.timescale[i.cc]=a),l.length&&(this.unparsedVttFrags=[],l.forEach((function(t){r.onFragLoaded(n.Events.FRAG_LOADED,t)})))},e.getExistingTrack=function(t){var e=this.media;if(e)for(var r=0;r<e.textTracks.length;r++){var i=e.textTracks[r];if(i[t])return i}return null},e.createCaptionsTrack=function(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)},e.createNativeTrack=function(t){if(!this.captionsTracks[t]){var e=this.captionsProperties,r=this.captionsTracks,i=this.media,n=e[t],o=n.label,s=n.languageCode,a=this.getExistingTrack(t);if(a)r[t]=a,Object(l.clearCurrentCues)(r[t]),Object(l.sendAddTrackEvent)(r[t],i);else{var c=this.createTextTrack("captions",o,s);c&&(c[t]=!0,r[t]=c)}}},e.createNonNativeTrack=function(t){if(!this.nonNativeCaptionsTracks[t]){var e=this.captionsProperties[t];if(e){var r={_id:t,label:e.label,kind:"captions",default:!!e.media&&!!e.media.default,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=r,this.hls.trigger(n.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}},e.createTextTrack=function(t,e,r){var i=this.media;if(i)return i.addTextTrack(t,e,r)},e.onMediaAttaching=function(t,e){this.media=e.media,this._cleanTracks()},e.onMediaDetaching=function(){var t=this.captionsTracks;Object.keys(t).forEach((function(e){Object(l.clearCurrentCues)(t[e]),delete t[e]})),this.nonNativeCaptionsTracks={}},e.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},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())},e._cleanTracks=function(){var t=this.media;if(t){var e=t.textTracks;if(e)for(var r=0;r<e.length;r++)Object(l.clearCurrentCues)(e[r])}},e.onSubtitleTracksUpdated=function(t,e){var r=this;this.textTracks=[];var i=e.subtitleTracks||[],o=i.some((function(t){return t.textCodec===c.IMSC1_CODEC}));if(this.config.enableWebVTT||o&&this.config.enableIMSC1){var s=this.tracks&&i&&this.tracks.length===i.length;if(this.tracks=i||[],this.config.renderTextTracksNatively){var a=this.media?this.media.textTracks:[];this.tracks.forEach((function(t,e){var i;if(e<a.length){for(var n=null,o=0;o<a.length;o++)if(f(a[o],t)){n=a[o];break}n&&(i=n)}i?Object(l.clearCurrentCues)(i):(i=r.createTextTrack("subtitles",t.name,t.lang))&&(i.mode="disabled"),i&&(i.groupId=t.groupId,r.textTracks.push(i))}))}else if(!s&&this.tracks&&this.tracks.length){var u=this.tracks.map((function(t){return{label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t}}));this.hls.trigger(n.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:u})}}},e.onManifestLoaded=function(t,e){var r=this;this.config.enableCEA708Captions&&e.captions&&e.captions.forEach((function(t){var e=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(e){var i="textTrack"+e[1],n=r.captionsProperties[i];n&&(n.label=t.name,t.lang&&(n.languageCode=t.lang),n.media=t)}}))},e.onFragLoading=function(t,e){var r=this.cea608Parser1,i=this.cea608Parser2,n=this.lastSn,o=this.lastPartIndex;if(this.enabled&&r&&i&&e.frag.type===u.PlaylistLevelType.MAIN){var s,a,l=e.frag.sn,c=null!=(s=null==e||null===(a=e.part)||void 0===a?void 0:a.index)?s:-1;l===n+1||l===n&&c===o+1||(r.reset(),i.reset()),this.lastSn=l,this.lastPartIndex=c}},e.onFragLoaded=function(t,e){var r=e.frag,o=e.payload,s=this.initPTS,a=this.unparsedVttFrags;if(r.type===u.PlaylistLevelType.SUBTITLE)if(o.byteLength){if(!Object(i.isFiniteNumber)(s[r.cc]))return a.push(e),void(s.length&&this.hls.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")}));var l=r.decryptdata;if(null==l||null==l.key||"AES-128"!==l.method){var h=this.tracks[r.level],d=this.vttCCs;d[r.cc]||(d[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),h&&h.textCodec===c.IMSC1_CODEC?this._parseIMSC1(r,o):this._parseVTTs(r,o,d)}}else this.hls.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},e._parseIMSC1=function(t,e){var r=this,i=this.hls;Object(c.parseIMSC1)(e,this.initPTS[t.cc],this.timescale[t.cc],(function(e){r._appendCues(e,t.level),i.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(function(e){h.logger.log("Failed to parse IMSC1: "+e),i.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:e})}))},e._parseVTTs=function(t,e,r){var i=this,o=this.hls;Object(a.parseWebVTT)(e,this.initPTS[t.cc],this.timescale[t.cc],r,t.cc,t.start,(function(e){i._appendCues(e,t.level),o.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(function(r){i._fallbackToIMSC1(t,e),h.logger.log("Failed to parse VTT cue: "+r),o.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:r})}))},e._fallbackToIMSC1=function(t,e){var r=this,i=this.tracks[t.level];i.textCodec||Object(c.parseIMSC1)(e,this.initPTS[t.cc],this.timescale[t.cc],(function(){i.textCodec=c.IMSC1_CODEC,r._parseIMSC1(t,e)}),(function(){i.textCodec="wvtt"}))},e._appendCues=function(t,e){var r=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[e];if("disabled"===i.mode)return;t.forEach((function(t){return Object(l.addCueToTrack)(i,t)}))}else{var o=this.tracks[e].default?"default":"subtitles"+e;r.trigger(n.Events.CUES_PARSED,{type:"subtitles",cues:t,track:o})}},e.onFragDecrypted=function(t,e){var r=e.frag;if(r.type===u.PlaylistLevelType.SUBTITLE){if(!Object(i.isFiniteNumber)(this.initPTS[r.cc]))return void this.unparsedVttFrags.push(e);this.onFragLoaded(n.Events.FRAG_LOADED,e)}},e.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},e.onFragParsingUserdata=function(t,e){var r=this.cea608Parser1,i=this.cea608Parser2;if(this.enabled&&r&&i)for(var n=0;n<e.samples.length;n++){var o=e.samples[n].bytes;if(o){var s=this.extractCea608Data(o);r.addData(e.samples[n].pts,s[0]),i.addData(e.samples[n].pts,s[1])}}},e.onBufferFlushing=function(t,e){var r=e.startOffset,i=e.endOffset,n=e.endOffsetSubtitles,o=e.type,s=this.media;if(s&&!(s.currentTime<i)){if(!o||"video"===o){var a=this.captionsTracks;Object.keys(a).forEach((function(t){return Object(l.removeCuesInRange)(a[t],r,i)}))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==n){var c=this.textTracks;Object.keys(c).forEach((function(t){return Object(l.removeCuesInRange)(c[t],r,n)}))}}},e.extractCea608Data=function(t){for(var e=31&t[0],r=2,i=[[],[]],n=0;n<e;n++){var o=t[r++],s=127&t[r++],a=127&t[r++],l=3&o;0===s&&0===a||0!=(4&o)&&(0!==l&&1!==l||(i[l].push(s),i[l].push(a)))}return i},t}();function f(t,e){return t&&t.label===e.name&&!(t.textTrack1||t.textTrack2)}},"./src/crypt/aes-crypto.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/crypt/aes-crypto.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return i}));var i=function(){function t(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}return t.prototype.decrypt=function(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)},t}()},"./src/crypt/aes-decryptor.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/crypt/aes-decryptor.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: removePadding, default */function(t,e,r){"use strict";r.r(e),r.d(e,"removePadding",(function(){return n})),r.d(e,"default",(function(){return o}));var i=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts");function n(t){var e=t.byteLength,r=e&&new DataView(t.buffer).getUint8(e-1);return r?Object(i.sliceUint8)(t,0,e-r):t}var o=function(){function t(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var e=t.prototype;return e.uint8ArrayToUint32Array_=function(t){for(var e=new DataView(t),r=new Uint32Array(4),i=0;i<4;i++)r[i]=e.getUint32(4*i);return r},e.initTable=function(){var t=this.sBox,e=this.invSBox,r=this.subMix,i=r[0],n=r[1],o=r[2],s=r[3],a=this.invSubMix,l=a[0],c=a[1],u=a[2],h=a[3],d=new Uint32Array(256),f=0,p=0,g=0;for(g=0;g<256;g++)d[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var m=p^p<<1^p<<2^p<<3^p<<4;m=m>>>8^255&m^99,t[f]=m,e[m]=f;var v=d[f],y=d[v],b=d[y],x=257*d[m]^16843008*m;i[f]=x<<24|x>>>8,n[f]=x<<16|x>>>16,o[f]=x<<8|x>>>24,s[f]=x,x=16843009*b^65537*y^257*v^16843008*f,l[m]=x<<24|x>>>8,c[m]=x<<16|x>>>16,u[m]=x<<8|x>>>24,h[m]=x,f?(f=v^d[d[d[b^v]]],p^=d[d[p]]):f=p=1}},e.expandKey=function(t){for(var e=this.uint8ArrayToUint32Array_(t),r=!0,i=0;i<e.length&&r;)r=e[i]===this.key[i],i++;if(!r){this.key=e;var n=this.keySize=e.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);var o,s,a,l,c=this.ksRows=4*(n+6+1),u=this.keySchedule=new Uint32Array(c),h=this.invKeySchedule=new Uint32Array(c),d=this.sBox,f=this.rcon,p=this.invSubMix,g=p[0],m=p[1],v=p[2],y=p[3];for(o=0;o<c;o++)o<n?a=u[o]=e[o]:(l=a,o%n==0?(l=d[(l=l<<8|l>>>24)>>>24]<<24|d[l>>>16&255]<<16|d[l>>>8&255]<<8|d[255&l],l^=f[o/n|0]<<24):n>6&&o%n==4&&(l=d[l>>>24]<<24|d[l>>>16&255]<<16|d[l>>>8&255]<<8|d[255&l]),u[o]=a=(u[o-n]^l)>>>0);for(s=0;s<c;s++)o=c-s,l=3&s?u[o]:u[o-4],h[s]=s<4||o<=4?l:g[d[l>>>24]]^m[d[l>>>16&255]]^v[d[l>>>8&255]]^y[d[255&l]],h[s]=h[s]>>>0}},e.networkToHostOrderSwap=function(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24},e.decrypt=function(t,e,r){for(var i,n,o,s,a,l,c,u,h,d,f,p,g,m,v=this.keySize+6,y=this.invKeySchedule,b=this.invSBox,x=this.invSubMix,S=x[0],C=x[1],w=x[2],k=x[3],E=this.uint8ArrayToUint32Array_(r),T=E[0],L=E[1],A=E[2],D=E[3],O=new Int32Array(t),R=new Int32Array(O.length),_=this.networkToHostOrderSwap;e<O.length;){for(h=_(O[e]),d=_(O[e+1]),f=_(O[e+2]),p=_(O[e+3]),a=h^y[0],l=p^y[1],c=f^y[2],u=d^y[3],g=4,m=1;m<v;m++)i=S[a>>>24]^C[l>>16&255]^w[c>>8&255]^k[255&u]^y[g],n=S[l>>>24]^C[c>>16&255]^w[u>>8&255]^k[255&a]^y[g+1],o=S[c>>>24]^C[u>>16&255]^w[a>>8&255]^k[255&l]^y[g+2],s=S[u>>>24]^C[a>>16&255]^w[l>>8&255]^k[255&c]^y[g+3],a=i,l=n,c=o,u=s,g+=4;i=b[a>>>24]<<24^b[l>>16&255]<<16^b[c>>8&255]<<8^b[255&u]^y[g],n=b[l>>>24]<<24^b[c>>16&255]<<16^b[u>>8&255]<<8^b[255&a]^y[g+1],o=b[c>>>24]<<24^b[u>>16&255]<<16^b[a>>8&255]<<8^b[255&l]^y[g+2],s=b[u>>>24]<<24^b[a>>16&255]<<16^b[l>>8&255]<<8^b[255&c]^y[g+3],R[e]=_(i^T),R[e+1]=_(s^L),R[e+2]=_(o^A),R[e+3]=_(n^D),T=h,L=d,A=f,D=p,e+=4}return R.buffer},t}()},"./src/crypt/decrypter.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/crypt/decrypter.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return c}));var i=r(/*! ./aes-crypto */"./src/crypt/aes-crypto.ts"),n=r(/*! ./fast-aes-key */"./src/crypt/fast-aes-key.ts"),o=r(/*! ./aes-decryptor */"./src/crypt/aes-decryptor.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),c=function(){function t(t,e,r){var i=(void 0===r?{}:r).removePKCS7Padding,n=void 0===i||i;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=t,this.config=e,this.removePKCS7Padding=n,n)try{var o=self.crypto;o&&(this.subtle=o.subtle||o.webkitSubtle)}catch(t){}null===this.subtle&&(this.config.enableSoftwareAES=!0)}var e=t.prototype;return e.destroy=function(){this.observer=null},e.isSync=function(){return this.config.enableSoftwareAES},e.flush=function(){var t=this.currentResult;if(t){var e=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?Object(o.removePadding)(e):e}this.reset()},e.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},e.decrypt=function(t,e,r,i){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(t),e,r);var n=this.flush();n&&i(n.buffer)}else this.webCryptoDecrypt(new Uint8Array(t),e,r).then(i)},e.softwareDecrypt=function(t,e,r){var i=this.currentIV,n=this.currentResult,s=this.remainderData;this.logOnce("JS AES decrypt"),s&&(t=Object(a.appendUint8Array)(s,t),this.remainderData=null);var c=this.getValidChunk(t);if(!c.length)return null;i&&(r=i);var u=this.softwareDecrypter;u||(u=this.softwareDecrypter=new o.default),u.expandKey(e);var h=n;return this.currentResult=u.decrypt(c.buffer,0,r),this.currentIV=Object(l.sliceUint8)(c,-16).buffer,h||null},e.webCryptoDecrypt=function(t,e,r){var o=this,s=this.subtle;return this.key===e&&this.fastAesKey||(this.key=e,this.fastAesKey=new n.default(s,e)),this.fastAesKey.expandKey().then((function(e){return s?new i.default(s,r).decrypt(t.buffer,e):Promise.reject(new Error("web crypto not initialized"))})).catch((function(i){return o.onWebCryptoError(i,t,e,r)}))},e.onWebCryptoError=function(t,e,r,i){return s.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",t),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(e,r,i)},e.getValidChunk=function(t){var e=t,r=t.length-t.length%16;return r!==t.length&&(e=Object(l.sliceUint8)(t,0,r),this.remainderData=Object(l.sliceUint8)(t,r)),e},e.logOnce=function(t){this.logEnabled&&(s.logger.log("[decrypter.ts]: "+t),this.logEnabled=!1)},t}()},"./src/crypt/fast-aes-key.ts":
|
|
|
/*!***********************************!*\
|
|
|
!*** ./src/crypt/fast-aes-key.ts ***!
|
|
|
\***********************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return i}));var i=function(){function t(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}return t.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},t}()},"./src/demux/aacdemuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/aacdemuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),n=r(/*! ./adts */"./src/demux/adts.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts");function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var l=function(t){var e,r;function i(e,r){var i;return(i=t.call(this)||this).observer=void 0,i.config=void 0,i.observer=e,i.config=r,i}r=t,(e=i).prototype=Object.create(r.prototype),e.prototype.constructor=e,a(e,r);var l=i.prototype;return l.resetInitSegment=function(e,r,i){t.prototype.resetInitSegment.call(this,e,r,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:e,duration:i,inputTimeScale:9e4,dropped:0}},i.probe=function(t){if(!t)return!1;for(var e=(s.getID3Data(t,0)||[]).length,r=t.length;e<r;e++)if(n.probe(t,e))return o.logger.log("ADTS sync word found !"),!0;return!1},l.canParse=function(t,e){return n.canParse(t,e)},l.appendFrame=function(t,e,r){n.initTrackConfig(t,this.observer,e,r,t.manifestCodec);var i=n.appendFrame(t,e,r,this.initPTS,this.frameIndex);if(i&&0===i.missing)return i},i}(i.default);l.minProbeByteLength=9,e.default=l},"./src/demux/adts.ts":
|
|
|
/*!***************************!*\
|
|
|
!*** ./src/demux/adts.ts ***!
|
|
|
\***************************/
|
|
|
/*! exports provided: getAudioConfig, isHeaderPattern, getHeaderLength, getFullFrameLength, canGetFrameLength, isHeader, canParse, probe, initTrackConfig, getFrameDuration, parseFrameHeader, appendFrame */function(t,e,r){"use strict";r.r(e),r.d(e,"getAudioConfig",(function(){return s})),r.d(e,"isHeaderPattern",(function(){return a})),r.d(e,"getHeaderLength",(function(){return l})),r.d(e,"getFullFrameLength",(function(){return c})),r.d(e,"canGetFrameLength",(function(){return u})),r.d(e,"isHeader",(function(){return h})),r.d(e,"canParse",(function(){return d})),r.d(e,"probe",(function(){return f})),r.d(e,"initTrackConfig",(function(){return p})),r.d(e,"getFrameDuration",(function(){return g})),r.d(e,"parseFrameHeader",(function(){return m})),r.d(e,"appendFrame",(function(){return v}));var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../events */"./src/events.ts");function s(t,e,r,s){var a,l,c,u,h=navigator.userAgent.toLowerCase(),d=s,f=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];a=1+((192&e[r+2])>>>6);var p=(60&e[r+2])>>>2;if(!(p>f.length-1))return c=(1&e[r+2])<<2,c|=(192&e[r+3])>>>6,i.logger.log("manifest codec:"+s+", ADTS type:"+a+", samplingIndex:"+p),/firefox/i.test(h)?p>=6?(a=5,u=new Array(4),l=p-3):(a=2,u=new Array(2),l=p):-1!==h.indexOf("android")?(a=2,u=new Array(2),l=p):(a=5,u=new Array(4),s&&(-1!==s.indexOf("mp4a.40.29")||-1!==s.indexOf("mp4a.40.5"))||!s&&p>=6?l=p-3:((s&&-1!==s.indexOf("mp4a.40.2")&&(p>=6&&1===c||/vivaldi/i.test(h))||!s&&1===c)&&(a=2,u=new Array(2)),l=p)),u[0]=a<<3,u[0]|=(14&p)>>1,u[1]|=(1&p)<<7,u[1]|=c<<3,5===a&&(u[1]|=(14&l)>>1,u[2]=(1&l)<<7,u[2]|=8,u[3]=0),{config:u,samplerate:f[p],channelCount:c,codec:"mp4a.40."+a,manifestCodec:d};t.trigger(o.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+p})}function a(t,e){return 255===t[e]&&240==(246&t[e+1])}function l(t,e){return 1&t[e+1]?7:9}function c(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function u(t,e){return e+5<t.length}function h(t,e){return e+1<t.length&&a(t,e)}function d(t,e){return u(t,e)&&a(t,e)&&c(t,e)<=t.length-e}function f(t,e){if(h(t,e)){var r=l(t,e);if(e+r>=t.length)return!1;var i=c(t,e);if(i<=r)return!1;var n=e+i;return n===t.length||h(t,n)}return!1}function p(t,e,r,n,o){if(!t.samplerate){var a=s(e,r,n,o);if(!a)return;t.config=a.config,t.samplerate=a.samplerate,t.channelCount=a.channelCount,t.codec=a.codec,t.manifestCodec=a.manifestCodec,i.logger.log("parsed codec:"+t.codec+", rate:"+a.samplerate+", channels:"+a.channelCount)}}function g(t){return 9216e4/t}function m(t,e,r,i,n){var o=l(t,e),s=c(t,e);if((s-=o)>0)return{headerLength:o,frameLength:s,stamp:r+i*n}}function v(t,e,r,i,n){var o=m(e,r,i,n,g(t.samplerate));if(o){var s,a=o.frameLength,l=o.headerLength,c=o.stamp,u=l+a,h=Math.max(0,r+u-e.length);h?(s=new Uint8Array(u-l)).set(e.subarray(r+l,e.length),0):s=e.subarray(r+l,r+u);var d={unit:s,pts:c};return h||t.samples.push(d),{sample:d,length:u,missing:h}}}},"./src/demux/base-audio-demuxer.ts":
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./src/demux/base-audio-demuxer.ts ***!
|
|
|
\*****************************************/
|
|
|
/*! exports provided: initPTSFn, default */function(t,e,r){"use strict";r.r(e),r.d(e,"initPTSFn",(function(){return c}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../demux/id3 */"./src/demux/id3.ts"),o=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),s=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),a=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),l=function(){function t(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var e=t.prototype;return e.resetInitSegment=function(t,e,r){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},e.resetTimeStamp=function(){},e.resetContiguity=function(){},e.canParse=function(t,e){return!1},e.appendFrame=function(t,e,r){},e.demux=function(t,e){this.cachedData&&(t=Object(s.appendUint8Array)(this.cachedData,t),this.cachedData=null);var r,i,l=n.getID3Data(t,0),u=l?l.length:0,h=this._audioTrack,d=this._id3Track,f=l?n.getTimeStamp(l):void 0,p=t.length;for(0!==this.frameIndex&&null!==this.initPTS||(this.initPTS=c(f,e)),l&&l.length>0&&d.samples.push({pts:this.initPTS,dts:this.initPTS,data:l}),i=this.initPTS;u<p;){if(this.canParse(t,u)){var g=this.appendFrame(h,t,u);g?(this.frameIndex++,i=g.sample.pts,r=u+=g.length):u=p}else n.canParse(t,u)?(l=n.getID3Data(t,u),d.samples.push({pts:i,dts:i,data:l}),r=u+=l.length):u++;if(u===p&&r!==p){var m=Object(a.sliceUint8)(t,r);this.cachedData?this.cachedData=Object(s.appendUint8Array)(this.cachedData,m):this.cachedData=m}}return{audioTrack:h,avcTrack:Object(o.dummyTrack)(),id3Track:d,textTrack:Object(o.dummyTrack)()}},e.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},e.flush=function(t){var e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(o.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(o.dummyTrack)()}},e.destroy=function(){},t}(),c=function(t,e){return Object(i.isFiniteNumber)(t)?90*t:9e4*e};e.default=l},"./src/demux/chunk-cache.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/demux/chunk-cache.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return i}));var i=function(){function t(){this.chunks=[],this.dataLength=0}var e=t.prototype;return e.push=function(t){this.chunks.push(t),this.dataLength+=t.length},e.flush=function(){var t,e=this.chunks,r=this.dataLength;return e.length?(t=1===e.length?e[0]:function(t,e){for(var r=new Uint8Array(e),i=0,n=0;n<t.length;n++){var o=t[n];r.set(o,i),i+=o.length}return r}(e,r),this.reset(),t):new Uint8Array(0)},e.reset=function(){this.chunks.length=0,this.dataLength=0},t}()},"./src/demux/dummy-demuxed-track.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/demux/dummy-demuxed-track.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: dummyTrack */function(t,e,r){"use strict";function i(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}r.r(e),r.d(e,"dummyTrack",(function(){return i}))},"./src/demux/exp-golomb.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/exp-golomb.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=function(){function t(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}var e=t.prototype;return e.loadWord=function(){var t=this.data,e=this.bytesAvailable,r=t.byteLength-e,i=new Uint8Array(4),n=Math.min(4,e);if(0===n)throw new Error("no bytes available");i.set(t.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n},e.skipBits=function(t){var e;this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,t-=(e=t>>3)>>3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},e.readBits=function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;return t>32&&i.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0?this.word<<=e:this.bytesAvailable>0&&this.loadWord(),(e=t-e)>0&&this.bitsAvailable?r<<e|this.readBits(e):r},e.skipLZ=function(){var t;for(t=0;t<this.bitsAvailable;++t)if(0!=(this.word&2147483648>>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},e.skipUEG=function(){this.skipBits(1+this.skipLZ())},e.skipEG=function(){this.skipBits(1+this.skipLZ())},e.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},e.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},e.readBoolean=function(){return 1===this.readBits(1)},e.readUByte=function(){return this.readBits(8)},e.readUShort=function(){return this.readBits(16)},e.readUInt=function(){return this.readBits(32)},e.skipScalingList=function(t){for(var e=8,r=8,i=0;i<t;i++)0!==r&&(r=(e+this.readEG()+256)%256),e=0===r?e:r},e.readSPS=function(){var t,e,r,i=0,n=0,o=0,s=0,a=this.readUByte.bind(this),l=this.readBits.bind(this),c=this.readUEG.bind(this),u=this.readBoolean.bind(this),h=this.skipBits.bind(this),d=this.skipEG.bind(this),f=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);a();var g=a();if(l(5),h(3),a(),f(),100===g||110===g||122===g||244===g||44===g||83===g||86===g||118===g||128===g){var m=c();if(3===m&&h(1),f(),f(),h(1),u())for(e=3!==m?8:12,r=0;r<e;r++)u()&&p(r<6?16:64)}f();var v=c();if(0===v)c();else if(1===v)for(h(1),d(),d(),t=c(),r=0;r<t;r++)d();f(),h(1);var y=c(),b=c(),x=l(1);0===x&&h(1),h(1),u()&&(i=c(),n=c(),o=c(),s=c());var S=[1,1];if(u()&&u())switch(a()){case 1:S=[1,1];break;case 2:S=[12,11];break;case 3:S=[10,11];break;case 4:S=[16,11];break;case 5:S=[40,33];break;case 6:S=[24,11];break;case 7:S=[20,11];break;case 8:S=[32,11];break;case 9:S=[80,33];break;case 10:S=[18,11];break;case 11:S=[15,11];break;case 12:S=[64,33];break;case 13:S=[160,99];break;case 14:S=[4,3];break;case 15:S=[3,2];break;case 16:S=[2,1];break;case 255:S=[a()<<8|a(),a()<<8|a()]}return{width:Math.ceil(16*(y+1)-2*i-2*n),height:(2-x)*(b+1)*16-(x?2:4)*(o+s),pixelRatio:S}},e.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},t}();e.default=n},"./src/demux/id3.ts":
|
|
|
/*!**************************!*\
|
|
|
!*** ./src/demux/id3.ts ***!
|
|
|
\**************************/
|
|
|
/*! exports provided: isHeader, isFooter, getID3Data, canParse, getTimeStamp, isTimeStampFrame, getID3Frames, decodeFrame, utf8ArrayToStr, testables */function(t,e,r){"use strict";r.r(e),r.d(e,"isHeader",(function(){return n})),r.d(e,"isFooter",(function(){return o})),r.d(e,"getID3Data",(function(){return s})),r.d(e,"canParse",(function(){return l})),r.d(e,"getTimeStamp",(function(){return c})),r.d(e,"isTimeStampFrame",(function(){return u})),r.d(e,"getID3Frames",(function(){return d})),r.d(e,"decodeFrame",(function(){return f})),r.d(e,"utf8ArrayToStr",(function(){return y})),r.d(e,"testables",(function(){return b}));var i,n=function(t,e){return e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},o=function(t,e){return e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},s=function(t,e){for(var r=e,i=0;n(t,e);)i+=10,i+=a(t,e+6),o(t,e+10)&&(i+=10),e+=i;if(i>0)return t.subarray(r,r+i)},a=function(t,e){var r=0;return r=(127&t[e])<<21,r|=(127&t[e+1])<<14,r|=(127&t[e+2])<<7,r|=127&t[e+3]},l=function(t,e){return n(t,e)&&a(t,e+6)+10<=t.length-e},c=function(t){for(var e=d(t),r=0;r<e.length;r++){var i=e[r];if(u(i))return v(i)}},u=function(t){return t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info},h=function(t){var e=String.fromCharCode(t[0],t[1],t[2],t[3]),r=a(t,4);return{type:e,size:r,data:t.subarray(10,10+r)}},d=function(t){for(var e=0,r=[];n(t,e);){for(var i=a(t,e+6),s=(e+=10)+i;e+8<s;){var l=h(t.subarray(e)),c=f(l);c&&r.push(c),e+=l.size+10}o(t,e)&&(e+=10)}return r},f=function(t){return"PRIV"===t.type?p(t):"W"===t.type[0]?m(t):g(t)},p=function(t){if(!(t.size<2)){var e=y(t.data,!0),r=new Uint8Array(t.data.subarray(e.length+1));return{key:t.type,info:e,data:r.buffer}}},g=function(t){if(!(t.size<2)){if("TXXX"===t.type){var e=1,r=y(t.data.subarray(e),!0);e+=r.length+1;var i=y(t.data.subarray(e));return{key:t.type,info:r,data:i}}var n=y(t.data.subarray(1));return{key:t.type,data:n}}},m=function(t){if("WXXX"===t.type){if(t.size<2)return;var e=1,r=y(t.data.subarray(e),!0);e+=r.length+1;var i=y(t.data.subarray(e));return{key:t.type,info:r,data:i}}var n=y(t.data);return{key:t.type,data:n}},v=function(t){if(8===t.data.byteLength){var e=new Uint8Array(t.data),r=1&e[3],i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},y=function(t,e){void 0===e&&(e=!1);var r=x();if(r){var i=r.decode(t);if(e){var n=i.indexOf("\0");return-1!==n?i.substring(0,n):i}return i.replace(/\0/g,"")}for(var o,s,a,l=t.length,c="",u=0;u<l;){if(0===(o=t[u++])&&e)return c;if(0!==o&&3!==o)switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:c+=String.fromCharCode(o);break;case 12:case 13:s=t[u++],c+=String.fromCharCode((31&o)<<6|63&s);break;case 14:s=t[u++],a=t[u++],c+=String.fromCharCode((15&o)<<12|(63&s)<<6|(63&a)<<0)}}return c},b={decodeTextFrame:g};function x(){return i||void 0===self.TextDecoder||(i=new self.TextDecoder("utf-8")),i}},"./src/demux/mp3demuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/mp3demuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),n=r(/*! ../demux/id3 */"./src/demux/id3.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts");function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var l=function(t){var e,r;function i(){return t.apply(this,arguments)||this}r=t,(e=i).prototype=Object.create(r.prototype),e.prototype.constructor=e,a(e,r);var l=i.prototype;return l.resetInitSegment=function(e,r,i){t.prototype.resetInitSegment.call(this,e,r,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:e,duration:i,inputTimeScale:9e4,dropped:0}},i.probe=function(t){if(!t)return!1;for(var e=(n.getID3Data(t,0)||[]).length,r=t.length;e<r;e++)if(s.probe(t,e))return o.logger.log("MPEG Audio sync word found !"),!0;return!1},l.canParse=function(t,e){return s.canParse(t,e)},l.appendFrame=function(t,e,r){if(null!==this.initPTS)return s.appendFrame(t,e,r,this.initPTS,this.frameIndex)},i}(i.default);l.minProbeByteLength=4,e.default=l},"./src/demux/mp4demuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/mp4demuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),n=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),o=function(){function t(t,e){this.remainderData=null,this.config=void 0,this.config=e}var e=t.prototype;return e.resetTimeStamp=function(){},e.resetInitSegment=function(){},e.resetContiguity=function(){},t.probe=function(t){return Object(i.findBox)({data:t,start:0,end:Math.min(t.length,16384)},["moof"]).length>0},e.demux=function(t){var e=t,r=Object(n.dummyTrack)();if(this.config.progressive){this.remainderData&&(e=Object(i.appendUint8Array)(this.remainderData,t));var o=Object(i.segmentValidRange)(e);this.remainderData=o.remainder,r.samples=o.valid||new Uint8Array}else r.samples=e;return{audioTrack:Object(n.dummyTrack)(),avcTrack:r,id3Track:Object(n.dummyTrack)(),textTrack:Object(n.dummyTrack)()}},e.flush=function(){var t=Object(n.dummyTrack)();return t.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(n.dummyTrack)(),avcTrack:t,id3Track:Object(n.dummyTrack)(),textTrack:Object(n.dummyTrack)()}},e.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},e.destroy=function(){},t}();o.minProbeByteLength=1024,e.default=o},"./src/demux/mpegaudio.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/demux/mpegaudio.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: appendFrame, parseHeader, isHeaderPattern, isHeader, canParse, probe */function(t,e,r){"use strict";r.r(e),r.d(e,"appendFrame",(function(){return l})),r.d(e,"parseHeader",(function(){return c})),r.d(e,"isHeaderPattern",(function(){return u})),r.d(e,"isHeader",(function(){return h})),r.d(e,"canParse",(function(){return d})),r.d(e,"probe",(function(){return f}));var i=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],o=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],s=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],a=[0,1,1,4];function l(t,e,r,i,n){if(!(r+24>e.length)){var o=c(e,r);if(o&&r+o.frameLength<=e.length){var s=i+n*(9e4*o.samplesPerFrame/o.sampleRate),a={unit:e.subarray(r,r+o.frameLength),pts:s,dts:s};return t.config=[],t.channelCount=o.channelCount,t.samplerate=o.sampleRate,t.samples.push(a),{sample:a,length:o.frameLength,missing:0}}}}function c(t,e){var r=t[e+1]>>3&3,l=t[e+1]>>1&3,c=t[e+2]>>4&15,u=t[e+2]>>2&3;if(1!==r&&0!==c&&15!==c&&3!==u){var h=t[e+2]>>1&1,d=t[e+3]>>6,f=1e3*n[14*(3===r?3-l:3===l?3:4)+c-1],p=o[3*(3===r?0:2===r?1:2)+u],g=3===d?1:2,m=s[r][l],v=a[l],y=8*m*v,b=Math.floor(m*f/p+h)*v;if(null===i){var x=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);i=x?parseInt(x[1]):0}return!!i&&i<=87&&2===l&&f>=224e3&&0===d&&(t[e+3]=128|t[e+3]),{sampleRate:p,channelCount:g,frameLength:b,samplesPerFrame:y}}}function u(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function h(t,e){return e+1<t.length&&u(t,e)}function d(t,e){return u(t,e)&&4<=t.length-e}function f(t,e){if(e+1<t.length&&u(t,e)){var r=c(t,e),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var n=e+i;return n===t.length||h(t,n)}return!1}},"./src/demux/sample-aes.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/sample-aes.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),n=r(/*! ./tsdemuxer */"./src/demux/tsdemuxer.ts"),o=function(){function t(t,e,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new i.default(t,e,{removePKCS7Padding:!1})}var e=t.prototype;return e.decryptBuffer=function(t,e){this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer,e)},e.decryptAacSample=function(t,e,r,i){var n=t[e].unit,o=n.subarray(16,n.length-n.length%16),s=o.buffer.slice(o.byteOffset,o.byteOffset+o.length),a=this;this.decryptBuffer(s,(function(o){var s=new Uint8Array(o);n.set(s,16),i||a.decryptAacSamples(t,e+1,r)}))},e.decryptAacSamples=function(t,e,r){for(;;e++){if(e>=t.length)return void r();if(!(t[e].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(t,e,r,i),!i)return}}},e.getAvcEncryptedData=function(t){for(var e=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(e),i=0,n=32;n<=t.length-16;n+=160,i+=16)r.set(t.subarray(n,n+16),i);return r},e.getAvcDecryptedUnit=function(t,e){for(var r=new Uint8Array(e),i=0,n=32;n<=t.length-16;n+=160,i+=16)t.set(r.subarray(i,i+16),n);return t},e.decryptAvcSample=function(t,e,r,i,o,s){var a=Object(n.discardEPB)(o.data),l=this.getAvcEncryptedData(a),c=this;this.decryptBuffer(l.buffer,(function(n){o.data=c.getAvcDecryptedUnit(a,n),s||c.decryptAvcSamples(t,e,r+1,i)}))},e.decryptAvcSamples=function(t,e,r,i){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,r=0){if(e>=t.length)return void i();for(var n=t[e].units;!(r>=n.length);r++){var o=n[r];if(!(o.data.length<=48||1!==o.type&&5!==o.type)){var s=this.decrypter.isSync();if(this.decryptAvcSample(t,e,r,i,o,s),!s)return}}}},t}();e.default=o},"./src/demux/transmuxer-interface.ts":
|
|
|
/*!*******************************************!*\
|
|
|
!*** ./src/demux/transmuxer-interface.ts ***!
|
|
|
\*******************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return h}));var i=r(/*! webworkify-webpack */"./node_modules/webworkify-webpack/index.js"),n=r(/*! ../events */"./src/events.ts"),o=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),c=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),u=Object(l.getMediaSource)()||{isTypeSupported:function(){return!1}},h=function(){function t(t,e,r,l){var h=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=t,this.id=e,this.onTransmuxComplete=r,this.onFlush=l;var d=t.config,f=function(e,r){(r=r||{}).frag=h.frag,r.id=h.id,t.trigger(e,r)};this.observer=new c.EventEmitter,this.observer.on(n.Events.FRAG_DECRYPTED,f),this.observer.on(n.Events.ERROR,f);var p={mp4:u.isTypeSupported("video/mp4"),mpeg:u.isTypeSupported("audio/mpeg"),mp3:u.isTypeSupported('audio/mp4; codecs="mp3"')},g=navigator.vendor;if(d.enableWorker&&"undefined"!=typeof Worker){var m;s.logger.log("demuxing in webworker");try{m=this.worker=i(/*! ../demux/transmuxer-worker.ts */"./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),m.addEventListener("message",this.onwmsg),m.onerror=function(e){t.trigger(n.Events.ERROR,{type:a.ErrorTypes.OTHER_ERROR,details:a.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(e.message+" ("+e.filename+":"+e.lineno+")")})},m.postMessage({cmd:"init",typeSupported:p,vendor:g,id:e,config:JSON.stringify(d)})}catch(t){s.logger.warn("Error in worker:",t),s.logger.error("Error while initializing DemuxerWorker, fallback to inline"),m&&self.URL.revokeObjectURL(m.objectURL),this.transmuxer=new o.default(this.observer,p,d,g,e),this.worker=null}}else this.transmuxer=new o.default(this.observer,p,d,g,e)}var e=t.prototype;return e.destroy=function(){var t=this.worker;if(t)t.removeEventListener("message",this.onwmsg),t.terminate(),this.worker=null;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var r=this.observer;r&&r.removeAllListeners(),this.observer=null},e.push=function(t,e,r,i,n,a,l,c,u,h){var d=this;u.transmuxing.start=self.performance.now();var f=this.transmuxer,p=this.worker,g=a?a.start:n.start,m=n.decryptdata,v=this.frag,y=!(v&&n.cc===v.cc),b=!(v&&u.level===v.level),x=v?u.sn-v.sn:-1,S=this.part?u.part-this.part.index:1,C=!b&&(1===x||0===x&&1===S),w=self.performance.now();(b||x||0===n.stats.parsing.start)&&(n.stats.parsing.start=w),!a||!S&&C||(a.stats.parsing.start=w);var k=new o.TransmuxState(y,C,c,b,g);if(!C||y){s.logger.log("[transmuxer-interface, "+n.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+"\n discontinuity: "+y+"\n trackSwitch: "+b+"\n contiguous: "+C+"\n accurateTimeOffset: "+c+"\n timeOffset: "+g);var E=new o.TransmuxConfig(r,i,e,l,h);this.configureTransmuxer(E)}if(this.frag=n,this.part=a,p)p.postMessage({cmd:"demux",data:t,decryptdata:m,chunkMeta:u,state:k},t instanceof ArrayBuffer?[t]:[]);else if(f){var T=f.push(t,m,u,k);Object(o.isPromise)(T)?T.then((function(t){d.handleTransmuxComplete(t)})):this.handleTransmuxComplete(T)}},e.flush=function(t){var e=this;t.transmuxing.start=self.performance.now();var r=this.transmuxer,i=this.worker;if(i)i.postMessage({cmd:"flush",chunkMeta:t});else if(r){var n=r.flush(t);Object(o.isPromise)(n)?n.then((function(r){e.handleFlushResult(r,t)})):this.handleFlushResult(n,t)}},e.handleFlushResult=function(t,e){var r=this;t.forEach((function(t){r.handleTransmuxComplete(t)})),this.onFlush(e)},e.onWorkerMessage=function(t){var e=t.data,r=this.hls;switch(e.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,r.trigger(e.event,e.data)}},e.configureTransmuxer=function(t){var e=this.worker,r=this.transmuxer;e?e.postMessage({cmd:"configure",config:t}):r&&r.configure(t)},e.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},t}()},"./src/demux/transmuxer-worker.ts":
|
|
|
/*!****************************************!*\
|
|
|
!*** ./src/demux/transmuxer-worker.ts ***!
|
|
|
\****************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return a}));var i=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),n=r(/*! ../events */"./src/events.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");function a(t){var e=new s.EventEmitter,r=function(e,r){t.postMessage({event:e,data:r})};e.on(n.Events.FRAG_DECRYPTED,r),e.on(n.Events.ERROR,r),t.addEventListener("message",(function(n){var s=n.data;switch(s.cmd){case"init":var a=JSON.parse(s.config);t.transmuxer=new i.default(e,s.typeSupported,a,s.vendor,s.id),Object(o.enableLogs)(a.debug),r("init",null);break;case"configure":t.transmuxer.configure(s.config);break;case"demux":var c=t.transmuxer.push(s.data,s.decryptdata,s.chunkMeta,s.state);Object(i.isPromise)(c)?c.then((function(e){l(t,e)})):l(t,c);break;case"flush":var h=s.chunkMeta,d=t.transmuxer.flush(h);Object(i.isPromise)(d)?d.then((function(e){u(t,e,h)})):u(t,d,h)}}))}function l(t,e){if((r=e.remuxResult).audio||r.video||r.text||r.id3||r.initSegment){var r,i=[],n=e.remuxResult,o=n.audio,s=n.video;o&&c(i,o),s&&c(i,s),t.postMessage({event:"transmuxComplete",data:e},i)}}function c(t,e){e.data1&&t.push(e.data1.buffer),e.data2&&t.push(e.data2.buffer)}function u(t,e,r){e.forEach((function(e){l(t,e)})),t.postMessage({event:"flush",data:r})}},"./src/demux/transmuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/transmuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default, isPromise, TransmuxConfig, TransmuxState */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return y})),r.d(e,"isPromise",(function(){return x})),r.d(e,"TransmuxConfig",(function(){return S})),r.d(e,"TransmuxState",(function(){return C}));var i,n=r(/*! ../events */"./src/events.ts"),o=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),a=r(/*! ../demux/aacdemuxer */"./src/demux/aacdemuxer.ts"),l=r(/*! ../demux/mp4demuxer */"./src/demux/mp4demuxer.ts"),c=r(/*! ../demux/tsdemuxer */"./src/demux/tsdemuxer.ts"),u=r(/*! ../demux/mp3demuxer */"./src/demux/mp3demuxer.ts"),h=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),d=r(/*! ../remux/passthrough-remuxer */"./src/remux/passthrough-remuxer.ts"),f=r(/*! ./chunk-cache */"./src/demux/chunk-cache.ts"),p=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),g=r(/*! ../utils/logger */"./src/utils/logger.ts");try{i=self.performance.now.bind(self.performance)}catch(t){g.logger.debug("Unable to use Performance API on this environment"),i=self.Date.now}var m=[{demux:c.default,remux:h.default},{demux:l.default,remux:d.default},{demux:a.default,remux:h.default},{demux:u.default,remux:h.default}],v=1024;m.forEach((function(t){var e=t.demux;v=Math.max(v,e.minProbeByteLength)}));var y=function(){function t(t,e,r,i,n){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 f.default,this.observer=t,this.typeSupported=e,this.config=r,this.vendor=i,this.id=n}var e=t.prototype;return e.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},e.push=function(t,e,r,n){var o=this,s=r.transmuxing;s.executeStart=i();var a=new Uint8Array(t),l=this.cache,c=this.config,u=this.currentTransmuxState,h=this.transmuxConfig;n&&(this.currentTransmuxState=n);var d=function(t,e){var r=null;return t.byteLength>0&&null!=e&&null!=e.key&&null!==e.iv&&null!=e.method&&(r=e),r}(a,e);if(d&&"AES-128"===d.method){var f=this.getDecrypter();if(!c.enableSoftwareAES)return this.decryptionPromise=f.webCryptoDecrypt(a,d.key.buffer,d.iv.buffer).then((function(t){var e=o.push(t,null,r);return o.decryptionPromise=null,e})),this.decryptionPromise;var g=f.softwareDecrypt(a,d.key.buffer,d.iv.buffer);if(!g)return s.executeEnd=i(),b(r);a=new Uint8Array(g)}var m=n||u,v=m.contiguous,y=m.discontinuity,x=m.trackSwitch,S=m.accurateTimeOffset,C=m.timeOffset,w=h.audioCodec,k=h.videoCodec,E=h.defaultInitPts,T=h.duration,L=h.initSegmentData;if((y||x)&&this.resetInitSegment(L,w,k,T),y&&this.resetInitialTimestamp(E),v||this.resetContiguity(),this.needsProbing(a,y,x)){if(l.dataLength){var A=l.flush();a=Object(p.appendUint8Array)(A,a)}this.configureTransmuxer(a,h)}var D=this.transmux(a,d,C,S,r),O=this.currentTransmuxState;return O.contiguous=!0,O.discontinuity=!1,O.trackSwitch=!1,s.executeEnd=i(),D},e.flush=function(t){var e=this,r=t.transmuxing;r.executeStart=i();var s=this.decrypter,a=this.cache,l=this.currentTransmuxState,c=this.decryptionPromise;if(c)return c.then((function(){return e.flush(t)}));var u=[],h=l.timeOffset;if(s){var d=s.flush();d&&u.push(this.push(d,null,t))}var f=a.dataLength;a.reset();var p=this.demuxer,g=this.remuxer;if(!p||!g)return f>=v&&this.observer.emit(n.Events.ERROR,n.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),r.executeEnd=i(),[b(t)];var m=p.flush(h);return x(m)?m.then((function(r){return e.flushRemux(u,r,t),u})):(this.flushRemux(u,m,t),u)},e.flushRemux=function(t,e,r){var n=e.audioTrack,o=e.avcTrack,s=e.id3Track,a=e.textTrack,l=this.currentTransmuxState,c=l.accurateTimeOffset,u=l.timeOffset;g.logger.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var h=this.remuxer.remux(n,o,s,a,u,c,!0,this.id);t.push({remuxResult:h,chunkMeta:r}),r.transmuxing.executeEnd=i()},e.resetInitialTimestamp=function(t){var e=this.demuxer,r=this.remuxer;e&&r&&(e.resetTimeStamp(t),r.resetTimeStamp(t))},e.resetContiguity=function(){var t=this.demuxer,e=this.remuxer;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())},e.resetInitSegment=function(t,e,r,i){var n=this.demuxer,o=this.remuxer;n&&o&&(n.resetInitSegment(e,r,i),o.resetInitSegment(t,e,r))},e.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},e.transmux=function(t,e,r,i,n){return e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,r,i,n):this.transmuxUnencrypted(t,r,i,n)},e.transmuxUnencrypted=function(t,e,r,i){var n=this.demuxer.demux(t,e,!1,!this.config.progressive),o=n.audioTrack,s=n.avcTrack,a=n.id3Track,l=n.textTrack;return{remuxResult:this.remuxer.remux(o,s,a,l,e,r,!1,this.id),chunkMeta:i}},e.transmuxSampleAes=function(t,e,r,i,n){var o=this;return this.demuxer.demuxSampleAes(t,e,r).then((function(t){return{remuxResult:o.remuxer.remux(t.audioTrack,t.avcTrack,t.id3Track,t.textTrack,r,i,!1,o.id),chunkMeta:n}}))},e.configureTransmuxer=function(t,e){for(var r,i=this.config,n=this.observer,o=this.typeSupported,s=this.vendor,a=e.audioCodec,c=e.defaultInitPts,u=e.duration,h=e.initSegmentData,f=e.videoCodec,p=0,v=m.length;p<v;p++)if(m[p].demux.probe(t)){r=m[p];break}r||(g.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),r={demux:l.default,remux:d.default});var y=this.demuxer,b=this.remuxer,x=r.remux,S=r.demux;b&&b instanceof x||(this.remuxer=new x(n,i,o,s)),y&&y instanceof S||(this.demuxer=new S(n,i,o),this.probe=S.probe),this.resetInitSegment(h,a,f,u),this.resetInitialTimestamp(c)},e.needsProbing=function(t,e,r){return!this.demuxer||!this.remuxer||e||r},e.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new s.default(this.observer,this.config)),t},t}(),b=function(t){return{remuxResult:{},chunkMeta:t}};function x(t){return"then"in t&&t.then instanceof Function}var S=function(t,e,r,i,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=r,this.duration=i,this.defaultInitPts=n},C=function(t,e,r,i,n){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=n}},"./src/demux/tsdemuxer.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/demux/tsdemuxer.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: discardEPB, default */function(t,e,r){"use strict";r.r(e),r.d(e,"discardEPB",(function(){return x}));var i=r(/*! ./adts */"./src/demux/adts.ts"),n=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts"),o=r(/*! ./exp-golomb */"./src/demux/exp-golomb.ts"),s=r(/*! ./id3 */"./src/demux/id3.ts"),a=r(/*! ./sample-aes */"./src/demux/sample-aes.ts"),l=r(/*! ../events */"./src/events.ts"),c=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),u=r(/*! ../utils/logger */"./src/utils/logger.ts"),h=r(/*! ../errors */"./src/errors.ts"),d={video:1,audio:2,id3:3,text:4},f=function(){function t(t,e,r){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=t,this.config=e,this.typeSupported=r}t.probe=function(e){var r=t.syncOffset(e);return!(r<0||(r&&u.logger.warn("MPEG2-TS detected but first sync word found @ offset "+r+", junk ahead ?"),0))},t.syncOffset=function(t){for(var e=Math.min(1e3,t.length-564),r=0;r<e;){if(71===t[r]&&71===t[r+188]&&71===t[r+376])return r;r++}return-1},t.createTrack=function(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:d[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}};var e=t.prototype;return e.resetInitSegment=function(e,r,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=t.createTrack("video",i),this._audioTrack=t.createTrack("audio",i),this._id3Track=t.createTrack("id3",i),this._txtTrack=t.createTrack("text",i),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=e,this.videoCodec=r,this._duration=i},e.resetTimeStamp=function(){},e.resetContiguity=function(){var t=this._audioTrack,e=this._avcTrack,r=this._id3Track;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},e.demux=function(e,r,i,n){var o;void 0===i&&(i=!1),void 0===n&&(n=!1),i||(this.sampleAes=null);var s=this._avcTrack,a=this._audioTrack,d=this._id3Track,f=s.pid,p=s.pesData,y=a.pid,b=d.pid,x=a.pesData,S=d.pesData,C=!1,w=this.pmtParsed,k=this._pmtId,E=e.length;if(this.remainderData&&(E=(e=Object(c.appendUint8Array)(this.remainderData,e)).length,this.remainderData=null),E<188&&!n)return this.remainderData=e,{audioTrack:a,avcTrack:s,id3Track:d,textTrack:this._txtTrack};var T=Math.max(0,t.syncOffset(e));(E-=(E+T)%188)<e.byteLength&&!n&&(this.remainderData=new Uint8Array(e.buffer,E,e.buffer.byteLength-E));for(var L=T;L<E;L+=188)if(71===e[L]){var A=!!(64&e[L+1]),D=((31&e[L+1])<<8)+e[L+2],O=void 0;if((48&e[L+3])>>4>1){if((O=L+5+e[L+4])===L+188)continue}else O=L+4;switch(D){case f:A&&(p&&(o=v(p))&&this.parseAVCPES(o,!1),p={data:[],size:0}),p&&(p.data.push(e.subarray(O,L+188)),p.size+=L+188-O);break;case y:A&&(x&&(o=v(x))&&(a.isAAC?this.parseAACPES(o):this.parseMPEGPES(o)),x={data:[],size:0}),x&&(x.data.push(e.subarray(O,L+188)),x.size+=L+188-O);break;case b:A&&(S&&(o=v(S))&&this.parseID3PES(o),S={data:[],size:0}),S&&(S.data.push(e.subarray(O,L+188)),S.size+=L+188-O);break;case 0:A&&(O+=e[O]+1),k=this._pmtId=g(e,O);break;case k:A&&(O+=e[O]+1);var R=m(e,O,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,i);(f=R.avc)>0&&(s.pid=f),(y=R.audio)>0&&(a.pid=y,a.isAAC=R.isAAC),(b=R.id3)>0&&(d.pid=b),C&&!w&&(u.logger.log("reparse from beginning"),C=!1,L=T-188),w=this.pmtParsed=!0;break;case 17:case 8191:break;default:C=!0}}else this.observer.emit(l.Events.ERROR,l.Events.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});s.pesData=p,a.pesData=x,d.pesData=S;var _={audioTrack:a,avcTrack:s,id3Track:d,textTrack:this._txtTrack};return n&&this.extractRemainingSamples(_),_},e.flush=function(){var t,e=this.remainderData;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},e.extractRemainingSamples=function(t){var e,r=t.audioTrack,i=t.avcTrack,n=t.id3Track,o=i.pesData,s=r.pesData,a=n.pesData;o&&(e=v(o))?(this.parseAVCPES(e,!0),i.pesData=null):i.pesData=o,s&&(e=v(s))?(r.isAAC?this.parseAACPES(e):this.parseMPEGPES(e),r.pesData=null):(null!=s&&s.size&&u.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=s),a&&(e=v(a))?(this.parseID3PES(e),n.pesData=null):n.pesData=a},e.demuxSampleAes=function(t,e,r){var i=this.demux(t,r,!0,!this.config.progressive),n=this.sampleAes=new a.default(this.observer,this.config,e);return this.decrypt(i,n)},e.decrypt=function(t,e){return new Promise((function(r){var i=t.audioTrack,n=t.avcTrack;i.samples&&i.isAAC?e.decryptAacSamples(i.samples,0,(function(){n.samples?e.decryptAvcSamples(n.samples,0,0,(function(){r(t)})):r(t)})):n.samples&&e.decryptAvcSamples(n.samples,0,0,(function(){r(t)}))}))},e.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},e.parseAVCPES=function(t,e){var r,i=this,n=this._avcTrack,a=this.parseAVCNALu(t.data),l=this.avcSample,c=!1;t.data=null,l&&a.length&&!n.audFound&&(y(l,n),l=this.avcSample=p(!1,t.pts,t.dts,"")),a.forEach((function(e){switch(e.type){case 1:r=!0,l||(l=i.avcSample=p(!0,t.pts,t.dts,"")),l.frame=!0;var a=e.data;if(c&&a.length>4){var u=new o.default(a).readSliceType();2!==u&&4!==u&&7!==u&&9!==u||(l.key=!0)}break;case 5:r=!0,l||(l=i.avcSample=p(!0,t.pts,t.dts,"")),l.key=!0,l.frame=!0;break;case 6:r=!0;var h=new o.default(x(e.data));h.readUByte();for(var d=0,f=0,g=!1,m=0;!g&&h.bytesAvailable>1;){d=0;do{d+=m=h.readUByte()}while(255===m);f=0;do{f+=m=h.readUByte()}while(255===m);if(4===d&&0!==h.bytesAvailable){if(g=!0,181===h.readUByte()&&49===h.readUShort()&&1195456820===h.readUInt()&&3===h.readUByte()){for(var v=h.readUByte(),S=31&v,C=[v,h.readUByte()],w=0;w<S;w++)C.push(h.readUByte()),C.push(h.readUByte()),C.push(h.readUByte());b(i._txtTrack.samples,{type:3,pts:t.pts,bytes:C})}}else if(5===d&&0!==h.bytesAvailable){if(g=!0,f>16){for(var k=[],E=0;E<16;E++)k.push(h.readUByte().toString(16)),3!==E&&5!==E&&7!==E&&9!==E||k.push("-");for(var T=f-16,L=new Uint8Array(T),A=0;A<T;A++)L[A]=h.readUByte();b(i._txtTrack.samples,{pts:t.pts,payloadType:d,uuid:k.join(""),userData:Object(s.utf8ArrayToStr)(L),userDataBytes:L})}}else if(f<h.bytesAvailable)for(var D=0;D<f;D++)h.readUByte()}break;case 7:if(r=!0,c=!0,!n.sps){var O=new o.default(e.data).readSPS();n.width=O.width,n.height=O.height,n.pixelRatio=O.pixelRatio,n.sps=[e.data],n.duration=i._duration;for(var R=e.data.subarray(1,4),_="avc1.",I=0;I<3;I++){var M=R[I].toString(16);M.length<2&&(M="0"+M),_+=M}n.codec=_}break;case 8:r=!0,n.pps||(n.pps=[e.data]);break;case 9:r=!1,n.audFound=!0,l&&y(l,n),l=i.avcSample=p(!1,t.pts,t.dts,"");break;case 12:r=!1;break;default:r=!1,l&&(l.debug+="unknown NAL "+e.type+" ")}l&&r&&l.units.push(e)})),e&&l&&(y(l,n),this.avcSample=null)},e.getLastNalUnit=function(){var t,e,r=this.avcSample;if(!r||0===r.units.length){var i=this._avcTrack.samples;r=i[i.length-1]}if(null!==(t=r)&&void 0!==t&&t.units){var n=r.units;e=n[n.length-1]}return e},e.parseAVCNALu=function(t){var e,r,i=t.byteLength,n=this._avcTrack,o=n.naluState||0,s=o,a=[],l=0,c=-1,u=0;for(-1===o&&(c=0,u=31&t[0],o=0,l=1);l<i;)if(e=t[l++],o)if(1!==o)if(e)if(1===e){if(c>=0){var h={data:t.subarray(c,l-o-1),type:u};a.push(h)}else{var d=this.getLastNalUnit();if(d&&(s&&l<=4-s&&d.state&&(d.data=d.data.subarray(0,d.data.byteLength-s)),(r=l-o-1)>0)){var f=new Uint8Array(d.data.byteLength+r);f.set(d.data,0),f.set(t.subarray(0,r),d.data.byteLength),d.data=f,d.state=0}}l<i?(c=l,u=31&t[l],o=0):o=-1}else o=0;else o=3;else o=e?0:2;else o=e?0:1;if(c>=0&&o>=0){var p={data:t.subarray(c,i),type:u,state:o};a.push(p)}if(0===a.length){var g=this.getLastNalUnit();if(g){var m=new Uint8Array(g.data.byteLength+t.byteLength);m.set(g.data,0),m.set(t,g.data.byteLength),g.data=m}}return n.naluState=o,a},e.parseAACPES=function(t){var e,r,n,o,s,a=0,c=this._audioTrack,d=this.aacOverFlow,f=t.data;if(d){this.aacOverFlow=null;var p=d.sample.unit.byteLength,g=Math.min(d.missing,p),m=p-g;d.sample.unit.set(f.subarray(0,g),m),c.samples.push(d.sample),a=d.missing}for(e=a,r=f.length;e<r-1&&!i.isHeader(f,e);e++);if(e===a||(e<r-1?(n="AAC PES did not start with ADTS header,offset:"+e,o=!1):(n="no ADTS header found in AAC PES",o=!0),u.logger.warn("parsing error:"+n),this.observer.emit(l.Events.ERROR,l.Events.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.FRAG_PARSING_ERROR,fatal:o,reason:n}),!o)){if(i.initTrackConfig(c,this.observer,f,e,this.audioCodec),void 0!==t.pts)s=t.pts;else{if(!d)return void u.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var v=i.getFrameDuration(c.samplerate);s=d.sample.pts+v}for(var y=0;e<r;){if(i.isHeader(f,e)){if(e+5<r){var b=i.appendFrame(c,f,e,s,y);if(b){if(!b.missing){e+=b.length,y++;continue}this.aacOverFlow=b}}break}e++}}},e.parseMPEGPES=function(t){var e=t.data,r=e.length,i=0,o=0,s=t.pts;if(void 0!==s)for(;o<r;)if(n.isHeader(e,o)){var a=n.appendFrame(this._audioTrack,e,o,s,i);if(!a)break;o+=a.length,i++}else o++;else u.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},e.parseID3PES=function(t){void 0!==t.pts?this._id3Track.samples.push(t):u.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},t}();function p(t,e,r,i){return{key:t,frame:!1,pts:e,dts:r,units:[],debug:i,length:0}}function g(t,e){return(31&t[e+10])<<8|t[e+11]}function m(t,e,r,i){var n={audio:-1,avc:-1,id3:-1,isAAC:!0},o=e+3+((15&t[e+1])<<8|t[e+2])-4;for(e+=12+((15&t[e+10])<<8|t[e+11]);e<o;){var s=(31&t[e+1])<<8|t[e+2];switch(t[e]){case 207:if(!i){u.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===n.audio&&(n.audio=s);break;case 21:-1===n.id3&&(n.id3=s);break;case 219:if(!i){u.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===n.avc&&(n.avc=s);break;case 3:case 4:r?-1===n.audio&&(n.audio=s,n.isAAC=!1):u.logger.log("MPEG audio found, not supported in this browser");break;case 36:u.logger.warn("Unsupported HEVC stream type found")}e+=5+((15&t[e+3])<<8|t[e+4])}return n}function v(t){var e,r,i,n,o,s=0,a=t.data;if(!t||0===t.size)return null;for(;a[0].length<19&&a.length>1;){var l=new Uint8Array(a[0].length+a[1].length);l.set(a[0]),l.set(a[1],a[0].length),a[0]=l,a.splice(1,1)}if(1===((e=a[0])[0]<<16)+(e[1]<<8)+e[2]){if((r=(e[4]<<8)+e[5])&&r>t.size-6)return null;var c=e[7];192&c&&(n=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&c?n-(o=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2)>54e5&&(u.logger.warn(Math.round((n-o)/9e4)+"s delta between PTS and DTS, align them"),n=o):o=n);var h=(i=e[8])+9;if(t.size<=h)return null;t.size-=h;for(var d=new Uint8Array(t.size),f=0,p=a.length;f<p;f++){var g=(e=a[f]).byteLength;if(h){if(h>g){h-=g;continue}e=e.subarray(h),g-=h,h=0}d.set(e,s),s+=g}return r&&(r-=i+3),{data:d,pts:n,dts:o,len:r}}return null}function y(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){var r=e.samples,i=r.length;if(!i)return void e.dropped++;var n=r[i-1];t.pts=n.pts,t.dts=n.dts}e.samples.push(t)}t.debug.length&&u.logger.log(t.pts+"/"+t.dts+":"+t.debug)}function b(t,e){var r=t.length;if(r>0){if(e.pts>=t[r-1].pts)t.push(e);else for(var i=r-1;i>=0;i--)if(e.pts<t[i].pts){t.splice(i,0,e);break}}else t.push(e)}function x(t){for(var e=t.byteLength,r=[],i=1;i<e-2;)0===t[i]&&0===t[i+1]&&3===t[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return t;var n=e-r.length,o=new Uint8Array(n),s=0;for(i=0;i<n;s++,i++)s===r[0]&&(s++,r.shift()),o[i]=t[s];return o}f.minProbeByteLength=188,e.default=f},"./src/errors.ts":
|
|
|
/*!***********************!*\
|
|
|
!*** ./src/errors.ts ***!
|
|
|
\***********************/
|
|
|
/*! exports provided: ErrorTypes, ErrorDetails */function(t,e,r){"use strict";var i,n;r.r(e),r.d(e,"ErrorTypes",(function(){return i})),r.d(e,"ErrorDetails",(function(){return n})),function(t){t.NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError"}(i||(i={})),function(t){t.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown"}(n||(n={}))},"./src/events.ts":
|
|
|
/*!***********************!*\
|
|
|
!*** ./src/events.ts ***!
|
|
|
\***********************/
|
|
|
/*! exports provided: Events */function(t,e,r){"use strict";var i;r.r(e),r.d(e,"Events",(function(){return i})),function(t){t.MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached"}(i||(i={}))},"./src/hls.ts":
|
|
|
/*!********************!*\
|
|
|
!*** ./src/hls.ts ***!
|
|
|
\********************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return y}));var i=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),n=r(/*! ./loader/playlist-loader */"./src/loader/playlist-loader.ts"),o=r(/*! ./loader/key-loader */"./src/loader/key-loader.ts"),s=r(/*! ./controller/id3-track-controller */"./src/controller/id3-track-controller.ts"),a=r(/*! ./controller/latency-controller */"./src/controller/latency-controller.ts"),l=r(/*! ./controller/level-controller */"./src/controller/level-controller.ts"),c=r(/*! ./controller/fragment-tracker */"./src/controller/fragment-tracker.ts"),u=r(/*! ./controller/stream-controller */"./src/controller/stream-controller.ts"),h=r(/*! ./is-supported */"./src/is-supported.ts"),d=r(/*! ./utils/logger */"./src/utils/logger.ts"),f=r(/*! ./config */"./src/config.ts"),p=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),g=r(/*! ./events */"./src/events.ts"),m=r(/*! ./errors */"./src/errors.ts");function v(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var y=function(){function t(e){void 0===e&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new p.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var r=this.config=Object(f.mergeConfig)(t.DefaultConfig,e);this.userConfig=e,Object(d.enableLogs)(r.debug),this._autoLevelCapping=-1,r.progressive&&Object(f.enableStreamingMode)(r);var i=r.abrController,h=r.bufferController,g=r.capLevelController,m=r.fpsController,v=this.abrController=new i(this),y=this.bufferController=new h(this),b=this.capLevelController=new g(this),x=new m(this),S=new n.default(this),C=new o.default(this),w=new s.default(this),k=this.levelController=new l.default(this),E=new c.FragmentTracker(this),T=this.streamController=new u.default(this,E);b.setStreamController(T),x.setStreamController(T);var L=[k,T];this.networkControllers=L;var A=[S,C,v,y,b,x,w,E];this.audioTrackController=this.createController(r.audioTrackController,null,L),this.createController(r.audioStreamController,E,L),this.subtitleTrackController=this.createController(r.subtitleTrackController,null,L),this.createController(r.subtitleStreamController,E,L),this.createController(r.timelineController,null,A),this.emeController=this.createController(r.emeController,null,A),this.cmcdController=this.createController(r.cmcdController,null,A),this.latencyController=this.createController(a.default,null,A),this.coreComponents=A}t.isSupported=function(){return Object(h.isSupported)()};var e,r,y,b=t.prototype;return b.createController=function(t,e,r){if(t){var i=e?new t(this,e):new t(this);return r&&r.push(i),i}return null},b.on=function(t,e,r){void 0===r&&(r=this),this._emitter.on(t,e,r)},b.once=function(t,e,r){void 0===r&&(r=this),this._emitter.once(t,e,r)},b.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},b.off=function(t,e,r,i){void 0===r&&(r=this),this._emitter.off(t,e,r,i)},b.listeners=function(t){return this._emitter.listeners(t)},b.emit=function(t,e,r){return this._emitter.emit(t,e,r)},b.trigger=function(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){d.logger.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),this.trigger(g.Events.ERROR,{type:m.ErrorTypes.OTHER_ERROR,details:m.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:e})}return!1},b.listenerCount=function(t){return this._emitter.listenerCount(t)},b.destroy=function(){d.logger.log("destroy"),this.trigger(g.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(t){return t.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(t){return t.destroy()})),this.coreComponents.length=0},b.attachMedia=function(t){d.logger.log("attachMedia"),this._media=t,this.trigger(g.Events.MEDIA_ATTACHING,{media:t})},b.detachMedia=function(){d.logger.log("detachMedia"),this.trigger(g.Events.MEDIA_DETACHING,void 0),this._media=null},b.loadSource=function(t){this.stopLoad();var e=this.media,r=this.url,n=this.url=i.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});d.logger.log("loadSource:"+n),e&&r&&r!==n&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(e)),this.trigger(g.Events.MANIFEST_LOADING,{url:t})},b.startLoad=function(t){void 0===t&&(t=-1),d.logger.log("startLoad("+t+")"),this.networkControllers.forEach((function(e){e.startLoad(t)}))},b.stopLoad=function(){d.logger.log("stopLoad"),this.networkControllers.forEach((function(t){t.stopLoad()}))},b.swapAudioCodec=function(){d.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},b.recoverMediaError=function(){d.logger.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},b.removeLevel=function(t,e){void 0===e&&(e=0),this.levelController.removeLevel(t,e)},e=t,y=[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return g.Events}},{key:"ErrorTypes",get:function(){return m.ErrorTypes}},{key:"ErrorDetails",get:function(){return m.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:f.hlsDefaultConfig},set:function(e){t.defaultConfig=e}}],(r=[{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){d.logger.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){d.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){d.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){d.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){d.logger.log("set startLevel:"+t),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(d.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,e=this.config.minAutoBitrate;if(!t)return 0;for(var r=t.length,i=0;i<r;i++)if(t[i].maxBitrate>e)return i;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,e=this.autoLevelCapping;return-1===e&&t&&t.length?t.length-1:e}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{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}}])&&v(e.prototype,r),y&&v(e,y),t}();y.defaultConfig=void 0},"./src/is-supported.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/is-supported.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: isSupported, changeTypeSupported */function(t,e,r){"use strict";r.r(e),r.d(e,"isSupported",(function(){return o})),r.d(e,"changeTypeSupported",(function(){return s}));var i=r(/*! ./utils/mediasource-helper */"./src/utils/mediasource-helper.ts");function n(){return self.SourceBuffer||self.WebKitSourceBuffer}function o(){var t=Object(i.getMediaSource)();if(!t)return!1;var e=n(),r=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),o=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove;return!!r&&!!o}function s(){var t,e=n();return"function"==typeof(null==e||null===(t=e.prototype)||void 0===t?void 0:t.changeType)}},"./src/loader/fragment-loader.ts":
|
|
|
/*!***************************************!*\
|
|
|
!*** ./src/loader/fragment-loader.ts ***!
|
|
|
\***************************************/
|
|
|
/*! exports provided: default, LoadError */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return h})),r.d(e,"LoadError",(function(){return f}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../errors */"./src/errors.ts");function o(t){var e="function"==typeof Map?new Map:void 0;return(o=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,i)}function i(){return s(t,arguments,c(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),l(i,t)})(t)}function s(t,e,r){return(s=a()?Reflect.construct:function(t,e,r){var i=[null];i.push.apply(i,e);var n=new(Function.bind.apply(t,i));return r&&l(n,r.prototype),n}).apply(null,arguments)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var u=Math.pow(2,17),h=function(){function t(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}var e=t.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(t,e){var r=this,i=t.url;if(!i)return Promise.reject(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,networkDetails:null},"Fragment does not have a "+(i?"part list":"url")));this.abort();var o=this.config,s=o.fLoader,a=o.loader;return new Promise((function(i,l){r.loader&&r.loader.destroy();var c=r.loader=t.loader=s?new s(o):new a(o),h=d(t),p={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:u};t.stats=c.stats,c.load(h,p,{onSuccess:function(e,n,o,s){r.resetLoader(t,c),i({frag:t,part:null,payload:e.data,networkDetails:s})},onError:function(e,i,o){r.resetLoader(t,c),l(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:e,networkDetails:o}))},onAbort:function(e,i,o){r.resetLoader(t,c),l(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,networkDetails:o}))},onTimeout:function(e,i,o){r.resetLoader(t,c),l(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,networkDetails:o}))},onProgress:function(r,i,n,o){e&&e({frag:t,part:null,payload:n,networkDetails:o})}})}))},e.loadPart=function(t,e,r){var i=this;this.abort();var o=this.config,s=o.fLoader,a=o.loader;return new Promise((function(l,c){i.loader&&i.loader.destroy();var h=i.loader=t.loader=s?new s(o):new a(o),p=d(t,e),g={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:u};e.stats=h.stats,h.load(p,g,{onSuccess:function(n,o,s,a){i.resetLoader(t,h),i.updateStatsFromPart(t,e);var c={frag:t,part:e,payload:n.data,networkDetails:a};r(c),l(c)},onError:function(r,o,s){i.resetLoader(t,h),c(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:r,networkDetails:s}))},onAbort:function(r,o,s){t.stats.aborted=e.stats.aborted,i.resetLoader(t,h),c(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,networkDetails:s}))},onTimeout:function(r,o,s){i.resetLoader(t,h),c(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,networkDetails:s}))}})}))},e.updateStatsFromPart=function(t,e){var r=t.stats,i=e.stats,n=i.total;if(r.loaded+=i.loaded,n){var o=Math.round(t.duration/e.duration),s=Math.min(Math.round(r.loaded/n),o),a=(o-s)*Math.round(r.loaded/s);r.total=r.loaded+a}else r.total=Math.max(r.loaded,r.total);var l=r.loading,c=i.loading;l.start?l.first+=c.first-c.start:(l.start=c.start,l.first=c.first),l.end=c.end},e.resetLoader=function(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()},t}();function d(t,e){void 0===e&&(e=null);var r=e||t,n={frag:t,part:e,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},o=r.byteRangeStartOffset,s=r.byteRangeEndOffset;return Object(i.isFiniteNumber)(o)&&Object(i.isFiniteNumber)(s)&&(n.rangeStart=o,n.rangeEnd=s),n}var f=function(t){var e,r;function i(e){for(var r,i=arguments.length,n=new Array(i>1?i-1:0),o=1;o<i;o++)n[o-1]=arguments[o];return(r=t.call.apply(t,[this].concat(n))||this).data=void 0,r.data=e,r}return r=t,(e=i).prototype=Object.create(r.prototype),e.prototype.constructor=e,l(e,r),i}(o(Error))},"./src/loader/fragment.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/loader/fragment.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: ElementaryStreamTypes, BaseSegment, Fragment, Part */function(t,e,r){"use strict";r.r(e),r.d(e,"ElementaryStreamTypes",(function(){return i})),r.d(e,"BaseSegment",(function(){return f})),r.d(e,"Fragment",(function(){return p})),r.d(e,"Part",(function(){return g}));var i,n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),o=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ./level-key */"./src/loader/level-key.ts"),l=r(/*! ./load-stats */"./src/loader/load-stats.ts");function c(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,u(t,e)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function h(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function d(t,e,r){return e&&h(t.prototype,e),r&&h(t,r),t}!function(t){t.AUDIO="audio",t.VIDEO="video",t.AUDIOVIDEO="audiovideo"}(i||(i={}));var f=function(){function t(t){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[i.AUDIO]=null,e[i.VIDEO]=null,e[i.AUDIOVIDEO]=null,e),this.baseurl=t}return t.prototype.setByteRange=function(t,e){var r=t.split("@",2),i=[];1===r.length?i[0]=e?e.byteRangeEndOffset:0:i[0]=parseInt(r[1]),i[1]=parseInt(r[0])+i[0],this._byteRange=i},d(t,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(o.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}]),t}(),p=function(t){function e(e,r){var i;return(i=t.call(this,r)||this)._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkey=void 0,i.type=void 0,i.loader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.appendedPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new l.LoadStats,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.type=e,i}c(e,t);var r=e.prototype;return r.createInitializationVector=function(t){for(var e=new Uint8Array(16),r=12;r<16;r++)e[r]=t>>8*(15-r)&255;return e},r.setDecryptDataFromLevelKey=function(t,e){var r=t;return"AES-128"===(null==t?void 0:t.method)&&t.uri&&!t.iv&&((r=a.LevelKey.fromURI(t.uri)).method=t.method,r.iv=this.createInitializationVector(e),r.keyFormat="identity"),r},r.setElementaryStreamInfo=function(t,e,r,i,n,o){void 0===o&&(o=!1);var s=this.elementaryStreams,a=s[t];a?(a.startPTS=Math.min(a.startPTS,e),a.endPTS=Math.max(a.endPTS,r),a.startDTS=Math.min(a.startDTS,i),a.endDTS=Math.max(a.endDTS,n)):s[t]={startPTS:e,endPTS:r,startDTS:i,endDTS:n,partial:o}},r.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[i.AUDIO]=null,t[i.VIDEO]=null,t[i.AUDIOVIDEO]=null},d(e,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var t=this.sn;"number"!=typeof t&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&s.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),t=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,t)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(n.isFiniteNumber)(this.programDateTime))return null;var t=Object(n.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*t}},{key:"encrypted",get:function(){var t;return!(null===(t=this.decryptdata)||void 0===t||!t.keyFormat||!this.decryptdata.uri)}}]),e}(f),g=function(t){function e(e,r,i,n,o){var s;(s=t.call(this,i)||this).fragOffset=0,s.duration=0,s.gap=!1,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.stats=new l.LoadStats,s.duration=e.decimalFloatingPoint("DURATION"),s.gap=e.bool("GAP"),s.independent=e.bool("INDEPENDENT"),s.relurl=e.enumeratedString("URI"),s.fragment=r,s.index=n;var a=e.enumeratedString("BYTERANGE");return a&&s.setByteRange(a,o),o&&(s.fragOffset=o.fragOffset+o.duration),s}return c(e,t),d(e,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)}}]),e}(f)},"./src/loader/key-loader.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/loader/key-loader.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return s}));var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=function(){function t(t){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=t,this._registerListeners()}var e=t.prototype;return e._registerListeners=function(){this.hls.on(i.Events.KEY_LOADING,this.onKeyLoading,this)},e._unregisterListeners=function(){this.hls.off(i.Events.KEY_LOADING,this.onKeyLoading)},e.destroy=function(){for(var t in this._unregisterListeners(),this.loaders){var e=this.loaders[t];e&&e.destroy()}this.loaders={}},e.onKeyLoading=function(t,e){var r=e.frag,n=r.type,s=this.loaders[n];if(r.decryptdata){var a=r.decryptdata.uri;if(a!==this.decrypturl||null===this.decryptkey){var l=this.hls.config;if(s&&(o.logger.warn("abort previous key loader for type:"+n),s.abort()),!a)return void o.logger.warn("key uri is falsy");var c=l.loader,u=r.loader=this.loaders[n]=new c(l);this.decrypturl=a,this.decryptkey=null;var h={url:a,frag:r,responseType:"arraybuffer"},d={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:l.fragLoadingRetryDelay,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:0},f={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};u.load(h,d,f)}else this.decryptkey&&(r.decryptdata.key=this.decryptkey,this.hls.trigger(i.Events.KEY_LOADED,{frag:r}))}else o.logger.warn("Missing decryption data on fragment in onKeyLoading")},e.loadsuccess=function(t,e,r){var n=r.frag;n.decryptdata?(this.decryptkey=n.decryptdata.key=new Uint8Array(t.data),n.loader=null,delete this.loaders[n.type],this.hls.trigger(i.Events.KEY_LOADED,{frag:n})):o.logger.error("after key load, decryptdata unset")},e.loaderror=function(t,e){var r=e.frag,o=r.loader;o&&o.abort(),delete this.loaders[r.type],this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:r,response:t})},e.loadtimeout=function(t,e){var r=e.frag,o=r.loader;o&&o.abort(),delete this.loaders[r.type],this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})},t}()},"./src/loader/level-details.ts":
|
|
|
/*!*************************************!*\
|
|
|
!*** ./src/loader/level-details.ts ***!
|
|
|
\*************************************/
|
|
|
/*! exports provided: LevelDetails */function(t,e,r){"use strict";r.r(e),r.d(e,"LevelDetails",(function(){return o}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");function n(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var o=function(){function t(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.url=t}var e,r,o;return t.prototype.reloaded=function(t){if(!t)return this.advanced=!0,void(this.updated=!0);var e=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!r||!!e,this.advanced=this.endSN>t.endSN||e>0||0===e&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay},e=t,(r=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&Object(i.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return null!==(t=this.fragments)&&void 0!==t&&t.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&n(e.prototype,r),o&&n(e,o),t}()},"./src/loader/level-key.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/loader/level-key.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: LevelKey */function(t,e,r){"use strict";r.r(e),r.d(e,"LevelKey",(function(){return o}));var i=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");function n(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var o=function(){function t(t,e){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,this._uri=e?Object(i.buildAbsoluteURL)(t,e,{alwaysNormalize:!0}):t}var e,r,o;return t.fromURL=function(e,r){return new t(e,r)},t.fromURI=function(e){return new t(e)},e=t,(r=[{key:"uri",get:function(){return this._uri}}])&&n(e.prototype,r),o&&n(e,o),t}()},"./src/loader/load-stats.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/loader/load-stats.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: LoadStats */function(t,e,r){"use strict";r.r(e),r.d(e,"LoadStats",(function(){return i}));var i=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":
|
|
|
/*!***********************************!*\
|
|
|
!*** ./src/loader/m3u8-parser.ts ***!
|
|
|
\***********************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return m}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),o=r(/*! ./fragment */"./src/loader/fragment.ts"),s=r(/*! ./level-details */"./src/loader/level-details.ts"),a=r(/*! ./level-key */"./src/loader/level-key.ts"),l=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),c=r(/*! ../utils/logger */"./src/utils/logger.ts"),u=r(/*! ../utils/codecs */"./src/utils/codecs.ts"),h=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,d=/#EXT-X-MEDIA:(.*)/g,f=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),p=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),g=/\.(mp4|m4s|m4v|m4a)$/i,m=function(){function t(){}return t.findGroup=function(t,e){for(var r=0;r<t.length;r++){var i=t[r];if(i.id===e)return i}},t.convertAVC1ToAVCOTI=function(t){var e=t.split(".");if(e.length>2){var r=e.shift()+".";return r+=parseInt(e.shift()).toString(16),r+=("000"+parseInt(e.shift()).toString(16)).substr(-4)}return t},t.resolve=function(t,e){return n.buildAbsoluteURL(e,t,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(e,r){var i,n=[],o={},s=!1;for(h.lastIndex=0;null!=(i=h.exec(e));)if(i[1]){var a=new l.AttrList(i[1]),c={attrs:a,bitrate:a.decimalInteger("AVERAGE-BANDWIDTH")||a.decimalInteger("BANDWIDTH"),name:a.NAME,url:t.resolve(i[2],r)},u=a.decimalResolution("RESOLUTION");u&&(c.width=u.width,c.height=u.height),v((a.CODECS||"").split(/[ ,]+/).filter((function(t){return t})),c),c.videoCodec&&-1!==c.videoCodec.indexOf("avc1")&&(c.videoCodec=t.convertAVC1ToAVCOTI(c.videoCodec)),n.push(c)}else if(i[3]){var d=new l.AttrList(i[3]);d["DATA-ID"]&&(s=!0,o[d["DATA-ID"]]=d)}return{levels:n,sessionData:s?o:null}},t.parseMasterPlaylistMedia=function(e,r,i,n){var o;void 0===n&&(n=[]);var s=[],a=0;for(d.lastIndex=0;null!==(o=d.exec(e));){var c=new l.AttrList(o[1]);if(c.TYPE===i){var u={attrs:c,bitrate:0,id:a++,groupId:c["GROUP-ID"],instreamId:c["INSTREAM-ID"],name:c.NAME||c.LANGUAGE||"",type:i,default:c.bool("DEFAULT"),autoselect:c.bool("AUTOSELECT"),forced:c.bool("FORCED"),lang:c.LANGUAGE,url:c.URI?t.resolve(c.URI,r):""};if(n.length){var h=t.findGroup(n,u.groupId)||n[0];y(u,h,"audioCodec"),y(u,h,"textCodec")}s.push(u)}}return s},t.parseLevelPlaylist=function(t,e,r,u,h){var d,m,v,y=new s.LevelDetails(e),x=y.fragments,S=null,C=0,w=0,k=0,E=0,T=null,L=new o.Fragment(u,e),A=-1,D=!1;for(f.lastIndex=0,y.m3u8=t;null!==(d=f.exec(t));){D&&(D=!1,(L=new o.Fragment(u,e)).start=k,L.sn=C,L.cc=E,L.level=r,S&&(L.initSegment=S,L.rawProgramDateTime=S.rawProgramDateTime));var O=d[1];if(O){L.duration=parseFloat(O);var R=(" "+d[2]).slice(1);L.title=R||null,L.tagList.push(R?["INF",O,R]:["INF",O])}else if(d[3])Object(i.isFiniteNumber)(L.duration)&&(L.start=k,v&&(L.levelkey=v),L.sn=C,L.level=r,L.cc=E,L.urlId=h,x.push(L),L.relurl=(" "+d[3]).slice(1),b(L,T),T=L,k+=L.duration,C++,w=0,D=!0);else if(d[4]){var _=(" "+d[4]).slice(1);T?L.setByteRange(_,T):L.setByteRange(_)}else if(d[5])L.rawProgramDateTime=(" "+d[5]).slice(1),L.tagList.push(["PROGRAM-DATE-TIME",L.rawProgramDateTime]),-1===A&&(A=x.length);else{if(!(d=d[0].match(p))){c.logger.warn("No matches on slow regex match for level playlist!");continue}for(m=1;m<d.length&&void 0===d[m];m++);var I=(" "+d[m]).slice(1),M=(" "+d[m+1]).slice(1),P=d[m+2]?(" "+d[m+2]).slice(1):"";switch(I){case"PLAYLIST-TYPE":y.type=M.toUpperCase();break;case"MEDIA-SEQUENCE":C=y.startSN=parseInt(M);break;case"SKIP":var N=new l.AttrList(M),F=N.decimalInteger("SKIPPED-SEGMENTS");if(Object(i.isFiniteNumber)(F)){y.skippedSegments=F;for(var B=F;B--;)x.unshift(null);C+=F}var j=N.enumeratedString("RECENTLY-REMOVED-DATERANGES");j&&(y.recentlyRemovedDateranges=j.split("\t"));break;case"TARGETDURATION":y.targetduration=parseFloat(M);break;case"VERSION":y.version=parseInt(M);break;case"EXTM3U":break;case"ENDLIST":y.live=!1;break;case"#":(M||P)&&L.tagList.push(P?[M,P]:[M]);break;case"DIS":E++;case"GAP":L.tagList.push([I]);break;case"BITRATE":L.tagList.push([I,M]);break;case"DISCONTINUITY-SEQ":E=parseInt(M);break;case"KEY":var U,H=new l.AttrList(M),G=H.enumeratedString("METHOD"),z=H.URI,W=H.hexadecimalInteger("IV"),V=H.enumeratedString("KEYFORMATVERSIONS"),K=H.enumeratedString("KEYID"),q=null!=(U=H.enumeratedString("KEYFORMAT"))?U:"identity";if(["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"].indexOf(q)>-1){c.logger.warn("Keyformat "+q+" is not supported from the manifest");continue}if("identity"!==q)continue;G&&(v=a.LevelKey.fromURL(e,z),z&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(G)>=0&&(v.method=G,v.keyFormat=q,K&&(v.keyID=K),V&&(v.keyFormatVersions=V),v.iv=W));break;case"START":var Y=new l.AttrList(M).decimalFloatingPoint("TIME-OFFSET");Object(i.isFiniteNumber)(Y)&&(y.startTimeOffset=Y);break;case"MAP":var X=new l.AttrList(M);L.relurl=X.URI,X.BYTERANGE&&L.setByteRange(X.BYTERANGE),L.level=r,L.sn="initSegment",v&&(L.levelkey=v),L.initSegment=null,S=L,D=!0;break;case"SERVER-CONTROL":var $=new l.AttrList(M);y.canBlockReload=$.bool("CAN-BLOCK-RELOAD"),y.canSkipUntil=$.optionalFloat("CAN-SKIP-UNTIL",0),y.canSkipDateRanges=y.canSkipUntil>0&&$.bool("CAN-SKIP-DATERANGES"),y.partHoldBack=$.optionalFloat("PART-HOLD-BACK",0),y.holdBack=$.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Z=new l.AttrList(M);y.partTarget=Z.decimalFloatingPoint("PART-TARGET");break;case"PART":var Q=y.partList;Q||(Q=y.partList=[]);var J=w>0?Q[Q.length-1]:void 0,tt=w++,et=new o.Part(new l.AttrList(M),L,e,tt,J);Q.push(et),L.duration+=et.duration;break;case"PRELOAD-HINT":var rt=new l.AttrList(M);y.preloadHint=rt;break;case"RENDITION-REPORT":var it=new l.AttrList(M);y.renditionReports=y.renditionReports||[],y.renditionReports.push(it);break;default:c.logger.warn("line parsed but not handled: "+d)}}}T&&!T.relurl?(x.pop(),k-=T.duration,y.partList&&(y.fragmentHint=T)):y.partList&&(b(L,T),L.cc=E,y.fragmentHint=L);var nt=x.length,ot=x[0],st=x[nt-1];if((k+=y.skippedSegments*y.targetduration)>0&&nt&&st){y.averagetargetduration=k/nt;var at=st.sn;y.endSN="initSegment"!==at?at:0,ot&&(y.startCC=ot.cc,ot.initSegment||y.fragments.every((function(t){return t.relurl&&(e=t.relurl,g.test(null!=(r=null===(i=n.parseURL(e))||void 0===i?void 0:i.path)?r:""));var e,r,i}))&&(c.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(L=new o.Fragment(u,e)).relurl=st.relurl,L.level=r,L.sn="initSegment",ot.initSegment=L,y.needSidxRanges=!0))}else y.endSN=0,y.startCC=0;return y.fragmentHint&&(k+=y.fragmentHint.duration),y.totalduration=k,y.endCC=E,A>0&&function(t,e){for(var r=t[e],i=e;i--;){var n=t[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(x,A),y},t}();function v(t,e){["video","audio","text"].forEach((function(r){var i=t.filter((function(t){return Object(u.isCodecType)(t,r)}));if(i.length){var n=i.filter((function(t){return 0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)}));e[r+"Codec"]=n.length>0?n[0]:i[0],t=t.filter((function(t){return-1===i.indexOf(t)}))}})),e.unknownCodecs=t}function y(t,e,r){var i=e[r];i&&(t[r]=i)}function b(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),Object(i.isFiniteNumber)(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":
|
|
|
/*!***************************************!*\
|
|
|
!*** ./src/loader/playlist-loader.ts ***!
|
|
|
\***************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),o=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ./m3u8-parser */"./src/loader/m3u8-parser.ts"),c=r(/*! ../types/loader */"./src/types/loader.ts"),u=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts");function h(t,e){var r=t.url;return void 0!==r&&0!==r.indexOf("data:")||(r=e.url),r}var d=function(){function t(t){this.hls=void 0,this.loaders=Object.create(null),this.hls=t,this.registerListeners()}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;t.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(n.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(n.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(n.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.unregisterListeners=function(){var t=this.hls;t.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(n.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(n.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(n.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.createInternalLoader=function(t){var e=this.hls.config,r=e.pLoader,i=e.loader,n=new(r||i)(e);return t.loader=n,this.loaders[t.type]=n,n},e.getInternalLoader=function(t){return this.loaders[t.type]},e.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},e.destroyInternalLoaders=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}},e.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},e.onManifestLoading=function(t,e){var r=e.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:c.PlaylistContextType.MANIFEST,url:r,deliveryDirectives:null})},e.onLevelLoading=function(t,e){var r=e.id,i=e.level,n=e.url,o=e.deliveryDirectives;this.load({id:r,groupId:null,level:i,responseType:"text",type:c.PlaylistContextType.LEVEL,url:n,deliveryDirectives:o})},e.onAudioTrackLoading=function(t,e){var r=e.id,i=e.groupId,n=e.url,o=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:c.PlaylistContextType.AUDIO_TRACK,url:n,deliveryDirectives:o})},e.onSubtitleTrackLoading=function(t,e){var r=e.id,i=e.groupId,n=e.url,o=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:c.PlaylistContextType.SUBTITLE_TRACK,url:n,deliveryDirectives:o})},e.load=function(t){var e,r,i,n,o,a,l=this.hls.config,u=this.getInternalLoader(t);if(u){var h=u.context;if(h&&h.url===t.url)return void s.logger.trace("[playlist-loader]: playlist request ongoing");s.logger.log("[playlist-loader]: aborting previous loader for type: "+t.type),u.abort()}switch(t.type){case c.PlaylistContextType.MANIFEST:r=l.manifestLoadingMaxRetry,i=l.manifestLoadingTimeOut,n=l.manifestLoadingRetryDelay,o=l.manifestLoadingMaxRetryTimeout;break;case c.PlaylistContextType.LEVEL:case c.PlaylistContextType.AUDIO_TRACK:case c.PlaylistContextType.SUBTITLE_TRACK:r=0,i=l.levelLoadingTimeOut;break;default:r=l.levelLoadingMaxRetry,i=l.levelLoadingTimeOut,n=l.levelLoadingRetryDelay,o=l.levelLoadingMaxRetryTimeout}if(u=this.createInternalLoader(t),null!==(e=t.deliveryDirectives)&&void 0!==e&&e.part&&(t.type===c.PlaylistContextType.LEVEL&&null!==t.level?a=this.hls.levels[t.level].details:t.type===c.PlaylistContextType.AUDIO_TRACK&&null!==t.id?a=this.hls.audioTracks[t.id].details:t.type===c.PlaylistContextType.SUBTITLE_TRACK&&null!==t.id&&(a=this.hls.subtitleTracks[t.id].details),a)){var d=a.partTarget,f=a.targetduration;d&&f&&(i=Math.min(1e3*Math.max(3*d,.8*f),i))}var p={timeout:i,maxRetry:r,retryDelay:n,maxRetryDelay:o,highWaterMark:0},g={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};u.load(t,p,g)},e.loadsuccess=function(t,e,r,i){if(void 0===i&&(i=null),r.isSidxRequest)return this.handleSidxRequest(t,r),void this.handlePlaylistLoaded(t,e,r,i);this.resetInternalLoader(r.type);var n=t.data;0===n.indexOf("#EXTM3U")?(e.parsing.start=performance.now(),n.indexOf("#EXTINF:")>0||n.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(t,e,r,i):this.handleMasterPlaylist(t,e,r,i)):this.handleManifestParsingError(t,r,"no EXTM3U delimiter",i)},e.loaderror=function(t,e,r){void 0===r&&(r=null),this.handleNetworkError(e,r,!1,t)},e.loadtimeout=function(t,e,r){void 0===r&&(r=null),this.handleNetworkError(e,r,!0)},e.handleMasterPlaylist=function(t,e,r,i){var o=this.hls,a=t.data,c=h(t,r),d=l.default.parseMasterPlaylist(a,c),f=d.levels,p=d.sessionData;if(f.length){var g=f.map((function(t){return{id:t.attrs.AUDIO,audioCodec:t.audioCodec}})),m=f.map((function(t){return{id:t.attrs.SUBTITLES,textCodec:t.textCodec}})),v=l.default.parseMasterPlaylistMedia(a,c,"AUDIO",g),y=l.default.parseMasterPlaylistMedia(a,c,"SUBTITLES",m),b=l.default.parseMasterPlaylistMedia(a,c,"CLOSED-CAPTIONS");v.length&&(v.some((function(t){return!t.url}))||!f[0].audioCodec||f[0].attrs.AUDIO||(s.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),v.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new u.AttrList({}),bitrate:0,url:""}))),o.trigger(n.Events.MANIFEST_LOADED,{levels:f,audioTracks:v,subtitles:y,captions:b,url:c,stats:e,networkDetails:i,sessionData:p})}else this.handleManifestParsingError(t,r,"no level found in manifest",i)},e.handleTrackOrLevelPlaylist=function(t,e,r,s){var a=this.hls,d=r.id,f=r.level,p=r.type,g=h(t,r),m=Object(i.isFiniteNumber)(d)?d:0,v=Object(i.isFiniteNumber)(f)?f:m,y=function(t){switch(t.type){case c.PlaylistContextType.AUDIO_TRACK:return c.PlaylistLevelType.AUDIO;case c.PlaylistContextType.SUBTITLE_TRACK:return c.PlaylistLevelType.SUBTITLE;default:return c.PlaylistLevelType.MAIN}}(r),b=l.default.parseLevelPlaylist(t.data,g,v,y,m);if(b.fragments.length){if(p===c.PlaylistContextType.MANIFEST){var x={attrs:new u.AttrList({}),bitrate:0,details:b,name:"",url:g};a.trigger(n.Events.MANIFEST_LOADED,{levels:[x],audioTracks:[],url:g,stats:e,networkDetails:s,sessionData:null})}if(e.parsing.end=performance.now(),b.needSidxRanges){var S,C=null===(S=b.fragments[0].initSegment)||void 0===S?void 0:S.url;this.load({url:C,isSidxRequest:!0,type:p,level:f,levelDetails:b,id:d,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null})}else r.levelDetails=b,this.handlePlaylistLoaded(t,e,r,s)}else a.trigger(n.Events.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:g,reason:"no fragments found in level",level:"number"==typeof r.level?r.level:void 0})},e.handleSidxRequest=function(t,e){var r=Object(a.parseSegmentIndex)(new Uint8Array(t.data));if(r){var i=r.references,n=e.levelDetails;i.forEach((function(t,e){var i=t.info,o=n.fragments[e];0===o.byteRange.length&&o.setByteRange(String(1+i.end-i.start)+"@"+String(i.start)),o.initSegment&&o.initSegment.setByteRange(String(r.moovEndOffset)+"@0")}))}},e.handleManifestParsingError=function(t,e,r,i){this.hls.trigger(n.Events.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:e.type===c.PlaylistContextType.MANIFEST,url:t.url,reason:r,response:t,context:e,networkDetails:i})},e.handleNetworkError=function(t,e,r,i){void 0===r&&(r=!1),s.logger.warn("[playlist-loader]: A network "+(r?"timeout":"error")+" occurred while loading "+t.type+" level: "+t.level+" id: "+t.id+' group-id: "'+t.groupId+'"');var a=o.ErrorDetails.UNKNOWN,l=!1,u=this.getInternalLoader(t);switch(t.type){case c.PlaylistContextType.MANIFEST:a=r?o.ErrorDetails.MANIFEST_LOAD_TIMEOUT:o.ErrorDetails.MANIFEST_LOAD_ERROR,l=!0;break;case c.PlaylistContextType.LEVEL:a=r?o.ErrorDetails.LEVEL_LOAD_TIMEOUT:o.ErrorDetails.LEVEL_LOAD_ERROR,l=!1;break;case c.PlaylistContextType.AUDIO_TRACK:a=r?o.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:o.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case c.PlaylistContextType.SUBTITLE_TRACK:a=r?o.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:o.ErrorDetails.SUBTITLE_LOAD_ERROR,l=!1}u&&this.resetInternalLoader(t.type);var h={type:o.ErrorTypes.NETWORK_ERROR,details:a,fatal:l,url:t.url,loader:u,context:t,networkDetails:e};i&&(h.response=i),this.hls.trigger(n.Events.ERROR,h)},e.handlePlaylistLoaded=function(t,e,r,i){var o=r.type,s=r.level,a=r.id,l=r.groupId,u=r.loader,h=r.levelDetails,d=r.deliveryDirectives;if(null!=h&&h.targetduration){if(u)switch(h.live&&(u.getCacheAge&&(h.ageHeader=u.getCacheAge()||0),u.getCacheAge&&!isNaN(h.ageHeader)||(h.ageHeader=0)),o){case c.PlaylistContextType.MANIFEST:case c.PlaylistContextType.LEVEL:this.hls.trigger(n.Events.LEVEL_LOADED,{details:h,level:s||0,id:a||0,stats:e,networkDetails:i,deliveryDirectives:d});break;case c.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(n.Events.AUDIO_TRACK_LOADED,{details:h,id:a||0,groupId:l||"",stats:e,networkDetails:i,deliveryDirectives:d});break;case c.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(n.Events.SUBTITLE_TRACK_LOADED,{details:h,id:a||0,groupId:l||"",stats:e,networkDetails:i,deliveryDirectives:d})}}else this.handleManifestParsingError(t,r,"invalid target duration",i)},t}();e.default=d},"./src/polyfills/number.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/polyfills/number.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: isFiniteNumber, MAX_SAFE_INTEGER */function(t,e,r){"use strict";r.r(e),r.d(e,"isFiniteNumber",(function(){return i})),r.d(e,"MAX_SAFE_INTEGER",(function(){return n}));var i=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},n=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/remux/aac-helper.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=function(){function t(){}return t.getSilentFrame=function(t,e){switch(t){case"mp4a.40.2":if(1===e)return new Uint8Array([0,200,0,128,35,128]);if(2===e)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===e)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(6===e)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(1===e)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(2===e)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(3===e)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])}},t}();e.default=i},"./src/remux/mp4-generator.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/remux/mp4-generator.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=Math.pow(2,32)-1,n=function(){function t(){}return t.init=function(){var e;for(e in t.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:[]},t.types)t.types.hasOwnProperty(e)&&(t.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var r=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]),i=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]);t.HDLR_TYPES={video:r,audio:i};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),o=new Uint8Array([0,0,0,0,0,0,0,0]);t.STTS=t.STSC=t.STCO=o,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);t.FTYP=t.box(t.types.ftyp,s,l,s,a),t.DINF=t.box(t.types.dinf,t.box(t.types.dref,n))},t.box=function(t){for(var e=8,r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];for(var o=i.length,s=o;o--;)e+=i[o].byteLength;var a=new Uint8Array(e);for(a[0]=e>>24&255,a[1]=e>>16&255,a[2]=e>>8&255,a[3]=255&e,a.set(t,4),o=0,e=8;o<s;o++)a.set(i[o],e),e+=i[o].byteLength;return a},t.hdlr=function(e){return t.box(t.types.hdlr,t.HDLR_TYPES[e])},t.mdat=function(e){return t.box(t.types.mdat,e)},t.mdhd=function(e,r){r*=e;var n=Math.floor(r/(i+1)),o=Math.floor(r%(i+1));return t.box(t.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,n>>24,n>>16&255,n>>8&255,255&n,o>>24,o>>16&255,o>>8&255,255&o,85,196,0,0]))},t.mdia=function(e){return t.box(t.types.mdia,t.mdhd(e.timescale,e.duration),t.hdlr(e.type),t.minf(e))},t.mfhd=function(e){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},t.minf=function(e){return"audio"===e.type?t.box(t.types.minf,t.box(t.types.smhd,t.SMHD),t.DINF,t.stbl(e)):t.box(t.types.minf,t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(e))},t.moof=function(e,r,i){return t.box(t.types.moof,t.mfhd(e),t.traf(i,r))},t.moov=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trak(e[r]);return t.box.apply(null,[t.types.moov,t.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(t.mvex(e)))},t.mvex=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trex(e[r]);return t.box.apply(null,[t.types.mvex].concat(i))},t.mvhd=function(e,r){r*=e;var n=Math.floor(r/(i+1)),o=Math.floor(r%(i+1)),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,n>>24,n>>16&255,n>>8&255,255&n,o>>24,o>>16&255,o>>8&255,255&o,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 t.box(t.types.mvhd,s)},t.sdtp=function(e){var r,i,n=e.samples||[],o=new Uint8Array(4+n.length);for(r=0;r<n.length;r++)i=n[r].flags,o[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return t.box(t.types.sdtp,o)},t.stbl=function(e){return t.box(t.types.stbl,t.stsd(e),t.box(t.types.stts,t.STTS),t.box(t.types.stsc,t.STSC),t.box(t.types.stsz,t.STSZ),t.box(t.types.stco,t.STCO))},t.avc1=function(e){var r,i,n,o=[],s=[];for(r=0;r<e.sps.length;r++)n=(i=e.sps[r]).byteLength,o.push(n>>>8&255),o.push(255&n),o=o.concat(Array.prototype.slice.call(i));for(r=0;r<e.pps.length;r++)n=(i=e.pps[r]).byteLength,s.push(n>>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(i));var a=t.box(t.types.avcC,new Uint8Array([1,o[3],o[4],o[5],255,224|e.sps.length].concat(o).concat([e.pps.length]).concat(s))),l=e.width,c=e.height,u=e.pixelRatio[0],h=e.pixelRatio[1];return t.box(t.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,l>>8&255,255&l,c>>8&255,255&c,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]),a,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,h>>24,h>>16&255,h>>8&255,255&h])))},t.esds=function(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))},t.mp4a=function(e){var r=e.samplerate;return t.box(t.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),t.box(t.types.esds,t.esds(e)))},t.mp3=function(e){var r=e.samplerate;return t.box(t.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},t.stsd=function(e){return"audio"===e.type?e.isAAC||"mp3"!==e.codec?t.box(t.types.stsd,t.STSD,t.mp4a(e)):t.box(t.types.stsd,t.STSD,t.mp3(e)):t.box(t.types.stsd,t.STSD,t.avc1(e))},t.tkhd=function(e){var r=e.id,n=e.duration*e.timescale,o=e.width,s=e.height,a=Math.floor(n/(i+1)),l=Math.floor(n%(i+1));return t.box(t.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,l>>24,l>>16&255,l>>8&255,255&l,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,o>>8&255,255&o,0,0,s>>8&255,255&s,0,0]))},t.traf=function(e,r){var n=t.sdtp(e),o=e.id,s=Math.floor(r/(i+1)),a=Math.floor(r%(i+1));return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,a>>24,a>>16&255,a>>8&255,255&a])),t.trun(e,n.length+16+20+8+16+8+8),n)},t.trak=function(e){return e.duration=e.duration||4294967295,t.box(t.types.trak,t.tkhd(e),t.mdia(e))},t.trex=function(e){var r=e.id;return t.box(t.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},t.trun=function(e,r){var i,n,o,s,a,l,c=e.samples||[],u=c.length,h=12+16*u,d=new Uint8Array(h);for(r+=8+h,d.set([0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,255&u,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<u;i++)o=(n=c[i]).duration,s=n.size,a=n.flags,l=n.cts,d.set([o>>>24&255,o>>>16&255,o>>>8&255,255&o,s>>>24&255,s>>>16&255,s>>>8&255,255&s,a.isLeading<<2|a.dependsOn,a.isDependedOn<<6|a.hasRedundancy<<4|a.paddingValue<<1|a.isNonSync,61440&a.degradPrio,15&a.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return t.box(t.types.trun,d)},t.initSegment=function(e){t.types||t.init();var r=t.moov(e),i=new Uint8Array(t.FTYP.byteLength+r.byteLength);return i.set(t.FTYP),i.set(r,t.FTYP.byteLength),i},t}();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,e.default=n},"./src/remux/mp4-remuxer.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/remux/mp4-remuxer.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: default, normalizePts */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return g})),r.d(e,"normalizePts",(function(){return m}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./aac-helper */"./src/remux/aac-helper.ts"),o=r(/*! ./mp4-generator */"./src/remux/mp4-generator.ts"),s=r(/*! ../events */"./src/events.ts"),a=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../utils/logger */"./src/utils/logger.ts"),c=r(/*! ../types/loader */"./src/types/loader.ts"),u=r(/*! ../utils/timescale-conversion */"./src/utils/timescale-conversion.ts");function h(){return(h=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}var d=null,f=null,p=!1,g=function(){function t(t,e,r,i){if(void 0===i&&(i=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=e,this.typeSupported=r,this.ISGenerated=!1,null===d){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);d=n?parseInt(n[1]):0}if(null===f){var o=navigator.userAgent.match(/Safari\/(\d+)/i);f=o?parseInt(o[1]):0}p=!!d&&d<75||!!f&&f<600}var e=t.prototype;return e.destroy=function(){},e.resetTimeStamp=function(t){l.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},e.resetNextTimestamp=function(){l.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},e.resetInitSegment=function(){l.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},e.getVideoStartPts=function(t){var e=!1,r=t.reduce((function(t,r){var i=r.pts-t;return i<-4294967296?(e=!0,m(t,r.pts)):i>0?t:r.pts}),t[0].pts);return e&&l.logger.debug("PTS rollover detected"),r},e.remux=function(t,e,r,i,n,o,s,a){var u,h,d,f,p,g,v=n,y=n,b=t.pid>-1,x=e.pid>-1,S=e.samples.length,C=t.samples.length>0,w=S>1;if((!b||C)&&(!x||w)||this.ISGenerated||s){this.ISGenerated||(d=this.generateIS(t,e,n));var k=this.isVideoContiguous,E=-1;if(w&&(E=function(t){for(var e=0;e<t.length;e++)if(t[e].key)return e;return-1}(e.samples),!k&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,E>0){l.logger.warn("[mp4-remuxer]: Dropped "+E+" out of "+S+" video samples due to a missing keyframe");var T=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(E),e.dropped+=E,y+=(e.samples[0].pts-T)/(e.timescale||9e4)}else-1===E&&(l.logger.warn("[mp4-remuxer]: No keyframe found out of "+S+" video samples"),g=!1);if(this.ISGenerated){if(C&&w){var L=this.getVideoStartPts(e.samples),A=(m(t.samples[0].pts,L)-L)/e.inputTimeScale;v+=Math.max(0,A),y+=Math.max(0,-A)}if(C){if(t.samplerate||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),d=this.generateIS(t,e,n)),h=this.remuxAudio(t,v,this.isAudioContiguous,o,x||w||a===c.PlaylistLevelType.AUDIO?y:void 0),w){var D=h?h.endPTS-h.startPTS:0;e.inputTimeScale||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(t,e,n)),u=this.remuxVideo(e,y,k,D)}}else w&&(u=this.remuxVideo(e,y,k,0));u&&(u.firstKeyFrame=E,u.independent=-1!==E)}}return this.ISGenerated&&(r.samples.length&&(p=this.remuxID3(r,n)),i.samples.length&&(f=this.remuxText(i,n))),{audio:h,video:u,initSegment:d,independent:g,text:f,id3:p}},e.generateIS=function(t,e,r){var n,s,a,l=t.samples,c=e.samples,u=this.typeSupported,h={},d=!Object(i.isFiniteNumber)(this._initPTS),f="audio/mp4";if(d&&(n=s=1/0),t.config&&l.length&&(t.timescale=t.samplerate,t.isAAC||(u.mpeg?(f="audio/mpeg",t.codec=""):u.mp3&&(t.codec="mp3")),h.audio={id:"audio",container:f,codec:t.codec,initSegment:!t.isAAC&&u.mpeg?new Uint8Array(0):o.default.initSegment([t]),metadata:{channelCount:t.channelCount}},d&&(a=t.inputTimeScale,n=s=l[0].pts-Math.round(a*r))),e.sps&&e.pps&&c.length&&(e.timescale=e.inputTimeScale,h.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:o.default.initSegment([e]),metadata:{width:e.width,height:e.height}},d)){a=e.inputTimeScale;var p=this.getVideoStartPts(c),g=Math.round(a*r);s=Math.min(s,m(c[0].dts,p)-g),n=Math.min(n,p-g)}if(Object.keys(h).length)return this.ISGenerated=!0,d&&(this._initPTS=n,this._initDTS=s),{tracks:h,initPTS:n,timescale:a}},e.remuxVideo=function(t,e,r,i){var n,c,f,g=t.inputTimeScale,y=t.samples,b=[],x=y.length,S=this._initPTS,C=this.nextAvcDts,w=8,k=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY,T=0,L=!1;r&&null!==C||(C=e*g-(y[0].pts-m(y[0].dts,y[0].pts)));for(var A=0;A<x;A++){var D=y[A];D.pts=m(D.pts-S,C),D.dts=m(D.dts-S,C),D.dts>D.pts&&(T=Math.max(Math.min(T,D.pts-D.dts),-18e3)),D.dts<y[A>0?A-1:A].dts&&(L=!0)}L&&y.sort((function(t,e){var r=t.dts-e.dts,i=t.pts-e.pts;return r||i})),c=y[0].dts,f=y[y.length-1].dts;var O=Math.round((f-c)/(x-1));if(T<0){if(T<-2*O){l.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(u.toMsFromMpegTsClock)(-O,!0)+" ms");for(var R=T,_=0;_<x;_++)y[_].dts=R=Math.max(R,y[_].pts-O),y[_].pts=Math.max(R,y[_].pts)}else{l.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(u.toMsFromMpegTsClock)(T,!0)+" ms to overcome this issue");for(var I=0;I<x;I++)y[I].dts=y[I].dts+T}c=y[0].dts}if(r){var M=c-C,P=M>O;if(P||M<-1){P?l.logger.warn("AVC: "+Object(u.toMsFromMpegTsClock)(M,!0)+" ms ("+M+"dts) hole between fragments detected, filling it"):l.logger.warn("AVC: "+Object(u.toMsFromMpegTsClock)(-M,!0)+" ms ("+M+"dts) overlapping between fragments detected"),c=C;var N=y[0].pts-M;y[0].dts=c,y[0].pts=N,l.logger.log("Video: First PTS/DTS adjusted: "+Object(u.toMsFromMpegTsClock)(N,!0)+"/"+Object(u.toMsFromMpegTsClock)(c,!0)+", delta: "+Object(u.toMsFromMpegTsClock)(M,!0)+" ms")}}p&&(c=Math.max(0,c));for(var F=0,B=0,j=0;j<x;j++){for(var U=y[j],H=U.units,G=H.length,z=0,W=0;W<G;W++)z+=H[W].data.length;B+=z,F+=G,U.length=z,U.dts=Math.max(U.dts,c),U.pts=Math.max(U.pts,U.dts,0),k=Math.min(U.pts,k),E=Math.max(U.pts,E)}f=y[x-1].dts;var V,K=B+4*F+8;try{V=new Uint8Array(K)}catch(t){return void this.observer.emit(s.Events.ERROR,s.Events.ERROR,{type:a.ErrorTypes.MUX_ERROR,details:a.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:K,reason:"fail allocating video mdat "+K})}var q=new DataView(V.buffer);q.setUint32(0,K),V.set(o.default.types.mdat,4);for(var Y=0;Y<x;Y++){for(var X=y[Y],$=X.units,Z=0,Q=0,J=$.length;Q<J;Q++){var tt=$[Q],et=tt.data,rt=tt.data.byteLength;q.setUint32(w,rt),w+=4,V.set(et,w),w+=rt,Z+=4+rt}if(Y<x-1)n=y[Y+1].dts-X.dts;else{var it=this.config,nt=X.dts-y[Y>0?Y-1:Y].dts;if(it.stretchShortVideoTrack&&null!==this.nextAudioPts){var ot=Math.floor(it.maxBufferHole*g),st=(i?k+i*g:this.nextAudioPts)-X.pts;st>ot?((n=st-nt)<0&&(n=nt),l.logger.log("[mp4-remuxer]: It is approximately "+st/90+" ms to the next segment; using duration "+n/90+" ms for the last video frame.")):n=nt}else n=nt}var at=Math.round(X.pts-X.dts);b.push(new v(X.key,n,Z,at))}if(b.length&&d&&d<70){var lt=b[0].flags;lt.dependsOn=2,lt.isNonSync=0}console.assert(void 0!==n,"mp4SampleDuration must be computed"),this.nextAvcDts=C=f+n,this.isVideoContiguous=!0;var ct={data1:o.default.moof(t.sequenceNumber++,c,h({},t,{samples:b})),data2:V,startPTS:k/g,endPTS:(E+n)/g,startDTS:c/g,endDTS:C/g,type:"video",hasAudio:!1,hasVideo:!0,nb:b.length,dropped:t.dropped};return t.samples=[],t.dropped=0,console.assert(V.length,"MDAT length must not be zero"),ct},e.remuxAudio=function(t,e,r,i,c){var u=t.inputTimeScale,d=u/(t.samplerate?t.samplerate:u),f=t.isAAC?1024:1152,p=f*d,g=this._initPTS,y=!t.isAAC&&this.typeSupported.mpeg,b=[],x=t.samples,S=y?0:8,C=this.nextAudioPts||-1,w=e*u;if(this.isAudioContiguous=r=r||x.length&&C>0&&(i&&Math.abs(w-C)<9e3||Math.abs(m(x[0].pts-g,w)-C)<20*p),x.forEach((function(t){t.pts=m(t.pts-g,w)})),!r||C<0){if(!(x=x.filter((function(t){return t.pts>=0}))).length)return;C=0===c?0:i?Math.max(0,w):x[0].pts}if(t.isAAC)for(var k=void 0!==c,E=this.config.maxAudioFramesDrift,T=0,L=C;T<x.length;T++){var A=x[T],D=A.pts,O=D-L,R=Math.abs(1e3*O/u);if(O<=-E*p&&k)0===T&&(l.logger.warn("Audio frame @ "+(D/u).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*O/u)+" ms."),this.nextAudioPts=C=L=D);else if(O>=E*p&&R<1e4&&k){var _=Math.round(O/p);(L=D-_*p)<0&&(_--,L+=p),0===T&&(this.nextAudioPts=C=L),l.logger.warn("[mp4-remuxer]: Injecting "+_+" audio frame @ "+(L/u).toFixed(3)+"s due to "+Math.round(1e3*O/u)+" ms gap.");for(var I=0;I<_;I++){var M=Math.max(L,0),P=n.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);P||(l.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),P=A.unit.subarray()),x.splice(T,0,{unit:P,pts:M}),L+=p,T++}}A.pts=L,L+=p}for(var N,F=null,B=null,j=0,U=x.length;U--;)j+=x[U].unit.byteLength;for(var H=0,G=x.length;H<G;H++){var z=x[H],W=z.unit,V=z.pts;if(null!==B)b[H-1].duration=Math.round((V-B)/d);else{if(r&&t.isAAC&&(V=C),F=V,!(j>0))return;j+=S;try{N=new Uint8Array(j)}catch(t){return void this.observer.emit(s.Events.ERROR,s.Events.ERROR,{type:a.ErrorTypes.MUX_ERROR,details:a.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:j,reason:"fail allocating audio mdat "+j})}y||(new DataView(N.buffer).setUint32(0,j),N.set(o.default.types.mdat,4))}N.set(W,S);var K=W.byteLength;S+=K,b.push(new v(!0,f,K,0)),B=V}var q=b.length;if(q){var Y=b[b.length-1];this.nextAudioPts=C=B+d*Y.duration;var X=y?new Uint8Array(0):o.default.moof(t.sequenceNumber++,F/d,h({},t,{samples:b}));t.samples=[];var $=F/u,Z=C/u,Q={data1:X,data2:N,startPTS:$,endPTS:Z,startDTS:$,endDTS:Z,type:"audio",hasAudio:!0,hasVideo:!1,nb:q};return this.isAudioContiguous=!0,console.assert(N.length,"MDAT length must not be zero"),Q}},e.remuxEmptyAudio=function(t,e,r,i){var o=t.inputTimeScale,s=o/(t.samplerate?t.samplerate:o),a=this.nextAudioPts,c=(null!==a?a:i.startDTS*o)+this._initDTS,u=i.endDTS*o+this._initDTS,h=1024*s,d=Math.ceil((u-c)/h),f=n.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(l.logger.warn("[mp4-remuxer]: remux empty Audio"),f){for(var p=[],g=0;g<d;g++){var m=c+g*h;p.push({unit:f,pts:m,dts:m})}return t.samples=p,this.remuxAudio(t,e,r,!1)}l.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},e.remuxID3=function(t,e){var r=t.samples.length;if(r){for(var i=t.inputTimeScale,n=this._initPTS,o=this._initDTS,s=0;s<r;s++){var a=t.samples[s];a.pts=m(a.pts-n,e*i)/i,a.dts=m(a.dts-o,e*i)/i}var l=t.samples;return t.samples=[],{samples:l}}},e.remuxText=function(t,e){var r=t.samples.length;if(r){for(var i=t.inputTimeScale,n=this._initPTS,o=0;o<r;o++){var s=t.samples[o];s.pts=m(s.pts-n,e*i)/i}t.samples.sort((function(t,e){return t.pts-e.pts}));var a=t.samples;return t.samples=[],{samples:a}}},t}();function m(t,e){var r;if(null===e)return t;for(r=e<t?-8589934592:8589934592;Math.abs(t-e)>4294967296;)t+=r;return t}var v=function(t,e,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=r,this.cts=i,this.flags=new y(t)},y=function(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}},"./src/remux/passthrough-remuxer.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/remux/passthrough-remuxer.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),o=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=function(){function t(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var e=t.prototype;return e.destroy=function(){},e.resetTimeStamp=function(t){this.initPTS=t,this.lastEndDTS=null},e.resetNextTimestamp=function(){this.lastEndDTS=null},e.resetInitSegment=function(t,e,r){this.audioCodec=e,this.videoCodec=r,this.generateInitSegment(t),this.emitInitSegment=!0},e.generateInitSegment=function(t){var e=this.audioCodec,r=this.videoCodec;if(!t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=Object(n.parseInitSegment)(t);e||(e=c(i.audio,o.ElementaryStreamTypes.AUDIO)),r||(r=c(i.video,o.ElementaryStreamTypes.VIDEO));var a={};i.audio&&i.video?a.audiovideo={container:"video/mp4",codec:e+","+r,initSegment:t,id:"main"}:i.audio?a.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:i.video?a.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:s.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a},e.remux=function(t,e,r,o,a){var c=this.initPTS,u=this.lastEndDTS,h={audio:void 0,video:void 0,text:o,id3:r,initSegment:void 0};Object(i.isFiniteNumber)(u)||(u=this.lastEndDTS=a||0);var d=e.samples;if(!d||!d.length)return h;var f={initPTS:void 0,timescale:1},p=this.initData;if(p&&p.length||(this.generateInitSegment(d),p=this.initData),!p||!p.length)return s.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1),Object(i.isFiniteNumber)(c)||(this.initPTS=f.initPTS=c=l(p,d,u));var g=Object(n.getDuration)(d,p),m=u,v=g+m;Object(n.offsetStartDTS)(p,d,c),g>0?this.lastEndDTS=v:(s.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var y=!!p.audio,b=!!p.video,x="";y&&(x+="audio"),b&&(x+="video");var S={data1:d,startPTS:m,startDTS:m,endPTS:v,endDTS:v,type:x,hasAudio:y,hasVideo:b,nb:1,dropped:0};return h.audio="audio"===S.type?S:void 0,h.video="audio"!==S.type?S:void 0,h.text=o,h.id3=r,h.initSegment=f,h},t}(),l=function(t,e,r){return Object(n.getStartDTS)(t,e)-r};function c(t,e){var r=null==t?void 0:t.codec;return r&&r.length>4?r:"hvc1"===r?"hvc1.1.c.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||e===o.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}e.default=a},"./src/task-loop.ts":
|
|
|
/*!**************************!*\
|
|
|
!*** ./src/task-loop.ts ***!
|
|
|
\**************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return i}));var i=function(){function t(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var e=t.prototype;return e.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},e.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},e.onHandlerDestroyed=function(){},e.hasInterval=function(){return!!this._tickInterval},e.hasNextTick=function(){return!!this._tickTimer},e.setInterval=function(t){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,t),!0)},e.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},e.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},e.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},e.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},e.doTick=function(){},t}()},"./src/types/cmcd.ts":
|
|
|
/*!***************************!*\
|
|
|
!*** ./src/types/cmcd.ts ***!
|
|
|
\***************************/
|
|
|
/*! exports provided: CMCDVersion, CMCDObjectType, CMCDStreamingFormat, CMCDStreamType */function(t,e,r){"use strict";r.r(e),r.d(e,"CMCDVersion",(function(){return s})),r.d(e,"CMCDObjectType",(function(){return i})),r.d(e,"CMCDStreamingFormat",(function(){return n})),r.d(e,"CMCDStreamType",(function(){return o}));var i,n,o,s=1;!function(t){t.MANIFEST="m",t.AUDIO="a",t.VIDEO="v",t.MUXED="av",t.INIT="i",t.CAPTION="c",t.TIMED_TEXT="tt",t.KEY="k",t.OTHER="o"}(i||(i={})),function(t){t.DASH="d",t.HLS="h",t.SMOOTH="s",t.OTHER="o"}(n||(n={})),function(t){t.VOD="v",t.LIVE="l"}(o||(o={}))},"./src/types/level.ts":
|
|
|
/*!****************************!*\
|
|
|
!*** ./src/types/level.ts ***!
|
|
|
\****************************/
|
|
|
/*! exports provided: HlsSkip, getSkipValue, HlsUrlParameters, Level */function(t,e,r){"use strict";function i(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var n;function o(t,e){var r=t.canSkipUntil,i=t.canSkipDateRanges,o=t.endSN;return r&&(void 0!==e?e-o:0)<r?i?n.v2:n.Yes:n.No}r.r(e),r.d(e,"HlsSkip",(function(){return n})),r.d(e,"getSkipValue",(function(){return o})),r.d(e,"HlsUrlParameters",(function(){return s})),r.d(e,"Level",(function(){return a})),function(t){t.No="",t.Yes="YES",t.v2="v2"}(n||(n={}));var s=function(){function t(t,e,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=r}return t.prototype.addDirectives=function(t){var e=new self.URL(t);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.toString()},t}(),a=function(){function t(t){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this.attrs=t.attrs,this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter((function(t){return t})).join(",").replace(/\.[^.,]+/g,"")}var e,r,n;return e=t,(r=[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(t){var e=t%this.url.length;this._urlId!==e&&(this.details=void 0,this._urlId=e)}}])&&i(e.prototype,r),n&&i(e,n),t}()},"./src/types/loader.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/types/loader.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: PlaylistContextType, PlaylistLevelType */function(t,e,r){"use strict";var i,n;r.r(e),r.d(e,"PlaylistContextType",(function(){return i})),r.d(e,"PlaylistLevelType",(function(){return n})),function(t){t.MANIFEST="manifest",t.LEVEL="level",t.AUDIO_TRACK="audioTrack",t.SUBTITLE_TRACK="subtitleTrack"}(i||(i={})),function(t){t.MAIN="main",t.AUDIO="audio",t.SUBTITLE="subtitle"}(n||(n={}))},"./src/types/transmuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/types/transmuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: ChunkMetadata */function(t,e,r){"use strict";r.r(e),r.d(e,"ChunkMetadata",(function(){return i}));var i=function(t,e,r,i,n,o){void 0===i&&(i=0),void 0===n&&(n=-1),void 0===o&&(o=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=e,this.id=r,this.size=i,this.part=n,this.partial=o}},"./src/utils/attr-list.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/utils/attr-list.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: AttrList */function(t,e,r){"use strict";r.r(e),r.d(e,"AttrList",(function(){return o}));var i=/^(\d+)x(\d+)$/,n=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,o=function(){function t(e){for(var r in"string"==typeof e&&(e=t.parseAttrList(e)),e)e.hasOwnProperty(r)&&(this[r]=e[r])}var e=t.prototype;return e.decimalInteger=function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.hexadecimalInteger=function(t){if(this[t]){var e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;for(var r=new Uint8Array(e.length/2),i=0;i<e.length/2;i++)r[i]=parseInt(e.slice(2*i,2*i+2),16);return r}return null},e.hexadecimalIntegerAsNumber=function(t){var e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.decimalFloatingPoint=function(t){return parseFloat(this[t])},e.optionalFloat=function(t,e){var r=this[t];return r?parseFloat(r):e},e.enumeratedString=function(t){return this[t]},e.bool=function(t){return"YES"===this[t]},e.decimalResolution=function(t){var e=i.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},t.parseAttrList=function(t){var e,r={};for(n.lastIndex=0;null!==(e=n.exec(t));){var i=e[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[e[1]]=i}return r},t}()},"./src/utils/binary-search.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/utils/binary-search.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),e.default={search:function(t,e){for(var r=0,i=t.length-1,n=null,o=null;r<=i;){var s=e(o=t[n=(r+i)/2|0]);if(s>0)r=n+1;else{if(!(s<0))return o;i=n-1}}return null}}},"./src/utils/buffer-helper.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/utils/buffer-helper.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: BufferHelper */function(t,e,r){"use strict";r.r(e),r.d(e,"BufferHelper",(function(){return o}));var i=r(/*! ./logger */"./src/utils/logger.ts"),n={length:0,start:function(){return 0},end:function(){return 0}},o=function(){function t(){}return t.isBuffered=function(e,r){try{if(e)for(var i=t.getBuffered(e),n=0;n<i.length;n++)if(r>=i.start(n)&&r<=i.end(n))return!0}catch(t){}return!1},t.bufferInfo=function(e,r,i){try{if(e){var n,o=t.getBuffered(e),s=[];for(n=0;n<o.length;n++)s.push({start:o.start(n),end:o.end(n)});return this.bufferedInfo(s,r,i)}}catch(t){}return{len:0,start:r,end:r,nextStart:void 0}},t.bufferedInfo=function(t,e,r){e=Math.max(0,e),t.sort((function(t,e){var r=t.start-e.start;return r||e.end-t.end}));var i=[];if(r)for(var n=0;n<t.length;n++){var o=i.length;if(o){var s=i[o-1].end;t[n].start-s<r?t[n].end>s&&(i[o-1].end=t[n].end):i.push(t[n])}else i.push(t[n])}else i=t;for(var a,l=0,c=e,u=e,h=0;h<i.length;h++){var d=i[h].start,f=i[h].end;if(e+r>=d&&e<f)c=d,l=(u=f)-e;else if(e+r<d){a=d;break}}return{len:l,start:c||0,end:u||0,nextStart:a}},t.getBuffered=function(t){try{return t.buffered}catch(t){return i.logger.log("failed to get media.buffered",t),n}},t}()},"./src/utils/cea-608-parser.ts":
|
|
|
/*!*************************************!*\
|
|
|
!*** ./src/utils/cea-608-parser.ts ***!
|
|
|
\*************************************/
|
|
|
/*! exports provided: Row, CaptionScreen, default */function(t,e,r){"use strict";r.r(e),r.d(e,"Row",(function(){return m})),r.d(e,"CaptionScreen",(function(){return v}));var i,n=r(/*! ../utils/logger */"./src/utils/logger.ts"),o={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},s=function(t){var e=t;return o.hasOwnProperty(t)&&(e=o[t]),String.fromCharCode(e)},a={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},l={17:2,18:4,21:6,22:8,23:10,19:13,20:15},c={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},u={25:2,26:4,29:6,30:8,31:10,27:13,28:15},h=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];!function(t){t[t.ERROR=0]="ERROR",t[t.TEXT=1]="TEXT",t[t.WARNING=2]="WARNING",t[t.INFO=2]="INFO",t[t.DEBUG=3]="DEBUG",t[t.DATA=3]="DATA"}(i||(i={}));var d=function(){function t(){this.time=null,this.verboseLevel=i.ERROR}return t.prototype.log=function(t,e){this.verboseLevel>=t&&n.logger.log(this.time+" ["+t+"] "+e)},t}(),f=function(t){for(var e=[],r=0;r<t.length;r++)e.push(t[r].toString(16));return e},p=function(){function t(t,e,r,i,n){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=e||!1,this.italics=r||!1,this.background=i||"black",this.flash=n||!1}var e=t.prototype;return e.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},e.setStyles=function(t){for(var e=["foreground","underline","italics","background","flash"],r=0;r<e.length;r++){var i=e[r];t.hasOwnProperty(i)&&(this[i]=t[i])}},e.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},e.equals=function(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash},e.copy=function(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash},e.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},t}(),g=function(){function t(t,e,r,i,n,o){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new p(e,r,i,n,o)}var e=t.prototype;return e.reset=function(){this.uchar=" ",this.penState.reset()},e.setChar=function(t,e){this.uchar=t,this.penState.copy(e)},e.setPenState=function(t){this.penState.copy(t)},e.equals=function(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)},e.copy=function(t){this.uchar=t.uchar,this.penState.copy(t.penState)},e.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},t}(),m=function(){function t(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var e=0;e<100;e++)this.chars.push(new g);this.logger=t,this.pos=0,this.currPenState=new p}var e=t.prototype;return e.equals=function(t){for(var e=!0,r=0;r<100;r++)if(!this.chars[r].equals(t.chars[r])){e=!1;break}return e},e.copy=function(t){for(var e=0;e<100;e++)this.chars[e].copy(t.chars[e])},e.isEmpty=function(){for(var t=!0,e=0;e<100;e++)if(!this.chars[e].isEmpty()){t=!1;break}return t},e.setCursor=function(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(i.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>100&&(this.logger.log(i.DEBUG,"Too large cursor position "+this.pos),this.pos=100)},e.moveCursor=function(t){var e=this.pos+t;if(t>1)for(var r=this.pos+1;r<e+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(e)},e.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},e.insertChar=function(t){t>=144&&this.backSpace();var e=s(t);this.pos>=100?this.logger.log(i.ERROR,"Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1))},e.clearFromPos=function(t){var e;for(e=t;e<100;e++)this.chars[e].reset()},e.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},e.clearToEndOfRow=function(){this.clearFromPos(this.pos)},e.getTextString=function(){for(var t=[],e=!0,r=0;r<100;r++){var i=this.chars[r].uchar;" "!==i&&(e=!1),t.push(i)}return e?"":t.join("")},e.setPenStyles=function(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)},t}(),v=function(){function t(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var e=0;e<15;e++)this.rows.push(new m(t));this.logger=t,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var e=t.prototype;return e.reset=function(){for(var t=0;t<15;t++)this.rows[t].clear();this.currRow=14},e.equals=function(t){for(var e=!0,r=0;r<15;r++)if(!this.rows[r].equals(t.rows[r])){e=!1;break}return e},e.copy=function(t){for(var e=0;e<15;e++)this.rows[e].copy(t.rows[e])},e.isEmpty=function(){for(var t=!0,e=0;e<15;e++)if(!this.rows[e].isEmpty()){t=!1;break}return t},e.backSpace=function(){this.rows[this.currRow].backSpace()},e.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},e.insertChar=function(t){this.rows[this.currRow].insertChar(t)},e.setPen=function(t){this.rows[this.currRow].setPenStyles(t)},e.moveCursor=function(t){this.rows[this.currRow].moveCursor(t)},e.setCursor=function(t){this.logger.log(i.INFO,"setCursor: "+t),this.rows[this.currRow].setCursor(t)},e.setPAC=function(t){this.logger.log(i.INFO,"pacData = "+JSON.stringify(t));var e=t.row-1;if(this.nrRollUpRows&&e<this.nrRollUpRows-1&&(e=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==e){for(var r=0;r<15;r++)this.rows[r].clear();var n=this.currRow+1-this.nrRollUpRows,o=this.lastOutputScreen;if(o){var s=o.rows[n].cueStartTime,a=this.logger.time;if(s&&null!==a&&s<a)for(var l=0;l<this.nrRollUpRows;l++)this.rows[e-this.nrRollUpRows+l+1].copy(o.rows[n+l])}}this.currRow=e;var c=this.rows[this.currRow];if(null!==t.indent){var u=t.indent,h=Math.max(u-1,0);c.setCursor(t.indent),t.color=c.chars[h].penState.foreground}var d={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(d)},e.setBkgData=function(t){this.logger.log(i.INFO,"bkgData = "+JSON.stringify(t)),this.backSpace(),this.setPen(t),this.insertChar(32)},e.setRollUpRows=function(t){this.nrRollUpRows=t},e.rollUp=function(){if(null!==this.nrRollUpRows){this.logger.log(i.TEXT,this.getDisplayText());var t=this.currRow+1-this.nrRollUpRows,e=this.rows.splice(t,1)[0];e.clear(),this.rows.splice(this.currRow,0,e),this.logger.log(i.INFO,"Rolling up")}else this.logger.log(i.DEBUG,"roll_up but nrRollUpRows not set yet")},e.getDisplayText=function(t){t=t||!1;for(var e=[],r="",i=-1,n=0;n<15;n++){var o=this.rows[n].getTextString();o&&(i=n+1,t?e.push("Row "+i+": '"+o+"'"):e.push(o.trim()))}return e.length>0&&(r=t?"["+e.join(" | ")+"]":e.join("\n")),r},e.getTextAndFormat=function(){return this.rows},t}(),y=function(){function t(t,e,r){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=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new v(r),this.nonDisplayedMemory=new v(r),this.lastOutputScreen=new v(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}var e=t.prototype;return e.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},e.getHandler=function(){return this.outputFilter},e.setHandler=function(t){this.outputFilter=t},e.setPAC=function(t){this.writeScreen.setPAC(t)},e.setBkgData=function(t){this.writeScreen.setBkgData(t)},e.setMode=function(t){t!==this.mode&&(this.mode=t,this.logger.log(i.INFO,"MODE="+t),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)},e.insertChars=function(t){for(var e=0;e<t.length;e++)this.writeScreen.insertChar(t[e]);var r=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(i.INFO,r+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(i.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},e.ccRCL=function(){this.logger.log(i.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},e.ccBS=function(){this.logger.log(i.INFO,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},e.ccAOF=function(){},e.ccAON=function(){},e.ccDER=function(){this.logger.log(i.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},e.ccRU=function(t){this.logger.log(i.INFO,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)},e.ccFON=function(){this.logger.log(i.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},e.ccRDC=function(){this.logger.log(i.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},e.ccTR=function(){this.logger.log(i.INFO,"TR"),this.setMode("MODE_TEXT")},e.ccRTD=function(){this.logger.log(i.INFO,"RTD"),this.setMode("MODE_TEXT")},e.ccEDM=function(){this.logger.log(i.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},e.ccCR=function(){this.logger.log(i.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},e.ccENM=function(){this.logger.log(i.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},e.ccEOC=function(){if(this.logger.log(i.INFO,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(i.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},e.ccTO=function(t){this.logger.log(i.INFO,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)},e.ccMIDROW=function(t){var e={flash:!1};if(e.underline=t%2==1,e.italics=t>=46,e.italics)e.foreground="white";else{var r=Math.floor(t/2)-16;e.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(i.INFO,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)},e.outputDataUpdate=function(t){void 0===t&&(t=!1);var e=this.logger.time;null!==e&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e):this.cueStartTime=e,this.lastOutputScreen.copy(this.displayedMemory))},e.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},t}(),b=function(){function t(t,e,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new d;this.channels=[null,new y(t,e,i),new y(t+1,r,i)],this.cmdHistory={a:null,b:null},this.logger=i}var e=t.prototype;return e.getHandler=function(t){return this.channels[t].getHandler()},e.setHandler=function(t,e){this.channels[t].setHandler(e)},e.addData=function(t,e){var r,n,o,s=!1;this.logger.time=t;for(var a=0;a<e.length;a+=2)if(n=127&e[a],o=127&e[a+1],0!==n||0!==o){if(this.logger.log(i.DATA,"["+f([e[a],e[a+1]])+"] -> ("+f([n,o])+")"),(r=this.parseCmd(n,o))||(r=this.parseMidrow(n,o)),r||(r=this.parsePAC(n,o)),r||(r=this.parseBackgroundAttributes(n,o)),!r&&(s=this.parseChars(n,o))){var l=this.currentChannel;l&&l>0?this.channels[l].insertChars(s):this.logger.log(i.WARNING,"No channel found yet. TEXT-MODE?")}r||s||this.logger.log(i.WARNING,"Couldn't parse cleaned data "+f([n,o])+" orig: "+f([e[a],e[a+1]]))}},e.parseCmd=function(t,e){var r=this.cmdHistory;if(!((20===t||28===t||21===t||29===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=33&&e<=35))return!1;if(S(t,e,r))return x(null,null,r),this.logger.log(i.DEBUG,"Repeated command ("+f([t,e])+") is dropped"),!0;var n=20===t||21===t||23===t?1:2,o=this.channels[n];return 20===t||21===t||28===t||29===t?32===e?o.ccRCL():33===e?o.ccBS():34===e?o.ccAOF():35===e?o.ccAON():36===e?o.ccDER():37===e?o.ccRU(2):38===e?o.ccRU(3):39===e?o.ccRU(4):40===e?o.ccFON():41===e?o.ccRDC():42===e?o.ccTR():43===e?o.ccRTD():44===e?o.ccEDM():45===e?o.ccCR():46===e?o.ccENM():47===e&&o.ccEOC():o.ccTO(e-32),x(t,e,r),this.currentChannel=n,!0},e.parseMidrow=function(t,e){var r=0;if((17===t||25===t)&&e>=32&&e<=47){if((r=17===t?1:2)!==this.currentChannel)return this.logger.log(i.ERROR,"Mismatch channel in midrow parsing"),!1;var n=this.channels[r];return!!n&&(n.ccMIDROW(e),this.logger.log(i.DEBUG,"MIDROW ("+f([t,e])+")"),!0)}return!1},e.parsePAC=function(t,e){var r,i=this.cmdHistory;if(!((t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127||(16===t||24===t)&&e>=64&&e<=95))return!1;if(S(t,e,i))return x(null,null,i),!0;var n=t<=23?1:2;r=e>=64&&e<=95?1===n?a[t]:c[t]:1===n?l[t]:u[t];var o=this.channels[n];return!!o&&(o.setPAC(this.interpretPAC(r,e)),x(t,e,i),this.currentChannel=n,!0)},e.interpretPAC=function(t,e){var r,i={color:null,italics:!1,indent:null,underline:!1,row:t};return r=e>95?e-96:e-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},e.parseChars=function(t,e){var r,n,o=null,a=null;if(t>=25?(r=2,a=t-8):(r=1,a=t),a>=17&&a<=19?(n=17===a?e+80:18===a?e+112:e+144,this.logger.log(i.INFO,"Special char '"+s(n)+"' in channel "+r),o=[n]):t>=32&&t<=127&&(o=0===e?[t]:[t,e]),o){var l=f(o);this.logger.log(i.DEBUG,"Char codes = "+l.join(",")),x(t,e,this.cmdHistory)}return o},e.parseBackgroundAttributes=function(t,e){var r;if(!((16===t||24===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=45&&e<=47))return!1;var i={};16===t||24===t?(r=Math.floor((e-32)/2),i.background=h[r],e%2==1&&(i.background=i.background+"_semi")):45===e?i.background="transparent":(i.foreground="black",47===e&&(i.underline=!0));var n=t<=23?1:2;return this.channels[n].setBkgData(i),x(t,e,this.cmdHistory),!0},e.reset=function(){for(var t=0;t<Object.keys(this.channels).length;t++){var e=this.channels[t];e&&e.reset()}this.cmdHistory={a:null,b:null}},e.cueSplitAtTime=function(t){for(var e=0;e<this.channels.length;e++){var r=this.channels[e];r&&r.cueSplitAtTime(t)}},t}();function x(t,e,r){r.a=t,r.b=e}function S(t,e,r){return r.a===t&&r.b===e}e.default=b},"./src/utils/codecs.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/utils/codecs.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: isCodecType, isCodecSupportedInMp4 */function(t,e,r){"use strict";r.r(e),r.d(e,"isCodecType",(function(){return n})),r.d(e,"isCodecSupportedInMp4",(function(){return o}));var i={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function n(t,e){var r=i[e];return!!r&&!0===r[t.slice(0,4)]}function o(t,e){return MediaSource.isTypeSupported((e||"video")+'/mp4;codecs="'+t+'"')}},"./src/utils/cues.ts":
|
|
|
/*!***************************!*\
|
|
|
!*** ./src/utils/cues.ts ***!
|
|
|
\***************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ./vttparser */"./src/utils/vttparser.ts"),n=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts"),o=r(/*! ./texttrack-utils */"./src/utils/texttrack-utils.ts"),s=/\s/,a={newCue:function(t,e,r,a){for(var l,c,u,h,d,f=[],p=self.VTTCue||self.TextTrackCue,g=0;g<a.rows.length;g++)if(u=!0,h=0,d="",!(l=a.rows[g]).isEmpty()){for(var m=0;m<l.chars.length;m++)s.test(l.chars[m].uchar)&&u?h++:(d+=l.chars[m].uchar,u=!1);l.cueStartTime=e,e===r&&(r+=1e-4),h>=16?h--:h++;var v=Object(i.fixLineBreaks)(d.trim()),y=Object(n.generateCueId)(e,r,v);t&&t.cues&&t.cues.getCueById(y)||((c=new p(e,r,v)).id=y,c.line=g+1,c.align="left",c.position=10+Math.min(80,10*Math.floor(8*h/32)),f.push(c))}return t&&f.length&&(f.sort((function(t,e){return"auto"===t.line||"auto"===e.line?0:t.line>8&&e.line>8?e.line-t.line:t.line-e.line})),f.forEach((function(e){return Object(o.addCueToTrack)(t,e)}))),f}};e.default=a},"./src/utils/discontinuities.ts":
|
|
|
/*!**************************************!*\
|
|
|
!*** ./src/utils/discontinuities.ts ***!
|
|
|
\**************************************/
|
|
|
/*! exports provided: findFirstFragWithCC, shouldAlignOnDiscontinuities, findDiscontinuousReferenceFrag, adjustSlidingStart, alignStream, alignPDT, alignFragmentByPDTDelta, alignMediaPlaylistByPDT */function(t,e,r){"use strict";r.r(e),r.d(e,"findFirstFragWithCC",(function(){return s})),r.d(e,"shouldAlignOnDiscontinuities",(function(){return a})),r.d(e,"findDiscontinuousReferenceFrag",(function(){return l})),r.d(e,"adjustSlidingStart",(function(){return u})),r.d(e,"alignStream",(function(){return h})),r.d(e,"alignPDT",(function(){return d})),r.d(e,"alignFragmentByPDTDelta",(function(){return f})),r.d(e,"alignMediaPlaylistByPDT",(function(){return p}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./logger */"./src/utils/logger.ts"),o=r(/*! ../controller/level-helper */"./src/controller/level-helper.ts");function s(t,e){for(var r=null,i=0,n=t.length;i<n;i++){var o=t[i];if(o&&o.cc===e){r=o;break}}return r}function a(t,e,r){return!(!e.details||!(r.endCC>r.startCC||t&&t.cc<r.startCC))}function l(t,e){var r=t.fragments,i=e.fragments;if(i.length&&r.length){var o=s(r,i[0].cc);if(o&&(!o||o.startPTS))return o;n.logger.log("No frag in previous level to align on")}else n.logger.log("No fragments to align")}function c(t,e){if(t){var r=t.start+e;t.start=t.startPTS=r,t.endPTS=r+t.duration}}function u(t,e){for(var r=e.fragments,i=0,n=r.length;i<n;i++)c(r[i],t);e.fragmentHint&&c(e.fragmentHint,t),e.alignedSliding=!0}function h(t,e,r){e&&(function(t,e,r){if(a(t,r,e)){var o=l(r.details,e);o&&Object(i.isFiniteNumber)(o.start)&&(n.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),u(o.start,e))}}(t,r,e),!r.alignedSliding&&e.details&&d(r,e.details),r.alignedSliding||!e.details||r.skippedSegments||Object(o.adjustSliding)(e.details,r))}function d(t,e){if(e.fragments.length&&t.hasProgramDateTime&&e.hasProgramDateTime){var r=e.fragments[0].programDateTime,o=t.fragments[0].programDateTime,s=(o-r)/1e3+e.fragments[0].start;s&&Object(i.isFiniteNumber)(s)&&(n.logger.log("Adjusting PTS using programDateTime delta "+(o-r)+"ms, sliding:"+s.toFixed(3)+" "+t.url+" "),u(s,t))}}function f(t,e){var r=t.programDateTime;if(r){var i=(r-e)/1e3;t.start=t.startPTS=i,t.endPTS=i+t.duration}}function p(t,e){if(e.fragments.length&&t.hasProgramDateTime&&e.hasProgramDateTime){var r=e.fragments[0].programDateTime-1e3*e.fragments[0].start;t.fragments.forEach((function(t){f(t,r)})),t.fragmentHint&&f(t.fragmentHint,r),t.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":
|
|
|
/*!***********************************************!*\
|
|
|
!*** ./src/utils/ewma-bandwidth-estimator.ts ***!
|
|
|
\***********************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ../utils/ewma */"./src/utils/ewma.ts"),n=function(){function t(t,e,r){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new i.default(t),this.fast_=new i.default(e)}var e=t.prototype;return e.update=function(t,e){var r=this.slow_,n=this.fast_;this.slow_.halfLife!==t&&(this.slow_=new i.default(t,r.getEstimate(),r.getTotalWeight())),this.fast_.halfLife!==e&&(this.fast_=new i.default(e,n.getEstimate(),n.getTotalWeight()))},e.sample=function(t,e){var r=(t=Math.max(t,this.minDelayMs_))/1e3,i=8*e/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},e.canEstimate=function(){var t=this.fast_;return t&&t.getTotalWeight()>=this.minWeight_},e.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},e.destroy=function(){},t}();e.default=n},"./src/utils/ewma.ts":
|
|
|
/*!***************************!*\
|
|
|
!*** ./src/utils/ewma.ts ***!
|
|
|
\***************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=function(){function t(t,e,r){void 0===e&&(e=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=r}var e=t.prototype;return e.sample=function(t,e){var r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t},e.getTotalWeight=function(){return this.totalWeight_},e.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},t}();e.default=i},"./src/utils/fetch-loader.ts":
|
|
|
/*!***********************************!*\
|
|
|
!*** ./src/utils/fetch-loader.ts ***!
|
|
|
\***********************************/
|
|
|
/*! exports provided: fetchSupported, default */function(t,e,r){"use strict";r.r(e),r.d(e,"fetchSupported",(function(){return d}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),o=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");function s(t){var e="function"==typeof Map?new Map:void 0;return(s=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,i)}function i(){return a(t,arguments,u(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),c(i,t)})(t)}function a(t,e,r){return(a=l()?Reflect.construct:function(t,e,r){var i=[null];i.push.apply(i,e);var n=new(Function.bind.apply(t,i));return r&&c(n,r.prototype),n}).apply(null,arguments)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function h(){return(h=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function d(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}var f=function(){function t(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||p,this.controller=new self.AbortController,this.stats=new n.LoadStats}var e=t.prototype;return e.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},e.abortInternal=function(){var t=this.response;t&&t.ok||(this.stats.aborted=!0,this.controller.abort())},e.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},e.load=function(t,e,r){var n=this,o=this.stats;if(o.loading.start)throw new Error("Loader can only be used once.");o.loading.start=self.performance.now();var s=function(t,e){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(h({},t.headers))};return t.rangeEnd&&r.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),r}(t,this.controller.signal),a=r.onProgress,l="arraybuffer"===t.responseType,c=l?"byteLength":"length";this.context=t,this.config=e,this.callbacks=r,this.request=this.fetchSetup(t,s),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout((function(){n.abortInternal(),r.onTimeout(o,t,n.response)}),e.timeout),self.fetch(this.request).then((function(r){if(n.response=n.loader=r,!r.ok){var s=r.status,c=r.statusText;throw new g(c||"fetch, bad network response",s,r)}return o.loading.first=Math.max(self.performance.now(),o.loading.start),o.total=parseInt(r.headers.get("Content-Length")||"0"),a&&Object(i.isFiniteNumber)(e.highWaterMark)?n.loadProgressively(r,o,t,e.highWaterMark,a):l?r.arrayBuffer():r.text()})).then((function(s){var l=n.response;self.clearTimeout(n.requestTimeout),o.loading.end=Math.max(self.performance.now(),o.loading.first),o.loaded=o.total=s[c];var u={url:l.url,data:s};a&&!Object(i.isFiniteNumber)(e.highWaterMark)&&a(o,t,s,l),r.onSuccess(u,o,t,l)})).catch((function(e){if(self.clearTimeout(n.requestTimeout),!o.aborted){var i=e.code||0;r.onError({code:i,text:e.message},t,e.details)}}))},e.getCacheAge=function(){var t=null;if(this.response){var e=this.response.headers.get("age");t=e?parseFloat(e):null}return t},e.loadProgressively=function(t,e,r,i,n){void 0===i&&(i=0);var s=new o.default,a=t.body.getReader();return function o(){return a.read().then((function(a){if(a.done)return s.dataLength&&n(e,r,s.flush(),t),Promise.resolve(new ArrayBuffer(0));var l=a.value,c=l.length;return e.loaded+=c,c<i||s.dataLength?(s.push(l),s.dataLength>=i&&n(e,r,s.flush(),t)):n(e,r,l,t),o()})).catch((function(){return Promise.reject()}))}()},t}();function p(t,e){return new self.Request(t.url,e)}var g=function(t){var e,r;function i(e,r,i){var n;return(n=t.call(this,e)||this).code=void 0,n.details=void 0,n.code=r,n.details=i,n}return r=t,(e=i).prototype=Object.create(r.prototype),e.prototype.constructor=e,c(e,r),i}(s(Error));e.default=f},"./src/utils/imsc1-ttml-parser.ts":
|
|
|
/*!****************************************!*\
|
|
|
!*** ./src/utils/imsc1-ttml-parser.ts ***!
|
|
|
\****************************************/
|
|
|
/*! exports provided: IMSC1_CODEC, parseIMSC1 */function(t,e,r){"use strict";r.r(e),r.d(e,"IMSC1_CODEC",(function(){return u})),r.d(e,"parseIMSC1",(function(){return p}));var i=r(/*! ./mp4-tools */"./src/utils/mp4-tools.ts"),n=r(/*! ./vttparser */"./src/utils/vttparser.ts"),o=r(/*! ./vttcue */"./src/utils/vttcue.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts"),a=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),l=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts");function c(){return(c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}var u="stpp.ttml.im1t",h=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,d=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,f={left:"start",center:"center",right:"end",start:"start",end:"end"};function p(t,e,r,n,u){var h=Object(i.findBox)(new Uint8Array(t),["mdat"]);if(0!==h.length){var d=h[0],p=Object(s.utf8ArrayToStr)(new Uint8Array(t,d.start,d.end-d.start)),x=Object(a.toTimescaleFromScale)(e,1,r);try{n(function(t,e){var r=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");var i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(i).reduce((function(t,e){return t[e]=r.getAttribute("ttp:"+e)||i[e],t}),{}),s="preserve"!==r.getAttribute("xml:space"),a=m(g(r,"styling","style")),u=m(g(r,"layout","region")),h=g(r,"body","[begin]");return[].map.call(h,(function(t){var r=function t(e,r){return[].slice.call(e.childNodes).reduce((function(e,i,n){var o;return"br"===i.nodeName&&n?e+"\n":null!==(o=i.childNodes)&&void 0!==o&&o.length?t(i,r):r?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent}),"")}(t,s);if(!r||!t.hasAttribute("begin"))return null;var i=b(t.getAttribute("begin"),n),h=b(t.getAttribute("dur"),n),d=b(t.getAttribute("end"),n);if(null===i)throw y(t);if(null===d){if(null===h)throw y(t);d=i+h}var p=new o.default(i-e,d-e,r);p.id=Object(l.generateCueId)(p.startTime,p.endTime,p.text);var g=u[t.getAttribute("region")],m=a[t.getAttribute("style")];p.position=10,p.size=80;var x=function(t,e){var r="http://www.w3.org/ns/ttml#styling";return["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((function(i,n){var o=v(e,r,n)||v(t,r,n);return o&&(i[n]=o),i}),{})}(g,m),S=x.textAlign;if(S){var C=f[S];C&&(p.lineAlign=C),p.align=S}return c(p,x),p})).filter((function(t){return null!==t}))}(p,x))}catch(t){u(t)}}else u(new Error("Could not parse IMSC1 mdat"))}function g(t,e,r){var i=t.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function m(t){return t.reduce((function(t,e){var r=e.getAttribute("xml:id");return r&&(t[r]=e),t}),{})}function v(t,e,r){return t.hasAttributeNS(e,r)?t.getAttributeNS(e,r):null}function y(t){return new Error("Could not parse ttml timestamp "+t)}function b(t,e){if(!t)return null;var r=Object(n.parseTimeStamp)(t);return null===r&&(h.test(t)?r=function(t,e){var r=h.exec(t),i=(0|r[4])+(0|r[5])/e.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/e.frameRate}(t,e):d.test(t)&&(r=function(t,e){var r=d.exec(t),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}(t,e))),r}},"./src/utils/logger.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/utils/logger.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: enableLogs, logger */function(t,e,r){"use strict";r.r(e),r.d(e,"enableLogs",(function(){return a})),r.d(e,"logger",(function(){return l}));var i=function(){},n={trace:i,debug:i,log:i,warn:i,info:i,error:i},o=n;function s(t){var e=self.console[t];return e?e.bind(self.console,"["+t+"] >"):i}function a(t){if(self.console&&!0===t||"object"==typeof t){!function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];r.forEach((function(e){o[e]=t[e]?t[e].bind(t):s(e)}))}(t,"debug","log","info","warn","error");try{o.log()}catch(t){o=n}}else o=n}var l=n},"./src/utils/mediakeys-helper.ts":
|
|
|
/*!***************************************!*\
|
|
|
!*** ./src/utils/mediakeys-helper.ts ***!
|
|
|
\***************************************/
|
|
|
/*! exports provided: KeySystems, requestMediaKeySystemAccess */function(t,e,r){"use strict";var i;r.r(e),r.d(e,"KeySystems",(function(){return i})),r.d(e,"requestMediaKeySystemAccess",(function(){return n})),function(t){t.WIDEVINE="com.widevine.alpha",t.PLAYREADY="com.microsoft.playready"}(i||(i={}));var n="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null},"./src/utils/mediasource-helper.ts":
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./src/utils/mediasource-helper.ts ***!
|
|
|
\*****************************************/
|
|
|
/*! exports provided: getMediaSource */function(t,e,r){"use strict";function i(){return self.MediaSource||self.WebKitMediaSource}r.r(e),r.d(e,"getMediaSource",(function(){return i}))},"./src/utils/mp4-tools.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/utils/mp4-tools.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: bin2str, readUint16, readUint32, writeUint32, findBox, parseSegmentIndex, parseInitSegment, getStartDTS, getDuration, computeRawDurationFromSamples, offsetStartDTS, segmentValidRange, appendUint8Array */function(t,e,r){"use strict";r.r(e),r.d(e,"bin2str",(function(){return a})),r.d(e,"readUint16",(function(){return l})),r.d(e,"readUint32",(function(){return c})),r.d(e,"writeUint32",(function(){return u})),r.d(e,"findBox",(function(){return h})),r.d(e,"parseSegmentIndex",(function(){return d})),r.d(e,"parseInitSegment",(function(){return f})),r.d(e,"getStartDTS",(function(){return p})),r.d(e,"getDuration",(function(){return g})),r.d(e,"computeRawDurationFromSamples",(function(){return m})),r.d(e,"offsetStartDTS",(function(){return v})),r.d(e,"segmentValidRange",(function(){return y})),r.d(e,"appendUint8Array",(function(){return b}));var i=r(/*! ./typed-array */"./src/utils/typed-array.ts"),n=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),o=Math.pow(2,32)-1,s=[].push;function a(t){return String.fromCharCode.apply(null,t)}function l(t,e){"data"in t&&(e+=t.start,t=t.data);var r=t[e]<<8|t[e+1];return r<0?65536+r:r}function c(t,e){"data"in t&&(e+=t.start,t=t.data);var r=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3];return r<0?4294967296+r:r}function u(t,e,r){"data"in t&&(e+=t.start,t=t.data),t[e]=r>>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r}function h(t,e){var r,i,n,o=[];if(!e.length)return o;"data"in t?(r=t.data,i=t.start,n=t.end):(i=0,n=(r=t).byteLength);for(var l=i;l<n;){var u=c(r,l),d=u>1?l+u:n;if(a(r.subarray(l+4,l+8))===e[0])if(1===e.length)o.push({data:r,start:l+8,end:d});else{var f=h({data:r,start:l+8,end:d},e.slice(1));f.length&&s.apply(o,f)}l=d}return o}function d(t){var e=h(t,["moov"])[0],r=e?e.end:null,i=h(t,["sidx"]);if(!i||!i[0])return null;var n=[],o=i[0],s=o.data[0],a=0===s?8:16,u=c(o,a);a+=4,a+=0===s?8:16,a+=2;var d=o.end+0,f=l(o,a);a+=2;for(var p=0;p<f;p++){var g=a,m=c(o,g);g+=4;var v=2147483647&m;if(1==(2147483648&m)>>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;var y=c(o,g);g+=4,n.push({referenceSize:v,subsegmentDuration:y,info:{duration:y/u,start:d,end:d+v-1}}),d+=v,a=g+=4}return{earliestPresentationTime:0,timescale:u,version:s,referencesCount:f,references:n,moovEndOffset:r}}function f(t){for(var e=[],r=h(t,["moov","trak"]),i=0;i<r.length;i++){var o=r[i],s=h(o,["tkhd"])[0];if(s){var l=s.data[s.start],u=0===l?12:20,d=c(s,u),f=h(o,["mdia","mdhd"])[0];if(f){var p=c(f,u=0===(l=f.data[f.start])?12:20),g=h(o,["mdia","hdlr"])[0];if(g){var m=a(g.data.subarray(g.start+8,g.start+12)),v={soun:n.ElementaryStreamTypes.AUDIO,vide:n.ElementaryStreamTypes.VIDEO}[m];if(v){var y=h(o,["mdia","minf","stbl","stsd"])[0],b=void 0;y&&(b=a(y.data.subarray(y.start+12,y.start+16))),e[d]={timescale:p,type:v},e[v]={timescale:p,id:d,codec:b}}}}}}return h(t,["moov","mvex","trex"]).forEach((function(t){var r=c(t,4),i=e[r];i&&(i.default={duration:c(t,12),flags:c(t,20)})})),e}function p(t,e){return h(e,["moof","traf"]).reduce((function(e,r){var i=h(r,["tfdt"])[0],n=i.data[i.start],o=h(r,["tfhd"]).reduce((function(e,r){var o=c(r,4),s=t[o];if(s){var a=c(i,4);1===n&&(a*=Math.pow(2,32),a+=c(i,8));var l=a/(s.timescale||9e4);if(isFinite(l)&&(null===e||l<e))return l}return e}),null);return null!==o&&isFinite(o)&&(null===e||o<e)?o:e}),null)||0}function g(t,e){for(var r=0,i=0,o=0,s=h(t,["moof","traf"]),a=0;a<s.length;a++){var l=s[a],u=h(l,["tfhd"])[0],f=e[c(u,4)];if(f){var p=f.default,g=c(u,0)|(null==p?void 0:p.flags),v=null==p?void 0:p.duration;8&g&&(v=c(u,2&g?12:8));for(var y=f.timescale||9e4,b=h(l,["trun"]),x=0;x<b.length;x++)r=v?v*c(b[x],4):m(b[x]),f.type===n.ElementaryStreamTypes.VIDEO?i+=r/y:f.type===n.ElementaryStreamTypes.AUDIO&&(o+=r/y)}}if(0===i&&0===o){var S=d(t);if(null!=S&&S.references)return S.references.reduce((function(t,e){return t+e.info.duration||0}),0)}return i||o}function m(t){var e=c(t,0),r=8;1&e&&(r+=4),4&e&&(r+=4);for(var i=0,n=c(t,4),o=0;o<n;o++)256&e&&(i+=c(t,r),r+=4),512&e&&(r+=4),1024&e&&(r+=4),2048&e&&(r+=4);return i}function v(t,e,r){h(e,["moof","traf"]).forEach((function(e){h(e,["tfhd"]).forEach((function(i){var n=c(i,4),s=t[n];if(s){var a=s.timescale||9e4;h(e,["tfdt"]).forEach((function(t){var e=t.data[t.start],i=c(t,4);if(0===e)u(t,4,i-r*a);else{i*=Math.pow(2,32),i+=c(t,8),i-=r*a,i=Math.max(i,0);var n=Math.floor(i/(o+1)),s=Math.floor(i%(o+1));u(t,4,n),u(t,8,s)}}))}}))}))}function y(t){var e={valid:null,remainder:null},r=h(t,["moof"]);if(!r)return e;if(r.length<2)return e.remainder=t,e;var n=r[r.length-1];return e.valid=Object(i.sliceUint8)(t,0,n.start-8),e.remainder=Object(i.sliceUint8)(t,n.start-8),e}function b(t,e){var r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}},"./src/utils/output-filter.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/utils/output-filter.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return i}));var i=function(){function t(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}var e=t.prototype;return e.dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},e.newCue=function(t,e,r){(null===this.startTime||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},e.reset=function(){this.cueRanges=[]},t}()},"./src/utils/texttrack-utils.ts":
|
|
|
/*!**************************************!*\
|
|
|
!*** ./src/utils/texttrack-utils.ts ***!
|
|
|
\**************************************/
|
|
|
/*! exports provided: sendAddTrackEvent, addCueToTrack, clearCurrentCues, removeCuesInRange, getCuesInRange */function(t,e,r){"use strict";r.r(e),r.d(e,"sendAddTrackEvent",(function(){return n})),r.d(e,"addCueToTrack",(function(){return o})),r.d(e,"clearCurrentCues",(function(){return s})),r.d(e,"removeCuesInRange",(function(){return a})),r.d(e,"getCuesInRange",(function(){return l}));var i=r(/*! ./logger */"./src/utils/logger.ts");function n(t,e){var r;try{r=new Event("addtrack")}catch(t){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=t,e.dispatchEvent(r)}function o(t,e){var r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(e.id))try{if(t.addCue(e),!t.cues.getCueById(e.id))throw new Error("addCue is failed for: "+e)}catch(r){i.logger.debug("[texttrack-utils]: "+r);var n=new self.TextTrackCue(e.startTime,e.endTime,e.text);n.id=e.id,t.addCue(n)}"disabled"===r&&(t.mode=r)}function s(t){var e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(var r=t.cues.length;r--;)t.removeCue(t.cues[r]);"disabled"===e&&(t.mode=e)}function a(t,e,r){var i=t.mode;if("disabled"===i&&(t.mode="hidden"),t.cues&&t.cues.length>0)for(var n=l(t.cues,e,r),o=0;o<n.length;o++)t.removeCue(n[o]);"disabled"===i&&(t.mode=i)}function l(t,e,r){var i=[],n=function(t,e){if(e<t[0].startTime)return 0;var r=t.length-1;if(e>t[r].endTime)return-1;for(var i=0,n=r;i<=n;){var o=Math.floor((n+i)/2);if(e<t[o].startTime)n=o-1;else{if(!(e>t[o].startTime&&i<r))return o;i=o+1}}return t[i].startTime-e<e-t[n].startTime?i:n}(t,e);if(n>-1)for(var o=n,s=t.length;o<s;o++){var a=t[o];if(a.startTime>=e&&a.endTime<=r)i.push(a);else if(a.startTime>r)return i}return i}},"./src/utils/time-ranges.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/utils/time-ranges.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),e.default={toString:function(t){for(var e="",r=t.length,i=0;i<r;i++)e+="["+t.start(i).toFixed(3)+","+t.end(i).toFixed(3)+"]";return e}}},"./src/utils/timescale-conversion.ts":
|
|
|
/*!*******************************************!*\
|
|
|
!*** ./src/utils/timescale-conversion.ts ***!
|
|
|
\*******************************************/
|
|
|
/*! exports provided: toTimescaleFromBase, toTimescaleFromScale, toMsFromMpegTsClock, toMpegTsClockFromTimescale */function(t,e,r){"use strict";function i(t,e,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var n=t*e*r;return i?Math.round(n):n}function n(t,e,r,n){return void 0===r&&(r=1),void 0===n&&(n=!1),i(t,e,1/r,n)}function o(t,e){return void 0===e&&(e=!1),i(t,1e3,1/9e4,e)}function s(t,e){return void 0===e&&(e=1),i(t,9e4,1/e)}r.r(e),r.d(e,"toTimescaleFromBase",(function(){return i})),r.d(e,"toTimescaleFromScale",(function(){return n})),r.d(e,"toMsFromMpegTsClock",(function(){return o})),r.d(e,"toMpegTsClockFromTimescale",(function(){return s}))},"./src/utils/typed-array.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/utils/typed-array.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: sliceUint8 */function(t,e,r){"use strict";function i(t,e,r){return Uint8Array.prototype.slice?t.slice(e,r):new Uint8Array(Array.prototype.slice.call(t,e,r))}r.r(e),r.d(e,"sliceUint8",(function(){return i}))},"./src/utils/vttcue.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/utils/vttcue.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),e.default=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var t=["","lr","rl"],e=["start","middle","end","left","right"];function r(t,e){if("string"!=typeof e)return!1;if(!Array.isArray(t))return!1;var r=e.toLowerCase();return!!~t.indexOf(r)&&r}function i(t){return r(e,t)}function n(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];for(var n=1;n<arguments.length;n++){var o=arguments[n];for(var s in o)t[s]=o[s]}return t}function o(e,o,s){var a=this,l={enumerable:!0};a.hasBeenReset=!1;var c="",u=!1,h=e,d=o,f=s,p=null,g="",m=!0,v="auto",y="start",b=50,x="middle",S=50,C="middle";Object.defineProperty(a,"id",n({},l,{get:function(){return c},set:function(t){c=""+t}})),Object.defineProperty(a,"pauseOnExit",n({},l,{get:function(){return u},set:function(t){u=!!t}})),Object.defineProperty(a,"startTime",n({},l,{get:function(){return h},set:function(t){if("number"!=typeof t)throw new TypeError("Start time must be set to a number.");h=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"endTime",n({},l,{get:function(){return d},set:function(t){if("number"!=typeof t)throw new TypeError("End time must be set to a number.");d=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"text",n({},l,{get:function(){return f},set:function(t){f=""+t,this.hasBeenReset=!0}})),Object.defineProperty(a,"region",n({},l,{get:function(){return p},set:function(t){p=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"vertical",n({},l,{get:function(){return g},set:function(e){var i=function(e){return r(t,e)}(e);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");g=i,this.hasBeenReset=!0}})),Object.defineProperty(a,"snapToLines",n({},l,{get:function(){return m},set:function(t){m=!!t,this.hasBeenReset=!0}})),Object.defineProperty(a,"line",n({},l,{get:function(){return v},set:function(t){if("number"!=typeof t&&"auto"!==t)throw new SyntaxError("An invalid number or illegal string was specified.");v=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"lineAlign",n({},l,{get:function(){return y},set:function(t){var e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");y=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"position",n({},l,{get:function(){return b},set:function(t){if(t<0||t>100)throw new Error("Position must be between 0 and 100.");b=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"positionAlign",n({},l,{get:function(){return x},set:function(t){var e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");x=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"size",n({},l,{get:function(){return S},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");S=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"align",n({},l,{get:function(){return C},set:function(t){var e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");C=e,this.hasBeenReset=!0}})),a.displayState=void 0}return o.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},o}()},"./src/utils/vttparser.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/utils/vttparser.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: parseTimeStamp, fixLineBreaks, VTTParser */function(t,e,r){"use strict";r.r(e),r.d(e,"parseTimeStamp",(function(){return o})),r.d(e,"fixLineBreaks",(function(){return h})),r.d(e,"VTTParser",(function(){return d}));var i=r(/*! ./vttcue */"./src/utils/vttcue.ts"),n=function(){function t(){}return t.prototype.decode=function(t,e){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))},t}();function o(t){function e(t,e,r,i){return 3600*(0|t)+60*(0|e)+(0|r)+parseFloat(i||0)}var r=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?e(r[2],r[3],0,r[4]):e(r[1],r[2],r[3],r[4]):null}var s=function(){function t(){this.values=Object.create(null)}var e=t.prototype;return e.set=function(t,e){this.get(t)||""===e||(this.values[t]=e)},e.get=function(t,e,r){return r?this.has(t)?this.values[t]:e[r]:this.has(t)?this.values[t]:e},e.has=function(t){return t in this.values},e.alt=function(t,e,r){for(var i=0;i<r.length;++i)if(e===r[i]){this.set(t,e);break}},e.integer=function(t,e){/^-?\d+$/.test(e)&&this.set(t,parseInt(e,10))},e.percent=function(t,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var r=parseFloat(e);if(r>=0&&r<=100)return this.set(t,r),!0}return!1},t}();function a(t,e,r,i){var n=i?t.split(i):[t];for(var o in n)if("string"==typeof n[o]){var s=n[o].split(r);2===s.length&&e(s[0],s[1])}}var l=new i.default(0,0,""),c="middle"===l.align?"middle":"center";function u(t,e,r){var i=t;function n(){var e=o(t);if(null===e)throw new Error("Malformed timestamp: "+i);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function u(){t=t.replace(/^\s+/,"")}if(u(),e.startTime=n(),u(),"--\x3e"!==t.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);t=t.substr(3),u(),e.endTime=n(),u(),function(t,e){var i=new s;a(t,(function(t,e){var n;switch(t){case"region":for(var o=r.length-1;o>=0;o--)if(r[o].id===e){i.set(t,r[o].region);break}break;case"vertical":i.alt(t,e,["rl","lr"]);break;case"line":n=e.split(","),i.integer(t,n[0]),i.percent(t,n[0])&&i.set("snapToLines",!1),i.alt(t,n[0],["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",c,"end"]);break;case"position":n=e.split(","),i.percent(t,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",c,"end","line-left","line-right","auto"]);break;case"size":i.percent(t,e);break;case"align":i.alt(t,e,["start",c,"end","left","right"])}}),/:/,/\s/),e.region=i.get("region",null),e.vertical=i.get("vertical","");var n=i.get("line","auto");"auto"===n&&-1===l.line&&(n=-1),e.line=n,e.lineAlign=i.get("lineAlign","start"),e.snapToLines=i.get("snapToLines",!0),e.size=i.get("size",100),e.align=i.get("align",c);var o=i.get("position","auto");"auto"===o&&50===l.position&&(o="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=o}(t,e)}function h(t){return t.replace(/<br(?: \/)?>/gi,"\n")}var d=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 e=t.prototype;return e.parse=function(t){var e=this;function r(){var t=e.buffer,r=0;for(t=h(t);r<t.length&&"\r"!==t[r]&&"\n"!==t[r];)++r;var i=t.substr(0,r);return"\r"===t[r]&&++r,"\n"===t[r]&&++r,e.buffer=t.substr(r),i}t&&(e.buffer+=e.decoder.decode(t,{stream:!0}));try{var n="";if("INITIAL"===e.state){if(!/\r\n|\n/.test(e.buffer))return this;var o=(n=r()).match(/^()?WEBVTT([ \t].*)?$/);if(!o||!o[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var s=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(s?s=!1:n=r(),e.state){case"HEADER":/:/.test(n)?a(n,(function(t,e){}),/:/):n||(e.state="ID");continue;case"NOTE":n||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){e.state="NOTE";break}if(!n)continue;if(e.cue=new i.default(0,0,""),e.state="CUE",-1===n.indexOf("--\x3e")){e.cue.id=n;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{u(n,e.cue,e.regionList)}catch(t){e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":var l=-1!==n.indexOf("--\x3e");if(!n||l&&(s=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(null===e.cue)continue;e.cue.text&&(e.cue.text+="\n"),e.cue.text+=n;continue;case"BADCUE":n||(e.state="ID")}}}catch(t){"CUETEXT"===e.state&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state="INITIAL"===e.state?"BADWEBVTT":"BADCUE"}return this},e.flush=function(){try{if((this.cue||"HEADER"===this.state)&&(this.buffer+="\n\n",this.parse()),"INITIAL"===this.state||"BADWEBVTT"===this.state)throw new Error("Malformed WebVTT signature.")}catch(t){this.onparsingerror&&this.onparsingerror(t)}return this.onflush&&this.onflush(),this},t}()},"./src/utils/webvtt-parser.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/utils/webvtt-parser.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: generateCueId, parseWebVTT */function(t,e,r){"use strict";r.r(e),r.d(e,"generateCueId",(function(){return h})),r.d(e,"parseWebVTT",(function(){return d}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./vttparser */"./src/utils/vttparser.ts"),o=r(/*! ../demux/id3 */"./src/demux/id3.ts"),s=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),a=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),l=/\r\n|\n\r|\n|\r/g,c=function(t,e,r){return void 0===r&&(r=0),t.substr(r,e.length)===e},u=function(t){for(var e=5381,r=t.length;r;)e=33*e^t.charCodeAt(--r);return(e>>>0).toString()};function h(t,e,r){return u(t.toString())+u(e.toString())+u(r)}function d(t,e,r,u,d,f,p,g){var m,v=new n.VTTParser,y=Object(o.utf8ArrayToStr)(new Uint8Array(t)).trim().replace(l,"\n").split("\n"),b=[],x=Object(s.toMpegTsClockFromTimescale)(e,r),S="00:00.000",C=0,w=0,k=!0,E=!1;v.oncue=function(t){var e=u[d],r=u.ccOffset,i=(C-x)/9e4;if(null!=e&&e.new&&(void 0!==w?r=u.ccOffset=e.start:function(t,e,r){var i=t[e],n=t[i.prevCC];if(!n||!n.new&&i.new)return t.ccOffset=t.presentationOffset=i.start,void(i.new=!1);for(;null!==(o=n)&&void 0!==o&&o.new;){var o;t.ccOffset+=i.start-n.start,i.new=!1,n=t[(i=n).prevCC]}t.presentationOffset=r}(u,d,i)),i&&(r=i-u.presentationOffset),E){var n=t.endTime-t.startTime,o=Object(a.normalizePts)(9e4*(t.startTime+r-w),9e4*f)/9e4;t.startTime=o,t.endTime=o+n}var s=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(s)),t.id||(t.id=h(t.startTime,t.endTime,s)),t.endTime>0&&b.push(t)},v.onparsingerror=function(t){m=t},v.onflush=function(){m?g(m):p(b)},y.forEach((function(t){if(k){if(c(t,"X-TIMESTAMP-MAP=")){k=!1,E=!0,t.substr(16).split(",").forEach((function(t){c(t,"LOCAL:")?S=t.substr(6):c(t,"MPEGTS:")&&(C=parseInt(t.substr(7)))}));try{w=function(t){var e=parseInt(t.substr(-3)),r=parseInt(t.substr(-6,2)),n=parseInt(t.substr(-9,2)),o=t.length>9?parseInt(t.substr(0,t.indexOf(":"))):0;if(!(Object(i.isFiniteNumber)(e)&&Object(i.isFiniteNumber)(r)&&Object(i.isFiniteNumber)(n)&&Object(i.isFiniteNumber)(o)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+t);return e+=1e3*r,e+=6e4*n,e+=36e5*o}(S)/1e3}catch(t){E=!1,m=t}return}""===t&&(k=!1)}v.parse(t+"\n")})),v.flush()}},"./src/utils/xhr-loader.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/utils/xhr-loader.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,r){"use strict";r.r(e);var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),o=/^age:\s*[\d.]+\s*$/m,s=function(){function t(t){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=t?t.xhrSetup:null,this.stats=new n.LoadStats,this.retryDelay=0}var e=t.prototype;return e.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},e.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},e.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.retryDelay=e.retryDelay,this.loadInternal()},e.loadInternal=function(){var t=this.config,e=this.context;if(t){var r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0;var n=this.xhrSetup;try{if(n)try{n(r,e.url)}catch(t){r.open("GET",e.url,!0),n(r,e.url)}r.readyState||r.open("GET",e.url,!0);var o=this.context.headers;if(o)for(var s in o)r.setRequestHeader(s,o[s])}catch(t){return void this.callbacks.onError({code:r.status,text:t.message},e,r)}e.rangeEnd&&r.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=e.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),r.send()}},e.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(t&&e){var n=e.readyState,o=this.config;if(!r.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start)),4===n){e.onreadystatechange=null,e.onprogress=null;var s=e.status;if(s>=200&&s<300){var a,l;if(r.loading.end=Math.max(self.performance.now(),r.loading.first),l="arraybuffer"===t.responseType?(a=e.response).byteLength:(a=e.responseText).length,r.loaded=r.total=l,!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(r,t,a,e),!this.callbacks)return;var u={url:e.responseURL,data:a};this.callbacks.onSuccess(u,r,t,e)}else r.retry>=o.maxRetry||s>=400&&s<499?(i.logger.error(s+" while loading "+t.url),this.callbacks.onError({code:s,text:e.statusText},t,e)):(i.logger.warn(s+" while loading "+t.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,o.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),o.timeout)}},e.loadtimeout=function(){i.logger.warn("timeout while loading "+this.context.url);var t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t=null;if(this.loader&&o.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},t}();e.default=s}}).default},t.exports=i())},vHTk:
|
|
|
/*!******************************************************!*\
|
|
|
!*** ./src/components/PreviewAll/index.less?modules ***!
|
|
|
\******************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,r){t.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}},wU8J:
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./node_modules/qr.js/lib/BitBuffer.js ***!
|
|
|
\*********************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e){function r(){this.buffer=new Array,this.length=0}r.prototype={get:function(t){var e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)},put:function(t,e){for(var r=0;r<e;r++)this.putBit(1==(t>>>e-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},t.exports=r},wzkS:
|
|
|
/*!**************************************************!*\
|
|
|
!*** ./src/pages/MoopCases/FormPanel/service.ts ***!
|
|
|
\**************************************************/
|
|
|
/*! exports provided: getMoopCase, getLibraryTags, removeAttachment, addMoopCase, updateMoopCase */
|
|
|
/*! exports used: addMoopCase, getLibraryTags, getMoopCase, removeAttachment, updateMoopCase */function(t,e,r){"use strict";r.d(e,"c",(function(){return a})),r.d(e,"b",(function(){return l})),r.d(e,"d",(function(){return c})),r.d(e,"a",(function(){return h})),r.d(e,"e",(function(){return d}));var i=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/asyncToGenerator */"9og8"),n=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/regenerator */"WmNS"),o=r.n(n),s=r(/*! @/utils/fetch */"ErOA");function a(t){return Object(s.c)("libraries/".concat(t,".json"))}function l(){return Object(s.c)("library_tags.json")}function c(t){return u.apply(this,arguments)}function u(){return(u=Object(i.a)(o.a.mark((function t(e){var r;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(s.b)("attachments/".concat(e,".json"));case 2:return r=t.sent,t.abrupt("return",0===r.status);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function h(t){return Object(s.f)("libraries.json",t)}function d(t,e){return Object(s.g)("libraries/".concat(t,".json"),e)}},y5JW:
|
|
|
/*!***********************************************!*\
|
|
|
!*** ./src/components/SingleUpload/index.tsx ***!
|
|
|
\***********************************************/
|
|
|
/*! exports provided: uploadNameSizeSeperator, bytesToSize, default */
|
|
|
/*! exports used: bytesToSize, default, uploadNameSizeSeperator */function(t,e,r){"use strict";r.d(e,"c",(function(){return g})),r.d(e,"a",(function(){return m}));r(/*! antd/es/upload/style */"DZo9");var i=r(/*! antd/es/upload */"8z0m"),n=(r(/*! antd/es/button/style */"+L6B"),r(/*! antd/es/button */"2/Rp")),o=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/asyncToGenerator */"9og8"),s=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2 */"k1fw"),a=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/toConsumableArray */"oBTY"),l=(r(/*! antd/es/message/style */"miYZ"),r(/*! antd/es/message */"tsqr")),c=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/regenerator */"WmNS"),u=r.n(c),h=r(/*! react */"q1tI"),d=r.n(h),f=r(/*! @/utils/env */"m3rI"),p=r(/*! @/pages/MoopCases/FormPanel/service */"wzkS"),g=" ";function m(t){if(0==t)return"0 Byte";var e=parseInt(""+Math.floor(Math.log(t)/Math.log(1024)),10);return(t/Math.pow(1024,e)).toFixed(1)+" "+["Bytes","KB","MB","GB","TB"][e]}e.b=function(t){var e,r=t.value,c=void 0===r?[]:r,h=(t.action,t.onChange),v=t.className,y=t.maxSize,b=void 0===y?150:y,x=t.title,S=void 0===x?"文件上传":x,C=t.accept,w={multiple:!1,fileList:c,accept:void 0===C?null:C,withCredentials:!0,beforeUpload:function(t){return t.size/1024/1024<b||(l.b.error("该文件无法上传。超过文件大小限制(".concat(b,"MB),建议上传到百度云等其它共享工具里,然后再txt文档里给出链接以及共享密码并上传")),Promise.reject())},action:"".concat(f.a.API_SERVER,"/api/attachments.json"),onChange:function(t){var e=Object(a.a)(t.fileList);e=e.map((function(t){return-1===t.name.indexOf(g)&&(t.name="".concat(t.name).concat(g).concat(m(t.size))),Object(s.a)({},t)})),h(e)},onRemove:(e=Object(o.a)(u.a.mark((function t(e){var r,i;return u.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.size/1024/1024,"uploading"!==e.status){t.next=3;break}return t.abrupt("return",!0);case 3:if(r<b){t.next=7;break}return t.abrupt("return",!0);case 7:if(!(e.response?e.response.id:e.uid)){t.next=15;break}return t.next=11,Object(p.d)(e.response?e.response.id:e.id);case 11:return i=t.sent,t.abrupt("return",i);case 15:return t.abrupt("return",!0);case 16:case"end":return t.stop()}}),t)}))),function(t){return e.apply(this,arguments)})};return d.a.createElement("div",{className:"single-upload ".concat(v||"")},d.a.createElement(i.a,w,d.a.createElement(n.a,{type:"primary",title:c.length>0?"每次只能上传一个资源, 删除下面资源可重新上传 ":"",disabled:c.length>0,ghost:!0},S),d.a.createElement("span",{onClick:function(t){t.preventDefault(),t.stopPropagation()},style:{marginLeft:10}},"(单个文件最大",b,"M) ")))}}}]); |