You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
330 lines
697 KiB
330 lines
697 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[196,5,7],{"55Ip":function(nt,We,J){"use strict";J.d(We,"a",function(){return s}),J.d(We,"b",function(){return c});var fe=J("Ty5D"),U=J("dI71"),C=J("q1tI"),B=J.n(C),O=J("YS25"),L=J("17x9"),_=J.n(L),M=J("wx14"),A=J("zLVn"),w=J("9R94"),g=function(r){Object(U.a)(t,r);function t(){for(var m,v=arguments.length,T=new Array(v),k=0;k<v;k++)T[k]=arguments[k];return m=r.call.apply(r,[this].concat(T))||this,m.history=Object(O.a)(m.props),m}var a=t.prototype;return a.render=function(){return B.a.createElement(fe.c,{history:this.history,children:this.props.children})},t}(B.a.Component),x=function(r){Object(U.a)(t,r);function t(){for(var m,v=arguments.length,T=new Array(v),k=0;k<v;k++)T[k]=arguments[k];return m=r.call.apply(r,[this].concat(T))||this,m.history=Object(O.b)(m.props),m}var a=t.prototype;return a.render=function(){return B.a.createElement(fe.c,{history:this.history,children:this.props.children})},t}(B.a.Component),S=function(t,a){return typeof t=="function"?t(a):t},E=function(t,a){return typeof t=="string"?Object(O.c)(t,null,null,a):t},b=function(t){return t},y=B.a.forwardRef;typeof y=="undefined"&&(y=b);function h(r){return!!(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}var e=y(function(r,t){var a=r.innerRef,m=r.navigate,v=r.onClick,T=Object(A.a)(r,["innerRef","navigate","onClick"]),k=T.target,I=Object(M.a)({},T,{onClick:function(K){try{v&&v(K)}catch(V){throw K.preventDefault(),V}!K.defaultPrevented&&K.button===0&&(!k||k==="_self")&&!h(K)&&(K.preventDefault(),m())}});return b!==y?I.ref=t||a:I.ref=a,B.a.createElement("a",I)}),s=y(function(r,t){var a=r.component,m=a===void 0?e:a,v=r.replace,T=r.to,k=r.innerRef,I=Object(A.a)(r,["component","replace","to","innerRef"]);return B.a.createElement(fe.e.Consumer,null,function(F){F||Object(w.a)(!1);var K=F.history,V=E(S(T,F.location),F.location),Q=V?K.createHref(V):"",Z=Object(M.a)({},I,{href:Q,navigate:function(){var ge=S(T,F.location),se=v?K.replace:K.push;se(ge)}});return b!==y?Z.ref=t||k:Z.innerRef=k,B.a.createElement(m,Z)})});if(!1)var o,f;var u=function(t){return t},l=B.a.forwardRef;typeof l=="undefined"&&(l=u);function p(){for(var r=arguments.length,t=new Array(r),a=0;a<r;a++)t[a]=arguments[a];return t.filter(function(m){return m}).join(" ")}var c=l(function(r,t){var a=r["aria-current"],m=a===void 0?"page":a,v=r.activeClassName,T=v===void 0?"active":v,k=r.activeStyle,I=r.className,F=r.exact,K=r.isActive,V=r.location,Q=r.sensitive,Z=r.strict,ie=r.style,ge=r.to,se=r.innerRef,he=Object(A.a)(r,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return B.a.createElement(fe.e.Consumer,null,function(de){de||Object(w.a)(!1);var $=V||de.location,Y=E(S(ge,$),$),ne=Y.pathname,z=ne&&ne.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),H=z?Object(fe.f)($.pathname,{path:z,exact:F,sensitive:Q,strict:Z}):null,me=!!(K?K(H,$):H),Le=me?p(I,T):I,Oe=me?Object(M.a)({},ie,{},k):ie,we=Object(M.a)({"aria-current":me&&m||null,className:Le,style:Oe,to:Y},he);return u!==l?we.ref=t||se:we.innerRef=se,B.a.createElement(s,we)})});if(!1)var i},"815F":function(nt,We,J){"use strict";J.d(We,"e",function(){return _}),J.d(We,"c",function(){return A}),J.d(We,"d",function(){return w}),J.d(We,"a",function(){return x}),J.d(We,"f",function(){return S}),J.d(We,"b",function(){return E});var fe=J("KQm4"),U=J("VTBJ"),C=J("Ff2n"),B=J("Zm9Q"),O=J("Kwbf"),L=J("OZM5");function _(b,y){return b!=null?b:y}function M(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],y=new Map;function h(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";(e||[]).forEach(function(o){var f=o.key,u=o.children;Object(O.a)(f!=null,"Tree node must have a certain key: [".concat(s).concat(f,"]"));var l=String(f);Object(O.a)(!y.has(l)||f===null||f===void 0,"Same 'key' exist in the Tree: ".concat(l)),y.set(l,!0),h(u,"".concat(s).concat(l," > "))})}h(b)}function A(b){function y(h){var e=Object(B.a)(h);return e.map(function(s){if(!Object(L.i)(s))return Object(O.a)(!s,"Tree/TreeNode can only accept TreeNode as children."),null;var o=s.key,f=s.props,u=f.children,l=Object(C.a)(f,["children"]),p=Object(U.a)({key:o},l),c=y(u);return c.length&&(p.children=c),p}).filter(function(s){return s})}return y(b)}function w(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],h=new Set(y===!0?[]:y),e=[];function s(o){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;return o.map(function(u,l){var p=Object(L.h)(f?f.pos:"0",l),c=_(u.key,p),i=Object(U.a)(Object(U.a)({},u),{},{parent:f,pos:p,children:null,data:u,isStart:[].concat(Object(fe.a)(f?f.isStart:[]),[l===0]),isEnd:[].concat(Object(fe.a)(f?f.isEnd:[]),[l===o.length-1])});return e.push(i),y===!0||h.has(c)?i.children=s(u.children||[],i):i.children=[],i})}return s(b),e}function g(b,y,h){var e;h?typeof h=="string"?e=function(f){return f[h]}:typeof h=="function"&&(e=function(f){return h(f)}):e=function(f,u){return _(f.key,u)};function s(o,f,u){var l=o?o.children:b,p=o?Object(L.h)(u.pos,f):"0";if(o){var c=e(o,p),i={node:o,index:f,pos:p,key:c,parentPos:u.node?u.pos:null,level:u.level+1};y(i)}l&&l.forEach(function(r,t){s(r,t,{node:o,pos:p,level:u?u.level+1:-1})})}s(null)}function x(b){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},h=y.initWrapper,e=y.processEntity,s=y.onProcessFinished,o=arguments.length>2?arguments[2]:void 0,f={},u={},l={posEntities:f,keyEntities:u};return h&&(l=h(l)||l),g(b,function(p){var c=p.node,i=p.index,r=p.pos,t=p.key,a=p.parentPos,m=p.level,v={node:c,index:i,key:t,pos:r,level:m},T=_(t,r);f[r]=v,u[T]=v,v.parent=f[a],v.parent&&(v.parent.children=v.parent.children||[],v.parent.children.push(v)),e&&e(v,l)},o),s&&s(l),l}function S(b,y){var h=y.expandedKeys,e=y.selectedKeys,s=y.loadedKeys,o=y.loadingKeys,f=y.checkedKeys,u=y.halfCheckedKeys,l=y.dragOverNodeKey,p=y.dropPosition,c=y.keyEntities,i=c[b],r={eventKey:b,expanded:h.indexOf(b)!==-1,selected:e.indexOf(b)!==-1,loaded:s.indexOf(b)!==-1,loading:o.indexOf(b)!==-1,checked:f.indexOf(b)!==-1,halfChecked:u.indexOf(b)!==-1,pos:String(i?i.pos:""),dragOver:l===b&&p===0,dragOverGapTop:l===b&&p===-1,dragOverGapBottom:l===b&&p===1};return r}function E(b){var y=b.data,h=b.expanded,e=b.selected,s=b.checked,o=b.loaded,f=b.loading,u=b.halfChecked,l=b.dragOver,p=b.dragOverGapTop,c=b.dragOverGapBottom,i=b.pos,r=b.active,t=Object(U.a)(Object(U.a)({},y),{},{expanded:h,selected:e,checked:s,loaded:o,loading:f,halfChecked:u,dragOver:l,dragOverGapTop:p,dragOverGapBottom:c,pos:i,active:r});return"props"in t||Object.defineProperty(t,"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`."),b}}),t}},"8Jsi":function(nt,We,J){"use strict";J.d(We,"d",function(){return a}),J.d(We,"a",function(){return Oe}),J.d(We,"b",function(){return De}),J.d(We,"c",function(){return we});var fe=J("1OyB"),U=J("vuIU"),C=J("Ji7U"),B=J("LK+K"),O=J("KQm4"),L=J("U8pU"),_=J("ODXe"),M=J("VTBJ"),A=J("q1tI"),w=J("qNPg"),g=J("2Qr1"),x=J("815F"),S=J("NvD2"),E=J("wPlo"),b=J("6cGi"),y=J("Kwbf"),h=J("4IlW"),e=J("YrtM"),s=J("fAei"),o=A.createContext(null);function f(ae,ue){if(!ae)return!0;var be=ae.data,xe=be.disabled,Ce=be.disableCheckbox;switch(ue){case"select":return xe;case"checkbox":return xe||Ce}return!1}function u(ae,ue){var be=A.useCallback(function(Ce){var Se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"select",ye=arguments.length>2?arguments[2]:void 0,Ne=ae.get(Ce);return!ye&&f(Ne,Se)?null:Ne},[ae]),xe=A.useCallback(function(Ce){var Se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"select",ye=arguments.length>2?arguments[2]:void 0,Ne=ue.get(Ce);return!ye&&f(Ne,Se)?null:Ne},[ue]);return[be,xe]}function l(ae){return A.useMemo(function(){var ue=new Map,be=new Map;return ae.forEach(function(xe){ue.set(xe.key,xe),be.set(xe.data.value,xe)}),[ue,be]},[ae])}var p={width:0,height:0,display:"flex",overflow:"hidden",opacity:0,border:0,padding:0,margin:0},c=function(ue,be){var xe=ue.prefixCls,Ce=ue.height,Se=ue.itemHeight,ye=ue.virtual,Ne=ue.options,Be=ue.flattenOptions,ve=ue.multiple,_e=ue.searchValue,re=ue.onSelect,q=ue.onToggleOpen,te=ue.open,j=ue.notFoundContent,W=ue.onMouseEnter,G=A.useContext(o),X=G.checkable,oe=G.checkedKeys,ce=G.halfCheckedKeys,Pe=G.treeExpandedKeys,He=G.treeDefaultExpandAll,$e=G.treeDefaultExpandedKeys,ze=G.onTreeExpand,Ze=G.treeIcon,et=G.showTreeIcon,Xe=G.switcherIcon,mt=G.treeLine,rt=G.treeNodeFilterProp,vt=G.loadData,ct=G.treeLoadedKeys,qe=G.treeMotion,yt=G.onTreeLoad,bt=A.useRef(),Ve=Object(e.a)(function(){return Ne},[te,Ne],function(je,Ae){return Ae[0]&&je[1]!==Ae[1]}),wt=l(Be),at=Object(_.a)(wt,2),ut=at[0],At=at[1],St=u(ut,At),Rt=Object(_.a)(St,2),it=Rt[0],Qe=Rt[1],Ye=A.useMemo(function(){return oe.map(function(je){var Ae=Qe(je);return Ae?Ae.key:null})},[oe]),ot=A.useMemo(function(){return X?{checked:Ye,halfChecked:ce}:null},[Ye,ce,X]);A.useEffect(function(){if(te&&!ve&&Ye.length){var je;(je=bt.current)===null||je===void 0||je.scrollTo({key:Ye[0]})}},[te]);var dt=String(_e).toLowerCase(),tt=function(Ae){return dt?String(Ae[rt]).toLowerCase().includes(dt):!1},st=A.useState($e),ft=Object(_.a)(st,2),Ot=ft[0],Ft=ft[1],_t=A.useState(null),Wt=Object(_.a)(_t,2),jt=Wt[0],Vt=Wt[1],Ht=A.useMemo(function(){return Pe?Object(O.a)(Pe):_e?jt:Ot},[Ot,jt,dt,Pe]);A.useEffect(function(){_e&&Vt(Be.map(function(je){return je.key}))},[_e]);var P=function(Ae){Ft(Ae),Vt(Ae),ze&&ze(Ae)},n=function(Ae){Ae.preventDefault()},d=function(Ae,Ge){var Ke=Ge.node.key,Je=it(Ke,X?"checkbox":"select");Je!==null&&re(Je.data.value,{selected:!oe.includes(Je.data.value)}),ve||q(!1)},D=A.useState(null),N=Object(_.a)(D,2),R=N[0],ee=N[1],Re=it(R);if(A.useImperativeHandle(be,function(){return{onKeyDown:function(Ae){var Ge,Ke=Ae.which;switch(Ke){case h.a.UP:case h.a.DOWN:case h.a.LEFT:case h.a.RIGHT:(Ge=bt.current)===null||Ge===void 0||Ge.onKeyDown(Ae);break;case h.a.ENTER:{Re!==null&&d(null,{node:{key:R},selected:!oe.includes(Re.data.value)});break}case h.a.ESC:q(!1)}},onKeyUp:function(){}}}),Ve.length===0)return A.createElement("div",{role:"listbox",className:"".concat(xe,"-empty"),onMouseDown:n},j);var Ue={};return ct&&(Ue.loadedKeys=ct),Ht&&(Ue.expandedKeys=Ht),A.createElement("div",{onMouseDown:n,onMouseEnter:W},Re&&te&&A.createElement("span",{style:p,"aria-live":"assertive"},Re.data.value),A.createElement(s.b,Object.assign({ref:bt,focusable:!1,prefixCls:"".concat(xe,"-tree"),treeData:Ve,height:Ce,itemHeight:Se,virtual:ye,multiple:ve,icon:Ze,showIcon:et,switcherIcon:Xe,showLine:mt,loadData:_e?null:vt,motion:qe,checkable:X,checkStrictly:!0,checkedKeys:ot,selectedKeys:X?[]:Ye,defaultExpandAll:He},Ue,{onActiveChange:ee,onSelect:d,onCheck:d,onExpand:P,onLoad:yt,filterTreeNode:tt})))},i=A.forwardRef(c);i.displayName="OptionList";var r=i,t=function(){return null},a=t,m=J("Ff2n"),v=J("Zm9Q");function T(ae){return Object(v.a)(ae).map(function(ue){if(!A.isValidElement(ue)||!ue.type)return null;var be=ue.key,xe=ue.props,Ce=xe.children,Se=xe.value,ye=Object(m.a)(xe,["children","value"]),Ne=Object(M.a)({key:be,value:Se},ye),Be=T(Ce);return Be.length&&(Ne.children=Be),Ne}).filter(function(ue){return ue})}function k(ae){if(!ae)return ae;var ue=Object(M.a)({},ae);return"props"in ue||Object.defineProperty(ue,"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."),ue}}),ue}function I(ae,ue,be,xe,Ce){var Se=null,ye=null;function Ne(){function Be(ve){var _e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"0",re=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return ve.map(function(q,te){var j="".concat(_e,"-").concat(te),W=be.includes(q.value),G=Be(q.children||[],j,W),X=A.createElement(a,Object.assign({},q),G.map(function(ce){return ce.node}));if(ue===q.value&&(Se=X),W){var oe={pos:j,node:X,children:G};return re||ye.push(oe),oe}return null}).filter(function(q){return q})}ye||(ye=[],Be(xe),ye.sort(function(ve,_e){var re=ve.node.props.value,q=_e.node.props.value,te=be.indexOf(re),j=be.indexOf(q);return te-j}))}Object.defineProperty(ae,"triggerNode",{get:function(){return Object(y.a)(!1,"`triggerNode` is deprecated. Please consider decoupling data with node."),Ne(),Se}}),Object.defineProperty(ae,"allCheckedNodes",{get:function(){return Object(y.a)(!1,"`allCheckedNodes` is deprecated. Please consider decoupling data with node."),Ne(),Ce?ye:ye.map(function(ve){var _e=ve.node;return _e})}})}function F(ae){return Array.isArray(ae)?ae:ae!==void 0?[ae]:[]}function K(ae,ue){var be=new Map;return ue.forEach(function(xe){var Ce=xe.data;be.set(Ce.value,Ce)}),ae.map(function(xe){return k(be.get(xe))})}function V(ae,ue){var be=K([ae],ue)[0];return be?be.disabled:!1}function Q(ae){return ae.disabled||ae.disableCheckbox||ae.checkable===!1}function Z(ae){for(var ue=ae.parent,be=0,xe=ue;xe;)xe=xe.parent,be+=1;return be}function ie(ae){function ue(xe){return(xe||[]).map(function(Ce){var Se=Ce.value,ye=Ce.key,Ne=Ce.children,Be=Object(M.a)(Object(M.a)({},Ce),{},{key:"key"in Ce?ye:Se});return Ne&&(Be.children=ue(Ne)),Be})}var be=Object(x.d)(ue(ae),!0);return be.map(function(xe){return{key:xe.data.key,data:xe.data,level:Z(xe)}})}function ge(ae){return function(ue,be){var xe=be[ae];return String(xe).toLowerCase().includes(String(ue).toLowerCase())}}function se(ae,ue,be){var xe=be.optionFilterProp,Ce=be.filterOption;if(Ce===!1)return ue;var Se;typeof Ce=="function"?Se=Ce:Se=ge(xe);function ye(Ne){var Be=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Ne.map(function(ve){var _e=ve.children,re=Be||Se(ae,k(ve)),q=ye(_e||[],re);return re||q.length?Object(M.a)(Object(M.a)({},ve),{},{children:q}):null}).filter(function(ve){return ve})}return ye(ue)}function he(ae,ue,be,xe){var Ce=new Map;return F(ue).forEach(function(Se){Se&&Object(L.a)(Se)==="object"&&"value"in Se&&Ce.set(Se.value,Se)}),ae.map(function(Se){var ye={value:Se},Ne=be(Se,"select",!0),Be=Ne?xe(Ne.data):Se;if(Ce.has(Se)){var ve=Ce.get(Se);ye.label="label"in ve?ve.label:Be,"halfChecked"in ve&&(ye.halfChecked=ve.halfChecked)}else ye.label=Be;return ye})}function de(ae,ue){var be=new Set(ae);return be.add(ue),Array.from(be)}function $(ae,ue){var be=new Set(ae);return be.delete(ue),Array.from(be)}function Y(ae){var ue=ae.searchPlaceholder,be=ae.treeCheckStrictly,xe=ae.treeCheckable,Ce=ae.labelInValue,Se=ae.value,ye=ae.multiple;Object(y.a)(!ue,"`searchPlaceholder` has been removed."),be&&Ce===!1&&Object(y.a)(!1,"`treeCheckStrictly` will force set `labelInValue` to `true`."),(Ce||be)&&Object(y.a)(F(Se).every(function(Ne){return Ne&&Object(L.a)(Ne)==="object"&&"value"in Ne}),"Invalid prop `value` supplied to `TreeSelect`. You should use { label: string, value: string | number } or [{ label: string, value: string | number }] instead."),be||ye||xe?Object(y.a)(!Se||Array.isArray(Se),"`value` should be an array when `TreeSelect` is checkable or multiple."):Object(y.a)(!Array.isArray(Se),"`value` should not be array when `TreeSelect` is single mode.")}var ne=Y,z=10;function H(ae,ue){var be=ue.id,xe=ue.pId,Ce=ue.rootPId,Se={},ye=[],Ne=ae.map(function(Be){var ve=Object(M.a)({},Be),_e=ve[be];return Se[_e]=ve,ve.key=ve.key||_e,ve});return Ne.forEach(function(Be){var ve=Be[xe],_e=Se[ve];_e&&(_e.children=_e.children||[],_e.children.push(Be)),(ve===Ce||!_e&&Ce===null)&&ye.push(Be)}),ye}function me(ae,ue){var be=0,xe=new Set;function Ce(Se){return(Se||[]).map(function(ye){var Ne=ye.key,Be=ye.value,ve=ye.children,_e=Object(m.a)(ye,["key","value","children"]),re="value"in ye?Be:Ne,q=Object(M.a)(Object(M.a)({},_e),{},{key:Ne!=null?Ne:re,value:re,title:ue(ye)});return"children"in ye&&(q.children=Ce(ve)),q})}return Ce(ae)}function Le(ae,ue,be){var xe=be.getLabelProp,Ce=be.simpleMode,Se=A.useRef({});return ae?(Se.current.formatTreeData=Se.current.treeData===ae?Se.current.formatTreeData:me(Ce?H(ae,Object(M.a)({id:"id",pId:"pId",rootPId:null},Ce!==!0?Ce:{})):ae,xe),Se.current.treeData=ae):Se.current.formatTreeData=Se.current.children===ue?Se.current.formatTreeData:me(T(ue),xe),Se.current.formatTreeData}var Oe="SHOW_ALL",we="SHOW_PARENT",De="SHOW_CHILD";function le(ae,ue,be){var xe=new Set(ae);return ue===De?ae.filter(function(Ce){var Se=be[Ce];return!(Se&&Se.children&&Se.children.every(function(ye){var Ne=ye.node;return Q(Ne)||xe.has(Ne.key)}))}):ue===we?ae.filter(function(Ce){var Se=be[Ce],ye=Se?Se.parent:null;return!(ye&&!Q(ye.node)&&xe.has(ye.node.key))}):ae}function pe(ae,ue){var be=ue.value,xe=ue.getEntityByValue,Ce=ue.getEntityByKey,Se=ue.treeConduction,ye=ue.showCheckedStrategy,Ne=ue.conductKeyEntities,Be=ue.getLabelProp;return A.useMemo(function(){var ve=ae;if(Se){var _e=le(ae.map(function(re){var q=xe(re);return q?q.key:re}),ye,Ne);ve=_e.map(function(re){var q=Ce(re);return q?q.data.value:re})}return he(ve,be,xe,Be)},[ae,be,Se,ye,xe])}var Ee=["expandedKeys","treeData","treeCheckable","showCheckedStrategy","searchPlaceholder","treeLine","treeIcon","showTreeIcon","switcherIcon","treeNodeFilterProp","filterTreeNode","dropdownPopupAlign","treeDefaultExpandAll","treeCheckStrictly","treeExpandedKeys","treeLoadedKeys","treeMotion","onTreeExpand","onTreeLoad","loadData","treeDataSimpleMode","treeNodeLabelProp","treeDefaultExpandedKeys"],Te=Object(w.a)({prefixCls:"rc-tree-select",components:{optionList:r},convertChildrenToData:function(){return null},flattenOptions:ie,getLabeledValue:g.e,filterOptions:se,isValueDisabled:V,findValueOption:K,omitDOMProps:function(ue){var be=Object(M.a)({},ue);return Ee.forEach(function(xe){delete be[xe]}),be}});Te.displayName="Select";var Ie=A.forwardRef(function(ae,ue){var be=ae.multiple,xe=ae.treeCheckable,Ce=ae.treeCheckStrictly,Se=ae.showCheckedStrategy,ye=Se===void 0?"SHOW_CHILD":Se,Ne=ae.labelInValue,Be=ae.loadData,ve=ae.treeLoadedKeys,_e=ae.treeNodeFilterProp,re=_e===void 0?"value":_e,q=ae.treeNodeLabelProp,te=ae.treeDataSimpleMode,j=ae.treeData,W=ae.treeExpandedKeys,G=ae.treeDefaultExpandedKeys,X=ae.treeDefaultExpandAll,oe=ae.children,ce=ae.treeIcon,Pe=ae.showTreeIcon,He=ae.switcherIcon,$e=ae.treeLine,ze=ae.treeMotion,Ze=ae.filterTreeNode,et=ae.dropdownPopupAlign,Xe=ae.onChange,mt=ae.onTreeExpand,rt=ae.onTreeLoad,vt=ae.onDropdownVisibleChange,ct=ae.onSelect,qe=ae.onDeselect,yt=xe||Ce,bt=be||yt,Ve=xe&&!Ce,wt=Ce||Ne,at=A.useRef(null);A.useImperativeHandle(ue,function(){return{focus:at.current.focus,blur:at.current.blur}});var ut=function(Ke){return j&&Ke.label||Ke.title},At=function(Ke){return q?Ke[q]:ut(Ke)},St=Le(j,oe,{getLabelProp:ut,simpleMode:te}),Rt=Object(A.useMemo)(function(){return ie(St)},[St]),it=l(Rt),Qe=Object(_.a)(it,2),Ye=Qe[0],ot=Qe[1],dt=u(Ye,ot),tt=Object(_.a)(dt,2),st=tt[0],ft=tt[1],Ot=Object(A.useMemo)(function(){return Ve?Object(x.a)(St):{keyEntities:null}},[St,xe,Ce]),Ft=Ot.keyEntities,_t=Object(b.a)(ae.defaultValue,{value:ae.value}),Wt=Object(_.a)(_t,2),jt=Wt[0],Vt=Wt[1],Ht=function(Ke){var Je=[],xt=[];return Ke.forEach(function(gt){ft(gt)?xt.push(gt):Je.push(gt)}),{missingRawValues:Je,existRawValues:xt}},P=Object(A.useMemo)(function(){var Ge=[],Ke=[];if(F(jt).forEach(function(pt){if(pt&&Object(L.a)(pt)==="object"&&"value"in pt)if(pt.halfChecked&&Ce){var Lt=ft(pt.value);Ge.push(Lt?Lt.key:pt.value)}else Ke.push(pt.value);else Ke.push(pt)}),Ve){var Je=Ht(Ke),xt=Je.missingRawValues,gt=Je.existRawValues,Et=gt.map(function(pt){return ft(pt).key}),Ct=Object(S.a)(Et,!0,Ft),Kt=Ct.checkedKeys,Nt=Ct.halfCheckedKeys;return[[].concat(Object(O.a)(xt),Object(O.a)(Kt.map(function(pt){return st(pt).data.value}))),Nt]}return[Ke,Ge]},[jt,bt,wt,xe,Ce]),n=Object(_.a)(P,2),d=n[0],D=n[1],N=pe(d,{treeConduction:Ve,value:jt,showCheckedStrategy:ye,conductKeyEntities:Ft,getEntityByValue:ft,getEntityByKey:st,getLabelProp:At}),R=function(Ke,Je,xt){if(Vt(bt?Ke:Ke[0]),Xe){var gt=Ke;if(Ve&&ye!=="SHOW_ALL"){var Et=Ke.map(function(Dt){var It=ft(Dt);return It?It.key:Dt}),Ct=le(Et,ye,Ft);gt=Ct.map(function(Dt){var It=st(Dt);return It?It.data.value:Dt})}var Kt=Je||{triggerValue:void 0,selected:void 0},Nt=Kt.triggerValue,pt=Kt.selected,Lt=wt?he(gt,jt,ft,At):gt;if(Ce){var Gt=D.map(function(Dt){var It=st(Dt);return It?It.data.value:Dt}).filter(function(Dt){return!gt.includes(Dt)});Lt=[].concat(Object(O.a)(Lt),Object(O.a)(he(Gt,jt,ft,At)))}var Pt={preValue:N,triggerValue:Nt},Xt=!0;(Ce||xt==="selection"&&!pt)&&(Xt=!1),I(Pt,Nt,Ke,St,Xt),yt?Pt.checked=pt:Pt.selected=pt,Xe(bt?Lt:Lt[0],wt?null:gt.map(function(Dt){var It=ft(Dt);return It?At(It.data):null}),Pt)}},ee=function(Ke,Je,xt){var gt=Ke;if(!bt)R([Ke],{selected:!0,triggerValue:Ke},xt);else{var Et=de(d,Ke);if(Ve){var Ct=Ht(Et),Kt=Ct.missingRawValues,Nt=Ct.existRawValues,pt=Nt.map(function(Pt){return ft(Pt).key}),Lt=Object(S.a)(pt,!0,Ft),Gt=Lt.checkedKeys;Et=[].concat(Object(O.a)(Kt),Object(O.a)(Gt.map(function(Pt){return st(Pt).data.value})))}R(Et,{selected:!0,triggerValue:Ke},xt)}ct&&ct(gt,Je)},Re=function(Ke,Je,xt){var gt=Ke,Et=$(d,Ke);if(Ve){var Ct=Ht(Et),Kt=Ct.missingRawValues,Nt=Ct.existRawValues,pt=Nt.map(function(Pt){return ft(Pt).key}),Lt=Object(S.a)(pt,{checked:!1,halfCheckedKeys:D},Ft),Gt=Lt.checkedKeys;Et=[].concat(Object(O.a)(Kt),Object(O.a)(Gt.map(function(Pt){return st(Pt).data.value})))}R(Et,{selected:!1,triggerValue:Ke},xt),qe&&qe(gt,Je)},Ue=function(){R([],null,"clear")},je=A.useCallback(function(Ge){if(vt){var Ke={};Object.defineProperty(Ke,"documentClickClose",{get:function(){return Object(y.a)(!1,"Second param of `onDropdownVisibleChange` has been removed."),!1}}),vt(Ge,Ke)}},[vt]),Ae={optionLabelProp:null,optionFilterProp:re,dropdownAlign:et,internalProps:{mark:E.a,onClear:Ue,skipTriggerChange:!0,skipTriggerSelect:!0,onRawSelect:ee,onRawDeselect:Re}};return"filterTreeNode"in ae&&(Ae.filterOption=Ze),A.createElement(o.Provider,{value:{checkable:yt,loadData:Be,treeLoadedKeys:ve,onTreeLoad:rt,checkedKeys:d,halfCheckedKeys:D,treeDefaultExpandAll:X,treeExpandedKeys:W,treeDefaultExpandedKeys:G,onTreeExpand:mt,treeIcon:ce,treeMotion:ze,showTreeIcon:Pe,switcherIcon:He,treeLine:$e,treeNodeFilterProp:re}},A.createElement(Te,Object.assign({ref:at,mode:bt?"multiple":null},ae,Ae,{value:N,labelInValue:!0,options:St,onChange:null,onSelect:null,onDeselect:null,onDropdownVisibleChange:je})))}),ke=function(ae){Object(C.a)(be,ae);var ue=Object(B.a)(be);function be(){var xe;return Object(fe.a)(this,be),xe=ue.apply(this,arguments),xe.selectRef=A.createRef(),xe.focus=function(){xe.selectRef.current.focus()},xe.blur=function(){xe.selectRef.current.blur()},xe}return Object(U.a)(be,[{key:"render",value:function(){return A.createElement(Ie,Object.assign({ref:this.selectRef},this.props))}}]),be}(A.Component);ke.TreeNode=a,ke.SHOW_ALL=Oe,ke.SHOW_PARENT=we,ke.SHOW_CHILD=De;var Me=ke,Fe=We.e=Me},"8hTe":function(nt,We,J){nt.exports={button:"button___1wy9m"}},"9Bee":function(nt,We,J){"use strict";var fe=J("DYRE"),U=J("zeV3"),C=J("+L6B"),B=J("2/Rp"),O=J("k1fw"),L=J("9og8"),_=J("tJVT"),M=J("WmNS"),A=J.n(M),w=J("q1tI"),g=J.n(w),x=J("vg9a"),S=J("DlQD"),E=J.n(S),b=J("rUJ1");function y(P,n){var d=P.match(/^(\s+)(?:```)/);if(d===null)return n;var D=d[1];return n.split(`
|
|
`).map(function(N){var R=N.match(/^\s+/);if(R===null)return N;var ee=Object(_.a)(R,1),Re=ee[0];return Re.length>=D.length?N.slice(D.length):N}).join(`
|
|
`)}var h=[],e=["<ul>"],s=new E.a.Renderer,o=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function f(){h.length=0,e=["<ul>"]}var u={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function l(P,n,d,D){if(n>=P.length||P[n].level<=d)return n;var N=P[n];D.push("<li><a href='#"+N.anchor+"'>"+N.text+"</a>"),n++;var R=[];return n=l(P,n,N.level,R),R.length>0&&(D.push("<ul>"),R.forEach(function(ee){D.push(ee)}),D.push("</ul>")),D.push("</li>"),n=l(P,n,d,D),n}function p(){return l(h,0,0,e),e.push("</ul>"),e.join("")}var c={heading:function(n){var d=o.exec(n);if(d)return{type:"heading",raw:d[0],depth:d[1].length,text:d[2]}},fences:function(n){var d=this.rules.block.fences.exec(n);if(d){var D=d[0],N=y(D,d[3]||""),R=d[2]?d[2].trim():d[2];if(["latex","katex","math"].indexOf(R)>=0){var ee=t(),Re=N;N=ee,a[ee]={type:"block",expression:Re}}return{type:"code",raw:D,lang:R,text:N}}}},i=/(?:\${2})([^\n`]+?)(?:\${2})/gi,r=0,t=function(){return"__special_katext_id_".concat(r++,"__")},a={};function m(){return a}function v(){r=0,a={}}function T(P){return P=P.replace(i,function(n,d){var D=t();return a[D]={type:"inline",expression:d},D}),P}var k=s.listitem;s.listitem=function(P){return k(T(P))};var I=s.paragraph;s.paragraph=function(P){return I(T(P))};var F=s.tablecell;s.tablecell=function(P,n){return F(T(P),n)},s.code=function(P,n,d){var D=(n||"").match(/\S*/)[0];return D?["latex","katex","math"].indexOf(D)>=0?"<p class='editormd-tex'>".concat(P,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(n,'">').concat(d?P:Object(b.escape)(P,!0),`</code></pre>
|
|
`):'<pre class="prettyprint linenums"><code>'+(d?P:Object(b.escape)(P,!0))+"</code></pre>"},s.heading=function(P,n,d){var D=this.options.headerPrefix+d.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return h.push({anchor:D,level:n,text:P}),"<h"+n+' id="'+D+'">'+P+"</h"+n+">"},E.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),E.a.use({tokenizer:c,renderer:s});var K=E.a,V=J("SJMd"),Q=J("ulZh"),Z=J.n(Q),ie=J("m3rI"),ge=J("Oy/b"),se=J("p5ED"),he=J("ErOA");/*! *****************************************************************************
|
|
Copyright (c) Microsoft Corporation.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
***************************************************************************** */var de=function(P,n){return(de=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,D){d.__proto__=D}||function(d,D){for(var N in D)Object.prototype.hasOwnProperty.call(D,N)&&(d[N]=D[N])})(P,n)};function $(P,n){function d(){this.constructor=P}de(P,n),P.prototype=n===null?Object.create(n):(d.prototype=n.prototype,new d)}function Y(P,n,d,D){return new(d||(d=Promise))(function(N,R){function ee(je){try{Ue(D.next(je))}catch(Ae){R(Ae)}}function Re(je){try{Ue(D.throw(je))}catch(Ae){R(Ae)}}function Ue(je){var Ae;je.done?N(je.value):(Ae=je.value,Ae instanceof d?Ae:new d(function(Ge){Ge(Ae)})).then(ee,Re)}Ue((D=D.apply(P,n||[])).next())})}function ne(P,n){var d,D,N,R,ee={label:0,sent:function(){if(1&N[0])throw N[1];return N[1]},trys:[],ops:[]};return R={next:Re(0),throw:Re(1),return:Re(2)},typeof Symbol=="function"&&(R[Symbol.iterator]=function(){return this}),R;function Re(Ue){return function(je){return function(Ae){if(d)throw new TypeError("Generator is already executing.");for(;ee;)try{if(d=1,D&&(N=2&Ae[0]?D.return:Ae[0]?D.throw||((N=D.return)&&N.call(D),0):D.next)&&!(N=N.call(D,Ae[1])).done)return N;switch(D=0,N&&(Ae=[2&Ae[0],N.value]),Ae[0]){case 0:case 1:N=Ae;break;case 4:return ee.label++,{value:Ae[1],done:!1};case 5:ee.label++,D=Ae[1],Ae=[0];continue;case 7:Ae=ee.ops.pop(),ee.trys.pop();continue;default:if(!(N=ee.trys,(N=N.length>0&&N[N.length-1])||Ae[0]!==6&&Ae[0]!==2)){ee=0;continue}if(Ae[0]===3&&(!N||Ae[1]>N[0]&&Ae[1]<N[3])){ee.label=Ae[1];break}if(Ae[0]===6&&ee.label<N[1]){ee.label=N[1],N=Ae;break}if(N&&ee.label<N[2]){ee.label=N[2],ee.ops.push(Ae);break}N[2]&&ee.ops.pop(),ee.trys.pop();continue}Ae=n.call(P,ee)}catch(Ge){Ae=[6,Ge],D=0}finally{d=N=0}if(5&Ae[0])throw Ae[1];return{value:Ae[0]?Ae[1]:void 0,done:!0}}([Ue,je])}}}function z(){for(var P=0,n=0,d=arguments.length;n<d;n++)P+=arguments[n].length;var D=Array(P),N=0;for(n=0;n<d;n++)for(var R=arguments[n],ee=0,Re=R.length;ee<Re;ee++,N++)D[N]=R[ee];return D}var H=function(){function P(){}return P.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},P.setAttributes=function(n,d){for(var D=0,N=d;D<N.length;D++){var R=N[D],ee=R[0],Re=R[1];n.setAttribute(ee,Re)}},P.createRect=function(n,d,D){var N=document.createElementNS("http://www.w3.org/2000/svg","rect");return N.setAttribute("width",n.toString()),N.setAttribute("height",d.toString()),D&&P.setAttributes(N,D),N},P.createLine=function(n,d,D,N,R){var ee=document.createElementNS("http://www.w3.org/2000/svg","line");return ee.setAttribute("x1",n.toString()),ee.setAttribute("y1",d.toString()),ee.setAttribute("x2",D.toString()),ee.setAttribute("y2",N.toString()),R&&P.setAttributes(ee,R),ee},P.createPolygon=function(n,d){var D=document.createElementNS("http://www.w3.org/2000/svg","polygon");return D.setAttribute("points",n),d&&P.setAttributes(D,d),D},P.createCircle=function(n,d){var D=document.createElementNS("http://www.w3.org/2000/svg","circle");return D.setAttribute("cx",(n/2).toString()),D.setAttribute("cy",(n/2).toString()),D.setAttribute("r",n.toString()),d&&P.setAttributes(D,d),D},P.createEllipse=function(n,d,D){var N=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return N.setAttribute("cx",(n/2).toString()),N.setAttribute("cy",(d/2).toString()),N.setAttribute("rx",(n/2).toString()),N.setAttribute("ry",(d/2).toString()),D&&P.setAttributes(N,D),N},P.createGroup=function(n){var d=document.createElementNS("http://www.w3.org/2000/svg","g");return n&&P.setAttributes(d,n),d},P.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},P.createMarker=function(n,d,D,N,R,ee,Re){var Ue=document.createElementNS("http://www.w3.org/2000/svg","marker");return P.setAttributes(Ue,[["id",n],["orient",d],["markerWidth",D.toString()],["markerHeight",N.toString()],["refX",R.toString()],["refY",ee.toString()]]),Ue.appendChild(Re),Ue},P.createText=function(n){var d=document.createElementNS("http://www.w3.org/2000/svg","text");return d.setAttribute("x","0"),d.setAttribute("y","0"),n&&P.setAttributes(d,n),d},P.createTSpan=function(n,d){var D=document.createElementNS("http://www.w3.org/2000/svg","tspan");return D.textContent=n,d&&P.setAttributes(D,d),D},P.createImage=function(n){var d=document.createElementNS("http://www.w3.org/2000/svg","image");return n&&P.setAttributes(d,n),d},P.createPoint=function(n,d){var D=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return D.x=n,D.y=d,D},P.createPath=function(n,d){var D=document.createElementNS("http://www.w3.org/2000/svg","path");return D.setAttribute("d",n),d&&P.setAttributes(D,d),D},P}(),me=function(){function P(){}return P.addKey=function(n){P.key=n},Object.defineProperty(P,"isLicensed",{get:function(){return!!P.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(P.key)},enumerable:!1,configurable:!0}),P}(),Le=function(){function P(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return P.prototype.rasterize=function(n,d,D){var N=this;return new Promise(function(R){var ee=D!==void 0?D:document.createElement("canvas");n===null&&(N.markersOnly=!0,N.naturalSize=!1);var Re=document.createElementNS("http://www.w3.org/2000/svg","svg");Re.setAttribute("xmlns","http://www.w3.org/2000/svg"),Re.setAttribute("width",d.width.baseVal.valueAsString),Re.setAttribute("height",d.height.baseVal.valueAsString),Re.setAttribute("viewBox","0 0 "+d.viewBox.baseVal.width.toString()+" "+d.viewBox.baseVal.height.toString()),Re.innerHTML=d.innerHTML,N.naturalSize===!0?(Re.width.baseVal.value=n.naturalWidth,Re.height.baseVal.value=n.naturalHeight):N.width!==void 0&&N.height!==void 0&&(Re.width.baseVal.value=N.width,Re.height.baseVal.value=N.height),ee.width=Re.width.baseVal.value,ee.height=Re.height.baseVal.value;var Ue=Re.outerHTML,je=ee.getContext("2d");N.markersOnly!==!0&&je.drawImage(n,0,0,ee.width,ee.height);var Ae=window.URL,Ge=new Image(ee.width,ee.height);Ge.setAttribute("crossOrigin","anonymous");var Ke=new Blob([Ue],{type:"image/svg+xml"}),Je=Ae.createObjectURL(Ke);Ge.onload=function(){je.drawImage(Ge,0,0),Ae.revokeObjectURL(Je);var xt=ee.toDataURL(N.imageType,N.imageQuality);R(xt)},Ge.src=Je})},P}(),Oe=function(){},we=function(){function P(n){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+n+"_"}return Object.defineProperty(P.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(P.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(P.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),P.prototype.addClass=function(n){return this.styleSheet===void 0&&this.addStyleSheet(),n.name=""+this.classNamePrefix+n.localName,this.classes.push(n),this.styleSheet.sheet.insertRule("."+n.name+" {"+n.style+"}",this.styleSheet.sheet.cssRules.length),n},P.prototype.addRule=function(n){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(n),this.styleSheet.sheet.insertRule(n.selector+" {"+n.style+"}",this.styleSheet.sheet.cssRules.length)},P.prototype.addStyleSheet=function(){var n;this.styleSheet=document.createElement("style"),((n=this.styleSheetRoot)!==null&&n!==void 0?n:document.head).appendChild(this.styleSheet),this.addRule(new De("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new De("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new De("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new le("fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new le("fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},P.prototype.removeStyleSheet=function(){var n;this.styleSheet&&(((n=this.styleSheetRoot)!==null&&n!==void 0?n:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},P}(),De=function(P,n){this.selector=P,this.style=n},le=function(P,n){this.localName=P,this.style=n},pe=function(){function P(n,d,D,N,R){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=n,this.displayMode=d,this.markerItems=D,this.uiStyleSettings=N,this.styles=R,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return P.prototype.show=function(n){var d=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=n,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var D=document.createElement("div");D.className=this.toolbarBlockStyleClass.name,D.style.whiteSpace="nowrap",this.uiContainer.appendChild(D),this.addActionButton(D,'<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(D,'<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(D,'<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(D,'<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(D,'<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(D,'<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(D,'<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(D,'<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(R){var ee=document.createElement("div");ee.className=""+d.toolbarButtonStyleClass.name,ee.setAttribute("data-type-name",R.typeName),ee.innerHTML=R.icon,ee.addEventListener("click",function(){d.markerToolbarButtonClicked(ee,R)}),d.buttons.push(ee),d.markerButtons.push(ee)}),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 N=document.createElement("div");N.className=this.toolbarBlockStyleClass.name,N.style.whiteSpace="nowrap",N.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(N),this.addActionButton(N,'<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(N,'<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()},P.prototype.addButtonClickListener=function(n){this.buttonClickListeners.push(n)},P.prototype.removeButtonClickListener=function(n){this.buttonClickListeners.indexOf(n)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(n),1)},P.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},P.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var n=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var d=0;d<this.markerButtons.length;d++)d<n||d===n&&this.markerButtons.length-1===n?this.markerButtonBlock.appendChild(this.markerButtons[d]):(d===n&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[d]))}},P.prototype.overflowButtonClicked=function(){this.markerButtonOverflowBlock.style.display!=="none"?(this.markerButtonOverflowBlock.className=this.markerButtonOverflowBlock.className.replace(this.styles.fadeInAnimationClassName,""),this.markerButtonOverflowBlock.style.display="none"):(this.markerButtonOverflowBlock.className+=" "+this.styles.fadeInAnimationClassName,this.markerButtonOverflowBlock.style.top=this.uiContainer.offsetTop+this.overflowButton.offsetHeight+"px",this.markerButtonOverflowBlock.style.right=this.uiContainer.offsetWidth-this.overflowButton.offsetLeft-this.overflowButton.offsetWidth+2*this.uiContainer.offsetLeft+"px",this.markerButtonOverflowBlock.style.display="inline-block")},P.prototype.resetButtonStyles=function(){var n=this;this.buttons.forEach(function(d){d.className=d.className.replace(n.uiStyleSettings.toolbarButtonStyleColorsClassName?n.uiStyleSettings.toolbarButtonStyleColorsClassName:n.toolbarButtonStyleColorsClass.name,"").trim(),d.className=d.className.replace(n.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?n.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:n.toolbarActiveButtonStyleColorsClass.name,"").trim(),d.className+=" "+(n.uiStyleSettings.toolbarButtonStyleColorsClassName?n.uiStyleSettings.toolbarButtonStyleColorsClassName:n.toolbarButtonStyleColorsClass.name)})},P.prototype.addActionButton=function(n,d,D){var N=this,R=document.createElement("div");switch(R.className=""+this.toolbarButtonStyleClass.name,R.innerHTML=d,R.setAttribute("data-action",D),R.addEventListener("click",function(){N.actionToolbarButtonClicked(R,D)}),D){case"select":R.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":R.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":R.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":R.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":R.style.fill=this.uiStyleSettings.closeButtonColor}n.appendChild(R),this.buttons.push(R)},P.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new le("toolbar",`
|
|
width: 100%;
|
|
flex-shrink: 0;
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
height: `+this.uiStyleSettings.toolbarHeight+`px;
|
|
box-sizing: content-box;
|
|
`+(this.displayMode==="inline"?"border-top-left-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
|
|
`+(this.displayMode==="inline"?"border-top-right-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
|
|
overflow: hidden;
|
|
`)),this.toolbarStyleColorsClass=this.styles.addClass(new le("toolbar_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new le("toolbar-block",`
|
|
display: inline-block;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new le("toolbar-overflow-block",`
|
|
position: absolute;
|
|
top: `+this.uiStyleSettings.toolbarHeight+`px;
|
|
max-width: `+2*this.uiStyleSettings.toolbarHeight+`px;
|
|
z-index: 10;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarOverflowBlockStyleColorsClass=this.styles.addClass(new le("toolbar-overflow-block_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`));var n=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new le("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*n)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*n)+`px;
|
|
padding: `+n+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new le("toolbar_button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new le("toolbar_active_button",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new De("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new De("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`))},P.prototype.markerToolbarButtonClicked=function(n,d){this.setActiveButton(n),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(D){return D("marker",d)}),this.markerButtonOverflowBlock.style.display="none"},P.prototype.actionToolbarButtonClicked=function(n,d){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(D){return D("action",d)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},P.prototype.setActiveButton=function(n){this.resetButtonStyles(),n.className=n.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),n.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},P.prototype.setActiveMarkerButton=function(n){var d=this.markerButtons.find(function(D){return D.getAttribute("data-type-name")===n});d&&this.setActiveButton(d)},P.prototype.setCurrentMarker=function(n){var d=this;this.currentMarker=n,this.buttons.filter(function(D){return/delete|notes/.test(D.getAttribute("data-action"))}).forEach(function(D){d.currentMarker===void 0?(D.style.fillOpacity="0.4",D.style.pointerEvents="none"):(D.style.fillOpacity="1",D.style.pointerEvents="all")})},P}(),Ee=function(){function P(n,d,D,N){this.panels=[],this.panelButtons=[],this.markerjsContainer=n,this.displayMode=d,this.uiStyleSettings=D,this.styles=N,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return P.prototype.addStyles=function(){var n;this.toolboxStyleClass=this.styles.addClass(new le("toolbox",`
|
|
width: 100%;
|
|
flex-shrink: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
font-family: sans-serif;
|
|
`+(this.displayMode==="popup"?"height:"+2.5*this.uiStyleSettings.toolbarHeight+"px;":"")+`
|
|
box-sizing: content-box;
|
|
`+(this.displayMode==="popup"?"background-color: "+this.uiStyleSettings.canvasBackgroundColor+";":"")+`
|
|
`+(this.displayMode==="inline"?"border-bottom-left-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
|
|
`+(this.displayMode==="inline"?"border-bottom-right-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
|
|
overflow: hidden;
|
|
`)),this.toolboxStyleColorsClass=this.styles.addClass(new le("toolbox_colors",`
|
|
color: `+this.uiStyleSettings.toolboxColor+`;
|
|
`));var d=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new le("toolbox-button-row",`
|
|
display: flex;
|
|
cursor: default;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new le("toolbox-button-row_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new le("toolbox-panel-row",`
|
|
display: flex;
|
|
`+(this.displayMode==="inline"?"position: absolute;":"")+`
|
|
`+(this.displayMode==="inline"?"bottom: "+this.uiStyleSettings.toolbarHeight+"px;":"")+`
|
|
cursor: default;
|
|
height: `+1.5*this.uiStyleSettings.toolbarHeight+`px;
|
|
`+(this.displayMode==="inline"?"width: 100%;":"")+`
|
|
box-sizing: content-box;
|
|
`)),this.toolboxPanelRowStyleColorsClass=this.styles.addClass(new le("toolbox-panel-row_colors",`
|
|
background-color: `+((n=this.uiStyleSettings.toolboxBackgroundColor)!==null&&n!==void 0?n:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
|
|
`)),this.toolboxButtonStyleClass=this.styles.addClass(new le("toolbox_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*d)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*d)+`px;
|
|
padding: `+d+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new le("toolbox-button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new le("toolbox-active-button_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.styles.addRule(new De("."+this.toolboxButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new De("."+this.toolboxButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`))},P.prototype.show=function(n){var d;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=n,this.uiContainer.className=this.toolboxStyleClass.name+" "+((d=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&d!==void 0?d:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},P.prototype.setPanelButtons=function(n){var d,D,N=this;this.panels=n,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((d=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&d!==void 0?d:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((D=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&D!==void 0?D:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(R){var ee;R.uiStyleSettings=N.uiStyleSettings;var Re=document.createElement("div");Re.className=N.toolboxButtonStyleClass.name+" "+((ee=N.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&ee!==void 0?ee:N.toolboxButtonStyleColorsClass.name),Re.innerHTML=R.icon,Re.title=R.title,Re.addEventListener("click",function(){N.panelButtonClick(R)}),N.panelButtons.push(Re),N.buttonRow.appendChild(Re)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},P.prototype.panelButtonClick=function(n){var d=this,D=-1;if(n!==this.activePanel){D=this.panels.indexOf(n),this.panelRow.innerHTML="";var N=n.getUi();N.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(N),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=n}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){d.displayMode==="inline"?d.panelRow.style.display="none":d.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(R,ee){var Re,Ue;R.className=d.toolboxButtonStyleClass.name+" "+(ee===D?""+((Re=d.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&Re!==void 0?Re:d.toolboxActiveButtonStyleColorsClass.name):""+((Ue=d.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Ue!==void 0?Ue:d.toolboxButtonStyleColorsClass.name))})},P}(),Te=function(P,n){this.title=P,this.icon=n},Ie=function(P){function n(d,D,N,R){var ee=P.call(this,d,R||'<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 ee.colors=[],ee.addTransparent=!1,ee.colorBoxes=[],ee.colors=D,ee.currentColor=N,ee.setCurrentColor=ee.setCurrentColor.bind(ee),ee.getColorBox=ee.getColorBox.bind(ee),ee}return $(n,P),n.prototype.getUi=function(){var d=this,D=document.createElement("div");return D.style.overflow="hidden",D.style.whiteSpace="nowrap",this.colors.forEach(function(N){var R=d.getColorBox(N);D.appendChild(R),d.colorBoxes.push(R)}),D},n.prototype.getColorBox=function(d){var D=this,N=this.uiStyleSettings.toolbarHeight/4,R=this.uiStyleSettings.toolbarHeight-N,ee=document.createElement("div");ee.style.display="inline-block",ee.style.boxSizing="content-box",ee.style.width=R-2+"px",ee.style.height=R-2+"px",ee.style.padding="1px",ee.style.marginRight="2px",ee.style.marginBottom="2px",ee.style.borderWidth="2px",ee.style.borderStyle="solid",ee.style.borderRadius=(R+2)/2+"px",ee.style.borderColor=d===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",ee.addEventListener("click",function(){D.setCurrentColor(d,ee)});var Re=document.createElement("div");return Re.style.display="inline-block",Re.style.width=R-2+"px",Re.style.height=R-2+"px",Re.style.backgroundColor=d,Re.style.borderRadius=R/2+"px",d==="transparent"&&(Re.style.fill=this.uiStyleSettings.toolboxAccentColor,Re.innerHTML=`<svg viewBox="0 0 24 24">
|
|
<path d="M2,5.27L3.28,4L20,20.72L18.73,22L15.65,18.92C14.5,19.3 13.28,19.5 12,19.5C7,19.5 2.73,16.39 1,12C1.69,10.24 2.79,8.69 4.19,7.46L2,5.27M12,9A3,3 0 0,1 15,12C15,12.35 14.94,12.69 14.83,13L11,9.17C11.31,9.06 11.65,9 12,9M12,4.5C17,4.5 21.27,7.61 23,12C22.18,14.08 20.79,15.88 19,17.19L17.58,15.76C18.94,14.82 20.06,13.54 20.82,12C19.17,8.64 15.76,6.5 12,6.5C10.91,6.5 9.84,6.68 8.84,7L7.3,5.47C8.74,4.85 10.33,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C12.69,17.5 13.37,17.43 14,17.29L11.72,15C10.29,14.85 9.15,13.71 9,12.28L5.6,8.87C4.61,9.72 3.78,10.78 3.18,12Z" />
|
|
</svg>`),ee.appendChild(Re),ee},n.prototype.setCurrentColor=function(d,D){var N=this;this.currentColor=d,this.colorBoxes.forEach(function(R){R.style.borderColor=R===D?N.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(d)},n}(Te),ke=function(){function P(n,d,D){this._state="new",this._isSelected=!1,this._container=n,this._overlayContainer=d,this.globalSettings=D,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(P.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),P.prototype.ownsTarget=function(n){return!1},Object.defineProperty(P.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),P.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},P.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},P.prototype.pointerDown=function(n,d){},P.prototype.dblClick=function(n,d){},P.prototype.manipulate=function(n){},P.prototype.pointerUp=function(n){this.stateChanged()},P.prototype.dispose=function(){},P.prototype.addMarkerVisualToContainer=function(n){this.container.childNodes.length>0?this.container.insertBefore(n,this.container.childNodes[0]):this.container.appendChild(n)},P.prototype.getState=function(){return{typeName:P.typeName,state:this.state,notes:this.notes}},P.prototype.restoreState=function(n){this._state=n.state,this.notes=n.notes},P.prototype.scale=function(n,d){},P.prototype.colorChanged=function(n){this.onColorChanged&&this.onColorChanged(n),this.stateChanged()},P.prototype.fillColorChanged=function(n){this.onFillColorChanged&&this.onFillColorChanged(n),this.stateChanged()},P.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var n=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),n.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(n)&&this.onStateChanged(this)}},P.typeName="MarkerBase",P}(),Me=function(){function P(){this.findGripByVisual=this.findGripByVisual.bind(this)}return P.prototype.findGripByVisual=function(n){return this.topLeft.ownsTarget(n)?this.topLeft:this.topCenter.ownsTarget(n)?this.topCenter:this.topRight.ownsTarget(n)?this.topRight:this.centerLeft.ownsTarget(n)?this.centerLeft:this.centerRight.ownsTarget(n)?this.centerRight:this.bottomLeft.ownsTarget(n)?this.bottomLeft:this.bottomCenter.ownsTarget(n)?this.bottomCenter:this.bottomRight.ownsTarget(n)?this.bottomRight:void 0},P}(),Fe=function(){function P(){this.GRIP_SIZE=10,this.visual=H.createGroup(),this.visual.appendChild(H.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(H.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return P.prototype.ownsTarget=function(n){return n===this.visual||n===this.visual.childNodes[0]||n===this.visual.childNodes[1]},P}(),ae=function(){function P(){}return P.toITransformMatrix=function(n){return{a:n.a,b:n.b,c:n.c,d:n.d,e:n.e,f:n.f}},P.toSVGMatrix=function(n,d){return n.a=d.a,n.b=d.b,n.c=d.c,n.d=d.d,n.e=d.e,n.f=d.f,n},P}(),ue=function(P){function n(d,D,N){var R=P.call(this,d,D,N)||this;return R.left=0,R.top=0,R.width=0,R.height=0,R.defaultSize={x:50,y:20},R.offsetX=0,R.offsetY=0,R.rotationAngle=0,R.CB_DISTANCE=10,R._suppressMarkerCreateEvent=!1,R.container.transform.baseVal.appendItem(H.createTransform()),R.setupControlBox(),R}return $(n,P),Object.defineProperty(n.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"visual",{get:function(){return this._visual},set:function(d){this._visual=d;var D=H.createTransform();this._visual.transform.baseVal.appendItem(D)},enumerable:!1,configurable:!0}),n.prototype.ownsTarget=function(d){return!!P.prototype.ownsTarget.call(this,d)||!!(this.controlGrips.findGripByVisual(d)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(d))},n.prototype.pointerDown=function(d,D){P.prototype.pointerDown.call(this,d,D),this.state==="new"&&(this.left=d.x,this.top=d.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var N=this.unrotatePoint(d);if(this.manipulationStartX=N.x,this.manipulationStartY=N.y,this.offsetX=N.x-this.left,this.offsetY=N.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(D),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(D)){this.activeGrip=this.rotatorGrip;var R=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=R.x-this.width/2,this.top=R.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var ee=this.container.transform.baseVal.getItem(0);ee.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(ee,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},n.prototype.pointerUp=function(d){var D=this.state;P.prototype.pointerUp.call(this,d),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(d),this._state="select",D==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},n.prototype.moveVisual=function(d){this.visual.style.transform="translate("+d.x+"px, "+d.y+"px)"},n.prototype.manipulate=function(d){var D=this.unrotatePoint(d);this.state==="creating"?this.resize(d):this.state==="move"?(this.left=this.manipulationStartLeft+(D.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(D.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(D):this.state==="rotate"&&this.rotate(d)},n.prototype.resize=function(d){var D=this.manipulationStartLeft,N=this.manipulationStartWidth,R=this.manipulationStartTop,ee=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:D=this.manipulationStartLeft+d.x-this.manipulationStartX,N=this.manipulationStartWidth+this.manipulationStartLeft-D;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:N=this.manipulationStartWidth+d.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:R=this.manipulationStartTop+d.y-this.manipulationStartY,ee=this.manipulationStartHeight+this.manipulationStartTop-R;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:ee=this.manipulationStartHeight+d.y-this.manipulationStartY}N>=0?(this.left=D,this.width=N):(this.left=D+N,this.width=-N),ee>=0?(this.top=R,this.height=ee):(this.top=R+ee,this.height=-ee),this.setSize()},n.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},n.prototype.rotate=function(d){if(Math.abs(d.x-this.centerX)>.1){var D=Math.sign(d.x-this.centerX);this.rotationAngle=180*Math.atan((d.y-this.centerY)/(d.x-this.centerX))/Math.PI+90*D,this.applyRotation()}},n.prototype.applyRotation=function(){var d=this.container.transform.baseVal.getItem(0);d.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(d,0)},n.prototype.rotatePoint=function(d){if(this.rotationAngle===0)return d;var D=this.container.getCTM(),N=H.createPoint(d.x,d.y);return{x:(N=N.matrixTransform(D)).x,y:N.y}},n.prototype.unrotatePoint=function(d){if(this.rotationAngle===0)return d;var D=this.container.getCTM();D=D.inverse();var N=H.createPoint(d.x,d.y);return{x:(N=N.matrixTransform(D)).x,y:N.y}},n.prototype.select=function(){P.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},n.prototype.deselect=function(){P.prototype.deselect.call(this),this.controlBox.style.display="none"},n.prototype.setupControlBox=function(){this.controlBox=H.createGroup();var d=H.createTransform();d.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(d),this.container.appendChild(this.controlBox),this.controlRect=H.createRect(this.width+this.CB_DISTANCE,this.height+this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"],["fill","transparent"],["pointer-events","none"]]),this.controlBox.appendChild(this.controlRect),this.globalSettings.disableRotation!==!0&&(this.rotatorGripLine=H.createLine((this.width+2*this.CB_DISTANCE)/2,this.top-this.CB_DISTANCE,(this.width+2*this.CB_DISTANCE)/2,this.top-3*this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.appendChild(this.rotatorGripLine)),this.controlGrips=new Me,this.addControlGrips(),this.controlBox.style.display="none"},n.prototype.adjustControlBox=function(){var d=this.controlBox.transform.baseVal.getItem(0);d.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(d,0),this.controlRect.setAttribute("width",(this.width+this.CB_DISTANCE).toString()),this.controlRect.setAttribute("height",(this.height+this.CB_DISTANCE).toString()),this.rotatorGripLine!==void 0&&(this.rotatorGripLine.setAttribute("x1",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y1",(-this.CB_DISTANCE/2).toString()),this.rotatorGripLine.setAttribute("x2",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y2",(3*-this.CB_DISTANCE).toString())),this.positionGrips()},n.prototype.addControlGrips=function(){this.controlGrips.topLeft=this.createGrip(),this.controlGrips.topCenter=this.createGrip(),this.controlGrips.topRight=this.createGrip(),this.controlGrips.centerLeft=this.createGrip(),this.controlGrips.centerRight=this.createGrip(),this.controlGrips.bottomLeft=this.createGrip(),this.controlGrips.bottomCenter=this.createGrip(),this.controlGrips.bottomRight=this.createGrip(),this.globalSettings.disableRotation!==!0&&(this.rotatorGrip=this.createGrip()),this.positionGrips()},n.prototype.createGrip=function(){var d=new Fe;return d.visual.transform.baseVal.appendItem(H.createTransform()),this.controlBox.appendChild(d.visual),d},n.prototype.positionGrips=function(){var d=this.controlGrips.topLeft.GRIP_SIZE,D=-d/2,N=D,R=(this.width+this.CB_DISTANCE)/2-d/2,ee=(this.height+this.CB_DISTANCE)/2-d/2,Re=this.height+this.CB_DISTANCE-d/2,Ue=this.width+this.CB_DISTANCE-d/2;this.positionGrip(this.controlGrips.topLeft.visual,D,N),this.positionGrip(this.controlGrips.topCenter.visual,R,N),this.positionGrip(this.controlGrips.topRight.visual,Ue,N),this.positionGrip(this.controlGrips.centerLeft.visual,D,ee),this.positionGrip(this.controlGrips.centerRight.visual,Ue,ee),this.positionGrip(this.controlGrips.bottomLeft.visual,D,Re),this.positionGrip(this.controlGrips.bottomCenter.visual,R,Re),this.positionGrip(this.controlGrips.bottomRight.visual,Ue,Re),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,R,N-3*this.CB_DISTANCE)},n.prototype.positionGrip=function(d,D,N){var R=d.transform.baseVal.getItem(0);R.setTranslate(D,N),d.transform.baseVal.replaceItem(R,0)},n.prototype.hideControlBox=function(){this.controlBox.style.display="none"},n.prototype.showControlBox=function(){this.controlBox.style.display=""},n.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:ae.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:ae.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},P.prototype.getState.call(this))},n.prototype.restoreState=function(d){P.prototype.restoreState.call(this,d);var D=d;this.left=D.left,this.top=D.top,this.width=D.width,this.height=D.height,this.rotationAngle=D.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(ae.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,D.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(ae.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,D.containerTransformMatrix))},n.prototype.scale=function(d,D){P.prototype.scale.call(this,d,D);var N=this.rotatePoint({x:this.left,y:this.top}),R=this.unrotatePoint({x:N.x*d,y:N.y*D});this.left=R.x,this.top=R.y,this.width=this.width*d,this.height=this.height*D,this.adjustControlBox()},n}(ke),be=function(P){function n(d,D,N){var R=P.call(this,d,D,N)||this;return R.fillColor="transparent",R.strokeColor="transparent",R.strokeWidth=0,R.strokeDasharray="",R.opacity=1,R.setStrokeColor=R.setStrokeColor.bind(R),R.setFillColor=R.setFillColor.bind(R),R.setStrokeWidth=R.setStrokeWidth.bind(R),R.setStrokeDasharray=R.setStrokeDasharray.bind(R),R.createVisual=R.createVisual.bind(R),R}return $(n,P),n.prototype.ownsTarget=function(d){return!(!P.prototype.ownsTarget.call(this,d)&&d!==this.visual)},n.prototype.createVisual=function(){this.visual=H.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)},n.prototype.pointerDown=function(d,D){P.prototype.pointerDown.call(this,d,D),this.state==="new"&&(this.createVisual(),this.moveVisual(d),this._state="creating")},n.prototype.manipulate=function(d){P.prototype.manipulate.call(this,d)},n.prototype.resize=function(d){P.prototype.resize.call(this,d),this.setSize()},n.prototype.setSize=function(){P.prototype.setSize.call(this),H.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},n.prototype.pointerUp=function(d){P.prototype.pointerUp.call(this,d),this.setSize()},n.prototype.setStrokeColor=function(d){this.strokeColor=d,this.visual&&H.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(d),this.stateChanged()},n.prototype.setFillColor=function(d){this.fillColor=d,this.visual&&H.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},n.prototype.setStrokeWidth=function(d){this.strokeWidth=d,this.visual&&H.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},n.prototype.setStrokeDasharray=function(d){this.strokeDasharray=d,this.visual&&H.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},n.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},P.prototype.getState.call(this))},n.prototype.restoreState=function(d){var D=d;this.fillColor=D.fillColor,this.strokeColor=D.strokeColor,this.strokeWidth=D.strokeWidth,this.strokeDasharray=D.strokeDasharray,this.opacity=D.opacity,this.createVisual(),P.prototype.restoreState.call(this,d),this.setSize()},n.prototype.scale=function(d,D){P.prototype.scale.call(this,d,D),this.setSize()},n.title="Rectangle marker",n}(ue),xe=function(P){function n(d,D,N,R){var ee=P.call(this,d,R||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return ee.widths=[],ee.widthBoxes=[],ee.widths=D,ee.currentWidth=N,ee.setCurrentWidth=ee.setCurrentWidth.bind(ee),ee}return $(n,P),n.prototype.getUi=function(){var d=this,D=document.createElement("div");return D.style.display="flex",D.style.overflow="hidden",D.style.flexGrow="2",this.widths.forEach(function(N){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=N===d.currentWidth?d.uiStyleSettings.toolboxAccentColor:"transparent",R.addEventListener("click",function(){d.setCurrentWidth(N,R)}),D.appendChild(R);var ee=document.createElement("div");ee.innerText=N.toString(),ee.style.marginRight="5px",R.appendChild(ee);var Re=document.createElement("div");Re.style.minHeight="20px",Re.style.flexGrow="2",Re.style.display="flex",Re.style.alignItems="center";var Ue=document.createElement("hr");Ue.style.minWidth="20px",Ue.style.border="0px",Ue.style.borderTop=N+"px solid "+d.uiStyleSettings.toolboxColor,Ue.style.flexGrow="2",Re.appendChild(Ue),R.appendChild(Re),d.widthBoxes.push(R)}),D},n.prototype.setCurrentWidth=function(d,D){var N=this;this.currentWidth=d,this.widthBoxes.forEach(function(R){R.style.borderColor=R===D?N.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},n}(Te),Ce=function(P){function n(d,D,N,R){var ee=P.call(this,d,R||'<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 ee.styles=[],ee.styleBoxes=[],ee.styles=D,ee.currentStyle=N,ee.setCurrentStyle=ee.setCurrentStyle.bind(ee),ee}return $(n,P),n.prototype.getUi=function(){var d=this,D=document.createElement("div");return D.style.display="flex",D.style.overflow="hidden",D.style.flexGrow="2",this.styles.forEach(function(N){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/d.styles.length-5+"%",R.style.borderColor=N===d.currentStyle?d.uiStyleSettings.toolboxAccentColor:"transparent",R.addEventListener("click",function(){d.setCurrentStyle(N,R)}),D.appendChild(R);var ee=document.createElement("div");ee.style.minHeight="20px",ee.style.flexGrow="2",ee.style.overflow="hidden";var Re=`<svg width="100" height="20">
|
|
<line x1="0" y1="10" x2="100" y2="10" stroke="`+d.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(N!==""?'stroke-dasharray="'+N+'"':"")+` />
|
|
</svg>`;ee.innerHTML=Re,R.appendChild(ee),d.styleBoxes.push(R)}),D},n.prototype.setCurrentStyle=function(d,D){var N=this;this.currentStyle=d,this.styleBoxes.forEach(function(R){R.style.borderColor=R===D?N.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},n}(Te),Se=function(P){function n(d,D,N){var R=P.call(this,d,D,N)||this;return R.strokeColor=N.defaultColor,R.strokeWidth=N.defaultStrokeWidth,R.strokeDasharray=N.defaultStrokeDasharray,R.strokePanel=new Ie("Line color",N.defaultColorSet,N.defaultColor),R.strokePanel.onColorChanged=R.setStrokeColor,R.strokeWidthPanel=new xe("Line width",N.defaultStrokeWidths,N.defaultStrokeWidth),R.strokeWidthPanel.onWidthChanged=R.setStrokeWidth,R.strokeStylePanel=new Ce("Line style",N.defaultStrokeDasharrays,N.defaultStrokeDasharray),R.strokeStylePanel.onStyleChanged=R.setStrokeDasharray,R}return $(n,P),Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var d=P.prototype.getState.call(this);return d.typeName=n.typeName,d},n.typeName="FrameMarker",n.title="Frame marker",n.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',n}(be),ye=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},Ne=function(P){function n(d,D,N){var R=P.call(this,d,D,N)||this;return R.x1=0,R.y1=0,R.x2=0,R.y2=0,R.defaultLength=50,R.manipulationStartX=0,R.manipulationStartY=0,R.manipulationStartX1=0,R.manipulationStartY1=0,R.manipulationStartX2=0,R.manipulationStartY2=0,R.setupControlBox(),R}return $(n,P),n.prototype.ownsTarget=function(d){return!!P.prototype.ownsTarget.call(this,d)||!(!this.grip1.ownsTarget(d)&&!this.grip2.ownsTarget(d))},n.prototype.pointerDown=function(d,D){P.prototype.pointerDown.call(this,d,D),this.manipulationStartX=d.x,this.manipulationStartY=d.y,this.state==="new"&&(this.x1=d.x,this.y1=d.y,this.x2=d.x,this.y2=d.y),this.manipulationStartX1=this.x1,this.manipulationStartY1=this.y1,this.manipulationStartX2=this.x2,this.manipulationStartY2=this.y2,this.state!=="new"&&(this.select(),this.grip1.ownsTarget(D)?this.activeGrip=this.grip1:this.grip2.ownsTarget(D)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},n.prototype.pointerUp=function(d){var D=this.state;P.prototype.pointerUp.call(this,d),this.state==="creating"&&Math.abs(this.x1-this.x2)<10&&Math.abs(this.y1-this.y2)<10?(this.x2=this.x1+this.defaultLength,this.adjustVisual(),this.adjustControlBox()):this.manipulate(d),this._state="select",D==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},n.prototype.adjustVisual=function(){},n.prototype.manipulate=function(d){this.state==="creating"?this.resize(d):this.state==="move"?(this.x1=this.manipulationStartX1+d.x-this.manipulationStartX,this.y1=this.manipulationStartY1+d.y-this.manipulationStartY,this.x2=this.manipulationStartX2+d.x-this.manipulationStartX,this.y2=this.manipulationStartY2+d.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(d)},n.prototype.resize=function(d){switch(this.activeGrip){case this.grip1:this.x1=d.x,this.y1=d.y;break;case this.grip2:case void 0:this.x2=d.x,this.y2=d.y}this.adjustVisual(),this.adjustControlBox()},n.prototype.select=function(){P.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},n.prototype.deselect=function(){P.prototype.deselect.call(this),this.controlBox.style.display="none"},n.prototype.setupControlBox=function(){this.controlBox=H.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},n.prototype.adjustControlBox=function(){this.positionGrips()},n.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},n.prototype.createGrip=function(){var d=new Fe;return d.visual.transform.baseVal.appendItem(H.createTransform()),this.controlBox.appendChild(d.visual),d},n.prototype.positionGrips=function(){var d=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-d/2,this.y1-d/2),this.positionGrip(this.grip2.visual,this.x2-d/2,this.y2-d/2)},n.prototype.positionGrip=function(d,D,N){var R=d.transform.baseVal.getItem(0);R.setTranslate(D,N),d.transform.baseVal.replaceItem(R,0)},n.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},P.prototype.getState.call(this))},n.prototype.restoreState=function(d){P.prototype.restoreState.call(this,d);var D=d;this.x1=D.x1,this.y1=D.y1,this.x2=D.x2,this.y2=D.y2},n.prototype.scale=function(d,D){P.prototype.scale.call(this,d,D),this.x1=this.x1*d,this.y1=this.y1*D,this.x2=this.x2*d,this.y2=this.y2*D,this.adjustVisual(),this.adjustControlBox()},n}(ke),Be=function(P){function n(d,D,N){var R=P.call(this,d,D,N)||this;return R.strokeColor="transparent",R.strokeWidth=0,R.strokeDasharray="",R.setStrokeColor=R.setStrokeColor.bind(R),R.setStrokeWidth=R.setStrokeWidth.bind(R),R.setStrokeDasharray=R.setStrokeDasharray.bind(R),R.strokeColor=N.defaultColor,R.strokeWidth=N.defaultStrokeWidth,R.strokeDasharray=N.defaultStrokeDasharray,R.strokePanel=new Ie("Line color",N.defaultColorSet,N.defaultColor),R.strokePanel.onColorChanged=R.setStrokeColor,R.strokeWidthPanel=new xe("Line width",N.defaultStrokeWidths,N.defaultStrokeWidth),R.strokeWidthPanel.onWidthChanged=R.setStrokeWidth,R.strokeStylePanel=new Ce("Line style",N.defaultStrokeDasharrays,N.defaultStrokeDasharray),R.strokeStylePanel.onStyleChanged=R.setStrokeDasharray,R}return $(n,P),n.prototype.ownsTarget=function(d){return!(!P.prototype.ownsTarget.call(this,d)&&d!==this.visual&&d!==this.selectorLine&&d!==this.visibleLine)},n.prototype.createVisual=function(){this.visual=H.createGroup(),this.selectorLine=H.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=H.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)},n.prototype.pointerDown=function(d,D){P.prototype.pointerDown.call(this,d,D),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},n.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()),H.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),H.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),H.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},n.prototype.setStrokeColor=function(d){this.strokeColor=d,this.adjustVisual(),this.colorChanged(d)},n.prototype.setStrokeWidth=function(d){this.strokeWidth=d,this.adjustVisual()},n.prototype.setStrokeDasharray=function(d){this.strokeDasharray=d,this.adjustVisual(),this.stateChanged()},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var d=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},P.prototype.getState.call(this));return d.typeName=n.typeName,d},n.prototype.restoreState=function(d){P.prototype.restoreState.call(this,d);var D=d;this.strokeColor=D.strokeColor,this.strokeWidth=D.strokeWidth,this.strokeDasharray=D.strokeDasharray,this.createVisual(),this.adjustVisual()},n.typeName="LineMarker",n.title="Line marker",n.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',n}(Ne),ve=function(P){function n(d,D,N,R){var ee=P.call(this,d,R||'<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 ee.fonts=[],ee.fontBoxes=[],ee.fonts=D,ee.currentFont=N,ee.setCurrentFont=ee.setCurrentFont.bind(ee),ee}return $(n,P),n.prototype.getUi=function(){var d=this,D=document.createElement("div");return D.style.overflow="hidden",D.style.flexGrow="2",this.fonts.forEach(function(N){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/d.fonts.length-5+"%",R.style.borderColor=N===d.currentFont?d.uiStyleSettings.toolboxAccentColor:"transparent",R.addEventListener("click",function(){d.setCurrentFont(N,R)}),D.appendChild(R);var ee=document.createElement("div");ee.style.display="flex",ee.style.minHeight="20px",ee.style.flexGrow="2",ee.style.fontFamily=N,ee.style.overflow="hidden";var Re=document.createElement("div");Re.style.whiteSpace="nowrap",Re.style.overflow="hidden",Re.style.textOverflow="ellipsis",Re.innerHTML="The quick brown fox jumps over the lazy dog",ee.appendChild(Re),R.appendChild(ee),d.fontBoxes.push(R)}),D},n.prototype.setCurrentFont=function(d,D){var N=this;this.currentFont=d,this.fontBoxes.forEach(function(R){R.style.borderColor=R===D?N.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},n}(Te),_e=function(P){function n(d,D,N){var R=P.call(this,d,D,N)||this;return R.color="transparent",R.padding=5,R.DEFAULT_TEXT="your text here",R.text=R.DEFAULT_TEXT,R.isMoved=!1,R.color=N.defaultColor,R.fontFamily=N.defaultFontFamily,R.defaultSize={x:100,y:30},R.setColor=R.setColor.bind(R),R.setFont=R.setFont.bind(R),R.renderText=R.renderText.bind(R),R.sizeText=R.sizeText.bind(R),R.textEditDivClicked=R.textEditDivClicked.bind(R),R.showTextEditor=R.showTextEditor.bind(R),R.setSize=R.setSize.bind(R),R.positionTextEditor=R.positionTextEditor.bind(R),R.colorPanel=new Ie("Color",N.defaultColorSet,N.defaultColor),R.colorPanel.onColorChanged=R.setColor,R.fontFamilyPanel=new ve("Font",N.defaultFontFamilies,N.defaultFontFamily),R.fontFamilyPanel.onFontChanged=R.setFont,R}return $(n,P),n.prototype.ownsTarget=function(d){if(P.prototype.ownsTarget.call(this,d)||d===this.visual||d===this.textElement||d===this.bgRectangle)return!0;var D=!1;return this.textElement.childNodes.forEach(function(N){N===d&&(D=!0)}),D},n.prototype.createVisual=function(){this.visual=H.createGroup(),this.bgRectangle=H.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=H.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(H.createTransform()),this.textElement.transform.baseVal.appendItem(H.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},n.prototype.pointerDown=function(d,D){P.prototype.pointerDown.call(this,d,D),this.isMoved=!1,this.pointerDownPoint=d,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(d),this._state="creating")},n.prototype.renderText=function(){var d=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(D){d.textElement.appendChild(H.createTSpan(D.trim()===""?" ":D.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},n.prototype.getTextScale=function(){var d=this.textElement.getBBox(),D=1;if(d.width>0&&d.height>0){var N=(1*this.width-this.width*this.padding*2/100)/d.width,R=(1*this.height-this.height*this.padding*2/100)/d.height;D=Math.min(N,R)}return D},n.prototype.getTextPosition=function(d){var D=this.textElement.getBBox(),N=0,R=0;return D.width>0&&D.height>0&&(N=(this.width-D.width*d)/2,R=this.height/2-D.height*d/2),{x:N,y:R}},n.prototype.sizeText=function(){var d=this.textElement.getBBox(),D=this.getTextScale(),N=this.getTextPosition(D);N.y-=d.y*D,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+N.x+"px, "+N.y+"px) scale("+D+", "+D+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(N.x,N.y),this.textElement.transform.baseVal.getItem(1).setScale(D,D))},n.prototype.manipulate=function(d){P.prototype.manipulate.call(this,d),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(d.x-this.pointerDownPoint.x)>5||Math.abs(d.y-this.pointerDownPoint.y)>5)},n.prototype.resize=function(d){P.prototype.resize.call(this,d),this.isMoved=!0,this.setSize(),this.sizeText()},n.prototype.setSize=function(){P.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(H.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),H.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},n.prototype.pointerUp=function(d){var D=this.state;D==="creating"&&(this._suppressMarkerCreateEvent=!0),P.prototype.pointerUp.call(this,d),this.setSize(),(D==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},n.prototype.showTextEditor=function(){var d=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(D){D.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var D=Number.parseFloat(d.textEditor.style.fontSize);d.textEditor.clientWidth>=Number.parseInt(d.textEditor.style.maxWidth)&&D>.9;)D-=.1,d.textEditor.style.fontSize=Math.max(D,.9)+"em"}),this.textEditor.addEventListener("keyup",function(D){D.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(D){if(D.clipboardData){var N=D.clipboardData.getData("text"),R=window.getSelection();if(!R.rangeCount)return!1;R.deleteFromDocument(),R.getRangeAt(0).insertNode(document.createTextNode(N)),D.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){d.textEditDivClicked(d.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},n.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var d=this.getTextScale(),D=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),N=this.textElement.getBBox(),R={x:N.width*d,y:N.height*d};D.x-=R.x/2,D.y-=R.y/2,this.textEditor.style.top=D.y+"px",this.textEditor.style.left=D.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-D.x+"px",this.textEditor.style.fontSize=Math.max(16*d,12)+"px",this.textElement.style.display="none"}},n.prototype.textEditDivClicked=function(d){this.text=d.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},n.prototype.select=function(){P.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},n.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),P.prototype.deselect.call(this)},n.prototype.dblClick=function(d,D){P.prototype.dblClick.call(this,d,D),this.showTextEditor()},n.prototype.setColor=function(d){this.textElement&&H.setAttributes(this.textElement,[["fill",d]]),this.color=d,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(d)},n.prototype.setFont=function(d){this.textElement&&H.setAttributes(this.textElement,[["font-family",d]]),this.fontFamily=d,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},n.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},n.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var d=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},P.prototype.getState.call(this));return d.typeName=n.typeName,d},n.prototype.restoreState=function(d){var D=d;this.color=D.color,this.fontFamily=D.fontFamily,this.padding=D.padding,this.text=D.text,this.createVisual(),P.prototype.restoreState.call(this,d),this.setSize()},n.prototype.scale=function(d,D){P.prototype.scale.call(this,d,D),this.setSize(),this.sizeText(),this.positionTextEditor()},n.typeName="TextMarker",n.title="Text marker",n.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>',n}(ue),re=function(P){function n(d,D,N){var R=P.call(this,d,D,N)||this;return R.color="transparent",R.lineWidth=3,R.drawing=!1,R.pixelRatio=1,R.color=N.defaultColor,R.lineWidth=N.defaultStrokeWidth,R.pixelRatio=N.freehandPixelRatio,R.setColor=R.setColor.bind(R),R.addCanvas=R.addCanvas.bind(R),R.finishCreation=R.finishCreation.bind(R),R.setLineWidth=R.setLineWidth.bind(R),R.colorPanel=new Ie("Color",N.defaultColorSet,N.defaultColor),R.colorPanel.onColorChanged=R.setColor,R.lineWidthPanel=new xe("Line width",N.defaultStrokeWidths,N.defaultStrokeWidth),R.lineWidthPanel.onWidthChanged=R.setLineWidth,R}return $(n,P),n.prototype.ownsTarget=function(d){return!(!P.prototype.ownsTarget.call(this,d)&&d!==this.visual&&d!==this.drawingImage)},n.prototype.createVisual=function(){this.visual=H.createGroup(),this.drawingImage=H.createImage(),this.visual.appendChild(this.drawingImage);var d=H.createTransform();this.visual.transform.baseVal.appendItem(d),this.addMarkerVisualToContainer(this.visual)},n.prototype.pointerDown=function(d,D){this.state==="new"&&(this.addCanvas(),this.createVisual(),this._state="creating"),this.state==="creating"?(this.canvasContext.strokeStyle=this.color,this.canvasContext.lineWidth=this.lineWidth,this.canvasContext.beginPath(),this.canvasContext.moveTo(d.x,d.y),this.drawing=!0):P.prototype.pointerDown.call(this,d,D)},n.prototype.manipulate=function(d){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(d.x,d.y),this.canvasContext.stroke()):P.prototype.manipulate.call(this,d)},n.prototype.resize=function(d){P.prototype.resize.call(this,d),H.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),H.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},n.prototype.pointerUp=function(d){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):P.prototype.pointerUp.call(this,d)},n.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)},n.prototype.select=function(){this.state==="creating"&&this.finishCreation(),P.prototype.select.call(this)},n.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),P.prototype.deselect.call(this)},n.prototype.finishCreation=function(){for(var d=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),D=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],N=D[0],R=D[1],ee=D[2],Re=D[3],Ue=!1,je=0;je<this.canvasElement.height;je++)for(var Ae=0;Ae<this.canvasElement.width;Ae++)d.data[je*this.canvasElement.width*4+4*Ae+3]>0&&(Ue=!0,je<R&&(R=je),Ae<N&&(N=Ae),je>Re&&(Re=je),Ae>ee&&(ee=Ae));if(Ue){this.left=N/this.pixelRatio,this.top=R/this.pixelRatio,this.width=(ee-N)/this.pixelRatio,this.height=(Re-R)/this.pixelRatio;var Ge=document.createElement("canvas");Ge.width=ee-N,Ge.height=Re-R,Ge.getContext("2d").putImageData(this.canvasContext.getImageData(N,R,ee-N,Re-R),0,0),this.drawingImgUrl=Ge.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},n.prototype.setDrawingImage=function(){H.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),H.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},n.prototype.setColor=function(d){this.color=d,this.colorChanged(d)},n.prototype.setLineWidth=function(d){this.lineWidth=d},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var d=Object.assign({drawingImgUrl:this.drawingImgUrl},P.prototype.getState.call(this));return d.typeName=n.typeName,d},n.prototype.restoreState=function(d){this.createVisual(),P.prototype.restoreState.call(this,d),this.drawingImgUrl=d.drawingImgUrl,this.setDrawingImage()},n.prototype.scale=function(d,D){P.prototype.scale.call(this,d,D),this.setDrawingImage()},n.typeName="FreehandMarker",n.title="Freehand marker",n.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>',n}(ue),q=function(P){function n(d,D,N){var R=P.call(this,d,N||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return R.typeBoxes=[],R.currentType=D,R.setCurrentType=R.setCurrentType.bind(R),R}return $(n,P),n.prototype.getUi=function(){var d=this,D=document.createElement("div");D.style.display="flex",D.style.overflow="hidden",D.style.flexGrow="2";for(var N=function(Re){var Ue="both";switch(Re){case 0:Ue="both";break;case 1:Ue="start";break;case 2:Ue="end";break;case 3:Ue="none"}var je=document.createElement("div");if(je.style.display="flex",je.style.flexGrow="2",je.style.alignItems="center",je.style.justifyContent="space-between",je.style.padding="5px",je.style.borderWidth="2px",je.style.borderStyle="solid",je.style.borderColor=Ue===R.currentType?R.uiStyleSettings.toolboxAccentColor:"transparent",je.addEventListener("click",function(){d.setCurrentType(Ue,je)}),D.appendChild(je),Ue==="both"||Ue==="start"){var Ae=document.createElement("div");Ae.style.display="flex",Ae.style.alignItems="center",Ae.style.minHeight="20px",Ae.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
|
|
<polygon points="0,5 10,0 10,10" fill="`+(R.uiStyleSettings!==void 0?R.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,Ae.style.marginLeft="5px",je.appendChild(Ae)}var Ge=document.createElement("div");Ge.style.display="flex",Ge.style.alignItems="center",Ge.style.minHeight="20px",Ge.style.flexGrow="2";var Ke=document.createElement("hr");if(Ke.style.minWidth="20px",Ke.style.border="0px",Ke.style.borderTop="3px solid "+(R.uiStyleSettings!==void 0?R.uiStyleSettings.toolboxColor:"#eeeeee"),Ke.style.flexGrow="2",Ge.appendChild(Ke),je.appendChild(Ge),Ue==="both"||Ue==="end"){var Je=document.createElement("div");Je.style.display="flex",Je.style.alignItems="center",Je.style.minHeight="20px",Je.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
|
|
<polygon points="0,0 10,5 0,10" fill="`+(R.uiStyleSettings!==void 0?R.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,Je.style.marginRight="5px",je.appendChild(Je)}R.typeBoxes.push(je)},R=this,ee=0;ee<4;ee++)N(ee);return D},n.prototype.setCurrentType=function(d,D){var N=this;this.currentType=d,this.typeBoxes.forEach(function(R){R.style.borderColor=R===D?N.uiStyleSettings!==void 0?N.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},n}(Te),te=function(P){function n(d,D,N){var R=P.call(this,d,D,N)||this;return R.arrowType="end",R.arrowBaseHeight=10,R.arrowBaseWidth=10,R.getArrowPoints=R.getArrowPoints.bind(R),R.setArrowType=R.setArrowType.bind(R),R.arrowTypePanel=new q("Arrow type","end"),R.arrowTypePanel.onArrowTypeChanged=R.setArrowType,R}return $(n,P),n.prototype.ownsTarget=function(d){return!(!P.prototype.ownsTarget.call(this,d)&&d!==this.arrow1&&d!==this.arrow2)},n.prototype.getArrowPoints=function(d,D){var N=this.arrowBaseWidth+2*this.strokeWidth,R=this.arrowBaseHeight+2*this.strokeWidth;return d-N/2+","+(D+R/2)+" "+d+","+(D-R/2)+" "+(d+N/2)+","+(D+R/2)},n.prototype.createTips=function(){this.arrow1=H.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(H.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=H.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(H.createTransform()),this.visual.appendChild(this.arrow2)},n.prototype.pointerDown=function(d,D){P.prototype.pointerDown.call(this,d,D),this.state==="creating"&&this.createTips()},n.prototype.adjustVisual=function(){if(P.prototype.adjustVisual.call(this),this.arrow1&&this.arrow2&&(this.arrow1.style.display=this.arrowType==="both"||this.arrowType==="start"?"":"none",this.arrow2.style.display=this.arrowType==="both"||this.arrowType==="end"?"":"none",H.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),H.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var d=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),D=this.arrow1.transform.baseVal.getItem(0);D.setRotate(d,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(D,0);var N=this.arrow2.transform.baseVal.getItem(0);N.setRotate(d+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(N,0)}},n.prototype.setArrowType=function(d){this.arrowType=d,this.adjustVisual(),this.stateChanged()},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var d=Object.assign({arrowType:this.arrowType},P.prototype.getState.call(this));return d.typeName=n.typeName,d},n.prototype.restoreState=function(d){P.prototype.restoreState.call(this,d);var D=d;this.arrowType=D.arrowType,this.createTips(),this.adjustVisual()},n.typeName="ArrowMarker",n.title="Arrow marker",n.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',n}(Be),j=function(P){function n(d,D,N){var R=P.call(this,d,D,N)||this;return R.fillColor=N.defaultFillColor,R.strokeWidth=0,R.fillPanel=new Ie("Color",N.defaultColorSet,N.defaultFillColor),R.fillPanel.onColorChanged=R.setFillColor,R}return $(n,P),Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var d=P.prototype.getState.call(this);return d.typeName=n.typeName,d},n.typeName="CoverMarker",n.title="Cover marker",n.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',n}(be),W=function(P){function n(d,D,N,R){var ee=P.call(this,d,R||'<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 ee.opacities=[],ee.opacityBoxes=[],ee.opacities=D,ee.currentOpacity=N,ee.setCurrentOpacity=ee.setCurrentOpacity.bind(ee),ee}return $(n,P),n.prototype.getUi=function(){var d=this,D=document.createElement("div");return D.style.display="flex",D.style.overflow="hidden",D.style.flexGrow="2",D.style.justifyContent="space-between",this.opacities.forEach(function(N){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=N===d.currentOpacity?d.uiStyleSettings.toolboxAccentColor:"transparent",R.addEventListener("click",function(){d.setCurrentOpacity(N,R)}),D.appendChild(R);var ee=document.createElement("div");ee.innerText=100*N+"%",R.appendChild(ee),d.opacityBoxes.push(R)}),D},n.prototype.setCurrentOpacity=function(d,D){var N=this;this.currentOpacity=d,this.opacityBoxes.forEach(function(R){R.style.borderColor=R===D?N.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},n}(Te),G=function(P){function n(d,D,N){var R=P.call(this,d,D,N)||this;return R.setOpacity=R.setOpacity.bind(R),R.fillColor=N.defaultHighlightColor,R.strokeWidth=0,R.opacity=N.defaultHighlightOpacity,R.fillPanel=new Ie("Color",N.defaultColorSet,R.fillColor),R.fillPanel.onColorChanged=R.setFillColor,R.opacityPanel=new W("Opacity",N.defaultOpacitySteps,R.opacity),R.opacityPanel.onOpacityChanged=R.setOpacity,R}return $(n,P),n.prototype.setOpacity=function(d){this.opacity=d,this.visual&&H.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var d=P.prototype.getState.call(this);return d.typeName=n.typeName,d},n.typeName="HighlightMarker",n.title="Highlight marker",n.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>',n}(j),X='<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>',oe=function(P){function n(d,D,N){var R=P.call(this,d,D,N)||this;return R.bgColor="transparent",R.tipPosition={x:0,y:0},R.tipBase1Position={x:0,y:0},R.tipBase2Position={x:0,y:0},R.tipMoving=!1,R.color=N.defaultStrokeColor,R.bgColor=N.defaultFillColor,R.fontFamily=N.defaultFontFamily,R.defaultSize={x:100,y:30},R.setBgColor=R.setBgColor.bind(R),R.getTipPoints=R.getTipPoints.bind(R),R.positionTip=R.positionTip.bind(R),R.setTipPoints=R.setTipPoints.bind(R),R.colorPanel=new Ie("Text color",N.defaultColorSet,R.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>'),R.colorPanel.onColorChanged=R.setColor,R.bgColorPanel=new Ie("Fill color",N.defaultColorSet,R.bgColor,X),R.bgColorPanel.onColorChanged=R.setBgColor,R.fontFamilyPanel=new ve("Font",N.defaultFontFamilies,N.defaultFontFamily),R.fontFamilyPanel.onFontChanged=R.setFont,R.tipGrip=new Fe,R.tipGrip.visual.transform.baseVal.appendItem(H.createTransform()),R.controlBox.appendChild(R.tipGrip.visual),R}return $(n,P),n.prototype.ownsTarget=function(d){return P.prototype.ownsTarget.call(this,d)||this.tipGrip.ownsTarget(d)||this.tip===d},n.prototype.createTip=function(){H.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=H.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},n.prototype.pointerDown=function(d,D){this.state==="new"&&P.prototype.pointerDown.call(this,d,D),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(D)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):P.prototype.pointerDown.call(this,d,D)},n.prototype.pointerUp=function(d){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,P.prototype.pointerUp.call(this,d);else{var D=this.state==="creating";P.prototype.pointerUp.call(this,d),this.setTipPoints(D),this.positionTip()}},n.prototype.manipulate=function(d){if(this.tipMoving){var D=this.unrotatePoint(d);this.tipPosition={x:D.x-this.manipulationStartLeft,y:D.y-this.manipulationStartTop},this.positionTip()}else P.prototype.manipulate.call(this,d)},n.prototype.setBgColor=function(d){this.bgRectangle&&this.tip&&(H.setAttributes(this.bgRectangle,[["fill",d]]),H.setAttributes(this.tip,[["fill",d]])),this.bgColor=d,this.fillColorChanged(d)},n.prototype.getTipPoints=function(){return this.setTipPoints(this.state==="creating"),this.tipBase1Position.x+","+this.tipBase1Position.y+" "+this.tipBase2Position.x+","+this.tipBase2Position.y+" "+this.tipPosition.x+","+this.tipPosition.y},n.prototype.setTipPoints=function(d){d===void 0&&(d=!1);var D=Math.min(this.height/2,15),N=this.height/5;d&&(this.tipPosition={x:D+N/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))?(N=this.width/5,D=Math.min(this.width/2,15),this.tipBase1Position={x:D,y:0},this.tipBase2Position={x:D+N,y:0}):(this.tipBase1Position={x:0,y:D},this.tipBase2Position={x:0,y:D+N}):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))?(N=this.width/5,D=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-D-N,y:0},this.tipBase2Position={x:this.width-D,y:0}):(this.tipBase1Position={x:this.width,y:D},this.tipBase2Position={x:this.width,y:D+N}):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))?(N=this.width/5,D=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-D-N,y:this.height},this.tipBase2Position={x:this.width-D,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-D-N},this.tipBase2Position={x:this.width,y:this.height-D}):R<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(N=this.width/5,D=Math.min(this.width/2,15),this.tipBase1Position={x:D,y:this.height},this.tipBase2Position={x:D+N,y:this.height}):(this.tipBase1Position={x:0,y:this.height-D},this.tipBase2Position={x:0,y:this.height-D-N})},n.prototype.resize=function(d){P.prototype.resize.call(this,d),this.positionTip()},n.prototype.positionTip=function(){H.setAttributes(this.tip,[["points",this.getTipPoints()]]);var d=this.tipGrip.visual.transform.baseVal.getItem(0);d.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(d,0)},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),n.prototype.select=function(){this.positionTip(),P.prototype.select.call(this)},n.prototype.getState=function(){var d=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},P.prototype.getState.call(this));return d.typeName=n.typeName,d},n.prototype.restoreState=function(d){var D=d;this.bgColor=D.bgColor,this.tipPosition=D.tipPosition,P.prototype.restoreState.call(this,d),this.createTip(),this.setTipPoints()},n.prototype.scale=function(d,D){P.prototype.scale.call(this,d,D),this.tipPosition={x:this.tipPosition.x*d,y:this.tipPosition.y*D},this.positionTip()},n.typeName="CalloutMarker",n.title="Callout marker",n.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>',n}(_e),ce=function(P){function n(d,D,N){var R=P.call(this,d,D,N)||this;return R.fillColor="transparent",R.strokeColor="transparent",R.strokeWidth=0,R.strokeDasharray="",R.opacity=1,R.strokeColor=N.defaultColor,R.strokeWidth=N.defaultStrokeWidth,R.strokeDasharray=N.defaultStrokeDasharray,R.fillColor=N.defaultFillColor,R.setStrokeColor=R.setStrokeColor.bind(R),R.setFillColor=R.setFillColor.bind(R),R.setStrokeWidth=R.setStrokeWidth.bind(R),R.setStrokeDasharray=R.setStrokeDasharray.bind(R),R.setOpacity=R.setOpacity.bind(R),R.createVisual=R.createVisual.bind(R),R.strokePanel=new Ie("Line color",z(N.defaultColorSet,["transparent"]),N.defaultColor),R.strokePanel.onColorChanged=R.setStrokeColor,R.fillPanel=new Ie("Fill color",z(N.defaultColorSet,["transparent"]),R.fillColor,X),R.fillPanel.onColorChanged=R.setFillColor,R.strokeWidthPanel=new xe("Line width",N.defaultStrokeWidths,N.defaultStrokeWidth),R.strokeWidthPanel.onWidthChanged=R.setStrokeWidth,R.strokeStylePanel=new Ce("Line style",N.defaultStrokeDasharrays,N.defaultStrokeDasharray),R.strokeStylePanel.onStyleChanged=R.setStrokeDasharray,R.opacityPanel=new W("Opacity",N.defaultOpacitySteps,R.opacity),R.opacityPanel.onOpacityChanged=R.setOpacity,R}return $(n,P),n.prototype.ownsTarget=function(d){return!(!P.prototype.ownsTarget.call(this,d)&&d!==this.visual)},n.prototype.createVisual=function(){this.visual=H.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)},n.prototype.pointerDown=function(d,D){P.prototype.pointerDown.call(this,d,D),this.state==="new"&&(this.createVisual(),this.moveVisual(d),this._state="creating")},n.prototype.manipulate=function(d){P.prototype.manipulate.call(this,d)},n.prototype.resize=function(d){P.prototype.resize.call(this,d),this.setSize()},n.prototype.setSize=function(){P.prototype.setSize.call(this),H.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},n.prototype.pointerUp=function(d){P.prototype.pointerUp.call(this,d),this.setSize()},n.prototype.setStrokeColor=function(d){this.strokeColor=d,this.visual&&H.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(d),this.stateChanged()},n.prototype.setFillColor=function(d){this.fillColor=d,this.visual&&H.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(d),this.stateChanged()},n.prototype.setStrokeWidth=function(d){this.strokeWidth=d,this.visual&&H.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},n.prototype.setStrokeDasharray=function(d){this.strokeDasharray=d,this.visual&&H.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},n.prototype.setOpacity=function(d){this.opacity=d,this.visual&&H.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var d=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},P.prototype.getState.call(this));return d.typeName=n.typeName,d},n.prototype.restoreState=function(d){var D=d;this.fillColor=D.fillColor,this.strokeColor=D.strokeColor,this.strokeWidth=D.strokeWidth,this.strokeDasharray=D.strokeDasharray,this.opacity=D.opacity,this.createVisual(),P.prototype.restoreState.call(this,d),this.setSize()},n.prototype.scale=function(d,D){P.prototype.scale.call(this,d,D),this.setSize()},n.typeName="EllipseMarker",n.title="Ellipse marker",n.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>',n}(ue),Pe=function(P){function n(d,D,N){return P.call(this,d,D,N)||this}return $(n,P),Object.defineProperty(n.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),n.prototype.ownsTarget=function(d){return!(!P.prototype.ownsTarget.call(this,d)&&d!==this.tip1&&d!==this.tip2)},n.prototype.createTips=function(){this.tip1=H.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(H.createTransform()),this.visual.appendChild(this.tip1),this.tip2=H.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(H.createTransform()),this.visual.appendChild(this.tip2)},n.prototype.pointerDown=function(d,D){P.prototype.pointerDown.call(this,d,D),this.state==="creating"&&this.createTips()},n.prototype.adjustVisual=function(){if(P.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(H.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()]]),H.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 d=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),D=this.tip1.transform.baseVal.getItem(0);D.setRotate(d,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(D,0);var N=this.tip2.transform.baseVal.getItem(0);N.setRotate(d+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(N,0)}},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var d=P.prototype.getState.call(this);return d.typeName=n.typeName,d},n.prototype.restoreState=function(d){P.prototype.restoreState.call(this,d),this.createTips(),this.adjustVisual()},n.typeName="MeasurementMarker",n.title="Measurement marker",n.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>',n}(Be),He=function(P){function n(d,D,N){var R=P.call(this,d,D,N)||this;return R.strokePanel.colors=N.defaultColorSet,R.fillColor="transparent",R}return $(n,P),Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var d=P.prototype.getState.call(this);return d.typeName=n.typeName,d},n.typeName="EllipseFrameMarker",n.title="Ellipse frame marker",n.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>',n}(ce),$e=function(){function P(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(P.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),P.prototype.addUndoStep=function(n){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(n)||(this.undoStack.push(n),JSON.stringify(this.lastRedoStep)!==JSON.stringify(n)&&this.redoStack.splice(0,this.redoStack.length))},P.prototype.replaceLastUndoStep=function(n){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=n)},P.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},P.prototype.undo=function(){if(this.undoStack.length>1){var n=this.undoStack.pop();return n!==void 0&&this.redoStack.push(n),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},P.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},P}(),ze=function(P){function n(d,D,N){var R=P.call(this,d,D,N)||this;return R.strokeColor="transparent",R.strokeWidth=0,R.strokeDasharray="",R.curveX=0,R.curveY=0,R.manipulationStartCurveX=0,R.manipulationStartCurveY=0,R.setStrokeColor=R.setStrokeColor.bind(R),R.setStrokeWidth=R.setStrokeWidth.bind(R),R.setStrokeDasharray=R.setStrokeDasharray.bind(R),R.positionGrips=R.positionGrips.bind(R),R.addControlGrips=R.addControlGrips.bind(R),R.adjustVisual=R.adjustVisual.bind(R),R.setupControlBox=R.setupControlBox.bind(R),R.resize=R.resize.bind(R),R.strokeColor=N.defaultColor,R.strokeWidth=N.defaultStrokeWidth,R.strokeDasharray=N.defaultStrokeDasharray,R.strokePanel=new Ie("Line color",N.defaultColorSet,N.defaultColor),R.strokePanel.onColorChanged=R.setStrokeColor,R.strokeWidthPanel=new xe("Line width",N.defaultStrokeWidths,N.defaultStrokeWidth),R.strokeWidthPanel.onWidthChanged=R.setStrokeWidth,R.strokeStylePanel=new Ce("Line style",N.defaultStrokeDasharrays,N.defaultStrokeDasharray),R.strokeStylePanel.onStyleChanged=R.setStrokeDasharray,R}return $(n,P),n.prototype.ownsTarget=function(d){return!(!P.prototype.ownsTarget.call(this,d)&&d!==this.visual&&d!==this.selectorCurve&&d!==this.visibleCurve&&!this.curveGrip.ownsTarget(d))},n.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},n.prototype.createVisual=function(){this.visual=H.createGroup(),this.selectorCurve=H.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=H.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)},n.prototype.pointerDown=function(d,D){P.prototype.pointerDown.call(this,d,D),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=d.x,this.curveY=d.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(D)&&(this.activeGrip=this.curveGrip,this._state="resize")},n.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),H.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),H.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),H.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},n.prototype.setupControlBox=function(){P.prototype.setupControlBox.call(this),this.curveControlLine1=H.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=H.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)},n.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,P.prototype.addControlGrips.call(this)},n.prototype.positionGrips=function(){P.prototype.positionGrips.call(this);var d=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-d/2,this.curveY-d/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()))},n.prototype.manipulate=function(d){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+d.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+d.y-this.manipulationStartY),P.prototype.manipulate.call(this,d)},n.prototype.resize=function(d){this.activeGrip===this.curveGrip&&(this.curveX=d.x,this.curveY=d.y),P.prototype.resize.call(this,d),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},n.prototype.setStrokeColor=function(d){this.strokeColor=d,this.adjustVisual(),this.colorChanged(d)},n.prototype.setStrokeWidth=function(d){this.strokeWidth=d,this.adjustVisual()},n.prototype.setStrokeDasharray=function(d){this.strokeDasharray=d,this.adjustVisual()},n.prototype.scale=function(d,D){this.curveX=this.curveX*d,this.curveY=this.curveY*D,P.prototype.scale.call(this,d,D)},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var d=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},P.prototype.getState.call(this));return d.typeName=n.typeName,d},n.prototype.restoreState=function(d){P.prototype.restoreState.call(this,d);var D=d;this.strokeColor=D.strokeColor,this.strokeWidth=D.strokeWidth,this.strokeDasharray=D.strokeDasharray,this.curveX=D.curveX,this.curveY=D.curveY,this.createVisual(),this.adjustVisual()},n.typeName="CurveMarker",n.title="Curve marker",n.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>',n}(Ne),Ze=function(){function P(n,d){d===void 0&&(d=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=n,this.cancelable=d}return Object.defineProperty(P.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),P.prototype.preventDefault=function(){this._defaultPrevented=!0},P}(),et=function(P){function n(d,D,N){var R=P.call(this,d,!1)||this;return R.dataUrl=D,R.state=N,R}return $(n,P),n}(Ze),Xe=function(P){function n(d,D,N){N===void 0&&(N=!1);var R=P.call(this,d,N)||this;return R.marker=D,R}return $(n,P),n}(Ze),mt=function(){function P(){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 P.prototype.addEventListener=function(n,d){this[n].push(d)},P.prototype.removeEventListener=function(n,d){var D=this[n].indexOf(d);D>-1&&this[n].splice(D,1)},P}(),rt=function(){function P(n){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new ye,this._isOpen=!1,this.undoRedoManager=new $e,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 mt,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=P.instanceCounter++,this.styles=new we(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=n,this.targetRoot=document.body,this.width=n.clientWidth,this.height=n.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(P.prototype,"ALL_MARKER_TYPES",{get:function(){return[Se,re,te,_e,He,ce,G,oe,Pe,j,Be,ze]},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[Se,re,te,_e,ce,G,oe]},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"BASIC_MARKER_TYPES",{get:function(){return[Se,re,te,_e,G]},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(n){var d=this;this._availableMarkerTypes.splice(0),n.forEach(function(D){if(typeof D=="string"){var N=d.ALL_MARKER_TYPES.find(function(R){return R.typeName===D});N!==void 0&&d._availableMarkerTypes.push(N)}else d._availableMarkerTypes.push(D)})},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(n){this._zoomLevel=n,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(P.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),P.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),me.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},P.prototype.show=function(){var n=this;this.styles.styleSheetRoot===void 0&&Oe.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=Oe.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(d){return d(new Ze(n))})},P.prototype.render=function(){return Y(this,void 0,void 0,function(){var n;return ne(this,function(d){switch(d.label){case 0:return this.setCurrentMarker(),(n=new Le).naturalSize=this.renderAtNaturalSize,n.imageType=this.renderImageType,n.imageQuality=this.renderImageQuality,n.markersOnly=this.renderMarkersOnly,n.width=this.renderWidth,n.height=this.renderHeight,[4,n.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return d.sent(),[4,n.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,d.sent()]}})})},P.prototype.close=function(n){var d=this;if(n===void 0&&(n=!1),this.isOpen){var D=!1;n||this.eventListeners.beforeclose.forEach(function(N){var R=new Ze(d,!0);N(R),R.defaultPrevented&&(D=!0)}),D||(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.settings.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),this.eventListeners.close.forEach(function(N){return N(new Ze(d))}),this.detachEvents(),this._isOpen=!1)}},P.prototype.addMarkersToToolbar=function(){for(var n,d=[],D=0;D<arguments.length;D++)d[D]=arguments[D];(n=this._availableMarkerTypes).push.apply(n,d)},P.prototype.addRenderEventListener=function(n){this.addEventListener("render",function(d){n(d.dataUrl,d.state)})},P.prototype.removeRenderEventListener=function(n){},P.prototype.addCloseEventListener=function(n){this.addEventListener("close",function(){n()})},P.prototype.removeCloseEventListener=function(n){},P.prototype.setupResizeObserver=function(){var n=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){n.resize(n.target.clientWidth,n.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return n.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},P.prototype.onPopupTargetResize=function(){var n=1*this.target.clientWidth/this.target.clientHeight,d=this.editorCanvas.clientWidth/n>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*n:this.editorCanvas.clientWidth,D=d<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/n;this.resize(d,D)},P.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},P.prototype.resize=function(n,d){this._isResizing=!0;var D=n/this.imageWidth,N=d/this.imageHeight;this.imageWidth=Math.round(n),this.imageHeight=Math.round(d),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px",this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.settings.displayMode!=="popup"?this.coverDiv.style.width=this.imageWidth.toString()+"px":(this.setTopLeft(),this.positionMarkerImage()),this.toolbar!==void 0&&this.toolbar.adjustLayout(),this.positionLogo(),this.scaleMarkers(D,N),this._isResizing=!1},P.prototype.scaleMarkers=function(n,d){var D,N=this;this._currentMarker&&this._currentMarker instanceof _e?this._currentMarker.scale(n,d):(D=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(R){R!==N._currentMarker&&R.scale(n,d)}),D!==void 0&&this.setCurrentMarker(D)},P.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"},P.prototype.setTopLeft=function(){var n=this.editingTarget.getBoundingClientRect(),d=this.editorCanvas.getBoundingClientRect();this.left=n.left-d.left,this.top=n.top-d.top},P.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)},P.prototype.addDefs=function(){for(var n,d=[],D=0;D<arguments.length;D++)d[D]=arguments[D];this.defs=H.createDefs(),this.addDefsToImage(),(n=this.defs).append.apply(n,d)},P.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},P.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)},P.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},P.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},P.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)},P.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},P.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)},P.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 n=document.createElement("a");n.href="https://markerjs.com/",n.target="_blank",n.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>',n.title="Powered by marker.js",n.style.display="grid",n.style.alignItems="center",n.style.justifyItems="center",n.style.padding="3px",n.style.width="20px",n.style.height="20px",this.logoUI.appendChild(n),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},P.prototype.positionLogo=function(){this.logoUI&&(this.uiStyleSettings.logoPosition!=="right"?this.logoUI.style.left=this.markerImageHolder.offsetLeft+10+"px":this.logoUI.style.left=this.markerImageHolder.offsetLeft+this.markerImageHolder.offsetWidth-this.logoUI.clientWidth-10+"px",this.logoUI.style.top=this.markerImageHolder.offsetTop+this.markerImageHolder.offsetHeight-this.logoUI.clientHeight-10+"px")},P.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"},P.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},P.prototype.showUI=function(){switch(this.settings.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.style.visibility=this._silentRenderMode?"hidden":"visible",this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.coverDiv.style.userSelect="none",this.settings.displayMode){case"inline":this.coverDiv.style.position="absolute";var n=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=n+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px",this.coverDiv.style.width=this.target.offsetWidth.toString()+"px",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.settings.displayMode==="popup"?this.settings.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.toolbar=new pe(this.uiDiv,this.settings.displayMode,this._availableMarkerTypes,this.uiStyleSettings,this.styles),this.toolbar.addButtonClickListener(this.toolbarButtonClicked),this.toolbar.show(this._silentRenderMode||this.uiStyleSettings.hideToolbar?"hidden":"visible"),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.settings.displayMode==="popup"&&(this.contentDiv.style.backgroundColor=this.uiStyleSettings.canvasBackgroundColor,this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.uiStyleSettings.toolbarHeight+"px",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.settings.popupMargin+"px)"),this.contentDiv.style.overflow="auto",this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.settings.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.editorCanvas.style.transformOrigin="left top",this.editorCanvas.style.transform="scale("+this.zoomLevel+")",this.contentDiv.appendChild(this.editorCanvas),this.editingTarget=this.target instanceof HTMLImageElement?document.createElement("img"):document.createElement("canvas"),this.target.getClientRects().item(0).y<this.styles.settings.toolbarHeight&&(this.editingTarget.style.marginTop=this.target.offsetTop-this.styles.settings.toolbarHeight+"px"),this.editorCanvas.appendChild(this.editingTarget),this.toolbox=new Ee(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},P.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},P.prototype.removeMarker=function(n){this.markerImage.removeChild(n.container),this.markers.indexOf(n)>-1&&this.markers.splice(this.markers.indexOf(n),1),n.dispose()},P.prototype.switchToSelectMode=function(){this.mode="select",this.hideNotesEditor(),this._currentMarker!==void 0&&(this._currentMarker.state!=="new"?this._currentMarker.select():(this.removeMarker(this._currentMarker),this.setCurrentMarker(),this.markerImage.style.cursor="default"),this.addUndoStep())},P.prototype.toolbarButtonClicked=function(n,d){if(n==="marker"&&d!==void 0)this.createNewMarker(d);else if(n==="action")switch(d){case"select":this.switchToSelectMode(),this.switchToSelectMode();break;case"delete":this.deleteSelectedMarker();break;case"clear":this.clear();break;case"undo":this.undo();break;case"redo":this.redo();break;case"zoom":this.stepZoom();break;case"zoom-out":this.zoomLevel=1;break;case"notes":this.notesArea===void 0?(this.switchToSelectMode(),this.zoomLevel=1,this.showNotesEditor()):this.switchToSelectMode();break;case"close":this.close();break;case"render":this.switchToSelectMode(),this.startRenderAndClose()}},P.prototype.deleteSelectedMarker=function(){var n=this;if(this._currentMarker!==void 0){var d=!1;if(this.eventListeners.markerbeforedelete.forEach(function(N){var R=new Xe(n,n._currentMarker,!0);N(R),R.defaultPrevented&&(d=!0)}),!d){var D=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(N){return N(new Xe(n,D))})}}},P.prototype.clear=function(){var n=this,d=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(ee){var Re=new Xe(n,void 0,!0);ee(Re),Re.defaultPrevented&&(d=!0)}),!d)){this.setCurrentMarker();for(var D=function(ee){var Re=N.markers[ee];N.setCurrentMarker(N.markers[ee]),N._currentMarker.dispose(),N.markerImage.removeChild(N._currentMarker.container),N.markers.splice(N.markers.indexOf(N._currentMarker),1),N.eventListeners.markerdelete.forEach(function(Ue){return Ue(new Xe(n,Re))})},N=this,R=this.markers.length-1;R>=0;R--)D(R);this.addUndoStep()}},Object.defineProperty(P.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),P.prototype.showNotesEditor=function(){var n;this._currentMarker!==void 0&&(this.overlayContainer.innerHTML="",this.notesArea=document.createElement("textarea"),this.notesArea.className=this.uiStyleSettings.notesAreaStyleClassName,this.notesArea.style.pointerEvents="auto",this.notesArea.style.alignSelf="stretch",this.notesArea.style.width="100%",this.notesArea.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.notesArea.value=(n=this._currentMarker.notes)!==null&&n!==void 0?n:"",this.overlayContainer.appendChild(this.notesArea))},P.prototype.hideNotesEditor=function(){this.isNotesAreaOpen&&(this._currentMarker!==void 0&&(this._currentMarker.notes=this.notesArea.value.trim()!==""?this.notesArea.value:void 0),this.overlayContainer.removeChild(this.notesArea),this.notesArea=void 0)},P.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},P.prototype.addUndoStep=function(){var n=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var d=this.getState(),D=this.undoRedoManager.getLastUndoStep();if(!D||D.width===d.width&&D.height===d.height){var N=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(d),N<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(R){return R(new Ze(n))})}else this.undoRedoManager.replaceLastUndoStep(d),this.eventListeners.statechange.forEach(function(R){return R(new Ze(n))})}},P.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},P.prototype.undoStep=function(){var n=this,d=this.undoRedoManager.undo();d!==void 0&&(this.restoreState(d),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(D){return D(new Ze(n))}))},P.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},P.prototype.redoStep=function(){var n=this,d=this.undoRedoManager.redo();d!==void 0&&(this.restoreState(d),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(D){return D(new Ze(n))}))},P.prototype.stepZoom=function(){var n=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=n<this.zoomSteps.length-1?this.zoomSteps[n+1]:this.zoomSteps[0]},P.prototype.panTo=function(n){this.contentDiv.scrollBy({left:this.prevPanPoint.x-n.x,top:this.prevPanPoint.y-n.y}),this.prevPanPoint=n},P.prototype.startRenderAndClose=function(){return Y(this,void 0,void 0,function(){var n,d,D=this;return ne(this,function(N){switch(N.label){case 0:return[4,this.render()];case 1:return n=N.sent(),d=this.getState(),this.eventListeners.render.forEach(function(R){return R(new et(D,n,d))}),this.close(!0),[2]}})})},P.prototype.getState=function(n){n===!0&&this.setCurrentMarker();var d={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(D){return d.markers.push(D.getState())}),d},P.prototype.restoreState=function(n){var d=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);n.markers.forEach(function(D){var N=d._availableMarkerTypes.find(function(ee){return ee.typeName===D.typeName});if(N!==void 0){var R=d.addNewMarker(N);R.restoreState(D),d.markers.push(R)}}),n.width&&n.height&&(n.width!==this.imageWidth||n.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/n.width,this.imageHeight/n.height),this.eventListeners.restorestate.forEach(function(D){return D(new Ze(d))})},P.prototype.addNewMarker=function(n){var d=H.createGroup();return this.markerImage.appendChild(d),new n(d,this.overlayContainer,this.settings)},P.prototype.createNewMarker=function(n){var d,D=this;(d=typeof n=="string"?this._availableMarkerTypes.find(function(N){return N.typeName===n}):n)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(d),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(d.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(N){return N(new Xe(D,D._currentMarker))}))},P.prototype.markerCreated=function(n){var d=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(n),this.setCurrentMarker(n),n instanceof re&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(re):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(D){return D(new Xe(d,d._currentMarker))})},P.prototype.colorChanged=function(n){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=n,this.settings.defaultStrokeColor=n)},P.prototype.fillColorChanged=function(n){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=n)},P.prototype.markerStateChanged=function(n){var d=this;this.eventListeners.markerchange.forEach(function(D){return D(new Xe(d,n))})},P.prototype.setCurrentMarker=function(n){var d=this;this._currentMarker!==n&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(D){return D(new Xe(d,d._currentMarker))})),this._currentMarker=n,this._currentMarker===void 0||this._currentMarker.isSelected||(this._currentMarker.state!=="new"&&this._currentMarker.select(),this.toolbar.setCurrentMarker(this._currentMarker),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this._isResizing||this.eventListeners.markerselect.forEach(function(D){return D(new Xe(d,d._currentMarker))}))},P.prototype.onPointerDown=function(n){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||n.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var d=this.markers.find(function(D){return D.ownsTarget(n.target)});d!==void 0?(this.setCurrentMarker(d),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(n.clientX,n.clientY),n.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:n.clientX,y:n.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(n.clientX,n.clientY))},P.prototype.onDblClick=function(n){if(this._isFocused||this.focus(),this.mode==="select"){var d=this.markers.find(function(D){return D.ownsTarget(n.target)});d!==void 0&&d!==this._currentMarker&&this.setCurrentMarker(d),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(n.clientX,n.clientY),n.target):this.setCurrentMarker()}},P.prototype.onPointerMove=function(n){this.touchPoints!==1&&n.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||n.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(n.clientX,n.clientY)):this.zoomLevel>1&&this.panTo({x:n.clientX,y:n.clientY}))},P.prototype.onPointerUp=function(n){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(n.clientX,n.clientY)),this.isDragging=!1,this.addUndoStep()},P.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},P.prototype.onKeyUp=function(n){this._currentMarker===void 0||this.notesArea!==void 0||n.key!=="Delete"&&n.key!=="Backspace"||this.deleteSelectedMarker()},P.prototype.clientToLocalCoordinates=function(n,d){var D=this.markerImage.getBoundingClientRect();return{x:(n-D.left)/this.zoomLevel,y:(d-D.top)/this.zoomLevel}},P.prototype.onWindowResize=function(){this.positionUI()},P.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var n=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=n+"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()},P.prototype.addLicenseKey=function(n){me.addKey(n)},P.prototype.addEventListener=function(n,d){this.eventListeners.addEventListener(n,d)},P.prototype.removeEventListener=function(n,d){this.eventListeners.removeEventListener(n,d)},P.prototype.renderState=function(n){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(n),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(P.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),P.prototype.focus=function(){var n=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(d){return d(new Ze(n))}))},P.prototype.blur=function(){var n=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(d){return d(new Ze(n))}))},P.instanceCounter=0,P}();/* **********************************
|
|
cropro version 1.2.0
|
|
@license SEE LICENSE IN LICENSE
|
|
|
|
copyright Alan Mendelevich
|
|
see README and LICENSE for details
|
|
********************************** *//*! *****************************************************************************
|
|
Copyright (c) Microsoft Corporation.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
***************************************************************************** */var vt=function(P,n){return(vt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,D){d.__proto__=D}||function(d,D){for(var N in D)Object.prototype.hasOwnProperty.call(D,N)&&(d[N]=D[N])})(P,n)};function ct(P,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function d(){this.constructor=P}vt(P,n),P.prototype=n===null?Object.create(n):(d.prototype=n.prototype,new d)}function qe(P,n,d,D){return new(d||(d=Promise))(function(N,R){function ee(je){try{Ue(D.next(je))}catch(Ae){R(Ae)}}function Re(je){try{Ue(D.throw(je))}catch(Ae){R(Ae)}}function Ue(je){var Ae;je.done?N(je.value):(Ae=je.value,Ae instanceof d?Ae:new d(function(Ge){Ge(Ae)})).then(ee,Re)}Ue((D=D.apply(P,n||[])).next())})}function yt(P,n){var d,D,N,R,ee={label:0,sent:function(){if(1&N[0])throw N[1];return N[1]},trys:[],ops:[]};return R={next:Re(0),throw:Re(1),return:Re(2)},typeof Symbol=="function"&&(R[Symbol.iterator]=function(){return this}),R;function Re(Ue){return function(je){return function(Ae){if(d)throw new TypeError("Generator is already executing.");for(;ee;)try{if(d=1,D&&(N=2&Ae[0]?D.return:Ae[0]?D.throw||((N=D.return)&&N.call(D),0):D.next)&&!(N=N.call(D,Ae[1])).done)return N;switch(D=0,N&&(Ae=[2&Ae[0],N.value]),Ae[0]){case 0:case 1:N=Ae;break;case 4:return ee.label++,{value:Ae[1],done:!1};case 5:ee.label++,D=Ae[1],Ae=[0];continue;case 7:Ae=ee.ops.pop(),ee.trys.pop();continue;default:if(!(N=ee.trys,(N=N.length>0&&N[N.length-1])||Ae[0]!==6&&Ae[0]!==2)){ee=0;continue}if(Ae[0]===3&&(!N||Ae[1]>N[0]&&Ae[1]<N[3])){ee.label=Ae[1];break}if(Ae[0]===6&&ee.label<N[1]){ee.label=N[1],N=Ae;break}if(N&&ee.label<N[2]){ee.label=N[2],ee.ops.push(Ae);break}N[2]&&ee.ops.pop(),ee.trys.pop();continue}Ae=n.call(P,ee)}catch(Ge){Ae=[6,Ge],D=0}finally{d=N=0}if(5&Ae[0])throw Ae[1];return{value:Ae[0]?Ae[1]:void 0,done:!0}}([Ue,je])}}}var bt=function(){function P(){}return P.addKey=function(n){P.key=n},Object.defineProperty(P,"isLicensed",{get:function(){return!!P.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(P.key)},enumerable:!1,configurable:!0}),P}(),Ve=function(){function P(){}return P.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},P.setAttributes=function(n,d){for(var D=0,N=d;D<N.length;D++){var R=N[D],ee=R[0],Re=R[1];n.setAttribute(ee,Re)}},P.createRect=function(n,d,D){var N=document.createElementNS("http://www.w3.org/2000/svg","rect");return N.setAttribute("width",n.toString()),N.setAttribute("height",d.toString()),D&&P.setAttributes(N,D),N},P.createLine=function(n,d,D,N,R){var ee=document.createElementNS("http://www.w3.org/2000/svg","line");return ee.setAttribute("x1",n.toString()),ee.setAttribute("y1",d.toString()),ee.setAttribute("x2",D.toString()),ee.setAttribute("y2",N.toString()),R&&P.setAttributes(ee,R),ee},P.createPolygon=function(n,d){var D=document.createElementNS("http://www.w3.org/2000/svg","polygon");return D.setAttribute("points",n),d&&P.setAttributes(D,d),D},P.createCircle=function(n,d){var D=document.createElementNS("http://www.w3.org/2000/svg","circle");return D.setAttribute("cx",(n/2).toString()),D.setAttribute("cy",(n/2).toString()),D.setAttribute("r",n.toString()),d&&P.setAttributes(D,d),D},P.createEllipse=function(n,d,D){var N=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return N.setAttribute("cx",(n/2).toString()),N.setAttribute("cy",(d/2).toString()),N.setAttribute("rx",(n/2).toString()),N.setAttribute("ry",(d/2).toString()),D&&P.setAttributes(N,D),N},P.createGroup=function(n){var d=document.createElementNS("http://www.w3.org/2000/svg","g");return n&&P.setAttributes(d,n),d},P.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},P.createMarker=function(n,d,D,N,R,ee,Re){var Ue=document.createElementNS("http://www.w3.org/2000/svg","marker");return P.setAttributes(Ue,[["id",n],["orient",d],["markerWidth",D.toString()],["markerHeight",N.toString()],["refX",R.toString()],["refY",ee.toString()]]),Ue.appendChild(Re),Ue},P.createText=function(n){var d=document.createElementNS("http://www.w3.org/2000/svg","text");return d.setAttribute("x","0"),d.setAttribute("y","0"),n&&P.setAttributes(d,n),d},P.createTSpan=function(n,d){var D=document.createElementNS("http://www.w3.org/2000/svg","tspan");return D.textContent=n,d&&P.setAttributes(D,d),D},P.createImage=function(n){var d=document.createElementNS("http://www.w3.org/2000/svg","image");return n&&P.setAttributes(d,n),d},P.createPoint=function(n,d){var D=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return D.x=n,D.y=d,D},P.createPath=function(n,d){var D=document.createElementNS("http://www.w3.org/2000/svg","path");return D.setAttribute("d",n),d&&P.setAttributes(D,d),D},P.createElement=function(n,d){var D=document.createElementNS("http://www.w3.org/2000/svg",n);return d&&P.setAttributes(D,d),D},P.getHollowRectanglePath=function(n,d,D,N,R,ee,Re,Ue){return"M"+n+","+d+"V"+(d+N)+"H"+(n+D)+"V"+d+"H"+R+"V"+ee+"H"+(R+Re)+"V"+(ee+Ue)+"H"+R+"V"+d+"Z"},P}(),wt=function(){function P(n){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+n+"_"}return Object.defineProperty(P.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(P.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(P.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),P.prototype.addClass=function(n){return this.styleSheet===void 0&&this.addStyleSheet(),n.name=""+this.classNamePrefix+n.localName,this.classes.push(n),this.styleSheet.sheet.insertRule("."+n.name+" {"+n.style+"}",this.styleSheet.sheet.cssRules.length),n},P.prototype.addRule=function(n){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(n),this.styleSheet.sheet.insertRule(n.selector+" {"+n.style+"}",this.styleSheet.sheet.cssRules.length)},P.prototype.addStyleSheet=function(){var n;this.styleSheet=document.createElement("style"),((n=this.styleSheetRoot)!==null&&n!==void 0?n:document.head).appendChild(this.styleSheet),this.addRule(new at("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new at("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new at("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new ut("_fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new ut("_fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},P.prototype.removeStyleSheet=function(){var n;this.styleSheet&&(((n=this.styleSheetRoot)!==null&&n!==void 0?n:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},P}(),at=function(P,n){this.selector=P,this.style=n},ut=function(P,n){this.localName=P,this.style=n},At=function(){function P(){this.blocks=[],this.display=""}return P.prototype.addButtonBlock=function(n){n.className=this.blockClassName,n.buttonClassName=this.buttonClassName,n.buttonColorsClassName=this.buttonColorsClassName,n.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(n)},P.prototype.addElementBlock=function(n){n.className===void 0&&(n.className=this.blockClassName),this.blocks.push(n)},P.prototype.getUI=function(){var n=document.createElement("div");return n.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,n.style.display=this.display,this.blocks.forEach(function(d){return n.appendChild(d.getUI())}),n},P}(),St=function(){function P(){}return P.prototype.getUI=function(){var n=document.createElement("div");if(n.className=this.className,this.minWidth!==void 0&&(n.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":n.style.justifyContent="flex-start";break;case"center":n.style.justifyContent="center";break;case"end":n.style.justifyContent="flex-end"}return n.style.whiteSpace="nowrap",n},P}(),Rt=function(P){function n(){var d=P!==null&&P.apply(this,arguments)||this;return d.buttons=[],d}return ct(n,P),n.prototype.addButton=function(d){d.className=this.buttonClassName,d.colorsClassName=this.buttonColorsClassName,d.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(d)},n.prototype.getUI=function(){var d=P.prototype.getUI.call(this);return this.buttons.forEach(function(D){return d.appendChild(D.getUI())}),d},n}(St),it=function(){function P(n,d){this._isActive=!1,this._isHidden=!1,this._icon=n,this.title=d,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(P.prototype,"icon",{get:function(){return this._icon},set:function(n){this._icon=n,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isActive",{get:function(){return this._isActive},set:function(n){this._isActive=n,this.adjustClassName()},enumerable:!1,configurable:!0}),P.prototype.getUI=function(){var n=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 n.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},P.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,"")))},P.prototype.hide=function(){this._isHidden=!0},P}(),Qe=function(P){function n(){var d=P!==null&&P.apply(this,arguments)||this;return d.elements=[],d}return ct(n,P),n.prototype.addElement=function(d){this.elements.push(d)},n.prototype.getUI=function(){var d=P.prototype.getUI.call(this);return this.elements.forEach(function(D){return d.appendChild(D)}),d},n}(St),Ye=function(){function P(n,d){this.horizontal=n,this.vertical=d}return Object.defineProperty(P.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),P.prototype.getVerticalLength=function(n){return n/this.ratio},P.prototype.getHorizontalLength=function(n){return n*this.ratio},P}(),ot=function(){function P(){}return P.getIcon=function(n,d){if(n>0&&d>0){var D=new Ye(n,d),N=D.ratio>=1?20:D.getHorizontalLength(20),R=D.ratio<1?20:D.getVerticalLength(20),ee=document.createElementNS("http://www.w3.org/2000/svg","svg");ee.setAttribute("xmlns","http://www.w3.org/2000/svg"),ee.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(ee);var Re=Ve.createDefs();ee.appendChild(Re);var Ue=Ve.createElement("clipPath",[["id","text-bg-clip"]]);Re.appendChild(Ue);var je=Ve.createPath(Ve.getHollowRectanglePath((24-N)/2,(24-R)/2,N,R,(24-N)/2+2,(24-R)/2+2,N-4,R-4));ee.appendChild(je);var Ae=Ve.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Ae.appendChild(Ve.createTSpan(n+":"+d)),ee.appendChild(Ae);var Ge=Ae.getBBox();Ve.setAttributes(Ae,[["x",((24-Ge.width)/2).toString()],["y",((24-Ge.height)/2-Ge.y).toString()]]);var Ke=Ve.createPath(Ve.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(Ge.width))/2,(24-Math.ceil(Ge.height))/2,Math.ceil(Ge.width),Math.ceil(Ge.height)));return Ue.appendChild(Ke),Ve.setAttributes(je,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(ee),ee.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>'},P}(),dt=function(P){function n(d,D,N){var R=P.call(this,d,D)||this;return R.isDropdownOpen=!1,R.onClick=R.dropdownButtonClicked,R.dropdownButtons=N,R}return ct(n,P),n.prototype.setupDropdown=function(){var d=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(D){D.className=d.className,D.colorsClassName=d.colorsClassName,d.dropdownBlock.appendChild(D.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},n.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},n.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},n.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},n.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},n.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},n}(it),tt=function(){function P(n,d){this.GRIP_SIZE=10,this.color=n,this.fillColor=d,this.visual=Ve.createGroup(),this.visual.appendChild(Ve.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(Ve.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return P.prototype.ownsTarget=function(n){return n===this.visual||n===this.visual.childNodes[0]||n===this.visual.childNodes[1]},P.prototype.setCenter=function(n,d){this.visual.childNodes.forEach(function(D){return Ve.setAttributes(D,[["cx",n.toString()],["cy",d.toString()]])})},P}(),st=function(){function P(n,d,D,N){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=n,this.canvasHeight=d,this.margin=D,this.container=N,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(P.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(n){this._aspectRatio=n,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(n){this._isGridVisible=n,this.gridContainer&&Ve.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(n){this._zoomFactor=n,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),P.prototype.open=function(){var n=this;this.cropShadeElement=Ve.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=Ve.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var d=0;d<this.numberOfGridLines;d++)this.horizontalGridLines.push(Ve.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(Ve.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(D){return n.gridContainer.appendChild(D)}),this.verticalGridLines.forEach(function(D){return n.gridContainer.appendChild(D)}),this.cropRectElement=Ve.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new tt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new tt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new tt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new tt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},P.prototype.setCropRectangle=function(n){this.cropRect=n;var d=Object.assign({},this.cropRect);this.zoomFactor!==1&&(d.width=this.cropRect.width*this.zoomFactor,d.height=this.cropRect.height*this.zoomFactor,d.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-d.width/2,d.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-d.height/2),Ve.setAttributes(this.cropRectElement,[["x",d.x.toString()],["y",d.y.toString()],["width",d.width.toString()],["height",d.height.toString()]]);var D=d.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(R,ee){var Re=d.y+D*(ee+1);Ve.setAttributes(R,[["x1",""+d.x],["y1",""+Re],["x2",""+(d.x+d.width)],["y2",""+Re]])});var N=d.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(R,ee){var Re=d.x+N*(ee+1);Ve.setAttributes(R,[["x1",""+Re],["y1",""+d.y],["x2",""+Re],["y2",""+(d.y+d.height)]])}),Ve.setAttributes(this.cropShadeElement,[["d",Ve.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,d.x,d.y,d.width,d.height)]]),this.topLeftGrip.setCenter(d.x,d.y),this.topRightGrip.setCenter(d.x+d.width,d.y),this.bottomLeftGrip.setCenter(d.x,d.y+d.height),this.bottomRightGrip.setCenter(d.x+d.width,d.y+d.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},P.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)},P.prototype.clientToLocalCoordinates=function(n,d){var D=this.container.getBoundingClientRect();return{x:n-D.left+this.margin,y:d-D.top+this.margin}},P.prototype.onPointerDown=function(n){this.container.setPointerCapture(n.pointerId),this.previousPoint=this.clientToLocalCoordinates(n.clientX,n.clientY),this.cropRectElement===n.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(n.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(n.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(n.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(n.target)&&(this.activeGrip=this.bottomRightGrip)},P.prototype.onPointerMove=function(n){if(this.isMoving)this.move(this.clientToLocalCoordinates(n.clientX,n.clientY));else if(this.activeGrip){var d=this.clientToLocalCoordinates(n.clientX,n.clientY);this.resize(d)}n.preventDefault()},P.prototype.onPointerUp=function(n){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(n.pointerId)},P.prototype.move=function(n){var d=n.x-this.previousPoint.x,D=n.y-this.previousPoint.y;this.zoomFactor!==1&&(d=-d/this.zoomFactor,D=-D/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+d),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+D),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=n},P.prototype.resize=function(n){var d=Object.assign({},this.cropRect),D=n.x-this.previousPoint.x,N=n.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:d.x+D<this.margin&&(D=this.margin-d.x),d.x+=D,d.width=this.cropRect.x+this.cropRect.width-d.x;break;case this.bottomRightGrip:case this.topRightGrip:d.width+D>this.canvasWidth*this.zoomFactor&&(D=this.canvasWidth*this.zoomFactor-d.width),d.width+=D}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(d.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(D),d.height=this.aspectRatio.getVerticalLength(d.width)):(d.y+=N,d.height=this.cropRect.y+this.cropRect.height-d.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?d.height=this.aspectRatio.getVerticalLength(d.width):d.height+=N}d.width<10&&(d.x=this.cropRect.x,d.width=10),d.height<10&&(d.y=this.cropRect.y,d.height=10),this.previousPoint=n,d.x>=this.margin&&d.y>=this.margin&&d.x-this.margin+d.width<=this.canvasWidth&&d.y-this.margin+d.height<=this.canvasHeight&&(this.cropRect=d,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},P.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var n=this.cropRect.x+this.cropRect.width/2,d=this.cropRect.y+this.cropRect.height/2,D=this.aspectRatio.getHorizontalLength(this.cropRect.height),N=this.aspectRatio.getVerticalLength(this.cropRect.width);D/this.canvasWidth<N/this.canvasHeight?this.cropRect.width=D:this.cropRect.height=N,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=n-this.cropRect.width/2,this.cropRect.y=d-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)}},P.prototype.getRescaledRect=function(n,d,D,N,R,ee){var Re=D/n,Ue=N/d;return{x:(R.x-ee)*Re+ee,y:(R.y-ee)*Ue+ee,width:R.width*Re,height:R.height*Ue}},P.prototype.scaleCanvas=function(n,d){var D=this.getRescaledRect(this.canvasWidth,this.canvasHeight,n,d,this.cropRect,this.margin);this.canvasWidth=n,this.canvasHeight=d,this.onCropChange&&this.onCropChange(D),this.setCropRectangle(D)},P}(),ft=function(){function P(n){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=n,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(P.prototype,"angle",{get:function(){return this._angle},set:function(n){this._angle=n,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),P.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},P.prototype.onPointerDown=function(n){this.controlContainer.setPointerCapture(n.pointerId),this.isDragging=!0,this.previousPoint={x:n.clientX,y:n.clientY}},P.prototype.onPointerMove=function(n){this.isDragging&&(this.onAngleChange&&this.onAngleChange((n.clientX-this.previousPoint.x)/5),this.previousPoint.x=n.clientX)},P.prototype.onPointerUp=function(n){this.isDragging&&this.onAngleChange&&this.onAngleChange((n.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(n.pointerId)},P.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var n=this.angleLabelText.getBBox();Ve.setAttributes(this.angleLabelElement,[["x",((this.width-n.width)/2).toString()],["y",(this.height/2).toString()]])}},P.prototype.positionScaleShape=function(){if(this.scaleShape){var n=this.scaleShape.transform.baseVal.getItem(0);n.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(n,0)}},P.prototype.getVisual=function(){var n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("xmlns","http://www.w3.org/2000/svg"),n.setAttribute("width",this.width+"px"),n.setAttribute("height",this.height+"px"),n.setAttribute("viewBox","0 0 "+this.width+" "+this.height),n.style.flexShrink="0",document.body.appendChild(n);for(var d="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,D=1;D<=this.width/5+10;D++){var N=D%5==0?this.height/3:this.height/6;d+="h4v"+-N+"h1v"+N}d+="v1H0Z",this.scaleShape=Ve.createPath(d);var R=Ve.createTransform();this.scaleShape.transform.baseVal.appendItem(R),n.appendChild(this.scaleShape),this.angleLabelElement=Ve.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=Ve.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var ee=Ve.createTSpan("");return ee.innerHTML="°",this.angleLabelElement.appendChild(ee),n.appendChild(this.angleLabelElement),document.body.removeChild(n),n},P}(),Ot=function(){function P(){this.naturalSize=!1,this.imageType="image/png"}return P.prototype.rasterize=function(n,d,D,N,R,ee,Re){var Ue=this;return new Promise(function(je){var Ae=document.createElement("canvas");Ae.width=n.width.baseVal.value-2*N,Ae.height=n.height.baseVal.value-2*N;var Ge=1,Ke=1;Ue.naturalSize===!0?(Ge=d.naturalWidth/(n.width.baseVal.value-2*N)/ee,Ke=d.naturalHeight/(n.height.baseVal.value-2*N)/Re,Ae.width=d.naturalWidth/ee,Ae.height=d.naturalHeight/Re):Ue.width!==void 0&&Ue.height!==void 0&&(Ge=Ue.width/D.width,Ke=Ue.height/D.height,Ae.width*=Ge,Ae.height*=Ke);var Je=Ae.getContext("2d");Je.translate(Ae.width/2,Ae.height/2),Je.rotate(R*Math.PI/180),Je.scale(ee,Re),Je.translate(-Ae.width/2,-Ae.height/2),Je.drawImage(d,0,0,Ae.width,Ae.height);var xt=document.createElement("canvas");xt.width=D.width*Ge,xt.height=D.height*Ke,xt.getContext("2d").putImageData(Je.getImageData((D.x-N)*Ge,(D.y-N)*Ke,D.width*Ge,D.height*Ke),0,0),je(xt.toDataURL(Ue.imageType,Ue.imageQuality))})},P}(),Ft=function(){function P(n){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=P.instanceCounter++,this.styles=new wt(this.instanceNo),this.target=n,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(P.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(n){this._zoomToCropEnabled=n,n?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(n){this._isGridVisible=n,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"gridLines",{get:function(){return this._gridLines},set:function(n){this._gridLines=n,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(n){this._rotationAngle=n,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"aspectRatio",{get:function(){var n;return(n=this._aspectRatio)!==null&&n!==void 0?n:this.aspectRatios[0]},set:function(n){this._aspectRatio=n},enumerable:!1,configurable:!0}),P.prototype.open=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.setupResizeObserver(),this.initCropCanvas(),this.setEditingTarget(),this.setTopLeft(),this.initCropLayer(),this.attachEvents(),this.applyAspectRatio(),this.displayMode==="popup"&&this.onPopupResize(),this._isOpen=!0},P.prototype.show=function(){this.showUI(),this.open()},P.prototype.close=function(n){n===void 0&&(n=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),n||this.closeEventListeners.forEach(function(d){return d()}),this._isOpen=!1)},P.prototype.addRenderEventListener=function(n){this.renderEventListeners.push(n)},P.prototype.removeRenderEventListener=function(n){this.renderEventListeners.indexOf(n)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(n),1)},P.prototype.addCloseEventListener=function(n){this.closeEventListeners.push(n)},P.prototype.removeCloseEventListener=function(n){this.closeEventListeners.indexOf(n)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(n),1)},P.prototype.setupResizeObserver=function(){var n=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){n.resize(n.target.clientWidth,n.target.clientHeight)}),this.targetObserver.observe(this.target)):this.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(this.onPopupResize),this.targetObserver.observe(this.contentDiv)),window.addEventListener("resize",this.setWindowHeight))},P.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var n=1*this.target.clientWidth/this.target.clientHeight,d=this.contentDiv.clientWidth/n>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*n:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,D=d+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/n;this.resize(d,D)}},P.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},P.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",Ve.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},P.prototype.resize=function(n,d){this.imageWidth=Math.round(n),this.imageHeight=Math.round(d),this.setEditingTargetSize(),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.displayMode!=="popup"?this.coverDiv.style.width=this.paddedImageWidth+"px":(this.setTopLeft(),this.positionCropImage()),this.cropLayer.scaleCanvas(this.imageWidth,this.imageHeight),this.applyRotation()},P.prototype.setEditingTarget=function(){var n=document.createElement("canvas");n.width=this.target.naturalWidth,n.height=this.target.naturalHeight,n.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var d=n.toDataURL();Ve.setAttributes(this.editingTarget,[["href",d]]),this.setEditingTargetSize()},P.prototype.setTopLeft=function(){var n=this.target.getBoundingClientRect(),d=this.editorCanvas.getBoundingClientRect();this.left=n.left-d.left-this.CANVAS_MARGIN,this.top=n.top-d.top-this.CANVAS_MARGIN},P.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=Ve.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=Ve.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=Ve.createGroup(),this.editingTargetRotationScaleContainer=Ve.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var n=Ve.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(n);var d=Ve.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(d),this.editingTargetContainer=Ve.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)},P.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},P.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=Ve.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new st(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()},P.prototype.zoomToCrop=function(){if(this.cropRect){var n=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,d=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=n+"px "+d+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-n+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-d+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},P.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)},P.prototype.cropRectChanged=function(n){this.cropRect=n,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},P.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},P.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"},P.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},P.prototype.showUI=function(){switch(this.addStyles(),this.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.displayMode){case"inline":this.coverDiv.style.position="absolute";var n=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,d=this.target.offsetTop>n+this.CANVAS_MARGIN?this.target.offsetTop-(n+this.CANVAS_MARGIN):0;this.coverDiv.style.top=d+"px",this.coverDiv.style.left=(this.target.offsetLeft>this.CANVAS_MARGIN?this.target.offsetLeft-this.CANVAS_MARGIN:0)+"px",this.coverDiv.style.width=this.target.offsetWidth+this.CANVAS_MARGIN+"px",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.displayMode==="popup"?this.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.addToolbars(),this.uiDiv.appendChild(this.topToolbar.getUI()),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.alignItems="center",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.contentDiv.style.overflow="hidden",this.contentDiv.style.backgroundColor=this.styles.settings.canvasBackgroundColor,this.displayMode==="popup"&&(this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.popupMargin+"px)"),this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.contentDiv.appendChild(this.editorCanvas),this.uiDiv.appendChild(this.bottomToolbar.getUI()),this.straightener.angle=this.rotationAngle},P.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},P.prototype.addTopToolbar=function(){var n=this;this.topToolbar=new At,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 d=new Rt;d.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(d);var D=[];this.aspectRatios.forEach(function(Ke){var Je=new it(ot.getIcon(Ke.horizontal,Ke.vertical),Ke.horizontal===0&&Ke.vertical===0?"FREE":Ke.horizontal+":"+Ke.vertical);Je.onClick=function(){return n.ratioButtonClicked(Ke)},D.push(Je)}),this.aspectRatioButton=new dt(ot.getIcon(0,0),"Aspect ratio",D),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,d.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var N=new it('<svg viewBox="0 0 24 24"><path d="M10 4v4h4V4h-4m6 0v4h4V4h-4m0 6v4h4v-4h-4m0 6v4h4v-4h-4m-2 4v-4h-4v4h4m-6 0v-4H4v4h4m0-6v-4H4v4h4m0-6V4H4v4h4m2 6h4v-4h-4v4M4 2h16a2 2 0 012 2v16a2 2 0 01-2 2H4c-1.08 0-2-.9-2-2V4a2 2 0 012-2z"/></svg>',"Toggle grid");N.isActive=this.isGridVisible,N.onClick=function(){n.isGridVisible=!n.isGridVisible,N.isActive=n.isGridVisible},d.addButton(N);var R=new it('<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"Zoom to selection");if(R.isActive=this.zoomToCropEnabled,R.onClick=function(){n.zoomToCropEnabled=!n.zoomToCropEnabled,R.isActive=n.zoomToCropEnabled},d.addButton(R),!bt.isLicensed){var ee=new Qe;this.topToolbar.addElementBlock(ee);var Re=document.createElement("div");Re.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var Ue=document.createElement("a");Ue.style.color="currentColor",Ue.href="https://markerjs.com/products/cropro",Ue.target="_blank",Ue.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>',Re.appendChild(Ue),ee.addElement(Re)}var je=new Rt;je.minWidth=3*this.toolbarHeight+"px",je.contentAlign="end",this.topToolbar.addButtonBlock(je);var Ae=new it('<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"OK");Ae.onClick=this.startRenderAndClose,je.addButton(Ae),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Ae.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var Ge=new it('<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"Close");Ge.onClick=this.close,je.addButton(Ge),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(Ge.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},P.prototype.addBottomToolbar=function(){var n=this;this.bottomToolbar=new At,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 d=new Rt;d.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(d);var D=new it('<svg viewBox="0 0 24 24"><path d="M13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93M7.1 18.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32M6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47m1.02-4.47L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47z"/></svg>',"Rotate left");D.onClick=this.rotateLeftButtonClicked,d.addButton(D);var N=new it('<svg viewBox="0 0 24 24"><path d="M16.89 15.5l1.42 1.39c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.5M13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03m6.93-6.9a7.906 7.906 0 00-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47m-2.36-5.45L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45z"/></svg>',"Rotate right");N.onClick=this.rotateRightButtonClicked,d.addButton(N);var R=new Qe;R.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(R),this.straightener=new ft("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(je){n.rotateBy(je),n.straightener.angle=n.rotationAngle},R.addElement(this.straightener.getUI());var ee=new Rt;ee.minWidth=2*this.toolbarHeight+"px",ee.contentAlign="end",this.bottomToolbar.addButtonBlock(ee);var Re=new it('<svg viewBox="0 0 24 24"><path d="M15 21h2v-2h-2m4-10h2V7h-2M3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2m16-2v2h2c0-1.1-.9-2-2-2m-8 20h2V1h-2m8 16h2v-2h-2M15 5h2V3h-2m4 10h2v-2h-2m0 10c1.1 0 2-.9 2-2h-2z"/></svg>',"Flip horizontal");Re.onClick=this.flipHorizontallyButtonClicked,ee.addButton(Re);var Ue=new it('<svg viewBox="0 0 24 24"><path d="M3 15v2h2v-2m10 4v2h2v-2m2-16H5c-1.1 0-2 .9-2 2v4h2V5h14v4h2V5c0-1.1-.9-2-2-2m2 16h-2v2c1.1 0 2-.9 2-2M1 11v2h22v-2M7 19v2h2v-2m10-4v2h2v-2m-10 4v2h2v-2M3 19c0 1.1.9 2 2 2v-2z"/></svg>',"Flip vertical");Ue.onClick=this.flipVerticallyButtonClicked,ee.addButton(Ue)},P.prototype.ratioButtonClicked=function(n){this.aspectRatio=n,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},P.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=ot.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},P.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new Ye(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},P.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},P.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},P.prototype.restoreState=function(n){if(n){var d=this.cropLayer.getRescaledRect(n.width,n.height,this.imageWidth,this.imageHeight,n.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(d),this.cropRectChanged(d),this.flippedHorizontally=n.flippedHorizontally,this.flippedVertically=n.flippedVertically,this.applyFlip(),this.rotationAngle=n.rotationAngle,this.applyRotation()}},P.prototype.clientToLocalCoordinates=function(n,d){var D=this.cropImage.getBoundingClientRect();return{x:n-D.left,y:d-D.top}},P.prototype.onWindowResize=function(){this.positionUI()},P.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var n=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=n+"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()},P.prototype.rotateLeftButtonClicked=function(){var n=this.rotationAngle-90;this.rotationAngle%90!=0&&(n+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(n)},P.prototype.rotateRightButtonClicked=function(){var n=this.rotationAngle+90;this.rotationAngle%90!=0&&(n-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(n)},P.prototype.rotateTo=function(n){n=(n=n>180?n-360:n)<=-180?n+360:n,this.rotationAngle=n,this.applyRotation()},P.prototype.rotateBy=function(n){this.rotateTo((this.rotationAngle+n)%360)},P.prototype.applyRotation=function(){var n=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var d=this.editingTargetRotationContainer.transform.baseVal.getItem(0);d.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(d,0);var D=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/D.width,this.imageHeight/D.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=n},P.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},P.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},P.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},P.prototype.startRenderAndClose=function(){return qe(this,void 0,void 0,function(){var n,d;return yt(this,function(D){switch(D.label){case 0:return[4,this.render()];case 1:return n=D.sent(),d=this.getState(),this.renderEventListeners.forEach(function(N){return N(n,d)}),this.close(!0),[2]}})})},P.prototype.render=function(){return qe(this,void 0,void 0,function(){var n;return yt(this,function(d){switch(d.label){case 0:return(n=new Ot).naturalSize=this.renderAtNaturalSize,n.imageType=this.renderImageType,n.imageQuality=this.renderImageQuality,n.width=this.renderWidth,n.height=this.renderHeight,this.unzoomFromCrop(),Ve.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,n.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 d.sent(),[4,n.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,d.sent()]}})})},P.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new ut("toolbar",`
|
|
width: `+(this.displayMode==="inline"?"100%":"calc(100vw - "+2*this.popupMargin+"px)")+`;
|
|
flex-shrink: 0;
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
height: `+this.toolbarHeight+`px;
|
|
box-sizing: content-box;
|
|
overflow: hidden;
|
|
line-height: 0px;
|
|
`)),this.toolbarStyleColorsClass=this.styles.addClass(new ut("toolbar_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new ut("toolbar-block",`
|
|
display: flex;
|
|
align-items: center;
|
|
box-sizing: content-box;
|
|
`));var n=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new ut("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.toolbarHeight-2*n)+`px;
|
|
height: `+(this.toolbarHeight-2*n)+`px;
|
|
padding: `+n+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new ut("toolbar_button_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new ut("toolbar_active_button",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
|
|
`)),this.styles.addRule(new at("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new at("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
|
|
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new ut("toolbar_dropdown",`
|
|
position: absolute;
|
|
max-width: `+4*this.toolbarHeight+`px;
|
|
z-index: 20;
|
|
white-space: normal;
|
|
box-sizing: content-box;
|
|
box-shadow: 3px 3px rgba(33, 33, 33, 0.1);
|
|
margin: `+(this.displayMode==="inline"?"0":this.popupMargin)+`px;
|
|
line-height: 0px;
|
|
`)),this.toolbarDropdownStyleColorsClass=this.styles.addClass(new ut("toolbar_dropdown_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new ut("toolbar_straightener_block",`
|
|
display: flex;
|
|
overflow: hidden;
|
|
justify-content: center;
|
|
-webkit-mask-image: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 30%, rgba(0,0,0,1) 70%, rgba(0,0,0,0) 100%);
|
|
`)),this.toolbarStraightenerStyleClass=this.styles.addClass(new ut("toolbar_straightener",`
|
|
display: flex;
|
|
overflow: hidden;
|
|
justify-content: center;
|
|
height: `+(this.toolbarHeight-2*n)+`px;
|
|
padding: `+n+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new ut("toolbar_straightener_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`))},P.instanceCounter=0,P}(),_t=J("8hTe"),Wt=J.n(_t),jt=/<pre[^>]*>/g;function Vt(P){var n=document.createElement("div");return n.innerHTML=P,n.childNodes.length===0?"":n.childNodes[0].nodeValue}var Ht=We.a=function(P){var n=P.value,d=n===void 0?"":n,D=P.edit,N=D===void 0?!1:D,R=P.className,ee=P.showTextOnly,Re=P.showLines,Ue=P.replaces,je=P.zoomImg,Ae=P.hasMask,Ge=P.style,Ke=Ge===void 0?{}:Ge,Je=P.stylesPrev,xt=Je===void 0?{}:Je,gt=String(d),Et=Object(w.useRef)(),Ct=Object(w.useRef)(),Kt=Object(w.useState)(""),Nt=Object(_.a)(Kt,2),pt=Nt[0],Lt=Nt[1],Gt=Object(w.useState)("office"),Pt=Object(_.a)(Gt,2),Xt=Pt[0],Dt=Pt[1],It=function(){var ht=new Ft(Ct.current);ht.displayMode="popup",ht.addRenderEventListener(function(){var Bt=Object(L.a)(A.a.mark(function lt(Ut){var Tt;return A.a.wrap(function(Mt){for(;;)switch(Mt.prev=Mt.next){case 0:return Et.current.style.display="none",Mt.next=3,Object(he.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:Ut}});case 3:Tt=Mt.sent,Tt!=null&&Tt.id&&Ue(Ct.current.getAttribute("src").replace(ie.a.API_SERVER,""),"/api/attachments/".concat(Tt==null?void 0:Tt.id,"?type=").concat(Tt.content_type));case 5:case"end":return Mt.stop()}},lt)}));return function(lt){return Bt.apply(this,arguments)}}()),ht.show()},Jt=function(){var ht=new rt(Ct.current);ht.settings.displayMode="popup",ht.addEventListener("render",function(){var Bt=Object(L.a)(A.a.mark(function lt(Ut){var Tt;return A.a.wrap(function(Mt){for(;;)switch(Mt.prev=Mt.next){case 0:if(Et.current.style.display="none",!Ct.current){Mt.next=6;break}return Mt.next=4,Object(he.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:Ut.dataUrl}});case 4:Tt=Mt.sent,Tt!=null&&Tt.id&&Ue(Ct.current.getAttribute("src").replace(ie.a.API_SERVER,""),"/api/attachments/".concat(Tt==null?void 0:Tt.id,"?type=").concat(Tt.content_type));case 6:case"end":return Mt.stop()}},lt)}));return function(lt){return Bt.apply(this,arguments)}}()),ht.show(),window.markerArea=ht},$t=Object(w.useMemo)(function(){try{var kt=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,ht=/\"\/api\/attachments\/|\"\/attachments\/download\//g,Bt=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;gt=gt.replace(kt,"("+ie.a.API_SERVER+"/api/attachments/").replace(ht,'"'+ie.a.API_SERVER+"/api/attachments/").replace(Bt,'"'+ie.a.API_SERVER+"/files/uploads/").replaceAll("http://video.educoder","https://video.educoder").replaceAll("http://www.educoder.net/api","https://data.educoder.net/api").replaceAll("https://www.educoder.net/api","https://data.educoder.net/api").replace(/\r\n/g,`
|
|
`),gt=gt.replace(new RegExp("(?<!\\n)\\n(?!\\n)","g"),`
|
|
`)}catch(Zt){}var lt=K(gt),Ut=m();if(gt.match(/\[TOC\]/)&&(lt=lt.replace("<p>[TOC]</p>",p()),f()),lt=lt.replace(/(__special_katext_id_\d+__)/g,function(Zt,Mt){var Qt=Ut[Mt],tr=Qt.type,rr=Qt.expression;return Object(ge.renderToString)(Vt(rr)||"",{displayMode:tr==="block",throwOnError:!1,output:"html"})}),lt=lt.replace(/▁/g,"\u2581\u2581\u2581"),v(),ee){var Tt=document.createElement("div");return Tt.innerHTML=lt,Tt.innerText}return setTimeout(function(){return qt()},500),lt},[gt]),zt=Object(w.useRef)();u.WebkitLineClamp=Re,Re&&(Ke=Object(O.a)(Object(O.a)({},Ke),u));function Yt(kt){var ht=kt.target;if(ht.tagName.toUpperCase()==="IMG"){if(je){var Bt=ht.getAttribute("src");Lt(Bt),Dt("image")}}else if(ht.tagName.toUpperCase()==="A"){var lt=ht.getAttribute("href");if(lt.indexOf("office")>-1)kt.preventDefault(),Lt(lt),Dt("office");else if(lt.indexOf("application/pdf")>-1)kt.preventDefault(),Lt(lt),Dt("pdf");else if(lt.indexOf("type=text")>-1)kt.preventDefault(),Lt(lt),Dt("html");else if(lt.startsWith("#")){kt.preventDefault();var Ut=document.getElementById(lt.replace("#",""));Ut&&Ut.scrollIntoView(!0)}}}var qt=function(){var ht,Bt=(ht=zt.current)===null||ht===void 0?void 0:ht.querySelectorAll("video");Bt==null||Bt.forEach(function(lt){if(lt.oncontextmenu=function(){return!1},lt.src.indexOf(".m3u8")>-1&&!lt.canPlayType("application/vnd.apple.mpegurl")){if(Z.a.isSupported()){var Ut=new Z.a;Ut.loadSource(lt.src),Ut.attachMedia(lt)}}})};Object(w.useEffect)(function(){if(zt.current&&$t&&($t.match(jt)&&window.PR.prettyPrint()),zt.current)return zt.current.addEventListener("click",Yt),function(){zt.current.removeEventListener("click",Yt),v(),f()}},[$t,zt.current,Yt]);var er=function(ht){if(!N)return;ht.target.nodeName==="IMG"?(Et.current.style.display="flex",Et.current.style.width=ht.target.clientWidth+"px",Et.current.style.height=ht.target.clientHeight+"px",Et.current.style.top=ht.target.offsetTop+"px",Et.current.style.left=ht.target.offsetLeft+"px",Ct.current.src=ht.target.getAttribute("src")):Et.current.style.display="none"};return g.a.createElement("div",{style:{position:"relative"}},g.a.createElement("div",{ref:zt,style:Object(O.a)({},Ke),className:"".concat(R||""," markdown-body ").concat(Wt.a.mdBody),onMouseOver:er,dangerouslySetInnerHTML:{__html:$t}}),g.a.createElement("div",{ref:Et,className:Wt.a.button},g.a.createElement(U.a,null,g.a.createElement(B.a,{onClick:function(){return It()}},"\u88C1\u526A"),g.a.createElement(B.a,{onClick:function(){return Jt()}},"\u7F16\u8F91"))),g.a.createElement("img",{ref:Ct,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),g.a.createElement(se.a,{close:!0,data:pt,hasMask:Ae,type:pt!=null&&pt.length?Xt:"",style:Object(O.a)({},xt),onClose:function(){return Lt("")}}))}},BU3w:function(nt,We,J){"use strict";J.d(We,"a",function(){return L});var fe=J("MNnm"),U="rc-util-key";function C(_){if(_.attachTo)return _.attachTo;var M=document.querySelector("head");return M||document.body}function B(_){var M,A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Object(fe.a)())return null;var w=document.createElement("style");if((M=A.csp)===null||M===void 0?void 0:M.nonce){var g;w.nonce=(g=A.csp)===null||g===void 0?void 0:g.nonce}w.innerHTML=_;var x=C(A),S=x.firstChild;return A.prepend&&x.prepend?x.prepend(w):A.prepend&&S?x.insertBefore(w,S):x.appendChild(w),w}var O=new Map;function L(_,M){var A=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},w=C(A);if(!O.has(w)){var g=B("",A),x=g.parentNode;O.set(w,x),x.removeChild(g)}var S=Array.from(O.get(w).children).find(function(e){return e.tagName==="STYLE"&&e[U]===M});if(S){var E,b;if(((E=A.csp)===null||E===void 0?void 0:E.nonce)&&S.nonce!==((b=A.csp)===null||b===void 0?void 0:b.nonce)){var y;S.nonce=(y=A.csp)===null||y===void 0?void 0:y.nonce}return S.innerHTML!==_&&(S.innerHTML=_),S}var h=B(_,A);return h[U]=M,h}},DlQD:function(nt,We,J){(function(fe,U){nt.exports=U()})(this,function(){"use strict";function fe(re,q){for(var te=0;te<q.length;te++){var j=q[te];j.enumerable=j.enumerable||!1,j.configurable=!0,"value"in j&&(j.writable=!0),Object.defineProperty(re,j.key,j)}}function U(re,q,te){return q&&fe(re.prototype,q),te&&fe(re,te),re}function C(re,q){if(!re)return;if(typeof re=="string")return B(re,q);var te=Object.prototype.toString.call(re).slice(8,-1);if(te==="Object"&&re.constructor&&(te=re.constructor.name),te==="Map"||te==="Set")return Array.from(re);if(te==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(te))return B(re,q)}function B(re,q){(q==null||q>re.length)&&(q=re.length);for(var te=0,j=new Array(q);te<q;te++)j[te]=re[te];return j}function O(re,q){var te;if(typeof Symbol=="undefined"||re[Symbol.iterator]==null){if(Array.isArray(re)||(te=C(re))||q&&re&&typeof re.length=="number"){te&&(re=te);var j=0;return function(){return j>=re.length?{done:!0}:{done:!1,value:re[j++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}return te=re[Symbol.iterator](),te.next.bind(te)}function L(re,q){return q={exports:{}},re(q,q.exports),q.exports}var _=L(function(re){function q(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}function te(j){re.exports.defaults=j}re.exports={defaults:q(),getDefaults:q,changeDefaults:te}}),M=_.defaults,A=_.getDefaults,w=_.changeDefaults,g=/[&<>"']/,x=/[&<>"']/g,S=/[<>"']|&(?!#?\w+;)/,E=/[<>"']|&(?!#?\w+;)/g,b={"&":"&","<":"<",">":">",'"':""","'":"'"},y=function(q){return b[q]};function h(re,q){if(q){if(g.test(re))return re.replace(x,y)}else if(S.test(re))return re.replace(E,y);return re}var e=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function s(re){return re.replace(e,function(q,te){return te=te.toLowerCase(),te==="colon"?":":te.charAt(0)==="#"?te.charAt(1)==="x"?String.fromCharCode(parseInt(te.substring(2),16)):String.fromCharCode(+te.substring(1)):""})}var o=/(^|[^\[])\^/g;function f(re,q){re=re.source||re,q=q||"";var te={replace:function(W,G){return G=G.source||G,G=G.replace(o,"$1"),re=re.replace(W,G),te},getRegex:function(){return new RegExp(re,q)}};return te}var u=/[^\w:]/g,l=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function p(re,q,te){if(re){var j;try{j=decodeURIComponent(s(te)).replace(u,"").toLowerCase()}catch(W){return null}if(j.indexOf("javascript:")===0||j.indexOf("vbscript:")===0||j.indexOf("data:")===0)return null}q&&!l.test(te)&&(te=a(q,te));try{te=encodeURI(te).replace(/%25/g,"%")}catch(W){return null}return te}var c={},i=/^[^:]+:\/*[^/]*$/,r=/^([^:]+:)[\s\S]*$/,t=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(re,q){c[" "+re]||(i.test(re)?c[" "+re]=re+"/":c[" "+re]=k(re,"/",!0)),re=c[" "+re];var te=re.indexOf(":")===-1;return q.substring(0,2)==="//"?te?q:re.replace(r,"$1")+q:q.charAt(0)==="/"?te?q:re.replace(t,"$1")+q:re+q}var m={exec:function(){}};function v(re){for(var q=1,te,j;q<arguments.length;q++){te=arguments[q];for(j in te)Object.prototype.hasOwnProperty.call(te,j)&&(re[j]=te[j])}return re}function T(re,q){var te=re.replace(/\|/g,function(G,X,oe){for(var ce=!1,Pe=X;--Pe>=0&&oe[Pe]==="\\";)ce=!ce;return ce?"|":" |"}),j=te.split(/ \|/),W=0;if(j.length>q)j.splice(q);else for(;j.length<q;)j.push("");for(;W<j.length;W++)j[W]=j[W].trim().replace(/\\\|/g,"|");return j}function k(re,q,te){var j=re.length;if(j===0)return"";for(var W=0;W<j;){var G=re.charAt(j-W-1);if(G===q&&!te)W++;else if(G!==q&&te)W++;else break}return re.substr(0,j-W)}function I(re,q){if(re.indexOf(q[1])===-1)return-1;for(var te=re.length,j=0,W=0;W<te;W++)if(re[W]==="\\")W++;else if(re[W]===q[0])j++;else if(re[W]===q[1]&&(j--,j<0))return W;return-1}function F(re){re&&re.sanitize&&!re.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}var K={escape:h,unescape:s,edit:f,cleanUrl:p,resolveUrl:a,noopTest:m,merge:v,splitCells:T,rtrim:k,findClosingBracket:I,checkSanitizeDeprecation:F},V=_.defaults,Q=K.rtrim,Z=K.splitCells,ie=K.escape,ge=K.findClosingBracket;function se(re,q,te){var j=q.href,W=q.title?ie(q.title):null,G=re[1].replace(/\\([\[\]])/g,"$1");return re[0].charAt(0)!=="!"?{type:"link",raw:te,href:j,title:W,text:G}:{type:"image",raw:te,href:j,title:W,text:ie(G)}}function he(re,q){var te=re.match(/^(\s+)(?:```)/);if(te===null)return q;var j=te[1];return q.split(`
|
|
`).map(function(W){var G=W.match(/^\s+/);if(G===null)return W;var X=G[0];return X.length>=j.length?W.slice(j.length):W}).join(`
|
|
`)}var de=function(){function re(te){this.options=te||V}var q=re.prototype;return q.space=function(j){var W=this.rules.block.newline.exec(j);if(W)return W[0].length>1?{type:"space",raw:W[0]}:{raw:`
|
|
`}},q.code=function(j,W){var G=this.rules.block.code.exec(j);if(G){var X=W[W.length-1];if(X&&X.type==="paragraph")return{raw:G[0],text:G[0].trimRight()};var oe=G[0].replace(/^ {4}/gm,"");return{type:"code",raw:G[0],codeBlockStyle:"indented",text:this.options.pedantic?oe:Q(oe,`
|
|
`)}}},q.fences=function(j){var W=this.rules.block.fences.exec(j);if(W){var G=W[0],X=he(G,W[3]||"");return{type:"code",raw:G,lang:W[2]?W[2].trim():W[2],text:X}}},q.heading=function(j){var W=this.rules.block.heading.exec(j);if(W)return{type:"heading",raw:W[0],depth:W[1].length,text:W[2]}},q.nptable=function(j){var W=this.rules.block.nptable.exec(j);if(W){var G={type:"table",header:Z(W[1].replace(/^ *| *\| *$/g,"")),align:W[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:W[3]?W[3].replace(/\n$/,"").split(`
|
|
`):[],raw:W[0]};if(G.header.length===G.align.length){var X=G.align.length,oe;for(oe=0;oe<X;oe++)/^ *-+: *$/.test(G.align[oe])?G.align[oe]="right":/^ *:-+: *$/.test(G.align[oe])?G.align[oe]="center":/^ *:-+ *$/.test(G.align[oe])?G.align[oe]="left":G.align[oe]=null;for(X=G.cells.length,oe=0;oe<X;oe++)G.cells[oe]=Z(G.cells[oe],G.header.length);return G}}},q.hr=function(j){var W=this.rules.block.hr.exec(j);if(W)return{type:"hr",raw:W[0]}},q.blockquote=function(j){var W=this.rules.block.blockquote.exec(j);if(W){var G=W[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:W[0],text:G}}},q.list=function(j){var W=this.rules.block.list.exec(j);if(W){for(var G=W[0],X=W[2],oe=X.length>1,ce=X[X.length-1]===")",Pe={type:"list",raw:G,ordered:oe,start:oe?+X.slice(0,-1):"",loose:!1,items:[]},He=W[0].match(this.rules.block.item),$e=!1,ze,Ze,et,Xe,mt,rt,vt,ct=He.length,qe=0;qe<ct;qe++)ze=He[qe],G=ze,Ze=ze.length,ze=ze.replace(/^ *([*+-]|\d+[.)]) */,""),~ze.indexOf(`
|
|
`)&&(Ze-=ze.length,ze=this.options.pedantic?ze.replace(/^ {1,4}/gm,""):ze.replace(new RegExp("^ {1,"+Ze+"}","gm"),"")),qe!==ct-1&&(et=this.rules.block.bullet.exec(He[qe+1])[0],(oe?et.length===1||!ce&&et[et.length-1]===")":et.length>1||this.options.smartLists&&et!==X)&&(Xe=He.slice(qe+1).join(`
|
|
`),Pe.raw=Pe.raw.substring(0,Pe.raw.length-Xe.length),qe=ct-1)),mt=$e||/\n\n(?!\s*$)/.test(ze),qe!==ct-1&&($e=ze.charAt(ze.length-1)===`
|
|
`,mt||(mt=$e)),mt&&(Pe.loose=!0),rt=/^\[[ xX]\] /.test(ze),vt=void 0,rt&&(vt=ze[1]!==" ",ze=ze.replace(/^\[[ xX]\] +/,"")),Pe.items.push({type:"list_item",raw:G,task:rt,checked:vt,loose:mt,text:ze});return Pe}},q.html=function(j){var W=this.rules.block.html.exec(j);if(W)return{type:this.options.sanitize?"paragraph":"html",raw:W[0],pre:!this.options.sanitizer&&(W[1]==="pre"||W[1]==="script"||W[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(W[0]):ie(W[0]):W[0]}},q.def=function(j){var W=this.rules.block.def.exec(j);if(W){W[3]&&(W[3]=W[3].substring(1,W[3].length-1));var G=W[1].toLowerCase().replace(/\s+/g," ");return{tag:G,raw:W[0],href:W[2],title:W[3]}}},q.table=function(j){var W=this.rules.block.table.exec(j);if(W){var G={type:"table",header:Z(W[1].replace(/^ *| *\| *$/g,"")),align:W[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:W[3]?W[3].replace(/\n$/,"").split(`
|
|
`):[]};if(G.header.length===G.align.length){G.raw=W[0];var X=G.align.length,oe;for(oe=0;oe<X;oe++)/^ *-+: *$/.test(G.align[oe])?G.align[oe]="right":/^ *:-+: *$/.test(G.align[oe])?G.align[oe]="center":/^ *:-+ *$/.test(G.align[oe])?G.align[oe]="left":G.align[oe]=null;for(X=G.cells.length,oe=0;oe<X;oe++)G.cells[oe]=Z(G.cells[oe].replace(/^ *\| *| *\| *$/g,""),G.header.length);return G}}},q.lheading=function(j){var W=this.rules.block.lheading.exec(j);if(W)return{type:"heading",raw:W[0],depth:W[2].charAt(0)==="="?1:2,text:W[1]}},q.paragraph=function(j){var W=this.rules.block.paragraph.exec(j);if(W)return{type:"paragraph",raw:W[0],text:W[1].charAt(W[1].length-1)===`
|
|
`?W[1].slice(0,-1):W[1]}},q.text=function(j,W){var G=this.rules.block.text.exec(j);if(G){var X=W[W.length-1];return X&&X.type==="text"?{raw:G[0],text:G[0]}:{type:"text",raw:G[0],text:G[0]}}},q.escape=function(j){var W=this.rules.inline.escape.exec(j);if(W)return{type:"escape",raw:W[0],text:ie(W[1])}},q.tag=function(j,W,G){var X=this.rules.inline.tag.exec(j);if(X)return!W&&/^<a /i.test(X[0])?W=!0:W&&/^<\/a>/i.test(X[0])&&(W=!1),!G&&/^<(pre|code|kbd|script)(\s|>)/i.test(X[0])?G=!0:G&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(X[0])&&(G=!1),{type:this.options.sanitize?"text":"html",raw:X[0],inLink:W,inRawBlock:G,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(X[0]):ie(X[0]):X[0]}},q.link=function(j){var W=this.rules.inline.link.exec(j);if(W){var G=ge(W[2],"()");if(G>-1){var X=W[0].indexOf("!")===0?5:4,oe=X+W[1].length+G;W[2]=W[2].substring(0,G),W[0]=W[0].substring(0,oe).trim(),W[3]=""}var ce=W[2],Pe="";if(this.options.pedantic){var He=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(ce);He?(ce=He[1],Pe=He[3]):Pe=""}else Pe=W[3]?W[3].slice(1,-1):"";ce=ce.trim().replace(/^<([\s\S]*)>$/,"$1");var $e=se(W,{href:ce&&ce.replace(this.rules.inline._escapes,"$1"),title:Pe&&Pe.replace(this.rules.inline._escapes,"$1")},W[0]);return $e}},q.reflink=function(j,W){var G;if((G=this.rules.inline.reflink.exec(j))||(G=this.rules.inline.nolink.exec(j))){var X=(G[2]||G[1]).replace(/\s+/g," ");if(X=W[X.toLowerCase()],!X||!X.href){var oe=G[0].charAt(0);return{type:"text",raw:oe,text:oe}}var ce=se(G,X,G[0]);return ce}},q.strong=function(j,W,G){G===void 0&&(G="");var X=this.rules.inline.strong.start.exec(j);if(X&&(!X[1]||X[1]&&(G===""||this.rules.inline.punctuation.exec(G)))){W=W.slice(-1*j.length);var oe=X[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;oe.lastIndex=0;for(var ce;(X=oe.exec(W))!=null;)if(ce=this.rules.inline.strong.middle.exec(W.slice(0,X.index+3)),ce)return{type:"strong",raw:j.slice(0,ce[0].length),text:j.slice(2,ce[0].length-2)}}},q.em=function(j,W,G){G===void 0&&(G="");var X=this.rules.inline.em.start.exec(j);if(X&&(!X[1]||X[1]&&(G===""||this.rules.inline.punctuation.exec(G)))){W=W.slice(-1*j.length);var oe=X[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;oe.lastIndex=0;for(var ce;(X=oe.exec(W))!=null;)if(ce=this.rules.inline.em.middle.exec(W.slice(0,X.index+2)),ce)return{type:"em",raw:j.slice(0,ce[0].length),text:j.slice(1,ce[0].length-1)}}},q.codespan=function(j){var W=this.rules.inline.code.exec(j);if(W){var G=W[2].replace(/\n/g," "),X=/[^ ]/.test(G),oe=G.startsWith(" ")&&G.endsWith(" ");return X&&oe&&(G=G.substring(1,G.length-1)),G=ie(G,!0),{type:"codespan",raw:W[0],text:G}}},q.br=function(j){var W=this.rules.inline.br.exec(j);if(W)return{type:"br",raw:W[0]}},q.del=function(j){var W=this.rules.inline.del.exec(j);if(W)return{type:"del",raw:W[0],text:W[1]}},q.autolink=function(j,W){var G=this.rules.inline.autolink.exec(j);if(G){var X,oe;return G[2]==="@"?(X=ie(this.options.mangle?W(G[1]):G[1]),oe="mailto:"+X):(X=ie(G[1]),oe=X),{type:"link",raw:G[0],text:X,href:oe,tokens:[{type:"text",raw:X,text:X}]}}},q.url=function(j,W){var G;if(G=this.rules.inline.url.exec(j)){var X,oe;if(G[2]==="@")X=ie(this.options.mangle?W(G[0]):G[0]),oe="mailto:"+X;else{var ce;do ce=G[0],G[0]=this.rules.inline._backpedal.exec(G[0])[0];while(ce!==G[0]);X=ie(G[0]),G[1]==="www."?oe="http://"+X:oe=X}return{type:"link",raw:G[0],text:X,href:oe,tokens:[{type:"text",raw:X,text:X}]}}},q.inlineText=function(j,W,G){var X=this.rules.inline.text.exec(j);if(X){var oe;return W?oe=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(X[0]):ie(X[0]):X[0]:oe=ie(this.options.smartypants?G(X[0]):X[0]),{type:"text",raw:X[0],text:oe}}},re}(),$=K.noopTest,Y=K.edit,ne=K.merge,z={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:$,table:$,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};z._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,z._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,z.def=Y(z.def).replace("label",z._label).replace("title",z._title).getRegex(),z.bullet=/(?:[*+-]|\d{1,9}[.)])/,z.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,z.item=Y(z.item,"gm").replace(/bull/g,z.bullet).getRegex(),z.list=Y(z.list).replace(/bull/g,z.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+z.def.source+")").getRegex(),z._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",z._comment=/<!--(?!-?>)[\s\S]*?-->/,z.html=Y(z.html,"i").replace("comment",z._comment).replace("tag",z._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),z.paragraph=Y(z._paragraph).replace("hr",z.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",z._tag).getRegex(),z.blockquote=Y(z.blockquote).replace("paragraph",z.paragraph).getRegex(),z.normal=ne({},z),z.gfm=ne({},z.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*|$)"}),z.gfm.nptable=Y(z.gfm.nptable).replace("hr",z.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",z._tag).getRegex(),z.gfm.table=Y(z.gfm.table).replace("hr",z.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",z._tag).getRegex(),z.pedantic=ne({},z.normal,{html:Y(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",z._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:$,paragraph:Y(z.normal._paragraph).replace("hr",z.hr).replace("heading",` *#{1,6} *[^
|
|
]`).replace("lheading",z.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var H={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:$,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:$,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};H._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",H.punctuation=Y(H.punctuation).replace(/punctuation/g,H._punctuation).getRegex(),H._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",H._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",H.em.start=Y(H.em.start).replace(/punctuation/g,H._punctuation).getRegex(),H.em.middle=Y(H.em.middle).replace(/punctuation/g,H._punctuation).replace(/overlapSkip/g,H._overlapSkip).getRegex(),H.em.endAst=Y(H.em.endAst,"g").replace(/punctuation/g,H._punctuation).getRegex(),H.em.endUnd=Y(H.em.endUnd,"g").replace(/punctuation/g,H._punctuation).getRegex(),H.strong.start=Y(H.strong.start).replace(/punctuation/g,H._punctuation).getRegex(),H.strong.middle=Y(H.strong.middle).replace(/punctuation/g,H._punctuation).replace(/blockSkip/g,H._blockSkip).getRegex(),H.strong.endAst=Y(H.strong.endAst,"g").replace(/punctuation/g,H._punctuation).getRegex(),H.strong.endUnd=Y(H.strong.endUnd,"g").replace(/punctuation/g,H._punctuation).getRegex(),H.blockSkip=Y(H._blockSkip,"g").getRegex(),H.overlapSkip=Y(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=Y(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=Y(H.tag).replace("comment",z._comment).replace("attribute",H._attribute).getRegex(),H._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,H._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,H._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,H.link=Y(H.link).replace("label",H._label).replace("href",H._href).replace("title",H._title).getRegex(),H.reflink=Y(H.reflink).replace("label",H._label).getRegex(),H.reflinkSearch=Y(H.reflinkSearch,"g").replace("reflink",H.reflink).replace("nolink",H.nolink).getRegex(),H.normal=ne({},H),H.pedantic=ne({},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:Y(/^!?\[(label)\]\((.*?)\)/).replace("label",H._label).getRegex(),reflink:Y(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",H._label).getRegex()}),H.gfm=ne({},H.normal,{escape:Y(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=Y(H.gfm.url,"i").replace("email",H.gfm._extended_email).getRegex(),H.breaks=ne({},H.gfm,{br:Y(H.br).replace("{2,}","*").getRegex(),text:Y(H.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var me={block:z,inline:H},Le=_.defaults,Oe=me.block,we=me.inline;function De(re){return re.replace(/---/g,"\u2014").replace(/--/g,"\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1\u2018").replace(/'/g,"\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1\u201C").replace(/"/g,"\u201D").replace(/\.{3}/g,"\u2026")}function le(re){var q="",te,j,W=re.length;for(te=0;te<W;te++)j=re.charCodeAt(te),Math.random()>.5&&(j="x"+j.toString(16)),q+="&#"+j+";";return q}var pe=function(){function re(te){this.tokens=[],this.tokens.links=Object.create(null),this.options=te||Le,this.options.tokenizer=this.options.tokenizer||new de,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var j={block:Oe.normal,inline:we.normal};this.options.pedantic?(j.block=Oe.pedantic,j.inline=we.pedantic):this.options.gfm&&(j.block=Oe.gfm,this.options.breaks?j.inline=we.breaks:j.inline=we.gfm),this.tokenizer.rules=j}re.lex=function(j,W){var G=new re(W);return G.lex(j)};var q=re.prototype;return q.lex=function(j){return j=j.replace(/\r\n|\r/g,`
|
|
`).replace(/\t/g," "),this.blockTokens(j,this.tokens,!0),this.inline(this.tokens),this.tokens},q.blockTokens=function(j,W,G){W===void 0&&(W=[]),G===void 0&&(G=!0),j=j.replace(/^ +$/gm,"");for(var X,oe,ce,Pe;j;){if(X=this.tokenizer.space(j)){j=j.substring(X.raw.length),X.type&&W.push(X);continue}if(X=this.tokenizer.code(j,W)){j=j.substring(X.raw.length),X.type?W.push(X):(Pe=W[W.length-1],Pe.raw+=`
|
|
`+X.raw,Pe.text+=`
|
|
`+X.text);continue}if(X=this.tokenizer.fences(j)){j=j.substring(X.raw.length),W.push(X);continue}if(X=this.tokenizer.heading(j)){j=j.substring(X.raw.length),W.push(X);continue}if(X=this.tokenizer.nptable(j)){j=j.substring(X.raw.length),W.push(X);continue}if(X=this.tokenizer.hr(j)){j=j.substring(X.raw.length),W.push(X);continue}if(X=this.tokenizer.blockquote(j)){j=j.substring(X.raw.length),X.tokens=this.blockTokens(X.text,[],G),W.push(X);continue}if(X=this.tokenizer.list(j)){for(j=j.substring(X.raw.length),ce=X.items.length,oe=0;oe<ce;oe++)X.items[oe].tokens=this.blockTokens(X.items[oe].text,[],!1);W.push(X);continue}if(X=this.tokenizer.html(j)){j=j.substring(X.raw.length),W.push(X);continue}if(G&&(X=this.tokenizer.def(j))){j=j.substring(X.raw.length),this.tokens.links[X.tag]||(this.tokens.links[X.tag]={href:X.href,title:X.title});continue}if(X=this.tokenizer.table(j)){j=j.substring(X.raw.length),W.push(X);continue}if(X=this.tokenizer.lheading(j)){j=j.substring(X.raw.length),W.push(X);continue}if(G&&(X=this.tokenizer.paragraph(j))){j=j.substring(X.raw.length),W.push(X);continue}if(X=this.tokenizer.text(j,W)){j=j.substring(X.raw.length),X.type?W.push(X):(Pe=W[W.length-1],Pe.raw+=`
|
|
`+X.raw,Pe.text+=`
|
|
`+X.text);continue}if(j){var He="Infinite loop on byte: "+j.charCodeAt(0);if(this.options.silent){console.error(He);break}else throw new Error(He)}}return W},q.inline=function(j){var W,G,X,oe,ce,Pe,He=j.length;for(W=0;W<He;W++){Pe=j[W];switch(Pe.type){case"paragraph":case"text":case"heading":{Pe.tokens=[],this.inlineTokens(Pe.text,Pe.tokens);break}case"table":{for(Pe.tokens={header:[],cells:[]},oe=Pe.header.length,G=0;G<oe;G++)Pe.tokens.header[G]=[],this.inlineTokens(Pe.header[G],Pe.tokens.header[G]);for(oe=Pe.cells.length,G=0;G<oe;G++)for(ce=Pe.cells[G],Pe.tokens.cells[G]=[],X=0;X<ce.length;X++)Pe.tokens.cells[G][X]=[],this.inlineTokens(ce[X],Pe.tokens.cells[G][X]);break}case"blockquote":{this.inline(Pe.tokens);break}case"list":{for(oe=Pe.items.length,G=0;G<oe;G++)this.inline(Pe.items[G].tokens);break}}}return j},q.inlineTokens=function(j,W,G,X,oe){W===void 0&&(W=[]),G===void 0&&(G=!1),X===void 0&&(X=!1),oe===void 0&&(oe="");var ce,Pe=j,He;if(this.tokens.links){var $e=Object.keys(this.tokens.links);if($e.length>0)for(;(He=this.tokenizer.rules.inline.reflinkSearch.exec(Pe))!=null;)$e.includes(He[0].slice(He[0].lastIndexOf("[")+1,-1))&&(Pe=Pe.slice(0,He.index)+"["+"a".repeat(He[0].length-2)+"]"+Pe.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(He=this.tokenizer.rules.inline.blockSkip.exec(Pe))!=null;)Pe=Pe.slice(0,He.index)+"["+"a".repeat(He[0].length-2)+"]"+Pe.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;j;){if(ce=this.tokenizer.escape(j)){j=j.substring(ce.raw.length),W.push(ce);continue}if(ce=this.tokenizer.tag(j,G,X)){j=j.substring(ce.raw.length),G=ce.inLink,X=ce.inRawBlock,W.push(ce);continue}if(ce=this.tokenizer.link(j)){j=j.substring(ce.raw.length),ce.type==="link"&&(ce.tokens=this.inlineTokens(ce.text,[],!0,X)),W.push(ce);continue}if(ce=this.tokenizer.reflink(j,this.tokens.links)){j=j.substring(ce.raw.length),ce.type==="link"&&(ce.tokens=this.inlineTokens(ce.text,[],!0,X)),W.push(ce);continue}if(ce=this.tokenizer.strong(j,Pe,oe)){j=j.substring(ce.raw.length),ce.tokens=this.inlineTokens(ce.text,[],G,X),W.push(ce);continue}if(ce=this.tokenizer.em(j,Pe,oe)){j=j.substring(ce.raw.length),ce.tokens=this.inlineTokens(ce.text,[],G,X),W.push(ce);continue}if(ce=this.tokenizer.codespan(j)){j=j.substring(ce.raw.length),W.push(ce);continue}if(ce=this.tokenizer.br(j)){j=j.substring(ce.raw.length),W.push(ce);continue}if(ce=this.tokenizer.del(j)){j=j.substring(ce.raw.length),ce.tokens=this.inlineTokens(ce.text,[],G,X),W.push(ce);continue}if(ce=this.tokenizer.autolink(j,le)){j=j.substring(ce.raw.length),W.push(ce);continue}if(!G&&(ce=this.tokenizer.url(j,le))){j=j.substring(ce.raw.length),W.push(ce);continue}if(ce=this.tokenizer.inlineText(j,X,De)){j=j.substring(ce.raw.length),oe=ce.raw.slice(-1),W.push(ce);continue}if(j){var ze="Infinite loop on byte: "+j.charCodeAt(0);if(this.options.silent){console.error(ze);break}else throw new Error(ze)}}return W},U(re,null,[{key:"rules",get:function(){return{block:Oe,inline:we}}}]),re}(),Ee=_.defaults,Te=K.cleanUrl,Ie=K.escape,ke=function(){function re(te){this.options=te||Ee}var q=re.prototype;return q.code=function(j,W,G){var X=(W||"").match(/\S*/)[0];if(this.options.highlight){var oe=this.options.highlight(j,X);oe!=null&&oe!==j&&(G=!0,j=oe)}return X?'<pre><code class="'+this.options.langPrefix+Ie(X,!0)+'">'+(G?j:Ie(j,!0))+`</code></pre>
|
|
`:"<pre><code>"+(G?j:Ie(j,!0))+`</code></pre>
|
|
`},q.blockquote=function(j){return`<blockquote>
|
|
`+j+`</blockquote>
|
|
`},q.html=function(j){return j},q.heading=function(j,W,G,X){return this.options.headerIds?"<h"+W+' id="'+this.options.headerPrefix+X.slug(G)+'">'+j+"</h"+W+`>
|
|
`:"<h"+W+">"+j+"</h"+W+`>
|
|
`},q.hr=function(){return this.options.xhtml?`<hr/>
|
|
`:`<hr>
|
|
`},q.list=function(j,W,G){var X=W?"ol":"ul",oe=W&&G!==1?' start="'+G+'"':"";return"<"+X+oe+`>
|
|
`+j+"</"+X+`>
|
|
`},q.listitem=function(j){return"<li>"+j+`</li>
|
|
`},q.checkbox=function(j){return"<input "+(j?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},q.paragraph=function(j){return"<p>"+j+`</p>
|
|
`},q.table=function(j,W){return W&&(W="<tbody>"+W+"</tbody>"),`<table>
|
|
<thead>
|
|
`+j+`</thead>
|
|
`+W+`</table>
|
|
`},q.tablerow=function(j){return`<tr>
|
|
`+j+`</tr>
|
|
`},q.tablecell=function(j,W){var G=W.header?"th":"td",X=W.align?"<"+G+' align="'+W.align+'">':"<"+G+">";return X+j+"</"+G+`>
|
|
`},q.strong=function(j){return"<strong>"+j+"</strong>"},q.em=function(j){return"<em>"+j+"</em>"},q.codespan=function(j){return"<code>"+j+"</code>"},q.br=function(){return this.options.xhtml?"<br/>":"<br>"},q.del=function(j){return"<del>"+j+"</del>"},q.link=function(j,W,G){if(j=Te(this.options.sanitize,this.options.baseUrl,j),j===null)return G;var X='<a href="'+Ie(j)+'"';return W&&(X+=' title="'+W+'"'),X+=">"+G+"</a>",X},q.image=function(j,W,G){if(j=Te(this.options.sanitize,this.options.baseUrl,j),j===null)return G;var X='<img src="'+j+'" alt="'+G+'"';return W&&(X+=' title="'+W+'"'),X+=this.options.xhtml?"/>":">",X},q.text=function(j){return j},re}(),Me=function(){function re(){}var q=re.prototype;return q.strong=function(j){return j},q.em=function(j){return j},q.codespan=function(j){return j},q.del=function(j){return j},q.html=function(j){return j},q.text=function(j){return j},q.link=function(j,W,G){return""+G},q.image=function(j,W,G){return""+G},q.br=function(){return""},re}(),Fe=function(){function re(){this.seen={}}var q=re.prototype;return q.slug=function(j){var W=j.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(W)){var G=W;do this.seen[G]++,W=G+"-"+this.seen[G];while(this.seen.hasOwnProperty(W))}return this.seen[W]=0,W},re}(),ae=_.defaults,ue=K.unescape,be=function(){function re(te){this.options=te||ae,this.options.renderer=this.options.renderer||new ke,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Me,this.slugger=new Fe}re.parse=function(j,W){var G=new re(W);return G.parse(j)};var q=re.prototype;return q.parse=function(j,W){W===void 0&&(W=!0);var G="",X,oe,ce,Pe,He,$e,ze,Ze,et,Xe,mt,rt,vt,ct,qe,yt,bt,Ve,wt=j.length;for(X=0;X<wt;X++){Xe=j[X];switch(Xe.type){case"space":continue;case"hr":{G+=this.renderer.hr();continue}case"heading":{G+=this.renderer.heading(this.parseInline(Xe.tokens),Xe.depth,ue(this.parseInline(Xe.tokens,this.textRenderer)),this.slugger);continue}case"code":{G+=this.renderer.code(Xe.text,Xe.lang,Xe.escaped);continue}case"table":{for(Ze="",ze="",Pe=Xe.header.length,oe=0;oe<Pe;oe++)ze+=this.renderer.tablecell(this.parseInline(Xe.tokens.header[oe]),{header:!0,align:Xe.align[oe]});for(Ze+=this.renderer.tablerow(ze),et="",Pe=Xe.cells.length,oe=0;oe<Pe;oe++){for($e=Xe.tokens.cells[oe],ze="",He=$e.length,ce=0;ce<He;ce++)ze+=this.renderer.tablecell(this.parseInline($e[ce]),{header:!1,align:Xe.align[ce]});et+=this.renderer.tablerow(ze)}G+=this.renderer.table(Ze,et);continue}case"blockquote":{et=this.parse(Xe.tokens),G+=this.renderer.blockquote(et);continue}case"list":{for(mt=Xe.ordered,rt=Xe.start,vt=Xe.loose,Pe=Xe.items.length,et="",oe=0;oe<Pe;oe++)qe=Xe.items[oe],yt=qe.checked,bt=qe.task,ct="",qe.task&&(Ve=this.renderer.checkbox(yt),vt?qe.tokens.length>0&&qe.tokens[0].type==="text"?(qe.tokens[0].text=Ve+" "+qe.tokens[0].text,qe.tokens[0].tokens&&qe.tokens[0].tokens.length>0&&qe.tokens[0].tokens[0].type==="text"&&(qe.tokens[0].tokens[0].text=Ve+" "+qe.tokens[0].tokens[0].text)):qe.tokens.unshift({type:"text",text:Ve}):ct+=Ve),ct+=this.parse(qe.tokens,vt),et+=this.renderer.listitem(ct,bt,yt);G+=this.renderer.list(et,mt,rt);continue}case"html":{G+=this.renderer.html(Xe.text);continue}case"paragraph":{G+=this.renderer.paragraph(this.parseInline(Xe.tokens));continue}case"text":{for(et=Xe.tokens?this.parseInline(Xe.tokens):Xe.text;X+1<wt&&j[X+1].type==="text";)Xe=j[++X],et+=`
|
|
`+(Xe.tokens?this.parseInline(Xe.tokens):Xe.text);G+=W?this.renderer.paragraph(et):et;continue}default:{var at='Token with "'+Xe.type+'" type was not found.';if(this.options.silent){console.error(at);return}else throw new Error(at)}}}return G},q.parseInline=function(j,W){W=W||this.renderer;var G="",X,oe,ce=j.length;for(X=0;X<ce;X++){oe=j[X];switch(oe.type){case"escape":{G+=W.text(oe.text);break}case"html":{G+=W.html(oe.text);break}case"link":{G+=W.link(oe.href,oe.title,this.parseInline(oe.tokens,W));break}case"image":{G+=W.image(oe.href,oe.title,oe.text);break}case"strong":{G+=W.strong(this.parseInline(oe.tokens,W));break}case"em":{G+=W.em(this.parseInline(oe.tokens,W));break}case"codespan":{G+=W.codespan(oe.text);break}case"br":{G+=W.br();break}case"del":{G+=W.del(this.parseInline(oe.tokens,W));break}case"text":{G+=W.text(oe.text);break}default:{var Pe='Token with "'+oe.type+'" type was not found.';if(this.options.silent){console.error(Pe);return}else throw new Error(Pe)}}}return G},re}(),xe=K.merge,Ce=K.checkSanitizeDeprecation,Se=K.escape,ye=_.getDefaults,Ne=_.changeDefaults,Be=_.defaults;function ve(re,q,te){if(typeof re=="undefined"||re===null)throw new Error("marked(): input parameter is undefined or null");if(typeof re!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(re)+", string expected");if(typeof q=="function"&&(te=q,q=null),q=xe({},ve.defaults,q||{}),Ce(q),te){var j=q.highlight,W;try{W=pe.lex(re,q)}catch(ce){return te(ce)}var G=function(Pe){var He;if(!Pe)try{He=be.parse(W,q)}catch($e){Pe=$e}return q.highlight=j,Pe?te(Pe):te(null,He)};if(!j||j.length<3)return G();if(delete q.highlight,!W.length)return G();var X=0;ve.walkTokens(W,function(ce){ce.type==="code"&&(X++,setTimeout(function(){j(ce.text,ce.lang,function(Pe,He){if(Pe)return G(Pe);He!=null&&He!==ce.text&&(ce.text=He,ce.escaped=!0),X--,X===0&&G()})},0))}),X===0&&G();return}try{var oe=pe.lex(re,q);return q.walkTokens&&ve.walkTokens(oe,q.walkTokens),be.parse(oe,q)}catch(ce){if(ce.message+=`
|
|
Please report this to https://github.com/markedjs/marked.`,q.silent)return"<p>An error occurred:</p><pre>"+Se(ce.message+"",!0)+"</pre>";throw ce}}ve.options=ve.setOptions=function(re){return xe(ve.defaults,re),Ne(ve.defaults),ve},ve.getDefaults=ye,ve.defaults=Be,ve.use=function(re){var q=xe({},re);if(re.renderer&&function(){var j=ve.defaults.renderer||new ke,W=function(oe){var ce=j[oe];j[oe]=function(){for(var Pe=arguments.length,He=new Array(Pe),$e=0;$e<Pe;$e++)He[$e]=arguments[$e];var ze=re.renderer[oe].apply(j,He);return ze===!1&&(ze=ce.apply(j,He)),ze}};for(var G in re.renderer)W(G);q.renderer=j}(),re.tokenizer&&function(){var j=ve.defaults.tokenizer||new de,W=function(oe){var ce=j[oe];j[oe]=function(){for(var Pe=arguments.length,He=new Array(Pe),$e=0;$e<Pe;$e++)He[$e]=arguments[$e];var ze=re.tokenizer[oe].apply(j,He);return ze===!1&&(ze=ce.apply(j,He)),ze}};for(var G in re.tokenizer)W(G);q.tokenizer=j}(),re.walkTokens){var te=ve.defaults.walkTokens;q.walkTokens=function(j){re.walkTokens(j),te&&te(j)}}ve.setOptions(q)},ve.walkTokens=function(re,q){for(var te=O(re),j;!(j=te()).done;){var W=j.value;q(W);switch(W.type){case"table":{for(var G=O(W.tokens.header),X;!(X=G()).done;){var oe=X.value;ve.walkTokens(oe,q)}for(var ce=O(W.tokens.cells),Pe;!(Pe=ce()).done;)for(var He=Pe.value,$e=O(He),ze;!(ze=$e()).done;){var Ze=ze.value;ve.walkTokens(Ze,q)}break}case"list":{ve.walkTokens(W.items,q);break}default:W.tokens&&ve.walkTokens(W.tokens,q)}}},ve.Parser=be,ve.parser=be.parse,ve.Renderer=ke,ve.TextRenderer=Me,ve.Lexer=pe,ve.lexer=pe.lex,ve.Tokenizer=de,ve.Slugger=Fe,ve.parse=ve;var _e=ve;return _e})},Etsf:function(nt,We,J){"use strict";J.r(We);var fe=J("5Dmo"),U=J("3S7+"),C=J("14J3"),B=J("BMrR"),O=J("jCWc"),L=J("kPKH"),_=J("sPJy"),M=J("bE4q"),A=J("k1fw"),w=J("9og8"),g=J("y8nQ"),x=J("Vl3Y"),S=J("tJVT"),E=J("PpiC"),b=J("WmNS"),y=J.n(b),h=J("q1tI"),e=J.n(h),s=J("55Ip"),o=J("9kvl"),f=J("9Bee"),u=J("xKgJ"),l=J("U/Y8"),p=J.n(l),c=J("Q9mQ"),i=J("diRs"),r=J("miYZ"),t=J("tsqr"),a=J("2qtc"),m=J("kLXV"),v=J("oBTY"),T=J("ozfa"),k=J("MJZm"),I=J("5NDa"),F=J("5rEg"),K=J("jrin"),V=J("nRaC"),Q=J("5RzL"),Z=J("ErOA"),ie=J("Ty5D"),ge=Q.a.TreeNode,se=function(Ee){var Te=Ee.restful,Ie=Ee.loading,ke=Ee.dispatch,Me=Object(ie.i)(),Fe=Object(ie.h)(),ae=Object(h.useState)(!1),ue=Object(S.a)(ae,2),be=ue[0],xe=ue[1],Ce=Object(h.useState)(),Se=Object(S.a)(Ce,2),ye=Se[0],Ne=Se[1],Be=Te.actionTabs,ve=x.a.useForm(),_e=Object(S.a)(ve,1),re=_e[0];return Object(h.useEffect)(function(){Te.actionTabs.key=="\u65B0\u5EFA\u540C\u7EA7\u76EE\u5F55"&&re.resetFields()},[Te.actionTabs.key]),Te.actionTabs.key!=="\u65B0\u5EFA\u540C\u7EA7\u76EE\u5F55"?null:e.a.createElement(m.a,{centered:!0,title:"\u65B0\u5EFA\u76EE\u5F55",visible:Te.actionTabs.key==="\u65B0\u5EFA\u540C\u7EA7\u76EE\u5F55",okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",bodyStyle:{minHeight:150},confirmLoading:be,onOk:Object(w.a)(y.a.mark(function q(){var te,j,W;return y.a.wrap(function(X){for(;;)switch(X.prev=X.next){case 0:return X.next=2,re.validateFields();case 2:return te=re.getFieldValue(),xe(!0),j="/api/restfuls.json",X.next=7,Object(Z.a)(j,{method:"post",body:Object(A.a)({file_type:1},te)});case 7:W=X.sent,W.status===0&&(t.b.success("\u6DFB\u52A0\u6210\u529F"),ke({type:"restful/setActionTabs",payload:{}}),ke({type:"restful/getRestful"})),xe(!1);case 10:case"end":return X.stop()}},q)})),onCancel:function(){ke({type:"restful/setActionTabs",payload:{}})}},e.a.createElement("div",{className:"pl30 pr30"},e.a.createElement(x.a,{form:re,initialValues:Object(K.a)({},"name","")},e.a.createElement(x.a.Item,{name:"name",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u76EE\u5F55\u540D\u79F0"}]},e.a.createElement(B.a,{className:"mt30"},e.a.createElement(L.a,{flex:"80px",className:"font14"},"\u76EE\u5F55\u540D\u79F0\uFF1A"),e.a.createElement(L.a,{flex:"1"},e.a.createElement(F.a,{placeholder:"\u8BF7\u8F93\u5165\u540D\u79F0\uFF0C\u6700\u5927\u9650\u523660\u4E2A\u5B57\u7B26 ",maxLength:60})))))))},he=Object(o.a)(function(pe){var Ee=pe.restful,Te=pe.loading;return{restful:Ee,loading:Te}})(se),de=Q.a.TreeNode,$=function(Ee){var Te=Ee.restful,Ie=Ee.loading,ke=Ee.dispatch,Me=Object(ie.i)(),Fe=Object(ie.h)(),ae=Object(h.useState)(!1),ue=Object(S.a)(ae,2),be=ue[0],xe=ue[1],Ce=Object(h.useState)(),Se=Object(S.a)(Ce,2),ye=Se[0],Ne=Se[1],Be=Te.actionTabs,ve=x.a.useForm(),_e=Object(S.a)(ve,1),re=_e[0];return Object(h.useEffect)(function(){Te.actionTabs.key=="\u91CD\u547D\u540D"&&(re.resetFields(),re.setFieldsValue({name:Te.actionTabs.data.title}))},[Te.actionTabs.key]),Te.actionTabs.key!=="\u91CD\u547D\u540D"?null:e.a.createElement(m.a,{centered:!0,title:"\u91CD\u547D\u540D",visible:Te.actionTabs.key==="\u91CD\u547D\u540D",okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",bodyStyle:{minHeight:150},confirmLoading:be,onOk:Object(w.a)(y.a.mark(function q(){var te,j,W;return y.a.wrap(function(X){for(;;)switch(X.prev=X.next){case 0:return X.next=2,re.validateFields();case 2:return te=re.getFieldValue(),xe(!0),j="/api/restfuls/".concat(Te.actionTabs.data.id,".json"),X.next=7,Object(Z.a)(j,{method:"put",body:Object(A.a)({file_type:1},te)});case 7:W=X.sent,W.status===0&&(t.b.success("\u4FEE\u6539\u6210\u529F"),ke({type:"restful/setActionTabs",payload:{}}),ke({type:"restful/getRestful"})),xe(!1);case 10:case"end":return X.stop()}},q)})),onCancel:function(){ke({type:"restful/setActionTabs",payload:{}})}},e.a.createElement("div",{className:"pl30 pr30"},e.a.createElement(x.a,{form:re,initialValues:Object(K.a)({},"name","")},e.a.createElement(B.a,{className:"mt30"},e.a.createElement(L.a,{flex:"80px",className:"font14"},"\u76EE\u5F55\u540D\u79F0\uFF1A"),e.a.createElement(L.a,{flex:"1"},e.a.createElement(x.a.Item,{name:"name",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u65B0\u540D\u79F0"}]},e.a.createElement(F.a,{placeholder:"\u8BF7\u8F93\u5165\u540D\u79F0\uFF0C\u6700\u5927\u9650\u523660\u4E2A\u5B57\u7B26 ",maxLength:60})))))))},Y=Object(o.a)(function(pe){var Ee=pe.restful,Te=pe.loading;return{restful:Ee,loading:Te}})($),ne=J("s7vb"),z=J("P48q"),H=J.n(z),me=F.a.Search,Le=k.a.DirectoryTree,Oe=function(Ee){var Te=Ee.user,Ie=Ee.globalSetting,ke=Ee.loading,Me=Ee.dispatch,Fe=Ee.restful,ae=Object(E.a)(Ee,["user","globalSetting","loading","dispatch","restful"]),ue=Object(h.useState)({content:"",message:"",status:0,contacts:[],address:"",data:[]}),be=Object(S.a)(ue,2),xe=be[0],Ce=be[1],Se=Object(h.useState)(!0),ye=Object(S.a)(Se,2),Ne=ye[0],Be=ye[1],ve=x.a.useForm(),_e=Object(S.a)(ve,1),re=_e[0],q=Object(h.useState)(""),te=Object(S.a)(q,2),j=te[0],W=te[1],G=Object(h.useState)([{id:1,name:"\u65B0\u5EFA\u6587\u4EF6"},{id:2,name:"\u65B0\u5EFA\u540C\u7EA7\u76EE\u5F55"},{id:3,name:"\u91CD\u547D\u540D"},{id:4,name:"\u7F16\u8F91"},{id:5,name:"\u5220\u9664"}]),X=Object(S.a)(G,1),oe=X[0],ce=Object(h.useState)([]),Pe=Object(S.a)(ce,2),He=Pe[0],$e=Pe[1],ze=Object(h.useState)([]),Ze=Object(S.a)(ze,2),et=Ze[0],Xe=Ze[1],mt=Object(h.useState)(!1),rt=Object(S.a)(mt,2),vt=rt[0],ct=rt[1],qe=Object(h.useState)([]),yt=Object(S.a)(qe,2),bt=yt[0],Ve=yt[1];Object(h.useEffect)(function(){var it;if((it=Fe.restful)!==null&&it!==void 0&&it.data){var Qe,Ye,ot;Ve(Object(v.a)((Qe=Fe.restful)===null||Qe===void 0?void 0:Qe.data));var dt=0,tt;if((Ye=Fe.restful)===null||Ye===void 0||((ot=Ye.data)===null||ot===void 0)||ot.map(function(st){var ft;st.id==ae.match.params.id&&(dt=st.id),st.file_type==0&&!tt&&(tt=st.id),st==null||((ft=st.children)===null||ft===void 0)||ft.map(function(Ot){tt||(tt=Ot.id),Ot.id==ae.match.params.id&&(dt=st.id)}),!st.children&&!tt&&(tt=st.id)}),!ae.match.params.id&&tt){ae.history.push("/ch/rest/".concat(tt));return}dt&&setTimeout(function(){$e([dt]),Xe([Number(ae.match.params.id||tt)])},200)}},[Fe.restful]);var wt=function(Qe,Ye){Ye.node.file_type===0?ae.history.push("/ch/rest/".concat(Qe[0])):Xe(Object(v.a)(Qe)),console.log("Trigger Select",Qe,Ye)},at=function(Qe){$e(Qe),console.log("Trigger Expand",Qe)},ut=function(Qe){return e.a.createElement("div",null,oe.map(function(Ye,ot){return e.a.createElement("p",{key:Ye.id,className:"current",onClick:function(){switch(Ye.id){case 1:ae.history.push("/ch/rest/edit/".concat(Qe.id,"/0"));break;case 2:case 3:Me({type:"restful/setActionTabs",payload:{key:Ye.name,data:Qe}});break;case 4:document.location.href="/ch/rest/edit/".concat(Qe.pid||0,"/").concat(Qe.id);break;case 5:m.a.confirm({title:"\u63D0\u793A",content:"\u662F\u5426\u786E\u5B9A\u5220\u9664\uFF1F",onOk:function(){var tt=Object(w.a)(y.a.mark(function ft(){var Ot;return y.a.wrap(function(_t){for(;;)switch(_t.prev=_t.next){case 0:return _t.next=2,Object(ne.a)({id:Qe.id});case 2:Ot=_t.sent,(Ot==null?void 0:Ot.status)==0&&(t.b.success("\u5220\u9664\u6210\u529F"),Me({type:"restful/getRestful"}));case 4:case"end":return _t.stop()}},ft)}));function st(){return tt.apply(this,arguments)}return st}()});break}}},Ye.name)}).filter(function(Ye){return!!Ye}).filter(function(Ye){return Qe.pid||Qe.file_type==0?Ye.key>3:Ye.key!=4}))},At=function it(Qe){return Qe.map(function(Ye){var ot=Ye.title.indexOf(j),dt=Ye.title.substr(0,ot),tt=Ye.title.substr(ot+j.length),st=e.a.createElement("span",null,dt,e.a.createElement("span",{className:"c-blue"},j),tt,Object(u.o)()&&e.a.createElement(i.a,{placement:"right",title:j,content:function(){return ut(Ye)},trigger:"hover"},e.a.createElement("span",{className:"iconfont icon-sandian ".concat(H.a.actions)})));if(j!==""){var ft;if(ot===-1&&!((ft=Ye.children)!==null&&ft!==void 0&&ft.length))return null}return Ye.children&&Ye.file_type===1?Object(A.a)(Object(A.a)({},Ye),{},{title:st,key:Ye.key,children:it(Ye.children)}):Object(A.a)(Object(A.a)({},Ye),{},{title:st,key:Ye.key,isLeaf:!0})}).filter(function(Ye){return!!Ye})},St=function it(Qe,Ye){for(var ot,dt=0;dt<Ye.length;dt++){var tt=Ye[dt];tt.children&&(tt.children.some(function(st){return st.key===Qe})?ot=tt.key:it(Qe,tt.children)&&(ot=it(Qe,tt.children)))}return ot},Rt=function(Qe){var Ye=Qe.target.value,ot=bt.map(function(dt){if(dt!=null&&dt.children){var tt;return dt!=null&&(tt=dt.children.filter(function(st){return st.title.indexOf(Ye)>-1}))!==null&&tt!==void 0&&tt.length?dt.id:null}return null});W(Ye),ct(!0),console.log("expandedKeys:",ot),$e(ot)};return console.log("loop(treeData):",At(bt)),e.a.createElement("div",{className:H.a.tree},e.a.createElement(me,{style:{marginBottom:8},placeholder:"\u8F93\u5165\u5173\u952E\u5B57\u68C0\u7D22",onChange:Rt}),e.a.createElement(Le,{multiple:!0,defaultExpandAll:!0,onSelect:wt,onExpand:at,expandedKeys:He,selectedKeys:et,autoExpandParent:vt,treeData:At(bt)}),e.a.createElement(he,null),e.a.createElement(Y,null))},we=Object(o.a)(function(pe){var Ee=pe.user,Te=pe.loading,Ie=pe.globalSetting,ke=pe.restful;return{user:Ee,globalSetting:Ie,restful:ke,loading:Te.models.index}})(Oe),De=function(Ee){var Te,Ie,ke=Ee.user,Me=Ee.globalSetting,Fe=Ee.loading,ae=Ee.dispatch,ue=Ee.restful,be=Object(E.a)(Ee,["user","globalSetting","loading","dispatch","restful"]),xe=Object(h.useState)({content:"",message:"",status:0,contacts:[],address:"",data:[]}),Ce=Object(S.a)(xe,2),Se=Ce[0],ye=Ce[1],Ne=Object(h.useState)(!0),Be=Object(S.a)(Ne,2),ve=Be[0],_e=Be[1],re=x.a.useForm(),q=Object(S.a)(re,1),te=q[0],j=be.match.params,W=function(){var oe=Object(w.a)(y.a.mark(function ce(){return y.a.wrap(function(He){for(;;)switch(He.prev=He.next){case 0:ae({type:"restful/getRestful"}),j.id&&ae({type:"restful/getRestfulDetail",payload:Object(A.a)({},j)});case 2:case"end":return He.stop()}},ce)}));return function(){return oe.apply(this,arguments)}}();Object(h.useEffect)(function(){_e(!0),W()},[j.id]);var G=function(){ae({type:"restful/setActionTabs",payload:{key:"\u65B0\u5EFA\u540C\u7EA7\u76EE\u5F55"}})},X=function(){var ce;if((ce=ue.restful)!==null&&ce!==void 0&&ce.data){var Pe,He,$e=0;return(Pe=ue.restful)===null||Pe===void 0||((He=Pe.data)===null||He===void 0)||He.map(function(ze){var Ze;ze==null||((Ze=ze.children)===null||Ze===void 0)||Ze.map(function(et){et.id==be.match.params.id&&($e=ze.id)}),!ze.children&&!$e&&($e=ze.id)}),$e}return 0};return e.a.createElement("section",null,e.a.createElement("aside",{className:"edu-container mt20"},e.a.createElement(M.a,null,e.a.createElement(M.a.Item,null,e.a.createElement(s.a,{to:"/"},"\u9996\u9875")),e.a.createElement(M.a.Item,null,e.a.createElement(s.a,{to:"/ch/rest"},"API\u6587\u6863"))),e.a.createElement("div",{className:"mt20"},e.a.createElement(B.a,{gutter:[20,20]},e.a.createElement(L.a,{flex:"300px"},e.a.createElement(we,be)),e.a.createElement(L.a,{flex:"1"},e.a.createElement("div",{className:p.a.info},e.a.createElement("h1",{style:{fontSize:28,paddingBottom:15,borderBottom:"1px solid #eaeaea",textAlign:"center"}},(Te=ue.restfulDetail)===null||Te===void 0?void 0:Te.name),e.a.createElement(f.a,{value:(Ie=ue.restfulDetail)===null||Ie===void 0?void 0:Ie.description}))))),Object(u.o)()&&e.a.createElement("div",{className:p.a.bar},e.a.createElement(B.a,null,!!X()&&e.a.createElement(L.a,null,e.a.createElement(U.a,{title:"\u7F16\u8F91\u6587\u4EF6"},e.a.createElement(s.a,{to:"/ch/rest/edit/".concat(X(),"/").concat(be.match.params.id),className:"icon-zhongmingming current"}))),e.a.createElement(L.a,null,e.a.createElement(U.a,{title:"\u6DFB\u52A0\u6587\u4EF6"},e.a.createElement(s.a,{to:"/ch/rest/edit/".concat(X(),"/0"),className:"icon-tianjiatimu current"}))),e.a.createElement(L.a,null,e.a.createElement(U.a,{title:"\u65B0\u5EFA\u6587\u4EF6\u5939"},e.a.createElement("span",{className:"icon-wenjianjia1 current",onClick:G})))))))},le=We.default=Object(o.a)(function(pe){var Ee=pe.user,Te=pe.loading,Ie=pe.globalSetting,ke=pe.restful;return{user:Ee,globalSetting:Ie,restful:ke,loading:Te.models.index}})(De)},NvD2:function(nt,We,J){"use strict";J.d(We,"a",function(){return L});var fe=J("Kwbf");function U(_,M){var A=new Set;return _.forEach(function(w){M.has(w)||A.add(w)}),A}function C(_){var M=_||{},A=M.disabled,w=M.disableCheckbox,g=M.checkable;return!!(A||w)||g===!1}function B(_,M,A,w){for(var g=new Set(_),x=new Set,S=0;S<=A;S+=1){var E=M.get(S)||new Set;E.forEach(function(e){var s=e.key,o=e.node,f=e.children,u=f===void 0?[]:f;g.has(s)&&!w(o)&&u.filter(function(l){return!w(l.node)}).forEach(function(l){g.add(l.key)})})}for(var b=new Set,y=A;y>=0;y-=1){var h=M.get(y)||new Set;h.forEach(function(e){var s=e.parent,o=e.node;if(w(o)||!e.parent||b.has(e.parent.key))return;if(w(e.parent.node)){b.add(s.key);return}var f=!0,u=!1;(s.children||[]).filter(function(l){return!w(l.node)}).forEach(function(l){var p=l.key,c=g.has(p);f&&!c&&(f=!1),!u&&(c||x.has(p))&&(u=!0)}),f&&g.add(s.key),u&&x.add(s.key),b.add(s.key)})}return{checkedKeys:Array.from(g),halfCheckedKeys:Array.from(U(x,g))}}function O(_,M,A,w,g){for(var x=new Set(_),S=new Set(M),E=0;E<=w;E+=1){var b=A.get(E)||new Set;b.forEach(function(s){var o=s.key,f=s.node,u=s.children,l=u===void 0?[]:u;!x.has(o)&&!S.has(o)&&!g(f)&&l.filter(function(p){return!g(p.node)}).forEach(function(p){x.delete(p.key)})})}S=new Set;for(var y=new Set,h=w;h>=0;h-=1){var e=A.get(h)||new Set;e.forEach(function(s){var o=s.parent,f=s.node;if(g(f)||!s.parent||y.has(s.parent.key))return;if(g(s.parent.node)){y.add(o.key);return}var u=!0,l=!1;(o.children||[]).filter(function(p){return!g(p.node)}).forEach(function(p){var c=p.key,i=x.has(c);u&&!i&&(u=!1),!l&&(i||S.has(c))&&(l=!0)}),u||x.delete(o.key),l&&S.add(o.key),y.add(o.key)})}return{checkedKeys:Array.from(x),halfCheckedKeys:Array.from(U(S,x))}}function L(_,M,A,w){var g=[],x;w?x=w:x=C;var S=new Set(_.filter(function(h){var e=!!A[h];return e||g.push(h),e})),E=new Map,b=0;Object.keys(A).forEach(function(h){var e=A[h],s=e.level,o=E.get(s);o||(o=new Set,E.set(s,o)),o.add(e),b=Math.max(b,s)}),Object(fe.a)(!g.length,"Tree missing follow keys: ".concat(g.slice(0,100).map(function(h){return"'".concat(h,"'")}).join(", ")));var y;return M===!0?y=B(S,E,b,x):y=O(S,M.halfCheckedKeys,E,b,x),y}},OZM5:function(nt,We,J){"use strict";J.d(We,"b",function(){return w}),J.d(We,"a",function(){return g}),J.d(We,"k",function(){return x}),J.d(We,"h",function(){return S}),J.d(We,"i",function(){return E}),J.d(We,"g",function(){return b}),J.d(We,"c",function(){return y}),J.d(We,"d",function(){return h}),J.d(We,"j",function(){return o}),J.d(We,"e",function(){return f}),J.d(We,"f",function(){return u});var fe=J("KQm4"),U=J("U8pU"),C=J("Ff2n"),B=J("q1tI"),O=J.n(B),L=J("Kwbf"),_=J("WaYH"),M=.25,A=2;function w(l,p){var c=l.slice(),i=c.indexOf(p);return i>=0&&c.splice(i,1),c}function g(l,p){var c=l.slice();return c.indexOf(p)===-1&&c.push(p),c}function x(l){return l.split("-")}function S(l,p){return"".concat(l,"-").concat(p)}function E(l){return l&&l.type&&l.type.isTreeNode}function b(l,p){var c=[l],i=p[l];function r(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];t.forEach(function(a){var m=a.key,v=a.children;c.push(m),r(v)})}return r(i.children),c}function y(l,p){var c=l.clientY,i=p.selectHandle.getBoundingClientRect(),r=i.top,t=i.bottom,a=i.height,m=Math.max(a*M,A);return c<=r+m?-1:c>=t-m?1:0}function h(l,p){if(!l)return;var c=p.multiple;return c?l.slice():l.length?[l[0]]:l}var e=function(p){return p};function s(l,p){if(!l)return[];var c=p||{},i=c.processProps,r=i===void 0?e:i,t=Array.isArray(l)?l:[l];return t.map(function(a){var m=a.children,v=Object(C.a)(a,["children"]),T=s(m,p);return O.a.createElement(_.a,Object.assign({},r(v)),T)})}function o(l){if(!l)return null;var p;if(Array.isArray(l))p={checkedKeys:l,halfCheckedKeys:void 0};else if(Object(U.a)(l)==="object")p={checkedKeys:l.checked||void 0,halfCheckedKeys:l.halfChecked||void 0};else return Object(L.a)(!1,"`checkedKeys` is not an array or an object"),null;return p}function f(l,p){var c=new Set;function i(r){if(c.has(r))return;var t=p[r];if(!t)return;c.add(r);var a=t.parent,m=t.node;if(m.disabled)return;a&&i(a.key)}return(l||[]).forEach(function(r){i(r)}),Object(fe.a)(c)}function u(l){var p={};return Object.keys(l).forEach(function(c){(c.startsWith("data-")||c.startsWith("aria-"))&&(p[c]=l[c])}),p}},P48q:function(nt,We,J){nt.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:function(nt,We){/**
|
|
* @license
|
|
* Copyright (C) 2006 Google Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/var J,fe,U,C=!1,B,O;window.PR_SHOULD_USE_CONTINUATION=!0;var L,_;(function(){var M=window,A=["break,continue,do,else,for,if,return,while"],w=[A,"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"],g=[w,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],x=[g,"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"],S=[g,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],E=[g,"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"],b="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",y=[g,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],h="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",e=[A,"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"],s=[A,"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"],o=[A,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],f=[x,E,S,y,h,e,s,o],u=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,l="str",p="kwd",c="com",i="typ",r="lit",t="pun",a="pln",m="tag",v="dec",T="src",k="atn",I="atv",F="nocode",K="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function V(le){for(var pe=0,Ee=!1,Te=!1,Ie=0,ke=le.length;Ie<ke;++Ie){var Me=le[Ie];if(Me.ignoreCase)Te=!0;else if(/[a-z]/i.test(Me.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){Ee=!0,Te=!1;break}}var Fe={b:8,t:9,n:10,v:11,f:12,r:13};function ae(Se){var ye=Se.charCodeAt(0);if(ye!==92)return ye;var Ne=Se.charAt(1);return ye=Fe[Ne],ye||("0"<=Ne&&Ne<="7"?parseInt(Se.substring(1),8):Ne==="u"||Ne==="x"?parseInt(Se.substring(2),16):Se.charCodeAt(1))}function ue(Se){if(Se<32)return(Se<16?"\\x0":"\\x")+Se.toString(16);var ye=String.fromCharCode(Se);return ye==="\\"||ye==="-"||ye==="]"||ye==="^"?"\\"+ye:ye}function be(Se){var ye=Se.substring(1,Se.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")),Ne=[],Be=ye[0]==="^",ve=["["];Be&&ve.push("^");for(var _e=Be?1:0,re=ye.length;_e<re;++_e){var q=ye[_e];if(/\\[bdsw]/i.test(q))ve.push(q);else{var te=ae(q),j;_e+2<re&&ye[_e+1]==="-"?(j=ae(ye[_e+2]),_e+=2):j=te,Ne.push([te,j]),j<65||te>122||(j<65||te>90||Ne.push([Math.max(65,te)|32,Math.min(j,90)|32]),j<97||te>122||Ne.push([Math.max(97,te)&~32,Math.min(j,122)&~32]))}}Ne.sort(function(oe,ce){return oe[0]-ce[0]||ce[1]-oe[1]});for(var W=[],G=[],_e=0;_e<Ne.length;++_e){var X=Ne[_e];X[0]<=G[1]+1?G[1]=Math.max(G[1],X[1]):W.push(G=X)}for(var _e=0;_e<W.length;++_e){var X=W[_e];ve.push(ue(X[0])),X[1]>X[0]&&(X[1]+1>X[0]&&ve.push("-"),ve.push(ue(X[1])))}return ve.push("]"),ve.join("")}function xe(Se){for(var ye=Se.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")),Ne=ye.length,Be=[],ve=0,_e=0;ve<Ne;++ve){var re=ye[ve];if(re==="(")++_e;else if(re.charAt(0)==="\\"){var q=+re.substring(1);q&&(q<=_e?Be[q]=-1:ye[ve]=ue(q))}}for(var ve=1;ve<Be.length;++ve)Be[ve]===-1&&(Be[ve]=++pe);for(var ve=0,_e=0;ve<Ne;++ve){var re=ye[ve];if(re==="(")++_e,Be[_e]||(ye[ve]="(?:");else if(re.charAt(0)==="\\"){var q=+re.substring(1);q&&q<=_e&&(ye[ve]="\\"+Be[q])}}for(var ve=0;ve<Ne;++ve)ye[ve]==="^"&&ye[ve+1]!=="^"&&(ye[ve]="");if(Se.ignoreCase&&Ee)for(var ve=0;ve<Ne;++ve){var re=ye[ve],te=re.charAt(0);re.length>=2&&te==="["?ye[ve]=be(re):te!=="\\"&&(ye[ve]=re.replace(/[a-zA-Z]/g,function(G){var X=G.charCodeAt(0);return"["+String.fromCharCode(X&~32,X|32)+"]"}))}return ye.join("")}for(var Ce=[],Ie=0,ke=le.length;Ie<ke;++Ie){var Me=le[Ie];if(Me.global||Me.multiline)throw new Error(""+Me);Ce.push("(?:"+xe(Me)+")")}return new RegExp(Ce.join("|"),Te?"gi":"g")}function Q(le,pe){var Ee=/(?:^|\s)nocode(?:\s|$)/,Te=[],Ie=0,ke=[],Me=0;function Fe(ae){var ue=ae.nodeType;if(ue==1){if(Ee.test(ae.className))return;for(var be=ae.firstChild;be;be=be.nextSibling)Fe(be);var xe=ae.nodeName.toLowerCase();(xe==="br"||xe==="li")&&(Te[Me]=`
|
|
`,ke[Me<<1]=Ie++,ke[Me++<<1|1]=ae)}else if(ue==3||ue==4){var Ce=ae.nodeValue;Ce.length&&(pe?Ce=Ce.replace(/\r\n?/g,`
|
|
`):Ce=Ce.replace(/[ \t\r\n]+/g," "),Te[Me]=Ce,ke[Me<<1]=Ie,Ie+=Ce.length,ke[Me++<<1|1]=ae)}}return Fe(le),{sourceCode:Te.join("").replace(/\n$/,""),spans:ke}}function Z(le,pe,Ee,Te,Ie){if(!Ee)return;var ke={sourceNode:le,pre:1,langExtension:null,numberLines:null,sourceCode:Ee,spans:null,basePos:pe,decorations:null};Te(ke),Ie.push.apply(Ie,ke.decorations)}var ie=/\S/;function ge(le){for(var pe=void 0,Ee=le.firstChild;Ee;Ee=Ee.nextSibling){var Te=Ee.nodeType;pe=Te===1?pe?le:Ee:Te===3&&ie.test(Ee.nodeValue)?le:pe}return pe===le?void 0:pe}function se(le,pe){var Ee={},Te;(function(){for(var Me=le.concat(pe),Fe=[],ae={},ue=0,be=Me.length;ue<be;++ue){var xe=Me[ue],Ce=xe[3];if(Ce)for(var Se=Ce.length;--Se>=0;)Ee[Ce.charAt(Se)]=xe;var ye=xe[1],Ne=""+ye;ae.hasOwnProperty(Ne)||(Fe.push(ye),ae[Ne]=null)}Fe.push(/[\0-\uffff]/),Te=V(Fe)})();var Ie=pe.length,ke=function(Me){for(var Fe=Me.sourceCode,ae=Me.basePos,ue=Me.sourceNode,be=[ae,a],xe=0,Ce=Fe.match(Te)||[],Se={},ye=0,Ne=Ce.length;ye<Ne;++ye){var Be=Ce[ye],ve=Se[Be],_e=void 0,re;if(typeof ve=="string")re=!1;else{var q=Ee[Be.charAt(0)];if(q)_e=Be.match(q[1]),ve=q[0];else{for(var te=0;te<Ie;++te)if(q=pe[te],_e=Be.match(q[1]),_e){ve=q[0];break}_e||(ve=a)}re=ve.length>=5&&ve.substring(0,5)==="lang-",re&&!(_e&&typeof _e[1]=="string")&&(re=!1,ve=T),re||(Se[Be]=ve)}var j=xe;if(xe+=Be.length,!re)be.push(ae+j,ve);else{var W=_e[1],G=Be.indexOf(W),X=G+W.length;_e[2]&&(X=Be.length-_e[2].length,G=X-W.length);var oe=ve.substring(5);Z(ue,ae+j,Be.substring(0,G),ke,be),Z(ue,ae+j+G,W,H(oe,W),be),Z(ue,ae+j+X,Be.substring(X),ke,be)}}Me.decorations=be};return ke}function he(le){var pe=[],Ee=[];le.tripleQuotedStrings?pe.push([l,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):le.multiLineStrings?pe.push([l,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):pe.push([l,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),le.verbatimStrings&&Ee.push([l,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Te=le.hashComments;Te&&(le.cStyleComments?(Te>1?pe.push([c,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):pe.push([c,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),Ee.push([l,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):pe.push([c,/^#[^\r\n]*/,null,"#"])),le.cStyleComments&&(Ee.push([c,/^\/\/[^\r\n]*/,null]),Ee.push([c,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var Ie=le.regexLiterals;if(Ie){var ke=Ie>1?"":`
|
|
\r`,Me=ke?".":"[\\S\\s]",Fe="/(?=[^/*"+ke+"])(?:[^/\\x5B\\x5C"+ke+"]|\\x5C"+Me+"|\\x5B(?:[^\\x5C\\x5D"+ke+"]|\\x5C"+Me+")*(?:\\x5D|$))+/";Ee.push(["lang-regex",RegExp("^"+K+"("+Fe+")")])}var ae=le.types;ae&&Ee.push([i,ae]);var ue=(""+le.keywords).replace(/^ | $/g,"");ue.length&&Ee.push([p,new RegExp("^(?:"+ue.replace(/[\s,]+/g,"|")+")\\b"),null]),pe.push([a,/^\s+/,null,` \r
|
|
\xA0`]);var be="^.[^\\s\\w.$@'\"`/\\\\]*";return le.regexLiterals&&(be+="(?!s*/)"),Ee.push([r,/^@[a-z_$][a-z_$@0-9]*/i,null],[i,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[a,/^[a-z_$][a-z_$@0-9]*/i,null],[r,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[a,/^\\[\s\S]?/,null],[t,new RegExp(be),null]),se(pe,Ee)}var de=he({keywords:f,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function $(le,pe,Ee){for(var Te=/(?:^|\s)nocode(?:\s|$)/,Ie=/\r\n?|\n/,ke=le.ownerDocument,Me=ke.createElement("li");le.firstChild;)Me.appendChild(le.firstChild);var Fe=[Me];function ae(ye){var Ne=ye.nodeType;if(Ne==1&&!Te.test(ye.className))if(ye.nodeName==="br")ue(ye),ye.parentNode&&ye.parentNode.removeChild(ye);else for(var Be=ye.firstChild;Be;Be=Be.nextSibling)ae(Be);else if((Ne==3||Ne==4)&&Ee){var ve=ye.nodeValue,_e=ve.match(Ie);if(_e){var re=ve.substring(0,_e.index);ye.nodeValue=re;var q=ve.substring(_e.index+_e[0].length);if(q){var te=ye.parentNode;te.insertBefore(ke.createTextNode(q),ye.nextSibling)}ue(ye),re||ye.parentNode.removeChild(ye)}}}function ue(ye){for(;!ye.nextSibling;)if(ye=ye.parentNode,!ye)return;function Ne(_e,re){var q=re?_e.cloneNode(!1):_e,te=_e.parentNode;if(te){var j=Ne(te,1),W=_e.nextSibling;j.appendChild(q);for(var G=W;G;G=W)W=G.nextSibling,j.appendChild(G)}return q}for(var Be=Ne(ye.nextSibling,0),ve;(ve=Be.parentNode)&&ve.nodeType===1;)Be=ve;Fe.push(Be)}for(var be=0;be<Fe.length;++be)ae(Fe[be]);pe===(pe|0)&&Fe[0].setAttribute("value",pe);var xe=ke.createElement("ol");xe.className="linenums";for(var Ce=Math.max(0,pe-1|0)||0,be=0,Se=Fe.length;be<Se;++be)Me=Fe[be],Me.className="L"+(be+Ce)%10,Me.firstChild||Me.appendChild(ke.createTextNode("\xA0")),xe.appendChild(Me);le.appendChild(xe)}function Y(le){var pe=/\bMSIE\s(\d+)/.exec(navigator.userAgent);pe=pe&&+pe[1]<=8;var Ee=/\n/g,Te=le.sourceCode,Ie=Te.length,ke=0,Me=le.spans,Fe=Me.length,ae=0,ue=le.decorations,be=ue.length,xe=0;ue[be]=Ie;var Ce,Se;for(Se=Ce=0;Se<be;)ue[Se]!==ue[Se+2]?(ue[Ce++]=ue[Se++],ue[Ce++]=ue[Se++]):Se+=2;for(be=Ce,Se=Ce=0;Se<be;){for(var ye=ue[Se],Ne=ue[Se+1],Be=Se+2;Be+2<=be&&ue[Be+1]===Ne;)Be+=2;ue[Ce++]=ye,ue[Ce++]=Ne,Se=Be}be=ue.length=Ce;var ve=le.sourceNode,_e="";ve&&(_e=ve.style.display,ve.style.display="none");try{for(var re=null;ae<Fe;){var q=Me[ae],te=Me[ae+2]||Ie,j=ue[xe+2]||Ie,Be=Math.min(te,j),W=Me[ae+1],G;if(W.nodeType!==1&&(G=Te.substring(ke,Be))){pe&&(G=G.replace(Ee,"\r")),W.nodeValue=G;var X=W.ownerDocument,oe=X.createElement("span");oe.className=ue[xe+1];var ce=W.parentNode;ce.replaceChild(oe,W),oe.appendChild(W),ke<te&&(Me[ae+1]=W=X.createTextNode(Te.substring(Be,te)),ce.insertBefore(W,oe.nextSibling))}ke=Be,ke>=te&&(ae+=2),ke>=j&&(xe+=2)}}finally{ve&&(ve.style.display=_e)}}var ne={};function z(le,pe){for(var Ee=pe.length;--Ee>=0;){var Te=pe[Ee];ne.hasOwnProperty(Te)?M.console&&console.warn("cannot override language handler %s",Te):ne[Te]=le}}function H(le,pe){return le&&ne.hasOwnProperty(le)||(le=/^\s*</.test(pe)?"default-markup":"default-code"),ne[le]}z(de,["default-code"]),z(se([],[[a,/^[^<?]+/],[v,/^<!\w[^>]*(?:>|$)/],[c,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[t,/^(?:<[%?]|[%?]>)/],["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"]),z(se([[a,/^[\s]+/,null,` \r
|
|
`],[I,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[k,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[t,/^[=<>\/]+/],["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"]),z(se([],[[I,/^[\s\S]+/]]),["uq.val"]),z(he({keywords:x,hashComments:!0,cStyleComments:!0,types:u}),["c","cc","cpp","cxx","cyc","m"]),z(he({keywords:"null,true,false"}),["json"]),z(he({keywords:E,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:u}),["cs"]),z(he({keywords:S,cStyleComments:!0}),["java"]),z(he({keywords:o,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),z(he({keywords:e,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),z(he({keywords:h,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),z(he({keywords:s,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),z(he({keywords:y,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),z(he({keywords:b,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),z(se([],[[l,/^[\s\S]+/]]),["regex"]);function me(le){var pe=le.langExtension;try{var Ee=Q(le.sourceNode,le.pre),Te=Ee.sourceCode;le.sourceCode=Te,le.spans=Ee.spans,le.basePos=0,H(pe,Te)(le),Y(le)}catch(Ie){M.console&&console.log(Ie&&Ie.stack||Ie)}}function Le(le,pe,Ee){var Te=Ee||!1,Ie=pe||null,ke=document.createElement("div");ke.innerHTML="<pre>"+le+"</pre>",ke=ke.firstChild,Te&&$(ke,Te,!0);var Me={langExtension:Ie,numberLines:Te,sourceNode:ke,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return me(Me),ke.innerHTML}function Oe(le,pe){var Ee=pe||document.body,Te=Ee.ownerDocument||document;function Ie(q){return Ee.getElementsByTagName(q)}for(var ke=[Ie("pre"),Ie("code"),Ie("xmp")],Me=[],Fe=0;Fe<ke.length;++Fe)for(var ae=0,ue=ke[Fe].length;ae<ue;++ae)Me.push(ke[Fe][ae]);ke=null;var be=Date;be.now||(be={now:function(){return+new Date}});var xe=0,Ce=/\blang(?:uage)?-([\w.]+)(?!\S)/,Se=/\bprettyprint\b/,ye=/\bprettyprinted\b/,Ne=/pre|xmp/i,Be=/^code$/i,ve=/^(?:pre|code|xmp)$/i,_e={};function re(){for(var q=M.PR_SHOULD_USE_CONTINUATION?be.now()+250:Infinity;xe<Me.length&&be.now()<q;xe++){for(var te=Me[xe],j=_e,W=te;W=W.previousSibling;){var G=W.nodeType,X=(G===7||G===8)&&W.nodeValue;if(X?!/^\??prettify\b/.test(X):G!==3||/\S/.test(W.nodeValue))break;if(X){j={},X.replace(/\b(\w+)=([\w:.%+-]+)/g,function(ct,qe,yt){j[qe]=yt});break}}var oe=te.className;if((j!==_e||Se.test(oe))&&!ye.test(oe)){for(var ce=!1,Pe=te.parentNode;Pe;Pe=Pe.parentNode){var He=Pe.tagName;if(ve.test(He)&&Pe.className&&Se.test(Pe.className)){ce=!0;break}}if(!ce){te.className+=" prettyprinted";var $e=j.lang;if(!$e){$e=oe.match(Ce);var ze;!$e&&(ze=ge(te))&&Be.test(ze.tagName)&&($e=ze.className.match(Ce)),$e&&($e=$e[1])}var Ze;if(Ne.test(te.tagName))Ze=1;else{var et=te.currentStyle,Xe=Te.defaultView,mt=et?et.whiteSpace:Xe&&Xe.getComputedStyle?Xe.getComputedStyle(te,null).getPropertyValue("white-space"):0;Ze=mt&&mt.substring(0,3)==="pre"}var rt=j.linenums;(rt=rt==="true"||+rt)||(rt=oe.match(/\blinenums\b(?::(\d+))?/),rt=rt?rt[1]&&rt[1].length?+rt[1]:!0:!1),rt&&$(te,rt,Ze);var vt={langExtension:$e,sourceNode:te,numberLines:rt,pre:Ze,sourceCode:null,basePos:null,spans:null,decorations:null};me(vt)}}}xe<Me.length?M.setTimeout(re,250):typeof le=="function"&&le()}re()}var we=M.PR={createSimpleLexer:se,registerLangHandler:z,sourceDecorator:he,PR_ATTRIB_NAME:k,PR_ATTRIB_VALUE:I,PR_COMMENT:c,PR_DECLARATION:v,PR_KEYWORD:p,PR_LITERAL:r,PR_NOCODE:F,PR_PLAIN:a,PR_PUNCTUATION:t,PR_SOURCE:T,PR_STRING:l,PR_TAG:m,PR_TYPE:i,prettyPrintOne:C?M.prettyPrintOne=Le:L=Le,prettyPrint:_=C?M.prettyPrint=Oe:_=Oe},De=M.define;typeof De=="function"&&De.amd&&De("google-code-prettify",[],function(){return we})})()},"U/Y8":function(nt,We,J){nt.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:function(nt,We,J){"use strict";var fe=J("rePB"),U=J("Ff2n"),C=J("VTBJ"),B=J("1OyB"),O=J("vuIU"),L=J("JX7q"),_=J("Ji7U"),M=J("LK+K"),A=J("q1tI"),w=J("TSYQ"),g=J.n(w),x=J("sboe"),S=J("OZM5"),E=function(p){var c=p.prefixCls,i=p.level,r=p.isStart,t=p.isEnd;if(!i)return null;for(var a="".concat(c,"-indent-unit"),m=[],v=0;v<i;v+=1){var T;m.push(A.createElement("span",{key:v,className:g()(a,(T={},Object(fe.a)(T,"".concat(a,"-start"),r[v+1]),Object(fe.a)(T,"".concat(a,"-end"),t[v+1]),Object(fe.a)(T,"".concat(a,"-end-first-level"),!v&&t[0]),T))}))}return A.createElement("span",{"aria-hidden":"true",className:"".concat(c,"-indent")},m)},b=E,y=J("815F"),h="open",e="close",s="---",o=function(l){Object(_.a)(c,l);var p=Object(M.a)(c);function c(){var i;return Object(B.a)(this,c),i=p.apply(this,arguments),i.state={dragNodeHighlight:!1},i.onSelectorClick=function(r){var t=i.props.context.onNodeClick;t(r,Object(y.b)(i.props)),i.isSelectable()?i.onSelect(r):i.onCheck(r)},i.onSelectorDoubleClick=function(r){var t=i.props.context.onNodeDoubleClick;t(r,Object(y.b)(i.props))},i.onSelect=function(r){if(i.isDisabled())return;var t=i.props.context.onNodeSelect;r.preventDefault(),t(r,Object(y.b)(i.props))},i.onCheck=function(r){if(i.isDisabled())return;var t=i.props,a=t.disableCheckbox,m=t.checked,v=i.props.context.onNodeCheck;if(!i.isCheckable()||a)return;r.preventDefault();var T=!m;v(r,Object(y.b)(i.props),T)},i.onMouseEnter=function(r){var t=i.props.context.onNodeMouseEnter;t(r,Object(y.b)(i.props))},i.onMouseLeave=function(r){var t=i.props.context.onNodeMouseLeave;t(r,Object(y.b)(i.props))},i.onContextMenu=function(r){var t=i.props.context.onNodeContextMenu;t(r,Object(y.b)(i.props))},i.onDragStart=function(r){var t=i.props.context.onNodeDragStart;r.stopPropagation(),i.setState({dragNodeHighlight:!0}),t(r,Object(L.a)(i));try{r.dataTransfer.setData("text/plain","")}catch(a){}},i.onDragEnter=function(r){var t=i.props.context.onNodeDragEnter;r.preventDefault(),r.stopPropagation(),t(r,Object(L.a)(i))},i.onDragOver=function(r){var t=i.props.context.onNodeDragOver;r.preventDefault(),r.stopPropagation(),t(r,Object(L.a)(i))},i.onDragLeave=function(r){var t=i.props.context.onNodeDragLeave;r.stopPropagation(),t(r,Object(L.a)(i))},i.onDragEnd=function(r){var t=i.props.context.onNodeDragEnd;r.stopPropagation(),i.setState({dragNodeHighlight:!1}),t(r,Object(L.a)(i))},i.onDrop=function(r){var t=i.props.context.onNodeDrop;r.preventDefault(),r.stopPropagation(),i.setState({dragNodeHighlight:!1}),t(r,Object(L.a)(i))},i.onExpand=function(r){var t=i.props.context.onNodeExpand;t(r,Object(y.b)(i.props))},i.setSelectHandle=function(r){i.selectHandle=r},i.getNodeState=function(){var r=i.props.expanded;return i.isLeaf()?null:r?h:e},i.hasChildren=function(){var r=i.props.eventKey,t=i.props.context.keyEntities,a=t[r]||{},m=a.children;return!!(m||[]).length},i.isLeaf=function(){var r=i.props,t=r.isLeaf,a=r.loaded,m=i.props.context.loadData,v=i.hasChildren();return t===!1?!1:t||!m&&!v||m&&a&&!v},i.isDisabled=function(){var r=i.props.disabled,t=i.props.context.disabled;return!!(t||r)},i.isCheckable=function(){var r=i.props.checkable,t=i.props.context.checkable;return!t||r===!1?!1:t},i.syncLoadData=function(r){var t=r.expanded,a=r.loading,m=r.loaded,v=i.props.context,T=v.loadData,k=v.onNodeLoad;if(a)return;T&&t&&!i.isLeaf()&&(!i.hasChildren()&&!m&&k(Object(y.b)(i.props)))},i.renderSwitcher=function(){var r=i.props,t=r.expanded,a=r.switcherIcon,m=i.props.context,v=m.prefixCls,T=m.switcherIcon,k=a||T;if(i.isLeaf())return A.createElement("span",{className:g()("".concat(v,"-switcher"),"".concat(v,"-switcher-noop"))},typeof k=="function"?k(Object(C.a)(Object(C.a)({},i.props),{},{isLeaf:!0})):k);var I=g()("".concat(v,"-switcher"),"".concat(v,"-switcher_").concat(t?h:e));return A.createElement("span",{onClick:i.onExpand,className:I},typeof k=="function"?k(Object(C.a)(Object(C.a)({},i.props),{},{isLeaf:!1})):k)},i.renderCheckbox=function(){var r=i.props,t=r.checked,a=r.halfChecked,m=r.disableCheckbox,v=i.props.context.prefixCls,T=i.isDisabled(),k=i.isCheckable();if(!k)return null;var I=typeof k!="boolean"?k:null;return A.createElement("span",{className:g()("".concat(v,"-checkbox"),t&&"".concat(v,"-checkbox-checked"),!t&&a&&"".concat(v,"-checkbox-indeterminate"),(T||m)&&"".concat(v,"-checkbox-disabled")),onClick:i.onCheck},I)},i.renderIcon=function(){var r=i.props.loading,t=i.props.context.prefixCls;return A.createElement("span",{className:g()("".concat(t,"-iconEle"),"".concat(t,"-icon__").concat(i.getNodeState()||"docu"),r&&"".concat(t,"-icon_loading"))})},i.renderSelector=function(){var r=i.state.dragNodeHighlight,t=i.props,a=t.title,m=t.selected,v=t.icon,T=t.loading,k=t.data,I=i.props.context,F=I.prefixCls,K=I.showIcon,V=I.icon,Q=I.draggable,Z=I.loadData,ie=I.titleRender,ge=i.isDisabled(),se="".concat(F,"-node-content-wrapper"),he;if(K){var de=v||V;he=de?A.createElement("span",{className:g()("".concat(F,"-iconEle"),"".concat(F,"-icon__customize"))},typeof de=="function"?de(i.props):de):i.renderIcon()}else Z&&T&&(he=i.renderIcon());var $;typeof a=="function"?$=a(k):ie?$=ie(k):$=a;var Y=A.createElement("span",{className:"".concat(F,"-title")},$);return A.createElement("span",{ref:i.setSelectHandle,title:typeof a=="string"?a:"",className:g()("".concat(se),"".concat(se,"-").concat(i.getNodeState()||"normal"),!ge&&(m||r)&&"".concat(F,"-node-selected"),!ge&&Q&&"draggable"),draggable:!ge&&Q||void 0,"aria-grabbed":!ge&&Q||void 0,onMouseEnter:i.onMouseEnter,onMouseLeave:i.onMouseLeave,onContextMenu:i.onContextMenu,onClick:i.onSelectorClick,onDoubleClick:i.onSelectorDoubleClick,onDragStart:Q?i.onDragStart:void 0},he,Y)},i}return Object(O.a)(c,[{key:"componentDidMount",value:function(){this.syncLoadData(this.props)}},{key:"componentDidUpdate",value:function(){this.syncLoadData(this.props)}},{key:"isSelectable",value:function(){var r=this.props.selectable,t=this.props.context.selectable;return typeof r=="boolean"?r:t}},{key:"render",value:function(){var r,t=this.props,a=t.eventKey,m=t.className,v=t.style,T=t.dragOver,k=t.dragOverGapTop,I=t.dragOverGapBottom,F=t.isLeaf,K=t.isStart,V=t.isEnd,Q=t.expanded,Z=t.selected,ie=t.checked,ge=t.halfChecked,se=t.loading,he=t.domRef,de=t.active,$=t.onMouseMove,Y=Object(U.a)(t,["eventKey","className","style","dragOver","dragOverGapTop","dragOverGapBottom","isLeaf","isStart","isEnd","expanded","selected","checked","halfChecked","loading","domRef","active","onMouseMove"]),ne=this.props.context,z=ne.prefixCls,H=ne.filterTreeNode,me=ne.draggable,Le=ne.keyEntities,Oe=this.isDisabled(),we=Object(S.f)(Y),De=Le[a]||{},le=De.level,pe=V[V.length-1];return A.createElement("div",Object.assign({ref:he,className:g()(m,"".concat(z,"-treenode"),(r={},Object(fe.a)(r,"".concat(z,"-treenode-disabled"),Oe),Object(fe.a)(r,"".concat(z,"-treenode-switcher-").concat(Q?"open":"close"),!F),Object(fe.a)(r,"".concat(z,"-treenode-checkbox-checked"),ie),Object(fe.a)(r,"".concat(z,"-treenode-checkbox-indeterminate"),ge),Object(fe.a)(r,"".concat(z,"-treenode-selected"),Z),Object(fe.a)(r,"".concat(z,"-treenode-loading"),se),Object(fe.a)(r,"".concat(z,"-treenode-active"),de),Object(fe.a)(r,"".concat(z,"-treenode-leaf-last"),pe),Object(fe.a)(r,"drag-over",!Oe&&T),Object(fe.a)(r,"drag-over-gap-top",!Oe&&k),Object(fe.a)(r,"drag-over-gap-bottom",!Oe&&I),Object(fe.a)(r,"filter-node",H&&H(Object(y.b)(this.props))),r)),style:v,onDragEnter:me?this.onDragEnter:void 0,onDragOver:me?this.onDragOver:void 0,onDragLeave:me?this.onDragLeave:void 0,onDrop:me?this.onDrop:void 0,onDragEnd:me?this.onDragEnd:void 0,onMouseMove:$},we),A.createElement(b,{prefixCls:z,level:le,isStart:K,isEnd:V}),this.renderSwitcher(),this.renderCheckbox(),this.renderSelector())}}]),c}(A.Component),f=function(p){return A.createElement(x.a.Consumer,null,function(c){return A.createElement(o,Object.assign({},p,{context:c}))})};f.displayName="TreeNode",f.defaultProps={title:s},f.isTreeNode=1;var u=We.a=f},Y1PL:function(nt,We,J){"use strict";J.r(We),J.d(We,"ResizableTextArea",function(){return ge});var fe=J("wx14"),U=J("1OyB"),C=J("vuIU"),B=J("Ji7U"),O=J("LK+K"),L=J("q1tI"),_=J("VTBJ"),M=J("rePB"),A=J("Zm9Q"),w=J("Kwbf"),g=J("c+Xe"),x=J("m+aA"),S=J("bdgK"),E=new Map;function b(de){de.forEach(function($){var Y,ne=$.target;(Y=E.get(ne))===null||Y===void 0||Y.forEach(function(z){return z(ne)})})}var y=new S.default(b),h=null,e=null;function s(de,$){E.has(de)||(E.set(de,new Set),y.observe(de)),E.get(de).add($)}function o(de,$){E.has(de)&&(E.get(de).delete($),E.get(de).size||(y.unobserve(de),E.delete(de)))}var f=function(de){Object(B.a)(Y,de);var $=Object(O.a)(Y);function Y(){return Object(U.a)(this,Y),$.apply(this,arguments)}return Object(C.a)(Y,[{key:"render",value:function(){return this.props.children}}]),Y}(L.Component),u=L.createContext(null);function l(de){var $=de.children,Y=de.onBatchResize,ne=L.useRef(0),z=L.useRef([]),H=L.useContext(u),me=L.useCallback(function(Le,Oe,we){ne.current+=1;var De=ne.current;z.current.push({size:Le,element:Oe,data:we}),Promise.resolve().then(function(){De===ne.current&&(Y==null||Y(z.current),z.current=[])}),H==null||H(Le,Oe,we)},[Y,H]);return L.createElement(u.Provider,{value:me},$)}function p(de){var $=de.children,Y=de.disabled,ne=L.useRef(null),z=L.useRef(null),H=L.useContext(u),me=L.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),Le=L.isValidElement($)&&Object(g.c)($),Oe=Le?$.ref:null,we=L.useMemo(function(){return Object(g.a)(Oe,ne)},[Oe,ne]),De=L.useRef(de);De.current=de;var le=L.useCallback(function(pe){var Ee=De.current,Te=Ee.onResize,Ie=Ee.data,ke=pe.getBoundingClientRect(),Me=ke.width,Fe=ke.height,ae=pe.offsetWidth,ue=pe.offsetHeight,be=Math.floor(Me),xe=Math.floor(Fe);if(me.current.width!==be||me.current.height!==xe||me.current.offsetWidth!==ae||me.current.offsetHeight!==ue){var Ce={width:be,height:xe,offsetWidth:ae,offsetHeight:ue};me.current=Ce;var Se=ae===Math.round(Me)?Me:ae,ye=ue===Math.round(Fe)?Fe:ue,Ne=Object(_.a)(Object(_.a)({},Ce),{},{offsetWidth:Se,offsetHeight:ye});H==null||H(Ne,pe,Ie),Te&&Promise.resolve().then(function(){Te(Ne,pe)})}},[]);return L.useEffect(function(){var pe=Object(x.a)(ne.current)||Object(x.a)(z.current);return pe&&!Y&&s(pe,le),function(){return o(pe,le)}},[ne.current,Y]),L.createElement(f,{ref:z},Le?L.cloneElement($,{ref:we}):$)}var c="rc-observer-key";function i(de){var $=de.children,Y=Object(A.a)($);return Y.map(function(ne,z){var H=(ne==null?void 0:ne.key)||"".concat(c,"-").concat(z);return L.createElement(p,Object(fe.a)({},de,{key:H}),ne)})}i.Collection=l;var r=i,t=J("bT9E"),a=J("TSYQ"),m=J.n(a),v=`
|
|
min-height:0 !important;
|
|
max-height:none !important;
|
|
height:0 !important;
|
|
visibility:hidden !important;
|
|
overflow:hidden !important;
|
|
position:absolute !important;
|
|
z-index:-1000 !important;
|
|
top:0 !important;
|
|
right:0 !important
|
|
`,T=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","font-variant","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing","word-break"],k={},I;function F(de){var $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Y=de.getAttribute("id")||de.getAttribute("data-reactid")||de.getAttribute("name");if($&&k[Y])return k[Y];var ne=window.getComputedStyle(de),z=ne.getPropertyValue("box-sizing")||ne.getPropertyValue("-moz-box-sizing")||ne.getPropertyValue("-webkit-box-sizing"),H=parseFloat(ne.getPropertyValue("padding-bottom"))+parseFloat(ne.getPropertyValue("padding-top")),me=parseFloat(ne.getPropertyValue("border-bottom-width"))+parseFloat(ne.getPropertyValue("border-top-width")),Le=T.map(function(we){return"".concat(we,":").concat(ne.getPropertyValue(we))}).join(";"),Oe={sizingStyle:Le,paddingSize:H,borderSize:me,boxSizing:z};return $&&Y&&(k[Y]=Oe),Oe}function K(de){var $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,ne=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;I||(I=document.createElement("textarea"),I.setAttribute("tab-index","-1"),I.setAttribute("aria-hidden","true"),document.body.appendChild(I)),de.getAttribute("wrap")?I.setAttribute("wrap",de.getAttribute("wrap")):I.removeAttribute("wrap");var z=F(de,$),H=z.paddingSize,me=z.borderSize,Le=z.boxSizing,Oe=z.sizingStyle;I.setAttribute("style","".concat(Oe,";").concat(v)),I.value=de.value||de.placeholder||"";var we=Number.MIN_SAFE_INTEGER,De=Number.MAX_SAFE_INTEGER,le=I.scrollHeight,pe;if(Le==="border-box"?le+=me:Le==="content-box"&&(le-=H),Y!==null||ne!==null){I.value=" ";var Ee=I.scrollHeight-H;Y!==null&&(we=Ee*Y,Le==="border-box"&&(we=we+H+me),le=Math.max(we,le)),ne!==null&&(De=Ee*ne,Le==="border-box"&&(De=De+H+me),pe=le>De?"":"hidden",le=Math.min(De,le))}return{height:le,minHeight:we,maxHeight:De,overflowY:pe,resize:"none"}}var V=J("Gytx"),Q=J.n(V),Z;(function(de){de[de.NONE=0]="NONE",de[de.RESIZING=1]="RESIZING",de[de.RESIZED=2]="RESIZED"})(Z||(Z={}));var ie=function(de){Object(B.a)(Y,de);var $=Object(O.a)(Y);function Y(ne){var z;return Object(U.a)(this,Y),z=$.call(this,ne),z.nextFrameActionId=void 0,z.resizeFrameId=void 0,z.textArea=void 0,z.saveTextArea=function(H){z.textArea=H},z.handleResize=function(H){var me=z.state.resizeStatus,Le=z.props,Oe=Le.autoSize,we=Le.onResize;if(me!==Z.NONE)return;typeof we=="function"&&we(H),Oe&&z.resizeOnNextFrame()},z.resizeOnNextFrame=function(){cancelAnimationFrame(z.nextFrameActionId),z.nextFrameActionId=requestAnimationFrame(z.resizeTextarea)},z.resizeTextarea=function(){var H=z.props.autoSize;if(!H||!z.textArea)return;var me=H.minRows,Le=H.maxRows,Oe=K(z.textArea,!1,me,Le);z.setState({textareaStyles:Oe,resizeStatus:Z.RESIZING},function(){cancelAnimationFrame(z.resizeFrameId),z.resizeFrameId=requestAnimationFrame(function(){z.setState({resizeStatus:Z.RESIZED},function(){z.resizeFrameId=requestAnimationFrame(function(){z.setState({resizeStatus:Z.NONE}),z.fixFirefoxAutoScroll()})})})})},z.renderTextArea=function(){var H=z.props,me=H.prefixCls,Le=me===void 0?"rc-textarea":me,Oe=H.autoSize,we=H.onResize,De=H.className,le=H.disabled,pe=z.state,Ee=pe.textareaStyles,Te=pe.resizeStatus,Ie=Object(t.a)(z.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),ke=m()(Le,De,Object(M.a)({},"".concat(Le,"-disabled"),le));"value"in Ie&&(Ie.value=Ie.value||"");var Me=Object(_.a)(Object(_.a)(Object(_.a)({},z.props.style),Ee),Te===Z.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return L.createElement(r,{onResize:z.handleResize,disabled:!(Oe||we)},L.createElement("textarea",Object(fe.a)({},Ie,{className:ke,style:Me,ref:z.saveTextArea})))},z.state={textareaStyles:{},resizeStatus:Z.NONE},z}return Object(C.a)(Y,[{key:"componentDidUpdate",value:function(z){(z.value!==this.props.value||!Q()(z.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 z=this.textArea.selectionStart,H=this.textArea.selectionEnd;this.textArea.setSelectionRange(z,H)}}catch(me){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Y}(L.Component),ge=ie,se=function(de){Object(B.a)(Y,de);var $=Object(O.a)(Y);function Y(ne){var z;Object(U.a)(this,Y),z=$.call(this,ne),z.resizableTextArea=void 0,z.focus=function(){z.resizableTextArea.textArea.focus()},z.saveTextArea=function(me){z.resizableTextArea=me},z.handleChange=function(me){var Le=z.props.onChange;z.setValue(me.target.value,function(){z.resizableTextArea.resizeTextarea()}),Le&&Le(me)},z.handleKeyDown=function(me){var Le=z.props,Oe=Le.onPressEnter,we=Le.onKeyDown;me.keyCode===13&&Oe&&Oe(me),we&&we(me)};var H=typeof ne.value=="undefined"||ne.value===null?ne.defaultValue:ne.value;return z.state={value:H},z}return Object(C.a)(Y,[{key:"setValue",value:function(z,H){"value"in this.props||this.setState({value:z},H)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return L.createElement(ge,Object(fe.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(z){return"value"in z?{value:z.value}:null}}]),Y}(L.Component),he=We.default=se},ZW9T:function(nt,We,J){"use strict";J.d(We,"a",function(){return f});var fe=J("k1fw"),U=J("miYZ"),C=J("tsqr"),B=J("rAM+"),O=J("tJVT"),L=J("PpiC"),_=J("q1tI"),M=J.n(_),A=J("bdgK");function w(u,l,p,c,i){var r=l.getWordUntilPosition(p),t={startLineNumber:p.lineNumber,endLineNumber:p.lineNumber,startColumn:r.startColumn,endColumn:r.endColumn},a=c.map(function(m){return{label:m,kind:u.languages.CompletionItemKind.Keyword,insertText:m,insertTextRules:u.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:t}});return i.map(function(m){a.push(Object(fe.a)(Object(fe.a)({},m),{},{range:t}))}),a}var g=function(u){var l={label:"ifelse",kind:u.languages.CompletionItemKind.Method,insertText:["if (${1:condition}) {"," $0","} else {"," ","}"].join(`
|
|
`),insertTextRules:u.languages.CompletionItemInsertTextRule.InsertAsSnippet},p=["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"];u.languages.registerCompletionItemProvider("cpp",{provideCompletionItems:function(t,a){var m=w(u,t,a,p,[l]);return{suggestions:m}}});var c=["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"];u.languages.registerCompletionItemProvider("python",{provideCompletionItems:function(t,a){var m=[{label:"print",kind:u.languages.CompletionItemKind.Snippet,insertText:["print($0)"].join(`
|
|
`),insertTextRules:u.languages.CompletionItemInsertTextRule.InsertAsSnippet}],v=w(u,t,a,c,m);return{suggestions:v}}});var i=["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"];u.languages.registerCompletionItemProvider("java",{provideCompletionItems:function(t,a){var m=[l,{label:"main",kind:u.languages.CompletionItemKind.Snippet,insertText:["public static void main(String[] args) {"," $0","}"].join(`
|
|
`),insertTextRules:u.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"System.out.print",kind:u.languages.CompletionItemKind.Snippet,insertText:["System.out.print($0)"].join(`
|
|
`),insertTextRules:u.languages.CompletionItemInsertTextRule.InsertAsSnippet}],v=w(u,t,a,i,m);return{suggestions:v}}})},x="\u8BE5\u4EFB\u52A1\u5173\u5361\u8BBE\u7F6E\u4E86\u7981\u6B62\u590D\u5236\u7C98\u8D34\uFF0C\u8BF7\u624B\u52A8\u8F93\u5165\u4EE3\u7801\u3002",S=J("LvDl");function E(u){return/^\d+$/.test(u)?"".concat(u,"px"):u}function b(){}var y=!1,h={"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 e(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],l=u;if(Array.isArray(u)){for(var p=0;p<u.length;p++){var c=h[u[p]];if(c)return c}return l[0]}return h[l]||l}var s=null,o=We.b=function(u){var l=u.width,p=l===void 0?"100%":l,c=u.height,i=c===void 0?"100%":c,r=u.value,t=u.language,a=t===void 0?"javascript":t,m=u.style,v=m===void 0?{}:m,T=u.options,k=T===void 0?{}:T,I=u.overrideServices,F=I===void 0?{}:I,K=u.theme,V=K===void 0?"vs-dark":K,Q=u.onEditBlur,Z=u.onSave,ie=u.autoHeight,ge=ie===void 0?!1:ie,se=u.forbidCopy,he=se===void 0?!1:se,de=u.onChange,$=de===void 0?b:de,Y=u.editorDidMount,ne=Y===void 0?b:Y,z=u.onFocus,H=z===void 0?b:z,me=u.filename,Le=me===void 0?"educoder.txt":me,Oe=Object(L.a)(u,["width","height","value","language","style","options","overrideServices","theme","onEditBlur","onSave","autoHeight","forbidCopy","onChange","editorDidMount","onFocus","filename"]),we=Object(_.useRef)(),De=Object(_.useRef)({}),le=Object(_.useRef)(),pe=Object(_.useRef)(!1),Ee=Object(_.useRef)(),Te=Object(_.useState)(!1),Ie=Object(O.a)(Te,2),ke=Ie[0],Me=Ie[1];function Fe(){var G;return we.current&&(G=new A.default(function(X){var oe=Object(B.a)(X),ce;try{for(oe.s();!(ce=oe.n()).done;){var Pe=ce.value;(Pe.target.offsetHeight>0||Pe.target.offsetWidth>0)&&De.current.instance.layout()}}catch(He){oe.e(He)}finally{oe.f()}}),G.observe(we.current)),G}function ae(){C.b.warn(decodeURIComponent(x))}var ue=function(){var X=De.current.instance;if(r!=null&&X&&ke){var oe=X.getModel();oe&&r!==oe.getValue()&&(y=!0,oe.setValue(r),X.layout(),y=!1)}};Object(_.useEffect)(function(){le.current&&clearTimeout(le.current),le.current=setTimeout(function(){ue()},500)},[r,ke,De.current]);function be(){var G=De.current.instance;if(G){var X=G.getSelection(),oe=De.current.pastePos||{},ce=new s.Range(oe.startLineNumber||X.endLineNumber,oe.startColumn||X.endColumn,oe.endLineNumber||X.endLineNumber,oe.endColumn||X.endColumn);setTimeout(function(){G.executeEdits("",[{range:ce,text:""}])},300)}}function xe(G){(window.navigator.platform.match("Mac")?G.metaKey:G.ctrlKey)&&G.keyCode==83&&(G.preventDefault(),Z())}var Ce=function(){if(ge&&De.current.instance){var X=De.current.instance.getContentHeight();j(X<i?i:X)}else j(i)};function Se(G){var X=document.createEvent("MouseEvents");X.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),G.dispatchEvent(X)}function ye(G,X){var oe=window.URL||window.webkitURL||window,ce=new Blob([X]),Pe=document.createElementNS("http://www.w3.org/1999/xhtml","a");Pe.href=oe.createObjectURL(ce),Pe.download=G,Se(Pe)}Object(_.useEffect)(function(){Ce()},[Ce]),Object(_.useEffect)(function(){we.current&&!ke&&J.e(27).then(J.t.bind(null,"M/lh",7)).then(function(G){try{s=G,De.current.instance=s.editor.create(we.current,{value:r,language:e(a),theme:V,requireConfig:{"vs/nls":{availableLanguages:{"*":"zh-cn"}}},wordWrap:!0},F);var X=De.current.instance;if(ne(X,s),setTimeout(function(){Ce(),De.current.instance.addAction({id:"d123123",label:"Download File",contextMenuGroupId:"9_cutcopypaste",run:function(){ye(Le||"educoder.txt",X.getValue())}})},500),De.current.subscription=X.onDidChangeModelContent(function(ce){pe.current?clearTimeout(Ee.current):(Ce(),$(X.getValue(),ce)),Ee.current=setTimeout(function(){pe.current=!1},500)}),window.Monaco||g(s),he&&(X.addCommand(s.KeyMod.CtrlCmd|s.KeyMod.Shift|s.KeyCode.KEY_V,function(){return ae(),null}),X.addCommand(s.KeyMod.CtrlCmd|s.KeyCode.KEY_C,function(){return ae(),null})),window.Monaco=s,Q&&X.onDidBlurEditorWidget(function(){Q(X.getValue())}),H&&X.onDidFocusEditorText(function(){H(X.getValue())}),he){X.addCommand(s.KeyMod.CtrlCmd|s.KeyCode.KEY_V,function(){return ae(),null}),X.onDidPaste(function(ce){De.current.pastePos=ce});try{window.addEventListener("paste",be)}catch(ce){}}var oe=Fe();return Me(!0),function(){var ce=De.current.instance;ce.dispose();var Pe=ce.getModel();Pe&&Pe.dispose(),De.current.subscription&&De.current.subscription.dispose(),he&&window.removeEventListener("paste",be),oe.unobserve(we.current)}}catch(ce){}})},[]),Object(_.useEffect)(function(){var G=De.current.instance;if(G&&ke)return document.addEventListener("keydown",xe,!1),function(){document.removeEventListener("keydown",xe)}},[Z,ke]),Object(_.useEffect)(function(){var G=De.current.instance;if(G&&ke){var X=e(a);s.editor.setModelLanguage(G.getModel(),X),console.log("language:",a,G.getModel(),X)}},[a,ke]),Object(_.useEffect)(function(){var G=De.current.instance;G&&ke&&s.editor.setTheme(V)},[V,ke]),Object(_.useEffect)(function(){var G=De.current.instance;G&&ke&&(G.updateOptions(Object(fe.a)({},k)),setTimeout(function(){G.getModel().updateOptions(Object(fe.a)({},k))},200))},[JSON.stringify(k),ke]),Object(_.useEffect)(function(){var G=De.current.instance;G&&ke&&G.layout()},[p,i,ke]);var Ne=Object(_.useState)(E(p)),Be=Object(O.a)(Ne,2),ve=Be[0],_e=Be[1],re=Object(_.useState)(E(i)),q=Object(O.a)(re,2),te=q[0],j=q[1],W=Object(fe.a)(Object(fe.a)({},v),{},{width:ve,height:te});return M.a.createElement("div",{className:"my-monaco-editor",ref:we,style:W})};function f(u){var l=u.width,p=l===void 0?"100%":l,c=u.height,i=c===void 0?"100%":c,r=u.original,t=u.modified,a=u.language,m=u.options,v=m===void 0?{}:m,T=Object(_.useRef)(),k=Object(_.useState)(null),I=Object(O.a)(k,2),F=I[0],K=I[1];function V(ge){var se;return T.current&&(se=new A.default(function(he){var de=Object(B.a)(he),$;try{for(de.s();!($=de.n()).done;){var Y=$.value;(Y.target.offsetHeight>0||Y.target.offsetWidth>0)&&ge.layout()}}catch(ne){de.e(ne)}finally{de.f()}}),se.observe(T.current)),se}Object(_.useEffect)(function(){T.current&&J.e(27).then(J.t.bind(null,"M/lh",7)).then(function(ge){s=ge;var se=s.editor.createDiffEditor(T.current,Object(fe.a)(Object(fe.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},v),{},{wordWrap:!0}));K(se);var he=V(se);return function(){se.dispose();var de=se.getModel();de&&de.dispose(),he.unobserve(T.current)}})},[]),Object(_.useEffect)(function(){F&&F.setModel({original:s.editor.createModel(r,a),modified:s.editor.createModel(t,a)})},[r,t,a,F]);var Q=E(p),Z=E(i),ie={width:Q,height:Z};return M.a.createElement("div",{className:"my-diff-editor",ref:T,style:ie})}},ZpRC:function(nt,We,J){"use strict";function fe(g){return typeof g=="object"&&g!=null&&g.nodeType===1}function U(g,x){return(!x||g!=="hidden")&&g!=="visible"&&g!=="clip"}function C(g,x){if(g.clientHeight<g.scrollHeight||g.clientWidth<g.scrollWidth){var S=getComputedStyle(g,null);return U(S.overflowY,x)||U(S.overflowX,x)||function(E){var b=function(y){if(!y.ownerDocument||!y.ownerDocument.defaultView)return null;try{return y.ownerDocument.defaultView.frameElement}catch(h){return null}}(E);return!!b&&(b.clientHeight<E.scrollHeight||b.clientWidth<E.scrollWidth)}(g)}return!1}function B(g,x,S,E,b,y,h,e){return y<g&&h>x||y>g&&h<x?0:y<=g&&e<=S||h>=x&&e>=S?y-g-E:h>x&&e<S||y<g&&e>S?h-x+b:0}var O=function(g,x){var S=window,E=x.scrollMode,b=x.block,y=x.inline,h=x.boundary,e=x.skipOverflowHiddenElements,s=typeof h=="function"?h:function(Ee){return Ee!==h};if(!fe(g))throw new TypeError("Invalid target");for(var o=document.scrollingElement||document.documentElement,f=[],u=g;fe(u)&&s(u);){if((u=u.parentElement)===o){f.push(u);break}u!=null&&u===document.body&&C(u)&&!C(document.documentElement)||u!=null&&C(u,e)&&f.push(u)}for(var l=S.visualViewport?S.visualViewport.width:innerWidth,p=S.visualViewport?S.visualViewport.height:innerHeight,c=window.scrollX||pageXOffset,i=window.scrollY||pageYOffset,r=g.getBoundingClientRect(),t=r.height,a=r.width,m=r.top,v=r.right,T=r.bottom,k=r.left,I=b==="start"||b==="nearest"?m:b==="end"?T:m+t/2,F=y==="center"?k+a/2:y==="end"?v:k,K=[],V=0;V<f.length;V++){var Q=f[V],Z=Q.getBoundingClientRect(),ie=Z.height,ge=Z.width,se=Z.top,he=Z.right,de=Z.bottom,$=Z.left;if(E==="if-needed"&&m>=0&&k>=0&&T<=p&&v<=l&&m>=se&&T<=de&&k>=$&&v<=he)return K;var Y=getComputedStyle(Q),ne=parseInt(Y.borderLeftWidth,10),z=parseInt(Y.borderTopWidth,10),H=parseInt(Y.borderRightWidth,10),me=parseInt(Y.borderBottomWidth,10),Le=0,Oe=0,we="offsetWidth"in Q?Q.offsetWidth-Q.clientWidth-ne-H:0,De="offsetHeight"in Q?Q.offsetHeight-Q.clientHeight-z-me:0;if(o===Q)Le=b==="start"?I:b==="end"?I-p:b==="nearest"?B(i,i+p,p,z,me,i+I,i+I+t,t):I-p/2,Oe=y==="start"?F:y==="center"?F-l/2:y==="end"?F-l:B(c,c+l,l,ne,H,c+F,c+F+a,a),Le=Math.max(0,Le+i),Oe=Math.max(0,Oe+c);else{Le=b==="start"?I-se-z:b==="end"?I-de+me+De:b==="nearest"?B(se,de,ie,z,me+De,I,I+t,t):I-(se+ie/2)+De/2,Oe=y==="start"?F-$-ne:y==="center"?F-($+ge/2)+we/2:y==="end"?F-he+H+we:B($,he,ge,ne,H+we,F,F+a,a);var le=Q.scrollLeft,pe=Q.scrollTop;I+=pe-(Le=Math.max(0,Math.min(pe+Le,Q.scrollHeight-ie+De))),F+=le-(Oe=Math.max(0,Math.min(le+Oe,Q.scrollWidth-ge+we)))}K.push({el:Q,top:Le,left:Oe})}return K};function L(g){return g===Object(g)&&Object.keys(g).length!==0}function _(g,x){x===void 0&&(x="auto");var S="scrollBehavior"in document.body.style;g.forEach(function(E){var b=E.el,y=E.top,h=E.left;b.scroll&&S?b.scroll({top:y,left:h,behavior:x}):(b.scrollTop=y,b.scrollLeft=h)})}function M(g){return g===!1?{block:"end",inline:"nearest"}:L(g)?g:{block:"start",inline:"nearest"}}function A(g,x){var S=!g.ownerDocument.documentElement.contains(g);if(L(x)&&typeof x.behavior=="function")return x.behavior(S?[]:O(g,x));if(S)return;var E=M(x);return _(O(g,E),E.behavior)}var w=We.a=A},bT9E:function(nt,We,J){"use strict";J.d(We,"a",function(){return U});var fe=J("VTBJ");function U(C,B){var O=Object(fe.a)({},C);return Array.isArray(B)&&B.forEach(function(L){delete O[L]}),O}},fAei:function(nt,We,J){"use strict";J.d(We,"a",function(){return o.a});var fe=J("rePB"),U=J("VTBJ"),C=J("KQm4"),B=J("1OyB"),O=J("vuIU"),L=J("Ji7U"),_=J("LK+K"),M=J("q1tI"),A=J("4IlW"),w=J("Kwbf"),g=J("TSYQ"),x=J.n(g),S=J("sboe"),E=J("OZM5"),b=J("815F"),y=J("ODXe"),h=J("Ff2n"),e=J("+nKL"),s=J("8XRh"),o=J("WaYH"),f=function(he,de){var $=he.className,Y=he.style,ne=he.motion,z=he.motionNodes,H=he.motionType,me=he.onMotionStart,Le=he.onMotionEnd,Oe=he.active,we=he.treeNodeRequiredProps,De=Object(h.a)(he,["className","style","motion","motionNodes","motionType","onMotionStart","onMotionEnd","active","treeNodeRequiredProps"]),le=M.useState(!0),pe=Object(y.a)(le,2),Ee=pe[0],Te=pe[1],Ie=M.useContext(S.a),ke=Ie.prefixCls,Me=M.useRef(!1),Fe=function(){Me.current||Le(),Me.current=!0};return Object(M.useEffect)(function(){z&&H==="hide"&&Ee&&Te(!1)},[z]),Object(M.useEffect)(function(){return z&&me(),function(){z&&Fe()}},[]),z?M.createElement(s.default,Object.assign({ref:de,visible:Ee},ne,{motionAppear:H==="show",onAppearEnd:Fe,onLeaveEnd:Fe}),function(ae,ue){var be=ae.className,xe=ae.style;return M.createElement("div",{ref:ue,className:x()("".concat(ke,"-treenode-motion"),be),style:xe},z.map(function(Ce){var Se=Ce.data,ye=Se.key,Ne=Object(h.a)(Se,["key"]),Be=Ce.isStart,ve=Ce.isEnd;delete Ne.children;var _e=Object(b.f)(ye,we);return M.createElement(o.a,Object.assign({},Ne,_e,{active:Oe,data:Ce.data,key:ye,isStart:Be,isEnd:ve}))}))}):M.createElement(o.a,Object.assign({domRef:de,className:$,style:Y},De,{active:Oe}))};f.displayName="MotionTreeNode";var u=M.forwardRef(f),l=u;function p(){var se=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],he=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],de=se.length,$=he.length;if(Math.abs(de-$)!==1)return{add:!1,key:null};function Y(ne,z){var H=new Map;ne.forEach(function(Le){H.set(Le,!0)});var me=z.filter(function(Le){return!H.has(Le)});return me.length===1?me[0]:null}return de<$?{add:!0,key:Y(se,he)}:{add:!1,key:Y(he,se)}}function c(se,he,de){var $=se.findIndex(function(H){var me=H.data;return me.key===de}),Y=se[$+1],ne=he.findIndex(function(H){var me=H.data;return me.key===de});if(Y){var z=he.findIndex(function(H){var me=H.data;return me.key===Y.data.key});return he.slice(ne+1,z)}return he.slice(ne+1)}var i={width:0,height:0,display:"flex",overflow:"hidden",opacity:0,border:0,padding:0,margin:0},r=function(){},t="RC_TREE_MOTION_".concat(Math.random()),a={key:t},m={key:t,level:0,index:0,pos:"0",node:a},v={parent:null,children:[],pos:m.pos,data:a,isStart:[],isEnd:[]};function T(se,he,de,$){return he===!1||!de?se:se.slice(0,Math.ceil(de/$)+1)}function k(se){var he=se.data.key,de=se.pos;return Object(b.e)(he,de)}function I(se){for(var he=String(se.data.key),de=se;de.parent;)de=de.parent,he="".concat(de.data.key," > ").concat(he);return he}var F=function(he,de){var $=he.prefixCls,Y=he.data,ne=he.selectable,z=he.checkable,H=he.expandedKeys,me=he.selectedKeys,Le=he.checkedKeys,Oe=he.loadedKeys,we=he.loadingKeys,De=he.halfCheckedKeys,le=he.keyEntities,pe=he.disabled,Ee=he.dragging,Te=he.dragOverNodeKey,Ie=he.dropPosition,ke=he.motion,Me=he.height,Fe=he.itemHeight,ae=he.virtual,ue=he.focusable,be=he.activeItem,xe=he.focused,Ce=he.tabIndex,Se=he.onKeyDown,ye=he.onFocus,Ne=he.onBlur,Be=he.onActiveChange,ve=he.onListChangeStart,_e=he.onListChangeEnd,re=Object(h.a)(he,["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"]),q=M.useRef(null);M.useImperativeHandle(de,function(){return{scrollTo:function(ut){q.current.scrollTo(ut)}}});var te=M.useState(H),j=Object(y.a)(te,2),W=j[0],G=j[1],X=M.useState(Y),oe=Object(y.a)(X,2),ce=oe[0],Pe=oe[1],He=M.useState(Y),$e=Object(y.a)(He,2),ze=$e[0],Ze=$e[1],et=M.useState([]),Xe=Object(y.a)(et,2),mt=Xe[0],rt=Xe[1],vt=M.useState(null),ct=Object(y.a)(vt,2),qe=ct[0],yt=ct[1];function bt(){Pe(Y),Ze(Y),rt([]),yt(null),_e()}M.useEffect(function(){G(H);var at=p(W,H);if(at.key!==null)if(at.add){var ut=ce.findIndex(function(Ye){var ot=Ye.data.key;return ot===at.key}),At=T(c(ce,Y,at.key),ae,Me,Fe),St=ce.slice();St.splice(ut+1,0,v),Ze(St),rt(At),yt("show")}else{var Rt=Y.findIndex(function(Ye){var ot=Ye.data.key;return ot===at.key}),it=T(c(Y,ce,at.key),ae,Me,Fe),Qe=Y.slice();Qe.splice(Rt+1,0,v),Ze(Qe),rt(it),yt("hide")}else ce!==Y&&(Pe(Y),Ze(Y))},[H,Y]),M.useEffect(function(){Ee||bt()},[Ee]);var Ve=ke?ze:Y,wt={expandedKeys:H,selectedKeys:me,loadedKeys:Oe,loadingKeys:we,checkedKeys:Le,halfCheckedKeys:De,dragOverNodeKey:Te,dropPosition:Ie,keyEntities:le};return M.createElement(M.Fragment,null,xe&&be&&M.createElement("span",{style:i,"aria-live":"assertive"},I(be)),M.createElement("div",{role:"tree"},M.createElement("input",{style:i,disabled:ue===!1||pe,tabIndex:ue!==!1?Ce:null,onKeyDown:Se,onFocus:ye,onBlur:Ne,value:"",onChange:r})),M.createElement(e.a,Object.assign({},re,{data:Ve,itemKey:k,height:Me,fullHeight:!1,virtual:ae,itemHeight:Fe,prefixCls:"".concat($,"-list"),ref:q}),function(at){var ut=at.pos,At=at.data,St=At.key,Rt=Object(h.a)(At,["key"]),it=at.isStart,Qe=at.isEnd,Ye=Object(b.e)(St,ut);delete Rt.children;var ot=Object(b.f)(Ye,wt);return M.createElement(l,Object.assign({},Rt,ot,{active:be&&St===be.data.key,pos:ut,data:at.data,isStart:it,isEnd:Qe,motion:ke,motionNodes:St===t?mt:null,motionType:qe,onMotionStart:ve,onMotionEnd:bt,treeNodeRequiredProps:wt,onMouseMove:function(){Be(null)}}))}))},K=M.forwardRef(F);K.displayName="NodeList";var V=K,Q=J("NvD2"),Z=function(se){Object(L.a)(de,se);var he=Object(_.a)(de);function de(){var $;return Object(B.a)(this,de),$=he.apply(this,arguments),$.destroyed=!1,$.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},$.listRef=M.createRef(),$.onNodeDragStart=function(Y,ne){var z=$.state,H=z.expandedKeys,me=z.keyEntities,Le=$.props.onDragStart,Oe=ne.props.eventKey;$.dragNode=ne;var we=Object(E.b)(H,Oe);$.setState({dragging:!0,dragNodesKeys:Object(E.g)(Oe,me)}),$.setExpandedKeys(we),Le&&Le({event:Y,node:Object(b.b)(ne.props)})},$.onNodeDragEnter=function(Y,ne){var z=$.state,H=z.expandedKeys,me=z.keyEntities,Le=z.dragNodesKeys,Oe=$.props.onDragEnter,we=ne.props,De=we.pos,le=we.eventKey;if(!$.dragNode||Le.indexOf(le)!==-1)return;var pe=Object(E.c)(Y,ne);if($.dragNode.props.eventKey===le&&pe===0){$.setState({dragOverNodeKey:"",dropPosition:null});return}setTimeout(function(){$.setState({dragOverNodeKey:le,dropPosition:pe}),$.delayedDragEnterLogic||($.delayedDragEnterLogic={}),Object.keys($.delayedDragEnterLogic).forEach(function(Ee){clearTimeout($.delayedDragEnterLogic[Ee])}),$.delayedDragEnterLogic[De]=window.setTimeout(function(){if(!$.state.dragging)return;var Ee=Object(C.a)(H),Te=me[le];Te&&(Te.children||[]).length&&(Ee=Object(E.a)(H,le)),"expandedKeys"in $.props||$.setExpandedKeys(Ee),Oe&&Oe({event:Y,node:Object(b.b)(ne.props),expandedKeys:Ee})},400)},0)},$.onNodeDragOver=function(Y,ne){var z=$.state.dragNodesKeys,H=$.props.onDragOver,me=ne.props.eventKey;if(z.indexOf(me)!==-1)return;if($.dragNode&&me===$.state.dragOverNodeKey){var Le=Object(E.c)(Y,ne);if(Le===$.state.dropPosition)return;$.setState({dropPosition:Le})}H&&H({event:Y,node:Object(b.b)(ne.props)})},$.onNodeDragLeave=function(Y,ne){var z=$.props.onDragLeave;$.setState({dragOverNodeKey:""}),z&&z({event:Y,node:Object(b.b)(ne.props)})},$.onNodeDragEnd=function(Y,ne){var z=$.props.onDragEnd;$.setState({dragOverNodeKey:""}),$.cleanDragState(),z&&z({event:Y,node:Object(b.b)(ne.props)}),$.dragNode=null},$.onNodeDrop=function(Y,ne){var z=$.state,H=z.dragNodesKeys,me=H===void 0?[]:H,Le=z.dropPosition,Oe=$.props.onDrop,we=ne.props,De=we.eventKey,le=we.pos;if($.setState({dragOverNodeKey:""}),$.cleanDragState(),me.indexOf(De)!==-1){Object(w.a)(!1,"Can not drop to dragNode(include it's children node)");return}var pe=Object(E.k)(le),Ee={event:Y,node:Object(b.b)(ne.props),dragNode:$.dragNode?Object(b.b)($.dragNode.props):null,dragNodesKeys:me.slice(),dropPosition:Le+Number(pe[pe.length-1]),dropToGap:!1};Le!==0&&(Ee.dropToGap=!0),Oe&&Oe(Ee),$.dragNode=null},$.cleanDragState=function(){var Y=$.state.dragging;Y&&$.setState({dragging:!1})},$.onNodeClick=function(Y,ne){var z=$.props.onClick;z&&z(Y,ne)},$.onNodeDoubleClick=function(Y,ne){var z=$.props.onDoubleClick;z&&z(Y,ne)},$.onNodeSelect=function(Y,ne){var z=$.state.selectedKeys,H=$.state.keyEntities,me=$.props,Le=me.onSelect,Oe=me.multiple,we=ne.selected,De=ne.key,le=!we;le?Oe?z=Object(E.a)(z,De):z=[De]:z=Object(E.b)(z,De);var pe=z.map(function(Ee){var Te=H[Ee];return Te?Te.node:null}).filter(function(Ee){return Ee});$.setUncontrolledState({selectedKeys:z}),Le&&Le(z,{event:"select",selected:le,node:ne,selectedNodes:pe,nativeEvent:Y.nativeEvent})},$.onNodeCheck=function(Y,ne,z){var H=$.state,me=H.keyEntities,Le=H.checkedKeys,Oe=H.halfCheckedKeys,we=$.props,De=we.checkStrictly,le=we.onCheck,pe=ne.key,Ee,Te={event:"check",node:ne,checked:z,nativeEvent:Y.nativeEvent};if(De){var Ie=z?Object(E.a)(Le,pe):Object(E.b)(Le,pe),ke=Object(E.b)(Oe,pe);Ee={checked:Ie,halfChecked:ke},Te.checkedNodes=Ie.map(function(xe){return me[xe]}).filter(function(xe){return xe}).map(function(xe){return xe.node}),$.setUncontrolledState({checkedKeys:Ie})}else{var Me=Object(Q.a)([].concat(Object(C.a)(Le),[pe]),!0,me),Fe=Me.checkedKeys,ae=Me.halfCheckedKeys;if(!z){var ue=new Set(Fe);ue.delete(pe);var be=Object(Q.a)(Array.from(ue),{checked:!1,halfCheckedKeys:ae},me);Fe=be.checkedKeys,ae=be.halfCheckedKeys}Ee=Fe,Te.checkedNodes=[],Te.checkedNodesPositions=[],Te.halfCheckedKeys=ae,Fe.forEach(function(xe){var Ce=me[xe];if(!Ce)return;var Se=Ce.node,ye=Ce.pos;Te.checkedNodes.push(Se),Te.checkedNodesPositions.push({node:Se,pos:ye})}),$.setUncontrolledState({checkedKeys:Fe},!1,{halfCheckedKeys:ae})}le&&le(Ee,Te)},$.onNodeLoad=function(Y){return new Promise(function(ne){$.setState(function(z){var H=z.loadedKeys,me=H===void 0?[]:H,Le=z.loadingKeys,Oe=Le===void 0?[]:Le,we=$.props,De=we.loadData,le=we.onLoad,pe=Y.key;if(!De||me.indexOf(pe)!==-1||Oe.indexOf(pe)!==-1)return{};var Ee=De(Y);return Ee.then(function(){var Te=$.state,Ie=Te.loadedKeys,ke=Te.loadingKeys,Me=Object(E.a)(Ie,pe),Fe=Object(E.b)(ke,pe);le&&le(Me,{event:"load",node:Y}),$.setUncontrolledState({loadedKeys:Me}),$.setState({loadingKeys:Fe}),ne()}),{loadingKeys:Object(E.a)(Oe,pe)}})})},$.onNodeMouseEnter=function(Y,ne){var z=$.props.onMouseEnter;z&&z({event:Y,node:ne})},$.onNodeMouseLeave=function(Y,ne){var z=$.props.onMouseLeave;z&&z({event:Y,node:ne})},$.onNodeContextMenu=function(Y,ne){var z=$.props.onRightClick;z&&(Y.preventDefault(),z({event:Y,node:ne}))},$.onFocus=function(){var Y=$.props.onFocus;$.setState({focused:!0}),Y&&Y.apply(void 0,arguments)},$.onBlur=function(){var Y=$.props.onBlur;$.setState({focused:!1}),$.onActiveChange(null),Y&&Y.apply(void 0,arguments)},$.getTreeNodeRequiredProps=function(){var Y=$.state,ne=Y.expandedKeys,z=Y.selectedKeys,H=Y.loadedKeys,me=Y.loadingKeys,Le=Y.checkedKeys,Oe=Y.halfCheckedKeys,we=Y.dragOverNodeKey,De=Y.dropPosition,le=Y.keyEntities;return{expandedKeys:ne||[],selectedKeys:z||[],loadedKeys:H||[],loadingKeys:me||[],checkedKeys:Le||[],halfCheckedKeys:Oe||[],dragOverNodeKey:we,dropPosition:De,keyEntities:le}},$.setExpandedKeys=function(Y){var ne=$.state.treeData,z=Object(b.d)(ne,Y);$.setUncontrolledState({expandedKeys:Y,flattenNodes:z},!0)},$.onNodeExpand=function(Y,ne){var z=$.state.expandedKeys,H=$.state.listChanging,me=$.props,Le=me.onExpand,Oe=me.loadData,we=ne.key,De=ne.expanded;if(H)return;var le=z.indexOf(we),pe=!De;if(Object(w.a)(De&&le!==-1||!De&&le===-1,"Expand state not sync with index check"),pe?z=Object(E.a)(z,we):z=Object(E.b)(z,we),$.setExpandedKeys(z),Le&&Le(z,{node:ne,expanded:pe,nativeEvent:Y.nativeEvent}),pe&&Oe){var Ee=$.onNodeLoad(ne);Ee&&Ee.then(function(){var Te=Object(b.d)($.state.treeData,z);$.setUncontrolledState({flattenNodes:Te})})}},$.onListChangeStart=function(){$.setUncontrolledState({listChanging:!0})},$.onListChangeEnd=function(){setTimeout(function(){$.setUncontrolledState({listChanging:!1})})},$.onActiveChange=function(Y){var ne=$.state.activeKey,z=$.props.onActiveChange;if(ne===Y)return;$.setState({activeKey:Y}),Y!==null&&$.scrollTo({key:Y}),z&&z(Y)},$.getActiveItem=function(){var Y=$.state,ne=Y.activeKey,z=Y.flattenNodes;return ne===null?null:z.find(function(H){var me=H.data.key;return me===ne})||null},$.offsetActiveKey=function(Y){var ne=$.state,z=ne.flattenNodes,H=ne.activeKey,me=z.findIndex(function(we){var De=we.data.key;return De===H});me===-1&&Y<0&&(me=z.length),me=(me+Y+z.length)%z.length;var Le=z[me];if(Le){var Oe=Le.data.key;$.onActiveChange(Oe)}else $.onActiveChange(null)},$.onKeyDown=function(Y){var ne=$.state,z=ne.activeKey,H=ne.expandedKeys,me=ne.checkedKeys,Le=$.props,Oe=Le.onKeyDown,we=Le.checkable,De=Le.selectable;switch(Y.which){case A.a.UP:{$.offsetActiveKey(-1),Y.preventDefault();break}case A.a.DOWN:{$.offsetActiveKey(1),Y.preventDefault();break}}var le=$.getActiveItem();if(le&&le.data){var pe=$.getTreeNodeRequiredProps(),Ee=le.data.isLeaf===!1||!!(le.data.children||[]).length,Te=Object(b.b)(Object(U.a)(Object(U.a)({},Object(b.f)(z,pe)),{},{data:le.data,active:!0}));switch(Y.which){case A.a.LEFT:{Ee&&H.includes(z)?$.onNodeExpand({},Te):le.parent&&$.onActiveChange(le.parent.data.key),Y.preventDefault();break}case A.a.RIGHT:{Ee&&!H.includes(z)?$.onNodeExpand({},Te):le.children&&le.children.length&&$.onActiveChange(le.children[0].data.key),Y.preventDefault();break}case A.a.ENTER:case A.a.SPACE:{we&&!Te.disabled&&Te.checkable!==!1&&!Te.disableCheckbox?$.onNodeCheck({},Te,!me.includes(z)):!we&&De&&!Te.disabled&&Te.selectable!==!1&&$.onNodeSelect({},Te);break}}}Oe&&Oe(Y)},$.setUncontrolledState=function(Y){var ne=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,z=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;if($.destroyed)return;var H=!1,me=!0,Le={};Object.keys(Y).forEach(function(Oe){if(Oe in $.props){me=!1;return}H=!0,Le[Oe]=Y[Oe]}),H&&(!ne||me)&&$.setState(Object(U.a)(Object(U.a)({},Le),z))},$.scrollTo=function(Y){$.listRef.current.scrollTo(Y)},$}return Object(O.a)(de,[{key:"componentWillUnmount",value:function(){this.destroyed=!0}},{key:"render",value:function(){var Y,ne=this.state,z=ne.focused,H=ne.flattenNodes,me=ne.keyEntities,Le=ne.dragging,Oe=ne.activeKey,we=this.props,De=we.prefixCls,le=we.className,pe=we.style,Ee=we.showLine,Te=we.focusable,Ie=we.tabIndex,ke=Ie===void 0?0:Ie,Me=we.selectable,Fe=we.showIcon,ae=we.icon,ue=we.switcherIcon,be=we.draggable,xe=we.checkable,Ce=we.checkStrictly,Se=we.disabled,ye=we.motion,Ne=we.loadData,Be=we.filterTreeNode,ve=we.height,_e=we.itemHeight,re=we.virtual,q=we.titleRender,te=we.onContextMenu,j=Object(E.f)(this.props);return M.createElement(S.a.Provider,{value:{prefixCls:De,selectable:Me,showIcon:Fe,icon:ae,switcherIcon:ue,draggable:be,checkable:xe,checkStrictly:Ce,disabled:Se,keyEntities:me,loadData:Ne,filterTreeNode:Be,titleRender:q,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}},M.createElement("div",{className:x()(De,le,(Y={},Object(fe.a)(Y,"".concat(De,"-show-line"),Ee),Object(fe.a)(Y,"".concat(De,"-focused"),z),Object(fe.a)(Y,"".concat(De,"-active-focused"),Oe!==null),Y))},M.createElement(V,Object.assign({ref:this.listRef,prefixCls:De,style:pe,data:H,disabled:Se,selectable:Me,checkable:!!xe,motion:ye,dragging:Le,height:ve,itemHeight:_e,virtual:re,focusable:Te,focused:z,tabIndex:ke,activeItem:this.getActiveItem(),onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onActiveChange:this.onActiveChange,onListChangeStart:this.onListChangeStart,onListChangeEnd:this.onListChangeEnd,onContextMenu:te},this.getTreeNodeRequiredProps(),j))))}}],[{key:"getDerivedStateFromProps",value:function(Y,ne){var z=ne.prevProps,H={prevProps:Y};function me(ae){return!z&&ae in Y||z&&z[ae]!==Y[ae]}var Le;if(me("treeData")?Le=Y.treeData:me("children")&&(Object(w.a)(!1,"`children` of Tree is deprecated. Please use `treeData` instead."),Le=Object(b.c)(Y.children)),Le){H.treeData=Le;var Oe=Object(b.a)(Le);H.keyEntities=Object(U.a)(Object(fe.a)({},t,m),Oe.keyEntities)}var we=H.keyEntities||ne.keyEntities;if(me("expandedKeys")||z&&me("autoExpandParent"))H.expandedKeys=Y.autoExpandParent||!z&&Y.defaultExpandParent?Object(E.e)(Y.expandedKeys,we):Y.expandedKeys;else if(!z&&Y.defaultExpandAll){var De=Object(U.a)({},we);delete De[t],H.expandedKeys=Object.keys(De).map(function(ae){return De[ae].key})}else!z&&Y.defaultExpandedKeys&&(H.expandedKeys=Y.autoExpandParent||Y.defaultExpandParent?Object(E.e)(Y.defaultExpandedKeys,we):Y.defaultExpandedKeys);if(H.expandedKeys||delete H.expandedKeys,Le||H.expandedKeys){var le=Object(b.d)(Le||ne.treeData,H.expandedKeys||ne.expandedKeys);H.flattenNodes=le}if(Y.selectable&&(me("selectedKeys")?H.selectedKeys=Object(E.d)(Y.selectedKeys,Y):!z&&Y.defaultSelectedKeys&&(H.selectedKeys=Object(E.d)(Y.defaultSelectedKeys,Y))),Y.checkable){var pe;if(me("checkedKeys")?pe=Object(E.j)(Y.checkedKeys)||{}:!z&&Y.defaultCheckedKeys?pe=Object(E.j)(Y.defaultCheckedKeys)||{}:Le&&(pe=Object(E.j)(Y.checkedKeys)||{checkedKeys:ne.checkedKeys,halfCheckedKeys:ne.halfCheckedKeys}),pe){var Ee=pe,Te=Ee.checkedKeys,Ie=Te===void 0?[]:Te,ke=Ee.halfCheckedKeys,Me=ke===void 0?[]:ke;if(!Y.checkStrictly){var Fe=Object(Q.a)(Ie,!0,we);Ie=Fe.checkedKeys,Me=Fe.halfCheckedKeys}H.checkedKeys=Ie,H.halfCheckedKeys=Me}}return me("loadedKeys")&&(H.loadedKeys=Y.loadedKeys),H}}]),de}(M.Component);Z.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:[]},Z.TreeNode=o.a;var ie=Z,ge=We.b=ie},p5ED:function(nt,We,J){"use strict";var fe=J("+L6B"),U=J("2/Rp"),C=J("5Dmo"),B=J("3S7+"),O=J("k1fw"),L=J("9og8"),_=J("tJVT"),M=J("WmNS"),A=J.n(M),w=J("q1tI"),g=J.n(w),x=J("vHTk"),S=J.n(x),E=J("yEEn"),b=J("ZW9T"),y=J("1vsH"),h=J("V0Rq"),e=J("m3rI"),s=function(f){var u=f.name,l=f.data,p=f.theme,c=f.type,i=f.filename,r=f.monacoEditor,t=f.className,a=f.style,m=f.close,v=f.onClose,T=f.hasMask,k=f.otherData,I=k===void 0?{}:k,F=Object(w.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),K=Object(_.a)(F,2),V=K[0],Q=K[1],Z=Object(w.useState)(""),ie=Object(_.a)(Z,2),ge=ie[0],se=ie[1],he=Object(w.useState)(),de=Object(_.a)(he,2),$=de[0],Y=de[1],ne=window.ENV==="build"?"/react/build/office.html":"/office.html",z,H=1024*1024,me=10*H,Le=Object(w.useRef)();c==="office"&&(z=Object(y.R)(l).filesize,z>me&&(c="other")),i&&(r.filename=i),Object(w.useEffect)(function(){var le,pe,Ee=(le=document.cookie)===null||le===void 0||((pe=le.replace(/\s/g,""))===null||pe===void 0)?void 0:pe.split(";");Ee==null||Ee.map(function(Te){var Ie=Te.split("=");Ie[0]==="_educoder_session"&&se(Ie[1])})},[]),Object(w.useEffect)(function(){c==="office"&&Oe()},[c]);var Oe=function(){var le=Object(L.a)(A.a.mark(function pe(){var Ee,Te,Ie;return A.a.wrap(function(Me){for(;;)switch(Me.prev=Me.next){case 0:return console.log("data:",l),Ee=l,l.startsWith("http")||(Ee=location.origin+Ee),Te=new URL(Ee).pathname.split("/").pop(),Me.next=6,Object(h.U)({attachment_id:Te});case 6:Ie=Me.sent,Y(Ie);case 8:case"end":return Me.stop()}},pe)}));return function(){return le.apply(this,arguments)}}(),we=function(){if(l.startsWith("http")||l.startsWith("/api")||l.startsWith("blob:")){De();return}Object(y.x)(i||"educoder",l,i||"educoder")},De=function(){Object(y.v)(i||"educoder",decodeURIComponent(l))};return g.a.createElement("div",{style:Object(O.a)({},a||{}),className:"".concat(T&&S.a.bgBlack," ").concat(c?S.a.wrp:"hide")},m&&g.a.createElement("div",{className:S.a.close,ref:Le},g.a.createElement(B.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return Le.current}},g.a.createElement("span",{onClick:De},g.a.createElement("i",{className:"icon-quxiaozhiding"}))),g.a.createElement(B.a,{title:"\u5173\u95ED",getPopupContainer:function(){return Le.current}},g.a.createElement("span",{className:"",onClick:function(){v(),Y(null)}},g.a.createElement("i",{className:"icon-guanbi1"})))),g.a.createElement("div",{className:"".concat(S.a[t]," ").concat(t," ").concat(S.a.monaco," ").concat(c==="txt"?"show":"hide")},c==="txt"&&g.a.createElement(b.b,r)),c==="audio"&&g.a.createElement("audio",{src:"".concat((l==null?void 0:l.indexOf("http://"))>-1||(l==null?void 0:l.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(l),autoPlay:!0}),c==="video"&&g.a.createElement(g.a.Fragment,null,(l==null?void 0:l.indexOf("/api"))>-1?g.a.createElement("video",{controls:!0,src:"".concat(l),autoPlay:!0}):g.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(l),autoPlay:!0})),c==="office"&&$&&g.a.createElement("iframe",{src:"".concat(ne,"?key=").concat($.key,"&url=").concat(e.a.API_SERVER+$.url,"&callbackUrl=").concat(e.a.API_SERVER+$.callbackUrl,"&fileType=").concat($.fileType,"&title=").concat($.title,"&model=view")}),(c==="xlsx"||c==="doc"||c==="pptx"||c==="docx")&&g.a.createElement("iframe",{src:"".concat(ne,"?key=").concat(I.key,"&url=").concat(e.a.API_SERVER+I.url,"&callbackUrl=").concat(e.a.API_SERVER+I.callbackUrl,"&fileType=").concat(I.fileType,"&title=").concat(I.title,"&model=").concat(I.model)}),c==="html"&&g.a.createElement("iframe",{src:l+"&disposition=inline"}),c==="pdf"&&g.a.createElement("embed",{className:S.a.embed,src:l,type:"application/pdf"}),c==="image"&&g.a.createElement("img",{src:"".concat((l==null?void 0:l.indexOf("http://"))>-1||(l==null?void 0:l.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(l)}),c==="other"&&g.a.createElement("div",null,g.a.createElement(U.a,{type:"primary",size:"large",onClick:we},g.a.createElement(E.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),c==="download"&&g.a.createElement(U.a,{type:"primary",size:"large",onClick:we},g.a.createElement(E.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))};We.a=s},"rAM+":function(nt,We,J){"use strict";J.d(We,"a",function(){return U});var fe=J("Qw5x");function U(C,B){var O;if(typeof Symbol=="undefined"||C[Symbol.iterator]==null){if(Array.isArray(C)||(O=Object(fe.a)(C))||B&&C&&typeof C.length=="number"){O&&(C=O);var L=0,_=function(){};return{s:_,n:function(){return L>=C.length?{done:!0}:{done:!1,value:C[L++]}},e:function(x){throw x},f:_}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var M=!0,A=!1,w;return{s:function(){O=C[Symbol.iterator]()},n:function(){var x=O.next();return M=x.done,x},e:function(x){A=!0,w=x},f:function(){try{!M&&O.return!=null&&O.return()}finally{if(A)throw w}}}}},rUJ1:function(nt,We){const J=/[&<>"']/,fe=/[&<>"']/g,U=/[<>"']|&(?!#?\w+;)/,C=/[<>"']|&(?!#?\w+;)/g,B={"&":"&","<":"<",">":">",'"':""","'":"'"},O=c=>B[c];function L(c,i){if(i){if(J.test(c))return c.replace(fe,O)}else if(U.test(c))return c.replace(C,O);return c}const _=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function M(c){return c.replace(_,(i,r)=>(r=r.toLowerCase(),r==="colon"?":":r.charAt(0)==="#"?r.charAt(1)==="x"?String.fromCharCode(parseInt(r.substring(2),16)):String.fromCharCode(+r.substring(1)):""))}const A=/(^|[^\[])\^/g;function w(c,i){c=c.source||c,i=i||"";const r={replace:(t,a)=>(a=a.source||a,a=a.replace(A,"$1"),c=c.replace(t,a),r),getRegex:()=>new RegExp(c,i)};return r}const g=/[^\w:]/g,x=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function S(c,i,r){if(c){let t;try{t=decodeURIComponent(M(r)).replace(g,"").toLowerCase()}catch(a){return null}if(t.indexOf("javascript:")===0||t.indexOf("vbscript:")===0||t.indexOf("data:")===0)return null}i&&!x.test(r)&&(r=e(i,r));try{r=encodeURI(r).replace(/%25/g,"%")}catch(t){return null}return r}const E={},b=/^[^:]+:\/*[^/]*$/,y=/^([^:]+:)[\s\S]*$/,h=/^([^:]+:\/*[^/]*)[\s\S]*$/;function e(c,i){E[" "+c]||(b.test(c)?E[" "+c]=c+"/":E[" "+c]=u(c,"/",!0)),c=E[" "+c];const r=c.indexOf(":")===-1;return i.substring(0,2)==="//"?r?i:c.replace(y,"$1")+i:i.charAt(0)==="/"?r?i:c.replace(h,"$1")+i:c+i}const s={exec:function(){}};function o(c){let i=1,r,t;for(;i<arguments.length;i++){r=arguments[i];for(t in r)Object.prototype.hasOwnProperty.call(r,t)&&(c[t]=r[t])}return c}function f(c,i){const r=c.replace(/\|/g,(m,v,T)=>{let k=!1,I=v;for(;--I>=0&&T[I]==="\\";)k=!k;return k?"|":" |"}),t=r.split(/ \|/);let a=0;if(t.length>i)t.splice(i);else for(;t.length<i;)t.push("");for(;a<t.length;a++)t[a]=t[a].trim().replace(/\\\|/g,"|");return t}function u(c,i,r){const t=c.length;if(t===0)return"";let a=0;for(;a<t;){const m=c.charAt(t-a-1);if(m===i&&!r)a++;else if(m!==i&&r)a++;else break}return c.substr(0,t-a)}function l(c,i){if(c.indexOf(i[1])===-1)return-1;const r=c.length;let t=0,a=0;for(;a<r;a++)if(c[a]==="\\")a++;else if(c[a]===i[0])t++;else if(c[a]===i[1]&&(t--,t<0))return a;return-1}function p(c){c&&c.sanitize&&!c.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")}nt.exports={escape:L,unescape:M,edit:w,cleanUrl:S,resolveUrl:e,noopTest:s,merge:o,splitCells:f,rtrim:u,findClosingBracket:l,checkSanitizeDeprecation:p}},sboe:function(nt,We,J){"use strict";J.d(We,"a",function(){return C});var fe=J("q1tI"),U=J.n(fe),C=fe.createContext(null)},ulZh:function(nt,We,J){typeof window!="undefined"&&function(U,C){nt.exports=C()}(this,function(){return function(fe){var U={};function C(B){if(U[B])return U[B].exports;var O=U[B]={i:B,l:!1,exports:{}};return fe[B].call(O.exports,O,O.exports,C),O.l=!0,O.exports}return C.m=fe,C.c=U,C.d=function(B,O,L){C.o(B,O)||Object.defineProperty(B,O,{enumerable:!0,get:L})},C.r=function(B){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(B,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(B,"__esModule",{value:!0})},C.t=function(B,O){if(O&1&&(B=C(B)),O&8)return B;if(O&4&&typeof B=="object"&&B&&B.__esModule)return B;var L=Object.create(null);if(C.r(L),Object.defineProperty(L,"default",{enumerable:!0,value:B}),O&2&&typeof B!="string")for(var _ in B)C.d(L,_,function(M){return B[M]}.bind(null,_));return L},C.n=function(B){var O=B&&B.__esModule?function(){return B.default}:function(){return B};return C.d(O,"a",O),O},C.o=function(B,O){return Object.prototype.hasOwnProperty.call(B,O)},C.p="/dist/",C(C.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(fe,U,C){"use strict";var B=Object.prototype.hasOwnProperty,O="~";function L(){}Object.create&&(L.prototype=Object.create(null),new L().__proto__||(O=!1));function _(g,x,S){this.fn=g,this.context=x,this.once=S||!1}function M(g,x,S,E,b){if(typeof S!="function")throw new TypeError("The listener must be a function");var y=new _(S,E||g,b),h=O?O+x:x;return g._events[h]?g._events[h].fn?g._events[h]=[g._events[h],y]:g._events[h].push(y):(g._events[h]=y,g._eventsCount++),g}function A(g,x){--g._eventsCount===0?g._events=new L:delete g._events[x]}function w(){this._events=new L,this._eventsCount=0}w.prototype.eventNames=function(){var x=[],S,E;if(this._eventsCount===0)return x;for(E in S=this._events)B.call(S,E)&&x.push(O?E.slice(1):E);return Object.getOwnPropertySymbols?x.concat(Object.getOwnPropertySymbols(S)):x},w.prototype.listeners=function(x){var S=O?O+x:x,E=this._events[S];if(!E)return[];if(E.fn)return[E.fn];for(var b=0,y=E.length,h=new Array(y);b<y;b++)h[b]=E[b].fn;return h},w.prototype.listenerCount=function(x){var S=O?O+x:x,E=this._events[S];return E?E.fn?1:E.length:0},w.prototype.emit=function(x,S,E,b,y,h){var e=O?O+x:x;if(!this._events[e])return!1;var s=this._events[e],o=arguments.length,f,u;if(s.fn){s.once&&this.removeListener(x,s.fn,void 0,!0);switch(o){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,S),!0;case 3:return s.fn.call(s.context,S,E),!0;case 4:return s.fn.call(s.context,S,E,b),!0;case 5:return s.fn.call(s.context,S,E,b,y),!0;case 6:return s.fn.call(s.context,S,E,b,y,h),!0}for(u=1,f=new Array(o-1);u<o;u++)f[u-1]=arguments[u];s.fn.apply(s.context,f)}else{var l=s.length,p;for(u=0;u<l;u++){s[u].once&&this.removeListener(x,s[u].fn,void 0,!0);switch(o){case 1:s[u].fn.call(s[u].context);break;case 2:s[u].fn.call(s[u].context,S);break;case 3:s[u].fn.call(s[u].context,S,E);break;case 4:s[u].fn.call(s[u].context,S,E,b);break;default:if(!f)for(p=1,f=new Array(o-1);p<o;p++)f[p-1]=arguments[p];s[u].fn.apply(s[u].context,f)}}}return!0},w.prototype.on=function(x,S,E){return M(this,x,S,E,!1)},w.prototype.once=function(x,S,E){return M(this,x,S,E,!0)},w.prototype.removeListener=function(x,S,E,b){var y=O?O+x:x;if(!this._events[y])return this;if(!S)return A(this,y),this;var h=this._events[y];if(h.fn)h.fn===S&&(!b||h.once)&&(!E||h.context===E)&&A(this,y);else{for(var e=0,s=[],o=h.length;e<o;e++)(h[e].fn!==S||b&&!h[e].once||E&&h[e].context!==E)&&s.push(h[e]);s.length?this._events[y]=s.length===1?s[0]:s:A(this,y)}return this},w.prototype.removeAllListeners=function(x){var S;return x?(S=O?O+x:x,this._events[S]&&A(this,S)):(this._events=new L,this._eventsCount=0),this},w.prototype.off=w.prototype.removeListener,w.prototype.addListener=w.prototype.on,w.prefixed=O,w.EventEmitter=w,fe.exports=w},"./node_modules/url-toolkit/src/url-toolkit.js":function(fe,U,C){(function(B){var O=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,L=/^([^\/?#]*)([^]*)$/,_=/(?:\/|^)\.(?=\/)/g,M=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,A={buildAbsoluteURL:function(w,g,x){if(x=x||{},w=w.trim(),g=g.trim(),!g){if(!x.alwaysNormalize)return w;var S=A.parseURL(w);if(!S)throw new Error("Error trying to parse base URL.");return S.path=A.normalizePath(S.path),A.buildURLFromParts(S)}var E=A.parseURL(g);if(!E)throw new Error("Error trying to parse relative URL.");if(E.scheme)return x.alwaysNormalize?(E.path=A.normalizePath(E.path),A.buildURLFromParts(E)):g;var b=A.parseURL(w);if(!b)throw new Error("Error trying to parse base URL.");if(!b.netLoc&&b.path&&b.path[0]!=="/"){var y=L.exec(b.path);b.netLoc=y[1],b.path=y[2]}b.netLoc&&!b.path&&(b.path="/");var h={scheme:b.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc&&(h.netLoc=b.netLoc,E.path[0]!=="/"))if(!E.path)h.path=b.path,E.params||(h.params=b.params,E.query||(h.query=b.query));else{var e=b.path,s=e.substring(0,e.lastIndexOf("/")+1)+E.path;h.path=A.normalizePath(s)}return h.path===null&&(h.path=x.alwaysNormalize?A.normalizePath(E.path):E.path),A.buildURLFromParts(h)},parseURL:function(w){var g=O.exec(w);return g?{scheme:g[1]||"",netLoc:g[2]||"",path:g[3]||"",params:g[4]||"",query:g[5]||"",fragment:g[6]||""}:null},normalizePath:function(w){for(w=w.split("").reverse().join("").replace(_,"");w.length!==(w=w.replace(M,"")).length;);return w.split("").reverse().join("")},buildURLFromParts:function(w){return w.scheme+w.netLoc+w.path+w.params+w.query+w.fragment}};fe.exports=A})(this)},"./node_modules/webworkify-webpack/index.js":function(fe,U,C){function B(x){var S={};function E(y){if(S[y])return S[y].exports;var h=S[y]={i:y,l:!1,exports:{}};return x[y].call(h.exports,h,h.exports,E),h.l=!0,h.exports}E.m=x,E.c=S,E.i=function(y){return y},E.d=function(y,h,e){E.o(y,h)||Object.defineProperty(y,h,{configurable:!1,enumerable:!0,get:e})},E.r=function(y){Object.defineProperty(y,"__esModule",{value:!0})},E.n=function(y){var h=y&&y.__esModule?function(){return y.default}:function(){return y};return E.d(h,"a",h),h},E.o=function(y,h){return Object.prototype.hasOwnProperty.call(y,h)},E.p="/",E.oe=function(y){throw console.error(y),y};var b=E(E.s=ENTRY_MODULE);return b.default||b}var O="[\\.|\\-|\\+|\\w|/|@]+",L="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+O+").*?\\)";function _(x){return(x+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function M(x){return!isNaN(1*x)}function A(x,S,E){var b={};b[E]=[];var y=S.toString(),h=y.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!h)return b;for(var e=h[1],s=new RegExp("(\\\\n|\\W)"+_(e)+L,"g"),o;o=s.exec(y);){if(o[3]==="dll-reference")continue;b[E].push(o[3])}for(s=new RegExp("\\("+_(e)+'\\("(dll-reference\\s('+O+'))"\\)\\)'+L,"g");o=s.exec(y);)x[o[2]]||(b[E].push(o[1]),x[o[2]]=C(o[1]).m),b[o[2]]=b[o[2]]||[],b[o[2]].push(o[4]);for(var f=Object.keys(b),u=0;u<f.length;u++)for(var l=0;l<b[f[u]].length;l++)M(b[f[u]][l])&&(b[f[u]][l]=1*b[f[u]][l]);return b}function w(x){var S=Object.keys(x);return S.reduce(function(E,b){return E||x[b].length>0},!1)}function g(x,S){for(var E={main:[S]},b={main:[]},y={main:{}};w(E);)for(var h=Object.keys(E),e=0;e<h.length;e++){var s=h[e],o=E[s],f=o.pop();if(y[s]=y[s]||{},y[s][f]||!x[s][f])continue;y[s][f]=!0,b[s]=b[s]||[],b[s].push(f);for(var u=A(x,x[s][f],s),l=Object.keys(u),p=0;p<l.length;p++)E[l[p]]=E[l[p]]||[],E[l[p]]=E[l[p]].concat(u[l[p]])}return b}fe.exports=function(x,S){S=S||{};var E={main:C.m},b=S.all?{main:Object.keys(E.main)}:g(E,x),y="";Object.keys(b).filter(function(f){return f!=="main"}).forEach(function(f){for(var u=0;b[f][u];)u++;b[f].push(u),E[f][u]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",y=y+"var "+f+" = ("+B.toString().replace("ENTRY_MODULE",JSON.stringify(u))+")({"+b[f].map(function(l){return""+JSON.stringify(l)+": "+E[f][l].toString()}).join(",")+`});
|
|
`}),y=y+"new (("+B.toString().replace("ENTRY_MODULE",JSON.stringify(x))+")({"+b.main.map(function(f){return""+JSON.stringify(f)+": "+E.main[f].toString()}).join(",")+"}))(self);";var h=new window.Blob([y],{type:"text/javascript"});if(S.bare)return h;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,s=e.createObjectURL(h),o=new window.Worker(s);return o.objectURL=s,o}},"./src/config.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"hlsDefaultConfig",function(){return p}),C.d(U,"mergeConfig",function(){return i}),C.d(U,"enableStreamingMode",function(){return r});var B=C("./src/controller/abr-controller.ts"),O=C("./src/controller/audio-stream-controller.ts"),L=C("./src/controller/audio-track-controller.ts"),_=C("./src/controller/subtitle-stream-controller.ts"),M=C("./src/controller/subtitle-track-controller.ts"),A=C("./src/controller/buffer-controller.ts"),w=C("./src/controller/timeline-controller.ts"),g=C("./src/controller/cap-level-controller.ts"),x=C("./src/controller/fps-controller.ts"),S=C("./src/controller/eme-controller.ts"),E=C("./src/controller/cmcd-controller.ts"),b=C("./src/utils/xhr-loader.ts"),y=C("./src/utils/fetch-loader.ts"),h=C("./src/utils/cues.ts"),e=C("./src/utils/mediakeys-helper.ts"),s=C("./src/utils/logger.ts");function o(){return o=Object.assign||function(t){for(var a=1;a<arguments.length;a++){var m=arguments[a];for(var v in m)Object.prototype.hasOwnProperty.call(m,v)&&(t[v]=m[v])}return t},o.apply(this,arguments)}function f(t,a){var m=Object.keys(t);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(t);a&&(v=v.filter(function(T){return Object.getOwnPropertyDescriptor(t,T).enumerable})),m.push.apply(m,v)}return m}function u(t){for(var a=1;a<arguments.length;a++){var m=arguments[a]!=null?arguments[a]:{};a%2?f(Object(m),!0).forEach(function(v){l(t,v,m[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(m)):f(Object(m)).forEach(function(v){Object.defineProperty(t,v,Object.getOwnPropertyDescriptor(m,v))})}return t}function l(t,a,m){return a in t?Object.defineProperty(t,a,{value:m,enumerable:!0,configurable:!0,writable:!0}):t[a]=m,t}var p=u(u({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:Infinity,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:Infinity,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:b.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:B.default,bufferController:A.default,capLevelController:g.default,fpsController:x.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:e.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},c()),{},{subtitleStreamController:_.SubtitleStreamController,subtitleTrackController:M.default,timelineController:w.TimelineController,audioStreamController:O.default,audioTrackController:L.default,emeController:S.default,cmcdController:E.default});function c(){return{cueHandler:h.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function i(t,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return o({},t,a)}function r(t){var a=t.loader;if(a!==y.default&&a!==b.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1;else{var m=Object(y.fetchSupported)();m&&(t.loader=y.default,t.progressive=!0,t.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/polyfills/number.ts"),O=C("./src/utils/ewma-bandwidth-estimator.ts"),L=C("./src/events.ts"),_=C("./src/utils/buffer-helper.ts"),M=C("./src/errors.ts"),A=C("./src/types/loader.ts"),w=C("./src/utils/logger.ts");function g(E,b){for(var y=0;y<b.length;y++){var h=b[y];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(E,h.key,h)}}function x(E,b,y){return b&&g(E.prototype,b),y&&g(E,y),E}var S=function(){function E(y){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=y;var h=y.config;this.bwEstimator=new O.default(h.abrEwmaSlowVoD,h.abrEwmaFastVoD,h.abrEwmaDefaultEstimate),this.registerListeners()}var b=E.prototype;return b.registerListeners=function(){var h=this.hls;h.on(L.Events.FRAG_LOADING,this.onFragLoading,this),h.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),h.on(L.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(L.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){var h=this.hls;h.off(L.Events.FRAG_LOADING,this.onFragLoading,this),h.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),h.off(L.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(L.Events.ERROR,this.onError,this)},b.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},b.onFragLoading=function(h,e){var s=e.frag;if(s.type===A.PlaylistLevelType.MAIN&&!this.timer){var o;this.fragCurrent=s,this.partCurrent=(o=e.part)!=null?o:null,this.timer=self.setInterval(this.onCheck,100)}},b.onLevelLoaded=function(h,e){var s=this.hls.config;e.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)},b._abandonRulesCheck=function(){var h=this.fragCurrent,e=this.partCurrent,s=this.hls,o=s.autoLevelEnabled,f=s.config,u=s.media;if(!h||!u)return;var l=e?e.stats:h.stats,p=e?e.duration:h.duration;if(l.aborted){w.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!o||u.paused||!u.playbackRate||!u.readyState)return;var c=performance.now()-l.loading.start,i=Math.abs(u.playbackRate);if(c<=500*p/i)return;var r=s.levels,t=s.minAutoLevel,a=r[h.level],m=l.total||Math.max(l.loaded,Math.round(p*a.maxBitrate/8)),v=Math.max(1,l.bwEstimate?l.bwEstimate/8:l.loaded*1e3/c),T=(m-l.loaded)/v,k=u.currentTime,I=(_.BufferHelper.bufferInfo(u,k,f.maxBufferHole).end-k)/i;if(I>=2*p/i||T<=I)return;var F=Number.POSITIVE_INFINITY,K;for(K=h.level-1;K>t;K--){var V=r[K].maxBitrate;if(F=p*V/(8*.8*v),F<I)break}if(F>=T)return;var Q=this.bwEstimator.getEstimate();w.logger.warn("Fragment "+h.sn+(e?" part "+e.index:"")+" of level "+h.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+K+`
|
|
Current BW estimate: `+(Object(B.isFiniteNumber)(Q)?(Q/1024).toFixed(3):"Unknown")+` Kb/s
|
|
Estimated load time for current fragment: `+T.toFixed(3)+` s
|
|
Estimated load time for the next fragment: `+F.toFixed(3)+` s
|
|
Time to underbuffer: `+I.toFixed(3)+" s"),s.nextLoadLevel=K,this.bwEstimator.sample(c,l.loaded),this.clearTimer(),h.loader&&(this.fragCurrent=this.partCurrent=null,h.loader.abort()),s.trigger(L.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:h,part:e,stats:l})},b.onFragLoaded=function(h,e){var s=e.frag,o=e.part;if(s.type===A.PlaylistLevelType.MAIN&&Object(B.isFiniteNumber)(s.sn)){var f=o?o.stats:s.stats,u=o?o.duration:s.duration;if(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var l=this.hls.levels[s.level],p=(l.loaded?l.loaded.bytes:0)+f.loaded,c=(l.loaded?l.loaded.duration:0)+u;l.loaded={bytes:p,duration:c},l.realBitrate=Math.round(8*p/c)}if(s.bitrateTest){var i={stats:f,frag:s,part:o,id:s.type};this.onFragBuffered(L.Events.FRAG_BUFFERED,i),s.bitrateTest=!1}}},b.onFragBuffered=function(h,e){var s=e.frag,o=e.part,f=o?o.stats:s.stats;if(f.aborted)return;if(s.type!==A.PlaylistLevelType.MAIN||s.sn==="initSegment")return;var u=f.parsing.end-f.loading.start;this.bwEstimator.sample(u,f.loaded),f.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=u/1e3:this.bitrateTestDelay=0},b.onError=function(h,e){switch(e.details){case M.ErrorDetails.FRAG_LOAD_ERROR:case M.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},b.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},b.getNextABRAutoLevel=function(){var h=this.fragCurrent,e=this.partCurrent,s=this.hls,o=s.maxAutoLevel,f=s.config,u=s.minAutoLevel,l=s.media,p=e?e.duration:h?h.duration:0,c=l?l.currentTime:0,i=l&&l.playbackRate!==0?Math.abs(l.playbackRate):1,r=this.bwEstimator?this.bwEstimator.getEstimate():f.abrEwmaDefaultEstimate,t=(_.BufferHelper.bufferInfo(l,c,f.maxBufferHole).end-c)/i,a=this.findBestLevel(r,u,o,t,f.abrBandWidthFactor,f.abrBandWidthUpFactor);if(a>=0)return a;w.logger.trace((t?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var m=p?Math.min(p,f.maxStarvationDelay):f.maxStarvationDelay,v=f.abrBandWidthFactor,T=f.abrBandWidthUpFactor;if(!t){var k=this.bitrateTestDelay;if(k){var I=p?Math.min(p,f.maxLoadingDelay):f.maxLoadingDelay;m=I-k,w.logger.trace("bitrate test took "+Math.round(1e3*k)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*m)+" ms"),v=T=1}}return a=this.findBestLevel(r,u,o,t+m,v,T),Math.max(a,0)},b.findBestLevel=function(h,e,s,o,f,u){for(var l,p=this.fragCurrent,c=this.partCurrent,i=this.lastLoadedFragLevel,r=this.hls.levels,t=r[i],a=!!(t!=null&&(l=t.details)!==null&&l!==void 0&&l.live),m=t==null?void 0:t.codecSet,v=c?c.duration:p?p.duration:0,T=s;T>=e;T--){var k=r[T];if(!k||m&&k.codecSet!==m)continue;var I=k.details,F=(c?I==null?void 0:I.partTarget:I==null?void 0:I.averagetargetduration)||v,K=void 0;T<=i?K=f*h:K=u*h;var V=r[T].maxBitrate,Q=V*F/K;if(w.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+T+"/"+Math.round(K)+"/"+V+"/"+F+"/"+o+"/"+Q),K>V&&(!Q||a&&!this.bitrateTestDelay||Q<o))return T}return-1},x(E,[{key:"nextAutoLevel",get:function(){var h=this._nextAutoLevel,e=this.bwEstimator;if(h!==-1&&(!e||!e.canEstimate()))return h;var s=this.getNextABRAutoLevel();return h!==-1&&(s=Math.min(h,s)),s},set:function(h){this._nextAutoLevel=h}}]),E}();U.default=S},"./src/controller/audio-stream-controller.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/polyfills/number.ts"),O=C("./src/controller/base-stream-controller.ts"),L=C("./src/events.ts"),_=C("./src/utils/buffer-helper.ts"),M=C("./src/controller/fragment-tracker.ts"),A=C("./src/types/level.ts"),w=C("./src/types/loader.ts"),g=C("./src/loader/fragment.ts"),x=C("./src/demux/chunk-cache.ts"),S=C("./src/demux/transmuxer-interface.ts"),E=C("./src/types/transmuxer.ts"),b=C("./src/controller/fragment-finders.ts"),y=C("./src/utils/discontinuities.ts"),h=C("./src/errors.ts"),e=C("./src/utils/logger.ts");function s(){return s=Object.assign||function(p){for(var c=1;c<arguments.length;c++){var i=arguments[c];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(p[r]=i[r])}return p},s.apply(this,arguments)}function o(p,c){p.prototype=Object.create(c.prototype),p.prototype.constructor=p,f(p,c)}function f(p,c){return f=Object.setPrototypeOf||function(r,t){return r.__proto__=t,r},f(p,c)}var u=100,l=function(p){o(c,p);function c(r,t){var a;return a=p.call(this,r,t,"[audio-stream-controller]")||this,a.videoBuffer=null,a.videoTrackCC=-1,a.waitingVideoCC=-1,a.audioSwitch=!1,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.bufferFlushed=!1,a._registerListeners(),a}var i=c.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var t=this.hls;t.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(L.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(L.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(L.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(L.Events.ERROR,this.onError,this),t.on(L.Events.BUFFER_RESET,this.onBufferReset,this),t.on(L.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(L.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(L.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var t=this.hls;t.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(L.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(L.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(L.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(L.Events.ERROR,this.onError,this),t.off(L.Events.BUFFER_RESET,this.onBufferReset,this),t.off(L.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(L.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(L.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i.onInitPtsFound=function(t,a){var m=a.frag,v=a.id,T=a.initPTS;if(v==="main"){var k=m.cc;this.initPTS[m.cc]=T,this.log("InitPTS for cc: "+k+" found from main: "+T),this.videoTrackCC=k,this.state===O.State.WAITING_INIT_PTS&&this.tick()}},i.startLoad=function(t){if(!this.levels){this.startPosition=t,this.state=O.State.STOPPED;return}var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(u),this.fragLoadError=0,a>0&&t===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),this.state=O.State.IDLE):(this.loadedmetadata=!1,this.state=O.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},i.doTick=function(){switch(this.state){case O.State.IDLE:this.doTickIdle();break;case O.State.WAITING_TRACK:{var t,a=this.levels,m=this.trackId,v=a==null||((t=a[m])===null||t===void 0)?void 0:t.details;if(v){if(this.waitForCdnTuneIn(v))break;this.state=O.State.WAITING_INIT_PTS}break}case O.State.FRAG_LOADING_WAITING_RETRY:{var T,k=performance.now(),I=this.retryDate;(!I||k>=I||(T=this.media)!==null&&T!==void 0&&T.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=O.State.IDLE);break}case O.State.WAITING_INIT_PTS:{var F=this.waitingData;if(F){var K=F.frag,V=F.part,Q=F.cache,Z=F.complete;if(this.initPTS[K.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=O.State.FRAG_LOADING;var ie=Q.flush(),ge={frag:K,part:V,payload:ie,networkDetails:null};this._handleFragmentLoadProgress(ge),Z&&p.prototype._handleFragmentLoadComplete.call(this,ge)}else if(this.videoTrackCC!==this.waitingVideoCC)e.logger.log("Waiting fragment cc ("+K.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var se=this.getLoadPosition(),he=_.BufferHelper.bufferInfo(this.mediaBuffer,se,this.config.maxBufferHole),de=Object(b.fragmentWithinToleranceTest)(he.end,this.config.maxFragLookUpTolerance,K);de<0&&(e.logger.log("Waiting fragment cc ("+K.cc+") @ "+K.start+" cancelled because another fragment at "+he.end+" is needed"),this.clearWaitingFragment())}}else this.state=O.State.IDLE}}this.onTickEnd()},i.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=O.State.IDLE)},i.onTickEnd=function(){var t=this.media;if(!t||!t.readyState)return;var a=this.mediaBuffer?this.mediaBuffer:t,m=a.buffered;!this.loadedmetadata&&m.length&&(this.loadedmetadata=!0),this.lastCurrentTime=t.currentTime},i.doTickIdle=function(){var t,a,m=this.hls,v=this.levels,T=this.media,k=this.trackId,I=m.config;if(!v||!v[k])return;if(!T&&(this.startFragRequested||!I.startFragPrefetch))return;var F=v[k],K=F.details;if(!K||K.live&&this.levelLastLoaded!==k||this.waitForCdnTuneIn(K)){this.state=O.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,g.ElementaryStreamTypes.AUDIO,w.PlaylistLevelType.AUDIO));var V=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,w.PlaylistLevelType.AUDIO);if(V===null)return;var Q=V.len,Z=this.getMaxBufferLength(),ie=this.audioSwitch;if(Q>=Z&&!ie)return;if(!ie&&this._streamEnded(V,K)){m.trigger(L.Events.BUFFER_EOS,{type:"audio"}),this.state=O.State.ENDED;return}var ge=K.fragments,se=ge[0].start,he=V.end;if(ie){var de=this.getLoadPosition();he=de,K.PTSKnown&&de<se&&((V.end>se||V.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),T.currentTime=se+.05))}var $=this.getNextFragment(he,K);if(!$){this.bufferFlushed=!0;return}((t=$.decryptdata)===null||t===void 0?void 0:t.keyFormat)==="identity"&&!((a=$.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey($,K):this.loadFragment($,K,he)},i.getMaxBufferLength=function(){var t=p.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,w.PlaylistLevelType.MAIN);return a===null?t:Math.max(t,a.len)},i.onMediaDetaching=function(){this.videoBuffer=null,p.prototype.onMediaDetaching.call(this)},i.onAudioTracksUpdated=function(t,a){var m=a.audioTracks;this.resetTransmuxer(),this.levels=m.map(function(v){return new A.Level(v)})},i.onAudioTrackSwitching=function(t,a){var m=!!a.url;this.trackId=a.id;var v=this.fragCurrent;v!=null&&v.loader&&v.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),m?this.setInterval(u):this.resetTransmuxer(),m?(this.audioSwitch=!0,this.state=O.State.IDLE):this.state=O.State.STOPPED,this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},i.onLevelLoaded=function(t,a){this.mainDetails=a.details},i.onAudioTrackLoaded=function(t,a){var m,v=this.levels,T=a.details,k=a.id;if(!v){this.warn("Audio tracks were reset while loading level "+k);return}this.log("Track "+k+" loaded ["+T.startSN+","+T.endSN+"],duration:"+T.totalduration);var I=v[k],F=0;if(T.live||(m=I.details)!==null&&m!==void 0&&m.live){var K=this.mainDetails;if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed||!K)return;!I.details&&T.hasProgramDateTime&&K.hasProgramDateTime?(Object(y.alignMediaPlaylistByPDT)(T,K),F=T.fragments[0].start):F=this.alignPlaylists(T,I.details)}I.details=T,this.levelLastLoaded=k,!this.startFragRequested&&(this.mainDetails||!T.live)&&this.setStartPosition(I.details,F),this.state===O.State.WAITING_TRACK&&!this.waitForCdnTuneIn(T)&&(this.state=O.State.IDLE),this.tick()},i._handleFragmentLoadProgress=function(t){var a,m=t.frag,v=t.part,T=t.payload,k=this.config,I=this.trackId,F=this.levels;if(!F){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+m.sn+" of level "+m.level+" will not be buffered");return}var K=F[I];console.assert(K,"Audio track is defined on fragment load progress");var V=K.details;console.assert(V,"Audio track details are defined on fragment load progress");var Q=k.defaultAudioCodec||K.audioCodec||"mp4a.40.2",Z=this.transmuxer;Z||(Z=this.transmuxer=new S.default(this.hls,w.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var ie=this.initPTS[m.cc],ge=(a=m.initSegment)===null||a===void 0?void 0:a.data;if(ie!==void 0){var se=!1,he=v?v.index:-1,de=he!==-1,$=new E.ChunkMetadata(m.level,m.sn,m.stats.chunkCount,T.byteLength,he,de);Z.push(T,ge,Q,"",m,v,V.totalduration,se,$,ie)}else{e.logger.log("Unknown video PTS for cc "+m.cc+", waiting for video PTS before demuxing audio frag "+m.sn+" of ["+V.startSN+" ,"+V.endSN+"],track "+I);var Y=this.waitingData=this.waitingData||{frag:m,part:v,cache:new x.default,complete:!1},ne=Y.cache;ne.push(new Uint8Array(T)),this.waitingVideoCC=this.videoTrackCC,this.state=O.State.WAITING_INIT_PTS}},i._handleFragmentLoadComplete=function(t){if(this.waitingData){this.waitingData.complete=!0;return}p.prototype._handleFragmentLoadComplete.call(this,t)},i.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},i.onBufferCreated=function(t,a){var m=a.tracks.audio;m&&(this.mediaBuffer=m.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},i.onFragBuffered=function(t,a){var m=a.frag,v=a.part;if(m.type!==w.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(m)){this.warn("Fragment "+m.sn+(v?" p: "+v.index:"")+" of level "+m.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}m.sn!=="initSegment"&&(this.fragPrevious=m,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(L.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(m,v)},i.onError=function(t,a){switch(a.details){case h.ErrorDetails.FRAG_LOAD_ERROR:case h.ErrorDetails.FRAG_LOAD_TIMEOUT:case h.ErrorDetails.KEY_LOAD_ERROR:case h.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(w.PlaylistLevelType.AUDIO,a);break;case h.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case h.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==O.State.ERROR&&this.state!==O.State.STOPPED&&(this.state=a.fatal?O.State.ERROR:O.State.IDLE,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case h.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===O.State.PARSING||this.state===O.State.PARSED)){var m=!0,v=this.getFwdBufferInfo(this.mediaBuffer,w.PlaylistLevelType.AUDIO);v&&v.len>.5&&(m=!this.reduceMaxBufferLength(v.len)),m&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,p.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},i.onBufferFlushed=function(t,a){var m=a.type;m===g.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},i._handleTransmuxComplete=function(t){var a,m="audio",v=this.hls,T=t.remuxResult,k=t.chunkMeta,I=this.getCurrentContext(k);if(!I){this.warn("The loading context changed while buffering fragment "+k.sn+" of level "+k.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(k.level);return}var F=I.frag,K=I.part,V=T.audio,Q=T.text,Z=T.id3,ie=T.initSegment;if(this.fragContextChanged(F))return;if(this.state=O.State.PARSING,this.audioSwitch&&V&&this.completeAudioSwitch(),ie!=null&&ie.tracks&&(this._bufferInitSegment(ie.tracks,F,k),v.trigger(L.Events.FRAG_PARSING_INIT_SEGMENT,{frag:F,id:m,tracks:ie.tracks})),V){var ge=V.startPTS,se=V.endPTS,he=V.startDTS,de=V.endDTS;K&&(K.elementaryStreams[g.ElementaryStreamTypes.AUDIO]={startPTS:ge,endPTS:se,startDTS:he,endDTS:de}),F.setElementaryStreamInfo(g.ElementaryStreamTypes.AUDIO,ge,se,he,de),this.bufferFragmentData(V,F,K,k)}if(Z!=null&&(a=Z.samples)!==null&&a!==void 0&&a.length){var $=s({frag:F,id:m},Z);v.trigger(L.Events.FRAG_PARSING_METADATA,$)}if(Q){var Y=s({frag:F,id:m},Q);v.trigger(L.Events.FRAG_PARSING_USERDATA,Y)}},i._bufferInitSegment=function(t,a,m){if(this.state!==O.State.PARSING)return;t.video&&delete t.video;var v=t.audio;if(!v)return;v.levelCodec=v.codec,v.id="audio",this.log("Init audio buffer, container:"+v.container+", codecs[parsed]=["+v.codec+"]"),this.hls.trigger(L.Events.BUFFER_CODECS,t);var T=v.initSegment;if(T!=null&&T.byteLength){var k={type:"audio",frag:a,part:null,chunkMeta:m,parent:a.type,data:T};this.hls.trigger(L.Events.BUFFER_APPENDING,k)}this.tick()},i.loadFragment=function(t,a,m){var v=this.fragmentTracker.getState(t);this.fragCurrent=t,(this.audioSwitch||v===M.FragmentState.NOT_LOADED||v===M.FragmentState.PARTIAL)&&(t.sn==="initSegment"?this._loadInitSegment(t):a.live&&!Object(B.isFiniteNumber)(this.initPTS[t.cc])?(this.log("Waiting for video PTS in continuity counter "+t.cc+" of live stream before loading audio fragment "+t.sn+" of level "+this.trackId),this.state=O.State.WAITING_INIT_PTS):(this.startFragRequested=!0,p.prototype.loadFragment.call(this,t,a,m)))},i.completeAudioSwitch=function(){var t=this.hls,a=this.media,m=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),p.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,t.trigger(L.Events.AUDIO_TRACK_SWITCHED,{id:m})},c}(O.default);U.default=l},"./src/controller/audio-track-controller.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/events.ts"),O=C("./src/errors.ts"),L=C("./src/controller/base-playlist-controller.ts"),_=C("./src/types/loader.ts");function M(S,E){for(var b=0;b<E.length;b++){var y=E[b];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(S,y.key,y)}}function A(S,E,b){return E&&M(S.prototype,E),b&&M(S,b),S}function w(S,E){S.prototype=Object.create(E.prototype),S.prototype.constructor=S,g(S,E)}function g(S,E){return g=Object.setPrototypeOf||function(y,h){return y.__proto__=h,y},g(S,E)}var x=function(S){w(E,S);function E(y){var h;return h=S.call(this,y,"[audio-track-controller]")||this,h.tracks=[],h.groupId=null,h.tracksInGroup=[],h.trackId=-1,h.trackName="",h.selectDefaultTrack=!0,h.registerListeners(),h}var b=E.prototype;return b.registerListeners=function(){var h=this.hls;h.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),h.on(B.Events.LEVEL_LOADING,this.onLevelLoading,this),h.on(B.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),h.on(B.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.on(B.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){var h=this.hls;h.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),h.off(B.Events.LEVEL_LOADING,this.onLevelLoading,this),h.off(B.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),h.off(B.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.off(B.Events.ERROR,this.onError,this)},b.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,S.prototype.destroy.call(this)},b.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},b.onManifestParsed=function(h,e){this.tracks=e.audioTracks||[]},b.onAudioTrackLoaded=function(h,e){var s=e.id,o=e.details,f=this.tracksInGroup[s];if(!f){this.warn("Invalid audio track id "+s);return}var u=f.details;f.details=e.details,this.log("audioTrack "+s+" loaded ["+o.startSN+"-"+o.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,e,u))},b.onLevelLoading=function(h,e){this.switchLevel(e.level)},b.onLevelSwitching=function(h,e){this.switchLevel(e.level)},b.switchLevel=function(h){var e=this.hls.levels[h];if(!(e!=null&&e.audioGroupIds))return;var s=e.audioGroupIds[e.urlId];if(this.groupId!==s){this.groupId=s;var o=this.tracks.filter(function(u){return!s||u.groupId===s});this.selectDefaultTrack&&!o.some(function(u){return u.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=o;var f={audioTracks:o};this.log("Updating audio tracks, "+o.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(B.Events.AUDIO_TRACKS_UPDATED,f),this.selectInitialTrack()}},b.onError=function(h,e){if(S.prototype.onError.call(this,h,e),e.fatal||!e.context)return;e.context.type===_.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},b.setAudioTrack=function(h){var e=this.tracksInGroup;if(h<0||h>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var s=e[this.trackId];this.log("Now switching to audio-track index "+h);var o=e[h],f=o.id,u=o.groupId,l=u===void 0?"":u,p=o.name,c=o.type,i=o.url;if(this.trackId=h,this.trackName=p,this.selectDefaultTrack=!1,this.hls.trigger(B.Events.AUDIO_TRACK_SWITCHING,{id:f,groupId:l,name:p,type:c,url:i}),o.details&&!o.details.live)return;var r=this.switchParams(o.url,s==null?void 0:s.details);this.loadPlaylist(r)},b.selectInitialTrack=function(){var h=this.tracksInGroup;console.assert(h.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,s=this.findTrackId(e)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},b.findTrackId=function(h){for(var e=this.tracksInGroup,s=0;s<e.length;s++){var o=e[s];if((!this.selectDefaultTrack||o.default)&&(!h||h===o.name))return o.id}return-1},b.loadPlaylist=function(h){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var s=e.id,o=e.groupId,f=e.url;if(h)try{f=h.addDirectives(f)}catch(u){this.warn("Could not construct new URL with HLS Delivery Directives: "+u)}this.log("loading audio-track playlist for id: "+s),this.clearTimer(),this.hls.trigger(B.Events.AUDIO_TRACK_LOADING,{url:f,id:s,groupId:o,deliveryDirectives:h||null})}},A(E,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(h){this.selectDefaultTrack=!1,this.setAudioTrack(h)}}]),E}(L.default);U.default=x},"./src/controller/base-playlist-controller.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return A});var B=C("./src/polyfills/number.ts"),O=C("./src/types/level.ts"),L=C("./src/controller/level-helper.ts"),_=C("./src/utils/logger.ts"),M=C("./src/errors.ts"),A=function(){function w(x,S){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=_.logger.log.bind(_.logger,S+":"),this.warn=_.logger.warn.bind(_.logger,S+":"),this.hls=x}var g=w.prototype;return g.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},g.onError=function(S,E){E.fatal&&E.type===M.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},g.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},g.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},g.stopLoad=function(){this.canLoad=!1,this.clearTimer()},g.switchParams=function(S,E){var b=E==null?void 0:E.renditionReports;if(b)for(var y=0;y<b.length;y++){var h=b[y],e=""+h.URI;if(e===S.substr(-e.length)){var s=parseInt(h["LAST-MSN"]),o=parseInt(h["LAST-PART"]);if(E&&this.hls.config.lowLatencyMode){var f=Math.min(E.age-E.partTarget,E.targetduration);o!==void 0&&f>E.partTarget&&(o+=1)}if(Object(B.isFiniteNumber)(s))return new O.HlsUrlParameters(s,Object(B.isFiniteNumber)(o)?o:void 0,O.HlsSkip.No)}}},g.loadPlaylist=function(S){},g.shouldLoadTrack=function(S){return this.canLoad&&S&&!!S.url&&(!S.details||S.details.live)},g.playlistLoaded=function(S,E,b){var y=this,h=E.details,e=E.stats,s=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(h.advancedDateTime=Date.now()-s,h.live||b!=null&&b.live){if(h.reloaded(b),b&&this.log("live playlist "+S+" "+(h.advanced?"REFRESHED "+h.lastPartSn+"-"+h.lastPartIndex:"MISSED")),b&&h.fragments.length>0&&Object(L.mergeDetails)(b,h),!this.canLoad||!h.live)return;var o,f=void 0,u=void 0;if(h.canBlockReload&&h.endSN&&h.advanced){var l=this.hls.config.lowLatencyMode,p=h.lastPartSn,c=h.endSN,i=h.lastPartIndex,r=i!==-1,t=p===c,a=l?0:i;r?(f=t?c+1:p,u=t?a:i+1):f=c+1;var m=h.age,v=m+h.ageHeader,T=Math.min(v-h.partTarget,h.targetduration*1.5);if(T>0){if(b&&T>b.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+b.tuneInGoal+" to: "+T+" with playlist age: "+h.age),T=0;else{var k=Math.floor(T/h.targetduration);if(f+=k,u!==void 0){var I=Math.round(T%h.targetduration/h.partTarget);u+=I}this.log("CDN Tune-in age: "+h.ageHeader+"s last advanced "+m.toFixed(2)+"s goal: "+T+" skip sn "+k+" to part "+u)}h.tuneInGoal=T}if(o=this.getDeliveryDirectives(h,E.deliveryDirectives,f,u),l||!t){this.loadPlaylist(o);return}}else o=this.getDeliveryDirectives(h,E.deliveryDirectives,f,u);var F=Object(L.computeReloadInterval)(h,e);f!==void 0&&h.canBlockReload&&(F-=h.partTarget||1),this.log("reload live playlist "+S+" in "+Math.round(F)+" ms"),this.timer=self.setTimeout(function(){return y.loadPlaylist(o)},F)}else this.clearTimer()},g.getDeliveryDirectives=function(S,E,b,y){var h=Object(O.getSkipValue)(S,b);return E!=null&&E.skip&&S.deltaUpdateFailed&&(b=E.msn,y=E.part,h=O.HlsSkip.No),new O.HlsUrlParameters(b,y,h)},g.retryLoadingOrFail=function(S){var E=this,b=this.hls.config,y=this.retryCount<b.levelLoadingMaxRetry;if(y){var h;if(this.retryCount++,S.details.indexOf("LoadTimeOut")>-1&&(h=S.context)!==null&&h!==void 0&&h.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+S.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*b.levelLoadingRetryDelay,b.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return E.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+S.details+'"')}}else this.warn('cannot recover from error "'+S.details+'"'),this.clearTimer(),S.fatal=!0;return y},w}()},"./src/controller/base-stream-controller.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"State",function(){return c}),C.d(U,"default",function(){return i});var B=C("./src/polyfills/number.ts"),O=C("./src/task-loop.ts"),L=C("./src/controller/fragment-tracker.ts"),_=C("./src/utils/buffer-helper.ts"),M=C("./src/utils/logger.ts"),A=C("./src/events.ts"),w=C("./src/errors.ts"),g=C("./src/types/transmuxer.ts"),x=C("./src/utils/mp4-tools.ts"),S=C("./src/utils/discontinuities.ts"),E=C("./src/controller/fragment-finders.ts"),b=C("./src/controller/level-helper.ts"),y=C("./src/loader/fragment-loader.ts"),h=C("./src/crypt/decrypter.ts"),e=C("./src/utils/time-ranges.ts"),s=C("./src/types/loader.ts");function o(r,t){for(var a=0;a<t.length;a++){var m=t[a];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(r,m.key,m)}}function f(r,t,a){return t&&o(r.prototype,t),a&&o(r,a),r}function u(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function l(r,t){r.prototype=Object.create(t.prototype),r.prototype.constructor=r,p(r,t)}function p(r,t){return p=Object.setPrototypeOf||function(m,v){return m.__proto__=v,m},p(r,t)}var c={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"},i=function(r){l(t,r);function t(m,v,T){var k;return k=r.call(this)||this,k.hls=void 0,k.fragPrevious=null,k.fragCurrent=null,k.fragmentTracker=void 0,k.transmuxer=null,k._state=c.STOPPED,k.media=void 0,k.mediaBuffer=void 0,k.config=void 0,k.bitrateTest=!1,k.lastCurrentTime=0,k.nextLoadPosition=0,k.startPosition=0,k.loadedmetadata=!1,k.fragLoadError=0,k.retryDate=0,k.levels=null,k.fragmentLoader=void 0,k.levelLastLoaded=null,k.startFragRequested=!1,k.decrypter=void 0,k.initPTS=[],k.onvseeking=null,k.onvended=null,k.logPrefix="",k.log=void 0,k.warn=void 0,k.logPrefix=T,k.log=M.logger.log.bind(M.logger,T+":"),k.warn=M.logger.warn.bind(M.logger,T+":"),k.hls=m,k.fragmentLoader=new y.default(m.config),k.fragmentTracker=v,k.config=m.config,k.decrypter=new h.default(m,m.config),m.on(A.Events.KEY_LOADED,k.onKeyLoaded,u(k)),k}var a=t.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(v){},a.stopLoad=function(){this.fragmentLoader.abort();var v=this.fragCurrent;v&&this.fragmentTracker.removeFragment(v),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=c.STOPPED},a._streamEnded=function(v,T){var k=this.fragCurrent,I=this.fragmentTracker;if(!T.live&&k&&k.sn===T.endSN&&!v.nextStart){var F=I.getState(k);return F===L.FragmentState.PARTIAL||F===L.FragmentState.OK}return!1},a.onMediaAttached=function(v,T){var k=this.media=this.mediaBuffer=T.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),k.addEventListener("seeking",this.onvseeking),k.addEventListener("ended",this.onvended);var I=this.config;this.levels&&I.autoStartLoad&&this.state===c.STOPPED&&this.startLoad(I.startPosition)},a.onMediaDetaching=function(){var v=this.media;v!=null&&v.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),v&&(v.removeEventListener("seeking",this.onvseeking),v.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var v=this.config,T=this.fragCurrent,k=this.media,I=this.mediaBuffer,F=this.state,K=k?k.currentTime:0,V=_.BufferHelper.bufferInfo(I||k,K,v.maxBufferHole);if(this.log("media seeking to "+(Object(B.isFiniteNumber)(K)?K.toFixed(3):K)+", state: "+F),F===c.ENDED)this.resetLoadingState();else if(T&&!V.len){var Q=v.maxFragLookUpTolerance,Z=T.start-Q,ie=T.start+T.duration+Q,ge=K>ie;(K<Z||ge)&&(ge&&T.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),T.loader.abort()),this.resetLoadingState())}k&&(this.lastCurrentTime=K),!this.loadedmetadata&&!V.len&&(this.nextLoadPosition=this.startPosition=K),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(v,T){if(this.state!==c.KEY_LOADING||T.frag!==this.fragCurrent||!this.levels)return;this.state=c.IDLE;var k=this.levels[T.frag.level].details;k&&this.loadFragment(T.frag,k,T.frag.start)},a.onHandlerDestroying=function(){this.stopLoad(),r.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=c.STOPPED,this.hls.off(A.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,r.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(v,T){this.log("Loading key for "+v.sn+" of ["+T.startSN+"-"+T.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level),this.state=c.KEY_LOADING,this.fragCurrent=v,this.hls.trigger(A.Events.KEY_LOADING,{frag:v})},a.loadFragment=function(v,T,k){this._loadFragForPlayback(v,T,k)},a._loadFragForPlayback=function(v,T,k){var I=this,F=function(V){if(I.fragContextChanged(v)){I.warn("Fragment "+v.sn+(V.part?" p: "+V.part.index:"")+" of level "+v.level+" was dropped during download."),I.fragmentTracker.removeFragment(v);return}v.stats.chunkCount++,I._handleFragmentLoadProgress(V)};this._doFragLoad(v,T,k,F).then(function(K){if(!K)return;I.fragLoadError=0;var V=I.state;if(I.fragContextChanged(v)){(V===c.FRAG_LOADING||V===c.BACKTRACKING||!I.fragCurrent&&V===c.PARSING)&&(I.fragmentTracker.removeFragment(v),I.state=c.IDLE);return}if("payload"in K&&(I.log("Loaded fragment "+v.sn+" of level "+v.level),I.hls.trigger(A.Events.FRAG_LOADED,K),I.state===c.BACKTRACKING)){I.fragmentTracker.backtrack(v,K),I.resetFragmentLoading(v);return}I._handleFragmentLoadComplete(K)}).catch(function(K){I.warn(K),I.resetFragmentLoading(v)})},a.flushMainBuffer=function(v,T,k){if(k===void 0&&(k=null),!(v-T))return;var I={startOffset:v,endOffset:T,type:k};this.fragLoadError=0,this.hls.trigger(A.Events.BUFFER_FLUSHING,I)},a._loadInitSegment=function(v){var T=this;this._doFragLoad(v).then(function(k){if(!k||T.fragContextChanged(v)||!T.levels)throw new Error("init load aborted");return k}).then(function(k){var I=T.hls,F=k.payload,K=v.decryptdata;if(F&&F.byteLength>0&&K&&K.key&&K.iv&&K.method==="AES-128"){var V=self.performance.now();return T.decrypter.webCryptoDecrypt(new Uint8Array(F),K.key.buffer,K.iv.buffer).then(function(Q){var Z=self.performance.now();return I.trigger(A.Events.FRAG_DECRYPTED,{frag:v,payload:Q,stats:{tstart:V,tdecrypt:Z}}),k.payload=Q,k})}return k}).then(function(k){var I=T.fragCurrent,F=T.hls,K=T.levels;if(!K)throw new Error("init load aborted, missing levels");var V=K[v.level].details;console.assert(V,"Level details are defined when init segment is loaded");var Q=v.stats;T.state=c.IDLE,T.fragLoadError=0,v.data=new Uint8Array(k.payload),Q.parsing.start=Q.buffering.start=self.performance.now(),Q.parsing.end=Q.buffering.end=self.performance.now(),k.frag===I&&F.trigger(A.Events.FRAG_BUFFERED,{stats:Q,frag:I,part:null,id:v.type}),T.tick()}).catch(function(k){T.warn(k),T.resetFragmentLoading(v)})},a.fragContextChanged=function(v){var T=this.fragCurrent;return!v||!T||v.level!==T.level||v.sn!==T.sn||v.urlId!==T.urlId},a.fragBufferedComplete=function(v,T){var k=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+v.type+" sn: "+v.sn+(T?" part: "+T.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level+" "+e.default.toString(_.BufferHelper.getBuffered(k))),this.state=c.IDLE,this.tick()},a._handleFragmentLoadComplete=function(v){var T=this.transmuxer;if(!T)return;var k=v.frag,I=v.part,F=v.partsLoaded,K=!F||F.length===0||F.some(function(Q){return!Q}),V=new g.ChunkMetadata(k.level,k.sn,k.stats.chunkCount+1,0,I?I.index:-1,!K);T.flush(V)},a._handleFragmentLoadProgress=function(v){},a._doFragLoad=function(v,T,k,I){var F=this;if(k===void 0&&(k=null),!this.levels)throw new Error("frag load aborted, missing levels");if(k=Math.max(v.start,k||0),this.config.lowLatencyMode&&T){var K=T.partList;if(K&&I){k>v.end&&T.fragmentHint&&(v=T.fragmentHint);var V=this.getNextPart(K,v,k);if(V>-1){var Q=K[V];return this.log("Loading part sn: "+v.sn+" p: "+Q.index+" cc: "+v.cc+" of playlist ["+T.startSN+"-"+T.endSN+"] parts [0-"+V+"-"+(K.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(k.toFixed(3))),this.nextLoadPosition=Q.start+Q.duration,this.state=c.FRAG_LOADING,this.hls.trigger(A.Events.FRAG_LOADING,{frag:v,part:K[V],targetBufferTime:k}),this.doFragPartsLoad(v,K,V,I).catch(function(Z){return F.handleFragLoadError(Z)})}else if(!v.url||this.loadedEndOfParts(K,k))return Promise.resolve(null)}}return this.log("Loading fragment "+v.sn+" cc: "+v.cc+" "+(T?"of ["+T.startSN+"-"+T.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(k.toFixed(3))),Object(B.isFiniteNumber)(v.sn)&&!this.bitrateTest&&(this.nextLoadPosition=v.start+v.duration),this.state=c.FRAG_LOADING,this.hls.trigger(A.Events.FRAG_LOADING,{frag:v,targetBufferTime:k}),this.fragmentLoader.load(v,I).catch(function(Z){return F.handleFragLoadError(Z)})},a.doFragPartsLoad=function(v,T,k,I){var F=this;return new Promise(function(K,V){var Q=[],Z=function ie(ge){var se=T[ge];F.fragmentLoader.loadPart(v,se,I).then(function(he){Q[se.index]=he;var de=he.part;F.hls.trigger(A.Events.FRAG_LOADED,he);var $=T[ge+1];if($&&$.fragment===v)ie(ge+1);else return K({frag:v,part:de,partsLoaded:Q})}).catch(V)};Z(k)})},a.handleFragLoadError=function(v){var T=v.data;return T&&T.details===w.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(T.frag,T.part):this.hls.trigger(A.Events.ERROR,T),null},a._handleTransmuxerFlush=function(v){var T=this.getCurrentContext(v);if(!T||this.state!==c.PARSING){this.fragCurrent||(this.state=c.IDLE);return}var k=T.frag,I=T.part,F=T.level,K=self.performance.now();k.stats.parsing.end=K,I&&(I.stats.parsing.end=K),this.updateLevelTiming(k,I,F,v.partial)},a.getCurrentContext=function(v){var T=this.levels,k=v.level,I=v.sn,F=v.part;if(!T||!T[k])return this.warn("Levels object was unset while buffering fragment "+I+" of level "+k+". The current chunk will not be buffered."),null;var K=T[k],V=F>-1?Object(b.getPartWith)(K,I,F):null,Q=V?V.fragment:Object(b.getFragmentWithSN)(K,I,this.fragCurrent);return Q?{frag:Q,part:V,level:K}:null},a.bufferFragmentData=function(v,T,k,I){if(!v||this.state!==c.PARSING)return;var F=v.data1,K=v.data2,V=F;if(F&&K&&(V=Object(x.appendUint8Array)(F,K)),!V||!V.length)return;var Q={type:v.type,frag:T,part:k,chunkMeta:I,parent:T.type,data:V};this.hls.trigger(A.Events.BUFFER_APPENDING,Q),v.dropped&&v.independent&&!k&&this.flushBufferGap(T)},a.flushBufferGap=function(v){var T=this.media;if(!T)return;if(!_.BufferHelper.isBuffered(T,T.currentTime)){this.flushMainBuffer(0,v.start);return}var k=T.currentTime,I=_.BufferHelper.bufferInfo(T,k,0),F=v.duration,K=Math.min(this.config.maxFragLookUpTolerance*2,F*.25),V=Math.max(Math.min(v.start-K,I.end-K),k+K);v.start-V>K&&this.flushMainBuffer(V,v.start)},a.getFwdBufferInfo=function(v,T){var k=this.config,I=this.getLoadPosition();if(!Object(B.isFiniteNumber)(I))return null;var F=_.BufferHelper.bufferInfo(v,I,k.maxBufferHole);if(F.len===0&&F.nextStart!==void 0){var K=this.fragmentTracker.getBufferedFrag(I,T);if(K&&F.nextStart<K.end)return _.BufferHelper.bufferInfo(v,I,Math.max(F.nextStart,k.maxBufferHole))}return F},a.getMaxBufferLength=function(v){var T=this.config,k;return v?k=Math.max(8*T.maxBufferSize/v,T.maxBufferLength):k=T.maxBufferLength,Math.min(k,T.maxMaxBufferLength)},a.reduceMaxBufferLength=function(v){var T=this.config,k=v||T.maxBufferLength;return T.maxMaxBufferLength>=k?(T.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+T.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(v,T){var k,I,F=T.fragments,K=F.length;if(!K)return null;var V=this.config,Q=F[0].start,Z;if(T.live){var ie=V.initialLiveManifestSize;if(K<ie)return this.warn("Not enough fragments to start playback (have: "+K+", need: "+ie+")"),null;!T.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(Z=this.getInitialLiveFragment(T,F),this.startPosition=Z?this.hls.liveSyncPosition||Z.start:v)}else v<=Q&&(Z=F[0]);if(!Z){var ge=V.lowLatencyMode?T.partEnd:T.fragmentEnd;Z=this.getFragmentAtPosition(v,ge,T)}return(k=Z)!==null&&k!==void 0&&k.initSegment&&!((I=Z)!==null&&I!==void 0&&I.initSegment.data)&&!this.bitrateTest&&(Z=Z.initSegment),Z},a.getNextPart=function(v,T,k){for(var I=-1,F=!1,K=!0,V=0,Q=v.length;V<Q;V++){var Z=v[V];if(K=K&&!Z.independent,I>-1&&k<Z.start)break;var ie=Z.loaded;!ie&&(F||Z.independent||K)&&Z.fragment===T&&(I=V),F=ie}return I},a.loadedEndOfParts=function(v,T){var k=v[v.length-1];return k&&T>k.start&&k.loaded},a.getInitialLiveFragment=function(v,T){var k=this.fragPrevious,I=null;if(k){if(v.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+k.programDateTime),I=Object(E.findFragmentByPDT)(T,k.endProgramDateTime,this.config.maxFragLookUpTolerance)),!I){var F=k.sn+1;if(F>=v.startSN&&F<=v.endSN){var K=T[F-v.startSN];k.cc===K.cc&&(I=K,this.log("Live playlist, switching playlist, load frag with next SN: "+I.sn))}I||(I=Object(E.findFragWithCC)(T,k.cc),I&&this.log("Live playlist, switching playlist, load frag with same CC: "+I.sn))}}else{var V=this.hls.liveSyncPosition;V!==null&&(I=this.getFragmentAtPosition(V,this.bitrateTest?v.fragmentEnd:v.edge,v))}return I},a.getFragmentAtPosition=function(v,T,k){var I=this.config,F=this.fragPrevious,K=k.fragments,V=k.endSN,Q=k.fragmentHint,Z=I.maxFragLookUpTolerance,ie=!!(I.lowLatencyMode&&k.partList&&Q);ie&&Q&&!this.bitrateTest&&(K=K.concat(Q),V=Q.sn);var ge;if(v<T){var se=v>T-Z?0:Z;ge=Object(E.findFragmentByPTS)(F,K,v,se)}else ge=K[K.length-1];if(ge){var he=ge.sn-k.startSN,de=F&&ge.level===F.level,$=K[he+1],Y=this.fragmentTracker.getState(ge);if(Y===L.FragmentState.BACKTRACKED){ge=null;for(var ne=he;K[ne]&&this.fragmentTracker.getState(K[ne])===L.FragmentState.BACKTRACKED;)F?ge=K[ne--]:ge=K[--ne];ge||(ge=$)}else F&&ge.sn===F.sn&&!ie&&(de&&(ge.sn<V&&this.fragmentTracker.getState($)!==L.FragmentState.OK?(this.log("SN "+ge.sn+" just loaded, load next one: "+$.sn),ge=$):ge=null))}return ge},a.synchronizeToLiveEdge=function(v){var T=this.config,k=this.media;if(!k)return;var I=this.hls.liveSyncPosition,F=k.currentTime,K=v.fragments[0].start,V=v.edge,Q=F>=K-T.maxFragLookUpTolerance&&F<=V;if(I!==null&&k.duration>I&&(F<I||!Q)){var Z=T.liveMaxLatencyDuration!==void 0?T.liveMaxLatencyDuration:T.liveMaxLatencyDurationCount*v.targetduration;(!Q&&k.readyState<4||F<V-Z)&&(this.loadedmetadata||(this.nextLoadPosition=I),k.readyState&&(this.warn("Playback: "+F.toFixed(3)+" is located too far from the end of live sliding playlist: "+V+", reset currentTime to : "+I.toFixed(3)),k.currentTime=I))}},a.alignPlaylists=function(v,T){var k=this.levels,I=this.levelLastLoaded,F=this.fragPrevious,K=I!==null?k[I]:null,V=v.fragments.length;if(!V)return this.warn("No fragments in live playlist"),0;var Q=v.fragments[0].start,Z=!T,ie=v.alignedSliding&&Object(B.isFiniteNumber)(Q);if(Z||!ie&&!Q){Object(S.alignStream)(F,K,v);var ge=v.fragments[0].start;return this.log("Live playlist sliding: "+ge.toFixed(2)+" start-sn: "+(T?T.startSN:"na")+"->"+v.startSN+" prev-sn: "+(F?F.sn:"na")+" fragments: "+V),ge}return Q},a.waitForCdnTuneIn=function(v){var T=3;return v.live&&v.canBlockReload&&v.tuneInGoal>Math.max(v.partHoldBack,v.partTarget*T)},a.setStartPosition=function(v,T){var k=this.startPosition;if(k<T&&(k=-1),k===-1||this.lastCurrentTime===-1){var I=v.startTimeOffset;Object(B.isFiniteNumber)(I)?(k=T+I,I<0&&(k+=v.totalduration),k=Math.min(Math.max(T,k),T+v.totalduration),this.log("Start time offset "+I+" found in playlist, adjust startPosition to "+k),this.startPosition=k):v.live?k=this.hls.liveSyncPosition||T:this.startPosition=k=0,this.lastCurrentTime=k}this.nextLoadPosition=k},a.getLoadPosition=function(){var v=this.media,T=0;return this.loadedmetadata&&v?T=v.currentTime:this.nextLoadPosition&&(T=this.nextLoadPosition),T},a.handleFragLoadAborted=function(v,T){this.transmuxer&&v.sn!=="initSegment"&&v.stats.aborted&&(this.warn("Fragment "+v.sn+(T?" part"+T.index:"")+" of level "+v.level+" was aborted"),this.resetFragmentLoading(v))},a.resetFragmentLoading=function(v){(!this.fragCurrent||!this.fragContextChanged(v))&&(this.state=c.IDLE)},a.onFragmentOrKeyLoadError=function(v,T){if(T.fatal)return;var k=T.frag;if(!k||k.type!==v)return;var I=this.fragCurrent;console.assert(I&&k.sn===I.sn&&k.level===I.level&&k.urlId===I.urlId,"Frag load error must match current frag to retry");var F=this.config;if(this.fragLoadError+1<=F.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(k.level))return;var K=Math.min(Math.pow(2,this.fragLoadError)*F.fragLoadingRetryDelay,F.fragLoadingMaxRetryTimeout);this.warn("Fragment "+k.sn+" of "+v+" "+k.level+" failed to load, retrying in "+K+"ms"),this.retryDate=self.performance.now()+K,this.fragLoadError++,this.state=c.FRAG_LOADING_WAITING_RETRY}else T.levelRetry?(v===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=c.IDLE):(M.logger.error(T.details+" reaches max retry, redispatch as fatal ..."),T.fatal=!0,this.hls.stopLoad(),this.state=c.ERROR)},a.afterBufferFlushed=function(v,T,k){if(!v)return;var I=_.BufferHelper.getBuffered(v);this.fragmentTracker.detectEvictedFragments(T,I,k),this.state===c.ENDED&&this.resetLoadingState()},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=c.IDLE},a.resetLiveStartWhenNotLoaded=function(v){if(!this.loadedmetadata){this.startFragRequested=!1;var T=this.levels?this.levels[v].details:null;if(T!=null&&T.live)return this.startPosition=-1,this.setStartPosition(T,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},a.updateLevelTiming=function(v,T,k,I){var F=this,K=k.details;console.assert(!!K,"level.details must be defined");var V=Object.keys(v.elementaryStreams).reduce(function(Q,Z){var ie=v.elementaryStreams[Z];if(ie){var ge=ie.endPTS-ie.startPTS;if(ge<=0)return F.warn("Could not parse fragment "+v.sn+" "+Z+" duration reliably ("+ge+") resetting transmuxer to fallback to playlist timing"),F.resetTransmuxer(),Q||!1;var se=I?0:Object(b.updateFragPTSDTS)(K,v,ie.startPTS,ie.endPTS,ie.startDTS,ie.endDTS);return F.hls.trigger(A.Events.LEVEL_PTS_UPDATED,{details:K,level:k,drift:se,type:Z,frag:v,start:ie.startPTS,end:ie.endPTS}),!0}return Q},!1);V?(this.state=c.PARSED,this.hls.trigger(A.Events.FRAG_PARSED,{frag:v,part:T})):this.resetLoadingState()},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},f(t,[{key:"state",get:function(){return this._state},set:function(v){var T=this._state;T!==v&&(this._state=v,this.log(T+"->"+v))}}]),t}(O.default)},"./src/controller/buffer-controller.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return E});var B=C("./src/polyfills/number.ts"),O=C("./src/events.ts"),L=C("./src/utils/logger.ts"),_=C("./src/errors.ts"),M=C("./src/utils/buffer-helper.ts"),A=C("./src/utils/mediasource-helper.ts"),w=C("./src/loader/fragment.ts"),g=C("./src/controller/buffer-operation-queue.ts"),x=Object(A.getMediaSource)(),S=/([ha]vc.)(?:\.[^.,]+)+/,E=function(){function b(h){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 s=e.hls,o=e.media,f=e.mediaSource;L.logger.log("[buffer-controller]: Media source opened"),o&&(e.updateMediaElementDuration(),s.trigger(O.Events.MEDIA_ATTACHED,{media:o})),f&&f.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){L.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){L.logger.log("[buffer-controller]: Media source ended")},this.hls=h,this._initSourceBuffer(),this.registerListeners()}var y=b.prototype;return y.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},y.destroy=function(){this.unregisterListeners(),this.details=null},y.registerListeners=function(){var e=this.hls;e.on(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(O.Events.BUFFER_RESET,this.onBufferReset,this),e.on(O.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(O.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(O.Events.BUFFER_EOS,this.onBufferEos,this),e.on(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(O.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(O.Events.FRAG_PARSED,this.onFragParsed,this),e.on(O.Events.FRAG_CHANGED,this.onFragChanged,this)},y.unregisterListeners=function(){var e=this.hls;e.off(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(O.Events.BUFFER_RESET,this.onBufferReset,this),e.off(O.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(O.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(O.Events.BUFFER_EOS,this.onBufferEos,this),e.off(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(O.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(O.Events.FRAG_PARSED,this.onFragParsed,this),e.off(O.Events.FRAG_CHANGED,this.onFragChanged,this)},y._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new g.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},y.onManifestParsed=function(e,s){var o=2;(s.audio&&!s.video||!s.altAudio)&&(o=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=o,this.details=null,L.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},y.onMediaAttaching=function(e,s){var o=this.media=s.media;if(o&&x){var f=this.mediaSource=new x;f.addEventListener("sourceopen",this._onMediaSourceOpen),f.addEventListener("sourceended",this._onMediaSourceEnded),f.addEventListener("sourceclose",this._onMediaSourceClose),o.src=self.URL.createObjectURL(f),this._objectUrl=o.src}},y.onMediaDetaching=function(){var e=this.media,s=this.mediaSource,o=this._objectUrl;if(s){if(L.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(f){L.logger.warn("[buffer-controller]: onMediaDetaching: "+f.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(o&&self.URL.revokeObjectURL(o),e.src===o?(e.removeAttribute("src"),e.load()):L.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(O.Events.MEDIA_DETACHED,void 0)},y.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(s){var o=e.sourceBuffer[s];try{o&&(e.removeBufferListeners(s),e.mediaSource&&e.mediaSource.removeSourceBuffer(o),e.sourceBuffer[s]=void 0)}catch(f){L.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",f)}}),this._initSourceBuffer()},y.onBufferCodecs=function(e,s){var o=this,f=this.getSourceBufferTypes().length;if(Object.keys(s).forEach(function(u){if(f){var l=o.tracks[u];if(l&&typeof l.buffer.changeType=="function"){var p=s[u],c=p.codec,i=p.levelCodec,r=p.container,t=(l.levelCodec||l.codec).replace(S,"$1"),a=(i||c).replace(S,"$1");if(t!==a){var m=r+";codecs="+(i||c);o.appendChangeType(u,m)}}}else o.pendingTracks[u]=s[u]}),f)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},y.appendChangeType=function(e,s){var o=this,f=this.operationQueue,u={execute:function(){var p=o.sourceBuffer[e];p&&(L.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+s),p.changeType(s)),f.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(p){L.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",p)}};f.append(u,e)},y.onBufferAppending=function(e,s){var o=this,f=this.hls,u=this.operationQueue,l=this.tracks,p=s.data,c=s.type,i=s.frag,r=s.part,t=s.chunkMeta,a=t.buffering[c],m=self.performance.now();a.start=m;var v=i.stats.buffering,T=r?r.stats.buffering:null;v.start===0&&(v.start=m),T&&T.start===0&&(T.start=m);var k=l.audio,I=c==="audio"&&t.id===1&&(k==null?void 0:k.container)==="audio/mpeg",F={execute:function(){if(a.executeStart=self.performance.now(),I){var V=o.sourceBuffer[c];if(V){var Q=i.start-V.timestampOffset;Math.abs(Q)>=.1&&(L.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+i.start+" (delta: "+Q+") sn: "+i.sn+")"),V.timestampOffset=i.start)}}o.appendExecutor(p,c)},onStart:function(){},onComplete:function(){var V=self.performance.now();a.executeEnd=a.end=V,v.first===0&&(v.first=V),T&&T.first===0&&(T.first=V);var Q=o.sourceBuffer,Z={};for(var ie in Q)Z[ie]=M.BufferHelper.getBuffered(Q[ie]);o.appendError=0,o.hls.trigger(O.Events.BUFFER_APPENDED,{type:c,frag:i,part:r,chunkMeta:t,parent:i.type,timeRanges:Z})},onError:function(V){L.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",V);var Q={type:_.ErrorTypes.MEDIA_ERROR,parent:i.type,details:_.ErrorDetails.BUFFER_APPEND_ERROR,err:V,fatal:!1};V.code===DOMException.QUOTA_EXCEEDED_ERR?Q.details=_.ErrorDetails.BUFFER_FULL_ERROR:(o.appendError++,Q.details=_.ErrorDetails.BUFFER_APPEND_ERROR,o.appendError>f.config.appendErrorMaxRetry&&(L.logger.error("[buffer-controller]: Failed "+f.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),Q.fatal=!0)),f.trigger(O.Events.ERROR,Q)}};u.append(F,c)},y.onBufferFlushing=function(e,s){var o=this,f=this.operationQueue,u=function(p){return{execute:o.removeExecutor.bind(o,p,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){o.hls.trigger(O.Events.BUFFER_FLUSHED,{type:p})},onError:function(i){L.logger.warn("[buffer-controller]: Failed to remove from "+p+" SourceBuffer",i)}}};s.type?f.append(u(s.type),s.type):this.getSourceBufferTypes().forEach(function(l){f.append(u(l),l)})},y.onFragParsed=function(e,s){var o=this,f=s.frag,u=s.part,l=[],p=u?u.elementaryStreams:f.elementaryStreams;p[w.ElementaryStreamTypes.AUDIOVIDEO]?l.push("audiovideo"):(p[w.ElementaryStreamTypes.AUDIO]&&l.push("audio"),p[w.ElementaryStreamTypes.VIDEO]&&l.push("video"));var c=function(){var r=self.performance.now();f.stats.buffering.end=r,u&&(u.stats.buffering.end=r);var t=u?u.stats:f.stats;o.hls.trigger(O.Events.FRAG_BUFFERED,{frag:f,part:u,stats:t,id:f.type})};l.length===0&&L.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+f.type+" level: "+f.level+" sn: "+f.sn),this.blockBuffers(c,l)},y.onFragChanged=function(e,s){this.flushBackBuffer()},y.onBufferEos=function(e,s){var o=this,f=this.getSourceBufferTypes().reduce(function(u,l){var p=o.sourceBuffer[l];return(!s.type||s.type===l)&&(p&&!p.ended&&(p.ended=!0,L.logger.log("[buffer-controller]: "+l+" sourceBuffer now EOS"))),u&&!!(!p||p.ended)},!0);f&&this.blockBuffers(function(){var u=o.mediaSource;if(!u||u.readyState!=="open")return;u.endOfStream()})},y.onLevelUpdated=function(e,s){var o=s.details;if(!o.fragments.length)return;this.details=o,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},y.flushBackBuffer=function(){var e=this.hls,s=this.details,o=this.media,f=this.sourceBuffer;if(!o||s===null)return;var u=this.getSourceBufferTypes();if(!u.length)return;var l=s.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!Object(B.isFiniteNumber)(l)||l<0)return;var p=o.currentTime,c=s.levelTargetDuration,i=Math.max(l,c),r=Math.floor(p/c)*c-i;u.forEach(function(t){var a=f[t];if(a){var m=M.BufferHelper.getBuffered(a);m.length>0&&r>m.start(0)&&(e.trigger(O.Events.BACK_BUFFER_REACHED,{bufferEnd:r}),s.live&&e.trigger(O.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r}),e.trigger(O.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:t}))}})},y.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var e=this.details,s=this.hls,o=this.media,f=this.mediaSource,u=e.fragments[0].start+e.totalduration,l=o.duration,p=Object(B.isFiniteNumber)(f.duration)?f.duration:0;e.live&&s.config.liveDurationInfinity?(L.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),f.duration=Infinity,this.updateSeekableRange(e)):(u>p&&u>l||!Object(B.isFiniteNumber)(l))&&(L.logger.log("[buffer-controller]: Updating Media Source duration to "+u.toFixed(3)),f.duration=u)},y.updateSeekableRange=function(e){var s=this.mediaSource,o=e.fragments,f=o.length;if(f&&e.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var u=Math.max(0,o[0].start),l=Math.max(u,u+e.totalduration);s.setLiveSeekableRange(u,l)}},y.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,s=this.operationQueue,o=this.pendingTracks,f=Object.keys(o).length;if(f&&!e||f===2){this.createSourceBuffers(o),this.pendingTracks={};var u=this.getSourceBufferTypes();if(u.length===0){this.hls.trigger(O.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}u.forEach(function(l){s.executeNext(l)})}},y.createSourceBuffers=function(e){var s=this.sourceBuffer,o=this.mediaSource;if(!o)throw Error("createSourceBuffers called when mediaSource was null");var f=0;for(var u in e)if(!s[u]){var l=e[u];if(!l)throw Error("source buffer exists for track "+u+", however track does not");var p=l.levelCodec||l.codec,c=l.container+";codecs="+p;L.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var i=s[u]=o.addSourceBuffer(c),r=u;this.addBufferListener(r,"updatestart",this._onSBUpdateStart),this.addBufferListener(r,"updateend",this._onSBUpdateEnd),this.addBufferListener(r,"error",this._onSBUpdateError),this.tracks[u]={buffer:i,codec:p,container:l.container,levelCodec:l.levelCodec,id:l.id},f++}catch(t){L.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(O.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:c})}}f&&this.hls.trigger(O.Events.BUFFER_CREATED,{tracks:this.tracks})},y._onSBUpdateStart=function(e){var s=this.operationQueue,o=s.current(e);o.onStart()},y._onSBUpdateEnd=function(e){var s=this.operationQueue,o=s.current(e);o.onComplete(),s.shiftAndExecuteNext(e)},y._onSBUpdateError=function(e,s){L.logger.error("[buffer-controller]: "+e+" SourceBuffer error",s),this.hls.trigger(O.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var o=this.operationQueue.current(e);o&&o.onError(s)},y.removeExecutor=function(e,s,o){var f=this.media,u=this.mediaSource,l=this.operationQueue,p=this.sourceBuffer,c=p[e];if(!f||!u||!c){L.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),l.shiftAndExecuteNext(e);return}var i=Object(B.isFiniteNumber)(f.duration)?f.duration:Infinity,r=Object(B.isFiniteNumber)(u.duration)?u.duration:Infinity,t=Math.max(0,s),a=Math.min(o,i,r);a>t?(L.logger.log("[buffer-controller]: Removing ["+t+","+a+"] from the "+e+" SourceBuffer"),console.assert(!c.updating,e+" sourceBuffer must not be updating"),c.remove(t,a)):l.shiftAndExecuteNext(e)},y.appendExecutor=function(e,s){var o=this.operationQueue,f=this.sourceBuffer,u=f[s];if(!u){L.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),o.shiftAndExecuteNext(s);return}u.ended=!1,console.assert(!u.updating,s+" sourceBuffer must not be updating"),u.appendBuffer(e)},y.blockBuffers=function(e,s){var o=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){L.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(e);return}var f=this.operationQueue,u=s.map(function(l){return f.appendBlocker(l)});Promise.all(u).then(function(){e(),s.forEach(function(l){var p=o.sourceBuffer[l];(!p||!p.updating)&&f.shiftAndExecuteNext(l)})})},y.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},y.addBufferListener=function(e,s,o){var f=this.sourceBuffer[e];if(!f)return;var u=o.bind(this,e);this.listeners[e].push({event:s,listener:u}),f.addEventListener(s,u)},y.removeBufferListeners=function(e){var s=this.sourceBuffer[e];if(!s)return;this.listeners[e].forEach(function(o){s.removeEventListener(o.event,o.listener)})},b}()},"./src/controller/buffer-operation-queue.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return O});var B=C("./src/utils/logger.ts"),O=function(){function L(M){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=M}var _=L.prototype;return _.append=function(A,w){var g=this.queues[w];g.push(A),g.length===1&&this.buffers[w]&&this.executeNext(w)},_.insertAbort=function(A,w){var g=this.queues[w];g.unshift(A),this.executeNext(w)},_.appendBlocker=function(A){var w,g=new Promise(function(S){w=S}),x={execute:w,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(x,A),g},_.executeNext=function(A){var w=this.buffers,g=this.queues,x=w[A],S=g[A];if(S.length){var E=S[0];try{E.execute()}catch(b){B.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),E.onError(b),(!x||!x.updating)&&(S.shift(),this.executeNext(A))}}},_.shiftAndExecuteNext=function(A){this.queues[A].shift(),this.executeNext(A)},_.current=function(A){return this.queues[A][0]},L}()},"./src/controller/cap-level-controller.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/events.ts");function O(M,A){for(var w=0;w<A.length;w++){var g=A[w];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(M,g.key,g)}}function L(M,A,w){return A&&O(M.prototype,A),w&&O(M,w),M}var _=function(){function M(w){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=w,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var A=M.prototype;return A.setStreamController=function(g){this.streamController=g},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 g=this.hls;g.on(B.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),g.on(B.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.on(B.Events.BUFFER_CODECS,this.onBufferCodecs,this),g.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},A.unregisterListener=function(){var g=this.hls;g.off(B.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),g.off(B.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.off(B.Events.BUFFER_CODECS,this.onBufferCodecs,this),g.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},A.onFpsDropLevelCapping=function(g,x){M.isLevelAllowed(x.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(x.droppedLevel)},A.onMediaAttaching=function(g,x){this.media=x.media instanceof HTMLVideoElement?x.media:null},A.onManifestParsed=function(g,x){var S=this.hls;this.restrictedLevels=[],this.firstLevel=x.firstLevel,S.config.capLevelToPlayerSize&&x.video&&this.startCapping()},A.onBufferCodecs=function(g,x){var S=this.hls;S.config.capLevelToPlayerSize&&x.video&&this.startCapping()},A.onMediaDetaching=function(){this.stopCapping()},A.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var g=this.hls.levels;if(g.length){var x=this.hls;x.autoLevelCapping=this.getMaxLevel(g.length-1),x.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=x.autoLevelCapping}}},A.getMaxLevel=function(g){var x=this,S=this.hls.levels;if(!S.length)return-1;var E=S.filter(function(b,y){return M.isLevelAllowed(y,x.restrictedLevels)&&y<=g});return this.clientRect=null,M.getMaxLevelByMediaSize(E,this.mediaWidth,this.mediaHeight)},A.startCapping=function(){if(this.timer)return;this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize()},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 g=this.media,x={width:0,height:0};if(g){var S=g.getBoundingClientRect();x.width=S.width,x.height=S.height,!x.width&&!x.height&&(x.width=S.right-S.left||g.width||0,x.height=S.bottom-S.top||g.height||0)}return this.clientRect=x,x},M.isLevelAllowed=function(g,x){return x===void 0&&(x=[]),x.indexOf(g)===-1},M.getMaxLevelByMediaSize=function(g,x,S){if(!g||!g.length)return-1;for(var E=function(s,o){return o?s.width!==o.width||s.height!==o.height:!0},b=g.length-1,y=0;y<g.length;y+=1){var h=g[y];if((h.width>=x||h.height>=S)&&E(h,g[y+1])){b=y;break}}return b},L(M,[{key:"mediaWidth",get:function(){return this.getDimensions().width*M.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*M.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var g=1;try{g=self.devicePixelRatio}catch(x){}return g}}]),M}();U.default=_},"./src/controller/cmcd-controller.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return E});var B=C("./src/events.ts"),O=C("./src/types/cmcd.ts"),L=C("./src/utils/buffer-helper.ts"),_=C("./src/utils/logger.ts");function M(b,y){for(var h=0;h<y.length;h++){var e=y[h];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(b,e.key,e)}}function A(b,y,h){return y&&M(b.prototype,y),h&&M(b,h),b}function w(b,y){var h=typeof Symbol!="undefined"&&b[Symbol.iterator]||b["@@iterator"];if(h)return(h=h.call(b)).next.bind(h);if(Array.isArray(b)||(h=g(b))||y&&b&&typeof b.length=="number"){h&&(b=h);var e=0;return function(){return e>=b.length?{done:!0}:{done:!1,value:b[e++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function g(b,y){if(!b)return;if(typeof b=="string")return x(b,y);var h=Object.prototype.toString.call(b).slice(8,-1);if(h==="Object"&&b.constructor&&(h=b.constructor.name),h==="Map"||h==="Set")return Array.from(b);if(h==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(h))return x(b,y)}function x(b,y){(y==null||y>b.length)&&(y=b.length);for(var h=0,e=new Array(y);h<y;h++)e[h]=b[h];return e}function S(){return S=Object.assign||function(b){for(var y=1;y<arguments.length;y++){var h=arguments[y];for(var e in h)Object.prototype.hasOwnProperty.call(h,e)&&(b[e]=h[e])}return b},S.apply(this,arguments)}var E=function(){function b(h){var e=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(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(f){try{e.apply(f,{ot:O.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(u){_.logger.warn("Could not generate manifest CMCD data.",u)}},this.applyFragmentData=function(f){try{var u=f.frag,l=e.hls.levels[u.level],p=e.getObjectType(u),c={d:u.duration*1e3,ot:p};(p===O.CMCDObjectType.VIDEO||p===O.CMCDObjectType.AUDIO||p==O.CMCDObjectType.MUXED)&&(c.br=l.bitrate/1e3,c.tb=e.getTopBandwidth(p),c.bl=e.getBufferLength(p)),e.apply(f,c)}catch(i){_.logger.warn("Could not generate segment CMCD data.",i)}},this.hls=h;var s=this.config=h.config,o=s.cmcd;o!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=o.sessionId||b.uuid(),this.cid=o.contentId,this.useHeaders=o.useHeaders===!0,this.registerListeners())}var y=b.prototype;return y.registerListeners=function(){var e=this.hls;e.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(B.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(B.Events.BUFFER_CREATED,this.onBufferCreated,this)},y.unregisterListeners=function(){var e=this.hls;e.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(B.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(B.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},y.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},y.onMediaAttached=function(e,s){this.media=s.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},y.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},y.onBufferCreated=function(e,s){var o,f;this.audioBuffer=(o=s.tracks.audio)===null||o===void 0?void 0:o.buffer,this.videoBuffer=(f=s.tracks.video)===null||f===void 0?void 0:f.buffer},y.createData=function(){var e;return{v:O.CMCDVersion,sf:O.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},y.apply=function(e,s){s===void 0&&(s={}),S(s,this.createData());var o=s.ot===O.CMCDObjectType.INIT||s.ot===O.CMCDObjectType.VIDEO||s.ot===O.CMCDObjectType.MUXED;if(this.starved&&o&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var f=b.toHeaders(s);if(!Object.keys(f).length)return;e.headers||(e.headers={}),S(e.headers,f)}else{var u=b.toQuery(s);if(!u)return;e.url=b.appendQueryToUri(e.url,u)}},y.getObjectType=function(e){var s=e.type;return s==="subtitle"?O.CMCDObjectType.TIMED_TEXT:e.sn==="initSegment"?O.CMCDObjectType.INIT:s==="audio"?O.CMCDObjectType.AUDIO:s==="main"?this.hls.audioTracks.length?O.CMCDObjectType.VIDEO:O.CMCDObjectType.MUXED:void 0},y.getTopBandwidth=function(e){for(var s=0,o=e===O.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,f=w(o),u;!(u=f()).done;){var l=u.value;l.bitrate>s&&(s=l.bitrate)}return s>0?s:NaN},y.getBufferLength=function(e){var s=this.hls.media,o=e===O.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!o||!s)return NaN;var f=L.BufferHelper.bufferInfo(o,s.currentTime,this.config.maxBufferHole);return f.len*1e3},y.createPlaylistLoader=function(){var e=this.config.pLoader,s=this.applyPlaylistData,o=e||this.config.loader;return function(){function f(l){this.loader=void 0,this.loader=new o(l)}var u=f.prototype;return u.destroy=function(){this.loader.destroy()},u.abort=function(){this.loader.abort()},u.load=function(p,c,i){s(p),this.loader.load(p,c,i)},A(f,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),f}()},y.createFragmentLoader=function(){var e=this.config.fLoader,s=this.applyFragmentData,o=e||this.config.loader;return function(){function f(l){this.loader=void 0,this.loader=new o(l)}var u=f.prototype;return u.destroy=function(){this.loader.destroy()},u.abort=function(){this.loader.abort()},u.load=function(p,c,i){s(p),this.loader.load(p,c,i)},A(f,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),f}()},b.uuid=function(){var e=URL.createObjectURL(new Blob),s=e.toString();return URL.revokeObjectURL(e),s.substr(s.lastIndexOf("/")+1)},b.serialize=function(e){for(var s=[],o=function(I){return!Number.isNaN(I)&&I!=null&&I!==""&&I!==!1},f=function(I){return Math.round(I)},u=function(I){return f(I/100)*100},l=function(I){return encodeURIComponent(I)},p={br:f,d:f,bl:u,dl:u,mtp:u,nor:l,rtp:u,tb:f},c=Object.keys(e||{}).sort(),i=w(c),r;!(r=i()).done;){var t=r.value,a=e[t];if(!o(a))continue;if(t==="v"&&a===1)continue;if(t=="pr"&&a===1)continue;var m=p[t];m&&(a=m(a));var v=typeof a,T=void 0;t==="ot"||t==="sf"||t==="st"?T=t+"="+a:v==="boolean"?T=t:v==="number"?T=t+"="+a:T=t+"="+JSON.stringify(a),s.push(T)}return s.join(",")},b.toHeaders=function(e){for(var s=Object.keys(e),o={},f=["Object","Request","Session","Status"],u=[{},{},{},{}],l={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},p=0,c=s;p<c.length;p++){var i=c[p],r=l[i]!=null?l[i]:1;u[r][i]=e[i]}for(var t=0;t<u.length;t++){var a=b.serialize(u[t]);a&&(o["CMCD-"+f[t]]=a)}return o},b.toQuery=function(e){return"CMCD="+encodeURIComponent(b.serialize(e))},b.appendQueryToUri=function(e,s){if(!s)return e;var o=e.includes("?")?"&":"?";return""+e+o+s},b}()},"./src/controller/eme-controller.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/events.ts"),O=C("./src/errors.ts"),L=C("./src/utils/logger.ts"),_=C("./src/utils/mediakeys-helper.ts");function M(E,b){for(var y=0;y<b.length;y++){var h=b[y];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(E,h.key,h)}}function A(E,b,y){return b&&M(E.prototype,b),y&&M(E,y),E}var w=3,g=function(b,y,h){var e={audioCapabilities:[],videoCapabilities:[]};return b.forEach(function(s){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+s+'"',robustness:h.audioRobustness||""})}),y.forEach(function(s){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+s+'"',robustness:h.videoRobustness||""})}),[e]},x=function(b,y,h,e){switch(b){case _.KeySystems.WIDEVINE:return g(y,h,e);default:throw new Error("Unknown key-system: "+b)}},S=function(){function E(y){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=y,this._config=y.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 b=E.prototype;return b.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},b._registerListeners=function(){this.hls.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(B.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this)},b._unregisterListeners=function(){this.hls.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(B.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this)},b.getLicenseServerUrl=function(h){switch(h){case _.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+h+'"')},b._attemptKeySystemAccess=function(h,e,s){var o=this,f=x(h,e,s,this._drmSystemOptions);L.logger.log("Requesting encrypted media key-system access");var u=this.requestMediaKeySystemAccess(h,f);this.mediaKeysPromise=u.then(function(l){return o._onMediaKeySystemAccessObtained(h,l)}),u.catch(function(l){L.logger.error('Failed to obtain key-system "'+h+'" access:',l)})},b._onMediaKeySystemAccessObtained=function(h,e){var s=this;L.logger.log('Access for key-system "'+h+'" obtained');var o={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:h};this._mediaKeysList.push(o);var f=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(u){return o.mediaKeys=u,L.logger.log('Media-keys created for key-system "'+h+'"'),s._onMediaKeysCreated(),u});return f.catch(function(u){L.logger.error("Failed to create media-keys:",u)}),f},b._onMediaKeysCreated=function(){var h=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),h._onNewMediaKeySession(e.mediaKeysSession))})},b._onNewMediaKeySession=function(h){var e=this;L.logger.log("New key-system session "+h.sessionId),h.addEventListener("message",function(s){e._onKeySessionMessage(h,s.message)},!1)},b._onKeySessionMessage=function(h,e){L.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(s){L.logger.log("Received license data (length: "+(s&&s.byteLength)+"), updating key-session"),h.update(s)})},b.onMediaEncrypted=function(h){var e=this;if(L.logger.log('Media is encrypted using "'+h.initDataType+'" init data type'),!this.mediaKeysPromise){L.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var s=function(f){if(!e._media)return;e._attemptSetMediaKeys(f),e._generateRequestWithPreferredKeySession(h.initDataType,h.initData)};this.mediaKeysPromise.then(s).catch(s)},b._attemptSetMediaKeys=function(h){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){L.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}L.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},b._generateRequestWithPreferredKeySession=function(h,e){var s=this,o=this._mediaKeysList[0];if(!o){L.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(o.mediaKeysSessionInitialized){L.logger.warn("Key-Session already initialized but requested again");return}var f=o.mediaKeysSession;if(!f){L.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){L.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}L.logger.log('Generating key-session request for "'+h+'" init data type'),o.mediaKeysSessionInitialized=!0,f.generateRequest(h,e).then(function(){L.logger.debug("Key-session generation succeeded")}).catch(function(u){L.logger.error("Error generating key-session request:",u),s.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},b._createLicenseXhr=function(h,e,s){var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,o,h,e,s);var f=this._licenseXhrSetup;if(f)try{f.call(this.hls,o,h),f=void 0}catch(u){L.logger.error(u)}try{o.readyState||o.open("POST",h,!0),f&&f.call(this.hls,o,h)}catch(u){throw new Error("issue setting up KeySystem license XHR "+u)}return o},b._onLicenseRequestReadyStageChange=function(h,e,s,o){switch(h.readyState){case 4:if(h.status===200){this._requestLicenseFailureCount=0,L.logger.log("License request succeeded");var f=h.response,u=this._licenseResponseCallback;if(u)try{f=u.call(this.hls,h,e)}catch(p){L.logger.error(p)}o(f)}else{if(L.logger.error("License Request XHR failed ("+e+"). Status: "+h.status+" ("+h.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>w){this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var l=w-this._requestLicenseFailureCount+1;L.logger.warn("Retrying license request, "+l+" attempts left"),this._requestLicense(s,o)}break}},b._generateLicenseRequestChallenge=function(h,e){switch(h.mediaKeySystemDomain){case _.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+h.mediaKeySystemDomain)},b._requestLicense=function(h,e){L.logger.log("Requesting content license for key-system");var s=this._mediaKeysList[0];if(!s){L.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var o=this.getLicenseServerUrl(s.mediaKeySystemDomain),f=this._createLicenseXhr(o,h,e);L.logger.log("Sending license request to URL: "+o);var u=this._generateLicenseRequestChallenge(s,h);f.send(u)}catch(l){L.logger.error("Failure requesting DRM license: "+l),this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},b.onMediaAttached=function(h,e){if(!this._emeEnabled)return;var s=e.media;this._media=s,s.addEventListener("encrypted",this._onMediaEncrypted)},b.onMediaDetached=function(){var h=this._media,e=this._mediaKeysList;if(!h)return;h.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(s){if(s.mediaKeysSession)return s.mediaKeysSession.close().catch(function(){})})).then(function(){return h.setMediaKeys(null)}).catch(function(){})},b.onManifestParsed=function(h,e){if(!this._emeEnabled)return;var s=e.levels.map(function(f){return f.audioCodec}).filter(function(f){return!!f}),o=e.levels.map(function(f){return f.videoCodec}).filter(function(f){return!!f});this._attemptKeySystemAccess(_.KeySystems.WIDEVINE,s,o)},A(E,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),E}();U.default=S},"./src/controller/fps-controller.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/events.ts"),O=C("./src/utils/logger.ts"),L=function(){function _(A){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=A,this.registerListeners()}var M=_.prototype;return M.setStreamController=function(w){this.streamController=w},M.registerListeners=function(){this.hls.on(B.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},M.unregisterListeners=function(){this.hls.off(B.Events.MEDIA_ATTACHING,this.onMediaAttaching)},M.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},M.onMediaAttaching=function(w,g){var x=this.hls.config;if(x.capLevelOnFPSDrop){var S=g.media instanceof self.HTMLVideoElement?g.media:null;this.media=S,S&&typeof S.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),x.fpsDroppedMonitoringPeriod)}},M.checkFPS=function(w,g,x){var S=performance.now();if(g){if(this.lastTime){var E=S-this.lastTime,b=x-this.lastDroppedFrames,y=g-this.lastDecodedFrames,h=1e3*b/E,e=this.hls;if(e.trigger(B.Events.FPS_DROP,{currentDropped:b,currentDecoded:y,totalDroppedFrames:x}),h>0&&b>e.config.fpsDroppedMonitoringThreshold*y){var s=e.currentLevel;O.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),s>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=s)&&(s=s-1,e.trigger(B.Events.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:e.currentLevel}),e.autoLevelCapping=s,this.streamController.nextLevelSwitch())}}this.lastTime=S,this.lastDroppedFrames=x,this.lastDecodedFrames=g}},M.checkFPSInterval=function(){var w=this.media;if(w)if(this.isVideoPlaybackQualityAvailable){var g=w.getVideoPlaybackQuality();this.checkFPS(w,g.totalVideoFrames,g.droppedVideoFrames)}else this.checkFPS(w,w.webkitDecodedFrameCount,w.webkitDroppedFrameCount)},_}();U.default=L},"./src/controller/fragment-finders.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"findFragmentByPDT",function(){return L}),C.d(U,"findFragmentByPTS",function(){return _}),C.d(U,"fragmentWithinToleranceTest",function(){return M}),C.d(U,"pdtWithinToleranceTest",function(){return A}),C.d(U,"findFragWithCC",function(){return w});var B=C("./src/polyfills/number.ts"),O=C("./src/utils/binary-search.ts");function L(g,x,S){if(x===null||!Array.isArray(g)||!g.length||!Object(B.isFiniteNumber)(x))return null;var E=g[0].programDateTime;if(x<(E||0))return null;var b=g[g.length-1].endProgramDateTime;if(x>=(b||0))return null;S=S||0;for(var y=0;y<g.length;++y){var h=g[y];if(A(x,S,h))return h}return null}function _(g,x,S,E){S===void 0&&(S=0),E===void 0&&(E=0);var b=null;if(g?b=x[g.sn-x[0].sn+1]||null:S===0&&x[0].start===0&&(b=x[0]),b&&M(S,E,b)===0)return b;var y=O.default.search(x,M.bind(null,S,E));return y||b}function M(g,x,S){g===void 0&&(g=0),x===void 0&&(x=0);var E=Math.min(x,S.duration+(S.deltaPTS?S.deltaPTS:0));return S.start+S.duration-E<=g?1:S.start-E>g&&S.start?-1:0}function A(g,x,S){var E=Math.min(x,S.duration+(S.deltaPTS?S.deltaPTS:0))*1e3,b=S.endProgramDateTime||0;return b-E>g}function w(g,x){return O.default.search(g,function(S){return S.cc<x?1:S.cc>x?-1:0})}},"./src/controller/fragment-tracker.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"FragmentState",function(){return L}),C.d(U,"FragmentTracker",function(){return _});var B=C("./src/events.ts"),O=C("./src/types/loader.ts"),L;(function(w){w.NOT_LOADED="NOT_LOADED",w.BACKTRACKED="BACKTRACKED",w.APPENDING="APPENDING",w.PARTIAL="PARTIAL",w.OK="OK"})(L||(L={}));var _=function(){function w(x){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=x,this._registerListeners()}var g=w.prototype;return g._registerListeners=function(){var S=this.hls;S.on(B.Events.BUFFER_APPENDED,this.onBufferAppended,this),S.on(B.Events.FRAG_BUFFERED,this.onFragBuffered,this),S.on(B.Events.FRAG_LOADED,this.onFragLoaded,this)},g._unregisterListeners=function(){var S=this.hls;S.off(B.Events.BUFFER_APPENDED,this.onBufferAppended,this),S.off(B.Events.FRAG_BUFFERED,this.onFragBuffered,this),S.off(B.Events.FRAG_LOADED,this.onFragLoaded,this)},g.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},g.getAppendedFrag=function(S,E){if(E===O.PlaylistLevelType.MAIN){var b=this.activeFragment,y=this.activeParts;if(!b)return null;if(y)for(var h=y.length;h--;){var e=y[h],s=e?e.end:b.appendedPTS;if(e.start<=S&&s!==void 0&&S<=s)return h>9&&(this.activeParts=y.slice(h-9)),e}else if(b.start<=S&&b.appendedPTS!==void 0&&S<=b.appendedPTS)return b}return this.getBufferedFrag(S,E)},g.getBufferedFrag=function(S,E){for(var b=this.fragments,y=Object.keys(b),h=y.length;h--;){var e=b[y[h]];if((e==null?void 0:e.body.type)===E&&e.buffered){var s=e.body;if(s.start<=S&&S<=s.end)return s}}return null},g.detectEvictedFragments=function(S,E,b){var y=this;Object.keys(this.fragments).forEach(function(h){var e=y.fragments[h];if(!e)return;if(!e.buffered){e.body.type===b&&y.removeFragment(e.body);return}var s=e.range[S];if(!s)return;s.time.some(function(o){var f=!y.isTimeBuffered(o.startPTS,o.endPTS,E);return f&&y.removeFragment(e.body),f})})},g.detectPartialFragments=function(S){var E=this,b=this.timeRanges,y=S.frag,h=S.part;if(!b||y.sn==="initSegment")return;var e=A(y),s=this.fragments[e];if(!s)return;Object.keys(b).forEach(function(o){var f=y.elementaryStreams[o];if(!f)return;var u=b[o],l=h!==null||f.partial===!0;s.range[o]=E.getBufferedTimes(y,h,l,u)}),s.backtrack=s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body)},g.fragBuffered=function(S){var E=A(S),b=this.fragments[E];b&&(b.backtrack=b.loaded=null,b.buffered=!0)},g.getBufferedTimes=function(S,E,b,y){for(var h={time:[],partial:b},e=E?E.start:S.start,s=E?E.end:S.end,o=S.minEndPTS||s,f=S.maxStartPTS||e,u=0;u<y.length;u++){var l=y.start(u)-this.bufferPadding,p=y.end(u)+this.bufferPadding;if(f>=l&&o<=p){h.time.push({startPTS:Math.max(e,y.start(u)),endPTS:Math.min(s,y.end(u))});break}else if(e<p&&s>l)h.partial=!0,h.time.push({startPTS:Math.max(e,y.start(u)),endPTS:Math.min(s,y.end(u))});else if(s<=l)break}return h},g.getPartialFragment=function(S){var E=null,b,y,h,e=0,s=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach(function(f){var u=o[f];if(!u)return;M(u)&&(y=u.body.start-s,h=u.body.end+s,S>=y&&S<=h&&(b=Math.min(S-y,h-S),e<=b&&(E=u.body,e=b)))}),E},g.getState=function(S){var E=A(S),b=this.fragments[E];return b?b.buffered?M(b)?L.PARTIAL:L.OK:b.backtrack?L.BACKTRACKED:L.APPENDING:L.NOT_LOADED},g.backtrack=function(S,E){var b=A(S),y=this.fragments[b];if(!y||y.backtrack)return null;var h=y.backtrack=E||y.loaded;return y.loaded=null,h},g.getBacktrackData=function(S){var E=A(S),b=this.fragments[E];if(b){var y,h=b.backtrack;if(h!=null&&(y=h.payload)!==null&&y!==void 0&&y.byteLength)return h;this.removeFragment(S)}return null},g.isTimeBuffered=function(S,E,b){for(var y,h,e=0;e<b.length;e++){if(y=b.start(e)-this.bufferPadding,h=b.end(e)+this.bufferPadding,S>=y&&E<=h)return!0;if(E<=y)return!1}return!1},g.onFragLoaded=function(S,E){var b=E.frag,y=E.part;if(b.sn==="initSegment"||b.bitrateTest||y)return;var h=A(b);this.fragments[h]={body:b,loaded:E,backtrack:null,buffered:!1,range:Object.create(null)}},g.onBufferAppended=function(S,E){var b=this,y=E.frag,h=E.part,e=E.timeRanges;if(y.type===O.PlaylistLevelType.MAIN)if(this.activeFragment=y,h){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(h)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(o){var f=e[o];if(b.detectEvictedFragments(o,f),!h)for(var u=0;u<f.length;u++)y.appendedPTS=Math.max(f.end(u),y.appendedPTS||0)})},g.onFragBuffered=function(S,E){this.detectPartialFragments(E)},g.hasFragment=function(S){var E=A(S);return!!this.fragments[E]},g.removeFragmentsInRange=function(S,E,b){var y=this;Object.keys(this.fragments).forEach(function(h){var e=y.fragments[h];if(!e)return;if(e.buffered){var s=e.body;s.type===b&&s.start<E&&s.end>S&&y.removeFragment(s)}})},g.removeFragment=function(S){var E=A(S);S.stats.loaded=0,S.clearElementaryStreamInfo(),delete this.fragments[E]},g.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},w}();function M(w){var g,x;return w.buffered&&(((g=w.range.video)===null||g===void 0?void 0:g.partial)||((x=w.range.audio)===null||x===void 0?void 0:x.partial))}function A(w){return w.type+"_"+w.level+"_"+w.urlId+"_"+w.sn}},"./src/controller/gap-controller.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"STALL_MINIMUM_DURATION_MS",function(){return M}),C.d(U,"MAX_START_GAP_JUMP",function(){return A}),C.d(U,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return w}),C.d(U,"SKIP_BUFFER_RANGE_START",function(){return g}),C.d(U,"default",function(){return x});var B=C("./src/utils/buffer-helper.ts"),O=C("./src/errors.ts"),L=C("./src/events.ts"),_=C("./src/utils/logger.ts"),M=250,A=2,w=.1,g=.05,x=function(){function S(b,y,h,e){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=b,this.media=y,this.fragmentTracker=h,this.hls=e}var E=S.prototype;return E.destroy=function(){this.hls=this.fragmentTracker=this.media=null},E.poll=function(y){var h=this.config,e=this.media,s=this.stalled,o=e.currentTime,f=e.seeking,u=this.seeking&&!f,l=!this.seeking&&f;if(this.seeking=f,o!==y){if(this.moved=!0,s!==null){if(this.stallReported){var p=self.performance.now()-s;_.logger.warn("playback not stuck anymore @"+o+", after "+Math.round(p)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((l||u)&&(this.stalled=null),e.paused||e.ended||e.playbackRate===0||!B.BufferHelper.getBuffered(e).length)return;var c=B.BufferHelper.bufferInfo(e,o,0),i=c.len>0,r=c.nextStart||0;if(!i&&!r)return;if(f){var t=c.len>A,a=!r||r-o>A&&!this.fragmentTracker.getPartialFragment(o);if(t||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var m,v=Math.max(r,c.start||0)-o,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,k=T==null||((m=T.details)===null||m===void 0)?void 0:m.live,I=k?T.details.targetduration*2:A;if(v>0&&v<=I){this._trySkipBufferHole(null);return}}var F=self.performance.now();if(s===null){this.stalled=F;return}var K=F-s;!f&&K>=M&&this._reportStall(c.len);var V=B.BufferHelper.bufferInfo(e,o,h.maxBufferHole);this._tryFixBufferStall(V,K)},E._tryFixBufferStall=function(y,h){var e=this.config,s=this.fragmentTracker,o=this.media,f=o.currentTime,u=s.getPartialFragment(f);if(u){var l=this._trySkipBufferHole(u);if(l)return}y.len>e.maxBufferHole&&h>e.highBufferWatchdogPeriod*1e3&&(_.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},E._reportStall=function(y){var h=this.hls,e=this.media,s=this.stallReported;s||(this.stallReported=!0,_.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer (buffer="+y+")"),h.trigger(L.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:y}))},E._trySkipBufferHole=function(y){for(var h=this.config,e=this.hls,s=this.media,o=s.currentTime,f=0,u=B.BufferHelper.getBuffered(s),l=0;l<u.length;l++){var p=u.start(l);if(o+h.maxBufferHole>=f&&o<p){var c=Math.max(p+g,s.currentTime+w);return _.logger.warn("skipping hole, adjusting currentTime from "+o+" to "+c),this.moved=!0,this.stalled=null,s.currentTime=c,y&&e.trigger(L.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+o+" to "+c,frag:y}),c}f=u.end(l)}return 0},E._tryNudgeBuffer=function(){var y=this.config,h=this.hls,e=this.media,s=e.currentTime,o=(this.nudgeRetry||0)+1;if(this.nudgeRetry=o,o<y.nudgeMaxRetry){var f=s+o*y.nudgeOffset;_.logger.warn("Nudging 'currentTime' from "+s+" to "+f),e.currentTime=f,h.trigger(L.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else _.logger.error("Playhead still not moving while enough data buffered @"+s+" after "+y.nudgeMaxRetry+" nudges"),h.trigger(L.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},S}()},"./src/controller/id3-track-controller.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/events.ts"),O=C("./src/utils/texttrack-utils.ts"),L=C("./src/demux/id3.ts"),_=.25,M=function(){function A(g){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=g,this._registerListeners()}var w=A.prototype;return w.destroy=function(){this._unregisterListeners()},w._registerListeners=function(){var x=this.hls;x.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),x.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),x.on(B.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),x.on(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},w._unregisterListeners=function(){var x=this.hls;x.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),x.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),x.off(B.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),x.off(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},w.onMediaAttached=function(x,S){this.media=S.media},w.onMediaDetaching=function(){if(!this.id3Track)return;Object(O.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},w.getID3Track=function(x){if(!this.media)return;for(var S=0;S<x.length;S++){var E=x[S];if(E.kind==="metadata"&&E.label==="id3")return Object(O.sendAddTrackEvent)(E,this.media),E}return this.media.addTextTrack("metadata","id3")},w.onFragParsingMetadata=function(x,S){if(!this.media)return;var E=S.frag,b=S.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var y=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,h=0;h<b.length;h++){var e=L.getID3Frames(b[h].data);if(e){var s=b[h].pts,o=h<b.length-1?b[h+1].pts:E.end,f=o-s;f<=0&&(o=s+_);for(var u=0;u<e.length;u++){var l=e[u];if(!L.isTimeStampFrame(l)){var p=new y(s,o,"");p.value=l,this.id3Track.addCue(p)}}}}},w.onBufferFlushing=function(x,S){var E=S.startOffset,b=S.endOffset,y=S.type;if(!y||y==="audio"){var h=this.id3Track;h&&Object(O.removeCuesInRange)(h,E,b)}},A}();U.default=M},"./src/controller/latency-controller.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return A});var B=C("./src/errors.ts"),O=C("./src/events.ts"),L=C("./src/utils/logger.ts");function _(w,g){for(var x=0;x<g.length;x++){var S=g[x];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(w,S.key,S)}}function M(w,g,x){return g&&_(w.prototype,g),x&&_(w,x),w}var A=function(){function w(x){var S=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 S.timeupdate()},this.hls=x,this.config=x.config,this.registerListeners()}var g=w.prototype;return g.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},g.registerListeners=function(){this.hls.on(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(O.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(O.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){this.hls.off(O.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(O.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(O.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(O.Events.ERROR,this.onError)},g.onMediaAttached=function(S,E){this.media=E.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},g.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},g.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},g.onLevelUpdated=function(S,E){var b=E.details;this.levelDetails=b,b.advanced&&this.timeupdate(),!b.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},g.onError=function(S,E){if(E.details!==B.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,L.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},g.timeupdate=function(){var S=this.media,E=this.levelDetails;if(!S||!E)return;this.currentTime=S.currentTime;var b=this.computeLatency();if(b===null)return;this._latency=b;var y=this.config,h=y.lowLatencyMode,e=y.maxLiveSyncPlaybackRate;if(!h||e===1)return;var s=this.targetLatency;if(s===null)return;var o=b-s,f=Math.min(this.maxLatency,s+E.targetduration),u=o<f;if(E.live&&u&&o>.05&&this.forwardBufferLength>1){var l=Math.min(2,Math.max(1,e)),p=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;S.playbackRate=Math.min(l,Math.max(1,p))}else S.playbackRate!==1&&S.playbackRate!==0&&(S.playbackRate=1)},g.estimateLiveEdge=function(){var S=this.levelDetails;return S===null?null:S.edge+S.age},g.computeLatency=function(){var S=this.estimateLiveEdge();return S===null?null:S-this.currentTime},M(w,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var S=this.config,E=this.levelDetails;return S.liveMaxLatencyDuration!==void 0?S.liveMaxLatencyDuration:E?S.liveMaxLatencyDurationCount*E.targetduration:0}},{key:"targetLatency",get:function(){var S=this.levelDetails;if(S===null)return null;var E=S.holdBack,b=S.partHoldBack,y=S.targetduration,h=this.config,e=h.liveSyncDuration,s=h.liveSyncDurationCount,o=h.lowLatencyMode,f=this.hls.userConfig,u=o&&b||E;(f.liveSyncDuration||f.liveSyncDurationCount||u===0)&&(u=e!==void 0?e:s*y);var l=y,p=1;return u+Math.min(this.stallCount*p,l)}},{key:"liveSyncPosition",get:function(){var S=this.estimateLiveEdge(),E=this.targetLatency,b=this.levelDetails;if(S===null||E===null||b===null)return null;var y=b.edge,h=S-E-this.edgeStalled,e=y-b.totalduration,s=y-(this.config.lowLatencyMode&&b.partTarget||b.targetduration);return Math.min(Math.max(e,h),s)}},{key:"drift",get:function(){var S=this.levelDetails;return S===null?1:S.drift}},{key:"edgeStalled",get:function(){var S=this.levelDetails;if(S===null)return 0;var E=(this.config.lowLatencyMode&&S.partTarget||S.targetduration)*3;return Math.max(S.age-E,0)}},{key:"forwardBufferLength",get:function(){var S=this.media,E=this.levelDetails;if(!S||!E)return 0;var b=S.buffered.length;return b?S.buffered.end(b-1):E.edge-this.currentTime}}]),w}()},"./src/controller/level-controller.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return h});var B=C("./src/types/level.ts"),O=C("./src/events.ts"),L=C("./src/errors.ts"),_=C("./src/utils/codecs.ts"),M=C("./src/controller/level-helper.ts"),A=C("./src/controller/base-playlist-controller.ts"),w=C("./src/types/loader.ts");function g(){return g=Object.assign||function(e){for(var s=1;s<arguments.length;s++){var o=arguments[s];for(var f in o)Object.prototype.hasOwnProperty.call(o,f)&&(e[f]=o[f])}return e},g.apply(this,arguments)}function x(e,s){for(var o=0;o<s.length;o++){var f=s[o];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(e,f.key,f)}}function S(e,s,o){return s&&x(e.prototype,s),o&&x(e,o),e}function E(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,b(e,s)}function b(e,s){return b=Object.setPrototypeOf||function(f,u){return f.__proto__=u,f},b(e,s)}var y=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),h=function(e){E(s,e);function s(f){var u;return u=e.call(this,f,"[level-controller]")||this,u._levels=[],u._firstLevel=-1,u._startLevel=void 0,u.currentLevelIndex=-1,u.manualLevelIndex=-1,u.onParsedComplete=void 0,u._registerListeners(),u}var o=s.prototype;return o._registerListeners=function(){var u=this.hls;u.on(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this),u.on(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(O.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),u.on(O.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(O.Events.ERROR,this.onError,this)},o._unregisterListeners=function(){var u=this.hls;u.off(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this),u.off(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(O.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),u.off(O.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(O.Events.ERROR,this.onError,this)},o.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},o.startLoad=function(){var u=this._levels;u.forEach(function(l){l.loadError=0}),e.prototype.startLoad.call(this)},o.onManifestLoaded=function(u,l){var p=[],c=[],i=[],r,t={},a,m=!1,v=!1,T=!1;if(l.levels.forEach(function(K){var V=K.attrs;m=m||!!(K.width&&K.height),v=v||!!K.videoCodec,T=T||!!K.audioCodec,y&&K.audioCodec&&K.audioCodec.indexOf("mp4a.40.34")!==-1&&(K.audioCodec=void 0);var Q=K.bitrate+"-"+K.attrs.RESOLUTION+"-"+K.attrs.CODECS;a=t[Q],a?a.url.push(K.url):(a=new B.Level(K),t[Q]=a,p.push(a)),V&&(V.AUDIO&&Object(M.addGroupId)(a,"audio",V.AUDIO),V.SUBTITLES&&Object(M.addGroupId)(a,"text",V.SUBTITLES))}),(m||v)&&T&&(p=p.filter(function(K){var V=K.videoCodec,Q=K.width,Z=K.height;return!!V||!!(Q&&Z)})),p=p.filter(function(K){var V=K.audioCodec,Q=K.videoCodec;return(!V||Object(_.isCodecSupportedInMp4)(V,"audio"))&&(!Q||Object(_.isCodecSupportedInMp4)(Q,"video"))}),l.audioTracks&&(c=l.audioTracks.filter(function(K){return!K.audioCodec||Object(_.isCodecSupportedInMp4)(K.audioCodec,"audio")}),Object(M.assignTrackIdsByGroup)(c)),l.subtitles&&(i=l.subtitles,Object(M.assignTrackIdsByGroup)(i)),p.length>0){r=p[0].bitrate,p.sort(function(K,V){return K.bitrate-V.bitrate}),this._levels=p;for(var k=0;k<p.length;k++)if(p[k].bitrate===r){this._firstLevel=k,this.log("manifest loaded, "+p.length+" level(s) found, first bitrate: "+r);break}var I=T&&!v,F={levels:p,audioTracks:c,subtitleTracks:i,firstLevel:this._firstLevel,stats:l.stats,audio:T,video:v,altAudio:!I&&c.some(function(K){return!!K.url})};this.hls.trigger(O.Events.MANIFEST_PARSED,F),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(O.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:l.url,reason:"no level with compatible codecs found in manifest"})},o.onError=function(u,l){if(e.prototype.onError.call(this,u,l),l.fatal)return;var p=l.context,c=this._levels[this.currentLevelIndex];if(p&&(p.type===w.PlaylistContextType.AUDIO_TRACK&&c.audioGroupIds&&p.groupId===c.audioGroupIds[c.urlId]||p.type===w.PlaylistContextType.SUBTITLE_TRACK&&c.textGroupIds&&p.groupId===c.textGroupIds[c.urlId])){this.redundantFailover(this.currentLevelIndex);return}var i=!1,r=!0,t;switch(l.details){case L.ErrorDetails.FRAG_LOAD_ERROR:case L.ErrorDetails.FRAG_LOAD_TIMEOUT:case L.ErrorDetails.KEY_LOAD_ERROR:case L.ErrorDetails.KEY_LOAD_TIMEOUT:if(l.frag){var a=this._levels[l.frag.level];a?(a.fragmentError++,a.fragmentError>this.hls.config.fragLoadingMaxRetry&&(t=l.frag.level)):t=l.frag.level}break;case L.ErrorDetails.LEVEL_LOAD_ERROR:case L.ErrorDetails.LEVEL_LOAD_TIMEOUT:p&&(p.deliveryDirectives&&(r=!1),t=p.level),i=!0;break;case L.ErrorDetails.REMUX_ALLOC_ERROR:t=l.level,i=!0;break}t!==void 0&&this.recoverLevel(l,t,i,r)},o.recoverLevel=function(u,l,p,c){var i=u.details,r=this._levels[l];if(r.loadError++,p){var t=this.retryLoadingOrFail(u);if(t)u.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(c){var a=r.url.length;if(a>1&&r.loadError<a)u.levelRetry=!0,this.redundantFailover(l);else if(this.manualLevelIndex===-1){var m=l===0?this._levels.length-1:l-1;this.currentLevelIndex!==m&&this._levels[m].loadError===0&&(this.warn(i+": switch to "+m),u.levelRetry=!0,this.hls.nextAutoLevel=m)}}},o.redundantFailover=function(u){var l=this._levels[u],p=l.url.length;if(p>1){var c=(l.urlId+1)%p;this.warn("Switching to redundant URL-id "+c),this._levels.forEach(function(i){i.urlId=c}),this.level=u}},o.onFragLoaded=function(u,l){var p=l.frag;if(p!==void 0&&p.type===w.PlaylistLevelType.MAIN){var c=this._levels[p.level];c!==void 0&&(c.fragmentError=0,c.loadError=0)}},o.onLevelLoaded=function(u,l){var p,c=l.level,i=l.details,r=this._levels[c];if(!r){var t;this.warn("Invalid level index "+c),(t=l.deliveryDirectives)!==null&&t!==void 0&&t.skip&&(i.deltaUpdateFailed=!0);return}c===this.currentLevelIndex?(r.fragmentError===0&&(r.loadError=0,this.retryCount=0),this.playlistLoaded(c,l,r.details)):(p=l.deliveryDirectives)!==null&&p!==void 0&&p.skip&&(i.deltaUpdateFailed=!0)},o.onAudioTrackSwitched=function(u,l){var p=this.hls.levels[this.currentLevelIndex];if(!p)return;if(p.audioGroupIds){for(var c=-1,i=this.hls.audioTracks[l.id].groupId,r=0;r<p.audioGroupIds.length;r++)if(p.audioGroupIds[r]===i){c=r;break}c!==p.urlId&&(p.urlId=c,this.startLoad())}},o.loadPlaylist=function(u){var l=this.currentLevelIndex,p=this._levels[l];if(this.canLoad&&p&&p.url.length>0){var c=p.urlId,i=p.url[c];if(u)try{i=u.addDirectives(i)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log("Attempt loading level index "+l+(u?" at sn "+u.msn+" part "+u.part:"")+" with URL-id "+c+" "+i),this.clearTimer(),this.hls.trigger(O.Events.LEVEL_LOADING,{url:i,level:l,id:c,deliveryDirectives:u||null})}},o.removeLevel=function(u,l){var p=function(r,t){return t!==l},c=this._levels.filter(function(i,r){return r!==u?!0:i.url.length>1&&l!==void 0?(i.url=i.url.filter(p),i.audioGroupIds&&(i.audioGroupIds=i.audioGroupIds.filter(p)),i.textGroupIds&&(i.textGroupIds=i.textGroupIds.filter(p)),i.urlId=0,!0):!1}).map(function(i,r){var t=i.details;return t!=null&&t.fragments&&t.fragments.forEach(function(a){a.level=r}),i});this._levels=c,this.hls.trigger(O.Events.LEVELS_UPDATED,{levels:c})},S(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(u){var l,p=this._levels;if(p.length===0)return;if(this.currentLevelIndex===u&&(l=p[u])!==null&&l!==void 0&&l.details)return;if(u<0||u>=p.length){var c=u<0;if(this.hls.trigger(O.Events.ERROR,{type:L.ErrorTypes.OTHER_ERROR,details:L.ErrorDetails.LEVEL_SWITCH_ERROR,level:u,fatal:c,reason:"invalid level idx"}),c)return;u=Math.min(u,p.length-1)}this.clearTimer();var i=this.currentLevelIndex,r=p[i],t=p[u];this.log("switching to level "+u+" from "+i),this.currentLevelIndex=u;var a=g({},t,{level:u,maxBitrate:t.maxBitrate,uri:t.uri,urlId:t.urlId});delete a._urlId,this.hls.trigger(O.Events.LEVEL_SWITCHING,a);var m=t.details;if(!m||m.live){var v=this.switchParams(t.uri,r==null?void 0:r.details);this.loadPlaylist(v)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(u){this.manualLevelIndex=u,this._startLevel===void 0&&(this._startLevel=u),u!==-1&&(this.level=u)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(u){this._firstLevel=u}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var u=this.hls.config.startLevel;return u!==void 0?u:this._firstLevel}else return this._startLevel},set:function(u){this._startLevel=u}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(u){this.level=u,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=u)}}]),s}(A.default)},"./src/controller/level-helper.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"addGroupId",function(){return L}),C.d(U,"assignTrackIdsByGroup",function(){return _}),C.d(U,"updatePTS",function(){return M}),C.d(U,"updateFragPTSDTS",function(){return w}),C.d(U,"mergeDetails",function(){return g}),C.d(U,"mapPartIntersection",function(){return x}),C.d(U,"mapFragmentIntersection",function(){return S}),C.d(U,"adjustSliding",function(){return E}),C.d(U,"addSliding",function(){return b}),C.d(U,"computeReloadInterval",function(){return y}),C.d(U,"getFragmentWithSN",function(){return h}),C.d(U,"getPartWith",function(){return e});var B=C("./src/polyfills/number.ts"),O=C("./src/utils/logger.ts");function L(s,o,f){switch(o){case"audio":s.audioGroupIds||(s.audioGroupIds=[]),s.audioGroupIds.push(f);break;case"text":s.textGroupIds||(s.textGroupIds=[]),s.textGroupIds.push(f);break}}function _(s){var o={};s.forEach(function(f){var u=f.groupId||"";f.id=o[u]=o[u]||0,o[u]++})}function M(s,o,f){var u=s[o],l=s[f];A(u,l)}function A(s,o){var f=o.startPTS;if(Object(B.isFiniteNumber)(f)){var u=0,l;o.sn>s.sn?(u=f-s.start,l=s):(u=s.start-f,l=o),l.duration!==u&&(l.duration=u)}else if(o.sn>s.sn){var p=s.cc===o.cc;p&&s.minEndPTS?o.start=s.start+(s.minEndPTS-s.start):o.start=s.start+s.duration}else o.start=Math.max(s.start-o.duration,0)}function w(s,o,f,u,l,p){var c=u-f;c<=0&&(O.logger.warn("Fragment should have a positive duration",o),u=f+o.duration,p=l+o.duration);var i=f,r=u,t=o.startPTS,a=o.endPTS;if(Object(B.isFiniteNumber)(t)){var m=Math.abs(t-f);Object(B.isFiniteNumber)(o.deltaPTS)?o.deltaPTS=Math.max(m,o.deltaPTS):o.deltaPTS=m,i=Math.max(f,t),f=Math.min(f,t),l=Math.min(l,o.startDTS),r=Math.min(u,a),u=Math.max(u,a),p=Math.max(p,o.endDTS)}o.duration=u-f;var v=f-o.start;o.appendedPTS=u,o.start=o.startPTS=f,o.maxStartPTS=i,o.startDTS=l,o.endPTS=u,o.minEndPTS=r,o.endDTS=p;var T=o.sn;if(!s||T<s.startSN||T>s.endSN)return 0;var k,I=T-s.startSN,F=s.fragments;for(F[I]=o,k=I;k>0;k--)A(F[k],F[k-1]);for(k=I;k<F.length-1;k++)A(F[k],F[k+1]);return s.fragmentHint&&A(F[F.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,v}function g(s,o){for(var f=null,u=s.fragments,l=u.length-1;l>=0;l--){var p=u[l].initSegment;if(p){f=p;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;var c=0,i;if(S(s,o,function(k,I){k.relurl&&(c=k.cc-I.cc),Object(B.isFiniteNumber)(k.startPTS)&&Object(B.isFiniteNumber)(k.endPTS)&&(I.start=I.startPTS=k.startPTS,I.startDTS=k.startDTS,I.appendedPTS=k.appendedPTS,I.maxStartPTS=k.maxStartPTS,I.endPTS=k.endPTS,I.endDTS=k.endDTS,I.minEndPTS=k.minEndPTS,I.duration=k.endPTS-k.startPTS,I.duration&&(i=I),o.PTSKnown=o.alignedSliding=!0),I.elementaryStreams=k.elementaryStreams,I.loader=k.loader,I.stats=k.stats,I.urlId=k.urlId,k.initSegment&&(I.initSegment=k.initSegment,f=k.initSegment)}),f){var r=o.fragmentHint?o.fragments.concat(o.fragmentHint):o.fragments;r.forEach(function(k){var I;(!k.initSegment||k.initSegment.relurl===((I=f)===null||I===void 0?void 0:I.relurl))&&(k.initSegment=f)})}if(o.skippedSegments&&(o.deltaUpdateFailed=o.fragments.some(function(k){return!k}),o.deltaUpdateFailed)){O.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var t=o.skippedSegments;t--;)o.fragments.shift();o.startSN=o.fragments[0].sn,o.startCC=o.fragments[0].cc}var a=o.fragments;if(c){O.logger.warn("discontinuity sliding from playlist, take drift into account");for(var m=0;m<a.length;m++)a[m].cc+=c}o.skippedSegments&&(o.startCC=o.fragments[0].cc),x(s.partList,o.partList,function(k,I){I.elementaryStreams=k.elementaryStreams,I.stats=k.stats}),i?w(o,i,i.startPTS,i.endPTS,i.startDTS,i.endDTS):E(s,o),a.length&&(o.totalduration=o.edge-a[0].start),o.driftStartTime=s.driftStartTime,o.driftStart=s.driftStart;var v=o.advancedDateTime;if(o.advanced&&v){var T=o.edge;o.driftStart||(o.driftStartTime=v,o.driftStart=T),o.driftEndTime=v,o.driftEnd=T}else o.driftEndTime=s.driftEndTime,o.driftEnd=s.driftEnd,o.advancedDateTime=s.advancedDateTime}function x(s,o,f){if(s&&o)for(var u=0,l=0,p=s.length;l<=p;l++){var c=s[l],i=o[l+u];c&&i&&c.index===i.index&&c.fragment.sn===i.fragment.sn?f(c,i):u--}}function S(s,o,f){for(var u=o.skippedSegments,l=Math.max(s.startSN,o.startSN)-o.startSN,p=(s.fragmentHint?1:0)+(u?o.endSN:Math.min(s.endSN,o.endSN))-o.startSN,c=o.startSN-s.startSN,i=o.fragmentHint?o.fragments.concat(o.fragmentHint):o.fragments,r=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments,t=l;t<=p;t++){var a=r[c+t],m=i[t];u&&!m&&t<u&&(m=o.fragments[t]=a),a&&m&&f(a,m)}}function E(s,o){var f=o.startSN+o.skippedSegments-s.startSN,u=s.fragments;if(f<0||f>=u.length)return;b(o,u[f].start)}function b(s,o){if(o){for(var f=s.fragments,u=s.skippedSegments;u<f.length;u++)f[u].start+=o;s.fragmentHint&&(s.fragmentHint.start+=o)}}function y(s,o){var f=1e3*s.levelTargetDuration,u=f/2,l=s.age,p=l>0&&l<f*3,c=o.loading.end-o.loading.start,i,r=s.availabilityDelay;if(s.updated===!1)if(p){var t=333*s.misses;i=Math.max(Math.min(u,c*2),t),s.availabilityDelay=(s.availabilityDelay||0)+i}else i=u;else p?(r=Math.min(r||f/2,l),s.availabilityDelay=r,i=r+f-l):i=f-c;return Math.round(i)}function h(s,o,f){if(!s||!s.details)return null;var u=s.details,l=u.fragments[o-u.startSN];return l||(l=u.fragmentHint,l&&l.sn===o?l:o<u.startSN&&f&&f.sn===o?f:null)}function e(s,o,f){if(!s||!s.details)return null;var u=s.details.partList;if(u)for(var l=u.length;l--;){var p=u[l];if(p.index===f&&p.fragment.sn===o)return p}return null}},"./src/controller/stream-controller.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return u});var B=C("./src/polyfills/number.ts"),O=C("./src/controller/base-stream-controller.ts"),L=C("./src/is-supported.ts"),_=C("./src/events.ts"),M=C("./src/utils/buffer-helper.ts"),A=C("./src/controller/fragment-tracker.ts"),w=C("./src/types/loader.ts"),g=C("./src/loader/fragment.ts"),x=C("./src/demux/transmuxer-interface.ts"),S=C("./src/types/transmuxer.ts"),E=C("./src/controller/gap-controller.ts"),b=C("./src/errors.ts"),y=C("./src/utils/logger.ts");function h(l,p){for(var c=0;c<p.length;c++){var i=p[c];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(l,i.key,i)}}function e(l,p,c){return p&&h(l.prototype,p),c&&h(l,c),l}function s(l,p){l.prototype=Object.create(p.prototype),l.prototype.constructor=l,o(l,p)}function o(l,p){return o=Object.setPrototypeOf||function(i,r){return i.__proto__=r,i},o(l,p)}var f=100,u=function(l){s(p,l);function p(i,r){var t;return t=l.call(this,i,r,"[stream-controller]")||this,t.audioCodecSwap=!1,t.gapController=null,t.level=-1,t._forceStartLoad=!1,t.altAudio=!1,t.audioOnly=!1,t.fragPlaying=null,t.onvplaying=null,t.onvseeked=null,t.fragLastKbps=0,t.stalled=!1,t.couldBacktrack=!1,t.audioCodecSwitch=!1,t.videoBuffer=null,t._registerListeners(),t}var c=p.prototype;return c._registerListeners=function(){var r=this.hls;r.on(_.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(_.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(_.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(_.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(_.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.on(_.Events.ERROR,this.onError,this),r.on(_.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(_.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(_.Events.BUFFER_CREATED,this.onBufferCreated,this),r.on(_.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(_.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(_.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var r=this.hls;r.off(_.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(_.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(_.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(_.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.off(_.Events.ERROR,this.onError,this),r.off(_.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(_.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(_.Events.BUFFER_CREATED,this.onBufferCreated,this),r.off(_.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(_.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(_.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},c.startLoad=function(r){if(this.levels){var t=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(f),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var m=a.startLevel;m===-1&&(a.config.testBandwidth?(m=0,this.bitrateTest=!0):m=a.nextAutoLevel),this.level=a.nextLoadLevel=m,this.loadedmetadata=!1}t>0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),r=t),this.state=O.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=O.State.STOPPED},c.stopLoad=function(){this._forceStartLoad=!1,l.prototype.stopLoad.call(this)},c.doTick=function(){switch(this.state){case O.State.IDLE:this.doTickIdle();break;case O.State.WAITING_LEVEL:{var r,t=this.levels,a=this.level,m=t==null||((r=t[a])===null||r===void 0)?void 0:r.details;if(m&&(!m.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(m))break;this.state=O.State.IDLE;break}break}case O.State.FRAG_LOADING_WAITING_RETRY:{var v,T=self.performance.now(),k=this.retryDate;(!k||T>=k||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=O.State.IDLE)}break;default:break}this.onTickEnd()},c.onTickEnd=function(){l.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},c.doTickIdle=function(){var r,t,a=this.hls,m=this.levelLastLoaded,v=this.levels,T=this.media,k=a.config,I=a.nextLoadLevel;if(m===null||!T&&(this.startFragRequested||!k.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!v||!v[I])return;var F=v[I];this.level=a.nextLoadLevel=I;var K=F.details;if(!K||this.state===O.State.WAITING_LEVEL||K.live&&this.levelLastLoaded!==I){this.state=O.State.WAITING_LEVEL;return}var V=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:T,w.PlaylistLevelType.MAIN);if(V===null)return;var Q=V.len,Z=this.getMaxBufferLength(F.maxBitrate);if(Q>=Z)return;if(this._streamEnded(V,K)){var ie={};this.altAudio&&(ie.type="video"),this.hls.trigger(_.Events.BUFFER_EOS,ie),this.state=O.State.ENDED;return}var ge=V.end,se=this.getNextFragment(ge,K);if(this.couldBacktrack&&!this.fragPrevious&&se&&se.sn!=="initSegment"){var he=se.sn-K.startSN;he>1&&(se=K.fragments[he-1],this.fragmentTracker.removeFragment(se))}if(se&&this.fragmentTracker.getState(se)===A.FragmentState.OK&&this.nextLoadPosition>ge){var de=this.audioOnly&&!this.altAudio?g.ElementaryStreamTypes.AUDIO:g.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(T,de,w.PlaylistLevelType.MAIN),se=this.getNextFragment(this.nextLoadPosition,K)}if(!se)return;se.initSegment&&!se.initSegment.data&&!this.bitrateTest&&(se=se.initSegment),((r=se.decryptdata)===null||r===void 0?void 0:r.keyFormat)==="identity"&&!((t=se.decryptdata)!==null&&t!==void 0&&t.key)?this.loadKey(se,K):this.loadFragment(se,K,ge)},c.loadFragment=function(r,t,a){var m,v=this.fragmentTracker.getState(r);if(this.fragCurrent=r,v===A.FragmentState.BACKTRACKED){var T=this.fragmentTracker.getBacktrackData(r);if(T){this._handleFragmentLoadProgress(T),this._handleFragmentLoadComplete(T);return}else v=A.FragmentState.NOT_LOADED}v===A.FragmentState.NOT_LOADED||v===A.FragmentState.PARTIAL?r.sn==="initSegment"?this._loadInitSegment(r):this.bitrateTest?(r.bitrateTest=!0,this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(r)):(this.startFragRequested=!0,l.prototype.loadFragment.call(this,r,t,a)):v===A.FragmentState.APPENDING?this.reduceMaxBufferLength(r.duration)&&this.fragmentTracker.removeFragment(r):((m=this.media)===null||m===void 0?void 0:m.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},c.getAppendedFrag=function(r){var t=this.fragmentTracker.getAppendedFrag(r,w.PlaylistLevelType.MAIN);return t&&"fragment"in t?t.fragment:t},c.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,w.PlaylistLevelType.MAIN)},c.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},c.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},c.nextLevelSwitch=function(){var r=this.levels,t=this.media;if(t!=null&&t.readyState){var a,m=this.getAppendedFrag(t.currentTime);if(m&&m.start>1&&this.flushMainBuffer(0,m.start-1),!t.paused&&r){var v=this.hls.nextLoadLevel,T=r[v],k=this.fragLastKbps;k&&this.fragCurrent?a=this.fragCurrent.duration*T.maxBitrate/(1e3*k)+1:a=0}else a=0;var I=this.getBufferedFrag(t.currentTime+a);if(I){var F=this.followingBufferedFrag(I);if(F){this.abortCurrentFrag();var K=F.maxStartPTS?F.maxStartPTS:F.start,V=F.duration,Q=Math.max(I.end,K+Math.min(Math.max(V-this.config.maxFragLookUpTolerance,V*.5),V*.75));this.flushMainBuffer(Q,Number.POSITIVE_INFINITY)}}}},c.abortCurrentFrag=function(){var r=this.fragCurrent;this.fragCurrent=null,r!=null&&r.loader&&r.loader.abort(),this.state===O.State.KEY_LOADING&&(this.state=O.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},c.flushMainBuffer=function(r,t){l.prototype.flushMainBuffer.call(this,r,t,this.altAudio?"video":null)},c.onMediaAttached=function(r,t){l.prototype.onMediaAttached.call(this,r,t);var a=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),a.addEventListener("playing",this.onvplaying),a.addEventListener("seeked",this.onvseeked),this.gapController=new E.default(this.config,a,this.fragmentTracker,this.hls)},c.onMediaDetaching=function(){var r=this.media;r&&(r.removeEventListener("playing",this.onvplaying),r.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),l.prototype.onMediaDetaching.call(this)},c.onMediaPlaying=function(){this.tick()},c.onMediaSeeked=function(){var r=this.media,t=r?r.currentTime:null;Object(B.isFiniteNumber)(t)&&this.log("Media seeked to "+t.toFixed(3)),this.tick()},c.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(_.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},c.onManifestParsed=function(r,t){var a=!1,m=!1,v;t.levels.forEach(function(T){v=T.audioCodec,v&&(v.indexOf("mp4a.40.2")!==-1&&(a=!0),v.indexOf("mp4a.40.5")!==-1&&(m=!0))}),this.audioCodecSwitch=a&&m&&!Object(L.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1},c.onLevelLoading=function(r,t){var a=this.levels;if(!a||this.state!==O.State.IDLE)return;var m=a[t.level];(!m.details||m.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(m.details))&&(this.state=O.State.WAITING_LEVEL)},c.onLevelLoaded=function(r,t){var a,m=this.levels,v=t.level,T=t.details,k=T.totalduration;if(!m){this.warn("Levels were reset while loading level "+v);return}this.log("Level "+v+" loaded ["+T.startSN+","+T.endSN+"], cc ["+T.startCC+", "+T.endCC+"] duration:"+k);var I=this.fragCurrent;I&&(this.state===O.State.FRAG_LOADING||this.state===O.State.FRAG_LOADING_WAITING_RETRY)&&(I.level!==t.level&&I.loader&&(this.state=O.State.IDLE,I.loader.abort()));var F=m[v],K=0;if(T.live||(a=F.details)!==null&&a!==void 0&&a.live){if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed)return;K=this.alignPlaylists(T,F.details)}if(F.details=T,this.levelLastLoaded=v,this.hls.trigger(_.Events.LEVEL_UPDATED,{details:T,level:v}),this.state===O.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(T))return;this.state=O.State.IDLE}this.startFragRequested?T.live&&this.synchronizeToLiveEdge(T):this.setStartPosition(T,K),this.tick()},c._handleFragmentLoadProgress=function(r){var t,a=r.frag,m=r.part,v=r.payload,T=this.levels;if(!T){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var k=T[a.level],I=k.details;if(!I){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var F=k.videoCodec,K=I.PTSKnown||!I.live,V=(t=a.initSegment)===null||t===void 0?void 0:t.data,Q=this._getAudioCodec(k),Z=this.transmuxer=this.transmuxer||new x.default(this.hls,w.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),ie=m?m.index:-1,ge=ie!==-1,se=new S.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,v.byteLength,ie,ge),he=this.initPTS[a.cc];Z.push(v,V,Q,F,a,m,I.totalduration,K,se,he)},c.onAudioTrackSwitching=function(r,t){var a=this.altAudio,m=!!t.url,v=t.id;if(!m){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var T=this.fragCurrent;T!=null&&T.loader&&(this.log("Switching to main audio track, cancel main fragment load"),T.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var k=this.hls;a&&k.trigger(_.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),k.trigger(_.Events.AUDIO_TRACK_SWITCHED,{id:v})}},c.onAudioTrackSwitched=function(r,t){var a=t.id,m=!!this.hls.audioTracks[a].url;if(m){var v=this.videoBuffer;v&&this.mediaBuffer!==v&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=v)}this.altAudio=m,this.tick()},c.onBufferCreated=function(r,t){var a=t.tracks,m,v,T=!1;for(var k in a){var I=a[k];if(I.id==="main"){if(v=k,m=I,k==="video"){var F=a[k];F&&(this.videoBuffer=F.buffer)}}else T=!0}T&&m?(this.log("Alternate track found, use "+v+".buffered to schedule main fragment loading"),this.mediaBuffer=m.buffer):this.mediaBuffer=this.media},c.onFragBuffered=function(r,t){var a=t.frag,m=t.part;if(a&&a.type!==w.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(m?" p: "+m.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===O.State.PARSED&&(this.state=O.State.IDLE);return}var v=m?m.stats:a.stats;this.fragLastKbps=Math.round(8*v.total/(v.buffering.end-v.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,m)},c.onError=function(r,t){switch(t.details){case b.ErrorDetails.FRAG_LOAD_ERROR:case b.ErrorDetails.FRAG_LOAD_TIMEOUT:case b.ErrorDetails.KEY_LOAD_ERROR:case b.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(w.PlaylistLevelType.MAIN,t);break;case b.ErrorDetails.LEVEL_LOAD_ERROR:case b.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==O.State.ERROR&&(t.fatal?(this.warn(""+t.details),this.state=O.State.ERROR):!t.levelRetry&&this.state===O.State.WAITING_LEVEL&&(this.state=O.State.IDLE));break;case b.ErrorDetails.BUFFER_FULL_ERROR:if(t.parent==="main"&&(this.state===O.State.PARSING||this.state===O.State.PARSED)){var a=!0,m=this.getFwdBufferInfo(this.media,w.PlaylistLevelType.MAIN);m&&m.len>.5&&(a=!this.reduceMaxBufferLength(m.len)),a&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},c.checkBuffer=function(){var r=this.media,t=this.gapController;if(!r||!t||!r.readyState)return;var a=M.BufferHelper.getBuffered(r);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):t.poll(this.lastCurrentTime),this.lastCurrentTime=r.currentTime},c.onFragLoadEmergencyAborted=function(){this.state=O.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},c.onBufferFlushed=function(r,t){var a=t.type;if(a!==g.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var m=(a===g.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(m,a,w.PlaylistLevelType.MAIN)}},c.onLevelsUpdated=function(r,t){this.levels=t.levels},c.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},c.seekToStartPos=function(){var r=this.media,t=r.currentTime,a=this.startPosition;if(a>=0&&t<a){if(r.seeking){y.logger.log("could not seek to "+a+", already seeking at "+t);return}var m=M.BufferHelper.getBuffered(r),v=m.length?m.start(0):0,T=v-a;T>0&&(T<this.config.maxBufferHole||T<this.config.maxFragLookUpTolerance)&&(y.logger.log("adjusting start position by "+T+" to match buffer start"),a+=T,this.startPosition=a),this.log("seek to target start position "+a+" from current time "+t),r.currentTime=a}},c._getAudioCodec=function(r){var t=this.config.defaultAudioCodec||r.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t},c._loadBitrateTestFrag=function(r){var t=this;this._doFragLoad(r).then(function(a){var m=t.hls;if(!a||m.nextLoadLevel||t.fragContextChanged(r))return;t.fragLoadError=0,t.state=O.State.IDLE,t.startFragRequested=!1,t.bitrateTest=!1;var v=r.stats;v.parsing.start=v.parsing.end=v.buffering.start=v.buffering.end=self.performance.now(),m.trigger(_.Events.FRAG_LOADED,a)})},c._handleTransmuxComplete=function(r){var t,a="main",m=this.hls,v=r.remuxResult,T=r.chunkMeta,k=this.getCurrentContext(T);if(!k){this.warn("The loading context changed while buffering fragment "+T.sn+" of level "+T.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(T.level);return}var I=k.frag,F=k.part,K=k.level,V=v.video,Q=v.text,Z=v.id3,ie=v.initSegment,ge=this.altAudio?void 0:v.audio;if(this.fragContextChanged(I))return;if(this.state=O.State.PARSING,ie){ie.tracks&&(this._bufferInitSegment(K,ie.tracks,I,T),m.trigger(_.Events.FRAG_PARSING_INIT_SEGMENT,{frag:I,id:a,tracks:ie.tracks}));var se=ie.initPTS,he=ie.timescale;Object(B.isFiniteNumber)(se)&&(this.initPTS[I.cc]=se,m.trigger(_.Events.INIT_PTS_FOUND,{frag:I,id:a,initPTS:se,timescale:he}))}if(V&&v.independent!==!1){if(K.details){var de=V.startPTS,$=V.endPTS,Y=V.startDTS,ne=V.endDTS;if(F)F.elementaryStreams[V.type]={startPTS:de,endPTS:$,startDTS:Y,endDTS:ne};else if(V.firstKeyFrame&&V.independent&&(this.couldBacktrack=!0),V.dropped&&V.independent){var z=this.getLoadPosition()+this.config.maxBufferHole;if(z<de){this.backtrack(I);return}I.setElementaryStreamInfo(V.type,I.start,$,I.start,ne,!0)}I.setElementaryStreamInfo(V.type,de,$,Y,ne),this.bufferFragmentData(V,I,F,T)}}else if(v.independent===!1){this.backtrack(I);return}if(ge){var H=ge.startPTS,me=ge.endPTS,Le=ge.startDTS,Oe=ge.endDTS;F&&(F.elementaryStreams[g.ElementaryStreamTypes.AUDIO]={startPTS:H,endPTS:me,startDTS:Le,endDTS:Oe}),I.setElementaryStreamInfo(g.ElementaryStreamTypes.AUDIO,H,me,Le,Oe),this.bufferFragmentData(ge,I,F,T)}if(Z!=null&&(t=Z.samples)!==null&&t!==void 0&&t.length){var we={frag:I,id:a,samples:Z.samples};m.trigger(_.Events.FRAG_PARSING_METADATA,we)}if(Q){var De={frag:I,id:a,samples:Q.samples};m.trigger(_.Events.FRAG_PARSING_USERDATA,De)}},c._bufferInitSegment=function(r,t,a,m){var v=this;if(this.state!==O.State.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var T=t.audio,k=t.video,I=t.audiovideo;if(T){var F=r.audioCodec,K=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(F&&(F.indexOf("mp4a.40.5")!==-1?F="mp4a.40.2":F="mp4a.40.5"),T.metadata.channelCount!==1&&K.indexOf("firefox")===-1&&(F="mp4a.40.5")),K.indexOf("android")!==-1&&T.container!=="audio/mpeg"&&(F="mp4a.40.2",this.log("Android: force audio codec to "+F)),r.audioCodec&&r.audioCodec!==F&&this.log('Swapping manifest audio codec "'+r.audioCodec+'" for "'+F+'"'),T.levelCodec=F,T.id="main",this.log("Init audio buffer, container:"+T.container+", codecs[selected/level/parsed]=["+(F||"")+"/"+(r.audioCodec||"")+"/"+T.codec+"]")}k&&(k.levelCodec=r.videoCodec,k.id="main",this.log("Init video buffer, container:"+k.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+k.codec+"]")),I&&this.log("Init audiovideo buffer, container:"+I.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+I.codec+"]"),this.hls.trigger(_.Events.BUFFER_CODECS,t),Object.keys(t).forEach(function(V){var Q=t[V],Z=Q.initSegment;Z!=null&&Z.byteLength&&v.hls.trigger(_.Events.BUFFER_APPENDING,{type:V,data:Z,frag:a,part:null,chunkMeta:m,parent:a.type})}),this.tick()},c.backtrack=function(r){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(r);var t=this.fragmentTracker.backtrack(r);this.fragPrevious=null,this.nextLoadPosition=r.start,t?this.resetFragmentLoading(r):this.state=O.State.BACKTRACKING},c.checkFragmentChanged=function(){var r=this.media,t=null;if(r&&r.readyState>1&&r.seeking===!1){var a=r.currentTime;if(M.BufferHelper.isBuffered(r,a)?t=this.getAppendedFrag(a):M.BufferHelper.isBuffered(r,a+.1)&&(t=this.getAppendedFrag(a+.1)),t){var m=this.fragPlaying,v=t.level;(!m||t.sn!==m.sn||m.level!==v||t.urlId!==m.urlId)&&(this.hls.trigger(_.Events.FRAG_CHANGED,{frag:t}),(!m||m.level!==v)&&this.hls.trigger(_.Events.LEVEL_SWITCHED,{level:v}),this.fragPlaying=t)}}},e(p,[{key:"nextLevel",get:function(){var r=this.nextBufferedFrag;return r?r.level:-1}},{key:"currentLevel",get:function(){var r=this.media;if(r){var t=this.getAppendedFrag(r.currentTime);if(t)return t.level}return-1}},{key:"nextBufferedFrag",get:function(){var r=this.media;if(r){var t=this.getAppendedFrag(r.currentTime);return this.followingBufferedFrag(t)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),p}(O.default)},"./src/controller/subtitle-stream-controller.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"SubtitleStreamController",function(){return s});var B=C("./src/events.ts"),O=C("./src/utils/logger.ts"),L=C("./src/utils/buffer-helper.ts"),_=C("./src/controller/fragment-finders.ts"),M=C("./src/utils/discontinuities.ts"),A=C("./src/controller/level-helper.ts"),w=C("./src/controller/fragment-tracker.ts"),g=C("./src/controller/base-stream-controller.ts"),x=C("./src/types/loader.ts"),S=C("./src/types/level.ts");function E(o,f){for(var u=0;u<f.length;u++){var l=f[u];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(o,l.key,l)}}function b(o,f,u){return f&&E(o.prototype,f),u&&E(o,u),o}function y(o,f){o.prototype=Object.create(f.prototype),o.prototype.constructor=o,h(o,f)}function h(o,f){return h=Object.setPrototypeOf||function(l,p){return l.__proto__=p,l},h(o,f)}var e=500,s=function(o){y(f,o);function f(l,p){var c;return c=o.call(this,l,p,"[subtitle-stream-controller]")||this,c.levels=[],c.currentTrackId=-1,c.tracksBuffered=[],c.mainDetails=null,c._registerListeners(),c}var u=f.prototype;return u.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},u._registerListeners=function(){var p=this.hls;p.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.on(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.on(B.Events.ERROR,this.onError,this),p.on(B.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),p.on(B.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),p.on(B.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),p.on(B.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),p.on(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},u._unregisterListeners=function(){var p=this.hls;p.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.off(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.off(B.Events.ERROR,this.onError,this),p.off(B.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),p.off(B.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),p.off(B.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),p.off(B.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),p.off(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},u.startLoad=function(){this.stopLoad(),this.state=g.State.IDLE,this.setInterval(e),this.tick()},u.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},u.onLevelLoaded=function(p,c){this.mainDetails=c.details},u.onSubtitleFragProcessed=function(p,c){var i=c.frag,r=c.success;if(this.fragPrevious=i,this.state=g.State.IDLE,!r)return;var t=this.tracksBuffered[this.currentTrackId];if(!t)return;for(var a,m=i.start,v=0;v<t.length;v++)if(m>=t[v].start&&m<=t[v].end){a=t[v];break}var T=i.start+i.duration;a?a.end=T:(a={start:m,end:T},t.push(a)),this.fragmentTracker.fragBuffered(i)},u.onBufferFlushing=function(p,c){var i=c.startOffset,r=c.endOffset;if(i===0&&r!==Number.POSITIVE_INFINITY){var t=this.currentTrackId,a=this.levels;if(!a.length||!a[t]||!a[t].details)return;var m=a[t].details,v=m.targetduration,T=r-v;if(T<=0)return;c.endOffsetSubtitles=Math.max(0,T),this.tracksBuffered.forEach(function(k){for(var I=0;I<k.length;){if(k[I].end<=T){k.shift();continue}else if(k[I].start<T)k[I].start=T;else break;I++}}),this.fragmentTracker.removeFragmentsInRange(i,T,x.PlaylistLevelType.SUBTITLE)}},u.onError=function(p,c){var i,r=c.frag;if(!r||r.type!==x.PlaylistLevelType.SUBTITLE)return;(i=this.fragCurrent)!==null&&i!==void 0&&i.loader&&this.fragCurrent.loader.abort(),this.state=g.State.IDLE},u.onSubtitleTracksUpdated=function(p,c){var i=this,r=c.subtitleTracks;this.tracksBuffered=[],this.levels=r.map(function(t){return new S.Level(t)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(t){i.tracksBuffered[t.id]=[]}),this.mediaBuffer=null},u.onSubtitleTrackSwitch=function(p,c){if(this.currentTrackId=c.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var i=this.levels[this.currentTrackId];i!=null&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(e)},u.onSubtitleTrackLoaded=function(p,c){var i,r=c.details,t=c.id,a=this.currentTrackId,m=this.levels;if(!m.length)return;var v=m[a];if(t>=m.length||t!==a||!v)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,r.live||(i=v.details)!==null&&i!==void 0&&i.live){var T=this.mainDetails;if(r.deltaUpdateFailed||!T)return;var k=T.fragments[0];if(!v.details)r.hasProgramDateTime&&T.hasProgramDateTime?Object(M.alignMediaPlaylistByPDT)(r,T):k&&Object(A.addSliding)(r,k.start);else{var I=this.alignPlaylists(r,v.details);I===0&&k&&Object(A.addSliding)(r,k.start)}}if(v.details=r,this.levelLastLoaded=t,this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===g.State.IDLE){var F=Object(_.findFragmentByPTS)(null,r.fragments,this.media.currentTime,0);F||(this.warn("Subtitle playlist not aligned with playback"),v.details=void 0)}},u._handleFragmentLoadComplete=function(p){var c=p.frag,i=p.payload,r=c.decryptdata,t=this.hls;if(this.fragContextChanged(c))return;if(i&&i.byteLength>0&&r&&r.key&&r.iv&&r.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(i),r.key.buffer,r.iv.buffer).then(function(m){var v=performance.now();t.trigger(B.Events.FRAG_DECRYPTED,{frag:c,payload:m,stats:{tstart:a,tdecrypt:v}})})}},u.doTick=function(){if(!this.media){this.state=g.State.IDLE;return}if(this.state===g.State.IDLE){var p,c=this.currentTrackId,i=this.levels;if(!i.length||!i[c]||!i[c].details)return;var r=i[c].details,t=r.targetduration,a=this.config,m=this.media,v=L.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,m.currentTime-t,a.maxBufferHole),T=v.end,k=v.len,I=this.getMaxBufferLength()+t;if(k>I)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var F=r.fragments,K=F.length,V=r.edge,Q,Z=this.fragPrevious;if(T<V){var ie=a.maxFragLookUpTolerance;Z&&r.hasProgramDateTime&&(Q=Object(_.findFragmentByPDT)(F,Z.endProgramDateTime,ie)),Q||(Q=Object(_.findFragmentByPTS)(Z,F,T,ie),!Q&&Z&&Z.start<F[0].start&&(Q=F[0]))}else Q=F[K-1];(p=Q)!==null&&p!==void 0&&p.encrypted?(O.logger.log("Loading key for "+Q.sn),this.state=g.State.KEY_LOADING,this.hls.trigger(B.Events.KEY_LOADING,{frag:Q})):Q&&this.fragmentTracker.getState(Q)===w.FragmentState.NOT_LOADED&&this.loadFragment(Q,r,T)}},u.loadFragment=function(p,c,i){this.fragCurrent=p,o.prototype.loadFragment.call(this,p,c,i)},b(f,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),f}(g.default)},"./src/controller/subtitle-track-controller.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/events.ts"),O=C("./src/utils/texttrack-utils.ts"),L=C("./src/controller/base-playlist-controller.ts"),_=C("./src/types/loader.ts");function M(E,b){for(var y=0;y<b.length;y++){var h=b[y];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(E,h.key,h)}}function A(E,b,y){return b&&M(E.prototype,b),y&&M(E,y),E}function w(E,b){E.prototype=Object.create(b.prototype),E.prototype.constructor=E,g(E,b)}function g(E,b){return g=Object.setPrototypeOf||function(h,e){return h.__proto__=e,h},g(E,b)}var x=function(E){w(b,E);function b(h){var e;return e=E.call(this,h,"[subtitle-track-controller]")||this,e.media=null,e.tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.selectDefaultTrack=!0,e.queuedDefaultTrack=-1,e.trackChangeListener=function(){return e.onTextTracksChanged()},e.asyncPollTrackChange=function(){return e.pollTrackChange(0)},e.useTextTrackPolling=!1,e.subtitlePollingInterval=-1,e.subtitleDisplay=!0,e.registerListeners(),e}var y=b.prototype;return y.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,E.prototype.destroy.call(this)},y.registerListeners=function(){var e=this.hls;e.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(B.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(B.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(B.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(B.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){var e=this.hls;e.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(B.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(B.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(B.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(B.Events.ERROR,this.onError,this)},y.onMediaAttached=function(e,s){if(this.media=s.media,!this.media)return;this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)},y.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},y.onMediaDetaching=function(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var e=S(this.media.textTracks);e.forEach(function(s){Object(O.clearCurrentCues)(s)}),this.subtitleTrack=-1,this.media=null},y.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},y.onManifestParsed=function(e,s){this.tracks=s.subtitleTracks},y.onSubtitleTrackLoaded=function(e,s){var o=s.id,f=s.details,u=this.trackId,l=this.tracksInGroup[u];if(!l){this.warn("Invalid subtitle track id "+o);return}var p=l.details;l.details=s.details,this.log("subtitle track "+o+" loaded ["+f.startSN+"-"+f.endSN+"]"),o===this.trackId&&(this.retryCount=0,this.playlistLoaded(o,s,p))},y.onLevelLoading=function(e,s){this.switchLevel(s.level)},y.onLevelSwitching=function(e,s){this.switchLevel(s.level)},y.switchLevel=function(e){var s=this.hls.levels[e];if(!(s!=null&&s.textGroupIds))return;var o=s.textGroupIds[s.urlId];if(this.groupId!==o){var f=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,u=this.tracks.filter(function(c){return!o||c.groupId===o});this.tracksInGroup=u;var l=this.findTrackId(f==null?void 0:f.name)||this.findTrackId();this.groupId=o;var p={subtitleTracks:u};this.log("Updating subtitle tracks, "+u.length+' track(s) found in "'+o+'" group-id'),this.hls.trigger(B.Events.SUBTITLE_TRACKS_UPDATED,p),l!==-1&&this.setSubtitleTrack(l,f)}},y.findTrackId=function(e){for(var s=this.tracksInGroup,o=0;o<s.length;o++){var f=s[o];if((!this.selectDefaultTrack||f.default)&&(!e||e===f.name))return f.id}return-1},y.onError=function(e,s){if(E.prototype.onError.call(this,e,s),s.fatal||!s.context)return;s.context.type===_.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},y.loadPlaylist=function(e){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var o=s.id,f=s.groupId,u=s.url;if(e)try{u=e.addDirectives(u)}catch(l){this.warn("Could not construct new URL with HLS Delivery Directives: "+l)}this.log("Loading subtitle playlist for id "+o),this.hls.trigger(B.Events.SUBTITLE_TRACK_LOADING,{url:u,id:o,groupId:f,deliveryDirectives:e||null})}},y.toggleTrackModes=function(e){var s=this,o=this.media,f=this.subtitleDisplay,u=this.trackId;if(!o)return;var l=S(o.textTracks),p=l.filter(function(r){return r.groupId===s.groupId});if(e===-1)[].slice.call(l).forEach(function(r){r.mode="disabled"});else{var c=p[u];c&&(c.mode="disabled")}var i=p[e];i&&(i.mode=f?"showing":"hidden")},y.setSubtitleTrack=function(e,s){var o,f=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(e===-1||(o=f[e])!==null&&o!==void 0&&o.details)||e<-1||e>=f.length)return;this.clearTimer();var u=f[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,u){var l=u.id,p=u.groupId,c=p===void 0?"":p,i=u.name,r=u.type,t=u.url;this.hls.trigger(B.Events.SUBTITLE_TRACK_SWITCH,{id:l,groupId:c,name:i,type:r,url:t});var a=this.switchParams(u.url,s==null?void 0:s.details);this.loadPlaylist(a)}else this.hls.trigger(B.Events.SUBTITLE_TRACK_SWITCH,{id:e})},y.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var e=-1,s=S(this.media.textTracks),o=0;o<s.length;o++)if(s[o].mode==="hidden")e=o;else if(s[o].mode==="showing"){e=o;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)},A(b,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,s)}}]),b}(L.default);function S(E){for(var b=[],y=0;y<E.length;y++){var h=E[y];h.kind==="subtitles"&&h.label&&b.push(E[y])}return b}U.default=x},"./src/controller/timeline-controller.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"TimelineController",function(){return S});var B=C("./src/polyfills/number.ts"),O=C("./src/events.ts"),L=C("./src/utils/cea-608-parser.ts"),_=C("./src/utils/output-filter.ts"),M=C("./src/utils/webvtt-parser.ts"),A=C("./src/utils/texttrack-utils.ts"),w=C("./src/utils/imsc1-ttml-parser.ts"),g=C("./src/types/loader.ts"),x=C("./src/utils/logger.ts"),S=function(){function h(s){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=y(),this.captionsProperties=void 0,this.hls=s,this.config=s.config,this.Cues=s.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 o=new _.default(this,"textTrack1"),f=new _.default(this,"textTrack2"),u=new _.default(this,"textTrack3"),l=new _.default(this,"textTrack4");this.cea608Parser1=new L.default(1,o,f),this.cea608Parser2=new L.default(3,u,l)}s.on(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),s.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.on(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this),s.on(O.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),s.on(O.Events.FRAG_LOADING,this.onFragLoading,this),s.on(O.Events.FRAG_LOADED,this.onFragLoaded,this),s.on(O.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),s.on(O.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),s.on(O.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),s.on(O.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),s.on(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var e=h.prototype;return e.destroy=function(){var o=this.hls;o.off(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this),o.off(O.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.off(O.Events.FRAG_LOADING,this.onFragLoading,this),o.off(O.Events.FRAG_LOADED,this.onFragLoaded,this),o.off(O.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),o.off(O.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),o.off(O.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),o.off(O.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),o.off(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},e.addCues=function(o,f,u,l,p){for(var c=!1,i=p.length;i--;){var r=p[i],t=b(r[0],r[1],f,u);if(t>=0&&(r[0]=Math.min(r[0],f),r[1]=Math.max(r[1],u),c=!0,t/(u-f)>.5))return}if(c||p.push([f,u]),this.config.renderTextTracksNatively){var a=this.captionsTracks[o];this.Cues.newCue(a,f,u,l)}else{var m=this.Cues.newCue(null,f,u,l);this.hls.trigger(O.Events.CUES_PARSED,{type:"captions",cues:m,track:o})}},e.onInitPtsFound=function(o,f){var u=this,l=f.frag,p=f.id,c=f.initPTS,i=f.timescale,r=this.unparsedVttFrags;p==="main"&&(this.initPTS[l.cc]=c,this.timescale[l.cc]=i),r.length&&(this.unparsedVttFrags=[],r.forEach(function(t){u.onFragLoaded(O.Events.FRAG_LOADED,t)}))},e.getExistingTrack=function(o){var f=this.media;if(f)for(var u=0;u<f.textTracks.length;u++){var l=f.textTracks[u];if(l[o])return l}return null},e.createCaptionsTrack=function(o){this.config.renderTextTracksNatively?this.createNativeTrack(o):this.createNonNativeTrack(o)},e.createNativeTrack=function(o){if(this.captionsTracks[o])return;var f=this.captionsProperties,u=this.captionsTracks,l=this.media,p=f[o],c=p.label,i=p.languageCode,r=this.getExistingTrack(o);if(r)u[o]=r,Object(A.clearCurrentCues)(u[o]),Object(A.sendAddTrackEvent)(u[o],l);else{var t=this.createTextTrack("captions",c,i);t&&(t[o]=!0,u[o]=t)}},e.createNonNativeTrack=function(o){if(this.nonNativeCaptionsTracks[o])return;var f=this.captionsProperties[o];if(!f)return;var u=f.label,l={_id:o,label:u,kind:"captions",default:f.media?!!f.media.default:!1,closedCaptions:f.media};this.nonNativeCaptionsTracks[o]=l,this.hls.trigger(O.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[l]})},e.createTextTrack=function(o,f,u){var l=this.media;return l?l.addTextTrack(o,f,u):void 0},e.onMediaAttaching=function(o,f){this.media=f.media,this._cleanTracks()},e.onMediaDetaching=function(){var o=this.captionsTracks;Object.keys(o).forEach(function(f){Object(A.clearCurrentCues)(o[f]),delete o[f]}),this.nonNativeCaptionsTracks={}},e.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=y(),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 o=this.media;if(!o)return;var f=o.textTracks;if(f)for(var u=0;u<f.length;u++)Object(A.clearCurrentCues)(f[u])},e.onSubtitleTracksUpdated=function(o,f){var u=this;this.textTracks=[];var l=f.subtitleTracks||[],p=l.some(function(t){return t.textCodec===w.IMSC1_CODEC});if(this.config.enableWebVTT||p&&this.config.enableIMSC1){var c=this.tracks&&l&&this.tracks.length===l.length;if(this.tracks=l||[],this.config.renderTextTracksNatively){var i=this.media?this.media.textTracks:[];this.tracks.forEach(function(t,a){var m;if(a<i.length){for(var v=null,T=0;T<i.length;T++)if(E(i[T],t)){v=i[T];break}v&&(m=v)}m?Object(A.clearCurrentCues)(m):(m=u.createTextTrack("subtitles",t.name,t.lang),m&&(m.mode="disabled")),m&&(m.groupId=t.groupId,u.textTracks.push(m))})}else if(!c&&this.tracks&&this.tracks.length){var r=this.tracks.map(function(t){return{label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t}});this.hls.trigger(O.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:r})}}},e.onManifestLoaded=function(o,f){var u=this;this.config.enableCEA708Captions&&f.captions&&f.captions.forEach(function(l){var p=/(?:CC|SERVICE)([1-4])/.exec(l.instreamId);if(!p)return;var c="textTrack"+p[1],i=u.captionsProperties[c];if(!i)return;i.label=l.name,l.lang&&(i.languageCode=l.lang),i.media=l})},e.onFragLoading=function(o,f){var u=this.cea608Parser1,l=this.cea608Parser2,p=this.lastSn,c=this.lastPartIndex;if(!this.enabled||!(u&&l))return;if(f.frag.type===g.PlaylistLevelType.MAIN){var i,r,t=f.frag.sn,a=(i=f==null||((r=f.part)===null||r===void 0)?void 0:r.index)!=null?i:-1;t===p+1||t===p&&a===c+1||(u.reset(),l.reset()),this.lastSn=t,this.lastPartIndex=a}},e.onFragLoaded=function(o,f){var u=f.frag,l=f.payload,p=this.initPTS,c=this.unparsedVttFrags;if(u.type===g.PlaylistLevelType.SUBTITLE)if(l.byteLength){if(!Object(B.isFiniteNumber)(p[u.cc])){c.push(f),p.length&&this.hls.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:u,error:new Error("Missing initial subtitle PTS")});return}var i=u.decryptdata;if(i==null||i.key==null||i.method!=="AES-128"){var r=this.tracks[u.level],t=this.vttCCs;t[u.cc]||(t[u.cc]={start:u.start,prevCC:this.prevCC,new:!0},this.prevCC=u.cc),r&&r.textCodec===w.IMSC1_CODEC?this._parseIMSC1(u,l):this._parseVTTs(u,l,t)}}else this.hls.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:u,error:new Error("Empty subtitle payload")})},e._parseIMSC1=function(o,f){var u=this,l=this.hls;Object(w.parseIMSC1)(f,this.initPTS[o.cc],this.timescale[o.cc],function(p){u._appendCues(p,o.level),l.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:o})},function(p){x.logger.log("Failed to parse IMSC1: "+p),l.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:p})})},e._parseVTTs=function(o,f,u){var l=this,p=this.hls;Object(M.parseWebVTT)(f,this.initPTS[o.cc],this.timescale[o.cc],u,o.cc,o.start,function(c){l._appendCues(c,o.level),p.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:o})},function(c){l._fallbackToIMSC1(o,f),x.logger.log("Failed to parse VTT cue: "+c),p.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:c})})},e._fallbackToIMSC1=function(o,f){var u=this,l=this.tracks[o.level];l.textCodec||Object(w.parseIMSC1)(f,this.initPTS[o.cc],this.timescale[o.cc],function(){l.textCodec=w.IMSC1_CODEC,u._parseIMSC1(o,f)},function(){l.textCodec="wvtt"})},e._appendCues=function(o,f){var u=this.hls;if(this.config.renderTextTracksNatively){var l=this.textTracks[f];if(l.mode==="disabled")return;o.forEach(function(i){return Object(A.addCueToTrack)(l,i)})}else{var p=this.tracks[f],c=p.default?"default":"subtitles"+f;u.trigger(O.Events.CUES_PARSED,{type:"subtitles",cues:o,track:c})}},e.onFragDecrypted=function(o,f){var u=f.frag;if(u.type===g.PlaylistLevelType.SUBTITLE){if(!Object(B.isFiniteNumber)(this.initPTS[u.cc])){this.unparsedVttFrags.push(f);return}this.onFragLoaded(O.Events.FRAG_LOADED,f)}},e.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},e.onFragParsingUserdata=function(o,f){var u=this.cea608Parser1,l=this.cea608Parser2;if(!this.enabled||!(u&&l))return;for(var p=0;p<f.samples.length;p++){var c=f.samples[p].bytes;if(c){var i=this.extractCea608Data(c);u.addData(f.samples[p].pts,i[0]),l.addData(f.samples[p].pts,i[1])}}},e.onBufferFlushing=function(o,f){var u=f.startOffset,l=f.endOffset,p=f.endOffsetSubtitles,c=f.type,i=this.media;if(!i||i.currentTime<l)return;if(!c||c==="video"){var r=this.captionsTracks;Object.keys(r).forEach(function(a){return Object(A.removeCuesInRange)(r[a],u,l)})}if(this.config.renderTextTracksNatively&&(u===0&&p!==void 0)){var t=this.textTracks;Object.keys(t).forEach(function(a){return Object(A.removeCuesInRange)(t[a],u,p)})}},e.extractCea608Data=function(o){for(var f=o[0]&31,u=2,l=[[],[]],p=0;p<f;p++){var c=o[u++],i=127&o[u++],r=127&o[u++],t=(4&c)!==0,a=3&c;if(i===0&&r===0)continue;t&&((a===0||a===1)&&(l[a].push(i),l[a].push(r)))}return l},h}();function E(h,e){return h&&h.label===e.name&&!(h.textTrack1||h.textTrack2)}function b(h,e,s,o){return Math.min(e,o)-Math.max(h,s)}function y(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return B});var B=function(){function O(_,M){this.subtle=void 0,this.aesIV=void 0,this.subtle=_,this.aesIV=M}var L=O.prototype;return L.decrypt=function(M,A){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},A,M)},O}()},"./src/crypt/aes-decryptor.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"removePadding",function(){return O}),C.d(U,"default",function(){return L});var B=C("./src/utils/typed-array.ts");function O(_){var M=_.byteLength,A=M&&new DataView(_.buffer).getUint8(M-1);return A?Object(B.sliceUint8)(_,0,M-A):_}var L=function(){function _(){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 M=_.prototype;return M.uint8ArrayToUint32Array_=function(w){for(var g=new DataView(w),x=new Uint32Array(4),S=0;S<4;S++)x[S]=g.getUint32(S*4);return x},M.initTable=function(){var w=this.sBox,g=this.invSBox,x=this.subMix,S=x[0],E=x[1],b=x[2],y=x[3],h=this.invSubMix,e=h[0],s=h[1],o=h[2],f=h[3],u=new Uint32Array(256),l=0,p=0,c=0;for(c=0;c<256;c++)c<128?u[c]=c<<1:u[c]=c<<1^283;for(c=0;c<256;c++){var i=p^p<<1^p<<2^p<<3^p<<4;i=i>>>8^i&255^99,w[l]=i,g[i]=l;var r=u[l],t=u[r],a=u[t],m=u[i]*257^i*16843008;S[l]=m<<24|m>>>8,E[l]=m<<16|m>>>16,b[l]=m<<8|m>>>24,y[l]=m,m=a*16843009^t*65537^r*257^l*16843008,e[i]=m<<24|m>>>8,s[i]=m<<16|m>>>16,o[i]=m<<8|m>>>24,f[i]=m,l?(l=r^u[u[u[a^r]]],p^=u[u[p]]):l=p=1}},M.expandKey=function(w){for(var g=this.uint8ArrayToUint32Array_(w),x=!0,S=0;S<g.length&&x;)x=g[S]===this.key[S],S++;if(x)return;this.key=g;var E=this.keySize=g.length;if(E!==4&&E!==6&&E!==8)throw new Error("Invalid aes key size="+E);var b=this.ksRows=(E+6+1)*4,y,h,e=this.keySchedule=new Uint32Array(b),s=this.invKeySchedule=new Uint32Array(b),o=this.sBox,f=this.rcon,u=this.invSubMix,l=u[0],p=u[1],c=u[2],i=u[3],r,t;for(y=0;y<b;y++){if(y<E){r=e[y]=g[y];continue}t=r,y%E===0?(t=t<<8|t>>>24,t=o[t>>>24]<<24|o[t>>>16&255]<<16|o[t>>>8&255]<<8|o[t&255],t^=f[y/E|0]<<24):E>6&&y%E===4&&(t=o[t>>>24]<<24|o[t>>>16&255]<<16|o[t>>>8&255]<<8|o[t&255]),e[y]=r=(e[y-E]^t)>>>0}for(h=0;h<b;h++)y=b-h,h&3?t=e[y]:t=e[y-4],h<4||y<=4?s[h]=t:s[h]=l[o[t>>>24]]^p[o[t>>>16&255]]^c[o[t>>>8&255]]^i[o[t&255]],s[h]=s[h]>>>0},M.networkToHostOrderSwap=function(w){return w<<24|(w&65280)<<8|(w&16711680)>>8|w>>>24},M.decrypt=function(w,g,x){for(var S=this.keySize+6,E=this.invKeySchedule,b=this.invSBox,y=this.invSubMix,h=y[0],e=y[1],s=y[2],o=y[3],f=this.uint8ArrayToUint32Array_(x),u=f[0],l=f[1],p=f[2],c=f[3],i=new Int32Array(w),r=new Int32Array(i.length),t,a,m,v,T,k,I,F,K,V,Q,Z,ie,ge,se=this.networkToHostOrderSwap;g<i.length;){for(K=se(i[g]),V=se(i[g+1]),Q=se(i[g+2]),Z=se(i[g+3]),T=K^E[0],k=Z^E[1],I=Q^E[2],F=V^E[3],ie=4,ge=1;ge<S;ge++)t=h[T>>>24]^e[k>>16&255]^s[I>>8&255]^o[F&255]^E[ie],a=h[k>>>24]^e[I>>16&255]^s[F>>8&255]^o[T&255]^E[ie+1],m=h[I>>>24]^e[F>>16&255]^s[T>>8&255]^o[k&255]^E[ie+2],v=h[F>>>24]^e[T>>16&255]^s[k>>8&255]^o[I&255]^E[ie+3],T=t,k=a,I=m,F=v,ie=ie+4;t=b[T>>>24]<<24^b[k>>16&255]<<16^b[I>>8&255]<<8^b[F&255]^E[ie],a=b[k>>>24]<<24^b[I>>16&255]<<16^b[F>>8&255]<<8^b[T&255]^E[ie+1],m=b[I>>>24]<<24^b[F>>16&255]<<16^b[T>>8&255]<<8^b[k&255]^E[ie+2],v=b[F>>>24]<<24^b[T>>16&255]<<16^b[k>>8&255]<<8^b[I&255]^E[ie+3],r[g]=se(t^u),r[g+1]=se(v^l),r[g+2]=se(m^p),r[g+3]=se(a^c),u=K,l=V,p=Q,c=Z,g=g+4}return r.buffer},_}()},"./src/crypt/decrypter.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return g});var B=C("./src/crypt/aes-crypto.ts"),O=C("./src/crypt/fast-aes-key.ts"),L=C("./src/crypt/aes-decryptor.ts"),_=C("./src/utils/logger.ts"),M=C("./src/utils/mp4-tools.ts"),A=C("./src/utils/typed-array.ts"),w=16,g=function(){function x(E,b,y){var h=y===void 0?{}:y,e=h.removePKCS7Padding,s=e===void 0?!0:e;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=E,this.config=b,this.removePKCS7Padding=s,s)try{var o=self.crypto;o&&(this.subtle=o.subtle||o.webkitSubtle)}catch(f){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var S=x.prototype;return S.destroy=function(){this.observer=null},S.isSync=function(){return this.config.enableSoftwareAES},S.flush=function(){var b=this.currentResult;if(!b){this.reset();return}var y=new Uint8Array(b);return this.reset(),this.removePKCS7Padding?Object(L.removePadding)(y):y},S.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},S.decrypt=function(b,y,h,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(b),y,h);var s=this.flush();s&&e(s.buffer)}else this.webCryptoDecrypt(new Uint8Array(b),y,h).then(e)},S.softwareDecrypt=function(b,y,h){var e=this.currentIV,s=this.currentResult,o=this.remainderData;this.logOnce("JS AES decrypt"),o&&(b=Object(M.appendUint8Array)(o,b),this.remainderData=null);var f=this.getValidChunk(b);if(!f.length)return null;e&&(h=e);var u=this.softwareDecrypter;u||(u=this.softwareDecrypter=new L.default),u.expandKey(y);var l=s;return this.currentResult=u.decrypt(f.buffer,0,h),this.currentIV=Object(A.sliceUint8)(f,-16).buffer,l||null},S.webCryptoDecrypt=function(b,y,h){var e=this,s=this.subtle;return(this.key!==y||!this.fastAesKey)&&(this.key=y,this.fastAesKey=new O.default(s,y)),this.fastAesKey.expandKey().then(function(o){if(!s)return Promise.reject(new Error("web crypto not initialized"));var f=new B.default(s,h);return f.decrypt(b.buffer,o)}).catch(function(o){return e.onWebCryptoError(o,b,y,h)})},S.onWebCryptoError=function(b,y,h,e){return _.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",b),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(y,h,e)},S.getValidChunk=function(b){var y=b,h=b.length-b.length%w;return h!==b.length&&(y=Object(A.sliceUint8)(b,0,h),this.remainderData=Object(A.sliceUint8)(b,h)),y},S.logOnce=function(b){if(!this.logEnabled)return;_.logger.log("[decrypter.ts]: "+b),this.logEnabled=!1},x}()},"./src/crypt/fast-aes-key.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return B});var B=function(){function O(_,M){this.subtle=void 0,this.key=void 0,this.subtle=_,this.key=M}var L=O.prototype;return L.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},O}()},"./src/demux/aacdemuxer.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/demux/base-audio-demuxer.ts"),O=C("./src/demux/adts.ts"),L=C("./src/utils/logger.ts"),_=C("./src/demux/id3.ts");function M(g,x){g.prototype=Object.create(x.prototype),g.prototype.constructor=g,A(g,x)}function A(g,x){return A=Object.setPrototypeOf||function(E,b){return E.__proto__=b,E},A(g,x)}var w=function(g){M(x,g);function x(E,b){var y;return y=g.call(this)||this,y.observer=void 0,y.config=void 0,y.observer=E,y.config=b,y}var S=x.prototype;return S.resetInitSegment=function(b,y,h){g.prototype.resetInitSegment.call(this,b,y,h),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:b,duration:h,inputTimeScale:9e4,dropped:0}},x.probe=function(b){if(!b)return!1;for(var y=_.getID3Data(b,0)||[],h=y.length,e=b.length;h<e;h++)if(O.probe(b,h))return L.logger.log("ADTS sync word found !"),!0;return!1},S.canParse=function(b,y){return O.canParse(b,y)},S.appendFrame=function(b,y,h){O.initTrackConfig(b,this.observer,y,h,b.manifestCodec);var e=O.appendFrame(b,y,h,this.initPTS,this.frameIndex);if(e&&e.missing===0)return e},x}(B.default);w.minProbeByteLength=9,U.default=w},"./src/demux/adts.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"getAudioConfig",function(){return _}),C.d(U,"isHeaderPattern",function(){return M}),C.d(U,"getHeaderLength",function(){return A}),C.d(U,"getFullFrameLength",function(){return w}),C.d(U,"canGetFrameLength",function(){return g}),C.d(U,"isHeader",function(){return x}),C.d(U,"canParse",function(){return S}),C.d(U,"probe",function(){return E}),C.d(U,"initTrackConfig",function(){return b}),C.d(U,"getFrameDuration",function(){return y}),C.d(U,"parseFrameHeader",function(){return h}),C.d(U,"appendFrame",function(){return e});var B=C("./src/utils/logger.ts"),O=C("./src/errors.ts"),L=C("./src/events.ts");function _(s,o,f,u){var l,p,c,i,r=navigator.userAgent.toLowerCase(),t=u,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];l=((o[f+2]&192)>>>6)+1;var m=(o[f+2]&60)>>>2;if(m>a.length-1){s.trigger(L.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+m});return}return c=(o[f+2]&1)<<2,c|=(o[f+3]&192)>>>6,B.logger.log("manifest codec:"+u+", ADTS type:"+l+", samplingIndex:"+m),/firefox/i.test(r)?m>=6?(l=5,i=new Array(4),p=m-3):(l=2,i=new Array(2),p=m):r.indexOf("android")!==-1?(l=2,i=new Array(2),p=m):(l=5,i=new Array(4),u&&(u.indexOf("mp4a.40.29")!==-1||u.indexOf("mp4a.40.5")!==-1)||!u&&m>=6?p=m-3:((u&&u.indexOf("mp4a.40.2")!==-1&&(m>=6&&c===1||/vivaldi/i.test(r))||!u&&c===1)&&(l=2,i=new Array(2)),p=m)),i[0]=l<<3,i[0]|=(m&14)>>1,i[1]|=(m&1)<<7,i[1]|=c<<3,l===5&&(i[1]|=(p&14)>>1,i[2]=(p&1)<<7,i[2]|=2<<2,i[3]=0),{config:i,samplerate:a[m],channelCount:c,codec:"mp4a.40."+l,manifestCodec:t}}function M(s,o){return s[o]===255&&(s[o+1]&246)===240}function A(s,o){return s[o+1]&1?7:9}function w(s,o){return(s[o+3]&3)<<11|s[o+4]<<3|(s[o+5]&224)>>>5}function g(s,o){return o+5<s.length}function x(s,o){return o+1<s.length&&M(s,o)}function S(s,o){return g(s,o)&&M(s,o)&&w(s,o)<=s.length-o}function E(s,o){if(x(s,o)){var f=A(s,o);if(o+f>=s.length)return!1;var u=w(s,o);if(u<=f)return!1;var l=o+u;return l===s.length||x(s,l)}return!1}function b(s,o,f,u,l){if(!s.samplerate){var p=_(o,f,u,l);if(!p)return;s.config=p.config,s.samplerate=p.samplerate,s.channelCount=p.channelCount,s.codec=p.codec,s.manifestCodec=p.manifestCodec,B.logger.log("parsed codec:"+s.codec+", rate:"+p.samplerate+", channels:"+p.channelCount)}}function y(s){return 1024*9e4/s}function h(s,o,f,u,l){var p=A(s,o),c=w(s,o);if(c-=p,c>0){var i=f+u*l;return{headerLength:p,frameLength:c,stamp:i}}}function e(s,o,f,u,l){var p=y(s.samplerate),c=h(o,f,u,l,p);if(c){var i=c.frameLength,r=c.headerLength,t=c.stamp,a=r+i,m=Math.max(0,f+a-o.length),v;m?(v=new Uint8Array(a-r),v.set(o.subarray(f+r,o.length),0)):v=o.subarray(f+r,f+a);var T={unit:v,pts:t};return m||s.samples.push(T),{sample:T,length:a,missing:m}}}},"./src/demux/base-audio-demuxer.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"initPTSFn",function(){return w});var B=C("./src/polyfills/number.ts"),O=C("./src/demux/id3.ts"),L=C("./src/demux/dummy-demuxed-track.ts"),_=C("./src/utils/mp4-tools.ts"),M=C("./src/utils/typed-array.ts"),A=function(){function g(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var x=g.prototype;return x.resetInitSegment=function(E,b,y){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},x.resetTimeStamp=function(){},x.resetContiguity=function(){},x.canParse=function(E,b){return!1},x.appendFrame=function(E,b,y){},x.demux=function(E,b){this.cachedData&&(E=Object(_.appendUint8Array)(this.cachedData,E),this.cachedData=null);var y=O.getID3Data(E,0),h=y?y.length:0,e,s,o=this._audioTrack,f=this._id3Track,u=y?O.getTimeStamp(y):void 0,l=E.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=w(u,b)),y&&y.length>0&&f.samples.push({pts:this.initPTS,dts:this.initPTS,data:y}),s=this.initPTS;h<l;){if(this.canParse(E,h)){var p=this.appendFrame(o,E,h);p?(this.frameIndex++,s=p.sample.pts,h+=p.length,e=h):h=l}else O.canParse(E,h)?(y=O.getID3Data(E,h),f.samples.push({pts:s,dts:s,data:y}),h+=y.length,e=h):h++;if(h===l&&e!==l){var c=Object(M.sliceUint8)(E,e);this.cachedData?this.cachedData=Object(_.appendUint8Array)(this.cachedData,c):this.cachedData=c}}return{audioTrack:o,avcTrack:Object(L.dummyTrack)(),id3Track:f,textTrack:Object(L.dummyTrack)()}},x.demuxSampleAes=function(E,b,y){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},x.flush=function(E){var b=this.cachedData;return b&&(this.cachedData=null,this.demux(b,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(L.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(L.dummyTrack)()}},x.destroy=function(){},g}(),w=function(x,S){return Object(B.isFiniteNumber)(x)?x*90:S*9e4};U.default=A},"./src/demux/chunk-cache.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return B});var B=function(){function L(){this.chunks=[],this.dataLength=0}var _=L.prototype;return _.push=function(A){this.chunks.push(A),this.dataLength+=A.length},_.flush=function(){var A=this.chunks,w=this.dataLength,g;if(A.length)A.length===1?g=A[0]:g=O(A,w);else return new Uint8Array(0);return this.reset(),g},_.reset=function(){this.chunks.length=0,this.dataLength=0},L}();function O(L,_){for(var M=new Uint8Array(_),A=0,w=0;w<L.length;w++){var g=L[w];M.set(g,A),A+=g.length}return M}},"./src/demux/dummy-demuxed-track.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"dummyTrack",function(){return B});function B(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/utils/logger.ts"),O=function(){function L(M){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=M,this.bytesAvailable=M.byteLength,this.word=0,this.bitsAvailable=0}var _=L.prototype;return _.loadWord=function(){var A=this.data,w=this.bytesAvailable,g=A.byteLength-w,x=new Uint8Array(4),S=Math.min(4,w);if(S===0)throw new Error("no bytes available");x.set(A.subarray(g,g+S)),this.word=new DataView(x.buffer).getUint32(0),this.bitsAvailable=S*8,this.bytesAvailable-=S},_.skipBits=function(A){var w;this.bitsAvailable>A?(this.word<<=A,this.bitsAvailable-=A):(A-=this.bitsAvailable,w=A>>3,A-=w>>3,this.bytesAvailable-=w,this.loadWord(),this.word<<=A,this.bitsAvailable-=A)},_.readBits=function(A){var w=Math.min(this.bitsAvailable,A),g=this.word>>>32-w;return A>32&&B.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=w,this.bitsAvailable>0?this.word<<=w:this.bytesAvailable>0&&this.loadWord(),w=A-w,w>0&&this.bitsAvailable?g<<w|this.readBits(w):g},_.skipLZ=function(){var A;for(A=0;A<this.bitsAvailable;++A)if((this.word&2147483648>>>A)!==0)return this.word<<=A,this.bitsAvailable-=A,A;return this.loadWord(),A+this.skipLZ()},_.skipUEG=function(){this.skipBits(1+this.skipLZ())},_.skipEG=function(){this.skipBits(1+this.skipLZ())},_.readUEG=function(){var A=this.skipLZ();return this.readBits(A+1)-1},_.readEG=function(){var A=this.readUEG();return 1&A?1+A>>>1:-1*(A>>>1)},_.readBoolean=function(){return this.readBits(1)===1},_.readUByte=function(){return this.readBits(8)},_.readUShort=function(){return this.readBits(16)},_.readUInt=function(){return this.readBits(32)},_.skipScalingList=function(A){for(var w=8,g=8,x,S=0;S<A;S++)g!==0&&(x=this.readEG(),g=(w+x+256)%256),w=g===0?w:g},_.readSPS=function(){var A=0,w=0,g=0,x=0,S,E,b,y=this.readUByte.bind(this),h=this.readBits.bind(this),e=this.readUEG.bind(this),s=this.readBoolean.bind(this),o=this.skipBits.bind(this),f=this.skipEG.bind(this),u=this.skipUEG.bind(this),l=this.skipScalingList.bind(this);y();var p=y();if(h(5),o(3),y(),u(),p===100||p===110||p===122||p===244||p===44||p===83||p===86||p===118||p===128){var c=e();if(c===3&&o(1),u(),u(),o(1),s())for(E=c!==3?8:12,b=0;b<E;b++)s()&&(b<6?l(16):l(64))}u();var i=e();if(i===0)e();else if(i===1)for(o(1),f(),f(),S=e(),b=0;b<S;b++)f();u(),o(1);var r=e(),t=e(),a=h(1);a===0&&o(1),o(1),s()&&(A=e(),w=e(),g=e(),x=e());var m=[1,1];if(s()&&s()){var v=y();switch(v){case 1:m=[1,1];break;case 2:m=[12,11];break;case 3:m=[10,11];break;case 4:m=[16,11];break;case 5:m=[40,33];break;case 6:m=[24,11];break;case 7:m=[20,11];break;case 8:m=[32,11];break;case 9:m=[80,33];break;case 10:m=[18,11];break;case 11:m=[15,11];break;case 12:m=[64,33];break;case 13:m=[160,99];break;case 14:m=[4,3];break;case 15:m=[3,2];break;case 16:m=[2,1];break;case 255:{m=[y()<<8|y(),y()<<8|y()];break}}}return{width:Math.ceil((r+1)*16-A*2-w*2),height:(2-a)*(t+1)*16-(a?2:4)*(g+x),pixelRatio:m}},_.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},L}();U.default=O},"./src/demux/id3.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"isHeader",function(){return B}),C.d(U,"isFooter",function(){return O}),C.d(U,"getID3Data",function(){return L}),C.d(U,"canParse",function(){return M}),C.d(U,"getTimeStamp",function(){return A}),C.d(U,"isTimeStampFrame",function(){return w}),C.d(U,"getID3Frames",function(){return x}),C.d(U,"decodeFrame",function(){return S}),C.d(U,"utf8ArrayToStr",function(){return e}),C.d(U,"testables",function(){return s});var B=function(l,p){return p+10<=l.length&&(l[p]===73&&l[p+1]===68&&l[p+2]===51&&(l[p+3]<255&&l[p+4]<255&&(l[p+6]<128&&l[p+7]<128&&l[p+8]<128&&l[p+9]<128)))},O=function(l,p){return p+10<=l.length&&(l[p]===51&&l[p+1]===68&&l[p+2]===73&&(l[p+3]<255&&l[p+4]<255&&(l[p+6]<128&&l[p+7]<128&&l[p+8]<128&&l[p+9]<128)))},L=function(l,p){for(var c=p,i=0;B(l,p);){i+=10;var r=_(l,p+6);i+=r,O(l,p+10)&&(i+=10),p+=i}return i>0?l.subarray(c,c+i):void 0},_=function(l,p){var c=0;return c=(l[p]&127)<<21,c|=(l[p+1]&127)<<14,c|=(l[p+2]&127)<<7,c|=l[p+3]&127,c},M=function(l,p){return B(l,p)&&_(l,p+6)+10<=l.length-p},A=function(l){for(var p=x(l),c=0;c<p.length;c++){var i=p[c];if(w(i))return h(i)}return},w=function(l){return l&&l.key==="PRIV"&&l.info==="com.apple.streaming.transportStreamTimestamp"},g=function(l){var p=String.fromCharCode(l[0],l[1],l[2],l[3]),c=_(l,4),i=10;return{type:p,size:c,data:l.subarray(i,i+c)}},x=function(l){for(var p=0,c=[];B(l,p);){var i=_(l,p+6);p+=10;for(var r=p+i;p+8<r;){var t=g(l.subarray(p)),a=S(t);a&&c.push(a),p+=t.size+10}O(l,p)&&(p+=10)}return c},S=function(l){return l.type==="PRIV"?E(l):l.type[0]==="W"?y(l):b(l)},E=function(l){if(l.size<2)return;var p=e(l.data,!0),c=new Uint8Array(l.data.subarray(p.length+1));return{key:l.type,info:p,data:c.buffer}},b=function(l){if(l.size<2)return;if(l.type==="TXXX"){var p=1,c=e(l.data.subarray(p),!0);p+=c.length+1;var i=e(l.data.subarray(p));return{key:l.type,info:c,data:i}}var r=e(l.data.subarray(1));return{key:l.type,data:r}},y=function(l){if(l.type==="WXXX"){if(l.size<2)return;var p=1,c=e(l.data.subarray(p),!0);p+=c.length+1;var i=e(l.data.subarray(p));return{key:l.type,info:c,data:i}}var r=e(l.data);return{key:l.type,data:r}},h=function(l){if(l.data.byteLength===8){var p=new Uint8Array(l.data),c=p[3]&1,i=(p[4]<<23)+(p[5]<<15)+(p[6]<<7)+p[7];return i/=45,c&&(i+=4772185884e-2),Math.round(i)}return},e=function(l,p){p===void 0&&(p=!1);var c=f();if(c){var i=c.decode(l);if(p){var r=i.indexOf("\0");return r!==-1?i.substring(0,r):i}return i.replace(/\0/g,"")}for(var t=l.length,a,m,v,T="",k=0;k<t;){if(a=l[k++],a===0&&p)return T;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:T+=String.fromCharCode(a);break;case 12:case 13:m=l[k++],T+=String.fromCharCode((a&31)<<6|m&63);break;case 14:m=l[k++],v=l[k++],T+=String.fromCharCode((a&15)<<12|(m&63)<<6|(v&63)<<0);break;default:}}return T},s={decodeTextFrame:b},o;function f(){return!o&&typeof self.TextDecoder!="undefined"&&(o=new self.TextDecoder("utf-8")),o}},"./src/demux/mp3demuxer.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/demux/base-audio-demuxer.ts"),O=C("./src/demux/id3.ts"),L=C("./src/utils/logger.ts"),_=C("./src/demux/mpegaudio.ts");function M(g,x){g.prototype=Object.create(x.prototype),g.prototype.constructor=g,A(g,x)}function A(g,x){return A=Object.setPrototypeOf||function(E,b){return E.__proto__=b,E},A(g,x)}var w=function(g){M(x,g);function x(){return g.apply(this,arguments)||this}var S=x.prototype;return S.resetInitSegment=function(b,y,h){g.prototype.resetInitSegment.call(this,b,y,h),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:b,duration:h,inputTimeScale:9e4,dropped:0}},x.probe=function(b){if(!b)return!1;for(var y=O.getID3Data(b,0)||[],h=y.length,e=b.length;h<e;h++)if(_.probe(b,h))return L.logger.log("MPEG Audio sync word found !"),!0;return!1},S.canParse=function(b,y){return _.canParse(b,y)},S.appendFrame=function(b,y,h){return this.initPTS===null?void 0:_.appendFrame(b,y,h,this.initPTS,this.frameIndex)},x}(B.default);w.minProbeByteLength=4,U.default=w},"./src/demux/mp4demuxer.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/utils/mp4-tools.ts"),O=C("./src/demux/dummy-demuxed-track.ts"),L=function(){function _(A,w){this.remainderData=null,this.config=void 0,this.config=w}var M=_.prototype;return M.resetTimeStamp=function(){},M.resetInitSegment=function(){},M.resetContiguity=function(){},_.probe=function(w){return Object(B.findBox)({data:w,start:0,end:Math.min(w.length,16384)},["moof"]).length>0},M.demux=function(w){var g=w,x=Object(O.dummyTrack)();if(this.config.progressive){this.remainderData&&(g=Object(B.appendUint8Array)(this.remainderData,w));var S=Object(B.segmentValidRange)(g);this.remainderData=S.remainder,x.samples=S.valid||new Uint8Array}else x.samples=g;return{audioTrack:Object(O.dummyTrack)(),avcTrack:x,id3Track:Object(O.dummyTrack)(),textTrack:Object(O.dummyTrack)()}},M.flush=function(){var w=Object(O.dummyTrack)();return w.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(O.dummyTrack)(),avcTrack:w,id3Track:Object(O.dummyTrack)(),textTrack:Object(O.dummyTrack)()}},M.demuxSampleAes=function(w,g,x){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},M.destroy=function(){},_}();L.minProbeByteLength=1024,U.default=L},"./src/demux/mpegaudio.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"appendFrame",function(){return A}),C.d(U,"parseHeader",function(){return w}),C.d(U,"isHeaderPattern",function(){return g}),C.d(U,"isHeader",function(){return x}),C.d(U,"canParse",function(){return S}),C.d(U,"probe",function(){return E});var B=null,O=[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],L=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],_=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],M=[0,1,1,4];function A(b,y,h,e,s){if(h+24>y.length)return;var o=w(y,h);if(o&&h+o.frameLength<=y.length){var f=o.samplesPerFrame*9e4/o.sampleRate,u=e+s*f,l={unit:y.subarray(h,h+o.frameLength),pts:u,dts:u};return b.config=[],b.channelCount=o.channelCount,b.samplerate=o.sampleRate,b.samples.push(l),{sample:l,length:o.frameLength,missing:0}}}function w(b,y){var h=b[y+1]>>3&3,e=b[y+1]>>1&3,s=b[y+2]>>4&15,o=b[y+2]>>2&3;if(h!==1&&s!==0&&s!==15&&o!==3){var f=b[y+2]>>1&1,u=b[y+3]>>6,l=h===3?3-e:e===3?3:4,p=O[l*14+s-1]*1e3,c=h===3?0:h===2?1:2,i=L[c*3+o],r=u===3?1:2,t=_[h][e],a=M[e],m=t*8*a,v=Math.floor(t*p/i+f)*a;if(B===null){var T=navigator.userAgent||"",k=T.match(/Chrome\/(\d+)/i);B=k?parseInt(k[1]):0}var I=!!B&&B<=87;return I&&e===2&&p>=224e3&&u===0&&(b[y+3]=b[y+3]|128),{sampleRate:i,channelCount:r,frameLength:v,samplesPerFrame:m}}}function g(b,y){return b[y]===255&&(b[y+1]&224)===224&&(b[y+1]&6)!==0}function x(b,y){return y+1<b.length&&g(b,y)}function S(b,y){var h=4;return g(b,y)&&h<=b.length-y}function E(b,y){if(y+1<b.length&&g(b,y)){var h=4,e=w(b,y),s=h;e!=null&&e.frameLength&&(s=e.frameLength);var o=y+s;return o===b.length||x(b,o)}return!1}},"./src/demux/sample-aes.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/crypt/decrypter.ts"),O=C("./src/demux/tsdemuxer.ts"),L=function(){function _(A,w,g){this.keyData=void 0,this.decrypter=void 0,this.keyData=g,this.decrypter=new B.default(A,w,{removePKCS7Padding:!1})}var M=_.prototype;return M.decryptBuffer=function(w,g){this.decrypter.decrypt(w,this.keyData.key.buffer,this.keyData.iv.buffer,g)},M.decryptAacSample=function(w,g,x,S){var E=w[g].unit,b=E.subarray(16,E.length-E.length%16),y=b.buffer.slice(b.byteOffset,b.byteOffset+b.length),h=this;this.decryptBuffer(y,function(e){var s=new Uint8Array(e);E.set(s,16),S||h.decryptAacSamples(w,g+1,x)})},M.decryptAacSamples=function(w,g,x){for(;;g++){if(g>=w.length){x();return}if(w[g].unit.length<32)continue;var S=this.decrypter.isSync();if(this.decryptAacSample(w,g,x,S),!S)return}},M.getAvcEncryptedData=function(w){for(var g=Math.floor((w.length-48)/160)*16+16,x=new Int8Array(g),S=0,E=32;E<=w.length-16;E+=160,S+=16)x.set(w.subarray(E,E+16),S);return x},M.getAvcDecryptedUnit=function(w,g){for(var x=new Uint8Array(g),S=0,E=32;E<=w.length-16;E+=160,S+=16)w.set(x.subarray(S,S+16),E);return w},M.decryptAvcSample=function(w,g,x,S,E,b){var y=Object(O.discardEPB)(E.data),h=this.getAvcEncryptedData(y),e=this;this.decryptBuffer(h.buffer,function(s){E.data=e.getAvcDecryptedUnit(y,s),b||e.decryptAvcSamples(w,g,x+1,S)})},M.decryptAvcSamples=function(w,g,x,S){if(w instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;g++,x=0){if(g>=w.length){S();return}for(var E=w[g].units;!(x>=E.length);x++){var b=E[x];if(b.data.length<=48||b.type!==1&&b.type!==5)continue;var y=this.decrypter.isSync();if(this.decryptAvcSample(w,g,x,S,b,y),!y)return}}},_}();U.default=L},"./src/demux/transmuxer-interface.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return E});var B=C("./node_modules/webworkify-webpack/index.js"),O=C.n(B),L=C("./src/events.ts"),_=C("./src/demux/transmuxer.ts"),M=C("./src/utils/logger.ts"),A=C("./src/errors.ts"),w=C("./src/utils/mediasource-helper.ts"),g=C("./node_modules/eventemitter3/index.js"),x=C.n(g),S=Object(w.getMediaSource)()||{isTypeSupported:function(){return!1}},E=function(){function b(h,e,s,o){var f=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=h,this.id=e,this.onTransmuxComplete=s,this.onFlush=o;var u=h.config,l=function(t,a){a=a||{},a.frag=f.frag,a.id=f.id,h.trigger(t,a)};this.observer=new g.EventEmitter,this.observer.on(L.Events.FRAG_DECRYPTED,l),this.observer.on(L.Events.ERROR,l);var p={mp4:S.isTypeSupported("video/mp4"),mpeg:S.isTypeSupported("audio/mpeg"),mp3:S.isTypeSupported('audio/mp4; codecs="mp3"')},c=navigator.vendor;if(u.enableWorker&&typeof Worker!="undefined"){M.logger.log("demuxing in webworker");var i;try{i=this.worker=B("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),i.addEventListener("message",this.onwmsg),i.onerror=function(r){h.trigger(L.Events.ERROR,{type:A.ErrorTypes.OTHER_ERROR,details:A.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(r.message+" ("+r.filename+":"+r.lineno+")")})},i.postMessage({cmd:"init",typeSupported:p,vendor:c,id:e,config:JSON.stringify(u)})}catch(r){M.logger.warn("Error in worker:",r),M.logger.error("Error while initializing DemuxerWorker, fallback to inline"),i&&self.URL.revokeObjectURL(i.objectURL),this.transmuxer=new _.default(this.observer,p,u,c,e),this.worker=null}}else this.transmuxer=new _.default(this.observer,p,u,c,e)}var y=b.prototype;return y.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null;else{var s=this.transmuxer;s&&(s.destroy(),this.transmuxer=null)}var o=this.observer;o&&o.removeAllListeners(),this.observer=null},y.push=function(e,s,o,f,u,l,p,c,i,r){var t=this;i.transmuxing.start=self.performance.now();var a=this.transmuxer,m=this.worker,v=l?l.start:u.start,T=u.decryptdata,k=this.frag,I=!(k&&u.cc===k.cc),F=!(k&&i.level===k.level),K=k?i.sn-k.sn:-1,V=this.part?i.part-this.part.index:1,Q=!F&&(K===1||K===0&&V===1),Z=self.performance.now();(F||K||u.stats.parsing.start===0)&&(u.stats.parsing.start=Z),l&&(V||!Q)&&(l.stats.parsing.start=Z);var ie=new _.TransmuxState(I,Q,c,F,v);if(!Q||I){M.logger.log("[transmuxer-interface, "+u.type+"]: Starting new transmux session for sn: "+i.sn+" p: "+i.part+" level: "+i.level+" id: "+i.id+`
|
|
discontinuity: `+I+`
|
|
trackSwitch: `+F+`
|
|
contiguous: `+Q+`
|
|
accurateTimeOffset: `+c+`
|
|
timeOffset: `+v);var ge=new _.TransmuxConfig(o,f,s,p,r);this.configureTransmuxer(ge)}if(this.frag=u,this.part=l,m)m.postMessage({cmd:"demux",data:e,decryptdata:T,chunkMeta:i,state:ie},e instanceof ArrayBuffer?[e]:[]);else if(a){var se=a.push(e,T,i,ie);Object(_.isPromise)(se)?se.then(function(he){t.handleTransmuxComplete(he)}):this.handleTransmuxComplete(se)}},y.flush=function(e){var s=this;e.transmuxing.start=self.performance.now();var o=this.transmuxer,f=this.worker;if(f)f.postMessage({cmd:"flush",chunkMeta:e});else if(o){var u=o.flush(e);Object(_.isPromise)(u)?u.then(function(l){s.handleFlushResult(l,e)}):this.handleFlushResult(u,e)}},y.handleFlushResult=function(e,s){var o=this;e.forEach(function(f){o.handleTransmuxComplete(f)}),this.onFlush(s)},y.onWorkerMessage=function(e){var s=e.data,o=this.hls;switch(s.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(s.data);break}case"flush":{this.onFlush(s.data);break}default:{s.data=s.data||{},s.data.frag=this.frag,s.data.id=this.id,o.trigger(s.event,s.data);break}}},y.configureTransmuxer=function(e){var s=this.worker,o=this.transmuxer;s?s.postMessage({cmd:"configure",config:e}):o&&o.configure(e)},y.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},b}()},"./src/demux/transmuxer-worker.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return A});var B=C("./src/demux/transmuxer.ts"),O=C("./src/events.ts"),L=C("./src/utils/logger.ts"),_=C("./node_modules/eventemitter3/index.js"),M=C.n(_);function A(E){var b=new _.EventEmitter,y=function(e,s){E.postMessage({event:e,data:s})};b.on(O.Events.FRAG_DECRYPTED,y),b.on(O.Events.ERROR,y),E.addEventListener("message",function(h){var e=h.data;switch(e.cmd){case"init":{var s=JSON.parse(e.config);E.transmuxer=new B.default(b,e.typeSupported,s,e.vendor,e.id),Object(L.enableLogs)(s.debug),y("init",null);break}case"configure":{E.transmuxer.configure(e.config);break}case"demux":{var o=E.transmuxer.push(e.data,e.decryptdata,e.chunkMeta,e.state);Object(B.isPromise)(o)?o.then(function(l){w(E,l)}):w(E,o);break}case"flush":{var f=e.chunkMeta,u=E.transmuxer.flush(f);Object(B.isPromise)(u)?u.then(function(l){x(E,l,f)}):x(E,u,f);break}default:break}})}function w(E,b){if(S(b.remuxResult))return;var y=[],h=b.remuxResult,e=h.audio,s=h.video;e&&g(y,e),s&&g(y,s),E.postMessage({event:"transmuxComplete",data:b},y)}function g(E,b){b.data1&&E.push(b.data1.buffer),b.data2&&E.push(b.data2.buffer)}function x(E,b,y){b.forEach(function(h){w(E,h)}),E.postMessage({event:"flush",data:y})}function S(E){return!E.audio&&!E.video&&!E.text&&!E.id3&&!E.initSegment}},"./src/demux/transmuxer.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return s}),C.d(U,"isPromise",function(){return u}),C.d(U,"TransmuxConfig",function(){return l}),C.d(U,"TransmuxState",function(){return p});var B=C("./src/events.ts"),O=C("./src/errors.ts"),L=C("./src/crypt/decrypter.ts"),_=C("./src/demux/aacdemuxer.ts"),M=C("./src/demux/mp4demuxer.ts"),A=C("./src/demux/tsdemuxer.ts"),w=C("./src/demux/mp3demuxer.ts"),g=C("./src/remux/mp4-remuxer.ts"),x=C("./src/remux/passthrough-remuxer.ts"),S=C("./src/demux/chunk-cache.ts"),E=C("./src/utils/mp4-tools.ts"),b=C("./src/utils/logger.ts"),y;try{y=self.performance.now.bind(self.performance)}catch(c){b.logger.debug("Unable to use Performance API on this environment"),y=self.Date.now}var h=[{demux:A.default,remux:g.default},{demux:M.default,remux:x.default},{demux:_.default,remux:g.default},{demux:w.default,remux:g.default}],e=1024;h.forEach(function(c){var i=c.demux;e=Math.max(e,i.minProbeByteLength)});var s=function(){function c(r,t,a,m,v){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new S.default,this.observer=r,this.typeSupported=t,this.config=a,this.vendor=m,this.id=v}var i=c.prototype;return i.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},i.push=function(t,a,m,v){var T=this,k=m.transmuxing;k.executeStart=y();var I=new Uint8Array(t),F=this.cache,K=this.config,V=this.currentTransmuxState,Q=this.transmuxConfig;v&&(this.currentTransmuxState=v);var Z=o(I,a);if(Z&&Z.method==="AES-128"){var ie=this.getDecrypter();if(K.enableSoftwareAES){var ge=ie.softwareDecrypt(I,Z.key.buffer,Z.iv.buffer);if(!ge)return k.executeEnd=y(),f(m);I=new Uint8Array(ge)}else return this.decryptionPromise=ie.webCryptoDecrypt(I,Z.key.buffer,Z.iv.buffer).then(function(pe){var Ee=T.push(pe,null,m);return T.decryptionPromise=null,Ee}),this.decryptionPromise}var se=v||V,he=se.contiguous,de=se.discontinuity,$=se.trackSwitch,Y=se.accurateTimeOffset,ne=se.timeOffset,z=Q.audioCodec,H=Q.videoCodec,me=Q.defaultInitPts,Le=Q.duration,Oe=Q.initSegmentData;if((de||$)&&this.resetInitSegment(Oe,z,H,Le),de&&this.resetInitialTimestamp(me),he||this.resetContiguity(),this.needsProbing(I,de,$)){if(F.dataLength){var we=F.flush();I=Object(E.appendUint8Array)(we,I)}this.configureTransmuxer(I,Q)}var De=this.transmux(I,Z,ne,Y,m),le=this.currentTransmuxState;return le.contiguous=!0,le.discontinuity=!1,le.trackSwitch=!1,k.executeEnd=y(),De},i.flush=function(t){var a=this,m=t.transmuxing;m.executeStart=y();var v=this.decrypter,T=this.cache,k=this.currentTransmuxState,I=this.decryptionPromise;if(I)return I.then(function(){return a.flush(t)});var F=[],K=k.timeOffset;if(v){var V=v.flush();V&&F.push(this.push(V,null,t))}var Q=T.dataLength;T.reset();var Z=this.demuxer,ie=this.remuxer;if(!Z||!ie)return Q>=e&&this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),m.executeEnd=y(),[f(t)];var ge=Z.flush(K);return u(ge)?ge.then(function(se){return a.flushRemux(F,se,t),F}):(this.flushRemux(F,ge,t),F)},i.flushRemux=function(t,a,m){var v=a.audioTrack,T=a.avcTrack,k=a.id3Track,I=a.textTrack,F=this.currentTransmuxState,K=F.accurateTimeOffset,V=F.timeOffset;b.logger.log("[transmuxer.ts]: Flushed fragment "+m.sn+(m.part>-1?" p: "+m.part:"")+" of level "+m.level);var Q=this.remuxer.remux(v,T,k,I,V,K,!0,this.id);t.push({remuxResult:Q,chunkMeta:m}),m.transmuxing.executeEnd=y()},i.resetInitialTimestamp=function(t){var a=this.demuxer,m=this.remuxer;if(!a||!m)return;a.resetTimeStamp(t),m.resetTimeStamp(t)},i.resetContiguity=function(){var t=this.demuxer,a=this.remuxer;if(!t||!a)return;t.resetContiguity(),a.resetNextTimestamp()},i.resetInitSegment=function(t,a,m,v){var T=this.demuxer,k=this.remuxer;if(!T||!k)return;T.resetInitSegment(a,m,v),k.resetInitSegment(t,a,m)},i.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},i.transmux=function(t,a,m,v,T){var k;return a&&a.method==="SAMPLE-AES"?k=this.transmuxSampleAes(t,a,m,v,T):k=this.transmuxUnencrypted(t,m,v,T),k},i.transmuxUnencrypted=function(t,a,m,v){var T=this.demuxer.demux(t,a,!1,!this.config.progressive),k=T.audioTrack,I=T.avcTrack,F=T.id3Track,K=T.textTrack,V=this.remuxer.remux(k,I,F,K,a,m,!1,this.id);return{remuxResult:V,chunkMeta:v}},i.transmuxSampleAes=function(t,a,m,v,T){var k=this;return this.demuxer.demuxSampleAes(t,a,m).then(function(I){var F=k.remuxer.remux(I.audioTrack,I.avcTrack,I.id3Track,I.textTrack,m,v,!1,k.id);return{remuxResult:F,chunkMeta:T}})},i.configureTransmuxer=function(t,a){for(var m=this.config,v=this.observer,T=this.typeSupported,k=this.vendor,I=a.audioCodec,F=a.defaultInitPts,K=a.duration,V=a.initSegmentData,Q=a.videoCodec,Z,ie=0,ge=h.length;ie<ge;ie++)if(h[ie].demux.probe(t)){Z=h[ie];break}Z||(b.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),Z={demux:M.default,remux:x.default});var se=this.demuxer,he=this.remuxer,de=Z.remux,$=Z.demux;(!he||!(he instanceof de))&&(this.remuxer=new de(v,m,T,k)),(!se||!(se instanceof $))&&(this.demuxer=new $(v,m,T),this.probe=$.probe),this.resetInitSegment(V,I,Q,K),this.resetInitialTimestamp(F)},i.needsProbing=function(t,a,m){return!this.demuxer||!this.remuxer||a||m},i.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new L.default(this.observer,this.config)),t},c}();function o(c,i){var r=null;return c.byteLength>0&&i!=null&&i.key!=null&&i.iv!==null&&i.method!=null&&(r=i),r}var f=function(i){return{remuxResult:{},chunkMeta:i}};function u(c){return"then"in c&&c.then instanceof Function}var l=function(i,r,t,a,m){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=i,this.videoCodec=r,this.initSegmentData=t,this.duration=a,this.defaultInitPts=m},p=function(i,r,t,a,m){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=i,this.contiguous=r,this.accurateTimeOffset=t,this.trackSwitch=a,this.timeOffset=m}},"./src/demux/tsdemuxer.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"discardEPB",function(){return f});var B=C("./src/demux/adts.ts"),O=C("./src/demux/mpegaudio.ts"),L=C("./src/demux/exp-golomb.ts"),_=C("./src/demux/id3.ts"),M=C("./src/demux/sample-aes.ts"),A=C("./src/events.ts"),w=C("./src/utils/mp4-tools.ts"),g=C("./src/utils/logger.ts"),x=C("./src/errors.ts"),S={video:1,audio:2,id3:3,text:4},E=function(){function u(p,c,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=p,this.config=c,this.typeSupported=i}u.probe=function(c){var i=u.syncOffset(c);return i<0?!1:(i&&g.logger.warn("MPEG2-TS detected but first sync word found @ offset "+i+", junk ahead ?"),!0)},u.syncOffset=function(c){for(var i=Math.min(1e3,c.length-3*188),r=0;r<i;){if(c[r]===71&&c[r+188]===71&&c[r+2*188]===71)return r;r++}return-1},u.createTrack=function(c,i){return{container:c==="video"||c==="audio"?"video/mp2t":void 0,type:c,id:S[c],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:c==="audio"?i:void 0}};var l=u.prototype;return l.resetInitSegment=function(c,i,r){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=u.createTrack("video",r),this._audioTrack=u.createTrack("audio",r),this._id3Track=u.createTrack("id3",r),this._txtTrack=u.createTrack("text",r),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=c,this.videoCodec=i,this._duration=r},l.resetTimeStamp=function(){},l.resetContiguity=function(){var c=this._audioTrack,i=this._avcTrack,r=this._id3Track;c&&(c.pesData=null),i&&(i.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},l.demux=function(c,i,r,t){r===void 0&&(r=!1),t===void 0&&(t=!1),r||(this.sampleAes=null);var a,m=this._avcTrack,v=this._audioTrack,T=this._id3Track,k=m.pid,I=m.pesData,F=v.pid,K=T.pid,V=v.pesData,Q=T.pesData,Z=!1,ie=this.pmtParsed,ge=this._pmtId,se=c.length;if(this.remainderData&&(c=Object(w.appendUint8Array)(this.remainderData,c),se=c.length,this.remainderData=null),se<188&&!t)return this.remainderData=c,{audioTrack:v,avcTrack:m,id3Track:T,textTrack:this._txtTrack};var he=Math.max(0,u.syncOffset(c));se-=(se+he)%188,se<c.byteLength&&!t&&(this.remainderData=new Uint8Array(c.buffer,se,c.buffer.byteLength-se));for(var de=he;de<se;de+=188)if(c[de]===71){var $=!!(c[de+1]&64),Y=((c[de+1]&31)<<8)+c[de+2],ne=(c[de+3]&48)>>4,z=void 0;if(ne>1){if(z=de+5+c[de+4],z===de+188)continue}else z=de+4;switch(Y){case k:$&&(I&&(a=e(I))&&this.parseAVCPES(a,!1),I={data:[],size:0}),I&&(I.data.push(c.subarray(z,de+188)),I.size+=de+188-z);break;case F:$&&(V&&(a=e(V))&&(v.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),V={data:[],size:0}),V&&(V.data.push(c.subarray(z,de+188)),V.size+=de+188-z);break;case K:$&&(Q&&(a=e(Q))&&this.parseID3PES(a),Q={data:[],size:0}),Q&&(Q.data.push(c.subarray(z,de+188)),Q.size+=de+188-z);break;case 0:$&&(z+=c[z]+1),ge=this._pmtId=y(c,z);break;case ge:{$&&(z+=c[z]+1);var H=h(c,z,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,r);k=H.avc,k>0&&(m.pid=k),F=H.audio,F>0&&(v.pid=F,v.isAAC=H.isAAC),K=H.id3,K>0&&(T.pid=K),Z&&!ie&&(g.logger.log("reparse from beginning"),Z=!1,de=he-188),ie=this.pmtParsed=!0;break}case 17:case 8191:break;default:Z=!0;break}}else this.observer.emit(A.Events.ERROR,A.Events.ERROR,{type:x.ErrorTypes.MEDIA_ERROR,details:x.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});m.pesData=I,v.pesData=V,T.pesData=Q;var me={audioTrack:v,avcTrack:m,id3Track:T,textTrack:this._txtTrack};return t&&this.extractRemainingSamples(me),me},l.flush=function(){var c=this.remainderData;this.remainderData=null;var i;return c?i=this.demux(c,-1,!1,!0):i={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(i),this.sampleAes?this.decrypt(i,this.sampleAes):i},l.extractRemainingSamples=function(c){var i=c.audioTrack,r=c.avcTrack,t=c.id3Track,a=r.pesData,m=i.pesData,v=t.pesData,T;a&&(T=e(a))?(this.parseAVCPES(T,!0),r.pesData=null):r.pesData=a,m&&(T=e(m))?(i.isAAC?this.parseAACPES(T):this.parseMPEGPES(T),i.pesData=null):(m!=null&&m.size&&g.logger.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=m),v&&(T=e(v))?(this.parseID3PES(T),t.pesData=null):t.pesData=v},l.demuxSampleAes=function(c,i,r){var t=this.demux(c,r,!0,!this.config.progressive),a=this.sampleAes=new M.default(this.observer,this.config,i);return this.decrypt(t,a)},l.decrypt=function(c,i){return new Promise(function(r){var t=c.audioTrack,a=c.avcTrack;t.samples&&t.isAAC?i.decryptAacSamples(t.samples,0,function(){a.samples?i.decryptAvcSamples(a.samples,0,0,function(){r(c)}):r(c)}):a.samples&&i.decryptAvcSamples(a.samples,0,0,function(){r(c)})})},l.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},l.parseAVCPES=function(c,i){var r=this,t=this._avcTrack,a=this.parseAVCNALu(c.data),m=!1,v=this.avcSample,T,k=!1;c.data=null,v&&a.length&&!t.audFound&&(s(v,t),v=this.avcSample=b(!1,c.pts,c.dts,"")),a.forEach(function(I){switch(I.type){case 1:{T=!0,v||(v=r.avcSample=b(!0,c.pts,c.dts,"")),m&&(v.debug+="NDR "),v.frame=!0;var F=I.data;if(k&&F.length>4){var K=new L.default(F).readSliceType();(K===2||K===4||K===7||K===9)&&(v.key=!0)}break}case 5:T=!0,v||(v=r.avcSample=b(!0,c.pts,c.dts,"")),m&&(v.debug+="IDR "),v.key=!0,v.frame=!0;break;case 6:{T=!0,m&&v&&(v.debug+="SEI ");var V=new L.default(f(I.data));V.readUByte();for(var Q=0,Z=0,ie=!1,ge=0;!ie&&V.bytesAvailable>1;){Q=0;do ge=V.readUByte(),Q+=ge;while(ge===255);Z=0;do ge=V.readUByte(),Z+=ge;while(ge===255);if(Q===4&&V.bytesAvailable!==0){ie=!0;var se=V.readUByte();if(se===181){var he=V.readUShort();if(he===49){var de=V.readUInt();if(de===1195456820){var $=V.readUByte();if($===3){for(var Y=V.readUByte(),ne=V.readUByte(),z=31&Y,H=[Y,ne],me=0;me<z;me++)H.push(V.readUByte()),H.push(V.readUByte()),H.push(V.readUByte());o(r._txtTrack.samples,{type:3,pts:c.pts,bytes:H})}}}}}else if(Q===5&&V.bytesAvailable!==0){if(ie=!0,Z>16){for(var Le=[],Oe=0;Oe<16;Oe++)Le.push(V.readUByte().toString(16)),(Oe===3||Oe===5||Oe===7||Oe===9)&&Le.push("-");for(var we=Z-16,De=new Uint8Array(we),le=0;le<we;le++)De[le]=V.readUByte();o(r._txtTrack.samples,{pts:c.pts,payloadType:Q,uuid:Le.join(""),userData:Object(_.utf8ArrayToStr)(De),userDataBytes:De})}}else if(Z<V.bytesAvailable)for(var pe=0;pe<Z;pe++)V.readUByte()}break}case 7:if(T=!0,k=!0,m&&v&&(v.debug+="SPS "),!t.sps){var Ee=new L.default(I.data),Te=Ee.readSPS();t.width=Te.width,t.height=Te.height,t.pixelRatio=Te.pixelRatio,t.sps=[I.data],t.duration=r._duration;for(var Ie=I.data.subarray(1,4),ke="avc1.",Me=0;Me<3;Me++){var Fe=Ie[Me].toString(16);Fe.length<2&&(Fe="0"+Fe),ke+=Fe}t.codec=ke}break;case 8:T=!0,m&&v&&(v.debug+="PPS "),t.pps||(t.pps=[I.data]);break;case 9:T=!1,t.audFound=!0,v&&s(v,t),v=r.avcSample=b(!1,c.pts,c.dts,m?"AUD ":"");break;case 12:T=!1;break;default:T=!1,v&&(v.debug+="unknown NAL "+I.type+" ");break}if(v&&T){var ae=v.units;ae.push(I)}}),i&&v&&(s(v,t),this.avcSample=null)},l.getLastNalUnit=function(){var c,i=this.avcSample,r;if(!i||i.units.length===0){var t=this._avcTrack.samples;i=t[t.length-1]}if((c=i)!==null&&c!==void 0&&c.units){var a=i.units;r=a[a.length-1]}return r},l.parseAVCNALu=function(c){var i=c.byteLength,r=this._avcTrack,t=r.naluState||0,a=t,m=[],v=0,T,k,I,F=-1,K=0;for(t===-1&&(F=0,K=c[0]&31,t=0,v=1);v<i;){if(T=c[v++],!t){t=T?0:1;continue}if(t===1){t=T?0:2;continue}if(!T)t=3;else if(T===1){if(F>=0){var V={data:c.subarray(F,v-t-1),type:K};m.push(V)}else{var Q=this.getLastNalUnit();if(Q&&(a&&v<=4-a&&(Q.state&&(Q.data=Q.data.subarray(0,Q.data.byteLength-a))),k=v-t-1,k>0)){var Z=new Uint8Array(Q.data.byteLength+k);Z.set(Q.data,0),Z.set(c.subarray(0,k),Q.data.byteLength),Q.data=Z,Q.state=0}}v<i?(I=c[v]&31,F=v,K=I,t=0):t=-1}else t=0}if(F>=0&&t>=0){var ie={data:c.subarray(F,i),type:K,state:t};m.push(ie)}if(m.length===0){var ge=this.getLastNalUnit();if(ge){var se=new Uint8Array(ge.data.byteLength+c.byteLength);se.set(ge.data,0),se.set(c,ge.data.byteLength),ge.data=se}}return r.naluState=t,m},l.parseAACPES=function(c){var i=0,r=this._audioTrack,t=this.aacOverFlow,a=c.data;if(t){this.aacOverFlow=null;var m=t.sample.unit.byteLength,v=Math.min(t.missing,m),T=m-v;t.sample.unit.set(a.subarray(0,v),T),r.samples.push(t.sample),i=t.missing}var k,I;for(k=i,I=a.length;k<I-1&&!B.isHeader(a,k);k++);if(k!==i){var F,K;if(k<I-1?(F="AAC PES did not start with ADTS header,offset:"+k,K=!1):(F="no ADTS header found in AAC PES",K=!0),g.logger.warn("parsing error:"+F),this.observer.emit(A.Events.ERROR,A.Events.ERROR,{type:x.ErrorTypes.MEDIA_ERROR,details:x.ErrorDetails.FRAG_PARSING_ERROR,fatal:K,reason:F}),K)return}B.initTrackConfig(r,this.observer,a,k,this.audioCodec);var V;if(c.pts!==void 0)V=c.pts;else if(t){var Q=B.getFrameDuration(r.samplerate);V=t.sample.pts+Q}else{g.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var Z=0;k<I;)if(B.isHeader(a,k)){if(k+5<I){var ie=B.appendFrame(r,a,k,V,Z);if(ie)if(ie.missing)this.aacOverFlow=ie;else{k+=ie.length,Z++;continue}}break}else k++},l.parseMPEGPES=function(c){var i=c.data,r=i.length,t=0,a=0,m=c.pts;if(m===void 0){g.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<r;)if(O.isHeader(i,a)){var v=O.appendFrame(this._audioTrack,i,a,m,t);if(v)a+=v.length,t++;else break}else a++},l.parseID3PES=function(c){if(c.pts===void 0){g.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(c)},u}();E.minProbeByteLength=188;function b(u,l,p,c){return{key:u,frame:!1,pts:l,dts:p,units:[],debug:c,length:0}}function y(u,l){return(u[l+10]&31)<<8|u[l+11]}function h(u,l,p,c){var i={audio:-1,avc:-1,id3:-1,isAAC:!0},r=(u[l+1]&15)<<8|u[l+2],t=l+3+r-4,a=(u[l+10]&15)<<8|u[l+11];for(l+=12+a;l<t;){var m=(u[l+1]&31)<<8|u[l+2];switch(u[l]){case 207:if(!c){g.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:i.audio===-1&&(i.audio=m);break;case 21:i.id3===-1&&(i.id3=m);break;case 219:if(!c){g.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:i.avc===-1&&(i.avc=m);break;case 3:case 4:p?i.audio===-1&&(i.audio=m,i.isAAC=!1):g.logger.log("MPEG audio found, not supported in this browser");break;case 36:g.logger.warn("Unsupported HEVC stream type found");break;default:break}l+=((u[l+3]&15)<<8|u[l+4])+5}return i}function e(u){var l=0,p,c,i,r,t,a=u.data;if(!u||u.size===0)return null;for(;a[0].length<19&&a.length>1;){var m=new Uint8Array(a[0].length+a[1].length);m.set(a[0]),m.set(a[1],a[0].length),a[0]=m,a.splice(1,1)}p=a[0];var v=(p[0]<<16)+(p[1]<<8)+p[2];if(v===1){if(c=(p[4]<<8)+p[5],c&&c>u.size-6)return null;var T=p[7];T&192&&(r=(p[9]&14)*536870912+(p[10]&255)*4194304+(p[11]&254)*16384+(p[12]&255)*128+(p[13]&254)/2,T&64?(t=(p[14]&14)*536870912+(p[15]&255)*4194304+(p[16]&254)*16384+(p[17]&255)*128+(p[18]&254)/2,r-t>60*9e4&&(g.logger.warn(Math.round((r-t)/9e4)+"s delta between PTS and DTS, align them"),r=t)):t=r),i=p[8];var k=i+9;if(u.size<=k)return null;u.size-=k;for(var I=new Uint8Array(u.size),F=0,K=a.length;F<K;F++){p=a[F];var V=p.byteLength;if(k)if(k>V){k-=V;continue}else p=p.subarray(k),V-=k,k=0;I.set(p,l),l+=V}return c&&(c-=i+3),{data:I,pts:r,dts:t,len:c}}return null}function s(u,l){if(u.units.length&&u.frame){if(u.pts===void 0){var p=l.samples,c=p.length;if(c){var i=p[c-1];u.pts=i.pts,u.dts=i.dts}else{l.dropped++;return}}l.samples.push(u)}u.debug.length&&g.logger.log(u.pts+"/"+u.dts+":"+u.debug)}function o(u,l){var p=u.length;if(p>0){if(l.pts>=u[p-1].pts)u.push(l);else for(var c=p-1;c>=0;c--)if(l.pts<u[c].pts){u.splice(c,0,l);break}}else u.push(l)}function f(u){for(var l=u.byteLength,p=[],c=1;c<l-2;)u[c]===0&&u[c+1]===0&&u[c+2]===3?(p.push(c+2),c+=2):c++;if(p.length===0)return u;var i=l-p.length,r=new Uint8Array(i),t=0;for(c=0;c<i;t++,c++)t===p[0]&&(t++,p.shift()),r[c]=u[t];return r}U.default=E},"./src/errors.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"ErrorTypes",function(){return B}),C.d(U,"ErrorDetails",function(){return O});var B;(function(L){L.NETWORK_ERROR="networkError",L.MEDIA_ERROR="mediaError",L.KEY_SYSTEM_ERROR="keySystemError",L.MUX_ERROR="muxError",L.OTHER_ERROR="otherError"})(B||(B={}));var O;(function(L){L.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",L.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",L.KEY_SYSTEM_NO_SESSION="keySystemNoSession",L.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",L.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",L.MANIFEST_LOAD_ERROR="manifestLoadError",L.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",L.MANIFEST_PARSING_ERROR="manifestParsingError",L.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",L.LEVEL_EMPTY_ERROR="levelEmptyError",L.LEVEL_LOAD_ERROR="levelLoadError",L.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",L.LEVEL_SWITCH_ERROR="levelSwitchError",L.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",L.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",L.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",L.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",L.FRAG_LOAD_ERROR="fragLoadError",L.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",L.FRAG_DECRYPT_ERROR="fragDecryptError",L.FRAG_PARSING_ERROR="fragParsingError",L.REMUX_ALLOC_ERROR="remuxAllocError",L.KEY_LOAD_ERROR="keyLoadError",L.KEY_LOAD_TIMEOUT="keyLoadTimeOut",L.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",L.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",L.BUFFER_APPEND_ERROR="bufferAppendError",L.BUFFER_APPENDING_ERROR="bufferAppendingError",L.BUFFER_STALLED_ERROR="bufferStalledError",L.BUFFER_FULL_ERROR="bufferFullError",L.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",L.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",L.INTERNAL_EXCEPTION="internalException",L.INTERNAL_ABORTED="aborted",L.UNKNOWN="unknown"})(O||(O={}))},"./src/events.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"Events",function(){return B});var B;(function(O){O.MEDIA_ATTACHING="hlsMediaAttaching",O.MEDIA_ATTACHED="hlsMediaAttached",O.MEDIA_DETACHING="hlsMediaDetaching",O.MEDIA_DETACHED="hlsMediaDetached",O.BUFFER_RESET="hlsBufferReset",O.BUFFER_CODECS="hlsBufferCodecs",O.BUFFER_CREATED="hlsBufferCreated",O.BUFFER_APPENDING="hlsBufferAppending",O.BUFFER_APPENDED="hlsBufferAppended",O.BUFFER_EOS="hlsBufferEos",O.BUFFER_FLUSHING="hlsBufferFlushing",O.BUFFER_FLUSHED="hlsBufferFlushed",O.MANIFEST_LOADING="hlsManifestLoading",O.MANIFEST_LOADED="hlsManifestLoaded",O.MANIFEST_PARSED="hlsManifestParsed",O.LEVEL_SWITCHING="hlsLevelSwitching",O.LEVEL_SWITCHED="hlsLevelSwitched",O.LEVEL_LOADING="hlsLevelLoading",O.LEVEL_LOADED="hlsLevelLoaded",O.LEVEL_UPDATED="hlsLevelUpdated",O.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",O.LEVELS_UPDATED="hlsLevelsUpdated",O.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",O.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",O.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",O.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",O.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",O.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",O.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",O.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",O.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",O.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",O.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",O.CUES_PARSED="hlsCuesParsed",O.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",O.INIT_PTS_FOUND="hlsInitPtsFound",O.FRAG_LOADING="hlsFragLoading",O.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",O.FRAG_LOADED="hlsFragLoaded",O.FRAG_DECRYPTED="hlsFragDecrypted",O.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",O.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",O.FRAG_PARSING_METADATA="hlsFragParsingMetadata",O.FRAG_PARSED="hlsFragParsed",O.FRAG_BUFFERED="hlsFragBuffered",O.FRAG_CHANGED="hlsFragChanged",O.FPS_DROP="hlsFpsDrop",O.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",O.ERROR="hlsError",O.DESTROYING="hlsDestroying",O.KEY_LOADING="hlsKeyLoading",O.KEY_LOADED="hlsKeyLoaded",O.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",O.BACK_BUFFER_REACHED="hlsBackBufferReached"})(B||(B={}))},"./src/hls.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return u});var B=C("./node_modules/url-toolkit/src/url-toolkit.js"),O=C.n(B),L=C("./src/loader/playlist-loader.ts"),_=C("./src/loader/key-loader.ts"),M=C("./src/controller/id3-track-controller.ts"),A=C("./src/controller/latency-controller.ts"),w=C("./src/controller/level-controller.ts"),g=C("./src/controller/fragment-tracker.ts"),x=C("./src/controller/stream-controller.ts"),S=C("./src/is-supported.ts"),E=C("./src/utils/logger.ts"),b=C("./src/config.ts"),y=C("./node_modules/eventemitter3/index.js"),h=C.n(y),e=C("./src/events.ts"),s=C("./src/errors.ts");function o(l,p){for(var c=0;c<p.length;c++){var i=p[c];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(l,i.key,i)}}function f(l,p,c){return p&&o(l.prototype,p),c&&o(l,c),l}var u=function(){l.isSupported=function(){return Object(S.isSupported)()};function l(c){c===void 0&&(c={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new y.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(b.mergeConfig)(l.DefaultConfig,c);this.userConfig=c,Object(E.enableLogs)(i.debug),this._autoLevelCapping=-1,i.progressive&&Object(b.enableStreamingMode)(i);var r=i.abrController,t=i.bufferController,a=i.capLevelController,m=i.fpsController,v=this.abrController=new r(this),T=this.bufferController=new t(this),k=this.capLevelController=new a(this),I=new m(this),F=new L.default(this),K=new _.default(this),V=new M.default(this),Q=this.levelController=new w.default(this),Z=new g.FragmentTracker(this),ie=this.streamController=new x.default(this,Z);k.setStreamController(ie),I.setStreamController(ie);var ge=[Q,ie];this.networkControllers=ge;var se=[F,K,v,T,k,I,V,Z];this.audioTrackController=this.createController(i.audioTrackController,null,ge),this.createController(i.audioStreamController,Z,ge),this.subtitleTrackController=this.createController(i.subtitleTrackController,null,ge),this.createController(i.subtitleStreamController,Z,ge),this.createController(i.timelineController,null,se),this.emeController=this.createController(i.emeController,null,se),this.cmcdController=this.createController(i.cmcdController,null,se),this.latencyController=this.createController(A.default,null,se),this.coreComponents=se}var p=l.prototype;return p.createController=function(i,r,t){if(i){var a=r?new i(this,r):new i(this);return t&&t.push(a),a}return null},p.on=function(i,r,t){t===void 0&&(t=this),this._emitter.on(i,r,t)},p.once=function(i,r,t){t===void 0&&(t=this),this._emitter.once(i,r,t)},p.removeAllListeners=function(i){this._emitter.removeAllListeners(i)},p.off=function(i,r,t,a){t===void 0&&(t=this),this._emitter.off(i,r,t,a)},p.listeners=function(i){return this._emitter.listeners(i)},p.emit=function(i,r,t){return this._emitter.emit(i,r,t)},p.trigger=function(i,r){if(this.config.debug)return this.emit(i,i,r);try{return this.emit(i,i,r)}catch(t){E.logger.error("An internal error happened while handling event "+i+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.trigger(e.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:i,error:t})}return!1},p.listenerCount=function(i){return this._emitter.listenerCount(i)},p.destroy=function(){E.logger.log("destroy"),this.trigger(e.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(i){return i.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(i){return i.destroy()}),this.coreComponents.length=0},p.attachMedia=function(i){E.logger.log("attachMedia"),this._media=i,this.trigger(e.Events.MEDIA_ATTACHING,{media:i})},p.detachMedia=function(){E.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},p.loadSource=function(i){this.stopLoad();var r=this.media,t=this.url,a=this.url=B.buildAbsoluteURL(self.location.href,i,{alwaysNormalize:!0});E.logger.log("loadSource:"+a),r&&t&&t!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(r)),this.trigger(e.Events.MANIFEST_LOADING,{url:i})},p.startLoad=function(i){i===void 0&&(i=-1),E.logger.log("startLoad("+i+")"),this.networkControllers.forEach(function(r){r.startLoad(i)})},p.stopLoad=function(){E.logger.log("stopLoad"),this.networkControllers.forEach(function(i){i.stopLoad()})},p.swapAudioCodec=function(){E.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},p.recoverMediaError=function(){E.logger.log("recoverMediaError");var i=this._media;this.detachMedia(),i&&this.attachMedia(i)},p.removeLevel=function(i,r){r===void 0&&(r=0),this.levelController.removeLevel(i,r)},f(l,[{key:"levels",get:function(){var i=this.levelController.levels;return i||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(i){E.logger.log("set currentLevel:"+i),this.loadLevel=i,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(i){E.logger.log("set nextLevel:"+i),this.levelController.manualLevel=i,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(i){E.logger.log("set loadLevel:"+i),this.levelController.manualLevel=i}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(i){this.levelController.nextLoadLevel=i}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(i){E.logger.log("set firstLevel:"+i),this.levelController.firstLevel=i}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(i){E.logger.log("set startLevel:"+i),i!==-1&&(i=Math.max(i,this.minAutoLevel)),this.levelController.startLevel=i}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(i){var r=!!i;r!==this.config.capLevelToPlayerSize&&(r?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=r)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(i){this._autoLevelCapping!==i&&(E.logger.log("set autoLevelCapping:"+i),this._autoLevelCapping=i)}},{key:"bandwidthEstimate",get:function(){var i=this.abrController.bwEstimator;return i?i.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var i=this.levels,r=this.config.minAutoBitrate;if(!i)return 0;for(var t=i.length,a=0;a<t;a++)if(i[a].maxBitrate>r)return a;return 0}},{key:"maxAutoLevel",get:function(){var i=this.levels,r=this.autoLevelCapping,t;return r===-1&&i&&i.length?t=i.length-1:t=r,t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(i){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,i)}},{key:"audioTracks",get:function(){var i=this.audioTrackController;return i?i.audioTracks:[]}},{key:"audioTrack",get:function(){var i=this.audioTrackController;return i?i.audioTrack:-1},set:function(i){var r=this.audioTrackController;r&&(r.audioTrack=i)}},{key:"subtitleTracks",get:function(){var i=this.subtitleTrackController;return i?i.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var i=this.subtitleTrackController;return i?i.subtitleTrack:-1},set:function(i){var r=this.subtitleTrackController;r&&(r.subtitleTrack=i)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var i=this.subtitleTrackController;return i?i.subtitleDisplay:!1},set:function(i){var r=this.subtitleTrackController;r&&(r.subtitleDisplay=i)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(i){this.config.lowLatencyMode=i}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return e.Events}},{key:"ErrorTypes",get:function(){return s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return l.defaultConfig?l.defaultConfig:b.hlsDefaultConfig},set:function(i){l.defaultConfig=i}}]),l}();u.defaultConfig=void 0},"./src/is-supported.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"isSupported",function(){return L}),C.d(U,"changeTypeSupported",function(){return _});var B=C("./src/utils/mediasource-helper.ts");function O(){return self.SourceBuffer||self.WebKitSourceBuffer}function L(){var M=Object(B.getMediaSource)();if(!M)return!1;var A=O(),w=M&&typeof M.isTypeSupported=="function"&&M.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),g=!A||A.prototype&&typeof A.prototype.appendBuffer=="function"&&typeof A.prototype.remove=="function";return!!w&&!!g}function _(){var M,A=O();return typeof(A==null||((M=A.prototype)===null||M===void 0)?void 0:M.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return E}),C.d(U,"LoadError",function(){return y});var B=C("./src/polyfills/number.ts"),O=C("./src/errors.ts");function L(h,e){h.prototype=Object.create(e.prototype),h.prototype.constructor=h,g(h,e)}function _(h){var e=typeof Map=="function"?new Map:void 0;return _=function(o){if(o===null||!w(o))return o;if(typeof o!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(o))return e.get(o);e.set(o,f)}function f(){return M(o,arguments,x(this).constructor)}return f.prototype=Object.create(o.prototype,{constructor:{value:f,enumerable:!1,writable:!0,configurable:!0}}),g(f,o)},_(h)}function M(h,e,s){return A()?M=Reflect.construct:M=function(f,u,l){var p=[null];p.push.apply(p,u);var c=Function.bind.apply(f,p),i=new c;return l&&g(i,l.prototype),i},M.apply(null,arguments)}function A(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(h){return!1}}function w(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function g(h,e){return g=Object.setPrototypeOf||function(o,f){return o.__proto__=f,o},g(h,e)}function x(h){return x=Object.setPrototypeOf?Object.getPrototypeOf:function(s){return s.__proto__||Object.getPrototypeOf(s)},x(h)}var S=Math.pow(2,17),E=function(){function h(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var e=h.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(o,f){var u=this,l=o.url;if(!l)return Promise.reject(new y({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:o,networkDetails:null},"Fragment does not have a "+(l?"part list":"url")));this.abort();var p=this.config,c=p.fLoader,i=p.loader;return new Promise(function(r,t){u.loader&&u.loader.destroy();var a=u.loader=o.loader=c?new c(p):new i(p),m=b(o),v={timeout:p.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:p.fragLoadingMaxRetryTimeout,highWaterMark:S};o.stats=a.stats,a.load(m,v,{onSuccess:function(k,I,F,K){u.resetLoader(o,a),r({frag:o,part:null,payload:k.data,networkDetails:K})},onError:function(k,I,F){u.resetLoader(o,a),t(new y({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:o,response:k,networkDetails:F}))},onAbort:function(k,I,F){u.resetLoader(o,a),t(new y({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:o,networkDetails:F}))},onTimeout:function(k,I,F){u.resetLoader(o,a),t(new y({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:o,networkDetails:F}))},onProgress:function(k,I,F,K){f&&f({frag:o,part:null,payload:F,networkDetails:K})}})})},e.loadPart=function(o,f,u){var l=this;this.abort();var p=this.config,c=p.fLoader,i=p.loader;return new Promise(function(r,t){l.loader&&l.loader.destroy();var a=l.loader=o.loader=c?new c(p):new i(p),m=b(o,f),v={timeout:p.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:p.fragLoadingMaxRetryTimeout,highWaterMark:S};f.stats=a.stats,a.load(m,v,{onSuccess:function(k,I,F,K){l.resetLoader(o,a),l.updateStatsFromPart(o,f);var V={frag:o,part:f,payload:k.data,networkDetails:K};u(V),r(V)},onError:function(k,I,F){l.resetLoader(o,a),t(new y({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:o,part:f,response:k,networkDetails:F}))},onAbort:function(k,I,F){o.stats.aborted=f.stats.aborted,l.resetLoader(o,a),t(new y({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:o,part:f,networkDetails:F}))},onTimeout:function(k,I,F){l.resetLoader(o,a),t(new y({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:o,part:f,networkDetails:F}))}})})},e.updateStatsFromPart=function(o,f){var u=o.stats,l=f.stats,p=l.total;if(u.loaded+=l.loaded,p){var c=Math.round(o.duration/f.duration),i=Math.min(Math.round(u.loaded/p),c),r=c-i,t=r*Math.round(u.loaded/i);u.total=u.loaded+t}else u.total=Math.max(u.loaded,u.total);var a=u.loading,m=l.loading;a.start?a.first+=m.first-m.start:(a.start=m.start,a.first=m.first),a.end=m.end},e.resetLoader=function(o,f){o.loader=null,this.loader===f&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),f.destroy()},h}();function b(h,e){e===void 0&&(e=null);var s=e||h,o={frag:h,part:e,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},f=s.byteRangeStartOffset,u=s.byteRangeEndOffset;return Object(B.isFiniteNumber)(f)&&Object(B.isFiniteNumber)(u)&&(o.rangeStart=f,o.rangeEnd=u),o}var y=function(h){L(e,h);function e(s){for(var o,f=arguments.length,u=new Array(f>1?f-1:0),l=1;l<f;l++)u[l-1]=arguments[l];return o=h.call.apply(h,[this].concat(u))||this,o.data=void 0,o.data=s,o}return e}(_(Error))},"./src/loader/fragment.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"ElementaryStreamTypes",function(){return E}),C.d(U,"BaseSegment",function(){return b}),C.d(U,"Fragment",function(){return y}),C.d(U,"Part",function(){return h});var B=C("./src/polyfills/number.ts"),O=C("./node_modules/url-toolkit/src/url-toolkit.js"),L=C.n(O),_=C("./src/utils/logger.ts"),M=C("./src/loader/level-key.ts"),A=C("./src/loader/load-stats.ts");function w(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,g(e,s)}function g(e,s){return g=Object.setPrototypeOf||function(f,u){return f.__proto__=u,f},g(e,s)}function x(e,s){for(var o=0;o<s.length;o++){var f=s[o];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(e,f.key,f)}}function S(e,s,o){return s&&x(e.prototype,s),o&&x(e,o),e}var E;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(E||(E={}));var b=function(){function e(o){var f;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(f={},f[E.AUDIO]=null,f[E.VIDEO]=null,f[E.AUDIOVIDEO]=null,f),this.baseurl=o}var s=e.prototype;return s.setByteRange=function(f,u){var l=f.split("@",2),p=[];l.length===1?p[0]=u?u.byteRangeEndOffset:0:p[0]=parseInt(l[1]),p[1]=parseInt(l[0])+p[0],this._byteRange=p},S(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(O.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(f){this._url=f}}]),e}(),y=function(e){w(s,e);function s(f,u){var l;return l=e.call(this,u)||this,l._decryptdata=null,l.rawProgramDateTime=null,l.programDateTime=null,l.tagList=[],l.duration=0,l.sn=0,l.levelkey=void 0,l.type=void 0,l.loader=null,l.level=-1,l.cc=0,l.startPTS=void 0,l.endPTS=void 0,l.appendedPTS=void 0,l.startDTS=void 0,l.endDTS=void 0,l.start=0,l.deltaPTS=void 0,l.maxStartPTS=void 0,l.minEndPTS=void 0,l.stats=new A.LoadStats,l.urlId=0,l.data=void 0,l.bitrateTest=!1,l.title=null,l.initSegment=null,l.type=f,l}var o=s.prototype;return o.createInitializationVector=function(u){for(var l=new Uint8Array(16),p=12;p<16;p++)l[p]=u>>8*(15-p)&255;return l},o.setDecryptDataFromLevelKey=function(u,l){var p=u;return(u==null?void 0:u.method)==="AES-128"&&u.uri&&!u.iv&&(p=M.LevelKey.fromURI(u.uri),p.method=u.method,p.iv=this.createInitializationVector(l),p.keyFormat="identity"),p},o.setElementaryStreamInfo=function(u,l,p,c,i,r){r===void 0&&(r=!1);var t=this.elementaryStreams,a=t[u];if(!a){t[u]={startPTS:l,endPTS:p,startDTS:c,endDTS:i,partial:r};return}a.startPTS=Math.min(a.startPTS,l),a.endPTS=Math.max(a.endPTS,p),a.startDTS=Math.min(a.startDTS,c),a.endDTS=Math.max(a.endDTS,i)},o.clearElementaryStreamInfo=function(){var u=this.elementaryStreams;u[E.AUDIO]=null,u[E.VIDEO]=null,u[E.AUDIOVIDEO]=null},S(s,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var u=this.sn;typeof u!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&_.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),u=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,u)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(B.isFiniteNumber)(this.programDateTime))return null;var u=Object(B.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+u*1e3}},{key:"encrypted",get:function(){var u;return!!((u=this.decryptdata)!==null&&u!==void 0&&u.keyFormat&&this.decryptdata.uri)}}]),s}(b),h=function(e){w(s,e);function s(o,f,u,l,p){var c;c=e.call(this,u)||this,c.fragOffset=0,c.duration=0,c.gap=!1,c.independent=!1,c.relurl=void 0,c.fragment=void 0,c.index=void 0,c.stats=new A.LoadStats,c.duration=o.decimalFloatingPoint("DURATION"),c.gap=o.bool("GAP"),c.independent=o.bool("INDEPENDENT"),c.relurl=o.enumeratedString("URI"),c.fragment=f,c.index=l;var i=o.enumeratedString("BYTERANGE");return i&&c.setByteRange(i,p),p&&(c.fragOffset=p.fragOffset+p.duration),c}return S(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var f=this.elementaryStreams;return!!(f.audio||f.video||f.audiovideo)}}]),s}(b)},"./src/loader/key-loader.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return _});var B=C("./src/events.ts"),O=C("./src/errors.ts"),L=C("./src/utils/logger.ts"),_=function(){function M(w){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=w,this._registerListeners()}var A=M.prototype;return A._registerListeners=function(){this.hls.on(B.Events.KEY_LOADING,this.onKeyLoading,this)},A._unregisterListeners=function(){this.hls.off(B.Events.KEY_LOADING,this.onKeyLoading)},A.destroy=function(){this._unregisterListeners();for(var g in this.loaders){var x=this.loaders[g];x&&x.destroy()}this.loaders={}},A.onKeyLoading=function(g,x){var S=x.frag,E=S.type,b=this.loaders[E];if(!S.decryptdata){L.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var y=S.decryptdata.uri;if(y!==this.decrypturl||this.decryptkey===null){var h=this.hls.config;if(b&&(L.logger.warn("abort previous key loader for type:"+E),b.abort()),!y){L.logger.warn("key uri is falsy");return}var e=h.loader,s=S.loader=this.loaders[E]=new e(h);this.decrypturl=y,this.decryptkey=null;var o={url:y,frag:S,responseType:"arraybuffer"},f={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:h.fragLoadingRetryDelay,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:0},u={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(o,f,u)}else this.decryptkey&&(S.decryptdata.key=this.decryptkey,this.hls.trigger(B.Events.KEY_LOADED,{frag:S}))},A.loadsuccess=function(g,x,S){var E=S.frag;if(!E.decryptdata){L.logger.error("after key load, decryptdata unset");return}this.decryptkey=E.decryptdata.key=new Uint8Array(g.data),E.loader=null,delete this.loaders[E.type],this.hls.trigger(B.Events.KEY_LOADED,{frag:E})},A.loaderror=function(g,x){var S=x.frag,E=S.loader;E&&E.abort(),delete this.loaders[S.type],this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:S,response:g})},A.loadtimeout=function(g,x){var S=x.frag,E=S.loader;E&&E.abort(),delete this.loaders[S.type],this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:S})},M}()},"./src/loader/level-details.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"LevelDetails",function(){return M});var B=C("./src/polyfills/number.ts");function O(A,w){for(var g=0;g<w.length;g++){var x=w[g];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(A,x.key,x)}}function L(A,w,g){return w&&O(A.prototype,w),g&&O(A,g),A}var _=10,M=function(){function A(g){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=g}var w=A.prototype;return w.reloaded=function(x){if(!x){this.advanced=!0,this.updated=!0;return}var S=this.lastPartSn-x.lastPartSn,E=this.lastPartIndex-x.lastPartIndex;this.updated=this.endSN!==x.endSN||!!E||!!S,this.advanced=this.endSN>x.endSN||S>0||S===0&&E>0,this.updated||this.advanced?this.misses=Math.floor(x.misses*.6):this.misses=x.misses+1,this.availabilityDelay=x.availabilityDelay},L(A,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(B.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||_}},{key:"drift",get:function(){var x=this.driftEndTime-this.driftStartTime;if(x>0){var S=this.driftEnd-this.driftStart;return S*1e3/x}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var x;return(x=this.fragments)!==null&&x!==void 0&&x.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 x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),A}()},"./src/loader/level-key.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"LevelKey",function(){return M});var B=C("./node_modules/url-toolkit/src/url-toolkit.js"),O=C.n(B);function L(A,w){for(var g=0;g<w.length;g++){var x=w[g];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(A,x.key,x)}}function _(A,w,g){return w&&L(A.prototype,w),g&&L(A,g),A}var M=function(){A.fromURL=function(g,x){return new A(g,x)},A.fromURI=function(g){return new A(g)};function A(w,g){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,g?this._uri=Object(B.buildAbsoluteURL)(w,g,{alwaysNormalize:!0}):this._uri=w}return _(A,[{key:"uri",get:function(){return this._uri}}]),A}()},"./src/loader/load-stats.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"LoadStats",function(){return B});var B=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return s});var B=C("./src/polyfills/number.ts"),O=C("./node_modules/url-toolkit/src/url-toolkit.js"),L=C.n(O),_=C("./src/loader/fragment.ts"),M=C("./src/loader/level-details.ts"),A=C("./src/loader/level-key.ts"),w=C("./src/utils/attr-list.ts"),g=C("./src/utils/logger.ts"),x=C("./src/utils/codecs.ts"),S=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,E=/#EXT-X-MEDIA:(.*)/g,b=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),y=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),h=/\.(mp4|m4s|m4v|m4a)$/i;function e(p){var c,i;return h.test((c=(i=O.parseURL(p))===null||i===void 0?void 0:i.path)!=null?c:"")}var s=function(){function p(){}return p.findGroup=function(i,r){for(var t=0;t<i.length;t++){var a=i[t];if(a.id===r)return a}},p.convertAVC1ToAVCOTI=function(i){var r=i.split(".");if(r.length>2){var t=r.shift()+".";return t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).substr(-4),t}return i},p.resolve=function(i,r){return O.buildAbsoluteURL(r,i,{alwaysNormalize:!0})},p.parseMasterPlaylist=function(i,r){var t=[],a={},m=!1;S.lastIndex=0;for(var v;(v=S.exec(i))!=null;)if(v[1]){var T=new w.AttrList(v[1]),k={attrs:T,bitrate:T.decimalInteger("AVERAGE-BANDWIDTH")||T.decimalInteger("BANDWIDTH"),name:T.NAME,url:p.resolve(v[2],r)},I=T.decimalResolution("RESOLUTION");I&&(k.width=I.width,k.height=I.height),o((T.CODECS||"").split(/[ ,]+/).filter(function(K){return K}),k),k.videoCodec&&k.videoCodec.indexOf("avc1")!==-1&&(k.videoCodec=p.convertAVC1ToAVCOTI(k.videoCodec)),t.push(k)}else if(v[3]){var F=new w.AttrList(v[3]);F["DATA-ID"]&&(m=!0,a[F["DATA-ID"]]=F)}return{levels:t,sessionData:m?a:null}},p.parseMasterPlaylistMedia=function(i,r,t,a){a===void 0&&(a=[]);var m,v=[],T=0;for(E.lastIndex=0;(m=E.exec(i))!==null;){var k=new w.AttrList(m[1]);if(k.TYPE===t){var I={attrs:k,bitrate:0,id:T++,groupId:k["GROUP-ID"],instreamId:k["INSTREAM-ID"],name:k.NAME||k.LANGUAGE||"",type:t,default:k.bool("DEFAULT"),autoselect:k.bool("AUTOSELECT"),forced:k.bool("FORCED"),lang:k.LANGUAGE,url:k.URI?p.resolve(k.URI,r):""};if(a.length){var F=p.findGroup(a,I.groupId)||a[0];f(I,F,"audioCodec"),f(I,F,"textCodec")}v.push(I)}}return v},p.parseLevelPlaylist=function(i,r,t,a,m){var v=new M.LevelDetails(r),T=v.fragments,k=null,I=0,F=0,K=0,V=0,Q=null,Z=new _.Fragment(a,r),ie,ge,se,he=-1,de=!1;for(b.lastIndex=0,v.m3u8=i;(ie=b.exec(i))!==null;){de&&(de=!1,Z=new _.Fragment(a,r),Z.start=K,Z.sn=I,Z.cc=V,Z.level=t,k&&(Z.initSegment=k,Z.rawProgramDateTime=k.rawProgramDateTime));var $=ie[1];if($){Z.duration=parseFloat($);var Y=(" "+ie[2]).slice(1);Z.title=Y||null,Z.tagList.push(Y?["INF",$,Y]:["INF",$])}else if(ie[3])Object(B.isFiniteNumber)(Z.duration)&&(Z.start=K,se&&(Z.levelkey=se),Z.sn=I,Z.level=t,Z.cc=V,Z.urlId=m,T.push(Z),Z.relurl=(" "+ie[3]).slice(1),l(Z,Q),Q=Z,K+=Z.duration,I++,F=0,de=!0);else if(ie[4]){var ne=(" "+ie[4]).slice(1);Q?Z.setByteRange(ne,Q):Z.setByteRange(ne)}else if(ie[5])Z.rawProgramDateTime=(" "+ie[5]).slice(1),Z.tagList.push(["PROGRAM-DATE-TIME",Z.rawProgramDateTime]),he===-1&&(he=T.length);else{if(ie=ie[0].match(y),!ie){g.logger.warn("No matches on slow regex match for level playlist!");continue}for(ge=1;ge<ie.length&&!(typeof ie[ge]!="undefined");ge++);var z=(" "+ie[ge]).slice(1),H=(" "+ie[ge+1]).slice(1),me=ie[ge+2]?(" "+ie[ge+2]).slice(1):"";switch(z){case"PLAYLIST-TYPE":v.type=H.toUpperCase();break;case"MEDIA-SEQUENCE":I=v.startSN=parseInt(H);break;case"SKIP":{var Le=new w.AttrList(H),Oe=Le.decimalInteger("SKIPPED-SEGMENTS");if(Object(B.isFiniteNumber)(Oe)){v.skippedSegments=Oe;for(var we=Oe;we--;)T.unshift(null);I+=Oe}var De=Le.enumeratedString("RECENTLY-REMOVED-DATERANGES");De&&(v.recentlyRemovedDateranges=De.split(" "));break}case"TARGETDURATION":v.targetduration=parseFloat(H);break;case"VERSION":v.version=parseInt(H);break;case"EXTM3U":break;case"ENDLIST":v.live=!1;break;case"#":(H||me)&&Z.tagList.push(me?[H,me]:[H]);break;case"DIS":V++;case"GAP":Z.tagList.push([z]);break;case"BITRATE":Z.tagList.push([z,H]);break;case"DISCONTINUITY-SEQ":V=parseInt(H);break;case"KEY":{var le,pe=new w.AttrList(H),Ee=pe.enumeratedString("METHOD"),Te=pe.URI,Ie=pe.hexadecimalInteger("IV"),ke=pe.enumeratedString("KEYFORMATVERSIONS"),Me=pe.enumeratedString("KEYID"),Fe=(le=pe.enumeratedString("KEYFORMAT"))!=null?le:"identity",ae=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(ae.indexOf(Fe)>-1){g.logger.warn("Keyformat "+Fe+" is not supported from the manifest");continue}else if(Fe!=="identity")continue;Ee&&(se=A.LevelKey.fromURL(r,Te),Te&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Ee)>=0&&(se.method=Ee,se.keyFormat=Fe,Me&&(se.keyID=Me),ke&&(se.keyFormatVersions=ke),se.iv=Ie));break}case"START":{var ue=new w.AttrList(H),be=ue.decimalFloatingPoint("TIME-OFFSET");Object(B.isFiniteNumber)(be)&&(v.startTimeOffset=be);break}case"MAP":{var xe=new w.AttrList(H);Z.relurl=xe.URI,xe.BYTERANGE&&Z.setByteRange(xe.BYTERANGE),Z.level=t,Z.sn="initSegment",se&&(Z.levelkey=se),Z.initSegment=null,k=Z,de=!0;break}case"SERVER-CONTROL":{var Ce=new w.AttrList(H);v.canBlockReload=Ce.bool("CAN-BLOCK-RELOAD"),v.canSkipUntil=Ce.optionalFloat("CAN-SKIP-UNTIL",0),v.canSkipDateRanges=v.canSkipUntil>0&&Ce.bool("CAN-SKIP-DATERANGES"),v.partHoldBack=Ce.optionalFloat("PART-HOLD-BACK",0),v.holdBack=Ce.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Se=new w.AttrList(H);v.partTarget=Se.decimalFloatingPoint("PART-TARGET");break}case"PART":{var ye=v.partList;ye||(ye=v.partList=[]);var Ne=F>0?ye[ye.length-1]:void 0,Be=F++,ve=new _.Part(new w.AttrList(H),Z,r,Be,Ne);ye.push(ve),Z.duration+=ve.duration;break}case"PRELOAD-HINT":{var _e=new w.AttrList(H);v.preloadHint=_e;break}case"RENDITION-REPORT":{var re=new w.AttrList(H);v.renditionReports=v.renditionReports||[],v.renditionReports.push(re);break}default:g.logger.warn("line parsed but not handled: "+ie);break}}}Q&&!Q.relurl?(T.pop(),K-=Q.duration,v.partList&&(v.fragmentHint=Q)):v.partList&&(l(Z,Q),Z.cc=V,v.fragmentHint=Z);var q=T.length,te=T[0],j=T[q-1];if(K+=v.skippedSegments*v.targetduration,K>0&&q&&j){v.averagetargetduration=K/q;var W=j.sn;v.endSN=W!=="initSegment"?W:0,te&&(v.startCC=te.cc,te.initSegment||v.fragments.every(function(G){return G.relurl&&e(G.relurl)})&&(g.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),Z=new _.Fragment(a,r),Z.relurl=j.relurl,Z.level=t,Z.sn="initSegment",te.initSegment=Z,v.needSidxRanges=!0))}else v.endSN=0,v.startCC=0;return v.fragmentHint&&(K+=v.fragmentHint.duration),v.totalduration=K,v.endCC=V,he>0&&u(T,he),v},p}();function o(p,c){["video","audio","text"].forEach(function(i){var r=p.filter(function(a){return Object(x.isCodecType)(a,i)});if(r.length){var t=r.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});c[i+"Codec"]=t.length>0?t[0]:r[0],p=p.filter(function(a){return r.indexOf(a)===-1})}}),c.unknownCodecs=p}function f(p,c,i){var r=c[i];r&&(p[i]=r)}function u(p,c){for(var i=p[c],r=c;r--;){var t=p[r];if(!t)return;t.programDateTime=i.programDateTime-t.duration*1e3,i=t}}function l(p,c){p.rawProgramDateTime?p.programDateTime=Date.parse(p.rawProgramDateTime):c!=null&&c.programDateTime&&(p.programDateTime=c.endProgramDateTime),Object(B.isFiniteNumber)(p.programDateTime)||(p.programDateTime=null,p.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/polyfills/number.ts"),O=C("./src/events.ts"),L=C("./src/errors.ts"),_=C("./src/utils/logger.ts"),M=C("./src/utils/mp4-tools.ts"),A=C("./src/loader/m3u8-parser.ts"),w=C("./src/types/loader.ts"),g=C("./src/utils/attr-list.ts");function x(b){var y=b.type;switch(y){case w.PlaylistContextType.AUDIO_TRACK:return w.PlaylistLevelType.AUDIO;case w.PlaylistContextType.SUBTITLE_TRACK:return w.PlaylistLevelType.SUBTITLE;default:return w.PlaylistLevelType.MAIN}}function S(b,y){var h=b.url;return(h===void 0||h.indexOf("data:")===0)&&(h=y.url),h}var E=function(){function b(h){this.hls=void 0,this.loaders=Object.create(null),this.hls=h,this.registerListeners()}var y=b.prototype;return y.registerListeners=function(){var e=this.hls;e.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(O.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(O.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.unregisterListeners=function(){var e=this.hls;e.off(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(O.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(O.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.createInternalLoader=function(e){var s=this.hls.config,o=s.pLoader,f=s.loader,u=o||f,l=new u(s);return e.loader=l,this.loaders[e.type]=l,l},y.getInternalLoader=function(e){return this.loaders[e.type]},y.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},y.destroyInternalLoaders=function(){for(var e in this.loaders){var s=this.loaders[e];s&&s.destroy(),this.resetInternalLoader(e)}},y.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},y.onManifestLoading=function(e,s){var o=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:w.PlaylistContextType.MANIFEST,url:o,deliveryDirectives:null})},y.onLevelLoading=function(e,s){var o=s.id,f=s.level,u=s.url,l=s.deliveryDirectives;this.load({id:o,groupId:null,level:f,responseType:"text",type:w.PlaylistContextType.LEVEL,url:u,deliveryDirectives:l})},y.onAudioTrackLoading=function(e,s){var o=s.id,f=s.groupId,u=s.url,l=s.deliveryDirectives;this.load({id:o,groupId:f,level:null,responseType:"text",type:w.PlaylistContextType.AUDIO_TRACK,url:u,deliveryDirectives:l})},y.onSubtitleTrackLoading=function(e,s){var o=s.id,f=s.groupId,u=s.url,l=s.deliveryDirectives;this.load({id:o,groupId:f,level:null,responseType:"text",type:w.PlaylistContextType.SUBTITLE_TRACK,url:u,deliveryDirectives:l})},y.load=function(e){var s,o=this.hls.config,f=this.getInternalLoader(e);if(f){var u=f.context;if(u&&u.url===e.url){_.logger.trace("[playlist-loader]: playlist request ongoing");return}_.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),f.abort()}var l,p,c,i;switch(e.type){case w.PlaylistContextType.MANIFEST:l=o.manifestLoadingMaxRetry,p=o.manifestLoadingTimeOut,c=o.manifestLoadingRetryDelay,i=o.manifestLoadingMaxRetryTimeout;break;case w.PlaylistContextType.LEVEL:case w.PlaylistContextType.AUDIO_TRACK:case w.PlaylistContextType.SUBTITLE_TRACK:l=0,p=o.levelLoadingTimeOut;break;default:l=o.levelLoadingMaxRetry,p=o.levelLoadingTimeOut,c=o.levelLoadingRetryDelay,i=o.levelLoadingMaxRetryTimeout;break}if(f=this.createInternalLoader(e),(s=e.deliveryDirectives)!==null&&s!==void 0&&s.part){var r;if(e.type===w.PlaylistContextType.LEVEL&&e.level!==null?r=this.hls.levels[e.level].details:e.type===w.PlaylistContextType.AUDIO_TRACK&&e.id!==null?r=this.hls.audioTracks[e.id].details:e.type===w.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(r=this.hls.subtitleTracks[e.id].details),r){var t=r.partTarget,a=r.targetduration;t&&a&&(p=Math.min(Math.max(t*3,a*.8)*1e3,p))}}var m={timeout:p,maxRetry:l,retryDelay:c,maxRetryDelay:i,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};f.load(e,m,v)},y.loadsuccess=function(e,s,o,f){if(f===void 0&&(f=null),o.isSidxRequest){this.handleSidxRequest(e,o),this.handlePlaylistLoaded(e,s,o,f);return}this.resetInternalLoader(o.type);var u=e.data;if(u.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,o,"no EXTM3U delimiter",f);return}s.parsing.start=performance.now(),u.indexOf("#EXTINF:")>0||u.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,s,o,f):this.handleMasterPlaylist(e,s,o,f)},y.loaderror=function(e,s,o){o===void 0&&(o=null),this.handleNetworkError(s,o,!1,e)},y.loadtimeout=function(e,s,o){o===void 0&&(o=null),this.handleNetworkError(s,o,!0)},y.handleMasterPlaylist=function(e,s,o,f){var u=this.hls,l=e.data,p=S(e,o),c=A.default.parseMasterPlaylist(l,p),i=c.levels,r=c.sessionData;if(!i.length){this.handleManifestParsingError(e,o,"no level found in manifest",f);return}var t=i.map(function(I){return{id:I.attrs.AUDIO,audioCodec:I.audioCodec}}),a=i.map(function(I){return{id:I.attrs.SUBTITLES,textCodec:I.textCodec}}),m=A.default.parseMasterPlaylistMedia(l,p,"AUDIO",t),v=A.default.parseMasterPlaylistMedia(l,p,"SUBTITLES",a),T=A.default.parseMasterPlaylistMedia(l,p,"CLOSED-CAPTIONS");if(m.length){var k=m.some(function(I){return!I.url});!k&&i[0].audioCodec&&!i[0].attrs.AUDIO&&(_.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 g.AttrList({}),bitrate:0,url:""}))}u.trigger(O.Events.MANIFEST_LOADED,{levels:i,audioTracks:m,subtitles:v,captions:T,url:p,stats:s,networkDetails:f,sessionData:r})},y.handleTrackOrLevelPlaylist=function(e,s,o,f){var u=this.hls,l=o.id,p=o.level,c=o.type,i=S(e,o),r=Object(B.isFiniteNumber)(l)?l:0,t=Object(B.isFiniteNumber)(p)?p:r,a=x(o),m=A.default.parseLevelPlaylist(e.data,i,t,a,r);if(!m.fragments.length){u.trigger(O.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:i,reason:"no fragments found in level",level:typeof o.level=="number"?o.level:void 0});return}if(c===w.PlaylistContextType.MANIFEST){var v={attrs:new g.AttrList({}),bitrate:0,details:m,name:"",url:i};u.trigger(O.Events.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:i,stats:s,networkDetails:f,sessionData:null})}if(s.parsing.end=performance.now(),m.needSidxRanges){var T,k=(T=m.fragments[0].initSegment)===null||T===void 0?void 0:T.url;this.load({url:k,isSidxRequest:!0,type:c,level:p,levelDetails:m,id:l,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}o.levelDetails=m,this.handlePlaylistLoaded(e,s,o,f)},y.handleSidxRequest=function(e,s){var o=Object(M.parseSegmentIndex)(new Uint8Array(e.data));if(!o)return;var f=o.references,u=s.levelDetails;f.forEach(function(l,p){var c=l.info,i=u.fragments[p];i.byteRange.length===0&&i.setByteRange(String(1+c.end-c.start)+"@"+String(c.start)),i.initSegment&&i.initSegment.setByteRange(String(o.moovEndOffset)+"@0")})},y.handleManifestParsingError=function(e,s,o,f){this.hls.trigger(O.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===w.PlaylistContextType.MANIFEST,url:e.url,reason:o,response:e,context:s,networkDetails:f})},y.handleNetworkError=function(e,s,o,f){o===void 0&&(o=!1),_.logger.warn("[playlist-loader]: A network "+(o?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var u=L.ErrorDetails.UNKNOWN,l=!1,p=this.getInternalLoader(e);switch(e.type){case w.PlaylistContextType.MANIFEST:u=o?L.ErrorDetails.MANIFEST_LOAD_TIMEOUT:L.ErrorDetails.MANIFEST_LOAD_ERROR,l=!0;break;case w.PlaylistContextType.LEVEL:u=o?L.ErrorDetails.LEVEL_LOAD_TIMEOUT:L.ErrorDetails.LEVEL_LOAD_ERROR,l=!1;break;case w.PlaylistContextType.AUDIO_TRACK:u=o?L.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:L.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case w.PlaylistContextType.SUBTITLE_TRACK:u=o?L.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:L.ErrorDetails.SUBTITLE_LOAD_ERROR,l=!1;break}p&&this.resetInternalLoader(e.type);var c={type:L.ErrorTypes.NETWORK_ERROR,details:u,fatal:l,url:e.url,loader:p,context:e,networkDetails:s};f&&(c.response=f),this.hls.trigger(O.Events.ERROR,c)},y.handlePlaylistLoaded=function(e,s,o,f){var u=o.type,l=o.level,p=o.id,c=o.groupId,i=o.loader,r=o.levelDetails,t=o.deliveryDirectives;if(!(r!=null&&r.targetduration)){this.handleManifestParsingError(e,o,"invalid target duration",f);return}if(!i)return;r.live&&(i.getCacheAge&&(r.ageHeader=i.getCacheAge()||0),(!i.getCacheAge||isNaN(r.ageHeader))&&(r.ageHeader=0));switch(u){case w.PlaylistContextType.MANIFEST:case w.PlaylistContextType.LEVEL:this.hls.trigger(O.Events.LEVEL_LOADED,{details:r,level:l||0,id:p||0,stats:s,networkDetails:f,deliveryDirectives:t});break;case w.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(O.Events.AUDIO_TRACK_LOADED,{details:r,id:p||0,groupId:c||"",stats:s,networkDetails:f,deliveryDirectives:t});break;case w.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(O.Events.SUBTITLE_TRACK_LOADED,{details:r,id:p||0,groupId:c||"",stats:s,networkDetails:f,deliveryDirectives:t});break}},b}();U.default=E},"./src/polyfills/number.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"isFiniteNumber",function(){return B}),C.d(U,"MAX_SAFE_INTEGER",function(){return O});var B=Number.isFinite||function(L){return typeof L=="number"&&isFinite(L)},O=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(fe,U,C){"use strict";C.r(U);var B=function(){function O(){}return O.getSilentFrame=function(_,M){switch(_){case"mp4a.40.2":if(M===1)return new Uint8Array([0,200,0,128,35,128]);if(M===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(M===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(M===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(M===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(M===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(M===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(M===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(M===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return},O}();U.default=B},"./src/remux/mp4-generator.ts":function(fe,U,C){"use strict";C.r(U);var B=Math.pow(2,32)-1,O=function(){function L(){}return L.init=function(){L.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var M;for(M in L.types)L.types.hasOwnProperty(M)&&(L.types[M]=[M.charCodeAt(0),M.charCodeAt(1),M.charCodeAt(2),M.charCodeAt(3)]);var A=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]),w=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]);L.HDLR_TYPES={video:A,audio:w};var g=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),x=new Uint8Array([0,0,0,0,0,0,0,0]);L.STTS=L.STSC=L.STCO=x,L.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),L.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),L.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),L.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var S=new Uint8Array([105,115,111,109]),E=new Uint8Array([97,118,99,49]),b=new Uint8Array([0,0,0,1]);L.FTYP=L.box(L.types.ftyp,S,b,S,E),L.DINF=L.box(L.types.dinf,L.box(L.types.dref,g))},L.box=function(M){for(var A=8,w=arguments.length,g=new Array(w>1?w-1:0),x=1;x<w;x++)g[x-1]=arguments[x];for(var S=g.length,E=S;S--;)A+=g[S].byteLength;var b=new Uint8Array(A);for(b[0]=A>>24&255,b[1]=A>>16&255,b[2]=A>>8&255,b[3]=A&255,b.set(M,4),S=0,A=8;S<E;S++)b.set(g[S],A),A+=g[S].byteLength;return b},L.hdlr=function(M){return L.box(L.types.hdlr,L.HDLR_TYPES[M])},L.mdat=function(M){return L.box(L.types.mdat,M)},L.mdhd=function(M,A){A*=M;var w=Math.floor(A/(B+1)),g=Math.floor(A%(B+1));return L.box(L.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,M>>24&255,M>>16&255,M>>8&255,M&255,w>>24,w>>16&255,w>>8&255,w&255,g>>24,g>>16&255,g>>8&255,g&255,85,196,0,0]))},L.mdia=function(M){return L.box(L.types.mdia,L.mdhd(M.timescale,M.duration),L.hdlr(M.type),L.minf(M))},L.mfhd=function(M){return L.box(L.types.mfhd,new Uint8Array([0,0,0,0,M>>24,M>>16&255,M>>8&255,M&255]))},L.minf=function(M){return M.type==="audio"?L.box(L.types.minf,L.box(L.types.smhd,L.SMHD),L.DINF,L.stbl(M)):L.box(L.types.minf,L.box(L.types.vmhd,L.VMHD),L.DINF,L.stbl(M))},L.moof=function(M,A,w){return L.box(L.types.moof,L.mfhd(M),L.traf(w,A))},L.moov=function(M){for(var A=M.length,w=[];A--;)w[A]=L.trak(M[A]);return L.box.apply(null,[L.types.moov,L.mvhd(M[0].timescale,M[0].duration)].concat(w).concat(L.mvex(M)))},L.mvex=function(M){for(var A=M.length,w=[];A--;)w[A]=L.trex(M[A]);return L.box.apply(null,[L.types.mvex].concat(w))},L.mvhd=function(M,A){A*=M;var w=Math.floor(A/(B+1)),g=Math.floor(A%(B+1)),x=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,M>>24&255,M>>16&255,M>>8&255,M&255,w>>24,w>>16&255,w>>8&255,w&255,g>>24,g>>16&255,g>>8&255,g&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return L.box(L.types.mvhd,x)},L.sdtp=function(M){var A=M.samples||[],w=new Uint8Array(4+A.length),g,x;for(g=0;g<A.length;g++)x=A[g].flags,w[g+4]=x.dependsOn<<4|x.isDependedOn<<2|x.hasRedundancy;return L.box(L.types.sdtp,w)},L.stbl=function(M){return L.box(L.types.stbl,L.stsd(M),L.box(L.types.stts,L.STTS),L.box(L.types.stsc,L.STSC),L.box(L.types.stsz,L.STSZ),L.box(L.types.stco,L.STCO))},L.avc1=function(M){var A=[],w=[],g,x,S;for(g=0;g<M.sps.length;g++)x=M.sps[g],S=x.byteLength,A.push(S>>>8&255),A.push(S&255),A=A.concat(Array.prototype.slice.call(x));for(g=0;g<M.pps.length;g++)x=M.pps[g],S=x.byteLength,w.push(S>>>8&255),w.push(S&255),w=w.concat(Array.prototype.slice.call(x));var E=L.box(L.types.avcC,new Uint8Array([1,A[3],A[4],A[5],252|3,224|M.sps.length].concat(A).concat([M.pps.length]).concat(w))),b=M.width,y=M.height,h=M.pixelRatio[0],e=M.pixelRatio[1];return L.box(L.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,b>>8&255,b&255,y>>8&255,y&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),E,L.box(L.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),L.box(L.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,e>>24,e>>16&255,e>>8&255,e&255])))},L.esds=function(M){var A=M.config.length;return new Uint8Array([0,0,0,0,3,23+A,0,1,0,4,15+A,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([A]).concat(M.config).concat([6,1,2]))},L.mp4a=function(M){var A=M.samplerate;return L.box(L.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,M.channelCount,0,16,0,0,0,0,A>>8&255,A&255,0,0]),L.box(L.types.esds,L.esds(M)))},L.mp3=function(M){var A=M.samplerate;return L.box(L.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,M.channelCount,0,16,0,0,0,0,A>>8&255,A&255,0,0]))},L.stsd=function(M){return M.type==="audio"?!M.isAAC&&M.codec==="mp3"?L.box(L.types.stsd,L.STSD,L.mp3(M)):L.box(L.types.stsd,L.STSD,L.mp4a(M)):L.box(L.types.stsd,L.STSD,L.avc1(M))},L.tkhd=function(M){var A=M.id,w=M.duration*M.timescale,g=M.width,x=M.height,S=Math.floor(w/(B+1)),E=Math.floor(w%(B+1));return L.box(L.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,A>>24&255,A>>16&255,A>>8&255,A&255,0,0,0,0,S>>24,S>>16&255,S>>8&255,S&255,E>>24,E>>16&255,E>>8&255,E&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,g>>8&255,g&255,0,0,x>>8&255,x&255,0,0]))},L.traf=function(M,A){var w=L.sdtp(M),g=M.id,x=Math.floor(A/(B+1)),S=Math.floor(A%(B+1));return L.box(L.types.traf,L.box(L.types.tfhd,new Uint8Array([0,0,0,0,g>>24,g>>16&255,g>>8&255,g&255])),L.box(L.types.tfdt,new Uint8Array([1,0,0,0,x>>24,x>>16&255,x>>8&255,x&255,S>>24,S>>16&255,S>>8&255,S&255])),L.trun(M,w.length+16+20+8+16+8+8),w)},L.trak=function(M){return M.duration=M.duration||4294967295,L.box(L.types.trak,L.tkhd(M),L.mdia(M))},L.trex=function(M){var A=M.id;return L.box(L.types.trex,new Uint8Array([0,0,0,0,A>>24,A>>16&255,A>>8&255,A&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},L.trun=function(M,A){var w=M.samples||[],g=w.length,x=12+16*g,S=new Uint8Array(x),E,b,y,h,e,s;for(A+=8+x,S.set([0,0,15,1,g>>>24&255,g>>>16&255,g>>>8&255,g&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255],0),E=0;E<g;E++)b=w[E],y=b.duration,h=b.size,e=b.flags,s=b.cts,S.set([y>>>24&255,y>>>16&255,y>>>8&255,y&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,s>>>24&255,s>>>16&255,s>>>8&255,s&255],12+16*E);return L.box(L.types.trun,S)},L.initSegment=function(M){L.types||L.init();var A=L.moov(M),w=new Uint8Array(L.FTYP.byteLength+A.byteLength);return w.set(L.FTYP),w.set(A,L.FTYP.byteLength),w},L}();O.types=void 0,O.HDLR_TYPES=void 0,O.STTS=void 0,O.STSC=void 0,O.STCO=void 0,O.STSZ=void 0,O.VMHD=void 0,O.SMHD=void 0,O.STSD=void 0,O.FTYP=void 0,O.DINF=void 0,U.default=O},"./src/remux/mp4-remuxer.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return s}),C.d(U,"normalizePts",function(){return o});var B=C("./src/polyfills/number.ts"),O=C("./src/remux/aac-helper.ts"),L=C("./src/remux/mp4-generator.ts"),_=C("./src/events.ts"),M=C("./src/errors.ts"),A=C("./src/utils/logger.ts"),w=C("./src/types/loader.ts"),g=C("./src/utils/timescale-conversion.ts");function x(){return x=Object.assign||function(p){for(var c=1;c<arguments.length;c++){var i=arguments[c];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(p[r]=i[r])}return p},x.apply(this,arguments)}var S=10*1e3,E=1024,b=1152,y=null,h=null,e=!1,s=function(){function p(i,r,t,a){if(a===void 0&&(a=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=i,this.config=r,this.typeSupported=t,this.ISGenerated=!1,y===null){var m=navigator.userAgent||"",v=m.match(/Chrome\/(\d+)/i);y=v?parseInt(v[1]):0}if(h===null){var T=navigator.userAgent.match(/Safari\/(\d+)/i);h=T?parseInt(T[1]):0}e=!!y&&y<75||!!h&&h<600}var c=p.prototype;return c.destroy=function(){},c.resetTimeStamp=function(r){A.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=r},c.resetNextTimestamp=function(){A.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},c.resetInitSegment=function(){A.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},c.getVideoStartPts=function(r){var t=!1,a=r.reduce(function(m,v){var T=v.pts-m;return T<-4294967296?(t=!0,o(m,v.pts)):T>0?m:v.pts},r[0].pts);return t&&A.logger.debug("PTS rollover detected"),a},c.remux=function(r,t,a,m,v,T,k,I){var F,K,V,Q,Z,ie,ge=v,se=v,he=r.pid>-1,de=t.pid>-1,$=t.samples.length,Y=r.samples.length>0,ne=$>1,z=(!he||Y)&&(!de||ne)||this.ISGenerated||k;if(z){this.ISGenerated||(V=this.generateIS(r,t,v));var H=this.isVideoContiguous,me=-1;if(ne&&(me=f(t.samples),!H&&this.config.forceKeyFrameOnDiscontinuity))if(ie=!0,me>0){A.logger.warn("[mp4-remuxer]: Dropped "+me+" out of "+$+" video samples due to a missing keyframe");var Le=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(me),t.dropped+=me,se+=(t.samples[0].pts-Le)/(t.timescale||9e4)}else me===-1&&(A.logger.warn("[mp4-remuxer]: No keyframe found out of "+$+" video samples"),ie=!1);if(this.ISGenerated){if(Y&&ne){var Oe=this.getVideoStartPts(t.samples),we=o(r.samples[0].pts,Oe)-Oe,De=we/t.inputTimeScale;ge+=Math.max(0,De),se+=Math.max(0,-De)}if(Y){if(r.samplerate||(A.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),V=this.generateIS(r,t,v)),K=this.remuxAudio(r,ge,this.isAudioContiguous,T,de||ne||I===w.PlaylistLevelType.AUDIO?se:void 0),ne){var le=K?K.endPTS-K.startPTS:0;t.inputTimeScale||(A.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),V=this.generateIS(r,t,v)),F=this.remuxVideo(t,se,H,le)}}else ne&&(F=this.remuxVideo(t,se,H,0));F&&(F.firstKeyFrame=me,F.independent=me!==-1)}}return this.ISGenerated&&(a.samples.length&&(Z=this.remuxID3(a,v)),m.samples.length&&(Q=this.remuxText(m,v))),{audio:K,video:F,initSegment:V,independent:ie,text:Q,id3:Z}},c.generateIS=function(r,t,a){var m=r.samples,v=t.samples,T=this.typeSupported,k={},I=!Object(B.isFiniteNumber)(this._initPTS),F="audio/mp4",K,V,Q;if(I&&(K=V=Infinity),r.config&&m.length&&(r.timescale=r.samplerate,r.isAAC||(T.mpeg?(F="audio/mpeg",r.codec=""):T.mp3&&(r.codec="mp3")),k.audio={id:"audio",container:F,codec:r.codec,initSegment:!r.isAAC&&T.mpeg?new Uint8Array(0):L.default.initSegment([r]),metadata:{channelCount:r.channelCount}},I&&(Q=r.inputTimeScale,K=V=m[0].pts-Math.round(Q*a))),t.sps&&t.pps&&v.length&&(t.timescale=t.inputTimeScale,k.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:L.default.initSegment([t]),metadata:{width:t.width,height:t.height}},I)){Q=t.inputTimeScale;var Z=this.getVideoStartPts(v),ie=Math.round(Q*a);V=Math.min(V,o(v[0].dts,Z)-ie),K=Math.min(K,Z-ie)}if(Object.keys(k).length)return this.ISGenerated=!0,I&&(this._initPTS=K,this._initDTS=V),{tracks:k,initPTS:K,timescale:Q}},c.remuxVideo=function(r,t,a,m){var v=r.inputTimeScale,T=r.samples,k=[],I=T.length,F=this._initPTS,K=this.nextAvcDts,V=8,Q,Z,ie,ge=Number.POSITIVE_INFINITY,se=Number.NEGATIVE_INFINITY,he=0,de=!1;if(!a||K===null){var $=t*v,Y=T[0].pts-o(T[0].dts,T[0].pts);K=$-Y}for(var ne=0;ne<I;ne++){var z=T[ne];if(z.pts=o(z.pts-F,K),z.dts=o(z.dts-F,K),z.dts>z.pts){var H=9e4*.2;he=Math.max(Math.min(he,z.pts-z.dts),-1*H)}z.dts<T[ne>0?ne-1:ne].dts&&(de=!0)}de&&T.sort(function(Ze,et){var Xe=Ze.dts-et.dts,mt=Ze.pts-et.pts;return Xe||mt}),Z=T[0].dts,ie=T[T.length-1].dts;var me=Math.round((ie-Z)/(I-1));if(he<0){if(he<me*-2){A.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(g.toMsFromMpegTsClock)(-me,!0)+" ms");for(var Le=he,Oe=0;Oe<I;Oe++)T[Oe].dts=Le=Math.max(Le,T[Oe].pts-me),T[Oe].pts=Math.max(Le,T[Oe].pts)}else{A.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(g.toMsFromMpegTsClock)(he,!0)+" ms to overcome this issue");for(var we=0;we<I;we++)T[we].dts=T[we].dts+he}Z=T[0].dts}if(a){var De=Z-K,le=De>me,pe=De<-1;if(le||pe){le?A.logger.warn("AVC: "+Object(g.toMsFromMpegTsClock)(De,!0)+" ms ("+De+"dts) hole between fragments detected, filling it"):A.logger.warn("AVC: "+Object(g.toMsFromMpegTsClock)(-De,!0)+" ms ("+De+"dts) overlapping between fragments detected"),Z=K;var Ee=T[0].pts-De;T[0].dts=Z,T[0].pts=Ee,A.logger.log("Video: First PTS/DTS adjusted: "+Object(g.toMsFromMpegTsClock)(Ee,!0)+"/"+Object(g.toMsFromMpegTsClock)(Z,!0)+", delta: "+Object(g.toMsFromMpegTsClock)(De,!0)+" ms")}}e&&(Z=Math.max(0,Z));for(var Te=0,Ie=0,ke=0;ke<I;ke++){for(var Me=T[ke],Fe=Me.units,ae=Fe.length,ue=0,be=0;be<ae;be++)ue+=Fe[be].data.length;Ie+=ue,Te+=ae,Me.length=ue,Me.dts=Math.max(Me.dts,Z),Me.pts=Math.max(Me.pts,Me.dts,0),ge=Math.min(Me.pts,ge),se=Math.max(Me.pts,se)}ie=T[I-1].dts;var xe=Ie+4*Te+8,Ce;try{Ce=new Uint8Array(xe)}catch(Ze){this.observer.emit(_.Events.ERROR,_.Events.ERROR,{type:M.ErrorTypes.MUX_ERROR,details:M.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:xe,reason:"fail allocating video mdat "+xe});return}var Se=new DataView(Ce.buffer);Se.setUint32(0,xe),Ce.set(L.default.types.mdat,4);for(var ye=0;ye<I;ye++){for(var Ne=T[ye],Be=Ne.units,ve=0,_e=0,re=Be.length;_e<re;_e++){var q=Be[_e],te=q.data,j=q.data.byteLength;Se.setUint32(V,j),V+=4,Ce.set(te,V),V+=j,ve+=4+j}if(ye<I-1)Q=T[ye+1].dts-Ne.dts;else{var W=this.config,G=Ne.dts-T[ye>0?ye-1:ye].dts;if(W.stretchShortVideoTrack&&this.nextAudioPts!==null){var X=Math.floor(W.maxBufferHole*v),oe=(m?ge+m*v:this.nextAudioPts)-Ne.pts;oe>X?(Q=oe-G,Q<0&&(Q=G),A.logger.log("[mp4-remuxer]: It is approximately "+oe/90+" ms to the next segment; using duration "+Q/90+" ms for the last video frame.")):Q=G}else Q=G}var ce=Math.round(Ne.pts-Ne.dts);k.push(new u(Ne.key,Q,ve,ce))}if(k.length&&y&&y<70){var Pe=k[0].flags;Pe.dependsOn=2,Pe.isNonSync=0}console.assert(Q!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=K=ie+Q,this.isVideoContiguous=!0;var He=L.default.moof(r.sequenceNumber++,Z,x({},r,{samples:k})),$e="video",ze={data1:He,data2:Ce,startPTS:ge/v,endPTS:(se+Q)/v,startDTS:Z/v,endDTS:K/v,type:$e,hasAudio:!1,hasVideo:!0,nb:k.length,dropped:r.dropped};return r.samples=[],r.dropped=0,console.assert(Ce.length,"MDAT length must not be zero"),ze},c.remuxAudio=function(r,t,a,m,v){var T=r.inputTimeScale,k=r.samplerate?r.samplerate:T,I=T/k,F=r.isAAC?E:b,K=F*I,V=this._initPTS,Q=!r.isAAC&&this.typeSupported.mpeg,Z=[],ie=r.samples,ge=Q?0:8,se=this.nextAudioPts||-1,he=t*T;if(this.isAudioContiguous=a=a||ie.length&&se>0&&(m&&Math.abs(he-se)<9e3||Math.abs(o(ie[0].pts-V,he)-se)<20*K),ie.forEach(function(te){te.pts=o(te.pts-V,he)}),!a||se<0){if(ie=ie.filter(function(te){return te.pts>=0}),!ie.length)return;v===0?se=0:m?se=Math.max(0,he):se=ie[0].pts}if(r.isAAC)for(var de=v!==void 0,$=this.config.maxAudioFramesDrift,Y=0,ne=se;Y<ie.length;Y++){var z=ie[Y],H=z.pts,me=H-ne,Le=Math.abs(1e3*me/T);if(me<=-$*K&&de)Y===0&&(A.logger.warn("Audio frame @ "+(H/T).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*me/T)+" ms."),this.nextAudioPts=se=ne=H);else if(me>=$*K&&Le<S&&de){var Oe=Math.round(me/K);ne=H-Oe*K,ne<0&&(Oe--,ne+=K),Y===0&&(this.nextAudioPts=se=ne),A.logger.warn("[mp4-remuxer]: Injecting "+Oe+" audio frame @ "+(ne/T).toFixed(3)+"s due to "+Math.round(1e3*me/T)+" ms gap.");for(var we=0;we<Oe;we++){var De=Math.max(ne,0),le=O.default.getSilentFrame(r.manifestCodec||r.codec,r.channelCount);le||(A.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),le=z.unit.subarray()),ie.splice(Y,0,{unit:le,pts:De}),ne+=K,Y++}}z.pts=ne,ne+=K}for(var pe=null,Ee=null,Te,Ie=0,ke=ie.length;ke--;)Ie+=ie[ke].unit.byteLength;for(var Me=0,Fe=ie.length;Me<Fe;Me++){var ae=ie[Me],ue=ae.unit,be=ae.pts;if(Ee!==null){var xe=Z[Me-1];xe.duration=Math.round((be-Ee)/I)}else if(a&&r.isAAC&&(be=se),pe=be,Ie>0){Ie+=ge;try{Te=new Uint8Array(Ie)}catch(te){this.observer.emit(_.Events.ERROR,_.Events.ERROR,{type:M.ErrorTypes.MUX_ERROR,details:M.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ie,reason:"fail allocating audio mdat "+Ie});return}if(!Q){var Ce=new DataView(Te.buffer);Ce.setUint32(0,Ie),Te.set(L.default.types.mdat,4)}}else return;Te.set(ue,ge);var Se=ue.byteLength;ge+=Se,Z.push(new u(!0,F,Se,0)),Ee=be}var ye=Z.length;if(!ye)return;var Ne=Z[Z.length-1];this.nextAudioPts=se=Ee+I*Ne.duration;var Be=Q?new Uint8Array(0):L.default.moof(r.sequenceNumber++,pe/I,x({},r,{samples:Z}));r.samples=[];var ve=pe/T,_e=se/T,re="audio",q={data1:Be,data2:Te,startPTS:ve,endPTS:_e,startDTS:ve,endDTS:_e,type:re,hasAudio:!0,hasVideo:!1,nb:ye};return this.isAudioContiguous=!0,console.assert(Te.length,"MDAT length must not be zero"),q},c.remuxEmptyAudio=function(r,t,a,m){var v=r.inputTimeScale,T=r.samplerate?r.samplerate:v,k=v/T,I=this.nextAudioPts,F=(I!==null?I:m.startDTS*v)+this._initDTS,K=m.endDTS*v+this._initDTS,V=k*E,Q=Math.ceil((K-F)/V),Z=O.default.getSilentFrame(r.manifestCodec||r.codec,r.channelCount);if(A.logger.warn("[mp4-remuxer]: remux empty Audio"),!Z){A.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var ie=[],ge=0;ge<Q;ge++){var se=F+ge*V;ie.push({unit:Z,pts:se,dts:se})}return r.samples=ie,this.remuxAudio(r,t,a,!1)},c.remuxID3=function(r,t){var a=r.samples.length;if(!a)return;for(var m=r.inputTimeScale,v=this._initPTS,T=this._initDTS,k=0;k<a;k++){var I=r.samples[k];I.pts=o(I.pts-v,t*m)/m,I.dts=o(I.dts-T,t*m)/m}var F=r.samples;return r.samples=[],{samples:F}},c.remuxText=function(r,t){var a=r.samples.length;if(!a)return;for(var m=r.inputTimeScale,v=this._initPTS,T=0;T<a;T++){var k=r.samples[T];k.pts=o(k.pts-v,t*m)/m}r.samples.sort(function(F,K){return F.pts-K.pts});var I=r.samples;return r.samples=[],{samples:I}},p}();function o(p,c){var i;if(c===null)return p;for(c<p?i=-8589934592:i=8589934592;Math.abs(p-c)>4294967296;)p+=i;return p}function f(p){for(var c=0;c<p.length;c++)if(p[c].key)return c;return-1}var u=function(c,i,r,t){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=i,this.size=r,this.cts=t,this.flags=new l(c)},l=function(c){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=c?2:1,this.isNonSync=c?0:1}},"./src/remux/passthrough-remuxer.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/polyfills/number.ts"),O=C("./src/utils/mp4-tools.ts"),L=C("./src/loader/fragment.ts"),_=C("./src/utils/logger.ts"),M=function(){function g(){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 x=g.prototype;return x.destroy=function(){},x.resetTimeStamp=function(E){this.initPTS=E,this.lastEndDTS=null},x.resetNextTimestamp=function(){this.lastEndDTS=null},x.resetInitSegment=function(E,b,y){this.audioCodec=b,this.videoCodec=y,this.generateInitSegment(E),this.emitInitSegment=!0},x.generateInitSegment=function(E){var b=this.audioCodec,y=this.videoCodec;if(!E||!E.byteLength){this.initTracks=void 0,this.initData=void 0;return}var h=this.initData=Object(O.parseInitSegment)(E);b||(b=w(h.audio,L.ElementaryStreamTypes.AUDIO)),y||(y=w(h.video,L.ElementaryStreamTypes.VIDEO));var e={};h.audio&&h.video?e.audiovideo={container:"video/mp4",codec:b+","+y,initSegment:E,id:"main"}:h.audio?e.audio={container:"audio/mp4",codec:b,initSegment:E,id:"audio"}:h.video?e.video={container:"video/mp4",codec:y,initSegment:E,id:"main"}:_.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},x.remux=function(E,b,y,h,e){var s=this.initPTS,o=this.lastEndDTS,f={audio:void 0,video:void 0,text:h,id3:y,initSegment:void 0};Object(B.isFiniteNumber)(o)||(o=this.lastEndDTS=e||0);var u=b.samples;if(!u||!u.length)return f;var l={initPTS:void 0,timescale:1},p=this.initData;if((!p||!p.length)&&(this.generateInitSegment(u),p=this.initData),!p||!p.length)return _.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),f;this.emitInitSegment&&(l.tracks=this.initTracks,this.emitInitSegment=!1),Object(B.isFiniteNumber)(s)||(this.initPTS=l.initPTS=s=A(p,u,o));var c=Object(O.getDuration)(u,p),i=o,r=c+i;Object(O.offsetStartDTS)(p,u,s),c>0?this.lastEndDTS=r:(_.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var t=!!p.audio,a=!!p.video,m="";t&&(m+="audio"),a&&(m+="video");var v={data1:u,startPTS:i,startDTS:i,endPTS:r,endDTS:r,type:m,hasAudio:t,hasVideo:a,nb:1,dropped:0};return f.audio=v.type==="audio"?v:void 0,f.video=v.type!=="audio"?v:void 0,f.text=h,f.id3=y,f.initSegment=l,f},g}(),A=function(x,S,E){return Object(O.getStartDTS)(x,S)-E};function w(g,x){var S=g==null?void 0:g.codec;return S&&S.length>4?S:S==="hvc1"?"hvc1.1.c.L120.90":S==="av01"?"av01.0.04M.08":S==="avc1"||x===L.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}U.default=M},"./src/task-loop.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return B});var B=function(){function O(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var L=O.prototype;return L.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},L.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},L.onHandlerDestroyed=function(){},L.hasInterval=function(){return!!this._tickInterval},L.hasNextTick=function(){return!!this._tickTimer},L.setInterval=function(M){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,M),!0)},L.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},L.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},L.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},L.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},L.doTick=function(){},O}()},"./src/types/cmcd.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"CMCDVersion",function(){return B}),C.d(U,"CMCDObjectType",function(){return O}),C.d(U,"CMCDStreamingFormat",function(){return L}),C.d(U,"CMCDStreamType",function(){return _});var B=1,O;(function(M){M.MANIFEST="m",M.AUDIO="a",M.VIDEO="v",M.MUXED="av",M.INIT="i",M.CAPTION="c",M.TIMED_TEXT="tt",M.KEY="k",M.OTHER="o"})(O||(O={}));var L;(function(M){M.DASH="d",M.HLS="h",M.SMOOTH="s",M.OTHER="o"})(L||(L={}));var _;(function(M){M.VOD="v",M.LIVE="l"})(_||(_={}))},"./src/types/level.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"HlsSkip",function(){return L}),C.d(U,"getSkipValue",function(){return _}),C.d(U,"HlsUrlParameters",function(){return M}),C.d(U,"Level",function(){return A});function B(w,g){for(var x=0;x<g.length;x++){var S=g[x];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(w,S.key,S)}}function O(w,g,x){return g&&B(w.prototype,g),x&&B(w,x),w}var L;(function(w){w.No="",w.Yes="YES",w.v2="v2"})(L||(L={}));function _(w,g){var x=w.canSkipUntil,S=w.canSkipDateRanges,E=w.endSN,b=g!==void 0?g-E:0;return x&&b<x?S?L.v2:L.Yes:L.No}var M=function(){function w(x,S,E){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=x,this.part=S,this.skip=E}var g=w.prototype;return g.addDirectives=function(S){var E=new self.URL(S);return this.msn!==void 0&&E.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&E.searchParams.set("_HLS_part",this.part.toString()),this.skip&&E.searchParams.set("_HLS_skip",this.skip),E.toString()},w}(),A=function(){function w(g){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=[g.url],this.attrs=g.attrs,this.bitrate=g.bitrate,g.details&&(this.details=g.details),this.id=g.id||0,this.name=g.name,this.width=g.width||0,this.height=g.height||0,this.audioCodec=g.audioCodec,this.videoCodec=g.videoCodec,this.unknownCodecs=g.unknownCodecs,this.codecSet=[g.videoCodec,g.audioCodec].filter(function(x){return x}).join(",").replace(/\.[^.,]+/g,"")}return O(w,[{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(x){var S=x%this.url.length;this._urlId!==S&&(this.details=void 0,this._urlId=S)}}]),w}()},"./src/types/loader.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"PlaylistContextType",function(){return B}),C.d(U,"PlaylistLevelType",function(){return O});var B;(function(L){L.MANIFEST="manifest",L.LEVEL="level",L.AUDIO_TRACK="audioTrack",L.SUBTITLE_TRACK="subtitleTrack"})(B||(B={}));var O;(function(L){L.MAIN="main",L.AUDIO="audio",L.SUBTITLE="subtitle"})(O||(O={}))},"./src/types/transmuxer.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"ChunkMetadata",function(){return B});var B=function(_,M,A,w,g,x){w===void 0&&(w=0),g===void 0&&(g=-1),x===void 0&&(x=!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=O(),this.buffering={audio:O(),video:O(),audiovideo:O()},this.level=_,this.sn=M,this.id=A,this.size=w,this.part=g,this.partial=x};function O(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"AttrList",function(){return L});var B=/^(\d+)x(\d+)$/,O=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,L=function(){function _(A){typeof A=="string"&&(A=_.parseAttrList(A));for(var w in A)A.hasOwnProperty(w)&&(this[w]=A[w])}var M=_.prototype;return M.decimalInteger=function(w){var g=parseInt(this[w],10);return g>Number.MAX_SAFE_INTEGER?Infinity:g},M.hexadecimalInteger=function(w){if(this[w]){var g=(this[w]||"0x").slice(2);g=(g.length&1?"0":"")+g;for(var x=new Uint8Array(g.length/2),S=0;S<g.length/2;S++)x[S]=parseInt(g.slice(S*2,S*2+2),16);return x}else return null},M.hexadecimalIntegerAsNumber=function(w){var g=parseInt(this[w],16);return g>Number.MAX_SAFE_INTEGER?Infinity:g},M.decimalFloatingPoint=function(w){return parseFloat(this[w])},M.optionalFloat=function(w,g){var x=this[w];return x?parseFloat(x):g},M.enumeratedString=function(w){return this[w]},M.bool=function(w){return this[w]==="YES"},M.decimalResolution=function(w){var g=B.exec(this[w]);return g===null?void 0:{width:parseInt(g[1],10),height:parseInt(g[2],10)}},_.parseAttrList=function(w){var g,x={},S='"';for(O.lastIndex=0;(g=O.exec(w))!==null;){var E=g[2];E.indexOf(S)===0&&E.lastIndexOf(S)===E.length-1&&(E=E.slice(1,-1)),x[g[1]]=E}return x},_}()},"./src/utils/binary-search.ts":function(fe,U,C){"use strict";C.r(U);var B={search:function(L,_){for(var M=0,A=L.length-1,w=null,g=null;M<=A;){w=(M+A)/2|0,g=L[w];var x=_(g);if(x>0)M=w+1;else if(x<0)A=w-1;else return g}return null}};U.default=B},"./src/utils/buffer-helper.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"BufferHelper",function(){return L});var B=C("./src/utils/logger.ts"),O={length:0,start:function(){return 0},end:function(){return 0}},L=function(){function _(){}return _.isBuffered=function(A,w){try{if(A){for(var g=_.getBuffered(A),x=0;x<g.length;x++)if(w>=g.start(x)&&w<=g.end(x))return!0}}catch(S){}return!1},_.bufferInfo=function(A,w,g){try{if(A){var x=_.getBuffered(A),S=[],E;for(E=0;E<x.length;E++)S.push({start:x.start(E),end:x.end(E)});return this.bufferedInfo(S,w,g)}}catch(b){}return{len:0,start:w,end:w,nextStart:void 0}},_.bufferedInfo=function(A,w,g){w=Math.max(0,w),A.sort(function(l,p){var c=l.start-p.start;return c||p.end-l.end});var x=[];if(g)for(var S=0;S<A.length;S++){var E=x.length;if(E){var b=x[E-1].end;A[S].start-b<g?A[S].end>b&&(x[E-1].end=A[S].end):x.push(A[S])}else x.push(A[S])}else x=A;for(var y=0,h,e=w,s=w,o=0;o<x.length;o++){var f=x[o].start,u=x[o].end;if(w+g>=f&&w<u)e=f,s=u,y=s-w;else if(w+g<f){h=f;break}}return{len:y,start:e||0,end:s||0,nextStart:h}},_.getBuffered=function(A){try{return A.buffered}catch(w){return B.logger.log("failed to get media.buffered",w),O}},_}()},"./src/utils/cea-608-parser.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"Row",function(){return s}),C.d(U,"CaptionScreen",function(){return o});var B=C("./src/utils/logger.ts"),O={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},L=function(r){var t=r;return O.hasOwnProperty(r)&&(t=O[r]),String.fromCharCode(t)},_=15,M=100,A={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},w={17:2,18:4,21:6,22:8,23:10,19:13,20:15},g={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},x={25:2,26:4,29:6,30:8,31:10,27:13,28:15},S=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],E;(function(i){i[i.ERROR=0]="ERROR",i[i.TEXT=1]="TEXT",i[i.WARNING=2]="WARNING",i[i.INFO=2]="INFO",i[i.DEBUG=3]="DEBUG",i[i.DATA=3]="DATA"})(E||(E={}));var b=function(){function i(){this.time=null,this.verboseLevel=E.ERROR}var r=i.prototype;return r.log=function(a,m){this.verboseLevel>=a&&B.logger.log(this.time+" ["+a+"] "+m)},i}(),y=function(r){for(var t=[],a=0;a<r.length;a++)t.push(r[a].toString(16));return t},h=function(){function i(t,a,m,v,T){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=a||!1,this.italics=m||!1,this.background=v||"black",this.flash=T||!1}var r=i.prototype;return r.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},r.setStyles=function(a){for(var m=["foreground","underline","italics","background","flash"],v=0;v<m.length;v++){var T=m[v];a.hasOwnProperty(T)&&(this[T]=a[T])}},r.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},r.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},r.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},r.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},i}(),e=function(){function i(t,a,m,v,T,k){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new h(a,m,v,T,k)}var r=i.prototype;return r.reset=function(){this.uchar=" ",this.penState.reset()},r.setChar=function(a,m){this.uchar=a,this.penState.copy(m)},r.setPenState=function(a){this.penState.copy(a)},r.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},r.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},r.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},i}(),s=function(){function i(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 a=0;a<M;a++)this.chars.push(new e);this.logger=t,this.pos=0,this.currPenState=new h}var r=i.prototype;return r.equals=function(a){for(var m=!0,v=0;v<M;v++)if(!this.chars[v].equals(a.chars[v])){m=!1;break}return m},r.copy=function(a){for(var m=0;m<M;m++)this.chars[m].copy(a.chars[m])},r.isEmpty=function(){for(var a=!0,m=0;m<M;m++)if(!this.chars[m].isEmpty()){a=!1;break}return a},r.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(E.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>M&&(this.logger.log(E.DEBUG,"Too large cursor position "+this.pos),this.pos=M)},r.moveCursor=function(a){var m=this.pos+a;if(a>1)for(var v=this.pos+1;v<m+1;v++)this.chars[v].setPenState(this.currPenState);this.setCursor(m)},r.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},r.insertChar=function(a){a>=144&&this.backSpace();var m=L(a);if(this.pos>=M){this.logger.log(E.ERROR,"Cannot insert "+a.toString(16)+" ("+m+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(m,this.currPenState),this.moveCursor(1)},r.clearFromPos=function(a){var m;for(m=a;m<M;m++)this.chars[m].reset()},r.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},r.clearToEndOfRow=function(){this.clearFromPos(this.pos)},r.getTextString=function(){for(var a=[],m=!0,v=0;v<M;v++){var T=this.chars[v].uchar;T!==" "&&(m=!1),a.push(T)}return m?"":a.join("")},r.setPenStyles=function(a){this.currPenState.setStyles(a);var m=this.chars[this.pos];m.setPenState(this.currPenState)},i}(),o=function(){function i(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 a=0;a<_;a++)this.rows.push(new s(t));this.logger=t,this.currRow=_-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var r=i.prototype;return r.reset=function(){for(var a=0;a<_;a++)this.rows[a].clear();this.currRow=_-1},r.equals=function(a){for(var m=!0,v=0;v<_;v++)if(!this.rows[v].equals(a.rows[v])){m=!1;break}return m},r.copy=function(a){for(var m=0;m<_;m++)this.rows[m].copy(a.rows[m])},r.isEmpty=function(){for(var a=!0,m=0;m<_;m++)if(!this.rows[m].isEmpty()){a=!1;break}return a},r.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},r.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},r.insertChar=function(a){var m=this.rows[this.currRow];m.insertChar(a)},r.setPen=function(a){var m=this.rows[this.currRow];m.setPenStyles(a)},r.moveCursor=function(a){var m=this.rows[this.currRow];m.moveCursor(a)},r.setCursor=function(a){this.logger.log(E.INFO,"setCursor: "+a);var m=this.rows[this.currRow];m.setCursor(a)},r.setPAC=function(a){this.logger.log(E.INFO,"pacData = "+JSON.stringify(a));var m=a.row-1;if(this.nrRollUpRows&&m<this.nrRollUpRows-1&&(m=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==m){for(var v=0;v<_;v++)this.rows[v].clear();var T=this.currRow+1-this.nrRollUpRows,k=this.lastOutputScreen;if(k){var I=k.rows[T].cueStartTime,F=this.logger.time;if(I&&F!==null&&I<F)for(var K=0;K<this.nrRollUpRows;K++)this.rows[m-this.nrRollUpRows+K+1].copy(k.rows[T+K])}}this.currRow=m;var V=this.rows[this.currRow];if(a.indent!==null){var Q=a.indent,Z=Math.max(Q-1,0);V.setCursor(a.indent),a.color=V.chars[Z].penState.foreground}var ie={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(ie)},r.setBkgData=function(a){this.logger.log(E.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},r.setRollUpRows=function(a){this.nrRollUpRows=a},r.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(E.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(E.TEXT,this.getDisplayText());var a=this.currRow+1-this.nrRollUpRows,m=this.rows.splice(a,1)[0];m.clear(),this.rows.splice(this.currRow,0,m),this.logger.log(E.INFO,"Rolling up")},r.getDisplayText=function(a){a=a||!1;for(var m=[],v="",T=-1,k=0;k<_;k++){var I=this.rows[k].getTextString();I&&(T=k+1,a?m.push("Row "+T+": '"+I+"'"):m.push(I.trim()))}return m.length>0&&(a?v="["+m.join(" | ")+"]":v=m.join(`
|
|
`)),v},r.getTextAndFormat=function(){return this.rows},i}(),f=function(){function i(t,a,m){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=a,this.mode=null,this.verbose=0,this.displayedMemory=new o(m),this.nonDisplayedMemory=new o(m),this.lastOutputScreen=new o(m),this.currRollUpRow=this.displayedMemory.rows[_-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=m}var r=i.prototype;return r.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[_-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},r.getHandler=function(){return this.outputFilter},r.setHandler=function(a){this.outputFilter=a},r.setPAC=function(a){this.writeScreen.setPAC(a)},r.setBkgData=function(a){this.writeScreen.setBkgData(a)},r.setMode=function(a){if(a===this.mode)return;this.mode=a,this.logger.log(E.INFO,"MODE="+a),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=a},r.insertChars=function(a){for(var m=0;m<a.length;m++)this.writeScreen.insertChar(a[m]);var v=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(E.INFO,v+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(E.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},r.ccRCL=function(){this.logger.log(E.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},r.ccBS=function(){if(this.logger.log(E.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},r.ccAOF=function(){},r.ccAON=function(){},r.ccDER=function(){this.logger.log(E.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},r.ccRU=function(a){this.logger.log(E.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},r.ccFON=function(){this.logger.log(E.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},r.ccRDC=function(){this.logger.log(E.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},r.ccTR=function(){this.logger.log(E.INFO,"TR"),this.setMode("MODE_TEXT")},r.ccRTD=function(){this.logger.log(E.INFO,"RTD"),this.setMode("MODE_TEXT")},r.ccEDM=function(){this.logger.log(E.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},r.ccCR=function(){this.logger.log(E.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},r.ccENM=function(){this.logger.log(E.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},r.ccEOC=function(){if(this.logger.log(E.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var a=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=a,this.writeScreen=this.nonDisplayedMemory,this.logger.log(E.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},r.ccTO=function(a){this.logger.log(E.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},r.ccMIDROW=function(a){var m={flash:!1};if(m.underline=a%2===1,m.italics=a>=46,m.italics)m.foreground="white";else{var v=Math.floor(a/2)-16,T=["white","green","blue","cyan","red","yellow","magenta"];m.foreground=T[v]}this.logger.log(E.INFO,"MIDROW: "+JSON.stringify(m)),this.writeScreen.setPen(m)},r.outputDataUpdate=function(a){a===void 0&&(a=!1);var m=this.logger.time;if(m===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=m:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,m,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:m),this.lastOutputScreen.copy(this.displayedMemory))},r.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},i}(),u=function(){function i(t,a,m){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var v=new b;this.channels=[null,new f(t,a,v),new f(t+1,m,v)],this.cmdHistory=c(),this.logger=v}var r=i.prototype;return r.getHandler=function(a){return this.channels[a].getHandler()},r.setHandler=function(a,m){this.channels[a].setHandler(m)},r.addData=function(a,m){var v,T,k,I=!1;this.logger.time=a;for(var F=0;F<m.length;F+=2){if(T=m[F]&127,k=m[F+1]&127,T===0&&k===0)continue;if(this.logger.log(E.DATA,"["+y([m[F],m[F+1]])+"] -> ("+y([T,k])+")"),v=this.parseCmd(T,k),v||(v=this.parseMidrow(T,k)),v||(v=this.parsePAC(T,k)),v||(v=this.parseBackgroundAttributes(T,k)),!v&&(I=this.parseChars(T,k),I)){var K=this.currentChannel;if(K&&K>0){var V=this.channels[K];V.insertChars(I)}else this.logger.log(E.WARNING,"No channel found yet. TEXT-MODE?")}!v&&!I&&this.logger.log(E.WARNING,"Couldn't parse cleaned data "+y([T,k])+" orig: "+y([m[F],m[F+1]]))}},r.parseCmd=function(a,m){var v=this.cmdHistory,T=(a===20||a===28||a===21||a===29)&&m>=32&&m<=47,k=(a===23||a===31)&&m>=33&&m<=35;if(!(T||k))return!1;if(p(a,m,v))return l(null,null,v),this.logger.log(E.DEBUG,"Repeated command ("+y([a,m])+") is dropped"),!0;var I=a===20||a===21||a===23?1:2,F=this.channels[I];return a===20||a===21||a===28||a===29?m===32?F.ccRCL():m===33?F.ccBS():m===34?F.ccAOF():m===35?F.ccAON():m===36?F.ccDER():m===37?F.ccRU(2):m===38?F.ccRU(3):m===39?F.ccRU(4):m===40?F.ccFON():m===41?F.ccRDC():m===42?F.ccTR():m===43?F.ccRTD():m===44?F.ccEDM():m===45?F.ccCR():m===46?F.ccENM():m===47&&F.ccEOC():F.ccTO(m-32),l(a,m,v),this.currentChannel=I,!0},r.parseMidrow=function(a,m){var v=0;if((a===17||a===25)&&m>=32&&m<=47){if(a===17?v=1:v=2,v!==this.currentChannel)return this.logger.log(E.ERROR,"Mismatch channel in midrow parsing"),!1;var T=this.channels[v];return T?(T.ccMIDROW(m),this.logger.log(E.DEBUG,"MIDROW ("+y([a,m])+")"),!0):!1}return!1},r.parsePAC=function(a,m){var v,T=this.cmdHistory,k=(a>=17&&a<=23||a>=25&&a<=31)&&m>=64&&m<=127,I=(a===16||a===24)&&m>=64&&m<=95;if(!(k||I))return!1;if(p(a,m,T))return l(null,null,T),!0;var F=a<=23?1:2;m>=64&&m<=95?v=F===1?A[a]:g[a]:v=F===1?w[a]:x[a];var K=this.channels[F];return K?(K.setPAC(this.interpretPAC(v,m)),l(a,m,T),this.currentChannel=F,!0):!1},r.interpretPAC=function(a,m){var v,T={color:null,italics:!1,indent:null,underline:!1,row:a};return m>95?v=m-96:v=m-64,T.underline=(v&1)===1,v<=13?T.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(v/2)]:v<=15?(T.italics=!0,T.color="white"):T.indent=Math.floor((v-16)/2)*4,T},r.parseChars=function(a,m){var v,T=null,k=null;if(a>=25?(v=2,k=a-8):(v=1,k=a),k>=17&&k<=19){var I;k===17?I=m+80:k===18?I=m+112:I=m+144,this.logger.log(E.INFO,"Special char '"+L(I)+"' in channel "+v),T=[I]}else a>=32&&a<=127&&(T=m===0?[a]:[a,m]);if(T){var F=y(T);this.logger.log(E.DEBUG,"Char codes = "+F.join(",")),l(a,m,this.cmdHistory)}return T},r.parseBackgroundAttributes=function(a,m){var v=(a===16||a===24)&&m>=32&&m<=47,T=(a===23||a===31)&&m>=45&&m<=47;if(!(v||T))return!1;var k,I={};a===16||a===24?(k=Math.floor((m-32)/2),I.background=S[k],m%2===1&&(I.background=I.background+"_semi")):m===45?I.background="transparent":(I.foreground="black",m===47&&(I.underline=!0));var F=a<=23?1:2,K=this.channels[F];return K.setBkgData(I),l(a,m,this.cmdHistory),!0},r.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var m=this.channels[a];m&&m.reset()}this.cmdHistory=c()},r.cueSplitAtTime=function(a){for(var m=0;m<this.channels.length;m++){var v=this.channels[m];v&&v.cueSplitAtTime(a)}},i}();function l(i,r,t){t.a=i,t.b=r}function p(i,r,t){return t.a===i&&t.b===r}function c(){return{a:null,b:null}}U.default=u},"./src/utils/codecs.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"isCodecType",function(){return O}),C.d(U,"isCodecSupportedInMp4",function(){return L});var B={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 O(_,M){var A=B[M];return!!A&&A[_.slice(0,4)]===!0}function L(_,M){return MediaSource.isTypeSupported((M||"video")+'/mp4;codecs="'+_+'"')}},"./src/utils/cues.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/utils/vttparser.ts"),O=C("./src/utils/webvtt-parser.ts"),L=C("./src/utils/texttrack-utils.ts"),_=/\s/,M={newCue:function(w,g,x,S){for(var E=[],b,y,h,e,s,o=self.VTTCue||self.TextTrackCue,f=0;f<S.rows.length;f++)if(b=S.rows[f],h=!0,e=0,s="",!b.isEmpty()){for(var u=0;u<b.chars.length;u++)_.test(b.chars[u].uchar)&&h?e++:(s+=b.chars[u].uchar,h=!1);b.cueStartTime=g,g===x&&(x+=1e-4),e>=16?e--:e++;var l=Object(B.fixLineBreaks)(s.trim()),p=Object(O.generateCueId)(g,x,l);(!w||!w.cues||!w.cues.getCueById(p))&&(y=new o(g,x,l),y.id=p,y.line=f+1,y.align="left",y.position=10+Math.min(80,Math.floor(e*8/32)*10),E.push(y))}return w&&E.length&&(E.sort(function(c,i){return c.line==="auto"||i.line==="auto"?0:c.line>8&&i.line>8?i.line-c.line:c.line-i.line}),E.forEach(function(c){return Object(L.addCueToTrack)(w,c)})),E}};U.default=M},"./src/utils/discontinuities.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"findFirstFragWithCC",function(){return _}),C.d(U,"shouldAlignOnDiscontinuities",function(){return M}),C.d(U,"findDiscontinuousReferenceFrag",function(){return A}),C.d(U,"adjustSlidingStart",function(){return g}),C.d(U,"alignStream",function(){return x}),C.d(U,"alignPDT",function(){return E}),C.d(U,"alignFragmentByPDTDelta",function(){return b}),C.d(U,"alignMediaPlaylistByPDT",function(){return y});var B=C("./src/polyfills/number.ts"),O=C("./src/utils/logger.ts"),L=C("./src/controller/level-helper.ts");function _(h,e){for(var s=null,o=0,f=h.length;o<f;o++){var u=h[o];if(u&&u.cc===e){s=u;break}}return s}function M(h,e,s){return!!(e.details&&(s.endCC>s.startCC||h&&h.cc<s.startCC))}function A(h,e){var s=h.fragments,o=e.fragments;if(!o.length||!s.length){O.logger.log("No fragments to align");return}var f=_(s,o[0].cc);if(!f||f&&!f.startPTS){O.logger.log("No frag in previous level to align on");return}return f}function w(h,e){if(h){var s=h.start+e;h.start=h.startPTS=s,h.endPTS=s+h.duration}}function g(h,e){for(var s=e.fragments,o=0,f=s.length;o<f;o++)w(s[o],h);e.fragmentHint&&w(e.fragmentHint,h),e.alignedSliding=!0}function x(h,e,s){if(!e)return;S(h,s,e),!s.alignedSliding&&e.details&&E(s,e.details),!s.alignedSliding&&e.details&&!s.skippedSegments&&Object(L.adjustSliding)(e.details,s)}function S(h,e,s){if(M(h,s,e)){var o=A(s.details,e);o&&Object(B.isFiniteNumber)(o.start)&&(O.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),g(o.start,e))}}function E(h,e){if(!e.fragments.length||!h.hasProgramDateTime||!e.hasProgramDateTime)return;var s=e.fragments[0].programDateTime,o=h.fragments[0].programDateTime,f=(o-s)/1e3+e.fragments[0].start;f&&Object(B.isFiniteNumber)(f)&&(O.logger.log("Adjusting PTS using programDateTime delta "+(o-s)+"ms, sliding:"+f.toFixed(3)+" "+h.url+" "),g(f,h))}function b(h,e){var s=h.programDateTime;if(!s)return;var o=(s-e)/1e3;h.start=h.startPTS=o,h.endPTS=o+h.duration}function y(h,e){if(!e.fragments.length||!h.hasProgramDateTime||!e.hasProgramDateTime)return;var s=e.fragments[0].programDateTime,o=e.fragments[0].start,f=s-o*1e3;h.fragments.forEach(function(u){b(u,f)}),h.fragmentHint&&b(h.fragmentHint,f),h.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/utils/ewma.ts"),O=function(){function L(M,A,w){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=w,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new B.default(M),this.fast_=new B.default(A)}var _=L.prototype;return _.update=function(A,w){var g=this.slow_,x=this.fast_;this.slow_.halfLife!==A&&(this.slow_=new B.default(A,g.getEstimate(),g.getTotalWeight())),this.fast_.halfLife!==w&&(this.fast_=new B.default(w,x.getEstimate(),x.getTotalWeight()))},_.sample=function(A,w){A=Math.max(A,this.minDelayMs_);var g=8*w,x=A/1e3,S=g/x;this.fast_.sample(x,S),this.slow_.sample(x,S)},_.canEstimate=function(){var A=this.fast_;return A&&A.getTotalWeight()>=this.minWeight_},_.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},_.destroy=function(){},L}();U.default=O},"./src/utils/ewma.ts":function(fe,U,C){"use strict";C.r(U);var B=function(){function O(_,M,A){M===void 0&&(M=0),A===void 0&&(A=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=_,this.alpha_=_?Math.exp(Math.log(.5)/_):0,this.estimate_=M,this.totalWeight_=A}var L=O.prototype;return L.sample=function(M,A){var w=Math.pow(this.alpha_,M);this.estimate_=A*(1-w)+w*this.estimate_,this.totalWeight_+=M},L.getTotalWeight=function(){return this.totalWeight_},L.getEstimate=function(){if(this.alpha_){var M=1-Math.pow(this.alpha_,this.totalWeight_);if(M)return this.estimate_/M}return this.estimate_},O}();U.default=B},"./src/utils/fetch-loader.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"fetchSupported",function(){return b});var B=C("./src/polyfills/number.ts"),O=C("./src/loader/load-stats.ts"),L=C("./src/demux/chunk-cache.ts");function _(o,f){o.prototype=Object.create(f.prototype),o.prototype.constructor=o,x(o,f)}function M(o){var f=typeof Map=="function"?new Map:void 0;return M=function(l){if(l===null||!g(l))return l;if(typeof l!="function")throw new TypeError("Super expression must either be null or a function");if(typeof f!="undefined"){if(f.has(l))return f.get(l);f.set(l,p)}function p(){return A(l,arguments,S(this).constructor)}return p.prototype=Object.create(l.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),x(p,l)},M(o)}function A(o,f,u){return w()?A=Reflect.construct:A=function(p,c,i){var r=[null];r.push.apply(r,c);var t=Function.bind.apply(p,r),a=new t;return i&&x(a,i.prototype),a},A.apply(null,arguments)}function w(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(o){return!1}}function g(o){return Function.toString.call(o).indexOf("[native code]")!==-1}function x(o,f){return x=Object.setPrototypeOf||function(l,p){return l.__proto__=p,l},x(o,f)}function S(o){return S=Object.setPrototypeOf?Object.getPrototypeOf:function(u){return u.__proto__||Object.getPrototypeOf(u)},S(o)}function E(){return E=Object.assign||function(o){for(var f=1;f<arguments.length;f++){var u=arguments[f];for(var l in u)Object.prototype.hasOwnProperty.call(u,l)&&(o[l]=u[l])}return o},E.apply(this,arguments)}function b(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(o){}return!1}var y=function(){function o(u){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=u.fetchSetup||e,this.controller=new self.AbortController,this.stats=new O.LoadStats}var f=o.prototype;return f.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},f.abortInternal=function(){var l=this.response;(!l||!l.ok)&&(this.stats.aborted=!0,this.controller.abort())},f.abort=function(){var l;this.abortInternal(),(l=this.callbacks)!==null&&l!==void 0&&l.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},f.load=function(l,p,c){var i=this,r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();var t=h(l,this.controller.signal),a=c.onProgress,m=l.responseType==="arraybuffer",v=m?"byteLength":"length";this.context=l,this.config=p,this.callbacks=c,this.request=this.fetchSetup(l,t),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){i.abortInternal(),c.onTimeout(r,l,i.response)},p.timeout),self.fetch(this.request).then(function(T){if(i.response=i.loader=T,!T.ok){var k=T.status,I=T.statusText;throw new s(I||"fetch, bad network response",k,T)}return r.loading.first=Math.max(self.performance.now(),r.loading.start),r.total=parseInt(T.headers.get("Content-Length")||"0"),a&&Object(B.isFiniteNumber)(p.highWaterMark)?i.loadProgressively(T,r,l,p.highWaterMark,a):m?T.arrayBuffer():T.text()}).then(function(T){var k=i.response;self.clearTimeout(i.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first),r.loaded=r.total=T[v];var I={url:k.url,data:T};a&&!Object(B.isFiniteNumber)(p.highWaterMark)&&a(r,l,T,k),c.onSuccess(I,r,l,k)}).catch(function(T){if(self.clearTimeout(i.requestTimeout),r.aborted)return;var k=T.code||0;c.onError({code:k,text:T.message},l,T.details)})},f.getCacheAge=function(){var l=null;if(this.response){var p=this.response.headers.get("age");l=p?parseFloat(p):null}return l},f.loadProgressively=function(l,p,c,i,r){i===void 0&&(i=0);var t=new L.default,a=l.body.getReader(),m=function v(){return a.read().then(function(T){if(T.done)return t.dataLength&&r(p,c,t.flush(),l),Promise.resolve(new ArrayBuffer(0));var k=T.value,I=k.length;return p.loaded+=I,I<i||t.dataLength?(t.push(k),t.dataLength>=i&&r(p,c,t.flush(),l)):r(p,c,k,l),v()}).catch(function(){return Promise.reject()})};return m()},o}();function h(o,f){var u={method:"GET",mode:"cors",credentials:"same-origin",signal:f,headers:new self.Headers(E({},o.headers))};return o.rangeEnd&&u.headers.set("Range","bytes="+o.rangeStart+"-"+String(o.rangeEnd-1)),u}function e(o,f){return new self.Request(o.url,f)}var s=function(o){_(f,o);function f(u,l,p){var c;return c=o.call(this,u)||this,c.code=void 0,c.details=void 0,c.code=l,c.details=p,c}return f}(M(Error));U.default=y},"./src/utils/imsc1-ttml-parser.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"IMSC1_CODEC",function(){return g}),C.d(U,"parseIMSC1",function(){return b});var B=C("./src/utils/mp4-tools.ts"),O=C("./src/utils/vttparser.ts"),L=C("./src/utils/vttcue.ts"),_=C("./src/demux/id3.ts"),M=C("./src/utils/timescale-conversion.ts"),A=C("./src/utils/webvtt-parser.ts");function w(){return w=Object.assign||function(i){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(i[a]=t[a])}return i},w.apply(this,arguments)}var g="stpp.ttml.im1t",x=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,S=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,E={left:"start",center:"center",right:"end",start:"start",end:"end"};function b(i,r,t,a,m){var v=Object(B.findBox)(new Uint8Array(i),["mdat"]);if(v.length===0){m(new Error("Could not parse IMSC1 mdat"));return}var T=v[0],k=Object(_.utf8ArrayToStr)(new Uint8Array(i,T.start,T.end-T.start)),I=Object(M.toTimescaleFromScale)(r,1,t);try{a(y(k,I))}catch(F){m(F)}}function y(i,r){var t=new DOMParser,a=t.parseFromString(i,"text/xml"),m=a.getElementsByTagName("tt")[0];if(!m)throw new Error("Invalid ttml");var v={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},T=Object.keys(v).reduce(function(V,Q){return V[Q]=m.getAttribute("ttp:"+Q)||v[Q],V},{}),k=m.getAttribute("xml:space")!=="preserve",I=e(h(m,"styling","style")),F=e(h(m,"layout","region")),K=h(m,"body","[begin]");return[].map.call(K,function(V){var Q=s(V,k);if(!Q||!V.hasAttribute("begin"))return null;var Z=l(V.getAttribute("begin"),T),ie=l(V.getAttribute("dur"),T),ge=l(V.getAttribute("end"),T);if(Z===null)throw u(V);if(ge===null){if(ie===null)throw u(V);ge=Z+ie}var se=new L.default(Z-r,ge-r,Q);se.id=Object(A.generateCueId)(se.startTime,se.endTime,se.text);var he=F[V.getAttribute("region")],de=I[V.getAttribute("style")];se.position=10,se.size=80;var $=o(he,de),Y=$.textAlign;if(Y){var ne=E[Y];ne&&(se.lineAlign=ne),se.align=Y}return w(se,$),se}).filter(function(V){return V!==null})}function h(i,r,t){var a=i.getElementsByTagName(r)[0];return a?[].slice.call(a.querySelectorAll(t)):[]}function e(i){return i.reduce(function(r,t){var a=t.getAttribute("xml:id");return a&&(r[a]=t),r},{})}function s(i,r){return[].slice.call(i.childNodes).reduce(function(t,a,m){var v;return a.nodeName==="br"&&m?t+`
|
|
`:(v=a.childNodes)!==null&&v!==void 0&&v.length?s(a,r):r?t+a.textContent.trim().replace(/\s+/g," "):t+a.textContent},"")}function o(i,r){var t="http://www.w3.org/ns/ttml#styling",a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return a.reduce(function(m,v){var T=f(r,t,v)||f(i,t,v);return T&&(m[v]=T),m},{})}function f(i,r,t){return i.hasAttributeNS(r,t)?i.getAttributeNS(r,t):null}function u(i){return new Error("Could not parse ttml timestamp "+i)}function l(i,r){if(!i)return null;var t=Object(O.parseTimeStamp)(i);return t===null&&(x.test(i)?t=p(i,r):S.test(i)&&(t=c(i,r))),t}function p(i,r){var t=x.exec(i),a=(t[4]|0)+(t[5]|0)/r.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+a/r.frameRate}function c(i,r){var t=S.exec(i),a=Number(t[1]),m=t[2];switch(m){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/r.frameRate;case"t":return a/r.tickRate}return a}},"./src/utils/logger.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"enableLogs",function(){return A}),C.d(U,"logger",function(){return w});var B=function(){},O={trace:B,debug:B,log:B,warn:B,info:B,error:B},L=O;function _(g){var x=self.console[g];return x?x.bind(self.console,"["+g+"] >"):B}function M(g){for(var x=arguments.length,S=new Array(x>1?x-1:0),E=1;E<x;E++)S[E-1]=arguments[E];S.forEach(function(b){L[b]=g[b]?g[b].bind(g):_(b)})}function A(g){if(self.console&&g===!0||typeof g=="object"){M(g,"debug","log","info","warn","error");try{L.log()}catch(x){L=O}}else L=O}var w=L},"./src/utils/mediakeys-helper.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"KeySystems",function(){return B}),C.d(U,"requestMediaKeySystemAccess",function(){return O});var B;(function(L){L.WIDEVINE="com.widevine.alpha",L.PLAYREADY="com.microsoft.playready"})(B||(B={}));var O=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"getMediaSource",function(){return B});function B(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"bin2str",function(){return M}),C.d(U,"readUint16",function(){return A}),C.d(U,"readUint32",function(){return w}),C.d(U,"writeUint32",function(){return g}),C.d(U,"findBox",function(){return x}),C.d(U,"parseSegmentIndex",function(){return S}),C.d(U,"parseInitSegment",function(){return E}),C.d(U,"getStartDTS",function(){return b}),C.d(U,"getDuration",function(){return y}),C.d(U,"computeRawDurationFromSamples",function(){return h}),C.d(U,"offsetStartDTS",function(){return e}),C.d(U,"segmentValidRange",function(){return s}),C.d(U,"appendUint8Array",function(){return o});var B=C("./src/utils/typed-array.ts"),O=C("./src/loader/fragment.ts"),L=Math.pow(2,32)-1,_=[].push;function M(f){return String.fromCharCode.apply(null,f)}function A(f,u){"data"in f&&(u+=f.start,f=f.data);var l=f[u]<<8|f[u+1];return l<0?65536+l:l}function w(f,u){"data"in f&&(u+=f.start,f=f.data);var l=f[u]<<24|f[u+1]<<16|f[u+2]<<8|f[u+3];return l<0?4294967296+l:l}function g(f,u,l){"data"in f&&(u+=f.start,f=f.data),f[u]=l>>24,f[u+1]=l>>16&255,f[u+2]=l>>8&255,f[u+3]=l&255}function x(f,u){var l=[];if(!u.length)return l;var p,c,i;"data"in f?(p=f.data,c=f.start,i=f.end):(p=f,c=0,i=p.byteLength);for(var r=c;r<i;){var t=w(p,r),a=M(p.subarray(r+4,r+8)),m=t>1?r+t:i;if(a===u[0])if(u.length===1)l.push({data:p,start:r+8,end:m});else{var v=x({data:p,start:r+8,end:m},u.slice(1));v.length&&_.apply(l,v)}r=m}return l}function S(f){var u=x(f,["moov"]),l=u[0],p=l?l.end:null,c=x(f,["sidx"]);if(!c||!c[0])return null;var i=[],r=c[0],t=r.data[0],a=t===0?8:16,m=w(r,a);a+=4;var v=0,T=0;t===0?a+=8:a+=16,a+=2;var k=r.end+T,I=A(r,a);a+=2;for(var F=0;F<I;F++){var K=a,V=w(r,K);K+=4;var Q=V&2147483647,Z=(V&2147483648)>>>31;if(Z===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var ie=w(r,K);K+=4,i.push({referenceSize:Q,subsegmentDuration:ie,info:{duration:ie/m,start:k,end:k+Q-1}}),k+=Q,K+=4,a=K}return{earliestPresentationTime:v,timescale:m,version:t,referencesCount:I,references:i,moovEndOffset:p}}function E(f){for(var u=[],l=x(f,["moov","trak"]),p=0;p<l.length;p++){var c=l[p],i=x(c,["tkhd"])[0];if(i){var r=i.data[i.start],t=r===0?12:20,a=w(i,t),m=x(c,["mdia","mdhd"])[0];if(m){r=m.data[m.start],t=r===0?12:20;var v=w(m,t),T=x(c,["mdia","hdlr"])[0];if(T){var k=M(T.data.subarray(T.start+8,T.start+12)),I={soun:O.ElementaryStreamTypes.AUDIO,vide:O.ElementaryStreamTypes.VIDEO}[k];if(I){var F=x(c,["mdia","minf","stbl","stsd"])[0],K=void 0;F&&(K=M(F.data.subarray(F.start+12,F.start+16))),u[a]={timescale:v,type:I},u[I]={timescale:v,id:a,codec:K}}}}}}var V=x(f,["moov","mvex","trex"]);return V.forEach(function(Q){var Z=w(Q,4),ie=u[Z];ie&&(ie.default={duration:w(Q,12),flags:w(Q,20)})}),u}function b(f,u){return x(u,["moof","traf"]).reduce(function(l,p){var c=x(p,["tfdt"])[0],i=c.data[c.start],r=x(p,["tfhd"]).reduce(function(t,a){var m=w(a,4),v=f[m];if(v){var T=w(c,4);i===1&&(T*=Math.pow(2,32),T+=w(c,8));var k=v.timescale||9e4,I=T/k;if(isFinite(I)&&(t===null||I<t))return I}return t},null);return r!==null&&isFinite(r)&&(l===null||r<l)?r:l},null)||0}function y(f,u){for(var l=0,p=0,c=0,i=x(f,["moof","traf"]),r=0;r<i.length;r++){var t=i[r],a=x(t,["tfhd"])[0],m=w(a,4),v=u[m];if(!v)continue;var T=v.default,k=w(a,0)|(T==null?void 0:T.flags),I=T==null?void 0:T.duration;k&8&&(k&2?I=w(a,12):I=w(a,8));for(var F=v.timescale||9e4,K=x(t,["trun"]),V=0;V<K.length;V++){if(I){var Q=w(K[V],4);l=I*Q}else l=h(K[V]);v.type===O.ElementaryStreamTypes.VIDEO?p+=l/F:v.type===O.ElementaryStreamTypes.AUDIO&&(c+=l/F)}}if(p===0&&c===0){var Z=S(f);if(Z!=null&&Z.references)return Z.references.reduce(function(ie,ge){return ie+ge.info.duration||0},0)}return p||c}function h(f){var u=w(f,0),l=8;u&1&&(l+=4),u&4&&(l+=4);for(var p=0,c=w(f,4),i=0;i<c;i++){if(u&256){var r=w(f,l);p+=r,l+=4}u&512&&(l+=4),u&1024&&(l+=4),u&2048&&(l+=4)}return p}function e(f,u,l){x(u,["moof","traf"]).forEach(function(p){x(p,["tfhd"]).forEach(function(c){var i=w(c,4),r=f[i];if(!r)return;var t=r.timescale||9e4;x(p,["tfdt"]).forEach(function(a){var m=a.data[a.start],v=w(a,4);if(m===0)g(a,4,v-l*t);else{v*=Math.pow(2,32),v+=w(a,8),v-=l*t,v=Math.max(v,0);var T=Math.floor(v/(L+1)),k=Math.floor(v%(L+1));g(a,4,T),g(a,8,k)}})})})}function s(f){var u={valid:null,remainder:null},l=x(f,["moof"]);if(l){if(l.length<2)return u.remainder=f,u}else return u;var p=l[l.length-1];return u.valid=Object(B.sliceUint8)(f,0,p.start-8),u.remainder=Object(B.sliceUint8)(f,p.start-8),u}function o(f,u){var l=new Uint8Array(f.length+u.length);return l.set(f),l.set(u,f.length),l}},"./src/utils/output-filter.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"default",function(){return B});var B=function(){function O(_,M){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=_,this.trackName=M}var L=O.prototype;return L.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},L.newCue=function(M,A,w){(this.startTime===null||this.startTime>M)&&(this.startTime=M),this.endTime=A,this.screen=w,this.timelineController.createCaptionsTrack(this.trackName)},L.reset=function(){this.cueRanges=[]},O}()},"./src/utils/texttrack-utils.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"sendAddTrackEvent",function(){return O}),C.d(U,"addCueToTrack",function(){return L}),C.d(U,"clearCurrentCues",function(){return _}),C.d(U,"removeCuesInRange",function(){return M}),C.d(U,"getCuesInRange",function(){return w});var B=C("./src/utils/logger.ts");function O(g,x){var S;try{S=new Event("addtrack")}catch(E){S=document.createEvent("Event"),S.initEvent("addtrack",!1,!1)}S.track=g,x.dispatchEvent(S)}function L(g,x){var S=g.mode;if(S==="disabled"&&(g.mode="hidden"),g.cues&&!g.cues.getCueById(x.id))try{if(g.addCue(x),!g.cues.getCueById(x.id))throw new Error("addCue is failed for: "+x)}catch(b){B.logger.debug("[texttrack-utils]: "+b);var E=new self.TextTrackCue(x.startTime,x.endTime,x.text);E.id=x.id,g.addCue(E)}S==="disabled"&&(g.mode=S)}function _(g){var x=g.mode;if(x==="disabled"&&(g.mode="hidden"),g.cues)for(var S=g.cues.length;S--;)g.removeCue(g.cues[S]);x==="disabled"&&(g.mode=x)}function M(g,x,S){var E=g.mode;if(E==="disabled"&&(g.mode="hidden"),g.cues&&g.cues.length>0)for(var b=w(g.cues,x,S),y=0;y<b.length;y++)g.removeCue(b[y]);E==="disabled"&&(g.mode=E)}function A(g,x){if(x<g[0].startTime)return 0;var S=g.length-1;if(x>g[S].endTime)return-1;for(var E=0,b=S;E<=b;){var y=Math.floor((b+E)/2);if(x<g[y].startTime)b=y-1;else if(x>g[y].startTime&&E<S)E=y+1;else return y}return g[E].startTime-x<x-g[b].startTime?E:b}function w(g,x,S){var E=[],b=A(g,x);if(b>-1)for(var y=b,h=g.length;y<h;y++){var e=g[y];if(e.startTime>=x&&e.endTime<=S)E.push(e);else if(e.startTime>S)return E}return E}},"./src/utils/time-ranges.ts":function(fe,U,C){"use strict";C.r(U);var B={toString:function(L){for(var _="",M=L.length,A=0;A<M;A++)_+="["+L.start(A).toFixed(3)+","+L.end(A).toFixed(3)+"]";return _}};U.default=B},"./src/utils/timescale-conversion.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"toTimescaleFromBase",function(){return O}),C.d(U,"toTimescaleFromScale",function(){return L}),C.d(U,"toMsFromMpegTsClock",function(){return _}),C.d(U,"toMpegTsClockFromTimescale",function(){return M});var B=9e4;function O(A,w,g,x){g===void 0&&(g=1),x===void 0&&(x=!1);var S=A*w*g;return x?Math.round(S):S}function L(A,w,g,x){return g===void 0&&(g=1),x===void 0&&(x=!1),O(A,w,1/g,x)}function _(A,w){return w===void 0&&(w=!1),O(A,1e3,1/B,w)}function M(A,w){return w===void 0&&(w=1),O(A,B,1/w)}},"./src/utils/typed-array.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"sliceUint8",function(){return B});function B(O,L,_){return Uint8Array.prototype.slice?O.slice(L,_):new Uint8Array(Array.prototype.slice.call(O,L,_))}},"./src/utils/vttcue.ts":function(fe,U,C){"use strict";C.r(U),U.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var B=["","lr","rl"],O=["start","middle","end","left","right"];function L(g,x){if(typeof x!="string")return!1;if(!Array.isArray(g))return!1;var S=x.toLowerCase();return~g.indexOf(S)?S:!1}function _(g){return L(B,g)}function M(g){return L(O,g)}function A(g){for(var x=arguments.length,S=new Array(x>1?x-1:0),E=1;E<x;E++)S[E-1]=arguments[E];for(var b=1;b<arguments.length;b++){var y=arguments[b];for(var h in y)g[h]=y[h]}return g}function w(g,x,S){var E=this,b={enumerable:!0};E.hasBeenReset=!1;var y="",h=!1,e=g,s=x,o=S,f=null,u="",l=!0,p="auto",c="start",i=50,r="middle",t=50,a="middle";Object.defineProperty(E,"id",A({},b,{get:function(){return y},set:function(v){y=""+v}})),Object.defineProperty(E,"pauseOnExit",A({},b,{get:function(){return h},set:function(v){h=!!v}})),Object.defineProperty(E,"startTime",A({},b,{get:function(){return e},set:function(v){if(typeof v!="number")throw new TypeError("Start time must be set to a number.");e=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"endTime",A({},b,{get:function(){return s},set:function(v){if(typeof v!="number")throw new TypeError("End time must be set to a number.");s=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"text",A({},b,{get:function(){return o},set:function(v){o=""+v,this.hasBeenReset=!0}})),Object.defineProperty(E,"region",A({},b,{get:function(){return f},set:function(v){f=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"vertical",A({},b,{get:function(){return u},set:function(v){var T=_(v);if(T===!1)throw new SyntaxError("An invalid or illegal string was specified.");u=T,this.hasBeenReset=!0}})),Object.defineProperty(E,"snapToLines",A({},b,{get:function(){return l},set:function(v){l=!!v,this.hasBeenReset=!0}})),Object.defineProperty(E,"line",A({},b,{get:function(){return p},set:function(v){if(typeof v!="number"&&v!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");p=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"lineAlign",A({},b,{get:function(){return c},set:function(v){var T=M(v);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");c=T,this.hasBeenReset=!0}})),Object.defineProperty(E,"position",A({},b,{get:function(){return i},set:function(v){if(v<0||v>100)throw new Error("Position must be between 0 and 100.");i=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"positionAlign",A({},b,{get:function(){return r},set:function(v){var T=M(v);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");r=T,this.hasBeenReset=!0}})),Object.defineProperty(E,"size",A({},b,{get:function(){return t},set:function(v){if(v<0||v>100)throw new Error("Size must be between 0 and 100.");t=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"align",A({},b,{get:function(){return a},set:function(v){var T=M(v);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");a=T,this.hasBeenReset=!0}})),E.displayState=void 0}return w.prototype.getCueAsHTML=function(){var g=self.WebVTT;return g.convertCueToDOMTree(self,this.text)},w}()},"./src/utils/vttparser.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"parseTimeStamp",function(){return L}),C.d(U,"fixLineBreaks",function(){return x}),C.d(U,"VTTParser",function(){return S});var B=C("./src/utils/vttcue.ts"),O=function(){function E(){}var b=E.prototype;return b.decode=function(h,e){if(!h)return"";if(typeof h!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(h))},E}();function L(E){function b(h,e,s,o){return(h|0)*3600+(e|0)*60+(s|0)+parseFloat(o||0)}var y=E.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return y?parseFloat(y[2])>59?b(y[2],y[3],0,y[4]):b(y[1],y[2],y[3],y[4]):null}var _=function(){function E(){this.values=Object.create(null)}var b=E.prototype;return b.set=function(h,e){!this.get(h)&&e!==""&&(this.values[h]=e)},b.get=function(h,e,s){return s?this.has(h)?this.values[h]:e[s]:this.has(h)?this.values[h]:e},b.has=function(h){return h in this.values},b.alt=function(h,e,s){for(var o=0;o<s.length;++o)if(e===s[o]){this.set(h,e);break}},b.integer=function(h,e){/^-?\d+$/.test(e)&&this.set(h,parseInt(e,10))},b.percent=function(h,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var s=parseFloat(e);if(s>=0&&s<=100)return this.set(h,s),!0}return!1},E}();function M(E,b,y,h){var e=h?E.split(h):[E];for(var s in e){if(typeof e[s]!="string")continue;var o=e[s].split(y);if(o.length!==2)continue;var f=o[0],u=o[1];b(f,u)}}var A=new B.default(0,0,""),w=A.align==="middle"?"middle":"center";function g(E,b,y){var h=E;function e(){var f=L(E);if(f===null)throw new Error("Malformed timestamp: "+h);return E=E.replace(/^[^\sa-zA-Z-]+/,""),f}function s(f,u){var l=new _;M(f,function(i,r){var t;switch(i){case"region":for(var a=y.length-1;a>=0;a--)if(y[a].id===r){l.set(i,y[a].region);break}break;case"vertical":l.alt(i,r,["rl","lr"]);break;case"line":t=r.split(","),l.integer(i,t[0]),l.percent(i,t[0])&&l.set("snapToLines",!1),l.alt(i,t[0],["auto"]),t.length===2&&l.alt("lineAlign",t[1],["start",w,"end"]);break;case"position":t=r.split(","),l.percent(i,t[0]),t.length===2&&l.alt("positionAlign",t[1],["start",w,"end","line-left","line-right","auto"]);break;case"size":l.percent(i,r);break;case"align":l.alt(i,r,["start",w,"end","left","right"]);break}},/:/,/\s/),u.region=l.get("region",null),u.vertical=l.get("vertical","");var p=l.get("line","auto");p==="auto"&&A.line===-1&&(p=-1),u.line=p,u.lineAlign=l.get("lineAlign","start"),u.snapToLines=l.get("snapToLines",!0),u.size=l.get("size",100),u.align=l.get("align",w);var c=l.get("position","auto");c==="auto"&&A.position===50&&(c=u.align==="start"||u.align==="left"?0:u.align==="end"||u.align==="right"?100:50),u.position=c}function o(){E=E.replace(/^\s+/,"")}if(o(),b.startTime=e(),o(),E.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+h);E=E.substr(3),o(),b.endTime=e(),o(),s(E,b)}function x(E){return E.replace(/<br(?: \/)?>/gi,`
|
|
`)}var S=function(){function E(){this.state="INITIAL",this.buffer="",this.decoder=new O,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var b=E.prototype;return b.parse=function(h){var e=this;h&&(e.buffer+=e.decoder.decode(h,{stream:!0}));function s(){var c=e.buffer,i=0;for(c=x(c);i<c.length&&c[i]!=="\r"&&c[i]!==`
|
|
`;)++i;var r=c.substr(0,i);return c[i]==="\r"&&++i,c[i]===`
|
|
`&&++i,e.buffer=c.substr(i),r}function o(c){M(c,function(i,r){},/:/)}try{var f="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;f=s();var u=f.match(/^()?WEBVTT([ \t].*)?$/);if(!u||!u[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var l=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;l?l=!1:f=s();switch(e.state){case"HEADER":/:/.test(f)?o(f):f||(e.state="ID");continue;case"NOTE":f||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(f)){e.state="NOTE";break}if(!f)continue;if(e.cue=new B.default(0,0,""),e.state="CUE",f.indexOf("-->")===-1){e.cue.id=f;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{g(f,e.cue,e.regionList)}catch(c){e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{var p=f.indexOf("-->")!==-1;if(!f||p&&(l=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
|
|
`),e.cue.text+=f}continue;case"BADCUE":f||(e.state="ID")}}}catch(c){e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},b.flush=function(){var h=this;try{if((h.cue||h.state==="HEADER")&&(h.buffer+=`
|
|
|
|
`,h.parse()),h.state==="INITIAL"||h.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){h.onparsingerror&&h.onparsingerror(e)}return h.onflush&&h.onflush(),this},E}()},"./src/utils/webvtt-parser.ts":function(fe,U,C){"use strict";C.r(U),C.d(U,"generateCueId",function(){return S}),C.d(U,"parseWebVTT",function(){return b});var B=C("./src/polyfills/number.ts"),O=C("./src/utils/vttparser.ts"),L=C("./src/demux/id3.ts"),_=C("./src/utils/timescale-conversion.ts"),M=C("./src/remux/mp4-remuxer.ts"),A=/\r\n|\n\r|\n|\r/g,w=function(h,e,s){return s===void 0&&(s=0),h.substr(s,e.length)===e},g=function(h){var e=parseInt(h.substr(-3)),s=parseInt(h.substr(-6,2)),o=parseInt(h.substr(-9,2)),f=h.length>9?parseInt(h.substr(0,h.indexOf(":"))):0;if(!Object(B.isFiniteNumber)(e)||!Object(B.isFiniteNumber)(s)||!Object(B.isFiniteNumber)(o)||!Object(B.isFiniteNumber)(f))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+h);return e+=1e3*s,e+=60*1e3*o,e+=60*60*1e3*f,e},x=function(h){for(var e=5381,s=h.length;s;)e=e*33^h.charCodeAt(--s);return(e>>>0).toString()};function S(y,h,e){return x(y.toString())+x(h.toString())+x(e)}var E=function(h,e,s){var o=h[e],f=h[o.prevCC];if(!f||!f.new&&o.new){h.ccOffset=h.presentationOffset=o.start,o.new=!1;return}for(;(u=f)!==null&&u!==void 0&&u.new;){var u;h.ccOffset+=o.start-f.start,o.new=!1,o=f,f=h[o.prevCC]}h.presentationOffset=s};function b(y,h,e,s,o,f,u,l){var p=new O.VTTParser,c=Object(L.utf8ArrayToStr)(new Uint8Array(y)).trim().replace(A,`
|
|
`).split(`
|
|
`),i=[],r=Object(_.toMpegTsClockFromTimescale)(h,e),t="00:00.000",a=0,m=0,v,T=!0,k=!1;p.oncue=function(I){var F=s[o],K=s.ccOffset,V=(a-r)/9e4;if(F!=null&&F.new&&(m!==void 0?K=s.ccOffset=F.start:E(s,o,V)),V&&(K=V-s.presentationOffset),k){var Q=I.endTime-I.startTime,Z=Object(M.normalizePts)((I.startTime+K-m)*9e4,f*9e4)/9e4;I.startTime=Z,I.endTime=Z+Q}var ie=I.text.trim();I.text=decodeURIComponent(encodeURIComponent(ie)),I.id||(I.id=S(I.startTime,I.endTime,ie)),I.endTime>0&&i.push(I)},p.onparsingerror=function(I){v=I},p.onflush=function(){if(v){l(v);return}u(i)},c.forEach(function(I){if(T)if(w(I,"X-TIMESTAMP-MAP=")){T=!1,k=!0,I.substr(16).split(",").forEach(function(F){w(F,"LOCAL:")?t=F.substr(6):w(F,"MPEGTS:")&&(a=parseInt(F.substr(7)))});try{m=g(t)/1e3}catch(F){k=!1,v=F}return}else I===""&&(T=!1);p.parse(I+`
|
|
`)}),p.flush()}},"./src/utils/xhr-loader.ts":function(fe,U,C){"use strict";C.r(U);var B=C("./src/utils/logger.ts"),O=C("./src/loader/load-stats.ts"),L=/^age:\s*[\d.]+\s*$/m,_=function(){function M(w){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=w?w.xhrSetup:null,this.stats=new O.LoadStats,this.retryDelay=0}var A=M.prototype;return A.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},A.abortInternal=function(){var g=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),g&&(g.onreadystatechange=null,g.onprogress=null,g.readyState!==4&&(this.stats.aborted=!0,g.abort()))},A.abort=function(){var g;this.abortInternal(),(g=this.callbacks)!==null&&g!==void 0&&g.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},A.load=function(g,x,S){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=g,this.config=x,this.callbacks=S,this.retryDelay=x.retryDelay,this.loadInternal()},A.loadInternal=function(){var g=this.config,x=this.context;if(!g)return;var S=this.loader=new self.XMLHttpRequest,E=this.stats;E.loading.first=0,E.loaded=0;var b=this.xhrSetup;try{if(b)try{b(S,x.url)}catch(e){S.open("GET",x.url,!0),b(S,x.url)}S.readyState||S.open("GET",x.url,!0);var y=this.context.headers;if(y)for(var h in y)S.setRequestHeader(h,y[h])}catch(e){this.callbacks.onError({code:S.status,text:e.message},x,S);return}x.rangeEnd&&S.setRequestHeader("Range","bytes="+x.rangeStart+"-"+(x.rangeEnd-1)),S.onreadystatechange=this.readystatechange.bind(this),S.onprogress=this.loadprogress.bind(this),S.responseType=x.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout),S.send()},A.readystatechange=function(){var g=this.context,x=this.loader,S=this.stats;if(!g||!x)return;var E=x.readyState,b=this.config;if(S.aborted)return;if(E>=2)if(self.clearTimeout(this.requestTimeout),S.loading.first===0&&(S.loading.first=Math.max(self.performance.now(),S.loading.start)),E===4){x.onreadystatechange=null,x.onprogress=null;var y=x.status;if(y>=200&&y<300){S.loading.end=Math.max(self.performance.now(),S.loading.first);var h,e;if(g.responseType==="arraybuffer"?(h=x.response,e=h.byteLength):(h=x.responseText,e=h.length),S.loaded=S.total=e,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(S,g,h,x),!this.callbacks)return;var o={url:x.responseURL,data:h};this.callbacks.onSuccess(o,S,g,x)}else S.retry>=b.maxRetry||y>=400&&y<499?(B.logger.error(y+" while loading "+g.url),this.callbacks.onError({code:y,text:x.statusText},g,x)):(B.logger.warn(y+" while loading "+g.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,b.maxRetryDelay),S.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),b.timeout)},A.loadtimeout=function(){B.logger.warn("timeout while loading "+this.context.url);var g=this.callbacks;g&&(this.abortInternal(),g.onTimeout(this.stats,this.context,this.loader))},A.loadprogress=function(g){var x=this.stats;x.loaded=g.loaded,g.lengthComputable&&(x.total=g.total)},A.getCacheAge=function(){var g=null;if(this.loader&&L.test(this.loader.getAllResponseHeaders())){var x=this.loader.getResponseHeader("age");g=x?parseFloat(x):null}return g},M}();U.default=_}}).default})},vHTk:function(nt,We,J){nt.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);
|