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.
NewEduCoderBuild/p__Messages__Private.38d016...

394 lines
804 KiB

(window.webpackJsonp=window.webpackJsonp||[]).push([[184,5,7,8],{"+ua5":function(Je,Ve,ee){},"30zm":function(Je,Ve,ee){"use strict";var he=ee("jCWc"),G=ee("kPKH"),w=ee("k1fw"),j=ee("tJVT"),I=ee("PpiC"),O=ee("B9cy"),B=ee("Ol7k"),M=ee("lUTK"),A=ee("BvKs"),S=ee("q1tI"),p=ee.n(S),m=ee("Ty5D"),s=ee("55Ip"),r=ee("9kvl"),n=ee("m3rI"),u=ee("kzJb"),o=ee.n(u),t=A.a.SubMenu,e=B.a.Sider,i=B.a.Content,T=function(y){var E=y.messages,b=y.globalSetting,g=y.loading,d=y.user,a=y.dispatch,l=Object(I.a)(y,["messages","globalSetting","loading","user","dispatch"]),f=Object(m.i)(),c=d.userInfo,x=Object(m.h)(),R=E.tidingsList,C=E.privateMessage,N=E.unreadInfo,U=Object(S.useState)({per_page:10,page:1}),W=Object(j.a)(U,2),L=W[0],H=W[1];Object(S.useEffect)(function(){K()},[f.userId]);var K=function(){a({type:"messages/unreadMessageInfo",payload:Object(w.a)(Object(w.a)({},L),f)})};return p.a.createElement(G.a,{flex:"264px"},p.a.createElement("aside",{className:o.a.userInfo},p.a.createElement("img",{className:"mt40",src:n.a.IMG_SERVER+"/images/"+(c==null?void 0:c.image_url)}),p.a.createElement("p",{className:"font24 mt10"},c==null?void 0:c.username),p.a.createElement("p",{className:"mt20"},c==null?void 0:c.user_identity)),p.a.createElement("ul",{className:o.a.navInfo},p.a.createElement(s.a,{to:"/messages/".concat(c==null?void 0:c.login,"/user_tidings")},p.a.createElement("li",{className:x.pathname.indexOf("user_tidings")>-1&&o.a.actived},"\u6D88\u606F",!!(N!=null&&N.unread_tiding_count)&&p.a.createElement("span",{className:o.a.newTip},N==null?void 0:N.unread_tiding_count))),p.a.createElement(s.a,{to:"/messages/".concat(c==null?void 0:c.login,"/private_messages")},p.a.createElement("li",{className:(x.pathname.indexOf("private_messages")>-1||x.pathname.indexOf("message_detail")>-1)&&o.a.actived},"\u79C1\u4FE1",!!(N!=null&&N.unread_message_count)&&p.a.createElement("span",{className:o.a.newTip},N==null?void 0:N.unread_message_count)))))};Ve.a=Object(r.a)(function(_){var y=_.messages,E=_.loading,b=_.user,g=_.globalSetting;return{messages:y,globalSetting:g,user:b,loading:E.effects}})(T)},"55Ip":function(Je,Ve,ee){"use strict";ee.d(Ve,"a",function(){return e});var he=ee("Ty5D"),G=ee("dI71"),w=ee("q1tI"),j=ee.n(w),I=ee("YS25"),O=ee("17x9"),B=ee.n(O),M=ee("wx14"),A=ee("zLVn"),S=ee("9R94"),p=function(d){Object(G.a)(a,d);function a(){for(var f,c=arguments.length,x=new Array(c),R=0;R<c;R++)x[R]=arguments[R];return f=d.call.apply(d,[this].concat(x))||this,f.history=Object(I.a)(f.props),f}var l=a.prototype;return l.render=function(){return j.a.createElement(he.c,{history:this.history,children:this.props.children})},a}(j.a.Component),m=function(d){Object(G.a)(a,d);function a(){for(var f,c=arguments.length,x=new Array(c),R=0;R<c;R++)x[R]=arguments[R];return f=d.call.apply(d,[this].concat(x))||this,f.history=Object(I.b)(f.props),f}var l=a.prototype;return l.render=function(){return j.a.createElement(he.c,{history:this.history,children:this.props.children})},a}(j.a.Component),s=function(a,l){return typeof a=="function"?a(l):a},r=function(a,l){return typeof a=="string"?Object(I.c)(a,null,null,l):a},n=function(a){return a},u=j.a.forwardRef;typeof u=="undefined"&&(u=n);function o(d){return!!(d.metaKey||d.altKey||d.ctrlKey||d.shiftKey)}var t=u(function(d,a){var l=d.innerRef,f=d.navigate,c=d.onClick,x=Object(A.a)(d,["innerRef","navigate","onClick"]),R=x.target,C=Object(M.a)({},x,{onClick:function(U){try{c&&c(U)}catch(W){throw U.preventDefault(),W}!U.defaultPrevented&&U.button===0&&(!R||R==="_self")&&!o(U)&&(U.preventDefault(),f())}});return n!==u?C.ref=a||l:C.ref=l,j.a.createElement("a",C)}),e=u(function(d,a){var l=d.component,f=l===void 0?t:l,c=d.replace,x=d.to,R=d.innerRef,C=Object(A.a)(d,["component","replace","to","innerRef"]);return j.a.createElement(he.e.Consumer,null,function(N){N||Object(S.a)(!1);var U=N.history,W=r(s(x,N.location),N.location),L=W?U.createHref(W):"",H=Object(M.a)({},C,{href:L,navigate:function(){var $=s(x,N.location),Q=c?U.replace:U.push;Q($)}});return n!==u?H.ref=a||R:H.innerRef=R,j.a.createElement(f,H)})});if(!1)var i,T;var _=function(a){return a},y=j.a.forwardRef;typeof y=="undefined"&&(y=_);function E(){for(var d=arguments.length,a=new Array(d),l=0;l<d;l++)a[l]=arguments[l];return a.filter(function(f){return f}).join(" ")}var b=y(function(d,a){var l=d["aria-current"],f=l===void 0?"page":l,c=d.activeClassName,x=c===void 0?"active":c,R=d.activeStyle,C=d.className,N=d.exact,U=d.isActive,W=d.location,L=d.sensitive,H=d.strict,K=d.style,$=d.to,Q=d.innerRef,ue=Object(A.a)(d,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return j.a.createElement(he.e.Consumer,null,function(ne){ne||Object(S.a)(!1);var se=W||ne.location,le=r(s($,se),se),de=le.pathname,re=de&&de.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),Y=re?Object(he.f)(se.pathname,{path:re,exact:N,sensitive:L,strict:H}):null,pe=!!(U?U(Y,se):Y),Te=pe?E(C,x):C,xe=pe?Object(M.a)({},K,{},R):K,Se=Object(M.a)({"aria-current":pe&&f||null,className:Te,style:xe,to:le},ue);return _!==y?Se.ref=a||Q:Se.innerRef=Q,j.a.createElement(e,Se)})});if(!1)var g},"5VLF":function(Je,Ve,ee){"use strict";var he,G;function w(j,I,O){var B=function(M,A){return j.js_beautify(M,A)};return B.js=j.js_beautify,B.css=I.css_beautify,B.html=O.html_beautify,B.js_beautify=j.js_beautify,B.css_beautify=I.css_beautify,B.html_beautify=O.html_beautify,B}!(he=[ee("6UM0"),ee("TXwP"),ee("psGv")],G=function(j,I,O){return w(j,I,O)}.apply(Ve,he),G!==void 0&&(Je.exports=G))},"6+eU":function(Je,Ve,ee){"use strict";ee.d(Ve,"a",function(){return y});var he=ee("wx14"),G=ee("rePB"),w=ee("VTBJ"),j=ee("1OyB"),I=ee("vuIU"),O=ee("Ji7U"),B=ee("LK+K"),M=ee("q1tI"),A=ee.n(M),S=ee("TSYQ"),p=ee.n(S),m=function(b){var g,d="".concat(b.rootPrefixCls,"-item"),a=p()(d,"".concat(d,"-").concat(b.page),(g={},Object(G.a)(g,"".concat(d,"-active"),b.active),Object(G.a)(g,b.className,!!b.className),Object(G.a)(g,"".concat(d,"-disabled"),!b.page),g)),l=function(){b.onClick(b.page)},f=function(x){b.onKeyPress(x,b.onClick,b.page)};return A.a.createElement("li",{title:b.showTitle?b.page:null,className:a,onClick:l,onKeyPress:f,tabIndex:"0"},b.itemRender(b.page,"page",A.a.createElement("a",{rel:"nofollow"},b.page)))},s=m,r={ZERO:48,NINE:57,NUMPAD_ZERO:96,NUMPAD_NINE:105,BACKSPACE:8,DELETE:46,ENTER:13,ARROW_UP:38,ARROW_DOWN:40},n=function(E){Object(O.a)(g,E);var b=Object(B.a)(g);function g(){var d;Object(j.a)(this,g);for(var a=arguments.length,l=new Array(a),f=0;f<a;f++)l[f]=arguments[f];return d=b.call.apply(b,[this].concat(l)),d.state={goInputText:""},d.buildOptionText=function(c){return"".concat(c," ").concat(d.props.locale.items_per_page)},d.changeSize=function(c){d.props.changeSize(Number(c))},d.handleChange=function(c){d.setState({goInputText:c.target.value})},d.handleBlur=function(c){var x=d.props,R=x.goButton,C=x.quickGo,N=x.rootPrefixCls,U=d.state.goInputText;if(R||U==="")return;if(c.relatedTarget&&(c.relatedTarget.className.indexOf("".concat(N,"-prev"))>=0||c.relatedTarget.className.indexOf("".concat(N,"-next"))>=0))return;d.setState({goInputText:""}),C(d.getValidValue())},d.go=function(c){var x=d.state.goInputText;if(x==="")return;(c.keyCode===r.ENTER||c.type==="click")&&(d.setState({goInputText:""}),d.props.quickGo(d.getValidValue()))},d}return Object(I.a)(g,[{key:"getValidValue",value:function(){var a=this.state,l=a.goInputText,f=a.current;return!l||isNaN(l)?f:Number(l)}},{key:"getPageSizeOptions",value:function(){var a=this.props,l=a.pageSize,f=a.pageSizeOptions;return f.some(function(c){return c.toString()===l.toString()})?f:f.concat([l.toString()]).sort(function(c,x){var R=isNaN(Number(c))?0:Number(c),C=isNaN(Number(x))?0:Number(x);return R-C})}},{key:"render",value:function(){var a=this,l=this.props,f=l.pageSize,c=l.locale,x=l.rootPrefixCls,R=l.changeSize,C=l.quickGo,N=l.goButton,U=l.selectComponentClass,W=l.buildOptionText,L=l.selectPrefixCls,H=l.disabled,K=this.state.goInputText,$="".concat(x,"-options"),Q=U,ue=null,ne=null,se=null;if(!R&&!C)return null;var le=this.getPageSizeOptions();if(R&&Q){var de=le.map(function(re,Y){return A.a.createElement(Q.Option,{key:Y,value:re.toString()},(W||a.buildOptionText)(re))});ue=A.a.createElement(Q,{disabled:H,prefixCls:L,showSearch:!1,className:"".concat($,"-size-changer"),optionLabelProp:"children",dropdownMatchSelectWidth:!1,value:(f||le[0]).toString(),onChange:this.changeSize,getPopupContainer:function(Y){return Y.parentNode}},de)}return C&&(N&&(se=typeof N=="boolean"?A.a.createElement("button",{type:"button",onClick:this.go,onKeyUp:this.go,disabled:H,className:"".concat($,"-quick-jumper-button")},c.jump_to_confirm):A.a.createElement("span",{onClick:this.go,onKeyUp:this.go},N)),ne=A.a.createElement("div",{className:"".concat($,"-quick-jumper")},c.jump_to,A.a.createElement("input",{disabled:H,type:"text",value:K,onChange:this.handleChange,onKeyUp:this.go,onBlur:this.handleBlur}),c.page,se)),A.a.createElement("li",{className:"".concat($)},ue,ne)}}]),g}(A.a.Component);n.defaultProps={pageSizeOptions:["10","20","50","100"]};var u=n,o=ee("N2Kk");function t(){}function e(E){return typeof E=="number"&&isFinite(E)&&Math.floor(E)===E}function i(E,b,g){return g}function T(E,b,g){var d=typeof E=="undefined"?b.pageSize:E;return Math.floor((g.total-1)/d)+1}var _=function(E){Object(O.a)(g,E);var b=Object(B.a)(g);function g(d){var a;Object(j.a)(this,g),a=b.call(this,d),a.getJumpPrevPage=function(){return Math.max(1,a.state.current-(a.props.showLessItems?3:5))},a.getJumpNextPage=function(){return Math.min(T(void 0,a.state,a.props),a.state.current+(a.props.showLessItems?3:5))},a.getItemIcon=function(R,C){var N=a.props.prefixCls,U=R||A.a.createElement("button",{type:"button","aria-label":C,className:"".concat(N,"-item-link")});return typeof R=="function"&&(U=A.a.createElement(R,Object(w.a)({},a.props))),U},a.savePaginationNode=function(R){a.paginationNode=R},a.isValid=function(R){return e(R)&&R!==a.state.current},a.shouldDisplayQuickJumper=function(){var R=a.props,C=R.showQuickJumper,N=R.pageSize,U=R.total;return U<=N?!1:C},a.handleKeyDown=function(R){(R.keyCode===r.ARROW_UP||R.keyCode===r.ARROW_DOWN)&&R.preventDefault()},a.handleKeyUp=function(R){var C=a.getValidValue(R),N=a.state.currentInputValue;C!==N&&a.setState({currentInputValue:C}),R.keyCode===r.ENTER?a.handleChange(C):R.keyCode===r.ARROW_UP?a.handleChange(C-1):R.keyCode===r.ARROW_DOWN&&a.handleChange(C+1)},a.changePageSize=function(R){var C=a.state.current,N=T(R,a.state,a.props);C=C>N?N:C,N===0&&(C=a.state.current),typeof R=="number"&&("pageSize"in a.props||a.setState({pageSize:R}),"current"in a.props||a.setState({current:C,currentInputValue:C})),a.props.onShowSizeChange(C,R),"onChange"in a.props&&a.props.onChange&&a.props.onChange(C,R)},a.handleChange=function(R){var C=a.props.disabled,N=R;if(a.isValid(N)&&!C){var U=T(void 0,a.state,a.props);N>U?N=U:N<1&&(N=1),"current"in a.props||a.setState({current:N,currentInputValue:N});var W=a.state.pageSize;return a.props.onChange(N,W),N}return a.state.current},a.prev=function(){a.hasPrev()&&a.handleChange(a.state.current-1)},a.next=function(){a.hasNext()&&a.handleChange(a.state.current+1)},a.jumpPrev=function(){a.handleChange(a.getJumpPrevPage())},a.jumpNext=function(){a.handleChange(a.getJumpNextPage())},a.hasPrev=function(){return a.state.current>1},a.hasNext=function(){return a.state.current<T(void 0,a.state,a.props)},a.runIfEnter=function(R,C){if(R.key==="Enter"||R.charCode===13){for(var N=arguments.length,U=new Array(N>2?N-2:0),W=2;W<N;W++)U[W-2]=arguments[W];C.apply(void 0,U)}},a.runIfEnterPrev=function(R){a.runIfEnter(R,a.prev)},a.runIfEnterNext=function(R){a.runIfEnter(R,a.next)},a.runIfEnterJumpPrev=function(R){a.runIfEnter(R,a.jumpPrev)},a.runIfEnterJumpNext=function(R){a.runIfEnter(R,a.jumpNext)},a.handleGoTO=function(R){(R.keyCode===r.ENTER||R.type==="click")&&a.handleChange(a.state.currentInputValue)};var l=d.onChange!==t,f="current"in d;f&&!l&&console.warn("Warning: You provided a `current` prop to a Pagination component without an `onChange` handler. This will render a read-only component.");var c=d.defaultCurrent;"current"in d&&(c=d.current);var x=d.defaultPageSize;return"pageSize"in d&&(x=d.pageSize),c=Math.min(c,T(x,void 0,d)),a.state={current:c,currentInputValue:c,pageSize:x},a}return Object(I.a)(g,[{key:"componentDidUpdate",value:function(a,l){var f=this.props.prefixCls;if(l.current!==this.state.current&&this.paginationNode){var c=this.paginationNode.querySelector(".".concat(f,"-item-").concat(l.current));c&&document.activeElement===c&&c.blur()}}},{key:"getValidValue",value:function(a){var l=a.target.value,f=T(void 0,this.state,this.props),c=this.state.currentInputValue,x;return l===""?x=l:isNaN(Number(l))?x=c:l>=f?x=f:x=Number(l),x}},{key:"getShowSizeChanger",value:function(){var a=this.props,l=a.showSizeChanger,f=a.total,c=a.totalBoundaryShowSizeChanger;return typeof l!="undefined"?l:f>c}},{key:"renderPrev",value:function(a){var l=this.props,f=l.prevIcon,c=l.itemRender,x=c(a,"prev",this.getItemIcon(f,"prev page")),R=!this.hasPrev();return Object(M.isValidElement)(x)?Object(M.cloneElement)(x,{disabled:R}):x}},{key:"renderNext",value:function(a){var l=this.props,f=l.nextIcon,c=l.itemRender,x=c(a,"next",this.getItemIcon(f,"next page")),R=!this.hasNext();return Object(M.isValidElement)(x)?Object(M.cloneElement)(x,{disabled:R}):x}},{key:"render",value:function(){var a=this,l=this.props,f=l.prefixCls,c=l.className,x=l.style,R=l.disabled,C=l.hideOnSinglePage,N=l.total,U=l.locale,W=l.showQuickJumper,L=l.showLessItems,H=l.showTitle,K=l.showTotal,$=l.simple,Q=l.itemRender,ue=l.showPrevNextJumpers,ne=l.jumpPrevIcon,se=l.jumpNextIcon,le=l.selectComponentClass,de=l.selectPrefixCls,re=l.pageSizeOptions,Y=this.state,pe=Y.current,Te=Y.pageSize,xe=Y.currentInputValue;if(C===!0&&N<=Te)return null;var Se=T(void 0,this.state,this.props),Ae=[],fe=null,ve=null,Ce=null,Oe=null,we=null,be=W&&W.goButton,me=L?1:2,Ue=pe-1>0?pe-1:0,Le=pe+1<Se?pe+1:Se,ke=Object.keys(this.props).reduce(function(z,V){return(V.substr(0,5)==="data-"||V.substr(0,5)==="aria-"||V==="role")&&(z[V]=a.props[V]),z},{});if($)return be&&(typeof be=="boolean"?we=A.a.createElement("button",{type:"button",onClick:this.handleGoTO,onKeyUp:this.handleGoTO},U.jump_to_confirm):we=A.a.createElement("span",{onClick:this.handleGoTO,onKeyUp:this.handleGoTO},be),we=A.a.createElement("li",{title:H?"".concat(U.jump_to).concat(pe,"/").concat(Se):null,className:"".concat(f,"-simple-pager")},we)),A.a.createElement("ul",Object(he.a)({className:p()(f,"".concat(f,"-simple"),Object(G.a)({},"".concat(f,"-disabled"),R),c),style:x,ref:this.savePaginationNode},ke),A.a.createElement("li",{title:H?U.prev_page:null,onClick:this.prev,tabIndex:this.hasPrev()?0:null,onKeyPress:this.runIfEnterPrev,className:p()("".concat(f,"-prev"),Object(G.a)({},"".concat(f,"-disabled"),!this.hasPrev())),"aria-disabled":!this.hasPrev()},this.renderPrev(Ue)),A.a.createElement("li",{title:H?"".concat(pe,"/").concat(Se):null,className:"".concat(f,"-simple-pager")},A.a.createElement("input",{type:"text",value:xe,disabled:R,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,onChange:this.handleKeyUp,size:"3"}),A.a.createElement("span",{className:"".concat(f,"-slash")},"/"),Se),A.a.createElement("li",{title:H?U.next_page:null,onClick:this.next,tabIndex:this.hasPrev()?0:null,onKeyPress:this.runIfEnterNext,className:p()("".concat(f,"-next"),Object(G.a)({},"".concat(f,"-disabled"),!this.hasNext())),"aria-disabled":!this.hasNext()},this.renderNext(Le)),we);if(Se<=3+me*2){var Pe={locale:U,rootPrefixCls:f,onClick:this.handleChange,onKeyPress:this.runIfEnter,showTitle:H,itemRender:Q};Se||Ae.push(A.a.createElement(s,Object(he.a)({},Pe,{key:"noPager",page:Se,className:"".concat(f,"-disabled")})));for(var Be=1;Be<=Se;Be+=1){var je=pe===Be;Ae.push(A.a.createElement(s,Object(he.a)({},Pe,{key:Be,page:Be,active:je})))}}else{var Me=L?U.prev_3:U.prev_5,Re=L?U.next_3:U.next_5;ue&&(fe=A.a.createElement("li",{title:H?Me:null,key:"prev",onClick:this.jumpPrev,tabIndex:"0",onKeyPress:this.runIfEnterJumpPrev,className:p()("".concat(f,"-jump-prev"),Object(G.a)({},"".concat(f,"-jump-prev-custom-icon"),!!ne))},Q(this.getJumpPrevPage(),"jump-prev",this.getItemIcon(ne,"prev page"))),ve=A.a.createElement("li",{title:H?Re:null,key:"next",tabIndex:"0",onClick:this.jumpNext,onKeyPress:this.runIfEnterJumpNext,className:p()("".concat(f,"-jump-next"),Object(G.a)({},"".concat(f,"-jump-next-custom-icon"),!!se))},Q(this.getJumpNextPage(),"jump-next",this.getItemIcon(se,"next page")))),Oe=A.a.createElement(s,{locale:U,last:!0,rootPrefixCls:f,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:Se,page:Se,active:!1,showTitle:H,itemRender:Q}),Ce=A.a.createElement(s,{locale:U,rootPrefixCls:f,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:1,page:1,active:!1,showTitle:H,itemRender:Q});var Fe=Math.max(1,pe-me),Ne=Math.min(pe+me,Se);pe-1<=me&&(Ne=1+me*2),Se-pe<=me&&(Fe=Se-me*2);for(var oe=Fe;oe<=Ne;oe+=1){var Ee=pe===oe;Ae.push(A.a.createElement(s,{locale:U,rootPrefixCls:f,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:oe,page:oe,active:Ee,showTitle:H,itemRender:Q}))}pe-1>=me*2&&pe!==1+2&&(Ae[0]=Object(M.cloneElement)(Ae[0],{className:"".concat(f,"-item-after-jump-prev")}),Ae.unshift(fe)),Se-pe>=me*2&&pe!==Se-2&&(Ae[Ae.length-1]=Object(M.cloneElement)(Ae[Ae.length-1],{className:"".concat(f,"-item-before-jump-next")}),Ae.push(ve)),Fe!==1&&Ae.unshift(Ce),Ne!==Se&&Ae.push(Oe)}var ie=null;K&&(ie=A.a.createElement("li",{className:"".concat(f,"-total-text")},K(N,[N===0?0:(pe-1)*Te+1,pe*Te>N?N:pe*Te])));var J=!this.hasPrev()||!Se,te=!this.hasNext()||!Se;return A.a.createElement("ul",Object(he.a)({className:p()(f,c,Object(G.a)({},"".concat(f,"-disabled"),R)),style:x,unselectable:"unselectable",ref:this.savePaginationNode},ke),ie,A.a.createElement("li",{title:H?U.prev_page:null,onClick:this.prev,tabIndex:J?null:0,onKeyPress:this.runIfEnterPrev,className:p()("".concat(f,"-prev"),Object(G.a)({},"".concat(f,"-disabled"),J)),"aria-disabled":J},this.renderPrev(Ue)),Ae,A.a.createElement("li",{title:H?U.next_page:null,onClick:this.next,tabIndex:te?null:0,onKeyPress:this.runIfEnterNext,className:p()("".concat(f,"-next"),Object(G.a)({},"".concat(f,"-disabled"),te)),"aria-disabled":te},this.renderNext(Le)),A.a.createElement(u,{disabled:R,locale:U,rootPrefixCls:f,selectComponentClass:le,selectPrefixCls:de,changeSize:this.getShowSizeChanger()?this.changePageSize:null,current:pe,pageSize:Te,pageSizeOptions:re,quickGo:this.shouldDisplayQuickJumper()?this.handleChange:null,goButton:be}))}}],[{key:"getDerivedStateFromProps",value:function(a,l){var f={};if("current"in a&&(f.current=a.current,a.current!==l.current&&(f.currentInputValue=f.current)),"pageSize"in a&&a.pageSize!==l.pageSize){var c=l.current,x=T(a.pageSize,l,a);c=c>x?x:c,"current"in a||(f.current=c,f.currentInputValue=c),f.pageSize=a.pageSize}return f}}]),g}(A.a.Component);_.defaultProps={defaultCurrent:1,total:0,defaultPageSize:10,onChange:t,className:"",selectPrefixCls:"rc-select",prefixCls:"rc-pagination",selectComponentClass:null,hideOnSinglePage:!1,showPrevNextJumpers:!0,showQuickJumper:!1,showLessItems:!1,showTitle:!0,onShowSizeChange:t,locale:o.a,style:{},itemRender:i,totalBoundaryShowSizeChanger:50};var y=_},"6UM0":function(Je,Ve,ee){var he,G;(function(){var w;(function(){"use strict";var I=[function(A,S,p){var m=p(1).Beautifier,s=p(5).Options;function r(n,u){var o=new m(n,u);return o.beautify()}A.exports=r,A.exports.defaultOptions=function(){return new s}},function(A,S,p){var m=p(2).Output,s=p(3).Token,r=p(4),n=p(5).Options,u=p(7).Tokenizer,o=p(7).line_starters,t=p(7).positionable_operators,e=p(7).TOKEN;function i(L,H){return H.indexOf(L)!==-1}function T(L){return L.replace(/^\s+/g,"")}function _(L){for(var H={},K=0;K<L.length;K++)H[L[K].replace(/-/g,"_")]=L[K];return H}function y(L,H){return L&&L.type===e.RESERVED&&L.text===H}function E(L,H){return L&&L.type===e.RESERVED&&i(L.text,H)}var b=["case","return","do","if","throw","else","await","break","continue","async"],g=["before-newline","after-newline","preserve-newline"],d=_(g),a=[d.before_newline,d.preserve_newline],l={BlockStatement:"BlockStatement",Statement:"Statement",ObjectLiteral:"ObjectLiteral",ArrayLiteral:"ArrayLiteral",ForInitializer:"ForInitializer",Conditional:"Conditional",Expression:"Expression"};function f(L,H){if(H.multiline_frame||H.mode===l.ForInitializer||H.mode===l.Conditional)return;L.remove_indent(H.start_line_index)}function c(L){L=L.replace(r.allLineBreaks,`
`);for(var H=[],K=L.indexOf(`
`);K!==-1;)H.push(L.substring(0,K)),L=L.substring(K+1),K=L.indexOf(`
`);return L.length&&H.push(L),H}function x(L){return L===l.ArrayLiteral}function R(L){return i(L,[l.Expression,l.ForInitializer,l.Conditional])}function C(L,H){for(var K=0;K<L.length;K++){var $=L[K].trim();if($.charAt(0)!==H)return!1}return!0}function N(L,H){for(var K=0,$=L.length,Q;K<$;K++)if(Q=L[K],Q&&Q.indexOf(H)!==0)return!1;return!0}function U(L,H){H=H||{},this._source_text=L||"",this._output=null,this._tokens=null,this._last_last_text=null,this._flags=null,this._previous_flags=null,this._flag_store=null,this._options=new n(H)}U.prototype.create_flags=function(L,H){var K=0;L&&(K=L.indentation_level,!this._output.just_added_newline()&&L.line_indent_level>K&&(K=L.line_indent_level));var $={mode:H,parent:L,last_token:L?L.last_token:new s(e.START_BLOCK,""),last_word:L?L.last_word:"",declaration_statement:!1,declaration_assignment:!1,multiline_frame:!1,inline_frame:!1,if_block:!1,else_block:!1,class_start_block:!1,do_block:!1,do_while:!1,import_block:!1,in_case_statement:!1,in_case:!1,case_body:!1,case_block:!1,indentation_level:K,alignment:0,line_indent_level:L?L.line_indent_level:K,start_line_index:this._output.get_line_number(),ternary_depth:0};return $},U.prototype._reset=function(L){var H=L.match(/^[\t ]*/)[0];this._last_last_text="",this._output=new m(this._options,H),this._output.raw=this._options.test_output_raw,this._flag_store=[],this.set_mode(l.BlockStatement);var K=new u(L,this._options);return this._tokens=K.tokenize(),L},U.prototype.beautify=function(){if(this._options.disabled)return this._source_text;var L,H=this._reset(this._source_text),K=this._options.eol;this._options.eol==="auto"&&(K=`
`,H&&r.lineBreak.test(H||"")&&(K=H.match(r.lineBreak)[0]));for(var $=this._tokens.next();$;)this.handle_token($),this._last_last_text=this._flags.last_token.text,this._flags.last_token=$,$=this._tokens.next();return L=this._output.get_code(K),L},U.prototype.handle_token=function(L,H){L.type===e.START_EXPR?this.handle_start_expr(L):L.type===e.END_EXPR?this.handle_end_expr(L):L.type===e.START_BLOCK?this.handle_start_block(L):L.type===e.END_BLOCK?this.handle_end_block(L):L.type===e.WORD?this.handle_word(L):L.type===e.RESERVED?this.handle_word(L):L.type===e.SEMICOLON?this.handle_semicolon(L):L.type===e.STRING?this.handle_string(L):L.type===e.EQUALS?this.handle_equals(L):L.type===e.OPERATOR?this.handle_operator(L):L.type===e.COMMA?this.handle_comma(L):L.type===e.BLOCK_COMMENT?this.handle_block_comment(L,H):L.type===e.COMMENT?this.handle_comment(L,H):L.type===e.DOT?this.handle_dot(L):L.type===e.EOF?this.handle_eof(L):L.type===e.UNKNOWN?this.handle_unknown(L,H):this.handle_unknown(L,H)},U.prototype.handle_whitespace_and_comments=function(L,H){var K=L.newlines,$=this._options.keep_array_indentation&&x(this._flags.mode);if(L.comments_before)for(var Q=L.comments_before.next();Q;)this.handle_whitespace_and_comments(Q,H),this.handle_token(Q,H),Q=L.comments_before.next();if($)for(var ue=0;ue<K;ue+=1)this.print_newline(ue>0,H);else if(this._options.max_preserve_newlines&&K>this._options.max_preserve_newlines&&(K=this._options.max_preserve_newlines),this._options.preserve_newlines&&K>1){this.print_newline(!1,H);for(var ne=1;ne<K;ne+=1)this.print_newline(!0,H)}};var W=["async","break","continue","return","throw","yield"];U.prototype.allow_wrap_or_preserved_newline=function(L,H){if(H=H===void 0?!1:H,this._output.just_added_newline())return;var K=this._options.preserve_newlines&&L.newlines||H,$=i(this._flags.last_token.text,t)||i(L.text,t);if($){var Q=i(this._flags.last_token.text,t)&&i(this._options.operator_position,a)||i(L.text,t);K=K&&Q}if(K)this.print_newline(!1,!0);else if(this._options.wrap_line_length){if(E(this._flags.last_token,W))return;this._output.set_wrap_point()}},U.prototype.print_newline=function(L,H){if(!H&&(this._flags.last_token.text!==";"&&this._flags.last_token.text!==","&&this._flags.last_token.text!=="="&&(this._flags.last_token.type!==e.OPERATOR||this._flags.last_token.text==="--"||this._flags.last_token.text==="++")))for(var K=this._tokens.peek();this._flags.mode===l.Statement&&!(this._flags.if_block&&y(K,"else"))&&!this._flags.do_block;)this.restore_mode();this._output.add_new_line(L)&&(this._flags.multiline_frame=!0)},U.prototype.print_token_line_indentation=function(L){this._output.just_added_newline()&&(this._options.keep_array_indentation&&L.newlines&&(L.text==="["||x(this._flags.mode))?(this._output.current_line.set_indent(-1),this._output.current_line.push(L.whitespace_before),this._output.space_before_token=!1):this._output.set_indent(this._flags.indentation_level,this._flags.alignment)&&(this._flags.line_indent_level=this._flags.indentation_level))},U.prototype.print_token=function(L){if(this._output.raw){this._output.add_raw_token(L);return}if(this._options.comma_first&&L.previous&&L.previous.type===e.COMMA&&this._output.just_added_newline()&&this._output.previous_line.last()===","){var H=this._output.previous_line.pop();this._output.previous_line.is_empty()&&(this._output.previous_line.push(H),this._output.trim(!0),this._output.current_line.pop(),this._output.trim()),this.print_token_line_indentation(L),this._output.add_token(","),this._output.space_before_token=!0}this.print_token_line_indentation(L),this._output.non_breaking_space=!0,this._output.add_token(L.text),this._output.previous_token_wrapped&&(this._flags.multiline_frame=!0)},U.prototype.indent=function(){this._flags.indentation_level+=1,this._output.set_indent(this._flags.indentation_level,this._flags.alignment)},U.prototype.deindent=function(){this._flags.indentation_level>0&&(!this._flags.parent||this._flags.indentation_level>this._flags.parent.indentation_level)&&(this._flags.indentation_level-=1,this._output.set_indent(this._flags.indentation_level,this._flags.alignment))},U.prototype.set_mode=function(L){this._flags?(this._flag_store.push(this._flags),this._previous_flags=this._flags):this._previous_flags=this.create_flags(null,L),this._flags=this.create_flags(this._previous_flags,L),this._output.set_indent(this._flags.indentation_level,this._flags.alignment)},U.prototype.restore_mode=function(){this._flag_store.length>0&&(this._previous_flags=this._flags,this._flags=this._flag_store.pop(),this._previous_flags.mode===l.Statement&&f(this._output,this._previous_flags),this._output.set_indent(this._flags.indentation_level,this._flags.alignment))},U.prototype.start_of_object_property=function(){return this._flags.parent.mode===l.ObjectLiteral&&this._flags.mode===l.Statement&&(this._flags.last_token.text===":"&&this._flags.ternary_depth===0||E(this._flags.last_token,["get","set"]))},U.prototype.start_of_statement=function(L){var H=!1;return H=H||E(this._flags.last_token,["var","let","const"])&&L.type===e.WORD,H=H||y(this._flags.last_token,"do"),H=H||!(this._flags.parent.mode===l.ObjectLiteral&&this._flags.mode===l.Statement)&&E(this._flags.last_token,W)&&!L.newlines,H=H||y(this._flags.last_token,"else")&&!(y(L,"if")&&!L.comments_before),H=H||this._flags.last_token.type===e.END_EXPR&&(this._previous_flags.mode===l.ForInitializer||this._previous_flags.mode===l.Conditional),H=H||this._flags.last_token.type===e.WORD&&this._flags.mode===l.BlockStatement&&!this._flags.in_case&&!(L.text==="--"||L.text==="++")&&this._last_last_text!=="function"&&L.type!==e.WORD&&L.type!==e.RESERVED,H=H||this._flags.mode===l.ObjectLiteral&&(this._flags.last_token.text===":"&&this._flags.ternary_depth===0||E(this._flags.last_token,["get","set"])),H?(this.set_mode(l.Statement),this.indent(),this.handle_whitespace_and_comments(L,!0),this.start_of_object_property()||this.allow_wrap_or_preserved_newline(L,E(L,["do","for","if","while"])),!0):!1},U.prototype.handle_start_expr=function(L){this.start_of_statement(L)||this.handle_whitespace_and_comments(L);var H=l.Expression;if(L.text==="["){if(this._flags.last_token.type===e.WORD||this._flags.last_token.text===")"){E(this._flags.last_token,o)&&(this._output.space_before_token=!0),this.print_token(L),this.set_mode(H),this.indent(),this._options.space_in_paren&&(this._output.space_before_token=!0);return}H=l.ArrayLiteral,x(this._flags.mode)&&((this._flags.last_token.text==="["||this._flags.last_token.text===","&&(this._last_last_text==="]"||this._last_last_text==="}"))&&(this._options.keep_array_indentation||this.print_newline())),i(this._flags.last_token.type,[e.START_EXPR,e.END_EXPR,e.WORD,e.OPERATOR,e.DOT])||(this._output.space_before_token=!0)}else{if(this._flags.last_token.type===e.RESERVED)this._flags.last_token.text==="for"?(this._output.space_before_token=this._options.space_before_conditional,H=l.ForInitializer):i(this._flags.last_token.text,["if","while","switch"])?(this._output.space_before_token=this._options.space_before_conditional,H=l.Conditional):i(this._flags.last_word,["await","async"])?this._output.space_before_token=!0:this._flags.last_token.text==="import"&&L.whitespace_before===""?this._output.space_before_token=!1:(i(this._flags.last_token.text,o)||this._flags.last_token.text==="catch")&&(this._output.space_before_token=!0);else if(this._flags.last_token.type===e.EQUALS||this._flags.last_token.type===e.OPERATOR)this.start_of_object_property()||this.allow_wrap_or_preserved_newline(L);else if(this._flags.last_token.type===e.WORD){this._output.space_before_token=!1;var K=this._tokens.peek(-3);if(this._options.space_after_named_function&&K){var $=this._tokens.peek(-4);E(K,["async","function"])||K.text==="*"&&E($,["async","function"])?this._output.space_before_token=!0:this._flags.mode===l.ObjectLiteral?(K.text==="{"||K.text===","||K.text==="*"&&($.text==="{"||$.text===","))&&(this._output.space_before_token=!0):this._flags.parent&&this._flags.parent.class_start_block&&(this._output.space_before_token=!0)}}else this.allow_wrap_or_preserved_newline(L);(this._flags.last_token.type===e.RESERVED&&(this._flags.last_word==="function"||this._flags.last_word==="typeof")||this._flags.last_token.text==="*"&&(i(this._last_last_text,["function","yield"])||this._flags.mode===l.ObjectLiteral&&i(this._last_last_text,["{",","])))&&(this._output.space_before_token=this._options.space_after_anon_function)}this._flags.last_token.text===";"||this._flags.last_token.type===e.START_BLOCK?this.print_newline():(this._flags.last_token.type===e.END_EXPR||this._flags.last_token.type===e.START_EXPR||this._flags.last_token.type===e.END_BLOCK||this._flags.last_token.text==="."||this._flags.last_token.type===e.COMMA)&&this.allow_wrap_or_preserved_newline(L,L.newlines),this.print_token(L),this.set_mode(H),this._options.space_in_paren&&(this._output.space_before_token=!0),this.indent()},U.prototype.handle_end_expr=function(L){for(;this._flags.mode===l.Statement;)this.restore_mode();this.handle_whitespace_and_comments(L),this._flags.multiline_frame&&this.allow_wrap_or_preserved_newline(L,L.text==="]"&&x(this._flags.mode)&&!this._options.keep_array_indentation),this._options.space_in_paren&&(this._flags.last_token.type===e.START_EXPR&&!this._options.space_in_empty_paren?(this._output.trim(),this._output.space_before_token=!1):this._output.space_before_token=!0),this.deindent(),this.print_token(L),this.restore_mode(),f(this._output,this._previous_flags),this._flags.do_while&&this._previous_flags.mode===l.Conditional&&(this._previous_flags.mode=l.Expression,this._flags.do_block=!1,this._flags.do_while=!1)},U.prototype.handle_start_block=function(L){this.handle_whitespace_and_comments(L);var H=this._tokens.peek(),K=this._tokens.peek(1);this._flags.last_word==="switch"&&this._flags.last_token.type===e.END_EXPR?(this.set_mode(l.BlockStatement),this._flags.in_case_statement=!0):this._flags.case_body?this.set_mode(l.BlockStatement):K&&(i(K.text,[":",","])&&i(H.type,[e.STRING,e.WORD,e.RESERVED])||i(H.text,["get","set","..."])&&i(K.type,[e.WORD,e.RESERVED]))?i(this._last_last_text,["class","interface"])&&!i(K.text,[":",","])?this.set_mode(l.BlockStatement):this.set_mode(l.ObjectLiteral):this._flags.last_token.type===e.OPERATOR&&this._flags.last_token.text==="=>"?this.set_mode(l.BlockStatement):i(this._flags.last_token.type,[e.EQUALS,e.START_EXPR,e.COMMA,e.OPERATOR])||E(this._flags.last_token,["return","throw","import","default"])?this.set_mode(l.ObjectLiteral):this.set_mode(l.BlockStatement),this._flags.last_token&&(E(this._flags.last_token.previous,["class","extends"])&&(this._flags.class_start_block=!0));var $=!H.comments_before&&H.text==="}",Q=$&&this._flags.last_word==="function"&&this._flags.last_token.type===e.END_EXPR;if(this._options.brace_preserve_inline){var ue=0,ne=null;this._flags.inline_frame=!0;do if(ue+=1,ne=this._tokens.peek(ue-1),ne.newlines){this._flags.inline_frame=!1;break}while(ne.type!==e.EOF&&!(ne.type===e.END_BLOCK&&ne.opened===L))}(this._options.brace_style==="expand"||this._options.brace_style==="none"&&L.newlines)&&!this._flags.inline_frame?this._flags.last_token.type!==e.OPERATOR&&(Q||this._flags.last_token.type===e.EQUALS||E(this._flags.last_token,b)&&this._flags.last_token.text!=="else")?this._output.space_before_token=!0:this.print_newline(!1,!0):(x(this._previous_flags.mode)&&(this._flags.last_token.type===e.START_EXPR||this._flags.last_token.type===e.COMMA)&&((this._flags.last_token.type===e.COMMA||this._options.space_in_paren)&&(this._output.space_before_token=!0),(this._flags.last_token.type===e.COMMA||this._flags.last_token.type===e.START_EXPR&&this._flags.inline_frame)&&(this.allow_wrap_or_preserved_newline(L),this._previous_flags.multiline_frame=this._previous_flags.multiline_frame||this._flags.multiline_frame,this._flags.multiline_frame=!1)),this._flags.last_token.type!==e.OPERATOR&&this._flags.last_token.type!==e.START_EXPR&&(this._flags.last_token.type===e.START_BLOCK&&!this._flags.inline_frame?this.print_newline():this._output.space_before_token=!0)),this.print_token(L),this.indent(),!$&&!(this._options.brace_preserve_inline&&this._flags.inline_frame)&&this.print_newline()},U.prototype.handle_end_block=function(L){for(this.handle_whitespace_and_comments(L);this._flags.mode===l.Statement;)this.restore_mode();var H=this._flags.last_token.type===e.START_BLOCK;this._flags.inline_frame&&!H?this._output.space_before_token=!0:this._options.brace_style==="expand"?H||this.print_newline():H||(x(this._flags.mode)&&this._options.keep_array_indentation?(this._options.keep_array_indentation=!1,this.print_newline(),this._options.keep_array_indentation=!0):this.print_newline()),this.restore_mode(),this.print_token(L)},U.prototype.handle_word=function(L){if(L.type===e.RESERVED){if(i(L.text,["set","get"])&&this._flags.mode!==l.ObjectLiteral)L.type=e.WORD;else if(L.text==="import"&&i(this._tokens.peek().text,["(","."]))L.type=e.WORD;else if(i(L.text,["as","from"])&&!this._flags.import_block)L.type=e.WORD;else if(this._flags.mode===l.ObjectLiteral){var H=this._tokens.peek();H.text===":"&&(L.type=e.WORD)}}if(this.start_of_statement(L)?E(this._flags.last_token,["var","let","const"])&&L.type===e.WORD&&(this._flags.declaration_statement=!0):L.newlines&&!R(this._flags.mode)&&(this._flags.last_token.type!==e.OPERATOR||this._flags.last_token.text==="--"||this._flags.last_token.text==="++")&&this._flags.last_token.type!==e.EQUALS&&(this._options.preserve_newlines||!E(this._flags.last_token,["var","let","const","set","get"]))?(this.handle_whitespace_and_comments(L),this.print_newline()):this.handle_whitespace_and_comments(L),this._flags.do_block&&!this._flags.do_while)if(y(L,"while")){this._output.space_before_token=!0,this.print_token(L),this._output.space_before_token=!0,this._flags.do_while=!0;return}else this.print_newline(),this._flags.do_block=!1;if(this._flags.if_block)if(!this._flags.else_block&&y(L,"else"))this._flags.else_block=!0;else{for(;this._flags.mode===l.Statement;)this.restore_mode();this._flags.if_block=!1,this._flags.else_block=!1}if(this._flags.in_case_statement&&E(L,["case","default"])){this.print_newline(),!this._flags.case_block&&(this._flags.case_body||this._options.jslint_happy)&&this.deindent(),this._flags.case_body=!1,this.print_token(L),this._flags.in_case=!0;return}if((this._flags.last_token.type===e.COMMA||this._flags.last_token.type===e.START_EXPR||this._flags.last_token.type===e.EQUALS||this._flags.last_token.type===e.OPERATOR)&&(this.start_of_object_property()||this.allow_wrap_or_preserved_newline(L)),y(L,"function")){(i(this._flags.last_token.text,["}",";"])||this._output.just_added_newline()&&!(i(this._flags.last_token.text,["(","[","{",":","=",","])||this._flags.last_token.type===e.OPERATOR))&&(!this._output.just_added_blankline()&&!L.comments_before&&(this.print_newline(),this.print_newline(!0))),this._flags.last_token.type===e.RESERVED||this._flags.last_token.type===e.WORD?E(this._flags.last_token,["get","set","new","export"])||E(this._flags.last_token,W)?this._output.space_before_token=!0:y(this._flags.last_token,"default")&&this._last_last_text==="export"?this._output.space_before_token=!0:this._flags.last_token.text==="declare"?this._output.space_before_token=!0:this.print_newline():this._flags.last_token.type===e.OPERATOR||this._flags.last_token.text==="="?this._output.space_before_token=!0:!this._flags.multiline_frame&&(R(this._flags.mode)||x(this._flags.mode))||this.print_newline(),this.print_token(L),this._flags.last_word=L.text;return}var K="NONE";if(this._flags.last_token.type===e.END_BLOCK?this._previous_flags.inline_frame?K="SPACE":E(L,["else","catch","finally","from"])?this._options.brace_style==="expand"||this._options.brace_style==="end-expand"||this._options.brace_style==="none"&&L.newlines?K="NEWLINE":(K="SPACE",this._output.space_before_token=!0):K="NEWLINE":this._flags.last_token.type===e.SEMICOLON&&this._flags.mode===l.BlockStatement?K="NEWLINE":this._flags.last_token.type===e.SEMICOLON&&R(this._flags.mode)?K="SPACE":this._flags.last_token.type===e.STRING?K="NEWLINE":this._flags.last_token.type===e.RESERVED||this._flags.last_token.type===e.WORD||this._flags.last_token.text==="*"&&(i(this._last_last_text,["function","yield"])||this._flags.mode===l.ObjectLiteral&&i(this._last_last_text,["{",","]))?K="SPACE":this._flags.last_token.type===e.START_BLOCK?this._flags.inline_frame?K="SPACE":K="NEWLINE":this._flags.last_token.type===e.END_EXPR&&(this._output.space_before_token=!0,K="NEWLINE"),E(L,o)&&this._flags.last_token.text!==")"&&(this._flags.inline_frame||this._flags.last_token.text==="else"||this._flags.last_token.text==="export"?K="SPACE":K="NEWLINE"),E(L,["else","catch","finally"]))if((!(this._flags.last_token.type===e.END_BLOCK&&this._previous_flags.mode===l.BlockStatement)||this._options.brace_style==="expand"||this._options.brace_style==="end-expand"||this._options.brace_style==="none"&&L.newlines)&&!this._flags.inline_frame)this.print_newline();else{this._output.trim(!0);var $=this._output.current_line;$.last()!=="}"&&this.print_newline(),this._output.space_before_token=!0}else K==="NEWLINE"?E(this._flags.last_token,b)?this._output.space_before_token=!0:this._flags.last_token.text==="declare"&&E(L,["var","let","const"])?this._output.space_before_token=!0:this._flags.last_token.type!==e.END_EXPR?(this._flags.last_token.type!==e.START_EXPR||!E(L,["var","let","const"]))&&this._flags.last_token.text!==":"&&(y(L,"if")&&y(L.previous,"else")?this._output.space_before_token=!0:this.print_newline()):E(L,o)&&this._flags.last_token.text!==")"&&this.print_newline():this._flags.multiline_frame&&x(this._flags.mode)&&this._flags.last_token.text===","&&this._last_last_text==="}"?this.print_newline():K==="SPACE"&&(this._output.space_before_token=!0);L.previous&&(L.previous.type===e.WORD||L.previous.type===e.RESERVED)&&(this._output.space_before_token=!0),this.print_token(L),this._flags.last_word=L.text,L.type===e.RESERVED&&(L.text==="do"?this._flags.do_block=!0:L.text==="if"?this._flags.if_block=!0:L.text==="import"?this._flags.import_block=!0:this._flags.import_block&&y(L,"from")&&(this._flags.import_block=!1))},U.prototype.handle_semicolon=function(L){this.start_of_statement(L)?this._output.space_before_token=!1:this.handle_whitespace_and_comments(L);for(var H=this._tokens.peek();this._flags.mode===l.Statement&&!(this._flags.if_block&&y(H,"else"))&&!this._flags.do_block;)this.restore_mode();this._flags.import_block&&(this._flags.import_block=!1),this.print_token(L)},U.prototype.handle_string=function(L){L.text.startsWith("`")&&L.newlines===0&&L.whitespace_before===""&&(L.previous.text===")"||this._flags.last_token.type===e.WORD)||(this.start_of_statement(L)?this._output.space_before_token=!0:(this.handle_whitespace_and_comments(L),this._flags.last_token.type===e.RESERVED||this._flags.last_token.type===e.WORD||this._flags.inline_frame?this._output.space_before_token=!0:this._flags.last_token.type===e.COMMA||this._flags.last_token.type===e.START_EXPR||this._flags.last_token.type===e.EQUALS||this._flags.last_token.type===e.OPERATOR?this.start_of_object_property()||this.allow_wrap_or_preserved_newline(L):L.text.startsWith("`")&&this._flags.last_token.type===e.END_EXPR&&(L.previous.text==="]"||L.previous.text===")")&&L.newlines===0?this._output.space_before_token=!0:this.print_newline())),this.print_token(L)},U.prototype.handle_equals=function(L){this.start_of_statement(L)||this.handle_whitespace_and_comments(L),this._flags.declaration_statement&&(this._flags.declaration_assignment=!0),this._output.space_before_token=!0,this.print_token(L),this._output.space_before_token=!0},U.prototype.handle_comma=function(L){this.handle_whitespace_and_comments(L,!0),this.print_token(L),this._output.space_before_token=!0,this._flags.declaration_statement?(R(this._flags.parent.mode)&&(this._flags.declaration_assignment=!1),this._flags.declaration_assignment?(this._flags.declaration_assignment=!1,this.print_newline(!1,!0)):this._options.comma_first&&this.allow_wrap_or_preserved_newline(L)):this._flags.mode===l.ObjectLiteral||this._flags.mode===l.Statement&&this._flags.parent.mode===l.ObjectLiteral?(this._flags.mode===l.Statement&&this.restore_mode(),this._flags.inline_frame||this.print_newline()):this._options.comma_first&&this.allow_wrap_or_preserved_newline(L)},U.prototype.handle_operator=function(L){var H=L.text==="*"&&(E(this._flags.last_token,["function","yield"])||i(this._flags.last_token.type,[e.START_BLOCK,e.COMMA,e.END_BLOCK,e.SEMICOLON])),K=i(L.text,["-","+"])&&(i(this._flags.last_token.type,[e.START_BLOCK,e.START_EXPR,e.EQUALS,e.OPERATOR])||i(this._flags.last_token.text,o)||this._flags.last_token.text===",");if(!this.start_of_statement(L)){var $=!H;this.handle_whitespace_and_comments(L,$)}if(L.text==="*"&&this._flags.last_token.type===e.DOT){this.print_token(L);return}if(L.text==="::"){this.print_token(L);return}if(this._flags.last_token.type===e.OPERATOR&&i(this._options.operator_position,a)&&this.allow_wrap_or_preserved_newline(L),L.text===":"&&this._flags.in_case){this.print_token(L),this._flags.in_case=!1,this._flags.case_body=!0,this._tokens.peek().type!==e.START_BLOCK?(this.indent(),this.print_newline(),this._flags.case_block=!1):(this._flags.case_block=!0,this._output.space_before_token=!0);return}var Q=!0,ue=!0,ne=!1;if(L.text===":"?this._flags.ternary_depth===0?Q=!1:(this._flags.ternary_depth-=1,ne=!0):L.text==="?"&&(this._flags.ternary_depth+=1),!K&&!H&&this._options.preserve_newlines&&i(L.text,t)){var se=L.text===":",le=se&&ne,de=se&&!ne;switch(this._options.operator_position){case d.before_newline:this._output.space_before_token=!de,this.print_token(L),(!se||le)&&this.allow_wrap_or_preserved_newline(L),this._output.space_before_token=!0;return;case d.after_newline:this._output.space_before_token=!0,!se||le?this._tokens.peek().newlines?this.print_newline(!1,!0):this.allow_wrap_or_preserved_newline(L):this._output.space_before_token=!1,this.print_token(L),this._output.space_before_token=!0;return;case d.preserve_newline:de||this.allow_wrap_or_preserved_newline(L),Q=!(this._output.just_added_newline()||de),this._output.space_before_token=Q,this.print_token(L),this._output.space_before_token=!0;return}}if(H){this.allow_wrap_or_preserved_newline(L),Q=!1;var re=this._tokens.peek();ue=re&&i(re.type,[e.WORD,e.RESERVED])}else if(L.text==="...")this.allow_wrap_or_preserved_newline(L),Q=this._flags.last_token.type===e.START_BLOCK,ue=!1;else if(i(L.text,["--","++","!","~"])||K){if((this._flags.last_token.type===e.COMMA||this._flags.last_token.type===e.START_EXPR)&&this.allow_wrap_or_preserved_newline(L),Q=!1,ue=!1,L.newlines&&(L.text==="--"||L.text==="++"||L.text==="~")){var Y=E(this._flags.last_token,b)&&L.newlines;Y&&(this._previous_flags.if_block||this._previous_flags.else_block)&&this.restore_mode(),this.print_newline(Y,!0)}this._flags.last_token.text===";"&&R(this._flags.mode)&&(Q=!0),this._flags.last_token.type===e.RESERVED?Q=!0:this._flags.last_token.type===e.END_EXPR?Q=!(this._flags.last_token.text==="]"&&(L.text==="--"||L.text==="++")):this._flags.last_token.type===e.OPERATOR&&(Q=i(L.text,["--","-","++","+"])&&i(this._flags.last_token.text,["--","-","++","+"]),i(L.text,["+","-"])&&i(this._flags.last_token.text,["--","++"])&&(ue=!0)),(this._flags.mode===l.BlockStatement&&!this._flags.inline_frame||this._flags.mode===l.Statement)&&(this._flags.last_token.text==="{"||this._flags.last_token.text===";")&&this.print_newline()}this._output.space_before_token=this._output.space_before_token||Q,this.print_token(L),this._output.space_before_token=ue},U.prototype.handle_block_comment=function(L,H){if(this._output.raw){this._output.add_raw_token(L),L.directives&&L.directives.preserve==="end"&&(this._output.raw=this._options.test_output_raw);return}if(L.directives){this.print_newline(!1,H),this.print_token(L),L.directives.preserve==="start"&&(this._output.raw=!0),this.print_newline(!1,!0);return}if(!r.newline.test(L.text)&&!L.newlines){this._output.space_before_token=!0,this.print_token(L),this._output.space_before_token=!0;return}else this.print_block_commment(L,H)},U.prototype.print_block_commment=function(L,H){var K=c(L.text),$,Q=!1,ue=!1,ne=L.whitespace_before,se=ne.length;if(this.print_newline(!1,H),this.print_token_line_indentation(L),this._output.add_token(K[0]),this.print_newline(!1,H),K.length>1){for(K=K.slice(1),Q=C(K,"*"),ue=N(K,ne),Q&&(this._flags.alignment=1),$=0;$<K.length;$++)Q?(this.print_token_line_indentation(L),this._output.add_token(T(K[$]))):ue&&K[$]?(this.print_token_line_indentation(L),this._output.add_token(K[$].substring(se))):(this._output.current_line.set_indent(-1),this._output.add_token(K[$])),this.print_newline(!1,H);this._flags.alignment=0}},U.prototype.handle_comment=function(L,H){L.newlines?this.print_newline(!1,H):this._output.trim(!0),this._output.space_before_token=!0,this.print_token(L),this.print_newline(!1,H)},U.prototype.handle_dot=function(L){this.start_of_statement(L)||this.handle_whitespace_and_comments(L,!0),this._flags.last_token.text.match("^[0-9]+$")&&(this._output.space_before_token=!0),E(this._flags.last_token,b)?this._output.space_before_token=!1:this.allow_wrap_or_preserved_newline(L,this._flags.last_token.text===")"&&this._options.break_chained_methods),this._options.unindent_chained_methods&&this._output.just_added_newline()&&this.deindent(),this.print_token(L)},U.prototype.handle_unknown=function(L,H){this.print_token(L),L.text[L.text.length-1]===`
`&&this.print_newline(!1,H)},U.prototype.handle_eof=function(L){for(;this._flags.mode===l.Statement;)this.restore_mode();this.handle_whitespace_and_comments(L)},A.exports.Beautifier=U},function(A){function S(s){this.__parent=s,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}S.prototype.clone_empty=function(){var s=new S(this.__parent);return s.set_indent(this.__indent_count,this.__alignment_count),s},S.prototype.item=function(s){return s<0?this.__items[this.__items.length+s]:this.__items[s]},S.prototype.has_match=function(s){for(var r=this.__items.length-1;r>=0;r--)if(this.__items[r].match(s))return!0;return!1},S.prototype.set_indent=function(s,r){this.is_empty()&&(this.__indent_count=s||0,this.__alignment_count=r||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},S.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},S.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},S.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var s=this.__parent.current_line;return s.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),s.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),s.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,s.__items[0]===" "&&(s.__items.splice(0,1),s.__character_count-=1),!0}return!1},S.prototype.is_empty=function(){return this.__items.length===0},S.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},S.prototype.push=function(s){this.__items.push(s);var r=s.lastIndexOf(`
`);r!==-1?this.__character_count=s.length-r:this.__character_count+=s.length},S.prototype.pop=function(){var s=null;return this.is_empty()||(s=this.__items.pop(),this.__character_count-=s.length),s},S.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},S.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},S.prototype.trim=function(){for(;this.last()===" ";)this.__items.pop(),this.__character_count-=1},S.prototype.toString=function(){var s="";return this.is_empty()?this.__parent.indent_empty_lines&&(s=this.__parent.get_indent_string(this.__indent_count)):(s=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),s+=this.__items.join("")),s};function p(s,r){this.__cache=[""],this.__indent_size=s.indent_size,this.__indent_string=s.indent_char,s.indent_with_tabs||(this.__indent_string=new Array(s.indent_size+1).join(s.indent_char)),r=r||"",s.indent_level>0&&(r=new Array(s.indent_level+1).join(this.__indent_string)),this.__base_string=r,this.__base_string_length=r.length}p.prototype.get_indent_size=function(s,r){var n=this.__base_string_length;return r=r||0,s<0&&(n=0),n+=s*this.__indent_size,n+=r,n},p.prototype.get_indent_string=function(s,r){var n=this.__base_string;return r=r||0,s<0&&(s=0,n=""),r+=s*this.__indent_size,this.__ensure_cache(r),n+=this.__cache[r],n},p.prototype.__ensure_cache=function(s){for(;s>=this.__cache.length;)this.__add_column()},p.prototype.__add_column=function(){var s=this.__cache.length,r=0,n="";this.__indent_size&&s>=this.__indent_size&&(r=Math.floor(s/this.__indent_size),s-=r*this.__indent_size,n=new Array(r+1).join(this.__indent_string)),s&&(n+=new Array(s+1).join(" ")),this.__cache.push(n)};function m(s,r){this.__indent_cache=new p(s,r),this.raw=!1,this._end_with_newline=s.end_with_newline,this.indent_size=s.indent_size,this.wrap_line_length=s.wrap_line_length,this.indent_empty_lines=s.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new S(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}m.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},m.prototype.get_line_number=function(){return this.__lines.length},m.prototype.get_indent_string=function(s,r){return this.__indent_cache.get_indent_string(s,r)},m.prototype.get_indent_size=function(s,r){return this.__indent_cache.get_indent_size(s,r)},m.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},m.prototype.add_new_line=function(s){return this.is_empty()||!s&&this.just_added_newline()?!1:(this.raw||this.__add_outputline(),!0)},m.prototype.get_code=function(s){this.trim(!0);var r=this.current_line.pop();r&&(r[r.length-1]===`
`&&(r=r.replace(/\n+$/g,"")),this.current_line.push(r)),this._end_with_newline&&this.__add_outputline();var n=this.__lines.join(`
`);return s!==`
`&&(n=n.replace(/[\n]/g,s)),n},m.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},m.prototype.set_indent=function(s,r){return s=s||0,r=r||0,this.next_line.set_indent(s,r),this.__lines.length>1?(this.current_line.set_indent(s,r),!0):(this.current_line.set_indent(),!1)},m.prototype.add_raw_token=function(s){for(var r=0;r<s.newlines;r++)this.__add_outputline();this.current_line.set_indent(-1),this.current_line.push(s.whitespace_before),this.current_line.push(s.text),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1},m.prototype.add_token=function(s){this.__add_space_before_token(),this.current_line.push(s),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=this.current_line._allow_wrap()},m.prototype.__add_space_before_token=function(){this.space_before_token&&!this.just_added_newline()&&(this.non_breaking_space||this.set_wrap_point(),this.current_line.push(" "))},m.prototype.remove_indent=function(s){for(var r=this.__lines.length;s<r;)this.__lines[s]._remove_indent(),s++;this.current_line._remove_wrap_indent()},m.prototype.trim=function(s){for(s=s===void 0?!1:s,this.current_line.trim();s&&this.__lines.length>1&&this.current_line.is_empty();)this.__lines.pop(),this.current_line=this.__lines[this.__lines.length-1],this.current_line.trim();this.previous_line=this.__lines.length>1?this.__lines[this.__lines.length-2]:null},m.prototype.just_added_newline=function(){return this.current_line.is_empty()},m.prototype.just_added_blankline=function(){return this.is_empty()||this.current_line.is_empty()&&this.previous_line.is_empty()},m.prototype.ensure_empty_line_above=function(s,r){for(var n=this.__lines.length-2;n>=0;){var u=this.__lines[n];if(u.is_empty())break;if(u.item(0).indexOf(s)!==0&&u.item(-1)!==r){this.__lines.splice(n+1,0,new S(this)),this.previous_line=this.__lines[this.__lines.length-2];break}n--}},A.exports.Output=m},function(A){function S(p,m,s,r){this.type=p,this.text=m,this.comments_before=null,this.newlines=s||0,this.whitespace_before=r||"",this.parent=null,this.next=null,this.previous=null,this.opened=null,this.closed=null,this.directives=null}A.exports.Token=S},function(A,S){var p="\\x23\\x24\\x40\\x41-\\x5a\\x5f\\x61-\\x7a",m="\\x24\\x30-\\x39\\x41-\\x5a\\x5f\\x61-\\x7a",s="\\xaa\\xb5\\xba\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02c1\\u02c6-\\u02d1\\u02e0-\\u02e4\\u02ec\\u02ee\\u0370-\\u0374\\u0376\\u0377\\u037a-\\u037d\\u0386\\u0388-\\u038a\\u038c\\u038e-\\u03a1\\u03a3-\\u03f5\\u03f7-\\u0481\\u048a-\\u0527\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05d0-\\u05ea\\u05f0-\\u05f2\\u0620-\\u064a\\u066e\\u066f\\u0671-\\u06d3\\u06d5\\u06e5\\u06e6\\u06ee\\u06ef\\u06fa-\\u06fc\\u06ff\\u0710\\u0712-\\u072f\\u074d-\\u07a5\\u07b1\\u07ca-\\u07ea\\u07f4\\u07f5\\u07fa\\u0800-\\u0815\\u081a\\u0824\\u0828\\u0840-\\u0858\\u08a0\\u08a2-\\u08ac\\u0904-\\u0939\\u093d\\u0950\\u0958-\\u0961\\u0971-\\u0977\\u0979-\\u097f\\u0985-\\u098c\\u098f\\u0990\\u0993-\\u09a8\\u09aa-\\u09b0\\u09b2\\u09b6-\\u09b9\\u09bd\\u09ce\\u09dc\\u09dd\\u09df-\\u09e1\\u09f0\\u09f1\\u0a05-\\u0a0a\\u0a0f\\u0a10\\u0a13-\\u0a28\\u0a2a-\\u0a30\\u0a32\\u0a33\\u0a35\\u0a36\\u0a38\\u0a39\\u0a59-\\u0a5c\\u0a5e\\u0a72-\\u0a74\\u0a85-\\u0a8d\\u0a8f-\\u0a91\\u0a93-\\u0aa8\\u0aaa-\\u0ab0\\u0ab2\\u0ab3\\u0ab5-\\u0ab9\\u0abd\\u0ad0\\u0ae0\\u0ae1\\u0b05-\\u0b0c\\u0b0f\\u0b10\\u0b13-\\u0b28\\u0b2a-\\u0b30\\u0b32\\u0b33\\u0b35-\\u0b39\\u0b3d\\u0b5c\\u0b5d\\u0b5f-\\u0b61\\u0b71\\u0b83\\u0b85-\\u0b8a\\u0b8e-\\u0b90\\u0b92-\\u0b95\\u0b99\\u0b9a\\u0b9c\\u0b9e\\u0b9f\\u0ba3\\u0ba4\\u0ba8-\\u0baa\\u0bae-\\u0bb9\\u0bd0\\u0c05-\\u0c0c\\u0c0e-\\u0c10\\u0c12-\\u0c28\\u0c2a-\\u0c33\\u0c35-\\u0c39\\u0c3d\\u0c58\\u0c59\\u0c60\\u0c61\\u0c85-\\u0c8c\\u0c8e-\\u0c90\\u0c92-\\u0ca8\\u0caa-\\u0cb3\\u0cb5-\\u0cb9\\u0cbd\\u0cde\\u0ce0\\u0ce1\\u0cf1\\u0cf2\\u0d05-\\u0d0c\\u0d0e-\\u0d10\\u0d12-\\u0d3a\\u0d3d\\u0d4e\\u0d60\\u0d61\\u0d7a-\\u0d7f\\u0d85-\\u0d96\\u0d9a-\\u0db1\\u0db3-\\u0dbb\\u0dbd\\u0dc0-\\u0dc6\\u0e01-\\u0e30\\u0e32\\u0e33\\u0e40-\\u0e46\\u0e81\\u0e82\\u0e84\\u0e87\\u0e88\\u0e8a\\u0e8d\\u0e94-\\u0e97\\u0e99-\\u0e9f\\u0ea1-\\u0ea3\\u0ea5\\u0ea7\\u0eaa\\u0eab\\u0ead-\\u0eb0\\u0eb2\\u0eb3\\u0ebd\\u0ec0-\\u0ec4\\u0ec6\\u0edc-\\u0edf\\u0f00\\u0f40-\\u0f47\\u0f49-\\u0f6c\\u0f88-\\u0f8c\\u1000-\\u102a\\u103f\\u1050-\\u1055\\u105a-\\u105d\\u1061\\u1065\\u1066\\u106e-\\u1070\\u1075-\\u1081\\u108e\\u10a0-\\u10c5\\u10c7\\u10cd\\u10d0-\\u10fa\\u10fc-\\u1248\\u124a-\\u124d\\u1250-\\u1256\\u1258\\u125a-\\u125d\\u1260-\\u1288\\u128a-\\u128d\\u1290-\\u12b0\\u12b2-\\u12b5\\u12b8-\\u12be\\u12c0\\u12c2-\\u12c5\\u12c8-\\u12d6\\u12d8-\\u1310\\u1312-\\u1315\\u1318-\\u135a\\u1380-\\u138f\\u13a0-\\u13f4\\u1401-\\u166c\\u166f-\\u167f\\u1681-\\u169a\\u16a0-\\u16ea\\u16ee-\\u16f0\\u1700-\\u170c\\u170e-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176c\\u176e-\\u1770\\u1780-\\u17b3\\u17d7\\u17dc\\u1820-\\u1877\\u1880-\\u18a8\\u18aa\\u18b0-\\u18f5\\u1900-\\u191c\\u1950-\\u196d\\u1970-\\u1974\\u1980-\\u19ab\\u19c1-\\u19c7\\u1a00-\\u1a16\\u1a20-\\u1a54\\u1aa7\\u1b05-\\u1b33\\u1b45-\\u1b4b\\u1b83-\\u1ba0\\u1bae\\u1baf\\u1bba-\\u1be5\\u1c00-\\u1c23\\u1c4d-\\u1c4f\\u1c5a-\\u1c7d\\u1ce9-\\u1cec\\u1cee-\\u1cf1\\u1cf5\\u1cf6\\u1d00-\\u1dbf\\u1e00-\\u1f15\\u1f18-\\u1f1d\\u1f20-\\u1f45\\u1f48-\\u1f4d\\u1f50-\\u1f57\\u1f59\\u1f5b\\u1f5d\\u1f5f-\\u1f7d\\u1f80-\\u1fb4\\u1fb6-\\u1fbc\\u1fbe\\u1fc2-\\u1fc4\\u1fc6-\\u1fcc\\u1fd0-\\u1fd3\\u1fd6-\\u1fdb\\u1fe0-\\u1fec\\u1ff2-\\u1ff4\\u1ff6-\\u1ffc\\u2071\\u207f\\u2090-\\u209c\\u2102\\u2107\\u210a-\\u2113\\u2115\\u2119-\\u211d\\u2124\\u2126\\u2128\\u212a-\\u212d\\u212f-\\u2139\\u213c-\\u213f\\u2145-\\u2149\\u214e\\u2160-\\u2188\\u2c00-\\u2c2e\\u2c30-\\u2c5e\\u2c60-\\u2ce4\\u2ceb-\\u2cee\\u2cf2\\u2cf3\\u2d00-\\u2d25\\u2d27\\u2d2d\\u2d30-\\u2d67\\u2d6f\\u2d80-\\u2d96\\u2da0-\\u2da6\\u2da8-\\u2dae\\u2db0-\\u2db6\\u2db8-\\u2dbe\\u2dc0-\\u2dc6\\u2dc8-\\u2dce\\u2dd0-\\u2dd6\\u2dd8-\\u2dde\\u2e2f\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303c\\u3041-\\u3096\\u309d-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312d\\u3131-\\u318e\\u31a0-\\u31ba\\u31f0-\\u31ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\ua000-\\ua48c\\ua4d0-\\ua4fd\\ua500-\\ua60c\\ua610-\\ua61f\\ua62a\\ua62b\\ua640-\\ua66e\\ua67f-\\ua697\\ua6a0-\\ua6ef\\ua717-\\ua71f\\ua722-\\ua788\\ua78b-\\ua78e\\ua790-\\ua793\\ua7a0-\\ua7aa\\ua7f8-\\ua801\\ua803-\\ua805\\ua807-\\ua80a\\ua80c-\\ua822\\ua840-\\ua873\\ua882-\\ua8b3\\ua8f2-\\ua8f7\\ua8fb\\ua90a-\\ua925\\ua930-\\ua946\\ua960-\\ua97c\\ua984-\\ua9b2\\ua9cf\\uaa00-\\uaa28\\uaa40-\\uaa42\\uaa44-\\uaa4b\\uaa60-\\uaa76\\uaa7a\\uaa80-\\uaaaf\\uaab1\\uaab5\\uaab6\\uaab9-\\uaabd\\uaac0\\uaac2\\uaadb-\\uaadd\\uaae0-\\uaaea\\uaaf2-\\uaaf4\\uab01-\\uab06\\uab09-\\uab0e\\uab11-\\uab16\\uab20-\\uab26\\uab28-\\uab2e\\uabc0-\\uabe2\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufb00-\\ufb06\\ufb13-\\ufb17\\ufb1d\\ufb1f-\\ufb28\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40\\ufb41\\ufb43\\ufb44\\ufb46-\\ufbb1\\ufbd3-\\ufd3d\\ufd50-\\ufd8f\\ufd92-\\ufdc7\\ufdf0-\\ufdfb\\ufe70-\\ufe74\\ufe76-\\ufefc\\uff21-\\uff3a\\uff41-\\uff5a\\uff66-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc",r="\\u0300-\\u036f\\u0483-\\u0487\\u0591-\\u05bd\\u05bf\\u05c1\\u05c2\\u05c4\\u05c5\\u05c7\\u0610-\\u061a\\u0620-\\u0649\\u0672-\\u06d3\\u06e7-\\u06e8\\u06fb-\\u06fc\\u0730-\\u074a\\u0800-\\u0814\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0840-\\u0857\\u08e4-\\u08fe\\u0900-\\u0903\\u093a-\\u093c\\u093e-\\u094f\\u0951-\\u0957\\u0962-\\u0963\\u0966-\\u096f\\u0981-\\u0983\\u09bc\\u09be-\\u09c4\\u09c7\\u09c8\\u09d7\\u09df-\\u09e0\\u0a01-\\u0a03\\u0a3c\\u0a3e-\\u0a42\\u0a47\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a66-\\u0a71\\u0a75\\u0a81-\\u0a83\\u0abc\\u0abe-\\u0ac5\\u0ac7-\\u0ac9\\u0acb-\\u0acd\\u0ae2-\\u0ae3\\u0ae6-\\u0aef\\u0b01-\\u0b03\\u0b3c\\u0b3e-\\u0b44\\u0b47\\u0b48\\u0b4b-\\u0b4d\\u0b56\\u0b57\\u0b5f-\\u0b60\\u0b66-\\u0b6f\\u0b82\\u0bbe-\\u0bc2\\u0bc6-\\u0bc8\\u0bca-\\u0bcd\\u0bd7\\u0be6-\\u0bef\\u0c01-\\u0c03\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55\\u0c56\\u0c62-\\u0c63\\u0c66-\\u0c6f\\u0c82\\u0c83\\u0cbc\\u0cbe-\\u0cc4\\u0cc6-\\u0cc8\\u0cca-\\u0ccd\\u0cd5\\u0cd6\\u0ce2-\\u0ce3\\u0ce6-\\u0cef\\u0d02\\u0d03\\u0d46-\\u0d48\\u0d57\\u0d62-\\u0d63\\u0d66-\\u0d6f\\u0d82\\u0d83\\u0dca\\u0dcf-\\u0dd4\\u0dd6\\u0dd8-\\u0ddf\\u0df2\\u0df3\\u0e34-\\u0e3a\\u0e40-\\u0e45\\u0e50-\\u0e59\\u0eb4-\\u0eb9\\u0ec8-\\u0ecd\\u0ed0-\\u0ed9\\u0f18\\u0f19\\u0f20-\\u0f29\\u0f35\\u0f37\\u0f39\\u0f41-\\u0f47\\u0f71-\\u0f84\\u0f86-\\u0f87\\u0f8d-\\u0f97\\u0f99-\\u0fbc\\u0fc6\\u1000-\\u1029\\u1040-\\u1049\\u1067-\\u106d\\u1071-\\u1074\\u1082-\\u108d\\u108f-\\u109d\\u135d-\\u135f\\u170e-\\u1710\\u1720-\\u1730\\u1740-\\u1750\\u1772\\u1773\\u1780-\\u17b2\\u17dd\\u17e0-\\u17e9\\u180b-\\u180d\\u1810-\\u1819\\u1920-\\u192b\\u1930-\\u193b\\u1951-\\u196d\\u19b0-\\u19c0\\u19c8-\\u19c9\\u19d0-\\u19d9\\u1a00-\\u1a15\\u1a20-\\u1a53\\u1a60-\\u1a7c\\u1a7f-\\u1a89\\u1a90-\\u1a99\\u1b46-\\u1b4b\\u1b50-\\u1b59\\u1b6b-\\u1b73\\u1bb0-\\u1bb9\\u1be6-\\u1bf3\\u1c00-\\u1c22\\u1c40-\\u1c49\\u1c5b-\\u1c7d\\u1cd0-\\u1cd2\\u1d00-\\u1dbe\\u1e01-\\u1f15\\u200c\\u200d\\u203f\\u2040\\u2054\\u20d0-\\u20dc\\u20e1\\u20e5-\\u20f0\\u2d81-\\u2d96\\u2de0-\\u2dff\\u3021-\\u3028\\u3099\\u309a\\ua640-\\ua66d\\ua674-\\ua67d\\ua69f\\ua6f0-\\ua6f1\\ua7f8-\\ua800\\ua806\\ua80b\\ua823-\\ua827\\ua880-\\ua881\\ua8b4-\\ua8c4\\ua8d0-\\ua8d9\\ua8f3-\\ua8f7\\ua900-\\ua909\\ua926-\\ua92d\\ua930-\\ua945\\ua980-\\ua983\\ua9b3-\\ua9c0\\uaa00-\\uaa27\\uaa40-\\uaa41\\uaa4c-\\uaa4d\\uaa50-\\uaa59\\uaa7b\\uaae0-\\uaae9\\uaaf2-\\uaaf3\\uabc0-\\uabe1\\uabec\\uabed\\uabf0-\\uabf9\\ufb20-\\ufb28\\ufe00-\\ufe0f\\ufe20-\\ufe26\\ufe33\\ufe34\\ufe4d-\\ufe4f\\uff10-\\uff19\\uff3f",n="(?:\\\\u[0-9a-fA-F]{4}|["+p+s+"])",u="(?:\\\\u[0-9a-fA-F]{4}|["+m+s+r+"])*";S.identifier=new RegExp(n+u,"g"),S.identifierStart=new RegExp(n),S.identifierMatch=new RegExp("(?:\\\\u[0-9a-fA-F]{4}|["+m+s+r+"])+");var o=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;S.newline=/[\n\r\u2028\u2029]/,S.lineBreak=new RegExp(`\r
|`+S.newline.source),S.allLineBreaks=new RegExp(S.lineBreak.source,"g")},function(A,S,p){var m=p(6).Options,s=["before-newline","after-newline","preserve-newline"];function r(n){m.call(this,n,"js");var u=this.raw_options.brace_style||null;u==="expand-strict"?this.raw_options.brace_style="expand":u==="collapse-preserve-inline"?this.raw_options.brace_style="collapse,preserve-inline":this.raw_options.braces_on_own_line!==void 0&&(this.raw_options.brace_style=this.raw_options.braces_on_own_line?"expand":"collapse");var o=this._get_selection_list("brace_style",["collapse","expand","end-expand","none","preserve-inline"]);this.brace_preserve_inline=!1,this.brace_style="collapse";for(var t=0;t<o.length;t++)o[t]==="preserve-inline"?this.brace_preserve_inline=!0:this.brace_style=o[t];this.unindent_chained_methods=this._get_boolean("unindent_chained_methods"),this.break_chained_methods=this._get_boolean("break_chained_methods"),this.space_in_paren=this._get_boolean("space_in_paren"),this.space_in_empty_paren=this._get_boolean("space_in_empty_paren"),this.jslint_happy=this._get_boolean("jslint_happy"),this.space_after_anon_function=this._get_boolean("space_after_anon_function"),this.space_after_named_function=this._get_boolean("space_after_named_function"),this.keep_array_indentation=this._get_boolean("keep_array_indentation"),this.space_before_conditional=this._get_boolean("space_before_conditional",!0),this.unescape_strings=this._get_boolean("unescape_strings"),this.e4x=this._get_boolean("e4x"),this.comma_first=this._get_boolean("comma_first"),this.operator_position=this._get_selection("operator_position",s),this.test_output_raw=this._get_boolean("test_output_raw"),this.jslint_happy&&(this.space_after_anon_function=!0)}r.prototype=new m,A.exports.Options=r},function(A){function S(s,r){this.raw_options=p(s,r),this.disabled=this._get_boolean("disabled"),this.eol=this._get_characters("eol","auto"),this.end_with_newline=this._get_boolean("end_with_newline"),this.indent_size=this._get_number("indent_size",4),this.indent_char=this._get_characters("indent_char"," "),this.indent_level=this._get_number("indent_level"),this.preserve_newlines=this._get_boolean("preserve_newlines",!0),this.max_preserve_newlines=this._get_number("max_preserve_newlines",32786),this.preserve_newlines||(this.max_preserve_newlines=0),this.indent_with_tabs=this._get_boolean("indent_with_tabs",this.indent_char===" "),this.indent_with_tabs&&(this.indent_char=" ",this.indent_size===1&&(this.indent_size=4)),this.wrap_line_length=this._get_number("wrap_line_length",this._get_number("max_char")),this.indent_empty_lines=this._get_boolean("indent_empty_lines"),this.templating=this._get_selection_list("templating",["auto","none","django","erb","handlebars","php","smarty"],["auto"])}S.prototype._get_array=function(s,r){var n=this.raw_options[s],u=r||[];return typeof n=="object"?n!==null&&typeof n.concat=="function"&&(u=n.concat()):typeof n=="string"&&(u=n.split(/[^a-zA-Z0-9_\/\-]+/)),u},S.prototype._get_boolean=function(s,r){var n=this.raw_options[s],u=n===void 0?!!r:!!n;return u},S.prototype._get_characters=function(s,r){var n=this.raw_options[s],u=r||"";return typeof n=="string"&&(u=n.replace(/\\r/,"\r").replace(/\\n/,`
`).replace(/\\t/," ")),u},S.prototype._get_number=function(s,r){var n=this.raw_options[s];r=parseInt(r,10),isNaN(r)&&(r=0);var u=parseInt(n,10);return isNaN(u)&&(u=r),u},S.prototype._get_selection=function(s,r,n){var u=this._get_selection_list(s,r,n);if(u.length!==1)throw new Error("Invalid Option Value: The option '"+s+`' can only be one of the following values:
`+r+`
You passed in: '`+this.raw_options[s]+"'");return u[0]},S.prototype._get_selection_list=function(s,r,n){if(!r||r.length===0)throw new Error("Selection list cannot be empty.");if(n=n||[r[0]],!this._is_valid_selection(n,r))throw new Error("Invalid Default Value!");var u=this._get_array(s,n);if(!this._is_valid_selection(u,r))throw new Error("Invalid Option Value: The option '"+s+`' can contain only the following values:
`+r+`
You passed in: '`+this.raw_options[s]+"'");return u},S.prototype._is_valid_selection=function(s,r){return s.length&&r.length&&!s.some(function(n){return r.indexOf(n)===-1})};function p(s,r){var n={};s=m(s);var u;for(u in s)u!==r&&(n[u]=s[u]);if(r&&s[r])for(u in s[r])n[u]=s[r][u];return n}function m(s){var r={},n;for(n in s){var u=n.replace(/-/g,"_");r[u]=s[n]}return r}A.exports.Options=S,A.exports.normalizeOpts=m,A.exports.mergeOpts=p},function(A,S,p){var m=p(8).InputScanner,s=p(9).Tokenizer,r=p(9).TOKEN,n=p(13).Directives,u=p(4),o=p(12).Pattern,t=p(14).TemplatablePattern;function e(C,N){return N.indexOf(C)!==-1}var i={START_EXPR:"TK_START_EXPR",END_EXPR:"TK_END_EXPR",START_BLOCK:"TK_START_BLOCK",END_BLOCK:"TK_END_BLOCK",WORD:"TK_WORD",RESERVED:"TK_RESERVED",SEMICOLON:"TK_SEMICOLON",STRING:"TK_STRING",EQUALS:"TK_EQUALS",OPERATOR:"TK_OPERATOR",COMMA:"TK_COMMA",BLOCK_COMMENT:"TK_BLOCK_COMMENT",COMMENT:"TK_COMMENT",DOT:"TK_DOT",UNKNOWN:"TK_UNKNOWN",START:r.START,RAW:r.RAW,EOF:r.EOF},T=new n(/\/\*/,/\*\//),_=/0[xX][0123456789abcdefABCDEF_]*n?|0[oO][01234567_]*n?|0[bB][01_]*n?|\d[\d_]*n|(?:\.\d[\d_]*|\d[\d_]*\.?[\d_]*)(?:[eE][+-]?[\d_]+)?/,y=/[0-9]/,E=/[^\d\.]/,b=">>> === !== &&= ??= ||= << && >= ** != == <= >> || ?? |> < / - + > : & % ? ^ | *".split(" "),g=">>>= ... >>= <<= === >>> !== **= &&= ??= ||= => ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> = ! ? > < : / ^ - + * & % ~ |";g=g.replace(/[-[\]{}()*+?.,\\^$|#]/g,"\\$&"),g="\\?\\.(?!\\d) "+g,g=g.replace(/ /g,"|");var d=new RegExp(g),a="continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export".split(","),l=a.concat(["do","in","of","else","get","set","new","catch","finally","typeof","yield","async","await","from","as","class","extends"]),f=new RegExp("^(?:"+l.join("|")+")$"),c,x=function(C,N){s.call(this,C,N),this._patterns.whitespace=this._patterns.whitespace.matching(/\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,/\u2028\u2029/.source);var U=new o(this._input),W=new t(this._input).read_options(this._options);this.__patterns={template:W,identifier:W.starting_with(u.identifier).matching(u.identifierMatch),number:U.matching(_),punct:U.matching(d),comment:U.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),block_comment:U.starting_with(/\/\*/).until_after(/\*\//),html_comment_start:U.matching(/<!--/),html_comment_end:U.matching(/-->/),include:U.starting_with(/#include/).until_after(u.lineBreak),shebang:U.starting_with(/#!/).until_after(u.lineBreak),xml:U.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[^}]+?}|!\[CDATA\[[^\]]*?\]\]|)(\s*{[^}]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{([^{}]|{[^}]+?})+?}))*\s*(\/?)\s*>/),single_quote:W.until(/['\\\n\r\u2028\u2029]/),double_quote:W.until(/["\\\n\r\u2028\u2029]/),template_text:W.until(/[`\\$]/),template_expression:W.until(/[`}\\]/)}};x.prototype=new s,x.prototype._is_comment=function(C){return C.type===i.COMMENT||C.type===i.BLOCK_COMMENT||C.type===i.UNKNOWN},x.prototype._is_opening=function(C){return C.type===i.START_BLOCK||C.type===i.START_EXPR},x.prototype._is_closing=function(C,N){return(C.type===i.END_BLOCK||C.type===i.END_EXPR)&&N&&(C.text==="]"&&N.text==="["||C.text===")"&&N.text==="("||C.text==="}"&&N.text==="{")},x.prototype._reset=function(){c=!1},x.prototype._get_next_token=function(C,N){var U=null;this._readWhitespace();var W=this._input.peek();return W===null?this._create_token(i.EOF,""):(U=U||this._read_non_javascript(W),U=U||this._read_string(W),U=U||this._read_word(C),U=U||this._read_singles(W),U=U||this._read_comment(W),U=U||this._read_regexp(W,C),U=U||this._read_xml(W,C),U=U||this._read_punctuation(),U=U||this._create_token(i.UNKNOWN,this._input.next()),U)},x.prototype._read_word=function(C){var N;if(N=this.__patterns.identifier.read(),N!=="")return N=N.replace(u.allLineBreaks,`
`),!(C.type===i.DOT||C.type===i.RESERVED&&(C.text==="set"||C.text==="get"))&&f.test(N)?(N==="in"||N==="of")&&(C.type===i.WORD||C.type===i.STRING)?this._create_token(i.OPERATOR,N):this._create_token(i.RESERVED,N):this._create_token(i.WORD,N);if(N=this.__patterns.number.read(),N!=="")return this._create_token(i.WORD,N)},x.prototype._read_singles=function(C){var N=null;return C==="("||C==="["?N=this._create_token(i.START_EXPR,C):C===")"||C==="]"?N=this._create_token(i.END_EXPR,C):C==="{"?N=this._create_token(i.START_BLOCK,C):C==="}"?N=this._create_token(i.END_BLOCK,C):C===";"?N=this._create_token(i.SEMICOLON,C):C==="."&&E.test(this._input.peek(1))?N=this._create_token(i.DOT,C):C===","&&(N=this._create_token(i.COMMA,C)),N&&this._input.next(),N},x.prototype._read_punctuation=function(){var C=this.__patterns.punct.read();if(C!=="")return C==="="?this._create_token(i.EQUALS,C):C==="?."?this._create_token(i.DOT,C):this._create_token(i.OPERATOR,C)},x.prototype._read_non_javascript=function(C){var N="";if(C==="#"){if(this._is_first_token()&&(N=this.__patterns.shebang.read(),N))return this._create_token(i.UNKNOWN,N.trim()+`
`);if(N=this.__patterns.include.read(),N)return this._create_token(i.UNKNOWN,N.trim()+`
`);C=this._input.next();var U="#";if(this._input.hasNext()&&this._input.testChar(y)){do C=this._input.next(),U+=C;while(this._input.hasNext()&&C!=="#"&&C!=="=");return C==="#"||(this._input.peek()==="["&&this._input.peek(1)==="]"?(U+="[]",this._input.next(),this._input.next()):this._input.peek()==="{"&&this._input.peek(1)==="}"&&(U+="{}",this._input.next(),this._input.next())),this._create_token(i.WORD,U)}this._input.back()}else if(C==="<"&&this._is_first_token()){if(N=this.__patterns.html_comment_start.read(),N){for(;this._input.hasNext()&&!this._input.testChar(u.newline);)N+=this._input.next();return c=!0,this._create_token(i.COMMENT,N)}}else if(c&&C==="-"&&(N=this.__patterns.html_comment_end.read(),N))return c=!1,this._create_token(i.COMMENT,N);return null},x.prototype._read_comment=function(C){var N=null;if(C==="/"){var U="";if(this._input.peek(1)==="*"){U=this.__patterns.block_comment.read();var W=T.get_directives(U);W&&W.ignore==="start"&&(U+=T.readIgnored(this._input)),U=U.replace(u.allLineBreaks,`
`),N=this._create_token(i.BLOCK_COMMENT,U),N.directives=W}else this._input.peek(1)==="/"&&(U=this.__patterns.comment.read(),N=this._create_token(i.COMMENT,U))}return N},x.prototype._read_string=function(C){if(C==="`"||C==="'"||C==='"'){var N=this._input.next();return this.has_char_escapes=!1,C==="`"?N+=this._read_string_recursive("`",!0,"${"):N+=this._read_string_recursive(C),this.has_char_escapes&&this._options.unescape_strings&&(N=R(N)),this._input.peek()===C&&(N+=this._input.next()),N=N.replace(u.allLineBreaks,`
`),this._create_token(i.STRING,N)}return null},x.prototype._allow_regexp_or_xml=function(C){return C.type===i.RESERVED&&e(C.text,["return","case","throw","else","do","typeof","yield"])||C.type===i.END_EXPR&&C.text===")"&&C.opened.previous.type===i.RESERVED&&e(C.opened.previous.text,["if","while","for"])||e(C.type,[i.COMMENT,i.START_EXPR,i.START_BLOCK,i.START,i.END_BLOCK,i.OPERATOR,i.EQUALS,i.EOF,i.SEMICOLON,i.COMMA])},x.prototype._read_regexp=function(C,N){if(C==="/"&&this._allow_regexp_or_xml(N)){for(var U=this._input.next(),W=!1,L=!1;this._input.hasNext()&&(W||L||this._input.peek()!==C)&&!this._input.testChar(u.newline);)U+=this._input.peek(),W?W=!1:(W=this._input.peek()==="\\",this._input.peek()==="["?L=!0:this._input.peek()==="]"&&(L=!1)),this._input.next();return this._input.peek()===C&&(U+=this._input.next(),U+=this._input.read(u.identifier)),this._create_token(i.STRING,U)}return null},x.prototype._read_xml=function(C,N){if(this._options.e4x&&C==="<"&&this._allow_regexp_or_xml(N)){var U="",W=this.__patterns.xml.read_match();if(W){for(var L=W[2].replace(/^{\s+/,"{").replace(/\s+}$/,"}"),H=L.indexOf("{")===0,K=0;W;){var $=!!W[1],Q=W[2],ue=!!W[W.length-1]||Q.slice(0,8)==="![CDATA[";if(!ue&&(Q===L||H&&Q.replace(/^{\s+/,"{").replace(/\s+}$/,"}"))&&($?--K:++K),U+=W[0],K<=0)break;W=this.__patterns.xml.read_match()}return W||(U+=this._input.match(/[\s\S]*/g)[0]),U=U.replace(u.allLineBreaks,`
`),this._create_token(i.STRING,U)}}return null};function R(C){for(var N="",U=0,W=new m(C),L=null;W.hasNext();)if(L=W.match(/([\s]|[^\\]|\\\\)+/g),L&&(N+=L[0]),W.peek()==="\\"){if(W.next(),W.peek()==="x")L=W.match(/x([0-9A-Fa-f]{2})/g);else if(W.peek()==="u")L=W.match(/u([0-9A-Fa-f]{4})/g);else{N+="\\",W.hasNext()&&(N+=W.next());continue}if(!L)return C;if(U=parseInt(L[1],16),U>126&&U<=255&&L[0].indexOf("x")===0)return C;if(U>=0&&U<32){N+="\\"+L[0];continue}else U===34||U===39||U===92?N+="\\"+String.fromCharCode(U):N+=String.fromCharCode(U)}return N}x.prototype._read_string_recursive=function(C,N,U){var W,L;C==="'"?L=this.__patterns.single_quote:C==='"'?L=this.__patterns.double_quote:C==="`"?L=this.__patterns.template_text:C==="}"&&(L=this.__patterns.template_expression);for(var H=L.read(),K="";this._input.hasNext();){if(K=this._input.next(),K===C||!N&&u.newline.test(K)){this._input.back();break}else K==="\\"&&this._input.hasNext()?(W=this._input.peek(),W==="x"||W==="u"?this.has_char_escapes=!0:W==="\r"&&this._input.peek(1)===`
`&&this._input.next(),K+=this._input.next()):U&&(U==="${"&&K==="$"&&this._input.peek()==="{"&&(K+=this._input.next()),U===K&&(C==="`"?K+=this._read_string_recursive("}",N,"`"):K+=this._read_string_recursive("`",N,"${"),this._input.hasNext()&&(K+=this._input.next())));K+=L.read(),H+=K}return H},A.exports.Tokenizer=x,A.exports.TOKEN=i,A.exports.positionable_operators=b.slice(),A.exports.line_starters=a.slice()},function(A){var S=RegExp.prototype.hasOwnProperty("sticky");function p(m){this.__input=m||"",this.__input_length=this.__input.length,this.__position=0}p.prototype.restart=function(){this.__position=0},p.prototype.back=function(){this.__position>0&&(this.__position-=1)},p.prototype.hasNext=function(){return this.__position<this.__input_length},p.prototype.next=function(){var m=null;return this.hasNext()&&(m=this.__input.charAt(this.__position),this.__position+=1),m},p.prototype.peek=function(m){var s=null;return m=m||0,m+=this.__position,m>=0&&m<this.__input_length&&(s=this.__input.charAt(m)),s},p.prototype.__match=function(m,s){m.lastIndex=s;var r=m.exec(this.__input);return r&&!(S&&m.sticky)&&(r.index!==s&&(r=null)),r},p.prototype.test=function(m,s){return s=s||0,s+=this.__position,s>=0&&s<this.__input_length?!!this.__match(m,s):!1},p.prototype.testChar=function(m,s){var r=this.peek(s);return m.lastIndex=0,r!==null&&m.test(r)},p.prototype.match=function(m){var s=this.__match(m,this.__position);return s?this.__position+=s[0].length:s=null,s},p.prototype.read=function(m,s,r){var n="",u;return m&&(u=this.match(m),u&&(n+=u[0])),s&&(u||!m)&&(n+=this.readUntil(s,r)),n},p.prototype.readUntil=function(m,s){var r="",n=this.__position;m.lastIndex=this.__position;var u=m.exec(this.__input);return u?(n=u.index,s&&(n+=u[0].length)):n=this.__input_length,r=this.__input.substring(this.__position,n),this.__position=n,r},p.prototype.readUntilAfter=function(m){return this.readUntil(m,!0)},p.prototype.get_regexp=function(m,s){var r=null,n="g";return s&&S&&(n="y"),typeof m=="string"&&m!==""?r=new RegExp(m,n):m&&(r=new RegExp(m.source,n)),r},p.prototype.get_literal_regexp=function(m){return RegExp(m.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"))},p.prototype.peekUntilAfter=function(m){var s=this.__position,r=this.readUntilAfter(m);return this.__position=s,r},p.prototype.lookBack=function(m){var s=this.__position-1;return s>=m.length&&this.__input.substring(s-m.length,s).toLowerCase()===m},A.exports.InputScanner=p},function(A,S,p){var m=p(8).InputScanner,s=p(3).Token,r=p(10).TokenStream,n=p(11).WhitespacePattern,u={START:"TK_START",RAW:"TK_RAW",EOF:"TK_EOF"},o=function(t,e){this._input=new m(t),this._options=e||{},this.__tokens=null,this._patterns={},this._patterns.whitespace=new n(this._input)};o.prototype.tokenize=function(){this._input.restart(),this.__tokens=new r,this._reset();for(var t,e=new s(u.START,""),i=null,T=[],_=new r;e.type!==u.EOF;){for(t=this._get_next_token(e,i);this._is_comment(t);)_.add(t),t=this._get_next_token(e,i);_.isEmpty()||(t.comments_before=_,_=new r),t.parent=i,this._is_opening(t)?(T.push(i),i=t):i&&this._is_closing(t,i)&&(t.opened=i,i.closed=t,i=T.pop(),t.parent=i),t.previous=e,e.next=t,this.__tokens.add(t),e=t}return this.__tokens},o.prototype._is_first_token=function(){return this.__tokens.isEmpty()},o.prototype._reset=function(){},o.prototype._get_next_token=function(t,e){this._readWhitespace();var i=this._input.read(/.+/g);return i?this._create_token(u.RAW,i):this._create_token(u.EOF,"")},o.prototype._is_comment=function(t){return!1},o.prototype._is_opening=function(t){return!1},o.prototype._is_closing=function(t,e){return!1},o.prototype._create_token=function(t,e){var i=new s(t,e,this._patterns.whitespace.newline_count,this._patterns.whitespace.whitespace_before_token);return i},o.prototype._readWhitespace=function(){return this._patterns.whitespace.read()},A.exports.Tokenizer=o,A.exports.TOKEN=u},function(A){function S(p){this.__tokens=[],this.__tokens_length=this.__tokens.length,this.__position=0,this.__parent_token=p}S.prototype.restart=function(){this.__position=0},S.prototype.isEmpty=function(){return this.__tokens_length===0},S.prototype.hasNext=function(){return this.__position<this.__tokens_length},S.prototype.next=function(){var p=null;return this.hasNext()&&(p=this.__tokens[this.__position],this.__position+=1),p},S.prototype.peek=function(p){var m=null;return p=p||0,p+=this.__position,p>=0&&p<this.__tokens_length&&(m=this.__tokens[p]),m},S.prototype.add=function(p){this.__parent_token&&(p.parent=this.__parent_token),this.__tokens.push(p),this.__tokens_length+=1},A.exports.TokenStream=S},function(A,S,p){var m=p(12).Pattern;function s(r,n){m.call(this,r,n),n?this._line_regexp=this._input.get_regexp(n._line_regexp):this.__set_whitespace_patterns("",""),this.newline_count=0,this.whitespace_before_token=""}s.prototype=new m,s.prototype.__set_whitespace_patterns=function(r,n){r+="\\t ",n+="\\n\\r",this._match_pattern=this._input.get_regexp("["+r+n+"]+",!0),this._newline_regexp=this._input.get_regexp("\\r\\n|["+n+"]")},s.prototype.read=function(){this.newline_count=0,this.whitespace_before_token="";var r=this._input.read(this._match_pattern);if(r===" ")this.whitespace_before_token=" ";else if(r){var n=this.__split(this._newline_regexp,r);this.newline_count=n.length-1,this.whitespace_before_token=n[this.newline_count]}return r},s.prototype.matching=function(r,n){var u=this._create();return u.__set_whitespace_patterns(r,n),u._update(),u},s.prototype._create=function(){return new s(this._input,this)},s.prototype.__split=function(r,n){r.lastIndex=0;for(var u=0,o=[],t=r.exec(n);t;)o.push(n.substring(u,t.index)),u=t.index+t[0].length,t=r.exec(n);return u<n.length?o.push(n.substring(u,n.length)):o.push(""),o},A.exports.WhitespacePattern=s},function(A){function S(p,m){this._input=p,this._starting_pattern=null,this._match_pattern=null,this._until_pattern=null,this._until_after=!1,m&&(this._starting_pattern=this._input.get_regexp(m._starting_pattern,!0),this._match_pattern=this._input.get_regexp(m._match_pattern,!0),this._until_pattern=this._input.get_regexp(m._until_pattern),this._until_after=m._until_after)}S.prototype.read=function(){var p=this._input.read(this._starting_pattern);return(!this._starting_pattern||p)&&(p+=this._input.read(this._match_pattern,this._until_pattern,this._until_after)),p},S.prototype.read_match=function(){return this._input.match(this._match_pattern)},S.prototype.until_after=function(p){var m=this._create();return m._until_after=!0,m._until_pattern=this._input.get_regexp(p),m._update(),m},S.prototype.until=function(p){var m=this._create();return m._until_after=!1,m._until_pattern=this._input.get_regexp(p),m._update(),m},S.prototype.starting_with=function(p){var m=this._create();return m._starting_pattern=this._input.get_regexp(p,!0),m._update(),m},S.prototype.matching=function(p){var m=this._create();return m._match_pattern=this._input.get_regexp(p,!0),m._update(),m},S.prototype._create=function(){return new S(this._input,this)},S.prototype._update=function(){},A.exports.Pattern=S},function(A){function S(p,m){p=typeof p=="string"?p:p.source,m=typeof m=="string"?m:m.source,this.__directives_block_pattern=new RegExp(p+/ beautify( \w+[:]\w+)+ /.source+m,"g"),this.__directive_pattern=/ (\w+)[:](\w+)/g,this.__directives_end_ignore_pattern=new RegExp(p+/\sbeautify\signore:end\s/.source+m,"g")}S.prototype.get_directives=function(p){if(!p.match(this.__directives_block_pattern))return null;var m={};this.__directive_pattern.lastIndex=0;for(var s=this.__directive_pattern.exec(p);s;)m[s[1]]=s[2],s=this.__directive_pattern.exec(p);return m},S.prototype.readIgnored=function(p){return p.readUntilAfter(this.__directives_end_ignore_pattern)},A.exports.Directives=S},function(A,S,p){var m=p(12).Pattern,s={django:!1,erb:!1,handlebars:!1,php:!1,smarty:!1};function r(n,u){m.call(this,n,u),this.__template_pattern=null,this._disabled=Object.assign({},s),this._excluded=Object.assign({},s),u&&(this.__template_pattern=this._input.get_regexp(u.__template_pattern),this._excluded=Object.assign(this._excluded,u._excluded),this._disabled=Object.assign(this._disabled,u._disabled));var o=new m(n);this.__patterns={handlebars_comment:o.starting_with(/{{!--/).until_after(/--}}/),handlebars_unescaped:o.starting_with(/{{{/).until_after(/}}}/),handlebars:o.starting_with(/{{/).until_after(/}}/),php:o.starting_with(/<\?(?:[= ]|php)/).until_after(/\?>/),erb:o.starting_with(/<%[^%]/).until_after(/[^%]%>/),django:o.starting_with(/{%/).until_after(/%}/),django_value:o.starting_with(/{{/).until_after(/}}/),django_comment:o.starting_with(/{#/).until_after(/#}/),smarty:o.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),smarty_comment:o.starting_with(/{\*/).until_after(/\*}/),smarty_literal:o.starting_with(/{literal}/).until_after(/{\/literal}/)}}r.prototype=new m,r.prototype._create=function(){return new r(this._input,this)},r.prototype._update=function(){this.__set_templated_pattern()},r.prototype.disable=function(n){var u=this._create();return u._disabled[n]=!0,u._update(),u},r.prototype.read_options=function(n){var u=this._create();for(var o in s)u._disabled[o]=n.templating.indexOf(o)===-1;return u._update(),u},r.prototype.exclude=function(n){var u=this._create();return u._excluded[n]=!0,u._update(),u},r.prototype.read=function(){var n="";this._match_pattern?n=this._input.read(this._starting_pattern):n=this._input.read(this._starting_pattern,this.__template_pattern);for(var u=this._read_template();u;)this._match_pattern?u+=this._input.read(this._match_pattern):u+=this._input.readUntil(this.__template_pattern),n+=u,u=this._read_template();return this._until_after&&(n+=this._input.readUntilAfter(this._until_pattern)),n},r.prototype.__set_templated_pattern=function(){var n=[];this._disabled.php||n.push(this.__patterns.php._starting_pattern.source),this._disabled.handlebars||n.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.erb||n.push(this.__patterns.erb._starting_pattern.source),this._disabled.django||(n.push(this.__patterns.django._starting_pattern.source),n.push(this.__patterns.django_value._starting_pattern.source),n.push(this.__patterns.django_comment._starting_pattern.source)),this._disabled.smarty||n.push(this.__patterns.smarty._starting_pattern.source),this._until_pattern&&n.push(this._until_pattern.source),this.__template_pattern=this._input.get_regexp("(?:"+n.join("|")+")")},r.prototype._read_template=function(){var n="",u=this._input.peek();if(u==="<"){var o=this._input.peek(1);!this._disabled.php&&!this._excluded.php&&o==="?"&&(n=n||this.__patterns.php.read()),!this._disabled.erb&&!this._excluded.erb&&o==="%"&&(n=n||this.__patterns.erb.read())}else u==="{"&&(!this._disabled.handlebars&&!this._excluded.handlebars&&(n=n||this.__patterns.handlebars_comment.read(),n=n||this.__patterns.handlebars_unescaped.read(),n=n||this.__patterns.handlebars.read()),this._disabled.django||(!this._excluded.django&&!this._excluded.handlebars&&(n=n||this.__patterns.django_value.read()),this._excluded.django||(n=n||this.__patterns.django_comment.read(),n=n||this.__patterns.django.read())),this._disabled.smarty||this._disabled.django&&this._disabled.handlebars&&(n=n||this.__patterns.smarty_comment.read(),n=n||this.__patterns.smarty_literal.read(),n=n||this.__patterns.smarty.read()));return n},A.exports.TemplatablePattern=r}],O={};function B(A){var S=O[A];if(S!==void 0)return S.exports;var p=O[A]={exports:{}};return I[A](p,p.exports,B),p.exports}var M=B(0);w=M})();var j=w;!(he=[],G=function(){return{js_beautify:j}}.apply(Ve,he),G!==void 0&&(Je.exports=G))})()},"8hTe":function(Je,Ve,ee){Je.exports={button:"button___1wy9m"}},"9Bee":function(Je,Ve,ee){"use strict";var he=ee("DYRE"),G=ee("zeV3"),w=ee("+L6B"),j=ee("2/Rp"),I=ee("k1fw"),O=ee("9og8"),B=ee("tJVT"),M=ee("WmNS"),A=ee.n(M),S=ee("q1tI"),p=ee.n(S),m=ee("vg9a"),s=ee("DlQD"),r=ee.n(s),n=ee("rUJ1");function u(k,h){var v=k.match(/^(\s+)(?:```)/);if(v===null)return h;var D=v[1];return h.split(`
`).map(function(F){var P=F.match(/^\s+/);if(P===null)return F;var Z=Object(B.a)(P,1),ge=Z[0];return ge.length>=D.length?F.slice(D.length):F}).join(`
`)}var o=[],t=["<ul>"],e=new r.a.Renderer,i=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function T(){o.length=0,t=["<ul>"]}var _={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function y(k,h,v,D){if(h>=k.length||k[h].level<=v)return h;var F=k[h];D.push("<li><a href='#"+F.anchor+"'>"+F.text+"</a>"),h++;var P=[];return h=y(k,h,F.level,P),P.length>0&&(D.push("<ul>"),P.forEach(function(Z){D.push(Z)}),D.push("</ul>")),D.push("</li>"),h=y(k,h,v,D),h}function E(){return y(o,0,0,t),t.push("</ul>"),t.join("")}var b={heading:function(h){var v=i.exec(h);if(v)return{type:"heading",raw:v[0],depth:v[1].length,text:v[2]}},fences:function(h){var v=this.rules.block.fences.exec(h);if(v){var D=v[0],F=u(D,v[3]||""),P=v[2]?v[2].trim():v[2];if(["latex","katex","math"].indexOf(P)>=0){var Z=a(),ge=F;F=Z,l[Z]={type:"block",expression:ge}}return{type:"code",raw:D,lang:P,text:F}}}},g=/(?:\${2})([^\n`]+?)(?:\${2})/gi,d=0,a=function(){return"__special_katext_id_".concat(d++,"__")},l={};function f(){return l}function c(){d=0,l={}}function x(k){return k=k.replace(g,function(h,v){var D=a();return l[D]={type:"inline",expression:v},D}),k}var R=e.listitem;e.listitem=function(k){return R(x(k))};var C=e.paragraph;e.paragraph=function(k){return C(x(k))};var N=e.tablecell;e.tablecell=function(k,h){return N(x(k),h)},e.code=function(k,h,v){var D=(h||"").match(/\S*/)[0];return D?["latex","katex","math"].indexOf(D)>=0?"<p class='editormd-tex'>".concat(k,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(h,'">').concat(v?k:Object(n.escape)(k,!0),`</code></pre>
`):'<pre class="prettyprint linenums"><code>'+(v?k:Object(n.escape)(k,!0))+"</code></pre>"},e.heading=function(k,h,v){var D=this.options.headerPrefix+v.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return o.push({anchor:D,level:h,text:k}),"<h"+h+' id="'+D+'">'+k+"</h"+h+">"},r.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),r.a.use({tokenizer:b,renderer:e});var U=r.a,W=ee("SJMd"),L=ee("ulZh"),H=ee.n(L),K=ee("m3rI"),$=ee("Oy/b"),Q=ee("p5ED"),ue=ee("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 ne=function(k,h){return(ne=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,D){v.__proto__=D}||function(v,D){for(var F in D)Object.prototype.hasOwnProperty.call(D,F)&&(v[F]=D[F])})(k,h)};function se(k,h){function v(){this.constructor=k}ne(k,h),k.prototype=h===null?Object.create(h):(v.prototype=h.prototype,new v)}function le(k,h,v,D){return new(v||(v=Promise))(function(F,P){function Z(Ge){try{De(D.next(Ge))}catch(ye){P(ye)}}function ge(Ge){try{De(D.throw(Ge))}catch(ye){P(ye)}}function De(Ge){var ye;Ge.done?F(Ge.value):(ye=Ge.value,ye instanceof v?ye:new v(function(Ye){Ye(ye)})).then(Z,ge)}De((D=D.apply(k,h||[])).next())})}function de(k,h){var v,D,F,P,Z={label:0,sent:function(){if(1&F[0])throw F[1];return F[1]},trys:[],ops:[]};return P={next:ge(0),throw:ge(1),return:ge(2)},typeof Symbol=="function"&&(P[Symbol.iterator]=function(){return this}),P;function ge(De){return function(Ge){return function(ye){if(v)throw new TypeError("Generator is already executing.");for(;Z;)try{if(v=1,D&&(F=2&ye[0]?D.return:ye[0]?D.throw||((F=D.return)&&F.call(D),0):D.next)&&!(F=F.call(D,ye[1])).done)return F;switch(D=0,F&&(ye=[2&ye[0],F.value]),ye[0]){case 0:case 1:F=ye;break;case 4:return Z.label++,{value:ye[1],done:!1};case 5:Z.label++,D=ye[1],ye=[0];continue;case 7:ye=Z.ops.pop(),Z.trys.pop();continue;default:if(!(F=Z.trys,(F=F.length>0&&F[F.length-1])||ye[0]!==6&&ye[0]!==2)){Z=0;continue}if(ye[0]===3&&(!F||ye[1]>F[0]&&ye[1]<F[3])){Z.label=ye[1];break}if(ye[0]===6&&Z.label<F[1]){Z.label=F[1],F=ye;break}if(F&&Z.label<F[2]){Z.label=F[2],Z.ops.push(ye);break}F[2]&&Z.ops.pop(),Z.trys.pop();continue}ye=h.call(k,Z)}catch(Ye){ye=[6,Ye],D=0}finally{v=F=0}if(5&ye[0])throw ye[1];return{value:ye[0]?ye[1]:void 0,done:!0}}([De,Ge])}}}function re(){for(var k=0,h=0,v=arguments.length;h<v;h++)k+=arguments[h].length;var D=Array(k),F=0;for(h=0;h<v;h++)for(var P=arguments[h],Z=0,ge=P.length;Z<ge;Z++,F++)D[F]=P[Z];return D}var Y=function(){function k(){}return k.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},k.setAttributes=function(h,v){for(var D=0,F=v;D<F.length;D++){var P=F[D],Z=P[0],ge=P[1];h.setAttribute(Z,ge)}},k.createRect=function(h,v,D){var F=document.createElementNS("http://www.w3.org/2000/svg","rect");return F.setAttribute("width",h.toString()),F.setAttribute("height",v.toString()),D&&k.setAttributes(F,D),F},k.createLine=function(h,v,D,F,P){var Z=document.createElementNS("http://www.w3.org/2000/svg","line");return Z.setAttribute("x1",h.toString()),Z.setAttribute("y1",v.toString()),Z.setAttribute("x2",D.toString()),Z.setAttribute("y2",F.toString()),P&&k.setAttributes(Z,P),Z},k.createPolygon=function(h,v){var D=document.createElementNS("http://www.w3.org/2000/svg","polygon");return D.setAttribute("points",h),v&&k.setAttributes(D,v),D},k.createCircle=function(h,v){var D=document.createElementNS("http://www.w3.org/2000/svg","circle");return D.setAttribute("cx",(h/2).toString()),D.setAttribute("cy",(h/2).toString()),D.setAttribute("r",h.toString()),v&&k.setAttributes(D,v),D},k.createEllipse=function(h,v,D){var F=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return F.setAttribute("cx",(h/2).toString()),F.setAttribute("cy",(v/2).toString()),F.setAttribute("rx",(h/2).toString()),F.setAttribute("ry",(v/2).toString()),D&&k.setAttributes(F,D),F},k.createGroup=function(h){var v=document.createElementNS("http://www.w3.org/2000/svg","g");return h&&k.setAttributes(v,h),v},k.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},k.createMarker=function(h,v,D,F,P,Z,ge){var De=document.createElementNS("http://www.w3.org/2000/svg","marker");return k.setAttributes(De,[["id",h],["orient",v],["markerWidth",D.toString()],["markerHeight",F.toString()],["refX",P.toString()],["refY",Z.toString()]]),De.appendChild(ge),De},k.createText=function(h){var v=document.createElementNS("http://www.w3.org/2000/svg","text");return v.setAttribute("x","0"),v.setAttribute("y","0"),h&&k.setAttributes(v,h),v},k.createTSpan=function(h,v){var D=document.createElementNS("http://www.w3.org/2000/svg","tspan");return D.textContent=h,v&&k.setAttributes(D,v),D},k.createImage=function(h){var v=document.createElementNS("http://www.w3.org/2000/svg","image");return h&&k.setAttributes(v,h),v},k.createPoint=function(h,v){var D=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return D.x=h,D.y=v,D},k.createPath=function(h,v){var D=document.createElementNS("http://www.w3.org/2000/svg","path");return D.setAttribute("d",h),v&&k.setAttributes(D,v),D},k}(),pe=function(){function k(){}return k.addKey=function(h){k.key=h},Object.defineProperty(k,"isLicensed",{get:function(){return!!k.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(k.key)},enumerable:!1,configurable:!0}),k}(),Te=function(){function k(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return k.prototype.rasterize=function(h,v,D){var F=this;return new Promise(function(P){var Z=D!==void 0?D:document.createElement("canvas");h===null&&(F.markersOnly=!0,F.naturalSize=!1);var ge=document.createElementNS("http://www.w3.org/2000/svg","svg");ge.setAttribute("xmlns","http://www.w3.org/2000/svg"),ge.setAttribute("width",v.width.baseVal.valueAsString),ge.setAttribute("height",v.height.baseVal.valueAsString),ge.setAttribute("viewBox","0 0 "+v.viewBox.baseVal.width.toString()+" "+v.viewBox.baseVal.height.toString()),ge.innerHTML=v.innerHTML,F.naturalSize===!0?(ge.width.baseVal.value=h.naturalWidth,ge.height.baseVal.value=h.naturalHeight):F.width!==void 0&&F.height!==void 0&&(ge.width.baseVal.value=F.width,ge.height.baseVal.value=F.height),Z.width=ge.width.baseVal.value,Z.height=ge.height.baseVal.value;var De=ge.outerHTML,Ge=Z.getContext("2d");F.markersOnly!==!0&&Ge.drawImage(h,0,0,Z.width,Z.height);var ye=window.URL,Ye=new Image(Z.width,Z.height);Ye.setAttribute("crossOrigin","anonymous");var it=new Blob([De],{type:"image/svg+xml"}),at=ye.createObjectURL(it);Ye.onload=function(){Ge.drawImage(Ye,0,0),ye.revokeObjectURL(at);var yt=Z.toDataURL(F.imageType,F.imageQuality);P(yt)},Ye.src=at})},k}(),xe=function(){},Se=function(){function k(h){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+h+"_"}return Object.defineProperty(k.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(k.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(k.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),k.prototype.addClass=function(h){return this.styleSheet===void 0&&this.addStyleSheet(),h.name=""+this.classNamePrefix+h.localName,this.classes.push(h),this.styleSheet.sheet.insertRule("."+h.name+" {"+h.style+"}",this.styleSheet.sheet.cssRules.length),h},k.prototype.addRule=function(h){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(h),this.styleSheet.sheet.insertRule(h.selector+" {"+h.style+"}",this.styleSheet.sheet.cssRules.length)},k.prototype.addStyleSheet=function(){var h;this.styleSheet=document.createElement("style"),((h=this.styleSheetRoot)!==null&&h!==void 0?h:document.head).appendChild(this.styleSheet),this.addRule(new Ae("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new Ae("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new Ae("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new fe("fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new fe("fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},k.prototype.removeStyleSheet=function(){var h;this.styleSheet&&(((h=this.styleSheetRoot)!==null&&h!==void 0?h:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},k}(),Ae=function(k,h){this.selector=k,this.style=h},fe=function(k,h){this.localName=k,this.style=h},ve=function(){function k(h,v,D,F,P){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=h,this.displayMode=v,this.markerItems=D,this.uiStyleSettings=F,this.styles=P,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return k.prototype.show=function(h){var v=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=h,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(P){var Z=document.createElement("div");Z.className=""+v.toolbarButtonStyleClass.name,Z.setAttribute("data-type-name",P.typeName),Z.innerHTML=P.icon,Z.addEventListener("click",function(){v.markerToolbarButtonClicked(Z,P)}),v.buttons.push(Z),v.markerButtons.push(Z)}),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 F=document.createElement("div");F.className=this.toolbarBlockStyleClass.name,F.style.whiteSpace="nowrap",F.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(F),this.addActionButton(F,'<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(F,'<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()},k.prototype.addButtonClickListener=function(h){this.buttonClickListeners.push(h)},k.prototype.removeButtonClickListener=function(h){this.buttonClickListeners.indexOf(h)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(h),1)},k.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},k.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var h=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var v=0;v<this.markerButtons.length;v++)v<h||v===h&&this.markerButtons.length-1===h?this.markerButtonBlock.appendChild(this.markerButtons[v]):(v===h&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[v]))}},k.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")},k.prototype.resetButtonStyles=function(){var h=this;this.buttons.forEach(function(v){v.className=v.className.replace(h.uiStyleSettings.toolbarButtonStyleColorsClassName?h.uiStyleSettings.toolbarButtonStyleColorsClassName:h.toolbarButtonStyleColorsClass.name,"").trim(),v.className=v.className.replace(h.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?h.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:h.toolbarActiveButtonStyleColorsClass.name,"").trim(),v.className+=" "+(h.uiStyleSettings.toolbarButtonStyleColorsClassName?h.uiStyleSettings.toolbarButtonStyleColorsClassName:h.toolbarButtonStyleColorsClass.name)})},k.prototype.addActionButton=function(h,v,D){var F=this,P=document.createElement("div");switch(P.className=""+this.toolbarButtonStyleClass.name,P.innerHTML=v,P.setAttribute("data-action",D),P.addEventListener("click",function(){F.actionToolbarButtonClicked(P,D)}),D){case"select":P.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":P.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":P.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":P.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":P.style.fill=this.uiStyleSettings.closeButtonColor}h.appendChild(P),this.buttons.push(P)},k.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new fe("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 fe("toolbar_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
`)),this.toolbarBlockStyleClass=this.styles.addClass(new fe("toolbar-block",`
display: inline-block;
box-sizing: content-box;
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new fe("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 fe("toolbar-overflow-block_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`));var h=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new fe("toolbar_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*h)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*h)+`px;
padding: `+h+`px;
box-sizing: content-box;
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new fe("toolbar_button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new fe("toolbar_active_button",`
fill: `+this.uiStyleSettings.toolbarColor+`;
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new Ae("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`)),this.styles.addRule(new Ae("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`))},k.prototype.markerToolbarButtonClicked=function(h,v){this.setActiveButton(h),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(D){return D("marker",v)}),this.markerButtonOverflowBlock.style.display="none"},k.prototype.actionToolbarButtonClicked=function(h,v){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(D){return D("action",v)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},k.prototype.setActiveButton=function(h){this.resetButtonStyles(),h.className=h.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),h.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},k.prototype.setActiveMarkerButton=function(h){var v=this.markerButtons.find(function(D){return D.getAttribute("data-type-name")===h});v&&this.setActiveButton(v)},k.prototype.setCurrentMarker=function(h){var v=this;this.currentMarker=h,this.buttons.filter(function(D){return/delete|notes/.test(D.getAttribute("data-action"))}).forEach(function(D){v.currentMarker===void 0?(D.style.fillOpacity="0.4",D.style.pointerEvents="none"):(D.style.fillOpacity="1",D.style.pointerEvents="all")})},k}(),Ce=function(){function k(h,v,D,F){this.panels=[],this.panelButtons=[],this.markerjsContainer=h,this.displayMode=v,this.uiStyleSettings=D,this.styles=F,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return k.prototype.addStyles=function(){var h;this.toolboxStyleClass=this.styles.addClass(new fe("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 fe("toolbox_colors",`
color: `+this.uiStyleSettings.toolboxColor+`;
`));var v=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new fe("toolbox-button-row",`
display: flex;
cursor: default;
box-sizing: content-box;
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new fe("toolbox-button-row_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new fe("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 fe("toolbox-panel-row_colors",`
background-color: `+((h=this.uiStyleSettings.toolboxBackgroundColor)!==null&&h!==void 0?h:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
`)),this.toolboxButtonStyleClass=this.styles.addClass(new fe("toolbox_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*v)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*v)+`px;
padding: `+v+`px;
box-sizing: content-box;
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new fe("toolbox-button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new fe("toolbox-active-button_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.styles.addRule(new Ae("."+this.toolboxButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new Ae("."+this.toolboxButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`))},k.prototype.show=function(h){var v;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=h,this.uiContainer.className=this.toolboxStyleClass.name+" "+((v=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&v!==void 0?v:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},k.prototype.setPanelButtons=function(h){var v,D,F=this;this.panels=h,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((v=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&v!==void 0?v: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(P){var Z;P.uiStyleSettings=F.uiStyleSettings;var ge=document.createElement("div");ge.className=F.toolboxButtonStyleClass.name+" "+((Z=F.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Z!==void 0?Z:F.toolboxButtonStyleColorsClass.name),ge.innerHTML=P.icon,ge.title=P.title,ge.addEventListener("click",function(){F.panelButtonClick(P)}),F.panelButtons.push(ge),F.buttonRow.appendChild(ge)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},k.prototype.panelButtonClick=function(h){var v=this,D=-1;if(h!==this.activePanel){D=this.panels.indexOf(h),this.panelRow.innerHTML="";var F=h.getUi();F.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(F),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=h}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){v.displayMode==="inline"?v.panelRow.style.display="none":v.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(P,Z){var ge,De;P.className=v.toolboxButtonStyleClass.name+" "+(Z===D?""+((ge=v.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&ge!==void 0?ge:v.toolboxActiveButtonStyleColorsClass.name):""+((De=v.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&De!==void 0?De:v.toolboxButtonStyleColorsClass.name))})},k}(),Oe=function(k,h){this.title=k,this.icon=h},we=function(k){function h(v,D,F,P){var Z=k.call(this,v,P||'<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 Z.colors=[],Z.addTransparent=!1,Z.colorBoxes=[],Z.colors=D,Z.currentColor=F,Z.setCurrentColor=Z.setCurrentColor.bind(Z),Z.getColorBox=Z.getColorBox.bind(Z),Z}return se(h,k),h.prototype.getUi=function(){var v=this,D=document.createElement("div");return D.style.overflow="hidden",D.style.whiteSpace="nowrap",this.colors.forEach(function(F){var P=v.getColorBox(F);D.appendChild(P),v.colorBoxes.push(P)}),D},h.prototype.getColorBox=function(v){var D=this,F=this.uiStyleSettings.toolbarHeight/4,P=this.uiStyleSettings.toolbarHeight-F,Z=document.createElement("div");Z.style.display="inline-block",Z.style.boxSizing="content-box",Z.style.width=P-2+"px",Z.style.height=P-2+"px",Z.style.padding="1px",Z.style.marginRight="2px",Z.style.marginBottom="2px",Z.style.borderWidth="2px",Z.style.borderStyle="solid",Z.style.borderRadius=(P+2)/2+"px",Z.style.borderColor=v===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",Z.addEventListener("click",function(){D.setCurrentColor(v,Z)});var ge=document.createElement("div");return ge.style.display="inline-block",ge.style.width=P-2+"px",ge.style.height=P-2+"px",ge.style.backgroundColor=v,ge.style.borderRadius=P/2+"px",v==="transparent"&&(ge.style.fill=this.uiStyleSettings.toolboxAccentColor,ge.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>`),Z.appendChild(ge),Z},h.prototype.setCurrentColor=function(v,D){var F=this;this.currentColor=v,this.colorBoxes.forEach(function(P){P.style.borderColor=P===D?F.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(v)},h}(Oe),be=function(){function k(h,v,D){this._state="new",this._isSelected=!1,this._container=h,this._overlayContainer=v,this.globalSettings=D,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(k.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),k.prototype.ownsTarget=function(h){return!1},Object.defineProperty(k.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),k.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},k.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},k.prototype.pointerDown=function(h,v){},k.prototype.dblClick=function(h,v){},k.prototype.manipulate=function(h){},k.prototype.pointerUp=function(h){this.stateChanged()},k.prototype.dispose=function(){},k.prototype.addMarkerVisualToContainer=function(h){this.container.childNodes.length>0?this.container.insertBefore(h,this.container.childNodes[0]):this.container.appendChild(h)},k.prototype.getState=function(){return{typeName:k.typeName,state:this.state,notes:this.notes}},k.prototype.restoreState=function(h){this._state=h.state,this.notes=h.notes},k.prototype.scale=function(h,v){},k.prototype.colorChanged=function(h){this.onColorChanged&&this.onColorChanged(h),this.stateChanged()},k.prototype.fillColorChanged=function(h){this.onFillColorChanged&&this.onFillColorChanged(h),this.stateChanged()},k.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var h=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),h.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(h)&&this.onStateChanged(this)}},k.typeName="MarkerBase",k}(),me=function(){function k(){this.findGripByVisual=this.findGripByVisual.bind(this)}return k.prototype.findGripByVisual=function(h){return this.topLeft.ownsTarget(h)?this.topLeft:this.topCenter.ownsTarget(h)?this.topCenter:this.topRight.ownsTarget(h)?this.topRight:this.centerLeft.ownsTarget(h)?this.centerLeft:this.centerRight.ownsTarget(h)?this.centerRight:this.bottomLeft.ownsTarget(h)?this.bottomLeft:this.bottomCenter.ownsTarget(h)?this.bottomCenter:this.bottomRight.ownsTarget(h)?this.bottomRight:void 0},k}(),Ue=function(){function k(){this.GRIP_SIZE=10,this.visual=Y.createGroup(),this.visual.appendChild(Y.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(Y.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return k.prototype.ownsTarget=function(h){return h===this.visual||h===this.visual.childNodes[0]||h===this.visual.childNodes[1]},k}(),Le=function(){function k(){}return k.toITransformMatrix=function(h){return{a:h.a,b:h.b,c:h.c,d:h.d,e:h.e,f:h.f}},k.toSVGMatrix=function(h,v){return h.a=v.a,h.b=v.b,h.c=v.c,h.d=v.d,h.e=v.e,h.f=v.f,h},k}(),ke=function(k){function h(v,D,F){var P=k.call(this,v,D,F)||this;return P.left=0,P.top=0,P.width=0,P.height=0,P.defaultSize={x:50,y:20},P.offsetX=0,P.offsetY=0,P.rotationAngle=0,P.CB_DISTANCE=10,P._suppressMarkerCreateEvent=!1,P.container.transform.baseVal.appendItem(Y.createTransform()),P.setupControlBox(),P}return se(h,k),Object.defineProperty(h.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"visual",{get:function(){return this._visual},set:function(v){this._visual=v;var D=Y.createTransform();this._visual.transform.baseVal.appendItem(D)},enumerable:!1,configurable:!0}),h.prototype.ownsTarget=function(v){return!!k.prototype.ownsTarget.call(this,v)||!!(this.controlGrips.findGripByVisual(v)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(v))},h.prototype.pointerDown=function(v,D){k.prototype.pointerDown.call(this,v,D),this.state==="new"&&(this.left=v.x,this.top=v.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var F=this.unrotatePoint(v);if(this.manipulationStartX=F.x,this.manipulationStartY=F.y,this.offsetX=F.x-this.left,this.offsetY=F.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 P=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=P.x-this.width/2,this.top=P.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var Z=this.container.transform.baseVal.getItem(0);Z.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(Z,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},h.prototype.pointerUp=function(v){var D=this.state;k.prototype.pointerUp.call(this,v),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(v),this._state="select",D==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},h.prototype.moveVisual=function(v){this.visual.style.transform="translate("+v.x+"px, "+v.y+"px)"},h.prototype.manipulate=function(v){var D=this.unrotatePoint(v);this.state==="creating"?this.resize(v):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(v)},h.prototype.resize=function(v){var D=this.manipulationStartLeft,F=this.manipulationStartWidth,P=this.manipulationStartTop,Z=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:D=this.manipulationStartLeft+v.x-this.manipulationStartX,F=this.manipulationStartWidth+this.manipulationStartLeft-D;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:F=this.manipulationStartWidth+v.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:P=this.manipulationStartTop+v.y-this.manipulationStartY,Z=this.manipulationStartHeight+this.manipulationStartTop-P;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:Z=this.manipulationStartHeight+v.y-this.manipulationStartY}F>=0?(this.left=D,this.width=F):(this.left=D+F,this.width=-F),Z>=0?(this.top=P,this.height=Z):(this.top=P+Z,this.height=-Z),this.setSize()},h.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},h.prototype.rotate=function(v){if(Math.abs(v.x-this.centerX)>.1){var D=Math.sign(v.x-this.centerX);this.rotationAngle=180*Math.atan((v.y-this.centerY)/(v.x-this.centerX))/Math.PI+90*D,this.applyRotation()}},h.prototype.applyRotation=function(){var v=this.container.transform.baseVal.getItem(0);v.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(v,0)},h.prototype.rotatePoint=function(v){if(this.rotationAngle===0)return v;var D=this.container.getCTM(),F=Y.createPoint(v.x,v.y);return{x:(F=F.matrixTransform(D)).x,y:F.y}},h.prototype.unrotatePoint=function(v){if(this.rotationAngle===0)return v;var D=this.container.getCTM();D=D.inverse();var F=Y.createPoint(v.x,v.y);return{x:(F=F.matrixTransform(D)).x,y:F.y}},h.prototype.select=function(){k.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},h.prototype.deselect=function(){k.prototype.deselect.call(this),this.controlBox.style.display="none"},h.prototype.setupControlBox=function(){this.controlBox=Y.createGroup();var v=Y.createTransform();v.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(v),this.container.appendChild(this.controlBox),this.controlRect=Y.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=Y.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"},h.prototype.adjustControlBox=function(){var v=this.controlBox.transform.baseVal.getItem(0);v.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(v,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()},h.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()},h.prototype.createGrip=function(){var v=new Ue;return v.visual.transform.baseVal.appendItem(Y.createTransform()),this.controlBox.appendChild(v.visual),v},h.prototype.positionGrips=function(){var v=this.controlGrips.topLeft.GRIP_SIZE,D=-v/2,F=D,P=(this.width+this.CB_DISTANCE)/2-v/2,Z=(this.height+this.CB_DISTANCE)/2-v/2,ge=this.height+this.CB_DISTANCE-v/2,De=this.width+this.CB_DISTANCE-v/2;this.positionGrip(this.controlGrips.topLeft.visual,D,F),this.positionGrip(this.controlGrips.topCenter.visual,P,F),this.positionGrip(this.controlGrips.topRight.visual,De,F),this.positionGrip(this.controlGrips.centerLeft.visual,D,Z),this.positionGrip(this.controlGrips.centerRight.visual,De,Z),this.positionGrip(this.controlGrips.bottomLeft.visual,D,ge),this.positionGrip(this.controlGrips.bottomCenter.visual,P,ge),this.positionGrip(this.controlGrips.bottomRight.visual,De,ge),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,P,F-3*this.CB_DISTANCE)},h.prototype.positionGrip=function(v,D,F){var P=v.transform.baseVal.getItem(0);P.setTranslate(D,F),v.transform.baseVal.replaceItem(P,0)},h.prototype.hideControlBox=function(){this.controlBox.style.display="none"},h.prototype.showControlBox=function(){this.controlBox.style.display=""},h.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:Le.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:Le.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},k.prototype.getState.call(this))},h.prototype.restoreState=function(v){k.prototype.restoreState.call(this,v);var D=v;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(Le.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,D.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(Le.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,D.containerTransformMatrix))},h.prototype.scale=function(v,D){k.prototype.scale.call(this,v,D);var F=this.rotatePoint({x:this.left,y:this.top}),P=this.unrotatePoint({x:F.x*v,y:F.y*D});this.left=P.x,this.top=P.y,this.width=this.width*v,this.height=this.height*D,this.adjustControlBox()},h}(be),Pe=function(k){function h(v,D,F){var P=k.call(this,v,D,F)||this;return P.fillColor="transparent",P.strokeColor="transparent",P.strokeWidth=0,P.strokeDasharray="",P.opacity=1,P.setStrokeColor=P.setStrokeColor.bind(P),P.setFillColor=P.setFillColor.bind(P),P.setStrokeWidth=P.setStrokeWidth.bind(P),P.setStrokeDasharray=P.setStrokeDasharray.bind(P),P.createVisual=P.createVisual.bind(P),P}return se(h,k),h.prototype.ownsTarget=function(v){return!(!k.prototype.ownsTarget.call(this,v)&&v!==this.visual)},h.prototype.createVisual=function(){this.visual=Y.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)},h.prototype.pointerDown=function(v,D){k.prototype.pointerDown.call(this,v,D),this.state==="new"&&(this.createVisual(),this.moveVisual(v),this._state="creating")},h.prototype.manipulate=function(v){k.prototype.manipulate.call(this,v)},h.prototype.resize=function(v){k.prototype.resize.call(this,v),this.setSize()},h.prototype.setSize=function(){k.prototype.setSize.call(this),Y.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},h.prototype.pointerUp=function(v){k.prototype.pointerUp.call(this,v),this.setSize()},h.prototype.setStrokeColor=function(v){this.strokeColor=v,this.visual&&Y.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(v),this.stateChanged()},h.prototype.setFillColor=function(v){this.fillColor=v,this.visual&&Y.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},h.prototype.setStrokeWidth=function(v){this.strokeWidth=v,this.visual&&Y.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},h.prototype.setStrokeDasharray=function(v){this.strokeDasharray=v,this.visual&&Y.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},h.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},k.prototype.getState.call(this))},h.prototype.restoreState=function(v){var D=v;this.fillColor=D.fillColor,this.strokeColor=D.strokeColor,this.strokeWidth=D.strokeWidth,this.strokeDasharray=D.strokeDasharray,this.opacity=D.opacity,this.createVisual(),k.prototype.restoreState.call(this,v),this.setSize()},h.prototype.scale=function(v,D){k.prototype.scale.call(this,v,D),this.setSize()},h.title="Rectangle marker",h}(ke),Be=function(k){function h(v,D,F,P){var Z=k.call(this,v,P||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return Z.widths=[],Z.widthBoxes=[],Z.widths=D,Z.currentWidth=F,Z.setCurrentWidth=Z.setCurrentWidth.bind(Z),Z}return se(h,k),h.prototype.getUi=function(){var v=this,D=document.createElement("div");return D.style.display="flex",D.style.overflow="hidden",D.style.flexGrow="2",this.widths.forEach(function(F){var P=document.createElement("div");P.style.display="flex",P.style.flexGrow="2",P.style.alignItems="center",P.style.justifyContent="space-between",P.style.padding="5px",P.style.borderWidth="2px",P.style.borderStyle="solid",P.style.borderColor=F===v.currentWidth?v.uiStyleSettings.toolboxAccentColor:"transparent",P.addEventListener("click",function(){v.setCurrentWidth(F,P)}),D.appendChild(P);var Z=document.createElement("div");Z.innerText=F.toString(),Z.style.marginRight="5px",P.appendChild(Z);var ge=document.createElement("div");ge.style.minHeight="20px",ge.style.flexGrow="2",ge.style.display="flex",ge.style.alignItems="center";var De=document.createElement("hr");De.style.minWidth="20px",De.style.border="0px",De.style.borderTop=F+"px solid "+v.uiStyleSettings.toolboxColor,De.style.flexGrow="2",ge.appendChild(De),P.appendChild(ge),v.widthBoxes.push(P)}),D},h.prototype.setCurrentWidth=function(v,D){var F=this;this.currentWidth=v,this.widthBoxes.forEach(function(P){P.style.borderColor=P===D?F.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},h}(Oe),je=function(k){function h(v,D,F,P){var Z=k.call(this,v,P||'<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 Z.styles=[],Z.styleBoxes=[],Z.styles=D,Z.currentStyle=F,Z.setCurrentStyle=Z.setCurrentStyle.bind(Z),Z}return se(h,k),h.prototype.getUi=function(){var v=this,D=document.createElement("div");return D.style.display="flex",D.style.overflow="hidden",D.style.flexGrow="2",this.styles.forEach(function(F){var P=document.createElement("div");P.style.display="flex",P.style.alignItems="center",P.style.justifyContent="space-between",P.style.padding="5px",P.style.borderWidth="2px",P.style.borderStyle="solid",P.style.overflow="hidden",P.style.maxWidth=100/v.styles.length-5+"%",P.style.borderColor=F===v.currentStyle?v.uiStyleSettings.toolboxAccentColor:"transparent",P.addEventListener("click",function(){v.setCurrentStyle(F,P)}),D.appendChild(P);var Z=document.createElement("div");Z.style.minHeight="20px",Z.style.flexGrow="2",Z.style.overflow="hidden";var ge=`<svg width="100" height="20">
<line x1="0" y1="10" x2="100" y2="10" stroke="`+v.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(F!==""?'stroke-dasharray="'+F+'"':"")+` />
</svg>`;Z.innerHTML=ge,P.appendChild(Z),v.styleBoxes.push(P)}),D},h.prototype.setCurrentStyle=function(v,D){var F=this;this.currentStyle=v,this.styleBoxes.forEach(function(P){P.style.borderColor=P===D?F.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},h}(Oe),Me=function(k){function h(v,D,F){var P=k.call(this,v,D,F)||this;return P.strokeColor=F.defaultColor,P.strokeWidth=F.defaultStrokeWidth,P.strokeDasharray=F.defaultStrokeDasharray,P.strokePanel=new we("Line color",F.defaultColorSet,F.defaultColor),P.strokePanel.onColorChanged=P.setStrokeColor,P.strokeWidthPanel=new Be("Line width",F.defaultStrokeWidths,F.defaultStrokeWidth),P.strokeWidthPanel.onWidthChanged=P.setStrokeWidth,P.strokeStylePanel=new je("Line style",F.defaultStrokeDasharrays,F.defaultStrokeDasharray),P.strokeStylePanel.onStyleChanged=P.setStrokeDasharray,P}return se(h,k),Object.defineProperty(h.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),h.prototype.getState=function(){var v=k.prototype.getState.call(this);return v.typeName=h.typeName,v},h.typeName="FrameMarker",h.title="Frame marker",h.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',h}(Pe),Re=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},Fe=function(k){function h(v,D,F){var P=k.call(this,v,D,F)||this;return P.x1=0,P.y1=0,P.x2=0,P.y2=0,P.defaultLength=50,P.manipulationStartX=0,P.manipulationStartY=0,P.manipulationStartX1=0,P.manipulationStartY1=0,P.manipulationStartX2=0,P.manipulationStartY2=0,P.setupControlBox(),P}return se(h,k),h.prototype.ownsTarget=function(v){return!!k.prototype.ownsTarget.call(this,v)||!(!this.grip1.ownsTarget(v)&&!this.grip2.ownsTarget(v))},h.prototype.pointerDown=function(v,D){k.prototype.pointerDown.call(this,v,D),this.manipulationStartX=v.x,this.manipulationStartY=v.y,this.state==="new"&&(this.x1=v.x,this.y1=v.y,this.x2=v.x,this.y2=v.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")},h.prototype.pointerUp=function(v){var D=this.state;k.prototype.pointerUp.call(this,v),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(v),this._state="select",D==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},h.prototype.adjustVisual=function(){},h.prototype.manipulate=function(v){this.state==="creating"?this.resize(v):this.state==="move"?(this.x1=this.manipulationStartX1+v.x-this.manipulationStartX,this.y1=this.manipulationStartY1+v.y-this.manipulationStartY,this.x2=this.manipulationStartX2+v.x-this.manipulationStartX,this.y2=this.manipulationStartY2+v.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(v)},h.prototype.resize=function(v){switch(this.activeGrip){case this.grip1:this.x1=v.x,this.y1=v.y;break;case this.grip2:case void 0:this.x2=v.x,this.y2=v.y}this.adjustVisual(),this.adjustControlBox()},h.prototype.select=function(){k.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},h.prototype.deselect=function(){k.prototype.deselect.call(this),this.controlBox.style.display="none"},h.prototype.setupControlBox=function(){this.controlBox=Y.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},h.prototype.adjustControlBox=function(){this.positionGrips()},h.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},h.prototype.createGrip=function(){var v=new Ue;return v.visual.transform.baseVal.appendItem(Y.createTransform()),this.controlBox.appendChild(v.visual),v},h.prototype.positionGrips=function(){var v=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-v/2,this.y1-v/2),this.positionGrip(this.grip2.visual,this.x2-v/2,this.y2-v/2)},h.prototype.positionGrip=function(v,D,F){var P=v.transform.baseVal.getItem(0);P.setTranslate(D,F),v.transform.baseVal.replaceItem(P,0)},h.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},k.prototype.getState.call(this))},h.prototype.restoreState=function(v){k.prototype.restoreState.call(this,v);var D=v;this.x1=D.x1,this.y1=D.y1,this.x2=D.x2,this.y2=D.y2},h.prototype.scale=function(v,D){k.prototype.scale.call(this,v,D),this.x1=this.x1*v,this.y1=this.y1*D,this.x2=this.x2*v,this.y2=this.y2*D,this.adjustVisual(),this.adjustControlBox()},h}(be),Ne=function(k){function h(v,D,F){var P=k.call(this,v,D,F)||this;return P.strokeColor="transparent",P.strokeWidth=0,P.strokeDasharray="",P.setStrokeColor=P.setStrokeColor.bind(P),P.setStrokeWidth=P.setStrokeWidth.bind(P),P.setStrokeDasharray=P.setStrokeDasharray.bind(P),P.strokeColor=F.defaultColor,P.strokeWidth=F.defaultStrokeWidth,P.strokeDasharray=F.defaultStrokeDasharray,P.strokePanel=new we("Line color",F.defaultColorSet,F.defaultColor),P.strokePanel.onColorChanged=P.setStrokeColor,P.strokeWidthPanel=new Be("Line width",F.defaultStrokeWidths,F.defaultStrokeWidth),P.strokeWidthPanel.onWidthChanged=P.setStrokeWidth,P.strokeStylePanel=new je("Line style",F.defaultStrokeDasharrays,F.defaultStrokeDasharray),P.strokeStylePanel.onStyleChanged=P.setStrokeDasharray,P}return se(h,k),h.prototype.ownsTarget=function(v){return!(!k.prototype.ownsTarget.call(this,v)&&v!==this.visual&&v!==this.selectorLine&&v!==this.visibleLine)},h.prototype.createVisual=function(){this.visual=Y.createGroup(),this.selectorLine=Y.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=Y.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)},h.prototype.pointerDown=function(v,D){k.prototype.pointerDown.call(this,v,D),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},h.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()),Y.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),Y.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),Y.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},h.prototype.setStrokeColor=function(v){this.strokeColor=v,this.adjustVisual(),this.colorChanged(v)},h.prototype.setStrokeWidth=function(v){this.strokeWidth=v,this.adjustVisual()},h.prototype.setStrokeDasharray=function(v){this.strokeDasharray=v,this.adjustVisual(),this.stateChanged()},Object.defineProperty(h.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),h.prototype.getState=function(){var v=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},k.prototype.getState.call(this));return v.typeName=h.typeName,v},h.prototype.restoreState=function(v){k.prototype.restoreState.call(this,v);var D=v;this.strokeColor=D.strokeColor,this.strokeWidth=D.strokeWidth,this.strokeDasharray=D.strokeDasharray,this.createVisual(),this.adjustVisual()},h.typeName="LineMarker",h.title="Line marker",h.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',h}(Fe),oe=function(k){function h(v,D,F,P){var Z=k.call(this,v,P||'<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 Z.fonts=[],Z.fontBoxes=[],Z.fonts=D,Z.currentFont=F,Z.setCurrentFont=Z.setCurrentFont.bind(Z),Z}return se(h,k),h.prototype.getUi=function(){var v=this,D=document.createElement("div");return D.style.overflow="hidden",D.style.flexGrow="2",this.fonts.forEach(function(F){var P=document.createElement("div");P.style.display="inline-block",P.style.alignItems="center",P.style.justifyContent="space-between",P.style.padding="5px",P.style.borderWidth="2px",P.style.borderStyle="solid",P.style.overflow="hidden",P.style.maxWidth=100/v.fonts.length-5+"%",P.style.borderColor=F===v.currentFont?v.uiStyleSettings.toolboxAccentColor:"transparent",P.addEventListener("click",function(){v.setCurrentFont(F,P)}),D.appendChild(P);var Z=document.createElement("div");Z.style.display="flex",Z.style.minHeight="20px",Z.style.flexGrow="2",Z.style.fontFamily=F,Z.style.overflow="hidden";var ge=document.createElement("div");ge.style.whiteSpace="nowrap",ge.style.overflow="hidden",ge.style.textOverflow="ellipsis",ge.innerHTML="The quick brown fox jumps over the lazy dog",Z.appendChild(ge),P.appendChild(Z),v.fontBoxes.push(P)}),D},h.prototype.setCurrentFont=function(v,D){var F=this;this.currentFont=v,this.fontBoxes.forEach(function(P){P.style.borderColor=P===D?F.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},h}(Oe),Ee=function(k){function h(v,D,F){var P=k.call(this,v,D,F)||this;return P.color="transparent",P.padding=5,P.DEFAULT_TEXT="your text here",P.text=P.DEFAULT_TEXT,P.isMoved=!1,P.color=F.defaultColor,P.fontFamily=F.defaultFontFamily,P.defaultSize={x:100,y:30},P.setColor=P.setColor.bind(P),P.setFont=P.setFont.bind(P),P.renderText=P.renderText.bind(P),P.sizeText=P.sizeText.bind(P),P.textEditDivClicked=P.textEditDivClicked.bind(P),P.showTextEditor=P.showTextEditor.bind(P),P.setSize=P.setSize.bind(P),P.positionTextEditor=P.positionTextEditor.bind(P),P.colorPanel=new we("Color",F.defaultColorSet,F.defaultColor),P.colorPanel.onColorChanged=P.setColor,P.fontFamilyPanel=new oe("Font",F.defaultFontFamilies,F.defaultFontFamily),P.fontFamilyPanel.onFontChanged=P.setFont,P}return se(h,k),h.prototype.ownsTarget=function(v){if(k.prototype.ownsTarget.call(this,v)||v===this.visual||v===this.textElement||v===this.bgRectangle)return!0;var D=!1;return this.textElement.childNodes.forEach(function(F){F===v&&(D=!0)}),D},h.prototype.createVisual=function(){this.visual=Y.createGroup(),this.bgRectangle=Y.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=Y.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(Y.createTransform()),this.textElement.transform.baseVal.appendItem(Y.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},h.prototype.pointerDown=function(v,D){k.prototype.pointerDown.call(this,v,D),this.isMoved=!1,this.pointerDownPoint=v,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(v),this._state="creating")},h.prototype.renderText=function(){var v=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){v.textElement.appendChild(Y.createTSpan(D.trim()===""?" ":D.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},h.prototype.getTextScale=function(){var v=this.textElement.getBBox(),D=1;if(v.width>0&&v.height>0){var F=(1*this.width-this.width*this.padding*2/100)/v.width,P=(1*this.height-this.height*this.padding*2/100)/v.height;D=Math.min(F,P)}return D},h.prototype.getTextPosition=function(v){var D=this.textElement.getBBox(),F=0,P=0;return D.width>0&&D.height>0&&(F=(this.width-D.width*v)/2,P=this.height/2-D.height*v/2),{x:F,y:P}},h.prototype.sizeText=function(){var v=this.textElement.getBBox(),D=this.getTextScale(),F=this.getTextPosition(D);F.y-=v.y*D,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+F.x+"px, "+F.y+"px) scale("+D+", "+D+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(F.x,F.y),this.textElement.transform.baseVal.getItem(1).setScale(D,D))},h.prototype.manipulate=function(v){k.prototype.manipulate.call(this,v),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(v.x-this.pointerDownPoint.x)>5||Math.abs(v.y-this.pointerDownPoint.y)>5)},h.prototype.resize=function(v){k.prototype.resize.call(this,v),this.isMoved=!0,this.setSize(),this.sizeText()},h.prototype.setSize=function(){k.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(Y.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),Y.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},h.prototype.pointerUp=function(v){var D=this.state;D==="creating"&&(this._suppressMarkerCreateEvent=!0),k.prototype.pointerUp.call(this,v),this.setSize(),(D==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},h.prototype.showTextEditor=function(){var v=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(v.textEditor.style.fontSize);v.textEditor.clientWidth>=Number.parseInt(v.textEditor.style.maxWidth)&&D>.9;)D-=.1,v.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 F=D.clipboardData.getData("text"),P=window.getSelection();if(!P.rangeCount)return!1;P.deleteFromDocument(),P.getRangeAt(0).insertNode(document.createTextNode(F)),D.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){v.textEditDivClicked(v.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},h.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var v=this.getTextScale(),D=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),F=this.textElement.getBBox(),P={x:F.width*v,y:F.height*v};D.x-=P.x/2,D.y-=P.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*v,12)+"px",this.textElement.style.display="none"}},h.prototype.textEditDivClicked=function(v){this.text=v.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},h.prototype.select=function(){k.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},h.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),k.prototype.deselect.call(this)},h.prototype.dblClick=function(v,D){k.prototype.dblClick.call(this,v,D),this.showTextEditor()},h.prototype.setColor=function(v){this.textElement&&Y.setAttributes(this.textElement,[["fill",v]]),this.color=v,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(v)},h.prototype.setFont=function(v){this.textElement&&Y.setAttributes(this.textElement,[["font-family",v]]),this.fontFamily=v,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},h.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},h.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(h.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),h.prototype.getState=function(){var v=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},k.prototype.getState.call(this));return v.typeName=h.typeName,v},h.prototype.restoreState=function(v){var D=v;this.color=D.color,this.fontFamily=D.fontFamily,this.padding=D.padding,this.text=D.text,this.createVisual(),k.prototype.restoreState.call(this,v),this.setSize()},h.prototype.scale=function(v,D){k.prototype.scale.call(this,v,D),this.setSize(),this.sizeText(),this.positionTextEditor()},h.typeName="TextMarker",h.title="Text marker",h.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>',h}(ke),ie=function(k){function h(v,D,F){var P=k.call(this,v,D,F)||this;return P.color="transparent",P.lineWidth=3,P.drawing=!1,P.pixelRatio=1,P.color=F.defaultColor,P.lineWidth=F.defaultStrokeWidth,P.pixelRatio=F.freehandPixelRatio,P.setColor=P.setColor.bind(P),P.addCanvas=P.addCanvas.bind(P),P.finishCreation=P.finishCreation.bind(P),P.setLineWidth=P.setLineWidth.bind(P),P.colorPanel=new we("Color",F.defaultColorSet,F.defaultColor),P.colorPanel.onColorChanged=P.setColor,P.lineWidthPanel=new Be("Line width",F.defaultStrokeWidths,F.defaultStrokeWidth),P.lineWidthPanel.onWidthChanged=P.setLineWidth,P}return se(h,k),h.prototype.ownsTarget=function(v){return!(!k.prototype.ownsTarget.call(this,v)&&v!==this.visual&&v!==this.drawingImage)},h.prototype.createVisual=function(){this.visual=Y.createGroup(),this.drawingImage=Y.createImage(),this.visual.appendChild(this.drawingImage);var v=Y.createTransform();this.visual.transform.baseVal.appendItem(v),this.addMarkerVisualToContainer(this.visual)},h.prototype.pointerDown=function(v,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(v.x,v.y),this.drawing=!0):k.prototype.pointerDown.call(this,v,D)},h.prototype.manipulate=function(v){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(v.x,v.y),this.canvasContext.stroke()):k.prototype.manipulate.call(this,v)},h.prototype.resize=function(v){k.prototype.resize.call(this,v),Y.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),Y.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},h.prototype.pointerUp=function(v){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):k.prototype.pointerUp.call(this,v)},h.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)},h.prototype.select=function(){this.state==="creating"&&this.finishCreation(),k.prototype.select.call(this)},h.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),k.prototype.deselect.call(this)},h.prototype.finishCreation=function(){for(var v=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),D=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],F=D[0],P=D[1],Z=D[2],ge=D[3],De=!1,Ge=0;Ge<this.canvasElement.height;Ge++)for(var ye=0;ye<this.canvasElement.width;ye++)v.data[Ge*this.canvasElement.width*4+4*ye+3]>0&&(De=!0,Ge<P&&(P=Ge),ye<F&&(F=ye),Ge>ge&&(ge=Ge),ye>Z&&(Z=ye));if(De){this.left=F/this.pixelRatio,this.top=P/this.pixelRatio,this.width=(Z-F)/this.pixelRatio,this.height=(ge-P)/this.pixelRatio;var Ye=document.createElement("canvas");Ye.width=Z-F,Ye.height=ge-P,Ye.getContext("2d").putImageData(this.canvasContext.getImageData(F,P,Z-F,ge-P),0,0),this.drawingImgUrl=Ye.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},h.prototype.setDrawingImage=function(){Y.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),Y.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},h.prototype.setColor=function(v){this.color=v,this.colorChanged(v)},h.prototype.setLineWidth=function(v){this.lineWidth=v},Object.defineProperty(h.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),h.prototype.getState=function(){var v=Object.assign({drawingImgUrl:this.drawingImgUrl},k.prototype.getState.call(this));return v.typeName=h.typeName,v},h.prototype.restoreState=function(v){this.createVisual(),k.prototype.restoreState.call(this,v),this.drawingImgUrl=v.drawingImgUrl,this.setDrawingImage()},h.prototype.scale=function(v,D){k.prototype.scale.call(this,v,D),this.setDrawingImage()},h.typeName="FreehandMarker",h.title="Freehand marker",h.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>',h}(ke),J=function(k){function h(v,D,F){var P=k.call(this,v,F||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return P.typeBoxes=[],P.currentType=D,P.setCurrentType=P.setCurrentType.bind(P),P}return se(h,k),h.prototype.getUi=function(){var v=this,D=document.createElement("div");D.style.display="flex",D.style.overflow="hidden",D.style.flexGrow="2";for(var F=function(ge){var De="both";switch(ge){case 0:De="both";break;case 1:De="start";break;case 2:De="end";break;case 3:De="none"}var Ge=document.createElement("div");if(Ge.style.display="flex",Ge.style.flexGrow="2",Ge.style.alignItems="center",Ge.style.justifyContent="space-between",Ge.style.padding="5px",Ge.style.borderWidth="2px",Ge.style.borderStyle="solid",Ge.style.borderColor=De===P.currentType?P.uiStyleSettings.toolboxAccentColor:"transparent",Ge.addEventListener("click",function(){v.setCurrentType(De,Ge)}),D.appendChild(Ge),De==="both"||De==="start"){var ye=document.createElement("div");ye.style.display="flex",ye.style.alignItems="center",ye.style.minHeight="20px",ye.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="`+(P.uiStyleSettings!==void 0?P.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,ye.style.marginLeft="5px",Ge.appendChild(ye)}var Ye=document.createElement("div");Ye.style.display="flex",Ye.style.alignItems="center",Ye.style.minHeight="20px",Ye.style.flexGrow="2";var it=document.createElement("hr");if(it.style.minWidth="20px",it.style.border="0px",it.style.borderTop="3px solid "+(P.uiStyleSettings!==void 0?P.uiStyleSettings.toolboxColor:"#eeeeee"),it.style.flexGrow="2",Ye.appendChild(it),Ge.appendChild(Ye),De==="both"||De==="end"){var at=document.createElement("div");at.style.display="flex",at.style.alignItems="center",at.style.minHeight="20px",at.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="`+(P.uiStyleSettings!==void 0?P.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,at.style.marginRight="5px",Ge.appendChild(at)}P.typeBoxes.push(Ge)},P=this,Z=0;Z<4;Z++)F(Z);return D},h.prototype.setCurrentType=function(v,D){var F=this;this.currentType=v,this.typeBoxes.forEach(function(P){P.style.borderColor=P===D?F.uiStyleSettings!==void 0?F.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},h}(Oe),te=function(k){function h(v,D,F){var P=k.call(this,v,D,F)||this;return P.arrowType="end",P.arrowBaseHeight=10,P.arrowBaseWidth=10,P.getArrowPoints=P.getArrowPoints.bind(P),P.setArrowType=P.setArrowType.bind(P),P.arrowTypePanel=new J("Arrow type","end"),P.arrowTypePanel.onArrowTypeChanged=P.setArrowType,P}return se(h,k),h.prototype.ownsTarget=function(v){return!(!k.prototype.ownsTarget.call(this,v)&&v!==this.arrow1&&v!==this.arrow2)},h.prototype.getArrowPoints=function(v,D){var F=this.arrowBaseWidth+2*this.strokeWidth,P=this.arrowBaseHeight+2*this.strokeWidth;return v-F/2+","+(D+P/2)+" "+v+","+(D-P/2)+" "+(v+F/2)+","+(D+P/2)},h.prototype.createTips=function(){this.arrow1=Y.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(Y.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=Y.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(Y.createTransform()),this.visual.appendChild(this.arrow2)},h.prototype.pointerDown=function(v,D){k.prototype.pointerDown.call(this,v,D),this.state==="creating"&&this.createTips()},h.prototype.adjustVisual=function(){if(k.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",Y.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),Y.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var v=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(v,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(D,0);var F=this.arrow2.transform.baseVal.getItem(0);F.setRotate(v+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(F,0)}},h.prototype.setArrowType=function(v){this.arrowType=v,this.adjustVisual(),this.stateChanged()},Object.defineProperty(h.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),h.prototype.getState=function(){var v=Object.assign({arrowType:this.arrowType},k.prototype.getState.call(this));return v.typeName=h.typeName,v},h.prototype.restoreState=function(v){k.prototype.restoreState.call(this,v);var D=v;this.arrowType=D.arrowType,this.createTips(),this.adjustVisual()},h.typeName="ArrowMarker",h.title="Arrow marker",h.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',h}(Ne),z=function(k){function h(v,D,F){var P=k.call(this,v,D,F)||this;return P.fillColor=F.defaultFillColor,P.strokeWidth=0,P.fillPanel=new we("Color",F.defaultColorSet,F.defaultFillColor),P.fillPanel.onColorChanged=P.setFillColor,P}return se(h,k),Object.defineProperty(h.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),h.prototype.getState=function(){var v=k.prototype.getState.call(this);return v.typeName=h.typeName,v},h.typeName="CoverMarker",h.title="Cover marker",h.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',h}(Pe),V=function(k){function h(v,D,F,P){var Z=k.call(this,v,P||'<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 Z.opacities=[],Z.opacityBoxes=[],Z.opacities=D,Z.currentOpacity=F,Z.setCurrentOpacity=Z.setCurrentOpacity.bind(Z),Z}return se(h,k),h.prototype.getUi=function(){var v=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(F){var P=document.createElement("div");P.style.display="flex",P.style.alignItems="center",P.style.justifyContent="center",P.style.padding="5px",P.style.borderWidth="2px",P.style.borderStyle="solid",P.style.borderColor=F===v.currentOpacity?v.uiStyleSettings.toolboxAccentColor:"transparent",P.addEventListener("click",function(){v.setCurrentOpacity(F,P)}),D.appendChild(P);var Z=document.createElement("div");Z.innerText=100*F+"%",P.appendChild(Z),v.opacityBoxes.push(P)}),D},h.prototype.setCurrentOpacity=function(v,D){var F=this;this.currentOpacity=v,this.opacityBoxes.forEach(function(P){P.style.borderColor=P===D?F.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},h}(Oe),X=function(k){function h(v,D,F){var P=k.call(this,v,D,F)||this;return P.setOpacity=P.setOpacity.bind(P),P.fillColor=F.defaultHighlightColor,P.strokeWidth=0,P.opacity=F.defaultHighlightOpacity,P.fillPanel=new we("Color",F.defaultColorSet,P.fillColor),P.fillPanel.onColorChanged=P.setFillColor,P.opacityPanel=new V("Opacity",F.defaultOpacitySteps,P.opacity),P.opacityPanel.onOpacityChanged=P.setOpacity,P}return se(h,k),h.prototype.setOpacity=function(v){this.opacity=v,this.visual&&Y.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(h.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),h.prototype.getState=function(){var v=k.prototype.getState.call(this);return v.typeName=h.typeName,v},h.typeName="HighlightMarker",h.title="Highlight marker",h.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>',h}(z),q='<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>',ae=function(k){function h(v,D,F){var P=k.call(this,v,D,F)||this;return P.bgColor="transparent",P.tipPosition={x:0,y:0},P.tipBase1Position={x:0,y:0},P.tipBase2Position={x:0,y:0},P.tipMoving=!1,P.color=F.defaultStrokeColor,P.bgColor=F.defaultFillColor,P.fontFamily=F.defaultFontFamily,P.defaultSize={x:100,y:30},P.setBgColor=P.setBgColor.bind(P),P.getTipPoints=P.getTipPoints.bind(P),P.positionTip=P.positionTip.bind(P),P.setTipPoints=P.setTipPoints.bind(P),P.colorPanel=new we("Text color",F.defaultColorSet,P.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>'),P.colorPanel.onColorChanged=P.setColor,P.bgColorPanel=new we("Fill color",F.defaultColorSet,P.bgColor,q),P.bgColorPanel.onColorChanged=P.setBgColor,P.fontFamilyPanel=new oe("Font",F.defaultFontFamilies,F.defaultFontFamily),P.fontFamilyPanel.onFontChanged=P.setFont,P.tipGrip=new Ue,P.tipGrip.visual.transform.baseVal.appendItem(Y.createTransform()),P.controlBox.appendChild(P.tipGrip.visual),P}return se(h,k),h.prototype.ownsTarget=function(v){return k.prototype.ownsTarget.call(this,v)||this.tipGrip.ownsTarget(v)||this.tip===v},h.prototype.createTip=function(){Y.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=Y.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},h.prototype.pointerDown=function(v,D){this.state==="new"&&k.prototype.pointerDown.call(this,v,D),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(D)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):k.prototype.pointerDown.call(this,v,D)},h.prototype.pointerUp=function(v){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,k.prototype.pointerUp.call(this,v);else{var D=this.state==="creating";k.prototype.pointerUp.call(this,v),this.setTipPoints(D),this.positionTip()}},h.prototype.manipulate=function(v){if(this.tipMoving){var D=this.unrotatePoint(v);this.tipPosition={x:D.x-this.manipulationStartLeft,y:D.y-this.manipulationStartTop},this.positionTip()}else k.prototype.manipulate.call(this,v)},h.prototype.setBgColor=function(v){this.bgRectangle&&this.tip&&(Y.setAttributes(this.bgRectangle,[["fill",v]]),Y.setAttributes(this.tip,[["fill",v]])),this.bgColor=v,this.fillColorChanged(v)},h.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},h.prototype.setTipPoints=function(v){v===void 0&&(v=!1);var D=Math.min(this.height/2,15),F=this.height/5;v&&(this.tipPosition={x:D+F/2,y:this.height+20});var P=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?P<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(F=this.width/5,D=Math.min(this.width/2,15),this.tipBase1Position={x:D,y:0},this.tipBase2Position={x:D+F,y:0}):(this.tipBase1Position={x:0,y:D},this.tipBase2Position={x:0,y:D+F}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?P<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(F=this.width/5,D=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-D-F,y:0},this.tipBase2Position={x:this.width-D,y:0}):(this.tipBase1Position={x:this.width,y:D},this.tipBase2Position={x:this.width,y:D+F}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?P<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(F=this.width/5,D=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-D-F,y:this.height},this.tipBase2Position={x:this.width-D,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-D-F},this.tipBase2Position={x:this.width,y:this.height-D}):P<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(F=this.width/5,D=Math.min(this.width/2,15),this.tipBase1Position={x:D,y:this.height},this.tipBase2Position={x:D+F,y:this.height}):(this.tipBase1Position={x:0,y:this.height-D},this.tipBase2Position={x:0,y:this.height-D-F})},h.prototype.resize=function(v){k.prototype.resize.call(this,v),this.positionTip()},h.prototype.positionTip=function(){Y.setAttributes(this.tip,[["points",this.getTipPoints()]]);var v=this.tipGrip.visual.transform.baseVal.getItem(0);v.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(v,0)},Object.defineProperty(h.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),h.prototype.select=function(){this.positionTip(),k.prototype.select.call(this)},h.prototype.getState=function(){var v=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},k.prototype.getState.call(this));return v.typeName=h.typeName,v},h.prototype.restoreState=function(v){var D=v;this.bgColor=D.bgColor,this.tipPosition=D.tipPosition,k.prototype.restoreState.call(this,v),this.createTip(),this.setTipPoints()},h.prototype.scale=function(v,D){k.prototype.scale.call(this,v,D),this.tipPosition={x:this.tipPosition.x*v,y:this.tipPosition.y*D},this.positionTip()},h.typeName="CalloutMarker",h.title="Callout marker",h.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>',h}(Ee),ce=function(k){function h(v,D,F){var P=k.call(this,v,D,F)||this;return P.fillColor="transparent",P.strokeColor="transparent",P.strokeWidth=0,P.strokeDasharray="",P.opacity=1,P.strokeColor=F.defaultColor,P.strokeWidth=F.defaultStrokeWidth,P.strokeDasharray=F.defaultStrokeDasharray,P.fillColor=F.defaultFillColor,P.setStrokeColor=P.setStrokeColor.bind(P),P.setFillColor=P.setFillColor.bind(P),P.setStrokeWidth=P.setStrokeWidth.bind(P),P.setStrokeDasharray=P.setStrokeDasharray.bind(P),P.setOpacity=P.setOpacity.bind(P),P.createVisual=P.createVisual.bind(P),P.strokePanel=new we("Line color",re(F.defaultColorSet,["transparent"]),F.defaultColor),P.strokePanel.onColorChanged=P.setStrokeColor,P.fillPanel=new we("Fill color",re(F.defaultColorSet,["transparent"]),P.fillColor,q),P.fillPanel.onColorChanged=P.setFillColor,P.strokeWidthPanel=new Be("Line width",F.defaultStrokeWidths,F.defaultStrokeWidth),P.strokeWidthPanel.onWidthChanged=P.setStrokeWidth,P.strokeStylePanel=new je("Line style",F.defaultStrokeDasharrays,F.defaultStrokeDasharray),P.strokeStylePanel.onStyleChanged=P.setStrokeDasharray,P.opacityPanel=new V("Opacity",F.defaultOpacitySteps,P.opacity),P.opacityPanel.onOpacityChanged=P.setOpacity,P}return se(h,k),h.prototype.ownsTarget=function(v){return!(!k.prototype.ownsTarget.call(this,v)&&v!==this.visual)},h.prototype.createVisual=function(){this.visual=Y.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)},h.prototype.pointerDown=function(v,D){k.prototype.pointerDown.call(this,v,D),this.state==="new"&&(this.createVisual(),this.moveVisual(v),this._state="creating")},h.prototype.manipulate=function(v){k.prototype.manipulate.call(this,v)},h.prototype.resize=function(v){k.prototype.resize.call(this,v),this.setSize()},h.prototype.setSize=function(){k.prototype.setSize.call(this),Y.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},h.prototype.pointerUp=function(v){k.prototype.pointerUp.call(this,v),this.setSize()},h.prototype.setStrokeColor=function(v){this.strokeColor=v,this.visual&&Y.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(v),this.stateChanged()},h.prototype.setFillColor=function(v){this.fillColor=v,this.visual&&Y.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(v),this.stateChanged()},h.prototype.setStrokeWidth=function(v){this.strokeWidth=v,this.visual&&Y.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},h.prototype.setStrokeDasharray=function(v){this.strokeDasharray=v,this.visual&&Y.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},h.prototype.setOpacity=function(v){this.opacity=v,this.visual&&Y.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(h.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),h.prototype.getState=function(){var v=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},k.prototype.getState.call(this));return v.typeName=h.typeName,v},h.prototype.restoreState=function(v){var D=v;this.fillColor=D.fillColor,this.strokeColor=D.strokeColor,this.strokeWidth=D.strokeWidth,this.strokeDasharray=D.strokeDasharray,this.opacity=D.opacity,this.createVisual(),k.prototype.restoreState.call(this,v),this.setSize()},h.prototype.scale=function(v,D){k.prototype.scale.call(this,v,D),this.setSize()},h.typeName="EllipseMarker",h.title="Ellipse marker",h.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>',h}(ke),_e=function(k){function h(v,D,F){return k.call(this,v,D,F)||this}return se(h,k),Object.defineProperty(h.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),h.prototype.ownsTarget=function(v){return!(!k.prototype.ownsTarget.call(this,v)&&v!==this.tip1&&v!==this.tip2)},h.prototype.createTips=function(){this.tip1=Y.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(Y.createTransform()),this.visual.appendChild(this.tip1),this.tip2=Y.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(Y.createTransform()),this.visual.appendChild(this.tip2)},h.prototype.pointerDown=function(v,D){k.prototype.pointerDown.call(this,v,D),this.state==="creating"&&this.createTips()},h.prototype.adjustVisual=function(){if(k.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(Y.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()]]),Y.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 v=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(v,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(D,0);var F=this.tip2.transform.baseVal.getItem(0);F.setRotate(v+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(F,0)}},Object.defineProperty(h.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),h.prototype.getState=function(){var v=k.prototype.getState.call(this);return v.typeName=h.typeName,v},h.prototype.restoreState=function(v){k.prototype.restoreState.call(this,v),this.createTips(),this.adjustVisual()},h.typeName="MeasurementMarker",h.title="Measurement marker",h.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>',h}(Ne),We=function(k){function h(v,D,F){var P=k.call(this,v,D,F)||this;return P.strokePanel.colors=F.defaultColorSet,P.fillColor="transparent",P}return se(h,k),Object.defineProperty(h.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),h.prototype.getState=function(){var v=k.prototype.getState.call(this);return v.typeName=h.typeName,v},h.typeName="EllipseFrameMarker",h.title="Ellipse frame marker",h.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>',h}(ce),ze=function(){function k(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(k.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),k.prototype.addUndoStep=function(h){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(h)||(this.undoStack.push(h),JSON.stringify(this.lastRedoStep)!==JSON.stringify(h)&&this.redoStack.splice(0,this.redoStack.length))},k.prototype.replaceLastUndoStep=function(h){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=h)},k.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},k.prototype.undo=function(){if(this.undoStack.length>1){var h=this.undoStack.pop();return h!==void 0&&this.redoStack.push(h),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},k.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},k}(),He=function(k){function h(v,D,F){var P=k.call(this,v,D,F)||this;return P.strokeColor="transparent",P.strokeWidth=0,P.strokeDasharray="",P.curveX=0,P.curveY=0,P.manipulationStartCurveX=0,P.manipulationStartCurveY=0,P.setStrokeColor=P.setStrokeColor.bind(P),P.setStrokeWidth=P.setStrokeWidth.bind(P),P.setStrokeDasharray=P.setStrokeDasharray.bind(P),P.positionGrips=P.positionGrips.bind(P),P.addControlGrips=P.addControlGrips.bind(P),P.adjustVisual=P.adjustVisual.bind(P),P.setupControlBox=P.setupControlBox.bind(P),P.resize=P.resize.bind(P),P.strokeColor=F.defaultColor,P.strokeWidth=F.defaultStrokeWidth,P.strokeDasharray=F.defaultStrokeDasharray,P.strokePanel=new we("Line color",F.defaultColorSet,F.defaultColor),P.strokePanel.onColorChanged=P.setStrokeColor,P.strokeWidthPanel=new Be("Line width",F.defaultStrokeWidths,F.defaultStrokeWidth),P.strokeWidthPanel.onWidthChanged=P.setStrokeWidth,P.strokeStylePanel=new je("Line style",F.defaultStrokeDasharrays,F.defaultStrokeDasharray),P.strokeStylePanel.onStyleChanged=P.setStrokeDasharray,P}return se(h,k),h.prototype.ownsTarget=function(v){return!(!k.prototype.ownsTarget.call(this,v)&&v!==this.visual&&v!==this.selectorCurve&&v!==this.visibleCurve&&!this.curveGrip.ownsTarget(v))},h.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},h.prototype.createVisual=function(){this.visual=Y.createGroup(),this.selectorCurve=Y.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=Y.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)},h.prototype.pointerDown=function(v,D){k.prototype.pointerDown.call(this,v,D),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=v.x,this.curveY=v.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(D)&&(this.activeGrip=this.curveGrip,this._state="resize")},h.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),Y.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),Y.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),Y.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},h.prototype.setupControlBox=function(){k.prototype.setupControlBox.call(this),this.curveControlLine1=Y.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=Y.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)},h.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,k.prototype.addControlGrips.call(this)},h.prototype.positionGrips=function(){k.prototype.positionGrips.call(this);var v=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-v/2,this.curveY-v/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()))},h.prototype.manipulate=function(v){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+v.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+v.y-this.manipulationStartY),k.prototype.manipulate.call(this,v)},h.prototype.resize=function(v){this.activeGrip===this.curveGrip&&(this.curveX=v.x,this.curveY=v.y),k.prototype.resize.call(this,v),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},h.prototype.setStrokeColor=function(v){this.strokeColor=v,this.adjustVisual(),this.colorChanged(v)},h.prototype.setStrokeWidth=function(v){this.strokeWidth=v,this.adjustVisual()},h.prototype.setStrokeDasharray=function(v){this.strokeDasharray=v,this.adjustVisual()},h.prototype.scale=function(v,D){this.curveX=this.curveX*v,this.curveY=this.curveY*D,k.prototype.scale.call(this,v,D)},Object.defineProperty(h.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),h.prototype.getState=function(){var v=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},k.prototype.getState.call(this));return v.typeName=h.typeName,v},h.prototype.restoreState=function(v){k.prototype.restoreState.call(this,v);var D=v;this.strokeColor=D.strokeColor,this.strokeWidth=D.strokeWidth,this.strokeDasharray=D.strokeDasharray,this.curveX=D.curveX,this.curveY=D.curveY,this.createVisual(),this.adjustVisual()},h.typeName="CurveMarker",h.title="Curve marker",h.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>',h}(Fe),Xe=function(){function k(h,v){v===void 0&&(v=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=h,this.cancelable=v}return Object.defineProperty(k.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),k.prototype.preventDefault=function(){this._defaultPrevented=!0},k}(),Qe=function(k){function h(v,D,F){var P=k.call(this,v,!1)||this;return P.dataUrl=D,P.state=F,P}return se(h,k),h}(Xe),Ke=function(k){function h(v,D,F){F===void 0&&(F=!1);var P=k.call(this,v,F)||this;return P.marker=D,P}return se(h,k),h}(Xe),rt=function(){function k(){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 k.prototype.addEventListener=function(h,v){this[h].push(v)},k.prototype.removeEventListener=function(h,v){var D=this[h].indexOf(v);D>-1&&this[h].splice(D,1)},k}(),st=function(){function k(h){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new Re,this._isOpen=!1,this.undoRedoManager=new ze,this.renderAtNaturalSize=!1,this.renderImageType="image/png",this.renderMarkersOnly=!1,this.zoomSteps=[1,1.5,2,4],this._zoomLevel=1,this._isResizing=!1,this.prevPanPoint={x:0,y:0},this.eventListeners=new rt,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=k.instanceCounter++,this.styles=new Se(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=h,this.targetRoot=document.body,this.width=h.clientWidth,this.height=h.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(k.prototype,"ALL_MARKER_TYPES",{get:function(){return[Me,ie,te,Ee,We,ce,X,ae,_e,z,Ne,He]},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[Me,ie,te,Ee,ce,X,ae]},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"BASIC_MARKER_TYPES",{get:function(){return[Me,ie,te,Ee,X]},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(h){var v=this;this._availableMarkerTypes.splice(0),h.forEach(function(D){if(typeof D=="string"){var F=v.ALL_MARKER_TYPES.find(function(P){return P.typeName===D});F!==void 0&&v._availableMarkerTypes.push(F)}else v._availableMarkerTypes.push(D)})},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(h){this._zoomLevel=h,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(k.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),k.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),pe.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},k.prototype.show=function(){var h=this;this.styles.styleSheetRoot===void 0&&xe.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=xe.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(v){return v(new Xe(h))})},k.prototype.render=function(){return le(this,void 0,void 0,function(){var h;return de(this,function(v){switch(v.label){case 0:return this.setCurrentMarker(),(h=new Te).naturalSize=this.renderAtNaturalSize,h.imageType=this.renderImageType,h.imageQuality=this.renderImageQuality,h.markersOnly=this.renderMarkersOnly,h.width=this.renderWidth,h.height=this.renderHeight,[4,h.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return v.sent(),[4,h.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,v.sent()]}})})},k.prototype.close=function(h){var v=this;if(h===void 0&&(h=!1),this.isOpen){var D=!1;h||this.eventListeners.beforeclose.forEach(function(F){var P=new Xe(v,!0);F(P),P.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(F){return F(new Xe(v))}),this.detachEvents(),this._isOpen=!1)}},k.prototype.addMarkersToToolbar=function(){for(var h,v=[],D=0;D<arguments.length;D++)v[D]=arguments[D];(h=this._availableMarkerTypes).push.apply(h,v)},k.prototype.addRenderEventListener=function(h){this.addEventListener("render",function(v){h(v.dataUrl,v.state)})},k.prototype.removeRenderEventListener=function(h){},k.prototype.addCloseEventListener=function(h){this.addEventListener("close",function(){h()})},k.prototype.removeCloseEventListener=function(h){},k.prototype.setupResizeObserver=function(){var h=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){h.resize(h.target.clientWidth,h.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return h.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},k.prototype.onPopupTargetResize=function(){var h=1*this.target.clientWidth/this.target.clientHeight,v=this.editorCanvas.clientWidth/h>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*h:this.editorCanvas.clientWidth,D=v<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/h;this.resize(v,D)},k.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},k.prototype.resize=function(h,v){this._isResizing=!0;var D=h/this.imageWidth,F=v/this.imageHeight;this.imageWidth=Math.round(h),this.imageHeight=Math.round(v),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,F),this._isResizing=!1},k.prototype.scaleMarkers=function(h,v){var D,F=this;this._currentMarker&&this._currentMarker instanceof Ee?this._currentMarker.scale(h,v):(D=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(P){P!==F._currentMarker&&P.scale(h,v)}),D!==void 0&&this.setCurrentMarker(D)},k.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"},k.prototype.setTopLeft=function(){var h=this.editingTarget.getBoundingClientRect(),v=this.editorCanvas.getBoundingClientRect();this.left=h.left-v.left,this.top=h.top-v.top},k.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)},k.prototype.addDefs=function(){for(var h,v=[],D=0;D<arguments.length;D++)v[D]=arguments[D];this.defs=Y.createDefs(),this.addDefsToImage(),(h=this.defs).append.apply(h,v)},k.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},k.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)},k.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},k.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},k.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)},k.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},k.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)},k.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 h=document.createElement("a");h.href="https://markerjs.com/",h.target="_blank",h.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>',h.title="Powered by marker.js",h.style.display="grid",h.style.alignItems="center",h.style.justifyItems="center",h.style.padding="3px",h.style.width="20px",h.style.height="20px",this.logoUI.appendChild(h),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},k.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")},k.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"},k.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},k.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 h=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=h+"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 ve(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 Ce(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},k.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},k.prototype.removeMarker=function(h){this.markerImage.removeChild(h.container),this.markers.indexOf(h)>-1&&this.markers.splice(this.markers.indexOf(h),1),h.dispose()},k.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())},k.prototype.toolbarButtonClicked=function(h,v){if(h==="marker"&&v!==void 0)this.createNewMarker(v);else if(h==="action")switch(v){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()}},k.prototype.deleteSelectedMarker=function(){var h=this;if(this._currentMarker!==void 0){var v=!1;if(this.eventListeners.markerbeforedelete.forEach(function(F){var P=new Ke(h,h._currentMarker,!0);F(P),P.defaultPrevented&&(v=!0)}),!v){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(F){return F(new Ke(h,D))})}}},k.prototype.clear=function(){var h=this,v=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(Z){var ge=new Ke(h,void 0,!0);Z(ge),ge.defaultPrevented&&(v=!0)}),!v)){this.setCurrentMarker();for(var D=function(Z){var ge=F.markers[Z];F.setCurrentMarker(F.markers[Z]),F._currentMarker.dispose(),F.markerImage.removeChild(F._currentMarker.container),F.markers.splice(F.markers.indexOf(F._currentMarker),1),F.eventListeners.markerdelete.forEach(function(De){return De(new Ke(h,ge))})},F=this,P=this.markers.length-1;P>=0;P--)D(P);this.addUndoStep()}},Object.defineProperty(k.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),k.prototype.showNotesEditor=function(){var h;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=(h=this._currentMarker.notes)!==null&&h!==void 0?h:"",this.overlayContainer.appendChild(this.notesArea))},k.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)},k.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},k.prototype.addUndoStep=function(){var h=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var v=this.getState(),D=this.undoRedoManager.getLastUndoStep();if(!D||D.width===v.width&&D.height===v.height){var F=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(v),F<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(P){return P(new Xe(h))})}else this.undoRedoManager.replaceLastUndoStep(v),this.eventListeners.statechange.forEach(function(P){return P(new Xe(h))})}},k.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},k.prototype.undoStep=function(){var h=this,v=this.undoRedoManager.undo();v!==void 0&&(this.restoreState(v),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(D){return D(new Xe(h))}))},k.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},k.prototype.redoStep=function(){var h=this,v=this.undoRedoManager.redo();v!==void 0&&(this.restoreState(v),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(D){return D(new Xe(h))}))},k.prototype.stepZoom=function(){var h=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=h<this.zoomSteps.length-1?this.zoomSteps[h+1]:this.zoomSteps[0]},k.prototype.panTo=function(h){this.contentDiv.scrollBy({left:this.prevPanPoint.x-h.x,top:this.prevPanPoint.y-h.y}),this.prevPanPoint=h},k.prototype.startRenderAndClose=function(){return le(this,void 0,void 0,function(){var h,v,D=this;return de(this,function(F){switch(F.label){case 0:return[4,this.render()];case 1:return h=F.sent(),v=this.getState(),this.eventListeners.render.forEach(function(P){return P(new Qe(D,h,v))}),this.close(!0),[2]}})})},k.prototype.getState=function(h){h===!0&&this.setCurrentMarker();var v={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(D){return v.markers.push(D.getState())}),v},k.prototype.restoreState=function(h){var v=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);h.markers.forEach(function(D){var F=v._availableMarkerTypes.find(function(Z){return Z.typeName===D.typeName});if(F!==void 0){var P=v.addNewMarker(F);P.restoreState(D),v.markers.push(P)}}),h.width&&h.height&&(h.width!==this.imageWidth||h.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/h.width,this.imageHeight/h.height),this.eventListeners.restorestate.forEach(function(D){return D(new Xe(v))})},k.prototype.addNewMarker=function(h){var v=Y.createGroup();return this.markerImage.appendChild(v),new h(v,this.overlayContainer,this.settings)},k.prototype.createNewMarker=function(h){var v,D=this;(v=typeof h=="string"?this._availableMarkerTypes.find(function(F){return F.typeName===h}):h)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(v),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(v.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(F){return F(new Ke(D,D._currentMarker))}))},k.prototype.markerCreated=function(h){var v=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(h),this.setCurrentMarker(h),h instanceof ie&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(ie):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(D){return D(new Ke(v,v._currentMarker))})},k.prototype.colorChanged=function(h){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=h,this.settings.defaultStrokeColor=h)},k.prototype.fillColorChanged=function(h){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=h)},k.prototype.markerStateChanged=function(h){var v=this;this.eventListeners.markerchange.forEach(function(D){return D(new Ke(v,h))})},k.prototype.setCurrentMarker=function(h){var v=this;this._currentMarker!==h&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(D){return D(new Ke(v,v._currentMarker))})),this._currentMarker=h,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 Ke(v,v._currentMarker))}))},k.prototype.onPointerDown=function(h){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||h.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var v=this.markers.find(function(D){return D.ownsTarget(h.target)});v!==void 0?(this.setCurrentMarker(v),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(h.clientX,h.clientY),h.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:h.clientX,y:h.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(h.clientX,h.clientY))},k.prototype.onDblClick=function(h){if(this._isFocused||this.focus(),this.mode==="select"){var v=this.markers.find(function(D){return D.ownsTarget(h.target)});v!==void 0&&v!==this._currentMarker&&this.setCurrentMarker(v),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(h.clientX,h.clientY),h.target):this.setCurrentMarker()}},k.prototype.onPointerMove=function(h){this.touchPoints!==1&&h.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||h.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(h.clientX,h.clientY)):this.zoomLevel>1&&this.panTo({x:h.clientX,y:h.clientY}))},k.prototype.onPointerUp=function(h){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(h.clientX,h.clientY)),this.isDragging=!1,this.addUndoStep()},k.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},k.prototype.onKeyUp=function(h){this._currentMarker===void 0||this.notesArea!==void 0||h.key!=="Delete"&&h.key!=="Backspace"||this.deleteSelectedMarker()},k.prototype.clientToLocalCoordinates=function(h,v){var D=this.markerImage.getBoundingClientRect();return{x:(h-D.left)/this.zoomLevel,y:(v-D.top)/this.zoomLevel}},k.prototype.onWindowResize=function(){this.positionUI()},k.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var h=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=h+"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()},k.prototype.addLicenseKey=function(h){pe.addKey(h)},k.prototype.addEventListener=function(h,v){this.eventListeners.addEventListener(h,v)},k.prototype.removeEventListener=function(h,v){this.eventListeners.removeEventListener(h,v)},k.prototype.renderState=function(h){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(h),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(k.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),k.prototype.focus=function(){var h=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(v){return v(new Xe(h))}))},k.prototype.blur=function(){var h=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(v){return v(new Xe(h))}))},k.instanceCounter=0,k}();/* **********************************
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 ut=function(k,h){return(ut=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,D){v.__proto__=D}||function(v,D){for(var F in D)Object.prototype.hasOwnProperty.call(D,F)&&(v[F]=D[F])})(k,h)};function lt(k,h){if(typeof h!="function"&&h!==null)throw new TypeError("Class extends value "+String(h)+" is not a constructor or null");function v(){this.constructor=k}ut(k,h),k.prototype=h===null?Object.create(h):(v.prototype=h.prototype,new v)}function qe(k,h,v,D){return new(v||(v=Promise))(function(F,P){function Z(Ge){try{De(D.next(Ge))}catch(ye){P(ye)}}function ge(Ge){try{De(D.throw(Ge))}catch(ye){P(ye)}}function De(Ge){var ye;Ge.done?F(Ge.value):(ye=Ge.value,ye instanceof v?ye:new v(function(Ye){Ye(ye)})).then(Z,ge)}De((D=D.apply(k,h||[])).next())})}function pt(k,h){var v,D,F,P,Z={label:0,sent:function(){if(1&F[0])throw F[1];return F[1]},trys:[],ops:[]};return P={next:ge(0),throw:ge(1),return:ge(2)},typeof Symbol=="function"&&(P[Symbol.iterator]=function(){return this}),P;function ge(De){return function(Ge){return function(ye){if(v)throw new TypeError("Generator is already executing.");for(;Z;)try{if(v=1,D&&(F=2&ye[0]?D.return:ye[0]?D.throw||((F=D.return)&&F.call(D),0):D.next)&&!(F=F.call(D,ye[1])).done)return F;switch(D=0,F&&(ye=[2&ye[0],F.value]),ye[0]){case 0:case 1:F=ye;break;case 4:return Z.label++,{value:ye[1],done:!1};case 5:Z.label++,D=ye[1],ye=[0];continue;case 7:ye=Z.ops.pop(),Z.trys.pop();continue;default:if(!(F=Z.trys,(F=F.length>0&&F[F.length-1])||ye[0]!==6&&ye[0]!==2)){Z=0;continue}if(ye[0]===3&&(!F||ye[1]>F[0]&&ye[1]<F[3])){Z.label=ye[1];break}if(ye[0]===6&&Z.label<F[1]){Z.label=F[1],F=ye;break}if(F&&Z.label<F[2]){Z.label=F[2],Z.ops.push(ye);break}F[2]&&Z.ops.pop(),Z.trys.pop();continue}ye=h.call(k,Z)}catch(Ye){ye=[6,Ye],D=0}finally{v=F=0}if(5&ye[0])throw ye[1];return{value:ye[0]?ye[1]:void 0,done:!0}}([De,Ge])}}}var Et=function(){function k(){}return k.addKey=function(h){k.key=h},Object.defineProperty(k,"isLicensed",{get:function(){return!!k.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(k.key)},enumerable:!1,configurable:!0}),k}(),Ie=function(){function k(){}return k.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},k.setAttributes=function(h,v){for(var D=0,F=v;D<F.length;D++){var P=F[D],Z=P[0],ge=P[1];h.setAttribute(Z,ge)}},k.createRect=function(h,v,D){var F=document.createElementNS("http://www.w3.org/2000/svg","rect");return F.setAttribute("width",h.toString()),F.setAttribute("height",v.toString()),D&&k.setAttributes(F,D),F},k.createLine=function(h,v,D,F,P){var Z=document.createElementNS("http://www.w3.org/2000/svg","line");return Z.setAttribute("x1",h.toString()),Z.setAttribute("y1",v.toString()),Z.setAttribute("x2",D.toString()),Z.setAttribute("y2",F.toString()),P&&k.setAttributes(Z,P),Z},k.createPolygon=function(h,v){var D=document.createElementNS("http://www.w3.org/2000/svg","polygon");return D.setAttribute("points",h),v&&k.setAttributes(D,v),D},k.createCircle=function(h,v){var D=document.createElementNS("http://www.w3.org/2000/svg","circle");return D.setAttribute("cx",(h/2).toString()),D.setAttribute("cy",(h/2).toString()),D.setAttribute("r",h.toString()),v&&k.setAttributes(D,v),D},k.createEllipse=function(h,v,D){var F=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return F.setAttribute("cx",(h/2).toString()),F.setAttribute("cy",(v/2).toString()),F.setAttribute("rx",(h/2).toString()),F.setAttribute("ry",(v/2).toString()),D&&k.setAttributes(F,D),F},k.createGroup=function(h){var v=document.createElementNS("http://www.w3.org/2000/svg","g");return h&&k.setAttributes(v,h),v},k.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},k.createMarker=function(h,v,D,F,P,Z,ge){var De=document.createElementNS("http://www.w3.org/2000/svg","marker");return k.setAttributes(De,[["id",h],["orient",v],["markerWidth",D.toString()],["markerHeight",F.toString()],["refX",P.toString()],["refY",Z.toString()]]),De.appendChild(ge),De},k.createText=function(h){var v=document.createElementNS("http://www.w3.org/2000/svg","text");return v.setAttribute("x","0"),v.setAttribute("y","0"),h&&k.setAttributes(v,h),v},k.createTSpan=function(h,v){var D=document.createElementNS("http://www.w3.org/2000/svg","tspan");return D.textContent=h,v&&k.setAttributes(D,v),D},k.createImage=function(h){var v=document.createElementNS("http://www.w3.org/2000/svg","image");return h&&k.setAttributes(v,h),v},k.createPoint=function(h,v){var D=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return D.x=h,D.y=v,D},k.createPath=function(h,v){var D=document.createElementNS("http://www.w3.org/2000/svg","path");return D.setAttribute("d",h),v&&k.setAttributes(D,v),D},k.createElement=function(h,v){var D=document.createElementNS("http://www.w3.org/2000/svg",h);return v&&k.setAttributes(D,v),D},k.getHollowRectanglePath=function(h,v,D,F,P,Z,ge,De){return"M"+h+","+v+"V"+(v+F)+"H"+(h+D)+"V"+v+"H"+P+"V"+Z+"H"+(P+ge)+"V"+(Z+De)+"H"+P+"V"+v+"Z"},k}(),$e=function(){function k(h){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+h+"_"}return Object.defineProperty(k.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(k.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(k.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),k.prototype.addClass=function(h){return this.styleSheet===void 0&&this.addStyleSheet(),h.name=""+this.classNamePrefix+h.localName,this.classes.push(h),this.styleSheet.sheet.insertRule("."+h.name+" {"+h.style+"}",this.styleSheet.sheet.cssRules.length),h},k.prototype.addRule=function(h){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(h),this.styleSheet.sheet.insertRule(h.selector+" {"+h.style+"}",this.styleSheet.sheet.cssRules.length)},k.prototype.addStyleSheet=function(){var h;this.styleSheet=document.createElement("style"),((h=this.styleSheetRoot)!==null&&h!==void 0?h:document.head).appendChild(this.styleSheet),this.addRule(new et("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new et("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new et("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new Ze("_fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new Ze("_fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},k.prototype.removeStyleSheet=function(){var h;this.styleSheet&&(((h=this.styleSheetRoot)!==null&&h!==void 0?h:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},k}(),et=function(k,h){this.selector=k,this.style=h},Ze=function(k,h){this.localName=k,this.style=h},ct=function(){function k(){this.blocks=[],this.display=""}return k.prototype.addButtonBlock=function(h){h.className=this.blockClassName,h.buttonClassName=this.buttonClassName,h.buttonColorsClassName=this.buttonColorsClassName,h.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(h)},k.prototype.addElementBlock=function(h){h.className===void 0&&(h.className=this.blockClassName),this.blocks.push(h)},k.prototype.getUI=function(){var h=document.createElement("div");return h.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,h.style.display=this.display,this.blocks.forEach(function(v){return h.appendChild(v.getUI())}),h},k}(),St=function(){function k(){}return k.prototype.getUI=function(){var h=document.createElement("div");if(h.className=this.className,this.minWidth!==void 0&&(h.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":h.style.justifyContent="flex-start";break;case"center":h.style.justifyContent="center";break;case"end":h.style.justifyContent="flex-end"}return h.style.whiteSpace="nowrap",h},k}(),wt=function(k){function h(){var v=k!==null&&k.apply(this,arguments)||this;return v.buttons=[],v}return lt(h,k),h.prototype.addButton=function(v){v.className=this.buttonClassName,v.colorsClassName=this.buttonColorsClassName,v.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(v)},h.prototype.getUI=function(){var v=k.prototype.getUI.call(this);return this.buttons.forEach(function(D){return v.appendChild(D.getUI())}),v},h}(St),vt=function(){function k(h,v){this._isActive=!1,this._isHidden=!1,this._icon=h,this.title=v,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(k.prototype,"icon",{get:function(){return this._icon},set:function(h){this._icon=h,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isActive",{get:function(){return this._isActive},set:function(h){this._isActive=h,this.adjustClassName()},enumerable:!1,configurable:!0}),k.prototype.getUI=function(){var h=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 h.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},k.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,"")))},k.prototype.hide=function(){this._isHidden=!0},k}(),Pt=function(k){function h(){var v=k!==null&&k.apply(this,arguments)||this;return v.elements=[],v}return lt(h,k),h.prototype.addElement=function(v){this.elements.push(v)},h.prototype.getUI=function(){var v=k.prototype.getUI.call(this);return this.elements.forEach(function(D){return v.appendChild(D)}),v},h}(St),kt=function(){function k(h,v){this.horizontal=h,this.vertical=v}return Object.defineProperty(k.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),k.prototype.getVerticalLength=function(h){return h/this.ratio},k.prototype.getHorizontalLength=function(h){return h*this.ratio},k}(),It=function(){function k(){}return k.getIcon=function(h,v){if(h>0&&v>0){var D=new kt(h,v),F=D.ratio>=1?20:D.getHorizontalLength(20),P=D.ratio<1?20:D.getVerticalLength(20),Z=document.createElementNS("http://www.w3.org/2000/svg","svg");Z.setAttribute("xmlns","http://www.w3.org/2000/svg"),Z.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(Z);var ge=Ie.createDefs();Z.appendChild(ge);var De=Ie.createElement("clipPath",[["id","text-bg-clip"]]);ge.appendChild(De);var Ge=Ie.createPath(Ie.getHollowRectanglePath((24-F)/2,(24-P)/2,F,P,(24-F)/2+2,(24-P)/2+2,F-4,P-4));Z.appendChild(Ge);var ye=Ie.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);ye.appendChild(Ie.createTSpan(h+":"+v)),Z.appendChild(ye);var Ye=ye.getBBox();Ie.setAttributes(ye,[["x",((24-Ye.width)/2).toString()],["y",((24-Ye.height)/2-Ye.y).toString()]]);var it=Ie.createPath(Ie.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(Ye.width))/2,(24-Math.ceil(Ye.height))/2,Math.ceil(Ye.width),Math.ceil(Ye.height)));return De.appendChild(it),Ie.setAttributes(Ge,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(Z),Z.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>'},k}(),Ft=function(k){function h(v,D,F){var P=k.call(this,v,D)||this;return P.isDropdownOpen=!1,P.onClick=P.dropdownButtonClicked,P.dropdownButtons=F,P}return lt(h,k),h.prototype.setupDropdown=function(){var v=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=v.className,D.colorsClassName=v.colorsClassName,v.dropdownBlock.appendChild(D.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},h.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},h.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},h.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},h.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},h.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},h}(vt),Ct=function(){function k(h,v){this.GRIP_SIZE=10,this.color=h,this.fillColor=v,this.visual=Ie.createGroup(),this.visual.appendChild(Ie.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(Ie.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return k.prototype.ownsTarget=function(h){return h===this.visual||h===this.visual.childNodes[0]||h===this.visual.childNodes[1]},k.prototype.setCenter=function(h,v){this.visual.childNodes.forEach(function(D){return Ie.setAttributes(D,[["cx",h.toString()],["cy",v.toString()]])})},k}(),jt=function(){function k(h,v,D,F){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=h,this.canvasHeight=v,this.margin=D,this.container=F,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(k.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(h){this._aspectRatio=h,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(h){this._isGridVisible=h,this.gridContainer&&Ie.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(h){this._zoomFactor=h,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),k.prototype.open=function(){var h=this;this.cropShadeElement=Ie.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=Ie.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var v=0;v<this.numberOfGridLines;v++)this.horizontalGridLines.push(Ie.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(Ie.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(D){return h.gridContainer.appendChild(D)}),this.verticalGridLines.forEach(function(D){return h.gridContainer.appendChild(D)}),this.cropRectElement=Ie.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new Ct(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new Ct(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new Ct(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new Ct(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},k.prototype.setCropRectangle=function(h){this.cropRect=h;var v=Object.assign({},this.cropRect);this.zoomFactor!==1&&(v.width=this.cropRect.width*this.zoomFactor,v.height=this.cropRect.height*this.zoomFactor,v.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-v.width/2,v.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-v.height/2),Ie.setAttributes(this.cropRectElement,[["x",v.x.toString()],["y",v.y.toString()],["width",v.width.toString()],["height",v.height.toString()]]);var D=v.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(P,Z){var ge=v.y+D*(Z+1);Ie.setAttributes(P,[["x1",""+v.x],["y1",""+ge],["x2",""+(v.x+v.width)],["y2",""+ge]])});var F=v.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(P,Z){var ge=v.x+F*(Z+1);Ie.setAttributes(P,[["x1",""+ge],["y1",""+v.y],["x2",""+ge],["y2",""+(v.y+v.height)]])}),Ie.setAttributes(this.cropShadeElement,[["d",Ie.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,v.x,v.y,v.width,v.height)]]),this.topLeftGrip.setCenter(v.x,v.y),this.topRightGrip.setCenter(v.x+v.width,v.y),this.bottomLeftGrip.setCenter(v.x,v.y+v.height),this.bottomRightGrip.setCenter(v.x+v.width,v.y+v.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},k.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)},k.prototype.clientToLocalCoordinates=function(h,v){var D=this.container.getBoundingClientRect();return{x:h-D.left+this.margin,y:v-D.top+this.margin}},k.prototype.onPointerDown=function(h){this.container.setPointerCapture(h.pointerId),this.previousPoint=this.clientToLocalCoordinates(h.clientX,h.clientY),this.cropRectElement===h.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(h.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(h.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(h.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(h.target)&&(this.activeGrip=this.bottomRightGrip)},k.prototype.onPointerMove=function(h){if(this.isMoving)this.move(this.clientToLocalCoordinates(h.clientX,h.clientY));else if(this.activeGrip){var v=this.clientToLocalCoordinates(h.clientX,h.clientY);this.resize(v)}h.preventDefault()},k.prototype.onPointerUp=function(h){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(h.pointerId)},k.prototype.move=function(h){var v=h.x-this.previousPoint.x,D=h.y-this.previousPoint.y;this.zoomFactor!==1&&(v=-v/this.zoomFactor,D=-D/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+v),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=h},k.prototype.resize=function(h){var v=Object.assign({},this.cropRect),D=h.x-this.previousPoint.x,F=h.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:v.x+D<this.margin&&(D=this.margin-v.x),v.x+=D,v.width=this.cropRect.x+this.cropRect.width-v.x;break;case this.bottomRightGrip:case this.topRightGrip:v.width+D>this.canvasWidth*this.zoomFactor&&(D=this.canvasWidth*this.zoomFactor-v.width),v.width+=D}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(v.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(D),v.height=this.aspectRatio.getVerticalLength(v.width)):(v.y+=F,v.height=this.cropRect.y+this.cropRect.height-v.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?v.height=this.aspectRatio.getVerticalLength(v.width):v.height+=F}v.width<10&&(v.x=this.cropRect.x,v.width=10),v.height<10&&(v.y=this.cropRect.y,v.height=10),this.previousPoint=h,v.x>=this.margin&&v.y>=this.margin&&v.x-this.margin+v.width<=this.canvasWidth&&v.y-this.margin+v.height<=this.canvasHeight&&(this.cropRect=v,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},k.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var h=this.cropRect.x+this.cropRect.width/2,v=this.cropRect.y+this.cropRect.height/2,D=this.aspectRatio.getHorizontalLength(this.cropRect.height),F=this.aspectRatio.getVerticalLength(this.cropRect.width);D/this.canvasWidth<F/this.canvasHeight?this.cropRect.width=D:this.cropRect.height=F,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=h-this.cropRect.width/2,this.cropRect.y=v-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)}},k.prototype.getRescaledRect=function(h,v,D,F,P,Z){var ge=D/h,De=F/v;return{x:(P.x-Z)*ge+Z,y:(P.y-Z)*De+Z,width:P.width*ge,height:P.height*De}},k.prototype.scaleCanvas=function(h,v){var D=this.getRescaledRect(this.canvasWidth,this.canvasHeight,h,v,this.cropRect,this.margin);this.canvasWidth=h,this.canvasHeight=v,this.onCropChange&&this.onCropChange(D),this.setCropRectangle(D)},k}(),Ht=function(){function k(h){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=h,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(k.prototype,"angle",{get:function(){return this._angle},set:function(h){this._angle=h,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),k.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},k.prototype.onPointerDown=function(h){this.controlContainer.setPointerCapture(h.pointerId),this.isDragging=!0,this.previousPoint={x:h.clientX,y:h.clientY}},k.prototype.onPointerMove=function(h){this.isDragging&&(this.onAngleChange&&this.onAngleChange((h.clientX-this.previousPoint.x)/5),this.previousPoint.x=h.clientX)},k.prototype.onPointerUp=function(h){this.isDragging&&this.onAngleChange&&this.onAngleChange((h.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(h.pointerId)},k.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var h=this.angleLabelText.getBBox();Ie.setAttributes(this.angleLabelElement,[["x",((this.width-h.width)/2).toString()],["y",(this.height/2).toString()]])}},k.prototype.positionScaleShape=function(){if(this.scaleShape){var h=this.scaleShape.transform.baseVal.getItem(0);h.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(h,0)}},k.prototype.getVisual=function(){var h=document.createElementNS("http://www.w3.org/2000/svg","svg");h.setAttribute("xmlns","http://www.w3.org/2000/svg"),h.setAttribute("width",this.width+"px"),h.setAttribute("height",this.height+"px"),h.setAttribute("viewBox","0 0 "+this.width+" "+this.height),h.style.flexShrink="0",document.body.appendChild(h);for(var v="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,D=1;D<=this.width/5+10;D++){var F=D%5==0?this.height/3:this.height/6;v+="h4v"+-F+"h1v"+F}v+="v1H0Z",this.scaleShape=Ie.createPath(v);var P=Ie.createTransform();this.scaleShape.transform.baseVal.appendItem(P),h.appendChild(this.scaleShape),this.angleLabelElement=Ie.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=Ie.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var Z=Ie.createTSpan("");return Z.innerHTML="&deg;",this.angleLabelElement.appendChild(Z),h.appendChild(this.angleLabelElement),document.body.removeChild(h),h},k}(),Wt=function(){function k(){this.naturalSize=!1,this.imageType="image/png"}return k.prototype.rasterize=function(h,v,D,F,P,Z,ge){var De=this;return new Promise(function(Ge){var ye=document.createElement("canvas");ye.width=h.width.baseVal.value-2*F,ye.height=h.height.baseVal.value-2*F;var Ye=1,it=1;De.naturalSize===!0?(Ye=v.naturalWidth/(h.width.baseVal.value-2*F)/Z,it=v.naturalHeight/(h.height.baseVal.value-2*F)/ge,ye.width=v.naturalWidth/Z,ye.height=v.naturalHeight/ge):De.width!==void 0&&De.height!==void 0&&(Ye=De.width/D.width,it=De.height/D.height,ye.width*=Ye,ye.height*=it);var at=ye.getContext("2d");at.translate(ye.width/2,ye.height/2),at.rotate(P*Math.PI/180),at.scale(Z,ge),at.translate(-ye.width/2,-ye.height/2),at.drawImage(v,0,0,ye.width,ye.height);var yt=document.createElement("canvas");yt.width=D.width*Ye,yt.height=D.height*it,yt.getContext("2d").putImageData(at.getImageData((D.x-F)*Ye,(D.y-F)*it,D.width*Ye,D.height*it),0,0),Ge(yt.toDataURL(De.imageType,De.imageQuality))})},k}(),Gt=function(){function k(h){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=k.instanceCounter++,this.styles=new $e(this.instanceNo),this.target=h,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(k.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(h){this._zoomToCropEnabled=h,h?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(h){this._isGridVisible=h,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"gridLines",{get:function(){return this._gridLines},set:function(h){this._gridLines=h,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(h){this._rotationAngle=h,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"aspectRatio",{get:function(){var h;return(h=this._aspectRatio)!==null&&h!==void 0?h:this.aspectRatios[0]},set:function(h){this._aspectRatio=h},enumerable:!1,configurable:!0}),k.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},k.prototype.show=function(){this.showUI(),this.open()},k.prototype.close=function(h){h===void 0&&(h=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),h||this.closeEventListeners.forEach(function(v){return v()}),this._isOpen=!1)},k.prototype.addRenderEventListener=function(h){this.renderEventListeners.push(h)},k.prototype.removeRenderEventListener=function(h){this.renderEventListeners.indexOf(h)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(h),1)},k.prototype.addCloseEventListener=function(h){this.closeEventListeners.push(h)},k.prototype.removeCloseEventListener=function(h){this.closeEventListeners.indexOf(h)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(h),1)},k.prototype.setupResizeObserver=function(){var h=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){h.resize(h.target.clientWidth,h.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))},k.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var h=1*this.target.clientWidth/this.target.clientHeight,v=this.contentDiv.clientWidth/h>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*h:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,D=v+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/h;this.resize(v,D)}},k.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},k.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",Ie.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},k.prototype.resize=function(h,v){this.imageWidth=Math.round(h),this.imageHeight=Math.round(v),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()},k.prototype.setEditingTarget=function(){var h=document.createElement("canvas");h.width=this.target.naturalWidth,h.height=this.target.naturalHeight,h.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var v=h.toDataURL();Ie.setAttributes(this.editingTarget,[["href",v]]),this.setEditingTargetSize()},k.prototype.setTopLeft=function(){var h=this.target.getBoundingClientRect(),v=this.editorCanvas.getBoundingClientRect();this.left=h.left-v.left-this.CANVAS_MARGIN,this.top=h.top-v.top-this.CANVAS_MARGIN},k.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=Ie.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=Ie.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=Ie.createGroup(),this.editingTargetRotationScaleContainer=Ie.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var h=Ie.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(h);var v=Ie.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(v),this.editingTargetContainer=Ie.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)},k.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},k.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=Ie.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new jt(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()},k.prototype.zoomToCrop=function(){if(this.cropRect){var h=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,v=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=h+"px "+v+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-h+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-v+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},k.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)},k.prototype.cropRectChanged=function(h){this.cropRect=h,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},k.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},k.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"},k.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},k.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 h=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,v=this.target.offsetTop>h+this.CANVAS_MARGIN?this.target.offsetTop-(h+this.CANVAS_MARGIN):0;this.coverDiv.style.top=v+"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},k.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},k.prototype.addTopToolbar=function(){var h=this;this.topToolbar=new ct,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 v=new wt;v.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(v);var D=[];this.aspectRatios.forEach(function(it){var at=new vt(It.getIcon(it.horizontal,it.vertical),it.horizontal===0&&it.vertical===0?"FREE":it.horizontal+":"+it.vertical);at.onClick=function(){return h.ratioButtonClicked(it)},D.push(at)}),this.aspectRatioButton=new Ft(It.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,v.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var F=new vt('<svg viewBox="0 0 24 24"><path d="M10 4v4h4V4h-4m6 0v4h4V4h-4m0 6v4h4v-4h-4m0 6v4h4v-4h-4m-2 4v-4h-4v4h4m-6 0v-4H4v4h4m0-6v-4H4v4h4m0-6V4H4v4h4m2 6h4v-4h-4v4M4 2h16a2 2 0 012 2v16a2 2 0 01-2 2H4c-1.08 0-2-.9-2-2V4a2 2 0 012-2z"/></svg>',"Toggle grid");F.isActive=this.isGridVisible,F.onClick=function(){h.isGridVisible=!h.isGridVisible,F.isActive=h.isGridVisible},v.addButton(F);var P=new vt('<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"Zoom to selection");if(P.isActive=this.zoomToCropEnabled,P.onClick=function(){h.zoomToCropEnabled=!h.zoomToCropEnabled,P.isActive=h.zoomToCropEnabled},v.addButton(P),!Et.isLicensed){var Z=new Pt;this.topToolbar.addElementBlock(Z);var ge=document.createElement("div");ge.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var De=document.createElement("a");De.style.color="currentColor",De.href="https://markerjs.com/products/cropro",De.target="_blank",De.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>',ge.appendChild(De),Z.addElement(ge)}var Ge=new wt;Ge.minWidth=3*this.toolbarHeight+"px",Ge.contentAlign="end",this.topToolbar.addButtonBlock(Ge);var ye=new vt('<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"OK");ye.onClick=this.startRenderAndClose,Ge.addButton(ye),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(ye.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var Ye=new vt('<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"Close");Ye.onClick=this.close,Ge.addButton(Ye),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(Ye.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},k.prototype.addBottomToolbar=function(){var h=this;this.bottomToolbar=new ct,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 v=new wt;v.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(v);var D=new vt('<svg viewBox="0 0 24 24"><path d="M13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93M7.1 18.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32M6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47m1.02-4.47L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47z"/></svg>',"Rotate left");D.onClick=this.rotateLeftButtonClicked,v.addButton(D);var F=new vt('<svg viewBox="0 0 24 24"><path d="M16.89 15.5l1.42 1.39c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.5M13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03m6.93-6.9a7.906 7.906 0 00-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47m-2.36-5.45L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45z"/></svg>',"Rotate right");F.onClick=this.rotateRightButtonClicked,v.addButton(F);var P=new Pt;P.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(P),this.straightener=new Ht("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(Ge){h.rotateBy(Ge),h.straightener.angle=h.rotationAngle},P.addElement(this.straightener.getUI());var Z=new wt;Z.minWidth=2*this.toolbarHeight+"px",Z.contentAlign="end",this.bottomToolbar.addButtonBlock(Z);var ge=new vt('<svg viewBox="0 0 24 24"><path d="M15 21h2v-2h-2m4-10h2V7h-2M3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2m16-2v2h2c0-1.1-.9-2-2-2m-8 20h2V1h-2m8 16h2v-2h-2M15 5h2V3h-2m4 10h2v-2h-2m0 10c1.1 0 2-.9 2-2h-2z"/></svg>',"Flip horizontal");ge.onClick=this.flipHorizontallyButtonClicked,Z.addButton(ge);var De=new vt('<svg viewBox="0 0 24 24"><path d="M3 15v2h2v-2m10 4v2h2v-2m2-16H5c-1.1 0-2 .9-2 2v4h2V5h14v4h2V5c0-1.1-.9-2-2-2m2 16h-2v2c1.1 0 2-.9 2-2M1 11v2h22v-2M7 19v2h2v-2m10-4v2h2v-2m-10 4v2h2v-2M3 19c0 1.1.9 2 2 2v-2z"/></svg>',"Flip vertical");De.onClick=this.flipVerticallyButtonClicked,Z.addButton(De)},k.prototype.ratioButtonClicked=function(h){this.aspectRatio=h,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},k.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=It.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},k.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new kt(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},k.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},k.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},k.prototype.restoreState=function(h){if(h){var v=this.cropLayer.getRescaledRect(h.width,h.height,this.imageWidth,this.imageHeight,h.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(v),this.cropRectChanged(v),this.flippedHorizontally=h.flippedHorizontally,this.flippedVertically=h.flippedVertically,this.applyFlip(),this.rotationAngle=h.rotationAngle,this.applyRotation()}},k.prototype.clientToLocalCoordinates=function(h,v){var D=this.cropImage.getBoundingClientRect();return{x:h-D.left,y:v-D.top}},k.prototype.onWindowResize=function(){this.positionUI()},k.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var h=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=h+"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()},k.prototype.rotateLeftButtonClicked=function(){var h=this.rotationAngle-90;this.rotationAngle%90!=0&&(h+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(h)},k.prototype.rotateRightButtonClicked=function(){var h=this.rotationAngle+90;this.rotationAngle%90!=0&&(h-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(h)},k.prototype.rotateTo=function(h){h=(h=h>180?h-360:h)<=-180?h+360:h,this.rotationAngle=h,this.applyRotation()},k.prototype.rotateBy=function(h){this.rotateTo((this.rotationAngle+h)%360)},k.prototype.applyRotation=function(){var h=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var v=this.editingTargetRotationContainer.transform.baseVal.getItem(0);v.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(v,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=h},k.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},k.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},k.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},k.prototype.startRenderAndClose=function(){return qe(this,void 0,void 0,function(){var h,v;return pt(this,function(D){switch(D.label){case 0:return[4,this.render()];case 1:return h=D.sent(),v=this.getState(),this.renderEventListeners.forEach(function(F){return F(h,v)}),this.close(!0),[2]}})})},k.prototype.render=function(){return qe(this,void 0,void 0,function(){var h;return pt(this,function(v){switch(v.label){case 0:return(h=new Wt).naturalSize=this.renderAtNaturalSize,h.imageType=this.renderImageType,h.imageQuality=this.renderImageQuality,h.width=this.renderWidth,h.height=this.renderHeight,this.unzoomFromCrop(),Ie.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,h.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 v.sent(),[4,h.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,v.sent()]}})})},k.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new Ze("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 Ze("toolbar_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarBlockStyleClass=this.styles.addClass(new Ze("toolbar-block",`
display: flex;
align-items: center;
box-sizing: content-box;
`));var h=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new Ze("toolbar_button",`
display: inline-block;
width: `+(this.toolbarHeight-2*h)+`px;
height: `+(this.toolbarHeight-2*h)+`px;
padding: `+h+`px;
cursor: default;
user-select: none;
box-sizing: content-box;
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new Ze("toolbar_button_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new Ze("toolbar_active_button",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
`)),this.styles.addRule(new et("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.toolbarHeight/2+`px;
`)),this.styles.addRule(new et("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new Ze("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 Ze("toolbar_dropdown_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new Ze("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 Ze("toolbar_straightener",`
display: flex;
overflow: hidden;
justify-content: center;
height: `+(this.toolbarHeight-2*h)+`px;
padding: `+h+`px;
cursor: default;
user-select: none;
box-sizing: content-box;
`)),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new Ze("toolbar_straightener_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`))},k.instanceCounter=0,k}(),Kt=ee("8hTe"),Mt=ee.n(Kt),zt=/<pre[^>]*>/g;function Vt(k){var h=document.createElement("div");return h.innerHTML=k,h.childNodes.length===0?"":h.childNodes[0].nodeValue}var ii=Ve.a=function(k){var h=k.value,v=h===void 0?"":h,D=k.edit,F=D===void 0?!1:D,P=k.className,Z=k.showTextOnly,ge=k.showLines,De=k.replaces,Ge=k.zoomImg,ye=k.hasMask,Ye=k.style,it=Ye===void 0?{}:Ye,at=k.stylesPrev,yt=at===void 0?{}:at,Tt=String(v),ft=Object(S.useRef)(),_t=Object(S.useRef)(),Yt=Object(S.useState)(""),Nt=Object(B.a)(Yt,2),Rt=Nt[0],xt=Nt[1],Xt=Object(S.useState)("office"),Ut=Object(B.a)(Xt,2),$t=Ut[0],At=Ut[1],Qt=function(){var nt=new Gt(_t.current);nt.displayMode="popup",nt.addRenderEventListener(function(){var mt=Object(O.a)(A.a.mark(function tt(gt){var ot;return A.a.wrap(function(dt){for(;;)switch(dt.prev=dt.next){case 0:return ft.current.style.display="none",dt.next=3,Object(ue.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:gt}});case 3:ot=dt.sent,ot!=null&&ot.id&&De(_t.current.getAttribute("src").replace(K.a.API_SERVER,""),"/api/attachments/".concat(ot==null?void 0:ot.id,"?type=").concat(ot.content_type));case 5:case"end":return dt.stop()}},tt)}));return function(tt){return mt.apply(this,arguments)}}()),nt.show()},Jt=function(){var nt=new st(_t.current);nt.settings.displayMode="popup",nt.addEventListener("render",function(){var mt=Object(O.a)(A.a.mark(function tt(gt){var ot;return A.a.wrap(function(dt){for(;;)switch(dt.prev=dt.next){case 0:if(ft.current.style.display="none",!_t.current){dt.next=6;break}return dt.next=4,Object(ue.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:gt.dataUrl}});case 4:ot=dt.sent,ot!=null&&ot.id&&De(_t.current.getAttribute("src").replace(K.a.API_SERVER,""),"/api/attachments/".concat(ot==null?void 0:ot.id,"?type=").concat(ot.content_type));case 6:case"end":return dt.stop()}},tt)}));return function(tt){return mt.apply(this,arguments)}}()),nt.show(),window.markerArea=nt},Ot=Object(S.useMemo)(function(){ft.current&&(ft.current.style.zIndex=-1);try{var ht=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,nt=/\"\/api\/attachments\/|\"\/attachments\/download\//g,mt=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;Tt=Tt.replace(ht,"("+K.a.API_SERVER+"/api/attachments/").replace(nt,'"'+K.a.API_SERVER+"/api/attachments/").replace(mt,'"'+K.a.API_SERVER+"/files/uploads/").replaceAll("http://video.educoder","https://video.educoder").replaceAll("http://www.educoder.net/api","https://data.educoder.net/api").replaceAll("https://www.educoder.net/api","https://data.educoder.net/api").replace(/\r\n/g,`
`)}catch(Dt){}var tt=U(Tt),gt=f();if(Tt.match(/\[TOC\]/)&&(tt=tt.replace("<p>[TOC]</p>",E()),T()),tt=tt.replace(/(__special_katext_id_\d+__)/g,function(Dt,dt){var Bt=gt[dt],ei=Bt.type,ti=Bt.expression;return Object($.renderToString)(Vt(ti)||"",{displayMode:ei==="block",throwOnError:!1,output:"html"})}),tt=tt.replace(/▁/g,"\u2581\u2581\u2581"),c(),Z){var ot=document.createElement("div");return ot.innerHTML=tt,ot.innerText}return setTimeout(function(){return Zt()},500),tt},[Tt]),bt=Object(S.useRef)();_.WebkitLineClamp=ge,ge&&(it=Object(I.a)(Object(I.a)({},it),_));function Lt(ht){var nt=ht.target;if(nt.tagName.toUpperCase()==="IMG"){if(Ge){var mt=nt.getAttribute("src");xt(mt),At("image")}}else if(nt.tagName.toUpperCase()==="A"){var tt=nt.getAttribute("href");if(tt.indexOf("office")>-1)ht.preventDefault(),xt(tt),At("office");else if(tt.indexOf("application/pdf")>-1)ht.preventDefault(),xt(tt),At("pdf");else if(tt.indexOf("text/html")>-1)ht.preventDefault(),xt(tt),At("html");else if(tt.startsWith("#")){ht.preventDefault();var gt=document.getElementById(tt.replace("#",""));gt&&gt.scrollIntoView(!0)}}}var Zt=function(){var nt,mt=(nt=bt.current)===null||nt===void 0?void 0:nt.querySelectorAll("video");mt==null||mt.forEach(function(tt){if(tt.oncontextmenu=function(){return!1},tt.src.indexOf(".m3u8")>-1&&!tt.canPlayType("application/vnd.apple.mpegurl")){if(H.a.isSupported()){var gt=new H.a;gt.loadSource(tt.src),gt.attachMedia(tt)}}})};Object(S.useEffect)(function(){if(bt.current&&Ot&&(Ot.match(zt)&&window.PR.prettyPrint()),bt.current)return bt.current.addEventListener("click",Lt),function(){bt.current.removeEventListener("click",Lt),c(),T()}},[Ot,bt.current,Lt]);var qt=function(nt){if(!F)return;nt.target.nodeName==="IMG"?(ft.current.style.zIndex=1,ft.current.style.display="flex",ft.current.style.width=nt.target.clientWidth+"px",ft.current.style.height=nt.target.clientHeight+"px",ft.current.style.top=nt.target.offsetTop+"px",ft.current.style.left=nt.target.offsetLeft+"px",_t.current.src=nt.target.getAttribute("src")):ft.current.style.display="none"};return p.a.createElement("div",{style:{position:"relative"}},p.a.createElement("div",{ref:bt,style:Object(I.a)({},it),className:"".concat(P||""," markdown-body ").concat(Mt.a.mdBody),onMouseOver:qt,dangerouslySetInnerHTML:{__html:Ot}}),p.a.createElement("div",{ref:ft,className:Mt.a.button},p.a.createElement(G.a,null,p.a.createElement(j.a,{onClick:function(){return Qt()}},"\u88C1\u526A"),p.a.createElement(j.a,{onClick:function(){return Jt()}},"\u7F16\u8F91"))),p.a.createElement("img",{ref:_t,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),p.a.createElement(Q.a,{close:!0,data:Rt,type:Rt!=null&&Rt.length?$t:"",style:Object(I.a)({},yt),onClose:function(){return xt("")}}))}},BU3w:function(Je,Ve,ee){"use strict";ee.d(Ve,"a",function(){return O});var he=ee("MNnm"),G="rc-util-key";function w(B){if(B.attachTo)return B.attachTo;var M=document.querySelector("head");return M||document.body}function j(B){var M,A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Object(he.a)())return null;var S=document.createElement("style");if((M=A.csp)===null||M===void 0?void 0:M.nonce){var p;S.nonce=(p=A.csp)===null||p===void 0?void 0:p.nonce}S.innerHTML=B;var m=w(A),s=m.firstChild;return A.prepend&&m.prepend?m.prepend(S):A.prepend&&s?m.insertBefore(S,s):m.appendChild(S),S}var I=new Map;function O(B,M){var A=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},S=w(A);if(!I.has(S)){var p=j("",A),m=p.parentNode;I.set(S,m),m.removeChild(p)}var s=Array.from(I.get(S).children).find(function(t){return t.tagName==="STYLE"&&t[G]===M});if(s){var r,n;if(((r=A.csp)===null||r===void 0?void 0:r.nonce)&&s.nonce!==((n=A.csp)===null||n===void 0?void 0:n.nonce)){var u;s.nonce=(u=A.csp)===null||u===void 0?void 0:u.nonce}return s.innerHTML!==B&&(s.innerHTML=B),s}var o=j(B,A);return o[G]=M,o}},BdwD:function(Je,Ve,ee){"use strict";var he=ee("+L6B"),G=ee("2/Rp"),w=ee("0Owb"),j=ee("k1fw"),I=ee("q1tI"),O=ee.n(I),B=ee("FOrL"),M=ee.n(B),A=function(p){var m=p.buttonProps,s=m===void 0?{}:m,r=p.styles,n=r===void 0?{}:r,u=p.customText,o=p.ButtonText,t=p.ButtonClick,e=p.Buttonclass,i=p.ButtonTwo;return O.a.createElement("section",{className:"tc animated fadeIn",style:Object(j.a)(Object(j.a)({},{color:"#999",margin:"200px auto"}),n)},O.a.createElement("img",{src:M.a}),O.a.createElement("p",{className:"mt20 font14"},u||"\u6682\u65F6\u8FD8\u6CA1\u6709\u76F8\u5173\u6570\u636E\u54E6!"),o&&O.a.createElement(G.a,Object(w.a)({className:e,onClick:t},s),o),i&&i)};Ve.a=A},DlQD:function(Je,Ve,ee){(function(he,G){Je.exports=G()})(this,function(){"use strict";function he(ie,J){for(var te=0;te<J.length;te++){var z=J[te];z.enumerable=z.enumerable||!1,z.configurable=!0,"value"in z&&(z.writable=!0),Object.defineProperty(ie,z.key,z)}}function G(ie,J,te){return J&&he(ie.prototype,J),te&&he(ie,te),ie}function w(ie,J){if(!ie)return;if(typeof ie=="string")return j(ie,J);var te=Object.prototype.toString.call(ie).slice(8,-1);if(te==="Object"&&ie.constructor&&(te=ie.constructor.name),te==="Map"||te==="Set")return Array.from(ie);if(te==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(te))return j(ie,J)}function j(ie,J){(J==null||J>ie.length)&&(J=ie.length);for(var te=0,z=new Array(J);te<J;te++)z[te]=ie[te];return z}function I(ie,J){var te;if(typeof Symbol=="undefined"||ie[Symbol.iterator]==null){if(Array.isArray(ie)||(te=w(ie))||J&&ie&&typeof ie.length=="number"){te&&(ie=te);var z=0;return function(){return z>=ie.length?{done:!0}:{done:!1,value:ie[z++]}}}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=ie[Symbol.iterator](),te.next.bind(te)}function O(ie,J){return J={exports:{}},ie(J,J.exports),J.exports}var B=O(function(ie){function J(){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(z){ie.exports.defaults=z}ie.exports={defaults:J(),getDefaults:J,changeDefaults:te}}),M=B.defaults,A=B.getDefaults,S=B.changeDefaults,p=/[&<>"']/,m=/[&<>"']/g,s=/[<>"']|&(?!#?\w+;)/,r=/[<>"']|&(?!#?\w+;)/g,n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},u=function(J){return n[J]};function o(ie,J){if(J){if(p.test(ie))return ie.replace(m,u)}else if(s.test(ie))return ie.replace(r,u);return ie}var t=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function e(ie){return ie.replace(t,function(J,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 i=/(^|[^\[])\^/g;function T(ie,J){ie=ie.source||ie,J=J||"";var te={replace:function(V,X){return X=X.source||X,X=X.replace(i,"$1"),ie=ie.replace(V,X),te},getRegex:function(){return new RegExp(ie,J)}};return te}var _=/[^\w:]/g,y=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function E(ie,J,te){if(ie){var z;try{z=decodeURIComponent(e(te)).replace(_,"").toLowerCase()}catch(V){return null}if(z.indexOf("javascript:")===0||z.indexOf("vbscript:")===0||z.indexOf("data:")===0)return null}J&&!y.test(te)&&(te=l(J,te));try{te=encodeURI(te).replace(/%25/g,"%")}catch(V){return null}return te}var b={},g=/^[^:]+:\/*[^/]*$/,d=/^([^:]+:)[\s\S]*$/,a=/^([^:]+:\/*[^/]*)[\s\S]*$/;function l(ie,J){b[" "+ie]||(g.test(ie)?b[" "+ie]=ie+"/":b[" "+ie]=R(ie,"/",!0)),ie=b[" "+ie];var te=ie.indexOf(":")===-1;return J.substring(0,2)==="//"?te?J:ie.replace(d,"$1")+J:J.charAt(0)==="/"?te?J:ie.replace(a,"$1")+J:ie+J}var f={exec:function(){}};function c(ie){for(var J=1,te,z;J<arguments.length;J++){te=arguments[J];for(z in te)Object.prototype.hasOwnProperty.call(te,z)&&(ie[z]=te[z])}return ie}function x(ie,J){var te=ie.replace(/\|/g,function(X,q,ae){for(var ce=!1,_e=q;--_e>=0&&ae[_e]==="\\";)ce=!ce;return ce?"|":" |"}),z=te.split(/ \|/),V=0;if(z.length>J)z.splice(J);else for(;z.length<J;)z.push("");for(;V<z.length;V++)z[V]=z[V].trim().replace(/\\\|/g,"|");return z}function R(ie,J,te){var z=ie.length;if(z===0)return"";for(var V=0;V<z;){var X=ie.charAt(z-V-1);if(X===J&&!te)V++;else if(X!==J&&te)V++;else break}return ie.substr(0,z-V)}function C(ie,J){if(ie.indexOf(J[1])===-1)return-1;for(var te=ie.length,z=0,V=0;V<te;V++)if(ie[V]==="\\")V++;else if(ie[V]===J[0])z++;else if(ie[V]===J[1]&&(z--,z<0))return V;return-1}function N(ie){ie&&ie.sanitize&&!ie.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 U={escape:o,unescape:e,edit:T,cleanUrl:E,resolveUrl:l,noopTest:f,merge:c,splitCells:x,rtrim:R,findClosingBracket:C,checkSanitizeDeprecation:N},W=B.defaults,L=U.rtrim,H=U.splitCells,K=U.escape,$=U.findClosingBracket;function Q(ie,J,te){var z=J.href,V=J.title?K(J.title):null,X=ie[1].replace(/\\([\[\]])/g,"$1");return ie[0].charAt(0)!=="!"?{type:"link",raw:te,href:z,title:V,text:X}:{type:"image",raw:te,href:z,title:V,text:K(X)}}function ue(ie,J){var te=ie.match(/^(\s+)(?:```)/);if(te===null)return J;var z=te[1];return J.split(`
`).map(function(V){var X=V.match(/^\s+/);if(X===null)return V;var q=X[0];return q.length>=z.length?V.slice(z.length):V}).join(`
`)}var ne=function(){function ie(te){this.options=te||W}var J=ie.prototype;return J.space=function(z){var V=this.rules.block.newline.exec(z);if(V)return V[0].length>1?{type:"space",raw:V[0]}:{raw:`
`}},J.code=function(z,V){var X=this.rules.block.code.exec(z);if(X){var q=V[V.length-1];if(q&&q.type==="paragraph")return{raw:X[0],text:X[0].trimRight()};var ae=X[0].replace(/^ {4}/gm,"");return{type:"code",raw:X[0],codeBlockStyle:"indented",text:this.options.pedantic?ae:L(ae,`
`)}}},J.fences=function(z){var V=this.rules.block.fences.exec(z);if(V){var X=V[0],q=ue(X,V[3]||"");return{type:"code",raw:X,lang:V[2]?V[2].trim():V[2],text:q}}},J.heading=function(z){var V=this.rules.block.heading.exec(z);if(V)return{type:"heading",raw:V[0],depth:V[1].length,text:V[2]}},J.nptable=function(z){var V=this.rules.block.nptable.exec(z);if(V){var X={type:"table",header:H(V[1].replace(/^ *| *\| *$/g,"")),align:V[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:V[3]?V[3].replace(/\n$/,"").split(`
`):[],raw:V[0]};if(X.header.length===X.align.length){var q=X.align.length,ae;for(ae=0;ae<q;ae++)/^ *-+: *$/.test(X.align[ae])?X.align[ae]="right":/^ *:-+: *$/.test(X.align[ae])?X.align[ae]="center":/^ *:-+ *$/.test(X.align[ae])?X.align[ae]="left":X.align[ae]=null;for(q=X.cells.length,ae=0;ae<q;ae++)X.cells[ae]=H(X.cells[ae],X.header.length);return X}}},J.hr=function(z){var V=this.rules.block.hr.exec(z);if(V)return{type:"hr",raw:V[0]}},J.blockquote=function(z){var V=this.rules.block.blockquote.exec(z);if(V){var X=V[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:V[0],text:X}}},J.list=function(z){var V=this.rules.block.list.exec(z);if(V){for(var X=V[0],q=V[2],ae=q.length>1,ce=q[q.length-1]===")",_e={type:"list",raw:X,ordered:ae,start:ae?+q.slice(0,-1):"",loose:!1,items:[]},We=V[0].match(this.rules.block.item),ze=!1,He,Xe,Qe,Ke,rt,st,ut,lt=We.length,qe=0;qe<lt;qe++)He=We[qe],X=He,Xe=He.length,He=He.replace(/^ *([*+-]|\d+[.)]) */,""),~He.indexOf(`
`)&&(Xe-=He.length,He=this.options.pedantic?He.replace(/^ {1,4}/gm,""):He.replace(new RegExp("^ {1,"+Xe+"}","gm"),"")),qe!==lt-1&&(Qe=this.rules.block.bullet.exec(We[qe+1])[0],(ae?Qe.length===1||!ce&&Qe[Qe.length-1]===")":Qe.length>1||this.options.smartLists&&Qe!==q)&&(Ke=We.slice(qe+1).join(`
`),_e.raw=_e.raw.substring(0,_e.raw.length-Ke.length),qe=lt-1)),rt=ze||/\n\n(?!\s*$)/.test(He),qe!==lt-1&&(ze=He.charAt(He.length-1)===`
`,rt||(rt=ze)),rt&&(_e.loose=!0),st=/^\[[ xX]\] /.test(He),ut=void 0,st&&(ut=He[1]!==" ",He=He.replace(/^\[[ xX]\] +/,"")),_e.items.push({type:"list_item",raw:X,task:st,checked:ut,loose:rt,text:He});return _e}},J.html=function(z){var V=this.rules.block.html.exec(z);if(V)return{type:this.options.sanitize?"paragraph":"html",raw:V[0],pre:!this.options.sanitizer&&(V[1]==="pre"||V[1]==="script"||V[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(V[0]):K(V[0]):V[0]}},J.def=function(z){var V=this.rules.block.def.exec(z);if(V){V[3]&&(V[3]=V[3].substring(1,V[3].length-1));var X=V[1].toLowerCase().replace(/\s+/g," ");return{tag:X,raw:V[0],href:V[2],title:V[3]}}},J.table=function(z){var V=this.rules.block.table.exec(z);if(V){var X={type:"table",header:H(V[1].replace(/^ *| *\| *$/g,"")),align:V[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:V[3]?V[3].replace(/\n$/,"").split(`
`):[]};if(X.header.length===X.align.length){X.raw=V[0];var q=X.align.length,ae;for(ae=0;ae<q;ae++)/^ *-+: *$/.test(X.align[ae])?X.align[ae]="right":/^ *:-+: *$/.test(X.align[ae])?X.align[ae]="center":/^ *:-+ *$/.test(X.align[ae])?X.align[ae]="left":X.align[ae]=null;for(q=X.cells.length,ae=0;ae<q;ae++)X.cells[ae]=H(X.cells[ae].replace(/^ *\| *| *\| *$/g,""),X.header.length);return X}}},J.lheading=function(z){var V=this.rules.block.lheading.exec(z);if(V)return{type:"heading",raw:V[0],depth:V[2].charAt(0)==="="?1:2,text:V[1]}},J.paragraph=function(z){var V=this.rules.block.paragraph.exec(z);if(V)return{type:"paragraph",raw:V[0],text:V[1].charAt(V[1].length-1)===`
`?V[1].slice(0,-1):V[1]}},J.text=function(z,V){var X=this.rules.block.text.exec(z);if(X){var q=V[V.length-1];return q&&q.type==="text"?{raw:X[0],text:X[0]}:{type:"text",raw:X[0],text:X[0]}}},J.escape=function(z){var V=this.rules.inline.escape.exec(z);if(V)return{type:"escape",raw:V[0],text:K(V[1])}},J.tag=function(z,V,X){var q=this.rules.inline.tag.exec(z);if(q)return!V&&/^<a /i.test(q[0])?V=!0:V&&/^<\/a>/i.test(q[0])&&(V=!1),!X&&/^<(pre|code|kbd|script)(\s|>)/i.test(q[0])?X=!0:X&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(q[0])&&(X=!1),{type:this.options.sanitize?"text":"html",raw:q[0],inLink:V,inRawBlock:X,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(q[0]):K(q[0]):q[0]}},J.link=function(z){var V=this.rules.inline.link.exec(z);if(V){var X=$(V[2],"()");if(X>-1){var q=V[0].indexOf("!")===0?5:4,ae=q+V[1].length+X;V[2]=V[2].substring(0,X),V[0]=V[0].substring(0,ae).trim(),V[3]=""}var ce=V[2],_e="";if(this.options.pedantic){var We=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(ce);We?(ce=We[1],_e=We[3]):_e=""}else _e=V[3]?V[3].slice(1,-1):"";ce=ce.trim().replace(/^<([\s\S]*)>$/,"$1");var ze=Q(V,{href:ce&&ce.replace(this.rules.inline._escapes,"$1"),title:_e&&_e.replace(this.rules.inline._escapes,"$1")},V[0]);return ze}},J.reflink=function(z,V){var X;if((X=this.rules.inline.reflink.exec(z))||(X=this.rules.inline.nolink.exec(z))){var q=(X[2]||X[1]).replace(/\s+/g," ");if(q=V[q.toLowerCase()],!q||!q.href){var ae=X[0].charAt(0);return{type:"text",raw:ae,text:ae}}var ce=Q(X,q,X[0]);return ce}},J.strong=function(z,V,X){X===void 0&&(X="");var q=this.rules.inline.strong.start.exec(z);if(q&&(!q[1]||q[1]&&(X===""||this.rules.inline.punctuation.exec(X)))){V=V.slice(-1*z.length);var ae=q[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;ae.lastIndex=0;for(var ce;(q=ae.exec(V))!=null;)if(ce=this.rules.inline.strong.middle.exec(V.slice(0,q.index+3)),ce)return{type:"strong",raw:z.slice(0,ce[0].length),text:z.slice(2,ce[0].length-2)}}},J.em=function(z,V,X){X===void 0&&(X="");var q=this.rules.inline.em.start.exec(z);if(q&&(!q[1]||q[1]&&(X===""||this.rules.inline.punctuation.exec(X)))){V=V.slice(-1*z.length);var ae=q[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;ae.lastIndex=0;for(var ce;(q=ae.exec(V))!=null;)if(ce=this.rules.inline.em.middle.exec(V.slice(0,q.index+2)),ce)return{type:"em",raw:z.slice(0,ce[0].length),text:z.slice(1,ce[0].length-1)}}},J.codespan=function(z){var V=this.rules.inline.code.exec(z);if(V){var X=V[2].replace(/\n/g," "),q=/[^ ]/.test(X),ae=X.startsWith(" ")&&X.endsWith(" ");return q&&ae&&(X=X.substring(1,X.length-1)),X=K(X,!0),{type:"codespan",raw:V[0],text:X}}},J.br=function(z){var V=this.rules.inline.br.exec(z);if(V)return{type:"br",raw:V[0]}},J.del=function(z){var V=this.rules.inline.del.exec(z);if(V)return{type:"del",raw:V[0],text:V[1]}},J.autolink=function(z,V){var X=this.rules.inline.autolink.exec(z);if(X){var q,ae;return X[2]==="@"?(q=K(this.options.mangle?V(X[1]):X[1]),ae="mailto:"+q):(q=K(X[1]),ae=q),{type:"link",raw:X[0],text:q,href:ae,tokens:[{type:"text",raw:q,text:q}]}}},J.url=function(z,V){var X;if(X=this.rules.inline.url.exec(z)){var q,ae;if(X[2]==="@")q=K(this.options.mangle?V(X[0]):X[0]),ae="mailto:"+q;else{var ce;do ce=X[0],X[0]=this.rules.inline._backpedal.exec(X[0])[0];while(ce!==X[0]);q=K(X[0]),X[1]==="www."?ae="http://"+q:ae=q}return{type:"link",raw:X[0],text:q,href:ae,tokens:[{type:"text",raw:q,text:q}]}}},J.inlineText=function(z,V,X){var q=this.rules.inline.text.exec(z);if(q){var ae;return V?ae=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(q[0]):K(q[0]):q[0]:ae=K(this.options.smartypants?X(q[0]):q[0]),{type:"text",raw:q[0],text:ae}}},ie}(),se=U.noopTest,le=U.edit,de=U.merge,re={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:se,table:se,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};re._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,re._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,re.def=le(re.def).replace("label",re._label).replace("title",re._title).getRegex(),re.bullet=/(?:[*+-]|\d{1,9}[.)])/,re.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,re.item=le(re.item,"gm").replace(/bull/g,re.bullet).getRegex(),re.list=le(re.list).replace(/bull/g,re.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+re.def.source+")").getRegex(),re._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",re._comment=/<!--(?!-?>)[\s\S]*?-->/,re.html=le(re.html,"i").replace("comment",re._comment).replace("tag",re._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),re.paragraph=le(re._paragraph).replace("hr",re.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",re._tag).getRegex(),re.blockquote=le(re.blockquote).replace("paragraph",re.paragraph).getRegex(),re.normal=de({},re),re.gfm=de({},re.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*|$)"}),re.gfm.nptable=le(re.gfm.nptable).replace("hr",re.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",re._tag).getRegex(),re.gfm.table=le(re.gfm.table).replace("hr",re.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",re._tag).getRegex(),re.pedantic=de({},re.normal,{html:le(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",re._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:se,paragraph:le(re.normal._paragraph).replace("hr",re.hr).replace("heading",` *#{1,6} *[^
]`).replace("lheading",re.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var Y={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:se,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:se,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};Y._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",Y.punctuation=le(Y.punctuation).replace(/punctuation/g,Y._punctuation).getRegex(),Y._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",Y._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",Y.em.start=le(Y.em.start).replace(/punctuation/g,Y._punctuation).getRegex(),Y.em.middle=le(Y.em.middle).replace(/punctuation/g,Y._punctuation).replace(/overlapSkip/g,Y._overlapSkip).getRegex(),Y.em.endAst=le(Y.em.endAst,"g").replace(/punctuation/g,Y._punctuation).getRegex(),Y.em.endUnd=le(Y.em.endUnd,"g").replace(/punctuation/g,Y._punctuation).getRegex(),Y.strong.start=le(Y.strong.start).replace(/punctuation/g,Y._punctuation).getRegex(),Y.strong.middle=le(Y.strong.middle).replace(/punctuation/g,Y._punctuation).replace(/blockSkip/g,Y._blockSkip).getRegex(),Y.strong.endAst=le(Y.strong.endAst,"g").replace(/punctuation/g,Y._punctuation).getRegex(),Y.strong.endUnd=le(Y.strong.endUnd,"g").replace(/punctuation/g,Y._punctuation).getRegex(),Y.blockSkip=le(Y._blockSkip,"g").getRegex(),Y.overlapSkip=le(Y._overlapSkip,"g").getRegex(),Y._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,Y._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,Y._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])?)+(?![-_])/,Y.autolink=le(Y.autolink).replace("scheme",Y._scheme).replace("email",Y._email).getRegex(),Y._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,Y.tag=le(Y.tag).replace("comment",re._comment).replace("attribute",Y._attribute).getRegex(),Y._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Y._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,Y._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,Y.link=le(Y.link).replace("label",Y._label).replace("href",Y._href).replace("title",Y._title).getRegex(),Y.reflink=le(Y.reflink).replace("label",Y._label).getRegex(),Y.reflinkSearch=le(Y.reflinkSearch,"g").replace("reflink",Y.reflink).replace("nolink",Y.nolink).getRegex(),Y.normal=de({},Y),Y.pedantic=de({},Y.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:le(/^!?\[(label)\]\((.*?)\)/).replace("label",Y._label).getRegex(),reflink:le(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Y._label).getRegex()}),Y.gfm=de({},Y.normal,{escape:le(Y.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),Y.gfm.url=le(Y.gfm.url,"i").replace("email",Y.gfm._extended_email).getRegex(),Y.breaks=de({},Y.gfm,{br:le(Y.br).replace("{2,}","*").getRegex(),text:le(Y.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var pe={block:re,inline:Y},Te=B.defaults,xe=pe.block,Se=pe.inline;function Ae(ie){return ie.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 fe(ie){var J="",te,z,V=ie.length;for(te=0;te<V;te++)z=ie.charCodeAt(te),Math.random()>.5&&(z="x"+z.toString(16)),J+="&#"+z+";";return J}var ve=function(){function ie(te){this.tokens=[],this.tokens.links=Object.create(null),this.options=te||Te,this.options.tokenizer=this.options.tokenizer||new ne,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var z={block:xe.normal,inline:Se.normal};this.options.pedantic?(z.block=xe.pedantic,z.inline=Se.pedantic):this.options.gfm&&(z.block=xe.gfm,this.options.breaks?z.inline=Se.breaks:z.inline=Se.gfm),this.tokenizer.rules=z}ie.lex=function(z,V){var X=new ie(V);return X.lex(z)};var J=ie.prototype;return J.lex=function(z){return z=z.replace(/\r\n|\r/g,`
`).replace(/\t/g," "),this.blockTokens(z,this.tokens,!0),this.inline(this.tokens),this.tokens},J.blockTokens=function(z,V,X){V===void 0&&(V=[]),X===void 0&&(X=!0),z=z.replace(/^ +$/gm,"");for(var q,ae,ce,_e;z;){if(q=this.tokenizer.space(z)){z=z.substring(q.raw.length),q.type&&V.push(q);continue}if(q=this.tokenizer.code(z,V)){z=z.substring(q.raw.length),q.type?V.push(q):(_e=V[V.length-1],_e.raw+=`
`+q.raw,_e.text+=`
`+q.text);continue}if(q=this.tokenizer.fences(z)){z=z.substring(q.raw.length),V.push(q);continue}if(q=this.tokenizer.heading(z)){z=z.substring(q.raw.length),V.push(q);continue}if(q=this.tokenizer.nptable(z)){z=z.substring(q.raw.length),V.push(q);continue}if(q=this.tokenizer.hr(z)){z=z.substring(q.raw.length),V.push(q);continue}if(q=this.tokenizer.blockquote(z)){z=z.substring(q.raw.length),q.tokens=this.blockTokens(q.text,[],X),V.push(q);continue}if(q=this.tokenizer.list(z)){for(z=z.substring(q.raw.length),ce=q.items.length,ae=0;ae<ce;ae++)q.items[ae].tokens=this.blockTokens(q.items[ae].text,[],!1);V.push(q);continue}if(q=this.tokenizer.html(z)){z=z.substring(q.raw.length),V.push(q);continue}if(X&&(q=this.tokenizer.def(z))){z=z.substring(q.raw.length),this.tokens.links[q.tag]||(this.tokens.links[q.tag]={href:q.href,title:q.title});continue}if(q=this.tokenizer.table(z)){z=z.substring(q.raw.length),V.push(q);continue}if(q=this.tokenizer.lheading(z)){z=z.substring(q.raw.length),V.push(q);continue}if(X&&(q=this.tokenizer.paragraph(z))){z=z.substring(q.raw.length),V.push(q);continue}if(q=this.tokenizer.text(z,V)){z=z.substring(q.raw.length),q.type?V.push(q):(_e=V[V.length-1],_e.raw+=`
`+q.raw,_e.text+=`
`+q.text);continue}if(z){var We="Infinite loop on byte: "+z.charCodeAt(0);if(this.options.silent){console.error(We);break}else throw new Error(We)}}return V},J.inline=function(z){var V,X,q,ae,ce,_e,We=z.length;for(V=0;V<We;V++){_e=z[V];switch(_e.type){case"paragraph":case"text":case"heading":{_e.tokens=[],this.inlineTokens(_e.text,_e.tokens);break}case"table":{for(_e.tokens={header:[],cells:[]},ae=_e.header.length,X=0;X<ae;X++)_e.tokens.header[X]=[],this.inlineTokens(_e.header[X],_e.tokens.header[X]);for(ae=_e.cells.length,X=0;X<ae;X++)for(ce=_e.cells[X],_e.tokens.cells[X]=[],q=0;q<ce.length;q++)_e.tokens.cells[X][q]=[],this.inlineTokens(ce[q],_e.tokens.cells[X][q]);break}case"blockquote":{this.inline(_e.tokens);break}case"list":{for(ae=_e.items.length,X=0;X<ae;X++)this.inline(_e.items[X].tokens);break}}}return z},J.inlineTokens=function(z,V,X,q,ae){V===void 0&&(V=[]),X===void 0&&(X=!1),q===void 0&&(q=!1),ae===void 0&&(ae="");var ce,_e=z,We;if(this.tokens.links){var ze=Object.keys(this.tokens.links);if(ze.length>0)for(;(We=this.tokenizer.rules.inline.reflinkSearch.exec(_e))!=null;)ze.includes(We[0].slice(We[0].lastIndexOf("[")+1,-1))&&(_e=_e.slice(0,We.index)+"["+"a".repeat(We[0].length-2)+"]"+_e.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(We=this.tokenizer.rules.inline.blockSkip.exec(_e))!=null;)_e=_e.slice(0,We.index)+"["+"a".repeat(We[0].length-2)+"]"+_e.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;z;){if(ce=this.tokenizer.escape(z)){z=z.substring(ce.raw.length),V.push(ce);continue}if(ce=this.tokenizer.tag(z,X,q)){z=z.substring(ce.raw.length),X=ce.inLink,q=ce.inRawBlock,V.push(ce);continue}if(ce=this.tokenizer.link(z)){z=z.substring(ce.raw.length),ce.type==="link"&&(ce.tokens=this.inlineTokens(ce.text,[],!0,q)),V.push(ce);continue}if(ce=this.tokenizer.reflink(z,this.tokens.links)){z=z.substring(ce.raw.length),ce.type==="link"&&(ce.tokens=this.inlineTokens(ce.text,[],!0,q)),V.push(ce);continue}if(ce=this.tokenizer.strong(z,_e,ae)){z=z.substring(ce.raw.length),ce.tokens=this.inlineTokens(ce.text,[],X,q),V.push(ce);continue}if(ce=this.tokenizer.em(z,_e,ae)){z=z.substring(ce.raw.length),ce.tokens=this.inlineTokens(ce.text,[],X,q),V.push(ce);continue}if(ce=this.tokenizer.codespan(z)){z=z.substring(ce.raw.length),V.push(ce);continue}if(ce=this.tokenizer.br(z)){z=z.substring(ce.raw.length),V.push(ce);continue}if(ce=this.tokenizer.del(z)){z=z.substring(ce.raw.length),ce.tokens=this.inlineTokens(ce.text,[],X,q),V.push(ce);continue}if(ce=this.tokenizer.autolink(z,fe)){z=z.substring(ce.raw.length),V.push(ce);continue}if(!X&&(ce=this.tokenizer.url(z,fe))){z=z.substring(ce.raw.length),V.push(ce);continue}if(ce=this.tokenizer.inlineText(z,q,Ae)){z=z.substring(ce.raw.length),ae=ce.raw.slice(-1),V.push(ce);continue}if(z){var He="Infinite loop on byte: "+z.charCodeAt(0);if(this.options.silent){console.error(He);break}else throw new Error(He)}}return V},G(ie,null,[{key:"rules",get:function(){return{block:xe,inline:Se}}}]),ie}(),Ce=B.defaults,Oe=U.cleanUrl,we=U.escape,be=function(){function ie(te){this.options=te||Ce}var J=ie.prototype;return J.code=function(z,V,X){var q=(V||"").match(/\S*/)[0];if(this.options.highlight){var ae=this.options.highlight(z,q);ae!=null&&ae!==z&&(X=!0,z=ae)}return q?'<pre><code class="'+this.options.langPrefix+we(q,!0)+'">'+(X?z:we(z,!0))+`</code></pre>
`:"<pre><code>"+(X?z:we(z,!0))+`</code></pre>
`},J.blockquote=function(z){return`<blockquote>
`+z+`</blockquote>
`},J.html=function(z){return z},J.heading=function(z,V,X,q){return this.options.headerIds?"<h"+V+' id="'+this.options.headerPrefix+q.slug(X)+'">'+z+"</h"+V+`>
`:"<h"+V+">"+z+"</h"+V+`>
`},J.hr=function(){return this.options.xhtml?`<hr/>
`:`<hr>
`},J.list=function(z,V,X){var q=V?"ol":"ul",ae=V&&X!==1?' start="'+X+'"':"";return"<"+q+ae+`>
`+z+"</"+q+`>
`},J.listitem=function(z){return"<li>"+z+`</li>
`},J.checkbox=function(z){return"<input "+(z?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},J.paragraph=function(z){return"<p>"+z+`</p>
`},J.table=function(z,V){return V&&(V="<tbody>"+V+"</tbody>"),`<table>
<thead>
`+z+`</thead>
`+V+`</table>
`},J.tablerow=function(z){return`<tr>
`+z+`</tr>
`},J.tablecell=function(z,V){var X=V.header?"th":"td",q=V.align?"<"+X+' align="'+V.align+'">':"<"+X+">";return q+z+"</"+X+`>
`},J.strong=function(z){return"<strong>"+z+"</strong>"},J.em=function(z){return"<em>"+z+"</em>"},J.codespan=function(z){return"<code>"+z+"</code>"},J.br=function(){return this.options.xhtml?"<br/>":"<br>"},J.del=function(z){return"<del>"+z+"</del>"},J.link=function(z,V,X){if(z=Oe(this.options.sanitize,this.options.baseUrl,z),z===null)return X;var q='<a href="'+we(z)+'"';return V&&(q+=' title="'+V+'"'),q+=">"+X+"</a>",q},J.image=function(z,V,X){if(z=Oe(this.options.sanitize,this.options.baseUrl,z),z===null)return X;var q='<img src="'+z+'" alt="'+X+'"';return V&&(q+=' title="'+V+'"'),q+=this.options.xhtml?"/>":">",q},J.text=function(z){return z},ie}(),me=function(){function ie(){}var J=ie.prototype;return J.strong=function(z){return z},J.em=function(z){return z},J.codespan=function(z){return z},J.del=function(z){return z},J.html=function(z){return z},J.text=function(z){return z},J.link=function(z,V,X){return""+X},J.image=function(z,V,X){return""+X},J.br=function(){return""},ie}(),Ue=function(){function ie(){this.seen={}}var J=ie.prototype;return J.slug=function(z){var V=z.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(V)){var X=V;do this.seen[X]++,V=X+"-"+this.seen[X];while(this.seen.hasOwnProperty(V))}return this.seen[V]=0,V},ie}(),Le=B.defaults,ke=U.unescape,Pe=function(){function ie(te){this.options=te||Le,this.options.renderer=this.options.renderer||new be,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new me,this.slugger=new Ue}ie.parse=function(z,V){var X=new ie(V);return X.parse(z)};var J=ie.prototype;return J.parse=function(z,V){V===void 0&&(V=!0);var X="",q,ae,ce,_e,We,ze,He,Xe,Qe,Ke,rt,st,ut,lt,qe,pt,Et,Ie,$e=z.length;for(q=0;q<$e;q++){Ke=z[q];switch(Ke.type){case"space":continue;case"hr":{X+=this.renderer.hr();continue}case"heading":{X+=this.renderer.heading(this.parseInline(Ke.tokens),Ke.depth,ke(this.parseInline(Ke.tokens,this.textRenderer)),this.slugger);continue}case"code":{X+=this.renderer.code(Ke.text,Ke.lang,Ke.escaped);continue}case"table":{for(Xe="",He="",_e=Ke.header.length,ae=0;ae<_e;ae++)He+=this.renderer.tablecell(this.parseInline(Ke.tokens.header[ae]),{header:!0,align:Ke.align[ae]});for(Xe+=this.renderer.tablerow(He),Qe="",_e=Ke.cells.length,ae=0;ae<_e;ae++){for(ze=Ke.tokens.cells[ae],He="",We=ze.length,ce=0;ce<We;ce++)He+=this.renderer.tablecell(this.parseInline(ze[ce]),{header:!1,align:Ke.align[ce]});Qe+=this.renderer.tablerow(He)}X+=this.renderer.table(Xe,Qe);continue}case"blockquote":{Qe=this.parse(Ke.tokens),X+=this.renderer.blockquote(Qe);continue}case"list":{for(rt=Ke.ordered,st=Ke.start,ut=Ke.loose,_e=Ke.items.length,Qe="",ae=0;ae<_e;ae++)qe=Ke.items[ae],pt=qe.checked,Et=qe.task,lt="",qe.task&&(Ie=this.renderer.checkbox(pt),ut?qe.tokens.length>0&&qe.tokens[0].type==="text"?(qe.tokens[0].text=Ie+" "+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=Ie+" "+qe.tokens[0].tokens[0].text)):qe.tokens.unshift({type:"text",text:Ie}):lt+=Ie),lt+=this.parse(qe.tokens,ut),Qe+=this.renderer.listitem(lt,Et,pt);X+=this.renderer.list(Qe,rt,st);continue}case"html":{X+=this.renderer.html(Ke.text);continue}case"paragraph":{X+=this.renderer.paragraph(this.parseInline(Ke.tokens));continue}case"text":{for(Qe=Ke.tokens?this.parseInline(Ke.tokens):Ke.text;q+1<$e&&z[q+1].type==="text";)Ke=z[++q],Qe+=`
`+(Ke.tokens?this.parseInline(Ke.tokens):Ke.text);X+=V?this.renderer.paragraph(Qe):Qe;continue}default:{var et='Token with "'+Ke.type+'" type was not found.';if(this.options.silent){console.error(et);return}else throw new Error(et)}}}return X},J.parseInline=function(z,V){V=V||this.renderer;var X="",q,ae,ce=z.length;for(q=0;q<ce;q++){ae=z[q];switch(ae.type){case"escape":{X+=V.text(ae.text);break}case"html":{X+=V.html(ae.text);break}case"link":{X+=V.link(ae.href,ae.title,this.parseInline(ae.tokens,V));break}case"image":{X+=V.image(ae.href,ae.title,ae.text);break}case"strong":{X+=V.strong(this.parseInline(ae.tokens,V));break}case"em":{X+=V.em(this.parseInline(ae.tokens,V));break}case"codespan":{X+=V.codespan(ae.text);break}case"br":{X+=V.br();break}case"del":{X+=V.del(this.parseInline(ae.tokens,V));break}case"text":{X+=V.text(ae.text);break}default:{var _e='Token with "'+ae.type+'" type was not found.';if(this.options.silent){console.error(_e);return}else throw new Error(_e)}}}return X},ie}(),Be=U.merge,je=U.checkSanitizeDeprecation,Me=U.escape,Re=B.getDefaults,Fe=B.changeDefaults,Ne=B.defaults;function oe(ie,J,te){if(typeof ie=="undefined"||ie===null)throw new Error("marked(): input parameter is undefined or null");if(typeof ie!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(ie)+", string expected");if(typeof J=="function"&&(te=J,J=null),J=Be({},oe.defaults,J||{}),je(J),te){var z=J.highlight,V;try{V=ve.lex(ie,J)}catch(ce){return te(ce)}var X=function(_e){var We;if(!_e)try{We=Pe.parse(V,J)}catch(ze){_e=ze}return J.highlight=z,_e?te(_e):te(null,We)};if(!z||z.length<3)return X();if(delete J.highlight,!V.length)return X();var q=0;oe.walkTokens(V,function(ce){ce.type==="code"&&(q++,setTimeout(function(){z(ce.text,ce.lang,function(_e,We){if(_e)return X(_e);We!=null&&We!==ce.text&&(ce.text=We,ce.escaped=!0),q--,q===0&&X()})},0))}),q===0&&X();return}try{var ae=ve.lex(ie,J);return J.walkTokens&&oe.walkTokens(ae,J.walkTokens),Pe.parse(ae,J)}catch(ce){if(ce.message+=`
Please report this to https://github.com/markedjs/marked.`,J.silent)return"<p>An error occurred:</p><pre>"+Me(ce.message+"",!0)+"</pre>";throw ce}}oe.options=oe.setOptions=function(ie){return Be(oe.defaults,ie),Fe(oe.defaults),oe},oe.getDefaults=Re,oe.defaults=Ne,oe.use=function(ie){var J=Be({},ie);if(ie.renderer&&function(){var z=oe.defaults.renderer||new be,V=function(ae){var ce=z[ae];z[ae]=function(){for(var _e=arguments.length,We=new Array(_e),ze=0;ze<_e;ze++)We[ze]=arguments[ze];var He=ie.renderer[ae].apply(z,We);return He===!1&&(He=ce.apply(z,We)),He}};for(var X in ie.renderer)V(X);J.renderer=z}(),ie.tokenizer&&function(){var z=oe.defaults.tokenizer||new ne,V=function(ae){var ce=z[ae];z[ae]=function(){for(var _e=arguments.length,We=new Array(_e),ze=0;ze<_e;ze++)We[ze]=arguments[ze];var He=ie.tokenizer[ae].apply(z,We);return He===!1&&(He=ce.apply(z,We)),He}};for(var X in ie.tokenizer)V(X);J.tokenizer=z}(),ie.walkTokens){var te=oe.defaults.walkTokens;J.walkTokens=function(z){ie.walkTokens(z),te&&te(z)}}oe.setOptions(J)},oe.walkTokens=function(ie,J){for(var te=I(ie),z;!(z=te()).done;){var V=z.value;J(V);switch(V.type){case"table":{for(var X=I(V.tokens.header),q;!(q=X()).done;){var ae=q.value;oe.walkTokens(ae,J)}for(var ce=I(V.tokens.cells),_e;!(_e=ce()).done;)for(var We=_e.value,ze=I(We),He;!(He=ze()).done;){var Xe=He.value;oe.walkTokens(Xe,J)}break}case"list":{oe.walkTokens(V.items,J);break}default:V.tokens&&oe.walkTokens(V.tokens,J)}}},oe.Parser=Pe,oe.parser=Pe.parse,oe.Renderer=be,oe.TextRenderer=me,oe.Lexer=ve,oe.lexer=ve.lex,oe.Tokenizer=ne,oe.Slugger=Ue,oe.parse=oe;var Ee=oe;return Ee})},EjUQ:function(Je,Ve,ee){"use strict";ee.r(Ve);var he=ee("DjyN"),G=ee("NUBc"),w=ee("cWXX"),j=ee("/ezw"),I=ee("/zsF"),O=ee("PArb"),B=ee("14J3"),M=ee("BMrR"),A=ee("jCWc"),S=ee("kPKH"),p=ee("k1fw"),m=ee("tJVT"),s=ee("PpiC"),r=ee("B9cy"),n=ee("Ol7k"),u=ee("lUTK"),o=ee("BvKs"),t=ee("q1tI"),e=ee.n(t),i=ee("9kvl"),T=ee("wd/R"),_=ee.n(T),y=ee("m3rI"),E=ee("BdwD"),b=ee("2qtc"),g=ee("kLXV"),d=ee("5NDa"),a=ee("5rEg"),l=ee("jrin"),f=ee("miYZ"),c=ee("tsqr"),x=ee("9og8"),R=ee("y8nQ"),C=ee("Vl3Y"),N=ee("WmNS"),U=ee.n(N),W=ee("5WQS"),L=ee("Ty5D"),H=ee("NDqe"),K=ee.n(H),$=function(Te){var xe,Se=Te.messages,Ae=Te.loading,fe=Te.user,ve=Te.dispatch,Ce=Object(L.i)(),Oe=Object(L.h)(),we=Se.actionTabs,be=C.a.useForm(),me=Object(m.a)(be,1),Ue=me[0],Le=Se.recentContacts,ke=Object(t.useState)(""),Pe=Object(m.a)(ke,2),Be=Pe[0],je=Pe[1],Me=Object(t.useState)([]),Re=Object(m.a)(Me,2),Fe=Re[0],Ne=Re[1],oe=Object(t.useState)(!1),Ee=Object(m.a)(oe,2),ie=Ee[0],J=Ee[1],te=Object(t.useState)(),z=Object(m.a)(te,2),V=z[0],X=z[1];Object(t.useEffect)(function(){Se.actionTabs.key==="\u5199\u79C1\u4FE1"&&q()},[Se.actionTabs.key]);var q=function(){var ce=Object(x.a)(U.a.mark(function _e(){var We,ze;return U.a.wrap(function(Xe){for(;;)switch(Xe.prev=Xe.next){case 0:return Xe.next=2,ve({type:"messages/getRecentContacts",payload:{id:fe==null||((We=fe.userInfo)===null||We===void 0)?void 0:We.user_id,keyword:Be}});case 2:ze=Xe.sent,Ne(Object(p.a)({},ze));case 4:case"end":return Xe.stop()}},_e)}));return function(){return ce.apply(this,arguments)}}(),ae=function(){var ce=Object(x.a)(U.a.mark(function _e(){var We;return U.a.wrap(function(He){for(;;)switch(He.prev=He.next){case 0:if(!(Be!=="")){He.next=5;break}return He.next=3,ve({type:"messages/getUsersForPrivateMessages",payload:{keyword:Be}});case 3:We=He.sent,Ne(Object(p.a)({},We));case 5:case"end":return He.stop()}},_e)}));return function(){return ce.apply(this,arguments)}}();return Object(t.useEffect)(function(){ae()},[Be]),e.a.createElement(g.a,{centered:!0,title:"\u5199\u79C1\u4FE1",visible:Se.actionTabs.key==="\u5199\u79C1\u4FE1",okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",bodyStyle:{height:320},onOk:Object(x.a)(U.a.mark(function ce(){var _e,We,ze,He,Xe,Qe;return U.a.wrap(function(rt){for(;;)switch(rt.prev=rt.next){case 0:return rt.next=2,Ue.validateFields();case 2:return We=Ue.getFieldValue(),ze="/api/course_modules/".concat(Ce.categoryId,"/add_second_category.json"),rt.next=6,Object(W.g)({content:We.content,target_id:V,userId:fe==null||((_e=fe.userInfo)===null||_e===void 0)?void 0:_e.user_id});case 6:He=rt.sent,He.status===0&&(c.b.success("\u6DFB\u52A0\u6210\u529F"),ve({type:"messages/setActionTabs",payload:{}}),i.d.push("/messages/".concat(fe==null||((Xe=fe.userInfo)===null||Xe===void 0)?void 0:Xe.login,"/message_detail?target_ids=").concat(He==null||((Qe=He.private_message)===null||Qe===void 0)?void 0:Qe.receiver_id)));case 8:case"end":return rt.stop()}},ce)})),onCancel:function(){ve({type:"messages/setActionTabs",payload:{}})}},e.a.createElement(C.a,{form:Ue,initialValues:Object(l.a)({},"name","")},e.a.createElement(C.a.Item,{name:"users",rules:[{required:!0,message:"\u8BF7\u9009\u62E9\u53D1\u9001\u5BF9\u8C61"}]},e.a.createElement(a.a.Search,{onFocus:function(){return J(!0)},onSearch:function(_e){je(_e)},placeholder:"\u53D1\u9001\u7ED9..."})),ie&&e.a.createElement(j.a,{loading:Ae["messages/getUsersForPrivateMessages"]},e.a.createElement("aside",{className:K.a.searchWrp,style:{maxHeight:260,overflow:"auto"}},e.a.createElement("p",{className:"c-light-black mt10"},Be===""?"\u6700\u8FD1\u8054\u7CFB\u4EBA":"\u641C\u7D22\u7ED3\u679C"),Fe==null||((xe=Fe.users)===null||xe===void 0)?void 0:xe.map(function(ce,_e){return e.a.createElement(M.a,{key:_e,align:"middle",className:"mt15 current",onClick:function(){X(ce.id),Ue.setFieldsValue({users:ce.name}),J(!1)}},e.a.createElement(S.a,{flex:"58px"},e.a.createElement("img",{style:{width:48,borderRadius:48},src:y.a.IMG_SERVER+"/images/"+(ce==null?void 0:ce.image_url),alt:""})),e.a.createElement(S.a,null,ce.name))}))),e.a.createElement(C.a.Item,{rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u53D1\u9001\u5185\u5BB9"}],className:ie&&"hide",name:"content"},e.a.createElement(a.a.TextArea,{rows:10,maxLength:200}))))},Q=Object(i.a)(function(pe){var Te=pe.messages,xe=pe.loading,Se=pe.user;return{messages:Te,user:Se,loading:xe.effects}})($),ue=ee("9Bee"),ne=ee("30zm"),se=o.a.SubMenu,le=n.a.Sider,de=n.a.Content,re=function(Te){var xe,Se,Ae=Te.messages,fe=Te.globalSetting,ve=Te.loading,Ce=Te.user,Oe=Te.dispatch,we=Object(s.a)(Te,["messages","globalSetting","loading","user","dispatch"]),be=we.match.params,me=Ce.userInfo,Ue=Ae.tidingsList,Le=Ae.privateMessage,ke=Object(t.useState)({per_page:10,page:1}),Pe=Object(m.a)(ke,2),Be=Pe[0],je=Pe[1];Object(t.useEffect)(function(){Be.page=1,Me()},[be.userId]);var Me=function(){Oe({type:"messages/getPrivateMessages",payload:Object(p.a)(Object(p.a)({},Be),be)})},Re=function(Ee){var ie,J;we.history.push("/messages/".concat(Ce==null||((ie=Ce.userInfo)===null||ie===void 0)?void 0:ie.login,"/message_detail?target_ids=").concat(Ee==null||((J=Ee.target)===null||J===void 0)?void 0:J.id))},Fe=function(Ee){var ie;we.history.push("/users/".concat(Ee==null||((ie=Ee.target)===null||ie===void 0)?void 0:ie.login))},Ne=Object(t.useMemo)(function(){return(me==null?void 0:me.is_teacher)&&(me==null?void 0:me.professional_certification)},[me]);return e.a.createElement("section",{className:K.a.bg},e.a.createElement("section",{className:"edu-container mt20"},e.a.createElement(M.a,{gutter:[20,20]},e.a.createElement(ne.a,null),e.a.createElement(S.a,{flex:"1"},e.a.createElement("aside",{className:"bg-white"},e.a.createElement("aside",{className:"pt30 pl30 pr30 font16"},e.a.createElement(M.a,null,e.a.createElement(S.a,{flex:"1"},"\u5168\u90E8\u79C1\u4FE1"),Ne&&e.a.createElement(S.a,null,e.a.createElement("span",{className:"c-blue current",onClick:function(){var Ee;Oe({type:"messages/setActionTabs",payload:{key:"\u5199\u79C1\u4FE1",bodyParams:Object(p.a)(Object(p.a)({},Be),{},{user_id:Ce==null||((Ee=Ce.userInfo)===null||Ee===void 0)?void 0:Ee.user_id})}})}},"\u5199\u79C1\u4FE1")))),e.a.createElement(O.a,null),e.a.createElement("aside",{className:K.a.list},e.a.createElement(j.a,{active:!0,avatar:{size:40},paragraph:{rows:5},loading:ve["messages/getPrivateMessages"]},!(Le!=null&&(xe=Le.private_messages)!==null&&xe!==void 0&&xe.length)&&e.a.createElement(E.a,null),Le==null||((Se=Le.private_messages)===null||Se===void 0)?void 0:Se.map(function(oe,Ee){var ie,J;return e.a.createElement("aside",null,e.a.createElement(M.a,null,e.a.createElement(S.a,{flex:"58px",onClick:function(){return Fe(oe)}},e.a.createElement("img",{src:y.a.IMG_SERVER+"/images/"+(oe==null||((ie=oe.target)===null||ie===void 0)?void 0:ie.image_url),alt:""})),e.a.createElement(S.a,{flex:1},e.a.createElement(M.a,null,e.a.createElement(S.a,{span:24},e.a.createElement(M.a,null,e.a.createElement(S.a,{flex:"1"},e.a.createElement("span",{onClick:function(){return Fe(oe)}},oe==null||((J=oe.target)===null||J===void 0)?void 0:J.name),e.a.createElement("span",{className:"ml15"},"\u4E0E\u4F60\u7684\u79C1\u4FE1"),e.a.createElement("span",{className:"c-light-black mr15"},"[",oe==null?void 0:oe.message_count,"\u6761]"),e.a.createElement("span",{className:"ml15 c-light-black"},_()(oe.send_time).fromNow())),e.a.createElement(S.a,null,(oe==null?void 0:oe.unread)&&e.a.createElement("span",{className:K.a.newlight})))),e.a.createElement(S.a,{span:24,onClick:function(){return Re(oe)}},e.a.createElement("div",{className:"mt15"},e.a.createElement(ue.a,{value:oe.content||""})))))))})))),e.a.createElement("aside",{className:"tc mt20"},!ve["messages/getTidings"]&&e.a.createElement(G.a,{hideOnSinglePage:!0,showSizeChanger:!1,onChange:function(Ee){Be.page=Ee,je(Object(p.a)({},Be)),Me()},current:Be.page||1,total:Le==null?void 0:Le.count}))))),e.a.createElement(Q,null))},Y=Ve.default=Object(i.a)(function(pe){var Te=pe.messages,xe=pe.loading,Se=pe.user,Ae=pe.globalSetting;return{messages:Te,globalSetting:Ae,user:Se,loading:xe.effects}})(re)},FOrL:function(Je,Ve,ee){Je.exports=ee.p+"static/nodata.a6b3f948.png"},LdHM:function(Je,Ve,ee){"use strict";ee.d(Ve,"b",function(){return i}),ee.d(Ve,"a",function(){return _});var he=ee("1OyB"),G=ee("vuIU"),w=ee("Ji7U"),j=ee("LK+K"),I=ee("q1tI"),O=ee("rePB"),B=ee("Ff2n"),M=ee("ODXe"),A=ee("4IlW"),S=ee("bX4T"),p=ee("YrtM"),m=ee("TSYQ"),s=ee.n(m),r=ee("+nKL"),n=ee("8OUc"),u=function(H,K){var $=H.prefixCls,Q=H.id,ue=H.flattenOptions,ne=H.childrenAsData,se=H.values,le=H.searchValue,de=H.multiple,re=H.defaultActiveFirstOption,Y=H.height,pe=H.itemHeight,Te=H.notFoundContent,xe=H.open,Se=H.menuItemSelectedIcon,Ae=H.virtual,fe=H.onSelect,ve=H.onToggleOpen,Ce=H.onActiveValue,Oe=H.onScroll,we=H.onMouseEnter,be="".concat($,"-item"),me=Object(p.a)(function(){return ue},[xe,ue],function(Ee,ie){return ie[0]&&Ee[1]!==ie[1]}),Ue=I.useRef(null),Le=function(ie){ie.preventDefault()},ke=function(ie){Ue.current&&Ue.current.scrollTo({index:ie})},Pe=function(ie){for(var J=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,te=me.length,z=0;z<te;z+=1){var V=(ie+z*J+te)%te,X=me[V],q=X.group,ae=X.data;if(!q&&!ae.disabled)return V}return-1},Be=I.useState(function(){return Pe(0)}),je=Object(M.a)(Be,2),Me=je[0],Re=je[1],Fe=function(ie){Re(ie);var J=me[ie];if(!J){Ce(null,-1);return}Ce(J.data.value,ie)};I.useEffect(function(){Fe(re!==!1?Pe(0):-1)},[me.length,le]),I.useEffect(function(){var Ee=setTimeout(function(){if(!de&&xe&&se.size===1){var ie=Array.from(se)[0],J=me.findIndex(function(te){var z=te.data;return z.value===ie});Fe(J),ke(J)}});return function(){return clearTimeout(Ee)}},[xe]);var Ne=function(ie){ie!==void 0&&fe(ie,{selected:!se.has(ie)}),de||ve(!1)};if(I.useImperativeHandle(K,function(){return{onKeyDown:function(ie){var J=ie.which;switch(J){case A.a.UP:case A.a.DOWN:{var te=0;if(J===A.a.UP?te=-1:J===A.a.DOWN&&(te=1),te!==0){var z=Pe(Me+te,te);ke(z),Fe(z)}break}case A.a.ENTER:{var V=me[Me];V&&!V.data.disabled?Ne(V.data.value):Ne(void 0),xe&&ie.preventDefault();break}case A.a.ESC:ve(!1)}},onKeyUp:function(){},scrollTo:function(ie){ke(ie)}}}),me.length===0)return I.createElement("div",{role:"listbox",id:"".concat(Q,"_list"),className:"".concat(be,"-empty"),onMouseDown:Le},Te);function oe(Ee){var ie=me[Ee];if(!ie)return null;var J=ie.data||{},te=J.value,z=J.label,V=J.children,X=Object(S.a)(J,!0),q=ne?V:z;return ie?I.createElement("div",Object.assign({"aria-label":typeof q=="string"?q:null},X,{key:Ee,role:"option",id:"".concat(Q,"_list_").concat(Ee),"aria-selected":se.has(te)}),te):null}return I.createElement(I.Fragment,null,I.createElement("div",{role:"listbox",id:"".concat(Q,"_list"),style:{height:0,width:0,overflow:"hidden"}},oe(Me-1),oe(Me),oe(Me+1)),I.createElement(r.a,{itemKey:"key",ref:Ue,data:me,height:Y,itemHeight:pe,fullHeight:!1,onMouseDown:Le,onScroll:Oe,virtual:Ae,onMouseEnter:we},function(Ee,ie){var J,te=Ee.group,z=Ee.groupOption,V=Ee.data,X=V.label,q=V.key;if(te)return I.createElement("div",{className:s()(be,"".concat(be,"-group"))},X!==void 0?X:q);var ae=V.disabled,ce=V.value,_e=V.title,We=V.children,ze=V.style,He=V.className,Xe=Object(B.a)(V,["disabled","value","title","children","style","className"]),Qe=se.has(ce),Ke="".concat(be,"-option"),rt=s()(be,Ke,He,(J={},Object(O.a)(J,"".concat(Ke,"-grouped"),z),Object(O.a)(J,"".concat(Ke,"-active"),Me===ie&&!ae),Object(O.a)(J,"".concat(Ke,"-disabled"),ae),Object(O.a)(J,"".concat(Ke,"-selected"),Qe),J)),st=ne?We:X,ut=!Se||typeof Se=="function"||Qe;return I.createElement("div",Object.assign({},Xe,{"aria-selected":Qe,className:rt,title:_e,onMouseMove:function(){if(Me===ie||ae)return;Fe(ie)},onClick:function(){ae||Ne(ce)},style:ze}),I.createElement("div",{className:"".concat(Ke,"-content")},st||ce),I.isValidElement(Se)||Qe,ut&&I.createElement(n.a,{className:"".concat(be,"-option-state"),customizeIcon:Se,customizeIconProps:{isSelected:Qe}},Qe?"\u2713":null))}))},o=I.forwardRef(u);o.displayName="OptionList";var t=o,e=function(){return null};e.isSelectOption=!0;var i=e,T=function(){return null};T.isSelectOptGroup=!0;var _=T,y=ee("VTBJ"),E=ee("Zm9Q");function b(L){var H=L.key,K=L.props,$=K.children,Q=K.value,ue=Object(B.a)(K,["children","value"]);return Object(y.a)({key:H,value:Q!==void 0?Q:H,children:$},ue)}function g(L){var H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(E.a)(L).map(function(K,$){if(!I.isValidElement(K)||!K.type)return null;var Q=K.type.isSelectOptGroup,ue=K.key,ne=K.props,se=ne.children,le=Object(B.a)(ne,["children"]);return H||!Q?b(K):Object(y.a)(Object(y.a)({key:"__RC_SELECT_GRP__".concat(ue===null?$:ue,"__"),label:ue},le),{},{options:g(se)})}).filter(function(K){return K})}var d=ee("2Qr1"),a=ee("qNPg"),l=ee("U8pU"),f=ee("Kwbf"),c=ee("WKfj");function x(L){var H=L.mode,K=L.options,$=L.children,Q=L.backfill,ue=L.allowClear,ne=L.placeholder,se=L.getInputElement,le=L.showSearch,de=L.onSearch,re=L.defaultOpen,Y=L.autoFocus,pe=L.labelInValue,Te=L.value,xe=L.inputValue,Se=L.optionLabelProp,Ae=H==="multiple"||H==="tags",fe=le!==void 0?le:Ae||H==="combobox",ve=K||g($);if(Object(f.a)(H!=="tags"||ve.every(function(be){return!be.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),H==="tags"||H==="combobox"){var Ce=ve.some(function(be){return be.options?be.options.some(function(me){return typeof("value"in me?me.value:me.key)=="number"}):typeof("value"in be?be.value:be.key)=="number"});Object(f.a)(!Ce,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(f.a)(H!=="combobox"||!Se,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(f.a)(H==="combobox"||!Q,"`backfill` only works with `combobox` mode."),Object(f.a)(H==="combobox"||!se,"`getInputElement` only work with `combobox` mode."),Object(f.b)(H!=="combobox"||!se||!ue||!ne,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),de&&!fe&&H!=="combobox"&&H!=="tags"&&Object(f.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(f.b)(!re||Y,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),Te!=null){var Oe=Object(c.d)(Te);Object(f.a)(!pe||Oe.every(function(be){return Object(l.a)(be)==="object"&&("key"in be||"value"in be)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(f.a)(!Ae||Array.isArray(Te),"`value` should be array when `mode` is `multiple` or `tags`")}if($){var we=null;Object(E.a)($).some(function(be){if(!I.isValidElement(be)||!be.type)return!1;var me=be.type;if(me.isSelectOption)return!1;if(me.isSelectOptGroup){var Ue=Object(E.a)(be.props.children).every(function(Le){return!I.isValidElement(Le)||!be.type||Le.type.isSelectOption?!0:(we=Le.type,!1)});return!Ue}return we=me,!0}),we&&Object(f.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(we.displayName||we.name||we,"`.")),Object(f.a)(xe===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var R=x,C=Object(a.a)({prefixCls:"rc-select",components:{optionList:t},convertChildrenToData:g,flattenOptions:d.d,getLabeledValue:d.e,filterOptions:d.b,isValueDisabled:d.g,findValueOption:d.c,warningProps:R,fillOptionsWithMissingValue:d.a}),N=function(L){Object(w.a)(K,L);var H=Object(j.a)(K);function K(){var $;return Object(he.a)(this,K),$=H.apply(this,arguments),$.selectRef=I.createRef(),$.focus=function(){$.selectRef.current.focus()},$.blur=function(){$.selectRef.current.blur()},$}return Object(G.a)(K,[{key:"render",value:function(){return I.createElement(C,Object.assign({ref:this.selectRef},this.props))}}]),K}(I.Component);N.Option=i,N.OptGroup=_;var U=N,W=Ve.c=U},NDqe:function(Je,Ve,ee){Je.exports={flex_box_center:"flex_box_center___3oYZ2",flex_space_between:"flex_space_between___1FifH",flex_box_vertical_center:"flex_box_vertical_center___2iDXN",flex_box_center_end:"flex_box_center_end___2rJ_G",flex_box_column:"flex_box_column___3ucki",tabs:"tabs___3aVAD",active:"active___1eCl8",list:"list___2weuP",tags:"tags___10O8v",searchWrp:"searchWrp___xsrqM",newlight:"newlight___1S7Yv"}},SJMd:function(Je,Ve){/**
* @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 ee,he,G,w=!1,j,I;window.PR_SHOULD_USE_CONTINUATION=!0;var O,B;(function(){var M=window,A=["break,continue,do,else,for,if,return,while"],S=[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"],p=[S,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],m=[p,"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=[p,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],r=[p,"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"],n="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",u=[p,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],o="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",t=[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"],e=[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"],i=[A,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],T=[m,r,s,u,o,t,e,i],_=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,y="str",E="kwd",b="com",g="typ",d="lit",a="pun",l="pln",f="tag",c="dec",x="src",R="atn",C="atv",N="nocode",U="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function W(fe){for(var ve=0,Ce=!1,Oe=!1,we=0,be=fe.length;we<be;++we){var me=fe[we];if(me.ignoreCase)Oe=!0;else if(/[a-z]/i.test(me.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){Ce=!0,Oe=!1;break}}var Ue={b:8,t:9,n:10,v:11,f:12,r:13};function Le(Me){var Re=Me.charCodeAt(0);if(Re!==92)return Re;var Fe=Me.charAt(1);return Re=Ue[Fe],Re||("0"<=Fe&&Fe<="7"?parseInt(Me.substring(1),8):Fe==="u"||Fe==="x"?parseInt(Me.substring(2),16):Me.charCodeAt(1))}function ke(Me){if(Me<32)return(Me<16?"\\x0":"\\x")+Me.toString(16);var Re=String.fromCharCode(Me);return Re==="\\"||Re==="-"||Re==="]"||Re==="^"?"\\"+Re:Re}function Pe(Me){var Re=Me.substring(1,Me.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")),Fe=[],Ne=Re[0]==="^",oe=["["];Ne&&oe.push("^");for(var Ee=Ne?1:0,ie=Re.length;Ee<ie;++Ee){var J=Re[Ee];if(/\\[bdsw]/i.test(J))oe.push(J);else{var te=Le(J),z;Ee+2<ie&&Re[Ee+1]==="-"?(z=Le(Re[Ee+2]),Ee+=2):z=te,Fe.push([te,z]),z<65||te>122||(z<65||te>90||Fe.push([Math.max(65,te)|32,Math.min(z,90)|32]),z<97||te>122||Fe.push([Math.max(97,te)&~32,Math.min(z,122)&~32]))}}Fe.sort(function(ae,ce){return ae[0]-ce[0]||ce[1]-ae[1]});for(var V=[],X=[],Ee=0;Ee<Fe.length;++Ee){var q=Fe[Ee];q[0]<=X[1]+1?X[1]=Math.max(X[1],q[1]):V.push(X=q)}for(var Ee=0;Ee<V.length;++Ee){var q=V[Ee];oe.push(ke(q[0])),q[1]>q[0]&&(q[1]+1>q[0]&&oe.push("-"),oe.push(ke(q[1])))}return oe.push("]"),oe.join("")}function Be(Me){for(var Re=Me.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")),Fe=Re.length,Ne=[],oe=0,Ee=0;oe<Fe;++oe){var ie=Re[oe];if(ie==="(")++Ee;else if(ie.charAt(0)==="\\"){var J=+ie.substring(1);J&&(J<=Ee?Ne[J]=-1:Re[oe]=ke(J))}}for(var oe=1;oe<Ne.length;++oe)Ne[oe]===-1&&(Ne[oe]=++ve);for(var oe=0,Ee=0;oe<Fe;++oe){var ie=Re[oe];if(ie==="(")++Ee,Ne[Ee]||(Re[oe]="(?:");else if(ie.charAt(0)==="\\"){var J=+ie.substring(1);J&&J<=Ee&&(Re[oe]="\\"+Ne[J])}}for(var oe=0;oe<Fe;++oe)Re[oe]==="^"&&Re[oe+1]!=="^"&&(Re[oe]="");if(Me.ignoreCase&&Ce)for(var oe=0;oe<Fe;++oe){var ie=Re[oe],te=ie.charAt(0);ie.length>=2&&te==="["?Re[oe]=Pe(ie):te!=="\\"&&(Re[oe]=ie.replace(/[a-zA-Z]/g,function(X){var q=X.charCodeAt(0);return"["+String.fromCharCode(q&~32,q|32)+"]"}))}return Re.join("")}for(var je=[],we=0,be=fe.length;we<be;++we){var me=fe[we];if(me.global||me.multiline)throw new Error(""+me);je.push("(?:"+Be(me)+")")}return new RegExp(je.join("|"),Oe?"gi":"g")}function L(fe,ve){var Ce=/(?:^|\s)nocode(?:\s|$)/,Oe=[],we=0,be=[],me=0;function Ue(Le){var ke=Le.nodeType;if(ke==1){if(Ce.test(Le.className))return;for(var Pe=Le.firstChild;Pe;Pe=Pe.nextSibling)Ue(Pe);var Be=Le.nodeName.toLowerCase();(Be==="br"||Be==="li")&&(Oe[me]=`
`,be[me<<1]=we++,be[me++<<1|1]=Le)}else if(ke==3||ke==4){var je=Le.nodeValue;je.length&&(ve?je=je.replace(/\r\n?/g,`
`):je=je.replace(/[ \t\r\n]+/g," "),Oe[me]=je,be[me<<1]=we,we+=je.length,be[me++<<1|1]=Le)}}return Ue(fe),{sourceCode:Oe.join("").replace(/\n$/,""),spans:be}}function H(fe,ve,Ce,Oe,we){if(!Ce)return;var be={sourceNode:fe,pre:1,langExtension:null,numberLines:null,sourceCode:Ce,spans:null,basePos:ve,decorations:null};Oe(be),we.push.apply(we,be.decorations)}var K=/\S/;function $(fe){for(var ve=void 0,Ce=fe.firstChild;Ce;Ce=Ce.nextSibling){var Oe=Ce.nodeType;ve=Oe===1?ve?fe:Ce:Oe===3&&K.test(Ce.nodeValue)?fe:ve}return ve===fe?void 0:ve}function Q(fe,ve){var Ce={},Oe;(function(){for(var me=fe.concat(ve),Ue=[],Le={},ke=0,Pe=me.length;ke<Pe;++ke){var Be=me[ke],je=Be[3];if(je)for(var Me=je.length;--Me>=0;)Ce[je.charAt(Me)]=Be;var Re=Be[1],Fe=""+Re;Le.hasOwnProperty(Fe)||(Ue.push(Re),Le[Fe]=null)}Ue.push(/[\0-\uffff]/),Oe=W(Ue)})();var we=ve.length,be=function(me){for(var Ue=me.sourceCode,Le=me.basePos,ke=me.sourceNode,Pe=[Le,l],Be=0,je=Ue.match(Oe)||[],Me={},Re=0,Fe=je.length;Re<Fe;++Re){var Ne=je[Re],oe=Me[Ne],Ee=void 0,ie;if(typeof oe=="string")ie=!1;else{var J=Ce[Ne.charAt(0)];if(J)Ee=Ne.match(J[1]),oe=J[0];else{for(var te=0;te<we;++te)if(J=ve[te],Ee=Ne.match(J[1]),Ee){oe=J[0];break}Ee||(oe=l)}ie=oe.length>=5&&oe.substring(0,5)==="lang-",ie&&!(Ee&&typeof Ee[1]=="string")&&(ie=!1,oe=x),ie||(Me[Ne]=oe)}var z=Be;if(Be+=Ne.length,!ie)Pe.push(Le+z,oe);else{var V=Ee[1],X=Ne.indexOf(V),q=X+V.length;Ee[2]&&(q=Ne.length-Ee[2].length,X=q-V.length);var ae=oe.substring(5);H(ke,Le+z,Ne.substring(0,X),be,Pe),H(ke,Le+z+X,V,Y(ae,V),Pe),H(ke,Le+z+q,Ne.substring(q),be,Pe)}}me.decorations=Pe};return be}function ue(fe){var ve=[],Ce=[];fe.tripleQuotedStrings?ve.push([y,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):fe.multiLineStrings?ve.push([y,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):ve.push([y,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),fe.verbatimStrings&&Ce.push([y,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Oe=fe.hashComments;Oe&&(fe.cStyleComments?(Oe>1?ve.push([b,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):ve.push([b,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),Ce.push([y,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):ve.push([b,/^#[^\r\n]*/,null,"#"])),fe.cStyleComments&&(Ce.push([b,/^\/\/[^\r\n]*/,null]),Ce.push([b,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var we=fe.regexLiterals;if(we){var be=we>1?"":`
\r`,me=be?".":"[\\S\\s]",Ue="/(?=[^/*"+be+"])(?:[^/\\x5B\\x5C"+be+"]|\\x5C"+me+"|\\x5B(?:[^\\x5C\\x5D"+be+"]|\\x5C"+me+")*(?:\\x5D|$))+/";Ce.push(["lang-regex",RegExp("^"+U+"("+Ue+")")])}var Le=fe.types;Le&&Ce.push([g,Le]);var ke=(""+fe.keywords).replace(/^ | $/g,"");ke.length&&Ce.push([E,new RegExp("^(?:"+ke.replace(/[\s,]+/g,"|")+")\\b"),null]),ve.push([l,/^\s+/,null,` \r
\xA0`]);var Pe="^.[^\\s\\w.$@'\"`/\\\\]*";return fe.regexLiterals&&(Pe+="(?!s*/)"),Ce.push([d,/^@[a-z_$][a-z_$@0-9]*/i,null],[g,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[l,/^[a-z_$][a-z_$@0-9]*/i,null],[d,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[l,/^\\[\s\S]?/,null],[a,new RegExp(Pe),null]),Q(ve,Ce)}var ne=ue({keywords:T,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function se(fe,ve,Ce){for(var Oe=/(?:^|\s)nocode(?:\s|$)/,we=/\r\n?|\n/,be=fe.ownerDocument,me=be.createElement("li");fe.firstChild;)me.appendChild(fe.firstChild);var Ue=[me];function Le(Re){var Fe=Re.nodeType;if(Fe==1&&!Oe.test(Re.className))if(Re.nodeName==="br")ke(Re),Re.parentNode&&Re.parentNode.removeChild(Re);else for(var Ne=Re.firstChild;Ne;Ne=Ne.nextSibling)Le(Ne);else if((Fe==3||Fe==4)&&Ce){var oe=Re.nodeValue,Ee=oe.match(we);if(Ee){var ie=oe.substring(0,Ee.index);Re.nodeValue=ie;var J=oe.substring(Ee.index+Ee[0].length);if(J){var te=Re.parentNode;te.insertBefore(be.createTextNode(J),Re.nextSibling)}ke(Re),ie||Re.parentNode.removeChild(Re)}}}function ke(Re){for(;!Re.nextSibling;)if(Re=Re.parentNode,!Re)return;function Fe(Ee,ie){var J=ie?Ee.cloneNode(!1):Ee,te=Ee.parentNode;if(te){var z=Fe(te,1),V=Ee.nextSibling;z.appendChild(J);for(var X=V;X;X=V)V=X.nextSibling,z.appendChild(X)}return J}for(var Ne=Fe(Re.nextSibling,0),oe;(oe=Ne.parentNode)&&oe.nodeType===1;)Ne=oe;Ue.push(Ne)}for(var Pe=0;Pe<Ue.length;++Pe)Le(Ue[Pe]);ve===(ve|0)&&Ue[0].setAttribute("value",ve);var Be=be.createElement("ol");Be.className="linenums";for(var je=Math.max(0,ve-1|0)||0,Pe=0,Me=Ue.length;Pe<Me;++Pe)me=Ue[Pe],me.className="L"+(Pe+je)%10,me.firstChild||me.appendChild(be.createTextNode("\xA0")),Be.appendChild(me);fe.appendChild(Be)}function le(fe){var ve=/\bMSIE\s(\d+)/.exec(navigator.userAgent);ve=ve&&+ve[1]<=8;var Ce=/\n/g,Oe=fe.sourceCode,we=Oe.length,be=0,me=fe.spans,Ue=me.length,Le=0,ke=fe.decorations,Pe=ke.length,Be=0;ke[Pe]=we;var je,Me;for(Me=je=0;Me<Pe;)ke[Me]!==ke[Me+2]?(ke[je++]=ke[Me++],ke[je++]=ke[Me++]):Me+=2;for(Pe=je,Me=je=0;Me<Pe;){for(var Re=ke[Me],Fe=ke[Me+1],Ne=Me+2;Ne+2<=Pe&&ke[Ne+1]===Fe;)Ne+=2;ke[je++]=Re,ke[je++]=Fe,Me=Ne}Pe=ke.length=je;var oe=fe.sourceNode,Ee="";oe&&(Ee=oe.style.display,oe.style.display="none");try{for(var ie=null;Le<Ue;){var J=me[Le],te=me[Le+2]||we,z=ke[Be+2]||we,Ne=Math.min(te,z),V=me[Le+1],X;if(V.nodeType!==1&&(X=Oe.substring(be,Ne))){ve&&(X=X.replace(Ce,"\r")),V.nodeValue=X;var q=V.ownerDocument,ae=q.createElement("span");ae.className=ke[Be+1];var ce=V.parentNode;ce.replaceChild(ae,V),ae.appendChild(V),be<te&&(me[Le+1]=V=q.createTextNode(Oe.substring(Ne,te)),ce.insertBefore(V,ae.nextSibling))}be=Ne,be>=te&&(Le+=2),be>=z&&(Be+=2)}}finally{oe&&(oe.style.display=Ee)}}var de={};function re(fe,ve){for(var Ce=ve.length;--Ce>=0;){var Oe=ve[Ce];de.hasOwnProperty(Oe)?M.console&&console.warn("cannot override language handler %s",Oe):de[Oe]=fe}}function Y(fe,ve){return fe&&de.hasOwnProperty(fe)||(fe=/^\s*</.test(ve)?"default-markup":"default-code"),de[fe]}re(ne,["default-code"]),re(Q([],[[l,/^[^<?]+/],[c,/^<!\w[^>]*(?:>|$)/],[b,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[a,/^(?:<[%?]|[%?]>)/],["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"]),re(Q([[l,/^[\s]+/,null,` \r
`],[C,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[f,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[R,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[a,/^[=<>\/]+/],["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"]),re(Q([],[[C,/^[\s\S]+/]]),["uq.val"]),re(ue({keywords:m,hashComments:!0,cStyleComments:!0,types:_}),["c","cc","cpp","cxx","cyc","m"]),re(ue({keywords:"null,true,false"}),["json"]),re(ue({keywords:r,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:_}),["cs"]),re(ue({keywords:s,cStyleComments:!0}),["java"]),re(ue({keywords:i,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),re(ue({keywords:t,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),re(ue({keywords:o,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),re(ue({keywords:e,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),re(ue({keywords:u,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),re(ue({keywords:n,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),re(Q([],[[y,/^[\s\S]+/]]),["regex"]);function pe(fe){var ve=fe.langExtension;try{var Ce=L(fe.sourceNode,fe.pre),Oe=Ce.sourceCode;fe.sourceCode=Oe,fe.spans=Ce.spans,fe.basePos=0,Y(ve,Oe)(fe),le(fe)}catch(we){M.console&&console.log(we&&we.stack||we)}}function Te(fe,ve,Ce){var Oe=Ce||!1,we=ve||null,be=document.createElement("div");be.innerHTML="<pre>"+fe+"</pre>",be=be.firstChild,Oe&&se(be,Oe,!0);var me={langExtension:we,numberLines:Oe,sourceNode:be,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return pe(me),be.innerHTML}function xe(fe,ve){var Ce=ve||document.body,Oe=Ce.ownerDocument||document;function we(J){return Ce.getElementsByTagName(J)}for(var be=[we("pre"),we("code"),we("xmp")],me=[],Ue=0;Ue<be.length;++Ue)for(var Le=0,ke=be[Ue].length;Le<ke;++Le)me.push(be[Ue][Le]);be=null;var Pe=Date;Pe.now||(Pe={now:function(){return+new Date}});var Be=0,je=/\blang(?:uage)?-([\w.]+)(?!\S)/,Me=/\bprettyprint\b/,Re=/\bprettyprinted\b/,Fe=/pre|xmp/i,Ne=/^code$/i,oe=/^(?:pre|code|xmp)$/i,Ee={};function ie(){for(var J=M.PR_SHOULD_USE_CONTINUATION?Pe.now()+250:Infinity;Be<me.length&&Pe.now()<J;Be++){for(var te=me[Be],z=Ee,V=te;V=V.previousSibling;){var X=V.nodeType,q=(X===7||X===8)&&V.nodeValue;if(q?!/^\??prettify\b/.test(q):X!==3||/\S/.test(V.nodeValue))break;if(q){z={},q.replace(/\b(\w+)=([\w:.%+-]+)/g,function(lt,qe,pt){z[qe]=pt});break}}var ae=te.className;if((z!==Ee||Me.test(ae))&&!Re.test(ae)){for(var ce=!1,_e=te.parentNode;_e;_e=_e.parentNode){var We=_e.tagName;if(oe.test(We)&&_e.className&&Me.test(_e.className)){ce=!0;break}}if(!ce){te.className+=" prettyprinted";var ze=z.lang;if(!ze){ze=ae.match(je);var He;!ze&&(He=$(te))&&Ne.test(He.tagName)&&(ze=He.className.match(je)),ze&&(ze=ze[1])}var Xe;if(Fe.test(te.tagName))Xe=1;else{var Qe=te.currentStyle,Ke=Oe.defaultView,rt=Qe?Qe.whiteSpace:Ke&&Ke.getComputedStyle?Ke.getComputedStyle(te,null).getPropertyValue("white-space"):0;Xe=rt&&rt.substring(0,3)==="pre"}var st=z.linenums;(st=st==="true"||+st)||(st=ae.match(/\blinenums\b(?::(\d+))?/),st=st?st[1]&&st[1].length?+st[1]:!0:!1),st&&se(te,st,Xe);var ut={langExtension:ze,sourceNode:te,numberLines:st,pre:Xe,sourceCode:null,basePos:null,spans:null,decorations:null};pe(ut)}}}Be<me.length?M.setTimeout(ie,250):typeof fe=="function"&&fe()}ie()}var Se=M.PR={createSimpleLexer:Q,registerLangHandler:re,sourceDecorator:ue,PR_ATTRIB_NAME:R,PR_ATTRIB_VALUE:C,PR_COMMENT:b,PR_DECLARATION:c,PR_KEYWORD:E,PR_LITERAL:d,PR_NOCODE:N,PR_PLAIN:l,PR_PUNCTUATION:a,PR_SOURCE:x,PR_STRING:y,PR_TAG:f,PR_TYPE:g,prettyPrintOne:w?M.prettyPrintOne=Te:O=Te,prettyPrint:B=w?M.prettyPrint=xe:B=xe},Ae=M.define;typeof Ae=="function"&&Ae.amd&&Ae("google-code-prettify",[],function(){return Se})})()},TXwP:function(Je,Ve,ee){var he,G;(function(){var w;(function(){"use strict";var I=[,,function(A){function S(s){this.__parent=s,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}S.prototype.clone_empty=function(){var s=new S(this.__parent);return s.set_indent(this.__indent_count,this.__alignment_count),s},S.prototype.item=function(s){return s<0?this.__items[this.__items.length+s]:this.__items[s]},S.prototype.has_match=function(s){for(var r=this.__items.length-1;r>=0;r--)if(this.__items[r].match(s))return!0;return!1},S.prototype.set_indent=function(s,r){this.is_empty()&&(this.__indent_count=s||0,this.__alignment_count=r||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},S.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},S.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},S.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var s=this.__parent.current_line;return s.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),s.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),s.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,s.__items[0]===" "&&(s.__items.splice(0,1),s.__character_count-=1),!0}return!1},S.prototype.is_empty=function(){return this.__items.length===0},S.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},S.prototype.push=function(s){this.__items.push(s);var r=s.lastIndexOf(`
`);r!==-1?this.__character_count=s.length-r:this.__character_count+=s.length},S.prototype.pop=function(){var s=null;return this.is_empty()||(s=this.__items.pop(),this.__character_count-=s.length),s},S.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},S.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},S.prototype.trim=function(){for(;this.last()===" ";)this.__items.pop(),this.__character_count-=1},S.prototype.toString=function(){var s="";return this.is_empty()?this.__parent.indent_empty_lines&&(s=this.__parent.get_indent_string(this.__indent_count)):(s=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),s+=this.__items.join("")),s};function p(s,r){this.__cache=[""],this.__indent_size=s.indent_size,this.__indent_string=s.indent_char,s.indent_with_tabs||(this.__indent_string=new Array(s.indent_size+1).join(s.indent_char)),r=r||"",s.indent_level>0&&(r=new Array(s.indent_level+1).join(this.__indent_string)),this.__base_string=r,this.__base_string_length=r.length}p.prototype.get_indent_size=function(s,r){var n=this.__base_string_length;return r=r||0,s<0&&(n=0),n+=s*this.__indent_size,n+=r,n},p.prototype.get_indent_string=function(s,r){var n=this.__base_string;return r=r||0,s<0&&(s=0,n=""),r+=s*this.__indent_size,this.__ensure_cache(r),n+=this.__cache[r],n},p.prototype.__ensure_cache=function(s){for(;s>=this.__cache.length;)this.__add_column()},p.prototype.__add_column=function(){var s=this.__cache.length,r=0,n="";this.__indent_size&&s>=this.__indent_size&&(r=Math.floor(s/this.__indent_size),s-=r*this.__indent_size,n=new Array(r+1).join(this.__indent_string)),s&&(n+=new Array(s+1).join(" ")),this.__cache.push(n)};function m(s,r){this.__indent_cache=new p(s,r),this.raw=!1,this._end_with_newline=s.end_with_newline,this.indent_size=s.indent_size,this.wrap_line_length=s.wrap_line_length,this.indent_empty_lines=s.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new S(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}m.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},m.prototype.get_line_number=function(){return this.__lines.length},m.prototype.get_indent_string=function(s,r){return this.__indent_cache.get_indent_string(s,r)},m.prototype.get_indent_size=function(s,r){return this.__indent_cache.get_indent_size(s,r)},m.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},m.prototype.add_new_line=function(s){return this.is_empty()||!s&&this.just_added_newline()?!1:(this.raw||this.__add_outputline(),!0)},m.prototype.get_code=function(s){this.trim(!0);var r=this.current_line.pop();r&&(r[r.length-1]===`
`&&(r=r.replace(/\n+$/g,"")),this.current_line.push(r)),this._end_with_newline&&this.__add_outputline();var n=this.__lines.join(`
`);return s!==`
`&&(n=n.replace(/[\n]/g,s)),n},m.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},m.prototype.set_indent=function(s,r){return s=s||0,r=r||0,this.next_line.set_indent(s,r),this.__lines.length>1?(this.current_line.set_indent(s,r),!0):(this.current_line.set_indent(),!1)},m.prototype.add_raw_token=function(s){for(var r=0;r<s.newlines;r++)this.__add_outputline();this.current_line.set_indent(-1),this.current_line.push(s.whitespace_before),this.current_line.push(s.text),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1},m.prototype.add_token=function(s){this.__add_space_before_token(),this.current_line.push(s),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=this.current_line._allow_wrap()},m.prototype.__add_space_before_token=function(){this.space_before_token&&!this.just_added_newline()&&(this.non_breaking_space||this.set_wrap_point(),this.current_line.push(" "))},m.prototype.remove_indent=function(s){for(var r=this.__lines.length;s<r;)this.__lines[s]._remove_indent(),s++;this.current_line._remove_wrap_indent()},m.prototype.trim=function(s){for(s=s===void 0?!1:s,this.current_line.trim();s&&this.__lines.length>1&&this.current_line.is_empty();)this.__lines.pop(),this.current_line=this.__lines[this.__lines.length-1],this.current_line.trim();this.previous_line=this.__lines.length>1?this.__lines[this.__lines.length-2]:null},m.prototype.just_added_newline=function(){return this.current_line.is_empty()},m.prototype.just_added_blankline=function(){return this.is_empty()||this.current_line.is_empty()&&this.previous_line.is_empty()},m.prototype.ensure_empty_line_above=function(s,r){for(var n=this.__lines.length-2;n>=0;){var u=this.__lines[n];if(u.is_empty())break;if(u.item(0).indexOf(s)!==0&&u.item(-1)!==r){this.__lines.splice(n+1,0,new S(this)),this.previous_line=this.__lines[this.__lines.length-2];break}n--}},A.exports.Output=m},,,,function(A){function S(s,r){this.raw_options=p(s,r),this.disabled=this._get_boolean("disabled"),this.eol=this._get_characters("eol","auto"),this.end_with_newline=this._get_boolean("end_with_newline"),this.indent_size=this._get_number("indent_size",4),this.indent_char=this._get_characters("indent_char"," "),this.indent_level=this._get_number("indent_level"),this.preserve_newlines=this._get_boolean("preserve_newlines",!0),this.max_preserve_newlines=this._get_number("max_preserve_newlines",32786),this.preserve_newlines||(this.max_preserve_newlines=0),this.indent_with_tabs=this._get_boolean("indent_with_tabs",this.indent_char===" "),this.indent_with_tabs&&(this.indent_char=" ",this.indent_size===1&&(this.indent_size=4)),this.wrap_line_length=this._get_number("wrap_line_length",this._get_number("max_char")),this.indent_empty_lines=this._get_boolean("indent_empty_lines"),this.templating=this._get_selection_list("templating",["auto","none","django","erb","handlebars","php","smarty"],["auto"])}S.prototype._get_array=function(s,r){var n=this.raw_options[s],u=r||[];return typeof n=="object"?n!==null&&typeof n.concat=="function"&&(u=n.concat()):typeof n=="string"&&(u=n.split(/[^a-zA-Z0-9_\/\-]+/)),u},S.prototype._get_boolean=function(s,r){var n=this.raw_options[s],u=n===void 0?!!r:!!n;return u},S.prototype._get_characters=function(s,r){var n=this.raw_options[s],u=r||"";return typeof n=="string"&&(u=n.replace(/\\r/,"\r").replace(/\\n/,`
`).replace(/\\t/," ")),u},S.prototype._get_number=function(s,r){var n=this.raw_options[s];r=parseInt(r,10),isNaN(r)&&(r=0);var u=parseInt(n,10);return isNaN(u)&&(u=r),u},S.prototype._get_selection=function(s,r,n){var u=this._get_selection_list(s,r,n);if(u.length!==1)throw new Error("Invalid Option Value: The option '"+s+`' can only be one of the following values:
`+r+`
You passed in: '`+this.raw_options[s]+"'");return u[0]},S.prototype._get_selection_list=function(s,r,n){if(!r||r.length===0)throw new Error("Selection list cannot be empty.");if(n=n||[r[0]],!this._is_valid_selection(n,r))throw new Error("Invalid Default Value!");var u=this._get_array(s,n);if(!this._is_valid_selection(u,r))throw new Error("Invalid Option Value: The option '"+s+`' can contain only the following values:
`+r+`
You passed in: '`+this.raw_options[s]+"'");return u},S.prototype._is_valid_selection=function(s,r){return s.length&&r.length&&!s.some(function(n){return r.indexOf(n)===-1})};function p(s,r){var n={};s=m(s);var u;for(u in s)u!==r&&(n[u]=s[u]);if(r&&s[r])for(u in s[r])n[u]=s[r][u];return n}function m(s){var r={},n;for(n in s){var u=n.replace(/-/g,"_");r[u]=s[n]}return r}A.exports.Options=S,A.exports.normalizeOpts=m,A.exports.mergeOpts=p},,function(A){var S=RegExp.prototype.hasOwnProperty("sticky");function p(m){this.__input=m||"",this.__input_length=this.__input.length,this.__position=0}p.prototype.restart=function(){this.__position=0},p.prototype.back=function(){this.__position>0&&(this.__position-=1)},p.prototype.hasNext=function(){return this.__position<this.__input_length},p.prototype.next=function(){var m=null;return this.hasNext()&&(m=this.__input.charAt(this.__position),this.__position+=1),m},p.prototype.peek=function(m){var s=null;return m=m||0,m+=this.__position,m>=0&&m<this.__input_length&&(s=this.__input.charAt(m)),s},p.prototype.__match=function(m,s){m.lastIndex=s;var r=m.exec(this.__input);return r&&!(S&&m.sticky)&&(r.index!==s&&(r=null)),r},p.prototype.test=function(m,s){return s=s||0,s+=this.__position,s>=0&&s<this.__input_length?!!this.__match(m,s):!1},p.prototype.testChar=function(m,s){var r=this.peek(s);return m.lastIndex=0,r!==null&&m.test(r)},p.prototype.match=function(m){var s=this.__match(m,this.__position);return s?this.__position+=s[0].length:s=null,s},p.prototype.read=function(m,s,r){var n="",u;return m&&(u=this.match(m),u&&(n+=u[0])),s&&(u||!m)&&(n+=this.readUntil(s,r)),n},p.prototype.readUntil=function(m,s){var r="",n=this.__position;m.lastIndex=this.__position;var u=m.exec(this.__input);return u?(n=u.index,s&&(n+=u[0].length)):n=this.__input_length,r=this.__input.substring(this.__position,n),this.__position=n,r},p.prototype.readUntilAfter=function(m){return this.readUntil(m,!0)},p.prototype.get_regexp=function(m,s){var r=null,n="g";return s&&S&&(n="y"),typeof m=="string"&&m!==""?r=new RegExp(m,n):m&&(r=new RegExp(m.source,n)),r},p.prototype.get_literal_regexp=function(m){return RegExp(m.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"))},p.prototype.peekUntilAfter=function(m){var s=this.__position,r=this.readUntilAfter(m);return this.__position=s,r},p.prototype.lookBack=function(m){var s=this.__position-1;return s>=m.length&&this.__input.substring(s-m.length,s).toLowerCase()===m},A.exports.InputScanner=p},,,,,function(A){function S(p,m){p=typeof p=="string"?p:p.source,m=typeof m=="string"?m:m.source,this.__directives_block_pattern=new RegExp(p+/ beautify( \w+[:]\w+)+ /.source+m,"g"),this.__directive_pattern=/ (\w+)[:](\w+)/g,this.__directives_end_ignore_pattern=new RegExp(p+/\sbeautify\signore:end\s/.source+m,"g")}S.prototype.get_directives=function(p){if(!p.match(this.__directives_block_pattern))return null;var m={};this.__directive_pattern.lastIndex=0;for(var s=this.__directive_pattern.exec(p);s;)m[s[1]]=s[2],s=this.__directive_pattern.exec(p);return m},S.prototype.readIgnored=function(p){return p.readUntilAfter(this.__directives_end_ignore_pattern)},A.exports.Directives=S},,function(A,S,p){var m=p(16).Beautifier,s=p(17).Options;function r(n,u){var o=new m(n,u);return o.beautify()}A.exports=r,A.exports.defaultOptions=function(){return new s}},function(A,S,p){var m=p(17).Options,s=p(2).Output,r=p(8).InputScanner,n=p(13).Directives,u=new n(/\/\*/,/\*\//),o=/\r\n|[\r\n]/,t=/\r\n|[\r\n]/g,e=/\s/,i=/(?:\s|\n)+/g,T=/\/\*(?:[\s\S]*?)((?:\*\/)|$)/g,_=/\/\/(?:[^\n\r\u2028\u2029]*)/g;function y(E,b){this._source_text=E||"",this._options=new m(b),this._ch=null,this._input=null,this.NESTED_AT_RULE={"@page":!0,"@font-face":!0,"@keyframes":!0,"@media":!0,"@supports":!0,"@document":!0},this.CONDITIONAL_GROUP_RULE={"@media":!0,"@supports":!0,"@document":!0},this.NON_SEMICOLON_NEWLINE_PROPERTY=["grid-template-areas","grid-template"]}y.prototype.eatString=function(E){var b="";for(this._ch=this._input.next();this._ch;){if(b+=this._ch,this._ch==="\\")b+=this._input.next();else if(E.indexOf(this._ch)!==-1||this._ch===`
`)break;this._ch=this._input.next()}return b},y.prototype.eatWhitespace=function(E){for(var b=e.test(this._input.peek()),g=0;e.test(this._input.peek());)this._ch=this._input.next(),E&&this._ch===`
`&&((g===0||g<this._options.max_preserve_newlines)&&(g++,this._output.add_new_line(!0)));return b},y.prototype.foundNestedPseudoClass=function(){for(var E=0,b=1,g=this._input.peek(b);g;){if(g==="{")return!0;if(g==="(")E+=1;else if(g===")"){if(E===0)return!1;E-=1}else if(g===";"||g==="}")return!1;b++,g=this._input.peek(b)}return!1},y.prototype.print_string=function(E){this._output.set_indent(this._indentLevel),this._output.non_breaking_space=!0,this._output.add_token(E)},y.prototype.preserveSingleSpace=function(E){E&&(this._output.space_before_token=!0)},y.prototype.indent=function(){this._indentLevel++},y.prototype.outdent=function(){this._indentLevel>0&&this._indentLevel--},y.prototype.beautify=function(){if(this._options.disabled)return this._source_text;var E=this._source_text,b=this._options.eol;b==="auto"&&(b=`
`,E&&o.test(E||"")&&(b=E.match(o)[0])),E=E.replace(t,`
`);var g=E.match(/^[\t ]*/)[0];this._output=new s(this._options,g),this._input=new r(E),this._indentLevel=0,this._nestedLevel=0,this._ch=null;for(var d=0,a=!1,l=!1,f=!1,c=!1,x=!1,R=!1,C=this._ch,N=!1,U,W,L;U=this._input.read(i),W=U!=="",L=C,this._ch=this._input.next(),this._ch==="\\"&&this._input.hasNext()&&(this._ch+=this._input.next()),C=this._ch,this._ch;)if(this._ch==="/"&&this._input.peek()==="*"){this._output.add_new_line(),this._input.back();var H=this._input.read(T),K=u.get_directives(H);K&&K.ignore==="start"&&(H+=u.readIgnored(this._input)),this.print_string(H),this.eatWhitespace(!0),this._output.add_new_line()}else if(this._ch==="/"&&this._input.peek()==="/")this._output.space_before_token=!0,this._input.back(),this.print_string(this._input.read(_)),this.eatWhitespace(!0);else if(this._ch==="@"||this._ch==="$")if(this.preserveSingleSpace(W),this._input.peek()==="{")this.print_string(this._ch+this.eatString("}"));else{this.print_string(this._ch);var $=this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);$.match(/[ :]$/)&&($=this.eatString(": ").replace(/\s$/,""),this.print_string($),this._output.space_before_token=!0),$=$.replace(/\s$/,""),$==="extend"?c=!0:$==="import"&&(x=!0),$ in this.NESTED_AT_RULE?(this._nestedLevel+=1,$ in this.CONDITIONAL_GROUP_RULE&&(f=!0)):!a&&d===0&&$.indexOf(":")!==-1&&(l=!0,this.indent())}else if(this._ch==="#"&&this._input.peek()==="{")this.preserveSingleSpace(W),this.print_string(this._ch+this.eatString("}"));else if(this._ch==="{")l&&(l=!1,this.outdent()),f?(f=!1,a=this._indentLevel>=this._nestedLevel):a=this._indentLevel>=this._nestedLevel-1,this._options.newline_between_rules&&a&&(this._output.previous_line&&this._output.previous_line.item(-1)!=="{"&&this._output.ensure_empty_line_above("/",",")),this._output.space_before_token=!0,this._options.brace_style==="expand"?(this._output.add_new_line(),this.print_string(this._ch),this.indent(),this._output.set_indent(this._indentLevel)):(L==="("?this._output.space_before_token=!1:L!==","&&this.indent(),this.print_string(this._ch)),this.eatWhitespace(!0),this._output.add_new_line();else if(this._ch==="}")this.outdent(),this._output.add_new_line(),L==="{"&&this._output.trim(!0),x=!1,c=!1,l&&(this.outdent(),l=!1),this.print_string(this._ch),a=!1,this._nestedLevel&&this._nestedLevel--,this.eatWhitespace(!0),this._output.add_new_line(),this._options.newline_between_rules&&!this._output.just_added_blankline()&&(this._input.peek()!=="}"&&this._output.add_new_line(!0)),this._input.peek()===")"&&(this._output.trim(!0),this._options.brace_style==="expand"&&this._output.add_new_line(!0));else if(this._ch===":"){for(var Q=0;Q<this.NON_SEMICOLON_NEWLINE_PROPERTY.length;Q++)if(this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[Q])){N=!0;break}(a||f)&&!(this._input.lookBack("&")||this.foundNestedPseudoClass())&&!this._input.lookBack("(")&&!c&&d===0?(this.print_string(":"),l||(l=!0,this._output.space_before_token=!0,this.eatWhitespace(!0),this.indent())):(this._input.lookBack(" ")&&(this._output.space_before_token=!0),this._input.peek()===":"?(this._ch=this._input.next(),this.print_string("::")):this.print_string(":"))}else if(this._ch==='"'||this._ch==="'"){var ue=L==='"'||L==="'";this.preserveSingleSpace(ue||W),this.print_string(this._ch+this.eatString(this._ch)),this.eatWhitespace(!0)}else if(this._ch===";")N=!1,d===0?(l&&(this.outdent(),l=!1),c=!1,x=!1,this.print_string(this._ch),this.eatWhitespace(!0),this._input.peek()!=="/"&&this._output.add_new_line()):(this.print_string(this._ch),this.eatWhitespace(!0),this._output.space_before_token=!0);else if(this._ch==="(")if(this._input.lookBack("url"))this.print_string(this._ch),this.eatWhitespace(),d++,this.indent(),this._ch=this._input.next(),this._ch===")"||this._ch==='"'||this._ch==="'"?this._input.back():this._ch&&(this.print_string(this._ch+this.eatString(")")),d&&(d--,this.outdent()));else{var ne=!1;this._input.lookBack("with")&&(ne=!0),this.preserveSingleSpace(W||ne),this.print_string(this._ch),l&&L==="$"&&this._options.selector_separator_newline?(this._output.add_new_line(),R=!0):(this.eatWhitespace(),d++,this.indent())}else if(this._ch===")")d&&(d--,this.outdent()),R&&this._input.peek()===";"&&this._options.selector_separator_newline&&(R=!1,this.outdent(),this._output.add_new_line()),this.print_string(this._ch);else if(this._ch===",")this.print_string(this._ch),this.eatWhitespace(!0),this._options.selector_separator_newline&&(!l||R)&&d===0&&!x&&!c?this._output.add_new_line():this._output.space_before_token=!0;else if((this._ch===">"||this._ch==="+"||this._ch==="~")&&!l&&d===0)this._options.space_around_combinator?(this._output.space_before_token=!0,this.print_string(this._ch),this._output.space_before_token=!0):(this.print_string(this._ch),this.eatWhitespace(),this._ch&&e.test(this._ch)&&(this._ch=""));else if(this._ch==="]")this.print_string(this._ch);else if(this._ch==="[")this.preserveSingleSpace(W),this.print_string(this._ch);else if(this._ch==="=")this.eatWhitespace(),this.print_string("="),e.test(this._ch)&&(this._ch="");else if(this._ch==="!"&&!this._input.lookBack("\\"))this._output.space_before_token=!0,this.print_string(this._ch);else{var se=L==='"'||L==="'";this.preserveSingleSpace(se||W),this.print_string(this._ch),!this._output.just_added_newline()&&this._input.peek()===`
`&&N&&this._output.add_new_line()}var le=this._output.get_code(b);return le},A.exports.Beautifier=y},function(A,S,p){var m=p(6).Options;function s(r){m.call(this,r,"css"),this.selector_separator_newline=this._get_boolean("selector_separator_newline",!0),this.newline_between_rules=this._get_boolean("newline_between_rules",!0);var n=this._get_boolean("space_around_selector_separator");this.space_around_combinator=this._get_boolean("space_around_combinator")||n;var u=this._get_selection_list("brace_style",["collapse","expand","end-expand","none","preserve-inline"]);this.brace_style="collapse";for(var o=0;o<u.length;o++)u[o]!=="expand"?this.brace_style="collapse":this.brace_style=u[o]}s.prototype=new m,A.exports.Options=s}],O={};function B(A){var S=O[A];if(S!==void 0)return S.exports;var p=O[A]={exports:{}};return I[A](p,p.exports,B),p.exports}var M=B(15);w=M})();var j=w;!(he=[],G=function(){return{css_beautify:j}}.apply(Ve,he),G!==void 0&&(Je.exports=G))})()},Y1PL:function(Je,Ve,ee){"use strict";ee.r(Ve),ee.d(Ve,"ResizableTextArea",function(){return $});var he=ee("wx14"),G=ee("1OyB"),w=ee("vuIU"),j=ee("Ji7U"),I=ee("LK+K"),O=ee("q1tI"),B=ee("VTBJ"),M=ee("rePB"),A=ee("Zm9Q"),S=ee("Kwbf"),p=ee("c+Xe"),m=ee("m+aA"),s=ee("bdgK"),r=new Map;function n(ne){ne.forEach(function(se){var le,de=se.target;(le=r.get(de))===null||le===void 0||le.forEach(function(re){return re(de)})})}var u=new s.default(n),o=null,t=null;function e(ne,se){r.has(ne)||(r.set(ne,new Set),u.observe(ne)),r.get(ne).add(se)}function i(ne,se){r.has(ne)&&(r.get(ne).delete(se),r.get(ne).size||(u.unobserve(ne),r.delete(ne)))}var T=function(ne){Object(j.a)(le,ne);var se=Object(I.a)(le);function le(){return Object(G.a)(this,le),se.apply(this,arguments)}return Object(w.a)(le,[{key:"render",value:function(){return this.props.children}}]),le}(O.Component),_=O.createContext(null);function y(ne){var se=ne.children,le=ne.onBatchResize,de=O.useRef(0),re=O.useRef([]),Y=O.useContext(_),pe=O.useCallback(function(Te,xe,Se){de.current+=1;var Ae=de.current;re.current.push({size:Te,element:xe,data:Se}),Promise.resolve().then(function(){Ae===de.current&&(le==null||le(re.current),re.current=[])}),Y==null||Y(Te,xe,Se)},[le,Y]);return O.createElement(_.Provider,{value:pe},se)}function E(ne){var se=ne.children,le=ne.disabled,de=O.useRef(null),re=O.useRef(null),Y=O.useContext(_),pe=O.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),Te=O.isValidElement(se)&&Object(p.c)(se),xe=Te?se.ref:null,Se=O.useMemo(function(){return Object(p.a)(xe,de)},[xe,de]),Ae=O.useRef(ne);Ae.current=ne;var fe=O.useCallback(function(ve){var Ce=Ae.current,Oe=Ce.onResize,we=Ce.data,be=ve.getBoundingClientRect(),me=be.width,Ue=be.height,Le=ve.offsetWidth,ke=ve.offsetHeight,Pe=Math.floor(me),Be=Math.floor(Ue);if(pe.current.width!==Pe||pe.current.height!==Be||pe.current.offsetWidth!==Le||pe.current.offsetHeight!==ke){var je={width:Pe,height:Be,offsetWidth:Le,offsetHeight:ke};pe.current=je;var Me=Le===Math.round(me)?me:Le,Re=ke===Math.round(Ue)?Ue:ke,Fe=Object(B.a)(Object(B.a)({},je),{},{offsetWidth:Me,offsetHeight:Re});Y==null||Y(Fe,ve,we),Oe&&Promise.resolve().then(function(){Oe(Fe,ve)})}},[]);return O.useEffect(function(){var ve=Object(m.a)(de.current)||Object(m.a)(re.current);return ve&&!le&&e(ve,fe),function(){return i(ve,fe)}},[de.current,le]),O.createElement(T,{ref:re},Te?O.cloneElement(se,{ref:Se}):se)}var b="rc-observer-key";function g(ne){var se=ne.children,le=Object(A.a)(se);return le.map(function(de,re){var Y=(de==null?void 0:de.key)||"".concat(b,"-").concat(re);return O.createElement(E,Object(he.a)({},ne,{key:Y}),de)})}g.Collection=y;var d=g,a=ee("bT9E"),l=ee("TSYQ"),f=ee.n(l),c=`
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
`,x=["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"],R={},C;function N(ne){var se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,le=ne.getAttribute("id")||ne.getAttribute("data-reactid")||ne.getAttribute("name");if(se&&R[le])return R[le];var de=window.getComputedStyle(ne),re=de.getPropertyValue("box-sizing")||de.getPropertyValue("-moz-box-sizing")||de.getPropertyValue("-webkit-box-sizing"),Y=parseFloat(de.getPropertyValue("padding-bottom"))+parseFloat(de.getPropertyValue("padding-top")),pe=parseFloat(de.getPropertyValue("border-bottom-width"))+parseFloat(de.getPropertyValue("border-top-width")),Te=x.map(function(Se){return"".concat(Se,":").concat(de.getPropertyValue(Se))}).join(";"),xe={sizingStyle:Te,paddingSize:Y,borderSize:pe,boxSizing:re};return se&&le&&(R[le]=xe),xe}function U(ne){var se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,le=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,de=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;C||(C=document.createElement("textarea"),C.setAttribute("tab-index","-1"),C.setAttribute("aria-hidden","true"),document.body.appendChild(C)),ne.getAttribute("wrap")?C.setAttribute("wrap",ne.getAttribute("wrap")):C.removeAttribute("wrap");var re=N(ne,se),Y=re.paddingSize,pe=re.borderSize,Te=re.boxSizing,xe=re.sizingStyle;C.setAttribute("style","".concat(xe,";").concat(c)),C.value=ne.value||ne.placeholder||"";var Se=Number.MIN_SAFE_INTEGER,Ae=Number.MAX_SAFE_INTEGER,fe=C.scrollHeight,ve;if(Te==="border-box"?fe+=pe:Te==="content-box"&&(fe-=Y),le!==null||de!==null){C.value=" ";var Ce=C.scrollHeight-Y;le!==null&&(Se=Ce*le,Te==="border-box"&&(Se=Se+Y+pe),fe=Math.max(Se,fe)),de!==null&&(Ae=Ce*de,Te==="border-box"&&(Ae=Ae+Y+pe),ve=fe>Ae?"":"hidden",fe=Math.min(Ae,fe))}return{height:fe,minHeight:Se,maxHeight:Ae,overflowY:ve,resize:"none"}}var W=ee("Gytx"),L=ee.n(W),H;(function(ne){ne[ne.NONE=0]="NONE",ne[ne.RESIZING=1]="RESIZING",ne[ne.RESIZED=2]="RESIZED"})(H||(H={}));var K=function(ne){Object(j.a)(le,ne);var se=Object(I.a)(le);function le(de){var re;return Object(G.a)(this,le),re=se.call(this,de),re.nextFrameActionId=void 0,re.resizeFrameId=void 0,re.textArea=void 0,re.saveTextArea=function(Y){re.textArea=Y},re.handleResize=function(Y){var pe=re.state.resizeStatus,Te=re.props,xe=Te.autoSize,Se=Te.onResize;if(pe!==H.NONE)return;typeof Se=="function"&&Se(Y),xe&&re.resizeOnNextFrame()},re.resizeOnNextFrame=function(){cancelAnimationFrame(re.nextFrameActionId),re.nextFrameActionId=requestAnimationFrame(re.resizeTextarea)},re.resizeTextarea=function(){var Y=re.props.autoSize;if(!Y||!re.textArea)return;var pe=Y.minRows,Te=Y.maxRows,xe=U(re.textArea,!1,pe,Te);re.setState({textareaStyles:xe,resizeStatus:H.RESIZING},function(){cancelAnimationFrame(re.resizeFrameId),re.resizeFrameId=requestAnimationFrame(function(){re.setState({resizeStatus:H.RESIZED},function(){re.resizeFrameId=requestAnimationFrame(function(){re.setState({resizeStatus:H.NONE}),re.fixFirefoxAutoScroll()})})})})},re.renderTextArea=function(){var Y=re.props,pe=Y.prefixCls,Te=pe===void 0?"rc-textarea":pe,xe=Y.autoSize,Se=Y.onResize,Ae=Y.className,fe=Y.disabled,ve=re.state,Ce=ve.textareaStyles,Oe=ve.resizeStatus,we=Object(a.a)(re.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),be=f()(Te,Ae,Object(M.a)({},"".concat(Te,"-disabled"),fe));"value"in we&&(we.value=we.value||"");var me=Object(B.a)(Object(B.a)(Object(B.a)({},re.props.style),Ce),Oe===H.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return O.createElement(d,{onResize:re.handleResize,disabled:!(xe||Se)},O.createElement("textarea",Object(he.a)({},we,{className:be,style:me,ref:re.saveTextArea})))},re.state={textareaStyles:{},resizeStatus:H.NONE},re}return Object(w.a)(le,[{key:"componentDidUpdate",value:function(re){(re.value!==this.props.value||!L()(re.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 re=this.textArea.selectionStart,Y=this.textArea.selectionEnd;this.textArea.setSelectionRange(re,Y)}}catch(pe){}}},{key:"render",value:function(){return this.renderTextArea()}}]),le}(O.Component),$=K,Q=function(ne){Object(j.a)(le,ne);var se=Object(I.a)(le);function le(de){var re;Object(G.a)(this,le),re=se.call(this,de),re.resizableTextArea=void 0,re.focus=function(){re.resizableTextArea.textArea.focus()},re.saveTextArea=function(pe){re.resizableTextArea=pe},re.handleChange=function(pe){var Te=re.props.onChange;re.setValue(pe.target.value,function(){re.resizableTextArea.resizeTextarea()}),Te&&Te(pe)},re.handleKeyDown=function(pe){var Te=re.props,xe=Te.onPressEnter,Se=Te.onKeyDown;pe.keyCode===13&&xe&&xe(pe),Se&&Se(pe)};var Y=typeof de.value=="undefined"||de.value===null?de.defaultValue:de.value;return re.state={value:Y},re}return Object(w.a)(le,[{key:"setValue",value:function(re,Y){"value"in this.props||this.setState({value:re},Y)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return O.createElement($,Object(he.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(re){return"value"in re?{value:re.value}:null}}]),le}(O.Component),ue=Ve.default=Q},ZW9T:function(Je,Ve,ee){"use strict";ee.d(Ve,"a",function(){return U});var he=ee("k1fw"),G=ee("miYZ"),w=ee("tsqr"),j=ee("rAM+"),I=ee("tJVT"),O=ee("PpiC"),B=ee("q1tI"),M=ee.n(B),A=ee("bdgK"),S=ee("oBTY"),p=ee("9og8"),m=ee("WmNS"),s=ee.n(m),r={keywords:["print","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"]},n={quickKey:[{label:"main",content:["public static void main(String[] args) {"," $0","}"].join(`
`)},{label:"System.out.println",content:["System.out.println($0)"].join(`
`)},{label:"System.out.print",content:["System.out.print($0)"].join(`
`)}],keywords:["abstract","continue","for","new","switch","assert","default","goto","package","synchronized","boolean","do","if","private","this","break","double","implements","protected","throw","byte","else","import","public","throws","case","enum","instanceof","return","transient","catch","extends","int","short","try","char","final","interface","static","void","class","finally","long","strictfp","volatile","const","float","native","super","while","true","false"]},u={keywords:["abstract","amp","array","auto","bool","break","case","catch","char","class","const","constexpr","const_cast","continue","cpu","decltype","default","delegate","delete","do","double","dynamic_cast","each","else","enum","event","explicit","export","extern","false","final","finally","float","for","friend","gcnew","generic","goto","if","in","initonly","inline","int","interface","interior_ptr","internal","literal","long","mutable","namespace","new","noexcept","nullptr","__nullptr","operator","override","partial","pascal","pin_ptr","private","property","protected","public","ref","register","reinterpret_cast","restrict","return","safe_cast","sealed","short","signed","sizeof","static","static_assert","static_cast","struct","switch","template","this","thread_local","throw","tile_static","true","try","typedef","typeid","typename","union","unsigned","using","virtual","void","volatile","wchar_t","where","while","_asm","_based","_cdecl","_declspec","_fastcall","_if_exists","_if_not_exists","_inline","_multiple_inheritance","_pascal","_single_inheritance","_stdcall","_virtual_inheritance","_w64","__abstract","__alignof","__asm","__assume","__based","__box","__builtin_alignof","__cdecl","__clrcall","__declspec","__delegate","__event","__except","__fastcall","__finally","__forceinline","__gc","__hook","__identifier","__if_exists","__if_not_exists","__inline","__int128","__int16","__int32","__int64","__int8","__interface","__leave","__m128","__m128d","__m128i","__m256","__m256d","__m256i","__m64","__multiple_inheritance","__newslot","__nogc","__noop","__nounwind","__novtordisp","__pascal","__pin","__pragma","__property","__ptr32","__ptr64","__raise","__restrict","__resume","__sealed","__single_inheritance","__stdcall","__super","__thiscall","__try","__try_cast","__typeof","__unaligned","__unhook","__uuidof","__value","__virtual_inheritance","__w64","__wchar_t"],operators:["=",">","<","!","~","?",":","==","<=",">=","!=","&&","||","++","--","+","-","*","/","&","|","^","%","<<",">>",">>>","+=","-=","*=","/=","&=","|=","^=","%=","<<=",">>=",">>>="],quickKey:[{label:"ifelse",content:["if (${1:condition}) {"," $0","} else {"," ","}"].join(`
`)},{label:"#include",content:'include "$0"'},{label:"printf",content:"printf($0)"},{label:"main",content:["int main () {"," $0","}"].join(`
`)},{label:"for",content:["for( ; ; ){"," $0","}"].join(`
`)},{label:"trycatch",content:["try{"," $0","}catch(ExceptionName e){","}"].join(`
`)},{label:"using namespace std;",content:["using namespace std;"].join(`
`)},{label:"#include <iostream>",content:["#include <iostream>"].join(`
`)},{label:"#include <vector>",content:["#include <vector>"].join(`
`)},{label:"#include <sstream>",content:["#include <sstream>"].join(`
`)},{label:"#include <string>",content:["#include <string>"].join(`
`)},{label:"#include <cmath>",content:["#include <cmath>"].join(`
`)}]},o={keywords:["and","as","assert","break","class","continue","def","del","elif","else","except","exec","finally","for","from","global","if","import","in","is","lambda","None","not","or","pass","raise","return","self","try","while","with","yield","int","float","long","complex","hex","abs","all","any","apply","basestring","bin","bool","buffer","bytearray","callable","chr","classmethod","cmp","coerce","compile","complex","delattr","dict","dir","divmod","enumerate","eval","execfile","file","filter","format","frozenset","getattr","globals","hasattr","hash","help","id","input","intern","isinstance","issubclass","iter","len","locals","list","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","reversed","range","raw_input","reduce","reload","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","unichr","unicode","vars","xrange","zip","True","False","__dict__","__methods__","__members__","__class__","__bases__","__name__","__mro__","__subclasses__","__init__","__import__"],quickKey:[{label:"print",content:["print($0)"].join(`
`)}]},t=ee("5VLF"),e=ee.n(t),i={languages:["c","abap","apex","azcli","bat","cameligo","clojure","coffee","cpp","csharp","csp","css","dockerfile","fsharp","go","graphql","handlebars","html","ini","java","javascript","json","kotlin","less","lua","markdown","mips","msdax","mysql","objective-c","pascal","pascaligo","perl","pgsql","php","postiats","powerquery","powershell","pug","python","r","razor","redis","redshift","restructuredtext","ruby","rust","sb","scheme","scss","shell","solidity","sophia","sql","st","swift","tcl","twig","vb","xml","yaml'"],tables:{users:["name","id","email","phone","password"],roles:["id","name","order","created_at","updated_at","deleted_at"]}},T=function(L,H){return H.map(function(K){return{label:K,kind:L.languages.CompletionItemKind.Keyword,insertText:K}})},_=function(L){return Object.keys(i.tables).map(function(H){return{label:H,kind:L.languages.CompletionItemKind.Variable,insertText:H}})},y=function(L,H){var K=i.tables[L];return K?K.map(function($){return{label:$,kind:H.languages.CompletionItemKind.Field,insertText:$}}):[]};function E(W,L,H,K,$){var Q=L.getWordUntilPosition(H),ue={startLineNumber:H.lineNumber,endLineNumber:H.lineNumber,startColumn:Q.startColumn,endColumn:Q.endColumn},ne=K.map(function(se){return{label:se,kind:W.languages.CompletionItemKind.Keyword,insertText:se,insertTextRules:W.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:ue}});return $.map(function(se){ne.push(Object(he.a)(Object(he.a)({},se),{},{range:ue}))}),ne}var b=function(W){i.languages.map(function($){return W.languages.registerDocumentFormattingEditProvider($,{provideDocumentFormattingEdits:function(ue,ne,se){return Object(p.a)(s.a.mark(function le(){var de;return s.a.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return de=e()(ue.getValue(),{indent_size:"2",indent_char:" ",max_preserve_newlines:"2",preserve_newlines:!0,keep_array_indentation:!0,break_chained_methods:!1,indent_scripts:"normal",brace_style:"collapse",space_before_conditional:!0,unescape_strings:!1,jslint_happy:!1,end_with_newline:!0,wrap_line_length:"0",indent_inner_html:!1,comma_first:!1,e4x:!1,indent_empty_lines:!1}),Y.abrupt("return",[{range:ue.getFullModelRange(),text:de}]);case 2:case"end":return Y.stop()}},le)}))()}}),$});var L=u.quickKey.map(function($){return{label:$.label,kind:W.languages.CompletionItemKind.Method,insertText:$.content,insertTextRules:W.languages.CompletionItemInsertTextRule.InsertAsSnippet}}),H=o.quickKey.map(function($){return{label:$.label,kind:W.languages.CompletionItemKind.Method,insertText:$.content,insertTextRules:W.languages.CompletionItemInsertTextRule.InsertAsSnippet}}),K=n.quickKey.map(function($){return{label:$.label,kind:W.languages.CompletionItemKind.Method,insertText:$.content,insertTextRules:W.languages.CompletionItemInsertTextRule.InsertAsSnippet}});W.languages.registerCompletionItemProvider("cpp",{triggerCharacters:["."," ","#"].concat(Object(S.a)(u.keywords),Object(S.a)(u.quickKey.map(function($){return $.label}))),provideCompletionItems:function(Q,ue){var ne=Q.getValueInRange({startLineNumber:ue.lineNumber,startColumn:1,endLineNumber:ue.lineNumber,endColumn:ue.column}),se=ne.match(/cu/gim);console.log("match:",se,ue,ne,Q);var le=[],de=ue.lineNumber,re=ue.column,Y=Q.getValueInRange({startLineNumber:de,startColumn:0,endLineNumber:de,endColumn:re}),pe=Y.trim().split(/\s+/),Te=pe[pe.length-1];if(Te.endsWith(".")){var xe=Te.slice(0,Te.length-1);Object.keys(i.tables).includes(xe)&&(le=Object(S.a)(y(xe,W)))}else Te==="."?le=[]:le=[].concat(Object(S.a)(_(W)),Object(S.a)(T(W,u.keywords)),Object(S.a)(L));return{suggestions:le}}}),W.languages.registerCompletionItemProvider("c",{triggerCharacters:["."," ","#"].concat(Object(S.a)(r.keywords)),provideCompletionItems:function(Q,ue){var ne=Q.getValueInRange({startLineNumber:ue.lineNumber,startColumn:1,endLineNumber:ue.lineNumber,endColumn:ue.column}),se=ne.match(/cu/gim);console.log("match:",se,ue,ne,Q);var le=[],de=ue.lineNumber,re=ue.column,Y=Q.getValueInRange({startLineNumber:de,startColumn:0,endLineNumber:de,endColumn:re}),pe=Y.trim().split(/\s+/),Te=pe[pe.length-1];if(Te.endsWith(".")){var xe=Te.slice(0,Te.length-1);Object.keys(i.tables).includes(xe)&&(le=Object(S.a)(y(xe,W)))}else Te==="."?le=[]:le=[].concat(Object(S.a)(_(W)),Object(S.a)(T(W,r.keywords)));return{suggestions:le}}}),W.languages.registerCompletionItemProvider("java",{triggerCharacters:["."," "].concat(Object(S.a)(n.keywords)),provideCompletionItems:function(Q,ue){var ne=[],se=ue.lineNumber,le=ue.column,de=Q.getValueInRange({startLineNumber:se,startColumn:0,endLineNumber:se,endColumn:le}),re=de.trim().split(/\s+/),Y=re[re.length-1];if(Y.endsWith(".")){var pe=Y.slice(0,Y.length-1);Object.keys(i.tables).includes(pe)&&(ne=Object(S.a)(y(pe,W)))}else Y==="."?ne=[]:ne=[].concat(Object(S.a)(_(W)),Object(S.a)(T(W,n.keywords)),Object(S.a)(K));return{suggestions:ne}}}),W.languages.registerCompletionItemProvider("python",{triggerCharacters:["."," "].concat(Object(S.a)(o.keywords)),provideCompletionItems:function(Q,ue){var ne=[],se=ue.lineNumber,le=ue.column,de=Q.getValueInRange({startLineNumber:se,startColumn:0,endLineNumber:se,endColumn:le}),re=de.trim().split(/\s+/),Y=re[re.length-1];if(Y.endsWith(".")){var pe=Y.slice(0,Y.length-1);Object.keys(i.tables).includes(pe)&&(ne=Object(S.a)(y(pe,W)))}else Y==="."?ne=[]:ne=[].concat(Object(S.a)(_(W)),Object(S.a)(T(W,o.keywords)),Object(S.a)(H));return{suggestions:ne}}})},g="\u8BE5\u4EFB\u52A1\u5173\u5361\u8BBE\u7F6E\u4E86\u7981\u6B62\u590D\u5236\u7C98\u8D34\uFF0C\u8BF7\u624B\u52A8\u8F93\u5165\u4EE3\u7801\u3002",d=ee("LvDl"),a=ee("+ua5");function l(W){return/^\d+$/.test(W)?"".concat(W,"px"):W}function f(){}var c=!1,x={"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 R(){var W=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],L=W;if(Array.isArray(W)){for(var H=0;H<W.length;H++){var K=x[W[H]];if(K)return K}return L[0]}return x[L]||L}var C=null,N=Ve.b=function(W){var L=W.width,H=L===void 0?"100%":L,K=W.height,$=K===void 0?"100%":K,Q=W.value,ue=W.language,ne=ue===void 0?"javascript":ue,se=W.style,le=se===void 0?{}:se,de=W.options,re=de===void 0?{}:de,Y=W.overrideServices,pe=Y===void 0?{}:Y,Te=W.theme,xe=Te===void 0?"vs-dark":Te,Se=W.onEditBlur,Ae=W.onSave,fe=W.autoHeight,ve=fe===void 0?!1:fe,Ce=W.forbidCopy,Oe=Ce===void 0?!1:Ce,we=W.onChange,be=we===void 0?f:we,me=W.editorDidMount,Ue=me===void 0?f:me,Le=W.onFocus,ke=Le===void 0?f:Le,Pe=W.filename,Be=Pe===void 0?"educoder.txt":Pe,je=W.errorLine,Me=W.errorContent,Re=Me===void 0?"":Me,Fe=Object(O.a)(W,["width","height","value","language","style","options","overrideServices","theme","onEditBlur","onSave","autoHeight","forbidCopy","onChange","editorDidMount","onFocus","filename","errorLine","errorContent"]),Ne=Object(B.useRef)(),oe=Object(B.useRef)({}),Ee=Object(B.useRef)(),ie=Object(B.useRef)(!1),J=Object(B.useRef)(),te=Object(B.useState)(!1),z=Object(I.a)(te,2),V=z[0],X=z[1];function q(){var Ie;return Ne.current&&(Ie=new A.default(function($e){var et=Object(j.a)($e),Ze;try{for(et.s();!(Ze=et.n()).done;){var ct=Ze.value;(ct.target.offsetHeight>0||ct.target.offsetWidth>0)&&oe.current.instance.layout()}}catch(St){et.e(St)}finally{et.f()}}),Ie.observe(Ne.current)),Ie}function ae(){w.b.warn(decodeURIComponent(g))}var ce=function(){var $e=oe.current.instance;if(Q!=null&&$e&&V){var et=$e.getModel();et&&Q!==et.getValue()&&(c=!0,et.setValue(Q),$e.layout(),c=!1)}};Object(B.useEffect)(function(){Ee.current&&clearTimeout(Ee.current),Ee.current=setTimeout(function(){ce()},500)},[Q,V,oe.current]),Object(B.useEffect)(function(){if(je&&oe.current&&oe.current.instance){var Ie=oe.current.instance;Ie.changeViewZones(function(et){var Ze=document.createElement("div");Ze.style.padding="10px 20px",Ze.style.width="calc(100% - 20px)",Ze.className="my-error-line-wrp",Ze.innerHTML=Re,et.addZone({afterLineNumber:je||11,heightInLines:3,domNode:Ze})});var $e={domNode:null,getId:function(){return"my.overlay.widget"},getDomNode:function(){return this.domNode||(this.domNode=document.createElement("div"),this.domNode.innerHTML="",this.domNode.style.width="100%",this.domNode.style.padding="20px 100px",this.domNode.style.right="0px",this.domNode.style.top="50px",this.domNode.style.position="relative",this.domNode.style.color="#333"),this.domNode},getPosition:function(){return null}};Ie.addOverlayWidget($e),Ie.revealPositionInCenter({lineNumber:20,column:1})}},[je,oe.current,V]);function _e(){var Ie=oe.current.instance;if(Ie){var $e=Ie.getSelection(),et=oe.current.pastePos||{},Ze=new C.Range(et.startLineNumber||$e.endLineNumber,et.startColumn||$e.endColumn,et.endLineNumber||$e.endLineNumber,et.endColumn||$e.endColumn);setTimeout(function(){Ie.executeEdits("",[{range:Ze,text:""}])},300)}}function We(Ie){(window.navigator.platform.match("Mac")?Ie.metaKey:Ie.ctrlKey)&&Ie.keyCode==83&&(Ie.preventDefault(),Ae())}var ze=function(){if(ve&&oe.current.instance){var $e=oe.current.instance.getContentHeight();pt($e<$?$:$e)}else pt($)};function He(Ie){var $e=document.createEvent("MouseEvents");$e.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),Ie.dispatchEvent($e)}function Xe(Ie,$e){var et=window.URL||window.webkitURL||window,Ze=new Blob([$e]),ct=document.createElementNS("http://www.w3.org/1999/xhtml","a");ct.href=et.createObjectURL(Ze),ct.download=Ie,He(ct)}Object(B.useEffect)(function(){ze()},[ze]),Object(B.useEffect)(function(){Ne.current&&!V&&ee.e(27).then(ee.t.bind(null,"M/lh",7)).then(function(Ie){try{C=Ie,oe.current.instance=C.editor.create(Ne.current,{value:Q,language:R(ne),theme:xe,requireConfig:{"vs/nls":{availableLanguages:{"*":"zh-cn"}}},wordWrap:!0},pe);var $e=oe.current.instance;if(Ue($e,C),setTimeout(function(){ze(),oe.current.instance.addAction({id:"d123123",label:"Download File",contextMenuGroupId:"9_cutcopypaste",run:function(){Xe(Be||"educoder.txt",$e.getValue())}})},500),oe.current.subscription=$e.onDidChangeModelContent(function(Ze){ie.current?clearTimeout(J.current):(ze(),be($e.getValue(),Ze)),J.current=setTimeout(function(){ie.current=!1},500)}),window.Monaco||b(C),Oe&&($e.addCommand(C.KeyMod.CtrlCmd|C.KeyMod.Shift|C.KeyCode.KEY_V,function(){return ae(),null}),$e.addCommand(C.KeyMod.CtrlCmd|C.KeyCode.KEY_C,function(){return ae(),null})),window.Monaco=C,Se&&$e.onDidBlurEditorWidget(function(){Se($e.getValue())}),ke&&$e.onDidFocusEditorText(function(){ke($e.getValue())}),Oe){$e.addCommand(C.KeyMod.CtrlCmd|C.KeyCode.KEY_V,function(){return ae(),null}),$e.onDidPaste(function(Ze){oe.current.pastePos=Ze});try{window.addEventListener("paste",_e)}catch(Ze){}}var et=q();return X(!0),function(){var Ze=oe.current.instance;Ze.dispose();var ct=Ze.getModel();ct&&ct.dispose(),oe.current.subscription&&oe.current.subscription.dispose(),Oe&&window.removeEventListener("paste",_e),et.unobserve(Ne.current)}}catch(Ze){}})},[]),Object(B.useEffect)(function(){var Ie=oe.current.instance;if(Ie&&V)return document.addEventListener("keydown",We,!1),function(){document.removeEventListener("keydown",We)}},[Ae,V]),Object(B.useEffect)(function(){var Ie=oe.current.instance;if(Ie&&V){var $e=R(ne);C.editor.setModelLanguage(Ie.getModel(),$e),console.log("language:",ne,Ie.getModel(),$e)}},[ne,V]),Object(B.useEffect)(function(){var Ie=oe.current.instance;Ie&&V&&C.editor.setTheme(xe)},[xe,V]),Object(B.useEffect)(function(){var Ie=oe.current.instance;Ie&&V&&(Ie.updateOptions(Object(he.a)({},re)),setTimeout(function(){Ie.getModel().updateOptions(Object(he.a)({},re))},200))},[JSON.stringify(re),V]),Object(B.useEffect)(function(){var Ie=oe.current.instance;Ie&&V&&Ie.layout()},[H,$,V]);var Qe=Object(B.useState)(l(H)),Ke=Object(I.a)(Qe,2),rt=Ke[0],st=Ke[1],ut=Object(B.useState)(l($)),lt=Object(I.a)(ut,2),qe=lt[0],pt=lt[1],Et=Object(he.a)(Object(he.a)({},le),{},{width:rt,height:qe});return M.a.createElement("div",{className:"my-monaco-editor",ref:Ne,style:Et})};function U(W){var L=W.width,H=L===void 0?"100%":L,K=W.height,$=K===void 0?"100%":K,Q=W.original,ue=W.modified,ne=W.language,se=W.options,le=se===void 0?{}:se,de=Object(B.useRef)(),re=Object(B.useState)(null),Y=Object(I.a)(re,2),pe=Y[0],Te=Y[1];function xe(ve){var Ce;return de.current&&(Ce=new A.default(function(Oe){var we=Object(j.a)(Oe),be;try{for(we.s();!(be=we.n()).done;){var me=be.value;(me.target.offsetHeight>0||me.target.offsetWidth>0)&&ve.layout()}}catch(Ue){we.e(Ue)}finally{we.f()}}),Ce.observe(de.current)),Ce}Object(B.useEffect)(function(){de.current&&ee.e(27).then(ee.t.bind(null,"M/lh",7)).then(function(ve){C=ve;var Ce=C.editor.createDiffEditor(de.current,Object(he.a)(Object(he.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},le),{},{wordWrap:!0}));Te(Ce);var Oe=xe(Ce);return function(){Ce.dispose();var we=Ce.getModel();we&&we.dispose(),Oe.unobserve(de.current)}})},[]),Object(B.useEffect)(function(){pe&&pe.setModel({original:C.editor.createModel(Q,ne),modified:C.editor.createModel(ue,ne)})},[Q,ue,ne,pe]);var Se=l(H),Ae=l($),fe={width:Se,height:Ae};return M.a.createElement("div",{className:"my-diff-editor",ref:de,style:fe})}},ZpRC:function(Je,Ve,ee){"use strict";function he(p){return typeof p=="object"&&p!=null&&p.nodeType===1}function G(p,m){return(!m||p!=="hidden")&&p!=="visible"&&p!=="clip"}function w(p,m){if(p.clientHeight<p.scrollHeight||p.clientWidth<p.scrollWidth){var s=getComputedStyle(p,null);return G(s.overflowY,m)||G(s.overflowX,m)||function(r){var n=function(u){if(!u.ownerDocument||!u.ownerDocument.defaultView)return null;try{return u.ownerDocument.defaultView.frameElement}catch(o){return null}}(r);return!!n&&(n.clientHeight<r.scrollHeight||n.clientWidth<r.scrollWidth)}(p)}return!1}function j(p,m,s,r,n,u,o,t){return u<p&&o>m||u>p&&o<m?0:u<=p&&t<=s||o>=m&&t>=s?u-p-r:o>m&&t<s||u<p&&t>s?o-m+n:0}var I=function(p,m){var s=window,r=m.scrollMode,n=m.block,u=m.inline,o=m.boundary,t=m.skipOverflowHiddenElements,e=typeof o=="function"?o:function(Ce){return Ce!==o};if(!he(p))throw new TypeError("Invalid target");for(var i=document.scrollingElement||document.documentElement,T=[],_=p;he(_)&&e(_);){if((_=_.parentElement)===i){T.push(_);break}_!=null&&_===document.body&&w(_)&&!w(document.documentElement)||_!=null&&w(_,t)&&T.push(_)}for(var y=s.visualViewport?s.visualViewport.width:innerWidth,E=s.visualViewport?s.visualViewport.height:innerHeight,b=window.scrollX||pageXOffset,g=window.scrollY||pageYOffset,d=p.getBoundingClientRect(),a=d.height,l=d.width,f=d.top,c=d.right,x=d.bottom,R=d.left,C=n==="start"||n==="nearest"?f:n==="end"?x:f+a/2,N=u==="center"?R+l/2:u==="end"?c:R,U=[],W=0;W<T.length;W++){var L=T[W],H=L.getBoundingClientRect(),K=H.height,$=H.width,Q=H.top,ue=H.right,ne=H.bottom,se=H.left;if(r==="if-needed"&&f>=0&&R>=0&&x<=E&&c<=y&&f>=Q&&x<=ne&&R>=se&&c<=ue)return U;var le=getComputedStyle(L),de=parseInt(le.borderLeftWidth,10),re=parseInt(le.borderTopWidth,10),Y=parseInt(le.borderRightWidth,10),pe=parseInt(le.borderBottomWidth,10),Te=0,xe=0,Se="offsetWidth"in L?L.offsetWidth-L.clientWidth-de-Y:0,Ae="offsetHeight"in L?L.offsetHeight-L.clientHeight-re-pe:0;if(i===L)Te=n==="start"?C:n==="end"?C-E:n==="nearest"?j(g,g+E,E,re,pe,g+C,g+C+a,a):C-E/2,xe=u==="start"?N:u==="center"?N-y/2:u==="end"?N-y:j(b,b+y,y,de,Y,b+N,b+N+l,l),Te=Math.max(0,Te+g),xe=Math.max(0,xe+b);else{Te=n==="start"?C-Q-re:n==="end"?C-ne+pe+Ae:n==="nearest"?j(Q,ne,K,re,pe+Ae,C,C+a,a):C-(Q+K/2)+Ae/2,xe=u==="start"?N-se-de:u==="center"?N-(se+$/2)+Se/2:u==="end"?N-ue+Y+Se:j(se,ue,$,de,Y+Se,N,N+l,l);var fe=L.scrollLeft,ve=L.scrollTop;C+=ve-(Te=Math.max(0,Math.min(ve+Te,L.scrollHeight-K+Ae))),N+=fe-(xe=Math.max(0,Math.min(fe+xe,L.scrollWidth-$+Se)))}U.push({el:L,top:Te,left:xe})}return U};function O(p){return p===Object(p)&&Object.keys(p).length!==0}function B(p,m){m===void 0&&(m="auto");var s="scrollBehavior"in document.body.style;p.forEach(function(r){var n=r.el,u=r.top,o=r.left;n.scroll&&s?n.scroll({top:u,left:o,behavior:m}):(n.scrollTop=u,n.scrollLeft=o)})}function M(p){return p===!1?{block:"end",inline:"nearest"}:O(p)?p:{block:"start",inline:"nearest"}}function A(p,m){var s=!p.ownerDocument.documentElement.contains(p);if(O(m)&&typeof m.behavior=="function")return m.behavior(s?[]:I(p,m));if(s)return;var r=M(m);return B(I(p,r),r.behavior)}var S=Ve.a=A},bT9E:function(Je,Ve,ee){"use strict";ee.d(Ve,"a",function(){return G});var he=ee("VTBJ");function G(w,j){var I=Object(he.a)({},w);return Array.isArray(j)&&j.forEach(function(O){delete I[O]}),I}},kzJb:function(Je,Ve,ee){Je.exports={flex_box_center:"flex_box_center___2qtoc",flex_space_between:"flex_space_between___NF1Yf",flex_box_vertical_center:"flex_box_vertical_center___2qH_j",flex_box_center_end:"flex_box_center_end___22P0N",flex_box_column:"flex_box_column___1IKP8",userInfo:"userInfo___2Dupy",navInfo:"navInfo___3fEvD",actived:"actived___3F322",newTip:"newTip___1Ta-b"}},p5ED:function(Je,Ve,ee){"use strict";var he=ee("+L6B"),G=ee("2/Rp"),w=ee("5Dmo"),j=ee("3S7+"),I=ee("k1fw"),O=ee("tJVT"),B=ee("q1tI"),M=ee.n(B),A=ee("vHTk"),S=ee.n(A),p=ee("yEEn"),m=ee("ZW9T"),s=ee("1vsH");Ve.a=function(r){var n=r.name,u=r.data,o=r.theme,t=r.type,e=r.filename,i=r.monacoEditor,T=r.className,_=r.style,y=r.close,E=r.onClose,b=r.hasMask,g=Object(B.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),d=Object(O.a)(g,2),a=d[0],l=d[1],f=Object(B.useState)(""),c=Object(O.a)(f,2),x=c[0],R=c[1],C,N=1024*1024,U=10*N,W=Object(B.useRef)();t==="office"&&(C=Object(s.T)(u).filesize,C>U&&(t="other")),e&&(i.filename=e),Object(B.useEffect)(function(){var K,$,Q=(K=document.cookie)===null||K===void 0||(($=K.replace(/\s/g,""))===null||$===void 0)?void 0:$.split(";");Q==null||Q.map(function(ue){var ne=ue.split("=");ne[0]==="_educoder_session"&&R(ne[1])})},[]);var L=function(){if(u.startsWith("http")||u.startsWith("/")){H();return}Object(s.z)(e||"educoder",u,e)},H=function(){Object(s.x)(e||n,u)};return console.log("data:",u,"fileanme:",e," name:",n),M.a.createElement("div",{style:Object(I.a)({},_||{}),className:"".concat(b&&S.a.bgBlack," ").concat(t?S.a.wrp:"hide")},y&&M.a.createElement("div",{className:S.a.close,ref:W},M.a.createElement(j.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return W.current}},M.a.createElement("span",{onClick:H},M.a.createElement("i",{className:"icon-quxiaozhiding"}))),M.a.createElement(j.a,{title:"\u5173\u95ED",getPopupContainer:function(){return W.current}},M.a.createElement("span",{className:"",onClick:E},M.a.createElement("i",{className:"icon-guanbi1"})))),M.a.createElement("div",{className:"".concat(S.a[T]," ").concat(T," ").concat(S.a.monaco," ").concat(t==="txt"?"show":"hide")},t==="txt"&&M.a.createElement(m.b,i)),t==="audio"&&M.a.createElement("audio",{src:"".concat(u!=null&&u.startsWith("/")||(u==null?void 0:u.indexOf("https://"))>-1?u:"data:audio/mp3;base64,").concat(u),autoPlay:!0}),t==="video"&&M.a.createElement(M.a.Fragment,null,u!=null&&u.startsWith("/")?M.a.createElement("video",{controls:!0,src:"".concat(u),autoPlay:!0}):M.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(u),autoPlay:!0})),t==="html"&&M.a.createElement("iframe",{src:u+"&disposition=inline"}),t==="pdf"&&M.a.createElement("embed",{className:S.a.embed,src:u}),t==="image"&&M.a.createElement(M.a.Fragment,null,M.a.createElement("img",{src:"".concat(u!=null&&u.startsWith("/")||(u==null?void 0:u.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(u)})),t==="other"&&M.a.createElement("div",null,M.a.createElement(G.a,{type:"primary",size:"large",onClick:L},M.a.createElement(p.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),(t==="download"||t==="office")&&M.a.createElement(G.a,{type:"primary",size:"large",onClick:L},M.a.createElement(p.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},psGv:function(Je,Ve,ee){var he,G;(function(){var w;(function(){"use strict";var B=[,,function(p){function m(n){this.__parent=n,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}m.prototype.clone_empty=function(){var n=new m(this.__parent);return n.set_indent(this.__indent_count,this.__alignment_count),n},m.prototype.item=function(n){return n<0?this.__items[this.__items.length+n]:this.__items[n]},m.prototype.has_match=function(n){for(var u=this.__items.length-1;u>=0;u--)if(this.__items[u].match(n))return!0;return!1},m.prototype.set_indent=function(n,u){this.is_empty()&&(this.__indent_count=n||0,this.__alignment_count=u||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},m.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},m.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},m.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var n=this.__parent.current_line;return n.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),n.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),n.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,n.__items[0]===" "&&(n.__items.splice(0,1),n.__character_count-=1),!0}return!1},m.prototype.is_empty=function(){return this.__items.length===0},m.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},m.prototype.push=function(n){this.__items.push(n);var u=n.lastIndexOf(`
`);u!==-1?this.__character_count=n.length-u:this.__character_count+=n.length},m.prototype.pop=function(){var n=null;return this.is_empty()||(n=this.__items.pop(),this.__character_count-=n.length),n},m.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},m.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},m.prototype.trim=function(){for(;this.last()===" ";)this.__items.pop(),this.__character_count-=1},m.prototype.toString=function(){var n="";return this.is_empty()?this.__parent.indent_empty_lines&&(n=this.__parent.get_indent_string(this.__indent_count)):(n=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),n+=this.__items.join("")),n};function s(n,u){this.__cache=[""],this.__indent_size=n.indent_size,this.__indent_string=n.indent_char,n.indent_with_tabs||(this.__indent_string=new Array(n.indent_size+1).join(n.indent_char)),u=u||"",n.indent_level>0&&(u=new Array(n.indent_level+1).join(this.__indent_string)),this.__base_string=u,this.__base_string_length=u.length}s.prototype.get_indent_size=function(n,u){var o=this.__base_string_length;return u=u||0,n<0&&(o=0),o+=n*this.__indent_size,o+=u,o},s.prototype.get_indent_string=function(n,u){var o=this.__base_string;return u=u||0,n<0&&(n=0,o=""),u+=n*this.__indent_size,this.__ensure_cache(u),o+=this.__cache[u],o},s.prototype.__ensure_cache=function(n){for(;n>=this.__cache.length;)this.__add_column()},s.prototype.__add_column=function(){var n=this.__cache.length,u=0,o="";this.__indent_size&&n>=this.__indent_size&&(u=Math.floor(n/this.__indent_size),n-=u*this.__indent_size,o=new Array(u+1).join(this.__indent_string)),n&&(o+=new Array(n+1).join(" ")),this.__cache.push(o)};function r(n,u){this.__indent_cache=new s(n,u),this.raw=!1,this._end_with_newline=n.end_with_newline,this.indent_size=n.indent_size,this.wrap_line_length=n.wrap_line_length,this.indent_empty_lines=n.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new m(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}r.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},r.prototype.get_line_number=function(){return this.__lines.length},r.prototype.get_indent_string=function(n,u){return this.__indent_cache.get_indent_string(n,u)},r.prototype.get_indent_size=function(n,u){return this.__indent_cache.get_indent_size(n,u)},r.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},r.prototype.add_new_line=function(n){return this.is_empty()||!n&&this.just_added_newline()?!1:(this.raw||this.__add_outputline(),!0)},r.prototype.get_code=function(n){this.trim(!0);var u=this.current_line.pop();u&&(u[u.length-1]===`
`&&(u=u.replace(/\n+$/g,"")),this.current_line.push(u)),this._end_with_newline&&this.__add_outputline();var o=this.__lines.join(`
`);return n!==`
`&&(o=o.replace(/[\n]/g,n)),o},r.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},r.prototype.set_indent=function(n,u){return n=n||0,u=u||0,this.next_line.set_indent(n,u),this.__lines.length>1?(this.current_line.set_indent(n,u),!0):(this.current_line.set_indent(),!1)},r.prototype.add_raw_token=function(n){for(var u=0;u<n.newlines;u++)this.__add_outputline();this.current_line.set_indent(-1),this.current_line.push(n.whitespace_before),this.current_line.push(n.text),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1},r.prototype.add_token=function(n){this.__add_space_before_token(),this.current_line.push(n),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=this.current_line._allow_wrap()},r.prototype.__add_space_before_token=function(){this.space_before_token&&!this.just_added_newline()&&(this.non_breaking_space||this.set_wrap_point(),this.current_line.push(" "))},r.prototype.remove_indent=function(n){for(var u=this.__lines.length;n<u;)this.__lines[n]._remove_indent(),n++;this.current_line._remove_wrap_indent()},r.prototype.trim=function(n){for(n=n===void 0?!1:n,this.current_line.trim();n&&this.__lines.length>1&&this.current_line.is_empty();)this.__lines.pop(),this.current_line=this.__lines[this.__lines.length-1],this.current_line.trim();this.previous_line=this.__lines.length>1?this.__lines[this.__lines.length-2]:null},r.prototype.just_added_newline=function(){return this.current_line.is_empty()},r.prototype.just_added_blankline=function(){return this.is_empty()||this.current_line.is_empty()&&this.previous_line.is_empty()},r.prototype.ensure_empty_line_above=function(n,u){for(var o=this.__lines.length-2;o>=0;){var t=this.__lines[o];if(t.is_empty())break;if(t.item(0).indexOf(n)!==0&&t.item(-1)!==u){this.__lines.splice(o+1,0,new m(this)),this.previous_line=this.__lines[this.__lines.length-2];break}o--}},p.exports.Output=r},function(p){function m(s,r,n,u){this.type=s,this.text=r,this.comments_before=null,this.newlines=n||0,this.whitespace_before=u||"",this.parent=null,this.next=null,this.previous=null,this.opened=null,this.closed=null,this.directives=null}p.exports.Token=m},,,function(p){function m(n,u){this.raw_options=s(n,u),this.disabled=this._get_boolean("disabled"),this.eol=this._get_characters("eol","auto"),this.end_with_newline=this._get_boolean("end_with_newline"),this.indent_size=this._get_number("indent_size",4),this.indent_char=this._get_characters("indent_char"," "),this.indent_level=this._get_number("indent_level"),this.preserve_newlines=this._get_boolean("preserve_newlines",!0),this.max_preserve_newlines=this._get_number("max_preserve_newlines",32786),this.preserve_newlines||(this.max_preserve_newlines=0),this.indent_with_tabs=this._get_boolean("indent_with_tabs",this.indent_char===" "),this.indent_with_tabs&&(this.indent_char=" ",this.indent_size===1&&(this.indent_size=4)),this.wrap_line_length=this._get_number("wrap_line_length",this._get_number("max_char")),this.indent_empty_lines=this._get_boolean("indent_empty_lines"),this.templating=this._get_selection_list("templating",["auto","none","django","erb","handlebars","php","smarty"],["auto"])}m.prototype._get_array=function(n,u){var o=this.raw_options[n],t=u||[];return typeof o=="object"?o!==null&&typeof o.concat=="function"&&(t=o.concat()):typeof o=="string"&&(t=o.split(/[^a-zA-Z0-9_\/\-]+/)),t},m.prototype._get_boolean=function(n,u){var o=this.raw_options[n],t=o===void 0?!!u:!!o;return t},m.prototype._get_characters=function(n,u){var o=this.raw_options[n],t=u||"";return typeof o=="string"&&(t=o.replace(/\\r/,"\r").replace(/\\n/,`
`).replace(/\\t/," ")),t},m.prototype._get_number=function(n,u){var o=this.raw_options[n];u=parseInt(u,10),isNaN(u)&&(u=0);var t=parseInt(o,10);return isNaN(t)&&(t=u),t},m.prototype._get_selection=function(n,u,o){var t=this._get_selection_list(n,u,o);if(t.length!==1)throw new Error("Invalid Option Value: The option '"+n+`' can only be one of the following values:
`+u+`
You passed in: '`+this.raw_options[n]+"'");return t[0]},m.prototype._get_selection_list=function(n,u,o){if(!u||u.length===0)throw new Error("Selection list cannot be empty.");if(o=o||[u[0]],!this._is_valid_selection(o,u))throw new Error("Invalid Default Value!");var t=this._get_array(n,o);if(!this._is_valid_selection(t,u))throw new Error("Invalid Option Value: The option '"+n+`' can contain only the following values:
`+u+`
You passed in: '`+this.raw_options[n]+"'");return t},m.prototype._is_valid_selection=function(n,u){return n.length&&u.length&&!n.some(function(o){return u.indexOf(o)===-1})};function s(n,u){var o={};n=r(n);var t;for(t in n)t!==u&&(o[t]=n[t]);if(u&&n[u])for(t in n[u])o[t]=n[u][t];return o}function r(n){var u={},o;for(o in n){var t=o.replace(/-/g,"_");u[t]=n[o]}return u}p.exports.Options=m,p.exports.normalizeOpts=r,p.exports.mergeOpts=s},,function(p){var m=RegExp.prototype.hasOwnProperty("sticky");function s(r){this.__input=r||"",this.__input_length=this.__input.length,this.__position=0}s.prototype.restart=function(){this.__position=0},s.prototype.back=function(){this.__position>0&&(this.__position-=1)},s.prototype.hasNext=function(){return this.__position<this.__input_length},s.prototype.next=function(){var r=null;return this.hasNext()&&(r=this.__input.charAt(this.__position),this.__position+=1),r},s.prototype.peek=function(r){var n=null;return r=r||0,r+=this.__position,r>=0&&r<this.__input_length&&(n=this.__input.charAt(r)),n},s.prototype.__match=function(r,n){r.lastIndex=n;var u=r.exec(this.__input);return u&&!(m&&r.sticky)&&(u.index!==n&&(u=null)),u},s.prototype.test=function(r,n){return n=n||0,n+=this.__position,n>=0&&n<this.__input_length?!!this.__match(r,n):!1},s.prototype.testChar=function(r,n){var u=this.peek(n);return r.lastIndex=0,u!==null&&r.test(u)},s.prototype.match=function(r){var n=this.__match(r,this.__position);return n?this.__position+=n[0].length:n=null,n},s.prototype.read=function(r,n,u){var o="",t;return r&&(t=this.match(r),t&&(o+=t[0])),n&&(t||!r)&&(o+=this.readUntil(n,u)),o},s.prototype.readUntil=function(r,n){var u="",o=this.__position;r.lastIndex=this.__position;var t=r.exec(this.__input);return t?(o=t.index,n&&(o+=t[0].length)):o=this.__input_length,u=this.__input.substring(this.__position,o),this.__position=o,u},s.prototype.readUntilAfter=function(r){return this.readUntil(r,!0)},s.prototype.get_regexp=function(r,n){var u=null,o="g";return n&&m&&(o="y"),typeof r=="string"&&r!==""?u=new RegExp(r,o):r&&(u=new RegExp(r.source,o)),u},s.prototype.get_literal_regexp=function(r){return RegExp(r.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"))},s.prototype.peekUntilAfter=function(r){var n=this.__position,u=this.readUntilAfter(r);return this.__position=n,u},s.prototype.lookBack=function(r){var n=this.__position-1;return n>=r.length&&this.__input.substring(n-r.length,n).toLowerCase()===r},p.exports.InputScanner=s},function(p,m,s){var r=s(8).InputScanner,n=s(3).Token,u=s(10).TokenStream,o=s(11).WhitespacePattern,t={START:"TK_START",RAW:"TK_RAW",EOF:"TK_EOF"},e=function(i,T){this._input=new r(i),this._options=T||{},this.__tokens=null,this._patterns={},this._patterns.whitespace=new o(this._input)};e.prototype.tokenize=function(){this._input.restart(),this.__tokens=new u,this._reset();for(var i,T=new n(t.START,""),_=null,y=[],E=new u;T.type!==t.EOF;){for(i=this._get_next_token(T,_);this._is_comment(i);)E.add(i),i=this._get_next_token(T,_);E.isEmpty()||(i.comments_before=E,E=new u),i.parent=_,this._is_opening(i)?(y.push(_),_=i):_&&this._is_closing(i,_)&&(i.opened=_,_.closed=i,_=y.pop(),i.parent=_),i.previous=T,T.next=i,this.__tokens.add(i),T=i}return this.__tokens},e.prototype._is_first_token=function(){return this.__tokens.isEmpty()},e.prototype._reset=function(){},e.prototype._get_next_token=function(i,T){this._readWhitespace();var _=this._input.read(/.+/g);return _?this._create_token(t.RAW,_):this._create_token(t.EOF,"")},e.prototype._is_comment=function(i){return!1},e.prototype._is_opening=function(i){return!1},e.prototype._is_closing=function(i,T){return!1},e.prototype._create_token=function(i,T){var _=new n(i,T,this._patterns.whitespace.newline_count,this._patterns.whitespace.whitespace_before_token);return _},e.prototype._readWhitespace=function(){return this._patterns.whitespace.read()},p.exports.Tokenizer=e,p.exports.TOKEN=t},function(p){function m(s){this.__tokens=[],this.__tokens_length=this.__tokens.length,this.__position=0,this.__parent_token=s}m.prototype.restart=function(){this.__position=0},m.prototype.isEmpty=function(){return this.__tokens_length===0},m.prototype.hasNext=function(){return this.__position<this.__tokens_length},m.prototype.next=function(){var s=null;return this.hasNext()&&(s=this.__tokens[this.__position],this.__position+=1),s},m.prototype.peek=function(s){var r=null;return s=s||0,s+=this.__position,s>=0&&s<this.__tokens_length&&(r=this.__tokens[s]),r},m.prototype.add=function(s){this.__parent_token&&(s.parent=this.__parent_token),this.__tokens.push(s),this.__tokens_length+=1},p.exports.TokenStream=m},function(p,m,s){var r=s(12).Pattern;function n(u,o){r.call(this,u,o),o?this._line_regexp=this._input.get_regexp(o._line_regexp):this.__set_whitespace_patterns("",""),this.newline_count=0,this.whitespace_before_token=""}n.prototype=new r,n.prototype.__set_whitespace_patterns=function(u,o){u+="\\t ",o+="\\n\\r",this._match_pattern=this._input.get_regexp("["+u+o+"]+",!0),this._newline_regexp=this._input.get_regexp("\\r\\n|["+o+"]")},n.prototype.read=function(){this.newline_count=0,this.whitespace_before_token="";var u=this._input.read(this._match_pattern);if(u===" ")this.whitespace_before_token=" ";else if(u){var o=this.__split(this._newline_regexp,u);this.newline_count=o.length-1,this.whitespace_before_token=o[this.newline_count]}return u},n.prototype.matching=function(u,o){var t=this._create();return t.__set_whitespace_patterns(u,o),t._update(),t},n.prototype._create=function(){return new n(this._input,this)},n.prototype.__split=function(u,o){u.lastIndex=0;for(var t=0,e=[],i=u.exec(o);i;)e.push(o.substring(t,i.index)),t=i.index+i[0].length,i=u.exec(o);return t<o.length?e.push(o.substring(t,o.length)):e.push(""),e},p.exports.WhitespacePattern=n},function(p){function m(s,r){this._input=s,this._starting_pattern=null,this._match_pattern=null,this._until_pattern=null,this._until_after=!1,r&&(this._starting_pattern=this._input.get_regexp(r._starting_pattern,!0),this._match_pattern=this._input.get_regexp(r._match_pattern,!0),this._until_pattern=this._input.get_regexp(r._until_pattern),this._until_after=r._until_after)}m.prototype.read=function(){var s=this._input.read(this._starting_pattern);return(!this._starting_pattern||s)&&(s+=this._input.read(this._match_pattern,this._until_pattern,this._until_after)),s},m.prototype.read_match=function(){return this._input.match(this._match_pattern)},m.prototype.until_after=function(s){var r=this._create();return r._until_after=!0,r._until_pattern=this._input.get_regexp(s),r._update(),r},m.prototype.until=function(s){var r=this._create();return r._until_after=!1,r._until_pattern=this._input.get_regexp(s),r._update(),r},m.prototype.starting_with=function(s){var r=this._create();return r._starting_pattern=this._input.get_regexp(s,!0),r._update(),r},m.prototype.matching=function(s){var r=this._create();return r._match_pattern=this._input.get_regexp(s,!0),r._update(),r},m.prototype._create=function(){return new m(this._input,this)},m.prototype._update=function(){},p.exports.Pattern=m},function(p){function m(s,r){s=typeof s=="string"?s:s.source,r=typeof r=="string"?r:r.source,this.__directives_block_pattern=new RegExp(s+/ beautify( \w+[:]\w+)+ /.source+r,"g"),this.__directive_pattern=/ (\w+)[:](\w+)/g,this.__directives_end_ignore_pattern=new RegExp(s+/\sbeautify\signore:end\s/.source+r,"g")}m.prototype.get_directives=function(s){if(!s.match(this.__directives_block_pattern))return null;var r={};this.__directive_pattern.lastIndex=0;for(var n=this.__directive_pattern.exec(s);n;)r[n[1]]=n[2],n=this.__directive_pattern.exec(s);return r},m.prototype.readIgnored=function(s){return s.readUntilAfter(this.__directives_end_ignore_pattern)},p.exports.Directives=m},function(p,m,s){var r=s(12).Pattern,n={django:!1,erb:!1,handlebars:!1,php:!1,smarty:!1};function u(o,t){r.call(this,o,t),this.__template_pattern=null,this._disabled=Object.assign({},n),this._excluded=Object.assign({},n),t&&(this.__template_pattern=this._input.get_regexp(t.__template_pattern),this._excluded=Object.assign(this._excluded,t._excluded),this._disabled=Object.assign(this._disabled,t._disabled));var e=new r(o);this.__patterns={handlebars_comment:e.starting_with(/{{!--/).until_after(/--}}/),handlebars_unescaped:e.starting_with(/{{{/).until_after(/}}}/),handlebars:e.starting_with(/{{/).until_after(/}}/),php:e.starting_with(/<\?(?:[= ]|php)/).until_after(/\?>/),erb:e.starting_with(/<%[^%]/).until_after(/[^%]%>/),django:e.starting_with(/{%/).until_after(/%}/),django_value:e.starting_with(/{{/).until_after(/}}/),django_comment:e.starting_with(/{#/).until_after(/#}/),smarty:e.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),smarty_comment:e.starting_with(/{\*/).until_after(/\*}/),smarty_literal:e.starting_with(/{literal}/).until_after(/{\/literal}/)}}u.prototype=new r,u.prototype._create=function(){return new u(this._input,this)},u.prototype._update=function(){this.__set_templated_pattern()},u.prototype.disable=function(o){var t=this._create();return t._disabled[o]=!0,t._update(),t},u.prototype.read_options=function(o){var t=this._create();for(var e in n)t._disabled[e]=o.templating.indexOf(e)===-1;return t._update(),t},u.prototype.exclude=function(o){var t=this._create();return t._excluded[o]=!0,t._update(),t},u.prototype.read=function(){var o="";this._match_pattern?o=this._input.read(this._starting_pattern):o=this._input.read(this._starting_pattern,this.__template_pattern);for(var t=this._read_template();t;)this._match_pattern?t+=this._input.read(this._match_pattern):t+=this._input.readUntil(this.__template_pattern),o+=t,t=this._read_template();return this._until_after&&(o+=this._input.readUntilAfter(this._until_pattern)),o},u.prototype.__set_templated_pattern=function(){var o=[];this._disabled.php||o.push(this.__patterns.php._starting_pattern.source),this._disabled.handlebars||o.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.erb||o.push(this.__patterns.erb._starting_pattern.source),this._disabled.django||(o.push(this.__patterns.django._starting_pattern.source),o.push(this.__patterns.django_value._starting_pattern.source),o.push(this.__patterns.django_comment._starting_pattern.source)),this._disabled.smarty||o.push(this.__patterns.smarty._starting_pattern.source),this._until_pattern&&o.push(this._until_pattern.source),this.__template_pattern=this._input.get_regexp("(?:"+o.join("|")+")")},u.prototype._read_template=function(){var o="",t=this._input.peek();if(t==="<"){var e=this._input.peek(1);!this._disabled.php&&!this._excluded.php&&e==="?"&&(o=o||this.__patterns.php.read()),!this._disabled.erb&&!this._excluded.erb&&e==="%"&&(o=o||this.__patterns.erb.read())}else t==="{"&&(!this._disabled.handlebars&&!this._excluded.handlebars&&(o=o||this.__patterns.handlebars_comment.read(),o=o||this.__patterns.handlebars_unescaped.read(),o=o||this.__patterns.handlebars.read()),this._disabled.django||(!this._excluded.django&&!this._excluded.handlebars&&(o=o||this.__patterns.django_value.read()),this._excluded.django||(o=o||this.__patterns.django_comment.read(),o=o||this.__patterns.django.read())),this._disabled.smarty||this._disabled.django&&this._disabled.handlebars&&(o=o||this.__patterns.smarty_comment.read(),o=o||this.__patterns.smarty_literal.read(),o=o||this.__patterns.smarty.read()));return o},p.exports.TemplatablePattern=u},,,,function(p,m,s){var r=s(19).Beautifier,n=s(20).Options;function u(o,t,e,i){var T=new r(o,t,e,i);return T.beautify()}p.exports=u,p.exports.defaultOptions=function(){return new n}},function(p,m,s){var r=s(20).Options,n=s(2).Output,u=s(21).Tokenizer,o=s(21).TOKEN,t=/\r\n|[\r\n]/,e=/\r\n|[\r\n]/g,i=function(f,c){this.indent_level=0,this.alignment_size=0,this.max_preserve_newlines=f.max_preserve_newlines,this.preserve_newlines=f.preserve_newlines,this._output=new n(f,c)};i.prototype.current_line_has_match=function(f){return this._output.current_line.has_match(f)},i.prototype.set_space_before_token=function(f,c){this._output.space_before_token=f,this._output.non_breaking_space=c},i.prototype.set_wrap_point=function(){this._output.set_indent(this.indent_level,this.alignment_size),this._output.set_wrap_point()},i.prototype.add_raw_token=function(f){this._output.add_raw_token(f)},i.prototype.print_preserved_newlines=function(f){var c=0;f.type!==o.TEXT&&f.previous.type!==o.TEXT&&(c=f.newlines?1:0),this.preserve_newlines&&(c=f.newlines<this.max_preserve_newlines+1?f.newlines:this.max_preserve_newlines+1);for(var x=0;x<c;x++)this.print_newline(x>0);return c!==0},i.prototype.traverse_whitespace=function(f){return f.whitespace_before||f.newlines?(this.print_preserved_newlines(f)||(this._output.space_before_token=!0),!0):!1},i.prototype.previous_token_wrapped=function(){return this._output.previous_token_wrapped},i.prototype.print_newline=function(f){this._output.add_new_line(f)},i.prototype.print_token=function(f){f.text&&(this._output.set_indent(this.indent_level,this.alignment_size),this._output.add_token(f.text))},i.prototype.indent=function(){this.indent_level++},i.prototype.get_full_indent=function(f){return f=this.indent_level+(f||0),f<1?"":this._output.get_indent_string(f)};var T=function(f){for(var c=null,x=f.next;x.type!==o.EOF&&f.closed!==x;){if(x.type===o.ATTRIBUTE&&x.text==="type"){x.next&&x.next.type===o.EQUALS&&x.next.next&&x.next.next.type===o.VALUE&&(c=x.next.next.text);break}x=x.next}return c},_=function(f,c){var x=null,R=null;return c.closed?(f==="script"?x="text/javascript":f==="style"&&(x="text/css"),x=T(c)||x,x.search("text/css")>-1?R="css":x.search(/module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/)>-1?R="javascript":x.search(/(text|application|dojo)\/(x-)?(html)/)>-1?R="html":x.search(/test\/null/)>-1&&(R="null"),R):null};function y(f,c){return c.indexOf(f)!==-1}function E(f,c,x){this.parent=f||null,this.tag=c?c.tag_name:"",this.indent_level=x||0,this.parser_token=c||null}function b(f){this._printer=f,this._current_frame=null}b.prototype.get_parser_token=function(){return this._current_frame?this._current_frame.parser_token:null},b.prototype.record_tag=function(f){var c=new E(this._current_frame,f,this._printer.indent_level);this._current_frame=c},b.prototype._try_pop_frame=function(f){var c=null;return f&&(c=f.parser_token,this._printer.indent_level=f.indent_level,this._current_frame=f.parent),c},b.prototype._get_frame=function(f,c){for(var x=this._current_frame;x&&!(f.indexOf(x.tag)!==-1);){if(c&&c.indexOf(x.tag)!==-1){x=null;break}x=x.parent}return x},b.prototype.try_pop=function(f,c){var x=this._get_frame([f],c);return this._try_pop_frame(x)},b.prototype.indent_to_tag=function(f){var c=this._get_frame(f);c&&(this._printer.indent_level=c.indent_level)};function g(f,c,x,R){this._source_text=f||"",c=c||{},this._js_beautify=x,this._css_beautify=R,this._tag_stack=null;var C=new r(c,"html");this._options=C,this._is_wrap_attributes_force=this._options.wrap_attributes.substr(0,"force".length)==="force",this._is_wrap_attributes_force_expand_multiline=this._options.wrap_attributes==="force-expand-multiline",this._is_wrap_attributes_force_aligned=this._options.wrap_attributes==="force-aligned",this._is_wrap_attributes_aligned_multiple=this._options.wrap_attributes==="aligned-multiple",this._is_wrap_attributes_preserve=this._options.wrap_attributes.substr(0,"preserve".length)==="preserve",this._is_wrap_attributes_preserve_aligned=this._options.wrap_attributes==="preserve-aligned"}g.prototype.beautify=function(){if(this._options.disabled)return this._source_text;var f=this._source_text,c=this._options.eol;this._options.eol==="auto"&&(c=`
`,f&&t.test(f)&&(c=f.match(t)[0])),f=f.replace(e,`
`);var x=f.match(/^[\t ]*/)[0],R={text:"",type:""},C=new d,N=new i(this._options,x),U=new u(f,this._options).tokenize();this._tag_stack=new b(N);for(var W=null,L=U.next();L.type!==o.EOF;)L.type===o.TAG_OPEN||L.type===o.COMMENT?(W=this._handle_tag_open(N,L,C,R),C=W):L.type===o.ATTRIBUTE||L.type===o.EQUALS||L.type===o.VALUE||L.type===o.TEXT&&!C.tag_complete?W=this._handle_inside_tag(N,L,C,U):L.type===o.TAG_CLOSE?W=this._handle_tag_close(N,L,C):L.type===o.TEXT?W=this._handle_text(N,L,C):N.add_raw_token(L),R=W,L=U.next();var H=N._output.get_code(c);return H},g.prototype._handle_tag_close=function(f,c,x){var R={text:c.text,type:c.type};return f.alignment_size=0,x.tag_complete=!0,f.set_space_before_token(c.newlines||c.whitespace_before!=="",!0),x.is_unformatted?f.add_raw_token(c):(x.tag_start_char==="<"&&(f.set_space_before_token(c.text[0]==="/",!0),this._is_wrap_attributes_force_expand_multiline&&x.has_wrapped_attrs&&f.print_newline(!1)),f.print_token(c)),x.indent_content&&!(x.is_unformatted||x.is_content_unformatted)&&(f.indent(),x.indent_content=!1),!x.is_inline_element&&!(x.is_unformatted||x.is_content_unformatted)&&f.set_wrap_point(),R},g.prototype._handle_inside_tag=function(f,c,x,R){var C=x.has_wrapped_attrs,N={text:c.text,type:c.type};if(f.set_space_before_token(c.newlines||c.whitespace_before!=="",!0),x.is_unformatted)f.add_raw_token(c);else if(x.tag_start_char==="{"&&c.type===o.TEXT)f.print_preserved_newlines(c)?(c.newlines=0,f.add_raw_token(c)):f.print_token(c);else{if(c.type===o.ATTRIBUTE?(f.set_space_before_token(!0),x.attr_count+=1):(c.type===o.EQUALS||c.type===o.VALUE&&c.previous.type===o.EQUALS)&&f.set_space_before_token(!1),c.type===o.ATTRIBUTE&&x.tag_start_char==="<"&&((this._is_wrap_attributes_preserve||this._is_wrap_attributes_preserve_aligned)&&(f.traverse_whitespace(c),C=C||c.newlines!==0),this._is_wrap_attributes_force)){var U=x.attr_count>1;if(this._is_wrap_attributes_force_expand_multiline&&x.attr_count===1){var W=!0,L=0,H;do{if(H=R.peek(L),H.type===o.ATTRIBUTE){W=!1;break}L+=1}while(L<4&&H.type!==o.EOF&&H.type!==o.TAG_CLOSE);U=!W}U&&(f.print_newline(!1),C=!0)}f.print_token(c),C=C||f.previous_token_wrapped(),x.has_wrapped_attrs=C}return N},g.prototype._handle_text=function(f,c,x){var R={text:c.text,type:"TK_CONTENT"};return x.custom_beautifier_name?this._print_custom_beatifier_text(f,c,x):x.is_unformatted||x.is_content_unformatted?f.add_raw_token(c):(f.traverse_whitespace(c),f.print_token(c)),R},g.prototype._print_custom_beatifier_text=function(f,c,x){var R=this;if(c.text!==""){var C=c.text,N,U=1,W="",L="";x.custom_beautifier_name==="javascript"&&typeof this._js_beautify=="function"?N=this._js_beautify:x.custom_beautifier_name==="css"&&typeof this._css_beautify=="function"?N=this._css_beautify:x.custom_beautifier_name==="html"&&(N=function(ne,se){var le=new g(ne,se,R._js_beautify,R._css_beautify);return le.beautify()}),this._options.indent_scripts==="keep"?U=0:this._options.indent_scripts==="separate"&&(U=-f.indent_level);var H=f.get_full_indent(U);if(C=C.replace(/\n[ \t]*$/,""),x.custom_beautifier_name!=="html"&&C[0]==="<"&&C.match(/^(<!--|<!\[CDATA\[)/)){var K=/^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(C);if(!K){f.add_raw_token(c);return}W=H+K[1]+`
`,C=K[4],K[5]&&(L=H+K[5]),C=C.replace(/\n[ \t]*$/,""),(K[2]||K[3].indexOf(`
`)!==-1)&&(K=K[3].match(/[ \t]+$/),K&&(c.whitespace_before=K[0]))}if(C)if(N){var $=function(){this.eol=`
`};$.prototype=this._options.raw_options;var Q=new $;C=N(H+C,Q)}else{var ue=c.whitespace_before;ue&&(C=C.replace(new RegExp(`
(`+ue+")?","g"),`
`)),C=H+C.replace(/\n/g,`
`+H)}W&&(C?C=W+C+`
`+L:C=W+L),f.print_newline(!1),C&&(c.text=C,c.whitespace_before="",c.newlines=0,f.add_raw_token(c),f.print_newline(!0))}},g.prototype._handle_tag_open=function(f,c,x,R){var C=this._get_tag_open_token(c);return(x.is_unformatted||x.is_content_unformatted)&&!x.is_empty_element&&c.type===o.TAG_OPEN&&c.text.indexOf("</")===0?(f.add_raw_token(c),C.start_tag_token=this._tag_stack.try_pop(C.tag_name)):(f.traverse_whitespace(c),this._set_tag_position(f,c,C,x,R),C.is_inline_element||f.set_wrap_point(),f.print_token(c)),(this._is_wrap_attributes_force_aligned||this._is_wrap_attributes_aligned_multiple||this._is_wrap_attributes_preserve_aligned)&&(C.alignment_size=c.text.length+1),!C.tag_complete&&!C.is_unformatted&&(f.alignment_size=C.alignment_size),C};var d=function(f,c){if(this.parent=f||null,this.text="",this.type="TK_TAG_OPEN",this.tag_name="",this.is_inline_element=!1,this.is_unformatted=!1,this.is_content_unformatted=!1,this.is_empty_element=!1,this.is_start_tag=!1,this.is_end_tag=!1,this.indent_content=!1,this.multiline_content=!1,this.custom_beautifier_name=null,this.start_tag_token=null,this.attr_count=0,this.has_wrapped_attrs=!1,this.alignment_size=0,this.tag_complete=!1,this.tag_start_char="",this.tag_check="",!c)this.tag_complete=!0;else{var x;this.tag_start_char=c.text[0],this.text=c.text,this.tag_start_char==="<"?(x=c.text.match(/^<([^\s>]*)/),this.tag_check=x?x[1]:""):(x=c.text.match(/^{{~?(?:[\^]|#\*?)?([^\s}]+)/),this.tag_check=x?x[1]:"",(c.text.startsWith("{{#>")||c.text.startsWith("{{~#>"))&&this.tag_check[0]===">"&&(this.tag_check===">"&&c.next!==null?this.tag_check=c.next.text.split(" ")[0]:this.tag_check=c.text.split(">")[1])),this.tag_check=this.tag_check.toLowerCase(),c.type===o.COMMENT&&(this.tag_complete=!0),this.is_start_tag=this.tag_check.charAt(0)!=="/",this.tag_name=this.is_start_tag?this.tag_check:this.tag_check.substr(1),this.is_end_tag=!this.is_start_tag||c.closed&&c.closed.text==="/>";var R=2;this.tag_start_char==="{"&&this.text.length>=3&&(this.text.charAt(2)==="~"&&(R=3)),this.is_end_tag=this.is_end_tag||this.tag_start_char==="{"&&(this.text.length<3||/[^#\^]/.test(this.text.charAt(R)))}};g.prototype._get_tag_open_token=function(f){var c=new d(this._tag_stack.get_parser_token(),f);return c.alignment_size=this._options.wrap_attributes_indent_size,c.is_end_tag=c.is_end_tag||y(c.tag_check,this._options.void_elements),c.is_empty_element=c.tag_complete||c.is_start_tag&&c.is_end_tag,c.is_unformatted=!c.tag_complete&&y(c.tag_check,this._options.unformatted),c.is_content_unformatted=!c.is_empty_element&&y(c.tag_check,this._options.content_unformatted),c.is_inline_element=y(c.tag_name,this._options.inline)||c.tag_name.includes("-")||c.tag_start_char==="{",c},g.prototype._set_tag_position=function(f,c,x,R,C){if(x.is_empty_element||(x.is_end_tag?x.start_tag_token=this._tag_stack.try_pop(x.tag_name):(this._do_optional_end_element(x)&&(x.is_inline_element||f.print_newline(!1)),this._tag_stack.record_tag(x),(x.tag_name==="script"||x.tag_name==="style")&&!(x.is_unformatted||x.is_content_unformatted)&&(x.custom_beautifier_name=_(x.tag_check,c)))),y(x.tag_check,this._options.extra_liners)&&(f.print_newline(!1),f._output.just_added_blankline()||f.print_newline(!0)),x.is_empty_element){if(x.tag_start_char==="{"&&x.tag_check==="else"){this._tag_stack.indent_to_tag(["if","unless","each"]),x.indent_content=!0;var N=f.current_line_has_match(/{{#if/);N||f.print_newline(!1)}x.tag_name==="!--"&&C.type===o.TAG_CLOSE&&R.is_end_tag&&x.text.indexOf(`
`)===-1||(x.is_inline_element||x.is_unformatted||f.print_newline(!1),this._calcluate_parent_multiline(f,x))}else if(x.is_end_tag){var U=!1;U=x.start_tag_token&&x.start_tag_token.multiline_content,U=U||!x.is_inline_element&&!(R.is_inline_element||R.is_unformatted)&&!(C.type===o.TAG_CLOSE&&x.start_tag_token===R)&&C.type!=="TK_CONTENT",(x.is_content_unformatted||x.is_unformatted)&&(U=!1),U&&f.print_newline(!1)}else x.indent_content=!x.custom_beautifier_name,x.tag_start_char==="<"&&(x.tag_name==="html"?x.indent_content=this._options.indent_inner_html:x.tag_name==="head"?x.indent_content=this._options.indent_head_inner_html:x.tag_name==="body"&&(x.indent_content=this._options.indent_body_inner_html)),!(x.is_inline_element||x.is_unformatted)&&(C.type!=="TK_CONTENT"||x.is_content_unformatted)&&f.print_newline(!1),this._calcluate_parent_multiline(f,x)},g.prototype._calcluate_parent_multiline=function(f,c){c.parent&&f._output.just_added_newline()&&!((c.is_inline_element||c.is_unformatted)&&c.parent.is_inline_element)&&(c.parent.multiline_content=!0)};var a=["address","article","aside","blockquote","details","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","main","nav","ol","p","pre","section","table","ul"],l=["a","audio","del","ins","map","noscript","video"];g.prototype._do_optional_end_element=function(f){var c=null;if(f.is_empty_element||!f.is_start_tag||!f.parent)return;if(f.tag_name==="body")c=c||this._tag_stack.try_pop("head");else if(f.tag_name==="li")c=c||this._tag_stack.try_pop("li",["ol","ul"]);else if(f.tag_name==="dd"||f.tag_name==="dt")c=c||this._tag_stack.try_pop("dt",["dl"]),c=c||this._tag_stack.try_pop("dd",["dl"]);else if(f.parent.tag_name==="p"&&a.indexOf(f.tag_name)!==-1){var x=f.parent.parent;(!x||l.indexOf(x.tag_name)===-1)&&(c=c||this._tag_stack.try_pop("p"))}else f.tag_name==="rp"||f.tag_name==="rt"?(c=c||this._tag_stack.try_pop("rt",["ruby","rtc"]),c=c||this._tag_stack.try_pop("rp",["ruby","rtc"])):f.tag_name==="optgroup"?c=c||this._tag_stack.try_pop("optgroup",["select"]):f.tag_name==="option"?c=c||this._tag_stack.try_pop("option",["select","datalist","optgroup"]):f.tag_name==="colgroup"?c=c||this._tag_stack.try_pop("caption",["table"]):f.tag_name==="thead"?(c=c||this._tag_stack.try_pop("caption",["table"]),c=c||this._tag_stack.try_pop("colgroup",["table"])):f.tag_name==="tbody"||f.tag_name==="tfoot"?(c=c||this._tag_stack.try_pop("caption",["table"]),c=c||this._tag_stack.try_pop("colgroup",["table"]),c=c||this._tag_stack.try_pop("thead",["table"]),c=c||this._tag_stack.try_pop("tbody",["table"])):f.tag_name==="tr"?(c=c||this._tag_stack.try_pop("caption",["table"]),c=c||this._tag_stack.try_pop("colgroup",["table"]),c=c||this._tag_stack.try_pop("tr",["table","thead","tbody","tfoot"])):(f.tag_name==="th"||f.tag_name==="td")&&(c=c||this._tag_stack.try_pop("td",["table","thead","tbody","tfoot","tr"]),c=c||this._tag_stack.try_pop("th",["table","thead","tbody","tfoot","tr"]));return f.parent=this._tag_stack.get_parser_token(),c},p.exports.Beautifier=g},function(p,m,s){var r=s(6).Options;function n(u){r.call(this,u,"html"),this.templating.length===1&&this.templating[0]==="auto"&&(this.templating=["django","erb","handlebars","php"]),this.indent_inner_html=this._get_boolean("indent_inner_html"),this.indent_body_inner_html=this._get_boolean("indent_body_inner_html",!0),this.indent_head_inner_html=this._get_boolean("indent_head_inner_html",!0),this.indent_handlebars=this._get_boolean("indent_handlebars",!0),this.wrap_attributes=this._get_selection("wrap_attributes",["auto","force","force-aligned","force-expand-multiline","aligned-multiple","preserve","preserve-aligned"]),this.wrap_attributes_indent_size=this._get_number("wrap_attributes_indent_size",this.indent_size),this.extra_liners=this._get_array("extra_liners",["head","body","/html"]),this.inline=this._get_array("inline",["a","abbr","area","audio","b","bdi","bdo","br","button","canvas","cite","code","data","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","keygen","label","map","mark","math","meter","noscript","object","output","progress","q","ruby","s","samp","select","small","span","strong","sub","sup","svg","template","textarea","time","u","var","video","wbr","text","acronym","big","strike","tt"]),this.void_elements=this._get_array("void_elements",["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr","!doctype","?xml","basefont","isindex"]),this.unformatted=this._get_array("unformatted",[]),this.content_unformatted=this._get_array("content_unformatted",["pre","textarea"]),this.unformatted_content_delimiter=this._get_characters("unformatted_content_delimiter"),this.indent_scripts=this._get_selection("indent_scripts",["normal","keep","separate"])}n.prototype=new r,p.exports.Options=n},function(p,m,s){var r=s(9).Tokenizer,n=s(9).TOKEN,u=s(13).Directives,o=s(14).TemplatablePattern,t=s(12).Pattern,e={TAG_OPEN:"TK_TAG_OPEN",TAG_CLOSE:"TK_TAG_CLOSE",ATTRIBUTE:"TK_ATTRIBUTE",EQUALS:"TK_EQUALS",VALUE:"TK_VALUE",COMMENT:"TK_COMMENT",TEXT:"TK_TEXT",UNKNOWN:"TK_UNKNOWN",START:n.START,RAW:n.RAW,EOF:n.EOF},i=new u(/<\!--/,/-->/),T=function(_,y){r.call(this,_,y),this._current_tag_name="";var E=new o(this._input).read_options(this._options),b=new t(this._input);if(this.__patterns={word:E.until(/[\n\r\t <]/),single_quote:E.until_after(/'/),double_quote:E.until_after(/"/),attribute:E.until(/[\n\r\t =>]|\/>/),element_name:E.until(/[\n\r\t >\/]/),handlebars_comment:b.starting_with(/{{!--/).until_after(/--}}/),handlebars:b.starting_with(/{{/).until_after(/}}/),handlebars_open:b.until(/[\n\r\t }]/),handlebars_raw_close:b.until(/}}/),comment:b.starting_with(/<!--/).until_after(/-->/),cdata:b.starting_with(/<!\[CDATA\[/).until_after(/]]>/),conditional_comment:b.starting_with(/<!\[/).until_after(/]>/),processing:b.starting_with(/<\?/).until_after(/\?>/)},this._options.indent_handlebars&&(this.__patterns.word=this.__patterns.word.exclude("handlebars")),this._unformatted_content_delimiter=null,this._options.unformatted_content_delimiter){var g=this._input.get_literal_regexp(this._options.unformatted_content_delimiter);this.__patterns.unformatted_content_delimiter=b.matching(g).until_after(g)}};T.prototype=new r,T.prototype._is_comment=function(_){return!1},T.prototype._is_opening=function(_){return _.type===e.TAG_OPEN},T.prototype._is_closing=function(_,y){return _.type===e.TAG_CLOSE&&y&&((_.text===">"||_.text==="/>")&&y.text[0]==="<"||_.text==="}}"&&y.text[0]==="{"&&y.text[1]==="{")},T.prototype._reset=function(){this._current_tag_name=""},T.prototype._get_next_token=function(_,y){var E=null;this._readWhitespace();var b=this._input.peek();return b===null?this._create_token(e.EOF,""):(E=E||this._read_open_handlebars(b,y),E=E||this._read_attribute(b,_,y),E=E||this._read_close(b,y),E=E||this._read_raw_content(b,_,y),E=E||this._read_content_word(b),E=E||this._read_comment_or_cdata(b),E=E||this._read_processing(b),E=E||this._read_open(b,y),E=E||this._create_token(e.UNKNOWN,this._input.next()),E)},T.prototype._read_comment_or_cdata=function(_){var y=null,E=null,b=null;if(_==="<"){var g=this._input.peek(1);g==="!"&&(E=this.__patterns.comment.read(),E?(b=i.get_directives(E),b&&b.ignore==="start"&&(E+=i.readIgnored(this._input))):E=this.__patterns.cdata.read()),E&&(y=this._create_token(e.COMMENT,E),y.directives=b)}return y},T.prototype._read_processing=function(_){var y=null,E=null,b=null;if(_==="<"){var g=this._input.peek(1);(g==="!"||g==="?")&&(E=this.__patterns.conditional_comment.read(),E=E||this.__patterns.processing.read()),E&&(y=this._create_token(e.COMMENT,E),y.directives=b)}return y},T.prototype._read_open=function(_,y){var E=null,b=null;return y||_==="<"&&(E=this._input.next(),this._input.peek()==="/"&&(E+=this._input.next()),E+=this.__patterns.element_name.read(),b=this._create_token(e.TAG_OPEN,E)),b},T.prototype._read_open_handlebars=function(_,y){var E=null,b=null;return y||this._options.indent_handlebars&&_==="{"&&this._input.peek(1)==="{"&&(this._input.peek(2)==="!"?(E=this.__patterns.handlebars_comment.read(),E=E||this.__patterns.handlebars.read(),b=this._create_token(e.COMMENT,E)):(E=this.__patterns.handlebars_open.read(),b=this._create_token(e.TAG_OPEN,E))),b},T.prototype._read_close=function(_,y){var E=null,b=null;return y&&(y.text[0]==="<"&&(_===">"||_==="/"&&this._input.peek(1)===">")?(E=this._input.next(),_==="/"&&(E+=this._input.next()),b=this._create_token(e.TAG_CLOSE,E)):y.text[0]==="{"&&_==="}"&&this._input.peek(1)==="}"&&(this._input.next(),this._input.next(),b=this._create_token(e.TAG_CLOSE,"}}"))),b},T.prototype._read_attribute=function(_,y,E){var b=null,g="";if(E&&E.text[0]==="<")if(_==="=")b=this._create_token(e.EQUALS,this._input.next());else if(_==='"'||_==="'"){var d=this._input.next();_==='"'?d+=this.__patterns.double_quote.read():d+=this.__patterns.single_quote.read(),b=this._create_token(e.VALUE,d)}else g=this.__patterns.attribute.read(),g&&(y.type===e.EQUALS?b=this._create_token(e.VALUE,g):b=this._create_token(e.ATTRIBUTE,g));return b},T.prototype._is_content_unformatted=function(_){return this._options.void_elements.indexOf(_)===-1&&(this._options.content_unformatted.indexOf(_)!==-1||this._options.unformatted.indexOf(_)!==-1)},T.prototype._read_raw_content=function(_,y,E){var b="";if(E&&E.text[0]==="{")b=this.__patterns.handlebars_raw_close.read();else if(y.type===e.TAG_CLOSE&&y.opened.text[0]==="<"&&y.text[0]!=="/"){var g=y.opened.text.substr(1).toLowerCase();if(g==="script"||g==="style"){var d=this._read_comment_or_cdata(_);if(d)return d.type=e.TEXT,d;b=this._input.readUntil(new RegExp("</"+g+"[\\n\\r\\t ]*?>","ig"))}else this._is_content_unformatted(g)&&(b=this._input.readUntil(new RegExp("</"+g+"[\\n\\r\\t ]*?>","ig")))}return b?this._create_token(e.TEXT,b):null},T.prototype._read_content_word=function(_){var y="";if(this._options.unformatted_content_delimiter&&(_===this._options.unformatted_content_delimiter[0]&&(y=this.__patterns.unformatted_content_delimiter.read())),y||(y=this.__patterns.word.read()),y)return this._create_token(e.TEXT,y)},p.exports.Tokenizer=T,p.exports.TOKEN=e}],M={};function A(p){var m=M[p];if(m!==void 0)return m.exports;var s=M[p]={exports:{}};return B[p](s,s.exports,A),s.exports}var S=A(18);w=S})();var j=w;if(!0)!(he=[ee,ee("6UM0"),ee("TXwP")],G=function(B){var M=ee("6UM0"),A=ee("TXwP");return{html_beautify:function(S,p){return j(S,p,M.js_beautify,A.css_beautify)}}}.apply(Ve,he),G!==void 0&&(Je.exports=G));else var I,O})()},"rAM+":function(Je,Ve,ee){"use strict";ee.d(Ve,"a",function(){return G});var he=ee("Qw5x");function G(w,j){var I;if(typeof Symbol=="undefined"||w[Symbol.iterator]==null){if(Array.isArray(w)||(I=Object(he.a)(w))||j&&w&&typeof w.length=="number"){I&&(w=I);var O=0,B=function(){};return{s:B,n:function(){return O>=w.length?{done:!0}:{done:!1,value:w[O++]}},e:function(m){throw m},f:B}}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,S;return{s:function(){I=w[Symbol.iterator]()},n:function(){var m=I.next();return M=m.done,m},e:function(m){A=!0,S=m},f:function(){try{!M&&I.return!=null&&I.return()}finally{if(A)throw S}}}}},rUJ1:function(Je,Ve){const ee=/[&<>"']/,he=/[&<>"']/g,G=/[<>"']|&(?!#?\w+;)/,w=/[<>"']|&(?!#?\w+;)/g,j={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},I=b=>j[b];function O(b,g){if(g){if(ee.test(b))return b.replace(he,I)}else if(G.test(b))return b.replace(w,I);return b}const B=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function M(b){return b.replace(B,(g,d)=>(d=d.toLowerCase(),d==="colon"?":":d.charAt(0)==="#"?d.charAt(1)==="x"?String.fromCharCode(parseInt(d.substring(2),16)):String.fromCharCode(+d.substring(1)):""))}const A=/(^|[^\[])\^/g;function S(b,g){b=b.source||b,g=g||"";const d={replace:(a,l)=>(l=l.source||l,l=l.replace(A,"$1"),b=b.replace(a,l),d),getRegex:()=>new RegExp(b,g)};return d}const p=/[^\w:]/g,m=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function s(b,g,d){if(b){let a;try{a=decodeURIComponent(M(d)).replace(p,"").toLowerCase()}catch(l){return null}if(a.indexOf("javascript:")===0||a.indexOf("vbscript:")===0||a.indexOf("data:")===0)return null}g&&!m.test(d)&&(d=t(g,d));try{d=encodeURI(d).replace(/%25/g,"%")}catch(a){return null}return d}const r={},n=/^[^:]+:\/*[^/]*$/,u=/^([^:]+:)[\s\S]*$/,o=/^([^:]+:\/*[^/]*)[\s\S]*$/;function t(b,g){r[" "+b]||(n.test(b)?r[" "+b]=b+"/":r[" "+b]=_(b,"/",!0)),b=r[" "+b];const d=b.indexOf(":")===-1;return g.substring(0,2)==="//"?d?g:b.replace(u,"$1")+g:g.charAt(0)==="/"?d?g:b.replace(o,"$1")+g:b+g}const e={exec:function(){}};function i(b){let g=1,d,a;for(;g<arguments.length;g++){d=arguments[g];for(a in d)Object.prototype.hasOwnProperty.call(d,a)&&(b[a]=d[a])}return b}function T(b,g){const d=b.replace(/\|/g,(f,c,x)=>{let R=!1,C=c;for(;--C>=0&&x[C]==="\\";)R=!R;return R?"|":" |"}),a=d.split(/ \|/);let l=0;if(a.length>g)a.splice(g);else for(;a.length<g;)a.push("");for(;l<a.length;l++)a[l]=a[l].trim().replace(/\\\|/g,"|");return a}function _(b,g,d){const a=b.length;if(a===0)return"";let l=0;for(;l<a;){const f=b.charAt(a-l-1);if(f===g&&!d)l++;else if(f!==g&&d)l++;else break}return b.substr(0,a-l)}function y(b,g){if(b.indexOf(g[1])===-1)return-1;const d=b.length;let a=0,l=0;for(;l<d;l++)if(b[l]==="\\")l++;else if(b[l]===g[0])a++;else if(b[l]===g[1]&&(a--,a<0))return l;return-1}function E(b){b&&b.sanitize&&!b.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")}Je.exports={escape:O,unescape:M,edit:S,cleanUrl:s,resolveUrl:t,noopTest:e,merge:i,splitCells:T,rtrim:_,findClosingBracket:y,checkSanitizeDeprecation:E}},ulZh:function(Je,Ve,ee){typeof window!="undefined"&&function(G,w){Je.exports=w()}(this,function(){return function(he){var G={};function w(j){if(G[j])return G[j].exports;var I=G[j]={i:j,l:!1,exports:{}};return he[j].call(I.exports,I,I.exports,w),I.l=!0,I.exports}return w.m=he,w.c=G,w.d=function(j,I,O){w.o(j,I)||Object.defineProperty(j,I,{enumerable:!0,get:O})},w.r=function(j){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(j,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(j,"__esModule",{value:!0})},w.t=function(j,I){if(I&1&&(j=w(j)),I&8)return j;if(I&4&&typeof j=="object"&&j&&j.__esModule)return j;var O=Object.create(null);if(w.r(O),Object.defineProperty(O,"default",{enumerable:!0,value:j}),I&2&&typeof j!="string")for(var B in j)w.d(O,B,function(M){return j[M]}.bind(null,B));return O},w.n=function(j){var I=j&&j.__esModule?function(){return j.default}:function(){return j};return w.d(I,"a",I),I},w.o=function(j,I){return Object.prototype.hasOwnProperty.call(j,I)},w.p="/dist/",w(w.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(he,G,w){"use strict";var j=Object.prototype.hasOwnProperty,I="~";function O(){}Object.create&&(O.prototype=Object.create(null),new O().__proto__||(I=!1));function B(p,m,s){this.fn=p,this.context=m,this.once=s||!1}function M(p,m,s,r,n){if(typeof s!="function")throw new TypeError("The listener must be a function");var u=new B(s,r||p,n),o=I?I+m:m;return p._events[o]?p._events[o].fn?p._events[o]=[p._events[o],u]:p._events[o].push(u):(p._events[o]=u,p._eventsCount++),p}function A(p,m){--p._eventsCount===0?p._events=new O:delete p._events[m]}function S(){this._events=new O,this._eventsCount=0}S.prototype.eventNames=function(){var m=[],s,r;if(this._eventsCount===0)return m;for(r in s=this._events)j.call(s,r)&&m.push(I?r.slice(1):r);return Object.getOwnPropertySymbols?m.concat(Object.getOwnPropertySymbols(s)):m},S.prototype.listeners=function(m){var s=I?I+m:m,r=this._events[s];if(!r)return[];if(r.fn)return[r.fn];for(var n=0,u=r.length,o=new Array(u);n<u;n++)o[n]=r[n].fn;return o},S.prototype.listenerCount=function(m){var s=I?I+m:m,r=this._events[s];return r?r.fn?1:r.length:0},S.prototype.emit=function(m,s,r,n,u,o){var t=I?I+m:m;if(!this._events[t])return!1;var e=this._events[t],i=arguments.length,T,_;if(e.fn){e.once&&this.removeListener(m,e.fn,void 0,!0);switch(i){case 1:return e.fn.call(e.context),!0;case 2:return e.fn.call(e.context,s),!0;case 3:return e.fn.call(e.context,s,r),!0;case 4:return e.fn.call(e.context,s,r,n),!0;case 5:return e.fn.call(e.context,s,r,n,u),!0;case 6:return e.fn.call(e.context,s,r,n,u,o),!0}for(_=1,T=new Array(i-1);_<i;_++)T[_-1]=arguments[_];e.fn.apply(e.context,T)}else{var y=e.length,E;for(_=0;_<y;_++){e[_].once&&this.removeListener(m,e[_].fn,void 0,!0);switch(i){case 1:e[_].fn.call(e[_].context);break;case 2:e[_].fn.call(e[_].context,s);break;case 3:e[_].fn.call(e[_].context,s,r);break;case 4:e[_].fn.call(e[_].context,s,r,n);break;default:if(!T)for(E=1,T=new Array(i-1);E<i;E++)T[E-1]=arguments[E];e[_].fn.apply(e[_].context,T)}}}return!0},S.prototype.on=function(m,s,r){return M(this,m,s,r,!1)},S.prototype.once=function(m,s,r){return M(this,m,s,r,!0)},S.prototype.removeListener=function(m,s,r,n){var u=I?I+m:m;if(!this._events[u])return this;if(!s)return A(this,u),this;var o=this._events[u];if(o.fn)o.fn===s&&(!n||o.once)&&(!r||o.context===r)&&A(this,u);else{for(var t=0,e=[],i=o.length;t<i;t++)(o[t].fn!==s||n&&!o[t].once||r&&o[t].context!==r)&&e.push(o[t]);e.length?this._events[u]=e.length===1?e[0]:e:A(this,u)}return this},S.prototype.removeAllListeners=function(m){var s;return m?(s=I?I+m:m,this._events[s]&&A(this,s)):(this._events=new O,this._eventsCount=0),this},S.prototype.off=S.prototype.removeListener,S.prototype.addListener=S.prototype.on,S.prefixed=I,S.EventEmitter=S,he.exports=S},"./node_modules/url-toolkit/src/url-toolkit.js":function(he,G,w){(function(j){var I=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,O=/^([^\/?#]*)([^]*)$/,B=/(?:\/|^)\.(?=\/)/g,M=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,A={buildAbsoluteURL:function(S,p,m){if(m=m||{},S=S.trim(),p=p.trim(),!p){if(!m.alwaysNormalize)return S;var s=A.parseURL(S);if(!s)throw new Error("Error trying to parse base URL.");return s.path=A.normalizePath(s.path),A.buildURLFromParts(s)}var r=A.parseURL(p);if(!r)throw new Error("Error trying to parse relative URL.");if(r.scheme)return m.alwaysNormalize?(r.path=A.normalizePath(r.path),A.buildURLFromParts(r)):p;var n=A.parseURL(S);if(!n)throw new Error("Error trying to parse base URL.");if(!n.netLoc&&n.path&&n.path[0]!=="/"){var u=O.exec(n.path);n.netLoc=u[1],n.path=u[2]}n.netLoc&&!n.path&&(n.path="/");var o={scheme:n.scheme,netLoc:r.netLoc,path:null,params:r.params,query:r.query,fragment:r.fragment};if(!r.netLoc&&(o.netLoc=n.netLoc,r.path[0]!=="/"))if(!r.path)o.path=n.path,r.params||(o.params=n.params,r.query||(o.query=n.query));else{var t=n.path,e=t.substring(0,t.lastIndexOf("/")+1)+r.path;o.path=A.normalizePath(e)}return o.path===null&&(o.path=m.alwaysNormalize?A.normalizePath(r.path):r.path),A.buildURLFromParts(o)},parseURL:function(S){var p=I.exec(S);return p?{scheme:p[1]||"",netLoc:p[2]||"",path:p[3]||"",params:p[4]||"",query:p[5]||"",fragment:p[6]||""}:null},normalizePath:function(S){for(S=S.split("").reverse().join("").replace(B,"");S.length!==(S=S.replace(M,"")).length;);return S.split("").reverse().join("")},buildURLFromParts:function(S){return S.scheme+S.netLoc+S.path+S.params+S.query+S.fragment}};he.exports=A})(this)},"./node_modules/webworkify-webpack/index.js":function(he,G,w){function j(m){var s={};function r(u){if(s[u])return s[u].exports;var o=s[u]={i:u,l:!1,exports:{}};return m[u].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=m,r.c=s,r.i=function(u){return u},r.d=function(u,o,t){r.o(u,o)||Object.defineProperty(u,o,{configurable:!1,enumerable:!0,get:t})},r.r=function(u){Object.defineProperty(u,"__esModule",{value:!0})},r.n=function(u){var o=u&&u.__esModule?function(){return u.default}:function(){return u};return r.d(o,"a",o),o},r.o=function(u,o){return Object.prototype.hasOwnProperty.call(u,o)},r.p="/",r.oe=function(u){throw console.error(u),u};var n=r(r.s=ENTRY_MODULE);return n.default||n}var I="[\\.|\\-|\\+|\\w|/|@]+",O="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+I+").*?\\)";function B(m){return(m+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function M(m){return!isNaN(1*m)}function A(m,s,r){var n={};n[r]=[];var u=s.toString(),o=u.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!o)return n;for(var t=o[1],e=new RegExp("(\\\\n|\\W)"+B(t)+O,"g"),i;i=e.exec(u);){if(i[3]==="dll-reference")continue;n[r].push(i[3])}for(e=new RegExp("\\("+B(t)+'\\("(dll-reference\\s('+I+'))"\\)\\)'+O,"g");i=e.exec(u);)m[i[2]]||(n[r].push(i[1]),m[i[2]]=w(i[1]).m),n[i[2]]=n[i[2]]||[],n[i[2]].push(i[4]);for(var T=Object.keys(n),_=0;_<T.length;_++)for(var y=0;y<n[T[_]].length;y++)M(n[T[_]][y])&&(n[T[_]][y]=1*n[T[_]][y]);return n}function S(m){var s=Object.keys(m);return s.reduce(function(r,n){return r||m[n].length>0},!1)}function p(m,s){for(var r={main:[s]},n={main:[]},u={main:{}};S(r);)for(var o=Object.keys(r),t=0;t<o.length;t++){var e=o[t],i=r[e],T=i.pop();if(u[e]=u[e]||{},u[e][T]||!m[e][T])continue;u[e][T]=!0,n[e]=n[e]||[],n[e].push(T);for(var _=A(m,m[e][T],e),y=Object.keys(_),E=0;E<y.length;E++)r[y[E]]=r[y[E]]||[],r[y[E]]=r[y[E]].concat(_[y[E]])}return n}he.exports=function(m,s){s=s||{};var r={main:w.m},n=s.all?{main:Object.keys(r.main)}:p(r,m),u="";Object.keys(n).filter(function(T){return T!=="main"}).forEach(function(T){for(var _=0;n[T][_];)_++;n[T].push(_),r[T][_]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",u=u+"var "+T+" = ("+j.toString().replace("ENTRY_MODULE",JSON.stringify(_))+")({"+n[T].map(function(y){return""+JSON.stringify(y)+": "+r[T][y].toString()}).join(",")+`});
`}),u=u+"new (("+j.toString().replace("ENTRY_MODULE",JSON.stringify(m))+")({"+n.main.map(function(T){return""+JSON.stringify(T)+": "+r.main[T].toString()}).join(",")+"}))(self);";var o=new window.Blob([u],{type:"text/javascript"});if(s.bare)return o;var t=window.URL||window.webkitURL||window.mozURL||window.msURL,e=t.createObjectURL(o),i=new window.Worker(e);return i.objectURL=e,i}},"./src/config.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"hlsDefaultConfig",function(){return E}),w.d(G,"mergeConfig",function(){return g}),w.d(G,"enableStreamingMode",function(){return d});var j=w("./src/controller/abr-controller.ts"),I=w("./src/controller/audio-stream-controller.ts"),O=w("./src/controller/audio-track-controller.ts"),B=w("./src/controller/subtitle-stream-controller.ts"),M=w("./src/controller/subtitle-track-controller.ts"),A=w("./src/controller/buffer-controller.ts"),S=w("./src/controller/timeline-controller.ts"),p=w("./src/controller/cap-level-controller.ts"),m=w("./src/controller/fps-controller.ts"),s=w("./src/controller/eme-controller.ts"),r=w("./src/controller/cmcd-controller.ts"),n=w("./src/utils/xhr-loader.ts"),u=w("./src/utils/fetch-loader.ts"),o=w("./src/utils/cues.ts"),t=w("./src/utils/mediakeys-helper.ts"),e=w("./src/utils/logger.ts");function i(){return i=Object.assign||function(a){for(var l=1;l<arguments.length;l++){var f=arguments[l];for(var c in f)Object.prototype.hasOwnProperty.call(f,c)&&(a[c]=f[c])}return a},i.apply(this,arguments)}function T(a,l){var f=Object.keys(a);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(a);l&&(c=c.filter(function(x){return Object.getOwnPropertyDescriptor(a,x).enumerable})),f.push.apply(f,c)}return f}function _(a){for(var l=1;l<arguments.length;l++){var f=arguments[l]!=null?arguments[l]:{};l%2?T(Object(f),!0).forEach(function(c){y(a,c,f[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(f)):T(Object(f)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(f,c))})}return a}function y(a,l,f){return l in a?Object.defineProperty(a,l,{value:f,enumerable:!0,configurable:!0,writable:!0}):a[l]=f,a}var E=_(_({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:n.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:j.default,bufferController:A.default,capLevelController:p.default,fpsController:m.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:t.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},b()),{},{subtitleStreamController:B.SubtitleStreamController,subtitleTrackController:M.default,timelineController:S.TimelineController,audioStreamController:I.default,audioTrackController:O.default,emeController:s.default,cmcdController:r.default});function b(){return{cueHandler:o.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 g(a,l){if((l.liveSyncDurationCount||l.liveMaxLatencyDurationCount)&&(l.liveSyncDuration||l.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(l.liveMaxLatencyDurationCount!==void 0&&(l.liveSyncDurationCount===void 0||l.liveMaxLatencyDurationCount<=l.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(l.liveMaxLatencyDuration!==void 0&&(l.liveSyncDuration===void 0||l.liveMaxLatencyDuration<=l.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return i({},a,l)}function d(a){var l=a.loader;if(l!==u.default&&l!==n.default)e.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),a.progressive=!1;else{var f=Object(u.fetchSupported)();f&&(a.loader=u.default,a.progressive=!0,a.enableSoftwareAES=!0,e.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/polyfills/number.ts"),I=w("./src/utils/ewma-bandwidth-estimator.ts"),O=w("./src/events.ts"),B=w("./src/utils/buffer-helper.ts"),M=w("./src/errors.ts"),A=w("./src/types/loader.ts"),S=w("./src/utils/logger.ts");function p(r,n){for(var u=0;u<n.length;u++){var o=n[u];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(r,o.key,o)}}function m(r,n,u){return n&&p(r.prototype,n),u&&p(r,u),r}var s=function(){function r(u){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=u;var o=u.config;this.bwEstimator=new I.default(o.abrEwmaSlowVoD,o.abrEwmaFastVoD,o.abrEwmaDefaultEstimate),this.registerListeners()}var n=r.prototype;return n.registerListeners=function(){var o=this.hls;o.on(O.Events.FRAG_LOADING,this.onFragLoading,this),o.on(O.Events.FRAG_LOADED,this.onFragLoaded,this),o.on(O.Events.FRAG_BUFFERED,this.onFragBuffered,this),o.on(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.on(O.Events.ERROR,this.onError,this)},n.unregisterListeners=function(){var o=this.hls;o.off(O.Events.FRAG_LOADING,this.onFragLoading,this),o.off(O.Events.FRAG_LOADED,this.onFragLoaded,this),o.off(O.Events.FRAG_BUFFERED,this.onFragBuffered,this),o.off(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.off(O.Events.ERROR,this.onError,this)},n.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},n.onFragLoading=function(o,t){var e=t.frag;if(e.type===A.PlaylistLevelType.MAIN&&!this.timer){var i;this.fragCurrent=e,this.partCurrent=(i=t.part)!=null?i:null,this.timer=self.setInterval(this.onCheck,100)}},n.onLevelLoaded=function(o,t){var e=this.hls.config;t.details.live?this.bwEstimator.update(e.abrEwmaSlowLive,e.abrEwmaFastLive):this.bwEstimator.update(e.abrEwmaSlowVoD,e.abrEwmaFastVoD)},n._abandonRulesCheck=function(){var o=this.fragCurrent,t=this.partCurrent,e=this.hls,i=e.autoLevelEnabled,T=e.config,_=e.media;if(!o||!_)return;var y=t?t.stats:o.stats,E=t?t.duration:o.duration;if(y.aborted){S.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!i||_.paused||!_.playbackRate||!_.readyState)return;var b=performance.now()-y.loading.start,g=Math.abs(_.playbackRate);if(b<=500*E/g)return;var d=e.levels,a=e.minAutoLevel,l=d[o.level],f=y.total||Math.max(y.loaded,Math.round(E*l.maxBitrate/8)),c=Math.max(1,y.bwEstimate?y.bwEstimate/8:y.loaded*1e3/b),x=(f-y.loaded)/c,R=_.currentTime,C=(B.BufferHelper.bufferInfo(_,R,T.maxBufferHole).end-R)/g;if(C>=2*E/g||x<=C)return;var N=Number.POSITIVE_INFINITY,U;for(U=o.level-1;U>a;U--){var W=d[U].maxBitrate;if(N=E*W/(8*.8*c),N<C)break}if(N>=x)return;var L=this.bwEstimator.getEstimate();S.logger.warn("Fragment "+o.sn+(t?" part "+t.index:"")+" of level "+o.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+U+`
Current BW estimate: `+(Object(j.isFiniteNumber)(L)?(L/1024).toFixed(3):"Unknown")+` Kb/s
Estimated load time for current fragment: `+x.toFixed(3)+` s
Estimated load time for the next fragment: `+N.toFixed(3)+` s
Time to underbuffer: `+C.toFixed(3)+" s"),e.nextLoadLevel=U,this.bwEstimator.sample(b,y.loaded),this.clearTimer(),o.loader&&(this.fragCurrent=this.partCurrent=null,o.loader.abort()),e.trigger(O.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:o,part:t,stats:y})},n.onFragLoaded=function(o,t){var e=t.frag,i=t.part;if(e.type===A.PlaylistLevelType.MAIN&&Object(j.isFiniteNumber)(e.sn)){var T=i?i.stats:e.stats,_=i?i.duration:e.duration;if(this.clearTimer(),this.lastLoadedFragLevel=e.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var y=this.hls.levels[e.level],E=(y.loaded?y.loaded.bytes:0)+T.loaded,b=(y.loaded?y.loaded.duration:0)+_;y.loaded={bytes:E,duration:b},y.realBitrate=Math.round(8*E/b)}if(e.bitrateTest){var g={stats:T,frag:e,part:i,id:e.type};this.onFragBuffered(O.Events.FRAG_BUFFERED,g),e.bitrateTest=!1}}},n.onFragBuffered=function(o,t){var e=t.frag,i=t.part,T=i?i.stats:e.stats;if(T.aborted)return;if(e.type!==A.PlaylistLevelType.MAIN||e.sn==="initSegment")return;var _=T.parsing.end-T.loading.start;this.bwEstimator.sample(_,T.loaded),T.bwEstimate=this.bwEstimator.getEstimate(),e.bitrateTest?this.bitrateTestDelay=_/1e3:this.bitrateTestDelay=0},n.onError=function(o,t){switch(t.details){case M.ErrorDetails.FRAG_LOAD_ERROR:case M.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},n.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},n.getNextABRAutoLevel=function(){var o=this.fragCurrent,t=this.partCurrent,e=this.hls,i=e.maxAutoLevel,T=e.config,_=e.minAutoLevel,y=e.media,E=t?t.duration:o?o.duration:0,b=y?y.currentTime:0,g=y&&y.playbackRate!==0?Math.abs(y.playbackRate):1,d=this.bwEstimator?this.bwEstimator.getEstimate():T.abrEwmaDefaultEstimate,a=(B.BufferHelper.bufferInfo(y,b,T.maxBufferHole).end-b)/g,l=this.findBestLevel(d,_,i,a,T.abrBandWidthFactor,T.abrBandWidthUpFactor);if(l>=0)return l;S.logger.trace((a?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var f=E?Math.min(E,T.maxStarvationDelay):T.maxStarvationDelay,c=T.abrBandWidthFactor,x=T.abrBandWidthUpFactor;if(!a){var R=this.bitrateTestDelay;if(R){var C=E?Math.min(E,T.maxLoadingDelay):T.maxLoadingDelay;f=C-R,S.logger.trace("bitrate test took "+Math.round(1e3*R)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*f)+" ms"),c=x=1}}return l=this.findBestLevel(d,_,i,a+f,c,x),Math.max(l,0)},n.findBestLevel=function(o,t,e,i,T,_){for(var y,E=this.fragCurrent,b=this.partCurrent,g=this.lastLoadedFragLevel,d=this.hls.levels,a=d[g],l=!!(a!=null&&(y=a.details)!==null&&y!==void 0&&y.live),f=a==null?void 0:a.codecSet,c=b?b.duration:E?E.duration:0,x=e;x>=t;x--){var R=d[x];if(!R||f&&R.codecSet!==f)continue;var C=R.details,N=(b?C==null?void 0:C.partTarget:C==null?void 0:C.averagetargetduration)||c,U=void 0;x<=g?U=T*o:U=_*o;var W=d[x].maxBitrate,L=W*N/U;if(S.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+x+"/"+Math.round(U)+"/"+W+"/"+N+"/"+i+"/"+L),U>W&&(!L||l&&!this.bitrateTestDelay||L<i))return x}return-1},m(r,[{key:"nextAutoLevel",get:function(){var o=this._nextAutoLevel,t=this.bwEstimator;if(o!==-1&&(!t||!t.canEstimate()))return o;var e=this.getNextABRAutoLevel();return o!==-1&&(e=Math.min(o,e)),e},set:function(o){this._nextAutoLevel=o}}]),r}();G.default=s},"./src/controller/audio-stream-controller.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/polyfills/number.ts"),I=w("./src/controller/base-stream-controller.ts"),O=w("./src/events.ts"),B=w("./src/utils/buffer-helper.ts"),M=w("./src/controller/fragment-tracker.ts"),A=w("./src/types/level.ts"),S=w("./src/types/loader.ts"),p=w("./src/loader/fragment.ts"),m=w("./src/demux/chunk-cache.ts"),s=w("./src/demux/transmuxer-interface.ts"),r=w("./src/types/transmuxer.ts"),n=w("./src/controller/fragment-finders.ts"),u=w("./src/utils/discontinuities.ts"),o=w("./src/errors.ts"),t=w("./src/utils/logger.ts");function e(){return e=Object.assign||function(E){for(var b=1;b<arguments.length;b++){var g=arguments[b];for(var d in g)Object.prototype.hasOwnProperty.call(g,d)&&(E[d]=g[d])}return E},e.apply(this,arguments)}function i(E,b){E.prototype=Object.create(b.prototype),E.prototype.constructor=E,T(E,b)}function T(E,b){return T=Object.setPrototypeOf||function(d,a){return d.__proto__=a,d},T(E,b)}var _=100,y=function(E){i(b,E);function b(d,a){var l;return l=E.call(this,d,a,"[audio-stream-controller]")||this,l.videoBuffer=null,l.videoTrackCC=-1,l.waitingVideoCC=-1,l.audioSwitch=!1,l.trackId=-1,l.waitingData=null,l.mainDetails=null,l.bufferFlushed=!1,l._registerListeners(),l}var g=b.prototype;return g.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},g._registerListeners=function(){var a=this.hls;a.on(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.on(O.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),a.on(O.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),a.on(O.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.on(O.Events.ERROR,this.onError,this),a.on(O.Events.BUFFER_RESET,this.onBufferReset,this),a.on(O.Events.BUFFER_CREATED,this.onBufferCreated,this),a.on(O.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),a.on(O.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),a.on(O.Events.FRAG_BUFFERED,this.onFragBuffered,this)},g._unregisterListeners=function(){var a=this.hls;a.off(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.off(O.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),a.off(O.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),a.off(O.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.off(O.Events.ERROR,this.onError,this),a.off(O.Events.BUFFER_RESET,this.onBufferReset,this),a.off(O.Events.BUFFER_CREATED,this.onBufferCreated,this),a.off(O.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),a.off(O.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),a.off(O.Events.FRAG_BUFFERED,this.onFragBuffered,this)},g.onInitPtsFound=function(a,l){var f=l.frag,c=l.id,x=l.initPTS;if(c==="main"){var R=f.cc;this.initPTS[f.cc]=x,this.log("InitPTS for cc: "+R+" found from main: "+x),this.videoTrackCC=R,this.state===I.State.WAITING_INIT_PTS&&this.tick()}},g.startLoad=function(a){if(!this.levels){this.startPosition=a,this.state=I.State.STOPPED;return}var l=this.lastCurrentTime;this.stopLoad(),this.setInterval(_),this.fragLoadError=0,l>0&&a===-1?(this.log("Override startPosition with lastCurrentTime @"+l.toFixed(3)),this.state=I.State.IDLE):(this.loadedmetadata=!1,this.state=I.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=a,this.tick()},g.doTick=function(){switch(this.state){case I.State.IDLE:this.doTickIdle();break;case I.State.WAITING_TRACK:{var a,l=this.levels,f=this.trackId,c=l==null||((a=l[f])===null||a===void 0)?void 0:a.details;if(c){if(this.waitForCdnTuneIn(c))break;this.state=I.State.WAITING_INIT_PTS}break}case I.State.FRAG_LOADING_WAITING_RETRY:{var x,R=performance.now(),C=this.retryDate;(!C||R>=C||(x=this.media)!==null&&x!==void 0&&x.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=I.State.IDLE);break}case I.State.WAITING_INIT_PTS:{var N=this.waitingData;if(N){var U=N.frag,W=N.part,L=N.cache,H=N.complete;if(this.initPTS[U.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=I.State.FRAG_LOADING;var K=L.flush(),$={frag:U,part:W,payload:K,networkDetails:null};this._handleFragmentLoadProgress($),H&&E.prototype._handleFragmentLoadComplete.call(this,$)}else if(this.videoTrackCC!==this.waitingVideoCC)t.logger.log("Waiting fragment cc ("+U.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var Q=this.getLoadPosition(),ue=B.BufferHelper.bufferInfo(this.mediaBuffer,Q,this.config.maxBufferHole),ne=Object(n.fragmentWithinToleranceTest)(ue.end,this.config.maxFragLookUpTolerance,U);ne<0&&(t.logger.log("Waiting fragment cc ("+U.cc+") @ "+U.start+" cancelled because another fragment at "+ue.end+" is needed"),this.clearWaitingFragment())}}else this.state=I.State.IDLE}}this.onTickEnd()},g.clearWaitingFragment=function(){var a=this.waitingData;a&&(this.fragmentTracker.removeFragment(a.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=I.State.IDLE)},g.onTickEnd=function(){var a=this.media;if(!a||!a.readyState)return;var l=this.mediaBuffer?this.mediaBuffer:a,f=l.buffered;!this.loadedmetadata&&f.length&&(this.loadedmetadata=!0),this.lastCurrentTime=a.currentTime},g.doTickIdle=function(){var a,l,f=this.hls,c=this.levels,x=this.media,R=this.trackId,C=f.config;if(!c||!c[R])return;if(!x&&(this.startFragRequested||!C.startFragPrefetch))return;var N=c[R],U=N.details;if(!U||U.live&&this.levelLastLoaded!==R||this.waitForCdnTuneIn(U)){this.state=I.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,p.ElementaryStreamTypes.AUDIO,S.PlaylistLevelType.AUDIO));var W=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,S.PlaylistLevelType.AUDIO);if(W===null)return;var L=W.len,H=this.getMaxBufferLength(),K=this.audioSwitch;if(L>=H&&!K)return;if(!K&&this._streamEnded(W,U)){f.trigger(O.Events.BUFFER_EOS,{type:"audio"}),this.state=I.State.ENDED;return}var $=U.fragments,Q=$[0].start,ue=W.end;if(K){var ne=this.getLoadPosition();ue=ne,U.PTSKnown&&ne<Q&&((W.end>Q||W.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),x.currentTime=Q+.05))}var se=this.getNextFragment(ue,U);if(!se){this.bufferFlushed=!0;return}((a=se.decryptdata)===null||a===void 0?void 0:a.keyFormat)==="identity"&&!((l=se.decryptdata)!==null&&l!==void 0&&l.key)?this.loadKey(se,U):this.loadFragment(se,U,ue)},g.getMaxBufferLength=function(){var a=E.prototype.getMaxBufferLength.call(this),l=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,S.PlaylistLevelType.MAIN);return l===null?a:Math.max(a,l.len)},g.onMediaDetaching=function(){this.videoBuffer=null,E.prototype.onMediaDetaching.call(this)},g.onAudioTracksUpdated=function(a,l){var f=l.audioTracks;this.resetTransmuxer(),this.levels=f.map(function(c){return new A.Level(c)})},g.onAudioTrackSwitching=function(a,l){var f=!!l.url;this.trackId=l.id;var c=this.fragCurrent;c!=null&&c.loader&&c.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),f?this.setInterval(_):this.resetTransmuxer(),f?(this.audioSwitch=!0,this.state=I.State.IDLE):this.state=I.State.STOPPED,this.tick()},g.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},g.onLevelLoaded=function(a,l){this.mainDetails=l.details},g.onAudioTrackLoaded=function(a,l){var f,c=this.levels,x=l.details,R=l.id;if(!c){this.warn("Audio tracks were reset while loading level "+R);return}this.log("Track "+R+" loaded ["+x.startSN+","+x.endSN+"],duration:"+x.totalduration);var C=c[R],N=0;if(x.live||(f=C.details)!==null&&f!==void 0&&f.live){var U=this.mainDetails;if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed||!U)return;!C.details&&x.hasProgramDateTime&&U.hasProgramDateTime?(Object(u.alignMediaPlaylistByPDT)(x,U),N=x.fragments[0].start):N=this.alignPlaylists(x,C.details)}C.details=x,this.levelLastLoaded=R,!this.startFragRequested&&(this.mainDetails||!x.live)&&this.setStartPosition(C.details,N),this.state===I.State.WAITING_TRACK&&!this.waitForCdnTuneIn(x)&&(this.state=I.State.IDLE),this.tick()},g._handleFragmentLoadProgress=function(a){var l,f=a.frag,c=a.part,x=a.payload,R=this.config,C=this.trackId,N=this.levels;if(!N){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+f.sn+" of level "+f.level+" will not be buffered");return}var U=N[C];console.assert(U,"Audio track is defined on fragment load progress");var W=U.details;console.assert(W,"Audio track details are defined on fragment load progress");var L=R.defaultAudioCodec||U.audioCodec||"mp4a.40.2",H=this.transmuxer;H||(H=this.transmuxer=new s.default(this.hls,S.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var K=this.initPTS[f.cc],$=(l=f.initSegment)===null||l===void 0?void 0:l.data;if(K!==void 0){var Q=!1,ue=c?c.index:-1,ne=ue!==-1,se=new r.ChunkMetadata(f.level,f.sn,f.stats.chunkCount,x.byteLength,ue,ne);H.push(x,$,L,"",f,c,W.totalduration,Q,se,K)}else{t.logger.log("Unknown video PTS for cc "+f.cc+", waiting for video PTS before demuxing audio frag "+f.sn+" of ["+W.startSN+" ,"+W.endSN+"],track "+C);var le=this.waitingData=this.waitingData||{frag:f,part:c,cache:new m.default,complete:!1},de=le.cache;de.push(new Uint8Array(x)),this.waitingVideoCC=this.videoTrackCC,this.state=I.State.WAITING_INIT_PTS}},g._handleFragmentLoadComplete=function(a){if(this.waitingData){this.waitingData.complete=!0;return}E.prototype._handleFragmentLoadComplete.call(this,a)},g.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},g.onBufferCreated=function(a,l){var f=l.tracks.audio;f&&(this.mediaBuffer=f.buffer),l.tracks.video&&(this.videoBuffer=l.tracks.video.buffer)},g.onFragBuffered=function(a,l){var f=l.frag,c=l.part;if(f.type!==S.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(f)){this.warn("Fragment "+f.sn+(c?" p: "+c.index:"")+" of level "+f.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}f.sn!=="initSegment"&&(this.fragPrevious=f,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(O.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(f,c)},g.onError=function(a,l){switch(l.details){case o.ErrorDetails.FRAG_LOAD_ERROR:case o.ErrorDetails.FRAG_LOAD_TIMEOUT:case o.ErrorDetails.KEY_LOAD_ERROR:case o.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(S.PlaylistLevelType.AUDIO,l);break;case o.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case o.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==I.State.ERROR&&this.state!==I.State.STOPPED&&(this.state=l.fatal?I.State.ERROR:I.State.IDLE,this.warn(l.details+" while loading frag, switching to "+this.state+" state"));break;case o.ErrorDetails.BUFFER_FULL_ERROR:if(l.parent==="audio"&&(this.state===I.State.PARSING||this.state===I.State.PARSED)){var f=!0,c=this.getFwdBufferInfo(this.mediaBuffer,S.PlaylistLevelType.AUDIO);c&&c.len>.5&&(f=!this.reduceMaxBufferLength(c.len)),f&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,E.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},g.onBufferFlushed=function(a,l){var f=l.type;f===p.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},g._handleTransmuxComplete=function(a){var l,f="audio",c=this.hls,x=a.remuxResult,R=a.chunkMeta,C=this.getCurrentContext(R);if(!C){this.warn("The loading context changed while buffering fragment "+R.sn+" of level "+R.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(R.level);return}var N=C.frag,U=C.part,W=x.audio,L=x.text,H=x.id3,K=x.initSegment;if(this.fragContextChanged(N))return;if(this.state=I.State.PARSING,this.audioSwitch&&W&&this.completeAudioSwitch(),K!=null&&K.tracks&&(this._bufferInitSegment(K.tracks,N,R),c.trigger(O.Events.FRAG_PARSING_INIT_SEGMENT,{frag:N,id:f,tracks:K.tracks})),W){var $=W.startPTS,Q=W.endPTS,ue=W.startDTS,ne=W.endDTS;U&&(U.elementaryStreams[p.ElementaryStreamTypes.AUDIO]={startPTS:$,endPTS:Q,startDTS:ue,endDTS:ne}),N.setElementaryStreamInfo(p.ElementaryStreamTypes.AUDIO,$,Q,ue,ne),this.bufferFragmentData(W,N,U,R)}if(H!=null&&(l=H.samples)!==null&&l!==void 0&&l.length){var se=e({frag:N,id:f},H);c.trigger(O.Events.FRAG_PARSING_METADATA,se)}if(L){var le=e({frag:N,id:f},L);c.trigger(O.Events.FRAG_PARSING_USERDATA,le)}},g._bufferInitSegment=function(a,l,f){if(this.state!==I.State.PARSING)return;a.video&&delete a.video;var c=a.audio;if(!c)return;c.levelCodec=c.codec,c.id="audio",this.log("Init audio buffer, container:"+c.container+", codecs[parsed]=["+c.codec+"]"),this.hls.trigger(O.Events.BUFFER_CODECS,a);var x=c.initSegment;if(x!=null&&x.byteLength){var R={type:"audio",frag:l,part:null,chunkMeta:f,parent:l.type,data:x};this.hls.trigger(O.Events.BUFFER_APPENDING,R)}this.tick()},g.loadFragment=function(a,l,f){var c=this.fragmentTracker.getState(a);this.fragCurrent=a,(this.audioSwitch||c===M.FragmentState.NOT_LOADED||c===M.FragmentState.PARTIAL)&&(a.sn==="initSegment"?this._loadInitSegment(a):l.live&&!Object(j.isFiniteNumber)(this.initPTS[a.cc])?(this.log("Waiting for video PTS in continuity counter "+a.cc+" of live stream before loading audio fragment "+a.sn+" of level "+this.trackId),this.state=I.State.WAITING_INIT_PTS):(this.startFragRequested=!0,E.prototype.loadFragment.call(this,a,l,f)))},g.completeAudioSwitch=function(){var a=this.hls,l=this.media,f=this.trackId;l&&(this.log("Switching audio track : flushing all audio"),E.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,a.trigger(O.Events.AUDIO_TRACK_SWITCHED,{id:f})},b}(I.default);G.default=y},"./src/controller/audio-track-controller.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/events.ts"),I=w("./src/errors.ts"),O=w("./src/controller/base-playlist-controller.ts"),B=w("./src/types/loader.ts");function M(s,r){for(var n=0;n<r.length;n++){var u=r[n];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}function A(s,r,n){return r&&M(s.prototype,r),n&&M(s,n),s}function S(s,r){s.prototype=Object.create(r.prototype),s.prototype.constructor=s,p(s,r)}function p(s,r){return p=Object.setPrototypeOf||function(u,o){return u.__proto__=o,u},p(s,r)}var m=function(s){S(r,s);function r(u){var o;return o=s.call(this,u,"[audio-track-controller]")||this,o.tracks=[],o.groupId=null,o.tracksInGroup=[],o.trackId=-1,o.trackName="",o.selectDefaultTrack=!0,o.registerListeners(),o}var n=r.prototype;return n.registerListeners=function(){var o=this.hls;o.on(j.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(j.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(j.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(j.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.on(j.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),o.on(j.Events.ERROR,this.onError,this)},n.unregisterListeners=function(){var o=this.hls;o.off(j.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(j.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(j.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(j.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.off(j.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),o.off(j.Events.ERROR,this.onError,this)},n.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,s.prototype.destroy.call(this)},n.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},n.onManifestParsed=function(o,t){this.tracks=t.audioTracks||[]},n.onAudioTrackLoaded=function(o,t){var e=t.id,i=t.details,T=this.tracksInGroup[e];if(!T){this.warn("Invalid audio track id "+e);return}var _=T.details;T.details=t.details,this.log("audioTrack "+e+" loaded ["+i.startSN+"-"+i.endSN+"]"),e===this.trackId&&(this.retryCount=0,this.playlistLoaded(e,t,_))},n.onLevelLoading=function(o,t){this.switchLevel(t.level)},n.onLevelSwitching=function(o,t){this.switchLevel(t.level)},n.switchLevel=function(o){var t=this.hls.levels[o];if(!(t!=null&&t.audioGroupIds))return;var e=t.audioGroupIds[t.urlId];if(this.groupId!==e){this.groupId=e;var i=this.tracks.filter(function(_){return!e||_.groupId===e});this.selectDefaultTrack&&!i.some(function(_){return _.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=i;var T={audioTracks:i};this.log("Updating audio tracks, "+i.length+' track(s) found in "'+e+'" group-id'),this.hls.trigger(j.Events.AUDIO_TRACKS_UPDATED,T),this.selectInitialTrack()}},n.onError=function(o,t){if(s.prototype.onError.call(this,o,t),t.fatal||!t.context)return;t.context.type===B.PlaylistContextType.AUDIO_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.retryLoadingOrFail(t)},n.setAudioTrack=function(o){var t=this.tracksInGroup;if(o<0||o>=t.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var e=t[this.trackId];this.log("Now switching to audio-track index "+o);var i=t[o],T=i.id,_=i.groupId,y=_===void 0?"":_,E=i.name,b=i.type,g=i.url;if(this.trackId=o,this.trackName=E,this.selectDefaultTrack=!1,this.hls.trigger(j.Events.AUDIO_TRACK_SWITCHING,{id:T,groupId:y,name:E,type:b,url:g}),i.details&&!i.details.live)return;var d=this.switchParams(i.url,e==null?void 0:e.details);this.loadPlaylist(d)},n.selectInitialTrack=function(){var o=this.tracksInGroup;console.assert(o.length,"Initial audio track should be selected when tracks are known");var t=this.trackName,e=this.findTrackId(t)||this.findTrackId();e!==-1?this.setAudioTrack(e):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(j.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},n.findTrackId=function(o){for(var t=this.tracksInGroup,e=0;e<t.length;e++){var i=t[e];if((!this.selectDefaultTrack||i.default)&&(!o||o===i.name))return i.id}return-1},n.loadPlaylist=function(o){var t=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(t)){var e=t.id,i=t.groupId,T=t.url;if(o)try{T=o.addDirectives(T)}catch(_){this.warn("Could not construct new URL with HLS Delivery Directives: "+_)}this.log("loading audio-track playlist for id: "+e),this.clearTimer(),this.hls.trigger(j.Events.AUDIO_TRACK_LOADING,{url:T,id:e,groupId:i,deliveryDirectives:o||null})}},A(r,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(o){this.selectDefaultTrack=!1,this.setAudioTrack(o)}}]),r}(O.default);G.default=m},"./src/controller/base-playlist-controller.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return A});var j=w("./src/polyfills/number.ts"),I=w("./src/types/level.ts"),O=w("./src/controller/level-helper.ts"),B=w("./src/utils/logger.ts"),M=w("./src/errors.ts"),A=function(){function S(m,s){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=B.logger.log.bind(B.logger,s+":"),this.warn=B.logger.warn.bind(B.logger,s+":"),this.hls=m}var p=S.prototype;return p.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},p.onError=function(s,r){r.fatal&&r.type===M.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},p.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},p.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},p.stopLoad=function(){this.canLoad=!1,this.clearTimer()},p.switchParams=function(s,r){var n=r==null?void 0:r.renditionReports;if(n)for(var u=0;u<n.length;u++){var o=n[u],t=""+o.URI;if(t===s.substr(-t.length)){var e=parseInt(o["LAST-MSN"]),i=parseInt(o["LAST-PART"]);if(r&&this.hls.config.lowLatencyMode){var T=Math.min(r.age-r.partTarget,r.targetduration);i!==void 0&&T>r.partTarget&&(i+=1)}if(Object(j.isFiniteNumber)(e))return new I.HlsUrlParameters(e,Object(j.isFiniteNumber)(i)?i:void 0,I.HlsSkip.No)}}},p.loadPlaylist=function(s){},p.shouldLoadTrack=function(s){return this.canLoad&&s&&!!s.url&&(!s.details||s.details.live)},p.playlistLoaded=function(s,r,n){var u=this,o=r.details,t=r.stats,e=t.loading.end?Math.max(0,self.performance.now()-t.loading.end):0;if(o.advancedDateTime=Date.now()-e,o.live||n!=null&&n.live){if(o.reloaded(n),n&&this.log("live playlist "+s+" "+(o.advanced?"REFRESHED "+o.lastPartSn+"-"+o.lastPartIndex:"MISSED")),n&&o.fragments.length>0&&Object(O.mergeDetails)(n,o),!this.canLoad||!o.live)return;var i,T=void 0,_=void 0;if(o.canBlockReload&&o.endSN&&o.advanced){var y=this.hls.config.lowLatencyMode,E=o.lastPartSn,b=o.endSN,g=o.lastPartIndex,d=g!==-1,a=E===b,l=y?0:g;d?(T=a?b+1:E,_=a?l:g+1):T=b+1;var f=o.age,c=f+o.ageHeader,x=Math.min(c-o.partTarget,o.targetduration*1.5);if(x>0){if(n&&x>n.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+n.tuneInGoal+" to: "+x+" with playlist age: "+o.age),x=0;else{var R=Math.floor(x/o.targetduration);if(T+=R,_!==void 0){var C=Math.round(x%o.targetduration/o.partTarget);_+=C}this.log("CDN Tune-in age: "+o.ageHeader+"s last advanced "+f.toFixed(2)+"s goal: "+x+" skip sn "+R+" to part "+_)}o.tuneInGoal=x}if(i=this.getDeliveryDirectives(o,r.deliveryDirectives,T,_),y||!a){this.loadPlaylist(i);return}}else i=this.getDeliveryDirectives(o,r.deliveryDirectives,T,_);var N=Object(O.computeReloadInterval)(o,t);T!==void 0&&o.canBlockReload&&(N-=o.partTarget||1),this.log("reload live playlist "+s+" in "+Math.round(N)+" ms"),this.timer=self.setTimeout(function(){return u.loadPlaylist(i)},N)}else this.clearTimer()},p.getDeliveryDirectives=function(s,r,n,u){var o=Object(I.getSkipValue)(s,n);return r!=null&&r.skip&&s.deltaUpdateFailed&&(n=r.msn,u=r.part,o=I.HlsSkip.No),new I.HlsUrlParameters(n,u,o)},p.retryLoadingOrFail=function(s){var r=this,n=this.hls.config,u=this.retryCount<n.levelLoadingMaxRetry;if(u){var o;if(this.retryCount++,s.details.indexOf("LoadTimeOut")>-1&&(o=s.context)!==null&&o!==void 0&&o.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+s.details+'"'),this.loadPlaylist();else{var t=Math.min(Math.pow(2,this.retryCount)*n.levelLoadingRetryDelay,n.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return r.loadPlaylist()},t),this.warn("retry playlist loading #"+this.retryCount+" in "+t+' ms after "'+s.details+'"')}}else this.warn('cannot recover from error "'+s.details+'"'),this.clearTimer(),s.fatal=!0;return u},S}()},"./src/controller/base-stream-controller.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"State",function(){return b}),w.d(G,"default",function(){return g});var j=w("./src/polyfills/number.ts"),I=w("./src/task-loop.ts"),O=w("./src/controller/fragment-tracker.ts"),B=w("./src/utils/buffer-helper.ts"),M=w("./src/utils/logger.ts"),A=w("./src/events.ts"),S=w("./src/errors.ts"),p=w("./src/types/transmuxer.ts"),m=w("./src/utils/mp4-tools.ts"),s=w("./src/utils/discontinuities.ts"),r=w("./src/controller/fragment-finders.ts"),n=w("./src/controller/level-helper.ts"),u=w("./src/loader/fragment-loader.ts"),o=w("./src/crypt/decrypter.ts"),t=w("./src/utils/time-ranges.ts"),e=w("./src/types/loader.ts");function i(d,a){for(var l=0;l<a.length;l++){var f=a[l];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}function T(d,a,l){return a&&i(d.prototype,a),l&&i(d,l),d}function _(d){if(d===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d}function y(d,a){d.prototype=Object.create(a.prototype),d.prototype.constructor=d,E(d,a)}function E(d,a){return E=Object.setPrototypeOf||function(f,c){return f.__proto__=c,f},E(d,a)}var b={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"},g=function(d){y(a,d);function a(f,c,x){var R;return R=d.call(this)||this,R.hls=void 0,R.fragPrevious=null,R.fragCurrent=null,R.fragmentTracker=void 0,R.transmuxer=null,R._state=b.STOPPED,R.media=void 0,R.mediaBuffer=void 0,R.config=void 0,R.bitrateTest=!1,R.lastCurrentTime=0,R.nextLoadPosition=0,R.startPosition=0,R.loadedmetadata=!1,R.fragLoadError=0,R.retryDate=0,R.levels=null,R.fragmentLoader=void 0,R.levelLastLoaded=null,R.startFragRequested=!1,R.decrypter=void 0,R.initPTS=[],R.onvseeking=null,R.onvended=null,R.logPrefix="",R.log=void 0,R.warn=void 0,R.logPrefix=x,R.log=M.logger.log.bind(M.logger,x+":"),R.warn=M.logger.warn.bind(M.logger,x+":"),R.hls=f,R.fragmentLoader=new u.default(f.config),R.fragmentTracker=c,R.config=f.config,R.decrypter=new o.default(f,f.config),f.on(A.Events.KEY_LOADED,R.onKeyLoaded,_(R)),R}var l=a.prototype;return l.doTick=function(){this.onTickEnd()},l.onTickEnd=function(){},l.startLoad=function(c){},l.stopLoad=function(){this.fragmentLoader.abort();var c=this.fragCurrent;c&&this.fragmentTracker.removeFragment(c),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=b.STOPPED},l._streamEnded=function(c,x){var R=this.fragCurrent,C=this.fragmentTracker;if(!x.live&&R&&R.sn===x.endSN&&!c.nextStart){var N=C.getState(R);return N===O.FragmentState.PARTIAL||N===O.FragmentState.OK}return!1},l.onMediaAttached=function(c,x){var R=this.media=this.mediaBuffer=x.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),R.addEventListener("seeking",this.onvseeking),R.addEventListener("ended",this.onvended);var C=this.config;this.levels&&C.autoStartLoad&&this.state===b.STOPPED&&this.startLoad(C.startPosition)},l.onMediaDetaching=function(){var c=this.media;c!=null&&c.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),c&&(c.removeEventListener("seeking",this.onvseeking),c.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},l.onMediaSeeking=function(){var c=this.config,x=this.fragCurrent,R=this.media,C=this.mediaBuffer,N=this.state,U=R?R.currentTime:0,W=B.BufferHelper.bufferInfo(C||R,U,c.maxBufferHole);if(this.log("media seeking to "+(Object(j.isFiniteNumber)(U)?U.toFixed(3):U)+", state: "+N),N===b.ENDED)this.resetLoadingState();else if(x&&!W.len){var L=c.maxFragLookUpTolerance,H=x.start-L,K=x.start+x.duration+L,$=U>K;(U<H||$)&&($&&x.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),x.loader.abort()),this.resetLoadingState())}R&&(this.lastCurrentTime=U),!this.loadedmetadata&&!W.len&&(this.nextLoadPosition=this.startPosition=U),this.tickImmediate()},l.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},l.onKeyLoaded=function(c,x){if(this.state!==b.KEY_LOADING||x.frag!==this.fragCurrent||!this.levels)return;this.state=b.IDLE;var R=this.levels[x.frag.level].details;R&&this.loadFragment(x.frag,R,x.frag.start)},l.onHandlerDestroying=function(){this.stopLoad(),d.prototype.onHandlerDestroying.call(this)},l.onHandlerDestroyed=function(){this.state=b.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,d.prototype.onHandlerDestroyed.call(this)},l.loadKey=function(c,x){this.log("Loading key for "+c.sn+" of ["+x.startSN+"-"+x.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+c.level),this.state=b.KEY_LOADING,this.fragCurrent=c,this.hls.trigger(A.Events.KEY_LOADING,{frag:c})},l.loadFragment=function(c,x,R){this._loadFragForPlayback(c,x,R)},l._loadFragForPlayback=function(c,x,R){var C=this,N=function(W){if(C.fragContextChanged(c)){C.warn("Fragment "+c.sn+(W.part?" p: "+W.part.index:"")+" of level "+c.level+" was dropped during download."),C.fragmentTracker.removeFragment(c);return}c.stats.chunkCount++,C._handleFragmentLoadProgress(W)};this._doFragLoad(c,x,R,N).then(function(U){if(!U)return;C.fragLoadError=0;var W=C.state;if(C.fragContextChanged(c)){(W===b.FRAG_LOADING||W===b.BACKTRACKING||!C.fragCurrent&&W===b.PARSING)&&(C.fragmentTracker.removeFragment(c),C.state=b.IDLE);return}if("payload"in U&&(C.log("Loaded fragment "+c.sn+" of level "+c.level),C.hls.trigger(A.Events.FRAG_LOADED,U),C.state===b.BACKTRACKING)){C.fragmentTracker.backtrack(c,U),C.resetFragmentLoading(c);return}C._handleFragmentLoadComplete(U)}).catch(function(U){C.warn(U),C.resetFragmentLoading(c)})},l.flushMainBuffer=function(c,x,R){if(R===void 0&&(R=null),!(c-x))return;var C={startOffset:c,endOffset:x,type:R};this.fragLoadError=0,this.hls.trigger(A.Events.BUFFER_FLUSHING,C)},l._loadInitSegment=function(c){var x=this;this._doFragLoad(c).then(function(R){if(!R||x.fragContextChanged(c)||!x.levels)throw new Error("init load aborted");return R}).then(function(R){var C=x.hls,N=R.payload,U=c.decryptdata;if(N&&N.byteLength>0&&U&&U.key&&U.iv&&U.method==="AES-128"){var W=self.performance.now();return x.decrypter.webCryptoDecrypt(new Uint8Array(N),U.key.buffer,U.iv.buffer).then(function(L){var H=self.performance.now();return C.trigger(A.Events.FRAG_DECRYPTED,{frag:c,payload:L,stats:{tstart:W,tdecrypt:H}}),R.payload=L,R})}return R}).then(function(R){var C=x.fragCurrent,N=x.hls,U=x.levels;if(!U)throw new Error("init load aborted, missing levels");var W=U[c.level].details;console.assert(W,"Level details are defined when init segment is loaded");var L=c.stats;x.state=b.IDLE,x.fragLoadError=0,c.data=new Uint8Array(R.payload),L.parsing.start=L.buffering.start=self.performance.now(),L.parsing.end=L.buffering.end=self.performance.now(),R.frag===C&&N.trigger(A.Events.FRAG_BUFFERED,{stats:L,frag:C,part:null,id:c.type}),x.tick()}).catch(function(R){x.warn(R),x.resetFragmentLoading(c)})},l.fragContextChanged=function(c){var x=this.fragCurrent;return!c||!x||c.level!==x.level||c.sn!==x.sn||c.urlId!==x.urlId},l.fragBufferedComplete=function(c,x){var R=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+c.type+" sn: "+c.sn+(x?" part: "+x.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+c.level+" "+t.default.toString(B.BufferHelper.getBuffered(R))),this.state=b.IDLE,this.tick()},l._handleFragmentLoadComplete=function(c){var x=this.transmuxer;if(!x)return;var R=c.frag,C=c.part,N=c.partsLoaded,U=!N||N.length===0||N.some(function(L){return!L}),W=new p.ChunkMetadata(R.level,R.sn,R.stats.chunkCount+1,0,C?C.index:-1,!U);x.flush(W)},l._handleFragmentLoadProgress=function(c){},l._doFragLoad=function(c,x,R,C){var N=this;if(R===void 0&&(R=null),!this.levels)throw new Error("frag load aborted, missing levels");if(R=Math.max(c.start,R||0),this.config.lowLatencyMode&&x){var U=x.partList;if(U&&C){R>c.end&&x.fragmentHint&&(c=x.fragmentHint);var W=this.getNextPart(U,c,R);if(W>-1){var L=U[W];return this.log("Loading part sn: "+c.sn+" p: "+L.index+" cc: "+c.cc+" of playlist ["+x.startSN+"-"+x.endSN+"] parts [0-"+W+"-"+(U.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+c.level+", target: "+parseFloat(R.toFixed(3))),this.nextLoadPosition=L.start+L.duration,this.state=b.FRAG_LOADING,this.hls.trigger(A.Events.FRAG_LOADING,{frag:c,part:U[W],targetBufferTime:R}),this.doFragPartsLoad(c,U,W,C).catch(function(H){return N.handleFragLoadError(H)})}else if(!c.url||this.loadedEndOfParts(U,R))return Promise.resolve(null)}}return this.log("Loading fragment "+c.sn+" cc: "+c.cc+" "+(x?"of ["+x.startSN+"-"+x.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+c.level+", target: "+parseFloat(R.toFixed(3))),Object(j.isFiniteNumber)(c.sn)&&!this.bitrateTest&&(this.nextLoadPosition=c.start+c.duration),this.state=b.FRAG_LOADING,this.hls.trigger(A.Events.FRAG_LOADING,{frag:c,targetBufferTime:R}),this.fragmentLoader.load(c,C).catch(function(H){return N.handleFragLoadError(H)})},l.doFragPartsLoad=function(c,x,R,C){var N=this;return new Promise(function(U,W){var L=[],H=function K($){var Q=x[$];N.fragmentLoader.loadPart(c,Q,C).then(function(ue){L[Q.index]=ue;var ne=ue.part;N.hls.trigger(A.Events.FRAG_LOADED,ue);var se=x[$+1];if(se&&se.fragment===c)K($+1);else return U({frag:c,part:ne,partsLoaded:L})}).catch(W)};H(R)})},l.handleFragLoadError=function(c){var x=c.data;return x&&x.details===S.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(x.frag,x.part):this.hls.trigger(A.Events.ERROR,x),null},l._handleTransmuxerFlush=function(c){var x=this.getCurrentContext(c);if(!x||this.state!==b.PARSING){this.fragCurrent||(this.state=b.IDLE);return}var R=x.frag,C=x.part,N=x.level,U=self.performance.now();R.stats.parsing.end=U,C&&(C.stats.parsing.end=U),this.updateLevelTiming(R,C,N,c.partial)},l.getCurrentContext=function(c){var x=this.levels,R=c.level,C=c.sn,N=c.part;if(!x||!x[R])return this.warn("Levels object was unset while buffering fragment "+C+" of level "+R+". The current chunk will not be buffered."),null;var U=x[R],W=N>-1?Object(n.getPartWith)(U,C,N):null,L=W?W.fragment:Object(n.getFragmentWithSN)(U,C,this.fragCurrent);return L?{frag:L,part:W,level:U}:null},l.bufferFragmentData=function(c,x,R,C){if(!c||this.state!==b.PARSING)return;var N=c.data1,U=c.data2,W=N;if(N&&U&&(W=Object(m.appendUint8Array)(N,U)),!W||!W.length)return;var L={type:c.type,frag:x,part:R,chunkMeta:C,parent:x.type,data:W};this.hls.trigger(A.Events.BUFFER_APPENDING,L),c.dropped&&c.independent&&!R&&this.flushBufferGap(x)},l.flushBufferGap=function(c){var x=this.media;if(!x)return;if(!B.BufferHelper.isBuffered(x,x.currentTime)){this.flushMainBuffer(0,c.start);return}var R=x.currentTime,C=B.BufferHelper.bufferInfo(x,R,0),N=c.duration,U=Math.min(this.config.maxFragLookUpTolerance*2,N*.25),W=Math.max(Math.min(c.start-U,C.end-U),R+U);c.start-W>U&&this.flushMainBuffer(W,c.start)},l.getFwdBufferInfo=function(c,x){var R=this.config,C=this.getLoadPosition();if(!Object(j.isFiniteNumber)(C))return null;var N=B.BufferHelper.bufferInfo(c,C,R.maxBufferHole);if(N.len===0&&N.nextStart!==void 0){var U=this.fragmentTracker.getBufferedFrag(C,x);if(U&&N.nextStart<U.end)return B.BufferHelper.bufferInfo(c,C,Math.max(N.nextStart,R.maxBufferHole))}return N},l.getMaxBufferLength=function(c){var x=this.config,R;return c?R=Math.max(8*x.maxBufferSize/c,x.maxBufferLength):R=x.maxBufferLength,Math.min(R,x.maxMaxBufferLength)},l.reduceMaxBufferLength=function(c){var x=this.config,R=c||x.maxBufferLength;return x.maxMaxBufferLength>=R?(x.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+x.maxMaxBufferLength+"s"),!0):!1},l.getNextFragment=function(c,x){var R,C,N=x.fragments,U=N.length;if(!U)return null;var W=this.config,L=N[0].start,H;if(x.live){var K=W.initialLiveManifestSize;if(U<K)return this.warn("Not enough fragments to start playback (have: "+U+", need: "+K+")"),null;!x.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(H=this.getInitialLiveFragment(x,N),this.startPosition=H?this.hls.liveSyncPosition||H.start:c)}else c<=L&&(H=N[0]);if(!H){var $=W.lowLatencyMode?x.partEnd:x.fragmentEnd;H=this.getFragmentAtPosition(c,$,x)}return(R=H)!==null&&R!==void 0&&R.initSegment&&!((C=H)!==null&&C!==void 0&&C.initSegment.data)&&!this.bitrateTest&&(H=H.initSegment),H},l.getNextPart=function(c,x,R){for(var C=-1,N=!1,U=!0,W=0,L=c.length;W<L;W++){var H=c[W];if(U=U&&!H.independent,C>-1&&R<H.start)break;var K=H.loaded;!K&&(N||H.independent||U)&&H.fragment===x&&(C=W),N=K}return C},l.loadedEndOfParts=function(c,x){var R=c[c.length-1];return R&&x>R.start&&R.loaded},l.getInitialLiveFragment=function(c,x){var R=this.fragPrevious,C=null;if(R){if(c.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+R.programDateTime),C=Object(r.findFragmentByPDT)(x,R.endProgramDateTime,this.config.maxFragLookUpTolerance)),!C){var N=R.sn+1;if(N>=c.startSN&&N<=c.endSN){var U=x[N-c.startSN];R.cc===U.cc&&(C=U,this.log("Live playlist, switching playlist, load frag with next SN: "+C.sn))}C||(C=Object(r.findFragWithCC)(x,R.cc),C&&this.log("Live playlist, switching playlist, load frag with same CC: "+C.sn))}}else{var W=this.hls.liveSyncPosition;W!==null&&(C=this.getFragmentAtPosition(W,this.bitrateTest?c.fragmentEnd:c.edge,c))}return C},l.getFragmentAtPosition=function(c,x,R){var C=this.config,N=this.fragPrevious,U=R.fragments,W=R.endSN,L=R.fragmentHint,H=C.maxFragLookUpTolerance,K=!!(C.lowLatencyMode&&R.partList&&L);K&&L&&!this.bitrateTest&&(U=U.concat(L),W=L.sn);var $;if(c<x){var Q=c>x-H?0:H;$=Object(r.findFragmentByPTS)(N,U,c,Q)}else $=U[U.length-1];if($){var ue=$.sn-R.startSN,ne=N&&$.level===N.level,se=U[ue+1],le=this.fragmentTracker.getState($);if(le===O.FragmentState.BACKTRACKED){$=null;for(var de=ue;U[de]&&this.fragmentTracker.getState(U[de])===O.FragmentState.BACKTRACKED;)N?$=U[de--]:$=U[--de];$||($=se)}else N&&$.sn===N.sn&&!K&&(ne&&($.sn<W&&this.fragmentTracker.getState(se)!==O.FragmentState.OK?(this.log("SN "+$.sn+" just loaded, load next one: "+se.sn),$=se):$=null))}return $},l.synchronizeToLiveEdge=function(c){var x=this.config,R=this.media;if(!R)return;var C=this.hls.liveSyncPosition,N=R.currentTime,U=c.fragments[0].start,W=c.edge,L=N>=U-x.maxFragLookUpTolerance&&N<=W;if(C!==null&&R.duration>C&&(N<C||!L)){var H=x.liveMaxLatencyDuration!==void 0?x.liveMaxLatencyDuration:x.liveMaxLatencyDurationCount*c.targetduration;(!L&&R.readyState<4||N<W-H)&&(this.loadedmetadata||(this.nextLoadPosition=C),R.readyState&&(this.warn("Playback: "+N.toFixed(3)+" is located too far from the end of live sliding playlist: "+W+", reset currentTime to : "+C.toFixed(3)),R.currentTime=C))}},l.alignPlaylists=function(c,x){var R=this.levels,C=this.levelLastLoaded,N=this.fragPrevious,U=C!==null?R[C]:null,W=c.fragments.length;if(!W)return this.warn("No fragments in live playlist"),0;var L=c.fragments[0].start,H=!x,K=c.alignedSliding&&Object(j.isFiniteNumber)(L);if(H||!K&&!L){Object(s.alignStream)(N,U,c);var $=c.fragments[0].start;return this.log("Live playlist sliding: "+$.toFixed(2)+" start-sn: "+(x?x.startSN:"na")+"->"+c.startSN+" prev-sn: "+(N?N.sn:"na")+" fragments: "+W),$}return L},l.waitForCdnTuneIn=function(c){var x=3;return c.live&&c.canBlockReload&&c.tuneInGoal>Math.max(c.partHoldBack,c.partTarget*x)},l.setStartPosition=function(c,x){var R=this.startPosition;if(R<x&&(R=-1),R===-1||this.lastCurrentTime===-1){var C=c.startTimeOffset;Object(j.isFiniteNumber)(C)?(R=x+C,C<0&&(R+=c.totalduration),R=Math.min(Math.max(x,R),x+c.totalduration),this.log("Start time offset "+C+" found in playlist, adjust startPosition to "+R),this.startPosition=R):c.live?R=this.hls.liveSyncPosition||x:this.startPosition=R=0,this.lastCurrentTime=R}this.nextLoadPosition=R},l.getLoadPosition=function(){var c=this.media,x=0;return this.loadedmetadata&&c?x=c.currentTime:this.nextLoadPosition&&(x=this.nextLoadPosition),x},l.handleFragLoadAborted=function(c,x){this.transmuxer&&c.sn!=="initSegment"&&c.stats.aborted&&(this.warn("Fragment "+c.sn+(x?" part"+x.index:"")+" of level "+c.level+" was aborted"),this.resetFragmentLoading(c))},l.resetFragmentLoading=function(c){(!this.fragCurrent||!this.fragContextChanged(c))&&(this.state=b.IDLE)},l.onFragmentOrKeyLoadError=function(c,x){if(x.fatal)return;var R=x.frag;if(!R||R.type!==c)return;var C=this.fragCurrent;console.assert(C&&R.sn===C.sn&&R.level===C.level&&R.urlId===C.urlId,"Frag load error must match current frag to retry");var N=this.config;if(this.fragLoadError+1<=N.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(R.level))return;var U=Math.min(Math.pow(2,this.fragLoadError)*N.fragLoadingRetryDelay,N.fragLoadingMaxRetryTimeout);this.warn("Fragment "+R.sn+" of "+c+" "+R.level+" failed to load, retrying in "+U+"ms"),this.retryDate=self.performance.now()+U,this.fragLoadError++,this.state=b.FRAG_LOADING_WAITING_RETRY}else x.levelRetry?(c===e.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=b.IDLE):(M.logger.error(x.details+" reaches max retry, redispatch as fatal ..."),x.fatal=!0,this.hls.stopLoad(),this.state=b.ERROR)},l.afterBufferFlushed=function(c,x,R){if(!c)return;var C=B.BufferHelper.getBuffered(c);this.fragmentTracker.detectEvictedFragments(x,C,R),this.state===b.ENDED&&this.resetLoadingState()},l.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=b.IDLE},l.resetLiveStartWhenNotLoaded=function(c){if(!this.loadedmetadata){this.startFragRequested=!1;var x=this.levels?this.levels[c].details:null;if(x!=null&&x.live)return this.startPosition=-1,this.setStartPosition(x,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},l.updateLevelTiming=function(c,x,R,C){var N=this,U=R.details;console.assert(!!U,"level.details must be defined");var W=Object.keys(c.elementaryStreams).reduce(function(L,H){var K=c.elementaryStreams[H];if(K){var $=K.endPTS-K.startPTS;if($<=0)return N.warn("Could not parse fragment "+c.sn+" "+H+" duration reliably ("+$+") resetting transmuxer to fallback to playlist timing"),N.resetTransmuxer(),L||!1;var Q=C?0:Object(n.updateFragPTSDTS)(U,c,K.startPTS,K.endPTS,K.startDTS,K.endDTS);return N.hls.trigger(A.Events.LEVEL_PTS_UPDATED,{details:U,level:R,drift:Q,type:H,frag:c,start:K.startPTS,end:K.endPTS}),!0}return L},!1);W?(this.state=b.PARSED,this.hls.trigger(A.Events.FRAG_PARSED,{frag:c,part:x})):this.resetLoadingState()},l.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},T(a,[{key:"state",get:function(){return this._state},set:function(c){var x=this._state;x!==c&&(this._state=c,this.log(x+"->"+c))}}]),a}(I.default)},"./src/controller/buffer-controller.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return r});var j=w("./src/polyfills/number.ts"),I=w("./src/events.ts"),O=w("./src/utils/logger.ts"),B=w("./src/errors.ts"),M=w("./src/utils/buffer-helper.ts"),A=w("./src/utils/mediasource-helper.ts"),S=w("./src/loader/fragment.ts"),p=w("./src/controller/buffer-operation-queue.ts"),m=Object(A.getMediaSource)(),s=/([ha]vc.)(?:\.[^.,]+)+/,r=function(){function n(o){var t=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 e=t.hls,i=t.media,T=t.mediaSource;O.logger.log("[buffer-controller]: Media source opened"),i&&(t.updateMediaElementDuration(),e.trigger(I.Events.MEDIA_ATTACHED,{media:i})),T&&T.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){O.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){O.logger.log("[buffer-controller]: Media source ended")},this.hls=o,this._initSourceBuffer(),this.registerListeners()}var u=n.prototype;return u.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},u.destroy=function(){this.unregisterListeners(),this.details=null},u.registerListeners=function(){var t=this.hls;t.on(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(I.Events.BUFFER_RESET,this.onBufferReset,this),t.on(I.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.on(I.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(I.Events.BUFFER_EOS,this.onBufferEos,this),t.on(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(I.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(I.Events.FRAG_PARSED,this.onFragParsed,this),t.on(I.Events.FRAG_CHANGED,this.onFragChanged,this)},u.unregisterListeners=function(){var t=this.hls;t.off(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(I.Events.BUFFER_RESET,this.onBufferReset,this),t.off(I.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.off(I.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(I.Events.BUFFER_EOS,this.onBufferEos,this),t.off(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(I.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(I.Events.FRAG_PARSED,this.onFragParsed,this),t.off(I.Events.FRAG_CHANGED,this.onFragChanged,this)},u._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new p.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},u.onManifestParsed=function(t,e){var i=2;(e.audio&&!e.video||!e.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,this.details=null,O.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},u.onMediaAttaching=function(t,e){var i=this.media=e.media;if(i&&m){var T=this.mediaSource=new m;T.addEventListener("sourceopen",this._onMediaSourceOpen),T.addEventListener("sourceended",this._onMediaSourceEnded),T.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(T),this._objectUrl=i.src}},u.onMediaDetaching=function(){var t=this.media,e=this.mediaSource,i=this._objectUrl;if(e){if(O.logger.log("[buffer-controller]: media source detaching"),e.readyState==="open")try{e.endOfStream()}catch(T){O.logger.warn("[buffer-controller]: onMediaDetaching: "+T.message+" while calling endOfStream")}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(i&&self.URL.revokeObjectURL(i),t.src===i?(t.removeAttribute("src"),t.load()):O.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(I.Events.MEDIA_DETACHED,void 0)},u.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach(function(e){var i=t.sourceBuffer[e];try{i&&(t.removeBufferListeners(e),t.mediaSource&&t.mediaSource.removeSourceBuffer(i),t.sourceBuffer[e]=void 0)}catch(T){O.logger.warn("[buffer-controller]: Failed to reset the "+e+" buffer",T)}}),this._initSourceBuffer()},u.onBufferCodecs=function(t,e){var i=this,T=this.getSourceBufferTypes().length;if(Object.keys(e).forEach(function(_){if(T){var y=i.tracks[_];if(y&&typeof y.buffer.changeType=="function"){var E=e[_],b=E.codec,g=E.levelCodec,d=E.container,a=(y.levelCodec||y.codec).replace(s,"$1"),l=(g||b).replace(s,"$1");if(a!==l){var f=d+";codecs="+(g||b);i.appendChangeType(_,f)}}}else i.pendingTracks[_]=e[_]}),T)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},u.appendChangeType=function(t,e){var i=this,T=this.operationQueue,_={execute:function(){var E=i.sourceBuffer[t];E&&(O.logger.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+e),E.changeType(e)),T.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(E){O.logger.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",E)}};T.append(_,t)},u.onBufferAppending=function(t,e){var i=this,T=this.hls,_=this.operationQueue,y=this.tracks,E=e.data,b=e.type,g=e.frag,d=e.part,a=e.chunkMeta,l=a.buffering[b],f=self.performance.now();l.start=f;var c=g.stats.buffering,x=d?d.stats.buffering:null;c.start===0&&(c.start=f),x&&x.start===0&&(x.start=f);var R=y.audio,C=b==="audio"&&a.id===1&&(R==null?void 0:R.container)==="audio/mpeg",N={execute:function(){if(l.executeStart=self.performance.now(),C){var W=i.sourceBuffer[b];if(W){var L=g.start-W.timestampOffset;Math.abs(L)>=.1&&(O.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+g.start+" (delta: "+L+") sn: "+g.sn+")"),W.timestampOffset=g.start)}}i.appendExecutor(E,b)},onStart:function(){},onComplete:function(){var W=self.performance.now();l.executeEnd=l.end=W,c.first===0&&(c.first=W),x&&x.first===0&&(x.first=W);var L=i.sourceBuffer,H={};for(var K in L)H[K]=M.BufferHelper.getBuffered(L[K]);i.appendError=0,i.hls.trigger(I.Events.BUFFER_APPENDED,{type:b,frag:g,part:d,chunkMeta:a,parent:g.type,timeRanges:H})},onError:function(W){O.logger.error("[buffer-controller]: Error encountered while trying to append to the "+b+" SourceBuffer",W);var L={type:B.ErrorTypes.MEDIA_ERROR,parent:g.type,details:B.ErrorDetails.BUFFER_APPEND_ERROR,err:W,fatal:!1};W.code===DOMException.QUOTA_EXCEEDED_ERR?L.details=B.ErrorDetails.BUFFER_FULL_ERROR:(i.appendError++,L.details=B.ErrorDetails.BUFFER_APPEND_ERROR,i.appendError>T.config.appendErrorMaxRetry&&(O.logger.error("[buffer-controller]: Failed "+T.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),L.fatal=!0)),T.trigger(I.Events.ERROR,L)}};_.append(N,b)},u.onBufferFlushing=function(t,e){var i=this,T=this.operationQueue,_=function(E){return{execute:i.removeExecutor.bind(i,E,e.startOffset,e.endOffset),onStart:function(){},onComplete:function(){i.hls.trigger(I.Events.BUFFER_FLUSHED,{type:E})},onError:function(g){O.logger.warn("[buffer-controller]: Failed to remove from "+E+" SourceBuffer",g)}}};e.type?T.append(_(e.type),e.type):this.getSourceBufferTypes().forEach(function(y){T.append(_(y),y)})},u.onFragParsed=function(t,e){var i=this,T=e.frag,_=e.part,y=[],E=_?_.elementaryStreams:T.elementaryStreams;E[S.ElementaryStreamTypes.AUDIOVIDEO]?y.push("audiovideo"):(E[S.ElementaryStreamTypes.AUDIO]&&y.push("audio"),E[S.ElementaryStreamTypes.VIDEO]&&y.push("video"));var b=function(){var d=self.performance.now();T.stats.buffering.end=d,_&&(_.stats.buffering.end=d);var a=_?_.stats:T.stats;i.hls.trigger(I.Events.FRAG_BUFFERED,{frag:T,part:_,stats:a,id:T.type})};y.length===0&&O.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+T.type+" level: "+T.level+" sn: "+T.sn),this.blockBuffers(b,y)},u.onFragChanged=function(t,e){this.flushBackBuffer()},u.onBufferEos=function(t,e){var i=this,T=this.getSourceBufferTypes().reduce(function(_,y){var E=i.sourceBuffer[y];return(!e.type||e.type===y)&&(E&&!E.ended&&(E.ended=!0,O.logger.log("[buffer-controller]: "+y+" sourceBuffer now EOS"))),_&&!!(!E||E.ended)},!0);T&&this.blockBuffers(function(){var _=i.mediaSource;if(!_||_.readyState!=="open")return;_.endOfStream()})},u.onLevelUpdated=function(t,e){var i=e.details;if(!i.fragments.length)return;this.details=i,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},u.flushBackBuffer=function(){var t=this.hls,e=this.details,i=this.media,T=this.sourceBuffer;if(!i||e===null)return;var _=this.getSourceBufferTypes();if(!_.length)return;var y=e.live&&t.config.liveBackBufferLength!==null?t.config.liveBackBufferLength:t.config.backBufferLength;if(!Object(j.isFiniteNumber)(y)||y<0)return;var E=i.currentTime,b=e.levelTargetDuration,g=Math.max(y,b),d=Math.floor(E/b)*b-g;_.forEach(function(a){var l=T[a];if(l){var f=M.BufferHelper.getBuffered(l);f.length>0&&d>f.start(0)&&(t.trigger(I.Events.BACK_BUFFER_REACHED,{bufferEnd:d}),e.live&&t.trigger(I.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:d}),t.trigger(I.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:d,type:a}))}})},u.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var t=this.details,e=this.hls,i=this.media,T=this.mediaSource,_=t.fragments[0].start+t.totalduration,y=i.duration,E=Object(j.isFiniteNumber)(T.duration)?T.duration:0;t.live&&e.config.liveDurationInfinity?(O.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),T.duration=Infinity,this.updateSeekableRange(t)):(_>E&&_>y||!Object(j.isFiniteNumber)(y))&&(O.logger.log("[buffer-controller]: Updating Media Source duration to "+_.toFixed(3)),T.duration=_)},u.updateSeekableRange=function(t){var e=this.mediaSource,i=t.fragments,T=i.length;if(T&&t.live&&e!==null&&e!==void 0&&e.setLiveSeekableRange){var _=Math.max(0,i[0].start),y=Math.max(_,_+t.totalduration);e.setLiveSeekableRange(_,y)}},u.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,e=this.operationQueue,i=this.pendingTracks,T=Object.keys(i).length;if(T&&!t||T===2){this.createSourceBuffers(i),this.pendingTracks={};var _=this.getSourceBufferTypes();if(_.length===0){this.hls.trigger(I.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}_.forEach(function(y){e.executeNext(y)})}},u.createSourceBuffers=function(t){var e=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");var T=0;for(var _ in t)if(!e[_]){var y=t[_];if(!y)throw Error("source buffer exists for track "+_+", however track does not");var E=y.levelCodec||y.codec,b=y.container+";codecs="+E;O.logger.log("[buffer-controller]: creating sourceBuffer("+b+")");try{var g=e[_]=i.addSourceBuffer(b),d=_;this.addBufferListener(d,"updatestart",this._onSBUpdateStart),this.addBufferListener(d,"updateend",this._onSBUpdateEnd),this.addBufferListener(d,"error",this._onSBUpdateError),this.tracks[_]={buffer:g,codec:E,container:y.container,levelCodec:y.levelCodec,id:y.id},T++}catch(a){O.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+a.message),this.hls.trigger(I.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:a,mimeType:b})}}T&&this.hls.trigger(I.Events.BUFFER_CREATED,{tracks:this.tracks})},u._onSBUpdateStart=function(t){var e=this.operationQueue,i=e.current(t);i.onStart()},u._onSBUpdateEnd=function(t){var e=this.operationQueue,i=e.current(t);i.onComplete(),e.shiftAndExecuteNext(t)},u._onSBUpdateError=function(t,e){O.logger.error("[buffer-controller]: "+t+" SourceBuffer error",e),this.hls.trigger(I.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var i=this.operationQueue.current(t);i&&i.onError(e)},u.removeExecutor=function(t,e,i){var T=this.media,_=this.mediaSource,y=this.operationQueue,E=this.sourceBuffer,b=E[t];if(!T||!_||!b){O.logger.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),y.shiftAndExecuteNext(t);return}var g=Object(j.isFiniteNumber)(T.duration)?T.duration:Infinity,d=Object(j.isFiniteNumber)(_.duration)?_.duration:Infinity,a=Math.max(0,e),l=Math.min(i,g,d);l>a?(O.logger.log("[buffer-controller]: Removing ["+a+","+l+"] from the "+t+" SourceBuffer"),console.assert(!b.updating,t+" sourceBuffer must not be updating"),b.remove(a,l)):y.shiftAndExecuteNext(t)},u.appendExecutor=function(t,e){var i=this.operationQueue,T=this.sourceBuffer,_=T[e];if(!_){O.logger.warn("[buffer-controller]: Attempting to append to the "+e+" SourceBuffer, but it does not exist"),i.shiftAndExecuteNext(e);return}_.ended=!1,console.assert(!_.updating,e+" sourceBuffer must not be updating"),_.appendBuffer(t)},u.blockBuffers=function(t,e){var i=this;if(e===void 0&&(e=this.getSourceBufferTypes()),!e.length){O.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(t);return}var T=this.operationQueue,_=e.map(function(y){return T.appendBlocker(y)});Promise.all(_).then(function(){t(),e.forEach(function(y){var E=i.sourceBuffer[y];(!E||!E.updating)&&T.shiftAndExecuteNext(y)})})},u.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},u.addBufferListener=function(t,e,i){var T=this.sourceBuffer[t];if(!T)return;var _=i.bind(this,t);this.listeners[t].push({event:e,listener:_}),T.addEventListener(e,_)},u.removeBufferListeners=function(t){var e=this.sourceBuffer[t];if(!e)return;this.listeners[t].forEach(function(i){e.removeEventListener(i.event,i.listener)})},n}()},"./src/controller/buffer-operation-queue.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return I});var j=w("./src/utils/logger.ts"),I=function(){function O(M){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=M}var B=O.prototype;return B.append=function(A,S){var p=this.queues[S];p.push(A),p.length===1&&this.buffers[S]&&this.executeNext(S)},B.insertAbort=function(A,S){var p=this.queues[S];p.unshift(A),this.executeNext(S)},B.appendBlocker=function(A){var S,p=new Promise(function(s){S=s}),m={execute:S,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(m,A),p},B.executeNext=function(A){var S=this.buffers,p=this.queues,m=S[A],s=p[A];if(s.length){var r=s[0];try{r.execute()}catch(n){j.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),r.onError(n),(!m||!m.updating)&&(s.shift(),this.executeNext(A))}}},B.shiftAndExecuteNext=function(A){this.queues[A].shift(),this.executeNext(A)},B.current=function(A){return this.queues[A][0]},O}()},"./src/controller/cap-level-controller.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/events.ts");function I(M,A){for(var S=0;S<A.length;S++){var p=A[S];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(M,p.key,p)}}function O(M,A,S){return A&&I(M.prototype,A),S&&I(M,S),M}var B=function(){function M(S){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=S,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(p){this.streamController=p},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 p=this.hls;p.on(j.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),p.on(j.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),p.on(j.Events.MANIFEST_PARSED,this.onManifestParsed,this),p.on(j.Events.BUFFER_CODECS,this.onBufferCodecs,this),p.on(j.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},A.unregisterListener=function(){var p=this.hls;p.off(j.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),p.off(j.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),p.off(j.Events.MANIFEST_PARSED,this.onManifestParsed,this),p.off(j.Events.BUFFER_CODECS,this.onBufferCodecs,this),p.off(j.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},A.onFpsDropLevelCapping=function(p,m){M.isLevelAllowed(m.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(m.droppedLevel)},A.onMediaAttaching=function(p,m){this.media=m.media instanceof HTMLVideoElement?m.media:null},A.onManifestParsed=function(p,m){var s=this.hls;this.restrictedLevels=[],this.firstLevel=m.firstLevel,s.config.capLevelToPlayerSize&&m.video&&this.startCapping()},A.onBufferCodecs=function(p,m){var s=this.hls;s.config.capLevelToPlayerSize&&m.video&&this.startCapping()},A.onMediaDetaching=function(){this.stopCapping()},A.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var p=this.hls.levels;if(p.length){var m=this.hls;m.autoLevelCapping=this.getMaxLevel(p.length-1),m.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=m.autoLevelCapping}}},A.getMaxLevel=function(p){var m=this,s=this.hls.levels;if(!s.length)return-1;var r=s.filter(function(n,u){return M.isLevelAllowed(u,m.restrictedLevels)&&u<=p});return this.clientRect=null,M.getMaxLevelByMediaSize(r,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 p=this.media,m={width:0,height:0};if(p){var s=p.getBoundingClientRect();m.width=s.width,m.height=s.height,!m.width&&!m.height&&(m.width=s.right-s.left||p.width||0,m.height=s.bottom-s.top||p.height||0)}return this.clientRect=m,m},M.isLevelAllowed=function(p,m){return m===void 0&&(m=[]),m.indexOf(p)===-1},M.getMaxLevelByMediaSize=function(p,m,s){if(!p||!p.length)return-1;for(var r=function(e,i){return i?e.width!==i.width||e.height!==i.height:!0},n=p.length-1,u=0;u<p.length;u+=1){var o=p[u];if((o.width>=m||o.height>=s)&&r(o,p[u+1])){n=u;break}}return n},O(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 p=1;try{p=self.devicePixelRatio}catch(m){}return p}}]),M}();G.default=B},"./src/controller/cmcd-controller.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return r});var j=w("./src/events.ts"),I=w("./src/types/cmcd.ts"),O=w("./src/utils/buffer-helper.ts"),B=w("./src/utils/logger.ts");function M(n,u){for(var o=0;o<u.length;o++){var t=u[o];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,t.key,t)}}function A(n,u,o){return u&&M(n.prototype,u),o&&M(n,o),n}function S(n,u){var o=typeof Symbol!="undefined"&&n[Symbol.iterator]||n["@@iterator"];if(o)return(o=o.call(n)).next.bind(o);if(Array.isArray(n)||(o=p(n))||u&&n&&typeof n.length=="number"){o&&(n=o);var t=0;return function(){return t>=n.length?{done:!0}:{done:!1,value:n[t++]}}}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 p(n,u){if(!n)return;if(typeof n=="string")return m(n,u);var o=Object.prototype.toString.call(n).slice(8,-1);if(o==="Object"&&n.constructor&&(o=n.constructor.name),o==="Map"||o==="Set")return Array.from(n);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return m(n,u)}function m(n,u){(u==null||u>n.length)&&(u=n.length);for(var o=0,t=new Array(u);o<u;o++)t[o]=n[o];return t}function s(){return s=Object.assign||function(n){for(var u=1;u<arguments.length;u++){var o=arguments[u];for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&(n[t]=o[t])}return n},s.apply(this,arguments)}var r=function(){function n(o){var t=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(){t.initialized&&(t.starved=!0),t.buffering=!0},this.onPlaying=function(){t.initialized||(t.initialized=!0),t.buffering=!1},this.applyPlaylistData=function(T){try{t.apply(T,{ot:I.CMCDObjectType.MANIFEST,su:!t.initialized})}catch(_){B.logger.warn("Could not generate manifest CMCD data.",_)}},this.applyFragmentData=function(T){try{var _=T.frag,y=t.hls.levels[_.level],E=t.getObjectType(_),b={d:_.duration*1e3,ot:E};(E===I.CMCDObjectType.VIDEO||E===I.CMCDObjectType.AUDIO||E==I.CMCDObjectType.MUXED)&&(b.br=y.bitrate/1e3,b.tb=t.getTopBandwidth(E),b.bl=t.getBufferLength(E)),t.apply(T,b)}catch(g){B.logger.warn("Could not generate segment CMCD data.",g)}},this.hls=o;var e=this.config=o.config,i=e.cmcd;i!=null&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||n.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}var u=n.prototype;return u.registerListeners=function(){var t=this.hls;t.on(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(j.Events.MEDIA_DETACHED,this.onMediaDetached,this),t.on(j.Events.BUFFER_CREATED,this.onBufferCreated,this)},u.unregisterListeners=function(){var t=this.hls;t.off(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(j.Events.MEDIA_DETACHED,this.onMediaDetached,this),t.off(j.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},u.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},u.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},u.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},u.onBufferCreated=function(t,e){var i,T;this.audioBuffer=(i=e.tracks.audio)===null||i===void 0?void 0:i.buffer,this.videoBuffer=(T=e.tracks.video)===null||T===void 0?void 0:T.buffer},u.createData=function(){var t;return{v:I.CMCDVersion,sf:I.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(t=this.media)===null||t===void 0?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},u.apply=function(t,e){e===void 0&&(e={}),s(e,this.createData());var i=e.ot===I.CMCDObjectType.INIT||e.ot===I.CMCDObjectType.VIDEO||e.ot===I.CMCDObjectType.MUXED;if(this.starved&&i&&(e.bs=!0,e.su=!0,this.starved=!1),e.su==null&&(e.su=this.buffering),this.useHeaders){var T=n.toHeaders(e);if(!Object.keys(T).length)return;t.headers||(t.headers={}),s(t.headers,T)}else{var _=n.toQuery(e);if(!_)return;t.url=n.appendQueryToUri(t.url,_)}},u.getObjectType=function(t){var e=t.type;return e==="subtitle"?I.CMCDObjectType.TIMED_TEXT:t.sn==="initSegment"?I.CMCDObjectType.INIT:e==="audio"?I.CMCDObjectType.AUDIO:e==="main"?this.hls.audioTracks.length?I.CMCDObjectType.VIDEO:I.CMCDObjectType.MUXED:void 0},u.getTopBandwidth=function(t){for(var e=0,i=t===I.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,T=S(i),_;!(_=T()).done;){var y=_.value;y.bitrate>e&&(e=y.bitrate)}return e>0?e:NaN},u.getBufferLength=function(t){var e=this.hls.media,i=t===I.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!i||!e)return NaN;var T=O.BufferHelper.bufferInfo(i,e.currentTime,this.config.maxBufferHole);return T.len*1e3},u.createPlaylistLoader=function(){var t=this.config.pLoader,e=this.applyPlaylistData,i=t||this.config.loader;return function(){function T(y){this.loader=void 0,this.loader=new i(y)}var _=T.prototype;return _.destroy=function(){this.loader.destroy()},_.abort=function(){this.loader.abort()},_.load=function(E,b,g){e(E),this.loader.load(E,b,g)},A(T,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),T}()},u.createFragmentLoader=function(){var t=this.config.fLoader,e=this.applyFragmentData,i=t||this.config.loader;return function(){function T(y){this.loader=void 0,this.loader=new i(y)}var _=T.prototype;return _.destroy=function(){this.loader.destroy()},_.abort=function(){this.loader.abort()},_.load=function(E,b,g){e(E),this.loader.load(E,b,g)},A(T,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),T}()},n.uuid=function(){var t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.substr(e.lastIndexOf("/")+1)},n.serialize=function(t){for(var e=[],i=function(C){return!Number.isNaN(C)&&C!=null&&C!==""&&C!==!1},T=function(C){return Math.round(C)},_=function(C){return T(C/100)*100},y=function(C){return encodeURIComponent(C)},E={br:T,d:T,bl:_,dl:_,mtp:_,nor:y,rtp:_,tb:T},b=Object.keys(t||{}).sort(),g=S(b),d;!(d=g()).done;){var a=d.value,l=t[a];if(!i(l))continue;if(a==="v"&&l===1)continue;if(a=="pr"&&l===1)continue;var f=E[a];f&&(l=f(l));var c=typeof l,x=void 0;a==="ot"||a==="sf"||a==="st"?x=a+"="+l:c==="boolean"?x=a:c==="number"?x=a+"="+l:x=a+"="+JSON.stringify(l),e.push(x)}return e.join(",")},n.toHeaders=function(t){for(var e=Object.keys(t),i={},T=["Object","Request","Session","Status"],_=[{},{},{},{}],y={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},E=0,b=e;E<b.length;E++){var g=b[E],d=y[g]!=null?y[g]:1;_[d][g]=t[g]}for(var a=0;a<_.length;a++){var l=n.serialize(_[a]);l&&(i["CMCD-"+T[a]]=l)}return i},n.toQuery=function(t){return"CMCD="+encodeURIComponent(n.serialize(t))},n.appendQueryToUri=function(t,e){if(!e)return t;var i=t.includes("?")?"&":"?";return""+t+i+e},n}()},"./src/controller/eme-controller.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/events.ts"),I=w("./src/errors.ts"),O=w("./src/utils/logger.ts"),B=w("./src/utils/mediakeys-helper.ts");function M(r,n){for(var u=0;u<n.length;u++){var o=n[u];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(r,o.key,o)}}function A(r,n,u){return n&&M(r.prototype,n),u&&M(r,u),r}var S=3,p=function(n,u,o){var t={audioCapabilities:[],videoCapabilities:[]};return n.forEach(function(e){t.audioCapabilities.push({contentType:'audio/mp4; codecs="'+e+'"',robustness:o.audioRobustness||""})}),u.forEach(function(e){t.videoCapabilities.push({contentType:'video/mp4; codecs="'+e+'"',robustness:o.videoRobustness||""})}),[t]},m=function(n,u,o,t){switch(n){case B.KeySystems.WIDEVINE:return p(u,o,t);default:throw new Error("Unknown key-system: "+n)}},s=function(){function r(u){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=u,this._config=u.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 n=r.prototype;return n.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},n._registerListeners=function(){this.hls.on(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(j.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(j.Events.MANIFEST_PARSED,this.onManifestParsed,this)},n._unregisterListeners=function(){this.hls.off(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(j.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(j.Events.MANIFEST_PARSED,this.onManifestParsed,this)},n.getLicenseServerUrl=function(o){switch(o){case B.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+o+'"')},n._attemptKeySystemAccess=function(o,t,e){var i=this,T=m(o,t,e,this._drmSystemOptions);O.logger.log("Requesting encrypted media key-system access");var _=this.requestMediaKeySystemAccess(o,T);this.mediaKeysPromise=_.then(function(y){return i._onMediaKeySystemAccessObtained(o,y)}),_.catch(function(y){O.logger.error('Failed to obtain key-system "'+o+'" access:',y)})},n._onMediaKeySystemAccessObtained=function(o,t){var e=this;O.logger.log('Access for key-system "'+o+'" obtained');var i={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:t,mediaKeySystemDomain:o};this._mediaKeysList.push(i);var T=Promise.resolve().then(function(){return t.createMediaKeys()}).then(function(_){return i.mediaKeys=_,O.logger.log('Media-keys created for key-system "'+o+'"'),e._onMediaKeysCreated(),_});return T.catch(function(_){O.logger.error("Failed to create media-keys:",_)}),T},n._onMediaKeysCreated=function(){var o=this;this._mediaKeysList.forEach(function(t){t.mediaKeysSession||(t.mediaKeysSession=t.mediaKeys.createSession(),o._onNewMediaKeySession(t.mediaKeysSession))})},n._onNewMediaKeySession=function(o){var t=this;O.logger.log("New key-system session "+o.sessionId),o.addEventListener("message",function(e){t._onKeySessionMessage(o,e.message)},!1)},n._onKeySessionMessage=function(o,t){O.logger.log("Got EME message event, creating license request"),this._requestLicense(t,function(e){O.logger.log("Received license data (length: "+(e&&e.byteLength)+"), updating key-session"),o.update(e)})},n.onMediaEncrypted=function(o){var t=this;if(O.logger.log('Media is encrypted using "'+o.initDataType+'" init data type'),!this.mediaKeysPromise){O.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(j.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var e=function(T){if(!t._media)return;t._attemptSetMediaKeys(T),t._generateRequestWithPreferredKeySession(o.initDataType,o.initData)};this.mediaKeysPromise.then(e).catch(e)},n._attemptSetMediaKeys=function(o){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var t=this._mediaKeysList[0];if(!t||!t.mediaKeys){O.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(j.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}O.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(t.mediaKeys),this._hasSetMediaKeys=!0}},n._generateRequestWithPreferredKeySession=function(o,t){var e=this,i=this._mediaKeysList[0];if(!i){O.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(j.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(i.mediaKeysSessionInitialized){O.logger.warn("Key-Session already initialized but requested again");return}var T=i.mediaKeysSession;if(!T){O.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(j.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!t){O.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(j.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}O.logger.log('Generating key-session request for "'+o+'" init data type'),i.mediaKeysSessionInitialized=!0,T.generateRequest(o,t).then(function(){O.logger.debug("Key-session generation succeeded")}).catch(function(_){O.logger.error("Error generating key-session request:",_),e.hls.trigger(j.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},n._createLicenseXhr=function(o,t,e){var i=new XMLHttpRequest;i.responseType="arraybuffer",i.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,i,o,t,e);var T=this._licenseXhrSetup;if(T)try{T.call(this.hls,i,o),T=void 0}catch(_){O.logger.error(_)}try{i.readyState||i.open("POST",o,!0),T&&T.call(this.hls,i,o)}catch(_){throw new Error("issue setting up KeySystem license XHR "+_)}return i},n._onLicenseRequestReadyStageChange=function(o,t,e,i){switch(o.readyState){case 4:if(o.status===200){this._requestLicenseFailureCount=0,O.logger.log("License request succeeded");var T=o.response,_=this._licenseResponseCallback;if(_)try{T=_.call(this.hls,o,t)}catch(E){O.logger.error(E)}i(T)}else{if(O.logger.error("License Request XHR failed ("+t+"). Status: "+o.status+" ("+o.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>S){this.hls.trigger(j.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var y=S-this._requestLicenseFailureCount+1;O.logger.warn("Retrying license request, "+y+" attempts left"),this._requestLicense(e,i)}break}},n._generateLicenseRequestChallenge=function(o,t){switch(o.mediaKeySystemDomain){case B.KeySystems.WIDEVINE:return t}throw new Error("unsupported key-system: "+o.mediaKeySystemDomain)},n._requestLicense=function(o,t){O.logger.log("Requesting content license for key-system");var e=this._mediaKeysList[0];if(!e){O.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(j.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var i=this.getLicenseServerUrl(e.mediaKeySystemDomain),T=this._createLicenseXhr(i,o,t);O.logger.log("Sending license request to URL: "+i);var _=this._generateLicenseRequestChallenge(e,o);T.send(_)}catch(y){O.logger.error("Failure requesting DRM license: "+y),this.hls.trigger(j.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},n.onMediaAttached=function(o,t){if(!this._emeEnabled)return;var e=t.media;this._media=e,e.addEventListener("encrypted",this._onMediaEncrypted)},n.onMediaDetached=function(){var o=this._media,t=this._mediaKeysList;if(!o)return;o.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(t.map(function(e){if(e.mediaKeysSession)return e.mediaKeysSession.close().catch(function(){})})).then(function(){return o.setMediaKeys(null)}).catch(function(){})},n.onManifestParsed=function(o,t){if(!this._emeEnabled)return;var e=t.levels.map(function(T){return T.audioCodec}).filter(function(T){return!!T}),i=t.levels.map(function(T){return T.videoCodec}).filter(function(T){return!!T});this._attemptKeySystemAccess(B.KeySystems.WIDEVINE,e,i)},A(r,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),r}();G.default=s},"./src/controller/fps-controller.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/events.ts"),I=w("./src/utils/logger.ts"),O=function(){function B(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=B.prototype;return M.setStreamController=function(S){this.streamController=S},M.registerListeners=function(){this.hls.on(j.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},M.unregisterListeners=function(){this.hls.off(j.Events.MEDIA_ATTACHING,this.onMediaAttaching)},M.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},M.onMediaAttaching=function(S,p){var m=this.hls.config;if(m.capLevelOnFPSDrop){var s=p.media instanceof self.HTMLVideoElement?p.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),m.fpsDroppedMonitoringPeriod)}},M.checkFPS=function(S,p,m){var s=performance.now();if(p){if(this.lastTime){var r=s-this.lastTime,n=m-this.lastDroppedFrames,u=p-this.lastDecodedFrames,o=1e3*n/r,t=this.hls;if(t.trigger(j.Events.FPS_DROP,{currentDropped:n,currentDecoded:u,totalDroppedFrames:m}),o>0&&n>t.config.fpsDroppedMonitoringThreshold*u){var e=t.currentLevel;I.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(t.autoLevelCapping===-1||t.autoLevelCapping>=e)&&(e=e-1,t.trigger(j.Events.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:t.currentLevel}),t.autoLevelCapping=e,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=m,this.lastDecodedFrames=p}},M.checkFPSInterval=function(){var S=this.media;if(S)if(this.isVideoPlaybackQualityAvailable){var p=S.getVideoPlaybackQuality();this.checkFPS(S,p.totalVideoFrames,p.droppedVideoFrames)}else this.checkFPS(S,S.webkitDecodedFrameCount,S.webkitDroppedFrameCount)},B}();G.default=O},"./src/controller/fragment-finders.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"findFragmentByPDT",function(){return O}),w.d(G,"findFragmentByPTS",function(){return B}),w.d(G,"fragmentWithinToleranceTest",function(){return M}),w.d(G,"pdtWithinToleranceTest",function(){return A}),w.d(G,"findFragWithCC",function(){return S});var j=w("./src/polyfills/number.ts"),I=w("./src/utils/binary-search.ts");function O(p,m,s){if(m===null||!Array.isArray(p)||!p.length||!Object(j.isFiniteNumber)(m))return null;var r=p[0].programDateTime;if(m<(r||0))return null;var n=p[p.length-1].endProgramDateTime;if(m>=(n||0))return null;s=s||0;for(var u=0;u<p.length;++u){var o=p[u];if(A(m,s,o))return o}return null}function B(p,m,s,r){s===void 0&&(s=0),r===void 0&&(r=0);var n=null;if(p?n=m[p.sn-m[0].sn+1]||null:s===0&&m[0].start===0&&(n=m[0]),n&&M(s,r,n)===0)return n;var u=I.default.search(m,M.bind(null,s,r));return u||n}function M(p,m,s){p===void 0&&(p=0),m===void 0&&(m=0);var r=Math.min(m,s.duration+(s.deltaPTS?s.deltaPTS:0));return s.start+s.duration-r<=p?1:s.start-r>p&&s.start?-1:0}function A(p,m,s){var r=Math.min(m,s.duration+(s.deltaPTS?s.deltaPTS:0))*1e3,n=s.endProgramDateTime||0;return n-r>p}function S(p,m){return I.default.search(p,function(s){return s.cc<m?1:s.cc>m?-1:0})}},"./src/controller/fragment-tracker.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"FragmentState",function(){return O}),w.d(G,"FragmentTracker",function(){return B});var j=w("./src/events.ts"),I=w("./src/types/loader.ts"),O;(function(S){S.NOT_LOADED="NOT_LOADED",S.BACKTRACKED="BACKTRACKED",S.APPENDING="APPENDING",S.PARTIAL="PARTIAL",S.OK="OK"})(O||(O={}));var B=function(){function S(m){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=m,this._registerListeners()}var p=S.prototype;return p._registerListeners=function(){var s=this.hls;s.on(j.Events.BUFFER_APPENDED,this.onBufferAppended,this),s.on(j.Events.FRAG_BUFFERED,this.onFragBuffered,this),s.on(j.Events.FRAG_LOADED,this.onFragLoaded,this)},p._unregisterListeners=function(){var s=this.hls;s.off(j.Events.BUFFER_APPENDED,this.onBufferAppended,this),s.off(j.Events.FRAG_BUFFERED,this.onFragBuffered,this),s.off(j.Events.FRAG_LOADED,this.onFragLoaded,this)},p.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},p.getAppendedFrag=function(s,r){if(r===I.PlaylistLevelType.MAIN){var n=this.activeFragment,u=this.activeParts;if(!n)return null;if(u)for(var o=u.length;o--;){var t=u[o],e=t?t.end:n.appendedPTS;if(t.start<=s&&e!==void 0&&s<=e)return o>9&&(this.activeParts=u.slice(o-9)),t}else if(n.start<=s&&n.appendedPTS!==void 0&&s<=n.appendedPTS)return n}return this.getBufferedFrag(s,r)},p.getBufferedFrag=function(s,r){for(var n=this.fragments,u=Object.keys(n),o=u.length;o--;){var t=n[u[o]];if((t==null?void 0:t.body.type)===r&&t.buffered){var e=t.body;if(e.start<=s&&s<=e.end)return e}}return null},p.detectEvictedFragments=function(s,r,n){var u=this;Object.keys(this.fragments).forEach(function(o){var t=u.fragments[o];if(!t)return;if(!t.buffered){t.body.type===n&&u.removeFragment(t.body);return}var e=t.range[s];if(!e)return;e.time.some(function(i){var T=!u.isTimeBuffered(i.startPTS,i.endPTS,r);return T&&u.removeFragment(t.body),T})})},p.detectPartialFragments=function(s){var r=this,n=this.timeRanges,u=s.frag,o=s.part;if(!n||u.sn==="initSegment")return;var t=A(u),e=this.fragments[t];if(!e)return;Object.keys(n).forEach(function(i){var T=u.elementaryStreams[i];if(!T)return;var _=n[i],y=o!==null||T.partial===!0;e.range[i]=r.getBufferedTimes(u,o,y,_)}),e.backtrack=e.loaded=null,Object.keys(e.range).length?e.buffered=!0:this.removeFragment(e.body)},p.fragBuffered=function(s){var r=A(s),n=this.fragments[r];n&&(n.backtrack=n.loaded=null,n.buffered=!0)},p.getBufferedTimes=function(s,r,n,u){for(var o={time:[],partial:n},t=r?r.start:s.start,e=r?r.end:s.end,i=s.minEndPTS||e,T=s.maxStartPTS||t,_=0;_<u.length;_++){var y=u.start(_)-this.bufferPadding,E=u.end(_)+this.bufferPadding;if(T>=y&&i<=E){o.time.push({startPTS:Math.max(t,u.start(_)),endPTS:Math.min(e,u.end(_))});break}else if(t<E&&e>y)o.partial=!0,o.time.push({startPTS:Math.max(t,u.start(_)),endPTS:Math.min(e,u.end(_))});else if(e<=y)break}return o},p.getPartialFragment=function(s){var r=null,n,u,o,t=0,e=this.bufferPadding,i=this.fragments;return Object.keys(i).forEach(function(T){var _=i[T];if(!_)return;M(_)&&(u=_.body.start-e,o=_.body.end+e,s>=u&&s<=o&&(n=Math.min(s-u,o-s),t<=n&&(r=_.body,t=n)))}),r},p.getState=function(s){var r=A(s),n=this.fragments[r];return n?n.buffered?M(n)?O.PARTIAL:O.OK:n.backtrack?O.BACKTRACKED:O.APPENDING:O.NOT_LOADED},p.backtrack=function(s,r){var n=A(s),u=this.fragments[n];if(!u||u.backtrack)return null;var o=u.backtrack=r||u.loaded;return u.loaded=null,o},p.getBacktrackData=function(s){var r=A(s),n=this.fragments[r];if(n){var u,o=n.backtrack;if(o!=null&&(u=o.payload)!==null&&u!==void 0&&u.byteLength)return o;this.removeFragment(s)}return null},p.isTimeBuffered=function(s,r,n){for(var u,o,t=0;t<n.length;t++){if(u=n.start(t)-this.bufferPadding,o=n.end(t)+this.bufferPadding,s>=u&&r<=o)return!0;if(r<=u)return!1}return!1},p.onFragLoaded=function(s,r){var n=r.frag,u=r.part;if(n.sn==="initSegment"||n.bitrateTest||u)return;var o=A(n);this.fragments[o]={body:n,loaded:r,backtrack:null,buffered:!1,range:Object.create(null)}},p.onBufferAppended=function(s,r){var n=this,u=r.frag,o=r.part,t=r.timeRanges;if(u.type===I.PlaylistLevelType.MAIN)if(this.activeFragment=u,o){var e=this.activeParts;e||(this.activeParts=e=[]),e.push(o)}else this.activeParts=null;this.timeRanges=t,Object.keys(t).forEach(function(i){var T=t[i];if(n.detectEvictedFragments(i,T),!o)for(var _=0;_<T.length;_++)u.appendedPTS=Math.max(T.end(_),u.appendedPTS||0)})},p.onFragBuffered=function(s,r){this.detectPartialFragments(r)},p.hasFragment=function(s){var r=A(s);return!!this.fragments[r]},p.removeFragmentsInRange=function(s,r,n){var u=this;Object.keys(this.fragments).forEach(function(o){var t=u.fragments[o];if(!t)return;if(t.buffered){var e=t.body;e.type===n&&e.start<r&&e.end>s&&u.removeFragment(e)}})},p.removeFragment=function(s){var r=A(s);s.stats.loaded=0,s.clearElementaryStreamInfo(),delete this.fragments[r]},p.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},S}();function M(S){var p,m;return S.buffered&&(((p=S.range.video)===null||p===void 0?void 0:p.partial)||((m=S.range.audio)===null||m===void 0?void 0:m.partial))}function A(S){return S.type+"_"+S.level+"_"+S.urlId+"_"+S.sn}},"./src/controller/gap-controller.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"STALL_MINIMUM_DURATION_MS",function(){return M}),w.d(G,"MAX_START_GAP_JUMP",function(){return A}),w.d(G,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return S}),w.d(G,"SKIP_BUFFER_RANGE_START",function(){return p}),w.d(G,"default",function(){return m});var j=w("./src/utils/buffer-helper.ts"),I=w("./src/errors.ts"),O=w("./src/events.ts"),B=w("./src/utils/logger.ts"),M=250,A=2,S=.1,p=.05,m=function(){function s(n,u,o,t){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=n,this.media=u,this.fragmentTracker=o,this.hls=t}var r=s.prototype;return r.destroy=function(){this.hls=this.fragmentTracker=this.media=null},r.poll=function(u){var o=this.config,t=this.media,e=this.stalled,i=t.currentTime,T=t.seeking,_=this.seeking&&!T,y=!this.seeking&&T;if(this.seeking=T,i!==u){if(this.moved=!0,e!==null){if(this.stallReported){var E=self.performance.now()-e;B.logger.warn("playback not stuck anymore @"+i+", after "+Math.round(E)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((y||_)&&(this.stalled=null),t.paused||t.ended||t.playbackRate===0||!j.BufferHelper.getBuffered(t).length)return;var b=j.BufferHelper.bufferInfo(t,i,0),g=b.len>0,d=b.nextStart||0;if(!g&&!d)return;if(T){var a=b.len>A,l=!d||d-i>A&&!this.fragmentTracker.getPartialFragment(i);if(a||l)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var f,c=Math.max(d,b.start||0)-i,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,R=x==null||((f=x.details)===null||f===void 0)?void 0:f.live,C=R?x.details.targetduration*2:A;if(c>0&&c<=C){this._trySkipBufferHole(null);return}}var N=self.performance.now();if(e===null){this.stalled=N;return}var U=N-e;!T&&U>=M&&this._reportStall(b.len);var W=j.BufferHelper.bufferInfo(t,i,o.maxBufferHole);this._tryFixBufferStall(W,U)},r._tryFixBufferStall=function(u,o){var t=this.config,e=this.fragmentTracker,i=this.media,T=i.currentTime,_=e.getPartialFragment(T);if(_){var y=this._trySkipBufferHole(_);if(y)return}u.len>t.maxBufferHole&&o>t.highBufferWatchdogPeriod*1e3&&(B.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},r._reportStall=function(u){var o=this.hls,t=this.media,e=this.stallReported;e||(this.stallReported=!0,B.logger.warn("Playback stalling at @"+t.currentTime+" due to low buffer (buffer="+u+")"),o.trigger(O.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:u}))},r._trySkipBufferHole=function(u){for(var o=this.config,t=this.hls,e=this.media,i=e.currentTime,T=0,_=j.BufferHelper.getBuffered(e),y=0;y<_.length;y++){var E=_.start(y);if(i+o.maxBufferHole>=T&&i<E){var b=Math.max(E+p,e.currentTime+S);return B.logger.warn("skipping hole, adjusting currentTime from "+i+" to "+b),this.moved=!0,this.stalled=null,e.currentTime=b,u&&t.trigger(O.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+i+" to "+b,frag:u}),b}T=_.end(y)}return 0},r._tryNudgeBuffer=function(){var u=this.config,o=this.hls,t=this.media,e=t.currentTime,i=(this.nudgeRetry||0)+1;if(this.nudgeRetry=i,i<u.nudgeMaxRetry){var T=e+i*u.nudgeOffset;B.logger.warn("Nudging 'currentTime' from "+e+" to "+T),t.currentTime=T,o.trigger(O.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else B.logger.error("Playhead still not moving while enough data buffered @"+e+" after "+u.nudgeMaxRetry+" nudges"),o.trigger(O.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},s}()},"./src/controller/id3-track-controller.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/events.ts"),I=w("./src/utils/texttrack-utils.ts"),O=w("./src/demux/id3.ts"),B=.25,M=function(){function A(p){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=p,this._registerListeners()}var S=A.prototype;return S.destroy=function(){this._unregisterListeners()},S._registerListeners=function(){var m=this.hls;m.on(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),m.on(j.Events.MEDIA_DETACHING,this.onMediaDetaching,this),m.on(j.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),m.on(j.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},S._unregisterListeners=function(){var m=this.hls;m.off(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),m.off(j.Events.MEDIA_DETACHING,this.onMediaDetaching,this),m.off(j.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),m.off(j.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},S.onMediaAttached=function(m,s){this.media=s.media},S.onMediaDetaching=function(){if(!this.id3Track)return;Object(I.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},S.getID3Track=function(m){if(!this.media)return;for(var s=0;s<m.length;s++){var r=m[s];if(r.kind==="metadata"&&r.label==="id3")return Object(I.sendAddTrackEvent)(r,this.media),r}return this.media.addTextTrack("metadata","id3")},S.onFragParsingMetadata=function(m,s){if(!this.media)return;var r=s.frag,n=s.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var u=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,o=0;o<n.length;o++){var t=O.getID3Frames(n[o].data);if(t){var e=n[o].pts,i=o<n.length-1?n[o+1].pts:r.end,T=i-e;T<=0&&(i=e+B);for(var _=0;_<t.length;_++){var y=t[_];if(!O.isTimeStampFrame(y)){var E=new u(e,i,"");E.value=y,this.id3Track.addCue(E)}}}}},S.onBufferFlushing=function(m,s){var r=s.startOffset,n=s.endOffset,u=s.type;if(!u||u==="audio"){var o=this.id3Track;o&&Object(I.removeCuesInRange)(o,r,n)}},A}();G.default=M},"./src/controller/latency-controller.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return A});var j=w("./src/errors.ts"),I=w("./src/events.ts"),O=w("./src/utils/logger.ts");function B(S,p){for(var m=0;m<p.length;m++){var s=p[m];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(S,s.key,s)}}function M(S,p,m){return p&&B(S.prototype,p),m&&B(S,m),S}var A=function(){function S(m){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=m,this.config=m.config,this.registerListeners()}var p=S.prototype;return p.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},p.registerListeners=function(){this.hls.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(I.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(I.Events.ERROR,this.onError,this)},p.unregisterListeners=function(){this.hls.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(I.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(I.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(I.Events.ERROR,this.onError)},p.onMediaAttached=function(s,r){this.media=r.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},p.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},p.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},p.onLevelUpdated=function(s,r){var n=r.details;this.levelDetails=n,n.advanced&&this.timeupdate(),!n.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},p.onError=function(s,r){if(r.details!==j.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,O.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},p.timeupdate=function(){var s=this.media,r=this.levelDetails;if(!s||!r)return;this.currentTime=s.currentTime;var n=this.computeLatency();if(n===null)return;this._latency=n;var u=this.config,o=u.lowLatencyMode,t=u.maxLiveSyncPlaybackRate;if(!o||t===1)return;var e=this.targetLatency;if(e===null)return;var i=n-e,T=Math.min(this.maxLatency,e+r.targetduration),_=i<T;if(r.live&&_&&i>.05&&this.forwardBufferLength>1){var y=Math.min(2,Math.max(1,t)),E=Math.round(2/(1+Math.exp(-.75*i-this.edgeStalled))*20)/20;s.playbackRate=Math.min(y,Math.max(1,E))}else s.playbackRate!==1&&s.playbackRate!==0&&(s.playbackRate=1)},p.estimateLiveEdge=function(){var s=this.levelDetails;return s===null?null:s.edge+s.age},p.computeLatency=function(){var s=this.estimateLiveEdge();return s===null?null:s-this.currentTime},M(S,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var s=this.config,r=this.levelDetails;return s.liveMaxLatencyDuration!==void 0?s.liveMaxLatencyDuration:r?s.liveMaxLatencyDurationCount*r.targetduration:0}},{key:"targetLatency",get:function(){var s=this.levelDetails;if(s===null)return null;var r=s.holdBack,n=s.partHoldBack,u=s.targetduration,o=this.config,t=o.liveSyncDuration,e=o.liveSyncDurationCount,i=o.lowLatencyMode,T=this.hls.userConfig,_=i&&n||r;(T.liveSyncDuration||T.liveSyncDurationCount||_===0)&&(_=t!==void 0?t:e*u);var y=u,E=1;return _+Math.min(this.stallCount*E,y)}},{key:"liveSyncPosition",get:function(){var s=this.estimateLiveEdge(),r=this.targetLatency,n=this.levelDetails;if(s===null||r===null||n===null)return null;var u=n.edge,o=s-r-this.edgeStalled,t=u-n.totalduration,e=u-(this.config.lowLatencyMode&&n.partTarget||n.targetduration);return Math.min(Math.max(t,o),e)}},{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 r=(this.config.lowLatencyMode&&s.partTarget||s.targetduration)*3;return Math.max(s.age-r,0)}},{key:"forwardBufferLength",get:function(){var s=this.media,r=this.levelDetails;if(!s||!r)return 0;var n=s.buffered.length;return n?s.buffered.end(n-1):r.edge-this.currentTime}}]),S}()},"./src/controller/level-controller.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return o});var j=w("./src/types/level.ts"),I=w("./src/events.ts"),O=w("./src/errors.ts"),B=w("./src/utils/codecs.ts"),M=w("./src/controller/level-helper.ts"),A=w("./src/controller/base-playlist-controller.ts"),S=w("./src/types/loader.ts");function p(){return p=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var T in i)Object.prototype.hasOwnProperty.call(i,T)&&(t[T]=i[T])}return t},p.apply(this,arguments)}function m(t,e){for(var i=0;i<e.length;i++){var T=e[i];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(t,T.key,T)}}function s(t,e,i){return e&&m(t.prototype,e),i&&m(t,i),t}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,n(t,e)}function n(t,e){return n=Object.setPrototypeOf||function(T,_){return T.__proto__=_,T},n(t,e)}var u=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),o=function(t){r(e,t);function e(T){var _;return _=t.call(this,T,"[level-controller]")||this,_._levels=[],_._firstLevel=-1,_._startLevel=void 0,_.currentLevelIndex=-1,_.manualLevelIndex=-1,_.onParsedComplete=void 0,_._registerListeners(),_}var i=e.prototype;return i._registerListeners=function(){var _=this.hls;_.on(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),_.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),_.on(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),_.on(I.Events.FRAG_LOADED,this.onFragLoaded,this),_.on(I.Events.ERROR,this.onError,this)},i._unregisterListeners=function(){var _=this.hls;_.off(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),_.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),_.off(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),_.off(I.Events.FRAG_LOADED,this.onFragLoaded,this),_.off(I.Events.ERROR,this.onError,this)},i.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,t.prototype.destroy.call(this)},i.startLoad=function(){var _=this._levels;_.forEach(function(y){y.loadError=0}),t.prototype.startLoad.call(this)},i.onManifestLoaded=function(_,y){var E=[],b=[],g=[],d,a={},l,f=!1,c=!1,x=!1;if(y.levels.forEach(function(U){var W=U.attrs;f=f||!!(U.width&&U.height),c=c||!!U.videoCodec,x=x||!!U.audioCodec,u&&U.audioCodec&&U.audioCodec.indexOf("mp4a.40.34")!==-1&&(U.audioCodec=void 0);var L=U.bitrate+"-"+U.attrs.RESOLUTION+"-"+U.attrs.CODECS;l=a[L],l?l.url.push(U.url):(l=new j.Level(U),a[L]=l,E.push(l)),W&&(W.AUDIO&&Object(M.addGroupId)(l,"audio",W.AUDIO),W.SUBTITLES&&Object(M.addGroupId)(l,"text",W.SUBTITLES))}),(f||c)&&x&&(E=E.filter(function(U){var W=U.videoCodec,L=U.width,H=U.height;return!!W||!!(L&&H)})),E=E.filter(function(U){var W=U.audioCodec,L=U.videoCodec;return(!W||Object(B.isCodecSupportedInMp4)(W,"audio"))&&(!L||Object(B.isCodecSupportedInMp4)(L,"video"))}),y.audioTracks&&(b=y.audioTracks.filter(function(U){return!U.audioCodec||Object(B.isCodecSupportedInMp4)(U.audioCodec,"audio")}),Object(M.assignTrackIdsByGroup)(b)),y.subtitles&&(g=y.subtitles,Object(M.assignTrackIdsByGroup)(g)),E.length>0){d=E[0].bitrate,E.sort(function(U,W){return U.bitrate-W.bitrate}),this._levels=E;for(var R=0;R<E.length;R++)if(E[R].bitrate===d){this._firstLevel=R,this.log("manifest loaded, "+E.length+" level(s) found, first bitrate: "+d);break}var C=x&&!c,N={levels:E,audioTracks:b,subtitleTracks:g,firstLevel:this._firstLevel,stats:y.stats,audio:x,video:c,altAudio:!C&&b.some(function(U){return!!U.url})};this.hls.trigger(I.Events.MANIFEST_PARSED,N),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(I.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:y.url,reason:"no level with compatible codecs found in manifest"})},i.onError=function(_,y){if(t.prototype.onError.call(this,_,y),y.fatal)return;var E=y.context,b=this._levels[this.currentLevelIndex];if(E&&(E.type===S.PlaylistContextType.AUDIO_TRACK&&b.audioGroupIds&&E.groupId===b.audioGroupIds[b.urlId]||E.type===S.PlaylistContextType.SUBTITLE_TRACK&&b.textGroupIds&&E.groupId===b.textGroupIds[b.urlId])){this.redundantFailover(this.currentLevelIndex);return}var g=!1,d=!0,a;switch(y.details){case O.ErrorDetails.FRAG_LOAD_ERROR:case O.ErrorDetails.FRAG_LOAD_TIMEOUT:case O.ErrorDetails.KEY_LOAD_ERROR:case O.ErrorDetails.KEY_LOAD_TIMEOUT:if(y.frag){var l=this._levels[y.frag.level];l?(l.fragmentError++,l.fragmentError>this.hls.config.fragLoadingMaxRetry&&(a=y.frag.level)):a=y.frag.level}break;case O.ErrorDetails.LEVEL_LOAD_ERROR:case O.ErrorDetails.LEVEL_LOAD_TIMEOUT:E&&(E.deliveryDirectives&&(d=!1),a=E.level),g=!0;break;case O.ErrorDetails.REMUX_ALLOC_ERROR:a=y.level,g=!0;break}a!==void 0&&this.recoverLevel(y,a,g,d)},i.recoverLevel=function(_,y,E,b){var g=_.details,d=this._levels[y];if(d.loadError++,E){var a=this.retryLoadingOrFail(_);if(a)_.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(b){var l=d.url.length;if(l>1&&d.loadError<l)_.levelRetry=!0,this.redundantFailover(y);else if(this.manualLevelIndex===-1){var f=y===0?this._levels.length-1:y-1;this.currentLevelIndex!==f&&this._levels[f].loadError===0&&(this.warn(g+": switch to "+f),_.levelRetry=!0,this.hls.nextAutoLevel=f)}}},i.redundantFailover=function(_){var y=this._levels[_],E=y.url.length;if(E>1){var b=(y.urlId+1)%E;this.warn("Switching to redundant URL-id "+b),this._levels.forEach(function(g){g.urlId=b}),this.level=_}},i.onFragLoaded=function(_,y){var E=y.frag;if(E!==void 0&&E.type===S.PlaylistLevelType.MAIN){var b=this._levels[E.level];b!==void 0&&(b.fragmentError=0,b.loadError=0)}},i.onLevelLoaded=function(_,y){var E,b=y.level,g=y.details,d=this._levels[b];if(!d){var a;this.warn("Invalid level index "+b),(a=y.deliveryDirectives)!==null&&a!==void 0&&a.skip&&(g.deltaUpdateFailed=!0);return}b===this.currentLevelIndex?(d.fragmentError===0&&(d.loadError=0,this.retryCount=0),this.playlistLoaded(b,y,d.details)):(E=y.deliveryDirectives)!==null&&E!==void 0&&E.skip&&(g.deltaUpdateFailed=!0)},i.onAudioTrackSwitched=function(_,y){var E=this.hls.levels[this.currentLevelIndex];if(!E)return;if(E.audioGroupIds){for(var b=-1,g=this.hls.audioTracks[y.id].groupId,d=0;d<E.audioGroupIds.length;d++)if(E.audioGroupIds[d]===g){b=d;break}b!==E.urlId&&(E.urlId=b,this.startLoad())}},i.loadPlaylist=function(_){var y=this.currentLevelIndex,E=this._levels[y];if(this.canLoad&&E&&E.url.length>0){var b=E.urlId,g=E.url[b];if(_)try{g=_.addDirectives(g)}catch(d){this.warn("Could not construct new URL with HLS Delivery Directives: "+d)}this.log("Attempt loading level index "+y+(_?" at sn "+_.msn+" part "+_.part:"")+" with URL-id "+b+" "+g),this.clearTimer(),this.hls.trigger(I.Events.LEVEL_LOADING,{url:g,level:y,id:b,deliveryDirectives:_||null})}},i.removeLevel=function(_,y){var E=function(d,a){return a!==y},b=this._levels.filter(function(g,d){return d!==_?!0:g.url.length>1&&y!==void 0?(g.url=g.url.filter(E),g.audioGroupIds&&(g.audioGroupIds=g.audioGroupIds.filter(E)),g.textGroupIds&&(g.textGroupIds=g.textGroupIds.filter(E)),g.urlId=0,!0):!1}).map(function(g,d){var a=g.details;return a!=null&&a.fragments&&a.fragments.forEach(function(l){l.level=d}),g});this._levels=b,this.hls.trigger(I.Events.LEVELS_UPDATED,{levels:b})},s(e,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(_){var y,E=this._levels;if(E.length===0)return;if(this.currentLevelIndex===_&&(y=E[_])!==null&&y!==void 0&&y.details)return;if(_<0||_>=E.length){var b=_<0;if(this.hls.trigger(I.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.LEVEL_SWITCH_ERROR,level:_,fatal:b,reason:"invalid level idx"}),b)return;_=Math.min(_,E.length-1)}this.clearTimer();var g=this.currentLevelIndex,d=E[g],a=E[_];this.log("switching to level "+_+" from "+g),this.currentLevelIndex=_;var l=p({},a,{level:_,maxBitrate:a.maxBitrate,uri:a.uri,urlId:a.urlId});delete l._urlId,this.hls.trigger(I.Events.LEVEL_SWITCHING,l);var f=a.details;if(!f||f.live){var c=this.switchParams(a.uri,d==null?void 0:d.details);this.loadPlaylist(c)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(_){this.manualLevelIndex=_,this._startLevel===void 0&&(this._startLevel=_),_!==-1&&(this.level=_)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(_){this._firstLevel=_}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var _=this.hls.config.startLevel;return _!==void 0?_:this._firstLevel}else return this._startLevel},set:function(_){this._startLevel=_}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(_){this.level=_,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=_)}}]),e}(A.default)},"./src/controller/level-helper.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"addGroupId",function(){return O}),w.d(G,"assignTrackIdsByGroup",function(){return B}),w.d(G,"updatePTS",function(){return M}),w.d(G,"updateFragPTSDTS",function(){return S}),w.d(G,"mergeDetails",function(){return p}),w.d(G,"mapPartIntersection",function(){return m}),w.d(G,"mapFragmentIntersection",function(){return s}),w.d(G,"adjustSliding",function(){return r}),w.d(G,"addSliding",function(){return n}),w.d(G,"computeReloadInterval",function(){return u}),w.d(G,"getFragmentWithSN",function(){return o}),w.d(G,"getPartWith",function(){return t});var j=w("./src/polyfills/number.ts"),I=w("./src/utils/logger.ts");function O(e,i,T){switch(i){case"audio":e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds.push(T);break;case"text":e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds.push(T);break}}function B(e){var i={};e.forEach(function(T){var _=T.groupId||"";T.id=i[_]=i[_]||0,i[_]++})}function M(e,i,T){var _=e[i],y=e[T];A(_,y)}function A(e,i){var T=i.startPTS;if(Object(j.isFiniteNumber)(T)){var _=0,y;i.sn>e.sn?(_=T-e.start,y=e):(_=e.start-T,y=i),y.duration!==_&&(y.duration=_)}else if(i.sn>e.sn){var E=e.cc===i.cc;E&&e.minEndPTS?i.start=e.start+(e.minEndPTS-e.start):i.start=e.start+e.duration}else i.start=Math.max(e.start-i.duration,0)}function S(e,i,T,_,y,E){var b=_-T;b<=0&&(I.logger.warn("Fragment should have a positive duration",i),_=T+i.duration,E=y+i.duration);var g=T,d=_,a=i.startPTS,l=i.endPTS;if(Object(j.isFiniteNumber)(a)){var f=Math.abs(a-T);Object(j.isFiniteNumber)(i.deltaPTS)?i.deltaPTS=Math.max(f,i.deltaPTS):i.deltaPTS=f,g=Math.max(T,a),T=Math.min(T,a),y=Math.min(y,i.startDTS),d=Math.min(_,l),_=Math.max(_,l),E=Math.max(E,i.endDTS)}i.duration=_-T;var c=T-i.start;i.appendedPTS=_,i.start=i.startPTS=T,i.maxStartPTS=g,i.startDTS=y,i.endPTS=_,i.minEndPTS=d,i.endDTS=E;var x=i.sn;if(!e||x<e.startSN||x>e.endSN)return 0;var R,C=x-e.startSN,N=e.fragments;for(N[C]=i,R=C;R>0;R--)A(N[R],N[R-1]);for(R=C;R<N.length-1;R++)A(N[R],N[R+1]);return e.fragmentHint&&A(N[N.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,c}function p(e,i){for(var T=null,_=e.fragments,y=_.length-1;y>=0;y--){var E=_[y].initSegment;if(E){T=E;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var b=0,g;if(s(e,i,function(R,C){R.relurl&&(b=R.cc-C.cc),Object(j.isFiniteNumber)(R.startPTS)&&Object(j.isFiniteNumber)(R.endPTS)&&(C.start=C.startPTS=R.startPTS,C.startDTS=R.startDTS,C.appendedPTS=R.appendedPTS,C.maxStartPTS=R.maxStartPTS,C.endPTS=R.endPTS,C.endDTS=R.endDTS,C.minEndPTS=R.minEndPTS,C.duration=R.endPTS-R.startPTS,C.duration&&(g=C),i.PTSKnown=i.alignedSliding=!0),C.elementaryStreams=R.elementaryStreams,C.loader=R.loader,C.stats=R.stats,C.urlId=R.urlId,R.initSegment&&(C.initSegment=R.initSegment,T=R.initSegment)}),T){var d=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;d.forEach(function(R){var C;(!R.initSegment||R.initSegment.relurl===((C=T)===null||C===void 0?void 0:C.relurl))&&(R.initSegment=T)})}if(i.skippedSegments&&(i.deltaUpdateFailed=i.fragments.some(function(R){return!R}),i.deltaUpdateFailed)){I.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var a=i.skippedSegments;a--;)i.fragments.shift();i.startSN=i.fragments[0].sn,i.startCC=i.fragments[0].cc}var l=i.fragments;if(b){I.logger.warn("discontinuity sliding from playlist, take drift into account");for(var f=0;f<l.length;f++)l[f].cc+=b}i.skippedSegments&&(i.startCC=i.fragments[0].cc),m(e.partList,i.partList,function(R,C){C.elementaryStreams=R.elementaryStreams,C.stats=R.stats}),g?S(i,g,g.startPTS,g.endPTS,g.startDTS,g.endDTS):r(e,i),l.length&&(i.totalduration=i.edge-l[0].start),i.driftStartTime=e.driftStartTime,i.driftStart=e.driftStart;var c=i.advancedDateTime;if(i.advanced&&c){var x=i.edge;i.driftStart||(i.driftStartTime=c,i.driftStart=x),i.driftEndTime=c,i.driftEnd=x}else i.driftEndTime=e.driftEndTime,i.driftEnd=e.driftEnd,i.advancedDateTime=e.advancedDateTime}function m(e,i,T){if(e&&i)for(var _=0,y=0,E=e.length;y<=E;y++){var b=e[y],g=i[y+_];b&&g&&b.index===g.index&&b.fragment.sn===g.fragment.sn?T(b,g):_--}}function s(e,i,T){for(var _=i.skippedSegments,y=Math.max(e.startSN,i.startSN)-i.startSN,E=(e.fragmentHint?1:0)+(_?i.endSN:Math.min(e.endSN,i.endSN))-i.startSN,b=i.startSN-e.startSN,g=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,d=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,a=y;a<=E;a++){var l=d[b+a],f=g[a];_&&!f&&a<_&&(f=i.fragments[a]=l),l&&f&&T(l,f)}}function r(e,i){var T=i.startSN+i.skippedSegments-e.startSN,_=e.fragments;if(T<0||T>=_.length)return;n(i,_[T].start)}function n(e,i){if(i){for(var T=e.fragments,_=e.skippedSegments;_<T.length;_++)T[_].start+=i;e.fragmentHint&&(e.fragmentHint.start+=i)}}function u(e,i){var T=1e3*e.levelTargetDuration,_=T/2,y=e.age,E=y>0&&y<T*3,b=i.loading.end-i.loading.start,g,d=e.availabilityDelay;if(e.updated===!1)if(E){var a=333*e.misses;g=Math.max(Math.min(_,b*2),a),e.availabilityDelay=(e.availabilityDelay||0)+g}else g=_;else E?(d=Math.min(d||T/2,y),e.availabilityDelay=d,g=d+T-y):g=T-b;return Math.round(g)}function o(e,i,T){if(!e||!e.details)return null;var _=e.details,y=_.fragments[i-_.startSN];return y||(y=_.fragmentHint,y&&y.sn===i?y:i<_.startSN&&T&&T.sn===i?T:null)}function t(e,i,T){if(!e||!e.details)return null;var _=e.details.partList;if(_)for(var y=_.length;y--;){var E=_[y];if(E.index===T&&E.fragment.sn===i)return E}return null}},"./src/controller/stream-controller.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return _});var j=w("./src/polyfills/number.ts"),I=w("./src/controller/base-stream-controller.ts"),O=w("./src/is-supported.ts"),B=w("./src/events.ts"),M=w("./src/utils/buffer-helper.ts"),A=w("./src/controller/fragment-tracker.ts"),S=w("./src/types/loader.ts"),p=w("./src/loader/fragment.ts"),m=w("./src/demux/transmuxer-interface.ts"),s=w("./src/types/transmuxer.ts"),r=w("./src/controller/gap-controller.ts"),n=w("./src/errors.ts"),u=w("./src/utils/logger.ts");function o(y,E){for(var b=0;b<E.length;b++){var g=E[b];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(y,g.key,g)}}function t(y,E,b){return E&&o(y.prototype,E),b&&o(y,b),y}function e(y,E){y.prototype=Object.create(E.prototype),y.prototype.constructor=y,i(y,E)}function i(y,E){return i=Object.setPrototypeOf||function(g,d){return g.__proto__=d,g},i(y,E)}var T=100,_=function(y){e(E,y);function E(g,d){var a;return a=y.call(this,g,d,"[stream-controller]")||this,a.audioCodecSwap=!1,a.gapController=null,a.level=-1,a._forceStartLoad=!1,a.altAudio=!1,a.audioOnly=!1,a.fragPlaying=null,a.onvplaying=null,a.onvseeked=null,a.fragLastKbps=0,a.stalled=!1,a.couldBacktrack=!1,a.audioCodecSwitch=!1,a.videoBuffer=null,a._registerListeners(),a}var b=E.prototype;return b._registerListeners=function(){var d=this.hls;d.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.on(B.Events.LEVEL_LOADING,this.onLevelLoading,this),d.on(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(B.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),d.on(B.Events.ERROR,this.onError,this),d.on(B.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.on(B.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),d.on(B.Events.BUFFER_CREATED,this.onBufferCreated,this),d.on(B.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.on(B.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),d.on(B.Events.FRAG_BUFFERED,this.onFragBuffered,this)},b._unregisterListeners=function(){var d=this.hls;d.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.off(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(B.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),d.off(B.Events.ERROR,this.onError,this),d.off(B.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.off(B.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),d.off(B.Events.BUFFER_CREATED,this.onBufferCreated,this),d.off(B.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.off(B.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),d.off(B.Events.FRAG_BUFFERED,this.onFragBuffered,this)},b.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},b.startLoad=function(d){if(this.levels){var a=this.lastCurrentTime,l=this.hls;if(this.stopLoad(),this.setInterval(T),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var f=l.startLevel;f===-1&&(l.config.testBandwidth?(f=0,this.bitrateTest=!0):f=l.nextAutoLevel),this.level=l.nextLoadLevel=f,this.loadedmetadata=!1}a>0&&d===-1&&(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),d=a),this.state=I.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=d,this.tick()}else this._forceStartLoad=!0,this.state=I.State.STOPPED},b.stopLoad=function(){this._forceStartLoad=!1,y.prototype.stopLoad.call(this)},b.doTick=function(){switch(this.state){case I.State.IDLE:this.doTickIdle();break;case I.State.WAITING_LEVEL:{var d,a=this.levels,l=this.level,f=a==null||((d=a[l])===null||d===void 0)?void 0:d.details;if(f&&(!f.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(f))break;this.state=I.State.IDLE;break}break}case I.State.FRAG_LOADING_WAITING_RETRY:{var c,x=self.performance.now(),R=this.retryDate;(!R||x>=R||(c=this.media)!==null&&c!==void 0&&c.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=I.State.IDLE)}break;default:break}this.onTickEnd()},b.onTickEnd=function(){y.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},b.doTickIdle=function(){var d,a,l=this.hls,f=this.levelLastLoaded,c=this.levels,x=this.media,R=l.config,C=l.nextLoadLevel;if(f===null||!x&&(this.startFragRequested||!R.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!c||!c[C])return;var N=c[C];this.level=l.nextLoadLevel=C;var U=N.details;if(!U||this.state===I.State.WAITING_LEVEL||U.live&&this.levelLastLoaded!==C){this.state=I.State.WAITING_LEVEL;return}var W=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:x,S.PlaylistLevelType.MAIN);if(W===null)return;var L=W.len,H=this.getMaxBufferLength(N.maxBitrate);if(L>=H)return;if(this._streamEnded(W,U)){var K={};this.altAudio&&(K.type="video"),this.hls.trigger(B.Events.BUFFER_EOS,K),this.state=I.State.ENDED;return}var $=W.end,Q=this.getNextFragment($,U);if(this.couldBacktrack&&!this.fragPrevious&&Q&&Q.sn!=="initSegment"){var ue=Q.sn-U.startSN;ue>1&&(Q=U.fragments[ue-1],this.fragmentTracker.removeFragment(Q))}if(Q&&this.fragmentTracker.getState(Q)===A.FragmentState.OK&&this.nextLoadPosition>$){var ne=this.audioOnly&&!this.altAudio?p.ElementaryStreamTypes.AUDIO:p.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(x,ne,S.PlaylistLevelType.MAIN),Q=this.getNextFragment(this.nextLoadPosition,U)}if(!Q)return;Q.initSegment&&!Q.initSegment.data&&!this.bitrateTest&&(Q=Q.initSegment),((d=Q.decryptdata)===null||d===void 0?void 0:d.keyFormat)==="identity"&&!((a=Q.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(Q,U):this.loadFragment(Q,U,$)},b.loadFragment=function(d,a,l){var f,c=this.fragmentTracker.getState(d);if(this.fragCurrent=d,c===A.FragmentState.BACKTRACKED){var x=this.fragmentTracker.getBacktrackData(d);if(x){this._handleFragmentLoadProgress(x),this._handleFragmentLoadComplete(x);return}else c=A.FragmentState.NOT_LOADED}c===A.FragmentState.NOT_LOADED||c===A.FragmentState.PARTIAL?d.sn==="initSegment"?this._loadInitSegment(d):this.bitrateTest?(d.bitrateTest=!0,this.log("Fragment "+d.sn+" of level "+d.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(d)):(this.startFragRequested=!0,y.prototype.loadFragment.call(this,d,a,l)):c===A.FragmentState.APPENDING?this.reduceMaxBufferLength(d.duration)&&this.fragmentTracker.removeFragment(d):((f=this.media)===null||f===void 0?void 0:f.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},b.getAppendedFrag=function(d){var a=this.fragmentTracker.getAppendedFrag(d,S.PlaylistLevelType.MAIN);return a&&"fragment"in a?a.fragment:a},b.getBufferedFrag=function(d){return this.fragmentTracker.getBufferedFrag(d,S.PlaylistLevelType.MAIN)},b.followingBufferedFrag=function(d){return d?this.getBufferedFrag(d.end+.5):null},b.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},b.nextLevelSwitch=function(){var d=this.levels,a=this.media;if(a!=null&&a.readyState){var l,f=this.getAppendedFrag(a.currentTime);if(f&&f.start>1&&this.flushMainBuffer(0,f.start-1),!a.paused&&d){var c=this.hls.nextLoadLevel,x=d[c],R=this.fragLastKbps;R&&this.fragCurrent?l=this.fragCurrent.duration*x.maxBitrate/(1e3*R)+1:l=0}else l=0;var C=this.getBufferedFrag(a.currentTime+l);if(C){var N=this.followingBufferedFrag(C);if(N){this.abortCurrentFrag();var U=N.maxStartPTS?N.maxStartPTS:N.start,W=N.duration,L=Math.max(C.end,U+Math.min(Math.max(W-this.config.maxFragLookUpTolerance,W*.5),W*.75));this.flushMainBuffer(L,Number.POSITIVE_INFINITY)}}}},b.abortCurrentFrag=function(){var d=this.fragCurrent;this.fragCurrent=null,d!=null&&d.loader&&d.loader.abort(),this.state===I.State.KEY_LOADING&&(this.state=I.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},b.flushMainBuffer=function(d,a){y.prototype.flushMainBuffer.call(this,d,a,this.altAudio?"video":null)},b.onMediaAttached=function(d,a){y.prototype.onMediaAttached.call(this,d,a);var l=a.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),l.addEventListener("playing",this.onvplaying),l.addEventListener("seeked",this.onvseeked),this.gapController=new r.default(this.config,l,this.fragmentTracker,this.hls)},b.onMediaDetaching=function(){var d=this.media;d&&(d.removeEventListener("playing",this.onvplaying),d.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),y.prototype.onMediaDetaching.call(this)},b.onMediaPlaying=function(){this.tick()},b.onMediaSeeked=function(){var d=this.media,a=d?d.currentTime:null;Object(j.isFiniteNumber)(a)&&this.log("Media seeked to "+a.toFixed(3)),this.tick()},b.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(B.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},b.onManifestParsed=function(d,a){var l=!1,f=!1,c;a.levels.forEach(function(x){c=x.audioCodec,c&&(c.indexOf("mp4a.40.2")!==-1&&(l=!0),c.indexOf("mp4a.40.5")!==-1&&(f=!0))}),this.audioCodecSwitch=l&&f&&!Object(O.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=a.levels,this.startFragRequested=!1},b.onLevelLoading=function(d,a){var l=this.levels;if(!l||this.state!==I.State.IDLE)return;var f=l[a.level];(!f.details||f.details.live&&this.levelLastLoaded!==a.level||this.waitForCdnTuneIn(f.details))&&(this.state=I.State.WAITING_LEVEL)},b.onLevelLoaded=function(d,a){var l,f=this.levels,c=a.level,x=a.details,R=x.totalduration;if(!f){this.warn("Levels were reset while loading level "+c);return}this.log("Level "+c+" loaded ["+x.startSN+","+x.endSN+"], cc ["+x.startCC+", "+x.endCC+"] duration:"+R);var C=this.fragCurrent;C&&(this.state===I.State.FRAG_LOADING||this.state===I.State.FRAG_LOADING_WAITING_RETRY)&&(C.level!==a.level&&C.loader&&(this.state=I.State.IDLE,C.loader.abort()));var N=f[c],U=0;if(x.live||(l=N.details)!==null&&l!==void 0&&l.live){if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed)return;U=this.alignPlaylists(x,N.details)}if(N.details=x,this.levelLastLoaded=c,this.hls.trigger(B.Events.LEVEL_UPDATED,{details:x,level:c}),this.state===I.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(x))return;this.state=I.State.IDLE}this.startFragRequested?x.live&&this.synchronizeToLiveEdge(x):this.setStartPosition(x,U),this.tick()},b._handleFragmentLoadProgress=function(d){var a,l=d.frag,f=d.part,c=d.payload,x=this.levels;if(!x){this.warn("Levels were reset while fragment load was in progress. Fragment "+l.sn+" of level "+l.level+" will not be buffered");return}var R=x[l.level],C=R.details;if(!C){this.warn("Dropping fragment "+l.sn+" of level "+l.level+" after level details were reset");return}var N=R.videoCodec,U=C.PTSKnown||!C.live,W=(a=l.initSegment)===null||a===void 0?void 0:a.data,L=this._getAudioCodec(R),H=this.transmuxer=this.transmuxer||new m.default(this.hls,S.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),K=f?f.index:-1,$=K!==-1,Q=new s.ChunkMetadata(l.level,l.sn,l.stats.chunkCount,c.byteLength,K,$),ue=this.initPTS[l.cc];H.push(c,W,L,N,l,f,C.totalduration,U,Q,ue)},b.onAudioTrackSwitching=function(d,a){var l=this.altAudio,f=!!a.url,c=a.id;if(!f){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var x=this.fragCurrent;x!=null&&x.loader&&(this.log("Switching to main audio track, cancel main fragment load"),x.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var R=this.hls;l&&R.trigger(B.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),R.trigger(B.Events.AUDIO_TRACK_SWITCHED,{id:c})}},b.onAudioTrackSwitched=function(d,a){var l=a.id,f=!!this.hls.audioTracks[l].url;if(f){var c=this.videoBuffer;c&&this.mediaBuffer!==c&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=c)}this.altAudio=f,this.tick()},b.onBufferCreated=function(d,a){var l=a.tracks,f,c,x=!1;for(var R in l){var C=l[R];if(C.id==="main"){if(c=R,f=C,R==="video"){var N=l[R];N&&(this.videoBuffer=N.buffer)}}else x=!0}x&&f?(this.log("Alternate track found, use "+c+".buffered to schedule main fragment loading"),this.mediaBuffer=f.buffer):this.mediaBuffer=this.media},b.onFragBuffered=function(d,a){var l=a.frag,f=a.part;if(l&&l.type!==S.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(l)){this.warn("Fragment "+l.sn+(f?" p: "+f.index:"")+" of level "+l.level+" finished buffering, but was aborted. state: "+this.state),this.state===I.State.PARSED&&(this.state=I.State.IDLE);return}var c=f?f.stats:l.stats;this.fragLastKbps=Math.round(8*c.total/(c.buffering.end-c.loading.first)),l.sn!=="initSegment"&&(this.fragPrevious=l),this.fragBufferedComplete(l,f)},b.onError=function(d,a){switch(a.details){case n.ErrorDetails.FRAG_LOAD_ERROR:case n.ErrorDetails.FRAG_LOAD_TIMEOUT:case n.ErrorDetails.KEY_LOAD_ERROR:case n.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(S.PlaylistLevelType.MAIN,a);break;case n.ErrorDetails.LEVEL_LOAD_ERROR:case n.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==I.State.ERROR&&(a.fatal?(this.warn(""+a.details),this.state=I.State.ERROR):!a.levelRetry&&this.state===I.State.WAITING_LEVEL&&(this.state=I.State.IDLE));break;case n.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="main"&&(this.state===I.State.PARSING||this.state===I.State.PARSED)){var l=!0,f=this.getFwdBufferInfo(this.media,S.PlaylistLevelType.MAIN);f&&f.len>.5&&(l=!this.reduceMaxBufferLength(f.len)),l&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},b.checkBuffer=function(){var d=this.media,a=this.gapController;if(!d||!a||!d.readyState)return;var l=M.BufferHelper.getBuffered(d);!this.loadedmetadata&&l.length?(this.loadedmetadata=!0,this.seekToStartPos()):a.poll(this.lastCurrentTime),this.lastCurrentTime=d.currentTime},b.onFragLoadEmergencyAborted=function(){this.state=I.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},b.onBufferFlushed=function(d,a){var l=a.type;if(l!==p.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var f=(l===p.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(f,l,S.PlaylistLevelType.MAIN)}},b.onLevelsUpdated=function(d,a){this.levels=a.levels},b.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},b.seekToStartPos=function(){var d=this.media,a=d.currentTime,l=this.startPosition;if(l>=0&&a<l){if(d.seeking){u.logger.log("could not seek to "+l+", already seeking at "+a);return}var f=M.BufferHelper.getBuffered(d),c=f.length?f.start(0):0,x=c-l;x>0&&(x<this.config.maxBufferHole||x<this.config.maxFragLookUpTolerance)&&(u.logger.log("adjusting start position by "+x+" to match buffer start"),l+=x,this.startPosition=l),this.log("seek to target start position "+l+" from current time "+a),d.currentTime=l}},b._getAudioCodec=function(d){var a=this.config.defaultAudioCodec||d.audioCodec;return this.audioCodecSwap&&a&&(this.log("Swapping audio codec"),a.indexOf("mp4a.40.5")!==-1?a="mp4a.40.2":a="mp4a.40.5"),a},b._loadBitrateTestFrag=function(d){var a=this;this._doFragLoad(d).then(function(l){var f=a.hls;if(!l||f.nextLoadLevel||a.fragContextChanged(d))return;a.fragLoadError=0,a.state=I.State.IDLE,a.startFragRequested=!1,a.bitrateTest=!1;var c=d.stats;c.parsing.start=c.parsing.end=c.buffering.start=c.buffering.end=self.performance.now(),f.trigger(B.Events.FRAG_LOADED,l)})},b._handleTransmuxComplete=function(d){var a,l="main",f=this.hls,c=d.remuxResult,x=d.chunkMeta,R=this.getCurrentContext(x);if(!R){this.warn("The loading context changed while buffering fragment "+x.sn+" of level "+x.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(x.level);return}var C=R.frag,N=R.part,U=R.level,W=c.video,L=c.text,H=c.id3,K=c.initSegment,$=this.altAudio?void 0:c.audio;if(this.fragContextChanged(C))return;if(this.state=I.State.PARSING,K){K.tracks&&(this._bufferInitSegment(U,K.tracks,C,x),f.trigger(B.Events.FRAG_PARSING_INIT_SEGMENT,{frag:C,id:l,tracks:K.tracks}));var Q=K.initPTS,ue=K.timescale;Object(j.isFiniteNumber)(Q)&&(this.initPTS[C.cc]=Q,f.trigger(B.Events.INIT_PTS_FOUND,{frag:C,id:l,initPTS:Q,timescale:ue}))}if(W&&c.independent!==!1){if(U.details){var ne=W.startPTS,se=W.endPTS,le=W.startDTS,de=W.endDTS;if(N)N.elementaryStreams[W.type]={startPTS:ne,endPTS:se,startDTS:le,endDTS:de};else if(W.firstKeyFrame&&W.independent&&(this.couldBacktrack=!0),W.dropped&&W.independent){var re=this.getLoadPosition()+this.config.maxBufferHole;if(re<ne){this.backtrack(C);return}C.setElementaryStreamInfo(W.type,C.start,se,C.start,de,!0)}C.setElementaryStreamInfo(W.type,ne,se,le,de),this.bufferFragmentData(W,C,N,x)}}else if(c.independent===!1){this.backtrack(C);return}if($){var Y=$.startPTS,pe=$.endPTS,Te=$.startDTS,xe=$.endDTS;N&&(N.elementaryStreams[p.ElementaryStreamTypes.AUDIO]={startPTS:Y,endPTS:pe,startDTS:Te,endDTS:xe}),C.setElementaryStreamInfo(p.ElementaryStreamTypes.AUDIO,Y,pe,Te,xe),this.bufferFragmentData($,C,N,x)}if(H!=null&&(a=H.samples)!==null&&a!==void 0&&a.length){var Se={frag:C,id:l,samples:H.samples};f.trigger(B.Events.FRAG_PARSING_METADATA,Se)}if(L){var Ae={frag:C,id:l,samples:L.samples};f.trigger(B.Events.FRAG_PARSING_USERDATA,Ae)}},b._bufferInitSegment=function(d,a,l,f){var c=this;if(this.state!==I.State.PARSING)return;this.audioOnly=!!a.audio&&!a.video,this.altAudio&&!this.audioOnly&&delete a.audio;var x=a.audio,R=a.video,C=a.audiovideo;if(x){var N=d.audioCodec,U=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(N&&(N.indexOf("mp4a.40.5")!==-1?N="mp4a.40.2":N="mp4a.40.5"),x.metadata.channelCount!==1&&U.indexOf("firefox")===-1&&(N="mp4a.40.5")),U.indexOf("android")!==-1&&x.container!=="audio/mpeg"&&(N="mp4a.40.2",this.log("Android: force audio codec to "+N)),d.audioCodec&&d.audioCodec!==N&&this.log('Swapping manifest audio codec "'+d.audioCodec+'" for "'+N+'"'),x.levelCodec=N,x.id="main",this.log("Init audio buffer, container:"+x.container+", codecs[selected/level/parsed]=["+(N||"")+"/"+(d.audioCodec||"")+"/"+x.codec+"]")}R&&(R.levelCodec=d.videoCodec,R.id="main",this.log("Init video buffer, container:"+R.container+", codecs[level/parsed]=["+(d.videoCodec||"")+"/"+R.codec+"]")),C&&this.log("Init audiovideo buffer, container:"+C.container+", codecs[level/parsed]=["+(d.attrs.CODECS||"")+"/"+C.codec+"]"),this.hls.trigger(B.Events.BUFFER_CODECS,a),Object.keys(a).forEach(function(W){var L=a[W],H=L.initSegment;H!=null&&H.byteLength&&c.hls.trigger(B.Events.BUFFER_APPENDING,{type:W,data:H,frag:l,part:null,chunkMeta:f,parent:l.type})}),this.tick()},b.backtrack=function(d){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(d);var a=this.fragmentTracker.backtrack(d);this.fragPrevious=null,this.nextLoadPosition=d.start,a?this.resetFragmentLoading(d):this.state=I.State.BACKTRACKING},b.checkFragmentChanged=function(){var d=this.media,a=null;if(d&&d.readyState>1&&d.seeking===!1){var l=d.currentTime;if(M.BufferHelper.isBuffered(d,l)?a=this.getAppendedFrag(l):M.BufferHelper.isBuffered(d,l+.1)&&(a=this.getAppendedFrag(l+.1)),a){var f=this.fragPlaying,c=a.level;(!f||a.sn!==f.sn||f.level!==c||a.urlId!==f.urlId)&&(this.hls.trigger(B.Events.FRAG_CHANGED,{frag:a}),(!f||f.level!==c)&&this.hls.trigger(B.Events.LEVEL_SWITCHED,{level:c}),this.fragPlaying=a)}}},t(E,[{key:"nextLevel",get:function(){var d=this.nextBufferedFrag;return d?d.level:-1}},{key:"currentLevel",get:function(){var d=this.media;if(d){var a=this.getAppendedFrag(d.currentTime);if(a)return a.level}return-1}},{key:"nextBufferedFrag",get:function(){var d=this.media;if(d){var a=this.getAppendedFrag(d.currentTime);return this.followingBufferedFrag(a)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),E}(I.default)},"./src/controller/subtitle-stream-controller.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"SubtitleStreamController",function(){return e});var j=w("./src/events.ts"),I=w("./src/utils/logger.ts"),O=w("./src/utils/buffer-helper.ts"),B=w("./src/controller/fragment-finders.ts"),M=w("./src/utils/discontinuities.ts"),A=w("./src/controller/level-helper.ts"),S=w("./src/controller/fragment-tracker.ts"),p=w("./src/controller/base-stream-controller.ts"),m=w("./src/types/loader.ts"),s=w("./src/types/level.ts");function r(i,T){for(var _=0;_<T.length;_++){var y=T[_];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(i,y.key,y)}}function n(i,T,_){return T&&r(i.prototype,T),_&&r(i,_),i}function u(i,T){i.prototype=Object.create(T.prototype),i.prototype.constructor=i,o(i,T)}function o(i,T){return o=Object.setPrototypeOf||function(y,E){return y.__proto__=E,y},o(i,T)}var t=500,e=function(i){u(T,i);function T(y,E){var b;return b=i.call(this,y,E,"[subtitle-stream-controller]")||this,b.levels=[],b.currentTrackId=-1,b.tracksBuffered=[],b.mainDetails=null,b._registerListeners(),b}var _=T.prototype;return _.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},_._registerListeners=function(){var E=this.hls;E.on(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),E.on(j.Events.MEDIA_DETACHING,this.onMediaDetaching,this),E.on(j.Events.MANIFEST_LOADING,this.onManifestLoading,this),E.on(j.Events.LEVEL_LOADED,this.onLevelLoaded,this),E.on(j.Events.ERROR,this.onError,this),E.on(j.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),E.on(j.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),E.on(j.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),E.on(j.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),E.on(j.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},_._unregisterListeners=function(){var E=this.hls;E.off(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),E.off(j.Events.MEDIA_DETACHING,this.onMediaDetaching,this),E.off(j.Events.MANIFEST_LOADING,this.onManifestLoading,this),E.off(j.Events.LEVEL_LOADED,this.onLevelLoaded,this),E.off(j.Events.ERROR,this.onError,this),E.off(j.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),E.off(j.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),E.off(j.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),E.off(j.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),E.off(j.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},_.startLoad=function(){this.stopLoad(),this.state=p.State.IDLE,this.setInterval(t),this.tick()},_.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},_.onLevelLoaded=function(E,b){this.mainDetails=b.details},_.onSubtitleFragProcessed=function(E,b){var g=b.frag,d=b.success;if(this.fragPrevious=g,this.state=p.State.IDLE,!d)return;var a=this.tracksBuffered[this.currentTrackId];if(!a)return;for(var l,f=g.start,c=0;c<a.length;c++)if(f>=a[c].start&&f<=a[c].end){l=a[c];break}var x=g.start+g.duration;l?l.end=x:(l={start:f,end:x},a.push(l)),this.fragmentTracker.fragBuffered(g)},_.onBufferFlushing=function(E,b){var g=b.startOffset,d=b.endOffset;if(g===0&&d!==Number.POSITIVE_INFINITY){var a=this.currentTrackId,l=this.levels;if(!l.length||!l[a]||!l[a].details)return;var f=l[a].details,c=f.targetduration,x=d-c;if(x<=0)return;b.endOffsetSubtitles=Math.max(0,x),this.tracksBuffered.forEach(function(R){for(var C=0;C<R.length;){if(R[C].end<=x){R.shift();continue}else if(R[C].start<x)R[C].start=x;else break;C++}}),this.fragmentTracker.removeFragmentsInRange(g,x,m.PlaylistLevelType.SUBTITLE)}},_.onError=function(E,b){var g,d=b.frag;if(!d||d.type!==m.PlaylistLevelType.SUBTITLE)return;(g=this.fragCurrent)!==null&&g!==void 0&&g.loader&&this.fragCurrent.loader.abort(),this.state=p.State.IDLE},_.onSubtitleTracksUpdated=function(E,b){var g=this,d=b.subtitleTracks;this.tracksBuffered=[],this.levels=d.map(function(a){return new s.Level(a)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(a){g.tracksBuffered[a.id]=[]}),this.mediaBuffer=null},_.onSubtitleTrackSwitch=function(E,b){if(this.currentTrackId=b.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var g=this.levels[this.currentTrackId];g!=null&&g.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,g&&this.setInterval(t)},_.onSubtitleTrackLoaded=function(E,b){var g,d=b.details,a=b.id,l=this.currentTrackId,f=this.levels;if(!f.length)return;var c=f[l];if(a>=f.length||a!==l||!c)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,d.live||(g=c.details)!==null&&g!==void 0&&g.live){var x=this.mainDetails;if(d.deltaUpdateFailed||!x)return;var R=x.fragments[0];if(!c.details)d.hasProgramDateTime&&x.hasProgramDateTime?Object(M.alignMediaPlaylistByPDT)(d,x):R&&Object(A.addSliding)(d,R.start);else{var C=this.alignPlaylists(d,c.details);C===0&&R&&Object(A.addSliding)(d,R.start)}}if(c.details=d,this.levelLastLoaded=a,this.tick(),d.live&&!this.fragCurrent&&this.media&&this.state===p.State.IDLE){var N=Object(B.findFragmentByPTS)(null,d.fragments,this.media.currentTime,0);N||(this.warn("Subtitle playlist not aligned with playback"),c.details=void 0)}},_._handleFragmentLoadComplete=function(E){var b=E.frag,g=E.payload,d=b.decryptdata,a=this.hls;if(this.fragContextChanged(b))return;if(g&&g.byteLength>0&&d&&d.key&&d.iv&&d.method==="AES-128"){var l=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(g),d.key.buffer,d.iv.buffer).then(function(f){var c=performance.now();a.trigger(j.Events.FRAG_DECRYPTED,{frag:b,payload:f,stats:{tstart:l,tdecrypt:c}})})}},_.doTick=function(){if(!this.media){this.state=p.State.IDLE;return}if(this.state===p.State.IDLE){var E,b=this.currentTrackId,g=this.levels;if(!g.length||!g[b]||!g[b].details)return;var d=g[b].details,a=d.targetduration,l=this.config,f=this.media,c=O.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,f.currentTime-a,l.maxBufferHole),x=c.end,R=c.len,C=this.getMaxBufferLength()+a;if(R>C)return;console.assert(d,"Subtitle track details are defined on idle subtitle stream controller tick");var N=d.fragments,U=N.length,W=d.edge,L,H=this.fragPrevious;if(x<W){var K=l.maxFragLookUpTolerance;H&&d.hasProgramDateTime&&(L=Object(B.findFragmentByPDT)(N,H.endProgramDateTime,K)),L||(L=Object(B.findFragmentByPTS)(H,N,x,K),!L&&H&&H.start<N[0].start&&(L=N[0]))}else L=N[U-1];(E=L)!==null&&E!==void 0&&E.encrypted?(I.logger.log("Loading key for "+L.sn),this.state=p.State.KEY_LOADING,this.hls.trigger(j.Events.KEY_LOADING,{frag:L})):L&&this.fragmentTracker.getState(L)===S.FragmentState.NOT_LOADED&&this.loadFragment(L,d,x)}},_.loadFragment=function(E,b,g){this.fragCurrent=E,i.prototype.loadFragment.call(this,E,b,g)},n(T,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),T}(p.default)},"./src/controller/subtitle-track-controller.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/events.ts"),I=w("./src/utils/texttrack-utils.ts"),O=w("./src/controller/base-playlist-controller.ts"),B=w("./src/types/loader.ts");function M(r,n){for(var u=0;u<n.length;u++){var o=n[u];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(r,o.key,o)}}function A(r,n,u){return n&&M(r.prototype,n),u&&M(r,u),r}function S(r,n){r.prototype=Object.create(n.prototype),r.prototype.constructor=r,p(r,n)}function p(r,n){return p=Object.setPrototypeOf||function(o,t){return o.__proto__=t,o},p(r,n)}var m=function(r){S(n,r);function n(o){var t;return t=r.call(this,o,"[subtitle-track-controller]")||this,t.media=null,t.tracks=[],t.groupId=null,t.tracksInGroup=[],t.trackId=-1,t.selectDefaultTrack=!0,t.queuedDefaultTrack=-1,t.trackChangeListener=function(){return t.onTextTracksChanged()},t.asyncPollTrackChange=function(){return t.pollTrackChange(0)},t.useTextTrackPolling=!1,t.subtitlePollingInterval=-1,t.subtitleDisplay=!0,t.registerListeners(),t}var u=n.prototype;return u.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,r.prototype.destroy.call(this)},u.registerListeners=function(){var t=this.hls;t.on(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(j.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(j.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(j.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(j.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(j.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(j.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(j.Events.ERROR,this.onError,this)},u.unregisterListeners=function(){var t=this.hls;t.off(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(j.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(j.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(j.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(j.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(j.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(j.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(j.Events.ERROR,this.onError,this)},u.onMediaAttached=function(t,e){if(this.media=e.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)},u.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)},u.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 t=s(this.media.textTracks);t.forEach(function(e){Object(I.clearCurrentCues)(e)}),this.subtitleTrack=-1,this.media=null},u.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},u.onManifestParsed=function(t,e){this.tracks=e.subtitleTracks},u.onSubtitleTrackLoaded=function(t,e){var i=e.id,T=e.details,_=this.trackId,y=this.tracksInGroup[_];if(!y){this.warn("Invalid subtitle track id "+i);return}var E=y.details;y.details=e.details,this.log("subtitle track "+i+" loaded ["+T.startSN+"-"+T.endSN+"]"),i===this.trackId&&(this.retryCount=0,this.playlistLoaded(i,e,E))},u.onLevelLoading=function(t,e){this.switchLevel(e.level)},u.onLevelSwitching=function(t,e){this.switchLevel(e.level)},u.switchLevel=function(t){var e=this.hls.levels[t];if(!(e!=null&&e.textGroupIds))return;var i=e.textGroupIds[e.urlId];if(this.groupId!==i){var T=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,_=this.tracks.filter(function(b){return!i||b.groupId===i});this.tracksInGroup=_;var y=this.findTrackId(T==null?void 0:T.name)||this.findTrackId();this.groupId=i;var E={subtitleTracks:_};this.log("Updating subtitle tracks, "+_.length+' track(s) found in "'+i+'" group-id'),this.hls.trigger(j.Events.SUBTITLE_TRACKS_UPDATED,E),y!==-1&&this.setSubtitleTrack(y,T)}},u.findTrackId=function(t){for(var e=this.tracksInGroup,i=0;i<e.length;i++){var T=e[i];if((!this.selectDefaultTrack||T.default)&&(!t||t===T.name))return T.id}return-1},u.onError=function(t,e){if(r.prototype.onError.call(this,t,e),e.fatal||!e.context)return;e.context.type===B.PlaylistContextType.SUBTITLE_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},u.loadPlaylist=function(t){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var i=e.id,T=e.groupId,_=e.url;if(t)try{_=t.addDirectives(_)}catch(y){this.warn("Could not construct new URL with HLS Delivery Directives: "+y)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(j.Events.SUBTITLE_TRACK_LOADING,{url:_,id:i,groupId:T,deliveryDirectives:t||null})}},u.toggleTrackModes=function(t){var e=this,i=this.media,T=this.subtitleDisplay,_=this.trackId;if(!i)return;var y=s(i.textTracks),E=y.filter(function(d){return d.groupId===e.groupId});if(t===-1)[].slice.call(y).forEach(function(d){d.mode="disabled"});else{var b=E[_];b&&(b.mode="disabled")}var g=E[t];g&&(g.mode=T?"showing":"hidden")},u.setSubtitleTrack=function(t,e){var i,T=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=t;return}if(this.trackId!==t&&this.toggleTrackModes(t),this.trackId===t&&(t===-1||(i=T[t])!==null&&i!==void 0&&i.details)||t<-1||t>=T.length)return;this.clearTimer();var _=T[t];if(this.log("Switching to subtitle track "+t),this.trackId=t,_){var y=_.id,E=_.groupId,b=E===void 0?"":E,g=_.name,d=_.type,a=_.url;this.hls.trigger(j.Events.SUBTITLE_TRACK_SWITCH,{id:y,groupId:b,name:g,type:d,url:a});var l=this.switchParams(_.url,e==null?void 0:e.details);this.loadPlaylist(l)}else this.hls.trigger(j.Events.SUBTITLE_TRACK_SWITCH,{id:t})},u.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var t=-1,e=s(this.media.textTracks),i=0;i<e.length;i++)if(e[i].mode==="hidden")t=i;else if(e[i].mode==="showing"){t=i;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)},A(n,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1;var e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,e)}}]),n}(O.default);function s(r){for(var n=[],u=0;u<r.length;u++){var o=r[u];o.kind==="subtitles"&&o.label&&n.push(r[u])}return n}G.default=m},"./src/controller/timeline-controller.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"TimelineController",function(){return s});var j=w("./src/polyfills/number.ts"),I=w("./src/events.ts"),O=w("./src/utils/cea-608-parser.ts"),B=w("./src/utils/output-filter.ts"),M=w("./src/utils/webvtt-parser.ts"),A=w("./src/utils/texttrack-utils.ts"),S=w("./src/utils/imsc1-ttml-parser.ts"),p=w("./src/types/loader.ts"),m=w("./src/utils/logger.ts"),s=function(){function o(e){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=u(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.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 i=new B.default(this,"textTrack1"),T=new B.default(this,"textTrack2"),_=new B.default(this,"textTrack3"),y=new B.default(this,"textTrack4");this.cea608Parser1=new O.default(1,i,T),this.cea608Parser2=new O.default(3,_,y)}e.on(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(I.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(I.Events.FRAG_LOADING,this.onFragLoading,this),e.on(I.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(I.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(I.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(I.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var t=o.prototype;return t.destroy=function(){var i=this.hls;i.off(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.off(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.off(I.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),i.off(I.Events.FRAG_LOADING,this.onFragLoading,this),i.off(I.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(I.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),i.off(I.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),i.off(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),i.off(I.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),i.off(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},t.addCues=function(i,T,_,y,E){for(var b=!1,g=E.length;g--;){var d=E[g],a=n(d[0],d[1],T,_);if(a>=0&&(d[0]=Math.min(d[0],T),d[1]=Math.max(d[1],_),b=!0,a/(_-T)>.5))return}if(b||E.push([T,_]),this.config.renderTextTracksNatively){var l=this.captionsTracks[i];this.Cues.newCue(l,T,_,y)}else{var f=this.Cues.newCue(null,T,_,y);this.hls.trigger(I.Events.CUES_PARSED,{type:"captions",cues:f,track:i})}},t.onInitPtsFound=function(i,T){var _=this,y=T.frag,E=T.id,b=T.initPTS,g=T.timescale,d=this.unparsedVttFrags;E==="main"&&(this.initPTS[y.cc]=b,this.timescale[y.cc]=g),d.length&&(this.unparsedVttFrags=[],d.forEach(function(a){_.onFragLoaded(I.Events.FRAG_LOADED,a)}))},t.getExistingTrack=function(i){var T=this.media;if(T)for(var _=0;_<T.textTracks.length;_++){var y=T.textTracks[_];if(y[i])return y}return null},t.createCaptionsTrack=function(i){this.config.renderTextTracksNatively?this.createNativeTrack(i):this.createNonNativeTrack(i)},t.createNativeTrack=function(i){if(this.captionsTracks[i])return;var T=this.captionsProperties,_=this.captionsTracks,y=this.media,E=T[i],b=E.label,g=E.languageCode,d=this.getExistingTrack(i);if(d)_[i]=d,Object(A.clearCurrentCues)(_[i]),Object(A.sendAddTrackEvent)(_[i],y);else{var a=this.createTextTrack("captions",b,g);a&&(a[i]=!0,_[i]=a)}},t.createNonNativeTrack=function(i){if(this.nonNativeCaptionsTracks[i])return;var T=this.captionsProperties[i];if(!T)return;var _=T.label,y={_id:i,label:_,kind:"captions",default:T.media?!!T.media.default:!1,closedCaptions:T.media};this.nonNativeCaptionsTracks[i]=y,this.hls.trigger(I.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[y]})},t.createTextTrack=function(i,T,_){var y=this.media;return y?y.addTextTrack(i,T,_):void 0},t.onMediaAttaching=function(i,T){this.media=T.media,this._cleanTracks()},t.onMediaDetaching=function(){var i=this.captionsTracks;Object.keys(i).forEach(function(T){Object(A.clearCurrentCues)(i[T]),delete i[T]}),this.nonNativeCaptionsTracks={}},t.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=u(),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())},t._cleanTracks=function(){var i=this.media;if(!i)return;var T=i.textTracks;if(T)for(var _=0;_<T.length;_++)Object(A.clearCurrentCues)(T[_])},t.onSubtitleTracksUpdated=function(i,T){var _=this;this.textTracks=[];var y=T.subtitleTracks||[],E=y.some(function(a){return a.textCodec===S.IMSC1_CODEC});if(this.config.enableWebVTT||E&&this.config.enableIMSC1){var b=this.tracks&&y&&this.tracks.length===y.length;if(this.tracks=y||[],this.config.renderTextTracksNatively){var g=this.media?this.media.textTracks:[];this.tracks.forEach(function(a,l){var f;if(l<g.length){for(var c=null,x=0;x<g.length;x++)if(r(g[x],a)){c=g[x];break}c&&(f=c)}f?Object(A.clearCurrentCues)(f):(f=_.createTextTrack("subtitles",a.name,a.lang),f&&(f.mode="disabled")),f&&(f.groupId=a.groupId,_.textTracks.push(f))})}else if(!b&&this.tracks&&this.tracks.length){var d=this.tracks.map(function(a){return{label:a.name,kind:a.type.toLowerCase(),default:a.default,subtitleTrack:a}});this.hls.trigger(I.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:d})}}},t.onManifestLoaded=function(i,T){var _=this;this.config.enableCEA708Captions&&T.captions&&T.captions.forEach(function(y){var E=/(?:CC|SERVICE)([1-4])/.exec(y.instreamId);if(!E)return;var b="textTrack"+E[1],g=_.captionsProperties[b];if(!g)return;g.label=y.name,y.lang&&(g.languageCode=y.lang),g.media=y})},t.onFragLoading=function(i,T){var _=this.cea608Parser1,y=this.cea608Parser2,E=this.lastSn,b=this.lastPartIndex;if(!this.enabled||!(_&&y))return;if(T.frag.type===p.PlaylistLevelType.MAIN){var g,d,a=T.frag.sn,l=(g=T==null||((d=T.part)===null||d===void 0)?void 0:d.index)!=null?g:-1;a===E+1||a===E&&l===b+1||(_.reset(),y.reset()),this.lastSn=a,this.lastPartIndex=l}},t.onFragLoaded=function(i,T){var _=T.frag,y=T.payload,E=this.initPTS,b=this.unparsedVttFrags;if(_.type===p.PlaylistLevelType.SUBTITLE)if(y.byteLength){if(!Object(j.isFiniteNumber)(E[_.cc])){b.push(T),E.length&&this.hls.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:_,error:new Error("Missing initial subtitle PTS")});return}var g=_.decryptdata;if(g==null||g.key==null||g.method!=="AES-128"){var d=this.tracks[_.level],a=this.vttCCs;a[_.cc]||(a[_.cc]={start:_.start,prevCC:this.prevCC,new:!0},this.prevCC=_.cc),d&&d.textCodec===S.IMSC1_CODEC?this._parseIMSC1(_,y):this._parseVTTs(_,y,a)}}else this.hls.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:_,error:new Error("Empty subtitle payload")})},t._parseIMSC1=function(i,T){var _=this,y=this.hls;Object(S.parseIMSC1)(T,this.initPTS[i.cc],this.timescale[i.cc],function(E){_._appendCues(E,i.level),y.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},function(E){m.logger.log("Failed to parse IMSC1: "+E),y.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:E})})},t._parseVTTs=function(i,T,_){var y=this,E=this.hls;Object(M.parseWebVTT)(T,this.initPTS[i.cc],this.timescale[i.cc],_,i.cc,i.start,function(b){y._appendCues(b,i.level),E.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},function(b){y._fallbackToIMSC1(i,T),m.logger.log("Failed to parse VTT cue: "+b),E.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:b})})},t._fallbackToIMSC1=function(i,T){var _=this,y=this.tracks[i.level];y.textCodec||Object(S.parseIMSC1)(T,this.initPTS[i.cc],this.timescale[i.cc],function(){y.textCodec=S.IMSC1_CODEC,_._parseIMSC1(i,T)},function(){y.textCodec="wvtt"})},t._appendCues=function(i,T){var _=this.hls;if(this.config.renderTextTracksNatively){var y=this.textTracks[T];if(y.mode==="disabled")return;i.forEach(function(g){return Object(A.addCueToTrack)(y,g)})}else{var E=this.tracks[T],b=E.default?"default":"subtitles"+T;_.trigger(I.Events.CUES_PARSED,{type:"subtitles",cues:i,track:b})}},t.onFragDecrypted=function(i,T){var _=T.frag;if(_.type===p.PlaylistLevelType.SUBTITLE){if(!Object(j.isFiniteNumber)(this.initPTS[_.cc])){this.unparsedVttFrags.push(T);return}this.onFragLoaded(I.Events.FRAG_LOADED,T)}},t.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},t.onFragParsingUserdata=function(i,T){var _=this.cea608Parser1,y=this.cea608Parser2;if(!this.enabled||!(_&&y))return;for(var E=0;E<T.samples.length;E++){var b=T.samples[E].bytes;if(b){var g=this.extractCea608Data(b);_.addData(T.samples[E].pts,g[0]),y.addData(T.samples[E].pts,g[1])}}},t.onBufferFlushing=function(i,T){var _=T.startOffset,y=T.endOffset,E=T.endOffsetSubtitles,b=T.type,g=this.media;if(!g||g.currentTime<y)return;if(!b||b==="video"){var d=this.captionsTracks;Object.keys(d).forEach(function(l){return Object(A.removeCuesInRange)(d[l],_,y)})}if(this.config.renderTextTracksNatively&&(_===0&&E!==void 0)){var a=this.textTracks;Object.keys(a).forEach(function(l){return Object(A.removeCuesInRange)(a[l],_,E)})}},t.extractCea608Data=function(i){for(var T=i[0]&31,_=2,y=[[],[]],E=0;E<T;E++){var b=i[_++],g=127&i[_++],d=127&i[_++],a=(4&b)!==0,l=3&b;if(g===0&&d===0)continue;a&&((l===0||l===1)&&(y[l].push(g),y[l].push(d)))}return y},o}();function r(o,t){return o&&o.label===t.name&&!(o.textTrack1||o.textTrack2)}function n(o,t,e,i){return Math.min(t,i)-Math.max(o,e)}function u(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return j});var j=function(){function I(B,M){this.subtle=void 0,this.aesIV=void 0,this.subtle=B,this.aesIV=M}var O=I.prototype;return O.decrypt=function(M,A){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},A,M)},I}()},"./src/crypt/aes-decryptor.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"removePadding",function(){return I}),w.d(G,"default",function(){return O});var j=w("./src/utils/typed-array.ts");function I(B){var M=B.byteLength,A=M&&new DataView(B.buffer).getUint8(M-1);return A?Object(j.sliceUint8)(B,0,M-A):B}var O=function(){function B(){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=B.prototype;return M.uint8ArrayToUint32Array_=function(S){for(var p=new DataView(S),m=new Uint32Array(4),s=0;s<4;s++)m[s]=p.getUint32(s*4);return m},M.initTable=function(){var S=this.sBox,p=this.invSBox,m=this.subMix,s=m[0],r=m[1],n=m[2],u=m[3],o=this.invSubMix,t=o[0],e=o[1],i=o[2],T=o[3],_=new Uint32Array(256),y=0,E=0,b=0;for(b=0;b<256;b++)b<128?_[b]=b<<1:_[b]=b<<1^283;for(b=0;b<256;b++){var g=E^E<<1^E<<2^E<<3^E<<4;g=g>>>8^g&255^99,S[y]=g,p[g]=y;var d=_[y],a=_[d],l=_[a],f=_[g]*257^g*16843008;s[y]=f<<24|f>>>8,r[y]=f<<16|f>>>16,n[y]=f<<8|f>>>24,u[y]=f,f=l*16843009^a*65537^d*257^y*16843008,t[g]=f<<24|f>>>8,e[g]=f<<16|f>>>16,i[g]=f<<8|f>>>24,T[g]=f,y?(y=d^_[_[_[l^d]]],E^=_[_[E]]):y=E=1}},M.expandKey=function(S){for(var p=this.uint8ArrayToUint32Array_(S),m=!0,s=0;s<p.length&&m;)m=p[s]===this.key[s],s++;if(m)return;this.key=p;var r=this.keySize=p.length;if(r!==4&&r!==6&&r!==8)throw new Error("Invalid aes key size="+r);var n=this.ksRows=(r+6+1)*4,u,o,t=this.keySchedule=new Uint32Array(n),e=this.invKeySchedule=new Uint32Array(n),i=this.sBox,T=this.rcon,_=this.invSubMix,y=_[0],E=_[1],b=_[2],g=_[3],d,a;for(u=0;u<n;u++){if(u<r){d=t[u]=p[u];continue}a=d,u%r===0?(a=a<<8|a>>>24,a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[a&255],a^=T[u/r|0]<<24):r>6&&u%r===4&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[a&255]),t[u]=d=(t[u-r]^a)>>>0}for(o=0;o<n;o++)u=n-o,o&3?a=t[u]:a=t[u-4],o<4||u<=4?e[o]=a:e[o]=y[i[a>>>24]]^E[i[a>>>16&255]]^b[i[a>>>8&255]]^g[i[a&255]],e[o]=e[o]>>>0},M.networkToHostOrderSwap=function(S){return S<<24|(S&65280)<<8|(S&16711680)>>8|S>>>24},M.decrypt=function(S,p,m){for(var s=this.keySize+6,r=this.invKeySchedule,n=this.invSBox,u=this.invSubMix,o=u[0],t=u[1],e=u[2],i=u[3],T=this.uint8ArrayToUint32Array_(m),_=T[0],y=T[1],E=T[2],b=T[3],g=new Int32Array(S),d=new Int32Array(g.length),a,l,f,c,x,R,C,N,U,W,L,H,K,$,Q=this.networkToHostOrderSwap;p<g.length;){for(U=Q(g[p]),W=Q(g[p+1]),L=Q(g[p+2]),H=Q(g[p+3]),x=U^r[0],R=H^r[1],C=L^r[2],N=W^r[3],K=4,$=1;$<s;$++)a=o[x>>>24]^t[R>>16&255]^e[C>>8&255]^i[N&255]^r[K],l=o[R>>>24]^t[C>>16&255]^e[N>>8&255]^i[x&255]^r[K+1],f=o[C>>>24]^t[N>>16&255]^e[x>>8&255]^i[R&255]^r[K+2],c=o[N>>>24]^t[x>>16&255]^e[R>>8&255]^i[C&255]^r[K+3],x=a,R=l,C=f,N=c,K=K+4;a=n[x>>>24]<<24^n[R>>16&255]<<16^n[C>>8&255]<<8^n[N&255]^r[K],l=n[R>>>24]<<24^n[C>>16&255]<<16^n[N>>8&255]<<8^n[x&255]^r[K+1],f=n[C>>>24]<<24^n[N>>16&255]<<16^n[x>>8&255]<<8^n[R&255]^r[K+2],c=n[N>>>24]<<24^n[x>>16&255]<<16^n[R>>8&255]<<8^n[C&255]^r[K+3],d[p]=Q(a^_),d[p+1]=Q(c^y),d[p+2]=Q(f^E),d[p+3]=Q(l^b),_=U,y=W,E=L,b=H,p=p+4}return d.buffer},B}()},"./src/crypt/decrypter.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return p});var j=w("./src/crypt/aes-crypto.ts"),I=w("./src/crypt/fast-aes-key.ts"),O=w("./src/crypt/aes-decryptor.ts"),B=w("./src/utils/logger.ts"),M=w("./src/utils/mp4-tools.ts"),A=w("./src/utils/typed-array.ts"),S=16,p=function(){function m(r,n,u){var o=u===void 0?{}:u,t=o.removePKCS7Padding,e=t===void 0?!0:t;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=r,this.config=n,this.removePKCS7Padding=e,e)try{var i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch(T){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var s=m.prototype;return s.destroy=function(){this.observer=null},s.isSync=function(){return this.config.enableSoftwareAES},s.flush=function(){var n=this.currentResult;if(!n){this.reset();return}var u=new Uint8Array(n);return this.reset(),this.removePKCS7Padding?Object(O.removePadding)(u):u},s.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},s.decrypt=function(n,u,o,t){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(n),u,o);var e=this.flush();e&&t(e.buffer)}else this.webCryptoDecrypt(new Uint8Array(n),u,o).then(t)},s.softwareDecrypt=function(n,u,o){var t=this.currentIV,e=this.currentResult,i=this.remainderData;this.logOnce("JS AES decrypt"),i&&(n=Object(M.appendUint8Array)(i,n),this.remainderData=null);var T=this.getValidChunk(n);if(!T.length)return null;t&&(o=t);var _=this.softwareDecrypter;_||(_=this.softwareDecrypter=new O.default),_.expandKey(u);var y=e;return this.currentResult=_.decrypt(T.buffer,0,o),this.currentIV=Object(A.sliceUint8)(T,-16).buffer,y||null},s.webCryptoDecrypt=function(n,u,o){var t=this,e=this.subtle;return(this.key!==u||!this.fastAesKey)&&(this.key=u,this.fastAesKey=new I.default(e,u)),this.fastAesKey.expandKey().then(function(i){if(!e)return Promise.reject(new Error("web crypto not initialized"));var T=new j.default(e,o);return T.decrypt(n.buffer,i)}).catch(function(i){return t.onWebCryptoError(i,n,u,o)})},s.onWebCryptoError=function(n,u,o,t){return B.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",n),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(u,o,t)},s.getValidChunk=function(n){var u=n,o=n.length-n.length%S;return o!==n.length&&(u=Object(A.sliceUint8)(n,0,o),this.remainderData=Object(A.sliceUint8)(n,o)),u},s.logOnce=function(n){if(!this.logEnabled)return;B.logger.log("[decrypter.ts]: "+n),this.logEnabled=!1},m}()},"./src/crypt/fast-aes-key.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return j});var j=function(){function I(B,M){this.subtle=void 0,this.key=void 0,this.subtle=B,this.key=M}var O=I.prototype;return O.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},I}()},"./src/demux/aacdemuxer.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/demux/base-audio-demuxer.ts"),I=w("./src/demux/adts.ts"),O=w("./src/utils/logger.ts"),B=w("./src/demux/id3.ts");function M(p,m){p.prototype=Object.create(m.prototype),p.prototype.constructor=p,A(p,m)}function A(p,m){return A=Object.setPrototypeOf||function(r,n){return r.__proto__=n,r},A(p,m)}var S=function(p){M(m,p);function m(r,n){var u;return u=p.call(this)||this,u.observer=void 0,u.config=void 0,u.observer=r,u.config=n,u}var s=m.prototype;return s.resetInitSegment=function(n,u,o){p.prototype.resetInitSegment.call(this,n,u,o),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:n,duration:o,inputTimeScale:9e4,dropped:0}},m.probe=function(n){if(!n)return!1;for(var u=B.getID3Data(n,0)||[],o=u.length,t=n.length;o<t;o++)if(I.probe(n,o))return O.logger.log("ADTS sync word found !"),!0;return!1},s.canParse=function(n,u){return I.canParse(n,u)},s.appendFrame=function(n,u,o){I.initTrackConfig(n,this.observer,u,o,n.manifestCodec);var t=I.appendFrame(n,u,o,this.initPTS,this.frameIndex);if(t&&t.missing===0)return t},m}(j.default);S.minProbeByteLength=9,G.default=S},"./src/demux/adts.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"getAudioConfig",function(){return B}),w.d(G,"isHeaderPattern",function(){return M}),w.d(G,"getHeaderLength",function(){return A}),w.d(G,"getFullFrameLength",function(){return S}),w.d(G,"canGetFrameLength",function(){return p}),w.d(G,"isHeader",function(){return m}),w.d(G,"canParse",function(){return s}),w.d(G,"probe",function(){return r}),w.d(G,"initTrackConfig",function(){return n}),w.d(G,"getFrameDuration",function(){return u}),w.d(G,"parseFrameHeader",function(){return o}),w.d(G,"appendFrame",function(){return t});var j=w("./src/utils/logger.ts"),I=w("./src/errors.ts"),O=w("./src/events.ts");function B(e,i,T,_){var y,E,b,g,d=navigator.userAgent.toLowerCase(),a=_,l=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];y=((i[T+2]&192)>>>6)+1;var f=(i[T+2]&60)>>>2;if(f>l.length-1){e.trigger(O.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+f});return}return b=(i[T+2]&1)<<2,b|=(i[T+3]&192)>>>6,j.logger.log("manifest codec:"+_+", ADTS type:"+y+", samplingIndex:"+f),/firefox/i.test(d)?f>=6?(y=5,g=new Array(4),E=f-3):(y=2,g=new Array(2),E=f):d.indexOf("android")!==-1?(y=2,g=new Array(2),E=f):(y=5,g=new Array(4),_&&(_.indexOf("mp4a.40.29")!==-1||_.indexOf("mp4a.40.5")!==-1)||!_&&f>=6?E=f-3:((_&&_.indexOf("mp4a.40.2")!==-1&&(f>=6&&b===1||/vivaldi/i.test(d))||!_&&b===1)&&(y=2,g=new Array(2)),E=f)),g[0]=y<<3,g[0]|=(f&14)>>1,g[1]|=(f&1)<<7,g[1]|=b<<3,y===5&&(g[1]|=(E&14)>>1,g[2]=(E&1)<<7,g[2]|=2<<2,g[3]=0),{config:g,samplerate:l[f],channelCount:b,codec:"mp4a.40."+y,manifestCodec:a}}function M(e,i){return e[i]===255&&(e[i+1]&246)===240}function A(e,i){return e[i+1]&1?7:9}function S(e,i){return(e[i+3]&3)<<11|e[i+4]<<3|(e[i+5]&224)>>>5}function p(e,i){return i+5<e.length}function m(e,i){return i+1<e.length&&M(e,i)}function s(e,i){return p(e,i)&&M(e,i)&&S(e,i)<=e.length-i}function r(e,i){if(m(e,i)){var T=A(e,i);if(i+T>=e.length)return!1;var _=S(e,i);if(_<=T)return!1;var y=i+_;return y===e.length||m(e,y)}return!1}function n(e,i,T,_,y){if(!e.samplerate){var E=B(i,T,_,y);if(!E)return;e.config=E.config,e.samplerate=E.samplerate,e.channelCount=E.channelCount,e.codec=E.codec,e.manifestCodec=E.manifestCodec,j.logger.log("parsed codec:"+e.codec+", rate:"+E.samplerate+", channels:"+E.channelCount)}}function u(e){return 1024*9e4/e}function o(e,i,T,_,y){var E=A(e,i),b=S(e,i);if(b-=E,b>0){var g=T+_*y;return{headerLength:E,frameLength:b,stamp:g}}}function t(e,i,T,_,y){var E=u(e.samplerate),b=o(i,T,_,y,E);if(b){var g=b.frameLength,d=b.headerLength,a=b.stamp,l=d+g,f=Math.max(0,T+l-i.length),c;f?(c=new Uint8Array(l-d),c.set(i.subarray(T+d,i.length),0)):c=i.subarray(T+d,T+l);var x={unit:c,pts:a};return f||e.samples.push(x),{sample:x,length:l,missing:f}}}},"./src/demux/base-audio-demuxer.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"initPTSFn",function(){return S});var j=w("./src/polyfills/number.ts"),I=w("./src/demux/id3.ts"),O=w("./src/demux/dummy-demuxed-track.ts"),B=w("./src/utils/mp4-tools.ts"),M=w("./src/utils/typed-array.ts"),A=function(){function p(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var m=p.prototype;return m.resetInitSegment=function(r,n,u){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},m.resetTimeStamp=function(){},m.resetContiguity=function(){},m.canParse=function(r,n){return!1},m.appendFrame=function(r,n,u){},m.demux=function(r,n){this.cachedData&&(r=Object(B.appendUint8Array)(this.cachedData,r),this.cachedData=null);var u=I.getID3Data(r,0),o=u?u.length:0,t,e,i=this._audioTrack,T=this._id3Track,_=u?I.getTimeStamp(u):void 0,y=r.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=S(_,n)),u&&u.length>0&&T.samples.push({pts:this.initPTS,dts:this.initPTS,data:u}),e=this.initPTS;o<y;){if(this.canParse(r,o)){var E=this.appendFrame(i,r,o);E?(this.frameIndex++,e=E.sample.pts,o+=E.length,t=o):o=y}else I.canParse(r,o)?(u=I.getID3Data(r,o),T.samples.push({pts:e,dts:e,data:u}),o+=u.length,t=o):o++;if(o===y&&t!==y){var b=Object(M.sliceUint8)(r,t);this.cachedData?this.cachedData=Object(B.appendUint8Array)(this.cachedData,b):this.cachedData=b}}return{audioTrack:i,avcTrack:Object(O.dummyTrack)(),id3Track:T,textTrack:Object(O.dummyTrack)()}},m.demuxSampleAes=function(r,n,u){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},m.flush=function(r){var n=this.cachedData;return n&&(this.cachedData=null,this.demux(n,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(O.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(O.dummyTrack)()}},m.destroy=function(){},p}(),S=function(m,s){return Object(j.isFiniteNumber)(m)?m*90:s*9e4};G.default=A},"./src/demux/chunk-cache.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return j});var j=function(){function O(){this.chunks=[],this.dataLength=0}var B=O.prototype;return B.push=function(A){this.chunks.push(A),this.dataLength+=A.length},B.flush=function(){var A=this.chunks,S=this.dataLength,p;if(A.length)A.length===1?p=A[0]:p=I(A,S);else return new Uint8Array(0);return this.reset(),p},B.reset=function(){this.chunks.length=0,this.dataLength=0},O}();function I(O,B){for(var M=new Uint8Array(B),A=0,S=0;S<O.length;S++){var p=O[S];M.set(p,A),A+=p.length}return M}},"./src/demux/dummy-demuxed-track.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"dummyTrack",function(){return j});function j(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/utils/logger.ts"),I=function(){function O(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 B=O.prototype;return B.loadWord=function(){var A=this.data,S=this.bytesAvailable,p=A.byteLength-S,m=new Uint8Array(4),s=Math.min(4,S);if(s===0)throw new Error("no bytes available");m.set(A.subarray(p,p+s)),this.word=new DataView(m.buffer).getUint32(0),this.bitsAvailable=s*8,this.bytesAvailable-=s},B.skipBits=function(A){var S;this.bitsAvailable>A?(this.word<<=A,this.bitsAvailable-=A):(A-=this.bitsAvailable,S=A>>3,A-=S>>3,this.bytesAvailable-=S,this.loadWord(),this.word<<=A,this.bitsAvailable-=A)},B.readBits=function(A){var S=Math.min(this.bitsAvailable,A),p=this.word>>>32-S;return A>32&&j.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=S,this.bitsAvailable>0?this.word<<=S:this.bytesAvailable>0&&this.loadWord(),S=A-S,S>0&&this.bitsAvailable?p<<S|this.readBits(S):p},B.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()},B.skipUEG=function(){this.skipBits(1+this.skipLZ())},B.skipEG=function(){this.skipBits(1+this.skipLZ())},B.readUEG=function(){var A=this.skipLZ();return this.readBits(A+1)-1},B.readEG=function(){var A=this.readUEG();return 1&A?1+A>>>1:-1*(A>>>1)},B.readBoolean=function(){return this.readBits(1)===1},B.readUByte=function(){return this.readBits(8)},B.readUShort=function(){return this.readBits(16)},B.readUInt=function(){return this.readBits(32)},B.skipScalingList=function(A){for(var S=8,p=8,m,s=0;s<A;s++)p!==0&&(m=this.readEG(),p=(S+m+256)%256),S=p===0?S:p},B.readSPS=function(){var A=0,S=0,p=0,m=0,s,r,n,u=this.readUByte.bind(this),o=this.readBits.bind(this),t=this.readUEG.bind(this),e=this.readBoolean.bind(this),i=this.skipBits.bind(this),T=this.skipEG.bind(this),_=this.skipUEG.bind(this),y=this.skipScalingList.bind(this);u();var E=u();if(o(5),i(3),u(),_(),E===100||E===110||E===122||E===244||E===44||E===83||E===86||E===118||E===128){var b=t();if(b===3&&i(1),_(),_(),i(1),e())for(r=b!==3?8:12,n=0;n<r;n++)e()&&(n<6?y(16):y(64))}_();var g=t();if(g===0)t();else if(g===1)for(i(1),T(),T(),s=t(),n=0;n<s;n++)T();_(),i(1);var d=t(),a=t(),l=o(1);l===0&&i(1),i(1),e()&&(A=t(),S=t(),p=t(),m=t());var f=[1,1];if(e()&&e()){var c=u();switch(c){case 1:f=[1,1];break;case 2:f=[12,11];break;case 3:f=[10,11];break;case 4:f=[16,11];break;case 5:f=[40,33];break;case 6:f=[24,11];break;case 7:f=[20,11];break;case 8:f=[32,11];break;case 9:f=[80,33];break;case 10:f=[18,11];break;case 11:f=[15,11];break;case 12:f=[64,33];break;case 13:f=[160,99];break;case 14:f=[4,3];break;case 15:f=[3,2];break;case 16:f=[2,1];break;case 255:{f=[u()<<8|u(),u()<<8|u()];break}}}return{width:Math.ceil((d+1)*16-A*2-S*2),height:(2-l)*(a+1)*16-(l?2:4)*(p+m),pixelRatio:f}},B.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},O}();G.default=I},"./src/demux/id3.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"isHeader",function(){return j}),w.d(G,"isFooter",function(){return I}),w.d(G,"getID3Data",function(){return O}),w.d(G,"canParse",function(){return M}),w.d(G,"getTimeStamp",function(){return A}),w.d(G,"isTimeStampFrame",function(){return S}),w.d(G,"getID3Frames",function(){return m}),w.d(G,"decodeFrame",function(){return s}),w.d(G,"utf8ArrayToStr",function(){return t}),w.d(G,"testables",function(){return e});var j=function(y,E){return E+10<=y.length&&(y[E]===73&&y[E+1]===68&&y[E+2]===51&&(y[E+3]<255&&y[E+4]<255&&(y[E+6]<128&&y[E+7]<128&&y[E+8]<128&&y[E+9]<128)))},I=function(y,E){return E+10<=y.length&&(y[E]===51&&y[E+1]===68&&y[E+2]===73&&(y[E+3]<255&&y[E+4]<255&&(y[E+6]<128&&y[E+7]<128&&y[E+8]<128&&y[E+9]<128)))},O=function(y,E){for(var b=E,g=0;j(y,E);){g+=10;var d=B(y,E+6);g+=d,I(y,E+10)&&(g+=10),E+=g}return g>0?y.subarray(b,b+g):void 0},B=function(y,E){var b=0;return b=(y[E]&127)<<21,b|=(y[E+1]&127)<<14,b|=(y[E+2]&127)<<7,b|=y[E+3]&127,b},M=function(y,E){return j(y,E)&&B(y,E+6)+10<=y.length-E},A=function(y){for(var E=m(y),b=0;b<E.length;b++){var g=E[b];if(S(g))return o(g)}return},S=function(y){return y&&y.key==="PRIV"&&y.info==="com.apple.streaming.transportStreamTimestamp"},p=function(y){var E=String.fromCharCode(y[0],y[1],y[2],y[3]),b=B(y,4),g=10;return{type:E,size:b,data:y.subarray(g,g+b)}},m=function(y){for(var E=0,b=[];j(y,E);){var g=B(y,E+6);E+=10;for(var d=E+g;E+8<d;){var a=p(y.subarray(E)),l=s(a);l&&b.push(l),E+=a.size+10}I(y,E)&&(E+=10)}return b},s=function(y){return y.type==="PRIV"?r(y):y.type[0]==="W"?u(y):n(y)},r=function(y){if(y.size<2)return;var E=t(y.data,!0),b=new Uint8Array(y.data.subarray(E.length+1));return{key:y.type,info:E,data:b.buffer}},n=function(y){if(y.size<2)return;if(y.type==="TXXX"){var E=1,b=t(y.data.subarray(E),!0);E+=b.length+1;var g=t(y.data.subarray(E));return{key:y.type,info:b,data:g}}var d=t(y.data.subarray(1));return{key:y.type,data:d}},u=function(y){if(y.type==="WXXX"){if(y.size<2)return;var E=1,b=t(y.data.subarray(E),!0);E+=b.length+1;var g=t(y.data.subarray(E));return{key:y.type,info:b,data:g}}var d=t(y.data);return{key:y.type,data:d}},o=function(y){if(y.data.byteLength===8){var E=new Uint8Array(y.data),b=E[3]&1,g=(E[4]<<23)+(E[5]<<15)+(E[6]<<7)+E[7];return g/=45,b&&(g+=4772185884e-2),Math.round(g)}return},t=function(y,E){E===void 0&&(E=!1);var b=T();if(b){var g=b.decode(y);if(E){var d=g.indexOf("\0");return d!==-1?g.substring(0,d):g}return g.replace(/\0/g,"")}for(var a=y.length,l,f,c,x="",R=0;R<a;){if(l=y[R++],l===0&&E)return x;if(l===0||l===3)continue;switch(l>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:x+=String.fromCharCode(l);break;case 12:case 13:f=y[R++],x+=String.fromCharCode((l&31)<<6|f&63);break;case 14:f=y[R++],c=y[R++],x+=String.fromCharCode((l&15)<<12|(f&63)<<6|(c&63)<<0);break;default:}}return x},e={decodeTextFrame:n},i;function T(){return!i&&typeof self.TextDecoder!="undefined"&&(i=new self.TextDecoder("utf-8")),i}},"./src/demux/mp3demuxer.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/demux/base-audio-demuxer.ts"),I=w("./src/demux/id3.ts"),O=w("./src/utils/logger.ts"),B=w("./src/demux/mpegaudio.ts");function M(p,m){p.prototype=Object.create(m.prototype),p.prototype.constructor=p,A(p,m)}function A(p,m){return A=Object.setPrototypeOf||function(r,n){return r.__proto__=n,r},A(p,m)}var S=function(p){M(m,p);function m(){return p.apply(this,arguments)||this}var s=m.prototype;return s.resetInitSegment=function(n,u,o){p.prototype.resetInitSegment.call(this,n,u,o),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:n,duration:o,inputTimeScale:9e4,dropped:0}},m.probe=function(n){if(!n)return!1;for(var u=I.getID3Data(n,0)||[],o=u.length,t=n.length;o<t;o++)if(B.probe(n,o))return O.logger.log("MPEG Audio sync word found !"),!0;return!1},s.canParse=function(n,u){return B.canParse(n,u)},s.appendFrame=function(n,u,o){return this.initPTS===null?void 0:B.appendFrame(n,u,o,this.initPTS,this.frameIndex)},m}(j.default);S.minProbeByteLength=4,G.default=S},"./src/demux/mp4demuxer.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/utils/mp4-tools.ts"),I=w("./src/demux/dummy-demuxed-track.ts"),O=function(){function B(A,S){this.remainderData=null,this.config=void 0,this.config=S}var M=B.prototype;return M.resetTimeStamp=function(){},M.resetInitSegment=function(){},M.resetContiguity=function(){},B.probe=function(S){return Object(j.findBox)({data:S,start:0,end:Math.min(S.length,16384)},["moof"]).length>0},M.demux=function(S){var p=S,m=Object(I.dummyTrack)();if(this.config.progressive){this.remainderData&&(p=Object(j.appendUint8Array)(this.remainderData,S));var s=Object(j.segmentValidRange)(p);this.remainderData=s.remainder,m.samples=s.valid||new Uint8Array}else m.samples=p;return{audioTrack:Object(I.dummyTrack)(),avcTrack:m,id3Track:Object(I.dummyTrack)(),textTrack:Object(I.dummyTrack)()}},M.flush=function(){var S=Object(I.dummyTrack)();return S.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(I.dummyTrack)(),avcTrack:S,id3Track:Object(I.dummyTrack)(),textTrack:Object(I.dummyTrack)()}},M.demuxSampleAes=function(S,p,m){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},M.destroy=function(){},B}();O.minProbeByteLength=1024,G.default=O},"./src/demux/mpegaudio.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"appendFrame",function(){return A}),w.d(G,"parseHeader",function(){return S}),w.d(G,"isHeaderPattern",function(){return p}),w.d(G,"isHeader",function(){return m}),w.d(G,"canParse",function(){return s}),w.d(G,"probe",function(){return r});var j=null,I=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],O=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],B=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],M=[0,1,1,4];function A(n,u,o,t,e){if(o+24>u.length)return;var i=S(u,o);if(i&&o+i.frameLength<=u.length){var T=i.samplesPerFrame*9e4/i.sampleRate,_=t+e*T,y={unit:u.subarray(o,o+i.frameLength),pts:_,dts:_};return n.config=[],n.channelCount=i.channelCount,n.samplerate=i.sampleRate,n.samples.push(y),{sample:y,length:i.frameLength,missing:0}}}function S(n,u){var o=n[u+1]>>3&3,t=n[u+1]>>1&3,e=n[u+2]>>4&15,i=n[u+2]>>2&3;if(o!==1&&e!==0&&e!==15&&i!==3){var T=n[u+2]>>1&1,_=n[u+3]>>6,y=o===3?3-t:t===3?3:4,E=I[y*14+e-1]*1e3,b=o===3?0:o===2?1:2,g=O[b*3+i],d=_===3?1:2,a=B[o][t],l=M[t],f=a*8*l,c=Math.floor(a*E/g+T)*l;if(j===null){var x=navigator.userAgent||"",R=x.match(/Chrome\/(\d+)/i);j=R?parseInt(R[1]):0}var C=!!j&&j<=87;return C&&t===2&&E>=224e3&&_===0&&(n[u+3]=n[u+3]|128),{sampleRate:g,channelCount:d,frameLength:c,samplesPerFrame:f}}}function p(n,u){return n[u]===255&&(n[u+1]&224)===224&&(n[u+1]&6)!==0}function m(n,u){return u+1<n.length&&p(n,u)}function s(n,u){var o=4;return p(n,u)&&o<=n.length-u}function r(n,u){if(u+1<n.length&&p(n,u)){var o=4,t=S(n,u),e=o;t!=null&&t.frameLength&&(e=t.frameLength);var i=u+e;return i===n.length||m(n,i)}return!1}},"./src/demux/sample-aes.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/crypt/decrypter.ts"),I=w("./src/demux/tsdemuxer.ts"),O=function(){function B(A,S,p){this.keyData=void 0,this.decrypter=void 0,this.keyData=p,this.decrypter=new j.default(A,S,{removePKCS7Padding:!1})}var M=B.prototype;return M.decryptBuffer=function(S,p){this.decrypter.decrypt(S,this.keyData.key.buffer,this.keyData.iv.buffer,p)},M.decryptAacSample=function(S,p,m,s){var r=S[p].unit,n=r.subarray(16,r.length-r.length%16),u=n.buffer.slice(n.byteOffset,n.byteOffset+n.length),o=this;this.decryptBuffer(u,function(t){var e=new Uint8Array(t);r.set(e,16),s||o.decryptAacSamples(S,p+1,m)})},M.decryptAacSamples=function(S,p,m){for(;;p++){if(p>=S.length){m();return}if(S[p].unit.length<32)continue;var s=this.decrypter.isSync();if(this.decryptAacSample(S,p,m,s),!s)return}},M.getAvcEncryptedData=function(S){for(var p=Math.floor((S.length-48)/160)*16+16,m=new Int8Array(p),s=0,r=32;r<=S.length-16;r+=160,s+=16)m.set(S.subarray(r,r+16),s);return m},M.getAvcDecryptedUnit=function(S,p){for(var m=new Uint8Array(p),s=0,r=32;r<=S.length-16;r+=160,s+=16)S.set(m.subarray(s,s+16),r);return S},M.decryptAvcSample=function(S,p,m,s,r,n){var u=Object(I.discardEPB)(r.data),o=this.getAvcEncryptedData(u),t=this;this.decryptBuffer(o.buffer,function(e){r.data=t.getAvcDecryptedUnit(u,e),n||t.decryptAvcSamples(S,p,m+1,s)})},M.decryptAvcSamples=function(S,p,m,s){if(S instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;p++,m=0){if(p>=S.length){s();return}for(var r=S[p].units;!(m>=r.length);m++){var n=r[m];if(n.data.length<=48||n.type!==1&&n.type!==5)continue;var u=this.decrypter.isSync();if(this.decryptAvcSample(S,p,m,s,n,u),!u)return}}},B}();G.default=O},"./src/demux/transmuxer-interface.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return r});var j=w("./node_modules/webworkify-webpack/index.js"),I=w.n(j),O=w("./src/events.ts"),B=w("./src/demux/transmuxer.ts"),M=w("./src/utils/logger.ts"),A=w("./src/errors.ts"),S=w("./src/utils/mediasource-helper.ts"),p=w("./node_modules/eventemitter3/index.js"),m=w.n(p),s=Object(S.getMediaSource)()||{isTypeSupported:function(){return!1}},r=function(){function n(o,t,e,i){var T=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=o,this.id=t,this.onTransmuxComplete=e,this.onFlush=i;var _=o.config,y=function(a,l){l=l||{},l.frag=T.frag,l.id=T.id,o.trigger(a,l)};this.observer=new p.EventEmitter,this.observer.on(O.Events.FRAG_DECRYPTED,y),this.observer.on(O.Events.ERROR,y);var E={mp4:s.isTypeSupported("video/mp4"),mpeg:s.isTypeSupported("audio/mpeg"),mp3:s.isTypeSupported('audio/mp4; codecs="mp3"')},b=navigator.vendor;if(_.enableWorker&&typeof Worker!="undefined"){M.logger.log("demuxing in webworker");var g;try{g=this.worker=j("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),g.addEventListener("message",this.onwmsg),g.onerror=function(d){o.trigger(O.Events.ERROR,{type:A.ErrorTypes.OTHER_ERROR,details:A.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(d.message+" ("+d.filename+":"+d.lineno+")")})},g.postMessage({cmd:"init",typeSupported:E,vendor:b,id:t,config:JSON.stringify(_)})}catch(d){M.logger.warn("Error in worker:",d),M.logger.error("Error while initializing DemuxerWorker, fallback to inline"),g&&self.URL.revokeObjectURL(g.objectURL),this.transmuxer=new B.default(this.observer,E,_,b,t),this.worker=null}}else this.transmuxer=new B.default(this.observer,E,_,b,t)}var u=n.prototype;return u.destroy=function(){var t=this.worker;if(t)t.removeEventListener("message",this.onwmsg),t.terminate(),this.worker=null;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var i=this.observer;i&&i.removeAllListeners(),this.observer=null},u.push=function(t,e,i,T,_,y,E,b,g,d){var a=this;g.transmuxing.start=self.performance.now();var l=this.transmuxer,f=this.worker,c=y?y.start:_.start,x=_.decryptdata,R=this.frag,C=!(R&&_.cc===R.cc),N=!(R&&g.level===R.level),U=R?g.sn-R.sn:-1,W=this.part?g.part-this.part.index:1,L=!N&&(U===1||U===0&&W===1),H=self.performance.now();(N||U||_.stats.parsing.start===0)&&(_.stats.parsing.start=H),y&&(W||!L)&&(y.stats.parsing.start=H);var K=new B.TransmuxState(C,L,b,N,c);if(!L||C){M.logger.log("[transmuxer-interface, "+_.type+"]: Starting new transmux session for sn: "+g.sn+" p: "+g.part+" level: "+g.level+" id: "+g.id+`
discontinuity: `+C+`
trackSwitch: `+N+`
contiguous: `+L+`
accurateTimeOffset: `+b+`
timeOffset: `+c);var $=new B.TransmuxConfig(i,T,e,E,d);this.configureTransmuxer($)}if(this.frag=_,this.part=y,f)f.postMessage({cmd:"demux",data:t,decryptdata:x,chunkMeta:g,state:K},t instanceof ArrayBuffer?[t]:[]);else if(l){var Q=l.push(t,x,g,K);Object(B.isPromise)(Q)?Q.then(function(ue){a.handleTransmuxComplete(ue)}):this.handleTransmuxComplete(Q)}},u.flush=function(t){var e=this;t.transmuxing.start=self.performance.now();var i=this.transmuxer,T=this.worker;if(T)T.postMessage({cmd:"flush",chunkMeta:t});else if(i){var _=i.flush(t);Object(B.isPromise)(_)?_.then(function(y){e.handleFlushResult(y,t)}):this.handleFlushResult(_,t)}},u.handleFlushResult=function(t,e){var i=this;t.forEach(function(T){i.handleTransmuxComplete(T)}),this.onFlush(e)},u.onWorkerMessage=function(t){var e=t.data,i=this.hls;switch(e.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(e.data);break}case"flush":{this.onFlush(e.data);break}default:{e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,i.trigger(e.event,e.data);break}}},u.configureTransmuxer=function(t){var e=this.worker,i=this.transmuxer;e?e.postMessage({cmd:"configure",config:t}):i&&i.configure(t)},u.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},n}()},"./src/demux/transmuxer-worker.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return A});var j=w("./src/demux/transmuxer.ts"),I=w("./src/events.ts"),O=w("./src/utils/logger.ts"),B=w("./node_modules/eventemitter3/index.js"),M=w.n(B);function A(r){var n=new B.EventEmitter,u=function(t,e){r.postMessage({event:t,data:e})};n.on(I.Events.FRAG_DECRYPTED,u),n.on(I.Events.ERROR,u),r.addEventListener("message",function(o){var t=o.data;switch(t.cmd){case"init":{var e=JSON.parse(t.config);r.transmuxer=new j.default(n,t.typeSupported,e,t.vendor,t.id),Object(O.enableLogs)(e.debug),u("init",null);break}case"configure":{r.transmuxer.configure(t.config);break}case"demux":{var i=r.transmuxer.push(t.data,t.decryptdata,t.chunkMeta,t.state);Object(j.isPromise)(i)?i.then(function(y){S(r,y)}):S(r,i);break}case"flush":{var T=t.chunkMeta,_=r.transmuxer.flush(T);Object(j.isPromise)(_)?_.then(function(y){m(r,y,T)}):m(r,_,T);break}default:break}})}function S(r,n){if(s(n.remuxResult))return;var u=[],o=n.remuxResult,t=o.audio,e=o.video;t&&p(u,t),e&&p(u,e),r.postMessage({event:"transmuxComplete",data:n},u)}function p(r,n){n.data1&&r.push(n.data1.buffer),n.data2&&r.push(n.data2.buffer)}function m(r,n,u){n.forEach(function(o){S(r,o)}),r.postMessage({event:"flush",data:u})}function s(r){return!r.audio&&!r.video&&!r.text&&!r.id3&&!r.initSegment}},"./src/demux/transmuxer.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return e}),w.d(G,"isPromise",function(){return _}),w.d(G,"TransmuxConfig",function(){return y}),w.d(G,"TransmuxState",function(){return E});var j=w("./src/events.ts"),I=w("./src/errors.ts"),O=w("./src/crypt/decrypter.ts"),B=w("./src/demux/aacdemuxer.ts"),M=w("./src/demux/mp4demuxer.ts"),A=w("./src/demux/tsdemuxer.ts"),S=w("./src/demux/mp3demuxer.ts"),p=w("./src/remux/mp4-remuxer.ts"),m=w("./src/remux/passthrough-remuxer.ts"),s=w("./src/demux/chunk-cache.ts"),r=w("./src/utils/mp4-tools.ts"),n=w("./src/utils/logger.ts"),u;try{u=self.performance.now.bind(self.performance)}catch(b){n.logger.debug("Unable to use Performance API on this environment"),u=self.Date.now}var o=[{demux:A.default,remux:p.default},{demux:M.default,remux:m.default},{demux:B.default,remux:p.default},{demux:S.default,remux:p.default}],t=1024;o.forEach(function(b){var g=b.demux;t=Math.max(t,g.minProbeByteLength)});var e=function(){function b(d,a,l,f,c){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=d,this.typeSupported=a,this.config=l,this.vendor=f,this.id=c}var g=b.prototype;return g.configure=function(a){this.transmuxConfig=a,this.decrypter&&this.decrypter.reset()},g.push=function(a,l,f,c){var x=this,R=f.transmuxing;R.executeStart=u();var C=new Uint8Array(a),N=this.cache,U=this.config,W=this.currentTransmuxState,L=this.transmuxConfig;c&&(this.currentTransmuxState=c);var H=i(C,l);if(H&&H.method==="AES-128"){var K=this.getDecrypter();if(U.enableSoftwareAES){var $=K.softwareDecrypt(C,H.key.buffer,H.iv.buffer);if(!$)return R.executeEnd=u(),T(f);C=new Uint8Array($)}else return this.decryptionPromise=K.webCryptoDecrypt(C,H.key.buffer,H.iv.buffer).then(function(ve){var Ce=x.push(ve,null,f);return x.decryptionPromise=null,Ce}),this.decryptionPromise}var Q=c||W,ue=Q.contiguous,ne=Q.discontinuity,se=Q.trackSwitch,le=Q.accurateTimeOffset,de=Q.timeOffset,re=L.audioCodec,Y=L.videoCodec,pe=L.defaultInitPts,Te=L.duration,xe=L.initSegmentData;if((ne||se)&&this.resetInitSegment(xe,re,Y,Te),ne&&this.resetInitialTimestamp(pe),ue||this.resetContiguity(),this.needsProbing(C,ne,se)){if(N.dataLength){var Se=N.flush();C=Object(r.appendUint8Array)(Se,C)}this.configureTransmuxer(C,L)}var Ae=this.transmux(C,H,de,le,f),fe=this.currentTransmuxState;return fe.contiguous=!0,fe.discontinuity=!1,fe.trackSwitch=!1,R.executeEnd=u(),Ae},g.flush=function(a){var l=this,f=a.transmuxing;f.executeStart=u();var c=this.decrypter,x=this.cache,R=this.currentTransmuxState,C=this.decryptionPromise;if(C)return C.then(function(){return l.flush(a)});var N=[],U=R.timeOffset;if(c){var W=c.flush();W&&N.push(this.push(W,null,a))}var L=x.dataLength;x.reset();var H=this.demuxer,K=this.remuxer;if(!H||!K)return L>=t&&this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),f.executeEnd=u(),[T(a)];var $=H.flush(U);return _($)?$.then(function(Q){return l.flushRemux(N,Q,a),N}):(this.flushRemux(N,$,a),N)},g.flushRemux=function(a,l,f){var c=l.audioTrack,x=l.avcTrack,R=l.id3Track,C=l.textTrack,N=this.currentTransmuxState,U=N.accurateTimeOffset,W=N.timeOffset;n.logger.log("[transmuxer.ts]: Flushed fragment "+f.sn+(f.part>-1?" p: "+f.part:"")+" of level "+f.level);var L=this.remuxer.remux(c,x,R,C,W,U,!0,this.id);a.push({remuxResult:L,chunkMeta:f}),f.transmuxing.executeEnd=u()},g.resetInitialTimestamp=function(a){var l=this.demuxer,f=this.remuxer;if(!l||!f)return;l.resetTimeStamp(a),f.resetTimeStamp(a)},g.resetContiguity=function(){var a=this.demuxer,l=this.remuxer;if(!a||!l)return;a.resetContiguity(),l.resetNextTimestamp()},g.resetInitSegment=function(a,l,f,c){var x=this.demuxer,R=this.remuxer;if(!x||!R)return;x.resetInitSegment(l,f,c),R.resetInitSegment(a,l,f)},g.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},g.transmux=function(a,l,f,c,x){var R;return l&&l.method==="SAMPLE-AES"?R=this.transmuxSampleAes(a,l,f,c,x):R=this.transmuxUnencrypted(a,f,c,x),R},g.transmuxUnencrypted=function(a,l,f,c){var x=this.demuxer.demux(a,l,!1,!this.config.progressive),R=x.audioTrack,C=x.avcTrack,N=x.id3Track,U=x.textTrack,W=this.remuxer.remux(R,C,N,U,l,f,!1,this.id);return{remuxResult:W,chunkMeta:c}},g.transmuxSampleAes=function(a,l,f,c,x){var R=this;return this.demuxer.demuxSampleAes(a,l,f).then(function(C){var N=R.remuxer.remux(C.audioTrack,C.avcTrack,C.id3Track,C.textTrack,f,c,!1,R.id);return{remuxResult:N,chunkMeta:x}})},g.configureTransmuxer=function(a,l){for(var f=this.config,c=this.observer,x=this.typeSupported,R=this.vendor,C=l.audioCodec,N=l.defaultInitPts,U=l.duration,W=l.initSegmentData,L=l.videoCodec,H,K=0,$=o.length;K<$;K++)if(o[K].demux.probe(a)){H=o[K];break}H||(n.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),H={demux:M.default,remux:m.default});var Q=this.demuxer,ue=this.remuxer,ne=H.remux,se=H.demux;(!ue||!(ue instanceof ne))&&(this.remuxer=new ne(c,f,x,R)),(!Q||!(Q instanceof se))&&(this.demuxer=new se(c,f,x),this.probe=se.probe),this.resetInitSegment(W,C,L,U),this.resetInitialTimestamp(N)},g.needsProbing=function(a,l,f){return!this.demuxer||!this.remuxer||l||f},g.getDecrypter=function(){var a=this.decrypter;return a||(a=this.decrypter=new O.default(this.observer,this.config)),a},b}();function i(b,g){var d=null;return b.byteLength>0&&g!=null&&g.key!=null&&g.iv!==null&&g.method!=null&&(d=g),d}var T=function(g){return{remuxResult:{},chunkMeta:g}};function _(b){return"then"in b&&b.then instanceof Function}var y=function(g,d,a,l,f){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=g,this.videoCodec=d,this.initSegmentData=a,this.duration=l,this.defaultInitPts=f},E=function(g,d,a,l,f){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=g,this.contiguous=d,this.accurateTimeOffset=a,this.trackSwitch=l,this.timeOffset=f}},"./src/demux/tsdemuxer.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"discardEPB",function(){return T});var j=w("./src/demux/adts.ts"),I=w("./src/demux/mpegaudio.ts"),O=w("./src/demux/exp-golomb.ts"),B=w("./src/demux/id3.ts"),M=w("./src/demux/sample-aes.ts"),A=w("./src/events.ts"),S=w("./src/utils/mp4-tools.ts"),p=w("./src/utils/logger.ts"),m=w("./src/errors.ts"),s={video:1,audio:2,id3:3,text:4},r=function(){function _(E,b,g){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=E,this.config=b,this.typeSupported=g}_.probe=function(b){var g=_.syncOffset(b);return g<0?!1:(g&&p.logger.warn("MPEG2-TS detected but first sync word found @ offset "+g+", junk ahead ?"),!0)},_.syncOffset=function(b){for(var g=Math.min(1e3,b.length-3*188),d=0;d<g;){if(b[d]===71&&b[d+188]===71&&b[d+2*188]===71)return d;d++}return-1},_.createTrack=function(b,g){return{container:b==="video"||b==="audio"?"video/mp2t":void 0,type:b,id:s[b],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:b==="audio"?g:void 0}};var y=_.prototype;return y.resetInitSegment=function(b,g,d){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=_.createTrack("video",d),this._audioTrack=_.createTrack("audio",d),this._id3Track=_.createTrack("id3",d),this._txtTrack=_.createTrack("text",d),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=b,this.videoCodec=g,this._duration=d},y.resetTimeStamp=function(){},y.resetContiguity=function(){var b=this._audioTrack,g=this._avcTrack,d=this._id3Track;b&&(b.pesData=null),g&&(g.pesData=null),d&&(d.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},y.demux=function(b,g,d,a){d===void 0&&(d=!1),a===void 0&&(a=!1),d||(this.sampleAes=null);var l,f=this._avcTrack,c=this._audioTrack,x=this._id3Track,R=f.pid,C=f.pesData,N=c.pid,U=x.pid,W=c.pesData,L=x.pesData,H=!1,K=this.pmtParsed,$=this._pmtId,Q=b.length;if(this.remainderData&&(b=Object(S.appendUint8Array)(this.remainderData,b),Q=b.length,this.remainderData=null),Q<188&&!a)return this.remainderData=b,{audioTrack:c,avcTrack:f,id3Track:x,textTrack:this._txtTrack};var ue=Math.max(0,_.syncOffset(b));Q-=(Q+ue)%188,Q<b.byteLength&&!a&&(this.remainderData=new Uint8Array(b.buffer,Q,b.buffer.byteLength-Q));for(var ne=ue;ne<Q;ne+=188)if(b[ne]===71){var se=!!(b[ne+1]&64),le=((b[ne+1]&31)<<8)+b[ne+2],de=(b[ne+3]&48)>>4,re=void 0;if(de>1){if(re=ne+5+b[ne+4],re===ne+188)continue}else re=ne+4;switch(le){case R:se&&(C&&(l=t(C))&&this.parseAVCPES(l,!1),C={data:[],size:0}),C&&(C.data.push(b.subarray(re,ne+188)),C.size+=ne+188-re);break;case N:se&&(W&&(l=t(W))&&(c.isAAC?this.parseAACPES(l):this.parseMPEGPES(l)),W={data:[],size:0}),W&&(W.data.push(b.subarray(re,ne+188)),W.size+=ne+188-re);break;case U:se&&(L&&(l=t(L))&&this.parseID3PES(l),L={data:[],size:0}),L&&(L.data.push(b.subarray(re,ne+188)),L.size+=ne+188-re);break;case 0:se&&(re+=b[re]+1),$=this._pmtId=u(b,re);break;case $:{se&&(re+=b[re]+1);var Y=o(b,re,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,d);R=Y.avc,R>0&&(f.pid=R),N=Y.audio,N>0&&(c.pid=N,c.isAAC=Y.isAAC),U=Y.id3,U>0&&(x.pid=U),H&&!K&&(p.logger.log("reparse from beginning"),H=!1,ne=ue-188),K=this.pmtParsed=!0;break}case 17:case 8191:break;default:H=!0;break}}else this.observer.emit(A.Events.ERROR,A.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});f.pesData=C,c.pesData=W,x.pesData=L;var pe={audioTrack:c,avcTrack:f,id3Track:x,textTrack:this._txtTrack};return a&&this.extractRemainingSamples(pe),pe},y.flush=function(){var b=this.remainderData;this.remainderData=null;var g;return b?g=this.demux(b,-1,!1,!0):g={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(g),this.sampleAes?this.decrypt(g,this.sampleAes):g},y.extractRemainingSamples=function(b){var g=b.audioTrack,d=b.avcTrack,a=b.id3Track,l=d.pesData,f=g.pesData,c=a.pesData,x;l&&(x=t(l))?(this.parseAVCPES(x,!0),d.pesData=null):d.pesData=l,f&&(x=t(f))?(g.isAAC?this.parseAACPES(x):this.parseMPEGPES(x),g.pesData=null):(f!=null&&f.size&&p.logger.log("last AAC PES packet truncated,might overlap between fragments"),g.pesData=f),c&&(x=t(c))?(this.parseID3PES(x),a.pesData=null):a.pesData=c},y.demuxSampleAes=function(b,g,d){var a=this.demux(b,d,!0,!this.config.progressive),l=this.sampleAes=new M.default(this.observer,this.config,g);return this.decrypt(a,l)},y.decrypt=function(b,g){return new Promise(function(d){var a=b.audioTrack,l=b.avcTrack;a.samples&&a.isAAC?g.decryptAacSamples(a.samples,0,function(){l.samples?g.decryptAvcSamples(l.samples,0,0,function(){d(b)}):d(b)}):l.samples&&g.decryptAvcSamples(l.samples,0,0,function(){d(b)})})},y.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},y.parseAVCPES=function(b,g){var d=this,a=this._avcTrack,l=this.parseAVCNALu(b.data),f=!1,c=this.avcSample,x,R=!1;b.data=null,c&&l.length&&!a.audFound&&(e(c,a),c=this.avcSample=n(!1,b.pts,b.dts,"")),l.forEach(function(C){switch(C.type){case 1:{x=!0,c||(c=d.avcSample=n(!0,b.pts,b.dts,"")),f&&(c.debug+="NDR "),c.frame=!0;var N=C.data;if(R&&N.length>4){var U=new O.default(N).readSliceType();(U===2||U===4||U===7||U===9)&&(c.key=!0)}break}case 5:x=!0,c||(c=d.avcSample=n(!0,b.pts,b.dts,"")),f&&(c.debug+="IDR "),c.key=!0,c.frame=!0;break;case 6:{x=!0,f&&c&&(c.debug+="SEI ");var W=new O.default(T(C.data));W.readUByte();for(var L=0,H=0,K=!1,$=0;!K&&W.bytesAvailable>1;){L=0;do $=W.readUByte(),L+=$;while($===255);H=0;do $=W.readUByte(),H+=$;while($===255);if(L===4&&W.bytesAvailable!==0){K=!0;var Q=W.readUByte();if(Q===181){var ue=W.readUShort();if(ue===49){var ne=W.readUInt();if(ne===1195456820){var se=W.readUByte();if(se===3){for(var le=W.readUByte(),de=W.readUByte(),re=31&le,Y=[le,de],pe=0;pe<re;pe++)Y.push(W.readUByte()),Y.push(W.readUByte()),Y.push(W.readUByte());i(d._txtTrack.samples,{type:3,pts:b.pts,bytes:Y})}}}}}else if(L===5&&W.bytesAvailable!==0){if(K=!0,H>16){for(var Te=[],xe=0;xe<16;xe++)Te.push(W.readUByte().toString(16)),(xe===3||xe===5||xe===7||xe===9)&&Te.push("-");for(var Se=H-16,Ae=new Uint8Array(Se),fe=0;fe<Se;fe++)Ae[fe]=W.readUByte();i(d._txtTrack.samples,{pts:b.pts,payloadType:L,uuid:Te.join(""),userData:Object(B.utf8ArrayToStr)(Ae),userDataBytes:Ae})}}else if(H<W.bytesAvailable)for(var ve=0;ve<H;ve++)W.readUByte()}break}case 7:if(x=!0,R=!0,f&&c&&(c.debug+="SPS "),!a.sps){var Ce=new O.default(C.data),Oe=Ce.readSPS();a.width=Oe.width,a.height=Oe.height,a.pixelRatio=Oe.pixelRatio,a.sps=[C.data],a.duration=d._duration;for(var we=C.data.subarray(1,4),be="avc1.",me=0;me<3;me++){var Ue=we[me].toString(16);Ue.length<2&&(Ue="0"+Ue),be+=Ue}a.codec=be}break;case 8:x=!0,f&&c&&(c.debug+="PPS "),a.pps||(a.pps=[C.data]);break;case 9:x=!1,a.audFound=!0,c&&e(c,a),c=d.avcSample=n(!1,b.pts,b.dts,f?"AUD ":"");break;case 12:x=!1;break;default:x=!1,c&&(c.debug+="unknown NAL "+C.type+" ");break}if(c&&x){var Le=c.units;Le.push(C)}}),g&&c&&(e(c,a),this.avcSample=null)},y.getLastNalUnit=function(){var b,g=this.avcSample,d;if(!g||g.units.length===0){var a=this._avcTrack.samples;g=a[a.length-1]}if((b=g)!==null&&b!==void 0&&b.units){var l=g.units;d=l[l.length-1]}return d},y.parseAVCNALu=function(b){var g=b.byteLength,d=this._avcTrack,a=d.naluState||0,l=a,f=[],c=0,x,R,C,N=-1,U=0;for(a===-1&&(N=0,U=b[0]&31,a=0,c=1);c<g;){if(x=b[c++],!a){a=x?0:1;continue}if(a===1){a=x?0:2;continue}if(!x)a=3;else if(x===1){if(N>=0){var W={data:b.subarray(N,c-a-1),type:U};f.push(W)}else{var L=this.getLastNalUnit();if(L&&(l&&c<=4-l&&(L.state&&(L.data=L.data.subarray(0,L.data.byteLength-l))),R=c-a-1,R>0)){var H=new Uint8Array(L.data.byteLength+R);H.set(L.data,0),H.set(b.subarray(0,R),L.data.byteLength),L.data=H,L.state=0}}c<g?(C=b[c]&31,N=c,U=C,a=0):a=-1}else a=0}if(N>=0&&a>=0){var K={data:b.subarray(N,g),type:U,state:a};f.push(K)}if(f.length===0){var $=this.getLastNalUnit();if($){var Q=new Uint8Array($.data.byteLength+b.byteLength);Q.set($.data,0),Q.set(b,$.data.byteLength),$.data=Q}}return d.naluState=a,f},y.parseAACPES=function(b){var g=0,d=this._audioTrack,a=this.aacOverFlow,l=b.data;if(a){this.aacOverFlow=null;var f=a.sample.unit.byteLength,c=Math.min(a.missing,f),x=f-c;a.sample.unit.set(l.subarray(0,c),x),d.samples.push(a.sample),g=a.missing}var R,C;for(R=g,C=l.length;R<C-1&&!j.isHeader(l,R);R++);if(R!==g){var N,U;if(R<C-1?(N="AAC PES did not start with ADTS header,offset:"+R,U=!1):(N="no ADTS header found in AAC PES",U=!0),p.logger.warn("parsing error:"+N),this.observer.emit(A.Events.ERROR,A.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.FRAG_PARSING_ERROR,fatal:U,reason:N}),U)return}j.initTrackConfig(d,this.observer,l,R,this.audioCodec);var W;if(b.pts!==void 0)W=b.pts;else if(a){var L=j.getFrameDuration(d.samplerate);W=a.sample.pts+L}else{p.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var H=0;R<C;)if(j.isHeader(l,R)){if(R+5<C){var K=j.appendFrame(d,l,R,W,H);if(K)if(K.missing)this.aacOverFlow=K;else{R+=K.length,H++;continue}}break}else R++},y.parseMPEGPES=function(b){var g=b.data,d=g.length,a=0,l=0,f=b.pts;if(f===void 0){p.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<d;)if(I.isHeader(g,l)){var c=I.appendFrame(this._audioTrack,g,l,f,a);if(c)l+=c.length,a++;else break}else l++},y.parseID3PES=function(b){if(b.pts===void 0){p.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(b)},_}();r.minProbeByteLength=188;function n(_,y,E,b){return{key:_,frame:!1,pts:y,dts:E,units:[],debug:b,length:0}}function u(_,y){return(_[y+10]&31)<<8|_[y+11]}function o(_,y,E,b){var g={audio:-1,avc:-1,id3:-1,isAAC:!0},d=(_[y+1]&15)<<8|_[y+2],a=y+3+d-4,l=(_[y+10]&15)<<8|_[y+11];for(y+=12+l;y<a;){var f=(_[y+1]&31)<<8|_[y+2];switch(_[y]){case 207:if(!b){p.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:g.audio===-1&&(g.audio=f);break;case 21:g.id3===-1&&(g.id3=f);break;case 219:if(!b){p.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:g.avc===-1&&(g.avc=f);break;case 3:case 4:E?g.audio===-1&&(g.audio=f,g.isAAC=!1):p.logger.log("MPEG audio found, not supported in this browser");break;case 36:p.logger.warn("Unsupported HEVC stream type found");break;default:break}y+=((_[y+3]&15)<<8|_[y+4])+5}return g}function t(_){var y=0,E,b,g,d,a,l=_.data;if(!_||_.size===0)return null;for(;l[0].length<19&&l.length>1;){var f=new Uint8Array(l[0].length+l[1].length);f.set(l[0]),f.set(l[1],l[0].length),l[0]=f,l.splice(1,1)}E=l[0];var c=(E[0]<<16)+(E[1]<<8)+E[2];if(c===1){if(b=(E[4]<<8)+E[5],b&&b>_.size-6)return null;var x=E[7];x&192&&(d=(E[9]&14)*536870912+(E[10]&255)*4194304+(E[11]&254)*16384+(E[12]&255)*128+(E[13]&254)/2,x&64?(a=(E[14]&14)*536870912+(E[15]&255)*4194304+(E[16]&254)*16384+(E[17]&255)*128+(E[18]&254)/2,d-a>60*9e4&&(p.logger.warn(Math.round((d-a)/9e4)+"s delta between PTS and DTS, align them"),d=a)):a=d),g=E[8];var R=g+9;if(_.size<=R)return null;_.size-=R;for(var C=new Uint8Array(_.size),N=0,U=l.length;N<U;N++){E=l[N];var W=E.byteLength;if(R)if(R>W){R-=W;continue}else E=E.subarray(R),W-=R,R=0;C.set(E,y),y+=W}return b&&(b-=g+3),{data:C,pts:d,dts:a,len:b}}return null}function e(_,y){if(_.units.length&&_.frame){if(_.pts===void 0){var E=y.samples,b=E.length;if(b){var g=E[b-1];_.pts=g.pts,_.dts=g.dts}else{y.dropped++;return}}y.samples.push(_)}_.debug.length&&p.logger.log(_.pts+"/"+_.dts+":"+_.debug)}function i(_,y){var E=_.length;if(E>0){if(y.pts>=_[E-1].pts)_.push(y);else for(var b=E-1;b>=0;b--)if(y.pts<_[b].pts){_.splice(b,0,y);break}}else _.push(y)}function T(_){for(var y=_.byteLength,E=[],b=1;b<y-2;)_[b]===0&&_[b+1]===0&&_[b+2]===3?(E.push(b+2),b+=2):b++;if(E.length===0)return _;var g=y-E.length,d=new Uint8Array(g),a=0;for(b=0;b<g;a++,b++)a===E[0]&&(a++,E.shift()),d[b]=_[a];return d}G.default=r},"./src/errors.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"ErrorTypes",function(){return j}),w.d(G,"ErrorDetails",function(){return I});var j;(function(O){O.NETWORK_ERROR="networkError",O.MEDIA_ERROR="mediaError",O.KEY_SYSTEM_ERROR="keySystemError",O.MUX_ERROR="muxError",O.OTHER_ERROR="otherError"})(j||(j={}));var I;(function(O){O.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",O.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",O.KEY_SYSTEM_NO_SESSION="keySystemNoSession",O.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",O.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",O.MANIFEST_LOAD_ERROR="manifestLoadError",O.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",O.MANIFEST_PARSING_ERROR="manifestParsingError",O.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",O.LEVEL_EMPTY_ERROR="levelEmptyError",O.LEVEL_LOAD_ERROR="levelLoadError",O.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",O.LEVEL_SWITCH_ERROR="levelSwitchError",O.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",O.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",O.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",O.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",O.FRAG_LOAD_ERROR="fragLoadError",O.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",O.FRAG_DECRYPT_ERROR="fragDecryptError",O.FRAG_PARSING_ERROR="fragParsingError",O.REMUX_ALLOC_ERROR="remuxAllocError",O.KEY_LOAD_ERROR="keyLoadError",O.KEY_LOAD_TIMEOUT="keyLoadTimeOut",O.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",O.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",O.BUFFER_APPEND_ERROR="bufferAppendError",O.BUFFER_APPENDING_ERROR="bufferAppendingError",O.BUFFER_STALLED_ERROR="bufferStalledError",O.BUFFER_FULL_ERROR="bufferFullError",O.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",O.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",O.INTERNAL_EXCEPTION="internalException",O.INTERNAL_ABORTED="aborted",O.UNKNOWN="unknown"})(I||(I={}))},"./src/events.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"Events",function(){return j});var j;(function(I){I.MEDIA_ATTACHING="hlsMediaAttaching",I.MEDIA_ATTACHED="hlsMediaAttached",I.MEDIA_DETACHING="hlsMediaDetaching",I.MEDIA_DETACHED="hlsMediaDetached",I.BUFFER_RESET="hlsBufferReset",I.BUFFER_CODECS="hlsBufferCodecs",I.BUFFER_CREATED="hlsBufferCreated",I.BUFFER_APPENDING="hlsBufferAppending",I.BUFFER_APPENDED="hlsBufferAppended",I.BUFFER_EOS="hlsBufferEos",I.BUFFER_FLUSHING="hlsBufferFlushing",I.BUFFER_FLUSHED="hlsBufferFlushed",I.MANIFEST_LOADING="hlsManifestLoading",I.MANIFEST_LOADED="hlsManifestLoaded",I.MANIFEST_PARSED="hlsManifestParsed",I.LEVEL_SWITCHING="hlsLevelSwitching",I.LEVEL_SWITCHED="hlsLevelSwitched",I.LEVEL_LOADING="hlsLevelLoading",I.LEVEL_LOADED="hlsLevelLoaded",I.LEVEL_UPDATED="hlsLevelUpdated",I.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",I.LEVELS_UPDATED="hlsLevelsUpdated",I.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",I.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",I.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",I.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",I.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",I.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",I.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",I.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",I.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",I.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",I.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",I.CUES_PARSED="hlsCuesParsed",I.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",I.INIT_PTS_FOUND="hlsInitPtsFound",I.FRAG_LOADING="hlsFragLoading",I.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",I.FRAG_LOADED="hlsFragLoaded",I.FRAG_DECRYPTED="hlsFragDecrypted",I.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",I.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",I.FRAG_PARSING_METADATA="hlsFragParsingMetadata",I.FRAG_PARSED="hlsFragParsed",I.FRAG_BUFFERED="hlsFragBuffered",I.FRAG_CHANGED="hlsFragChanged",I.FPS_DROP="hlsFpsDrop",I.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",I.ERROR="hlsError",I.DESTROYING="hlsDestroying",I.KEY_LOADING="hlsKeyLoading",I.KEY_LOADED="hlsKeyLoaded",I.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",I.BACK_BUFFER_REACHED="hlsBackBufferReached"})(j||(j={}))},"./src/hls.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return _});var j=w("./node_modules/url-toolkit/src/url-toolkit.js"),I=w.n(j),O=w("./src/loader/playlist-loader.ts"),B=w("./src/loader/key-loader.ts"),M=w("./src/controller/id3-track-controller.ts"),A=w("./src/controller/latency-controller.ts"),S=w("./src/controller/level-controller.ts"),p=w("./src/controller/fragment-tracker.ts"),m=w("./src/controller/stream-controller.ts"),s=w("./src/is-supported.ts"),r=w("./src/utils/logger.ts"),n=w("./src/config.ts"),u=w("./node_modules/eventemitter3/index.js"),o=w.n(u),t=w("./src/events.ts"),e=w("./src/errors.ts");function i(y,E){for(var b=0;b<E.length;b++){var g=E[b];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(y,g.key,g)}}function T(y,E,b){return E&&i(y.prototype,E),b&&i(y,b),y}var _=function(){y.isSupported=function(){return Object(s.isSupported)()};function y(b){b===void 0&&(b={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new u.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 g=this.config=Object(n.mergeConfig)(y.DefaultConfig,b);this.userConfig=b,Object(r.enableLogs)(g.debug),this._autoLevelCapping=-1,g.progressive&&Object(n.enableStreamingMode)(g);var d=g.abrController,a=g.bufferController,l=g.capLevelController,f=g.fpsController,c=this.abrController=new d(this),x=this.bufferController=new a(this),R=this.capLevelController=new l(this),C=new f(this),N=new O.default(this),U=new B.default(this),W=new M.default(this),L=this.levelController=new S.default(this),H=new p.FragmentTracker(this),K=this.streamController=new m.default(this,H);R.setStreamController(K),C.setStreamController(K);var $=[L,K];this.networkControllers=$;var Q=[N,U,c,x,R,C,W,H];this.audioTrackController=this.createController(g.audioTrackController,null,$),this.createController(g.audioStreamController,H,$),this.subtitleTrackController=this.createController(g.subtitleTrackController,null,$),this.createController(g.subtitleStreamController,H,$),this.createController(g.timelineController,null,Q),this.emeController=this.createController(g.emeController,null,Q),this.cmcdController=this.createController(g.cmcdController,null,Q),this.latencyController=this.createController(A.default,null,Q),this.coreComponents=Q}var E=y.prototype;return E.createController=function(g,d,a){if(g){var l=d?new g(this,d):new g(this);return a&&a.push(l),l}return null},E.on=function(g,d,a){a===void 0&&(a=this),this._emitter.on(g,d,a)},E.once=function(g,d,a){a===void 0&&(a=this),this._emitter.once(g,d,a)},E.removeAllListeners=function(g){this._emitter.removeAllListeners(g)},E.off=function(g,d,a,l){a===void 0&&(a=this),this._emitter.off(g,d,a,l)},E.listeners=function(g){return this._emitter.listeners(g)},E.emit=function(g,d,a){return this._emitter.emit(g,d,a)},E.trigger=function(g,d){if(this.config.debug)return this.emit(g,g,d);try{return this.emit(g,g,d)}catch(a){r.logger.error("An internal error happened while handling event "+g+'. Error message: "'+a.message+'". Here is a stacktrace:',a),this.trigger(t.Events.ERROR,{type:e.ErrorTypes.OTHER_ERROR,details:e.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:g,error:a})}return!1},E.listenerCount=function(g){return this._emitter.listenerCount(g)},E.destroy=function(){r.logger.log("destroy"),this.trigger(t.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(g){return g.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(g){return g.destroy()}),this.coreComponents.length=0},E.attachMedia=function(g){r.logger.log("attachMedia"),this._media=g,this.trigger(t.Events.MEDIA_ATTACHING,{media:g})},E.detachMedia=function(){r.logger.log("detachMedia"),this.trigger(t.Events.MEDIA_DETACHING,void 0),this._media=null},E.loadSource=function(g){this.stopLoad();var d=this.media,a=this.url,l=this.url=j.buildAbsoluteURL(self.location.href,g,{alwaysNormalize:!0});r.logger.log("loadSource:"+l),d&&a&&a!==l&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(d)),this.trigger(t.Events.MANIFEST_LOADING,{url:g})},E.startLoad=function(g){g===void 0&&(g=-1),r.logger.log("startLoad("+g+")"),this.networkControllers.forEach(function(d){d.startLoad(g)})},E.stopLoad=function(){r.logger.log("stopLoad"),this.networkControllers.forEach(function(g){g.stopLoad()})},E.swapAudioCodec=function(){r.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},E.recoverMediaError=function(){r.logger.log("recoverMediaError");var g=this._media;this.detachMedia(),g&&this.attachMedia(g)},E.removeLevel=function(g,d){d===void 0&&(d=0),this.levelController.removeLevel(g,d)},T(y,[{key:"levels",get:function(){var g=this.levelController.levels;return g||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(g){r.logger.log("set currentLevel:"+g),this.loadLevel=g,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(g){r.logger.log("set nextLevel:"+g),this.levelController.manualLevel=g,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(g){r.logger.log("set loadLevel:"+g),this.levelController.manualLevel=g}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(g){this.levelController.nextLoadLevel=g}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(g){r.logger.log("set firstLevel:"+g),this.levelController.firstLevel=g}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(g){r.logger.log("set startLevel:"+g),g!==-1&&(g=Math.max(g,this.minAutoLevel)),this.levelController.startLevel=g}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(g){var d=!!g;d!==this.config.capLevelToPlayerSize&&(d?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=d)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(g){this._autoLevelCapping!==g&&(r.logger.log("set autoLevelCapping:"+g),this._autoLevelCapping=g)}},{key:"bandwidthEstimate",get:function(){var g=this.abrController.bwEstimator;return g?g.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var g=this.levels,d=this.config.minAutoBitrate;if(!g)return 0;for(var a=g.length,l=0;l<a;l++)if(g[l].maxBitrate>d)return l;return 0}},{key:"maxAutoLevel",get:function(){var g=this.levels,d=this.autoLevelCapping,a;return d===-1&&g&&g.length?a=g.length-1:a=d,a}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(g){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,g)}},{key:"audioTracks",get:function(){var g=this.audioTrackController;return g?g.audioTracks:[]}},{key:"audioTrack",get:function(){var g=this.audioTrackController;return g?g.audioTrack:-1},set:function(g){var d=this.audioTrackController;d&&(d.audioTrack=g)}},{key:"subtitleTracks",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTrack:-1},set:function(g){var d=this.subtitleTrackController;d&&(d.subtitleTrack=g)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var g=this.subtitleTrackController;return g?g.subtitleDisplay:!1},set:function(g){var d=this.subtitleTrackController;d&&(d.subtitleDisplay=g)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(g){this.config.lowLatencyMode=g}},{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 t.Events}},{key:"ErrorTypes",get:function(){return e.ErrorTypes}},{key:"ErrorDetails",get:function(){return e.ErrorDetails}},{key:"DefaultConfig",get:function(){return y.defaultConfig?y.defaultConfig:n.hlsDefaultConfig},set:function(g){y.defaultConfig=g}}]),y}();_.defaultConfig=void 0},"./src/is-supported.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"isSupported",function(){return O}),w.d(G,"changeTypeSupported",function(){return B});var j=w("./src/utils/mediasource-helper.ts");function I(){return self.SourceBuffer||self.WebKitSourceBuffer}function O(){var M=Object(j.getMediaSource)();if(!M)return!1;var A=I(),S=M&&typeof M.isTypeSupported=="function"&&M.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),p=!A||A.prototype&&typeof A.prototype.appendBuffer=="function"&&typeof A.prototype.remove=="function";return!!S&&!!p}function B(){var M,A=I();return typeof(A==null||((M=A.prototype)===null||M===void 0)?void 0:M.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return r}),w.d(G,"LoadError",function(){return u});var j=w("./src/polyfills/number.ts"),I=w("./src/errors.ts");function O(o,t){o.prototype=Object.create(t.prototype),o.prototype.constructor=o,p(o,t)}function B(o){var t=typeof Map=="function"?new Map:void 0;return B=function(i){if(i===null||!S(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t!="undefined"){if(t.has(i))return t.get(i);t.set(i,T)}function T(){return M(i,arguments,m(this).constructor)}return T.prototype=Object.create(i.prototype,{constructor:{value:T,enumerable:!1,writable:!0,configurable:!0}}),p(T,i)},B(o)}function M(o,t,e){return A()?M=Reflect.construct:M=function(T,_,y){var E=[null];E.push.apply(E,_);var b=Function.bind.apply(T,E),g=new b;return y&&p(g,y.prototype),g},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(o){return!1}}function S(o){return Function.toString.call(o).indexOf("[native code]")!==-1}function p(o,t){return p=Object.setPrototypeOf||function(i,T){return i.__proto__=T,i},p(o,t)}function m(o){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(o)}var s=Math.pow(2,17),r=function(){function o(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var t=o.prototype;return t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(i,T){var _=this,y=i.url;if(!y)return Promise.reject(new u({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:i,networkDetails:null},"Fragment does not have a "+(y?"part list":"url")));this.abort();var E=this.config,b=E.fLoader,g=E.loader;return new Promise(function(d,a){_.loader&&_.loader.destroy();var l=_.loader=i.loader=b?new b(E):new g(E),f=n(i),c={timeout:E.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:E.fragLoadingMaxRetryTimeout,highWaterMark:s};i.stats=l.stats,l.load(f,c,{onSuccess:function(R,C,N,U){_.resetLoader(i,l),d({frag:i,part:null,payload:R.data,networkDetails:U})},onError:function(R,C,N){_.resetLoader(i,l),a(new u({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:i,response:R,networkDetails:N}))},onAbort:function(R,C,N){_.resetLoader(i,l),a(new u({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:i,networkDetails:N}))},onTimeout:function(R,C,N){_.resetLoader(i,l),a(new u({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:i,networkDetails:N}))},onProgress:function(R,C,N,U){T&&T({frag:i,part:null,payload:N,networkDetails:U})}})})},t.loadPart=function(i,T,_){var y=this;this.abort();var E=this.config,b=E.fLoader,g=E.loader;return new Promise(function(d,a){y.loader&&y.loader.destroy();var l=y.loader=i.loader=b?new b(E):new g(E),f=n(i,T),c={timeout:E.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:E.fragLoadingMaxRetryTimeout,highWaterMark:s};T.stats=l.stats,l.load(f,c,{onSuccess:function(R,C,N,U){y.resetLoader(i,l),y.updateStatsFromPart(i,T);var W={frag:i,part:T,payload:R.data,networkDetails:U};_(W),d(W)},onError:function(R,C,N){y.resetLoader(i,l),a(new u({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:i,part:T,response:R,networkDetails:N}))},onAbort:function(R,C,N){i.stats.aborted=T.stats.aborted,y.resetLoader(i,l),a(new u({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:i,part:T,networkDetails:N}))},onTimeout:function(R,C,N){y.resetLoader(i,l),a(new u({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:i,part:T,networkDetails:N}))}})})},t.updateStatsFromPart=function(i,T){var _=i.stats,y=T.stats,E=y.total;if(_.loaded+=y.loaded,E){var b=Math.round(i.duration/T.duration),g=Math.min(Math.round(_.loaded/E),b),d=b-g,a=d*Math.round(_.loaded/g);_.total=_.loaded+a}else _.total=Math.max(_.loaded,_.total);var l=_.loading,f=y.loading;l.start?l.first+=f.first-f.start:(l.start=f.start,l.first=f.first),l.end=f.end},t.resetLoader=function(i,T){i.loader=null,this.loader===T&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),T.destroy()},o}();function n(o,t){t===void 0&&(t=null);var e=t||o,i={frag:o,part:t,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},T=e.byteRangeStartOffset,_=e.byteRangeEndOffset;return Object(j.isFiniteNumber)(T)&&Object(j.isFiniteNumber)(_)&&(i.rangeStart=T,i.rangeEnd=_),i}var u=function(o){O(t,o);function t(e){for(var i,T=arguments.length,_=new Array(T>1?T-1:0),y=1;y<T;y++)_[y-1]=arguments[y];return i=o.call.apply(o,[this].concat(_))||this,i.data=void 0,i.data=e,i}return t}(B(Error))},"./src/loader/fragment.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"ElementaryStreamTypes",function(){return r}),w.d(G,"BaseSegment",function(){return n}),w.d(G,"Fragment",function(){return u}),w.d(G,"Part",function(){return o});var j=w("./src/polyfills/number.ts"),I=w("./node_modules/url-toolkit/src/url-toolkit.js"),O=w.n(I),B=w("./src/utils/logger.ts"),M=w("./src/loader/level-key.ts"),A=w("./src/loader/load-stats.ts");function S(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,p(t,e)}function p(t,e){return p=Object.setPrototypeOf||function(T,_){return T.__proto__=_,T},p(t,e)}function m(t,e){for(var i=0;i<e.length;i++){var T=e[i];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(t,T.key,T)}}function s(t,e,i){return e&&m(t.prototype,e),i&&m(t,i),t}var r;(function(t){t.AUDIO="audio",t.VIDEO="video",t.AUDIOVIDEO="audiovideo"})(r||(r={}));var n=function(){function t(i){var T;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(T={},T[r.AUDIO]=null,T[r.VIDEO]=null,T[r.AUDIOVIDEO]=null,T),this.baseurl=i}var e=t.prototype;return e.setByteRange=function(T,_){var y=T.split("@",2),E=[];y.length===1?E[0]=_?_.byteRangeEndOffset:0:E[0]=parseInt(y[1]),E[1]=parseInt(y[0])+E[0],this._byteRange=E},s(t,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(I.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(T){this._url=T}}]),t}(),u=function(t){S(e,t);function e(T,_){var y;return y=t.call(this,_)||this,y._decryptdata=null,y.rawProgramDateTime=null,y.programDateTime=null,y.tagList=[],y.duration=0,y.sn=0,y.levelkey=void 0,y.type=void 0,y.loader=null,y.level=-1,y.cc=0,y.startPTS=void 0,y.endPTS=void 0,y.appendedPTS=void 0,y.startDTS=void 0,y.endDTS=void 0,y.start=0,y.deltaPTS=void 0,y.maxStartPTS=void 0,y.minEndPTS=void 0,y.stats=new A.LoadStats,y.urlId=0,y.data=void 0,y.bitrateTest=!1,y.title=null,y.initSegment=null,y.type=T,y}var i=e.prototype;return i.createInitializationVector=function(_){for(var y=new Uint8Array(16),E=12;E<16;E++)y[E]=_>>8*(15-E)&255;return y},i.setDecryptDataFromLevelKey=function(_,y){var E=_;return(_==null?void 0:_.method)==="AES-128"&&_.uri&&!_.iv&&(E=M.LevelKey.fromURI(_.uri),E.method=_.method,E.iv=this.createInitializationVector(y),E.keyFormat="identity"),E},i.setElementaryStreamInfo=function(_,y,E,b,g,d){d===void 0&&(d=!1);var a=this.elementaryStreams,l=a[_];if(!l){a[_]={startPTS:y,endPTS:E,startDTS:b,endDTS:g,partial:d};return}l.startPTS=Math.min(l.startPTS,y),l.endPTS=Math.max(l.endPTS,E),l.startDTS=Math.min(l.startDTS,b),l.endDTS=Math.max(l.endDTS,g)},i.clearElementaryStreamInfo=function(){var _=this.elementaryStreams;_[r.AUDIO]=null,_[r.VIDEO]=null,_[r.AUDIOVIDEO]=null},s(e,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var _=this.sn;typeof _!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&B.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),_=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,_)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(j.isFiniteNumber)(this.programDateTime))return null;var _=Object(j.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+_*1e3}},{key:"encrypted",get:function(){var _;return!!((_=this.decryptdata)!==null&&_!==void 0&&_.keyFormat&&this.decryptdata.uri)}}]),e}(n),o=function(t){S(e,t);function e(i,T,_,y,E){var b;b=t.call(this,_)||this,b.fragOffset=0,b.duration=0,b.gap=!1,b.independent=!1,b.relurl=void 0,b.fragment=void 0,b.index=void 0,b.stats=new A.LoadStats,b.duration=i.decimalFloatingPoint("DURATION"),b.gap=i.bool("GAP"),b.independent=i.bool("INDEPENDENT"),b.relurl=i.enumeratedString("URI"),b.fragment=T,b.index=y;var g=i.enumeratedString("BYTERANGE");return g&&b.setByteRange(g,E),E&&(b.fragOffset=E.fragOffset+E.duration),b}return s(e,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var T=this.elementaryStreams;return!!(T.audio||T.video||T.audiovideo)}}]),e}(n)},"./src/loader/key-loader.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return B});var j=w("./src/events.ts"),I=w("./src/errors.ts"),O=w("./src/utils/logger.ts"),B=function(){function M(S){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=S,this._registerListeners()}var A=M.prototype;return A._registerListeners=function(){this.hls.on(j.Events.KEY_LOADING,this.onKeyLoading,this)},A._unregisterListeners=function(){this.hls.off(j.Events.KEY_LOADING,this.onKeyLoading)},A.destroy=function(){this._unregisterListeners();for(var p in this.loaders){var m=this.loaders[p];m&&m.destroy()}this.loaders={}},A.onKeyLoading=function(p,m){var s=m.frag,r=s.type,n=this.loaders[r];if(!s.decryptdata){O.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var u=s.decryptdata.uri;if(u!==this.decrypturl||this.decryptkey===null){var o=this.hls.config;if(n&&(O.logger.warn("abort previous key loader for type:"+r),n.abort()),!u){O.logger.warn("key uri is falsy");return}var t=o.loader,e=s.loader=this.loaders[r]=new t(o);this.decrypturl=u,this.decryptkey=null;var i={url:u,frag:s,responseType:"arraybuffer"},T={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:o.fragLoadingRetryDelay,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:0},_={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};e.load(i,T,_)}else this.decryptkey&&(s.decryptdata.key=this.decryptkey,this.hls.trigger(j.Events.KEY_LOADED,{frag:s}))},A.loadsuccess=function(p,m,s){var r=s.frag;if(!r.decryptdata){O.logger.error("after key load, decryptdata unset");return}this.decryptkey=r.decryptdata.key=new Uint8Array(p.data),r.loader=null,delete this.loaders[r.type],this.hls.trigger(j.Events.KEY_LOADED,{frag:r})},A.loaderror=function(p,m){var s=m.frag,r=s.loader;r&&r.abort(),delete this.loaders[s.type],this.hls.trigger(j.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:s,response:p})},A.loadtimeout=function(p,m){var s=m.frag,r=s.loader;r&&r.abort(),delete this.loaders[s.type],this.hls.trigger(j.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:s})},M}()},"./src/loader/level-details.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"LevelDetails",function(){return M});var j=w("./src/polyfills/number.ts");function I(A,S){for(var p=0;p<S.length;p++){var m=S[p];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(A,m.key,m)}}function O(A,S,p){return S&&I(A.prototype,S),p&&I(A,p),A}var B=10,M=function(){function A(p){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=p}var S=A.prototype;return S.reloaded=function(m){if(!m){this.advanced=!0,this.updated=!0;return}var s=this.lastPartSn-m.lastPartSn,r=this.lastPartIndex-m.lastPartIndex;this.updated=this.endSN!==m.endSN||!!r||!!s,this.advanced=this.endSN>m.endSN||s>0||s===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(m.misses*.6):this.misses=m.misses+1,this.availabilityDelay=m.availabilityDelay},O(A,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(j.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||B}},{key:"drift",get:function(){var m=this.driftEndTime-this.driftStartTime;if(m>0){var s=this.driftEnd-this.driftStart;return s*1e3/m}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var m;return(m=this.partList)!==null&&m!==void 0&&m.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var m;return(m=this.fragments)!==null&&m!==void 0&&m.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 m;return(m=this.partList)!==null&&m!==void 0&&m.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var m;return(m=this.partList)!==null&&m!==void 0&&m.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),A}()},"./src/loader/level-key.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"LevelKey",function(){return M});var j=w("./node_modules/url-toolkit/src/url-toolkit.js"),I=w.n(j);function O(A,S){for(var p=0;p<S.length;p++){var m=S[p];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(A,m.key,m)}}function B(A,S,p){return S&&O(A.prototype,S),p&&O(A,p),A}var M=function(){A.fromURL=function(p,m){return new A(p,m)},A.fromURI=function(p){return new A(p)};function A(S,p){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,p?this._uri=Object(j.buildAbsoluteURL)(S,p,{alwaysNormalize:!0}):this._uri=S}return B(A,[{key:"uri",get:function(){return this._uri}}]),A}()},"./src/loader/load-stats.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"LoadStats",function(){return j});var j=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(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return e});var j=w("./src/polyfills/number.ts"),I=w("./node_modules/url-toolkit/src/url-toolkit.js"),O=w.n(I),B=w("./src/loader/fragment.ts"),M=w("./src/loader/level-details.ts"),A=w("./src/loader/level-key.ts"),S=w("./src/utils/attr-list.ts"),p=w("./src/utils/logger.ts"),m=w("./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,r=/#EXT-X-MEDIA:(.*)/g,n=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),u=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("|")),o=/\.(mp4|m4s|m4v|m4a)$/i;function t(E){var b,g;return o.test((b=(g=I.parseURL(E))===null||g===void 0?void 0:g.path)!=null?b:"")}var e=function(){function E(){}return E.findGroup=function(g,d){for(var a=0;a<g.length;a++){var l=g[a];if(l.id===d)return l}},E.convertAVC1ToAVCOTI=function(g){var d=g.split(".");if(d.length>2){var a=d.shift()+".";return a+=parseInt(d.shift()).toString(16),a+=("000"+parseInt(d.shift()).toString(16)).substr(-4),a}return g},E.resolve=function(g,d){return I.buildAbsoluteURL(d,g,{alwaysNormalize:!0})},E.parseMasterPlaylist=function(g,d){var a=[],l={},f=!1;s.lastIndex=0;for(var c;(c=s.exec(g))!=null;)if(c[1]){var x=new S.AttrList(c[1]),R={attrs:x,bitrate:x.decimalInteger("AVERAGE-BANDWIDTH")||x.decimalInteger("BANDWIDTH"),name:x.NAME,url:E.resolve(c[2],d)},C=x.decimalResolution("RESOLUTION");C&&(R.width=C.width,R.height=C.height),i((x.CODECS||"").split(/[ ,]+/).filter(function(U){return U}),R),R.videoCodec&&R.videoCodec.indexOf("avc1")!==-1&&(R.videoCodec=E.convertAVC1ToAVCOTI(R.videoCodec)),a.push(R)}else if(c[3]){var N=new S.AttrList(c[3]);N["DATA-ID"]&&(f=!0,l[N["DATA-ID"]]=N)}return{levels:a,sessionData:f?l:null}},E.parseMasterPlaylistMedia=function(g,d,a,l){l===void 0&&(l=[]);var f,c=[],x=0;for(r.lastIndex=0;(f=r.exec(g))!==null;){var R=new S.AttrList(f[1]);if(R.TYPE===a){var C={attrs:R,bitrate:0,id:x++,groupId:R["GROUP-ID"],instreamId:R["INSTREAM-ID"],name:R.NAME||R.LANGUAGE||"",type:a,default:R.bool("DEFAULT"),autoselect:R.bool("AUTOSELECT"),forced:R.bool("FORCED"),lang:R.LANGUAGE,url:R.URI?E.resolve(R.URI,d):""};if(l.length){var N=E.findGroup(l,C.groupId)||l[0];T(C,N,"audioCodec"),T(C,N,"textCodec")}c.push(C)}}return c},E.parseLevelPlaylist=function(g,d,a,l,f){var c=new M.LevelDetails(d),x=c.fragments,R=null,C=0,N=0,U=0,W=0,L=null,H=new B.Fragment(l,d),K,$,Q,ue=-1,ne=!1;for(n.lastIndex=0,c.m3u8=g;(K=n.exec(g))!==null;){ne&&(ne=!1,H=new B.Fragment(l,d),H.start=U,H.sn=C,H.cc=W,H.level=a,R&&(H.initSegment=R,H.rawProgramDateTime=R.rawProgramDateTime));var se=K[1];if(se){H.duration=parseFloat(se);var le=(" "+K[2]).slice(1);H.title=le||null,H.tagList.push(le?["INF",se,le]:["INF",se])}else if(K[3])Object(j.isFiniteNumber)(H.duration)&&(H.start=U,Q&&(H.levelkey=Q),H.sn=C,H.level=a,H.cc=W,H.urlId=f,x.push(H),H.relurl=(" "+K[3]).slice(1),y(H,L),L=H,U+=H.duration,C++,N=0,ne=!0);else if(K[4]){var de=(" "+K[4]).slice(1);L?H.setByteRange(de,L):H.setByteRange(de)}else if(K[5])H.rawProgramDateTime=(" "+K[5]).slice(1),H.tagList.push(["PROGRAM-DATE-TIME",H.rawProgramDateTime]),ue===-1&&(ue=x.length);else{if(K=K[0].match(u),!K){p.logger.warn("No matches on slow regex match for level playlist!");continue}for($=1;$<K.length&&!(typeof K[$]!="undefined");$++);var re=(" "+K[$]).slice(1),Y=(" "+K[$+1]).slice(1),pe=K[$+2]?(" "+K[$+2]).slice(1):"";switch(re){case"PLAYLIST-TYPE":c.type=Y.toUpperCase();break;case"MEDIA-SEQUENCE":C=c.startSN=parseInt(Y);break;case"SKIP":{var Te=new S.AttrList(Y),xe=Te.decimalInteger("SKIPPED-SEGMENTS");if(Object(j.isFiniteNumber)(xe)){c.skippedSegments=xe;for(var Se=xe;Se--;)x.unshift(null);C+=xe}var Ae=Te.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ae&&(c.recentlyRemovedDateranges=Ae.split(" "));break}case"TARGETDURATION":c.targetduration=parseFloat(Y);break;case"VERSION":c.version=parseInt(Y);break;case"EXTM3U":break;case"ENDLIST":c.live=!1;break;case"#":(Y||pe)&&H.tagList.push(pe?[Y,pe]:[Y]);break;case"DIS":W++;case"GAP":H.tagList.push([re]);break;case"BITRATE":H.tagList.push([re,Y]);break;case"DISCONTINUITY-SEQ":W=parseInt(Y);break;case"KEY":{var fe,ve=new S.AttrList(Y),Ce=ve.enumeratedString("METHOD"),Oe=ve.URI,we=ve.hexadecimalInteger("IV"),be=ve.enumeratedString("KEYFORMATVERSIONS"),me=ve.enumeratedString("KEYID"),Ue=(fe=ve.enumeratedString("KEYFORMAT"))!=null?fe:"identity",Le=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Le.indexOf(Ue)>-1){p.logger.warn("Keyformat "+Ue+" is not supported from the manifest");continue}else if(Ue!=="identity")continue;Ce&&(Q=A.LevelKey.fromURL(d,Oe),Oe&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Ce)>=0&&(Q.method=Ce,Q.keyFormat=Ue,me&&(Q.keyID=me),be&&(Q.keyFormatVersions=be),Q.iv=we));break}case"START":{var ke=new S.AttrList(Y),Pe=ke.decimalFloatingPoint("TIME-OFFSET");Object(j.isFiniteNumber)(Pe)&&(c.startTimeOffset=Pe);break}case"MAP":{var Be=new S.AttrList(Y);H.relurl=Be.URI,Be.BYTERANGE&&H.setByteRange(Be.BYTERANGE),H.level=a,H.sn="initSegment",Q&&(H.levelkey=Q),H.initSegment=null,R=H,ne=!0;break}case"SERVER-CONTROL":{var je=new S.AttrList(Y);c.canBlockReload=je.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=je.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&je.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=je.optionalFloat("PART-HOLD-BACK",0),c.holdBack=je.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Me=new S.AttrList(Y);c.partTarget=Me.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Re=c.partList;Re||(Re=c.partList=[]);var Fe=N>0?Re[Re.length-1]:void 0,Ne=N++,oe=new B.Part(new S.AttrList(Y),H,d,Ne,Fe);Re.push(oe),H.duration+=oe.duration;break}case"PRELOAD-HINT":{var Ee=new S.AttrList(Y);c.preloadHint=Ee;break}case"RENDITION-REPORT":{var ie=new S.AttrList(Y);c.renditionReports=c.renditionReports||[],c.renditionReports.push(ie);break}default:p.logger.warn("line parsed but not handled: "+K);break}}}L&&!L.relurl?(x.pop(),U-=L.duration,c.partList&&(c.fragmentHint=L)):c.partList&&(y(H,L),H.cc=W,c.fragmentHint=H);var J=x.length,te=x[0],z=x[J-1];if(U+=c.skippedSegments*c.targetduration,U>0&&J&&z){c.averagetargetduration=U/J;var V=z.sn;c.endSN=V!=="initSegment"?V:0,te&&(c.startCC=te.cc,te.initSegment||c.fragments.every(function(X){return X.relurl&&t(X.relurl)})&&(p.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),H=new B.Fragment(l,d),H.relurl=z.relurl,H.level=a,H.sn="initSegment",te.initSegment=H,c.needSidxRanges=!0))}else c.endSN=0,c.startCC=0;return c.fragmentHint&&(U+=c.fragmentHint.duration),c.totalduration=U,c.endCC=W,ue>0&&_(x,ue),c},E}();function i(E,b){["video","audio","text"].forEach(function(g){var d=E.filter(function(l){return Object(m.isCodecType)(l,g)});if(d.length){var a=d.filter(function(l){return l.lastIndexOf("avc1",0)===0||l.lastIndexOf("mp4a",0)===0});b[g+"Codec"]=a.length>0?a[0]:d[0],E=E.filter(function(l){return d.indexOf(l)===-1})}}),b.unknownCodecs=E}function T(E,b,g){var d=b[g];d&&(E[g]=d)}function _(E,b){for(var g=E[b],d=b;d--;){var a=E[d];if(!a)return;a.programDateTime=g.programDateTime-a.duration*1e3,g=a}}function y(E,b){E.rawProgramDateTime?E.programDateTime=Date.parse(E.rawProgramDateTime):b!=null&&b.programDateTime&&(E.programDateTime=b.endProgramDateTime),Object(j.isFiniteNumber)(E.programDateTime)||(E.programDateTime=null,E.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/polyfills/number.ts"),I=w("./src/events.ts"),O=w("./src/errors.ts"),B=w("./src/utils/logger.ts"),M=w("./src/utils/mp4-tools.ts"),A=w("./src/loader/m3u8-parser.ts"),S=w("./src/types/loader.ts"),p=w("./src/utils/attr-list.ts");function m(n){var u=n.type;switch(u){case S.PlaylistContextType.AUDIO_TRACK:return S.PlaylistLevelType.AUDIO;case S.PlaylistContextType.SUBTITLE_TRACK:return S.PlaylistLevelType.SUBTITLE;default:return S.PlaylistLevelType.MAIN}}function s(n,u){var o=n.url;return(o===void 0||o.indexOf("data:")===0)&&(o=u.url),o}var r=function(){function n(o){this.hls=void 0,this.loaders=Object.create(null),this.hls=o,this.registerListeners()}var u=n.prototype;return u.registerListeners=function(){var t=this.hls;t.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(I.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(I.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},u.unregisterListeners=function(){var t=this.hls;t.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(I.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(I.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},u.createInternalLoader=function(t){var e=this.hls.config,i=e.pLoader,T=e.loader,_=i||T,y=new _(e);return t.loader=y,this.loaders[t.type]=y,y},u.getInternalLoader=function(t){return this.loaders[t.type]},u.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},u.destroyInternalLoaders=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}},u.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},u.onManifestLoading=function(t,e){var i=e.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:S.PlaylistContextType.MANIFEST,url:i,deliveryDirectives:null})},u.onLevelLoading=function(t,e){var i=e.id,T=e.level,_=e.url,y=e.deliveryDirectives;this.load({id:i,groupId:null,level:T,responseType:"text",type:S.PlaylistContextType.LEVEL,url:_,deliveryDirectives:y})},u.onAudioTrackLoading=function(t,e){var i=e.id,T=e.groupId,_=e.url,y=e.deliveryDirectives;this.load({id:i,groupId:T,level:null,responseType:"text",type:S.PlaylistContextType.AUDIO_TRACK,url:_,deliveryDirectives:y})},u.onSubtitleTrackLoading=function(t,e){var i=e.id,T=e.groupId,_=e.url,y=e.deliveryDirectives;this.load({id:i,groupId:T,level:null,responseType:"text",type:S.PlaylistContextType.SUBTITLE_TRACK,url:_,deliveryDirectives:y})},u.load=function(t){var e,i=this.hls.config,T=this.getInternalLoader(t);if(T){var _=T.context;if(_&&_.url===t.url){B.logger.trace("[playlist-loader]: playlist request ongoing");return}B.logger.log("[playlist-loader]: aborting previous loader for type: "+t.type),T.abort()}var y,E,b,g;switch(t.type){case S.PlaylistContextType.MANIFEST:y=i.manifestLoadingMaxRetry,E=i.manifestLoadingTimeOut,b=i.manifestLoadingRetryDelay,g=i.manifestLoadingMaxRetryTimeout;break;case S.PlaylistContextType.LEVEL:case S.PlaylistContextType.AUDIO_TRACK:case S.PlaylistContextType.SUBTITLE_TRACK:y=0,E=i.levelLoadingTimeOut;break;default:y=i.levelLoadingMaxRetry,E=i.levelLoadingTimeOut,b=i.levelLoadingRetryDelay,g=i.levelLoadingMaxRetryTimeout;break}if(T=this.createInternalLoader(t),(e=t.deliveryDirectives)!==null&&e!==void 0&&e.part){var d;if(t.type===S.PlaylistContextType.LEVEL&&t.level!==null?d=this.hls.levels[t.level].details:t.type===S.PlaylistContextType.AUDIO_TRACK&&t.id!==null?d=this.hls.audioTracks[t.id].details:t.type===S.PlaylistContextType.SUBTITLE_TRACK&&t.id!==null&&(d=this.hls.subtitleTracks[t.id].details),d){var a=d.partTarget,l=d.targetduration;a&&l&&(E=Math.min(Math.max(a*3,l*.8)*1e3,E))}}var f={timeout:E,maxRetry:y,retryDelay:b,maxRetryDelay:g,highWaterMark:0},c={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};T.load(t,f,c)},u.loadsuccess=function(t,e,i,T){if(T===void 0&&(T=null),i.isSidxRequest){this.handleSidxRequest(t,i),this.handlePlaylistLoaded(t,e,i,T);return}this.resetInternalLoader(i.type);var _=t.data;if(_.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(t,i,"no EXTM3U delimiter",T);return}e.parsing.start=performance.now(),_.indexOf("#EXTINF:")>0||_.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(t,e,i,T):this.handleMasterPlaylist(t,e,i,T)},u.loaderror=function(t,e,i){i===void 0&&(i=null),this.handleNetworkError(e,i,!1,t)},u.loadtimeout=function(t,e,i){i===void 0&&(i=null),this.handleNetworkError(e,i,!0)},u.handleMasterPlaylist=function(t,e,i,T){var _=this.hls,y=t.data,E=s(t,i),b=A.default.parseMasterPlaylist(y,E),g=b.levels,d=b.sessionData;if(!g.length){this.handleManifestParsingError(t,i,"no level found in manifest",T);return}var a=g.map(function(C){return{id:C.attrs.AUDIO,audioCodec:C.audioCodec}}),l=g.map(function(C){return{id:C.attrs.SUBTITLES,textCodec:C.textCodec}}),f=A.default.parseMasterPlaylistMedia(y,E,"AUDIO",a),c=A.default.parseMasterPlaylistMedia(y,E,"SUBTITLES",l),x=A.default.parseMasterPlaylistMedia(y,E,"CLOSED-CAPTIONS");if(f.length){var R=f.some(function(C){return!C.url});!R&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(B.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),f.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new p.AttrList({}),bitrate:0,url:""}))}_.trigger(I.Events.MANIFEST_LOADED,{levels:g,audioTracks:f,subtitles:c,captions:x,url:E,stats:e,networkDetails:T,sessionData:d})},u.handleTrackOrLevelPlaylist=function(t,e,i,T){var _=this.hls,y=i.id,E=i.level,b=i.type,g=s(t,i),d=Object(j.isFiniteNumber)(y)?y:0,a=Object(j.isFiniteNumber)(E)?E:d,l=m(i),f=A.default.parseLevelPlaylist(t.data,g,a,l,d);if(!f.fragments.length){_.trigger(I.Events.ERROR,{type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:g,reason:"no fragments found in level",level:typeof i.level=="number"?i.level:void 0});return}if(b===S.PlaylistContextType.MANIFEST){var c={attrs:new p.AttrList({}),bitrate:0,details:f,name:"",url:g};_.trigger(I.Events.MANIFEST_LOADED,{levels:[c],audioTracks:[],url:g,stats:e,networkDetails:T,sessionData:null})}if(e.parsing.end=performance.now(),f.needSidxRanges){var x,R=(x=f.fragments[0].initSegment)===null||x===void 0?void 0:x.url;this.load({url:R,isSidxRequest:!0,type:b,level:E,levelDetails:f,id:y,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}i.levelDetails=f,this.handlePlaylistLoaded(t,e,i,T)},u.handleSidxRequest=function(t,e){var i=Object(M.parseSegmentIndex)(new Uint8Array(t.data));if(!i)return;var T=i.references,_=e.levelDetails;T.forEach(function(y,E){var b=y.info,g=_.fragments[E];g.byteRange.length===0&&g.setByteRange(String(1+b.end-b.start)+"@"+String(b.start)),g.initSegment&&g.initSegment.setByteRange(String(i.moovEndOffset)+"@0")})},u.handleManifestParsingError=function(t,e,i,T){this.hls.trigger(I.Events.ERROR,{type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:e.type===S.PlaylistContextType.MANIFEST,url:t.url,reason:i,response:t,context:e,networkDetails:T})},u.handleNetworkError=function(t,e,i,T){i===void 0&&(i=!1),B.logger.warn("[playlist-loader]: A network "+(i?"timeout":"error")+" occurred while loading "+t.type+" level: "+t.level+" id: "+t.id+' group-id: "'+t.groupId+'"');var _=O.ErrorDetails.UNKNOWN,y=!1,E=this.getInternalLoader(t);switch(t.type){case S.PlaylistContextType.MANIFEST:_=i?O.ErrorDetails.MANIFEST_LOAD_TIMEOUT:O.ErrorDetails.MANIFEST_LOAD_ERROR,y=!0;break;case S.PlaylistContextType.LEVEL:_=i?O.ErrorDetails.LEVEL_LOAD_TIMEOUT:O.ErrorDetails.LEVEL_LOAD_ERROR,y=!1;break;case S.PlaylistContextType.AUDIO_TRACK:_=i?O.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:O.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,y=!1;break;case S.PlaylistContextType.SUBTITLE_TRACK:_=i?O.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:O.ErrorDetails.SUBTITLE_LOAD_ERROR,y=!1;break}E&&this.resetInternalLoader(t.type);var b={type:O.ErrorTypes.NETWORK_ERROR,details:_,fatal:y,url:t.url,loader:E,context:t,networkDetails:e};T&&(b.response=T),this.hls.trigger(I.Events.ERROR,b)},u.handlePlaylistLoaded=function(t,e,i,T){var _=i.type,y=i.level,E=i.id,b=i.groupId,g=i.loader,d=i.levelDetails,a=i.deliveryDirectives;if(!(d!=null&&d.targetduration)){this.handleManifestParsingError(t,i,"invalid target duration",T);return}if(!g)return;d.live&&(g.getCacheAge&&(d.ageHeader=g.getCacheAge()||0),(!g.getCacheAge||isNaN(d.ageHeader))&&(d.ageHeader=0));switch(_){case S.PlaylistContextType.MANIFEST:case S.PlaylistContextType.LEVEL:this.hls.trigger(I.Events.LEVEL_LOADED,{details:d,level:y||0,id:E||0,stats:e,networkDetails:T,deliveryDirectives:a});break;case S.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(I.Events.AUDIO_TRACK_LOADED,{details:d,id:E||0,groupId:b||"",stats:e,networkDetails:T,deliveryDirectives:a});break;case S.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(I.Events.SUBTITLE_TRACK_LOADED,{details:d,id:E||0,groupId:b||"",stats:e,networkDetails:T,deliveryDirectives:a});break}},n}();G.default=r},"./src/polyfills/number.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"isFiniteNumber",function(){return j}),w.d(G,"MAX_SAFE_INTEGER",function(){return I});var j=Number.isFinite||function(O){return typeof O=="number"&&isFinite(O)},I=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(he,G,w){"use strict";w.r(G);var j=function(){function I(){}return I.getSilentFrame=function(B,M){switch(B){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},I}();G.default=j},"./src/remux/mp4-generator.ts":function(he,G,w){"use strict";w.r(G);var j=Math.pow(2,32)-1,I=function(){function O(){}return O.init=function(){O.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 O.types)O.types.hasOwnProperty(M)&&(O.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]),S=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]);O.HDLR_TYPES={video:A,audio:S};var p=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),m=new Uint8Array([0,0,0,0,0,0,0,0]);O.STTS=O.STSC=O.STCO=m,O.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),O.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),O.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),O.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),r=new Uint8Array([97,118,99,49]),n=new Uint8Array([0,0,0,1]);O.FTYP=O.box(O.types.ftyp,s,n,s,r),O.DINF=O.box(O.types.dinf,O.box(O.types.dref,p))},O.box=function(M){for(var A=8,S=arguments.length,p=new Array(S>1?S-1:0),m=1;m<S;m++)p[m-1]=arguments[m];for(var s=p.length,r=s;s--;)A+=p[s].byteLength;var n=new Uint8Array(A);for(n[0]=A>>24&255,n[1]=A>>16&255,n[2]=A>>8&255,n[3]=A&255,n.set(M,4),s=0,A=8;s<r;s++)n.set(p[s],A),A+=p[s].byteLength;return n},O.hdlr=function(M){return O.box(O.types.hdlr,O.HDLR_TYPES[M])},O.mdat=function(M){return O.box(O.types.mdat,M)},O.mdhd=function(M,A){A*=M;var S=Math.floor(A/(j+1)),p=Math.floor(A%(j+1));return O.box(O.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,S>>24,S>>16&255,S>>8&255,S&255,p>>24,p>>16&255,p>>8&255,p&255,85,196,0,0]))},O.mdia=function(M){return O.box(O.types.mdia,O.mdhd(M.timescale,M.duration),O.hdlr(M.type),O.minf(M))},O.mfhd=function(M){return O.box(O.types.mfhd,new Uint8Array([0,0,0,0,M>>24,M>>16&255,M>>8&255,M&255]))},O.minf=function(M){return M.type==="audio"?O.box(O.types.minf,O.box(O.types.smhd,O.SMHD),O.DINF,O.stbl(M)):O.box(O.types.minf,O.box(O.types.vmhd,O.VMHD),O.DINF,O.stbl(M))},O.moof=function(M,A,S){return O.box(O.types.moof,O.mfhd(M),O.traf(S,A))},O.moov=function(M){for(var A=M.length,S=[];A--;)S[A]=O.trak(M[A]);return O.box.apply(null,[O.types.moov,O.mvhd(M[0].timescale,M[0].duration)].concat(S).concat(O.mvex(M)))},O.mvex=function(M){for(var A=M.length,S=[];A--;)S[A]=O.trex(M[A]);return O.box.apply(null,[O.types.mvex].concat(S))},O.mvhd=function(M,A){A*=M;var S=Math.floor(A/(j+1)),p=Math.floor(A%(j+1)),m=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,S>>24,S>>16&255,S>>8&255,S&255,p>>24,p>>16&255,p>>8&255,p&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 O.box(O.types.mvhd,m)},O.sdtp=function(M){var A=M.samples||[],S=new Uint8Array(4+A.length),p,m;for(p=0;p<A.length;p++)m=A[p].flags,S[p+4]=m.dependsOn<<4|m.isDependedOn<<2|m.hasRedundancy;return O.box(O.types.sdtp,S)},O.stbl=function(M){return O.box(O.types.stbl,O.stsd(M),O.box(O.types.stts,O.STTS),O.box(O.types.stsc,O.STSC),O.box(O.types.stsz,O.STSZ),O.box(O.types.stco,O.STCO))},O.avc1=function(M){var A=[],S=[],p,m,s;for(p=0;p<M.sps.length;p++)m=M.sps[p],s=m.byteLength,A.push(s>>>8&255),A.push(s&255),A=A.concat(Array.prototype.slice.call(m));for(p=0;p<M.pps.length;p++)m=M.pps[p],s=m.byteLength,S.push(s>>>8&255),S.push(s&255),S=S.concat(Array.prototype.slice.call(m));var r=O.box(O.types.avcC,new Uint8Array([1,A[3],A[4],A[5],252|3,224|M.sps.length].concat(A).concat([M.pps.length]).concat(S))),n=M.width,u=M.height,o=M.pixelRatio[0],t=M.pixelRatio[1];return O.box(O.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,n>>8&255,n&255,u>>8&255,u&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]),r,O.box(O.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),O.box(O.types.pasp,new Uint8Array([o>>24,o>>16&255,o>>8&255,o&255,t>>24,t>>16&255,t>>8&255,t&255])))},O.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]))},O.mp4a=function(M){var A=M.samplerate;return O.box(O.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]),O.box(O.types.esds,O.esds(M)))},O.mp3=function(M){var A=M.samplerate;return O.box(O.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]))},O.stsd=function(M){return M.type==="audio"?!M.isAAC&&M.codec==="mp3"?O.box(O.types.stsd,O.STSD,O.mp3(M)):O.box(O.types.stsd,O.STSD,O.mp4a(M)):O.box(O.types.stsd,O.STSD,O.avc1(M))},O.tkhd=function(M){var A=M.id,S=M.duration*M.timescale,p=M.width,m=M.height,s=Math.floor(S/(j+1)),r=Math.floor(S%(j+1));return O.box(O.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,r>>24,r>>16&255,r>>8&255,r&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,p>>8&255,p&255,0,0,m>>8&255,m&255,0,0]))},O.traf=function(M,A){var S=O.sdtp(M),p=M.id,m=Math.floor(A/(j+1)),s=Math.floor(A%(j+1));return O.box(O.types.traf,O.box(O.types.tfhd,new Uint8Array([0,0,0,0,p>>24,p>>16&255,p>>8&255,p&255])),O.box(O.types.tfdt,new Uint8Array([1,0,0,0,m>>24,m>>16&255,m>>8&255,m&255,s>>24,s>>16&255,s>>8&255,s&255])),O.trun(M,S.length+16+20+8+16+8+8),S)},O.trak=function(M){return M.duration=M.duration||4294967295,O.box(O.types.trak,O.tkhd(M),O.mdia(M))},O.trex=function(M){var A=M.id;return O.box(O.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]))},O.trun=function(M,A){var S=M.samples||[],p=S.length,m=12+16*p,s=new Uint8Array(m),r,n,u,o,t,e;for(A+=8+m,s.set([0,0,15,1,p>>>24&255,p>>>16&255,p>>>8&255,p&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255],0),r=0;r<p;r++)n=S[r],u=n.duration,o=n.size,t=n.flags,e=n.cts,s.set([u>>>24&255,u>>>16&255,u>>>8&255,u&255,o>>>24&255,o>>>16&255,o>>>8&255,o&255,t.isLeading<<2|t.dependsOn,t.isDependedOn<<6|t.hasRedundancy<<4|t.paddingValue<<1|t.isNonSync,t.degradPrio&240<<8,t.degradPrio&15,e>>>24&255,e>>>16&255,e>>>8&255,e&255],12+16*r);return O.box(O.types.trun,s)},O.initSegment=function(M){O.types||O.init();var A=O.moov(M),S=new Uint8Array(O.FTYP.byteLength+A.byteLength);return S.set(O.FTYP),S.set(A,O.FTYP.byteLength),S},O}();I.types=void 0,I.HDLR_TYPES=void 0,I.STTS=void 0,I.STSC=void 0,I.STCO=void 0,I.STSZ=void 0,I.VMHD=void 0,I.SMHD=void 0,I.STSD=void 0,I.FTYP=void 0,I.DINF=void 0,G.default=I},"./src/remux/mp4-remuxer.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return e}),w.d(G,"normalizePts",function(){return i});var j=w("./src/polyfills/number.ts"),I=w("./src/remux/aac-helper.ts"),O=w("./src/remux/mp4-generator.ts"),B=w("./src/events.ts"),M=w("./src/errors.ts"),A=w("./src/utils/logger.ts"),S=w("./src/types/loader.ts"),p=w("./src/utils/timescale-conversion.ts");function m(){return m=Object.assign||function(E){for(var b=1;b<arguments.length;b++){var g=arguments[b];for(var d in g)Object.prototype.hasOwnProperty.call(g,d)&&(E[d]=g[d])}return E},m.apply(this,arguments)}var s=10*1e3,r=1024,n=1152,u=null,o=null,t=!1,e=function(){function E(g,d,a,l){if(l===void 0&&(l=""),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=g,this.config=d,this.typeSupported=a,this.ISGenerated=!1,u===null){var f=navigator.userAgent||"",c=f.match(/Chrome\/(\d+)/i);u=c?parseInt(c[1]):0}if(o===null){var x=navigator.userAgent.match(/Safari\/(\d+)/i);o=x?parseInt(x[1]):0}t=!!u&&u<75||!!o&&o<600}var b=E.prototype;return b.destroy=function(){},b.resetTimeStamp=function(d){A.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=d},b.resetNextTimestamp=function(){A.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},b.resetInitSegment=function(){A.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},b.getVideoStartPts=function(d){var a=!1,l=d.reduce(function(f,c){var x=c.pts-f;return x<-4294967296?(a=!0,i(f,c.pts)):x>0?f:c.pts},d[0].pts);return a&&A.logger.debug("PTS rollover detected"),l},b.remux=function(d,a,l,f,c,x,R,C){var N,U,W,L,H,K,$=c,Q=c,ue=d.pid>-1,ne=a.pid>-1,se=a.samples.length,le=d.samples.length>0,de=se>1,re=(!ue||le)&&(!ne||de)||this.ISGenerated||R;if(re){this.ISGenerated||(W=this.generateIS(d,a,c));var Y=this.isVideoContiguous,pe=-1;if(de&&(pe=T(a.samples),!Y&&this.config.forceKeyFrameOnDiscontinuity))if(K=!0,pe>0){A.logger.warn("[mp4-remuxer]: Dropped "+pe+" out of "+se+" video samples due to a missing keyframe");var Te=this.getVideoStartPts(a.samples);a.samples=a.samples.slice(pe),a.dropped+=pe,Q+=(a.samples[0].pts-Te)/(a.timescale||9e4)}else pe===-1&&(A.logger.warn("[mp4-remuxer]: No keyframe found out of "+se+" video samples"),K=!1);if(this.ISGenerated){if(le&&de){var xe=this.getVideoStartPts(a.samples),Se=i(d.samples[0].pts,xe)-xe,Ae=Se/a.inputTimeScale;$+=Math.max(0,Ae),Q+=Math.max(0,-Ae)}if(le){if(d.samplerate||(A.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),W=this.generateIS(d,a,c)),U=this.remuxAudio(d,$,this.isAudioContiguous,x,ne||de||C===S.PlaylistLevelType.AUDIO?Q:void 0),de){var fe=U?U.endPTS-U.startPTS:0;a.inputTimeScale||(A.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),W=this.generateIS(d,a,c)),N=this.remuxVideo(a,Q,Y,fe)}}else de&&(N=this.remuxVideo(a,Q,Y,0));N&&(N.firstKeyFrame=pe,N.independent=pe!==-1)}}return this.ISGenerated&&(l.samples.length&&(H=this.remuxID3(l,c)),f.samples.length&&(L=this.remuxText(f,c))),{audio:U,video:N,initSegment:W,independent:K,text:L,id3:H}},b.generateIS=function(d,a,l){var f=d.samples,c=a.samples,x=this.typeSupported,R={},C=!Object(j.isFiniteNumber)(this._initPTS),N="audio/mp4",U,W,L;if(C&&(U=W=Infinity),d.config&&f.length&&(d.timescale=d.samplerate,d.isAAC||(x.mpeg?(N="audio/mpeg",d.codec=""):x.mp3&&(d.codec="mp3")),R.audio={id:"audio",container:N,codec:d.codec,initSegment:!d.isAAC&&x.mpeg?new Uint8Array(0):O.default.initSegment([d]),metadata:{channelCount:d.channelCount}},C&&(L=d.inputTimeScale,U=W=f[0].pts-Math.round(L*l))),a.sps&&a.pps&&c.length&&(a.timescale=a.inputTimeScale,R.video={id:"main",container:"video/mp4",codec:a.codec,initSegment:O.default.initSegment([a]),metadata:{width:a.width,height:a.height}},C)){L=a.inputTimeScale;var H=this.getVideoStartPts(c),K=Math.round(L*l);W=Math.min(W,i(c[0].dts,H)-K),U=Math.min(U,H-K)}if(Object.keys(R).length)return this.ISGenerated=!0,C&&(this._initPTS=U,this._initDTS=W),{tracks:R,initPTS:U,timescale:L}},b.remuxVideo=function(d,a,l,f){var c=d.inputTimeScale,x=d.samples,R=[],C=x.length,N=this._initPTS,U=this.nextAvcDts,W=8,L,H,K,$=Number.POSITIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,ue=0,ne=!1;if(!l||U===null){var se=a*c,le=x[0].pts-i(x[0].dts,x[0].pts);U=se-le}for(var de=0;de<C;de++){var re=x[de];if(re.pts=i(re.pts-N,U),re.dts=i(re.dts-N,U),re.dts>re.pts){var Y=9e4*.2;ue=Math.max(Math.min(ue,re.pts-re.dts),-1*Y)}re.dts<x[de>0?de-1:de].dts&&(ne=!0)}ne&&x.sort(function(Xe,Qe){var Ke=Xe.dts-Qe.dts,rt=Xe.pts-Qe.pts;return Ke||rt}),H=x[0].dts,K=x[x.length-1].dts;var pe=Math.round((K-H)/(C-1));if(ue<0){if(ue<pe*-2){A.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(p.toMsFromMpegTsClock)(-pe,!0)+" ms");for(var Te=ue,xe=0;xe<C;xe++)x[xe].dts=Te=Math.max(Te,x[xe].pts-pe),x[xe].pts=Math.max(Te,x[xe].pts)}else{A.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(p.toMsFromMpegTsClock)(ue,!0)+" ms to overcome this issue");for(var Se=0;Se<C;Se++)x[Se].dts=x[Se].dts+ue}H=x[0].dts}if(l){var Ae=H-U,fe=Ae>pe,ve=Ae<-1;if(fe||ve){fe?A.logger.warn("AVC: "+Object(p.toMsFromMpegTsClock)(Ae,!0)+" ms ("+Ae+"dts) hole between fragments detected, filling it"):A.logger.warn("AVC: "+Object(p.toMsFromMpegTsClock)(-Ae,!0)+" ms ("+Ae+"dts) overlapping between fragments detected"),H=U;var Ce=x[0].pts-Ae;x[0].dts=H,x[0].pts=Ce,A.logger.log("Video: First PTS/DTS adjusted: "+Object(p.toMsFromMpegTsClock)(Ce,!0)+"/"+Object(p.toMsFromMpegTsClock)(H,!0)+", delta: "+Object(p.toMsFromMpegTsClock)(Ae,!0)+" ms")}}t&&(H=Math.max(0,H));for(var Oe=0,we=0,be=0;be<C;be++){for(var me=x[be],Ue=me.units,Le=Ue.length,ke=0,Pe=0;Pe<Le;Pe++)ke+=Ue[Pe].data.length;we+=ke,Oe+=Le,me.length=ke,me.dts=Math.max(me.dts,H),me.pts=Math.max(me.pts,me.dts,0),$=Math.min(me.pts,$),Q=Math.max(me.pts,Q)}K=x[C-1].dts;var Be=we+4*Oe+8,je;try{je=new Uint8Array(Be)}catch(Xe){this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:M.ErrorTypes.MUX_ERROR,details:M.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Be,reason:"fail allocating video mdat "+Be});return}var Me=new DataView(je.buffer);Me.setUint32(0,Be),je.set(O.default.types.mdat,4);for(var Re=0;Re<C;Re++){for(var Fe=x[Re],Ne=Fe.units,oe=0,Ee=0,ie=Ne.length;Ee<ie;Ee++){var J=Ne[Ee],te=J.data,z=J.data.byteLength;Me.setUint32(W,z),W+=4,je.set(te,W),W+=z,oe+=4+z}if(Re<C-1)L=x[Re+1].dts-Fe.dts;else{var V=this.config,X=Fe.dts-x[Re>0?Re-1:Re].dts;if(V.stretchShortVideoTrack&&this.nextAudioPts!==null){var q=Math.floor(V.maxBufferHole*c),ae=(f?$+f*c:this.nextAudioPts)-Fe.pts;ae>q?(L=ae-X,L<0&&(L=X),A.logger.log("[mp4-remuxer]: It is approximately "+ae/90+" ms to the next segment; using duration "+L/90+" ms for the last video frame.")):L=X}else L=X}var ce=Math.round(Fe.pts-Fe.dts);R.push(new _(Fe.key,L,oe,ce))}if(R.length&&u&&u<70){var _e=R[0].flags;_e.dependsOn=2,_e.isNonSync=0}console.assert(L!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=U=K+L,this.isVideoContiguous=!0;var We=O.default.moof(d.sequenceNumber++,H,m({},d,{samples:R})),ze="video",He={data1:We,data2:je,startPTS:$/c,endPTS:(Q+L)/c,startDTS:H/c,endDTS:U/c,type:ze,hasAudio:!1,hasVideo:!0,nb:R.length,dropped:d.dropped};return d.samples=[],d.dropped=0,console.assert(je.length,"MDAT length must not be zero"),He},b.remuxAudio=function(d,a,l,f,c){var x=d.inputTimeScale,R=d.samplerate?d.samplerate:x,C=x/R,N=d.isAAC?r:n,U=N*C,W=this._initPTS,L=!d.isAAC&&this.typeSupported.mpeg,H=[],K=d.samples,$=L?0:8,Q=this.nextAudioPts||-1,ue=a*x;if(this.isAudioContiguous=l=l||K.length&&Q>0&&(f&&Math.abs(ue-Q)<9e3||Math.abs(i(K[0].pts-W,ue)-Q)<20*U),K.forEach(function(te){te.pts=i(te.pts-W,ue)}),!l||Q<0){if(K=K.filter(function(te){return te.pts>=0}),!K.length)return;c===0?Q=0:f?Q=Math.max(0,ue):Q=K[0].pts}if(d.isAAC)for(var ne=c!==void 0,se=this.config.maxAudioFramesDrift,le=0,de=Q;le<K.length;le++){var re=K[le],Y=re.pts,pe=Y-de,Te=Math.abs(1e3*pe/x);if(pe<=-se*U&&ne)le===0&&(A.logger.warn("Audio frame @ "+(Y/x).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*pe/x)+" ms."),this.nextAudioPts=Q=de=Y);else if(pe>=se*U&&Te<s&&ne){var xe=Math.round(pe/U);de=Y-xe*U,de<0&&(xe--,de+=U),le===0&&(this.nextAudioPts=Q=de),A.logger.warn("[mp4-remuxer]: Injecting "+xe+" audio frame @ "+(de/x).toFixed(3)+"s due to "+Math.round(1e3*pe/x)+" ms gap.");for(var Se=0;Se<xe;Se++){var Ae=Math.max(de,0),fe=I.default.getSilentFrame(d.manifestCodec||d.codec,d.channelCount);fe||(A.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),fe=re.unit.subarray()),K.splice(le,0,{unit:fe,pts:Ae}),de+=U,le++}}re.pts=de,de+=U}for(var ve=null,Ce=null,Oe,we=0,be=K.length;be--;)we+=K[be].unit.byteLength;for(var me=0,Ue=K.length;me<Ue;me++){var Le=K[me],ke=Le.unit,Pe=Le.pts;if(Ce!==null){var Be=H[me-1];Be.duration=Math.round((Pe-Ce)/C)}else if(l&&d.isAAC&&(Pe=Q),ve=Pe,we>0){we+=$;try{Oe=new Uint8Array(we)}catch(te){this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:M.ErrorTypes.MUX_ERROR,details:M.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:we,reason:"fail allocating audio mdat "+we});return}if(!L){var je=new DataView(Oe.buffer);je.setUint32(0,we),Oe.set(O.default.types.mdat,4)}}else return;Oe.set(ke,$);var Me=ke.byteLength;$+=Me,H.push(new _(!0,N,Me,0)),Ce=Pe}var Re=H.length;if(!Re)return;var Fe=H[H.length-1];this.nextAudioPts=Q=Ce+C*Fe.duration;var Ne=L?new Uint8Array(0):O.default.moof(d.sequenceNumber++,ve/C,m({},d,{samples:H}));d.samples=[];var oe=ve/x,Ee=Q/x,ie="audio",J={data1:Ne,data2:Oe,startPTS:oe,endPTS:Ee,startDTS:oe,endDTS:Ee,type:ie,hasAudio:!0,hasVideo:!1,nb:Re};return this.isAudioContiguous=!0,console.assert(Oe.length,"MDAT length must not be zero"),J},b.remuxEmptyAudio=function(d,a,l,f){var c=d.inputTimeScale,x=d.samplerate?d.samplerate:c,R=c/x,C=this.nextAudioPts,N=(C!==null?C:f.startDTS*c)+this._initDTS,U=f.endDTS*c+this._initDTS,W=R*r,L=Math.ceil((U-N)/W),H=I.default.getSilentFrame(d.manifestCodec||d.codec,d.channelCount);if(A.logger.warn("[mp4-remuxer]: remux empty Audio"),!H){A.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var K=[],$=0;$<L;$++){var Q=N+$*W;K.push({unit:H,pts:Q,dts:Q})}return d.samples=K,this.remuxAudio(d,a,l,!1)},b.remuxID3=function(d,a){var l=d.samples.length;if(!l)return;for(var f=d.inputTimeScale,c=this._initPTS,x=this._initDTS,R=0;R<l;R++){var C=d.samples[R];C.pts=i(C.pts-c,a*f)/f,C.dts=i(C.dts-x,a*f)/f}var N=d.samples;return d.samples=[],{samples:N}},b.remuxText=function(d,a){var l=d.samples.length;if(!l)return;for(var f=d.inputTimeScale,c=this._initPTS,x=0;x<l;x++){var R=d.samples[x];R.pts=i(R.pts-c,a*f)/f}d.samples.sort(function(N,U){return N.pts-U.pts});var C=d.samples;return d.samples=[],{samples:C}},E}();function i(E,b){var g;if(b===null)return E;for(b<E?g=-8589934592:g=8589934592;Math.abs(E-b)>4294967296;)E+=g;return E}function T(E){for(var b=0;b<E.length;b++)if(E[b].key)return b;return-1}var _=function(b,g,d,a){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=g,this.size=d,this.cts=a,this.flags=new y(b)},y=function(b){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=b?2:1,this.isNonSync=b?0:1}},"./src/remux/passthrough-remuxer.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/polyfills/number.ts"),I=w("./src/utils/mp4-tools.ts"),O=w("./src/loader/fragment.ts"),B=w("./src/utils/logger.ts"),M=function(){function p(){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 m=p.prototype;return m.destroy=function(){},m.resetTimeStamp=function(r){this.initPTS=r,this.lastEndDTS=null},m.resetNextTimestamp=function(){this.lastEndDTS=null},m.resetInitSegment=function(r,n,u){this.audioCodec=n,this.videoCodec=u,this.generateInitSegment(r),this.emitInitSegment=!0},m.generateInitSegment=function(r){var n=this.audioCodec,u=this.videoCodec;if(!r||!r.byteLength){this.initTracks=void 0,this.initData=void 0;return}var o=this.initData=Object(I.parseInitSegment)(r);n||(n=S(o.audio,O.ElementaryStreamTypes.AUDIO)),u||(u=S(o.video,O.ElementaryStreamTypes.VIDEO));var t={};o.audio&&o.video?t.audiovideo={container:"video/mp4",codec:n+","+u,initSegment:r,id:"main"}:o.audio?t.audio={container:"audio/mp4",codec:n,initSegment:r,id:"audio"}:o.video?t.video={container:"video/mp4",codec:u,initSegment:r,id:"main"}:B.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=t},m.remux=function(r,n,u,o,t){var e=this.initPTS,i=this.lastEndDTS,T={audio:void 0,video:void 0,text:o,id3:u,initSegment:void 0};Object(j.isFiniteNumber)(i)||(i=this.lastEndDTS=t||0);var _=n.samples;if(!_||!_.length)return T;var y={initPTS:void 0,timescale:1},E=this.initData;if((!E||!E.length)&&(this.generateInitSegment(_),E=this.initData),!E||!E.length)return B.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),T;this.emitInitSegment&&(y.tracks=this.initTracks,this.emitInitSegment=!1),Object(j.isFiniteNumber)(e)||(this.initPTS=y.initPTS=e=A(E,_,i));var b=Object(I.getDuration)(_,E),g=i,d=b+g;Object(I.offsetStartDTS)(E,_,e),b>0?this.lastEndDTS=d:(B.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var a=!!E.audio,l=!!E.video,f="";a&&(f+="audio"),l&&(f+="video");var c={data1:_,startPTS:g,startDTS:g,endPTS:d,endDTS:d,type:f,hasAudio:a,hasVideo:l,nb:1,dropped:0};return T.audio=c.type==="audio"?c:void 0,T.video=c.type!=="audio"?c:void 0,T.text=o,T.id3=u,T.initSegment=y,T},p}(),A=function(m,s,r){return Object(I.getStartDTS)(m,s)-r};function S(p,m){var s=p==null?void 0:p.codec;return s&&s.length>4?s:s==="hvc1"?"hvc1.1.c.L120.90":s==="av01"?"av01.0.04M.08":s==="avc1"||m===O.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}G.default=M},"./src/task-loop.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return j});var j=function(){function I(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var O=I.prototype;return O.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},O.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},O.onHandlerDestroyed=function(){},O.hasInterval=function(){return!!this._tickInterval},O.hasNextTick=function(){return!!this._tickTimer},O.setInterval=function(M){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,M),!0)},O.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},O.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},O.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},O.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},O.doTick=function(){},I}()},"./src/types/cmcd.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"CMCDVersion",function(){return j}),w.d(G,"CMCDObjectType",function(){return I}),w.d(G,"CMCDStreamingFormat",function(){return O}),w.d(G,"CMCDStreamType",function(){return B});var j=1,I;(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"})(I||(I={}));var O;(function(M){M.DASH="d",M.HLS="h",M.SMOOTH="s",M.OTHER="o"})(O||(O={}));var B;(function(M){M.VOD="v",M.LIVE="l"})(B||(B={}))},"./src/types/level.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"HlsSkip",function(){return O}),w.d(G,"getSkipValue",function(){return B}),w.d(G,"HlsUrlParameters",function(){return M}),w.d(G,"Level",function(){return A});function j(S,p){for(var m=0;m<p.length;m++){var s=p[m];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(S,s.key,s)}}function I(S,p,m){return p&&j(S.prototype,p),m&&j(S,m),S}var O;(function(S){S.No="",S.Yes="YES",S.v2="v2"})(O||(O={}));function B(S,p){var m=S.canSkipUntil,s=S.canSkipDateRanges,r=S.endSN,n=p!==void 0?p-r:0;return m&&n<m?s?O.v2:O.Yes:O.No}var M=function(){function S(m,s,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=m,this.part=s,this.skip=r}var p=S.prototype;return p.addDirectives=function(s){var r=new self.URL(s);return this.msn!==void 0&&r.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&r.searchParams.set("_HLS_part",this.part.toString()),this.skip&&r.searchParams.set("_HLS_skip",this.skip),r.toString()},S}(),A=function(){function S(p){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=[p.url],this.attrs=p.attrs,this.bitrate=p.bitrate,p.details&&(this.details=p.details),this.id=p.id||0,this.name=p.name,this.width=p.width||0,this.height=p.height||0,this.audioCodec=p.audioCodec,this.videoCodec=p.videoCodec,this.unknownCodecs=p.unknownCodecs,this.codecSet=[p.videoCodec,p.audioCodec].filter(function(m){return m}).join(",").replace(/\.[^.,]+/g,"")}return I(S,[{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(m){var s=m%this.url.length;this._urlId!==s&&(this.details=void 0,this._urlId=s)}}]),S}()},"./src/types/loader.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"PlaylistContextType",function(){return j}),w.d(G,"PlaylistLevelType",function(){return I});var j;(function(O){O.MANIFEST="manifest",O.LEVEL="level",O.AUDIO_TRACK="audioTrack",O.SUBTITLE_TRACK="subtitleTrack"})(j||(j={}));var I;(function(O){O.MAIN="main",O.AUDIO="audio",O.SUBTITLE="subtitle"})(I||(I={}))},"./src/types/transmuxer.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"ChunkMetadata",function(){return j});var j=function(B,M,A,S,p,m){S===void 0&&(S=0),p===void 0&&(p=-1),m===void 0&&(m=!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=I(),this.buffering={audio:I(),video:I(),audiovideo:I()},this.level=B,this.sn=M,this.id=A,this.size=S,this.part=p,this.partial=m};function I(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"AttrList",function(){return O});var j=/^(\d+)x(\d+)$/,I=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,O=function(){function B(A){typeof A=="string"&&(A=B.parseAttrList(A));for(var S in A)A.hasOwnProperty(S)&&(this[S]=A[S])}var M=B.prototype;return M.decimalInteger=function(S){var p=parseInt(this[S],10);return p>Number.MAX_SAFE_INTEGER?Infinity:p},M.hexadecimalInteger=function(S){if(this[S]){var p=(this[S]||"0x").slice(2);p=(p.length&1?"0":"")+p;for(var m=new Uint8Array(p.length/2),s=0;s<p.length/2;s++)m[s]=parseInt(p.slice(s*2,s*2+2),16);return m}else return null},M.hexadecimalIntegerAsNumber=function(S){var p=parseInt(this[S],16);return p>Number.MAX_SAFE_INTEGER?Infinity:p},M.decimalFloatingPoint=function(S){return parseFloat(this[S])},M.optionalFloat=function(S,p){var m=this[S];return m?parseFloat(m):p},M.enumeratedString=function(S){return this[S]},M.bool=function(S){return this[S]==="YES"},M.decimalResolution=function(S){var p=j.exec(this[S]);return p===null?void 0:{width:parseInt(p[1],10),height:parseInt(p[2],10)}},B.parseAttrList=function(S){var p,m={},s='"';for(I.lastIndex=0;(p=I.exec(S))!==null;){var r=p[2];r.indexOf(s)===0&&r.lastIndexOf(s)===r.length-1&&(r=r.slice(1,-1)),m[p[1]]=r}return m},B}()},"./src/utils/binary-search.ts":function(he,G,w){"use strict";w.r(G);var j={search:function(O,B){for(var M=0,A=O.length-1,S=null,p=null;M<=A;){S=(M+A)/2|0,p=O[S];var m=B(p);if(m>0)M=S+1;else if(m<0)A=S-1;else return p}return null}};G.default=j},"./src/utils/buffer-helper.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"BufferHelper",function(){return O});var j=w("./src/utils/logger.ts"),I={length:0,start:function(){return 0},end:function(){return 0}},O=function(){function B(){}return B.isBuffered=function(A,S){try{if(A){for(var p=B.getBuffered(A),m=0;m<p.length;m++)if(S>=p.start(m)&&S<=p.end(m))return!0}}catch(s){}return!1},B.bufferInfo=function(A,S,p){try{if(A){var m=B.getBuffered(A),s=[],r;for(r=0;r<m.length;r++)s.push({start:m.start(r),end:m.end(r)});return this.bufferedInfo(s,S,p)}}catch(n){}return{len:0,start:S,end:S,nextStart:void 0}},B.bufferedInfo=function(A,S,p){S=Math.max(0,S),A.sort(function(y,E){var b=y.start-E.start;return b||E.end-y.end});var m=[];if(p)for(var s=0;s<A.length;s++){var r=m.length;if(r){var n=m[r-1].end;A[s].start-n<p?A[s].end>n&&(m[r-1].end=A[s].end):m.push(A[s])}else m.push(A[s])}else m=A;for(var u=0,o,t=S,e=S,i=0;i<m.length;i++){var T=m[i].start,_=m[i].end;if(S+p>=T&&S<_)t=T,e=_,u=e-S;else if(S+p<T){o=T;break}}return{len:u,start:t||0,end:e||0,nextStart:o}},B.getBuffered=function(A){try{return A.buffered}catch(S){return j.logger.log("failed to get media.buffered",S),I}},B}()},"./src/utils/cea-608-parser.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"Row",function(){return e}),w.d(G,"CaptionScreen",function(){return i});var j=w("./src/utils/logger.ts"),I={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},O=function(d){var a=d;return I.hasOwnProperty(d)&&(a=I[d]),String.fromCharCode(a)},B=15,M=100,A={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},S={17:2,18:4,21:6,22:8,23:10,19:13,20:15},p={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},m={25:2,26:4,29:6,30:8,31:10,27:13,28:15},s=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],r;(function(g){g[g.ERROR=0]="ERROR",g[g.TEXT=1]="TEXT",g[g.WARNING=2]="WARNING",g[g.INFO=2]="INFO",g[g.DEBUG=3]="DEBUG",g[g.DATA=3]="DATA"})(r||(r={}));var n=function(){function g(){this.time=null,this.verboseLevel=r.ERROR}var d=g.prototype;return d.log=function(l,f){this.verboseLevel>=l&&j.logger.log(this.time+" ["+l+"] "+f)},g}(),u=function(d){for(var a=[],l=0;l<d.length;l++)a.push(d[l].toString(16));return a},o=function(){function g(a,l,f,c,x){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=a||"white",this.underline=l||!1,this.italics=f||!1,this.background=c||"black",this.flash=x||!1}var d=g.prototype;return d.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},d.setStyles=function(l){for(var f=["foreground","underline","italics","background","flash"],c=0;c<f.length;c++){var x=f[c];l.hasOwnProperty(x)&&(this[x]=l[x])}},d.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},d.equals=function(l){return this.foreground===l.foreground&&this.underline===l.underline&&this.italics===l.italics&&this.background===l.background&&this.flash===l.flash},d.copy=function(l){this.foreground=l.foreground,this.underline=l.underline,this.italics=l.italics,this.background=l.background,this.flash=l.flash},d.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},g}(),t=function(){function g(a,l,f,c,x,R){this.uchar=void 0,this.penState=void 0,this.uchar=a||" ",this.penState=new o(l,f,c,x,R)}var d=g.prototype;return d.reset=function(){this.uchar=" ",this.penState.reset()},d.setChar=function(l,f){this.uchar=l,this.penState.copy(f)},d.setPenState=function(l){this.penState.copy(l)},d.equals=function(l){return this.uchar===l.uchar&&this.penState.equals(l.penState)},d.copy=function(l){this.uchar=l.uchar,this.penState.copy(l.penState)},d.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},g}(),e=function(){function g(a){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var l=0;l<M;l++)this.chars.push(new t);this.logger=a,this.pos=0,this.currPenState=new o}var d=g.prototype;return d.equals=function(l){for(var f=!0,c=0;c<M;c++)if(!this.chars[c].equals(l.chars[c])){f=!1;break}return f},d.copy=function(l){for(var f=0;f<M;f++)this.chars[f].copy(l.chars[f])},d.isEmpty=function(){for(var l=!0,f=0;f<M;f++)if(!this.chars[f].isEmpty()){l=!1;break}return l},d.setCursor=function(l){this.pos!==l&&(this.pos=l),this.pos<0?(this.logger.log(r.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>M&&(this.logger.log(r.DEBUG,"Too large cursor position "+this.pos),this.pos=M)},d.moveCursor=function(l){var f=this.pos+l;if(l>1)for(var c=this.pos+1;c<f+1;c++)this.chars[c].setPenState(this.currPenState);this.setCursor(f)},d.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},d.insertChar=function(l){l>=144&&this.backSpace();var f=O(l);if(this.pos>=M){this.logger.log(r.ERROR,"Cannot insert "+l.toString(16)+" ("+f+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(f,this.currPenState),this.moveCursor(1)},d.clearFromPos=function(l){var f;for(f=l;f<M;f++)this.chars[f].reset()},d.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},d.clearToEndOfRow=function(){this.clearFromPos(this.pos)},d.getTextString=function(){for(var l=[],f=!0,c=0;c<M;c++){var x=this.chars[c].uchar;x!==" "&&(f=!1),l.push(x)}return f?"":l.join("")},d.setPenStyles=function(l){this.currPenState.setStyles(l);var f=this.chars[this.pos];f.setPenState(this.currPenState)},g}(),i=function(){function g(a){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var l=0;l<B;l++)this.rows.push(new e(a));this.logger=a,this.currRow=B-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var d=g.prototype;return d.reset=function(){for(var l=0;l<B;l++)this.rows[l].clear();this.currRow=B-1},d.equals=function(l){for(var f=!0,c=0;c<B;c++)if(!this.rows[c].equals(l.rows[c])){f=!1;break}return f},d.copy=function(l){for(var f=0;f<B;f++)this.rows[f].copy(l.rows[f])},d.isEmpty=function(){for(var l=!0,f=0;f<B;f++)if(!this.rows[f].isEmpty()){l=!1;break}return l},d.backSpace=function(){var l=this.rows[this.currRow];l.backSpace()},d.clearToEndOfRow=function(){var l=this.rows[this.currRow];l.clearToEndOfRow()},d.insertChar=function(l){var f=this.rows[this.currRow];f.insertChar(l)},d.setPen=function(l){var f=this.rows[this.currRow];f.setPenStyles(l)},d.moveCursor=function(l){var f=this.rows[this.currRow];f.moveCursor(l)},d.setCursor=function(l){this.logger.log(r.INFO,"setCursor: "+l);var f=this.rows[this.currRow];f.setCursor(l)},d.setPAC=function(l){this.logger.log(r.INFO,"pacData = "+JSON.stringify(l));var f=l.row-1;if(this.nrRollUpRows&&f<this.nrRollUpRows-1&&(f=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==f){for(var c=0;c<B;c++)this.rows[c].clear();var x=this.currRow+1-this.nrRollUpRows,R=this.lastOutputScreen;if(R){var C=R.rows[x].cueStartTime,N=this.logger.time;if(C&&N!==null&&C<N)for(var U=0;U<this.nrRollUpRows;U++)this.rows[f-this.nrRollUpRows+U+1].copy(R.rows[x+U])}}this.currRow=f;var W=this.rows[this.currRow];if(l.indent!==null){var L=l.indent,H=Math.max(L-1,0);W.setCursor(l.indent),l.color=W.chars[H].penState.foreground}var K={foreground:l.color,underline:l.underline,italics:l.italics,background:"black",flash:!1};this.setPen(K)},d.setBkgData=function(l){this.logger.log(r.INFO,"bkgData = "+JSON.stringify(l)),this.backSpace(),this.setPen(l),this.insertChar(32)},d.setRollUpRows=function(l){this.nrRollUpRows=l},d.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(r.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(r.TEXT,this.getDisplayText());var l=this.currRow+1-this.nrRollUpRows,f=this.rows.splice(l,1)[0];f.clear(),this.rows.splice(this.currRow,0,f),this.logger.log(r.INFO,"Rolling up")},d.getDisplayText=function(l){l=l||!1;for(var f=[],c="",x=-1,R=0;R<B;R++){var C=this.rows[R].getTextString();C&&(x=R+1,l?f.push("Row "+x+": '"+C+"'"):f.push(C.trim()))}return f.length>0&&(l?c="["+f.join(" | ")+"]":c=f.join(`
`)),c},d.getTextAndFormat=function(){return this.rows},g}(),T=function(){function g(a,l,f){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=a,this.outputFilter=l,this.mode=null,this.verbose=0,this.displayedMemory=new i(f),this.nonDisplayedMemory=new i(f),this.lastOutputScreen=new i(f),this.currRollUpRow=this.displayedMemory.rows[B-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=f}var d=g.prototype;return d.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[B-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},d.getHandler=function(){return this.outputFilter},d.setHandler=function(l){this.outputFilter=l},d.setPAC=function(l){this.writeScreen.setPAC(l)},d.setBkgData=function(l){this.writeScreen.setBkgData(l)},d.setMode=function(l){if(l===this.mode)return;this.mode=l,this.logger.log(r.INFO,"MODE="+l),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=l},d.insertChars=function(l){for(var f=0;f<l.length;f++)this.writeScreen.insertChar(l[f]);var c=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(r.INFO,c+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(r.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},d.ccRCL=function(){this.logger.log(r.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},d.ccBS=function(){if(this.logger.log(r.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},d.ccAOF=function(){},d.ccAON=function(){},d.ccDER=function(){this.logger.log(r.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},d.ccRU=function(l){this.logger.log(r.INFO,"RU("+l+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(l)},d.ccFON=function(){this.logger.log(r.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},d.ccRDC=function(){this.logger.log(r.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},d.ccTR=function(){this.logger.log(r.INFO,"TR"),this.setMode("MODE_TEXT")},d.ccRTD=function(){this.logger.log(r.INFO,"RTD"),this.setMode("MODE_TEXT")},d.ccEDM=function(){this.logger.log(r.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},d.ccCR=function(){this.logger.log(r.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},d.ccENM=function(){this.logger.log(r.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},d.ccEOC=function(){if(this.logger.log(r.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var l=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=l,this.writeScreen=this.nonDisplayedMemory,this.logger.log(r.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},d.ccTO=function(l){this.logger.log(r.INFO,"TO("+l+") - Tab Offset"),this.writeScreen.moveCursor(l)},d.ccMIDROW=function(l){var f={flash:!1};if(f.underline=l%2===1,f.italics=l>=46,f.italics)f.foreground="white";else{var c=Math.floor(l/2)-16,x=["white","green","blue","cyan","red","yellow","magenta"];f.foreground=x[c]}this.logger.log(r.INFO,"MIDROW: "+JSON.stringify(f)),this.writeScreen.setPen(f)},d.outputDataUpdate=function(l){l===void 0&&(l=!1);var f=this.logger.time;if(f===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=f:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,f,this.lastOutputScreen),l&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:f),this.lastOutputScreen.copy(this.displayedMemory))},d.cueSplitAtTime=function(l){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,l,this.displayedMemory),this.cueStartTime=l))},g}(),_=function(){function g(a,l,f){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var c=new n;this.channels=[null,new T(a,l,c),new T(a+1,f,c)],this.cmdHistory=b(),this.logger=c}var d=g.prototype;return d.getHandler=function(l){return this.channels[l].getHandler()},d.setHandler=function(l,f){this.channels[l].setHandler(f)},d.addData=function(l,f){var c,x,R,C=!1;this.logger.time=l;for(var N=0;N<f.length;N+=2){if(x=f[N]&127,R=f[N+1]&127,x===0&&R===0)continue;if(this.logger.log(r.DATA,"["+u([f[N],f[N+1]])+"] -> ("+u([x,R])+")"),c=this.parseCmd(x,R),c||(c=this.parseMidrow(x,R)),c||(c=this.parsePAC(x,R)),c||(c=this.parseBackgroundAttributes(x,R)),!c&&(C=this.parseChars(x,R),C)){var U=this.currentChannel;if(U&&U>0){var W=this.channels[U];W.insertChars(C)}else this.logger.log(r.WARNING,"No channel found yet. TEXT-MODE?")}!c&&!C&&this.logger.log(r.WARNING,"Couldn't parse cleaned data "+u([x,R])+" orig: "+u([f[N],f[N+1]]))}},d.parseCmd=function(l,f){var c=this.cmdHistory,x=(l===20||l===28||l===21||l===29)&&f>=32&&f<=47,R=(l===23||l===31)&&f>=33&&f<=35;if(!(x||R))return!1;if(E(l,f,c))return y(null,null,c),this.logger.log(r.DEBUG,"Repeated command ("+u([l,f])+") is dropped"),!0;var C=l===20||l===21||l===23?1:2,N=this.channels[C];return l===20||l===21||l===28||l===29?f===32?N.ccRCL():f===33?N.ccBS():f===34?N.ccAOF():f===35?N.ccAON():f===36?N.ccDER():f===37?N.ccRU(2):f===38?N.ccRU(3):f===39?N.ccRU(4):f===40?N.ccFON():f===41?N.ccRDC():f===42?N.ccTR():f===43?N.ccRTD():f===44?N.ccEDM():f===45?N.ccCR():f===46?N.ccENM():f===47&&N.ccEOC():N.ccTO(f-32),y(l,f,c),this.currentChannel=C,!0},d.parseMidrow=function(l,f){var c=0;if((l===17||l===25)&&f>=32&&f<=47){if(l===17?c=1:c=2,c!==this.currentChannel)return this.logger.log(r.ERROR,"Mismatch channel in midrow parsing"),!1;var x=this.channels[c];return x?(x.ccMIDROW(f),this.logger.log(r.DEBUG,"MIDROW ("+u([l,f])+")"),!0):!1}return!1},d.parsePAC=function(l,f){var c,x=this.cmdHistory,R=(l>=17&&l<=23||l>=25&&l<=31)&&f>=64&&f<=127,C=(l===16||l===24)&&f>=64&&f<=95;if(!(R||C))return!1;if(E(l,f,x))return y(null,null,x),!0;var N=l<=23?1:2;f>=64&&f<=95?c=N===1?A[l]:p[l]:c=N===1?S[l]:m[l];var U=this.channels[N];return U?(U.setPAC(this.interpretPAC(c,f)),y(l,f,x),this.currentChannel=N,!0):!1},d.interpretPAC=function(l,f){var c,x={color:null,italics:!1,indent:null,underline:!1,row:l};return f>95?c=f-96:c=f-64,x.underline=(c&1)===1,c<=13?x.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(c/2)]:c<=15?(x.italics=!0,x.color="white"):x.indent=Math.floor((c-16)/2)*4,x},d.parseChars=function(l,f){var c,x=null,R=null;if(l>=25?(c=2,R=l-8):(c=1,R=l),R>=17&&R<=19){var C;R===17?C=f+80:R===18?C=f+112:C=f+144,this.logger.log(r.INFO,"Special char '"+O(C)+"' in channel "+c),x=[C]}else l>=32&&l<=127&&(x=f===0?[l]:[l,f]);if(x){var N=u(x);this.logger.log(r.DEBUG,"Char codes = "+N.join(",")),y(l,f,this.cmdHistory)}return x},d.parseBackgroundAttributes=function(l,f){var c=(l===16||l===24)&&f>=32&&f<=47,x=(l===23||l===31)&&f>=45&&f<=47;if(!(c||x))return!1;var R,C={};l===16||l===24?(R=Math.floor((f-32)/2),C.background=s[R],f%2===1&&(C.background=C.background+"_semi")):f===45?C.background="transparent":(C.foreground="black",f===47&&(C.underline=!0));var N=l<=23?1:2,U=this.channels[N];return U.setBkgData(C),y(l,f,this.cmdHistory),!0},d.reset=function(){for(var l=0;l<Object.keys(this.channels).length;l++){var f=this.channels[l];f&&f.reset()}this.cmdHistory=b()},d.cueSplitAtTime=function(l){for(var f=0;f<this.channels.length;f++){var c=this.channels[f];c&&c.cueSplitAtTime(l)}},g}();function y(g,d,a){a.a=g,a.b=d}function E(g,d,a){return a.a===g&&a.b===d}function b(){return{a:null,b:null}}G.default=_},"./src/utils/codecs.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"isCodecType",function(){return I}),w.d(G,"isCodecSupportedInMp4",function(){return O});var j={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 I(B,M){var A=j[M];return!!A&&A[B.slice(0,4)]===!0}function O(B,M){return MediaSource.isTypeSupported((M||"video")+'/mp4;codecs="'+B+'"')}},"./src/utils/cues.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/utils/vttparser.ts"),I=w("./src/utils/webvtt-parser.ts"),O=w("./src/utils/texttrack-utils.ts"),B=/\s/,M={newCue:function(S,p,m,s){for(var r=[],n,u,o,t,e,i=self.VTTCue||self.TextTrackCue,T=0;T<s.rows.length;T++)if(n=s.rows[T],o=!0,t=0,e="",!n.isEmpty()){for(var _=0;_<n.chars.length;_++)B.test(n.chars[_].uchar)&&o?t++:(e+=n.chars[_].uchar,o=!1);n.cueStartTime=p,p===m&&(m+=1e-4),t>=16?t--:t++;var y=Object(j.fixLineBreaks)(e.trim()),E=Object(I.generateCueId)(p,m,y);(!S||!S.cues||!S.cues.getCueById(E))&&(u=new i(p,m,y),u.id=E,u.line=T+1,u.align="left",u.position=10+Math.min(80,Math.floor(t*8/32)*10),r.push(u))}return S&&r.length&&(r.sort(function(b,g){return b.line==="auto"||g.line==="auto"?0:b.line>8&&g.line>8?g.line-b.line:b.line-g.line}),r.forEach(function(b){return Object(O.addCueToTrack)(S,b)})),r}};G.default=M},"./src/utils/discontinuities.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"findFirstFragWithCC",function(){return B}),w.d(G,"shouldAlignOnDiscontinuities",function(){return M}),w.d(G,"findDiscontinuousReferenceFrag",function(){return A}),w.d(G,"adjustSlidingStart",function(){return p}),w.d(G,"alignStream",function(){return m}),w.d(G,"alignPDT",function(){return r}),w.d(G,"alignFragmentByPDTDelta",function(){return n}),w.d(G,"alignMediaPlaylistByPDT",function(){return u});var j=w("./src/polyfills/number.ts"),I=w("./src/utils/logger.ts"),O=w("./src/controller/level-helper.ts");function B(o,t){for(var e=null,i=0,T=o.length;i<T;i++){var _=o[i];if(_&&_.cc===t){e=_;break}}return e}function M(o,t,e){return!!(t.details&&(e.endCC>e.startCC||o&&o.cc<e.startCC))}function A(o,t){var e=o.fragments,i=t.fragments;if(!i.length||!e.length){I.logger.log("No fragments to align");return}var T=B(e,i[0].cc);if(!T||T&&!T.startPTS){I.logger.log("No frag in previous level to align on");return}return T}function S(o,t){if(o){var e=o.start+t;o.start=o.startPTS=e,o.endPTS=e+o.duration}}function p(o,t){for(var e=t.fragments,i=0,T=e.length;i<T;i++)S(e[i],o);t.fragmentHint&&S(t.fragmentHint,o),t.alignedSliding=!0}function m(o,t,e){if(!t)return;s(o,e,t),!e.alignedSliding&&t.details&&r(e,t.details),!e.alignedSliding&&t.details&&!e.skippedSegments&&Object(O.adjustSliding)(t.details,e)}function s(o,t,e){if(M(o,e,t)){var i=A(e.details,t);i&&Object(j.isFiniteNumber)(i.start)&&(I.logger.log("Adjusting PTS using last level due to CC increase within current level "+t.url),p(i.start,t))}}function r(o,t){if(!t.fragments.length||!o.hasProgramDateTime||!t.hasProgramDateTime)return;var e=t.fragments[0].programDateTime,i=o.fragments[0].programDateTime,T=(i-e)/1e3+t.fragments[0].start;T&&Object(j.isFiniteNumber)(T)&&(I.logger.log("Adjusting PTS using programDateTime delta "+(i-e)+"ms, sliding:"+T.toFixed(3)+" "+o.url+" "),p(T,o))}function n(o,t){var e=o.programDateTime;if(!e)return;var i=(e-t)/1e3;o.start=o.startPTS=i,o.endPTS=i+o.duration}function u(o,t){if(!t.fragments.length||!o.hasProgramDateTime||!t.hasProgramDateTime)return;var e=t.fragments[0].programDateTime,i=t.fragments[0].start,T=e-i*1e3;o.fragments.forEach(function(_){n(_,T)}),o.fragmentHint&&n(o.fragmentHint,T),o.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/utils/ewma.ts"),I=function(){function O(M,A,S){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=S,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new j.default(M),this.fast_=new j.default(A)}var B=O.prototype;return B.update=function(A,S){var p=this.slow_,m=this.fast_;this.slow_.halfLife!==A&&(this.slow_=new j.default(A,p.getEstimate(),p.getTotalWeight())),this.fast_.halfLife!==S&&(this.fast_=new j.default(S,m.getEstimate(),m.getTotalWeight()))},B.sample=function(A,S){A=Math.max(A,this.minDelayMs_);var p=8*S,m=A/1e3,s=p/m;this.fast_.sample(m,s),this.slow_.sample(m,s)},B.canEstimate=function(){var A=this.fast_;return A&&A.getTotalWeight()>=this.minWeight_},B.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},B.destroy=function(){},O}();G.default=I},"./src/utils/ewma.ts":function(he,G,w){"use strict";w.r(G);var j=function(){function I(B,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=B,this.alpha_=B?Math.exp(Math.log(.5)/B):0,this.estimate_=M,this.totalWeight_=A}var O=I.prototype;return O.sample=function(M,A){var S=Math.pow(this.alpha_,M);this.estimate_=A*(1-S)+S*this.estimate_,this.totalWeight_+=M},O.getTotalWeight=function(){return this.totalWeight_},O.getEstimate=function(){if(this.alpha_){var M=1-Math.pow(this.alpha_,this.totalWeight_);if(M)return this.estimate_/M}return this.estimate_},I}();G.default=j},"./src/utils/fetch-loader.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"fetchSupported",function(){return n});var j=w("./src/polyfills/number.ts"),I=w("./src/loader/load-stats.ts"),O=w("./src/demux/chunk-cache.ts");function B(i,T){i.prototype=Object.create(T.prototype),i.prototype.constructor=i,m(i,T)}function M(i){var T=typeof Map=="function"?new Map:void 0;return M=function(y){if(y===null||!p(y))return y;if(typeof y!="function")throw new TypeError("Super expression must either be null or a function");if(typeof T!="undefined"){if(T.has(y))return T.get(y);T.set(y,E)}function E(){return A(y,arguments,s(this).constructor)}return E.prototype=Object.create(y.prototype,{constructor:{value:E,enumerable:!1,writable:!0,configurable:!0}}),m(E,y)},M(i)}function A(i,T,_){return S()?A=Reflect.construct:A=function(E,b,g){var d=[null];d.push.apply(d,b);var a=Function.bind.apply(E,d),l=new a;return g&&m(l,g.prototype),l},A.apply(null,arguments)}function S(){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(i){return!1}}function p(i){return Function.toString.call(i).indexOf("[native code]")!==-1}function m(i,T){return m=Object.setPrototypeOf||function(y,E){return y.__proto__=E,y},m(i,T)}function s(i){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(_){return _.__proto__||Object.getPrototypeOf(_)},s(i)}function r(){return r=Object.assign||function(i){for(var T=1;T<arguments.length;T++){var _=arguments[T];for(var y in _)Object.prototype.hasOwnProperty.call(_,y)&&(i[y]=_[y])}return i},r.apply(this,arguments)}function n(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(i){}return!1}var u=function(){function i(_){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=_.fetchSetup||t,this.controller=new self.AbortController,this.stats=new I.LoadStats}var T=i.prototype;return T.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},T.abortInternal=function(){var y=this.response;(!y||!y.ok)&&(this.stats.aborted=!0,this.controller.abort())},T.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},T.load=function(y,E,b){var g=this,d=this.stats;if(d.loading.start)throw new Error("Loader can only be used once.");d.loading.start=self.performance.now();var a=o(y,this.controller.signal),l=b.onProgress,f=y.responseType==="arraybuffer",c=f?"byteLength":"length";this.context=y,this.config=E,this.callbacks=b,this.request=this.fetchSetup(y,a),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){g.abortInternal(),b.onTimeout(d,y,g.response)},E.timeout),self.fetch(this.request).then(function(x){if(g.response=g.loader=x,!x.ok){var R=x.status,C=x.statusText;throw new e(C||"fetch, bad network response",R,x)}return d.loading.first=Math.max(self.performance.now(),d.loading.start),d.total=parseInt(x.headers.get("Content-Length")||"0"),l&&Object(j.isFiniteNumber)(E.highWaterMark)?g.loadProgressively(x,d,y,E.highWaterMark,l):f?x.arrayBuffer():x.text()}).then(function(x){var R=g.response;self.clearTimeout(g.requestTimeout),d.loading.end=Math.max(self.performance.now(),d.loading.first),d.loaded=d.total=x[c];var C={url:R.url,data:x};l&&!Object(j.isFiniteNumber)(E.highWaterMark)&&l(d,y,x,R),b.onSuccess(C,d,y,R)}).catch(function(x){if(self.clearTimeout(g.requestTimeout),d.aborted)return;var R=x.code||0;b.onError({code:R,text:x.message},y,x.details)})},T.getCacheAge=function(){var y=null;if(this.response){var E=this.response.headers.get("age");y=E?parseFloat(E):null}return y},T.loadProgressively=function(y,E,b,g,d){g===void 0&&(g=0);var a=new O.default,l=y.body.getReader(),f=function c(){return l.read().then(function(x){if(x.done)return a.dataLength&&d(E,b,a.flush(),y),Promise.resolve(new ArrayBuffer(0));var R=x.value,C=R.length;return E.loaded+=C,C<g||a.dataLength?(a.push(R),a.dataLength>=g&&d(E,b,a.flush(),y)):d(E,b,R,y),c()}).catch(function(){return Promise.reject()})};return f()},i}();function o(i,T){var _={method:"GET",mode:"cors",credentials:"same-origin",signal:T,headers:new self.Headers(r({},i.headers))};return i.rangeEnd&&_.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),_}function t(i,T){return new self.Request(i.url,T)}var e=function(i){B(T,i);function T(_,y,E){var b;return b=i.call(this,_)||this,b.code=void 0,b.details=void 0,b.code=y,b.details=E,b}return T}(M(Error));G.default=u},"./src/utils/imsc1-ttml-parser.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"IMSC1_CODEC",function(){return p}),w.d(G,"parseIMSC1",function(){return n});var j=w("./src/utils/mp4-tools.ts"),I=w("./src/utils/vttparser.ts"),O=w("./src/utils/vttcue.ts"),B=w("./src/demux/id3.ts"),M=w("./src/utils/timescale-conversion.ts"),A=w("./src/utils/webvtt-parser.ts");function S(){return S=Object.assign||function(g){for(var d=1;d<arguments.length;d++){var a=arguments[d];for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&(g[l]=a[l])}return g},S.apply(this,arguments)}var p="stpp.ttml.im1t",m=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,s=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,r={left:"start",center:"center",right:"end",start:"start",end:"end"};function n(g,d,a,l,f){var c=Object(j.findBox)(new Uint8Array(g),["mdat"]);if(c.length===0){f(new Error("Could not parse IMSC1 mdat"));return}var x=c[0],R=Object(B.utf8ArrayToStr)(new Uint8Array(g,x.start,x.end-x.start)),C=Object(M.toTimescaleFromScale)(d,1,a);try{l(u(R,C))}catch(N){f(N)}}function u(g,d){var a=new DOMParser,l=a.parseFromString(g,"text/xml"),f=l.getElementsByTagName("tt")[0];if(!f)throw new Error("Invalid ttml");var c={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},x=Object.keys(c).reduce(function(W,L){return W[L]=f.getAttribute("ttp:"+L)||c[L],W},{}),R=f.getAttribute("xml:space")!=="preserve",C=t(o(f,"styling","style")),N=t(o(f,"layout","region")),U=o(f,"body","[begin]");return[].map.call(U,function(W){var L=e(W,R);if(!L||!W.hasAttribute("begin"))return null;var H=y(W.getAttribute("begin"),x),K=y(W.getAttribute("dur"),x),$=y(W.getAttribute("end"),x);if(H===null)throw _(W);if($===null){if(K===null)throw _(W);$=H+K}var Q=new O.default(H-d,$-d,L);Q.id=Object(A.generateCueId)(Q.startTime,Q.endTime,Q.text);var ue=N[W.getAttribute("region")],ne=C[W.getAttribute("style")];Q.position=10,Q.size=80;var se=i(ue,ne),le=se.textAlign;if(le){var de=r[le];de&&(Q.lineAlign=de),Q.align=le}return S(Q,se),Q}).filter(function(W){return W!==null})}function o(g,d,a){var l=g.getElementsByTagName(d)[0];return l?[].slice.call(l.querySelectorAll(a)):[]}function t(g){return g.reduce(function(d,a){var l=a.getAttribute("xml:id");return l&&(d[l]=a),d},{})}function e(g,d){return[].slice.call(g.childNodes).reduce(function(a,l,f){var c;return l.nodeName==="br"&&f?a+`
`:(c=l.childNodes)!==null&&c!==void 0&&c.length?e(l,d):d?a+l.textContent.trim().replace(/\s+/g," "):a+l.textContent},"")}function i(g,d){var a="http://www.w3.org/ns/ttml#styling",l=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return l.reduce(function(f,c){var x=T(d,a,c)||T(g,a,c);return x&&(f[c]=x),f},{})}function T(g,d,a){return g.hasAttributeNS(d,a)?g.getAttributeNS(d,a):null}function _(g){return new Error("Could not parse ttml timestamp "+g)}function y(g,d){if(!g)return null;var a=Object(I.parseTimeStamp)(g);return a===null&&(m.test(g)?a=E(g,d):s.test(g)&&(a=b(g,d))),a}function E(g,d){var a=m.exec(g),l=(a[4]|0)+(a[5]|0)/d.subFrameRate;return(a[1]|0)*3600+(a[2]|0)*60+(a[3]|0)+l/d.frameRate}function b(g,d){var a=s.exec(g),l=Number(a[1]),f=a[2];switch(f){case"h":return l*3600;case"m":return l*60;case"ms":return l*1e3;case"f":return l/d.frameRate;case"t":return l/d.tickRate}return l}},"./src/utils/logger.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"enableLogs",function(){return A}),w.d(G,"logger",function(){return S});var j=function(){},I={trace:j,debug:j,log:j,warn:j,info:j,error:j},O=I;function B(p){var m=self.console[p];return m?m.bind(self.console,"["+p+"] >"):j}function M(p){for(var m=arguments.length,s=new Array(m>1?m-1:0),r=1;r<m;r++)s[r-1]=arguments[r];s.forEach(function(n){O[n]=p[n]?p[n].bind(p):B(n)})}function A(p){if(self.console&&p===!0||typeof p=="object"){M(p,"debug","log","info","warn","error");try{O.log()}catch(m){O=I}}else O=I}var S=O},"./src/utils/mediakeys-helper.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"KeySystems",function(){return j}),w.d(G,"requestMediaKeySystemAccess",function(){return I});var j;(function(O){O.WIDEVINE="com.widevine.alpha",O.PLAYREADY="com.microsoft.playready"})(j||(j={}));var I=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"getMediaSource",function(){return j});function j(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"bin2str",function(){return M}),w.d(G,"readUint16",function(){return A}),w.d(G,"readUint32",function(){return S}),w.d(G,"writeUint32",function(){return p}),w.d(G,"findBox",function(){return m}),w.d(G,"parseSegmentIndex",function(){return s}),w.d(G,"parseInitSegment",function(){return r}),w.d(G,"getStartDTS",function(){return n}),w.d(G,"getDuration",function(){return u}),w.d(G,"computeRawDurationFromSamples",function(){return o}),w.d(G,"offsetStartDTS",function(){return t}),w.d(G,"segmentValidRange",function(){return e}),w.d(G,"appendUint8Array",function(){return i});var j=w("./src/utils/typed-array.ts"),I=w("./src/loader/fragment.ts"),O=Math.pow(2,32)-1,B=[].push;function M(T){return String.fromCharCode.apply(null,T)}function A(T,_){"data"in T&&(_+=T.start,T=T.data);var y=T[_]<<8|T[_+1];return y<0?65536+y:y}function S(T,_){"data"in T&&(_+=T.start,T=T.data);var y=T[_]<<24|T[_+1]<<16|T[_+2]<<8|T[_+3];return y<0?4294967296+y:y}function p(T,_,y){"data"in T&&(_+=T.start,T=T.data),T[_]=y>>24,T[_+1]=y>>16&255,T[_+2]=y>>8&255,T[_+3]=y&255}function m(T,_){var y=[];if(!_.length)return y;var E,b,g;"data"in T?(E=T.data,b=T.start,g=T.end):(E=T,b=0,g=E.byteLength);for(var d=b;d<g;){var a=S(E,d),l=M(E.subarray(d+4,d+8)),f=a>1?d+a:g;if(l===_[0])if(_.length===1)y.push({data:E,start:d+8,end:f});else{var c=m({data:E,start:d+8,end:f},_.slice(1));c.length&&B.apply(y,c)}d=f}return y}function s(T){var _=m(T,["moov"]),y=_[0],E=y?y.end:null,b=m(T,["sidx"]);if(!b||!b[0])return null;var g=[],d=b[0],a=d.data[0],l=a===0?8:16,f=S(d,l);l+=4;var c=0,x=0;a===0?l+=8:l+=16,l+=2;var R=d.end+x,C=A(d,l);l+=2;for(var N=0;N<C;N++){var U=l,W=S(d,U);U+=4;var L=W&2147483647,H=(W&2147483648)>>>31;if(H===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var K=S(d,U);U+=4,g.push({referenceSize:L,subsegmentDuration:K,info:{duration:K/f,start:R,end:R+L-1}}),R+=L,U+=4,l=U}return{earliestPresentationTime:c,timescale:f,version:a,referencesCount:C,references:g,moovEndOffset:E}}function r(T){for(var _=[],y=m(T,["moov","trak"]),E=0;E<y.length;E++){var b=y[E],g=m(b,["tkhd"])[0];if(g){var d=g.data[g.start],a=d===0?12:20,l=S(g,a),f=m(b,["mdia","mdhd"])[0];if(f){d=f.data[f.start],a=d===0?12:20;var c=S(f,a),x=m(b,["mdia","hdlr"])[0];if(x){var R=M(x.data.subarray(x.start+8,x.start+12)),C={soun:I.ElementaryStreamTypes.AUDIO,vide:I.ElementaryStreamTypes.VIDEO}[R];if(C){var N=m(b,["mdia","minf","stbl","stsd"])[0],U=void 0;N&&(U=M(N.data.subarray(N.start+12,N.start+16))),_[l]={timescale:c,type:C},_[C]={timescale:c,id:l,codec:U}}}}}}var W=m(T,["moov","mvex","trex"]);return W.forEach(function(L){var H=S(L,4),K=_[H];K&&(K.default={duration:S(L,12),flags:S(L,20)})}),_}function n(T,_){return m(_,["moof","traf"]).reduce(function(y,E){var b=m(E,["tfdt"])[0],g=b.data[b.start],d=m(E,["tfhd"]).reduce(function(a,l){var f=S(l,4),c=T[f];if(c){var x=S(b,4);g===1&&(x*=Math.pow(2,32),x+=S(b,8));var R=c.timescale||9e4,C=x/R;if(isFinite(C)&&(a===null||C<a))return C}return a},null);return d!==null&&isFinite(d)&&(y===null||d<y)?d:y},null)||0}function u(T,_){for(var y=0,E=0,b=0,g=m(T,["moof","traf"]),d=0;d<g.length;d++){var a=g[d],l=m(a,["tfhd"])[0],f=S(l,4),c=_[f];if(!c)continue;var x=c.default,R=S(l,0)|(x==null?void 0:x.flags),C=x==null?void 0:x.duration;R&8&&(R&2?C=S(l,12):C=S(l,8));for(var N=c.timescale||9e4,U=m(a,["trun"]),W=0;W<U.length;W++){if(C){var L=S(U[W],4);y=C*L}else y=o(U[W]);c.type===I.ElementaryStreamTypes.VIDEO?E+=y/N:c.type===I.ElementaryStreamTypes.AUDIO&&(b+=y/N)}}if(E===0&&b===0){var H=s(T);if(H!=null&&H.references)return H.references.reduce(function(K,$){return K+$.info.duration||0},0)}return E||b}function o(T){var _=S(T,0),y=8;_&1&&(y+=4),_&4&&(y+=4);for(var E=0,b=S(T,4),g=0;g<b;g++){if(_&256){var d=S(T,y);E+=d,y+=4}_&512&&(y+=4),_&1024&&(y+=4),_&2048&&(y+=4)}return E}function t(T,_,y){m(_,["moof","traf"]).forEach(function(E){m(E,["tfhd"]).forEach(function(b){var g=S(b,4),d=T[g];if(!d)return;var a=d.timescale||9e4;m(E,["tfdt"]).forEach(function(l){var f=l.data[l.start],c=S(l,4);if(f===0)p(l,4,c-y*a);else{c*=Math.pow(2,32),c+=S(l,8),c-=y*a,c=Math.max(c,0);var x=Math.floor(c/(O+1)),R=Math.floor(c%(O+1));p(l,4,x),p(l,8,R)}})})})}function e(T){var _={valid:null,remainder:null},y=m(T,["moof"]);if(y){if(y.length<2)return _.remainder=T,_}else return _;var E=y[y.length-1];return _.valid=Object(j.sliceUint8)(T,0,E.start-8),_.remainder=Object(j.sliceUint8)(T,E.start-8),_}function i(T,_){var y=new Uint8Array(T.length+_.length);return y.set(T),y.set(_,T.length),y}},"./src/utils/output-filter.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"default",function(){return j});var j=function(){function I(B,M){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=B,this.trackName=M}var O=I.prototype;return O.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},O.newCue=function(M,A,S){(this.startTime===null||this.startTime>M)&&(this.startTime=M),this.endTime=A,this.screen=S,this.timelineController.createCaptionsTrack(this.trackName)},O.reset=function(){this.cueRanges=[]},I}()},"./src/utils/texttrack-utils.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"sendAddTrackEvent",function(){return I}),w.d(G,"addCueToTrack",function(){return O}),w.d(G,"clearCurrentCues",function(){return B}),w.d(G,"removeCuesInRange",function(){return M}),w.d(G,"getCuesInRange",function(){return S});var j=w("./src/utils/logger.ts");function I(p,m){var s;try{s=new Event("addtrack")}catch(r){s=document.createEvent("Event"),s.initEvent("addtrack",!1,!1)}s.track=p,m.dispatchEvent(s)}function O(p,m){var s=p.mode;if(s==="disabled"&&(p.mode="hidden"),p.cues&&!p.cues.getCueById(m.id))try{if(p.addCue(m),!p.cues.getCueById(m.id))throw new Error("addCue is failed for: "+m)}catch(n){j.logger.debug("[texttrack-utils]: "+n);var r=new self.TextTrackCue(m.startTime,m.endTime,m.text);r.id=m.id,p.addCue(r)}s==="disabled"&&(p.mode=s)}function B(p){var m=p.mode;if(m==="disabled"&&(p.mode="hidden"),p.cues)for(var s=p.cues.length;s--;)p.removeCue(p.cues[s]);m==="disabled"&&(p.mode=m)}function M(p,m,s){var r=p.mode;if(r==="disabled"&&(p.mode="hidden"),p.cues&&p.cues.length>0)for(var n=S(p.cues,m,s),u=0;u<n.length;u++)p.removeCue(n[u]);r==="disabled"&&(p.mode=r)}function A(p,m){if(m<p[0].startTime)return 0;var s=p.length-1;if(m>p[s].endTime)return-1;for(var r=0,n=s;r<=n;){var u=Math.floor((n+r)/2);if(m<p[u].startTime)n=u-1;else if(m>p[u].startTime&&r<s)r=u+1;else return u}return p[r].startTime-m<m-p[n].startTime?r:n}function S(p,m,s){var r=[],n=A(p,m);if(n>-1)for(var u=n,o=p.length;u<o;u++){var t=p[u];if(t.startTime>=m&&t.endTime<=s)r.push(t);else if(t.startTime>s)return r}return r}},"./src/utils/time-ranges.ts":function(he,G,w){"use strict";w.r(G);var j={toString:function(O){for(var B="",M=O.length,A=0;A<M;A++)B+="["+O.start(A).toFixed(3)+","+O.end(A).toFixed(3)+"]";return B}};G.default=j},"./src/utils/timescale-conversion.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"toTimescaleFromBase",function(){return I}),w.d(G,"toTimescaleFromScale",function(){return O}),w.d(G,"toMsFromMpegTsClock",function(){return B}),w.d(G,"toMpegTsClockFromTimescale",function(){return M});var j=9e4;function I(A,S,p,m){p===void 0&&(p=1),m===void 0&&(m=!1);var s=A*S*p;return m?Math.round(s):s}function O(A,S,p,m){return p===void 0&&(p=1),m===void 0&&(m=!1),I(A,S,1/p,m)}function B(A,S){return S===void 0&&(S=!1),I(A,1e3,1/j,S)}function M(A,S){return S===void 0&&(S=1),I(A,j,1/S)}},"./src/utils/typed-array.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"sliceUint8",function(){return j});function j(I,O,B){return Uint8Array.prototype.slice?I.slice(O,B):new Uint8Array(Array.prototype.slice.call(I,O,B))}},"./src/utils/vttcue.ts":function(he,G,w){"use strict";w.r(G),G.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var j=["","lr","rl"],I=["start","middle","end","left","right"];function O(p,m){if(typeof m!="string")return!1;if(!Array.isArray(p))return!1;var s=m.toLowerCase();return~p.indexOf(s)?s:!1}function B(p){return O(j,p)}function M(p){return O(I,p)}function A(p){for(var m=arguments.length,s=new Array(m>1?m-1:0),r=1;r<m;r++)s[r-1]=arguments[r];for(var n=1;n<arguments.length;n++){var u=arguments[n];for(var o in u)p[o]=u[o]}return p}function S(p,m,s){var r=this,n={enumerable:!0};r.hasBeenReset=!1;var u="",o=!1,t=p,e=m,i=s,T=null,_="",y=!0,E="auto",b="start",g=50,d="middle",a=50,l="middle";Object.defineProperty(r,"id",A({},n,{get:function(){return u},set:function(c){u=""+c}})),Object.defineProperty(r,"pauseOnExit",A({},n,{get:function(){return o},set:function(c){o=!!c}})),Object.defineProperty(r,"startTime",A({},n,{get:function(){return t},set:function(c){if(typeof c!="number")throw new TypeError("Start time must be set to a number.");t=c,this.hasBeenReset=!0}})),Object.defineProperty(r,"endTime",A({},n,{get:function(){return e},set:function(c){if(typeof c!="number")throw new TypeError("End time must be set to a number.");e=c,this.hasBeenReset=!0}})),Object.defineProperty(r,"text",A({},n,{get:function(){return i},set:function(c){i=""+c,this.hasBeenReset=!0}})),Object.defineProperty(r,"region",A({},n,{get:function(){return T},set:function(c){T=c,this.hasBeenReset=!0}})),Object.defineProperty(r,"vertical",A({},n,{get:function(){return _},set:function(c){var x=B(c);if(x===!1)throw new SyntaxError("An invalid or illegal string was specified.");_=x,this.hasBeenReset=!0}})),Object.defineProperty(r,"snapToLines",A({},n,{get:function(){return y},set:function(c){y=!!c,this.hasBeenReset=!0}})),Object.defineProperty(r,"line",A({},n,{get:function(){return E},set:function(c){if(typeof c!="number"&&c!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");E=c,this.hasBeenReset=!0}})),Object.defineProperty(r,"lineAlign",A({},n,{get:function(){return b},set:function(c){var x=M(c);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");b=x,this.hasBeenReset=!0}})),Object.defineProperty(r,"position",A({},n,{get:function(){return g},set:function(c){if(c<0||c>100)throw new Error("Position must be between 0 and 100.");g=c,this.hasBeenReset=!0}})),Object.defineProperty(r,"positionAlign",A({},n,{get:function(){return d},set:function(c){var x=M(c);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");d=x,this.hasBeenReset=!0}})),Object.defineProperty(r,"size",A({},n,{get:function(){return a},set:function(c){if(c<0||c>100)throw new Error("Size must be between 0 and 100.");a=c,this.hasBeenReset=!0}})),Object.defineProperty(r,"align",A({},n,{get:function(){return l},set:function(c){var x=M(c);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");l=x,this.hasBeenReset=!0}})),r.displayState=void 0}return S.prototype.getCueAsHTML=function(){var p=self.WebVTT;return p.convertCueToDOMTree(self,this.text)},S}()},"./src/utils/vttparser.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"parseTimeStamp",function(){return O}),w.d(G,"fixLineBreaks",function(){return m}),w.d(G,"VTTParser",function(){return s});var j=w("./src/utils/vttcue.ts"),I=function(){function r(){}var n=r.prototype;return n.decode=function(o,t){if(!o)return"";if(typeof o!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(o))},r}();function O(r){function n(o,t,e,i){return(o|0)*3600+(t|0)*60+(e|0)+parseFloat(i||0)}var u=r.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return u?parseFloat(u[2])>59?n(u[2],u[3],0,u[4]):n(u[1],u[2],u[3],u[4]):null}var B=function(){function r(){this.values=Object.create(null)}var n=r.prototype;return n.set=function(o,t){!this.get(o)&&t!==""&&(this.values[o]=t)},n.get=function(o,t,e){return e?this.has(o)?this.values[o]:t[e]:this.has(o)?this.values[o]:t},n.has=function(o){return o in this.values},n.alt=function(o,t,e){for(var i=0;i<e.length;++i)if(t===e[i]){this.set(o,t);break}},n.integer=function(o,t){/^-?\d+$/.test(t)&&this.set(o,parseInt(t,10))},n.percent=function(o,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var e=parseFloat(t);if(e>=0&&e<=100)return this.set(o,e),!0}return!1},r}();function M(r,n,u,o){var t=o?r.split(o):[r];for(var e in t){if(typeof t[e]!="string")continue;var i=t[e].split(u);if(i.length!==2)continue;var T=i[0],_=i[1];n(T,_)}}var A=new j.default(0,0,""),S=A.align==="middle"?"middle":"center";function p(r,n,u){var o=r;function t(){var T=O(r);if(T===null)throw new Error("Malformed timestamp: "+o);return r=r.replace(/^[^\sa-zA-Z-]+/,""),T}function e(T,_){var y=new B;M(T,function(g,d){var a;switch(g){case"region":for(var l=u.length-1;l>=0;l--)if(u[l].id===d){y.set(g,u[l].region);break}break;case"vertical":y.alt(g,d,["rl","lr"]);break;case"line":a=d.split(","),y.integer(g,a[0]),y.percent(g,a[0])&&y.set("snapToLines",!1),y.alt(g,a[0],["auto"]),a.length===2&&y.alt("lineAlign",a[1],["start",S,"end"]);break;case"position":a=d.split(","),y.percent(g,a[0]),a.length===2&&y.alt("positionAlign",a[1],["start",S,"end","line-left","line-right","auto"]);break;case"size":y.percent(g,d);break;case"align":y.alt(g,d,["start",S,"end","left","right"]);break}},/:/,/\s/),_.region=y.get("region",null),_.vertical=y.get("vertical","");var E=y.get("line","auto");E==="auto"&&A.line===-1&&(E=-1),_.line=E,_.lineAlign=y.get("lineAlign","start"),_.snapToLines=y.get("snapToLines",!0),_.size=y.get("size",100),_.align=y.get("align",S);var b=y.get("position","auto");b==="auto"&&A.position===50&&(b=_.align==="start"||_.align==="left"?0:_.align==="end"||_.align==="right"?100:50),_.position=b}function i(){r=r.replace(/^\s+/,"")}if(i(),n.startTime=t(),i(),r.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+o);r=r.substr(3),i(),n.endTime=t(),i(),e(r,n)}function m(r){return r.replace(/<br(?: \/)?>/gi,`
`)}var s=function(){function r(){this.state="INITIAL",this.buffer="",this.decoder=new I,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var n=r.prototype;return n.parse=function(o){var t=this;o&&(t.buffer+=t.decoder.decode(o,{stream:!0}));function e(){var b=t.buffer,g=0;for(b=m(b);g<b.length&&b[g]!=="\r"&&b[g]!==`
`;)++g;var d=b.substr(0,g);return b[g]==="\r"&&++g,b[g]===`
`&&++g,t.buffer=b.substr(g),d}function i(b){M(b,function(g,d){},/:/)}try{var T="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;T=e();var _=T.match(/^()?WEBVTT([ \t].*)?$/);if(!_||!_[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var y=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;y?y=!1:T=e();switch(t.state){case"HEADER":/:/.test(T)?i(T):T||(t.state="ID");continue;case"NOTE":T||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(T)){t.state="NOTE";break}if(!T)continue;if(t.cue=new j.default(0,0,""),t.state="CUE",T.indexOf("-->")===-1){t.cue.id=T;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{p(T,t.cue,t.regionList)}catch(b){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{var E=T.indexOf("-->")!==-1;if(!T||E&&(y=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
`),t.cue.text+=T}continue;case"BADCUE":T||(t.state="ID")}}}catch(b){t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},n.flush=function(){var o=this;try{if((o.cue||o.state==="HEADER")&&(o.buffer+=`
`,o.parse()),o.state==="INITIAL"||o.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){o.onparsingerror&&o.onparsingerror(t)}return o.onflush&&o.onflush(),this},r}()},"./src/utils/webvtt-parser.ts":function(he,G,w){"use strict";w.r(G),w.d(G,"generateCueId",function(){return s}),w.d(G,"parseWebVTT",function(){return n});var j=w("./src/polyfills/number.ts"),I=w("./src/utils/vttparser.ts"),O=w("./src/demux/id3.ts"),B=w("./src/utils/timescale-conversion.ts"),M=w("./src/remux/mp4-remuxer.ts"),A=/\r\n|\n\r|\n|\r/g,S=function(o,t,e){return e===void 0&&(e=0),o.substr(e,t.length)===t},p=function(o){var t=parseInt(o.substr(-3)),e=parseInt(o.substr(-6,2)),i=parseInt(o.substr(-9,2)),T=o.length>9?parseInt(o.substr(0,o.indexOf(":"))):0;if(!Object(j.isFiniteNumber)(t)||!Object(j.isFiniteNumber)(e)||!Object(j.isFiniteNumber)(i)||!Object(j.isFiniteNumber)(T))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+o);return t+=1e3*e,t+=60*1e3*i,t+=60*60*1e3*T,t},m=function(o){for(var t=5381,e=o.length;e;)t=t*33^o.charCodeAt(--e);return(t>>>0).toString()};function s(u,o,t){return m(u.toString())+m(o.toString())+m(t)}var r=function(o,t,e){var i=o[t],T=o[i.prevCC];if(!T||!T.new&&i.new){o.ccOffset=o.presentationOffset=i.start,i.new=!1;return}for(;(_=T)!==null&&_!==void 0&&_.new;){var _;o.ccOffset+=i.start-T.start,i.new=!1,i=T,T=o[i.prevCC]}o.presentationOffset=e};function n(u,o,t,e,i,T,_,y){var E=new I.VTTParser,b=Object(O.utf8ArrayToStr)(new Uint8Array(u)).trim().replace(A,`
`).split(`
`),g=[],d=Object(B.toMpegTsClockFromTimescale)(o,t),a="00:00.000",l=0,f=0,c,x=!0,R=!1;E.oncue=function(C){var N=e[i],U=e.ccOffset,W=(l-d)/9e4;if(N!=null&&N.new&&(f!==void 0?U=e.ccOffset=N.start:r(e,i,W)),W&&(U=W-e.presentationOffset),R){var L=C.endTime-C.startTime,H=Object(M.normalizePts)((C.startTime+U-f)*9e4,T*9e4)/9e4;C.startTime=H,C.endTime=H+L}var K=C.text.trim();C.text=decodeURIComponent(encodeURIComponent(K)),C.id||(C.id=s(C.startTime,C.endTime,K)),C.endTime>0&&g.push(C)},E.onparsingerror=function(C){c=C},E.onflush=function(){if(c){y(c);return}_(g)},b.forEach(function(C){if(x)if(S(C,"X-TIMESTAMP-MAP=")){x=!1,R=!0,C.substr(16).split(",").forEach(function(N){S(N,"LOCAL:")?a=N.substr(6):S(N,"MPEGTS:")&&(l=parseInt(N.substr(7)))});try{f=p(a)/1e3}catch(N){R=!1,c=N}return}else C===""&&(x=!1);E.parse(C+`
`)}),E.flush()}},"./src/utils/xhr-loader.ts":function(he,G,w){"use strict";w.r(G);var j=w("./src/utils/logger.ts"),I=w("./src/loader/load-stats.ts"),O=/^age:\s*[\d.]+\s*$/m,B=function(){function M(S){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=S?S.xhrSetup:null,this.stats=new I.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 p=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),p&&(p.onreadystatechange=null,p.onprogress=null,p.readyState!==4&&(this.stats.aborted=!0,p.abort()))},A.abort=function(){var p;this.abortInternal(),(p=this.callbacks)!==null&&p!==void 0&&p.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},A.load=function(p,m,s){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=p,this.config=m,this.callbacks=s,this.retryDelay=m.retryDelay,this.loadInternal()},A.loadInternal=function(){var p=this.config,m=this.context;if(!p)return;var s=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0;var n=this.xhrSetup;try{if(n)try{n(s,m.url)}catch(t){s.open("GET",m.url,!0),n(s,m.url)}s.readyState||s.open("GET",m.url,!0);var u=this.context.headers;if(u)for(var o in u)s.setRequestHeader(o,u[o])}catch(t){this.callbacks.onError({code:s.status,text:t.message},m,s);return}m.rangeEnd&&s.setRequestHeader("Range","bytes="+m.rangeStart+"-"+(m.rangeEnd-1)),s.onreadystatechange=this.readystatechange.bind(this),s.onprogress=this.loadprogress.bind(this),s.responseType=m.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),p.timeout),s.send()},A.readystatechange=function(){var p=this.context,m=this.loader,s=this.stats;if(!p||!m)return;var r=m.readyState,n=this.config;if(s.aborted)return;if(r>=2)if(self.clearTimeout(this.requestTimeout),s.loading.first===0&&(s.loading.first=Math.max(self.performance.now(),s.loading.start)),r===4){m.onreadystatechange=null,m.onprogress=null;var u=m.status;if(u>=200&&u<300){s.loading.end=Math.max(self.performance.now(),s.loading.first);var o,t;if(p.responseType==="arraybuffer"?(o=m.response,t=o.byteLength):(o=m.responseText,t=o.length),s.loaded=s.total=t,!this.callbacks)return;var e=this.callbacks.onProgress;if(e&&e(s,p,o,m),!this.callbacks)return;var i={url:m.responseURL,data:o};this.callbacks.onSuccess(i,s,p,m)}else s.retry>=n.maxRetry||u>=400&&u<499?(j.logger.error(u+" while loading "+p.url),this.callbacks.onError({code:u,text:m.statusText},p,m)):(j.logger.warn(u+" while loading "+p.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,n.maxRetryDelay),s.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.timeout)},A.loadtimeout=function(){j.logger.warn("timeout while loading "+this.context.url);var p=this.callbacks;p&&(this.abortInternal(),p.onTimeout(this.stats,this.context,this.loader))},A.loadprogress=function(p){var m=this.stats;m.loaded=p.loaded,p.lengthComputable&&(m.total=p.total)},A.getCacheAge=function(){var p=null;if(this.loader&&O.test(this.loader.getAllResponseHeaders())){var m=this.loader.getResponseHeader("age");p=m?parseFloat(m):null}return p},M}();G.default=B}}).default})},vHTk:function(Je,Ve,ee){Je.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);