|
|
(window.webpackJsonp=window.webpackJsonp||[]).push([[204,5,7],{"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,i){"use strict";i.d(e,"a",(function(){return v})),i.d(e,"b",(function(){return b}));var r=i(/*! react-router */"Ty5D"),n=i(/*! @babel/runtime/helpers/esm/inheritsLoose */"dI71"),s=i(/*! react */"q1tI"),a=i.n(s),o=i(/*! history */"YS25"),l=(i(/*! prop-types */"17x9"),i(/*! @babel/runtime/helpers/esm/extends */"wx14")),c=i(/*! @babel/runtime/helpers/esm/objectWithoutPropertiesLoose */"zLVn"),h=i(/*! tiny-invariant */"9R94");a.a.Component;a.a.Component;var u=function(t,e){return"function"==typeof t?t(e):t},d=function(t,e){return"string"==typeof t?Object(o.c)(t,null,null,e):t},f=function(t){return t},p=a.a.forwardRef;void 0===p&&(p=f);var g=p((function(t,e){var i=t.innerRef,r=t.navigate,n=t.onClick,s=Object(c.a)(t,["innerRef","navigate","onClick"]),o=s.target,h=Object(l.a)({},s,{onClick:function(t){try{n&&n(t)}catch(e){throw t.preventDefault(),e}t.defaultPrevented||0!==t.button||o&&"_self"!==o||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||(t.preventDefault(),r())}});return h.ref=f!==p&&e||i,a.a.createElement("a",h)}));var v=p((function(t,e){var i=t.component,n=void 0===i?g:i,s=t.replace,o=t.to,v=t.innerRef,m=Object(c.a)(t,["component","replace","to","innerRef"]);return a.a.createElement(r.e.Consumer,null,(function(t){t||Object(h.a)(!1);var i=t.history,r=d(u(o,t.location),t.location),c=r?i.createHref(r):"",g=Object(l.a)({},m,{href:c,navigate:function(){var e=u(o,t.location);(s?i.replace:i.push)(e)}});return f!==p?g.ref=e||v:g.innerRef=v,a.a.createElement(n,g)}))})),m=function(t){return t},y=a.a.forwardRef;void 0===y&&(y=m);var b=y((function(t,e){var i=t["aria-current"],n=void 0===i?"page":i,s=t.activeClassName,o=void 0===s?"active":s,f=t.activeStyle,p=t.className,g=t.exact,b=t.isActive,S=t.location,E=t.sensitive,C=t.strict,k=t.style,T=t.to,w=t.innerRef,x=Object(c.a)(t,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return a.a.createElement(r.e.Consumer,null,(function(t){t||Object(h.a)(!1);var i=S||t.location,s=d(u(T,i),i),c=s.pathname,A=c&&c.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),L=A?Object(r.f)(i.pathname,{path:A,exact:g,sensitive:E,strict:C}):null,R=!!(b?b(L,i):L),D=R?function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return e.filter((function(t){return t})).join(" ")}(p,o):p,_=R?Object(l.a)({},k,{},f):k,O=Object(l.a)({"aria-current":R&&n||null,className:D,style:_,to:s},x);return m!==y?O.ref=e||w:O.innerRef=w,a.a.createElement(v,O)}))}))},"815F":
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./node_modules/rc-tree/es/utils/treeUtil.js ***!
|
|
|
\***************************************************/
|
|
|
/*! exports provided: getKey, warningWithoutKey, convertTreeToData, flattenTreeData, traverseDataNodes, convertDataToEntities, getTreeNodeProps, convertNodePropsToEventData */
|
|
|
/*! exports used: convertDataToEntities, convertNodePropsToEventData, convertTreeToData, flattenTreeData, getKey, getTreeNodeProps */function(t,e,i){"use strict";i.d(e,"e",(function(){return c})),i.d(e,"c",(function(){return h})),i.d(e,"d",(function(){return u})),i.d(e,"a",(function(){return f})),i.d(e,"f",(function(){return p})),i.d(e,"b",(function(){return g}));var r=i(/*! @babel/runtime/helpers/esm/toConsumableArray */"KQm4"),n=i(/*! @babel/runtime/helpers/esm/objectSpread2 */"VTBJ"),s=i(/*! @babel/runtime/helpers/esm/objectWithoutProperties */"Ff2n"),a=i(/*! rc-util/es/Children/toArray */"Zm9Q"),o=i(/*! rc-util/es/warning */"Kwbf"),l=i(/*! ../util */"OZM5");function c(t,e){return null!=t?t:e}function h(t){return function t(e){return Object(a.a)(e).map((function(e){if(!Object(l.i)(e))return Object(o.a)(!e,"Tree/TreeNode can only accept TreeNode as children."),null;var i=e.key,r=e.props,a=r.children,c=Object(s.a)(r,["children"]),h=Object(n.a)({key:i},c),u=t(a);return u.length&&(h.children=u),h})).filter((function(t){return t}))}(t)}function u(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=new Set(!0===e?[]:e),s=[];function a(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return t.map((function(h,u){var d=Object(l.h)(o?o.pos:"0",u),f=c(h.key,d),p=Object(n.a)(Object(n.a)({},h),{},{parent:o,pos:d,children:null,data:h,isStart:[].concat(Object(r.a)(o?o.isStart:[]),[0===u]),isEnd:[].concat(Object(r.a)(o?o.isEnd:[]),[u===t.length-1])});return s.push(p),!0===e||i.has(f)?p.children=a(h.children||[],p):p.children=[],p}))}return a(t),s}function d(t,e,i){var r;i?"string"==typeof i?r=function(t){return t[i]}:"function"==typeof i&&(r=function(t){return i(t)}):r=function(t,e){return c(t.key,e)},function i(n,s,a){var o=n?n.children:t,c=n?Object(l.h)(a.pos,s):"0";if(n){var h=r(n,c),u={node:n,index:s,pos:c,key:h,parentPos:a.node?a.pos:null,level:a.level+1};e(u)}o&&o.forEach((function(t,e){i(t,e,{node:n,pos:c,level:a?a.level+1:-1})}))}(null)}function f(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=e.initWrapper,r=e.processEntity,n=e.onProcessFinished,s=arguments.length>2?arguments[2]:void 0,a={},o={},l={posEntities:a,keyEntities:o};return i&&(l=i(l)||l),d(t,(function(t){var e=t.node,i=t.index,n=t.pos,s=t.key,h=t.parentPos,u={node:e,index:i,key:s,pos:n,level:t.level},d=c(s,n);a[n]=u,o[d]=u,u.parent=a[h],u.parent&&(u.parent.children=u.parent.children||[],u.parent.children.push(u)),r&&r(u,l)}),s),n&&n(l),l}function p(t,e){var i=e.expandedKeys,r=e.selectedKeys,n=e.loadedKeys,s=e.loadingKeys,a=e.checkedKeys,o=e.halfCheckedKeys,l=e.dragOverNodeKey,c=e.dropPosition,h=e.keyEntities[t];return{eventKey:t,expanded:-1!==i.indexOf(t),selected:-1!==r.indexOf(t),loaded:-1!==n.indexOf(t),loading:-1!==s.indexOf(t),checked:-1!==a.indexOf(t),halfChecked:-1!==o.indexOf(t),pos:String(h?h.pos:""),dragOver:l===t&&0===c,dragOverGapTop:l===t&&-1===c,dragOverGapBottom:l===t&&1===c}}function g(t){var e=t.data,i=t.expanded,r=t.selected,s=t.checked,a=t.loaded,l=t.loading,c=t.halfChecked,h=t.dragOver,u=t.dragOverGapTop,d=t.dragOverGapBottom,f=t.pos,p=t.active,g=Object(n.a)(Object(n.a)({},e),{},{expanded:i,selected:r,checked:s,loaded:a,loading:l,halfChecked:c,dragOver:h,dragOverGapTop:u,dragOverGapBottom:d,pos:f,active:p});return"props"in g||Object.defineProperty(g,"props",{get:function(){return Object(o.a)(!1,"Second param return from event is node data instead of TreeNode instance. Please read value directly instead of reading from `props`."),t}}),g}},"8Jsi":
|
|
|
/*!**************************************************************!*\
|
|
|
!*** ./node_modules/rc-tree-select/es/index.js + 12 modules ***!
|
|
|
\**************************************************************/
|
|
|
/*! exports provided: TreeNode, SHOW_ALL, SHOW_CHILD, SHOW_PARENT, default */
|
|
|
/*! exports used: SHOW_ALL, SHOW_CHILD, SHOW_PARENT, TreeNode, 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/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/toConsumableArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/typeof.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-select/es/generate.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-select/es/interface/generator.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-select/es/utils/valueUtil.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/utils/conductUtil.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/utils/treeUtil.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/hooks/useMergedState.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) */function(t,e,i){"use strict";i.d(e,"d",(function(){return D})),i.d(e,"a",(function(){return H})),i.d(e,"b",(function(){return z})),i.d(e,"c",(function(){return V}));var r=i("1OyB"),n=i("vuIU"),s=i("Ji7U"),a=i("LK+K"),o=i("KQm4"),l=i("U8pU"),c=i("ODXe"),h=i("VTBJ"),u=i("q1tI"),d=i("qNPg"),f=i("2Qr1"),p=i("815F"),g=i("NvD2"),v=i("wPlo"),m=i("6cGi"),y=i("Kwbf"),b=i("4IlW"),S=i("YrtM"),E=i("fAei"),C=u.createContext(null);function k(t,e){if(!t)return!0;var i=t.data,r=i.disabled,n=i.disableCheckbox;switch(e){case"select":return r;case"checkbox":return r||n}return!1}function T(t,e){return[u.useCallback((function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"select",r=arguments.length>2?arguments[2]:void 0,n=t.get(e);return!r&&k(n,i)?null:n}),[t]),u.useCallback((function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"select",r=arguments.length>2?arguments[2]:void 0,n=e.get(t);return!r&&k(n,i)?null:n}),[e])]}function w(t){return u.useMemo((function(){var e=new Map,i=new Map;return t.forEach((function(t){e.set(t.key,t),i.set(t.data.value,t)})),[e,i]}),[t])}var x={width:0,height:0,display:"flex",overflow:"hidden",opacity:0,border:0,padding:0,margin:0},A=function(t,e){var i=t.prefixCls,r=t.height,n=t.itemHeight,s=t.virtual,a=t.options,l=t.flattenOptions,h=t.multiple,d=t.searchValue,f=t.onSelect,p=t.onToggleOpen,g=t.open,v=t.notFoundContent,m=t.onMouseEnter,y=u.useContext(C),k=y.checkable,A=y.checkedKeys,L=y.halfCheckedKeys,R=y.treeExpandedKeys,D=y.treeDefaultExpandAll,_=y.treeDefaultExpandedKeys,O=y.onTreeExpand,I=y.treeIcon,P=y.showTreeIcon,M=y.switcherIcon,N=y.treeLine,B=y.treeNodeFilterProp,F=y.loadData,j=y.treeLoadedKeys,U=y.treeMotion,G=y.onTreeLoad,H=u.useRef(),V=Object(S.a)((function(){return a}),[g,a],(function(t,e){return e[0]&&t[1]!==e[1]})),z=w(l),K=Object(c.a)(z,2),W=T(K[0],K[1]),Y=Object(c.a)(W,2),q=Y[0],X=Y[1],$=u.useMemo((function(){return A.map((function(t){var e=X(t);return e?e.key:null}))}),[A]),Z=u.useMemo((function(){return k?{checked:$,halfChecked:L}:null}),[$,L,k]);u.useEffect((function(){var t;g&&!h&&$.length&&(null===(t=H.current)||void 0===t||t.scrollTo({key:$[0]}))}),[g]);var Q=String(d).toLowerCase(),J=u.useState(_),tt=Object(c.a)(J,2),et=tt[0],it=tt[1],rt=u.useState(null),nt=Object(c.a)(rt,2),st=nt[0],at=nt[1],ot=u.useMemo((function(){return R?Object(o.a)(R):d?st:et}),[et,st,Q,R]);u.useEffect((function(){d&&at(l.map((function(t){return t.key})))}),[d]);var lt=function(t){t.preventDefault()},ct=function(t,e){var i=e.node.key,r=q(i,k?"checkbox":"select");null!==r&&f(r.data.value,{selected:!A.includes(r.data.value)}),h||p(!1)},ht=u.useState(null),ut=Object(c.a)(ht,2),dt=ut[0],ft=ut[1],pt=q(dt);if(u.useImperativeHandle(e,(function(){return{onKeyDown:function(t){var e;switch(t.which){case b.a.UP:case b.a.DOWN:case b.a.LEFT:case b.a.RIGHT:null===(e=H.current)||void 0===e||e.onKeyDown(t);break;case b.a.ENTER:null!==pt&&ct(0,{node:{key:dt},selected:!A.includes(pt.data.value)});break;case b.a.ESC:p(!1)}},onKeyUp:function(){}}})),0===V.length)return u.createElement("div",{role:"listbox",className:"".concat(i,"-empty"),onMouseDown:lt},v);var gt={};return j&&(gt.loadedKeys=j),ot&&(gt.expandedKeys=ot),u.createElement("div",{onMouseDown:lt,onMouseEnter:m},pt&&g&&u.createElement("span",{style:x,"aria-live":"assertive"},pt.data.value),u.createElement(E.b,Object.assign({ref:H,focusable:!1,prefixCls:"".concat(i,"-tree"),treeData:V,height:r,itemHeight:n,virtual:s,multiple:h,icon:I,showIcon:P,switcherIcon:M,showLine:N,loadData:d?null:F,motion:U,checkable:k,checkStrictly:!0,checkedKeys:Z,selectedKeys:k?[]:$,defaultExpandAll:D},gt,{onActiveChange:ft,onSelect:ct,onCheck:ct,onExpand:function(t){it(t),at(t),O&&O(t)},onLoad:G,filterTreeNode:function(t){return!!Q&&String(t[B]).toLowerCase().includes(Q)}})))},L=u.forwardRef(A);L.displayName="OptionList";var R=L,D=function(){return null},_=i("Ff2n"),O=i("Zm9Q");function I(t){if(!t)return t;var e=Object(h.a)({},t);return"props"in e||Object.defineProperty(e,"props",{get:function(){return Object(y.a)(!1,"New `rc-tree-select` not support return node instance as argument anymore. Please consider to remove `props` access."),e}}),e}function P(t){return Array.isArray(t)?t:void 0!==t?[t]:[]}function M(t,e){var i=new Map;return e.forEach((function(t){var e=t.data;i.set(e.value,e)})),t.map((function(t){return I(i.get(t))}))}function N(t){return t.disabled||t.disableCheckbox||!1===t.checkable}function B(t){for(var e=0,i=t.parent;i;)i=i.parent,e+=1;return e}function F(t){return Object(p.d)(function t(e){return(e||[]).map((function(e){var i=e.value,r=e.key,n=e.children,s=Object(h.a)(Object(h.a)({},e),{},{key:"key"in e?r:i});return n&&(s.children=t(n)),s}))}(t),!0).map((function(t){return{key:t.data.key,data:t.data,level:B(t)}}))}function j(t,e,i,r){var n=new Map;return P(e).forEach((function(t){t&&"object"===Object(l.a)(t)&&"value"in t&&n.set(t.value,t)})),t.map((function(t){var e={value:t},s=i(t,"select",!0),a=s?r(s.data):t;if(n.has(t)){var o=n.get(t);e.label="label"in o?o.label:a,"halfChecked"in o&&(e.halfChecked=o.halfChecked)}else e.label=a;return e}))}function U(t,e){new Set;return function t(i){return(i||[]).map((function(i){var r=i.key,n=i.value,s=i.children,a=Object(_.a)(i,["key","value","children"]),o="value"in i?n:r,l=Object(h.a)(Object(h.a)({},a),{},{key:null!=r?r:o,value:o,title:e(i)});return"children"in i&&(l.children=t(s)),l}))}(t)}function G(t,e,i){var r=i.getLabelProp,n=i.simpleMode,s=u.useRef({});return t?(s.current.formatTreeData=s.current.treeData===t?s.current.formatTreeData:U(n?function(t,e){var i=e.id,r=e.pId,n=e.rootPId,s={},a=[];return t.map((function(t){var e=Object(h.a)({},t),r=e[i];return s[r]=e,e.key=e.key||r,e})).forEach((function(t){var e=t[r],i=s[e];i&&(i.children=i.children||[],i.children.push(t)),(e===n||!i&&null===n)&&a.push(t)})),a}(t,Object(h.a)({id:"id",pId:"pId",rootPId:null},!0!==n?n:{})):t,r),s.current.treeData=t):s.current.formatTreeData=s.current.children===e?s.current.formatTreeData:U(function t(e){return Object(O.a)(e).map((function(e){if(!u.isValidElement(e)||!e.type)return null;var i=e.key,r=e.props,n=r.children,s=r.value,a=Object(_.a)(r,["children","value"]),o=Object(h.a)({key:i,value:s},a),l=t(n);return l.length&&(o.children=l),o})).filter((function(t){return t}))}(e),r),s.current.formatTreeData}var H="SHOW_ALL",V="SHOW_PARENT",z="SHOW_CHILD";function K(t,e,i){var r=new Set(t);return e===z?t.filter((function(t){var e=i[t];return!(e&&e.children&&e.children.every((function(t){var e=t.node;return N(e)||r.has(e.key)})))})):e===V?t.filter((function(t){var e=i[t],n=e?e.parent:null;return!(n&&!N(n.node)&&r.has(n.node.key))})):t}var W=["expandedKeys","treeData","treeCheckable","showCheckedStrategy","searchPlaceholder","treeLine","treeIcon","showTreeIcon","switcherIcon","treeNodeFilterProp","filterTreeNode","dropdownPopupAlign","treeDefaultExpandAll","treeCheckStrictly","treeExpandedKeys","treeLoadedKeys","treeMotion","onTreeExpand","onTreeLoad","loadData","treeDataSimpleMode","treeNodeLabelProp","treeDefaultExpandedKeys"],Y=Object(d.a)({prefixCls:"rc-tree-select",components:{optionList:R},convertChildrenToData:function(){return null},flattenOptions:F,getLabeledValue:f.e,filterOptions:function(t,e,i){var r,n=i.optionFilterProp,s=i.filterOption;return!1===s?e:(r="function"==typeof s?s:function(t){return function(e,i){var r=i[t];return String(r).toLowerCase().includes(String(e).toLowerCase())}}(n),function e(i){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return i.map((function(i){var s=i.children,a=n||r(t,I(i)),o=e(s||[],a);return a||o.length?Object(h.a)(Object(h.a)({},i),{},{children:o}):null})).filter((function(t){return t}))}(e))},isValueDisabled:function(t,e){var i=M([t],e)[0];return!!i&&i.disabled},findValueOption:M,omitDOMProps:function(t){var e=Object(h.a)({},t);return W.forEach((function(t){delete e[t]})),e}});Y.displayName="Select";var q=u.forwardRef((function(t,e){var i=t.multiple,r=t.treeCheckable,n=t.treeCheckStrictly,s=t.showCheckedStrategy,a=void 0===s?"SHOW_CHILD":s,h=t.labelInValue,d=t.loadData,f=t.treeLoadedKeys,b=t.treeNodeFilterProp,S=void 0===b?"value":b,E=t.treeNodeLabelProp,k=t.treeDataSimpleMode,x=t.treeData,A=t.treeExpandedKeys,L=t.treeDefaultExpandedKeys,R=t.treeDefaultExpandAll,_=t.children,O=t.treeIcon,I=t.showTreeIcon,M=t.switcherIcon,N=t.treeLine,B=t.treeMotion,U=t.filterTreeNode,H=t.dropdownPopupAlign,V=t.onChange,z=t.onTreeExpand,W=t.onTreeLoad,q=t.onDropdownVisibleChange,X=t.onSelect,$=t.onDeselect,Z=r||n,Q=i||Z,J=r&&!n,tt=n||h,et=u.useRef(null);u.useImperativeHandle(e,(function(){return{focus:et.current.focus,blur:et.current.blur}}));var it=function(t){return x&&t.label||t.title},rt=function(t){return E?t[E]:it(t)},nt=G(x,_,{getLabelProp:it,simpleMode:k}),st=w(Object(u.useMemo)((function(){return F(nt)}),[nt])),at=Object(c.a)(st,2),ot=T(at[0],at[1]),lt=Object(c.a)(ot,2),ct=lt[0],ht=lt[1],ut=Object(u.useMemo)((function(){return J?Object(p.a)(nt):{keyEntities:null}}),[nt,r,n]).keyEntities,dt=Object(m.a)(t.defaultValue,{value:t.value}),ft=Object(c.a)(dt,2),pt=ft[0],gt=ft[1],vt=function(t){var e=[],i=[];return t.forEach((function(t){ht(t)?i.push(t):e.push(t)})),{missingRawValues:e,existRawValues:i}},mt=Object(u.useMemo)((function(){var t=[],e=[];if(P(pt).forEach((function(i){if(i&&"object"===Object(l.a)(i)&&"value"in i)if(i.halfChecked&&n){var r=ht(i.value);t.push(r?r.key:i.value)}else e.push(i.value);else e.push(i)})),J){var i=vt(e),r=i.missingRawValues,s=i.existRawValues.map((function(t){return ht(t).key})),a=Object(g.a)(s,!0,ut),c=a.checkedKeys,h=a.halfCheckedKeys;return[[].concat(Object(o.a)(r),Object(o.a)(c.map((function(t){return ct(t).data.value})))),h]}return[e,t]}),[pt,Q,tt,r,n]),yt=Object(c.a)(mt,2),bt=yt[0],St=yt[1],Et=function(t,e){var i=e.value,r=e.getEntityByValue,n=e.getEntityByKey,s=e.treeConduction,a=e.showCheckedStrategy,o=e.conductKeyEntities,l=e.getLabelProp;return u.useMemo((function(){var e=t;s&&(e=K(t.map((function(t){var e=r(t);return e?e.key:t})),a,o).map((function(t){var e=n(t);return e?e.data.value:t})));return j(e,i,r,l)}),[t,i,s,a,r])}(bt,{treeConduction:J,value:pt,showCheckedStrategy:a,conductKeyEntities:ut,getEntityByValue:ht,getEntityByKey:ct,getLabelProp:rt}),Ct=function(t,e,i){if(gt(Q?t:t[0]),V){var r=t;if(J&&"SHOW_ALL"!==a){var s=K(t.map((function(t){var e=ht(t);return e?e.key:t})),a,ut);r=s.map((function(t){var e=ct(t);return e?e.data.value:t}))}var l=e||{triggerValue:void 0,selected:void 0},c=l.triggerValue,h=l.selected,d=tt?j(r,pt,ht,rt):r;if(n){var f=St.map((function(t){var e=ct(t);return e?e.data.value:t})).filter((function(t){return!r.includes(t)}));d=[].concat(Object(o.a)(d),Object(o.a)(j(f,pt,ht,rt)))}var p={preValue:Et,triggerValue:c},g=!0;(n||"selection"===i&&!h)&&(g=!1),function(t,e,i,r,n){var s=null,a=null;function o(){a||(a=[],function t(r){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0",o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return r.map((function(r,l){var c="".concat(n,"-").concat(l),h=i.includes(r.value),d=t(r.children||[],c,h),f=u.createElement(D,Object.assign({},r),d.map((function(t){return t.node})));if(e===r.value&&(s=f),h){var p={pos:c,node:f,children:d};return o||a.push(p),p}return null})).filter((function(t){return t}))}(r),a.sort((function(t,e){var r=t.node.props.value,n=e.node.props.value;return i.indexOf(r)-i.indexOf(n)})))}Object.defineProperty(t,"triggerNode",{get:function(){return Object(y.a)(!1,"`triggerNode` is deprecated. Please consider decoupling data with node."),o(),s}}),Object.defineProperty(t,"allCheckedNodes",{get:function(){return Object(y.a)(!1,"`allCheckedNodes` is deprecated. Please consider decoupling data with node."),o(),n?a:a.map((function(t){return t.node}))}})}(p,c,t,nt,g),Z?p.checked=h:p.selected=h,V(Q?d:d[0],tt?null:r.map((function(t){var e=ht(t);return e?rt(e.data):null})),p)}},kt=u.useCallback((function(t){if(q){var e={};Object.defineProperty(e,"documentClickClose",{get:function(){return Object(y.a)(!1,"Second param of `onDropdownVisibleChange` has been removed."),!1}}),q(t,e)}}),[q]);var Tt={optionLabelProp:null,optionFilterProp:S,dropdownAlign:H,internalProps:{mark:v.a,onClear:function(){Ct([],null,"clear")},skipTriggerChange:!0,skipTriggerSelect:!0,onRawSelect:function(t,e,i){var r=t;if(Q){var n=function(t,e){var i=new Set(t);return i.add(e),Array.from(i)}(bt,t);if(J){var s=vt(n),a=s.missingRawValues,l=s.existRawValues.map((function(t){return ht(t).key})),c=Object(g.a)(l,!0,ut).checkedKeys;n=[].concat(Object(o.a)(a),Object(o.a)(c.map((function(t){return ct(t).data.value}))))}Ct(n,{selected:!0,triggerValue:t},i)}else Ct([t],{selected:!0,triggerValue:t},i);X&&X(r,e)},onRawDeselect:function(t,e,i){var r=t,n=function(t,e){var i=new Set(t);return i.delete(e),Array.from(i)}(bt,t);if(J){var s=vt(n),a=s.missingRawValues,l=s.existRawValues.map((function(t){return ht(t).key})),c=Object(g.a)(l,{checked:!1,halfCheckedKeys:St},ut).checkedKeys;n=[].concat(Object(o.a)(a),Object(o.a)(c.map((function(t){return ct(t).data.value}))))}Ct(n,{selected:!1,triggerValue:t},i),$&&$(r,e)}}};return"filterTreeNode"in t&&(Tt.filterOption=U),u.createElement(C.Provider,{value:{checkable:Z,loadData:d,treeLoadedKeys:f,onTreeLoad:W,checkedKeys:bt,halfCheckedKeys:St,treeDefaultExpandAll:R,treeExpandedKeys:A,treeDefaultExpandedKeys:L,onTreeExpand:z,treeIcon:O,treeMotion:B,showTreeIcon:I,switcherIcon:M,treeLine:N,treeNodeFilterProp:S}},u.createElement(Y,Object.assign({ref:et,mode:Q?"multiple":null},t,Tt,{value:Et,labelInValue:!0,options:nt,onChange:null,onSelect:null,onDeselect:null,onDropdownVisibleChange:kt})))})),X=function(t){Object(s.a)(i,t);var e=Object(a.a)(i);function i(){var t;return Object(r.a)(this,i),(t=e.apply(this,arguments)).selectRef=u.createRef(),t.focus=function(){t.selectRef.current.focus()},t.blur=function(){t.selectRef.current.blur()},t}return Object(n.a)(i,[{key:"render",value:function(){return u.createElement(q,Object.assign({ref:this.selectRef},this.props))}}]),i}(u.Component);X.TreeNode=D,X.SHOW_ALL=H,X.SHOW_PARENT=V,X.SHOW_CHILD=z;var $=X;e.e=$},"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,i){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,i){"use strict";i("DYRE");var r=i("zeV3"),n=(i("+L6B"),i("2/Rp")),s=i("k1fw"),a=i("9og8"),o=i("tJVT"),l=i("WmNS"),c=i.n(l),h=i("q1tI"),u=i.n(h),d=(i("vg9a"),i("DlQD")),f=i.n(d),p=i("rUJ1");var g=[],v=["<ul>"],m=new f.a.Renderer,y=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function b(){g.length=0,v=["<ul>"]}var S={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function E(){return function t(e,i,r,n){if(i>=e.length||e[i].level<=r)return i;var s=e[i];n.push("<li><a href='#"+s.anchor+"'>"+s.text+"</a>");var a=[];return i=t(e,++i,s.level,a),a.length>0&&(n.push("<ul>"),a.forEach((function(t){n.push(t)})),n.push("</ul>")),n.push("</li>"),i=t(e,i,r,n)}(g,0,0,v),v.push("</ul>"),v.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 i=e[0],r=function(t,e){var i=t.match(/^(\s+)(?:```)/);if(null===i)return e;var r=i[1];return e.split("\n").map((function(t){var e=t.match(/^\s+/);return null===e?t:Object(o.a)(e,1)[0].length>=r.length?t.slice(r.length):t})).join("\n")}(i,e[3]||""),n=e[2]?e[2].trim():e[2];if(["latex","katex","math"].indexOf(n)>=0){var s=w(),a=r;r=s,x[s]={type:"block",expression:a}}return{type:"code",raw:i,lang:n,text:r}}}},k=/(?:\${2})([^\n`]+?)(?:\${2})/gi,T=0,w=function(){return"__special_katext_id_".concat(T++,"__")},x={};function A(){T=0,x={}}function L(t){return t=t.replace(k,(function(t,e){var i=w();return x[i]={type:"inline",expression:e},i}))}var R=m.listitem;m.listitem=function(t){return R(L(t))};var D=m.paragraph;m.paragraph=function(t){return D(L(t))};var _=m.tablecell;m.tablecell=function(t,e){return _(L(t),e)},m.code=function(t,e,i){var r=(e||"").match(/\S*/)[0];return r?["latex","katex","math"].indexOf(r)>=0?"<p class='editormd-tex'>".concat(t,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(e,'">').concat(i?t:Object(p.escape)(t,!0),"</code></pre>\n"):'<pre class="prettyprint linenums"><code>'+(i?t:Object(p.escape)(t,!0))+"</code></pre>"},m.heading=function(t,e,i){var r=this.options.headerPrefix+i.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return g.push({anchor:r,level:e,text:t}),"<h"+e+' id="'+r+'">'+t+"</h"+e+">"},f.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),f.a.use({tokenizer:C,renderer:m});var O=f.a,I=(i("SJMd"),i("ulZh")),P=i.n(I),M=i("m3rI"),N=i("Oy/b"),B=i("p5ED"),F=i("ErOA"),j=function(t,e){return(j=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,e)};function U(t,e){function i(){this.constructor=t}j(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}function G(t,e,i,r){return new(i||(i=Promise))((function(n,s){function a(t){try{l(r.next(t))}catch(t){s(t)}}function o(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}l((r=r.apply(t,e||[])).next())}))}function H(t,e){var i,r,n,s,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,r&&(n=2&s[0]?r.return:s[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,s[1])).done)return n;switch(r=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((n=(n=a.trys).length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){a.label=s[1];break}if(6===s[0]&&a.label<n[1]){a.label=n[1],n=s;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(s);break}n[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{i=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}}function V(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var r=Array(t),n=0;for(e=0;e<i;e++)for(var s=arguments[e],a=0,o=s.length;a<o;a++,n++)r[n]=s[a];return r}var z=function(){function t(){}return t.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},t.setAttributes=function(t,e){for(var i=0,r=e;i<r.length;i++){var n=r[i],s=n[0],a=n[1];t.setAttribute(s,a)}},t.createRect=function(e,i,r){var n=document.createElementNS("http://www.w3.org/2000/svg","rect");return n.setAttribute("width",e.toString()),n.setAttribute("height",i.toString()),r&&t.setAttributes(n,r),n},t.createLine=function(e,i,r,n,s){var a=document.createElementNS("http://www.w3.org/2000/svg","line");return a.setAttribute("x1",e.toString()),a.setAttribute("y1",i.toString()),a.setAttribute("x2",r.toString()),a.setAttribute("y2",n.toString()),s&&t.setAttributes(a,s),a},t.createPolygon=function(e,i){var r=document.createElementNS("http://www.w3.org/2000/svg","polygon");return r.setAttribute("points",e),i&&t.setAttributes(r,i),r},t.createCircle=function(e,i){var r=document.createElementNS("http://www.w3.org/2000/svg","circle");return r.setAttribute("cx",(e/2).toString()),r.setAttribute("cy",(e/2).toString()),r.setAttribute("r",e.toString()),i&&t.setAttributes(r,i),r},t.createEllipse=function(e,i,r){var n=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return n.setAttribute("cx",(e/2).toString()),n.setAttribute("cy",(i/2).toString()),n.setAttribute("rx",(e/2).toString()),n.setAttribute("ry",(i/2).toString()),r&&t.setAttributes(n,r),n},t.createGroup=function(e){var i=document.createElementNS("http://www.w3.org/2000/svg","g");return e&&t.setAttributes(i,e),i},t.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},t.createMarker=function(e,i,r,n,s,a,o){var l=document.createElementNS("http://www.w3.org/2000/svg","marker");return t.setAttributes(l,[["id",e],["orient",i],["markerWidth",r.toString()],["markerHeight",n.toString()],["refX",s.toString()],["refY",a.toString()]]),l.appendChild(o),l},t.createText=function(e){var i=document.createElementNS("http://www.w3.org/2000/svg","text");return i.setAttribute("x","0"),i.setAttribute("y","0"),e&&t.setAttributes(i,e),i},t.createTSpan=function(e,i){var r=document.createElementNS("http://www.w3.org/2000/svg","tspan");return r.textContent=e,i&&t.setAttributes(r,i),r},t.createImage=function(e){var i=document.createElementNS("http://www.w3.org/2000/svg","image");return e&&t.setAttributes(i,e),i},t.createPoint=function(t,e){var i=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return i.x=t,i.y=e,i},t.createPath=function(e,i){var r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d",e),i&&t.setAttributes(r,i),r},t}(),K=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}(),W=function(){function t(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return t.prototype.rasterize=function(t,e,i){var r=this;return new Promise((function(n){var s=void 0!==i?i:document.createElement("canvas");null===t&&(r.markersOnly=!0,r.naturalSize=!1);var a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("xmlns","http://www.w3.org/2000/svg"),a.setAttribute("width",e.width.baseVal.valueAsString),a.setAttribute("height",e.height.baseVal.valueAsString),a.setAttribute("viewBox","0 0 "+e.viewBox.baseVal.width.toString()+" "+e.viewBox.baseVal.height.toString()),a.innerHTML=e.innerHTML,!0===r.naturalSize?(a.width.baseVal.value=t.naturalWidth,a.height.baseVal.value=t.naturalHeight):void 0!==r.width&&void 0!==r.height&&(a.width.baseVal.value=r.width,a.height.baseVal.value=r.height),s.width=a.width.baseVal.value,s.height=a.height.baseVal.value;var o=a.outerHTML,l=s.getContext("2d");!0!==r.markersOnly&&l.drawImage(t,0,0,s.width,s.height);var c=window.URL,h=new Image(s.width,s.height);h.setAttribute("crossOrigin","anonymous");var u=new Blob([o],{type:"image/svg+xml"}),d=c.createObjectURL(u);h.onload=function(){l.drawImage(h,0,0),c.revokeObjectURL(d);var t=s.toDataURL(r.imageType,r.imageQuality);n(t)},h.src=d}))},t}(),Y=function(){},q=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,i,r,n){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=t,this.displayMode=e,this.markerItems=i,this.uiStyleSettings=r,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 i=document.createElement("div");i.className=this.toolbarBlockStyleClass.name,i.style.whiteSpace="nowrap",this.uiContainer.appendChild(i),this.addActionButton(i,'<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(i,'<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(i,'<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(i,'<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(i,'<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(i,'<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(i,'<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(i,'<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 i=document.createElement("div");i.className=""+e.toolbarButtonStyleClass.name,i.setAttribute("data-type-name",t.typeName),i.innerHTML=t.icon,i.addEventListener("click",(function(){e.markerToolbarButtonClicked(i,t)})),e.buttons.push(i),e.markerButtons.push(i)})),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 r=document.createElement("div");r.className=this.toolbarBlockStyleClass.name,r.style.whiteSpace="nowrap",r.style.display=!1!==this.uiStyleSettings.resultButtonBlockVisible?"":"none",this.uiContainer.appendChild(r),this.addActionButton(r,'<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(r,'<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,i){var r=this,n=document.createElement("div");switch(n.className=""+this.toolbarButtonStyleClass.name,n.innerHTML=e,n.setAttribute("data-action",i),n.addEventListener("click",(function(){r.actionToolbarButtonClicked(n,i)})),i){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,i,r){this.panels=[],this.panelButtons=[],this.markerjsContainer=t,this.displayMode=e,this.uiStyleSettings=i,this.styles=r,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,i,r=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!==(i=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)&&void 0!==i?i:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach((function(t){var e;t.uiStyleSettings=r.uiStyleSettings;var i=document.createElement("div");i.className=r.toolboxButtonStyleClass.name+" "+(null!==(e=r.uiStyleSettings.toolboxButtonStyleColorsClassName)&&void 0!==e?e:r.toolboxButtonStyleColorsClass.name),i.innerHTML=t.icon,i.title=t.title,i.addEventListener("click",(function(){r.panelButtonClick(t)})),r.panelButtons.push(i),r.buttonRow.appendChild(i)})),"inline"===this.displayMode?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},t.prototype.panelButtonClick=function(t){var e=this,i=-1;if(t!==this.activePanel){i=this.panels.indexOf(t),this.panelRow.innerHTML="";var r=t.getUi();r.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(r),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,r){var n,s;t.className=e.toolboxButtonStyleClass.name+" "+(r===i?""+(null!==(n=e.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)&&void 0!==n?n:e.toolboxActiveButtonStyleColorsClass.name):""+(null!==(s=e.uiStyleSettings.toolboxButtonStyleColorsClassName)&&void 0!==s?s:e.toolboxButtonStyleColorsClass.name))}))},t}(),J=function(t,e){this.title=t,this.icon=e},tt=function(t){function e(e,i,r,n){var s=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 s.colors=[],s.addTransparent=!1,s.colorBoxes=[],s.colors=i,s.currentColor=r,s.setCurrentColor=s.setCurrentColor.bind(s),s.getColorBox=s.getColorBox.bind(s),s}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(i){var r=t.getColorBox(i);e.appendChild(r),t.colorBoxes.push(r)})),e},e.prototype.getColorBox=function(t){var e=this,i=this.uiStyleSettings.toolbarHeight/4,r=this.uiStyleSettings.toolbarHeight-i,n=document.createElement("div");n.style.display="inline-block",n.style.boxSizing="content-box",n.style.width=r-2+"px",n.style.height=r-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=(r+2)/2+"px",n.style.borderColor=t===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",n.addEventListener("click",(function(){e.setCurrentColor(t,n)}));var s=document.createElement("div");return s.style.display="inline-block",s.style.width=r-2+"px",s.style.height=r-2+"px",s.style.backgroundColor=t,s.style.borderRadius=r/2+"px","transparent"===t&&(s.style.fill=this.uiStyleSettings.toolboxAccentColor,s.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(s),n},e.prototype.setCurrentColor=function(t,e){var i=this;this.currentColor=t,this.colorBoxes.forEach((function(t){t.style.borderColor=t===e?i.uiStyleSettings.toolboxAccentColor:"transparent"})),this.onColorChanged&&this.onColorChanged(t)},e}(J),et=function(){function t(t,e,i){this._state="new",this._isSelected=!1,this._container=t,this._overlayContainer=e,this.globalSettings=i,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}(),it=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}(),rt=function(){function t(){this.GRIP_SIZE=10,this.visual=z.createGroup(),this.visual.appendChild(z.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(z.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}(),st=function(t){function e(e,i,r){var n=t.call(this,e,i,r)||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(z.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=z.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,i){t.prototype.pointerDown.call(this,e,i),"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 r=this.unrotatePoint(e);if(this.manipulationStartX=r.x,this.manipulationStartY=r.y,this.offsetX=r.x-this.left,this.offsetY=r.y-this.top,"new"!==this.state)if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(i),void 0!==this.activeGrip)this._state="resize";else if(void 0!==this.rotatorGrip&&this.rotatorGrip.ownsTarget(i)){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 s=this.container.transform.baseVal.getItem(0);s.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(s,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},e.prototype.pointerUp=function(e){var i=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"===i&&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,i=this.manipulationStartWidth,r=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,i=this.manipulationStartWidth+this.manipulationStartLeft-e;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:i=this.manipulationStartWidth+t.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:r=this.manipulationStartTop+t.y-this.manipulationStartY,n=this.manipulationStartHeight+this.manipulationStartTop-r;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:n=this.manipulationStartHeight+t.y-this.manipulationStartY}i>=0?(this.left=e,this.width=i):(this.left=e+i,this.width=-i),n>=0?(this.top=r,this.height=n):(this.top=r+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(),i=z.createPoint(t.x,t.y);return{x:(i=i.matrixTransform(e)).x,y:i.y}},e.prototype.unrotatePoint=function(t){if(0===this.rotationAngle)return t;var e=this.container.getCTM();e=e.inverse();var i=z.createPoint(t.x,t.y);return{x:(i=i.matrixTransform(e)).x,y:i.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=z.createGroup();var t=z.createTransform();t.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(t),this.container.appendChild(this.controlBox),this.controlRect=z.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=z.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 it,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 rt;return t.visual.transform.baseVal.appendItem(z.createTransform()),this.controlBox.appendChild(t.visual),t},e.prototype.positionGrips=function(){var t=this.controlGrips.topLeft.GRIP_SIZE,e=-t/2,i=e,r=(this.width+this.CB_DISTANCE)/2-t/2,n=(this.height+this.CB_DISTANCE)/2-t/2,s=this.height+this.CB_DISTANCE-t/2,a=this.width+this.CB_DISTANCE-t/2;this.positionGrip(this.controlGrips.topLeft.visual,e,i),this.positionGrip(this.controlGrips.topCenter.visual,r,i),this.positionGrip(this.controlGrips.topRight.visual,a,i),this.positionGrip(this.controlGrips.centerLeft.visual,e,n),this.positionGrip(this.controlGrips.centerRight.visual,a,n),this.positionGrip(this.controlGrips.bottomLeft.visual,e,s),this.positionGrip(this.controlGrips.bottomCenter.visual,r,s),this.positionGrip(this.controlGrips.bottomRight.visual,a,s),void 0!==this.rotatorGrip&&this.positionGrip(this.rotatorGrip.visual,r,i-3*this.CB_DISTANCE)},e.prototype.positionGrip=function(t,e,i){var r=t.transform.baseVal.getItem(0);r.setTranslate(e,i),t.transform.baseVal.replaceItem(r,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 i=e;this.left=i.left,this.top=i.top,this.width=i.width,this.height=i.height,this.rotationAngle=i.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(nt.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,i.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(nt.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,i.containerTransformMatrix))},e.prototype.scale=function(e,i){t.prototype.scale.call(this,e,i);var r=this.rotatePoint({x:this.left,y:this.top}),n=this.unrotatePoint({x:r.x*e,y:r.y*i});this.left=n.x,this.top=n.y,this.width=this.width*e,this.height=this.height*i,this.adjustControlBox()},e}(et),at=function(t){function e(e,i,r){var n=t.call(this,e,i,r)||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=z.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,i){t.prototype.pointerDown.call(this,e,i),"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),z.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&&z.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(t),this.stateChanged()},e.prototype.setFillColor=function(t){this.fillColor=t,this.visual&&z.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},e.prototype.setStrokeWidth=function(t){this.strokeWidth=t,this.visual&&z.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},e.prototype.setStrokeDasharray=function(t){this.strokeDasharray=t,this.visual&&z.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 i=e;this.fillColor=i.fillColor,this.strokeColor=i.strokeColor,this.strokeWidth=i.strokeWidth,this.strokeDasharray=i.strokeDasharray,this.opacity=i.opacity,this.createVisual(),t.prototype.restoreState.call(this,e),this.setSize()},e.prototype.scale=function(e,i){t.prototype.scale.call(this,e,i),this.setSize()},e.title="Rectangle marker",e}(st),ot=function(t){function e(e,i,r,n){var s=t.call(this,e,n||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return s.widths=[],s.widthBoxes=[],s.widths=i,s.currentWidth=r,s.setCurrentWidth=s.setCurrentWidth.bind(s),s}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(i){var r=document.createElement("div");r.style.display="flex",r.style.flexGrow="2",r.style.alignItems="center",r.style.justifyContent="space-between",r.style.padding="5px",r.style.borderWidth="2px",r.style.borderStyle="solid",r.style.borderColor=i===t.currentWidth?t.uiStyleSettings.toolboxAccentColor:"transparent",r.addEventListener("click",(function(){t.setCurrentWidth(i,r)})),e.appendChild(r);var n=document.createElement("div");n.innerText=i.toString(),n.style.marginRight="5px",r.appendChild(n);var s=document.createElement("div");s.style.minHeight="20px",s.style.flexGrow="2",s.style.display="flex",s.style.alignItems="center";var a=document.createElement("hr");a.style.minWidth="20px",a.style.border="0px",a.style.borderTop=i+"px solid "+t.uiStyleSettings.toolboxColor,a.style.flexGrow="2",s.appendChild(a),r.appendChild(s),t.widthBoxes.push(r)})),e},e.prototype.setCurrentWidth=function(t,e){var i=this;this.currentWidth=t,this.widthBoxes.forEach((function(t){t.style.borderColor=t===e?i.uiStyleSettings.toolboxAccentColor:"transparent"})),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},e}(J),lt=function(t){function e(e,i,r,n){var s=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 s.styles=[],s.styleBoxes=[],s.styles=i,s.currentStyle=r,s.setCurrentStyle=s.setCurrentStyle.bind(s),s}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(i){var r=document.createElement("div");r.style.display="flex",r.style.alignItems="center",r.style.justifyContent="space-between",r.style.padding="5px",r.style.borderWidth="2px",r.style.borderStyle="solid",r.style.overflow="hidden",r.style.maxWidth=100/t.styles.length-5+"%",r.style.borderColor=i===t.currentStyle?t.uiStyleSettings.toolboxAccentColor:"transparent",r.addEventListener("click",(function(){t.setCurrentStyle(i,r)})),e.appendChild(r);var n=document.createElement("div");n.style.minHeight="20px",n.style.flexGrow="2",n.style.overflow="hidden";var s='<svg width="100" height="20">\n <line x1="0" y1="10" x2="100" y2="10" stroke="'+t.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(""!==i?'stroke-dasharray="'+i+'"':"")+" />\n </svg>";n.innerHTML=s,r.appendChild(n),t.styleBoxes.push(r)})),e},e.prototype.setCurrentStyle=function(t,e){var i=this;this.currentStyle=t,this.styleBoxes.forEach((function(t){t.style.borderColor=t===e?i.uiStyleSettings.toolboxAccentColor:"transparent"})),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},e}(J),ct=function(t){function e(e,i,r){var n=t.call(this,e,i,r)||this;return n.strokeColor=r.defaultColor,n.strokeWidth=r.defaultStrokeWidth,n.strokeDasharray=r.defaultStrokeDasharray,n.strokePanel=new tt("Line color",r.defaultColorSet,r.defaultColor),n.strokePanel.onColorChanged=n.setStrokeColor,n.strokeWidthPanel=new ot("Line width",r.defaultStrokeWidths,r.defaultStrokeWidth),n.strokeWidthPanel.onWidthChanged=n.setStrokeWidth,n.strokeStylePanel=new lt("Line style",r.defaultStrokeDasharrays,r.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 i=t.prototype.getState.call(this);return i.typeName=e.typeName,i},e.typeName="FrameMarker",e.title="Frame marker",e.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',e}(at),ht=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},ut=function(t){function e(e,i,r){var n=t.call(this,e,i,r)||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,i){t.prototype.pointerDown.call(this,e,i),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(i)?this.activeGrip=this.grip1:this.grip2.ownsTarget(i)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},e.prototype.pointerUp=function(e){var i=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"===i&&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=z.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 rt;return t.visual.transform.baseVal.appendItem(z.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,i){var r=t.transform.baseVal.getItem(0);r.setTranslate(e,i),t.transform.baseVal.replaceItem(r,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 i=e;this.x1=i.x1,this.y1=i.y1,this.x2=i.x2,this.y2=i.y2},e.prototype.scale=function(e,i){t.prototype.scale.call(this,e,i),this.x1=this.x1*e,this.y1=this.y1*i,this.x2=this.x2*e,this.y2=this.y2*i,this.adjustVisual(),this.adjustControlBox()},e}(et),dt=function(t){function e(e,i,r){var n=t.call(this,e,i,r)||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=r.defaultColor,n.strokeWidth=r.defaultStrokeWidth,n.strokeDasharray=r.defaultStrokeDasharray,n.strokePanel=new tt("Line color",r.defaultColorSet,r.defaultColor),n.strokePanel.onColorChanged=n.setStrokeColor,n.strokeWidthPanel=new ot("Line width",r.defaultStrokeWidths,r.defaultStrokeWidth),n.strokeWidthPanel.onWidthChanged=n.setStrokeWidth,n.strokeStylePanel=new lt("Line style",r.defaultStrokeDasharrays,r.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=z.createGroup(),this.selectorLine=z.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=z.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,i){t.prototype.pointerDown.call(this,e,i),"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()),z.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),z.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),z.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 i=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},t.prototype.getState.call(this));return i.typeName=e.typeName,i},e.prototype.restoreState=function(e){t.prototype.restoreState.call(this,e);var i=e;this.strokeColor=i.strokeColor,this.strokeWidth=i.strokeWidth,this.strokeDasharray=i.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}(ut),ft=function(t){function e(e,i,r,n){var s=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 s.fonts=[],s.fontBoxes=[],s.fonts=i,s.currentFont=r,s.setCurrentFont=s.setCurrentFont.bind(s),s}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(i){var r=document.createElement("div");r.style.display="inline-block",r.style.alignItems="center",r.style.justifyContent="space-between",r.style.padding="5px",r.style.borderWidth="2px",r.style.borderStyle="solid",r.style.overflow="hidden",r.style.maxWidth=100/t.fonts.length-5+"%",r.style.borderColor=i===t.currentFont?t.uiStyleSettings.toolboxAccentColor:"transparent",r.addEventListener("click",(function(){t.setCurrentFont(i,r)})),e.appendChild(r);var n=document.createElement("div");n.style.display="flex",n.style.minHeight="20px",n.style.flexGrow="2",n.style.fontFamily=i,n.style.overflow="hidden";var s=document.createElement("div");s.style.whiteSpace="nowrap",s.style.overflow="hidden",s.style.textOverflow="ellipsis",s.innerHTML="The quick brown fox jumps over the lazy dog",n.appendChild(s),r.appendChild(n),t.fontBoxes.push(r)})),e},e.prototype.setCurrentFont=function(t,e){var i=this;this.currentFont=t,this.fontBoxes.forEach((function(t){t.style.borderColor=t===e?i.uiStyleSettings.toolboxAccentColor:"transparent"})),this.onFontChanged&&this.onFontChanged(this.currentFont)},e}(J),pt=function(t){function e(e,i,r){var n=t.call(this,e,i,r)||this;return n.color="transparent",n.padding=5,n.DEFAULT_TEXT="your text here",n.text=n.DEFAULT_TEXT,n.isMoved=!1,n.color=r.defaultColor,n.fontFamily=r.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",r.defaultColorSet,r.defaultColor),n.colorPanel.onColorChanged=n.setColor,n.fontFamilyPanel=new ft("Font",r.defaultFontFamilies,r.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 i=!1;return this.textElement.childNodes.forEach((function(t){t===e&&(i=!0)})),i},e.prototype.createVisual=function(){this.visual=z.createGroup(),this.bgRectangle=z.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=z.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(z.createTransform()),this.textElement.transform.baseVal.appendItem(z.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},e.prototype.pointerDown=function(e,i){t.prototype.pointerDown.call(this,e,i),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(z.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 i=(1*this.width-this.width*this.padding*2/100)/t.width,r=(1*this.height-this.height*this.padding*2/100)/t.height;e=Math.min(i,r)}return e},e.prototype.getTextPosition=function(t){var e=this.textElement.getBBox(),i=0,r=0;return e.width>0&&e.height>0&&(i=(this.width-e.width*t)/2,r=this.height/2-e.height*t/2),{x:i,y:r}},e.prototype.sizeText=function(){var t=this.textElement.getBBox(),e=this.getTextScale(),i=this.getTextPosition(e);i.y-=t.y*e,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+i.x+"px, "+i.y+"px) scale("+e+", "+e+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(i.x,i.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&&(z.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),z.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},e.prototype.pointerUp=function(e){var i=this.state;"creating"===i&&(this._suppressMarkerCreateEvent=!0),t.prototype.pointerUp.call(this,e),this.setSize(),("creating"===i||!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"),i=window.getSelection();if(!i.rangeCount)return!1;i.deleteFromDocument(),i.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}),i=this.textElement.getBBox(),r={x:i.width*t,y:i.height*t};e.x-=r.x/2,e.y-=r.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,i){t.prototype.dblClick.call(this,e,i),this.showTextEditor()},e.prototype.setColor=function(t){this.textElement&&z.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&&z.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 i=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},t.prototype.getState.call(this));return i.typeName=e.typeName,i},e.prototype.restoreState=function(e){var i=e;this.color=i.color,this.fontFamily=i.fontFamily,this.padding=i.padding,this.text=i.text,this.createVisual(),t.prototype.restoreState.call(this,e),this.setSize()},e.prototype.scale=function(e,i){t.prototype.scale.call(this,e,i),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}(st),gt=function(t){function e(e,i,r){var n=t.call(this,e,i,r)||this;return n.color="transparent",n.lineWidth=3,n.drawing=!1,n.pixelRatio=1,n.color=r.defaultColor,n.lineWidth=r.defaultStrokeWidth,n.pixelRatio=r.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",r.defaultColorSet,r.defaultColor),n.colorPanel.onColorChanged=n.setColor,n.lineWidthPanel=new ot("Line width",r.defaultStrokeWidths,r.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=z.createGroup(),this.drawingImage=z.createImage(),this.visual.appendChild(this.drawingImage);var t=z.createTransform();this.visual.transform.baseVal.appendItem(t),this.addMarkerVisualToContainer(this.visual)},e.prototype.pointerDown=function(e,i){"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,i)},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),z.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),z.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],i=e[0],r=e[1],n=e[2],s=e[3],a=!1,o=0;o<this.canvasElement.height;o++)for(var l=0;l<this.canvasElement.width;l++)t.data[o*this.canvasElement.width*4+4*l+3]>0&&(a=!0,o<r&&(r=o),l<i&&(i=l),o>s&&(s=o),l>n&&(n=l));if(a){this.left=i/this.pixelRatio,this.top=r/this.pixelRatio,this.width=(n-i)/this.pixelRatio,this.height=(s-r)/this.pixelRatio;var c=document.createElement("canvas");c.width=n-i,c.height=s-r,c.getContext("2d").putImageData(this.canvasContext.getImageData(i,r,n-i,s-r),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(){z.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),z.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 i=Object.assign({drawingImgUrl:this.drawingImgUrl},t.prototype.getState.call(this));return i.typeName=e.typeName,i},e.prototype.restoreState=function(e){this.createVisual(),t.prototype.restoreState.call(this,e),this.drawingImgUrl=e.drawingImgUrl,this.setDrawingImage()},e.prototype.scale=function(e,i){t.prototype.scale.call(this,e,i),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}(st),vt=function(t){function e(e,i,r){var n=t.call(this,e,r||'<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=i,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 i=function(i){var n="both";switch(i){case 0:n="both";break;case 1:n="start";break;case 2:n="end";break;case 3:n="none"}var s=document.createElement("div");if(s.style.display="flex",s.style.flexGrow="2",s.style.alignItems="center",s.style.justifyContent="space-between",s.style.padding="5px",s.style.borderWidth="2px",s.style.borderStyle="solid",s.style.borderColor=n===r.currentType?r.uiStyleSettings.toolboxAccentColor:"transparent",s.addEventListener("click",(function(){t.setCurrentType(n,s)})),e.appendChild(s),"both"===n||"start"===n){var a=document.createElement("div");a.style.display="flex",a.style.alignItems="center",a.style.minHeight="20px",a.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!==r.uiStyleSettings?r.uiStyleSettings.toolboxColor:"#eeeeee")+'" />\n </svg>',a.style.marginLeft="5px",s.appendChild(a)}var o=document.createElement("div");o.style.display="flex",o.style.alignItems="center",o.style.minHeight="20px",o.style.flexGrow="2";var l=document.createElement("hr");if(l.style.minWidth="20px",l.style.border="0px",l.style.borderTop="3px solid "+(void 0!==r.uiStyleSettings?r.uiStyleSettings.toolboxColor:"#eeeeee"),l.style.flexGrow="2",o.appendChild(l),s.appendChild(o),"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!==r.uiStyleSettings?r.uiStyleSettings.toolboxColor:"#eeeeee")+'" />\n </svg>',c.style.marginRight="5px",s.appendChild(c)}r.typeBoxes.push(s)},r=this,n=0;n<4;n++)i(n);return e},e.prototype.setCurrentType=function(t,e){var i=this;this.currentType=t,this.typeBoxes.forEach((function(t){t.style.borderColor=t===e?void 0!==i.uiStyleSettings?i.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"})),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},e}(J),mt=function(t){function e(e,i,r){var n=t.call(this,e,i,r)||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 vt("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 i=this.arrowBaseWidth+2*this.strokeWidth,r=this.arrowBaseHeight+2*this.strokeWidth;return t-i/2+","+(e+r/2)+" "+t+","+(e-r/2)+" "+(t+i/2)+","+(e+r/2)},e.prototype.createTips=function(){this.arrow1=z.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(z.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=z.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(z.createTransform()),this.visual.appendChild(this.arrow2)},e.prototype.pointerDown=function(e,i){t.prototype.pointerDown.call(this,e,i),"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",z.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),z.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),i=this.arrow1.transform.baseVal.getItem(0);i.setRotate(e,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(i,0);var r=this.arrow2.transform.baseVal.getItem(0);r.setRotate(e+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(r,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 i=Object.assign({arrowType:this.arrowType},t.prototype.getState.call(this));return i.typeName=e.typeName,i},e.prototype.restoreState=function(e){t.prototype.restoreState.call(this,e);var i=e;this.arrowType=i.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,i,r){var n=t.call(this,e,i,r)||this;return n.fillColor=r.defaultFillColor,n.strokeWidth=0,n.fillPanel=new tt("Color",r.defaultColorSet,r.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 i=t.prototype.getState.call(this);return i.typeName=e.typeName,i},e.typeName="CoverMarker",e.title="Cover marker",e.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',e}(at),bt=function(t){function e(e,i,r,n){var s=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 s.opacities=[],s.opacityBoxes=[],s.opacities=i,s.currentOpacity=r,s.setCurrentOpacity=s.setCurrentOpacity.bind(s),s}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(i){var r=document.createElement("div");r.style.display="flex",r.style.alignItems="center",r.style.justifyContent="center",r.style.padding="5px",r.style.borderWidth="2px",r.style.borderStyle="solid",r.style.borderColor=i===t.currentOpacity?t.uiStyleSettings.toolboxAccentColor:"transparent",r.addEventListener("click",(function(){t.setCurrentOpacity(i,r)})),e.appendChild(r);var n=document.createElement("div");n.innerText=100*i+"%",r.appendChild(n),t.opacityBoxes.push(r)})),e},e.prototype.setCurrentOpacity=function(t,e){var i=this;this.currentOpacity=t,this.opacityBoxes.forEach((function(t){t.style.borderColor=t===e?i.uiStyleSettings.toolboxAccentColor:"transparent"})),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},e}(J),St=function(t){function e(e,i,r){var n=t.call(this,e,i,r)||this;return n.setOpacity=n.setOpacity.bind(n),n.fillColor=r.defaultHighlightColor,n.strokeWidth=0,n.opacity=r.defaultHighlightOpacity,n.fillPanel=new tt("Color",r.defaultColorSet,n.fillColor),n.fillPanel.onColorChanged=n.setFillColor,n.opacityPanel=new bt("Opacity",r.defaultOpacitySteps,n.opacity),n.opacityPanel.onOpacityChanged=n.setOpacity,n}return U(e,t),e.prototype.setOpacity=function(t){this.opacity=t,this.visual&&z.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 i=t.prototype.getState.call(this);return i.typeName=e.typeName,i},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),Et='<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,i,r){var n=t.call(this,e,i,r)||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=r.defaultStrokeColor,n.bgColor=r.defaultFillColor,n.fontFamily=r.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",r.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",r.defaultColorSet,n.bgColor,Et),n.bgColorPanel.onColorChanged=n.setBgColor,n.fontFamilyPanel=new ft("Font",r.defaultFontFamilies,r.defaultFontFamily),n.fontFamilyPanel.onFontChanged=n.setFont,n.tipGrip=new rt,n.tipGrip.visual.transform.baseVal.appendItem(z.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(){z.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=z.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},e.prototype.pointerDown=function(e,i){"new"===this.state&&t.prototype.pointerDown.call(this,e,i),"creating"===this.state?this.createTip():this.tipGrip.ownsTarget(i)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):t.prototype.pointerDown.call(this,e,i)},e.prototype.pointerUp=function(e){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,t.prototype.pointerUp.call(this,e);else{var i="creating"===this.state;t.prototype.pointerUp.call(this,e),this.setTipPoints(i),this.positionTip()}},e.prototype.manipulate=function(e){if(this.tipMoving){var i=this.unrotatePoint(e);this.tipPosition={x:i.x-this.manipulationStartLeft,y:i.y-this.manipulationStartTop},this.positionTip()}else t.prototype.manipulate.call(this,e)},e.prototype.setBgColor=function(t){this.bgRectangle&&this.tip&&(z.setAttributes(this.bgRectangle,[["fill",t]]),z.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),i=this.height/5;t&&(this.tipPosition={x:e+i/2,y:this.height+20});var r=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?r<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(i=this.width/5,e=Math.min(this.width/2,15),this.tipBase1Position={x:e,y:0},this.tipBase2Position={x:e+i,y:0}):(this.tipBase1Position={x:0,y:e},this.tipBase2Position={x:0,y:e+i}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?r<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(i=this.width/5,e=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-e-i,y:0},this.tipBase2Position={x:this.width-e,y:0}):(this.tipBase1Position={x:this.width,y:e},this.tipBase2Position={x:this.width,y:e+i}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?r<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(i=this.width/5,e=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-e-i,y:this.height},this.tipBase2Position={x:this.width-e,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-e-i},this.tipBase2Position={x:this.width,y:this.height-e}):r<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(i=this.width/5,e=Math.min(this.width/2,15),this.tipBase1Position={x:e,y:this.height},this.tipBase2Position={x:e+i,y:this.height}):(this.tipBase1Position={x:0,y:this.height-e},this.tipBase2Position={x:0,y:this.height-e-i})},e.prototype.resize=function(e){t.prototype.resize.call(this,e),this.positionTip()},e.prototype.positionTip=function(){z.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 i=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},t.prototype.getState.call(this));return i.typeName=e.typeName,i},e.prototype.restoreState=function(e){var i=e;this.bgColor=i.bgColor,this.tipPosition=i.tipPosition,t.prototype.restoreState.call(this,e),this.createTip(),this.setTipPoints()},e.prototype.scale=function(e,i){t.prototype.scale.call(this,e,i),this.tipPosition={x:this.tipPosition.x*e,y:this.tipPosition.y*i},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),kt=function(t){function e(e,i,r){var n=t.call(this,e,i,r)||this;return n.fillColor="transparent",n.strokeColor="transparent",n.strokeWidth=0,n.strokeDasharray="",n.opacity=1,n.strokeColor=r.defaultColor,n.strokeWidth=r.defaultStrokeWidth,n.strokeDasharray=r.defaultStrokeDasharray,n.fillColor=r.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",V(r.defaultColorSet,["transparent"]),r.defaultColor),n.strokePanel.onColorChanged=n.setStrokeColor,n.fillPanel=new tt("Fill color",V(r.defaultColorSet,["transparent"]),n.fillColor,Et),n.fillPanel.onColorChanged=n.setFillColor,n.strokeWidthPanel=new ot("Line width",r.defaultStrokeWidths,r.defaultStrokeWidth),n.strokeWidthPanel.onWidthChanged=n.setStrokeWidth,n.strokeStylePanel=new lt("Line style",r.defaultStrokeDasharrays,r.defaultStrokeDasharray),n.strokeStylePanel.onStyleChanged=n.setStrokeDasharray,n.opacityPanel=new bt("Opacity",r.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=z.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,i){t.prototype.pointerDown.call(this,e,i),"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),z.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&&z.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(t),this.stateChanged()},e.prototype.setFillColor=function(t){this.fillColor=t,this.visual&&z.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(t),this.stateChanged()},e.prototype.setStrokeWidth=function(t){this.strokeWidth=t,this.visual&&z.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},e.prototype.setStrokeDasharray=function(t){this.strokeDasharray=t,this.visual&&z.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},e.prototype.setOpacity=function(t){this.opacity=t,this.visual&&z.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 i=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},t.prototype.getState.call(this));return i.typeName=e.typeName,i},e.prototype.restoreState=function(e){var i=e;this.fillColor=i.fillColor,this.strokeColor=i.strokeColor,this.strokeWidth=i.strokeWidth,this.strokeDasharray=i.strokeDasharray,this.opacity=i.opacity,this.createVisual(),t.prototype.restoreState.call(this,e),this.setSize()},e.prototype.scale=function(e,i){t.prototype.scale.call(this,e,i),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}(st),Tt=function(t){function e(e,i,r){return t.call(this,e,i,r)||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=z.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(z.createTransform()),this.visual.appendChild(this.tip1),this.tip2=z.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(z.createTransform()),this.visual.appendChild(this.tip2)},e.prototype.pointerDown=function(e,i){t.prototype.pointerDown.call(this,e,i),"creating"===this.state&&this.createTips()},e.prototype.adjustVisual=function(){if(t.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(z.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()]]),z.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),i=this.tip1.transform.baseVal.getItem(0);i.setRotate(e,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(i,0);var r=this.tip2.transform.baseVal.getItem(0);r.setRotate(e+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(r,0)}},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var i=t.prototype.getState.call(this);return i.typeName=e.typeName,i},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),wt=function(t){function e(e,i,r){var n=t.call(this,e,i,r)||this;return n.strokePanel.colors=r.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 i=t.prototype.getState.call(this);return i.typeName=e.typeName,i},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}(kt),xt=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}(),At=function(t){function e(e,i,r){var n=t.call(this,e,i,r)||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=r.defaultColor,n.strokeWidth=r.defaultStrokeWidth,n.strokeDasharray=r.defaultStrokeDasharray,n.strokePanel=new tt("Line color",r.defaultColorSet,r.defaultColor),n.strokePanel.onColorChanged=n.setStrokeColor,n.strokeWidthPanel=new ot("Line width",r.defaultStrokeWidths,r.defaultStrokeWidth),n.strokeWidthPanel.onWidthChanged=n.setStrokeWidth,n.strokeStylePanel=new lt("Line style",r.defaultStrokeDasharrays,r.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=z.createGroup(),this.selectorCurve=z.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=z.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,i){t.prototype.pointerDown.call(this,e,i),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(i)&&(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()),z.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),z.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),z.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},e.prototype.setupControlBox=function(){t.prototype.setupControlBox.call(this),this.curveControlLine1=z.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=z.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,i){this.curveX=this.curveX*e,this.curveY=this.curveY*i,t.prototype.scale.call(this,e,i)},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var i=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},t.prototype.getState.call(this));return i.typeName=e.typeName,i},e.prototype.restoreState=function(e){t.prototype.restoreState.call(this,e);var i=e;this.strokeColor=i.strokeColor,this.strokeWidth=i.strokeWidth,this.strokeDasharray=i.strokeDasharray,this.curveX=i.curveX,this.curveY=i.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}(ut),Lt=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}(),Rt=function(t){function e(e,i,r){var n=t.call(this,e,!1)||this;return n.dataUrl=i,n.state=r,n}return U(e,t),e}(Lt),Dt=function(t){function e(e,i,r){void 0===r&&(r=!1);var n=t.call(this,e,r)||this;return n.marker=i,n}return U(e,t),e}(Lt),_t=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 i=this[t].indexOf(e);i>-1&&this[t].splice(i,1)},t}(),Ot=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 ht,this._isOpen=!1,this.undoRedoManager=new xt,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 _t,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=t.instanceCounter++,this.styles=new q(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,mt,pt,wt,kt,St,Ct,Tt,yt,dt,At]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[ct,gt,mt,pt,kt,St,Ct]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"BASIC_MARKER_TYPES",{get:function(){return[ct,gt,mt,pt,St]},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 i=e.ALL_MARKER_TYPES.find((function(e){return e.typeName===t}));void 0!==i&&e._availableMarkerTypes.push(i)}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(),K.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},t.prototype.show=function(){var t=this;void 0===this.styles.styleSheetRoot&&void 0!==Y.styleSheetRoot&&(this.styles.styleSheetRoot=Y.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach((function(e){return e(new Lt(t))}))},t.prototype.render=function(){return G(this,void 0,void 0,(function(){var t;return H(this,(function(e){switch(e.label){case 0:return this.setCurrentMarker(),(t=new W).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 i=!1;t||this.eventListeners.beforeclose.forEach((function(t){var r=new Lt(e,!0);t(r),r.defaultPrevented&&(i=!0)})),i||(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 Lt(e))})),this.detachEvents(),this._isOpen=!1)}},t.prototype.addMarkersToToolbar=function(){for(var t,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];(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,i=e<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/t;this.resize(e,i)},t.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},t.prototype.resize=function(t,e){this._isResizing=!0;var i=t/this.imageWidth,r=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(i,r),this._isResizing=!1},t.prototype.scaleMarkers=function(t,e){var i,r=this;this._currentMarker&&this._currentMarker instanceof pt?this._currentMarker.scale(t,e):(i=this._currentMarker,this.setCurrentMarker()),this.markers.forEach((function(i){i!==r._currentMarker&&i.scale(t,e)})),void 0!==i&&this.setCurrentMarker(i)},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=[],i=0;i<arguments.length;i++)e[i]=arguments[i];this.defs=z.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(i){var r=new Dt(t,t._currentMarker,!0);i(r),r.defaultPrevented&&(e=!0)})),!e){var i=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 Dt(t,i))}))}}},t.prototype.clear=function(){var t=this,e=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach((function(i){var r=new Dt(t,void 0,!0);i(r),r.defaultPrevented&&(e=!0)})),!e)){this.setCurrentMarker();for(var i=function(e){var i=r.markers[e];r.setCurrentMarker(r.markers[e]),r._currentMarker.dispose(),r.markerImage.removeChild(r._currentMarker.container),r.markers.splice(r.markers.indexOf(r._currentMarker),1),r.eventListeners.markerdelete.forEach((function(e){return e(new Dt(t,i))}))},r=this,n=this.markers.length-1;n>=0;n--)i(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(),i=this.undoRedoManager.getLastUndoStep();if(!i||i.width===e.width&&i.height===e.height){var r=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(e),r<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach((function(e){return e(new Lt(t))}))}else this.undoRedoManager.replaceLastUndoStep(e),this.eventListeners.statechange.forEach((function(e){return e(new Lt(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 Lt(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 Lt(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 G(this,void 0,void 0,(function(){var t,e,i=this;return H(this,(function(r){switch(r.label){case 0:return[4,this.render()];case 1:return t=r.sent(),e=this.getState(),this.eventListeners.render.forEach((function(r){return r(new Rt(i,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 i=e._availableMarkerTypes.find((function(e){return e.typeName===t.typeName}));if(void 0!==i){var r=e.addNewMarker(i);r.restoreState(t),e.markers.push(r)}})),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 Lt(e))}))},t.prototype.addNewMarker=function(t){var e=z.createGroup();return this.markerImage.appendChild(e),new t(e,this.overlayContainer,this.settings)},t.prototype.createNewMarker=function(t){var e,i=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 Dt(i,i._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 Dt(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(i){return i(new Dt(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 Dt(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 Dt(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 i=this.markerImage.getBoundingClientRect();return{x:(t-i.left)/this.zoomLevel,y:(e-i.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){K.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 Lt(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 Lt(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 i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(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 Pt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}It(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}function Mt(t,e,i,r){return new(i||(i=Promise))((function(n,s){function a(t){try{l(r.next(t))}catch(t){s(t)}}function o(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}l((r=r.apply(t,e||[])).next())}))}function Nt(t,e){var i,r,n,s,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,r&&(n=2&s[0]?r.return:s[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,s[1])).done)return n;switch(r=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((n=(n=a.trys).length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){a.label=s[1];break}if(6===s[0]&&a.label<n[1]){a.label=n[1],n=s;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(s);break}n[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{i=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}}var Bt=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}(),Ft=function(){function t(){}return t.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},t.setAttributes=function(t,e){for(var i=0,r=e;i<r.length;i++){var n=r[i],s=n[0],a=n[1];t.setAttribute(s,a)}},t.createRect=function(e,i,r){var n=document.createElementNS("http://www.w3.org/2000/svg","rect");return n.setAttribute("width",e.toString()),n.setAttribute("height",i.toString()),r&&t.setAttributes(n,r),n},t.createLine=function(e,i,r,n,s){var a=document.createElementNS("http://www.w3.org/2000/svg","line");return a.setAttribute("x1",e.toString()),a.setAttribute("y1",i.toString()),a.setAttribute("x2",r.toString()),a.setAttribute("y2",n.toString()),s&&t.setAttributes(a,s),a},t.createPolygon=function(e,i){var r=document.createElementNS("http://www.w3.org/2000/svg","polygon");return r.setAttribute("points",e),i&&t.setAttributes(r,i),r},t.createCircle=function(e,i){var r=document.createElementNS("http://www.w3.org/2000/svg","circle");return r.setAttribute("cx",(e/2).toString()),r.setAttribute("cy",(e/2).toString()),r.setAttribute("r",e.toString()),i&&t.setAttributes(r,i),r},t.createEllipse=function(e,i,r){var n=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return n.setAttribute("cx",(e/2).toString()),n.setAttribute("cy",(i/2).toString()),n.setAttribute("rx",(e/2).toString()),n.setAttribute("ry",(i/2).toString()),r&&t.setAttributes(n,r),n},t.createGroup=function(e){var i=document.createElementNS("http://www.w3.org/2000/svg","g");return e&&t.setAttributes(i,e),i},t.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},t.createMarker=function(e,i,r,n,s,a,o){var l=document.createElementNS("http://www.w3.org/2000/svg","marker");return t.setAttributes(l,[["id",e],["orient",i],["markerWidth",r.toString()],["markerHeight",n.toString()],["refX",s.toString()],["refY",a.toString()]]),l.appendChild(o),l},t.createText=function(e){var i=document.createElementNS("http://www.w3.org/2000/svg","text");return i.setAttribute("x","0"),i.setAttribute("y","0"),e&&t.setAttributes(i,e),i},t.createTSpan=function(e,i){var r=document.createElementNS("http://www.w3.org/2000/svg","tspan");return r.textContent=e,i&&t.setAttributes(r,i),r},t.createImage=function(e){var i=document.createElementNS("http://www.w3.org/2000/svg","image");return e&&t.setAttributes(i,e),i},t.createPoint=function(t,e){var i=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return i.x=t,i.y=e,i},t.createPath=function(e,i){var r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d",e),i&&t.setAttributes(r,i),r},t.createElement=function(e,i){var r=document.createElementNS("http://www.w3.org/2000/svg",e);return i&&t.setAttributes(r,i),r},t.getHollowRectanglePath=function(t,e,i,r,n,s,a,o){return"M"+t+","+e+"V"+(e+r)+"H"+(t+i)+"V"+e+"H"+n+"V"+s+"H"+(n+a)+"V"+(s+o)+"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 Gt("_fade_in","\n animation-duration: 0.3s;\n animation-name: "+this.classNamePrefix+"_fade_in_animation_frames;\n ")),this.addClass(new Gt("_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},Gt=function(t,e){this.localName=t,this.style=e},Ht=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}(),Vt=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}(),zt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.buttons=[],e}return Pt(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}(Vt),Kt=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}(),Wt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.elements=[],e}return Pt(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}(Vt),Yt=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}(),qt=function(){function t(){}return t.getIcon=function(t,e){if(t>0&&e>0){var i=new Yt(t,e),r=i.ratio>=1?20:i.getHorizontalLength(20),n=i.ratio<1?20:i.getVerticalLength(20),s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("xmlns","http://www.w3.org/2000/svg"),s.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(s);var a=Ft.createDefs();s.appendChild(a);var o=Ft.createElement("clipPath",[["id","text-bg-clip"]]);a.appendChild(o);var l=Ft.createPath(Ft.getHollowRectanglePath((24-r)/2,(24-n)/2,r,n,(24-r)/2+2,(24-n)/2+2,r-4,n-4));s.appendChild(l);var c=Ft.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);c.appendChild(Ft.createTSpan(t+":"+e)),s.appendChild(c);var h=c.getBBox();Ft.setAttributes(c,[["x",((24-h.width)/2).toString()],["y",((24-h.height)/2-h.y).toString()]]);var u=Ft.createPath(Ft.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(h.width))/2,(24-Math.ceil(h.height))/2,Math.ceil(h.width),Math.ceil(h.height)));return o.appendChild(u),Ft.setAttributes(l,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(s),s.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,i,r){var n=t.call(this,e,i)||this;return n.isDropdownOpen=!1,n.onClick=n.dropdownButtonClicked,n.dropdownButtons=r,n}return Pt(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}(Kt),$t=function(){function t(t,e){this.GRIP_SIZE=10,this.color=t,this.fillColor=e,this.visual=Ft.createGroup(),this.visual.appendChild(Ft.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(Ft.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return 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(i){return Ft.setAttributes(i,[["cx",t.toString()],["cy",e.toString()]])}))},t}(),Zt=function(){function t(t,e,i,r){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=i,this.container=r,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&&Ft.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=Ft.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=Ft.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var e=0;e<this.numberOfGridLines;e++)this.horizontalGridLines.push(Ft.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(Ft.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=Ft.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),Ft.setAttributes(this.cropRectElement,[["x",e.x.toString()],["y",e.y.toString()],["width",e.width.toString()],["height",e.height.toString()]]);var i=e.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach((function(t,r){var n=e.y+i*(r+1);Ft.setAttributes(t,[["x1",""+e.x],["y1",""+n],["x2",""+(e.x+e.width)],["y2",""+n]])}));var r=e.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach((function(t,i){var n=e.x+r*(i+1);Ft.setAttributes(t,[["x1",""+n],["y1",""+e.y],["x2",""+n],["y2",""+(e.y+e.height)]])})),Ft.setAttributes(this.cropShadeElement,[["d",Ft.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 i=this.container.getBoundingClientRect();return{x:t-i.left+this.margin,y:e-i.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,i=t.y-this.previousPoint.y;1!==this.zoomFactor&&(e=-e/this.zoomFactor,i=-i/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+i),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),i=t.x-this.previousPoint.x,r=t.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:e.x+i<this.margin&&(i=this.margin-e.x),e.x+=i,e.width=this.cropRect.x+this.cropRect.width-e.x;break;case this.bottomRightGrip:case this.topRightGrip:e.width+i>this.canvasWidth*this.zoomFactor&&(i=this.canvasWidth*this.zoomFactor-e.width),e.width+=i}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(i),e.height=this.aspectRatio.getVerticalLength(e.width)):(e.y+=r,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+=r}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,i=this.aspectRatio.getHorizontalLength(this.cropRect.height),r=this.aspectRatio.getVerticalLength(this.cropRect.width);i/this.canvasWidth<r/this.canvasHeight?this.cropRect.width=i:this.cropRect.height=r,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,i,r,n,s){var a=i/t,o=r/e;return{x:(n.x-s)*a+s,y:(n.y-s)*o+s,width:n.width*a,height:n.height*o}},t.prototype.scaleCanvas=function(t,e){var i=this.getRescaledRect(this.canvasWidth,this.canvasHeight,t,e,this.cropRect,this.margin);this.canvasWidth=t,this.canvasHeight=e,this.onCropChange&&this.onCropChange(i),this.setCropRectangle(i)},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();Ft.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,i=1;i<=this.width/5+10;i++){var r=i%5==0?this.height/3:this.height/6;e+="h4v"+-r+"h1v"+r}e+="v1H0Z",this.scaleShape=Ft.createPath(e);var n=Ft.createTransform();this.scaleShape.transform.baseVal.appendItem(n),t.appendChild(this.scaleShape),this.angleLabelElement=Ft.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=Ft.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var s=Ft.createTSpan("");return s.innerHTML="°",this.angleLabelElement.appendChild(s),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,i,r,n,s,a){var o=this;return new Promise((function(l){var c=document.createElement("canvas");c.width=t.width.baseVal.value-2*r,c.height=t.height.baseVal.value-2*r;var h=1,u=1;!0===o.naturalSize?(h=e.naturalWidth/(t.width.baseVal.value-2*r)/s,u=e.naturalHeight/(t.height.baseVal.value-2*r)/a,c.width=e.naturalWidth/s,c.height=e.naturalHeight/a):void 0!==o.width&&void 0!==o.height&&(h=o.width/i.width,u=o.height/i.height,c.width*=h,c.height*=u);var d=c.getContext("2d");d.translate(c.width/2,c.height/2),d.rotate(n*Math.PI/180),d.scale(s,a),d.translate(-c.width/2,-c.height/2),d.drawImage(e,0,0,c.width,c.height);var f=document.createElement("canvas");f.width=i.width*h,f.height=i.height*u,f.getContext("2d").putImageData(d.getImageData((i.x-r)*h,(i.y-r)*u,i.width*h,i.height*u),0,0),l(f.toDataURL(o.imageType,o.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,i=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,i)}},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",Ft.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();Ft.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=Ft.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=Ft.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=Ft.createGroup(),this.editingTargetRotationScaleContainer=Ft.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var t=Ft.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(t);var e=Ft.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(e),this.editingTargetContainer=Ft.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=Ft.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 Ht,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 zt;e.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(e);var i=[];this.aspectRatios.forEach((function(e){var r=new Kt(qt.getIcon(e.horizontal,e.vertical),0===e.horizontal&&0===e.vertical?"FREE":e.horizontal+":"+e.vertical);r.onClick=function(){return t.ratioButtonClicked(e)},i.push(r)})),this.aspectRatioButton=new Xt(qt.getIcon(0,0),"Aspect ratio",i),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 r=new Kt('<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");r.isActive=this.isGridVisible,r.onClick=function(){t.isGridVisible=!t.isGridVisible,r.isActive=t.isGridVisible},e.addButton(r);var n=new Kt('<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),!Bt.isLicensed){var s=new Wt;this.topToolbar.addElementBlock(s);var a=document.createElement("div");a.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var o=document.createElement("a");o.style.color="currentColor",o.href="https://markerjs.com/products/cropro",o.target="_blank",o.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>',a.appendChild(o),s.addElement(a)}var l=new zt;l.minWidth=3*this.toolbarHeight+"px",l.contentAlign="end",this.topToolbar.addButtonBlock(l);var c=new Kt('<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 h=new Kt('<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");h.onClick=this.close,l.addButton(h),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(h.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},t.prototype.addBottomToolbar=function(){var t=this;this.bottomToolbar=new Ht,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 zt;e.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(e);var i=new Kt('<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");i.onClick=this.rotateLeftButtonClicked,e.addButton(i);var r=new Kt('<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");r.onClick=this.rotateRightButtonClicked,e.addButton(r);var n=new Wt;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 s=new zt;s.minWidth=2*this.toolbarHeight+"px",s.contentAlign="end",this.bottomToolbar.addButtonBlock(s);var a=new Kt('<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");a.onClick=this.flipHorizontallyButtonClicked,s.addButton(a);var o=new Kt('<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");o.onClick=this.flipVerticallyButtonClicked,s.addButton(o)},t.prototype.ratioButtonClicked=function(t){this.aspectRatio=t,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},t.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=qt.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 Yt(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 i=this.cropImage.getBoundingClientRect();return{x:t-i.left,y:e-i.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 i=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/i.width,this.imageHeight/i.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 Mt(this,void 0,void 0,(function(){var t,e;return Nt(this,(function(i){switch(i.label){case 0:return[4,this.render()];case 1:return t=i.sent(),e=this.getState(),this.renderEventListeners.forEach((function(i){return i(t,e)})),this.close(!0),[2]}}))}))},t.prototype.render=function(){return Mt(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(),Ft.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 Gt("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 Gt("toolbar_colors","\n background-color: "+this.styles.settings.toolbarBackgroundColor+";\n ")),this.toolbarBlockStyleClass=this.styles.addClass(new Gt("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 Gt("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 Gt("toolbar_button_colors","\n color: "+this.styles.settings.toolbarColor+";\n fill: currentColor;\n ")),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new Gt("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 Gt("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 Gt("toolbar_dropdown_colors","\n background-color: "+this.styles.settings.toolbarBackgroundColor+";\n ")),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new Gt("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 Gt("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 Gt("toolbar_straightener_colors","\n color: "+this.styles.settings.toolbarColor+";\n fill: currentColor;\n "))},t.instanceCounter=0,t}(),ee=i("8hTe"),ie=i.n(ee),re=/<pre[^>]*>/g;e.a=function(t){var e=t.value,i=void 0===e?"":e,l=t.edit,d=void 0!==l&&l,f=t.className,p=t.showTextOnly,g=t.showLines,v=t.replaces,m=t.zoomImg,y=t.hasMask,C=t.style,k=void 0===C?{}:C,T=t.stylesPrev,w=void 0===T?{}:T,L=String(i),R=Object(h.useRef)(),D=Object(h.useRef)(),_=Object(h.useState)(""),I=Object(o.a)(_,2),j=I[0],U=I[1],G=Object(h.useState)("office"),H=Object(o.a)(G,2),V=H[0],z=H[1],K=Object(h.useMemo)((function(){try{L=(L=L.replace(/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,"("+M.a.API_SERVER+"/api/attachments/").replace(/\"\/api\/attachments\/|\"\/attachments\/download\//g,'"'+M.a.API_SERVER+"/api/attachments/").replace(/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g,'"'+M.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=O(L),e=x;if(L.match(/\[TOC\]/)&&(t=t.replace("<p>[TOC]</p>",E()),b()),t=(t=t.replace(/(__special_katext_id_\d+__)/g,(function(t,i){var r=e[i],n=r.type,s=r.expression;return Object(N.renderToString)(function(t){var e=document.createElement("div");return e.innerHTML=t,0===e.childNodes.length?"":e.childNodes[0].nodeValue}(s)||"",{displayMode:"block"===n,throwOnError:!1,output:"html"})}))).replace(/▁/g,"▁▁▁"),A(),p){var i=document.createElement("div");return i.innerHTML=t,i.innerText}return setTimeout((function(){return q()}),500),t}),[L]),W=Object(h.useRef)();function Y(t){var e=t.target;if("IMG"===e.tagName.toUpperCase()){if(m){var i=e.getAttribute("src");U(i),z("image")}}else if("A"===e.tagName.toUpperCase()){var r=e.getAttribute("href");if(r.indexOf("office")>-1)t.preventDefault(),U(r),z("office");else if(r.indexOf("application/pdf")>-1)t.preventDefault(),U(r),z("pdf");else if(r.indexOf("type=text")>-1)t.preventDefault(),U(r),z("html");else if(r.startsWith("#")){t.preventDefault();var n=document.getElementById(r.replace("#",""));n&&n.scrollIntoView(!0)}}}S.WebkitLineClamp=g,g&&(k=Object(s.a)(Object(s.a)({},k),S));var q=function(){var t,e=null===(t=W.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(P.a.isSupported()){var e=new P.a;e.loadSource(t.src),e.attachMedia(t)}}))};Object(h.useEffect)((function(){if(W.current&&K&&K.match(re)&&window.PR.prettyPrint(),W.current)return W.current.addEventListener("click",Y),function(){W.current.removeEventListener("click",Y),A(),b()}}),[K,W.current,Y]);return u.a.createElement("div",{style:{position:"relative"}},u.a.createElement("div",{ref:W,style:Object(s.a)({},k),className:"".concat(f||""," markdown-body ").concat(ie.a.mdBody),onMouseOver:function(t){d&&("IMG"===t.target.nodeName?(R.current.style.display="flex",R.current.style.width=t.target.clientWidth+"px",R.current.style.height=t.target.clientHeight+"px",R.current.style.top=t.target.offsetTop+"px",R.current.style.left=t.target.offsetLeft+"px",D.current.src=t.target.getAttribute("src")):R.current.style.display="none")},dangerouslySetInnerHTML:{__html:K}}),u.a.createElement("div",{ref:R,className:ie.a.button},u.a.createElement(r.a,null,u.a.createElement(n.a,{onClick:function(){return(t=new te(D.current)).displayMode="popup",t.addRenderEventListener(function(){var t=Object(a.a)(c.a.mark((function t(e){var i;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return R.current.style.display="none",t.next=3,Object(F.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:e}});case 3:null!=(i=t.sent)&&i.id&&v(D.current.getAttribute("src").replace(M.a.API_SERVER,""),"/api/attachments/".concat(null==i?void 0:i.id,"?type=").concat(i.content_type));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),void t.show();var t}},"裁剪"),u.a.createElement(n.a,{onClick:function(){return(t=new Ot(D.current)).settings.displayMode="popup",t.addEventListener("render",function(){var t=Object(a.a)(c.a.mark((function t(e){var i;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(R.current.style.display="none",!D.current){t.next=6;break}return t.next=4,Object(F.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:e.dataUrl}});case 4:null!=(i=t.sent)&&i.id&&v(D.current.getAttribute("src").replace(M.a.API_SERVER,""),"/api/attachments/".concat(null==i?void 0:i.id,"?type=").concat(i.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}},"编辑"))),u.a.createElement("img",{ref:D,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}}),u.a.createElement(B.a,{close:!0,data:j,hasMask:y,type:null!=j&&j.length?V:"",style:Object(s.a)({},w),onClose:function(){return U("")}}))}},BU3w:
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./node_modules/rc-util/es/Dom/dynamicCSS.js ***!
|
|
|
\***************************************************/
|
|
|
/*! exports provided: injectCSS, updateCSS */
|
|
|
/*! exports used: updateCSS */function(t,e,i){"use strict";i.d(e,"a",(function(){return o}));var r=i(/*! ./canUseDom */"MNnm");function n(t){return t.attachTo?t.attachTo:document.querySelector("head")||document.body}function s(t){var e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Object(r.a)())return null;var s,a=document.createElement("style");(null===(e=i.csp)||void 0===e?void 0:e.nonce)&&(a.nonce=null===(s=i.csp)||void 0===s?void 0:s.nonce);a.innerHTML=t;var o=n(i),l=o.firstChild;return i.prepend&&o.prepend?o.prepend(a):i.prepend&&l?o.insertBefore(a,l):o.appendChild(a),a}var a=new Map;function o(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n(i);if(!a.has(r)){var o=s("",i),l=o.parentNode;a.set(r,l),l.removeChild(o)}var c=Array.from(a.get(r).children).find((function(t){return"STYLE"===t.tagName&&t["rc-util-key"]===e}));if(c){var h,u,d;if((null===(h=i.csp)||void 0===h?void 0:h.nonce)&&c.nonce!==(null===(u=i.csp)||void 0===u?void 0:u.nonce))c.nonce=null===(d=i.csp)||void 0===d?void 0:d.nonce;return c.innerHTML!==t&&(c.innerHTML=t),c}var f=s(t,i);return f["rc-util-key"]=e,f}},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,i){t.exports=function(){"use strict";function t(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=new Array(e);i<e;i++)r[i]=t[i];return r}function i(t,i){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,i){if(t){if("string"==typeof t)return e(t,i);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)?e(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){r&&(t=r);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(r=t[Symbol.iterator]()).next.bind(r)}var r=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=(r.defaults,r.getDefaults,r.changeDefaults,/[&<>"']/),s=/[&<>"']/g,a=/[<>"']|&(?!#?\w+;)/,o=/[<>"']|&(?!#?\w+;)/g,l={"&":"&","<":"<",">":">",'"':""","'":"'"},c=function(t){return l[t]},h=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function u(t){return t.replace(h,(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={},v=/^[^:]+:\/*[^/]*$/,m=/^([^:]+:)[\s\S]*$/,y=/^([^:]+:\/*[^/]*)[\s\S]*$/;function b(t,e){g[" "+t]||(v.test(t)?g[" "+t]=t+"/":g[" "+t]=S(t,"/",!0));var i=-1===(t=g[" "+t]).indexOf(":");return"//"===e.substring(0,2)?i?e:t.replace(m,"$1")+e:"/"===e.charAt(0)?i?e:t.replace(y,"$1")+e:t+e}function S(t,e,i){var r=t.length;if(0===r)return"";for(var n=0;n<r;){var s=t.charAt(r-n-1);if(s!==e||i){if(s===e||!i)break;n++}else n++}return t.substr(0,r-n)}var E=function(t,e){if(e){if(n.test(t))return t.replace(s,c)}else if(a.test(t))return t.replace(o,c);return t},C=u,k=function(t,e){t=t.source||t,e=e||"";var i={replace:function(e,r){return r=(r=r.source||r).replace(d,"$1"),t=t.replace(e,r),i},getRegex:function(){return new RegExp(t,e)}};return i},T=function(t,e,i){if(t){var r;try{r=decodeURIComponent(u(i)).replace(f,"").toLowerCase()}catch(t){return null}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:")||0===r.indexOf("data:"))return null}e&&!p.test(i)&&(i=b(e,i));try{i=encodeURI(i).replace(/%25/g,"%")}catch(t){return null}return i},w={exec:function(){}},x=function(t){for(var e,i,r=1;r<arguments.length;r++)for(i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},A=function(t,e){var i=t.replace(/\|/g,(function(t,e,i){for(var r=!1,n=e;--n>=0&&"\\"===i[n];)r=!r;return r?"|":" |"})).split(/ \|/),r=0;if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;r<i.length;r++)i[r]=i[r].trim().replace(/\\\|/g,"|");return i},L=S,R=function(t,e){if(-1===t.indexOf(e[1]))return-1;for(var i=t.length,r=0,n=0;n<i;n++)if("\\"===t[n])n++;else if(t[n]===e[0])r++;else if(t[n]===e[1]&&--r<0)return n;return-1},D=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.defaults,O=L,I=A,P=E,M=R;function N(t,e,i){var r=e.href,n=e.title?P(e.title):null,s=t[1].replace(/\\([\[\]])/g,"$1");return"!"!==t[0].charAt(0)?{type:"link",raw:i,href:r,title:n,text:s}:{type:"image",raw:i,href:r,title:n,text:P(s)}}var B=function(){function t(t){this.options=t||_}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 i=this.rules.block.code.exec(t);if(i){var r=e[e.length-1];if(r&&"paragraph"===r.type)return{raw:i[0],text:i[0].trimRight()};var n=i[0].replace(/^ {4}/gm,"");return{type:"code",raw:i[0],codeBlockStyle:"indented",text:this.options.pedantic?n:O(n,"\n")}}},e.fences=function(t){var e=this.rules.block.fences.exec(t);if(e){var i=e[0],r=function(t,e){var i=t.match(/^(\s+)(?:```)/);if(null===i)return e;var r=i[1];return e.split("\n").map((function(t){var e=t.match(/^\s+/);return null===e?t:e[0].length>=r.length?t.slice(r.length):t})).join("\n")}(i,e[3]||"");return{type:"code",raw:i,lang:e[2]?e[2].trim():e[2],text:r}}},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 i={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(i.header.length===i.align.length){var r,n=i.align.length;for(r=0;r<n;r++)/^ *-+: *$/.test(i.align[r])?i.align[r]="right":/^ *:-+: *$/.test(i.align[r])?i.align[r]="center":/^ *:-+ *$/.test(i.align[r])?i.align[r]="left":i.align[r]=null;for(n=i.cells.length,r=0;r<n;r++)i.cells[r]=I(i.cells[r],i.header.length);return i}}},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 i=e[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:e[0],text:i}}},e.list=function(t){var e=this.rules.block.list.exec(t);if(e){for(var i,r,n,s,a,o,l,c=e[0],h=e[2],u=h.length>1,d=")"===h[h.length-1],f={type:"list",raw:c,ordered:u,start:u?+h.slice(0,-1):"",loose:!1,items:[]},p=e[0].match(this.rules.block.item),g=!1,v=p.length,m=0;m<v;m++)c=i=p[m],r=i.length,~(i=i.replace(/^ *([*+-]|\d+[.)]) */,"")).indexOf("\n ")&&(r-=i.length,i=this.options.pedantic?i.replace(/^ {1,4}/gm,""):i.replace(new RegExp("^ {1,"+r+"}","gm"),"")),m!==v-1&&(n=this.rules.block.bullet.exec(p[m+1])[0],(u?1===n.length||!d&&")"===n[n.length-1]:n.length>1||this.options.smartLists&&n!==h)&&(s=p.slice(m+1).join("\n"),f.raw=f.raw.substring(0,f.raw.length-s.length),m=v-1)),a=g||/\n\n(?!\s*$)/.test(i),m!==v-1&&(g="\n"===i.charAt(i.length-1),a||(a=g)),a&&(f.loose=!0),l=void 0,(o=/^\[[ xX]\] /.test(i))&&(l=" "!==i[1],i=i.replace(/^\[[ xX]\] +/,"")),f.items.push({type:"list_item",raw:c,task:o,checked:l,loose:a,text:i});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]):P(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 i={type:"table",header:I(e[1].replace(/^ *| *\| *$/g,"")),align:e[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:e[3]?e[3].replace(/\n$/,"").split("\n"):[]};if(i.header.length===i.align.length){i.raw=e[0];var r,n=i.align.length;for(r=0;r<n;r++)/^ *-+: *$/.test(i.align[r])?i.align[r]="right":/^ *:-+: *$/.test(i.align[r])?i.align[r]="center":/^ *:-+ *$/.test(i.align[r])?i.align[r]="left":i.align[r]=null;for(n=i.cells.length,r=0;r<n;r++)i.cells[r]=I(i.cells[r].replace(/^ *\| *| *\| *$/g,""),i.header.length);return i}}},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 i=this.rules.block.text.exec(t);if(i){var r=e[e.length-1];return r&&"text"===r.type?{raw:i[0],text:i[0]}:{type:"text",raw:i[0],text:i[0]}}},e.escape=function(t){var e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:P(e[1])}},e.tag=function(t,e,i){var r=this.rules.inline.tag.exec(t);if(r)return!e&&/^<a /i.test(r[0])?e=!0:e&&/^<\/a>/i.test(r[0])&&(e=!1),!i&&/^<(pre|code|kbd|script)(\s|>)/i.test(r[0])?i=!0:i&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(r[0])&&(i=!1),{type:this.options.sanitize?"text":"html",raw:r[0],inLink:e,inRawBlock:i,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):P(r[0]):r[0]}},e.link=function(t){var e=this.rules.inline.link.exec(t);if(e){var i=M(e[2],"()");if(i>-1){var r=(0===e[0].indexOf("!")?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,r).trim(),e[3]=""}var n=e[2],s="";if(this.options.pedantic){var a=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);a?(n=a[1],s=a[3]):s=""}else s=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:s?s.replace(this.rules.inline._escapes,"$1"):s},e[0])}},e.reflink=function(t,e){var i;if((i=this.rules.inline.reflink.exec(t))||(i=this.rules.inline.nolink.exec(t))){var r=(i[2]||i[1]).replace(/\s+/g," ");if(!(r=e[r.toLowerCase()])||!r.href){var n=i[0].charAt(0);return{type:"text",raw:n,text:n}}return N(i,r,i[0])}},e.strong=function(t,e,i){void 0===i&&(i="");var r=this.rules.inline.strong.start.exec(t);if(r&&(!r[1]||r[1]&&(""===i||this.rules.inline.punctuation.exec(i)))){e=e.slice(-1*t.length);var n,s="**"===r[0]?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;for(s.lastIndex=0;null!=(r=s.exec(e));)if(n=this.rules.inline.strong.middle.exec(e.slice(0,r.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,i){void 0===i&&(i="");var r=this.rules.inline.em.start.exec(t);if(r&&(!r[1]||r[1]&&(""===i||this.rules.inline.punctuation.exec(i)))){e=e.slice(-1*t.length);var n,s="*"===r[0]?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;for(s.lastIndex=0;null!=(r=s.exec(e));)if(n=this.rules.inline.em.middle.exec(e.slice(0,r.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 i=e[2].replace(/\n/g," "),r=/[^ ]/.test(i),n=i.startsWith(" ")&&i.endsWith(" ");return r&&n&&(i=i.substring(1,i.length-1)),i=P(i,!0),{type:"codespan",raw:e[0],text:i}}},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 i,r,n=this.rules.inline.autolink.exec(t);if(n)return r="@"===n[2]?"mailto:"+(i=P(this.options.mangle?e(n[1]):n[1])):i=P(n[1]),{type:"link",raw:n[0],text:i,href:r,tokens:[{type:"text",raw:i,text:i}]}},e.url=function(t,e){var i;if(i=this.rules.inline.url.exec(t)){var r,n;if("@"===i[2])n="mailto:"+(r=P(this.options.mangle?e(i[0]):i[0]));else{var s;do{s=i[0],i[0]=this.rules.inline._backpedal.exec(i[0])[0]}while(s!==i[0]);r=P(i[0]),n="www."===i[1]?"http://"+r:r}return{type:"link",raw:i[0],text:r,href:n,tokens:[{type:"text",raw:r,text:r}]}}},e.inlineText=function(t,e,i){var r,n=this.rules.inline.text.exec(t);if(n)return r=e?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):P(n[0]):n[0]:P(this.options.smartypants?i(n[0]):n[0]),{type:"text",raw:n[0],text:r}},t}(),F=w,j=k,U=x,G={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:F,table:F,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?'|\([^()]*\))/};G.def=j(G.def).replace("label",G._label).replace("title",G._title).getRegex(),G.bullet=/(?:[*+-]|\d{1,9}[.)])/,G.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,G.item=j(G.item,"gm").replace(/bull/g,G.bullet).getRegex(),G.list=j(G.list).replace(/bull/g,G.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+G.def.source+")").getRegex(),G._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",G._comment=/<!--(?!-?>)[\s\S]*?-->/,G.html=j(G.html,"i").replace("comment",G._comment).replace("tag",G._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),G.paragraph=j(G._paragraph).replace("hr",G.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",G._tag).getRegex(),G.blockquote=j(G.blockquote).replace("paragraph",G.paragraph).getRegex(),G.normal=U({},G),G.gfm=U({},G.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*|$)"}),G.gfm.nptable=j(G.gfm.nptable).replace("hr",G.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",G._tag).getRegex(),G.gfm.table=j(G.gfm.table).replace("hr",G.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",G._tag).getRegex(),G.pedantic=U({},G.normal,{html:j("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",G._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:F,paragraph:j(G.normal._paragraph).replace("hr",G.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",G.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var H={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:F,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:F,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/,_punctuation:"!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~"};H.punctuation=j(H.punctuation).replace(/punctuation/g,H._punctuation).getRegex(),H._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",H._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",H.em.start=j(H.em.start).replace(/punctuation/g,H._punctuation).getRegex(),H.em.middle=j(H.em.middle).replace(/punctuation/g,H._punctuation).replace(/overlapSkip/g,H._overlapSkip).getRegex(),H.em.endAst=j(H.em.endAst,"g").replace(/punctuation/g,H._punctuation).getRegex(),H.em.endUnd=j(H.em.endUnd,"g").replace(/punctuation/g,H._punctuation).getRegex(),H.strong.start=j(H.strong.start).replace(/punctuation/g,H._punctuation).getRegex(),H.strong.middle=j(H.strong.middle).replace(/punctuation/g,H._punctuation).replace(/blockSkip/g,H._blockSkip).getRegex(),H.strong.endAst=j(H.strong.endAst,"g").replace(/punctuation/g,H._punctuation).getRegex(),H.strong.endUnd=j(H.strong.endUnd,"g").replace(/punctuation/g,H._punctuation).getRegex(),H.blockSkip=j(H._blockSkip,"g").getRegex(),H.overlapSkip=j(H._overlapSkip,"g").getRegex(),H._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,H._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,H._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])?)+(?![-_])/,H.autolink=j(H.autolink).replace("scheme",H._scheme).replace("email",H._email).getRegex(),H._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,H.tag=j(H.tag).replace("comment",G._comment).replace("attribute",H._attribute).getRegex(),H._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,H._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,H._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,H.link=j(H.link).replace("label",H._label).replace("href",H._href).replace("title",H._title).getRegex(),H.reflink=j(H.reflink).replace("label",H._label).getRegex(),H.reflinkSearch=j(H.reflinkSearch,"g").replace("reflink",H.reflink).replace("nolink",H.nolink).getRegex(),H.normal=U({},H),H.pedantic=U({},H.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",H._label).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",H._label).getRegex()}),H.gfm=U({},H.normal,{escape:j(H.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),H.gfm.url=j(H.gfm.url,"i").replace("email",H.gfm._extended_email).getRegex(),H.breaks=U({},H.gfm,{br:j(H.br).replace("{2,}","*").getRegex(),text:j(H.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var V={block:G,inline:H},z=r.defaults,K=V.block,W=V.inline;function Y(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 q(t){var e,i,r="",n=t.length;for(e=0;e<n;e++)i=t.charCodeAt(e),Math.random()>.5&&(i="x"+i.toString(16)),r+="&#"+i+";";return r}var X=function(){function e(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||z,this.options.tokenizer=this.options.tokenizer||new B,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var e={block:K.normal,inline:W.normal};this.options.pedantic?(e.block=K.pedantic,e.inline=W.pedantic):this.options.gfm&&(e.block=K.gfm,this.options.breaks?e.inline=W.breaks:e.inline=W.gfm),this.tokenizer.rules=e}e.lex=function(t,i){return new e(i).lex(t)};var i,r,n,s=e.prototype;return s.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},s.blockTokens=function(t,e,i){var r,n,s,a;for(void 0===e&&(e=[]),void 0===i&&(i=!0),t=t.replace(/^ +$/gm,"");t;)if(r=this.tokenizer.space(t))t=t.substring(r.raw.length),r.type&&e.push(r);else if(r=this.tokenizer.code(t,e))t=t.substring(r.raw.length),r.type?e.push(r):((a=e[e.length-1]).raw+="\n"+r.raw,a.text+="\n"+r.text);else if(r=this.tokenizer.fences(t))t=t.substring(r.raw.length),e.push(r);else if(r=this.tokenizer.heading(t))t=t.substring(r.raw.length),e.push(r);else if(r=this.tokenizer.nptable(t))t=t.substring(r.raw.length),e.push(r);else if(r=this.tokenizer.hr(t))t=t.substring(r.raw.length),e.push(r);else if(r=this.tokenizer.blockquote(t))t=t.substring(r.raw.length),r.tokens=this.blockTokens(r.text,[],i),e.push(r);else if(r=this.tokenizer.list(t)){for(t=t.substring(r.raw.length),s=r.items.length,n=0;n<s;n++)r.items[n].tokens=this.blockTokens(r.items[n].text,[],!1);e.push(r)}else if(r=this.tokenizer.html(t))t=t.substring(r.raw.length),e.push(r);else if(i&&(r=this.tokenizer.def(t)))t=t.substring(r.raw.length),this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});else if(r=this.tokenizer.table(t))t=t.substring(r.raw.length),e.push(r);else if(r=this.tokenizer.lheading(t))t=t.substring(r.raw.length),e.push(r);else if(i&&(r=this.tokenizer.paragraph(t)))t=t.substring(r.raw.length),e.push(r);else if(r=this.tokenizer.text(t,e))t=t.substring(r.raw.length),r.type?e.push(r):((a=e[e.length-1]).raw+="\n"+r.raw,a.text+="\n"+r.text);else if(t){var o="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(o);break}throw new Error(o)}return e},s.inline=function(t){var e,i,r,n,s,a,o=t.length;for(e=0;e<o;e++)switch((a=t[e]).type){case"paragraph":case"text":case"heading":a.tokens=[],this.inlineTokens(a.text,a.tokens);break;case"table":for(a.tokens={header:[],cells:[]},n=a.header.length,i=0;i<n;i++)a.tokens.header[i]=[],this.inlineTokens(a.header[i],a.tokens.header[i]);for(n=a.cells.length,i=0;i<n;i++)for(s=a.cells[i],a.tokens.cells[i]=[],r=0;r<s.length;r++)a.tokens.cells[i][r]=[],this.inlineTokens(s[r],a.tokens.cells[i][r]);break;case"blockquote":this.inline(a.tokens);break;case"list":for(n=a.items.length,i=0;i<n;i++)this.inline(a.items[i].tokens)}return t},s.inlineTokens=function(t,e,i,r,n){var s;void 0===e&&(e=[]),void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===n&&(n="");var a,o=t;if(this.tokens.links){var l=Object.keys(this.tokens.links);if(l.length>0)for(;null!=(a=this.tokenizer.rules.inline.reflinkSearch.exec(o));)l.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(a=this.tokenizer.rules.inline.blockSkip.exec(o));)o=o.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;t;)if(s=this.tokenizer.escape(t))t=t.substring(s.raw.length),e.push(s);else if(s=this.tokenizer.tag(t,i,r))t=t.substring(s.raw.length),i=s.inLink,r=s.inRawBlock,e.push(s);else if(s=this.tokenizer.link(t))t=t.substring(s.raw.length),"link"===s.type&&(s.tokens=this.inlineTokens(s.text,[],!0,r)),e.push(s);else if(s=this.tokenizer.reflink(t,this.tokens.links))t=t.substring(s.raw.length),"link"===s.type&&(s.tokens=this.inlineTokens(s.text,[],!0,r)),e.push(s);else if(s=this.tokenizer.strong(t,o,n))t=t.substring(s.raw.length),s.tokens=this.inlineTokens(s.text,[],i,r),e.push(s);else if(s=this.tokenizer.em(t,o,n))t=t.substring(s.raw.length),s.tokens=this.inlineTokens(s.text,[],i,r),e.push(s);else if(s=this.tokenizer.codespan(t))t=t.substring(s.raw.length),e.push(s);else if(s=this.tokenizer.br(t))t=t.substring(s.raw.length),e.push(s);else if(s=this.tokenizer.del(t))t=t.substring(s.raw.length),s.tokens=this.inlineTokens(s.text,[],i,r),e.push(s);else if(s=this.tokenizer.autolink(t,q))t=t.substring(s.raw.length),e.push(s);else if(i||!(s=this.tokenizer.url(t,q))){if(s=this.tokenizer.inlineText(t,r,Y))t=t.substring(s.raw.length),n=s.raw.slice(-1),e.push(s);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(s.raw.length),e.push(s);return e},i=e,n=[{key:"rules",get:function(){return{block:K,inline:W}}}],(r=null)&&t(i.prototype,r),n&&t(i,n),e}(),$=r.defaults,Z=T,Q=E,J=function(){function t(t){this.options=t||$}var e=t.prototype;return e.code=function(t,e,i){var r=(e||"").match(/\S*/)[0];if(this.options.highlight){var n=this.options.highlight(t,r);null!=n&&n!==t&&(i=!0,t=n)}return r?'<pre><code class="'+this.options.langPrefix+Q(r,!0)+'">'+(i?t:Q(t,!0))+"</code></pre>\n":"<pre><code>"+(i?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,i,r){return this.options.headerIds?"<h"+e+' id="'+this.options.headerPrefix+r.slug(i)+'">'+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,i){var r=e?"ol":"ul";return"<"+r+(e&&1!==i?' start="'+i+'"':"")+">\n"+t+"</"+r+">\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 i=e.header?"th":"td";return(e.align?"<"+i+' align="'+e.align+'">':"<"+i+">")+t+"</"+i+">\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,i){if(null===(t=Z(this.options.sanitize,this.options.baseUrl,t)))return i;var r='<a href="'+Q(t)+'"';return e&&(r+=' title="'+e+'"'),r+=">"+i+"</a>"},e.image=function(t,e,i){if(null===(t=Z(this.options.sanitize,this.options.baseUrl,t)))return i;var r='<img src="'+t+'" alt="'+i+'"';return e&&(r+=' title="'+e+'"'),r+=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,i){return""+i},e.image=function(t,e,i){return""+i},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 i=e;do{this.seen[i]++,e=i+"-"+this.seen[i]}while(this.seen.hasOwnProperty(e))}return this.seen[e]=0,e},t}(),it=r.defaults,rt=C,nt=function(){function t(t){this.options=t||it,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,i){return new t(i).parse(e)};var e=t.prototype;return e.parse=function(t,e){void 0===e&&(e=!0);var i,r,n,s,a,o,l,c,h,u,d,f,p,g,v,m,y,b,S="",E=t.length;for(i=0;i<E;i++)switch((u=t[i]).type){case"space":continue;case"hr":S+=this.renderer.hr();continue;case"heading":S+=this.renderer.heading(this.parseInline(u.tokens),u.depth,rt(this.parseInline(u.tokens,this.textRenderer)),this.slugger);continue;case"code":S+=this.renderer.code(u.text,u.lang,u.escaped);continue;case"table":for(c="",l="",s=u.header.length,r=0;r<s;r++)l+=this.renderer.tablecell(this.parseInline(u.tokens.header[r]),{header:!0,align:u.align[r]});for(c+=this.renderer.tablerow(l),h="",s=u.cells.length,r=0;r<s;r++){for(l="",a=(o=u.tokens.cells[r]).length,n=0;n<a;n++)l+=this.renderer.tablecell(this.parseInline(o[n]),{header:!1,align:u.align[n]});h+=this.renderer.tablerow(l)}S+=this.renderer.table(c,h);continue;case"blockquote":h=this.parse(u.tokens),S+=this.renderer.blockquote(h);continue;case"list":for(d=u.ordered,f=u.start,p=u.loose,s=u.items.length,h="",r=0;r<s;r++)m=(v=u.items[r]).checked,y=v.task,g="",v.task&&(b=this.renderer.checkbox(m),p?v.tokens.length>0&&"text"===v.tokens[0].type?(v.tokens[0].text=b+" "+v.tokens[0].text,v.tokens[0].tokens&&v.tokens[0].tokens.length>0&&"text"===v.tokens[0].tokens[0].type&&(v.tokens[0].tokens[0].text=b+" "+v.tokens[0].tokens[0].text)):v.tokens.unshift({type:"text",text:b}):g+=b),g+=this.parse(v.tokens,p),h+=this.renderer.listitem(g,y,m);S+=this.renderer.list(h,d,f);continue;case"html":S+=this.renderer.html(u.text);continue;case"paragraph":S+=this.renderer.paragraph(this.parseInline(u.tokens));continue;case"text":for(h=u.tokens?this.parseInline(u.tokens):u.text;i+1<E&&"text"===t[i+1].type;)h+="\n"+((u=t[++i]).tokens?this.parseInline(u.tokens):u.text);S+=e?this.renderer.paragraph(h):h;continue;default:var C='Token with "'+u.type+'" type was not found.';if(this.options.silent)return void console.error(C);throw new Error(C)}return S},e.parseInline=function(t,e){e=e||this.renderer;var i,r,n="",s=t.length;for(i=0;i<s;i++)switch((r=t[i]).type){case"escape":n+=e.text(r.text);break;case"html":n+=e.html(r.text);break;case"link":n+=e.link(r.href,r.title,this.parseInline(r.tokens,e));break;case"image":n+=e.image(r.href,r.title,r.text);break;case"strong":n+=e.strong(this.parseInline(r.tokens,e));break;case"em":n+=e.em(this.parseInline(r.tokens,e));break;case"codespan":n+=e.codespan(r.text);break;case"br":n+=e.br();break;case"del":n+=e.del(this.parseInline(r.tokens,e));break;case"text":n+=e.text(r.text);break;default:var a='Token with "'+r.type+'" type was not found.';if(this.options.silent)return void console.error(a);throw new Error(a)}return n},t}(),st=x,at=D,ot=E,lt=r.getDefaults,ct=r.changeDefaults,ht=r.defaults;function ut(t,e,i){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&&(i=e,e=null),e=st({},ut.defaults,e||{}),at(e),i){var r,n=e.highlight;try{r=X.lex(t,e)}catch(t){return i(t)}var s=function(t){var s;if(!t)try{s=nt.parse(r,e)}catch(e){t=e}return e.highlight=n,t?i(t):i(null,s)};if(!n||n.length<3)return s();if(delete e.highlight,!r.length)return s();var a=0;return ut.walkTokens(r,(function(t){"code"===t.type&&(a++,setTimeout((function(){n(t.text,t.lang,(function(e,i){if(e)return s(e);null!=i&&i!==t.text&&(t.text=i,t.escaped=!0),0==--a&&s()}))}),0))})),void(0===a&&s())}try{var o=X.lex(t,e);return e.walkTokens&&ut.walkTokens(o,e.walkTokens),nt.parse(o,e)}catch(t){if(t.message+="\nPlease report this to https://github.com/markedjs/marked.",e.silent)return"<p>An error occurred:</p><pre>"+ot(t.message+"",!0)+"</pre>";throw t}}return ut.options=ut.setOptions=function(t){return st(ut.defaults,t),ct(ut.defaults),ut},ut.getDefaults=lt,ut.defaults=ht,ut.use=function(t){var e=st({},t);if(t.renderer&&function(){var i=ut.defaults.renderer||new J,r=function(e){var r=i[e];i[e]=function(){for(var n=arguments.length,s=new Array(n),a=0;a<n;a++)s[a]=arguments[a];var o=t.renderer[e].apply(i,s);return!1===o&&(o=r.apply(i,s)),o}};for(var n in t.renderer)r(n);e.renderer=i}(),t.tokenizer&&function(){var i=ut.defaults.tokenizer||new B,r=function(e){var r=i[e];i[e]=function(){for(var n=arguments.length,s=new Array(n),a=0;a<n;a++)s[a]=arguments[a];var o=t.tokenizer[e].apply(i,s);return!1===o&&(o=r.apply(i,s)),o}};for(var n in t.tokenizer)r(n);e.tokenizer=i}(),t.walkTokens){var i=ut.defaults.walkTokens;e.walkTokens=function(e){t.walkTokens(e),i&&i(e)}}ut.setOptions(e)},ut.walkTokens=function(t,e){for(var r,n=i(t);!(r=n()).done;){var s=r.value;switch(e(s),s.type){case"table":for(var a,o=i(s.tokens.header);!(a=o()).done;){var l=a.value;ut.walkTokens(l,e)}for(var c,h=i(s.tokens.cells);!(c=h()).done;)for(var u,d=i(c.value);!(u=d()).done;){var f=u.value;ut.walkTokens(f,e)}break;case"list":ut.walkTokens(s.items,e);break;default:s.tokens&&ut.walkTokens(s.tokens,e)}}},ut.Parser=nt,ut.parser=nt.parse,ut.Renderer=J,ut.TextRenderer=tt,ut.Lexer=X,ut.lexer=X.lex,ut.Tokenizer=B,ut.Slugger=et,ut.parse=ut,ut}()},Etsf:
|
|
|
/*!*************************************************!*\
|
|
|
!*** ./src/pages/RestFul/index.tsx + 3 modules ***!
|
|
|
\*************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! all exports used */
|
|
|
/*! 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/defineProperty.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/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/toConsumableArray.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/pages/RestFul/components/LeftBar/index.less?modules (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/pages/RestFul/index.less?modules (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/.umi-production/core/umiExports.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/RenderHtml/index.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/service/restful.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/authority.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/fetch.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/breadcrumb/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/breadcrumb/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/col/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/col/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/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/row/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/row/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/tooltip/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/tooltip/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/tree-select/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/tree-select/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/tree/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/tree/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react-router-dom/esm/react-router-dom.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react-router/esm/react-router.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */function(t,e,i){"use strict";i.r(e);i("5Dmo");var r=i("3S7+"),n=(i("14J3"),i("BMrR")),s=(i("jCWc"),i("kPKH")),a=(i("sPJy"),i("bE4q")),o=i("k1fw"),l=i("9og8"),c=(i("y8nQ"),i("Vl3Y")),h=i("tJVT"),u=i("PpiC"),d=i("WmNS"),f=i.n(d),p=i("q1tI"),g=i.n(p),v=i("55Ip"),m=i("9kvl"),y=i("9Bee"),b=i("xKgJ"),S=i("U/Y8"),E=i.n(S),C=(i("Q9mQ"),i("diRs")),k=(i("miYZ"),i("tsqr")),T=(i("2qtc"),i("kLXV")),w=i("oBTY"),x=(i("ozfa"),i("MJZm")),A=(i("5NDa"),i("5rEg")),L=i("jrin"),R=(i("nRaC"),i("5RzL")),D=i("ErOA"),_=i("Ty5D"),O=(R.a.TreeNode,Object(m.a)((function(t){return{restful:t.restful,loading:t.loading}}))((function(t){var e=t.restful,i=(t.loading,t.dispatch),r=(Object(_.i)(),Object(_.h)(),Object(p.useState)(!1)),a=Object(h.a)(r,2),u=a[0],d=a[1],v=Object(p.useState)(),m=Object(h.a)(v,2),y=(m[0],m[1],e.actionTabs,c.a.useForm()),b=Object(h.a)(y,1)[0];return Object(p.useEffect)((function(){"新建同级目录"==e.actionTabs.key&&b.resetFields()}),[e.actionTabs.key]),"新建同级目录"!==e.actionTabs.key?null:g.a.createElement(T.a,{centered:!0,title:"新建目录",visible:"新建同级目录"===e.actionTabs.key,okText:"确定",cancelText:"取消",bodyStyle:{minHeight:150},confirmLoading:u,onOk:Object(l.a)(f.a.mark((function t(){var e;return f.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.validateFields();case 2:return e=b.getFieldValue(),d(!0),"/api/restfuls.json",t.next=7,Object(D.a)("/api/restfuls.json",{method:"post",body:Object(o.a)({file_type:1},e)});case 7:0===t.sent.status&&(k.b.success("添加成功"),i({type:"restful/setActionTabs",payload:{}}),i({type:"restful/getRestful"})),d(!1);case 10:case"end":return t.stop()}}),t)}))),onCancel:function(){i({type:"restful/setActionTabs",payload:{}})}},g.a.createElement("div",{className:"pl30 pr30"},g.a.createElement(c.a,{form:b,initialValues:Object(L.a)({},"name","")},g.a.createElement(c.a.Item,{name:"name",rules:[{required:!0,message:"请输入目录名称"}]},g.a.createElement(n.a,{className:"mt30"},g.a.createElement(s.a,{flex:"80px",className:"font14"},"目录名称:"),g.a.createElement(s.a,{flex:"1"},g.a.createElement(A.a,{placeholder:"请输入名称,最大限制60个字符 ",maxLength:60})))))))}))),I=(R.a.TreeNode,Object(m.a)((function(t){return{restful:t.restful,loading:t.loading}}))((function(t){var e=t.restful,i=(t.loading,t.dispatch),r=(Object(_.i)(),Object(_.h)(),Object(p.useState)(!1)),a=Object(h.a)(r,2),u=a[0],d=a[1],v=Object(p.useState)(),m=Object(h.a)(v,2),y=(m[0],m[1],e.actionTabs,c.a.useForm()),b=Object(h.a)(y,1)[0];return Object(p.useEffect)((function(){"重命名"==e.actionTabs.key&&(b.resetFields(),b.setFieldsValue({name:e.actionTabs.data.title}))}),[e.actionTabs.key]),"重命名"!==e.actionTabs.key?null:g.a.createElement(T.a,{centered:!0,title:"重命名",visible:"重命名"===e.actionTabs.key,okText:"确定",cancelText:"取消",bodyStyle:{minHeight:150},confirmLoading:u,onOk:Object(l.a)(f.a.mark((function t(){var r,n;return f.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.validateFields();case 2:return r=b.getFieldValue(),d(!0),n="/api/restfuls/".concat(e.actionTabs.data.id,".json"),t.next=7,Object(D.a)(n,{method:"put",body:Object(o.a)({file_type:1},r)});case 7:0===t.sent.status&&(k.b.success("修改成功"),i({type:"restful/setActionTabs",payload:{}}),i({type:"restful/getRestful"})),d(!1);case 10:case"end":return t.stop()}}),t)}))),onCancel:function(){i({type:"restful/setActionTabs",payload:{}})}},g.a.createElement("div",{className:"pl30 pr30"},g.a.createElement(c.a,{form:b,initialValues:Object(L.a)({},"name","")},g.a.createElement(n.a,{className:"mt30"},g.a.createElement(s.a,{flex:"80px",className:"font14"},"目录名称:"),g.a.createElement(s.a,{flex:"1"},g.a.createElement(c.a.Item,{name:"name",rules:[{required:!0,message:"请输入新名称"}]},g.a.createElement(A.a,{placeholder:"请输入名称,最大限制60个字符 ",maxLength:60})))))))}))),P=i("s7vb"),M=i("P48q"),N=i.n(M),B=A.a.Search,F=x.a.DirectoryTree,j=Object(m.a)((function(t){var e=t.user,i=t.loading;return{user:e,globalSetting:t.globalSetting,restful:t.restful,loading:i.models.index}}))((function(t){t.user,t.globalSetting,t.loading;var e=t.dispatch,i=t.restful,r=Object(u.a)(t,["user","globalSetting","loading","dispatch","restful"]),n=Object(p.useState)({content:"",message:"",status:0,contacts:[],address:"",data:[]}),s=Object(h.a)(n,2),a=(s[0],s[1],Object(p.useState)(!0)),d=Object(h.a)(a,2),v=(d[0],d[1],c.a.useForm()),m=(Object(h.a)(v,1)[0],Object(p.useState)("")),y=Object(h.a)(m,2),S=y[0],E=y[1],x=Object(p.useState)([{id:1,name:"新建文件"},{id:2,name:"新建同级目录"},{id:3,name:"重命名"},{id:4,name:"编辑"},{id:5,name:"删除"}]),A=Object(h.a)(x,1)[0],L=Object(p.useState)([]),R=Object(h.a)(L,2),D=R[0],_=R[1],M=Object(p.useState)([]),j=Object(h.a)(M,2),U=j[0],G=j[1],H=Object(p.useState)(!1),V=Object(h.a)(H,2),z=V[0],K=V[1],W=Object(p.useState)([]),Y=Object(h.a)(W,2),q=Y[0],X=Y[1];Object(p.useEffect)((function(){var t;if(null!==(t=i.restful)&&void 0!==t&&t.data){var e,n,s;X(Object(w.a)(null===(e=i.restful)||void 0===e?void 0:e.data));var a,o=0;if(null===(n=i.restful)||void 0===n||null===(s=n.data)||void 0===s||s.map((function(t){var e;t.id==r.match.params.id&&(o=t.id),0!=t.file_type||a||(a=t.id),null==t||null===(e=t.children)||void 0===e||e.map((function(e){a||(a=e.id),e.id==r.match.params.id&&(o=t.id)})),t.children||a||(a=t.id)})),!r.match.params.id&&a)return void r.history.push("/ch/rest/".concat(a));o&&setTimeout((function(){_([o]),G([Number(r.match.params.id||a)])}),200)}}),[i.restful]);var $=function t(i){return i.map((function(i){var n,s=i.title.indexOf(S),a=i.title.substr(0,s),c=i.title.substr(s+S.length),h=g.a.createElement("span",null,a,g.a.createElement("span",{className:"c-blue"},S),c,Object(b.o)()&&g.a.createElement(C.a,{placement:"right",title:S,content:function(){return function(t){return g.a.createElement("div",null,A.map((function(i,n){return g.a.createElement("p",{key:i.id,className:"current",onClick:function(){switch(i.id){case 1:r.history.push("/ch/rest/edit/".concat(t.id,"/0"));break;case 2:case 3:e({type:"restful/setActionTabs",payload:{key:i.name,data:t}});break;case 4:document.location.href="/ch/rest/edit/".concat(t.pid||0,"/").concat(t.id);break;case 5:T.a.confirm({title:"提示",content:"是否确定删除?",onOk:(n=Object(l.a)(f.a.mark((function i(){var r;return f.a.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,Object(P.a)({id:t.id});case 2:0==(null==(r=i.sent)?void 0:r.status)&&(k.b.success("删除成功"),e({type:"restful/getRestful"}));case 4:case"end":return i.stop()}}),i)}))),function(){return n.apply(this,arguments)})})}var n}},i.name)})).filter((function(t){return!!t})).filter((function(e){return t.pid||0==t.file_type?e.key>3:4!=e.key})))}(i)},trigger:"hover"},g.a.createElement("span",{className:"iconfont icon-sandian ".concat(N.a.actions)})));if(""!==S&&(-1===s&&(null===(n=i.children)||void 0===n||!n.length)))return null;return i.children&&1===i.file_type?Object(o.a)(Object(o.a)({},i),{},{title:h,key:i.key,children:t(i.children)}):Object(o.a)(Object(o.a)({},i),{},{title:h,key:i.key,isLeaf:!0})})).filter((function(t){return!!t}))};return console.log("loop(treeData):",$(q)),g.a.createElement("div",{className:N.a.tree},g.a.createElement(B,{style:{marginBottom:8},placeholder:"输入关键字检索",onChange:function(t){var e=t.target.value,i=q.map((function(t){var i;return null!=t&&t.children&&null!=t&&null!==(i=t.children.filter((function(t){return t.title.indexOf(e)>-1})))&&void 0!==i&&i.length?t.id:null}));E(e),K(!0),console.log("expandedKeys:",i),_(i)}}),g.a.createElement(F,{multiple:!0,defaultExpandAll:!0,onSelect:function(t,e){0===e.node.file_type?r.history.push("/ch/rest/".concat(t[0])):G(Object(w.a)(t)),console.log("Trigger Select",t,e)},onExpand:function(t){_(t),console.log("Trigger Expand",t)},expandedKeys:D,selectedKeys:U,autoExpandParent:z,treeData:$(q)}),g.a.createElement(O,null),g.a.createElement(I,null))}));e.default=Object(m.a)((function(t){var e=t.user,i=t.loading;return{user:e,globalSetting:t.globalSetting,restful:t.restful,loading:i.models.index}}))((function(t){t.user,t.globalSetting,t.loading;var e,i,d=t.dispatch,m=t.restful,S=Object(u.a)(t,["user","globalSetting","loading","dispatch","restful"]),C=Object(p.useState)({content:"",message:"",status:0,contacts:[],address:"",data:[]}),k=Object(h.a)(C,2),T=(k[0],k[1],Object(p.useState)(!0)),w=Object(h.a)(T,2),x=(w[0],w[1]),A=c.a.useForm(),L=(Object(h.a)(A,1)[0],S.match.params),R=function(){var t=Object(l.a)(f.a.mark((function t(){return f.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:d({type:"restful/getRestful"}),L.id&&d({type:"restful/getRestfulDetail",payload:Object(o.a)({},L)});case 2:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();Object(p.useEffect)((function(){x(!0),R()}),[L.id]);var D=function(){var t;if(null!==(t=m.restful)&&void 0!==t&&t.data){var e,i,r=0;return null===(e=m.restful)||void 0===e||null===(i=e.data)||void 0===i||i.map((function(t){var e;null==t||null===(e=t.children)||void 0===e||e.map((function(e){e.id==S.match.params.id&&(r=t.id)})),t.children||r||(r=t.id)})),r}return 0};return g.a.createElement("section",null,g.a.createElement("aside",{className:"edu-container mt20"},g.a.createElement(a.a,null,g.a.createElement(a.a.Item,null,g.a.createElement(v.a,{to:"/"},"首页")),g.a.createElement(a.a.Item,null,g.a.createElement(v.a,{to:"/ch/rest"},"API文档"))),g.a.createElement("div",{className:"mt20"},g.a.createElement(n.a,{gutter:[20,20]},g.a.createElement(s.a,{flex:"300px"},g.a.createElement(j,S)),g.a.createElement(s.a,{flex:"1"},g.a.createElement("div",{className:E.a.info},g.a.createElement("h1",{style:{fontSize:28,paddingBottom:15,borderBottom:"1px solid #eaeaea",textAlign:"center"}},null===(e=m.restfulDetail)||void 0===e?void 0:e.name),g.a.createElement(y.a,{value:null===(i=m.restfulDetail)||void 0===i?void 0:i.description}))))),Object(b.o)()&&g.a.createElement("div",{className:E.a.bar},g.a.createElement(n.a,null,!!D()&&g.a.createElement(s.a,null,g.a.createElement(r.a,{title:"编辑文件"},g.a.createElement(v.a,{to:"/ch/rest/edit/".concat(D(),"/").concat(S.match.params.id),className:"icon-zhongmingming current"}))),g.a.createElement(s.a,null,g.a.createElement(r.a,{title:"添加文件"},g.a.createElement(v.a,{to:"/ch/rest/edit/".concat(D(),"/0"),className:"icon-tianjiatimu current"}))),g.a.createElement(s.a,null,g.a.createElement(r.a,{title:"新建文件夹"},g.a.createElement("span",{className:"icon-wenjianjia1 current",onClick:function(){d({type:"restful/setActionTabs",payload:{key:"新建同级目录"}})}})))))))}))},NvD2:
|
|
|
/*!******************************************************!*\
|
|
|
!*** ./node_modules/rc-tree/es/utils/conductUtil.js ***!
|
|
|
\******************************************************/
|
|
|
/*! exports provided: isCheckDisabled, conductCheck */
|
|
|
/*! exports used: conductCheck */function(t,e,i){"use strict";i.d(e,"a",(function(){return a}));var r=i(/*! rc-util/es/warning */"Kwbf");function n(t,e){var i=new Set;return t.forEach((function(t){e.has(t)||i.add(t)})),i}function s(t){var e=t||{},i=e.disabled,r=e.disableCheckbox,n=e.checkable;return!(!i&&!r)||!1===n}function a(t,e,i,a){var o,l=[];o=a||s;var c=new Set(t.filter((function(t){var e=!!i[t];return e||l.push(t),e}))),h=new Map,u=0;return Object.keys(i).forEach((function(t){var e=i[t],r=e.level,n=h.get(r);n||(n=new Set,h.set(r,n)),n.add(e),u=Math.max(u,r)})),Object(r.a)(!l.length,"Tree missing follow keys: ".concat(l.slice(0,100).map((function(t){return"'".concat(t,"'")})).join(", "))),!0===e?function(t,e,i,r){for(var s=new Set(t),a=new Set,o=0;o<=i;o+=1){(e.get(o)||new Set).forEach((function(t){var e=t.key,i=t.node,n=t.children,a=void 0===n?[]:n;s.has(e)&&!r(i)&&a.filter((function(t){return!r(t.node)})).forEach((function(t){s.add(t.key)}))}))}for(var l=new Set,c=i;c>=0;c-=1){(e.get(c)||new Set).forEach((function(t){var e=t.parent,i=t.node;if(!r(i)&&t.parent&&!l.has(t.parent.key))if(r(t.parent.node))l.add(e.key);else{var n=!0,o=!1;(e.children||[]).filter((function(t){return!r(t.node)})).forEach((function(t){var e=t.key,i=s.has(e);n&&!i&&(n=!1),o||!i&&!a.has(e)||(o=!0)})),n&&s.add(e.key),o&&a.add(e.key),l.add(e.key)}}))}return{checkedKeys:Array.from(s),halfCheckedKeys:Array.from(n(a,s))}}(c,h,u,o):function(t,e,i,r,s){for(var a=new Set(t),o=new Set(e),l=0;l<=r;l+=1){(i.get(l)||new Set).forEach((function(t){var e=t.key,i=t.node,r=t.children,n=void 0===r?[]:r;a.has(e)||o.has(e)||s(i)||n.filter((function(t){return!s(t.node)})).forEach((function(t){a.delete(t.key)}))}))}o=new Set;for(var c=new Set,h=r;h>=0;h-=1){(i.get(h)||new Set).forEach((function(t){var e=t.parent,i=t.node;if(!s(i)&&t.parent&&!c.has(t.parent.key))if(s(t.parent.node))c.add(e.key);else{var r=!0,n=!1;(e.children||[]).filter((function(t){return!s(t.node)})).forEach((function(t){var e=t.key,i=a.has(e);r&&!i&&(r=!1),n||!i&&!o.has(e)||(n=!0)})),r||a.delete(e.key),n&&o.add(e.key),c.add(e.key)}}))}return{checkedKeys:Array.from(a),halfCheckedKeys:Array.from(n(o,a))}}(c,e.halfCheckedKeys,h,u,o)}},OZM5:
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./node_modules/rc-tree/es/util.js ***!
|
|
|
\*****************************************/
|
|
|
/*! exports provided: arrDel, arrAdd, posToArr, getPosition, isTreeNode, getDragNodesKeys, calcDropPosition, calcSelectedKeys, convertDataToTree, parseCheckedKeys, conductExpandParent, getDataAndAria */
|
|
|
/*! exports used: arrAdd, arrDel, calcDropPosition, calcSelectedKeys, conductExpandParent, getDataAndAria, getDragNodesKeys, getPosition, isTreeNode, parseCheckedKeys, posToArr */function(t,e,i){"use strict";i.d(e,"b",(function(){return a})),i.d(e,"a",(function(){return o})),i.d(e,"k",(function(){return l})),i.d(e,"h",(function(){return c})),i.d(e,"i",(function(){return h})),i.d(e,"g",(function(){return u})),i.d(e,"c",(function(){return d})),i.d(e,"d",(function(){return f})),i.d(e,"j",(function(){return p})),i.d(e,"e",(function(){return g})),i.d(e,"f",(function(){return v}));var r=i(/*! @babel/runtime/helpers/esm/toConsumableArray */"KQm4"),n=i(/*! @babel/runtime/helpers/esm/typeof */"U8pU"),s=(i(/*! @babel/runtime/helpers/esm/objectWithoutProperties */"Ff2n"),i(/*! react */"q1tI"),i(/*! rc-util/es/warning */"Kwbf"));i(/*! ./TreeNode */"WaYH");function a(t,e){var i=t.slice(),r=i.indexOf(e);return r>=0&&i.splice(r,1),i}function o(t,e){var i=t.slice();return-1===i.indexOf(e)&&i.push(e),i}function l(t){return t.split("-")}function c(t,e){return"".concat(t,"-").concat(e)}function h(t){return t&&t.type&&t.type.isTreeNode}function u(t,e){var i=[t];return function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];e.forEach((function(e){var r=e.key,n=e.children;i.push(r),t(n)}))}(e[t].children),i}function d(t,e){var i=t.clientY,r=e.selectHandle.getBoundingClientRect(),n=r.top,s=r.bottom,a=r.height,o=Math.max(.25*a,2);return i<=n+o?-1:i>=s-o?1:0}function f(t,e){if(t)return e.multiple?t.slice():t.length?[t[0]]:t}function p(t){if(!t)return null;var e;if(Array.isArray(t))e={checkedKeys:t,halfCheckedKeys:void 0};else{if("object"!==Object(n.a)(t))return Object(s.a)(!1,"`checkedKeys` is not an array or an object"),null;e={checkedKeys:t.checked||void 0,halfCheckedKeys:t.halfChecked||void 0}}return e}function g(t,e){var i=new Set;return(t||[]).forEach((function(t){!function t(r){if(!i.has(r)){var n=e[r];if(n){i.add(r);var s=n.parent;n.node.disabled||s&&t(s.key)}}}(t)})),Object(r.a)(i)}function v(t){var e={};return Object.keys(t).forEach((function(i){(i.startsWith("data-")||i.startsWith("aria-"))&&(e[i]=t[i])})),e}},P48q:
|
|
|
/*!*****************************************************************!*\
|
|
|
!*** ./src/pages/RestFul/components/LeftBar/index.less?modules ***!
|
|
|
\*****************************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){t.exports={flex_box_center:"flex_box_center___BHtvi",flex_space_between:"flex_space_between___1noDr",flex_box_vertical_center:"flex_box_vertical_center___2UDAc",flex_box_center_end:"flex_box_center_end___2j8--",flex_box_column:"flex_box_column___3X60k",tree:"tree___2kCYs",actions:"actions___10Q_6"}},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"],i=[[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"],r=[i,"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=[i,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],s=[i,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],a=[i,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],o="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"],h=[e,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],u=/^(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,i,r,n){if(i){var s={sourceNode:t,pre:1,langExtension:null,numberLines:null,sourceCode:i,spans:null,basePos:e,decorations:null};r(s),n.push.apply(n,s.decorations)}}var f=/\S/;function p(t){for(var e=void 0,i=t.firstChild;i;i=i.nextSibling){var r=i.nodeType;e=1===r?e?t:i:3===r&&f.test(i.nodeValue)?t:e}return e===t?void 0:e}function g(t,e){var i,r={};!function(){for(var n=t.concat(e),s=[],a={},o=0,l=n.length;o<l;++o){var c=n[o],h=c[3];if(h)for(var u=h.length;--u>=0;)r[h.charAt(u)]=c;var d=c[1],f=""+d;a.hasOwnProperty(f)||(s.push(d),a[f]=null)}s.push(/[\0-\uffff]/),i=function(t){for(var e=0,i=!1,r=!1,n=0,s=t.length;n<s;++n){if((d=t[n]).ignoreCase)r=!0;else if(/[a-z]/i.test(d.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){i=!0,r=!1;break}}var a={b:8,t:9,n:10,v:11,f:12,r:13};function o(t){var e=t.charCodeAt(0);if(92!==e)return e;var i=t.charAt(1);return(e=a[i])||("0"<=i&&i<="7"?parseInt(t.substring(1),8):"u"===i||"x"===i?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")),i=[],r="^"===e[0],n=["["];r&&n.push("^");for(var s=r?1:0,a=e.length;s<a;++s){var c=e[s];if(/\\[bdsw]/i.test(c))n.push(c);else{var h,u=o(c);s+2<a&&"-"===e[s+1]?(h=o(e[s+2]),s+=2):h=u,i.push([u,h]),h<65||u>122||(h<65||u>90||i.push([32|Math.max(65,u),32|Math.min(h,90)]),h<97||u>122||i.push([-33&Math.max(97,u),-33&Math.min(h,122)]))}}i.sort((function(t,e){return t[0]-e[0]||e[1]-t[1]}));var d=[],f=[];for(s=0;s<i.length;++s){(p=i[s])[0]<=f[1]+1?f[1]=Math.max(f[1],p[1]):d.push(f=p)}for(s=0;s<d.length;++s){var p=d[s];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 h(t){for(var r=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=r.length,s=[],a=0,o=0;a<n;++a){if("("===(u=r[a]))++o;else if("\\"===u.charAt(0)){(h=+u.substring(1))&&(h<=o?s[h]=-1:r[a]=l(h))}}for(a=1;a<s.length;++a)-1===s[a]&&(s[a]=++e);for(a=0,o=0;a<n;++a){if("("===(u=r[a]))s[++o]||(r[a]="(?:");else if("\\"===u.charAt(0)){var h;(h=+u.substring(1))&&h<=o&&(r[a]="\\"+s[h])}}for(a=0;a<n;++a)"^"===r[a]&&"^"!==r[a+1]&&(r[a]="");if(t.ignoreCase&&i)for(a=0;a<n;++a){var u,d=(u=r[a]).charAt(0);u.length>=2&&"["===d?r[a]=c(u):"\\"!==d&&(r[a]=u.replace(/[a-zA-Z]/g,(function(t){var e=t.charCodeAt(0);return"["+String.fromCharCode(-33&e,32|e)+"]"})))}return r.join("")}var u=[];for(n=0,s=t.length;n<s;++n){var d;if((d=t[n]).global||d.multiline)throw new Error(""+d);u.push("(?:"+h(d)+")")}return new RegExp(u.join("|"),r?"gi":"g")}(s)}();var n=e.length,s=function(t){for(var a=t.sourceCode,o=t.basePos,l=t.sourceNode,c=[o,"pln"],h=0,u=a.match(i)||[],f={},p=0,g=u.length;p<g;++p){var v,m=u[p],y=f[m],b=void 0;if("string"==typeof y)v=!1;else{var S=r[m.charAt(0)];if(S)b=m.match(S[1]),y=S[0];else{for(var C=0;C<n;++C)if(S=e[C],b=m.match(S[1])){y=S[0];break}b||(y="pln")}!(v=y.length>=5&&"lang-"===y.substring(0,5))||b&&"string"==typeof b[1]||(v=!1,y="src"),v||(f[m]=y)}var k=h;if(h+=m.length,v){var T=b[1],w=m.indexOf(T),x=w+T.length;b[2]&&(w=(x=m.length-b[2].length)-T.length);var A=y.substring(5);d(l,o+k,m.substring(0,w),s,c),d(l,o+k+w,T,E(A,T),c),d(l,o+k+x,m.substring(x),s,c)}else c.push(o+k,y)}t.decorations=c};return s}function v(t){var e=[],i=[];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&&i.push(["str",/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var r=t.hashComments;r&&(t.cStyleComments?(r>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,"#"]),i.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):e.push(["com",/^#[^\r\n]*/,null,"#"])),t.cStyleComments&&(i.push(["com",/^\/\/[^\r\n]*/,null]),i.push(["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var n=t.regexLiterals;if(n){var s=n>1?"":"\n\r",a=s?".":"[\\S\\s]",o="/(?=[^/*"+s+"])(?:[^/\\x5B\\x5C"+s+"]|\\x5C"+a+"|\\x5B(?:[^\\x5C\\x5D"+s+"]|\\x5C"+a+")*(?:\\x5D|$))+/";i.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+o+")")])}var l=t.types;l&&i.push(["typ",l]);var c=(""+t.keywords).replace(/^ | $/g,"");c.length&&i.push(["kwd",new RegExp("^(?:"+c.replace(/[\s,]+/g,"|")+")\\b"),null]),e.push(["pln",/^\s+/,null," \r\n\t "]);var h="^.[^\\s\\w.$@'\"`/\\\\]*";return t.regexLiterals&&(h+="(?!s*/)"),i.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(h),null]),g(e,i)}var m=v({keywords:[r,s,n,a,o,l,c,h],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function y(t,e,i){for(var r=/(?:^|\s)nocode(?:\s|$)/,n=/\r\n?|\n/,s=t.ownerDocument,a=s.createElement("li");t.firstChild;)a.appendChild(t.firstChild);var o=[a];function l(t){var e=t.nodeType;if(1!=e||r.test(t.className)){if((3==e||4==e)&&i){var a=t.nodeValue,o=a.match(n);if(o){var h=a.substring(0,o.index);t.nodeValue=h;var u=a.substring(o.index+o[0].length);if(u)t.parentNode.insertBefore(s.createTextNode(u),t.nextSibling);c(t),h||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,i=function t(e,i){var r=i?e.cloneNode(!1):e,n=e.parentNode;if(n){var s=t(n,1),a=e.nextSibling;s.appendChild(r);for(var o=a;o;o=a)a=o.nextSibling,s.appendChild(o)}return r}(t.nextSibling,0);(e=i.parentNode)&&1===e.nodeType;)i=e;o.push(i)}for(var h=0;h<o.length;++h)l(o[h]);e===(0|e)&&o[0].setAttribute("value",e);var u=s.createElement("ol");u.className="linenums";for(var d=Math.max(0,e-1|0)||0,f=(h=0,o.length);h<f;++h)(a=o[h]).className="L"+(h+d)%10,a.firstChild||a.appendChild(s.createTextNode(" ")),u.appendChild(a);t.appendChild(u)}var b={};function S(e,i){for(var r=i.length;--r>=0;){var n=i[r];b.hasOwnProperty(n)?t.console&&console.warn("cannot override language handler %s",n):b[n]=e}}function E(t,e){return t&&b.hasOwnProperty(t)||(t=/^\s*</.test(e)?"default-markup":"default-code"),b[t]}function C(e){var i,r,n,s,a,o,l,c=e.langExtension;try{var h=(i=e.sourceNode,r=e.pre,n=/(?:^|\s)nocode(?:\s|$)/,s=[],a=0,o=[],l=0,function t(e){var i=e.nodeType;if(1==i){if(n.test(e.className))return;for(var c=e.firstChild;c;c=c.nextSibling)t(c);var h=e.nodeName.toLowerCase();"br"!==h&&"li"!==h||(s[l]="\n",o[l<<1]=a++,o[l++<<1|1]=e)}else if(3==i||4==i){var u=e.nodeValue;u.length&&(u=r?u.replace(/\r\n?/g,"\n"):u.replace(/[ \t\r\n]+/g," "),s[l]=u,o[l<<1]=a,a+=u.length,o[l++<<1|1]=e)}}(i),{sourceCode:s.join("").replace(/\n$/,""),spans:o}),u=h.sourceCode;e.sourceCode=u,e.spans=h.spans,e.basePos=0,E(c,u)(e),function(t){var e=/\bMSIE\s(\d+)/.exec(navigator.userAgent);e=e&&+e[1]<=8;var i,r,n=/\n/g,s=t.sourceCode,a=s.length,o=0,l=t.spans,c=l.length,h=0,u=t.decorations,d=u.length,f=0;for(u[d]=a,r=i=0;r<d;)u[r]!==u[r+2]?(u[i++]=u[r++],u[i++]=u[r++]):r+=2;for(d=i,r=i=0;r<d;){for(var p=u[r],g=u[r+1],v=r+2;v+2<=d&&u[v+1]===g;)v+=2;u[i++]=p,u[i++]=g,r=v}d=u.length=i;var m=t.sourceNode,y="";m&&(y=m.style.display,m.style.display="none");try{for(;h<c;){l[h];var b,S=l[h+2]||a,E=u[f+2]||a,C=(v=Math.min(S,E),l[h+1]);if(1!==C.nodeType&&(b=s.substring(o,v))){e&&(b=b.replace(n,"\r")),C.nodeValue=b;var k=C.ownerDocument,T=k.createElement("span");T.className=u[f+1];var w=C.parentNode;w.replaceChild(T,C),T.appendChild(C),o<S&&(l[h+1]=C=k.createTextNode(s.substring(v,S)),w.insertBefore(C,T.nextSibling))}(o=v)>=S&&(h+=2),o>=E&&(f+=2)}}finally{m&&(m.style.display=y)}}(e)}catch(e){t.console&&console.log(e&&e.stack||e)}}function k(t,e,i){var r=i||!1,n=e||null,s=document.createElement("div");return s.innerHTML="<pre>"+t+"</pre>",s=s.firstChild,r&&y(s,r,!0),C({langExtension:n,numberLines:r,sourceNode:s,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null}),s.innerHTML}function T(e,i){var r=i||document.body,n=r.ownerDocument||document;function s(t){return r.getElementsByTagName(t)}for(var a=[s("pre"),s("code"),s("xmp")],o=[],l=0;l<a.length;++l)for(var c=0,h=a[l].length;c<h;++c)o.push(a[l][c]);a=null;var u=Date;u.now||(u={now:function(){return+new Date}});var d=0,f=/\blang(?:uage)?-([\w.]+)(?!\S)/,g=/\bprettyprint\b/,v=/\bprettyprinted\b/,m=/pre|xmp/i,b=/^code$/i,S=/^(?:pre|code|xmp)$/i,E={};!function i(){for(var r=t.PR_SHOULD_USE_CONTINUATION?u.now()+250:1/0;d<o.length&&u.now()<r;d++){for(var s=o[d],a=E,l=s;l=l.previousSibling;){var c=l.nodeType,h=(7===c||8===c)&&l.nodeValue;if(h?!/^\??prettify\b/.test(h):3!==c||/\S/.test(l.nodeValue))break;if(h){a={},h.replace(/\b(\w+)=([\w:.%+-]+)/g,(function(t,e,i){a[e]=i}));break}}var k=s.className;if((a!==E||g.test(k))&&!v.test(k)){for(var T=!1,w=s.parentNode;w;w=w.parentNode){var x=w.tagName;if(S.test(x)&&w.className&&g.test(w.className)){T=!0;break}}if(!T){s.className+=" prettyprinted";var A,L,R=a.lang;if(!R)!(R=k.match(f))&&(A=p(s))&&b.test(A.tagName)&&(R=A.className.match(f)),R&&(R=R[1]);if(m.test(s.tagName))L=1;else{var D=s.currentStyle,_=n.defaultView,O=D?D.whiteSpace:_&&_.getComputedStyle?_.getComputedStyle(s,null).getPropertyValue("white-space"):0;L=O&&"pre"===O.substring(0,3)}var I=a.linenums;(I="true"===I||+I)||(I=!!(I=k.match(/\blinenums\b(?::(\d+))?/))&&(!I[1]||!I[1].length||+I[1])),I&&y(s,I,L),C({langExtension:R,sourceNode:s,numberLines:I,pre:L,sourceCode:null,basePos:null,spans:null,decorations:null})}}}d<o.length?t.setTimeout(i,250):"function"==typeof e&&e()}()}S(m,["default-code"]),S(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"]),S(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"]),S(g([],[["atv",/^[\s\S]+/]]),["uq.val"]),S(v({keywords:r,hashComments:!0,cStyleComments:!0,types:u}),["c","cc","cpp","cxx","cyc","m"]),S(v({keywords:"null,true,false"}),["json"]),S(v({keywords:s,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:u}),["cs"]),S(v({keywords:n,cStyleComments:!0}),["java"]),S(v({keywords:h,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),S(v({keywords:l,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),S(v({keywords:o,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),S(v({keywords:c,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),S(v({keywords:a,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),S(v({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"]),S(g([],[["str",/^[\s\S]+/]]),["regex"]);var w=t.PR={createSimpleLexer:g,registerLangHandler:S,sourceDecorator:v,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:k,prettyPrint:T},x=t.define;"function"==typeof x&&x.amd&&x("google-code-prettify",[],(function(){return w}))}()},"U/Y8":
|
|
|
/*!**********************************************!*\
|
|
|
!*** ./src/pages/RestFul/index.less?modules ***!
|
|
|
\**********************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){t.exports={flex_box_center:"flex_box_center___2aRVA",flex_space_between:"flex_space_between___12c3F",flex_box_vertical_center:"flex_box_vertical_center___30OYS",flex_box_center_end:"flex_box_center_end___12QBt",flex_box_column:"flex_box_column___t6urT",info:"info___2BaCz",bar:"bar___3Aega"}},WaYH:
|
|
|
/*!*********************************************************!*\
|
|
|
!*** ./node_modules/rc-tree/es/TreeNode.js + 1 modules ***!
|
|
|
\*********************************************************/
|
|
|
/*! exports provided: InternalTreeNode, default */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js */
|
|
|
/*! 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/classnames/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/contextTypes.js because of ./node_modules/rc-tree/es/Tree.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/util.js because of ./node_modules/antd/es/table/hooks/useSelection.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/utils/treeUtil.js because of ./node_modules/antd/es/table/hooks/useSelection.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */function(t,e,i){"use strict";var r=i("rePB"),n=i("Ff2n"),s=i("VTBJ"),a=i("1OyB"),o=i("vuIU"),l=i("JX7q"),c=i("Ji7U"),h=i("LK+K"),u=i("q1tI"),d=i("TSYQ"),f=i.n(d),p=i("sboe"),g=i("OZM5"),v=function(t){var e=t.prefixCls,i=t.level,n=t.isStart,s=t.isEnd;if(!i)return null;for(var a="".concat(e,"-indent-unit"),o=[],l=0;l<i;l+=1){var c;o.push(u.createElement("span",{key:l,className:f()(a,(c={},Object(r.a)(c,"".concat(a,"-start"),n[l+1]),Object(r.a)(c,"".concat(a,"-end"),s[l+1]),Object(r.a)(c,"".concat(a,"-end-first-level"),!l&&s[0]),c))}))}return u.createElement("span",{"aria-hidden":"true",className:"".concat(e,"-indent")},o)},m=i("815F"),y=function(t){Object(c.a)(i,t);var e=Object(h.a)(i);function i(){var t;return Object(a.a)(this,i),(t=e.apply(this,arguments)).state={dragNodeHighlight:!1},t.onSelectorClick=function(e){(0,t.props.context.onNodeClick)(e,Object(m.b)(t.props)),t.isSelectable()?t.onSelect(e):t.onCheck(e)},t.onSelectorDoubleClick=function(e){(0,t.props.context.onNodeDoubleClick)(e,Object(m.b)(t.props))},t.onSelect=function(e){if(!t.isDisabled()){var i=t.props.context.onNodeSelect;e.preventDefault(),i(e,Object(m.b)(t.props))}},t.onCheck=function(e){if(!t.isDisabled()){var i=t.props,r=i.disableCheckbox,n=i.checked,s=t.props.context.onNodeCheck;if(t.isCheckable()&&!r){e.preventDefault();var a=!n;s(e,Object(m.b)(t.props),a)}}},t.onMouseEnter=function(e){(0,t.props.context.onNodeMouseEnter)(e,Object(m.b)(t.props))},t.onMouseLeave=function(e){(0,t.props.context.onNodeMouseLeave)(e,Object(m.b)(t.props))},t.onContextMenu=function(e){(0,t.props.context.onNodeContextMenu)(e,Object(m.b)(t.props))},t.onDragStart=function(e){var i=t.props.context.onNodeDragStart;e.stopPropagation(),t.setState({dragNodeHighlight:!0}),i(e,Object(l.a)(t));try{e.dataTransfer.setData("text/plain","")}catch(t){}},t.onDragEnter=function(e){var i=t.props.context.onNodeDragEnter;e.preventDefault(),e.stopPropagation(),i(e,Object(l.a)(t))},t.onDragOver=function(e){var i=t.props.context.onNodeDragOver;e.preventDefault(),e.stopPropagation(),i(e,Object(l.a)(t))},t.onDragLeave=function(e){var i=t.props.context.onNodeDragLeave;e.stopPropagation(),i(e,Object(l.a)(t))},t.onDragEnd=function(e){var i=t.props.context.onNodeDragEnd;e.stopPropagation(),t.setState({dragNodeHighlight:!1}),i(e,Object(l.a)(t))},t.onDrop=function(e){var i=t.props.context.onNodeDrop;e.preventDefault(),e.stopPropagation(),t.setState({dragNodeHighlight:!1}),i(e,Object(l.a)(t))},t.onExpand=function(e){(0,t.props.context.onNodeExpand)(e,Object(m.b)(t.props))},t.setSelectHandle=function(e){t.selectHandle=e},t.getNodeState=function(){var e=t.props.expanded;return t.isLeaf()?null:e?"open":"close"},t.hasChildren=function(){var e=t.props.eventKey;return!!((t.props.context.keyEntities[e]||{}).children||[]).length},t.isLeaf=function(){var e=t.props,i=e.isLeaf,r=e.loaded,n=t.props.context.loadData,s=t.hasChildren();return!1!==i&&(i||!n&&!s||n&&r&&!s)},t.isDisabled=function(){var e=t.props.disabled;return!(!t.props.context.disabled&&!e)},t.isCheckable=function(){var e=t.props.checkable,i=t.props.context.checkable;return!(!i||!1===e)&&i},t.syncLoadData=function(e){var i=e.expanded,r=e.loading,n=e.loaded,s=t.props.context,a=s.loadData,o=s.onNodeLoad;r||a&&i&&!t.isLeaf()&&(t.hasChildren()||n||o(Object(m.b)(t.props)))},t.renderSwitcher=function(){var e=t.props,i=e.expanded,r=e.switcherIcon,n=t.props.context,a=n.prefixCls,o=n.switcherIcon,l=r||o;if(t.isLeaf())return u.createElement("span",{className:f()("".concat(a,"-switcher"),"".concat(a,"-switcher-noop"))},"function"==typeof l?l(Object(s.a)(Object(s.a)({},t.props),{},{isLeaf:!0})):l);var c=f()("".concat(a,"-switcher"),"".concat(a,"-switcher_").concat(i?"open":"close"));return u.createElement("span",{onClick:t.onExpand,className:c},"function"==typeof l?l(Object(s.a)(Object(s.a)({},t.props),{},{isLeaf:!1})):l)},t.renderCheckbox=function(){var e=t.props,i=e.checked,r=e.halfChecked,n=e.disableCheckbox,s=t.props.context.prefixCls,a=t.isDisabled(),o=t.isCheckable();if(!o)return null;var l="boolean"!=typeof o?o:null;return u.createElement("span",{className:f()("".concat(s,"-checkbox"),i&&"".concat(s,"-checkbox-checked"),!i&&r&&"".concat(s,"-checkbox-indeterminate"),(a||n)&&"".concat(s,"-checkbox-disabled")),onClick:t.onCheck},l)},t.renderIcon=function(){var e=t.props.loading,i=t.props.context.prefixCls;return u.createElement("span",{className:f()("".concat(i,"-iconEle"),"".concat(i,"-icon__").concat(t.getNodeState()||"docu"),e&&"".concat(i,"-icon_loading"))})},t.renderSelector=function(){var e,i,r=t.state.dragNodeHighlight,n=t.props,s=n.title,a=n.selected,o=n.icon,l=n.loading,c=n.data,h=t.props.context,d=h.prefixCls,p=h.showIcon,g=h.icon,v=h.draggable,m=h.loadData,y=h.titleRender,b=t.isDisabled(),S="".concat(d,"-node-content-wrapper");if(p){var E=o||g;e=E?u.createElement("span",{className:f()("".concat(d,"-iconEle"),"".concat(d,"-icon__customize"))},"function"==typeof E?E(t.props):E):t.renderIcon()}else m&&l&&(e=t.renderIcon());i="function"==typeof s?s(c):y?y(c):s;var C=u.createElement("span",{className:"".concat(d,"-title")},i);return u.createElement("span",{ref:t.setSelectHandle,title:"string"==typeof s?s:"",className:f()("".concat(S),"".concat(S,"-").concat(t.getNodeState()||"normal"),!b&&(a||r)&&"".concat(d,"-node-selected"),!b&&v&&"draggable"),draggable:!b&&v||void 0,"aria-grabbed":!b&&v||void 0,onMouseEnter:t.onMouseEnter,onMouseLeave:t.onMouseLeave,onContextMenu:t.onContextMenu,onClick:t.onSelectorClick,onDoubleClick:t.onSelectorDoubleClick,onDragStart:v?t.onDragStart:void 0},e,C)},t}return Object(o.a)(i,[{key:"componentDidMount",value:function(){this.syncLoadData(this.props)}},{key:"componentDidUpdate",value:function(){this.syncLoadData(this.props)}},{key:"isSelectable",value:function(){var t=this.props.selectable,e=this.props.context.selectable;return"boolean"==typeof t?t:e}},{key:"render",value:function(){var t,e=this.props,i=e.eventKey,s=e.className,a=e.style,o=e.dragOver,l=e.dragOverGapTop,c=e.dragOverGapBottom,h=e.isLeaf,d=e.isStart,p=e.isEnd,y=e.expanded,b=e.selected,S=e.checked,E=e.halfChecked,C=e.loading,k=e.domRef,T=e.active,w=e.onMouseMove,x=Object(n.a)(e,["eventKey","className","style","dragOver","dragOverGapTop","dragOverGapBottom","isLeaf","isStart","isEnd","expanded","selected","checked","halfChecked","loading","domRef","active","onMouseMove"]),A=this.props.context,L=A.prefixCls,R=A.filterTreeNode,D=A.draggable,_=A.keyEntities,O=this.isDisabled(),I=Object(g.f)(x),P=(_[i]||{}).level,M=p[p.length-1];return u.createElement("div",Object.assign({ref:k,className:f()(s,"".concat(L,"-treenode"),(t={},Object(r.a)(t,"".concat(L,"-treenode-disabled"),O),Object(r.a)(t,"".concat(L,"-treenode-switcher-").concat(y?"open":"close"),!h),Object(r.a)(t,"".concat(L,"-treenode-checkbox-checked"),S),Object(r.a)(t,"".concat(L,"-treenode-checkbox-indeterminate"),E),Object(r.a)(t,"".concat(L,"-treenode-selected"),b),Object(r.a)(t,"".concat(L,"-treenode-loading"),C),Object(r.a)(t,"".concat(L,"-treenode-active"),T),Object(r.a)(t,"".concat(L,"-treenode-leaf-last"),M),Object(r.a)(t,"drag-over",!O&&o),Object(r.a)(t,"drag-over-gap-top",!O&&l),Object(r.a)(t,"drag-over-gap-bottom",!O&&c),Object(r.a)(t,"filter-node",R&&R(Object(m.b)(this.props))),t)),style:a,onDragEnter:D?this.onDragEnter:void 0,onDragOver:D?this.onDragOver:void 0,onDragLeave:D?this.onDragLeave:void 0,onDrop:D?this.onDrop:void 0,onDragEnd:D?this.onDragEnd:void 0,onMouseMove:w},I),u.createElement(v,{prefixCls:L,level:P,isStart:d,isEnd:p}),this.renderSwitcher(),this.renderCheckbox(),this.renderSelector())}}]),i}(u.Component),b=function(t){return u.createElement(p.a.Consumer,null,(function(e){return u.createElement(y,Object.assign({},t,{context:e}))}))};b.displayName="TreeNode",b.defaultProps={title:"---"},b.isTreeNode=1;e.a=b},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,i){"use strict";i.r(e),i.d(e,"ResizableTextArea",(function(){return I}));var r=i("wx14"),n=i("1OyB"),s=i("vuIU"),a=i("Ji7U"),o=i("LK+K"),l=i("q1tI"),c=i("VTBJ"),h=i("rePB"),u=i("Zm9Q"),d=(i("Kwbf"),i("c+Xe")),f=i("m+aA"),p=i("bdgK"),g=new Map;var v=new p.default((function(t){t.forEach((function(t){var e,i=t.target;null===(e=g.get(i))||void 0===e||e.forEach((function(t){return t(i)}))}))}));var m=function(t){Object(a.a)(i,t);var e=Object(o.a)(i);function i(){return Object(n.a)(this,i),e.apply(this,arguments)}return Object(s.a)(i,[{key:"render",value:function(){return this.props.children}}]),i}(l.Component),y=l.createContext(null);function b(t){var e=t.children,i=t.disabled,r=l.useRef(null),n=l.useRef(null),s=l.useContext(y),a=l.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),o=l.isValidElement(e)&&Object(d.c)(e),h=o?e.ref:null,u=l.useMemo((function(){return Object(d.a)(h,r)}),[h,r]),p=l.useRef(t);p.current=t;var b=l.useCallback((function(t){var e=p.current,i=e.onResize,r=e.data,n=t.getBoundingClientRect(),o=n.width,l=n.height,h=t.offsetWidth,u=t.offsetHeight,d=Math.floor(o),f=Math.floor(l);if(a.current.width!==d||a.current.height!==f||a.current.offsetWidth!==h||a.current.offsetHeight!==u){var g={width:d,height:f,offsetWidth:h,offsetHeight:u};a.current=g;var v=h===Math.round(o)?o:h,m=u===Math.round(l)?l:u,y=Object(c.a)(Object(c.a)({},g),{},{offsetWidth:v,offsetHeight:m});null==s||s(y,t,r),i&&Promise.resolve().then((function(){i(y,t)}))}}),[]);return l.useEffect((function(){var t,e,s=Object(f.a)(r.current)||Object(f.a)(n.current);return s&&!i&&(t=s,e=b,g.has(t)||(g.set(t,new Set),v.observe(t)),g.get(t).add(e)),function(){return function(t,e){g.has(t)&&(g.get(t).delete(e),g.get(t).size||(v.unobserve(t),g.delete(t)))}(s,b)}}),[r.current,i]),l.createElement(m,{ref:n},o?l.cloneElement(e,{ref:u}):e)}function S(t){var e=t.children;return Object(u.a)(e).map((function(e,i){var n=(null==e?void 0:e.key)||"".concat("rc-observer-key","-").concat(i);return l.createElement(b,Object(r.a)({},t,{key:n}),e)}))}S.Collection=function(t){var e=t.children,i=t.onBatchResize,r=l.useRef(0),n=l.useRef([]),s=l.useContext(y),a=l.useCallback((function(t,e,a){r.current+=1;var o=r.current;n.current.push({size:t,element:e,data:a}),Promise.resolve().then((function(){o===r.current&&(null==i||i(n.current),n.current=[])})),null==s||s(t,e,a)}),[i,s]);return l.createElement(y.Provider,{value:a},e)};var E,C=S,k=i("bT9E"),T=i("TSYQ"),w=i.n(T),x="\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",A=["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"],L={};function R(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=t.getAttribute("id")||t.getAttribute("data-reactid")||t.getAttribute("name");if(e&&L[i])return L[i];var r=window.getComputedStyle(t),n=r.getPropertyValue("box-sizing")||r.getPropertyValue("-moz-box-sizing")||r.getPropertyValue("-webkit-box-sizing"),s=parseFloat(r.getPropertyValue("padding-bottom"))+parseFloat(r.getPropertyValue("padding-top")),a=parseFloat(r.getPropertyValue("border-bottom-width"))+parseFloat(r.getPropertyValue("border-top-width")),o=A.map((function(t){return"".concat(t,":").concat(r.getPropertyValue(t))})).join(";"),l={sizingStyle:o,paddingSize:s,borderSize:a,boxSizing:n};return e&&i&&(L[i]=l),l}var D,_=i("Gytx"),O=i.n(_);!function(t){t[t.NONE=0]="NONE",t[t.RESIZING=1]="RESIZING",t[t.RESIZED=2]="RESIZED"}(D||(D={}));var I=function(t){Object(a.a)(i,t);var e=Object(o.a)(i);function i(t){var s;return Object(n.a)(this,i),(s=e.call(this,t)).nextFrameActionId=void 0,s.resizeFrameId=void 0,s.textArea=void 0,s.saveTextArea=function(t){s.textArea=t},s.handleResize=function(t){var e=s.state.resizeStatus,i=s.props,r=i.autoSize,n=i.onResize;e===D.NONE&&("function"==typeof n&&n(t),r&&s.resizeOnNextFrame())},s.resizeOnNextFrame=function(){cancelAnimationFrame(s.nextFrameActionId),s.nextFrameActionId=requestAnimationFrame(s.resizeTextarea)},s.resizeTextarea=function(){var t=s.props.autoSize;if(t&&s.textArea){var e=t.minRows,i=t.maxRows,r=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;E||((E=document.createElement("textarea")).setAttribute("tab-index","-1"),E.setAttribute("aria-hidden","true"),document.body.appendChild(E)),t.getAttribute("wrap")?E.setAttribute("wrap",t.getAttribute("wrap")):E.removeAttribute("wrap");var n=R(t,e),s=n.paddingSize,a=n.borderSize,o=n.boxSizing,l=n.sizingStyle;E.setAttribute("style","".concat(l,";").concat(x)),E.value=t.value||t.placeholder||"";var c,h=Number.MIN_SAFE_INTEGER,u=Number.MAX_SAFE_INTEGER,d=E.scrollHeight;if("border-box"===o?d+=a:"content-box"===o&&(d-=s),null!==i||null!==r){E.value=" ";var f=E.scrollHeight-s;null!==i&&(h=f*i,"border-box"===o&&(h=h+s+a),d=Math.max(h,d)),null!==r&&(u=f*r,"border-box"===o&&(u=u+s+a),c=d>u?"":"hidden",d=Math.min(u,d))}return{height:d,minHeight:h,maxHeight:u,overflowY:c,resize:"none"}}(s.textArea,!1,e,i);s.setState({textareaStyles:r,resizeStatus:D.RESIZING},(function(){cancelAnimationFrame(s.resizeFrameId),s.resizeFrameId=requestAnimationFrame((function(){s.setState({resizeStatus:D.RESIZED},(function(){s.resizeFrameId=requestAnimationFrame((function(){s.setState({resizeStatus:D.NONE}),s.fixFirefoxAutoScroll()}))}))}))}))}},s.renderTextArea=function(){var t=s.props,e=t.prefixCls,i=void 0===e?"rc-textarea":e,n=t.autoSize,a=t.onResize,o=t.className,u=t.disabled,d=s.state,f=d.textareaStyles,p=d.resizeStatus,g=Object(k.a)(s.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),v=w()(i,o,Object(h.a)({},"".concat(i,"-disabled"),u));"value"in g&&(g.value=g.value||"");var m=Object(c.a)(Object(c.a)(Object(c.a)({},s.props.style),f),p===D.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return l.createElement(C,{onResize:s.handleResize,disabled:!(n||a)},l.createElement("textarea",Object(r.a)({},g,{className:v,style:m,ref:s.saveTextArea})))},s.state={textareaStyles:{},resizeStatus:D.NONE},s}return Object(s.a)(i,[{key:"componentDidUpdate",value:function(t){t.value===this.props.value&&O()(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()}}]),i}(l.Component),P=function(t){Object(a.a)(i,t);var e=Object(o.a)(i);function i(t){var r;Object(n.a)(this,i),(r=e.call(this,t)).resizableTextArea=void 0,r.focus=function(){r.resizableTextArea.textArea.focus()},r.saveTextArea=function(t){r.resizableTextArea=t},r.handleChange=function(t){var e=r.props.onChange;r.setValue(t.target.value,(function(){r.resizableTextArea.resizeTextarea()})),e&&e(t)},r.handleKeyDown=function(t){var e=r.props,i=e.onPressEnter,n=e.onKeyDown;13===t.keyCode&&i&&i(t),n&&n(t)};var s=void 0===t.value||null===t.value?t.defaultValue:t.value;return r.state={value:s},r}return Object(s.a)(i,[{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(r.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}}]),i}(l.Component);e.default=P},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,i){"use strict";i.d(e,"a",(function(){return m}));var r=i("k1fw"),n=(i("miYZ"),i("tsqr")),s=i("rAM+"),a=i("tJVT"),o=i("PpiC"),l=i("q1tI"),c=i.n(l),h=i("bdgK");function u(t,e,i,n,s){var a=e.getWordUntilPosition(i),o={startLineNumber:i.lineNumber,endLineNumber:i.lineNumber,startColumn:a.startColumn,endColumn:a.endColumn},l=n.map((function(e){return{label:e,kind:t.languages.CompletionItemKind.Keyword,insertText:e,insertTextRules:t.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:o}}));return s.map((function(t){l.push(Object(r.a)(Object(r.a)({},t),{},{range:o}))})),l}i("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 i=0;i<t.length;i++){var r=p[t[i]];if(r)return r}return e[0]}return p[e]||e}var v=null;e.b=function(t){var e=t.width,p=void 0===e?"100%":e,m=t.height,y=void 0===m?"100%":m,b=t.value,S=t.language,E=void 0===S?"javascript":S,C=t.style,k=void 0===C?{}:C,T=t.options,w=void 0===T?{}:T,x=t.overrideServices,A=void 0===x?{}:x,L=t.theme,R=void 0===L?"vs-dark":L,D=t.onEditBlur,_=t.onSave,O=t.autoHeight,I=void 0!==O&&O,P=t.forbidCopy,M=void 0!==P&&P,N=t.onChange,B=void 0===N?f:N,F=t.editorDidMount,j=void 0===F?f:F,U=t.onFocus,G=void 0===U?f:U,H=t.filename,V=void 0===H?"educoder.txt":H,z=(Object(o.a)(t,["width","height","value","language","style","options","overrideServices","theme","onEditBlur","onSave","autoHeight","forbidCopy","onChange","editorDidMount","onFocus","filename"]),Object(l.useRef)()),K=Object(l.useRef)({}),W=Object(l.useRef)(),Y=Object(l.useRef)(!1),q=Object(l.useRef)(),X=Object(l.useState)(!1),$=Object(a.a)(X,2),Z=$[0],Q=$[1];function J(){n.b.warn(decodeURIComponent("该任务关卡设置了禁止复制粘贴,请手动输入代码。"))}function tt(){var t=K.current.instance;if(t){var e=t.getSelection(),i=K.current.pastePos||{},r=new v.Range(i.startLineNumber||e.endLineNumber,i.startColumn||e.endColumn,i.endLineNumber||e.endLineNumber,i.endColumn||e.endColumn);setTimeout((function(){t.executeEdits("",[{range:r,text:""}])}),300)}}function et(t){(window.navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)&&83==t.keyCode&&(t.preventDefault(),_())}Object(l.useEffect)((function(){W.current&&clearTimeout(W.current),W.current=setTimeout((function(){!function(){var t=K.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,K.current]);var it=function(){if(I&&K.current.instance){var t=K.current.instance.getContentHeight();ht(t<y?y:t)}else ht(y)};function rt(t,e){var i,r,n=window.URL||window.webkitURL||window,s=new Blob([e]),a=document.createElementNS("http://www.w3.org/1999/xhtml","a");a.href=n.createObjectURL(s),a.download=t,i=a,(r=document.createEvent("MouseEvents")).initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),i.dispatchEvent(r)}Object(l.useEffect)((function(){it()}),[it]),Object(l.useEffect)((function(){z.current&&!Z&&i.e(/*! import() | monaco-editor */27).then(i.t.bind(null,/*! monaco-editor/esm/vs/editor/editor.api.js */"M/lh",7)).then((function(t){try{v=t,K.current.instance=v.editor.create(z.current,{value:b,language:g(E),theme:R,requireConfig:{"vs/nls":{availableLanguages:{"*":"zh-cn"}}},wordWrap:!0},A);var e=K.current.instance;if(j(e,v),setTimeout((function(){it(),K.current.instance.addAction({id:"d123123",label:"Download File",contextMenuGroupId:"9_cutcopypaste",run:function(){rt(V||"educoder.txt",e.getValue())}})}),500),K.current.subscription=e.onDidChangeModelContent((function(t){Y.current?clearTimeout(q.current):(it(),B(e.getValue(),t)),q.current=setTimeout((function(){Y.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},i=["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(r,n){return{suggestions:u(t,r,n,i,[e])}}});var r=["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,i){var n=[{label:"print",kind:t.languages.CompletionItemKind.Snippet,insertText:["print($0)"].join("\n"),insertTextRules:t.languages.CompletionItemInsertTextRule.InsertAsSnippet}];return{suggestions:u(t,e,i,r,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(i,r){var s=[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:u(t,i,r,n,s)}}})}(v),M&&(e.addCommand(v.KeyMod.CtrlCmd|v.KeyMod.Shift|v.KeyCode.KEY_V,(function(){return J(),null})),e.addCommand(v.KeyMod.CtrlCmd|v.KeyCode.KEY_C,(function(){return J(),null}))),window.Monaco=v,D&&e.onDidBlurEditorWidget((function(){D(e.getValue())})),G&&e.onDidFocusEditorText((function(){G(e.getValue())})),M){e.addCommand(v.KeyMod.CtrlCmd|v.KeyCode.KEY_V,(function(){return J(),null})),e.onDidPaste((function(t){K.current.pastePos=t}));try{window.addEventListener("paste",tt)}catch(t){}}var i=function(){var t;return z.current&&(t=new h.default((function(t){var e,i=Object(s.a)(t);try{for(i.s();!(e=i.n()).done;){var r=e.value;(r.target.offsetHeight>0||r.target.offsetWidth>0)&&K.current.instance.layout()}}catch(t){i.e(t)}finally{i.f()}}))).observe(z.current),t}();return Q(!0),function(){var t=K.current.instance;t.dispose();var e=t.getModel();e&&e.dispose(),K.current.subscription&&K.current.subscription.dispose(),M&&window.removeEventListener("paste",tt),i.unobserve(z.current)}}catch(t){}}))}),[]),Object(l.useEffect)((function(){if(K.current.instance&&Z)return document.addEventListener("keydown",et,!1),function(){document.removeEventListener("keydown",et)}}),[_,Z]),Object(l.useEffect)((function(){var t=K.current.instance;if(t&&Z){var e=g(E);v.editor.setModelLanguage(t.getModel(),e),console.log("language:",E,t.getModel(),e)}}),[E,Z]),Object(l.useEffect)((function(){K.current.instance&&Z&&v.editor.setTheme(R)}),[R,Z]),Object(l.useEffect)((function(){var t=K.current.instance;t&&Z&&(t.updateOptions(Object(r.a)({},w)),setTimeout((function(){t.getModel().updateOptions(Object(r.a)({},w))}),200))}),[JSON.stringify(w),Z]),Object(l.useEffect)((function(){var t=K.current.instance;t&&Z&&t.layout()}),[p,y,Z]);var nt=Object(l.useState)(d(p)),st=Object(a.a)(nt,2),at=st[0],ot=(st[1],Object(l.useState)(d(y))),lt=Object(a.a)(ot,2),ct=lt[0],ht=lt[1],ut=Object(r.a)(Object(r.a)({},k),{},{width:at,height:ct});return c.a.createElement("div",{className:"my-monaco-editor",ref:z,style:ut})};function m(t){var e=t.width,n=void 0===e?"100%":e,o=t.height,u=void 0===o?"100%":o,f=t.original,p=t.modified,g=t.language,m=t.options,y=void 0===m?{}:m,b=Object(l.useRef)(),S=Object(l.useState)(null),E=Object(a.a)(S,2),C=E[0],k=E[1];Object(l.useEffect)((function(){b.current&&i.e(/*! import() | monaco-editor */27).then(i.t.bind(null,/*! monaco-editor/esm/vs/editor/editor.api.js */"M/lh",7)).then((function(t){var e=(v=t).editor.createDiffEditor(b.current,Object(r.a)(Object(r.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}));k(e);var i=function(t){var e;return b.current&&(e=new h.default((function(e){var i,r=Object(s.a)(e);try{for(r.s();!(i=r.n()).done;){var n=i.value;(n.target.offsetHeight>0||n.target.offsetWidth>0)&&t.layout()}}catch(t){r.e(t)}finally{r.f()}}))).observe(b.current),e}(e);return function(){e.dispose();var t=e.getModel();t&&t.dispose(),i.unobserve(b.current)}}))}),[]),Object(l.useEffect)((function(){C&&C.setModel({original:v.editor.createModel(f,g),modified:v.editor.createModel(p,g)})}),[f,p,g,C]);var T={width:d(n),height:d(u)};return c.a.createElement("div",{className:"my-diff-editor",ref:b,style:T})}},ZpRC:
|
|
|
/*!*************************************************************************!*\
|
|
|
!*** ./node_modules/scroll-into-view-if-needed/es/index.js + 1 modules ***!
|
|
|
\*************************************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,i){"use strict";function r(t){return"object"==typeof t&&null!=t&&1===t.nodeType}function n(t,e){return(!e||"hidden"!==t)&&"visible"!==t&&"clip"!==t}function s(t,e){if(t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth){var i=getComputedStyle(t,null);return n(i.overflowY,e)||n(i.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 a(t,e,i,r,n,s,a,o){return s<t&&a>e||s>t&&a<e?0:s<=t&&o<=i||a>=e&&o>=i?s-t-r:a>e&&o<i||s<t&&o>i?a-e+n:0}var o=function(t,e){var i=window,n=e.scrollMode,o=e.block,l=e.inline,c=e.boundary,h=e.skipOverflowHiddenElements,u="function"==typeof c?c:function(t){return t!==c};if(!r(t))throw new TypeError("Invalid target");for(var d=document.scrollingElement||document.documentElement,f=[],p=t;r(p)&&u(p);){if((p=p.parentElement)===d){f.push(p);break}null!=p&&p===document.body&&s(p)&&!s(document.documentElement)||null!=p&&s(p,h)&&f.push(p)}for(var g=i.visualViewport?i.visualViewport.width:innerWidth,v=i.visualViewport?i.visualViewport.height:innerHeight,m=window.scrollX||pageXOffset,y=window.scrollY||pageYOffset,b=t.getBoundingClientRect(),S=b.height,E=b.width,C=b.top,k=b.right,T=b.bottom,w=b.left,x="start"===o||"nearest"===o?C:"end"===o?T:C+S/2,A="center"===l?w+E/2:"end"===l?k:w,L=[],R=0;R<f.length;R++){var D=f[R],_=D.getBoundingClientRect(),O=_.height,I=_.width,P=_.top,M=_.right,N=_.bottom,B=_.left;if("if-needed"===n&&C>=0&&w>=0&&T<=v&&k<=g&&C>=P&&T<=N&&w>=B&&k<=M)return L;var F=getComputedStyle(D),j=parseInt(F.borderLeftWidth,10),U=parseInt(F.borderTopWidth,10),G=parseInt(F.borderRightWidth,10),H=parseInt(F.borderBottomWidth,10),V=0,z=0,K="offsetWidth"in D?D.offsetWidth-D.clientWidth-j-G:0,W="offsetHeight"in D?D.offsetHeight-D.clientHeight-U-H:0;if(d===D)V="start"===o?x:"end"===o?x-v:"nearest"===o?a(y,y+v,v,U,H,y+x,y+x+S,S):x-v/2,z="start"===l?A:"center"===l?A-g/2:"end"===l?A-g:a(m,m+g,g,j,G,m+A,m+A+E,E),V=Math.max(0,V+y),z=Math.max(0,z+m);else{V="start"===o?x-P-U:"end"===o?x-N+H+W:"nearest"===o?a(P,N,O,U,H+W,x,x+S,S):x-(P+O/2)+W/2,z="start"===l?A-B-j:"center"===l?A-(B+I/2)+K/2:"end"===l?A-M+G+K:a(B,M,I,j,G+K,A,A+E,E);var Y=D.scrollLeft,q=D.scrollTop;x+=q-(V=Math.max(0,Math.min(q+V,D.scrollHeight-O+W))),A+=Y-(z=Math.max(0,Math.min(Y+z,D.scrollWidth-I+K)))}L.push({el:D,top:V,left:z})}return L};function l(t){return t===Object(t)&&0!==Object.keys(t).length}e.a=function(t,e){var i=!t.ownerDocument.documentElement.contains(t);if(l(e)&&"function"==typeof e.behavior)return e.behavior(i?[]:o(t,e));if(!i){var r=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 i="scrollBehavior"in document.body.style;t.forEach((function(t){var r=t.el,n=t.top,s=t.left;r.scroll&&i?r.scroll({top:n,left:s,behavior:e}):(r.scrollTop=n,r.scrollLeft=s)}))}(o(t,r),r.behavior)}}},bT9E:
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./node_modules/rc-util/es/omit.js ***!
|
|
|
\*****************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,i){"use strict";i.d(e,"a",(function(){return n}));var r=i(/*! @babel/runtime/helpers/esm/objectSpread2 */"VTBJ");function n(t,e){var i=Object(r.a)({},t);return Array.isArray(e)&&e.forEach((function(t){delete i[t]})),i}},fAei:
|
|
|
/*!******************************************************!*\
|
|
|
!*** ./node_modules/rc-tree/es/index.js + 4 modules ***!
|
|
|
\******************************************************/
|
|
|
/*! exports provided: TreeNode, default */
|
|
|
/*! exports used: TreeNode, 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/toConsumableArray.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-motion/es/index.js (<- Module is referenced from these modules with unsupported syntax: ./node_modules/antd/lib/button/LoadingIcon.js (referenced with cjs require)) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/TreeNode.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/contextTypes.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/util.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/utils/conductUtil.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/utils/treeUtil.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/KeyCode.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,i){"use strict";i.d(e,"a",(function(){return C.a}));var r=i("rePB"),n=i("VTBJ"),s=i("KQm4"),a=i("1OyB"),o=i("vuIU"),l=i("Ji7U"),c=i("LK+K"),h=i("q1tI"),u=i("4IlW"),d=i("Kwbf"),f=i("TSYQ"),p=i.n(f),g=i("sboe"),v=i("OZM5"),m=i("815F"),y=i("ODXe"),b=i("Ff2n"),S=i("+nKL"),E=i("8XRh"),C=i("WaYH"),k=function(t,e){var i=t.className,r=t.style,n=t.motion,s=t.motionNodes,a=t.motionType,o=t.onMotionStart,l=t.onMotionEnd,c=t.active,u=t.treeNodeRequiredProps,d=Object(b.a)(t,["className","style","motion","motionNodes","motionType","onMotionStart","onMotionEnd","active","treeNodeRequiredProps"]),f=h.useState(!0),v=Object(y.a)(f,2),S=v[0],k=v[1],T=h.useContext(g.a).prefixCls,w=h.useRef(!1),x=function(){w.current||l(),w.current=!0};return Object(h.useEffect)((function(){s&&"hide"===a&&S&&k(!1)}),[s]),Object(h.useEffect)((function(){return s&&o(),function(){s&&x()}}),[]),s?h.createElement(E.default,Object.assign({ref:e,visible:S},n,{motionAppear:"show"===a,onAppearEnd:x,onLeaveEnd:x}),(function(t,e){var i=t.className,r=t.style;return h.createElement("div",{ref:e,className:p()("".concat(T,"-treenode-motion"),i),style:r},s.map((function(t){var e=t.data,i=e.key,r=Object(b.a)(e,["key"]),n=t.isStart,s=t.isEnd;delete r.children;var a=Object(m.f)(i,u);return h.createElement(C.a,Object.assign({},r,a,{active:c,data:t.data,key:i,isStart:n,isEnd:s}))})))})):h.createElement(C.a,Object.assign({domRef:e,className:i,style:r},d,{active:c}))};k.displayName="MotionTreeNode";var T=h.forwardRef(k);function w(t,e,i){var r=t.findIndex((function(t){return t.data.key===i})),n=t[r+1],s=e.findIndex((function(t){return t.data.key===i}));if(n){var a=e.findIndex((function(t){return t.data.key===n.data.key}));return e.slice(s+1,a)}return e.slice(s+1)}var x={width:0,height:0,display:"flex",overflow:"hidden",opacity:0,border:0,padding:0,margin:0},A=function(){},L="RC_TREE_MOTION_".concat(Math.random()),R={key:L},D={key:L,level:0,index:0,pos:"0",node:R},_={parent:null,children:[],pos:D.pos,data:R,isStart:[],isEnd:[]};function O(t,e,i,r){return!1!==e&&i?t.slice(0,Math.ceil(i/r)+1):t}function I(t){var e=t.data.key,i=t.pos;return Object(m.e)(e,i)}var P=h.forwardRef((function(t,e){var i=t.prefixCls,r=t.data,n=(t.selectable,t.checkable,t.expandedKeys),s=t.selectedKeys,a=t.checkedKeys,o=t.loadedKeys,l=t.loadingKeys,c=t.halfCheckedKeys,u=t.keyEntities,d=t.disabled,f=t.dragging,p=t.dragOverNodeKey,g=t.dropPosition,v=t.motion,E=t.height,C=t.itemHeight,k=t.virtual,R=t.focusable,D=t.activeItem,P=t.focused,M=t.tabIndex,N=t.onKeyDown,B=t.onFocus,F=t.onBlur,j=t.onActiveChange,U=t.onListChangeStart,G=t.onListChangeEnd,H=Object(b.a)(t,["prefixCls","data","selectable","checkable","expandedKeys","selectedKeys","checkedKeys","loadedKeys","loadingKeys","halfCheckedKeys","keyEntities","disabled","dragging","dragOverNodeKey","dropPosition","motion","height","itemHeight","virtual","focusable","activeItem","focused","tabIndex","onKeyDown","onFocus","onBlur","onActiveChange","onListChangeStart","onListChangeEnd"]),V=h.useRef(null);h.useImperativeHandle(e,(function(){return{scrollTo:function(t){V.current.scrollTo(t)}}}));var z=h.useState(n),K=Object(y.a)(z,2),W=K[0],Y=K[1],q=h.useState(r),X=Object(y.a)(q,2),$=X[0],Z=X[1],Q=h.useState(r),J=Object(y.a)(Q,2),tt=J[0],et=J[1],it=h.useState([]),rt=Object(y.a)(it,2),nt=rt[0],st=rt[1],at=h.useState(null),ot=Object(y.a)(at,2),lt=ot[0],ct=ot[1];function ht(){Z(r),et(r),st([]),ct(null),G()}h.useEffect((function(){Y(n);var t=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=t.length,r=e.length;if(1!==Math.abs(i-r))return{add:!1,key:null};function n(t,e){var i=new Map;t.forEach((function(t){i.set(t,!0)}));var r=e.filter((function(t){return!i.has(t)}));return 1===r.length?r[0]:null}return i<r?{add:!0,key:n(t,e)}:{add:!1,key:n(e,t)}}(W,n);if(null!==t.key)if(t.add){var e=$.findIndex((function(e){return e.data.key===t.key})),i=O(w($,r,t.key),k,E,C),s=$.slice();s.splice(e+1,0,_),et(s),st(i),ct("show")}else{var a=r.findIndex((function(e){return e.data.key===t.key})),o=O(w(r,$,t.key),k,E,C),l=r.slice();l.splice(a+1,0,_),et(l),st(o),ct("hide")}else $!==r&&(Z(r),et(r))}),[n,r]),h.useEffect((function(){f||ht()}),[f]);var ut=v?tt:r,dt={expandedKeys:n,selectedKeys:s,loadedKeys:o,loadingKeys:l,checkedKeys:a,halfCheckedKeys:c,dragOverNodeKey:p,dropPosition:g,keyEntities:u};return h.createElement(h.Fragment,null,P&&D&&h.createElement("span",{style:x,"aria-live":"assertive"},function(t){for(var e=String(t.data.key),i=t;i.parent;)i=i.parent,e="".concat(i.data.key," > ").concat(e);return e}(D)),h.createElement("div",{role:"tree"},h.createElement("input",{style:x,disabled:!1===R||d,tabIndex:!1!==R?M:null,onKeyDown:N,onFocus:B,onBlur:F,value:"",onChange:A})),h.createElement(S.a,Object.assign({},H,{data:ut,itemKey:I,height:E,fullHeight:!1,virtual:k,itemHeight:C,prefixCls:"".concat(i,"-list"),ref:V}),(function(t){var e=t.pos,i=t.data,r=i.key,n=Object(b.a)(i,["key"]),s=t.isStart,a=t.isEnd,o=Object(m.e)(r,e);delete n.children;var l=Object(m.f)(o,dt);return h.createElement(T,Object.assign({},n,l,{active:D&&r===D.data.key,pos:e,data:t.data,isStart:s,isEnd:a,motion:v,motionNodes:r===L?nt:null,motionType:lt,onMotionStart:U,onMotionEnd:ht,treeNodeRequiredProps:dt,onMouseMove:function(){j(null)}}))})))}));P.displayName="NodeList";var M=P,N=i("NvD2"),B=function(t){Object(l.a)(i,t);var e=Object(c.a)(i);function i(){var t;return Object(a.a)(this,i),(t=e.apply(this,arguments)).destroyed=!1,t.state={keyEntities:{},selectedKeys:[],checkedKeys:[],halfCheckedKeys:[],loadedKeys:[],loadingKeys:[],expandedKeys:[],dragging:!1,dragNodesKeys:[],dragOverNodeKey:null,dropPosition:null,treeData:[],flattenNodes:[],focused:!1,activeKey:null,listChanging:!1,prevProps:null},t.listRef=h.createRef(),t.onNodeDragStart=function(e,i){var r=t.state,n=r.expandedKeys,s=r.keyEntities,a=t.props.onDragStart,o=i.props.eventKey;t.dragNode=i;var l=Object(v.b)(n,o);t.setState({dragging:!0,dragNodesKeys:Object(v.g)(o,s)}),t.setExpandedKeys(l),a&&a({event:e,node:Object(m.b)(i.props)})},t.onNodeDragEnter=function(e,i){var r=t.state,n=r.expandedKeys,a=r.keyEntities,o=r.dragNodesKeys,l=t.props.onDragEnter,c=i.props,h=c.pos,u=c.eventKey;if(t.dragNode&&-1===o.indexOf(u)){var d=Object(v.c)(e,i);t.dragNode.props.eventKey!==u||0!==d?setTimeout((function(){t.setState({dragOverNodeKey:u,dropPosition:d}),t.delayedDragEnterLogic||(t.delayedDragEnterLogic={}),Object.keys(t.delayedDragEnterLogic).forEach((function(e){clearTimeout(t.delayedDragEnterLogic[e])})),t.delayedDragEnterLogic[h]=window.setTimeout((function(){if(t.state.dragging){var r=Object(s.a)(n),o=a[u];o&&(o.children||[]).length&&(r=Object(v.a)(n,u)),"expandedKeys"in t.props||t.setExpandedKeys(r),l&&l({event:e,node:Object(m.b)(i.props),expandedKeys:r})}}),400)}),0):t.setState({dragOverNodeKey:"",dropPosition:null})}},t.onNodeDragOver=function(e,i){var r=t.state.dragNodesKeys,n=t.props.onDragOver,s=i.props.eventKey;if(-1===r.indexOf(s)){if(t.dragNode&&s===t.state.dragOverNodeKey){var a=Object(v.c)(e,i);if(a===t.state.dropPosition)return;t.setState({dropPosition:a})}n&&n({event:e,node:Object(m.b)(i.props)})}},t.onNodeDragLeave=function(e,i){var r=t.props.onDragLeave;t.setState({dragOverNodeKey:""}),r&&r({event:e,node:Object(m.b)(i.props)})},t.onNodeDragEnd=function(e,i){var r=t.props.onDragEnd;t.setState({dragOverNodeKey:""}),t.cleanDragState(),r&&r({event:e,node:Object(m.b)(i.props)}),t.dragNode=null},t.onNodeDrop=function(e,i){var r=t.state,n=r.dragNodesKeys,s=void 0===n?[]:n,a=r.dropPosition,o=t.props.onDrop,l=i.props,c=l.eventKey,h=l.pos;if(t.setState({dragOverNodeKey:""}),t.cleanDragState(),-1===s.indexOf(c)){var u=Object(v.k)(h),f={event:e,node:Object(m.b)(i.props),dragNode:t.dragNode?Object(m.b)(t.dragNode.props):null,dragNodesKeys:s.slice(),dropPosition:a+Number(u[u.length-1]),dropToGap:!1};0!==a&&(f.dropToGap=!0),o&&o(f),t.dragNode=null}else Object(d.a)(!1,"Can not drop to dragNode(include it's children node)")},t.cleanDragState=function(){t.state.dragging&&t.setState({dragging:!1})},t.onNodeClick=function(e,i){var r=t.props.onClick;r&&r(e,i)},t.onNodeDoubleClick=function(e,i){var r=t.props.onDoubleClick;r&&r(e,i)},t.onNodeSelect=function(e,i){var r=t.state.selectedKeys,n=t.state.keyEntities,s=t.props,a=s.onSelect,o=s.multiple,l=i.selected,c=i.key,h=!l,u=(r=h?o?Object(v.a)(r,c):[c]:Object(v.b)(r,c)).map((function(t){var e=n[t];return e?e.node:null})).filter((function(t){return t}));t.setUncontrolledState({selectedKeys:r}),a&&a(r,{event:"select",selected:h,node:i,selectedNodes:u,nativeEvent:e.nativeEvent})},t.onNodeCheck=function(e,i,r){var n,a=t.state,o=a.keyEntities,l=a.checkedKeys,c=a.halfCheckedKeys,h=t.props,u=h.checkStrictly,d=h.onCheck,f=i.key,p={event:"check",node:i,checked:r,nativeEvent:e.nativeEvent};if(u){var g=r?Object(v.a)(l,f):Object(v.b)(l,f);n={checked:g,halfChecked:Object(v.b)(c,f)},p.checkedNodes=g.map((function(t){return o[t]})).filter((function(t){return t})).map((function(t){return t.node})),t.setUncontrolledState({checkedKeys:g})}else{var m=Object(N.a)([].concat(Object(s.a)(l),[f]),!0,o),y=m.checkedKeys,b=m.halfCheckedKeys;if(!r){var S=new Set(y);S.delete(f);var E=Object(N.a)(Array.from(S),{checked:!1,halfCheckedKeys:b},o);y=E.checkedKeys,b=E.halfCheckedKeys}n=y,p.checkedNodes=[],p.checkedNodesPositions=[],p.halfCheckedKeys=b,y.forEach((function(t){var e=o[t];if(e){var i=e.node,r=e.pos;p.checkedNodes.push(i),p.checkedNodesPositions.push({node:i,pos:r})}})),t.setUncontrolledState({checkedKeys:y},!1,{halfCheckedKeys:b})}d&&d(n,p)},t.onNodeLoad=function(e){return new Promise((function(i){t.setState((function(r){var n=r.loadedKeys,s=void 0===n?[]:n,a=r.loadingKeys,o=void 0===a?[]:a,l=t.props,c=l.loadData,h=l.onLoad,u=e.key;return c&&-1===s.indexOf(u)&&-1===o.indexOf(u)?(c(e).then((function(){var r=t.state,n=r.loadedKeys,s=r.loadingKeys,a=Object(v.a)(n,u),o=Object(v.b)(s,u);h&&h(a,{event:"load",node:e}),t.setUncontrolledState({loadedKeys:a}),t.setState({loadingKeys:o}),i()})),{loadingKeys:Object(v.a)(o,u)}):{}}))}))},t.onNodeMouseEnter=function(e,i){var r=t.props.onMouseEnter;r&&r({event:e,node:i})},t.onNodeMouseLeave=function(e,i){var r=t.props.onMouseLeave;r&&r({event:e,node:i})},t.onNodeContextMenu=function(e,i){var r=t.props.onRightClick;r&&(e.preventDefault(),r({event:e,node:i}))},t.onFocus=function(){var e=t.props.onFocus;t.setState({focused:!0}),e&&e.apply(void 0,arguments)},t.onBlur=function(){var e=t.props.onBlur;t.setState({focused:!1}),t.onActiveChange(null),e&&e.apply(void 0,arguments)},t.getTreeNodeRequiredProps=function(){var e=t.state;return{expandedKeys:e.expandedKeys||[],selectedKeys:e.selectedKeys||[],loadedKeys:e.loadedKeys||[],loadingKeys:e.loadingKeys||[],checkedKeys:e.checkedKeys||[],halfCheckedKeys:e.halfCheckedKeys||[],dragOverNodeKey:e.dragOverNodeKey,dropPosition:e.dropPosition,keyEntities:e.keyEntities}},t.setExpandedKeys=function(e){var i=t.state.treeData,r=Object(m.d)(i,e);t.setUncontrolledState({expandedKeys:e,flattenNodes:r},!0)},t.onNodeExpand=function(e,i){var r=t.state.expandedKeys,n=t.state.listChanging,s=t.props,a=s.onExpand,o=s.loadData,l=i.key,c=i.expanded;if(!n){var h=r.indexOf(l),u=!c;if(Object(d.a)(c&&-1!==h||!c&&-1===h,"Expand state not sync with index check"),r=u?Object(v.a)(r,l):Object(v.b)(r,l),t.setExpandedKeys(r),a&&a(r,{node:i,expanded:u,nativeEvent:e.nativeEvent}),u&&o){var f=t.onNodeLoad(i);f&&f.then((function(){var e=Object(m.d)(t.state.treeData,r);t.setUncontrolledState({flattenNodes:e})}))}}},t.onListChangeStart=function(){t.setUncontrolledState({listChanging:!0})},t.onListChangeEnd=function(){setTimeout((function(){t.setUncontrolledState({listChanging:!1})}))},t.onActiveChange=function(e){var i=t.state.activeKey,r=t.props.onActiveChange;i!==e&&(t.setState({activeKey:e}),null!==e&&t.scrollTo({key:e}),r&&r(e))},t.getActiveItem=function(){var e=t.state,i=e.activeKey,r=e.flattenNodes;return null===i?null:r.find((function(t){return t.data.key===i}))||null},t.offsetActiveKey=function(e){var i=t.state,r=i.flattenNodes,n=i.activeKey,s=r.findIndex((function(t){return t.data.key===n}));-1===s&&e<0&&(s=r.length);var a=r[s=(s+e+r.length)%r.length];if(a){var o=a.data.key;t.onActiveChange(o)}else t.onActiveChange(null)},t.onKeyDown=function(e){var i=t.state,r=i.activeKey,s=i.expandedKeys,a=i.checkedKeys,o=t.props,l=o.onKeyDown,c=o.checkable,h=o.selectable;switch(e.which){case u.a.UP:t.offsetActiveKey(-1),e.preventDefault();break;case u.a.DOWN:t.offsetActiveKey(1),e.preventDefault()}var d=t.getActiveItem();if(d&&d.data){var f=t.getTreeNodeRequiredProps(),p=!1===d.data.isLeaf||!!(d.data.children||[]).length,g=Object(m.b)(Object(n.a)(Object(n.a)({},Object(m.f)(r,f)),{},{data:d.data,active:!0}));switch(e.which){case u.a.LEFT:p&&s.includes(r)?t.onNodeExpand({},g):d.parent&&t.onActiveChange(d.parent.data.key),e.preventDefault();break;case u.a.RIGHT:p&&!s.includes(r)?t.onNodeExpand({},g):d.children&&d.children.length&&t.onActiveChange(d.children[0].data.key),e.preventDefault();break;case u.a.ENTER:case u.a.SPACE:!c||g.disabled||!1===g.checkable||g.disableCheckbox?c||!h||g.disabled||!1===g.selectable||t.onNodeSelect({},g):t.onNodeCheck({},g,!a.includes(r))}}l&&l(e)},t.setUncontrolledState=function(e){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!t.destroyed){var s=!1,a=!0,o={};Object.keys(e).forEach((function(i){i in t.props?a=!1:(s=!0,o[i]=e[i])})),!s||i&&!a||t.setState(Object(n.a)(Object(n.a)({},o),r))}},t.scrollTo=function(e){t.listRef.current.scrollTo(e)},t}return Object(o.a)(i,[{key:"componentWillUnmount",value:function(){this.destroyed=!0}},{key:"render",value:function(){var t,e=this.state,i=e.focused,n=e.flattenNodes,s=e.keyEntities,a=e.dragging,o=e.activeKey,l=this.props,c=l.prefixCls,u=l.className,d=l.style,f=l.showLine,m=l.focusable,y=l.tabIndex,b=void 0===y?0:y,S=l.selectable,E=l.showIcon,C=l.icon,k=l.switcherIcon,T=l.draggable,w=l.checkable,x=l.checkStrictly,A=l.disabled,L=l.motion,R=l.loadData,D=l.filterTreeNode,_=l.height,O=l.itemHeight,I=l.virtual,P=l.titleRender,N=l.onContextMenu,B=Object(v.f)(this.props);return h.createElement(g.a.Provider,{value:{prefixCls:c,selectable:S,showIcon:E,icon:C,switcherIcon:k,draggable:T,checkable:w,checkStrictly:x,disabled:A,keyEntities:s,loadData:R,filterTreeNode:D,titleRender:P,onNodeClick:this.onNodeClick,onNodeDoubleClick:this.onNodeDoubleClick,onNodeExpand:this.onNodeExpand,onNodeSelect:this.onNodeSelect,onNodeCheck:this.onNodeCheck,onNodeLoad:this.onNodeLoad,onNodeMouseEnter:this.onNodeMouseEnter,onNodeMouseLeave:this.onNodeMouseLeave,onNodeContextMenu:this.onNodeContextMenu,onNodeDragStart:this.onNodeDragStart,onNodeDragEnter:this.onNodeDragEnter,onNodeDragOver:this.onNodeDragOver,onNodeDragLeave:this.onNodeDragLeave,onNodeDragEnd:this.onNodeDragEnd,onNodeDrop:this.onNodeDrop}},h.createElement("div",{className:p()(c,u,(t={},Object(r.a)(t,"".concat(c,"-show-line"),f),Object(r.a)(t,"".concat(c,"-focused"),i),Object(r.a)(t,"".concat(c,"-active-focused"),null!==o),t))},h.createElement(M,Object.assign({ref:this.listRef,prefixCls:c,style:d,data:n,disabled:A,selectable:S,checkable:!!w,motion:L,dragging:a,height:_,itemHeight:O,virtual:I,focusable:m,focused:i,tabIndex:b,activeItem:this.getActiveItem(),onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onActiveChange:this.onActiveChange,onListChangeStart:this.onListChangeStart,onListChangeEnd:this.onListChangeEnd,onContextMenu:N},this.getTreeNodeRequiredProps(),B))))}}],[{key:"getDerivedStateFromProps",value:function(t,e){var i,s=e.prevProps,a={prevProps:t};function o(e){return!s&&e in t||s&&s[e]!==t[e]}if(o("treeData")?i=t.treeData:o("children")&&(Object(d.a)(!1,"`children` of Tree is deprecated. Please use `treeData` instead."),i=Object(m.c)(t.children)),i){a.treeData=i;var l=Object(m.a)(i);a.keyEntities=Object(n.a)(Object(r.a)({},L,D),l.keyEntities)}var c,h=a.keyEntities||e.keyEntities;if(o("expandedKeys")||s&&o("autoExpandParent"))a.expandedKeys=t.autoExpandParent||!s&&t.defaultExpandParent?Object(v.e)(t.expandedKeys,h):t.expandedKeys;else if(!s&&t.defaultExpandAll){var u=Object(n.a)({},h);delete u[L],a.expandedKeys=Object.keys(u).map((function(t){return u[t].key}))}else!s&&t.defaultExpandedKeys&&(a.expandedKeys=t.autoExpandParent||t.defaultExpandParent?Object(v.e)(t.defaultExpandedKeys,h):t.defaultExpandedKeys);if(a.expandedKeys||delete a.expandedKeys,i||a.expandedKeys){var f=Object(m.d)(i||e.treeData,a.expandedKeys||e.expandedKeys);a.flattenNodes=f}if((t.selectable&&(o("selectedKeys")?a.selectedKeys=Object(v.d)(t.selectedKeys,t):!s&&t.defaultSelectedKeys&&(a.selectedKeys=Object(v.d)(t.defaultSelectedKeys,t))),t.checkable)&&(o("checkedKeys")?c=Object(v.j)(t.checkedKeys)||{}:!s&&t.defaultCheckedKeys?c=Object(v.j)(t.defaultCheckedKeys)||{}:i&&(c=Object(v.j)(t.checkedKeys)||{checkedKeys:e.checkedKeys,halfCheckedKeys:e.halfCheckedKeys}),c)){var p=c,g=p.checkedKeys,y=void 0===g?[]:g,b=p.halfCheckedKeys,S=void 0===b?[]:b;if(!t.checkStrictly){var E=Object(N.a)(y,!0,h);y=E.checkedKeys,S=E.halfCheckedKeys}a.checkedKeys=y,a.halfCheckedKeys=S}return o("loadedKeys")&&(a.loadedKeys=t.loadedKeys),a}}]),i}(h.Component);B.defaultProps={prefixCls:"rc-tree",showLine:!1,showIcon:!0,selectable:!0,multiple:!1,checkable:!1,disabled:!1,checkStrictly:!1,draggable:!1,defaultExpandParent:!0,autoExpandParent:!1,defaultExpandAll:!1,defaultExpandedKeys:[],defaultCheckedKeys:[],defaultSelectedKeys:[]},B.TreeNode=C.a;var F=B;e.b=F},p5ED:
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./src/components/PreviewAll/index.tsx ***!
|
|
|
\*********************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,i){"use strict";i(/*! antd/es/button/style */"+L6B");var r=i(/*! antd/es/button */"2/Rp"),n=(i(/*! antd/es/tooltip/style */"5Dmo"),i(/*! antd/es/tooltip */"3S7+")),s=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2 */"k1fw"),a=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray */"tJVT"),o=i(/*! react */"q1tI"),l=i.n(o),c=i(/*! ./index.less?modules */"vHTk"),h=i.n(c),u=i(/*! @ant-design/icons */"yEEn"),d=i(/*! @/components/monaco-editor */"ZW9T"),f=i(/*! @/utils/util */"1vsH");e.a=function(t){var e=t.name,i=t.data,c=(t.theme,t.type),p=t.filename,g=t.monacoEditor,v=t.className,m=t.style,y=t.close,b=t.onClose,S=t.hasMask,E=Object(o.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),C=Object(a.a)(E,2),k=(C[0],C[1],Object(o.useState)("")),T=Object(a.a)(k,2),w=(T[0],T[1]),x=Object(o.useRef)();p&&(g.filename=p),Object(o.useEffect)((function(){var t,e,i=null===(t=document.cookie)||void 0===t||null===(e=t.replace(/\s/g,""))||void 0===e?void 0:e.split(";");null==i||i.map((function(t){var e=t.split("=");"_educoder_session"===e[0]&&w(e[1])}))}),[]);var A=function(){i.startsWith("http")||i.startsWith("/")?L():Object(f.x)(p||"educoder",i,p)},L=function(){Object(f.v)(p||e,i)};return console.log("data:",i,"fileanme:",p," name:",e),l.a.createElement("div",{style:Object(s.a)({},m||{}),className:"".concat(S&&h.a.bgBlack," ").concat(c?h.a.wrp:"hide")},y&&l.a.createElement("div",{className:h.a.close,ref:x},l.a.createElement(n.a,{title:"点击下载此文件",getPopupContainer:function(){return x.current}},l.a.createElement("span",{onClick:L},l.a.createElement("i",{className:"icon-quxiaozhiding"}))),l.a.createElement(n.a,{title:"关闭",getPopupContainer:function(){return x.current}},l.a.createElement("span",{className:"",onClick:b},l.a.createElement("i",{className:"icon-guanbi1"})))),l.a.createElement("div",{className:"".concat(h.a[v]," ").concat(v," ").concat(h.a.monaco," ").concat("txt"===c?"show":"hide")},"txt"===c&&l.a.createElement(d.b,g)),"audio"===c&&l.a.createElement("audio",{src:"".concat(null!=i&&i.startsWith("/")||(null==i?void 0:i.indexOf("https://"))>-1?i:"data:audio/mp3;base64,").concat(i),autoPlay:!0}),"video"===c&&l.a.createElement(l.a.Fragment,null,null!=i&&i.startsWith("/")?l.a.createElement("video",{controls:!0,src:"".concat(i),autoPlay:!0}):l.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(i),autoPlay:!0})),"html"===c&&l.a.createElement("iframe",{src:i+"&disposition=inline"}),"pdf"===c&&l.a.createElement("embed",{className:h.a.embed,src:i}),"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!=i&&i.startsWith("/")||(null==i?void 0:i.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(i)})),"other"===c&&l.a.createElement("div",null,l.a.createElement(r.a,{type:"primary",size:"large",onClick:A},l.a.createElement(u.a,null),"点击下载")),("download"===c||"office"===c)&&l.a.createElement(r.a,{type:"primary",size:"large",onClick:A},l.a.createElement(u.a,null),"点击下载"))}},"rAM+":
|
|
|
/*!*******************************************************************************************************************!*\
|
|
|
!*** ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js ***!
|
|
|
\*******************************************************************************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,i){"use strict";i.d(e,"a",(function(){return n}));var r=i(/*! @babel/runtime/helpers/esm/unsupportedIterableToArray */"Qw5x");function n(t,e){var i;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(i=Object(r.a)(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0,s=function(){};return{s:s,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:s}}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 a,o=!0,l=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==i.return||i.return()}finally{if(l)throw a}}}}},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 i=/[&<>"']/,r=/[&<>"']/g,n=/[<>"']|&(?!#?\w+;)/,s=/[<>"']|&(?!#?\w+;)/g,a={"&":"&","<":"<",">":">",'"':""","'":"'"},o=t=>a[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 h=/(^|[^\[])\^/g;const u=/[^\w:]/g,d=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;const f={},p=/^[^:]+:\/*[^/]*$/,g=/^([^:]+:)[\s\S]*$/,v=/^([^:]+:\/*[^/]*)[\s\S]*$/;function m(t,e){f[" "+t]||(p.test(t)?f[" "+t]=t+"/":f[" "+t]=y(t,"/",!0));const i=-1===(t=f[" "+t]).indexOf(":");return"//"===e.substring(0,2)?i?e:t.replace(g,"$1")+e:"/"===e.charAt(0)?i?e:t.replace(v,"$1")+e:t+e}function y(t,e,i){const r=t.length;if(0===r)return"";let n=0;for(;n<r;){const s=t.charAt(r-n-1);if(s!==e||i){if(s===e||!i)break;n++}else n++}return t.substr(0,r-n)}t.exports={escape:function(t,e){if(e){if(i.test(t))return t.replace(r,o)}else if(n.test(t))return t.replace(s,o);return t},unescape:c,edit:function(t,e){t=t.source||t,e=e||"";const i={replace:(e,r)=>(r=(r=r.source||r).replace(h,"$1"),t=t.replace(e,r),i),getRegex:()=>new RegExp(t,e)};return i},cleanUrl:function(t,e,i){if(t){let t;try{t=decodeURIComponent(c(i)).replace(u,"").toLowerCase()}catch(t){return null}if(0===t.indexOf("javascript:")||0===t.indexOf("vbscript:")||0===t.indexOf("data:"))return null}e&&!d.test(i)&&(i=m(e,i));try{i=encodeURI(i).replace(/%25/g,"%")}catch(t){return null}return i},resolveUrl:m,noopTest:{exec:function(){}},merge:function(t){let e,i,r=1;for(;r<arguments.length;r++)for(i in e=arguments[r],e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},splitCells:function(t,e){const i=t.replace(/\|/g,(t,e,i)=>{let r=!1,n=e;for(;--n>=0&&"\\"===i[n];)r=!r;return r?"|":" |"}).split(/ \|/);let r=0;if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;r<i.length;r++)i[r]=i[r].trim().replace(/\\\|/g,"|");return i},rtrim:y,findClosingBracket:function(t,e){if(-1===t.indexOf(e[1]))return-1;const i=t.length;let r=0,n=0;for(;n<i;n++)if("\\"===t[n])n++;else if(t[n]===e[0])r++;else if(t[n]===e[1]&&(r--,r<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")}}},sboe:
|
|
|
/*!*************************************************!*\
|
|
|
!*** ./node_modules/rc-tree/es/contextTypes.js ***!
|
|
|
\*************************************************/
|
|
|
/*! exports provided: TreeContext */
|
|
|
/*! exports used: TreeContext */function(t,e,i){"use strict";i.d(e,"a",(function(){return n}));var r=i(/*! react */"q1tI"),n=r.createContext(null)},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,i){var r;"undefined"!=typeof window&&(r=function(){return function(t){var e={};function i(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(r,n,function(e){return t[e]}.bind(null,n));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/dist/",i(i.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./node_modules/eventemitter3/index.js ***!
|
|
|
\*********************************************/
|
|
|
/*! no static exports found */function(t,e,i){"use strict";var r=Object.prototype.hasOwnProperty,n="~";function s(){}function a(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function o(t,e,i,r,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new a(i,r||t,s),l=n?n+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],o]:t._events[l].push(o):(t._events[l]=o,t._eventsCount++),t}function l(t,e){0==--t._eventsCount?t._events=new s:delete t._events[e]}function c(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(n=!1)),c.prototype.eventNames=function(){var t,e,i=[];if(0===this._eventsCount)return i;for(e in t=this._events)r.call(t,e)&&i.push(n?e.slice(1):e);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},c.prototype.listeners=function(t){var e=n?n+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,s=i.length,a=new Array(s);r<s;r++)a[r]=i[r].fn;return a},c.prototype.listenerCount=function(t){var e=n?n+t:t,i=this._events[e];return i?i.fn?1:i.length:0},c.prototype.emit=function(t,e,i,r,s,a){var o=n?n+t:t;if(!this._events[o])return!1;var l,c,h=this._events[o],u=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),u){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,i),!0;case 4:return h.fn.call(h.context,e,i,r),!0;case 5:return h.fn.call(h.context,e,i,r,s),!0;case 6:return h.fn.call(h.context,e,i,r,s,a),!0}for(c=1,l=new Array(u-1);c<u;c++)l[c-1]=arguments[c];h.fn.apply(h.context,l)}else{var d,f=h.length;for(c=0;c<f;c++)switch(h[c].once&&this.removeListener(t,h[c].fn,void 0,!0),u){case 1:h[c].fn.call(h[c].context);break;case 2:h[c].fn.call(h[c].context,e);break;case 3:h[c].fn.call(h[c].context,e,i);break;case 4:h[c].fn.call(h[c].context,e,i,r);break;default:if(!l)for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];h[c].fn.apply(h[c].context,l)}}return!0},c.prototype.on=function(t,e,i){return o(this,t,e,i,!1)},c.prototype.once=function(t,e,i){return o(this,t,e,i,!0)},c.prototype.removeListener=function(t,e,i,r){var s=n?n+t:t;if(!this._events[s])return this;if(!e)return l(this,s),this;var a=this._events[s];if(a.fn)a.fn!==e||r&&!a.once||i&&a.context!==i||l(this,s);else{for(var o=0,c=[],h=a.length;o<h;o++)(a[o].fn!==e||r&&!a[o].once||i&&a[o].context!==i)&&c.push(a[o]);c.length?this._events[s]=1===c.length?c[0]:c:l(this,s)}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 s,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,i){var r,n,s,a,o;r=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,n=/^([^\/?#]*)([^]*)$/,s=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(t,e,i){if(i=i||{},t=t.trim(),!(e=e.trim())){if(!i.alwaysNormalize)return t;var r=o.parseURL(t);if(!r)throw new Error("Error trying to parse base URL.");return r.path=o.normalizePath(r.path),o.buildURLFromParts(r)}var s=o.parseURL(e);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return i.alwaysNormalize?(s.path=o.normalizePath(s.path),o.buildURLFromParts(s)):e;var a=o.parseURL(t);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&"/"!==a.path[0]){var l=n.exec(a.path);a.netLoc=l[1],a.path=l[2]}a.netLoc&&!a.path&&(a.path="/");var c={scheme:a.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(c.netLoc=a.netLoc,"/"!==s.path[0]))if(s.path){var h=a.path,u=h.substring(0,h.lastIndexOf("/")+1)+s.path;c.path=o.normalizePath(u)}else c.path=a.path,s.params||(c.params=a.params,s.query||(c.query=a.query));return null===c.path&&(c.path=i.alwaysNormalize?o.normalizePath(s.path):s.path),o.buildURLFromParts(c)},parseURL:function(t){var e=r.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(s,"");t.length!==(t=t.replace(a,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}},t.exports=o},"./node_modules/webworkify-webpack/index.js":
|
|
|
/*!**************************************************!*\
|
|
|
!*** ./node_modules/webworkify-webpack/index.js ***!
|
|
|
\**************************************************/
|
|
|
/*! no static exports found */function(t,e,i){function r(t){var e={};function i(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=t,i.c=e,i.i=function(t){return t},i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},i.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/",i.oe=function(t){throw console.error(t),t};var r=i(i.s=ENTRY_MODULE);return r.default||r}function n(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function s(t,e,r){var s={};s[r]=[];var a=e.toString(),o=a.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!o)return s;for(var l,c=o[1],h=new RegExp("(\\\\n|\\W)"+n(c)+"\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g");l=h.exec(a);)"dll-reference"!==l[3]&&s[r].push(l[3]);for(h=new RegExp("\\("+n(c)+'\\("(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))"\\)\\)\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)',"g");l=h.exec(a);)t[l[2]]||(s[r].push(l[1]),t[l[2]]=i(l[1]).m),s[l[2]]=s[l[2]]||[],s[l[2]].push(l[4]);for(var u,d=Object.keys(s),f=0;f<d.length;f++)for(var p=0;p<s[d[f]].length;p++)u=s[d[f]][p],isNaN(1*u)||(s[d[f]][p]=1*s[d[f]][p]);return s}function a(t){return Object.keys(t).reduce((function(e,i){return e||t[i].length>0}),!1)}t.exports=function(t,e){e=e||{};var n={main:i.m},o=e.all?{main:Object.keys(n.main)}:function(t,e){for(var i={main:[e]},r={main:[]},n={main:{}};a(i);)for(var o=Object.keys(i),l=0;l<o.length;l++){var c=o[l],h=i[c].pop();if(n[c]=n[c]||{},!n[c][h]&&t[c][h]){n[c][h]=!0,r[c]=r[c]||[],r[c].push(h);for(var u=s(t,t[c][h],c),d=Object.keys(u),f=0;f<d.length;f++)i[d[f]]=i[d[f]]||[],i[d[f]]=i[d[f]].concat(u[d[f]])}}return r}(n,t),l="";Object.keys(o).filter((function(t){return"main"!==t})).forEach((function(t){for(var e=0;o[t][e];)e++;o[t].push(e),n[t][e]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",l=l+"var "+t+" = ("+r.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+o[t].map((function(e){return JSON.stringify(e)+": "+n[t][e].toString()})).join(",")+"});\n"})),l=l+"new (("+r.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+o.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 h=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(c),u=new window.Worker(h);return u.objectURL=h,u}},"./src/config.ts":
|
|
|
/*!***********************!*\
|
|
|
!*** ./src/config.ts ***!
|
|
|
\***********************/
|
|
|
/*! exports provided: hlsDefaultConfig, mergeConfig, enableStreamingMode */function(t,e,i){"use strict";i.r(e),i.d(e,"hlsDefaultConfig",(function(){return k})),i.d(e,"mergeConfig",(function(){return T})),i.d(e,"enableStreamingMode",(function(){return w}));var r=i(/*! ./controller/abr-controller */"./src/controller/abr-controller.ts"),n=i(/*! ./controller/audio-stream-controller */"./src/controller/audio-stream-controller.ts"),s=i(/*! ./controller/audio-track-controller */"./src/controller/audio-track-controller.ts"),a=i(/*! ./controller/subtitle-stream-controller */"./src/controller/subtitle-stream-controller.ts"),o=i(/*! ./controller/subtitle-track-controller */"./src/controller/subtitle-track-controller.ts"),l=i(/*! ./controller/buffer-controller */"./src/controller/buffer-controller.ts"),c=i(/*! ./controller/timeline-controller */"./src/controller/timeline-controller.ts"),h=i(/*! ./controller/cap-level-controller */"./src/controller/cap-level-controller.ts"),u=i(/*! ./controller/fps-controller */"./src/controller/fps-controller.ts"),d=i(/*! ./controller/eme-controller */"./src/controller/eme-controller.ts"),f=i(/*! ./controller/cmcd-controller */"./src/controller/cmcd-controller.ts"),p=i(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts"),g=i(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts"),v=i(/*! ./utils/cues */"./src/utils/cues.ts"),m=i(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),y=i(/*! ./utils/logger */"./src/utils/logger.ts");function b(){return(b=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t}).apply(this,arguments)}function S(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,r)}return i}function E(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?S(Object(i),!0).forEach((function(e){C(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):S(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function C(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var k=E(E({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:r.default,bufferController:l.default,capLevelController:h.default,fpsController:u.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:m.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},{cueHandler:v.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:a.SubtitleStreamController,subtitleTrackController:o.default,timelineController:c.TimelineController,audioStreamController:n.default,audioTrackController:s.default,emeController:d.default,cmcdController:f.default});function T(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 w(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,i){"use strict";i.r(e);var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ../utils/ewma-bandwidth-estimator */"./src/utils/ewma-bandwidth-estimator.ts"),s=i(/*! ../events */"./src/events.ts"),a=i(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=i(/*! ../errors */"./src/errors.ts"),l=i(/*! ../types/loader */"./src/types/loader.ts"),c=i(/*! ../utils/logger */"./src/utils/logger.ts");function h(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var u=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,i,u,d=t.prototype;return d.registerListeners=function(){var t=this.hls;t.on(s.Events.FRAG_LOADING,this.onFragLoading,this),t.on(s.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(s.Events.ERROR,this.onError,this)},d.unregisterListeners=function(){var t=this.hls;t.off(s.Events.FRAG_LOADING,this.onFragLoading,this),t.off(s.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(s.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 i,r=e.frag;r.type===l.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=r,this.partCurrent=null!=(i=e.part)?i:null,this.timer=self.setInterval(this.onCheck,100)))},d.onLevelLoaded=function(t,e){var i=this.hls.config;e.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)},d._abandonRulesCheck=function(){var t=this.fragCurrent,e=this.partCurrent,i=this.hls,n=i.autoLevelEnabled,o=i.config,l=i.media;if(t&&l){var h=e?e.stats:t.stats,u=e?e.duration:t.duration;if(h.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()-h.loading.start,f=Math.abs(l.playbackRate);if(!(d<=500*u/f)){var p=i.levels,g=i.minAutoLevel,v=p[t.level],m=h.total||Math.max(h.loaded,Math.round(u*v.maxBitrate/8)),y=Math.max(1,h.bwEstimate?h.bwEstimate/8:1e3*h.loaded/d),b=(m-h.loaded)/y,S=l.currentTime,E=(a.BufferHelper.bufferInfo(l,S,o.maxBufferHole).end-S)/f;if(!(E>=2*u/f||b<=E)){var C,k=Number.POSITIVE_INFINITY;for(C=t.level-1;C>g&&!((k=u*p[C].maxBitrate/(6.4*y))<E);C--);if(!(k>=b)){var T=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(r.isFiniteNumber)(T)?(T/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: "+k.toFixed(3)+" s\n Time to underbuffer: "+E.toFixed(3)+" s"),i.nextLoadLevel=C,this.bwEstimator.sample(d,h.loaded),this.clearTimer(),t.loader&&(this.fragCurrent=this.partCurrent=null,t.loader.abort()),i.trigger(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:h})}}}}}},d.onFragLoaded=function(t,e){var i=e.frag,n=e.part;if(i.type===l.PlaylistLevelType.MAIN&&Object(r.isFiniteNumber)(i.sn)){var a=n?n.stats:i.stats,o=n?n.duration:i.duration;if(this.clearTimer(),this.lastLoadedFragLevel=i.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var c=this.hls.levels[i.level],h=(c.loaded?c.loaded.bytes:0)+a.loaded,u=(c.loaded?c.loaded.duration:0)+o;c.loaded={bytes:h,duration:u},c.realBitrate=Math.round(8*h/u)}if(i.bitrateTest){var d={stats:a,frag:i,part:n,id:i.type};this.onFragBuffered(s.Events.FRAG_BUFFERED,d),i.bitrateTest=!1}}},d.onFragBuffered=function(t,e){var i=e.frag,r=e.part,n=r?r.stats:i.stats;if(!n.aborted&&i.type===l.PlaylistLevelType.MAIN&&"initSegment"!==i.sn){var s=n.parsing.end-n.loading.start;this.bwEstimator.sample(s,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=s/1e3:this.bitrateTestDelay=0}},d.onError=function(t,e){switch(e.details){case o.ErrorDetails.FRAG_LOAD_ERROR:case o.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,i=this.hls,r=i.maxAutoLevel,n=i.config,s=i.minAutoLevel,o=i.media,l=e?e.duration:t?t.duration:0,h=o?o.currentTime:0,u=o&&0!==o.playbackRate?Math.abs(o.playbackRate):1,d=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,f=(a.BufferHelper.bufferInfo(o,h,n.maxBufferHole).end-h)/u,p=this.findBestLevel(d,s,r,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,v=n.abrBandWidthFactor,m=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"),v=m=1)}return p=this.findBestLevel(d,s,r,f+g,v,m),Math.max(p,0)},d.findBestLevel=function(t,e,i,r,n,s){for(var a,o=this.fragCurrent,l=this.partCurrent,h=this.lastLoadedFragLevel,u=this.hls.levels,d=u[h],f=!(null==d||null===(a=d.details)||void 0===a||!a.live),p=null==d?void 0:d.codecSet,g=l?l.duration:o?o.duration:0,v=i;v>=e;v--){var m=u[v];if(m&&(!p||m.codecSet===p)){var y=m.details,b=(l?null==y?void 0:y.partTarget:null==y?void 0:y.averagetargetduration)||g,S=void 0;S=v<=h?n*t:s*t;var E=u[v].maxBitrate,C=E*b/S;if(c.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+v+"/"+Math.round(S)+"/"+E+"/"+b+"/"+r+"/"+C),S>E&&(!C||f&&!this.bitrateTestDelay||C<r))return v}}return-1},e=t,(i=[{key:"nextAutoLevel",get:function(){var t=this._nextAutoLevel,e=this.bwEstimator;if(!(-1===t||e&&e.canEstimate()))return t;var i=this.getNextABRAutoLevel();return-1!==t&&(i=Math.min(t,i)),i},set:function(t){this._nextAutoLevel=t}}])&&h(e.prototype,i),u&&h(e,u),t}();e.default=u},"./src/controller/audio-stream-controller.ts":
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./src/controller/audio-stream-controller.ts ***!
|
|
|
\***************************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),s=i(/*! ../events */"./src/events.ts"),a=i(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=i(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),l=i(/*! ../types/level */"./src/types/level.ts"),c=i(/*! ../types/loader */"./src/types/loader.ts"),h=i(/*! ../loader/fragment */"./src/loader/fragment.ts"),u=i(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts"),d=i(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),f=i(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),p=i(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),g=i(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),v=i(/*! ../errors */"./src/errors.ts"),m=i(/*! ../utils/logger */"./src/utils/logger.ts");function y(){return(y=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t}).apply(this,arguments)}function b(t,e){return(b=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var S=function(t){var e,i;function S(e,i){var r;return(r=t.call(this,e,i,"[audio-stream-controller]")||this).videoBuffer=null,r.videoTrackCC=-1,r.waitingVideoCC=-1,r.audioSwitch=!1,r.trackId=-1,r.waitingData=null,r.mainDetails=null,r.bufferFlushed=!1,r._registerListeners(),r}i=t,(e=S).prototype=Object.create(i.prototype),e.prototype.constructor=e,b(e,i);var E=S.prototype;return E.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},E._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.LEVEL_LOADED,this.onLevelLoaded,this),t.on(s.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(s.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(s.Events.ERROR,this.onError,this),t.on(s.Events.BUFFER_RESET,this.onBufferReset,this),t.on(s.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(s.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E._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.LEVEL_LOADED,this.onLevelLoaded,this),t.off(s.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(s.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(s.Events.ERROR,this.onError,this),t.off(s.Events.BUFFER_RESET,this.onBufferReset,this),t.off(s.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(s.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E.onInitPtsFound=function(t,e){var i=e.frag,r=e.id,s=e.initPTS;if("main"===r){var a=i.cc;this.initPTS[i.cc]=s,this.log("InitPTS for cc: "+a+" found from main: "+s),this.videoTrackCC=a,this.state===n.State.WAITING_INIT_PTS&&this.tick()}},E.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()},E.doTick=function(){switch(this.state){case n.State.IDLE:this.doTickIdle();break;case n.State.WAITING_TRACK:var e,i=this.levels,r=this.trackId,s=null==i||null===(e=i[r])||void 0===e?void 0:e.details;if(s){if(this.waitForCdnTuneIn(s))break;this.state=n.State.WAITING_INIT_PTS}break;case n.State.FRAG_LOADING_WAITING_RETRY:var o,l=performance.now(),c=this.retryDate;(!c||l>=c||null!==(o=this.media)&&void 0!==o&&o.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=n.State.IDLE);break;case n.State.WAITING_INIT_PTS:var h=this.waitingData;if(h){var u=h.frag,d=h.part,f=h.cache,g=h.complete;if(void 0!==this.initPTS[u.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=n.State.FRAG_LOADING;var v={frag:u,part:d,payload:f.flush(),networkDetails:null};this._handleFragmentLoadProgress(v),g&&t.prototype._handleFragmentLoadComplete.call(this,v)}else if(this.videoTrackCC!==this.waitingVideoCC)m.logger.log("Waiting fragment cc ("+u.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var y=this.getLoadPosition(),b=a.BufferHelper.bufferInfo(this.mediaBuffer,y,this.config.maxBufferHole);Object(p.fragmentWithinToleranceTest)(b.end,this.config.maxFragLookUpTolerance,u)<0&&(m.logger.log("Waiting fragment cc ("+u.cc+") @ "+u.start+" cancelled because another fragment at "+b.end+" is needed"),this.clearWaitingFragment())}}else this.state=n.State.IDLE}this.onTickEnd()},E.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=n.State.IDLE)},E.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}},E.doTickIdle=function(){var t,e,i=this.hls,r=this.levels,a=this.media,o=this.trackId,l=i.config;if(r&&r[o]&&(a||!this.startFragRequested&&l.startFragPrefetch)){var u=r[o].details;if(!u||u.live&&this.levelLastLoaded!==o||this.waitForCdnTuneIn(u))this.state=n.State.WAITING_TRACK;else{this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,h.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,u))return i.trigger(s.Events.BUFFER_EOS,{type:"audio"}),void(this.state=n.State.ENDED);var v=u.fragments[0].start,m=d.end;if(g){var y=this.getLoadPosition();m=y,u.PTSKnown&&y<v&&(d.end>v||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),a.currentTime=v+.05)}var b=this.getNextFragment(m,u);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,u,m):this.loadKey(b,u):this.bufferFlushed=!0}}}}},E.getMaxBufferLength=function(){var e=t.prototype.getMaxBufferLength.call(this),i=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,c.PlaylistLevelType.MAIN);return null===i?e:Math.max(e,i.len)},E.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},E.onAudioTracksUpdated=function(t,e){var i=e.audioTracks;this.resetTransmuxer(),this.levels=i.map((function(t){return new l.Level(t)}))},E.onAudioTrackSwitching=function(t,e){var i=!!e.url;this.trackId=e.id;var r=this.fragCurrent;null!=r&&r.loader&&r.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),i?this.setInterval(100):this.resetTransmuxer(),i?(this.audioSwitch=!0,this.state=n.State.IDLE):this.state=n.State.STOPPED,this.tick()},E.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},E.onLevelLoaded=function(t,e){this.mainDetails=e.details},E.onAudioTrackLoaded=function(t,e){var i,r=this.levels,s=e.details,a=e.id;if(r){this.log("Track "+a+" loaded ["+s.startSN+","+s.endSN+"],duration:"+s.totalduration);var o=r[a],l=0;if(s.live||null!==(i=o.details)&&void 0!==i&&i.live){var c=this.mainDetails;if(s.fragments[0]||(s.deltaUpdateFailed=!0),s.deltaUpdateFailed||!c)return;!o.details&&s.hasProgramDateTime&&c.hasProgramDateTime?(Object(g.alignMediaPlaylistByPDT)(s,c),l=s.fragments[0].start):l=this.alignPlaylists(s,o.details)}o.details=s,this.levelLastLoaded=a,this.startFragRequested||!this.mainDetails&&s.live||this.setStartPosition(o.details,l),this.state!==n.State.WAITING_TRACK||this.waitForCdnTuneIn(s)||(this.state=n.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+a)},E._handleFragmentLoadProgress=function(t){var e,i=t.frag,r=t.part,s=t.payload,a=this.config,o=this.trackId,l=this.levels;if(l){var h=l[o];console.assert(h,"Audio track is defined on fragment load progress");var p=h.details;console.assert(p,"Audio track details are defined on fragment load progress");var g=a.defaultAudioCodec||h.audioCodec||"mp4a.40.2",v=this.transmuxer;v||(v=this.transmuxer=new d.default(this.hls,c.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var y=this.initPTS[i.cc],b=null===(e=i.initSegment)||void 0===e?void 0:e.data;if(void 0!==y){var S=r?r.index:-1,E=-1!==S,C=new f.ChunkMetadata(i.level,i.sn,i.stats.chunkCount,s.byteLength,S,E);v.push(s,b,g,"",i,r,p.totalduration,!1,C,y)}else m.logger.log("Unknown video PTS for cc "+i.cc+", waiting for video PTS before demuxing audio frag "+i.sn+" of ["+p.startSN+" ,"+p.endSN+"],track "+o),(this.waitingData=this.waitingData||{frag:i,part:r,cache:new u.default,complete:!1}).cache.push(new Uint8Array(s)),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 "+i.sn+" of level "+i.level+" will not be buffered")},E._handleFragmentLoadComplete=function(e){this.waitingData?this.waitingData.complete=!0:t.prototype._handleFragmentLoadComplete.call(this,e)},E.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},E.onBufferCreated=function(t,e){var i=e.tracks.audio;i&&(this.mediaBuffer=i.buffer),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer)},E.onFragBuffered=function(t,e){var i=e.frag,r=e.part;i.type===c.PlaylistLevelType.AUDIO&&(this.fragContextChanged(i)?this.warn("Fragment "+i.sn+(r?" p: "+r.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):("initSegment"!==i.sn&&(this.fragPrevious=i,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(i,r)))},E.onError=function(e,i){switch(i.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:case v.ErrorDetails.KEY_LOAD_ERROR:case v.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(c.PlaylistLevelType.AUDIO,i);break;case v.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case v.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==n.State.ERROR&&this.state!==n.State.STOPPED&&(this.state=i.fatal?n.State.ERROR:n.State.IDLE,this.warn(i.details+" while loading frag, switching to "+this.state+" state"));break;case v.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===i.parent&&(this.state===n.State.PARSING||this.state===n.State.PARSED)){var r=!0,s=this.getFwdBufferInfo(this.mediaBuffer,c.PlaylistLevelType.AUDIO);s&&s.len>.5&&(r=!this.reduceMaxBufferLength(s.len)),r&&(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()}}},E.onBufferFlushed=function(t,e){e.type===h.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},E._handleTransmuxComplete=function(t){var e,i="audio",r=this.hls,a=t.remuxResult,o=t.chunkMeta,l=this.getCurrentContext(o);if(!l)return this.warn("The loading context changed while buffering fragment "+o.sn+" of level "+o.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(o.level);var c=l.frag,u=l.part,d=a.audio,f=a.text,p=a.id3,g=a.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,o),r.trigger(s.Events.FRAG_PARSING_INIT_SEGMENT,{frag:c,id:i,tracks:g.tracks})),d){var v=d.startPTS,m=d.endPTS,b=d.startDTS,S=d.endDTS;u&&(u.elementaryStreams[h.ElementaryStreamTypes.AUDIO]={startPTS:v,endPTS:m,startDTS:b,endDTS:S}),c.setElementaryStreamInfo(h.ElementaryStreamTypes.AUDIO,v,m,b,S),this.bufferFragmentData(d,c,u,o)}if(null!=p&&null!==(e=p.samples)&&void 0!==e&&e.length){var E=y({frag:c,id:i},p);r.trigger(s.Events.FRAG_PARSING_METADATA,E)}if(f){var C=y({frag:c,id:i},f);r.trigger(s.Events.FRAG_PARSING_USERDATA,C)}}},E._bufferInitSegment=function(t,e,i){if(this.state===n.State.PARSING){t.video&&delete t.video;var r=t.audio;if(r){r.levelCodec=r.codec,r.id="audio",this.log("Init audio buffer, container:"+r.container+", codecs[parsed]=["+r.codec+"]"),this.hls.trigger(s.Events.BUFFER_CODECS,t);var a=r.initSegment;if(null!=a&&a.byteLength){var o={type:"audio",frag:e,part:null,chunkMeta:i,parent:e.type,data:a};this.hls.trigger(s.Events.BUFFER_APPENDING,o)}this.tick()}}},E.loadFragment=function(e,i,s){var a=this.fragmentTracker.getState(e);this.fragCurrent=e,(this.audioSwitch||a===o.FragmentState.NOT_LOADED||a===o.FragmentState.PARTIAL)&&("initSegment"===e.sn?this._loadInitSegment(e):i.live&&!Object(r.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,i,s)))},E.completeAudioSwitch=function(){var e=this.hls,i=this.media,r=this.trackId;i&&(this.log("Switching audio track : flushing all audio"),t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,e.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:r})},S}(n.default);e.default=S},"./src/controller/audio-track-controller.ts":
|
|
|
/*!**************************************************!*\
|
|
|
!*** ./src/controller/audio-track-controller.ts ***!
|
|
|
\**************************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var r=i(/*! ../events */"./src/events.ts"),n=i(/*! ../errors */"./src/errors.ts"),s=i(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),a=i(/*! ../types/loader */"./src/types/loader.ts");function o(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var c=function(t){var e,i;function s(e){var i;return(i=t.call(this,e,"[audio-track-controller]")||this).tracks=[],i.groupId=null,i.tracksInGroup=[],i.trackId=-1,i.trackName="",i.selectDefaultTrack=!0,i.registerListeners(),i}i=t,(e=s).prototype=Object.create(i.prototype),e.prototype.constructor=e,l(e,i);var c,h,u,d=s.prototype;return d.registerListeners=function(){var t=this.hls;t.on(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(r.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(r.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(r.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(r.Events.ERROR,this.onError,this)},d.unregisterListeners=function(){var t=this.hls;t.off(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(r.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(r.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(r.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(r.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 i=e.id,r=e.details,n=this.tracksInGroup[i];if(n){var s=n.details;n.details=e.details,this.log("audioTrack "+i+" loaded ["+r.startSN+"-"+r.endSN+"]"),i===this.trackId&&(this.retryCount=0,this.playlistLoaded(i,e,s))}else this.warn("Invalid audio track id "+i)},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 i=e.audioGroupIds[e.urlId];if(this.groupId!==i){this.groupId=i;var n=this.tracks.filter((function(t){return!i||t.groupId===i}));this.selectDefaultTrack&&!n.some((function(t){return t.default}))&&(this.selectDefaultTrack=!1),this.tracksInGroup=n;var s={audioTracks:n};this.log("Updating audio tracks, "+n.length+' track(s) found in "'+i+'" group-id'),this.hls.trigger(r.Events.AUDIO_TRACKS_UPDATED,s),this.selectInitialTrack()}}},d.onError=function(e,i){t.prototype.onError.call(this,e,i),!i.fatal&&i.context&&i.context.type===a.PlaylistContextType.AUDIO_TRACK&&i.context.id===this.trackId&&i.context.groupId===this.groupId&&this.retryLoadingOrFail(i)},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 i=e[this.trackId];this.log("Now switching to audio-track index "+t);var n=e[t],s=n.id,a=n.groupId,o=void 0===a?"":a,l=n.name,c=n.type,h=n.url;if(this.trackId=t,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(r.Events.AUDIO_TRACK_SWITCHING,{id:s,groupId:o,name:l,type:c,url:h}),!n.details||n.details.live){var u=this.switchParams(n.url,null==i?void 0:i.details);this.loadPlaylist(u)}}},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,i=this.findTrackId(e)||this.findTrackId();-1!==i?this.setAudioTrack(i):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(r.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,i=0;i<e.length;i++){var r=e[i];if((!this.selectDefaultTrack||r.default)&&(!t||t===r.name))return r.id}return-1},d.loadPlaylist=function(t){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var i=e.id,n=e.groupId,s=e.url;if(t)try{s=t.addDirectives(s)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("loading audio-track playlist for id: "+i),this.clearTimer(),this.hls.trigger(r.Events.AUDIO_TRACK_LOADING,{url:s,id:i,groupId:n,deliveryDirectives:t||null})}},c=s,(h=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}}])&&o(c.prototype,h),u&&o(c,u),s}(s.default);e.default=c},"./src/controller/base-playlist-controller.ts":
|
|
|
/*!****************************************************!*\
|
|
|
!*** ./src/controller/base-playlist-controller.ts ***!
|
|
|
\****************************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return l}));var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ../types/level */"./src/types/level.ts"),s=i(/*! ./level-helper */"./src/controller/level-helper.ts"),a=i(/*! ../utils/logger */"./src/utils/logger.ts"),o=i(/*! ../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=a.logger.log.bind(a.logger,e+":"),this.warn=a.logger.warn.bind(a.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===o.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 i=null==e?void 0:e.renditionReports;if(i)for(var s=0;s<i.length;s++){var a=i[s],o=""+a.URI;if(o===t.substr(-o.length)){var l=parseInt(a["LAST-MSN"]),c=parseInt(a["LAST-PART"]);if(e&&this.hls.config.lowLatencyMode){var h=Math.min(e.age-e.partTarget,e.targetduration);void 0!==c&&h>e.partTarget&&(c+=1)}if(Object(r.isFiniteNumber)(l))return new n.HlsUrlParameters(l,Object(r.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,i){var r=this,n=e.details,a=e.stats,o=a.loading.end?Math.max(0,self.performance.now()-a.loading.end):0;if(n.advancedDateTime=Date.now()-o,n.live||null!=i&&i.live){if(n.reloaded(i),i&&this.log("live playlist "+t+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:"MISSED")),i&&n.fragments.length>0&&Object(s.mergeDetails)(i,n),!this.canLoad||!n.live)return;var l,c=void 0,h=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var u=this.hls.config.lowLatencyMode,d=n.lastPartSn,f=n.endSN,p=n.lastPartIndex,g=d===f;-1!==p?(c=g?f+1:d,h=g?u?0:p:p+1):c=f+1;var v=n.age,m=v+n.ageHeader,y=Math.min(m-n.partTarget,1.5*n.targetduration);if(y>0){if(i&&y>i.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+i.tuneInGoal+" to: "+y+" with playlist age: "+n.age),y=0;else{var b=Math.floor(y/n.targetduration);c+=b,void 0!==h&&(h+=Math.round(y%n.targetduration/n.partTarget)),this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+v.toFixed(2)+"s goal: "+y+" skip sn "+b+" to part "+h)}n.tuneInGoal=y}if(l=this.getDeliveryDirectives(n,e.deliveryDirectives,c,h),u||!g)return void this.loadPlaylist(l)}else l=this.getDeliveryDirectives(n,e.deliveryDirectives,c,h);var S=Object(s.computeReloadInterval)(n,a);void 0!==c&&n.canBlockReload&&(S-=n.partTarget||1),this.log("reload live playlist "+t+" in "+Math.round(S)+" ms"),this.timer=self.setTimeout((function(){return r.loadPlaylist(l)}),S)}else this.clearTimer()},e.getDeliveryDirectives=function(t,e,i,r){var s=Object(n.getSkipValue)(t,i);return null!=e&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,r=e.part,s=n.HlsSkip.No),new n.HlsUrlParameters(i,r,s)},e.retryLoadingOrFail=function(t){var e,i=this,r=this.hls.config,n=this.retryCount<r.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 s=Math.min(Math.pow(2,this.retryCount)*r.levelLoadingRetryDelay,r.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout((function(){return i.loadPlaylist()}),s),this.warn("retry playlist loading #"+this.retryCount+" in "+s+' 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,i){"use strict";i.r(e),i.d(e,"State",(function(){return E})),i.d(e,"default",(function(){return C}));var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ../task-loop */"./src/task-loop.ts"),s=i(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),a=i(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=i(/*! ../utils/logger */"./src/utils/logger.ts"),l=i(/*! ../events */"./src/events.ts"),c=i(/*! ../errors */"./src/errors.ts"),h=i(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),u=i(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),d=i(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),f=i(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),p=i(/*! ./level-helper */"./src/controller/level-helper.ts"),g=i(/*! ../loader/fragment-loader */"./src/loader/fragment-loader.ts"),v=i(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),m=i(/*! ../utils/time-ranges */"./src/utils/time-ranges.ts"),y=i(/*! ../types/loader */"./src/types/loader.ts");function b(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function S(t,e){return(S=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var E={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},C=function(t){var e,i;function n(e,i,r){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=E.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=r,n.log=o.logger.log.bind(o.logger,r+":"),n.warn=o.logger.warn.bind(o.logger,r+":"),n.hls=e,n.fragmentLoader=new g.default(e.config),n.fragmentTracker=i,n.config=e.config,n.decrypter=new v.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}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,S(e,i);var C,k,T,w=n.prototype;return w.doTick=function(){this.onTickEnd()},w.onTickEnd=function(){},w.startLoad=function(t){},w.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=E.STOPPED},w._streamEnded=function(t,e){var i=this.fragCurrent,r=this.fragmentTracker;if(!e.live&&i&&i.sn===e.endSN&&!t.nextStart){var n=r.getState(i);return n===s.FragmentState.PARTIAL||n===s.FragmentState.OK}return!1},w.onMediaAttached=function(t,e){var i=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);var r=this.config;this.levels&&r.autoStartLoad&&this.state===E.STOPPED&&this.startLoad(r.startPosition)},w.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()},w.onMediaSeeking=function(){var t=this.config,e=this.fragCurrent,i=this.media,n=this.mediaBuffer,s=this.state,o=i?i.currentTime:0,l=a.BufferHelper.bufferInfo(n||i,o,t.maxBufferHole);if(this.log("media seeking to "+(Object(r.isFiniteNumber)(o)?o.toFixed(3):o)+", state: "+s),s===E.ENDED)this.resetLoadingState();else if(e&&!l.len){var c=t.maxFragLookUpTolerance,h=e.start-c,u=o>e.start+e.duration+c;(o<h||u)&&(u&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.loader.abort()),this.resetLoadingState())}i&&(this.lastCurrentTime=o),this.loadedmetadata||l.len||(this.nextLoadPosition=this.startPosition=o),this.tickImmediate()},w.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},w.onKeyLoaded=function(t,e){if(this.state===E.KEY_LOADING&&e.frag===this.fragCurrent&&this.levels){this.state=E.IDLE;var i=this.levels[e.frag.level].details;i&&this.loadFragment(e.frag,i,e.frag.start)}},w.onHandlerDestroying=function(){this.stopLoad(),t.prototype.onHandlerDestroying.call(this)},w.onHandlerDestroyed=function(){this.state=E.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)},w.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=E.KEY_LOADING,this.fragCurrent=t,this.hls.trigger(l.Events.KEY_LOADING,{frag:t})},w.loadFragment=function(t,e,i){this._loadFragForPlayback(t,e,i)},w._loadFragForPlayback=function(t,e,i){var r=this;this._doFragLoad(t,e,i,(function(e){if(r.fragContextChanged(t))return r.warn("Fragment "+t.sn+(e.part?" p: "+e.part.index:"")+" of level "+t.level+" was dropped during download."),void r.fragmentTracker.removeFragment(t);t.stats.chunkCount++,r._handleFragmentLoadProgress(e)})).then((function(e){if(e){r.fragLoadError=0;var i=r.state;if(!r.fragContextChanged(t))return"payload"in e&&(r.log("Loaded fragment "+t.sn+" of level "+t.level),r.hls.trigger(l.Events.FRAG_LOADED,e),r.state===E.BACKTRACKING)?(r.fragmentTracker.backtrack(t,e),void r.resetFragmentLoading(t)):void r._handleFragmentLoadComplete(e);(i===E.FRAG_LOADING||i===E.BACKTRACKING||!r.fragCurrent&&i===E.PARSING)&&(r.fragmentTracker.removeFragment(t),r.state=E.IDLE)}})).catch((function(e){r.warn(e),r.resetFragmentLoading(t)}))},w.flushMainBuffer=function(t,e,i){if(void 0===i&&(i=null),t-e){var r={startOffset:t,endOffset:e,type:i};this.fragLoadError=0,this.hls.trigger(l.Events.BUFFER_FLUSHING,r)}},w._loadInitSegment=function(t){var e=this;this._doFragLoad(t).then((function(i){if(!i||e.fragContextChanged(t)||!e.levels)throw new Error("init load aborted");return i})).then((function(i){var r=e.hls,n=i.payload,s=t.decryptdata;if(n&&n.byteLength>0&&s&&s.key&&s.iv&&"AES-128"===s.method){var a=self.performance.now();return e.decrypter.webCryptoDecrypt(new Uint8Array(n),s.key.buffer,s.iv.buffer).then((function(e){var n=self.performance.now();return r.trigger(l.Events.FRAG_DECRYPTED,{frag:t,payload:e,stats:{tstart:a,tdecrypt:n}}),i.payload=e,i}))}return i})).then((function(i){var r=e.fragCurrent,n=e.hls,s=e.levels;if(!s)throw new Error("init load aborted, missing levels");var a=s[t.level].details;console.assert(a,"Level details are defined when init segment is loaded");var o=t.stats;e.state=E.IDLE,e.fragLoadError=0,t.data=new Uint8Array(i.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),i.frag===r&&n.trigger(l.Events.FRAG_BUFFERED,{stats:o,frag:r,part:null,id:t.type}),e.tick()})).catch((function(i){e.warn(i),e.resetFragmentLoading(t)}))},w.fragContextChanged=function(t){var e=this.fragCurrent;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId},w.fragBufferedComplete=function(t,e){var i=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+" "+m.default.toString(a.BufferHelper.getBuffered(i))),this.state=E.IDLE,this.tick()},w._handleFragmentLoadComplete=function(t){var e=this.transmuxer;if(e){var i=t.frag,r=t.part,n=t.partsLoaded,s=!n||0===n.length||n.some((function(t){return!t})),a=new h.ChunkMetadata(i.level,i.sn,i.stats.chunkCount+1,0,r?r.index:-1,!s);e.flush(a)}},w._handleFragmentLoadProgress=function(t){},w._doFragLoad=function(t,e,i,n){var s=this;if(void 0===i&&(i=null),!this.levels)throw new Error("frag load aborted, missing levels");if(i=Math.max(t.start,i||0),this.config.lowLatencyMode&&e){var a=e.partList;if(a&&n){i>t.end&&e.fragmentHint&&(t=e.fragmentHint);var o=this.getNextPart(a,t,i);if(o>-1){var c=a[o];return this.log("Loading part sn: "+t.sn+" p: "+c.index+" cc: "+t.cc+" of playlist ["+e.startSN+"-"+e.endSN+"] parts [0-"+o+"-"+(a.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(i.toFixed(3))),this.nextLoadPosition=c.start+c.duration,this.state=E.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:t,part:a[o],targetBufferTime:i}),this.doFragPartsLoad(t,a,o,n).catch((function(t){return s.handleFragLoadError(t)}))}if(!t.url||this.loadedEndOfParts(a,i))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(i.toFixed(3))),Object(r.isFiniteNumber)(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=E.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:t,targetBufferTime:i}),this.fragmentLoader.load(t,n).catch((function(t){return s.handleFragLoadError(t)}))},w.doFragPartsLoad=function(t,e,i,r){var n=this;return new Promise((function(s,a){var o=[];!function i(c){var h=e[c];n.fragmentLoader.loadPart(t,h,r).then((function(r){o[h.index]=r;var a=r.part;n.hls.trigger(l.Events.FRAG_LOADED,r);var u=e[c+1];if(!u||u.fragment!==t)return s({frag:t,part:a,partsLoaded:o});i(c+1)})).catch(a)}(i)}))},w.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},w._handleTransmuxerFlush=function(t){var e=this.getCurrentContext(t);if(e&&this.state===E.PARSING){var i=e.frag,r=e.part,n=e.level,s=self.performance.now();i.stats.parsing.end=s,r&&(r.stats.parsing.end=s),this.updateLevelTiming(i,r,n,t.partial)}else this.fragCurrent||(this.state=E.IDLE)},w.getCurrentContext=function(t){var e=this.levels,i=t.level,r=t.sn,n=t.part;if(!e||!e[i])return this.warn("Levels object was unset while buffering fragment "+r+" of level "+i+". The current chunk will not be buffered."),null;var s=e[i],a=n>-1?Object(p.getPartWith)(s,r,n):null,o=a?a.fragment:Object(p.getFragmentWithSN)(s,r,this.fragCurrent);return o?{frag:o,part:a,level:s}:null},w.bufferFragmentData=function(t,e,i,r){if(t&&this.state===E.PARSING){var n=t.data1,s=t.data2,a=n;if(n&&s&&(a=Object(u.appendUint8Array)(n,s)),a&&a.length){var o={type:t.type,frag:e,part:i,chunkMeta:r,parent:e.type,data:a};this.hls.trigger(l.Events.BUFFER_APPENDING,o),t.dropped&&t.independent&&!i&&this.flushBufferGap(e)}}},w.flushBufferGap=function(t){var e=this.media;if(e)if(a.BufferHelper.isBuffered(e,e.currentTime)){var i=e.currentTime,r=a.BufferHelper.bufferInfo(e,i,0),n=t.duration,s=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),o=Math.max(Math.min(t.start-s,r.end-s),i+s);t.start-o>s&&this.flushMainBuffer(o,t.start)}else this.flushMainBuffer(0,t.start)},w.getFwdBufferInfo=function(t,e){var i=this.config,n=this.getLoadPosition();if(!Object(r.isFiniteNumber)(n))return null;var s=a.BufferHelper.bufferInfo(t,n,i.maxBufferHole);if(0===s.len&&void 0!==s.nextStart){var o=this.fragmentTracker.getBufferedFrag(n,e);if(o&&s.nextStart<o.end)return a.BufferHelper.bufferInfo(t,n,Math.max(s.nextStart,i.maxBufferHole))}return s},w.getMaxBufferLength=function(t){var e,i=this.config;return e=t?Math.max(8*i.maxBufferSize/t,i.maxBufferLength):i.maxBufferLength,Math.min(e,i.maxMaxBufferLength)},w.reduceMaxBufferLength=function(t){var e=this.config,i=t||e.maxBufferLength;return e.maxMaxBufferLength>=i&&(e.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+e.maxMaxBufferLength+"s"),!0)},w.getNextFragment=function(t,e){var i,r,n=e.fragments,s=n.length;if(!s)return null;var a,o=this.config,l=n[0].start;if(e.live){var c=o.initialLiveManifestSize;if(s<c)return this.warn("Not enough fragments to start playback (have: "+s+", need: "+c+")"),null;e.PTSKnown||this.startFragRequested||-1!==this.startPosition||(a=this.getInitialLiveFragment(e,n),this.startPosition=a?this.hls.liveSyncPosition||a.start:t)}else t<=l&&(a=n[0]);if(!a){var h=o.lowLatencyMode?e.partEnd:e.fragmentEnd;a=this.getFragmentAtPosition(t,h,e)}return null===(i=a)||void 0===i||!i.initSegment||null!==(r=a)&&void 0!==r&&r.initSegment.data||this.bitrateTest||(a=a.initSegment),a},w.getNextPart=function(t,e,i){for(var r=-1,n=!1,s=!0,a=0,o=t.length;a<o;a++){var l=t[a];if(s=s&&!l.independent,r>-1&&i<l.start)break;var c=l.loaded;!c&&(n||l.independent||s)&&l.fragment===e&&(r=a),n=c}return r},w.loadedEndOfParts=function(t,e){var i=t[t.length-1];return i&&e>i.start&&i.loaded},w.getInitialLiveFragment=function(t,e){var i=this.fragPrevious,r=null;if(i){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),r=Object(f.findFragmentByPDT)(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){var n=i.sn+1;if(n>=t.startSN&&n<=t.endSN){var s=e[n-t.startSN];i.cc===s.cc&&(r=s,this.log("Live playlist, switching playlist, load frag with next SN: "+r.sn))}r||(r=Object(f.findFragWithCC)(e,i.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+r.sn)}}else{var a=this.hls.liveSyncPosition;null!==a&&(r=this.getFragmentAtPosition(a,this.bitrateTest?t.fragmentEnd:t.edge,t))}return r},w.getFragmentAtPosition=function(t,e,i){var r,n=this.config,a=this.fragPrevious,o=i.fragments,l=i.endSN,c=i.fragmentHint,h=n.maxFragLookUpTolerance,u=!!(n.lowLatencyMode&&i.partList&&c);if(u&&c&&!this.bitrateTest&&(o=o.concat(c),l=c.sn),t<e){var d=t>e-h?0:h;r=Object(f.findFragmentByPTS)(a,o,t,d)}else r=o[o.length-1];if(r){var p=r.sn-i.startSN,g=a&&r.level===a.level,v=o[p+1];if(this.fragmentTracker.getState(r)===s.FragmentState.BACKTRACKED){r=null;for(var m=p;o[m]&&this.fragmentTracker.getState(o[m])===s.FragmentState.BACKTRACKED;)r=a?o[m--]:o[--m];r||(r=v)}else a&&r.sn===a.sn&&!u&&g&&(r.sn<l&&this.fragmentTracker.getState(v)!==s.FragmentState.OK?(this.log("SN "+r.sn+" just loaded, load next one: "+v.sn),r=v):r=null)}return r},w.synchronizeToLiveEdge=function(t){var e=this.config,i=this.media;if(i){var r=this.hls.liveSyncPosition,n=i.currentTime,s=t.fragments[0].start,a=t.edge,o=n>=s-e.maxFragLookUpTolerance&&n<=a;if(null!==r&&i.duration>r&&(n<r||!o)){var l=void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!o&&i.readyState<4||n<a-l)&&(this.loadedmetadata||(this.nextLoadPosition=r),i.readyState&&(this.warn("Playback: "+n.toFixed(3)+" is located too far from the end of live sliding playlist: "+a+", reset currentTime to : "+r.toFixed(3)),i.currentTime=r))}}},w.alignPlaylists=function(t,e){var i=this.levels,n=this.levelLastLoaded,s=this.fragPrevious,a=null!==n?i[n]:null,o=t.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;var l=t.fragments[0].start,c=!e,h=t.alignedSliding&&Object(r.isFiniteNumber)(l);if(c||!h&&!l){Object(d.alignStream)(s,a,t);var u=t.fragments[0].start;return this.log("Live playlist sliding: "+u.toFixed(2)+" start-sn: "+(e?e.startSN:"na")+"->"+t.startSN+" prev-sn: "+(s?s.sn:"na")+" fragments: "+o),u}return l},w.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},w.setStartPosition=function(t,e){var i=this.startPosition;if(i<e&&(i=-1),-1===i||-1===this.lastCurrentTime){var n=t.startTimeOffset;Object(r.isFiniteNumber)(n)?(i=e+n,n<0&&(i+=t.totalduration),i=Math.min(Math.max(e,i),e+t.totalduration),this.log("Start time offset "+n+" found in playlist, adjust startPosition to "+i),this.startPosition=i):t.live?i=this.hls.liveSyncPosition||e:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i},w.getLoadPosition=function(){var t=this.media,e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e},w.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))},w.resetFragmentLoading=function(t){this.fragCurrent&&this.fragContextChanged(t)||(this.state=E.IDLE)},w.onFragmentOrKeyLoadError=function(t,e){if(!e.fatal){var i=e.frag;if(i&&i.type===t){var r=this.fragCurrent;console.assert(r&&i.sn===r.sn&&i.level===r.level&&i.urlId===r.urlId,"Frag load error must match current frag to retry");var n=this.config;if(this.fragLoadError+1<=n.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(i.level))return;var s=Math.min(Math.pow(2,this.fragLoadError)*n.fragLoadingRetryDelay,n.fragLoadingMaxRetryTimeout);this.warn("Fragment "+i.sn+" of "+t+" "+i.level+" failed to load, retrying in "+s+"ms"),this.retryDate=self.performance.now()+s,this.fragLoadError++,this.state=E.FRAG_LOADING_WAITING_RETRY}else e.levelRetry?(t===y.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=E.IDLE):(o.logger.error(e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.hls.stopLoad(),this.state=E.ERROR)}}},w.afterBufferFlushed=function(t,e,i){if(t){var r=a.BufferHelper.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,r,i),this.state===E.ENDED&&this.resetLoadingState()}},w.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=E.IDLE},w.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},w.updateLevelTiming=function(t,e,i,r){var n=this,s=i.details;console.assert(!!s,"level.details must be defined"),Object.keys(t.elementaryStreams).reduce((function(e,a){var o=t.elementaryStreams[a];if(o){var c=o.endPTS-o.startPTS;if(c<=0)return n.warn("Could not parse fragment "+t.sn+" "+a+" duration reliably ("+c+") resetting transmuxer to fallback to playlist timing"),n.resetTransmuxer(),e||!1;var h=r?0:Object(p.updateFragPTSDTS)(s,t,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return n.hls.trigger(l.Events.LEVEL_PTS_UPDATED,{details:s,level:i,drift:h,type:a,frag:t,start:o.startPTS,end:o.endPTS}),!0}return e}),!1)?(this.state=E.PARSED,this.hls.trigger(l.Events.FRAG_PARSED,{frag:t,part:e})):this.resetLoadingState()},w.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},C=n,(k=[{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,k),T&&b(C,T),n}(n.default)},"./src/controller/buffer-controller.ts":
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./src/controller/buffer-controller.ts ***!
|
|
|
\*********************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return f}));var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ../events */"./src/events.ts"),s=i(/*! ../utils/logger */"./src/utils/logger.ts"),a=i(/*! ../errors */"./src/errors.ts"),o=i(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=i(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),c=i(/*! ../loader/fragment */"./src/loader/fragment.ts"),h=i(/*! ./buffer-operation-queue */"./src/controller/buffer-operation-queue.ts"),u=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,i=e.media,r=e.mediaSource;s.logger.log("[buffer-controller]: Media source opened"),i&&(e.updateMediaElementDuration(),t.trigger(n.Events.MEDIA_ATTACHED,{media:i})),r&&r.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){s.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){s.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 h.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},e.onManifestParsed=function(t,e){var i=2;(e.audio&&!e.video||!e.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,this.details=null,s.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},e.onMediaAttaching=function(t,e){var i=this.media=e.media;if(i&&u){var r=this.mediaSource=new u;r.addEventListener("sourceopen",this._onMediaSourceOpen),r.addEventListener("sourceended",this._onMediaSourceEnded),r.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(r),this._objectUrl=i.src}},e.onMediaDetaching=function(){var t=this.media,e=this.mediaSource,i=this._objectUrl;if(e){if(s.logger.log("[buffer-controller]: media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(t){s.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&&(i&&self.URL.revokeObjectURL(i),t.src===i?(t.removeAttribute("src"),t.load()):s.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 i=t.sourceBuffer[e];try{i&&(t.removeBufferListeners(e),t.mediaSource&&t.mediaSource.removeSourceBuffer(i),t.sourceBuffer[e]=void 0)}catch(t){s.logger.warn("[buffer-controller]: Failed to reset the "+e+" buffer",t)}})),this._initSourceBuffer()},e.onBufferCodecs=function(t,e){var i=this,r=this.getSourceBufferTypes().length;Object.keys(e).forEach((function(t){if(r){var n=i.tracks[t];if(n&&"function"==typeof n.buffer.changeType){var s=e[t],a=s.codec,o=s.levelCodec,l=s.container;if((n.levelCodec||n.codec).replace(d,"$1")!==(o||a).replace(d,"$1")){var c=l+";codecs="+(o||a);i.appendChangeType(t,c)}}}else i.pendingTracks[t]=e[t]})),r||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},e.appendChangeType=function(t,e){var i=this,r=this.operationQueue,n={execute:function(){var n=i.sourceBuffer[t];n&&(s.logger.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+e),n.changeType(e)),r.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(e){s.logger.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",e)}};r.append(n,t)},e.onBufferAppending=function(t,e){var i=this,r=this.hls,l=this.operationQueue,c=this.tracks,h=e.data,u=e.type,d=e.frag,f=e.part,p=e.chunkMeta,g=p.buffering[u],v=self.performance.now();g.start=v;var m=d.stats.buffering,y=f?f.stats.buffering:null;0===m.start&&(m.start=v),y&&0===y.start&&(y.start=v);var b=c.audio,S="audio"===u&&1===p.id&&"audio/mpeg"===(null==b?void 0:b.container),E={execute:function(){if(g.executeStart=self.performance.now(),S){var t=i.sourceBuffer[u];if(t){var e=d.start-t.timestampOffset;Math.abs(e)>=.1&&(s.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+d.start+" (delta: "+e+") sn: "+d.sn+")"),t.timestampOffset=d.start)}}i.appendExecutor(h,u)},onStart:function(){},onComplete:function(){var t=self.performance.now();g.executeEnd=g.end=t,0===m.first&&(m.first=t),y&&0===y.first&&(y.first=t);var e=i.sourceBuffer,r={};for(var s in e)r[s]=o.BufferHelper.getBuffered(e[s]);i.appendError=0,i.hls.trigger(n.Events.BUFFER_APPENDED,{type:u,frag:d,part:f,chunkMeta:p,parent:d.type,timeRanges:r})},onError:function(t){s.logger.error("[buffer-controller]: Error encountered while trying to append to the "+u+" SourceBuffer",t);var e={type:a.ErrorTypes.MEDIA_ERROR,parent:d.type,details:a.ErrorDetails.BUFFER_APPEND_ERROR,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=a.ErrorDetails.BUFFER_FULL_ERROR:(i.appendError++,e.details=a.ErrorDetails.BUFFER_APPEND_ERROR,i.appendError>r.config.appendErrorMaxRetry&&(s.logger.error("[buffer-controller]: Failed "+r.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),e.fatal=!0)),r.trigger(n.Events.ERROR,e)}};l.append(E,u)},e.onBufferFlushing=function(t,e){var i=this,r=this.operationQueue,a=function(t){return{execute:i.removeExecutor.bind(i,t,e.startOffset,e.endOffset),onStart:function(){},onComplete:function(){i.hls.trigger(n.Events.BUFFER_FLUSHED,{type:t})},onError:function(e){s.logger.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",e)}}};e.type?r.append(a(e.type),e.type):this.getSourceBufferTypes().forEach((function(t){r.append(a(t),t)}))},e.onFragParsed=function(t,e){var i=this,r=e.frag,a=e.part,o=[],l=a?a.elementaryStreams:r.elementaryStreams;l[c.ElementaryStreamTypes.AUDIOVIDEO]?o.push("audiovideo"):(l[c.ElementaryStreamTypes.AUDIO]&&o.push("audio"),l[c.ElementaryStreamTypes.VIDEO]&&o.push("video")),0===o.length&&s.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+r.type+" level: "+r.level+" sn: "+r.sn),this.blockBuffers((function(){var t=self.performance.now();r.stats.buffering.end=t,a&&(a.stats.buffering.end=t);var e=a?a.stats:r.stats;i.hls.trigger(n.Events.FRAG_BUFFERED,{frag:r,part:a,stats:e,id:r.type})}),o)},e.onFragChanged=function(t,e){this.flushBackBuffer()},e.onBufferEos=function(t,e){var i=this;this.getSourceBufferTypes().reduce((function(t,r){var n=i.sourceBuffer[r];return e.type&&e.type!==r||n&&!n.ended&&(n.ended=!0,s.logger.log("[buffer-controller]: "+r+" sourceBuffer now EOS")),t&&!(n&&!n.ended)}),!0)&&this.blockBuffers((function(){var t=i.mediaSource;t&&"open"===t.readyState&&t.endOfStream()}))},e.onLevelUpdated=function(t,e){var i=e.details;i.fragments.length&&(this.details=i,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},e.flushBackBuffer=function(){var t=this.hls,e=this.details,i=this.media,s=this.sourceBuffer;if(i&&null!==e){var a=this.getSourceBufferTypes();if(a.length){var l=e.live&&null!==t.config.liveBackBufferLength?t.config.liveBackBufferLength:t.config.backBufferLength;if(Object(r.isFiniteNumber)(l)&&!(l<0)){var c=i.currentTime,h=e.levelTargetDuration,u=Math.max(l,h),d=Math.floor(c/h)*h-u;a.forEach((function(i){var r=s[i];if(r){var a=o.BufferHelper.getBuffered(r);a.length>0&&d>a.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:i}))}}))}}}},e.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var t=this.details,e=this.hls,i=this.media,n=this.mediaSource,a=t.fragments[0].start+t.totalduration,o=i.duration,l=Object(r.isFiniteNumber)(n.duration)?n.duration:0;t.live&&e.config.liveDurationInfinity?(s.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(t)):(a>l&&a>o||!Object(r.isFiniteNumber)(o))&&(s.logger.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),n.duration=a)}},e.updateSeekableRange=function(t){var e=this.mediaSource,i=t.fragments;if(i.length&&t.live&&null!=e&&e.setLiveSeekableRange){var r=Math.max(0,i[0].start),n=Math.max(r,r+t.totalduration);e.setLiveSeekableRange(r,n)}},e.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,e=this.operationQueue,i=this.pendingTracks,r=Object.keys(i).length;if(r&&!t||2===r){this.createSourceBuffers(i),this.pendingTracks={};var s=this.getSourceBufferTypes();if(0===s.length)return void this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});s.forEach((function(t){e.executeNext(t)}))}},e.createSourceBuffers=function(t){var e=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");var r=0;for(var o in t)if(!e[o]){var l=t[o];if(!l)throw Error("source buffer exists for track "+o+", however track does not");var c=l.levelCodec||l.codec,h=l.container+";codecs="+c;s.logger.log("[buffer-controller]: creating sourceBuffer("+h+")");try{var u=e[o]=i.addSourceBuffer(h),d=o;this.addBufferListener(d,"updatestart",this._onSBUpdateStart),this.addBufferListener(d,"updateend",this._onSBUpdateEnd),this.addBufferListener(d,"error",this._onSBUpdateError),this.tracks[o]={buffer:u,codec:c,container:l.container,levelCodec:l.levelCodec,id:l.id},r++}catch(t){s.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:h})}}r&&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){s.logger.error("[buffer-controller]: "+t+" SourceBuffer error",e),this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var i=this.operationQueue.current(t);i&&i.onError(e)},e.removeExecutor=function(t,e,i){var n=this.media,a=this.mediaSource,o=this.operationQueue,l=this.sourceBuffer[t];if(!n||!a||!l)return s.logger.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(t);var c=Object(r.isFiniteNumber)(n.duration)?n.duration:1/0,h=Object(r.isFiniteNumber)(a.duration)?a.duration:1/0,u=Math.max(0,e),d=Math.min(i,c,h);d>u?(s.logger.log("[buffer-controller]: Removing ["+u+","+d+"] from the "+t+" SourceBuffer"),console.assert(!l.updating,t+" sourceBuffer must not be updating"),l.remove(u,d)):o.shiftAndExecuteNext(t)},e.appendExecutor=function(t,e){var i=this.operationQueue,r=this.sourceBuffer[e];if(!r)return s.logger.warn("[buffer-controller]: Attempting to append to the "+e+" SourceBuffer, but it does not exist"),void i.shiftAndExecuteNext(e);r.ended=!1,console.assert(!r.updating,e+" sourceBuffer must not be updating"),r.appendBuffer(t)},e.blockBuffers=function(t,e){var i=this;if(void 0===e&&(e=this.getSourceBufferTypes()),!e.length)return s.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve(t);var r=this.operationQueue,n=e.map((function(t){return r.appendBlocker(t)}));Promise.all(n).then((function(){t(),e.forEach((function(t){var e=i.sourceBuffer[t];e&&e.updating||r.shiftAndExecuteNext(t)}))}))},e.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},e.addBufferListener=function(t,e,i){var r=this.sourceBuffer[t];if(r){var n=i.bind(this,t);this.listeners[t].push({event:e,listener:n}),r.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,i){"use strict";i.r(e),i.d(e,"default",(function(){return n}));var r=i(/*! ../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 i=this.queues[e];i.push(t),1===i.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,i=new Promise((function(t){e=t})),r={execute:e,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(r,t),i},e.executeNext=function(t){var e=this.buffers,i=this.queues,n=e[t],s=i[t];if(s.length){var a=s[0];try{a.execute()}catch(e){r.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),a.onError(e),n&&n.updating||(s.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,i){"use strict";i.r(e);var r=i(/*! ../events */"./src/events.ts");function n(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var s=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,i,s,a=t.prototype;return a.setStreamController=function(t){this.streamController=t},a.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},a.registerListeners=function(){var t=this.hls;t.on(r.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(r.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(r.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},a.unregisterListener=function(){var t=this.hls;t.off(r.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(r.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(r.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},a.onFpsDropLevelCapping=function(e,i){t.isLevelAllowed(i.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(i.droppedLevel)},a.onMediaAttaching=function(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null},a.onManifestParsed=function(t,e){var i=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,i.config.capLevelToPlayerSize&&e.video&&this.startCapping()},a.onBufferCodecs=function(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()},a.onMediaDetaching=function(){this.stopCapping()},a.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}}},a.getMaxLevel=function(e){var i=this,r=this.hls.levels;if(!r.length)return-1;var n=r.filter((function(r,n){return t.isLevelAllowed(n,i.restrictedLevels)&&n<=e}));return this.clientRect=null,t.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)},a.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())},a.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},a.getDimensions=function(){if(this.clientRect)return this.clientRect;var t=this.media,e={width:0,height:0};if(t){var i=t.getBoundingClientRect();e.width=i.width,e.height=i.height,e.width||e.height||(e.width=i.right-i.left||t.width||0,e.height=i.bottom-i.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,i){if(!t||!t.length)return-1;for(var r,n,s=t.length-1,a=0;a<t.length;a+=1){var o=t[a];if((o.width>=e||o.height>=i)&&(r=o,!(n=t[a+1])||r.width!==n.width||r.height!==n.height)){s=a;break}}return s},e=t,s=[{key:"contentScaleFactor",get:function(){var t=1;try{t=self.devicePixelRatio}catch(t){}return t}}],(i=[{key:"mediaWidth",get:function(){return this.getDimensions().width*t.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*t.contentScaleFactor}}])&&n(e.prototype,i),s&&n(e,s),t}();e.default=s},"./src/controller/cmcd-controller.ts":
|
|
|
/*!*******************************************!*\
|
|
|
!*** ./src/controller/cmcd-controller.ts ***!
|
|
|
\*******************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return d}));var r=i(/*! ../events */"./src/events.ts"),n=i(/*! ../types/cmcd */"./src/types/cmcd.ts"),s=i(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),a=i(/*! ../utils/logger */"./src/utils/logger.ts");function o(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function l(t,e,i){return e&&o(t.prototype,e),i&&o(t,i),t}function c(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(i)return(i=i.call(t)).next.bind(i);if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return h(t,e);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)?h(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}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 h(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=new Array(e);i<e;i++)r[i]=t[i];return r}function u(){return(u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t}).apply(this,arguments)}var d=function(){function t(e){var i=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(){i.initialized&&(i.starved=!0),i.buffering=!0},this.onPlaying=function(){i.initialized||(i.initialized=!0),i.buffering=!1},this.applyPlaylistData=function(t){try{i.apply(t,{ot:n.CMCDObjectType.MANIFEST,su:!i.initialized})}catch(t){a.logger.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=function(t){try{var e=t.frag,r=i.hls.levels[e.level],s=i.getObjectType(e),o={d:1e3*e.duration,ot:s};s!==n.CMCDObjectType.VIDEO&&s!==n.CMCDObjectType.AUDIO&&s!=n.CMCDObjectType.MUXED||(o.br=r.bitrate/1e3,o.tb=i.getTopBandwidth(s),o.bl=i.getBufferLength(s)),i.apply(t,o)}catch(t){a.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=e;var r=this.config=e.config,s=r.cmcd;null!=s&&(r.pLoader=this.createPlaylistLoader(),r.fLoader=this.createFragmentLoader(),this.sid=s.sessionId||t.uuid(),this.cid=s.contentId,this.useHeaders=!0===s.useHeaders,this.registerListeners())}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;t.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(r.Events.MEDIA_DETACHED,this.onMediaDetached,this),t.on(r.Events.BUFFER_CREATED,this.onBufferCreated,this)},e.unregisterListeners=function(){var t=this.hls;t.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(r.Events.MEDIA_DETACHED,this.onMediaDetached,this),t.off(r.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 i,r;this.audioBuffer=null===(i=e.tracks.audio)||void 0===i?void 0:i.buffer,this.videoBuffer=null===(r=e.tracks.video)||void 0===r?void 0:r.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,i){void 0===i&&(i={}),u(i,this.createData());var r=i.ot===n.CMCDObjectType.INIT||i.ot===n.CMCDObjectType.VIDEO||i.ot===n.CMCDObjectType.MUXED;if(this.starved&&r&&(i.bs=!0,i.su=!0,this.starved=!1),null==i.su&&(i.su=this.buffering),this.useHeaders){var s=t.toHeaders(i);if(!Object.keys(s).length)return;e.headers||(e.headers={}),u(e.headers,s)}else{var a=t.toQuery(i);if(!a)return;e.url=t.appendQueryToUri(e.url,a)}},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,i=0,r=c(t===n.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels);!(e=r()).done;){var s=e.value;s.bitrate>i&&(i=s.bitrate)}return i>0?i:NaN},e.getBufferLength=function(t){var e=this.hls.media,i=t===n.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;return i&&e?1e3*s.BufferHelper.bufferInfo(i,e.currentTime,this.config.maxBufferHole).len:NaN},e.createPlaylistLoader=function(){var t=this.config.pLoader,e=this.applyPlaylistData,i=t||this.config.loader;return function(){function t(t){this.loader=void 0,this.loader=new i(t)}var r=t.prototype;return r.destroy=function(){this.loader.destroy()},r.abort=function(){this.loader.abort()},r.load=function(t,i,r){e(t),this.loader.load(t,i,r)},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,i=t||this.config.loader;return function(){function t(t){this.loader=void 0,this.loader=new i(t)}var r=t.prototype;return r.destroy=function(){this.loader.destroy()},r.abort=function(){this.loader.abort()},r.load=function(t,i,r){e(t),this.loader.load(t,i,r)},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,i=[],r=function(t){return!Number.isNaN(t)&&null!=t&&""!==t&&!1!==t},n=function(t){return Math.round(t)},s=function(t){return 100*n(t/100)},a={br:n,d:n,bl:s,dl:s,mtp:s,nor:function(t){return encodeURIComponent(t)},rtp:s,tb:n},o=c(Object.keys(t||{}).sort());!(e=o()).done;){var l=e.value,h=t[l];if(r(h)&&!("v"===l&&1===h||"pr"==l&&1===h)){var u=a[l];u&&(h=u(h));var d=typeof h,f=void 0;f="ot"===l||"sf"===l||"st"===l?l+"="+h:"boolean"===d?l:"number"===d?l+"="+h:l+"="+JSON.stringify(h),i.push(f)}}return i.join(",")},t.toHeaders=function(e){for(var i={},r=["Object","Request","Session","Status"],n=[{},{},{},{}],s={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},a=0,o=Object.keys(e);a<o.length;a++){var l=o[a];n[null!=s[l]?s[l]:1][l]=e[l]}for(var c=0;c<n.length;c++){var h=t.serialize(n[c]);h&&(i["CMCD-"+r[c]]=h)}return i},t.toQuery=function(e){return"CMCD="+encodeURIComponent(t.serialize(e))},t.appendQueryToUri=function(t,e){if(!e)return t;var i=t.includes("?")?"&":"?";return""+t+i+e},t}()},"./src/controller/eme-controller.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/controller/eme-controller.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var r=i(/*! ../events */"./src/events.ts"),n=i(/*! ../errors */"./src/errors.ts"),s=i(/*! ../utils/logger */"./src/utils/logger.ts"),a=i(/*! ../utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts");function o(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}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,i,l,c=t.prototype;return c.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},c._registerListeners=function(){this.hls.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(r.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(r.Events.MANIFEST_PARSED,this.onManifestParsed,this)},c._unregisterListeners=function(){this.hls.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(r.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(r.Events.MANIFEST_PARSED,this.onManifestParsed,this)},c.getLicenseServerUrl=function(t){switch(t){case a.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,i){var r=this,n=function(t,e,i,r){switch(t){case a.KeySystems.WIDEVINE:return function(t,e,i){var r={audioCapabilities:[],videoCapabilities:[]};return t.forEach((function(t){r.audioCapabilities.push({contentType:'audio/mp4; codecs="'+t+'"',robustness:i.audioRobustness||""})})),e.forEach((function(t){r.videoCapabilities.push({contentType:'video/mp4; codecs="'+t+'"',robustness:i.videoRobustness||""})})),[r]}(e,i,r);default:throw new Error("Unknown key-system: "+t)}}(t,e,i,this._drmSystemOptions);s.logger.log("Requesting encrypted media key-system access");var o=this.requestMediaKeySystemAccess(t,n);this.mediaKeysPromise=o.then((function(e){return r._onMediaKeySystemAccessObtained(t,e)})),o.catch((function(e){s.logger.error('Failed to obtain key-system "'+t+'" access:',e)}))},c._onMediaKeySystemAccessObtained=function(t,e){var i=this;s.logger.log('Access for key-system "'+t+'" obtained');var r={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:t};this._mediaKeysList.push(r);var n=Promise.resolve().then((function(){return e.createMediaKeys()})).then((function(e){return r.mediaKeys=e,s.logger.log('Media-keys created for key-system "'+t+'"'),i._onMediaKeysCreated(),e}));return n.catch((function(t){s.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;s.logger.log("New key-system session "+t.sessionId),t.addEventListener("message",(function(i){e._onKeySessionMessage(t,i.message)}),!1)},c._onKeySessionMessage=function(t,e){s.logger.log("Got EME message event, creating license request"),this._requestLicense(e,(function(e){s.logger.log("Received license data (length: "+(e?e.byteLength:e)+"), updating key-session"),t.update(e)}))},c.onMediaEncrypted=function(t){var e=this;if(s.logger.log('Media is encrypted using "'+t.initDataType+'" init data type'),!this.mediaKeysPromise)return s.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),void this.hls.trigger(r.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});var i=function(i){e._media&&(e._attemptSetMediaKeys(i),e._generateRequestWithPreferredKeySession(t.initDataType,t.initData))};this.mediaKeysPromise.then(i).catch(i)},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 s.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(r.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});s.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},c._generateRequestWithPreferredKeySession=function(t,e){var i=this,a=this._mediaKeysList[0];if(!a)return s.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(r.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});if(a.mediaKeysSessionInitialized)s.logger.warn("Key-Session already initialized but requested again");else{var o=a.mediaKeysSession;if(!o)return s.logger.error("Fatal: Media is encrypted but no key-session existing"),void this.hls.trigger(r.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});if(!e)return s.logger.warn("Fatal: initData required for generating a key session is null"),void this.hls.trigger(r.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});s.logger.log('Generating key-session request for "'+t+'" init data type'),a.mediaKeysSessionInitialized=!0,o.generateRequest(t,e).then((function(){s.logger.debug("Key-session generation succeeded")})).catch((function(t){s.logger.error("Error generating key-session request:",t),i.hls.trigger(r.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})}))}},c._createLicenseXhr=function(t,e,i){var r=new XMLHttpRequest;r.responseType="arraybuffer",r.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,r,t,e,i);var n=this._licenseXhrSetup;if(n)try{n.call(this.hls,r,t),n=void 0}catch(t){s.logger.error(t)}try{r.readyState||r.open("POST",t,!0),n&&n.call(this.hls,r,t)}catch(t){throw new Error("issue setting up KeySystem license XHR "+t)}return r},c._onLicenseRequestReadyStageChange=function(t,e,i,a){switch(t.readyState){case 4:if(200===t.status){this._requestLicenseFailureCount=0,s.logger.log("License request succeeded");var o=t.response,l=this._licenseResponseCallback;if(l)try{o=l.call(this.hls,t,e)}catch(t){s.logger.error(t)}a(o)}else{if(s.logger.error("License Request XHR failed ("+e+"). Status: "+t.status+" ("+t.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>3)return void this.hls.trigger(r.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});var c=3-this._requestLicenseFailureCount+1;s.logger.warn("Retrying license request, "+c+" attempts left"),this._requestLicense(i,a)}}},c._generateLicenseRequestChallenge=function(t,e){switch(t.mediaKeySystemDomain){case a.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+t.mediaKeySystemDomain)},c._requestLicense=function(t,e){s.logger.log("Requesting content license for key-system");var i=this._mediaKeysList[0];if(!i)return s.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(r.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var a=this.getLicenseServerUrl(i.mediaKeySystemDomain),o=this._createLicenseXhr(a,t,e);s.logger.log("Sending license request to URL: "+a);var l=this._generateLicenseRequestChallenge(i,t);o.send(l)}catch(t){s.logger.error("Failure requesting DRM license: "+t),this.hls.trigger(r.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 i=e.media;this._media=i,i.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 i=e.levels.map((function(t){return t.audioCodec})).filter((function(t){return!!t})),r=e.levels.map((function(t){return t.videoCodec})).filter((function(t){return!!t}));this._attemptKeySystemAccess(a.KeySystems.WIDEVINE,i,r)}},e=t,(i=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&o(e.prototype,i),l&&o(e,l),t}();e.default=l},"./src/controller/fps-controller.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/controller/fps-controller.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var r=i(/*! ../events */"./src/events.ts"),n=i(/*! ../utils/logger */"./src/utils/logger.ts"),s=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(r.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},e.unregisterListeners=function(){this.hls.off(r.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 i=this.hls.config;if(i.capLevelOnFPSDrop){var r=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=r,r&&"function"==typeof r.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}},e.checkFPS=function(t,e,i){var s=performance.now();if(e){if(this.lastTime){var a=s-this.lastTime,o=i-this.lastDroppedFrames,l=e-this.lastDecodedFrames,c=1e3*o/a,h=this.hls;if(h.trigger(r.Events.FPS_DROP,{currentDropped:o,currentDecoded:l,totalDroppedFrames:i}),c>0&&o>h.config.fpsDroppedMonitoringThreshold*l){var u=h.currentLevel;n.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===h.autoLevelCapping||h.autoLevelCapping>=u)&&(u-=1,h.trigger(r.Events.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:h.currentLevel}),h.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=i,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=s},"./src/controller/fragment-finders.ts":
|
|
|
/*!********************************************!*\
|
|
|
!*** ./src/controller/fragment-finders.ts ***!
|
|
|
\********************************************/
|
|
|
/*! exports provided: findFragmentByPDT, findFragmentByPTS, fragmentWithinToleranceTest, pdtWithinToleranceTest, findFragWithCC */function(t,e,i){"use strict";i.r(e),i.d(e,"findFragmentByPDT",(function(){return s})),i.d(e,"findFragmentByPTS",(function(){return a})),i.d(e,"fragmentWithinToleranceTest",(function(){return o})),i.d(e,"pdtWithinToleranceTest",(function(){return l})),i.d(e,"findFragWithCC",(function(){return c}));var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ../utils/binary-search */"./src/utils/binary-search.ts");function s(t,e,i){if(null===e||!Array.isArray(t)||!t.length||!Object(r.isFiniteNumber)(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;i=i||0;for(var n=0;n<t.length;++n){var s=t[n];if(l(e,i,s))return s}return null}function a(t,e,i,r){void 0===i&&(i=0),void 0===r&&(r=0);var s=null;if(t?s=e[t.sn-e[0].sn+1]||null:0===i&&0===e[0].start&&(s=e[0]),s&&0===o(i,r,s))return s;var a=n.default.search(e,o.bind(null,i,r));return a||s}function o(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0);var r=Math.min(e,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-r<=t?1:i.start-r>t&&i.start?-1:0}function l(t,e,i){var r=1e3*Math.min(e,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-r>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,i){"use strict";i.r(e),i.d(e,"FragmentState",(function(){return r})),i.d(e,"FragmentTracker",(function(){return a}));var r,n=i(/*! ../events */"./src/events.ts"),s=i(/*! ../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"}(r||(r={}));var a=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===s.PlaylistLevelType.MAIN){var i=this.activeFragment,r=this.activeParts;if(!i)return null;if(r)for(var n=r.length;n--;){var a=r[n],o=a?a.end:i.appendedPTS;if(a.start<=t&&void 0!==o&&t<=o)return n>9&&(this.activeParts=r.slice(n-9)),a}else if(i.start<=t&&void 0!==i.appendedPTS&&t<=i.appendedPTS)return i}return this.getBufferedFrag(t,e)},e.getBufferedFrag=function(t,e){for(var i=this.fragments,r=Object.keys(i),n=r.length;n--;){var s=i[r[n]];if((null==s?void 0:s.body.type)===e&&s.buffered){var a=s.body;if(a.start<=t&&t<=a.end)return a}}return null},e.detectEvictedFragments=function(t,e,i){var r=this;Object.keys(this.fragments).forEach((function(n){var s=r.fragments[n];if(s)if(s.buffered){var a=s.range[t];a&&a.time.some((function(t){var i=!r.isTimeBuffered(t.startPTS,t.endPTS,e);return i&&r.removeFragment(s.body),i}))}else s.body.type===i&&r.removeFragment(s.body)}))},e.detectPartialFragments=function(t){var e=this,i=this.timeRanges,r=t.frag,n=t.part;if(i&&"initSegment"!==r.sn){var s=l(r),a=this.fragments[s];a&&(Object.keys(i).forEach((function(t){var s=r.elementaryStreams[t];if(s){var o=i[t],l=null!==n||!0===s.partial;a.range[t]=e.getBufferedTimes(r,n,l,o)}})),a.backtrack=a.loaded=null,Object.keys(a.range).length?a.buffered=!0:this.removeFragment(a.body))}},e.fragBuffered=function(t){var e=l(t),i=this.fragments[e];i&&(i.backtrack=i.loaded=null,i.buffered=!0)},e.getBufferedTimes=function(t,e,i,r){for(var n={time:[],partial:i},s=e?e.start:t.start,a=e?e.end:t.end,o=t.minEndPTS||a,l=t.maxStartPTS||s,c=0;c<r.length;c++){var h=r.start(c)-this.bufferPadding,u=r.end(c)+this.bufferPadding;if(l>=h&&o<=u){n.time.push({startPTS:Math.max(s,r.start(c)),endPTS:Math.min(a,r.end(c))});break}if(s<u&&a>h)n.partial=!0,n.time.push({startPTS:Math.max(s,r.start(c)),endPTS:Math.min(a,r.end(c))});else if(a<=h)break}return n},e.getPartialFragment=function(t){var e,i,r,n=null,s=0,a=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach((function(c){var h=l[c];h&&o(h)&&(i=h.body.start-a,r=h.body.end+a,t>=i&&t<=r&&(e=Math.min(t-i,r-t),s<=e&&(n=h.body,s=e)))})),n},e.getState=function(t){var e=l(t),i=this.fragments[e];return i?i.buffered?o(i)?r.PARTIAL:r.OK:i.backtrack?r.BACKTRACKED:r.APPENDING:r.NOT_LOADED},e.backtrack=function(t,e){var i=l(t),r=this.fragments[i];if(!r||r.backtrack)return null;var n=r.backtrack=e||r.loaded;return r.loaded=null,n},e.getBacktrackData=function(t){var e=l(t),i=this.fragments[e];if(i){var r,n=i.backtrack;if(null!=n&&null!==(r=n.payload)&&void 0!==r&&r.byteLength)return n;this.removeFragment(t)}return null},e.isTimeBuffered=function(t,e,i){for(var r,n,s=0;s<i.length;s++){if(r=i.start(s)-this.bufferPadding,n=i.end(s)+this.bufferPadding,t>=r&&e<=n)return!0;if(e<=r)return!1}return!1},e.onFragLoaded=function(t,e){var i=e.frag,r=e.part;if("initSegment"!==i.sn&&!i.bitrateTest&&!r){var n=l(i);this.fragments[n]={body:i,loaded:e,backtrack:null,buffered:!1,range:Object.create(null)}}},e.onBufferAppended=function(t,e){var i=this,r=e.frag,n=e.part,a=e.timeRanges;if(r.type===s.PlaylistLevelType.MAIN)if(this.activeFragment=r,n){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(n)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach((function(t){var e=a[t];if(i.detectEvictedFragments(t,e),!n)for(var s=0;s<e.length;s++)r.appendedPTS=Math.max(e.end(s),r.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,i){var r=this;Object.keys(this.fragments).forEach((function(n){var s=r.fragments[n];if(s&&s.buffered){var a=s.body;a.type===i&&a.start<e&&a.end>t&&r.removeFragment(a)}}))},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 o(t){var e,i;return t.buffered&&((null===(e=t.range.video)||void 0===e?void 0:e.partial)||(null===(i=t.range.audio)||void 0===i?void 0:i.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,i){"use strict";i.r(e),i.d(e,"STALL_MINIMUM_DURATION_MS",(function(){return o})),i.d(e,"MAX_START_GAP_JUMP",(function(){return l})),i.d(e,"SKIP_BUFFER_HOLE_STEP_SECONDS",(function(){return c})),i.d(e,"SKIP_BUFFER_RANGE_START",(function(){return h})),i.d(e,"default",(function(){return u}));var r=i(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),n=i(/*! ../errors */"./src/errors.ts"),s=i(/*! ../events */"./src/events.ts"),a=i(/*! ../utils/logger */"./src/utils/logger.ts"),o=250,l=2,c=.1,h=.05,u=function(){function t(t,e,i,r){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=i,this.hls=r}var e=t.prototype;return e.destroy=function(){this.hls=this.fragmentTracker=this.media=null},e.poll=function(t){var e=this.config,i=this.media,n=this.stalled,s=i.currentTime,c=i.seeking,h=this.seeking&&!c,u=!this.seeking&&c;if(this.seeking=c,s===t){if((u||h)&&(this.stalled=null),!i.paused&&!i.ended&&0!==i.playbackRate&&r.BufferHelper.getBuffered(i).length){var d=r.BufferHelper.bufferInfo(i,s,0),f=d.len>0,p=d.nextStart||0;if(f||p){if(c){var g=d.len>l,v=!p||p-s>l&&!this.fragmentTracker.getPartialFragment(s);if(g||v)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var m,y=Math.max(p,d.start||0)-s,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,S=(null==b||null===(m=b.details)||void 0===m?void 0:m.live)?2*b.details.targetduration:l;if(y>0&&y<=S)return void this._trySkipBufferHole(null)}var E=self.performance.now();if(null!==n){var C=E-n;!c&&C>=o&&this._reportStall(d.len);var k=r.BufferHelper.bufferInfo(i,s,e.maxBufferHole);this._tryFixBufferStall(k,C)}else this.stalled=E}}}else if(this.moved=!0,null!==n){if(this.stallReported){var T=self.performance.now()-n;a.logger.warn("playback not stuck anymore @"+s+", after "+Math.round(T)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},e._tryFixBufferStall=function(t,e){var i=this.config,r=this.fragmentTracker,n=this.media.currentTime,s=r.getPartialFragment(n);s&&this._trySkipBufferHole(s)||t.len>i.maxBufferHole&&e>1e3*i.highBufferWatchdogPeriod&&(a.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},e._reportStall=function(t){var e=this.hls,i=this.media;this.stallReported||(this.stallReported=!0,a.logger.warn("Playback stalling at @"+i.currentTime+" due to low buffer (buffer="+t+")"),e.trigger(s.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,i=this.hls,o=this.media,l=o.currentTime,u=0,d=r.BufferHelper.getBuffered(o),f=0;f<d.length;f++){var p=d.start(f);if(l+e.maxBufferHole>=u&&l<p){var g=Math.max(p+h,o.currentTime+c);return a.logger.warn("skipping hole, adjusting currentTime from "+l+" to "+g),this.moved=!0,this.stalled=null,o.currentTime=g,t&&i.trigger(s.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}u=d.end(f)}return 0},e._tryNudgeBuffer=function(){var t=this.config,e=this.hls,i=this.media,r=i.currentTime,o=(this.nudgeRetry||0)+1;if(this.nudgeRetry=o,o<t.nudgeMaxRetry){var l=r+o*t.nudgeOffset;a.logger.warn("Nudging 'currentTime' from "+r+" to "+l),i.currentTime=l,e.trigger(s.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else a.logger.error("Playhead still not moving while enough data buffered @"+r+" after "+t.nudgeMaxRetry+" nudges"),e.trigger(s.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,i){"use strict";i.r(e);var r=i(/*! ../events */"./src/events.ts"),n=i(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),s=i(/*! ../demux/id3 */"./src/demux/id3.ts"),a=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(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(r.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},e._unregisterListeners=function(){var t=this.hls;t.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(r.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(r.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 i=t[e];if("metadata"===i.kind&&"id3"===i.label)return Object(n.sendAddTrackEvent)(i,this.media),i}return this.media.addTextTrack("metadata","id3")}},e.onFragParsingMetadata=function(t,e){if(this.media){var i=e.frag,r=e.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var n=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,a=0;a<r.length;a++){var o=s.getID3Frames(r[a].data);if(o){var l=r[a].pts,c=a<r.length-1?r[a+1].pts:i.end;c-l<=0&&(c=l+.25);for(var h=0;h<o.length;h++){var u=o[h];if(!s.isTimeStampFrame(u)){var d=new n(l,c,"");d.value=u,this.id3Track.addCue(d)}}}}}},e.onBufferFlushing=function(t,e){var i=e.startOffset,r=e.endOffset,s=e.type;if(!s||"audio"===s){var a=this.id3Track;a&&Object(n.removeCuesInRange)(a,i,r)}},t}();e.default=a},"./src/controller/latency-controller.ts":
|
|
|
/*!**********************************************!*\
|
|
|
!*** ./src/controller/latency-controller.ts ***!
|
|
|
\**********************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return o}));var r=i(/*! ../errors */"./src/errors.ts"),n=i(/*! ../events */"./src/events.ts"),s=i(/*! ../utils/logger */"./src/utils/logger.ts");function a(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var o=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,i,o,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 i=e.details;this.levelDetails=i,i.advanced&&this.timeupdate(),!i.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},l.onError=function(t,e){e.details===r.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,s.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 i=this.computeLatency();if(null!==i){this._latency=i;var r=this.config,n=r.lowLatencyMode,s=r.maxLiveSyncPlaybackRate;if(n&&1!==s){var a=this.targetLatency;if(null!==a){var o=i-a,l=o<Math.min(this.maxLatency,a+e.targetduration);if(e.live&&l&&o>.05&&this.forwardBufferLength>1){var c=Math.min(2,Math.max(1,s)),h=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;t.playbackRate=Math.min(c,Math.max(1,h))}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,(i=[{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,i=t.partHoldBack,r=t.targetduration,n=this.config,s=n.liveSyncDuration,a=n.liveSyncDurationCount,o=n.lowLatencyMode,l=this.hls.userConfig,c=o&&i||e;(l.liveSyncDuration||l.liveSyncDurationCount||0===c)&&(c=void 0!==s?s:a*r);var h=r;return c+Math.min(1*this.stallCount,h)}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),e=this.targetLatency,i=this.levelDetails;if(null===t||null===e||null===i)return null;var r=i.edge,n=t-e-this.edgeStalled,s=r-i.totalduration,a=r-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(s,n),a)}},{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 i=t.buffered.length;return i?t.buffered.end(i-1):e.edge-this.currentTime}}])&&a(e.prototype,i),o&&a(e,o),t}()},"./src/controller/level-controller.ts":
|
|
|
/*!********************************************!*\
|
|
|
!*** ./src/controller/level-controller.ts ***!
|
|
|
\********************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return p}));var r=i(/*! ../types/level */"./src/types/level.ts"),n=i(/*! ../events */"./src/events.ts"),s=i(/*! ../errors */"./src/errors.ts"),a=i(/*! ../utils/codecs */"./src/utils/codecs.ts"),o=i(/*! ./level-helper */"./src/controller/level-helper.ts"),l=i(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),c=i(/*! ../types/loader */"./src/types/loader.ts");function h(){return(h=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t}).apply(this,arguments)}function u(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}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,i;function l(e){var i;return(i=t.call(this,e,"[level-controller]")||this)._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.onParsedComplete=void 0,i._registerListeners(),i}i=t,(e=l).prototype=Object.create(i.prototype),e.prototype.constructor=e,d(e,i);var p,g,v,m=l.prototype;return m._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)},m._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)},m.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,t.prototype.destroy.call(this)},m.startLoad=function(){this._levels.forEach((function(t){t.loadError=0})),t.prototype.startLoad.call(this)},m.onManifestLoaded=function(t,e){var i,l,c=[],h=[],u=[],d={},p=!1,g=!1,v=!1;if(e.levels.forEach((function(t){var e=t.attrs;p=p||!(!t.width||!t.height),g=g||!!t.videoCodec,v=v||!!t.audioCodec,f&&t.audioCodec&&-1!==t.audioCodec.indexOf("mp4a.40.34")&&(t.audioCodec=void 0);var i=t.bitrate+"-"+t.attrs.RESOLUTION+"-"+t.attrs.CODECS;(l=d[i])?l.url.push(t.url):(l=new r.Level(t),d[i]=l,c.push(l)),e&&(e.AUDIO&&Object(o.addGroupId)(l,"audio",e.AUDIO),e.SUBTITLES&&Object(o.addGroupId)(l,"text",e.SUBTITLES))})),(p||g)&&v&&(c=c.filter((function(t){var e=t.videoCodec,i=t.width,r=t.height;return!!e||!(!i||!r)}))),c=c.filter((function(t){var e=t.audioCodec,i=t.videoCodec;return(!e||Object(a.isCodecSupportedInMp4)(e,"audio"))&&(!i||Object(a.isCodecSupportedInMp4)(i,"video"))})),e.audioTracks&&(h=e.audioTracks.filter((function(t){return!t.audioCodec||Object(a.isCodecSupportedInMp4)(t.audioCodec,"audio")})),Object(o.assignTrackIdsByGroup)(h)),e.subtitles&&(u=e.subtitles,Object(o.assignTrackIdsByGroup)(u)),c.length>0){i=c[0].bitrate,c.sort((function(t,e){return t.bitrate-e.bitrate})),this._levels=c;for(var m=0;m<c.length;m++)if(c[m].bitrate===i){this._firstLevel=m,this.log("manifest loaded, "+c.length+" level(s) found, first bitrate: "+i);break}var y=v&&!g,b={levels:c,audioTracks:h,subtitleTracks:u,firstLevel:this._firstLevel,stats:e.stats,audio:v,video:g,altAudio:!y&&h.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:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,reason:"no level with compatible codecs found in manifest"})},m.onError=function(e,i){if(t.prototype.onError.call(this,e,i),!i.fatal){var r=i.context,n=this._levels[this.currentLevelIndex];if(r&&(r.type===c.PlaylistContextType.AUDIO_TRACK&&n.audioGroupIds&&r.groupId===n.audioGroupIds[n.urlId]||r.type===c.PlaylistContextType.SUBTITLE_TRACK&&n.textGroupIds&&r.groupId===n.textGroupIds[n.urlId]))this.redundantFailover(this.currentLevelIndex);else{var a,o=!1,l=!0;switch(i.details){case s.ErrorDetails.FRAG_LOAD_ERROR:case s.ErrorDetails.FRAG_LOAD_TIMEOUT:case s.ErrorDetails.KEY_LOAD_ERROR:case s.ErrorDetails.KEY_LOAD_TIMEOUT:if(i.frag){var h=this._levels[i.frag.level];h?(h.fragmentError++,h.fragmentError>this.hls.config.fragLoadingMaxRetry&&(a=i.frag.level)):a=i.frag.level}break;case s.ErrorDetails.LEVEL_LOAD_ERROR:case s.ErrorDetails.LEVEL_LOAD_TIMEOUT:r&&(r.deliveryDirectives&&(l=!1),a=r.level),o=!0;break;case s.ErrorDetails.REMUX_ALLOC_ERROR:a=i.level,o=!0}void 0!==a&&this.recoverLevel(i,a,o,l)}}},m.recoverLevel=function(t,e,i,r){var n=t.details,s=this._levels[e];if(s.loadError++,i){if(!this.retryLoadingOrFail(t))return void(this.currentLevelIndex=-1);t.levelRetry=!0}if(r){var a=s.url.length;if(a>1&&s.loadError<a)t.levelRetry=!0,this.redundantFailover(e);else if(-1===this.manualLevelIndex){var o=0===e?this._levels.length-1:e-1;this.currentLevelIndex!==o&&0===this._levels[o].loadError&&(this.warn(n+": switch to "+o),t.levelRetry=!0,this.hls.nextAutoLevel=o)}}},m.redundantFailover=function(t){var e=this._levels[t],i=e.url.length;if(i>1){var r=(e.urlId+1)%i;this.warn("Switching to redundant URL-id "+r),this._levels.forEach((function(t){t.urlId=r})),this.level=t}},m.onFragLoaded=function(t,e){var i=e.frag;if(void 0!==i&&i.type===c.PlaylistLevelType.MAIN){var r=this._levels[i.level];void 0!==r&&(r.fragmentError=0,r.loadError=0)}},m.onLevelLoaded=function(t,e){var i,r,n=e.level,s=e.details,a=this._levels[n];if(!a)return this.warn("Invalid level index "+n),void(null!==(r=e.deliveryDirectives)&&void 0!==r&&r.skip&&(s.deltaUpdateFailed=!0));n===this.currentLevelIndex?(0===a.fragmentError&&(a.loadError=0,this.retryCount=0),this.playlistLoaded(n,e,a.details)):null!==(i=e.deliveryDirectives)&&void 0!==i&&i.skip&&(s.deltaUpdateFailed=!0)},m.onAudioTrackSwitched=function(t,e){var i=this.hls.levels[this.currentLevelIndex];if(i&&i.audioGroupIds){for(var r=-1,n=this.hls.audioTracks[e.id].groupId,s=0;s<i.audioGroupIds.length;s++)if(i.audioGroupIds[s]===n){r=s;break}r!==i.urlId&&(i.urlId=r,this.startLoad())}},m.loadPlaylist=function(t){var e=this.currentLevelIndex,i=this._levels[e];if(this.canLoad&&i&&i.url.length>0){var r=i.urlId,s=i.url[r];if(t)try{s=t.addDirectives(s)}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 "+r+" "+s),this.clearTimer(),this.hls.trigger(n.Events.LEVEL_LOADING,{url:s,level:e,id:r,deliveryDirectives:t||null})}},m.removeLevel=function(t,e){var i=function(t,i){return i!==e},r=this._levels.filter((function(r,n){return n!==t||r.url.length>1&&void 0!==e&&(r.url=r.url.filter(i),r.audioGroupIds&&(r.audioGroupIds=r.audioGroupIds.filter(i)),r.textGroupIds&&(r.textGroupIds=r.textGroupIds.filter(i)),r.urlId=0,!0)})).map((function(t,e){var i=t.details;return null!=i&&i.fragments&&i.fragments.forEach((function(t){t.level=e})),t}));this._levels=r,this.hls.trigger(n.Events.LEVELS_UPDATED,{levels:r})},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,i=this._levels;if(0!==i.length&&(this.currentLevelIndex!==t||null===(e=i[t])||void 0===e||!e.details)){if(t<0||t>=i.length){var r=t<0;if(this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.LEVEL_SWITCH_ERROR,level:t,fatal:r,reason:"invalid level idx"}),r)return;t=Math.min(t,i.length-1)}this.clearTimer();var a=this.currentLevelIndex,o=i[a],l=i[t];this.log("switching to level "+t+" from "+a),this.currentLevelIndex=t;var c=h({},l,{level:t,maxBitrate:l.maxBitrate,uri:l.uri,urlId:l.urlId});delete c._urlId,this.hls.trigger(n.Events.LEVEL_SWITCHING,c);var u=l.details;if(!u||u.live){var d=this.switchParams(l.uri,null==o?void 0:o.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)}}])&&u(p.prototype,g),v&&u(p,v),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,i){"use strict";i.r(e),i.d(e,"addGroupId",(function(){return s})),i.d(e,"assignTrackIdsByGroup",(function(){return a})),i.d(e,"updatePTS",(function(){return o})),i.d(e,"updateFragPTSDTS",(function(){return c})),i.d(e,"mergeDetails",(function(){return h})),i.d(e,"mapPartIntersection",(function(){return u})),i.d(e,"mapFragmentIntersection",(function(){return d})),i.d(e,"adjustSliding",(function(){return f})),i.d(e,"addSliding",(function(){return p})),i.d(e,"computeReloadInterval",(function(){return g})),i.d(e,"getFragmentWithSN",(function(){return v})),i.d(e,"getPartWith",(function(){return m}));var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ../utils/logger */"./src/utils/logger.ts");function s(t,e,i){switch(e){case"audio":t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds.push(i);break;case"text":t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds.push(i)}}function a(t){var e={};t.forEach((function(t){var i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++}))}function o(t,e,i){l(t[e],t[i])}function l(t,e){var i=e.startPTS;if(Object(r.isFiniteNumber)(i)){var n,s=0;e.sn>t.sn?(s=i-t.start,n=t):(s=t.start-i,n=e),n.duration!==s&&(n.duration=s)}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,i,s,a,o){s-i<=0&&(n.logger.warn("Fragment should have a positive duration",e),s=i+e.duration,o=a+e.duration);var c=i,h=s,u=e.startPTS,d=e.endPTS;if(Object(r.isFiniteNumber)(u)){var f=Math.abs(u-i);Object(r.isFiniteNumber)(e.deltaPTS)?e.deltaPTS=Math.max(f,e.deltaPTS):e.deltaPTS=f,c=Math.max(i,u),i=Math.min(i,u),a=Math.min(a,e.startDTS),h=Math.min(s,d),s=Math.max(s,d),o=Math.max(o,e.endDTS)}e.duration=s-i;var p=i-e.start;e.appendedPTS=s,e.start=e.startPTS=i,e.maxStartPTS=c,e.startDTS=a,e.endPTS=s,e.minEndPTS=h,e.endDTS=o;var g,v=e.sn;if(!t||v<t.startSN||v>t.endSN)return 0;var m=v-t.startSN,y=t.fragments;for(y[m]=e,g=m;g>0;g--)l(y[g],y[g-1]);for(g=m;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 h(t,e){for(var i=null,s=t.fragments,a=s.length-1;a>=0;a--){var o=s[a].initSegment;if(o){i=o;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var l,h=0;if(d(t,e,(function(t,n){t.relurl&&(h=t.cc-n.cc),Object(r.isFiniteNumber)(t.startPTS)&&Object(r.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,i=t.initSegment)})),i&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach((function(t){var e;t.initSegment&&t.initSegment.relurl!==(null===(e=i)||void 0===e?void 0:e.relurl)||(t.initSegment=i)})),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(h){n.logger.warn("discontinuity sliding from playlist, take drift into account");for(var v=0;v<g.length;v++)g[v].cc+=h}e.skippedSegments&&(e.startCC=e.fragments[0].cc),u(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 m=e.advancedDateTime;if(e.advanced&&m){var y=e.edge;e.driftStart||(e.driftStartTime=m,e.driftStart=y),e.driftEndTime=m,e.driftEnd=y}else e.driftEndTime=t.driftEndTime,e.driftEnd=t.driftEnd,e.advancedDateTime=t.advancedDateTime}function u(t,e,i){if(t&&e)for(var r=0,n=0,s=t.length;n<=s;n++){var a=t[n],o=e[n+r];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?i(a,o):r--}}function d(t,e,i){for(var r=e.skippedSegments,n=Math.max(t.startSN,e.startSN)-e.startSN,s=(t.fragmentHint?1:0)+(r?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,a=e.startSN-t.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,c=n;c<=s;c++){var h=l[a+c],u=o[c];r&&!u&&c<r&&(u=e.fragments[c]=h),h&&u&&i(h,u)}}function f(t,e){var i=e.startSN+e.skippedSegments-t.startSN,r=t.fragments;i<0||i>=r.length||p(e,r[i].start)}function p(t,e){if(e){for(var i=t.fragments,r=t.skippedSegments;r<i.length;r++)i[r].start+=e;t.fragmentHint&&(t.fragmentHint.start+=e)}}function g(t,e){var i,r=1e3*t.levelTargetDuration,n=r/2,s=t.age,a=s>0&&s<3*r,o=e.loading.end-e.loading.start,l=t.availabilityDelay;if(!1===t.updated)if(a){var c=333*t.misses;i=Math.max(Math.min(n,2*o),c),t.availabilityDelay=(t.availabilityDelay||0)+i}else i=n;else a?(l=Math.min(l||r/2,s),t.availabilityDelay=l,i=l+r-s):i=r-o;return Math.round(i)}function v(t,e,i){if(!t||!t.details)return null;var r=t.details,n=r.fragments[e-r.startSN];return n||((n=r.fragmentHint)&&n.sn===e?n:e<r.startSN&&i&&i.sn===e?i:null)}function m(t,e,i){if(!t||!t.details)return null;var r=t.details.partList;if(r)for(var n=r.length;n--;){var s=r[n];if(s.index===i&&s.fragment.sn===e)return s}return null}},"./src/controller/stream-controller.ts":
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./src/controller/stream-controller.ts ***!
|
|
|
\*********************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return y}));var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),s=i(/*! ../is-supported */"./src/is-supported.ts"),a=i(/*! ../events */"./src/events.ts"),o=i(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=i(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),c=i(/*! ../types/loader */"./src/types/loader.ts"),h=i(/*! ../loader/fragment */"./src/loader/fragment.ts"),u=i(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),d=i(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),f=i(/*! ./gap-controller */"./src/controller/gap-controller.ts"),p=i(/*! ../errors */"./src/errors.ts"),g=i(/*! ../utils/logger */"./src/utils/logger.ts");function v(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function m(t,e){return(m=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var y=function(t){var e,i;function y(e,i){var r;return(r=t.call(this,e,i,"[stream-controller]")||this).audioCodecSwap=!1,r.gapController=null,r.level=-1,r._forceStartLoad=!1,r.altAudio=!1,r.audioOnly=!1,r.fragPlaying=null,r.onvplaying=null,r.onvseeked=null,r.fragLastKbps=0,r.stalled=!1,r.couldBacktrack=!1,r.audioCodecSwitch=!1,r.videoBuffer=null,r._registerListeners(),r}i=t,(e=y).prototype=Object.create(i.prototype),e.prototype.constructor=e,m(e,i);var b,S,E,C=y.prototype;return C._registerListeners=function(){var t=this.hls;t.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(a.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(a.Events.ERROR,this.onError,this),t.on(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(a.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(a.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(a.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},C._unregisterListeners=function(){var t=this.hls;t.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(a.Events.ERROR,this.onError,this),t.off(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(a.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(a.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(a.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},C.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},C.startLoad=function(t){if(this.levels){var e=this.lastCurrentTime,i=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var r=i.startLevel;-1===r&&(i.config.testBandwidth?(r=0,this.bitrateTest=!0):r=i.nextAutoLevel),this.level=i.nextLoadLevel=r,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,i=this.level,r=null==e||null===(t=e[i])||void 0===t?void 0:t.details;if(r&&(!r.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(r))break;this.state=n.State.IDLE;break}break;case n.State.FRAG_LOADING_WAITING_RETRY:var s,a=self.performance.now(),o=this.retryDate;(!o||a>=o||null!==(s=this.media)&&void 0!==s&&s.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,i=this.hls,r=this.levelLastLoaded,s=this.levels,o=this.media,u=i.config,d=i.nextLoadLevel;if(null!==r&&(o||!this.startFragRequested&&u.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&s&&s[d]){var f=s[d];this.level=i.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:o,c.PlaylistLevelType.MAIN);if(null!==g&&!(g.len>=this.getMaxBufferLength(f.maxBitrate))){if(this._streamEnded(g,p)){var v={};return this.altAudio&&(v.type="video"),this.hls.trigger(a.Events.BUFFER_EOS,v),void(this.state=n.State.ENDED)}var m=g.end,y=this.getNextFragment(m,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>m){var S=this.audioOnly&&!this.altAudio?h.ElementaryStreamTypes.AUDIO:h.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(o,S,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,m):this.loadKey(y,p))}}}},C.loadFragment=function(e,i,r){var n,s=this.fragmentTracker.getState(e);if(this.fragCurrent=e,s===l.FragmentState.BACKTRACKED){var a=this.fragmentTracker.getBacktrackData(e);if(a)return this._handleFragmentLoadProgress(a),void this._handleFragmentLoadComplete(a);s=l.FragmentState.NOT_LOADED}s===l.FragmentState.NOT_LOADED||s===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,i,r)):s===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 i,r=this.getAppendedFrag(e.currentTime);if(r&&r.start>1&&this.flushMainBuffer(0,r.start-1),!e.paused&&t){var n=t[this.hls.nextLoadLevel],s=this.fragLastKbps;i=s&&this.fragCurrent?this.fragCurrent.duration*n.maxBitrate/(1e3*s)+1:0}else i=0;var a=this.getBufferedFrag(e.currentTime+i);if(a){var o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();var l=o.maxStartPTS?o.maxStartPTS:o.start,c=o.duration,h=Math.max(a.end,l+Math.min(Math.max(c-this.config.maxFragLookUpTolerance,.5*c),.75*c));this.flushMainBuffer(h,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,i){t.prototype.flushMainBuffer.call(this,e,i,this.altAudio?"video":null)},C.onMediaAttached=function(e,i){t.prototype.onMediaAttached.call(this,e,i);var r=i.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new f.default(this.config,r,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(r.isFiniteNumber)(e)&&this.log("Media seeked to "+e.toFixed(3)),this.tick()},C.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(a.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 i,r=!1,n=!1;e.levels.forEach((function(t){(i=t.audioCodec)&&(-1!==i.indexOf("mp4a.40.2")&&(r=!0),-1!==i.indexOf("mp4a.40.5")&&(n=!0))})),this.audioCodecSwitch=r&&n&&!Object(s.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 i=this.levels;if(i&&this.state===n.State.IDLE){var r=i[e.level];(!r.details||r.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(r.details))&&(this.state=n.State.WAITING_LEVEL)}},C.onLevelLoaded=function(t,e){var i,r=this.levels,s=e.level,o=e.details,l=o.totalduration;if(r){this.log("Level "+s+" loaded ["+o.startSN+","+o.endSN+"], cc ["+o.startCC+", "+o.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 h=r[s],u=0;if(o.live||null!==(i=h.details)&&void 0!==i&&i.live){if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed)return;u=this.alignPlaylists(o,h.details)}if(h.details=o,this.levelLastLoaded=s,this.hls.trigger(a.Events.LEVEL_UPDATED,{details:o,level:s}),this.state===n.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=n.State.IDLE}this.startFragRequested?o.live&&this.synchronizeToLiveEdge(o):this.setStartPosition(o,u),this.tick()}else this.warn("Levels were reset while loading level "+s)},C._handleFragmentLoadProgress=function(t){var e,i=t.frag,r=t.part,n=t.payload,s=this.levels;if(s){var a=s[i.level],o=a.details;if(o){var l=a.videoCodec,h=o.PTSKnown||!o.live,f=null===(e=i.initSegment)||void 0===e?void 0:e.data,p=this._getAudioCodec(a),g=this.transmuxer=this.transmuxer||new u.default(this.hls,c.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),v=r?r.index:-1,m=-1!==v,y=new d.ChunkMetadata(i.level,i.sn,i.stats.chunkCount,n.byteLength,v,m),b=this.initPTS[i.cc];g.push(n,f,p,l,i,r,o.totalduration,h,y,b)}else this.warn("Dropping fragment "+i.sn+" of level "+i.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},C.onAudioTrackSwitching=function(t,e){var i=this.altAudio,r=!!e.url,n=e.id;if(!r){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var s=this.fragCurrent;null!=s&&s.loader&&(this.log("Switching to main audio track, cancel main fragment load"),s.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var o=this.hls;i&&o.trigger(a.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),o.trigger(a.Events.AUDIO_TRACK_SWITCHED,{id:n})}},C.onAudioTrackSwitched=function(t,e){var i=e.id,r=!!this.hls.audioTracks[i].url;if(r){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=r,this.tick()},C.onBufferCreated=function(t,e){var i,r,n=e.tracks,s=!1;for(var a in n){var o=n[a];if("main"===o.id){if(r=a,i=o,"video"===a){var l=n[a];l&&(this.videoBuffer=l.buffer)}}else s=!0}s&&i?(this.log("Alternate track found, use "+r+".buffered to schedule main fragment loading"),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media},C.onFragBuffered=function(t,e){var i=e.frag,r=e.part;if(!i||i.type===c.PlaylistLevelType.MAIN){if(this.fragContextChanged(i))return this.warn("Fragment "+i.sn+(r?" p: "+r.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===n.State.PARSED&&(this.state=n.State.IDLE));var s=r?r.stats:i.stats;this.fragLastKbps=Math.round(8*s.total/(s.buffering.end-s.loading.first)),"initSegment"!==i.sn&&(this.fragPrevious=i),this.fragBufferedComplete(i,r)}},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 i=!0,r=this.getFwdBufferInfo(this.media,c.PlaylistLevelType.MAIN);r&&r.len>.5&&(i=!this.reduceMaxBufferLength(r.len)),i&&(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 i=o.BufferHelper.getBuffered(t);!this.loadedmetadata&&i.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 i=e.type;if(i!==h.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var r=(i===h.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,i,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,i=this.startPosition;if(i>=0&&e<i){if(t.seeking)return void g.logger.log("could not seek to "+i+", already seeking at "+e);var r=o.BufferHelper.getBuffered(t),n=(r.length?r.start(0):0)-i;n>0&&(n<this.config.maxBufferHole||n<this.config.maxFragLookUpTolerance)&&(g.logger.log("adjusting start position by "+n+" to match buffer start"),i+=n,this.startPosition=i),this.log("seek to target start position "+i+" from current time "+e),t.currentTime=i}},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(i){var r=e.hls;if(i&&!r.nextLoadLevel&&!e.fragContextChanged(t)){e.fragLoadError=0,e.state=n.State.IDLE,e.startFragRequested=!1,e.bitrateTest=!1;var s=t.stats;s.parsing.start=s.parsing.end=s.buffering.start=s.buffering.end=self.performance.now(),r.trigger(a.Events.FRAG_LOADED,i)}}))},C._handleTransmuxComplete=function(t){var e,i="main",s=this.hls,o=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 u=c.frag,d=c.part,f=c.level,p=o.video,g=o.text,v=o.id3,m=o.initSegment,y=this.altAudio?void 0:o.audio;if(!this.fragContextChanged(u)){if(this.state=n.State.PARSING,m){m.tracks&&(this._bufferInitSegment(f,m.tracks,u,l),s.trigger(a.Events.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:i,tracks:m.tracks}));var b=m.initPTS,S=m.timescale;Object(r.isFiniteNumber)(b)&&(this.initPTS[u.cc]=b,s.trigger(a.Events.INIT_PTS_FOUND,{frag:u,id:i,initPTS:b,timescale:S}))}if(p&&!1!==o.independent){if(f.details){var E=p.startPTS,C=p.endPTS,k=p.startDTS,T=p.endDTS;if(d)d.elementaryStreams[p.type]={startPTS:E,endPTS:C,startDTS:k,endDTS:T};else if(p.firstKeyFrame&&p.independent&&(this.couldBacktrack=!0),p.dropped&&p.independent){if(this.getLoadPosition()+this.config.maxBufferHole<E)return void this.backtrack(u);u.setElementaryStreamInfo(p.type,u.start,C,u.start,T,!0)}u.setElementaryStreamInfo(p.type,E,C,k,T),this.bufferFragmentData(p,u,d,l)}}else if(!1===o.independent)return void this.backtrack(u);if(y){var w=y.startPTS,x=y.endPTS,A=y.startDTS,L=y.endDTS;d&&(d.elementaryStreams[h.ElementaryStreamTypes.AUDIO]={startPTS:w,endPTS:x,startDTS:A,endDTS:L}),u.setElementaryStreamInfo(h.ElementaryStreamTypes.AUDIO,w,x,A,L),this.bufferFragmentData(y,u,d,l)}if(null!=v&&null!==(e=v.samples)&&void 0!==e&&e.length){var R={frag:u,id:i,samples:v.samples};s.trigger(a.Events.FRAG_PARSING_METADATA,R)}if(g){var D={frag:u,id:i,samples:g.samples};s.trigger(a.Events.FRAG_PARSING_USERDATA,D)}}},C._bufferInitSegment=function(t,e,i,r){var s=this;if(this.state===n.State.PARSING){this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;var o=e.audio,l=e.video,c=e.audiovideo;if(o){var h=t.audioCodec,u=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(h&&(h=-1!==h.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==o.metadata.channelCount&&-1===u.indexOf("firefox")&&(h="mp4a.40.5")),-1!==u.indexOf("android")&&"audio/mpeg"!==o.container&&(h="mp4a.40.2",this.log("Android: force audio codec to "+h)),t.audioCodec&&t.audioCodec!==h&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+h+'"'),o.levelCodec=h,o.id="main",this.log("Init audio buffer, container:"+o.container+", codecs[selected/level/parsed]=["+(h||"")+"/"+(t.audioCodec||"")+"/"+o.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(a.Events.BUFFER_CODECS,e),Object.keys(e).forEach((function(t){var n=e[t].initSegment;null!=n&&n.byteLength&&s.hls.trigger(a.Events.BUFFER_APPENDING,{type:t,data:n,frag:i,part:null,chunkMeta:r,parent:i.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 i=t.currentTime;if(o.BufferHelper.isBuffered(t,i)?e=this.getAppendedFrag(i):o.BufferHelper.isBuffered(t,i+.1)&&(e=this.getAppendedFrag(i+.1)),e){var r=this.fragPlaying,n=e.level;r&&e.sn===r.sn&&r.level===n&&e.urlId===r.urlId||(this.hls.trigger(a.Events.FRAG_CHANGED,{frag:e}),r&&r.level===n||this.hls.trigger(a.Events.LEVEL_SWITCHED,{level:n}),this.fragPlaying=e)}}},b=y,(S=[{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}}])&&v(b.prototype,S),E&&v(b,E),y}(n.default)},"./src/controller/subtitle-stream-controller.ts":
|
|
|
/*!******************************************************!*\
|
|
|
!*** ./src/controller/subtitle-stream-controller.ts ***!
|
|
|
\******************************************************/
|
|
|
/*! exports provided: SubtitleStreamController */function(t,e,i){"use strict";i.r(e),i.d(e,"SubtitleStreamController",(function(){return g}));var r=i(/*! ../events */"./src/events.ts"),n=i(/*! ../utils/logger */"./src/utils/logger.ts"),s=i(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),a=i(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),o=i(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),l=i(/*! ./level-helper */"./src/controller/level-helper.ts"),c=i(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),h=i(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),u=i(/*! ../types/loader */"./src/types/loader.ts"),d=i(/*! ../types/level */"./src/types/level.ts");function f(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var g=function(t){var e,i;function g(e,i){var r;return(r=t.call(this,e,i,"[subtitle-stream-controller]")||this).levels=[],r.currentTrackId=-1,r.tracksBuffered=[],r.mainDetails=null,r._registerListeners(),r}i=t,(e=g).prototype=Object.create(i.prototype),e.prototype.constructor=e,p(e,i);var v,m,y,b=g.prototype;return b.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},b._registerListeners=function(){var t=this.hls;t.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(r.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(r.Events.ERROR,this.onError,this),t.on(r.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(r.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(r.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(r.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},b._unregisterListeners=function(){var t=this.hls;t.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(r.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(r.Events.ERROR,this.onError,this),t.off(r.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(r.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(r.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(r.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},b.startLoad=function(){this.stopLoad(),this.state=h.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 i=e.frag,r=e.success;if(this.fragPrevious=i,this.state=h.State.IDLE,r){var n=this.tracksBuffered[this.currentTrackId];if(n){for(var s,a=i.start,o=0;o<n.length;o++)if(a>=n[o].start&&a<=n[o].end){s=n[o];break}var l=i.start+i.duration;s?s.end=l:(s={start:a,end:l},n.push(s)),this.fragmentTracker.fragBuffered(i)}}},b.onBufferFlushing=function(t,e){var i=e.startOffset,r=e.endOffset;if(0===i&&r!==Number.POSITIVE_INFINITY){var n=this.currentTrackId,s=this.levels;if(!s.length||!s[n]||!s[n].details)return;var a=r-s[n].details.targetduration;if(a<=0)return;e.endOffsetSubtitles=Math.max(0,a),this.tracksBuffered.forEach((function(t){for(var e=0;e<t.length;)if(t[e].end<=a)t.shift();else{if(!(t[e].start<a))break;t[e].start=a,e++}})),this.fragmentTracker.removeFragmentsInRange(i,a,u.PlaylistLevelType.SUBTITLE)}},b.onError=function(t,e){var i,r=e.frag;r&&r.type===u.PlaylistLevelType.SUBTITLE&&(null!==(i=this.fragCurrent)&&void 0!==i&&i.loader&&this.fragCurrent.loader.abort(),this.state=h.State.IDLE)},b.onSubtitleTracksUpdated=function(t,e){var i=this,r=e.subtitleTracks;this.tracksBuffered=[],this.levels=r.map((function(t){return new d.Level(t)})),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach((function(t){i.tracksBuffered[t.id]=[]})),this.mediaBuffer=null},b.onSubtitleTrackSwitch=function(t,e){if(this.currentTrackId=e.id,this.levels.length&&-1!==this.currentTrackId){var i=this.levels[this.currentTrackId];null!=i&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(500)}else this.clearInterval()},b.onSubtitleTrackLoaded=function(t,e){var i,r=e.details,n=e.id,s=this.currentTrackId,c=this.levels;if(c.length){var u=c[s];if(!(n>=c.length||n!==s)&&u){if(this.mediaBuffer=this.mediaBufferTimeRanges,r.live||null!==(i=u.details)&&void 0!==i&&i.live){var d=this.mainDetails;if(r.deltaUpdateFailed||!d)return;var f=d.fragments[0];u.details?0===this.alignPlaylists(r,u.details)&&f&&Object(l.addSliding)(r,f.start):r.hasProgramDateTime&&d.hasProgramDateTime?Object(o.alignMediaPlaylistByPDT)(r,d):f&&Object(l.addSliding)(r,f.start)}u.details=r,this.levelLastLoaded=n,this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===h.State.IDLE&&(Object(a.findFragmentByPTS)(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),u.details=void 0))}}},b._handleFragmentLoadComplete=function(t){var e=t.frag,i=t.payload,n=e.decryptdata,s=this.hls;if(!this.fragContextChanged(e)&&i&&i.byteLength>0&&n&&n.key&&n.iv&&"AES-128"===n.method){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer).then((function(t){var i=performance.now();s.trigger(r.Events.FRAG_DECRYPTED,{frag:e,payload:t,stats:{tstart:a,tdecrypt:i}})}))}},b.doTick=function(){if(this.media){if(this.state===h.State.IDLE){var t,e=this.currentTrackId,i=this.levels;if(!i.length||!i[e]||!i[e].details)return;var o=i[e].details,l=o.targetduration,u=this.config,d=this.media,f=s.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,d.currentTime-l,u.maxBufferHole),p=f.end;if(f.len>this.getMaxBufferLength()+l)return;console.assert(o,"Subtitle track details are defined on idle subtitle stream controller tick");var g,v=o.fragments,m=v.length,y=o.edge,b=this.fragPrevious;if(p<y){var S=u.maxFragLookUpTolerance;b&&o.hasProgramDateTime&&(g=Object(a.findFragmentByPDT)(v,b.endProgramDateTime,S)),g||!(g=Object(a.findFragmentByPTS)(b,v,p,S))&&b&&b.start<v[0].start&&(g=v[0])}else g=v[m-1];null!==(t=g)&&void 0!==t&&t.encrypted?(n.logger.log("Loading key for "+g.sn),this.state=h.State.KEY_LOADING,this.hls.trigger(r.Events.KEY_LOADING,{frag:g})):g&&this.fragmentTracker.getState(g)===c.FragmentState.NOT_LOADED&&this.loadFragment(g,o,p)}}else this.state=h.State.IDLE},b.loadFragment=function(e,i,r){this.fragCurrent=e,t.prototype.loadFragment.call(this,e,i,r)},v=g,(m=[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}])&&f(v.prototype,m),y&&f(v,y),g}(h.default)},"./src/controller/subtitle-track-controller.ts":
|
|
|
/*!*****************************************************!*\
|
|
|
!*** ./src/controller/subtitle-track-controller.ts ***!
|
|
|
\*****************************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var r=i(/*! ../events */"./src/events.ts"),n=i(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),s=i(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),a=i(/*! ../types/loader */"./src/types/loader.ts");function o(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var c=function(t){var e,i;function s(e){var i;return(i=t.call(this,e,"[subtitle-track-controller]")||this).media=null,i.tracks=[],i.groupId=null,i.tracksInGroup=[],i.trackId=-1,i.selectDefaultTrack=!0,i.queuedDefaultTrack=-1,i.trackChangeListener=function(){return i.onTextTracksChanged()},i.asyncPollTrackChange=function(){return i.pollTrackChange(0)},i.useTextTrackPolling=!1,i.subtitlePollingInterval=-1,i.subtitleDisplay=!0,i.registerListeners(),i}i=t,(e=s).prototype=Object.create(i.prototype),e.prototype.constructor=e,l(e,i);var c,u,d,f=s.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(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(r.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(r.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(r.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(r.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var t=this.hls;t.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(r.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(r.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(r.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(r.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),h(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 i=e.id,r=e.details,n=this.trackId,s=this.tracksInGroup[n];if(s){var a=s.details;s.details=e.details,this.log("subtitle track "+i+" loaded ["+r.startSN+"-"+r.endSN+"]"),i===this.trackId&&(this.retryCount=0,this.playlistLoaded(i,e,a))}else this.warn("Invalid subtitle track id "+i)},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 i=e.textGroupIds[e.urlId];if(this.groupId!==i){var n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,s=this.tracks.filter((function(t){return!i||t.groupId===i}));this.tracksInGroup=s;var a=this.findTrackId(null==n?void 0:n.name)||this.findTrackId();this.groupId=i;var o={subtitleTracks:s};this.log("Updating subtitle tracks, "+s.length+' track(s) found in "'+i+'" group-id'),this.hls.trigger(r.Events.SUBTITLE_TRACKS_UPDATED,o),-1!==a&&this.setSubtitleTrack(a,n)}}},f.findTrackId=function(t){for(var e=this.tracksInGroup,i=0;i<e.length;i++){var r=e[i];if((!this.selectDefaultTrack||r.default)&&(!t||t===r.name))return r.id}return-1},f.onError=function(e,i){t.prototype.onError.call(this,e,i),!i.fatal&&i.context&&i.context.type===a.PlaylistContextType.SUBTITLE_TRACK&&i.context.id===this.trackId&&i.context.groupId===this.groupId&&this.retryLoadingOrFail(i)},f.loadPlaylist=function(t){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var i=e.id,n=e.groupId,s=e.url;if(t)try{s=t.addDirectives(s)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(r.Events.SUBTITLE_TRACK_LOADING,{url:s,id:i,groupId:n,deliveryDirectives:t||null})}},f.toggleTrackModes=function(t){var e=this,i=this.media,r=this.subtitleDisplay,n=this.trackId;if(i){var s=h(i.textTracks),a=s.filter((function(t){return t.groupId===e.groupId}));if(-1===t)[].slice.call(s).forEach((function(t){t.mode="disabled"}));else{var o=a[n];o&&(o.mode="disabled")}var l=a[t];l&&(l.mode=r?"showing":"hidden")}},f.setSubtitleTrack=function(t,e){var i,n=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(-1===t||null!==(i=n[t])&&void 0!==i&&i.details)||t<-1||t>=n.length)){this.clearTimer();var s=n[t];if(this.log("Switching to subtitle track "+t),this.trackId=t,s){var a=s.id,o=s.groupId,l=void 0===o?"":o,c=s.name,h=s.type,u=s.url;this.hls.trigger(r.Events.SUBTITLE_TRACK_SWITCH,{id:a,groupId:l,name:c,type:h,url:u});var d=this.switchParams(s.url,null==e?void 0:e.details);this.loadPlaylist(d)}else this.hls.trigger(r.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=h(this.media.textTracks),i=0;i<e.length;i++)if("hidden"===e[i].mode)t=i;else if("showing"===e[i].mode){t=i;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}},c=s,(u=[{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)}}])&&o(c.prototype,u),d&&o(c,d),s}(s.default);function h(t){for(var e=[],i=0;i<t.length;i++){var r=t[i];"subtitles"===r.kind&&r.label&&e.push(t[i])}return e}e.default=c},"./src/controller/timeline-controller.ts":
|
|
|
/*!***********************************************!*\
|
|
|
!*** ./src/controller/timeline-controller.ts ***!
|
|
|
\***********************************************/
|
|
|
/*! exports provided: TimelineController */function(t,e,i){"use strict";i.r(e),i.d(e,"TimelineController",(function(){return d}));var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ../events */"./src/events.ts"),s=i(/*! ../utils/cea-608-parser */"./src/utils/cea-608-parser.ts"),a=i(/*! ../utils/output-filter */"./src/utils/output-filter.ts"),o=i(/*! ../utils/webvtt-parser */"./src/utils/webvtt-parser.ts"),l=i(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),c=i(/*! ../utils/imsc1-ttml-parser */"./src/utils/imsc1-ttml-parser.ts"),h=i(/*! ../types/loader */"./src/types/loader.ts"),u=i(/*! ../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 a.default(this,"textTrack1"),i=new a.default(this,"textTrack2"),r=new a.default(this,"textTrack3"),o=new a.default(this,"textTrack4");this.cea608Parser1=new s.default(1,e,i),this.cea608Parser2=new s.default(3,r,o)}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,i,r,s){for(var a,o,l,c,h=!1,u=s.length;u--;){var d=s[u],f=(a=d[0],o=d[1],l=e,c=i,Math.min(o,c)-Math.max(a,l));if(f>=0&&(d[0]=Math.min(d[0],e),d[1]=Math.max(d[1],i),h=!0,f/(i-e)>.5))return}if(h||s.push([e,i]),this.config.renderTextTracksNatively){var p=this.captionsTracks[t];this.Cues.newCue(p,e,i,r)}else{var g=this.Cues.newCue(null,e,i,r);this.hls.trigger(n.Events.CUES_PARSED,{type:"captions",cues:g,track:t})}},e.onInitPtsFound=function(t,e){var i=this,r=e.frag,s=e.id,a=e.initPTS,o=e.timescale,l=this.unparsedVttFrags;"main"===s&&(this.initPTS[r.cc]=a,this.timescale[r.cc]=o),l.length&&(this.unparsedVttFrags=[],l.forEach((function(t){i.onFragLoaded(n.Events.FRAG_LOADED,t)})))},e.getExistingTrack=function(t){var e=this.media;if(e)for(var i=0;i<e.textTracks.length;i++){var r=e.textTracks[i];if(r[t])return r}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,i=this.captionsTracks,r=this.media,n=e[t],s=n.label,a=n.languageCode,o=this.getExistingTrack(t);if(o)i[t]=o,Object(l.clearCurrentCues)(i[t]),Object(l.sendAddTrackEvent)(i[t],r);else{var c=this.createTextTrack("captions",s,a);c&&(c[t]=!0,i[t]=c)}}},e.createNonNativeTrack=function(t){if(!this.nonNativeCaptionsTracks[t]){var e=this.captionsProperties[t];if(e){var i={_id:t,label:e.label,kind:"captions",default:!!e.media&&!!e.media.default,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=i,this.hls.trigger(n.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}}},e.createTextTrack=function(t,e,i){var r=this.media;if(r)return r.addTextTrack(t,e,i)},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 i=0;i<e.length;i++)Object(l.clearCurrentCues)(e[i])}},e.onSubtitleTracksUpdated=function(t,e){var i=this;this.textTracks=[];var r=e.subtitleTracks||[],s=r.some((function(t){return t.textCodec===c.IMSC1_CODEC}));if(this.config.enableWebVTT||s&&this.config.enableIMSC1){var a=this.tracks&&r&&this.tracks.length===r.length;if(this.tracks=r||[],this.config.renderTextTracksNatively){var o=this.media?this.media.textTracks:[];this.tracks.forEach((function(t,e){var r;if(e<o.length){for(var n=null,s=0;s<o.length;s++)if(f(o[s],t)){n=o[s];break}n&&(r=n)}r?Object(l.clearCurrentCues)(r):(r=i.createTextTrack("subtitles",t.name,t.lang))&&(r.mode="disabled"),r&&(r.groupId=t.groupId,i.textTracks.push(r))}))}else if(!a&&this.tracks&&this.tracks.length){var h=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:h})}}},e.onManifestLoaded=function(t,e){var i=this;this.config.enableCEA708Captions&&e.captions&&e.captions.forEach((function(t){var e=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(e){var r="textTrack"+e[1],n=i.captionsProperties[r];n&&(n.label=t.name,t.lang&&(n.languageCode=t.lang),n.media=t)}}))},e.onFragLoading=function(t,e){var i=this.cea608Parser1,r=this.cea608Parser2,n=this.lastSn,s=this.lastPartIndex;if(this.enabled&&i&&r&&e.frag.type===h.PlaylistLevelType.MAIN){var a,o,l=e.frag.sn,c=null!=(a=null==e||null===(o=e.part)||void 0===o?void 0:o.index)?a:-1;l===n+1||l===n&&c===s+1||(i.reset(),r.reset()),this.lastSn=l,this.lastPartIndex=c}},e.onFragLoaded=function(t,e){var i=e.frag,s=e.payload,a=this.initPTS,o=this.unparsedVttFrags;if(i.type===h.PlaylistLevelType.SUBTITLE)if(s.byteLength){if(!Object(r.isFiniteNumber)(a[i.cc]))return o.push(e),void(a.length&&this.hls.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Missing initial subtitle PTS")}));var l=i.decryptdata;if(null==l||null==l.key||"AES-128"!==l.method){var u=this.tracks[i.level],d=this.vttCCs;d[i.cc]||(d[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),u&&u.textCodec===c.IMSC1_CODEC?this._parseIMSC1(i,s):this._parseVTTs(i,s,d)}}else this.hls.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})},e._parseIMSC1=function(t,e){var i=this,r=this.hls;Object(c.parseIMSC1)(e,this.initPTS[t.cc],this.timescale[t.cc],(function(e){i._appendCues(e,t.level),r.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(function(e){u.logger.log("Failed to parse IMSC1: "+e),r.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:e})}))},e._parseVTTs=function(t,e,i){var r=this,s=this.hls;Object(o.parseWebVTT)(e,this.initPTS[t.cc],this.timescale[t.cc],i,t.cc,t.start,(function(e){r._appendCues(e,t.level),s.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(function(i){r._fallbackToIMSC1(t,e),u.logger.log("Failed to parse VTT cue: "+i),s.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:i})}))},e._fallbackToIMSC1=function(t,e){var i=this,r=this.tracks[t.level];r.textCodec||Object(c.parseIMSC1)(e,this.initPTS[t.cc],this.timescale[t.cc],(function(){r.textCodec=c.IMSC1_CODEC,i._parseIMSC1(t,e)}),(function(){r.textCodec="wvtt"}))},e._appendCues=function(t,e){var i=this.hls;if(this.config.renderTextTracksNatively){var r=this.textTracks[e];if("disabled"===r.mode)return;t.forEach((function(t){return Object(l.addCueToTrack)(r,t)}))}else{var s=this.tracks[e].default?"default":"subtitles"+e;i.trigger(n.Events.CUES_PARSED,{type:"subtitles",cues:t,track:s})}},e.onFragDecrypted=function(t,e){var i=e.frag;if(i.type===h.PlaylistLevelType.SUBTITLE){if(!Object(r.isFiniteNumber)(this.initPTS[i.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 i=this.cea608Parser1,r=this.cea608Parser2;if(this.enabled&&i&&r)for(var n=0;n<e.samples.length;n++){var s=e.samples[n].bytes;if(s){var a=this.extractCea608Data(s);i.addData(e.samples[n].pts,a[0]),r.addData(e.samples[n].pts,a[1])}}},e.onBufferFlushing=function(t,e){var i=e.startOffset,r=e.endOffset,n=e.endOffsetSubtitles,s=e.type,a=this.media;if(a&&!(a.currentTime<r)){if(!s||"video"===s){var o=this.captionsTracks;Object.keys(o).forEach((function(t){return Object(l.removeCuesInRange)(o[t],i,r)}))}if(this.config.renderTextTracksNatively&&0===i&&void 0!==n){var c=this.textTracks;Object.keys(c).forEach((function(t){return Object(l.removeCuesInRange)(c[t],i,n)}))}}},e.extractCea608Data=function(t){for(var e=31&t[0],i=2,r=[[],[]],n=0;n<e;n++){var s=t[i++],a=127&t[i++],o=127&t[i++],l=3&s;0===a&&0===o||0!=(4&s)&&(0!==l&&1!==l||(r[l].push(a),r[l].push(o)))}return r},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,i){"use strict";i.r(e),i.d(e,"default",(function(){return r}));var r=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,i){"use strict";i.r(e),i.d(e,"removePadding",(function(){return n})),i.d(e,"default",(function(){return s}));var r=i(/*! ../utils/typed-array */"./src/utils/typed-array.ts");function n(t){var e=t.byteLength,i=e&&new DataView(t.buffer).getUint8(e-1);return i?Object(r.sliceUint8)(t,0,e-i):t}var s=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),i=new Uint32Array(4),r=0;r<4;r++)i[r]=e.getUint32(4*r);return i},e.initTable=function(){var t=this.sBox,e=this.invSBox,i=this.subMix,r=i[0],n=i[1],s=i[2],a=i[3],o=this.invSubMix,l=o[0],c=o[1],h=o[2],u=o[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 v=p^p<<1^p<<2^p<<3^p<<4;v=v>>>8^255&v^99,t[f]=v,e[v]=f;var m=d[f],y=d[m],b=d[y],S=257*d[v]^16843008*v;r[f]=S<<24|S>>>8,n[f]=S<<16|S>>>16,s[f]=S<<8|S>>>24,a[f]=S,S=16843009*b^65537*y^257*m^16843008*f,l[v]=S<<24|S>>>8,c[v]=S<<16|S>>>16,h[v]=S<<8|S>>>24,u[v]=S,f?(f=m^d[d[d[b^m]]],p^=d[d[p]]):f=p=1}},e.expandKey=function(t){for(var e=this.uint8ArrayToUint32Array_(t),i=!0,r=0;r<e.length&&i;)i=e[r]===this.key[r],r++;if(!i){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 s,a,o,l,c=this.ksRows=4*(n+6+1),h=this.keySchedule=new Uint32Array(c),u=this.invKeySchedule=new Uint32Array(c),d=this.sBox,f=this.rcon,p=this.invSubMix,g=p[0],v=p[1],m=p[2],y=p[3];for(s=0;s<c;s++)s<n?o=h[s]=e[s]:(l=o,s%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[s/n|0]<<24):n>6&&s%n==4&&(l=d[l>>>24]<<24|d[l>>>16&255]<<16|d[l>>>8&255]<<8|d[255&l]),h[s]=o=(h[s-n]^l)>>>0);for(a=0;a<c;a++)s=c-a,l=3&a?h[s]:h[s-4],u[a]=a<4||s<=4?l:g[d[l>>>24]]^v[d[l>>>16&255]]^m[d[l>>>8&255]]^y[d[255&l]],u[a]=u[a]>>>0}},e.networkToHostOrderSwap=function(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24},e.decrypt=function(t,e,i){for(var r,n,s,a,o,l,c,h,u,d,f,p,g,v,m=this.keySize+6,y=this.invKeySchedule,b=this.invSBox,S=this.invSubMix,E=S[0],C=S[1],k=S[2],T=S[3],w=this.uint8ArrayToUint32Array_(i),x=w[0],A=w[1],L=w[2],R=w[3],D=new Int32Array(t),_=new Int32Array(D.length),O=this.networkToHostOrderSwap;e<D.length;){for(u=O(D[e]),d=O(D[e+1]),f=O(D[e+2]),p=O(D[e+3]),o=u^y[0],l=p^y[1],c=f^y[2],h=d^y[3],g=4,v=1;v<m;v++)r=E[o>>>24]^C[l>>16&255]^k[c>>8&255]^T[255&h]^y[g],n=E[l>>>24]^C[c>>16&255]^k[h>>8&255]^T[255&o]^y[g+1],s=E[c>>>24]^C[h>>16&255]^k[o>>8&255]^T[255&l]^y[g+2],a=E[h>>>24]^C[o>>16&255]^k[l>>8&255]^T[255&c]^y[g+3],o=r,l=n,c=s,h=a,g+=4;r=b[o>>>24]<<24^b[l>>16&255]<<16^b[c>>8&255]<<8^b[255&h]^y[g],n=b[l>>>24]<<24^b[c>>16&255]<<16^b[h>>8&255]<<8^b[255&o]^y[g+1],s=b[c>>>24]<<24^b[h>>16&255]<<16^b[o>>8&255]<<8^b[255&l]^y[g+2],a=b[h>>>24]<<24^b[o>>16&255]<<16^b[l>>8&255]<<8^b[255&c]^y[g+3],_[e]=O(r^x),_[e+1]=O(a^A),_[e+2]=O(s^L),_[e+3]=O(n^R),x=u,A=d,L=f,R=p,e+=4}return _.buffer},t}()},"./src/crypt/decrypter.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/crypt/decrypter.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return c}));var r=i(/*! ./aes-crypto */"./src/crypt/aes-crypto.ts"),n=i(/*! ./fast-aes-key */"./src/crypt/fast-aes-key.ts"),s=i(/*! ./aes-decryptor */"./src/crypt/aes-decryptor.ts"),a=i(/*! ../utils/logger */"./src/utils/logger.ts"),o=i(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=i(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),c=function(){function t(t,e,i){var r=(void 0===i?{}:i).removePKCS7Padding,n=void 0===r||r;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 s=self.crypto;s&&(this.subtle=s.subtle||s.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(s.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,i,r){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(t),e,i);var n=this.flush();n&&r(n.buffer)}else this.webCryptoDecrypt(new Uint8Array(t),e,i).then(r)},e.softwareDecrypt=function(t,e,i){var r=this.currentIV,n=this.currentResult,a=this.remainderData;this.logOnce("JS AES decrypt"),a&&(t=Object(o.appendUint8Array)(a,t),this.remainderData=null);var c=this.getValidChunk(t);if(!c.length)return null;r&&(i=r);var h=this.softwareDecrypter;h||(h=this.softwareDecrypter=new s.default),h.expandKey(e);var u=n;return this.currentResult=h.decrypt(c.buffer,0,i),this.currentIV=Object(l.sliceUint8)(c,-16).buffer,u||null},e.webCryptoDecrypt=function(t,e,i){var s=this,a=this.subtle;return this.key===e&&this.fastAesKey||(this.key=e,this.fastAesKey=new n.default(a,e)),this.fastAesKey.expandKey().then((function(e){return a?new r.default(a,i).decrypt(t.buffer,e):Promise.reject(new Error("web crypto not initialized"))})).catch((function(r){return s.onWebCryptoError(r,t,e,i)}))},e.onWebCryptoError=function(t,e,i,r){return a.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",t),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(e,i,r)},e.getValidChunk=function(t){var e=t,i=t.length-t.length%16;return i!==t.length&&(e=Object(l.sliceUint8)(t,0,i),this.remainderData=Object(l.sliceUint8)(t,i)),e},e.logOnce=function(t){this.logEnabled&&(a.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,i){"use strict";i.r(e),i.d(e,"default",(function(){return r}));var r=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,i){"use strict";i.r(e);var r=i(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),n=i(/*! ./adts */"./src/demux/adts.ts"),s=i(/*! ../utils/logger */"./src/utils/logger.ts"),a=i(/*! ../demux/id3 */"./src/demux/id3.ts");function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var l=function(t){var e,i;function r(e,i){var r;return(r=t.call(this)||this).observer=void 0,r.config=void 0,r.observer=e,r.config=i,r}i=t,(e=r).prototype=Object.create(i.prototype),e.prototype.constructor=e,o(e,i);var l=r.prototype;return l.resetInitSegment=function(e,i,r){t.prototype.resetInitSegment.call(this,e,i,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:e,duration:r,inputTimeScale:9e4,dropped:0}},r.probe=function(t){if(!t)return!1;for(var e=(a.getID3Data(t,0)||[]).length,i=t.length;e<i;e++)if(n.probe(t,e))return s.logger.log("ADTS sync word found !"),!0;return!1},l.canParse=function(t,e){return n.canParse(t,e)},l.appendFrame=function(t,e,i){n.initTrackConfig(t,this.observer,e,i,t.manifestCodec);var r=n.appendFrame(t,e,i,this.initPTS,this.frameIndex);if(r&&0===r.missing)return r},r}(r.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,i){"use strict";i.r(e),i.d(e,"getAudioConfig",(function(){return a})),i.d(e,"isHeaderPattern",(function(){return o})),i.d(e,"getHeaderLength",(function(){return l})),i.d(e,"getFullFrameLength",(function(){return c})),i.d(e,"canGetFrameLength",(function(){return h})),i.d(e,"isHeader",(function(){return u})),i.d(e,"canParse",(function(){return d})),i.d(e,"probe",(function(){return f})),i.d(e,"initTrackConfig",(function(){return p})),i.d(e,"getFrameDuration",(function(){return g})),i.d(e,"parseFrameHeader",(function(){return v})),i.d(e,"appendFrame",(function(){return m}));var r=i(/*! ../utils/logger */"./src/utils/logger.ts"),n=i(/*! ../errors */"./src/errors.ts"),s=i(/*! ../events */"./src/events.ts");function a(t,e,i,a){var o,l,c,h,u=navigator.userAgent.toLowerCase(),d=a,f=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];o=1+((192&e[i+2])>>>6);var p=(60&e[i+2])>>>2;if(!(p>f.length-1))return c=(1&e[i+2])<<2,c|=(192&e[i+3])>>>6,r.logger.log("manifest codec:"+a+", ADTS type:"+o+", samplingIndex:"+p),/firefox/i.test(u)?p>=6?(o=5,h=new Array(4),l=p-3):(o=2,h=new Array(2),l=p):-1!==u.indexOf("android")?(o=2,h=new Array(2),l=p):(o=5,h=new Array(4),a&&(-1!==a.indexOf("mp4a.40.29")||-1!==a.indexOf("mp4a.40.5"))||!a&&p>=6?l=p-3:((a&&-1!==a.indexOf("mp4a.40.2")&&(p>=6&&1===c||/vivaldi/i.test(u))||!a&&1===c)&&(o=2,h=new Array(2)),l=p)),h[0]=o<<3,h[0]|=(14&p)>>1,h[1]|=(1&p)<<7,h[1]|=c<<3,5===o&&(h[1]|=(14&l)>>1,h[2]=(1&l)<<7,h[2]|=8,h[3]=0),{config:h,samplerate:f[p],channelCount:c,codec:"mp4a.40."+o,manifestCodec:d};t.trigger(s.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+p})}function o(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 h(t,e){return e+5<t.length}function u(t,e){return e+1<t.length&&o(t,e)}function d(t,e){return h(t,e)&&o(t,e)&&c(t,e)<=t.length-e}function f(t,e){if(u(t,e)){var i=l(t,e);if(e+i>=t.length)return!1;var r=c(t,e);if(r<=i)return!1;var n=e+r;return n===t.length||u(t,n)}return!1}function p(t,e,i,n,s){if(!t.samplerate){var o=a(e,i,n,s);if(!o)return;t.config=o.config,t.samplerate=o.samplerate,t.channelCount=o.channelCount,t.codec=o.codec,t.manifestCodec=o.manifestCodec,r.logger.log("parsed codec:"+t.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function g(t){return 9216e4/t}function v(t,e,i,r,n){var s=l(t,e),a=c(t,e);if((a-=s)>0)return{headerLength:s,frameLength:a,stamp:i+r*n}}function m(t,e,i,r,n){var s=v(e,i,r,n,g(t.samplerate));if(s){var a,o=s.frameLength,l=s.headerLength,c=s.stamp,h=l+o,u=Math.max(0,i+h-e.length);u?(a=new Uint8Array(h-l)).set(e.subarray(i+l,e.length),0):a=e.subarray(i+l,i+h);var d={unit:a,pts:c};return u||t.samples.push(d),{sample:d,length:h,missing:u}}}},"./src/demux/base-audio-demuxer.ts":
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./src/demux/base-audio-demuxer.ts ***!
|
|
|
\*****************************************/
|
|
|
/*! exports provided: initPTSFn, default */function(t,e,i){"use strict";i.r(e),i.d(e,"initPTSFn",(function(){return c}));var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ../demux/id3 */"./src/demux/id3.ts"),s=i(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),a=i(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),o=i(/*! ../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,i){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,i){},e.demux=function(t,e){this.cachedData&&(t=Object(a.appendUint8Array)(this.cachedData,t),this.cachedData=null);var i,r,l=n.getID3Data(t,0),h=l?l.length:0,u=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}),r=this.initPTS;h<p;){if(this.canParse(t,h)){var g=this.appendFrame(u,t,h);g?(this.frameIndex++,r=g.sample.pts,i=h+=g.length):h=p}else n.canParse(t,h)?(l=n.getID3Data(t,h),d.samples.push({pts:r,dts:r,data:l}),i=h+=l.length):h++;if(h===p&&i!==p){var v=Object(o.sliceUint8)(t,i);this.cachedData?this.cachedData=Object(a.appendUint8Array)(this.cachedData,v):this.cachedData=v}}return{audioTrack:u,avcTrack:Object(s.dummyTrack)(),id3Track:d,textTrack:Object(s.dummyTrack)()}},e.demuxSampleAes=function(t,e,i){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(s.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(s.dummyTrack)()}},e.destroy=function(){},t}(),c=function(t,e){return Object(r.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,i){"use strict";i.r(e),i.d(e,"default",(function(){return r}));var r=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,i=this.dataLength;return e.length?(t=1===e.length?e[0]:function(t,e){for(var i=new Uint8Array(e),r=0,n=0;n<t.length;n++){var s=t[n];i.set(s,r),r+=s.length}return i}(e,i),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,i){"use strict";function r(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}i.r(e),i.d(e,"dummyTrack",(function(){return r}))},"./src/demux/exp-golomb.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/exp-golomb.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var r=i(/*! ../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,i=t.byteLength-e,r=new Uint8Array(4),n=Math.min(4,e);if(0===n)throw new Error("no bytes available");r.set(t.subarray(i,i+n)),this.word=new DataView(r.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),i=this.word>>>32-e;return t>32&&r.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?i<<e|this.readBits(e):i},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,i=8,r=0;r<t;r++)0!==i&&(i=(e+this.readEG()+256)%256),e=0===i?e:i},e.readSPS=function(){var t,e,i,r=0,n=0,s=0,a=0,o=this.readUByte.bind(this),l=this.readBits.bind(this),c=this.readUEG.bind(this),h=this.readBoolean.bind(this),u=this.skipBits.bind(this),d=this.skipEG.bind(this),f=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);o();var g=o();if(l(5),u(3),o(),f(),100===g||110===g||122===g||244===g||44===g||83===g||86===g||118===g||128===g){var v=c();if(3===v&&u(1),f(),f(),u(1),h())for(e=3!==v?8:12,i=0;i<e;i++)h()&&p(i<6?16:64)}f();var m=c();if(0===m)c();else if(1===m)for(u(1),d(),d(),t=c(),i=0;i<t;i++)d();f(),u(1);var y=c(),b=c(),S=l(1);0===S&&u(1),u(1),h()&&(r=c(),n=c(),s=c(),a=c());var E=[1,1];if(h()&&h())switch(o()){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:E=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(y+1)-2*r-2*n),height:(2-S)*(b+1)*16-(S?2:4)*(s+a),pixelRatio:E}},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,i){"use strict";i.r(e),i.d(e,"isHeader",(function(){return n})),i.d(e,"isFooter",(function(){return s})),i.d(e,"getID3Data",(function(){return a})),i.d(e,"canParse",(function(){return l})),i.d(e,"getTimeStamp",(function(){return c})),i.d(e,"isTimeStampFrame",(function(){return h})),i.d(e,"getID3Frames",(function(){return d})),i.d(e,"decodeFrame",(function(){return f})),i.d(e,"utf8ArrayToStr",(function(){return y})),i.d(e,"testables",(function(){return b}));var r,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},s=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},a=function(t,e){for(var i=e,r=0;n(t,e);)r+=10,r+=o(t,e+6),s(t,e+10)&&(r+=10),e+=r;if(r>0)return t.subarray(i,i+r)},o=function(t,e){var i=0;return i=(127&t[e])<<21,i|=(127&t[e+1])<<14,i|=(127&t[e+2])<<7,i|=127&t[e+3]},l=function(t,e){return n(t,e)&&o(t,e+6)+10<=t.length-e},c=function(t){for(var e=d(t),i=0;i<e.length;i++){var r=e[i];if(h(r))return m(r)}},h=function(t){return t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info},u=function(t){var e=String.fromCharCode(t[0],t[1],t[2],t[3]),i=o(t,4);return{type:e,size:i,data:t.subarray(10,10+i)}},d=function(t){for(var e=0,i=[];n(t,e);){for(var r=o(t,e+6),a=(e+=10)+r;e+8<a;){var l=u(t.subarray(e)),c=f(l);c&&i.push(c),e+=l.size+10}s(t,e)&&(e+=10)}return i},f=function(t){return"PRIV"===t.type?p(t):"W"===t.type[0]?v(t):g(t)},p=function(t){if(!(t.size<2)){var e=y(t.data,!0),i=new Uint8Array(t.data.subarray(e.length+1));return{key:t.type,info:e,data:i.buffer}}},g=function(t){if(!(t.size<2)){if("TXXX"===t.type){var e=1,i=y(t.data.subarray(e),!0);e+=i.length+1;var r=y(t.data.subarray(e));return{key:t.type,info:i,data:r}}var n=y(t.data.subarray(1));return{key:t.type,data:n}}},v=function(t){if("WXXX"===t.type){if(t.size<2)return;var e=1,i=y(t.data.subarray(e),!0);e+=i.length+1;var r=y(t.data.subarray(e));return{key:t.type,info:i,data:r}}var n=y(t.data);return{key:t.type,data:n}},m=function(t){if(8===t.data.byteLength){var e=new Uint8Array(t.data),i=1&e[3],r=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return r/=45,i&&(r+=47721858.84),Math.round(r)}},y=function(t,e){void 0===e&&(e=!1);var i=S();if(i){var r=i.decode(t);if(e){var n=r.indexOf("\0");return-1!==n?r.substring(0,n):r}return r.replace(/\0/g,"")}for(var s,a,o,l=t.length,c="",h=0;h<l;){if(0===(s=t[h++])&&e)return c;if(0!==s&&3!==s)switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:c+=String.fromCharCode(s);break;case 12:case 13:a=t[h++],c+=String.fromCharCode((31&s)<<6|63&a);break;case 14:a=t[h++],o=t[h++],c+=String.fromCharCode((15&s)<<12|(63&a)<<6|(63&o)<<0)}}return c},b={decodeTextFrame:g};function S(){return r||void 0===self.TextDecoder||(r=new self.TextDecoder("utf-8")),r}},"./src/demux/mp3demuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/mp3demuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var r=i(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),n=i(/*! ../demux/id3 */"./src/demux/id3.ts"),s=i(/*! ../utils/logger */"./src/utils/logger.ts"),a=i(/*! ./mpegaudio */"./src/demux/mpegaudio.ts");function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var l=function(t){var e,i;function r(){return t.apply(this,arguments)||this}i=t,(e=r).prototype=Object.create(i.prototype),e.prototype.constructor=e,o(e,i);var l=r.prototype;return l.resetInitSegment=function(e,i,r){t.prototype.resetInitSegment.call(this,e,i,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:e,duration:r,inputTimeScale:9e4,dropped:0}},r.probe=function(t){if(!t)return!1;for(var e=(n.getID3Data(t,0)||[]).length,i=t.length;e<i;e++)if(a.probe(t,e))return s.logger.log("MPEG Audio sync word found !"),!0;return!1},l.canParse=function(t,e){return a.canParse(t,e)},l.appendFrame=function(t,e,i){if(null!==this.initPTS)return a.appendFrame(t,e,i,this.initPTS,this.frameIndex)},r}(r.default);l.minProbeByteLength=4,e.default=l},"./src/demux/mp4demuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/mp4demuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var r=i(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),n=i(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),s=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(r.findBox)({data:t,start:0,end:Math.min(t.length,16384)},["moof"]).length>0},e.demux=function(t){var e=t,i=Object(n.dummyTrack)();if(this.config.progressive){this.remainderData&&(e=Object(r.appendUint8Array)(this.remainderData,t));var s=Object(r.segmentValidRange)(e);this.remainderData=s.remainder,i.samples=s.valid||new Uint8Array}else i.samples=e;return{audioTrack:Object(n.dummyTrack)(),avcTrack:i,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,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},e.destroy=function(){},t}();s.minProbeByteLength=1024,e.default=s},"./src/demux/mpegaudio.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/demux/mpegaudio.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: appendFrame, parseHeader, isHeaderPattern, isHeader, canParse, probe */function(t,e,i){"use strict";i.r(e),i.d(e,"appendFrame",(function(){return l})),i.d(e,"parseHeader",(function(){return c})),i.d(e,"isHeaderPattern",(function(){return h})),i.d(e,"isHeader",(function(){return u})),i.d(e,"canParse",(function(){return d})),i.d(e,"probe",(function(){return f}));var r=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],s=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],a=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],o=[0,1,1,4];function l(t,e,i,r,n){if(!(i+24>e.length)){var s=c(e,i);if(s&&i+s.frameLength<=e.length){var a=r+n*(9e4*s.samplesPerFrame/s.sampleRate),o={unit:e.subarray(i,i+s.frameLength),pts:a,dts:a};return t.config=[],t.channelCount=s.channelCount,t.samplerate=s.sampleRate,t.samples.push(o),{sample:o,length:s.frameLength,missing:0}}}}function c(t,e){var i=t[e+1]>>3&3,l=t[e+1]>>1&3,c=t[e+2]>>4&15,h=t[e+2]>>2&3;if(1!==i&&0!==c&&15!==c&&3!==h){var u=t[e+2]>>1&1,d=t[e+3]>>6,f=1e3*n[14*(3===i?3-l:3===l?3:4)+c-1],p=s[3*(3===i?0:2===i?1:2)+h],g=3===d?1:2,v=a[i][l],m=o[l],y=8*v*m,b=Math.floor(v*f/p+u)*m;if(null===r){var S=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);r=S?parseInt(S[1]):0}return!!r&&r<=87&&2===l&&f>=224e3&&0===d&&(t[e+3]=128|t[e+3]),{sampleRate:p,channelCount:g,frameLength:b,samplesPerFrame:y}}}function h(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function u(t,e){return e+1<t.length&&h(t,e)}function d(t,e){return h(t,e)&&4<=t.length-e}function f(t,e){if(e+1<t.length&&h(t,e)){var i=c(t,e),r=4;null!=i&&i.frameLength&&(r=i.frameLength);var n=e+r;return n===t.length||u(t,n)}return!1}},"./src/demux/sample-aes.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/sample-aes.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var r=i(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),n=i(/*! ./tsdemuxer */"./src/demux/tsdemuxer.ts"),s=function(){function t(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new r.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,i,r){var n=t[e].unit,s=n.subarray(16,n.length-n.length%16),a=s.buffer.slice(s.byteOffset,s.byteOffset+s.length),o=this;this.decryptBuffer(a,(function(s){var a=new Uint8Array(s);n.set(a,16),r||o.decryptAacSamples(t,e+1,i)}))},e.decryptAacSamples=function(t,e,i){for(;;e++){if(e>=t.length)return void i();if(!(t[e].unit.length<32)){var r=this.decrypter.isSync();if(this.decryptAacSample(t,e,i,r),!r)return}}},e.getAvcEncryptedData=function(t){for(var e=16*Math.floor((t.length-48)/160)+16,i=new Int8Array(e),r=0,n=32;n<=t.length-16;n+=160,r+=16)i.set(t.subarray(n,n+16),r);return i},e.getAvcDecryptedUnit=function(t,e){for(var i=new Uint8Array(e),r=0,n=32;n<=t.length-16;n+=160,r+=16)t.set(i.subarray(r,r+16),n);return t},e.decryptAvcSample=function(t,e,i,r,s,a){var o=Object(n.discardEPB)(s.data),l=this.getAvcEncryptedData(o),c=this;this.decryptBuffer(l.buffer,(function(n){s.data=c.getAvcDecryptedUnit(o,n),a||c.decryptAvcSamples(t,e,i+1,r)}))},e.decryptAvcSamples=function(t,e,i,r){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,i=0){if(e>=t.length)return void r();for(var n=t[e].units;!(i>=n.length);i++){var s=n[i];if(!(s.data.length<=48||1!==s.type&&5!==s.type)){var a=this.decrypter.isSync();if(this.decryptAvcSample(t,e,i,r,s,a),!a)return}}}},t}();e.default=s},"./src/demux/transmuxer-interface.ts":
|
|
|
/*!*******************************************!*\
|
|
|
!*** ./src/demux/transmuxer-interface.ts ***!
|
|
|
\*******************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return u}));var r=i(/*! webworkify-webpack */"./node_modules/webworkify-webpack/index.js"),n=i(/*! ../events */"./src/events.ts"),s=i(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),a=i(/*! ../utils/logger */"./src/utils/logger.ts"),o=i(/*! ../errors */"./src/errors.ts"),l=i(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),c=i(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),h=Object(l.getMediaSource)()||{isTypeSupported:function(){return!1}},u=function(){function t(t,e,i,l){var u=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=i,this.onFlush=l;var d=t.config,f=function(e,i){(i=i||{}).frag=u.frag,i.id=u.id,t.trigger(e,i)};this.observer=new c.EventEmitter,this.observer.on(n.Events.FRAG_DECRYPTED,f),this.observer.on(n.Events.ERROR,f);var p={mp4:h.isTypeSupported("video/mp4"),mpeg:h.isTypeSupported("audio/mpeg"),mp3:h.isTypeSupported('audio/mp4; codecs="mp3"')},g=navigator.vendor;if(d.enableWorker&&"undefined"!=typeof Worker){var v;a.logger.log("demuxing in webworker");try{v=this.worker=r(/*! ../demux/transmuxer-worker.ts */"./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),v.addEventListener("message",this.onwmsg),v.onerror=function(e){t.trigger(n.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(e.message+" ("+e.filename+":"+e.lineno+")")})},v.postMessage({cmd:"init",typeSupported:p,vendor:g,id:e,config:JSON.stringify(d)})}catch(t){a.logger.warn("Error in worker:",t),a.logger.error("Error while initializing DemuxerWorker, fallback to inline"),v&&self.URL.revokeObjectURL(v.objectURL),this.transmuxer=new s.default(this.observer,p,d,g,e),this.worker=null}}else this.transmuxer=new s.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 i=this.observer;i&&i.removeAllListeners(),this.observer=null},e.push=function(t,e,i,r,n,o,l,c,h,u){var d=this;h.transmuxing.start=self.performance.now();var f=this.transmuxer,p=this.worker,g=o?o.start:n.start,v=n.decryptdata,m=this.frag,y=!(m&&n.cc===m.cc),b=!(m&&h.level===m.level),S=m?h.sn-m.sn:-1,E=this.part?h.part-this.part.index:1,C=!b&&(1===S||0===S&&1===E),k=self.performance.now();(b||S||0===n.stats.parsing.start)&&(n.stats.parsing.start=k),!o||!E&&C||(o.stats.parsing.start=k);var T=new s.TransmuxState(y,C,c,b,g);if(!C||y){a.logger.log("[transmuxer-interface, "+n.type+"]: Starting new transmux session for sn: "+h.sn+" p: "+h.part+" level: "+h.level+" id: "+h.id+"\n discontinuity: "+y+"\n trackSwitch: "+b+"\n contiguous: "+C+"\n accurateTimeOffset: "+c+"\n timeOffset: "+g);var w=new s.TransmuxConfig(i,r,e,l,u);this.configureTransmuxer(w)}if(this.frag=n,this.part=o,p)p.postMessage({cmd:"demux",data:t,decryptdata:v,chunkMeta:h,state:T},t instanceof ArrayBuffer?[t]:[]);else if(f){var x=f.push(t,v,h,T);Object(s.isPromise)(x)?x.then((function(t){d.handleTransmuxComplete(t)})):this.handleTransmuxComplete(x)}},e.flush=function(t){var e=this;t.transmuxing.start=self.performance.now();var i=this.transmuxer,r=this.worker;if(r)r.postMessage({cmd:"flush",chunkMeta:t});else if(i){var n=i.flush(t);Object(s.isPromise)(n)?n.then((function(i){e.handleFlushResult(i,t)})):this.handleFlushResult(n,t)}},e.handleFlushResult=function(t,e){var i=this;t.forEach((function(t){i.handleTransmuxComplete(t)})),this.onFlush(e)},e.onWorkerMessage=function(t){var e=t.data,i=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,i.trigger(e.event,e.data)}},e.configureTransmuxer=function(t){var e=this.worker,i=this.transmuxer;e?e.postMessage({cmd:"configure",config:t}):i&&i.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,i){"use strict";i.r(e),i.d(e,"default",(function(){return o}));var r=i(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),n=i(/*! ../events */"./src/events.ts"),s=i(/*! ../utils/logger */"./src/utils/logger.ts"),a=i(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");function o(t){var e=new a.EventEmitter,i=function(e,i){t.postMessage({event:e,data:i})};e.on(n.Events.FRAG_DECRYPTED,i),e.on(n.Events.ERROR,i),t.addEventListener("message",(function(n){var a=n.data;switch(a.cmd){case"init":var o=JSON.parse(a.config);t.transmuxer=new r.default(e,a.typeSupported,o,a.vendor,a.id),Object(s.enableLogs)(o.debug),i("init",null);break;case"configure":t.transmuxer.configure(a.config);break;case"demux":var c=t.transmuxer.push(a.data,a.decryptdata,a.chunkMeta,a.state);Object(r.isPromise)(c)?c.then((function(e){l(t,e)})):l(t,c);break;case"flush":var u=a.chunkMeta,d=t.transmuxer.flush(u);Object(r.isPromise)(d)?d.then((function(e){h(t,e,u)})):h(t,d,u)}}))}function l(t,e){if((i=e.remuxResult).audio||i.video||i.text||i.id3||i.initSegment){var i,r=[],n=e.remuxResult,s=n.audio,a=n.video;s&&c(r,s),a&&c(r,a),t.postMessage({event:"transmuxComplete",data:e},r)}}function c(t,e){e.data1&&t.push(e.data1.buffer),e.data2&&t.push(e.data2.buffer)}function h(t,e,i){e.forEach((function(e){l(t,e)})),t.postMessage({event:"flush",data:i})}},"./src/demux/transmuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/transmuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default, isPromise, TransmuxConfig, TransmuxState */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return y})),i.d(e,"isPromise",(function(){return S})),i.d(e,"TransmuxConfig",(function(){return E})),i.d(e,"TransmuxState",(function(){return C}));var r,n=i(/*! ../events */"./src/events.ts"),s=i(/*! ../errors */"./src/errors.ts"),a=i(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),o=i(/*! ../demux/aacdemuxer */"./src/demux/aacdemuxer.ts"),l=i(/*! ../demux/mp4demuxer */"./src/demux/mp4demuxer.ts"),c=i(/*! ../demux/tsdemuxer */"./src/demux/tsdemuxer.ts"),h=i(/*! ../demux/mp3demuxer */"./src/demux/mp3demuxer.ts"),u=i(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),d=i(/*! ../remux/passthrough-remuxer */"./src/remux/passthrough-remuxer.ts"),f=i(/*! ./chunk-cache */"./src/demux/chunk-cache.ts"),p=i(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),g=i(/*! ../utils/logger */"./src/utils/logger.ts");try{r=self.performance.now.bind(self.performance)}catch(t){g.logger.debug("Unable to use Performance API on this environment"),r=self.Date.now}var v=[{demux:c.default,remux:u.default},{demux:l.default,remux:d.default},{demux:o.default,remux:u.default},{demux:h.default,remux:u.default}],m=1024;v.forEach((function(t){var e=t.demux;m=Math.max(m,e.minProbeByteLength)}));var y=function(){function t(t,e,i,r,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=i,this.vendor=r,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,i,n){var s=this,a=i.transmuxing;a.executeStart=r();var o=new Uint8Array(t),l=this.cache,c=this.config,h=this.currentTransmuxState,u=this.transmuxConfig;n&&(this.currentTransmuxState=n);var d=function(t,e){var i=null;return t.byteLength>0&&null!=e&&null!=e.key&&null!==e.iv&&null!=e.method&&(i=e),i}(o,e);if(d&&"AES-128"===d.method){var f=this.getDecrypter();if(!c.enableSoftwareAES)return this.decryptionPromise=f.webCryptoDecrypt(o,d.key.buffer,d.iv.buffer).then((function(t){var e=s.push(t,null,i);return s.decryptionPromise=null,e})),this.decryptionPromise;var g=f.softwareDecrypt(o,d.key.buffer,d.iv.buffer);if(!g)return a.executeEnd=r(),b(i);o=new Uint8Array(g)}var v=n||h,m=v.contiguous,y=v.discontinuity,S=v.trackSwitch,E=v.accurateTimeOffset,C=v.timeOffset,k=u.audioCodec,T=u.videoCodec,w=u.defaultInitPts,x=u.duration,A=u.initSegmentData;if((y||S)&&this.resetInitSegment(A,k,T,x),y&&this.resetInitialTimestamp(w),m||this.resetContiguity(),this.needsProbing(o,y,S)){if(l.dataLength){var L=l.flush();o=Object(p.appendUint8Array)(L,o)}this.configureTransmuxer(o,u)}var R=this.transmux(o,d,C,E,i),D=this.currentTransmuxState;return D.contiguous=!0,D.discontinuity=!1,D.trackSwitch=!1,a.executeEnd=r(),R},e.flush=function(t){var e=this,i=t.transmuxing;i.executeStart=r();var a=this.decrypter,o=this.cache,l=this.currentTransmuxState,c=this.decryptionPromise;if(c)return c.then((function(){return e.flush(t)}));var h=[],u=l.timeOffset;if(a){var d=a.flush();d&&h.push(this.push(d,null,t))}var f=o.dataLength;o.reset();var p=this.demuxer,g=this.remuxer;if(!p||!g)return f>=m&&this.observer.emit(n.Events.ERROR,n.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),i.executeEnd=r(),[b(t)];var v=p.flush(u);return S(v)?v.then((function(i){return e.flushRemux(h,i,t),h})):(this.flushRemux(h,v,t),h)},e.flushRemux=function(t,e,i){var n=e.audioTrack,s=e.avcTrack,a=e.id3Track,o=e.textTrack,l=this.currentTransmuxState,c=l.accurateTimeOffset,h=l.timeOffset;g.logger.log("[transmuxer.ts]: Flushed fragment "+i.sn+(i.part>-1?" p: "+i.part:"")+" of level "+i.level);var u=this.remuxer.remux(n,s,a,o,h,c,!0,this.id);t.push({remuxResult:u,chunkMeta:i}),i.transmuxing.executeEnd=r()},e.resetInitialTimestamp=function(t){var e=this.demuxer,i=this.remuxer;e&&i&&(e.resetTimeStamp(t),i.resetTimeStamp(t))},e.resetContiguity=function(){var t=this.demuxer,e=this.remuxer;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())},e.resetInitSegment=function(t,e,i,r){var n=this.demuxer,s=this.remuxer;n&&s&&(n.resetInitSegment(e,i,r),s.resetInitSegment(t,e,i))},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,i,r,n){return e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,i,r,n):this.transmuxUnencrypted(t,i,r,n)},e.transmuxUnencrypted=function(t,e,i,r){var n=this.demuxer.demux(t,e,!1,!this.config.progressive),s=n.audioTrack,a=n.avcTrack,o=n.id3Track,l=n.textTrack;return{remuxResult:this.remuxer.remux(s,a,o,l,e,i,!1,this.id),chunkMeta:r}},e.transmuxSampleAes=function(t,e,i,r,n){var s=this;return this.demuxer.demuxSampleAes(t,e,i).then((function(t){return{remuxResult:s.remuxer.remux(t.audioTrack,t.avcTrack,t.id3Track,t.textTrack,i,r,!1,s.id),chunkMeta:n}}))},e.configureTransmuxer=function(t,e){for(var i,r=this.config,n=this.observer,s=this.typeSupported,a=this.vendor,o=e.audioCodec,c=e.defaultInitPts,h=e.duration,u=e.initSegmentData,f=e.videoCodec,p=0,m=v.length;p<m;p++)if(v[p].demux.probe(t)){i=v[p];break}i||(g.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),i={demux:l.default,remux:d.default});var y=this.demuxer,b=this.remuxer,S=i.remux,E=i.demux;b&&b instanceof S||(this.remuxer=new S(n,r,s,a)),y&&y instanceof E||(this.demuxer=new E(n,r,s),this.probe=E.probe),this.resetInitSegment(u,o,f,h),this.resetInitialTimestamp(c)},e.needsProbing=function(t,e,i){return!this.demuxer||!this.remuxer||e||i},e.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new a.default(this.observer,this.config)),t},t}(),b=function(t){return{remuxResult:{},chunkMeta:t}};function S(t){return"then"in t&&t.then instanceof Function}var E=function(t,e,i,r,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=i,this.duration=r,this.defaultInitPts=n},C=function(t,e,i,r,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=i,this.trackSwitch=r,this.timeOffset=n}},"./src/demux/tsdemuxer.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/demux/tsdemuxer.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: discardEPB, default */function(t,e,i){"use strict";i.r(e),i.d(e,"discardEPB",(function(){return S}));var r=i(/*! ./adts */"./src/demux/adts.ts"),n=i(/*! ./mpegaudio */"./src/demux/mpegaudio.ts"),s=i(/*! ./exp-golomb */"./src/demux/exp-golomb.ts"),a=i(/*! ./id3 */"./src/demux/id3.ts"),o=i(/*! ./sample-aes */"./src/demux/sample-aes.ts"),l=i(/*! ../events */"./src/events.ts"),c=i(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),h=i(/*! ../utils/logger */"./src/utils/logger.ts"),u=i(/*! ../errors */"./src/errors.ts"),d={video:1,audio:2,id3:3,text:4},f=function(){function t(t,e,i){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=i}t.probe=function(e){var i=t.syncOffset(e);return!(i<0||(i&&h.logger.warn("MPEG2-TS detected but first sync word found @ offset "+i+", junk ahead ?"),0))},t.syncOffset=function(t){for(var e=Math.min(1e3,t.length-564),i=0;i<e;){if(71===t[i]&&71===t[i+188]&&71===t[i+376])return i;i++}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,i,r){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=t.createTrack("video",r),this._audioTrack=t.createTrack("audio",r),this._id3Track=t.createTrack("id3",r),this._txtTrack=t.createTrack("text",r),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=e,this.videoCodec=i,this._duration=r},e.resetTimeStamp=function(){},e.resetContiguity=function(){var t=this._audioTrack,e=this._avcTrack,i=this._id3Track;t&&(t.pesData=null),e&&(e.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},e.demux=function(e,i,r,n){var s;void 0===r&&(r=!1),void 0===n&&(n=!1),r||(this.sampleAes=null);var a=this._avcTrack,o=this._audioTrack,d=this._id3Track,f=a.pid,p=a.pesData,y=o.pid,b=d.pid,S=o.pesData,E=d.pesData,C=!1,k=this.pmtParsed,T=this._pmtId,w=e.length;if(this.remainderData&&(w=(e=Object(c.appendUint8Array)(this.remainderData,e)).length,this.remainderData=null),w<188&&!n)return this.remainderData=e,{audioTrack:o,avcTrack:a,id3Track:d,textTrack:this._txtTrack};var x=Math.max(0,t.syncOffset(e));(w-=(w+x)%188)<e.byteLength&&!n&&(this.remainderData=new Uint8Array(e.buffer,w,e.buffer.byteLength-w));for(var A=x;A<w;A+=188)if(71===e[A]){var L=!!(64&e[A+1]),R=((31&e[A+1])<<8)+e[A+2],D=void 0;if((48&e[A+3])>>4>1){if((D=A+5+e[A+4])===A+188)continue}else D=A+4;switch(R){case f:L&&(p&&(s=m(p))&&this.parseAVCPES(s,!1),p={data:[],size:0}),p&&(p.data.push(e.subarray(D,A+188)),p.size+=A+188-D);break;case y:L&&(S&&(s=m(S))&&(o.isAAC?this.parseAACPES(s):this.parseMPEGPES(s)),S={data:[],size:0}),S&&(S.data.push(e.subarray(D,A+188)),S.size+=A+188-D);break;case b:L&&(E&&(s=m(E))&&this.parseID3PES(s),E={data:[],size:0}),E&&(E.data.push(e.subarray(D,A+188)),E.size+=A+188-D);break;case 0:L&&(D+=e[D]+1),T=this._pmtId=g(e,D);break;case T:L&&(D+=e[D]+1);var _=v(e,D,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,r);(f=_.avc)>0&&(a.pid=f),(y=_.audio)>0&&(o.pid=y,o.isAAC=_.isAAC),(b=_.id3)>0&&(d.pid=b),C&&!k&&(h.logger.log("reparse from beginning"),C=!1,A=x-188),k=this.pmtParsed=!0;break;case 17:case 8191:break;default:C=!0}}else this.observer.emit(l.Events.ERROR,l.Events.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:u.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});a.pesData=p,o.pesData=S,d.pesData=E;var O={audioTrack:o,avcTrack:a,id3Track:d,textTrack:this._txtTrack};return n&&this.extractRemainingSamples(O),O},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,i=t.audioTrack,r=t.avcTrack,n=t.id3Track,s=r.pesData,a=i.pesData,o=n.pesData;s&&(e=m(s))?(this.parseAVCPES(e,!0),r.pesData=null):r.pesData=s,a&&(e=m(a))?(i.isAAC?this.parseAACPES(e):this.parseMPEGPES(e),i.pesData=null):(null!=a&&a.size&&h.logger.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=a),o&&(e=m(o))?(this.parseID3PES(e),n.pesData=null):n.pesData=o},e.demuxSampleAes=function(t,e,i){var r=this.demux(t,i,!0,!this.config.progressive),n=this.sampleAes=new o.default(this.observer,this.config,e);return this.decrypt(r,n)},e.decrypt=function(t,e){return new Promise((function(i){var r=t.audioTrack,n=t.avcTrack;r.samples&&r.isAAC?e.decryptAacSamples(r.samples,0,(function(){n.samples?e.decryptAvcSamples(n.samples,0,0,(function(){i(t)})):i(t)})):n.samples&&e.decryptAvcSamples(n.samples,0,0,(function(){i(t)}))}))},e.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},e.parseAVCPES=function(t,e){var i,r=this,n=this._avcTrack,o=this.parseAVCNALu(t.data),l=this.avcSample,c=!1;t.data=null,l&&o.length&&!n.audFound&&(y(l,n),l=this.avcSample=p(!1,t.pts,t.dts,"")),o.forEach((function(e){switch(e.type){case 1:i=!0,l||(l=r.avcSample=p(!0,t.pts,t.dts,"")),l.frame=!0;var o=e.data;if(c&&o.length>4){var h=new s.default(o).readSliceType();2!==h&&4!==h&&7!==h&&9!==h||(l.key=!0)}break;case 5:i=!0,l||(l=r.avcSample=p(!0,t.pts,t.dts,"")),l.key=!0,l.frame=!0;break;case 6:i=!0;var u=new s.default(S(e.data));u.readUByte();for(var d=0,f=0,g=!1,v=0;!g&&u.bytesAvailable>1;){d=0;do{d+=v=u.readUByte()}while(255===v);f=0;do{f+=v=u.readUByte()}while(255===v);if(4===d&&0!==u.bytesAvailable){if(g=!0,181===u.readUByte()&&49===u.readUShort()&&1195456820===u.readUInt()&&3===u.readUByte()){for(var m=u.readUByte(),E=31&m,C=[m,u.readUByte()],k=0;k<E;k++)C.push(u.readUByte()),C.push(u.readUByte()),C.push(u.readUByte());b(r._txtTrack.samples,{type:3,pts:t.pts,bytes:C})}}else if(5===d&&0!==u.bytesAvailable){if(g=!0,f>16){for(var T=[],w=0;w<16;w++)T.push(u.readUByte().toString(16)),3!==w&&5!==w&&7!==w&&9!==w||T.push("-");for(var x=f-16,A=new Uint8Array(x),L=0;L<x;L++)A[L]=u.readUByte();b(r._txtTrack.samples,{pts:t.pts,payloadType:d,uuid:T.join(""),userData:Object(a.utf8ArrayToStr)(A),userDataBytes:A})}}else if(f<u.bytesAvailable)for(var R=0;R<f;R++)u.readUByte()}break;case 7:if(i=!0,c=!0,!n.sps){var D=new s.default(e.data).readSPS();n.width=D.width,n.height=D.height,n.pixelRatio=D.pixelRatio,n.sps=[e.data],n.duration=r._duration;for(var _=e.data.subarray(1,4),O="avc1.",I=0;I<3;I++){var P=_[I].toString(16);P.length<2&&(P="0"+P),O+=P}n.codec=O}break;case 8:i=!0,n.pps||(n.pps=[e.data]);break;case 9:i=!1,n.audFound=!0,l&&y(l,n),l=r.avcSample=p(!1,t.pts,t.dts,"");break;case 12:i=!1;break;default:i=!1,l&&(l.debug+="unknown NAL "+e.type+" ")}l&&i&&l.units.push(e)})),e&&l&&(y(l,n),this.avcSample=null)},e.getLastNalUnit=function(){var t,e,i=this.avcSample;if(!i||0===i.units.length){var r=this._avcTrack.samples;i=r[r.length-1]}if(null!==(t=i)&&void 0!==t&&t.units){var n=i.units;e=n[n.length-1]}return e},e.parseAVCNALu=function(t){var e,i,r=t.byteLength,n=this._avcTrack,s=n.naluState||0,a=s,o=[],l=0,c=-1,h=0;for(-1===s&&(c=0,h=31&t[0],s=0,l=1);l<r;)if(e=t[l++],s)if(1!==s)if(e)if(1===e){if(c>=0){var u={data:t.subarray(c,l-s-1),type:h};o.push(u)}else{var d=this.getLastNalUnit();if(d&&(a&&l<=4-a&&d.state&&(d.data=d.data.subarray(0,d.data.byteLength-a)),(i=l-s-1)>0)){var f=new Uint8Array(d.data.byteLength+i);f.set(d.data,0),f.set(t.subarray(0,i),d.data.byteLength),d.data=f,d.state=0}}l<r?(c=l,h=31&t[l],s=0):s=-1}else s=0;else s=3;else s=e?0:2;else s=e?0:1;if(c>=0&&s>=0){var p={data:t.subarray(c,r),type:h,state:s};o.push(p)}if(0===o.length){var g=this.getLastNalUnit();if(g){var v=new Uint8Array(g.data.byteLength+t.byteLength);v.set(g.data,0),v.set(t,g.data.byteLength),g.data=v}}return n.naluState=s,o},e.parseAACPES=function(t){var e,i,n,s,a,o=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),v=p-g;d.sample.unit.set(f.subarray(0,g),v),c.samples.push(d.sample),o=d.missing}for(e=o,i=f.length;e<i-1&&!r.isHeader(f,e);e++);if(e===o||(e<i-1?(n="AAC PES did not start with ADTS header,offset:"+e,s=!1):(n="no ADTS header found in AAC PES",s=!0),h.logger.warn("parsing error:"+n),this.observer.emit(l.Events.ERROR,l.Events.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:u.ErrorDetails.FRAG_PARSING_ERROR,fatal:s,reason:n}),!s)){if(r.initTrackConfig(c,this.observer,f,e,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!d)return void h.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var m=r.getFrameDuration(c.samplerate);a=d.sample.pts+m}for(var y=0;e<i;){if(r.isHeader(f,e)){if(e+5<i){var b=r.appendFrame(c,f,e,a,y);if(b){if(!b.missing){e+=b.length,y++;continue}this.aacOverFlow=b}}break}e++}}},e.parseMPEGPES=function(t){var e=t.data,i=e.length,r=0,s=0,a=t.pts;if(void 0!==a)for(;s<i;)if(n.isHeader(e,s)){var o=n.appendFrame(this._audioTrack,e,s,a,r);if(!o)break;s+=o.length,r++}else s++;else h.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},e.parseID3PES=function(t){void 0!==t.pts?this._id3Track.samples.push(t):h.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},t}();function p(t,e,i,r){return{key:t,frame:!1,pts:e,dts:i,units:[],debug:r,length:0}}function g(t,e){return(31&t[e+10])<<8|t[e+11]}function v(t,e,i,r){var n={audio:-1,avc:-1,id3:-1,isAAC:!0},s=e+3+((15&t[e+1])<<8|t[e+2])-4;for(e+=12+((15&t[e+10])<<8|t[e+11]);e<s;){var a=(31&t[e+1])<<8|t[e+2];switch(t[e]){case 207:if(!r){h.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===n.audio&&(n.audio=a);break;case 21:-1===n.id3&&(n.id3=a);break;case 219:if(!r){h.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===n.avc&&(n.avc=a);break;case 3:case 4:i?-1===n.audio&&(n.audio=a,n.isAAC=!1):h.logger.log("MPEG audio found, not supported in this browser");break;case 36:h.logger.warn("Unsupported HEVC stream type found")}e+=5+((15&t[e+3])<<8|t[e+4])}return n}function m(t){var e,i,r,n,s,a=0,o=t.data;if(!t||0===t.size)return null;for(;o[0].length<19&&o.length>1;){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(1===((e=o[0])[0]<<16)+(e[1]<<8)+e[2]){if((i=(e[4]<<8)+e[5])&&i>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-(s=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2)>54e5&&(h.logger.warn(Math.round((n-s)/9e4)+"s delta between PTS and DTS, align them"),n=s):s=n);var u=(r=e[8])+9;if(t.size<=u)return null;t.size-=u;for(var d=new Uint8Array(t.size),f=0,p=o.length;f<p;f++){var g=(e=o[f]).byteLength;if(u){if(u>g){u-=g;continue}e=e.subarray(u),g-=u,u=0}d.set(e,a),a+=g}return i&&(i-=r+3),{data:d,pts:n,dts:s,len:i}}return null}function y(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){var i=e.samples,r=i.length;if(!r)return void e.dropped++;var n=i[r-1];t.pts=n.pts,t.dts=n.dts}e.samples.push(t)}t.debug.length&&h.logger.log(t.pts+"/"+t.dts+":"+t.debug)}function b(t,e){var i=t.length;if(i>0){if(e.pts>=t[i-1].pts)t.push(e);else for(var r=i-1;r>=0;r--)if(e.pts<t[r].pts){t.splice(r,0,e);break}}else t.push(e)}function S(t){for(var e=t.byteLength,i=[],r=1;r<e-2;)0===t[r]&&0===t[r+1]&&3===t[r+2]?(i.push(r+2),r+=2):r++;if(0===i.length)return t;var n=e-i.length,s=new Uint8Array(n),a=0;for(r=0;r<n;a++,r++)a===i[0]&&(a++,i.shift()),s[r]=t[a];return s}f.minProbeByteLength=188,e.default=f},"./src/errors.ts":
|
|
|
/*!***********************!*\
|
|
|
!*** ./src/errors.ts ***!
|
|
|
\***********************/
|
|
|
/*! exports provided: ErrorTypes, ErrorDetails */function(t,e,i){"use strict";var r,n;i.r(e),i.d(e,"ErrorTypes",(function(){return r})),i.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"}(r||(r={})),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,i){"use strict";var r;i.r(e),i.d(e,"Events",(function(){return r})),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"}(r||(r={}))},"./src/hls.ts":
|
|
|
/*!********************!*\
|
|
|
!*** ./src/hls.ts ***!
|
|
|
\********************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return y}));var r=i(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),n=i(/*! ./loader/playlist-loader */"./src/loader/playlist-loader.ts"),s=i(/*! ./loader/key-loader */"./src/loader/key-loader.ts"),a=i(/*! ./controller/id3-track-controller */"./src/controller/id3-track-controller.ts"),o=i(/*! ./controller/latency-controller */"./src/controller/latency-controller.ts"),l=i(/*! ./controller/level-controller */"./src/controller/level-controller.ts"),c=i(/*! ./controller/fragment-tracker */"./src/controller/fragment-tracker.ts"),h=i(/*! ./controller/stream-controller */"./src/controller/stream-controller.ts"),u=i(/*! ./is-supported */"./src/is-supported.ts"),d=i(/*! ./utils/logger */"./src/utils/logger.ts"),f=i(/*! ./config */"./src/config.ts"),p=i(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),g=i(/*! ./events */"./src/events.ts"),v=i(/*! ./errors */"./src/errors.ts");function m(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}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 i=this.config=Object(f.mergeConfig)(t.DefaultConfig,e);this.userConfig=e,Object(d.enableLogs)(i.debug),this._autoLevelCapping=-1,i.progressive&&Object(f.enableStreamingMode)(i);var r=i.abrController,u=i.bufferController,g=i.capLevelController,v=i.fpsController,m=this.abrController=new r(this),y=this.bufferController=new u(this),b=this.capLevelController=new g(this),S=new v(this),E=new n.default(this),C=new s.default(this),k=new a.default(this),T=this.levelController=new l.default(this),w=new c.FragmentTracker(this),x=this.streamController=new h.default(this,w);b.setStreamController(x),S.setStreamController(x);var A=[T,x];this.networkControllers=A;var L=[E,C,m,y,b,S,k,w];this.audioTrackController=this.createController(i.audioTrackController,null,A),this.createController(i.audioStreamController,w,A),this.subtitleTrackController=this.createController(i.subtitleTrackController,null,A),this.createController(i.subtitleStreamController,w,A),this.createController(i.timelineController,null,L),this.emeController=this.createController(i.emeController,null,L),this.cmcdController=this.createController(i.cmcdController,null,L),this.latencyController=this.createController(o.default,null,L),this.coreComponents=L}t.isSupported=function(){return Object(u.isSupported)()};var e,i,y,b=t.prototype;return b.createController=function(t,e,i){if(t){var r=e?new t(this,e):new t(this);return i&&i.push(r),r}return null},b.on=function(t,e,i){void 0===i&&(i=this),this._emitter.on(t,e,i)},b.once=function(t,e,i){void 0===i&&(i=this),this._emitter.once(t,e,i)},b.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},b.off=function(t,e,i,r){void 0===i&&(i=this),this._emitter.off(t,e,i,r)},b.listeners=function(t){return this._emitter.listeners(t)},b.emit=function(t,e,i){return this._emitter.emit(t,e,i)},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:v.ErrorTypes.OTHER_ERROR,details:v.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,i=this.url,n=this.url=r.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});d.logger.log("loadSource:"+n),e&&i&&i!==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 v.ErrorTypes}},{key:"ErrorDetails",get:function(){return v.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:f.hlsDefaultConfig},set:function(e){t.defaultConfig=e}}],(i=[{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 i=t.length,r=0;r<i;r++)if(t[r].maxBitrate>e)return r;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}}])&&m(e.prototype,i),y&&m(e,y),t}();y.defaultConfig=void 0},"./src/is-supported.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/is-supported.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: isSupported, changeTypeSupported */function(t,e,i){"use strict";i.r(e),i.d(e,"isSupported",(function(){return s})),i.d(e,"changeTypeSupported",(function(){return a}));var r=i(/*! ./utils/mediasource-helper */"./src/utils/mediasource-helper.ts");function n(){return self.SourceBuffer||self.WebKitSourceBuffer}function s(){var t=Object(r.getMediaSource)();if(!t)return!1;var e=n(),i=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),s=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove;return!!i&&!!s}function a(){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,i){"use strict";i.r(e),i.d(e,"default",(function(){return u})),i.d(e,"LoadError",(function(){return f}));var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ../errors */"./src/errors.ts");function s(t){var e="function"==typeof Map?new Map:void 0;return(s=function(t){if(null===t||(i=t,-1===Function.toString.call(i).indexOf("[native code]")))return t;var i;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,r)}function r(){return a(t,arguments,c(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),l(r,t)})(t)}function a(t,e,i){return(a=o()?Reflect.construct:function(t,e,i){var r=[null];r.push.apply(r,e);var n=new(Function.bind.apply(t,r));return i&&l(n,i.prototype),n}).apply(null,arguments)}function o(){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 h=Math.pow(2,17),u=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 i=this,r=t.url;if(!r)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 "+(r?"part list":"url")));this.abort();var s=this.config,a=s.fLoader,o=s.loader;return new Promise((function(r,l){i.loader&&i.loader.destroy();var c=i.loader=t.loader=a?new a(s):new o(s),u=d(t),p={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:h};t.stats=c.stats,c.load(u,p,{onSuccess:function(e,n,s,a){i.resetLoader(t,c),r({frag:t,part:null,payload:e.data,networkDetails:a})},onError:function(e,r,s){i.resetLoader(t,c),l(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:e,networkDetails:s}))},onAbort:function(e,r,s){i.resetLoader(t,c),l(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,networkDetails:s}))},onTimeout:function(e,r,s){i.resetLoader(t,c),l(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,networkDetails:s}))},onProgress:function(i,r,n,s){e&&e({frag:t,part:null,payload:n,networkDetails:s})}})}))},e.loadPart=function(t,e,i){var r=this;this.abort();var s=this.config,a=s.fLoader,o=s.loader;return new Promise((function(l,c){r.loader&&r.loader.destroy();var u=r.loader=t.loader=a?new a(s):new o(s),p=d(t,e),g={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:h};e.stats=u.stats,u.load(p,g,{onSuccess:function(n,s,a,o){r.resetLoader(t,u),r.updateStatsFromPart(t,e);var c={frag:t,part:e,payload:n.data,networkDetails:o};i(c),l(c)},onError:function(i,s,a){r.resetLoader(t,u),c(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:i,networkDetails:a}))},onAbort:function(i,s,a){t.stats.aborted=e.stats.aborted,r.resetLoader(t,u),c(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,networkDetails:a}))},onTimeout:function(i,s,a){r.resetLoader(t,u),c(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,networkDetails:a}))}})}))},e.updateStatsFromPart=function(t,e){var i=t.stats,r=e.stats,n=r.total;if(i.loaded+=r.loaded,n){var s=Math.round(t.duration/e.duration),a=Math.min(Math.round(i.loaded/n),s),o=(s-a)*Math.round(i.loaded/a);i.total=i.loaded+o}else i.total=Math.max(i.loaded,i.total);var l=i.loading,c=r.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 i=e||t,n={frag:t,part:e,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},s=i.byteRangeStartOffset,a=i.byteRangeEndOffset;return Object(r.isFiniteNumber)(s)&&Object(r.isFiniteNumber)(a)&&(n.rangeStart=s,n.rangeEnd=a),n}var f=function(t){var e,i;function r(e){for(var i,r=arguments.length,n=new Array(r>1?r-1:0),s=1;s<r;s++)n[s-1]=arguments[s];return(i=t.call.apply(t,[this].concat(n))||this).data=void 0,i.data=e,i}return i=t,(e=r).prototype=Object.create(i.prototype),e.prototype.constructor=e,l(e,i),r}(s(Error))},"./src/loader/fragment.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/loader/fragment.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: ElementaryStreamTypes, BaseSegment, Fragment, Part */function(t,e,i){"use strict";i.r(e),i.d(e,"ElementaryStreamTypes",(function(){return r})),i.d(e,"BaseSegment",(function(){return f})),i.d(e,"Fragment",(function(){return p})),i.d(e,"Part",(function(){return g}));var r,n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),s=i(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),a=i(/*! ../utils/logger */"./src/utils/logger.ts"),o=i(/*! ./level-key */"./src/loader/level-key.ts"),l=i(/*! ./load-stats */"./src/loader/load-stats.ts");function c(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,h(t,e)}function h(t,e){return(h=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function d(t,e,i){return e&&u(t.prototype,e),i&&u(t,i),t}!function(t){t.AUDIO="audio",t.VIDEO="video",t.AUDIOVIDEO="audiovideo"}(r||(r={}));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={})[r.AUDIO]=null,e[r.VIDEO]=null,e[r.AUDIOVIDEO]=null,e),this.baseurl=t}return t.prototype.setByteRange=function(t,e){var i=t.split("@",2),r=[];1===i.length?r[0]=e?e.byteRangeEndOffset:0:r[0]=parseInt(i[1]),r[1]=parseInt(i[0])+r[0],this._byteRange=r},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(s.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}]),t}(),p=function(t){function e(e,i){var r;return(r=t.call(this,i)||this)._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkey=void 0,r.type=void 0,r.loader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.appendedPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new l.LoadStats,r.urlId=0,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.type=e,r}c(e,t);var i=e.prototype;return i.createInitializationVector=function(t){for(var e=new Uint8Array(16),i=12;i<16;i++)e[i]=t>>8*(15-i)&255;return e},i.setDecryptDataFromLevelKey=function(t,e){var i=t;return"AES-128"===(null==t?void 0:t.method)&&t.uri&&!t.iv&&((i=o.LevelKey.fromURI(t.uri)).method=t.method,i.iv=this.createInitializationVector(e),i.keyFormat="identity"),i},i.setElementaryStreamInfo=function(t,e,i,r,n,s){void 0===s&&(s=!1);var a=this.elementaryStreams,o=a[t];o?(o.startPTS=Math.min(o.startPTS,e),o.endPTS=Math.max(o.endPTS,i),o.startDTS=Math.min(o.startDTS,r),o.endDTS=Math.max(o.endDTS,n)):a[t]={startPTS:e,endPTS:i,startDTS:r,endDTS:n,partial:s}},i.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[r.AUDIO]=null,t[r.VIDEO]=null,t[r.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&&a.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,i,r,n,s){var a;(a=t.call(this,r)||this).fragOffset=0,a.duration=0,a.gap=!1,a.independent=!1,a.relurl=void 0,a.fragment=void 0,a.index=void 0,a.stats=new l.LoadStats,a.duration=e.decimalFloatingPoint("DURATION"),a.gap=e.bool("GAP"),a.independent=e.bool("INDEPENDENT"),a.relurl=e.enumeratedString("URI"),a.fragment=i,a.index=n;var o=e.enumeratedString("BYTERANGE");return o&&a.setByteRange(o,s),s&&(a.fragOffset=s.fragOffset+s.duration),a}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,i){"use strict";i.r(e),i.d(e,"default",(function(){return a}));var r=i(/*! ../events */"./src/events.ts"),n=i(/*! ../errors */"./src/errors.ts"),s=i(/*! ../utils/logger */"./src/utils/logger.ts"),a=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(r.Events.KEY_LOADING,this.onKeyLoading,this)},e._unregisterListeners=function(){this.hls.off(r.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 i=e.frag,n=i.type,a=this.loaders[n];if(i.decryptdata){var o=i.decryptdata.uri;if(o!==this.decrypturl||null===this.decryptkey){var l=this.hls.config;if(a&&(s.logger.warn("abort previous key loader for type:"+n),a.abort()),!o)return void s.logger.warn("key uri is falsy");var c=l.loader,h=i.loader=this.loaders[n]=new c(l);this.decrypturl=o,this.decryptkey=null;var u={url:o,frag:i,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)};h.load(u,d,f)}else this.decryptkey&&(i.decryptdata.key=this.decryptkey,this.hls.trigger(r.Events.KEY_LOADED,{frag:i}))}else s.logger.warn("Missing decryption data on fragment in onKeyLoading")},e.loadsuccess=function(t,e,i){var n=i.frag;n.decryptdata?(this.decryptkey=n.decryptdata.key=new Uint8Array(t.data),n.loader=null,delete this.loaders[n.type],this.hls.trigger(r.Events.KEY_LOADED,{frag:n})):s.logger.error("after key load, decryptdata unset")},e.loaderror=function(t,e){var i=e.frag,s=i.loader;s&&s.abort(),delete this.loaders[i.type],this.hls.trigger(r.Events.ERROR,{type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:i,response:t})},e.loadtimeout=function(t,e){var i=e.frag,s=i.loader;s&&s.abort(),delete this.loaders[i.type],this.hls.trigger(r.Events.ERROR,{type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:i})},t}()},"./src/loader/level-details.ts":
|
|
|
/*!*************************************!*\
|
|
|
!*** ./src/loader/level-details.ts ***!
|
|
|
\*************************************/
|
|
|
/*! exports provided: LevelDetails */function(t,e,i){"use strict";i.r(e),i.d(e,"LevelDetails",(function(){return s}));var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts");function n(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var s=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,i,s;return t.prototype.reloaded=function(t){if(!t)return this.advanced=!0,void(this.updated=!0);var e=this.lastPartSn-t.lastPartSn,i=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!i||!!e,this.advanced=this.endSN>t.endSN||e>0||0===e&&i>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay},e=t,(i=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&Object(r.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,i),s&&n(e,s),t}()},"./src/loader/level-key.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/loader/level-key.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: LevelKey */function(t,e,i){"use strict";i.r(e),i.d(e,"LevelKey",(function(){return s}));var r=i(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");function n(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var s=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(r.buildAbsoluteURL)(t,e,{alwaysNormalize:!0}):t}var e,i,s;return t.fromURL=function(e,i){return new t(e,i)},t.fromURI=function(e){return new t(e)},e=t,(i=[{key:"uri",get:function(){return this._uri}}])&&n(e.prototype,i),s&&n(e,s),t}()},"./src/loader/load-stats.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/loader/load-stats.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: LoadStats */function(t,e,i){"use strict";i.r(e),i.d(e,"LoadStats",(function(){return r}));var r=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,i){"use strict";i.r(e),i.d(e,"default",(function(){return v}));var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),s=i(/*! ./fragment */"./src/loader/fragment.ts"),a=i(/*! ./level-details */"./src/loader/level-details.ts"),o=i(/*! ./level-key */"./src/loader/level-key.ts"),l=i(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),c=i(/*! ../utils/logger */"./src/utils/logger.ts"),h=i(/*! ../utils/codecs */"./src/utils/codecs.ts"),u=/#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,v=function(){function t(){}return t.findGroup=function(t,e){for(var i=0;i<t.length;i++){var r=t[i];if(r.id===e)return r}},t.convertAVC1ToAVCOTI=function(t){var e=t.split(".");if(e.length>2){var i=e.shift()+".";return i+=parseInt(e.shift()).toString(16),i+=("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,i){var r,n=[],s={},a=!1;for(u.lastIndex=0;null!=(r=u.exec(e));)if(r[1]){var o=new l.AttrList(r[1]),c={attrs:o,bitrate:o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),name:o.NAME,url:t.resolve(r[2],i)},h=o.decimalResolution("RESOLUTION");h&&(c.width=h.width,c.height=h.height),m((o.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(r[3]){var d=new l.AttrList(r[3]);d["DATA-ID"]&&(a=!0,s[d["DATA-ID"]]=d)}return{levels:n,sessionData:a?s:null}},t.parseMasterPlaylistMedia=function(e,i,r,n){var s;void 0===n&&(n=[]);var a=[],o=0;for(d.lastIndex=0;null!==(s=d.exec(e));){var c=new l.AttrList(s[1]);if(c.TYPE===r){var h={attrs:c,bitrate:0,id:o++,groupId:c["GROUP-ID"],instreamId:c["INSTREAM-ID"],name:c.NAME||c.LANGUAGE||"",type:r,default:c.bool("DEFAULT"),autoselect:c.bool("AUTOSELECT"),forced:c.bool("FORCED"),lang:c.LANGUAGE,url:c.URI?t.resolve(c.URI,i):""};if(n.length){var u=t.findGroup(n,h.groupId)||n[0];y(h,u,"audioCodec"),y(h,u,"textCodec")}a.push(h)}}return a},t.parseLevelPlaylist=function(t,e,i,h,u){var d,v,m,y=new a.LevelDetails(e),S=y.fragments,E=null,C=0,k=0,T=0,w=0,x=null,A=new s.Fragment(h,e),L=-1,R=!1;for(f.lastIndex=0,y.m3u8=t;null!==(d=f.exec(t));){R&&(R=!1,(A=new s.Fragment(h,e)).start=T,A.sn=C,A.cc=w,A.level=i,E&&(A.initSegment=E,A.rawProgramDateTime=E.rawProgramDateTime));var D=d[1];if(D){A.duration=parseFloat(D);var _=(" "+d[2]).slice(1);A.title=_||null,A.tagList.push(_?["INF",D,_]:["INF",D])}else if(d[3])Object(r.isFiniteNumber)(A.duration)&&(A.start=T,m&&(A.levelkey=m),A.sn=C,A.level=i,A.cc=w,A.urlId=u,S.push(A),A.relurl=(" "+d[3]).slice(1),b(A,x),x=A,T+=A.duration,C++,k=0,R=!0);else if(d[4]){var O=(" "+d[4]).slice(1);x?A.setByteRange(O,x):A.setByteRange(O)}else if(d[5])A.rawProgramDateTime=(" "+d[5]).slice(1),A.tagList.push(["PROGRAM-DATE-TIME",A.rawProgramDateTime]),-1===L&&(L=S.length);else{if(!(d=d[0].match(p))){c.logger.warn("No matches on slow regex match for level playlist!");continue}for(v=1;v<d.length&&void 0===d[v];v++);var I=(" "+d[v]).slice(1),P=(" "+d[v+1]).slice(1),M=d[v+2]?(" "+d[v+2]).slice(1):"";switch(I){case"PLAYLIST-TYPE":y.type=P.toUpperCase();break;case"MEDIA-SEQUENCE":C=y.startSN=parseInt(P);break;case"SKIP":var N=new l.AttrList(P),B=N.decimalInteger("SKIPPED-SEGMENTS");if(Object(r.isFiniteNumber)(B)){y.skippedSegments=B;for(var F=B;F--;)S.unshift(null);C+=B}var j=N.enumeratedString("RECENTLY-REMOVED-DATERANGES");j&&(y.recentlyRemovedDateranges=j.split("\t"));break;case"TARGETDURATION":y.targetduration=parseFloat(P);break;case"VERSION":y.version=parseInt(P);break;case"EXTM3U":break;case"ENDLIST":y.live=!1;break;case"#":(P||M)&&A.tagList.push(M?[P,M]:[P]);break;case"DIS":w++;case"GAP":A.tagList.push([I]);break;case"BITRATE":A.tagList.push([I,P]);break;case"DISCONTINUITY-SEQ":w=parseInt(P);break;case"KEY":var U,G=new l.AttrList(P),H=G.enumeratedString("METHOD"),V=G.URI,z=G.hexadecimalInteger("IV"),K=G.enumeratedString("KEYFORMATVERSIONS"),W=G.enumeratedString("KEYID"),Y=null!=(U=G.enumeratedString("KEYFORMAT"))?U:"identity";if(["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"].indexOf(Y)>-1){c.logger.warn("Keyformat "+Y+" is not supported from the manifest");continue}if("identity"!==Y)continue;H&&(m=o.LevelKey.fromURL(e,V),V&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(H)>=0&&(m.method=H,m.keyFormat=Y,W&&(m.keyID=W),K&&(m.keyFormatVersions=K),m.iv=z));break;case"START":var q=new l.AttrList(P).decimalFloatingPoint("TIME-OFFSET");Object(r.isFiniteNumber)(q)&&(y.startTimeOffset=q);break;case"MAP":var X=new l.AttrList(P);A.relurl=X.URI,X.BYTERANGE&&A.setByteRange(X.BYTERANGE),A.level=i,A.sn="initSegment",m&&(A.levelkey=m),A.initSegment=null,E=A,R=!0;break;case"SERVER-CONTROL":var $=new l.AttrList(P);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(P);y.partTarget=Z.decimalFloatingPoint("PART-TARGET");break;case"PART":var Q=y.partList;Q||(Q=y.partList=[]);var J=k>0?Q[Q.length-1]:void 0,tt=k++,et=new s.Part(new l.AttrList(P),A,e,tt,J);Q.push(et),A.duration+=et.duration;break;case"PRELOAD-HINT":var it=new l.AttrList(P);y.preloadHint=it;break;case"RENDITION-REPORT":var rt=new l.AttrList(P);y.renditionReports=y.renditionReports||[],y.renditionReports.push(rt);break;default:c.logger.warn("line parsed but not handled: "+d)}}}x&&!x.relurl?(S.pop(),T-=x.duration,y.partList&&(y.fragmentHint=x)):y.partList&&(b(A,x),A.cc=w,y.fragmentHint=A);var nt=S.length,st=S[0],at=S[nt-1];if((T+=y.skippedSegments*y.targetduration)>0&&nt&&at){y.averagetargetduration=T/nt;var ot=at.sn;y.endSN="initSegment"!==ot?ot:0,st&&(y.startCC=st.cc,st.initSegment||y.fragments.every((function(t){return t.relurl&&(e=t.relurl,g.test(null!=(i=null===(r=n.parseURL(e))||void 0===r?void 0:r.path)?i:""));var e,i,r}))&&(c.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(A=new s.Fragment(h,e)).relurl=at.relurl,A.level=i,A.sn="initSegment",st.initSegment=A,y.needSidxRanges=!0))}else y.endSN=0,y.startCC=0;return y.fragmentHint&&(T+=y.fragmentHint.duration),y.totalduration=T,y.endCC=w,L>0&&function(t,e){for(var i=t[e],r=e;r--;){var n=t[r];if(!n)return;n.programDateTime=i.programDateTime-1e3*n.duration,i=n}}(S,L),y},t}();function m(t,e){["video","audio","text"].forEach((function(i){var r=t.filter((function(t){return Object(h.isCodecType)(t,i)}));if(r.length){var n=r.filter((function(t){return 0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)}));e[i+"Codec"]=n.length>0?n[0]:r[0],t=t.filter((function(t){return-1===r.indexOf(t)}))}})),e.unknownCodecs=t}function y(t,e,i){var r=e[i];r&&(t[i]=r)}function b(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),Object(r.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,i){"use strict";i.r(e);var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ../events */"./src/events.ts"),s=i(/*! ../errors */"./src/errors.ts"),a=i(/*! ../utils/logger */"./src/utils/logger.ts"),o=i(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=i(/*! ./m3u8-parser */"./src/loader/m3u8-parser.ts"),c=i(/*! ../types/loader */"./src/types/loader.ts"),h=i(/*! ../utils/attr-list */"./src/utils/attr-list.ts");function u(t,e){var i=t.url;return void 0!==i&&0!==i.indexOf("data:")||(i=e.url),i}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,i=e.pLoader,r=e.loader,n=new(i||r)(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 i=e.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:c.PlaylistContextType.MANIFEST,url:i,deliveryDirectives:null})},e.onLevelLoading=function(t,e){var i=e.id,r=e.level,n=e.url,s=e.deliveryDirectives;this.load({id:i,groupId:null,level:r,responseType:"text",type:c.PlaylistContextType.LEVEL,url:n,deliveryDirectives:s})},e.onAudioTrackLoading=function(t,e){var i=e.id,r=e.groupId,n=e.url,s=e.deliveryDirectives;this.load({id:i,groupId:r,level:null,responseType:"text",type:c.PlaylistContextType.AUDIO_TRACK,url:n,deliveryDirectives:s})},e.onSubtitleTrackLoading=function(t,e){var i=e.id,r=e.groupId,n=e.url,s=e.deliveryDirectives;this.load({id:i,groupId:r,level:null,responseType:"text",type:c.PlaylistContextType.SUBTITLE_TRACK,url:n,deliveryDirectives:s})},e.load=function(t){var e,i,r,n,s,o,l=this.hls.config,h=this.getInternalLoader(t);if(h){var u=h.context;if(u&&u.url===t.url)return void a.logger.trace("[playlist-loader]: playlist request ongoing");a.logger.log("[playlist-loader]: aborting previous loader for type: "+t.type),h.abort()}switch(t.type){case c.PlaylistContextType.MANIFEST:i=l.manifestLoadingMaxRetry,r=l.manifestLoadingTimeOut,n=l.manifestLoadingRetryDelay,s=l.manifestLoadingMaxRetryTimeout;break;case c.PlaylistContextType.LEVEL:case c.PlaylistContextType.AUDIO_TRACK:case c.PlaylistContextType.SUBTITLE_TRACK:i=0,r=l.levelLoadingTimeOut;break;default:i=l.levelLoadingMaxRetry,r=l.levelLoadingTimeOut,n=l.levelLoadingRetryDelay,s=l.levelLoadingMaxRetryTimeout}if(h=this.createInternalLoader(t),null!==(e=t.deliveryDirectives)&&void 0!==e&&e.part&&(t.type===c.PlaylistContextType.LEVEL&&null!==t.level?o=this.hls.levels[t.level].details:t.type===c.PlaylistContextType.AUDIO_TRACK&&null!==t.id?o=this.hls.audioTracks[t.id].details:t.type===c.PlaylistContextType.SUBTITLE_TRACK&&null!==t.id&&(o=this.hls.subtitleTracks[t.id].details),o)){var d=o.partTarget,f=o.targetduration;d&&f&&(r=Math.min(1e3*Math.max(3*d,.8*f),r))}var p={timeout:r,maxRetry:i,retryDelay:n,maxRetryDelay:s,highWaterMark:0},g={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};h.load(t,p,g)},e.loadsuccess=function(t,e,i,r){if(void 0===r&&(r=null),i.isSidxRequest)return this.handleSidxRequest(t,i),void this.handlePlaylistLoaded(t,e,i,r);this.resetInternalLoader(i.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,i,r):this.handleMasterPlaylist(t,e,i,r)):this.handleManifestParsingError(t,i,"no EXTM3U delimiter",r)},e.loaderror=function(t,e,i){void 0===i&&(i=null),this.handleNetworkError(e,i,!1,t)},e.loadtimeout=function(t,e,i){void 0===i&&(i=null),this.handleNetworkError(e,i,!0)},e.handleMasterPlaylist=function(t,e,i,r){var s=this.hls,o=t.data,c=u(t,i),d=l.default.parseMasterPlaylist(o,c),f=d.levels,p=d.sessionData;if(f.length){var g=f.map((function(t){return{id:t.attrs.AUDIO,audioCodec:t.audioCodec}})),v=f.map((function(t){return{id:t.attrs.SUBTITLES,textCodec:t.textCodec}})),m=l.default.parseMasterPlaylistMedia(o,c,"AUDIO",g),y=l.default.parseMasterPlaylistMedia(o,c,"SUBTITLES",v),b=l.default.parseMasterPlaylistMedia(o,c,"CLOSED-CAPTIONS");m.length&&(m.some((function(t){return!t.url}))||!f[0].audioCodec||f[0].attrs.AUDIO||(a.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new h.AttrList({}),bitrate:0,url:""}))),s.trigger(n.Events.MANIFEST_LOADED,{levels:f,audioTracks:m,subtitles:y,captions:b,url:c,stats:e,networkDetails:r,sessionData:p})}else this.handleManifestParsingError(t,i,"no level found in manifest",r)},e.handleTrackOrLevelPlaylist=function(t,e,i,a){var o=this.hls,d=i.id,f=i.level,p=i.type,g=u(t,i),v=Object(r.isFiniteNumber)(d)?d:0,m=Object(r.isFiniteNumber)(f)?f:v,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}}(i),b=l.default.parseLevelPlaylist(t.data,g,m,y,v);if(b.fragments.length){if(p===c.PlaylistContextType.MANIFEST){var S={attrs:new h.AttrList({}),bitrate:0,details:b,name:"",url:g};o.trigger(n.Events.MANIFEST_LOADED,{levels:[S],audioTracks:[],url:g,stats:e,networkDetails:a,sessionData:null})}if(e.parsing.end=performance.now(),b.needSidxRanges){var E,C=null===(E=b.fragments[0].initSegment)||void 0===E?void 0:E.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 i.levelDetails=b,this.handlePlaylistLoaded(t,e,i,a)}else o.trigger(n.Events.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:g,reason:"no fragments found in level",level:"number"==typeof i.level?i.level:void 0})},e.handleSidxRequest=function(t,e){var i=Object(o.parseSegmentIndex)(new Uint8Array(t.data));if(i){var r=i.references,n=e.levelDetails;r.forEach((function(t,e){var r=t.info,s=n.fragments[e];0===s.byteRange.length&&s.setByteRange(String(1+r.end-r.start)+"@"+String(r.start)),s.initSegment&&s.initSegment.setByteRange(String(i.moovEndOffset)+"@0")}))}},e.handleManifestParsingError=function(t,e,i,r){this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:e.type===c.PlaylistContextType.MANIFEST,url:t.url,reason:i,response:t,context:e,networkDetails:r})},e.handleNetworkError=function(t,e,i,r){void 0===i&&(i=!1),a.logger.warn("[playlist-loader]: A network "+(i?"timeout":"error")+" occurred while loading "+t.type+" level: "+t.level+" id: "+t.id+' group-id: "'+t.groupId+'"');var o=s.ErrorDetails.UNKNOWN,l=!1,h=this.getInternalLoader(t);switch(t.type){case c.PlaylistContextType.MANIFEST:o=i?s.ErrorDetails.MANIFEST_LOAD_TIMEOUT:s.ErrorDetails.MANIFEST_LOAD_ERROR,l=!0;break;case c.PlaylistContextType.LEVEL:o=i?s.ErrorDetails.LEVEL_LOAD_TIMEOUT:s.ErrorDetails.LEVEL_LOAD_ERROR,l=!1;break;case c.PlaylistContextType.AUDIO_TRACK:o=i?s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case c.PlaylistContextType.SUBTITLE_TRACK:o=i?s.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:s.ErrorDetails.SUBTITLE_LOAD_ERROR,l=!1}h&&this.resetInternalLoader(t.type);var u={type:s.ErrorTypes.NETWORK_ERROR,details:o,fatal:l,url:t.url,loader:h,context:t,networkDetails:e};r&&(u.response=r),this.hls.trigger(n.Events.ERROR,u)},e.handlePlaylistLoaded=function(t,e,i,r){var s=i.type,a=i.level,o=i.id,l=i.groupId,h=i.loader,u=i.levelDetails,d=i.deliveryDirectives;if(null!=u&&u.targetduration){if(h)switch(u.live&&(h.getCacheAge&&(u.ageHeader=h.getCacheAge()||0),h.getCacheAge&&!isNaN(u.ageHeader)||(u.ageHeader=0)),s){case c.PlaylistContextType.MANIFEST:case c.PlaylistContextType.LEVEL:this.hls.trigger(n.Events.LEVEL_LOADED,{details:u,level:a||0,id:o||0,stats:e,networkDetails:r,deliveryDirectives:d});break;case c.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(n.Events.AUDIO_TRACK_LOADED,{details:u,id:o||0,groupId:l||"",stats:e,networkDetails:r,deliveryDirectives:d});break;case c.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(n.Events.SUBTITLE_TRACK_LOADED,{details:u,id:o||0,groupId:l||"",stats:e,networkDetails:r,deliveryDirectives:d})}}else this.handleManifestParsingError(t,i,"invalid target duration",r)},t}();e.default=d},"./src/polyfills/number.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/polyfills/number.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: isFiniteNumber, MAX_SAFE_INTEGER */function(t,e,i){"use strict";i.r(e),i.d(e,"isFiniteNumber",(function(){return r})),i.d(e,"MAX_SAFE_INTEGER",(function(){return n}));var r=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,i){"use strict";i.r(e);var r=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=r},"./src/remux/mp4-generator.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/remux/mp4-generator.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var r=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 i=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=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:i,audio:r};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),s=new Uint8Array([0,0,0,0,0,0,0,0]);t.STTS=t.STSC=t.STCO=s,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 a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);t.FTYP=t.box(t.types.ftyp,a,l,a,o),t.DINF=t.box(t.types.dinf,t.box(t.types.dref,n))},t.box=function(t){for(var e=8,i=arguments.length,r=new Array(i>1?i-1:0),n=1;n<i;n++)r[n-1]=arguments[n];for(var s=r.length,a=s;s--;)e+=r[s].byteLength;var o=new Uint8Array(e);for(o[0]=e>>24&255,o[1]=e>>16&255,o[2]=e>>8&255,o[3]=255&e,o.set(t,4),s=0,e=8;s<a;s++)o.set(r[s],e),e+=r[s].byteLength;return o},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,i){i*=e;var n=Math.floor(i/(r+1)),s=Math.floor(i%(r+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,s>>24,s>>16&255,s>>8&255,255&s,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,i,r){return t.box(t.types.moof,t.mfhd(e),t.traf(r,i))},t.moov=function(e){for(var i=e.length,r=[];i--;)r[i]=t.trak(e[i]);return t.box.apply(null,[t.types.moov,t.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(t.mvex(e)))},t.mvex=function(e){for(var i=e.length,r=[];i--;)r[i]=t.trex(e[i]);return t.box.apply(null,[t.types.mvex].concat(r))},t.mvhd=function(e,i){i*=e;var n=Math.floor(i/(r+1)),s=Math.floor(i%(r+1)),a=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,s>>24,s>>16&255,s>>8&255,255&s,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,a)},t.sdtp=function(e){var i,r,n=e.samples||[],s=new Uint8Array(4+n.length);for(i=0;i<n.length;i++)r=n[i].flags,s[i+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return t.box(t.types.sdtp,s)},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 i,r,n,s=[],a=[];for(i=0;i<e.sps.length;i++)n=(r=e.sps[i]).byteLength,s.push(n>>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(r));for(i=0;i<e.pps.length;i++)n=(r=e.pps[i]).byteLength,a.push(n>>>8&255),a.push(255&n),a=a.concat(Array.prototype.slice.call(r));var o=t.box(t.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|e.sps.length].concat(s).concat([e.pps.length]).concat(a))),l=e.width,c=e.height,h=e.pixelRatio[0],u=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]),o,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([h>>24,h>>16&255,h>>8&255,255&h,u>>24,u>>16&255,u>>8&255,255&u])))},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 i=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,i>>8&255,255&i,0,0]),t.box(t.types.esds,t.esds(e)))},t.mp3=function(e){var i=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,i>>8&255,255&i,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 i=e.id,n=e.duration*e.timescale,s=e.width,a=e.height,o=Math.floor(n/(r+1)),l=Math.floor(n%(r+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,i>>24&255,i>>16&255,i>>8&255,255&i,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,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,s>>8&255,255&s,0,0,a>>8&255,255&a,0,0]))},t.traf=function(e,i){var n=t.sdtp(e),s=e.id,a=Math.floor(i/(r+1)),o=Math.floor(i%(r+1));return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,o>>24,o>>16&255,o>>8&255,255&o])),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 i=e.id;return t.box(t.types.trex,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},t.trun=function(e,i){var r,n,s,a,o,l,c=e.samples||[],h=c.length,u=12+16*h,d=new Uint8Array(u);for(i+=8+u,d.set([0,0,15,1,h>>>24&255,h>>>16&255,h>>>8&255,255&h,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0),r=0;r<h;r++)s=(n=c[r]).duration,a=n.size,o=n.flags,l=n.cts,d.set([s>>>24&255,s>>>16&255,s>>>8&255,255&s,a>>>24&255,a>>>16&255,a>>>8&255,255&a,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*r);return t.box(t.types.trun,d)},t.initSegment=function(e){t.types||t.init();var i=t.moov(e),r=new Uint8Array(t.FTYP.byteLength+i.byteLength);return r.set(t.FTYP),r.set(i,t.FTYP.byteLength),r},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,i){"use strict";i.r(e),i.d(e,"default",(function(){return g})),i.d(e,"normalizePts",(function(){return v}));var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ./aac-helper */"./src/remux/aac-helper.ts"),s=i(/*! ./mp4-generator */"./src/remux/mp4-generator.ts"),a=i(/*! ../events */"./src/events.ts"),o=i(/*! ../errors */"./src/errors.ts"),l=i(/*! ../utils/logger */"./src/utils/logger.ts"),c=i(/*! ../types/loader */"./src/types/loader.ts"),h=i(/*! ../utils/timescale-conversion */"./src/utils/timescale-conversion.ts");function u(){return(u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t}).apply(this,arguments)}var d=null,f=null,p=!1,g=function(){function t(t,e,i,r){if(void 0===r&&(r=""),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=i,this.ISGenerated=!1,null===d){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);d=n?parseInt(n[1]):0}if(null===f){var s=navigator.userAgent.match(/Safari\/(\d+)/i);f=s?parseInt(s[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,i=t.reduce((function(t,i){var r=i.pts-t;return r<-4294967296?(e=!0,v(t,i.pts)):r>0?t:i.pts}),t[0].pts);return e&&l.logger.debug("PTS rollover detected"),i},e.remux=function(t,e,i,r,n,s,a,o){var h,u,d,f,p,g,m=n,y=n,b=t.pid>-1,S=e.pid>-1,E=e.samples.length,C=t.samples.length>0,k=E>1;if((!b||C)&&(!S||k)||this.ISGenerated||a){this.ISGenerated||(d=this.generateIS(t,e,n));var T=this.isVideoContiguous,w=-1;if(k&&(w=function(t){for(var e=0;e<t.length;e++)if(t[e].key)return e;return-1}(e.samples),!T&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,w>0){l.logger.warn("[mp4-remuxer]: Dropped "+w+" out of "+E+" video samples due to a missing keyframe");var x=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(w),e.dropped+=w,y+=(e.samples[0].pts-x)/(e.timescale||9e4)}else-1===w&&(l.logger.warn("[mp4-remuxer]: No keyframe found out of "+E+" video samples"),g=!1);if(this.ISGenerated){if(C&&k){var A=this.getVideoStartPts(e.samples),L=(v(t.samples[0].pts,A)-A)/e.inputTimeScale;m+=Math.max(0,L),y+=Math.max(0,-L)}if(C){if(t.samplerate||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),d=this.generateIS(t,e,n)),u=this.remuxAudio(t,m,this.isAudioContiguous,s,S||k||o===c.PlaylistLevelType.AUDIO?y:void 0),k){var R=u?u.endPTS-u.startPTS:0;e.inputTimeScale||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(t,e,n)),h=this.remuxVideo(e,y,T,R)}}else k&&(h=this.remuxVideo(e,y,T,0));h&&(h.firstKeyFrame=w,h.independent=-1!==w)}}return this.ISGenerated&&(i.samples.length&&(p=this.remuxID3(i,n)),r.samples.length&&(f=this.remuxText(r,n))),{audio:u,video:h,initSegment:d,independent:g,text:f,id3:p}},e.generateIS=function(t,e,i){var n,a,o,l=t.samples,c=e.samples,h=this.typeSupported,u={},d=!Object(r.isFiniteNumber)(this._initPTS),f="audio/mp4";if(d&&(n=a=1/0),t.config&&l.length&&(t.timescale=t.samplerate,t.isAAC||(h.mpeg?(f="audio/mpeg",t.codec=""):h.mp3&&(t.codec="mp3")),u.audio={id:"audio",container:f,codec:t.codec,initSegment:!t.isAAC&&h.mpeg?new Uint8Array(0):s.default.initSegment([t]),metadata:{channelCount:t.channelCount}},d&&(o=t.inputTimeScale,n=a=l[0].pts-Math.round(o*i))),e.sps&&e.pps&&c.length&&(e.timescale=e.inputTimeScale,u.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:s.default.initSegment([e]),metadata:{width:e.width,height:e.height}},d)){o=e.inputTimeScale;var p=this.getVideoStartPts(c),g=Math.round(o*i);a=Math.min(a,v(c[0].dts,p)-g),n=Math.min(n,p-g)}if(Object.keys(u).length)return this.ISGenerated=!0,d&&(this._initPTS=n,this._initDTS=a),{tracks:u,initPTS:n,timescale:o}},e.remuxVideo=function(t,e,i,r){var n,c,f,g=t.inputTimeScale,y=t.samples,b=[],S=y.length,E=this._initPTS,C=this.nextAvcDts,k=8,T=Number.POSITIVE_INFINITY,w=Number.NEGATIVE_INFINITY,x=0,A=!1;i&&null!==C||(C=e*g-(y[0].pts-v(y[0].dts,y[0].pts)));for(var L=0;L<S;L++){var R=y[L];R.pts=v(R.pts-E,C),R.dts=v(R.dts-E,C),R.dts>R.pts&&(x=Math.max(Math.min(x,R.pts-R.dts),-18e3)),R.dts<y[L>0?L-1:L].dts&&(A=!0)}A&&y.sort((function(t,e){var i=t.dts-e.dts,r=t.pts-e.pts;return i||r})),c=y[0].dts,f=y[y.length-1].dts;var D=Math.round((f-c)/(S-1));if(x<0){if(x<-2*D){l.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(h.toMsFromMpegTsClock)(-D,!0)+" ms");for(var _=x,O=0;O<S;O++)y[O].dts=_=Math.max(_,y[O].pts-D),y[O].pts=Math.max(_,y[O].pts)}else{l.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(h.toMsFromMpegTsClock)(x,!0)+" ms to overcome this issue");for(var I=0;I<S;I++)y[I].dts=y[I].dts+x}c=y[0].dts}if(i){var P=c-C,M=P>D;if(M||P<-1){M?l.logger.warn("AVC: "+Object(h.toMsFromMpegTsClock)(P,!0)+" ms ("+P+"dts) hole between fragments detected, filling it"):l.logger.warn("AVC: "+Object(h.toMsFromMpegTsClock)(-P,!0)+" ms ("+P+"dts) overlapping between fragments detected"),c=C;var N=y[0].pts-P;y[0].dts=c,y[0].pts=N,l.logger.log("Video: First PTS/DTS adjusted: "+Object(h.toMsFromMpegTsClock)(N,!0)+"/"+Object(h.toMsFromMpegTsClock)(c,!0)+", delta: "+Object(h.toMsFromMpegTsClock)(P,!0)+" ms")}}p&&(c=Math.max(0,c));for(var B=0,F=0,j=0;j<S;j++){for(var U=y[j],G=U.units,H=G.length,V=0,z=0;z<H;z++)V+=G[z].data.length;F+=V,B+=H,U.length=V,U.dts=Math.max(U.dts,c),U.pts=Math.max(U.pts,U.dts,0),T=Math.min(U.pts,T),w=Math.max(U.pts,w)}f=y[S-1].dts;var K,W=F+4*B+8;try{K=new Uint8Array(W)}catch(t){return void this.observer.emit(a.Events.ERROR,a.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:W,reason:"fail allocating video mdat "+W})}var Y=new DataView(K.buffer);Y.setUint32(0,W),K.set(s.default.types.mdat,4);for(var q=0;q<S;q++){for(var X=y[q],$=X.units,Z=0,Q=0,J=$.length;Q<J;Q++){var tt=$[Q],et=tt.data,it=tt.data.byteLength;Y.setUint32(k,it),k+=4,K.set(et,k),k+=it,Z+=4+it}if(q<S-1)n=y[q+1].dts-X.dts;else{var rt=this.config,nt=X.dts-y[q>0?q-1:q].dts;if(rt.stretchShortVideoTrack&&null!==this.nextAudioPts){var st=Math.floor(rt.maxBufferHole*g),at=(r?T+r*g:this.nextAudioPts)-X.pts;at>st?((n=at-nt)<0&&(n=nt),l.logger.log("[mp4-remuxer]: It is approximately "+at/90+" ms to the next segment; using duration "+n/90+" ms for the last video frame.")):n=nt}else n=nt}var ot=Math.round(X.pts-X.dts);b.push(new m(X.key,n,Z,ot))}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:s.default.moof(t.sequenceNumber++,c,u({},t,{samples:b})),data2:K,startPTS:T/g,endPTS:(w+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(K.length,"MDAT length must not be zero"),ct},e.remuxAudio=function(t,e,i,r,c){var h=t.inputTimeScale,d=h/(t.samplerate?t.samplerate:h),f=t.isAAC?1024:1152,p=f*d,g=this._initPTS,y=!t.isAAC&&this.typeSupported.mpeg,b=[],S=t.samples,E=y?0:8,C=this.nextAudioPts||-1,k=e*h;if(this.isAudioContiguous=i=i||S.length&&C>0&&(r&&Math.abs(k-C)<9e3||Math.abs(v(S[0].pts-g,k)-C)<20*p),S.forEach((function(t){t.pts=v(t.pts-g,k)})),!i||C<0){if(!(S=S.filter((function(t){return t.pts>=0}))).length)return;C=0===c?0:r?Math.max(0,k):S[0].pts}if(t.isAAC)for(var T=void 0!==c,w=this.config.maxAudioFramesDrift,x=0,A=C;x<S.length;x++){var L=S[x],R=L.pts,D=R-A,_=Math.abs(1e3*D/h);if(D<=-w*p&&T)0===x&&(l.logger.warn("Audio frame @ "+(R/h).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*D/h)+" ms."),this.nextAudioPts=C=A=R);else if(D>=w*p&&_<1e4&&T){var O=Math.round(D/p);(A=R-O*p)<0&&(O--,A+=p),0===x&&(this.nextAudioPts=C=A),l.logger.warn("[mp4-remuxer]: Injecting "+O+" audio frame @ "+(A/h).toFixed(3)+"s due to "+Math.round(1e3*D/h)+" ms gap.");for(var I=0;I<O;I++){var P=Math.max(A,0),M=n.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);M||(l.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),M=L.unit.subarray()),S.splice(x,0,{unit:M,pts:P}),A+=p,x++}}L.pts=A,A+=p}for(var N,B=null,F=null,j=0,U=S.length;U--;)j+=S[U].unit.byteLength;for(var G=0,H=S.length;G<H;G++){var V=S[G],z=V.unit,K=V.pts;if(null!==F)b[G-1].duration=Math.round((K-F)/d);else{if(i&&t.isAAC&&(K=C),B=K,!(j>0))return;j+=E;try{N=new Uint8Array(j)}catch(t){return void this.observer.emit(a.Events.ERROR,a.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:j,reason:"fail allocating audio mdat "+j})}y||(new DataView(N.buffer).setUint32(0,j),N.set(s.default.types.mdat,4))}N.set(z,E);var W=z.byteLength;E+=W,b.push(new m(!0,f,W,0)),F=K}var Y=b.length;if(Y){var q=b[b.length-1];this.nextAudioPts=C=F+d*q.duration;var X=y?new Uint8Array(0):s.default.moof(t.sequenceNumber++,B/d,u({},t,{samples:b}));t.samples=[];var $=B/h,Z=C/h,Q={data1:X,data2:N,startPTS:$,endPTS:Z,startDTS:$,endDTS:Z,type:"audio",hasAudio:!0,hasVideo:!1,nb:Y};return this.isAudioContiguous=!0,console.assert(N.length,"MDAT length must not be zero"),Q}},e.remuxEmptyAudio=function(t,e,i,r){var s=t.inputTimeScale,a=s/(t.samplerate?t.samplerate:s),o=this.nextAudioPts,c=(null!==o?o:r.startDTS*s)+this._initDTS,h=r.endDTS*s+this._initDTS,u=1024*a,d=Math.ceil((h-c)/u),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 v=c+g*u;p.push({unit:f,pts:v,dts:v})}return t.samples=p,this.remuxAudio(t,e,i,!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 i=t.samples.length;if(i){for(var r=t.inputTimeScale,n=this._initPTS,s=this._initDTS,a=0;a<i;a++){var o=t.samples[a];o.pts=v(o.pts-n,e*r)/r,o.dts=v(o.dts-s,e*r)/r}var l=t.samples;return t.samples=[],{samples:l}}},e.remuxText=function(t,e){var i=t.samples.length;if(i){for(var r=t.inputTimeScale,n=this._initPTS,s=0;s<i;s++){var a=t.samples[s];a.pts=v(a.pts-n,e*r)/r}t.samples.sort((function(t,e){return t.pts-e.pts}));var o=t.samples;return t.samples=[],{samples:o}}},t}();function v(t,e){var i;if(null===e)return t;for(i=e<t?-8589934592:8589934592;Math.abs(t-e)>4294967296;)t+=i;return t}var m=function(t,e,i,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=i,this.cts=r,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,i){"use strict";i.r(e);var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),s=i(/*! ../loader/fragment */"./src/loader/fragment.ts"),a=i(/*! ../utils/logger */"./src/utils/logger.ts"),o=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,i){this.audioCodec=e,this.videoCodec=i,this.generateInitSegment(t),this.emitInitSegment=!0},e.generateInitSegment=function(t){var e=this.audioCodec,i=this.videoCodec;if(!t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var r=this.initData=Object(n.parseInitSegment)(t);e||(e=c(r.audio,s.ElementaryStreamTypes.AUDIO)),i||(i=c(r.video,s.ElementaryStreamTypes.VIDEO));var o={};r.audio&&r.video?o.audiovideo={container:"video/mp4",codec:e+","+i,initSegment:t,id:"main"}:r.audio?o.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:r.video?o.video={container:"video/mp4",codec:i,initSegment:t,id:"main"}:a.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},e.remux=function(t,e,i,s,o){var c=this.initPTS,h=this.lastEndDTS,u={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};Object(r.isFiniteNumber)(h)||(h=this.lastEndDTS=o||0);var d=e.samples;if(!d||!d.length)return u;var f={initPTS:void 0,timescale:1},p=this.initData;if(p&&p.length||(this.generateInitSegment(d),p=this.initData),!p||!p.length)return a.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),u;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1),Object(r.isFiniteNumber)(c)||(this.initPTS=f.initPTS=c=l(p,d,h));var g=Object(n.getDuration)(d,p),v=h,m=g+v;Object(n.offsetStartDTS)(p,d,c),g>0?this.lastEndDTS=m:(a.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var y=!!p.audio,b=!!p.video,S="";y&&(S+="audio"),b&&(S+="video");var E={data1:d,startPTS:v,startDTS:v,endPTS:m,endDTS:m,type:S,hasAudio:y,hasVideo:b,nb:1,dropped:0};return u.audio="audio"===E.type?E:void 0,u.video="audio"!==E.type?E:void 0,u.text=s,u.id3=i,u.initSegment=f,u},t}(),l=function(t,e,i){return Object(n.getStartDTS)(t,e)-i};function c(t,e){var i=null==t?void 0:t.codec;return i&&i.length>4?i:"hvc1"===i?"hvc1.1.c.L120.90":"av01"===i?"av01.0.04M.08":"avc1"===i||e===s.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}e.default=o},"./src/task-loop.ts":
|
|
|
/*!**************************!*\
|
|
|
!*** ./src/task-loop.ts ***!
|
|
|
\**************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return r}));var r=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,i){"use strict";i.r(e),i.d(e,"CMCDVersion",(function(){return a})),i.d(e,"CMCDObjectType",(function(){return r})),i.d(e,"CMCDStreamingFormat",(function(){return n})),i.d(e,"CMCDStreamType",(function(){return s}));var r,n,s,a=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"}(r||(r={})),function(t){t.DASH="d",t.HLS="h",t.SMOOTH="s",t.OTHER="o"}(n||(n={})),function(t){t.VOD="v",t.LIVE="l"}(s||(s={}))},"./src/types/level.ts":
|
|
|
/*!****************************!*\
|
|
|
!*** ./src/types/level.ts ***!
|
|
|
\****************************/
|
|
|
/*! exports provided: HlsSkip, getSkipValue, HlsUrlParameters, Level */function(t,e,i){"use strict";function r(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var n;function s(t,e){var i=t.canSkipUntil,r=t.canSkipDateRanges,s=t.endSN;return i&&(void 0!==e?e-s:0)<i?r?n.v2:n.Yes:n.No}i.r(e),i.d(e,"HlsSkip",(function(){return n})),i.d(e,"getSkipValue",(function(){return s})),i.d(e,"HlsUrlParameters",(function(){return a})),i.d(e,"Level",(function(){return o})),function(t){t.No="",t.Yes="YES",t.v2="v2"}(n||(n={}));var a=function(){function t(t,e,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=i}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}(),o=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,i,n;return e=t,(i=[{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)}}])&&r(e.prototype,i),n&&r(e,n),t}()},"./src/types/loader.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/types/loader.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: PlaylistContextType, PlaylistLevelType */function(t,e,i){"use strict";var r,n;i.r(e),i.d(e,"PlaylistContextType",(function(){return r})),i.d(e,"PlaylistLevelType",(function(){return n})),function(t){t.MANIFEST="manifest",t.LEVEL="level",t.AUDIO_TRACK="audioTrack",t.SUBTITLE_TRACK="subtitleTrack"}(r||(r={})),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,i){"use strict";i.r(e),i.d(e,"ChunkMetadata",(function(){return r}));var r=function(t,e,i,r,n,s){void 0===r&&(r=0),void 0===n&&(n=-1),void 0===s&&(s=!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=i,this.size=r,this.part=n,this.partial=s}},"./src/utils/attr-list.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/utils/attr-list.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: AttrList */function(t,e,i){"use strict";i.r(e),i.d(e,"AttrList",(function(){return s}));var r=/^(\d+)x(\d+)$/,n=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,s=function(){function t(e){for(var i in"string"==typeof e&&(e=t.parseAttrList(e)),e)e.hasOwnProperty(i)&&(this[i]=e[i])}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 i=new Uint8Array(e.length/2),r=0;r<e.length/2;r++)i[r]=parseInt(e.slice(2*r,2*r+2),16);return i}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 i=this[t];return i?parseFloat(i):e},e.enumeratedString=function(t){return this[t]},e.bool=function(t){return"YES"===this[t]},e.decimalResolution=function(t){var e=r.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},t.parseAttrList=function(t){var e,i={};for(n.lastIndex=0;null!==(e=n.exec(t));){var r=e[2];0===r.indexOf('"')&&r.lastIndexOf('"')===r.length-1&&(r=r.slice(1,-1)),i[e[1]]=r}return i},t}()},"./src/utils/binary-search.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/utils/binary-search.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),e.default={search:function(t,e){for(var i=0,r=t.length-1,n=null,s=null;i<=r;){var a=e(s=t[n=(i+r)/2|0]);if(a>0)i=n+1;else{if(!(a<0))return s;r=n-1}}return null}}},"./src/utils/buffer-helper.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/utils/buffer-helper.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: BufferHelper */function(t,e,i){"use strict";i.r(e),i.d(e,"BufferHelper",(function(){return s}));var r=i(/*! ./logger */"./src/utils/logger.ts"),n={length:0,start:function(){return 0},end:function(){return 0}},s=function(){function t(){}return t.isBuffered=function(e,i){try{if(e)for(var r=t.getBuffered(e),n=0;n<r.length;n++)if(i>=r.start(n)&&i<=r.end(n))return!0}catch(t){}return!1},t.bufferInfo=function(e,i,r){try{if(e){var n,s=t.getBuffered(e),a=[];for(n=0;n<s.length;n++)a.push({start:s.start(n),end:s.end(n)});return this.bufferedInfo(a,i,r)}}catch(t){}return{len:0,start:i,end:i,nextStart:void 0}},t.bufferedInfo=function(t,e,i){e=Math.max(0,e),t.sort((function(t,e){var i=t.start-e.start;return i||e.end-t.end}));var r=[];if(i)for(var n=0;n<t.length;n++){var s=r.length;if(s){var a=r[s-1].end;t[n].start-a<i?t[n].end>a&&(r[s-1].end=t[n].end):r.push(t[n])}else r.push(t[n])}else r=t;for(var o,l=0,c=e,h=e,u=0;u<r.length;u++){var d=r[u].start,f=r[u].end;if(e+i>=d&&e<f)c=d,l=(h=f)-e;else if(e+i<d){o=d;break}}return{len:l,start:c||0,end:h||0,nextStart:o}},t.getBuffered=function(t){try{return t.buffered}catch(t){return r.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,i){"use strict";i.r(e),i.d(e,"Row",(function(){return v})),i.d(e,"CaptionScreen",(function(){return m}));var r,n=i(/*! ../utils/logger */"./src/utils/logger.ts"),s={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},a=function(t){var e=t;return s.hasOwnProperty(t)&&(e=s[t]),String.fromCharCode(e)},o={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},h={25:2,26:4,29:6,30:8,31:10,27:13,28:15},u=["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"}(r||(r={}));var d=function(){function t(){this.time=null,this.verboseLevel=r.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=[],i=0;i<t.length;i++)e.push(t[i].toString(16));return e},p=function(){function t(t,e,i,r,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=i||!1,this.background=r||"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"],i=0;i<e.length;i++){var r=e[i];t.hasOwnProperty(r)&&(this[r]=t[r])}},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,i,r,n,s){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new p(e,i,r,n,s)}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}(),v=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,i=0;i<100;i++)if(!this.chars[i].equals(t.chars[i])){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(r.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>100&&(this.logger.log(r.DEBUG,"Too large cursor position "+this.pos),this.pos=100)},e.moveCursor=function(t){var e=this.pos+t;if(t>1)for(var i=this.pos+1;i<e+1;i++)this.chars[i].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=a(t);this.pos>=100?this.logger.log(r.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,i=0;i<100;i++){var r=this.chars[i].uchar;" "!==r&&(e=!1),t.push(r)}return e?"":t.join("")},e.setPenStyles=function(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)},t}(),m=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 v(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,i=0;i<15;i++)if(!this.rows[i].equals(t.rows[i])){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(r.INFO,"setCursor: "+t),this.rows[this.currRow].setCursor(t)},e.setPAC=function(t){this.logger.log(r.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 i=0;i<15;i++)this.rows[i].clear();var n=this.currRow+1-this.nrRollUpRows,s=this.lastOutputScreen;if(s){var a=s.rows[n].cueStartTime,o=this.logger.time;if(a&&null!==o&&a<o)for(var l=0;l<this.nrRollUpRows;l++)this.rows[e-this.nrRollUpRows+l+1].copy(s.rows[n+l])}}this.currRow=e;var c=this.rows[this.currRow];if(null!==t.indent){var h=t.indent,u=Math.max(h-1,0);c.setCursor(t.indent),t.color=c.chars[u].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(r.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(r.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(r.INFO,"Rolling up")}else this.logger.log(r.DEBUG,"roll_up but nrRollUpRows not set yet")},e.getDisplayText=function(t){t=t||!1;for(var e=[],i="",r=-1,n=0;n<15;n++){var s=this.rows[n].getTextString();s&&(r=n+1,t?e.push("Row "+r+": '"+s+"'"):e.push(s.trim()))}return e.length>0&&(i=t?"["+e.join(" | ")+"]":e.join("\n")),i},e.getTextAndFormat=function(){return this.rows},t}(),y=function(){function t(t,e,i){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 m(i),this.nonDisplayedMemory=new m(i),this.lastOutputScreen=new m(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}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(r.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 i=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(r.INFO,i+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(r.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},e.ccRCL=function(){this.logger.log(r.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},e.ccBS=function(){this.logger.log(r.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(r.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},e.ccRU=function(t){this.logger.log(r.INFO,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)},e.ccFON=function(){this.logger.log(r.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},e.ccRDC=function(){this.logger.log(r.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},e.ccTR=function(){this.logger.log(r.INFO,"TR"),this.setMode("MODE_TEXT")},e.ccRTD=function(){this.logger.log(r.INFO,"RTD"),this.setMode("MODE_TEXT")},e.ccEDM=function(){this.logger.log(r.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},e.ccCR=function(){this.logger.log(r.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},e.ccENM=function(){this.logger.log(r.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},e.ccEOC=function(){if(this.logger.log(r.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(r.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},e.ccTO=function(t){this.logger.log(r.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 i=Math.floor(t/2)-16;e.foreground=["white","green","blue","cyan","red","yellow","magenta"][i]}this.logger.log(r.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,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var r=new d;this.channels=[null,new y(t,e,r),new y(t+1,i,r)],this.cmdHistory={a:null,b:null},this.logger=r}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 i,n,s,a=!1;this.logger.time=t;for(var o=0;o<e.length;o+=2)if(n=127&e[o],s=127&e[o+1],0!==n||0!==s){if(this.logger.log(r.DATA,"["+f([e[o],e[o+1]])+"] -> ("+f([n,s])+")"),(i=this.parseCmd(n,s))||(i=this.parseMidrow(n,s)),i||(i=this.parsePAC(n,s)),i||(i=this.parseBackgroundAttributes(n,s)),!i&&(a=this.parseChars(n,s))){var l=this.currentChannel;l&&l>0?this.channels[l].insertChars(a):this.logger.log(r.WARNING,"No channel found yet. TEXT-MODE?")}i||a||this.logger.log(r.WARNING,"Couldn't parse cleaned data "+f([n,s])+" orig: "+f([e[o],e[o+1]]))}},e.parseCmd=function(t,e){var i=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(E(t,e,i))return S(null,null,i),this.logger.log(r.DEBUG,"Repeated command ("+f([t,e])+") is dropped"),!0;var n=20===t||21===t||23===t?1:2,s=this.channels[n];return 20===t||21===t||28===t||29===t?32===e?s.ccRCL():33===e?s.ccBS():34===e?s.ccAOF():35===e?s.ccAON():36===e?s.ccDER():37===e?s.ccRU(2):38===e?s.ccRU(3):39===e?s.ccRU(4):40===e?s.ccFON():41===e?s.ccRDC():42===e?s.ccTR():43===e?s.ccRTD():44===e?s.ccEDM():45===e?s.ccCR():46===e?s.ccENM():47===e&&s.ccEOC():s.ccTO(e-32),S(t,e,i),this.currentChannel=n,!0},e.parseMidrow=function(t,e){var i=0;if((17===t||25===t)&&e>=32&&e<=47){if((i=17===t?1:2)!==this.currentChannel)return this.logger.log(r.ERROR,"Mismatch channel in midrow parsing"),!1;var n=this.channels[i];return!!n&&(n.ccMIDROW(e),this.logger.log(r.DEBUG,"MIDROW ("+f([t,e])+")"),!0)}return!1},e.parsePAC=function(t,e){var i,r=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(E(t,e,r))return S(null,null,r),!0;var n=t<=23?1:2;i=e>=64&&e<=95?1===n?o[t]:c[t]:1===n?l[t]:h[t];var s=this.channels[n];return!!s&&(s.setPAC(this.interpretPAC(i,e)),S(t,e,r),this.currentChannel=n,!0)},e.interpretPAC=function(t,e){var i,r={color:null,italics:!1,indent:null,underline:!1,row:t};return i=e>95?e-96:e-64,r.underline=1==(1&i),i<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(r.italics=!0,r.color="white"):r.indent=4*Math.floor((i-16)/2),r},e.parseChars=function(t,e){var i,n,s=null,o=null;if(t>=25?(i=2,o=t-8):(i=1,o=t),o>=17&&o<=19?(n=17===o?e+80:18===o?e+112:e+144,this.logger.log(r.INFO,"Special char '"+a(n)+"' in channel "+i),s=[n]):t>=32&&t<=127&&(s=0===e?[t]:[t,e]),s){var l=f(s);this.logger.log(r.DEBUG,"Char codes = "+l.join(",")),S(t,e,this.cmdHistory)}return s},e.parseBackgroundAttributes=function(t,e){var i;if(!((16===t||24===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=45&&e<=47))return!1;var r={};16===t||24===t?(i=Math.floor((e-32)/2),r.background=u[i],e%2==1&&(r.background=r.background+"_semi")):45===e?r.background="transparent":(r.foreground="black",47===e&&(r.underline=!0));var n=t<=23?1:2;return this.channels[n].setBkgData(r),S(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 i=this.channels[e];i&&i.cueSplitAtTime(t)}},t}();function S(t,e,i){i.a=t,i.b=e}function E(t,e,i){return i.a===t&&i.b===e}e.default=b},"./src/utils/codecs.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/utils/codecs.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: isCodecType, isCodecSupportedInMp4 */function(t,e,i){"use strict";i.r(e),i.d(e,"isCodecType",(function(){return n})),i.d(e,"isCodecSupportedInMp4",(function(){return s}));var r={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 i=r[e];return!!i&&!0===i[t.slice(0,4)]}function s(t,e){return MediaSource.isTypeSupported((e||"video")+'/mp4;codecs="'+t+'"')}},"./src/utils/cues.ts":
|
|
|
/*!***************************!*\
|
|
|
!*** ./src/utils/cues.ts ***!
|
|
|
\***************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var r=i(/*! ./vttparser */"./src/utils/vttparser.ts"),n=i(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts"),s=i(/*! ./texttrack-utils */"./src/utils/texttrack-utils.ts"),a=/\s/,o={newCue:function(t,e,i,o){for(var l,c,h,u,d,f=[],p=self.VTTCue||self.TextTrackCue,g=0;g<o.rows.length;g++)if(h=!0,u=0,d="",!(l=o.rows[g]).isEmpty()){for(var v=0;v<l.chars.length;v++)a.test(l.chars[v].uchar)&&h?u++:(d+=l.chars[v].uchar,h=!1);l.cueStartTime=e,e===i&&(i+=1e-4),u>=16?u--:u++;var m=Object(r.fixLineBreaks)(d.trim()),y=Object(n.generateCueId)(e,i,m);t&&t.cues&&t.cues.getCueById(y)||((c=new p(e,i,m)).id=y,c.line=g+1,c.align="left",c.position=10+Math.min(80,10*Math.floor(8*u/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(s.addCueToTrack)(t,e)}))),f}};e.default=o},"./src/utils/discontinuities.ts":
|
|
|
/*!**************************************!*\
|
|
|
!*** ./src/utils/discontinuities.ts ***!
|
|
|
\**************************************/
|
|
|
/*! exports provided: findFirstFragWithCC, shouldAlignOnDiscontinuities, findDiscontinuousReferenceFrag, adjustSlidingStart, alignStream, alignPDT, alignFragmentByPDTDelta, alignMediaPlaylistByPDT */function(t,e,i){"use strict";i.r(e),i.d(e,"findFirstFragWithCC",(function(){return a})),i.d(e,"shouldAlignOnDiscontinuities",(function(){return o})),i.d(e,"findDiscontinuousReferenceFrag",(function(){return l})),i.d(e,"adjustSlidingStart",(function(){return h})),i.d(e,"alignStream",(function(){return u})),i.d(e,"alignPDT",(function(){return d})),i.d(e,"alignFragmentByPDTDelta",(function(){return f})),i.d(e,"alignMediaPlaylistByPDT",(function(){return p}));var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ./logger */"./src/utils/logger.ts"),s=i(/*! ../controller/level-helper */"./src/controller/level-helper.ts");function a(t,e){for(var i=null,r=0,n=t.length;r<n;r++){var s=t[r];if(s&&s.cc===e){i=s;break}}return i}function o(t,e,i){return!(!e.details||!(i.endCC>i.startCC||t&&t.cc<i.startCC))}function l(t,e){var i=t.fragments,r=e.fragments;if(r.length&&i.length){var s=a(i,r[0].cc);if(s&&(!s||s.startPTS))return s;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 i=t.start+e;t.start=t.startPTS=i,t.endPTS=i+t.duration}}function h(t,e){for(var i=e.fragments,r=0,n=i.length;r<n;r++)c(i[r],t);e.fragmentHint&&c(e.fragmentHint,t),e.alignedSliding=!0}function u(t,e,i){e&&(function(t,e,i){if(o(t,i,e)){var s=l(i.details,e);s&&Object(r.isFiniteNumber)(s.start)&&(n.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),h(s.start,e))}}(t,i,e),!i.alignedSliding&&e.details&&d(i,e.details),i.alignedSliding||!e.details||i.skippedSegments||Object(s.adjustSliding)(e.details,i))}function d(t,e){if(e.fragments.length&&t.hasProgramDateTime&&e.hasProgramDateTime){var i=e.fragments[0].programDateTime,s=t.fragments[0].programDateTime,a=(s-i)/1e3+e.fragments[0].start;a&&Object(r.isFiniteNumber)(a)&&(n.logger.log("Adjusting PTS using programDateTime delta "+(s-i)+"ms, sliding:"+a.toFixed(3)+" "+t.url+" "),h(a,t))}}function f(t,e){var i=t.programDateTime;if(i){var r=(i-e)/1e3;t.start=t.startPTS=r,t.endPTS=r+t.duration}}function p(t,e){if(e.fragments.length&&t.hasProgramDateTime&&e.hasProgramDateTime){var i=e.fragments[0].programDateTime-1e3*e.fragments[0].start;t.fragments.forEach((function(t){f(t,i)})),t.fragmentHint&&f(t.fragmentHint,i),t.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":
|
|
|
/*!***********************************************!*\
|
|
|
!*** ./src/utils/ewma-bandwidth-estimator.ts ***!
|
|
|
\***********************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var r=i(/*! ../utils/ewma */"./src/utils/ewma.ts"),n=function(){function t(t,e,i){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new r.default(t),this.fast_=new r.default(e)}var e=t.prototype;return e.update=function(t,e){var i=this.slow_,n=this.fast_;this.slow_.halfLife!==t&&(this.slow_=new r.default(t,i.getEstimate(),i.getTotalWeight())),this.fast_.halfLife!==e&&(this.fast_=new r.default(e,n.getEstimate(),n.getTotalWeight()))},e.sample=function(t,e){var i=(t=Math.max(t,this.minDelayMs_))/1e3,r=8*e/i;this.fast_.sample(i,r),this.slow_.sample(i,r)},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,i){"use strict";i.r(e);var r=function(){function t(t,e,i){void 0===e&&(e=0),void 0===i&&(i=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_=i}var e=t.prototype;return e.sample=function(t,e){var i=Math.pow(this.alpha_,t);this.estimate_=e*(1-i)+i*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=r},"./src/utils/fetch-loader.ts":
|
|
|
/*!***********************************!*\
|
|
|
!*** ./src/utils/fetch-loader.ts ***!
|
|
|
\***********************************/
|
|
|
/*! exports provided: fetchSupported, default */function(t,e,i){"use strict";i.r(e),i.d(e,"fetchSupported",(function(){return d}));var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=i(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");function a(t){var e="function"==typeof Map?new Map:void 0;return(a=function(t){if(null===t||(i=t,-1===Function.toString.call(i).indexOf("[native code]")))return t;var i;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,r)}function r(){return o(t,arguments,h(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),c(r,t)})(t)}function o(t,e,i){return(o=l()?Reflect.construct:function(t,e,i){var r=[null];r.push.apply(r,e);var n=new(Function.bind.apply(t,r));return i&&c(n,i.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 h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(){return(u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}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,i){var n=this,s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();var a=function(t,e){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(u({},t.headers))};return t.rangeEnd&&i.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),i}(t,this.controller.signal),o=i.onProgress,l="arraybuffer"===t.responseType,c=l?"byteLength":"length";this.context=t,this.config=e,this.callbacks=i,this.request=this.fetchSetup(t,a),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout((function(){n.abortInternal(),i.onTimeout(s,t,n.response)}),e.timeout),self.fetch(this.request).then((function(i){if(n.response=n.loader=i,!i.ok){var a=i.status,c=i.statusText;throw new g(c||"fetch, bad network response",a,i)}return s.loading.first=Math.max(self.performance.now(),s.loading.start),s.total=parseInt(i.headers.get("Content-Length")||"0"),o&&Object(r.isFiniteNumber)(e.highWaterMark)?n.loadProgressively(i,s,t,e.highWaterMark,o):l?i.arrayBuffer():i.text()})).then((function(a){var l=n.response;self.clearTimeout(n.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first),s.loaded=s.total=a[c];var h={url:l.url,data:a};o&&!Object(r.isFiniteNumber)(e.highWaterMark)&&o(s,t,a,l),i.onSuccess(h,s,t,l)})).catch((function(e){if(self.clearTimeout(n.requestTimeout),!s.aborted){var r=e.code||0;i.onError({code:r,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,i,r,n){void 0===r&&(r=0);var a=new s.default,o=t.body.getReader();return function s(){return o.read().then((function(o){if(o.done)return a.dataLength&&n(e,i,a.flush(),t),Promise.resolve(new ArrayBuffer(0));var l=o.value,c=l.length;return e.loaded+=c,c<r||a.dataLength?(a.push(l),a.dataLength>=r&&n(e,i,a.flush(),t)):n(e,i,l,t),s()})).catch((function(){return Promise.reject()}))}()},t}();function p(t,e){return new self.Request(t.url,e)}var g=function(t){var e,i;function r(e,i,r){var n;return(n=t.call(this,e)||this).code=void 0,n.details=void 0,n.code=i,n.details=r,n}return i=t,(e=r).prototype=Object.create(i.prototype),e.prototype.constructor=e,c(e,i),r}(a(Error));e.default=f},"./src/utils/imsc1-ttml-parser.ts":
|
|
|
/*!****************************************!*\
|
|
|
!*** ./src/utils/imsc1-ttml-parser.ts ***!
|
|
|
\****************************************/
|
|
|
/*! exports provided: IMSC1_CODEC, parseIMSC1 */function(t,e,i){"use strict";i.r(e),i.d(e,"IMSC1_CODEC",(function(){return h})),i.d(e,"parseIMSC1",(function(){return p}));var r=i(/*! ./mp4-tools */"./src/utils/mp4-tools.ts"),n=i(/*! ./vttparser */"./src/utils/vttparser.ts"),s=i(/*! ./vttcue */"./src/utils/vttcue.ts"),a=i(/*! ../demux/id3 */"./src/demux/id3.ts"),o=i(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),l=i(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts");function c(){return(c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t}).apply(this,arguments)}var h="stpp.ttml.im1t",u=/^(\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,i,n,h){var u=Object(r.findBox)(new Uint8Array(t),["mdat"]);if(0!==u.length){var d=u[0],p=Object(a.utf8ArrayToStr)(new Uint8Array(t,d.start,d.end-d.start)),S=Object(o.toTimescaleFromScale)(e,1,i);try{n(function(t,e){var i=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");var r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(r).reduce((function(t,e){return t[e]=i.getAttribute("ttp:"+e)||r[e],t}),{}),a="preserve"!==i.getAttribute("xml:space"),o=v(g(i,"styling","style")),h=v(g(i,"layout","region")),u=g(i,"body","[begin]");return[].map.call(u,(function(t){var i=function t(e,i){return[].slice.call(e.childNodes).reduce((function(e,r,n){var s;return"br"===r.nodeName&&n?e+"\n":null!==(s=r.childNodes)&&void 0!==s&&s.length?t(r,i):i?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent}),"")}(t,a);if(!i||!t.hasAttribute("begin"))return null;var r=b(t.getAttribute("begin"),n),u=b(t.getAttribute("dur"),n),d=b(t.getAttribute("end"),n);if(null===r)throw y(t);if(null===d){if(null===u)throw y(t);d=r+u}var p=new s.default(r-e,d-e,i);p.id=Object(l.generateCueId)(p.startTime,p.endTime,p.text);var g=h[t.getAttribute("region")],v=o[t.getAttribute("style")];p.position=10,p.size=80;var S=function(t,e){var i="http://www.w3.org/ns/ttml#styling";return["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((function(r,n){var s=m(e,i,n)||m(t,i,n);return s&&(r[n]=s),r}),{})}(g,v),E=S.textAlign;if(E){var C=f[E];C&&(p.lineAlign=C),p.align=E}return c(p,S),p})).filter((function(t){return null!==t}))}(p,S))}catch(t){h(t)}}else h(new Error("Could not parse IMSC1 mdat"))}function g(t,e,i){var r=t.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(i)):[]}function v(t){return t.reduce((function(t,e){var i=e.getAttribute("xml:id");return i&&(t[i]=e),t}),{})}function m(t,e,i){return t.hasAttributeNS(e,i)?t.getAttributeNS(e,i):null}function y(t){return new Error("Could not parse ttml timestamp "+t)}function b(t,e){if(!t)return null;var i=Object(n.parseTimeStamp)(t);return null===i&&(u.test(t)?i=function(t,e){var i=u.exec(t),r=(0|i[4])+(0|i[5])/e.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+r/e.frameRate}(t,e):d.test(t)&&(i=function(t,e){var i=d.exec(t),r=Number(i[1]);switch(i[2]){case"h":return 3600*r;case"m":return 60*r;case"ms":return 1e3*r;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}(t,e))),i}},"./src/utils/logger.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/utils/logger.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: enableLogs, logger */function(t,e,i){"use strict";i.r(e),i.d(e,"enableLogs",(function(){return o})),i.d(e,"logger",(function(){return l}));var r=function(){},n={trace:r,debug:r,log:r,warn:r,info:r,error:r},s=n;function a(t){var e=self.console[t];return e?e.bind(self.console,"["+t+"] >"):r}function o(t){if(self.console&&!0===t||"object"==typeof t){!function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];i.forEach((function(e){s[e]=t[e]?t[e].bind(t):a(e)}))}(t,"debug","log","info","warn","error");try{s.log()}catch(t){s=n}}else s=n}var l=n},"./src/utils/mediakeys-helper.ts":
|
|
|
/*!***************************************!*\
|
|
|
!*** ./src/utils/mediakeys-helper.ts ***!
|
|
|
\***************************************/
|
|
|
/*! exports provided: KeySystems, requestMediaKeySystemAccess */function(t,e,i){"use strict";var r;i.r(e),i.d(e,"KeySystems",(function(){return r})),i.d(e,"requestMediaKeySystemAccess",(function(){return n})),function(t){t.WIDEVINE="com.widevine.alpha",t.PLAYREADY="com.microsoft.playready"}(r||(r={}));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,i){"use strict";function r(){return self.MediaSource||self.WebKitMediaSource}i.r(e),i.d(e,"getMediaSource",(function(){return r}))},"./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,i){"use strict";i.r(e),i.d(e,"bin2str",(function(){return o})),i.d(e,"readUint16",(function(){return l})),i.d(e,"readUint32",(function(){return c})),i.d(e,"writeUint32",(function(){return h})),i.d(e,"findBox",(function(){return u})),i.d(e,"parseSegmentIndex",(function(){return d})),i.d(e,"parseInitSegment",(function(){return f})),i.d(e,"getStartDTS",(function(){return p})),i.d(e,"getDuration",(function(){return g})),i.d(e,"computeRawDurationFromSamples",(function(){return v})),i.d(e,"offsetStartDTS",(function(){return m})),i.d(e,"segmentValidRange",(function(){return y})),i.d(e,"appendUint8Array",(function(){return b}));var r=i(/*! ./typed-array */"./src/utils/typed-array.ts"),n=i(/*! ../loader/fragment */"./src/loader/fragment.ts"),s=Math.pow(2,32)-1,a=[].push;function o(t){return String.fromCharCode.apply(null,t)}function l(t,e){"data"in t&&(e+=t.start,t=t.data);var i=t[e]<<8|t[e+1];return i<0?65536+i:i}function c(t,e){"data"in t&&(e+=t.start,t=t.data);var i=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3];return i<0?4294967296+i:i}function h(t,e,i){"data"in t&&(e+=t.start,t=t.data),t[e]=i>>24,t[e+1]=i>>16&255,t[e+2]=i>>8&255,t[e+3]=255&i}function u(t,e){var i,r,n,s=[];if(!e.length)return s;"data"in t?(i=t.data,r=t.start,n=t.end):(r=0,n=(i=t).byteLength);for(var l=r;l<n;){var h=c(i,l),d=h>1?l+h:n;if(o(i.subarray(l+4,l+8))===e[0])if(1===e.length)s.push({data:i,start:l+8,end:d});else{var f=u({data:i,start:l+8,end:d},e.slice(1));f.length&&a.apply(s,f)}l=d}return s}function d(t){var e=u(t,["moov"])[0],i=e?e.end:null,r=u(t,["sidx"]);if(!r||!r[0])return null;var n=[],s=r[0],a=s.data[0],o=0===a?8:16,h=c(s,o);o+=4,o+=0===a?8:16,o+=2;var d=s.end+0,f=l(s,o);o+=2;for(var p=0;p<f;p++){var g=o,v=c(s,g);g+=4;var m=2147483647&v;if(1==(2147483648&v)>>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;var y=c(s,g);g+=4,n.push({referenceSize:m,subsegmentDuration:y,info:{duration:y/h,start:d,end:d+m-1}}),d+=m,o=g+=4}return{earliestPresentationTime:0,timescale:h,version:a,referencesCount:f,references:n,moovEndOffset:i}}function f(t){for(var e=[],i=u(t,["moov","trak"]),r=0;r<i.length;r++){var s=i[r],a=u(s,["tkhd"])[0];if(a){var l=a.data[a.start],h=0===l?12:20,d=c(a,h),f=u(s,["mdia","mdhd"])[0];if(f){var p=c(f,h=0===(l=f.data[f.start])?12:20),g=u(s,["mdia","hdlr"])[0];if(g){var v=o(g.data.subarray(g.start+8,g.start+12)),m={soun:n.ElementaryStreamTypes.AUDIO,vide:n.ElementaryStreamTypes.VIDEO}[v];if(m){var y=u(s,["mdia","minf","stbl","stsd"])[0],b=void 0;y&&(b=o(y.data.subarray(y.start+12,y.start+16))),e[d]={timescale:p,type:m},e[m]={timescale:p,id:d,codec:b}}}}}}return u(t,["moov","mvex","trex"]).forEach((function(t){var i=c(t,4),r=e[i];r&&(r.default={duration:c(t,12),flags:c(t,20)})})),e}function p(t,e){return u(e,["moof","traf"]).reduce((function(e,i){var r=u(i,["tfdt"])[0],n=r.data[r.start],s=u(i,["tfhd"]).reduce((function(e,i){var s=c(i,4),a=t[s];if(a){var o=c(r,4);1===n&&(o*=Math.pow(2,32),o+=c(r,8));var l=o/(a.timescale||9e4);if(isFinite(l)&&(null===e||l<e))return l}return e}),null);return null!==s&&isFinite(s)&&(null===e||s<e)?s:e}),null)||0}function g(t,e){for(var i=0,r=0,s=0,a=u(t,["moof","traf"]),o=0;o<a.length;o++){var l=a[o],h=u(l,["tfhd"])[0],f=e[c(h,4)];if(f){var p=f.default,g=c(h,0)|(null==p?void 0:p.flags),m=null==p?void 0:p.duration;8&g&&(m=c(h,2&g?12:8));for(var y=f.timescale||9e4,b=u(l,["trun"]),S=0;S<b.length;S++)i=m?m*c(b[S],4):v(b[S]),f.type===n.ElementaryStreamTypes.VIDEO?r+=i/y:f.type===n.ElementaryStreamTypes.AUDIO&&(s+=i/y)}}if(0===r&&0===s){var E=d(t);if(null!=E&&E.references)return E.references.reduce((function(t,e){return t+e.info.duration||0}),0)}return r||s}function v(t){var e=c(t,0),i=8;1&e&&(i+=4),4&e&&(i+=4);for(var r=0,n=c(t,4),s=0;s<n;s++)256&e&&(r+=c(t,i),i+=4),512&e&&(i+=4),1024&e&&(i+=4),2048&e&&(i+=4);return r}function m(t,e,i){u(e,["moof","traf"]).forEach((function(e){u(e,["tfhd"]).forEach((function(r){var n=c(r,4),a=t[n];if(a){var o=a.timescale||9e4;u(e,["tfdt"]).forEach((function(t){var e=t.data[t.start],r=c(t,4);if(0===e)h(t,4,r-i*o);else{r*=Math.pow(2,32),r+=c(t,8),r-=i*o,r=Math.max(r,0);var n=Math.floor(r/(s+1)),a=Math.floor(r%(s+1));h(t,4,n),h(t,8,a)}}))}}))}))}function y(t){var e={valid:null,remainder:null},i=u(t,["moof"]);if(!i)return e;if(i.length<2)return e.remainder=t,e;var n=i[i.length-1];return e.valid=Object(r.sliceUint8)(t,0,n.start-8),e.remainder=Object(r.sliceUint8)(t,n.start-8),e}function b(t,e){var i=new Uint8Array(t.length+e.length);return i.set(t),i.set(e,t.length),i}},"./src/utils/output-filter.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/utils/output-filter.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return r}));var r=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,i){(null===this.startTime||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=i,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,i){"use strict";i.r(e),i.d(e,"sendAddTrackEvent",(function(){return n})),i.d(e,"addCueToTrack",(function(){return s})),i.d(e,"clearCurrentCues",(function(){return a})),i.d(e,"removeCuesInRange",(function(){return o})),i.d(e,"getCuesInRange",(function(){return l}));var r=i(/*! ./logger */"./src/utils/logger.ts");function n(t,e){var i;try{i=new Event("addtrack")}catch(t){(i=document.createEvent("Event")).initEvent("addtrack",!1,!1)}i.track=t,e.dispatchEvent(i)}function s(t,e){var i=t.mode;if("disabled"===i&&(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(i){r.logger.debug("[texttrack-utils]: "+i);var n=new self.TextTrackCue(e.startTime,e.endTime,e.text);n.id=e.id,t.addCue(n)}"disabled"===i&&(t.mode=i)}function a(t){var e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(var i=t.cues.length;i--;)t.removeCue(t.cues[i]);"disabled"===e&&(t.mode=e)}function o(t,e,i){var r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&t.cues.length>0)for(var n=l(t.cues,e,i),s=0;s<n.length;s++)t.removeCue(n[s]);"disabled"===r&&(t.mode=r)}function l(t,e,i){var r=[],n=function(t,e){if(e<t[0].startTime)return 0;var i=t.length-1;if(e>t[i].endTime)return-1;for(var r=0,n=i;r<=n;){var s=Math.floor((n+r)/2);if(e<t[s].startTime)n=s-1;else{if(!(e>t[s].startTime&&r<i))return s;r=s+1}}return t[r].startTime-e<e-t[n].startTime?r:n}(t,e);if(n>-1)for(var s=n,a=t.length;s<a;s++){var o=t[s];if(o.startTime>=e&&o.endTime<=i)r.push(o);else if(o.startTime>i)return r}return r}},"./src/utils/time-ranges.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/utils/time-ranges.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),e.default={toString:function(t){for(var e="",i=t.length,r=0;r<i;r++)e+="["+t.start(r).toFixed(3)+","+t.end(r).toFixed(3)+"]";return e}}},"./src/utils/timescale-conversion.ts":
|
|
|
/*!*******************************************!*\
|
|
|
!*** ./src/utils/timescale-conversion.ts ***!
|
|
|
\*******************************************/
|
|
|
/*! exports provided: toTimescaleFromBase, toTimescaleFromScale, toMsFromMpegTsClock, toMpegTsClockFromTimescale */function(t,e,i){"use strict";function r(t,e,i,r){void 0===i&&(i=1),void 0===r&&(r=!1);var n=t*e*i;return r?Math.round(n):n}function n(t,e,i,n){return void 0===i&&(i=1),void 0===n&&(n=!1),r(t,e,1/i,n)}function s(t,e){return void 0===e&&(e=!1),r(t,1e3,1/9e4,e)}function a(t,e){return void 0===e&&(e=1),r(t,9e4,1/e)}i.r(e),i.d(e,"toTimescaleFromBase",(function(){return r})),i.d(e,"toTimescaleFromScale",(function(){return n})),i.d(e,"toMsFromMpegTsClock",(function(){return s})),i.d(e,"toMpegTsClockFromTimescale",(function(){return a}))},"./src/utils/typed-array.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/utils/typed-array.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: sliceUint8 */function(t,e,i){"use strict";function r(t,e,i){return Uint8Array.prototype.slice?t.slice(e,i):new Uint8Array(Array.prototype.slice.call(t,e,i))}i.r(e),i.d(e,"sliceUint8",(function(){return r}))},"./src/utils/vttcue.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/utils/vttcue.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.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 i(t,e){if("string"!=typeof e)return!1;if(!Array.isArray(t))return!1;var i=e.toLowerCase();return!!~t.indexOf(i)&&i}function r(t){return i(e,t)}function n(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];for(var n=1;n<arguments.length;n++){var s=arguments[n];for(var a in s)t[a]=s[a]}return t}function s(e,s,a){var o=this,l={enumerable:!0};o.hasBeenReset=!1;var c="",h=!1,u=e,d=s,f=a,p=null,g="",v=!0,m="auto",y="start",b=50,S="middle",E=50,C="middle";Object.defineProperty(o,"id",n({},l,{get:function(){return c},set:function(t){c=""+t}})),Object.defineProperty(o,"pauseOnExit",n({},l,{get:function(){return h},set:function(t){h=!!t}})),Object.defineProperty(o,"startTime",n({},l,{get:function(){return u},set:function(t){if("number"!=typeof t)throw new TypeError("Start time must be set to a number.");u=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"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(o,"text",n({},l,{get:function(){return f},set:function(t){f=""+t,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",n({},l,{get:function(){return p},set:function(t){p=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",n({},l,{get:function(){return g},set:function(e){var r=function(e){return i(t,e)}(e);if(!1===r)throw new SyntaxError("An invalid or illegal string was specified.");g=r,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",n({},l,{get:function(){return v},set:function(t){v=!!t,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",n({},l,{get:function(){return m},set:function(t){if("number"!=typeof t&&"auto"!==t)throw new SyntaxError("An invalid number or illegal string was specified.");m=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",n({},l,{get:function(){return y},set:function(t){var e=r(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");y=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"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(o,"positionAlign",n({},l,{get:function(){return S},set:function(t){var e=r(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");S=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",n({},l,{get:function(){return E},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",n({},l,{get:function(){return C},set:function(t){var e=r(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");C=e,this.hasBeenReset=!0}})),o.displayState=void 0}return s.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},s}()},"./src/utils/vttparser.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/utils/vttparser.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: parseTimeStamp, fixLineBreaks, VTTParser */function(t,e,i){"use strict";i.r(e),i.d(e,"parseTimeStamp",(function(){return s})),i.d(e,"fixLineBreaks",(function(){return u})),i.d(e,"VTTParser",(function(){return d}));var r=i(/*! ./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 s(t){function e(t,e,i,r){return 3600*(0|t)+60*(0|e)+(0|i)+parseFloat(r||0)}var i=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return i?parseFloat(i[2])>59?e(i[2],i[3],0,i[4]):e(i[1],i[2],i[3],i[4]):null}var a=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,i){return i?this.has(t)?this.values[t]:e[i]:this.has(t)?this.values[t]:e},e.has=function(t){return t in this.values},e.alt=function(t,e,i){for(var r=0;r<i.length;++r)if(e===i[r]){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 i=parseFloat(e);if(i>=0&&i<=100)return this.set(t,i),!0}return!1},t}();function o(t,e,i,r){var n=r?t.split(r):[t];for(var s in n)if("string"==typeof n[s]){var a=n[s].split(i);2===a.length&&e(a[0],a[1])}}var l=new r.default(0,0,""),c="middle"===l.align?"middle":"center";function h(t,e,i){var r=t;function n(){var e=s(t);if(null===e)throw new Error("Malformed timestamp: "+r);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function h(){t=t.replace(/^\s+/,"")}if(h(),e.startTime=n(),h(),"--\x3e"!==t.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+r);t=t.substr(3),h(),e.endTime=n(),h(),function(t,e){var r=new a;o(t,(function(t,e){var n;switch(t){case"region":for(var s=i.length-1;s>=0;s--)if(i[s].id===e){r.set(t,i[s].region);break}break;case"vertical":r.alt(t,e,["rl","lr"]);break;case"line":n=e.split(","),r.integer(t,n[0]),r.percent(t,n[0])&&r.set("snapToLines",!1),r.alt(t,n[0],["auto"]),2===n.length&&r.alt("lineAlign",n[1],["start",c,"end"]);break;case"position":n=e.split(","),r.percent(t,n[0]),2===n.length&&r.alt("positionAlign",n[1],["start",c,"end","line-left","line-right","auto"]);break;case"size":r.percent(t,e);break;case"align":r.alt(t,e,["start",c,"end","left","right"])}}),/:/,/\s/),e.region=r.get("region",null),e.vertical=r.get("vertical","");var n=r.get("line","auto");"auto"===n&&-1===l.line&&(n=-1),e.line=n,e.lineAlign=r.get("lineAlign","start"),e.snapToLines=r.get("snapToLines",!0),e.size=r.get("size",100),e.align=r.get("align",c);var s=r.get("position","auto");"auto"===s&&50===l.position&&(s="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=s}(t,e)}function u(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 i(){var t=e.buffer,i=0;for(t=u(t);i<t.length&&"\r"!==t[i]&&"\n"!==t[i];)++i;var r=t.substr(0,i);return"\r"===t[i]&&++i,"\n"===t[i]&&++i,e.buffer=t.substr(i),r}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 s=(n=i()).match(/^()?WEBVTT([ \t].*)?$/);if(!s||!s[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var a=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(a?a=!1:n=i(),e.state){case"HEADER":/:/.test(n)?o(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 r.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{h(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&&(a=!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,i){"use strict";i.r(e),i.d(e,"generateCueId",(function(){return u})),i.d(e,"parseWebVTT",(function(){return d}));var r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=i(/*! ./vttparser */"./src/utils/vttparser.ts"),s=i(/*! ../demux/id3 */"./src/demux/id3.ts"),a=i(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),o=i(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),l=/\r\n|\n\r|\n|\r/g,c=function(t,e,i){return void 0===i&&(i=0),t.substr(i,e.length)===e},h=function(t){for(var e=5381,i=t.length;i;)e=33*e^t.charCodeAt(--i);return(e>>>0).toString()};function u(t,e,i){return h(t.toString())+h(e.toString())+h(i)}function d(t,e,i,h,d,f,p,g){var v,m=new n.VTTParser,y=Object(s.utf8ArrayToStr)(new Uint8Array(t)).trim().replace(l,"\n").split("\n"),b=[],S=Object(a.toMpegTsClockFromTimescale)(e,i),E="00:00.000",C=0,k=0,T=!0,w=!1;m.oncue=function(t){var e=h[d],i=h.ccOffset,r=(C-S)/9e4;if(null!=e&&e.new&&(void 0!==k?i=h.ccOffset=e.start:function(t,e,i){var r=t[e],n=t[r.prevCC];if(!n||!n.new&&r.new)return t.ccOffset=t.presentationOffset=r.start,void(r.new=!1);for(;null!==(s=n)&&void 0!==s&&s.new;){var s;t.ccOffset+=r.start-n.start,r.new=!1,n=t[(r=n).prevCC]}t.presentationOffset=i}(h,d,r)),r&&(i=r-h.presentationOffset),w){var n=t.endTime-t.startTime,s=Object(o.normalizePts)(9e4*(t.startTime+i-k),9e4*f)/9e4;t.startTime=s,t.endTime=s+n}var a=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(a)),t.id||(t.id=u(t.startTime,t.endTime,a)),t.endTime>0&&b.push(t)},m.onparsingerror=function(t){v=t},m.onflush=function(){v?g(v):p(b)},y.forEach((function(t){if(T){if(c(t,"X-TIMESTAMP-MAP=")){T=!1,w=!0,t.substr(16).split(",").forEach((function(t){c(t,"LOCAL:")?E=t.substr(6):c(t,"MPEGTS:")&&(C=parseInt(t.substr(7)))}));try{k=function(t){var e=parseInt(t.substr(-3)),i=parseInt(t.substr(-6,2)),n=parseInt(t.substr(-9,2)),s=t.length>9?parseInt(t.substr(0,t.indexOf(":"))):0;if(!(Object(r.isFiniteNumber)(e)&&Object(r.isFiniteNumber)(i)&&Object(r.isFiniteNumber)(n)&&Object(r.isFiniteNumber)(s)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+t);return e+=1e3*i,e+=6e4*n,e+=36e5*s}(E)/1e3}catch(t){w=!1,v=t}return}""===t&&(T=!1)}m.parse(t+"\n")})),m.flush()}},"./src/utils/xhr-loader.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/utils/xhr-loader.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var r=i(/*! ../utils/logger */"./src/utils/logger.ts"),n=i(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=/^age:\s*[\d.]+\s*$/m,a=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,i){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=i,this.retryDelay=e.retryDelay,this.loadInternal()},e.loadInternal=function(){var t=this.config,e=this.context;if(t){var i=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0;var n=this.xhrSetup;try{if(n)try{n(i,e.url)}catch(t){i.open("GET",e.url,!0),n(i,e.url)}i.readyState||i.open("GET",e.url,!0);var s=this.context.headers;if(s)for(var a in s)i.setRequestHeader(a,s[a])}catch(t){return void this.callbacks.onError({code:i.status,text:t.message},e,i)}e.rangeEnd&&i.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),i.onreadystatechange=this.readystatechange.bind(this),i.onprogress=this.loadprogress.bind(this),i.responseType=e.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),i.send()}},e.readystatechange=function(){var t=this.context,e=this.loader,i=this.stats;if(t&&e){var n=e.readyState,s=this.config;if(!i.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start)),4===n){e.onreadystatechange=null,e.onprogress=null;var a=e.status;if(a>=200&&a<300){var o,l;if(i.loading.end=Math.max(self.performance.now(),i.loading.first),l="arraybuffer"===t.responseType?(o=e.response).byteLength:(o=e.responseText).length,i.loaded=i.total=l,!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(i,t,o,e),!this.callbacks)return;var h={url:e.responseURL,data:o};this.callbacks.onSuccess(h,i,t,e)}else i.retry>=s.maxRetry||a>=400&&a<499?(r.logger.error(a+" while loading "+t.url),this.callbacks.onError({code:a,text:e.statusText},t,e)):(r.logger.warn(a+" 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,s.maxRetryDelay),i.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout)}},e.loadtimeout=function(){r.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&&s.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},t}();e.default=a}}).default},t.exports=r())},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,i){t.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]); |