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/8461.a72d2bbb.async.js

3206 lines
1.6 MiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

!(function(){var va=Math.pow;var el=(Li,Rt,oe)=>new Promise((ce,De)=>{var qe=S=>{try{q(oe.next(S))}catch(Te){De(Te)}},ge=S=>{try{q(oe.throw(S))}catch(Te){De(Te)}},q=S=>S.done?ce(S.value):Promise.resolve(S.value).then(qe,ge);q((oe=oe.apply(Li,Rt)).next())});(self.webpackChunk=self.webpackChunk||[]).push([[8461],{65030:function(Li,Rt,oe){"use strict";oe.d(Rt,{Z:function(){return ln}});var ce=oe(33885),De=oe(42978),qe=oe(75931),ge=oe(43403),q=oe(92310),S=oe.n(q),Te=oe(29301),P=oe(76846),d=oe(96452),ne=oe(6089),I=oe(80402),k=oe(34280),T=oe(49658),M=oe(59301),O=oe(54476),Y=oe(77900),H=oe(8654);function j(Ne){var Ge=Ne.prefixCls,ve=Ne.align,nt=Ne.arrow,_t=Ne.arrowPos,lt=nt||{},ee=lt.className,xe=lt.content,$e=_t.x,Ye=$e===void 0?0:$e,rt=_t.y,gt=rt===void 0?0:rt,Yt=M.useRef();if(!ve||!ve.points)return null;var pt={position:"absolute"};if(ve.autoArrow!==!1){var ke=ve.points[0],ht=ve.points[1],Gt=ke[0],zt=ke[1],Ae=ht[0],Me=ht[1];Gt===Ae||!["t","b"].includes(Gt)?pt.top=gt:Gt==="t"?pt.top=0:pt.bottom=0,zt===Me||!["l","r"].includes(zt)?pt.left=Ye:zt==="l"?pt.left=0:pt.right=0}return M.createElement("div",{ref:Yt,className:S()("".concat(Ge,"-arrow"),ee),style:pt},xe)}function U(Ne){var Ge=Ne.prefixCls,ve=Ne.open,nt=Ne.zIndex,_t=Ne.mask,lt=Ne.motion;return _t?M.createElement(Y.default,(0,O.Z)({},lt,{motionAppear:!0,visible:ve,removeOnLeave:!0}),function(ee){var xe=ee.className;return M.createElement("div",{style:{zIndex:nt},className:S()("".concat(Ge,"-mask"),xe)})}):null}var $=M.memo(function(Ne){var Ge=Ne.children;return Ge},function(Ne,Ge){return Ge.cache}),G=$,he=M.forwardRef(function(Ne,Ge){var ve=Ne.popup,nt=Ne.className,_t=Ne.prefixCls,lt=Ne.style,ee=Ne.target,xe=Ne.onVisibleChanged,$e=Ne.open,Ye=Ne.keepDom,rt=Ne.fresh,gt=Ne.onClick,Yt=Ne.mask,pt=Ne.arrow,ke=Ne.arrowPos,ht=Ne.align,Gt=Ne.motion,zt=Ne.maskMotion,Ae=Ne.forceRender,Me=Ne.getPopupContainer,tt=Ne.autoDestroy,ft=Ne.portal,je=Ne.zIndex,At=Ne.onMouseEnter,Lt=Ne.onMouseLeave,vt=Ne.onPointerEnter,Pt=Ne.onPointerDownCapture,Ht=Ne.ready,Xe=Ne.offsetX,Ft=Ne.offsetY,Le=Ne.offsetR,ye=Ne.offsetB,we=Ne.onAlign,K=Ne.onPrepare,W=Ne.stretch,ae=Ne.targetWidth,fe=Ne.targetHeight,_e=typeof ve=="function"?ve():ve,st=$e||Ye,ot=(Me==null?void 0:Me.length)>0,xt=M.useState(!Me||!ot),Ut=(0,De.Z)(xt,2),ti=Ut[0],di=Ut[1];if((0,k.Z)(function(){!ti&&ot&&ee&&di(!0)},[ti,ot,ee]),!ti)return null;var Qt="auto",kt={left:"-1000vw",top:"-1000vh",right:Qt,bottom:Qt};if(Ht||!$e){var oi,Di=ht.points,ki=ht.dynamicInset||((oi=ht._experimental)===null||oi===void 0?void 0:oi.dynamicInset),Bi=ki&&Di[0][1]==="r",pi=ki&&Di[0][0]==="b";Bi?(kt.right=Le,kt.left=Qt):(kt.left=Xe,kt.right=Qt),pi?(kt.bottom=ye,kt.top=Qt):(kt.top=Ft,kt.bottom=Qt)}var mi={};return W&&(W.includes("height")&&fe?mi.height=fe:W.includes("minHeight")&&fe&&(mi.minHeight=fe),W.includes("width")&&ae?mi.width=ae:W.includes("minWidth")&&ae&&(mi.minWidth=ae)),$e||(mi.pointerEvents="none"),M.createElement(ft,{open:Ae||st,getContainer:Me&&function(){return Me(ee)},autoDestroy:tt},M.createElement(U,{prefixCls:_t,open:$e,zIndex:je,mask:Yt,motion:zt}),M.createElement(Te.Z,{onResize:we,disabled:!$e},function(Xi){return M.createElement(Y.default,(0,O.Z)({motionAppear:!0,motionEnter:!0,motionLeave:!0,removeOnLeave:!1,forceRender:Ae,leavedClassName:"".concat(_t,"-hidden")},Gt,{onAppearPrepare:K,onEnterPrepare:K,visible:$e,onVisibleChanged:function(un){var Ji;Gt==null||(Ji=Gt.onVisibleChanged)===null||Ji===void 0||Ji.call(Gt,un),xe(un)}}),function(nn,un){var Ji=nn.className,dr=nn.style,Mi=S()(_t,Ji,nt);return M.createElement("div",{ref:(0,H.sQ)(Xi,Ge,un),className:Mi,style:(0,ce.Z)((0,ce.Z)((0,ce.Z)((0,ce.Z)({"--arrow-x":"".concat(ke.x||0,"px"),"--arrow-y":"".concat(ke.y||0,"px")},kt),mi),dr),{},{boxSizing:"border-box",zIndex:je},lt),onMouseEnter:At,onMouseLeave:Lt,onPointerEnter:vt,onClick:gt,onPointerDownCapture:Pt},pt&&M.createElement(j,{prefixCls:_t,arrow:pt,arrowPos:ke,align:ht}),M.createElement(G,{cache:!$e&&!rt},_e))})}))}),be=he,Se=M.forwardRef(function(Ne,Ge){var ve=Ne.children,nt=Ne.getTriggerDOMNode,_t=(0,H.Yr)(ve),lt=M.useCallback(function(xe){(0,H.mH)(Ge,nt?nt(xe):xe)},[nt]),ee=(0,H.x1)(lt,(0,H.C4)(ve));return _t?M.cloneElement(ve,{ref:ee}):ve}),re=Se,Oe=M.createContext(null),We=Oe;function Be(Ne){return Ne?Array.isArray(Ne)?Ne:[Ne]:[]}function Dt(Ne,Ge,ve,nt){return M.useMemo(function(){var _t=Be(ve!=null?ve:Ge),lt=Be(nt!=null?nt:Ge),ee=new Set(_t),xe=new Set(lt);return Ne&&(ee.has("hover")&&(ee.delete("hover"),ee.add("click")),xe.has("hover")&&(xe.delete("hover"),xe.add("click"))),[ee,xe]},[Ne,Ge,ve,nt])}var te=oe(29194);function z(){var Ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],Ge=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],ve=arguments.length>2?arguments[2]:void 0;return ve?Ne[0]===Ge[0]:Ne[0]===Ge[0]&&Ne[1]===Ge[1]}function X(Ne,Ge,ve,nt){for(var _t=ve.points,lt=Object.keys(Ne),ee=0;ee<lt.length;ee+=1){var xe,$e=lt[ee];if(z((xe=Ne[$e])===null||xe===void 0?void 0:xe.points,_t,nt))return"".concat(Ge,"-placement-").concat($e)}return""}function J(Ne,Ge,ve,nt){return Ge||(ve?{motionName:"".concat(Ne,"-").concat(ve)}:nt?{motionName:nt}:null)}function de(Ne){return Ne.ownerDocument.defaultView}function ie(Ne){for(var Ge=[],ve=Ne==null?void 0:Ne.parentElement,nt=["hidden","scroll","clip","auto"];ve;){var _t=de(ve).getComputedStyle(ve),lt=_t.overflowX,ee=_t.overflowY,xe=_t.overflow;[lt,ee,xe].some(function($e){return nt.includes($e)})&&Ge.push(ve),ve=ve.parentElement}return Ge}function A(Ne){var Ge=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;return Number.isNaN(Ne)?Ge:Ne}function L(Ne){return A(parseFloat(Ne),0)}function V(Ne,Ge){var ve=(0,ce.Z)({},Ne);return(Ge||[]).forEach(function(nt){if(!(nt instanceof HTMLBodyElement||nt instanceof HTMLHtmlElement)){var _t=de(nt).getComputedStyle(nt),lt=_t.overflow,ee=_t.overflowClipMargin,xe=_t.borderTopWidth,$e=_t.borderBottomWidth,Ye=_t.borderLeftWidth,rt=_t.borderRightWidth,gt=nt.getBoundingClientRect(),Yt=nt.offsetHeight,pt=nt.clientHeight,ke=nt.offsetWidth,ht=nt.clientWidth,Gt=L(xe),zt=L($e),Ae=L(Ye),Me=L(rt),tt=A(Math.round(gt.width/ke*1e3)/1e3),ft=A(Math.round(gt.height/Yt*1e3)/1e3),je=(ke-ht-Ae-Me)*tt,At=(Yt-pt-Gt-zt)*ft,Lt=Gt*ft,vt=zt*ft,Pt=Ae*tt,Ht=Me*tt,Xe=0,Ft=0;if(lt==="clip"){var Le=L(ee);Xe=Le*tt,Ft=Le*ft}var ye=gt.x+Pt-Xe,we=gt.y+Lt-Ft,K=ye+gt.width+2*Xe-Pt-Ht-je,W=we+gt.height+2*Ft-Lt-vt-At;ve.left=Math.max(ve.left,ye),ve.top=Math.max(ve.top,we),ve.right=Math.min(ve.right,K),ve.bottom=Math.min(ve.bottom,W)}}),ve}function pe(Ne){var Ge=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,ve="".concat(Ge),nt=ve.match(/^(.*)\%$/);return nt?Ne*(parseFloat(nt[1])/100):parseFloat(ve)}function ze(Ne,Ge){var ve=Ge||[],nt=(0,De.Z)(ve,2),_t=nt[0],lt=nt[1];return[pe(Ne.width,_t),pe(Ne.height,lt)]}function at(){var Ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";return[Ne[0],Ne[1]]}function Ot(Ne,Ge){var ve=Ge[0],nt=Ge[1],_t,lt;return ve==="t"?lt=Ne.y:ve==="b"?lt=Ne.y+Ne.height:lt=Ne.y+Ne.height/2,nt==="l"?_t=Ne.x:nt==="r"?_t=Ne.x+Ne.width:_t=Ne.x+Ne.width/2,{x:_t,y:lt}}function Ce(Ne,Ge){var ve={t:"b",b:"t",l:"r",r:"l"};return Ne.map(function(nt,_t){return _t===Ge?ve[nt]||"c":nt}).join("")}function jt(Ne,Ge,ve,nt,_t,lt,ee){var xe=M.useState({ready:!1,offsetX:0,offsetY:0,offsetR:0,offsetB:0,arrowX:0,arrowY:0,scaleX:1,scaleY:1,align:_t[nt]||{}}),$e=(0,De.Z)(xe,2),Ye=$e[0],rt=$e[1],gt=M.useRef(0),Yt=M.useMemo(function(){return Ge?ie(Ge):[]},[Ge]),pt=M.useRef({}),ke=function(){pt.current={}};Ne||ke();var ht=(0,ne.Z)(function(){if(Ge&&ve&&Ne){let _r=function(fr,Xn){var rs=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Dn,ss=st.x+fr,Ps=st.y+Xn,ya=ss+pi,Os=Ps+Bi,ba=Math.max(ss,rs.left),ri=Math.max(Ps,rs.top),Jt=Math.min(ya,rs.right),Wi=Math.min(Os,rs.bottom);return Math.max(0,(Jt-ba)*(Wi-ri))},Kn=function(){Ui=st.y+Ii,zi=Ui+Bi,Ln=st.x+ui,bn=Ln+pi};var Ae,Me,tt,ft,je=Ge,At=je.ownerDocument,Lt=de(je),vt=Lt.getComputedStyle(je),Pt=vt.position,Ht=je.style.left,Xe=je.style.top,Ft=je.style.right,Le=je.style.bottom,ye=je.style.overflow,we=(0,ce.Z)((0,ce.Z)({},_t[nt]),lt),K=At.createElement("div");(Ae=je.parentElement)===null||Ae===void 0||Ae.appendChild(K),K.style.left="".concat(je.offsetLeft,"px"),K.style.top="".concat(je.offsetTop,"px"),K.style.position=Pt,K.style.height="".concat(je.offsetHeight,"px"),K.style.width="".concat(je.offsetWidth,"px"),je.style.left="0",je.style.top="0",je.style.right="auto",je.style.bottom="auto",je.style.overflow="hidden";var W;if(Array.isArray(ve))W={x:ve[0],y:ve[1],width:0,height:0};else{var ae,fe,_e=ve.getBoundingClientRect();_e.x=(ae=_e.x)!==null&&ae!==void 0?ae:_e.left,_e.y=(fe=_e.y)!==null&&fe!==void 0?fe:_e.top,W={x:_e.x,y:_e.y,width:_e.width,height:_e.height}}var st=je.getBoundingClientRect(),ot=Lt.getComputedStyle(je),xt=ot.height,Ut=ot.width;st.x=(Me=st.x)!==null&&Me!==void 0?Me:st.left,st.y=(tt=st.y)!==null&&tt!==void 0?tt:st.top;var ti=At.documentElement,di=ti.clientWidth,Qt=ti.clientHeight,kt=ti.scrollWidth,oi=ti.scrollHeight,Di=ti.scrollTop,ki=ti.scrollLeft,Bi=st.height,pi=st.width,mi=W.height,Xi=W.width,nn={left:0,top:0,right:di,bottom:Qt},un={left:-ki,top:-Di,right:kt-ki,bottom:oi-Di},Ji=we.htmlRegion,dr="visible",Mi="visibleFirst";Ji!=="scroll"&&Ji!==Mi&&(Ji=dr);var Oi=Ji===Mi,yn=V(un,Yt),Ri=V(nn,Yt),Dn=Ji===dr?Ri:yn,hn=Oi?Ri:Dn;je.style.left="auto",je.style.top="auto",je.style.right="0",je.style.bottom="0";var Yn=je.getBoundingClientRect();je.style.left=Ht,je.style.top=Xe,je.style.right=Ft,je.style.bottom=Le,je.style.overflow=ye,(ft=je.parentElement)===null||ft===void 0||ft.removeChild(K);var fn=A(Math.round(pi/parseFloat(Ut)*1e3)/1e3),gr=A(Math.round(Bi/parseFloat(xt)*1e3)/1e3);if(fn===0||gr===0||(0,P.Sh)(ve)&&!(0,te.Z)(ve))return;var Yr=we.offset,Ei=we.targetOffset,$t=ze(st,Yr),Re=(0,De.Z)($t,2),Je=Re[0],ut=Re[1],it=ze(W,Ei),wt=(0,De.Z)(it,2),St=wt[0],Bt=wt[1];W.x-=St,W.y-=Bt;var ni=we.points||[],Gi=(0,De.Z)(ni,2),gi=Gi[0],dn=Gi[1],_i=at(dn),Ai=at(gi),Ci=Ot(W,_i),Ni=Ot(st,Ai),$i=(0,ce.Z)({},we),ui=Ci.x-Ni.x+Je,Ii=Ci.y-Ni.y+ut,Qi=_r(ui,Ii),Fi=_r(ui,Ii,Ri),wi=Ot(W,["t","l"]),ji=Ot(st,["t","l"]),Ki=Ot(W,["b","r"]),en=Ot(st,["b","r"]),Pn=we.overflow||{},tn=Pn.adjustX,er=Pn.adjustY,cn=Pn.shiftX,Cn=Pn.shiftY,tr=function(Xn){return typeof Xn=="boolean"?Xn:Xn>=0},Ui,zi,Ln,bn;Kn();var rn=tr(er),xn=Ai[0]===_i[0];if(rn&&Ai[0]==="t"&&(zi>hn.bottom||pt.current.bt)){var pn=Ii;xn?pn-=Bi-mi:pn=wi.y-en.y-ut;var Vn=_r(ui,pn),Mr=_r(ui,pn,Ri);Vn>Qi||Vn===Qi&&(!Oi||Mr>=Fi)?(pt.current.bt=!0,Ii=pn,ut=-ut,$i.points=[Ce(Ai,0),Ce(_i,0)]):pt.current.bt=!1}if(rn&&Ai[0]==="b"&&(Ui<hn.top||pt.current.tb)){var On=Ii;xn?On+=Bi-mi:On=Ki.y-ji.y-ut;var Br=_r(ui,On),En=_r(ui,On,Ri);Br>Qi||Br===Qi&&(!Oi||En>=Fi)?(pt.current.tb=!0,Ii=On,ut=-ut,$i.points=[Ce(Ai,0),Ce(_i,0)]):pt.current.tb=!1}var sr=tr(tn),Rr=Ai[1]===_i[1];if(sr&&Ai[1]==="l"&&(bn>hn.right||pt.current.rl)){var Tr=ui;Rr?Tr-=pi-Xi:Tr=wi.x-en.x-Je;var xr=_r(Tr,Ii),Mn=_r(Tr,Ii,Ri);xr>Qi||xr===Qi&&(!Oi||Mn>=Fi)?(pt.current.rl=!0,ui=Tr,Je=-Je,$i.points=[Ce(Ai,1),Ce(_i,1)]):pt.current.rl=!1}if(sr&&Ai[1]==="r"&&(Ln<hn.left||pt.current.lr)){var cr=ui;Rr?cr+=pi-Xi:cr=Ki.x-ji.x-Je;var wr=_r(cr,Ii),Nr=_r(cr,Ii,Ri);wr>Qi||wr===Qi&&(!Oi||Nr>=Fi)?(pt.current.lr=!0,ui=cr,Je=-Je,$i.points=[Ce(Ai,1),Ce(_i,1)]):pt.current.lr=!1}Kn();var kn=cn===!0?0:cn;typeof kn=="number"&&(Ln<Ri.left&&(ui-=Ln-Ri.left-Je,W.x+Xi<Ri.left+kn&&(ui+=W.x-Ri.left+Xi-kn)),bn>Ri.right&&(ui-=bn-Ri.right-Je,W.x>Ri.right-kn&&(ui+=W.x-Ri.right+kn)));var pr=Cn===!0?0:Cn;typeof pr=="number"&&(Ui<Ri.top&&(Ii-=Ui-Ri.top-ut,W.y+mi<Ri.top+pr&&(Ii+=W.y-Ri.top+mi-pr)),zi>Ri.bottom&&(Ii-=zi-Ri.bottom-ut,W.y>Ri.bottom-pr&&(Ii+=W.y-Ri.bottom+pr)));var Gn=st.x+ui,hr=Gn+pi,Wr=st.y+Ii,Hi=Wr+Bi,vi=W.x,Wt=vi+Xi,_n=W.y,mr=_n+mi,Nn=Math.max(Gn,vi),ar=Math.min(hr,Wt),$n=(Nn+ar)/2,cs=$n-Gn,Sr=Math.max(Wr,_n),vn=Math.min(Hi,mr),hs=(Sr+vn)/2,ns=hs-Wr;ee==null||ee(Ge,$i);var or=Yn.right-st.x-(ui+st.width),jr=Yn.bottom-st.y-(Ii+st.height);fn===1&&(ui=Math.round(ui),or=Math.round(or)),gr===1&&(Ii=Math.round(Ii),jr=Math.round(jr));var ys={ready:!0,offsetX:ui/fn,offsetY:Ii/gr,offsetR:or/fn,offsetB:jr/gr,arrowX:cs/fn,arrowY:ns/gr,scaleX:fn,scaleY:gr,align:$i};rt(ys)}}),Gt=function(){gt.current+=1;var Me=gt.current;Promise.resolve().then(function(){gt.current===Me&&ht()})},zt=function(){rt(function(Me){return(0,ce.Z)((0,ce.Z)({},Me),{},{ready:!1})})};return(0,k.Z)(zt,[nt]),(0,k.Z)(function(){Ne||zt()},[Ne]),[Ye.ready,Ye.offsetX,Ye.offsetY,Ye.offsetR,Ye.offsetB,Ye.arrowX,Ye.arrowY,Ye.scaleX,Ye.scaleY,Ye.align,Gt]}var Mt=oe(94480);function dt(Ne,Ge,ve,nt,_t){(0,k.Z)(function(){if(Ne&&Ge&&ve){let gt=function(){nt(),_t()};var lt=Ge,ee=ve,xe=ie(lt),$e=ie(ee),Ye=de(ee),rt=new Set([Ye].concat((0,Mt.Z)(xe),(0,Mt.Z)($e)));return rt.forEach(function(Yt){Yt.addEventListener("scroll",gt,{passive:!0})}),Ye.addEventListener("resize",gt,{passive:!0}),nt(),function(){rt.forEach(function(Yt){Yt.removeEventListener("scroll",gt),Ye.removeEventListener("resize",gt)})}}},[Ne,Ge,ve])}var Ti=oe(48736);function fi(Ne,Ge,ve,nt,_t,lt,ee,xe){var $e=M.useRef(Ne);$e.current=Ne;var Ye=M.useRef(!1);M.useEffect(function(){if(Ge&&nt&&(!_t||lt)){var gt=function(){Ye.current=!1},Yt=function(tt){var ft;$e.current&&!ee(((ft=tt.composedPath)===null||ft===void 0||(ft=ft.call(tt))===null||ft===void 0?void 0:ft[0])||tt.target)&&!Ye.current&&xe(!1)},pt=de(nt);pt.addEventListener("pointerdown",gt,!0),pt.addEventListener("mousedown",Yt,!0),pt.addEventListener("contextmenu",Yt,!0);var ke=(0,d.A)(ve);if(ke&&(ke.addEventListener("mousedown",Yt,!0),ke.addEventListener("contextmenu",Yt,!0)),0)var ht,Gt,zt,Ae;return function(){pt.removeEventListener("pointerdown",gt,!0),pt.removeEventListener("mousedown",Yt,!0),pt.removeEventListener("contextmenu",Yt,!0),ke&&(ke.removeEventListener("mousedown",Yt,!0),ke.removeEventListener("contextmenu",Yt,!0))}}},[Ge,ve,nt,_t,lt]);function rt(){Ye.current=!0}return rt}var Yi=["prefixCls","children","action","showAction","hideAction","popupVisible","defaultPopupVisible","onPopupVisibleChange","afterPopupVisibleChange","mouseEnterDelay","mouseLeaveDelay","focusDelay","blurDelay","mask","maskClosable","getPopupContainer","forceRender","autoDestroy","destroyPopupOnHide","popup","popupClassName","popupStyle","popupPlacement","builtinPlacements","popupAlign","zIndex","stretch","getPopupClassNameFromAlign","fresh","alignPoint","onPopupClick","onPopupAlign","arrow","popupMotion","maskMotion","popupTransitionName","popupAnimation","maskTransitionName","maskAnimation","className","getTriggerDOMNode"];function Kt(){var Ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ge.Z,Ge=M.forwardRef(function(ve,nt){var _t=ve.prefixCls,lt=_t===void 0?"rc-trigger-popup":_t,ee=ve.children,xe=ve.action,$e=xe===void 0?"hover":xe,Ye=ve.showAction,rt=ve.hideAction,gt=ve.popupVisible,Yt=ve.defaultPopupVisible,pt=ve.onPopupVisibleChange,ke=ve.afterPopupVisibleChange,ht=ve.mouseEnterDelay,Gt=ve.mouseLeaveDelay,zt=Gt===void 0?.1:Gt,Ae=ve.focusDelay,Me=ve.blurDelay,tt=ve.mask,ft=ve.maskClosable,je=ft===void 0?!0:ft,At=ve.getPopupContainer,Lt=ve.forceRender,vt=ve.autoDestroy,Pt=ve.destroyPopupOnHide,Ht=ve.popup,Xe=ve.popupClassName,Ft=ve.popupStyle,Le=ve.popupPlacement,ye=ve.builtinPlacements,we=ye===void 0?{}:ye,K=ve.popupAlign,W=ve.zIndex,ae=ve.stretch,fe=ve.getPopupClassNameFromAlign,_e=ve.fresh,st=ve.alignPoint,ot=ve.onPopupClick,xt=ve.onPopupAlign,Ut=ve.arrow,ti=ve.popupMotion,di=ve.maskMotion,Qt=ve.popupTransitionName,kt=ve.popupAnimation,oi=ve.maskTransitionName,Di=ve.maskAnimation,ki=ve.className,Bi=ve.getTriggerDOMNode,pi=(0,qe.Z)(ve,Yi),mi=vt||Pt||!1,Xi=M.useState(!1),nn=(0,De.Z)(Xi,2),un=nn[0],Ji=nn[1];(0,k.Z)(function(){Ji((0,T.Z)())},[]);var dr=M.useRef({}),Mi=M.useContext(We),Oi=M.useMemo(function(){return{registerSubPopup:function(Jt,Wi){dr.current[Jt]=Wi,Mi==null||Mi.registerSubPopup(Jt,Wi)}}},[Mi]),yn=(0,I.Z)(),Ri=M.useState(null),Dn=(0,De.Z)(Ri,2),hn=Dn[0],Yn=Dn[1],fn=M.useRef(null),gr=(0,ne.Z)(function(ri){fn.current=ri,(0,P.Sh)(ri)&&hn!==ri&&Yn(ri),Mi==null||Mi.registerSubPopup(yn,ri)}),Yr=M.useState(null),Ei=(0,De.Z)(Yr,2),$t=Ei[0],Re=Ei[1],Je=M.useRef(null),ut=(0,ne.Z)(function(ri){(0,P.Sh)(ri)&&$t!==ri&&(Re(ri),Je.current=ri)}),it=M.Children.only(ee),wt=(it==null?void 0:it.props)||{},St={},Bt=(0,ne.Z)(function(ri){var Jt,Wi,Hn=$t;return(Hn==null?void 0:Hn.contains(ri))||((Jt=(0,d.A)(Hn))===null||Jt===void 0?void 0:Jt.host)===ri||ri===Hn||(hn==null?void 0:hn.contains(ri))||((Wi=(0,d.A)(hn))===null||Wi===void 0?void 0:Wi.host)===ri||ri===hn||Object.values(dr.current).some(function(mn){return(mn==null?void 0:mn.contains(ri))||ri===mn})}),ni=J(lt,ti,kt,Qt),Gi=J(lt,di,Di,oi),gi=M.useState(Yt||!1),dn=(0,De.Z)(gi,2),_i=dn[0],Ai=dn[1],Ci=gt!=null?gt:_i,Ni=(0,ne.Z)(function(ri){gt===void 0&&Ai(ri)});(0,k.Z)(function(){Ai(gt||!1)},[gt]);var $i=M.useRef(Ci);$i.current=Ci;var ui=M.useRef([]);ui.current=[];var Ii=(0,ne.Z)(function(ri){var Jt;Ni(ri),((Jt=ui.current[ui.current.length-1])!==null&&Jt!==void 0?Jt:Ci)!==ri&&(ui.current.push(ri),pt==null||pt(ri))}),Qi=M.useRef(),Fi=function(){clearTimeout(Qi.current)},wi=function(Jt){var Wi=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;Fi(),Wi===0?Ii(Jt):Qi.current=setTimeout(function(){Ii(Jt)},Wi*1e3)};M.useEffect(function(){return Fi},[]);var ji=M.useState(!1),Ki=(0,De.Z)(ji,2),en=Ki[0],Pn=Ki[1];(0,k.Z)(function(ri){(!ri||Ci)&&Pn(!0)},[Ci]);var tn=M.useState(null),er=(0,De.Z)(tn,2),cn=er[0],Cn=er[1],tr=M.useState(null),Ui=(0,De.Z)(tr,2),zi=Ui[0],Ln=Ui[1],bn=function(Jt){Ln([Jt.clientX,Jt.clientY])},rn=jt(Ci,hn,st&&zi!==null?zi:$t,Le,we,K,xt),xn=(0,De.Z)(rn,11),pn=xn[0],Vn=xn[1],Mr=xn[2],On=xn[3],Br=xn[4],En=xn[5],sr=xn[6],Rr=xn[7],Tr=xn[8],xr=xn[9],Mn=xn[10],cr=Dt(un,$e,Ye,rt),wr=(0,De.Z)(cr,2),Nr=wr[0],kn=wr[1],pr=Nr.has("click"),Gn=kn.has("click")||kn.has("contextMenu"),hr=(0,ne.Z)(function(){en||Mn()}),Wr=function(){$i.current&&st&&Gn&&wi(!1)};dt(Ci,$t,hn,hr,Wr),(0,k.Z)(function(){hr()},[zi,Le]),(0,k.Z)(function(){Ci&&!(we!=null&&we[Le])&&hr()},[JSON.stringify(K)]);var Hi=M.useMemo(function(){var ri=X(we,lt,xr,st);return S()(ri,fe==null?void 0:fe(xr))},[xr,fe,we,lt,st]);M.useImperativeHandle(nt,function(){return{nativeElement:Je.current,popupElement:fn.current,forceAlign:hr}});var vi=M.useState(0),Wt=(0,De.Z)(vi,2),_n=Wt[0],mr=Wt[1],Nn=M.useState(0),ar=(0,De.Z)(Nn,2),$n=ar[0],cs=ar[1],Sr=function(){if(ae&&$t){var Jt=$t.getBoundingClientRect();mr(Jt.width),cs(Jt.height)}},vn=function(){Sr(),hr()},hs=function(Jt){Pn(!1),Mn(),ke==null||ke(Jt)},ns=function(){return new Promise(function(Jt){Sr(),Cn(function(){return Jt})})};(0,k.Z)(function(){cn&&(Mn(),cn(),Cn(null))},[cn]);function or(ri,Jt,Wi,Hn){St[ri]=function(mn){var $r;Hn==null||Hn(mn),wi(Jt,Wi);for(var ir=arguments.length,Ts=new Array(ir>1?ir-1:0),fs=1;fs<ir;fs++)Ts[fs-1]=arguments[fs];($r=wt[ri])===null||$r===void 0||$r.call.apply($r,[wt,mn].concat(Ts))}}(pr||Gn)&&(St.onClick=function(ri){var Jt;$i.current&&Gn?wi(!1):!$i.current&&pr&&(bn(ri),wi(!0));for(var Wi=arguments.length,Hn=new Array(Wi>1?Wi-1:0),mn=1;mn<Wi;mn++)Hn[mn-1]=arguments[mn];(Jt=wt.onClick)===null||Jt===void 0||Jt.call.apply(Jt,[wt,ri].concat(Hn))});var jr=fi(Ci,Gn,$t,hn,tt,je,Bt,wi),ys=Nr.has("hover"),_r=kn.has("hover"),Kn,fr;ys&&(or("onMouseEnter",!0,ht,function(ri){bn(ri)}),or("onPointerEnter",!0,ht,function(ri){bn(ri)}),Kn=function(Jt){(Ci||en)&&hn!==null&&hn!==void 0&&hn.contains(Jt.target)&&wi(!0,ht)},st&&(St.onMouseMove=function(ri){var Jt;(Jt=wt.onMouseMove)===null||Jt===void 0||Jt.call(wt,ri)})),_r&&(or("onMouseLeave",!1,zt),or("onPointerLeave",!1,zt),fr=function(){wi(!1,zt)}),Nr.has("focus")&&or("onFocus",!0,Ae),kn.has("focus")&&or("onBlur",!1,Me),Nr.has("contextMenu")&&(St.onContextMenu=function(ri){var Jt;$i.current&&kn.has("contextMenu")?wi(!1):(bn(ri),wi(!0)),ri.preventDefault();for(var Wi=arguments.length,Hn=new Array(Wi>1?Wi-1:0),mn=1;mn<Wi;mn++)Hn[mn-1]=arguments[mn];(Jt=wt.onContextMenu)===null||Jt===void 0||Jt.call.apply(Jt,[wt,ri].concat(Hn))}),ki&&(St.className=S()(wt.className,ki));var Xn=M.useRef(!1);Xn.current||(Xn.current=Lt||Ci||en);var rs=(0,ce.Z)((0,ce.Z)({},wt),St),ss={},Ps=["onContextMenu","onClick","onMouseDown","onTouchStart","onMouseEnter","onMouseLeave","onFocus","onBlur"];Ps.forEach(function(ri){pi[ri]&&(ss[ri]=function(){for(var Jt,Wi=arguments.length,Hn=new Array(Wi),mn=0;mn<Wi;mn++)Hn[mn]=arguments[mn];(Jt=rs[ri])===null||Jt===void 0||Jt.call.apply(Jt,[rs].concat(Hn)),pi[ri].apply(pi,Hn)})});var ya=M.cloneElement(it,(0,ce.Z)((0,ce.Z)({},rs),ss)),Os={x:En,y:sr},ba=Ut?(0,ce.Z)({},Ut!==!0?Ut:{}):null;return M.createElement(M.Fragment,null,M.createElement(Te.Z,{disabled:!Ci,ref:ut,onResize:vn},M.createElement(re,{getTriggerDOMNode:Bi},ya)),Xn.current&&M.createElement(We.Provider,{value:Oi},M.createElement(be,{portal:Ne,ref:gr,prefixCls:lt,popup:Ht,className:S()(Xe,Hi),style:Ft,target:$t,onMouseEnter:Kn,onMouseLeave:fr,onPointerEnter:Kn,zIndex:W,open:Ci,keepDom:en,fresh:_e,onClick:ot,onPointerDownCapture:jr,mask:tt,motion:ni,maskMotion:Gi,onVisibleChanged:hs,onPrepare:ns,forceRender:Lt,autoDestroy:mi,getPopupContainer:At,align:xr,arrow:ba,arrowPos:Os,ready:pn,offsetX:Vn,offsetY:Mr,offsetR:On,offsetB:Br,onAlign:hr,stretch:ae,targetWidth:_n/Rr,targetHeight:$n/Tr})))});return Ge}var ln=Kt(ge.Z)},64018:function(){var Li,Rt,oe,ce=!1,De,qe;window.PR_SHOULD_USE_CONTINUATION=!0;var ge,q;(function(){var S=window,Te=["break,continue,do,else,for,if,return,while"],P=[Te,"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"],d=[P,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],ne=[d,"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"],I=[d,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],k=[d,"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"],T="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",M=[d,"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",Y=[Te,"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"],H=[Te,"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"],j=[Te,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],U=[ne,k,I,M,O,Y,H,j],$=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,G="str",he="kwd",be="com",Se="typ",re="lit",Oe="pun",We="pln",Be="tag",Dt="dec",te="src",z="atn",X="atv",J="nocode",de="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function ie(Ge){for(var ve=0,nt=!1,_t=!1,lt=0,ee=Ge.length;lt<ee;++lt){var xe=Ge[lt];if(xe.ignoreCase)_t=!0;else if(/[a-z]/i.test(xe.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){nt=!0,_t=!1;break}}var $e={b:8,t:9,n:10,v:11,f:12,r:13};function Ye(ke){var ht=ke.charCodeAt(0);if(ht!==92)return ht;var Gt=ke.charAt(1);return ht=$e[Gt],ht||("0"<=Gt&&Gt<="7"?parseInt(ke.substring(1),8):Gt==="u"||Gt==="x"?parseInt(ke.substring(2),16):ke.charCodeAt(1))}function rt(ke){if(ke<32)return(ke<16?"\\x0":"\\x")+ke.toString(16);var ht=String.fromCharCode(ke);return ht==="\\"||ht==="-"||ht==="]"||ht==="^"?"\\"+ht:ht}function gt(ke){var ht=ke.substring(1,ke.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")),Gt=[],zt=ht[0]==="^",Ae=["["];zt&&Ae.push("^");for(var Me=zt?1:0,tt=ht.length;Me<tt;++Me){var ft=ht[Me];if(/\\[bdsw]/i.test(ft))Ae.push(ft);else{var je=Ye(ft),At;Me+2<tt&&ht[Me+1]==="-"?(At=Ye(ht[Me+2]),Me+=2):At=je,Gt.push([je,At]),At<65||je>122||(At<65||je>90||Gt.push([Math.max(65,je)|32,Math.min(At,90)|32]),At<97||je>122||Gt.push([Math.max(97,je)&-33,Math.min(At,122)&-33]))}}Gt.sort(function(Ht,Xe){return Ht[0]-Xe[0]||Xe[1]-Ht[1]});for(var Lt=[],vt=[],Me=0;Me<Gt.length;++Me){var Pt=Gt[Me];Pt[0]<=vt[1]+1?vt[1]=Math.max(vt[1],Pt[1]):Lt.push(vt=Pt)}for(var Me=0;Me<Lt.length;++Me){var Pt=Lt[Me];Ae.push(rt(Pt[0])),Pt[1]>Pt[0]&&(Pt[1]+1>Pt[0]&&Ae.push("-"),Ae.push(rt(Pt[1])))}return Ae.push("]"),Ae.join("")}function Yt(ke){for(var ht=ke.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),Gt=ht.length,zt=[],Ae=0,Me=0;Ae<Gt;++Ae){var tt=ht[Ae];if(tt==="(")++Me;else if(tt.charAt(0)==="\\"){var ft=+tt.substring(1);ft&&(ft<=Me?zt[ft]=-1:ht[Ae]=rt(ft))}}for(var Ae=1;Ae<zt.length;++Ae)zt[Ae]===-1&&(zt[Ae]=++ve);for(var Ae=0,Me=0;Ae<Gt;++Ae){var tt=ht[Ae];if(tt==="(")++Me,zt[Me]||(ht[Ae]="(?:");else if(tt.charAt(0)==="\\"){var ft=+tt.substring(1);ft&&ft<=Me&&(ht[Ae]="\\"+zt[ft])}}for(var Ae=0;Ae<Gt;++Ae)ht[Ae]==="^"&&ht[Ae+1]!=="^"&&(ht[Ae]="");if(ke.ignoreCase&&nt)for(var Ae=0;Ae<Gt;++Ae){var tt=ht[Ae],je=tt.charAt(0);tt.length>=2&&je==="["?ht[Ae]=gt(tt):je!=="\\"&&(ht[Ae]=tt.replace(/[a-zA-Z]/g,function(vt){var Pt=vt.charCodeAt(0);return"["+String.fromCharCode(Pt&-33,Pt|32)+"]"}))}return ht.join("")}for(var pt=[],lt=0,ee=Ge.length;lt<ee;++lt){var xe=Ge[lt];if(xe.global||xe.multiline)throw new Error(""+xe);pt.push("(?:"+Yt(xe)+")")}return new RegExp(pt.join("|"),_t?"gi":"g")}function A(Ge,ve){var nt=/(?:^|\s)nocode(?:\s|$)/,_t=[],lt=0,ee=[],xe=0;function $e(Ye){var rt=Ye.nodeType;if(rt==1){if(nt.test(Ye.className))return;for(var gt=Ye.firstChild;gt;gt=gt.nextSibling)$e(gt);var Yt=Ye.nodeName.toLowerCase();(Yt==="br"||Yt==="li")&&(_t[xe]=`
`,ee[xe<<1]=lt++,ee[xe++<<1|1]=Ye)}else if(rt==3||rt==4){var pt=Ye.nodeValue;pt.length&&(ve?pt=pt.replace(/\r\n?/g,`
`):pt=pt.replace(/[ \t\r\n]+/g," "),_t[xe]=pt,ee[xe<<1]=lt,lt+=pt.length,ee[xe++<<1|1]=Ye)}}return $e(Ge),{sourceCode:_t.join("").replace(/\n$/,""),spans:ee}}function L(Ge,ve,nt,_t,lt){if(nt){var ee={sourceNode:Ge,pre:1,langExtension:null,numberLines:null,sourceCode:nt,spans:null,basePos:ve,decorations:null};_t(ee),lt.push.apply(lt,ee.decorations)}}var V=/\S/;function pe(Ge){for(var ve=void 0,nt=Ge.firstChild;nt;nt=nt.nextSibling){var _t=nt.nodeType;ve=_t===1?ve?Ge:nt:_t===3&&V.test(nt.nodeValue)?Ge:ve}return ve===Ge?void 0:ve}function ze(Ge,ve){var nt={},_t;(function(){for(var xe=Ge.concat(ve),$e=[],Ye={},rt=0,gt=xe.length;rt<gt;++rt){var Yt=xe[rt],pt=Yt[3];if(pt)for(var ke=pt.length;--ke>=0;)nt[pt.charAt(ke)]=Yt;var ht=Yt[1],Gt=""+ht;Ye.hasOwnProperty(Gt)||($e.push(ht),Ye[Gt]=null)}$e.push(/[\0-\uffff]/),_t=ie($e)})();var lt=ve.length,ee=function(xe){for(var $e=xe.sourceCode,Ye=xe.basePos,rt=xe.sourceNode,gt=[Ye,We],Yt=0,pt=$e.match(_t)||[],ke={},ht=0,Gt=pt.length;ht<Gt;++ht){var zt=pt[ht],Ae=ke[zt],Me=void 0,tt;if(typeof Ae=="string")tt=!1;else{var ft=nt[zt.charAt(0)];if(ft)Me=zt.match(ft[1]),Ae=ft[0];else{for(var je=0;je<lt;++je)if(ft=ve[je],Me=zt.match(ft[1]),Me){Ae=ft[0];break}Me||(Ae=We)}tt=Ae.length>=5&&Ae.substring(0,5)==="lang-",tt&&!(Me&&typeof Me[1]=="string")&&(tt=!1,Ae=te),tt||(ke[zt]=Ae)}var At=Yt;if(Yt+=zt.length,!tt)gt.push(Ye+At,Ae);else{var Lt=Me[1],vt=zt.indexOf(Lt),Pt=vt+Lt.length;Me[2]&&(Pt=zt.length-Me[2].length,vt=Pt-Lt.length);var Ht=Ae.substring(5);L(rt,Ye+At,zt.substring(0,vt),ee,gt),L(rt,Ye+At+vt,Lt,Ti(Ht,Lt),gt),L(rt,Ye+At+Pt,zt.substring(Pt),ee,gt)}}xe.decorations=gt};return ee}function at(Ge){var ve=[],nt=[];Ge.tripleQuotedStrings?ve.push([G,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):Ge.multiLineStrings?ve.push([G,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):ve.push([G,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),Ge.verbatimStrings&&nt.push([G,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var _t=Ge.hashComments;_t&&(Ge.cStyleComments?(_t>1?ve.push([be,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):ve.push([be,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),nt.push([G,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):ve.push([be,/^#[^\r\n]*/,null,"#"])),Ge.cStyleComments&&(nt.push([be,/^\/\/[^\r\n]*/,null]),nt.push([be,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var lt=Ge.regexLiterals;if(lt){var ee=lt>1?"":`
\r`,xe=ee?".":"[\\S\\s]",$e="/(?=[^/*"+ee+"])(?:[^/\\x5B\\x5C"+ee+"]|\\x5C"+xe+"|\\x5B(?:[^\\x5C\\x5D"+ee+"]|\\x5C"+xe+")*(?:\\x5D|$))+/";nt.push(["lang-regex",RegExp("^"+de+"("+$e+")")])}var Ye=Ge.types;Ye&&nt.push([Se,Ye]);var rt=(""+Ge.keywords).replace(/^ | $/g,"");rt.length&&nt.push([he,new RegExp("^(?:"+rt.replace(/[\s,]+/g,"|")+")\\b"),null]),ve.push([We,/^\s+/,null,` \r
\xA0`]);var gt="^.[^\\s\\w.$@'\"`/\\\\]*";return Ge.regexLiterals&&(gt+="(?!s*/)"),nt.push([re,/^@[a-z_$][a-z_$@0-9]*/i,null],[Se,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[We,/^[a-z_$][a-z_$@0-9]*/i,null],[re,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[We,/^\\[\s\S]?/,null],[Oe,new RegExp(gt),null]),ze(ve,nt)}var Ot=at({keywords:U,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function Ce(Ge,ve,nt){for(var _t=/(?:^|\s)nocode(?:\s|$)/,lt=/\r\n?|\n/,ee=Ge.ownerDocument,xe=ee.createElement("li");Ge.firstChild;)xe.appendChild(Ge.firstChild);var $e=[xe];function Ye(ht){var Gt=ht.nodeType;if(Gt==1&&!_t.test(ht.className))if(ht.nodeName==="br")rt(ht),ht.parentNode&&ht.parentNode.removeChild(ht);else for(var zt=ht.firstChild;zt;zt=zt.nextSibling)Ye(zt);else if((Gt==3||Gt==4)&&nt){var Ae=ht.nodeValue,Me=Ae.match(lt);if(Me){var tt=Ae.substring(0,Me.index);ht.nodeValue=tt;var ft=Ae.substring(Me.index+Me[0].length);if(ft){var je=ht.parentNode;je.insertBefore(ee.createTextNode(ft),ht.nextSibling)}rt(ht),tt||ht.parentNode.removeChild(ht)}}}function rt(ht){for(;!ht.nextSibling;)if(ht=ht.parentNode,!ht)return;function Gt(Me,tt){var ft=tt?Me.cloneNode(!1):Me,je=Me.parentNode;if(je){var At=Gt(je,1),Lt=Me.nextSibling;At.appendChild(ft);for(var vt=Lt;vt;vt=Lt)Lt=vt.nextSibling,At.appendChild(vt)}return ft}for(var zt=Gt(ht.nextSibling,0),Ae;(Ae=zt.parentNode)&&Ae.nodeType===1;)zt=Ae;$e.push(zt)}for(var gt=0;gt<$e.length;++gt)Ye($e[gt]);ve===(ve|0)&&$e[0].setAttribute("value",ve);var Yt=ee.createElement("ol");Yt.className="linenums";for(var pt=Math.max(0,ve-1|0)||0,gt=0,ke=$e.length;gt<ke;++gt)xe=$e[gt],xe.className="L"+(gt+pt)%10,xe.firstChild||xe.appendChild(ee.createTextNode("\xA0")),Yt.appendChild(xe);Ge.appendChild(Yt)}function jt(Ge){var ve=/\bMSIE\s(\d+)/.exec(navigator.userAgent);ve=ve&&+ve[1]<=8;var nt=/\n/g,_t=Ge.sourceCode,lt=_t.length,ee=0,xe=Ge.spans,$e=xe.length,Ye=0,rt=Ge.decorations,gt=rt.length,Yt=0;rt[gt]=lt;var pt,ke;for(ke=pt=0;ke<gt;)rt[ke]!==rt[ke+2]?(rt[pt++]=rt[ke++],rt[pt++]=rt[ke++]):ke+=2;for(gt=pt,ke=pt=0;ke<gt;){for(var ht=rt[ke],Gt=rt[ke+1],zt=ke+2;zt+2<=gt&&rt[zt+1]===Gt;)zt+=2;rt[pt++]=ht,rt[pt++]=Gt,ke=zt}gt=rt.length=pt;var Ae=Ge.sourceNode,Me="";Ae&&(Me=Ae.style.display,Ae.style.display="none");try{for(var tt=null;Ye<$e;){var ft=xe[Ye],je=xe[Ye+2]||lt,At=rt[Yt+2]||lt,zt=Math.min(je,At),Lt=xe[Ye+1],vt;if(Lt.nodeType!==1&&(vt=_t.substring(ee,zt))){ve&&(vt=vt.replace(nt,"\r")),Lt.nodeValue=vt;var Pt=Lt.ownerDocument,Ht=Pt.createElement("span");Ht.className=rt[Yt+1];var Xe=Lt.parentNode;Xe.replaceChild(Ht,Lt),Ht.appendChild(Lt),ee<je&&(xe[Ye+1]=Lt=Pt.createTextNode(_t.substring(zt,je)),Xe.insertBefore(Lt,Ht.nextSibling))}ee=zt,ee>=je&&(Ye+=2),ee>=At&&(Yt+=2)}}finally{Ae&&(Ae.style.display=Me)}}var Mt={};function dt(Ge,ve){for(var nt=ve.length;--nt>=0;){var _t=ve[nt];Mt.hasOwnProperty(_t)?S.console&&console.warn("cannot override language handler %s",_t):Mt[_t]=Ge}}function Ti(Ge,ve){return Ge&&Mt.hasOwnProperty(Ge)||(Ge=/^\s*</.test(ve)?"default-markup":"default-code"),Mt[Ge]}dt(Ot,["default-code"]),dt(ze([],[[We,/^[^<?]+/],[Dt,/^<!\w[^>]*(?:>|$)/],[be,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[Oe,/^(?:<[%?]|[%?]>)/],["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"]),dt(ze([[We,/^[\s]+/,null,` \r
`],[X,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[Be,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[z,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[Oe,/^[=<>\/]+/],["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"]),dt(ze([],[[X,/^[\s\S]+/]]),["uq.val"]),dt(at({keywords:ne,hashComments:!0,cStyleComments:!0,types:$}),["c","cc","cpp","cxx","cyc","m"]),dt(at({keywords:"null,true,false"}),["json"]),dt(at({keywords:k,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:$}),["cs"]),dt(at({keywords:I,cStyleComments:!0}),["java"]),dt(at({keywords:j,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),dt(at({keywords:Y,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),dt(at({keywords:O,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),dt(at({keywords:H,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),dt(at({keywords:M,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),dt(at({keywords:T,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),dt(ze([],[[G,/^[\s\S]+/]]),["regex"]);function fi(Ge){var ve=Ge.langExtension;try{var nt=A(Ge.sourceNode,Ge.pre),_t=nt.sourceCode;Ge.sourceCode=_t,Ge.spans=nt.spans,Ge.basePos=0,Ti(ve,_t)(Ge),jt(Ge)}catch(lt){S.console&&console.log(lt&&lt.stack||lt)}}function Yi(Ge,ve,nt){var _t=nt||!1,lt=ve||null,ee=document.createElement("div");ee.innerHTML="<pre>"+Ge+"</pre>",ee=ee.firstChild,_t&&Ce(ee,_t,!0);var xe={langExtension:lt,numberLines:_t,sourceNode:ee,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return fi(xe),ee.innerHTML}function Kt(Ge,ve){var nt=ve||document.body,_t=nt.ownerDocument||document;function lt(ft){return nt.getElementsByTagName(ft)}for(var ee=[lt("pre"),lt("code"),lt("xmp")],xe=[],$e=0;$e<ee.length;++$e)for(var Ye=0,rt=ee[$e].length;Ye<rt;++Ye)xe.push(ee[$e][Ye]);ee=null;var gt=Date;gt.now||(gt={now:function(){return+new Date}});var Yt=0,pt=/\blang(?:uage)?-([\w.]+)(?!\S)/,ke=/\bprettyprint\b/,ht=/\bprettyprinted\b/,Gt=/pre|xmp/i,zt=/^code$/i,Ae=/^(?:pre|code|xmp)$/i,Me={};function tt(){for(var ft=S.PR_SHOULD_USE_CONTINUATION?gt.now()+250:1/0;Yt<xe.length&&gt.now()<ft;Yt++){for(var je=xe[Yt],At=Me,Lt=je;Lt=Lt.previousSibling;){var vt=Lt.nodeType,Pt=(vt===7||vt===8)&&Lt.nodeValue;if(Pt?!/^\??prettify\b/.test(Pt):vt!==3||/\S/.test(Lt.nodeValue))break;if(Pt){At={},Pt.replace(/\b(\w+)=([\w:.%+-]+)/g,function(ot,xt,Ut){At[xt]=Ut});break}}var Ht=je.className;if((At!==Me||ke.test(Ht))&&!ht.test(Ht)){for(var Xe=!1,Ft=je.parentNode;Ft;Ft=Ft.parentNode){var Le=Ft.tagName;if(Ae.test(Le)&&Ft.className&&ke.test(Ft.className)){Xe=!0;break}}if(!Xe){je.className+=" prettyprinted";var ye=At.lang;if(!ye){ye=Ht.match(pt);var we;!ye&&(we=pe(je))&&zt.test(we.tagName)&&(ye=we.className.match(pt)),ye&&(ye=ye[1])}var K;if(Gt.test(je.tagName))K=1;else{var W=je.currentStyle,ae=_t.defaultView,fe=W?W.whiteSpace:ae&&ae.getComputedStyle?ae.getComputedStyle(je,null).getPropertyValue("white-space"):0;K=fe&&fe.substring(0,3)==="pre"}var _e=At.linenums;(_e=_e==="true"||+_e)||(_e=Ht.match(/\blinenums\b(?::(\d+))?/),_e=_e?_e[1]&&_e[1].length?+_e[1]:!0:!1),_e&&Ce(je,_e,K);var st={langExtension:ye,sourceNode:je,numberLines:_e,pre:K,sourceCode:null,basePos:null,spans:null,decorations:null};fi(st)}}}Yt<xe.length?S.setTimeout(tt,250):typeof Ge=="function"&&Ge()}tt()}var ln=S.PR={createSimpleLexer:ze,registerLangHandler:dt,sourceDecorator:at,PR_ATTRIB_NAME:z,PR_ATTRIB_VALUE:X,PR_COMMENT:be,PR_DECLARATION:Dt,PR_KEYWORD:he,PR_LITERAL:re,PR_NOCODE:J,PR_PLAIN:We,PR_PUNCTUATION:Oe,PR_SOURCE:te,PR_STRING:G,PR_TAG:Be,PR_TYPE:Se,prettyPrintOne:ce?S.prettyPrintOne=Yi:ge=Yi,prettyPrint:q=ce?S.prettyPrint=Kt:q=Kt},Ne=S.define;typeof Ne=="function"&&Ne.amd&&Ne("google-code-prettify",[],function(){return ln})})()},25769:function(Li,Rt,oe){"use strict";var ce=oe(98040),De={"text/plain":"Text","text/html":"Url",default:"Text"},qe="Copy to clipboard: #{key}, Enter";function ge(S){var Te=(/mac os x/i.test(navigator.userAgent)?"\u2318":"Ctrl")+"+C";return S.replace(/#{\s*key\s*}/g,Te)}function q(S,Te){var P,d,ne,I,k,T,M=!1;Te||(Te={}),P=Te.debug||!1;try{ne=ce(),I=document.createRange(),k=document.getSelection(),T=document.createElement("span"),T.textContent=S,T.ariaHidden="true",T.style.all="unset",T.style.position="fixed",T.style.top=0,T.style.clip="rect(0, 0, 0, 0)",T.style.whiteSpace="pre",T.style.webkitUserSelect="text",T.style.MozUserSelect="text",T.style.msUserSelect="text",T.style.userSelect="text",T.addEventListener("copy",function(Y){if(Y.stopPropagation(),Te.format)if(Y.preventDefault(),typeof Y.clipboardData=="undefined"){P&&console.warn("unable to use e.clipboardData"),P&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var H=De[Te.format]||De.default;window.clipboardData.setData(H,S)}else Y.clipboardData.clearData(),Y.clipboardData.setData(Te.format,S);Te.onCopy&&(Y.preventDefault(),Te.onCopy(Y.clipboardData))}),document.body.appendChild(T),I.selectNodeContents(T),k.addRange(I);var O=document.execCommand("copy");if(!O)throw new Error("copy command was unsuccessful");M=!0}catch(Y){P&&console.error("unable to copy using execCommand: ",Y),P&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(Te.format||"text",S),Te.onCopy&&Te.onCopy(window.clipboardData),M=!0}catch(H){P&&console.error("unable to copy using clipboardData: ",H),P&&console.error("falling back to prompt"),d=ge("message"in Te?Te.message:qe),window.prompt(d,S)}}finally{k&&(typeof k.removeRange=="function"?k.removeRange(I):k.removeAllRanges()),T&&document.body.removeChild(T),ne()}return M}Li.exports=q},53184:function(Li,Rt,oe){"use strict";var ce,De;function qe(ge,q,S){var Te=function(P,d){return ge.js_beautify(P,d)};return Te.js=ge.js_beautify,Te.css=q.css_beautify,Te.html=S.html_beautify,Te.js_beautify=ge.js_beautify,Te.css_beautify=q.css_beautify,Te.html_beautify=S.html_beautify,Te}ce=[oe(58553),oe(87804),oe(40998)],De=function(ge,q,S){return qe(ge,q,S)}.apply(Rt,ce),De!==void 0&&(Li.exports=De)},87804:function(Li,Rt){var oe,ce;(function(){var De;(function(){"use strict";var ge=[,,function(P){function d(k){this.__parent=k,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=[]}d.prototype.clone_empty=function(){var k=new d(this.__parent);return k.set_indent(this.__indent_count,this.__alignment_count),k},d.prototype.item=function(k){return k<0?this.__items[this.__items.length+k]:this.__items[k]},d.prototype.has_match=function(k){for(var T=this.__items.length-1;T>=0;T--)if(this.__items[T].match(k))return!0;return!1},d.prototype.set_indent=function(k,T){this.is_empty()&&(this.__indent_count=k||0,this.__alignment_count=T||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},d.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)},d.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},d.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var k=this.__parent.current_line;return k.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),k.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),k.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,k.__items[0]===" "&&(k.__items.splice(0,1),k.__character_count-=1),!0}return!1},d.prototype.is_empty=function(){return this.__items.length===0},d.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},d.prototype.push=function(k){this.__items.push(k);var T=k.lastIndexOf(`
`);T!==-1?this.__character_count=k.length-T:this.__character_count+=k.length},d.prototype.pop=function(){var k=null;return this.is_empty()||(k=this.__items.pop(),this.__character_count-=k.length),k},d.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},d.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},d.prototype.trim=function(){for(;this.last()===" ";)this.__items.pop(),this.__character_count-=1},d.prototype.toString=function(){var k="";return this.is_empty()?this.__parent.indent_empty_lines&&(k=this.__parent.get_indent_string(this.__indent_count)):(k=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),k+=this.__items.join("")),k};function ne(k,T){this.__cache=[""],this.__indent_size=k.indent_size,this.__indent_string=k.indent_char,k.indent_with_tabs||(this.__indent_string=new Array(k.indent_size+1).join(k.indent_char)),T=T||"",k.indent_level>0&&(T=new Array(k.indent_level+1).join(this.__indent_string)),this.__base_string=T,this.__base_string_length=T.length}ne.prototype.get_indent_size=function(k,T){var M=this.__base_string_length;return T=T||0,k<0&&(M=0),M+=k*this.__indent_size,M+=T,M},ne.prototype.get_indent_string=function(k,T){var M=this.__base_string;return T=T||0,k<0&&(k=0,M=""),T+=k*this.__indent_size,this.__ensure_cache(T),M+=this.__cache[T],M},ne.prototype.__ensure_cache=function(k){for(;k>=this.__cache.length;)this.__add_column()},ne.prototype.__add_column=function(){var k=this.__cache.length,T=0,M="";this.__indent_size&&k>=this.__indent_size&&(T=Math.floor(k/this.__indent_size),k-=T*this.__indent_size,M=new Array(T+1).join(this.__indent_string)),k&&(M+=new Array(k+1).join(" ")),this.__cache.push(M)};function I(k,T){this.__indent_cache=new ne(k,T),this.raw=!1,this._end_with_newline=k.end_with_newline,this.indent_size=k.indent_size,this.wrap_line_length=k.wrap_line_length,this.indent_empty_lines=k.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new d(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}I.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},I.prototype.get_line_number=function(){return this.__lines.length},I.prototype.get_indent_string=function(k,T){return this.__indent_cache.get_indent_string(k,T)},I.prototype.get_indent_size=function(k,T){return this.__indent_cache.get_indent_size(k,T)},I.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},I.prototype.add_new_line=function(k){return this.is_empty()||!k&&this.just_added_newline()?!1:(this.raw||this.__add_outputline(),!0)},I.prototype.get_code=function(k){this.trim(!0);var T=this.current_line.pop();T&&(T[T.length-1]===`
`&&(T=T.replace(/\n+$/g,"")),this.current_line.push(T)),this._end_with_newline&&this.__add_outputline();var M=this.__lines.join(`
`);return k!==`
`&&(M=M.replace(/[\n]/g,k)),M},I.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},I.prototype.set_indent=function(k,T){return k=k||0,T=T||0,this.next_line.set_indent(k,T),this.__lines.length>1?(this.current_line.set_indent(k,T),!0):(this.current_line.set_indent(),!1)},I.prototype.add_raw_token=function(k){for(var T=0;T<k.newlines;T++)this.__add_outputline();this.current_line.set_indent(-1),this.current_line.push(k.whitespace_before),this.current_line.push(k.text),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1},I.prototype.add_token=function(k){this.__add_space_before_token(),this.current_line.push(k),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=this.current_line._allow_wrap()},I.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(" "))},I.prototype.remove_indent=function(k){for(var T=this.__lines.length;k<T;)this.__lines[k]._remove_indent(),k++;this.current_line._remove_wrap_indent()},I.prototype.trim=function(k){for(k=k===void 0?!1:k,this.current_line.trim();k&&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},I.prototype.just_added_newline=function(){return this.current_line.is_empty()},I.prototype.just_added_blankline=function(){return this.is_empty()||this.current_line.is_empty()&&this.previous_line.is_empty()},I.prototype.ensure_empty_line_above=function(k,T){for(var M=this.__lines.length-2;M>=0;){var O=this.__lines[M];if(O.is_empty())break;if(O.item(0).indexOf(k)!==0&&O.item(-1)!==T){this.__lines.splice(M+1,0,new d(this)),this.previous_line=this.__lines[this.__lines.length-2];break}M--}},P.exports.Output=I},,,,function(P){function d(k,T){this.raw_options=ne(k,T),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","angular","django","erb","handlebars","php","smarty"],["auto"])}d.prototype._get_array=function(k,T){var M=this.raw_options[k],O=T||[];return typeof M=="object"?M!==null&&typeof M.concat=="function"&&(O=M.concat()):typeof M=="string"&&(O=M.split(/[^a-zA-Z0-9_\/\-]+/)),O},d.prototype._get_boolean=function(k,T){var M=this.raw_options[k],O=M===void 0?!!T:!!M;return O},d.prototype._get_characters=function(k,T){var M=this.raw_options[k],O=T||"";return typeof M=="string"&&(O=M.replace(/\\r/,"\r").replace(/\\n/,`
`).replace(/\\t/," ")),O},d.prototype._get_number=function(k,T){var M=this.raw_options[k];T=parseInt(T,10),isNaN(T)&&(T=0);var O=parseInt(M,10);return isNaN(O)&&(O=T),O},d.prototype._get_selection=function(k,T,M){var O=this._get_selection_list(k,T,M);if(O.length!==1)throw new Error("Invalid Option Value: The option '"+k+`' can only be one of the following values:
`+T+`
You passed in: '`+this.raw_options[k]+"'");return O[0]},d.prototype._get_selection_list=function(k,T,M){if(!T||T.length===0)throw new Error("Selection list cannot be empty.");if(M=M||[T[0]],!this._is_valid_selection(M,T))throw new Error("Invalid Default Value!");var O=this._get_array(k,M);if(!this._is_valid_selection(O,T))throw new Error("Invalid Option Value: The option '"+k+`' can contain only the following values:
`+T+`
You passed in: '`+this.raw_options[k]+"'");return O},d.prototype._is_valid_selection=function(k,T){return k.length&&T.length&&!k.some(function(M){return T.indexOf(M)===-1})};function ne(k,T){var M={};k=I(k);var O;for(O in k)O!==T&&(M[O]=k[O]);if(T&&k[T])for(O in k[T])M[O]=k[T][O];return M}function I(k){var T={},M;for(M in k){var O=M.replace(/-/g,"_");T[O]=k[M]}return T}P.exports.Options=d,P.exports.normalizeOpts=I,P.exports.mergeOpts=ne},,function(P){var d=RegExp.prototype.hasOwnProperty("sticky");function ne(I){this.__input=I||"",this.__input_length=this.__input.length,this.__position=0}ne.prototype.restart=function(){this.__position=0},ne.prototype.back=function(){this.__position>0&&(this.__position-=1)},ne.prototype.hasNext=function(){return this.__position<this.__input_length},ne.prototype.next=function(){var I=null;return this.hasNext()&&(I=this.__input.charAt(this.__position),this.__position+=1),I},ne.prototype.peek=function(I){var k=null;return I=I||0,I+=this.__position,I>=0&&I<this.__input_length&&(k=this.__input.charAt(I)),k},ne.prototype.__match=function(I,k){I.lastIndex=k;var T=I.exec(this.__input);return T&&!(d&&I.sticky)&&T.index!==k&&(T=null),T},ne.prototype.test=function(I,k){return k=k||0,k+=this.__position,k>=0&&k<this.__input_length?!!this.__match(I,k):!1},ne.prototype.testChar=function(I,k){var T=this.peek(k);return I.lastIndex=0,T!==null&&I.test(T)},ne.prototype.match=function(I){var k=this.__match(I,this.__position);return k?this.__position+=k[0].length:k=null,k},ne.prototype.read=function(I,k,T){var M="",O;return I&&(O=this.match(I),O&&(M+=O[0])),k&&(O||!I)&&(M+=this.readUntil(k,T)),M},ne.prototype.readUntil=function(I,k){var T="",M=this.__position;I.lastIndex=this.__position;var O=I.exec(this.__input);return O?(M=O.index,k&&(M+=O[0].length)):M=this.__input_length,T=this.__input.substring(this.__position,M),this.__position=M,T},ne.prototype.readUntilAfter=function(I){return this.readUntil(I,!0)},ne.prototype.get_regexp=function(I,k){var T=null,M="g";return k&&d&&(M="y"),typeof I=="string"&&I!==""?T=new RegExp(I,M):I&&(T=new RegExp(I.source,M)),T},ne.prototype.get_literal_regexp=function(I){return RegExp(I.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"))},ne.prototype.peekUntilAfter=function(I){var k=this.__position,T=this.readUntilAfter(I);return this.__position=k,T},ne.prototype.lookBack=function(I){var k=this.__position-1;return k>=I.length&&this.__input.substring(k-I.length,k).toLowerCase()===I},P.exports.InputScanner=ne},,,,,function(P){function d(ne,I){ne=typeof ne=="string"?ne:ne.source,I=typeof I=="string"?I:I.source,this.__directives_block_pattern=new RegExp(ne+/ beautify( \w+[:]\w+)+ /.source+I,"g"),this.__directive_pattern=/ (\w+)[:](\w+)/g,this.__directives_end_ignore_pattern=new RegExp(ne+/\sbeautify\signore:end\s/.source+I,"g")}d.prototype.get_directives=function(ne){if(!ne.match(this.__directives_block_pattern))return null;var I={};this.__directive_pattern.lastIndex=0;for(var k=this.__directive_pattern.exec(ne);k;)I[k[1]]=k[2],k=this.__directive_pattern.exec(ne);return I},d.prototype.readIgnored=function(ne){return ne.readUntilAfter(this.__directives_end_ignore_pattern)},P.exports.Directives=d},,function(P,d,ne){var I=ne(16).Beautifier,k=ne(17).Options;function T(M,O){var Y=new I(M,O);return Y.beautify()}P.exports=T,P.exports.defaultOptions=function(){return new k}},function(P,d,ne){var I=ne(17).Options,k=ne(2).Output,T=ne(8).InputScanner,M=ne(13).Directives,O=new M(/\/\*/,/\*\//),Y=/\r\n|[\r\n]/,H=/\r\n|[\r\n]/g,j=/\s/,U=/(?:\s|\n)+/g,$=/\/\*(?:[\s\S]*?)((?:\*\/)|$)/g,G=/\/\/(?:[^\n\r\u2028\u2029]*)/g;function he(be,Se){this._source_text=be||"",this._options=new I(Se),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"]}he.prototype.eatString=function(be){var Se="";for(this._ch=this._input.next();this._ch;){if(Se+=this._ch,this._ch==="\\")Se+=this._input.next();else if(be.indexOf(this._ch)!==-1||this._ch===`
`)break;this._ch=this._input.next()}return Se},he.prototype.eatWhitespace=function(be){for(var Se=j.test(this._input.peek()),re=0;j.test(this._input.peek());)this._ch=this._input.next(),be&&this._ch===`
`&&(re===0||re<this._options.max_preserve_newlines)&&(re++,this._output.add_new_line(!0));return Se},he.prototype.foundNestedPseudoClass=function(){for(var be=0,Se=1,re=this._input.peek(Se);re;){if(re==="{")return!0;if(re==="(")be+=1;else if(re===")"){if(be===0)return!1;be-=1}else if(re===";"||re==="}")return!1;Se++,re=this._input.peek(Se)}return!1},he.prototype.print_string=function(be){this._output.set_indent(this._indentLevel),this._output.non_breaking_space=!0,this._output.add_token(be)},he.prototype.preserveSingleSpace=function(be){be&&(this._output.space_before_token=!0)},he.prototype.indent=function(){this._indentLevel++},he.prototype.outdent=function(){this._indentLevel>0&&this._indentLevel--},he.prototype.beautify=function(){if(this._options.disabled)return this._source_text;var be=this._source_text,Se=this._options.eol;Se==="auto"&&(Se=`
`,be&&Y.test(be||"")&&(Se=be.match(Y)[0])),be=be.replace(H,`
`);var re=be.match(/^[\t ]*/)[0];this._output=new k(this._options,re),this._input=new T(be),this._indentLevel=0,this._nestedLevel=0,this._ch=null;for(var Oe=0,We=!1,Be=!1,Dt=!1,te=!1,z=!1,X=this._ch,J=!1,de,ie,A;de=this._input.read(U),ie=de!=="",A=X,this._ch=this._input.next(),this._ch==="\\"&&this._input.hasNext()&&(this._ch+=this._input.next()),X=this._ch,this._ch;)if(this._ch==="/"&&this._input.peek()==="*"){this._output.add_new_line(),this._input.back();var L=this._input.read($),V=O.get_directives(L);V&&V.ignore==="start"&&(L+=O.readIgnored(this._input)),this.print_string(L),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(G)),this.eatWhitespace(!0);else if(this._ch==="$"){this.preserveSingleSpace(ie),this.print_string(this._ch);var pe=this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);pe.match(/[ :]$/)&&(pe=this.eatString(": ").replace(/\s+$/,""),this.print_string(pe),this._output.space_before_token=!0),Oe===0&&pe.indexOf(":")!==-1&&(Be=!0,this.indent())}else if(this._ch==="@")if(this.preserveSingleSpace(ie),this._input.peek()==="{")this.print_string(this._ch+this.eatString("}"));else{this.print_string(this._ch);var ze=this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);ze.match(/[ :]$/)&&(ze=this.eatString(": ").replace(/\s+$/,""),this.print_string(ze),this._output.space_before_token=!0),Oe===0&&ze.indexOf(":")!==-1?(Be=!0,this.indent()):ze in this.NESTED_AT_RULE?(this._nestedLevel+=1,ze in this.CONDITIONAL_GROUP_RULE&&(Dt=!0)):Oe===0&&!Be&&(te=!0)}else if(this._ch==="#"&&this._input.peek()==="{")this.preserveSingleSpace(ie),this.print_string(this._ch+this.eatString("}"));else if(this._ch==="{")Be&&(Be=!1,this.outdent()),te=!1,Dt?(Dt=!1,We=this._indentLevel>=this._nestedLevel):We=this._indentLevel>=this._nestedLevel-1,this._options.newline_between_rules&&We&&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)):(A==="("?this._output.space_before_token=!1:A!==","&&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(),A==="{"&&this._output.trim(!0),Be&&(this.outdent(),Be=!1),this.print_string(this._ch),We=!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 at=0;at<this.NON_SEMICOLON_NEWLINE_PROPERTY.length;at++)if(this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[at])){J=!0;break}(We||Dt)&&!(this._input.lookBack("&")||this.foundNestedPseudoClass())&&!this._input.lookBack("(")&&!te&&Oe===0?(this.print_string(":"),Be||(Be=!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 Ot=A==='"'||A==="'";this.preserveSingleSpace(Ot||ie),this.print_string(this._ch+this.eatString(this._ch)),this.eatWhitespace(!0)}else if(this._ch===";")J=!1,Oe===0?(Be&&(this.outdent(),Be=!1),te=!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(),Oe++,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(")")),Oe&&(Oe--,this.outdent()));else{var Ce=!1;this._input.lookBack("with")&&(Ce=!0),this.preserveSingleSpace(ie||Ce),this.print_string(this._ch),Be&&A==="$"&&this._options.selector_separator_newline?(this._output.add_new_line(),z=!0):(this.eatWhitespace(),Oe++,this.indent())}else if(this._ch===")")Oe&&(Oe--,this.outdent()),z&&this._input.peek()===";"&&this._options.selector_separator_newline&&(z=!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&&(!Be||z)&&Oe===0&&!te?this._output.add_new_line():this._output.space_before_token=!0;else if((this._ch===">"||this._ch==="+"||this._ch==="~")&&!Be&&Oe===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&&j.test(this._ch)&&(this._ch=""));else if(this._ch==="]")this.print_string(this._ch);else if(this._ch==="[")this.preserveSingleSpace(ie),this.print_string(this._ch);else if(this._ch==="=")this.eatWhitespace(),this.print_string("="),j.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 jt=A==='"'||A==="'";this.preserveSingleSpace(jt||ie),this.print_string(this._ch),!this._output.just_added_newline()&&this._input.peek()===`
`&&J&&this._output.add_new_line()}var Mt=this._output.get_code(Se);return Mt},P.exports.Beautifier=he},function(P,d,ne){var I=ne(6).Options;function k(T){I.call(this,T,"css"),this.selector_separator_newline=this._get_boolean("selector_separator_newline",!0),this.newline_between_rules=this._get_boolean("newline_between_rules",!0);var M=this._get_boolean("space_around_selector_separator");this.space_around_combinator=this._get_boolean("space_around_combinator")||M;var O=this._get_selection_list("brace_style",["collapse","expand","end-expand","none","preserve-inline"]);this.brace_style="collapse";for(var Y=0;Y<O.length;Y++)O[Y]!=="expand"?this.brace_style="collapse":this.brace_style=O[Y]}k.prototype=new I,P.exports.Options=k}],q={};function S(P){var d=q[P];if(d!==void 0)return d.exports;var ne=q[P]={exports:{}};return ge[P](ne,ne.exports,S),ne.exports}var Te=S(15);De=Te})();var qe=De;oe=[],ce=function(){return{css_beautify:qe}}.apply(Rt,oe),ce!==void 0&&(Li.exports=ce)})()},40998:function(Li,Rt,oe){var ce,De;(function(){var qe;(function(){"use strict";var Te=[,,function(I){function k(O){this.__parent=O,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=[]}k.prototype.clone_empty=function(){var O=new k(this.__parent);return O.set_indent(this.__indent_count,this.__alignment_count),O},k.prototype.item=function(O){return O<0?this.__items[this.__items.length+O]:this.__items[O]},k.prototype.has_match=function(O){for(var Y=this.__items.length-1;Y>=0;Y--)if(this.__items[Y].match(O))return!0;return!1},k.prototype.set_indent=function(O,Y){this.is_empty()&&(this.__indent_count=O||0,this.__alignment_count=Y||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},k.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)},k.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},k.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var O=this.__parent.current_line;return O.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),O.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),O.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,O.__items[0]===" "&&(O.__items.splice(0,1),O.__character_count-=1),!0}return!1},k.prototype.is_empty=function(){return this.__items.length===0},k.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},k.prototype.push=function(O){this.__items.push(O);var Y=O.lastIndexOf(`
`);Y!==-1?this.__character_count=O.length-Y:this.__character_count+=O.length},k.prototype.pop=function(){var O=null;return this.is_empty()||(O=this.__items.pop(),this.__character_count-=O.length),O},k.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},k.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},k.prototype.trim=function(){for(;this.last()===" ";)this.__items.pop(),this.__character_count-=1},k.prototype.toString=function(){var O="";return this.is_empty()?this.__parent.indent_empty_lines&&(O=this.__parent.get_indent_string(this.__indent_count)):(O=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),O+=this.__items.join("")),O};function T(O,Y){this.__cache=[""],this.__indent_size=O.indent_size,this.__indent_string=O.indent_char,O.indent_with_tabs||(this.__indent_string=new Array(O.indent_size+1).join(O.indent_char)),Y=Y||"",O.indent_level>0&&(Y=new Array(O.indent_level+1).join(this.__indent_string)),this.__base_string=Y,this.__base_string_length=Y.length}T.prototype.get_indent_size=function(O,Y){var H=this.__base_string_length;return Y=Y||0,O<0&&(H=0),H+=O*this.__indent_size,H+=Y,H},T.prototype.get_indent_string=function(O,Y){var H=this.__base_string;return Y=Y||0,O<0&&(O=0,H=""),Y+=O*this.__indent_size,this.__ensure_cache(Y),H+=this.__cache[Y],H},T.prototype.__ensure_cache=function(O){for(;O>=this.__cache.length;)this.__add_column()},T.prototype.__add_column=function(){var O=this.__cache.length,Y=0,H="";this.__indent_size&&O>=this.__indent_size&&(Y=Math.floor(O/this.__indent_size),O-=Y*this.__indent_size,H=new Array(Y+1).join(this.__indent_string)),O&&(H+=new Array(O+1).join(" ")),this.__cache.push(H)};function M(O,Y){this.__indent_cache=new T(O,Y),this.raw=!1,this._end_with_newline=O.end_with_newline,this.indent_size=O.indent_size,this.wrap_line_length=O.wrap_line_length,this.indent_empty_lines=O.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new k(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(O,Y){return this.__indent_cache.get_indent_string(O,Y)},M.prototype.get_indent_size=function(O,Y){return this.__indent_cache.get_indent_size(O,Y)},M.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},M.prototype.add_new_line=function(O){return this.is_empty()||!O&&this.just_added_newline()?!1:(this.raw||this.__add_outputline(),!0)},M.prototype.get_code=function(O){this.trim(!0);var Y=this.current_line.pop();Y&&(Y[Y.length-1]===`
`&&(Y=Y.replace(/\n+$/g,"")),this.current_line.push(Y)),this._end_with_newline&&this.__add_outputline();var H=this.__lines.join(`
`);return O!==`
`&&(H=H.replace(/[\n]/g,O)),H},M.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},M.prototype.set_indent=function(O,Y){return O=O||0,Y=Y||0,this.next_line.set_indent(O,Y),this.__lines.length>1?(this.current_line.set_indent(O,Y),!0):(this.current_line.set_indent(),!1)},M.prototype.add_raw_token=function(O){for(var Y=0;Y<O.newlines;Y++)this.__add_outputline();this.current_line.set_indent(-1),this.current_line.push(O.whitespace_before),this.current_line.push(O.text),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1},M.prototype.add_token=function(O){this.__add_space_before_token(),this.current_line.push(O),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(O){for(var Y=this.__lines.length;O<Y;)this.__lines[O]._remove_indent(),O++;this.current_line._remove_wrap_indent()},M.prototype.trim=function(O){for(O=O===void 0?!1:O,this.current_line.trim();O&&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(O,Y){for(var H=this.__lines.length-2;H>=0;){var j=this.__lines[H];if(j.is_empty())break;if(j.item(0).indexOf(O)!==0&&j.item(-1)!==Y){this.__lines.splice(H+1,0,new k(this)),this.previous_line=this.__lines[this.__lines.length-2];break}H--}},I.exports.Output=M},function(I){function k(T,M,O,Y){this.type=T,this.text=M,this.comments_before=null,this.newlines=O||0,this.whitespace_before=Y||"",this.parent=null,this.next=null,this.previous=null,this.opened=null,this.closed=null,this.directives=null}I.exports.Token=k},,,function(I){function k(O,Y){this.raw_options=T(O,Y),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","angular","django","erb","handlebars","php","smarty"],["auto"])}k.prototype._get_array=function(O,Y){var H=this.raw_options[O],j=Y||[];return typeof H=="object"?H!==null&&typeof H.concat=="function"&&(j=H.concat()):typeof H=="string"&&(j=H.split(/[^a-zA-Z0-9_\/\-]+/)),j},k.prototype._get_boolean=function(O,Y){var H=this.raw_options[O],j=H===void 0?!!Y:!!H;return j},k.prototype._get_characters=function(O,Y){var H=this.raw_options[O],j=Y||"";return typeof H=="string"&&(j=H.replace(/\\r/,"\r").replace(/\\n/,`
`).replace(/\\t/," ")),j},k.prototype._get_number=function(O,Y){var H=this.raw_options[O];Y=parseInt(Y,10),isNaN(Y)&&(Y=0);var j=parseInt(H,10);return isNaN(j)&&(j=Y),j},k.prototype._get_selection=function(O,Y,H){var j=this._get_selection_list(O,Y,H);if(j.length!==1)throw new Error("Invalid Option Value: The option '"+O+`' can only be one of the following values:
`+Y+`
You passed in: '`+this.raw_options[O]+"'");return j[0]},k.prototype._get_selection_list=function(O,Y,H){if(!Y||Y.length===0)throw new Error("Selection list cannot be empty.");if(H=H||[Y[0]],!this._is_valid_selection(H,Y))throw new Error("Invalid Default Value!");var j=this._get_array(O,H);if(!this._is_valid_selection(j,Y))throw new Error("Invalid Option Value: The option '"+O+`' can contain only the following values:
`+Y+`
You passed in: '`+this.raw_options[O]+"'");return j},k.prototype._is_valid_selection=function(O,Y){return O.length&&Y.length&&!O.some(function(H){return Y.indexOf(H)===-1})};function T(O,Y){var H={};O=M(O);var j;for(j in O)j!==Y&&(H[j]=O[j]);if(Y&&O[Y])for(j in O[Y])H[j]=O[Y][j];return H}function M(O){var Y={},H;for(H in O){var j=H.replace(/-/g,"_");Y[j]=O[H]}return Y}I.exports.Options=k,I.exports.normalizeOpts=M,I.exports.mergeOpts=T},,function(I){var k=RegExp.prototype.hasOwnProperty("sticky");function T(M){this.__input=M||"",this.__input_length=this.__input.length,this.__position=0}T.prototype.restart=function(){this.__position=0},T.prototype.back=function(){this.__position>0&&(this.__position-=1)},T.prototype.hasNext=function(){return this.__position<this.__input_length},T.prototype.next=function(){var M=null;return this.hasNext()&&(M=this.__input.charAt(this.__position),this.__position+=1),M},T.prototype.peek=function(M){var O=null;return M=M||0,M+=this.__position,M>=0&&M<this.__input_length&&(O=this.__input.charAt(M)),O},T.prototype.__match=function(M,O){M.lastIndex=O;var Y=M.exec(this.__input);return Y&&!(k&&M.sticky)&&Y.index!==O&&(Y=null),Y},T.prototype.test=function(M,O){return O=O||0,O+=this.__position,O>=0&&O<this.__input_length?!!this.__match(M,O):!1},T.prototype.testChar=function(M,O){var Y=this.peek(O);return M.lastIndex=0,Y!==null&&M.test(Y)},T.prototype.match=function(M){var O=this.__match(M,this.__position);return O?this.__position+=O[0].length:O=null,O},T.prototype.read=function(M,O,Y){var H="",j;return M&&(j=this.match(M),j&&(H+=j[0])),O&&(j||!M)&&(H+=this.readUntil(O,Y)),H},T.prototype.readUntil=function(M,O){var Y="",H=this.__position;M.lastIndex=this.__position;var j=M.exec(this.__input);return j?(H=j.index,O&&(H+=j[0].length)):H=this.__input_length,Y=this.__input.substring(this.__position,H),this.__position=H,Y},T.prototype.readUntilAfter=function(M){return this.readUntil(M,!0)},T.prototype.get_regexp=function(M,O){var Y=null,H="g";return O&&k&&(H="y"),typeof M=="string"&&M!==""?Y=new RegExp(M,H):M&&(Y=new RegExp(M.source,H)),Y},T.prototype.get_literal_regexp=function(M){return RegExp(M.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"))},T.prototype.peekUntilAfter=function(M){var O=this.__position,Y=this.readUntilAfter(M);return this.__position=O,Y},T.prototype.lookBack=function(M){var O=this.__position-1;return O>=M.length&&this.__input.substring(O-M.length,O).toLowerCase()===M},I.exports.InputScanner=T},function(I,k,T){var M=T(8).InputScanner,O=T(3).Token,Y=T(10).TokenStream,H=T(11).WhitespacePattern,j={START:"TK_START",RAW:"TK_RAW",EOF:"TK_EOF"},U=function($,G){this._input=new M($),this._options=G||{},this.__tokens=null,this._patterns={},this._patterns.whitespace=new H(this._input)};U.prototype.tokenize=function(){this._input.restart(),this.__tokens=new Y,this._reset();for(var $,G=new O(j.START,""),he=null,be=[],Se=new Y;G.type!==j.EOF;){for($=this._get_next_token(G,he);this._is_comment($);)Se.add($),$=this._get_next_token(G,he);Se.isEmpty()||($.comments_before=Se,Se=new Y),$.parent=he,this._is_opening($)?(be.push(he),he=$):he&&this._is_closing($,he)&&($.opened=he,he.closed=$,he=be.pop(),$.parent=he),$.previous=G,G.next=$,this.__tokens.add($),G=$}return this.__tokens},U.prototype._is_first_token=function(){return this.__tokens.isEmpty()},U.prototype._reset=function(){},U.prototype._get_next_token=function($,G){this._readWhitespace();var he=this._input.read(/.+/g);return he?this._create_token(j.RAW,he):this._create_token(j.EOF,"")},U.prototype._is_comment=function($){return!1},U.prototype._is_opening=function($){return!1},U.prototype._is_closing=function($,G){return!1},U.prototype._create_token=function($,G){var he=new O($,G,this._patterns.whitespace.newline_count,this._patterns.whitespace.whitespace_before_token);return he},U.prototype._readWhitespace=function(){return this._patterns.whitespace.read()},I.exports.Tokenizer=U,I.exports.TOKEN=j},function(I){function k(T){this.__tokens=[],this.__tokens_length=this.__tokens.length,this.__position=0,this.__parent_token=T}k.prototype.restart=function(){this.__position=0},k.prototype.isEmpty=function(){return this.__tokens_length===0},k.prototype.hasNext=function(){return this.__position<this.__tokens_length},k.prototype.next=function(){var T=null;return this.hasNext()&&(T=this.__tokens[this.__position],this.__position+=1),T},k.prototype.peek=function(T){var M=null;return T=T||0,T+=this.__position,T>=0&&T<this.__tokens_length&&(M=this.__tokens[T]),M},k.prototype.add=function(T){this.__parent_token&&(T.parent=this.__parent_token),this.__tokens.push(T),this.__tokens_length+=1},I.exports.TokenStream=k},function(I,k,T){var M=T(12).Pattern;function O(Y,H){M.call(this,Y,H),H?this._line_regexp=this._input.get_regexp(H._line_regexp):this.__set_whitespace_patterns("",""),this.newline_count=0,this.whitespace_before_token=""}O.prototype=new M,O.prototype.__set_whitespace_patterns=function(Y,H){Y+="\\t ",H+="\\n\\r",this._match_pattern=this._input.get_regexp("["+Y+H+"]+",!0),this._newline_regexp=this._input.get_regexp("\\r\\n|["+H+"]")},O.prototype.read=function(){this.newline_count=0,this.whitespace_before_token="";var Y=this._input.read(this._match_pattern);if(Y===" ")this.whitespace_before_token=" ";else if(Y){var H=this.__split(this._newline_regexp,Y);this.newline_count=H.length-1,this.whitespace_before_token=H[this.newline_count]}return Y},O.prototype.matching=function(Y,H){var j=this._create();return j.__set_whitespace_patterns(Y,H),j._update(),j},O.prototype._create=function(){return new O(this._input,this)},O.prototype.__split=function(Y,H){Y.lastIndex=0;for(var j=0,U=[],$=Y.exec(H);$;)U.push(H.substring(j,$.index)),j=$.index+$[0].length,$=Y.exec(H);return j<H.length?U.push(H.substring(j,H.length)):U.push(""),U},I.exports.WhitespacePattern=O},function(I){function k(T,M){this._input=T,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)}k.prototype.read=function(){var T=this._input.read(this._starting_pattern);return(!this._starting_pattern||T)&&(T+=this._input.read(this._match_pattern,this._until_pattern,this._until_after)),T},k.prototype.read_match=function(){return this._input.match(this._match_pattern)},k.prototype.until_after=function(T){var M=this._create();return M._until_after=!0,M._until_pattern=this._input.get_regexp(T),M._update(),M},k.prototype.until=function(T){var M=this._create();return M._until_after=!1,M._until_pattern=this._input.get_regexp(T),M._update(),M},k.prototype.starting_with=function(T){var M=this._create();return M._starting_pattern=this._input.get_regexp(T,!0),M._update(),M},k.prototype.matching=function(T){var M=this._create();return M._match_pattern=this._input.get_regexp(T,!0),M._update(),M},k.prototype._create=function(){return new k(this._input,this)},k.prototype._update=function(){},I.exports.Pattern=k},function(I){function k(T,M){T=typeof T=="string"?T:T.source,M=typeof M=="string"?M:M.source,this.__directives_block_pattern=new RegExp(T+/ beautify( \w+[:]\w+)+ /.source+M,"g"),this.__directive_pattern=/ (\w+)[:](\w+)/g,this.__directives_end_ignore_pattern=new RegExp(T+/\sbeautify\signore:end\s/.source+M,"g")}k.prototype.get_directives=function(T){if(!T.match(this.__directives_block_pattern))return null;var M={};this.__directive_pattern.lastIndex=0;for(var O=this.__directive_pattern.exec(T);O;)M[O[1]]=O[2],O=this.__directive_pattern.exec(T);return M},k.prototype.readIgnored=function(T){return T.readUntilAfter(this.__directives_end_ignore_pattern)},I.exports.Directives=k},function(I,k,T){var M=T(12).Pattern,O={django:!1,erb:!1,handlebars:!1,php:!1,smarty:!1,angular:!1};function Y(H,j){M.call(this,H,j),this.__template_pattern=null,this._disabled=Object.assign({},O),this._excluded=Object.assign({},O),j&&(this.__template_pattern=this._input.get_regexp(j.__template_pattern),this._excluded=Object.assign(this._excluded,j._excluded),this._disabled=Object.assign(this._disabled,j._disabled));var U=new M(H);this.__patterns={handlebars_comment:U.starting_with(/{{!--/).until_after(/--}}/),handlebars_unescaped:U.starting_with(/{{{/).until_after(/}}}/),handlebars:U.starting_with(/{{/).until_after(/}}/),php:U.starting_with(/<\?(?:[= ]|php)/).until_after(/\?>/),erb:U.starting_with(/<%[^%]/).until_after(/[^%]%>/),django:U.starting_with(/{%/).until_after(/%}/),django_value:U.starting_with(/{{/).until_after(/}}/),django_comment:U.starting_with(/{#/).until_after(/#}/),smarty:U.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),smarty_comment:U.starting_with(/{\*/).until_after(/\*}/),smarty_literal:U.starting_with(/{literal}/).until_after(/{\/literal}/)}}Y.prototype=new M,Y.prototype._create=function(){return new Y(this._input,this)},Y.prototype._update=function(){this.__set_templated_pattern()},Y.prototype.disable=function(H){var j=this._create();return j._disabled[H]=!0,j._update(),j},Y.prototype.read_options=function(H){var j=this._create();for(var U in O)j._disabled[U]=H.templating.indexOf(U)===-1;return j._update(),j},Y.prototype.exclude=function(H){var j=this._create();return j._excluded[H]=!0,j._update(),j},Y.prototype.read=function(){var H="";this._match_pattern?H=this._input.read(this._starting_pattern):H=this._input.read(this._starting_pattern,this.__template_pattern);for(var j=this._read_template();j;)this._match_pattern?j+=this._input.read(this._match_pattern):j+=this._input.readUntil(this.__template_pattern),H+=j,j=this._read_template();return this._until_after&&(H+=this._input.readUntilAfter(this._until_pattern)),H},Y.prototype.__set_templated_pattern=function(){var H=[];this._disabled.php||H.push(this.__patterns.php._starting_pattern.source),this._disabled.handlebars||H.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.angular||H.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.erb||H.push(this.__patterns.erb._starting_pattern.source),this._disabled.django||(H.push(this.__patterns.django._starting_pattern.source),H.push(this.__patterns.django_value._starting_pattern.source),H.push(this.__patterns.django_comment._starting_pattern.source)),this._disabled.smarty||H.push(this.__patterns.smarty._starting_pattern.source),this._until_pattern&&H.push(this._until_pattern.source),this.__template_pattern=this._input.get_regexp("(?:"+H.join("|")+")")},Y.prototype._read_template=function(){var H="",j=this._input.peek();if(j==="<"){var U=this._input.peek(1);!this._disabled.php&&!this._excluded.php&&U==="?"&&(H=H||this.__patterns.php.read()),!this._disabled.erb&&!this._excluded.erb&&U==="%"&&(H=H||this.__patterns.erb.read())}else j==="{"&&(!this._disabled.handlebars&&!this._excluded.handlebars&&(H=H||this.__patterns.handlebars_comment.read(),H=H||this.__patterns.handlebars_unescaped.read(),H=H||this.__patterns.handlebars.read()),this._disabled.django||(!this._excluded.django&&!this._excluded.handlebars&&(H=H||this.__patterns.django_value.read()),this._excluded.django||(H=H||this.__patterns.django_comment.read(),H=H||this.__patterns.django.read())),this._disabled.smarty||this._disabled.django&&this._disabled.handlebars&&(H=H||this.__patterns.smarty_comment.read(),H=H||this.__patterns.smarty_literal.read(),H=H||this.__patterns.smarty.read()));return H},I.exports.TemplatablePattern=Y},,,,function(I,k,T){var M=T(19).Beautifier,O=T(20).Options;function Y(H,j,U,$){var G=new M(H,j,U,$);return G.beautify()}I.exports=Y,I.exports.defaultOptions=function(){return new O}},function(I,k,T){var M=T(20).Options,O=T(2).Output,Y=T(21).Tokenizer,H=T(21).TOKEN,j=/\r\n|[\r\n]/,U=/\r\n|[\r\n]/g,$=function(te,z){this.indent_level=0,this.alignment_size=0,this.max_preserve_newlines=te.max_preserve_newlines,this.preserve_newlines=te.preserve_newlines,this._output=new O(te,z)};$.prototype.current_line_has_match=function(te){return this._output.current_line.has_match(te)},$.prototype.set_space_before_token=function(te,z){this._output.space_before_token=te,this._output.non_breaking_space=z},$.prototype.set_wrap_point=function(){this._output.set_indent(this.indent_level,this.alignment_size),this._output.set_wrap_point()},$.prototype.add_raw_token=function(te){this._output.add_raw_token(te)},$.prototype.print_preserved_newlines=function(te){var z=0;te.type!==H.TEXT&&te.previous.type!==H.TEXT&&(z=te.newlines?1:0),this.preserve_newlines&&(z=te.newlines<this.max_preserve_newlines+1?te.newlines:this.max_preserve_newlines+1);for(var X=0;X<z;X++)this.print_newline(X>0);return z!==0},$.prototype.traverse_whitespace=function(te){return te.whitespace_before||te.newlines?(this.print_preserved_newlines(te)||(this._output.space_before_token=!0),!0):!1},$.prototype.previous_token_wrapped=function(){return this._output.previous_token_wrapped},$.prototype.print_newline=function(te){this._output.add_new_line(te)},$.prototype.print_token=function(te){te.text&&(this._output.set_indent(this.indent_level,this.alignment_size),this._output.add_token(te.text))},$.prototype.indent=function(){this.indent_level++},$.prototype.deindent=function(){this.indent_level>0&&(this.indent_level--,this._output.set_indent(this.indent_level,this.alignment_size))},$.prototype.get_full_indent=function(te){return te=this.indent_level+(te||0),te<1?"":this._output.get_indent_string(te)};var G=function(te){for(var z=null,X=te.next;X.type!==H.EOF&&te.closed!==X;){if(X.type===H.ATTRIBUTE&&X.text==="type"){X.next&&X.next.type===H.EQUALS&&X.next.next&&X.next.next.type===H.VALUE&&(z=X.next.next.text);break}X=X.next}return z},he=function(te,z){var X=null,J=null;return z.closed?(te==="script"?X="text/javascript":te==="style"&&(X="text/css"),X=G(z)||X,X.search("text/css")>-1?J="css":X.search(/module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/)>-1?J="javascript":X.search(/(text|application|dojo)\/(x-)?(html)/)>-1?J="html":X.search(/test\/null/)>-1&&(J="null"),J):null};function be(te,z){return z.indexOf(te)!==-1}function Se(te,z,X){this.parent=te||null,this.tag=z?z.tag_name:"",this.indent_level=X||0,this.parser_token=z||null}function re(te){this._printer=te,this._current_frame=null}re.prototype.get_parser_token=function(){return this._current_frame?this._current_frame.parser_token:null},re.prototype.record_tag=function(te){var z=new Se(this._current_frame,te,this._printer.indent_level);this._current_frame=z},re.prototype._try_pop_frame=function(te){var z=null;return te&&(z=te.parser_token,this._printer.indent_level=te.indent_level,this._current_frame=te.parent),z},re.prototype._get_frame=function(te,z){for(var X=this._current_frame;X&&te.indexOf(X.tag)===-1;){if(z&&z.indexOf(X.tag)!==-1){X=null;break}X=X.parent}return X},re.prototype.try_pop=function(te,z){var X=this._get_frame([te],z);return this._try_pop_frame(X)},re.prototype.indent_to_tag=function(te){var z=this._get_frame(te);z&&(this._printer.indent_level=z.indent_level)};function Oe(te,z,X,J){this._source_text=te||"",z=z||{},this._js_beautify=X,this._css_beautify=J,this._tag_stack=null;var de=new M(z,"html");this._options=de,this._is_wrap_attributes_force=this._options.wrap_attributes.substr(0,5)==="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,8)==="preserve",this._is_wrap_attributes_preserve_aligned=this._options.wrap_attributes==="preserve-aligned"}Oe.prototype.beautify=function(){if(this._options.disabled)return this._source_text;var te=this._source_text,z=this._options.eol;this._options.eol==="auto"&&(z=`
`,te&&j.test(te)&&(z=te.match(j)[0])),te=te.replace(U,`
`);var X=te.match(/^[\t ]*/)[0],J={text:"",type:""},de=new We(this._options),ie=new $(this._options,X),A=new Y(te,this._options).tokenize();this._tag_stack=new re(ie);for(var L=null,V=A.next();V.type!==H.EOF;)V.type===H.TAG_OPEN||V.type===H.COMMENT?(L=this._handle_tag_open(ie,V,de,J,A),de=L):V.type===H.ATTRIBUTE||V.type===H.EQUALS||V.type===H.VALUE||V.type===H.TEXT&&!de.tag_complete?L=this._handle_inside_tag(ie,V,de,J):V.type===H.TAG_CLOSE?L=this._handle_tag_close(ie,V,de):V.type===H.TEXT?L=this._handle_text(ie,V,de):V.type===H.CONTROL_FLOW_OPEN?L=this._handle_control_flow_open(ie,V):V.type===H.CONTROL_FLOW_CLOSE?L=this._handle_control_flow_close(ie,V):ie.add_raw_token(V),J=L,V=A.next();var pe=ie._output.get_code(z);return pe},Oe.prototype._handle_control_flow_open=function(te,z){var X={text:z.text,type:z.type};return te.set_space_before_token(z.newlines||z.whitespace_before!=="",!0),z.newlines?te.print_preserved_newlines(z):te.set_space_before_token(z.newlines||z.whitespace_before!=="",!0),te.print_token(z),te.indent(),X},Oe.prototype._handle_control_flow_close=function(te,z){var X={text:z.text,type:z.type};return te.deindent(),z.newlines?te.print_preserved_newlines(z):te.set_space_before_token(z.newlines||z.whitespace_before!=="",!0),te.print_token(z),X},Oe.prototype._handle_tag_close=function(te,z,X){var J={text:z.text,type:z.type};return te.alignment_size=0,X.tag_complete=!0,te.set_space_before_token(z.newlines||z.whitespace_before!=="",!0),X.is_unformatted?te.add_raw_token(z):(X.tag_start_char==="<"&&(te.set_space_before_token(z.text[0]==="/",!0),this._is_wrap_attributes_force_expand_multiline&&X.has_wrapped_attrs&&te.print_newline(!1)),te.print_token(z)),X.indent_content&&!(X.is_unformatted||X.is_content_unformatted)&&(te.indent(),X.indent_content=!1),!X.is_inline_element&&!(X.is_unformatted||X.is_content_unformatted)&&te.set_wrap_point(),J},Oe.prototype._handle_inside_tag=function(te,z,X,J){var de=X.has_wrapped_attrs,ie={text:z.text,type:z.type};return te.set_space_before_token(z.newlines||z.whitespace_before!=="",!0),X.is_unformatted?te.add_raw_token(z):X.tag_start_char==="{"&&z.type===H.TEXT?te.print_preserved_newlines(z)?(z.newlines=0,te.add_raw_token(z)):te.print_token(z):(z.type===H.ATTRIBUTE?te.set_space_before_token(!0):(z.type===H.EQUALS||z.type===H.VALUE&&z.previous.type===H.EQUALS)&&te.set_space_before_token(!1),z.type===H.ATTRIBUTE&&X.tag_start_char==="<"&&((this._is_wrap_attributes_preserve||this._is_wrap_attributes_preserve_aligned)&&(te.traverse_whitespace(z),de=de||z.newlines!==0),this._is_wrap_attributes_force&&X.attr_count>=this._options.wrap_attributes_min_attrs&&(J.type!==H.TAG_OPEN||this._is_wrap_attributes_force_expand_multiline)&&(te.print_newline(!1),de=!0)),te.print_token(z),de=de||te.previous_token_wrapped(),X.has_wrapped_attrs=de),ie},Oe.prototype._handle_text=function(te,z,X){var J={text:z.text,type:"TK_CONTENT"};return X.custom_beautifier_name?this._print_custom_beatifier_text(te,z,X):X.is_unformatted||X.is_content_unformatted?te.add_raw_token(z):(te.traverse_whitespace(z),te.print_token(z)),J},Oe.prototype._print_custom_beatifier_text=function(te,z,X){var J=this;if(z.text!==""){var de=z.text,ie,A=1,L="",V="";X.custom_beautifier_name==="javascript"&&typeof this._js_beautify=="function"?ie=this._js_beautify:X.custom_beautifier_name==="css"&&typeof this._css_beautify=="function"?ie=this._css_beautify:X.custom_beautifier_name==="html"&&(ie=function(jt,Mt){var dt=new Oe(jt,Mt,J._js_beautify,J._css_beautify);return dt.beautify()}),this._options.indent_scripts==="keep"?A=0:this._options.indent_scripts==="separate"&&(A=-te.indent_level);var pe=te.get_full_indent(A);if(de=de.replace(/\n[ \t]*$/,""),X.custom_beautifier_name!=="html"&&de[0]==="<"&&de.match(/^(<!--|<!\[CDATA\[)/)){var ze=/^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(de);if(!ze){te.add_raw_token(z);return}L=pe+ze[1]+`
`,de=ze[4],ze[5]&&(V=pe+ze[5]),de=de.replace(/\n[ \t]*$/,""),(ze[2]||ze[3].indexOf(`
`)!==-1)&&(ze=ze[3].match(/[ \t]+$/),ze&&(z.whitespace_before=ze[0]))}if(de)if(ie){var at=function(){this.eol=`
`};at.prototype=this._options.raw_options;var Ot=new at;de=ie(pe+de,Ot)}else{var Ce=z.whitespace_before;Ce&&(de=de.replace(new RegExp(`
(`+Ce+")?","g"),`
`)),de=pe+de.replace(/\n/g,`
`+pe)}L&&(de?de=L+de+`
`+V:de=L+V),te.print_newline(!1),de&&(z.text=de,z.whitespace_before="",z.newlines=0,te.add_raw_token(z),te.print_newline(!0))}},Oe.prototype._handle_tag_open=function(te,z,X,J,de){var ie=this._get_tag_open_token(z);if((X.is_unformatted||X.is_content_unformatted)&&!X.is_empty_element&&z.type===H.TAG_OPEN&&!ie.is_start_tag?(te.add_raw_token(z),ie.start_tag_token=this._tag_stack.try_pop(ie.tag_name)):(te.traverse_whitespace(z),this._set_tag_position(te,z,ie,X,J),ie.is_inline_element||te.set_wrap_point(),te.print_token(z)),ie.is_start_tag&&this._is_wrap_attributes_force){var A=0,L;do L=de.peek(A),L.type===H.ATTRIBUTE&&(ie.attr_count+=1),A+=1;while(L.type!==H.EOF&&L.type!==H.TAG_CLOSE)}return(this._is_wrap_attributes_force_aligned||this._is_wrap_attributes_aligned_multiple||this._is_wrap_attributes_preserve_aligned)&&(ie.alignment_size=z.text.length+1),!ie.tag_complete&&!ie.is_unformatted&&(te.alignment_size=ie.alignment_size),ie};var We=function(te,z,X){if(this.parent=z||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="",!X)this.tag_complete=!0;else{var J;this.tag_start_char=X.text[0],this.text=X.text,this.tag_start_char==="<"?(J=X.text.match(/^<([^\s>]*)/),this.tag_check=J?J[1]:""):(J=X.text.match(/^{{~?(?:[\^]|#\*?)?([^\s}]+)/),this.tag_check=J?J[1]:"",(X.text.startsWith("{{#>")||X.text.startsWith("{{~#>"))&&this.tag_check[0]===">"&&(this.tag_check===">"&&X.next!==null?this.tag_check=X.next.text.split(" ")[0]:this.tag_check=X.text.split(">")[1])),this.tag_check=this.tag_check.toLowerCase(),X.type===H.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||X.closed&&X.closed.text==="/>";var de=2;this.tag_start_char==="{"&&this.text.length>=3&&this.text.charAt(2)==="~"&&(de=3),this.is_end_tag=this.is_end_tag||this.tag_start_char==="{"&&(!te.indent_handlebars||this.text.length<3||/[^#\^]/.test(this.text.charAt(de)))}};Oe.prototype._get_tag_open_token=function(te){var z=new We(this._options,this._tag_stack.get_parser_token(),te);return z.alignment_size=this._options.wrap_attributes_indent_size,z.is_end_tag=z.is_end_tag||be(z.tag_check,this._options.void_elements),z.is_empty_element=z.tag_complete||z.is_start_tag&&z.is_end_tag,z.is_unformatted=!z.tag_complete&&be(z.tag_check,this._options.unformatted),z.is_content_unformatted=!z.is_empty_element&&be(z.tag_check,this._options.content_unformatted),z.is_inline_element=be(z.tag_name,this._options.inline)||this._options.inline_custom_elements&&z.tag_name.includes("-")||z.tag_start_char==="{",z},Oe.prototype._set_tag_position=function(te,z,X,J,de){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||te.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=he(X.tag_check,z)))),be(X.tag_check,this._options.extra_liners)&&(te.print_newline(!1),te._output.just_added_blankline()||te.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 ie=te.current_line_has_match(/{{#if/);ie||te.print_newline(!1)}X.tag_name==="!--"&&de.type===H.TAG_CLOSE&&J.is_end_tag&&X.text.indexOf(`
`)===-1||(X.is_inline_element||X.is_unformatted||te.print_newline(!1),this._calcluate_parent_multiline(te,X))}else if(X.is_end_tag){var A=!1;A=X.start_tag_token&&X.start_tag_token.multiline_content,A=A||!X.is_inline_element&&!(J.is_inline_element||J.is_unformatted)&&!(de.type===H.TAG_CLOSE&&X.start_tag_token===J)&&de.type!=="TK_CONTENT",(X.is_content_unformatted||X.is_unformatted)&&(A=!1),A&&te.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)&&(de.type!=="TK_CONTENT"||X.is_content_unformatted)&&te.print_newline(!1),this._calcluate_parent_multiline(te,X)},Oe.prototype._calcluate_parent_multiline=function(te,z){z.parent&&te._output.just_added_newline()&&!((z.is_inline_element||z.is_unformatted)&&z.parent.is_inline_element)&&(z.parent.multiline_content=!0)};var Be=["address","article","aside","blockquote","details","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","main","menu","nav","ol","p","pre","section","table","ul"],Dt=["a","audio","del","ins","map","noscript","video"];Oe.prototype._do_optional_end_element=function(te){var z=null;if(!(te.is_empty_element||!te.is_start_tag||!te.parent)){if(te.tag_name==="body")z=z||this._tag_stack.try_pop("head");else if(te.tag_name==="li")z=z||this._tag_stack.try_pop("li",["ol","ul","menu"]);else if(te.tag_name==="dd"||te.tag_name==="dt")z=z||this._tag_stack.try_pop("dt",["dl"]),z=z||this._tag_stack.try_pop("dd",["dl"]);else if(te.parent.tag_name==="p"&&Be.indexOf(te.tag_name)!==-1){var X=te.parent.parent;(!X||Dt.indexOf(X.tag_name)===-1)&&(z=z||this._tag_stack.try_pop("p"))}else te.tag_name==="rp"||te.tag_name==="rt"?(z=z||this._tag_stack.try_pop("rt",["ruby","rtc"]),z=z||this._tag_stack.try_pop("rp",["ruby","rtc"])):te.tag_name==="optgroup"?z=z||this._tag_stack.try_pop("optgroup",["select"]):te.tag_name==="option"?z=z||this._tag_stack.try_pop("option",["select","datalist","optgroup"]):te.tag_name==="colgroup"?z=z||this._tag_stack.try_pop("caption",["table"]):te.tag_name==="thead"?(z=z||this._tag_stack.try_pop("caption",["table"]),z=z||this._tag_stack.try_pop("colgroup",["table"])):te.tag_name==="tbody"||te.tag_name==="tfoot"?(z=z||this._tag_stack.try_pop("caption",["table"]),z=z||this._tag_stack.try_pop("colgroup",["table"]),z=z||this._tag_stack.try_pop("thead",["table"]),z=z||this._tag_stack.try_pop("tbody",["table"])):te.tag_name==="tr"?(z=z||this._tag_stack.try_pop("caption",["table"]),z=z||this._tag_stack.try_pop("colgroup",["table"]),z=z||this._tag_stack.try_pop("tr",["table","thead","tbody","tfoot"])):(te.tag_name==="th"||te.tag_name==="td")&&(z=z||this._tag_stack.try_pop("td",["table","thead","tbody","tfoot","tr"]),z=z||this._tag_stack.try_pop("th",["table","thead","tbody","tfoot","tr"]));return te.parent=this._tag_stack.get_parser_token(),z}},I.exports.Beautifier=Oe},function(I,k,T){var M=T(6).Options;function O(Y){M.call(this,Y,"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_min_attrs=this._get_number("wrap_attributes_min_attrs",2),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.inline_custom_elements=this._get_boolean("inline_custom_elements",!0),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"])}O.prototype=new M,I.exports.Options=O},function(I,k,T){var M=T(9).Tokenizer,O=T(9).TOKEN,Y=T(13).Directives,H=T(14).TemplatablePattern,j=T(12).Pattern,U={TAG_OPEN:"TK_TAG_OPEN",TAG_CLOSE:"TK_TAG_CLOSE",CONTROL_FLOW_OPEN:"TK_CONTROL_FLOW_OPEN",CONTROL_FLOW_CLOSE:"TK_CONTROL_FLOW_CLOSE",ATTRIBUTE:"TK_ATTRIBUTE",EQUALS:"TK_EQUALS",VALUE:"TK_VALUE",COMMENT:"TK_COMMENT",TEXT:"TK_TEXT",UNKNOWN:"TK_UNKNOWN",START:O.START,RAW:O.RAW,EOF:O.EOF},$=new Y(/<\!--/,/-->/),G=function(he,be){M.call(this,he,be),this._current_tag_name="";var Se=new H(this._input).read_options(this._options),re=new j(this._input);if(this.__patterns={word:Se.until(/[\n\r\t <]/),word_control_flow_close_excluded:Se.until(/[\n\r\t <}]/),single_quote:Se.until_after(/'/),double_quote:Se.until_after(/"/),attribute:Se.until(/[\n\r\t =>]|\/>/),element_name:Se.until(/[\n\r\t >\/]/),angular_control_flow_start:re.matching(/\@[a-zA-Z]+[^({]*[({]/),handlebars_comment:re.starting_with(/{{!--/).until_after(/--}}/),handlebars:re.starting_with(/{{/).until_after(/}}/),handlebars_open:re.until(/[\n\r\t }]/),handlebars_raw_close:re.until(/}}/),comment:re.starting_with(/<!--/).until_after(/-->/),cdata:re.starting_with(/<!\[CDATA\[/).until_after(/]]>/),conditional_comment:re.starting_with(/<!\[/).until_after(/]>/),processing:re.starting_with(/<\?/).until_after(/\?>/)},this._options.indent_handlebars&&(this.__patterns.word=this.__patterns.word.exclude("handlebars"),this.__patterns.word_control_flow_close_excluded=this.__patterns.word_control_flow_close_excluded.exclude("handlebars")),this._unformatted_content_delimiter=null,this._options.unformatted_content_delimiter){var Oe=this._input.get_literal_regexp(this._options.unformatted_content_delimiter);this.__patterns.unformatted_content_delimiter=re.matching(Oe).until_after(Oe)}};G.prototype=new M,G.prototype._is_comment=function(he){return!1},G.prototype._is_opening=function(he){return he.type===U.TAG_OPEN||he.type===U.CONTROL_FLOW_OPEN},G.prototype._is_closing=function(he,be){return he.type===U.TAG_CLOSE&&be&&((he.text===">"||he.text==="/>")&&be.text[0]==="<"||he.text==="}}"&&be.text[0]==="{"&&be.text[1]==="{")||he.type===U.CONTROL_FLOW_CLOSE&&he.text==="}"&&be.text.endsWith("{")},G.prototype._reset=function(){this._current_tag_name=""},G.prototype._get_next_token=function(he,be){var Se=null;this._readWhitespace();var re=this._input.peek();return re===null?this._create_token(U.EOF,""):(Se=Se||this._read_open_handlebars(re,be),Se=Se||this._read_attribute(re,he,be),Se=Se||this._read_close(re,be),Se=Se||this._read_script_and_style(re,he),Se=Se||this._read_control_flows(re,be),Se=Se||this._read_raw_content(re,he,be),Se=Se||this._read_content_word(re,be),Se=Se||this._read_comment_or_cdata(re),Se=Se||this._read_processing(re),Se=Se||this._read_open(re,be),Se=Se||this._create_token(U.UNKNOWN,this._input.next()),Se)},G.prototype._read_comment_or_cdata=function(he){var be=null,Se=null,re=null;if(he==="<"){var Oe=this._input.peek(1);Oe==="!"&&(Se=this.__patterns.comment.read(),Se?(re=$.get_directives(Se),re&&re.ignore==="start"&&(Se+=$.readIgnored(this._input))):Se=this.__patterns.cdata.read()),Se&&(be=this._create_token(U.COMMENT,Se),be.directives=re)}return be},G.prototype._read_processing=function(he){var be=null,Se=null,re=null;if(he==="<"){var Oe=this._input.peek(1);(Oe==="!"||Oe==="?")&&(Se=this.__patterns.conditional_comment.read(),Se=Se||this.__patterns.processing.read()),Se&&(be=this._create_token(U.COMMENT,Se),be.directives=re)}return be},G.prototype._read_open=function(he,be){var Se=null,re=null;return(!be||be.type===U.CONTROL_FLOW_OPEN)&&he==="<"&&(Se=this._input.next(),this._input.peek()==="/"&&(Se+=this._input.next()),Se+=this.__patterns.element_name.read(),re=this._create_token(U.TAG_OPEN,Se)),re},G.prototype._read_open_handlebars=function(he,be){var Se=null,re=null;return(!be||be.type===U.CONTROL_FLOW_OPEN)&&(this._options.templating.includes("angular")||this._options.indent_handlebars)&&he==="{"&&this._input.peek(1)==="{"&&(this._options.indent_handlebars&&this._input.peek(2)==="!"?(Se=this.__patterns.handlebars_comment.read(),Se=Se||this.__patterns.handlebars.read(),re=this._create_token(U.COMMENT,Se)):(Se=this.__patterns.handlebars_open.read(),re=this._create_token(U.TAG_OPEN,Se))),re},G.prototype._read_control_flows=function(he,be){var Se="",re=null;if(!this._options.templating.includes("angular"))return re;if(he==="@"){if(Se=this.__patterns.angular_control_flow_start.read(),Se==="")return re;for(var Oe=Se.endsWith("(")?1:0,We=0;!(Se.endsWith("{")&&Oe===We);){var Be=this._input.next();if(Be===null)break;Be==="("?Oe++:Be===")"&&We++,Se+=Be}re=this._create_token(U.CONTROL_FLOW_OPEN,Se)}else he==="}"&&be&&be.type===U.CONTROL_FLOW_OPEN&&(Se=this._input.next(),re=this._create_token(U.CONTROL_FLOW_CLOSE,Se));return re},G.prototype._read_close=function(he,be){var Se=null,re=null;return be&&be.type===U.TAG_OPEN&&(be.text[0]==="<"&&(he===">"||he==="/"&&this._input.peek(1)===">")?(Se=this._input.next(),he==="/"&&(Se+=this._input.next()),re=this._create_token(U.TAG_CLOSE,Se)):be.text[0]==="{"&&he==="}"&&this._input.peek(1)==="}"&&(this._input.next(),this._input.next(),re=this._create_token(U.TAG_CLOSE,"}}"))),re},G.prototype._read_attribute=function(he,be,Se){var re=null,Oe="";if(Se&&Se.text[0]==="<")if(he==="=")re=this._create_token(U.EQUALS,this._input.next());else if(he==='"'||he==="'"){var We=this._input.next();he==='"'?We+=this.__patterns.double_quote.read():We+=this.__patterns.single_quote.read(),re=this._create_token(U.VALUE,We)}else Oe=this.__patterns.attribute.read(),Oe&&(be.type===U.EQUALS?re=this._create_token(U.VALUE,Oe):re=this._create_token(U.ATTRIBUTE,Oe));return re},G.prototype._is_content_unformatted=function(he){return this._options.void_elements.indexOf(he)===-1&&(this._options.content_unformatted.indexOf(he)!==-1||this._options.unformatted.indexOf(he)!==-1)},G.prototype._read_raw_content=function(he,be,Se){var re="";if(Se&&Se.text[0]==="{")re=this.__patterns.handlebars_raw_close.read();else if(be.type===U.TAG_CLOSE&&be.opened.text[0]==="<"&&be.text[0]!=="/"){var Oe=be.opened.text.substr(1).toLowerCase();this._is_content_unformatted(Oe)&&(re=this._input.readUntil(new RegExp("</"+Oe+"[\\n\\r\\t ]*?>","ig")))}return re?this._create_token(U.TEXT,re):null},G.prototype._read_script_and_style=function(he,be){if(be.type===U.TAG_CLOSE&&be.opened.text[0]==="<"&&be.text[0]!=="/"){var Se=be.opened.text.substr(1).toLowerCase();if(Se==="script"||Se==="style"){var re=this._read_comment_or_cdata(he);if(re)return re.type=U.TEXT,re;var Oe=this._input.readUntil(new RegExp("</"+Se+"[\\n\\r\\t ]*?>","ig"));if(Oe)return this._create_token(U.TEXT,Oe)}}return null},G.prototype._read_content_word=function(he,be){var Se="";return this._options.unformatted_content_delimiter&&he===this._options.unformatted_content_delimiter[0]&&(Se=this.__patterns.unformatted_content_delimiter.read()),Se||(Se=be&&be.type===U.CONTROL_FLOW_OPEN?this.__patterns.word_control_flow_close_excluded.read():this.__patterns.word.read()),Se?this._create_token(U.TEXT,Se):null},I.exports.Tokenizer=G,I.exports.TOKEN=U}],P={};function d(I){var k=P[I];if(k!==void 0)return k.exports;var T=P[I]={exports:{}};return Te[I](T,T.exports,d),T.exports}var ne=d(18);qe=ne})();var ge=qe;if(1)ce=[oe,oe(58553),oe(87804)],De=function(Te){var P=oe(58553),d=oe(87804);return{html_beautify:function(ne,I){return ge(ne,I,P.js_beautify,d.css_beautify)}}}.apply(Rt,ce),De!==void 0&&(Li.exports=De);else var q,S})()},58553:function(Li,Rt){var oe,ce;(function(){var De;(function(){"use strict";var ge=[function(P,d,ne){var I=ne(1).Beautifier,k=ne(5).Options;function T(M,O){var Y=new I(M,O);return Y.beautify()}P.exports=T,P.exports.defaultOptions=function(){return new k}},function(P,d,ne){var I=ne(2).Output,k=ne(3).Token,T=ne(4),M=ne(5).Options,O=ne(7).Tokenizer,Y=ne(7).line_starters,H=ne(7).positionable_operators,j=ne(7).TOKEN;function U(L,V){return V.indexOf(L)!==-1}function $(L){return L.replace(/^\s+/g,"")}function G(L){for(var V={},pe=0;pe<L.length;pe++)V[L[pe].replace(/-/g,"_")]=L[pe];return V}function he(L,V){return L&&L.type===j.RESERVED&&L.text===V}function be(L,V){return L&&L.type===j.RESERVED&&U(L.text,V)}var Se=["case","return","do","if","throw","else","await","break","continue","async"],re=["before-newline","after-newline","preserve-newline"],Oe=G(re),We=[Oe.before_newline,Oe.preserve_newline],Be={BlockStatement:"BlockStatement",Statement:"Statement",ObjectLiteral:"ObjectLiteral",ArrayLiteral:"ArrayLiteral",ForInitializer:"ForInitializer",Conditional:"Conditional",Expression:"Expression"};function Dt(L,V){V.multiline_frame||V.mode===Be.ForInitializer||V.mode===Be.Conditional||L.remove_indent(V.start_line_index)}function te(L){L=L.replace(T.allLineBreaks,`
`);for(var V=[],pe=L.indexOf(`
`);pe!==-1;)V.push(L.substring(0,pe)),L=L.substring(pe+1),pe=L.indexOf(`
`);return L.length&&V.push(L),V}function z(L){return L===Be.ArrayLiteral}function X(L){return U(L,[Be.Expression,Be.ForInitializer,Be.Conditional])}function J(L,V){for(var pe=0;pe<L.length;pe++){var ze=L[pe].trim();if(ze.charAt(0)!==V)return!1}return!0}function de(L,V){for(var pe=0,ze=L.length,at;pe<ze;pe++)if(at=L[pe],at&&at.indexOf(V)!==0)return!1;return!0}function ie(L,V){V=V||{},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 M(V)}ie.prototype.create_flags=function(L,V){var pe=0;L&&(pe=L.indentation_level,!this._output.just_added_newline()&&L.line_indent_level>pe&&(pe=L.line_indent_level));var ze={mode:V,parent:L,last_token:L?L.last_token:new k(j.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:pe,alignment:0,line_indent_level:L?L.line_indent_level:pe,start_line_index:this._output.get_line_number(),ternary_depth:0};return ze},ie.prototype._reset=function(L){var V=L.match(/^[\t ]*/)[0];this._last_last_text="",this._output=new I(this._options,V),this._output.raw=this._options.test_output_raw,this._flag_store=[],this.set_mode(Be.BlockStatement);var pe=new O(L,this._options);return this._tokens=pe.tokenize(),L},ie.prototype.beautify=function(){if(this._options.disabled)return this._source_text;var L,V=this._reset(this._source_text),pe=this._options.eol;this._options.eol==="auto"&&(pe=`
`,V&&T.lineBreak.test(V||"")&&(pe=V.match(T.lineBreak)[0]));for(var ze=this._tokens.next();ze;)this.handle_token(ze),this._last_last_text=this._flags.last_token.text,this._flags.last_token=ze,ze=this._tokens.next();return L=this._output.get_code(pe),L},ie.prototype.handle_token=function(L,V){L.type===j.START_EXPR?this.handle_start_expr(L):L.type===j.END_EXPR?this.handle_end_expr(L):L.type===j.START_BLOCK?this.handle_start_block(L):L.type===j.END_BLOCK?this.handle_end_block(L):L.type===j.WORD?this.handle_word(L):L.type===j.RESERVED?this.handle_word(L):L.type===j.SEMICOLON?this.handle_semicolon(L):L.type===j.STRING?this.handle_string(L):L.type===j.EQUALS?this.handle_equals(L):L.type===j.OPERATOR?this.handle_operator(L):L.type===j.COMMA?this.handle_comma(L):L.type===j.BLOCK_COMMENT?this.handle_block_comment(L,V):L.type===j.COMMENT?this.handle_comment(L,V):L.type===j.DOT?this.handle_dot(L):L.type===j.EOF?this.handle_eof(L):L.type===j.UNKNOWN?this.handle_unknown(L,V):this.handle_unknown(L,V)},ie.prototype.handle_whitespace_and_comments=function(L,V){var pe=L.newlines,ze=this._options.keep_array_indentation&&z(this._flags.mode);if(L.comments_before)for(var at=L.comments_before.next();at;)this.handle_whitespace_and_comments(at,V),this.handle_token(at,V),at=L.comments_before.next();if(ze)for(var Ot=0;Ot<pe;Ot+=1)this.print_newline(Ot>0,V);else if(this._options.max_preserve_newlines&&pe>this._options.max_preserve_newlines&&(pe=this._options.max_preserve_newlines),this._options.preserve_newlines&&pe>1){this.print_newline(!1,V);for(var Ce=1;Ce<pe;Ce+=1)this.print_newline(!0,V)}};var A=["async","break","continue","return","throw","yield"];ie.prototype.allow_wrap_or_preserved_newline=function(L,V){if(V=V===void 0?!1:V,!this._output.just_added_newline()){var pe=this._options.preserve_newlines&&L.newlines||V,ze=U(this._flags.last_token.text,H)||U(L.text,H);if(ze){var at=U(this._flags.last_token.text,H)&&U(this._options.operator_position,We)||U(L.text,H);pe=pe&&at}if(pe)this.print_newline(!1,!0);else if(this._options.wrap_line_length){if(be(this._flags.last_token,A))return;this._output.set_wrap_point()}}},ie.prototype.print_newline=function(L,V){if(!V&&this._flags.last_token.text!==";"&&this._flags.last_token.text!==","&&this._flags.last_token.text!=="="&&(this._flags.last_token.type!==j.OPERATOR||this._flags.last_token.text==="--"||this._flags.last_token.text==="++"))for(var pe=this._tokens.peek();this._flags.mode===Be.Statement&&!(this._flags.if_block&&he(pe,"else"))&&!this._flags.do_block;)this.restore_mode();this._output.add_new_line(L)&&(this._flags.multiline_frame=!0)},ie.prototype.print_token_line_indentation=function(L){this._output.just_added_newline()&&(this._options.keep_array_indentation&&L.newlines&&(L.text==="["||z(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))},ie.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===j.COMMA&&this._output.just_added_newline()&&this._output.previous_line.last()===","){var V=this._output.previous_line.pop();this._output.previous_line.is_empty()&&(this._output.previous_line.push(V),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)},ie.prototype.indent=function(){this._flags.indentation_level+=1,this._output.set_indent(this._flags.indentation_level,this._flags.alignment)},ie.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))},ie.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)},ie.prototype.restore_mode=function(){this._flag_store.length>0&&(this._previous_flags=this._flags,this._flags=this._flag_store.pop(),this._previous_flags.mode===Be.Statement&&Dt(this._output,this._previous_flags),this._output.set_indent(this._flags.indentation_level,this._flags.alignment))},ie.prototype.start_of_object_property=function(){return this._flags.parent.mode===Be.ObjectLiteral&&this._flags.mode===Be.Statement&&(this._flags.last_token.text===":"&&this._flags.ternary_depth===0||be(this._flags.last_token,["get","set"]))},ie.prototype.start_of_statement=function(L){var V=!1;return V=V||be(this._flags.last_token,["var","let","const"])&&L.type===j.WORD,V=V||he(this._flags.last_token,"do"),V=V||!(this._flags.parent.mode===Be.ObjectLiteral&&this._flags.mode===Be.Statement)&&be(this._flags.last_token,A)&&!L.newlines,V=V||he(this._flags.last_token,"else")&&!(he(L,"if")&&!L.comments_before),V=V||this._flags.last_token.type===j.END_EXPR&&(this._previous_flags.mode===Be.ForInitializer||this._previous_flags.mode===Be.Conditional),V=V||this._flags.last_token.type===j.WORD&&this._flags.mode===Be.BlockStatement&&!this._flags.in_case&&!(L.text==="--"||L.text==="++")&&this._last_last_text!=="function"&&L.type!==j.WORD&&L.type!==j.RESERVED,V=V||this._flags.mode===Be.ObjectLiteral&&(this._flags.last_token.text===":"&&this._flags.ternary_depth===0||be(this._flags.last_token,["get","set"])),V?(this.set_mode(Be.Statement),this.indent(),this.handle_whitespace_and_comments(L,!0),this.start_of_object_property()||this.allow_wrap_or_preserved_newline(L,be(L,["do","for","if","while"])),!0):!1},ie.prototype.handle_start_expr=function(L){this.start_of_statement(L)||this.handle_whitespace_and_comments(L);var V=Be.Expression;if(L.text==="["){if(this._flags.last_token.type===j.WORD||this._flags.last_token.text===")"){be(this._flags.last_token,Y)&&(this._output.space_before_token=!0),this.print_token(L),this.set_mode(V),this.indent(),this._options.space_in_paren&&(this._output.space_before_token=!0);return}V=Be.ArrayLiteral,z(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()),U(this._flags.last_token.type,[j.START_EXPR,j.END_EXPR,j.WORD,j.OPERATOR,j.DOT])||(this._output.space_before_token=!0)}else{if(this._flags.last_token.type===j.RESERVED)this._flags.last_token.text==="for"?(this._output.space_before_token=this._options.space_before_conditional,V=Be.ForInitializer):U(this._flags.last_token.text,["if","while","switch"])?(this._output.space_before_token=this._options.space_before_conditional,V=Be.Conditional):U(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:(U(this._flags.last_token.text,Y)||this._flags.last_token.text==="catch")&&(this._output.space_before_token=!0);else if(this._flags.last_token.type===j.EQUALS||this._flags.last_token.type===j.OPERATOR)this.start_of_object_property()||this.allow_wrap_or_preserved_newline(L);else if(this._flags.last_token.type===j.WORD){this._output.space_before_token=!1;var pe=this._tokens.peek(-3);if(this._options.space_after_named_function&&pe){var ze=this._tokens.peek(-4);be(pe,["async","function"])||pe.text==="*"&&be(ze,["async","function"])?this._output.space_before_token=!0:this._flags.mode===Be.ObjectLiteral?(pe.text==="{"||pe.text===","||pe.text==="*"&&(ze.text==="{"||ze.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===j.RESERVED&&(this._flags.last_word==="function"||this._flags.last_word==="typeof")||this._flags.last_token.text==="*"&&(U(this._last_last_text,["function","yield"])||this._flags.mode===Be.ObjectLiteral&&U(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===j.START_BLOCK?this.print_newline():(this._flags.last_token.type===j.END_EXPR||this._flags.last_token.type===j.START_EXPR||this._flags.last_token.type===j.END_BLOCK||this._flags.last_token.text==="."||this._flags.last_token.type===j.COMMA)&&this.allow_wrap_or_preserved_newline(L,L.newlines),this.print_token(L),this.set_mode(V),this._options.space_in_paren&&(this._output.space_before_token=!0),this.indent()},ie.prototype.handle_end_expr=function(L){for(;this._flags.mode===Be.Statement;)this.restore_mode();this.handle_whitespace_and_comments(L),this._flags.multiline_frame&&this.allow_wrap_or_preserved_newline(L,L.text==="]"&&z(this._flags.mode)&&!this._options.keep_array_indentation),this._options.space_in_paren&&(this._flags.last_token.type===j.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(),Dt(this._output,this._previous_flags),this._flags.do_while&&this._previous_flags.mode===Be.Conditional&&(this._previous_flags.mode=Be.Expression,this._flags.do_block=!1,this._flags.do_while=!1)},ie.prototype.handle_start_block=function(L){this.handle_whitespace_and_comments(L);var V=this._tokens.peek(),pe=this._tokens.peek(1);this._flags.last_word==="switch"&&this._flags.last_token.type===j.END_EXPR?(this.set_mode(Be.BlockStatement),this._flags.in_case_statement=!0):this._flags.case_body?this.set_mode(Be.BlockStatement):pe&&(U(pe.text,[":",","])&&U(V.type,[j.STRING,j.WORD,j.RESERVED])||U(V.text,["get","set","..."])&&U(pe.type,[j.WORD,j.RESERVED]))?U(this._last_last_text,["class","interface"])&&!U(pe.text,[":",","])?this.set_mode(Be.BlockStatement):this.set_mode(Be.ObjectLiteral):this._flags.last_token.type===j.OPERATOR&&this._flags.last_token.text==="=>"?this.set_mode(Be.BlockStatement):U(this._flags.last_token.type,[j.EQUALS,j.START_EXPR,j.COMMA,j.OPERATOR])||be(this._flags.last_token,["return","throw","import","default"])?this.set_mode(Be.ObjectLiteral):this.set_mode(Be.BlockStatement),this._flags.last_token&&be(this._flags.last_token.previous,["class","extends"])&&(this._flags.class_start_block=!0);var ze=!V.comments_before&&V.text==="}",at=ze&&this._flags.last_word==="function"&&this._flags.last_token.type===j.END_EXPR;if(this._options.brace_preserve_inline){var Ot=0,Ce=null;this._flags.inline_frame=!0;do if(Ot+=1,Ce=this._tokens.peek(Ot-1),Ce.newlines){this._flags.inline_frame=!1;break}while(Ce.type!==j.EOF&&!(Ce.type===j.END_BLOCK&&Ce.opened===L))}(this._options.brace_style==="expand"||this._options.brace_style==="none"&&L.newlines)&&!this._flags.inline_frame?this._flags.last_token.type!==j.OPERATOR&&(at||this._flags.last_token.type===j.EQUALS||be(this._flags.last_token,Se)&&this._flags.last_token.text!=="else")?this._output.space_before_token=!0:this.print_newline(!1,!0):(z(this._previous_flags.mode)&&(this._flags.last_token.type===j.START_EXPR||this._flags.last_token.type===j.COMMA)&&((this._flags.last_token.type===j.COMMA||this._options.space_in_paren)&&(this._output.space_before_token=!0),(this._flags.last_token.type===j.COMMA||this._flags.last_token.type===j.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!==j.OPERATOR&&this._flags.last_token.type!==j.START_EXPR&&(U(this._flags.last_token.type,[j.START_BLOCK,j.SEMICOLON])&&!this._flags.inline_frame?this.print_newline():this._output.space_before_token=!0)),this.print_token(L),this.indent(),!ze&&!(this._options.brace_preserve_inline&&this._flags.inline_frame)&&this.print_newline()},ie.prototype.handle_end_block=function(L){for(this.handle_whitespace_and_comments(L);this._flags.mode===Be.Statement;)this.restore_mode();var V=this._flags.last_token.type===j.START_BLOCK;this._flags.inline_frame&&!V?this._output.space_before_token=!0:this._options.brace_style==="expand"?V||this.print_newline():V||(z(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)},ie.prototype.handle_word=function(L){if(L.type===j.RESERVED){if(U(L.text,["set","get"])&&this._flags.mode!==Be.ObjectLiteral)L.type=j.WORD;else if(L.text==="import"&&U(this._tokens.peek().text,["(","."]))L.type=j.WORD;else if(U(L.text,["as","from"])&&!this._flags.import_block)L.type=j.WORD;else if(this._flags.mode===Be.ObjectLiteral){var V=this._tokens.peek();V.text===":"&&(L.type=j.WORD)}}if(this.start_of_statement(L)?be(this._flags.last_token,["var","let","const"])&&L.type===j.WORD&&(this._flags.declaration_statement=!0):L.newlines&&!X(this._flags.mode)&&(this._flags.last_token.type!==j.OPERATOR||this._flags.last_token.text==="--"||this._flags.last_token.text==="++")&&this._flags.last_token.type!==j.EQUALS&&(this._options.preserve_newlines||!be(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(he(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&&he(L,"else"))this._flags.else_block=!0;else{for(;this._flags.mode===Be.Statement;)this.restore_mode();this._flags.if_block=!1,this._flags.else_block=!1}if(this._flags.in_case_statement&&be(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===j.COMMA||this._flags.last_token.type===j.START_EXPR||this._flags.last_token.type===j.EQUALS||this._flags.last_token.type===j.OPERATOR)&&!this.start_of_object_property()&&!(U(this._flags.last_token.text,["+","-"])&&this._last_last_text===":"&&this._flags.parent.mode===Be.ObjectLiteral)&&this.allow_wrap_or_preserved_newline(L),he(L,"function")){(U(this._flags.last_token.text,["}",";"])||this._output.just_added_newline()&&!(U(this._flags.last_token.text,["(","[","{",":","=",","])||this._flags.last_token.type===j.OPERATOR))&&!this._output.just_added_blankline()&&!L.comments_before&&(this.print_newline(),this.print_newline(!0)),this._flags.last_token.type===j.RESERVED||this._flags.last_token.type===j.WORD?be(this._flags.last_token,["get","set","new","export"])||be(this._flags.last_token,A)?this._output.space_before_token=!0:he(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===j.OPERATOR||this._flags.last_token.text==="="?this._output.space_before_token=!0:!this._flags.multiline_frame&&(X(this._flags.mode)||z(this._flags.mode))||this.print_newline(),this.print_token(L),this._flags.last_word=L.text;return}var pe="NONE";if(this._flags.last_token.type===j.END_BLOCK?this._previous_flags.inline_frame?pe="SPACE":be(L,["else","catch","finally","from"])?this._options.brace_style==="expand"||this._options.brace_style==="end-expand"||this._options.brace_style==="none"&&L.newlines?pe="NEWLINE":(pe="SPACE",this._output.space_before_token=!0):pe="NEWLINE":this._flags.last_token.type===j.SEMICOLON&&this._flags.mode===Be.BlockStatement?pe="NEWLINE":this._flags.last_token.type===j.SEMICOLON&&X(this._flags.mode)?pe="SPACE":this._flags.last_token.type===j.STRING?pe="NEWLINE":this._flags.last_token.type===j.RESERVED||this._flags.last_token.type===j.WORD||this._flags.last_token.text==="*"&&(U(this._last_last_text,["function","yield"])||this._flags.mode===Be.ObjectLiteral&&U(this._last_last_text,["{",","]))?pe="SPACE":this._flags.last_token.type===j.START_BLOCK?this._flags.inline_frame?pe="SPACE":pe="NEWLINE":this._flags.last_token.type===j.END_EXPR&&(this._output.space_before_token=!0,pe="NEWLINE"),be(L,Y)&&this._flags.last_token.text!==")"&&(this._flags.inline_frame||this._flags.last_token.text==="else"||this._flags.last_token.text==="export"?pe="SPACE":pe="NEWLINE"),be(L,["else","catch","finally"]))if((!(this._flags.last_token.type===j.END_BLOCK&&this._previous_flags.mode===Be.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 ze=this._output.current_line;ze.last()!=="}"&&this.print_newline(),this._output.space_before_token=!0}else pe==="NEWLINE"?be(this._flags.last_token,Se)?this._output.space_before_token=!0:this._flags.last_token.text==="declare"&&be(L,["var","let","const"])?this._output.space_before_token=!0:this._flags.last_token.type!==j.END_EXPR?(this._flags.last_token.type!==j.START_EXPR||!be(L,["var","let","const"]))&&this._flags.last_token.text!==":"&&(he(L,"if")&&he(L.previous,"else")?this._output.space_before_token=!0:this.print_newline()):be(L,Y)&&this._flags.last_token.text!==")"&&this.print_newline():this._flags.multiline_frame&&z(this._flags.mode)&&this._flags.last_token.text===","&&this._last_last_text==="}"?this.print_newline():pe==="SPACE"&&(this._output.space_before_token=!0);L.previous&&(L.previous.type===j.WORD||L.previous.type===j.RESERVED)&&(this._output.space_before_token=!0),this.print_token(L),this._flags.last_word=L.text,L.type===j.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&&he(L,"from")&&(this._flags.import_block=!1))},ie.prototype.handle_semicolon=function(L){this.start_of_statement(L)?this._output.space_before_token=!1:this.handle_whitespace_and_comments(L);for(var V=this._tokens.peek();this._flags.mode===Be.Statement&&!(this._flags.if_block&&he(V,"else"))&&!this._flags.do_block;)this.restore_mode();this._flags.import_block&&(this._flags.import_block=!1),this.print_token(L)},ie.prototype.handle_string=function(L){L.text.startsWith("`")&&L.newlines===0&&L.whitespace_before===""&&(L.previous.text===")"||this._flags.last_token.type===j.WORD)||(this.start_of_statement(L)?this._output.space_before_token=!0:(this.handle_whitespace_and_comments(L),this._flags.last_token.type===j.RESERVED||this._flags.last_token.type===j.WORD||this._flags.inline_frame?this._output.space_before_token=!0:this._flags.last_token.type===j.COMMA||this._flags.last_token.type===j.START_EXPR||this._flags.last_token.type===j.EQUALS||this._flags.last_token.type===j.OPERATOR?this.start_of_object_property()||this.allow_wrap_or_preserved_newline(L):L.text.startsWith("`")&&this._flags.last_token.type===j.END_EXPR&&(L.previous.text==="]"||L.previous.text===")")&&L.newlines===0?this._output.space_before_token=!0:this.print_newline())),this.print_token(L)},ie.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},ie.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?(X(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===Be.ObjectLiteral||this._flags.mode===Be.Statement&&this._flags.parent.mode===Be.ObjectLiteral?(this._flags.mode===Be.Statement&&this.restore_mode(),this._flags.inline_frame||this.print_newline()):this._options.comma_first&&this.allow_wrap_or_preserved_newline(L)},ie.prototype.handle_operator=function(L){var V=L.text==="*"&&(be(this._flags.last_token,["function","yield"])||U(this._flags.last_token.type,[j.START_BLOCK,j.COMMA,j.END_BLOCK,j.SEMICOLON])),pe=U(L.text,["-","+"])&&(U(this._flags.last_token.type,[j.START_BLOCK,j.START_EXPR,j.EQUALS,j.OPERATOR])||U(this._flags.last_token.text,Y)||this._flags.last_token.text===",");if(!this.start_of_statement(L)){var ze=!V;this.handle_whitespace_and_comments(L,ze)}if(L.text==="*"&&this._flags.last_token.type===j.DOT){this.print_token(L);return}if(L.text==="::"){this.print_token(L);return}if(U(L.text,["-","+"])&&this.start_of_object_property()){this.print_token(L);return}if(this._flags.last_token.type===j.OPERATOR&&U(this._options.operator_position,We)&&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!==j.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 at=!0,Ot=!0,Ce=!1;if(L.text===":"?this._flags.ternary_depth===0?at=!1:(this._flags.ternary_depth-=1,Ce=!0):L.text==="?"&&(this._flags.ternary_depth+=1),!pe&&!V&&this._options.preserve_newlines&&U(L.text,H)){var jt=L.text===":",Mt=jt&&Ce,dt=jt&&!Ce;switch(this._options.operator_position){case Oe.before_newline:this._output.space_before_token=!dt,this.print_token(L),(!jt||Mt)&&this.allow_wrap_or_preserved_newline(L),this._output.space_before_token=!0;return;case Oe.after_newline:this._output.space_before_token=!0,!jt||Mt?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 Oe.preserve_newline:dt||this.allow_wrap_or_preserved_newline(L),at=!(this._output.just_added_newline()||dt),this._output.space_before_token=at,this.print_token(L),this._output.space_before_token=!0;return}}if(V){this.allow_wrap_or_preserved_newline(L),at=!1;var Ti=this._tokens.peek();Ot=Ti&&U(Ti.type,[j.WORD,j.RESERVED])}else if(L.text==="...")this.allow_wrap_or_preserved_newline(L),at=this._flags.last_token.type===j.START_BLOCK,Ot=!1;else if(U(L.text,["--","++","!","~"])||pe){if((this._flags.last_token.type===j.COMMA||this._flags.last_token.type===j.START_EXPR)&&this.allow_wrap_or_preserved_newline(L),at=!1,Ot=!1,L.newlines&&(L.text==="--"||L.text==="++"||L.text==="~")){var fi=be(this._flags.last_token,Se)&&L.newlines;fi&&(this._previous_flags.if_block||this._previous_flags.else_block)&&this.restore_mode(),this.print_newline(fi,!0)}this._flags.last_token.text===";"&&X(this._flags.mode)&&(at=!0),this._flags.last_token.type===j.RESERVED?at=!0:this._flags.last_token.type===j.END_EXPR?at=!(this._flags.last_token.text==="]"&&(L.text==="--"||L.text==="++")):this._flags.last_token.type===j.OPERATOR&&(at=U(L.text,["--","-","++","+"])&&U(this._flags.last_token.text,["--","-","++","+"]),U(L.text,["+","-"])&&U(this._flags.last_token.text,["--","++"])&&(Ot=!0)),(this._flags.mode===Be.BlockStatement&&!this._flags.inline_frame||this._flags.mode===Be.Statement)&&(this._flags.last_token.text==="{"||this._flags.last_token.text===";")&&this.print_newline()}this._output.space_before_token=this._output.space_before_token||at,this.print_token(L),this._output.space_before_token=Ot},ie.prototype.handle_block_comment=function(L,V){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,V),this.print_token(L),L.directives.preserve==="start"&&(this._output.raw=!0),this.print_newline(!1,!0);return}if(!T.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,V)},ie.prototype.print_block_commment=function(L,V){var pe=te(L.text),ze,at=!1,Ot=!1,Ce=L.whitespace_before,jt=Ce.length;if(this.print_newline(!1,V),this.print_token_line_indentation(L),this._output.add_token(pe[0]),this.print_newline(!1,V),pe.length>1){for(pe=pe.slice(1),at=J(pe,"*"),Ot=de(pe,Ce),at&&(this._flags.alignment=1),ze=0;ze<pe.length;ze++)at?(this.print_token_line_indentation(L),this._output.add_token($(pe[ze]))):Ot&&pe[ze]?(this.print_token_line_indentation(L),this._output.add_token(pe[ze].substring(jt))):(this._output.current_line.set_indent(-1),this._output.add_token(pe[ze])),this.print_newline(!1,V);this._flags.alignment=0}},ie.prototype.handle_comment=function(L,V){L.newlines?this.print_newline(!1,V):this._output.trim(!0),this._output.space_before_token=!0,this.print_token(L),this.print_newline(!1,V)},ie.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),be(this._flags.last_token,Se)?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)},ie.prototype.handle_unknown=function(L,V){this.print_token(L),L.text[L.text.length-1]===`
`&&this.print_newline(!1,V)},ie.prototype.handle_eof=function(L){for(;this._flags.mode===Be.Statement;)this.restore_mode();this.handle_whitespace_and_comments(L)},P.exports.Beautifier=ie},function(P){function d(k){this.__parent=k,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=[]}d.prototype.clone_empty=function(){var k=new d(this.__parent);return k.set_indent(this.__indent_count,this.__alignment_count),k},d.prototype.item=function(k){return k<0?this.__items[this.__items.length+k]:this.__items[k]},d.prototype.has_match=function(k){for(var T=this.__items.length-1;T>=0;T--)if(this.__items[T].match(k))return!0;return!1},d.prototype.set_indent=function(k,T){this.is_empty()&&(this.__indent_count=k||0,this.__alignment_count=T||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},d.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)},d.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},d.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var k=this.__parent.current_line;return k.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),k.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),k.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,k.__items[0]===" "&&(k.__items.splice(0,1),k.__character_count-=1),!0}return!1},d.prototype.is_empty=function(){return this.__items.length===0},d.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},d.prototype.push=function(k){this.__items.push(k);var T=k.lastIndexOf(`
`);T!==-1?this.__character_count=k.length-T:this.__character_count+=k.length},d.prototype.pop=function(){var k=null;return this.is_empty()||(k=this.__items.pop(),this.__character_count-=k.length),k},d.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},d.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},d.prototype.trim=function(){for(;this.last()===" ";)this.__items.pop(),this.__character_count-=1},d.prototype.toString=function(){var k="";return this.is_empty()?this.__parent.indent_empty_lines&&(k=this.__parent.get_indent_string(this.__indent_count)):(k=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),k+=this.__items.join("")),k};function ne(k,T){this.__cache=[""],this.__indent_size=k.indent_size,this.__indent_string=k.indent_char,k.indent_with_tabs||(this.__indent_string=new Array(k.indent_size+1).join(k.indent_char)),T=T||"",k.indent_level>0&&(T=new Array(k.indent_level+1).join(this.__indent_string)),this.__base_string=T,this.__base_string_length=T.length}ne.prototype.get_indent_size=function(k,T){var M=this.__base_string_length;return T=T||0,k<0&&(M=0),M+=k*this.__indent_size,M+=T,M},ne.prototype.get_indent_string=function(k,T){var M=this.__base_string;return T=T||0,k<0&&(k=0,M=""),T+=k*this.__indent_size,this.__ensure_cache(T),M+=this.__cache[T],M},ne.prototype.__ensure_cache=function(k){for(;k>=this.__cache.length;)this.__add_column()},ne.prototype.__add_column=function(){var k=this.__cache.length,T=0,M="";this.__indent_size&&k>=this.__indent_size&&(T=Math.floor(k/this.__indent_size),k-=T*this.__indent_size,M=new Array(T+1).join(this.__indent_string)),k&&(M+=new Array(k+1).join(" ")),this.__cache.push(M)};function I(k,T){this.__indent_cache=new ne(k,T),this.raw=!1,this._end_with_newline=k.end_with_newline,this.indent_size=k.indent_size,this.wrap_line_length=k.wrap_line_length,this.indent_empty_lines=k.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new d(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}I.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},I.prototype.get_line_number=function(){return this.__lines.length},I.prototype.get_indent_string=function(k,T){return this.__indent_cache.get_indent_string(k,T)},I.prototype.get_indent_size=function(k,T){return this.__indent_cache.get_indent_size(k,T)},I.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},I.prototype.add_new_line=function(k){return this.is_empty()||!k&&this.just_added_newline()?!1:(this.raw||this.__add_outputline(),!0)},I.prototype.get_code=function(k){this.trim(!0);var T=this.current_line.pop();T&&(T[T.length-1]===`
`&&(T=T.replace(/\n+$/g,"")),this.current_line.push(T)),this._end_with_newline&&this.__add_outputline();var M=this.__lines.join(`
`);return k!==`
`&&(M=M.replace(/[\n]/g,k)),M},I.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},I.prototype.set_indent=function(k,T){return k=k||0,T=T||0,this.next_line.set_indent(k,T),this.__lines.length>1?(this.current_line.set_indent(k,T),!0):(this.current_line.set_indent(),!1)},I.prototype.add_raw_token=function(k){for(var T=0;T<k.newlines;T++)this.__add_outputline();this.current_line.set_indent(-1),this.current_line.push(k.whitespace_before),this.current_line.push(k.text),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1},I.prototype.add_token=function(k){this.__add_space_before_token(),this.current_line.push(k),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=this.current_line._allow_wrap()},I.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(" "))},I.prototype.remove_indent=function(k){for(var T=this.__lines.length;k<T;)this.__lines[k]._remove_indent(),k++;this.current_line._remove_wrap_indent()},I.prototype.trim=function(k){for(k=k===void 0?!1:k,this.current_line.trim();k&&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},I.prototype.just_added_newline=function(){return this.current_line.is_empty()},I.prototype.just_added_blankline=function(){return this.is_empty()||this.current_line.is_empty()&&this.previous_line.is_empty()},I.prototype.ensure_empty_line_above=function(k,T){for(var M=this.__lines.length-2;M>=0;){var O=this.__lines[M];if(O.is_empty())break;if(O.item(0).indexOf(k)!==0&&O.item(-1)!==T){this.__lines.splice(M+1,0,new d(this)),this.previous_line=this.__lines[this.__lines.length-2];break}M--}},P.exports.Output=I},function(P){function d(ne,I,k,T){this.type=ne,this.text=I,this.comments_before=null,this.newlines=k||0,this.whitespace_before=T||"",this.parent=null,this.next=null,this.previous=null,this.opened=null,this.closed=null,this.directives=null}P.exports.Token=d},function(P,d){var ne="\\x23\\x24\\x40\\x41-\\x5a\\x5f\\x61-\\x7a",I="\\x24\\x30-\\x39\\x41-\\x5a\\x5f\\x61-\\x7a",k="\\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",T="\\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",M="\\\\u[0-9a-fA-F]{4}|\\\\u\\{[0-9a-fA-F]+\\}",O="(?:"+M+"|["+ne+k+"])",Y="(?:"+M+"|["+I+k+T+"])*";d.identifier=new RegExp(O+Y,"g"),d.identifierStart=new RegExp(O),d.identifierMatch=new RegExp("(?:"+M+"|["+I+k+T+"])+");var H=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;d.newline=/[\n\r\u2028\u2029]/,d.lineBreak=new RegExp(`\r
|`+d.newline.source),d.allLineBreaks=new RegExp(d.lineBreak.source,"g")},function(P,d,ne){var I=ne(6).Options,k=["before-newline","after-newline","preserve-newline"];function T(M){I.call(this,M,"js");var O=this.raw_options.brace_style||null;O==="expand-strict"?this.raw_options.brace_style="expand":O==="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 Y=this._get_selection_list("brace_style",["collapse","expand","end-expand","none","preserve-inline"]);this.brace_preserve_inline=!1,this.brace_style="collapse";for(var H=0;H<Y.length;H++)Y[H]==="preserve-inline"?this.brace_preserve_inline=!0:this.brace_style=Y[H];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",k),this.test_output_raw=this._get_boolean("test_output_raw"),this.jslint_happy&&(this.space_after_anon_function=!0)}T.prototype=new I,P.exports.Options=T},function(P){function d(k,T){this.raw_options=ne(k,T),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","angular","django","erb","handlebars","php","smarty"],["auto"])}d.prototype._get_array=function(k,T){var M=this.raw_options[k],O=T||[];return typeof M=="object"?M!==null&&typeof M.concat=="function"&&(O=M.concat()):typeof M=="string"&&(O=M.split(/[^a-zA-Z0-9_\/\-]+/)),O},d.prototype._get_boolean=function(k,T){var M=this.raw_options[k],O=M===void 0?!!T:!!M;return O},d.prototype._get_characters=function(k,T){var M=this.raw_options[k],O=T||"";return typeof M=="string"&&(O=M.replace(/\\r/,"\r").replace(/\\n/,`
`).replace(/\\t/," ")),O},d.prototype._get_number=function(k,T){var M=this.raw_options[k];T=parseInt(T,10),isNaN(T)&&(T=0);var O=parseInt(M,10);return isNaN(O)&&(O=T),O},d.prototype._get_selection=function(k,T,M){var O=this._get_selection_list(k,T,M);if(O.length!==1)throw new Error("Invalid Option Value: The option '"+k+`' can only be one of the following values:
`+T+`
You passed in: '`+this.raw_options[k]+"'");return O[0]},d.prototype._get_selection_list=function(k,T,M){if(!T||T.length===0)throw new Error("Selection list cannot be empty.");if(M=M||[T[0]],!this._is_valid_selection(M,T))throw new Error("Invalid Default Value!");var O=this._get_array(k,M);if(!this._is_valid_selection(O,T))throw new Error("Invalid Option Value: The option '"+k+`' can contain only the following values:
`+T+`
You passed in: '`+this.raw_options[k]+"'");return O},d.prototype._is_valid_selection=function(k,T){return k.length&&T.length&&!k.some(function(M){return T.indexOf(M)===-1})};function ne(k,T){var M={};k=I(k);var O;for(O in k)O!==T&&(M[O]=k[O]);if(T&&k[T])for(O in k[T])M[O]=k[T][O];return M}function I(k){var T={},M;for(M in k){var O=M.replace(/-/g,"_");T[O]=k[M]}return T}P.exports.Options=d,P.exports.normalizeOpts=I,P.exports.mergeOpts=ne},function(P,d,ne){var I=ne(8).InputScanner,k=ne(9).Tokenizer,T=ne(9).TOKEN,M=ne(13).Directives,O=ne(4),Y=ne(12).Pattern,H=ne(14).TemplatablePattern;function j(J,de){return de.indexOf(J)!==-1}var U={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:T.START,RAW:T.RAW,EOF:T.EOF},$=new M(/\/\*/,/\*\//),G=/0[xX][0123456789abcdefABCDEF_]*n?|0[oO][01234567_]*n?|0[bB][01_]*n?|\d[\d_]*n|(?:\.\d[\d_]*|\d[\d_]*\.?[\d_]*)(?:[eE][+-]?[\d_]+)?/,he=/[0-9]/,be=/[^\d\.]/,Se=">>> === !== &&= ??= ||= << && >= ** != == <= >> || ?? |> < / - + > : & % ? ^ | *".split(" "),re=">>>= ... >>= <<= === >>> !== **= &&= ??= ||= => ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> = ! ? > < : / ^ - + * & % ~ |";re=re.replace(/[-[\]{}()*+?.,\\^$|#]/g,"\\$&"),re="\\?\\.(?!\\d) "+re,re=re.replace(/ /g,"|");var Oe=new RegExp(re),We="continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export".split(","),Be=We.concat(["do","in","of","else","get","set","new","catch","finally","typeof","yield","async","await","from","as","class","extends"]),Dt=new RegExp("^(?:"+Be.join("|")+")$"),te,z=function(J,de){k.call(this,J,de),this._patterns.whitespace=this._patterns.whitespace.matching(/\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,/\u2028\u2029/.source);var ie=new Y(this._input),A=new H(this._input).read_options(this._options);this.__patterns={template:A,identifier:A.starting_with(O.identifier).matching(O.identifierMatch),number:ie.matching(G),punct:ie.matching(Oe),comment:ie.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),block_comment:ie.starting_with(/\/\*/).until_after(/\*\//),html_comment_start:ie.matching(/<!--/),html_comment_end:ie.matching(/-->/),include:ie.starting_with(/#include/).until_after(O.lineBreak),shebang:ie.starting_with(/#!/).until_after(O.lineBreak),xml:ie.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:A.until(/['\\\n\r\u2028\u2029]/),double_quote:A.until(/["\\\n\r\u2028\u2029]/),template_text:A.until(/[`\\$]/),template_expression:A.until(/[`}\\]/)}};z.prototype=new k,z.prototype._is_comment=function(J){return J.type===U.COMMENT||J.type===U.BLOCK_COMMENT||J.type===U.UNKNOWN},z.prototype._is_opening=function(J){return J.type===U.START_BLOCK||J.type===U.START_EXPR},z.prototype._is_closing=function(J,de){return(J.type===U.END_BLOCK||J.type===U.END_EXPR)&&de&&(J.text==="]"&&de.text==="["||J.text===")"&&de.text==="("||J.text==="}"&&de.text==="{")},z.prototype._reset=function(){te=!1},z.prototype._get_next_token=function(J,de){var ie=null;this._readWhitespace();var A=this._input.peek();return A===null?this._create_token(U.EOF,""):(ie=ie||this._read_non_javascript(A),ie=ie||this._read_string(A),ie=ie||this._read_pair(A,this._input.peek(1)),ie=ie||this._read_word(J),ie=ie||this._read_singles(A),ie=ie||this._read_comment(A),ie=ie||this._read_regexp(A,J),ie=ie||this._read_xml(A,J),ie=ie||this._read_punctuation(),ie=ie||this._create_token(U.UNKNOWN,this._input.next()),ie)},z.prototype._read_word=function(J){var de;if(de=this.__patterns.identifier.read(),de!=="")return de=de.replace(O.allLineBreaks,`
`),!(J.type===U.DOT||J.type===U.RESERVED&&(J.text==="set"||J.text==="get"))&&Dt.test(de)?(de==="in"||de==="of")&&(J.type===U.WORD||J.type===U.STRING)?this._create_token(U.OPERATOR,de):this._create_token(U.RESERVED,de):this._create_token(U.WORD,de);if(de=this.__patterns.number.read(),de!=="")return this._create_token(U.WORD,de)},z.prototype._read_singles=function(J){var de=null;return J==="("||J==="["?de=this._create_token(U.START_EXPR,J):J===")"||J==="]"?de=this._create_token(U.END_EXPR,J):J==="{"?de=this._create_token(U.START_BLOCK,J):J==="}"?de=this._create_token(U.END_BLOCK,J):J===";"?de=this._create_token(U.SEMICOLON,J):J==="."&&be.test(this._input.peek(1))?de=this._create_token(U.DOT,J):J===","&&(de=this._create_token(U.COMMA,J)),de&&this._input.next(),de},z.prototype._read_pair=function(J,de){var ie=null;return J==="#"&&de==="{"&&(ie=this._create_token(U.START_BLOCK,J+de)),ie&&(this._input.next(),this._input.next()),ie},z.prototype._read_punctuation=function(){var J=this.__patterns.punct.read();if(J!=="")return J==="="?this._create_token(U.EQUALS,J):J==="?."?this._create_token(U.DOT,J):this._create_token(U.OPERATOR,J)},z.prototype._read_non_javascript=function(J){var de="";if(J==="#"){if(this._is_first_token()&&(de=this.__patterns.shebang.read(),de))return this._create_token(U.UNKNOWN,de.trim()+`
`);if(de=this.__patterns.include.read(),de)return this._create_token(U.UNKNOWN,de.trim()+`
`);J=this._input.next();var ie="#";if(this._input.hasNext()&&this._input.testChar(he)){do J=this._input.next(),ie+=J;while(this._input.hasNext()&&J!=="#"&&J!=="=");return J==="#"||(this._input.peek()==="["&&this._input.peek(1)==="]"?(ie+="[]",this._input.next(),this._input.next()):this._input.peek()==="{"&&this._input.peek(1)==="}"&&(ie+="{}",this._input.next(),this._input.next())),this._create_token(U.WORD,ie)}this._input.back()}else if(J==="<"&&this._is_first_token()){if(de=this.__patterns.html_comment_start.read(),de){for(;this._input.hasNext()&&!this._input.testChar(O.newline);)de+=this._input.next();return te=!0,this._create_token(U.COMMENT,de)}}else if(te&&J==="-"&&(de=this.__patterns.html_comment_end.read(),de))return te=!1,this._create_token(U.COMMENT,de);return null},z.prototype._read_comment=function(J){var de=null;if(J==="/"){var ie="";if(this._input.peek(1)==="*"){ie=this.__patterns.block_comment.read();var A=$.get_directives(ie);A&&A.ignore==="start"&&(ie+=$.readIgnored(this._input)),ie=ie.replace(O.allLineBreaks,`
`),de=this._create_token(U.BLOCK_COMMENT,ie),de.directives=A}else this._input.peek(1)==="/"&&(ie=this.__patterns.comment.read(),de=this._create_token(U.COMMENT,ie))}return de},z.prototype._read_string=function(J){if(J==="`"||J==="'"||J==='"'){var de=this._input.next();return this.has_char_escapes=!1,J==="`"?de+=this._read_string_recursive("`",!0,"${"):de+=this._read_string_recursive(J),this.has_char_escapes&&this._options.unescape_strings&&(de=X(de)),this._input.peek()===J&&(de+=this._input.next()),de=de.replace(O.allLineBreaks,`
`),this._create_token(U.STRING,de)}return null},z.prototype._allow_regexp_or_xml=function(J){return J.type===U.RESERVED&&j(J.text,["return","case","throw","else","do","typeof","yield"])||J.type===U.END_EXPR&&J.text===")"&&J.opened.previous.type===U.RESERVED&&j(J.opened.previous.text,["if","while","for"])||j(J.type,[U.COMMENT,U.START_EXPR,U.START_BLOCK,U.START,U.END_BLOCK,U.OPERATOR,U.EQUALS,U.EOF,U.SEMICOLON,U.COMMA])},z.prototype._read_regexp=function(J,de){if(J==="/"&&this._allow_regexp_or_xml(de)){for(var ie=this._input.next(),A=!1,L=!1;this._input.hasNext()&&(A||L||this._input.peek()!==J)&&!this._input.testChar(O.newline);)ie+=this._input.peek(),A?A=!1:(A=this._input.peek()==="\\",this._input.peek()==="["?L=!0:this._input.peek()==="]"&&(L=!1)),this._input.next();return this._input.peek()===J&&(ie+=this._input.next(),ie+=this._input.read(O.identifier)),this._create_token(U.STRING,ie)}return null},z.prototype._read_xml=function(J,de){if(this._options.e4x&&J==="<"&&this._allow_regexp_or_xml(de)){var ie="",A=this.__patterns.xml.read_match();if(A){for(var L=A[2].replace(/^{\s+/,"{").replace(/\s+}$/,"}"),V=L.indexOf("{")===0,pe=0;A;){var ze=!!A[1],at=A[2],Ot=!!A[A.length-1]||at.slice(0,8)==="![CDATA[";if(!Ot&&(at===L||V&&at.replace(/^{\s+/,"{").replace(/\s+}$/,"}"))&&(ze?--pe:++pe),ie+=A[0],pe<=0)break;A=this.__patterns.xml.read_match()}return A||(ie+=this._input.match(/[\s\S]*/g)[0]),ie=ie.replace(O.allLineBreaks,`
`),this._create_token(U.STRING,ie)}}return null};function X(J){for(var de="",ie=0,A=new I(J),L=null;A.hasNext();)if(L=A.match(/([\s]|[^\\]|\\\\)+/g),L&&(de+=L[0]),A.peek()==="\\"){if(A.next(),A.peek()==="x")L=A.match(/x([0-9A-Fa-f]{2})/g);else if(A.peek()==="u")L=A.match(/u([0-9A-Fa-f]{4})/g),L||(L=A.match(/u\{([0-9A-Fa-f]+)\}/g));else{de+="\\",A.hasNext()&&(de+=A.next());continue}if(!L||(ie=parseInt(L[1],16),ie>126&&ie<=255&&L[0].indexOf("x")===0))return J;ie>=0&&ie<32||ie>1114111?de+="\\"+L[0]:ie===34||ie===39||ie===92?de+="\\"+String.fromCharCode(ie):de+=String.fromCharCode(ie)}return de}z.prototype._read_string_recursive=function(J,de,ie){var A,L;J==="'"?L=this.__patterns.single_quote:J==='"'?L=this.__patterns.double_quote:J==="`"?L=this.__patterns.template_text:J==="}"&&(L=this.__patterns.template_expression);for(var V=L.read(),pe="";this._input.hasNext();){if(pe=this._input.next(),pe===J||!de&&O.newline.test(pe)){this._input.back();break}else pe==="\\"&&this._input.hasNext()?(A=this._input.peek(),A==="x"||A==="u"?this.has_char_escapes=!0:A==="\r"&&this._input.peek(1)===`
`&&this._input.next(),pe+=this._input.next()):ie&&(ie==="${"&&pe==="$"&&this._input.peek()==="{"&&(pe+=this._input.next()),ie===pe&&(J==="`"?pe+=this._read_string_recursive("}",de,"`"):pe+=this._read_string_recursive("`",de,"${"),this._input.hasNext()&&(pe+=this._input.next())));pe+=L.read(),V+=pe}return V},P.exports.Tokenizer=z,P.exports.TOKEN=U,P.exports.positionable_operators=Se.slice(),P.exports.line_starters=We.slice()},function(P){var d=RegExp.prototype.hasOwnProperty("sticky");function ne(I){this.__input=I||"",this.__input_length=this.__input.length,this.__position=0}ne.prototype.restart=function(){this.__position=0},ne.prototype.back=function(){this.__position>0&&(this.__position-=1)},ne.prototype.hasNext=function(){return this.__position<this.__input_length},ne.prototype.next=function(){var I=null;return this.hasNext()&&(I=this.__input.charAt(this.__position),this.__position+=1),I},ne.prototype.peek=function(I){var k=null;return I=I||0,I+=this.__position,I>=0&&I<this.__input_length&&(k=this.__input.charAt(I)),k},ne.prototype.__match=function(I,k){I.lastIndex=k;var T=I.exec(this.__input);return T&&!(d&&I.sticky)&&T.index!==k&&(T=null),T},ne.prototype.test=function(I,k){return k=k||0,k+=this.__position,k>=0&&k<this.__input_length?!!this.__match(I,k):!1},ne.prototype.testChar=function(I,k){var T=this.peek(k);return I.lastIndex=0,T!==null&&I.test(T)},ne.prototype.match=function(I){var k=this.__match(I,this.__position);return k?this.__position+=k[0].length:k=null,k},ne.prototype.read=function(I,k,T){var M="",O;return I&&(O=this.match(I),O&&(M+=O[0])),k&&(O||!I)&&(M+=this.readUntil(k,T)),M},ne.prototype.readUntil=function(I,k){var T="",M=this.__position;I.lastIndex=this.__position;var O=I.exec(this.__input);return O?(M=O.index,k&&(M+=O[0].length)):M=this.__input_length,T=this.__input.substring(this.__position,M),this.__position=M,T},ne.prototype.readUntilAfter=function(I){return this.readUntil(I,!0)},ne.prototype.get_regexp=function(I,k){var T=null,M="g";return k&&d&&(M="y"),typeof I=="string"&&I!==""?T=new RegExp(I,M):I&&(T=new RegExp(I.source,M)),T},ne.prototype.get_literal_regexp=function(I){return RegExp(I.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"))},ne.prototype.peekUntilAfter=function(I){var k=this.__position,T=this.readUntilAfter(I);return this.__position=k,T},ne.prototype.lookBack=function(I){var k=this.__position-1;return k>=I.length&&this.__input.substring(k-I.length,k).toLowerCase()===I},P.exports.InputScanner=ne},function(P,d,ne){var I=ne(8).InputScanner,k=ne(3).Token,T=ne(10).TokenStream,M=ne(11).WhitespacePattern,O={START:"TK_START",RAW:"TK_RAW",EOF:"TK_EOF"},Y=function(H,j){this._input=new I(H),this._options=j||{},this.__tokens=null,this._patterns={},this._patterns.whitespace=new M(this._input)};Y.prototype.tokenize=function(){this._input.restart(),this.__tokens=new T,this._reset();for(var H,j=new k(O.START,""),U=null,$=[],G=new T;j.type!==O.EOF;){for(H=this._get_next_token(j,U);this._is_comment(H);)G.add(H),H=this._get_next_token(j,U);G.isEmpty()||(H.comments_before=G,G=new T),H.parent=U,this._is_opening(H)?($.push(U),U=H):U&&this._is_closing(H,U)&&(H.opened=U,U.closed=H,U=$.pop(),H.parent=U),H.previous=j,j.next=H,this.__tokens.add(H),j=H}return this.__tokens},Y.prototype._is_first_token=function(){return this.__tokens.isEmpty()},Y.prototype._reset=function(){},Y.prototype._get_next_token=function(H,j){this._readWhitespace();var U=this._input.read(/.+/g);return U?this._create_token(O.RAW,U):this._create_token(O.EOF,"")},Y.prototype._is_comment=function(H){return!1},Y.prototype._is_opening=function(H){return!1},Y.prototype._is_closing=function(H,j){return!1},Y.prototype._create_token=function(H,j){var U=new k(H,j,this._patterns.whitespace.newline_count,this._patterns.whitespace.whitespace_before_token);return U},Y.prototype._readWhitespace=function(){return this._patterns.whitespace.read()},P.exports.Tokenizer=Y,P.exports.TOKEN=O},function(P){function d(ne){this.__tokens=[],this.__tokens_length=this.__tokens.length,this.__position=0,this.__parent_token=ne}d.prototype.restart=function(){this.__position=0},d.prototype.isEmpty=function(){return this.__tokens_length===0},d.prototype.hasNext=function(){return this.__position<this.__tokens_length},d.prototype.next=function(){var ne=null;return this.hasNext()&&(ne=this.__tokens[this.__position],this.__position+=1),ne},d.prototype.peek=function(ne){var I=null;return ne=ne||0,ne+=this.__position,ne>=0&&ne<this.__tokens_length&&(I=this.__tokens[ne]),I},d.prototype.add=function(ne){this.__parent_token&&(ne.parent=this.__parent_token),this.__tokens.push(ne),this.__tokens_length+=1},P.exports.TokenStream=d},function(P,d,ne){var I=ne(12).Pattern;function k(T,M){I.call(this,T,M),M?this._line_regexp=this._input.get_regexp(M._line_regexp):this.__set_whitespace_patterns("",""),this.newline_count=0,this.whitespace_before_token=""}k.prototype=new I,k.prototype.__set_whitespace_patterns=function(T,M){T+="\\t ",M+="\\n\\r",this._match_pattern=this._input.get_regexp("["+T+M+"]+",!0),this._newline_regexp=this._input.get_regexp("\\r\\n|["+M+"]")},k.prototype.read=function(){this.newline_count=0,this.whitespace_before_token="";var T=this._input.read(this._match_pattern);if(T===" ")this.whitespace_before_token=" ";else if(T){var M=this.__split(this._newline_regexp,T);this.newline_count=M.length-1,this.whitespace_before_token=M[this.newline_count]}return T},k.prototype.matching=function(T,M){var O=this._create();return O.__set_whitespace_patterns(T,M),O._update(),O},k.prototype._create=function(){return new k(this._input,this)},k.prototype.__split=function(T,M){T.lastIndex=0;for(var O=0,Y=[],H=T.exec(M);H;)Y.push(M.substring(O,H.index)),O=H.index+H[0].length,H=T.exec(M);return O<M.length?Y.push(M.substring(O,M.length)):Y.push(""),Y},P.exports.WhitespacePattern=k},function(P){function d(ne,I){this._input=ne,this._starting_pattern=null,this._match_pattern=null,this._until_pattern=null,this._until_after=!1,I&&(this._starting_pattern=this._input.get_regexp(I._starting_pattern,!0),this._match_pattern=this._input.get_regexp(I._match_pattern,!0),this._until_pattern=this._input.get_regexp(I._until_pattern),this._until_after=I._until_after)}d.prototype.read=function(){var ne=this._input.read(this._starting_pattern);return(!this._starting_pattern||ne)&&(ne+=this._input.read(this._match_pattern,this._until_pattern,this._until_after)),ne},d.prototype.read_match=function(){return this._input.match(this._match_pattern)},d.prototype.until_after=function(ne){var I=this._create();return I._until_after=!0,I._until_pattern=this._input.get_regexp(ne),I._update(),I},d.prototype.until=function(ne){var I=this._create();return I._until_after=!1,I._until_pattern=this._input.get_regexp(ne),I._update(),I},d.prototype.starting_with=function(ne){var I=this._create();return I._starting_pattern=this._input.get_regexp(ne,!0),I._update(),I},d.prototype.matching=function(ne){var I=this._create();return I._match_pattern=this._input.get_regexp(ne,!0),I._update(),I},d.prototype._create=function(){return new d(this._input,this)},d.prototype._update=function(){},P.exports.Pattern=d},function(P){function d(ne,I){ne=typeof ne=="string"?ne:ne.source,I=typeof I=="string"?I:I.source,this.__directives_block_pattern=new RegExp(ne+/ beautify( \w+[:]\w+)+ /.source+I,"g"),this.__directive_pattern=/ (\w+)[:](\w+)/g,this.__directives_end_ignore_pattern=new RegExp(ne+/\sbeautify\signore:end\s/.source+I,"g")}d.prototype.get_directives=function(ne){if(!ne.match(this.__directives_block_pattern))return null;var I={};this.__directive_pattern.lastIndex=0;for(var k=this.__directive_pattern.exec(ne);k;)I[k[1]]=k[2],k=this.__directive_pattern.exec(ne);return I},d.prototype.readIgnored=function(ne){return ne.readUntilAfter(this.__directives_end_ignore_pattern)},P.exports.Directives=d},function(P,d,ne){var I=ne(12).Pattern,k={django:!1,erb:!1,handlebars:!1,php:!1,smarty:!1,angular:!1};function T(M,O){I.call(this,M,O),this.__template_pattern=null,this._disabled=Object.assign({},k),this._excluded=Object.assign({},k),O&&(this.__template_pattern=this._input.get_regexp(O.__template_pattern),this._excluded=Object.assign(this._excluded,O._excluded),this._disabled=Object.assign(this._disabled,O._disabled));var Y=new I(M);this.__patterns={handlebars_comment:Y.starting_with(/{{!--/).until_after(/--}}/),handlebars_unescaped:Y.starting_with(/{{{/).until_after(/}}}/),handlebars:Y.starting_with(/{{/).until_after(/}}/),php:Y.starting_with(/<\?(?:[= ]|php)/).until_after(/\?>/),erb:Y.starting_with(/<%[^%]/).until_after(/[^%]%>/),django:Y.starting_with(/{%/).until_after(/%}/),django_value:Y.starting_with(/{{/).until_after(/}}/),django_comment:Y.starting_with(/{#/).until_after(/#}/),smarty:Y.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),smarty_comment:Y.starting_with(/{\*/).until_after(/\*}/),smarty_literal:Y.starting_with(/{literal}/).until_after(/{\/literal}/)}}T.prototype=new I,T.prototype._create=function(){return new T(this._input,this)},T.prototype._update=function(){this.__set_templated_pattern()},T.prototype.disable=function(M){var O=this._create();return O._disabled[M]=!0,O._update(),O},T.prototype.read_options=function(M){var O=this._create();for(var Y in k)O._disabled[Y]=M.templating.indexOf(Y)===-1;return O._update(),O},T.prototype.exclude=function(M){var O=this._create();return O._excluded[M]=!0,O._update(),O},T.prototype.read=function(){var M="";this._match_pattern?M=this._input.read(this._starting_pattern):M=this._input.read(this._starting_pattern,this.__template_pattern);for(var O=this._read_template();O;)this._match_pattern?O+=this._input.read(this._match_pattern):O+=this._input.readUntil(this.__template_pattern),M+=O,O=this._read_template();return this._until_after&&(M+=this._input.readUntilAfter(this._until_pattern)),M},T.prototype.__set_templated_pattern=function(){var M=[];this._disabled.php||M.push(this.__patterns.php._starting_pattern.source),this._disabled.handlebars||M.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.angular||M.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.erb||M.push(this.__patterns.erb._starting_pattern.source),this._disabled.django||(M.push(this.__patterns.django._starting_pattern.source),M.push(this.__patterns.django_value._starting_pattern.source),M.push(this.__patterns.django_comment._starting_pattern.source)),this._disabled.smarty||M.push(this.__patterns.smarty._starting_pattern.source),this._until_pattern&&M.push(this._until_pattern.source),this.__template_pattern=this._input.get_regexp("(?:"+M.join("|")+")")},T.prototype._read_template=function(){var M="",O=this._input.peek();if(O==="<"){var Y=this._input.peek(1);!this._disabled.php&&!this._excluded.php&&Y==="?"&&(M=M||this.__patterns.php.read()),!this._disabled.erb&&!this._excluded.erb&&Y==="%"&&(M=M||this.__patterns.erb.read())}else O==="{"&&(!this._disabled.handlebars&&!this._excluded.handlebars&&(M=M||this.__patterns.handlebars_comment.read(),M=M||this.__patterns.handlebars_unescaped.read(),M=M||this.__patterns.handlebars.read()),this._disabled.django||(!this._excluded.django&&!this._excluded.handlebars&&(M=M||this.__patterns.django_value.read()),this._excluded.django||(M=M||this.__patterns.django_comment.read(),M=M||this.__patterns.django.read())),this._disabled.smarty||this._disabled.django&&this._disabled.handlebars&&(M=M||this.__patterns.smarty_comment.read(),M=M||this.__patterns.smarty_literal.read(),M=M||this.__patterns.smarty.read()));return M},P.exports.TemplatablePattern=T}],q={};function S(P){var d=q[P];if(d!==void 0)return d.exports;var ne=q[P]={exports:{}};return ge[P](ne,ne.exports,S),ne.exports}var Te=S(0);De=Te})();var qe=De;oe=[],ce=function(){return{js_beautify:qe}}.apply(Rt,oe),ce!==void 0&&(Li.exports=ce)})()},32834:function(Li){(function(Rt,oe){Li.exports=oe()})(this,function(){"use strict";function Rt(Le,ye){for(var we=0;we<ye.length;we++){var K=ye[we];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(Le,K.key,K)}}function oe(Le,ye,we){return ye&&Rt(Le.prototype,ye),we&&Rt(Le,we),Le}function ce(Le,ye){if(Le){if(typeof Le=="string")return De(Le,ye);var we=Object.prototype.toString.call(Le).slice(8,-1);if(we==="Object"&&Le.constructor&&(we=Le.constructor.name),we==="Map"||we==="Set")return Array.from(Le);if(we==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(we))return De(Le,ye)}}function De(Le,ye){(ye==null||ye>Le.length)&&(ye=Le.length);for(var we=0,K=new Array(ye);we<ye;we++)K[we]=Le[we];return K}function qe(Le,ye){var we=typeof Symbol!="undefined"&&Le[Symbol.iterator]||Le["@@iterator"];if(we)return(we=we.call(Le)).next.bind(we);if(Array.isArray(Le)||(we=ce(Le))||ye&&Le&&typeof Le.length=="number"){we&&(Le=we);var K=0;return function(){return K>=Le.length?{done:!0}:{done:!1,value:Le[K++]}}}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 ge={exports:{}};function q(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}function S(Le){ge.exports.defaults=Le}ge.exports={defaults:q(),getDefaults:q,changeDefaults:S};var Te=/[&<>"']/,P=/[&<>"']/g,d=/[<>"']|&(?!#?\w+;)/,ne=/[<>"']|&(?!#?\w+;)/g,I={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},k=function(ye){return I[ye]};function T(Le,ye){if(ye){if(Te.test(Le))return Le.replace(P,k)}else if(d.test(Le))return Le.replace(ne,k);return Le}var M=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function O(Le){return Le.replace(M,function(ye,we){return we=we.toLowerCase(),we==="colon"?":":we.charAt(0)==="#"?we.charAt(1)==="x"?String.fromCharCode(parseInt(we.substring(2),16)):String.fromCharCode(+we.substring(1)):""})}var Y=/(^|[^\[])\^/g;function H(Le,ye){Le=Le.source||Le,ye=ye||"";var we={replace:function(W,ae){return ae=ae.source||ae,ae=ae.replace(Y,"$1"),Le=Le.replace(W,ae),we},getRegex:function(){return new RegExp(Le,ye)}};return we}var j=/[^\w:]/g,U=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function $(Le,ye,we){if(Le){var K;try{K=decodeURIComponent(O(we)).replace(j,"").toLowerCase()}catch(W){return null}if(K.indexOf("javascript:")===0||K.indexOf("vbscript:")===0||K.indexOf("data:")===0)return null}ye&&!U.test(we)&&(we=re(ye,we));try{we=encodeURI(we).replace(/%25/g,"%")}catch(W){return null}return we}var G={},he=/^[^:]+:\/*[^/]*$/,be=/^([^:]+:)[\s\S]*$/,Se=/^([^:]+:\/*[^/]*)[\s\S]*$/;function re(Le,ye){G[" "+Le]||(he.test(Le)?G[" "+Le]=Le+"/":G[" "+Le]=Dt(Le,"/",!0)),Le=G[" "+Le];var we=Le.indexOf(":")===-1;return ye.substring(0,2)==="//"?we?ye:Le.replace(be,"$1")+ye:ye.charAt(0)==="/"?we?ye:Le.replace(Se,"$1")+ye:Le+ye}var Oe={exec:function(){}};function We(Le){for(var ye=1,we,K;ye<arguments.length;ye++){we=arguments[ye];for(K in we)Object.prototype.hasOwnProperty.call(we,K)&&(Le[K]=we[K])}return Le}function Be(Le,ye){var we=Le.replace(/\|/g,function(ae,fe,_e){for(var st=!1,ot=fe;--ot>=0&&_e[ot]==="\\";)st=!st;return st?"|":" |"}),K=we.split(/ \|/),W=0;if(K.length>ye)K.splice(ye);else for(;K.length<ye;)K.push("");for(;W<K.length;W++)K[W]=K[W].trim().replace(/\\\|/g,"|");return K}function Dt(Le,ye,we){var K=Le.length;if(K===0)return"";for(var W=0;W<K;){var ae=Le.charAt(K-W-1);if(ae===ye&&!we)W++;else if(ae!==ye&&we)W++;else break}return Le.substr(0,K-W)}function te(Le,ye){if(Le.indexOf(ye[1])===-1)return-1;for(var we=Le.length,K=0,W=0;W<we;W++)if(Le[W]==="\\")W++;else if(Le[W]===ye[0])K++;else if(Le[W]===ye[1]&&(K--,K<0))return W;return-1}function z(Le){Le&&Le.sanitize&&!Le.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")}function X(Le,ye){if(ye<1)return"";for(var we="";ye>1;)ye&1&&(we+=Le),ye>>=1,Le+=Le;return we+Le}var J={escape:T,unescape:O,edit:H,cleanUrl:$,resolveUrl:re,noopTest:Oe,merge:We,splitCells:Be,rtrim:Dt,findClosingBracket:te,checkSanitizeDeprecation:z,repeatString:X},de=ge.exports.defaults,ie=J.rtrim,A=J.splitCells,L=J.escape,V=J.findClosingBracket;function pe(Le,ye,we){var K=ye.href,W=ye.title?L(ye.title):null,ae=Le[1].replace(/\\([\[\]])/g,"$1");return Le[0].charAt(0)!=="!"?{type:"link",raw:we,href:K,title:W,text:ae}:{type:"image",raw:we,href:K,title:W,text:L(ae)}}function ze(Le,ye){var we=Le.match(/^(\s+)(?:```)/);if(we===null)return ye;var K=we[1];return ye.split(`
`).map(function(W){var ae=W.match(/^\s+/);if(ae===null)return W;var fe=ae[0];return fe.length>=K.length?W.slice(K.length):W}).join(`
`)}var at=function(){function Le(we){this.options=we||de}var ye=Le.prototype;return ye.space=function(K){var W=this.rules.block.newline.exec(K);if(W)return W[0].length>1?{type:"space",raw:W[0]}:{raw:`
`}},ye.code=function(K){var W=this.rules.block.code.exec(K);if(W){var ae=W[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:W[0],codeBlockStyle:"indented",text:this.options.pedantic?ae:ie(ae,`
`)}}},ye.fences=function(K){var W=this.rules.block.fences.exec(K);if(W){var ae=W[0],fe=ze(ae,W[3]||"");return{type:"code",raw:ae,lang:W[2]?W[2].trim():W[2],text:fe}}},ye.heading=function(K){var W=this.rules.block.heading.exec(K);if(W){var ae=W[2].trim();if(/#$/.test(ae)){var fe=ie(ae,"#");(this.options.pedantic||!fe||/ $/.test(fe))&&(ae=fe.trim())}return{type:"heading",raw:W[0],depth:W[1].length,text:ae}}},ye.nptable=function(K){var W=this.rules.block.nptable.exec(K);if(W){var ae={type:"table",header:A(W[1].replace(/^ *| *\| *$/g,"")),align:W[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:W[3]?W[3].replace(/\n$/,"").split(`
`):[],raw:W[0]};if(ae.header.length===ae.align.length){var fe=ae.align.length,_e;for(_e=0;_e<fe;_e++)/^ *-+: *$/.test(ae.align[_e])?ae.align[_e]="right":/^ *:-+: *$/.test(ae.align[_e])?ae.align[_e]="center":/^ *:-+ *$/.test(ae.align[_e])?ae.align[_e]="left":ae.align[_e]=null;for(fe=ae.cells.length,_e=0;_e<fe;_e++)ae.cells[_e]=A(ae.cells[_e],ae.header.length);return ae}}},ye.hr=function(K){var W=this.rules.block.hr.exec(K);if(W)return{type:"hr",raw:W[0]}},ye.blockquote=function(K){var W=this.rules.block.blockquote.exec(K);if(W){var ae=W[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:W[0],text:ae}}},ye.list=function(K){var W=this.rules.block.list.exec(K);if(W){var ae=W[0],fe=W[2],_e=fe.length>1,st={type:"list",raw:ae,ordered:_e,start:_e?+fe.slice(0,-1):"",loose:!1,items:[]},ot=W[0].match(this.rules.block.item),xt=!1,Ut,ti,di,Qt,kt,oi,Di,ki,Bi,pi=ot.length;di=this.rules.block.listItemStart.exec(ot[0]);for(var mi=0;mi<pi;mi++){if(Ut=ot[mi],ae=Ut,this.options.pedantic||(Bi=Ut.match(new RegExp("\\n\\s*\\n {0,"+(di[0].length-1)+"}\\S")),Bi&&(kt=Ut.length-Bi.index+ot.slice(mi+1).join(`
`).length,st.raw=st.raw.substring(0,st.raw.length-kt),Ut=Ut.substring(0,Bi.index),ae=Ut,pi=mi+1)),mi!==pi-1){if(Qt=this.rules.block.listItemStart.exec(ot[mi+1]),this.options.pedantic?Qt[1].length>di[1].length:Qt[1].length>=di[0].length||Qt[1].length>3){ot.splice(mi,2,ot[mi]+(!this.options.pedantic&&Qt[1].length<di[0].length&&!ot[mi].match(/\n$/)?"":`
`)+ot[mi+1]),mi--,pi--;continue}else(!this.options.pedantic||this.options.smartLists?Qt[2][Qt[2].length-1]!==fe[fe.length-1]:_e===(Qt[2].length===1))&&(kt=ot.slice(mi+1).join(`
`).length,st.raw=st.raw.substring(0,st.raw.length-kt),mi=pi-1);di=Qt}ti=Ut.length,Ut=Ut.replace(/^ *([*+-]|\d+[.)]) ?/,""),~Ut.indexOf(`
`)&&(ti-=Ut.length,Ut=this.options.pedantic?Ut.replace(/^ {1,4}/gm,""):Ut.replace(new RegExp("^ {1,"+ti+"}","gm"),"")),Ut=ie(Ut,`
`),mi!==pi-1&&(ae=ae+`
`),oi=xt||/\n\n(?!\s*$)/.test(ae),mi!==pi-1&&(xt=ae.slice(-2)===`
`,oi||(oi=xt)),oi&&(st.loose=!0),this.options.gfm&&(Di=/^\[[ xX]\] /.test(Ut),ki=void 0,Di&&(ki=Ut[1]!==" ",Ut=Ut.replace(/^\[[ xX]\] +/,""))),st.items.push({type:"list_item",raw:ae,task:Di,checked:ki,loose:oi,text:Ut})}return st}},ye.html=function(K){var W=this.rules.block.html.exec(K);if(W)return{type:this.options.sanitize?"paragraph":"html",raw:W[0],pre:!this.options.sanitizer&&(W[1]==="pre"||W[1]==="script"||W[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(W[0]):L(W[0]):W[0]}},ye.def=function(K){var W=this.rules.block.def.exec(K);if(W){W[3]&&(W[3]=W[3].substring(1,W[3].length-1));var ae=W[1].toLowerCase().replace(/\s+/g," ");return{type:"def",tag:ae,raw:W[0],href:W[2],title:W[3]}}},ye.table=function(K){var W=this.rules.block.table.exec(K);if(W){var ae={type:"table",header:A(W[1].replace(/^ *| *\| *$/g,"")),align:W[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:W[3]?W[3].replace(/\n$/,"").split(`
`):[]};if(ae.header.length===ae.align.length){ae.raw=W[0];var fe=ae.align.length,_e;for(_e=0;_e<fe;_e++)/^ *-+: *$/.test(ae.align[_e])?ae.align[_e]="right":/^ *:-+: *$/.test(ae.align[_e])?ae.align[_e]="center":/^ *:-+ *$/.test(ae.align[_e])?ae.align[_e]="left":ae.align[_e]=null;for(fe=ae.cells.length,_e=0;_e<fe;_e++)ae.cells[_e]=A(ae.cells[_e].replace(/^ *\| *| *\| *$/g,""),ae.header.length);return ae}}},ye.lheading=function(K){var W=this.rules.block.lheading.exec(K);if(W)return{type:"heading",raw:W[0],depth:W[2].charAt(0)==="="?1:2,text:W[1]}},ye.paragraph=function(K){var W=this.rules.block.paragraph.exec(K);if(W)return{type:"paragraph",raw:W[0],text:W[1].charAt(W[1].length-1)===`
`?W[1].slice(0,-1):W[1]}},ye.text=function(K){var W=this.rules.block.text.exec(K);if(W)return{type:"text",raw:W[0],text:W[0]}},ye.escape=function(K){var W=this.rules.inline.escape.exec(K);if(W)return{type:"escape",raw:W[0],text:L(W[1])}},ye.tag=function(K,W,ae){var fe=this.rules.inline.tag.exec(K);if(fe)return!W&&/^<a /i.test(fe[0])?W=!0:W&&/^<\/a>/i.test(fe[0])&&(W=!1),!ae&&/^<(pre|code|kbd|script)(\s|>)/i.test(fe[0])?ae=!0:ae&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(fe[0])&&(ae=!1),{type:this.options.sanitize?"text":"html",raw:fe[0],inLink:W,inRawBlock:ae,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(fe[0]):L(fe[0]):fe[0]}},ye.link=function(K){var W=this.rules.inline.link.exec(K);if(W){var ae=W[2].trim();if(!this.options.pedantic&&/^</.test(ae)){if(!/>$/.test(ae))return;var fe=ie(ae.slice(0,-1),"\\");if((ae.length-fe.length)%2===0)return}else{var _e=V(W[2],"()");if(_e>-1){var st=W[0].indexOf("!")===0?5:4,ot=st+W[1].length+_e;W[2]=W[2].substring(0,_e),W[0]=W[0].substring(0,ot).trim(),W[3]=""}}var xt=W[2],Ut="";if(this.options.pedantic){var ti=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(xt);ti&&(xt=ti[1],Ut=ti[3])}else Ut=W[3]?W[3].slice(1,-1):"";return xt=xt.trim(),/^</.test(xt)&&(this.options.pedantic&&!/>$/.test(ae)?xt=xt.slice(1):xt=xt.slice(1,-1)),pe(W,{href:xt&&xt.replace(this.rules.inline._escapes,"$1"),title:Ut&&Ut.replace(this.rules.inline._escapes,"$1")},W[0])}},ye.reflink=function(K,W){var ae;if((ae=this.rules.inline.reflink.exec(K))||(ae=this.rules.inline.nolink.exec(K))){var fe=(ae[2]||ae[1]).replace(/\s+/g," ");if(fe=W[fe.toLowerCase()],!fe||!fe.href){var _e=ae[0].charAt(0);return{type:"text",raw:_e,text:_e}}return pe(ae,fe,ae[0])}},ye.emStrong=function(K,W,ae){ae===void 0&&(ae="");var fe=this.rules.inline.emStrong.lDelim.exec(K);if(fe&&!(fe[3]&&ae.match(/(?:[0-9A-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u0660-\u0669\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0966-\u096F\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09E6-\u09F1\u09F4-\u09F9\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AE6-\u0AEF\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F\u0B71-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0BE6-\u0BF2\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C66-\u0C6F\u0C78-\u0C7E\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CE6-\u0CEF\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D58-\u0D61\u0D66-\u0D78\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DE6-\u0DEF\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F20-\u0F33\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F-\u1049\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u1090-\u1099\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\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A16\u1A20-\u1A54\u1A80-\u1A89\u1A90-\u1A99\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B50-\u1B59\u1B83-\u1BA0\u1BAE-\u1BE5\u1C00-\u1C23\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\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\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2CFD\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-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA830-\uA835\uA840-\uA873\uA882-\uA8B3\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA900-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF-\uA9D9\uA9E0-\uA9E4\uA9E6-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uABF0-\uABF9\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\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDE80-\uDE9C\uDEA0-\uDED0\uDEE1-\uDEFB\uDF00-\uDF23\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC58-\uDC76\uDC79-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD20-\uDD39\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE40-\uDE48\uDE60-\uDE7E\uDE80-\uDE9F\uDEC0-\uDEC7\uDEC9-\uDEE4\uDEEB-\uDEEF\uDF00-\uDF35\uDF40-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD23\uDD30-\uDD39\uDE60-\uDE7E\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF27\uDF30-\uDF45\uDF51-\uDF54\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC52-\uDC6F\uDC83-\uDCAF\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD03-\uDD26\uDD36-\uDD3F\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDD0-\uDDDA\uDDDC\uDDE1-\uDDF4\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDEF0-\uDEF9\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC50-\uDC59\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE50-\uDE59\uDE80-\uDEAA\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF30-\uDF3B]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF2\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE96\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD40-\uDD49\uDD4E\uDEC0-\uDEEB\uDEF0-\uDEF9]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCCF\uDD00-\uDD43\uDD4B\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/))){var _e=fe[1]||fe[2]||"";if(!_e||_e&&(ae===""||this.rules.inline.punctuation.exec(ae))){var st=fe[0].length-1,ot,xt,Ut=st,ti=0,di=fe[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(di.lastIndex=0,W=W.slice(-1*K.length+st);(fe=di.exec(W))!=null;)if(ot=fe[1]||fe[2]||fe[3]||fe[4]||fe[5]||fe[6],!!ot){if(xt=ot.length,fe[3]||fe[4]){Ut+=xt;continue}else if((fe[5]||fe[6])&&st%3&&!((st+xt)%3)){ti+=xt;continue}if(Ut-=xt,!(Ut>0))return xt=Math.min(xt,xt+Ut+ti),Math.min(st,xt)%2?{type:"em",raw:K.slice(0,st+fe.index+xt+1),text:K.slice(1,st+fe.index+xt)}:{type:"strong",raw:K.slice(0,st+fe.index+xt+1),text:K.slice(2,st+fe.index+xt-1)}}}}},ye.codespan=function(K){var W=this.rules.inline.code.exec(K);if(W){var ae=W[2].replace(/\n/g," "),fe=/[^ ]/.test(ae),_e=/^ /.test(ae)&&/ $/.test(ae);return fe&&_e&&(ae=ae.substring(1,ae.length-1)),ae=L(ae,!0),{type:"codespan",raw:W[0],text:ae}}},ye.br=function(K){var W=this.rules.inline.br.exec(K);if(W)return{type:"br",raw:W[0]}},ye.del=function(K){var W=this.rules.inline.del.exec(K);if(W)return{type:"del",raw:W[0],text:W[2]}},ye.autolink=function(K,W){var ae=this.rules.inline.autolink.exec(K);if(ae){var fe,_e;return ae[2]==="@"?(fe=L(this.options.mangle?W(ae[1]):ae[1]),_e="mailto:"+fe):(fe=L(ae[1]),_e=fe),{type:"link",raw:ae[0],text:fe,href:_e,tokens:[{type:"text",raw:fe,text:fe}]}}},ye.url=function(K,W){var ae;if(ae=this.rules.inline.url.exec(K)){var fe,_e;if(ae[2]==="@")fe=L(this.options.mangle?W(ae[0]):ae[0]),_e="mailto:"+fe;else{var st;do st=ae[0],ae[0]=this.rules.inline._backpedal.exec(ae[0])[0];while(st!==ae[0]);fe=L(ae[0]),ae[1]==="www."?_e="http://"+fe:_e=fe}return{type:"link",raw:ae[0],text:fe,href:_e,tokens:[{type:"text",raw:fe,text:fe}]}}},ye.inlineText=function(K,W,ae){var fe=this.rules.inline.text.exec(K);if(fe){var _e;return W?_e=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(fe[0]):L(fe[0]):fe[0]:_e=L(this.options.smartypants?ae(fe[0]):fe[0]),{type:"text",raw:fe[0],text:_e}}},Le}(),Ot=J.noopTest,Ce=J.edit,jt=J.merge,Mt={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\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})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?! {0,3}bull )\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 *)+\\n|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:Ot,table:Ot,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html| +\n)[^\n]+)*)/,text:/^[^\n]+/};Mt._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,Mt._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Mt.def=Ce(Mt.def).replace("label",Mt._label).replace("title",Mt._title).getRegex(),Mt.bullet=/(?:[*+-]|\d{1,9}[.)])/,Mt.item=/^( *)(bull) ?[^\n]*(?:\n(?! *bull ?)[^\n]*)*/,Mt.item=Ce(Mt.item,"gm").replace(/bull/g,Mt.bullet).getRegex(),Mt.listItemStart=Ce(/^( *)(bull) */).replace("bull",Mt.bullet).getRegex(),Mt.list=Ce(Mt.list).replace(/bull/g,Mt.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Mt.def.source+")").getRegex(),Mt._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",Mt._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Mt.html=Ce(Mt.html,"i").replace("comment",Mt._comment).replace("tag",Mt._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Mt.paragraph=Ce(Mt._paragraph).replace("hr",Mt.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",Mt._tag).getRegex(),Mt.blockquote=Ce(Mt.blockquote).replace("paragraph",Mt.paragraph).getRegex(),Mt.normal=jt({},Mt),Mt.gfm=jt({},Mt.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n {0,3}([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n {0,3}\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),Mt.gfm.nptable=Ce(Mt.gfm.nptable).replace("hr",Mt.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",Mt._tag).getRegex(),Mt.gfm.table=Ce(Mt.gfm.table).replace("hr",Mt.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",Mt._tag).getRegex(),Mt.pedantic=jt({},Mt.normal,{html:Ce(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Mt._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+|$)/,fences:Ot,paragraph:Ce(Mt.normal._paragraph).replace("hr",Mt.hr).replace("heading",` *#{1,6} *[^
]`).replace("lheading",Mt.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var dt={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ot,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(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/\_\_[^_*]*?\*[^_*]*?\_\_|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,rDelimUnd:/\*\*[^_*]*?\_[^_*]*?\*\*|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Ot,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};dt._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",dt.punctuation=Ce(dt.punctuation).replace(/punctuation/g,dt._punctuation).getRegex(),dt.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,dt.escapedEmSt=/\\\*|\\_/g,dt._comment=Ce(Mt._comment).replace("(?:-->|$)","-->").getRegex(),dt.emStrong.lDelim=Ce(dt.emStrong.lDelim).replace(/punct/g,dt._punctuation).getRegex(),dt.emStrong.rDelimAst=Ce(dt.emStrong.rDelimAst,"g").replace(/punct/g,dt._punctuation).getRegex(),dt.emStrong.rDelimUnd=Ce(dt.emStrong.rDelimUnd,"g").replace(/punct/g,dt._punctuation).getRegex(),dt._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,dt._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,dt._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])?)+(?![-_])/,dt.autolink=Ce(dt.autolink).replace("scheme",dt._scheme).replace("email",dt._email).getRegex(),dt._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,dt.tag=Ce(dt.tag).replace("comment",dt._comment).replace("attribute",dt._attribute).getRegex(),dt._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,dt._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,dt._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,dt.link=Ce(dt.link).replace("label",dt._label).replace("href",dt._href).replace("title",dt._title).getRegex(),dt.reflink=Ce(dt.reflink).replace("label",dt._label).getRegex(),dt.reflinkSearch=Ce(dt.reflinkSearch,"g").replace("reflink",dt.reflink).replace("nolink",dt.nolink).getRegex(),dt.normal=jt({},dt),dt.pedantic=jt({},dt.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:Ce(/^!?\[(label)\]\((.*?)\)/).replace("label",dt._label).getRegex(),reflink:Ce(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",dt._label).getRegex()}),dt.gfm=jt({},dt.normal,{escape:Ce(dt.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~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/}),dt.gfm.url=Ce(dt.gfm.url,"i").replace("email",dt.gfm._extended_email).getRegex(),dt.breaks=jt({},dt.gfm,{br:Ce(dt.br).replace("{2,}","*").getRegex(),text:Ce(dt.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var Ti={block:Mt,inline:dt},fi=at,Yi=ge.exports.defaults,Kt=Ti.block,ln=Ti.inline,Ne=J.repeatString;function Ge(Le){return Le.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 ve(Le){var ye="",we,K,W=Le.length;for(we=0;we<W;we++)K=Le.charCodeAt(we),Math.random()>.5&&(K="x"+K.toString(16)),ye+="&#"+K+";";return ye}var nt=function(){function Le(we){this.tokens=[],this.tokens.links=Object.create(null),this.options=we||Yi,this.options.tokenizer=this.options.tokenizer||new fi,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var K={block:Kt.normal,inline:ln.normal};this.options.pedantic?(K.block=Kt.pedantic,K.inline=ln.pedantic):this.options.gfm&&(K.block=Kt.gfm,this.options.breaks?K.inline=ln.breaks:K.inline=ln.gfm),this.tokenizer.rules=K}Le.lex=function(K,W){var ae=new Le(W);return ae.lex(K)},Le.lexInline=function(K,W){var ae=new Le(W);return ae.inlineTokens(K)};var ye=Le.prototype;return ye.lex=function(K){return K=K.replace(/\r\n|\r/g,`
`).replace(/\t/g," "),this.blockTokens(K,this.tokens,!0),this.inline(this.tokens),this.tokens},ye.blockTokens=function(K,W,ae){W===void 0&&(W=[]),ae===void 0&&(ae=!0),this.options.pedantic&&(K=K.replace(/^ +$/gm,""));for(var fe,_e,st,ot;K;){if(fe=this.tokenizer.space(K)){K=K.substring(fe.raw.length),fe.type&&W.push(fe);continue}if(fe=this.tokenizer.code(K)){K=K.substring(fe.raw.length),ot=W[W.length-1],ot&&ot.type==="paragraph"?(ot.raw+=`
`+fe.raw,ot.text+=`
`+fe.text):W.push(fe);continue}if(fe=this.tokenizer.fences(K)){K=K.substring(fe.raw.length),W.push(fe);continue}if(fe=this.tokenizer.heading(K)){K=K.substring(fe.raw.length),W.push(fe);continue}if(fe=this.tokenizer.nptable(K)){K=K.substring(fe.raw.length),W.push(fe);continue}if(fe=this.tokenizer.hr(K)){K=K.substring(fe.raw.length),W.push(fe);continue}if(fe=this.tokenizer.blockquote(K)){K=K.substring(fe.raw.length),fe.tokens=this.blockTokens(fe.text,[],ae),W.push(fe);continue}if(fe=this.tokenizer.list(K)){for(K=K.substring(fe.raw.length),st=fe.items.length,_e=0;_e<st;_e++)fe.items[_e].tokens=this.blockTokens(fe.items[_e].text,[],!1);W.push(fe);continue}if(fe=this.tokenizer.html(K)){K=K.substring(fe.raw.length),W.push(fe);continue}if(ae&&(fe=this.tokenizer.def(K))){K=K.substring(fe.raw.length),this.tokens.links[fe.tag]||(this.tokens.links[fe.tag]={href:fe.href,title:fe.title});continue}if(fe=this.tokenizer.table(K)){K=K.substring(fe.raw.length),W.push(fe);continue}if(fe=this.tokenizer.lheading(K)){K=K.substring(fe.raw.length),W.push(fe);continue}if(ae&&(fe=this.tokenizer.paragraph(K))){K=K.substring(fe.raw.length),W.push(fe);continue}if(fe=this.tokenizer.text(K)){K=K.substring(fe.raw.length),ot=W[W.length-1],ot&&ot.type==="text"?(ot.raw+=`
`+fe.raw,ot.text+=`
`+fe.text):W.push(fe);continue}if(K){var xt="Infinite loop on byte: "+K.charCodeAt(0);if(this.options.silent){console.error(xt);break}else throw new Error(xt)}}return W},ye.inline=function(K){var W,ae,fe,_e,st,ot,xt=K.length;for(W=0;W<xt;W++)switch(ot=K[W],ot.type){case"paragraph":case"text":case"heading":{ot.tokens=[],this.inlineTokens(ot.text,ot.tokens);break}case"table":{for(ot.tokens={header:[],cells:[]},_e=ot.header.length,ae=0;ae<_e;ae++)ot.tokens.header[ae]=[],this.inlineTokens(ot.header[ae],ot.tokens.header[ae]);for(_e=ot.cells.length,ae=0;ae<_e;ae++)for(st=ot.cells[ae],ot.tokens.cells[ae]=[],fe=0;fe<st.length;fe++)ot.tokens.cells[ae][fe]=[],this.inlineTokens(st[fe],ot.tokens.cells[ae][fe]);break}case"blockquote":{this.inline(ot.tokens);break}case"list":{for(_e=ot.items.length,ae=0;ae<_e;ae++)this.inline(ot.items[ae].tokens);break}}return K},ye.inlineTokens=function(K,W,ae,fe){W===void 0&&(W=[]),ae===void 0&&(ae=!1),fe===void 0&&(fe=!1);var _e,st,ot=K,xt,Ut,ti;if(this.tokens.links){var di=Object.keys(this.tokens.links);if(di.length>0)for(;(xt=this.tokenizer.rules.inline.reflinkSearch.exec(ot))!=null;)di.includes(xt[0].slice(xt[0].lastIndexOf("[")+1,-1))&&(ot=ot.slice(0,xt.index)+"["+Ne("a",xt[0].length-2)+"]"+ot.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(xt=this.tokenizer.rules.inline.blockSkip.exec(ot))!=null;)ot=ot.slice(0,xt.index)+"["+Ne("a",xt[0].length-2)+"]"+ot.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(xt=this.tokenizer.rules.inline.escapedEmSt.exec(ot))!=null;)ot=ot.slice(0,xt.index)+"++"+ot.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);for(;K;){if(Ut||(ti=""),Ut=!1,_e=this.tokenizer.escape(K)){K=K.substring(_e.raw.length),W.push(_e);continue}if(_e=this.tokenizer.tag(K,ae,fe)){K=K.substring(_e.raw.length),ae=_e.inLink,fe=_e.inRawBlock;var Qt=W[W.length-1];Qt&&_e.type==="text"&&Qt.type==="text"?(Qt.raw+=_e.raw,Qt.text+=_e.text):W.push(_e);continue}if(_e=this.tokenizer.link(K)){K=K.substring(_e.raw.length),_e.type==="link"&&(_e.tokens=this.inlineTokens(_e.text,[],!0,fe)),W.push(_e);continue}if(_e=this.tokenizer.reflink(K,this.tokens.links)){K=K.substring(_e.raw.length);var kt=W[W.length-1];_e.type==="link"?(_e.tokens=this.inlineTokens(_e.text,[],!0,fe),W.push(_e)):kt&&_e.type==="text"&&kt.type==="text"?(kt.raw+=_e.raw,kt.text+=_e.text):W.push(_e);continue}if(_e=this.tokenizer.emStrong(K,ot,ti)){K=K.substring(_e.raw.length),_e.tokens=this.inlineTokens(_e.text,[],ae,fe),W.push(_e);continue}if(_e=this.tokenizer.codespan(K)){K=K.substring(_e.raw.length),W.push(_e);continue}if(_e=this.tokenizer.br(K)){K=K.substring(_e.raw.length),W.push(_e);continue}if(_e=this.tokenizer.del(K)){K=K.substring(_e.raw.length),_e.tokens=this.inlineTokens(_e.text,[],ae,fe),W.push(_e);continue}if(_e=this.tokenizer.autolink(K,ve)){K=K.substring(_e.raw.length),W.push(_e);continue}if(!ae&&(_e=this.tokenizer.url(K,ve))){K=K.substring(_e.raw.length),W.push(_e);continue}if(_e=this.tokenizer.inlineText(K,fe,Ge)){K=K.substring(_e.raw.length),_e.raw.slice(-1)!=="_"&&(ti=_e.raw.slice(-1)),Ut=!0,st=W[W.length-1],st&&st.type==="text"?(st.raw+=_e.raw,st.text+=_e.text):W.push(_e);continue}if(K){var oi="Infinite loop on byte: "+K.charCodeAt(0);if(this.options.silent){console.error(oi);break}else throw new Error(oi)}}return W},oe(Le,null,[{key:"rules",get:function(){return{block:Kt,inline:ln}}}]),Le}(),_t=ge.exports.defaults,lt=J.cleanUrl,ee=J.escape,xe=function(){function Le(we){this.options=we||_t}var ye=Le.prototype;return ye.code=function(K,W,ae){var fe=(W||"").match(/\S*/)[0];if(this.options.highlight){var _e=this.options.highlight(K,fe);_e!=null&&_e!==K&&(ae=!0,K=_e)}return K=K.replace(/\n$/,"")+`
`,fe?'<pre><code class="'+this.options.langPrefix+ee(fe,!0)+'">'+(ae?K:ee(K,!0))+`</code></pre>
`:"<pre><code>"+(ae?K:ee(K,!0))+`</code></pre>
`},ye.blockquote=function(K){return`<blockquote>
`+K+`</blockquote>
`},ye.html=function(K){return K},ye.heading=function(K,W,ae,fe){return this.options.headerIds?"<h"+W+' id="'+this.options.headerPrefix+fe.slug(ae)+'">'+K+"</h"+W+`>
`:"<h"+W+">"+K+"</h"+W+`>
`},ye.hr=function(){return this.options.xhtml?`<hr/>
`:`<hr>
`},ye.list=function(K,W,ae){var fe=W?"ol":"ul",_e=W&&ae!==1?' start="'+ae+'"':"";return"<"+fe+_e+`>
`+K+"</"+fe+`>
`},ye.listitem=function(K){return"<li>"+K+`</li>
`},ye.checkbox=function(K){return"<input "+(K?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},ye.paragraph=function(K){return"<p>"+K+`</p>
`},ye.table=function(K,W){return W&&(W="<tbody>"+W+"</tbody>"),`<table>
<thead>
`+K+`</thead>
`+W+`</table>
`},ye.tablerow=function(K){return`<tr>
`+K+`</tr>
`},ye.tablecell=function(K,W){var ae=W.header?"th":"td",fe=W.align?"<"+ae+' align="'+W.align+'">':"<"+ae+">";return fe+K+"</"+ae+`>
`},ye.strong=function(K){return"<strong>"+K+"</strong>"},ye.em=function(K){return"<em>"+K+"</em>"},ye.codespan=function(K){return"<code>"+K+"</code>"},ye.br=function(){return this.options.xhtml?"<br/>":"<br>"},ye.del=function(K){return"<del>"+K+"</del>"},ye.link=function(K,W,ae){if(K=lt(this.options.sanitize,this.options.baseUrl,K),K===null)return ae;var fe='<a href="'+ee(K)+'"';return W&&(fe+=' title="'+W+'"'),fe+=">"+ae+"</a>",fe},ye.image=function(K,W,ae){if(K=lt(this.options.sanitize,this.options.baseUrl,K),K===null)return ae;var fe='<img src="'+K+'" alt="'+ae+'"';return W&&(fe+=' title="'+W+'"'),fe+=this.options.xhtml?"/>":">",fe},ye.text=function(K){return K},Le}(),$e=function(){function Le(){}var ye=Le.prototype;return ye.strong=function(K){return K},ye.em=function(K){return K},ye.codespan=function(K){return K},ye.del=function(K){return K},ye.html=function(K){return K},ye.text=function(K){return K},ye.link=function(K,W,ae){return""+ae},ye.image=function(K,W,ae){return""+ae},ye.br=function(){return""},Le}(),Ye=function(){function Le(){this.seen={}}var ye=Le.prototype;return ye.serialize=function(K){return K.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")},ye.getNextSafeSlug=function(K,W){var ae=K,fe=0;if(this.seen.hasOwnProperty(ae)){fe=this.seen[K];do fe++,ae=K+"-"+fe;while(this.seen.hasOwnProperty(ae))}return W||(this.seen[K]=fe,this.seen[ae]=0),ae},ye.slug=function(K,W){W===void 0&&(W={});var ae=this.serialize(K);return this.getNextSafeSlug(ae,W.dryrun)},Le}(),rt=xe,gt=$e,Yt=Ye,pt=ge.exports.defaults,ke=J.unescape,ht=function(){function Le(we){this.options=we||pt,this.options.renderer=this.options.renderer||new rt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new gt,this.slugger=new Yt}Le.parse=function(K,W){var ae=new Le(W);return ae.parse(K)},Le.parseInline=function(K,W){var ae=new Le(W);return ae.parseInline(K)};var ye=Le.prototype;return ye.parse=function(K,W){W===void 0&&(W=!0);var ae="",fe,_e,st,ot,xt,Ut,ti,di,Qt,kt,oi,Di,ki,Bi,pi,mi,Xi,nn,un=K.length;for(fe=0;fe<un;fe++)switch(kt=K[fe],kt.type){case"space":continue;case"hr":{ae+=this.renderer.hr();continue}case"heading":{ae+=this.renderer.heading(this.parseInline(kt.tokens),kt.depth,ke(this.parseInline(kt.tokens,this.textRenderer)),this.slugger);continue}case"code":{ae+=this.renderer.code(kt.text,kt.lang,kt.escaped);continue}case"table":{for(di="",ti="",ot=kt.header.length,_e=0;_e<ot;_e++)ti+=this.renderer.tablecell(this.parseInline(kt.tokens.header[_e]),{header:!0,align:kt.align[_e]});for(di+=this.renderer.tablerow(ti),Qt="",ot=kt.cells.length,_e=0;_e<ot;_e++){for(Ut=kt.tokens.cells[_e],ti="",xt=Ut.length,st=0;st<xt;st++)ti+=this.renderer.tablecell(this.parseInline(Ut[st]),{header:!1,align:kt.align[st]});Qt+=this.renderer.tablerow(ti)}ae+=this.renderer.table(di,Qt);continue}case"blockquote":{Qt=this.parse(kt.tokens),ae+=this.renderer.blockquote(Qt);continue}case"list":{for(oi=kt.ordered,Di=kt.start,ki=kt.loose,ot=kt.items.length,Qt="",_e=0;_e<ot;_e++)pi=kt.items[_e],mi=pi.checked,Xi=pi.task,Bi="",pi.task&&(nn=this.renderer.checkbox(mi),ki?pi.tokens.length>0&&pi.tokens[0].type==="text"?(pi.tokens[0].text=nn+" "+pi.tokens[0].text,pi.tokens[0].tokens&&pi.tokens[0].tokens.length>0&&pi.tokens[0].tokens[0].type==="text"&&(pi.tokens[0].tokens[0].text=nn+" "+pi.tokens[0].tokens[0].text)):pi.tokens.unshift({type:"text",text:nn}):Bi+=nn),Bi+=this.parse(pi.tokens,ki),Qt+=this.renderer.listitem(Bi,Xi,mi);ae+=this.renderer.list(Qt,oi,Di);continue}case"html":{ae+=this.renderer.html(kt.text);continue}case"paragraph":{ae+=this.renderer.paragraph(this.parseInline(kt.tokens));continue}case"text":{for(Qt=kt.tokens?this.parseInline(kt.tokens):kt.text;fe+1<un&&K[fe+1].type==="text";)kt=K[++fe],Qt+=`
`+(kt.tokens?this.parseInline(kt.tokens):kt.text);ae+=W?this.renderer.paragraph(Qt):Qt;continue}default:{var Ji='Token with "'+kt.type+'" type was not found.';if(this.options.silent){console.error(Ji);return}else throw new Error(Ji)}}return ae},ye.parseInline=function(K,W){W=W||this.renderer;var ae="",fe,_e,st=K.length;for(fe=0;fe<st;fe++)switch(_e=K[fe],_e.type){case"escape":{ae+=W.text(_e.text);break}case"html":{ae+=W.html(_e.text);break}case"link":{ae+=W.link(_e.href,_e.title,this.parseInline(_e.tokens,W));break}case"image":{ae+=W.image(_e.href,_e.title,_e.text);break}case"strong":{ae+=W.strong(this.parseInline(_e.tokens,W));break}case"em":{ae+=W.em(this.parseInline(_e.tokens,W));break}case"codespan":{ae+=W.codespan(_e.text);break}case"br":{ae+=W.br();break}case"del":{ae+=W.del(this.parseInline(_e.tokens,W));break}case"text":{ae+=W.text(_e.text);break}default:{var ot='Token with "'+_e.type+'" type was not found.';if(this.options.silent){console.error(ot);return}else throw new Error(ot)}}return ae},Le}(),Gt=nt,zt=ht,Ae=at,Me=xe,tt=$e,ft=Ye,je=J.merge,At=J.checkSanitizeDeprecation,Lt=J.escape,vt=ge.exports.getDefaults,Pt=ge.exports.changeDefaults,Ht=ge.exports.defaults;function Xe(Le,ye,we){if(typeof Le=="undefined"||Le===null)throw new Error("marked(): input parameter is undefined or null");if(typeof Le!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(Le)+", string expected");if(typeof ye=="function"&&(we=ye,ye=null),ye=je({},Xe.defaults,ye||{}),At(ye),we){var K=ye.highlight,W;try{W=Gt.lex(Le,ye)}catch(st){return we(st)}var ae=function(ot){var xt;if(!ot)try{ye.walkTokens&&Xe.walkTokens(W,ye.walkTokens),xt=zt.parse(W,ye)}catch(Ut){ot=Ut}return ye.highlight=K,ot?we(ot):we(null,xt)};if(!K||K.length<3||(delete ye.highlight,!W.length))return ae();var fe=0;Xe.walkTokens(W,function(st){st.type==="code"&&(fe++,setTimeout(function(){K(st.text,st.lang,function(ot,xt){if(ot)return ae(ot);xt!=null&&xt!==st.text&&(st.text=xt,st.escaped=!0),fe--,fe===0&&ae()})},0))}),fe===0&&ae();return}try{var _e=Gt.lex(Le,ye);return ye.walkTokens&&Xe.walkTokens(_e,ye.walkTokens),zt.parse(_e,ye)}catch(st){if(st.message+=`
Please report this to https://github.com/markedjs/marked.`,ye.silent)return"<p>An error occurred:</p><pre>"+Lt(st.message+"",!0)+"</pre>";throw st}}Xe.options=Xe.setOptions=function(Le){return je(Xe.defaults,Le),Pt(Xe.defaults),Xe},Xe.getDefaults=vt,Xe.defaults=Ht,Xe.use=function(Le){var ye=je({},Le);if(Le.renderer&&function(){var K=Xe.defaults.renderer||new Me,W=function(_e){var st=K[_e];K[_e]=function(){for(var ot=arguments.length,xt=new Array(ot),Ut=0;Ut<ot;Ut++)xt[Ut]=arguments[Ut];var ti=Le.renderer[_e].apply(K,xt);return ti===!1&&(ti=st.apply(K,xt)),ti}};for(var ae in Le.renderer)W(ae);ye.renderer=K}(),Le.tokenizer&&function(){var K=Xe.defaults.tokenizer||new Ae,W=function(_e){var st=K[_e];K[_e]=function(){for(var ot=arguments.length,xt=new Array(ot),Ut=0;Ut<ot;Ut++)xt[Ut]=arguments[Ut];var ti=Le.tokenizer[_e].apply(K,xt);return ti===!1&&(ti=st.apply(K,xt)),ti}};for(var ae in Le.tokenizer)W(ae);ye.tokenizer=K}(),Le.walkTokens){var we=Xe.defaults.walkTokens;ye.walkTokens=function(K){Le.walkTokens(K),we&&we(K)}}Xe.setOptions(ye)},Xe.walkTokens=function(Le,ye){for(var we=qe(Le),K;!(K=we()).done;){var W=K.value;switch(ye(W),W.type){case"table":{for(var ae=qe(W.tokens.header),fe;!(fe=ae()).done;){var _e=fe.value;Xe.walkTokens(_e,ye)}for(var st=qe(W.tokens.cells),ot;!(ot=st()).done;)for(var xt=ot.value,Ut=qe(xt),ti;!(ti=Ut()).done;){var di=ti.value;Xe.walkTokens(di,ye)}break}case"list":{Xe.walkTokens(W.items,ye);break}default:W.tokens&&Xe.walkTokens(W.tokens,ye)}}},Xe.parseInline=function(Le,ye){if(typeof Le=="undefined"||Le===null)throw new Error("marked.parseInline(): input parameter is undefined or null");if(typeof Le!="string")throw new Error("marked.parseInline(): input parameter is of type "+Object.prototype.toString.call(Le)+", string expected");ye=je({},Xe.defaults,ye||{}),At(ye);try{var we=Gt.lexInline(Le,ye);return ye.walkTokens&&Xe.walkTokens(we,ye.walkTokens),zt.parseInline(we,ye)}catch(K){if(K.message+=`
Please report this to https://github.com/markedjs/marked.`,ye.silent)return"<p>An error occurred:</p><pre>"+Lt(K.message+"",!0)+"</pre>";throw K}},Xe.Parser=zt,Xe.parser=zt.parse,Xe.Renderer=Me,Xe.TextRenderer=tt,Xe.Lexer=Gt,Xe.lexer=Gt.lex,Xe.Tokenizer=Ae,Xe.Slugger=ft,Xe.parse=Xe;var Ft=Xe;return Ft})},11690:function(Li){const Rt=/[&<>"']/,oe=/[&<>"']/g,ce=/[<>"']|&(?!#?\w+;)/,De=/[<>"']|&(?!#?\w+;)/g,qe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ge=re=>qe[re];function q(re,Oe){if(Oe){if(Rt.test(re))return re.replace(oe,ge)}else if(ce.test(re))return re.replace(De,ge);return re}const S=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Te(re){return re.replace(S,(Oe,We)=>(We=We.toLowerCase(),We==="colon"?":":We.charAt(0)==="#"?We.charAt(1)==="x"?String.fromCharCode(parseInt(We.substring(2),16)):String.fromCharCode(+We.substring(1)):""))}const P=/(^|[^\[])\^/g;function d(re,Oe){re=re.source||re,Oe=Oe||"";const We={replace:(Be,Dt)=>(Dt=Dt.source||Dt,Dt=Dt.replace(P,"$1"),re=re.replace(Be,Dt),We),getRegex:()=>new RegExp(re,Oe)};return We}const ne=/[^\w:]/g,I=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function k(re,Oe,We){if(re){let Be;try{Be=decodeURIComponent(Te(We)).replace(ne,"").toLowerCase()}catch(Dt){return null}if(Be.indexOf("javascript:")===0||Be.indexOf("vbscript:")===0||Be.indexOf("data:")===0)return null}Oe&&!I.test(We)&&(We=H(Oe,We));try{We=encodeURI(We).replace(/%25/g,"%")}catch(Be){return null}return We}const T={},M=/^[^:]+:\/*[^/]*$/,O=/^([^:]+:)[\s\S]*$/,Y=/^([^:]+:\/*[^/]*)[\s\S]*$/;function H(re,Oe){T[" "+re]||(M.test(re)?T[" "+re]=re+"/":T[" "+re]=G(re,"/",!0)),re=T[" "+re];const We=re.indexOf(":")===-1;return Oe.substring(0,2)==="//"?We?Oe:re.replace(O,"$1")+Oe:Oe.charAt(0)==="/"?We?Oe:re.replace(Y,"$1")+Oe:re+Oe}const j={exec:function(){}};function U(re){let Oe=1,We,Be;for(;Oe<arguments.length;Oe++){We=arguments[Oe];for(Be in We)Object.prototype.hasOwnProperty.call(We,Be)&&(re[Be]=We[Be])}return re}function $(re,Oe){const We=re.replace(/\|/g,(te,z,X)=>{let J=!1,de=z;for(;--de>=0&&X[de]==="\\";)J=!J;return J?"|":" |"}),Be=We.split(/ \|/);let Dt=0;if(Be.length>Oe)Be.splice(Oe);else for(;Be.length<Oe;)Be.push("");for(;Dt<Be.length;Dt++)Be[Dt]=Be[Dt].trim().replace(/\\\|/g,"|");return Be}function G(re,Oe,We){const Be=re.length;if(Be===0)return"";let Dt=0;for(;Dt<Be;){const te=re.charAt(Be-Dt-1);if(te===Oe&&!We)Dt++;else if(te!==Oe&&We)Dt++;else break}return re.substr(0,Be-Dt)}function he(re,Oe){if(re.indexOf(Oe[1])===-1)return-1;const We=re.length;let Be=0,Dt=0;for(;Dt<We;Dt++)if(re[Dt]==="\\")Dt++;else if(re[Dt]===Oe[0])Be++;else if(re[Dt]===Oe[1]&&(Be--,Be<0))return Dt;return-1}function be(re){re&&re.sanitize&&!re.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function Se(re,Oe){if(Oe<1)return"";let We="";for(;Oe>1;)Oe&1&&(We+=re),Oe>>=1,re+=re;return We+re}Li.exports={escape:q,unescape:Te,edit:d,cleanUrl:k,resolveUrl:H,noopTest:j,merge:U,splitCells:$,rtrim:G,findClosingBracket:he,checkSanitizeDeprecation:be,repeatString:Se}},75918:function(Li,Rt,oe){"use strict";oe.d(Rt,{Wi:function(){return S},Z0:function(){return Te},aU:function(){return q},eZ:function(){return d},wY:function(){return P}});var ce=oe(4348),De=oe(69323),qe=oe(13268),ge=function(ne,I,k,T){function M(O){return O instanceof k?O:new k(function(Y){Y(O)})}return new(k||(k=Promise))(function(O,Y){function H($){try{U(T.next($))}catch(G){Y(G)}}function j($){try{U(T.throw($))}catch(G){Y(G)}}function U($){$.done?O($.value):M($.value).then(H,j)}U((T=T.apply(ne,I||[])).next())})};class q extends De.JT{constructor(I,k="",T="",M=!0,O){super(),this._onDidChange=this._register(new ce.Q5),this.onDidChange=this._onDidChange.event,this._enabled=!0,this._id=I,this._label=k,this._cssClass=T,this._enabled=M,this._actionCallback=O}get id(){return this._id}get label(){return this._label}set label(I){this._setLabel(I)}_setLabel(I){this._label!==I&&(this._label=I,this._onDidChange.fire({label:I}))}get tooltip(){return this._tooltip||""}set tooltip(I){this._setTooltip(I)}_setTooltip(I){this._tooltip!==I&&(this._tooltip=I,this._onDidChange.fire({tooltip:I}))}get class(){return this._cssClass}set class(I){this._setClass(I)}_setClass(I){this._cssClass!==I&&(this._cssClass=I,this._onDidChange.fire({class:I}))}get enabled(){return this._enabled}set enabled(I){this._setEnabled(I)}_setEnabled(I){this._enabled!==I&&(this._enabled=I,this._onDidChange.fire({enabled:I}))}get checked(){return this._checked}set checked(I){this._setChecked(I)}_setChecked(I){this._checked!==I&&(this._checked=I,this._onDidChange.fire({checked:I}))}run(I,k){return ge(this,void 0,void 0,function*(){this._actionCallback&&(yield this._actionCallback(I))})}}class S extends De.JT{constructor(){super(...arguments),this._onBeforeRun=this._register(new ce.Q5),this.onBeforeRun=this._onBeforeRun.event,this._onDidRun=this._register(new ce.Q5),this.onDidRun=this._onDidRun.event}run(I,k){return ge(this,void 0,void 0,function*(){if(!I.enabled)return;this._onBeforeRun.fire({action:I});let T;try{yield this.runAction(I,k)}catch(M){T=M}this._onDidRun.fire({action:I,error:T})})}runAction(I,k){return ge(this,void 0,void 0,function*(){yield I.run(k)})}}class Te extends q{constructor(I){super(Te.ID,I,I?"separator text":"separator"),this.checked=!1,this.enabled=!1}}Te.ID="vs.actions.separator";class P{constructor(I,k,T,M){this.tooltip="",this.enabled=!0,this.checked=!1,this.id=I,this.label=k,this.class=M,this._actions=T}get actions(){return this._actions}dispose(){}run(){return ge(this,void 0,void 0,function*(){})}}class d extends q{constructor(){super(d.ID,qe.N("submenu.empty","(empty)"),void 0,!1)}}d.ID="vs.actions.empty"},76068:function(Li,Rt,oe){"use strict";oe.d(Rt,{ok:function(){return ce}});function ce(De,qe){if(!De)throw new Error(qe?`Assertion failed (${qe})`:"Assertion Failed")}},52615:function(Li,Rt,oe){"use strict";oe.d(Rt,{CM:function(){return q},JL:function(){return S},dT:function(){return P},fK:function(){return ge},lA:function(){return Te}});var ce=oe(4348);class De{constructor(){this._icons=new Map,this._onDidRegister=new ce.Q5}add(ne){const I=this._icons.get(ne.id);I?ne.description?I.description=ne.description:console.error(`Duplicate registration of codicon ${ne.id}`):(this._icons.set(ne.id,ne),this._onDidRegister.fire(ne))}get(ne){return this._icons.get(ne)}get all(){return this._icons.values()}get onDidRegister(){return this._onDidRegister.event}}const qe=new De,ge=qe;function q(d,ne){return new Te(d,ne)}function S(d){return d?d.replace(/\$\((.*?)\)/g,(ne,I)=>` ${I} `).trim():""}class Te{constructor(ne,I,k){this.id=ne,this.definition=I,this.description=k,qe.add(this)}get classNames(){return"codicon codicon-"+this.id}get classNamesArray(){return["codicon","codicon-"+this.id]}get cssSelector(){return".codicon.codicon-"+this.id}}var P;(function(d){d.iconNameSegment="[A-Za-z0-9]+",d.iconNameExpression="[A-Za-z0-9\\-]+",d.iconModifierExpression="~[A-Za-z]+";const ne=new RegExp(`^(${d.iconNameExpression})(${d.iconModifierExpression})?$`);function I(M){if(M instanceof Te)return["codicon","codicon-"+M.id];const O=ne.exec(M.id);if(!O)return I(Te.error);let[,Y,H]=O;const j=["codicon","codicon-"+Y];return H&&j.push("codicon-modifier-"+H.substr(1)),j}d.asClassNameArray=I;function k(M){return I(M).join(" ")}d.asClassName=k;function T(M){return"."+I(M).join(".")}d.asCSSSelector=T})(P||(P={})),function(d){d.add=new d("add",{fontCharacter:"\\ea60"}),d.plus=new d("plus",d.add.definition),d.gistNew=new d("gist-new",d.add.definition),d.repoCreate=new d("repo-create",d.add.definition),d.lightbulb=new d("lightbulb",{fontCharacter:"\\ea61"}),d.lightBulb=new d("light-bulb",{fontCharacter:"\\ea61"}),d.repo=new d("repo",{fontCharacter:"\\ea62"}),d.repoDelete=new d("repo-delete",{fontCharacter:"\\ea62"}),d.gistFork=new d("gist-fork",{fontCharacter:"\\ea63"}),d.repoForked=new d("repo-forked",{fontCharacter:"\\ea63"}),d.gitPullRequest=new d("git-pull-request",{fontCharacter:"\\ea64"}),d.gitPullRequestAbandoned=new d("git-pull-request-abandoned",{fontCharacter:"\\ea64"}),d.recordKeys=new d("record-keys",{fontCharacter:"\\ea65"}),d.keyboard=new d("keyboard",{fontCharacter:"\\ea65"}),d.tag=new d("tag",{fontCharacter:"\\ea66"}),d.tagAdd=new d("tag-add",{fontCharacter:"\\ea66"}),d.tagRemove=new d("tag-remove",{fontCharacter:"\\ea66"}),d.person=new d("person",{fontCharacter:"\\ea67"}),d.personFollow=new d("person-follow",{fontCharacter:"\\ea67"}),d.personOutline=new d("person-outline",{fontCharacter:"\\ea67"}),d.personFilled=new d("person-filled",{fontCharacter:"\\ea67"}),d.gitBranch=new d("git-branch",{fontCharacter:"\\ea68"}),d.gitBranchCreate=new d("git-branch-create",{fontCharacter:"\\ea68"}),d.gitBranchDelete=new d("git-branch-delete",{fontCharacter:"\\ea68"}),d.sourceControl=new d("source-control",{fontCharacter:"\\ea68"}),d.mirror=new d("mirror",{fontCharacter:"\\ea69"}),d.mirrorPublic=new d("mirror-public",{fontCharacter:"\\ea69"}),d.star=new d("star",{fontCharacter:"\\ea6a"}),d.starAdd=new d("star-add",{fontCharacter:"\\ea6a"}),d.starDelete=new d("star-delete",{fontCharacter:"\\ea6a"}),d.starEmpty=new d("star-empty",{fontCharacter:"\\ea6a"}),d.comment=new d("comment",{fontCharacter:"\\ea6b"}),d.commentAdd=new d("comment-add",{fontCharacter:"\\ea6b"}),d.alert=new d("alert",{fontCharacter:"\\ea6c"}),d.warning=new d("warning",{fontCharacter:"\\ea6c"}),d.search=new d("search",{fontCharacter:"\\ea6d"}),d.searchSave=new d("search-save",{fontCharacter:"\\ea6d"}),d.logOut=new d("log-out",{fontCharacter:"\\ea6e"}),d.signOut=new d("sign-out",{fontCharacter:"\\ea6e"}),d.logIn=new d("log-in",{fontCharacter:"\\ea6f"}),d.signIn=new d("sign-in",{fontCharacter:"\\ea6f"}),d.eye=new d("eye",{fontCharacter:"\\ea70"}),d.eyeUnwatch=new d("eye-unwatch",{fontCharacter:"\\ea70"}),d.eyeWatch=new d("eye-watch",{fontCharacter:"\\ea70"}),d.circleFilled=new d("circle-filled",{fontCharacter:"\\ea71"}),d.primitiveDot=new d("primitive-dot",{fontCharacter:"\\ea71"}),d.closeDirty=new d("close-dirty",{fontCharacter:"\\ea71"}),d.debugBreakpoint=new d("debug-breakpoint",{fontCharacter:"\\ea71"}),d.debugBreakpointDisabled=new d("debug-breakpoint-disabled",{fontCharacter:"\\ea71"}),d.debugHint=new d("debug-hint",{fontCharacter:"\\ea71"}),d.primitiveSquare=new d("primitive-square",{fontCharacter:"\\ea72"}),d.edit=new d("edit",{fontCharacter:"\\ea73"}),d.pencil=new d("pencil",{fontCharacter:"\\ea73"}),d.info=new d("info",{fontCharacter:"\\ea74"}),d.issueOpened=new d("issue-opened",{fontCharacter:"\\ea74"}),d.gistPrivate=new d("gist-private",{fontCharacter:"\\ea75"}),d.gitForkPrivate=new d("git-fork-private",{fontCharacter:"\\ea75"}),d.lock=new d("lock",{fontCharacter:"\\ea75"}),d.mirrorPrivate=new d("mirror-private",{fontCharacter:"\\ea75"}),d.close=new d("close",{fontCharacter:"\\ea76"}),d.removeClose=new d("remove-close",{fontCharacter:"\\ea76"}),d.x=new d("x",{fontCharacter:"\\ea76"}),d.repoSync=new d("repo-sync",{fontCharacter:"\\ea77"}),d.sync=new d("sync",{fontCharacter:"\\ea77"}),d.clone=new d("clone",{fontCharacter:"\\ea78"}),d.desktopDownload=new d("desktop-download",{fontCharacter:"\\ea78"}),d.beaker=new d("beaker",{fontCharacter:"\\ea79"}),d.microscope=new d("microscope",{fontCharacter:"\\ea79"}),d.vm=new d("vm",{fontCharacter:"\\ea7a"}),d.deviceDesktop=new d("device-desktop",{fontCharacter:"\\ea7a"}),d.file=new d("file",{fontCharacter:"\\ea7b"}),d.fileText=new d("file-text",{fontCharacter:"\\ea7b"}),d.more=new d("more",{fontCharacter:"\\ea7c"}),d.ellipsis=new d("ellipsis",{fontCharacter:"\\ea7c"}),d.kebabHorizontal=new d("kebab-horizontal",{fontCharacter:"\\ea7c"}),d.mailReply=new d("mail-reply",{fontCharacter:"\\ea7d"}),d.reply=new d("reply",{fontCharacter:"\\ea7d"}),d.organization=new d("organization",{fontCharacter:"\\ea7e"}),d.organizationFilled=new d("organization-filled",{fontCharacter:"\\ea7e"}),d.organizationOutline=new d("organization-outline",{fontCharacter:"\\ea7e"}),d.newFile=new d("new-file",{fontCharacter:"\\ea7f"}),d.fileAdd=new d("file-add",{fontCharacter:"\\ea7f"}),d.newFolder=new d("new-folder",{fontCharacter:"\\ea80"}),d.fileDirectoryCreate=new d("file-directory-create",{fontCharacter:"\\ea80"}),d.trash=new d("trash",{fontCharacter:"\\ea81"}),d.trashcan=new d("trashcan",{fontCharacter:"\\ea81"}),d.history=new d("history",{fontCharacter:"\\ea82"}),d.clock=new d("clock",{fontCharacter:"\\ea82"}),d.folder=new d("folder",{fontCharacter:"\\ea83"}),d.fileDirectory=new d("file-directory",{fontCharacter:"\\ea83"}),d.symbolFolder=new d("symbol-folder",{fontCharacter:"\\ea83"}),d.logoGithub=new d("logo-github",{fontCharacter:"\\ea84"}),d.markGithub=new d("mark-github",{fontCharacter:"\\ea84"}),d.github=new d("github",{fontCharacter:"\\ea84"}),d.terminal=new d("terminal",{fontCharacter:"\\ea85"}),d.console=new d("console",{fontCharacter:"\\ea85"}),d.repl=new d("repl",{fontCharacter:"\\ea85"}),d.zap=new d("zap",{fontCharacter:"\\ea86"}),d.symbolEvent=new d("symbol-event",{fontCharacter:"\\ea86"}),d.error=new d("error",{fontCharacter:"\\ea87"}),d.stop=new d("stop",{fontCharacter:"\\ea87"}),d.variable=new d("variable",{fontCharacter:"\\ea88"}),d.symbolVariable=new d("symbol-variable",{fontCharacter:"\\ea88"}),d.array=new d("array",{fontCharacter:"\\ea8a"}),d.symbolArray=new d("symbol-array",{fontCharacter:"\\ea8a"}),d.symbolModule=new d("symbol-module",{fontCharacter:"\\ea8b"}),d.symbolPackage=new d("symbol-package",{fontCharacter:"\\ea8b"}),d.symbolNamespace=new d("symbol-namespace",{fontCharacter:"\\ea8b"}),d.symbolObject=new d("symbol-object",{fontCharacter:"\\ea8b"}),d.symbolMethod=new d("symbol-method",{fontCharacter:"\\ea8c"}),d.symbolFunction=new d("symbol-function",{fontCharacter:"\\ea8c"}),d.symbolConstructor=new d("symbol-constructor",{fontCharacter:"\\ea8c"}),d.symbolBoolean=new d("symbol-boolean",{fontCharacter:"\\ea8f"}),d.symbolNull=new d("symbol-null",{fontCharacter:"\\ea8f"}),d.symbolNumeric=new d("symbol-numeric",{fontCharacter:"\\ea90"}),d.symbolNumber=new d("symbol-number",{fontCharacter:"\\ea90"}),d.symbolStructure=new d("symbol-structure",{fontCharacter:"\\ea91"}),d.symbolStruct=new d("symbol-struct",{fontCharacter:"\\ea91"}),d.symbolParameter=new d("symbol-parameter",{fontCharacter:"\\ea92"}),d.symbolTypeParameter=new d("symbol-type-parameter",{fontCharacter:"\\ea92"}),d.symbolKey=new d("symbol-key",{fontCharacter:"\\ea93"}),d.symbolText=new d("symbol-text",{fontCharacter:"\\ea93"}),d.symbolReference=new d("symbol-reference",{fontCharacter:"\\ea94"}),d.goToFile=new d("go-to-file",{fontCharacter:"\\ea94"}),d.symbolEnum=new d("symbol-enum",{fontCharacter:"\\ea95"}),d.symbolValue=new d("symbol-value",{fontCharacter:"\\ea95"}),d.symbolRuler=new d("symbol-ruler",{fontCharacter:"\\ea96"}),d.symbolUnit=new d("symbol-unit",{fontCharacter:"\\ea96"}),d.activateBreakpoints=new d("activate-breakpoints",{fontCharacter:"\\ea97"}),d.archive=new d("archive",{fontCharacter:"\\ea98"}),d.arrowBoth=new d("arrow-both",{fontCharacter:"\\ea99"}),d.arrowDown=new d("arrow-down",{fontCharacter:"\\ea9a"}),d.arrowLeft=new d("arrow-left",{fontCharacter:"\\ea9b"}),d.arrowRight=new d("arrow-right",{fontCharacter:"\\ea9c"}),d.arrowSmallDown=new d("arrow-small-down",{fontCharacter:"\\ea9d"}),d.arrowSmallLeft=new d("arrow-small-left",{fontCharacter:"\\ea9e"}),d.arrowSmallRight=new d("arrow-small-right",{fontCharacter:"\\ea9f"}),d.arrowSmallUp=new d("arrow-small-up",{fontCharacter:"\\eaa0"}),d.arrowUp=new d("arrow-up",{fontCharacter:"\\eaa1"}),d.bell=new d("bell",{fontCharacter:"\\eaa2"}),d.bold=new d("bold",{fontCharacter:"\\eaa3"}),d.book=new d("book",{fontCharacter:"\\eaa4"}),d.bookmark=new d("bookmark",{fontCharacter:"\\eaa5"}),d.debugBreakpointConditionalUnverified=new d("debug-breakpoint-conditional-unverified",{fontCharacter:"\\eaa6"}),d.debugBreakpointConditional=new d("debug-breakpoint-conditional",{fontCharacter:"\\eaa7"}),d.debugBreakpointConditionalDisabled=new d("debug-breakpoint-conditional-disabled",{fontCharacter:"\\eaa7"}),d.debugBreakpointDataUnverified=new d("debug-breakpoint-data-unverified",{fontCharacter:"\\eaa8"}),d.debugBreakpointData=new d("debug-breakpoint-data",{fontCharacter:"\\eaa9"}),d.debugBreakpointDataDisabled=new d("debug-breakpoint-data-disabled",{fontCharacter:"\\eaa9"}),d.debugBreakpointLogUnverified=new d("debug-breakpoint-log-unverified",{fontCharacter:"\\eaaa"}),d.debugBreakpointLog=new d("debug-breakpoint-log",{fontCharacter:"\\eaab"}),d.debugBreakpointLogDisabled=new d("debug-breakpoint-log-disabled",{fontCharacter:"\\eaab"}),d.briefcase=new d("briefcase",{fontCharacter:"\\eaac"}),d.broadcast=new d("broadcast",{fontCharacter:"\\eaad"}),d.browser=new d("browser",{fontCharacter:"\\eaae"}),d.bug=new d("bug",{fontCharacter:"\\eaaf"}),d.calendar=new d("calendar",{fontCharacter:"\\eab0"}),d.caseSensitive=new d("case-sensitive",{fontCharacter:"\\eab1"}),d.check=new d("check",{fontCharacter:"\\eab2"}),d.checklist=new d("checklist",{fontCharacter:"\\eab3"}),d.chevronDown=new d("chevron-down",{fontCharacter:"\\eab4"}),d.dropDownButton=new d("drop-down-button",d.chevronDown.definition),d.chevronLeft=new d("chevron-left",{fontCharacter:"\\eab5"}),d.chevronRight=new d("chevron-right",{fontCharacter:"\\eab6"}),d.chevronUp=new d("chevron-up",{fontCharacter:"\\eab7"}),d.chromeClose=new d("chrome-close",{fontCharacter:"\\eab8"}),d.chromeMaximize=new d("chrome-maximize",{fontCharacter:"\\eab9"}),d.chromeMinimize=new d("chrome-minimize",{fontCharacter:"\\eaba"}),d.chromeRestore=new d("chrome-restore",{fontCharacter:"\\eabb"}),d.circleOutline=new d("circle-outline",{fontCharacter:"\\eabc"}),d.debugBreakpointUnverified=new d("debug-breakpoint-unverified",{fontCharacter:"\\eabc"}),d.circleSlash=new d("circle-slash",{fontCharacter:"\\eabd"}),d.circuitBoard=new d("circuit-board",{fontCharacter:"\\eabe"}),d.clearAll=new d("clear-all",{fontCharacter:"\\eabf"}),d.clippy=new d("clippy",{fontCharacter:"\\eac0"}),d.closeAll=new d("close-all",{fontCharacter:"\\eac1"}),d.cloudDownload=new d("cloud-download",{fontCharacter:"\\eac2"}),d.cloudUpload=new d("cloud-upload",{fontCharacter:"\\eac3"}),d.code=new d("code",{fontCharacter:"\\eac4"}),d.collapseAll=new d("collapse-all",{fontCharacter:"\\eac5"}),d.colorMode=new d("color-mode",{fontCharacter:"\\eac6"}),d.commentDiscussion=new d("comment-discussion",{fontCharacter:"\\eac7"}),d.compareChanges=new d("compare-changes",{fontCharacter:"\\eafd"}),d.creditCard=new d("credit-card",{fontCharacter:"\\eac9"}),d.dash=new d("dash",{fontCharacter:"\\eacc"}),d.dashboard=new d("dashboard",{fontCharacter:"\\eacd"}),d.database=new d("database",{fontCharacter:"\\eace"}),d.debugContinue=new d("debug-continue",{fontCharacter:"\\eacf"}),d.debugDisconnect=new d("debug-disconnect",{fontCharacter:"\\ead0"}),d.debugPause=new d("debug-pause",{fontCharacter:"\\ead1"}),d.debugRestart=new d("debug-restart",{fontCharacter:"\\ead2"}),d.debugStart=new d("debug-start",{fontCharacter:"\\ead3"}),d.debugStepInto=new d("debug-step-into",{fontCharacter:"\\ead4"}),d.debugStepOut=new d("debug-step-out",{fontCharacter:"\\ead5"}),d.debugStepOver=new d("debug-step-over",{fontCharacter:"\\ead6"}),d.debugStop=new d("debug-stop",{fontCharacter:"\\ead7"}),d.debug=new d("debug",{fontCharacter:"\\ead8"}),d.deviceCameraVideo=new d("device-camera-video",{fontCharacter:"\\ead9"}),d.deviceCamera=new d("device-camera",{fontCharacter:"\\eada"}),d.deviceMobile=new d("device-mobile",{fontCharacter:"\\eadb"}),d.diffAdded=new d("diff-added",{fontCharacter:"\\eadc"}),d.diffIgnored=new d("diff-ignored",{fontCharacter:"\\eadd"}),d.diffModified=new d("diff-modified",{fontCharacter:"\\eade"}),d.diffRemoved=new d("diff-removed",{fontCharacter:"\\eadf"}),d.diffRenamed=new d("diff-renamed",{fontCharacter:"\\eae0"}),d.diff=new d("diff",{fontCharacter:"\\eae1"}),d.discard=new d("discard",{fontCharacter:"\\eae2"}),d.editorLayout=new d("editor-layout",{fontCharacter:"\\eae3"}),d.emptyWindow=new d("empty-window",{fontCharacter:"\\eae4"}),d.exclude=new d("exclude",{fontCharacter:"\\eae5"}),d.extensions=new d("extensions",{fontCharacter:"\\eae6"}),d.eyeClosed=new d("eye-closed",{fontCharacter:"\\eae7"}),d.fileBinary=new d("file-binary",{fontCharacter:"\\eae8"}),d.fileCode=new d("file-code",{fontCharacter:"\\eae9"}),d.fileMedia=new d("file-media",{fontCharacter:"\\eaea"}),d.filePdf=new d("file-pdf",{fontCharacter:"\\eaeb"}),d.fileSubmodule=new d("file-submodule",{fontCharacter:"\\eaec"}),d.fileSymlinkDirectory=new d("file-symlink-directory",{fontCharacter:"\\eaed"}),d.fileSymlinkFile=new d("file-symlink-file",{fontCharacter:"\\eaee"}),d.fileZip=new d("file-zip",{fontCharacter:"\\eaef"}),d.files=new d("files",{fontCharacter:"\\eaf0"}),d.filter=new d("filter",{fontCharacter:"\\eaf1"}),d.flame=new d("flame",{fontCharacter:"\\eaf2"}),d.foldDown=new d("fold-down",{fontCharacter:"\\eaf3"}),d.foldUp=new d("fold-up",{fontCharacter:"\\eaf4"}),d.fold=new d("fold",{fontCharacter:"\\eaf5"}),d.folderActive=new d("folder-active",{fontCharacter:"\\eaf6"}),d.folderOpened=new d("folder-opened",{fontCharacter:"\\eaf7"}),d.gear=new d("gear",{fontCharacter:"\\eaf8"}),d.gift=new d("gift",{fontCharacter:"\\eaf9"}),d.gistSecret=new d("gist-secret",{fontCharacter:"\\eafa"}),d.gist=new d("gist",{fontCharacter:"\\eafb"}),d.gitCommit=new d("git-commit",{fontCharacter:"\\eafc"}),d.gitCompare=new d("git-compare",{fontCharacter:"\\eafd"}),d.gitMerge=new d("git-merge",{fontCharacter:"\\eafe"}),d.githubAction=new d("github-action",{fontCharacter:"\\eaff"}),d.githubAlt=new d("github-alt",{fontCharacter:"\\eb00"}),d.globe=new d("globe",{fontCharacter:"\\eb01"}),d.grabber=new d("grabber",{fontCharacter:"\\eb02"}),d.graph=new d("graph",{fontCharacter:"\\eb03"}),d.gripper=new d("gripper",{fontCharacter:"\\eb04"}),d.heart=new d("heart",{fontCharacter:"\\eb05"}),d.home=new d("home",{fontCharacter:"\\eb06"}),d.horizontalRule=new d("horizontal-rule",{fontCharacter:"\\eb07"}),d.hubot=new d("hubot",{fontCharacter:"\\eb08"}),d.inbox=new d("inbox",{fontCharacter:"\\eb09"}),d.issueClosed=new d("issue-closed",{fontCharacter:"\\eba4"}),d.issueReopened=new d("issue-reopened",{fontCharacter:"\\eb0b"}),d.issues=new d("issues",{fontCharacter:"\\eb0c"}),d.italic=new d("italic",{fontCharacter:"\\eb0d"}),d.jersey=new d("jersey",{fontCharacter:"\\eb0e"}),d.json=new d("json",{fontCharacter:"\\eb0f"}),d.kebabVertical=new d("kebab-vertical",{fontCharacter:"\\eb10"}),d.key=new d("key",{fontCharacter:"\\eb11"}),d.law=new d("law",{fontCharacter:"\\eb12"}),d.lightbulbAutofix=new d("lightbulb-autofix",{fontCharacter:"\\eb13"}),d.linkExternal=new d("link-external",{fontCharacter:"\\eb14"}),d.link=new d("link",{fontCharacter:"\\eb15"}),d.listOrdered=new d("list-ordered",{fontCharacter:"\\eb16"}),d.listUnordered=new d("list-unordered",{fontCharacter:"\\eb17"}),d.liveShare=new d("live-share",{fontCharacter:"\\eb18"}),d.loading=new d("loading",{fontCharacter:"\\eb19"}),d.location=new d("location",{fontCharacter:"\\eb1a"}),d.mailRead=new d("mail-read",{fontCharacter:"\\eb1b"}),d.mail=new d("mail",{fontCharacter:"\\eb1c"}),d.markdown=new d("markdown",{fontCharacter:"\\eb1d"}),d.megaphone=new d("megaphone",{fontCharacter:"\\eb1e"}),d.mention=new d("mention",{fontCharacter:"\\eb1f"}),d.milestone=new d("milestone",{fontCharacter:"\\eb20"}),d.mortarBoard=new d("mortar-board",{fontCharacter:"\\eb21"}),d.move=new d("move",{fontCharacter:"\\eb22"}),d.multipleWindows=new d("multiple-windows",{fontCharacter:"\\eb23"}),d.mute=new d("mute",{fontCharacter:"\\eb24"}),d.noNewline=new d("no-newline",{fontCharacter:"\\eb25"}),d.note=new d("note",{fontCharacter:"\\eb26"}),d.octoface=new d("octoface",{fontCharacter:"\\eb27"}),d.openPreview=new d("open-preview",{fontCharacter:"\\eb28"}),d.package_=new d("package",{fontCharacter:"\\eb29"}),d.paintcan=new d("paintcan",{fontCharacter:"\\eb2a"}),d.pin=new d("pin",{fontCharacter:"\\eb2b"}),d.play=new d("play",{fontCharacter:"\\eb2c"}),d.run=new d("run",{fontCharacter:"\\eb2c"}),d.plug=new d("plug",{fontCharacter:"\\eb2d"}),d.preserveCase=new d("preserve-case",{fontCharacter:"\\eb2e"}),d.preview=new d("preview",{fontCharacter:"\\eb2f"}),d.project=new d("project",{fontCharacter:"\\eb30"}),d.pulse=new d("pulse",{fontCharacter:"\\eb31"}),d.question=new d("question",{fontCharacter:"\\eb32"}),d.quote=new d("quote",{fontCharacter:"\\eb33"}),d.radioTower=new d("radio-tower",{fontCharacter:"\\eb34"}),d.reactions=new d("reactions",{fontCharacter:"\\eb35"}),d.references=new d("references",{fontCharacter:"\\eb36"}),d.refresh=new d("refresh",{fontCharacter:"\\eb37"}),d.regex=new d("regex",{fontCharacter:"\\eb38"}),d.remoteExplorer=new d("remote-explorer",{fontCharacter:"\\eb39"}),d.remote=new d("remote",{fontCharacter:"\\eb3a"}),d.remove=new d("remove",{fontCharacter:"\\eb3b"}),d.replaceAll=new d("replace-all",{fontCharacter:"\\eb3c"}),d.replace=new d("replace",{fontCharacter:"\\eb3d"}),d.repoClone=new d("repo-clone",{fontCharacter:"\\eb3e"}),d.repoForcePush=new d("repo-force-push",{fontCharacter:"\\eb3f"}),d.repoPull=new d("repo-pull",{fontCharacter:"\\eb40"}),d.repoPush=new d("repo-push",{fontCharacter:"\\eb41"}),d.report=new d("report",{fontCharacter:"\\eb42"}),d.requestChanges=new d("request-changes",{fontCharacter:"\\eb43"}),d.rocket=new d("rocket",{fontCharacter:"\\eb44"}),d.rootFolderOpened=new d("root-folder-opened",{fontCharacter:"\\eb45"}),d.rootFolder=new d("root-folder",{fontCharacter:"\\eb46"}),d.rss=new d("rss",{fontCharacter:"\\eb47"}),d.ruby=new d("ruby",{fontCharacter:"\\eb48"}),d.saveAll=new d("save-all",{fontCharacter:"\\eb49"}),d.saveAs=new d("save-as",{fontCharacter:"\\eb4a"}),d.save=new d("save",{fontCharacter:"\\eb4b"}),d.screenFull=new d("screen-full",{fontCharacter:"\\eb4c"}),d.screenNormal=new d("screen-normal",{fontCharacter:"\\eb4d"}),d.searchStop=new d("search-stop",{fontCharacter:"\\eb4e"}),d.server=new d("server",{fontCharacter:"\\eb50"}),d.settingsGear=new d("settings-gear",{fontCharacter:"\\eb51"}),d.settings=new d("settings",{fontCharacter:"\\eb52"}),d.shield=new d("shield",{fontCharacter:"\\eb53"}),d.smiley=new d("smiley",{fontCharacter:"\\eb54"}),d.sortPrecedence=new d("sort-precedence",{fontCharacter:"\\eb55"}),d.splitHorizontal=new d("split-horizontal",{fontCharacter:"\\eb56"}),d.splitVertical=new d("split-vertical",{fontCharacter:"\\eb57"}),d.squirrel=new d("squirrel",{fontCharacter:"\\eb58"}),d.starFull=new d("star-full",{fontCharacter:"\\eb59"}),d.starHalf=new d("star-half",{fontCharacter:"\\eb5a"}),d.symbolClass=new d("symbol-class",{fontCharacter:"\\eb5b"}),d.symbolColor=new d("symbol-color",{fontCharacter:"\\eb5c"}),d.symbolConstant=new d("symbol-constant",{fontCharacter:"\\eb5d"}),d.symbolEnumMember=new d("symbol-enum-member",{fontCharacter:"\\eb5e"}),d.symbolField=new d("symbol-field",{fontCharacter:"\\eb5f"}),d.symbolFile=new d("symbol-file",{fontCharacter:"\\eb60"}),d.symbolInterface=new d("symbol-interface",{fontCharacter:"\\eb61"}),d.symbolKeyword=new d("symbol-keyword",{fontCharacter:"\\eb62"}),d.symbolMisc=new d("symbol-misc",{fontCharacter:"\\eb63"}),d.symbolOperator=new d("symbol-operator",{fontCharacter:"\\eb64"}),d.symbolProperty=new d("symbol-property",{fontCharacter:"\\eb65"}),d.wrench=new d("wrench",{fontCharacter:"\\eb65"}),d.wrenchSubaction=new d("wrench-subaction",{fontCharacter:"\\eb65"}),d.symbolSnippet=new d("symbol-snippet",{fontCharacter:"\\eb66"}),d.tasklist=new d("tasklist",{fontCharacter:"\\eb67"}),d.telescope=new d("telescope",{fontCharacter:"\\eb68"}),d.textSize=new d("text-size",{fontCharacter:"\\eb69"}),d.threeBars=new d("three-bars",{fontCharacter:"\\eb6a"}),d.thumbsdown=new d("thumbsdown",{fontCharacter:"\\eb6b"}),d.thumbsup=new d("thumbsup",{fontCharacter:"\\eb6c"}),d.tools=new d("tools",{fontCharacter:"\\eb6d"}),d.triangleDown=new d("triangle-down",{fontCharacter:"\\eb6e"}),d.triangleLeft=new d("triangle-left",{fontCharacter:"\\eb6f"}),d.triangleRight=new d("triangle-right",{fontCharacter:"\\eb70"}),d.triangleUp=new d("triangle-up",{fontCharacter:"\\eb71"}),d.twitter=new d("twitter",{fontCharacter:"\\eb72"}),d.unfold=new d("unfold",{fontCharacter:"\\eb73"}),d.unlock=new d("unlock",{fontCharacter:"\\eb74"}),d.unmute=new d("unmute",{fontCharacter:"\\eb75"}),d.unverified=new d("unverified",{fontCharacter:"\\eb76"}),d.verified=new d("verified",{fontCharacter:"\\eb77"}),d.versions=new d("versions",{fontCharacter:"\\eb78"}),d.vmActive=new d("vm-active",{fontCharacter:"\\eb79"}),d.vmOutline=new d("vm-outline",{fontCharacter:"\\eb7a"}),d.vmRunning=new d("vm-running",{fontCharacter:"\\eb7b"}),d.watch=new d("watch",{fontCharacter:"\\eb7c"}),d.whitespace=new d("whitespace",{fontCharacter:"\\eb7d"}),d.wholeWord=new d("whole-word",{fontCharacter:"\\eb7e"}),d.window=new d("window",{fontCharacter:"\\eb7f"}),d.wordWrap=new d("word-wrap",{fontCharacter:"\\eb80"}),d.zoomIn=new d("zoom-in",{fontCharacter:"\\eb81"}),d.zoomOut=new d("zoom-out",{fontCharacter:"\\eb82"}),d.listFilter=new d("list-filter",{fontCharacter:"\\eb83"}),d.listFlat=new d("list-flat",{fontCharacter:"\\eb84"}),d.listSelection=new d("list-selection",{fontCharacter:"\\eb85"}),d.selection=new d("selection",{fontCharacter:"\\eb85"}),d.listTree=new d("list-tree",{fontCharacter:"\\eb86"}),d.debugBreakpointFunctionUnverified=new d("debug-breakpoint-function-unverified",{fontCharacter:"\\eb87"}),d.debugBreakpointFunction=new d("debug-breakpoint-function",{fontCharacter:"\\eb88"}),d.debugBreakpointFunctionDisabled=new d("debug-breakpoint-function-disabled",{fontCharacter:"\\eb88"}),d.debugStackframeActive=new d("debug-stackframe-active",{fontCharacter:"\\eb89"}),d.debugStackframeDot=new d("debug-stackframe-dot",{fontCharacter:"\\eb8a"}),d.debugStackframe=new d("debug-stackframe",{fontCharacter:"\\eb8b"}),d.debugStackframeFocused=new d("debug-stackframe-focused",{fontCharacter:"\\eb8b"}),d.debugBreakpointUnsupported=new d("debug-breakpoint-unsupported",{fontCharacter:"\\eb8c"}),d.symbolString=new d("symbol-string",{fontCharacter:"\\eb8d"}),d.debugReverseContinue=new d("debug-reverse-continue",{fontCharacter:"\\eb8e"}),d.debugStepBack=new d("debug-step-back",{fontCharacter:"\\eb8f"}),d.debugRestartFrame=new d("debug-restart-frame",{fontCharacter:"\\eb90"}),d.callIncoming=new d("call-incoming",{fontCharacter:"\\eb92"}),d.callOutgoing=new d("call-outgoing",{fontCharacter:"\\eb93"}),d.menu=new d("menu",{fontCharacter:"\\eb94"}),d.expandAll=new d("expand-all",{fontCharacter:"\\eb95"}),d.feedback=new d("feedback",{fontCharacter:"\\eb96"}),d.groupByRefType=new d("group-by-ref-type",{fontCharacter:"\\eb97"}),d.ungroupByRefType=new d("ungroup-by-ref-type",{fontCharacter:"\\eb98"}),d.account=new d("account",{fontCharacter:"\\eb99"}),d.bellDot=new d("bell-dot",{fontCharacter:"\\eb9a"}),d.debugConsole=new d("debug-console",{fontCharacter:"\\eb9b"}),d.library=new d("library",{fontCharacter:"\\eb9c"}),d.output=new d("output",{fontCharacter:"\\eb9d"}),d.runAll=new d("run-all",{fontCharacter:"\\eb9e"}),d.syncIgnored=new d("sync-ignored",{fontCharacter:"\\eb9f"}),d.pinned=new d("pinned",{fontCharacter:"\\eba0"}),d.githubInverted=new d("github-inverted",{fontCharacter:"\\eba1"}),d.debugAlt=new d("debug-alt",{fontCharacter:"\\eb91"}),d.serverProcess=new d("server-process",{fontCharacter:"\\eba2"}),d.serverEnvironment=new d("server-environment",{fontCharacter:"\\eba3"}),d.pass=new d("pass",{fontCharacter:"\\eba4"}),d.stopCircle=new d("stop-circle",{fontCharacter:"\\eba5"}),d.playCircle=new d("play-circle",{fontCharacter:"\\eba6"}),d.record=new d("record",{fontCharacter:"\\eba7"}),d.debugAltSmall=new d("debug-alt-small",{fontCharacter:"\\eba8"}),d.vmConnect=new d("vm-connect",{fontCharacter:"\\eba9"}),d.cloud=new d("cloud",{fontCharacter:"\\ebaa"}),d.merge=new d("merge",{fontCharacter:"\\ebab"}),d.exportIcon=new d("export",{fontCharacter:"\\ebac"}),d.graphLeft=new d("graph-left",{fontCharacter:"\\ebad"}),d.magnet=new d("magnet",{fontCharacter:"\\ebae"}),d.notebook=new d("notebook",{fontCharacter:"\\ebaf"}),d.redo=new d("redo",{fontCharacter:"\\ebb0"}),d.checkAll=new d("check-all",{fontCharacter:"\\ebb1"}),d.pinnedDirty=new d("pinned-dirty",{fontCharacter:"\\ebb2"}),d.passFilled=new d("pass-filled",{fontCharacter:"\\ebb3"}),d.circleLargeFilled=new d("circle-large-filled",{fontCharacter:"\\ebb4"}),d.circleLargeOutline=new d("circle-large-outline",{fontCharacter:"\\ebb5"}),d.combine=new d("combine",{fontCharacter:"\\ebb6"}),d.gather=new d("gather",{fontCharacter:"\\ebb6"}),d.table=new d("table",{fontCharacter:"\\ebb7"}),d.variableGroup=new d("variable-group",{fontCharacter:"\\ebb8"}),d.typeHierarchy=new d("type-hierarchy",{fontCharacter:"\\ebb9"}),d.typeHierarchySub=new d("type-hierarchy-sub",{fontCharacter:"\\ebba"}),d.typeHierarchySuper=new d("type-hierarchy-super",{fontCharacter:"\\ebbb"}),d.gitPullRequestCreate=new d("git-pull-request-create",{fontCharacter:"\\ebbc"}),d.runAbove=new d("run-above",{fontCharacter:"\\ebbd"}),d.runBelow=new d("run-below",{fontCharacter:"\\ebbe"}),d.notebookTemplate=new d("notebook-template",{fontCharacter:"\\ebbf"}),d.debugRerun=new d("debug-rerun",{fontCharacter:"\\ebc0"}),d.workspaceTrusted=new d("workspace-trusted",{fontCharacter:"\\ebc1"}),d.workspaceUntrusted=new d("workspace-untrusted",{fontCharacter:"\\ebc2"}),d.workspaceUnspecified=new d("workspace-unspecified",{fontCharacter:"\\ebc3"}),d.terminalCmd=new d("terminal-cmd",{fontCharacter:"\\ebc4"}),d.terminalDebian=new d("terminal-debian",{fontCharacter:"\\ebc5"}),d.terminalLinux=new d("terminal-linux",{fontCharacter:"\\ebc6"}),d.terminalPowershell=new d("terminal-powershell",{fontCharacter:"\\ebc7"}),d.terminalTmux=new d("terminal-tmux",{fontCharacter:"\\ebc8"}),d.terminalUbuntu=new d("terminal-ubuntu",{fontCharacter:"\\ebc9"}),d.terminalBash=new d("terminal-bash",{fontCharacter:"\\ebca"}),d.arrowSwap=new d("arrow-swap",{fontCharacter:"\\ebcb"}),d.copy=new d("copy",{fontCharacter:"\\ebcc"}),d.personAdd=new d("person-add",{fontCharacter:"\\ebcd"}),d.filterFilled=new d("filter-filled",{fontCharacter:"\\ebce"}),d.wand=new d("wand",{fontCharacter:"\\ebcf"}),d.debugLineByLine=new d("debug-line-by-line",{fontCharacter:"\\ebd0"}),d.inspect=new d("inspect",{fontCharacter:"\\ebd1"}),d.layers=new d("layers",{fontCharacter:"\\ebd2"}),d.layersDot=new d("layers-dot",{fontCharacter:"\\ebd3"}),d.layersActive=new d("layers-active",{fontCharacter:"\\ebd4"}),d.compass=new d("compass",{fontCharacter:"\\ebd5"}),d.compassDot=new d("compass-dot",{fontCharacter:"\\ebd6"}),d.compassActive=new d("compass-active",{fontCharacter:"\\ebd7"}),d.azure=new d("azure",{fontCharacter:"\\ebd8"}),d.issueDraft=new d("issue-draft",{fontCharacter:"\\ebd9"}),d.gitPullRequestClosed=new d("git-pull-request-closed",{fontCharacter:"\\ebda"}),d.gitPullRequestDraft=new d("git-pull-request-draft",{fontCharacter:"\\ebdb"}),d.debugAll=new d("debug-all",{fontCharacter:"\\ebdc"}),d.debugCoverage=new d("debug-coverage",{fontCharacter:"\\ebdd"}),d.runErrors=new d("run-errors",{fontCharacter:"\\ebde"}),d.folderLibrary=new d("folder-library",{fontCharacter:"\\ebdf"}),d.debugContinueSmall=new d("debug-continue-small",{fontCharacter:"\\ebe0"}),d.beakerStop=new d("beaker-stop",{fontCharacter:"\\ebe1"}),d.graphLine=new d("graph-line",{fontCharacter:"\\ebe2"}),d.graphScatter=new d("graph-scatter",{fontCharacter:"\\ebe3"}),d.pieChart=new d("pie-chart",{fontCharacter:"\\ebe4"}),d.bracket=new d("bracket",d.json.definition),d.bracketDot=new d("bracket-dot",{fontCharacter:"\\ebe5"}),d.bracketError=new d("bracket-error",{fontCharacter:"\\ebe6"}),d.lockSmall=new d("lock-small",{fontCharacter:"\\ebe7"}),d.azureDevops=new d("azure-devops",{fontCharacter:"\\ebe8"}),d.verifiedFilled=new d("verified-filled",{fontCharacter:"\\ebe9"})}(Te||(Te={}))},79881:function(Li,Rt,oe){"use strict";oe.d(Rt,{B8:function(){return I},Cp:function(){return ge},F0:function(){return P},L6:function(){return ne},VV:function(){return Te},b1:function(){return d},dL:function(){return qe},ri:function(){return q}});class ce{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(T){setTimeout(()=>{throw T.stack?new Error(T.message+`
`+T.stack):T},0)}}emit(T){this.listeners.forEach(M=>{M(T)})}onUnexpectedError(T){this.unexpectedErrorHandler(T),this.emit(T)}onUnexpectedExternalError(T){this.unexpectedErrorHandler(T)}}const De=new ce;function qe(k){Te(k)||De.onUnexpectedError(k)}function ge(k){Te(k)||De.onUnexpectedExternalError(k)}function q(k){if(k instanceof Error){let{name:T,message:M}=k;const O=k.stacktrace||k.stack;return{$isError:!0,name:T,message:M,stack:O}}return k}const S="Canceled";function Te(k){return k instanceof Error&&k.name===S&&k.message===S}function P(){const k=new Error(S);return k.name=k.message,k}function d(k){return k?new Error(`Illegal argument: ${k}`):new Error("Illegal argument")}function ne(k){return k?new Error(`Illegal state: ${k}`):new Error("Illegal state")}class I extends Error{constructor(T){super("NotSupported"),T&&(this.message=T)}}},4348:function(Li,Rt,oe){"use strict";oe.d(Rt,{D0:function(){return I},E7:function(){return k},K3:function(){return ne},Q5:function(){return d},ZD:function(){return T},ju:function(){return q}});var ce=oe(79881),De=oe(69323),qe=oe(34502),ge=oe(95830),q;(function(M){M.None=()=>De.JT.None;function O(X){return(J,de=null,ie)=>{let A=!1,L;return L=X(V=>{if(!A)return L?L.dispose():A=!0,J.call(de,V)},null,ie),A&&L.dispose(),L}}M.once=O;function Y(X,J){return he((de,ie=null,A)=>X(L=>de.call(ie,J(L)),null,A))}M.map=Y;function H(X,J){return he((de,ie=null,A)=>X(L=>{J(L),de.call(ie,L)},null,A))}M.forEach=H;function j(X,J){return he((de,ie=null,A)=>X(L=>J(L)&&de.call(ie,L),null,A))}M.filter=j;function U(X){return X}M.signal=U;function $(...X){return(J,de=null,ie)=>(0,De.F8)(...X.map(A=>A(L=>J.call(de,L),null,ie)))}M.any=$;function G(X,J,de){let ie=de;return Y(X,A=>(ie=J(ie,A),ie))}M.reduce=G;function he(X){let J;const de=new d({onFirstListenerAdd(){J=X(de.fire,de)},onLastListenerRemove(){J.dispose()}});return de.event}function be(X,J,de=100,ie=!1,A){let L,V,pe,ze=0;const at=new d({leakWarningThreshold:A,onFirstListenerAdd(){L=X(Ot=>{ze++,V=J(V,Ot),ie&&!pe&&(at.fire(V),V=void 0),clearTimeout(pe),pe=setTimeout(()=>{const Ce=V;V=void 0,pe=void 0,(!ie||ze>1)&&at.fire(Ce),ze=0},de)})},onLastListenerRemove(){L.dispose()}});return at.event}M.debounce=be;function Se(X,J=(de,ie)=>de===ie){let de=!0,ie;return j(X,A=>{const L=de||!J(A,ie);return de=!1,ie=A,L})}M.latch=Se;function re(X,J){return[M.filter(X,J),M.filter(X,de=>!J(de))]}M.split=re;function Oe(X,J=!1,de=[]){let ie=de.slice(),A=X(pe=>{ie?ie.push(pe):V.fire(pe)});const L=()=>{ie&&ie.forEach(pe=>V.fire(pe)),ie=null},V=new d({onFirstListenerAdd(){A||(A=X(pe=>V.fire(pe)))},onFirstListenerDidAdd(){ie&&(J?setTimeout(L):L())},onLastListenerRemove(){A&&A.dispose(),A=null}});return V.event}M.buffer=Oe;class We{constructor(J){this.event=J}map(J){return new We(Y(this.event,J))}forEach(J){return new We(H(this.event,J))}filter(J){return new We(j(this.event,J))}reduce(J,de){return new We(G(this.event,J,de))}latch(){return new We(Se(this.event))}debounce(J,de=100,ie=!1,A){return new We(be(this.event,J,de,ie,A))}on(J,de,ie){return this.event(J,de,ie)}once(J,de,ie){return O(this.event)(J,de,ie)}}function Be(X){return new We(X)}M.chain=Be;function Dt(X,J,de=ie=>ie){const ie=(...pe)=>V.fire(de(...pe)),A=()=>X.on(J,ie),L=()=>X.removeListener(J,ie),V=new d({onFirstListenerAdd:A,onLastListenerRemove:L});return V.event}M.fromNodeEventEmitter=Dt;function te(X,J,de=ie=>ie){const ie=(...pe)=>V.fire(de(...pe)),A=()=>X.addEventListener(J,ie),L=()=>X.removeEventListener(J,ie),V=new d({onFirstListenerAdd:A,onLastListenerRemove:L});return V.event}M.fromDOMEventEmitter=te;function z(X){return new Promise(J=>O(X)(J))}M.toPromise=z})(q||(q={}));class S{constructor(O){this._listenerCount=0,this._invocationCount=0,this._elapsedOverall=0,this._name=`${O}_${S._idPool++}`}start(O){this._stopWatch=new ge.G(!0),this._listenerCount=O}stop(){if(this._stopWatch){const O=this._stopWatch.elapsed();this._elapsedOverall+=O,this._invocationCount+=1,console.info(`did FIRE ${this._name}: elapsed_ms: ${O.toFixed(5)}, listener: ${this._listenerCount} (elapsed_overall: ${this._elapsedOverall.toFixed(2)}, invocations: ${this._invocationCount})`),this._stopWatch=void 0}}}S._idPool=0;let Te=-1;class P{constructor(O,Y=Math.random().toString(18).slice(2,5)){this.customThreshold=O,this.name=Y,this._warnCountdown=0}dispose(){this._stacks&&this._stacks.clear()}check(O){let Y=Te;if(typeof this.customThreshold=="number"&&(Y=this.customThreshold),Y<=0||O<Y)return;this._stacks||(this._stacks=new Map);const H=new Error().stack.split(`
`).slice(3).join(`
`),j=this._stacks.get(H)||0;if(this._stacks.set(H,j+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=Y*.5;let U,$=0;for(const[G,he]of this._stacks)(!U||$<he)&&(U=G,$=he);console.warn(`[${this.name}] potential listener LEAK detected, having ${O} listeners already. MOST frequent listener (${$}):`),console.warn(U)}return()=>{const U=this._stacks.get(H)||0;this._stacks.set(H,U-1)}}}class d{constructor(O){var Y;this._disposed=!1,this._options=O,this._leakageMon=Te>0?new P(this._options&&this._options.leakWarningThreshold):void 0,this._perfMon=!((Y=this._options)===null||Y===void 0)&&Y._profName?new S(this._options._profName):void 0}get event(){return this._event||(this._event=(O,Y,H)=>{var j;this._listeners||(this._listeners=new qe.S);const U=this._listeners.isEmpty();U&&this._options&&this._options.onFirstListenerAdd&&this._options.onFirstListenerAdd(this);const $=this._listeners.push(Y?[O,Y]:O);U&&this._options&&this._options.onFirstListenerDidAdd&&this._options.onFirstListenerDidAdd(this),this._options&&this._options.onListenerDidAdd&&this._options.onListenerDidAdd(this,O,Y);const G=(j=this._leakageMon)===null||j===void 0?void 0:j.check(this._listeners.size),he=(0,De.OF)(()=>{G&&G(),this._disposed||($(),this._options&&this._options.onLastListenerRemove&&(this._listeners&&!this._listeners.isEmpty()||this._options.onLastListenerRemove(this)))});return H instanceof De.SL?H.add(he):Array.isArray(H)&&H.push(he),he}),this._event}fire(O){var Y,H;if(this._listeners){this._deliveryQueue||(this._deliveryQueue=new qe.S);for(let j of this._listeners)this._deliveryQueue.push([j,O]);for((Y=this._perfMon)===null||Y===void 0||Y.start(this._deliveryQueue.size);this._deliveryQueue.size>0;){const[j,U]=this._deliveryQueue.shift();try{typeof j=="function"?j.call(void 0,U):j[0].call(j[1],U)}catch($){(0,ce.dL)($)}}(H=this._perfMon)===null||H===void 0||H.stop()}}dispose(){var O,Y,H,j,U;this._disposed||(this._disposed=!0,(O=this._listeners)===null||O===void 0||O.clear(),(Y=this._deliveryQueue)===null||Y===void 0||Y.clear(),(j=(H=this._options)===null||H===void 0?void 0:H.onLastListenerRemove)===null||j===void 0||j.call(H),(U=this._leakageMon)===null||U===void 0||U.dispose())}}class ne extends d{constructor(O){super(O),this._isPaused=0,this._eventQueue=new qe.S,this._mergeFn=O==null?void 0:O.merge}pause(){this._isPaused++}resume(){if(this._isPaused!==0&&--this._isPaused===0)if(this._mergeFn){const O=Array.from(this._eventQueue);this._eventQueue.clear(),super.fire(this._mergeFn(O))}else for(;!this._isPaused&&this._eventQueue.size!==0;)super.fire(this._eventQueue.shift())}fire(O){this._listeners&&(this._isPaused!==0?this._eventQueue.push(O):super.fire(O))}}class I extends ne{constructor(O){var Y;super(O),this._delay=(Y=O.delay)!==null&&Y!==void 0?Y:100}fire(O){this._handle||(this.pause(),this._handle=setTimeout(()=>{this._handle=void 0,this.resume()},this._delay)),super.fire(O)}}class k{constructor(){this.buffers=[]}wrapEvent(O){return(Y,H,j)=>O(U=>{const $=this.buffers[this.buffers.length-1];$?$.push(()=>Y.call(H,U)):Y.call(H,U)},void 0,j)}bufferEvents(O){const Y=[];this.buffers.push(Y);const H=O();return this.buffers.pop(),Y.forEach(j=>j()),H}}class T{constructor(){this.listening=!1,this.inputEvent=q.None,this.inputEventListener=De.JT.None,this.emitter=new d({onFirstListenerDidAdd:()=>{this.listening=!0,this.inputEventListener=this.inputEvent(this.emitter.fire,this.emitter)},onLastListenerRemove:()=>{this.listening=!1,this.inputEventListener.dispose()}}),this.event=this.emitter.event}set input(O){this.inputEvent=O,this.listening&&(this.inputEventListener.dispose(),this.inputEventListener=O(this.emitter.fire,this.emitter))}dispose(){this.inputEventListener.dispose(),this.emitter.dispose()}}},17845:function(Li,Rt,oe){"use strict";oe.d(Rt,{I:function(){return ce}});function ce(De){const qe=this;let ge=!1,q;return function(){return ge||(ge=!0,q=De.apply(qe,arguments)),q}}},88226:function(Li,Rt,oe){"use strict";oe.d(Rt,{$:function(){return ce}});var ce;(function(De){function qe($){return $&&typeof $=="object"&&typeof $[Symbol.iterator]=="function"}De.is=qe;const ge=Object.freeze([]);function q(){return ge}De.empty=q;function*S($){yield $}De.single=S;function Te($){return $||ge}De.from=Te;function P($){return!$||$[Symbol.iterator]().next().done===!0}De.isEmpty=P;function d($){return $[Symbol.iterator]().next().value}De.first=d;function ne($,G){for(const he of $)if(G(he))return!0;return!1}De.some=ne;function I($,G){for(const he of $)if(G(he))return he}De.find=I;function*k($,G){for(const he of $)G(he)&&(yield he)}De.filter=k;function*T($,G){let he=0;for(const be of $)yield G(be,he++)}De.map=T;function*M(...$){for(const G of $)for(const he of G)yield he}De.concat=M;function*O($){for(const G of $)for(const he of G)yield he}De.concatNested=O;function Y($,G,he){let be=he;for(const Se of $)be=G(be,Se);return be}De.reduce=Y;function*H($,G,he=$.length){for(G<0&&(G+=$.length),he<0?he+=$.length:he>$.length&&(he=$.length);G<he;G++)yield $[G]}De.slice=H;function j($,G=Number.POSITIVE_INFINITY){const he=[];if(G===0)return[he,$];const be=$[Symbol.iterator]();for(let Se=0;Se<G;Se++){const re=be.next();if(re.done)return[he,De.empty()];he.push(re.value)}return[he,{[Symbol.iterator](){return be}}]}De.consume=j;function U($,G,he=(be,Se)=>be===Se){const be=$[Symbol.iterator](),Se=G[Symbol.iterator]();for(;;){const re=be.next(),Oe=Se.next();if(re.done!==Oe.done)return!1;if(re.done)return!0;if(!he(re.value,Oe.value))return!1}}De.equals=U})(ce||(ce={}))},69323:function(Li,Rt,oe){"use strict";oe.d(Rt,{B9:function(){return T},F8:function(){return M},JT:function(){return H},Jz:function(){return U},OF:function(){return O},SL:function(){return Y},Wf:function(){return k},XK:function(){return j},dk:function(){return ne}});var ce=oe(17845),De=oe(88226);const qe=!1;let ge=null;function q($){ge=$}if(qe){const $="__is_disposable_tracked__";q(new class{trackDisposable(G){const he=new Error("Potentially leaked disposable").stack;setTimeout(()=>{G[$]||console.log(he)},3e3)}setParent(G,he){if(G&&G!==H.None)try{G[$]=!0}catch(be){}}markAsDisposed(G){if(G&&G!==H.None)try{G[$]=!0}catch(he){}}markAsSingleton(G){}})}function S($){return ge==null||ge.trackDisposable($),$}function Te($){ge==null||ge.markAsDisposed($)}function P($,G){ge==null||ge.setParent($,G)}function d($,G){if(ge)for(const he of $)ge.setParent(he,G)}function ne($){return ge==null||ge.markAsSingleton($),$}class I extends Error{constructor(G){super(`Encountered errors while disposing of store. Errors: [${G.join(", ")}]`),this.errors=G}}function k($){return typeof $.dispose=="function"&&$.dispose.length===0}function T($){if(De.$.is($)){let G=[];for(const he of $)if(he)try{he.dispose()}catch(be){G.push(be)}if(G.length===1)throw G[0];if(G.length>1)throw new I(G);return Array.isArray($)?[]:$}else if($)return $.dispose(),$}function M(...$){const G=O(()=>T($));return d($,G),G}function O($){const G=S({dispose:(0,ce.I)(()=>{Te(G),$()})});return G}class Y{constructor(){this._toDispose=new Set,this._isDisposed=!1,S(this)}dispose(){this._isDisposed||(Te(this),this._isDisposed=!0,this.clear())}clear(){try{T(this._toDispose.values())}finally{this._toDispose.clear()}}add(G){if(!G)return G;if(G===this)throw new Error("Cannot register a disposable on itself!");return P(G,this),this._isDisposed?Y.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(G),G}}Y.DISABLE_DISPOSED_WARNING=!1;class H{constructor(){this._store=new Y,S(this),P(this._store,this)}dispose(){Te(this),this._store.dispose()}_register(G){if(G===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(G)}}H.None=Object.freeze({dispose(){}});class j{constructor(){this._isDisposed=!1,S(this)}get value(){return this._isDisposed?void 0:this._value}set value(G){var he;this._isDisposed||G===this._value||((he=this._value)===null||he===void 0||he.dispose(),G&&P(G,this),this._value=G)}clear(){this.value=void 0}dispose(){var G;this._isDisposed=!0,Te(this),(G=this._value)===null||G===void 0||G.dispose(),this._value=void 0}clearAndLeak(){const G=this._value;return this._value=void 0,G&&P(G,null),G}}class U{constructor(G){this.object=G}dispose(){}}},34502:function(Li,Rt,oe){"use strict";oe.d(Rt,{S:function(){return De}});class ce{constructor(ge){this.element=ge,this.next=ce.Undefined,this.prev=ce.Undefined}}ce.Undefined=new ce(void 0);class De{constructor(){this._first=ce.Undefined,this._last=ce.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ce.Undefined}clear(){let ge=this._first;for(;ge!==ce.Undefined;){const q=ge.next;ge.prev=ce.Undefined,ge.next=ce.Undefined,ge=q}this._first=ce.Undefined,this._last=ce.Undefined,this._size=0}unshift(ge){return this._insert(ge,!1)}push(ge){return this._insert(ge,!0)}_insert(ge,q){const S=new ce(ge);if(this._first===ce.Undefined)this._first=S,this._last=S;else if(q){const P=this._last;this._last=S,S.prev=P,P.next=S}else{const P=this._first;this._first=S,S.next=P,P.prev=S}this._size+=1;let Te=!1;return()=>{Te||(Te=!0,this._remove(S))}}shift(){if(this._first!==ce.Undefined){const ge=this._first.element;return this._remove(this._first),ge}}pop(){if(this._last!==ce.Undefined){const ge=this._last.element;return this._remove(this._last),ge}}_remove(ge){if(ge.prev!==ce.Undefined&&ge.next!==ce.Undefined){const q=ge.prev;q.next=ge.next,ge.next.prev=q}else ge.prev===ce.Undefined&&ge.next===ce.Undefined?(this._first=ce.Undefined,this._last=ce.Undefined):ge.next===ce.Undefined?(this._last=this._last.prev,this._last.next=ce.Undefined):ge.prev===ce.Undefined&&(this._first=this._first.next,this._first.prev=ce.Undefined);this._size-=1}*[Symbol.iterator](){let ge=this._first;for(;ge!==ce.Undefined;)yield ge.element,ge=ge.next}}},23345:function(Li,Rt,oe){"use strict";oe.d(Rt,{$L:function(){return be},ED:function(){return U},IJ:function(){return G},OS:function(){return We},WE:function(){return re},dz:function(){return $},gn:function(){return Se},li:function(){return O},r:function(){return te},tY:function(){return he},xS:function(){return Oe}});var ce=oe(97671),De;const qe="en";let ge=!1,q=!1,S=!1,Te=!1,P=!1,d=!1,ne=!1,I,k=null,T=null,M;const O=typeof self=="object"?self:typeof oe.g=="object"?oe.g:{};let Y;typeof O.vscode!="undefined"&&typeof O.vscode.process!="undefined"?Y=O.vscode.process:typeof ce!="undefined"&&(Y=ce);const H=typeof((De=Y==null?void 0:Y.versions)===null||De===void 0?void 0:De.electron)=="string"&&Y.type==="renderer";if(typeof navigator=="object"&&!H)M=navigator.userAgent,ge=M.indexOf("Windows")>=0,q=M.indexOf("Macintosh")>=0,ne=(M.indexOf("Macintosh")>=0||M.indexOf("iPad")>=0||M.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints>0,S=M.indexOf("Linux")>=0,d=!0,I=navigator.language,k=I;else if(typeof Y=="object"){ge=Y.platform==="win32",q=Y.platform==="darwin",S=Y.platform==="linux",Te=S&&!!Y.env.SNAP&&!!Y.env.SNAP_REVISION,I=qe,k=qe;const z=Y.env.VSCODE_NLS_CONFIG;if(z)try{const X=JSON.parse(z),J=X.availableLanguages["*"];I=X.locale,k=J||qe,T=X._translationsConfigFile}catch(X){}P=!0}else console.error("Unable to resolve platform.");let j=0;q?j=1:ge?j=3:S&&(j=2);const U=ge,$=q,G=S,he=P,be=d,Se=ne,re=M,Oe=function(){if(O.setImmediate)return O.setImmediate.bind(O);if(typeof O.postMessage=="function"&&!O.importScripts){let J=[];O.addEventListener("message",ie=>{if(ie.data&&ie.data.vscodeSetImmediateId)for(let A=0,L=J.length;A<L;A++){const V=J[A];if(V.id===ie.data.vscodeSetImmediateId){J.splice(A,1),V.callback();return}}});let de=0;return ie=>{const A=++de;J.push({id:A,callback:ie}),O.postMessage({vscodeSetImmediateId:A},"*")}}if(typeof(Y==null?void 0:Y.nextTick)=="function")return Y.nextTick.bind(Y);const X=Promise.resolve();return J=>X.then(J)}(),We=q||ne?2:ge?1:3;let Be=!0,Dt=!1;function te(){if(!Dt){Dt=!0;const z=new Uint8Array(2);z[0]=1,z[1]=2,Be=new Uint16Array(z.buffer)[0]===513}return Be}},95830:function(Li,Rt,oe){"use strict";oe.d(Rt,{G:function(){return qe}});var ce=oe(23345);const De=ce.li.performance&&typeof ce.li.performance.now=="function";class qe{constructor(q){this._highResolution=De&&q,this._startTime=this._now(),this._stopTime=-1}static create(q=!0){return new qe(q)}stop(){this._stopTime=this._now()}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}_now(){return this._highResolution?ce.li.performance.now():Date.now()}}},82983:function(Li,Rt,oe){"use strict";oe.d(Rt,{$i:function(){return ze},C8:function(){return Mt},GF:function(){return I},HO:function(){return de},IO:function(){return k},K7:function(){return jt},Kw:function(){return fi},LC:function(){return O},Mh:function(){return Oe},P1:function(){return We},PJ:function(){return Yi},Qe:function(){return at},R1:function(){return ne},RP:function(){return V},S6:function(){return Kt},TT:function(){return U},Ut:function(){return A},V8:function(){return Y},WU:function(){return qe},YK:function(){return Dt},YU:function(){return ge},ZG:function(){return Be},ZH:function(){return z},ab:function(){return Ot},c1:function(){return dt},df:function(){return be},ec:function(){return q},fi:function(){return ln},fy:function(){return S},j3:function(){return Te},j_:function(){return G},m5:function(){return ce},mK:function(){return he},mr:function(){return T},oH:function(){return ve},oL:function(){return P},ok:function(){return re},ow:function(){return H},qq:function(){return Se},qu:function(){return j},rL:function(){return te},uS:function(){return Ti},un:function(){return d},uq:function(){return M},vH:function(){return J},xe:function(){return Ce},zY:function(){return $}});function ce(ee){return!ee||typeof ee!="string"?!0:ee.trim().length===0}const De=/{(\d+)}/g;function qe(ee,...xe){return xe.length===0?ee:ee.replace(De,function($e,Ye){const rt=parseInt(Ye,10);return isNaN(rt)||rt<0||rt>=xe.length?$e:xe[rt]})}function ge(ee){return ee.replace(/[<>&]/g,function(xe){switch(xe){case"<":return"&lt;";case">":return"&gt;";case"&":return"&amp;";default:return xe}})}function q(ee){return ee.replace(/[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g,"\\$&")}function S(ee,xe=" "){const $e=Te(ee,xe);return P($e,xe)}function Te(ee,xe){if(!ee||!xe)return ee;const $e=xe.length;if($e===0||ee.length===0)return ee;let Ye=0;for(;ee.indexOf(xe,Ye)===Ye;)Ye=Ye+$e;return ee.substring(Ye)}function P(ee,xe){if(!ee||!xe)return ee;const $e=xe.length,Ye=ee.length;if($e===0||Ye===0)return ee;let rt=Ye,gt=-1;for(;gt=ee.lastIndexOf(xe,rt-1),!(gt===-1||gt+$e!==rt);){if(gt===0)return"";rt=gt}return ee.substring(0,rt)}function d(ee){return ee.replace(/[\-\\\{\}\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&").replace(/[\*]/g,".*")}function ne(ee){return ee.replace(/\*/g,"")}function I(ee,xe,$e={}){if(!ee)throw new Error("Cannot create regex from empty string");xe||(ee=q(ee)),$e.wholeWord&&(/\B/.test(ee.charAt(0))||(ee="\\b"+ee),/\B/.test(ee.charAt(ee.length-1))||(ee=ee+"\\b"));let Ye="";return $e.global&&(Ye+="g"),$e.matchCase||(Ye+="i"),$e.multiline&&(Ye+="m"),$e.unicode&&(Ye+="u"),new RegExp(ee,Ye)}function k(ee){return ee.source==="^"||ee.source==="^$"||ee.source==="$"||ee.source==="^\\s*$"?!1:!!(ee.exec("")&&ee.lastIndex===0)}function T(ee){return(ee.global?"g":"")+(ee.ignoreCase?"i":"")+(ee.multiline?"m":"")+(ee.unicode?"u":"")}function M(ee){return ee.split(/\r\n|\r|\n/)}function O(ee){for(let xe=0,$e=ee.length;xe<$e;xe++){const Ye=ee.charCodeAt(xe);if(Ye!==32&&Ye!==9)return xe}return-1}function Y(ee,xe=0,$e=ee.length){for(let Ye=xe;Ye<$e;Ye++){const rt=ee.charCodeAt(Ye);if(rt!==32&&rt!==9)return ee.substring(xe,Ye)}return ee.substring(xe,$e)}function H(ee,xe=ee.length-1){for(let $e=xe;$e>=0;$e--){const Ye=ee.charCodeAt($e);if(Ye!==32&&Ye!==9)return $e}return-1}function j(ee,xe){return ee<xe?-1:ee>xe?1:0}function U(ee,xe,$e=0,Ye=ee.length,rt=0,gt=xe.length){for(;$e<Ye&&rt<gt;$e++,rt++){let ke=ee.charCodeAt($e),ht=xe.charCodeAt(rt);if(ke<ht)return-1;if(ke>ht)return 1}const Yt=Ye-$e,pt=gt-rt;return Yt<pt?-1:Yt>pt?1:0}function $(ee,xe){return G(ee,xe,0,ee.length,0,xe.length)}function G(ee,xe,$e=0,Ye=ee.length,rt=0,gt=xe.length){for(;$e<Ye&&rt<gt;$e++,rt++){let ke=ee.charCodeAt($e),ht=xe.charCodeAt(rt);if(ke===ht)continue;if(ke>=128||ht>=128)return U(ee.toLowerCase(),xe.toLowerCase(),$e,Ye,rt,gt);he(ke)&&(ke-=32),he(ht)&&(ht-=32);const Gt=ke-ht;if(Gt!==0)return Gt}const Yt=Ye-$e,pt=gt-rt;return Yt<pt?-1:Yt>pt?1:0}function he(ee){return ee>=97&&ee<=122}function be(ee){return ee>=65&&ee<=90}function Se(ee,xe){return ee.length===xe.length&&G(ee,xe)===0}function re(ee,xe){const $e=xe.length;return xe.length>ee.length?!1:G(ee,xe,0,$e)===0}function Oe(ee,xe){let $e,Ye=Math.min(ee.length,xe.length);for($e=0;$e<Ye;$e++)if(ee.charCodeAt($e)!==xe.charCodeAt($e))return $e;return Ye}function We(ee,xe){let $e,Ye=Math.min(ee.length,xe.length);const rt=ee.length-1,gt=xe.length-1;for($e=0;$e<Ye;$e++)if(ee.charCodeAt(rt-$e)!==xe.charCodeAt(gt-$e))return $e;return Ye}function Be(ee){return 55296<=ee&&ee<=56319}function Dt(ee){return 56320<=ee&&ee<=57343}function te(ee,xe){return(ee-55296<<10)+(xe-56320)+65536}function z(ee,xe,$e){const Ye=ee.charCodeAt($e);if(Be(Ye)&&$e+1<xe){const rt=ee.charCodeAt($e+1);if(Dt(rt))return te(Ye,rt)}return Ye}function X(ee,xe){const $e=ee.charCodeAt(xe-1);if(Dt($e)&&xe>1){const Ye=ee.charCodeAt(xe-2);if(Be(Ye))return te(Ye,$e)}return $e}function J(ee,xe){const $e=Ne.getInstance(),Ye=xe,rt=ee.length,gt=z(ee,rt,xe);xe+=gt>=65536?2:1;let Yt=$e.getGraphemeBreakType(gt);for(;xe<rt;){const pt=z(ee,rt,xe),ke=$e.getGraphemeBreakType(pt);if(ln(Yt,ke))break;xe+=pt>=65536?2:1,Yt=ke}return xe-Ye}function de(ee,xe){const $e=Ne.getInstance(),Ye=xe,rt=X(ee,xe);xe-=rt>=65536?2:1;let gt=$e.getGraphemeBreakType(rt);for(;xe>0;){const Yt=X(ee,xe),pt=$e.getGraphemeBreakType(Yt);if(ln(pt,gt))break;xe-=Yt>=65536?2:1,gt=pt}return Ye-xe}const ie=/(?:[\u05BE\u05C0\u05C3\u05C6\u05D0-\u05F4\u0608\u060B\u060D\u061B-\u064A\u066D-\u066F\u0671-\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u0710\u0712-\u072F\u074D-\u07A5\u07B1-\u07EA\u07F4\u07F5\u07FA-\u0815\u081A\u0824\u0828\u0830-\u0858\u085E-\u08BD\u200F\uFB1D\uFB1F-\uFB28\uFB2A-\uFD3D\uFD50-\uFDFC\uFE70-\uFEFC]|\uD802[\uDC00-\uDD1B\uDD20-\uDE00\uDE10-\uDE33\uDE40-\uDEE4\uDEEB-\uDF35\uDF40-\uDFFF]|\uD803[\uDC00-\uDCFF]|\uD83A[\uDC00-\uDCCF\uDD00-\uDD43\uDD50-\uDFFF]|\uD83B[\uDC00-\uDEBB])/;function A(ee){return ie.test(ee)}const L=/(?:[\u231A\u231B\u23F0\u23F3\u2600-\u27BF\u2B50\u2B55]|\uD83C[\uDDE6-\uDDFF\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F\uDE80-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD00-\uDDFF\uDE70-\uDED6])/;function V(ee){return L.test(ee)}const pe=/^[\t\n\r\x20-\x7E]*$/;function ze(ee){return pe.test(ee)}const at=/[\u2028\u2029]/;function Ot(ee){return at.test(ee)}function Ce(ee){for(let xe=0,$e=ee.length;xe<$e;xe++)if(jt(ee.charCodeAt(xe)))return!0;return!1}function jt(ee){return ee=+ee,ee>=11904&&ee<=55215||ee>=63744&&ee<=64255||ee>=65281&&ee<=65374}function Mt(ee){return ee>=127462&&ee<=127487||ee===8986||ee===8987||ee===9200||ee===9203||ee>=9728&&ee<=10175||ee===11088||ee===11093||ee>=127744&&ee<=128591||ee>=128640&&ee<=128764||ee>=128992&&ee<=129003||ee>=129280&&ee<=129535||ee>=129648&&ee<=129750}const dt="\uFEFF";function Ti(ee){return!!(ee&&ee.length>0&&ee.charCodeAt(0)===65279)}function fi(ee,xe=!1){return ee?(xe&&(ee=ee.replace(/\\./g,"")),ee.toLowerCase()!==ee):!1}function Yi(ee){return ee=ee%(2*26),ee<26?String.fromCharCode(97+ee):String.fromCharCode(65+ee-26)}function Kt(ee){return Ne.getInstance().getGraphemeBreakType(ee)}function ln(ee,xe){return ee===0?xe!==5&&xe!==7:ee===2&&xe===3?!1:ee===4||ee===2||ee===3||xe===4||xe===2||xe===3?!0:!(ee===8&&(xe===8||xe===9||xe===11||xe===12)||(ee===11||ee===9)&&(xe===9||xe===10)||(ee===12||ee===10)&&xe===10||xe===5||xe===13||xe===7||ee===1||ee===13&&xe===14||ee===6&&xe===6)}class Ne{constructor(){this._data=Ge()}static getInstance(){return Ne._INSTANCE||(Ne._INSTANCE=new Ne),Ne._INSTANCE}getGraphemeBreakType(xe){if(xe<32)return xe===10?3:xe===13?2:4;if(xe<127)return 0;const $e=this._data,Ye=$e.length/3;let rt=1;for(;rt<=Ye;)if(xe<$e[3*rt])rt=2*rt;else if(xe>$e[3*rt+1])rt=2*rt+1;else return $e[3*rt+2];return 0}}Ne._INSTANCE=null;function Ge(){return JSON.parse("[0,0,0,51592,51592,11,44424,44424,11,72251,72254,5,7150,7150,7,48008,48008,11,55176,55176,11,128420,128420,14,3276,3277,5,9979,9980,14,46216,46216,11,49800,49800,11,53384,53384,11,70726,70726,5,122915,122916,5,129320,129327,14,2558,2558,5,5906,5908,5,9762,9763,14,43360,43388,8,45320,45320,11,47112,47112,11,48904,48904,11,50696,50696,11,52488,52488,11,54280,54280,11,70082,70083,1,71350,71350,7,73111,73111,5,127892,127893,14,128726,128727,14,129473,129474,14,2027,2035,5,2901,2902,5,3784,3789,5,6754,6754,5,8418,8420,5,9877,9877,14,11088,11088,14,44008,44008,5,44872,44872,11,45768,45768,11,46664,46664,11,47560,47560,11,48456,48456,11,49352,49352,11,50248,50248,11,51144,51144,11,52040,52040,11,52936,52936,11,53832,53832,11,54728,54728,11,69811,69814,5,70459,70460,5,71096,71099,7,71998,71998,5,72874,72880,5,119149,119149,7,127374,127374,14,128335,128335,14,128482,128482,14,128765,128767,14,129399,129400,14,129680,129685,14,1476,1477,5,2377,2380,7,2759,2760,5,3137,3140,7,3458,3459,7,4153,4154,5,6432,6434,5,6978,6978,5,7675,7679,5,9723,9726,14,9823,9823,14,9919,9923,14,10035,10036,14,42736,42737,5,43596,43596,5,44200,44200,11,44648,44648,11,45096,45096,11,45544,45544,11,45992,45992,11,46440,46440,11,46888,46888,11,47336,47336,11,47784,47784,11,48232,48232,11,48680,48680,11,49128,49128,11,49576,49576,11,50024,50024,11,50472,50472,11,50920,50920,11,51368,51368,11,51816,51816,11,52264,52264,11,52712,52712,11,53160,53160,11,53608,53608,11,54056,54056,11,54504,54504,11,54952,54952,11,68108,68111,5,69933,69940,5,70197,70197,7,70498,70499,7,70845,70845,5,71229,71229,5,71727,71735,5,72154,72155,5,72344,72345,5,73023,73029,5,94095,94098,5,121403,121452,5,126981,127182,14,127538,127546,14,127990,127990,14,128391,128391,14,128445,128449,14,128500,128505,14,128752,128752,14,129160,129167,14,129356,129356,14,129432,129442,14,129648,129651,14,129751,131069,14,173,173,4,1757,1757,1,2274,2274,1,2494,2494,5,2641,2641,5,2876,2876,5,3014,3016,7,3262,3262,7,3393,3396,5,3570,3571,7,3968,3972,5,4228,4228,7,6086,6086,5,6679,6680,5,6912,6915,5,7080,7081,5,7380,7392,5,8252,8252,14,9096,9096,14,9748,9749,14,9784,9786,14,9833,9850,14,9890,9894,14,9938,9938,14,9999,9999,14,10085,10087,14,12349,12349,14,43136,43137,7,43454,43456,7,43755,43755,7,44088,44088,11,44312,44312,11,44536,44536,11,44760,44760,11,44984,44984,11,45208,45208,11,45432,45432,11,45656,45656,11,45880,45880,11,46104,46104,11,46328,46328,11,46552,46552,11,46776,46776,11,47000,47000,11,47224,47224,11,47448,47448,11,47672,47672,11,47896,47896,11,48120,48120,11,48344,48344,11,48568,48568,11,48792,48792,11,49016,49016,11,49240,49240,11,49464,49464,11,49688,49688,11,49912,49912,11,50136,50136,11,50360,50360,11,50584,50584,11,50808,50808,11,51032,51032,11,51256,51256,11,51480,51480,11,51704,51704,11,51928,51928,11,52152,52152,11,52376,52376,11,52600,52600,11,52824,52824,11,53048,53048,11,53272,53272,11,53496,53496,11,53720,53720,11,53944,53944,11,54168,54168,11,54392,54392,11,54616,54616,11,54840,54840,11,55064,55064,11,65438,65439,5,69633,69633,5,69837,69837,1,70018,70018,7,70188,70190,7,70368,70370,7,70465,70468,7,70712,70719,5,70835,70840,5,70850,70851,5,71132,71133,5,71340,71340,7,71458,71461,5,71985,71989,7,72002,72002,7,72193,72202,5,72281,72283,5,72766,72766,7,72885,72886,5,73104,73105,5,92912,92916,5,113824,113827,4,119173,119179,5,121505,121519,5,125136,125142,5,127279,127279,14,127489,127490,14,127570,127743,14,127900,127901,14,128254,128254,14,128369,128370,14,128400,128400,14,128425,128432,14,128468,128475,14,128489,128494,14,128715,128720,14,128745,128745,14,128759,128760,14,129004,129023,14,129296,129304,14,129340,129342,14,129388,129392,14,129404,129407,14,129454,129455,14,129485,129487,14,129659,129663,14,129719,129727,14,917536,917631,5,13,13,2,1160,1161,5,1564,1564,4,1807,1807,1,2085,2087,5,2363,2363,7,2402,2403,5,2507,2508,7,2622,2624,7,2691,2691,7,2786,2787,5,2881,2884,5,3006,3006,5,3072,3072,5,3170,3171,5,3267,3268,7,3330,3331,7,3406,3406,1,3538,3540,5,3655,3662,5,3897,3897,5,4038,4038,5,4184,4185,5,4352,4447,8,6068,6069,5,6155,6157,5,6448,6449,7,6742,6742,5,6783,6783,5,6966,6970,5,7042,7042,7,7143,7143,7,7212,7219,5,7412,7412,5,8206,8207,4,8294,8303,4,8596,8601,14,9410,9410,14,9742,9742,14,9757,9757,14,9770,9770,14,9794,9794,14,9828,9828,14,9855,9855,14,9882,9882,14,9900,9903,14,9929,9933,14,9963,9967,14,9987,9988,14,10006,10006,14,10062,10062,14,10175,10175,14,11744,11775,5,42607,42607,5,43043,43044,7,43263,43263,5,43444,43445,7,43569,43570,5,43698,43700,5,43766,43766,5,44032,44032,11,44144,44144,11,44256,44256,11,44368,44368,11,44480,44480,11,44592,44592,11,44704,44704,11,44816,44816,11,44928,44928,11,45040,45040,11,45152,45152,11,45264,45264,11,45376,45376,11,45488,45488,11,45600,45600,11,45712,45712,11,45824,45824,11,45936,45936,11,46048,46048,11,46160,46160,11,46272,46272,11,46384,46384,11,46496,46496,11,46608,46608,11,46720,46720,11,46832,46832,11,46944,46944,11,47056,47056,11,47168,47168,11,47280,47280,11,47392,47392,11,47504,47504,11,47616,47616,11,47728,47728,11,47840,47840,11,47952,47952,11,48064,48064,11,48176,48176,11,48288,48288,11,48400,48400,11,48512,48512,11,48624,48624,11,48736,48736,11,48848,48848,11,48960,48960,11,49072,49072,11,49184,49184,11,49296,49296,11,49408,49408,11,49520,49520,11,49632,49632,11,49744,49744,11,49856,49856,11,49968,49968,11,50080,50080,11,50192,50192,11,50304,50304,11,50416,50416,11,50528,50528,11,50640,50640,11,50752,50752,11,50864,50864,11,50976,50976,11,51088,51088,11,51200,51200,11,51312,51312,11,51424,51424,11,51536,51536,11,51648,51648,11,51760,51760,11,51872,51872,11,51984,51984,11,52096,52096,11,52208,52208,11,52320,52320,11,52432,52432,11,52544,52544,11,52656,52656,11,52768,52768,11,52880,52880,11,52992,52992,11,53104,53104,11,53216,53216,11,53328,53328,11,53440,53440,11,53552,53552,11,53664,53664,11,53776,53776,11,53888,53888,11,54000,54000,11,54112,54112,11,54224,54224,11,54336,54336,11,54448,54448,11,54560,54560,11,54672,54672,11,54784,54784,11,54896,54896,11,55008,55008,11,55120,55120,11,64286,64286,5,66272,66272,5,68900,68903,5,69762,69762,7,69817,69818,5,69927,69931,5,70003,70003,5,70070,70078,5,70094,70094,7,70194,70195,7,70206,70206,5,70400,70401,5,70463,70463,7,70475,70477,7,70512,70516,5,70722,70724,5,70832,70832,5,70842,70842,5,70847,70848,5,71088,71089,7,71102,71102,7,71219,71226,5,71231,71232,5,71342,71343,7,71453,71455,5,71463,71467,5,71737,71738,5,71995,71996,5,72000,72000,7,72145,72147,7,72160,72160,5,72249,72249,7,72273,72278,5,72330,72342,5,72752,72758,5,72850,72871,5,72882,72883,5,73018,73018,5,73031,73031,5,73109,73109,5,73461,73462,7,94031,94031,5,94192,94193,7,119142,119142,7,119155,119162,4,119362,119364,5,121476,121476,5,122888,122904,5,123184,123190,5,126976,126979,14,127184,127231,14,127344,127345,14,127405,127461,14,127514,127514,14,127561,127567,14,127778,127779,14,127896,127896,14,127985,127986,14,127995,127999,5,128326,128328,14,128360,128366,14,128378,128378,14,128394,128397,14,128405,128406,14,128422,128423,14,128435,128443,14,128453,128464,14,128479,128480,14,128484,128487,14,128496,128498,14,128640,128709,14,128723,128724,14,128736,128741,14,128747,128748,14,128755,128755,14,128762,128762,14,128981,128991,14,129096,129103,14,129292,129292,14,129311,129311,14,129329,129330,14,129344,129349,14,129360,129374,14,129394,129394,14,129402,129402,14,129413,129425,14,129445,129450,14,129466,129471,14,129483,129483,14,129511,129535,14,129653,129655,14,129667,129670,14,129705,129711,14,129731,129743,14,917505,917505,4,917760,917999,5,10,10,3,127,159,4,768,879,5,1471,1471,5,1536,1541,1,1648,1648,5,1767,1768,5,1840,1866,5,2070,2073,5,2137,2139,5,2307,2307,7,2366,2368,7,2382,2383,7,2434,2435,7,2497,2500,5,2519,2519,5,2563,2563,7,2631,2632,5,2677,2677,5,2750,2752,7,2763,2764,7,2817,2817,5,2879,2879,5,2891,2892,7,2914,2915,5,3008,3008,5,3021,3021,5,3076,3076,5,3146,3149,5,3202,3203,7,3264,3265,7,3271,3272,7,3298,3299,5,3390,3390,5,3402,3404,7,3426,3427,5,3535,3535,5,3544,3550,7,3635,3635,7,3763,3763,7,3893,3893,5,3953,3966,5,3981,3991,5,4145,4145,7,4157,4158,5,4209,4212,5,4237,4237,5,4520,4607,10,5970,5971,5,6071,6077,5,6089,6099,5,6277,6278,5,6439,6440,5,6451,6456,7,6683,6683,5,6744,6750,5,6765,6770,7,6846,6846,5,6964,6964,5,6972,6972,5,7019,7027,5,7074,7077,5,7083,7085,5,7146,7148,7,7154,7155,7,7222,7223,5,7394,7400,5,7416,7417,5,8204,8204,5,8233,8233,4,8288,8292,4,8413,8416,5,8482,8482,14,8986,8987,14,9193,9203,14,9654,9654,14,9733,9733,14,9745,9745,14,9752,9752,14,9760,9760,14,9766,9766,14,9774,9775,14,9792,9792,14,9800,9811,14,9825,9826,14,9831,9831,14,9852,9853,14,9872,9873,14,9880,9880,14,9885,9887,14,9896,9897,14,9906,9916,14,9926,9927,14,9936,9936,14,9941,9960,14,9974,9974,14,9982,9985,14,9992,9997,14,10002,10002,14,10017,10017,14,10055,10055,14,10071,10071,14,10145,10145,14,11013,11015,14,11503,11505,5,12334,12335,5,12951,12951,14,42612,42621,5,43014,43014,5,43047,43047,7,43204,43205,5,43335,43345,5,43395,43395,7,43450,43451,7,43561,43566,5,43573,43574,5,43644,43644,5,43710,43711,5,43758,43759,7,44005,44005,5,44012,44012,7,44060,44060,11,44116,44116,11,44172,44172,11,44228,44228,11,44284,44284,11,44340,44340,11,44396,44396,11,44452,44452,11,44508,44508,11,44564,44564,11,44620,44620,11,44676,44676,11,44732,44732,11,44788,44788,11,44844,44844,11,44900,44900,11,44956,44956,11,45012,45012,11,45068,45068,11,45124,45124,11,45180,45180,11,45236,45236,11,45292,45292,11,45348,45348,11,45404,45404,11,45460,45460,11,45516,45516,11,45572,45572,11,45628,45628,11,45684,45684,11,45740,45740,11,45796,45796,11,45852,45852,11,45908,45908,11,45964,45964,11,46020,46020,11,46076,46076,11,46132,46132,11,46188,46188,11,46244,46244,11,46300,46300,11,46356,46356,11,46412,46412,11,46468,46468,11,46524,46524,11,46580,46580,11,46636,46636,11,46692,46692,11,46748,46748,11,46804,46804,11,46860,46860,11,46916,46916,11,46972,46972,11,47028,47028,11,47084,47084,11,47140,47140,11,47196,47196,11,47252,47252,11,47308,47308,11,47364,47364,11,47420,47420,11,47476,47476,11,47532,47532,11,47588,47588,11,47644,47644,11,47700,47700,11,47756,47756,11,47812,47812,11,47868,47868,11,47924,47924,11,47980,47980,11,48036,48036,11,48092,48092,11,48148,48148,11,48204,48204,11,48260,48260,11,48316,48316,11,48372,48372,11,48428,48428,11,48484,48484,11,48540,48540,11,48596,48596,11,48652,48652,11,48708,48708,11,48764,48764,11,48820,48820,11,48876,48876,11,48932,48932,11,48988,48988,11,49044,49044,11,49100,49100,11,49156,49156,11,49212,49212,11,49268,49268,11,49324,49324,11,49380,49380,11,49436,49436,11,49492,49492,11,49548,49548,11,49604,49604,11,49660,49660,11,49716,49716,11,49772,49772,11,49828,49828,11,49884,49884,11,49940,49940,11,49996,49996,11,50052,50052,11,50108,50108,11,50164,50164,11,50220,50220,11,50276,50276,11,50332,50332,11,50388,50388,11,50444,50444,11,50500,50500,11,50556,50556,11,50612,50612,11,50668,50668,11,50724,50724,11,50780,50780,11,50836,50836,11,50892,50892,11,50948,50948,11,51004,51004,11,51060,51060,11,51116,51116,11,51172,51172,11,51228,51228,11,51284,51284,11,51340,51340,11,51396,51396,11,51452,51452,11,51508,51508,11,51564,51564,11,51620,51620,11,51676,51676,11,51732,51732,11,51788,51788,11,51844,51844,11,51900,51900,11,51956,51956,11,52012,52012,11,52068,52068,11,52124,52124,11,52180,52180,11,52236,52236,11,52292,52292,11,52348,52348,11,52404,52404,11,52460,52460,11,52516,52516,11,52572,52572,11,52628,52628,11,52684,52684,11,52740,52740,11,52796,52796,11,52852,52852,11,52908,52908,11,52964,52964,11,53020,53020,11,53076,53076,11,53132,53132,11,53188,53188,11,53244,53244,11,53300,53300,11,53356,53356,11,53412,53412,11,53468,53468,11,53524,53524,11,53580,53580,11,53636,53636,11,53692,53692,11,53748,53748,11,53804,53804,11,53860,53860,11,53916,53916,11,53972,53972,11,54028,54028,11,54084,54084,11,54140,54140,11,54196,54196,11,54252,54252,11,54308,54308,11,54364,54364,11,54420,54420,11,54476,54476,11,54532,54532,11,54588,54588,11,54644,54644,11,54700,54700,11,54756,54756,11,54812,54812,11,54868,54868,11,54924,54924,11,54980,54980,11,55036,55036,11,55092,55092,11,55148,55148,11,55216,55238,9,65056,65071,5,65529,65531,4,68097,68099,5,68159,68159,5,69446,69456,5,69688,69702,5,69808,69810,7,69815,69816,7,69821,69821,1,69888,69890,5,69932,69932,7,69957,69958,7,70016,70017,5,70067,70069,7,70079,70080,7,70089,70092,5,70095,70095,5,70191,70193,5,70196,70196,5,70198,70199,5,70367,70367,5,70371,70378,5,70402,70403,7,70462,70462,5,70464,70464,5,70471,70472,7,70487,70487,5,70502,70508,5,70709,70711,7,70720,70721,7,70725,70725,7,70750,70750,5,70833,70834,7,70841,70841,7,70843,70844,7,70846,70846,7,70849,70849,7,71087,71087,5,71090,71093,5,71100,71101,5,71103,71104,5,71216,71218,7,71227,71228,7,71230,71230,7,71339,71339,5,71341,71341,5,71344,71349,5,71351,71351,5,71456,71457,7,71462,71462,7,71724,71726,7,71736,71736,7,71984,71984,5,71991,71992,7,71997,71997,7,71999,71999,1,72001,72001,1,72003,72003,5,72148,72151,5,72156,72159,7,72164,72164,7,72243,72248,5,72250,72250,1,72263,72263,5,72279,72280,7,72324,72329,1,72343,72343,7,72751,72751,7,72760,72765,5,72767,72767,5,72873,72873,7,72881,72881,7,72884,72884,7,73009,73014,5,73020,73021,5,73030,73030,1,73098,73102,7,73107,73108,7,73110,73110,7,73459,73460,5,78896,78904,4,92976,92982,5,94033,94087,7,94180,94180,5,113821,113822,5,119141,119141,5,119143,119145,5,119150,119154,5,119163,119170,5,119210,119213,5,121344,121398,5,121461,121461,5,121499,121503,5,122880,122886,5,122907,122913,5,122918,122922,5,123628,123631,5,125252,125258,5,126980,126980,14,127183,127183,14,127245,127247,14,127340,127343,14,127358,127359,14,127377,127386,14,127462,127487,6,127491,127503,14,127535,127535,14,127548,127551,14,127568,127569,14,127744,127777,14,127780,127891,14,127894,127895,14,127897,127899,14,127902,127984,14,127987,127989,14,127991,127994,14,128000,128253,14,128255,128317,14,128329,128334,14,128336,128359,14,128367,128368,14,128371,128377,14,128379,128390,14,128392,128393,14,128398,128399,14,128401,128404,14,128407,128419,14,128421,128421,14,128424,128424,14,128433,128434,14,128444,128444,14,128450,128452,14,128465,128467,14,128476,128478,14,128481,128481,14,128483,128483,14,128488,128488,14,128495,128495,14,128499,128499,14,128506,128591,14,128710,128714,14,128721,128722,14,128725,128725,14,128728,128735,14,128742,128744,14,128746,128746,14,128749,128751,14,128753,128754,14,128756,128758,14,128761,128761,14,128763,128764,14,128884,128895,14,128992,129003,14,129036,129039,14,129114,129119,14,129198,129279,14,129293,129295,14,129305,129310,14,129312,129319,14,129328,129328,14,129331,129338,14,129343,129343,14,129351,129355,14,129357,129359,14,129375,129387,14,129393,129393,14,129395,129398,14,129401,129401,14,129403,129403,14,129408,129412,14,129426,129431,14,129443,129444,14,129451,129453,14,129456,129465,14,129472,129472,14,129475,129482,14,129484,129484,14,129488,129510,14,129536,129647,14,129652,129652,14,129656,129658,14,129664,129666,14,129671,129679,14,129686,129704,14,129712,129718,14,129728,129730,14,129744,129750,14,917504,917504,4,917506,917535,4,917632,917759,4,918000,921599,4,0,9,4,11,12,4,14,31,4,169,169,14,174,174,14,1155,1159,5,1425,1469,5,1473,1474,5,1479,1479,5,1552,1562,5,1611,1631,5,1750,1756,5,1759,1764,5,1770,1773,5,1809,1809,5,1958,1968,5,2045,2045,5,2075,2083,5,2089,2093,5,2259,2273,5,2275,2306,5,2362,2362,5,2364,2364,5,2369,2376,5,2381,2381,5,2385,2391,5,2433,2433,5,2492,2492,5,2495,2496,7,2503,2504,7,2509,2509,5,2530,2531,5,2561,2562,5,2620,2620,5,2625,2626,5,2635,2637,5,2672,2673,5,2689,2690,5,2748,2748,5,2753,2757,5,2761,2761,7,2765,2765,5,2810,2815,5,2818,2819,7,2878,2878,5,2880,2880,7,2887,2888,7,2893,2893,5,2903,2903,5,2946,2946,5,3007,3007,7,3009,3010,7,3018,3020,7,3031,3031,5,3073,3075,7,3134,3136,5,3142,3144,5,3157,3158,5,3201,3201,5,3260,3260,5,3263,3263,5,3266,3266,5,3270,3270,5,3274,3275,7,3285,3286,5,3328,3329,5,3387,3388,5,3391,3392,7,3398,3400,7,3405,3405,5,3415,3415,5,3457,3457,5,3530,3530,5,3536,3537,7,3542,3542,5,3551,3551,5,3633,3633,5,3636,3642,5,3761,3761,5,3764,3772,5,3864,3865,5,3895,3895,5,3902,3903,7,3967,3967,7,3974,3975,5,3993,4028,5,4141,4144,5,4146,4151,5,4155,4156,7,4182,4183,7,4190,4192,5,4226,4226,5,4229,4230,5,4253,4253,5,4448,4519,9,4957,4959,5,5938,5940,5,6002,6003,5,6070,6070,7,6078,6085,7,6087,6088,7,6109,6109,5,6158,6158,4,6313,6313,5,6435,6438,7,6441,6443,7,6450,6450,5,6457,6459,5,6681,6682,7,6741,6741,7,6743,6743,7,6752,6752,5,6757,6764,5,6771,6780,5,6832,6845,5,6847,6848,5,6916,6916,7,6965,6965,5,6971,6971,7,6973,6977,7,6979,6980,7,7040,7041,5,7073,7073,7,7078,7079,7,7082,7082,7,7142,7142,5,7144,7145,5,7149,7149,5,7151,7153,5,7204,7211,7,7220,7221,7,7376,7378,5,7393,7393,7,7405,7405,5,7415,7415,7,7616,7673,5,8203,8203,4,8205,8205,13,8232,8232,4,8234,8238,4,8265,8265,14,8293,8293,4,8400,8412,5,8417,8417,5,8421,8432,5,8505,8505,14,8617,8618,14,9000,9000,14,9167,9167,14,9208,9210,14,9642,9643,14,9664,9664,14,9728,9732,14,9735,9741,14,9743,9744,14,9746,9746,14,9750,9751,14,9753,9756,14,9758,9759,14,9761,9761,14,9764,9765,14,9767,9769,14,9771,9773,14,9776,9783,14,9787,9791,14,9793,9793,14,9795,9799,14,9812,9822,14,9824,9824,14,9827,9827,14,9829,9830,14,9832,9832,14,9851,9851,14,9854,9854,14,9856,9861,14,9874,9876,14,9878,9879,14,9881,9881,14,9883,9884,14,9888,9889,14,9895,9895,14,9898,9899,14,9904,9905,14,9917,9918,14,9924,9925,14,9928,9928,14,9934,9935,14,9937,9937,14,9939,9940,14,9961,9962,14,9968,9973,14,9975,9978,14,9981,9981,14,9986,9986,14,9989,9989,14,9998,9998,14,10000,10001,14,10004,10004,14,10013,10013,14,10024,10024,14,10052,10052,14,10060,10060,14,10067,10069,14,10083,10084,14,10133,10135,14,10160,10160,14,10548,10549,14,11035,11036,14,11093,11093,14,11647,11647,5,12330,12333,5,12336,12336,14,12441,12442,5,12953,12953,14,42608,42610,5,42654,42655,5,43010,43010,5,43019,43019,5,43045,43046,5,43052,43052,5,43188,43203,7,43232,43249,5,43302,43309,5,43346,43347,7,43392,43394,5,43443,43443,5,43446,43449,5,43452,43453,5,43493,43493,5,43567,43568,7,43571,43572,7,43587,43587,5,43597,43597,7,43696,43696,5,43703,43704,5,43713,43713,5,43756,43757,5,43765,43765,7,44003,44004,7,44006,44007,7,44009,44010,7,44013,44013,5,44033,44059,12,44061,44087,12,44089,44115,12,44117,44143,12,44145,44171,12,44173,44199,12,44201,44227,12,44229,44255,12,44257,44283,12,44285,44311,12,44313,44339,12,44341,44367,12,44369,44395,12,44397,44423,12,44425,44451,12,44453,44479,12,44481,44507,12,44509,44535,12,44537,44563,12,44565,44591,12,44593,44619,12,44621,44647,12,44649,44675,12,44677,44703,12,44705,44731,12,44733,44759,12,44761,44787,12,44789,44815,12,44817,44843,12,44845,44871,12,44873,44899,12,44901,44927,12,44929,44955,12,44957,44983,12,44985,45011,12,45013,45039,12,45041,45067,12,45069,45095,12,45097,45123,12,45125,45151,12,45153,45179,12,45181,45207,12,45209,45235,12,45237,45263,12,45265,45291,12,45293,45319,12,45321,45347,12,45349,45375,12,45377,45403,12,45405,45431,12,45433,45459,12,45461,45487,12,45489,45515,12,45517,45543,12,45545,45571,12,45573,45599,12,45601,45627,12,45629,45655,12,45657,45683,12,45685,45711,12,45713,45739,12,45741,45767,12,45769,45795,12,45797,45823,12,45825,45851,12,45853,45879,12,45881,45907,12,45909,45935,12,45937,45963,12,45965,45991,12,45993,46019,12,46021,46047,12,46049,46075,12,46077,46103,12,46105,46131,12,46133,46159,12,46161,46187,12,46189,46215,12,46217,46243,12,46245,46271,12,46273,46299,12,46301,46327,12,46329,46355,12,46357,46383,12,46385,46411,12,46413,46439,12,46441,46467,12,46469,46495,12,46497,46523,12,46525,46551,12,46553,46579,12,46581,46607,12,46609,46635,12,46637,46663,12,46665,46691,12,46693,46719,12,46721,46747,12,46749,46775,12,46777,46803,12,46805,46831,12,46833,46859,12,46861,46887,12,46889,46915,12,46917,46943,12,46945,46971,12,46973,46999,12,47001,47027,12,47029,47055,12,47057,47083,12,47085,47111,12,47113,47139,12,47141,47167,12,47169,47195,12,47197,47223,12,47225,47251,12,47253,47279,12,47281,47307,12,47309,47335,12,47337,47363,12,47365,47391,12,47393,47419,12,47421,47447,12,47449,47475,12,47477,47503,12,47505,47531,12,47533,47559,12,47561,47587,12,47589,47615,12,47617,47643,12,47645,47671,12,47673,47699,12,47701,47727,12,47729,47755,12,47757,47783,12,47785,47811,12,47813,47839,12,47841,47867,12,47869,47895,12,47897,47923,12,47925,47951,12,47953,47979,12,47981,48007,12,48009,48035,12,48037,48063,12,48065,48091,12,48093,48119,12,48121,48147,12,48149,48175,12,48177,48203,12,48205,48231,12,48233,48259,12,48261,48287,12,48289,48315,12,48317,48343,12,48345,48371,12,48373,48399,12,48401,48427,12,48429,48455,12,48457,48483,12,48485,48511,12,48513,48539,12,48541,48567,12,48569,48595,12,48597,48623,12,48625,48651,12,48653,48679,12,48681,48707,12,48709,48735,12,48737,48763,12,48765,48791,12,48793,48819,12,48821,48847,12,48849,48875,12,48877,48903,12,48905,48931,12,48933,48959,12,48961,48987,12,48989,49015,12,49017,49043,12,49045,49071,12,49073,49099,12,49101,49127,12,49129,49155,12,49157,49183,12,49185,49211,12,49213,49239,12,49241,49267,12,49269,49295,12,49297,49323,12,49325,49351,12,49353,49379,12,49381,49407,12,49409,49435,12,49437,49463,12,49465,49491,12,49493,49519,12,49521,49547,12,49549,49575,12,49577,49603,12,49605,49631,12,49633,49659,12,49661,49687,12,49689,49715,12,49717,49743,12,49745,49771,12,49773,49799,12,49801,49827,12,49829,49855,12,49857,49883,12,49885,49911,12,49913,49939,12,49941,49967,12,49969,49995,12,49997,50023,12,50025,50051,12,50053,50079,12,50081,50107,12,50109,50135,12,50137,50163,12,50165,50191,12,50193,50219,12,50221,50247,12,50249,50275,12,50277,50303,12,50305,50331,12,50333,50359,12,50361,50387,12,50389,50415,12,50417,50443,12,50445,50471,12,50473,50499,12,50501,50527,12,50529,50555,12,50557,50583,12,50585,50611,12,50613,50639,12,50641,50667,12,50669,50695,12,50697,50723,12,50725,50751,12,50753,50779,12,50781,50807,12,50809,50835,12,50837,50863,12,50865,50891,12,50893,50919,12,50921,50947,12,50949,50975,12,50977,51003,12,51005,51031,12,51033,51059,12,51061,51087,12,51089,51115,12,51117,51143,12,51145,51171,12,51173,51199,12,51201,51227,12,51229,51255,12,51257,51283,12,51285,51311,12,51313,51339,12,51341,51367,12,51369,51395,12,51397,51423,12,51425,51451,12,51453,51479,12,51481,51507,12,51509,51535,12,51537,51563,12,51565,51591,12,51593,51619,12,51621,51647,12,51649,51675,12,51677,51703,12,51705,51731,12,51733,51759,12,51761,51787,12,51789,51815,12,51817,51843,12,51845,51871,12,51873,51899,12,51901,51927,12,51929,51955,12,51957,51983,12,51985,52011,12,52013,52039,12,52041,52067,12,52069,52095,12,52097,52123,12,52125,52151,12,52153,52179,12,52181,52207,12,52209,52235,12,52237,52263,12,52265,52291,12,52293,52319,12,52321,52347,12,52349,52375,12,52377,52403,12,52405,52431,12,52433,52459,12,52461,52487,12,52489,52515,12,52517,52543,12,52545,52571,12,52573,52599,12,52601,52627,12,52629,52655,12,52657,52683,12,52685,52711,12,52713,52739,12,52741,52767,12,52769,52795,12,52797,52823,12,52825,52851,12,52853,52879,12,52881,52907,12,52909,52935,12,52937,52963,12,52965,52991,12,52993,53019,12,53021,53047,12,53049,53075,12,53077,53103,12,53105,53131,12,53133,53159,12,53161,53187,12,53189,53215,12,53217,53243,12,53245,53271,12,53273,53299,12,53301,53327,12,53329,53355,12,53357,53383,12,53385,53411,12,53413,53439,12,53441,53467,12,53469,53495,12,53497,53523,12,53525,53551,12,53553,53579,12,53581,53607,12,53609,53635,12,53637,53663,12,53665,53691,12,53693,53719,12,53721,53747,12,53749,53775,12,53777,53803,12,53805,53831,12,53833,53859,12,53861,53887,12,53889,53915,12,53917,53943,12,53945,53971,12,53973,53999,12,54001,54027,12,54029,54055,12,54057,54083,12,54085,54111,12,54113,54139,12,54141,54167,12,54169,54195,12,54197,54223,12,54225,54251,12,54253,54279,12,54281,54307,12,54309,54335,12,54337,54363,12,54365,54391,12,54393,54419,12,54421,54447,12,54449,54475,12,54477,54503,12,54505,54531,12,54533,54559,12,54561,54587,12,54589,54615,12,54617,54643,12,54645,54671,12,54673,54699,12,54701,54727,12,54729,54755,12,54757,54783,12,54785,54811,12,54813,54839,12,54841,54867,12,54869,54895,12,54897,54923,12,54925,54951,12,54953,54979,12,54981,55007,12,55009,55035,12,55037,55063,12,55065,55091,12,55093,55119,12,55121,55147,12,55149,55175,12,55177,55203,12,55243,55291,10,65024,65039,5,65279,65279,4,65520,65528,4,66045,66045,5,66422,66426,5,68101,68102,5,68152,68154,5,68325,68326,5,69291,69292,5,69632,69632,7,69634,69634,7,69759,69761,5]")}function ve(ee,xe){if(ee===0)return 0;const $e=nt(ee,xe);if($e!==void 0)return $e;const Ye=X(xe,ee);return ee-=_t(Ye),ee}function nt(ee,xe){let $e=X(xe,ee);for(ee-=_t($e);lt($e)||$e===65039||$e===8419;){if(ee===0)return;$e=X(xe,ee),ee-=_t($e)}if(Mt($e)){if(ee>=0){const Ye=X(xe,ee);Ye===8205&&(ee-=_t(Ye))}return ee}}function _t(ee){return ee>=65536?2:1}function lt(ee){return 127995<=ee&&ee<=127999}},72999:function(Li,Rt,oe){"use strict";oe.d(Rt,{$E:function(){return O},$K:function(){return Te},D8:function(){return k},HD:function(){return De},IU:function(){return Y},Jp:function(){return P},Kn:function(){return qe},cW:function(){return ne},f6:function(){return H},hj:function(){return ge},jn:function(){return q},kJ:function(){return ce},mf:function(){return I},o8:function(){return S},p_:function(){return d},vE:function(){return j}});function ce(U){return Array.isArray(U)}function De(U){return typeof U=="string"}function qe(U){return typeof U=="object"&&U!==null&&!Array.isArray(U)&&!(U instanceof RegExp)&&!(U instanceof Date)}function ge(U){return typeof U=="number"&&!isNaN(U)}function q(U){return U===!0||U===!1}function S(U){return typeof U=="undefined"}function Te(U){return!P(U)}function P(U){return S(U)||U===null}function d(U,$){if(!U)throw new Error($?`Unexpected type, expected '${$}'`:"Unexpected type")}function ne(U){if(P(U))throw new Error("Assertion Failed: argument is undefined or null");return U}function I(U){return typeof U=="function"}function k(U,$){const G=Math.min(U.length,$.length);for(let he=0;he<G;he++)T(U[he],$[he])}function T(U,$){if(De($)){if(typeof U!==$)throw new Error(`argument does not match constraint: typeof ${$}`)}else if(I($)){try{if(U instanceof $)return}catch(G){}if(!P(U)&&U.constructor===$||$.length===1&&$.call(void 0,U)===!0)return;throw new Error("argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}function M(U){let $=[],G=Object.getPrototypeOf(U);for(;Object.prototype!==G;)$=$.concat(Object.getOwnPropertyNames(G)),G=Object.getPrototypeOf(G);return $}function O(U){const $=[];for(const G of M(U))typeof U[G]=="function"&&$.push(G);return $}function Y(U,$){const G=be=>function(){const Se=Array.prototype.slice.call(arguments,0);return $(be,Se)};let he={};for(const be of U)he[be]=G(be);return he}function H(U){return U===null?void 0:U}function j(U,$="Unreachable"){throw new Error($)}},13268:function(Li,Rt,oe){"use strict";oe.d(Rt,{N:function(){return De}});function ce(qe,ge){let q;return ge.length===0?q=qe:q=qe.replace(/\{(\d+)\}/g,function(S,Te){const P=Te[0];return typeof ge[P]!="undefined"?ge[P]:S}),q}function De(qe,ge,...q){return ce(ge,q)}},96236:function(Li,Rt,oe){"use strict";oe.d(Rt,{BH:function(){return Y},NZ:function(){return H},U8:function(){return j},co:function(){return O},eH:function(){return M},vr:function(){return T}});var ce=oe(75918),De=oe(52615),qe=oe(4348),ge=oe(88226),q=oe(69323),S=oe(34502),Te=oe(35884),P=oe(90689),d=oe(16925),ne=oe(49055),I=function(U,$,G,he){var be=arguments.length,Se=be<3?$:he===null?he=Object.getOwnPropertyDescriptor($,G):he,re;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Se=Reflect.decorate(U,$,G,he);else for(var Oe=U.length-1;Oe>=0;Oe--)(re=U[Oe])&&(Se=(be<3?re(Se):be>3?re($,G,Se):re($,G))||Se);return be>3&&Se&&Object.defineProperty($,G,Se),Se},k=function(U,$){return function(G,he){$(G,he,U)}};function T(U){return U.command!==void 0}class M{constructor($){this.id=M._idPool++,this._debugName=$}}M._idPool=0,M.CommandPalette=new M("CommandPalette"),M.EditorContext=new M("EditorContext"),M.SimpleEditorContext=new M("SimpleEditorContext"),M.EditorContextCopy=new M("EditorContextCopy"),M.EditorContextPeek=new M("EditorContextPeek"),M.MenubarEditMenu=new M("MenubarEditMenu"),M.MenubarCopy=new M("MenubarCopy"),M.MenubarGoMenu=new M("MenubarGoMenu"),M.MenubarSelectionMenu=new M("MenubarSelectionMenu"),M.InlineCompletionsActions=new M("InlineCompletionsActions");const O=(0,d.yh)("menuService"),Y=new class{constructor(){this._commands=new Map,this._menuItems=new Map,this._onDidChangeMenu=new qe.Q5,this.onDidChangeMenu=this._onDidChangeMenu.event,this._commandPaletteChangeEvent={has:U=>U===M.CommandPalette}}addCommand(U){return this.addCommands(ge.$.single(U))}addCommands(U){for(const $ of U)this._commands.set($.id,$);return this._onDidChangeMenu.fire(this._commandPaletteChangeEvent),(0,q.OF)(()=>{let $=!1;for(const G of U)$=this._commands.delete(G.id)||$;$&&this._onDidChangeMenu.fire(this._commandPaletteChangeEvent)})}getCommand(U){return this._commands.get(U)}getCommands(){const U=new Map;return this._commands.forEach(($,G)=>U.set(G,$)),U}appendMenuItem(U,$){return this.appendMenuItems(ge.$.single({id:U,item:$}))}appendMenuItems(U){const $=new Set,G=new S.S;for(const{id:he,item:be}of U){let Se=this._menuItems.get(he);Se||(Se=new S.S,this._menuItems.set(he,Se)),G.push(Se.push(be)),$.add(he)}return this._onDidChangeMenu.fire($),(0,q.OF)(()=>{if(G.size>0){for(let he of G)he();this._onDidChangeMenu.fire($),G.clear()}})}getMenuItems(U){let $;return this._menuItems.has(U)?$=[...this._menuItems.get(U)]:$=[],U===M.CommandPalette&&this._appendImplicitItems($),$}_appendImplicitItems(U){const $=new Set;for(const G of U)T(G)&&($.add(G.command.id),G.alt&&$.add(G.alt.id));this._commands.forEach((G,he)=>{$.has(he)||U.push({command:G})})}};class H extends ce.wY{constructor($,G,he,be){super(`submenuitem.${$.submenu.id}`,typeof $.title=="string"?$.title:$.title.value,[],"submenu"),this.item=$,this._menuService=G,this._contextKeyService=he,this._options=be}get actions(){const $=[],G=this._menuService.createMenu(this.item.submenu,this._contextKeyService),he=G.getActions(this._options);G.dispose();for(const[,be]of he)be.length>0&&($.push(...be),$.push(new ce.Z0));return $.length&&$.pop(),$}}let j=class $p{constructor($,G,he,be,Se){var re,Oe;if(this._commandService=Se,this.id=$.id,this.label=he!=null&&he.renderShortTitle&&$.shortTitle?typeof $.shortTitle=="string"?$.shortTitle:$.shortTitle.value:typeof $.title=="string"?$.title:$.title.value,this.tooltip=(Oe=typeof $.tooltip=="string"?$.tooltip:(re=$.tooltip)===null||re===void 0?void 0:re.value)!==null&&Oe!==void 0?Oe:"",this.enabled=!$.precondition||be.contextMatchesRules($.precondition),this.checked=void 0,$.toggled){const We=$.toggled.condition?$.toggled:{condition:$.toggled};this.checked=be.contextMatchesRules(We.condition),this.checked&&We.tooltip&&(this.tooltip=typeof We.tooltip=="string"?We.tooltip:We.tooltip.value),We.title&&(this.label=typeof We.title=="string"?We.title:We.title.value)}this.item=$,this.alt=G?new $p(G,void 0,he,be,Se):void 0,this._options=he,ne.kS.isThemeIcon($.icon)&&(this.class=De.dT.asClassName($.icon))}dispose(){}run(...$){var G,he;let be=[];return!((G=this._options)===null||G===void 0)&&G.arg&&(be=[...be,this._options.arg]),!((he=this._options)===null||he===void 0)&&he.shouldForwardArgs&&(be=[...be,...$]),this._commandService.executeCommand(this.id,...be)}};j=I([k(3,P.i6),k(4,Te.H)],j)},35884:function(Li,Rt,oe){"use strict";oe.d(Rt,{H:function(){return Te},P:function(){return P}});var ce=oe(4348),De=oe(88226),qe=oe(69323),ge=oe(34502),q=oe(72999),S=oe(16925);const Te=(0,S.yh)("commandService"),P=new class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new ce.Q5,this.onDidRegisterCommand=this._onDidRegisterCommand.event}registerCommand(d,ne){if(!d)throw new Error("invalid command");if(typeof d=="string"){if(!ne)throw new Error("invalid command");return this.registerCommand({id:d,handler:ne})}if(d.description){const O=[];for(let H of d.description.args)O.push(H.constraint);const Y=d.handler;d.handler=function(H,...j){return(0,q.D8)(j,O),Y(H,...j)}}const{id:I}=d;let k=this._commands.get(I);k||(k=new ge.S,this._commands.set(I,k));let T=k.unshift(d),M=(0,qe.OF)(()=>{T();const O=this._commands.get(I);O!=null&&O.isEmpty()&&this._commands.delete(I)});return this._onDidRegisterCommand.fire(I),M}registerCommandAlias(d,ne){return P.registerCommand(d,(I,...k)=>I.get(Te).executeCommand(ne,...k))}getCommand(d){const ne=this._commands.get(d);if(!(!ne||ne.isEmpty()))return De.$.first(ne)}getCommands(){const d=new Map;for(const ne of this._commands.keys()){const I=this.getCommand(ne);I&&d.set(ne,I)}return d}};P.registerCommand("noop",()=>{})},90689:function(Li,Rt,oe){"use strict";oe.d(Rt,{Ao:function(){return Te},Eq:function(){return te},Fb:function(){return P},K8:function(){return J},i6:function(){return Dt},uy:function(){return Be}});var ce=oe(23345),De=oe(82983),qe=oe(16925);let ge=ce.WE||"";const q=new Map;q.set("false",!1),q.set("true",!0),q.set("isMac",ce.dz),q.set("isLinux",ce.IJ),q.set("isWindows",ce.ED),q.set("isWeb",ce.$L),q.set("isMacNative",ce.dz&&!ce.$L),q.set("isEdge",ge.indexOf("Edg/")>=0),q.set("isFirefox",ge.indexOf("Firefox")>=0),q.set("isChrome",ge.indexOf("Chrome")>=0),q.set("isSafari",ge.indexOf("Safari")>=0);const S=Object.prototype.hasOwnProperty;class Te{static has(A){return k.create(A)}static equals(A,L){return T.create(A,L)}static regex(A,L){return be.create(A,L)}static not(A){return H.create(A)}static and(...A){return Oe.create(A,null)}static or(...A){return We.create(A,null,!0)}static deserialize(A,L=!1){if(A)return this._deserializeOrExpression(A,L)}static _deserializeOrExpression(A,L){let V=A.split("||");return We.create(V.map(pe=>this._deserializeAndExpression(pe,L)),null,!0)}static _deserializeAndExpression(A,L){let V=A.split("&&");return Oe.create(V.map(pe=>this._deserializeOne(pe,L)),null)}static _deserializeOne(A,L){if(A=A.trim(),A.indexOf("!=")>=0){let V=A.split("!=");return Y.create(V[0].trim(),this._deserializeValue(V[1],L))}if(A.indexOf("==")>=0){let V=A.split("==");return T.create(V[0].trim(),this._deserializeValue(V[1],L))}if(A.indexOf("=~")>=0){let V=A.split("=~");return be.create(V[0].trim(),this._deserializeRegexValue(V[1],L))}if(A.indexOf(" in ")>=0){let V=A.split(" in ");return M.create(V[0].trim(),V[1].trim())}if(/^[^<=>]+>=[^<=>]+$/.test(A)){const V=A.split(">=");return $.create(V[0].trim(),V[1].trim())}if(/^[^<=>]+>[^<=>]+$/.test(A)){const V=A.split(">");return U.create(V[0].trim(),V[1].trim())}if(/^[^<=>]+<=[^<=>]+$/.test(A)){const V=A.split("<=");return he.create(V[0].trim(),V[1].trim())}if(/^[^<=>]+<[^<=>]+$/.test(A)){const V=A.split("<");return G.create(V[0].trim(),V[1].trim())}return/^\!\s*/.test(A)?H.create(A.substr(1).trim()):k.create(A)}static _deserializeValue(A,L){if(A=A.trim(),A==="true")return!0;if(A==="false")return!1;let V=/^'([^']*)'$/.exec(A);return V?V[1].trim():A}static _deserializeRegexValue(A,L){if((0,De.m5)(A)){if(L)throw new Error("missing regexp-value for =~-expression");return console.warn("missing regexp-value for =~-expression"),null}let V=A.indexOf("/"),pe=A.lastIndexOf("/");if(V===pe||V<0){if(L)throw new Error(`bad regexp-value '${A}', missing /-enclosure`);return console.warn(`bad regexp-value '${A}', missing /-enclosure`),null}let ze=A.slice(V+1,pe),at=A[pe+1]==="i"?"i":"";try{return new RegExp(ze,at)}catch(Ot){if(L)throw new Error(`bad regexp-value '${A}', parse error: ${Ot}`);return console.warn(`bad regexp-value '${A}', parse error: ${Ot}`),null}}}function P(ie,A){const L=ie?ie.substituteConstants():void 0,V=A?A.substituteConstants():void 0;return!L&&!V?!0:!L||!V?!1:L.equals(V)}function d(ie,A){return ie.cmp(A)}class ne{constructor(){this.type=0}cmp(A){return this.type-A.type}equals(A){return A.type===this.type}substituteConstants(){return this}evaluate(A){return!1}serialize(){return"false"}keys(){return[]}negate(){return I.INSTANCE}}ne.INSTANCE=new ne;class I{constructor(){this.type=1}cmp(A){return this.type-A.type}equals(A){return A.type===this.type}substituteConstants(){return this}evaluate(A){return!0}serialize(){return"true"}keys(){return[]}negate(){return ne.INSTANCE}}I.INSTANCE=new I;class k{constructor(A,L){this.key=A,this.negated=L,this.type=2}static create(A,L=null){const V=q.get(A);return typeof V=="boolean"?V?I.INSTANCE:ne.INSTANCE:new k(A,L)}cmp(A){return A.type!==this.type?this.type-A.type:z(this.key,A.key)}equals(A){return A.type===this.type?this.key===A.key:!1}substituteConstants(){const A=q.get(this.key);return typeof A=="boolean"?A?I.INSTANCE:ne.INSTANCE:this}evaluate(A){return!!A.getValue(this.key)}serialize(){return this.key}keys(){return[this.key]}negate(){return this.negated||(this.negated=H.create(this.key,this)),this.negated}}class T{constructor(A,L,V){this.key=A,this.value=L,this.negated=V,this.type=4}static create(A,L,V=null){if(typeof L=="boolean")return L?k.create(A,V):H.create(A,V);const pe=q.get(A);return typeof pe=="boolean"?L===(pe?"true":"false")?I.INSTANCE:ne.INSTANCE:new T(A,L,V)}cmp(A){return A.type!==this.type?this.type-A.type:X(this.key,this.value,A.key,A.value)}equals(A){return A.type===this.type?this.key===A.key&&this.value===A.value:!1}substituteConstants(){const A=q.get(this.key);if(typeof A=="boolean"){const L=A?"true":"false";return this.value===L?I.INSTANCE:ne.INSTANCE}return this}evaluate(A){return A.getValue(this.key)==this.value}serialize(){return`${this.key} == '${this.value}'`}keys(){return[this.key]}negate(){return this.negated||(this.negated=Y.create(this.key,this.value,this)),this.negated}}class M{constructor(A,L){this.key=A,this.valueKey=L,this.type=10,this.negated=null}static create(A,L){return new M(A,L)}cmp(A){return A.type!==this.type?this.type-A.type:X(this.key,this.valueKey,A.key,A.valueKey)}equals(A){return A.type===this.type?this.key===A.key&&this.valueKey===A.valueKey:!1}substituteConstants(){return this}evaluate(A){const L=A.getValue(this.valueKey),V=A.getValue(this.key);return Array.isArray(L)?L.indexOf(V)>=0:typeof V=="string"&&typeof L=="object"&&L!==null?S.call(L,V):!1}serialize(){return`${this.key} in '${this.valueKey}'`}keys(){return[this.key,this.valueKey]}negate(){return this.negated||(this.negated=O.create(this)),this.negated}}class O{constructor(A){this._actual=A,this.type=11}static create(A){return new O(A)}cmp(A){return A.type!==this.type?this.type-A.type:this._actual.cmp(A._actual)}equals(A){return A.type===this.type?this._actual.equals(A._actual):!1}substituteConstants(){return this}evaluate(A){return!this._actual.evaluate(A)}serialize(){throw new Error("Method not implemented.")}keys(){return this._actual.keys()}negate(){return this._actual}}class Y{constructor(A,L,V){this.key=A,this.value=L,this.negated=V,this.type=5}static create(A,L,V=null){if(typeof L=="boolean")return L?H.create(A,V):k.create(A,V);const pe=q.get(A);return typeof pe=="boolean"?L===(pe?"true":"false")?ne.INSTANCE:I.INSTANCE:new Y(A,L,V)}cmp(A){return A.type!==this.type?this.type-A.type:X(this.key,this.value,A.key,A.value)}equals(A){return A.type===this.type?this.key===A.key&&this.value===A.value:!1}substituteConstants(){const A=q.get(this.key);if(typeof A=="boolean"){const L=A?"true":"false";return this.value===L?ne.INSTANCE:I.INSTANCE}return this}evaluate(A){return A.getValue(this.key)!=this.value}serialize(){return`${this.key} != '${this.value}'`}keys(){return[this.key]}negate(){return this.negated||(this.negated=T.create(this.key,this.value,this)),this.negated}}class H{constructor(A,L){this.key=A,this.negated=L,this.type=3}static create(A,L=null){const V=q.get(A);return typeof V=="boolean"?V?ne.INSTANCE:I.INSTANCE:new H(A,L)}cmp(A){return A.type!==this.type?this.type-A.type:z(this.key,A.key)}equals(A){return A.type===this.type?this.key===A.key:!1}substituteConstants(){const A=q.get(this.key);return typeof A=="boolean"?A?ne.INSTANCE:I.INSTANCE:this}evaluate(A){return!A.getValue(this.key)}serialize(){return`!${this.key}`}keys(){return[this.key]}negate(){return this.negated||(this.negated=k.create(this.key,this)),this.negated}}function j(ie,A){if(typeof ie=="string"){const L=parseFloat(ie);isNaN(L)||(ie=L)}return typeof ie=="string"||typeof ie=="number"?A(ie):ne.INSTANCE}class U{constructor(A,L,V){this.key=A,this.value=L,this.negated=V,this.type=12}static create(A,L,V=null){return j(L,pe=>new U(A,pe,V))}cmp(A){return A.type!==this.type?this.type-A.type:X(this.key,this.value,A.key,A.value)}equals(A){return A.type===this.type?this.key===A.key&&this.value===A.value:!1}substituteConstants(){return this}evaluate(A){return typeof this.value=="string"?!1:parseFloat(A.getValue(this.key))>this.value}serialize(){return`${this.key} > ${this.value}`}keys(){return[this.key]}negate(){return this.negated||(this.negated=he.create(this.key,this.value,this)),this.negated}}class ${constructor(A,L,V){this.key=A,this.value=L,this.negated=V,this.type=13}static create(A,L,V=null){return j(L,pe=>new $(A,pe,V))}cmp(A){return A.type!==this.type?this.type-A.type:X(this.key,this.value,A.key,A.value)}equals(A){return A.type===this.type?this.key===A.key&&this.value===A.value:!1}substituteConstants(){return this}evaluate(A){return typeof this.value=="string"?!1:parseFloat(A.getValue(this.key))>=this.value}serialize(){return`${this.key} >= ${this.value}`}keys(){return[this.key]}negate(){return this.negated||(this.negated=G.create(this.key,this.value,this)),this.negated}}class G{constructor(A,L,V){this.key=A,this.value=L,this.negated=V,this.type=14}static create(A,L,V=null){return j(L,pe=>new G(A,pe,V))}cmp(A){return A.type!==this.type?this.type-A.type:X(this.key,this.value,A.key,A.value)}equals(A){return A.type===this.type?this.key===A.key&&this.value===A.value:!1}substituteConstants(){return this}evaluate(A){return typeof this.value=="string"?!1:parseFloat(A.getValue(this.key))<this.value}serialize(){return`${this.key} < ${this.value}`}keys(){return[this.key]}negate(){return this.negated||(this.negated=$.create(this.key,this.value,this)),this.negated}}class he{constructor(A,L,V){this.key=A,this.value=L,this.negated=V,this.type=15}static create(A,L,V=null){return j(L,pe=>new he(A,pe,V))}cmp(A){return A.type!==this.type?this.type-A.type:X(this.key,this.value,A.key,A.value)}equals(A){return A.type===this.type?this.key===A.key&&this.value===A.value:!1}substituteConstants(){return this}evaluate(A){return typeof this.value=="string"?!1:parseFloat(A.getValue(this.key))<=this.value}serialize(){return`${this.key} <= ${this.value}`}keys(){return[this.key]}negate(){return this.negated||(this.negated=U.create(this.key,this.value,this)),this.negated}}class be{constructor(A,L){this.key=A,this.regexp=L,this.type=7,this.negated=null}static create(A,L){return new be(A,L)}cmp(A){if(A.type!==this.type)return this.type-A.type;if(this.key<A.key)return-1;if(this.key>A.key)return 1;const L=this.regexp?this.regexp.source:"",V=A.regexp?A.regexp.source:"";return L<V?-1:L>V?1:0}equals(A){if(A.type===this.type){const L=this.regexp?this.regexp.source:"",V=A.regexp?A.regexp.source:"";return this.key===A.key&&L===V}return!1}substituteConstants(){return this}evaluate(A){let L=A.getValue(this.key);return this.regexp?this.regexp.test(L):!1}serialize(){const A=this.regexp?`/${this.regexp.source}/${this.regexp.ignoreCase?"i":""}`:"/invalid/";return`${this.key} =~ ${A}`}keys(){return[this.key]}negate(){return this.negated||(this.negated=Se.create(this)),this.negated}}class Se{constructor(A){this._actual=A,this.type=8}static create(A){return new Se(A)}cmp(A){return A.type!==this.type?this.type-A.type:this._actual.cmp(A._actual)}equals(A){return A.type===this.type?this._actual.equals(A._actual):!1}substituteConstants(){return this}evaluate(A){return!this._actual.evaluate(A)}serialize(){throw new Error("Method not implemented.")}keys(){return this._actual.keys()}negate(){return this._actual}}function re(ie){let A=null;for(let L=0,V=ie.length;L<V;L++){const pe=ie[L].substituteConstants();if(ie[L]!==pe&&A===null){A=[];for(let ze=0;ze<L;ze++)A[ze]=ie[ze]}A!==null&&(A[L]=pe)}return A===null?ie:A}class Oe{constructor(A,L){this.expr=A,this.negated=L,this.type=6}static create(A,L){return Oe._normalizeArr(A,L)}cmp(A){if(A.type!==this.type)return this.type-A.type;if(this.expr.length<A.expr.length)return-1;if(this.expr.length>A.expr.length)return 1;for(let L=0,V=this.expr.length;L<V;L++){const pe=d(this.expr[L],A.expr[L]);if(pe!==0)return pe}return 0}equals(A){if(A.type===this.type){if(this.expr.length!==A.expr.length)return!1;for(let L=0,V=this.expr.length;L<V;L++)if(!this.expr[L].equals(A.expr[L]))return!1;return!0}return!1}substituteConstants(){const A=re(this.expr);return A===this.expr?this:Oe.create(A,this.negated)}evaluate(A){for(let L=0,V=this.expr.length;L<V;L++)if(!this.expr[L].evaluate(A))return!1;return!0}static _normalizeArr(A,L){const V=[];let pe=!1;for(const ze of A)if(ze){if(ze.type===1){pe=!0;continue}if(ze.type===0)return ne.INSTANCE;if(ze.type===6){V.push(...ze.expr);continue}V.push(ze)}if(V.length===0&&pe)return I.INSTANCE;if(V.length!==0){if(V.length===1)return V[0];V.sort(d);for(let ze=1;ze<V.length;ze++)V[ze-1].equals(V[ze])&&(V.splice(ze,1),ze--);if(V.length===1)return V[0];for(;V.length>1;){const ze=V[V.length-1];if(ze.type!==9)break;V.pop();const at=V.pop(),Ot=V.length===0,Ce=We.create(ze.expr.map(jt=>Oe.create([jt,at],null)),null,Ot);Ce&&(V.push(Ce),V.sort(d))}return V.length===1?V[0]:new Oe(V,L)}}serialize(){return this.expr.map(A=>A.serialize()).join(" && ")}keys(){const A=[];for(let L of this.expr)A.push(...L.keys());return A}negate(){if(!this.negated){const A=[];for(let L of this.expr)A.push(L.negate());this.negated=We.create(A,this,!0)}return this.negated}}class We{constructor(A,L){this.expr=A,this.negated=L,this.type=9}static create(A,L,V){return We._normalizeArr(A,L,V)}cmp(A){if(A.type!==this.type)return this.type-A.type;if(this.expr.length<A.expr.length)return-1;if(this.expr.length>A.expr.length)return 1;for(let L=0,V=this.expr.length;L<V;L++){const pe=d(this.expr[L],A.expr[L]);if(pe!==0)return pe}return 0}equals(A){if(A.type===this.type){if(this.expr.length!==A.expr.length)return!1;for(let L=0,V=this.expr.length;L<V;L++)if(!this.expr[L].equals(A.expr[L]))return!1;return!0}return!1}substituteConstants(){const A=re(this.expr);return A===this.expr?this:We.create(A,this.negated,!1)}evaluate(A){for(let L=0,V=this.expr.length;L<V;L++)if(this.expr[L].evaluate(A))return!0;return!1}static _normalizeArr(A,L,V){let pe=[],ze=!1;if(A){for(let at=0,Ot=A.length;at<Ot;at++){const Ce=A[at];if(Ce){if(Ce.type===0){ze=!0;continue}if(Ce.type===1)return I.INSTANCE;if(Ce.type===9){pe=pe.concat(Ce.expr);continue}pe.push(Ce)}}if(pe.length===0&&ze)return ne.INSTANCE;pe.sort(d)}if(pe.length!==0){if(pe.length===1)return pe[0];for(let at=1;at<pe.length;at++)pe[at-1].equals(pe[at])&&(pe.splice(at,1),at--);if(pe.length===1)return pe[0];if(V){for(let at=0;at<pe.length;at++)for(let Ot=at+1;Ot<pe.length;Ot++)J(pe[at],pe[Ot])&&(pe.splice(Ot,1),Ot--);if(pe.length===1)return pe[0]}return new We(pe,L)}}serialize(){return this.expr.map(A=>A.serialize()).join(" || ")}keys(){const A=[];for(let L of this.expr)A.push(...L.keys());return A}negate(){if(!this.negated){let A=[];for(let L of this.expr)A.push(L.negate());for(;A.length>1;){const L=A.shift(),V=A.shift(),pe=[];for(const at of de(L))for(const Ot of de(V))pe.push(Oe.create([at,Ot],null));const ze=A.length===0;A.unshift(We.create(pe,null,ze))}this.negated=A[0]}return this.negated}}class Be extends k{constructor(A,L,V){super(A,null),this._defaultValue=L,typeof V=="object"?Be._info.push(Object.assign(Object.assign({},V),{key:A})):V!==!0&&Be._info.push({key:A,description:V,type:L!=null?typeof L:void 0})}static all(){return Be._info.values()}bindTo(A){return A.createKey(this.key,this._defaultValue)}getValue(A){return A.getContextKeyValue(this.key)}toNegated(){return this.negate()}isEqualTo(A){return T.create(this.key,A)}}Be._info=[];const Dt=(0,qe.yh)("contextKeyService"),te="setContext";function z(ie,A){return ie<A?-1:ie>A?1:0}function X(ie,A,L,V){return ie<L?-1:ie>L?1:A<V?-1:A>V?1:0}function J(ie,A){if(A.type===6&&ie.type!==9&&ie.type!==6){for(const pe of A.expr)if(ie.equals(pe))return!0}const L=ie.negate(),V=de(L).concat(de(A));V.sort(d);for(let pe=0;pe<V.length;pe++){const at=V[pe].negate();for(let Ot=pe+1;Ot<V.length;Ot++){const Ce=V[Ot];if(at.equals(Ce))return!0}}return!1}function de(ie){return ie.type===9?ie.expr:[ie]}},16925:function(Li,Rt,oe){"use strict";oe.d(Rt,{I8:function(){return ce},TG:function(){return De},jt:function(){return q},yh:function(){return ge}});var ce;(function(S){S.serviceIds=new Map,S.DI_TARGET="$di$target",S.DI_DEPENDENCIES="$di$dependencies";function Te(P){return P[S.DI_DEPENDENCIES]||[]}S.getServiceDependencies=Te})(ce||(ce={}));const De=ge("instantiationService");function qe(S,Te,P,d){Te[ce.DI_TARGET]===Te?Te[ce.DI_DEPENDENCIES].push({id:S,index:P,optional:d}):(Te[ce.DI_DEPENDENCIES]=[{id:S,index:P,optional:d}],Te[ce.DI_TARGET]=Te)}function ge(S){if(ce.serviceIds.has(S))return ce.serviceIds.get(S);const Te=function(P,d,ne){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");qe(Te,P,ne,!1)};return Te.toString=()=>S,ce.serviceIds.set(S,Te),Te}function q(S){return function(Te,P,d){if(arguments.length!==3)throw new Error("@optional-decorator can only be used to decorate a parameter");qe(S,Te,d,!0)}}},44650:function(Li,Rt,oe){"use strict";oe.d(Rt,{B:function(){return ge}});var ce=oe(76068),De=oe(72999);class qe{constructor(){this.data=new Map}add(S,Te){ce.ok(De.HD(S)),ce.ok(De.Kn(Te)),ce.ok(!this.data.has(S),"There is already an extension with this id"),this.data.set(S,Te)}as(S){return this.data.get(S)||null}}const ge=new qe},66213:function(Li,Rt,oe){"use strict";oe.d(Rt,{e:function(){return ce}});var ce;(function(De){De.DARK="dark",De.LIGHT="light",De.HIGH_CONTRAST="hc"})(ce||(ce={}))},49055:function(Li,Rt,oe){"use strict";oe.d(Rt,{EN:function(){return d},IP:function(){return k},Ic:function(){return O},XE:function(){return Te},bB:function(){return Y},kS:function(){return ne},m6:function(){return I}});var ce=oe(52615),De=oe(4348),qe=oe(69323),ge=oe(16925),q=oe(44650),S=oe(66213);const Te=(0,ge.yh)("themeService");var P;(function(H){function j(U){return U&&typeof U=="object"&&typeof U.id=="string"}H.isThemeColor=j})(P||(P={}));function d(H){return{id:H}}var ne;(function(H){function j(Se){return Se&&typeof Se=="object"&&typeof Se.id=="string"&&(typeof Se.color=="undefined"||P.isThemeColor(Se.color))}H.isThemeIcon=j;const U=new RegExp(`^\\$\\((${ce.dT.iconNameExpression}(?:${ce.dT.iconModifierExpression})?)\\)$`);function $(Se){const re=U.exec(Se);if(!re)return;let[,Oe]=re;return{id:Oe}}H.fromString=$;function G(Se,re){let Oe=Se.id;const We=Oe.lastIndexOf("~");return We!==-1&&(Oe=Oe.substring(0,We)),re&&(Oe=`${Oe}~${re}`),{id:Oe}}H.modify=G;function he(Se,re){var Oe,We;return Se.id===re.id&&((Oe=Se.color)===null||Oe===void 0?void 0:Oe.id)===((We=re.color)===null||We===void 0?void 0:We.id)}H.isEqual=he;function be(Se,re){return{id:Se.id,color:re?d(re):void 0}}H.asThemeIcon=be,H.asClassNameArray=ce.dT.asClassNameArray,H.asClassName=ce.dT.asClassName,H.asCSSSelector=ce.dT.asCSSSelector})(ne||(ne={}));function I(H){switch(H){case S.e.DARK:return"vs-dark";case S.e.HIGH_CONTRAST:return"hc-black";default:return"vs"}}const k={ThemingContribution:"base.contributions.theming"};class T{constructor(){this.themingParticipants=[],this.themingParticipants=[],this.onThemingParticipantAddedEmitter=new De.Q5}onColorThemeChange(j){return this.themingParticipants.push(j),this.onThemingParticipantAddedEmitter.fire(j),(0,qe.OF)(()=>{const U=this.themingParticipants.indexOf(j);this.themingParticipants.splice(U,1)})}getThemingParticipants(){return this.themingParticipants}}let M=new T;q.B.add(k.ThemingContribution,M);function O(H){return M.onColorThemeChange(H)}class Y extends qe.JT{constructor(j){super(),this.themeService=j,this.theme=j.getColorTheme(),this._register(this.themeService.onDidColorThemeChange(U=>this.onThemeChange(U)))}onThemeChange(j){this.theme=j,this.updateStyles()}updateStyles(){}}},16632:function(Li,Rt,oe){"use strict";var ce=oe(54476),De=oe(33885),qe=oe(20068),ge=oe(42978),q=oe(75931),S=oe(92310),Te=oe.n(S),P=oe(18929),d=oe(59301),ne=["prefixCls","className","style","checked","disabled","defaultChecked","type","title","onChange"],I=(0,d.forwardRef)(function(k,T){var M=k.prefixCls,O=M===void 0?"rc-checkbox":M,Y=k.className,H=k.style,j=k.checked,U=k.disabled,$=k.defaultChecked,G=$===void 0?!1:$,he=k.type,be=he===void 0?"checkbox":he,Se=k.title,re=k.onChange,Oe=(0,q.Z)(k,ne),We=(0,d.useRef)(null),Be=(0,d.useRef)(null),Dt=(0,P.Z)(G,{value:j}),te=(0,ge.Z)(Dt,2),z=te[0],X=te[1];(0,d.useImperativeHandle)(T,function(){return{focus:function(A){var L;(L=We.current)===null||L===void 0||L.focus(A)},blur:function(){var A;(A=We.current)===null||A===void 0||A.blur()},input:We.current,nativeElement:Be.current}});var J=Te()(O,Y,(0,qe.Z)((0,qe.Z)({},"".concat(O,"-checked"),z),"".concat(O,"-disabled"),U)),de=function(A){U||("checked"in k||X(A.target.checked),re==null||re({target:(0,De.Z)((0,De.Z)({},k),{},{type:be,checked:A.target.checked}),stopPropagation:function(){A.stopPropagation()},preventDefault:function(){A.preventDefault()},nativeEvent:A.nativeEvent}))};return d.createElement("span",{className:J,title:Se,style:H,ref:Be},d.createElement("input",(0,ce.Z)({},Oe,{className:"".concat(O,"-input"),ref:We,onChange:de,disabled:U,checked:!!z,type:be})),d.createElement("span",{className:"".concat(O,"-inner")}))});Rt.Z=I},96478:function(Li,Rt,oe){"use strict";oe.d(Rt,{Z:function(){return Se}});var ce=oe(54476),De=oe(20068),qe=oe(42978),ge=oe(75931),q=oe(65030),S=oe(92310),Te=oe.n(S),P=oe(8654),d=oe(59301),ne=oe(10228),I=oe(16089),k=ne.Z.ESC,T=ne.Z.TAB;function M(re){var Oe=re.visible,We=re.triggerRef,Be=re.onVisibleChange,Dt=re.autoFocus,te=re.overlayRef,z=d.useRef(!1),X=function(){if(Oe){var A,L;(A=We.current)===null||A===void 0||(L=A.focus)===null||L===void 0||L.call(A),Be==null||Be(!1)}},J=function(){var A;return(A=te.current)!==null&&A!==void 0&&A.focus?(te.current.focus(),z.current=!0,!0):!1},de=function(A){switch(A.keyCode){case k:X();break;case T:{var L=!1;z.current||(L=J()),L?A.preventDefault():X();break}}};d.useEffect(function(){return Oe?(window.addEventListener("keydown",de),Dt&&(0,I.Z)(J,3),function(){window.removeEventListener("keydown",de),z.current=!1}):function(){z.current=!1}},[Oe])}var O=(0,d.forwardRef)(function(re,Oe){var We=re.overlay,Be=re.arrow,Dt=re.prefixCls,te=(0,d.useMemo)(function(){var X;return typeof We=="function"?X=We():X=We,X},[We]),z=(0,P.sQ)(Oe,(0,P.C4)(te));return d.createElement(d.Fragment,null,Be&&d.createElement("div",{className:"".concat(Dt,"-arrow")}),d.cloneElement(te,{ref:(0,P.Yr)(te)?z:void 0}))}),Y=O,H={adjustX:1,adjustY:1},j=[0,0],U={topLeft:{points:["bl","tl"],overflow:H,offset:[0,-4],targetOffset:j},top:{points:["bc","tc"],overflow:H,offset:[0,-4],targetOffset:j},topRight:{points:["br","tr"],overflow:H,offset:[0,-4],targetOffset:j},bottomLeft:{points:["tl","bl"],overflow:H,offset:[0,4],targetOffset:j},bottom:{points:["tc","bc"],overflow:H,offset:[0,4],targetOffset:j},bottomRight:{points:["tr","br"],overflow:H,offset:[0,4],targetOffset:j}},$=U,G=["arrow","prefixCls","transitionName","animation","align","placement","placements","getPopupContainer","showAction","hideAction","overlayClassName","overlayStyle","visible","trigger","autoFocus","overlay","children","onVisibleChange"];function he(re,Oe){var We,Be=re.arrow,Dt=Be===void 0?!1:Be,te=re.prefixCls,z=te===void 0?"rc-dropdown":te,X=re.transitionName,J=re.animation,de=re.align,ie=re.placement,A=ie===void 0?"bottomLeft":ie,L=re.placements,V=L===void 0?$:L,pe=re.getPopupContainer,ze=re.showAction,at=re.hideAction,Ot=re.overlayClassName,Ce=re.overlayStyle,jt=re.visible,Mt=re.trigger,dt=Mt===void 0?["hover"]:Mt,Ti=re.autoFocus,fi=re.overlay,Yi=re.children,Kt=re.onVisibleChange,ln=(0,ge.Z)(re,G),Ne=d.useState(),Ge=(0,qe.Z)(Ne,2),ve=Ge[0],nt=Ge[1],_t="visible"in re?jt:ve,lt=d.useRef(null),ee=d.useRef(null),xe=d.useRef(null);d.useImperativeHandle(Oe,function(){return lt.current});var $e=function(zt){nt(zt),Kt==null||Kt(zt)};M({visible:_t,triggerRef:xe,onVisibleChange:$e,autoFocus:Ti,overlayRef:ee});var Ye=function(zt){var Ae=re.onOverlayClick;nt(!1),Ae&&Ae(zt)},rt=function(){return d.createElement(Y,{ref:ee,overlay:fi,prefixCls:z,arrow:Dt})},gt=function(){return typeof fi=="function"?rt:rt()},Yt=function(){var zt=re.minOverlayWidthMatchTrigger,Ae=re.alignPoint;return"minOverlayWidthMatchTrigger"in re?zt:!Ae},pt=function(){var zt=re.openClassName;return zt!==void 0?zt:"".concat(z,"-open")},ke=d.cloneElement(Yi,{className:Te()((We=Yi.props)===null||We===void 0?void 0:We.className,_t&&pt()),ref:(0,P.Yr)(Yi)?(0,P.sQ)(xe,(0,P.C4)(Yi)):void 0}),ht=at;return!ht&&dt.indexOf("contextMenu")!==-1&&(ht=["click"]),d.createElement(q.Z,(0,ce.Z)({builtinPlacements:V},ln,{prefixCls:z,ref:lt,popupClassName:Te()(Ot,(0,De.Z)({},"".concat(z,"-show-arrow"),Dt)),popupStyle:Ce,action:dt,showAction:ze,hideAction:ht,popupPlacement:A,popupAlign:de,popupTransitionName:X,popupAnimation:J,popupVisible:_t,stretch:Yt()?"minWidth":"",popup:gt(),onPopupVisibleChange:$e,onPopupClick:Ye,getPopupContainer:pe}),ke)}var be=d.forwardRef(he),Se=be},66003:function(Li,Rt,oe){"use strict";oe.d(Rt,{Z:function(){return Te}});var ce=oe(75931),De=oe(33885),qe=oe(76190),ge=oe(59301),q=["show"];function S(P,d){if(!d.max)return!0;var ne=d.strategy(P);return ne<=d.max}function Te(P,d){return ge.useMemo(function(){var ne={};d&&(ne.show=(0,qe.Z)(d)==="object"&&d.formatter?d.formatter:!!d),ne=(0,De.Z)((0,De.Z)({},ne),P);var I=ne,k=I.show,T=(0,ce.Z)(I,q);return(0,De.Z)((0,De.Z)({},T),{},{show:!!k,showFormatter:typeof k=="function"?k:void 0,strategy:T.strategy||function(M){return M.length}})},[P,d])}},36901:function(Li,Rt,oe){"use strict";oe.r(Rt),oe.d(Rt,{BaseInput:function(){return ne},default:function(){return $}});var ce=oe(33885),De=oe(54476),qe=oe(20068),ge=oe(76190),q=oe(92310),S=oe.n(q),Te=oe(59301),P=oe(30292),d=Te.forwardRef(function(G,he){var be,Se,re,Oe=G.inputElement,We=G.children,Be=G.prefixCls,Dt=G.prefix,te=G.suffix,z=G.addonBefore,X=G.addonAfter,J=G.className,de=G.style,ie=G.disabled,A=G.readOnly,L=G.focused,V=G.triggerFocus,pe=G.allowClear,ze=G.value,at=G.handleReset,Ot=G.hidden,Ce=G.classes,jt=G.classNames,Mt=G.dataAttrs,dt=G.styles,Ti=G.components,fi=G.onClear,Yi=We!=null?We:Oe,Kt=(Ti==null?void 0:Ti.affixWrapper)||"span",ln=(Ti==null?void 0:Ti.groupWrapper)||"span",Ne=(Ti==null?void 0:Ti.wrapper)||"span",Ge=(Ti==null?void 0:Ti.groupAddon)||"span",ve=(0,Te.useRef)(null),nt=function(tt){var ft;(ft=ve.current)!==null&&ft!==void 0&&ft.contains(tt.target)&&(V==null||V())},_t=(0,P.X3)(G),lt=(0,Te.cloneElement)(Yi,{value:ze,className:S()((be=Yi.props)===null||be===void 0?void 0:be.className,!_t&&(jt==null?void 0:jt.variant))||null}),ee=(0,Te.useRef)(null);if(Te.useImperativeHandle(he,function(){return{nativeElement:ee.current||ve.current}}),_t){var xe=null;if(pe){var $e=!ie&&!A&&ze,Ye="".concat(Be,"-clear-icon"),rt=(0,ge.Z)(pe)==="object"&&pe!==null&&pe!==void 0&&pe.clearIcon?pe.clearIcon:"\u2716";xe=Te.createElement("button",{type:"button",tabIndex:-1,onClick:function(tt){at==null||at(tt),fi==null||fi()},onMouseDown:function(tt){return tt.preventDefault()},className:S()(Ye,(0,qe.Z)((0,qe.Z)({},"".concat(Ye,"-hidden"),!$e),"".concat(Ye,"-has-suffix"),!!te))},rt)}var gt="".concat(Be,"-affix-wrapper"),Yt=S()(gt,(0,qe.Z)((0,qe.Z)((0,qe.Z)((0,qe.Z)((0,qe.Z)({},"".concat(Be,"-disabled"),ie),"".concat(gt,"-disabled"),ie),"".concat(gt,"-focused"),L),"".concat(gt,"-readonly"),A),"".concat(gt,"-input-with-clear-btn"),te&&pe&&ze),Ce==null?void 0:Ce.affixWrapper,jt==null?void 0:jt.affixWrapper,jt==null?void 0:jt.variant),pt=(te||pe)&&Te.createElement("span",{className:S()("".concat(Be,"-suffix"),jt==null?void 0:jt.suffix),style:dt==null?void 0:dt.suffix},xe,te);lt=Te.createElement(Kt,(0,De.Z)({className:Yt,style:dt==null?void 0:dt.affixWrapper,onClick:nt},Mt==null?void 0:Mt.affixWrapper,{ref:ve}),Dt&&Te.createElement("span",{className:S()("".concat(Be,"-prefix"),jt==null?void 0:jt.prefix),style:dt==null?void 0:dt.prefix},Dt),lt,pt)}if((0,P.He)(G)){var ke="".concat(Be,"-group"),ht="".concat(ke,"-addon"),Gt="".concat(ke,"-wrapper"),zt=S()("".concat(Be,"-wrapper"),ke,Ce==null?void 0:Ce.wrapper,jt==null?void 0:jt.wrapper),Ae=S()(Gt,(0,qe.Z)({},"".concat(Gt,"-disabled"),ie),Ce==null?void 0:Ce.group,jt==null?void 0:jt.groupWrapper);lt=Te.createElement(ln,{className:Ae,ref:ee},Te.createElement(Ne,{className:zt},z&&Te.createElement(Ge,{className:ht},z),lt,X&&Te.createElement(Ge,{className:ht},X)))}return Te.cloneElement(lt,{className:S()((Se=lt.props)===null||Se===void 0?void 0:Se.className,J)||null,style:(0,ce.Z)((0,ce.Z)({},(re=lt.props)===null||re===void 0?void 0:re.style),de),hidden:Ot})}),ne=d,I=oe(94480),k=oe(42978),T=oe(75931),M=oe(18929),O=oe(2738),Y=oe(66003),H=["autoComplete","onChange","onFocus","onBlur","onPressEnter","onKeyDown","onKeyUp","prefixCls","disabled","htmlSize","className","maxLength","suffix","showCount","count","type","classes","classNames","styles","onCompositionStart","onCompositionEnd"],j=(0,Te.forwardRef)(function(G,he){var be=G.autoComplete,Se=G.onChange,re=G.onFocus,Oe=G.onBlur,We=G.onPressEnter,Be=G.onKeyDown,Dt=G.onKeyUp,te=G.prefixCls,z=te===void 0?"rc-input":te,X=G.disabled,J=G.htmlSize,de=G.className,ie=G.maxLength,A=G.suffix,L=G.showCount,V=G.count,pe=G.type,ze=pe===void 0?"text":pe,at=G.classes,Ot=G.classNames,Ce=G.styles,jt=G.onCompositionStart,Mt=G.onCompositionEnd,dt=(0,T.Z)(G,H),Ti=(0,Te.useState)(!1),fi=(0,k.Z)(Ti,2),Yi=fi[0],Kt=fi[1],ln=(0,Te.useRef)(!1),Ne=(0,Te.useRef)(!1),Ge=(0,Te.useRef)(null),ve=(0,Te.useRef)(null),nt=function(Ft){Ge.current&&(0,P.nH)(Ge.current,Ft)},_t=(0,M.Z)(G.defaultValue,{value:G.value}),lt=(0,k.Z)(_t,2),ee=lt[0],xe=lt[1],$e=ee==null?"":String(ee),Ye=(0,Te.useState)(null),rt=(0,k.Z)(Ye,2),gt=rt[0],Yt=rt[1],pt=(0,Y.Z)(V,L),ke=pt.max||ie,ht=pt.strategy($e),Gt=!!ke&&ht>ke;(0,Te.useImperativeHandle)(he,function(){var Xe;return{focus:nt,blur:function(){var Le;(Le=Ge.current)===null||Le===void 0||Le.blur()},setSelectionRange:function(Le,ye,we){var K;(K=Ge.current)===null||K===void 0||K.setSelectionRange(Le,ye,we)},select:function(){var Le;(Le=Ge.current)===null||Le===void 0||Le.select()},input:Ge.current,nativeElement:((Xe=ve.current)===null||Xe===void 0?void 0:Xe.nativeElement)||Ge.current}}),(0,Te.useEffect)(function(){Ne.current&&(Ne.current=!1),Kt(function(Xe){return Xe&&X?!1:Xe})},[X]);var zt=function(Ft,Le,ye){var we=Le;if(!ln.current&&pt.exceedFormatter&&pt.max&&pt.strategy(Le)>pt.max){if(we=pt.exceedFormatter(Le,{max:pt.max}),Le!==we){var K,W;Yt([((K=Ge.current)===null||K===void 0?void 0:K.selectionStart)||0,((W=Ge.current)===null||W===void 0?void 0:W.selectionEnd)||0])}}else if(ye.source==="compositionEnd")return;xe(we),Ge.current&&(0,P.rJ)(Ge.current,Ft,Se,we)};(0,Te.useEffect)(function(){if(gt){var Xe;(Xe=Ge.current)===null||Xe===void 0||Xe.setSelectionRange.apply(Xe,(0,I.Z)(gt))}},[gt]);var Ae=function(Ft){zt(Ft,Ft.target.value,{source:"change"})},Me=function(Ft){ln.current=!1,zt(Ft,Ft.currentTarget.value,{source:"compositionEnd"}),Mt==null||Mt(Ft)},tt=function(Ft){We&&Ft.key==="Enter"&&!Ne.current&&(Ne.current=!0,We(Ft)),Be==null||Be(Ft)},ft=function(Ft){Ft.key==="Enter"&&(Ne.current=!1),Dt==null||Dt(Ft)},je=function(Ft){Kt(!0),re==null||re(Ft)},At=function(Ft){Ne.current&&(Ne.current=!1),Kt(!1),Oe==null||Oe(Ft)},Lt=function(Ft){xe(""),nt(),Ge.current&&(0,P.rJ)(Ge.current,Ft,Se)},vt=Gt&&"".concat(z,"-out-of-range"),Pt=function(){var Ft=(0,O.Z)(G,["prefixCls","onPressEnter","addonBefore","addonAfter","prefix","suffix","allowClear","defaultValue","showCount","count","classes","htmlSize","styles","classNames","onClear"]);return Te.createElement("input",(0,De.Z)({autoComplete:be},Ft,{onChange:Ae,onFocus:je,onBlur:At,onKeyDown:tt,onKeyUp:ft,className:S()(z,(0,qe.Z)({},"".concat(z,"-disabled"),X),Ot==null?void 0:Ot.input),style:Ce==null?void 0:Ce.input,ref:Ge,size:J,type:ze,onCompositionStart:function(ye){ln.current=!0,jt==null||jt(ye)},onCompositionEnd:Me}))},Ht=function(){var Ft=Number(ke)>0;if(A||pt.show){var Le=pt.showFormatter?pt.showFormatter({value:$e,count:ht,maxLength:ke}):"".concat(ht).concat(Ft?" / ".concat(ke):"");return Te.createElement(Te.Fragment,null,pt.show&&Te.createElement("span",{className:S()("".concat(z,"-show-count-suffix"),(0,qe.Z)({},"".concat(z,"-show-count-has-suffix"),!!A),Ot==null?void 0:Ot.count),style:(0,ce.Z)({},Ce==null?void 0:Ce.count)},Le),A)}return null};return Te.createElement(ne,(0,De.Z)({},dt,{prefixCls:z,className:S()(de,vt),handleReset:Lt,value:$e,focused:Yi,triggerFocus:nt,suffix:Ht(),disabled:X,classes:at,classNames:Ot,styles:Ce}),Pt())}),U=j,$=U},30292:function(Li,Rt,oe){"use strict";oe.d(Rt,{He:function(){return ce},X3:function(){return De},nH:function(){return q},rJ:function(){return ge}});function ce(S){return!!(S.addonBefore||S.addonAfter)}function De(S){return!!(S.prefix||S.suffix||S.allowClear)}function qe(S,Te,P){var d=Te.cloneNode(!0),ne=Object.create(S,{target:{value:d},currentTarget:{value:d}});return d.value=P,typeof Te.selectionStart=="number"&&typeof Te.selectionEnd=="number"&&(d.selectionStart=Te.selectionStart,d.selectionEnd=Te.selectionEnd),d.setSelectionRange=function(){Te.setSelectionRange.apply(Te,arguments)},ne}function ge(S,Te,P,d){if(P){var ne=Te;if(Te.type==="click"){ne=qe(Te,S,""),P(ne);return}if(S.type!=="file"&&d!==void 0){ne=qe(Te,S,d),P(ne);return}P(ne)}}function q(S,Te){if(S){S.focus(Te);var P=Te||{},d=P.cursor;if(d){var ne=S.value.length;switch(d){case"start":S.setSelectionRange(0,0);break;case"end":S.setSelectionRange(ne,ne);break;default:S.setSelectionRange(0,ne)}}}}},28321:function(Li,Rt,oe){"use strict";oe.d(Rt,{iz:function(){return Ji},ck:function(){return we},BW:function(){return yn},sN:function(){return we},Wd:function(){return nn},ZP:function(){return $t},Xl:function(){return We}});var ce=oe(54476),De=oe(20068),qe=oe(33885),ge=oe(94480),q=oe(42978),S=oe(75931),Te=oe(92310),P=oe.n(Te),d=oe(11780),ne=oe(18929),I=oe(13697),k=oe(48736),T=oe(59301),M=oe(4676),O=T.createContext(null);function Y(Re,Je){return Re===void 0?null:"".concat(Re,"-").concat(Je)}function H(Re){var Je=T.useContext(O);return Y(Je,Re)}var j=oe(80547),U=["children","locked"],$=T.createContext(null);function G(Re,Je){var ut=(0,qe.Z)({},Re);return Object.keys(Je).forEach(function(it){var wt=Je[it];wt!==void 0&&(ut[it]=wt)}),ut}function he(Re){var Je=Re.children,ut=Re.locked,it=(0,S.Z)(Re,U),wt=T.useContext($),St=(0,j.Z)(function(){return G(wt,it)},[wt,it],function(Bt,ni){return!ut&&(Bt[0]!==ni[0]||!(0,I.Z)(Bt[1],ni[1],!0))});return T.createElement($.Provider,{value:St},Je)}var be=[],Se=T.createContext(null);function re(){return T.useContext(Se)}var Oe=T.createContext(be);function We(Re){var Je=T.useContext(Oe);return T.useMemo(function(){return Re!==void 0?[].concat((0,ge.Z)(Je),[Re]):Je},[Je,Re])}var Be=T.createContext(null),Dt=T.createContext({}),te=Dt,z=oe(29194);function X(Re){var Je=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if((0,z.Z)(Re)){var ut=Re.nodeName.toLowerCase(),it=["input","select","textarea","button"].includes(ut)||Re.isContentEditable||ut==="a"&&!!Re.getAttribute("href"),wt=Re.getAttribute("tabindex"),St=Number(wt),Bt=null;return wt&&!Number.isNaN(St)?Bt=St:it&&Bt===null&&(Bt=0),it&&Re.disabled&&(Bt=null),Bt!==null&&(Bt>=0||Je&&Bt<0)}return!1}function J(Re){var Je=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,ut=(0,ge.Z)(Re.querySelectorAll("*")).filter(function(it){return X(it,Je)});return X(Re,Je)&&ut.unshift(Re),ut}var de=null;function ie(){de=document.activeElement}function A(){de=null}function L(){if(de)try{de.focus()}catch(Re){}}function V(Re,Je){if(Je.keyCode===9){var ut=J(Re),it=ut[Je.shiftKey?0:ut.length-1],wt=it===document.activeElement||Re===document.activeElement;if(wt){var St=ut[Je.shiftKey?ut.length-1:0];St.focus(),Je.preventDefault()}}}var pe=oe(10228),ze=oe(16089),at=pe.Z.LEFT,Ot=pe.Z.RIGHT,Ce=pe.Z.UP,jt=pe.Z.DOWN,Mt=pe.Z.ENTER,dt=pe.Z.ESC,Ti=pe.Z.HOME,fi=pe.Z.END,Yi=[Ce,jt,at,Ot];function Kt(Re,Je,ut,it){var wt,St="prev",Bt="next",ni="children",Gi="parent";if(Re==="inline"&&it===Mt)return{inlineTrigger:!0};var gi=(0,De.Z)((0,De.Z)({},Ce,St),jt,Bt),dn=(0,De.Z)((0,De.Z)((0,De.Z)((0,De.Z)({},at,ut?Bt:St),Ot,ut?St:Bt),jt,ni),Mt,ni),_i=(0,De.Z)((0,De.Z)((0,De.Z)((0,De.Z)((0,De.Z)((0,De.Z)({},Ce,St),jt,Bt),Mt,ni),dt,Gi),at,ut?ni:Gi),Ot,ut?Gi:ni),Ai={inline:gi,horizontal:dn,vertical:_i,inlineSub:gi,horizontalSub:_i,verticalSub:_i},Ci=(wt=Ai["".concat(Re).concat(Je?"":"Sub")])===null||wt===void 0?void 0:wt[it];switch(Ci){case St:return{offset:-1,sibling:!0};case Bt:return{offset:1,sibling:!0};case Gi:return{offset:-1,sibling:!1};case ni:return{offset:1,sibling:!1};default:return null}}function ln(Re){for(var Je=Re;Je;){if(Je.getAttribute("data-menu-list"))return Je;Je=Je.parentElement}return null}function Ne(Re,Je){for(var ut=Re||document.activeElement;ut;){if(Je.has(ut))return ut;ut=ut.parentElement}return null}function Ge(Re,Je){var ut=J(Re,!0);return ut.filter(function(it){return Je.has(it)})}function ve(Re,Je,ut){var it=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(!Re)return null;var wt=Ge(Re,Je),St=wt.length,Bt=wt.findIndex(function(ni){return ut===ni});return it<0?Bt===-1?Bt=St-1:Bt-=1:it>0&&(Bt+=1),Bt=(Bt+St)%St,wt[Bt]}var nt=function(Je,ut){var it=new Set,wt=new Map,St=new Map;return Je.forEach(function(Bt){var ni=document.querySelector("[data-menu-id='".concat(Y(ut,Bt),"']"));ni&&(it.add(ni),St.set(ni,Bt),wt.set(Bt,ni))}),{elements:it,key2element:wt,element2key:St}};function _t(Re,Je,ut,it,wt,St,Bt,ni,Gi,gi){var dn=T.useRef(),_i=T.useRef();_i.current=Je;var Ai=function(){ze.Z.cancel(dn.current)};return T.useEffect(function(){return function(){Ai()}},[]),function(Ci){var Ni=Ci.which;if([].concat(Yi,[Mt,dt,Ti,fi]).includes(Ni)){var $i=St(),ui=nt($i,it),Ii=ui,Qi=Ii.elements,Fi=Ii.key2element,wi=Ii.element2key,ji=Fi.get(Je),Ki=Ne(ji,Qi),en=wi.get(Ki),Pn=Kt(Re,Bt(en,!0).length===1,ut,Ni);if(!Pn&&Ni!==Ti&&Ni!==fi)return;(Yi.includes(Ni)||[Ti,fi].includes(Ni))&&Ci.preventDefault();var tn=function(bn){if(bn){var rn=bn,xn=bn.querySelector("a");xn!=null&&xn.getAttribute("href")&&(rn=xn);var pn=wi.get(bn);ni(pn),Ai(),dn.current=(0,ze.Z)(function(){_i.current===pn&&rn.focus()})}};if([Ti,fi].includes(Ni)||Pn.sibling||!Ki){var er;!Ki||Re==="inline"?er=wt.current:er=ln(Ki);var cn,Cn=Ge(er,Qi);Ni===Ti?cn=Cn[0]:Ni===fi?cn=Cn[Cn.length-1]:cn=ve(er,Qi,Ki,Pn.offset),tn(cn)}else if(Pn.inlineTrigger)Gi(en);else if(Pn.offset>0)Gi(en,!0),Ai(),dn.current=(0,ze.Z)(function(){ui=nt($i,it);var Ln=Ki.getAttribute("aria-controls"),bn=document.getElementById(Ln),rn=ve(bn,ui.elements);tn(rn)},5);else if(Pn.offset<0){var tr=Bt(en,!0),Ui=tr[tr.length-2],zi=Fi.get(Ui);Gi(Ui,!1),tn(zi)}}gi==null||gi(Ci)}}function lt(Re){Promise.resolve().then(Re)}var ee="__RC_UTIL_PATH_SPLIT__",xe=function(Je){return Je.join(ee)},$e=function(Je){return Je.split(ee)},Ye="rc-menu-more";function rt(){var Re=T.useState({}),Je=(0,q.Z)(Re,2),ut=Je[1],it=(0,T.useRef)(new Map),wt=(0,T.useRef)(new Map),St=T.useState([]),Bt=(0,q.Z)(St,2),ni=Bt[0],Gi=Bt[1],gi=(0,T.useRef)(0),dn=(0,T.useRef)(!1),_i=function(){dn.current||ut({})},Ai=(0,T.useCallback)(function(Fi,wi){var ji=xe(wi);wt.current.set(ji,Fi),it.current.set(Fi,ji),gi.current+=1;var Ki=gi.current;lt(function(){Ki===gi.current&&_i()})},[]),Ci=(0,T.useCallback)(function(Fi,wi){var ji=xe(wi);wt.current.delete(ji),it.current.delete(Fi)},[]),Ni=(0,T.useCallback)(function(Fi){Gi(Fi)},[]),$i=(0,T.useCallback)(function(Fi,wi){var ji=it.current.get(Fi)||"",Ki=$e(ji);return wi&&ni.includes(Ki[0])&&Ki.unshift(Ye),Ki},[ni]),ui=(0,T.useCallback)(function(Fi,wi){return Fi.filter(function(ji){return ji!==void 0}).some(function(ji){var Ki=$i(ji,!0);return Ki.includes(wi)})},[$i]),Ii=function(){var wi=(0,ge.Z)(it.current.keys());return ni.length&&wi.push(Ye),wi},Qi=(0,T.useCallback)(function(Fi){var wi="".concat(it.current.get(Fi)).concat(ee),ji=new Set;return(0,ge.Z)(wt.current.keys()).forEach(function(Ki){Ki.startsWith(wi)&&ji.add(wt.current.get(Ki))}),ji},[]);return T.useEffect(function(){return function(){dn.current=!0}},[]),{registerPath:Ai,unregisterPath:Ci,refreshOverflowKeys:Ni,isSubPathKey:ui,getKeyPath:$i,getKeys:Ii,getSubPathKeys:Qi}}function gt(Re){var Je=T.useRef(Re);Je.current=Re;var ut=T.useCallback(function(){for(var it,wt=arguments.length,St=new Array(wt),Bt=0;Bt<wt;Bt++)St[Bt]=arguments[Bt];return(it=Je.current)===null||it===void 0?void 0:it.call.apply(it,[Je].concat(St))},[]);return Re?ut:void 0}var Yt=Math.random().toFixed(5).toString().slice(2),pt=0;function ke(Re){var Je=(0,ne.Z)(Re,{value:Re}),ut=(0,q.Z)(Je,2),it=ut[0],wt=ut[1];return T.useEffect(function(){pt+=1;var St="".concat(Yt,"-").concat(pt);wt("rc-menu-uuid-".concat(St))},[]),it}var ht=oe(67732),Gt=oe(83652),zt=oe(42403),Ae=oe(158),Me=oe(2738),tt=oe(8654);function ft(Re,Je,ut,it){var wt=T.useContext($),St=wt.activeKey,Bt=wt.onActive,ni=wt.onInactive,Gi={active:St===Re};return Je||(Gi.onMouseEnter=function(gi){ut==null||ut({key:Re,domEvent:gi}),Bt(Re)},Gi.onMouseLeave=function(gi){it==null||it({key:Re,domEvent:gi}),ni(Re)}),Gi}function je(Re){var Je=T.useContext($),ut=Je.mode,it=Je.rtl,wt=Je.inlineIndent;if(ut!=="inline")return null;var St=Re;return it?{paddingRight:St*wt}:{paddingLeft:St*wt}}function At(Re){var Je=Re.icon,ut=Re.props,it=Re.children,wt;return Je===null||Je===!1?null:(typeof Je=="function"?wt=T.createElement(Je,(0,qe.Z)({},ut)):typeof Je!="boolean"&&(wt=Je),wt||it||null)}var Lt=["item"];function vt(Re){var Je=Re.item,ut=(0,S.Z)(Re,Lt);return Object.defineProperty(ut,"item",{get:function(){return(0,k.ZP)(!1,"`info.item` is deprecated since we will move to function component that not provides React Node instance in future."),Je}}),ut}var Pt=["title","attribute","elementRef"],Ht=["style","className","eventKey","warnKey","disabled","itemIcon","children","role","onMouseEnter","onMouseLeave","onClick","onKeyDown","onFocus"],Xe=["active"],Ft=function(Re){(0,zt.Z)(ut,Re);var Je=(0,Ae.Z)(ut);function ut(){return(0,ht.Z)(this,ut),Je.apply(this,arguments)}return(0,Gt.Z)(ut,[{key:"render",value:function(){var wt=this.props,St=wt.title,Bt=wt.attribute,ni=wt.elementRef,Gi=(0,S.Z)(wt,Pt),gi=(0,Me.Z)(Gi,["eventKey","popupClassName","popupOffset","onTitleClick"]);return(0,k.ZP)(!Bt,"`attribute` of Menu.Item is deprecated. Please pass attribute directly."),T.createElement(d.Z.Item,(0,ce.Z)({},Bt,{title:typeof St=="string"?St:void 0},gi,{ref:ni}))}}]),ut}(T.Component),Le=T.forwardRef(function(Re,Je){var ut=Re.style,it=Re.className,wt=Re.eventKey,St=Re.warnKey,Bt=Re.disabled,ni=Re.itemIcon,Gi=Re.children,gi=Re.role,dn=Re.onMouseEnter,_i=Re.onMouseLeave,Ai=Re.onClick,Ci=Re.onKeyDown,Ni=Re.onFocus,$i=(0,S.Z)(Re,Ht),ui=H(wt),Ii=T.useContext($),Qi=Ii.prefixCls,Fi=Ii.onItemClick,wi=Ii.disabled,ji=Ii.overflowDisabled,Ki=Ii.itemIcon,en=Ii.selectedKeys,Pn=Ii.onActive,tn=T.useContext(te),er=tn._internalRenderMenuItem,cn="".concat(Qi,"-item"),Cn=T.useRef(),tr=T.useRef(),Ui=wi||Bt,zi=(0,tt.x1)(Je,tr),Ln=We(wt),bn=function(Mn){return{key:wt,keyPath:(0,ge.Z)(Ln).reverse(),item:Cn.current,domEvent:Mn}},rn=ni||Ki,xn=ft(wt,Ui,dn,_i),pn=xn.active,Vn=(0,S.Z)(xn,Xe),Mr=en.includes(wt),On=je(Ln.length),Br=function(Mn){if(!Ui){var cr=bn(Mn);Ai==null||Ai(vt(cr)),Fi(cr)}},En=function(Mn){if(Ci==null||Ci(Mn),Mn.which===pe.Z.ENTER){var cr=bn(Mn);Ai==null||Ai(vt(cr)),Fi(cr)}},sr=function(Mn){Pn(wt),Ni==null||Ni(Mn)},Rr={};Re.role==="option"&&(Rr["aria-selected"]=Mr);var Tr=T.createElement(Ft,(0,ce.Z)({ref:Cn,elementRef:zi,role:gi===null?"none":gi||"menuitem",tabIndex:Bt?null:-1,"data-menu-id":ji&&ui?null:ui},(0,Me.Z)($i,["extra"]),Vn,Rr,{component:"li","aria-disabled":Bt,style:(0,qe.Z)((0,qe.Z)({},On),ut),className:P()(cn,(0,De.Z)((0,De.Z)((0,De.Z)({},"".concat(cn,"-active"),pn),"".concat(cn,"-selected"),Mr),"".concat(cn,"-disabled"),Ui),it),onClick:Br,onKeyDown:En,onFocus:sr}),Gi,T.createElement(At,{props:(0,qe.Z)((0,qe.Z)({},Re),{},{isSelected:Mr}),icon:rn}));return er&&(Tr=er(Tr,Re,{selected:Mr})),Tr});function ye(Re,Je){var ut=Re.eventKey,it=re(),wt=We(ut);return T.useEffect(function(){if(it)return it.registerPath(ut,wt),function(){it.unregisterPath(ut,wt)}},[wt]),it?null:T.createElement(Le,(0,ce.Z)({},Re,{ref:Je}))}var we=T.forwardRef(ye),K=["className","children"],W=function(Je,ut){var it=Je.className,wt=Je.children,St=(0,S.Z)(Je,K),Bt=T.useContext($),ni=Bt.prefixCls,Gi=Bt.mode,gi=Bt.rtl;return T.createElement("ul",(0,ce.Z)({className:P()(ni,gi&&"".concat(ni,"-rtl"),"".concat(ni,"-sub"),"".concat(ni,"-").concat(Gi==="inline"?"inline":"vertical"),it),role:"menu"},St,{"data-menu-list":!0,ref:ut}),wt)},ae=T.forwardRef(W);ae.displayName="SubMenuList";var fe=ae,_e=oe(11592);function st(Re,Je){return(0,_e.Z)(Re).map(function(ut,it){if(T.isValidElement(ut)){var wt,St,Bt=ut.key,ni=(wt=(St=ut.props)===null||St===void 0?void 0:St.eventKey)!==null&&wt!==void 0?wt:Bt,Gi=ni==null;Gi&&(ni="tmp_key-".concat([].concat((0,ge.Z)(Je),[it]).join("-")));var gi={key:ni,eventKey:ni};return T.cloneElement(ut,gi)}return ut})}var ot=oe(65030),xt={adjustX:1,adjustY:1},Ut={topLeft:{points:["bl","tl"],overflow:xt},topRight:{points:["br","tr"],overflow:xt},bottomLeft:{points:["tl","bl"],overflow:xt},bottomRight:{points:["tr","br"],overflow:xt},leftTop:{points:["tr","tl"],overflow:xt},leftBottom:{points:["br","bl"],overflow:xt},rightTop:{points:["tl","tr"],overflow:xt},rightBottom:{points:["bl","br"],overflow:xt}},ti={topLeft:{points:["bl","tl"],overflow:xt},topRight:{points:["br","tr"],overflow:xt},bottomLeft:{points:["tl","bl"],overflow:xt},bottomRight:{points:["tr","br"],overflow:xt},rightTop:{points:["tr","tl"],overflow:xt},rightBottom:{points:["br","bl"],overflow:xt},leftTop:{points:["tl","tr"],overflow:xt},leftBottom:{points:["bl","br"],overflow:xt}},di=null;function Qt(Re,Je,ut){if(Je)return Je;if(ut)return ut[Re]||ut.other}var kt={horizontal:"bottomLeft",vertical:"rightTop","vertical-left":"rightTop","vertical-right":"leftTop"};function oi(Re){var Je=Re.prefixCls,ut=Re.visible,it=Re.children,wt=Re.popup,St=Re.popupStyle,Bt=Re.popupClassName,ni=Re.popupOffset,Gi=Re.disabled,gi=Re.mode,dn=Re.onVisibleChange,_i=T.useContext($),Ai=_i.getPopupContainer,Ci=_i.rtl,Ni=_i.subMenuOpenDelay,$i=_i.subMenuCloseDelay,ui=_i.builtinPlacements,Ii=_i.triggerSubMenuAction,Qi=_i.forceSubMenuRender,Fi=_i.rootClassName,wi=_i.motion,ji=_i.defaultMotions,Ki=T.useState(!1),en=(0,q.Z)(Ki,2),Pn=en[0],tn=en[1],er=Ci?(0,qe.Z)((0,qe.Z)({},ti),ui):(0,qe.Z)((0,qe.Z)({},Ut),ui),cn=kt[gi],Cn=Qt(gi,wi,ji),tr=T.useRef(Cn);gi!=="inline"&&(tr.current=Cn);var Ui=(0,qe.Z)((0,qe.Z)({},tr.current),{},{leavedClassName:"".concat(Je,"-hidden"),removeOnLeave:!1,motionAppear:!0}),zi=T.useRef();return T.useEffect(function(){return zi.current=(0,ze.Z)(function(){tn(ut)}),function(){ze.Z.cancel(zi.current)}},[ut]),T.createElement(ot.Z,{prefixCls:Je,popupClassName:P()("".concat(Je,"-popup"),(0,De.Z)({},"".concat(Je,"-rtl"),Ci),Bt,Fi),stretch:gi==="horizontal"?"minWidth":null,getPopupContainer:Ai,builtinPlacements:er,popupPlacement:cn,popupVisible:Pn,popup:wt,popupStyle:St,popupAlign:ni&&{offset:ni},action:Gi?[]:[Ii],mouseEnterDelay:Ni,mouseLeaveDelay:$i,onPopupVisibleChange:dn,forceRender:Qi,popupMotion:Ui,fresh:!0},it)}var Di=oe(77900);function ki(Re){var Je=Re.id,ut=Re.open,it=Re.keyPath,wt=Re.children,St="inline",Bt=T.useContext($),ni=Bt.prefixCls,Gi=Bt.forceSubMenuRender,gi=Bt.motion,dn=Bt.defaultMotions,_i=Bt.mode,Ai=T.useRef(!1);Ai.current=_i===St;var Ci=T.useState(!Ai.current),Ni=(0,q.Z)(Ci,2),$i=Ni[0],ui=Ni[1],Ii=Ai.current?ut:!1;T.useEffect(function(){Ai.current&&ui(!1)},[_i]);var Qi=(0,qe.Z)({},Qt(St,gi,dn));it.length>1&&(Qi.motionAppear=!1);var Fi=Qi.onVisibleChanged;return Qi.onVisibleChanged=function(wi){return!Ai.current&&!wi&&ui(!0),Fi==null?void 0:Fi(wi)},$i?null:T.createElement(he,{mode:St,locked:!Ai.current},T.createElement(Di.default,(0,ce.Z)({visible:Ii},Qi,{forceRender:Gi,removeOnLeave:!1,leavedClassName:"".concat(ni,"-hidden")}),function(wi){var ji=wi.className,Ki=wi.style;return T.createElement(fe,{id:Je,className:ji,style:Ki},wt)}))}var Bi=["style","className","title","eventKey","warnKey","disabled","internalPopupClose","children","itemIcon","expandIcon","popupClassName","popupOffset","popupStyle","onClick","onMouseEnter","onMouseLeave","onTitleClick","onTitleMouseEnter","onTitleMouseLeave"],pi=["active"],mi=T.forwardRef(function(Re,Je){var ut=Re.style,it=Re.className,wt=Re.title,St=Re.eventKey,Bt=Re.warnKey,ni=Re.disabled,Gi=Re.internalPopupClose,gi=Re.children,dn=Re.itemIcon,_i=Re.expandIcon,Ai=Re.popupClassName,Ci=Re.popupOffset,Ni=Re.popupStyle,$i=Re.onClick,ui=Re.onMouseEnter,Ii=Re.onMouseLeave,Qi=Re.onTitleClick,Fi=Re.onTitleMouseEnter,wi=Re.onTitleMouseLeave,ji=(0,S.Z)(Re,Bi),Ki=H(St),en=T.useContext($),Pn=en.prefixCls,tn=en.mode,er=en.openKeys,cn=en.disabled,Cn=en.overflowDisabled,tr=en.activeKey,Ui=en.selectedKeys,zi=en.itemIcon,Ln=en.expandIcon,bn=en.onItemClick,rn=en.onOpenChange,xn=en.onActive,pn=T.useContext(te),Vn=pn._internalRenderSubMenuItem,Mr=T.useContext(Be),On=Mr.isSubPathKey,Br=We(),En="".concat(Pn,"-submenu"),sr=cn||ni,Rr=T.useRef(),Tr=T.useRef(),xr=dn!=null?dn:zi,Mn=_i!=null?_i:Ln,cr=er.includes(St),wr=!Cn&&cr,Nr=On(Ui,St),kn=ft(St,sr,Fi,wi),pr=kn.active,Gn=(0,S.Z)(kn,pi),hr=T.useState(!1),Wr=(0,q.Z)(hr,2),Hi=Wr[0],vi=Wr[1],Wt=function(fr){sr||vi(fr)},_n=function(fr){Wt(!0),ui==null||ui({key:St,domEvent:fr})},mr=function(fr){Wt(!1),Ii==null||Ii({key:St,domEvent:fr})},Nn=T.useMemo(function(){return pr||(tn!=="inline"?Hi||On([tr],St):!1)},[tn,pr,tr,Hi,St,On]),ar=je(Br.length),$n=function(fr){sr||(Qi==null||Qi({key:St,domEvent:fr}),tn==="inline"&&rn(St,!cr))},cs=gt(function(Kn){$i==null||$i(vt(Kn)),bn(Kn)}),Sr=function(fr){tn!=="inline"&&rn(St,fr)},vn=function(){xn(St)},hs=Ki&&"".concat(Ki,"-popup"),ns=T.useMemo(function(){return T.createElement(At,{icon:tn!=="horizontal"?Mn:void 0,props:(0,qe.Z)((0,qe.Z)({},Re),{},{isOpen:wr,isSubMenu:!0})},T.createElement("i",{className:"".concat(En,"-arrow")}))},[tn,Mn,Re,wr,En]),or=T.createElement("div",(0,ce.Z)({role:"menuitem",style:ar,className:"".concat(En,"-title"),tabIndex:sr?null:-1,ref:Rr,title:typeof wt=="string"?wt:null,"data-menu-id":Cn&&Ki?null:Ki,"aria-expanded":wr,"aria-haspopup":!0,"aria-controls":hs,"aria-disabled":sr,onClick:$n,onFocus:vn},Gn),wt,ns),jr=T.useRef(tn);if(tn!=="inline"&&Br.length>1?jr.current="vertical":jr.current=tn,!Cn){var ys=jr.current;or=T.createElement(oi,{mode:ys,prefixCls:En,visible:!Gi&&wr&&tn!=="inline",popupClassName:Ai,popupOffset:Ci,popupStyle:Ni,popup:T.createElement(he,{mode:ys==="horizontal"?"vertical":ys},T.createElement(fe,{id:hs,ref:Tr},gi)),disabled:sr,onVisibleChange:Sr},or)}var _r=T.createElement(d.Z.Item,(0,ce.Z)({ref:Je,role:"none"},ji,{component:"li",style:ut,className:P()(En,"".concat(En,"-").concat(tn),it,(0,De.Z)((0,De.Z)((0,De.Z)((0,De.Z)({},"".concat(En,"-open"),wr),"".concat(En,"-active"),Nn),"".concat(En,"-selected"),Nr),"".concat(En,"-disabled"),sr)),onMouseEnter:_n,onMouseLeave:mr}),or,!Cn&&T.createElement(ki,{id:hs,open:wr,keyPath:Br},gi));return Vn&&(_r=Vn(_r,Re,{selected:Nr,active:Nn,open:wr,disabled:sr})),T.createElement(he,{onItemClick:cs,mode:tn==="horizontal"?"vertical":tn,itemIcon:xr,expandIcon:Mn},_r)}),Xi=T.forwardRef(function(Re,Je){var ut=Re.eventKey,it=Re.children,wt=We(ut),St=st(it,wt),Bt=re();T.useEffect(function(){if(Bt)return Bt.registerPath(ut,wt),function(){Bt.unregisterPath(ut,wt)}},[wt]);var ni;return Bt?ni=St:ni=T.createElement(mi,(0,ce.Z)({ref:Je},Re),St),T.createElement(Oe.Provider,{value:wt},ni)}),nn=Xi,un=oe(76190);function Ji(Re){var Je=Re.className,ut=Re.style,it=T.useContext($),wt=it.prefixCls,St=re();return St?null:T.createElement("li",{role:"separator",className:P()("".concat(wt,"-item-divider"),Je),style:ut})}var dr=["className","title","eventKey","children"],Mi=T.forwardRef(function(Re,Je){var ut=Re.className,it=Re.title,wt=Re.eventKey,St=Re.children,Bt=(0,S.Z)(Re,dr),ni=T.useContext($),Gi=ni.prefixCls,gi="".concat(Gi,"-item-group");return T.createElement("li",(0,ce.Z)({ref:Je,role:"presentation"},Bt,{onClick:function(_i){return _i.stopPropagation()},className:P()(gi,ut)}),T.createElement("div",{role:"presentation",className:"".concat(gi,"-title"),title:typeof it=="string"?it:void 0},it),T.createElement("ul",{role:"group",className:"".concat(gi,"-list")},St))}),Oi=T.forwardRef(function(Re,Je){var ut=Re.eventKey,it=Re.children,wt=We(ut),St=st(it,wt),Bt=re();return Bt?St:T.createElement(Mi,(0,ce.Z)({ref:Je},(0,Me.Z)(Re,["warnKey"])),St)}),yn=Oi,Ri=["label","children","key","type","extra"];function Dn(Re,Je,ut){var it=Je.item,wt=Je.group,St=Je.submenu,Bt=Je.divider;return(Re||[]).map(function(ni,Gi){if(ni&&(0,un.Z)(ni)==="object"){var gi=ni,dn=gi.label,_i=gi.children,Ai=gi.key,Ci=gi.type,Ni=gi.extra,$i=(0,S.Z)(gi,Ri),ui=Ai!=null?Ai:"tmp-".concat(Gi);return _i||Ci==="group"?Ci==="group"?T.createElement(wt,(0,ce.Z)({key:ui},$i,{title:dn}),Dn(_i,Je,ut)):T.createElement(St,(0,ce.Z)({key:ui},$i,{title:dn}),Dn(_i,Je,ut)):Ci==="divider"?T.createElement(Bt,(0,ce.Z)({key:ui},$i)):T.createElement(it,(0,ce.Z)({key:ui},$i,{extra:Ni}),dn,(!!Ni||Ni===0)&&T.createElement("span",{className:"".concat(ut,"-item-extra")},Ni))}return null}).filter(function(ni){return ni})}function hn(Re,Je,ut,it,wt){var St=Re,Bt=(0,qe.Z)({divider:Ji,item:we,group:yn,submenu:nn},it);return Je&&(St=Dn(Je,Bt,wt)),st(St,ut)}var Yn=["prefixCls","rootClassName","style","className","tabIndex","items","children","direction","id","mode","inlineCollapsed","disabled","disabledOverflow","subMenuOpenDelay","subMenuCloseDelay","forceSubMenuRender","defaultOpenKeys","openKeys","activeKey","defaultActiveFirst","selectable","multiple","defaultSelectedKeys","selectedKeys","onSelect","onDeselect","inlineIndent","motion","defaultMotions","triggerSubMenuAction","builtinPlacements","itemIcon","expandIcon","overflowedIndicator","overflowedIndicatorPopupClassName","getPopupContainer","onClick","onOpenChange","onKeyDown","openAnimation","openTransitionName","_internalRenderMenuItem","_internalRenderSubMenuItem","_internalComponents"],fn=[],gr=T.forwardRef(function(Re,Je){var ut,it=Re,wt=it.prefixCls,St=wt===void 0?"rc-menu":wt,Bt=it.rootClassName,ni=it.style,Gi=it.className,gi=it.tabIndex,dn=gi===void 0?0:gi,_i=it.items,Ai=it.children,Ci=it.direction,Ni=it.id,$i=it.mode,ui=$i===void 0?"vertical":$i,Ii=it.inlineCollapsed,Qi=it.disabled,Fi=it.disabledOverflow,wi=it.subMenuOpenDelay,ji=wi===void 0?.1:wi,Ki=it.subMenuCloseDelay,en=Ki===void 0?.1:Ki,Pn=it.forceSubMenuRender,tn=it.defaultOpenKeys,er=it.openKeys,cn=it.activeKey,Cn=it.defaultActiveFirst,tr=it.selectable,Ui=tr===void 0?!0:tr,zi=it.multiple,Ln=zi===void 0?!1:zi,bn=it.defaultSelectedKeys,rn=it.selectedKeys,xn=it.onSelect,pn=it.onDeselect,Vn=it.inlineIndent,Mr=Vn===void 0?24:Vn,On=it.motion,Br=it.defaultMotions,En=it.triggerSubMenuAction,sr=En===void 0?"hover":En,Rr=it.builtinPlacements,Tr=it.itemIcon,xr=it.expandIcon,Mn=it.overflowedIndicator,cr=Mn===void 0?"...":Mn,wr=it.overflowedIndicatorPopupClassName,Nr=it.getPopupContainer,kn=it.onClick,pr=it.onOpenChange,Gn=it.onKeyDown,hr=it.openAnimation,Wr=it.openTransitionName,Hi=it._internalRenderMenuItem,vi=it._internalRenderSubMenuItem,Wt=it._internalComponents,_n=(0,S.Z)(it,Yn),mr=T.useMemo(function(){return[hn(Ai,_i,fn,Wt,St),hn(Ai,_i,fn,{},St)]},[Ai,_i,Wt]),Nn=(0,q.Z)(mr,2),ar=Nn[0],$n=Nn[1],cs=T.useState(!1),Sr=(0,q.Z)(cs,2),vn=Sr[0],hs=Sr[1],ns=T.useRef(),or=ke(Ni),jr=Ci==="rtl",ys=(0,ne.Z)(tn,{value:er,postState:function(Rn){return Rn||fn}}),_r=(0,q.Z)(ys,2),Kn=_r[0],fr=_r[1],Xn=function(Rn){var Fn=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;function Ar(){fr(Rn),pr==null||pr(Rn)}Fn?(0,M.flushSync)(Ar):Ar()},rs=T.useState(Kn),ss=(0,q.Z)(rs,2),Ps=ss[0],ya=ss[1],Os=T.useRef(!1),ba=T.useMemo(function(){return(ui==="inline"||ui==="vertical")&&Ii?["vertical",Ii]:[ui,!1]},[ui,Ii]),ri=(0,q.Z)(ba,2),Jt=ri[0],Wi=ri[1],Hn=Jt==="inline",mn=T.useState(Jt),$r=(0,q.Z)(mn,2),ir=$r[0],Ts=$r[1],fs=T.useState(Wi),xa=(0,q.Z)(fs,2),ql=xa[0],Ws=xa[1];T.useEffect(function(){Ts(Jt),Ws(Wi),Os.current&&(Hn?fr(Ps):Xn(fn))},[Jt,Wi]);var as=T.useState(0),Ha=(0,q.Z)(as,2),nr=Ha[0],na=Ha[1],Wa=nr>=ar.length-1||ir!=="horizontal"||Fi;T.useEffect(function(){Hn&&ya(Kn)},[Kn]),T.useEffect(function(){return Os.current=!0,function(){Os.current=!1}},[]);var os=rt(),tl=os.registerPath,ds=os.unregisterPath,ls=os.refreshOverflowKeys,il=os.isSubPathKey,nl=os.getKeyPath,Eo=os.getKeys,rl=os.getSubPathKeys,sl=T.useMemo(function(){return{registerPath:tl,unregisterPath:ds}},[tl,ds]),al=T.useMemo(function(){return{isSubPathKey:il}},[il]);T.useEffect(function(){ls(Wa?fn:ar.slice(nr+1).map(function(Wn){return Wn.key}))},[nr,Wa]);var ra=(0,ne.Z)(cn||Cn&&((ut=ar[0])===null||ut===void 0?void 0:ut.key),{value:cn}),ko=(0,q.Z)(ra,2),As=ko[0],ps=ko[1],To=gt(function(Wn){ps(Wn)}),ja=gt(function(){ps(void 0)});(0,T.useImperativeHandle)(Je,function(){return{list:ns.current,focus:function(Rn){var Fn,Ar=Eo(),Xr=nt(Ar,or),Sa=Xr.elements,aa=Xr.key2element,Xa=Xr.element2key,Do=Ge(ns.current,Sa),Ea=As!=null?As:Do[0]?Xa.get(Do[0]):(Fn=ar.find(function(Yl){return!Yl.props.disabled}))===null||Fn===void 0?void 0:Fn.key,vr=aa.get(Ea);if(Ea&&vr){var Ir;vr==null||(Ir=vr.focus)===null||Ir===void 0||Ir.call(vr,Rn)}}}});var ol=(0,ne.Z)(bn||[],{value:rn,postState:function(Rn){return Array.isArray(Rn)?Rn:Rn==null?fn:[Rn]}}),ll=(0,q.Z)(ol,2),wa=ll[0],Zl=ll[1],sa=function(Rn){if(Ui){var Fn=Rn.key,Ar=wa.includes(Fn),Xr;Ln?Ar?Xr=wa.filter(function(aa){return aa!==Fn}):Xr=[].concat((0,ge.Z)(wa),[Fn]):Xr=[Fn],Zl(Xr);var Sa=(0,qe.Z)((0,qe.Z)({},Rn),{},{selectedKeys:Xr});Ar?pn==null||pn(Sa):xn==null||xn(Sa)}!Ln&&Kn.length&&ir!=="inline"&&Xn(fn)},qa=gt(function(Wn){kn==null||kn(vt(Wn)),sa(Wn)}),Ao=gt(function(Wn,Rn){var Fn=Kn.filter(function(Xr){return Xr!==Wn});if(Rn)Fn.push(Wn);else if(ir!=="inline"){var Ar=rl(Wn);Fn=Fn.filter(function(Xr){return!Ar.has(Xr)})}(0,I.Z)(Kn,Fn,!0)||Xn(Fn,!0)}),Lo=function(Rn,Fn){var Ar=Fn!=null?Fn:!Kn.includes(Rn);Ao(Rn,Ar)},Fs=_t(ir,As,jr,or,ns,Eo,nl,ps,Lo,Gn);T.useEffect(function(){hs(!0)},[]);var Za=T.useMemo(function(){return{_internalRenderMenuItem:Hi,_internalRenderSubMenuItem:vi}},[Hi,vi]),Ya=ir!=="horizontal"||Fi?ar:ar.map(function(Wn,Rn){return T.createElement(he,{key:Wn.key,overflowDisabled:Rn>nr},Wn)}),ul=T.createElement(d.Z,(0,ce.Z)({id:Ni,ref:ns,prefixCls:"".concat(St,"-overflow"),component:"ul",itemComponent:we,className:P()(St,"".concat(St,"-root"),"".concat(St,"-").concat(ir),Gi,(0,De.Z)((0,De.Z)({},"".concat(St,"-inline-collapsed"),ql),"".concat(St,"-rtl"),jr),Bt),dir:Ci,style:ni,role:"menu",tabIndex:dn,data:Ya,renderRawItem:function(Rn){return Rn},renderRawRest:function(Rn){var Fn=Rn.length,Ar=Fn?ar.slice(-Fn):null;return T.createElement(nn,{eventKey:Ye,title:cr,disabled:Wa,internalPopupClose:Fn===0,popupClassName:wr},Ar)},maxCount:ir!=="horizontal"||Fi?d.Z.INVALIDATE:d.Z.RESPONSIVE,ssr:"full","data-menu-list":!0,onVisibleChange:function(Rn){na(Rn)},onKeyDown:Fs},_n));return T.createElement(te.Provider,{value:Za},T.createElement(O.Provider,{value:or},T.createElement(he,{prefixCls:St,rootClassName:Bt,mode:ir,openKeys:Kn,rtl:jr,disabled:Qi,motion:vn?On:null,defaultMotions:vn?Br:null,activeKey:As,onActive:To,onInactive:ja,selectedKeys:wa,inlineIndent:Mr,subMenuOpenDelay:ji,subMenuCloseDelay:en,forceSubMenuRender:Pn,builtinPlacements:Rr,triggerSubMenuAction:sr,getPopupContainer:Nr,itemIcon:Tr,expandIcon:xr,onItemClick:qa,onOpenChange:Ao},T.createElement(Be.Provider,{value:al},ul),T.createElement("div",{style:{display:"none"},"aria-hidden":!0},T.createElement(Se.Provider,{value:sl},$n)))))}),Yr=gr,Ei=Yr;Ei.Item=we,Ei.SubMenu=nn,Ei.ItemGroup=yn,Ei.Divider=Ji;var $t=Ei},11780:function(Li,Rt,oe){"use strict";oe.d(Rt,{Z:function(){return ie}});var ce=oe(54476),De=oe(33885),qe=oe(42978),ge=oe(75931),q=oe(59301),S=oe(92310),Te=oe.n(S),P=oe(29301),d=oe(34280),ne=["prefixCls","invalidate","item","renderItem","responsive","responsiveDisabled","registerSize","itemKey","className","style","children","display","order","component"],I=void 0;function k(A,L){var V=A.prefixCls,pe=A.invalidate,ze=A.item,at=A.renderItem,Ot=A.responsive,Ce=A.responsiveDisabled,jt=A.registerSize,Mt=A.itemKey,dt=A.className,Ti=A.style,fi=A.children,Yi=A.display,Kt=A.order,ln=A.component,Ne=ln===void 0?"div":ln,Ge=(0,ge.Z)(A,ne),ve=Ot&&!Yi;function nt($e){jt(Mt,$e)}q.useEffect(function(){return function(){nt(null)}},[]);var _t=at&&ze!==I?at(ze,{index:Kt}):fi,lt;pe||(lt={opacity:ve?0:1,height:ve?0:I,overflowY:ve?"hidden":I,order:Ot?Kt:I,pointerEvents:ve?"none":I,position:ve?"absolute":I});var ee={};ve&&(ee["aria-hidden"]=!0);var xe=q.createElement(Ne,(0,ce.Z)({className:Te()(!pe&&V,dt),style:(0,De.Z)((0,De.Z)({},lt),Ti)},ee,Ge,{ref:L}),_t);return Ot&&(xe=q.createElement(P.Z,{onResize:function(Ye){var rt=Ye.offsetWidth;nt(rt)},disabled:Ce},xe)),xe}var T=q.forwardRef(k);T.displayName="Item";var M=T,O=oe(6089),Y=oe(4676),H=oe(16089);function j(A){if(typeof MessageChannel=="undefined")(0,H.Z)(A);else{var L=new MessageChannel;L.port1.onmessage=function(){return A()},L.port2.postMessage(void 0)}}function U(){var A=q.useRef(null),L=function(pe){A.current||(A.current=[],j(function(){(0,Y.unstable_batchedUpdates)(function(){A.current.forEach(function(ze){ze()}),A.current=null})})),A.current.push(pe)};return L}function $(A,L){var V=q.useState(L),pe=(0,qe.Z)(V,2),ze=pe[0],at=pe[1],Ot=(0,O.Z)(function(Ce){A(function(){at(Ce)})});return[ze,Ot]}var G=q.createContext(null),he=["component"],be=["className"],Se=["className"],re=function(L,V){var pe=q.useContext(G);if(!pe){var ze=L.component,at=ze===void 0?"div":ze,Ot=(0,ge.Z)(L,he);return q.createElement(at,(0,ce.Z)({},Ot,{ref:V}))}var Ce=pe.className,jt=(0,ge.Z)(pe,be),Mt=L.className,dt=(0,ge.Z)(L,Se);return q.createElement(G.Provider,{value:null},q.createElement(M,(0,ce.Z)({ref:V,className:Te()(Ce,Mt)},jt,dt)))},Oe=q.forwardRef(re);Oe.displayName="RawItem";var We=Oe,Be=["prefixCls","data","renderItem","renderRawItem","itemKey","itemWidth","ssr","style","className","maxCount","renderRest","renderRawRest","suffix","component","itemComponent","onVisibleChange"],Dt="responsive",te="invalidate";function z(A){return"+ ".concat(A.length," ...")}function X(A,L){var V=A.prefixCls,pe=V===void 0?"rc-overflow":V,ze=A.data,at=ze===void 0?[]:ze,Ot=A.renderItem,Ce=A.renderRawItem,jt=A.itemKey,Mt=A.itemWidth,dt=Mt===void 0?10:Mt,Ti=A.ssr,fi=A.style,Yi=A.className,Kt=A.maxCount,ln=A.renderRest,Ne=A.renderRawRest,Ge=A.suffix,ve=A.component,nt=ve===void 0?"div":ve,_t=A.itemComponent,lt=A.onVisibleChange,ee=(0,ge.Z)(A,Be),xe=Ti==="full",$e=U(),Ye=$($e,null),rt=(0,qe.Z)(Ye,2),gt=rt[0],Yt=rt[1],pt=gt||0,ke=$($e,new Map),ht=(0,qe.Z)(ke,2),Gt=ht[0],zt=ht[1],Ae=$($e,0),Me=(0,qe.Z)(Ae,2),tt=Me[0],ft=Me[1],je=$($e,0),At=(0,qe.Z)(je,2),Lt=At[0],vt=At[1],Pt=$($e,0),Ht=(0,qe.Z)(Pt,2),Xe=Ht[0],Ft=Ht[1],Le=(0,q.useState)(null),ye=(0,qe.Z)(Le,2),we=ye[0],K=ye[1],W=(0,q.useState)(null),ae=(0,qe.Z)(W,2),fe=ae[0],_e=ae[1],st=q.useMemo(function(){return fe===null&&xe?Number.MAX_SAFE_INTEGER:fe||0},[fe,gt]),ot=(0,q.useState)(!1),xt=(0,qe.Z)(ot,2),Ut=xt[0],ti=xt[1],di="".concat(pe,"-item"),Qt=Math.max(tt,Lt),kt=Kt===Dt,oi=at.length&&kt,Di=Kt===te,ki=oi||typeof Kt=="number"&&at.length>Kt,Bi=(0,q.useMemo)(function(){var Ei=at;return oi?gt===null&&xe?Ei=at:Ei=at.slice(0,Math.min(at.length,pt/dt)):typeof Kt=="number"&&(Ei=at.slice(0,Kt)),Ei},[at,dt,gt,Kt,oi]),pi=(0,q.useMemo)(function(){return oi?at.slice(st+1):at.slice(Bi.length)},[at,Bi,oi,st]),mi=(0,q.useCallback)(function(Ei,$t){var Re;return typeof jt=="function"?jt(Ei):(Re=jt&&(Ei==null?void 0:Ei[jt]))!==null&&Re!==void 0?Re:$t},[jt]),Xi=(0,q.useCallback)(Ot||function(Ei){return Ei},[Ot]);function nn(Ei,$t,Re){fe===Ei&&($t===void 0||$t===we)||(_e(Ei),Re||(ti(Ei<at.length-1),lt==null||lt(Ei)),$t!==void 0&&K($t))}function un(Ei,$t){Yt($t.clientWidth)}function Ji(Ei,$t){zt(function(Re){var Je=new Map(Re);return $t===null?Je.delete(Ei):Je.set(Ei,$t),Je})}function dr(Ei,$t){vt($t),ft(Lt)}function Mi(Ei,$t){Ft($t)}function Oi(Ei){return Gt.get(mi(Bi[Ei],Ei))}(0,d.Z)(function(){if(pt&&typeof Qt=="number"&&Bi){var Ei=Xe,$t=Bi.length,Re=$t-1;if(!$t){nn(0,null);return}for(var Je=0;Je<$t;Je+=1){var ut=Oi(Je);if(xe&&(ut=ut||0),ut===void 0){nn(Je-1,void 0,!0);break}if(Ei+=ut,Re===0&&Ei<=pt||Je===Re-1&&Ei+Oi(Re)<=pt){nn(Re,null);break}else if(Ei+Qt>pt){nn(Je-1,Ei-ut-Xe+Lt);break}}Ge&&Oi(0)+Xe>pt&&K(null)}},[pt,Gt,Lt,Xe,mi,Bi]);var yn=Ut&&!!pi.length,Ri={};we!==null&&oi&&(Ri={position:"absolute",left:we,top:0});var Dn={prefixCls:di,responsive:oi,component:_t,invalidate:Di},hn=Ce?function(Ei,$t){var Re=mi(Ei,$t);return q.createElement(G.Provider,{key:Re,value:(0,De.Z)((0,De.Z)({},Dn),{},{order:$t,item:Ei,itemKey:Re,registerSize:Ji,display:$t<=st})},Ce(Ei,$t))}:function(Ei,$t){var Re=mi(Ei,$t);return q.createElement(M,(0,ce.Z)({},Dn,{order:$t,key:Re,item:Ei,renderItem:Xi,itemKey:Re,registerSize:Ji,display:$t<=st}))},Yn={order:yn?st:Number.MAX_SAFE_INTEGER,className:"".concat(di,"-rest"),registerSize:dr,display:yn},fn=ln||z,gr=Ne?q.createElement(G.Provider,{value:(0,De.Z)((0,De.Z)({},Dn),Yn)},Ne(pi)):q.createElement(M,(0,ce.Z)({},Dn,Yn),typeof fn=="function"?fn(pi):fn),Yr=q.createElement(nt,(0,ce.Z)({className:Te()(!Di&&pe,Yi),style:fi,ref:L},ee),Bi.map(hn),ki?gr:null,Ge&&q.createElement(M,(0,ce.Z)({},Dn,{responsive:kt,responsiveDisabled:!oi,order:st,className:"".concat(di,"-suffix"),registerSize:Mi,display:!0,style:Ri}),Ge));return kt?q.createElement(P.Z,{onResize:un,disabled:!oi},Yr):Yr}var J=q.forwardRef(X);J.displayName="Overflow",J.Item=We,J.RESPONSIVE=Dt,J.INVALIDATE=te;var de=J,ie=de},29301:function(Li,Rt,oe){"use strict";oe.d(Rt,{Z:function(){return te}});var ce=oe(54476),De=oe(59301),qe=oe(11592),ge=oe(48736),q=oe(33885),S=oe(76190),Te=oe(76846),P=oe(8654),d=De.createContext(null);function ne(z){var X=z.children,J=z.onBatchResize,de=De.useRef(0),ie=De.useRef([]),A=De.useContext(d),L=De.useCallback(function(V,pe,ze){de.current+=1;var at=de.current;ie.current.push({size:V,element:pe,data:ze}),Promise.resolve().then(function(){at===de.current&&(J==null||J(ie.current),ie.current=[])}),A==null||A(V,pe,ze)},[J,A]);return De.createElement(d.Provider,{value:L},X)}var I=oe(76374),k=new Map;function T(z){z.forEach(function(X){var J,de=X.target;(J=k.get(de))===null||J===void 0||J.forEach(function(ie){return ie(de)})})}var M=new I.Z(T),O=null,Y=null;function H(z,X){k.has(z)||(k.set(z,new Set),M.observe(z)),k.get(z).add(X)}function j(z,X){k.has(z)&&(k.get(z).delete(X),k.get(z).size||(M.unobserve(z),k.delete(z)))}var U=oe(67732),$=oe(83652),G=oe(42403),he=oe(158),be=function(z){(0,G.Z)(J,z);var X=(0,he.Z)(J);function J(){return(0,U.Z)(this,J),X.apply(this,arguments)}return(0,$.Z)(J,[{key:"render",value:function(){return this.props.children}}]),J}(De.Component);function Se(z,X){var J=z.children,de=z.disabled,ie=De.useRef(null),A=De.useRef(null),L=De.useContext(d),V=typeof J=="function",pe=V?J(ie):J,ze=De.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),at=!V&&De.isValidElement(pe)&&(0,P.Yr)(pe),Ot=at?(0,P.C4)(pe):null,Ce=(0,P.x1)(Ot,ie),jt=function(){var fi;return(0,Te.ZP)(ie.current)||(ie.current&&(0,S.Z)(ie.current)==="object"?(0,Te.ZP)((fi=ie.current)===null||fi===void 0?void 0:fi.nativeElement):null)||(0,Te.ZP)(A.current)};De.useImperativeHandle(X,function(){return jt()});var Mt=De.useRef(z);Mt.current=z;var dt=De.useCallback(function(Ti){var fi=Mt.current,Yi=fi.onResize,Kt=fi.data,ln=Ti.getBoundingClientRect(),Ne=ln.width,Ge=ln.height,ve=Ti.offsetWidth,nt=Ti.offsetHeight,_t=Math.floor(Ne),lt=Math.floor(Ge);if(ze.current.width!==_t||ze.current.height!==lt||ze.current.offsetWidth!==ve||ze.current.offsetHeight!==nt){var ee={width:_t,height:lt,offsetWidth:ve,offsetHeight:nt};ze.current=ee;var xe=ve===Math.round(Ne)?Ne:ve,$e=nt===Math.round(Ge)?Ge:nt,Ye=(0,q.Z)((0,q.Z)({},ee),{},{offsetWidth:xe,offsetHeight:$e});L==null||L(Ye,Ti,Kt),Yi&&Promise.resolve().then(function(){Yi(Ye,Ti)})}},[]);return De.useEffect(function(){var Ti=jt();return Ti&&!de&&H(Ti,dt),function(){return j(Ti,dt)}},[ie.current,de]),De.createElement(be,{ref:A},at?De.cloneElement(pe,{ref:Ce}):pe)}var re=De.forwardRef(Se),Oe=re,We="rc-observer-key";function Be(z,X){var J=z.children,de=typeof J=="function"?[J]:(0,qe.Z)(J);return de.map(function(ie,A){var L=(ie==null?void 0:ie.key)||"".concat(We,"-").concat(A);return De.createElement(Oe,(0,ce.Z)({},z,{key:L,ref:A===0?X:void 0}),ie)})}var Dt=De.forwardRef(Be);Dt.Collection=ne;var te=Dt},29443:function(Li,Rt,oe){"use strict";oe.d(Rt,{Z:function(){return zt}});var ce=oe(54476),De=oe(20068),qe=oe(33885),ge=oe(42978),q=oe(76190),S=oe(75931),Te=oe(92310),P=oe.n(Te),d=oe(18929),ne=oe(49658),I=oe(59301),k=(0,I.createContext)(null),T=oe(94480),M=oe(29301),O=oe(6089),Y=oe(8654),H=oe(16089),j=function(Me){var tt=Me.activeTabOffset,ft=Me.horizontal,je=Me.rtl,At=Me.indicator,Lt=At===void 0?{}:At,vt=Lt.size,Pt=Lt.align,Ht=Pt===void 0?"center":Pt,Xe=(0,I.useState)(),Ft=(0,ge.Z)(Xe,2),Le=Ft[0],ye=Ft[1],we=(0,I.useRef)(),K=I.useCallback(function(ae){return typeof vt=="function"?vt(ae):typeof vt=="number"?vt:ae},[vt]);function W(){H.Z.cancel(we.current)}return(0,I.useEffect)(function(){var ae={};if(tt)if(ft){ae.width=K(tt.width);var fe=je?"right":"left";Ht==="start"&&(ae[fe]=tt[fe]),Ht==="center"&&(ae[fe]=tt[fe]+tt.width/2,ae.transform=je?"translateX(50%)":"translateX(-50%)"),Ht==="end"&&(ae[fe]=tt[fe]+tt.width,ae.transform="translateX(-100%)")}else ae.height=K(tt.height),Ht==="start"&&(ae.top=tt.top),Ht==="center"&&(ae.top=tt.top+tt.height/2,ae.transform="translateY(-50%)"),Ht==="end"&&(ae.top=tt.top+tt.height,ae.transform="translateY(-100%)");return W(),we.current=(0,H.Z)(function(){ye(ae)}),W},[tt,ft,je,Ht,K]),{style:Le}},U=j,$={width:0,height:0,left:0,top:0};function G(Ae,Me,tt){return(0,I.useMemo)(function(){for(var ft,je=new Map,At=Me.get((ft=Ae[0])===null||ft===void 0?void 0:ft.key)||$,Lt=At.left+At.width,vt=0;vt<Ae.length;vt+=1){var Pt=Ae[vt].key,Ht=Me.get(Pt);if(!Ht){var Xe;Ht=Me.get((Xe=Ae[vt-1])===null||Xe===void 0?void 0:Xe.key)||$}var Ft=je.get(Pt)||(0,qe.Z)({},Ht);Ft.right=Lt-Ft.left-Ft.width,je.set(Pt,Ft)}return je},[Ae.map(function(ft){return ft.key}).join("_"),Me,tt])}function he(Ae,Me){var tt=I.useRef(Ae),ft=I.useState({}),je=(0,ge.Z)(ft,2),At=je[1];function Lt(vt){var Pt=typeof vt=="function"?vt(tt.current):vt;Pt!==tt.current&&Me(Pt,tt.current),tt.current=Pt,At({})}return[tt.current,Lt]}var be=.1,Se=.01,re=20,Oe=Math.pow(.995,re);function We(Ae,Me){var tt=(0,I.useState)(),ft=(0,ge.Z)(tt,2),je=ft[0],At=ft[1],Lt=(0,I.useState)(0),vt=(0,ge.Z)(Lt,2),Pt=vt[0],Ht=vt[1],Xe=(0,I.useState)(0),Ft=(0,ge.Z)(Xe,2),Le=Ft[0],ye=Ft[1],we=(0,I.useState)(),K=(0,ge.Z)(we,2),W=K[0],ae=K[1],fe=(0,I.useRef)();function _e(di){var Qt=di.touches[0],kt=Qt.screenX,oi=Qt.screenY;At({x:kt,y:oi}),window.clearInterval(fe.current)}function st(di){if(je){var Qt=di.touches[0],kt=Qt.screenX,oi=Qt.screenY;At({x:kt,y:oi});var Di=kt-je.x,ki=oi-je.y;Me(Di,ki);var Bi=Date.now();Ht(Bi),ye(Bi-Pt),ae({x:Di,y:ki})}}function ot(){if(je&&(At(null),ae(null),W)){var di=W.x/Le,Qt=W.y/Le,kt=Math.abs(di),oi=Math.abs(Qt);if(Math.max(kt,oi)<be)return;var Di=di,ki=Qt;fe.current=window.setInterval(function(){if(Math.abs(Di)<Se&&Math.abs(ki)<Se){window.clearInterval(fe.current);return}Di*=Oe,ki*=Oe,Me(Di*re,ki*re)},re)}}var xt=(0,I.useRef)();function Ut(di){var Qt=di.deltaX,kt=di.deltaY,oi=0,Di=Math.abs(Qt),ki=Math.abs(kt);Di===ki?oi=xt.current==="x"?Qt:kt:Di>ki?(oi=Qt,xt.current="x"):(oi=kt,xt.current="y"),Me(-oi,-oi)&&di.preventDefault()}var ti=(0,I.useRef)(null);ti.current={onTouchStart:_e,onTouchMove:st,onTouchEnd:ot,onWheel:Ut},I.useEffect(function(){function di(Di){ti.current.onTouchStart(Di)}function Qt(Di){ti.current.onTouchMove(Di)}function kt(Di){ti.current.onTouchEnd(Di)}function oi(Di){ti.current.onWheel(Di)}return document.addEventListener("touchmove",Qt,{passive:!1}),document.addEventListener("touchend",kt,{passive:!0}),Ae.current.addEventListener("touchstart",di,{passive:!0}),Ae.current.addEventListener("wheel",oi,{passive:!1}),function(){document.removeEventListener("touchmove",Qt),document.removeEventListener("touchend",kt)}},[])}var Be=oe(34280);function Dt(Ae){var Me=(0,I.useState)(0),tt=(0,ge.Z)(Me,2),ft=tt[0],je=tt[1],At=(0,I.useRef)(0),Lt=(0,I.useRef)();return Lt.current=Ae,(0,Be.o)(function(){var vt;(vt=Lt.current)===null||vt===void 0||vt.call(Lt)},[ft]),function(){At.current===ft&&(At.current+=1,je(At.current))}}function te(Ae){var Me=(0,I.useRef)([]),tt=(0,I.useState)({}),ft=(0,ge.Z)(tt,2),je=ft[1],At=(0,I.useRef)(typeof Ae=="function"?Ae():Ae),Lt=Dt(function(){var Pt=At.current;Me.current.forEach(function(Ht){Pt=Ht(Pt)}),Me.current=[],At.current=Pt,je({})});function vt(Pt){Me.current.push(Pt),Lt()}return[At.current,vt]}var z={width:0,height:0,left:0,top:0,right:0};function X(Ae,Me,tt,ft,je,At,Lt){var vt=Lt.tabs,Pt=Lt.tabPosition,Ht=Lt.rtl,Xe,Ft,Le;return["top","bottom"].includes(Pt)?(Xe="width",Ft=Ht?"right":"left",Le=Math.abs(tt)):(Xe="height",Ft="top",Le=-tt),(0,I.useMemo)(function(){if(!vt.length)return[0,0];for(var ye=vt.length,we=ye,K=0;K<ye;K+=1){var W=Ae.get(vt[K].key)||z;if(Math.floor(W[Ft]+W[Xe])>Math.floor(Le+Me)){we=K-1;break}}for(var ae=0,fe=ye-1;fe>=0;fe-=1){var _e=Ae.get(vt[fe].key)||z;if(_e[Ft]<Le){ae=fe+1;break}}return ae>=we?[0,0]:[ae,we]},[Ae,Me,ft,je,At,Le,Pt,vt.map(function(ye){return ye.key}).join("_"),Ht])}function J(Ae){var Me;return Ae instanceof Map?(Me={},Ae.forEach(function(tt,ft){Me[ft]=tt})):Me=Ae,JSON.stringify(Me)}var de="TABS_DQ";function ie(Ae){return String(Ae).replace(/"/g,de)}function A(Ae,Me,tt,ft){return!(!tt||ft||Ae===!1||Ae===void 0&&(Me===!1||Me===null))}var L=I.forwardRef(function(Ae,Me){var tt=Ae.prefixCls,ft=Ae.editable,je=Ae.locale,At=Ae.style;return!ft||ft.showAdd===!1?null:I.createElement("button",{ref:Me,type:"button",className:"".concat(tt,"-nav-add"),style:At,"aria-label":(je==null?void 0:je.addAriaLabel)||"Add tab",onClick:function(vt){ft.onEdit("add",{event:vt})}},ft.addIcon||"+")}),V=L,pe=I.forwardRef(function(Ae,Me){var tt=Ae.position,ft=Ae.prefixCls,je=Ae.extra;if(!je)return null;var At,Lt={};return(0,q.Z)(je)==="object"&&!I.isValidElement(je)?Lt=je:Lt.right=je,tt==="right"&&(At=Lt.right),tt==="left"&&(At=Lt.left),At?I.createElement("div",{className:"".concat(ft,"-extra-content"),ref:Me},At):null}),ze=pe,at=oe(96478),Ot=oe(28321),Ce=oe(10228),jt=I.forwardRef(function(Ae,Me){var tt=Ae.prefixCls,ft=Ae.id,je=Ae.tabs,At=Ae.locale,Lt=Ae.mobile,vt=Ae.more,Pt=vt===void 0?{}:vt,Ht=Ae.style,Xe=Ae.className,Ft=Ae.editable,Le=Ae.tabBarGutter,ye=Ae.rtl,we=Ae.removeAriaLabel,K=Ae.onTabClick,W=Ae.getPopupContainer,ae=Ae.popupClassName,fe=(0,I.useState)(!1),_e=(0,ge.Z)(fe,2),st=_e[0],ot=_e[1],xt=(0,I.useState)(null),Ut=(0,ge.Z)(xt,2),ti=Ut[0],di=Ut[1],Qt=Pt.icon,kt=Qt===void 0?"More":Qt,oi="".concat(ft,"-more-popup"),Di="".concat(tt,"-dropdown"),ki=ti!==null?"".concat(oi,"-").concat(ti):null,Bi=At==null?void 0:At.dropdownAriaLabel;function pi(Mi,Oi){Mi.preventDefault(),Mi.stopPropagation(),Ft.onEdit("remove",{key:Oi,event:Mi})}var mi=I.createElement(Ot.ZP,{onClick:function(Oi){var yn=Oi.key,Ri=Oi.domEvent;K(yn,Ri),ot(!1)},prefixCls:"".concat(Di,"-menu"),id:oi,tabIndex:-1,role:"listbox","aria-activedescendant":ki,selectedKeys:[ti],"aria-label":Bi!==void 0?Bi:"expanded dropdown"},je.map(function(Mi){var Oi=Mi.closable,yn=Mi.disabled,Ri=Mi.closeIcon,Dn=Mi.key,hn=Mi.label,Yn=A(Oi,Ri,Ft,yn);return I.createElement(Ot.sN,{key:Dn,id:"".concat(oi,"-").concat(Dn),role:"option","aria-controls":ft&&"".concat(ft,"-panel-").concat(Dn),disabled:yn},I.createElement("span",null,hn),Yn&&I.createElement("button",{type:"button","aria-label":we||"remove",tabIndex:0,className:"".concat(Di,"-menu-item-remove"),onClick:function(gr){gr.stopPropagation(),pi(gr,Dn)}},Ri||Ft.removeIcon||"\xD7"))}));function Xi(Mi){for(var Oi=je.filter(function(Yn){return!Yn.disabled}),yn=Oi.findIndex(function(Yn){return Yn.key===ti})||0,Ri=Oi.length,Dn=0;Dn<Ri;Dn+=1){yn=(yn+Mi+Ri)%Ri;var hn=Oi[yn];if(!hn.disabled){di(hn.key);return}}}function nn(Mi){var Oi=Mi.which;if(!st){[Ce.Z.DOWN,Ce.Z.SPACE,Ce.Z.ENTER].includes(Oi)&&(ot(!0),Mi.preventDefault());return}switch(Oi){case Ce.Z.UP:Xi(-1),Mi.preventDefault();break;case Ce.Z.DOWN:Xi(1),Mi.preventDefault();break;case Ce.Z.ESC:ot(!1);break;case Ce.Z.SPACE:case Ce.Z.ENTER:ti!==null&&K(ti,Mi);break}}(0,I.useEffect)(function(){var Mi=document.getElementById(ki);Mi&&Mi.scrollIntoView&&Mi.scrollIntoView(!1)},[ti]),(0,I.useEffect)(function(){st||di(null)},[st]);var un=(0,De.Z)({},ye?"marginRight":"marginLeft",Le);je.length||(un.visibility="hidden",un.order=1);var Ji=P()((0,De.Z)({},"".concat(Di,"-rtl"),ye)),dr=Lt?null:I.createElement(at.Z,(0,ce.Z)({prefixCls:Di,overlay:mi,visible:je.length?st:!1,onVisibleChange:ot,overlayClassName:P()(Ji,ae),mouseEnterDelay:.1,mouseLeaveDelay:.1,getPopupContainer:W},Pt),I.createElement("button",{type:"button",className:"".concat(tt,"-nav-more"),style:un,"aria-haspopup":"listbox","aria-controls":oi,id:"".concat(ft,"-more"),"aria-expanded":st,onKeyDown:nn},kt));return I.createElement("div",{className:P()("".concat(tt,"-nav-operations"),Xe),style:Ht,ref:Me},dr,I.createElement(V,{prefixCls:tt,locale:At,editable:Ft}))}),Mt=I.memo(jt,function(Ae,Me){return Me.tabMoving}),dt=function(Me){var tt=Me.prefixCls,ft=Me.id,je=Me.active,At=Me.focus,Lt=Me.tab,vt=Lt.key,Pt=Lt.label,Ht=Lt.disabled,Xe=Lt.closeIcon,Ft=Lt.icon,Le=Me.closable,ye=Me.renderWrapper,we=Me.removeAriaLabel,K=Me.editable,W=Me.onClick,ae=Me.onFocus,fe=Me.onBlur,_e=Me.onKeyDown,st=Me.onMouseDown,ot=Me.onMouseUp,xt=Me.style,Ut=Me.tabCount,ti=Me.currentPosition,di="".concat(tt,"-tab"),Qt=A(Le,Xe,K,Ht);function kt(pi){Ht||W(pi)}function oi(pi){pi.preventDefault(),pi.stopPropagation(),K.onEdit("remove",{key:vt,event:pi})}var Di=I.useMemo(function(){return Ft&&typeof Pt=="string"?I.createElement("span",null,Pt):Pt},[Pt,Ft]),ki=I.useRef(null);I.useEffect(function(){At&&ki.current&&ki.current.focus()},[At]);var Bi=I.createElement("div",{key:vt,"data-node-key":ie(vt),className:P()(di,(0,De.Z)((0,De.Z)((0,De.Z)((0,De.Z)({},"".concat(di,"-with-remove"),Qt),"".concat(di,"-active"),je),"".concat(di,"-disabled"),Ht),"".concat(di,"-focus"),At)),style:xt,onClick:kt},I.createElement("div",{ref:ki,role:"tab","aria-selected":je,id:ft&&"".concat(ft,"-tab-").concat(vt),className:"".concat(di,"-btn"),"aria-controls":ft&&"".concat(ft,"-panel-").concat(vt),"aria-disabled":Ht,tabIndex:Ht?null:je?0:-1,onClick:function(mi){mi.stopPropagation(),kt(mi)},onKeyDown:_e,onMouseDown:st,onMouseUp:ot,onFocus:ae,onBlur:fe},At&&I.createElement("div",{"aria-live":"polite",style:{width:0,height:0,position:"absolute",overflow:"hidden",opacity:0}},"Tab ".concat(ti," of ").concat(Ut)),Ft&&I.createElement("span",{className:"".concat(di,"-icon")},Ft),Pt&&Di),Qt&&I.createElement("button",{type:"button",role:"tab","aria-label":we||"remove",tabIndex:je?0:-1,className:"".concat(di,"-remove"),onClick:function(mi){mi.stopPropagation(),oi(mi)}},Xe||K.removeIcon||"\xD7"));return ye?ye(Bi):Bi},Ti=dt,fi=function(Me,tt){var ft=Me.offsetWidth,je=Me.offsetHeight,At=Me.offsetTop,Lt=Me.offsetLeft,vt=Me.getBoundingClientRect(),Pt=vt.width,Ht=vt.height,Xe=vt.left,Ft=vt.top;return Math.abs(Pt-ft)<1?[Pt,Ht,Xe-tt.left,Ft-tt.top]:[ft,je,Lt,At]},Yi=function(Me){var tt=Me.current||{},ft=tt.offsetWidth,je=ft===void 0?0:ft,At=tt.offsetHeight,Lt=At===void 0?0:At;if(Me.current){var vt=Me.current.getBoundingClientRect(),Pt=vt.width,Ht=vt.height;if(Math.abs(Pt-je)<1)return[Pt,Ht]}return[je,Lt]},Kt=function(Me,tt){return Me[tt?0:1]},ln=I.forwardRef(function(Ae,Me){var tt=Ae.className,ft=Ae.style,je=Ae.id,At=Ae.animated,Lt=Ae.activeKey,vt=Ae.rtl,Pt=Ae.extra,Ht=Ae.editable,Xe=Ae.locale,Ft=Ae.tabPosition,Le=Ae.tabBarGutter,ye=Ae.children,we=Ae.onTabClick,K=Ae.onTabScroll,W=Ae.indicator,ae=I.useContext(k),fe=ae.prefixCls,_e=ae.tabs,st=(0,I.useRef)(null),ot=(0,I.useRef)(null),xt=(0,I.useRef)(null),Ut=(0,I.useRef)(null),ti=(0,I.useRef)(null),di=(0,I.useRef)(null),Qt=(0,I.useRef)(null),kt=Ft==="top"||Ft==="bottom",oi=he(0,function(Hi,vi){kt&&K&&K({direction:Hi>vi?"left":"right"})}),Di=(0,ge.Z)(oi,2),ki=Di[0],Bi=Di[1],pi=he(0,function(Hi,vi){!kt&&K&&K({direction:Hi>vi?"top":"bottom"})}),mi=(0,ge.Z)(pi,2),Xi=mi[0],nn=mi[1],un=(0,I.useState)([0,0]),Ji=(0,ge.Z)(un,2),dr=Ji[0],Mi=Ji[1],Oi=(0,I.useState)([0,0]),yn=(0,ge.Z)(Oi,2),Ri=yn[0],Dn=yn[1],hn=(0,I.useState)([0,0]),Yn=(0,ge.Z)(hn,2),fn=Yn[0],gr=Yn[1],Yr=(0,I.useState)([0,0]),Ei=(0,ge.Z)(Yr,2),$t=Ei[0],Re=Ei[1],Je=te(new Map),ut=(0,ge.Z)(Je,2),it=ut[0],wt=ut[1],St=G(_e,it,Ri[0]),Bt=Kt(dr,kt),ni=Kt(Ri,kt),Gi=Kt(fn,kt),gi=Kt($t,kt),dn=Math.floor(Bt)<Math.floor(ni+Gi),_i=dn?Bt-gi:Bt-Gi,Ai="".concat(fe,"-nav-operations-hidden"),Ci=0,Ni=0;kt&&vt?(Ci=0,Ni=Math.max(0,ni-_i)):(Ci=Math.min(0,_i-ni),Ni=0);function $i(Hi){return Hi<Ci?Ci:Hi>Ni?Ni:Hi}var ui=(0,I.useRef)(null),Ii=(0,I.useState)(),Qi=(0,ge.Z)(Ii,2),Fi=Qi[0],wi=Qi[1];function ji(){wi(Date.now())}function Ki(){ui.current&&clearTimeout(ui.current)}We(Ut,function(Hi,vi){function Wt(_n,mr){_n(function(Nn){var ar=$i(Nn+mr);return ar})}return dn?(kt?Wt(Bi,Hi):Wt(nn,vi),Ki(),ji(),!0):!1}),(0,I.useEffect)(function(){return Ki(),Fi&&(ui.current=setTimeout(function(){wi(0)},100)),Ki},[Fi]);var en=X(St,_i,kt?ki:Xi,ni,Gi,gi,(0,qe.Z)((0,qe.Z)({},Ae),{},{tabs:_e})),Pn=(0,ge.Z)(en,2),tn=Pn[0],er=Pn[1],cn=(0,O.Z)(function(){var Hi=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Lt,vi=St.get(Hi)||{width:0,height:0,left:0,right:0,top:0};if(kt){var Wt=ki;vt?vi.right<ki?Wt=vi.right:vi.right+vi.width>ki+_i&&(Wt=vi.right+vi.width-_i):vi.left<-ki?Wt=-vi.left:vi.left+vi.width>-ki+_i&&(Wt=-(vi.left+vi.width-_i)),nn(0),Bi($i(Wt))}else{var _n=Xi;vi.top<-Xi?_n=-vi.top:vi.top+vi.height>-Xi+_i&&(_n=-(vi.top+vi.height-_i)),Bi(0),nn($i(_n))}}),Cn=(0,I.useState)(),tr=(0,ge.Z)(Cn,2),Ui=tr[0],zi=tr[1],Ln=(0,I.useState)(!1),bn=(0,ge.Z)(Ln,2),rn=bn[0],xn=bn[1],pn=_e.filter(function(Hi){return!Hi.disabled}).map(function(Hi){return Hi.key}),Vn=function(vi){var Wt=pn.indexOf(Ui||Lt),_n=pn.length,mr=(Wt+vi+_n)%_n,Nn=pn[mr];zi(Nn)},Mr=function(vi){var Wt=vi.code,_n=vt&&kt,mr=pn[0],Nn=pn[pn.length-1];switch(Wt){case"ArrowLeft":{kt&&Vn(_n?1:-1);break}case"ArrowRight":{kt&&Vn(_n?-1:1);break}case"ArrowUp":{vi.preventDefault(),kt||Vn(-1);break}case"ArrowDown":{vi.preventDefault(),kt||Vn(1);break}case"Home":{vi.preventDefault(),zi(mr);break}case"End":{vi.preventDefault(),zi(Nn);break}case"Enter":case"Space":{vi.preventDefault(),we(Lt,vi);break}case"Backspace":case"Delete":{var ar=pn.indexOf(Ui),$n=_e.find(function(Sr){return Sr.key===Ui}),cs=A($n==null?void 0:$n.closable,$n==null?void 0:$n.closeIcon,Ht,$n==null?void 0:$n.disabled);cs&&(vi.preventDefault(),vi.stopPropagation(),Ht.onEdit("remove",{key:Ui,event:vi}),ar===pn.length-1?Vn(-1):Vn(1));break}}},On={};kt?On[vt?"marginRight":"marginLeft"]=Le:On.marginTop=Le;var Br=_e.map(function(Hi,vi){var Wt=Hi.key;return I.createElement(Ti,{id:je,prefixCls:fe,key:Wt,tab:Hi,style:vi===0?void 0:On,closable:Hi.closable,editable:Ht,active:Wt===Lt,focus:Wt===Ui,renderWrapper:ye,removeAriaLabel:Xe==null?void 0:Xe.removeAriaLabel,tabCount:pn.length,currentPosition:vi+1,onClick:function(mr){we(Wt,mr)},onKeyDown:Mr,onFocus:function(){rn||zi(Wt),cn(Wt),ji(),Ut.current&&(vt||(Ut.current.scrollLeft=0),Ut.current.scrollTop=0)},onBlur:function(){zi(void 0)},onMouseDown:function(){xn(!0)},onMouseUp:function(){xn(!1)}})}),En=function(){return wt(function(){var vi,Wt=new Map,_n=(vi=ti.current)===null||vi===void 0?void 0:vi.getBoundingClientRect();return _e.forEach(function(mr){var Nn,ar=mr.key,$n=(Nn=ti.current)===null||Nn===void 0?void 0:Nn.querySelector('[data-node-key="'.concat(ie(ar),'"]'));if($n){var cs=fi($n,_n),Sr=(0,ge.Z)(cs,4),vn=Sr[0],hs=Sr[1],ns=Sr[2],or=Sr[3];Wt.set(ar,{width:vn,height:hs,left:ns,top:or})}}),Wt})};(0,I.useEffect)(function(){En()},[_e.map(function(Hi){return Hi.key}).join("_")]);var sr=Dt(function(){var Hi=Yi(st),vi=Yi(ot),Wt=Yi(xt);Mi([Hi[0]-vi[0]-Wt[0],Hi[1]-vi[1]-Wt[1]]);var _n=Yi(Qt);gr(_n);var mr=Yi(di);Re(mr);var Nn=Yi(ti);Dn([Nn[0]-_n[0],Nn[1]-_n[1]]),En()}),Rr=_e.slice(0,tn),Tr=_e.slice(er+1),xr=[].concat((0,T.Z)(Rr),(0,T.Z)(Tr)),Mn=St.get(Lt),cr=U({activeTabOffset:Mn,horizontal:kt,indicator:W,rtl:vt}),wr=cr.style;(0,I.useEffect)(function(){cn()},[Lt,Ci,Ni,J(Mn),J(St),kt]),(0,I.useEffect)(function(){sr()},[vt]);var Nr=!!xr.length,kn="".concat(fe,"-nav-wrap"),pr,Gn,hr,Wr;return kt?vt?(Gn=ki>0,pr=ki!==Ni):(pr=ki<0,Gn=ki!==Ci):(hr=Xi<0,Wr=Xi!==Ci),I.createElement(M.Z,{onResize:sr},I.createElement("div",{ref:(0,Y.x1)(Me,st),role:"tablist","aria-orientation":kt?"horizontal":"vertical",className:P()("".concat(fe,"-nav"),tt),style:ft,onKeyDown:function(){ji()}},I.createElement(ze,{ref:ot,position:"left",extra:Pt,prefixCls:fe}),I.createElement(M.Z,{onResize:sr},I.createElement("div",{className:P()(kn,(0,De.Z)((0,De.Z)((0,De.Z)((0,De.Z)({},"".concat(kn,"-ping-left"),pr),"".concat(kn,"-ping-right"),Gn),"".concat(kn,"-ping-top"),hr),"".concat(kn,"-ping-bottom"),Wr)),ref:Ut},I.createElement(M.Z,{onResize:sr},I.createElement("div",{ref:ti,className:"".concat(fe,"-nav-list"),style:{transform:"translate(".concat(ki,"px, ").concat(Xi,"px)"),transition:Fi?"none":void 0}},Br,I.createElement(V,{ref:Qt,prefixCls:fe,locale:Xe,editable:Ht,style:(0,qe.Z)((0,qe.Z)({},Br.length===0?void 0:On),{},{visibility:Nr?"hidden":null})}),I.createElement("div",{className:P()("".concat(fe,"-ink-bar"),(0,De.Z)({},"".concat(fe,"-ink-bar-animated"),At.inkBar)),style:wr}))))),I.createElement(Mt,(0,ce.Z)({},Ae,{removeAriaLabel:Xe==null?void 0:Xe.removeAriaLabel,ref:di,prefixCls:fe,tabs:xr,className:!Nr&&Ai,tabMoving:!!Fi})),I.createElement(ze,{ref:xt,position:"right",extra:Pt,prefixCls:fe})))}),Ne=ln,Ge=I.forwardRef(function(Ae,Me){var tt=Ae.prefixCls,ft=Ae.className,je=Ae.style,At=Ae.id,Lt=Ae.active,vt=Ae.tabKey,Pt=Ae.children;return I.createElement("div",{id:At&&"".concat(At,"-panel-").concat(vt),role:"tabpanel",tabIndex:Lt?0:-1,"aria-labelledby":At&&"".concat(At,"-tab-").concat(vt),"aria-hidden":!Lt,style:je,className:P()(tt,Lt&&"".concat(tt,"-active"),ft),ref:Me},Pt)}),ve=Ge,nt=["renderTabBar"],_t=["label","key"],lt=function(Me){var tt=Me.renderTabBar,ft=(0,S.Z)(Me,nt),je=I.useContext(k),At=je.tabs;if(tt){var Lt=(0,qe.Z)((0,qe.Z)({},ft),{},{panes:At.map(function(vt){var Pt=vt.label,Ht=vt.key,Xe=(0,S.Z)(vt,_t);return I.createElement(ve,(0,ce.Z)({tab:Pt,key:Ht,tabKey:Ht},Xe))})});return tt(Lt,Ne)}return I.createElement(Ne,ft)},ee=lt,xe=oe(77900),$e=["key","forceRender","style","className","destroyInactiveTabPane"],Ye=function(Me){var tt=Me.id,ft=Me.activeKey,je=Me.animated,At=Me.tabPosition,Lt=Me.destroyInactiveTabPane,vt=I.useContext(k),Pt=vt.prefixCls,Ht=vt.tabs,Xe=je.tabPane,Ft="".concat(Pt,"-tabpane");return I.createElement("div",{className:P()("".concat(Pt,"-content-holder"))},I.createElement("div",{className:P()("".concat(Pt,"-content"),"".concat(Pt,"-content-").concat(At),(0,De.Z)({},"".concat(Pt,"-content-animated"),Xe))},Ht.map(function(Le){var ye=Le.key,we=Le.forceRender,K=Le.style,W=Le.className,ae=Le.destroyInactiveTabPane,fe=(0,S.Z)(Le,$e),_e=ye===ft;return I.createElement(xe.default,(0,ce.Z)({key:ye,visible:_e,forceRender:we,removeOnLeave:!!(Lt||ae),leavedClassName:"".concat(Ft,"-hidden")},je.tabPaneMotion),function(st,ot){var xt=st.style,Ut=st.className;return I.createElement(ve,(0,ce.Z)({},fe,{prefixCls:Ft,id:tt,tabKey:ye,animated:Xe,active:_e,style:(0,qe.Z)((0,qe.Z)({},K),xt),className:P()(W,Ut),ref:ot}))})})))},rt=Ye,gt=oe(48736);function Yt(){var Ae=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{inkBar:!0,tabPane:!1},Me;return Ae===!1?Me={inkBar:!1,tabPane:!1}:Ae===!0?Me={inkBar:!0,tabPane:!1}:Me=(0,qe.Z)({inkBar:!0},(0,q.Z)(Ae)==="object"?Ae:{}),Me.tabPaneMotion&&Me.tabPane===void 0&&(Me.tabPane=!0),!Me.tabPaneMotion&&Me.tabPane&&(Me.tabPane=!1),Me}var pt=["id","prefixCls","className","items","direction","activeKey","defaultActiveKey","editable","animated","tabPosition","tabBarGutter","tabBarStyle","tabBarExtraContent","locale","more","destroyInactiveTabPane","renderTabBar","onChange","onTabClick","onTabScroll","getPopupContainer","popupClassName","indicator"],ke=0,ht=I.forwardRef(function(Ae,Me){var tt=Ae.id,ft=Ae.prefixCls,je=ft===void 0?"rc-tabs":ft,At=Ae.className,Lt=Ae.items,vt=Ae.direction,Pt=Ae.activeKey,Ht=Ae.defaultActiveKey,Xe=Ae.editable,Ft=Ae.animated,Le=Ae.tabPosition,ye=Le===void 0?"top":Le,we=Ae.tabBarGutter,K=Ae.tabBarStyle,W=Ae.tabBarExtraContent,ae=Ae.locale,fe=Ae.more,_e=Ae.destroyInactiveTabPane,st=Ae.renderTabBar,ot=Ae.onChange,xt=Ae.onTabClick,Ut=Ae.onTabScroll,ti=Ae.getPopupContainer,di=Ae.popupClassName,Qt=Ae.indicator,kt=(0,S.Z)(Ae,pt),oi=I.useMemo(function(){return(Lt||[]).filter(function($t){return $t&&(0,q.Z)($t)==="object"&&"key"in $t})},[Lt]),Di=vt==="rtl",ki=Yt(Ft),Bi=(0,I.useState)(!1),pi=(0,ge.Z)(Bi,2),mi=pi[0],Xi=pi[1];(0,I.useEffect)(function(){Xi((0,ne.Z)())},[]);var nn=(0,d.Z)(function(){var $t;return($t=oi[0])===null||$t===void 0?void 0:$t.key},{value:Pt,defaultValue:Ht}),un=(0,ge.Z)(nn,2),Ji=un[0],dr=un[1],Mi=(0,I.useState)(function(){return oi.findIndex(function($t){return $t.key===Ji})}),Oi=(0,ge.Z)(Mi,2),yn=Oi[0],Ri=Oi[1];(0,I.useEffect)(function(){var $t=oi.findIndex(function(Je){return Je.key===Ji});if($t===-1){var Re;$t=Math.max(0,Math.min(yn,oi.length-1)),dr((Re=oi[$t])===null||Re===void 0?void 0:Re.key)}Ri($t)},[oi.map(function($t){return $t.key}).join("_"),Ji,yn]);var Dn=(0,d.Z)(null,{value:tt}),hn=(0,ge.Z)(Dn,2),Yn=hn[0],fn=hn[1];(0,I.useEffect)(function(){tt||(fn("rc-tabs-".concat(ke)),ke+=1)},[]);function gr($t,Re){xt==null||xt($t,Re);var Je=$t!==Ji;dr($t),Je&&(ot==null||ot($t))}var Yr={id:Yn,activeKey:Ji,animated:ki,tabPosition:ye,rtl:Di,mobile:mi},Ei=(0,qe.Z)((0,qe.Z)({},Yr),{},{editable:Xe,locale:ae,more:fe,tabBarGutter:we,onTabClick:gr,onTabScroll:Ut,extra:W,style:K,panes:null,getPopupContainer:ti,popupClassName:di,indicator:Qt});return I.createElement(k.Provider,{value:{tabs:oi,prefixCls:je}},I.createElement("div",(0,ce.Z)({ref:Me,id:tt,className:P()(je,"".concat(je,"-").concat(ye),(0,De.Z)((0,De.Z)((0,De.Z)({},"".concat(je,"-mobile"),mi),"".concat(je,"-editable"),Xe),"".concat(je,"-rtl"),Di),At)},kt),I.createElement(ee,(0,ce.Z)({},Ei,{renderTabBar:st})),I.createElement(rt,(0,ce.Z)({destroyInactiveTabPane:_e},Yr,{animated:ki}))))}),Gt=ht,zt=Gt},29125:function(Li,Rt,oe){"use strict";oe.d(Rt,{G:function(){return ge},Z:function(){return j}});var ce=oe(92310),De=oe.n(ce),qe=oe(59301);function ge(U){var $=U.children,G=U.prefixCls,he=U.id,be=U.overlayInnerStyle,Se=U.bodyClassName,re=U.className,Oe=U.style;return qe.createElement("div",{className:De()("".concat(G,"-content"),re),style:Oe},qe.createElement("div",{className:De()("".concat(G,"-inner"),Se),id:he,role:"tooltip",style:be},typeof $=="function"?$():$))}var q=oe(54476),S=oe(33885),Te=oe(75931),P=oe(65030),d={shiftX:64,adjustY:1},ne={adjustX:1,shiftY:!0},I=[0,0],k={left:{points:["cr","cl"],overflow:ne,offset:[-4,0],targetOffset:I},right:{points:["cl","cr"],overflow:ne,offset:[4,0],targetOffset:I},top:{points:["bc","tc"],overflow:d,offset:[0,-4],targetOffset:I},bottom:{points:["tc","bc"],overflow:d,offset:[0,4],targetOffset:I},topLeft:{points:["bl","tl"],overflow:d,offset:[0,-4],targetOffset:I},leftTop:{points:["tr","tl"],overflow:ne,offset:[-4,0],targetOffset:I},topRight:{points:["br","tr"],overflow:d,offset:[0,-4],targetOffset:I},rightTop:{points:["tl","tr"],overflow:ne,offset:[4,0],targetOffset:I},bottomRight:{points:["tr","br"],overflow:d,offset:[0,4],targetOffset:I},rightBottom:{points:["bl","br"],overflow:ne,offset:[4,0],targetOffset:I},bottomLeft:{points:["tl","bl"],overflow:d,offset:[0,4],targetOffset:I},leftBottom:{points:["br","bl"],overflow:ne,offset:[-4,0],targetOffset:I}},T=null,M=oe(80402),O=["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","motion","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer","overlayInnerStyle","arrowContent","overlay","id","showArrow","classNames","styles"],Y=function($,G){var he=$.overlayClassName,be=$.trigger,Se=be===void 0?["hover"]:be,re=$.mouseEnterDelay,Oe=re===void 0?0:re,We=$.mouseLeaveDelay,Be=We===void 0?.1:We,Dt=$.overlayStyle,te=$.prefixCls,z=te===void 0?"rc-tooltip":te,X=$.children,J=$.onVisibleChange,de=$.afterVisibleChange,ie=$.transitionName,A=$.animation,L=$.motion,V=$.placement,pe=V===void 0?"right":V,ze=$.align,at=ze===void 0?{}:ze,Ot=$.destroyTooltipOnHide,Ce=Ot===void 0?!1:Ot,jt=$.defaultVisible,Mt=$.getTooltipContainer,dt=$.overlayInnerStyle,Ti=$.arrowContent,fi=$.overlay,Yi=$.id,Kt=$.showArrow,ln=Kt===void 0?!0:Kt,Ne=$.classNames,Ge=$.styles,ve=(0,Te.Z)($,O),nt=(0,M.Z)(Yi),_t=(0,qe.useRef)(null);(0,qe.useImperativeHandle)(G,function(){return _t.current});var lt=(0,S.Z)({},ve);"visible"in $&&(lt.popupVisible=$.visible);var ee=function(){return qe.createElement(ge,{key:"content",prefixCls:z,id:nt,bodyClassName:Ne==null?void 0:Ne.body,overlayInnerStyle:(0,S.Z)((0,S.Z)({},dt),Ge==null?void 0:Ge.body)},fi)},xe=function(){var Ye=qe.Children.only(X),rt=(Ye==null?void 0:Ye.props)||{},gt=(0,S.Z)((0,S.Z)({},rt),{},{"aria-describedby":fi?nt:null});return qe.cloneElement(X,gt)};return qe.createElement(P.Z,(0,q.Z)({popupClassName:De()(he,Ne==null?void 0:Ne.root),prefixCls:z,popup:ee,action:Se,builtinPlacements:k,popupPlacement:pe,ref:_t,popupAlign:at,getPopupContainer:Mt,onPopupVisibleChange:J,afterPopupVisibleChange:de,popupTransitionName:ie,popupAnimation:A,popupMotion:L,defaultPopupVisible:jt,autoDestroy:Ce,mouseLeaveDelay:Be,popupStyle:(0,S.Z)((0,S.Z)({},Dt),Ge==null?void 0:Ge.root),mouseEnterDelay:Oe,arrow:ln},lt),xe())},H=(0,qe.forwardRef)(Y),j=H},49658:function(Li,Rt){"use strict";Rt.Z=function(){if(typeof navigator=="undefined"||typeof window=="undefined")return!1;var oe=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(oe)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(oe==null?void 0:oe.substr(0,4))}},83145:function(Li,Rt,oe){"use strict";Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.CopyToClipboard=void 0;var ce=qe(oe(59301)),De=qe(oe(25769));function qe(U){return U&&U.__esModule?U:{default:U}}function ge(U){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ge=function(G){return typeof G}:ge=function(G){return G&&typeof Symbol=="function"&&G.constructor===Symbol&&G!==Symbol.prototype?"symbol":typeof G},ge(U)}function q(U,$){var G=Object.keys(U);if(Object.getOwnPropertySymbols){var he=Object.getOwnPropertySymbols(U);$&&(he=he.filter(function(be){return Object.getOwnPropertyDescriptor(U,be).enumerable})),G.push.apply(G,he)}return G}function S(U){for(var $=1;$<arguments.length;$++){var G=arguments[$]!=null?arguments[$]:{};$%2?q(G,!0).forEach(function(he){H(U,he,G[he])}):Object.getOwnPropertyDescriptors?Object.defineProperties(U,Object.getOwnPropertyDescriptors(G)):q(G).forEach(function(he){Object.defineProperty(U,he,Object.getOwnPropertyDescriptor(G,he))})}return U}function Te(U,$){if(U==null)return{};var G=P(U,$),he,be;if(Object.getOwnPropertySymbols){var Se=Object.getOwnPropertySymbols(U);for(be=0;be<Se.length;be++)he=Se[be],!($.indexOf(he)>=0)&&Object.prototype.propertyIsEnumerable.call(U,he)&&(G[he]=U[he])}return G}function P(U,$){if(U==null)return{};var G={},he=Object.keys(U),be,Se;for(Se=0;Se<he.length;Se++)be=he[Se],!($.indexOf(be)>=0)&&(G[be]=U[be]);return G}function d(U,$){if(!(U instanceof $))throw new TypeError("Cannot call a class as a function")}function ne(U,$){for(var G=0;G<$.length;G++){var he=$[G];he.enumerable=he.enumerable||!1,he.configurable=!0,"value"in he&&(he.writable=!0),Object.defineProperty(U,he.key,he)}}function I(U,$,G){return $&&ne(U.prototype,$),G&&ne(U,G),U}function k(U,$){return $&&(ge($)==="object"||typeof $=="function")?$:M(U)}function T(U){return T=Object.setPrototypeOf?Object.getPrototypeOf:function(G){return G.__proto__||Object.getPrototypeOf(G)},T(U)}function M(U){if(U===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return U}function O(U,$){if(typeof $!="function"&&$!==null)throw new TypeError("Super expression must either be null or a function");U.prototype=Object.create($&&$.prototype,{constructor:{value:U,writable:!0,configurable:!0}}),$&&Y(U,$)}function Y(U,$){return Y=Object.setPrototypeOf||function(he,be){return he.__proto__=be,he},Y(U,$)}function H(U,$,G){return $ in U?Object.defineProperty(U,$,{value:G,enumerable:!0,configurable:!0,writable:!0}):U[$]=G,U}var j=function(U){O($,U);function $(){var G,he;d(this,$);for(var be=arguments.length,Se=new Array(be),re=0;re<be;re++)Se[re]=arguments[re];return he=k(this,(G=T($)).call.apply(G,[this].concat(Se))),H(M(he),"onClick",function(Oe){var We=he.props,Be=We.text,Dt=We.onCopy,te=We.children,z=We.options,X=ce.default.Children.only(te),J=(0,De.default)(Be,z);Dt&&Dt(Be,J),X&&X.props&&typeof X.props.onClick=="function"&&X.props.onClick(Oe)}),he}return I($,[{key:"render",value:function(){var he=this.props,be=he.text,Se=he.onCopy,re=he.options,Oe=he.children,We=Te(he,["text","onCopy","options","children"]),Be=ce.default.Children.only(Oe);return ce.default.cloneElement(Be,S({},We,{onClick:this.onClick}))}}]),$}(ce.default.PureComponent);Rt.CopyToClipboard=j,H(j,"defaultProps",{onCopy:void 0,options:void 0})},56102:function(Li,Rt,oe){"use strict";var ce=oe(83145),De=ce.CopyToClipboard;De.CopyToClipboard=De,Li.exports=De},76374:function(Li,Rt,oe){"use strict";var ce=function(){if(typeof Map!="undefined")return Map;function te(z,X){var J=-1;return z.some(function(de,ie){return de[0]===X?(J=ie,!0):!1}),J}return function(){function z(){this.__entries__=[]}return Object.defineProperty(z.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),z.prototype.get=function(X){var J=te(this.__entries__,X),de=this.__entries__[J];return de&&de[1]},z.prototype.set=function(X,J){var de=te(this.__entries__,X);~de?this.__entries__[de][1]=J:this.__entries__.push([X,J])},z.prototype.delete=function(X){var J=this.__entries__,de=te(J,X);~de&&J.splice(de,1)},z.prototype.has=function(X){return!!~te(this.__entries__,X)},z.prototype.clear=function(){this.__entries__.splice(0)},z.prototype.forEach=function(X,J){J===void 0&&(J=null);for(var de=0,ie=this.__entries__;de<ie.length;de++){var A=ie[de];X.call(J,A[1],A[0])}},z}()}(),De=typeof window!="undefined"&&typeof document!="undefined"&&window.document===document,qe=function(){return typeof oe.g!="undefined"&&oe.g.Math===Math?oe.g:typeof self!="undefined"&&self.Math===Math?self:typeof window!="undefined"&&window.Math===Math?window:Function("return this")()}(),ge=function(){return typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(qe):function(te){return setTimeout(function(){return te(Date.now())},1e3/60)}}(),q=2;function S(te,z){var X=!1,J=!1,de=0;function ie(){X&&(X=!1,te()),J&&L()}function A(){ge(ie)}function L(){var V=Date.now();if(X){if(V-de<q)return;J=!0}else X=!0,J=!1,setTimeout(A,z);de=V}return L}var Te=20,P=["top","right","bottom","left","width","height","size","weight"],d=typeof MutationObserver!="undefined",ne=function(){function te(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=S(this.refresh.bind(this),Te)}return te.prototype.addObserver=function(z){~this.observers_.indexOf(z)||this.observers_.push(z),this.connected_||this.connect_()},te.prototype.removeObserver=function(z){var X=this.observers_,J=X.indexOf(z);~J&&X.splice(J,1),!X.length&&this.connected_&&this.disconnect_()},te.prototype.refresh=function(){var z=this.updateObservers_();z&&this.refresh()},te.prototype.updateObservers_=function(){var z=this.observers_.filter(function(X){return X.gatherActive(),X.hasActive()});return z.forEach(function(X){return X.broadcastActive()}),z.length>0},te.prototype.connect_=function(){!De||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),d?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},te.prototype.disconnect_=function(){!De||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},te.prototype.onTransitionEnd_=function(z){var X=z.propertyName,J=X===void 0?"":X,de=P.some(function(ie){return!!~J.indexOf(ie)});de&&this.refresh()},te.getInstance=function(){return this.instance_||(this.instance_=new te),this.instance_},te.instance_=null,te}(),I=function(te,z){for(var X=0,J=Object.keys(z);X<J.length;X++){var de=J[X];Object.defineProperty(te,de,{value:z[de],enumerable:!1,writable:!1,configurable:!0})}return te},k=function(te){var z=te&&te.ownerDocument&&te.ownerDocument.defaultView;return z||qe},T=be(0,0,0,0);function M(te){return parseFloat(te)||0}function O(te){for(var z=[],X=1;X<arguments.length;X++)z[X-1]=arguments[X];return z.reduce(function(J,de){var ie=te["border-"+de+"-width"];return J+M(ie)},0)}function Y(te){for(var z=["top","right","bottom","left"],X={},J=0,de=z;J<de.length;J++){var ie=de[J],A=te["padding-"+ie];X[ie]=M(A)}return X}function H(te){var z=te.getBBox();return be(0,0,z.width,z.height)}function j(te){var z=te.clientWidth,X=te.clientHeight;if(!z&&!X)return T;var J=k(te).getComputedStyle(te),de=Y(J),ie=de.left+de.right,A=de.top+de.bottom,L=M(J.width),V=M(J.height);if(J.boxSizing==="border-box"&&(Math.round(L+ie)!==z&&(L-=O(J,"left","right")+ie),Math.round(V+A)!==X&&(V-=O(J,"top","bottom")+A)),!$(te)){var pe=Math.round(L+ie)-z,ze=Math.round(V+A)-X;Math.abs(pe)!==1&&(L-=pe),Math.abs(ze)!==1&&(V-=ze)}return be(de.left,de.top,L,V)}var U=function(){return typeof SVGGraphicsElement!="undefined"?function(te){return te instanceof k(te).SVGGraphicsElement}:function(te){return te instanceof k(te).SVGElement&&typeof te.getBBox=="function"}}();function $(te){return te===k(te).document.documentElement}function G(te){return De?U(te)?H(te):j(te):T}function he(te){var z=te.x,X=te.y,J=te.width,de=te.height,ie=typeof DOMRectReadOnly!="undefined"?DOMRectReadOnly:Object,A=Object.create(ie.prototype);return I(A,{x:z,y:X,width:J,height:de,top:X,right:z+J,bottom:de+X,left:z}),A}function be(te,z,X,J){return{x:te,y:z,width:X,height:J}}var Se=function(){function te(z){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=be(0,0,0,0),this.target=z}return te.prototype.isActive=function(){var z=G(this.target);return this.contentRect_=z,z.width!==this.broadcastWidth||z.height!==this.broadcastHeight},te.prototype.broadcastRect=function(){var z=this.contentRect_;return this.broadcastWidth=z.width,this.broadcastHeight=z.height,z},te}(),re=function(){function te(z,X){var J=he(X);I(this,{target:z,contentRect:J})}return te}(),Oe=function(){function te(z,X,J){if(this.activeObservations_=[],this.observations_=new ce,typeof z!="function")throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=z,this.controller_=X,this.callbackCtx_=J}return te.prototype.observe=function(z){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element=="undefined"||!(Element instanceof Object))){if(!(z instanceof k(z).Element))throw new TypeError('parameter 1 is not of type "Element".');var X=this.observations_;X.has(z)||(X.set(z,new Se(z)),this.controller_.addObserver(this),this.controller_.refresh())}},te.prototype.unobserve=function(z){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element=="undefined"||!(Element instanceof Object))){if(!(z instanceof k(z).Element))throw new TypeError('parameter 1 is not of type "Element".');var X=this.observations_;X.has(z)&&(X.delete(z),X.size||this.controller_.removeObserver(this))}},te.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},te.prototype.gatherActive=function(){var z=this;this.clearActive(),this.observations_.forEach(function(X){X.isActive()&&z.activeObservations_.push(X)})},te.prototype.broadcastActive=function(){if(this.hasActive()){var z=this.callbackCtx_,X=this.activeObservations_.map(function(J){return new re(J.target,J.broadcastRect())});this.callback_.call(z,X,z),this.clearActive()}},te.prototype.clearActive=function(){this.activeObservations_.splice(0)},te.prototype.hasActive=function(){return this.activeObservations_.length>0},te}(),We=typeof WeakMap!="undefined"?new WeakMap:new ce,Be=function(){function te(z){if(!(this instanceof te))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var X=ne.getInstance(),J=new Oe(z,X,this);We.set(this,J)}return te}();["observe","unobserve","disconnect"].forEach(function(te){Be.prototype[te]=function(){var z;return(z=We.get(this))[te].apply(z,arguments)}});var Dt=function(){return typeof qe.ResizeObserver!="undefined"?qe.ResizeObserver:Be}();Rt.Z=Dt},98040:function(Li){Li.exports=function(){var Rt=document.getSelection();if(!Rt.rangeCount)return function(){};for(var oe=document.activeElement,ce=[],De=0;De<Rt.rangeCount;De++)ce.push(Rt.getRangeAt(De));switch(oe.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":oe.blur();break;default:oe=null;break}return Rt.removeAllRanges(),function(){Rt.type==="Caret"&&Rt.removeAllRanges(),Rt.rangeCount||ce.forEach(function(qe){Rt.addRange(qe)}),oe&&oe.focus()}}},44523:function(Li,Rt,oe){"use strict";oe.d(Rt,{ZP:function(){return Oa}});const ce=Number.isFinite||function(h){return typeof h=="number"&&isFinite(h)},De=Number.isSafeInteger||function(h){return typeof h=="number"&&Math.abs(h)<=qe},qe=Number.MAX_SAFE_INTEGER||9007199254740991;let ge=function(h){return h.NETWORK_ERROR="networkError",h.MEDIA_ERROR="mediaError",h.KEY_SYSTEM_ERROR="keySystemError",h.MUX_ERROR="muxError",h.OTHER_ERROR="otherError",h}({}),q=function(h){return h.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",h.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",h.KEY_SYSTEM_NO_SESSION="keySystemNoSession",h.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",h.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",h.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",h.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",h.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",h.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",h.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",h.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",h.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",h.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",h.MANIFEST_LOAD_ERROR="manifestLoadError",h.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",h.MANIFEST_PARSING_ERROR="manifestParsingError",h.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",h.LEVEL_EMPTY_ERROR="levelEmptyError",h.LEVEL_LOAD_ERROR="levelLoadError",h.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",h.LEVEL_PARSING_ERROR="levelParsingError",h.LEVEL_SWITCH_ERROR="levelSwitchError",h.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",h.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",h.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",h.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",h.FRAG_LOAD_ERROR="fragLoadError",h.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",h.FRAG_DECRYPT_ERROR="fragDecryptError",h.FRAG_PARSING_ERROR="fragParsingError",h.FRAG_GAP="fragGap",h.REMUX_ALLOC_ERROR="remuxAllocError",h.KEY_LOAD_ERROR="keyLoadError",h.KEY_LOAD_TIMEOUT="keyLoadTimeOut",h.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",h.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",h.BUFFER_APPEND_ERROR="bufferAppendError",h.BUFFER_APPENDING_ERROR="bufferAppendingError",h.BUFFER_STALLED_ERROR="bufferStalledError",h.BUFFER_FULL_ERROR="bufferFullError",h.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",h.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",h.ASSET_LIST_LOAD_ERROR="assetListLoadError",h.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",h.ASSET_LIST_PARSING_ERROR="assetListParsingError",h.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",h.INTERNAL_EXCEPTION="internalException",h.INTERNAL_ABORTED="aborted",h.ATTACH_MEDIA_ERROR="attachMediaError",h.UNKNOWN="unknown",h}({}),S=function(h){return h.MEDIA_ATTACHING="hlsMediaAttaching",h.MEDIA_ATTACHED="hlsMediaAttached",h.MEDIA_DETACHING="hlsMediaDetaching",h.MEDIA_DETACHED="hlsMediaDetached",h.MEDIA_ENDED="hlsMediaEnded",h.STALL_RESOLVED="hlsStallResolved",h.BUFFER_RESET="hlsBufferReset",h.BUFFER_CODECS="hlsBufferCodecs",h.BUFFER_CREATED="hlsBufferCreated",h.BUFFER_APPENDING="hlsBufferAppending",h.BUFFER_APPENDED="hlsBufferAppended",h.BUFFER_EOS="hlsBufferEos",h.BUFFERED_TO_END="hlsBufferedToEnd",h.BUFFER_FLUSHING="hlsBufferFlushing",h.BUFFER_FLUSHED="hlsBufferFlushed",h.MANIFEST_LOADING="hlsManifestLoading",h.MANIFEST_LOADED="hlsManifestLoaded",h.MANIFEST_PARSED="hlsManifestParsed",h.LEVEL_SWITCHING="hlsLevelSwitching",h.LEVEL_SWITCHED="hlsLevelSwitched",h.LEVEL_LOADING="hlsLevelLoading",h.LEVEL_LOADED="hlsLevelLoaded",h.LEVEL_UPDATED="hlsLevelUpdated",h.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",h.LEVELS_UPDATED="hlsLevelsUpdated",h.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",h.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",h.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",h.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",h.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",h.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",h.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",h.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",h.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",h.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",h.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",h.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",h.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",h.CUES_PARSED="hlsCuesParsed",h.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",h.INIT_PTS_FOUND="hlsInitPtsFound",h.FRAG_LOADING="hlsFragLoading",h.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",h.FRAG_LOADED="hlsFragLoaded",h.FRAG_DECRYPTED="hlsFragDecrypted",h.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",h.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",h.FRAG_PARSING_METADATA="hlsFragParsingMetadata",h.FRAG_PARSED="hlsFragParsed",h.FRAG_BUFFERED="hlsFragBuffered",h.FRAG_CHANGED="hlsFragChanged",h.FPS_DROP="hlsFpsDrop",h.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",h.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",h.ERROR="hlsError",h.DESTROYING="hlsDestroying",h.KEY_LOADING="hlsKeyLoading",h.KEY_LOADED="hlsKeyLoaded",h.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",h.BACK_BUFFER_REACHED="hlsBackBufferReached",h.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",h.ASSET_LIST_LOADING="hlsAssetListLoading",h.ASSET_LIST_LOADED="hlsAssetListLoaded",h.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",h.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",h.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",h.INTERSTITIAL_STARTED="hlsInterstitialStarted",h.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",h.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",h.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",h.INTERSTITIAL_ENDED="hlsInterstitialEnded",h.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",h.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",h.EVENT_CUE_ENTER="hlsEventCueEnter",h}({});var Te={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},P={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};class d{constructor(t,n=0,s=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=n,this.totalWeight_=s}sample(t,n){const s=Math.pow(this.alpha_,t);this.estimate_=n*(1-s)+s*this.estimate_,this.totalWeight_+=t}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_}}class ne{constructor(t,n,s,o=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=s,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new d(t),this.fast_=new d(n),this.defaultTTFB_=o,this.ttfb_=new d(t)}update(t,n){const{slow_:s,fast_:o,ttfb_:l}=this;s.halfLife!==t&&(this.slow_=new d(t,s.getEstimate(),s.getTotalWeight())),o.halfLife!==n&&(this.fast_=new d(n,o.getEstimate(),o.getTotalWeight())),l.halfLife!==t&&(this.ttfb_=new d(t,l.getEstimate(),l.getTotalWeight()))}sample(t,n){t=Math.max(t,this.minDelayMs_);const s=8*n,o=t/1e3,l=s/o;this.fast_.sample(o,l),this.slow_.sample(o,l)}sampleTTFB(t){const n=t/1e3,s=Math.sqrt(2)*Math.exp(-Math.pow(n,2)/2);this.ttfb_.sample(s,Math.max(t,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function I(h,t,n){return(t=Y(t))in h?Object.defineProperty(h,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):h[t]=n,h}function k(){return k=Object.assign?Object.assign.bind():function(h){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)({}).hasOwnProperty.call(n,s)&&(h[s]=n[s])}return h},k.apply(null,arguments)}function T(h,t){var n=Object.keys(h);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(h);t&&(s=s.filter(function(o){return Object.getOwnPropertyDescriptor(h,o).enumerable})),n.push.apply(n,s)}return n}function M(h){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?T(Object(n),!0).forEach(function(s){I(h,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(h,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach(function(s){Object.defineProperty(h,s,Object.getOwnPropertyDescriptor(n,s))})}return h}function O(h,t){if(typeof h!="object"||!h)return h;var n=h[Symbol.toPrimitive];if(n!==void 0){var s=n.call(h,t);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(h)}function Y(h){var t=O(h,"string");return typeof t=="symbol"?t:t+""}class H{constructor(t,n){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const s=`[${t}]:`;this.trace=j,this.debug=n.debug.bind(null,s),this.log=n.log.bind(null,s),this.warn=n.warn.bind(null,s),this.info=n.info.bind(null,s),this.error=n.error.bind(null,s)}}const j=function(){},U={trace:j,debug:j,log:j,warn:j,info:j,error:j};function $(){return k({},U)}function G(h,t){const n=self.console[h];return n?n.bind(self.console,`${t?"["+t+"] ":""}[${h}] >`):j}function he(h,t,n){return t[h]?t[h].bind(t):G(h,n)}const be=$();function Se(h,t,n){const s=$();if(typeof console=="object"&&h===!0||typeof h=="object"){const o=["debug","log","info","warn","error"];o.forEach(l=>{s[l]=he(l,h,n)});try{s.log(`Debug logs enabled for "${t}" in hls.js version 1.6.12`)}catch(l){return $()}o.forEach(l=>{be[l]=he(l,h)})}else k(be,s);return s}const re=be;function Oe(h=!0){return typeof self=="undefined"?void 0:(h||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function We(h){return typeof self!="undefined"&&h===self.ManagedMediaSource}function Be(h,t){const n=Object.keys(h),s=Object.keys(t),o=n.length,l=s.length;return!o||!l||o===l&&!n.some(c=>s.indexOf(c)===-1)}function Dt(h,t=!1){if(typeof TextDecoder!="undefined"){const m=new TextDecoder("utf-8").decode(h);if(t){const v=m.indexOf("\0");return v!==-1?m.substring(0,v):m}return m.replace(/\0/g,"")}const n=h.length;let s,o,l,c="",f=0;for(;f<n;){if(s=h[f++],s===0&&t)return c;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:c+=String.fromCharCode(s);break;case 12:case 13:o=h[f++],c+=String.fromCharCode((s&31)<<6|o&63);break;case 14:o=h[f++],l=h[f++],c+=String.fromCharCode((s&15)<<12|(o&63)<<6|(l&63)<<0);break}}return c}function te(h){let t="";for(let n=0;n<h.length;n++){let s=h[n].toString(16);s.length<2&&(s="0"+s),t+=s}return t}function z(h){return Uint8Array.from(h.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function X(h){return h&&h.__esModule&&Object.prototype.hasOwnProperty.call(h,"default")?h.default:h}var J={exports:{}},de;function ie(){return de||(de=1,function(h,t){(function(n){var s=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,o=/^(?=([^\/?#]*))\1([^]*)$/,l=/(?:\/|^)\.(?=\/)/g,c=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,f={buildAbsoluteURL:function(_,m,v){if(v=v||{},_=_.trim(),m=m.trim(),!m){if(!v.alwaysNormalize)return _;var y=f.parseURL(_);if(!y)throw new Error("Error trying to parse base URL.");return y.path=f.normalizePath(y.path),f.buildURLFromParts(y)}var x=f.parseURL(m);if(!x)throw new Error("Error trying to parse relative URL.");if(x.scheme)return v.alwaysNormalize?(x.path=f.normalizePath(x.path),f.buildURLFromParts(x)):m;var D=f.parseURL(_);if(!D)throw new Error("Error trying to parse base URL.");if(!D.netLoc&&D.path&&D.path[0]!=="/"){var C=o.exec(D.path);D.netLoc=C[1],D.path=C[2]}D.netLoc&&!D.path&&(D.path="/");var B={scheme:D.scheme,netLoc:x.netLoc,path:null,params:x.params,query:x.query,fragment:x.fragment};if(!x.netLoc&&(B.netLoc=D.netLoc,x.path[0]!=="/"))if(!x.path)B.path=D.path,x.params||(B.params=D.params,x.query||(B.query=D.query));else{var F=D.path,Q=F.substring(0,F.lastIndexOf("/")+1)+x.path;B.path=f.normalizePath(Q)}return B.path===null&&(B.path=v.alwaysNormalize?f.normalizePath(x.path):x.path),f.buildURLFromParts(B)},parseURL:function(_){var m=s.exec(_);return m?{scheme:m[1]||"",netLoc:m[2]||"",path:m[3]||"",params:m[4]||"",query:m[5]||"",fragment:m[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(l,"");_.length!==(_=_.replace(c,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}};h.exports=f})()}(J)),J.exports}var A=ie();class L{constructor(){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}}}var V={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class pe{constructor(t){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof t=="string"&&(t={url:t}),this.base=t,jt(this,"stats")}setByteRange(t,n){const s=t.split("@",2);let o;s.length===1?o=(n==null?void 0:n.byteRangeEndOffset)||0:o=parseInt(s[1]),this._byteRange=[o,parseInt(s[0])+o]}get baseurl(){return this.base.url}get byteRange(){return this._byteRange===null?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return this._streams===null&&(this._streams={[V.AUDIO]:null,[V.VIDEO]:null,[V.AUDIOVIDEO]:null}),this._streams}set elementaryStreams(t){this._streams=t}get hasStats(){return this._stats!==null}get hasStreams(){return this._streams!==null}get stats(){return this._stats===null&&(this._stats=new L),this._stats}set stats(t){this._stats=t}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=A.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[V.AUDIO]=null,t[V.VIDEO]=null,t[V.AUDIOVIDEO]=null}}function ze(h){return h.sn!=="initSegment"}class at extends pe{constructor(t,n){super(n),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=t}get byteLength(){if(this.hasStats){const t=this.stats.total;if(t)return t}if(this.byteRange.length){const t=this.byteRange[0],n=this.byteRange[1];if(ce(t)&&ce(n))return n-t}return null}get bitrate(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null}set bitrate(t){this._bitrate=t}get decryptdata(){const{levelkeys:t}=this;if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const n=this.levelkeys.identity;if(n)this._decryptdata=n.getDecryptData(this.sn);else{const s=Object.keys(this.levelkeys);if(s.length===1){const o=this._decryptdata=this.levelkeys[s[0]]||null;if(o)return o.getDecryptData(this.sn)}}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;const t=ce(this.duration)?this.duration:0;return this.programDateTime+t*1e3}get encrypted(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){var n;const s=Object.keys(this.levelkeys),o=s.length;if(o>1||o===1&&(n=this.levelkeys[s[0]])!=null&&n.encrypted)return!0}return!1}get programDateTime(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(t){if(!ce(t)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=t}get ref(){return ze(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(t){this.setStart(this.start+t)}setStart(t){this.start=t,this._ref&&(this._ref.start=t)}setDuration(t){this.duration=t,this._ref&&(this._ref.duration=t)}setKeyFormat(t){if(this.levelkeys){const n=this.levelkeys[t];n&&!this._decryptdata&&(this._decryptdata=n.getDecryptData(this.sn))}}abortRequests(){var t,n;(t=this.loader)==null||t.abort(),(n=this.keyLoader)==null||n.abort()}setElementaryStreamInfo(t,n,s,o,l,c=!1){const{elementaryStreams:f}=this,_=f[t];if(!_){f[t]={startPTS:n,endPTS:s,startDTS:o,endDTS:l,partial:c};return}_.startPTS=Math.min(_.startPTS,n),_.endPTS=Math.max(_.endPTS,s),_.startDTS=Math.min(_.startDTS,o),_.endDTS=Math.max(_.endDTS,l)}}class Ot extends pe{constructor(t,n,s,o,l){super(s),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=t.decimalFloatingPoint("DURATION"),this.gap=t.bool("GAP"),this.independent=t.bool("INDEPENDENT"),this.relurl=t.enumeratedString("URI"),this.fragment=n,this.index=o;const c=t.enumeratedString("BYTERANGE");c&&this.setByteRange(c,l),l&&(this.fragOffset=l.fragOffset+l.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:t}=this;return!!(t.audio||t.video||t.audiovideo)}}function Ce(h,t){const n=Object.getPrototypeOf(h);if(n){const s=Object.getOwnPropertyDescriptor(n,t);return s||Ce(n,t)}}function jt(h,t){const n=Ce(h,t);n&&(n.enumerable=!0,Object.defineProperty(h,t,n))}const Mt=Math.pow(2,32)-1,dt=[].push,Ti={video:1,audio:2,id3:3,text:4};function fi(h){return String.fromCharCode.apply(null,h)}function Yi(h,t){const n=h[t]<<8|h[t+1];return n<0?65536+n:n}function Kt(h,t){const n=Ne(h,t);return n<0?4294967296+n:n}function ln(h,t){let n=Kt(h,t);return n*=Math.pow(2,32),n+=Kt(h,t+4),n}function Ne(h,t){return h[t]<<24|h[t+1]<<16|h[t+2]<<8|h[t+3]}function Ge(h){const t=h.byteLength;for(let n=0;n<t;){const s=Kt(h,n);if(s>8&&h[n+4]===109&&h[n+5]===111&&h[n+6]===111&&h[n+7]===102)return!0;n=s>1?n+s:t}return!1}function ve(h,t){const n=[];if(!t.length)return n;const s=h.byteLength;for(let o=0;o<s;){const l=Kt(h,o),c=fi(h.subarray(o+4,o+8)),f=l>1?o+l:s;if(c===t[0])if(t.length===1)n.push(h.subarray(o+8,f));else{const _=ve(h.subarray(o+8,f),t.slice(1));_.length&&dt.apply(n,_)}o=f}return n}function nt(h){const t=[],n=h[0];let s=8;const o=Kt(h,s);s+=4;let l=0,c=0;n===0?(l=Kt(h,s),c=Kt(h,s+4),s+=8):(l=ln(h,s),c=ln(h,s+8),s+=16),s+=2;let f=h.length+c;const _=Yi(h,s);s+=2;for(let m=0;m<_;m++){let v=s;const y=Kt(h,v);v+=4;const x=y&2147483647;if((y&2147483648)>>>31===1)return re.warn("SIDX has hierarchical references (not supported)"),null;const C=Kt(h,v);v+=4,t.push({referenceSize:x,subsegmentDuration:C,info:{duration:C/o,start:f,end:f+x-1}}),f+=x,v+=4,s=v}return{earliestPresentationTime:l,timescale:o,version:n,referencesCount:_,references:t}}function _t(h){const t=[],n=ve(h,["moov","trak"]);for(let o=0;o<n.length;o++){const l=n[o],c=ve(l,["tkhd"])[0];if(c){let f=c[0];const _=Kt(c,f===0?12:20),m=ve(l,["mdia","mdhd"])[0];if(m){f=m[0];const v=Kt(m,f===0?12:20),y=ve(l,["mdia","hdlr"])[0];if(y){const x=fi(y.subarray(8,12)),D={soun:V.AUDIO,vide:V.VIDEO}[x],C=ve(l,["mdia","minf","stbl","stsd"])[0],B=lt(C);D?(t[_]={timescale:v,type:D,stsd:B},t[D]=M({timescale:v,id:_},B)):t[_]={timescale:v,type:x,stsd:B}}}}}return ve(h,["moov","mvex","trex"]).forEach(o=>{const l=Kt(o,4),c=t[l];c&&(c.default={duration:Kt(o,12),flags:Kt(o,20)})}),t}function lt(h){const t=h.subarray(8),n=t.subarray(86),s=fi(t.subarray(4,8));let o=s,l;const c=s==="enca"||s==="encv";if(c){const m=ve(t,[s])[0].subarray(s==="enca"?28:78);ve(m,["sinf"]).forEach(y=>{const x=ve(y,["schm"])[0];if(x){const D=fi(x.subarray(4,8));if(D==="cbcs"||D==="cenc"){const C=ve(y,["frma"])[0];C&&(o=fi(C))}}})}const f=o;switch(o){case"avc1":case"avc2":case"avc3":case"avc4":{const _=ve(n,["avcC"])[0];_&&_.length>3&&(o+="."+Ye(_[1])+Ye(_[2])+Ye(_[3]),l=ee(f==="avc1"?"dva1":"dvav",n));break}case"mp4a":{const _=ve(t,[s])[0],m=ve(_.subarray(28),["esds"])[0];if(m&&m.length>7){let v=4;if(m[v++]!==3)break;v=$e(m,v),v+=2;const y=m[v++];if(y&128&&(v+=2),y&64&&(v+=m[v++]),m[v++]!==4)break;v=$e(m,v);const x=m[v++];if(x===64)o+="."+Ye(x);else break;if(v+=12,m[v++]!==5)break;v=$e(m,v);const D=m[v++];let C=(D&248)>>3;C===31&&(C+=1+((D&7)<<3)+((m[v]&224)>>5)),o+="."+C}break}case"hvc1":case"hev1":{const _=ve(n,["hvcC"])[0];if(_&&_.length>12){const m=_[1],v=["","A","B","C"][m>>6],y=m&31,x=Kt(_,2),D=(m&32)>>5?"H":"L",C=_[12],B=_.subarray(6,12);o+="."+v+y,o+="."+xe(x).toString(16).toUpperCase(),o+="."+D+C;let F="";for(let Q=B.length;Q--;){const se=B[Q];(se||F)&&(F="."+se.toString(16).toUpperCase()+F)}o+=F}l=ee(f=="hev1"?"dvhe":"dvh1",n);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{o=ee(o,n)||o;break}case"vp09":{const _=ve(n,["vpcC"])[0];if(_&&_.length>6){const m=_[4],v=_[5],y=_[6]>>4&15;o+="."+rt(m)+"."+rt(v)+"."+rt(y)}break}case"av01":{const _=ve(n,["av1C"])[0];if(_&&_.length>2){const m=_[1]>>>5,v=_[1]&31,y=_[2]>>>7?"H":"M",x=(_[2]&64)>>6,D=(_[2]&32)>>5,C=m===2&&x?D?12:10:x?10:8,B=(_[2]&16)>>4,F=(_[2]&8)>>3,Q=(_[2]&4)>>2,se=_[2]&3;o+="."+m+"."+rt(v)+y+"."+rt(C)+"."+B+"."+F+Q+se+"."+rt(1)+"."+rt(1)+"."+rt(1)+"."+0,l=ee("dav1",n)}break}}return{codec:o,encrypted:c,supplemental:l}}function ee(h,t){const n=ve(t,["dvvC"]),s=n.length?n[0]:ve(t,["dvcC"])[0];if(s){const o=s[2]>>1&127,l=s[2]<<5&32|s[3]>>3&31;return h+"."+rt(o)+"."+rt(l)}}function xe(h){let t=0;for(let n=0;n<32;n++)t|=(h>>n&1)<<31-n;return t>>>0}function $e(h,t){const n=t+5;for(;h[t++]&128&&t<n;);return t}function Ye(h){return("0"+h.toString(16).toUpperCase()).slice(-2)}function rt(h){return(h<10?"0":"")+h}function gt(h,t){if(!h||!t)return;const n=t.keyId;n&&t.isCommonEncryption&&ve(h,["moov","trak"]).forEach(o=>{const c=ve(o,["mdia","minf","stbl","stsd"])[0].subarray(8);let f=ve(c,["enca"]);const _=f.length>0;_||(f=ve(c,["encv"])),f.forEach(m=>{const v=_?m.subarray(28):m.subarray(78);ve(v,["sinf"]).forEach(x=>{const D=Yt(x);if(D){const C=D.subarray(8,24);C.some(B=>B!==0)||(re.log(`[eme] Patching keyId in 'enc${_?"a":"v"}>sinf>>tenc' box: ${te(C)} -> ${te(n)}`),D.set(n,8))}})})})}function Yt(h){const t=ve(h,["schm"])[0];if(t){const n=fi(t.subarray(4,8));if(n==="cbcs"||n==="cenc")return ve(h,["schi","tenc"])[0]}return null}function pt(h,t,n){const s={},o=ve(h,["moof","traf"]);for(let l=0;l<o.length;l++){const c=o[l],f=ve(c,["tfhd"])[0],_=Kt(f,4),m=t[_];if(!m)continue;s[_]||(s[_]={start:NaN,duration:0,sampleCount:0,timescale:m.timescale,type:m.type});const v=s[_],y=ve(c,["tfdt"])[0];if(y){const le=y[0];let Ee=Kt(y,4);le===1&&(Ee===Mt?n.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(Ee*=Mt+1,Ee+=Kt(y,8))),ce(Ee)&&(!ce(v.start)||Ee<v.start)&&(v.start=Ee)}const x=m.default,D=Kt(f,0)|(x==null?void 0:x.flags);let C=(x==null?void 0:x.duration)||0;D&8&&(D&2?C=Kt(f,12):C=Kt(f,8));const B=ve(c,["trun"]);let F=v.start||0,Q=0,se=C;for(let le=0;le<B.length;le++){const Ee=B[le],Ie=Kt(Ee,4),Qe=v.sampleCount;v.sampleCount+=Ie;const Pe=Ee[3]&1,Ze=Ee[3]&4,He=Ee[2]&1,Fe=Ee[2]&2,bt=Ee[2]&4,Xt=Ee[2]&8;let ci=8,yi=Ie;for(Pe&&(ci+=4),Ze&&Ie&&(!(Ee[ci+1]&1)&&v.keyFrameIndex===void 0&&(v.keyFrameIndex=Qe),ci+=4,He?(se=Kt(Ee,ci),ci+=4):se=C,Fe&&(ci+=4),Xt&&(ci+=4),F+=se,Q+=se,yi--);yi--;)He?(se=Kt(Ee,ci),ci+=4):se=C,Fe&&(ci+=4),bt&&(Ee[ci+1]&1||v.keyFrameIndex===void 0&&(v.keyFrameIndex=v.sampleCount-(yi+1),v.keyFrameStart=F),ci+=4),Xt&&(ci+=4),F+=se,Q+=se;!Q&&C&&(Q+=C*Ie)}v.duration+=Q}if(!Object.keys(s).some(l=>s[l].duration)){let l=1/0,c=0;const f=ve(h,["sidx"]);for(let _=0;_<f.length;_++){const m=nt(f[_]);if(m!=null&&m.references){l=Math.min(l,m.earliestPresentationTime/m.timescale);const v=m.references.reduce((y,x)=>y+x.info.duration||0,0);c=Math.max(c,v+m.earliestPresentationTime/m.timescale)}}c&&ce(c)&&Object.keys(s).forEach(_=>{s[_].duration||(s[_].duration=c*s[_].timescale-s[_].start)})}return s}function ke(h){const t={valid:null,remainder:null},n=ve(h,["moof"]);if(n.length<2)return t.remainder=h,t;const s=n[n.length-1];return t.valid=h.slice(0,s.byteOffset-8),t.remainder=h.slice(s.byteOffset-8),t}function ht(h,t){const n=new Uint8Array(h.length+t.length);return n.set(h),n.set(t,h.length),n}function Gt(h,t){const n=[],s=t.samples,o=t.timescale,l=t.id;let c=!1;return ve(s,["moof"]).map(_=>{const m=_.byteOffset-8;ve(_,["traf"]).map(y=>{const x=ve(y,["tfdt"]).map(D=>{const C=D[0];let B=Kt(D,4);return C===1&&(B*=Math.pow(2,32),B+=Kt(D,8)),B/o})[0];return x!==void 0&&(h=x),ve(y,["tfhd"]).map(D=>{const C=Kt(D,4),B=Kt(D,0)&16777215,F=(B&1)!==0,Q=(B&2)!==0,se=(B&8)!==0;let le=0;const Ee=(B&16)!==0;let Ie=0;const Qe=(B&32)!==0;let Pe=8;C===l&&(F&&(Pe+=8),Q&&(Pe+=4),se&&(le=Kt(D,Pe),Pe+=4),Ee&&(Ie=Kt(D,Pe),Pe+=4),Qe&&(Pe+=4),t.type==="video"&&(c=zt(t.codec)),ve(y,["trun"]).map(Ze=>{const He=Ze[0],Fe=Kt(Ze,0)&16777215,bt=(Fe&1)!==0;let Xt=0;const ci=(Fe&4)!==0,yi=(Fe&256)!==0;let li=0;const Vt=(Fe&512)!==0;let bi=0;const si=(Fe&1024)!==0,xi=(Fe&2048)!==0;let Pi=0;const qt=Kt(Ze,4);let Zt=8;bt&&(Xt=Kt(Ze,Zt),Zt+=4),ci&&(Zt+=4);let qi=Xt+m;for(let In=0;In<qt;In++){if(yi?(li=Kt(Ze,Zt),Zt+=4):li=le,Vt?(bi=Kt(Ze,Zt),Zt+=4):bi=Ie,si&&(Zt+=4),xi&&(He===0?Pi=Kt(Ze,Zt):Pi=Ne(Ze,Zt),Zt+=4),t.type===V.VIDEO){let an=0;for(;an<bi;){const Vi=Kt(s,qi);if(qi+=4,Ae(c,s[qi])){const ts=s.subarray(qi,qi+Vi);Me(ts,c?2:1,h+Pi/o,n)}qi+=Vi,an+=Vi+4}}h+=li/o}}))})})}),n}function zt(h){if(!h)return!1;const t=h.substring(0,4);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function Ae(h,t){if(h){const n=t>>1&63;return n===39||n===40}else return(t&31)===6}function Me(h,t,n,s){const o=tt(h);let l=0;l+=t;let c=0,f=0,_=0;for(;l<o.length;){c=0;do{if(l>=o.length)break;_=o[l++],c+=_}while(_===255);f=0;do{if(l>=o.length)break;_=o[l++],f+=_}while(_===255);const m=o.length-l;let v=l;if(f<m)l+=f;else if(f>m){re.error(`Malformed SEI payload. ${f} is too small, only ${m} bytes left to parse.`);break}if(c===4){if(o[v++]===181){const x=Yi(o,v);if(v+=2,x===49){const D=Kt(o,v);if(v+=4,D===1195456820){const C=o[v++];if(C===3){const B=o[v++],F=31&B,Q=64&B,se=Q?2+F*3:0,le=new Uint8Array(se);if(Q){le[0]=B;for(let Ee=1;Ee<se;Ee++)le[Ee]=o[v++]}s.push({type:C,payloadType:c,pts:n,bytes:le})}}}}}else if(c===5&&f>16){const y=[];for(let C=0;C<16;C++){const B=o[v++].toString(16);y.push(B.length==1?"0"+B:B),(C===3||C===5||C===7||C===9)&&y.push("-")}const x=f-16,D=new Uint8Array(x);for(let C=0;C<x;C++)D[C]=o[v++];s.push({payloadType:c,pts:n,uuid:y.join(""),userData:Dt(D),userDataBytes:D})}}}function tt(h){const t=h.byteLength,n=[];let s=1;for(;s<t-2;)h[s]===0&&h[s+1]===0&&h[s+2]===3?(n.push(s+2),s+=2):s++;if(n.length===0)return h;const o=t-n.length,l=new Uint8Array(o);let c=0;for(s=0;s<o;c++,s++)c===n[0]&&(c++,n.shift()),l[s]=h[c];return l}function ft(h){const t=h[0];let n="",s="",o=0,l=0,c=0,f=0,_=0,m=0;if(t===0){for(;fi(h.subarray(m,m+1))!=="\0";)n+=fi(h.subarray(m,m+1)),m+=1;for(n+=fi(h.subarray(m,m+1)),m+=1;fi(h.subarray(m,m+1))!=="\0";)s+=fi(h.subarray(m,m+1)),m+=1;s+=fi(h.subarray(m,m+1)),m+=1,o=Kt(h,12),l=Kt(h,16),f=Kt(h,20),_=Kt(h,24),m=28}else if(t===1){m+=4,o=Kt(h,m),m+=4;const y=Kt(h,m);m+=4;const x=Kt(h,m);for(m+=4,c=va(2,32)*y+x,De(c)||(c=Number.MAX_SAFE_INTEGER,re.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),f=Kt(h,m),m+=4,_=Kt(h,m),m+=4;fi(h.subarray(m,m+1))!=="\0";)n+=fi(h.subarray(m,m+1)),m+=1;for(n+=fi(h.subarray(m,m+1)),m+=1;fi(h.subarray(m,m+1))!=="\0";)s+=fi(h.subarray(m,m+1)),m+=1;s+=fi(h.subarray(m,m+1)),m+=1}const v=h.subarray(m,h.byteLength);return{schemeIdUri:n,value:s,timeScale:o,presentationTime:c,presentationTimeDelta:l,eventDuration:f,id:_,payload:v}}function je(h,...t){const n=t.length;let s=8,o=n;for(;o--;)s+=t[o].byteLength;const l=new Uint8Array(s);for(l[0]=s>>24&255,l[1]=s>>16&255,l[2]=s>>8&255,l[3]=s&255,l.set(h,4),o=0,s=8;o<n;o++)l.set(t[o],s),s+=t[o].byteLength;return l}function At(h,t,n){if(h.byteLength!==16)throw new RangeError("Invalid system id");let s,o;s=0,o=new Uint8Array;let l;s>0?(l=new Uint8Array(4),t.length>0&&new DataView(l.buffer).setUint32(0,t.length,!1)):l=new Uint8Array;const c=new Uint8Array(4);return n.byteLength>0&&new DataView(c.buffer).setUint32(0,n.byteLength,!1),je([112,115,115,104],new Uint8Array([s,0,0,0]),h,l,o,c,n)}function Lt(h){const t=[];if(h instanceof ArrayBuffer){const n=h.byteLength;let s=0;for(;s+32<n;){const o=new DataView(h,s),l=vt(o);t.push(l),s+=l.size}}return t}function vt(h){const t=h.getUint32(0),n=h.byteOffset,s=h.byteLength;if(s<t)return{offset:n,size:s};if(h.getUint32(4)!==1886614376)return{offset:n,size:t};const l=h.getUint32(8)>>>24;if(l!==0&&l!==1)return{offset:n,size:t};const c=h.buffer,f=te(new Uint8Array(c,n+12,16));let _=null,m=null,v=0;if(l===0)v=28;else{const x=h.getUint32(28);if(!x||s<32+x*16)return{offset:n,size:t};_=[];for(let D=0;D<x;D++)_.push(new Uint8Array(c,n+32+D*16,16));v=32+x*16}if(!v)return{offset:n,size:t};const y=h.getUint32(v);return t-32<y?{offset:n,size:t}:(m=new Uint8Array(c,n+v+4,y),{version:l,systemId:f,kids:_,data:m,offset:n,size:t})}const Pt=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),Ht={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Xe(h,t){const n=Ht[t];return!!n&&!!n[h.slice(0,4)]}function Ft(h,t,n=!0){return!h.split(",").some(s=>!Le(s,t,n))}function Le(h,t,n=!0){var s;const o=Oe(n);return(s=o==null?void 0:o.isTypeSupported(ye(h,t)))!=null?s:!1}function ye(h,t){return`${t}/mp4;codecs=${h}`}function we(h){if(h){const t=h.substring(0,4);return Ht.video[t]}return 2}function K(h){const t=Pt();return h.split(",").reduce((n,s)=>{const l=t&&zt(s)?9:Ht.video[s];return l?(l*2+n)/(n?3:2):(Ht.audio[s]+n)/(n?2:1)},0)}const W={};function ae(h,t=!0){if(W[h])return W[h];const n={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[h];for(let o=0;o<n.length;o++){var s;if(Le(n[o],"audio",t))return W[h]=n[o],n[o];if(n[o]==="mp3"&&(s=Oe(t))!=null&&s.isTypeSupported("audio/mpeg"))return""}return h}const fe=/flac|opus|mp4a\.40\.34/i;function _e(h,t=!0){return h.replace(fe,n=>ae(n.toLowerCase(),t))}function st(h,t){const n=[];if(h){const s=h.split(",");for(let o=0;o<s.length;o++)Xe(s[o],"video")||n.push(s[o])}return t&&n.push(t),n.join(",")}function ot(h,t){if(h&&(h.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(h)!==-1)&&(xt(h,"audio")||xt(h,"video")))return h;if(t){const n=t.split(",");if(n.length>1){if(h){for(let s=n.length;s--;)if(n[s].substring(0,4)===h.substring(0,4))return n[s]}return n[0]}}return t||h}function xt(h,t){return Xe(h,t)&&Le(h,t)}function Ut(h){const t=h.split(",");for(let n=0;n<t.length;n++){const s=t[n].split(".");s.length>2&&s[0]==="avc1"&&(t[n]=`avc1.${parseInt(s[1]).toString(16)}${("000"+parseInt(s[2]).toString(16)).slice(-4)}`)}return t.join(",")}function ti(h){if(h.startsWith("av01.")){const t=h.split("."),n=["0","111","01","01","01","0"];for(let s=t.length;s>4&&s<10;s++)t[s]=n[s-4];return t.join(".")}return h}function di(h){const t=Oe(h)||{isTypeSupported:()=>!1};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Qt(h){return h.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const kt={supported:!0,powerEfficient:!0,smooth:!0},oi={supported:!1,smooth:!1,powerEfficient:!1},Di={supported:!0,configurations:[],decodingInfoResults:[kt]};function ki(h,t){return{supported:!1,configurations:t,decodingInfoResults:[oi],error:h}}function Bi(h,t,n,s,o,l){const c=h.videoCodec,f=h.audioCodec?h.audioGroups:null,_=l==null?void 0:l.audioCodec,m=l==null?void 0:l.channels,v=m?parseInt(m):_?1/0:2;let y=null;if(f!=null&&f.length)try{f.length===1&&f[0]?y=t.groups[f[0]].channels:y=f.reduce((x,D)=>{if(D){const C=t.groups[D];if(!C)throw new Error(`Audio track group ${D} not found`);Object.keys(C.channels).forEach(B=>{x[B]=(x[B]||0)+C.channels[B]})}return x},{2:0})}catch(x){return!0}return c!==void 0&&(c.split(",").some(x=>zt(x))||h.width>1920&&h.height>1088||h.height>1920&&h.width>1088||h.frameRate>Math.max(s,30)||h.videoRange!=="SDR"&&h.videoRange!==n||h.bitrate>Math.max(o,8e6))||!!y&&ce(v)&&Object.keys(y).some(x=>parseInt(x)>v)}function pi(h,t,n,s={}){const o=h.videoCodec;if(!o&&!h.audioCodec||!n)return Promise.resolve(Di);const l=[],c=mi(h),f=c.length,_=Xi(h,t,f>0),m=_.length;for(let v=f||1*m||1;v--;){const y={type:"media-source"};if(f&&(y.video=c[v%f]),m){y.audio=_[v%m];const x=y.audio.bitrate;y.video&&x&&(y.video.bitrate-=x)}l.push(y)}if(o){const v=navigator.userAgent;if(o.split(",").some(y=>zt(y))&&Pt())return Promise.resolve(ki(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${v})`),l))}return Promise.all(l.map(v=>{const y=Ji(v);return s[y]||(s[y]=n.decodingInfo(v))})).then(v=>({supported:!v.some(y=>!y.supported),configurations:l,decodingInfoResults:v})).catch(v=>({supported:!1,configurations:l,decodingInfoResults:[],error:v}))}function mi(h){var t;const n=(t=h.videoCodec)==null?void 0:t.split(","),s=un(h),o=h.width||640,l=h.height||480,c=h.frameRate||30,f=h.videoRange.toLowerCase();return n?n.map(_=>{const m={contentType:ye(ti(_),"video"),width:o,height:l,bitrate:s,framerate:c};return f!=="sdr"&&(m.transferFunction=f),m}):[]}function Xi(h,t,n){var s;const o=(s=h.audioCodec)==null?void 0:s.split(","),l=un(h);return o&&h.audioGroups?h.audioGroups.reduce((c,f)=>{var _;const m=f?(_=t.groups[f])==null?void 0:_.tracks:null;return m?m.reduce((v,y)=>{if(y.groupId===f){const x=parseFloat(y.channels||"");o.forEach(D=>{const C={contentType:ye(D,"audio"),bitrate:n?nn(D,l):l};x&&(C.channels=""+x),v.push(C)})}return v},c):c},[]):[]}function nn(h,t){if(t<=1)return 1;let n=128e3;return h==="ec-3"?n=768e3:h==="ac-3"&&(n=64e4),Math.min(t/2,n)}function un(h){return Math.ceil(Math.max(h.bitrate*.9,h.averageBitrate)/1e3)*1e3||1}function Ji(h){let t="";const{audio:n,video:s}=h;if(s){const o=Qt(s.contentType);t+=`${o}_r${s.height}x${s.width}f${Math.ceil(s.framerate)}${s.transferFunction||"sd"}_${Math.ceil(s.bitrate/1e5)}`}if(n){const o=Qt(n.contentType);t+=`${s?"_":""}${o}_c${n.channels}`}return t}const dr=["NONE","TYPE-0","TYPE-1",null];function Mi(h){return dr.indexOf(h)>-1}const Oi=["SDR","PQ","HLG"];function yn(h){return!!h&&Oi.indexOf(h)>-1}var Ri={No:"",Yes:"YES",v2:"v2"};function Dn(h){const{canSkipUntil:t,canSkipDateRanges:n,age:s}=h,o=s<t/2;return t&&o?n?Ri.v2:Ri.Yes:Ri.No}class hn{constructor(t,n,s){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=n,this.skip=s}addDirectives(t){const n=new self.URL(t);return this.msn!==void 0&&n.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&n.searchParams.set("_HLS_part",this.part.toString()),this.skip&&n.searchParams.set("_HLS_skip",this.skip),n.href}}class Yn{constructor(t){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.frameRate=t.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=t.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.codecSet=[t.videoCodec,t.audioCodec].filter(s=>!!s).map(s=>s.substring(0,4)).join(","),"supplemental"in t){var n;this.supplemental=t.supplemental;const s=(n=t.supplemental)==null?void 0:n.videoCodec;s&&s!==t.videoCodec&&(this.codecSet+=`,${s.substring(0,4)}`)}this.addGroupId("audio",t.attrs.AUDIO),this.addGroupId("text",t.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(t){return fn(this._audioGroups,t)}hasSubtitleGroup(t){return fn(this._subtitleGroups,t)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(t,n){if(n){if(t==="audio"){let s=this._audioGroups;s||(s=this._audioGroups=[]),s.indexOf(n)===-1&&s.push(n)}else if(t==="text"){let s=this._subtitleGroups;s||(s=this._subtitleGroups=[]),s.indexOf(n)===-1&&s.push(n)}}}get urlId(){return 0}set urlId(t){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var t;return(t=this.audioGroups)==null?void 0:t[0]}get textGroupId(){var t;return(t=this.subtitleGroups)==null?void 0:t[0]}addFallback(){}}function fn(h,t){return!t||!h?!1:h.indexOf(t)!==-1}function gr(){if(typeof matchMedia=="function"){const h=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(h.media!==t.media)return h.matches===!0}return!1}function Yr(h,t){let n=!1,s=[];if(h&&(n=h!=="SDR",s=[h]),t){s=t.allowedVideoRanges||Oi.slice(0);const o=s.join("")!=="SDR"&&!t.videoCodec;n=t.preferHDR!==void 0?t.preferHDR:o&&gr(),n||(s=["SDR"])}return{preferHDR:n,allowedVideoRanges:s}}const Ei=h=>{const t=new WeakSet;return(n,s)=>{if(h&&(s=h(n,s)),typeof s=="object"&&s!==null){if(t.has(s))return;t.add(s)}return s}},$t=(h,t)=>JSON.stringify(h,Ei(t));function Re(h,t,n,s,o){const l=Object.keys(h),c=s==null?void 0:s.channels,f=s==null?void 0:s.audioCodec,_=o==null?void 0:o.videoCodec,m=c&&parseInt(c)===2;let v=!1,y=!1,x=1/0,D=1/0,C=1/0,B=1/0,F=0,Q=[];const{preferHDR:se,allowedVideoRanges:le}=Yr(t,o);for(let Ze=l.length;Ze--;){const He=h[l[Ze]];v||(v=He.channels[2]>0),x=Math.min(x,He.minHeight),D=Math.min(D,He.minFramerate),C=Math.min(C,He.minBitrate),le.filter(bt=>He.videoRanges[bt]>0).length>0&&(y=!0)}x=ce(x)?x:0,D=ce(D)?D:0;const Ee=Math.max(1080,x),Ie=Math.max(30,D);C=ce(C)?C:n,n=Math.max(C,n),y||(t=void 0);const Qe=l.length>1;return{codecSet:l.reduce((Ze,He)=>{const Fe=h[He];if(He===Ze)return Ze;if(Q=y?le.filter(bt=>Fe.videoRanges[bt]>0):[],Qe){if(Fe.minBitrate>n)return Je(He,`min bitrate of ${Fe.minBitrate} > current estimate of ${n}`),Ze;if(!Fe.hasDefaultAudio)return Je(He,"no renditions with default or auto-select sound found"),Ze;if(f&&He.indexOf(f.substring(0,4))%5!==0)return Je(He,`audio codec preference "${f}" not found`),Ze;if(c&&!m){if(!Fe.channels[c])return Je(He,`no renditions with ${c} channel sound found (channels options: ${Object.keys(Fe.channels)})`),Ze}else if((!f||m)&&v&&Fe.channels[2]===0)return Je(He,"no renditions with stereo sound found"),Ze;if(Fe.minHeight>Ee)return Je(He,`min resolution of ${Fe.minHeight} > maximum of ${Ee}`),Ze;if(Fe.minFramerate>Ie)return Je(He,`min framerate of ${Fe.minFramerate} > maximum of ${Ie}`),Ze;if(!Q.some(bt=>Fe.videoRanges[bt]>0))return Je(He,`no variants with VIDEO-RANGE of ${$t(Q)} found`),Ze;if(_&&He.indexOf(_.substring(0,4))%5!==0)return Je(He,`video codec preference "${_}" not found`),Ze;if(Fe.maxScore<F)return Je(He,`max score of ${Fe.maxScore} < selected max of ${F}`),Ze}return Ze&&(K(He)>=K(Ze)||Fe.fragmentError>h[Ze].fragmentError)?Ze:(B=Fe.minIndex,F=Fe.maxScore,He)},void 0),videoRanges:Q,preferHDR:se,minFramerate:D,minBitrate:C,minIndex:B}}function Je(h,t){re.log(`[abr] start candidates with "${h}" ignored because ${t}`)}function ut(h){return h.reduce((t,n)=>{let s=t.groups[n.groupId];s||(s=t.groups[n.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),s.tracks.push(n);const o=n.channels||"2";return s.channels[o]=(s.channels[o]||0)+1,s.hasDefault=s.hasDefault||n.default,s.hasAutoSelect=s.hasAutoSelect||n.autoselect,s.hasDefault&&(t.hasDefaultAudio=!0),s.hasAutoSelect&&(t.hasAutoSelectAudio=!0),t},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function it(h,t,n,s){return h.slice(n,s+1).reduce((o,l,c)=>{if(!l.codecSet)return o;const f=l.audioGroups;let _=o[l.codecSet];_||(o[l.codecSet]=_={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:c,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!f,fragmentError:0}),_.minBitrate=Math.min(_.minBitrate,l.bitrate);const m=Math.min(l.height,l.width);return _.minHeight=Math.min(_.minHeight,m),_.minFramerate=Math.min(_.minFramerate,l.frameRate),_.minIndex=Math.min(_.minIndex,c),_.maxScore=Math.max(_.maxScore,l.score),_.fragmentError+=l.fragmentError,_.videoRanges[l.videoRange]=(_.videoRanges[l.videoRange]||0)+1,f&&f.forEach(v=>{if(!v)return;const y=t.groups[v];y&&(_.hasDefaultAudio=_.hasDefaultAudio||t.hasDefaultAudio?y.hasDefault:y.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(y.channels).forEach(x=>{_.channels[x]=(_.channels[x]||0)+y.channels[x]}))}),o},{})}function wt(h){if(!h)return h;const{lang:t,assocLang:n,characteristics:s,channels:o,audioCodec:l}=h;return{lang:t,assocLang:n,characteristics:s,channels:o,audioCodec:l}}function St(h,t,n){if("attrs"in h){const s=t.indexOf(h);if(s!==-1)return s}for(let s=0;s<t.length;s++){const o=t[s];if(Bt(h,o,n))return s}return-1}function Bt(h,t,n){const{groupId:s,name:o,lang:l,assocLang:c,default:f}=h,_=h.forced;return(s===void 0||t.groupId===s)&&(o===void 0||t.name===o)&&(l===void 0||ni(l,t.lang))&&(l===void 0||t.assocLang===c)&&(f===void 0||t.default===f)&&(_===void 0||t.forced===_)&&(!("characteristics"in h)||Gi(h.characteristics||"",t.characteristics))&&(n===void 0||n(h,t))}function ni(h,t="--"){return h.length===t.length?h===t:h.startsWith(t)||t.startsWith(h)}function Gi(h,t=""){const n=h.split(","),s=t.split(",");return n.length===s.length&&!n.some(o=>s.indexOf(o)===-1)}function gi(h,t){const{audioCodec:n,channels:s}=h;return(n===void 0||(t.audioCodec||"").substring(0,4)===n.substring(0,4))&&(s===void 0||s===(t.channels||"2"))}function dn(h,t,n,s,o){const l=t[s],f=t.reduce((x,D,C)=>{const B=D.uri;return(x[B]||(x[B]=[])).push(C),x},{})[l.uri];f.length>1&&(s=Math.max.apply(Math,f));const _=l.videoRange,m=l.frameRate,v=l.codecSet.substring(0,4),y=_i(t,s,x=>{if(x.videoRange!==_||x.frameRate!==m||x.codecSet.substring(0,4)!==v)return!1;const D=x.audioGroups,C=n.filter(B=>!D||D.indexOf(B.groupId)!==-1);return St(h,C,o)>-1});return y>-1?y:_i(t,s,x=>{const D=x.audioGroups,C=n.filter(B=>!D||D.indexOf(B.groupId)!==-1);return St(h,C,o)>-1})}function _i(h,t,n){for(let s=t;s>-1;s--)if(n(h[s]))return s;for(let s=t+1;s<h.length;s++)if(n(h[s]))return s;return-1}function Ai(h,t){var n;return!!h&&h!==((n=t.loadLevelObj)==null?void 0:n.uri)}class Ci extends H{constructor(t){super("abr",t.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=n=>{var s;const{fragCurrent:o,partCurrent:l,hls:c}=this,{autoLevelEnabled:f,media:_}=c;if(!o||!_)return;const m=performance.now(),v=l?l.stats:o.stats,y=l?l.duration:o.duration,x=m-v.loading.start,D=c.minAutoLevel,C=o.level,B=this._nextAutoLevel;if(v.aborted||v.loaded&&v.loaded===v.total||C<=D){this.clearTimer(),this._nextAutoLevel=-1;return}if(!f)return;const F=B>-1&&B!==C,Q=!!n||F;if(!Q&&(_.paused||!_.playbackRate||!_.readyState))return;const se=c.mainForwardBufferInfo;if(!Q&&se===null)return;const le=this.bwEstimator.getEstimateTTFB(),Ee=Math.abs(_.playbackRate);if(x<=Math.max(le,1e3*(y/(Ee*2))))return;const Ie=se?se.len/Ee:0,Qe=v.loading.first?v.loading.first-v.loading.start:-1,Pe=v.loaded&&Qe>-1,Ze=this.getBwEstimate(),He=c.levels,Fe=He[C],bt=Math.max(v.loaded,Math.round(y*(o.bitrate||Fe.averageBitrate)/8));let Xt=Pe?x-Qe:x;Xt<1&&Pe&&(Xt=Math.min(x,v.loaded*8/Ze));const ci=Pe?v.loaded*1e3/Xt:0,yi=le/1e3,li=ci?(bt-v.loaded)/ci:bt*8/Ze+yi;if(li<=Ie)return;const Vt=ci?ci*8:Ze,bi=((s=(n==null?void 0:n.details)||this.hls.latestLevelDetails)==null?void 0:s.live)===!0,si=this.hls.config.abrBandWidthUpFactor;let xi=Number.POSITIVE_INFINITY,Pi;for(Pi=C-1;Pi>D;Pi--){const In=He[Pi].maxBitrate,an=!He[Pi].details||bi;if(xi=this.getTimeToLoadFrag(yi,Vt,y*In,an),xi<Math.min(Ie,y+yi))break}if(xi>=li||xi>y*10)return;Pe?this.bwEstimator.sample(x-Math.min(le,Qe),v.loaded):this.bwEstimator.sampleTTFB(x);const qt=He[Pi].maxBitrate;this.getBwEstimate()*si>qt&&this.resetEstimator(qt);const Zt=this.findBestLevel(qt,D,Pi,0,Ie,1,1);Zt>-1&&(Pi=Zt),this.warn(`Fragment ${o.sn}${l?" part "+l.index:""} of level ${C} is loading too slowly;
Fragment duration: ${o.duration.toFixed(3)}
Time to underbuffer: ${Ie.toFixed(3)} s
Estimated load time for current fragment: ${li.toFixed(3)} s
Estimated load time for down switch fragment: ${xi.toFixed(3)} s
TTFB estimate: ${Qe|0} ms
Current BW estimate: ${ce(Ze)?Ze|0:"Unknown"} bps
New BW estimate: ${this.getBwEstimate()|0} bps
Switching to level ${Pi} @ ${qt|0} bps`),c.nextLoadLevel=c.nextAutoLevel=Pi,this.clearTimer();const qi=()=>{if(this.clearTimer(),this.fragCurrent===o&&this.hls.loadLevel===Pi&&Pi>0){const In=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${Pi>0?"and switching down":""}
Fragment duration: ${o.duration.toFixed(3)} s
Time to underbuffer: ${In.toFixed(3)} s`),o.abortRequests(),this.fragCurrent=this.partCurrent=null,Pi>D){let an=this.findBestLevel(this.hls.levels[D].bitrate,D,Pi,0,In,1,1);an===-1&&(an=D),this.hls.nextLoadLevel=this.hls.nextAutoLevel=an,this.resetEstimator(this.hls.levels[an].bitrate)}}};F||li>xi*2?qi():this.timer=self.setInterval(qi,xi*1e3),c.trigger(S.FRAG_LOAD_EMERGENCY_ABORTED,{frag:o,part:l,stats:v})},this.hls=t,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(t){t&&(this.log(`setting initial bwe to ${t}`),this.hls.config.abrEwmaDefaultEstimate=t),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const t=this.hls.config;return new ne(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate)}registerListeners(){const{hls:t}=this;t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.FRAG_LOADING,this.onFragLoading,this),t.on(S.FRAG_LOADED,this.onFragLoaded,this),t.on(S.FRAG_BUFFERED,this.onFragBuffered,this),t.on(S.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(S.LEVEL_LOADED,this.onLevelLoaded,this),t.on(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(S.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.on(S.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t&&(t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.FRAG_LOADING,this.onFragLoading,this),t.off(S.FRAG_LOADED,this.onFragLoaded,this),t.off(S.FRAG_BUFFERED,this.onFragBuffered,this),t.off(S.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(S.LEVEL_LOADED,this.onLevelLoaded,this),t.off(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(S.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.off(S.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(t,n){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(t,n){const s=n.frag;if(!this.ignoreFragment(s)){if(!s.bitrateTest){var o;this.fragCurrent=s,this.partCurrent=(o=n.part)!=null?o:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(t,n){this.clearTimer()}onError(t,n){if(!n.fatal)switch(n.details){case q.BUFFER_ADD_CODEC_ERROR:case q.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case q.FRAG_LOAD_TIMEOUT:{const s=n.frag,{fragCurrent:o,partCurrent:l}=this;if(s&&o&&s.sn===o.sn&&s.level===o.level){const c=performance.now(),f=l?l.stats:s.stats,_=c-f.loading.start,m=f.loading.first?f.loading.first-f.loading.start:-1;if(f.loaded&&m>-1){const y=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(_-Math.min(y,m),f.loaded)}else this.bwEstimator.sampleTTFB(_)}break}}}getTimeToLoadFrag(t,n,s,o){const l=t+s/n,c=o?t+this.lastLevelLoadSec:0;return l+c}onLevelLoaded(t,n){const s=this.hls.config,{loading:o}=n.stats,l=o.end-o.first;ce(l)&&(this.lastLevelLoadSec=l/1e3),n.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(n.levelInfo)}onFragLoaded(t,{frag:n,part:s}){const o=s?s.stats:n.stats;if(n.type===P.MAIN&&this.bwEstimator.sampleTTFB(o.loading.first-o.loading.start),!this.ignoreFragment(n)){if(this.clearTimer(),n.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const l=s?s.duration:n.duration,c=this.hls.levels[n.level],f=(c.loaded?c.loaded.bytes:0)+o.loaded,_=(c.loaded?c.loaded.duration:0)+l;c.loaded={bytes:f,duration:_},c.realBitrate=Math.round(8*f/_)}if(n.bitrateTest){const l={stats:o,frag:n,part:s,id:n.type};this.onFragBuffered(S.FRAG_BUFFERED,l),n.bitrateTest=!1}else this.lastLoadedFragLevel=n.level}}onFragBuffered(t,n){const{frag:s,part:o}=n,l=o!=null&&o.stats.loaded?o.stats:s.stats;if(l.aborted||this.ignoreFragment(s))return;const c=l.parsing.end-l.loading.start-Math.min(l.loading.first-l.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(c,l.loaded),l.bwEstimate=this.getBwEstimate(),s.bitrateTest?this.bitrateTestDelay=c/1e3:this.bitrateTestDelay=0}ignoreFragment(t){return t.type!==P.MAIN||t.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:t,minAutoLevel:n}=this.hls,s=this.getBwEstimate(),o=this.hls.config.maxStarvationDelay,l=this.findBestLevel(s,n,t,0,o,1,1);if(l>-1)return l;const c=this.hls.firstLevel,f=Math.min(Math.max(c,n),t);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${c} clamped to ${f}`),f}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const t=this.forcedAutoLevel,s=this.bwEstimator.canEstimate(),o=this.lastLoadedFragLevel>-1;if(t!==-1&&(!s||!o||this.nextAutoLevelKey===this.getAutoLevelKey()))return t;const l=s&&o?this.getNextABRAutoLevel():this.firstAutoLevel;if(t!==-1){const c=this.hls.levels;if(c.length>Math.max(t,l)&&c[t].loadError<=c[l].loadError)return t}return this._nextAutoLevel=l,this.nextAutoLevelKey=this.getAutoLevelKey(),l}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:n,hls:s}=this;if(s.levels.length<=1)return s.loadLevel;const{maxAutoLevel:o,config:l,minAutoLevel:c}=s,f=n?n.duration:t?t.duration:0,_=this.getBwEstimate(),m=this.getStarvationDelay();let v=l.abrBandWidthFactor,y=l.abrBandWidthUpFactor;if(m){const F=this.findBestLevel(_,c,o,m,0,v,y);if(F>=0)return this.rebufferNotice=-1,F}let x=f?Math.min(f,l.maxStarvationDelay):l.maxStarvationDelay;if(!m){const F=this.bitrateTestDelay;F&&(x=(f?Math.min(f,l.maxLoadingDelay):l.maxLoadingDelay)-F,this.info(`bitrate test took ${Math.round(1e3*F)}ms, set first fragment max fetchDuration to ${Math.round(1e3*x)} ms`),v=y=1)}const D=this.findBestLevel(_,c,o,m,x,v,y);if(this.rebufferNotice!==D&&(this.rebufferNotice=D,this.info(`${m?"rebuffering expected":"buffer is empty"}, optimal quality level ${D}`)),D>-1)return D;const C=s.levels[c],B=s.loadLevelObj;return B&&(C==null?void 0:C.bitrate)<B.bitrate?c:s.loadLevel}getStarvationDelay(){const t=this.hls,n=t.media;if(!n)return 1/0;const s=n&&n.playbackRate!==0?Math.abs(n.playbackRate):1,o=t.mainForwardBufferInfo;return(o?o.len:0)/s}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(t,n,s,o,l,c,f){var _;const m=o+l,v=this.lastLoadedFragLevel,y=v===-1?this.hls.firstLevel:v,{fragCurrent:x,partCurrent:D}=this,{levels:C,allAudioTracks:B,loadLevel:F,config:Q}=this.hls;if(C.length===1)return 0;const se=C[y],le=!!((_=this.hls.latestLevelDetails)!=null&&_.live),Ee=F===-1||v===-1;let Ie,Qe="SDR",Pe=(se==null?void 0:se.frameRate)||0;const{audioPreference:Ze,videoPreference:He}=Q,Fe=this.audioTracksByGroup||(this.audioTracksByGroup=ut(B));let bt=-1;if(Ee){if(this.firstSelection!==-1)return this.firstSelection;const Vt=this.codecTiers||(this.codecTiers=it(C,Fe,n,s)),bi=Re(Vt,Qe,t,Ze,He),{codecSet:si,videoRanges:xi,minFramerate:Pi,minBitrate:qt,minIndex:Zt,preferHDR:qi}=bi;bt=Zt,Ie=si,Qe=qi?xi[xi.length-1]:xi[0],Pe=Pi,t=Math.max(t,qt),this.log(`picked start tier ${$t(bi)}`)}else Ie=se==null?void 0:se.codecSet,Qe=se==null?void 0:se.videoRange;const Xt=D?D.duration:x?x.duration:0,ci=this.bwEstimator.getEstimateTTFB()/1e3,yi=[];for(let Vt=s;Vt>=n;Vt--){var li;const bi=C[Vt],si=Vt>y;if(!bi)continue;if(Q.useMediaCapabilities&&!bi.supportedResult&&!bi.supportedPromise){const an=navigator.mediaCapabilities;typeof(an==null?void 0:an.decodingInfo)=="function"&&Bi(bi,Fe,Qe,Pe,t,Ze)?(bi.supportedPromise=pi(bi,Fe,an,this.supportedCache),bi.supportedPromise.then(Vi=>{if(!this.hls)return;bi.supportedResult=Vi;const ts=this.hls.levels,Dr=ts.indexOf(bi);Vi.error?this.warn(`MediaCapabilities decodingInfo error: "${Vi.error}" for level ${Dr} ${$t(Vi)}`):Vi.supported?Vi.decodingInfoResults.some(Is=>Is.smooth===!1||Is.powerEfficient===!1)&&this.log(`MediaCapabilities decodingInfo for level ${Dr} not smooth or powerEfficient: ${$t(Vi)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${Dr} ${$t(Vi)}`),Dr>-1&&ts.length>1&&(this.log(`Removing unsupported level ${Dr}`),this.hls.removeLevel(Dr),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)))}).catch(Vi=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${Vi}`)})):bi.supportedResult=Di}if((Ie&&bi.codecSet!==Ie||Qe&&bi.videoRange!==Qe||si&&Pe>bi.frameRate||!si&&Pe>0&&Pe<bi.frameRate||(li=bi.supportedResult)!=null&&(li=li.decodingInfoResults)!=null&&li.some(an=>an.smooth===!1))&&(!Ee||Vt!==bt)){yi.push(Vt);continue}const xi=bi.details,Pi=(D?xi==null?void 0:xi.partTarget:xi==null?void 0:xi.averagetargetduration)||Xt;let qt;si?qt=f*t:qt=c*t;const Zt=Xt&&o>=Xt*2&&l===0?bi.averageBitrate:bi.maxBitrate,qi=this.getTimeToLoadFrag(ci,qt,Zt*Pi,xi===void 0);if(qt>=Zt&&(Vt===v||bi.loadError===0&&bi.fragmentError===0)&&(qi<=ci||!ce(qi)||le&&!this.bitrateTestDelay||qi<m)){const an=this.forcedAutoLevel;return Vt!==F&&(an===-1||an!==F)&&(yi.length&&this.trace(`Skipped level(s) ${yi.join(",")} of ${s} max with CODECS and VIDEO-RANGE:"${C[yi[0]].codecs}" ${C[yi[0]].videoRange}; not compatible with "${Ie}" ${Qe}`),this.info(`switch candidate:${y}->${Vt} adjustedbw(${Math.round(qt)})-bitrate=${Math.round(qt-Zt)} ttfb:${ci.toFixed(1)} avgDuration:${Pi.toFixed(1)} maxFetchDuration:${m.toFixed(1)} fetchDuration:${qi.toFixed(1)} firstSelection:${Ee} codecSet:${bi.codecSet} videoRange:${bi.videoRange} hls.loadLevel:${F}`)),Ee&&(this.firstSelection=Vt),Vt}}return-1}set nextAutoLevel(t){const n=this.deriveNextAutoLevel(t);this._nextAutoLevel!==n&&(this.nextAutoLevelKey="",this._nextAutoLevel=n)}deriveNextAutoLevel(t){const{maxAutoLevel:n,minAutoLevel:s}=this.hls;return Math.min(Math.max(t,s),n)}}const Ni={search:function(h,t){let n=0,s=h.length-1,o=null,l=null;for(;n<=s;){o=(n+s)/2|0,l=h[o];const c=t(l);if(c>0)n=o+1;else if(c<0)s=o-1;else return l}return null}};function $i(h,t,n){if(t===null||!Array.isArray(h)||!h.length||!ce(t))return null;const s=h[0].programDateTime;if(t<(s||0))return null;const o=h[h.length-1].endProgramDateTime;if(t>=(o||0))return null;for(let l=0;l<h.length;++l){const c=h[l];if(Fi(t,n,c))return c}return null}function ui(h,t,n=0,s=0,o=.005){let l=null;if(h){l=t[1+h.sn-t[0].sn]||null;const f=h.endDTS-n;f>0&&f<15e-7&&(n+=15e-7),l&&h.level!==l.level&&l.end<=h.end&&(l=t[2+h.sn-t[0].sn]||null)}else n===0&&t[0].start===0&&(l=t[0]);if(l&&((!h||h.level===l.level)&&Qi(n,s,l)===0||Ii(l,h,Math.min(o,s))))return l;const c=Ni.search(t,Qi.bind(null,n,s));return c&&(c!==h||!l)?c:l}function Ii(h,t,n){if(t&&t.start===0&&t.level<h.level&&(t.endPTS||0)>0){const s=t.tagList.reduce((o,l)=>(l[0]==="INF"&&(o+=parseFloat(l[1])),o),n);return h.start<=s}return!1}function Qi(h=0,t=0,n){if(n.start<=h&&n.start+n.duration>h)return 0;const s=Math.min(t,n.duration+(n.deltaPTS?n.deltaPTS:0));return n.start+n.duration-s<=h?1:n.start-s>h&&n.start?-1:0}function Fi(h,t,n){const s=Math.min(t,n.duration+(n.deltaPTS?n.deltaPTS:0))*1e3;return(n.endProgramDateTime||0)-s>h}function wi(h,t,n){if(h&&h.startCC<=t&&h.endCC>=t){let s=h.fragments;const{fragmentHint:o}=h;o&&(s=s.concat(o));let l;return Ni.search(s,c=>c.cc<t?1:c.cc>t?-1:(l=c,c.end<=n?1:c.start>n?-1:0)),l||null}return null}function ji(h){switch(h.details){case q.FRAG_LOAD_TIMEOUT:case q.KEY_LOAD_TIMEOUT:case q.LEVEL_LOAD_TIMEOUT:case q.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Ki(h){return h.details.startsWith("key")}function en(h){return Ki(h)&&!!h.frag&&!h.frag.decryptdata}function Pn(h,t){const n=ji(t);return h.default[`${n?"timeout":"error"}Retry`]}function tn(h,t){const n=h.backoff==="linear"?1:Math.pow(2,t);return Math.min(n*h.retryDelayMs,h.maxRetryDelayMs)}function er(h){return M(M({},h),{errorRetry:null,timeoutRetry:null})}function cn(h,t,n,s){if(!h)return!1;const o=s==null?void 0:s.code,l=t<h.maxNumRetry&&(Cn(o)||!!n);return h.shouldRetry?h.shouldRetry(h,t,n,s,l):l}function Cn(h){return tr(h)||!!h&&(h<400||h>499)}function tr(h){return h===0&&navigator.onLine===!1}var Ui={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},zi={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,MoveAllAlternatesMatchingKey:4,SwitchToSDR:8};class Ln extends H{constructor(t){super("error-controller",t.logger),this.hls=void 0,this.playlistError=0,this.hls=t,this.registerListeners()}registerListeners(){const t=this.hls;t.on(S.ERROR,this.onError,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(S.ERROR,this.onError,this),t.off(S.ERROR,this.onErrorOut,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(t){}stopLoad(){this.playlistError=0}getVariantLevelIndex(t){return(t==null?void 0:t.type)===P.MAIN?t.level:this.getVariantIndex()}getVariantIndex(){var t;const n=this.hls,s=n.currentLevel;return(t=n.loadLevelObj)!=null&&t.details||s===-1?n.loadLevel:s}variantHasKey(t,n){if(t){var s;if((s=t.details)!=null&&s.hasKey(n))return!0;const o=t.audioGroups;if(o)return this.hls.allAudioTracks.filter(c=>o.indexOf(c.groupId)>=0).some(c=>{var f;return(f=c.details)==null?void 0:f.hasKey(n)})}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(t,n){var s;if(n.fatal)return;const o=this.hls,l=n.context;switch(n.details){case q.FRAG_LOAD_ERROR:case q.FRAG_LOAD_TIMEOUT:case q.KEY_LOAD_ERROR:case q.KEY_LOAD_TIMEOUT:n.errorAction=this.getFragRetryOrSwitchAction(n);return;case q.FRAG_PARSING_ERROR:if((s=n.frag)!=null&&s.gap){n.errorAction=bn();return}case q.FRAG_GAP:case q.FRAG_DECRYPT_ERROR:{n.errorAction=this.getFragRetryOrSwitchAction(n),n.errorAction.action=Ui.SendAlternateToPenaltyBox;return}case q.LEVEL_EMPTY_ERROR:case q.LEVEL_PARSING_ERROR:{var c;const _=n.parent===P.MAIN?n.level:o.loadLevel;n.details===q.LEVEL_EMPTY_ERROR&&((c=n.context)!=null&&(c=c.levelDetails)!=null&&c.live)?n.errorAction=this.getPlaylistRetryOrSwitchAction(n,_):(n.levelRetry=!1,n.errorAction=this.getLevelSwitchAction(n,_))}return;case q.LEVEL_LOAD_ERROR:case q.LEVEL_LOAD_TIMEOUT:typeof(l==null?void 0:l.level)=="number"&&(n.errorAction=this.getPlaylistRetryOrSwitchAction(n,l.level));return;case q.AUDIO_TRACK_LOAD_ERROR:case q.AUDIO_TRACK_LOAD_TIMEOUT:case q.SUBTITLE_LOAD_ERROR:case q.SUBTITLE_TRACK_LOAD_TIMEOUT:if(l){const _=o.loadLevelObj;if(_&&(l.type===Te.AUDIO_TRACK&&_.hasAudioGroup(l.groupId)||l.type===Te.SUBTITLE_TRACK&&_.hasSubtitleGroup(l.groupId))){n.errorAction=this.getPlaylistRetryOrSwitchAction(n,o.loadLevel),n.errorAction.action=Ui.SendAlternateToPenaltyBox,n.errorAction.flags=zi.MoveAllAlternatesMatchingHost;return}}return;case q.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:n.errorAction={action:Ui.SendAlternateToPenaltyBox,flags:zi.MoveAllAlternatesMatchingHDCP};return;case q.KEY_SYSTEM_SESSION_UPDATE_FAILED:case q.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case q.KEY_SYSTEM_NO_SESSION:n.errorAction={action:Ui.SendAlternateToPenaltyBox,flags:zi.MoveAllAlternatesMatchingKey};return;case q.BUFFER_ADD_CODEC_ERROR:case q.REMUX_ALLOC_ERROR:case q.BUFFER_APPEND_ERROR:if(!n.errorAction){var f;n.errorAction=this.getLevelSwitchAction(n,(f=n.level)!=null?f:o.loadLevel)}return;case q.INTERNAL_EXCEPTION:case q.BUFFER_APPENDING_ERROR:case q.BUFFER_FULL_ERROR:case q.LEVEL_SWITCH_ERROR:case q.BUFFER_STALLED_ERROR:case q.BUFFER_SEEK_OVER_HOLE:case q.BUFFER_NUDGE_ON_STALL:n.errorAction=bn();return}n.type===ge.KEY_SYSTEM_ERROR&&(n.levelRetry=!1,n.errorAction=bn())}getPlaylistRetryOrSwitchAction(t,n){const s=this.hls,o=Pn(s.config.playlistLoadPolicy,t),l=this.playlistError++;if(cn(o,l,ji(t),t.response))return{action:Ui.RetryRequest,flags:zi.None,retryConfig:o,retryCount:l};const f=this.getLevelSwitchAction(t,n);return o&&(f.retryConfig=o,f.retryCount=l),f}getFragRetryOrSwitchAction(t){const n=this.hls,s=this.getVariantLevelIndex(t.frag),o=n.levels[s],{fragLoadPolicy:l,keyLoadPolicy:c}=n.config,f=Pn(Ki(t)?c:l,t),_=n.levels.reduce((v,y)=>v+y.fragmentError,0);if(o&&(t.details!==q.FRAG_GAP&&o.fragmentError++,!en(t)&&cn(f,_,ji(t),t.response)))return{action:Ui.RetryRequest,flags:zi.None,retryConfig:f,retryCount:_};const m=this.getLevelSwitchAction(t,s);return f&&(m.retryConfig=f,m.retryCount=_),m}getLevelSwitchAction(t,n){const s=this.hls;n==null&&(n=s.loadLevel);const o=this.hls.levels[n];if(o){var l,c;const m=t.details;o.loadError++,m===q.BUFFER_APPEND_ERROR&&o.fragmentError++;let v=-1;const{levels:y,loadLevel:x,minAutoLevel:D,maxAutoLevel:C}=s;!s.autoLevelEnabled&&!s.config.preserveManualLevelOnError&&(s.loadLevel=-1);const B=(l=t.frag)==null?void 0:l.type,Q=(B===P.AUDIO&&m===q.FRAG_PARSING_ERROR||t.sourceBufferName==="audio"&&(m===q.BUFFER_ADD_CODEC_ERROR||m===q.BUFFER_APPEND_ERROR))&&y.some(({audioCodec:Qe})=>o.audioCodec!==Qe),le=t.sourceBufferName==="video"&&(m===q.BUFFER_ADD_CODEC_ERROR||m===q.BUFFER_APPEND_ERROR)&&y.some(({codecSet:Qe,audioCodec:Pe})=>o.codecSet!==Qe&&o.audioCodec===Pe),{type:Ee,groupId:Ie}=(c=t.context)!=null?c:{};for(let Qe=y.length;Qe--;){const Pe=(Qe+x)%y.length;if(Pe!==x&&Pe>=D&&Pe<=C&&y[Pe].loadError===0){var f,_;const Ze=y[Pe];if(m===q.FRAG_GAP&&B===P.MAIN&&t.frag){const He=y[Pe].details;if(He){const Fe=ui(t.frag,He.fragments,t.frag.start);if(Fe!=null&&Fe.gap)continue}}else{if(Ee===Te.AUDIO_TRACK&&Ze.hasAudioGroup(Ie)||Ee===Te.SUBTITLE_TRACK&&Ze.hasSubtitleGroup(Ie))continue;if(B===P.AUDIO&&(f=o.audioGroups)!=null&&f.some(He=>Ze.hasAudioGroup(He))||B===P.SUBTITLE&&(_=o.subtitleGroups)!=null&&_.some(He=>Ze.hasSubtitleGroup(He))||Q&&o.audioCodec===Ze.audioCodec||le&&o.codecSet===Ze.codecSet||!Q&&o.codecSet!==Ze.codecSet)continue}v=Pe;break}}if(v>-1&&s.loadLevel!==v)return t.levelRetry=!0,this.playlistError=0,{action:Ui.SendAlternateToPenaltyBox,flags:zi.None,nextAutoLevel:v}}return{action:Ui.SendAlternateToPenaltyBox,flags:zi.MoveAllAlternatesMatchingHost}}onErrorOut(t,n){var s;switch((s=n.errorAction)==null?void 0:s.action){case Ui.DoNothing:break;case Ui.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(n),!n.errorAction.resolved&&n.details!==q.FRAG_GAP?n.fatal=!0:/MediaSource readyState: ended/.test(n.error.message)&&(this.warn(`MediaSource ended after "${n.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break;case Ui.RetryRequest:break}if(n.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(t){const n=this.hls,s=t.errorAction;if(!s)return;const{flags:o}=s,l=s.nextAutoLevel;switch(o){case zi.None:this.switchLevel(t,l);break;case zi.MoveAllAlternatesMatchingHDCP:{const _=this.getVariantLevelIndex(t.frag),m=n.levels[_],v=m==null?void 0:m.attrs["HDCP-LEVEL"];if(s.hdcpLevel=v,v==="NONE")this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(v){n.maxHdcpLevel=dr[dr.indexOf(v)-1],s.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${n.maxHdcpLevel}" or lower`);break}}case zi.MoveAllAlternatesMatchingKey:{const _=t.decryptdata;if(_){const m=this.hls.levels,v=m.length;for(let x=v;x--;)if(this.variantHasKey(m[x],_)){var c,f;this.log(`Banned key found in level ${x} (${m[x].bitrate}bps) or audio group "${(c=m[x].audioGroups)==null?void 0:c.join(",")}" (${(f=t.frag)==null?void 0:f.type} fragment) ${te(_.keyId||[])}`),m[x].fragmentError++,m[x].loadError++,this.log(`Removing level ${x} with key error (${t.error})`),this.hls.removeLevel(x)}const y=t.frag;if(this.hls.levels.length<v)s.resolved=!0;else if(y&&y.type!==P.MAIN){const x=y.decryptdata;x&&!_.matches(x)&&(s.resolved=!0)}}break}}s.resolved||this.switchLevel(t,l)}switchLevel(t,n){if(n!==void 0&&t.errorAction&&(this.warn(`switching to level ${n} after ${t.details}`),this.hls.nextAutoLevel=n,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,t.details===q.BUFFER_ADD_CODEC_ERROR&&t.mimeType&&t.sourceBufferName!=="audiovideo")){const s=Qt(t.mimeType),o=this.hls.levels;for(let l=o.length;l--;)o[l][`${t.sourceBufferName}Codec`]===s&&(this.log(`Removing level ${l} for ${t.details} ("${s}" not supported)`),this.hls.removeLevel(l))}}}function bn(h){const t={action:Ui.DoNothing,flags:zi.None};return h&&(t.resolved=!0),t}var rn={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class xn{constructor(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}_registerListeners(){const{hls:t}=this;t&&(t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.BUFFER_APPENDED,this.onBufferAppended,this),t.on(S.FRAG_BUFFERED,this.onFragBuffered,this),t.on(S.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:t}=this;t&&(t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.BUFFER_APPENDED,this.onBufferAppended,this),t.off(S.FRAG_BUFFERED,this.onFragBuffered,this),t.off(S.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,n){const s=this.activePartLists[n];if(s)for(let o=s.length;o--;){const l=s[o];if(!l)break;if(l.start<=t&&t<=l.end&&l.loaded)return l}return this.getBufferedFrag(t,n)}getBufferedFrag(t,n){return this.getFragAtPos(t,n,!0)}getFragAtPos(t,n,s){const{fragments:o}=this,l=Object.keys(o);for(let c=l.length;c--;){const f=o[l[c]];if((f==null?void 0:f.body.type)===n&&(!s||f.buffered)){const _=f.body;if(_.start<=t&&t<=_.end)return _}}return null}detectEvictedFragments(t,n,s,o,l){this.timeRanges&&(this.timeRanges[t]=n);const c=(o==null?void 0:o.fragment.sn)||-1;Object.keys(this.fragments).forEach(f=>{const _=this.fragments[f];if(!_||c>=_.body.sn)return;if(!_.buffered&&(!_.loaded||l)){_.body.type===s&&this.removeFragment(_.body);return}const m=_.range[t];if(m){if(m.time.length===0){this.removeFragment(_.body);return}m.time.some(v=>{const y=!this.isTimeBuffered(v.startPTS,v.endPTS,n);return y&&this.removeFragment(_.body),y})}})}detectPartialFragments(t){const n=this.timeRanges;if(!n||t.frag.sn==="initSegment")return;const s=t.frag,o=Vn(s),l=this.fragments[o];if(!l||l.buffered&&s.gap)return;const c=!s.relurl;Object.keys(n).forEach(f=>{const _=s.elementaryStreams[f];if(!_)return;const m=n[f],v=c||_.partial===!0;l.range[f]=this.getBufferedTimes(s,t.part,v,m)}),l.loaded=null,Object.keys(l.range).length?(l.buffered=!0,(l.body.endList=s.endList||l.body.endList)&&(this.endListFragments[l.body.type]=l),pn(l)||this.removeParts(s.sn-1,s.type)):this.removeFragment(l.body)}removeParts(t,n){const s=this.activePartLists[n];s&&(this.activePartLists[n]=Mr(s,o=>o.fragment.sn>=t))}fragBuffered(t,n){const s=Vn(t);let o=this.fragments[s];!o&&n&&(o=this.fragments[s]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),o&&(o.loaded=null,o.buffered=!0)}getBufferedTimes(t,n,s,o){const l={time:[],partial:s},c=t.start,f=t.end,_=t.minEndPTS||f,m=t.maxStartPTS||c;for(let v=0;v<o.length;v++){const y=o.start(v)-this.bufferPadding,x=o.end(v)+this.bufferPadding;if(m>=y&&_<=x){l.time.push({startPTS:Math.max(c,o.start(v)),endPTS:Math.min(f,o.end(v))});break}else if(c<x&&f>y){const D=Math.max(c,o.start(v)),C=Math.min(f,o.end(v));C>D&&(l.partial=!0,l.time.push({startPTS:D,endPTS:C}))}else if(f<=y)break}return l}getPartialFragment(t){let n=null,s,o,l,c=0;const{bufferPadding:f,fragments:_}=this;return Object.keys(_).forEach(m=>{const v=_[m];v&&pn(v)&&(o=v.body.start-f,l=v.body.end+f,t>=o&&t<=l&&(s=Math.min(t-o,l-t),c<=s&&(n=v.body,c=s)))}),n}isEndListAppended(t){const n=this.endListFragments[t];return n!==void 0&&(n.buffered||pn(n))}getState(t){const n=Vn(t),s=this.fragments[n];return s?s.buffered?pn(s)?rn.PARTIAL:rn.OK:rn.APPENDING:rn.NOT_LOADED}isTimeBuffered(t,n,s){let o,l;for(let c=0;c<s.length;c++){if(o=s.start(c)-this.bufferPadding,l=s.end(c)+this.bufferPadding,t>=o&&n<=l)return!0;if(n<=o)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(t,n){if(n.frag.sn==="initSegment"||n.frag.bitrateTest)return;const s=n.frag,o=n.part?null:n,l=Vn(s);this.fragments[l]={body:s,appendedPTS:null,loaded:o,buffered:!1,range:Object.create(null)}}onBufferAppended(t,n){const{frag:s,part:o,timeRanges:l,type:c}=n;if(s.sn==="initSegment")return;const f=s.type;if(o){let m=this.activePartLists[f];m||(this.activePartLists[f]=m=[]),m.push(o)}this.timeRanges=l;const _=l[c];this.detectEvictedFragments(c,_,f,o)}onFragBuffered(t,n){this.detectPartialFragments(n)}hasFragment(t){const n=Vn(t);return!!this.fragments[n]}hasFragments(t){const{fragments:n}=this,s=Object.keys(n);if(!t)return s.length>0;for(let o=s.length;o--;){const l=n[s[o]];if((l==null?void 0:l.body.type)===t)return!0}return!1}hasParts(t){var n;return!!((n=this.activePartLists[t])!=null&&n.length)}removeFragmentsInRange(t,n,s,o,l){o&&!this.hasGaps||Object.keys(this.fragments).forEach(c=>{const f=this.fragments[c];if(!f)return;const _=f.body;_.type!==s||o&&!_.gap||_.start<n&&_.end>t&&(f.buffered||l)&&this.removeFragment(_)})}removeFragment(t){const n=Vn(t);t.clearElementaryStreamInfo();const s=this.activePartLists[t.type];if(s){const o=t.sn;this.activePartLists[t.type]=Mr(s,l=>l.fragment.sn!==o)}delete this.fragments[n],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){var t;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const n=(t=this.hls)==null||(t=t.latestLevelDetails)==null?void 0:t.partList;n&&n.forEach(s=>s.clearElementaryStreamInfo())}}function pn(h){var t,n,s;return h.buffered&&!!(h.body.gap||(t=h.range.video)!=null&&t.partial||(n=h.range.audio)!=null&&n.partial||(s=h.range.audiovideo)!=null&&s.partial)}function Vn(h){return`${h.type}_${h.level}_${h.sn}`}function Mr(h,t){return h.filter(n=>{const s=t(n);return s||n.clearElementaryStreamInfo(),s})}var On={cbc:0,ctr:1};class Br{constructor(t,n,s){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=t,this.aesIV=n,this.aesMode=s}decrypt(t,n){switch(this.aesMode){case On.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},n,t);case On.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},n,t);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}function En(h){const t=h.byteLength,n=t&&new DataView(h.buffer).getUint8(t-1);return n?h.slice(0,t-n):h}class sr{constructor(){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()}uint8ArrayToUint32Array_(t){const n=new DataView(t),s=new Uint32Array(4);for(let o=0;o<4;o++)s[o]=n.getUint32(o*4);return s}initTable(){const t=this.sBox,n=this.invSBox,s=this.subMix,o=s[0],l=s[1],c=s[2],f=s[3],_=this.invSubMix,m=_[0],v=_[1],y=_[2],x=_[3],D=new Uint32Array(256);let C=0,B=0,F=0;for(F=0;F<256;F++)F<128?D[F]=F<<1:D[F]=F<<1^283;for(F=0;F<256;F++){let Q=B^B<<1^B<<2^B<<3^B<<4;Q=Q>>>8^Q&255^99,t[C]=Q,n[Q]=C;const se=D[C],le=D[se],Ee=D[le];let Ie=D[Q]*257^Q*16843008;o[C]=Ie<<24|Ie>>>8,l[C]=Ie<<16|Ie>>>16,c[C]=Ie<<8|Ie>>>24,f[C]=Ie,Ie=Ee*16843009^le*65537^se*257^C*16843008,m[Q]=Ie<<24|Ie>>>8,v[Q]=Ie<<16|Ie>>>16,y[Q]=Ie<<8|Ie>>>24,x[Q]=Ie,C?(C=se^D[D[D[Ee^se]]],B^=D[D[B]]):C=B=1}}expandKey(t){const n=this.uint8ArrayToUint32Array_(t);let s=!0,o=0;for(;o<n.length&&s;)s=n[o]===this.key[o],o++;if(s)return;this.key=n;const l=this.keySize=n.length;if(l!==4&&l!==6&&l!==8)throw new Error("Invalid aes key size="+l);const c=this.ksRows=(l+6+1)*4;let f,_;const m=this.keySchedule=new Uint32Array(c),v=this.invKeySchedule=new Uint32Array(c),y=this.sBox,x=this.rcon,D=this.invSubMix,C=D[0],B=D[1],F=D[2],Q=D[3];let se,le;for(f=0;f<c;f++){if(f<l){se=m[f]=n[f];continue}le=se,f%l===0?(le=le<<8|le>>>24,le=y[le>>>24]<<24|y[le>>>16&255]<<16|y[le>>>8&255]<<8|y[le&255],le^=x[f/l|0]<<24):l>6&&f%l===4&&(le=y[le>>>24]<<24|y[le>>>16&255]<<16|y[le>>>8&255]<<8|y[le&255]),m[f]=se=(m[f-l]^le)>>>0}for(_=0;_<c;_++)f=c-_,_&3?le=m[f]:le=m[f-4],_<4||f<=4?v[_]=le:v[_]=C[y[le>>>24]]^B[y[le>>>16&255]]^F[y[le>>>8&255]]^Q[y[le&255]],v[_]=v[_]>>>0}networkToHostOrderSwap(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24}decrypt(t,n,s){const o=this.keySize+6,l=this.invKeySchedule,c=this.invSBox,f=this.invSubMix,_=f[0],m=f[1],v=f[2],y=f[3],x=this.uint8ArrayToUint32Array_(s);let D=x[0],C=x[1],B=x[2],F=x[3];const Q=new Int32Array(t),se=new Int32Array(Q.length);let le,Ee,Ie,Qe,Pe,Ze,He,Fe,bt,Xt,ci,yi,li,Vt;const bi=this.networkToHostOrderSwap;for(;n<Q.length;){for(bt=bi(Q[n]),Xt=bi(Q[n+1]),ci=bi(Q[n+2]),yi=bi(Q[n+3]),Pe=bt^l[0],Ze=yi^l[1],He=ci^l[2],Fe=Xt^l[3],li=4,Vt=1;Vt<o;Vt++)le=_[Pe>>>24]^m[Ze>>16&255]^v[He>>8&255]^y[Fe&255]^l[li],Ee=_[Ze>>>24]^m[He>>16&255]^v[Fe>>8&255]^y[Pe&255]^l[li+1],Ie=_[He>>>24]^m[Fe>>16&255]^v[Pe>>8&255]^y[Ze&255]^l[li+2],Qe=_[Fe>>>24]^m[Pe>>16&255]^v[Ze>>8&255]^y[He&255]^l[li+3],Pe=le,Ze=Ee,He=Ie,Fe=Qe,li=li+4;le=c[Pe>>>24]<<24^c[Ze>>16&255]<<16^c[He>>8&255]<<8^c[Fe&255]^l[li],Ee=c[Ze>>>24]<<24^c[He>>16&255]<<16^c[Fe>>8&255]<<8^c[Pe&255]^l[li+1],Ie=c[He>>>24]<<24^c[Fe>>16&255]<<16^c[Pe>>8&255]<<8^c[Ze&255]^l[li+2],Qe=c[Fe>>>24]<<24^c[Pe>>16&255]<<16^c[Ze>>8&255]<<8^c[He&255]^l[li+3],se[n]=bi(le^D),se[n+1]=bi(Qe^C),se[n+2]=bi(Ie^B),se[n+3]=bi(Ee^F),D=bt,C=Xt,B=ci,F=yi,n=n+4}return se.buffer}}class Rr{constructor(t,n,s){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=t,this.key=n,this.aesMode=s}expandKey(){const t=Tr(this.aesMode);return this.subtle.importKey("raw",this.key,{name:t},!1,["encrypt","decrypt"])}}function Tr(h){switch(h){case On.cbc:return"AES-CBC";case On.ctr:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${h}`)}}const xr=16;class Mn{constructor(t,{removePKCS7Padding:n=!0}={}){if(this.logEnabled=!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.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=t.enableSoftwareAES,this.removePKCS7Padding=n,n)try{const s=self.crypto;s&&(this.subtle=s.subtle||s.webkitSubtle)}catch(s){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:t,remainderData:n}=this;if(!t||n)return this.reset(),null;const s=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?En(s):s}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(t,n,s,o){return this.useSoftware?new Promise((l,c)=>{const f=ArrayBuffer.isView(t)?t:new Uint8Array(t);this.softwareDecrypt(f,n,s,o);const _=this.flush();_?l(_.buffer):c(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),n,s,o)}softwareDecrypt(t,n,s,o){const{currentIV:l,currentResult:c,remainderData:f}=this;if(o!==On.cbc||n.byteLength!==16)return re.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),f&&(t=ht(f,t),this.remainderData=null);const _=this.getValidChunk(t);if(!_.length)return null;l&&(s=l);let m=this.softwareDecrypter;m||(m=this.softwareDecrypter=new sr),m.expandKey(n);const v=c;return this.currentResult=m.decrypt(_.buffer,0,s),this.currentIV=_.slice(-16).buffer,v||null}webCryptoDecrypt(t,n,s,o){if(this.key!==n||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(t,n,s,o));this.key=n,this.fastAesKey=new Rr(this.subtle,n,o)}return this.fastAesKey.expandKey().then(l=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new Br(this.subtle,new Uint8Array(s),o).decrypt(t.buffer,l)):Promise.reject(new Error("web crypto not initialized"))).catch(l=>(re.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${l.name}: ${l.message}`),this.onWebCryptoError(t,n,s,o)))}onWebCryptoError(t,n,s,o){const l=this.enableSoftwareAES;if(l){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,n,s,o);const c=this.flush();if(c)return c.buffer}throw new Error("WebCrypto"+(l?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(t){let n=t;const s=t.length-t.length%xr;return s!==t.length&&(n=t.slice(0,s),this.remainderData=t.slice(s)),n}logOnce(t){this.logEnabled&&(re.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const cr=Math.pow(2,17);class wr{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(t,n){const s=t.url;if(!s)return Promise.reject(new Gn({type:ge.NETWORK_ERROR,details:q.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error(`Fragment does not have a ${s?"part list":"url"}`),networkDetails:null}));this.abort();const o=this.config,l=o.fLoader,c=o.loader;return new Promise((f,_)=>{if(this.loader&&this.loader.destroy(),t.gap)if(t.tagList.some(C=>C[0]==="GAP")){_(kn(t));return}else t.gap=!1;const m=this.loader=l?new l(o):new c(o),v=Nr(t);t.loader=m;const y=er(o.fragLoadPolicy.default),x={loadPolicy:y,timeout:y.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:cr};t.stats=m.stats;const D={onSuccess:(C,B,F,Q)=>{this.resetLoader(t,m);let se=C.data;F.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(se.slice(0,16)),se=se.slice(16)),f({frag:t,part:null,payload:se,networkDetails:Q})},onError:(C,B,F,Q)=>{this.resetLoader(t,m),_(new Gn({type:ge.NETWORK_ERROR,details:q.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:M({url:s,data:void 0},C),error:new Error(`HTTP Error ${C.code} ${C.text}`),networkDetails:F,stats:Q}))},onAbort:(C,B,F)=>{this.resetLoader(t,m),_(new Gn({type:ge.NETWORK_ERROR,details:q.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:F,stats:C}))},onTimeout:(C,B,F)=>{this.resetLoader(t,m),_(new Gn({type:ge.NETWORK_ERROR,details:q.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${x.timeout}ms`),networkDetails:F,stats:C}))}};n&&(D.onProgress=(C,B,F,Q)=>n({frag:t,part:null,payload:F,networkDetails:Q})),m.load(v,x,D)})}loadPart(t,n,s){this.abort();const o=this.config,l=o.fLoader,c=o.loader;return new Promise((f,_)=>{if(this.loader&&this.loader.destroy(),t.gap||n.gap){_(kn(t,n));return}const m=this.loader=l?new l(o):new c(o),v=Nr(t,n);t.loader=m;const y=er(o.fragLoadPolicy.default),x={loadPolicy:y,timeout:y.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:cr};n.stats=m.stats,m.load(v,x,{onSuccess:(D,C,B,F)=>{this.resetLoader(t,m),this.updateStatsFromPart(t,n);const Q={frag:t,part:n,payload:D.data,networkDetails:F};s(Q),f(Q)},onError:(D,C,B,F)=>{this.resetLoader(t,m),_(new Gn({type:ge.NETWORK_ERROR,details:q.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:n,response:M({url:v.url,data:void 0},D),error:new Error(`HTTP Error ${D.code} ${D.text}`),networkDetails:B,stats:F}))},onAbort:(D,C,B)=>{t.stats.aborted=n.stats.aborted,this.resetLoader(t,m),_(new Gn({type:ge.NETWORK_ERROR,details:q.INTERNAL_ABORTED,fatal:!1,frag:t,part:n,error:new Error("Aborted"),networkDetails:B,stats:D}))},onTimeout:(D,C,B)=>{this.resetLoader(t,m),_(new Gn({type:ge.NETWORK_ERROR,details:q.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:n,error:new Error(`Timeout after ${x.timeout}ms`),networkDetails:B,stats:D}))}})})}updateStatsFromPart(t,n){const s=t.stats,o=n.stats,l=o.total;if(s.loaded+=o.loaded,l){const _=Math.round(t.duration/n.duration),m=Math.min(Math.round(s.loaded/l),_),y=(_-m)*Math.round(s.loaded/m);s.total=s.loaded+y}else s.total=Math.max(s.loaded,s.total);const c=s.loading,f=o.loading;c.start?c.first+=f.first-f.start:(c.start=f.start,c.first=f.first),c.end=f.end}resetLoader(t,n){t.loader=null,this.loader===n&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),n.destroy()}}function Nr(h,t=null){const n=t||h,s={frag:h,part:t,responseType:"arraybuffer",url:n.url,headers:{},rangeStart:0,rangeEnd:0},o=n.byteRangeStartOffset,l=n.byteRangeEndOffset;if(ce(o)&&ce(l)){var c;let f=o,_=l;if(h.sn==="initSegment"&&pr((c=h.decryptdata)==null?void 0:c.method)){const m=l-o;m%16&&(_=l+(16-m%16)),o!==0&&(s.resetIV=!0,f=o-16)}s.rangeStart=f,s.rangeEnd=_}return s}function kn(h,t){const n=new Error(`GAP ${h.gap?"tag":"attribute"} found`),s={type:ge.MEDIA_ERROR,details:q.FRAG_GAP,fatal:!1,frag:h,error:n,networkDetails:null};return t&&(s.part=t),(t||h).stats.aborted=!0,new Gn(s)}function pr(h){return h==="AES-128"||h==="AES-256"}class Gn extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class hr extends H{constructor(t,n){super(t,n),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(t){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class Wr{constructor(t,n,s,o=0,l=-1,c=!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=Hi(),this.buffering={audio:Hi(),video:Hi(),audiovideo:Hi()},this.level=t,this.sn=n,this.id=s,this.size=o,this.part=l,this.partial=c}}function Hi(){return{start:0,executeStart:0,executeEnd:0,end:0}}const vi={length:0,start:()=>0,end:()=>0};class Wt{static isBuffered(t,n){if(t){const s=Wt.getBuffered(t);for(let o=s.length;o--;)if(n>=s.start(o)&&n<=s.end(o))return!0}return!1}static bufferedRanges(t){if(t){const n=Wt.getBuffered(t);return Wt.timeRangesToArray(n)}return[]}static timeRangesToArray(t){const n=[];for(let s=0;s<t.length;s++)n.push({start:t.start(s),end:t.end(s)});return n}static bufferInfo(t,n,s){if(t){const o=Wt.bufferedRanges(t);if(o.length)return Wt.bufferedInfo(o,n,s)}return{len:0,start:n,end:n,bufferedIndex:-1}}static bufferedInfo(t,n,s){n=Math.max(0,n),t.length>1&&t.sort((v,y)=>v.start-y.start||y.end-v.end);let o=-1,l=[];if(s)for(let v=0;v<t.length;v++){n>=t[v].start&&n<=t[v].end&&(o=v);const y=l.length;if(y){const x=l[y-1].end;t[v].start-x<s?t[v].end>x&&(l[y-1].end=t[v].end):l.push(t[v])}else l.push(t[v])}else l=t;let c=0,f,_=n,m=n;for(let v=0;v<l.length;v++){const y=l[v].start,x=l[v].end;if(o===-1&&n>=y&&n<=x&&(o=v),n+s>=y&&n<x)_=y,m=x,c=m-n;else if(n+s<y){f=y;break}}return{len:c,start:_||0,end:m||0,nextStart:f,buffered:t,bufferedIndex:o}}static getBuffered(t){try{return t.buffered||vi}catch(n){return re.log("failed to get media.buffered",n),vi}}}const _n=/\{\$([a-zA-Z0-9-_]+)\}/g;function mr(h){return _n.test(h)}function Nn(h,t){if(h.variableList!==null||h.hasVariableRefs){const n=h.variableList;return t.replace(_n,s=>{const o=s.substring(2,s.length-1),l=n==null?void 0:n[o];return l===void 0?(h.playlistParsingError||(h.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${o}"`)),s):l})}return t}function ar(h,t,n){let s=h.variableList;s||(h.variableList=s={});let o,l;if("QUERYPARAM"in t){o=t.QUERYPARAM;try{const c=new self.URL(n).searchParams;if(c.has(o))l=c.get(o);else throw new Error(`"${o}" does not match any query parameter in URI: "${n}"`)}catch(c){h.playlistParsingError||(h.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${c.message}`))}}else o=t.NAME,l=t.VALUE;o in s?h.playlistParsingError||(h.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${o}"`)):s[o]=l||""}function $n(h,t,n){const s=t.IMPORT;if(n&&s in n){let o=h.variableList;o||(h.variableList=o={}),o[s]=n[s]}else h.playlistParsingError||(h.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${s}"`))}const cs=/^(\d+)x(\d+)$/,Sr=/(.+?)=(".*?"|.*?)(?:,|$)/g;class vn{constructor(t,n){typeof t=="string"&&(t=vn.parseAttrList(t,n)),k(this,t)}get clientAttrs(){return Object.keys(this).filter(t=>t.substring(0,2)==="X-")}decimalInteger(t){const n=parseInt(this[t],10);return n>Number.MAX_SAFE_INTEGER?1/0:n}hexadecimalInteger(t){if(this[t]){let n=(this[t]||"0x").slice(2);n=(n.length&1?"0":"")+n;const s=new Uint8Array(n.length/2);for(let o=0;o<n.length/2;o++)s[o]=parseInt(n.slice(o*2,o*2+2),16);return s}return null}hexadecimalIntegerAsNumber(t){const n=parseInt(this[t],16);return n>Number.MAX_SAFE_INTEGER?1/0:n}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,n){const s=this[t];return s?parseFloat(s):n}enumeratedString(t){return this[t]}enumeratedStringList(t,n){const s=this[t];return(s?s.split(/[ ,]+/):[]).reduce((o,l)=>(o[l.toLowerCase()]=!0,o),n)}bool(t){return this[t]==="YES"}decimalResolution(t){const n=cs.exec(this[t]);if(n!==null)return{width:parseInt(n[1],10),height:parseInt(n[2],10)}}static parseAttrList(t,n){let s;const o={},l='"';for(Sr.lastIndex=0;(s=Sr.exec(t))!==null;){const c=s[1].trim();let f=s[2];const _=f.indexOf(l)===0&&f.lastIndexOf(l)===f.length-1;let m=!1;if(_)f=f.slice(1,-1);else switch(c){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":m=!0}if(n&&(_||m))f=Nn(n,f);else if(!m&&!_)switch(c){case"CLOSED-CAPTIONS":if(f==="NONE")break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":re.warn(`${t}: attribute ${c} is missing quotes`)}o[c]=f}return o}}const hs="com.apple.hls.interstitial";function ns(h){return h!=="ID"&&h!=="CLASS"&&h!=="CUE"&&h!=="START-DATE"&&h!=="DURATION"&&h!=="END-DATE"&&h!=="END-ON-NEXT"}function or(h){return h==="SCTE35-OUT"||h==="SCTE35-IN"||h==="SCTE35-CMD"}class jr{constructor(t,n,s=0){var o;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(n==null?void 0:n.tagAnchor)||null,this.tagOrder=(o=n==null?void 0:n.tagOrder)!=null?o:s,n){const l=n.attr;for(const c in l)if(Object.prototype.hasOwnProperty.call(t,c)&&t[c]!==l[c]){re.warn(`DATERANGE tag attribute: "${c}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=c;break}t=k(new vn({}),l,t)}if(this.attr=t,n?(this._startDate=n._startDate,this._cue=n._cue,this._endDate=n._endDate,this._dateAtEnd=n._dateAtEnd):this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const l=(n==null?void 0:n.endDate)||new Date(this.attr["END-DATE"]);ce(l.getTime())&&(this._endDate=l)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const t=this._cue;return t===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):t}get startTime(){const{tagAnchor:t}=this;return t===null||t.programDateTime===null?(re.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${t}`),NaN):t.start+(this.startDate.getTime()-t.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const t=this._endDate||this._dateAtEnd;if(t)return t;const n=this.duration;return n!==null?this._dateAtEnd=new Date(this._startDate.getTime()+n*1e3):null}get duration(){if("DURATION"in this.attr){const t=this.attr.decimalFloatingPoint("DURATION");if(ce(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return this.class===hs}get isValid(){return!!this.id&&!this._badValueForSameId&&ce(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}const ys=10;class _r{constructor(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,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.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}reloaded(t){if(!t){this.advanced=!0,this.updated=!0;return}const n=this.lastPartSn-t.lastPartSn,s=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!s||!!n||!this.live,this.advanced=this.endSN>t.endSN||n>0||n===0&&s>0,this.updated||this.advanced?this.misses=Math.floor(t.misses*.6):this.misses=t.misses+1}hasKey(t){return this.encryptedFragments.some(n=>{let s=n.decryptdata;return s||(n.setKeyFormat(t.keyFormat),s=n.decryptdata),!!s&&t.matches(s)})}get hasProgramDateTime(){return this.fragments.length?ce(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||ys}get drift(){const t=this.driftEndTime-this.driftStartTime;return t>0?(this.driftEnd-this.driftStart)*1e3/t:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){const t=this.partList;if(t){const n=this.lastPartIndex;if(n!==-1){for(let s=t.length;s--;)if(t[s].index>n)return t[s].index;return n}}return 0}get lastPartSn(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const t=this.partEnd-this.fragmentStart;return this.age>Math.max(t,this.totalduration)+this.levelTargetDuration}return!1}}function Kn(h,t){return h.length===t.length?!h.some((n,s)=>n!==t[s]):!1}function fr(h,t){return!h&&!t?!0:!h||!t?!1:Kn(h,t)}function Xn(h){return h==="AES-128"||h==="AES-256"||h==="AES-256-CTR"}function rs(h){switch(h){case"AES-128":case"AES-256":return On.cbc;case"AES-256-CTR":return On.ctr;default:throw new Error(`invalid full segment method ${h}`)}}function ss(h){return Uint8Array.from(atob(h),t=>t.charCodeAt(0))}function Ps(h){return Uint8Array.from(unescape(encodeURIComponent(h)),t=>t.charCodeAt(0))}function ya(h){const t=Ps(h).subarray(0,16),n=new Uint8Array(16);return n.set(t,16-t.length),n}function Os(h){const t=function(s,o,l){const c=s[o];s[o]=s[l],s[l]=c};t(h,0,3),t(h,1,2),t(h,4,5),t(h,6,7)}function ba(h){const t=h.split(":");let n=null;if(t[0]==="data"&&t.length===2){const s=t[1].split(";"),o=s[s.length-1].split(",");if(o.length===2){const l=o[0]==="base64",c=o[1];l?(s.splice(-1,1),n=ss(c)):n=ya(c)}}return n}const ri=typeof self!="undefined"?self:void 0;var Jt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Wi={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Hn(h){switch(h){case Wi.FAIRPLAY:return Jt.FAIRPLAY;case Wi.PLAYREADY:return Jt.PLAYREADY;case Wi.WIDEVINE:return Jt.WIDEVINE;case Wi.CLEARKEY:return Jt.CLEARKEY}}function mn(h){switch(h){case Jt.FAIRPLAY:return Wi.FAIRPLAY;case Jt.PLAYREADY:return Wi.PLAYREADY;case Jt.WIDEVINE:return Wi.WIDEVINE;case Jt.CLEARKEY:return Wi.CLEARKEY}}function $r(h){const{drmSystems:t,widevineLicenseUrl:n}=h,s=t?[Jt.FAIRPLAY,Jt.WIDEVINE,Jt.PLAYREADY,Jt.CLEARKEY].filter(o=>!!t[o]):[];return!s[Jt.WIDEVINE]&&n&&s.push(Jt.WIDEVINE),s}const ir=function(h){return ri!=null&&(h=ri.navigator)!=null&&h.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function Ts(h,t,n,s){let o;switch(h){case Jt.FAIRPLAY:o=["cenc","sinf"];break;case Jt.WIDEVINE:case Jt.PLAYREADY:o=["cenc"];break;case Jt.CLEARKEY:o=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${h}`)}return fs(o,t,n,s)}function fs(h,t,n,s){return[{initDataTypes:h,persistentState:s.persistentState||"optional",distinctiveIdentifier:s.distinctiveIdentifier||"optional",sessionTypes:s.sessionTypes||[s.sessionType||"temporary"],audioCapabilities:t.map(l=>({contentType:`audio/mp4; codecs=${l}`,robustness:s.audioRobustness||"",encryptionScheme:s.audioEncryptionScheme||null})),videoCapabilities:n.map(l=>({contentType:`video/mp4; codecs=${l}`,robustness:s.videoRobustness||"",encryptionScheme:s.videoEncryptionScheme||null}))}]}function xa(h){var t;return!!h&&(h.sessionType==="persistent-license"||!!((t=h.sessionTypes)!=null&&t.some(n=>n==="persistent-license")))}function ql(h){const t=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/2),n=String.fromCharCode.apply(null,Array.from(t)),s=n.substring(n.indexOf("<"),n.length),c=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("KID")[0];if(c){const f=c.childNodes[0]?c.childNodes[0].nodeValue:c.getAttribute("VALUE");if(f){const _=ss(f).subarray(0,16);return Os(_),_}}return null}let Ws={};class as{static clearKeyUriToKeyIdMap(){Ws={}}static setKeyIdForUri(t,n){Ws[t]=n}constructor(t,n,s,o=[1],l=null,c){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=n,this.keyFormat=s,this.keyFormatVersions=o,this.iv=l,this.encrypted=t?t!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!Xn(t),c!=null&&c.startsWith("0x")&&(this.keyId=new Uint8Array(z(c)))}matches(t){return t.uri===this.uri&&t.method===this.method&&t.encrypted===this.encrypted&&t.keyFormat===this.keyFormat&&Kn(t.keyFormatVersions,this.keyFormatVersions)&&fr(t.iv,this.iv)&&fr(t.keyId,this.keyId)}isSupported(){if(this.method){if(Xn(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Wi.FAIRPLAY:case Wi.WIDEVINE:case Wi.PLAYREADY:case Wi.CLEARKEY:return["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(t){if(!this.encrypted||!this.uri)return null;if(Xn(this.method)){let o=this.iv;return o||(typeof t!="number"&&(re.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0),o=Ha(t)),new as(this.method,this.uri,"identity",this.keyFormatVersions,o)}if(this.pssh&&this.keyId)return this;const n=ba(this.uri);if(n)switch(this.keyFormat){case Wi.WIDEVINE:if(this.pssh=n,!this.keyId){const o=Lt(n.buffer);if(o.length){var s;const l=o[0];this.keyId=(s=l.kids)!=null&&s.length?l.kids[0]:null}}if(!this.keyId){const o=n.length-22;this.keyId=n.subarray(o,o+16)}break;case Wi.PLAYREADY:{const o=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=At(o,null,n),this.keyId=ql(n);break}default:{let o=n.subarray(0,16);if(o.length!==16){const l=new Uint8Array(16);l.set(o,16-o.length),o=l}this.keyId=o;break}}if(!this.keyId||this.keyId.byteLength!==16){let o=Ws[this.uri];if(!o){const l=Object.keys(Ws).length%Number.MAX_SAFE_INTEGER;o=new Uint8Array(16),new DataView(o.buffer,12,4).setUint32(0,l),as.setKeyIdForUri(this.uri,o)}this.keyId=o}return this}}function Ha(h){const t=new Uint8Array(16);for(let n=12;n<16;n++)t[n]=h>>8*(15-n)&255;return t}const nr=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,na=/#EXT-X-MEDIA:(.*)/g,Wa=/^#EXT(?:INF|-X-TARGETDURATION):/m,os=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),tl=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class ds{static findGroup(t,n){for(let s=0;s<t.length;s++){const o=t[s];if(o.id===n)return o}}static resolve(t,n){return A.buildAbsoluteURL(n,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return Wa.test(t)}static parseMasterPlaylist(t,n){const s=mr(t),o={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:s},l=[];if(nr.lastIndex=0,!t.startsWith("#EXTM3U"))return o.playlistParsingError=new Error("no EXTM3U delimiter"),o;let c;for(;(c=nr.exec(t))!=null;)if(c[1]){var f;const m=new vn(c[1],o),v=Nn(o,c[2]),y={attrs:m,bitrate:m.decimalInteger("BANDWIDTH")||m.decimalInteger("AVERAGE-BANDWIDTH"),name:m.NAME,url:ds.resolve(v,n)},x=m.decimalResolution("RESOLUTION");x&&(y.width=x.width,y.height=x.height),rl(m.CODECS,y);const D=m["SUPPLEMENTAL-CODECS"];D&&(y.supplemental={},rl(D,y.supplemental)),(f=y.unknownCodecs)!=null&&f.length||l.push(y),o.levels.push(y)}else if(c[3]){const m=c[3],v=c[4];switch(m){case"SESSION-DATA":{const y=new vn(v,o),x=y["DATA-ID"];x&&(o.sessionData===null&&(o.sessionData={}),o.sessionData[x]=y);break}case"SESSION-KEY":{const y=nl(v,n,o);y.encrypted&&y.isSupported()?(o.sessionKeys===null&&(o.sessionKeys=[]),o.sessionKeys.push(y)):re.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${v}"`);break}case"DEFINE":{{const y=new vn(v,o);ar(o,y,n)}break}case"CONTENT-STEERING":{const y=new vn(v,o);o.contentSteering={uri:ds.resolve(y["SERVER-URI"],n),pathwayId:y["PATHWAY-ID"]||"."};break}case"START":{o.startTimeOffset=Eo(v);break}}}const _=l.length>0&&l.length<o.levels.length;return o.levels=_?l:o.levels,o.levels.length===0&&(o.playlistParsingError=new Error("no levels found in manifest")),o}static parseMasterPlaylistMedia(t,n,s){let o;const l={},c=s.levels,f={AUDIO:c.map(m=>({id:m.attrs.AUDIO,audioCodec:m.audioCodec})),SUBTITLES:c.map(m=>({id:m.attrs.SUBTITLES,textCodec:m.textCodec})),"CLOSED-CAPTIONS":[]};let _=0;for(na.lastIndex=0;(o=na.exec(t))!==null;){const m=new vn(o[1],s),v=m.TYPE;if(v){const y=f[v],x=l[v]||[];l[v]=x;const D=m.LANGUAGE,C=m["ASSOC-LANGUAGE"],B=m.CHANNELS,F=m.CHARACTERISTICS,Q=m["INSTREAM-ID"],se={attrs:m,bitrate:0,id:_++,groupId:m["GROUP-ID"]||"",name:m.NAME||D||"",type:v,default:m.bool("DEFAULT"),autoselect:m.bool("AUTOSELECT"),forced:m.bool("FORCED"),lang:D,url:m.URI?ds.resolve(m.URI,n):""};if(C&&(se.assocLang=C),B&&(se.channels=B),F&&(se.characteristics=F),Q&&(se.instreamId=Q),y!=null&&y.length){const le=ds.findGroup(y,se.groupId)||y[0];sl(se,le,"audioCodec"),sl(se,le,"textCodec")}x.push(se)}}return l}static parseLevelPlaylist(t,n,s,o,l,c){var f;const _={url:n},m=new _r(n),v=m.fragments,y=[];let x=null,D=0,C=0,B=0,F=0,Q=0,se=null,le=new at(o,_),Ee,Ie,Qe,Pe=-1,Ze=!1,He=null,Fe;if(os.lastIndex=0,m.m3u8=t,m.hasVariableRefs=mr(t),((f=os.exec(t))==null?void 0:f[0])!=="#EXTM3U")return m.playlistParsingError=new Error("Missing format identifier #EXTM3U"),m;for(;(Ee=os.exec(t))!==null;){Ze&&(Ze=!1,le=new at(o,_),le.playlistOffset=B,le.setStart(B),le.sn=D,le.cc=F,Q&&(le.bitrate=Q),le.level=s,x&&(le.initSegment=x,x.rawProgramDateTime&&(le.rawProgramDateTime=x.rawProgramDateTime,x.rawProgramDateTime=null),He&&(le.setByteRange(He),He=null)));const yi=Ee[1];if(yi){le.duration=parseFloat(yi);const li=(" "+Ee[2]).slice(1);le.title=li||null,le.tagList.push(li?["INF",yi,li]:["INF",yi])}else if(Ee[3]){if(ce(le.duration)){le.playlistOffset=B,le.setStart(B),Qe&&As(le,Qe,m),le.sn=D,le.level=s,le.cc=F,v.push(le);const li=(" "+Ee[3]).slice(1);le.relurl=Nn(m,li),ra(le,se,y),se=le,B+=le.duration,D++,C=0,Ze=!0}}else{if(Ee=Ee[0].match(tl),!Ee){re.warn("No matches on slow regex match for level playlist!");continue}for(Ie=1;Ie<Ee.length&&Ee[Ie]===void 0;Ie++);const li=(" "+Ee[Ie]).slice(1),Vt=(" "+Ee[Ie+1]).slice(1),bi=Ee[Ie+2]?(" "+Ee[Ie+2]).slice(1):null;switch(li){case"BYTERANGE":se?le.setByteRange(Vt,se):le.setByteRange(Vt);break;case"PROGRAM-DATE-TIME":le.rawProgramDateTime=Vt,le.tagList.push(["PROGRAM-DATE-TIME",Vt]),Pe===-1&&(Pe=v.length);break;case"PLAYLIST-TYPE":m.type&&ps(m,li,Ee),m.type=Vt.toUpperCase();break;case"MEDIA-SEQUENCE":m.startSN!==0?ps(m,li,Ee):v.length>0&&To(m,li,Ee),D=m.startSN=parseInt(Vt);break;case"SKIP":{m.skippedSegments&&ps(m,li,Ee);const si=new vn(Vt,m),xi=si.decimalInteger("SKIPPED-SEGMENTS");if(ce(xi)){m.skippedSegments+=xi;for(let qt=xi;qt--;)v.push(null);D+=xi}const Pi=si.enumeratedString("RECENTLY-REMOVED-DATERANGES");Pi&&(m.recentlyRemovedDateranges=(m.recentlyRemovedDateranges||[]).concat(Pi.split(" ")));break}case"TARGETDURATION":m.targetduration!==0&&ps(m,li,Ee),m.targetduration=Math.max(parseInt(Vt),1);break;case"VERSION":m.version!==null&&ps(m,li,Ee),m.version=parseInt(Vt);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":m.live||ps(m,li,Ee),m.live=!1;break;case"#":(Vt||bi)&&le.tagList.push(bi?[Vt,bi]:[Vt]);break;case"DISCONTINUITY":F++,le.tagList.push(["DIS"]);break;case"GAP":le.gap=!0,le.tagList.push([li]);break;case"BITRATE":le.tagList.push([li,Vt]),Q=parseInt(Vt)*1e3,ce(Q)?le.bitrate=Q:Q=0;break;case"DATERANGE":{const si=new vn(Vt,m),xi=new jr(si,m.dateRanges[si.ID],m.dateRangeTagCount);m.dateRangeTagCount++,xi.isValid||m.skippedSegments?m.dateRanges[xi.id]=xi:re.warn(`Ignoring invalid DATERANGE tag: "${Vt}"`),le.tagList.push(["EXT-X-DATERANGE",Vt]);break}case"DEFINE":{{const si=new vn(Vt,m);"IMPORT"in si?$n(m,si,c):ar(m,si,n)}break}case"DISCONTINUITY-SEQUENCE":m.startCC!==0?ps(m,li,Ee):v.length>0&&To(m,li,Ee),m.startCC=F=parseInt(Vt);break;case"KEY":{const si=nl(Vt,n,m);if(si.isSupported()){if(si.method==="NONE"){Qe=void 0;break}Qe||(Qe={});const xi=Qe[si.keyFormat];xi!=null&&xi.matches(si)||(xi&&(Qe=k({},Qe)),Qe[si.keyFormat]=si)}else re.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${Vt}"`);break}case"START":m.startTimeOffset=Eo(Vt);break;case"MAP":{const si=new vn(Vt,m);if(le.duration){const xi=new at(o,_);ko(xi,si,s,Qe),x=xi,le.initSegment=x,x.rawProgramDateTime&&!le.rawProgramDateTime&&(le.rawProgramDateTime=x.rawProgramDateTime)}else{const xi=le.byteRangeEndOffset;if(xi){const Pi=le.byteRangeStartOffset;He=`${xi-Pi}@${Pi}`}else He=null;ko(le,si,s,Qe),x=le,Ze=!0}x.cc=F;break}case"SERVER-CONTROL":{Fe&&ps(m,li,Ee),Fe=new vn(Vt),m.canBlockReload=Fe.bool("CAN-BLOCK-RELOAD"),m.canSkipUntil=Fe.optionalFloat("CAN-SKIP-UNTIL",0),m.canSkipDateRanges=m.canSkipUntil>0&&Fe.bool("CAN-SKIP-DATERANGES"),m.partHoldBack=Fe.optionalFloat("PART-HOLD-BACK",0),m.holdBack=Fe.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{m.partTarget&&ps(m,li,Ee);const si=new vn(Vt);m.partTarget=si.decimalFloatingPoint("PART-TARGET");break}case"PART":{let si=m.partList;si||(si=m.partList=[]);const xi=C>0?si[si.length-1]:void 0,Pi=C++,qt=new vn(Vt,m),Zt=new Ot(qt,le,_,Pi,xi);si.push(Zt),le.duration+=Zt.duration;break}case"PRELOAD-HINT":{const si=new vn(Vt,m);m.preloadHint=si;break}case"RENDITION-REPORT":{const si=new vn(Vt,m);m.renditionReports=m.renditionReports||[],m.renditionReports.push(si);break}default:re.warn(`line parsed but not handled: ${Ee}`);break}}}se&&!se.relurl?(v.pop(),B-=se.duration,m.partList&&(m.fragmentHint=se)):m.partList&&(ra(le,se,y),le.cc=F,m.fragmentHint=le,Qe&&As(le,Qe,m)),m.targetduration||(m.playlistParsingError=new Error("Missing Target Duration"));const bt=v.length,Xt=v[0],ci=v[bt-1];if(B+=m.skippedSegments*m.targetduration,B>0&&bt&&ci){m.averagetargetduration=B/bt;const yi=ci.sn;m.endSN=yi!=="initSegment"?yi:0,m.live||(ci.endList=!0),Pe>0&&(al(v,Pe),Xt&&y.unshift(Xt))}return m.fragmentHint&&(B+=m.fragmentHint.duration),m.totalduration=B,y.length&&m.dateRangeTagCount&&Xt&&ls(y,m),m.endCC=F,m}}function ls(h,t){let n=h.length;if(!n)if(t.hasProgramDateTime){const f=t.fragments[t.fragments.length-1];h.push(f),n++}else return;const s=h[n-1],o=t.live?1/0:t.totalduration,l=Object.keys(t.dateRanges);for(let f=l.length;f--;){const _=t.dateRanges[l[f]],m=_.startDate.getTime();_.tagAnchor=s.ref;for(let v=n;v--;){var c;if(((c=h[v])==null?void 0:c.sn)<t.startSN)break;const y=il(t,m,h,v,o);if(y!==-1){_.tagAnchor=t.fragments[y].ref;break}}}}function il(h,t,n,s,o){const l=n[s];if(l){const f=l.programDateTime;if(t>=f||s===0){var c;const _=(((c=n[s+1])==null?void 0:c.start)||o)-l.start;if(t<=f+_*1e3){const m=n[s].sn-h.startSN;if(m<0)return-1;const v=h.fragments;if(v.length>n.length){const x=(n[s+1]||v[v.length-1]).sn-h.startSN;for(let D=x;D>m;D--){const C=v[D].programDateTime;if(t>=C&&t<C+v[D].duration*1e3)return D}}return m}}}return-1}function nl(h,t,n){var s,o;const l=new vn(h,n),c=(s=l.METHOD)!=null?s:"",f=l.URI,_=l.hexadecimalInteger("IV"),m=l.KEYFORMATVERSIONS,v=(o=l.KEYFORMAT)!=null?o:"identity";f&&l.IV&&!_&&re.error(`Invalid IV: ${l.IV}`);const y=f?ds.resolve(f,t):"",x=(m||"1").split("/").map(Number).filter(Number.isFinite);return new as(c,y,v,x,_,l.KEYID)}function Eo(h){const n=new vn(h).decimalFloatingPoint("TIME-OFFSET");return ce(n)?n:null}function rl(h,t){let n=(h||"").split(/[ ,]+/).filter(s=>s);["video","audio","text"].forEach(s=>{const o=n.filter(l=>Xe(l,s));o.length&&(t[`${s}Codec`]=o.map(l=>l.split("/")[0]).join(","),n=n.filter(l=>o.indexOf(l)===-1))}),t.unknownCodecs=n}function sl(h,t,n){const s=t[n];s&&(h[n]=s)}function al(h,t){let n=h[t];for(let s=t;s--;){const o=h[s];if(!o)return;o.programDateTime=n.programDateTime-o.duration*1e3,n=o}}function ra(h,t,n){h.rawProgramDateTime?n.push(h):t!=null&&t.programDateTime&&(h.programDateTime=t.endProgramDateTime)}function ko(h,t,n,s){h.relurl=t.URI,t.BYTERANGE&&h.setByteRange(t.BYTERANGE),h.level=n,h.sn="initSegment",s&&(h.levelkeys=s),h.initSegment=null}function As(h,t,n){h.levelkeys=t;const{encryptedFragments:s}=n;(!s.length||s[s.length-1].levelkeys!==t)&&Object.keys(t).some(o=>t[o].isCommonEncryption)&&s.push(h)}function ps(h,t,n){h.playlistParsingError=new Error(`#EXT-X-${t} must not appear more than once (${n[0]})`)}function To(h,t,n){h.playlistParsingError=new Error(`#EXT-X-${t} must appear before the first Media Segment (${n[0]})`)}function ja(h,t){const n=t.startPTS;if(ce(n)){let s=0,o;t.sn>h.sn?(s=n-h.start,o=h):(s=h.start-n,o=t),o.duration!==s&&o.setDuration(s)}else t.sn>h.sn?h.cc===t.cc&&h.minEndPTS?t.setStart(h.start+(h.minEndPTS-h.start)):t.setStart(h.start+h.duration):t.setStart(Math.max(h.start-t.duration,0))}function ol(h,t,n,s,o,l,c){s-n<=0&&(c.warn("Fragment should have a positive duration",t),s=n+t.duration,l=o+t.duration);let _=n,m=s;const v=t.startPTS,y=t.endPTS;if(ce(v)){const Q=Math.abs(v-n);h&&Q>h.totalduration?c.warn(`media timestamps and playlist times differ by ${Q}s for level ${t.level} ${h.url}`):ce(t.deltaPTS)?t.deltaPTS=Math.max(Q,t.deltaPTS):t.deltaPTS=Q,_=Math.max(n,v),n=Math.min(n,v),o=t.startDTS!==void 0?Math.min(o,t.startDTS):o,m=Math.min(s,y),s=Math.max(s,y),l=t.endDTS!==void 0?Math.max(l,t.endDTS):l}const x=n-t.start;t.start!==0&&t.setStart(n),t.setDuration(s-t.start),t.startPTS=n,t.maxStartPTS=_,t.startDTS=o,t.endPTS=s,t.minEndPTS=m,t.endDTS=l;const D=t.sn;if(!h||D<h.startSN||D>h.endSN)return 0;let C;const B=D-h.startSN,F=h.fragments;for(F[B]=t,C=B;C>0;C--)ja(F[C],F[C-1]);for(C=B;C<F.length-1;C++)ja(F[C],F[C+1]);return h.fragmentHint&&ja(F[F.length-1],h.fragmentHint),h.PTSKnown=h.alignedSliding=!0,x}function ll(h,t,n){if(h===t)return;let s=null;const o=h.fragments;for(let v=o.length-1;v>=0;v--){const y=o[v].initSegment;if(y){s=y;break}}h.fragmentHint&&delete h.fragmentHint.endPTS;let l;sa(h,t,(v,y,x,D)=>{if((!t.startCC||t.skippedSegments)&&y.cc!==v.cc){const C=v.cc-y.cc;for(let B=x;B<D.length;B++)D[B].cc+=C;t.endCC=D[D.length-1].cc}ce(v.startPTS)&&ce(v.endPTS)&&(y.setStart(y.startPTS=v.startPTS),y.startDTS=v.startDTS,y.maxStartPTS=v.maxStartPTS,y.endPTS=v.endPTS,y.endDTS=v.endDTS,y.minEndPTS=v.minEndPTS,y.setDuration(v.endPTS-v.startPTS),y.duration&&(l=y),t.PTSKnown=t.alignedSliding=!0),v.hasStreams&&(y.elementaryStreams=v.elementaryStreams),y.loader=v.loader,v.hasStats&&(y.stats=v.stats),v.initSegment&&(y.initSegment=v.initSegment,s=v.initSegment)});const c=t.fragments,f=t.fragmentHint?c.concat(t.fragmentHint):c;if(s&&f.forEach(v=>{var y;v&&(!v.initSegment||v.initSegment.relurl===((y=s)==null?void 0:y.relurl))&&(v.initSegment=s)}),t.skippedSegments){if(t.deltaUpdateFailed=c.some(v=>!v),t.deltaUpdateFailed){n.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let v=t.skippedSegments;v--;)c.shift();t.startSN=c[0].sn}else{t.canSkipDateRanges&&(t.dateRanges=wa(h.dateRanges,t,n));const v=h.fragments.filter(y=>y.rawProgramDateTime);if(h.hasProgramDateTime&&!t.hasProgramDateTime)for(let y=1;y<f.length;y++)f[y].programDateTime===null&&ra(f[y],f[y-1],v);ls(v,t)}t.endCC=c[c.length-1].cc}if(!t.startCC){var _;const v=Za(h,t.startSN-1);t.startCC=(_=v==null?void 0:v.cc)!=null?_:c[0].cc}Zl(h.partList,t.partList,(v,y)=>{y.elementaryStreams=v.elementaryStreams,y.stats=v.stats}),l?ol(t,l,l.startPTS,l.endPTS,l.startDTS,l.endDTS,n):Ao(h,t),c.length&&(t.totalduration=t.edge-c[0].start),t.driftStartTime=h.driftStartTime,t.driftStart=h.driftStart;const m=t.advancedDateTime;if(t.advanced&&m){const v=t.edge;t.driftStart||(t.driftStartTime=m,t.driftStart=v),t.driftEndTime=m,t.driftEnd=v}else t.driftEndTime=h.driftEndTime,t.driftEnd=h.driftEnd,t.advancedDateTime=h.advancedDateTime;t.requestScheduled===-1&&(t.requestScheduled=h.requestScheduled)}function wa(h,t,n){const{dateRanges:s,recentlyRemovedDateranges:o}=t,l=k({},h);o&&o.forEach(_=>{delete l[_]});const f=Object.keys(l).length;return f?(Object.keys(s).forEach(_=>{const m=l[_],v=new jr(s[_].attr,m);v.isValid?(l[_]=v,m||(v.tagOrder+=f)):n.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${$t(s[_].attr)}"`)}),l):s}function Zl(h,t,n){if(h&&t){let s=0;for(let o=0,l=h.length;o<=l;o++){const c=h[o],f=t[o+s];c&&f&&c.index===f.index&&c.fragment.sn===f.fragment.sn?n(c,f):s--}}}function sa(h,t,n){const s=t.skippedSegments,o=Math.max(h.startSN,t.startSN)-t.startSN,l=(h.fragmentHint?1:0)+(s?t.endSN:Math.min(h.endSN,t.endSN))-t.startSN,c=t.startSN-h.startSN,f=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,_=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments;for(let m=o;m<=l;m++){const v=_[c+m];let y=f[m];if(s&&!y&&v&&(y=t.fragments[m]=v),v&&y){n(v,y,m,f);const x=v.relurl,D=y.relurl;if(x&&Rn(x,D)){t.playlistParsingError=qa(`media sequence mismatch ${y.sn}:`,h,t,v,y);return}else if(v.cc!==y.cc){t.playlistParsingError=qa(`discontinuity sequence mismatch (${v.cc}!=${y.cc})`,h,t,v,y);return}}}}function qa(h,t,n,s,o){return new Error(`${h} ${o.url}
Playlist starting @${t.startSN}
${t.m3u8}
Playlist starting @${n.startSN}
${n.m3u8}`)}function Ao(h,t,n=!0){const s=t.startSN+t.skippedSegments-h.startSN,o=h.fragments,l=s>=0;let c=0;if(l&&s<o.length)c=o[s].start;else if(l&&t.startSN===h.endSN+1)c=h.fragmentEnd;else if(l&&n)c=h.fragmentStart+s*t.levelTargetDuration;else if(!t.skippedSegments&&t.fragmentStart===0)c=h.fragmentStart;else return;Lo(t,c)}function Lo(h,t){if(t){const n=h.fragments;for(let s=h.skippedSegments;s<n.length;s++)n[s].addStart(t);h.fragmentHint&&h.fragmentHint.addStart(t)}}function Fs(h,t=1/0){let n=1e3*h.targetduration;if(h.updated){const s=h.fragments;if(s.length&&n*4>t){const l=s[s.length-1].duration*1e3;l<n&&(n=l)}}else n/=2;return Math.round(n)}function Za(h,t,n){if(!h)return null;let s=h.fragments[t-h.startSN];return s||(s=h.fragmentHint,s&&s.sn===t)?s:t<h.startSN&&n&&n.sn===t?n:null}function Ya(h,t,n){return h?ul(h.partList,t,n):null}function ul(h,t,n){if(h)for(let s=h.length;s--;){const o=h[s];if(o.index===n&&o.fragment.sn===t)return o}return null}function Wn(h){h.forEach((t,n)=>{var s;(s=t.details)==null||s.fragments.forEach(o=>{o.level=n,o.initSegment&&(o.initSegment.level=n)})})}function Rn(h,t){return h!==t&&t?Fn(h)!==Fn(t):!1}function Fn(h){return h.replace(/\?[^?]*$/,"")}function Ar(h,t){for(let s=0,o=h.length;s<o;s++){var n;if(((n=h[s])==null?void 0:n.cc)===t)return h[s]}return null}function Xr(h,t){return!!(h&&t.startCC<h.endCC&&t.endCC>h.startCC)}function Sa(h,t){const n=h.start+t;h.startPTS=n,h.setStart(n),h.endPTS=n+h.duration}function aa(h,t){const n=t.fragments;for(let s=0,o=n.length;s<o;s++)Sa(n[s],h);t.fragmentHint&&Sa(t.fragmentHint,h),t.alignedSliding=!0}function Xa(h,t){h&&(Do(t,h),t.alignedSliding||Ea(t,h),!t.alignedSliding&&!t.skippedSegments&&Ao(h,t,!1))}function Do(h,t){if(!Xr(t,h))return;const n=Math.min(t.endCC,h.endCC),s=Ar(t.fragments,n),o=Ar(h.fragments,n);if(!s||!o)return;re.log(`Aligning playlist at start of dicontinuity sequence ${n}`);const l=s.start-o.start;aa(l,h)}function Ea(h,t){if(!h.hasProgramDateTime||!t.hasProgramDateTime)return;const n=h.fragments,s=t.fragments;if(!n.length||!s.length)return;let o,l;const c=Math.min(t.endCC,h.endCC);t.startCC<c&&h.startCC<c&&(o=Ar(s,c),l=Ar(n,c)),(!o||!l)&&(o=s[Math.floor(s.length/2)],l=Ar(n,o.cc)||n[Math.floor(n.length/2)]);const f=o.programDateTime,_=l.programDateTime;if(!f||!_)return;const m=(_-f)/1e3-(l.start-o.start);aa(m,h)}function vr(h,t,n){Ir(h,t,n),h.addEventListener(t,n)}function Ir(h,t,n){h.removeEventListener(t,n)}const Yl={toString:function(h){let t="";const n=h.length;for(let s=0;s<n;s++)t+=`[${h.start(s).toFixed(3)}-${h.end(s).toFixed(3)}]`;return t}},mt={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",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class Xl extends hr{constructor(t,n,s,o,l){super(o,t.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=mt.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{const{config:c,fragCurrent:f,media:_,mediaBuffer:m,state:v}=this,y=_?_.currentTime:0,x=Wt.bufferInfo(m||_,y,c.maxBufferHole),D=!x.len;if(this.log(`Media seeking to ${ce(y)?y.toFixed(3):y}, state: ${v}, ${D?"out of":"in"} buffer`),this.state===mt.ENDED)this.resetLoadingState();else if(f){const C=c.maxFragLookUpTolerance,B=f.start-C,F=f.start+f.duration+C;if(D||F<x.start||B>x.end){const Q=y>F;(y<B||Q)&&(Q&&f.loader&&(this.log(`Cancelling fragment load for seek (sn: ${f.sn})`),f.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(_){this.fragmentTracker.removeFragmentsInRange(y,1/0,this.playlistType,!0);const C=this.lastCurrentTime;if(y>C&&(this.lastCurrentTime=y),!this.loadingParts){const B=Math.max(x.end,y),F=this.shouldLoadParts(this.getLevelDetails(),B);F&&(this.log(`LL-Part loading ON after seeking to ${y.toFixed(2)} with buffer @${B.toFixed(2)}`),this.loadingParts=F)}}this.hls.hasEnoughToStart||(this.log(`Setting ${D?"startPosition":"nextLoadPosition"} to ${y} for seek without enough to start`),this.nextLoadPosition=y,D&&(this.startPosition=y)),D&&this.state===mt.IDLE&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=l,this.hls=t,this.fragmentLoader=new wr(t.config),this.keyLoader=s,this.fragmentTracker=n,this.config=t.config,this.decrypter=new Mn(t.config)}registerListeners(){const{hls:t}=this;t.on(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(S.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(S.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){if(this.state===mt.STOPPED)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=mt.STOPPED}get startPositionValue(){const{nextLoadPosition:t,startPosition:n}=this;return n===-1&&t?t:n}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(t,n){if(n.live||!this.media)return!1;const s=t.end||0,o=this.config.timelineOffset||0;if(s<=o)return!1;const l=t.buffered;this.config.maxBufferHole&&l&&l.length>1&&(t=Wt.bufferedInfo(l,t.start,0));const c=t.nextStart;if(c&&c>o&&c<n.edge||this.media.currentTime<t.start)return!1;const _=n.partList;if(_!=null&&_.length){const v=_[_.length-1];return Wt.isBuffered(this.media,v.start+v.duration/2)}const m=n.fragments[n.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(m)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null)return this.levelLastLoaded.details}get timelineOffset(){const t=this.config.timelineOffset;if(t){var n;return((n=this.getLevelDetails())==null?void 0:n.appliedTimelineOffset)||t}return 0}onMediaAttached(t,n){const s=this.media=this.mediaBuffer=n.media;vr(s,"seeking",this.onMediaSeeking),vr(s,"ended",this.onMediaEnded);const o=this.config;this.levels&&o.autoStartLoad&&this.state===mt.STOPPED&&this.startLoad(o.startPosition)}onMediaDetaching(t,n){const s=!!n.transferMedia,o=this.media;if(o!==null){if(o.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),Ir(o,"seeking",this.onMediaSeeking),Ir(o,"ended",this.onMediaEnded),this.keyLoader&&!s&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,s){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}onError(t,n){}onManifestLoaded(t,n){this.startTimeOffset=n.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=mt.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(t,n,s){this.startFragRequested=!0,this._loadFragForPlayback(t,n,s)}_loadFragForPlayback(t,n,s){const o=l=>{const c=l.frag;if(this.fragContextChanged(c)){this.warn(`${c.type} sn: ${c.sn}${l.part?" part: "+l.part.index:""} of ${this.fragInfo(c,!1,l.part)}) was dropped during download.`),this.fragmentTracker.removeFragment(c);return}c.stats.chunkCount++,this._handleFragmentLoadProgress(l)};this._doFragLoad(t,n,s,o).then(l=>{if(!l)return;const c=this.state,f=l.frag;if(this.fragContextChanged(f)){(c===mt.FRAG_LOADING||!this.fragCurrent&&c===mt.PARSING)&&(this.fragmentTracker.removeFragment(f),this.state=mt.IDLE);return}"payload"in l&&(this.log(`Loaded ${f.type} sn: ${f.sn} of ${this.playlistLabel()} ${f.level}`),this.hls.trigger(S.FRAG_LOADED,l)),this._handleFragmentLoadComplete(l)}).catch(l=>{this.state===mt.STOPPED||this.state===mt.ERROR||(this.warn(`Frag error: ${(l==null?void 0:l.message)||l}`),this.resetFragmentLoading(t))})}clearTrackerIfNeeded(t){var n;const{fragmentTracker:s}=this;if(s.getState(t)===rn.APPENDING){const l=t.type,c=this.getFwdBufferInfo(this.mediaBuffer,l),f=Math.max(t.duration,c?c.len:this.config.maxBufferLength),_=this.backtrackFragment;((_?t.sn-_.sn:0)===1||this.reduceMaxBufferLength(f,t.duration))&&s.removeFragment(t)}else((n=this.mediaBuffer)==null?void 0:n.buffered.length)===0?s.removeAllFragments():s.hasParts(t.type)&&(s.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),s.getState(t)===rn.PARTIAL&&s.removeFragment(t))}checkLiveUpdate(t){if(t.updated&&!t.live){const n=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:n,part:null,stats:n.stats,id:n.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)}waitForLive(t){const n=t.details;return(n==null?void 0:n.live)&&n.type!=="EVENT"&&(this.levelLastLoaded!==t||n.expired)}flushMainBuffer(t,n,s=null){if(!(t-n))return;const o={startOffset:t,endOffset:n,type:s};this.hls.trigger(S.BUFFER_FLUSHING,o)}_loadInitSegment(t,n){this._doFragLoad(t,n).then(s=>{const o=s==null?void 0:s.frag;if(!o||this.fragContextChanged(o)||!this.levels)throw new Error("init load aborted");return s}).then(s=>{const{hls:o}=this,{frag:l,payload:c}=s,f=l.decryptdata;if(c&&c.byteLength>0&&f!=null&&f.key&&f.iv&&Xn(f.method)){const _=self.performance.now();return this.decrypter.decrypt(new Uint8Array(c),f.key.buffer,f.iv.buffer,rs(f.method)).catch(m=>{throw o.trigger(S.ERROR,{type:ge.MEDIA_ERROR,details:q.FRAG_DECRYPT_ERROR,fatal:!1,error:m,reason:m.message,frag:l}),m}).then(m=>{const v=self.performance.now();return o.trigger(S.FRAG_DECRYPTED,{frag:l,payload:m,stats:{tstart:_,tdecrypt:v}}),s.payload=m,this.completeInitSegmentLoad(s)})}return this.completeInitSegmentLoad(s)}).catch(s=>{this.state===mt.STOPPED||this.state===mt.ERROR||(this.warn(s),this.resetFragmentLoading(t))})}completeInitSegmentLoad(t){const{levels:n}=this;if(!n)throw new Error("init load aborted, missing levels");const s=t.frag.stats;this.state!==mt.STOPPED&&(this.state=mt.IDLE),t.frag.data=new Uint8Array(t.payload),s.parsing.start=s.buffering.start=self.performance.now(),s.parsing.end=s.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(t,n){var s,o;const l=t.tracks;if(l&&!n.encrypted&&((s=l.audio)!=null&&s.encrypted||(o=l.video)!=null&&o.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const c=this.media,f=new Error(`Encrypted track with no key in ${this.fragInfo(n)} (media ${c?"attached mediaKeys: "+c.mediaKeys:"detached"})`);return this.warn(f.message),!c||c.mediaKeys?!1:(this.hls.trigger(S.ERROR,{type:ge.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_KEYS,fatal:!1,error:f,frag:n}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(t){const{fragCurrent:n}=this;return!t||!n||t.sn!==n.sn||t.level!==n.level}fragBufferedComplete(t,n){const s=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${t.type} sn: ${t.sn}${n?" part: "+n.index:""} of ${this.fragInfo(t,!1,n)} > buffer:${s?Yl.toString(Wt.getBuffered(s)):"(detached)"})`),ze(t)){var o;if(t.type!==P.SUBTITLE){const c=t.elementaryStreams;if(!Object.keys(c).some(f=>!!c[f])){this.state=mt.IDLE;return}}const l=(o=this.levels)==null?void 0:o[t.level];l!=null&&l.fragmentError&&(this.log(`Resetting level fragment error count of ${l.fragmentError} on frag buffered`),l.fragmentError=0)}this.state=mt.IDLE}_handleFragmentLoadComplete(t){const{transmuxer:n}=this;if(!n)return;const{frag:s,part:o,partsLoaded:l}=t,c=!l||l.length===0||l.some(_=>!_),f=new Wr(s.level,s.sn,s.stats.chunkCount+1,0,o?o.index:-1,!c);n.flush(f)}_handleFragmentLoadProgress(t){}_doFragLoad(t,n,s=null,o){var l;this.fragCurrent=t;const c=n.details;if(!this.levels||!c)throw new Error(`frag load aborted, missing level${c?"":" detail"}s`);let f=null;if(t.encrypted&&!((l=t.decryptdata)!=null&&l.key)){if(this.log(`Loading key for ${t.sn} of [${c.startSN}-${c.endSN}], ${this.playlistLabel()} ${t.level}`),this.state=mt.KEY_LOADING,this.fragCurrent=t,f=this.keyLoader.load(t).then(x=>{if(!this.fragContextChanged(x.frag))return this.hls.trigger(S.KEY_LOADED,x),this.state===mt.KEY_LOADING&&(this.state=mt.IDLE),x}),this.hls.trigger(S.KEY_LOADING,{frag:t}),this.fragCurrent===null)return this.log("context changed in KEY_LOADING"),Promise.resolve(null)}else t.encrypted||(f=this.keyLoader.loadClear(t,c.encryptedFragments,this.startFragRequested),f&&this.log("[eme] blocking frag load until media-keys acquired"));const _=this.fragPrevious;if(ze(t)&&(!_||t.sn!==_.sn)){const x=this.shouldLoadParts(n.details,t.end);x!==this.loadingParts&&(this.log(`LL-Part loading ${x?"ON":"OFF"} loading sn ${_==null?void 0:_.sn}->${t.sn}`),this.loadingParts=x)}if(s=Math.max(t.start,s||0),this.loadingParts&&ze(t)){const x=c.partList;if(x&&o){s>c.fragmentEnd&&c.fragmentHint&&(t=c.fragmentHint);const D=this.getNextPart(x,t,s);if(D>-1){const C=x[D];t=this.fragCurrent=C.fragment,this.log(`Loading ${t.type} sn: ${t.sn} part: ${C.index} (${D}/${x.length-1}) of ${this.fragInfo(t,!1,C)}) cc: ${t.cc} [${c.startSN}-${c.endSN}], target: ${parseFloat(s.toFixed(3))}`),this.nextLoadPosition=C.start+C.duration,this.state=mt.FRAG_LOADING;let B;return f?B=f.then(F=>!F||this.fragContextChanged(F.frag)?null:this.doFragPartsLoad(t,C,n,o)).catch(F=>this.handleFragLoadError(F)):B=this.doFragPartsLoad(t,C,n,o).catch(F=>this.handleFragLoadError(F)),this.hls.trigger(S.FRAG_LOADING,{frag:t,part:C,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):B}else if(!t.url||this.loadedEndOfParts(x,s))return Promise.resolve(null)}}if(ze(t)&&this.loadingParts){var m;this.log(`LL-Part loading OFF after next part miss @${s.toFixed(2)} Check buffer at sn: ${t.sn} loaded parts: ${(m=c.partList)==null?void 0:m.filter(x=>x.loaded).map(x=>`[${x.start}-${x.end}]`)}`),this.loadingParts=!1}else if(!t.url)return Promise.resolve(null);this.log(`Loading ${t.type} sn: ${t.sn} of ${this.fragInfo(t,!1)}) cc: ${t.cc} ${"["+c.startSN+"-"+c.endSN+"]"}, target: ${parseFloat(s.toFixed(3))}`),ce(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=mt.FRAG_LOADING;const v=this.config.progressive;let y;return v&&f?y=f.then(x=>!x||this.fragContextChanged(x.frag)?null:this.fragmentLoader.load(t,o)).catch(x=>this.handleFragLoadError(x)):y=Promise.all([this.fragmentLoader.load(t,v?o:void 0),f]).then(([x])=>(!v&&o&&o(x),x)).catch(x=>this.handleFragLoadError(x)),this.hls.trigger(S.FRAG_LOADING,{frag:t,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):y}doFragPartsLoad(t,n,s,o){return new Promise((l,c)=>{var f;const _=[],m=(f=s.details)==null?void 0:f.partList,v=y=>{this.fragmentLoader.loadPart(t,y,o).then(x=>{_[y.index]=x;const D=x.part;this.hls.trigger(S.FRAG_LOADED,x);const C=Ya(s.details,t.sn,y.index+1)||ul(m,t.sn,y.index+1);if(C)v(C);else return l({frag:t,part:D,partsLoaded:_})}).catch(c)};v(n)})}handleFragLoadError(t){if("data"in t){const n=t.data;n.frag&&n.details===q.INTERNAL_ABORTED?this.handleFragLoadAborted(n.frag,n.part):n.frag&&n.type===ge.KEY_SYSTEM_ERROR?(n.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(n.frag)):this.hls.trigger(S.ERROR,n)}else this.hls.trigger(S.ERROR,{type:ge.OTHER_ERROR,details:q.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const n=this.getCurrentContext(t);if(!n||this.state!==mt.PARSING){!this.fragCurrent&&this.state!==mt.STOPPED&&this.state!==mt.ERROR&&(this.state=mt.IDLE);return}const{frag:s,part:o,level:l}=n,c=self.performance.now();s.stats.parsing.end=c,o&&(o.stats.parsing.end=c);const f=this.getLevelDetails(),m=f&&s.sn>f.endSN||this.shouldLoadParts(f,s.end);m!==this.loadingParts&&(this.log(`LL-Part loading ${m?"ON":"OFF"} after parsing segment ending @${s.end.toFixed(2)}`),this.loadingParts=m),this.updateLevelTiming(s,o,l,t.partial)}shouldLoadParts(t,n){if(this.config.lowLatencyMode){if(!t)return this.loadingParts;if(t.partList){var s;const l=t.partList[0];if(l.fragment.type===P.SUBTITLE)return!1;const c=l.end+(((s=t.fragmentHint)==null?void 0:s.duration)||0);if(n>=c){var o;if((this.hls.hasEnoughToStart?((o=this.media)==null?void 0:o.currentTime)||this.lastCurrentTime:this.getLoadPosition())>l.start-l.fragment.duration)return!0}}}return!1}getCurrentContext(t){const{levels:n,fragCurrent:s}=this,{level:o,sn:l,part:c}=t;if(!(n!=null&&n[o]))return this.warn(`Levels object was unset while buffering fragment ${l} of ${this.playlistLabel()} ${o}. The current chunk will not be buffered.`),null;const f=n[o],_=f.details,m=c>-1?Ya(_,l,c):null,v=m?m.fragment:Za(_,l,s);return v?(s&&s!==v&&(v.stats=s.stats),{frag:v,part:m,level:f}):null}bufferFragmentData(t,n,s,o,l){if(this.state!==mt.PARSING)return;const{data1:c,data2:f}=t;let _=c;if(f&&(_=ht(c,f)),!_.length)return;const m=this.initPTS[n.cc],v=m?-m.baseTime/m.timescale:void 0,y={type:t.type,frag:n,part:s,chunkMeta:o,offset:v,parent:n.type,data:_};if(this.hls.trigger(S.BUFFER_APPENDING,y),t.dropped&&t.independent&&!s){if(l)return;this.flushBufferGap(n)}}flushBufferGap(t){const n=this.media;if(!n)return;if(!Wt.isBuffered(n,n.currentTime)){this.flushMainBuffer(0,t.start);return}const s=n.currentTime,o=Wt.bufferInfo(n,s,0),l=t.duration,c=Math.min(this.config.maxFragLookUpTolerance*2,l*.25),f=Math.max(Math.min(t.start-c,o.end-c),s+c);t.start-f>c&&this.flushMainBuffer(f,t.start)}getFwdBufferInfo(t,n){var s;const o=this.getLoadPosition();if(!ce(o))return null;const c=this.lastCurrentTime>o||(s=this.media)!=null&&s.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(t,o,n,c)}getFwdBufferInfoAtPos(t,n,s,o){const l=Wt.bufferInfo(t,n,o);if(l.len===0&&l.nextStart!==void 0){const c=this.fragmentTracker.getBufferedFrag(n,s);if(c&&(l.nextStart<=c.end||c.gap)){const f=Math.max(Math.min(l.nextStart,c.end)-n,o);return Wt.bufferInfo(t,n,f)}}return l}getMaxBufferLength(t){const{config:n}=this;let s;return t?s=Math.max(8*n.maxBufferSize/t,n.maxBufferLength):s=n.maxBufferLength,Math.min(s,n.maxMaxBufferLength)}reduceMaxBufferLength(t,n){const s=this.config,o=Math.max(Math.min(t-n,s.maxBufferLength),n),l=Math.max(t-n*3,s.maxMaxBufferLength/2,o);return l>=o?(s.maxMaxBufferLength=l,this.warn(`Reduce max buffer length to ${l}s`),!0):!1}getAppendedFrag(t,n=P.MAIN){const s=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(t,n):null;return s&&"fragment"in s?s.fragment:s}getNextFragment(t,n){const s=n.fragments,o=s.length;if(!o)return null;const{config:l}=this,c=s[0].start,f=l.lowLatencyMode&&!!n.partList;let _=null;if(n.live){const y=l.initialLiveManifestSize;if(o<y)return this.warn(`Not enough fragments to start playback (have: ${o}, need: ${y})`),null;if(!n.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||t<c){var m;f&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),_=this.getInitialLiveFragment(n);const x=this.hls.startPosition,D=this.hls.liveSyncPosition,C=_?(x!==-1&&x>=c?x:D)||_.start:t;this.log(`Setting startPosition to ${C} to match start frag at live edge. mainStart: ${x} liveSyncPosition: ${D} frag.start: ${(m=_)==null?void 0:m.start}`),this.startPosition=this.nextLoadPosition=C}}else t<=c&&(_=s[0]);if(!_){const y=this.loadingParts?n.partEnd:n.fragmentEnd;_=this.getFragmentAtPosition(t,y,n)}let v=this.filterReplacedPrimary(_,n);if(!v&&_){const y=_.sn-n.startSN;v=this.filterReplacedPrimary(s[y+1]||null,n)}return this.mapToInitFragWhenRequired(v)}isLoopLoading(t,n){const s=this.fragmentTracker.getState(t);return(s===rn.OK||s===rn.PARTIAL&&!!t.gap)&&this.nextLoadPosition>n}getNextFragmentLoopLoading(t,n,s,o,l){let c=null;if(t.gap&&(c=this.getNextFragment(this.nextLoadPosition,n),c&&!c.gap&&s.nextStart)){const f=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,s.nextStart,o,0);if(f!==null&&s.len+f.len>=l){const _=c.sn;return this.loopSn!==_&&(this.log(`buffer full after gaps in "${o}" playlist starting at sn: ${_}`),this.loopSn=_),null}}return this.loopSn=void 0,c}get primaryPrefetch(){if(Co(this.config)){var t;if((t=this.hls.interstitialsManager)==null||(t=t.playingItem)==null?void 0:t.event)return!0}return!1}filterReplacedPrimary(t,n){if(!t)return t;if(Co(this.config)&&t.type!==P.SUBTITLE){const s=this.hls.interstitialsManager,o=s==null?void 0:s.bufferingItem;if(o){const c=o.event;if(c){if(c.appendInPlace||Math.abs(t.start-o.start)>1||o.start===0)return null}else if(t.end<=o.start&&(n==null?void 0:n.live)===!1||t.start>o.end&&o.nextEvent&&(o.nextEvent.appendInPlace||t.start-o.end>1))return null}const l=s==null?void 0:s.playerQueue;if(l)for(let c=l.length;c--;){const f=l[c].interstitial;if(f.appendInPlace&&t.start>=f.startTime&&t.end<=f.resumeTime)return null}}return t}mapToInitFragWhenRequired(t){return t!=null&&t.initSegment&&!t.initSegment.data&&!this.bitrateTest?t.initSegment:t}getNextPart(t,n,s){let o=-1,l=!1,c=!0;for(let f=0,_=t.length;f<_;f++){const m=t[f];if(c=c&&!m.independent,o>-1&&s<m.start)break;const v=m.loaded;v?o=-1:(l||(m.independent||c)&&m.fragment===n)&&(m.fragment!==n&&this.warn(`Need buffer at ${s} but next unloaded part starts at ${m.start}`),o=f),l=v}return o}loadedEndOfParts(t,n){let s;for(let o=t.length;o--;){if(s=t[o],!s.loaded)return!1;if(n>s.start)return!0}return!1}getInitialLiveFragment(t){const n=t.fragments,s=this.fragPrevious;let o=null;if(s){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${s.programDateTime}`),o=$i(n,s.endProgramDateTime,this.config.maxFragLookUpTolerance)),!o){const l=s.sn+1;if(l>=t.startSN&&l<=t.endSN){const c=n[l-t.startSN];s.cc===c.cc&&(o=c,this.log(`Live playlist, switching playlist, load frag with next SN: ${o.sn}`))}o||(o=wi(t,s.cc,s.end),o&&this.log(`Live playlist, switching playlist, load frag with same CC: ${o.sn}`))}}else{const l=this.hls.liveSyncPosition;l!==null&&(o=this.getFragmentAtPosition(l,this.bitrateTest?t.fragmentEnd:t.edge,t))}return o}getFragmentAtPosition(t,n,s){const{config:o}=this;let{fragPrevious:l}=this,{fragments:c,endSN:f}=s;const{fragmentHint:_}=s,{maxFragLookUpTolerance:m}=o,v=s.partList,y=!!(this.loadingParts&&v!=null&&v.length&&_);y&&!this.bitrateTest&&v[v.length-1].fragment.sn===_.sn&&(c=c.concat(_),f=_.sn);let x;if(t<n){var D;const B=t<this.lastCurrentTime||t>n-m||(D=this.media)!=null&&D.paused||!this.startFragRequested?0:m;x=ui(l,c,t,B)}else x=c[c.length-1];if(x){const C=x.sn-s.startSN,B=this.fragmentTracker.getState(x);if((B===rn.OK||B===rn.PARTIAL&&x.gap)&&(l=x),l&&x.sn===l.sn&&(!y||v[0].fragment.sn>x.sn||!s.live)&&x.level===l.level){const Q=c[C+1];x.sn<f&&this.fragmentTracker.getState(Q)!==rn.OK?x=Q:x=null}}return x}alignPlaylists(t,n,s){const o=t.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;const l=t.fragmentStart,c=!n,f=t.alignedSliding&&ce(l);if(c||!f&&!l){Xa(s,t);const _=t.fragmentStart;return this.log(`Live playlist sliding: ${_.toFixed(2)} start-sn: ${n?n.startSN:"na"}->${t.startSN} fragments: ${o}`),_}return l}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,t.partTarget*3)}setStartPosition(t,n){let s=this.startPosition;s<n&&(s=-1);const o=this.timelineOffset;if(s===-1){const l=this.startTimeOffset!==null,c=l?this.startTimeOffset:t.startTimeOffset;c!==null&&ce(c)?(s=n+c,c<0&&(s+=t.edge),s=Math.min(Math.max(n,s),n+t.totalduration),this.log(`Setting startPosition to ${s} for start time offset ${c} found in ${l?"multivariant":"media"} playlist`),this.startPosition=s):t.live?(s=this.hls.liveSyncPosition||n,this.log(`Setting startPosition to -1 to start at live edge ${s}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=s=0),this.lastCurrentTime=s+o}this.nextLoadPosition=s+o}getLoadPosition(){var t;const{media:n}=this;let s=0;return(t=this.hls)!=null&&t.hasEnoughToStart&&n?s=n.currentTime:this.nextLoadPosition>=0&&(s=this.nextLoadPosition),s}handleFragLoadAborted(t,n){this.transmuxer&&t.type===this.playlistType&&ze(t)&&t.stats.aborted&&(this.log(`Fragment ${t.sn}${n?" part "+n.index:""} of ${this.playlistLabel()} ${t.level} was aborted`),this.resetFragmentLoading(t))}resetFragmentLoading(t){(!this.fragCurrent||!this.fragContextChanged(t)&&this.state!==mt.FRAG_LOADING_WAITING_RETRY)&&(this.state=mt.IDLE)}onFragmentOrKeyLoadError(t,n){var s;if(n.chunkMeta&&!n.frag){const Q=this.getCurrentContext(n.chunkMeta);Q&&(n.frag=Q.frag)}const o=n.frag;if(!o||o.type!==t||!this.levels)return;if(this.fragContextChanged(o)){var l;this.warn(`Frag load error must match current frag to retry ${o.url} > ${(l=this.fragCurrent)==null?void 0:l.url}`);return}const c=n.details===q.FRAG_GAP;c&&this.fragmentTracker.fragBuffered(o,!0);const f=n.errorAction;if(!f){this.state=mt.ERROR;return}const{action:_,flags:m,retryCount:v=0,retryConfig:y}=f,x=!!y,D=x&&_===Ui.RetryRequest,C=x&&!f.resolved&&m===zi.MoveAllAlternatesMatchingHost,B=(s=this.hls.latestLevelDetails)==null?void 0:s.live;if(!D&&C&&ze(o)&&!o.endList&&B&&!en(n))this.resetFragmentErrors(t),this.treatAsGap(o),f.resolved=!0;else if((D||C)&&v<y.maxNumRetry){var F;const Q=tr((F=n.response)==null?void 0:F.code),se=tn(y,v);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+se,this.state=mt.FRAG_LOADING_WAITING_RETRY,f.resolved=!0,Q){this.log("Waiting for connection (offline)"),this.retryDate=1/0,n.reason="offline";return}this.warn(`Fragment ${o.sn} of ${t} ${o.level} errored with ${n.details}, retrying loading ${v+1}/${y.maxNumRetry} in ${se}ms`)}else if(y)if(this.resetFragmentErrors(t),v<y.maxNumRetry)!c&&_!==Ui.RemoveAlternatePermanently&&(f.resolved=!0);else{this.warn(`${n.details} reached or exceeded max retry (${v})`);return}else _===Ui.SendAlternateToPenaltyBox?this.state=mt.WAITING_LEVEL:this.state=mt.ERROR;this.tickImmediate()}checkRetryDate(){const t=self.performance.now(),n=this.retryDate,s=n===1/0;(!n||t>=n||s&&!tr(0))&&(s&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=mt.IDLE)}reduceLengthAndFlushBuffer(t){if(this.state===mt.PARSING||this.state===mt.PARSED){const n=t.frag,s=t.parent,o=this.getFwdBufferInfo(this.mediaBuffer,s),l=o&&o.len>.5;l&&this.reduceMaxBufferLength(o.len,(n==null?void 0:n.duration)||10);const c=!l;return c&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${s} buffer`),n&&(this.fragmentTracker.removeFragment(n),this.nextLoadPosition=n.start),this.resetLoadingState(),c}return!1}resetFragmentErrors(t){t===P.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==mt.STOPPED&&(this.state=mt.IDLE)}afterBufferFlushed(t,n,s){if(!t)return;const o=Wt.getBuffered(t);this.fragmentTracker.detectEvictedFragments(n,o,s),this.state===mt.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==mt.STOPPED&&(this.state=mt.IDLE)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const t=this.levelLastLoaded,n=t?t.details:null;n!=null&&n.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(n,n.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(t){this.log(`Loading context changed while buffering sn ${t.sn} of ${this.playlistLabel()} ${t.level===-1?"<removed>":t.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(t=0){this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(t,n,s,o){const l=s.details;if(!l){this.warn("level.details undefined");return}if(!Object.keys(t.elementaryStreams).reduce((_,m)=>{const v=t.elementaryStreams[m];if(v){const y=v.endPTS-v.startPTS;if(y<=0)return this.warn(`Could not parse fragment ${t.sn} ${m} duration reliably (${y})`),_||!1;const x=o?0:ol(l,t,v.startPTS,v.endPTS,v.startDTS,v.endDTS,this);return this.hls.trigger(S.LEVEL_PTS_UPDATED,{details:l,level:s,drift:x,type:m,frag:t,start:v.startPTS,end:v.endPTS}),!0}return _},!1)){var f;if(s.fragmentError===0&&this.treatAsGap(t,s),((f=this.transmuxer)==null?void 0:f.error)===null){const _=new Error(`Found no media in fragment ${t.sn} of ${this.playlistLabel()} ${t.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(_.message),this.hls.trigger(S.ERROR,{type:ge.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!1,error:_,frag:t,reason:`Found no media in msn ${t.sn} of ${this.playlistLabel()} "${s.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=mt.PARSED,this.log(`Parsed ${t.type} sn: ${t.sn}${n?" part: "+n.index:""} of ${this.fragInfo(t,!1,n)})`),this.hls.trigger(S.FRAG_PARSED,{frag:t,part:n})}playlistLabel(){return this.playlistType===P.MAIN?"level":"track"}fragInfo(t,n=!0,s){var o,l;return`${this.playlistLabel()} ${t.level} (${s?"part":"frag"}:[${((o=n&&!s?t.startPTS:(s||t).start)!=null?o:NaN).toFixed(3)}-${((l=n&&!s?t.endPTS:(s||t).end)!=null?l:NaN).toFixed(3)}]${s&&t.type==="main"?"INDEPENDENT="+(s.independent?"YES":"NO"):""}`}treatAsGap(t,n){n&&n.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)}resetTransmuxer(){var t;(t=this.transmuxer)==null||t.reset()}recoverWorkerError(t){t.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(t){const n=this._state;n!==t&&(this._state=t,this.log(`${n}->${t}`))}get state(){return this._state}}function Co(h){return!!h.interstitialsController&&h.enableInterstitialPlayback!==!1}class oc{constructor(){this.chunks=[],this.dataLength=0}push(t){this.chunks.push(t),this.dataLength+=t.length}flush(){const{chunks:t,dataLength:n}=this;let s;if(t.length)t.length===1?s=t[0]:s=vh(t,n);else return new Uint8Array(0);return this.reset(),s}reset(){this.chunks.length=0,this.dataLength=0}}function vh(h,t){const n=new Uint8Array(t);let s=0;for(let o=0;o<h.length;o++){const l=h[o];n.set(l,s),s+=l.length}return n}var Jl={exports:{}},lc;function yh(){return lc||(lc=1,function(h){var t=Object.prototype.hasOwnProperty,n="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(n=!1));function o(_,m,v){this.fn=_,this.context=m,this.once=v||!1}function l(_,m,v,y,x){if(typeof v!="function")throw new TypeError("The listener must be a function");var D=new o(v,y||_,x),C=n?n+m:m;return _._events[C]?_._events[C].fn?_._events[C]=[_._events[C],D]:_._events[C].push(D):(_._events[C]=D,_._eventsCount++),_}function c(_,m){--_._eventsCount===0?_._events=new s:delete _._events[m]}function f(){this._events=new s,this._eventsCount=0}f.prototype.eventNames=function(){var m=[],v,y;if(this._eventsCount===0)return m;for(y in v=this._events)t.call(v,y)&&m.push(n?y.slice(1):y);return Object.getOwnPropertySymbols?m.concat(Object.getOwnPropertySymbols(v)):m},f.prototype.listeners=function(m){var v=n?n+m:m,y=this._events[v];if(!y)return[];if(y.fn)return[y.fn];for(var x=0,D=y.length,C=new Array(D);x<D;x++)C[x]=y[x].fn;return C},f.prototype.listenerCount=function(m){var v=n?n+m:m,y=this._events[v];return y?y.fn?1:y.length:0},f.prototype.emit=function(m,v,y,x,D,C){var B=n?n+m:m;if(!this._events[B])return!1;var F=this._events[B],Q=arguments.length,se,le;if(F.fn){switch(F.once&&this.removeListener(m,F.fn,void 0,!0),Q){case 1:return F.fn.call(F.context),!0;case 2:return F.fn.call(F.context,v),!0;case 3:return F.fn.call(F.context,v,y),!0;case 4:return F.fn.call(F.context,v,y,x),!0;case 5:return F.fn.call(F.context,v,y,x,D),!0;case 6:return F.fn.call(F.context,v,y,x,D,C),!0}for(le=1,se=new Array(Q-1);le<Q;le++)se[le-1]=arguments[le];F.fn.apply(F.context,se)}else{var Ee=F.length,Ie;for(le=0;le<Ee;le++)switch(F[le].once&&this.removeListener(m,F[le].fn,void 0,!0),Q){case 1:F[le].fn.call(F[le].context);break;case 2:F[le].fn.call(F[le].context,v);break;case 3:F[le].fn.call(F[le].context,v,y);break;case 4:F[le].fn.call(F[le].context,v,y,x);break;default:if(!se)for(Ie=1,se=new Array(Q-1);Ie<Q;Ie++)se[Ie-1]=arguments[Ie];F[le].fn.apply(F[le].context,se)}}return!0},f.prototype.on=function(m,v,y){return l(this,m,v,y,!1)},f.prototype.once=function(m,v,y){return l(this,m,v,y,!0)},f.prototype.removeListener=function(m,v,y,x){var D=n?n+m:m;if(!this._events[D])return this;if(!v)return c(this,D),this;var C=this._events[D];if(C.fn)C.fn===v&&(!x||C.once)&&(!y||C.context===y)&&c(this,D);else{for(var B=0,F=[],Q=C.length;B<Q;B++)(C[B].fn!==v||x&&!C[B].once||y&&C[B].context!==y)&&F.push(C[B]);F.length?this._events[D]=F.length===1?F[0]:F:c(this,D)}return this},f.prototype.removeAllListeners=function(m){var v;return m?(v=n?n+m:m,this._events[v]&&c(this,v)):(this._events=new s,this._eventsCount=0),this},f.prototype.off=f.prototype.removeListener,f.prototype.addListener=f.prototype.on,f.prefixed=n,f.EventEmitter=f,h.exports=f}(Jl)),Jl.exports}var qr=yh(),Bs=X(qr);const Ls="1.6.12",Ja={};function uc(){return typeof __HLS_WORKER_BUNDLE__=="function"}function bh(){const h=Ja[Ls];if(h)return h.clientCount++,h;const t=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),n=self.URL.createObjectURL(t),o={worker:new self.Worker(n),objectURL:n,clientCount:1};return Ja[Ls]=o,o}function xh(h){const t=Ja[h];if(t)return t.clientCount++,t;const n=new self.URL(h,self.location.href).href,o={worker:new self.Worker(n),scriptURL:n,clientCount:1};return Ja[h]=o,o}function cc(h){const t=Ja[h||Ls];if(t&&t.clientCount--===1){const{worker:s,objectURL:o}=t;delete Ja[h||Ls],o&&self.URL.revokeObjectURL(o),s.terminate()}}function hc(h,t){return t+10<=h.length&&h[t]===51&&h[t+1]===68&&h[t+2]===73&&h[t+3]<255&&h[t+4]<255&&h[t+6]<128&&h[t+7]<128&&h[t+8]<128&&h[t+9]<128}function Ql(h,t){return t+10<=h.length&&h[t]===73&&h[t+1]===68&&h[t+2]===51&&h[t+3]<255&&h[t+4]<255&&h[t+6]<128&&h[t+7]<128&&h[t+8]<128&&h[t+9]<128}function cl(h,t){let n=0;return n=(h[t]&127)<<21,n|=(h[t+1]&127)<<14,n|=(h[t+2]&127)<<7,n|=h[t+3]&127,n}function ka(h,t){const n=t;let s=0;for(;Ql(h,t);){s+=10;const o=cl(h,t+6);s+=o,hc(h,t+10)&&(s+=10),t+=s}if(s>0)return h.subarray(n,n+s)}function wh(h,t,n,s){const o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],l=t[n+2],c=l>>2&15;if(c>12){const D=new Error(`invalid ADTS sampling index:${c}`);h.emit(S.ERROR,S.ERROR,{type:ge.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!0,error:D,reason:D.message});return}const f=(l>>6&3)+1,_=t[n+3]>>6&3|(l&1)<<2,m="mp4a.40."+f,v=o[c];let y=c;(f===5||f===29)&&(y-=3);const x=[f<<3|(y&14)>>1,(y&1)<<7|_<<3];return re.log(`manifest codec:${s}, parsed codec:${m}, channels:${_}, rate:${v} (ADTS object type:${f} sampling index:${c})`),{config:x,samplerate:v,channelCount:_,codec:m,parsedCodec:m,manifestCodec:s}}function fc(h,t){return h[t]===255&&(h[t+1]&246)===240}function eu(h,t){return h[t+1]&1?7:9}function hl(h,t){return(h[t+3]&3)<<11|h[t+4]<<3|(h[t+5]&224)>>>5}function js(h,t){return t+5<h.length}function Mo(h,t){return t+1<h.length&&fc(h,t)}function dc(h,t){return js(h,t)&&fc(h,t)&&hl(h,t)<=h.length-t}function Sh(h,t){if(Mo(h,t)){const n=eu(h,t);if(t+n>=h.length)return!1;const s=hl(h,t);if(s<=n)return!1;const o=t+s;return o===h.length||Mo(h,o)}return!1}function pc(h,t,n,s,o){if(!h.samplerate){const l=wh(t,n,s,o);if(!l)return;k(h,l)}}function mc(h){return 1024*9e4/h}function Eh(h,t){const n=eu(h,t);if(t+n<=h.length){const s=hl(h,t)-n;if(s>0)return{headerLength:n,frameLength:s}}}function tu(h,t,n,s,o){const l=mc(h.samplerate),c=s+o*l,f=Eh(t,n);let _;if(f){const{frameLength:y,headerLength:x}=f,D=x+y,C=Math.max(0,n+D-t.length);C?(_=new Uint8Array(D-x),_.set(t.subarray(n+x,t.length),0)):_=t.subarray(n+x,n+D);const B={unit:_,pts:c};return C||h.samples.push(B),{sample:B,length:D,missing:C}}const m=t.length-n;return _=new Uint8Array(m),_.set(t.subarray(n,t.length),0),{sample:{unit:_,pts:c},length:m,missing:-1}}function kh(h,t){return Ql(h,t)&&cl(h,t+6)+10<=h.length-t}function Th(h){return h instanceof ArrayBuffer?h:h.byteOffset==0&&h.byteLength==h.buffer.byteLength?h.buffer:new Uint8Array(h).buffer}function iu(h,t=0,n=1/0){return Ah(h,t,n,Uint8Array)}function Ah(h,t,n,s){const o=Lh(h);let l=1;"BYTES_PER_ELEMENT"in s&&(l=s.BYTES_PER_ELEMENT);const c=Dh(h)?h.byteOffset:0,f=(c+h.byteLength)/l,_=(c+t)/l,m=Math.floor(Math.max(0,Math.min(_,f))),v=Math.floor(Math.min(m+Math.max(n,0),f));return new s(o,m,v-m)}function Lh(h){return h instanceof ArrayBuffer?h:h.buffer}function Dh(h){return h&&h.buffer instanceof ArrayBuffer&&h.byteLength!==void 0&&h.byteOffset!==void 0}function qs(h){const t={key:h.type,description:"",data:"",mimeType:null,pictureType:null},n=3;if(h.size<2)return;if(h.data[0]!==n){console.log("Ignore frame with unrecognized character encoding");return}const s=h.data.subarray(1).indexOf(0);if(s===-1)return;const o=Dt(iu(h.data,1,s)),l=h.data[2+s],c=h.data.subarray(3+s).indexOf(0);if(c===-1)return;const f=Dt(iu(h.data,3+s,c));let _;return o==="-->"?_=Dt(iu(h.data,4+s+c)):_=Th(h.data.subarray(4+s+c)),t.mimeType=o,t.pictureType=l,t.description=f,t.data=_,t}function gc(h){if(h.size<2)return;const t=Dt(h.data,!0),n=new Uint8Array(h.data.subarray(t.length+1));return{key:h.type,info:t,data:n.buffer}}function oa(h){if(h.size<2)return;if(h.type==="TXXX"){let n=1;const s=Dt(h.data.subarray(n),!0);n+=s.length+1;const o=Dt(h.data.subarray(n));return{key:h.type,info:s,data:o}}const t=Dt(h.data.subarray(1));return{key:h.type,info:"",data:t}}function Ch(h){if(h.type==="WXXX"){if(h.size<2)return;let n=1;const s=Dt(h.data.subarray(n),!0);n+=s.length+1;const o=Dt(h.data.subarray(n));return{key:h.type,info:s,data:o}}const t=Dt(h.data);return{key:h.type,info:"",data:t}}function _c(h){return h.type==="PRIV"?gc(h):h.type[0]==="W"?Ch(h):h.type==="APIC"?qs(h):oa(h)}function vc(h){const t=String.fromCharCode(h[0],h[1],h[2],h[3]),n=cl(h,4),s=10;return{type:t,size:n,data:h.subarray(s,s+n)}}const fl=10,yc=10;function bc(h){let t=0;const n=[];for(;Ql(h,t);){const s=cl(h,t+6);h[t+5]>>6&1&&(t+=fl),t+=fl;const o=t+s;for(;t+yc<o;){const l=vc(h.subarray(t)),c=_c(l);c&&n.push(c),t+=l.size+fl}hc(h,t)&&(t+=fl)}return n}function xc(h){return h&&h.key==="PRIV"&&h.info==="com.apple.streaming.transportStreamTimestamp"}function Mh(h){if(h.data.byteLength===8){const t=new Uint8Array(h.data),n=t[3]&1;let s=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return s/=45,n&&(s+=4772185884e-2),Math.round(s)}}function nu(h){const t=bc(h);for(let n=0;n<t.length;n++){const s=t[n];if(xc(s))return Mh(s)}}let ms=function(h){return h.audioId3="org.id3",h.dateRange="com.apple.quicktime.HLS",h.emsg="https://aomedia.org/emsg/ID3",h.misbklv="urn:misb:KLV:bin:1910.1",h}({});function Ns(h="",t=9e4){return{type:h,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class ru{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(t,n,s,o){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,n){return!1}appendFrame(t,n,s){}demux(t,n){this.cachedData&&(t=ht(this.cachedData,t),this.cachedData=null);let s=ka(t,0),o=s?s.length:0,l;const c=this._audioTrack,f=this._id3Track,_=s?nu(s):void 0,m=t.length;for((this.basePTS===null||this.frameIndex===0&&ce(_))&&(this.basePTS=Rh(_,n,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),s&&s.length>0&&f.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:ms.audioId3,duration:Number.POSITIVE_INFINITY});o<m;){if(this.canParse(t,o)){const v=this.appendFrame(c,t,o);v?(this.frameIndex++,this.lastPTS=v.sample.pts,o+=v.length,l=o):o=m}else kh(t,o)?(s=ka(t,o),f.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:ms.audioId3,duration:Number.POSITIVE_INFINITY}),o+=s.length,l=o):o++;if(o===m&&l!==m){const v=t.slice(l);this.cachedData?this.cachedData=ht(this.cachedData,v):this.cachedData=v}}return{audioTrack:c,videoTrack:Ns(),id3Track:f,textTrack:Ns()}}demuxSampleAes(t,n,s){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(t){const n=this.cachedData;return n&&(this.cachedData=null,this.demux(n,0)),{audioTrack:this._audioTrack,videoTrack:Ns(),id3Track:this._id3Track,textTrack:Ns()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const Rh=(h,t,n)=>{if(ce(h))return h*90;const s=n?n.baseTime*9e4/n.timescale:0;return t*9e4+s};let dl=null;const su=[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],Ih=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Ph=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Oh=[0,1,1,4];function wc(h,t,n,s,o){if(n+24>t.length)return;const l=Sc(t,n);if(l&&n+l.frameLength<=t.length){const c=l.samplesPerFrame*9e4/l.sampleRate,f=s+o*c,_={unit:t.subarray(n,n+l.frameLength),pts:f,dts:f};return h.config=[],h.channelCount=l.channelCount,h.samplerate=l.sampleRate,h.samples.push(_),{sample:_,length:l.frameLength,missing:0}}}function Sc(h,t){const n=h[t+1]>>3&3,s=h[t+1]>>1&3,o=h[t+2]>>4&15,l=h[t+2]>>2&3;if(n!==1&&o!==0&&o!==15&&l!==3){const c=h[t+2]>>1&1,f=h[t+3]>>6,_=n===3?3-s:s===3?3:4,m=su[_*14+o-1]*1e3,y=Ih[(n===3?0:n===2?1:2)*3+l],x=f===3?1:2,D=Ph[n][s],C=Oh[s],B=D*8*C,F=Math.floor(D*m/y+c)*C;if(dl===null){const le=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);dl=le?parseInt(le[1]):0}return!!dl&&dl<=87&&s===2&&m>=224e3&&f===0&&(h[t+3]=h[t+3]|128),{sampleRate:y,channelCount:x,frameLength:F,samplesPerFrame:B}}}function Ta(h,t){return h[t]===255&&(h[t+1]&224)===224&&(h[t+1]&6)!==0}function Qa(h,t){return t+1<h.length&&Ta(h,t)}function Ec(h,t){return Ta(h,t)&&4<=h.length-t}function kc(h,t){if(t+1<h.length&&Ta(h,t)){const s=Sc(h,t);let o=4;s!=null&&s.frameLength&&(o=s.frameLength);const l=t+o;return l===h.length||Qa(h,l)}return!1}class Fh extends ru{constructor(t,n){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=n}resetInitSegment(t,n,s,o){super.resetInitSegment(t,n,s,o),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:n,duration:o,inputTimeScale:9e4,dropped:0}}static probe(t,n){if(!t)return!1;const s=ka(t,0);let o=(s==null?void 0:s.length)||0;if(kc(t,o))return!1;for(let l=t.length;o<l;o++)if(Sh(t,o))return n.log("ADTS sync word found !"),!0;return!1}canParse(t,n){return dc(t,n)}appendFrame(t,n,s){pc(t,this.observer,n,s,t.manifestCodec);const o=tu(t,n,s,this.basePTS,this.frameIndex);if(o&&o.missing===0)return o}}const Tc=(h,t)=>{let n=0,s=5;t+=s;const o=new Uint32Array(1),l=new Uint32Array(1),c=new Uint8Array(1);for(;s>0;){c[0]=h[t];const f=Math.min(s,8),_=8-f;l[0]=4278190080>>>24+_<<_,o[0]=(c[0]&l[0])>>_,n=n?n<<f|o[0]:o[0],t+=1,s-=f}return n};class Bh extends ru{constructor(t){super(),this.observer=void 0,this.observer=t}resetInitSegment(t,n,s,o){super.resetInitSegment(t,n,s,o),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:n,duration:o,inputTimeScale:9e4,dropped:0}}canParse(t,n){return n+64<t.length}appendFrame(t,n,s){const o=pl(t,n,s,this.basePTS,this.frameIndex);if(o!==-1)return{sample:t.samples[t.samples.length-1],length:o,missing:0}}static probe(t){if(!t)return!1;const n=ka(t,0);if(!n)return!1;const s=n.length;return t[s]===11&&t[s+1]===119&&nu(n)!==void 0&&Tc(t,s)<16}}function pl(h,t,n,s,o){if(n+8>t.length||t[n]!==11||t[n+1]!==119)return-1;const l=t[n+4]>>6;if(l>=3)return-1;const f=[48e3,44100,32e3][l],_=t[n+4]&63,v=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][_*3+l]*2;if(n+v>t.length)return-1;const y=t[n+6]>>5;let x=0;y===2?x+=2:(y&1&&y!==1&&(x+=2),y&4&&(x+=2));const D=(t[n+6]<<8|t[n+7])>>12-x&1,B=[2,1,2,3,3,4,4,5][y]+D,F=t[n+5]>>3,Q=t[n+5]&7,se=new Uint8Array([l<<6|F<<1|Q>>2,(Q&3)<<6|y<<3|D<<2|_>>4,_<<4&224]),le=1536/f*9e4,Ee=s+o*le,Ie=t.subarray(n,n+v);return h.config=se,h.channelCount=B,h.samplerate=f,h.samples.push({unit:Ie,pts:Ee}),v}class Nh extends ru{resetInitSegment(t,n,s,o){super.resetInitSegment(t,n,s,o),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:n,duration:o,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;const n=ka(t,0);let s=(n==null?void 0:n.length)||0;if(n&&t[s]===11&&t[s+1]===119&&nu(n)!==void 0&&Tc(t,s)<=16)return!1;for(let o=t.length;s<o;s++)if(kc(t,s))return re.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,n){return Ec(t,n)}appendFrame(t,n,s){if(this.basePTS!==null)return wc(t,n,s,this.basePTS,this.frameIndex)}}const $h=/\/emsg[-/]ID3/i;class Kh{constructor(t,n){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=n}resetTimeStamp(){}resetInitSegment(t,n,s,o){const l=this.videoTrack=Ns("video",1),c=this.audioTrack=Ns("audio",1),f=this.txtTrack=Ns("text",1);if(this.id3Track=Ns("id3",1),this.timeOffset=0,!(t!=null&&t.byteLength))return;const _=_t(t);if(_.video){const{id:m,timescale:v,codec:y,supplemental:x}=_.video;l.id=m,l.timescale=f.timescale=v,l.codec=y,l.supplemental=x}if(_.audio){const{id:m,timescale:v,codec:y}=_.audio;c.id=m,c.timescale=v,c.codec=y}f.id=Ti.text,l.sampleDuration=0,l.duration=c.duration=o}resetContiguity(){this.remainderData=null}static probe(t){return Ge(t)}demux(t,n){this.timeOffset=n;let s=t;const o=this.videoTrack,l=this.txtTrack;if(this.config.progressive){this.remainderData&&(s=ht(this.remainderData,t));const f=ke(s);this.remainderData=f.remainder,o.samples=f.valid||new Uint8Array}else o.samples=s;const c=this.extractID3Track(o,n);return l.samples=Gt(n,o),{videoTrack:o,audioTrack:this.audioTrack,id3Track:c,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,n=this.videoTrack,s=this.txtTrack;n.samples=this.remainderData||new Uint8Array,this.remainderData=null;const o=this.extractID3Track(n,this.timeOffset);return s.samples=Gt(t,n),{videoTrack:n,audioTrack:Ns(),id3Track:o,textTrack:Ns()}}extractID3Track(t,n){const s=this.id3Track;if(t.samples.length){const o=ve(t.samples,["emsg"]);o&&o.forEach(l=>{const c=ft(l);if($h.test(c.schemeIdUri)){const f=eo(c,n);let _=c.eventDuration===4294967295?Number.POSITIVE_INFINITY:c.eventDuration/c.timeScale;_<=.001&&(_=Number.POSITIVE_INFINITY);const m=c.payload;s.samples.push({data:m,len:m.byteLength,dts:f,pts:f,type:ms.emsg,duration:_})}else if(this.config.enableEmsgKLVMetadata&&c.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const f=eo(c,n);s.samples.push({data:c.payload,len:c.payload.byteLength,dts:f,pts:f,type:ms.misbklv,duration:Number.POSITIVE_INFINITY})}})}return s}demuxSampleAes(t,n,s){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}function eo(h,t){return ce(h.presentationTime)?h.presentationTime/h.timeScale:t+h.presentationTimeDelta/h.timeScale}class au{constructor(t,n,s){this.keyData=void 0,this.decrypter=void 0,this.keyData=s,this.decrypter=new Mn(n,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer,On.cbc)}decryptAacSample(t,n,s){const o=t[n].unit;if(o.length<=16)return;const l=o.subarray(16,o.length-o.length%16),c=l.buffer.slice(l.byteOffset,l.byteOffset+l.length);this.decryptBuffer(c).then(f=>{const _=new Uint8Array(f);o.set(_,16),this.decrypter.isSync()||this.decryptAacSamples(t,n+1,s)}).catch(s)}decryptAacSamples(t,n,s){for(;;n++){if(n>=t.length){s();return}if(!(t[n].unit.length<32)&&(this.decryptAacSample(t,n,s),!this.decrypter.isSync()))return}}getAvcEncryptedData(t){const n=Math.floor((t.length-48)/160)*16+16,s=new Int8Array(n);let o=0;for(let l=32;l<t.length-16;l+=160,o+=16)s.set(t.subarray(l,l+16),o);return s}getAvcDecryptedUnit(t,n){const s=new Uint8Array(n);let o=0;for(let l=32;l<t.length-16;l+=160,o+=16)t.set(s.subarray(o,o+16),l);return t}decryptAvcSample(t,n,s,o,l){const c=tt(l.data),f=this.getAvcEncryptedData(c);this.decryptBuffer(f.buffer).then(_=>{l.data=this.getAvcDecryptedUnit(c,_),this.decrypter.isSync()||this.decryptAvcSamples(t,n,s+1,o)}).catch(o)}decryptAvcSamples(t,n,s,o){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;n++,s=0){if(n>=t.length){o();return}const l=t[n].units;for(;!(s>=l.length);s++){const c=l[s];if(!(c.data.length<=48||c.type!==1&&c.type!==5)&&(this.decryptAvcSample(t,n,s,o,c),!this.decrypter.isSync()))return}}}}class Ac{constructor(){this.VideoSample=null}createVideoSample(t,n,s){return{key:t,frame:!1,pts:n,dts:s,units:[],length:0}}getLastNalUnit(t){var n;let s=this.VideoSample,o;if((!s||s.units.length===0)&&(s=t[t.length-1]),(n=s)!=null&&n.units){const l=s.units;o=l[l.length-1]}return o}pushAccessUnit(t,n){if(t.units.length&&t.frame){if(t.pts===void 0){const s=n.samples,o=s.length;if(o){const l=s[o-1];t.pts=l.pts,t.dts=l.dts}else{n.dropped++;return}}n.samples.push(t)}}parseNALu(t,n,s){const o=n.byteLength;let l=t.naluState||0;const c=l,f=[];let _=0,m,v,y,x=-1,D=0;for(l===-1&&(x=0,D=this.getNALuType(n,0),l=0,_=1);_<o;){if(m=n[_++],!l){l=m?0:1;continue}if(l===1){l=m?0:2;continue}if(!m)l=3;else if(m===1){if(v=_-l-1,x>=0){const C={data:n.subarray(x,v),type:D};f.push(C)}else{const C=this.getLastNalUnit(t.samples);C&&(c&&_<=4-c&&C.state&&(C.data=C.data.subarray(0,C.data.byteLength-c)),v>0&&(C.data=ht(C.data,n.subarray(0,v)),C.state=0))}_<o?(y=this.getNALuType(n,_),x=_,D=y,l=0):l=-1}else l=0}if(x>=0&&l>=0){const C={data:n.subarray(x,o),type:D,state:l};f.push(C)}if(f.length===0){const C=this.getLastNalUnit(t.samples);C&&(C.data=ht(C.data,n))}return t.naluState=l,f}}class to{constructor(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const t=this.data,n=this.bytesAvailable,s=t.byteLength-n,o=new Uint8Array(4),l=Math.min(4,n);if(l===0)throw new Error("no bytes available");o.set(t.subarray(s,s+l)),this.word=new DataView(o.buffer).getUint32(0),this.bitsAvailable=l*8,this.bytesAvailable-=l}skipBits(t){let n;t=Math.min(t,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,n=t>>3,t-=n<<3,this.bytesAvailable-=n,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)}readBits(t){let n=Math.min(this.bitsAvailable,t);const s=this.word>>>32-n;if(t>32&&re.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=n,this.bitsAvailable>0)this.word<<=n;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return n=t-n,n>0&&this.bitsAvailable?s<<n|this.readBits(n):s}skipLZ(){let t;for(t=0;t<this.bitsAvailable;++t)if(this.word&2147483648>>>t)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const t=this.skipLZ();return this.readBits(t+1)-1}readEG(){const t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class Uh extends Ac{parsePES(t,n,s,o){const l=this.parseNALu(t,s.data,o);let c=this.VideoSample,f,_=!1;s.data=null,c&&l.length&&!t.audFound&&(this.pushAccessUnit(c,t),c=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts)),l.forEach(m=>{var v,y;switch(m.type){case 1:{let B=!1;f=!0;const F=m.data;if(_&&F.length>4){const Q=this.readSliceType(F);(Q===2||Q===4||Q===7||Q===9)&&(B=!0)}if(B){var x;(x=c)!=null&&x.frame&&!c.key&&(this.pushAccessUnit(c,t),c=this.VideoSample=null)}c||(c=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),c.frame=!0,c.key=B;break}case 5:f=!0,(v=c)!=null&&v.frame&&!c.key&&(this.pushAccessUnit(c,t),c=this.VideoSample=null),c||(c=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),c.key=!0,c.frame=!0;break;case 6:{f=!0,Me(m.data,1,s.pts,n.samples);break}case 7:{var D,C;f=!0,_=!0;const B=m.data,F=this.readSPS(B);if(!t.sps||t.width!==F.width||t.height!==F.height||((D=t.pixelRatio)==null?void 0:D[0])!==F.pixelRatio[0]||((C=t.pixelRatio)==null?void 0:C[1])!==F.pixelRatio[1]){t.width=F.width,t.height=F.height,t.pixelRatio=F.pixelRatio,t.sps=[B];const Q=B.subarray(1,4);let se="avc1.";for(let le=0;le<3;le++){let Ee=Q[le].toString(16);Ee.length<2&&(Ee="0"+Ee),se+=Ee}t.codec=se}break}case 8:f=!0,t.pps=[m.data];break;case 9:f=!0,t.audFound=!0,(y=c)!=null&&y.frame&&(this.pushAccessUnit(c,t),c=null),c||(c=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts));break;case 12:f=!0;break;default:f=!1;break}c&&f&&c.units.push(m)}),o&&c&&(this.pushAccessUnit(c,t),this.VideoSample=null)}getNALuType(t,n){return t[n]&31}readSliceType(t){const n=new to(t);return n.readUByte(),n.readUEG(),n.readUEG()}skipScalingList(t,n){let s=8,o=8,l;for(let c=0;c<t;c++)o!==0&&(l=n.readEG(),o=(s+l+256)%256),s=o===0?s:o}readSPS(t){const n=new to(t);let s=0,o=0,l=0,c=0,f,_,m;const v=n.readUByte.bind(n),y=n.readBits.bind(n),x=n.readUEG.bind(n),D=n.readBoolean.bind(n),C=n.skipBits.bind(n),B=n.skipEG.bind(n),F=n.skipUEG.bind(n),Q=this.skipScalingList.bind(this);v();const se=v();if(y(5),C(3),v(),F(),se===100||se===110||se===122||se===244||se===44||se===83||se===86||se===118||se===128){const Ze=x();if(Ze===3&&C(1),F(),F(),C(1),D())for(_=Ze!==3?8:12,m=0;m<_;m++)D()&&(m<6?Q(16,n):Q(64,n))}F();const le=x();if(le===0)x();else if(le===1)for(C(1),B(),B(),f=x(),m=0;m<f;m++)B();F(),C(1);const Ee=x(),Ie=x(),Qe=y(1);Qe===0&&C(1),C(1),D()&&(s=x(),o=x(),l=x(),c=x());let Pe=[1,1];if(D()&&D())switch(v()){case 1:Pe=[1,1];break;case 2:Pe=[12,11];break;case 3:Pe=[10,11];break;case 4:Pe=[16,11];break;case 5:Pe=[40,33];break;case 6:Pe=[24,11];break;case 7:Pe=[20,11];break;case 8:Pe=[32,11];break;case 9:Pe=[80,33];break;case 10:Pe=[18,11];break;case 11:Pe=[15,11];break;case 12:Pe=[64,33];break;case 13:Pe=[160,99];break;case 14:Pe=[4,3];break;case 15:Pe=[3,2];break;case 16:Pe=[2,1];break;case 255:{Pe=[v()<<8|v(),v()<<8|v()];break}}return{width:Math.ceil((Ee+1)*16-s*2-o*2),height:(2-Qe)*(Ie+1)*16-(Qe?2:4)*(l+c),pixelRatio:Pe}}}class zh extends Ac{constructor(...t){super(...t),this.initVPS=null}parsePES(t,n,s,o){const l=this.parseNALu(t,s.data,o);let c=this.VideoSample,f,_=!1;s.data=null,c&&l.length&&!t.audFound&&(this.pushAccessUnit(c,t),c=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts)),l.forEach(m=>{var v,y;switch(m.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:c||(c=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts)),c.frame=!0,f=!0;break;case 16:case 17:case 18:case 21:if(f=!0,_){var x;(x=c)!=null&&x.frame&&!c.key&&(this.pushAccessUnit(c,t),c=this.VideoSample=null)}c||(c=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),c.key=!0,c.frame=!0;break;case 19:case 20:f=!0,(v=c)!=null&&v.frame&&!c.key&&(this.pushAccessUnit(c,t),c=this.VideoSample=null),c||(c=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),c.key=!0,c.frame=!0;break;case 39:f=!0,Me(m.data,2,s.pts,n.samples);break;case 32:f=!0,t.vps||(typeof t.params!="object"&&(t.params={}),t.params=k(t.params,this.readVPS(m.data)),this.initVPS=m.data),t.vps=[m.data];break;case 33:if(f=!0,_=!0,t.vps!==void 0&&t.vps[0]!==this.initVPS&&t.sps!==void 0&&!this.matchSPS(t.sps[0],m.data)&&(this.initVPS=t.vps[0],t.sps=t.pps=void 0),!t.sps){const D=this.readSPS(m.data);t.width=D.width,t.height=D.height,t.pixelRatio=D.pixelRatio,t.codec=D.codecString,t.sps=[],typeof t.params!="object"&&(t.params={});for(const C in D.params)t.params[C]=D.params[C]}this.pushParameterSet(t.sps,m.data,t.vps),c||(c=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),c.key=!0;break;case 34:if(f=!0,typeof t.params=="object"){if(!t.pps){t.pps=[];const D=this.readPPS(m.data);for(const C in D)t.params[C]=D[C]}this.pushParameterSet(t.pps,m.data,t.vps)}break;case 35:f=!0,t.audFound=!0,(y=c)!=null&&y.frame&&(this.pushAccessUnit(c,t),c=null),c||(c=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts));break;default:f=!1;break}c&&f&&c.units.push(m)}),o&&c&&(this.pushAccessUnit(c,t),this.VideoSample=null)}pushParameterSet(t,n,s){(s&&s[0]===this.initVPS||!s&&!t.length)&&t.push(n)}getNALuType(t,n){return(t[n]&126)>>>1}ebsp2rbsp(t){const n=new Uint8Array(t.byteLength);let s=0;for(let o=0;o<t.byteLength;o++)o>=2&&t[o]===3&&t[o-1]===0&&t[o-2]===0||(n[s]=t[o],s++);return new Uint8Array(n.buffer,0,s)}pushAccessUnit(t,n){super.pushAccessUnit(t,n),this.initVPS&&(this.initVPS=null)}readVPS(t){const n=new to(t);n.readUByte(),n.readUByte(),n.readBits(4),n.skipBits(2),n.readBits(6);const s=n.readBits(3),o=n.readBoolean();return{numTemporalLayers:s+1,temporalIdNested:o}}readSPS(t){const n=new to(this.ebsp2rbsp(t));n.readUByte(),n.readUByte(),n.readBits(4);const s=n.readBits(3);n.readBoolean();const o=n.readBits(2),l=n.readBoolean(),c=n.readBits(5),f=n.readUByte(),_=n.readUByte(),m=n.readUByte(),v=n.readUByte(),y=n.readUByte(),x=n.readUByte(),D=n.readUByte(),C=n.readUByte(),B=n.readUByte(),F=n.readUByte(),Q=n.readUByte(),se=[],le=[];for(let An=0;An<s;An++)se.push(n.readBoolean()),le.push(n.readBoolean());if(s>0)for(let An=s;An<8;An++)n.readBits(2);for(let An=0;An<s;An++)se[An]&&(n.readUByte(),n.readUByte(),n.readUByte(),n.readUByte(),n.readUByte(),n.readUByte(),n.readUByte(),n.readUByte(),n.readUByte(),n.readUByte(),n.readUByte()),le[An]&&n.readUByte();n.readUEG();const Ee=n.readUEG();Ee==3&&n.skipBits(1);const Ie=n.readUEG(),Qe=n.readUEG(),Pe=n.readBoolean();let Ze=0,He=0,Fe=0,bt=0;Pe&&(Ze+=n.readUEG(),He+=n.readUEG(),Fe+=n.readUEG(),bt+=n.readUEG());const Xt=n.readUEG(),ci=n.readUEG(),yi=n.readUEG(),li=n.readBoolean();for(let An=li?0:s;An<=s;An++)n.skipUEG(),n.skipUEG(),n.skipUEG();if(n.skipUEG(),n.skipUEG(),n.skipUEG(),n.skipUEG(),n.skipUEG(),n.skipUEG(),n.readBoolean()&&n.readBoolean())for(let lr=0;lr<4;lr++)for(let ur=0;ur<(lr===3?2:6);ur++)if(!n.readBoolean())n.readUEG();else{const is=Math.min(64,1<<4+(lr<<1));lr>1&&n.readEG();for(let jo=0;jo<is;jo++)n.readEG()}n.readBoolean(),n.readBoolean(),n.readBoolean()&&(n.readUByte(),n.skipUEG(),n.skipUEG(),n.readBoolean());const si=n.readUEG();let xi=0;for(let An=0;An<si;An++){let lr=!1;if(An!==0&&(lr=n.readBoolean()),lr){An===si&&n.readUEG(),n.readBoolean(),n.readUEG();let ur=0;for(let ma=0;ma<=xi;ma++){const is=n.readBoolean();let jo=!1;is||(jo=n.readBoolean()),(is||jo)&&ur++}xi=ur}else{const ur=n.readUEG(),ma=n.readUEG();xi=ur+ma;for(let is=0;is<ur;is++)n.readUEG(),n.readBoolean();for(let is=0;is<ma;is++)n.readUEG(),n.readBoolean()}}if(n.readBoolean()){const An=n.readUEG();for(let lr=0;lr<An;lr++){for(let ur=0;ur<yi+4;ur++)n.readBits(1);n.readBits(1)}}let qt=0,Zt=1,qi=1,In=!0,an=1,Vi=0;n.readBoolean(),n.readBoolean();let ts=!1;if(n.readBoolean()){if(n.readBoolean()){const vo=n.readUByte(),Ff=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],ju=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];vo>0&&vo<16?(Zt=Ff[vo-1],qi=ju[vo-1]):vo===255&&(Zt=n.readBits(16),qi=n.readBits(16))}if(n.readBoolean()&&n.readBoolean(),n.readBoolean()&&(n.readBits(3),n.readBoolean(),n.readBoolean()&&(n.readUByte(),n.readUByte(),n.readUByte())),n.readBoolean()&&(n.readUEG(),n.readUEG()),n.readBoolean(),n.readBoolean(),n.readBoolean(),ts=n.readBoolean(),ts&&(n.skipUEG(),n.skipUEG(),n.skipUEG(),n.skipUEG()),n.readBoolean()&&(an=n.readBits(32),Vi=n.readBits(32),n.readBoolean()&&n.readUEG(),n.readBoolean())){const ju=n.readBoolean(),Fl=n.readBoolean();let yo=!1;(ju||Fl)&&(yo=n.readBoolean(),yo&&(n.readUByte(),n.readBits(5),n.readBoolean(),n.readBits(5)),n.readBits(4),n.readBits(4),yo&&n.readBits(4),n.readBits(5),n.readBits(5),n.readBits(5));for(let Bf=0;Bf<=s;Bf++){In=n.readBoolean();const Nf=In||n.readBoolean();let Bl=!1;Nf?n.readEG():Bl=n.readBoolean();const qo=Bl?1:n.readUEG()+1;if(ju)for(let Zo=0;Zo<qo;Zo++)n.readUEG(),n.readUEG(),yo&&(n.readUEG(),n.readUEG()),n.skipBits(1);if(Fl)for(let Zo=0;Zo<qo;Zo++)n.readUEG(),n.readUEG(),yo&&(n.readUEG(),n.readUEG()),n.skipBits(1)}}n.readBoolean()&&(n.readBoolean(),n.readBoolean(),n.readBoolean(),qt=n.readUEG())}let Is=Ie,wn=Qe;if(Pe){let An=1,lr=1;Ee===1?An=lr=2:Ee==2&&(An=2),Is=Ie-An*He-An*Ze,wn=Qe-lr*bt-lr*Fe}const _o=o?["A","B","C"][o]:"",Of=f<<24|_<<16|m<<8|v;let pa=0;for(let An=0;An<32;An++)pa=(pa|(Of>>An&1)<<31-An)>>>0;let Wo=pa.toString(16);return c===1&&Wo==="2"&&(Wo="6"),{codecString:`hvc1.${_o}${c}.${Wo}.${l?"H":"L"}${Q}.B0`,params:{general_tier_flag:l,general_profile_idc:c,general_profile_space:o,general_profile_compatibility_flags:[f,_,m,v],general_constraint_indicator_flags:[y,x,D,C,B,F],general_level_idc:Q,bit_depth:Xt+8,bit_depth_luma_minus8:Xt,bit_depth_chroma_minus8:ci,min_spatial_segmentation_idc:qt,chroma_format_idc:Ee,frame_rate:{fixed:In,fps:Vi/an}},width:Is,height:wn,pixelRatio:[Zt,qi]}}readPPS(t){const n=new to(this.ebsp2rbsp(t));n.readUByte(),n.readUByte(),n.skipUEG(),n.skipUEG(),n.skipBits(2),n.skipBits(3),n.skipBits(2),n.skipUEG(),n.skipUEG(),n.skipEG(),n.skipBits(2),n.readBoolean()&&n.skipUEG(),n.skipEG(),n.skipEG(),n.skipBits(4);const o=n.readBoolean(),l=n.readBoolean();let c=1;return l&&o?c=0:l?c=3:o&&(c=2),{parallelismType:c}}matchSPS(t,n){return String.fromCharCode.apply(null,t).substr(3)===String.fromCharCode.apply(null,n).substr(3)}}const Pr=188;class $s{constructor(t,n,s,o){this.logger=void 0,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._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=t,this.config=n,this.typeSupported=s,this.logger=o,this.videoParser=null}static probe(t,n){const s=$s.syncOffset(t);return s>0&&n.warn(`MPEG2-TS detected but first sync word found @ offset ${s}`),s!==-1}static syncOffset(t){const n=t.length;let s=Math.min(Pr*5,n-Pr)+1,o=0;for(;o<s;){let l=!1,c=-1,f=0;for(let _=o;_<n;_+=Pr)if(t[_]===71&&(n-_===Pr||t[_+Pr]===71)){if(f++,c===-1&&(c=_,c!==0&&(s=Math.min(c+Pr*99,t.length-Pr)+1)),l||(l=Ro(t,_)===0),l&&f>1&&(c===0&&f>2||_+Pr>s))return c}else{if(f)return-1;break}o++}return-1}static createTrack(t,n){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:Ti[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?n:void 0}}resetInitSegment(t,n,s,o){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=$s.createTrack("video"),this._videoTrack.duration=o,this._audioTrack=$s.createTrack("audio",o),this._id3Track=$s.createTrack("id3"),this._txtTrack=$s.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=n,this.videoCodec=s}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_videoTrack:n,_id3Track:s}=this;t&&(t.pesData=null),n&&(n.pesData=null),s&&(s.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(t,n,s=!1,o=!1){s||(this.sampleAes=null);let l;const c=this._videoTrack,f=this._audioTrack,_=this._id3Track,m=this._txtTrack;let v=c.pid,y=c.pesData,x=f.pid,D=_.pid,C=f.pesData,B=_.pesData,F=null,Q=this.pmtParsed,se=this._pmtId,le=t.length;if(this.remainderData&&(t=ht(this.remainderData,t),le=t.length,this.remainderData=null),le<Pr&&!o)return this.remainderData=t,{audioTrack:f,videoTrack:c,id3Track:_,textTrack:m};const Ee=Math.max(0,$s.syncOffset(t));le-=(le-Ee)%Pr,le<t.byteLength&&!o&&(this.remainderData=new Uint8Array(t.buffer,le,t.buffer.byteLength-le));let Ie=0;for(let Pe=Ee;Pe<le;Pe+=Pr)if(t[Pe]===71){const Ze=!!(t[Pe+1]&64),He=Ro(t,Pe),Fe=(t[Pe+3]&48)>>4;let bt;if(Fe>1){if(bt=Pe+5+t[Pe+4],bt===Pe+Pr)continue}else bt=Pe+4;switch(He){case v:Ze&&(y&&(l=la(y,this.logger))&&(this.readyVideoParser(c.segmentCodec),this.videoParser!==null&&this.videoParser.parsePES(c,m,l,!1)),y={data:[],size:0}),y&&(y.data.push(t.subarray(bt,Pe+Pr)),y.size+=Pe+Pr-bt);break;case x:if(Ze){if(C&&(l=la(C,this.logger)))switch(f.segmentCodec){case"aac":this.parseAACPES(f,l);break;case"mp3":this.parseMPEGPES(f,l);break;case"ac3":this.parseAC3PES(f,l);break}C={data:[],size:0}}C&&(C.data.push(t.subarray(bt,Pe+Pr)),C.size+=Pe+Pr-bt);break;case D:Ze&&(B&&(l=la(B,this.logger))&&this.parseID3PES(_,l),B={data:[],size:0}),B&&(B.data.push(t.subarray(bt,Pe+Pr)),B.size+=Pe+Pr-bt);break;case 0:Ze&&(bt+=t[bt]+1),se=this._pmtId=ou(t,bt);break;case se:{Ze&&(bt+=t[bt]+1);const Xt=Vh(t,bt,this.typeSupported,s,this.observer,this.logger);v=Xt.videoPid,v>0&&(c.pid=v,c.segmentCodec=Xt.segmentVideoCodec),x=Xt.audioPid,x>0&&(f.pid=x,f.segmentCodec=Xt.segmentAudioCodec),D=Xt.id3Pid,D>0&&(_.pid=D),F!==null&&!Q&&(this.logger.warn(`MPEG-TS PMT found at ${Pe} after unknown PID '${F}'. Backtracking to sync byte @${Ee} to parse all TS packets.`),F=null,Pe=Ee-188),Q=this.pmtParsed=!0;break}case 17:case 8191:break;default:F=He;break}}else Ie++;Ie>0&&lu(this.observer,new Error(`Found ${Ie} TS packet/s that do not start with 0x47`),void 0,this.logger),c.pesData=y,f.pesData=C,_.pesData=B;const Qe={audioTrack:f,videoTrack:c,id3Track:_,textTrack:m};return o&&this.extractRemainingSamples(Qe),Qe}flush(){const{remainderData:t}=this;this.remainderData=null;let n;return t?n=this.demux(t,-1,!1,!0):n={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(n),this.sampleAes?this.decrypt(n,this.sampleAes):n}extractRemainingSamples(t){const{audioTrack:n,videoTrack:s,id3Track:o,textTrack:l}=t,c=s.pesData,f=n.pesData,_=o.pesData;let m;if(c&&(m=la(c,this.logger))?(this.readyVideoParser(s.segmentCodec),this.videoParser!==null&&(this.videoParser.parsePES(s,l,m,!0),s.pesData=null)):s.pesData=c,f&&(m=la(f,this.logger))){switch(n.segmentCodec){case"aac":this.parseAACPES(n,m);break;case"mp3":this.parseMPEGPES(n,m);break;case"ac3":this.parseAC3PES(n,m);break}n.pesData=null}else f!=null&&f.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),n.pesData=f;_&&(m=la(_,this.logger))?(this.parseID3PES(o,m),o.pesData=null):o.pesData=_}demuxSampleAes(t,n,s){const o=this.demux(t,s,!0,!this.config.progressive),l=this.sampleAes=new au(this.observer,this.config,n);return this.decrypt(o,l)}readyVideoParser(t){this.videoParser===null&&(t==="avc"?this.videoParser=new Uh:t==="hevc"&&(this.videoParser=new zh))}decrypt(t,n){return new Promise(s=>{const{audioTrack:o,videoTrack:l}=t;o.samples&&o.segmentCodec==="aac"?n.decryptAacSamples(o.samples,0,()=>{l.samples?n.decryptAvcSamples(l.samples,0,0,()=>{s(t)}):s(t)}):l.samples&&n.decryptAvcSamples(l.samples,0,0,()=>{s(t)})})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}parseAACPES(t,n){let s=0;const o=this.aacOverFlow;let l=n.data;if(o){this.aacOverFlow=null;const y=o.missing,x=o.sample.unit.byteLength;if(y===-1)l=ht(o.sample.unit,l);else{const D=x-y;o.sample.unit.set(l.subarray(0,y),D),t.samples.push(o.sample),s=o.missing}}let c,f;for(c=s,f=l.length;c<f-1&&!Mo(l,c);c++);if(c!==s){let y;const x=c<f-1;if(x?y=`AAC PES did not start with ADTS header,offset:${c}`:y="No ADTS header found in AAC PES",lu(this.observer,new Error(y),x,this.logger),!x)return}pc(t,this.observer,l,c,this.audioCodec);let _;if(n.pts!==void 0)_=n.pts;else if(o){const y=mc(t.samplerate);_=o.sample.pts+y}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let m=0,v;for(;c<f;)if(v=tu(t,l,c,_,m),c+=v.length,v.missing){this.aacOverFlow=v;break}else for(m++;c<f-1&&!Mo(l,c);c++);}parseMPEGPES(t,n){const s=n.data,o=s.length;let l=0,c=0;const f=n.pts;if(f===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;c<o;)if(Qa(s,c)){const _=wc(t,s,c,f,l);if(_)c+=_.length,l++;else break}else c++}parseAC3PES(t,n){{const s=n.data,o=n.pts;if(o===void 0){this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const l=s.length;let c=0,f=0,_;for(;f<l&&(_=pl(t,s,f,o,c++))>0;)f+=_}}parseID3PES(t,n){if(n.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const s=k({},n,{type:this._videoTrack?ms.emsg:ms.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(s)}}function Ro(h,t){return((h[t+1]&31)<<8)+h[t+2]}function ou(h,t){return(h[t+10]&31)<<8|h[t+11]}function Vh(h,t,n,s,o,l){const c={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},f=(h[t+1]&15)<<8|h[t+2],_=t+3+f-4,m=(h[t+10]&15)<<8|h[t+11];for(t+=12+m;t<_;){const v=Ro(h,t),y=(h[t+3]&15)<<8|h[t+4];switch(h[t]){case 207:if(!s){uu("ADTS AAC",l);break}case 15:c.audioPid===-1&&(c.audioPid=v);break;case 21:c.id3Pid===-1&&(c.id3Pid=v);break;case 219:if(!s){uu("H.264",l);break}case 27:c.videoPid===-1&&(c.videoPid=v);break;case 3:case 4:!n.mpeg&&!n.mp3?l.log("MPEG audio found, not supported in this browser"):c.audioPid===-1&&(c.audioPid=v,c.segmentAudioCodec="mp3");break;case 193:if(!s){uu("AC-3",l);break}case 129:n.ac3?c.audioPid===-1&&(c.audioPid=v,c.segmentAudioCodec="ac3"):l.log("AC-3 audio found, not supported in this browser");break;case 6:if(c.audioPid===-1&&y>0){let x=t+5,D=y;for(;D>2;){switch(h[x]){case 106:n.ac3!==!0?l.log("AC-3 audio found, not supported in this browser for now"):(c.audioPid=v,c.segmentAudioCodec="ac3");break}const B=h[x+1]+2;x+=B,D-=B}}break;case 194:case 135:return lu(o,new Error("Unsupported EC-3 in M2TS found"),void 0,l),c;case 36:c.videoPid===-1&&(c.videoPid=v,c.segmentVideoCodec="hevc",l.log("HEVC in M2TS found"));break}t+=y+5}return c}function lu(h,t,n,s){s.warn(`parsing error: ${t.message}`),h.emit(S.ERROR,S.ERROR,{type:ge.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!1,levelRetry:n,error:t,reason:t.message})}function uu(h,t){t.log(`${h} with AES-128-CBC encryption found in unencrypted stream`)}function la(h,t){let n=0,s,o,l,c,f;const _=h.data;if(!h||h.size===0)return null;for(;_[0].length<19&&_.length>1;)_[0]=ht(_[0],_[1]),_.splice(1,1);if(s=_[0],(s[0]<<16)+(s[1]<<8)+s[2]===1){if(o=(s[4]<<8)+s[5],o&&o>h.size-6)return null;const v=s[7];v&192&&(c=(s[9]&14)*536870912+(s[10]&255)*4194304+(s[11]&254)*16384+(s[12]&255)*128+(s[13]&254)/2,v&64?(f=(s[14]&14)*536870912+(s[15]&255)*4194304+(s[16]&254)*16384+(s[17]&255)*128+(s[18]&254)/2,c-f>60*9e4&&(t.warn(`${Math.round((c-f)/9e4)}s delta between PTS and DTS, align them`),c=f)):f=c),l=s[8];let y=l+9;if(h.size<=y)return null;h.size-=y;const x=new Uint8Array(h.size);for(let D=0,C=_.length;D<C;D++){s=_[D];let B=s.byteLength;if(y)if(y>B){y-=B;continue}else s=s.subarray(y),B-=y,y=0;x.set(s,n),n+=B}return o&&(o-=l+3),{data:x,pts:c,dts:f,len:o}}return null}class cu{static getSilentFrame(t,n){switch(t){case"mp4a.40.2":if(n===1)return new Uint8Array([0,200,0,128,35,128]);if(n===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(n===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(n===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(n===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(n===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(n===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(n===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(n===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}}}const Ks=Math.pow(2,32)-1;class Ke{static init(){Ke.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let t;for(t in Ke.types)Ke.types.hasOwnProperty(t)&&(Ke.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);const n=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]);Ke.HDLR_TYPES={video:n,audio:s};const o=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),l=new Uint8Array([0,0,0,0,0,0,0,0]);Ke.STTS=Ke.STSC=Ke.STCO=l,Ke.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Ke.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),Ke.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),Ke.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const c=new Uint8Array([105,115,111,109]),f=new Uint8Array([97,118,99,49]),_=new Uint8Array([0,0,0,1]);Ke.FTYP=Ke.box(Ke.types.ftyp,c,_,c,f),Ke.DINF=Ke.box(Ke.types.dinf,Ke.box(Ke.types.dref,o))}static box(t,...n){let s=8,o=n.length;const l=o;for(;o--;)s+=n[o].byteLength;const c=new Uint8Array(s);for(c[0]=s>>24&255,c[1]=s>>16&255,c[2]=s>>8&255,c[3]=s&255,c.set(t,4),o=0,s=8;o<l;o++)c.set(n[o],s),s+=n[o].byteLength;return c}static hdlr(t){return Ke.box(Ke.types.hdlr,Ke.HDLR_TYPES[t])}static mdat(t){return Ke.box(Ke.types.mdat,t)}static mdhd(t,n){n*=t;const s=Math.floor(n/(Ks+1)),o=Math.floor(n%(Ks+1));return Ke.box(Ke.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,s>>24,s>>16&255,s>>8&255,s&255,o>>24,o>>16&255,o>>8&255,o&255,85,196,0,0]))}static mdia(t){return Ke.box(Ke.types.mdia,Ke.mdhd(t.timescale||0,t.duration||0),Ke.hdlr(t.type),Ke.minf(t))}static mfhd(t){return Ke.box(Ke.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]))}static minf(t){return t.type==="audio"?Ke.box(Ke.types.minf,Ke.box(Ke.types.smhd,Ke.SMHD),Ke.DINF,Ke.stbl(t)):Ke.box(Ke.types.minf,Ke.box(Ke.types.vmhd,Ke.VMHD),Ke.DINF,Ke.stbl(t))}static moof(t,n,s){return Ke.box(Ke.types.moof,Ke.mfhd(t),Ke.traf(s,n))}static moov(t){let n=t.length;const s=[];for(;n--;)s[n]=Ke.trak(t[n]);return Ke.box.apply(null,[Ke.types.moov,Ke.mvhd(t[0].timescale||0,t[0].duration||0)].concat(s).concat(Ke.mvex(t)))}static mvex(t){let n=t.length;const s=[];for(;n--;)s[n]=Ke.trex(t[n]);return Ke.box.apply(null,[Ke.types.mvex,...s])}static mvhd(t,n){n*=t;const s=Math.floor(n/(Ks+1)),o=Math.floor(n%(Ks+1)),l=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,s>>24,s>>16&255,s>>8&255,s&255,o>>24,o>>16&255,o>>8&255,o&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 Ke.box(Ke.types.mvhd,l)}static sdtp(t){const n=t.samples||[],s=new Uint8Array(4+n.length);let o,l;for(o=0;o<n.length;o++)l=n[o].flags,s[o+4]=l.dependsOn<<4|l.isDependedOn<<2|l.hasRedundancy;return Ke.box(Ke.types.sdtp,s)}static stbl(t){return Ke.box(Ke.types.stbl,Ke.stsd(t),Ke.box(Ke.types.stts,Ke.STTS),Ke.box(Ke.types.stsc,Ke.STSC),Ke.box(Ke.types.stsz,Ke.STSZ),Ke.box(Ke.types.stco,Ke.STCO))}static avc1(t){let n=[],s=[],o,l,c;for(o=0;o<t.sps.length;o++)l=t.sps[o],c=l.byteLength,n.push(c>>>8&255),n.push(c&255),n=n.concat(Array.prototype.slice.call(l));for(o=0;o<t.pps.length;o++)l=t.pps[o],c=l.byteLength,s.push(c>>>8&255),s.push(c&255),s=s.concat(Array.prototype.slice.call(l));const f=Ke.box(Ke.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|t.sps.length].concat(n).concat([t.pps.length]).concat(s))),_=t.width,m=t.height,v=t.pixelRatio[0],y=t.pixelRatio[1];return Ke.box(Ke.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,_>>8&255,_&255,m>>8&255,m&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]),f,Ke.box(Ke.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Ke.box(Ke.types.pasp,new Uint8Array([v>>24,v>>16&255,v>>8&255,v&255,y>>24,y>>16&255,y>>8&255,y&255])))}static esds(t){const n=t.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...n,6,1,2])}static audioStsd(t){const n=t.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount||0,0,16,0,0,0,0,n>>8&255,n&255,0,0])}static mp4a(t){return Ke.box(Ke.types.mp4a,Ke.audioStsd(t),Ke.box(Ke.types.esds,Ke.esds(t)))}static mp3(t){return Ke.box(Ke.types[".mp3"],Ke.audioStsd(t))}static ac3(t){return Ke.box(Ke.types["ac-3"],Ke.audioStsd(t),Ke.box(Ke.types.dac3,t.config))}static stsd(t){const{segmentCodec:n}=t;if(t.type==="audio"){if(n==="aac")return Ke.box(Ke.types.stsd,Ke.STSD,Ke.mp4a(t));if(n==="ac3"&&t.config)return Ke.box(Ke.types.stsd,Ke.STSD,Ke.ac3(t));if(n==="mp3"&&t.codec==="mp3")return Ke.box(Ke.types.stsd,Ke.STSD,Ke.mp3(t))}else if(t.pps&&t.sps){if(n==="avc")return Ke.box(Ke.types.stsd,Ke.STSD,Ke.avc1(t));if(n==="hevc"&&t.vps)return Ke.box(Ke.types.stsd,Ke.STSD,Ke.hvc1(t))}else throw new Error("video track missing pps or sps");throw new Error(`unsupported ${t.type} segment codec (${n}/${t.codec})`)}static tkhd(t){const n=t.id,s=(t.duration||0)*(t.timescale||0),o=t.width||0,l=t.height||0,c=Math.floor(s/(Ks+1)),f=Math.floor(s%(Ks+1));return Ke.box(Ke.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,n&255,0,0,0,0,c>>24,c>>16&255,c>>8&255,c&255,f>>24,f>>16&255,f>>8&255,f&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,o>>8&255,o&255,0,0,l>>8&255,l&255,0,0]))}static traf(t,n){const s=Ke.sdtp(t),o=t.id,l=Math.floor(n/(Ks+1)),c=Math.floor(n%(Ks+1));return Ke.box(Ke.types.traf,Ke.box(Ke.types.tfhd,new Uint8Array([0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255])),Ke.box(Ke.types.tfdt,new Uint8Array([1,0,0,0,l>>24,l>>16&255,l>>8&255,l&255,c>>24,c>>16&255,c>>8&255,c&255])),Ke.trun(t,s.length+16+20+8+16+8+8),s)}static trak(t){return t.duration=t.duration||4294967295,Ke.box(Ke.types.trak,Ke.tkhd(t),Ke.mdia(t))}static trex(t){const n=t.id;return Ke.box(Ke.types.trex,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,n){const s=t.samples||[],o=s.length,l=12+16*o,c=new Uint8Array(l);let f,_,m,v,y,x;for(n+=8+l,c.set([t.type==="video"?1:0,0,15,1,o>>>24&255,o>>>16&255,o>>>8&255,o&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255],0),f=0;f<o;f++)_=s[f],m=_.duration,v=_.size,y=_.flags,x=_.cts,c.set([m>>>24&255,m>>>16&255,m>>>8&255,m&255,v>>>24&255,v>>>16&255,v>>>8&255,v&255,y.isLeading<<2|y.dependsOn,y.isDependedOn<<6|y.hasRedundancy<<4|y.paddingValue<<1|y.isNonSync,y.degradPrio&61440,y.degradPrio&15,x>>>24&255,x>>>16&255,x>>>8&255,x&255],12+16*f);return Ke.box(Ke.types.trun,c)}static initSegment(t){Ke.types||Ke.init();const n=Ke.moov(t);return ht(Ke.FTYP,n)}static hvc1(t){const n=t.params,s=[t.vps,t.sps,t.pps],o=4,l=new Uint8Array([1,n.general_profile_space<<6|(n.general_tier_flag?32:0)|n.general_profile_idc,n.general_profile_compatibility_flags[0],n.general_profile_compatibility_flags[1],n.general_profile_compatibility_flags[2],n.general_profile_compatibility_flags[3],n.general_constraint_indicator_flags[0],n.general_constraint_indicator_flags[1],n.general_constraint_indicator_flags[2],n.general_constraint_indicator_flags[3],n.general_constraint_indicator_flags[4],n.general_constraint_indicator_flags[5],n.general_level_idc,240|n.min_spatial_segmentation_idc>>8,255&n.min_spatial_segmentation_idc,252|n.parallelismType,252|n.chroma_format_idc,248|n.bit_depth_luma_minus8,248|n.bit_depth_chroma_minus8,0,parseInt(n.frame_rate.fps),o-1|n.temporal_id_nested<<2|n.num_temporal_layers<<3|(n.frame_rate.fixed?64:0),s.length]);let c=l.length;for(let C=0;C<s.length;C+=1){c+=3;for(let B=0;B<s[C].length;B+=1)c+=2+s[C][B].length}const f=new Uint8Array(c);f.set(l,0),c=l.length;const _=s.length-1;for(let C=0;C<s.length;C+=1){f.set(new Uint8Array([32+C|(C===_?128:0),0,s[C].length]),c),c+=3;for(let B=0;B<s[C].length;B+=1)f.set(new Uint8Array([s[C][B].length>>8,s[C][B].length&255]),c),c+=2,f.set(s[C][B],c),c+=s[C][B].length}const m=Ke.box(Ke.types.hvcC,f),v=t.width,y=t.height,x=t.pixelRatio[0],D=t.pixelRatio[1];return Ke.box(Ke.types.hvc1,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,v>>8&255,v&255,y>>8&255,y&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),m,Ke.box(Ke.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Ke.box(Ke.types.pasp,new Uint8Array([x>>24,x>>16&255,x>>8&255,x&255,D>>24,D>>16&255,D>>8&255,D&255])))}}Ke.types=void 0,Ke.HDLR_TYPES=void 0,Ke.STTS=void 0,Ke.STSC=void 0,Ke.STCO=void 0,Ke.STSZ=void 0,Ke.VMHD=void 0,Ke.SMHD=void 0,Ke.STSD=void 0,Ke.FTYP=void 0,Ke.DINF=void 0;const Lc=9e4;function ml(h,t,n=1,s=!1){const o=h*t*n;return s?Math.round(o):o}function hu(h,t,n=1,s=!1){return ml(h,t,1/n,s)}function Io(h,t=!1){return ml(h,1e3,1/Lc,t)}function Gh(h,t=1){return ml(h,Lc,1/t)}const Hh=10*1e3,Wh=1024,fu=1152,ii=1536;let Jr=null,du=null;function Dc(h,t,n,s){return{duration:t,size:n,cts:s,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:h?2:1,isNonSync:h?0:1}}}class Kr extends H{constructor(t,n,s,o){if(super("mp4-remuxer",o),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=t,this.config=n,this.typeSupported=s,this.ISGenerated=!1,Jr===null){const c=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Jr=c?parseInt(c[1]):0}if(du===null){const l=navigator.userAgent.match(/Safari\/(\d+)/i);du=l?parseInt(l[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(t){this.log("initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(t){let n=!1;const s=t[0].pts,o=t.reduce((l,c)=>{let f=c.pts,_=f-l;return _<-4294967296&&(n=!0,f=Qr(f,s),_=f-l),_>0?l:f},s);return n&&this.debug("PTS rollover detected"),o}remux(t,n,s,o,l,c,f,_){let m,v,y,x,D,C,B=l,F=l;const Q=t.pid>-1,se=n.pid>-1,le=n.samples.length,Ee=t.samples.length>0,Ie=f&&le>0||le>1;if((!Q||Ee)&&(!se||Ie)||this.ISGenerated||f){if(this.ISGenerated){var Pe,Ze,He,Fe;const yi=this.videoTrackConfig;(yi&&(n.width!==yi.width||n.height!==yi.height||((Pe=n.pixelRatio)==null?void 0:Pe[0])!==((Ze=yi.pixelRatio)==null?void 0:Ze[0])||((He=n.pixelRatio)==null?void 0:He[1])!==((Fe=yi.pixelRatio)==null?void 0:Fe[1]))||!yi&&Ie||this.nextAudioTs===null&&Ee)&&this.resetInitSegment()}this.ISGenerated||(y=this.generateIS(t,n,l,c));const bt=this.isVideoContiguous;let Xt=-1,ci;if(Ie&&(Xt=jh(n.samples),!bt&&this.config.forceKeyFrameOnDiscontinuity))if(C=!0,Xt>0){this.warn(`Dropped ${Xt} out of ${le} video samples due to a missing keyframe`);const yi=this.getVideoStartPts(n.samples);n.samples=n.samples.slice(Xt),n.dropped+=Xt,F+=(n.samples[0].pts-yi)/n.inputTimeScale,ci=F}else Xt===-1&&(this.warn(`No keyframe found out of ${le} video samples`),C=!1);if(this.ISGenerated){if(Ee&&Ie){const yi=this.getVideoStartPts(n.samples),Vt=(Qr(t.samples[0].pts,yi)-yi)/n.inputTimeScale;B+=Math.max(0,Vt),F+=Math.max(0,-Vt)}if(Ee){if(t.samplerate||(this.warn("regenerate InitSegment as audio detected"),y=this.generateIS(t,n,l,c)),v=this.remuxAudio(t,B,this.isAudioContiguous,c,se||Ie||_===P.AUDIO?F:void 0),Ie){const yi=v?v.endPTS-v.startPTS:0;n.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),y=this.generateIS(t,n,l,c)),m=this.remuxVideo(n,F,bt,yi)}}else Ie&&(m=this.remuxVideo(n,F,bt,0));m&&(m.firstKeyFrame=Xt,m.independent=Xt!==-1,m.firstKeyFramePTS=ci)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(s.samples.length&&(D=qh(s,l,this._initPTS,this._initDTS)),o.samples.length&&(x=Zh(o,l,this._initPTS))),{audio:v,video:m,initSegment:y,independent:C,text:x,id3:D}}generateIS(t,n,s,o){const l=t.samples,c=n.samples,f=this.typeSupported,_={},m=this._initPTS;let v=!m||o,y="audio/mp4",x,D,C,B=-1;if(v&&(x=D=1/0),t.config&&l.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":f.mpeg?(y="audio/mpeg",t.codec=""):f.mp3&&(t.codec="mp3");break;case"ac3":t.codec="ac-3";break}_.audio={id:"audio",container:y,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&f.mpeg?new Uint8Array(0):Ke.initSegment([t]),metadata:{channelCount:t.channelCount}},v&&(B=t.id,C=t.inputTimeScale,!m||C!==m.timescale?x=D=l[0].pts-Math.round(C*s):v=!1)}if(n.sps&&n.pps&&c.length){if(n.timescale=n.inputTimeScale,_.video={id:"main",container:"video/mp4",codec:n.codec,initSegment:Ke.initSegment([n]),metadata:{width:n.width,height:n.height}},v)if(B=n.id,C=n.inputTimeScale,!m||C!==m.timescale){const F=this.getVideoStartPts(c),Q=Math.round(C*s);D=Math.min(D,Qr(c[0].dts,F)-Q),x=Math.min(x,F-Q)}else v=!1;this.videoTrackConfig={width:n.width,height:n.height,pixelRatio:n.pixelRatio}}if(Object.keys(_).length)return this.ISGenerated=!0,v?(m&&this.warn(`Timestamps at playlist time: ${o?"":"~"}${s} ${x/C} != initPTS: ${m.baseTime/m.timescale} (${m.baseTime}/${m.timescale}) trackId: ${m.trackId}`),this.log(`Found initPTS at playlist time: ${s} offset: ${x/C} (${x}/${C}) trackId: ${B}`),this._initPTS={baseTime:x,timescale:C,trackId:B},this._initDTS={baseTime:D,timescale:C,trackId:B}):x=C=void 0,{tracks:_,initPTS:x,timescale:C,trackId:B}}remuxVideo(t,n,s,o){const l=t.inputTimeScale,c=t.samples,f=[],_=c.length,m=this._initPTS,v=m.baseTime*l/m.timescale;let y=this.nextVideoTs,x=8,D=this.videoSampleDuration,C,B,F=Number.POSITIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,se=!1;if(!s||y===null){const qt=v+n*l,Zt=c[0].pts-Qr(c[0].dts,c[0].pts);Jr&&y!==null&&Math.abs(qt-Zt-(y+v))<15e3?s=!0:y=qt-Zt-v}const le=y+v;for(let qt=0;qt<_;qt++){const Zt=c[qt];Zt.pts=Qr(Zt.pts,le),Zt.dts=Qr(Zt.dts,le),Zt.dts<c[qt>0?qt-1:qt].dts&&(se=!0)}se&&c.sort(function(qt,Zt){const qi=qt.dts-Zt.dts,In=qt.pts-Zt.pts;return qi||In}),C=c[0].dts,B=c[c.length-1].dts;const Ee=B-C,Ie=Ee?Math.round(Ee/(_-1)):D||t.inputTimeScale/30;if(s){const qt=C-le,Zt=qt>Ie,qi=qt<-1;if((Zt||qi)&&(Zt?this.warn(`${(t.segmentCodec||"").toUpperCase()}: ${Io(qt,!0)} ms (${qt}dts) hole between fragments detected at ${n.toFixed(3)}`):this.warn(`${(t.segmentCodec||"").toUpperCase()}: ${Io(-qt,!0)} ms (${qt}dts) overlapping between fragments detected at ${n.toFixed(3)}`),!qi||le>=c[0].pts||Jr)){C=le;const In=c[0].pts-qt;if(Zt)c[0].dts=C,c[0].pts=In;else{let an=!0;for(let Vi=0;Vi<c.length&&!(c[Vi].dts>In&&an);Vi++){const ts=c[Vi].pts;if(c[Vi].dts-=qt,c[Vi].pts-=qt,Vi<c.length-1){const Dr=c[Vi+1].pts,Is=c[Vi].pts,wn=Dr<=Is,_o=Dr<=ts;an=wn==_o}}}this.log(`Video: Initial PTS/DTS adjusted: ${Io(In,!0)}/${Io(C,!0)}, delta: ${Io(qt,!0)} ms`)}}C=Math.max(0,C);let Qe=0,Pe=0,Ze=C;for(let qt=0;qt<_;qt++){const Zt=c[qt],qi=Zt.units,In=qi.length;let an=0;for(let Vi=0;Vi<In;Vi++)an+=qi[Vi].data.length;Pe+=an,Qe+=In,Zt.length=an,Zt.dts<Ze?(Zt.dts=Ze,Ze+=Ie/4|0||1):Ze=Zt.dts,F=Math.min(Zt.pts,F),Q=Math.max(Zt.pts,Q)}B=c[_-1].dts;const He=Pe+4*Qe+8;let Fe;try{Fe=new Uint8Array(He)}catch(qt){this.observer.emit(S.ERROR,S.ERROR,{type:ge.MUX_ERROR,details:q.REMUX_ALLOC_ERROR,fatal:!1,error:qt,bytes:He,reason:`fail allocating video mdat ${He}`});return}const bt=new DataView(Fe.buffer);bt.setUint32(0,He),Fe.set(Ke.types.mdat,4);let Xt=!1,ci=Number.POSITIVE_INFINITY,yi=Number.POSITIVE_INFINITY,li=Number.NEGATIVE_INFINITY,Vt=Number.NEGATIVE_INFINITY;for(let qt=0;qt<_;qt++){const Zt=c[qt],qi=Zt.units;let In=0;for(let ts=0,Dr=qi.length;ts<Dr;ts++){const Is=qi[ts],wn=Is.data,_o=Is.data.byteLength;bt.setUint32(x,_o),x+=4,Fe.set(wn,x),x+=_o,In+=4+_o}let an;if(qt<_-1)D=c[qt+1].dts-Zt.dts,an=c[qt+1].pts-Zt.pts;else{const ts=this.config,Dr=qt>0?Zt.dts-c[qt-1].dts:Ie;if(an=qt>0?Zt.pts-c[qt-1].pts:Ie,ts.stretchShortVideoTrack&&this.nextAudioTs!==null){const Is=Math.floor(ts.maxBufferHole*l),wn=(o?F+o*l:this.nextAudioTs+v)-Zt.pts;wn>Is?(D=wn-Dr,D<0?D=Dr:Xt=!0,this.log(`It is approximately ${wn/90} ms to the next segment; using duration ${D/90} ms for the last video frame.`)):D=Dr}else D=Dr}const Vi=Math.round(Zt.pts-Zt.dts);ci=Math.min(ci,D),li=Math.max(li,D),yi=Math.min(yi,an),Vt=Math.max(Vt,an),f.push(Dc(Zt.key,D,In,Vi))}if(f.length){if(Jr){if(Jr<70){const qt=f[0].flags;qt.dependsOn=2,qt.isNonSync=0}}else if(du&&Vt-yi<li-ci&&Ie/li<.025&&f[0].cts===0){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let qt=C;for(let Zt=0,qi=f.length;Zt<qi;Zt++){const In=qt+f[Zt].duration,an=qt+f[Zt].cts;if(Zt<qi-1){const Vi=In+f[Zt+1].cts;f[Zt].duration=Vi-an}else f[Zt].duration=Zt?f[Zt-1].duration:Ie;f[Zt].cts=0,qt=In}}}D=Xt||!D?Ie:D;const bi=B+D;this.nextVideoTs=y=bi-v,this.videoSampleDuration=D,this.isVideoContiguous=!0;const Pi={data1:Ke.moof(t.sequenceNumber++,C,k(t,{samples:f})),data2:Fe,startPTS:(F-v)/l,endPTS:(Q+D-v)/l,startDTS:(C-v)/l,endDTS:y/l,type:"video",hasAudio:!1,hasVideo:!0,nb:f.length,dropped:t.dropped};return t.samples=[],t.dropped=0,Pi}getSamplesPerFrame(t){switch(t.segmentCodec){case"mp3":return fu;case"ac3":return ii;default:return Wh}}remuxAudio(t,n,s,o,l){const c=t.inputTimeScale,f=t.samplerate?t.samplerate:c,_=c/f,m=this.getSamplesPerFrame(t),v=m*_,y=this._initPTS,x=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,D=[],C=l!==void 0;let B=t.samples,F=x?0:8,Q=this.nextAudioTs||-1;const se=y.baseTime*c/y.timescale,le=se+n*c;if(this.isAudioContiguous=s=s||B.length&&Q>0&&(o&&Math.abs(le-(Q+se))<9e3||Math.abs(Qr(B[0].pts,le)-(Q+se))<20*v),B.forEach(function(Vt){Vt.pts=Qr(Vt.pts,le)}),!s||Q<0){if(B=B.filter(Vt=>Vt.pts>=0),!B.length)return;l===0?Q=0:o&&!C?Q=Math.max(0,le-se):Q=B[0].pts-se}if(t.segmentCodec==="aac"){const Vt=this.config.maxAudioFramesDrift;for(let bi=0,si=Q+se;bi<B.length;bi++){const xi=B[bi],Pi=xi.pts,qt=Pi-si,Zt=Math.abs(1e3*qt/c);if(qt<=-Vt*v&&C)bi===0&&(this.warn(`Audio frame @ ${(Pi/c).toFixed(3)}s overlaps marker by ${Math.round(1e3*qt/c)} ms.`),this.nextAudioTs=Q=Pi-se,si=Pi);else if(qt>=Vt*v&&Zt<Hh&&C){let qi=Math.round(qt/v);for(si=Pi-qi*v;si<0&&qi&&v;)qi--,si+=v;bi===0&&(this.nextAudioTs=Q=si-se),this.warn(`Injecting ${qi} audio frames @ ${((si-se)/c).toFixed(3)}s due to ${Math.round(1e3*qt/c)} ms gap.`);for(let In=0;In<qi;In++){let an=cu.getSilentFrame(t.parsedCodec||t.manifestCodec||t.codec,t.channelCount);an||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),an=xi.unit.subarray()),B.splice(bi,0,{unit:an,pts:si}),si+=v,bi++}}xi.pts=si,si+=v}}let Ee=null,Ie=null,Qe,Pe=0,Ze=B.length;for(;Ze--;)Pe+=B[Ze].unit.byteLength;for(let Vt=0,bi=B.length;Vt<bi;Vt++){const si=B[Vt],xi=si.unit;let Pi=si.pts;if(Ie!==null){const Zt=D[Vt-1];Zt.duration=Math.round((Pi-Ie)/_)}else if(s&&t.segmentCodec==="aac"&&(Pi=Q+se),Ee=Pi,Pe>0){Pe+=F;try{Qe=new Uint8Array(Pe)}catch(Zt){this.observer.emit(S.ERROR,S.ERROR,{type:ge.MUX_ERROR,details:q.REMUX_ALLOC_ERROR,fatal:!1,error:Zt,bytes:Pe,reason:`fail allocating audio mdat ${Pe}`});return}x||(new DataView(Qe.buffer).setUint32(0,Pe),Qe.set(Ke.types.mdat,4))}else return;Qe.set(xi,F);const qt=xi.byteLength;F+=qt,D.push(Dc(!0,m,qt,0)),Ie=Pi}const He=D.length;if(!He)return;const Fe=D[D.length-1];Q=Ie-se,this.nextAudioTs=Q+_*Fe.duration;const bt=x?new Uint8Array(0):Ke.moof(t.sequenceNumber++,Ee/_,k({},t,{samples:D}));t.samples=[];const Xt=(Ee-se)/c,ci=Q/c,li={data1:bt,data2:Qe,startPTS:Xt,endPTS:ci,startDTS:Xt,endDTS:ci,type:"audio",hasAudio:!0,hasVideo:!1,nb:He};return this.isAudioContiguous=!0,li}}function Qr(h,t){let n;if(t===null)return h;for(t<h?n=-8589934592:n=8589934592;Math.abs(h-t)>4294967296;)h+=n;return h}function jh(h){for(let t=0;t<h.length;t++)if(h[t].key)return t;return-1}function qh(h,t,n,s){const o=h.samples.length;if(!o)return;const l=h.inputTimeScale;for(let f=0;f<o;f++){const _=h.samples[f];_.pts=Qr(_.pts-n.baseTime*l/n.timescale,t*l)/l,_.dts=Qr(_.dts-s.baseTime*l/s.timescale,t*l)/l}const c=h.samples;return h.samples=[],{samples:c}}function Zh(h,t,n){const s=h.samples.length;if(!s)return;const o=h.inputTimeScale;for(let c=0;c<s;c++){const f=h.samples[c];f.pts=Qr(f.pts-n.baseTime*o/n.timescale,t*o)/o}h.samples.sort((c,f)=>c.pts-f.pts);const l=h.samples;return h.samples=[],{samples:l}}class Po extends H{constructor(t,n,s,o){super("passthrough-remuxer",o),this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.isVideoContiguous=!1}destroy(){}resetTimeStamp(t){this.lastEndTime=null;const n=this.initPTS;n&&t&&n.baseTime===t.baseTime&&n.timescale===t.timescale||(this.initPTS=t)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(t,n,s,o){this.audioCodec=n,this.videoCodec=s,this.generateInitSegment(t,o),this.emitInitSegment=!0}generateInitSegment(t,n){let{audioCodec:s,videoCodec:o}=this;if(!(t!=null&&t.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const{audio:l,video:c}=this.initData=_t(t);if(n)gt(t,n);else{const _=l||c;_!=null&&_.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${_.codec}")!`)}l&&(s=ua(l,V.AUDIO,this)),c&&(o=ua(c,V.VIDEO,this));const f={};l&&c?f.audiovideo={container:"video/mp4",codec:s+","+o,supplemental:c.supplemental,encrypted:c.encrypted,initSegment:t,id:"main"}:l?f.audio={container:"audio/mp4",codec:s,encrypted:l.encrypted,initSegment:t,id:"audio"}:c?f.video={container:"video/mp4",codec:o,supplemental:c.supplemental,encrypted:c.encrypted,initSegment:t,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=f}remux(t,n,s,o,l,c){var f,_;let{initPTS:m,lastEndTime:v}=this;const y={audio:void 0,video:void 0,text:o,id3:s,initSegment:void 0};ce(v)||(v=this.lastEndTime=l||0);const x=n.samples;if(!x.length)return y;const D={initPTS:void 0,timescale:void 0,trackId:void 0};let C=this.initData;if((f=C)!=null&&f.length||(this.generateInitSegment(x),C=this.initData),!((_=C)!=null&&_.length))return this.warn("Failed to generate initSegment."),y;this.emitInitSegment&&(D.tracks=this.initTracks,this.emitInitSegment=!1);const B=pt(x,C,this),F=C.audio?B[C.audio.id]:null,Q=C.video?B[C.video.id]:null,se=gs(Q,1/0),le=gs(F,1/0),Ee=gs(Q,0,!0),Ie=gs(F,0,!0);let Qe=l,Pe=0;const Ze=F&&(!Q||!m&&le<se||m&&m.trackId===C.audio.id),He=Ze?F:Q;if(He){const si=He.timescale,xi=He.start-l*si,Pi=Ze?C.audio.id:C.video.id;Qe=He.start/si,Pe=Ze?Ie-le:Ee-se,(c||!m)&&(od(m,Qe,l,Pe)||si!==m.timescale)&&(m&&this.warn(`Timestamps at playlist time: ${c?"":"~"}${l} ${xi/si} != initPTS: ${m.baseTime/m.timescale} (${m.baseTime}/${m.timescale}) trackId: ${m.trackId}`),this.log(`Found initPTS at playlist time: ${l} offset: ${Qe-l} (${xi}/${si}) trackId: ${Pi}`),m=null,D.initPTS=xi,D.timescale=si,D.trackId=Pi)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${l}`);m?(D.initPTS=m.baseTime,D.timescale=m.timescale,D.trackId=m.trackId):((!D.timescale||D.trackId===void 0||D.initPTS===void 0)&&(this.warn("Could not set initPTS"),D.initPTS=Qe,D.timescale=1,D.trackId=-1),this.initPTS=m={baseTime:D.initPTS,timescale:D.timescale,trackId:D.trackId});const Fe=Qe-m.baseTime/m.timescale,bt=Fe+Pe;Pe>0?this.lastEndTime=bt:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const Xt=!!C.audio,ci=!!C.video;let yi="";Xt&&(yi+="audio"),ci&&(yi+="video");const li=(C.audio?C.audio.encrypted:!1)||(C.video?C.video.encrypted:!1),Vt={data1:x,startPTS:Fe,startDTS:Fe,endPTS:bt,endDTS:bt,type:yi,hasAudio:Xt,hasVideo:ci,nb:1,dropped:0,encrypted:li};y.audio=Xt&&!ci?Vt:void 0,y.video=ci?Vt:void 0;const bi=Q==null?void 0:Q.sampleCount;if(bi){const si=Q.keyFrameIndex,xi=si!==-1;Vt.nb=bi,Vt.dropped=si===0||this.isVideoContiguous?0:xi?si:bi,Vt.independent=xi,Vt.firstKeyFrame=si,xi&&Q.keyFrameStart&&(Vt.firstKeyFramePTS=(Q.keyFrameStart-m.baseTime)/m.timescale),this.isVideoContiguous||(y.independent=xi),this.isVideoContiguous||(this.isVideoContiguous=xi),Vt.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${si}/${bi} dropped: ${Vt.dropped} start: ${Vt.firstKeyFramePTS||"NA"}`)}return y.initSegment=D,y.id3=qh(s,l,m,m),o.samples.length&&(y.text=Zh(o,l,m)),y}}function gs(h,t,n=!1){return(h==null?void 0:h.start)!==void 0?(h.start+(n?h.duration:0))/h.timescale:t}function od(h,t,n,s){if(h===null)return!0;const o=Math.max(s,1),l=t-h.baseTime/h.timescale;return Math.abs(l-n)>o}function ua(h,t,n){const s=h.codec;return s&&s.length>4?s:t===V.AUDIO?s==="ec-3"||s==="ac-3"||s==="alac"?s:s==="fLaC"||s==="Opus"?_e(s,!1):(n.warn(`Unhandled audio codec "${s}" in mp4 MAP`),s||"mp4a"):(n.warn(`Unhandled video codec "${s}" in mp4 MAP`),s||"avc1")}let Zs;try{Zs=self.performance.now.bind(self.performance)}catch(h){Zs=Date.now}const Oo=[{demux:Kh,remux:Po},{demux:$s,remux:Kr},{demux:Fh,remux:Kr},{demux:Nh,remux:Kr}];Oo.splice(2,0,{demux:Bh,remux:Kr});class pu{constructor(t,n,s,o,l,c){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=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.observer=t,this.typeSupported=n,this.config=s,this.id=l,this.logger=c}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,n,s,o){const l=s.transmuxing;l.executeStart=Zs();let c=new Uint8Array(t);const{currentTransmuxState:f,transmuxConfig:_}=this;o&&(this.currentTransmuxState=o);const{contiguous:m,discontinuity:v,trackSwitch:y,accurateTimeOffset:x,timeOffset:D,initSegmentChange:C}=o||f,{audioCodec:B,videoCodec:F,defaultInitPts:Q,duration:se,initSegmentData:le}=_,Ee=Yh(c,n);if(Ee&&Xn(Ee.method)){const Ze=this.getDecrypter(),He=rs(Ee.method);if(Ze.isSync()){let Fe=Ze.softwareDecrypt(c,Ee.key.buffer,Ee.iv.buffer,He);if(s.part>-1){const Xt=Ze.flush();Fe=Xt&&Xt.buffer}if(!Fe)return l.executeEnd=Zs(),Aa(s);c=new Uint8Array(Fe)}else return this.asyncResult=!0,this.decryptionPromise=Ze.webCryptoDecrypt(c,Ee.key.buffer,Ee.iv.buffer,He).then(Fe=>{const bt=this.push(Fe,null,s);return this.decryptionPromise=null,bt}),this.decryptionPromise}const Ie=this.needsProbing(v,y);if(Ie){const Ze=this.configureTransmuxer(c);if(Ze)return this.logger.warn(`[transmuxer] ${Ze.message}`),this.observer.emit(S.ERROR,S.ERROR,{type:ge.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!1,error:Ze,reason:Ze.message}),l.executeEnd=Zs(),Aa(s)}(v||y||C||Ie)&&this.resetInitSegment(le,B,F,se,n),(v||C||Ie)&&this.resetInitialTimestamp(Q),m||this.resetContiguity();const Qe=this.transmux(c,Ee,D,x,s);this.asyncResult=io(Qe);const Pe=this.currentTransmuxState;return Pe.contiguous=!0,Pe.discontinuity=!1,Pe.trackSwitch=!1,l.executeEnd=Zs(),Qe}flush(t){const n=t.transmuxing;n.executeStart=Zs();const{decrypter:s,currentTransmuxState:o,decryptionPromise:l}=this;if(l)return this.asyncResult=!0,l.then(()=>this.flush(t));const c=[],{timeOffset:f}=o;if(s){const y=s.flush();y&&c.push(this.push(y.buffer,null,t))}const{demuxer:_,remuxer:m}=this;if(!_||!m){n.executeEnd=Zs();const y=[Aa(t)];return this.asyncResult?Promise.resolve(y):y}const v=_.flush(f);return io(v)?(this.asyncResult=!0,v.then(y=>(this.flushRemux(c,y,t),c))):(this.flushRemux(c,v,t),this.asyncResult?Promise.resolve(c):c)}flushRemux(t,n,s){const{audioTrack:o,videoTrack:l,id3Track:c,textTrack:f}=n,{accurateTimeOffset:_,timeOffset:m}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${s.sn}${s.part>-1?" part: "+s.part:""} of ${this.id===P.MAIN?"level":"track"} ${s.level}`);const v=this.remuxer.remux(o,l,c,f,m,_,!0,this.id);t.push({remuxResult:v,chunkMeta:s}),s.transmuxing.executeEnd=Zs()}resetInitialTimestamp(t){const{demuxer:n,remuxer:s}=this;!n||!s||(n.resetTimeStamp(t),s.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:n}=this;!t||!n||(t.resetContiguity(),n.resetNextTimestamp())}resetInitSegment(t,n,s,o,l){const{demuxer:c,remuxer:f}=this;!c||!f||(c.resetInitSegment(t,n,s,o),f.resetInitSegment(t,n,s,l))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,n,s,o,l){let c;return n&&n.method==="SAMPLE-AES"?c=this.transmuxSampleAes(t,n,s,o,l):c=this.transmuxUnencrypted(t,s,o,l),c}transmuxUnencrypted(t,n,s,o){const{audioTrack:l,videoTrack:c,id3Track:f,textTrack:_}=this.demuxer.demux(t,n,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(l,c,f,_,n,s,!1,this.id),chunkMeta:o}}transmuxSampleAes(t,n,s,o,l){return this.demuxer.demuxSampleAes(t,n,s).then(c=>({remuxResult:this.remuxer.remux(c.audioTrack,c.videoTrack,c.id3Track,c.textTrack,s,o,!1,this.id),chunkMeta:l}))}configureTransmuxer(t){const{config:n,observer:s,typeSupported:o}=this;let l;for(let y=0,x=Oo.length;y<x;y++){var c;if((c=Oo[y].demux)!=null&&c.probe(t,this.logger)){l=Oo[y];break}}if(!l)return new Error("Failed to find demuxer by probing fragment data");const f=this.demuxer,_=this.remuxer,m=l.remux,v=l.demux;(!_||!(_ instanceof m))&&(this.remuxer=new m(s,n,o,this.logger)),(!f||!(f instanceof v))&&(this.demuxer=new v(s,n,o,this.logger),this.probe=v.probe)}needsProbing(t,n){return!this.demuxer||!this.remuxer||t||n}getDecrypter(){let t=this.decrypter;return t||(t=this.decrypter=new Mn(this.config)),t}}function Yh(h,t){let n=null;return h.byteLength>0&&(t==null?void 0:t.key)!=null&&t.iv!==null&&t.method!=null&&(n=t),n}const Aa=h=>({remuxResult:{},chunkMeta:h});function io(h){return"then"in h&&h.then instanceof Function}class Cc{constructor(t,n,s,o,l){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=n,this.initSegmentData=s,this.duration=o,this.defaultInitPts=l||null}}class Xh{constructor(t,n,s,o,l,c){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=n,this.accurateTimeOffset=s,this.trackSwitch=o,this.timeOffset=l,this.initSegmentChange=c}}let Jh=0;class Qh{constructor(t,n,s,o){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=Jh++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=_=>{const m=_.data,v=this.hls;if(!(!v||!(m!=null&&m.event)||m.instanceNo!==this.instanceNo))switch(m.event){case"init":{var y;const x=(y=this.workerContext)==null?void 0:y.objectURL;x&&self.URL.revokeObjectURL(x);break}case"transmuxComplete":{this.handleTransmuxComplete(m.data);break}case"flush":{this.onFlush(m.data);break}case"workerLog":{v.logger[m.data.logType]&&v.logger[m.data.logType](m.data.message);break}default:{m.data=m.data||{},m.data.frag=this.frag,m.data.part=this.part,m.data.id=this.id,v.trigger(m.event,m.data);break}}},this.onWorkerError=_=>{if(!this.hls)return;const m=new Error(`${_.message} (${_.filename}:${_.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(S.ERROR,{type:ge.OTHER_ERROR,details:q.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:m})};const l=t.config;this.hls=t,this.id=n,this.useWorker=!!l.enableWorker,this.onTransmuxComplete=s,this.onFlush=o;const c=(_,m)=>{m=m||{},m.frag=this.frag||void 0,_===S.ERROR&&(m=m,m.parent=this.id,m.part=this.part,this.error=m.error),this.hls.trigger(_,m)};this.observer=new Bs,this.observer.on(S.FRAG_DECRYPTED,c),this.observer.on(S.ERROR,c);const f=di(l.preferManagedMediaSource);if(this.useWorker&&typeof Worker!="undefined"){const _=this.hls.logger;if(l.workerPath||uc()){try{l.workerPath?(_.log(`loading Web Worker ${l.workerPath} for "${n}"`),this.workerContext=xh(l.workerPath)):(_.log(`injecting Web Worker for "${n}"`),this.workerContext=bh());const{worker:v}=this.workerContext;v.addEventListener("message",this.onWorkerMessage),v.addEventListener("error",this.onWorkerError),v.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:f,id:n,config:$t(l)})}catch(v){_.warn(`Error setting up "${n}" Web Worker, fallback to inline`,v),this.terminateWorker(),this.error=null,this.transmuxer=new pu(this.observer,f,l,"",n,t.logger)}return}}this.transmuxer=new pu(this.observer,f,l,"",n,t.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const t=this.instanceNo;this.instanceNo=Jh++;const n=this.hls.config,s=di(n.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:t,typeSupported:s,id:this.id,config:$t(n)})}}terminateWorker(){if(this.workerContext){const{worker:t}=this.workerContext;this.workerContext=null,t.removeEventListener("message",this.onWorkerMessage),t.removeEventListener("error",this.onWorkerError),cc(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const n=this.transmuxer;n&&(n.destroy(),this.transmuxer=null)}const t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(t,n,s,o,l,c,f,_,m,v){var y,x;m.transmuxing.start=self.performance.now();const{instanceNo:D,transmuxer:C}=this,B=c?c.start:l.start,F=l.decryptdata,Q=this.frag,se=!(Q&&l.cc===Q.cc),le=!(Q&&m.level===Q.level),Ee=Q?m.sn-Q.sn:-1,Ie=this.part?m.part-this.part.index:-1,Qe=Ee===0&&m.id>1&&m.id===(Q==null?void 0:Q.stats.chunkCount),Pe=!le&&(Ee===1||Ee===0&&(Ie===1||Qe&&Ie<=0)),Ze=self.performance.now();(le||Ee||l.stats.parsing.start===0)&&(l.stats.parsing.start=Ze),c&&(Ie||!Pe)&&(c.stats.parsing.start=Ze);const He=!(Q&&((y=l.initSegment)==null?void 0:y.url)===((x=Q.initSegment)==null?void 0:x.url)),Fe=new Xh(se,Pe,_,le,B,He);if(!Pe||se||He){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${l.type} sn: ${m.sn}${m.part>-1?" part: "+m.part:""} ${this.id===P.MAIN?"level":"track"}: ${m.level} id: ${m.id}
discontinuity: ${se}
trackSwitch: ${le}
contiguous: ${Pe}
accurateTimeOffset: ${_}
timeOffset: ${B}
initSegmentChange: ${He}`);const bt=new Cc(s,o,n,f,v);this.configureTransmuxer(bt)}if(this.frag=l,this.part=c,this.workerContext)this.workerContext.worker.postMessage({instanceNo:D,cmd:"demux",data:t,decryptdata:F,chunkMeta:m,state:Fe},t instanceof ArrayBuffer?[t]:[]);else if(C){const bt=C.push(t,F,m,Fe);io(bt)?bt.then(Xt=>{this.handleTransmuxComplete(Xt)}).catch(Xt=>{this.transmuxerError(Xt,m,"transmuxer-interface push error")}):this.handleTransmuxComplete(bt)}}flush(t){t.transmuxing.start=self.performance.now();const{instanceNo:n,transmuxer:s}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:n,cmd:"flush",chunkMeta:t});else if(s){const o=s.flush(t);io(o)?o.then(l=>{this.handleFlushResult(l,t)}).catch(l=>{this.transmuxerError(l,t,"transmuxer-interface flush error")}):this.handleFlushResult(o,t)}}transmuxerError(t,n,s){this.hls&&(this.error=t,this.hls.trigger(S.ERROR,{type:ge.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,chunkMeta:n,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:t,err:t,reason:s}))}handleFlushResult(t,n){t.forEach(s=>{this.handleTransmuxComplete(s)}),this.onFlush(n)}configureTransmuxer(t){const{instanceNo:n,transmuxer:s}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:n,cmd:"configure",config:t}):s&&s.configure(t)}handleTransmuxComplete(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)}}const ef=100;class mu extends Xl{constructor(t,n,s){super(t,n,s,"audio-stream-controller",P.AUDIO),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();const{hls:t}=this;t.on(S.LEVEL_LOADED,this.onLevelLoaded,this),t.on(S.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(S.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(S.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(S.BUFFER_RESET,this.onBufferReset,this),t.on(S.BUFFER_CREATED,this.onBufferCreated,this),t.on(S.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(S.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(S.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(S.FRAG_LOADING,this.onFragLoading,this),t.on(S.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:t}=this;t&&(super.unregisterListeners(),t.off(S.LEVEL_LOADED,this.onLevelLoaded,this),t.off(S.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(S.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(S.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(S.BUFFER_RESET,this.onBufferReset,this),t.off(S.BUFFER_CREATED,this.onBufferCreated,this),t.off(S.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(S.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(S.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(S.FRAG_LOADING,this.onFragLoading,this),t.off(S.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(t,{frag:n,id:s,initPTS:o,timescale:l,trackId:c}){if(s===P.MAIN){const f=n.cc,_=this.fragCurrent;if(this.initPTS[f]={baseTime:o,timescale:l,trackId:c},this.log(`InitPTS for cc: ${f} found from main: ${o/l} (${o}/${l}) trackId: ${c}`),this.mainAnchor=n,this.state===mt.WAITING_INIT_PTS){const m=this.waitingData;(!m&&!this.loadingParts||m&&m.frag.cc!==f)&&this.syncWithAnchor(n,m==null?void 0:m.frag)}else!this.hls.hasEnoughToStart&&_&&_.cc!==f?(_.abortRequests(),this.syncWithAnchor(n,_)):this.state===mt.IDLE&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(t,n){var s;const o=((s=this.mainFragLoading)==null?void 0:s.frag)||null;if(n&&(o==null?void 0:o.cc)===n.cc)return;const l=(o||t).cc,c=this.getLevelDetails(),f=this.getLoadPosition(),_=wi(c,l,f);_&&(this.log(`Syncing with main frag at ${_.start} cc ${_.cc}`),this.startFragRequested=!1,this.nextLoadPosition=_.start,this.resetLoadingState(),this.state===mt.IDLE&&this.doTickIdle())}startLoad(t,n){if(!this.levels){this.startPosition=t,this.state=mt.STOPPED;return}const s=this.lastCurrentTime;this.stopLoad(),this.setInterval(ef),s>0&&t===-1?(this.log(`Override startPosition with lastCurrentTime @${s.toFixed(3)}`),t=s,this.state=mt.IDLE):this.state=mt.WAITING_TRACK,this.nextLoadPosition=this.lastCurrentTime=t+this.timelineOffset,this.startPosition=n?-1:t,this.tick()}doTick(){switch(this.state){case mt.IDLE:this.doTickIdle();break;case mt.WAITING_TRACK:{const{levels:t,trackId:n}=this,s=t==null?void 0:t[n],o=s==null?void 0:s.details;if(o&&!this.waitForLive(s)){if(this.waitForCdnTuneIn(o))break;this.state=mt.WAITING_INIT_PTS}break}case mt.FRAG_LOADING_WAITING_RETRY:{this.checkRetryDate();break}case mt.WAITING_INIT_PTS:{const t=this.waitingData;if(t){const{frag:n,part:s,cache:o,complete:l}=t,c=this.mainAnchor;if(this.initPTS[n.cc]!==void 0){this.waitingData=null,this.state=mt.FRAG_LOADING;const f=o.flush().buffer,_={frag:n,part:s,payload:f,networkDetails:null};this._handleFragmentLoadProgress(_),l&&super._handleFragmentLoadComplete(_)}else c&&c.cc!==t.frag.cc&&this.syncWithAnchor(c,t.frag)}else this.state=mt.IDLE}}this.onTickEnd()}resetLoadingState(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:t}=this;t!=null&&t.readyState&&(this.lastCurrentTime=t.currentTime)}doTickIdle(){var t;const{hls:n,levels:s,media:o,trackId:l}=this,c=n.config;if(!this.buffering||!o&&!this.primaryPrefetch&&(this.startFragRequested||!c.startFragPrefetch)||!(s!=null&&s[l]))return;const f=s[l],_=f.details;if(!_||this.waitForLive(f)||this.waitForCdnTuneIn(_)){this.state=mt.WAITING_TRACK,this.startFragRequested=!1;return}const m=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&m&&(this.bufferFlushed=!1,this.afterBufferFlushed(m,V.AUDIO,P.AUDIO));const v=this.getFwdBufferInfo(m,P.AUDIO);if(v===null)return;if(!this.switchingTrack&&this._streamEnded(v,_)){n.trigger(S.BUFFER_EOS,{type:"audio"}),this.state=mt.ENDED;return}const y=v.len,x=n.maxBufferLength,D=_.fragments,C=D[0].start,B=this.getLoadPosition(),F=this.flushing?B:v.end;if(this.switchingTrack&&o){const le=B;_.PTSKnown&&le<C&&(v.end>C||v.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),o.currentTime=C+.05)}if(y>=x&&!this.switchingTrack&&F<D[D.length-1].start)return;let Q=this.getNextFragment(F,_);if(Q&&this.isLoopLoading(Q,F)&&(Q=this.getNextFragmentLoopLoading(Q,_,v,P.MAIN,x)),!Q){this.bufferFlushed=!0;return}let se=((t=this.mainFragLoading)==null?void 0:t.frag)||null;if(!this.audioOnly&&this.startFragRequested&&se&&ze(Q)&&!Q.endList&&(!_.live||!this.loadingParts&&F<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(se)===rn.OK&&(this.mainFragLoading=se=null),se&&ze(se))){if(Q.start>se.end){const Ee=this.fragmentTracker.getFragAtPos(F,P.MAIN);Ee&&Ee.end>se.end&&(se=Ee,this.mainFragLoading={frag:Ee,targetBufferTime:null})}if(Q.start>se.end)return}this.loadFragment(Q,f,F)}onMediaDetaching(t,n){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(t,n)}onAudioTracksUpdated(t,{audioTracks:n}){this.resetTransmuxer(),this.levels=n.map(s=>new Yn(s))}onAudioTrackSwitching(t,n){const s=!!n.url;this.trackId=n.id;const{fragCurrent:o}=this;o&&(o.abortRequests(),this.removeUnbufferedFrags(o.start)),this.resetLoadingState(),s?(this.switchingTrack=n,this.flushAudioIfNeeded(n),this.state!==mt.STOPPED&&(this.setInterval(ef),this.state=mt.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=n,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(t,n){this.mainDetails=n.details;const s=this.cachedTrackLoadedData;s&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(S.AUDIO_TRACK_LOADED,s))}onAudioTrackLoaded(t,n){var s;const{levels:o}=this,{details:l,id:c,groupId:f,track:_}=n;if(!o){this.warn(`Audio tracks reset while loading track ${c} "${_.name}" of "${f}"`);return}const m=this.mainDetails;if(!m||l.endCC>m.endCC||m.expired){this.cachedTrackLoadedData=n,this.state!==mt.STOPPED&&(this.state=mt.WAITING_TRACK);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${c} "${_.name}" of "${f}" loaded [${l.startSN},${l.endSN}]${l.lastPartSn?`[part-${l.lastPartSn}-${l.lastPartIndex}]`:""},duration:${l.totalduration}`);const v=o[c];let y=0;if(l.live||(s=v.details)!=null&&s.live){if(this.checkLiveUpdate(l),l.deltaUpdateFailed)return;if(v.details){var x;y=this.alignPlaylists(l,v.details,(x=this.levelLastLoaded)==null?void 0:x.details)}l.alignedSliding||(Do(l,m),l.alignedSliding||Ea(l,m),y=l.fragmentStart)}v.details=l,this.levelLastLoaded=v,this.startFragRequested||this.setStartPosition(m,y),this.hls.trigger(S.AUDIO_TRACK_UPDATED,{details:l,id:c,groupId:n.groupId}),this.state===mt.WAITING_TRACK&&!this.waitForCdnTuneIn(l)&&(this.state=mt.IDLE),this.tick()}_handleFragmentLoadProgress(t){var n;const s=t.frag,{part:o,payload:l}=t,{config:c,trackId:f,levels:_}=this;if(!_){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${s.sn} of level ${s.level} will not be buffered`);return}const m=_[f];if(!m){this.warn("Audio track is undefined on fragment load progress");return}const v=m.details;if(!v){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(s.start);return}const y=c.defaultAudioCodec||m.audioCodec||"mp4a.40.2";let x=this.transmuxer;x||(x=this.transmuxer=new Qh(this.hls,P.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const D=this.initPTS[s.cc],C=(n=s.initSegment)==null?void 0:n.data;if(D!==void 0){const F=o?o.index:-1,Q=F!==-1,se=new Wr(s.level,s.sn,s.stats.chunkCount,l.byteLength,F,Q);x.push(l,C,y,"",s,o,v.totalduration,!1,se,D)}else{this.log(`Unknown video PTS for cc ${s.cc}, waiting for video PTS before demuxing audio frag ${s.sn} of [${v.startSN} ,${v.endSN}],track ${f}`);const{cache:B}=this.waitingData=this.waitingData||{frag:s,part:o,cache:new oc,complete:!1};B.push(new Uint8Array(l)),this.state!==mt.STOPPED&&(this.state=mt.WAITING_INIT_PTS)}}_handleFragmentLoadComplete(t){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(t,n){this.bufferFlushed=this.flushing=!1;const s=n.tracks.audio;s&&(this.mediaBuffer=s.buffer||null)}onFragLoading(t,n){!this.audioOnly&&n.frag.type===P.MAIN&&ze(n.frag)&&(this.mainFragLoading=n,this.state===mt.IDLE&&this.tick())}onFragBuffered(t,n){const{frag:s,part:o}=n;if(s.type!==P.AUDIO){!this.audioOnly&&s.type===P.MAIN&&!s.elementaryStreams.video&&!s.elementaryStreams.audiovideo&&(this.audioOnly=!0,this.mainFragLoading=null);return}if(this.fragContextChanged(s)){this.warn(`Fragment ${s.sn}${o?" p: "+o.index:""} of level ${s.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(ze(s)){this.fragPrevious=s;const l=this.switchingTrack;l&&(this.bufferedTrack=l,this.switchingTrack=null,this.hls.trigger(S.AUDIO_TRACK_SWITCHED,M({},l)))}this.fragBufferedComplete(s,o),this.media&&this.tick()}onError(t,n){var s;if(n.fatal){this.state=mt.ERROR;return}switch(n.details){case q.FRAG_GAP:case q.FRAG_PARSING_ERROR:case q.FRAG_DECRYPT_ERROR:case q.FRAG_LOAD_ERROR:case q.FRAG_LOAD_TIMEOUT:case q.KEY_LOAD_ERROR:case q.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(P.AUDIO,n);break;case q.AUDIO_TRACK_LOAD_ERROR:case q.AUDIO_TRACK_LOAD_TIMEOUT:case q.LEVEL_PARSING_ERROR:!n.levelRetry&&this.state===mt.WAITING_TRACK&&((s=n.context)==null?void 0:s.type)===Te.AUDIO_TRACK&&(this.state=mt.IDLE);break;case q.BUFFER_ADD_CODEC_ERROR:case q.BUFFER_APPEND_ERROR:if(n.parent!=="audio")return;this.reduceLengthAndFlushBuffer(n)||this.resetLoadingState();break;case q.BUFFER_FULL_ERROR:if(n.parent!=="audio")return;this.reduceLengthAndFlushBuffer(n)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case q.INTERNAL_EXCEPTION:this.recoverWorkerError(n);break}}onBufferFlushing(t,{type:n}){n!==V.VIDEO&&(this.flushing=!0)}onBufferFlushed(t,{type:n}){if(n!==V.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===mt.ENDED&&(this.state=mt.IDLE);const s=this.mediaBuffer||this.media;s&&(this.afterBufferFlushed(s,n,P.AUDIO),this.tick())}}_handleTransmuxComplete(t){var n;const s="audio",{hls:o}=this,{remuxResult:l,chunkMeta:c}=t,f=this.getCurrentContext(c);if(!f){this.resetWhenMissingContext(c);return}const{frag:_,part:m,level:v}=f,{details:y}=v,{audio:x,text:D,id3:C,initSegment:B}=l;if(this.fragContextChanged(_)||!y){this.fragmentTracker.removeFragment(_);return}if(this.state=mt.PARSING,this.switchingTrack&&x&&this.completeAudioSwitch(this.switchingTrack),B!=null&&B.tracks){const F=_.initSegment||_;if(this.unhandledEncryptionError(B,_))return;this._bufferInitSegment(v,B.tracks,F,c),o.trigger(S.FRAG_PARSING_INIT_SEGMENT,{frag:F,id:s,tracks:B.tracks})}if(x){const{startPTS:F,endPTS:Q,startDTS:se,endDTS:le}=x;m&&(m.elementaryStreams[V.AUDIO]={startPTS:F,endPTS:Q,startDTS:se,endDTS:le}),_.setElementaryStreamInfo(V.AUDIO,F,Q,se,le),this.bufferFragmentData(x,_,m,c)}if(C!=null&&(n=C.samples)!=null&&n.length){const F=k({id:s,frag:_,details:y},C);o.trigger(S.FRAG_PARSING_METADATA,F)}if(D){const F=k({id:s,frag:_,details:y},D);o.trigger(S.FRAG_PARSING_USERDATA,F)}}_bufferInitSegment(t,n,s,o){if(this.state!==mt.PARSING||(n.video&&delete n.video,n.audiovideo&&delete n.audiovideo,!n.audio))return;const l=n.audio;l.id=P.AUDIO;const c=t.audioCodec;this.log(`Init audio buffer, container:${l.container}, codecs[level/parsed]=[${c}/${l.codec}]`),c&&c.split(",").length===1&&(l.levelCodec=c),this.hls.trigger(S.BUFFER_CODECS,n);const f=l.initSegment;if(f!=null&&f.byteLength){const _={type:"audio",frag:s,part:null,chunkMeta:o,parent:s.type,data:f};this.hls.trigger(S.BUFFER_APPENDING,_)}this.tickImmediate()}loadFragment(t,n,s){const o=this.fragmentTracker.getState(t);if(this.switchingTrack||o===rn.NOT_LOADED||o===rn.PARTIAL){var l;if(!ze(t))this._loadInitSegment(t,n);else if((l=n.details)!=null&&l.live&&!this.initPTS[t.cc]){this.log(`Waiting for video PTS in continuity counter ${t.cc} of live stream before loading audio fragment ${t.sn} of level ${this.trackId}`),this.state=mt.WAITING_INIT_PTS;const c=this.mainDetails;c&&c.fragmentStart!==n.details.fragmentStart&&Ea(n.details,c)}else super.loadFragment(t,n,s)}else this.clearTrackerIfNeeded(t)}flushAudioIfNeeded(t){if(this.media&&this.bufferedTrack){const{name:n,lang:s,assocLang:o,characteristics:l,audioCodec:c,channels:f}=this.bufferedTrack;Bt({name:n,lang:s,assocLang:o,characteristics:l,audioCodec:c,channels:f},t,gi)||(Ai(t.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=t)}}completeAudioSwitch(t){const{hls:n}=this;this.flushAudioIfNeeded(t),this.bufferedTrack=t,this.switchingTrack=null,n.trigger(S.AUDIO_TRACK_SWITCHED,M({},t))}}class Mc extends H{constructor(t,n){super(n,t.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(t,n,s){const o=n==null?void 0:n.renditionReports;if(o){let l=-1;for(let c=0;c<o.length;c++){const f=o[c];let _;try{_=new self.URL(f.URI,n.url).href}catch(m){this.warn(`Could not construct new URL for Rendition Report: ${m}`),_=f.URI||""}if(_===t){l=c;break}else _===t.substring(0,_.length)&&(l=c)}if(l!==-1){const c=o[l],f=parseInt(c["LAST-MSN"])||n.lastPartSn;let _=parseInt(c["LAST-PART"])||n.lastPartIndex;if(this.hls.config.lowLatencyMode){const v=Math.min(n.age-n.partTarget,n.targetduration);_>=0&&v>n.partTarget&&(_+=1)}const m=s&&Dn(s);return new hn(f,_>=0?_:void 0,m)}}}loadPlaylist(t){this.clearTimer()}loadingPlaylist(t,n){this.clearTimer()}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}getUrlWithDirectives(t,n){if(n)try{return n.addDirectives(t)}catch(s){this.warn(`Could not construct new URL with HLS Delivery Directives: ${s}`)}return t}playlistLoaded(t,n,s){const{details:o,stats:l}=n,c=self.performance.now(),f=l.loading.first?Math.max(0,c-l.loading.first):0;o.advancedDateTime=Date.now()-f;const _=this.hls.config.timelineOffset;if(_!==o.appliedTimelineOffset){const v=Math.max(_||0,0);o.appliedTimelineOffset=v,o.fragments.forEach(y=>{y.setStart(y.playlistOffset+v)})}if(o.live||s!=null&&s.live){const v="levelInfo"in n?n.levelInfo:n.track;if(o.reloaded(s),s&&o.fragments.length>0){ll(s,o,this);const se=o.playlistParsingError;if(se){this.warn(se);const le=this.hls;if(!le.config.ignorePlaylistParsingErrors){var m;const{networkDetails:Ee}=n;le.trigger(S.ERROR,{type:ge.NETWORK_ERROR,details:q.LEVEL_PARSING_ERROR,fatal:!1,url:o.url,error:se,reason:se.message,level:n.level||void 0,parent:(m=o.fragments[0])==null?void 0:m.type,networkDetails:Ee,stats:l});return}o.playlistParsingError=null}}o.requestScheduled===-1&&(o.requestScheduled=l.loading.start);const y=this.hls.mainForwardBufferInfo,x=y?y.end-y.len:0,D=(o.edge-x)*1e3,C=Fs(o,D);if(o.requestScheduled+C<c?o.requestScheduled=c:o.requestScheduled+=C,this.log(`live playlist ${t} ${o.advanced?"REFRESHED "+o.lastPartSn+"-"+o.lastPartIndex:o.updated?"UPDATED":"MISSED"}`),!this.canLoad||!o.live)return;let B,F,Q;if(o.canBlockReload&&o.endSN&&o.advanced){const se=this.hls.config.lowLatencyMode,le=o.lastPartSn,Ee=o.endSN,Ie=o.lastPartIndex,Qe=Ie!==-1,Pe=le===Ee;Qe?Pe?(F=Ee+1,Q=se?0:Ie):(F=le,Q=se?Ie+1:o.maxPartIndex):F=Ee+1;const Ze=o.age,He=Ze+o.ageHeader;let Fe=Math.min(He-o.partTarget,o.targetduration*1.5);if(Fe>0){if(He>o.targetduration*3)this.log(`Playlist last advanced ${Ze.toFixed(2)}s ago. Omitting segment and part directives.`),F=void 0,Q=void 0;else if(s!=null&&s.tuneInGoal&&He-o.partTarget>s.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${s.tuneInGoal} to: ${Fe} with playlist age: ${o.age}`),Fe=0;else{const bt=Math.floor(Fe/o.targetduration);if(F+=bt,Q!==void 0){const Xt=Math.round(Fe%o.targetduration/o.partTarget);Q+=Xt}this.log(`CDN Tune-in age: ${o.ageHeader}s last advanced ${Ze.toFixed(2)}s goal: ${Fe} skip sn ${bt} to part ${Q}`)}o.tuneInGoal=Fe}if(B=this.getDeliveryDirectives(o,n.deliveryDirectives,F,Q),se||!Pe){o.requestScheduled=c,this.loadingPlaylist(v,B);return}}else(o.canBlockReload||o.canSkipUntil)&&(B=this.getDeliveryDirectives(o,n.deliveryDirectives,F,Q));B&&F!==void 0&&o.canBlockReload&&(o.requestScheduled=l.loading.first+Math.max(C-f*2,C/2)),this.scheduleLoading(v,B,o)}else this.clearTimer()}scheduleLoading(t,n,s){const o=s||t.details;if(!o){this.loadingPlaylist(t,n);return}const l=self.performance.now(),c=o.requestScheduled;if(l>=c){this.loadingPlaylist(t,n);return}const f=c-l;this.log(`reload live playlist ${t.name||t.bitrate+"bps"} in ${Math.round(f)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(t,n),f)}getDeliveryDirectives(t,n,s,o){let l=Dn(t);return n!=null&&n.skip&&t.deltaUpdateFailed&&(s=n.msn,o=n.part,l=Ri.No),new hn(s,o,l)}checkRetry(t){const n=t.details,s=ji(t),o=t.errorAction,{action:l,retryCount:c=0,retryConfig:f}=o||{},_=!!o&&!!f&&(l===Ui.RetryRequest||!o.resolved&&l===Ui.SendAlternateToPenaltyBox);if(_){var m;if(c>=f.maxNumRetry)return!1;if(s&&(m=t.context)!=null&&m.deliveryDirectives)this.warn(`Retrying playlist loading ${c+1}/${f.maxNumRetry} after "${n}" without delivery-directives`),this.loadPlaylist();else{const v=tn(f,c);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),v),this.warn(`Retrying playlist loading ${c+1}/${f.maxNumRetry} after "${n}" in ${v}ms`)}t.levelRetry=!0,o.resolved=!0}return _}}function gl(h,t){if(h.length!==t.length)return!1;for(let n=0;n<h.length;n++)if(!Fo(h[n].attrs,t[n].attrs))return!1;return!0}function Fo(h,t,n){const s=h["STABLE-RENDITION-ID"];return s&&!n?s===t["STABLE-RENDITION-ID"]:!(n||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(o=>h[o]!==t[o])}function gu(h,t){return t.label.toLowerCase()===h.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(h.lang||"").toLowerCase())}class ld extends Mc{constructor(t){super(t,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_PARSED,this.onManifestParsed,this),t.on(S.LEVEL_LOADING,this.onLevelLoading,this),t.on(S.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(S.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(S.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_PARSED,this.onManifestParsed,this),t.off(S.LEVEL_LOADING,this.onLevelLoading,this),t.off(S.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(S.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(S.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(t,n){this.tracks=n.audioTracks||[]}onAudioTrackLoaded(t,n){const{id:s,groupId:o,details:l}=n,c=this.tracksInGroup[s];if(!c||c.groupId!==o){this.warn(`Audio track with id:${s} and group:${o} not found in active group ${c==null?void 0:c.groupId}`);return}const f=c.details;c.details=n.details,this.log(`Audio track ${s} "${c.name}" lang:${c.lang} group:${o} loaded [${l.startSN}-${l.endSN}]`),s===this.trackId&&this.playlistLoaded(s,n,f)}onLevelLoading(t,n){this.switchLevel(n.level)}onLevelSwitching(t,n){this.switchLevel(n.level)}switchLevel(t){const n=this.hls.levels[t];if(!n)return;const s=n.audioGroups||null,o=this.groupIds;let l=this.currentTrack;if(!s||(o==null?void 0:o.length)!==(s==null?void 0:s.length)||s!=null&&s.some(f=>(o==null?void 0:o.indexOf(f))===-1)){this.groupIds=s,this.trackId=-1,this.currentTrack=null;const f=this.tracks.filter(x=>!s||s.indexOf(x.groupId)!==-1);if(f.length)this.selectDefaultTrack&&!f.some(x=>x.default)&&(this.selectDefaultTrack=!1),f.forEach((x,D)=>{x.id=D});else if(!l&&!this.tracksInGroup.length)return;this.tracksInGroup=f;const _=this.hls.config.audioPreference;if(!l&&_){const x=St(_,f,gi);if(x>-1)l=f[x];else{const D=St(_,this.tracks);l=this.tracks[D]}}let m=this.findTrackId(l);m===-1&&l&&(m=this.findTrackId(null));const v={audioTracks:f};this.log(`Updating audio tracks, ${f.length} track(s) found in group(s): ${s==null?void 0:s.join(",")}`),this.hls.trigger(S.AUDIO_TRACKS_UPDATED,v);const y=this.trackId;if(m!==-1&&y===-1)this.setAudioTrack(m);else if(f.length&&y===-1){var c;const x=new Error(`No audio track selected for current audio group-ID(s): ${(c=this.groupIds)==null?void 0:c.join(",")} track count: ${f.length}`);this.warn(x.message),this.hls.trigger(S.ERROR,{type:ge.MEDIA_ERROR,details:q.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:x})}}}onError(t,n){n.fatal||!n.context||n.context.type===Te.AUDIO_TRACK&&n.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(n.context.groupId)!==-1)&&this.checkRetry(n)}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}setAudioOption(t){const n=this.hls;if(n.config.audioPreference=t,t){const s=this.allAudioTracks;if(this.selectDefaultTrack=!1,s.length){const o=this.currentTrack;if(o&&Bt(t,o,gi))return o;const l=St(t,this.tracksInGroup,gi);if(l>-1){const c=this.tracksInGroup[l];return this.setAudioTrack(l),c}else if(o){let c=n.loadLevel;c===-1&&(c=n.firstAutoLevel);const f=dn(t,n.levels,s,c,gi);if(f===-1)return null;n.nextLoadLevel=f}if(t.channels||t.audioCodec){const c=St(t,s);if(c>-1)return s[c]}}}return null}setAudioTrack(t){const n=this.tracksInGroup;if(t<0||t>=n.length){this.warn(`Invalid audio track id: ${t}`);return}this.selectDefaultTrack=!1;const s=this.currentTrack,o=n[t],l=o.details&&!o.details.live;if(t===this.trackId&&o===s&&l||(this.log(`Switching to audio-track ${t} "${o.name}" lang:${o.lang} group:${o.groupId} channels:${o.channels}`),this.trackId=t,this.currentTrack=o,this.hls.trigger(S.AUDIO_TRACK_SWITCHING,M({},o)),l))return;const c=this.switchParams(o.url,s==null?void 0:s.details,o.details);this.loadPlaylist(c)}findTrackId(t){const n=this.tracksInGroup;for(let s=0;s<n.length;s++){const o=n[s];if(!(this.selectDefaultTrack&&!o.default)&&(!t||Bt(t,o,gi)))return s}if(t){const{name:s,lang:o,assocLang:l,characteristics:c,audioCodec:f,channels:_}=t;for(let m=0;m<n.length;m++){const v=n[m];if(Bt({name:s,lang:o,assocLang:l,characteristics:c,audioCodec:f,channels:_},v,gi))return m}for(let m=0;m<n.length;m++){const v=n[m];if(Fo(t.attrs,v.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return m}for(let m=0;m<n.length;m++){const v=n[m];if(Fo(t.attrs,v.attrs,["LANGUAGE"]))return m}}return-1}loadPlaylist(t){super.loadPlaylist();const n=this.currentTrack;this.shouldLoadPlaylist(n)&&Ai(n.url,this.hls)&&this.scheduleLoading(n,t)}loadingPlaylist(t,n){super.loadingPlaylist(t,n);const s=t.id,o=t.groupId,l=this.getUrlWithDirectives(t.url,n),c=t.details,f=c==null?void 0:c.age;this.log(`Loading audio-track ${s} "${t.name}" lang:${t.lang} group:${o}${(n==null?void 0:n.msn)!==void 0?" at sn "+n.msn+" part "+n.part:""}${f&&c.live?" age "+f.toFixed(1)+(c.type?" "+c.type||0:""):""} ${l}`),this.hls.trigger(S.AUDIO_TRACK_LOADING,{url:l,id:s,groupId:o,deliveryDirectives:n||null,track:t})}}class tf{constructor(t){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=t}destroy(){this.tracks=this.queues=null}append(t,n,s){if(this.queues===null||this.tracks===null)return;const o=this.queues[n];o.push(t),o.length===1&&!s&&this.executeNext(n)}appendBlocker(t){return new Promise(n=>{const s={label:"async-blocker",execute:n,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(s,t)})}prependBlocker(t){return new Promise(n=>{if(this.queues){const s={label:"async-blocker-prepend",execute:n,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[t].unshift(s)}})}removeBlockers(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(t=>{var n;const s=(n=t[0])==null?void 0:n.label;(s==="async-blocker"||s==="async-blocker-prepend")&&(t[0].execute(),t.splice(0,1))})}unblockAudio(t){if(this.queues===null)return;this.queues.audio[0]===t&&this.shiftAndExecuteNext("audio")}executeNext(t){if(this.queues===null||this.tracks===null)return;const n=this.queues[t];if(n.length){const o=n[0];try{o.execute()}catch(l){var s;if(o.onError(l),this.queues===null||this.tracks===null)return;const c=(s=this.tracks[t])==null?void 0:s.buffer;c!=null&&c.updating||this.shiftAndExecuteNext(t)}}}shiftAndExecuteNext(t){this.queues!==null&&(this.queues[t].shift(),this.executeNext(t))}current(t){var n;return((n=this.queues)==null?void 0:n[t][0])||null}toString(){const{queues:t,tracks:n}=this;return t===null||n===null?"<destroyed>":`
${this.list("video")}
${this.list("audio")}
${this.list("audiovideo")}}`}list(t){var n,s;return(n=this.queues)!=null&&n[t]||(s=this.tracks)!=null&&s[t]?`${t}: (${this.listSbInfo(t)}) ${this.listOps(t)}`:""}listSbInfo(t){var n;const s=(n=this.tracks)==null?void 0:n[t],o=s==null?void 0:s.buffer;return o?`SourceBuffer${o.updating?" updating":""}${s.ended?" ended":""}${s.ending?" ending":""}`:"none"}listOps(t){var n;return((n=this.queues)==null?void 0:n[t].map(s=>s.label).join(", "))||""}}const nf=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,rf="HlsJsTrackRemovedError";class _u extends Error{constructor(t){super(t),this.name=rf}}class sn extends H{constructor(t,n){super("buffer-controller",t.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=s=>{var o;this.hls&&((o=this.mediaSource)==null?void 0:o.readyState)==="open"&&this.hls.pauseBuffering()},this._onStartStreaming=s=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=s=>{const{media:o,mediaSource:l}=this;s&&this.log("Media source opened"),!(!o||!l)&&(l.removeEventListener("sourceopen",this._onMediaSourceOpen),o.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(S.MEDIA_ATTACHED,{media:o,mediaSource:l}),this.mediaSource!==null&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:s,_objectUrl:o}=this;s!==o&&this.error(`Media element src was set while attaching MediaSource (${o} > ${s})`)},this.hls=t,this.fragmentTracker=n,this.appendSource=We(Oe(t.config.preferManagedMediaSource)),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}registerListeners(){const{hls:t}=this;t.on(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_PARSED,this.onManifestParsed,this),t.on(S.BUFFER_RESET,this.onBufferReset,this),t.on(S.BUFFER_APPENDING,this.onBufferAppending,this),t.on(S.BUFFER_CODECS,this.onBufferCodecs,this),t.on(S.BUFFER_EOS,this.onBufferEos,this),t.on(S.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(S.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(S.FRAG_PARSED,this.onFragParsed,this),t.on(S.FRAG_CHANGED,this.onFragChanged,this),t.on(S.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_PARSED,this.onManifestParsed,this),t.off(S.BUFFER_RESET,this.onBufferReset,this),t.off(S.BUFFER_APPENDING,this.onBufferAppending,this),t.off(S.BUFFER_CODECS,this.onBufferCodecs,this),t.off(S.BUFFER_EOS,this.onBufferEos,this),t.off(S.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(S.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(S.FRAG_PARSED,this.onFragParsed,this),t.off(S.FRAG_CHANGED,this.onFragChanged,this),t.off(S.ERROR,this.onError,this)}transferMedia(){const{media:t,mediaSource:n}=this;if(!t)return null;const s={};if(this.operationQueue){const l=this.isUpdating();l||this.operationQueue.removeBlockers();const c=this.isQueued();(l||c)&&this.warn(`Transfering MediaSource with${c?" operations in queue":""}${l?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const o=this.transferData;return!this.sourceBufferCount&&o&&o.mediaSource===n?k(s,o.tracks):this.sourceBuffers.forEach(l=>{const[c]=l;c&&(s[c]=k({},this.tracks[c]),this.removeBuffer(c)),l[0]=l[1]=null}),{media:t,mediaSource:n,tracks:s}}initTracks(){const t={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=t,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(t,n){var s;let o=2;(n.audio&&!n.video||!n.altAudio)&&(o=1),this.bufferCodecEventsTotal=o,this.log(`${o} bufferCodec event(s) expected.`),(s=this.transferData)!=null&&s.mediaSource&&this.sourceBufferCount&&o&&this.bufferCreated()}onMediaAttaching(t,n){const s=this.media=n.media;this.transferData=this.overrides=void 0;const o=Oe(this.appendSource);if(o){const l=!!n.mediaSource;(l||n.overrides)&&(this.transferData=n,this.overrides=n.overrides);const c=this.mediaSource=n.mediaSource||new o;if(this.assignMediaSource(c),l)this._objectUrl=s.src,this.attachTransferred();else{const f=this._objectUrl=self.URL.createObjectURL(c);if(this.appendSource)try{s.removeAttribute("src");const _=self.ManagedMediaSource;s.disableRemotePlayback=s.disableRemotePlayback||_&&c instanceof _,jn(s),no(s,f),s.load()}catch(_){s.src=f}else s.src=f}s.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(t){var n,s;this.log(`${((n=this.transferData)==null?void 0:n.mediaSource)===t?"transferred":"created"} media source: ${(s=t.constructor)==null?void 0:s.name}`),t.addEventListener("sourceopen",this._onMediaSourceOpen),t.addEventListener("sourceended",this._onMediaSourceEnded),t.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.addEventListener("startstreaming",this._onStartStreaming),t.addEventListener("endstreaming",this._onEndStreaming))}attachTransferred(){const t=this.media,n=this.transferData;if(!n||!t)return;const s=this.tracks,o=n.tracks,l=o?Object.keys(o):null,c=l?l.length:0,f=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(o&&l&&c){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})
required tracks: ${$t(s,(_,m)=>_==="initSegment"?void 0:m)};
transfer tracks: ${$t(o,(_,m)=>_==="initSegment"?void 0:m)}}`),!Be(o,s)){n.mediaSource=null,n.tracks=void 0;const _=t.currentTime,m=this.details,v=Math.max(_,(m==null?void 0:m.fragments[0].start)||0);if(v-_>1){this.log(`attachTransferred: waiting for playback to reach new tracks start time ${_} -> ${v}`);return}this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(o)}"->"${Object.keys(s)}") start time: ${v} currentTime: ${_}`),this.onMediaDetaching(S.MEDIA_DETACHING,{}),this.onMediaAttaching(S.MEDIA_ATTACHING,n),t.currentTime=v;return}this.transferData=void 0,l.forEach(_=>{const m=_,v=o[m];if(v){const y=v.buffer;if(y){const x=this.fragmentTracker,D=v.id;if(x.hasFragments(D)||x.hasParts(D)){const F=Wt.getBuffered(y);x.detectEvictedFragments(m,F,D,null,!0)}const C=vu(m),B=[m,y];this.sourceBuffers[C]=B,y.updating&&this.operationQueue&&this.operationQueue.prependBlocker(m),this.trackSourceBuffer(m,v)}}}),f(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),f()}get mediaSourceOpenOrEnded(){var t;const n=(t=this.mediaSource)==null?void 0:t.readyState;return n==="open"||n==="ended"}onMediaDetaching(t,n){const s=!!n.transferMedia;this.transferData=this.overrides=void 0;const{media:o,mediaSource:l,_objectUrl:c}=this;if(l){if(this.log(`media source ${s?"transferring":"detaching"}`),s)this.sourceBuffers.forEach(([f])=>{f&&this.removeBuffer(f)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const f=l.readyState==="open";try{const _=l.sourceBuffers;for(let m=_.length;m--;)f&&_[m].abort(),l.removeSourceBuffer(_[m]);f&&l.endOfStream()}catch(_){this.warn(`onMediaDetaching: ${_.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}l.removeEventListener("sourceopen",this._onMediaSourceOpen),l.removeEventListener("sourceended",this._onMediaSourceEnded),l.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(l.removeEventListener("startstreaming",this._onStartStreaming),l.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}o&&(o.removeEventListener("emptied",this._onMediaEmptied),s||(c&&self.URL.revokeObjectURL(c),this.mediaSrc===c?(o.removeAttribute("src"),this.appendSource&&jn(o),o.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(S.MEDIA_DETACHED,n)}onBufferReset(){this.sourceBuffers.forEach(([t])=>{t&&this.resetBuffer(t)}),this.initTracks()}resetBuffer(t){var n;const s=(n=this.tracks[t])==null?void 0:n.buffer;if(this.removeBuffer(t),s)try{var o;(o=this.mediaSource)!=null&&o.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(s)}catch(l){this.warn(`onBufferReset ${t}`,l)}delete this.tracks[t]}removeBuffer(t){this.removeBufferListeners(t),this.sourceBuffers[vu(t)]=[null,null];const n=this.tracks[t];n&&(n.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new tf(this.tracks)}onBufferCodecs(t,n){var s;const o=this.tracks,l=Object.keys(n);this.log(`BUFFER_CODECS: "${l}" (current SB count ${this.sourceBufferCount})`);const c="audiovideo"in n&&(o.audio||o.video)||o.audiovideo&&("audio"in n||"video"in n),f=!c&&this.sourceBufferCount&&this.media&&l.some(_=>!o[_]);if(c||f){this.warn(`Unsupported transition between "${Object.keys(o)}" and "${l}" SourceBuffers`);return}l.forEach(_=>{var m,v;const y=n[_],{id:x,codec:D,levelCodec:C,container:B,metadata:F,supplemental:Q}=y;let se=o[_];const le=(m=this.transferData)==null||(m=m.tracks)==null?void 0:m[_],Ee=le!=null&&le.buffer?le:se,Ie=(Ee==null?void 0:Ee.pendingCodec)||(Ee==null?void 0:Ee.codec),Qe=Ee==null?void 0:Ee.levelCodec;se||(se=o[_]={buffer:void 0,listeners:[],codec:D,supplemental:Q,container:B,levelCodec:C,metadata:F,id:x});const Pe=ot(Ie,Qe),Ze=Pe==null?void 0:Pe.replace(nf,"$1");let He=ot(D,C);const Fe=(v=He)==null?void 0:v.replace(nf,"$1");He&&Pe&&Ze!==Fe&&(_.slice(0,5)==="audio"&&(He=_e(He,this.appendSource)),this.log(`switching codec ${Ie} to ${He}`),He!==(se.pendingCodec||se.codec)&&(se.pendingCodec=He),se.container=B,this.appendChangeType(_,B,He))}),(this.tracksReady||this.sourceBufferCount)&&(n.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!n.video&&((s=n.audio)==null?void 0:s.id)==="main"&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((t,n)=>{const s=this.tracks[n];return t[n]={id:s.id,container:s.container,codec:s.codec,levelCodec:s.levelCodec},t},{})}appendChangeType(t,n,s){const o=`${n};codecs=${s}`,l={label:`change-type=${o}`,execute:()=>{const c=this.tracks[t];if(c){const f=c.buffer;f!=null&&f.changeType&&(this.log(`changing ${t} sourceBuffer type to ${o}`),f.changeType(o),c.codec=s,c.container=n)}this.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:c=>{this.warn(`Failed to change ${t} SourceBuffer type`,c)}};this.append(l,t,this.isPending(this.tracks[t]))}blockAudio(t){var n;const s=t.start,o=s+t.duration*.05;if(((n=this.fragmentTracker.getAppendedFrag(s,P.MAIN))==null?void 0:n.gap)===!0)return;const c={label:"block-audio",execute:()=>{var f;const _=this.tracks.video;(this.lastVideoAppendEnd>o||_!=null&&_.buffer&&Wt.isBuffered(_.buffer,o)||((f=this.fragmentTracker.getAppendedFrag(o,P.MAIN))==null?void 0:f.gap)===!0)&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:f=>{this.warn("Error executing block-audio operation",f)}};this.blockedAudioAppend={op:c,frag:t},this.append(c,"audio",!0)}unblockAudio(){const{blockedAudioAppend:t,operationQueue:n}=this;t&&n&&(this.blockedAudioAppend=null,n.unblockAudio(t.op))}onBufferAppending(t,n){const{tracks:s}=this,{data:o,type:l,parent:c,frag:f,part:_,chunkMeta:m,offset:v}=n,y=m.buffering[l],{sn:x,cc:D}=f,C=self.performance.now();y.start=C;const B=f.stats.buffering,F=_?_.stats.buffering:null;B.start===0&&(B.start=C),F&&F.start===0&&(F.start=C);const Q=s.audio;let se=!1;l==="audio"&&(Q==null?void 0:Q.container)==="audio/mpeg"&&(se=!this.lastMpegAudioChunk||m.id===1||this.lastMpegAudioChunk.sn!==m.sn,this.lastMpegAudioChunk=m);const le=s.video,Ee=le==null?void 0:le.buffer;if(Ee&&x!=="initSegment"){const Pe=_||f,Ze=this.blockedAudioAppend;if(l==="audio"&&c!=="main"&&!this.blockedAudioAppend&&!(le.ending||le.ended)){const Fe=Pe.start+Pe.duration*.05,bt=Ee.buffered,Xt=this.currentOp("video");!bt.length&&!Xt?this.blockAudio(Pe):!Xt&&!Wt.isBuffered(Ee,Fe)&&this.lastVideoAppendEnd<Fe&&this.blockAudio(Pe)}else if(l==="video"){const He=Pe.end;if(Ze){const Fe=Ze.frag.start;(He>Fe||He<this.lastVideoAppendEnd||Wt.isBuffered(Ee,Fe))&&this.unblockAudio()}this.lastVideoAppendEnd=He}}const Ie=(_||f).start,Qe={label:`append-${l}`,execute:()=>{var Pe;y.executeStart=self.performance.now();const Ze=(Pe=this.tracks[l])==null?void 0:Pe.buffer;Ze&&(se?this.updateTimestampOffset(Ze,Ie,.1,l,x,D):v!==void 0&&ce(v)&&this.updateTimestampOffset(Ze,v,1e-6,l,x,D)),this.appendExecutor(o,l)},onStart:()=>{},onComplete:()=>{const Pe=self.performance.now();y.executeEnd=y.end=Pe,B.first===0&&(B.first=Pe),F&&F.first===0&&(F.first=Pe);const Ze={};this.sourceBuffers.forEach(([He,Fe])=>{He&&(Ze[He]=Wt.getBuffered(Fe))}),this.appendErrors[l]=0,l==="audio"||l==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(S.BUFFER_APPENDED,{type:l,frag:f,part:_,chunkMeta:m,parent:f.type,timeRanges:Ze})},onError:Pe=>{var Ze;const He={type:ge.MEDIA_ERROR,parent:f.type,details:q.BUFFER_APPEND_ERROR,sourceBufferName:l,frag:f,part:_,chunkMeta:m,error:Pe,err:Pe,fatal:!1},Fe=(Ze=this.media)==null?void 0:Ze.error;if(Pe.code===DOMException.QUOTA_EXCEEDED_ERR||Pe.name=="QuotaExceededError"||"quota"in Pe)He.details=q.BUFFER_FULL_ERROR;else if(Pe.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!Fe)He.errorAction=bn(!0);else if(Pe.name===rf&&this.sourceBufferCount===0)He.errorAction=bn(!0);else{const bt=++this.appendErrors[l];this.warn(`Failed ${bt}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${l}" sourceBuffer (${Fe||"no media error"})`),(bt>=this.hls.config.appendErrorMaxRetry||Fe)&&(He.fatal=!0)}this.hls.trigger(S.ERROR,He)}};this.log(`queuing "${l}" append sn: ${x}${_?" p: "+_.index:""} of ${f.type===P.MAIN?"level":"track"} ${f.level} cc: ${D}`),this.append(Qe,l,this.isPending(this.tracks[l]))}getFlushOp(t,n,s){return this.log(`queuing "${t}" remove ${n}-${s}`),{label:"remove",execute:()=>{this.removeExecutor(t,n,s)},onStart:()=>{},onComplete:()=>{this.hls.trigger(S.BUFFER_FLUSHED,{type:t})},onError:o=>{this.warn(`Failed to remove ${n}-${s} from "${t}" SourceBuffer`,o)}}}onBufferFlushing(t,n){const{type:s,startOffset:o,endOffset:l}=n;s?this.append(this.getFlushOp(s,o,l),s):this.sourceBuffers.forEach(([c])=>{c&&this.append(this.getFlushOp(c,o,l),c)})}onFragParsed(t,n){const{frag:s,part:o}=n,l=[],c=o?o.elementaryStreams:s.elementaryStreams;c[V.AUDIOVIDEO]?l.push("audiovideo"):(c[V.AUDIO]&&l.push("audio"),c[V.VIDEO]&&l.push("video"));const f=()=>{const _=self.performance.now();s.stats.buffering.end=_,o&&(o.stats.buffering.end=_);const m=o?o.stats:s.stats;this.hls.trigger(S.FRAG_BUFFERED,{frag:s,part:o,stats:m,id:s.type})};l.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${s.type} level: ${s.level} sn: ${s.sn}`),this.blockBuffers(f,l).catch(_=>{this.warn(`Fragment buffered callback ${_}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(t,n){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([t])=>{if(t){const n=this.tracks[t];if(n)return!n.ended||n.ending}return!1})}onBufferEos(t,n){var s;this.sourceBuffers.forEach(([c])=>{if(c){const f=this.tracks[c];(!n.type||n.type===c)&&(f.ending=!0,f.ended||(f.ended=!0,this.log(`${c} buffer reached EOS`)))}});const o=((s=this.overrides)==null?void 0:s.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(([c])=>{var f;return c&&!((f=this.tracks[c])!=null&&f.ended)})?o?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:c}=this;if(!c||c.readyState!=="open"){c&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${c.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),c.endOfStream(),this.hls.trigger(S.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(S.BUFFERED_TO_END,void 0)):n.type==="video"&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([t])=>{if(t!==null){const n=this.tracks[t];n&&(n.ending=!1)}})}onLevelUpdated(t,{details:n}){n.fragments.length&&(this.details=n,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{const t=this.getDurationAndRange();t&&this.updateMediaSource(t)})}onError(t,n){if(n.details===q.BUFFER_APPEND_ERROR&&n.frag){var s;const o=(s=n.errorAction)==null?void 0:s.nextAutoLevel;ce(o)&&o!==n.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){const{hls:t,details:n,media:s}=this;if(!s||n===null||!this.sourceBufferCount)return;const o=t.config,l=s.currentTime,c=n.levelTargetDuration,f=n.live&&o.liveBackBufferLength!==null?o.liveBackBufferLength:o.backBufferLength;if(ce(f)&&f>=0){const m=Math.max(f,c),v=Math.floor(l/c)*c-m;this.flushBackBuffer(l,c,v)}const _=o.frontBufferFlushThreshold;if(ce(_)&&_>0){const m=Math.max(o.maxBufferLength,_),v=Math.max(m,c),y=Math.floor(l/c)*c+v;this.flushFrontBuffer(l,c,y)}}flushBackBuffer(t,n,s){this.sourceBuffers.forEach(([o,l])=>{if(l){const f=Wt.getBuffered(l);if(f.length>0&&s>f.start(0)){var c;this.hls.trigger(S.BACK_BUFFER_REACHED,{bufferEnd:s});const _=this.tracks[o];if((c=this.details)!=null&&c.live)this.hls.trigger(S.LIVE_BACK_BUFFER_REACHED,{bufferEnd:s});else if(_!=null&&_.ended){this.log(`Cannot flush ${o} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(S.BUFFER_FLUSHING,{startOffset:0,endOffset:s,type:o})}}})}flushFrontBuffer(t,n,s){this.sourceBuffers.forEach(([o,l])=>{if(l){const c=Wt.getBuffered(l),f=c.length;if(f<2)return;const _=c.start(f-1),m=c.end(f-1);if(s>_||t>=_&&t<=m)return;this.hls.trigger(S.BUFFER_FLUSHING,{startOffset:_,endOffset:1/0,type:o})}})}getDurationAndRange(){var t;const{details:n,mediaSource:s}=this;if(!n||!this.media||(s==null?void 0:s.readyState)!=="open")return null;const o=n.edge;if(n.live&&this.hls.config.liveDurationInfinity){if(n.fragments.length&&s.setLiveSeekableRange){const m=Math.max(0,n.fragmentStart),v=Math.max(m,o);return{duration:1/0,start:m,end:v}}return{duration:1/0}}const l=(t=this.overrides)==null?void 0:t.duration;if(l)return ce(l)?{duration:l}:null;const c=this.media.duration,f=ce(s.duration)?s.duration:0;return o>f&&o>c||!ce(c)?{duration:o}:null}updateMediaSource({duration:t,start:n,end:s}){const o=this.mediaSource;!this.media||!o||o.readyState!=="open"||(o.duration!==t&&(ce(t)&&this.log(`Updating MediaSource duration to ${t.toFixed(3)}`),o.duration=t),n!==void 0&&s!==void 0&&(this.log(`MediaSource duration is set to ${o.duration}. Setting seekable range to ${n}-${s}.`),o.setLiveSeekableRange(n,s)))}get tracksReady(){const t=this.pendingTrackCount;return t>0&&(t>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:t,pendingTrackCount:n,tracks:s}=this;if(this.log(`checkPendingTracks (pending: ${n} codec events expected: ${t}) ${$t(s)}`),this.tracksReady){var o;const l=(o=this.transferData)==null?void 0:o.tracks;l&&Object.keys(l).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const t={};this.sourceBuffers.forEach(([n,s])=>{if(n){const o=this.tracks[n];t[n]={buffer:s,container:o.container,codec:o.codec,supplemental:o.supplemental,levelCodec:o.levelCodec,id:o.id,metadata:o.metadata}}}),this.hls.trigger(S.BUFFER_CREATED,{tracks:t}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([n])=>{this.executeNext(n)})}else{const t=new Error("could not create source buffer for media codec(s)");this.hls.trigger(S.ERROR,{type:ge.MEDIA_ERROR,details:q.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:t,reason:t.message})}}createSourceBuffers(){const{tracks:t,sourceBuffers:n,mediaSource:s}=this;if(!s)throw new Error("createSourceBuffers called when mediaSource was null");for(const l in t){const c=l,f=t[c];if(this.isPending(f)){const _=this.getTrackCodec(f,c),m=`${f.container};codecs=${_}`;f.codec=_,this.log(`creating sourceBuffer(${m})${this.currentOp(c)?" Queued":""} ${$t(f)}`);try{const v=s.addSourceBuffer(m),y=vu(c),x=[c,v];n[y]=x,f.buffer=v}catch(v){var o;this.error(`error while trying to add sourceBuffer: ${v.message}`),this.shiftAndExecuteNext(c),(o=this.operationQueue)==null||o.removeBlockers(),delete this.tracks[c],this.hls.trigger(S.ERROR,{type:ge.MEDIA_ERROR,details:q.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:v,sourceBufferName:c,mimeType:m,parent:f.id});return}this.trackSourceBuffer(c,f)}}this.bufferCreated()}getTrackCodec(t,n){const s=t.supplemental;let o=t.codec;s&&(n==="video"||n==="audiovideo")&&Ft(s,"video")&&(o=st(o,s));const l=ot(o,t.levelCodec);return l?n.slice(0,5)==="audio"?_e(l,this.appendSource):l:""}trackSourceBuffer(t,n){const s=n.buffer;if(!s)return;const o=this.getTrackCodec(n,t);this.tracks[t]={buffer:s,codec:o,container:n.container,levelCodec:n.levelCodec,supplemental:n.supplemental,metadata:n.metadata,id:n.id,listeners:[]},this.removeBufferListeners(t),this.addBufferListener(t,"updatestart",this.onSBUpdateStart),this.addBufferListener(t,"updateend",this.onSBUpdateEnd),this.addBufferListener(t,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(t,"bufferedchange",(l,c)=>{const f=c.removedRanges;f!=null&&f.length&&this.hls.trigger(S.BUFFER_FLUSHED,{type:l})})}get mediaSrc(){var t,n;const s=((t=this.media)==null||(n=t.querySelector)==null?void 0:n.call(t,"source"))||this.media;return s==null?void 0:s.src}onSBUpdateStart(t){const n=this.currentOp(t);n&&n.onStart()}onSBUpdateEnd(t){var n;if(((n=this.mediaSource)==null?void 0:n.readyState)==="closed"){this.resetBuffer(t);return}const s=this.currentOp(t);s&&(s.onComplete(),this.shiftAndExecuteNext(t))}onSBUpdateError(t,n){var s;const o=new Error(`${t} SourceBuffer error. MediaSource readyState: ${(s=this.mediaSource)==null?void 0:s.readyState}`);this.error(`${o}`,n),this.hls.trigger(S.ERROR,{type:ge.MEDIA_ERROR,details:q.BUFFER_APPENDING_ERROR,sourceBufferName:t,error:o,fatal:!1});const l=this.currentOp(t);l&&l.onError(o)}updateTimestampOffset(t,n,s,o,l,c){const f=n-t.timestampOffset;Math.abs(f)>=s&&(this.log(`Updating ${o} SourceBuffer timestampOffset to ${n} (sn: ${l} cc: ${c})`),t.timestampOffset=n)}removeExecutor(t,n,s){const{media:o,mediaSource:l}=this,c=this.tracks[t],f=c==null?void 0:c.buffer;if(!o||!l||!f){this.warn(`Attempting to remove from the ${t} SourceBuffer, but it does not exist`),this.shiftAndExecuteNext(t);return}const _=ce(o.duration)?o.duration:1/0,m=ce(l.duration)?l.duration:1/0,v=Math.max(0,n),y=Math.min(s,_,m);y>v&&(!c.ending||c.ended)?(c.ended=!1,this.log(`Removing [${v},${y}] from the ${t} SourceBuffer`),f.remove(v,y)):this.shiftAndExecuteNext(t)}appendExecutor(t,n){const s=this.tracks[n],o=s==null?void 0:s.buffer;if(!o)throw new _u(`Attempting to append to the ${n} SourceBuffer, but it does not exist`);s.ending=!1,s.ended=!1,o.appendBuffer(t)}blockUntilOpen(t){if(this.isUpdating()||this.isQueued())this.blockBuffers(t).catch(n=>{this.warn(`SourceBuffer blocked callback ${n}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{t()}catch(n){this.warn(`Callback run without blocking ${this.operationQueue} ${n}`)}}isUpdating(){return this.sourceBuffers.some(([t,n])=>t&&n.updating)}isQueued(){return this.sourceBuffers.some(([t])=>t&&!!this.currentOp(t))}isPending(t){return!!t&&!t.buffer}blockBuffers(t,n=this.sourceBufferTypes){if(!n.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t);const{operationQueue:s}=this,o=n.map(c=>this.appendBlocker(c));return n.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(o).then(c=>{s===this.operationQueue&&(t(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(t){t.forEach(n=>{var s;const o=(s=this.tracks[n])==null?void 0:s.buffer;!o||o.updating||this.shiftAndExecuteNext(n)})}append(t,n,s){this.operationQueue&&this.operationQueue.append(t,n,s)}appendBlocker(t){if(this.operationQueue)return this.operationQueue.appendBlocker(t)}currentOp(t){return this.operationQueue?this.operationQueue.current(t):null}executeNext(t){t&&this.operationQueue&&this.operationQueue.executeNext(t)}shiftAndExecuteNext(t){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(t)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((t,n)=>t+(this.isPending(this.tracks[n])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((t,[n])=>t+(n?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([t])=>t).filter(t=>!!t)}addBufferListener(t,n,s){const o=this.tracks[t];if(!o)return;const l=o.buffer;if(!l)return;const c=s.bind(this,t);o.listeners.push({event:n,listener:c}),l.addEventListener(n,c)}removeBufferListeners(t){const n=this.tracks[t];if(!n)return;const s=n.buffer;s&&(n.listeners.forEach(o=>{s.removeEventListener(o.event,o.listener)}),n.listeners.length=0)}}function jn(h){const t=h.querySelectorAll("source");[].slice.call(t).forEach(n=>{h.removeChild(n)})}function no(h,t){const n=self.document.createElement("source");n.type="video/mp4",n.src=t,h.appendChild(n)}function vu(h){return h==="audio"?1:0}class us{constructor(t){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(t){this.streamController=t}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:t}=this;t.on(S.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(S.MANIFEST_PARSED,this.onManifestParsed,this),t.on(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(S.BUFFER_CODECS,this.onBufferCodecs,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(S.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(S.MANIFEST_PARSED,this.onManifestParsed,this),t.off(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(S.BUFFER_CODECS,this.onBufferCodecs,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,n){const s=this.hls.levels[n.droppedLevel];this.isLevelAllowed(s)&&this.restrictedLevels.push({bitrate:s.bitrate,height:s.height,width:s.width})}onMediaAttaching(t,n){this.media=n.media instanceof HTMLVideoElement?n.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(t,n){const s=this.hls;this.restrictedLevels=[],this.firstLevel=n.firstLevel,s.config.capLevelToPlayerSize&&n.video&&this.startCapping()}onLevelsUpdated(t,n){this.timer&&ce(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(t,n){this.hls.config.capLevelToPlayerSize&&n.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}const t=this.hls.levels;if(t.length){const n=this.hls,s=this.getMaxLevel(t.length-1);s!==this.autoLevelCapping&&n.logger.log(`Setting autoLevelCapping to ${s}: ${t[s].height}p@${t[s].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),n.autoLevelCapping=s,n.autoLevelEnabled&&n.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=n.autoLevelCapping}}}getMaxLevel(t){const n=this.hls.levels;if(!n.length)return-1;const s=n.filter((o,l)=>this.isLevelAllowed(o)&&l<=t);return this.clientRect=null,us.getMaxLevelByMediaSize(s,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const t=this.media,n={width:0,height:0};if(t){const s=t.getBoundingClientRect();n.width=s.width,n.height=s.height,!n.width&&!n.height&&(n.width=s.right-s.left||t.width||0,n.height=s.bottom-s.top||t.height||0)}return this.clientRect=n,n}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch(n){}return Math.min(t,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(t){return!this.restrictedLevels.some(s=>t.bitrate===s.bitrate&&t.width===s.width&&t.height===s.height)}static getMaxLevelByMediaSize(t,n,s){if(!(t!=null&&t.length))return-1;const o=(f,_)=>_?f.width!==_.width||f.height!==_.height:!0;let l=t.length-1;const c=Math.max(n,s);for(let f=0;f<t.length;f+=1){const _=t[f];if((_.width>=c||_.height>=c)&&o(_,t[f+1])){l=f;break}}return l}}const Er={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},hd={HLS:"h"};class Ys{constructor(t,n){Array.isArray(t)&&(t=t.map(s=>s instanceof Ys?s:new Ys(s))),this.value=t,this.params=n}}const Rc="Dict";function _l(h){return Array.isArray(h)?JSON.stringify(h):h instanceof Map?"Map{}":h instanceof Set?"Set{}":typeof h=="object"?JSON.stringify(h):String(h)}function vl(h,t,n,s){return new Error(`failed to ${h} "${_l(t)}" as ${n}`,{cause:s})}function Tt(h,t,n){return vl("serialize",h,t,n)}class yu{constructor(t){this.description=t}}const yl="Bare Item",bu="Boolean";function xu(h){if(typeof h!="boolean")throw Tt(h,bu);return h?"?1":"?0"}function fd(h){return btoa(String.fromCharCode(...h))}const dd="Byte Sequence";function pd(h){if(ArrayBuffer.isView(h)===!1)throw Tt(h,dd);return`:${fd(h)}:`}const kr="Integer";function md(h){return h<-999999999999999||999999999999999<h}function wu(h){if(md(h))throw Tt(h,kr);return h.toString()}function Su(h){return`@${wu(h.getTime()/1e3)}`}function bl(h,t){if(h<0)return-bl(-h,t);const n=Math.pow(10,t);if(Math.abs(h*n%1-.5)<Number.EPSILON){const o=Math.floor(h*n);return(o%2===0?o:o+1)/n}else return Math.round(h*n)/n}const ro="Decimal";function Bo(h){const t=bl(h,3);if(Math.floor(Math.abs(t)).toString().length>12)throw Tt(h,ro);const n=t.toString();return n.includes(".")?n:`${n}.0`}const bs="String",so=/[\x00-\x1f\x7f]+/;function es(h){if(so.test(h))throw Tt(h,bs);return`"${h.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function La(h){return h.description||h.toString().slice(7,-1)}const xl="Token";function Us(h){const t=La(h);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t)===!1)throw Tt(t,xl);return t}function Eu(h){switch(typeof h){case"number":if(!ce(h))throw Tt(h,yl);return Number.isInteger(h)?wu(h):Bo(h);case"string":return es(h);case"symbol":return Us(h);case"boolean":return xu(h);case"object":if(h instanceof Date)return Su(h);if(h instanceof Uint8Array)return pd(h);if(h instanceof yu)return Us(h);default:throw Tt(h,yl)}}const sf="Key";function wl(h){if(/^[a-z*][a-z0-9\-_.*]*$/.test(h)===!1)throw Tt(h,sf);return h}function Ic(h){return h==null?"":Object.entries(h).map(([t,n])=>n===!0?`;${wl(t)}`:`;${wl(t)}=${Eu(n)}`).join("")}function Or(h){return h instanceof Ys?`${Eu(h.value)}${Ic(h.params)}`:Eu(h)}function Xs(h){return`(${h.value.map(Or).join(" ")})${Ic(h.params)}`}function gd(h,t={whitespace:!0}){if(typeof h!="object"||h==null)throw Tt(h,Rc);const n=h instanceof Map?h.entries():Object.entries(h),s=t!=null&&t.whitespace?" ":"";return Array.from(n).map(([o,l])=>{l instanceof Ys||(l=new Ys(l));let c=wl(o);return l.value===!0?c+=Ic(l.params):(c+="=",Array.isArray(l.value)?c+=Xs(l):c+=Or(l)),c}).join(`,${s}`)}function Pc(h,t){return gd(h,t)}const Ds="CMCD-Object",Si="CMCD-Request",Cs="CMCD-Session",_s="CMCD-Status",ku={br:Ds,ab:Ds,d:Ds,ot:Ds,tb:Ds,tpb:Ds,lb:Ds,tab:Ds,lab:Ds,url:Ds,pb:Si,bl:Si,tbl:Si,dl:Si,ltc:Si,mtp:Si,nor:Si,nrr:Si,rc:Si,sn:Si,sta:Si,su:Si,ttfb:Si,ttfbb:Si,ttlb:Si,cmsdd:Si,cmsds:Si,smrt:Si,df:Si,cs:Si,ts:Si,cid:Cs,pr:Cs,sf:Cs,sid:Cs,st:Cs,v:Cs,msd:Cs,bs:_s,bsd:_s,cdn:_s,rtp:_s,bg:_s,pt:_s,ec:_s,e:_s},et={REQUEST:Si};function _d(h){return Object.keys(h).reduce((t,n)=>{var s;return(s=h[n])===null||s===void 0||s.forEach(o=>t[o]=n),t},{})}function vd(h,t){const n={};if(!h)return n;const s=Object.keys(h),o=t?_d(t):{};return s.reduce((l,c)=>{var f;const _=ku[c]||o[c]||et.REQUEST,m=(f=l[_])!==null&&f!==void 0?f:l[_]={};return m[c]=h[c],l},n)}function Oc(h){return["ot","sf","st","e","sta"].includes(h)}function yd(h){return typeof h=="number"?ce(h):h!=null&&h!==""&&h!==!1}const No="event";function bd(h,t){const n=new URL(h),s=new URL(t);if(n.origin!==s.origin)return h;const o=n.pathname.split("/").slice(1),l=s.pathname.split("/").slice(1,-1);for(;o[0]===l[0];)o.shift(),l.shift();for(;l.length;)l.shift(),o.unshift("..");return o.join("/")+n.search+n.hash}const Tu=h=>Math.round(h),Fr=(h,t)=>Array.isArray(h)?h.map(n=>Fr(n,t)):h instanceof Ys&&typeof h.value=="string"?new Ys(Fr(h.value,t),h.params):(t.baseUrl&&(h=bd(h,t.baseUrl)),t.version===1?encodeURIComponent(h):h),zs=h=>Tu(h/100)*100,Au={br:Tu,d:Tu,bl:zs,dl:zs,mtp:zs,nor:(h,t)=>{let n=h;return t.version>=2&&(h instanceof Ys&&typeof h.value=="string"?n=new Ys([h]):typeof h=="string"&&(n=[h])),Fr(n,t)},rtp:zs,tb:Tu},af="request",of="response",Sl=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],lf=["e"],Lu=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function Ur(h){return Lu.test(h)}function ao(h){return Sl.includes(h)||lf.includes(h)||Ur(h)}const Bc=["d","dl","nor","ot","rtp","su"];function uf(h){return Sl.includes(h)||Bc.includes(h)||Ur(h)}const Nc=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];function xd(h){return Sl.includes(h)||Bc.includes(h)||Nc.includes(h)||Ur(h)}const wd=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function Sd(h){return wd.includes(h)||Ur(h)}const Ed={[of]:xd,[No]:ao,[af]:uf};function $c(h,t={}){const n={};if(h==null||typeof h!="object")return n;const s=t.version||h.v||1,o=t.reportingMode||af,l=s===1?Sd:Ed[o];let c=Object.keys(h).filter(l);const f=t.filter;typeof f=="function"&&(c=c.filter(f));const _=o===of||o===No;_&&!c.includes("ts")&&c.push("ts"),s>1&&!c.includes("v")&&c.push("v");const m=k({},Au,t.formatters),v={version:s,reportingMode:o,baseUrl:t.baseUrl};return c.sort().forEach(y=>{let x=h[y];const D=m[y];if(typeof D=="function"&&(x=D(x,v)),y==="v"){if(s===1)return;x=s}y=="pr"&&x===1||(_&&y==="ts"&&!ce(x)&&(x=Date.now()),yd(x)&&(Oc(y)&&typeof x=="string"&&(x=new yu(x)),n[y]=x))}),n}function qn(h,t={}){const n={};if(!h)return n;const s=$c(h,t),o=vd(s,t==null?void 0:t.customHeaderMap);return Object.entries(o).reduce((l,[c,f])=>{const _=Pc(f,{whitespace:!1});return _&&(l[c]=_),l},n)}function kd(h,t,n){return k(h,qn(t,n))}const Td="CMCD";function oo(h,t={}){return h?Pc($c(h,t),{whitespace:!1}):""}function Ad(h,t={}){if(!h)return"";const n=oo(h,t);return encodeURIComponent(n)}function El(h,t={}){if(!h)return"";const n=Ad(h,t);return`${Td}=${n}`}const cf=/CMCD=[^&#]+/;function hf(h,t,n){const s=El(t,n);if(!s)return h;if(cf.test(h))return h.replace(cf,s);const o=h.includes("?")?"&":"?";return`${h}${o}${s}`}class ff{constructor(t){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=o=>{try{this.apply(o,{ot:Er.MANIFEST,su:!this.initialized})}catch(l){this.hls.logger.warn("Could not generate manifest CMCD data.",l)}},this.applyFragmentData=o=>{try{const{frag:l,part:c}=o,f=this.hls.levels[l.level],_=this.getObjectType(l),m={d:(c||l).duration*1e3,ot:_};(_===Er.VIDEO||_===Er.AUDIO||_==Er.MUXED)&&(m.br=f.bitrate/1e3,m.tb=this.getTopBandwidth(_)/1e3,m.bl=this.getBufferLength(_));const v=c?this.getNextPart(c):this.getNextFrag(l);v!=null&&v.url&&v.url!==l.url&&(m.nor=v.url),this.apply(o,m)}catch(l){this.hls.logger.warn("Could not generate segment CMCD data.",l)}},this.hls=t;const n=this.config=t.config,{cmcd:s}=n;s!=null&&(n.pLoader=this.createPlaylistLoader(),n.fLoader=this.createFragmentLoader(),this.sid=s.sessionId||t.sessionId,this.cid=s.contentId,this.useHeaders=s.useHeaders===!0,this.includeKeys=s.includeKeys,this.registerListeners())}registerListeners(){const t=this.hls;t.on(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(S.MEDIA_DETACHED,this.onMediaDetached,this),t.on(S.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(S.MEDIA_DETACHED,this.onMediaDetached,this),t.off(S.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}onMediaAttached(t,n){this.media=n.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(t,n){var s,o;this.audioBuffer=(s=n.tracks.audio)==null?void 0:s.buffer,this.videoBuffer=(o=n.tracks.video)==null?void 0:o.buffer}createData(){var t;return{v:1,sf:hd.HLS,sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,n={}){k(n,this.createData());const s=n.ot===Er.INIT||n.ot===Er.VIDEO||n.ot===Er.MUXED;this.starved&&s&&(n.bs=!0,n.su=!0,this.starved=!1),n.su==null&&(n.su=this.buffering);const{includeKeys:o}=this;o&&(n=Object.keys(n).reduce((c,f)=>(o.includes(f)&&(c[f]=n[f]),c),{}));const l={baseUrl:t.url};this.useHeaders?(t.headers||(t.headers={}),kd(t.headers,n,l)):t.url=hf(t.url,n,l)}getNextFrag(t){var n;const s=(n=this.hls.levels[t.level])==null?void 0:n.details;if(s){const o=t.sn-s.startSN;return s.fragments[o+1]}}getNextPart(t){var n;const{index:s,fragment:o}=t,l=(n=this.hls.levels[o.level])==null||(n=n.details)==null?void 0:n.partList;if(l){const{sn:c}=o;for(let f=l.length-1;f>=0;f--){const _=l[f];if(_.index===s&&_.fragment.sn===c)return l[f+1]}}}getObjectType(t){const{type:n}=t;if(n==="subtitle")return Er.TIMED_TEXT;if(t.sn==="initSegment")return Er.INIT;if(n==="audio")return Er.AUDIO;if(n==="main")return this.hls.audioTracks.length?Er.VIDEO:Er.MUXED}getTopBandwidth(t){let n=0,s;const o=this.hls;if(t===Er.AUDIO)s=o.audioTracks;else{const l=o.maxAutoLevel,c=l>-1?l+1:o.levels.length;s=o.levels.slice(0,c)}return s.forEach(l=>{l.bitrate>n&&(n=l.bitrate)}),n>0?n:NaN}getBufferLength(t){const n=this.media,s=t===Er.AUDIO?this.audioBuffer:this.videoBuffer;return!s||!n?NaN:Wt.bufferInfo(s,n.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:t}=this.config,n=this.applyPlaylistData,s=t||this.config.loader;return class{constructor(l){this.loader=void 0,this.loader=new s(l)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(l,c,f){n(l),this.loader.load(l,c,f)}}}createFragmentLoader(){const{fLoader:t}=this.config,n=this.applyFragmentData,s=t||this.config.loader;return class{constructor(l){this.loader=void 0,this.loader=new s(l)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(l,c,f){n(l),this.loader.load(l,c,f)}}}}const kl=3e5;class Ld extends H{constructor(t){super("content-steering",t.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=t,this.registerListeners()}registerListeners(){const t=this.hls;t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(S.MANIFEST_PARSED,this.onManifestParsed,this),t.on(S.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(S.MANIFEST_PARSED,this.onManifestParsed,this),t.off(S.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((t,n)=>(t.indexOf(n.pathwayId)===-1&&t.push(n.pathwayId),t),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(t){this.updatePathwayPriority(t)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const t=this.timeToLoad*1e3-(performance.now()-this.updated);if(t>0){this.scheduleRefresh(this.uri,t);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(t){const n=this.levels;n&&(this.levels=n.filter(s=>s!==t))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(t,n){const{contentSteering:s}=n;s!==null&&(this.pathwayId=s.pathwayId,this.uri=s.uri,this.started&&this.startLoad())}onManifestParsed(t,n){this.audioTracks=n.audioTracks,this.subtitleTracks=n.subtitleTracks}onError(t,n){const{errorAction:s}=n;if((s==null?void 0:s.action)===Ui.SendAlternateToPenaltyBox&&s.flags===zi.MoveAllAlternatesMatchingHost){const o=this.levels;let l=this._pathwayPriority,c=this.pathwayId;if(n.context){const{groupId:f,pathwayId:_,type:m}=n.context;f&&o?c=this.getPathwayForGroupId(f,m,c):_&&(c=_)}c in this.penalizedPathways||(this.penalizedPathways[c]=performance.now()),!l&&o&&(l=this.pathways()),l&&l.length>1&&(this.updatePathwayPriority(l),s.resolved=this.pathwayId!==c),n.details===q.BUFFER_APPEND_ERROR&&!n.fatal?s.resolved=!0:s.resolved||this.warn(`Could not resolve ${n.details} ("${n.error.message}") with content-steering for Pathway: ${c} levels: ${o&&o.length} priorities: ${$t(l)} penalized: ${$t(this.penalizedPathways)}`)}}filterParsedLevels(t){this.levels=t;let n=this.getLevelsForPathway(this.pathwayId);if(n.length===0){const s=t[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${s}"`),n=this.getLevelsForPathway(s),this.pathwayId=s}return n.length!==t.length&&this.log(`Found ${n.length}/${t.length} levels in Pathway "${this.pathwayId}"`),n}getLevelsForPathway(t){return this.levels===null?[]:this.levels.filter(n=>t===n.pathwayId)}updatePathwayPriority(t){this._pathwayPriority=t;let n;const s=this.penalizedPathways,o=performance.now();Object.keys(s).forEach(l=>{o-s[l]>kl&&delete s[l]});for(let l=0;l<t.length;l++){const c=t[l];if(c in s)continue;if(c===this.pathwayId)return;const f=this.hls.nextLoadLevel,_=this.hls.levels[f];if(n=this.getLevelsForPathway(c),n.length>0){this.log(`Setting Pathway to "${c}"`),this.pathwayId=c,Wn(n),this.hls.trigger(S.LEVELS_UPDATED,{levels:n});const m=this.hls.levels[f];_&&m&&this.levels&&(m.attrs["STABLE-VARIANT-ID"]!==_.attrs["STABLE-VARIANT-ID"]&&m.bitrate!==_.bitrate&&this.log(`Unstable Pathways change from bitrate ${_.bitrate} to ${m.bitrate}`),this.hls.nextLoadLevel=f);break}}}getPathwayForGroupId(t,n,s){const o=this.getLevelsForPathway(s).concat(this.levels||[]);for(let l=0;l<o.length;l++)if(n===Te.AUDIO_TRACK&&o[l].hasAudioGroup(t)||n===Te.SUBTITLE_TRACK&&o[l].hasSubtitleGroup(t))return o[l].pathwayId;return s}clonePathways(t){const n=this.levels;if(!n)return;const s={},o={};t.forEach(l=>{const{ID:c,"BASE-ID":f,"URI-REPLACEMENT":_}=l;if(n.some(v=>v.pathwayId===c))return;const m=this.getLevelsForPathway(f).map(v=>{const y=new vn(v.attrs);y["PATHWAY-ID"]=c;const x=y.AUDIO&&`${y.AUDIO}_clone_${c}`,D=y.SUBTITLES&&`${y.SUBTITLES}_clone_${c}`;x&&(s[y.AUDIO]=x,y.AUDIO=x),D&&(o[y.SUBTITLES]=D,y.SUBTITLES=D);const C=Du(v.uri,y["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",_),B=new Yn({attrs:y,audioCodec:v.audioCodec,bitrate:v.bitrate,height:v.height,name:v.name,url:C,videoCodec:v.videoCodec,width:v.width});if(v.audioGroups)for(let F=1;F<v.audioGroups.length;F++)B.addGroupId("audio",`${v.audioGroups[F]}_clone_${c}`);if(v.subtitleGroups)for(let F=1;F<v.subtitleGroups.length;F++)B.addGroupId("text",`${v.subtitleGroups[F]}_clone_${c}`);return B});n.push(...m),Kc(this.audioTracks,s,_,c),Kc(this.subtitleTracks,o,_,c)})}loadSteeringManifest(t){const n=this.hls.config,s=n.loader;this.loader&&this.loader.destroy(),this.loader=new s(n);let o;try{o=new self.URL(t)}catch(v){this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${t}`);return}if(o.protocol!=="data:"){const v=(this.hls.bandwidthEstimate||n.abrEwmaDefaultEstimate)|0;o.searchParams.set("_HLS_pathway",this.pathwayId),o.searchParams.set("_HLS_throughput",""+v)}const l={responseType:"json",url:o.href},c=n.steeringManifestLoadPolicy.default,f=c.errorRetry||c.timeoutRetry||{},_={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:f.maxNumRetry||0,retryDelay:f.retryDelayMs||0,maxRetryDelay:f.maxRetryDelayMs||0},m={onSuccess:(v,y,x,D)=>{this.log(`Loaded steering manifest: "${o}"`);const C=v.data;if((C==null?void 0:C.VERSION)!==1){this.log(`Steering VERSION ${C.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=C.TTL;const{"RELOAD-URI":B,"PATHWAY-CLONES":F,"PATHWAY-PRIORITY":Q}=C;if(B)try{this.uri=new self.URL(B,o).href}catch(le){this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${B}`);return}this.scheduleRefresh(this.uri||x.url),F&&this.clonePathways(F);const se={steeringManifest:C,url:o.toString()};this.hls.trigger(S.STEERING_MANIFEST_LOADED,se),Q&&this.updatePathwayPriority(Q)},onError:(v,y,x,D)=>{if(this.log(`Error loading steering manifest: ${v.code} ${v.text} (${y.url})`),this.stopLoad(),v.code===410){this.enabled=!1,this.log(`Steering manifest ${y.url} no longer available`);return}let C=this.timeToLoad*1e3;if(v.code===429){const B=this.loader;if(typeof(B==null?void 0:B.getResponseHeader)=="function"){const F=B.getResponseHeader("Retry-After");F&&(C=parseFloat(F)*1e3)}this.log(`Steering manifest ${y.url} rate limited`);return}this.scheduleRefresh(this.uri||y.url,C)},onTimeout:(v,y,x)=>{this.log(`Timeout loading steering manifest (${y.url})`),this.scheduleRefresh(this.uri||y.url)}};this.log(`Requesting steering manifest: ${o}`),this.loader.load(l,_,m)}scheduleRefresh(t,n=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var s;const o=(s=this.hls)==null?void 0:s.media;if(o&&!o.ended){this.loadSteeringManifest(t);return}this.scheduleRefresh(t,this.timeToLoad*1e3)},n)}}function Kc(h,t,n,s){h&&Object.keys(t).forEach(o=>{const l=h.filter(c=>c.groupId===o).map(c=>{const f=k({},c);return f.details=void 0,f.attrs=new vn(f.attrs),f.url=f.attrs.URI=Du(c.url,c.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",n),f.groupId=f.attrs["GROUP-ID"]=t[o],f.attrs["PATHWAY-ID"]=s,f});h.push(...l)})}function Du(h,t,n,s){const{HOST:o,PARAMS:l,[n]:c}=s;let f;t&&(f=c==null?void 0:c[t],f&&(h=f));const _=new self.URL(h);return o&&!f&&(_.host=o),l&&Object.keys(l).sort().forEach(m=>{m&&_.searchParams.set(m,l[m])}),_.href}class lo extends H{constructor(t){super("eme",t.logger),this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=lo.CDMCleanupPromise?[lo.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=n=>{const{initDataType:s,initData:o}=n,l=`"${n.type}" event: init data type: "${s}"`;if(this.debug(l),o!==null){if(!this.keyFormatPromise){let c=Object.keys(this.keySystemAccessPromises);c.length||(c=$r(this.config));const f=c.map(mn).filter(_=>!!_);this.keyFormatPromise=this.getKeyFormatPromise(f)}this.keyFormatPromise.then(c=>{const f=Hn(c);if(s!=="sinf"||f!==Jt.FAIRPLAY){this.log(`Ignoring "${n.type}" event with init data type: "${s}" for selected key-system ${f}`);return}let _;try{const D=fi(new Uint8Array(o)),C=ss(JSON.parse(D).sinf),B=Yt(C);if(!B)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");_=new Uint8Array(B.subarray(8,24))}catch(D){this.warn(`${l} Failed to parse sinf: ${D}`);return}const m=te(_),{keyIdToKeySessionPromise:v,mediaKeySessions:y}=this;let x=v[m];for(let D=0;D<y.length;D++){const C=y[D],B=C.decryptdata;if(!B.keyId)continue;const F=te(B.keyId);if(Kn(_,B.keyId)||B.uri.replace(/-/g,"").indexOf(m)!==-1){if(x=v[F],!x)continue;if(B.pssh)break;delete v[F],B.pssh=new Uint8Array(o),B.keyId=_,x=v[m]=x.then(()=>this.generateRequestWithPreferredKeySession(C,s,o,"encrypted-event-key-match")),x.catch(Q=>this.handleError(Q));break}}x||this.handleError(new Error(`Key ID ${m} not encountered in playlist. Key-system sessions ${y.length}.`))}).catch(c=>this.handleError(c))}},this.onWaitingForKey=n=>{this.log(`"${n.type}" event`)},this.hls=t,this.config=t.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();const t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(S.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(S.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(S.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(S.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(S.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(S.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(S.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(S.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(S.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(S.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(t){const{drmSystems:n,widevineLicenseUrl:s}=this.config,o=n==null?void 0:n[t];if(o)return o.licenseUrl;if(t===Jt.WIDEVINE&&s)return s}getLicenseServerUrlOrThrow(t){const n=this.getLicenseServerUrl(t);if(n===void 0)throw new Error(`no license server URL configured for key-system "${t}"`);return n}getServerCertificateUrl(t){const{drmSystems:n}=this.config,s=n==null?void 0:n[t];if(s)return s.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${t}"]`)}attemptKeySystemAccess(t){const n=this.hls.levels,s=(c,f,_)=>!!c&&_.indexOf(c)===f,o=n.map(c=>c.audioCodec).filter(s),l=n.map(c=>c.videoCodec).filter(s);return o.length+l.length===0&&l.push("avc1.42e01e"),new Promise((c,f)=>{const _=m=>{const v=m.shift();this.getMediaKeysPromise(v,o,l).then(y=>c({keySystem:v,mediaKeys:y})).catch(y=>{m.length?_(m):y instanceof xs?f(y):f(new xs({type:ge.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_ACCESS,error:y,fatal:!0},y.message))})};_(t)})}requestMediaKeySystemAccess(t,n){const{requestMediaKeySystemAccessFunc:s}=this.config;if(typeof s!="function"){let o=`Configured requestMediaKeySystemAccess is not a function ${s}`;return ir===null&&self.location.protocol==="http:"&&(o=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(o))}return s(t,n)}getMediaKeysPromise(t,n,s){var o;const l=Ts(t,n,s,this.config.drmSystemOptions||{});let c=this.keySystemAccessPromises[t],f=(o=c)==null?void 0:o.keySystemAccess;if(!f){this.log(`Requesting encrypted media "${t}" key-system access with config: ${$t(l)}`),f=this.requestMediaKeySystemAccess(t,l);const _=c=this.keySystemAccessPromises[t]={keySystemAccess:f};return f.catch(m=>{this.log(`Failed to obtain access to key-system "${t}": ${m}`)}),f.then(m=>{this.log(`Access for key-system "${m.keySystem}" obtained`);const v=this.fetchServerCertificate(t);this.log(`Create media-keys for "${t}"`);const y=_.mediaKeys=m.createMediaKeys().then(x=>(this.log(`Media-keys created for "${t}"`),_.hasMediaKeys=!0,v.then(D=>D?this.setMediaKeysServerCertificate(x,t,D):x)));return y.catch(x=>{this.error(`Failed to create media-keys for "${t}"}: ${x}`)}),y})}return f.then(()=>c.mediaKeys)}createMediaKeySessionContext({decryptdata:t,keySystem:n,mediaKeys:s}){this.log(`Creating key-system session "${n}" keyId: ${te(t.keyId||[])} keyUri: ${t.uri}`);const o=s.createSession(),l={decryptdata:t,keySystem:n,mediaKeys:s,mediaKeysSession:o,keyStatus:"status-pending"};return this.mediaKeySessions.push(l),l}renewKeySession(t){const n=t.decryptdata;if(n.pssh){const s=this.createMediaKeySessionContext(t),o=Cu(n),l="cenc";this.keyIdToKeySessionPromise[o]=this.generateRequestWithPreferredKeySession(s,l,n.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)}updateKeySession(t,n){const s=t.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyId ${te(t.decryptdata.keyId||[])}
} (data length: ${n.byteLength})`),s.update(n)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(t=>({keySystem:t,hasMediaKeys:this.keySystemAccessPromises[t].hasMediaKeys})).filter(({hasMediaKeys:t})=>!!t).map(({keySystem:t})=>mn(t)).filter(t=>!!t)}getKeySystemAccess(t){return this.getKeySystemSelectionPromise(t).then(({keySystem:n,mediaKeys:s})=>this.attemptSetMediaKeys(n,s))}selectKeySystem(t){return new Promise((n,s)=>{this.getKeySystemSelectionPromise(t).then(({keySystem:o})=>{const l=mn(o);l?n(l):s(new Error(`Unable to find format for key-system "${o}"`))}).catch(s)})}selectKeySystemFormat(t){const n=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${t.sn} ${t.type}: ${t.level}) key formats ${n.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(n)),this.keyFormatPromise}getKeyFormatPromise(t){const n=$r(this.config),s=t.map(Hn).filter(o=>!!o&&n.indexOf(o)!==-1);return this.selectKeySystem(s)}getKeyStatus(t){const{mediaKeySessions:n}=this;for(let s=0;s<n.length;s++){const o=Dd(t,n[s]);if(o)return o}}loadKey(t){const n=t.keyInfo.decryptdata,s=Cu(n),o=this.bannedKeyIds[s];if(o||this.getKeyStatus(n)==="internal-error"){const f=df(o||"internal-error",n);return this.handleError(f,t.frag),Promise.reject(f)}const l=`(keyId: ${s} format: "${n.keyFormat}" method: ${n.method} uri: ${n.uri})`;this.log(`Starting session for key ${l}`);const c=this.keyIdToKeySessionPromise[s];if(!c){const f=this.getKeySystemForKeyPromise(n).then(({keySystem:_,mediaKeys:m})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${l}`),this.attemptSetMediaKeys(_,m).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:_,mediaKeys:m,decryptdata:n}))))).then(_=>{const m="cenc",v=n.pssh?n.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(_,m,v,"playlist-key")});return f.catch(_=>this.handleError(_,t.frag)),this.keyIdToKeySessionPromise[s]=f,f}return c.catch(f=>{if(f instanceof xs){const _=M({},f.data);this.getKeyStatus(n)==="internal-error"&&(_.decryptdata=n);const m=new xs(_,f.message);this.handleError(m,t.frag)}}),c}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t,n){if(this.hls)if(t instanceof xs){n&&(t.data.frag=n);const s=t.data.decryptdata;this.error(`${t.message}${s?` (${te(s.keyId||[])})`:""}`),this.hls.trigger(S.ERROR,t.data)}else this.error(t.message),this.hls.trigger(S.ERROR,{type:ge.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0})}getKeySystemForKeyPromise(t){const n=Cu(t),s=this.keyIdToKeySessionPromise[n];if(!s){const o=Hn(t.keyFormat),l=o?[o]:$r(this.config);return this.attemptKeySystemAccess(l)}return s}getKeySystemSelectionPromise(t){if(t.length||(t=$r(this.config)),t.length===0)throw new xs({type:ge.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${$t({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(t)}attemptSetMediaKeys(t,n){if(this.mediaKeys===n)return Promise.resolve();const s=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${t}"`);const o=Promise.all(s).then(()=>{if(!this.media)throw this.mediaKeys=null,new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(n)});return this.mediaKeys=n,this.setMediaKeysQueue.push(o),o.then(()=>{this.log(`Media-keys set for "${t}"`),s.push(o),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(l=>s.indexOf(l)===-1)})}generateRequestWithPreferredKeySession(t,n,s,o){var l;const c=(l=this.config.drmSystems)==null||(l=l[t.keySystem])==null?void 0:l.generateRequest;if(c)try{const C=c.call(this.hls,n,s,t);if(!C)throw new Error("Invalid response from configured generateRequest filter");n=C.initDataType,s=C.initData?C.initData:null,t.decryptdata.pssh=s?new Uint8Array(s):null}catch(C){if(this.warn(C.message),this.hls&&this.hls.config.debug)throw C}if(s===null)return this.log(`Skipping key-session request for "${o}" (no initData)`),Promise.resolve(t);const f=Cu(t.decryptdata),_=t.decryptdata.uri;this.log(`Generating key-session request for "${o}" keyId: ${f} URI: ${_} (init data type: ${n} length: ${s.byteLength})`);const m=new Bs,v=t._onmessage=C=>{const B=t.mediaKeysSession;if(!B){m.emit("error",new Error("invalid state"));return}const{messageType:F,message:Q}=C;this.log(`"${F}" message event for session "${B.sessionId}" message size: ${Q.byteLength}`),F==="license-request"||F==="license-renewal"?this.renewLicense(t,Q).catch(se=>{m.eventNames().length?m.emit("error",se):this.handleError(se)}):F==="license-release"?t.keySystem===Jt.FAIRPLAY&&this.updateKeySession(t,Ps("acknowledged")).then(()=>this.removeSession(t)).catch(se=>this.handleError(se)):this.warn(`unhandled media key message type "${F}"`)},y=(C,B)=>{B.keyStatus=C;let F;C.startsWith("usable")?m.emit("resolved"):C==="internal-error"||C==="output-restricted"||C==="output-downscaled"?F=df(C,B.decryptdata):C==="expired"?F=new Error(`key expired (keyId: ${f})`):C==="released"?F=new Error("key released"):C==="status-pending"||this.warn(`unhandled key status change "${C}" (keyId: ${f})`),F&&(m.eventNames().length?m.emit("error",F):this.handleError(F))},x=t._onkeystatuseschange=C=>{if(!t.mediaKeysSession){m.emit("error",new Error("invalid state"));return}const F=this.getKeyStatuses(t);if(!Object.keys(F).some(Ee=>F[Ee]!=="status-pending"))return;if(F[f]==="expired"){this.log(`Expired key ${$t(F)} in key-session "${t.mediaKeysSession.sessionId}"`),this.renewKeySession(t);return}let se=F[f];if(se)y(se,t);else{var le;t.keyStatusTimeouts||(t.keyStatusTimeouts={}),(le=t.keyStatusTimeouts)[f]||(le[f]=self.setTimeout(()=>{if(!t.mediaKeysSession||!this.mediaKeys)return;const Ie=this.getKeyStatus(t.decryptdata);if(Ie&&Ie!=="status-pending")return this.log(`No status for keyId ${f} in key-session "${t.mediaKeysSession.sessionId}". Using session key-status ${Ie} from other session.`),y(Ie,t);this.log(`key status for ${f} in key-session "${t.mediaKeysSession.sessionId}" timed out after 0ms`),se="internal-error",y(se,t)},0)),this.log(`No status for keyId ${f} (${$t(F)}).`)}};vr(t.mediaKeysSession,"message",v),vr(t.mediaKeysSession,"keystatuseschange",x);const D=new Promise((C,B)=>{m.on("error",B),m.on("resolved",C)});return t.mediaKeysSession.generateRequest(n,s).then(()=>{this.log(`Request generated for key-session "${t.mediaKeysSession.sessionId}" keyId: ${f} URI: ${_}`)}).catch(C=>{throw new xs({type:ge.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_SESSION,error:C,decryptdata:t.decryptdata,fatal:!1},`Error generating key-session request: ${C}`)}).then(()=>D).catch(C=>(m.removeAllListeners(),this.removeSession(t).then(()=>{throw C}))).then(()=>(m.removeAllListeners(),t))}getKeyStatuses(t){const n={};return t.mediaKeysSession.keyStatuses.forEach((s,o)=>{if(typeof o=="string"&&typeof s=="object"){const f=o;o=s,s=f}const l="buffer"in o?new Uint8Array(o.buffer,o.byteOffset,o.byteLength):new Uint8Array(o);t.keySystem===Jt.PLAYREADY&&l.length===16&&Os(l);const c=te(l);s==="internal-error"&&(this.bannedKeyIds[c]=s),this.log(`key status change "${s}" for keyStatuses keyId: ${c} key-session "${t.mediaKeysSession.sessionId}"`),n[c]=s}),n}fetchServerCertificate(t){const n=this.config,s=n.loader,o=new s(n),l=this.getServerCertificateUrl(t);return l?(this.log(`Fetching server certificate for "${t}"`),new Promise((c,f)=>{const _={responseType:"arraybuffer",url:l},m=n.certLoadPolicy.default,v={loadPolicy:m,timeout:m.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},y={onSuccess:(x,D,C,B)=>{c(x.data)},onError:(x,D,C,B)=>{f(new xs({type:ge.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:C,response:M({url:_.url,data:void 0},x)},`"${t}" certificate request failed (${l}). Status: ${x.code} (${x.text})`))},onTimeout:(x,D,C)=>{f(new xs({type:ge.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:C,response:{url:_.url,data:void 0}},`"${t}" certificate request timed out (${l})`))},onAbort:(x,D,C)=>{f(new Error("aborted"))}};o.load(_,v,y)})):Promise.resolve()}setMediaKeysServerCertificate(t,n,s){return new Promise((o,l)=>{t.setServerCertificate(s).then(c=>{this.log(`setServerCertificate ${c?"success":"not supported by CDM"} (${s.byteLength}) on "${n}"`),o(t)}).catch(c=>{l(new xs({type:ge.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:c,fatal:!0},c.message))})})}renewLicense(t,n){return this.requestLicense(t,new Uint8Array(n)).then(s=>this.updateKeySession(t,new Uint8Array(s)).catch(o=>{throw new xs({type:ge.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:t.decryptdata,error:o,fatal:!1},o.message)}))}unpackPlayReadyKeyMessage(t,n){const s=String.fromCharCode.apply(null,new Uint16Array(n.buffer));if(!s.includes("PlayReadyKeyMessage"))return t.setRequestHeader("Content-Type","text/xml; charset=utf-8"),n;const o=new DOMParser().parseFromString(s,"application/xml"),l=o.querySelectorAll("HttpHeader");if(l.length>0){let v;for(let y=0,x=l.length;y<x;y++){var c,f;v=l[y];const D=(c=v.querySelector("name"))==null?void 0:c.textContent,C=(f=v.querySelector("value"))==null?void 0:f.textContent;D&&C&&t.setRequestHeader(D,C)}}const _=o.querySelector("Challenge"),m=_==null?void 0:_.textContent;if(!m)throw new Error("Cannot find <Challenge> in key message");return Ps(atob(m))}setupLicenseXHR(t,n,s,o){const l=this.config.licenseXhrSetup;return l?Promise.resolve().then(()=>{if(!s.decryptdata)throw new Error("Key removed");return l.call(this.hls,t,n,s,o)}).catch(c=>{if(!s.decryptdata)throw c;return t.open("POST",n,!0),l.call(this.hls,t,n,s,o)}).then(c=>(t.readyState||t.open("POST",n,!0),{xhr:t,licenseChallenge:c||o})):(t.open("POST",n,!0),Promise.resolve({xhr:t,licenseChallenge:o}))}requestLicense(t,n){const s=this.config.keyLoadPolicy.default;return new Promise((o,l)=>{const c=this.getLicenseServerUrlOrThrow(t.keySystem);this.log(`Sending license request to URL: ${c}`);const f=new XMLHttpRequest;f.responseType="arraybuffer",f.onreadystatechange=()=>{if(!this.hls||!t.mediaKeysSession)return l(new Error("invalid state"));if(f.readyState===4)if(f.status===200){this._requestLicenseFailureCount=0;let _=f.response;this.log(`License received ${_ instanceof ArrayBuffer?_.byteLength:_}`);const m=this.config.licenseResponseCallback;if(m)try{_=m.call(this.hls,f,c,t)}catch(v){this.error(v)}o(_)}else{const _=s.errorRetry,m=_?_.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>m||f.status>=400&&f.status<500)l(new xs({type:ge.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:t.decryptdata,fatal:!0,networkDetails:f,response:{url:c,data:void 0,code:f.status,text:f.statusText}},`License Request XHR failed (${c}). Status: ${f.status} (${f.statusText})`));else{const v=m-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${v} attempts left`),this.requestLicense(t,n).then(o,l)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=f,this.setupLicenseXHR(f,c,t,n).then(({xhr:_,licenseChallenge:m})=>{t.keySystem==Jt.PLAYREADY&&(m=this.unpackPlayReadyKeyMessage(_,m)),_.send(m)}).catch(l)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(t,n){if(!this.config.emeEnabled)return;const s=n.media;this.media=s,vr(s,"encrypted",this.onMediaEncrypted),vr(s,"waitingforkey",this.onWaitingForKey)}onMediaDetached(){const t=this.media;t&&(Ir(t,"encrypted",this.onMediaEncrypted),Ir(t,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var t;if(this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={},!this.mediaKeys&&!this.mediaKeySessions.length)return;const n=this.media,s=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,as.clearKeyUriToKeyIdMap();const o=s.length;lo.CDMCleanupPromise=Promise.all(s.map(l=>this.removeSession(l)).concat((n==null||(t=n.setMediaKeys(null))==null?void 0:t.catch(l=>{this.log(`Could not clear media keys: ${l}`),this.hls&&this.hls.trigger(S.ERROR,{type:ge.OTHER_ERROR,details:q.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${l}`)})}))||Promise.resolve())).catch(l=>{this.log(`Could not close sessions and clear media keys: ${l}`),this.hls&&this.hls.trigger(S.ERROR,{type:ge.OTHER_ERROR,details:q.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${l}`)})}).then(()=>{o&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this.keyFormatPromise=null,this.bannedKeyIds={}}onManifestLoaded(t,{sessionKeys:n}){if(!(!n||!this.config.emeEnabled)&&!this.keyFormatPromise){const s=n.reduce((o,l)=>(o.indexOf(l.keyFormat)===-1&&o.push(l.keyFormat),o),[]);this.log(`Selecting key-system from session-keys ${s.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(s)}}removeSession(t){const{mediaKeysSession:n,licenseXhr:s,decryptdata:o}=t;if(n){this.log(`Remove licenses and keys and close session "${n.sessionId}" keyId: ${te((o==null?void 0:o.keyId)||[])}`),t._onmessage&&(n.removeEventListener("message",t._onmessage),t._onmessage=void 0),t._onkeystatuseschange&&(n.removeEventListener("keystatuseschange",t._onkeystatuseschange),t._onkeystatuseschange=void 0),s&&s.readyState!==XMLHttpRequest.DONE&&s.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;const l=this.mediaKeySessions.indexOf(t);l>-1&&this.mediaKeySessions.splice(l,1);const{keyStatusTimeouts:c}=t;c&&Object.keys(c).forEach(m=>self.clearTimeout(c[m]));const{drmSystemOptions:f}=this.config;return(xa(f)?new Promise((m,v)=>{self.setTimeout(()=>v(new Error("MediaKeySession.remove() timeout")),8e3),n.remove().then(m).catch(v)}):Promise.resolve()).catch(m=>{this.log(`Could not remove session: ${m}`),this.hls&&this.hls.trigger(S.ERROR,{type:ge.OTHER_ERROR,details:q.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${m}`)})}).then(()=>n.close()).catch(m=>{this.log(`Could not close session: ${m}`),this.hls&&this.hls.trigger(S.ERROR,{type:ge.OTHER_ERROR,details:q.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${m}`)})})}return Promise.resolve()}}lo.CDMCleanupPromise=void 0;function Cu(h){if(!h)throw new Error("Could not read keyId of undefined decryptdata");if(h.keyId===null)throw new Error("keyId is null");return te(h.keyId)}function Dd(h,t){if(h.keyId&&t.mediaKeysSession.keyStatuses.has(h.keyId))return t.mediaKeysSession.keyStatuses.get(h.keyId);if(h.matches(t.decryptdata))return t.keyStatus}class xs extends Error{constructor(t,n){super(n),this.data=void 0,t.error||(t.error=new Error(n)),this.data=t,t.err=t.error}}function df(h,t){const n=h==="output-restricted",s=n?q.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:q.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new xs({type:ge.KEY_SYSTEM_ERROR,details:s,fatal:!1,decryptdata:t},n?"HDCP level output restricted":`key status changed to "${h}"`)}class Cd{constructor(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}setStreamController(t){this.streamController=t}registerListeners(){this.hls.on(S.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(S.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(S.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(S.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,n){const s=this.hls.config;if(s.capLevelOnFPSDrop){const o=n.media instanceof self.HTMLVideoElement?n.media:null;this.media=o,o&&typeof o.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),s.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(t,n,s){const o=performance.now();if(n){if(this.lastTime){const l=o-this.lastTime,c=s-this.lastDroppedFrames,f=n-this.lastDecodedFrames,_=1e3*c/l,m=this.hls;if(m.trigger(S.FPS_DROP,{currentDropped:c,currentDecoded:f,totalDroppedFrames:s}),_>0&&c>m.config.fpsDroppedMonitoringThreshold*f){let v=m.currentLevel;m.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+v),v>0&&(m.autoLevelCapping===-1||m.autoLevelCapping>=v)&&(v=v-1,m.trigger(S.FPS_DROP_LEVEL_CAPPING,{level:v,droppedLevel:m.currentLevel}),m.autoLevelCapping=v,this.streamController.nextLevelSwitch())}}this.lastTime=o,this.lastDroppedFrames=s,this.lastDecodedFrames=n}}checkFPSInterval(){const t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){const n=t.getVideoPlaybackQuality();this.checkFPS(t,n.totalVideoFrames,n.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)}}function pf(h,t){let n;try{n=new Event("addtrack")}catch(s){n=document.createEvent("Event"),n.initEvent("addtrack",!1,!1)}n.track=h,t.dispatchEvent(n)}function mf(h,t){const n=h.mode;if(n==="disabled"&&(h.mode="hidden"),h.cues&&!h.cues.getCueById(t.id))try{if(h.addCue(t),!h.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(s){re.debug(`[texttrack-utils]: ${s}`);try{const o=new self.TextTrackCue(t.startTime,t.endTime,t.text);o.id=t.id,h.addCue(o)}catch(o){re.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${o}`)}}n==="disabled"&&(h.mode=n)}function $o(h,t){const n=h.mode;if(n==="disabled"&&(h.mode="hidden"),h.cues)for(let s=h.cues.length;s--;)t&&h.cues[s].removeEventListener("enter",t),h.removeCue(h.cues[s]);n==="disabled"&&(h.mode=n)}function Js(h,t,n,s){const o=h.mode;if(o==="disabled"&&(h.mode="hidden"),h.cues&&h.cues.length>0){const l=Ko(h.cues,t,n);for(let c=0;c<l.length;c++)(!s||s(l[c]))&&h.removeCue(l[c])}o==="disabled"&&(h.mode=o)}function uo(h,t){if(t<=h[0].startTime)return 0;const n=h.length-1;if(t>h[n].endTime)return-1;let s=0,o=n,l;for(;s<=o;)if(l=Math.floor((o+s)/2),t<h[l].startTime)o=l-1;else if(t>h[l].startTime&&s<n)s=l+1;else return l;return h[s].startTime-t<t-h[o].startTime?s:o}function Ko(h,t,n){const s=[],o=uo(h,t);if(o>-1)for(let l=o,c=h.length;l<c;l++){const f=h[l];if(f.startTime>=t&&f.endTime<=n)s.push(f);else if(f.startTime>n)return s}return s}function Ms(h){const t=[];for(let n=0;n<h.length;n++){const s=h[n];(s.kind==="subtitles"||s.kind==="captions")&&s.label&&t.push(h[n])}return t}class ca extends Mc{constructor(t){super(t,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let n=null;const s=Ms(this.media.textTracks);for(let l=0;l<s.length;l++)if(s[l].mode==="hidden")n=s[l];else if(s[l].mode==="showing"){n=s[l];break}const o=this.findTrackForTextTrack(n);this.subtitleTrack!==o&&this.setSubtitleTrack(o)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:t}=this;t.on(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_PARSED,this.onManifestParsed,this),t.on(S.LEVEL_LOADING,this.onLevelLoading,this),t.on(S.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(S.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(S.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_PARSED,this.onManifestParsed,this),t.off(S.LEVEL_LOADING,this.onLevelLoading,this),t.off(S.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(S.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(S.ERROR,this.onError,this)}onMediaAttached(t,n){this.media=n.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,t)}onMediaDetaching(t,n){const s=this.media;if(!s)return;const o=!!n.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||s.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,o)return;Ms(s.textTracks).forEach(c=>{$o(c)})}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(t,n){this.tracks=n.subtitleTracks}onSubtitleTrackLoaded(t,n){const{id:s,groupId:o,details:l}=n,c=this.tracksInGroup[s];if(!c||c.groupId!==o){this.warn(`Subtitle track with id:${s} and group:${o} not found in active group ${c==null?void 0:c.groupId}`);return}const f=c.details;c.details=n.details,this.log(`Subtitle track ${s} "${c.name}" lang:${c.lang} group:${o} loaded [${l.startSN}-${l.endSN}]`),s===this.trackId&&this.playlistLoaded(s,n,f)}onLevelLoading(t,n){this.switchLevel(n.level)}onLevelSwitching(t,n){this.switchLevel(n.level)}switchLevel(t){const n=this.hls.levels[t];if(!n)return;const s=n.subtitleGroups||null,o=this.groupIds;let l=this.currentTrack;if(!s||(o==null?void 0:o.length)!==(s==null?void 0:s.length)||s!=null&&s.some(c=>(o==null?void 0:o.indexOf(c))===-1)){this.groupIds=s,this.trackId=-1,this.currentTrack=null;const c=this.tracks.filter(v=>!s||s.indexOf(v.groupId)!==-1);if(c.length)this.selectDefaultTrack&&!c.some(v=>v.default)&&(this.selectDefaultTrack=!1),c.forEach((v,y)=>{v.id=y});else if(!l&&!this.tracksInGroup.length)return;this.tracksInGroup=c;const f=this.hls.config.subtitlePreference;if(!l&&f){this.selectDefaultTrack=!1;const v=St(f,c);if(v>-1)l=c[v];else{const y=St(f,this.tracks);l=this.tracks[y]}}let _=this.findTrackId(l);_===-1&&l&&(_=this.findTrackId(null));const m={subtitleTracks:c};this.log(`Updating subtitle tracks, ${c.length} track(s) found in "${s==null?void 0:s.join(",")}" group-id`),this.hls.trigger(S.SUBTITLE_TRACKS_UPDATED,m),_!==-1&&this.trackId===-1&&this.setSubtitleTrack(_)}}findTrackId(t){const n=this.tracksInGroup,s=this.selectDefaultTrack;for(let o=0;o<n.length;o++){const l=n[o];if(!(s&&!l.default||!s&&!t)&&(!t||Bt(l,t)))return o}if(t){for(let o=0;o<n.length;o++){const l=n[o];if(Fo(t.attrs,l.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return o}for(let o=0;o<n.length;o++){const l=n[o];if(Fo(t.attrs,l.attrs,["LANGUAGE"]))return o}}return-1}findTrackForTextTrack(t){if(t){const n=this.tracksInGroup;for(let s=0;s<n.length;s++){const o=n[s];if(gu(o,t))return s}}return-1}onError(t,n){n.fatal||!n.context||n.context.type===Te.SUBTITLE_TRACK&&n.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(n.context.groupId)!==-1)&&this.checkRetry(n)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(t){this.selectDefaultTrack=!1,this.setSubtitleTrack(t)}setSubtitleOption(t){if(this.hls.config.subtitlePreference=t,t){if(t.id===-1)return this.setSubtitleTrack(-1),null;const n=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,n.length){const s=this.currentTrack;if(s&&Bt(t,s))return s;const o=St(t,this.tracksInGroup);if(o>-1){const l=this.tracksInGroup[o];return this.setSubtitleTrack(o),l}else{if(s)return null;{const l=St(t,n);if(l>-1)return n[l]}}}}return null}loadPlaylist(t){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,t)}loadingPlaylist(t,n){super.loadingPlaylist(t,n);const s=t.id,o=t.groupId,l=this.getUrlWithDirectives(t.url,n),c=t.details,f=c==null?void 0:c.age;this.log(`Loading subtitle ${s} "${t.name}" lang:${t.lang} group:${o}${(n==null?void 0:n.msn)!==void 0?" at sn "+n.msn+" part "+n.part:""}${f&&c.live?" age "+f.toFixed(1)+(c.type?" "+c.type||0:""):""} ${l}`),this.hls.trigger(S.SUBTITLE_TRACK_LOADING,{url:l,id:s,groupId:o,deliveryDirectives:n||null,track:t})}toggleTrackModes(){const{media:t}=this;if(!t)return;const n=Ms(t.textTracks),s=this.currentTrack;let o;if(s&&(o=n.filter(l=>gu(s,l))[0],o||this.warn(`Unable to find subtitle TextTrack with name "${s.name}" and language "${s.lang}"`)),[].slice.call(n).forEach(l=>{l.mode!=="disabled"&&l!==o&&(l.mode="disabled")}),o){const l=this.subtitleDisplay?"showing":"hidden";o.mode!==l&&(o.mode=l)}}setSubtitleTrack(t){const n=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=t;return}if(t<-1||t>=n.length||!ce(t)){this.warn(`Invalid subtitle track id: ${t}`);return}this.selectDefaultTrack=!1;const s=this.currentTrack,o=n[t]||null;if(this.trackId=t,this.currentTrack=o,this.toggleTrackModes(),!o){this.hls.trigger(S.SUBTITLE_TRACK_SWITCH,{id:t});return}const l=!!o.details&&!o.details.live;if(t===this.trackId&&o===s&&l)return;this.log(`Switching to subtitle-track ${t}`+(o?` "${o.name}" lang:${o.lang} group:${o.groupId}`:""));const{id:c,groupId:f="",name:_,type:m,url:v}=o;this.hls.trigger(S.SUBTITLE_TRACK_SWITCH,{id:c,groupId:f,name:_,type:m,url:v});const y=this.switchParams(o.url,s==null?void 0:s.details,o.details);this.loadPlaylist(y)}}function Da(){try{return crypto.randomUUID()}catch(h){try{const t=URL.createObjectURL(new Blob),n=t.toString();return URL.revokeObjectURL(t),n.slice(n.lastIndexOf("/")+1)}catch(t){let n=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,o=>{const l=(n+Math.random()*16)%16|0;return n=Math.floor(n/16),(o=="x"?l:l&3|8).toString(16)})}}}function Ca(h){let t=5381,n=h.length;for(;n;)t=t*33^h.charCodeAt(--n);return(t>>>0).toString()}const ha=.025;let co=function(h){return h[h.Point=0]="Point",h[h.Range=1]="Range",h}({});function Mu(h,t,n){return`${h.identifier}-${n+1}-${Ca(t)}`}class Md{constructor(t,n){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=n,this.dateRange=t,this.setDateRange(t)}setDateRange(t){this.dateRange=t,this.resumeOffset=t.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=t.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=t.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=t.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var t;this.appendInPlaceStarted=!1,(t=this.assetListLoader)==null||t.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(t){var n;if(t>0&&t>=this.assetList.length)return!0;const s=this.playoutLimit;return t<=0||isNaN(s)?!1:s===0?!0:(((n=this.assetList[t])==null?void 0:n.startOffset)||0)>s}findAssetIndex(t){return this.assetList.indexOf(t)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const t=this.dateRange.startTime;if(this.snapOptions.out){const n=this.dateRange.tagAnchor;if(n)return Ru(t,n)}return t}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(this.startTime===0||this.snapOptions.out)return!0;const t=this.dateRange.tagAnchor;if(t){const n=this.dateRange.startTime,s=Ru(n,t);return n-s<.1}return!1}get resumptionOffset(){const t=this.resumeOffset,n=ce(t)?t:this.duration;return this.cumulativeDuration+n}get resumeTime(){const t=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const n=this.resumeAnchor;if(n)return Ru(t,n)}return t}get appendInPlace(){return this.appendInPlaceStarted?!0:this.appendInPlaceDisabled?!1:!!(!this.cue.once&&!this.cue.pre&&this.startIsAligned&&(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<ha))}set appendInPlace(t){if(this.appendInPlaceStarted){this.resetOnResume=!t;return}this.appendInPlaceDisabled=!t}get timelineStart(){return this._timelineStart!==null?this._timelineStart:this.startTime}set timelineStart(t){this._timelineStart=t}get duration(){const t=this.playoutLimit;let n;return this._duration!==null?n=this._duration:this.dateRange.duration?n=this.dateRange.duration:n=this.dateRange.plannedDuration||0,!isNaN(t)&&t<n&&(n=t),n}set duration(t){this._duration=t}get cue(){return this.dateRange.cue}get timelineOccupancy(){return this.dateRange.attr["X-TIMELINE-OCCUPIES"]==="RANGE"?co.Range:co.Point}get supplementsPrimary(){return this.dateRange.attr["X-TIMELINE-STYLE"]==="PRIMARY"}get contentMayVary(){return this.dateRange.attr["X-CONTENT-MAY-VARY"]!=="NO"}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||this.assetListResponse!==null}toString(){return Rd(this)}}function Ru(h,t){return h-t.start<t.duration/2&&!(Math.abs(h-(t.start+t.duration))<ha)?t.start:t.start+t.duration}function Uc(h,t,n){const s=new self.URL(h,n);return s.protocol!=="data:"&&s.searchParams.set("_HLS_primary_id",t),s}function Iu(h,t){for(;(n=h.assetList[++t])!=null&&n.error;)var n;return t}function Rd(h){return`["${h.identifier}" ${h.cue.pre?"<pre>":h.cue.post?"<post>":""}${h.timelineStart.toFixed(2)}-${h.resumeTime.toFixed(2)}]`}function ho(h){const t=h.timelineStart,n=h.duration||0;return`["${h.identifier}" ${t.toFixed(2)}-${(t+n).toFixed(2)}]`}class Id{constructor(t,n,s,o){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(S.PLAYOUT_LIMIT_REACHED,{})};const l=this.hls=new t(n);this.interstitial=s,this.assetItem=o;const c=()=>{this.hasDetails=!0};l.once(S.LEVEL_LOADED,c),l.once(S.AUDIO_TRACK_LOADED,c),l.once(S.SUBTITLE_TRACK_LOADED,c),l.on(S.MEDIA_ATTACHING,(f,{media:_})=>{this.removeMediaListeners(),this.mediaAttached=_,this.interstitial.playoutLimit&&(_.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&l.on(S.BUFFER_APPENDED,()=>{const v=this.bufferedEnd;this.reachedPlayout(v)&&(this._bufferedEosTime=v,l.trigger(S.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){const t=this.hls;if(t)if(t.url)t.levels.length&&!t.started&&t.startLoad(-1,!0);else{let n=this.assetItem.uri;try{n=Uc(n,t.config.primarySessionId||"").href}catch(s){}t.loadSource(n)}}bufferedInPlaceToEnd(t){var n;if(!this.appendInPlace)return!1;if((n=this.hls)!=null&&n.bufferedToEnd)return!0;if(!t)return!1;const s=Math.min(this._bufferedEosTime||1/0,this.duration),o=this.timelineOffset,l=Wt.bufferInfo(t,o,0);return this.getAssetTime(l.end)>=s-.02}reachedPlayout(t){const s=this.interstitial.playoutLimit;return this.startOffset+t>=s}get destroyed(){var t;return!((t=this.hls)!=null&&t.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var t;return((t=this.hls)==null?void 0:t.media)||null}get bufferedEnd(){const t=this.media||this.mediaAttached;if(!t)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const n=Wt.bufferInfo(t,t.currentTime,.001);return this.getAssetTime(n.end)}get currentTime(){const t=this.media||this.mediaAttached;return t?this.getAssetTime(t.currentTime):this._currentTime||0}get duration(){const t=this.assetItem.duration;if(!t)return 0;const n=this.interstitial.playoutLimit;if(n){const s=n-this.startOffset;if(s>0&&s<t)return s}return t}get remaining(){const t=this.duration;return t?Math.max(0,t-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var t;return((t=this.hls)==null?void 0:t.config.timelineOffset)||0}set timelineOffset(t){const n=this.timelineOffset;if(t!==n){const s=t-n;if(Math.abs(s)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=t}}}getAssetTime(t){const n=this.timelineOffset,s=this.duration;return Math.min(Math.max(0,t-n),s)}removeMediaListeners(){const t=this.mediaAttached;t&&(this._currentTime=t.currentTime,this.bufferSnapShot(),t.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){if(this.mediaAttached){var t;(t=this.hls)!=null&&t.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd)}}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(t){var n;this.loadSource(),(n=this.hls)==null||n.attachMedia(t)}detachMedia(){var t;this.removeMediaListeners(),this.mediaAttached=null,(t=this.hls)==null||t.detachMedia()}resumeBuffering(){var t;(t=this.hls)==null||t.resumeBuffering()}pauseBuffering(){var t;(t=this.hls)==null||t.pauseBuffering()}transferMedia(){var t;return this.bufferSnapShot(),((t=this.hls)==null?void 0:t.transferMedia())||null}resetDetails(){const t=this.hls;if(t&&this.hasDetails){t.stopLoad();const n=s=>delete s.details;t.levels.forEach(n),t.allAudioTracks.forEach(n),t.allSubtitleTracks.forEach(n),this.hasDetails=!1}}on(t,n,s){var o;(o=this.hls)==null||o.on(t,n)}once(t,n,s){var o;(o=this.hls)==null||o.once(t,n)}off(t,n,s){var o;(o=this.hls)==null||o.off(t,n)}toString(){var t;return`HlsAssetPlayer: ${ho(this.assetItem)} ${(t=this.hls)==null?void 0:t.sessionId} ${this.appendInPlace?"append-in-place":""}`}}const gf=.033;class Pd extends H{constructor(t,n){super("interstitials-sched",n),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=t}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(t=>t.reset()),this.events=this.items=null}resetErrorsInRange(t,n){return this.events?this.events.reduce((s,o)=>t<=o.startOffset&&n>o.startOffset?(delete o.error,s+1):s,0):0}get duration(){const t=this.items;return t?t[t.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(t){return t&&this.eventMap[t]||null}hasEvent(t){return t in this.eventMap}findItemIndex(t,n){if(t.event)return this.findEventIndex(t.event.identifier);let s=-1;t.nextEvent?s=this.findEventIndex(t.nextEvent.identifier)-1:t.previousEvent&&(s=this.findEventIndex(t.previousEvent.identifier)+1);const o=this.items;if(o)for(o[s]||(n===void 0&&(n=t.start),s=this.findItemIndexAtTime(n));s>=0&&(l=o[s])!=null&&l.event;){var l;s--}return s}findItemIndexAtTime(t,n){const s=this.items;if(s)for(let o=0;o<s.length;o++){let l=s[o];if(n&&n!=="primary"&&(l=l[n]),t===l.start||t>l.start&&t<l.end)return o}return-1}findJumpRestrictedIndex(t,n){const s=this.items;if(s)for(let o=t;o<=n&&s[o];o++){const l=s[o].event;if(l!=null&&l.restrictions.jump&&!l.appendInPlace)return o}return-1}findEventIndex(t){const n=this.items;if(n)for(let o=n.length;o--;){var s;if(((s=n[o].event)==null?void 0:s.identifier)===t)return o}return-1}findAssetIndex(t,n){const s=t.assetList,o=s.length;if(o>1)for(let l=0;l<o;l++){const c=s[l];if(!c.error){const f=c.timelineStart;if(n===f||n>f&&(n<f+(c.duration||0)||l===o-1))return l}}return 0}get assetIdAtEnd(){var t;const n=(t=this.items)==null||(t=t[this.length-1])==null?void 0:t.event;if(n){const s=n.assetList,o=s[s.length-1];if(o)return o.identifier}return null}parseInterstitialDateRanges(t,n){const s=t.main.details,{dateRanges:o}=s,l=this.events,c=this.parseDateRanges(o,{url:s.url},n),f=Object.keys(o),_=l?l.filter(m=>!f.includes(m.identifier)):[];c.length&&c.sort((m,v)=>{const y=m.cue.pre,x=m.cue.post,D=v.cue.pre,C=v.cue.post;if(y&&!D)return-1;if(D&&!y||x&&!C)return 1;if(C&&!x)return-1;if(!y&&!D&&!x&&!C){const B=m.startTime,F=v.startTime;if(B!==F)return B-F}return m.dateRange.tagOrder-v.dateRange.tagOrder}),this.events=c,_.forEach(m=>{this.removeEvent(m)}),this.updateSchedule(t,_)}updateSchedule(t,n=[],s=!1){const o=this.events||[];if(o.length||n.length||this.length<2){const l=this.items,c=this.parseSchedule(o,t);(s||n.length||(l==null?void 0:l.length)!==c.length||c.some((_,m)=>Math.abs(_.playout.start-l[m].playout.start)>.005||Math.abs(_.playout.end-l[m].playout.end)>.005))&&(this.items=c,this.onScheduleUpdate(n,l))}}parseDateRanges(t,n,s){const o=[],l=Object.keys(t);for(let c=0;c<l.length;c++){const f=l[c],_=t[f];if(_.isInterstitial){let m=this.eventMap[f];m?m.setDateRange(_):(m=new Md(_,n),this.eventMap[f]=m,s===!1&&(m.appendInPlace=s)),o.push(m)}}return o}parseSchedule(t,n){const s=[],o=n.main.details,l=o.live?1/0:o.edge;let c=0;if(t=t.filter(_=>!_.error&&!(_.cue.once&&_.hasPlayed)),t.length){this.resolveOffsets(t,n);let _=0,m=0;if(t.forEach((v,y)=>{const x=v.cue.pre,D=v.cue.post,C=t[y-1]||null,B=v.appendInPlace,F=D?l:v.startOffset,Q=v.duration,se=v.timelineOccupancy===co.Range?Q:0,le=v.resumptionOffset,Ee=(C==null?void 0:C.startTime)===F,Ie=F+v.cumulativeDuration;let Qe=B?Ie+Q:F+le;if(x||!D&&F<=0){const Ze=m;m+=se,v.timelineStart=Ie;const He=c;c+=Q,s.push({event:v,start:Ie,end:Qe,playout:{start:He,end:c},integrated:{start:Ze,end:m}})}else if(F<=l){if(!Ee){const Fe=F-_;if(Fe>gf){const bt=_,Xt=m;m+=Fe;const ci=c;c+=Fe;const yi={previousEvent:t[y-1]||null,nextEvent:v,start:bt,end:bt+Fe,playout:{start:ci,end:c},integrated:{start:Xt,end:m}};s.push(yi)}else Fe>0&&C&&(C.cumulativeDuration+=Fe,s[s.length-1].end=F)}D&&(Qe=Ie),v.timelineStart=Ie;const Ze=m;m+=se;const He=c;c+=Q,s.push({event:v,start:Ie,end:Qe,playout:{start:He,end:c},integrated:{start:Ze,end:m}})}else return;const Pe=v.resumeTime;D||Pe>l?_=l:_=Pe}),_<l){var f;const v=_,y=m,x=l-_;m+=x;const D=c;c+=x,s.push({previousEvent:((f=s[s.length-1])==null?void 0:f.event)||null,nextEvent:null,start:_,end:v+x,playout:{start:D,end:c},integrated:{start:y,end:m}})}this.setDurations(l,c,m)}else s.push({previousEvent:null,nextEvent:null,start:0,end:l,playout:{start:0,end:l},integrated:{start:0,end:l}}),this.setDurations(l,l,l);return s}setDurations(t,n,s){this.durations={primary:t,playout:n,integrated:s}}resolveOffsets(t,n){const s=n.main.details,o=s.live?1/0:s.edge;let l=0,c=-1;t.forEach((f,_)=>{const m=f.cue.pre,v=f.cue.post,y=m?0:v?o:f.startTime;this.updateAssetDurations(f),c===y?f.cumulativeDuration=l:(l=0,c=y),!v&&f.snapOptions.in&&(f.resumeAnchor=ui(null,s.fragments,f.startOffset+f.resumptionOffset,0,0)||void 0),f.appendInPlace&&!f.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(f,n)||(f.appendInPlace=!1)),!f.appendInPlace&&_+1<t.length&&t[_+1].startTime-t[_].resumeTime<gf&&(t[_+1].appendInPlace=!1,t[_+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${f}`));const D=ce(f.resumeOffset)?f.resumeOffset:f.duration;l+=D})}primaryCanResumeInPlaceAt(t,n){const s=t.resumeTime,o=t.startTime+t.resumptionOffset;return Math.abs(s-o)>ha?(this.log(`"${t.identifier}" resumption ${s} not aligned with estimated timeline end ${o}`),!1):!Object.keys(n).some(c=>{const f=n[c].details,_=f.edge;if(s>=_)return this.log(`"${t.identifier}" resumption ${s} past ${c} playlist end ${_}`),!1;const m=ui(null,f.fragments,s);if(!m)return this.log(`"${t.identifier}" resumption ${s} does not align with any fragments in ${c} playlist (${f.fragStart}-${f.fragmentEnd})`),!0;const v=c==="audio"?.175:0;return Math.abs(m.start-s)<ha+v||Math.abs(m.end-s)<ha+v?!1:(this.log(`"${t.identifier}" resumption ${s} not aligned with ${c} fragment bounds (${m.start}-${m.end} sn: ${m.sn} cc: ${m.cc})`),!0)})}updateAssetDurations(t){if(!t.assetListLoaded)return;const n=t.timelineStart;let s=0,o=!1,l=!1;for(let c=0;c<t.assetList.length;c++){const f=t.assetList[c],_=n+s;f.startOffset=s,f.timelineStart=_,o||(o=f.duration===null),l||(l=!!f.error);const m=f.error?0:f.duration||0;s+=m}o&&!l?t.duration=Math.max(s,t.duration):t.duration=s}removeEvent(t){t.reset(),delete this.eventMap[t.identifier]}}function Vs(h){return`[${h.event?'"'+h.event.identifier+'"':"primary"}: ${h.start.toFixed(2)}-${h.end.toFixed(2)}]`}class Od{constructor(t){this.hls=void 0,this.hls=t}destroy(){this.hls=null}loadAssetList(t,n){const s=t.assetListUrl;let o;try{o=Uc(s,this.hls.sessionId,t.baseUrl)}catch(x){const D=this.assignAssetListError(t,q.ASSET_LIST_LOAD_ERROR,x,s);this.hls.trigger(S.ERROR,D);return}n&&o.protocol!=="data:"&&o.searchParams.set("_HLS_start_offset",""+n);const l=this.hls.config,c=l.loader,f=new c(l),_={responseType:"json",url:o.href},m=l.interstitialAssetListLoadPolicy.default,v={loadPolicy:m,timeout:m.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},y={onSuccess:(x,D,C,B)=>{const F=x.data,Q=F==null?void 0:F.ASSETS;if(!Array.isArray(Q)){const se=this.assignAssetListError(t,q.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),C.url,D,B);this.hls.trigger(S.ERROR,se);return}t.assetListResponse=F,this.hls.trigger(S.ASSET_LIST_LOADED,{event:t,assetListResponse:F,networkDetails:B})},onError:(x,D,C,B)=>{const F=this.assignAssetListError(t,q.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${x.code} ${x.text} (${D.url})`),D.url,B,C);this.hls.trigger(S.ERROR,F)},onTimeout:(x,D,C)=>{const B=this.assignAssetListError(t,q.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${D.url})`),D.url,x,C);this.hls.trigger(S.ERROR,B)}};return f.load(_,v,y),this.hls.trigger(S.ASSET_LIST_LOADING,{event:t}),f}assignAssetListError(t,n,s,o,l,c){return t.error=s,{type:ge.NETWORK_ERROR,details:n,fatal:!1,interstitial:t,url:o,error:s,networkDetails:c,stats:l}}}function _f(h){h==null||h.play().catch(()=>{})}function Pu(h,t){return`[${h}] Advancing timeline position to ${t}`}class Ou extends H{constructor(t,n){super("interstitials",t.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const s=this.currentTime;if(s===void 0||this.playbackDisabled||!this.schedule)return;const o=s-this.timelinePos;if(Math.abs(o)<1/7056e5)return;const c=o<=-.01;this.timelinePos=s,this.bufferedPos=s;const f=this.playingItem;if(!f){this.checkBuffer();return}if(c&&this.schedule.resetErrorsInRange(s,s-o)&&this.updateSchedule(!0),this.checkBuffer(),c&&s<f.start||s>=f.end){var _;const D=this.findItemIndex(f);let C=this.schedule.findItemIndexAtTime(s);if(C===-1&&(C=D+(c?-1:1),this.log(`seeked ${c?"back ":""}to position not covered by schedule ${s} (resolving from ${D} to ${C})`)),!this.isInterstitial(f)&&(_=this.media)!=null&&_.paused&&(this.shouldPlay=!1),!c&&C>D){const B=this.schedule.findJumpRestrictedIndex(D+1,C);if(B>D){this.setSchedulePosition(B);return}}this.setSchedulePosition(C);return}const m=this.playingAsset;if(!m){if(this.playingLastItem&&this.isInterstitial(f)){const D=f.event.assetList[0];D&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(s,D))}return}const v=m.timelineStart,y=m.duration||0;if(c&&s<v||s>=v+y){var x;(x=f.event)!=null&&x.appendInPlace&&(this.clearInterstitial(f.event,f),this.flushFrontBuffer(s)),this.setScheduleToAssetAtTime(s,m)}},this.onTimeupdate=()=>{const s=this.currentTime;if(s===void 0||this.playbackDisabled)return;if(s>this.timelinePos)this.timelinePos=s,s>this.bufferedPos&&this.checkBuffer();else return;const o=this.playingItem;if(!o||this.playingLastItem)return;if(s>=o.end){this.timelinePos=o.end;const f=this.findItemIndex(o);this.setSchedulePosition(f+1)}const l=this.playingAsset;if(!l)return;const c=l.timelineStart+(l.duration||0);s>=c&&this.setScheduleToAssetAtTime(s,l)},this.onScheduleUpdate=(s,o)=>{const l=this.schedule;if(!l)return;const c=this.playingItem,f=l.events||[],_=l.items||[],m=l.durations,v=s.map(B=>B.identifier),y=!!(f.length||v.length);(y||o)&&this.log(`INTERSTITIALS_UPDATED (${f.length}): ${f}
Schedule: ${_.map(B=>Vs(B))} pos: ${this.timelinePos}`),v.length&&this.log(`Removed events ${v}`);let x=null,D=null;c&&(x=this.updateItem(c,this.timelinePos),this.itemsMatch(c,x)?this.playingItem=x:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const C=this.bufferingItem;if(C&&(D=this.updateItem(C,this.bufferedPos),this.itemsMatch(C,D)?this.bufferingItem=D:C.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(C.event,null))),s.forEach(B=>{B.assetList.forEach(F=>{this.clearAssetPlayer(F.identifier,null)})}),this.playerQueue.forEach(B=>{if(B.interstitial.appendInPlace){const F=B.assetItem.timelineStart,Q=B.timelineOffset-F;if(Q)try{B.timelineOffset=F}catch(se){Math.abs(Q)>ha&&this.warn(`${se} ("${B.assetId}" ${B.timelineOffset}->${F})`)}}}),y||o){if(this.hls.trigger(S.INTERSTITIALS_UPDATED,{events:f.slice(0),schedule:_.slice(0),durations:m,removedIds:v}),this.isInterstitial(c)&&v.includes(c.event.identifier)){this.warn(`Interstitial "${c.event.identifier}" removed while playing`),this.primaryFallback(c.event);return}c&&this.trimInPlace(x,c),C&&D!==x&&this.trimInPlace(D,C),this.checkBuffer()}},this.hls=t,this.HlsPlayerClass=n,this.assetListLoader=new Od(t),this.schedule=new Pd(this.onScheduleUpdate,t.logger),this.registerListeners()}registerListeners(){const t=this.hls;t&&(t.on(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(S.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(S.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),t.on(S.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(S.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),t.on(S.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),t.on(S.ASSET_LIST_LOADED,this.onAssetListLoaded,this),t.on(S.BUFFER_APPENDED,this.onBufferAppended,this),t.on(S.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(S.BUFFERED_TO_END,this.onBufferedToEnd,this),t.on(S.MEDIA_ENDED,this.onMediaEnded,this),t.on(S.ERROR,this.onError,this),t.on(S.DESTROYING,this.onDestroying,this))}unregisterListeners(){const t=this.hls;t&&(t.off(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(S.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(S.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),t.off(S.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(S.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),t.off(S.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),t.off(S.ASSET_LIST_LOADED,this.onAssetListLoaded,this),t.off(S.BUFFER_CODECS,this.onBufferCodecs,this),t.off(S.BUFFER_APPENDED,this.onBufferAppended,this),t.off(S.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(S.BUFFERED_TO_END,this.onBufferedToEnd,this),t.off(S.MEDIA_ENDED,this.onMediaEnded,this),t.off(S.ERROR,this.onError,this),t.off(S.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var t;(t=this.getBufferingPlayer())==null||t.resumeBuffering()}pauseBuffering(){var t;(t=this.getBufferingPlayer())==null||t.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const t=this.primaryMedia||this.media;t&&this.removeMediaListeners(t)}removeMediaListeners(t){Ir(t,"play",this.onPlay),Ir(t,"pause",this.onPause),Ir(t,"seeking",this.onSeeking),Ir(t,"timeupdate",this.onTimeupdate)}onMediaAttaching(t,n){const s=this.media=n.media;vr(s,"seeking",this.onSeeking),vr(s,"timeupdate",this.onTimeupdate),vr(s,"play",this.onPlay),vr(s,"pause",this.onPause)}onMediaAttached(t,n){const s=this.effectivePlayingItem,o=this.detachedData;if(this.detachedData=null,s===null)this.checkStart();else if(!o){this.clearScheduleState();const l=this.findItemIndex(s);this.setSchedulePosition(l)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(t,n){const s=!!n.transferMedia,o=this.media;if(this.media=null,!s&&(o&&this.removeMediaListeners(o),this.detachedData)){const l=this.getBufferingPlayer();l&&(this.log(`Removing schedule state for detachedData and ${l}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,l.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;const t=this,n=()=>t.bufferingItem||t.waitingItem,s=y=>y&&t.getAssetPlayer(y.identifier),o=(y,x,D,C,B)=>{if(y){let F=y[x].start;const Q=y.event;if(Q){if(x==="playout"||Q.timelineOccupancy!==co.Point){const se=s(D);(se==null?void 0:se.interstitial)===Q&&(F+=se.assetItem.startOffset+se[B])}}else{const se=C==="bufferedPos"?c():t[C];F+=se-y.start}return F}return 0},l=(y,x)=>{var D;if(y!==0&&x!=="primary"&&(D=t.schedule)!=null&&D.length){var C;const B=t.schedule.findItemIndexAtTime(y),F=(C=t.schedule.items)==null?void 0:C[B];if(F){const Q=F[x].start-F.start;return y+Q}}return y},c=()=>{const y=t.bufferedPos;return y===Number.MAX_VALUE?f("primary"):Math.max(y,0)},f=y=>{var x,D;return(x=t.primaryDetails)!=null&&x.live?t.primaryDetails.edge:((D=t.schedule)==null?void 0:D.durations[y])||0},_=(y,x)=>{var D,C;const B=t.effectivePlayingItem;if(B!=null&&(D=B.event)!=null&&D.restrictions.skip||!t.schedule)return;t.log(`seek to ${y} "${x}"`);const F=t.effectivePlayingItem,Q=t.schedule.findItemIndexAtTime(y,x),se=(C=t.schedule.items)==null?void 0:C[Q],le=t.getBufferingPlayer(),Ee=le==null?void 0:le.interstitial,Ie=Ee==null?void 0:Ee.appendInPlace,Qe=F&&t.itemsMatch(F,se);if(F&&(Ie||Qe)){const Pe=s(t.playingAsset),Ze=(Pe==null?void 0:Pe.media)||t.primaryMedia;if(Ze){const He=x==="primary"?Ze.currentTime:o(F,x,t.playingAsset,"timelinePos","currentTime"),Fe=y-He,bt=(Ie?He:Ze.currentTime)+Fe;if(bt>=0&&(!Pe||Ie||bt<=Pe.duration)){Ze.currentTime=bt;return}}}if(se){let Pe=y;if(x!=="primary"){const He=se[x].start,Fe=y-He;Pe=se.start+Fe}const Ze=!t.isInterstitial(se);if((!t.isInterstitial(F)||F.event.appendInPlace)&&(Ze||se.event.appendInPlace)){const He=t.media||(Ie?le==null?void 0:le.media:null);He&&(He.currentTime=Pe)}else if(F){const He=t.findItemIndex(F);if(Q>He){const bt=t.schedule.findJumpRestrictedIndex(He+1,Q);if(bt>He){t.setSchedulePosition(bt);return}}let Fe=0;if(Ze)t.timelinePos=Pe,t.checkBuffer();else{const bt=se.event.assetList,Xt=y-(se[x]||se).start;for(let ci=bt.length;ci--;){const yi=bt[ci];if(yi.duration&&Xt>=yi.startOffset&&Xt<yi.startOffset+yi.duration){Fe=ci;break}}}t.setSchedulePosition(Q,Fe)}}},m=()=>{const y=t.effectivePlayingItem;if(t.isInterstitial(y))return y;const x=n();return t.isInterstitial(x)?x:null},v={get bufferedEnd(){const y=n(),x=t.bufferingItem;if(x&&x===y){var D;return o(x,"playout",t.bufferingAsset,"bufferedPos","bufferedEnd")-x.playout.start||((D=t.bufferingAsset)==null?void 0:D.startOffset)||0}return 0},get currentTime(){const y=m(),x=t.effectivePlayingItem;return x&&x===y?o(x,"playout",t.effectivePlayingAsset,"timelinePos","currentTime")-x.playout.start:0},set currentTime(y){const x=m(),D=t.effectivePlayingItem;D&&D===x&&_(y+D.playout.start,"playout")},get duration(){const y=m();return y?y.playout.end-y.playout.start:0},get assetPlayers(){var y;const x=(y=m())==null?void 0:y.event.assetList;return x?x.map(D=>t.getAssetPlayer(D.identifier)):[]},get playingIndex(){var y;const x=(y=m())==null?void 0:y.event;return x&&t.effectivePlayingAsset?x.findAssetIndex(t.effectivePlayingAsset):-1},get scheduleItem(){return m()}};return this.manager={get events(){var y;return((y=t.schedule)==null||(y=y.events)==null?void 0:y.slice(0))||[]},get schedule(){var y;return((y=t.schedule)==null||(y=y.items)==null?void 0:y.slice(0))||[]},get interstitialPlayer(){return m()?v:null},get playerQueue(){return t.playerQueue.slice(0)},get bufferingAsset(){return t.bufferingAsset},get bufferingItem(){return n()},get bufferingIndex(){const y=n();return t.findItemIndex(y)},get playingAsset(){return t.effectivePlayingAsset},get playingItem(){return t.effectivePlayingItem},get playingIndex(){const y=t.effectivePlayingItem;return t.findItemIndex(y)},primary:{get bufferedEnd(){return c()},get currentTime(){const y=t.timelinePos;return y>0?y:0},set currentTime(y){_(y,"primary")},get duration(){return f("primary")},get seekableStart(){var y;return((y=t.primaryDetails)==null?void 0:y.fragmentStart)||0}},integrated:{get bufferedEnd(){return o(n(),"integrated",t.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return o(t.effectivePlayingItem,"integrated",t.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(y){_(y,"integrated")},get duration(){return f("integrated")},get seekableStart(){var y;return l(((y=t.primaryDetails)==null?void 0:y.fragmentStart)||0,"integrated")}},skip:()=>{const y=t.effectivePlayingItem,x=y==null?void 0:y.event;if(x&&!x.restrictions.skip){const D=t.findItemIndex(y);if(x.appendInPlace){const C=y.playout.start+y.event.duration;_(C+.001,"playout")}else t.advanceAfterAssetEnded(x,D,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var t;const n=this.playingItem,s=(t=this.schedule)==null?void 0:t.items;return!this.playbackStarted||!n||!s?!1:this.findItemIndex(n)===s.length-1}get playbackStarted(){return this.effectivePlayingItem!==null}get currentTime(){var t,n;if(this.mediaSelection===null)return;const s=this.waitingItem||this.playingItem;if(this.isInterstitial(s)&&!s.event.appendInPlace)return;let o=this.media;!o&&(t=this.bufferingItem)!=null&&(t=t.event)!=null&&t.appendInPlace&&(o=this.primaryMedia);const l=(n=o)==null?void 0:n.currentTime;if(!(l===void 0||!ce(l)))return l}get primaryMedia(){var t;return this.media||((t=this.detachedData)==null?void 0:t.media)||null}isInterstitial(t){return!!(t!=null&&t.event)}retreiveMediaSource(t,n){const s=this.getAssetPlayer(t);s&&this.transferMediaFromPlayer(s,n)}transferMediaFromPlayer(t,n){const s=t.interstitial.appendInPlace,o=t.media;if(s&&o===this.primaryMedia){if(this.bufferingAsset=null,(!n||this.isInterstitial(n)&&!n.event.appendInPlace)&&n&&o){this.detachedData={media:o};return}const l=t.transferMedia();this.log(`transfer MediaSource from ${t} ${$t(l)}`),this.detachedData=l}else n&&o&&(this.shouldPlay||(this.shouldPlay=!o.paused))}transferMediaTo(t,n){var s,o;if(t.media===n)return;let l=null;const c=this.hls,f=t!==c,_=f&&t.interstitial.appendInPlace,m=(s=this.detachedData)==null?void 0:s.mediaSource;let v;if(c.media)_&&(l=c.transferMedia(),this.detachedData=l),v="Primary";else if(m){const C=this.getBufferingPlayer();C?(l=C.transferMedia(),v=`${C}`):v="detached MediaSource"}else v="detached media";if(!l){if(m)l=this.detachedData,this.log(`using detachedData: MediaSource ${$t(l)}`);else if(!this.detachedData||c.media===n){const C=this.playerQueue;C.length>1&&C.forEach(B=>{if(f&&B.interstitial.appendInPlace!==_){const F=B.interstitial;this.clearInterstitial(B.interstitial,null),F.appendInPlace=!1,F.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${F}`)}}),this.hls.detachMedia(),this.detachedData={media:n}}}const y=l&&"mediaSource"in l&&((o=l.mediaSource)==null?void 0:o.readyState)!=="closed",x=y&&l?l:n;this.log(`${y?"transfering MediaSource":"attaching media"} to ${f?t:"Primary"} from ${v} (media.currentTime: ${n.currentTime})`);const D=this.schedule;if(x===l&&D){const C=f&&t.assetId===D.assetIdAtEnd;x.overrides={duration:D.duration,endOfStream:!f||C,cueRemoval:!f}}t.attachMedia(x)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const t=this.schedule,n=t==null?void 0:t.events;if(!n||this.playbackDisabled||!this.media)return;this.bufferedPos===-1&&(this.bufferedPos=0);const s=this.timelinePos,o=this.effectivePlayingItem;if(s===-1){const l=this.hls.startPosition;if(this.log(Pu("checkStart",l)),this.timelinePos=l,n.length&&n[0].cue.pre){const c=t.findEventIndex(n[0].identifier);this.setSchedulePosition(c)}else if(l>=0||!this.primaryLive){const c=this.timelinePos=l>0?l:0,f=t.findItemIndexAtTime(c);this.setSchedulePosition(f)}}else if(o&&!this.playingItem){const l=t.findItemIndex(o);this.setSchedulePosition(l)}}advanceAssetBuffering(t,n){const s=t.event,o=s.findAssetIndex(n),l=Iu(s,o);if(!s.isAssetPastPlayoutLimit(l))this.bufferedToEvent(t,l);else if(this.schedule){var c;const f=(c=this.schedule.items)==null?void 0:c[this.findItemIndex(t)+1];f&&this.bufferedToItem(f)}}advanceAfterAssetEnded(t,n,s){const o=Iu(t,s);if(t.isAssetPastPlayoutLimit(o)){if(this.schedule){const l=this.schedule.items;if(l){const c=n+1,f=l.length;if(c>=f){this.setSchedulePosition(-1);return}const _=t.resumeTime;this.timelinePos<_&&(this.log(Pu("advanceAfterAssetEnded",_)),this.timelinePos=_,t.appendInPlace&&this.advanceInPlace(_),this.checkBuffer(this.bufferedPos<_)),this.setSchedulePosition(c)}}}else{if(t.appendInPlace){const l=t.assetList[o];l&&this.advanceInPlace(l.timelineStart)}this.setSchedulePosition(n,o)}}setScheduleToAssetAtTime(t,n){const s=this.schedule;if(!s)return;const o=n.parentIdentifier,l=s.getEvent(o);if(l){const c=s.findEventIndex(o),f=s.findAssetIndex(l,t);this.advanceAfterAssetEnded(l,c,f-1)}}setSchedulePosition(t,n){var s;const o=(s=this.schedule)==null?void 0:s.items;if(!o||this.playbackDisabled)return;const l=t>=0?o[t]:null;this.log(`setSchedulePosition ${t}, ${n} (${l&&Vs(l)}) pos: ${this.timelinePos}`);const c=this.waitingItem||this.playingItem,f=this.playingLastItem;if(this.isInterstitial(c)){const v=c.event,y=this.playingAsset,x=y==null?void 0:y.identifier,D=x?this.getAssetPlayer(x):null;if(D&&x&&(!this.eventItemsMatch(c,l)||n!==void 0&&x!==v.assetList[n].identifier)){var _;const C=v.findAssetIndex(y);if(this.log(`INTERSTITIAL_ASSET_ENDED ${C+1}/${v.assetList.length} ${ho(y)}`),this.endedAsset=y,this.playingAsset=null,this.hls.trigger(S.INTERSTITIAL_ASSET_ENDED,{asset:y,assetListIndex:C,event:v,schedule:o.slice(0),scheduleIndex:t,player:D}),c!==this.playingItem){this.itemsMatch(c,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(v,this.findItemIndex(this.playingItem),C);return}this.retreiveMediaSource(x,l),D.media&&!((_=this.detachedData)!=null&&_.mediaSource)&&D.detachMedia()}if(!this.eventItemsMatch(c,l)&&(this.endedItem=c,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${v} ${Vs(c)}`),v.hasPlayed=!0,this.hls.trigger(S.INTERSTITIAL_ENDED,{event:v,schedule:o.slice(0),scheduleIndex:t}),v.cue.once)){var m;this.updateSchedule();const C=(m=this.schedule)==null?void 0:m.items;if(l&&C){const B=this.findItemIndex(l);this.advanceSchedule(B,C,n,c,f)}return}}this.advanceSchedule(t,o,n,c,f)}advanceSchedule(t,n,s,o,l){const c=this.schedule;if(!c)return;const f=n[t]||null,_=this.primaryMedia,m=this.playerQueue;if(m.length&&m.forEach(v=>{const y=v.interstitial,x=c.findEventIndex(y.identifier);(x<t||x>t+1)&&this.clearInterstitial(y,f)}),this.isInterstitial(f)){this.timelinePos=Math.min(Math.max(this.timelinePos,f.start),f.end);const v=f.event;if(s===void 0){s=c.findAssetIndex(v,this.timelinePos);const C=Iu(v,s-1);if(v.isAssetPastPlayoutLimit(C)||v.appendInPlace&&this.timelinePos===f.end){this.advanceAfterAssetEnded(v,t,s);return}s=C}const y=this.waitingItem;this.assetsBuffered(f,_)||this.setBufferingItem(f);let x=this.preloadAssets(v,s);if(this.eventItemsMatch(f,y||o)||(this.waitingItem=f,this.log(`INTERSTITIAL_STARTED ${Vs(f)} ${v.appendInPlace?"append in place":""}`),this.hls.trigger(S.INTERSTITIAL_STARTED,{event:v,schedule:n.slice(0),scheduleIndex:t})),!v.assetListLoaded){this.log(`Waiting for ASSET-LIST to complete loading ${v}`);return}if(v.assetListLoader&&(v.assetListLoader.destroy(),v.assetListLoader=void 0),!_){this.log(`Waiting for attachMedia to start Interstitial ${v}`);return}this.waitingItem=this.endedItem=null,this.playingItem=f;const D=v.assetList[s];if(!D){this.advanceAfterAssetEnded(v,t,s||0);return}if(x||(x=this.getAssetPlayer(D.identifier)),x===null||x.destroyed){const C=v.assetList.length;this.warn(`asset ${s+1}/${C} player destroyed ${v}`),x=this.createAssetPlayer(v,D,s),x.loadSource()}if(!this.eventItemsMatch(f,this.bufferingItem)&&v.appendInPlace&&this.isAssetBuffered(D))return;this.startAssetPlayer(x,s,n,t,_),this.shouldPlay&&_f(x.media)}else f?(this.resumePrimary(f,t,o),this.shouldPlay&&_f(this.hls.media)):l&&this.isInterstitial(o)&&(this.endedItem=null,this.playingItem=o,o.event.appendInPlace||this.attachPrimary(c.durations.primary,null))}get playbackDisabled(){return this.hls.config.enableInterstitialPlayback===!1}get primaryDetails(){var t;return(t=this.mediaSelection)==null?void 0:t.main.details}get primaryLive(){var t;return!!((t=this.primaryDetails)!=null&&t.live)}resumePrimary(t,n,s){var o,l;if(this.playingItem=t,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(t),this.log(`resuming ${Vs(t)}`),!((o=this.detachedData)!=null&&o.mediaSource)){let f=this.timelinePos;(f<t.start||f>=t.end)&&(f=this.getPrimaryResumption(t,n),this.log(Pu("resumePrimary",f)),this.timelinePos=f),this.attachPrimary(f,t)}if(!s)return;const c=(l=this.schedule)==null?void 0:l.items;c&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${Vs(t)}`),this.hls.trigger(S.INTERSTITIALS_PRIMARY_RESUMED,{schedule:c.slice(0),scheduleIndex:n}),this.checkBuffer())}getPrimaryResumption(t,n){const s=t.start;if(this.primaryLive){const o=this.primaryDetails;if(n===0)return this.hls.startPosition;if(o&&(s<o.fragmentStart||s>o.edge))return this.hls.liveSyncPosition||-1}return s}isAssetBuffered(t){const n=this.getAssetPlayer(t.identifier);return n!=null&&n.hls?n.hls.bufferedToEnd:Wt.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=t.timelineStart+(t.duration||0)}attachPrimary(t,n,s){n?this.setBufferingItem(n):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const o=this.primaryMedia;if(!o)return;const l=this.hls;l.media?this.checkBuffer():(this.transferMediaTo(l,o),s&&this.startLoadingPrimaryAt(t,s)),s||(this.log(Pu("attachPrimary",t)),this.timelinePos=t,this.startLoadingPrimaryAt(t,s))}startLoadingPrimaryAt(t,n){var s;const o=this.hls;!o.loadingEnabled||!o.media||Math.abs((((s=o.mainForwardBufferInfo)==null?void 0:s.start)||o.media.currentTime)-t)>.5?o.startLoad(t,n):o.bufferingEnabled||o.resumeBuffering()}onManifestLoading(){var t;this.stopLoad(),(t=this.schedule)==null||t.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(S.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(S.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(t,n){if(n.level===-1||!this.schedule)return;const s=this.hls.levels[n.level];if(!s.details)return;const o=M(M({},this.mediaSelection||this.altSelection),{},{main:s});this.mediaSelection=o,this.schedule.parseInterstitialDateRanges(o,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(t,n){const s=this.hls.audioTracks[n.id],o=this.mediaSelection;if(!o){this.altSelection=M(M({},this.altSelection),{},{audio:s});return}const l=M(M({},o),{},{audio:s});this.mediaSelection=l}onSubtitleTrackUpdated(t,n){const s=this.hls.subtitleTracks[n.id],o=this.mediaSelection;if(!o){this.altSelection=M(M({},this.altSelection),{},{subtitles:s});return}const l=M(M({},o),{},{subtitles:s});this.mediaSelection=l}onAudioTrackSwitching(t,n){const s=wt(n);this.playerQueue.forEach(({hls:o})=>o&&(o.setAudioOption(n)||o.setAudioOption(s)))}onSubtitleTrackSwitch(t,n){const s=wt(n);this.playerQueue.forEach(({hls:o})=>o&&(o.setSubtitleOption(n)||n.id!==-1&&o.setSubtitleOption(s)))}onBufferCodecs(t,n){const s=n.tracks;s&&(this.requiredTracks=s)}onBufferAppended(t,n){this.checkBuffer()}onBufferFlushed(t,n){const s=this.playingItem;if(s&&!this.itemsMatch(s,this.bufferingItem)&&!this.isInterstitial(s)){const o=this.timelinePos;this.bufferedPos=o,this.checkBuffer()}}onBufferedToEnd(t){if(!this.schedule)return;const n=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&n){for(let o=0;o<n.length;o++){const l=n[o];if(l.cue.post){var s;const c=this.schedule.findEventIndex(l.identifier),f=(s=this.schedule.items)==null?void 0:s[c];this.isInterstitial(f)&&this.eventItemsMatch(f,this.bufferingItem)&&this.bufferedToItem(f,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(t){const n=this.playingItem;if(!this.playingLastItem&&n){const s=this.findItemIndex(n);this.setSchedulePosition(s+1)}else this.shouldPlay=!1}updateItem(t,n){var s;const o=(s=this.schedule)==null?void 0:s.items;if(t&&o){const l=this.findItemIndex(t,n);return o[l]||null}return null}trimInPlace(t,n){if(this.isInterstitial(t)&&t.event.appendInPlace&&n.end-t.end>.25){t.event.assetList.forEach((l,c)=>{t.event.isAssetPastPlayoutLimit(c)&&this.clearAssetPlayer(l.identifier,null)});const s=t.end+.25,o=Wt.bufferInfo(this.primaryMedia,s,0);(o.end>s||(o.nextStart||0)>s)&&(this.log(`trim buffered interstitial ${Vs(t)} (was ${Vs(n)})`),this.attachPrimary(s,null,!0),this.flushFrontBuffer(s))}}itemsMatch(t,n){return!!n&&(t===n||t.event&&n.event&&this.eventItemsMatch(t,n)||!t.event&&!n.event&&this.findItemIndex(t)===this.findItemIndex(n))}eventItemsMatch(t,n){var s;return!!n&&(t===n||t.event.identifier===((s=n.event)==null?void 0:s.identifier))}findItemIndex(t,n){return t&&this.schedule?this.schedule.findItemIndex(t,n):-1}updateSchedule(t=!1){var n;const s=this.mediaSelection;s&&((n=this.schedule)==null||n.updateSchedule(s,[],t))}checkBuffer(t){var n;const s=(n=this.schedule)==null?void 0:n.items;if(!s)return;const o=Wt.bufferInfo(this.primaryMedia,this.timelinePos,0);t&&(this.bufferedPos=this.timelinePos),t||(t=o.len<1),this.updateBufferedPos(o.end,s,t)}updateBufferedPos(t,n,s){const o=this.schedule,l=this.bufferingItem;if(this.bufferedPos>t||!o)return;if(n.length===1&&this.itemsMatch(n[0],l)){this.bufferedPos=t;return}const c=this.playingItem,f=this.findItemIndex(c);let _=o.findItemIndexAtTime(t);if(this.bufferedPos<t){var m;const v=this.findItemIndex(l),y=Math.min(v+1,n.length-1),x=n[y];if((_===-1&&l&&t>=l.end||(m=x.event)!=null&&m.appendInPlace&&t+.01>=x.start)&&(_=y),this.isInterstitial(l)){const D=l.event;if(y-f>1&&D.appendInPlace===!1||D.assetList.length===0&&D.assetListLoader)return}if(this.bufferedPos=t,_>v&&_>f)this.bufferedToItem(x);else{const D=this.primaryDetails;this.primaryLive&&D&&t>D.edge-D.targetduration&&x.start<D.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(x)&&this.preloadAssets(x.event,0)}}else s&&c&&!this.itemsMatch(c,l)&&(_===f?this.bufferedToItem(c):_===f+1&&this.bufferedToItem(n[_]))}assetsBuffered(t,n){return t.event.assetList.length===0?!1:!t.event.assetList.some(o=>{const l=this.getAssetPlayer(o.identifier);return!(l!=null&&l.bufferedInPlaceToEnd(n))})}setBufferingItem(t){const n=this.bufferingItem,s=this.schedule;if(!this.itemsMatch(t,n)&&s){const{items:o,events:l}=s;if(!o||!l)return n;const c=this.isInterstitial(t),f=this.getBufferingPlayer();this.bufferingItem=t,this.bufferedPos=Math.max(t.start,Math.min(t.end,this.timelinePos));const _=f?f.remaining:n?n.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${Vs(t)}`+(n?` (${_.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(c){const m=s.findAssetIndex(t.event,this.bufferedPos);t.event.assetList.forEach((v,y)=>{const x=this.getAssetPlayer(v.identifier);x&&(y===m&&x.loadSource(),x.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(m=>m.pauseBuffering());this.hls.trigger(S.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:l.slice(0),schedule:o.slice(0),bufferingIndex:this.findItemIndex(t),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==t&&(this.bufferingItem=t);return n}bufferedToItem(t,n=0){const s=this.setBufferingItem(t);if(!this.playbackDisabled){if(this.isInterstitial(t))this.bufferedToEvent(t,n);else if(s!==null){this.bufferingAsset=null;const o=this.detachedData;o?o.mediaSource?this.attachPrimary(t.start,t,!0):this.preloadPrimary(t):this.preloadPrimary(t)}}}preloadPrimary(t){const n=this.findItemIndex(t),s=this.getPrimaryResumption(t,n);this.startLoadingPrimaryAt(s)}bufferedToEvent(t,n){const s=t.event,o=s.assetList.length===0&&!s.assetListLoader,l=s.cue.once;if(o||!l){const c=this.preloadAssets(s,n);if(c!=null&&c.interstitial.appendInPlace){const f=this.primaryMedia;f&&this.bufferAssetPlayer(c,f)}}}preloadAssets(t,n){const s=t.assetUrl,o=t.assetList.length,l=o===0&&!t.assetListLoader,c=t.cue.once;if(l){const _=t.timelineStart;if(t.appendInPlace){var f;const x=this.playingItem;!this.isInterstitial(x)&&(x==null||(f=x.nextEvent)==null?void 0:f.identifier)===t.identifier&&this.flushFrontBuffer(_+.25)}let m,v=0;if(!this.playingItem&&this.primaryLive&&(v=this.hls.startPosition,v===-1&&(v=this.hls.liveSyncPosition||0)),v&&!(t.cue.pre||t.cue.post)){const x=v-_;x>0&&(m=Math.round(x*1e3)/1e3)}if(this.log(`Load interstitial asset ${n+1}/${s?1:o} ${t}${m?` live-start: ${v} start-offset: ${m}`:""}`),s)return this.createAsset(t,0,0,_,t.duration,s);const y=this.assetListLoader.loadAssetList(t,m);y&&(t.assetListLoader=y)}else if(!c&&o){for(let m=n;m<o;m++){const v=t.assetList[m],y=this.getAssetPlayerQueueIndex(v.identifier);(y===-1||this.playerQueue[y].destroyed)&&!v.error&&this.createAssetPlayer(t,v,m)}const _=t.assetList[n];if(_){const m=this.getAssetPlayer(_.identifier);return m&&m.loadSource(),m}}return null}flushFrontBuffer(t){const n=this.requiredTracks;if(!n)return;this.log(`Removing front buffer starting at ${t}`),Object.keys(n).forEach(o=>{this.hls.trigger(S.BUFFER_FLUSHING,{startOffset:t,endOffset:1/0,type:o})})}getAssetPlayerQueueIndex(t){const n=this.playerQueue;for(let s=0;s<n.length;s++)if(t===n[s].assetId)return s;return-1}getAssetPlayer(t){const n=this.getAssetPlayerQueueIndex(t);return this.playerQueue[n]||null}getBufferingPlayer(){const{playerQueue:t,primaryMedia:n}=this;if(n){for(let s=0;s<t.length;s++)if(t[s].media===n)return t[s]}return null}createAsset(t,n,s,o,l,c){const f={parentIdentifier:t.identifier,identifier:Mu(t,c,n),duration:l,startOffset:s,timelineStart:o,uri:c};return this.createAssetPlayer(t,f,n)}createAssetPlayer(t,n,s){const o=this.hls,l=o.userConfig;let c=l.videoPreference;const f=o.loadLevelObj||o.levels[o.currentLevel];(c||f)&&(c=k({},c),f.videoCodec&&(c.videoCodec=f.videoCodec),f.videoRange&&(c.allowedVideoRanges=[f.videoRange]));const _=o.audioTracks[o.audioTrack],m=o.subtitleTracks[o.subtitleTrack];let v=0;if(this.primaryLive||t.appendInPlace){const Ee=this.timelinePos-n.timelineStart;if(Ee>1){const Ie=n.duration;Ie&&Ee<Ie&&(v=Ee)}}const y=n.identifier,x=M(M({},l),{},{maxMaxBufferLength:Math.min(180,o.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:o.sessionId,assetPlayerId:y,abrEwmaDefaultEstimate:o.bandwidthEstimate,interstitialsController:void 0,startPosition:v,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:c,audioPreference:_||l.audioPreference,subtitlePreference:m||l.subtitlePreference});t.appendInPlace&&(t.appendInPlaceStarted=!0,n.timelineStart&&(x.timelineOffset=n.timelineStart));const D=x.cmcd;D!=null&&D.sessionId&&D.contentId&&(x.cmcd=k({},D,{contentId:Ca(n.uri)})),this.getAssetPlayer(y)&&this.warn(`Duplicate date range identifier ${t} and asset ${y}`);const C=new Id(this.HlsPlayerClass,x,t,n);this.playerQueue.push(C),t.assetList[s]=n;let B=!0;const F=Ee=>{if(Ee.live){var Ie;const Ze=new Error(`Interstitials MUST be VOD assets ${t}`),He={fatal:!0,type:ge.OTHER_ERROR,details:q.INTERSTITIAL_ASSET_ITEM_ERROR,error:Ze},Fe=((Ie=this.schedule)==null?void 0:Ie.findEventIndex(t.identifier))||-1;this.handleAssetItemError(He,t,Fe,s,Ze.message);return}const Qe=Ee.edge-Ee.fragmentStart,Pe=n.duration;(B||Pe===null||Qe>Pe)&&(B=!1,this.log(`Interstitial asset "${y}" duration change ${Pe} > ${Qe}`),n.duration=Qe,this.updateSchedule())};C.on(S.LEVEL_UPDATED,(Ee,{details:Ie})=>F(Ie)),C.on(S.LEVEL_PTS_UPDATED,(Ee,{details:Ie})=>F(Ie)),C.on(S.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const Q=(Ee,Ie)=>{const Qe=this.getAssetPlayer(y);if(Qe&&Ie.tracks){Qe.off(S.BUFFER_CODECS,Q),Qe.tracks=Ie.tracks;const Pe=this.primaryMedia;this.bufferingAsset===Qe.assetItem&&Pe&&!Qe.media&&this.bufferAssetPlayer(Qe,Pe)}};C.on(S.BUFFER_CODECS,Q);const se=()=>{var Ee;const Ie=this.getAssetPlayer(y);if(this.log(`buffered to end of asset ${Ie}`),!Ie||!this.schedule)return;const Qe=this.schedule.findEventIndex(t.identifier),Pe=(Ee=this.schedule.items)==null?void 0:Ee[Qe];this.isInterstitial(Pe)&&this.advanceAssetBuffering(Pe,n)};C.on(S.BUFFERED_TO_END,se);const le=Ee=>()=>{if(!this.getAssetPlayer(y)||!this.schedule)return;this.shouldPlay=!0;const Qe=this.schedule.findEventIndex(t.identifier);this.advanceAfterAssetEnded(t,Qe,Ee)};return C.once(S.MEDIA_ENDED,le(s)),C.once(S.PLAYOUT_LIMIT_REACHED,le(1/0)),C.on(S.ERROR,(Ee,Ie)=>{if(!this.schedule)return;const Qe=this.getAssetPlayer(y);if(Ie.details===q.BUFFER_STALLED_ERROR){if(Qe!=null&&Qe.appendInPlace){this.handleInPlaceStall(t);return}this.onTimeupdate(),this.checkBuffer(!0);return}this.handleAssetItemError(Ie,t,this.schedule.findEventIndex(t.identifier),s,`Asset player error ${Ie.error} ${t}`)}),C.on(S.DESTROYING,()=>{if(!this.getAssetPlayer(y)||!this.schedule)return;const Ie=new Error(`Asset player destroyed unexpectedly ${y}`),Qe={fatal:!0,type:ge.OTHER_ERROR,details:q.INTERSTITIAL_ASSET_ITEM_ERROR,error:Ie};this.handleAssetItemError(Qe,t,this.schedule.findEventIndex(t.identifier),s,Ie.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${ho(n)}`),this.hls.trigger(S.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:n,assetListIndex:s,event:t,player:C}),C}clearInterstitial(t,n){t.assetList.forEach(s=>{this.clearAssetPlayer(s.identifier,n)}),t.reset()}resetAssetPlayer(t){const n=this.getAssetPlayerQueueIndex(t);if(n!==-1){this.log(`reset asset player "${t}" after error`);const s=this.playerQueue[n];this.transferMediaFromPlayer(s,null),s.resetDetails()}}clearAssetPlayer(t,n){const s=this.getAssetPlayerQueueIndex(t);if(s!==-1){const o=this.playerQueue[s];this.log(`clear ${o} toSegment: ${n&&Vs(n)}`),this.transferMediaFromPlayer(o,n),this.playerQueue.splice(s,1),o.destroy()}}emptyPlayerQueue(){let t;for(;t=this.playerQueue.pop();)t.destroy();this.playerQueue=[]}startAssetPlayer(t,n,s,o,l){const{interstitial:c,assetItem:f,assetId:_}=t,m=c.assetList.length,v=this.playingAsset;this.endedAsset=null,this.playingAsset=f,(!v||v.identifier!==_)&&(v&&(this.clearAssetPlayer(v.identifier,s[o]),delete v.error),this.log(`INTERSTITIAL_ASSET_STARTED ${n+1}/${m} ${ho(f)}`),this.hls.trigger(S.INTERSTITIAL_ASSET_STARTED,{asset:f,assetListIndex:n,event:c,schedule:s.slice(0),scheduleIndex:o,player:t})),this.bufferAssetPlayer(t,l)}bufferAssetPlayer(t,n){var s,o;if(!this.schedule)return;const{interstitial:l,assetItem:c}=t,f=this.schedule.findEventIndex(l.identifier),_=(s=this.schedule.items)==null?void 0:s[f];if(!_)return;t.loadSource(),this.setBufferingItem(_),this.bufferingAsset=c;const m=this.getBufferingPlayer();if(m===t)return;const v=l.appendInPlace;if(v&&(m==null?void 0:m.interstitial.appendInPlace)===!1)return;const y=(m==null?void 0:m.tracks)||((o=this.detachedData)==null?void 0:o.tracks)||this.requiredTracks;if(v&&c!==this.playingAsset){if(!t.tracks){this.log(`Waiting for track info before buffering ${t}`);return}if(y&&!Be(y,t.tracks)){const x=new Error(`Asset ${ho(c)} SourceBuffer tracks ('${Object.keys(t.tracks)}') are not compatible with primary content tracks ('${Object.keys(y)}')`),D={fatal:!0,type:ge.OTHER_ERROR,details:q.INTERSTITIAL_ASSET_ITEM_ERROR,error:x},C=l.findAssetIndex(c);this.handleAssetItemError(D,l,f,C,x.message);return}}this.transferMediaTo(t,n)}handleInPlaceStall(t){const n=this.schedule,s=this.primaryMedia;if(!n||!s)return;const o=s.currentTime,l=n.findAssetIndex(t,o),c=t.assetList[l];if(c){const f=this.getAssetPlayer(c.identifier);if(f){const _=f.currentTime||o-c.timelineStart,m=f.duration-_;if(this.warn(`Stalled at ${_} of ${_+m} in ${f} ${t} (media.currentTime: ${o})`),_&&(m/s.playbackRate<.5||f.bufferedInPlaceToEnd(s))&&f.hls){const v=n.findEventIndex(t.identifier);this.advanceAfterAssetEnded(t,v,l)}}}}advanceInPlace(t){const n=this.primaryMedia;n&&n.currentTime<t&&(n.currentTime=t)}handleAssetItemError(t,n,s,o,l){if(t.details===q.BUFFER_STALLED_ERROR)return;const c=n.assetList[o]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${c&&ho(c)} ${t.error}`),!this.schedule)return;const f=(c==null?void 0:c.identifier)||"",_=this.getAssetPlayerQueueIndex(f),m=this.playerQueue[_]||null,v=this.schedule.items,y=k({},t,{fatal:!1,errorAction:bn(!0),asset:c,assetListIndex:o,event:n,schedule:v,scheduleIndex:s,player:m});if(this.hls.trigger(S.INTERSTITIAL_ASSET_ERROR,y),!t.fatal)return;const x=this.playingAsset,D=this.bufferingAsset,C=new Error(l);if(c&&(this.clearAssetPlayer(f,null),c.error=C),!n.assetList.some(B=>!B.error))n.error=C;else for(let B=o;B<n.assetList.length;B++)this.resetAssetPlayer(n.assetList[B].identifier);this.updateSchedule(!0),n.error?this.primaryFallback(n):x&&x.identifier===f?this.advanceAfterAssetEnded(n,s,o):D&&D.identifier===f&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,D)}primaryFallback(t){const n=t.timelineStart,s=this.effectivePlayingItem;if(s){this.log(`Fallback to primary from event "${t.identifier}" start: ${n} pos: ${this.timelinePos} playing: ${Vs(s)} error: ${t.error}`);let o=this.timelinePos;o===-1&&(o=this.hls.startPosition);const l=this.updateItem(s,o);if(this.itemsMatch(s,l)&&this.clearInterstitial(t,null),t.appendInPlace&&(this.attachPrimary(n,null),this.flushFrontBuffer(n)),!this.schedule)return;const c=this.schedule.findItemIndexAtTime(o);this.setSchedulePosition(c)}else this.checkStart()}onAssetListLoaded(t,n){var s,o;const l=n.event,c=l.identifier,f=n.assetListResponse.ASSETS;if(!((s=this.schedule)!=null&&s.hasEvent(c)))return;const _=l.timelineStart,m=l.duration;let v=0;f.forEach((B,F)=>{const Q=parseFloat(B.DURATION);this.createAsset(l,F,v,_+v,Q,B.URI),v+=Q}),l.duration=v,this.log(`Loaded asset-list with duration: ${v} (was: ${m}) ${l}`);const y=this.waitingItem,x=(y==null?void 0:y.event.identifier)===c;this.updateSchedule();const D=(o=this.bufferingItem)==null?void 0:o.event;if(x){var C;const B=this.schedule.findEventIndex(c),F=(C=this.schedule.items)==null?void 0:C[B];if(F){if(!this.playingItem&&this.timelinePos>F.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==B){l.error=new Error(`Interstitial no longer within playback range ${this.timelinePos} ${l}`),this.updateSchedule(!0),this.primaryFallback(l);return}this.setBufferingItem(F)}this.setSchedulePosition(B)}else if((D==null?void 0:D.identifier)===c){const B=l.assetList[0];if(B){const F=this.getAssetPlayer(B.identifier);if(D.appendInPlace){const Q=this.primaryMedia;F&&Q&&this.bufferAssetPlayer(F,Q)}else F&&F.loadSource()}}}onError(t,n){if(this.schedule)switch(n.details){case q.ASSET_LIST_PARSING_ERROR:case q.ASSET_LIST_LOAD_ERROR:case q.ASSET_LIST_LOAD_TIMEOUT:{const s=n.interstitial;s&&(this.updateSchedule(!0),this.primaryFallback(s));break}case q.BUFFER_STALLED_ERROR:{const s=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(s)&&s.event.appendInPlace){this.handleInPlaceStall(s.event);return}this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}const Uo=500;class fo extends Xl{constructor(t,n,s){super(t,n,s,"subtitle-stream-controller",P.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:t}=this;t.on(S.LEVEL_LOADED,this.onLevelLoaded,this),t.on(S.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(S.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(S.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(S.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(S.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:t}=this;t.off(S.LEVEL_LOADED,this.onLevelLoaded,this),t.off(S.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(S.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(S.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(S.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(S.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(t,n){this.stopLoad(),this.state=mt.IDLE,this.setInterval(Uo),this.nextLoadPosition=this.lastCurrentTime=t+this.timelineOffset,this.startPosition=n?-1:t,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(t,n){this.tracksBuffered=[],super.onMediaDetaching(t,n)}onLevelLoaded(t,n){this.mainDetails=n.details}onSubtitleFragProcessed(t,n){const{frag:s,success:o}=n;if(this.fragContextChanged(s)||(ze(s)&&(this.fragPrevious=s),this.state=mt.IDLE),!o)return;const l=this.tracksBuffered[this.currentTrackId];if(!l)return;let c;const f=s.start;for(let m=0;m<l.length;m++)if(f>=l[m].start&&f<=l[m].end){c=l[m];break}const _=s.start+s.duration;c?c.end=_:(c={start:f,end:_},l.push(c)),this.fragmentTracker.fragBuffered(s),this.fragBufferedComplete(s,null),this.media&&this.tick()}onBufferFlushing(t,n){const{startOffset:s,endOffset:o}=n;if(s===0&&o!==Number.POSITIVE_INFINITY){const l=o-1;if(l<=0)return;n.endOffsetSubtitles=Math.max(0,l),this.tracksBuffered.forEach(c=>{for(let f=0;f<c.length;){if(c[f].end<=l){c.shift();continue}else if(c[f].start<l)c[f].start=l;else break;f++}}),this.fragmentTracker.removeFragmentsInRange(s,l,P.SUBTITLE)}}onError(t,n){const s=n.frag;(s==null?void 0:s.type)===P.SUBTITLE&&(n.details===q.FRAG_GAP&&this.fragmentTracker.fragBuffered(s,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==mt.STOPPED&&(this.state=mt.IDLE))}onSubtitleTracksUpdated(t,{subtitleTracks:n}){if(this.levels&&gl(this.levels,n)){this.levels=n.map(s=>new Yn(s));return}this.tracksBuffered=[],this.levels=n.map(s=>{const o=new Yn(s);return this.tracksBuffered[o.id]=[],o}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,P.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(t,n){var s;if(this.currentTrackId=n.id,!((s=this.levels)!=null&&s.length)||this.currentTrackId===-1){this.clearInterval();return}const o=this.levels[this.currentTrackId];o!=null&&o.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,o&&this.state!==mt.STOPPED&&this.setInterval(Uo)}onSubtitleTrackLoaded(t,n){var s;const{currentTrackId:o,levels:l}=this,{details:c,id:f}=n;if(!l){this.warn(`Subtitle tracks were reset while loading level ${f}`);return}const _=l[f];if(f>=l.length||!_)return;this.log(`Subtitle track ${f} loaded [${c.startSN},${c.endSN}]${c.lastPartSn?`[part-${c.lastPartSn}-${c.lastPartIndex}]`:""},duration:${c.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let m=0;if(c.live||(s=_.details)!=null&&s.live){if(c.deltaUpdateFailed)return;const y=this.mainDetails;if(!y){this.startFragRequested=!1;return}const x=y.fragments[0];if(!_.details)c.hasProgramDateTime&&y.hasProgramDateTime?(Ea(c,y),m=c.fragmentStart):x&&(m=x.start,Lo(c,m));else{var v;m=this.alignPlaylists(c,_.details,(v=this.levelLastLoaded)==null?void 0:v.details),m===0&&x&&(m=x.start,Lo(c,m))}y&&!this.startFragRequested&&this.setStartPosition(y,m)}_.details=c,this.levelLastLoaded=_,f===o&&(this.hls.trigger(S.SUBTITLE_TRACK_UPDATED,{details:c,id:f,groupId:n.groupId}),this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===mt.IDLE&&(ui(null,c.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),_.details=void 0)))}_handleFragmentLoadComplete(t){const{frag:n,payload:s}=t,o=n.decryptdata,l=this.hls;if(!this.fragContextChanged(n)&&s&&s.byteLength>0&&o!=null&&o.key&&o.iv&&Xn(o.method)){const c=performance.now();this.decrypter.decrypt(new Uint8Array(s),o.key.buffer,o.iv.buffer,rs(o.method)).catch(f=>{throw l.trigger(S.ERROR,{type:ge.MEDIA_ERROR,details:q.FRAG_DECRYPT_ERROR,fatal:!1,error:f,reason:f.message,frag:n}),f}).then(f=>{const _=performance.now();l.trigger(S.FRAG_DECRYPTED,{frag:n,payload:f,stats:{tstart:c,tdecrypt:_}})}).catch(f=>{this.warn(`${f.name}: ${f.message}`),this.state=mt.IDLE})}}doTick(){if(!this.media){this.state=mt.IDLE;return}if(this.state===mt.IDLE){const{currentTrackId:t,levels:n}=this,s=n==null?void 0:n[t];if(!s||!n.length||!s.details||this.waitForLive(s))return;const{config:o}=this,l=this.getLoadPosition(),c=Wt.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],l,o.maxBufferHole),{end:f,len:_}=c,m=s.details,v=this.hls.maxBufferLength+m.levelTargetDuration;if(_>v)return;const y=m.fragments,x=y.length,D=m.edge;let C=null;const B=this.fragPrevious;if(f<D){const se=o.maxFragLookUpTolerance,le=f>D-se?0:se;C=ui(B,y,Math.max(y[0].start,f),le),!C&&B&&B.start<y[0].start&&(C=y[0])}else C=y[x-1];if(C=this.filterReplacedPrimary(C,s.details),!C)return;const F=C.sn-m.startSN,Q=y[F-1];if(Q&&Q.cc===C.cc&&this.fragmentTracker.getState(Q)===rn.NOT_LOADED&&(C=Q),this.fragmentTracker.getState(C)===rn.NOT_LOADED){const se=this.mapToInitFragWhenRequired(C);se&&this.loadFragment(se,s,f)}}}loadFragment(t,n,s){ze(t)?super.loadFragment(t,n,s):this._loadInitSegment(t,n)}get mediaBufferTimeRanges(){return new fa(this.tracksBuffered[this.currentTrackId]||[])}}class fa{constructor(t){this.buffered=void 0;const n=(s,o,l)=>{if(o=o>>>0,o>l-1)throw new DOMException(`Failed to execute '${s}' on 'TimeRanges': The index provided (${o}) is greater than the maximum bound (${l})`);return t[o][s]};this.buffered={get length(){return t.length},end(s){return n("end",s,t.length)},start(s){return n("start",s,t.length)}}}}const vf={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},zc=h=>String.fromCharCode(vf[h]||h),Rs=15,da=100,Fd={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},yf={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Bd={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Nd={25:2,26:4,29:6,30:8,31:10,27:13,28:15},$d=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Tn{constructor(){this.time=null,this.verboseLevel=0}log(t,n){if(this.verboseLevel>=t){const s=typeof n=="function"?n():n;re.log(`${this.time} [${t}] ${s}`)}}}const Qs=function(t){const n=[];for(let s=0;s<t.length;s++)n.push(t[s].toString(16));return n};class Tl{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(t){const n=["foreground","underline","italics","background","flash"];for(let s=0;s<n.length;s++){const o=n[s];t.hasOwnProperty(o)&&(this[o]=t[o])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash}copy(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class Kd{constructor(){this.uchar=" ",this.penState=new Tl}reset(){this.uchar=" ",this.penState.reset()}setChar(t,n){this.uchar=t,this.penState.copy(n)}setPenState(t){this.penState.copy(t)}equals(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)}copy(t){this.uchar=t.uchar,this.penState.copy(t.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class Ma{constructor(t){this.chars=[],this.pos=0,this.currPenState=new Tl,this.cueStartTime=null,this.logger=void 0;for(let n=0;n<da;n++)this.chars.push(new Kd);this.logger=t}equals(t){for(let n=0;n<da;n++)if(!this.chars[n].equals(t.chars[n]))return!1;return!0}copy(t){for(let n=0;n<da;n++)this.chars[n].copy(t.chars[n])}isEmpty(){let t=!0;for(let n=0;n<da;n++)if(!this.chars[n].isEmpty()){t=!1;break}return t}setCursor(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>da&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=da)}moveCursor(t){const n=this.pos+t;if(t>1)for(let s=this.pos+1;s<n+1;s++)this.chars[s].setPenState(this.currPenState);this.setCursor(n)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(t){t>=144&&this.backSpace();const n=zc(t);if(this.pos>=da){this.logger.log(0,()=>"Cannot insert "+t.toString(16)+" ("+n+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(n,this.currPenState),this.moveCursor(1)}clearFromPos(t){let n;for(n=t;n<da;n++)this.chars[n].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const t=[];let n=!0;for(let s=0;s<da;s++){const o=this.chars[s].uchar;o!==" "&&(n=!1),t.push(o)}return n?"":t.join("")}setPenStyles(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)}}class Fu{constructor(t){this.rows=[],this.currRow=Rs-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let n=0;n<Rs;n++)this.rows.push(new Ma(t));this.logger=t}reset(){for(let t=0;t<Rs;t++)this.rows[t].clear();this.currRow=Rs-1}equals(t){let n=!0;for(let s=0;s<Rs;s++)if(!this.rows[s].equals(t.rows[s])){n=!1;break}return n}copy(t){for(let n=0;n<Rs;n++)this.rows[n].copy(t.rows[n])}isEmpty(){let t=!0;for(let n=0;n<Rs;n++)if(!this.rows[n].isEmpty()){t=!1;break}return t}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(t){this.rows[this.currRow].insertChar(t)}setPen(t){this.rows[this.currRow].setPenStyles(t)}moveCursor(t){this.rows[this.currRow].moveCursor(t)}setCursor(t){this.logger.log(2,"setCursor: "+t),this.rows[this.currRow].setCursor(t)}setPAC(t){this.logger.log(2,()=>"pacData = "+$t(t));let n=t.row-1;if(this.nrRollUpRows&&n<this.nrRollUpRows-1&&(n=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==n){for(let f=0;f<Rs;f++)this.rows[f].clear();const l=this.currRow+1-this.nrRollUpRows,c=this.lastOutputScreen;if(c){const f=c.rows[l].cueStartTime,_=this.logger.time;if(f!==null&&_!==null&&f<_)for(let m=0;m<this.nrRollUpRows;m++)this.rows[n-this.nrRollUpRows+m+1].copy(c.rows[l+m])}}this.currRow=n;const s=this.rows[this.currRow];if(t.indent!==null){const l=t.indent,c=Math.max(l-1,0);s.setCursor(t.indent),t.color=s.chars[c].penState.foreground}const o={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(o)}setBkgData(t){this.logger.log(2,()=>"bkgData = "+$t(t)),this.backSpace(),this.setPen(t),this.insertChar(32)}setRollUpRows(t){this.nrRollUpRows=t}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const t=this.currRow+1-this.nrRollUpRows,n=this.rows.splice(t,1)[0];n.clear(),this.rows.splice(this.currRow,0,n),this.logger.log(2,"Rolling up")}getDisplayText(t){t=t||!1;const n=[];let s="",o=-1;for(let l=0;l<Rs;l++){const c=this.rows[l].getTextString();c&&(o=l+1,t?n.push("Row "+o+": '"+c+"'"):n.push(c.trim()))}return n.length>0&&(t?s="["+n.join(" | ")+"]":s=n.join(`
`)),s}getTextAndFormat(){return this.rows}}class Ra{constructor(t,n,s){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=n,this.mode=null,this.verbose=0,this.displayedMemory=new Fu(s),this.nonDisplayedMemory=new Fu(s),this.lastOutputScreen=new Fu(s),this.currRollUpRow=this.displayedMemory.rows[Rs-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=s}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[Rs-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(t){this.outputFilter=t}setPAC(t){this.writeScreen.setPAC(t)}setBkgData(t){this.writeScreen.setBkgData(t)}setMode(t){t!==this.mode&&(this.mode=t,this.logger.log(2,()=>"MODE="+t),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=t)}insertChars(t){for(let s=0;s<t.length;s++)this.writeScreen.insertChar(t[s]);const n=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>n+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(t){this.logger.log(2,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){const t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(t){this.logger.log(2,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)}ccMIDROW(t){const n={flash:!1};if(n.underline=t%2===1,n.italics=t>=46,n.italics)n.foreground="white";else{const s=Math.floor(t/2)-16,o=["white","green","blue","cyan","red","yellow","magenta"];n.foreground=o[s]}this.logger.log(2,"MIDROW: "+$t(n)),this.writeScreen.setPen(n)}outputDataUpdate(t=!1){const n=this.logger.time;n!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=n:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,n,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:n),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))}}class Vc{constructor(t,n,s){this.channels=void 0,this.currentChannel=0,this.cmdHistory=xf(),this.logger=void 0;const o=this.logger=new Tn;this.channels=[null,new Ra(t,n,o),new Ra(t+1,s,o)]}getHandler(t){return this.channels[t].getHandler()}setHandler(t,n){this.channels[t].setHandler(n)}addData(t,n){this.logger.time=t;for(let s=0;s<n.length;s+=2){const o=n[s]&127,l=n[s+1]&127;let c=!1,f=null;if(o===0&&l===0)continue;this.logger.log(3,()=>"["+Qs([n[s],n[s+1]])+"] -> ("+Qs([o,l])+")");const _=this.cmdHistory;if(o>=16&&o<=31){if(bf(o,l,_)){Zn(null,null,_),this.logger.log(3,()=>"Repeated command ("+Qs([o,l])+") is dropped");continue}Zn(o,l,this.cmdHistory),c=this.parseCmd(o,l),c||(c=this.parseMidrow(o,l)),c||(c=this.parsePAC(o,l)),c||(c=this.parseBackgroundAttributes(o,l))}else Zn(null,null,_);if(!c&&(f=this.parseChars(o,l),f)){const v=this.currentChannel;v&&v>0?this.channels[v].insertChars(f):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!c&&!f&&this.logger.log(2,()=>"Couldn't parse cleaned data "+Qs([o,l])+" orig: "+Qs([n[s],n[s+1]]))}}parseCmd(t,n){const s=(t===20||t===28||t===21||t===29)&&n>=32&&n<=47,o=(t===23||t===31)&&n>=33&&n<=35;if(!(s||o))return!1;const l=t===20||t===21||t===23?1:2,c=this.channels[l];return t===20||t===21||t===28||t===29?n===32?c.ccRCL():n===33?c.ccBS():n===34?c.ccAOF():n===35?c.ccAON():n===36?c.ccDER():n===37?c.ccRU(2):n===38?c.ccRU(3):n===39?c.ccRU(4):n===40?c.ccFON():n===41?c.ccRDC():n===42?c.ccTR():n===43?c.ccRTD():n===44?c.ccEDM():n===45?c.ccCR():n===46?c.ccENM():n===47&&c.ccEOC():c.ccTO(n-32),this.currentChannel=l,!0}parseMidrow(t,n){let s=0;if((t===17||t===25)&&n>=32&&n<=47){if(t===17?s=1:s=2,s!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const o=this.channels[s];return o?(o.ccMIDROW(n),this.logger.log(3,()=>"MIDROW ("+Qs([t,n])+")"),!0):!1}return!1}parsePAC(t,n){let s;const o=(t>=17&&t<=23||t>=25&&t<=31)&&n>=64&&n<=127,l=(t===16||t===24)&&n>=64&&n<=95;if(!(o||l))return!1;const c=t<=23?1:2;n>=64&&n<=95?s=c===1?Fd[t]:Bd[t]:s=c===1?yf[t]:Nd[t];const f=this.channels[c];return f?(f.setPAC(this.interpretPAC(s,n)),this.currentChannel=c,!0):!1}interpretPAC(t,n){let s;const o={color:null,italics:!1,indent:null,underline:!1,row:t};return n>95?s=n-96:s=n-64,o.underline=(s&1)===1,s<=13?o.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(s/2)]:s<=15?(o.italics=!0,o.color="white"):o.indent=Math.floor((s-16)/2)*4,o}parseChars(t,n){let s,o=null,l=null;if(t>=25?(s=2,l=t-8):(s=1,l=t),l>=17&&l<=19){let c;l===17?c=n+80:l===18?c=n+112:c=n+144,this.logger.log(2,()=>"Special char '"+zc(c)+"' in channel "+s),o=[c]}else t>=32&&t<=127&&(o=n===0?[t]:[t,n]);return o&&this.logger.log(3,()=>"Char codes = "+Qs(o).join(",")),o}parseBackgroundAttributes(t,n){const s=(t===16||t===24)&&n>=32&&n<=47,o=(t===23||t===31)&&n>=45&&n<=47;if(!(s||o))return!1;let l;const c={};t===16||t===24?(l=Math.floor((n-32)/2),c.background=$d[l],n%2===1&&(c.background=c.background+"_semi")):n===45?c.background="transparent":(c.foreground="black",n===47&&(c.underline=!0));const f=t<=23?1:2;return this.channels[f].setBkgData(c),!0}reset(){for(let t=0;t<Object.keys(this.channels).length;t++){const n=this.channels[t];n&&n.reset()}Zn(null,null,this.cmdHistory)}cueSplitAtTime(t){for(let n=0;n<this.channels.length;n++){const s=this.channels[n];s&&s.cueSplitAtTime(t)}}}function Zn(h,t,n){n.a=h,n.b=t}function bf(h,t,n){return n.a===h&&n.b===t}function xf(){return{a:null,b:null}}var Gc=function(){if(ri!=null&&ri.VTTCue)return self.VTTCue;const h=["","lr","rl"],t=["start","middle","end","left","right"];function n(f,_){if(typeof _!="string"||!Array.isArray(f))return!1;const m=_.toLowerCase();return~f.indexOf(m)?m:!1}function s(f){return n(h,f)}function o(f){return n(t,f)}function l(f,..._){let m=1;for(;m<arguments.length;m++){const v=arguments[m];for(const y in v)f[y]=v[y]}return f}function c(f,_,m){const v=this,y={enumerable:!0};v.hasBeenReset=!1;let x="",D=!1,C=f,B=_,F=m,Q=null,se="",le=!0,Ee="auto",Ie="start",Qe=50,Pe="middle",Ze=50,He="middle";Object.defineProperty(v,"id",l({},y,{get:function(){return x},set:function(Fe){x=""+Fe}})),Object.defineProperty(v,"pauseOnExit",l({},y,{get:function(){return D},set:function(Fe){D=!!Fe}})),Object.defineProperty(v,"startTime",l({},y,{get:function(){return C},set:function(Fe){if(typeof Fe!="number")throw new TypeError("Start time must be set to a number.");C=Fe,this.hasBeenReset=!0}})),Object.defineProperty(v,"endTime",l({},y,{get:function(){return B},set:function(Fe){if(typeof Fe!="number")throw new TypeError("End time must be set to a number.");B=Fe,this.hasBeenReset=!0}})),Object.defineProperty(v,"text",l({},y,{get:function(){return F},set:function(Fe){F=""+Fe,this.hasBeenReset=!0}})),Object.defineProperty(v,"region",l({},y,{get:function(){return Q},set:function(Fe){Q=Fe,this.hasBeenReset=!0}})),Object.defineProperty(v,"vertical",l({},y,{get:function(){return se},set:function(Fe){const bt=s(Fe);if(bt===!1)throw new SyntaxError("An invalid or illegal string was specified.");se=bt,this.hasBeenReset=!0}})),Object.defineProperty(v,"snapToLines",l({},y,{get:function(){return le},set:function(Fe){le=!!Fe,this.hasBeenReset=!0}})),Object.defineProperty(v,"line",l({},y,{get:function(){return Ee},set:function(Fe){if(typeof Fe!="number"&&Fe!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");Ee=Fe,this.hasBeenReset=!0}})),Object.defineProperty(v,"lineAlign",l({},y,{get:function(){return Ie},set:function(Fe){const bt=o(Fe);if(!bt)throw new SyntaxError("An invalid or illegal string was specified.");Ie=bt,this.hasBeenReset=!0}})),Object.defineProperty(v,"position",l({},y,{get:function(){return Qe},set:function(Fe){if(Fe<0||Fe>100)throw new Error("Position must be between 0 and 100.");Qe=Fe,this.hasBeenReset=!0}})),Object.defineProperty(v,"positionAlign",l({},y,{get:function(){return Pe},set:function(Fe){const bt=o(Fe);if(!bt)throw new SyntaxError("An invalid or illegal string was specified.");Pe=bt,this.hasBeenReset=!0}})),Object.defineProperty(v,"size",l({},y,{get:function(){return Ze},set:function(Fe){if(Fe<0||Fe>100)throw new Error("Size must be between 0 and 100.");Ze=Fe,this.hasBeenReset=!0}})),Object.defineProperty(v,"align",l({},y,{get:function(){return He},set:function(Fe){const bt=o(Fe);if(!bt)throw new SyntaxError("An invalid or illegal string was specified.");He=bt,this.hasBeenReset=!0}})),v.displayState=void 0}return c.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},c}();class wf{decode(t,n){if(!t)return"";if(typeof t!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function Al(h){function t(s,o,l,c){return(s|0)*3600+(o|0)*60+(l|0)+parseFloat(c||0)}const n=h.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return n?parseFloat(n[2])>59?t(n[2],n[3],0,n[4]):t(n[1],n[2],n[3],n[4]):null}class zo{constructor(){this.values=Object.create(null)}set(t,n){!this.get(t)&&n!==""&&(this.values[t]=n)}get(t,n,s){return s?this.has(t)?this.values[t]:n[s]:this.has(t)?this.values[t]:n}has(t){return t in this.values}alt(t,n,s){for(let o=0;o<s.length;++o)if(n===s[o]){this.set(t,n);break}}integer(t,n){/^-?\d+$/.test(n)&&this.set(t,parseInt(n,10))}percent(t,n){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(n)){const s=parseFloat(n);if(s>=0&&s<=100)return this.set(t,s),!0}return!1}}function Hc(h,t,n,s){const o=s?h.split(s):[h];for(const l in o){if(typeof o[l]!="string")continue;const c=o[l].split(n);if(c.length!==2)continue;const f=c[0],_=c[1];t(f,_)}}const zr=new Gc(0,0,""),Ll=zr.align==="middle"?"middle":"center";function Sf(h,t,n){const s=h;function o(){const f=Al(h);if(f===null)throw new Error("Malformed timestamp: "+s);return h=h.replace(/^[^\sa-zA-Z-]+/,""),f}function l(f,_){const m=new zo;Hc(f,function(x,D){let C;switch(x){case"region":for(let B=n.length-1;B>=0;B--)if(n[B].id===D){m.set(x,n[B].region);break}break;case"vertical":m.alt(x,D,["rl","lr"]);break;case"line":C=D.split(","),m.integer(x,C[0]),m.percent(x,C[0])&&m.set("snapToLines",!1),m.alt(x,C[0],["auto"]),C.length===2&&m.alt("lineAlign",C[1],["start",Ll,"end"]);break;case"position":C=D.split(","),m.percent(x,C[0]),C.length===2&&m.alt("positionAlign",C[1],["start",Ll,"end","line-left","line-right","auto"]);break;case"size":m.percent(x,D);break;case"align":m.alt(x,D,["start",Ll,"end","left","right"]);break}},/:/,/\s/),_.region=m.get("region",null),_.vertical=m.get("vertical","");let v=m.get("line","auto");v==="auto"&&zr.line===-1&&(v=-1),_.line=v,_.lineAlign=m.get("lineAlign","start"),_.snapToLines=m.get("snapToLines",!0),_.size=m.get("size",100),_.align=m.get("align",Ll);let y=m.get("position","auto");y==="auto"&&zr.position===50&&(y=_.align==="start"||_.align==="left"?0:_.align==="end"||_.align==="right"?100:50),_.position=y}function c(){h=h.replace(/^\s+/,"")}if(c(),t.startTime=o(),c(),h.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+s);h=h.slice(3),c(),t.endTime=o(),c(),l(h,t)}function Et(h){return h.replace(/<br(?: \/)?>/gi,`
`)}class Jn{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new wf,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(t){const n=this;t&&(n.buffer+=n.decoder.decode(t,{stream:!0}));function s(){let l=n.buffer,c=0;for(l=Et(l);c<l.length&&l[c]!=="\r"&&l[c]!==`
`;)++c;const f=l.slice(0,c);return l[c]==="\r"&&++c,l[c]===`
`&&++c,n.buffer=l.slice(c),f}function o(l){Hc(l,function(c,f){},/:/)}try{let l="";if(n.state==="INITIAL"){if(!/\r\n|\n/.test(n.buffer))return this;l=s();const f=l.match(/^()?WEBVTT([ \t].*)?$/);if(!(f!=null&&f[0]))throw new Error("Malformed WebVTT signature.");n.state="HEADER"}let c=!1;for(;n.buffer;){if(!/\r\n|\n/.test(n.buffer))return this;switch(c?c=!1:l=s(),n.state){case"HEADER":/:/.test(l)?o(l):l||(n.state="ID");continue;case"NOTE":l||(n.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(l)){n.state="NOTE";break}if(!l)continue;if(n.cue=new Gc(0,0,""),n.state="CUE",l.indexOf("-->")===-1){n.cue.id=l;continue}case"CUE":if(!n.cue){n.state="BADCUE";continue}try{Sf(l,n.cue,n.regionList)}catch(f){n.cue=null,n.state="BADCUE";continue}n.state="CUETEXT";continue;case"CUETEXT":{const f=l.indexOf("-->")!==-1;if(!l||f&&(c=!0)){n.oncue&&n.cue&&n.oncue(n.cue),n.cue=null,n.state="ID";continue}if(n.cue===null)continue;n.cue.text&&(n.cue.text+=`
`),n.cue.text+=l}continue;case"BADCUE":l||(n.state="ID")}}}catch(l){n.state==="CUETEXT"&&n.cue&&n.oncue&&n.oncue(n.cue),n.cue=null,n.state=n.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const t=this;try{if((t.cue||t.state==="HEADER")&&(t.buffer+=`
`,t.parse()),t.state==="INITIAL"||t.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(n){t.onparsingerror&&t.onparsingerror(n)}return t.onflush&&t.onflush(),this}}const N0=/\r\n|\n\r|\n|\r/g,Ef=function(t,n,s=0){return t.slice(s,s+n.length)===n},kf=function(t){let n=parseInt(t.slice(-3));const s=parseInt(t.slice(-6,-4)),o=parseInt(t.slice(-9,-7)),l=t.length>9?parseInt(t.substring(0,t.indexOf(":"))):0;if(!ce(n)||!ce(s)||!ce(o)||!ce(l))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${t}`);return n+=1e3*s,n+=60*1e3*o,n+=60*60*1e3*l,n};function Bu(h,t,n){return Ca(h.toString())+Ca(t.toString())+Ca(n)}const Dl=function(t,n,s){let o=t[n],l=t[o.prevCC];if(!l||!l.new&&o.new){t.ccOffset=t.presentationOffset=o.start,o.new=!1;return}for(;(c=l)!=null&&c.new;){var c;t.ccOffset+=o.start-l.start,o.new=!1,o=l,l=t[o.prevCC]}t.presentationOffset=s};function Nu(h,t,n,s,o,l,c){const f=new Jn,_=Dt(new Uint8Array(h)).trim().replace(N0,`
`).split(`
`),m=[],v=t?Gh(t.baseTime,t.timescale):0;let y="00:00.000",x=0,D=0,C,B=!0;f.oncue=function(F){const Q=n[s];let se=n.ccOffset;const le=(x-v)/9e4;if(Q!=null&&Q.new&&(D!==void 0?se=n.ccOffset=Q.start:Dl(n,s,le)),le){if(!t){C=new Error("Missing initPTS for VTT MPEGTS");return}se=le-n.presentationOffset}const Ee=F.endTime-F.startTime,Ie=Qr((F.startTime+se-D)*9e4,o*9e4)/9e4;F.startTime=Math.max(Ie,0),F.endTime=Math.max(Ie+Ee,0);const Qe=F.text.trim();F.text=decodeURIComponent(encodeURIComponent(Qe)),F.id||(F.id=Bu(F.startTime,F.endTime,Qe)),F.endTime>0&&m.push(F)},f.onparsingerror=function(F){C=F},f.onflush=function(){if(C){c(C);return}l(m)},_.forEach(F=>{if(B)if(Ef(F,"X-TIMESTAMP-MAP=")){B=!1,F.slice(16).split(",").forEach(Q=>{Ef(Q,"LOCAL:")?y=Q.slice(6):Ef(Q,"MPEGTS:")&&(x=parseInt(Q.slice(7)))});try{D=kf(y)/1e3}catch(Q){C=Q}return}else F===""&&(B=!1);f.parse(F+`
`)}),f.flush()}const Wc="stpp.ttml.im1t",Tf=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,jc=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Vo={left:"start",center:"center",right:"end",start:"start",end:"end"};function Lr(h,t,n,s){const o=ve(new Uint8Array(h),["mdat"]);if(o.length===0){s(new Error("Could not parse IMSC1 mdat"));return}const l=o.map(f=>Dt(f)),c=hu(t.baseTime,1,t.timescale);try{l.forEach(f=>n(Cl(f,c)))}catch(f){s(f)}}function Cl(h,t){const o=new DOMParser().parseFromString(h,"text/xml").getElementsByTagName("tt")[0];if(!o)throw new Error("Invalid ttml");const l={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},c=Object.keys(l).reduce((y,x)=>(y[x]=o.getAttribute(`ttp:${x}`)||l[x],y),{}),f=o.getAttribute("xml:space")!=="preserve",_=Ia(Ml(o,"styling","style")),m=Ia(Ml(o,"layout","region")),v=Ml(o,"body","[begin]");return[].map.call(v,y=>{const x=ws(y,f);if(!x||!y.hasAttribute("begin"))return null;const D=$u(y.getAttribute("begin"),c),C=$u(y.getAttribute("dur"),c);let B=$u(y.getAttribute("end"),c);if(D===null)throw Go(y);if(B===null){if(C===null)throw Go(y);B=D+C}const F=new Gc(D-t,B-t,x);F.id=Bu(F.startTime,F.endTime,F.text);const Q=m[y.getAttribute("region")],se=_[y.getAttribute("style")],le=Ud(Q,se,_),{textAlign:Ee}=le;if(Ee){const Ie=Vo[Ee];Ie&&(F.lineAlign=Ie),F.align=Ee}return k(F,le),F}).filter(y=>y!==null)}function Ml(h,t,n){const s=h.getElementsByTagName(t)[0];return s?[].slice.call(s.querySelectorAll(n)):[]}function Ia(h){return h.reduce((t,n)=>{const s=n.getAttribute("xml:id");return s&&(t[s]=n),t},{})}function ws(h,t){return[].slice.call(h.childNodes).reduce((n,s,o)=>{var l;return s.nodeName==="br"&&o?n+`
`:(l=s.childNodes)!=null&&l.length?ws(s,t):t?n+s.textContent.trim().replace(/\s+/g," "):n+s.textContent},"")}function Ud(h,t,n){const s="http://www.w3.org/ns/ttml#styling";let o=null;const l=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],c=h!=null&&h.hasAttribute("style")?h.getAttribute("style"):null;return c&&n.hasOwnProperty(c)&&(o=n[c]),l.reduce((f,_)=>{const m=po(t,s,_)||po(h,s,_)||po(o,s,_);return m&&(f[_]=m),f},{})}function po(h,t,n){return h&&h.hasAttributeNS(t,n)?h.getAttributeNS(t,n):null}function Go(h){return new Error(`Could not parse ttml timestamp ${h}`)}function $u(h,t){if(!h)return null;let n=Al(h);return n===null&&(Tf.test(h)?n=zd(h,t):jc.test(h)&&(n=Ku(h,t))),n}function zd(h,t){const n=Tf.exec(h),s=(n[4]|0)+(n[5]|0)/t.subFrameRate;return(n[1]|0)*3600+(n[2]|0)*60+(n[3]|0)+s/t.frameRate}function Ku(h,t){const n=jc.exec(h),s=Number(n[1]);switch(n[2]){case"h":return s*3600;case"m":return s*60;case"ms":return s*1e3;case"f":return s/t.frameRate;case"t":return s/t.tickRate}return s}class Uu{constructor(t,n){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=n}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(t,n,s){(this.startTime===null||this.startTime>t)&&(this.startTime=t),this.endTime=n,this.screen=s,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}class Vd{constructor(t){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.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=zu(),this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},t.on(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(S.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(S.FRAG_LOADING,this.onFragLoading,this),t.on(S.FRAG_LOADED,this.onFragLoaded,this),t.on(S.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(S.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(S.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(S.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(S.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:t}=this;t.off(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(S.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(S.FRAG_LOADING,this.onFragLoading,this),t.off(S.FRAG_LOADED,this.onFragLoaded,this),t.off(S.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(S.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(S.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(S.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(S.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const t=new Uu(this,"textTrack1"),n=new Uu(this,"textTrack2"),s=new Uu(this,"textTrack3"),o=new Uu(this,"textTrack4");this.cea608Parser1=new Vc(1,t,n),this.cea608Parser2=new Vc(3,s,o)}addCues(t,n,s,o,l){let c=!1;for(let f=l.length;f--;){const _=l[f],m=Rl(_[0],_[1],n,s);if(m>=0&&(_[0]=Math.min(_[0],n),_[1]=Math.max(_[1],s),c=!0,m/(s-n)>.5))return}if(c||l.push([n,s]),this.config.renderTextTracksNatively){const f=this.captionsTracks[t];this.Cues.newCue(f,n,s,o)}else{const f=this.Cues.newCue(null,n,s,o);this.hls.trigger(S.CUES_PARSED,{type:"captions",cues:f,track:t})}}onInitPtsFound(t,{frag:n,id:s,initPTS:o,timescale:l,trackId:c}){const{unparsedVttFrags:f}=this;s===P.MAIN&&(this.initPTS[n.cc]={baseTime:o,timescale:l,trackId:c}),f.length&&(this.unparsedVttFrags=[],f.forEach(_=>{this.initPTS[_.frag.cc]?this.onFragLoaded(S.FRAG_LOADED,_):this.hls.trigger(S.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:_.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(t,n){const{media:s}=this;if(s)for(let o=0;o<s.textTracks.length;o++){const l=s.textTracks[o];if(Ho(l,{name:t,lang:n,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return l}return null}createCaptionsTrack(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)}createNativeTrack(t){if(this.captionsTracks[t])return;const{captionsProperties:n,captionsTracks:s,media:o}=this,{label:l,languageCode:c}=n[t],f=this.getExistingTrack(l,c);if(f)s[t]=f,$o(s[t]),pf(s[t],o);else{const _=this.createTextTrack("captions",l,c);_&&(_[t]=!0,s[t]=_)}}createNonNativeTrack(t){if(this.nonNativeCaptionsTracks[t])return;const n=this.captionsProperties[t];if(!n)return;const s=n.label,o={_id:t,label:s,kind:"captions",default:n.media?!!n.media.default:!1,closedCaptions:n.media};this.nonNativeCaptionsTracks[t]=o,this.hls.trigger(S.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[o]})}createTextTrack(t,n,s){const o=this.media;if(o)return o.addTextTrack(t,n,s)}onMediaAttaching(t,n){this.media=n.media,n.mediaSource||this._cleanTracks()}onMediaDetaching(t,n){const s=!!n.transferMedia;if(this.media=null,s)return;const{captionsTracks:o}=this;Object.keys(o).forEach(l=>{$o(o[l]),delete o[l]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=zu(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:t}=this;if(!t)return;const n=t.textTracks;if(n)for(let s=0;s<n.length;s++)$o(n[s])}onSubtitleTracksUpdated(t,n){const s=n.subtitleTracks||[],o=s.some(l=>l.textCodec===Wc);if(this.config.enableWebVTT||o&&this.config.enableIMSC1){if(gl(this.tracks,s)){this.tracks=s;return}if(this.textTracks=[],this.tracks=s,this.config.renderTextTracksNatively){const c=this.media,f=c?Ms(c.textTracks):null;if(this.tracks.forEach((_,m)=>{let v;if(f){let y=null;for(let x=0;x<f.length;x++)if(f[x]&&Ho(f[x],_)){y=f[x],f[x]=null;break}y&&(v=y)}if(v)$o(v);else{const y=Af(_);v=this.createTextTrack(y,_.name,_.lang),v&&(v.mode="disabled")}v&&this.textTracks.push(v)}),f!=null&&f.length){const _=f.filter(m=>m!==null).map(m=>m.label);_.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${_.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const c=this.tracks.map(f=>({label:f.name,kind:f.type.toLowerCase(),default:f.default,subtitleTrack:f}));this.hls.trigger(S.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:c})}}}onManifestLoaded(t,n){this.config.enableCEA708Captions&&n.captions&&n.captions.forEach(s=>{const o=/(?:CC|SERVICE)([1-4])/.exec(s.instreamId);if(!o)return;const l=`textTrack${o[1]}`,c=this.captionsProperties[l];c&&(c.label=s.name,s.lang&&(c.languageCode=s.lang),c.media=s)})}closedCaptionsForLevel(t){const n=this.hls.levels[t.level];return n==null?void 0:n.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,n){if(this.enabled&&n.frag.type===P.MAIN){var s,o;const{cea608Parser1:l,cea608Parser2:c,lastSn:f}=this,{cc:_,sn:m}=n.frag,v=(s=(o=n.part)==null?void 0:o.index)!=null?s:-1;l&&c&&(m!==f+1||m===f&&v!==this.lastPartIndex+1||_!==this.lastCc)&&(l.reset(),c.reset()),this.lastCc=_,this.lastSn=m,this.lastPartIndex=v}}onFragLoaded(t,n){const{frag:s,payload:o}=n;if(s.type===P.SUBTITLE)if(o.byteLength){const l=s.decryptdata,c="stats"in n;if(l==null||!l.encrypted||c){const f=this.tracks[s.level],_=this.vttCCs;_[s.cc]||(_[s.cc]={start:s.start,prevCC:this.prevCC,new:!0},this.prevCC=s.cc),f&&f.textCodec===Wc?this._parseIMSC1(s,o):this._parseVTTs(n)}}else this.hls.trigger(S.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,n){const s=this.hls;Lr(n,this.initPTS[t.cc],o=>{this._appendCues(o,t.level),s.trigger(S.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},o=>{s.logger.log(`Failed to parse IMSC1: ${o}`),s.trigger(S.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:o})})}_parseVTTs(t){var n;const{frag:s,payload:o}=t,{initPTS:l,unparsedVttFrags:c}=this,f=l.length-1;if(!l[s.cc]&&f===-1){c.push(t);return}const _=this.hls,m=(n=s.initSegment)!=null&&n.data?ht(s.initSegment.data,new Uint8Array(o)).buffer:o;Nu(m,this.initPTS[s.cc],this.vttCCs,s.cc,s.start,v=>{this._appendCues(v,s.level),_.trigger(S.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:s})},v=>{const y=v.message==="Missing initPTS for VTT MPEGTS";y?c.push(t):this._fallbackToIMSC1(s,o),_.logger.log(`Failed to parse VTT cue: ${v}`),!(y&&f>s.cc)&&_.trigger(S.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:v})})}_fallbackToIMSC1(t,n){const s=this.tracks[t.level];s.textCodec||Lr(n,this.initPTS[t.cc],()=>{s.textCodec=Wc,this._parseIMSC1(t,n)},()=>{s.textCodec="wvtt"})}_appendCues(t,n){const s=this.hls;if(this.config.renderTextTracksNatively){const o=this.textTracks[n];if(!o||o.mode==="disabled")return;t.forEach(l=>mf(o,l))}else{const o=this.tracks[n];if(!o)return;const l=o.default?"default":"subtitles"+n;s.trigger(S.CUES_PARSED,{type:"subtitles",cues:t,track:l})}}onFragDecrypted(t,n){const{frag:s}=n;s.type===P.SUBTITLE&&this.onFragLoaded(S.FRAG_LOADED,n)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,n){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:s,samples:o}=n;if(!(s.type===P.MAIN&&this.closedCaptionsForLevel(s)==="NONE"))for(let l=0;l<o.length;l++){const c=o[l].bytes;if(c){this.cea608Parser1||this.initCea608Parsers();const f=this.extractCea608Data(c);this.cea608Parser1.addData(o[l].pts,f[0]),this.cea608Parser2.addData(o[l].pts,f[1])}}}onBufferFlushing(t,{startOffset:n,endOffset:s,endOffsetSubtitles:o,type:l}){const{media:c}=this;if(!(!c||c.currentTime<s)){if(!l||l==="video"){const{captionsTracks:f}=this;Object.keys(f).forEach(_=>Js(f[_],n,s))}if(this.config.renderTextTracksNatively&&n===0&&o!==void 0){const{textTracks:f}=this;Object.keys(f).forEach(_=>Js(f[_],n,o))}}}extractCea608Data(t){const n=[[],[]],s=t[0]&31;let o=2;for(let l=0;l<s;l++){const c=t[o++],f=127&t[o++],_=127&t[o++];if(f===0&&_===0)continue;if((4&c)!==0){const v=3&c;(v===0||v===1)&&(n[v].push(f),n[v].push(_))}}return n}}function Af(h){return h.characteristics&&/transcribes-spoken-dialog/gi.test(h.characteristics)&&/describes-music-and-sound/gi.test(h.characteristics)?"captions":"subtitles"}function Ho(h,t){return!!h&&h.kind===Af(t)&&gu(t,h)}function Rl(h,t,n,s){return Math.min(t,s)-Math.max(h,n)}function zu(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}const mo=/\s/,Pa={newCue(h,t,n,s){const o=[];let l,c,f,_,m;const v=self.VTTCue||self.TextTrackCue;for(let x=0;x<s.rows.length;x++)if(l=s.rows[x],f=!0,_=0,m="",!l.isEmpty()){var y;for(let B=0;B<l.chars.length;B++)mo.test(l.chars[B].uchar)&&f?_++:(m+=l.chars[B].uchar,f=!1);l.cueStartTime=t,t===n&&(n+=1e-4),_>=16?_--:_++;const D=Et(m.trim()),C=Bu(t,n,D);h!=null&&(y=h.cues)!=null&&y.getCueById(C)||(c=new v(t,n,D),c.id=C,c.line=x+1,c.align="left",c.position=10+Math.min(80,Math.floor(_*8/32)*10),o.push(c))}return h&&o.length&&(o.sort((x,D)=>x.line==="auto"||D.line==="auto"?0:x.line>8&&D.line>8?D.line-x.line:x.line-D.line),o.forEach(x=>mf(h,x))),o}};function Gd(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(h){}return!1}const Lf=/(\d+)-(\d+)\/(\d+)/;class Vu{constructor(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||jd,this.controller=new self.AbortController,this.stats=new L}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(t,n,s){const o=this.stats;if(o.loading.start)throw new Error("Loader can only be used once.");o.loading.start=self.performance.now();const l=Df(t,this.controller.signal),c=t.responseType==="arraybuffer",f=c?"byteLength":"length",{maxTimeToFirstByteMs:_,maxLoadTimeMs:m}=n.loadPolicy;this.context=t,this.config=n,this.callbacks=s,this.request=this.fetchSetup(t,l),self.clearTimeout(this.requestTimeout),n.timeout=_&&ce(_)?_:m,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(o,t,this.response))},n.timeout),(io(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(y=>{var x;this.response=this.loader=y;const D=Math.max(self.performance.now(),o.loading.start);if(self.clearTimeout(this.requestTimeout),n.timeout=m,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(o,t,this.response))},m-(D-o.loading.start)),!y.ok){const{status:B,statusText:F}=y;throw new qd(F||"fetch, bad network response",B,y)}o.loading.first=D,o.total=Wd(y.headers)||o.total;const C=(x=this.callbacks)==null?void 0:x.onProgress;return C&&ce(n.highWaterMark)?this.loadProgressively(y,o,t,n.highWaterMark,C):c?y.arrayBuffer():t.responseType==="json"?y.json():y.text()}).then(y=>{var x,D;const C=this.response;if(!C)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),o.loading.end=Math.max(self.performance.now(),o.loading.first);const B=y[f];B&&(o.loaded=o.total=B);const F={url:C.url,data:y,code:C.status},Q=(x=this.callbacks)==null?void 0:x.onProgress;Q&&!ce(n.highWaterMark)&&Q(o,t,y,C),(D=this.callbacks)==null||D.onSuccess(F,o,t,C)}).catch(y=>{var x;if(self.clearTimeout(this.requestTimeout),o.aborted)return;const D=y&&y.code||0,C=y?y.message:null;(x=this.callbacks)==null||x.onError({code:D,text:C},t,y?y.details:null,o)})}getCacheAge(){let t=null;if(this.response){const n=this.response.headers.get("age");t=n?parseFloat(n):null}return t}getResponseHeader(t){return this.response?this.response.headers.get(t):null}loadProgressively(t,n,s,o=0,l){const c=new oc,f=t.body.getReader(),_=()=>f.read().then(m=>{if(m.done)return c.dataLength&&l(n,s,c.flush().buffer,t),Promise.resolve(new ArrayBuffer(0));const v=m.value,y=v.length;return n.loaded+=y,y<o||c.dataLength?(c.push(v),c.dataLength>=o&&l(n,s,c.flush().buffer,t)):l(n,s,v.buffer,t),_()}).catch(()=>Promise.reject());return _()}}function Df(h,t){const n={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(k({},h.headers))};return h.rangeEnd&&n.headers.set("Range","bytes="+h.rangeStart+"-"+String(h.rangeEnd-1)),n}function Hd(h){const t=Lf.exec(h);if(t)return parseInt(t[2])-parseInt(t[1])+1}function Wd(h){const t=h.get("Content-Range");if(t){const s=Hd(t);if(ce(s))return s}const n=h.get("Content-Length");if(n)return parseInt(n)}function jd(h,t){return new self.Request(h.url,t)}class qd extends Error{constructor(t,n,s){super(t),this.code=void 0,this.details=void 0,this.code=n,this.details=s}}const Zd=/^age:\s*[\d.]+\s*$/im;class qc{constructor(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new L,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,t.readyState!==4&&(this.stats.aborted=!0,t.abort()))}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(t,n,s){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=n,this.callbacks=s,this.loadInternal()}loadInternal(){const{config:t,context:n}=this;if(!t||!n)return;const s=this.loader=new self.XMLHttpRequest,o=this.stats;o.loading.first=0,o.loaded=0,o.aborted=!1;const l=this.xhrSetup;l?Promise.resolve().then(()=>{if(!(this.loader!==s||this.stats.aborted))return l(s,n.url)}).catch(c=>{if(!(this.loader!==s||this.stats.aborted))return s.open("GET",n.url,!0),l(s,n.url)}).then(()=>{this.loader!==s||this.stats.aborted||this.openAndSendXhr(s,n,t)}).catch(c=>{var f;(f=this.callbacks)==null||f.onError({code:s.status,text:c.message},n,s,o)}):this.openAndSendXhr(s,n,t)}openAndSendXhr(t,n,s){t.readyState||t.open("GET",n.url,!0);const o=n.headers,{maxTimeToFirstByteMs:l,maxLoadTimeMs:c}=s.loadPolicy;if(o)for(const f in o)t.setRequestHeader(f,o[f]);n.rangeEnd&&t.setRequestHeader("Range","bytes="+n.rangeStart+"-"+(n.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=n.responseType,self.clearTimeout(this.requestTimeout),s.timeout=l&&ce(l)?l:c,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout),t.send()}readystatechange(){const{context:t,loader:n,stats:s}=this;if(!t||!n)return;const o=n.readyState,l=this.config;if(!s.aborted&&o>=2&&(s.loading.first===0&&(s.loading.first=Math.max(self.performance.now(),s.loading.start),l.timeout!==l.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),l.timeout=l.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),l.loadPolicy.maxLoadTimeMs-(s.loading.first-s.loading.start)))),o===4)){self.clearTimeout(this.requestTimeout),n.onreadystatechange=null,n.onprogress=null;const m=n.status,v=n.responseType==="text"?n.responseText:null;if(m>=200&&m<300){const C=v!=null?v:n.response;if(C!=null){var c,f;s.loading.end=Math.max(self.performance.now(),s.loading.first);const B=n.responseType==="arraybuffer"?C.byteLength:C.length;s.loaded=s.total=B,s.bwEstimate=s.total*8e3/(s.loading.end-s.loading.first);const F=(c=this.callbacks)==null?void 0:c.onProgress;F&&F(s,t,C,n);const Q={url:n.responseURL,data:C,code:m};(f=this.callbacks)==null||f.onSuccess(Q,s,t,n);return}}const y=l.loadPolicy.errorRetry,x=s.retry,D={url:t.url,data:void 0,code:m};if(cn(y,x,!1,D))this.retry(y);else{var _;re.error(`${m} while loading ${t.url}`),(_=this.callbacks)==null||_.onError({code:m,text:n.statusText},t,n,s)}}}loadtimeout(){if(!this.config)return;const t=this.config.loadPolicy.timeoutRetry,n=this.stats.retry;if(cn(t,n,!0))this.retry(t);else{var s;re.warn(`timeout while loading ${(s=this.context)==null?void 0:s.url}`);const o=this.callbacks;o&&(this.abortInternal(),o.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:n,stats:s}=this;this.retryDelay=tn(t,s.retry),s.retry++,re.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${n==null?void 0:n.url}, retrying ${s.retry}/${t.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(t){const n=this.stats;n.loaded=t.loaded,t.lengthComputable&&(n.total=t.total)}getCacheAge(){let t=null;if(this.loader&&Zd.test(this.loader.getAllResponseHeaders())){const n=this.loader.getResponseHeader("age");t=n?parseFloat(n):null}return t}getResponseHeader(t){return this.loader&&new RegExp(`^${t}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null}}const Yd={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},Xd=M(M({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:qc,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Ci,bufferController:sn,capLevelController:us,errorController:Ln,fpsController:Cd,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:ir,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:Yd},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},Jd()),{},{subtitleStreamController:fo,subtitleTrackController:ca,timelineController:Vd,audioStreamController:mu,audioTrackController:ld,emeController:lo,cmcdController:ff,contentSteeringController:Ld,interstitialsController:Ou});function Jd(){return{cueHandler:Pa,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Qd(h,t,n){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(t.liveMaxLatencyDurationCount!==void 0&&(t.liveSyncDurationCount===void 0||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(t.liveMaxLatencyDuration!==void 0&&(t.liveSyncDuration===void 0||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const s=Zc(h),o=["manifest","level","frag"],l=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return o.forEach(c=>{const f=`${c==="level"?"playlist":c}LoadPolicy`,_=t[f]===void 0,m=[];l.forEach(v=>{const y=`${c}Loading${v}`,x=t[y];if(x!==void 0&&_){m.push(y);const D=s[f].default;switch(t[f]={default:D},v){case"TimeOut":D.maxLoadTimeMs=x,D.maxTimeToFirstByteMs=x;break;case"MaxRetry":D.errorRetry.maxNumRetry=x,D.timeoutRetry.maxNumRetry=x;break;case"RetryDelay":D.errorRetry.retryDelayMs=x,D.timeoutRetry.retryDelayMs=x;break;case"MaxRetryTimeout":D.errorRetry.maxRetryDelayMs=x,D.timeoutRetry.maxRetryDelayMs=x;break}}}),m.length&&n.warn(`hls.js config: "${m.join('", "')}" setting(s) are deprecated, use "${f}": ${$t(t[f])}`)}),M(M({},s),t)}function Zc(h){return h&&typeof h=="object"?Array.isArray(h)?h.map(Zc):Object.keys(h).reduce((t,n)=>(t[n]=Zc(h[n]),t),{}):h}function Cf(h,t){const n=h.loader;n!==Vu&&n!==qc?(t.log("[config]: Custom loader detected, cannot enable progressive streaming"),h.progressive=!1):Gd()&&(h.loader=Vu,h.progressive=!0,h.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}const Gu=2,e0=.1,t0=.05,Yc=100;class Mf extends hr{constructor(t,n){super("gap-controller",t.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var s;(s=this.media)!=null&&s.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{if(this.hls){var s;this.ended=((s=this.media)==null?void 0:s.currentTime)||1,this.hls.trigger(S.MEDIA_ENDED,{stalled:!1})}},this.hls=t,this.fragmentTracker=n,this.registerListeners()}registerListeners(){const{hls:t}=this;t&&(t.on(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(S.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:t}=this;t&&(t.off(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(S.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(t,n){this.setInterval(Yc),this.mediaSource=n.mediaSource;const s=this.media=n.media;vr(s,"playing",this.onMediaPlaying),vr(s,"waiting",this.onMediaWaiting),vr(s,"ended",this.onMediaEnded)}onMediaDetaching(t,n){this.clearInterval();const{media:s}=this;s&&(Ir(s,"playing",this.onMediaPlaying),Ir(s,"waiting",this.onMediaWaiting),Ir(s,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(t,n){this.buffered=n.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var t;if(!((t=this.media)!=null&&t.readyState)||!this.hasBuffered)return;const n=this.media.currentTime;this.poll(n,this.lastCurrentTime),this.lastCurrentTime=n}poll(t,n){var s,o;const l=(s=this.hls)==null?void 0:s.config;if(!l)return;const c=this.media;if(!c)return;const{seeking:f}=c,_=this.seeking&&!f,m=!this.seeking&&f,v=c.paused&&!f||c.ended||c.playbackRate===0;if(this.seeking=f,t!==n){n&&(this.ended=0),this.moved=!0,f||(this.nudgeRetry=0,l.nudgeOnVideoHole&&!v&&t>n&&this.nudgeOnVideoHole(t,n)),this.waiting===0&&this.stallResolved(t);return}if(m||_){_&&this.stallResolved(t);return}if(v){this.nudgeRetry=0,this.stallResolved(t),!this.ended&&c.ended&&this.hls&&(this.ended=t||1,this.hls.trigger(S.MEDIA_ENDED,{stalled:!1}));return}if(!Wt.getBuffered(c).length){this.nudgeRetry=0;return}const y=Wt.bufferInfo(c,t,0),x=y.nextStart||0,D=this.fragmentTracker;if(f&&D&&this.hls){const Qe=Xc(this.hls.inFlightFragments,t),Pe=y.len>Gu,Ze=!x||Qe||x-t>Gu&&!D.getPartialFragment(t);if(Pe||Ze)return;this.moved=!1}const C=(o=this.hls)==null?void 0:o.latestLevelDetails;if(!this.moved&&this.stalled!==null&&D){if(!(y.len>0)&&!x)return;const Pe=Math.max(x,y.start||0)-t,He=!!(C!=null&&C.live)?C.targetduration*2:Gu,Fe=Hu(t,D);if(Pe>0&&(Pe<=He||Fe)){c.paused||this._trySkipBufferHole(Fe);return}}const B=l.detectStallWithCurrentTimeMs,F=self.performance.now(),Q=this.waiting;let se=this.stalled;if(se===null)if(Q>0&&F-Q<B)se=this.stalled=Q;else{this.stalled=F;return}const le=F-se;if(!f&&(le>=B||Q)&&this.hls){var Ee;if(((Ee=this.mediaSource)==null?void 0:Ee.readyState)==="ended"&&!(C!=null&&C.live)&&Math.abs(t-((C==null?void 0:C.edge)||0))<1){if(this.ended)return;this.ended=t||1,this.hls.trigger(S.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(y),!this.media||!this.hls)return}const Ie=Wt.bufferInfo(c,t,l.maxBufferHole);this._tryFixBufferStall(Ie,le,t)}stallResolved(t){const n=this.stalled;if(n&&this.hls&&(this.stalled=null,this.stallReported)){const s=self.performance.now()-n;this.log(`playback not stuck anymore @${t}, after ${Math.round(s)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(S.STALL_RESOLVED,{})}}nudgeOnVideoHole(t,n){var s;const o=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(s=this.buffered.audio)!=null&&s.length&&o&&o.length>1&&t>o.end(0)){const l=Wt.bufferedInfo(Wt.timeRangesToArray(this.buffered.audio),t,0);if(l.len>1&&n>=l.start){const c=Wt.timeRangesToArray(o),f=Wt.bufferedInfo(c,n,0).bufferedIndex;if(f>-1&&f<c.length-1){const _=Wt.bufferedInfo(c,t,0).bufferedIndex,m=c[f].end,v=c[f+1].start;if((_===-1||_>f)&&v-m<1&&t-m<2){const y=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${t} hole: ${m} -> ${v} buffered index: ${_}`);this.warn(y.message),this.media.currentTime+=1e-6;let x=Hu(t,this.fragmentTracker);x&&"fragment"in x?x=x.fragment:x||(x=void 0);const D=Wt.bufferInfo(this.media,t,0);this.hls.trigger(S.ERROR,{type:ge.MEDIA_ERROR,details:q.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:y,reason:y.message,frag:x,buffer:D.len,bufferInfo:D})}}}}}_tryFixBufferStall(t,n,s){var o,l;const{fragmentTracker:c,media:f}=this,_=(o=this.hls)==null?void 0:o.config;if(!f||!c||!_)return;const m=(l=this.hls)==null?void 0:l.latestLevelDetails,v=Hu(s,c);if((v||m!=null&&m.live&&s<m.fragmentStart)&&(this._trySkipBufferHole(v)||!this.media))return;const y=t.buffered,x=this.adjacentTraversal(t,s);(y&&y.length>1&&t.len>_.maxBufferHole||t.nextStart&&(t.nextStart-s<_.maxBufferHole||x))&&(n>_.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(t))}adjacentTraversal(t,n){const s=this.fragmentTracker,o=t.nextStart;if(s&&o){const l=s.getFragAtPos(n,P.MAIN),c=s.getFragAtPos(o,P.MAIN);if(l&&c)return c.sn-l.sn<2}return!1}_reportStall(t){const{hls:n,media:s,stallReported:o,stalled:l}=this;if(!o&&l!==null&&s&&n){this.stallReported=!0;const c=new Error(`Playback stalling at @${s.currentTime} due to low buffer (${$t(t)})`);this.warn(c.message),n.trigger(S.ERROR,{type:ge.MEDIA_ERROR,details:q.BUFFER_STALLED_ERROR,fatal:!1,error:c,buffer:t.len,bufferInfo:t,stalled:{start:l}})}}_trySkipBufferHole(t){var n;const{fragmentTracker:s,media:o}=this,l=(n=this.hls)==null?void 0:n.config;if(!o||!s||!l)return 0;const c=o.currentTime,f=Wt.bufferInfo(o,c,0),_=c<f.start?f.start:f.nextStart;if(_&&this.hls){const v=f.len<=l.maxBufferHole,y=f.len>0&&f.len<1&&o.readyState<3,x=_-c;if(x>0&&(v||y)){if(x>l.maxBufferHole){let C=!1;if(c===0){const B=s.getAppendedFrag(0,P.MAIN);B&&_<B.end&&(C=!0)}if(!C&&t){var m;if(!((m=this.hls.loadLevelObj)!=null&&m.details)||Xc(this.hls.inFlightFragments,_))return 0;let F=!1,Q=t.end;for(;Q<_;){const se=Hu(Q,s);if(se)Q+=se.duration;else{F=!0;break}}if(F)return 0}}const D=Math.max(_+t0,c+e0);if(this.warn(`skipping hole, adjusting currentTime from ${c} to ${D}`),this.moved=!0,o.currentTime=D,!(t!=null&&t.gap)){const C=new Error(`fragment loaded with buffer holes, seeking from ${c} to ${D}`),B={type:ge.MEDIA_ERROR,details:q.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:C,reason:C.message,buffer:f.len,bufferInfo:f};t&&("fragment"in t?B.part=t:B.frag=t),this.hls.trigger(S.ERROR,B)}return D}}return 0}_tryNudgeBuffer(t){const{hls:n,media:s,nudgeRetry:o}=this,l=n==null?void 0:n.config;if(!s||!l)return 0;const c=s.currentTime;if(this.nudgeRetry++,o<l.nudgeMaxRetry){const f=c+(o+1)*l.nudgeOffset,_=new Error(`Nudging 'currentTime' from ${c} to ${f}`);this.warn(_.message),s.currentTime=f,n.trigger(S.ERROR,{type:ge.MEDIA_ERROR,details:q.BUFFER_NUDGE_ON_STALL,error:_,fatal:!1,buffer:t.len,bufferInfo:t})}else{const f=new Error(`Playhead still not moving while enough data buffered @${c} after ${l.nudgeMaxRetry} nudges`);this.error(f.message),n.trigger(S.ERROR,{type:ge.MEDIA_ERROR,details:q.BUFFER_STALLED_ERROR,error:f,fatal:!0,buffer:t.len,bufferInfo:t})}}}function Xc(h,t){const n=Rf(h.main);if(n&&n.start<=t)return n;const s=Rf(h.audio);return s&&s.start<=t?s:null}function Rf(h){if(!h)return null;switch(h.state){case mt.IDLE:case mt.STOPPED:case mt.ENDED:case mt.ERROR:return null}return h.frag}function Hu(h,t){return t.getAppendedFrag(h,P.MAIN)||t.getPartialFragment(h)}const i0=.25;function Jc(){if(typeof self!="undefined")return self.VTTCue||self.TextTrackCue}function Qc(h,t,n,s,o){let l=new h(t,n,"");try{l.value=s,o&&(l.type=o)}catch(c){l=new h(t,n,$t(o?M({type:o},s):s))}return l}const Wu=(()=>{const h=Jc();try{h&&new h(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class n0{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(S.EVENT_CUE_ENTER,{})},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:t}=this;t&&(t.on(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(S.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(S.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(S.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:t}=this;t&&(t.off(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(S.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(S.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(S.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(t,n){var s;this.media=n.media,((s=n.overrides)==null?void 0:s.cueRemoval)===!1&&(this.removeCues=!1)}onMediaAttached(){var t;const n=(t=this.hls)==null?void 0:t.latestLevelDetails;n&&this.updateDateRangeCues(n)}onMediaDetaching(t,n){this.media=null,!n.transferMedia&&(this.id3Track&&(this.removeCues&&$o(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){const n=this.getID3Track(t.textTracks);return n.mode="hidden",n}getID3Track(t){if(this.media){for(let n=0;n<t.length;n++){const s=t[n];if(s.kind==="metadata"&&s.label==="id3")return pf(s,this.media),s}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,n){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:s,enableID3MetadataCues:o}=this.hls.config;if(!s&&!o)return;const{samples:l}=n;this.id3Track||(this.id3Track=this.createTrack(this.media));const c=Jc();if(c)for(let f=0;f<l.length;f++){const _=l[f].type;if(_===ms.emsg&&!s||!o)continue;const m=bc(l[f].data),v=l[f].pts;let y=v+l[f].duration;y>Wu&&(y=Wu),y-v<=0&&(y=v+i0);for(let D=0;D<m.length;D++){const C=m[D];if(!xc(C)){this.updateId3CueEnds(v,_);const B=Qc(c,v,y,C,_);B&&this.id3Track.addCue(B)}}}}updateId3CueEnds(t,n){var s;const o=(s=this.id3Track)==null?void 0:s.cues;if(o)for(let l=o.length;l--;){const c=o[l];c.type===n&&c.startTime<t&&c.endTime===Wu&&(c.endTime=t)}}onBufferFlushing(t,{startOffset:n,endOffset:s,type:o}){const{id3Track:l,hls:c}=this;if(!c)return;const{config:{enableEmsgMetadataCues:f,enableID3MetadataCues:_}}=c;if(l&&(f||_)){let m;o==="audio"?m=v=>v.type===ms.audioId3&&_:o==="video"?m=v=>v.type===ms.emsg&&f:m=v=>v.type===ms.audioId3&&_||v.type===ms.emsg&&f,Js(l,n,s,m)}}onLevelUpdated(t,{details:n}){this.updateDateRangeCues(n,!0)}onLevelPtsUpdated(t,n){Math.abs(n.drift)>.01&&this.updateDateRangeCues(n.details)}updateDateRangeCues(t,n){if(!this.hls||!this.media)return;const{assetPlayerId:s,timelineOffset:o,enableDateRangeMetadataCues:l,interstitialsController:c}=this.hls.config;if(!l)return;const f=Jc();if(s&&o&&!c){const{fragmentStart:B,fragmentEnd:F}=t;let Q=this.assetCue;Q?(Q.startTime=B,Q.endTime=F):f&&(Q=this.assetCue=Qc(f,B,F,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),Q&&(Q.id=s,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(Q),Q.addEventListener("enter",this.onEventCueEnter)))}if(!t.hasProgramDateTime)return;const{id3Track:_}=this,{dateRanges:m}=t,v=Object.keys(m);let y=this.dateRangeCuesAppended;if(_&&n){var x;if((x=_.cues)!=null&&x.length){const B=Object.keys(y).filter(F=>!v.includes(F));for(let F=B.length;F--;){var D;const Q=B[F],se=(D=y[Q])==null?void 0:D.cues;delete y[Q],se&&Object.keys(se).forEach(le=>{const Ee=se[le];if(Ee){Ee.removeEventListener("enter",this.onEventCueEnter);try{_.removeCue(Ee)}catch(Ie){}}})}}else y=this.dateRangeCuesAppended={}}const C=t.fragments[t.fragments.length-1];if(!(v.length===0||!ce(C==null?void 0:C.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let B=0;B<v.length;B++){const F=v[B],Q=m[F],se=Q.startTime,le=y[F],Ee=(le==null?void 0:le.cues)||{};let Ie=(le==null?void 0:le.durationKnown)||!1,Qe=Wu;const{duration:Pe,endDate:Ze}=Q;if(Ze&&Pe!==null)Qe=se+Pe,Ie=!0;else if(Q.endOnNext&&!Ie){const Fe=v.reduce((bt,Xt)=>{if(Xt!==Q.id){const ci=m[Xt];if(ci.class===Q.class&&ci.startDate>Q.startDate&&(!bt||Q.startDate<bt.startDate))return ci}return bt},null);Fe&&(Qe=Fe.startTime,Ie=!0)}const He=Object.keys(Q.attr);for(let Fe=0;Fe<He.length;Fe++){const bt=He[Fe];if(!ns(bt))continue;const Xt=Ee[bt];if(Xt)Ie&&!(le!=null&&le.durationKnown)?Xt.endTime=Qe:Math.abs(Xt.startTime-se)>.01&&(Xt.startTime=se,Xt.endTime=Qe);else if(f){let ci=Q.attr[bt];or(bt)&&(ci=z(ci));const li=Qc(f,se,Qe,{key:bt,data:ci},ms.dateRange);li&&(li.id=F,this.id3Track.addCue(li),Ee[bt]=li,c&&(bt==="X-ASSET-LIST"||bt==="X-ASSET-URL")&&li.addEventListener("enter",this.onEventCueEnter))}}y[F]={cues:Ee,dateRange:Q,durationKnown:Ie}}}}}class r0{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{const{media:n}=this,s=this.levelDetails;if(!n||!s)return;this.currentTime=n.currentTime;const o=this.computeLatency();if(o===null)return;this._latency=o;const{lowLatencyMode:l,maxLiveSyncPlaybackRate:c}=this.config;if(!l||c===1||!s.live)return;const f=this.targetLatency;if(f===null)return;const _=o-f,m=Math.min(this.maxLatency,f+s.targetduration);if(_<m&&_>.05&&this.forwardBufferLength>1){const y=Math.min(2,Math.max(1,c)),x=Math.round(2/(1+Math.exp(-.75*_-this.edgeStalled))*20)/20,D=Math.min(y,Math.max(1,x));this.changeMediaPlaybackRate(n,D)}else n.playbackRate!==1&&n.playbackRate!==0&&this.changeMediaPlaybackRate(n,1)},this.hls=t,this.config=t.config,this.registerListeners()}get levelDetails(){var t;return((t=this.hls)==null?void 0:t.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:t}=this;if(t.liveMaxLatencyDuration!==void 0)return t.liveMaxLatencyDuration;const n=this.levelDetails;return n?t.liveMaxLatencyDurationCount*n.targetduration:0}get targetLatency(){const t=this.levelDetails;if(t===null||this.hls===null)return null;const{holdBack:n,partHoldBack:s,targetduration:o}=t,{liveSyncDuration:l,liveSyncDurationCount:c,lowLatencyMode:f}=this.config,_=this.hls.userConfig;let m=f&&s||n;(this._targetLatencyUpdated||_.liveSyncDuration||_.liveSyncDurationCount||m===0)&&(m=l!==void 0?l:c*o);const v=o;return m+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,v)}set targetLatency(t){this.stallCount=0,this.config.liveSyncDuration=t,this._targetLatencyUpdated=!0}get liveSyncPosition(){const t=this.estimateLiveEdge(),n=this.targetLatency;if(t===null||n===null)return null;const s=this.levelDetails;if(s===null)return null;const o=s.edge,l=t-n-this.edgeStalled,c=o-s.totalduration,f=o-(this.config.lowLatencyMode&&s.partTarget||s.targetduration);return Math.min(Math.max(c,l),f)}get drift(){const t=this.levelDetails;return t===null?1:t.drift}get edgeStalled(){const t=this.levelDetails;if(t===null)return 0;const n=(this.config.lowLatencyMode&&t.partTarget||t.targetduration)*3;return Math.max(t.age-n,0)}get forwardBufferLength(){const{media:t}=this,n=this.levelDetails;if(!t||!n)return 0;const s=t.buffered.length;return(s?t.buffered.end(s-1):n.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:t}=this;t&&(t.on(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(S.ERROR,this.onError,this))}unregisterListeners(){const{hls:t}=this;t&&(t.off(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(S.ERROR,this.onError,this))}onMediaAttached(t,n){this.media=n.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(t,{details:n}){n.advanced&&this.onTimeupdate(),!n.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(t,n){var s;n.details===q.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(s=this.levelDetails)!=null&&s.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(t,n){var s,o;t.playbackRate!==n&&((s=this.hls)==null||s.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(o=this.targetLatency)==null?void 0:o.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${t.playbackRate} to ${n}`),t.playbackRate=n)}estimateLiveEdge(){const t=this.levelDetails;return t===null?null:t.edge+t.age}computeLatency(){const t=this.estimateLiveEdge();return t===null?null:t-this.currentTime}}class s0 extends Mc{constructor(t,n){super(t,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=n,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(S.LEVEL_LOADED,this.onLevelLoaded,this),t.on(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(S.FRAG_BUFFERED,this.onFragBuffered,this),t.on(S.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(S.LEVEL_LOADED,this.onLevelLoaded,this),t.off(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(S.FRAG_BUFFERED,this.onFragBuffered,this),t.off(S.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(n=>{n.loadError=0,n.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(t,n){this.resetLevels()}onManifestLoaded(t,n){const s=this.hls.config.preferManagedMediaSource,o=[],l={},c={};let f=!1,_=!1,m=!1;n.levels.forEach(v=>{const y=v.attrs;let{audioCodec:x,videoCodec:D}=v;x&&(v.audioCodec=x=_e(x,s)||void 0),D&&(D=v.videoCodec=Ut(D));const{width:C,height:B,unknownCodecs:F}=v,Q=(F==null?void 0:F.length)||0;if(f||(f=!!(C&&B)),_||(_=!!D),m||(m=!!x),Q||x&&!this.isAudioSupported(x)||D&&!this.isVideoSupported(D)){this.log(`Some or all CODECS not supported "${y.CODECS}"`);return}const{CODECS:se,"FRAME-RATE":le,"HDCP-LEVEL":Ee,"PATHWAY-ID":Ie,RESOLUTION:Qe,"VIDEO-RANGE":Pe}=y,He=`${`${Ie||"."}-`}${v.bitrate}-${Qe}-${le}-${se}-${Pe}-${Ee}`;if(l[He])if(l[He].uri!==v.url&&!v.attrs["PATHWAY-ID"]){const Fe=c[He]+=1;v.attrs["PATHWAY-ID"]=new Array(Fe+1).join(".");const bt=this.createLevel(v);l[He]=bt,o.push(bt)}else l[He].addGroupId("audio",y.AUDIO),l[He].addGroupId("text",y.SUBTITLES);else{const Fe=this.createLevel(v);l[He]=Fe,c[He]=1,o.push(Fe)}}),this.filterAndSortMediaOptions(o,n,f,_,m)}createLevel(t){const n=new Yn(t),s=t.supplemental;if(s!=null&&s.videoCodec&&!this.isVideoSupported(s.videoCodec)){const o=new Error(`SUPPLEMENTAL-CODECS not supported "${s.videoCodec}"`);this.log(o.message),n.supportedResult=ki(o,[])}return n}isAudioSupported(t){return Ft(t,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(t){return Ft(t,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(t,n,s,o,l){var c;let f=[],_=[],m=t;const v=((c=n.stats)==null?void 0:c.parsing)||{};if((s||o)&&l&&(m=m.filter(({videoCodec:se,videoRange:le,width:Ee,height:Ie})=>(!!se||!!(Ee&&Ie))&&yn(le))),m.length===0){Promise.resolve().then(()=>{if(this.hls){let se="no level with compatible codecs found in manifest",le=se;n.levels.length&&(le=`one or more CODECS in variant not supported: ${$t(n.levels.map(Ie=>Ie.attrs.CODECS).filter((Ie,Qe,Pe)=>Pe.indexOf(Ie)===Qe))}`,this.warn(le),se+=` (${le})`);const Ee=new Error(se);this.hls.trigger(S.ERROR,{type:ge.MEDIA_ERROR,details:q.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:n.url,error:Ee,reason:le})}}),v.end=performance.now();return}n.audioTracks&&(f=n.audioTracks.filter(se=>!se.audioCodec||this.isAudioSupported(se.audioCodec)),eh(f)),n.subtitles&&(_=n.subtitles,eh(_));const y=m.slice(0);m.sort((se,le)=>{if(se.attrs["HDCP-LEVEL"]!==le.attrs["HDCP-LEVEL"])return(se.attrs["HDCP-LEVEL"]||"")>(le.attrs["HDCP-LEVEL"]||"")?1:-1;if(s&&se.height!==le.height)return se.height-le.height;if(se.frameRate!==le.frameRate)return se.frameRate-le.frameRate;if(se.videoRange!==le.videoRange)return Oi.indexOf(se.videoRange)-Oi.indexOf(le.videoRange);if(se.videoCodec!==le.videoCodec){const Ee=we(se.videoCodec),Ie=we(le.videoCodec);if(Ee!==Ie)return Ie-Ee}if(se.uri===le.uri&&se.codecSet!==le.codecSet){const Ee=K(se.codecSet),Ie=K(le.codecSet);if(Ee!==Ie)return Ie-Ee}return se.averageBitrate!==le.averageBitrate?se.averageBitrate-le.averageBitrate:0});let x=y[0];if(this.steering&&(m=this.steering.filterParsedLevels(m),m.length!==y.length)){for(let se=0;se<y.length;se++)if(y[se].pathwayId===m[0].pathwayId){x=y[se];break}}this._levels=m;for(let se=0;se<m.length;se++)if(m[se]===x){var D;this._firstLevel=se;const le=x.bitrate,Ee=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${m.length} level(s) found, first bitrate: ${le}`),((D=this.hls.userConfig)==null?void 0:D.abrEwmaDefaultEstimate)===void 0){const Ie=Math.min(le,this.hls.config.abrEwmaDefaultEstimateMax);Ie>Ee&&Ee===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=Ie)}break}const C=l&&!o,B=this.hls.config,F=!!(B.audioStreamController&&B.audioTrackController),Q={levels:m,audioTracks:f,subtitleTracks:_,sessionData:n.sessionData,sessionKeys:n.sessionKeys,firstLevel:this._firstLevel,stats:n.stats,audio:l,video:o,altAudio:F&&!C&&f.some(se=>!!se.url)};v.end=performance.now(),this.hls.trigger(S.MANIFEST_PARSED,Q)}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(t){const n=this._levels;if(n.length===0)return;if(t<0||t>=n.length){const v=new Error("invalid level idx"),y=t<0;if(this.hls.trigger(S.ERROR,{type:ge.OTHER_ERROR,details:q.LEVEL_SWITCH_ERROR,level:t,fatal:y,error:v,reason:v.message}),y)return;t=Math.min(t,n.length-1)}const s=this.currentLevelIndex,o=this.currentLevel,l=o?o.attrs["PATHWAY-ID"]:void 0,c=n[t],f=c.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=c,s===t&&o&&l===f)return;this.log(`Switching to level ${t} (${c.height?c.height+"p ":""}${c.videoRange?c.videoRange+" ":""}${c.codecSet?c.codecSet+" ":""}@${c.bitrate})${f?" with Pathway "+f:""} from level ${s}${l?" with Pathway "+l:""}`);const _={level:t,attrs:c.attrs,details:c.details,bitrate:c.bitrate,averageBitrate:c.averageBitrate,maxBitrate:c.maxBitrate,realBitrate:c.realBitrate,width:c.width,height:c.height,codecSet:c.codecSet,audioCodec:c.audioCodec,videoCodec:c.videoCodec,audioGroups:c.audioGroups,subtitleGroups:c.subtitleGroups,loaded:c.loaded,loadError:c.loadError,fragmentError:c.fragmentError,name:c.name,id:c.id,uri:c.uri,url:c.url,urlId:0,audioGroupIds:c.audioGroupIds,textGroupIds:c.textGroupIds};this.hls.trigger(S.LEVEL_SWITCHING,_);const m=c.details;if(!m||m.live){const v=this.switchParams(c.uri,o==null?void 0:o.details,m);this.loadPlaylist(v)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){if(this._startLevel===void 0){const t=this.hls.config.startLevel;return t!==void 0?t:this.hls.firstAutoLevel}return this._startLevel}set startLevel(t){this._startLevel=t}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(t){if(this.steering){const n=this.steering.pathways(),s=t.filter(o=>n.indexOf(o)!==-1);if(t.length<1){this.warn(`pathwayPriority ${t} should contain at least one pathway from list: ${n}`);return}this.steering.pathwayPriority=s}}onError(t,n){n.fatal||!n.context||n.context.type===Te.LEVEL&&n.context.level===this.level&&this.checkRetry(n)}onFragBuffered(t,{frag:n}){if(n!==void 0&&n.type===P.MAIN){const s=n.elementaryStreams;if(!Object.keys(s).some(l=>!!s[l]))return;const o=this._levels[n.level];o!=null&&o.loadError&&(this.log(`Resetting level error count of ${o.loadError} on frag buffered`),o.loadError=0)}}onLevelLoaded(t,n){var s;const{level:o,details:l}=n,c=n.levelInfo;if(!c){var f;this.warn(`Invalid level index ${o}`),(f=n.deliveryDirectives)!=null&&f.skip&&(l.deltaUpdateFailed=!0);return}if(c===this.currentLevel||n.withoutMultiVariant){c.fragmentError===0&&(c.loadError=0);let _=c.details;_===n.details&&_.advanced&&(_=void 0),this.playlistLoaded(o,n,_)}else(s=n.deliveryDirectives)!=null&&s.skip&&(l.deltaUpdateFailed=!0)}loadPlaylist(t){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,t)}loadingPlaylist(t,n){super.loadingPlaylist(t,n);const s=this.getUrlWithDirectives(t.uri,n),o=this.currentLevelIndex,l=t.attrs["PATHWAY-ID"],c=t.details,f=c==null?void 0:c.age;this.log(`Loading level index ${o}${(n==null?void 0:n.msn)!==void 0?" at sn "+n.msn+" part "+n.part:""}${l?" Pathway "+l:""}${f&&c.live?" age "+f.toFixed(1)+(c.type?" "+c.type||0:""):""} ${s}`),this.hls.trigger(S.LEVEL_LOADING,{url:s,level:o,levelInfo:t,pathwayId:t.attrs["PATHWAY-ID"],id:0,deliveryDirectives:n||null})}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}removeLevel(t){var n;if(this._levels.length===1)return;const s=this._levels.filter((l,c)=>c!==t?!0:(this.steering&&this.steering.removeLevel(l),l===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,l.details&&l.details.fragments.forEach(f=>f.level=-1)),!1));Wn(s),this._levels=s,this.currentLevelIndex>-1&&(n=this.currentLevel)!=null&&n.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const o=s.length-1;this._firstLevel=Math.min(this._firstLevel,o),this._startLevel&&(this._startLevel=Math.min(this._startLevel,o)),this.hls.trigger(S.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(t,{levels:n}){this._levels=n}checkMaxAutoUpdated(){const{autoLevelCapping:t,maxAutoLevel:n,maxHdcpLevel:s}=this.hls;this._maxAutoLevel!==n&&(this._maxAutoLevel=n,this.hls.trigger(S.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:n,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:s}))}}function eh(h){const t={};h.forEach(n=>{const s=n.groupId||"";n.id=t[s]=t[s]||0,t[s]++})}function go(){return self.SourceBuffer||self.WebKitSourceBuffer}function If(){if(!Oe())return!1;const t=go();return!t||t.prototype&&typeof t.prototype.appendBuffer=="function"&&typeof t.prototype.remove=="function"}function Il(){if(!If())return!1;const h=Oe();return typeof(h==null?void 0:h.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(t=>h.isTypeSupported(ye(t,"video")))||["mp4a.40.2","fLaC"].some(t=>h.isTypeSupported(ye(t,"audio"))))}function Pl(){var h;const t=go();return typeof(t==null||(h=t.prototype)==null?void 0:h.changeType)=="function"}const th=100;class Ss extends Xl{constructor(t,n,s){super(t,n,s,"stream-controller",P.MAIN),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const o=this.media,l=o?o.currentTime:null;if(l===null||!ce(l)||(this.log(`Media seeked to ${l.toFixed(3)}`),!this.getBufferedFrag(l)))return;const c=this.getFwdBufferInfoAtPos(o,l,P.MAIN,0);if(c===null||c.len===0){this.warn(`Main forward buffer length at ${l} on "seeked" event ${c?c.len:"empty"})`);return}this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:t}=this;t.on(S.MANIFEST_PARSED,this.onManifestParsed,this),t.on(S.LEVEL_LOADING,this.onLevelLoading,this),t.on(S.LEVEL_LOADED,this.onLevelLoaded,this),t.on(S.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(S.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(S.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(S.BUFFER_CREATED,this.onBufferCreated,this),t.on(S.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(S.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:t}=this;t.off(S.MANIFEST_PARSED,this.onManifestParsed,this),t.off(S.LEVEL_LOADED,this.onLevelLoaded,this),t.off(S.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(S.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(S.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(S.BUFFER_CREATED,this.onBufferCreated,this),t.off(S.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(S.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(t,n){if(this.levels){const{lastCurrentTime:s,hls:o}=this;if(this.stopLoad(),this.setInterval(th),this.level=-1,!this.startFragRequested){let l=o.startLevel;l===-1&&(o.config.testBandwidth&&this.levels.length>1?(l=0,this.bitrateTest=!0):l=o.firstAutoLevel),o.nextLoadLevel=l,this.level=o.loadLevel,this._hasEnoughToStart=!!n}s>0&&t===-1&&!n&&(this.log(`Override startPosition with lastCurrentTime @${s.toFixed(3)}`),t=s),this.state=mt.IDLE,this.nextLoadPosition=this.lastCurrentTime=t+this.timelineOffset,this.startPosition=n?-1:t,this.tick()}else this._forceStartLoad=!0,this.state=mt.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case mt.WAITING_LEVEL:{const{levels:t,level:n}=this,s=t==null?void 0:t[n],o=s==null?void 0:s.details;if(o&&(!o.live||this.levelLastLoaded===s&&!this.waitForLive(s))){if(this.waitForCdnTuneIn(o))break;this.state=mt.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=mt.IDLE;break}break}case mt.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===mt.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var t;super.onTickEnd(),(t=this.media)!=null&&t.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:n,levels:s,media:o}=this;if(n===null||!o&&!this.primaryPrefetch&&(this.startFragRequested||!t.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const l=this.buffering?t.nextLoadLevel:t.loadLevel;if(!(s!=null&&s[l]))return;const c=s[l],f=this.getMainFwdBufferInfo();if(f===null)return;const _=this.getLevelDetails();if(_&&this._streamEnded(f,_)){const B={};this.altAudio===2&&(B.type="video"),this.hls.trigger(S.BUFFER_EOS,B),this.state=mt.ENDED;return}if(!this.buffering)return;t.loadLevel!==l&&t.manualLevel===-1&&this.log(`Adapting to level ${l} from level ${this.level}`),this.level=t.nextLoadLevel=l;const m=c.details;if(!m||this.state===mt.WAITING_LEVEL||this.waitForLive(c)){this.level=l,this.state=mt.WAITING_LEVEL,this.startFragRequested=!1;return}const v=f.len,y=this.getMaxBufferLength(c.maxBitrate);if(v>=y)return;this.backtrackFragment&&this.backtrackFragment.start>f.end&&(this.backtrackFragment=null);const x=this.backtrackFragment?this.backtrackFragment.start:f.end;let D=this.getNextFragment(x,m);if(this.couldBacktrack&&!this.fragPrevious&&D&&ze(D)&&this.fragmentTracker.getState(D)!==rn.OK){var C;const F=((C=this.backtrackFragment)!=null?C:D).sn-m.startSN,Q=m.fragments[F-1];Q&&D.cc===Q.cc&&(D=Q,this.fragmentTracker.removeFragment(Q))}else this.backtrackFragment&&f.len&&(this.backtrackFragment=null);if(D&&this.isLoopLoading(D,x)){if(!D.gap){const F=this.audioOnly&&!this.altAudio?V.AUDIO:V.VIDEO,Q=(F===V.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;Q&&this.afterBufferFlushed(Q,F,P.MAIN)}D=this.getNextFragmentLoopLoading(D,m,f,P.MAIN,y)}D&&(D.initSegment&&!D.initSegment.data&&!this.bitrateTest&&(D=D.initSegment),this.loadFragment(D,c,x))}loadFragment(t,n,s){const o=this.fragmentTracker.getState(t);o===rn.NOT_LOADED||o===rn.PARTIAL?ze(t)?this.bitrateTest?(this.log(`Fragment ${t.sn} of level ${t.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(t,n)):super.loadFragment(t,n,s):this._loadInitSegment(t,n):this.clearTrackerIfNeeded(t)}getBufferedFrag(t){return this.fragmentTracker.getBufferedFrag(t,P.MAIN)}followingBufferedFrag(t){return t?this.getBufferedFrag(t.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:t,media:n}=this;if(n!=null&&n.readyState){let s;const o=this.getAppendedFrag(n.currentTime);o&&o.start>1&&this.flushMainBuffer(0,o.start-1);const l=this.getLevelDetails();if(l!=null&&l.live){const f=this.getMainFwdBufferInfo();if(!f||f.len<l.targetduration*2)return}if(!n.paused&&t){const f=this.hls.nextLoadLevel,_=t[f],m=this.fragLastKbps;m&&this.fragCurrent?s=this.fragCurrent.duration*_.maxBitrate/(1e3*m)+1:s=0}else s=0;const c=this.getBufferedFrag(n.currentTime+s);if(c){const f=this.followingBufferedFrag(c);if(f){this.abortCurrentFrag();const _=f.maxStartPTS?f.maxStartPTS:f.start,m=f.duration,v=Math.max(c.end,_+Math.min(Math.max(m-this.config.maxFragLookUpTolerance,m*(this.couldBacktrack?.5:.125)),m*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(v,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case mt.KEY_LOADING:case mt.FRAG_LOADING:case mt.FRAG_LOADING_WAITING_RETRY:case mt.PARSING:case mt.PARSED:this.state=mt.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(t,n){super.flushMainBuffer(t,n,this.altAudio===2?"video":null)}onMediaAttached(t,n){super.onMediaAttached(t,n);const s=n.media;vr(s,"playing",this.onMediaPlaying),vr(s,"seeked",this.onMediaSeeked)}onMediaDetaching(t,n){const{media:s}=this;s&&(Ir(s,"playing",this.onMediaPlaying),Ir(s,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(t,n),!n.transferMedia&&(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(S.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(t,n){let s=!1,o=!1;for(let l=0;l<n.levels.length;l++){const c=n.levels[l].audioCodec;c&&(s=s||c.indexOf("mp4a.40.2")!==-1,o=o||c.indexOf("mp4a.40.5")!==-1)}this.audioCodecSwitch=s&&o&&!Pl(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=n.levels,this.startFragRequested=!1}onLevelLoading(t,n){const{levels:s}=this;if(!s||this.state!==mt.IDLE)return;const o=n.levelInfo;(!o.details||o.details.live&&(this.levelLastLoaded!==o||o.details.expired)||this.waitForCdnTuneIn(o.details))&&(this.state=mt.WAITING_LEVEL)}onLevelLoaded(t,n){var s;const{levels:o,startFragRequested:l}=this,c=n.level,f=n.details,_=f.totalduration;if(!o){this.warn(`Levels were reset while loading level ${c}`);return}this.log(`Level ${c} loaded [${f.startSN},${f.endSN}]${f.lastPartSn?`[part-${f.lastPartSn}-${f.lastPartIndex}]`:""}, cc [${f.startCC}, ${f.endCC}] duration:${_}`);const m=n.levelInfo,v=this.fragCurrent;v&&(this.state===mt.FRAG_LOADING||this.state===mt.FRAG_LOADING_WAITING_RETRY)&&v.level!==n.level&&v.loader&&this.abortCurrentFrag();let y=0;if(f.live||(s=m.details)!=null&&s.live){var x;if(this.checkLiveUpdate(f),f.deltaUpdateFailed)return;y=this.alignPlaylists(f,m.details,(x=this.levelLastLoaded)==null?void 0:x.details)}if(m.details=f,this.levelLastLoaded=m,l||this.setStartPosition(f,y),this.hls.trigger(S.LEVEL_UPDATED,{details:f,level:c}),this.state===mt.WAITING_LEVEL){if(this.waitForCdnTuneIn(f))return;this.state=mt.IDLE}l&&f.live&&this.synchronizeToLiveEdge(f),this.tick()}synchronizeToLiveEdge(t){const{config:n,media:s}=this;if(!s)return;const o=this.hls.liveSyncPosition,l=this.getLoadPosition(),c=t.fragmentStart,f=t.edge,_=l>=c-n.maxFragLookUpTolerance&&l<=f;if(o!==null&&s.duration>o&&(l<o||!_)){const v=n.liveMaxLatencyDuration!==void 0?n.liveMaxLatencyDuration:n.liveMaxLatencyDurationCount*t.targetduration;if((!_&&s.readyState<4||l<f-v)&&(this._hasEnoughToStart||(this.nextLoadPosition=o),s.readyState))if(this.warn(`Playback: ${l.toFixed(3)} is located too far from the end of live sliding playlist: ${f}, reset currentTime to : ${o.toFixed(3)}`),this.config.liveSyncMode==="buffered"){var m;const y=Wt.bufferInfo(s,o,0);if(!((m=y.buffered)!=null&&m.length)){s.currentTime=o;return}if(y.start<=l){s.currentTime=o;return}const{nextStart:D}=Wt.bufferedInfo(y.buffered,l,0);D&&(s.currentTime=D)}else s.currentTime=o}}_handleFragmentLoadProgress(t){var n;const s=t.frag,{part:o,payload:l}=t,{levels:c}=this;if(!c){this.warn(`Levels were reset while fragment load was in progress. Fragment ${s.sn} of level ${s.level} will not be buffered`);return}const f=c[s.level];if(!f){this.warn(`Level ${s.level} not found on progress`);return}const _=f.details;if(!_){this.warn(`Dropping fragment ${s.sn} of level ${s.level} after level details were reset`),this.fragmentTracker.removeFragment(s);return}const m=f.videoCodec,v=_.PTSKnown||!_.live,y=(n=s.initSegment)==null?void 0:n.data,x=this._getAudioCodec(f),D=this.transmuxer=this.transmuxer||new Qh(this.hls,P.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),C=o?o.index:-1,B=C!==-1,F=new Wr(s.level,s.sn,s.stats.chunkCount,l.byteLength,C,B),Q=this.initPTS[s.cc];D.push(l,y,x,m,s,o,_.totalduration,v,F,Q)}onAudioTrackSwitching(t,n){const s=this.hls,o=this.altAudio===2;if(Ai(n.url,s))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const c=this.fragCurrent;c&&(this.log("Switching to main audio track, cancel main fragment load"),c.abortRequests(),this.fragmentTracker.removeFragment(c)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(o){this.fragmentTracker.removeAllFragments(),s.once(S.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(S.AUDIO_TRACK_SWITCHED,n)}),s.trigger(S.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}s.trigger(S.AUDIO_TRACK_SWITCHED,n)}}onAudioTrackSwitched(t,n){const s=Ai(n.url,this.hls);if(s){const o=this.videoBuffer;o&&this.mediaBuffer!==o&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=o)}this.altAudio=s?2:0,this.tick()}onBufferCreated(t,n){const s=n.tracks;let o,l,c=!1;for(const f in s){const _=s[f];if(_.id==="main"){if(l=f,o=_,f==="video"){const m=s[f];m&&(this.videoBuffer=m.buffer)}}else c=!0}c&&o?(this.log(`Alternate track found, use ${l}.buffered to schedule main fragment loading`),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media}onFragBuffered(t,n){const{frag:s,part:o}=n,l=s.type===P.MAIN;if(l){if(this.fragContextChanged(s)){this.warn(`Fragment ${s.sn}${o?" p: "+o.index:""} of level ${s.level} finished buffering, but was aborted. state: ${this.state}`),this.state===mt.PARSED&&(this.state=mt.IDLE);return}const f=o?o.stats:s.stats;this.fragLastKbps=Math.round(8*f.total/(f.buffering.end-f.loading.first)),ze(s)&&(this.fragPrevious=s),this.fragBufferedComplete(s,o)}const c=this.media;c&&(!this._hasEnoughToStart&&Wt.getBuffered(c).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),l&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(t,n){var s;if(n.fatal){this.state=mt.ERROR;return}switch(n.details){case q.FRAG_GAP:case q.FRAG_PARSING_ERROR:case q.FRAG_DECRYPT_ERROR:case q.FRAG_LOAD_ERROR:case q.FRAG_LOAD_TIMEOUT:case q.KEY_LOAD_ERROR:case q.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(P.MAIN,n);break;case q.LEVEL_LOAD_ERROR:case q.LEVEL_LOAD_TIMEOUT:case q.LEVEL_PARSING_ERROR:!n.levelRetry&&this.state===mt.WAITING_LEVEL&&((s=n.context)==null?void 0:s.type)===Te.LEVEL&&(this.state=mt.IDLE);break;case q.BUFFER_ADD_CODEC_ERROR:case q.BUFFER_APPEND_ERROR:if(n.parent!=="main")return;this.reduceLengthAndFlushBuffer(n)&&this.resetLoadingState();break;case q.BUFFER_FULL_ERROR:if(n.parent!=="main")return;this.reduceLengthAndFlushBuffer(n)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case q.INTERNAL_EXCEPTION:this.recoverWorkerError(n);break}}onFragLoadEmergencyAborted(){this.state=mt.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(t,{type:n}){if(n!==V.AUDIO||!this.altAudio){const s=(n===V.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;s&&(this.afterBufferFlushed(s,n,P.MAIN),this.tick())}}onLevelsUpdated(t,n){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=n.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:t}=this;if(!t)return;const n=t.currentTime;let s=this.startPosition;if(s>=0&&n<s){if(t.seeking){this.log(`could not seek to ${s}, already seeking at ${n}`);return}const o=this.timelineOffset;o&&s&&(s+=o);const l=this.getLevelDetails(),c=Wt.getBuffered(t),f=c.length?c.start(0):0,_=f-s,m=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||_>0&&(_<m||this.loadingParts&&_<2*((l==null?void 0:l.partTarget)||0)))&&(this.log(`adjusting start position by ${_} to match buffer start`),s+=_,this.startPosition=s),n<s&&(this.log(`seek to target start position ${s} from current time ${n} buffer start ${f}`),t.currentTime=s)}}_getAudioCodec(t){let n=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&n&&(this.log("Swapping audio codec"),n.indexOf("mp4a.40.5")!==-1?n="mp4a.40.2":n="mp4a.40.5"),n}_loadBitrateTestFrag(t,n){t.bitrateTest=!0,this._doFragLoad(t,n).then(s=>{const{hls:o}=this,l=s==null?void 0:s.frag;if(!l||this.fragContextChanged(l))return;n.fragmentError=0,this.state=mt.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const c=l.stats;c.parsing.start=c.parsing.end=c.buffering.start=c.buffering.end=self.performance.now(),o.trigger(S.FRAG_LOADED,s),l.bitrateTest=!1}).catch(s=>{this.state===mt.STOPPED||this.state===mt.ERROR||(this.warn(s),this.resetFragmentLoading(t))})}_handleTransmuxComplete(t){const n=this.playlistType,{hls:s}=this,{remuxResult:o,chunkMeta:l}=t,c=this.getCurrentContext(l);if(!c){this.resetWhenMissingContext(l);return}const{frag:f,part:_,level:m}=c,{video:v,text:y,id3:x,initSegment:D}=o,{details:C}=m,B=this.altAudio?void 0:o.audio;if(this.fragContextChanged(f)){this.fragmentTracker.removeFragment(f);return}if(this.state=mt.PARSING,D){const F=D.tracks;if(F){const Ee=f.initSegment||f;if(this.unhandledEncryptionError(D,f))return;this._bufferInitSegment(m,F,Ee,l),s.trigger(S.FRAG_PARSING_INIT_SEGMENT,{frag:Ee,id:n,tracks:F})}const Q=D.initPTS,se=D.timescale,le=this.initPTS[f.cc];if(ce(Q)&&(!le||le.baseTime!==Q||le.timescale!==se)){const Ee=D.trackId;this.initPTS[f.cc]={baseTime:Q,timescale:se,trackId:Ee},s.trigger(S.INIT_PTS_FOUND,{frag:f,id:n,initPTS:Q,timescale:se,trackId:Ee})}}if(v&&C){B&&v.type==="audiovideo"&&this.logMuxedErr(f);const F=C.fragments[f.sn-1-C.startSN],Q=f.sn===C.startSN,se=!F||f.cc>F.cc;if(o.independent!==!1){const{startPTS:le,endPTS:Ee,startDTS:Ie,endDTS:Qe}=v;if(_)_.elementaryStreams[v.type]={startPTS:le,endPTS:Ee,startDTS:Ie,endDTS:Qe};else if(v.firstKeyFrame&&v.independent&&l.id===1&&!se&&(this.couldBacktrack=!0),v.dropped&&v.independent){const Pe=this.getMainFwdBufferInfo(),Ze=(Pe?Pe.end:this.getLoadPosition())+this.config.maxBufferHole,He=v.firstKeyFramePTS?v.firstKeyFramePTS:le;if(!Q&&Ze<He-this.config.maxBufferHole&&!se){this.backtrack(f);return}else se&&(f.gap=!0);f.setElementaryStreamInfo(v.type,f.start,Ee,f.start,Qe,!0)}else Q&&le-(C.appliedTimelineOffset||0)>Gu&&(f.gap=!0);f.setElementaryStreamInfo(v.type,le,Ee,Ie,Qe),this.backtrackFragment&&(this.backtrackFragment=f),this.bufferFragmentData(v,f,_,l,Q||se)}else if(Q||se)f.gap=!0;else{this.backtrack(f);return}}if(B){const{startPTS:F,endPTS:Q,startDTS:se,endDTS:le}=B;_&&(_.elementaryStreams[V.AUDIO]={startPTS:F,endPTS:Q,startDTS:se,endDTS:le}),f.setElementaryStreamInfo(V.AUDIO,F,Q,se,le),this.bufferFragmentData(B,f,_,l)}if(C&&x!=null&&x.samples.length){const F={id:n,frag:f,details:C,samples:x.samples};s.trigger(S.FRAG_PARSING_METADATA,F)}if(C&&y){const F={id:n,frag:f,details:C,samples:y.samples};s.trigger(S.FRAG_PARSING_USERDATA,F)}}logMuxedErr(t){this.warn(`${ze(t)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${t.url}`)}_bufferInitSegment(t,n,s,o){if(this.state!==mt.PARSING)return;this.audioOnly=!!n.audio&&!n.video,this.altAudio&&!this.audioOnly&&(delete n.audio,n.audiovideo&&this.logMuxedErr(s));const{audio:l,video:c,audiovideo:f}=n;if(l){const m=t.audioCodec;let v=ot(l.codec,m);v==="mp4a"&&(v="mp4a.40.5");const y=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){v&&(v.indexOf("mp4a.40.5")!==-1?v="mp4a.40.2":v="mp4a.40.5");const x=l.metadata;x&&"channelCount"in x&&(x.channelCount||1)!==1&&y.indexOf("firefox")===-1&&(v="mp4a.40.5")}v&&v.indexOf("mp4a.40.5")!==-1&&y.indexOf("android")!==-1&&l.container!=="audio/mpeg"&&(v="mp4a.40.2",this.log(`Android: force audio codec to ${v}`)),m&&m!==v&&this.log(`Swapping manifest audio codec "${m}" for "${v}"`),l.levelCodec=v,l.id=P.MAIN,this.log(`Init audio buffer, container:${l.container}, codecs[selected/level/parsed]=[${v||""}/${m||""}/${l.codec}]`),delete n.audiovideo}if(c){c.levelCodec=t.videoCodec,c.id=P.MAIN;const m=c.codec;if((m==null?void 0:m.length)===4)switch(m){case"hvc1":case"hev1":c.codec="hvc1.1.6.L120.90";break;case"av01":c.codec="av01.0.04M.08";break;case"avc1":c.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${c.container}, codecs[level/parsed]=[${t.videoCodec||""}/${m}]${c.codec!==m?" parsed-corrected="+c.codec:""}${c.supplemental?" supplemental="+c.supplemental:""}`),delete n.audiovideo}f&&(this.log(`Init audiovideo buffer, container:${f.container}, codecs[level/parsed]=[${t.codecs}/${f.codec}]`),delete n.video,delete n.audio);const _=Object.keys(n);if(_.length){if(this.hls.trigger(S.BUFFER_CODECS,n),!this.hls)return;_.forEach(m=>{const y=n[m].initSegment;y!=null&&y.byteLength&&this.hls.trigger(S.BUFFER_APPENDING,{type:m,data:y,frag:s,part:null,chunkMeta:o,parent:s.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const t=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(t,P.MAIN)}get maxBufferLength(){const{levels:t,level:n}=this,s=t==null?void 0:t[n];return s?this.getMaxBufferLength(s.maxBitrate):this.config.maxBufferLength}backtrack(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=mt.IDLE}checkFragmentChanged(){const t=this.media;let n=null;if(t&&t.readyState>1&&t.seeking===!1){const s=t.currentTime;if(Wt.isBuffered(t,s)?n=this.getAppendedFrag(s):Wt.isBuffered(t,s+.1)&&(n=this.getAppendedFrag(s+.1)),n){this.backtrackFragment=null;const o=this.fragPlaying,l=n.level;(!o||n.sn!==o.sn||o.level!==l)&&(this.fragPlaying=n,this.hls.trigger(S.FRAG_CHANGED,{frag:n}),(!o||o.level!==l)&&this.hls.trigger(S.LEVEL_SWITCHED,{level:l}))}}}get nextLevel(){const t=this.nextBufferedFrag;return t?t.level:-1}get currentFrag(){var t;if(this.fragPlaying)return this.fragPlaying;const n=((t=this.media)==null?void 0:t.currentTime)||this.lastCurrentTime;return ce(n)?this.getAppendedFrag(n):null}get currentProgramDateTime(){var t;const n=((t=this.media)==null?void 0:t.currentTime)||this.lastCurrentTime;if(ce(n)){const s=this.getLevelDetails(),o=this.currentFrag||(s?ui(null,s.fragments,n):null);if(o){const l=o.programDateTime;if(l!==null){const c=l+(n-o.start)*1e3;return new Date(c)}}}return null}get currentLevel(){const t=this.currentFrag;return t?t.level:-1}get nextBufferedFrag(){const t=this.currentFrag;return t?this.followingBufferedFrag(t):null}get forceStartLoad(){return this._forceStartLoad}}class a0 extends H{constructor(t,n){super("key-loader",n),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const s in this.keyIdToKeyInfo){const o=this.keyIdToKeyInfo[s].loader;if(o){var n;if(t&&t!==((n=o.context)==null?void 0:n.frag.type))return;o.abort()}}}detach(){for(const t in this.keyIdToKeyInfo){const n=this.keyIdToKeyInfo[t];(n.mediaKeySessionContext||n.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyIdToKeyInfo){const n=this.keyIdToKeyInfo[t].loader;n&&n.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(t,n=q.KEY_LOAD_ERROR,s,o,l){return new Gn({type:ge.NETWORK_ERROR,details:n,fatal:!1,frag:t,response:l,error:s,networkDetails:o})}loadClear(t,n,s){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(n.length)for(let o=0,l=n.length;o<l;o++){const c=n[o];if(t.cc<=c.cc&&(!ze(t)||!ze(c)||t.sn<c.sn)||!s&&o==l-1)return this.emeController.selectKeySystemFormat(c).then(f=>{if(!this.emeController)return;c.setKeyFormat(f);const _=Hn(f);if(_)return this.emeController.getKeySystemAccess([_])})}if(this.config.requireKeySystemAccessOnStart){const o=$r(this.config);if(o.length)return this.emeController.getKeySystemAccess(o)}}return null}load(t){return!t.decryptdata&&t.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(t).then(n=>this.loadInternal(t,n)):this.loadInternal(t)}loadInternal(t,n){var s,o;n&&t.setKeyFormat(n);const l=t.decryptdata;if(!l){const m=new Error(n?`Expected frag.decryptdata to be defined after setting format ${n}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(t,q.KEY_LOAD_ERROR,m))}const c=l.uri;if(!c)return Promise.reject(this.createKeyLoadError(t,q.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${c}"`)));const f=ih(l);let _=this.keyIdToKeyInfo[f];if((s=_)!=null&&s.decryptdata.key)return l.key=_.decryptdata.key,Promise.resolve({frag:t,keyInfo:_});if(this.emeController&&(o=_)!=null&&o.keyLoadPromise)switch(this.emeController.getKeyStatus(_.decryptdata)){case"usable":case"usable-in-future":return _.keyLoadPromise.then(v=>{const{keyInfo:y}=v;return l.key=y.decryptdata.key,{frag:t,keyInfo:y}})}switch(this.log(`${this.keyIdToKeyInfo[f]?"Rel":"L"}oading${l.keyId?" keyId: "+te(l.keyId):""} URI: ${l.uri} from ${t.type} ${t.level}`),_=this.keyIdToKeyInfo[f]={decryptdata:l,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},l.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return l.keyFormat==="identity"?this.loadKeyHTTP(_,t):this.loadKeyEME(_,t);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(_,t);default:return Promise.reject(this.createKeyLoadError(t,q.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${l.method}"`)))}}loadKeyEME(t,n){const s={frag:n,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const o=this.emeController.loadKey(s);return(t.keyLoadPromise=o.then(l=>(t.mediaKeySessionContext=l,s))).catch(l=>{throw t.keyLoadPromise=null,"data"in l&&(l.data.frag=n),l})}return Promise.resolve(s)}loadKeyHTTP(t,n){const s=this.config,o=s.loader,l=new o(s);return n.keyLoader=t.loader=l,t.keyLoadPromise=new Promise((c,f)=>{const _={keyInfo:t,frag:n,responseType:"arraybuffer",url:t.decryptdata.uri},m=s.keyLoadPolicy.default,v={loadPolicy:m,timeout:m.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},y={onSuccess:(x,D,C,B)=>{const{frag:F,keyInfo:Q}=C,se=ih(Q.decryptdata);if(!F.decryptdata||Q!==this.keyIdToKeyInfo[se])return f(this.createKeyLoadError(F,q.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),B));Q.decryptdata.key=F.decryptdata.key=new Uint8Array(x.data),F.keyLoader=null,Q.loader=null,c({frag:F,keyInfo:Q})},onError:(x,D,C,B)=>{this.resetLoader(D),f(this.createKeyLoadError(n,q.KEY_LOAD_ERROR,new Error(`HTTP Error ${x.code} loading key ${x.text}`),C,M({url:_.url,data:void 0},x)))},onTimeout:(x,D,C)=>{this.resetLoader(D),f(this.createKeyLoadError(n,q.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),C))},onAbort:(x,D,C)=>{this.resetLoader(D),f(this.createKeyLoadError(n,q.INTERNAL_ABORTED,new Error("key loading aborted"),C))}};l.load(_,v,y)})}resetLoader(t){const{frag:n,keyInfo:s,url:o}=t,l=s.loader;n.keyLoader===l&&(n.keyLoader=null,s.loader=null);const c=ih(s.decryptdata)||o;delete this.keyIdToKeyInfo[c],l&&l.destroy()}}function ih(h){if(h.keyFormat!==Wi.FAIRPLAY){const t=h.keyId;if(t)return te(t)}return h.uri}function Pf(h){const{type:t}=h;switch(t){case Te.AUDIO_TRACK:return P.AUDIO;case Te.SUBTITLE_TRACK:return P.SUBTITLE;default:return P.MAIN}}function nh(h,t){let n=h.url;return(n===void 0||n.indexOf("data:")===0)&&(n=t.url),n}class Ol{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=t,this.registerListeners()}startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:t}=this;t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.LEVEL_LOADING,this.onLevelLoading,this),t.on(S.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(S.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),t.on(S.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:t}=this;t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.LEVEL_LOADING,this.onLevelLoading,this),t.off(S.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(S.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),t.off(S.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(t){const n=this.hls.config,s=n.pLoader,o=n.loader,l=s||o,c=new l(n);return this.loaders[t.type]=c,c}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const t in this.loaders){const n=this.loaders[t];n&&n.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,n){const{url:s}=n;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Te.MANIFEST,url:s,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(t,n){const{id:s,level:o,pathwayId:l,url:c,deliveryDirectives:f,levelInfo:_}=n;this.load({id:s,level:o,pathwayId:l,responseType:"text",type:Te.LEVEL,url:c,deliveryDirectives:f,levelOrTrack:_})}onAudioTrackLoading(t,n){const{id:s,groupId:o,url:l,deliveryDirectives:c,track:f}=n;this.load({id:s,groupId:o,level:null,responseType:"text",type:Te.AUDIO_TRACK,url:l,deliveryDirectives:c,levelOrTrack:f})}onSubtitleTrackLoading(t,n){const{id:s,groupId:o,url:l,deliveryDirectives:c,track:f}=n;this.load({id:s,groupId:o,level:null,responseType:"text",type:Te.SUBTITLE_TRACK,url:l,deliveryDirectives:c,levelOrTrack:f})}onLevelsUpdated(t,n){const s=this.loaders[Te.LEVEL];if(s){const o=s.context;o&&!n.levels.some(l=>l===o.levelOrTrack)&&(s.abort(),delete this.loaders[Te.LEVEL])}}load(t){var n;const s=this.hls.config;let o=this.getInternalLoader(t);if(o){const m=this.hls.logger,v=o.context;if(v&&v.levelOrTrack===t.levelOrTrack&&(v.url===t.url||v.deliveryDirectives&&!t.deliveryDirectives)){v.url===t.url?m.log(`[playlist-loader]: ignore ${t.url} ongoing request`):m.log(`[playlist-loader]: ignore ${t.url} in favor of ${v.url}`);return}m.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),o.abort()}let l;if(t.type===Te.MANIFEST?l=s.manifestLoadPolicy.default:l=k({},s.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),o=this.createInternalLoader(t),ce((n=t.deliveryDirectives)==null?void 0:n.part)){let m;if(t.type===Te.LEVEL&&t.level!==null?m=this.hls.levels[t.level].details:t.type===Te.AUDIO_TRACK&&t.id!==null?m=this.hls.audioTracks[t.id].details:t.type===Te.SUBTITLE_TRACK&&t.id!==null&&(m=this.hls.subtitleTracks[t.id].details),m){const v=m.partTarget,y=m.targetduration;if(v&&y){const x=Math.max(v*3,y*.8)*1e3;l=k({},l,{maxTimeToFirstByteMs:Math.min(x,l.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(x,l.maxTimeToFirstByteMs)})}}}const c=l.errorRetry||l.timeoutRetry||{},f={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0},_={onSuccess:(m,v,y,x)=>{const D=this.getInternalLoader(y);this.resetInternalLoader(y.type);const C=m.data;v.parsing.start=performance.now(),ds.isMediaPlaylist(C)||y.type!==Te.MANIFEST?this.handleTrackOrLevelPlaylist(m,v,y,x||null,D):this.handleMasterPlaylist(m,v,y,x)},onError:(m,v,y,x)=>{this.handleNetworkError(v,y,!1,m,x)},onTimeout:(m,v,y)=>{this.handleNetworkError(v,y,!0,void 0,m)}};o.load(t,f,_)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:t,startPosition:n},forceStartLoad:s}=this.hls;(t||s)&&(this.hls.logger.log(`${t?"auto":"force"} startLoad with configured startPosition ${n}`),this.hls.startLoad(n))}handleMasterPlaylist(t,n,s,o){const l=this.hls,c=t.data,f=nh(t,s),_=ds.parseMasterPlaylist(c,f);if(_.playlistParsingError){n.parsing.end=performance.now(),this.handleManifestParsingError(t,s,_.playlistParsingError,o,n);return}const{contentSteering:m,levels:v,sessionData:y,sessionKeys:x,startTimeOffset:D,variableList:C}=_;this.variableList=C,v.forEach(se=>{const{unknownCodecs:le}=se;if(le){const{preferManagedMediaSource:Ee}=this.hls.config;let{audioCodec:Ie,videoCodec:Qe}=se;for(let Pe=le.length;Pe--;){const Ze=le[Pe];Ft(Ze,"audio",Ee)?(se.audioCodec=Ie=Ie?`${Ie},${Ze}`:Ze,Ht.audio[Ie.substring(0,4)]=2,le.splice(Pe,1)):Ft(Ze,"video",Ee)&&(se.videoCodec=Qe=Qe?`${Qe},${Ze}`:Ze,Ht.video[Qe.substring(0,4)]=2,le.splice(Pe,1))}}});const{AUDIO:B=[],SUBTITLES:F,"CLOSED-CAPTIONS":Q}=ds.parseMasterPlaylistMedia(c,f,_);B.length&&!B.some(le=>!le.url)&&v[0].audioCodec&&!v[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),B.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new vn({}),bitrate:0,url:""})),l.trigger(S.MANIFEST_LOADED,{levels:v,audioTracks:B,subtitles:F,captions:Q,contentSteering:m,url:f,stats:n,networkDetails:o,sessionData:y,sessionKeys:x,startTimeOffset:D,variableList:C})}handleTrackOrLevelPlaylist(t,n,s,o,l){const c=this.hls,{id:f,level:_,type:m}=s,v=nh(t,s),y=ce(_)?_:ce(f)?f:0,x=Pf(s),D=ds.parseLevelPlaylist(t.data,v,y,x,0,this.variableList);if(m===Te.MANIFEST){const C={attrs:new vn({}),bitrate:0,details:D,name:"",url:v};D.requestScheduled=n.loading.start+Fs(D,0),c.trigger(S.MANIFEST_LOADED,{levels:[C],audioTracks:[],url:v,stats:n,networkDetails:o,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}n.parsing.end=performance.now(),s.levelDetails=D,this.handlePlaylistLoaded(D,t,n,s,o,l)}handleManifestParsingError(t,n,s,o,l){this.hls.trigger(S.ERROR,{type:ge.NETWORK_ERROR,details:q.MANIFEST_PARSING_ERROR,fatal:n.type===Te.MANIFEST,url:t.url,err:s,error:s,reason:s.message,response:t,context:n,networkDetails:o,stats:l})}handleNetworkError(t,n,s=!1,o,l){let c=`A network ${s?"timeout":"error"+(o?" (status "+o.code+")":"")} occurred while loading ${t.type}`;t.type===Te.LEVEL?c+=`: ${t.level} id: ${t.id}`:(t.type===Te.AUDIO_TRACK||t.type===Te.SUBTITLE_TRACK)&&(c+=` id: ${t.id} group-id: "${t.groupId}"`);const f=new Error(c);this.hls.logger.warn(`[playlist-loader]: ${c}`);let _=q.UNKNOWN,m=!1;const v=this.getInternalLoader(t);switch(t.type){case Te.MANIFEST:_=s?q.MANIFEST_LOAD_TIMEOUT:q.MANIFEST_LOAD_ERROR,m=!0;break;case Te.LEVEL:_=s?q.LEVEL_LOAD_TIMEOUT:q.LEVEL_LOAD_ERROR,m=!1;break;case Te.AUDIO_TRACK:_=s?q.AUDIO_TRACK_LOAD_TIMEOUT:q.AUDIO_TRACK_LOAD_ERROR,m=!1;break;case Te.SUBTITLE_TRACK:_=s?q.SUBTITLE_TRACK_LOAD_TIMEOUT:q.SUBTITLE_LOAD_ERROR,m=!1;break}v&&this.resetInternalLoader(t.type);const y={type:ge.NETWORK_ERROR,details:_,fatal:m,url:t.url,loader:v,context:t,error:f,networkDetails:n,stats:l};if(o){const x=(n==null?void 0:n.url)||t.url;y.response=M({url:x,data:void 0},o)}this.hls.trigger(S.ERROR,y)}handlePlaylistLoaded(t,n,s,o,l,c){const f=this.hls,{type:_,level:m,levelOrTrack:v,id:y,groupId:x,deliveryDirectives:D}=o,C=nh(n,o),B=Pf(o);let F=typeof o.level=="number"&&B===P.MAIN?m:void 0;const Q=t.playlistParsingError;if(Q){if(this.hls.logger.warn(`${Q} ${t.url}`),!f.config.ignorePlaylistParsingErrors){f.trigger(S.ERROR,{type:ge.NETWORK_ERROR,details:q.LEVEL_PARSING_ERROR,fatal:!1,url:C,error:Q,reason:Q.message,response:n,context:o,level:F,parent:B,networkDetails:l,stats:s});return}t.playlistParsingError=null}if(!t.fragments.length){const se=t.playlistParsingError=new Error("No Segments found in Playlist");f.trigger(S.ERROR,{type:ge.NETWORK_ERROR,details:q.LEVEL_EMPTY_ERROR,fatal:!1,url:C,error:se,reason:se.message,response:n,context:o,level:F,parent:B,networkDetails:l,stats:s});return}switch(t.live&&c&&(c.getCacheAge&&(t.ageHeader=c.getCacheAge()||0),(!c.getCacheAge||isNaN(t.ageHeader))&&(t.ageHeader=0)),_){case Te.MANIFEST:case Te.LEVEL:if(F){if(!v)F=0;else if(v!==f.levels[F]){const se=f.levels.indexOf(v);se>-1&&(F=se)}}f.trigger(S.LEVEL_LOADED,{details:t,levelInfo:v||f.levels[0],level:F||0,id:y||0,stats:s,networkDetails:l,deliveryDirectives:D,withoutMultiVariant:_===Te.MANIFEST});break;case Te.AUDIO_TRACK:f.trigger(S.AUDIO_TRACK_LOADED,{details:t,track:v,id:y||0,groupId:x||"",stats:s,networkDetails:l,deliveryDirectives:D});break;case Te.SUBTITLE_TRACK:f.trigger(S.SUBTITLE_TRACK_LOADED,{details:t,track:v,id:y||0,groupId:x||"",stats:s,networkDetails:l,deliveryDirectives:D});break}}}class Oa{static get version(){return Ls}static isMSESupported(){return If()}static isSupported(){return Il()}static getMediaSource(){return Oe()}static get Events(){return S}static get MetadataSchema(){return ms}static get ErrorTypes(){return ge}static get ErrorDetails(){return q}static get DefaultConfig(){return Oa.defaultConfig?Oa.defaultConfig:Xd}static set DefaultConfig(t){Oa.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Bs,this._autoLevelCapping=-1,this._maxHdcpLevel=null,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const n=this.logger=Se(t.debug||!1,"Hls instance",t.assetPlayerId),s=this.config=Qd(Oa.DefaultConfig,t,n);this.userConfig=t,s.progressive&&Cf(s,n);const{abrController:o,bufferController:l,capLevelController:c,errorController:f,fpsController:_}=s,m=new f(this),v=this.abrController=new o(this),y=new xn(this),x=s.interstitialsController,D=x?this.interstitialsController=new x(this,Oa):null,C=this.bufferController=new l(this,y),B=this.capLevelController=new c(this),F=new _(this),Q=new Ol(this),se=s.contentSteeringController,le=se?new se(this):null,Ee=this.levelController=new s0(this,le),Ie=new n0(this),Qe=new a0(this.config,this.logger),Pe=this.streamController=new Ss(this,y,Qe),Ze=this.gapController=new Mf(this,y);B.setStreamController(Pe),F.setStreamController(Pe);const He=[Q,Ee,Pe];D&&He.splice(1,0,D),le&&He.splice(1,0,le),this.networkControllers=He;const Fe=[v,C,Ze,B,F,Ie,y];this.audioTrackController=this.createController(s.audioTrackController,He);const bt=s.audioStreamController;bt&&He.push(this.audioStreamController=new bt(this,y,Qe)),this.subtitleTrackController=this.createController(s.subtitleTrackController,He);const Xt=s.subtitleStreamController;Xt&&He.push(this.subtititleStreamController=new Xt(this,y,Qe)),this.createController(s.timelineController,Fe),Qe.emeController=this.emeController=this.createController(s.emeController,Fe),this.cmcdController=this.createController(s.cmcdController,Fe),this.latencyController=this.createController(r0,Fe),this.coreComponents=Fe,He.push(m);const ci=m.onErrorOut;typeof ci=="function"&&this.on(S.ERROR,ci,m),this.on(S.MANIFEST_LOADED,Q.onManifestLoaded,Q)}createController(t,n){if(t){const s=new t(this);return n&&n.push(s),s}return null}on(t,n,s=this){this._emitter.on(t,n,s)}once(t,n,s=this){this._emitter.once(t,n,s)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,n,s=this,o){this._emitter.off(t,n,s,o)}listeners(t){return this._emitter.listeners(t)}emit(t,n,s){return this._emitter.emit(t,n,s)}trigger(t,n){if(this.config.debug)return this.emit(t,t,n);try{return this.emit(t,t,n)}catch(s){if(this.logger.error("An internal error happened while handling event "+t+'. Error message: "'+s.message+'". Here is a stacktrace:',s),!this.triggeringException){this.triggeringException=!0;const o=t===S.ERROR;this.trigger(S.ERROR,{type:ge.OTHER_ERROR,details:q.INTERNAL_EXCEPTION,fatal:o,event:t,error:s}),this.triggeringException=!1}}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){this.logger.log("destroy"),this.trigger(S.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(n=>n.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(n=>n.destroy()),this.coreComponents.length=0;const t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){if(!t||"media"in t&&!t.media){const l=new Error(`attachMedia failed: invalid argument (${t})`);this.trigger(S.ERROR,{type:ge.OTHER_ERROR,details:q.ATTACH_MEDIA_ERROR,fatal:!0,error:l});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const n="media"in t,s=n?t.media:t,o=n?t:{media:s};this._media=s,this.trigger(S.MEDIA_ATTACHING,o)}detachMedia(){this.logger.log("detachMedia"),this.trigger(S.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const t=this.bufferController.transferMedia();return this.trigger(S.MEDIA_DETACHING,{transferMedia:t}),t}loadSource(t){this.stopLoad();const n=this.media,s=this._url,o=this._url=A.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${o}`),n&&s&&(s!==o||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(n)),this.trigger(S.MANIFEST_LOADING,{url:t})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(t=-1,n){this.logger.log(`startLoad(${t+(n?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let s=0;s<this.networkControllers.length&&(this.networkControllers[s].startLoad(t,n),!(!this.started||!this.networkControllers));s++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let t=0;t<this.networkControllers.length&&(this.networkControllers[t].stopLoad(),!(this.started||!this.networkControllers));t++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(t=>{t.resumeBuffering&&t.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(t=>{t.pauseBuffering&&t.pauseBuffering()}))}get inFlightFragments(){const t={[P.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(t[P.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(t[P.SUBTITLE]=this.subtititleStreamController.inFlightFrag),t}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const t=this._media,n=t==null?void 0:t.currentTime;this.detachMedia(),t&&(this.attachMedia(t),n&&this.startLoad(n))}removeLevel(t){this.levelController.removeLevel(t)}get sessionId(){let t=this._sessionId;return t||(t=this._sessionId=Da()),t}get levels(){const t=this.levelController.levels;return t||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){this.logger.log(`set currentLevel:${t}`),this.levelController.manualLevel=t,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){this.logger.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){this.logger.log(`set loadLevel:${t}`),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){this.logger.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){const t=this.levelController.startLevel;return t===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:t}set startLevel(t){this.logger.log(`set startLevel:${t}`),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){const n=!!t;n!==this.config.capLevelToPlayerSize&&(n?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=n)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimate():NaN}set bandwidthEstimate(t){this.abrController.resetEstimator(t)}get abrEwmaDefaultEstimate(){const{bwEstimator:t}=this.abrController;return t?t.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(this.logger.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){Mi(t)&&this._maxHdcpLevel!==t&&(this._maxHdcpLevel=t,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:t,config:{minAutoBitrate:n}}=this;if(!t)return 0;const s=t.length;for(let o=0;o<s;o++)if(t[o].maxBitrate>=n)return o;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:n,maxHdcpLevel:s}=this;let o;if(n===-1&&t!=null&&t.length?o=t.length-1:o=n,s)for(let l=o;l--;){const c=t[l].attrs["HDCP-LEVEL"];if(c&&c<=s)return l}return o}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(t){this.abrController.nextAutoLevel=t}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(t){var n;return((n=this.audioTrackController)==null?void 0:n.setAudioOption(t))||null}setSubtitleOption(t){var n;return((n=this.subtitleTrackController)==null?void 0:n.setSubtitleOption(t))||null}get allAudioTracks(){const t=this.audioTrackController;return t?t.allAudioTracks:[]}get audioTracks(){const t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){const t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){const n=this.audioTrackController;n&&(n.audioTrack=t)}get allSubtitleTracks(){const t=this.subtitleTrackController;return t?t.allSubtitleTracks:[]}get subtitleTracks(){const t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){const t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){const n=this.subtitleTrackController;n&&(n.subtitleTrack=t)}get subtitleDisplay(){const t=this.subtitleTrackController;return t?t.subtitleDisplay:!1}set subtitleDisplay(t){const n=this.subtitleTrackController;n&&(n.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(t){this.latencyController.targetLatency=t}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(t){this.levelController.pathwayPriority=t}get bufferedToEnd(){var t;return!!((t=this.bufferController)!=null&&t.bufferedToEnd)}get interstitialsManager(){var t;return((t=this.interstitialsController)==null?void 0:t.interstitialsManager)||null}getMediaDecodingInfo(t,n=this.allAudioTracks){const s=ut(n);return pi(t,s,navigator.mediaCapabilities)}}Oa.defaultConfig=void 0},48136:function(Li,Rt,oe){"use strict";var ce=Object.defineProperty,De=Object.defineProperties,qe=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,Te=(e,i,r)=>i in e?ce(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r,P=(e,i)=>{for(var r in i||(i={}))q.call(i,r)&&Te(e,r,i[r]);if(ge)for(var r of ge(i))S.call(i,r)&&Te(e,r,i[r]);return e},d=(e,i)=>De(e,qe(i)),ne=e=>typeof e=="symbol"?e:e+"",I=(e,i)=>{var r={};for(var a in e)q.call(e,a)&&i.indexOf(a)<0&&(r[a]=e[a]);if(e!=null&&ge)for(var a of ge(e))i.indexOf(a)<0&&S.call(e,a)&&(r[a]=e[a]);return r};function k(e){return Array.isArray(e)}var T={en:{"keyboard.tooltip.symbols":"\u7B26\u53F7","keyboard.tooltip.greek":"\u5E0C\u814A\u5B57\u6BCD","keyboard.tooltip.numeric":"\u6570\u5B57","keyboard.tooltip.alphabetic":"\u7F57\u9A6C\u5B57\u6BCD","tooltip.cut to clipboard":"\u526A\u5207\u5230\u526A\u8D34\u677F","tooltip.copy to clipboard":"\u590D\u5236\u5230\u526A\u8D34\u677F","tooltip.paste from clipboard":"\u7C98\u8D34","tooltip.redo":"\u91CD\u505A","tooltip.toggle virtual keyboard":"\u5207\u6362\u865A\u62DF\u952E\u76D8","tooltip.undo":"\u64A4\u6D88","menu.insert matrix":"\u63D2\u5165\u77E9\u9635","menu.borders":"\u77E9\u9635\u5206\u9694\u7B26","menu.array.add row above":"\u5728\u540E\u9762\u6DFB\u52A0\u884C","menu.array.add row below":"\u5728\u524D\u9762\u6DFB\u52A0\u884C","menu.array.add column after":"\u5728\u540E\u9762\u6DFB\u52A0\u5217r","menu.array.add column before":"\u5728\u524D\u9762\u6DFB\u52A0\u5217","menu.array.delete row":"\u5220\u9664\u884C","menu.array.delete rows":"\u5220\u9664\u9009\u5B9A\u884C","menu.array.delete column":"\u5220\u9664\u5217","menu.array.delete columns":"\u5220\u9664\u9009\u5B9A\u7684\u5217","menu.mode":"\u6A21\u5F0F","menu.mode-math":"\u6570\u5B66","menu.mode-text":"\u6587\u672C","menu.mode-latex":"LaTeX","tooltip.blackboard":"\u9ED1\u677F","tooltip.bold":"\u7C97\u4F53","tooltip.italic":"\u659C\u4F53","tooltip.fraktur":"Fraktur","tooltip.script":"\u811A\u672C","tooltip.caligraphic":"\u8349\u4E66","tooltip.typewriter":"\u6253\u5B57\u673A","tooltip.roman-upright":"\u7F57\u9A6C\u76F4\u7ACB","tooltip.row-by-col":"%@ \xD7 %@","menu.font-style":"\u5B57\u4F53\u6837\u5F0F","menu.accent":"\u91CD\u97F3","menu.decoration":"\u88C5\u9970","menu.color":"\u989C\u8272","menu.background-color":"\u80CC\u666F","menu.evaluate":"\u8BA1\u7B97","menu.simplify":"\u7B80\u5316","menu.solve":"\u6C42\u89E3","menu.solve-for":"\u6C42\u89E3 %@","menu.cut":"\u526A\u5207","menu.copy":"\u590D\u5236","menu.copy-as-latex":"\u590D\u5236\u4E3A LaTeX","menu.copy-as-ascii-math":"\u590D\u5236\u4E3A ASCII Math","menu.copy-as-mathml":"\u590D\u5236\u4E3A MathML","menu.paste":"\u7C98\u8D34","menu.select-all":"\u5168\u9009","color.red":"\u7EA2\u8272","color.orange":"\u6A59\u8272","color.yellow":"\u9EC4\u8272","color.lime":"\u7EFF\u9EC4\u8272","color.green":"\u7EFF\u8272","color.teal":"\u9752\u8272","color.cyan":"\u84DD\u7EFF\u8272","color.blue":"\u84DD\u8272","color.indigo":"\u975B\u84DD\u8272","color.purple":"\u7D2B\u8272","color.magenta":"\u6D0B\u7EA2\u8272","color.black":"\u9ED1\u8272","color.dark-grey":"\u6DF1\u7070\u8272","color.grey":"\u7070\u8272","color.light-grey":"\u6D45\u7070\u8272","color.white":"\u767D\u8272"}};function M(){return"window"in globalThis&&"document"in globalThis}function O(){return"matchMedia"in window?window.matchMedia("(pointer: coarse)").matches:"ontouchstart"in window||navigator.maxTouchPoints>0}function Y(){return typeof navigator.vibrate=="function"}function H(){var e,i;if(!M())return"other";const r=(i=(e=navigator.userAgentData)==null?void 0:e.platform)!=null?i:navigator.platform;return/^mac/i.test(r)?navigator.maxTouchPoints===5?"ios":"macos":/^win/i.test(r)?"windows":/android/i.test(navigator.userAgent)?"android":/iphone|ipod|ipad/i.test(navigator.userAgent)?"ios":/\bcros\b/i.test(navigator.userAgent)?"chromeos":"other"}function j(){if(!M())return!0;if(/firefox/i.test(navigator.userAgent)){const e=navigator.userAgent.match(/firefox\/(\d+)/i);return e?parseInt(e[1])>=78:!1}if(/trident/i.test(navigator.userAgent))return!1;if(/edge/i.test(navigator.userAgent)){const e=navigator.userAgent.match(/edg\/(\d+)/i);return e?parseInt(e[1])>=79:!1}return!0}function U(){return HTMLElement.prototype.hasOwnProperty("popover")}var $={strings:T,_locale:"",_dirty:!1,_subscribers:[],_numberFormatter:void 0,get locale(){return $._locale||($._locale=M()?navigator.language.slice(0,5):"en-US"),$._locale},set locale(e){$._locale=e,$._numberFormatter=void 0,$.dirty=!0},get numberFormatter(){return $._numberFormatter||($._numberFormatter=new Intl.NumberFormat($.locale)),$._numberFormatter},merge(e,i){if(typeof e=="string"&&i)$.strings[e]=P(P({},$.strings[e]),i),$.dirty=!0;else for(const r of Object.keys(e))$.merge(r,e[r])},get dirty(){return $._dirty},set dirty(e){$._dirty||$._dirty===e||($._dirty=!0,setTimeout(()=>{$._dirty=!1,this._subscribers.forEach(i=>i==null?void 0:i())},0))},subscribe(e){return $._subscribers.push(e),$._subscribers.length-1},unsubscribe(e){e<0||e>=$._subscribers.length||($._subscribers[e]=void 0)},update(e){let i=e.querySelectorAll("[data-l10n-tooltip]");for(const r of i){const a=r.getAttribute("data-l10n-tooltip");if(a){const u=G(a);u&&r.setAttribute("data-tooltip",u)}}i=e.querySelectorAll("[data-l10n-arial-label]");for(const r of i){const a=r.getAttribute("data-l10n-arial-label");if(a){const u=G(a);u&&r.setAttribute("aria-label",u)}}}};function G(e,...i){if(e===void 0)return;let r="";const a=$.locale;$.strings[a]&&(r=$.strings[a][e]);const u=a.slice(0,2);if(!r&&$.strings[u]&&(r=$.strings[u][e]),r||(r=$.strings.en[e]),!r)return;const p=/(%@|%([0-9]+)\$@)/g;let g=p.exec(r),b=0;for(;g;){if(i[b++]){const E=g[2]?parseInt(g[2],10)-1:b-1;let R=i[E];typeof R=="number"&&(R=$.numberFormatter.format(R)),r=r.replace(g[1],R)}g=p.exec(r)}return r=r.replace(/%%/g,"%"),r}var he={m0:"#3F3D99",m1:"#993D71",m2:"#998B3D",m3:"#3D9956",m4:"#3D5A99",m5:"#993D90",m6:"#996D3D",m7:"#43993D",m8:"#3D7999",m9:"#843D99"},be={blue:"#0072BD",orange:"#D95319",yellow:"#EDB120",purple:"#7E2F8E",green:"#77AC30",cyan:"#4DBEEE",red:"#A2142F"},Se={red:"#fbbbb6",orange:"#ffe0c2",yellow:"#fff1c2",lime:"#d0e8b9",green:"#bceac4",teal:"#b9f1f1",cyan:"#b8e5c9",blue:"#b6d9fb",indigo:"#d1c2f0",purple:"#e3baf8",magenta:"#f9c8e0",black:"#353535","dark-grey":"#8C8C8C",grey:"#D0D0D0","light-grey":"#F0F0F0",white:"#ffffff"},re={red:"#d7170b",orange:"#fe8a2b",yellow:"#ffc02b",lime:"#63b215",green:"#21ba3a",teal:"#17cfcf",cyan:"#13a7ec",blue:"#0d80f2",indigo:"#63c",purple:"#a219e6",magenta:"#eb4799",black:"#000","dark-grey":"#666",grey:"#A6A6A6","light-grey":"#d4d5d2",white:"#ffffff"},Oe={Red:"red",Orange:"orange",Yellow:"yellow",LimeGreen:"lime",Green:"green",TealBlue:"teal",Blue:"blue",Violet:"indigo",Purple:"purple",Magenta:"magenta",Black:"black",Gray:"grey",White:"white"},We={Apricot:"#FBB982",Aquamarine:"#00B5BE",Bittersweet:"#C04F17",Black:"#221E1F",Blue:"#2D2F92",BlueGreen:"#00B3B8",BlueViolet:"#473992",BrickRed:"#B6321C",Brown:"#792500",BurntOrange:"#F7921D",CadetBlue:"#74729A",CarnationPink:"#F282B4",Cerulean:"#00A2E3",CornflowerBlue:"#41B0E4",Cyan:"#00AEEF",Dandelion:"#FDBC42",DarkOrchid:"#A4538A",Emerald:"#00A99D",ForestGreen:"#009B55",Fuchsia:"#8C368C",Goldenrod:"#FFDF42",Gray:"#949698",Green:"#00A64F",GreenYellow:"#DFE674",JungleGreen:"#00A99A",Lavender:"#F49EC4",Limegreen:"#8DC73E",Magenta:"#EC008C",Mahogany:"#A9341F",Maroon:"#AF3235",Melon:"#F89E7B",MidnightBlue:"#006795",Mulberry:"#A93C93",NavyBlue:"#006EB8",OliveGreen:"#3C8031",Orange:"#F58137",OrangeRed:"#ED135A",Orchid:"#AF72B0",Peach:"#F7965A",Periwinkle:"#7977B8",PineGreen:"#008B72",Plum:"#92268F",ProcessBlue:"#00B0F0",Purple:"#99479B",RawSienna:"#974006",Red:"#ED1B23",RedOrange:"#F26035",RedViolet:"#A1246B",Rhodamine:"#EF559F",RoyalBlue:"#0071BC",RoyalPurple:"#613F99",RubineRed:"#ED017D",Salmon:"#F69289",SeaGreen:"#3FBC9D",Sepia:"#671800",SkyBlue:"#46C5DD",SpringGreen:"#C6DC67",Tan:"#DA9D76",TealBlue:"#00AEB3",Thistle:"#D883B7",Turquoise:"#00B4CE",Violet:"#58429B",VioletRed:"#EF58A0",White:"#FFFFFF",WildStrawberry:"#EE2967",Yellow:"#FFF200",YellowGreen:"#98CC70",YellowOrange:"#FAA21A"};function Be(e){var i,r,a,u,p,g;const b=e.split("!");let w,E,R,N=255,Z=255,ue=255,me=-1;const Ve=b.length>0&&b[0].startsWith("-");Ve&&(b[0]=b[0].slice(1));for(let Ct=0;Ct<b.length;Ct++){w=N,E=Z,R=ue;const Ue=(i=b[Ct].trim().match(/^([A-Za-z\d-]+)/))==null?void 0:i[1],ct=Ue==null?void 0:Ue.toLowerCase(),It=Ue&&(g=(p=(u=(a=(r=re[ct])!=null?r:re[Oe[Ue]])!=null?a:be[Ue])!=null?u:We[Ue])!=null?p:he[Ue])!=null?g:b[Ct].trim();let yt=It.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i);if(yt!=null&&yt[1]&&yt[2]&&yt[3])N=Math.max(0,Math.min(255,Number.parseInt(yt[1],16))),Z=Math.max(0,Math.min(255,Number.parseInt(yt[2],16))),ue=Math.max(0,Math.min(255,Number.parseInt(yt[3],16)));else if(yt=It.match(/^#([\da-f]{3})$/i),yt!=null&&yt[1]){const ei=Number.parseInt(yt[1][0],16),hi=Number.parseInt(yt[1][1],16),ai=Number.parseInt(yt[1][2],16);N=Math.max(0,Math.min(255,ei*16+ei)),Z=Math.max(0,Math.min(255,hi*16+hi)),ue=Math.max(0,Math.min(255,ai*16+ai))}else if(yt=It.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i),yt!=null&&yt[1]&&yt[2]&&yt[3])N=Math.max(0,Math.min(255,Number.parseInt(yt[1]))),Z=Math.max(0,Math.min(255,Number.parseInt(yt[2]))),ue=Math.max(0,Math.min(255,Number.parseInt(yt[3])));else return;me>=0&&(N=(1-me)*N+me*w,Z=(1-me)*Z+me*E,ue=(1-me)*ue+me*R,me=-1),Ct+1<b.length&&(me=Math.max(0,Math.min(100,Number.parseInt(b[++Ct])))/100)}return me>=0&&(N=me*N+(1-me)*w,Z=me*Z+(1-me)*E,ue=me*ue+(1-me)*R),Ve&&(N=255-N,Z=255-Z,ue=255-ue),"#"+("00"+Math.round(N).toString(16)).slice(-2)+("00"+Math.round(Z).toString(16)).slice(-2)+("00"+Math.round(ue).toString(16)).slice(-2)}function Dt(e){var i,r;return e=e.trim(),(r=(i=Se[e.toLowerCase()])!=null?i:Se[Oe[e]])!=null?r:Be(e)}function te(e){if(!e||e[0]!=="#")return;e=e.slice(1);let i;return e.length<=4?(i={r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16)},e.length===4&&(i.a=parseInt(e[3]+e[3],16)/255)):(i={r:parseInt(e[0]+e[1],16),g:parseInt(e[2]+e[3],16),b:parseInt(e[4]+e[5],16)},e.length===8&&(i.a=parseInt(e[6]+e[7],16)/255)),i&&i.a===void 0&&(i.a=1),i}function z(e,i,r){return r<0&&(r+=6),r>=6&&(r-=6),r<1?(i-e)*r+e:r<3?i:r<4?(i-e)*(4-r)+e:e}function X(e){let[i,r,a]=[e.h,e.s,e.l];i=(i+360)%360/60,a=Math.max(0,Math.min(a,1)),r=Math.max(0,Math.min(r,1));const u=a<=.5?a*(r+1):a+r-a*r,p=a*2-u;return{r:Math.round(255*z(p,u,i+2)),g:Math.round(255*z(p,u,i)),b:Math.round(255*z(p,u,i-2))}}function J(e){return e<0?0:e>255?255:Math.round(e)}function de(e){const{r:i,g:r,b:a}=e;let u=((1<<24)+(J(i)<<16)+(J(r)<<8)+J(a)).toString(16).slice(1);return u[0]===u[1]&&u[2]===u[3]&&u[4]===u[5]&&u[6]===u[7]&&(u=u[0]+u[2]+u[4]),"#"+u}function ie(e){let{r:i,g:r,b:a}=e;i=i/255,r=r/255,a=a/255;const u=Math.min(i,r,a),p=Math.max(i,r,a),g=p-u;let b,w;p===u?b=0:i===p?b=(r-a)/g:r===p?b=2+(a-i)/g:a===p&&(b=4+(i-r)/g),b=Math.min(b*60,360),b<0&&(b+=360);const E=(u+p)/2;return p===u?w=0:E<=.5?w=g/(p+u):w=g/(2-p-u),{h:b,s:w,l:E}}function A(e){let i=te(e);if(!i)return e;let{h:r,s:a,l:u}=ie(i);return a+=.1,u-=.1,de(X({h:r,s:a,l:u}))}var L={60:"\\lt",62:"\\gt",111:"o",38:"\\&",123:"\\lbrace",125:"\\rbrace",91:"\\lbrack",93:"\\rbrack",58:"\\colon",160:"~",172:"\\neg",183:"\\cdot",188:"\\frac{1}{4}",189:"\\frac{1}{2}",190:"\\frac{3}{4}",8304:"^{0}",8305:"^{i}",185:"^{1}",178:"^{2}",179:"^{3}",8224:"\\dagger",8225:"\\ddagger",8230:"\\ldots",8308:"^{4}",8309:"^{5}",8310:"^{6}",8311:"^{7}",8312:"^{8}",8313:"^{9}",8314:"^{+}",8315:"^{-}",8316:"^{=}",8319:"^{n}",8320:"_{0}",8321:"_{1}",8322:"_{2}",8323:"_{3}",8324:"_{4}",8325:"_{5}",8326:"_{6}",8327:"_{7}",8328:"_{8}",8329:"_{9}",8330:"_{+}",8331:"_{-}",8332:"_{=}",8336:"_{a}",8337:"_{e}",8338:"_{o}",8339:"_{x}",8242:"\\prime",39:"\\prime",8592:"\\gets",8594:"\\to",9651:"\\triangle",9661:"\\triangledown",8715:"\\owns",8727:"\\ast",8739:"\\vert",8741:"\\Vert",8743:"\\land",8744:"\\lor",8901:"\\cdot",8904:"\\bowtie",8800:"\\ne",8804:"\\le",8805:"\\ge",8869:"\\bot",10231:"\\biconditional",10232:"\\impliedby",10233:"\\implies",10234:"\\iff",8450:"\\mathbb{C}",8469:"\\mathbb{N}",8473:"\\mathbb{P}",8474:"\\mathbb{Q}",8477:"\\mathbb{R}",8484:"\\mathbb{Z}",8461:"\\mathbb{H}",8476:"\\Re",8465:"\\Im",42:"\\ast",11036:"\\square",9633:"\\square",8720:"\\coprod",8716:"\\not\\ni",9671:"\\diamond",8846:"\\uplus",8851:"\\sqcap",8852:"\\sqcup",8768:"\\wr",8750:"\\oint",8226:"\\textbullet",8722:"-",978:"\\Upsilon"},V={119893:8462,119965:8492,119968:8496,119969:8497,119971:8459,119972:8464,119975:8466,119976:8499,119981:8475,119994:8495,119996:8458,120004:8500,120070:8493,120075:8460,120076:8465,120085:8476,120093:8488,120122:8450,120127:8461,120133:8469,120135:8473,120136:8474,120137:8477,120145:8484},pe=[{start:119808,len:26,offset:65,style:"bold"},{start:119834,len:26,offset:97,style:"bold"},{start:119860,len:26,offset:65,style:"italic"},{start:119886,len:26,offset:97,style:"italic"},{start:119912,len:26,offset:65,style:"bolditalic"},{start:119938,len:26,offset:97,style:"bolditalic"},{start:119964,len:26,offset:65,variant:"script"},{start:119990,len:26,offset:97,variant:"script"},{start:120016,len:26,offset:65,variant:"script",style:"bold"},{start:120042,len:26,offset:97,variant:"script",style:"bold"},{start:120068,len:26,offset:65,variant:"fraktur"},{start:120094,len:26,offset:97,variant:"fraktur"},{start:120172,len:26,offset:65,variant:"fraktur",style:"bold"},{start:120198,len:26,offset:97,variant:"fraktur",style:"bold"},{start:120120,len:26,offset:65,variant:"double-struck"},{start:120146,len:26,offset:97,variant:"double-struck"},{start:120224,len:26,offset:65,variant:"sans-serif"},{start:120250,len:26,offset:97,variant:"sans-serif"},{start:120276,len:26,offset:65,variant:"sans-serif",style:"bold"},{start:120302,len:26,offset:97,variant:"sans-serif",style:"bold"},{start:120328,len:26,offset:65,variant:"sans-serif",style:"italic"},{start:120354,len:26,offset:97,variant:"sans-serif",style:"italic"},{start:120380,len:26,offset:65,variant:"sans-serif",style:"bolditalic"},{start:120406,len:26,offset:97,variant:"sans-serif",style:"bolditalic"},{start:120432,len:26,offset:65,variant:"monospace"},{start:120458,len:26,offset:97,variant:"monospace"},{start:120488,len:25,offset:913,style:"bold"},{start:120514,len:25,offset:945,style:"bold"},{start:120546,len:25,offset:913,style:"italic"},{start:120572,len:25,offset:945,style:"italic"},{start:120604,len:25,offset:913,style:"bolditalic"},{start:120630,len:25,offset:945,style:"bolditalic"},{start:120662,len:25,offset:913,variant:"sans-serif",style:"bold"},{start:120688,len:25,offset:945,variant:"sans-serif",style:"bold"},{start:120720,len:25,offset:913,variant:"sans-serif",style:"bolditalic"},{start:120746,len:25,offset:945,variant:"sans-serif",style:"bolditalic"},{start:120782,len:10,offset:48,variant:"main",style:"bold"},{start:120792,len:10,offset:48,variant:"double-struck"},{start:120803,len:10,offset:48,variant:"sans-serif"},{start:120812,len:10,offset:48,variant:"sans-serif",style:"bold"},{start:120822,len:10,offset:48,variant:"monospace"}];function ze(e,i,r){if(!/[A-Za-z\d]/.test(e)||(r==="up"&&(r=void 0),!i&&!r))return e;const a=e.codePointAt(0);if(a===void 0)return e;for(const u of pe)if((!i||u.variant===i)&&(!r||u.style===r)&&a>=u.offset&&a<u.offset+u.len){const p=u.start+a-u.offset;return String.fromCodePoint(V[p]||p)}return e}function at(e){var i;if((e<119808||e>120831)&&(e<8448||e>8527))return{char:String.fromCodePoint(e)};for(const r in V)if(V[r]===e){e=(i=r.codePointAt(0))!=null?i:0;break}for(const r of pe)if(e>=r.start&&e<r.start+r.len)return{char:String.fromCodePoint(e-r.start+r.offset),variant:r.variant,style:r.style};return{char:String.fromCodePoint(e)}}function Ot(e){var i;let r="";for(const a of e){if("{}<>[]$&#^_%:'\u02DC".includes(a)){r+=a;continue}const u=(i=a.codePointAt(0))!=null?i:0;let p=L[u];if(p)p.startsWith("\\")?r+=p+" ":r+=p;else{const{char:g,variant:b,style:w}=at(u);switch(p=g,b){case"double-struck":p=`\\mathbb{${p}}`;break;case"fraktur":p=`\\mathfrak{${p}}`;break;case"script":p=`\\mathscr{${p}}`;break;case"sans-serif":p=`\\mathsf{${p}}`;break;case"monospace":p=`\\mathtt{${p}}`;break;case"calligraphic":p=`\\mathcal{${p}}`;break}switch(w){case"bold":p=`\\mathbf{${p}}`;break;case"italic":p=`\\mathit{${p}}`;break;case"bolditalic":p=`\\mathbfit{${p}}`;break}r+=p}}return r}function Ce(e){return e?Array.isArray(e)?e:typeof e=="object"&&"group"in e?e.group:[]:[]}var jt={},Mt=P({},L),dt={},Ti={},fi={darr:"\\downarrow",dArr:"\\Downarrow",Darr:"\\Downarrow",lang:"\\langle",rang:"\\rangle",uarr:"\\uparrow",uArr:"\\Uparrow",Uarr:"\\Uparrow",N:"\\mathbb{N}",R:"\\mathbb{R}",Z:"\\mathbb{Z}",alef:"\\aleph",alefsym:"\\aleph",Alpha:"\\mathrm{A}",Beta:"\\mathrm{B}",bull:"\\bullet",Chi:"\\mathrm{X}",clubs:"\\clubsuit",cnums:"\\mathbb{C}",Complex:"\\mathbb{C}",Dagger:"\\ddagger",diamonds:"\\diamondsuit",empty:"\\emptyset",Epsilon:"\\mathrm{E}",Eta:"\\mathrm{H}",exist:"\\exists",harr:"\\leftrightarrow",hArr:"\\Leftrightarrow",Harr:"\\Leftrightarrow",hearts:"\\heartsuit",image:"\\Im",infin:"\\infty",Iota:"\\mathrm{I}",isin:"\\in",Kappa:"\\mathrm{K}",larr:"\\leftarrow",lArr:"\\Leftarrow",Larr:"\\Leftarrow",lrarr:"\\leftrightarrow",lrArr:"\\Leftrightarrow",Lrarr:"\\Leftrightarrow",Mu:"\\mathrm{M}",natnums:"\\mathbb{N}",Nu:"\\mathrm{N}",Omicron:"\\mathrm{O}",plusmn:"\\pm",rarr:"\\rightarrow",rArr:"\\Rightarrow",Rarr:"\\Rightarrow",real:"\\Re",reals:"\\mathbb{R}",Reals:"\\mathbb{R}",Rho:"\\mathrm{P}",sdot:"\\cdot",sect:"\\S",spades:"\\spadesuit",sub:"\\subset",sube:"\\subseteq",supe:"\\supseteq",Tau:"\\mathrm{T}",thetasym:"\\vartheta",weierp:"\\wp",Zeta:"\\mathrm{Z}"},Yi={varGamma:"\\mathit{\\Gamma}",varDelta:"\\mathit{\\Delta}",varTheta:"\\mathit{\\Theta}",varLambda:"\\mathit{\\Lambda}",varXi:"\\mathit{\\Xi}",varPi:"\\mathit{\\Pi}",varSigma:"\\mathit{\\Sigma}",varUpsilon:"\\mathit{\\Upsilon}",varPhi:"\\mathit{\\Phi}",varPsi:"\\mathit{\\Psi}",varOmega:"\\mathit{\\Omega}",pmod:{def:"\\quad(\\operatorname{mod}\\ #1)",args:1,expand:!1,captureSelection:!1},mod:{def:"\\quad\\operatorname{mod}\\,\\,#1",args:1,expand:!1},bmod:{def:"\\;\\mathbin{\\operatorname{mod }}",expand:!1}},Kt={bra:{def:"\\mathinner{\\langle{#1}|}",args:1,captureSelection:!1},ket:{def:"\\mathinner{|{#1}\\rangle}",args:1,captureSelection:!1},braket:{def:"\\mathinner{\\langle{#1}\\rangle}",args:1,captureSelection:!1},set:{def:"\\mathinner{\\lbrace #1 \\rbrace}",args:1,captureSelection:!1},Bra:{def:"\\left\\langle #1\\right|",args:1,captureSelection:!1},Ket:{def:"\\left|#1\\right\\rangle",args:1,captureSelection:!1},Braket:{def:"\\left\\langle{#1}\\right\\rangle",args:1,captureSelection:!1},Set:{def:"\\left\\lbrace #1 \\right\\rbrace",args:1,captureSelection:!1}},ln={iff:{primitive:!0,captureSelection:!0,def:"\\;\u27FA\\;"},nicefrac:"^{#1}\\!\\!/\\!_{#2}",phase:{def:"\\enclose{phasorangle}{#1}",args:1,captureSelection:!1},rd:"\\mathrm{d}",rD:"\\mathrm{D}",doubleStruckCapitalN:"\\mathbb{N}",doubleStruckCapitalR:"\\mathbb{R}",doubleStruckCapitalQ:"\\mathbb{Q}",doubleStruckCapitalZ:"\\mathbb{Z}",doubleStruckCapitalP:"\\mathbb{P}",scriptCapitalE:"\\mathscr{E}",scriptCapitalH:"\\mathscr{H}",scriptCapitalL:"\\mathscr{L}",gothicCapitalC:"\\mathfrak{C}",gothicCapitalH:"\\mathfrak{H}",gothicCapitalI:"\\mathfrak{I}",gothicCapitalR:"\\mathfrak{R}",imaginaryI:"\\mathrm{i}",imaginaryJ:"\\mathrm{j}",exponentialE:"\\mathrm{e}",differentialD:"\\mathrm{d}",capitalDifferentialD:"\\mathrm{D}",mathstrut:{def:"\\vphantom{(}",primitive:!0},angl:"\\enclose{actuarial}{#1}",angln:"\\enclose{actuarial}{n}",anglr:"\\enclose{actuarial}{r}",anglk:"\\enclose{actuarial}{k}",mathtools:{primitive:!0,package:{ordinarycolon:":",vcentcolon:"\\mathrel{\\mathop\\ordinarycolon}",dblcolon:'{\\mathop{\\char"2237}}',coloneqq:'{\\mathop{\\char"2254}}',Coloneqq:'{\\mathop{\\char"2237\\char"3D}}',coloneq:'{\\mathop{\\char"3A\\char"2212}}',Coloneq:'{\\mathop{\\char"2237\\char"2212}}',eqqcolon:'{\\mathop{\\char"2255}}',Eqqcolon:'{\\mathop{\\char"3D\\char"2237}}',eqcolon:'{\\mathop{\\char"2239}}',Eqcolon:'{\\mathop{\\char"2212\\char"2237}}',colonapprox:'{\\mathop{\\char"003A\\char"2248}}',Colonapprox:'{\\mathop{\\char"2237\\char"2248}}',colonsim:'{\\mathop{\\char"3A\\char"223C}}',Colonsim:'{\\mathop{\\char"2237\\char"223C}}',colondash:"\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}",Colondash:"\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}",dashcolon:"\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}",Dashcolon:"\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}"}},ratio:"\\vcentcolon",coloncolon:"\\dblcolon",colonequals:"\\coloneq",coloncolonequals:"\\Coloneq",equalscolon:"\\eqcolon",equalscoloncolon:"\\Eqcolon",colonminus:"\\colondash",coloncolonminus:"\\Colondash",minuscolon:"\\dashcolon",minuscoloncolon:"\\Dashcolon",coloncolonapprox:"\\Colonapprox",coloncolonsim:"\\Colonsim",simcolon:"\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}",Simcolon:"\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}",simcoloncolon:"\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}",approxcolon:"\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}",Approxcolon:"\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}",approxcoloncolon:"\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}",notni:"\\mathrel{\\char`\u220C}",limsup:"\\operatorname*{lim\\,sup}",liminf:"\\operatorname*{lim\\,inf}",injlim:"\\operatorname*{inj\\,lim}",projlim:"\\operatorname*{proj\\,lim}",varlimsup:"\\operatorname*{\\overline{lim}}",varliminf:"\\operatorname*{\\underline{lim}}",varinjlim:"\\operatorname*{\\underrightarrow{lim}}",varprojlim:"\\operatorname*{\\underleftarrow{lim}}",argmin:"\\operatorname*{arg\\,min}",argmax:"\\operatorname*{arg\\,max}",plim:"\\mathop{\\operatorname{plim}}\\limits",tripledash:{def:"\\vphantom{-}\\raise{4mu}{\\mkern1.5mu\\rule{2mu}{1.5mu}\\mkern{2.25mu}\\rule{2mu}{1.5mu}\\mkern{2.25mu}\\rule{2mu}{1.5mu}\\mkern{2mu}}",expand:!0},"braket.sty":{package:Kt},"amsmath.sty":{package:Yi,primitive:!0},"texvc.sty":{package:fi,primitive:!1}},Ne={" ":32,"\\!":33,"\\#":35,"\\$":36,"\\%":37,"\\&":38,"-":45,"\\textunderscore":95,"\\euro":8364,"\\maltese":10016,"\\{":123,"\\}":125,"\\textbraceleft":123,"\\textbraceright":125,"\\lbrace":123,"\\rbrace":125,"\\lbrack":91,"\\rbrack":93,"\\nobreakspace":160,"\\ldots":8230,"\\textellipsis":8230,"\\backslash":92,"`":8216,"'":8217,"``":8220,"''":8221,"\\degree":176,"\\textasciicircum":94,"\\textasciitilde":126,"\\textasteriskcentered":42,"\\textbackslash":92,"\\textbullet":8226,"\\textdollar":36,"\\textsterling":163,"\\textdagger":8224,"\\textdaggerdbl":8225,"\u2013":8211,"\u2014":8212,"\u2018":8216,"\u2019":8217,"\u201C":8220,"\u201D":8221,'"':8221,"\\ss":223,"\\ae":230,"\\oe":339,"\\AE":198,"\\OE":338,"\\O":216,"\\i":305,"\\j":567,"\\aa":229,"\\AA":197},Ge=/[\w!@*()-=+{}\[\]\\';:?/.,~<>`|$%#&^" ]/,ve,nt;j()?(ve=new RegExp("\\p{Letter}","u"),nt=new RegExp("[0-9\\p{Letter}]","u")):(ve=/[a-zA-ZаАбБвВгГдДеЕёЁжЖзЗиИйЙкКлЛмМнНоОпПрРсСтТуУфФхХцЦчЧшШщЩъЪыЫьЬэЭюЮяĄąĆćĘꣳŃńÓóŚśŹźŻżàâäôéèëêïîçùûüÿæœÀÂÄÔÉÈËÊÏΟÇÙÛÜÆŒößÖẞìíòúÌÍÒÚáñÁÑ]/,nt=/[\da-zA-ZаАбБвВгГдДеЕёЁжЖзЗиИйЙкКлЛмМнНоОпПрРсСтТуУфФхХцЦчЧшШщЩъЪыЫьЬэЭюЮяĄąĆćĘꣳŃńÓóŚśŹźŻżàâäôéèëêïîçùûüÿæœÀÂÄÔÉÈËÊÏΟÇÙÛÜÆŒößÖẞìíòúÌÍÒÚáñÁÑ]/);function _t(e,i,r="mord",a){i!==void 0&&(jt[e]={definitionType:"symbol",type:r,variant:a,codepoint:i},Mt[i]||(Mt[i]=e))}function lt(e,i,r){if(typeof e=="string"){for(let a=0;a<e.length;a++){const u=e.charAt(a);_t(u,u.codePointAt(0))}return}for(const[a,u,p,g]of e)_t(a,u,p!=null?p:i,g!=null?g:r)}function ee(e,i){for(let r=e;r<=i;r++)_t(String.fromCodePoint(r),r)}function xe(e){var i;return(i=Ti[e])!=null?i:null}function $e(e,i){var r,a;if(i.length===0||i==="\\"||!i.startsWith("\\"))return[];const u=[];for(const g in dt)g.startsWith(i)&&!dt[g].infix&&u.push({match:g,frequency:(r=dt[g].frequency)!=null?r:0});for(const g in jt)g.startsWith(i)&&u.push({match:g,frequency:(a=jt[g].frequency)!=null?a:0});const p=i.substring(1);for(const g of Object.keys(e.options.macros))g.startsWith(p)&&u.push({match:"\\"+g,frequency:0});return u.sort((g,b)=>{var w,E;return g.frequency===b.frequency?g.match.length===b.match.length?g.match<b.match?-1:1:g.match.length-b.match.length:((w=b.frequency)!=null?w:0)-((E=g.frequency)!=null?E:0)}),u.map(g=>g.match)}function Ye(e){let i="auto";const r=e.match(/:([^=]+)/);return r&&(i=r[1].trim()),i}function rt(e){if(!e)return[];const i=[];let r=e.split("]");if(r[0].startsWith("[")){i.push({isOptional:!0,type:Ye(r[0].slice(1))});for(let a=1;a<=r.length;a++)i.push(...rt(r[a]))}else if(r=e.split("}"),r[0].startsWith("{")){i.push({isOptional:!1,type:Ye(r[0].slice(1))});for(let a=1;a<=r.length;a++)i.push(...rt(r[a]))}return i}function gt(e){if(!e)return"";let i="",r=!0;for(const a of e)typeof a.value=="string"?i+=a.value:r=!1;return r?i:""}function Yt(e,i){typeof e=="string"&&(e=[e]);const r={tabular:!1,params:[],createAtom:i};for(const a of e)Ti[a]=r}function pt(e,i,r){typeof e=="string"&&(e=[e]);const u={tabular:!0,params:rt(i),createAtom:r};for(const p of e)Ti[p]=u}function ke(e,i,r){var a,u;r||(r={});const p={definitionType:"function",params:rt(i),ifMode:r.ifMode,isFunction:(a=r.isFunction)!=null?a:!1,applyMode:r.applyMode,infix:(u=r.infix)!=null?u:!1,parse:r.parse,createAtom:r.createAtom,applyStyle:r.applyStyle,serialize:r.serialize,render:r.render};if(typeof e=="string")dt["\\"+e]=p;else for(const g of e)dt["\\"+g]=p}var ht;function Gt(e){return ht||(ht=Ae(ln)),e?Ae(P(P({},ht),e)):ht}function zt(e,i){var r,a,u,p;if(typeof e=="string"){let g=0;const b=e;return/(^|[^\\])#1/.test(b)&&(g=1),/(^|[^\\])#2/.test(b)&&(g=2),/(^|[^\\])#3/.test(b)&&(g=3),/(^|[^\\])#4/.test(b)&&(g=4),/(^|[^\\])#5/.test(b)&&(g=5),/(^|[^\\])#6/.test(b)&&(g=6),/(^|[^\\])#7/.test(b)&&(g=7),/(^|[^\\])#8/.test(b)&&(g=8),/(^|[^\\])#9/.test(b)&&(g=9),{expand:(r=i==null?void 0:i.expand)!=null?r:!0,captureSelection:(a=i==null?void 0:i.captureSelection)!=null?a:!0,args:g,def:b}}return P({expand:(u=i==null?void 0:i.expand)!=null?u:!0,captureSelection:(p=i==null?void 0:i.captureSelection)!=null?p:!0,args:0},e)}function Ae(e){if(!e)return{};const i={};for(const r of Object.keys(e)){const a=e[r];if(a==null)delete i[r];else if(typeof a=="object"&&"package"in a)for(const u of Object.keys(a.package))i[u]=zt(a.package[u],{expand:!a.primitive,captureSelection:a.captureSelection});else i[r]=zt(a)}return i}function Me(e,i="math"){if(!e||e.length===0)return null;let r=null;if(e.startsWith("\\")){if(r=dt[e],r)return!r.ifMode||r.ifMode===i?r:null;i==="math"?r=jt[e]:Ne[e]&&(r={definitionType:"symbol",type:"mord",codepoint:Ne[e]})}else if(i==="math"){if(r=jt[e],!r&&e.length===1){const a=ft("math",e.codePointAt(0));return a.startsWith("\\")?d(P({},Me(a,"math")),{command:a}):null}}else Ne[e]?r={definitionType:"symbol",type:"mord",codepoint:Ne[e]}:i==="text"&&(r={definitionType:"symbol",type:"mord",codepoint:e.codePointAt(0)});return r!=null?r:null}function tt(e,i){if(!e.startsWith("\\"))return null;const r=e.slice(1);return i[r]}function ft(e,i){if(i===void 0)return"";if(e==="math"&&Mt[i])return Mt[i];if(e==="text"){const r=Object.keys(Ne).find(a=>Ne[a]===i);return r||String.fromCodePoint(i)}return String.fromCodePoint(i)}var je=[0,.68889,0,0,.72222],At=[0,.68889,0,0,.66667],Lt=[0,.68889,0,0,.77778],vt=[0,.68889,0,0,.61111],Pt=[.16667,.68889,0,0,.77778],Ht=[0,.68889,0,0,.55556],Xe=[0,0,0,0,.25],Ft=[0,.825,0,0,2.33334],Le=[0,.9,0,0,2.33334],ye=[0,.68889,0,0,.54028],we=[-.03598,.46402,0,0,.5],K=[-.13313,.36687,0,0,1],W=[.01354,.52239,0,0,1],ae=[.01354,.52239,0,0,1.11111],fe=[0,.54986,0,0,1],_e=[0,.69224,0,0,.5],st=[0,.43056,0,0,1],ot=[.08198,.58198,0,0,.77778],xt=[.19444,.69224,0,0,.41667],Ut=[.1808,.675,0,0,1],ti=[.19444,.69224,0,0,.83334],di=[.13667,.63667,0,0,1],Qt=[-.064,.437,0,0,1.334],kt=[.08167,.58167,0,0,.77778],oi=[0,.69224,0,0,.72222],Di=[0,.69224,0,0,.66667],ki=[-.13313,.36687,0,0,.77778],Bi=[.06062,.54986,0,0,.77778],pi=[0,.69224,0,0,.77778],mi=[.25583,.75583,0,0,.77778],Xi=[.25142,.75726,0,0,.77778],nn=[.20576,.70576,0,0,.77778],un=[.30274,.79383,0,0,.77778],Ji=[.22958,.72958,0,0,.77778],dr=[.1808,.675,0,0,.77778],Mi=[.13667,.63667,0,0,.77778],Oi=[.13597,.63597,0,0,.77778],yn=[.03517,.54986,0,0,.77778],Ri=[0,.675,0,0,.77778],Dn=[.19444,.69224,0,0,.61111],hn=[0,.54986,0,0,.76042],Yn=[0,.54986,0,0,.66667],fn=[.0391,.5391,0,0,.77778],gr=[.03517,.54986,0,0,1.33334],Yr=[.38569,.88569,0,0,.77778],Ei=[.23222,.74111,0,0,.77778],$t=[.19444,.69224,0,0,.77778],Re=[0,.37788,0,0,.5],Je=[0,.54986,0,0,.72222],ut=[0,.69224,0,0,.83334],it=[.11111,.69224,0,0,.66667],wt=[.26167,.75726,0,0,.77778],St=[.48256,.98256,0,0,.77778],Bt=[.28481,.79383,0,0,.77778],ni=[.08167,.58167,0,0,.22222],Gi=[.08167,.58167,0,0,.38889],gi=[0,.43056,.04028,0,.66667],dn=[.41951,.91951,0,0,.77778],_i=[.24982,.74947,0,0,.38865],Ai=[.08319,.58283,0,0,.75623],Ci=[0,.10803,0,0,.27764],Ni=[0,.47534,0,0,.50181],$i=[.18906,.47534,0,0,.50181],ui=[0,.69141,0,0,.50181],Ii=[.24982,.74947,0,0,.27764],Qi=[0,.69141,0,0,.21471],Fi=[.25,.75,0,0,.44722],wi=[0,.64444,0,0,.575],ji=[.08556,.58556,0,0,.89444],Ki=[0,.69444,0,0,.89444],en=[0,.68611,0,0,.9],Pn=[0,.68611,0,0,.86944],tn=[.25,.75,0,0,.575],er=[.25,.75,0,0,.31944],cn=[0,.69444,0,0,.63889],Cn=[0,.69444,0,0,.31944],tr=[0,.44444,0,0,.63889],Ui=[0,.44444,0,0,.51111],zi=[0,.69444,0,0,.575],Ln=[.13333,.63333,0,0,.89444],bn=[0,.44444,0,0,.31944],rn=[0,.69444,0,0,.86944],xn=[0,.68611,0,0,.69166],pn=[0,.68611,0,0,.83055],Vn=[0,.68611,0,0,.89444],Mr=[0,.69444,0,0,.60278],On=[.19444,.69444,0,0,.51111],Br=[0,.69444,0,0,.83055],En=[-.10889,.39111,0,0,1.14999],sr=[.19444,.69444,0,0,.575],Rr=[.19444,.69444,0,0,1.14999],Tr=[.19444,.69444,0,0,.70277],xr=[.05556,.75,0,0,.575],Mn=[0,.68611,0,0,.95833],cr=[.08556,.58556,0,0,.76666],wr=[-.02639,.47361,0,0,.575],Nr=[0,.44444,0,0,.89444],kn=[0,.55556,0,0,.76666],pr=[-.10889,.39111,0,0,.89444],Gn=[.00222,.50222,0,0,.89444],hr=[.19667,.69667,0,0,.89444],Wr=[.08556,.58556,0,0,1.14999],Hi=[0,.69444,0,0,.70277],vi=[-.02778,.47222,0,0,.575],Wt=[.25,.75,0,0,.51111],_n=[-.13889,.36111,0,0,1.14999],mr=[.19444,.69444,0,0,1.02222],Nn=[.12963,.69444,0,0,.89444],ar=[.19444,.69444,0,0,.44722],$n=[0,.64444,.13167,0,.59111],cs=[.19444,.64444,.13167,0,.59111],Sr=[0,.68611,.17208,0,.8961],vn=[.19444,.44444,.105,0,.53222],hs=[0,.44444,.085,0,.82666],ns=[0,.69444,.06709,0,.59111],or=[0,.69444,.12945,0,.35555],jr=[0,.69444,0,0,.94888],ys=[0,.69444,.11472,0,.59111],_r=[0,.68611,.10778,0,.88555],Kn=[0,.69444,.07939,0,.62055],fr=[0,.69444,.12417,0,.30667],Xn=[0,.64444,.13556,0,.51111],rs=[.19444,.64444,.13556,0,.51111],ss=[0,.68333,.16389,0,.74333],Ps=[.19444,.43056,.08847,0,.46],ya=[0,.43056,.07514,0,.71555],Os=[0,.69444,.06646,0,.51111],ba=[0,.69444,0,0,.83129],ri=[0,.69444,.1225,0,.51111],Jt=[0,.68333,.09403,0,.76666],Wi=[0,.68333,.11111,0,.76666],Hn=[0,.69444,.06961,0,.51444],mn=[0,.69444,0,0,.27778],$r=[.25,.75,0,0,.38889],ir=[0,.64444,0,0,.5],Ts=[0,.69444,0,0,.77778],fs=[0,.68333,0,0,.75],xa=[0,.68333,0,0,.77778],ql=[0,.68333,0,0,.68056],Ws=[0,.68333,0,0,.72222],as=[.25,.75,0,0,.5],Ha=[.25,.75,0,0,.27778],nr=[0,.69444,0,0,.5],na=[0,.69444,0,0,.55556],Wa=[0,.43056,0,0,.44445],os=[0,.43056,0,0,.5],tl=[.19444,.43056,0,0,.55556],ds=[0,.43056,0,0,.55556],ls=[.08333,.58333,0,0,.77778],il=[0,.43056,0,0,.27778],nl=[0,.66786,0,0,.27778],Eo=[0,.69444,0,0,.75],rl=[0,.66786,0,0,.5],sl=[0,.68333,0,0,.625],al=[.19444,.69444,0,0,.44445],ra=[0,.69444,0,0,.72222],ko=[.19444,.69444,0,0,.5],As=[.19444,.69444,0,0,1],ps=[.011,.511,0,0,1.126],To=[.19444,.69444,0,0,.61111],ja=[.05556,.75,0,0,.5],ol=[0,.68333,0,0,.83334],ll=[.0391,.5391,0,0,.66667],wa=[-.05555,.44445,0,0,.5],Zl=[0,.43056,0,0,.77778],sa=[0,.55556,0,0,.66667],qa=[-.03625,.46375,0,0,.77778],Ao=[-.01688,.48312,0,0,.77778],Lo=[.0391,.5391,0,0,1],Fs=[0,.69444,0,0,.61111],Za=[-.03472,.46528,0,0,.5],Ya=[.25,.75,0,0,.44445],ul=[-.14236,.35764,0,0,1],Wn=[.244,.744,0,0,.412],Rn=[.19444,.69444,0,0,.88889],Fn=[.12963,.69444,0,0,.77778],Ar=[.19444,.69444,0,0,.38889],Xr=[.011,.511,0,0,1.638],Sa=[.19444,.69444,0,0,0],aa=[0,.44444,0,0,.575],Xa=[.19444,.44444,0,0,.575],Do=[0,.68611,0,0,.75555],Ea=[0,.69444,0,0,.66759],vr=[0,.68611,0,0,.80555],Ir=[0,.68611,.08229,0,.98229],Yl=[0,.68611,0,0,.76666],mt=[0,.44444,0,0,.58472],Xl=[.19444,.44444,0,0,.6118],Co=[.19444,.43056,0,0,.5],oc=[0,.68333,.02778,.08334,.76278],vh=[0,.68333,.08125,.05556,.83125],Jl=[0,.43056,0,.05556,.48472],lc=[.19444,.43056,0,.08334,.51702],yh=[.25,.75,0,0,.42778],qr=[0,.69444,0,0,.55],Bs=[0,.69444,0,0,.73334],Ls=[0,.69444,0,0,.79445],Ja=[0,.69444,0,0,.51945],uc=[0,.69444,0,0,.70278],bh=[0,.69444,0,0,.76389],xh=[.25,.75,0,0,.34306],cc=[0,.69444,0,0,.56111],hc=[0,.69444,0,0,.25556],Ql=[.19444,.45833,0,0,.56111],cl=[0,.45833,0,0,.56111],ka=[0,.69444,0,0,.30556],wh=[0,.69444,0,0,.58056],fc=[0,.69444,0,0,.67223],eu=[0,.69444,0,0,.85556],hl=[0,.69444,0,0,.55834],js=[0,.65556,.11156,0,.5],Mo=[0,.69444,.08094,0,.70834],dc=[.17014,0,0,0,.44445],Sh=[0,.69444,.0799,0,.5],pc=[0,.69444,0,0,.73752],mc=[0,.69444,.09205,0,.5],Eh=[0,.69444,.09031,0,.77778],tu=[0,.69444,.07816,0,.27778],kh=[0,.69444,.00316,0,.5],Th=[.19444,.69444,0,0,.83334],iu=[.05556,.75,0,0,.83334],Ah=[0,.75,0,0,.5],Lh=[.125,.08333,0,0,.27778],Dh=[0,.08333,0,0,.27778],qs=[0,.65556,0,0,.5],gc=[0,.69444,0,0,.47222],oa=[0,.69444,0,0,.66667],Ch=[0,.69444,0,0,.59722],_c=[0,.69444,0,0,.54167],vc=[0,.69444,0,0,.70834],fl=[.25,.75,0,0,.28889],yc=[0,.69444,0,0,.51667],bc=[0,.44444,0,0,.44445],xc=[.19444,.44444,0,0,.51667],Mh=[0,.44444,0,0,.38333],nu=[0,.44444,0,0,.51667],ms=[0,.69444,0,0,.83334],Ns=[.35001,.85,0,0,.45834],ru=[.35001,.85,0,0,.57778],Rh=[.35001,.85,0,0,.41667],dl=[.35001,.85,0,0,.58334],su=[0,.72222,0,0,.55556],Ih=[1e-5,.6,0,0,.66667],Ph=[1e-5,.6,0,0,.77778],Oh=[.25001,.75,0,0,.94445],wc=[.306,.805,.19445,0,.47222],Sc=[.30612,.805,.19445,0,.47222],Ta=[.25001,.75,0,0,.83334],Qa=[.35001,.85,0,0,.47222],Ec=[.25001,.75,0,0,1.11111],kc=[.65002,1.15,0,0,.59722],Fh=[.65002,1.15,0,0,.81111],Tc=[.65002,1.15,0,0,.47222],Bh=[.65002,1.15,0,0,.66667],pl=[0,.75,0,0,1],Nh=[.55001,1.05,0,0,1.27778],$h=[.862,1.36,.44445,0,.55556],Kh=[.86225,1.36,.44445,0,.55556],eo=[.55001,1.05,0,0,1.11111],au=[.65002,1.15,0,0,.52778],Ac=[.65002,1.15,0,0,.61111],to=[.55001,1.05,0,0,1.51112],Uh=[.95003,1.45,0,0,.73611],zh=[.95003,1.45,0,0,1.04445],Pr=[.95003,1.45,0,0,.52778],$s=[.95003,1.45,0,0,.75],Ro=[0,.75,0,0,1.44445],ou=[.95003,1.45,0,0,.58334],Vh=[1.25003,1.75,0,0,.79167],lu=[1.25003,1.75,0,0,1.27778],uu=[1.25003,1.75,0,0,.58334],la=[1.25003,1.75,0,0,.80556],cu=[0,.825,0,0,1.8889],Ks=[1.25003,1.75,0,0,.63889],Ke=[.64502,1.155,0,0,.875],Lc=[1e-5,.6,0,0,.875],ml=[-99e-5,.601,0,0,.66667],hu=[.64502,1.155,0,0,.66667],Io=[1e-5,.9,0,0,.88889],Gh=[.65002,1.15,0,0,.88889],Hh=[.90001,0,0,0,.88889],Wh=[-.00499,.605,0,0,1.05556],fu=[0,.12,0,0,.45],ii=[0,.61111,0,0,.525],Jr=[.08333,.69444,0,0,.525],du=[-.08056,.53055,0,0,.525],Dc=[-.05556,.55556,0,0,.525],Kr=[0,.43056,0,0,.525],Qr=[.22222,.43056,0,0,.525],jh=[0,0,0,0,.525],qh={"AMS-Regular":{32:Xe,65:je,66:At,67:je,68:je,69:At,70:vt,71:Lt,72:Lt,73:[0,.68889,0,0,.38889],74:[.16667,.68889,0,0,.5],75:Lt,76:At,77:[0,.68889,0,0,.94445],78:je,79:Pt,80:vt,81:Pt,82:je,83:Ht,84:At,85:je,86:je,87:[0,.68889,0,0,1],88:je,89:je,90:At,107:Ht,160:Xe,165:[0,.675,.025,0,.75],174:[.15559,.69224,0,0,.94666],240:Ht,295:ye,710:Ft,732:Le,770:Ft,771:Le,989:kt,1008:gi,8245:[0,.54986,0,0,.275],8463:ye,8487:je,8498:Ht,8502:At,8503:[0,.68889,0,0,.44445],8504:At,8513:[0,.68889,0,0,.63889],8592:we,8594:we,8602:K,8603:K,8606:W,8608:W,8610:ae,8611:ae,8619:fe,8620:fe,8621:[-.13313,.37788,0,0,1.38889],8622:K,8624:_e,8625:_e,8630:st,8631:st,8634:ot,8635:ot,8638:xt,8639:xt,8642:xt,8643:xt,8644:Ut,8646:Ut,8647:Ut,8648:ti,8649:Ut,8650:ti,8651:W,8652:W,8653:K,8654:K,8655:K,8666:di,8667:di,8669:[-.13313,.37788,0,0,1],8672:Qt,8674:Qt,8705:[0,.825,0,0,.5],8708:Ht,8709:kt,8717:[0,.43056,0,0,.42917],8722:we,8724:[.08198,.69224,0,0,.77778],8726:kt,8733:pi,8736:oi,8737:oi,8738:[.03517,.52239,0,0,.72222],8739:ni,8740:[.25142,.74111,0,0,.27778],8741:Gi,8742:[.25142,.74111,0,0,.5],8756:Di,8757:Di,8764:ki,8765:[-.13313,.37788,0,0,.77778],8769:ki,8770:qa,8774:un,8776:Ao,8778:kt,8782:Bi,8783:Bi,8785:ot,8786:ot,8787:ot,8790:pi,8791:Ji,8796:[.08198,.91667,0,0,.77778],8806:mi,8807:mi,8808:Xi,8809:Xi,8812:[.25583,.75583,0,0,.5],8814:nn,8815:nn,8816:un,8817:un,8818:Ji,8819:Ji,8822:dr,8823:dr,8828:Mi,8829:Mi,8830:Ji,8831:Ji,8832:nn,8833:nn,8840:un,8841:un,8842:Oi,8843:Oi,8847:yn,8848:yn,8858:ot,8859:ot,8861:ot,8862:Ri,8863:Ri,8864:Ri,8865:Ri,8872:[0,.69224,0,0,.61111],8873:oi,8874:[0,.69224,0,0,.88889],8876:vt,8877:vt,8878:je,8879:je,8882:yn,8883:yn,8884:Mi,8885:Mi,8888:[0,.54986,0,0,1.11111],8890:tl,8891:Dn,8892:Dn,8901:[0,.54986,0,0,.27778],8903:kt,8905:kt,8906:kt,8907:pi,8908:pi,8909:[-.03598,.46402,0,0,.77778],8910:hn,8911:hn,8912:yn,8913:yn,8914:Yn,8915:Yn,8916:Di,8918:fn,8919:fn,8920:gr,8921:gr,8922:Yr,8923:Yr,8926:Mi,8927:Mi,8928:un,8929:un,8934:Ei,8935:Ei,8936:Ei,8937:Ei,8938:nn,8939:nn,8940:un,8941:un,8994:$t,8995:$t,9416:[.15559,.69224,0,0,.90222],9484:_e,9488:_e,9492:Re,9496:Re,9585:[.19444,.68889,0,0,.88889],9586:[.19444,.74111,0,0,.88889],9632:Ri,9633:Ri,9650:Je,9651:Je,9654:yn,9660:Je,9661:Je,9664:yn,9674:it,9733:[.19444,.69224,0,0,.94445],10003:ut,10016:ut,10731:it,10846:[.19444,.75583,0,0,.61111],10877:Mi,10878:Mi,10885:mi,10886:mi,10887:Oi,10888:Oi,10889:wt,10890:wt,10891:St,10892:St,10901:Mi,10902:Mi,10933:Xi,10934:Xi,10935:wt,10936:wt,10937:wt,10938:wt,10949:mi,10950:mi,10955:Bt,10956:Bt,57350:ni,57351:Gi,57352:kt,57353:gi,57356:Xi,57357:Xi,57358:dn,57359:un,57360:un,57361:dn,57366:Xi,57367:Xi,57368:Xi,57369:Xi,57370:Oi,57371:Oi},"Caligraphic-Regular":{32:Xe,65:[0,.68333,0,.19445,.79847],66:[0,.68333,.03041,.13889,.65681],67:[0,.68333,.05834,.13889,.52653],68:[0,.68333,.02778,.08334,.77139],69:[0,.68333,.08944,.11111,.52778],70:[0,.68333,.09931,.11111,.71875],71:[.09722,.68333,.0593,.11111,.59487],72:[0,.68333,.00965,.11111,.84452],73:[0,.68333,.07382,0,.54452],74:[.09722,.68333,.18472,.16667,.67778],75:[0,.68333,.01445,.05556,.76195],76:[0,.68333,0,.13889,.68972],77:[0,.68333,0,.13889,1.2009],78:[0,.68333,.14736,.08334,.82049],79:[0,.68333,.02778,.11111,.79611],80:[0,.68333,.08222,.08334,.69556],81:[.09722,.68333,0,.11111,.81667],82:[0,.68333,0,.08334,.8475],83:[0,.68333,.075,.13889,.60556],84:[0,.68333,.25417,0,.54464],85:[0,.68333,.09931,.08334,.62583],86:[0,.68333,.08222,0,.61278],87:[0,.68333,.08222,.08334,.98778],88:[0,.68333,.14643,.13889,.7133],89:[.09722,.68333,.08222,.08334,.66834],90:[0,.68333,.07944,.13889,.72473],160:Xe},"Fraktur-Regular":{32:Xe,33:[0,.69141,0,0,.29574],34:Qi,38:[0,.69141,0,0,.73786],39:[0,.69141,0,0,.21201],40:_i,41:_i,42:[0,.62119,0,0,.27764],43:Ai,44:Ci,45:Ai,46:Ci,47:[.24982,.74947,0,0,.50181],48:Ni,49:Ni,50:Ni,51:$i,52:$i,53:$i,54:ui,55:$i,56:ui,57:$i,58:[0,.47534,0,0,.21606],59:[.12604,.47534,0,0,.21606],61:[-.13099,.36866,0,0,.75623],63:[0,.69141,0,0,.36245],65:[0,.69141,0,0,.7176],66:[0,.69141,0,0,.88397],67:[0,.69141,0,0,.61254],68:[0,.69141,0,0,.83158],69:[0,.69141,0,0,.66278],70:[.12604,.69141,0,0,.61119],71:[0,.69141,0,0,.78539],72:[.06302,.69141,0,0,.7203],73:[0,.69141,0,0,.55448],74:[.12604,.69141,0,0,.55231],75:[0,.69141,0,0,.66845],76:[0,.69141,0,0,.66602],77:[0,.69141,0,0,1.04953],78:[0,.69141,0,0,.83212],79:[0,.69141,0,0,.82699],80:[.18906,.69141,0,0,.82753],81:[.03781,.69141,0,0,.82699],82:[0,.69141,0,0,.82807],83:[0,.69141,0,0,.82861],84:[0,.69141,0,0,.66899],85:[0,.69141,0,0,.64576],86:[0,.69141,0,0,.83131],87:[0,.69141,0,0,1.04602],88:[0,.69141,0,0,.71922],89:[.18906,.69141,0,0,.83293],90:[.12604,.69141,0,0,.60201],91:Ii,93:Ii,94:[0,.69141,0,0,.49965],97:[0,.47534,0,0,.50046],98:[0,.69141,0,0,.51315],99:[0,.47534,0,0,.38946],100:[0,.62119,0,0,.49857],101:[0,.47534,0,0,.40053],102:[.18906,.69141,0,0,.32626],103:[.18906,.47534,0,0,.5037],104:[.18906,.69141,0,0,.52126],105:[0,.69141,0,0,.27899],106:[0,.69141,0,0,.28088],107:[0,.69141,0,0,.38946],108:[0,.69141,0,0,.27953],109:[0,.47534,0,0,.76676],110:[0,.47534,0,0,.52666],111:[0,.47534,0,0,.48885],112:[.18906,.52396,0,0,.50046],113:[.18906,.47534,0,0,.48912],114:[0,.47534,0,0,.38919],115:[0,.47534,0,0,.44266],116:[0,.62119,0,0,.33301],117:[0,.47534,0,0,.5172],118:[0,.52396,0,0,.5118],119:[0,.52396,0,0,.77351],120:[.18906,.47534,0,0,.38865],121:[.18906,.47534,0,0,.49884],122:[.18906,.47534,0,0,.39054],160:Xe,8216:Qi,8217:Qi,58112:[0,.62119,0,0,.49749],58113:[0,.62119,0,0,.4983],58114:[.18906,.69141,0,0,.33328],58115:[.18906,.69141,0,0,.32923],58116:[.18906,.47534,0,0,.50343],58117:[0,.69141,0,0,.33301],58118:[0,.62119,0,0,.33409],58119:[0,.47534,0,0,.50073]},"Main-Bold":{32:Xe,33:[0,.69444,0,0,.35],34:Mr,35:[.19444,.69444,0,0,.95833],36:xr,37:[.05556,.75,0,0,.95833],38:Ki,39:Cn,40:Fi,41:Fi,42:[0,.75,0,0,.575],43:Ln,44:[.19444,.15556,0,0,.31944],45:Mh,46:[0,.15556,0,0,.31944],47:tn,48:wi,49:wi,50:wi,51:wi,52:wi,53:wi,54:wi,55:wi,56:wi,57:wi,58:bn,59:[.19444,.44444,0,0,.31944],60:ji,61:pr,62:ji,63:[0,.69444,0,0,.54305],64:Ki,65:Pn,66:[0,.68611,0,0,.81805],67:pn,68:[0,.68611,0,0,.88194],69:Do,70:[0,.68611,0,0,.72361],71:[0,.68611,0,0,.90416],72:en,73:[0,.68611,0,0,.43611],74:[0,.68611,0,0,.59444],75:[0,.68611,0,0,.90138],76:xn,77:[0,.68611,0,0,1.09166],78:en,79:[0,.68611,0,0,.86388],80:[0,.68611,0,0,.78611],81:[.19444,.68611,0,0,.86388],82:[0,.68611,0,0,.8625],83:[0,.68611,0,0,.63889],84:[0,.68611,0,0,.8],85:[0,.68611,0,0,.88472],86:[0,.68611,.01597,0,.86944],87:[0,.68611,.01597,0,1.18888],88:Pn,89:[0,.68611,.02875,0,.86944],90:[0,.68611,0,0,.70277],91:er,92:tn,93:er,94:zi,95:[.31,.13444,.03194,0,.575],97:[0,.44444,0,0,.55902],98:cn,99:Ui,100:cn,101:[0,.44444,0,0,.52708],102:[0,.69444,.10903,0,.35139],103:[.19444,.44444,.01597,0,.575],104:cn,105:Cn,106:[.19444,.69444,0,0,.35139],107:[0,.69444,0,0,.60694],108:Cn,109:[0,.44444,0,0,.95833],110:tr,111:aa,112:[.19444,.44444,0,0,.63889],113:[.19444,.44444,0,0,.60694],114:[0,.44444,0,0,.47361],115:[0,.44444,0,0,.45361],116:[0,.63492,0,0,.44722],117:tr,118:[0,.44444,.01597,0,.60694],119:[0,.44444,.01597,0,.83055],120:[0,.44444,0,0,.60694],121:[.19444,.44444,.01597,0,.60694],122:Ui,123:tn,124:er,125:tn,126:[.35,.34444,0,0,.575],160:Xe,163:[0,.69444,0,0,.86853],168:zi,172:[0,.44444,0,0,.76666],176:rn,177:Ln,184:[.17014,0,0,0,.51111],198:[0,.68611,0,0,1.04166],215:Ln,216:[.04861,.73472,0,0,.89444],223:Ch,230:[0,.44444,0,0,.83055],247:Ln,248:[.09722,.54167,0,0,.575],305:bn,338:[0,.68611,0,0,1.16944],339:Nr,567:[.19444,.44444,0,0,.35139],710:zi,711:[0,.63194,0,0,.575],713:[0,.59611,0,0,.575],714:zi,715:zi,728:zi,729:Cn,730:rn,732:zi,733:zi,915:xn,916:Mn,920:Vn,923:vr,926:Yl,928:en,931:pn,933:Vn,934:pn,936:Vn,937:pn,8211:[0,.44444,.03194,0,.575],8212:[0,.44444,.03194,0,1.14999],8216:Cn,8217:Cn,8220:Mr,8221:Mr,8224:On,8225:On,8242:[0,.55556,0,0,.34444],8407:[0,.72444,.15486,0,.575],8463:Ea,8465:Br,8467:[0,.69444,0,0,.47361],8472:[.19444,.44444,0,0,.74027],8476:Br,8501:Hi,8592:En,8593:sr,8594:En,8595:sr,8596:En,8597:tn,8598:Rr,8599:Rr,8600:Rr,8601:Rr,8636:En,8637:En,8640:En,8641:En,8656:En,8657:Tr,8658:En,8659:Tr,8660:En,8661:[.25,.75,0,0,.70277],8704:cn,8706:[0,.69444,.06389,0,.62847],8707:cn,8709:xr,8711:Mn,8712:cr,8715:cr,8722:Ln,8723:Ln,8725:tn,8726:tn,8727:vi,8728:wr,8729:wr,8730:[.18,.82,0,0,.95833],8733:Nr,8734:[0,.44444,0,0,1.14999],8736:oi,8739:er,8741:tn,8743:kn,8744:kn,8745:kn,8746:kn,8747:[.19444,.69444,.12778,0,.56875],8764:pr,8768:[.19444,.69444,0,0,.31944],8771:Gn,8776:[.02444,.52444,0,0,.89444],8781:Gn,8801:Gn,8804:hr,8805:hr,8810:Wr,8811:Wr,8826:ji,8827:ji,8834:ji,8835:ji,8838:hr,8839:hr,8846:kn,8849:hr,8850:hr,8851:kn,8852:kn,8853:Ln,8854:Ln,8855:Ln,8856:Ln,8857:Ln,8866:Hi,8867:Hi,8868:Ki,8869:Ki,8900:wr,8901:[-.02639,.47361,0,0,.31944],8902:vi,8968:Wt,8969:Wt,8970:Wt,8971:Wt,8994:_n,8995:_n,9651:mr,9657:vi,9661:mr,9667:vi,9711:Rr,9824:Nn,9825:Nn,9826:Nn,9827:Nn,9837:[0,.75,0,0,.44722],9838:ar,9839:ar,10216:Fi,10217:Fi,10815:en,10927:hr,10928:hr,57376:Sa},"Main-BoldItalic":{32:Xe,33:[0,.69444,.11417,0,.38611],34:Kn,35:[.19444,.69444,.06833,0,.94444],37:[.05556,.75,.12861,0,.94444],38:[0,.69444,.08528,0,.88555],39:or,40:[.25,.75,.15806,0,.47333],41:[.25,.75,.03306,0,.47333],42:[0,.75,.14333,0,.59111],43:[.10333,.60333,.03306,0,.88555],44:[.19444,.14722,0,0,.35555],45:[0,.44444,.02611,0,.41444],46:[0,.14722,0,0,.35555],47:[.25,.75,.15806,0,.59111],48:$n,49:$n,50:$n,51:$n,52:cs,53:$n,54:$n,55:cs,56:$n,57:$n,58:[0,.44444,.06695,0,.35555],59:[.19444,.44444,.06695,0,.35555],61:[-.10889,.39111,.06833,0,.88555],63:ys,64:[0,.69444,.09208,0,.88555],65:[0,.68611,0,0,.86555],66:[0,.68611,.0992,0,.81666],67:[0,.68611,.14208,0,.82666],68:[0,.68611,.09062,0,.87555],69:[0,.68611,.11431,0,.75666],70:[0,.68611,.12903,0,.72722],71:[0,.68611,.07347,0,.89527],72:Sr,73:[0,.68611,.15681,0,.47166],74:[0,.68611,.145,0,.61055],75:[0,.68611,.14208,0,.89499],76:[0,.68611,0,0,.69777],77:[0,.68611,.17208,0,1.07277],78:Sr,79:[0,.68611,.09062,0,.85499],80:[0,.68611,.0992,0,.78721],81:[.19444,.68611,.09062,0,.85499],82:[0,.68611,.02559,0,.85944],83:[0,.68611,.11264,0,.64999],84:[0,.68611,.12903,0,.7961],85:[0,.68611,.17208,0,.88083],86:[0,.68611,.18625,0,.86555],87:[0,.68611,.18625,0,1.15999],88:[0,.68611,.15681,0,.86555],89:[0,.68611,.19803,0,.86555],90:[0,.68611,.14208,0,.70888],91:[.25,.75,.1875,0,.35611],93:[.25,.75,.09972,0,.35611],94:ns,95:[.31,.13444,.09811,0,.59111],97:[0,.44444,.09426,0,.59111],98:[0,.69444,.07861,0,.53222],99:[0,.44444,.05222,0,.53222],100:[0,.69444,.10861,0,.59111],101:[0,.44444,.085,0,.53222],102:[.19444,.69444,.21778,0,.4],103:vn,104:[0,.69444,.09426,0,.59111],105:[0,.69326,.11387,0,.35555],106:[.19444,.69326,.1672,0,.35555],107:[0,.69444,.11111,0,.53222],108:[0,.69444,.10861,0,.29666],109:[0,.44444,.09426,0,.94444],110:[0,.44444,.09426,0,.64999],111:[0,.44444,.07861,0,.59111],112:[.19444,.44444,.07861,0,.59111],113:vn,114:[0,.44444,.11111,0,.50167],115:[0,.44444,.08167,0,.48694],116:[0,.63492,.09639,0,.385],117:[0,.44444,.09426,0,.62055],118:[0,.44444,.11111,0,.53222],119:[0,.44444,.11111,0,.76777],120:[0,.44444,.12583,0,.56055],121:[.19444,.44444,.105,0,.56166],122:[0,.44444,.13889,0,.49055],126:[.35,.34444,.11472,0,.59111],160:Xe,168:[0,.69444,.11473,0,.59111],176:jr,184:[.17014,0,0,0,.53222],198:[0,.68611,.11431,0,1.02277],216:[.04861,.73472,.09062,0,.88555],223:[.19444,.69444,.09736,0,.665],230:hs,248:[.09722,.54167,.09458,0,.59111],305:[0,.44444,.09426,0,.35555],338:[0,.68611,.11431,0,1.14054],339:hs,567:[.19444,.44444,.04611,0,.385],710:ns,711:[0,.63194,.08271,0,.59111],713:[0,.59444,.10444,0,.59111],714:[0,.69444,.08528,0,.59111],715:[0,.69444,0,0,.59111],728:[0,.69444,.10333,0,.59111],729:or,730:jr,732:ys,733:ys,915:[0,.68611,.12903,0,.69777],916:[0,.68611,0,0,.94444],920:[0,.68611,.09062,0,.88555],923:[0,.68611,0,0,.80666],926:[0,.68611,.15092,0,.76777],928:Sr,931:[0,.68611,.11431,0,.82666],933:_r,934:[0,.68611,.05632,0,.82666],936:_r,937:[0,.68611,.0992,0,.82666],8211:[0,.44444,.09811,0,.59111],8212:[0,.44444,.09811,0,1.18221],8216:or,8217:or,8220:[0,.69444,.16772,0,.62055],8221:Kn},"Main-Italic":{32:Xe,33:fr,34:Hn,35:[.19444,.69444,.06616,0,.81777],37:[.05556,.75,.13639,0,.81777],38:[0,.69444,.09694,0,.76666],39:fr,40:[.25,.75,.16194,0,.40889],41:[.25,.75,.03694,0,.40889],42:[0,.75,.14917,0,.51111],43:[.05667,.56167,.03694,0,.76666],44:[.19444,.10556,0,0,.30667],45:[0,.43056,.02826,0,.35778],46:[0,.10556,0,0,.30667],47:[.25,.75,.16194,0,.51111],48:Xn,49:Xn,50:Xn,51:Xn,52:rs,53:Xn,54:Xn,55:rs,56:Xn,57:Xn,58:[0,.43056,.0582,0,.30667],59:[.19444,.43056,.0582,0,.30667],61:[-.13313,.36687,.06616,0,.76666],63:ri,64:[0,.69444,.09597,0,.76666],65:[0,.68333,0,0,.74333],66:[0,.68333,.10257,0,.70389],67:[0,.68333,.14528,0,.71555],68:[0,.68333,.09403,0,.755],69:[0,.68333,.12028,0,.67833],70:[0,.68333,.13305,0,.65277],71:[0,.68333,.08722,0,.77361],72:ss,73:[0,.68333,.15806,0,.38555],74:[0,.68333,.14028,0,.525],75:[0,.68333,.14528,0,.76888],76:[0,.68333,0,0,.62722],77:[0,.68333,.16389,0,.89666],78:ss,79:Jt,80:[0,.68333,.10257,0,.67833],81:[.19444,.68333,.09403,0,.76666],82:[0,.68333,.03868,0,.72944],83:[0,.68333,.11972,0,.56222],84:[0,.68333,.13305,0,.71555],85:ss,86:[0,.68333,.18361,0,.74333],87:[0,.68333,.18361,0,.99888],88:[0,.68333,.15806,0,.74333],89:[0,.68333,.19383,0,.74333],90:[0,.68333,.14528,0,.61333],91:[.25,.75,.1875,0,.30667],93:[.25,.75,.10528,0,.30667],94:Os,95:[.31,.12056,.09208,0,.51111],97:[0,.43056,.07671,0,.51111],98:[0,.69444,.06312,0,.46],99:[0,.43056,.05653,0,.46],100:[0,.69444,.10333,0,.51111],101:[0,.43056,.07514,0,.46],102:[.19444,.69444,.21194,0,.30667],103:Ps,104:[0,.69444,.07671,0,.51111],105:[0,.65536,.1019,0,.30667],106:[.19444,.65536,.14467,0,.30667],107:[0,.69444,.10764,0,.46],108:[0,.69444,.10333,0,.25555],109:[0,.43056,.07671,0,.81777],110:[0,.43056,.07671,0,.56222],111:[0,.43056,.06312,0,.51111],112:[.19444,.43056,.06312,0,.51111],113:Ps,114:[0,.43056,.10764,0,.42166],115:[0,.43056,.08208,0,.40889],116:[0,.61508,.09486,0,.33222],117:[0,.43056,.07671,0,.53666],118:[0,.43056,.10764,0,.46],119:[0,.43056,.10764,0,.66444],120:[0,.43056,.12042,0,.46389],121:[.19444,.43056,.08847,0,.48555],122:[0,.43056,.12292,0,.40889],126:[.35,.31786,.11585,0,.51111],160:Xe,168:[0,.66786,.10474,0,.51111],176:ba,184:[.17014,0,0,0,.46],198:[0,.68333,.12028,0,.88277],216:[.04861,.73194,.09403,0,.76666],223:[.19444,.69444,.10514,0,.53666],230:ya,248:[.09722,.52778,.09194,0,.51111],338:[0,.68333,.12028,0,.98499],339:ya,710:Os,711:[0,.62847,.08295,0,.51111],713:[0,.56167,.10333,0,.51111],714:[0,.69444,.09694,0,.51111],715:[0,.69444,0,0,.51111],728:[0,.69444,.10806,0,.51111],729:[0,.66786,.11752,0,.30667],730:ba,732:[0,.66786,.11585,0,.51111],733:ri,915:[0,.68333,.13305,0,.62722],916:[0,.68333,0,0,.81777],920:Jt,923:[0,.68333,0,0,.69222],926:[0,.68333,.15294,0,.66444],928:ss,931:[0,.68333,.12028,0,.71555],933:Wi,934:[0,.68333,.05986,0,.71555],936:Wi,937:[0,.68333,.10257,0,.71555],8211:[0,.43056,.09208,0,.51111],8212:[0,.43056,.09208,0,1.02222],8216:fr,8217:fr,8220:[0,.69444,.1685,0,.51444],8221:Hn,8463:ye},"Main-Regular":{32:Xe,33:mn,34:nr,35:Th,36:ja,37:iu,38:Ts,39:mn,40:$r,41:$r,42:Ah,43:ls,44:[.19444,.10556,0,0,.27778],45:[0,.43056,0,0,.33333],46:[0,.10556,0,0,.27778],47:as,48:ir,49:ir,50:ir,51:ir,52:ir,53:ir,54:ir,55:ir,56:ir,57:ir,58:il,59:[.19444,.43056,0,0,.27778],60:fn,61:ki,62:fn,63:gc,64:Ts,65:fs,66:[0,.68333,0,0,.70834],67:Ws,68:[0,.68333,0,0,.76389],69:ql,70:[0,.68333,0,0,.65278],71:[0,.68333,0,0,.78472],72:fs,73:[0,.68333,0,0,.36111],74:[0,.68333,0,0,.51389],75:xa,76:sl,77:[0,.68333,0,0,.91667],78:fs,79:xa,80:ql,81:[.19444,.68333,0,0,.77778],82:[0,.68333,0,0,.73611],83:[0,.68333,0,0,.55556],84:Ws,85:fs,86:[0,.68333,.01389,0,.75],87:[0,.68333,.01389,0,1.02778],88:fs,89:[0,.68333,.025,0,.75],90:[0,.68333,0,0,.61111],91:Ha,92:as,93:Ha,94:nr,95:[.31,.12056,.02778,0,.5],97:os,98:na,99:Wa,100:na,101:Wa,102:[0,.69444,.07778,0,.30556],103:[.19444,.43056,.01389,0,.5],104:na,105:nl,106:[.19444,.66786,0,0,.30556],107:[0,.69444,0,0,.52778],108:mn,109:[0,.43056,0,0,.83334],110:ds,111:os,112:tl,113:[.19444,.43056,0,0,.52778],114:[0,.43056,0,0,.39167],115:[0,.43056,0,0,.39445],116:[0,.61508,0,0,.38889],117:ds,118:[0,.43056,.01389,0,.52778],119:[0,.43056,.01389,0,.72222],120:[0,.43056,0,0,.52778],121:[.19444,.43056,.01389,0,.52778],122:Wa,123:as,124:Ha,125:as,126:[.35,.31786,0,0,.5],160:Xe,163:[0,.69444,0,0,.76909],167:al,168:rl,172:[0,.43056,0,0,.66667],176:Eo,177:ls,182:To,184:dc,198:[0,.68333,0,0,.90278],215:ls,216:[.04861,.73194,0,0,.77778],223:nr,230:[0,.43056,0,0,.72222],247:ls,248:[.09722,.52778,0,0,.5],305:il,338:[0,.68333,0,0,1.01389],339:Zl,567:[.19444,.43056,0,0,.30556],710:nr,711:[0,.62847,0,0,.5],713:[0,.56778,0,0,.5],714:nr,715:nr,728:nr,729:nl,730:Eo,732:rl,733:nr,915:sl,916:ol,920:xa,923:[0,.68333,0,0,.69445],926:[0,.68333,0,0,.66667],928:fs,931:Ws,933:xa,934:Ws,936:xa,937:Ws,8211:[0,.43056,.02778,0,.5],8212:[0,.43056,.02778,0,1],8216:mn,8217:mn,8220:nr,8221:nr,8224:al,8225:al,8230:[0,.12,0,0,1.172],8242:[0,.55556,0,0,.275],8407:[0,.71444,.15382,0,.5],8463:ye,8465:ra,8467:[0,.69444,0,.11111,.41667],8472:[.19444,.43056,0,.11111,.63646],8476:ra,8501:Fs,8592:K,8593:ko,8594:K,8595:ko,8596:K,8597:as,8598:As,8599:As,8600:As,8601:As,8614:[.011,.511,0,0,1],8617:ps,8618:ps,8636:K,8637:K,8640:K,8641:K,8652:[.011,.671,0,0,1],8656:K,8657:To,8658:K,8659:To,8660:K,8661:[.25,.75,0,0,.61111],8704:na,8706:[0,.69444,.05556,.08334,.5309],8707:na,8709:ja,8711:ol,8712:ll,8715:ll,8722:ls,8723:ls,8725:as,8726:as,8727:Za,8728:wa,8729:wa,8730:[.2,.8,0,0,.83334],8733:Zl,8734:st,8736:oi,8739:Ha,8741:as,8743:sa,8744:sa,8745:sa,8746:sa,8747:[.19444,.69444,.11111,0,.41667],8764:ki,8768:[.19444,.69444,0,0,.27778],8771:qa,8773:[-.022,.589,0,0,1],8776:Ao,8781:qa,8784:[-.133,.67,0,0,.778],8801:qa,8804:Oi,8805:Oi,8810:Lo,8811:Lo,8826:fn,8827:fn,8834:fn,8835:fn,8838:Oi,8839:Oi,8846:sa,8849:Oi,8850:Oi,8851:sa,8852:sa,8853:ls,8854:ls,8855:ls,8856:ls,8857:ls,8866:Fs,8867:Fs,8868:Ts,8869:Ts,8872:[.249,.75,0,0,.867],8900:wa,8901:[-.05555,.44445,0,0,.27778],8902:Za,8904:[.005,.505,0,0,.9],8942:[.03,.9,0,0,.278],8943:[-.19,.31,0,0,1.172],8945:[-.1,.82,0,0,1.282],8968:Ya,8969:Ya,8970:Ya,8971:Ya,8994:ul,8995:ul,9136:Wn,9137:Wn,9651:Rn,9657:Za,9661:Rn,9667:Za,9711:As,9824:Fn,9825:Fn,9826:Fn,9827:Fn,9837:[0,.75,0,0,.38889],9838:Ar,9839:Ar,10216:$r,10217:$r,10222:Wn,10223:Wn,10229:[.011,.511,0,0,1.609],10230:Xr,10231:[.011,.511,0,0,1.859],10232:[.024,.525,0,0,1.609],10233:[.024,.525,0,0,1.638],10234:[.024,.525,0,0,1.858],10236:Xr,10815:fs,10927:Oi,10928:Oi,57376:Sa},"Math-BoldItalic":{32:Xe,48:aa,49:aa,50:aa,51:Xa,52:Xa,53:Xa,54:wi,55:Xa,56:wi,57:Xa,65:Pn,66:[0,.68611,.04835,0,.8664],67:[0,.68611,.06979,0,.81694],68:[0,.68611,.03194,0,.93812],69:[0,.68611,.05451,0,.81007],70:[0,.68611,.15972,0,.68889],71:[0,.68611,0,0,.88673],72:Ir,73:[0,.68611,.07778,0,.51111],74:[0,.68611,.10069,0,.63125],75:[0,.68611,.06979,0,.97118],76:Do,77:[0,.68611,.11424,0,1.14201],78:[0,.68611,.11424,0,.95034],79:[0,.68611,.03194,0,.83666],80:[0,.68611,.15972,0,.72309],81:[.19444,.68611,0,0,.86861],82:[0,.68611,.00421,0,.87235],83:[0,.68611,.05382,0,.69271],84:[0,.68611,.15972,0,.63663],85:[0,.68611,.11424,0,.80027],86:[0,.68611,.25555,0,.67778],87:[0,.68611,.15972,0,1.09305],88:[0,.68611,.07778,0,.94722],89:[0,.68611,.25555,0,.67458],90:[0,.68611,.06979,0,.77257],97:[0,.44444,0,0,.63287],98:[0,.69444,0,0,.52083],99:[0,.44444,0,0,.51342],100:[0,.69444,0,0,.60972],101:[0,.44444,0,0,.55361],102:[.19444,.69444,.11042,0,.56806],103:[.19444,.44444,.03704,0,.5449],104:Ea,105:[0,.69326,0,0,.4048],106:[.19444,.69326,.0622,0,.47083],107:[0,.69444,.01852,0,.6037],108:[0,.69444,.0088,0,.34815],109:[0,.44444,0,0,1.0324],110:[0,.44444,0,0,.71296],111:mt,112:[.19444,.44444,0,0,.60092],113:[.19444,.44444,.03704,0,.54213],114:[0,.44444,.03194,0,.5287],115:[0,.44444,0,0,.53125],116:[0,.63492,0,0,.41528],117:[0,.44444,0,0,.68102],118:[0,.44444,.03704,0,.56666],119:[0,.44444,.02778,0,.83148],120:[0,.44444,0,0,.65903],121:[.19444,.44444,.03704,0,.59028],122:[0,.44444,.04213,0,.55509],160:Xe,915:[0,.68611,.15972,0,.65694],916:Mn,920:[0,.68611,.03194,0,.86722],923:vr,926:[0,.68611,.07458,0,.84125],928:Ir,931:[0,.68611,.05451,0,.88507],933:[0,.68611,.15972,0,.67083],934:Yl,936:[0,.68611,.11653,0,.71402],937:[0,.68611,.04835,0,.8789],945:[0,.44444,0,0,.76064],946:[.19444,.69444,.03403,0,.65972],947:[.19444,.44444,.06389,0,.59003],948:[0,.69444,.03819,0,.52222],949:[0,.44444,0,0,.52882],950:[.19444,.69444,.06215,0,.50833],951:[.19444,.44444,.03704,0,.6],952:[0,.69444,.03194,0,.5618],953:[0,.44444,0,0,.41204],954:[0,.44444,0,0,.66759],955:[0,.69444,0,0,.67083],956:[.19444,.44444,0,0,.70787],957:[0,.44444,.06898,0,.57685],958:[.19444,.69444,.03021,0,.50833],959:mt,960:[0,.44444,.03704,0,.68241],961:Xl,962:[.09722,.44444,.07917,0,.42361],963:[0,.44444,.03704,0,.68588],964:[0,.44444,.13472,0,.52083],965:[0,.44444,.03704,0,.63055],966:[.19444,.44444,0,0,.74722],967:[.19444,.44444,0,0,.71805],968:[.19444,.69444,.03704,0,.75833],969:[0,.44444,.03704,0,.71782],977:[0,.69444,0,0,.69155],981:[.19444,.69444,0,0,.7125],982:[0,.44444,.03194,0,.975],1009:Xl,1013:[0,.44444,0,0,.48333],57649:[0,.44444,0,0,.39352],57911:[.19444,.44444,0,0,.43889]},"Math-Italic":{32:Xe,48:os,49:os,50:os,51:Co,52:Co,53:Co,54:ir,55:Co,56:ir,57:Co,65:[0,.68333,0,.13889,.75],66:[0,.68333,.05017,.08334,.75851],67:[0,.68333,.07153,.08334,.71472],68:[0,.68333,.02778,.05556,.82792],69:[0,.68333,.05764,.08334,.7382],70:[0,.68333,.13889,.08334,.64306],71:[0,.68333,0,.08334,.78625],72:vh,73:[0,.68333,.07847,.11111,.43958],74:[0,.68333,.09618,.16667,.55451],75:[0,.68333,.07153,.05556,.84931],76:[0,.68333,0,.02778,.68056],77:[0,.68333,.10903,.08334,.97014],78:[0,.68333,.10903,.08334,.80347],79:oc,80:[0,.68333,.13889,.08334,.64201],81:[.19444,.68333,0,.08334,.79056],82:[0,.68333,.00773,.08334,.75929],83:[0,.68333,.05764,.08334,.6132],84:[0,.68333,.13889,.08334,.58438],85:[0,.68333,.10903,.02778,.68278],86:[0,.68333,.22222,0,.58333],87:[0,.68333,.13889,0,.94445],88:[0,.68333,.07847,.08334,.82847],89:[0,.68333,.22222,0,.58056],90:[0,.68333,.07153,.08334,.68264],97:[0,.43056,0,0,.52859],98:[0,.69444,0,0,.42917],99:[0,.43056,0,.05556,.43276],100:[0,.69444,0,.16667,.52049],101:[0,.43056,0,.05556,.46563],102:[.19444,.69444,.10764,.16667,.48959],103:[.19444,.43056,.03588,.02778,.47697],104:[0,.69444,0,0,.57616],105:[0,.65952,0,0,.34451],106:[.19444,.65952,.05724,0,.41181],107:[0,.69444,.03148,0,.5206],108:[0,.69444,.01968,.08334,.29838],109:[0,.43056,0,0,.87801],110:[0,.43056,0,0,.60023],111:Jl,112:[.19444,.43056,0,.08334,.50313],113:[.19444,.43056,.03588,.08334,.44641],114:[0,.43056,.02778,.05556,.45116],115:[0,.43056,0,.05556,.46875],116:[0,.61508,0,.08334,.36111],117:[0,.43056,0,.02778,.57246],118:[0,.43056,.03588,.02778,.48472],119:[0,.43056,.02691,.08334,.71592],120:[0,.43056,0,.02778,.57153],121:[.19444,.43056,.03588,.05556,.49028],122:[0,.43056,.04398,.05556,.46505],160:Xe,915:[0,.68333,.13889,.08334,.61528],916:[0,.68333,0,.16667,.83334],920:oc,923:[0,.68333,0,.16667,.69445],926:[0,.68333,.07569,.08334,.74236],928:vh,931:[0,.68333,.05764,.08334,.77986],933:[0,.68333,.13889,.05556,.58333],934:[0,.68333,0,.08334,.66667],936:[0,.68333,.11,.05556,.61222],937:[0,.68333,.05017,.08334,.7724],945:[0,.43056,.0037,.02778,.6397],946:[.19444,.69444,.05278,.08334,.56563],947:[.19444,.43056,.05556,0,.51773],948:[0,.69444,.03785,.05556,.44444],949:[0,.43056,0,.08334,.46632],950:[.19444,.69444,.07378,.08334,.4375],951:[.19444,.43056,.03588,.05556,.49653],952:[0,.69444,.02778,.08334,.46944],953:[0,.43056,0,.05556,.35394],954:[0,.43056,0,0,.57616],955:[0,.69444,0,0,.58334],956:[.19444,.43056,0,.02778,.60255],957:[0,.43056,.06366,.02778,.49398],958:[.19444,.69444,.04601,.11111,.4375],959:Jl,960:[0,.43056,.03588,0,.57003],961:lc,962:[.09722,.43056,.07986,.08334,.36285],963:[0,.43056,.03588,0,.57141],964:[0,.43056,.1132,.02778,.43715],965:[0,.43056,.03588,.02778,.54028],966:[.19444,.43056,0,.08334,.65417],967:[.19444,.43056,0,.05556,.62569],968:[.19444,.69444,.03588,.11111,.65139],969:[0,.43056,.03588,0,.62245],977:[0,.69444,0,.08334,.59144],981:[.19444,.69444,0,.08334,.59583],982:[0,.43056,.02778,0,.82813],1009:lc,1013:[0,.43056,0,.05556,.4059],57649:[0,.43056,0,.02778,.32246],57911:[.19444,.43056,0,.08334,.38403]},"SansSerif-Bold":{32:Xe,33:[0,.69444,0,0,.36667],34:hl,35:[.19444,.69444,0,0,.91667],36:[.05556,.75,0,0,.55],37:[.05556,.75,0,0,1.02912],38:[0,.69444,0,0,.83056],39:ka,40:yh,41:yh,42:[0,.75,0,0,.55],43:[.11667,.61667,0,0,.85556],44:[.10556,.13056,0,0,.30556],45:[0,.45833,0,0,.36667],46:[0,.13056,0,0,.30556],47:[.25,.75,0,0,.55],48:qr,49:qr,50:qr,51:qr,52:qr,53:qr,54:qr,55:qr,56:qr,57:qr,58:[0,.45833,0,0,.30556],59:[.10556,.45833,0,0,.30556],61:[-.09375,.40625,0,0,.85556],63:Ja,64:Bs,65:Bs,66:Bs,67:uc,68:Ls,69:[0,.69444,0,0,.64167],70:Fs,71:Bs,72:Ls,73:[0,.69444,0,0,.33056],74:Ja,75:bh,76:wh,77:[0,.69444,0,0,.97778],78:Ls,79:Ls,80:uc,81:[.10556,.69444,0,0,.79445],82:uc,83:Fs,84:Bs,85:bh,86:[0,.69444,.01528,0,.73334],87:[0,.69444,.01528,0,1.03889],88:Bs,89:[0,.69444,.0275,0,.73334],90:fc,91:xh,93:xh,94:qr,95:[.35,.10833,.03056,0,.55],97:[0,.45833,0,0,.525],98:cc,99:[0,.45833,0,0,.48889],100:cc,101:[0,.45833,0,0,.51111],102:[0,.69444,.07639,0,.33611],103:[.19444,.45833,.01528,0,.55],104:cc,105:hc,106:[.19444,.69444,0,0,.28611],107:[0,.69444,0,0,.53056],108:hc,109:[0,.45833,0,0,.86667],110:cl,111:[0,.45833,0,0,.55],112:Ql,113:Ql,114:[0,.45833,.01528,0,.37222],115:[0,.45833,0,0,.42167],116:[0,.58929,0,0,.40417],117:cl,118:[0,.45833,.01528,0,.5],119:[0,.45833,.01528,0,.74445],120:[0,.45833,0,0,.5],121:[.19444,.45833,.01528,0,.5],122:[0,.45833,0,0,.47639],126:[.35,.34444,0,0,.55],160:Xe,168:qr,176:Bs,180:qr,184:[.17014,0,0,0,.48889],305:[0,.45833,0,0,.25556],567:[.19444,.45833,0,0,.28611],710:qr,711:[0,.63542,0,0,.55],713:[0,.63778,0,0,.55],728:qr,729:ka,730:Bs,732:qr,733:qr,915:wh,916:[0,.69444,0,0,.91667],920:eu,923:fc,926:Bs,928:Ls,931:Ls,933:eu,934:Ls,936:eu,937:Ls,8211:[0,.45833,.03056,0,.55],8212:[0,.45833,.03056,0,1.10001],8216:ka,8217:ka,8220:hl,8221:hl},"SansSerif-Italic":{32:Xe,33:[0,.69444,.05733,0,.31945],34:kh,35:[.19444,.69444,.05087,0,.83334],36:[.05556,.75,.11156,0,.5],37:[.05556,.75,.03126,0,.83334],38:[0,.69444,.03058,0,.75834],39:tu,40:[.25,.75,.13164,0,.38889],41:[.25,.75,.02536,0,.38889],42:[0,.75,.11775,0,.5],43:[.08333,.58333,.02536,0,.77778],44:Lh,45:[0,.44444,.01946,0,.33333],46:Dh,47:[.25,.75,.13164,0,.5],48:js,49:js,50:js,51:js,52:js,53:js,54:js,55:js,56:js,57:js,58:[0,.44444,.02502,0,.27778],59:[.125,.44444,.02502,0,.27778],61:[-.13,.37,.05087,0,.77778],63:[0,.69444,.11809,0,.47222],64:[0,.69444,.07555,0,.66667],65:oa,66:[0,.69444,.08293,0,.66667],67:[0,.69444,.11983,0,.63889],68:[0,.69444,.07555,0,.72223],69:[0,.69444,.11983,0,.59722],70:[0,.69444,.13372,0,.56945],71:[0,.69444,.11983,0,.66667],72:Mo,73:[0,.69444,.13372,0,.27778],74:[0,.69444,.08094,0,.47222],75:[0,.69444,.11983,0,.69445],76:_c,77:[0,.69444,.08094,0,.875],78:Mo,79:[0,.69444,.07555,0,.73611],80:[0,.69444,.08293,0,.63889],81:[.125,.69444,.07555,0,.73611],82:[0,.69444,.08293,0,.64584],83:[0,.69444,.09205,0,.55556],84:[0,.69444,.13372,0,.68056],85:[0,.69444,.08094,0,.6875],86:[0,.69444,.1615,0,.66667],87:[0,.69444,.1615,0,.94445],88:[0,.69444,.13372,0,.66667],89:[0,.69444,.17261,0,.66667],90:[0,.69444,.11983,0,.61111],91:[.25,.75,.15942,0,.28889],93:[.25,.75,.08719,0,.28889],94:Sh,95:[.35,.09444,.08616,0,.5],97:[0,.44444,.00981,0,.48056],98:[0,.69444,.03057,0,.51667],99:[0,.44444,.08336,0,.44445],100:[0,.69444,.09483,0,.51667],101:[0,.44444,.06778,0,.44445],102:[0,.69444,.21705,0,.30556],103:[.19444,.44444,.10836,0,.5],104:[0,.69444,.01778,0,.51667],105:[0,.67937,.09718,0,.23889],106:[.19444,.67937,.09162,0,.26667],107:[0,.69444,.08336,0,.48889],108:[0,.69444,.09483,0,.23889],109:[0,.44444,.01778,0,.79445],110:[0,.44444,.01778,0,.51667],111:[0,.44444,.06613,0,.5],112:[.19444,.44444,.0389,0,.51667],113:[.19444,.44444,.04169,0,.51667],114:[0,.44444,.10836,0,.34167],115:[0,.44444,.0778,0,.38333],116:[0,.57143,.07225,0,.36111],117:[0,.44444,.04169,0,.51667],118:[0,.44444,.10836,0,.46111],119:[0,.44444,.10836,0,.68334],120:[0,.44444,.09169,0,.46111],121:[.19444,.44444,.10836,0,.46111],122:[0,.44444,.08752,0,.43472],126:[.35,.32659,.08826,0,.5],160:Xe,168:[0,.67937,.06385,0,.5],176:pc,184:dc,305:[0,.44444,.04169,0,.23889],567:[.19444,.44444,.04169,0,.26667],710:Sh,711:[0,.63194,.08432,0,.5],713:[0,.60889,.08776,0,.5],714:mc,715:nr,728:[0,.69444,.09483,0,.5],729:[0,.67937,.07774,0,.27778],730:pc,732:[0,.67659,.08826,0,.5],733:mc,915:[0,.69444,.13372,0,.54167],916:ms,920:[0,.69444,.07555,0,.77778],923:Fs,926:[0,.69444,.12816,0,.66667],928:Mo,931:[0,.69444,.11983,0,.72222],933:Eh,934:[0,.69444,.04603,0,.72222],936:Eh,937:[0,.69444,.08293,0,.72222],8211:[0,.44444,.08616,0,.5],8212:[0,.44444,.08616,0,1],8216:tu,8217:tu,8220:[0,.69444,.14205,0,.5],8221:kh},"SansSerif-Regular":{32:Xe,33:[0,.69444,0,0,.31945],34:nr,35:Th,36:ja,37:iu,38:[0,.69444,0,0,.75834],39:mn,40:$r,41:$r,42:Ah,43:ls,44:Lh,45:[0,.44444,0,0,.33333],46:Dh,47:as,48:qs,49:qs,50:qs,51:qs,52:qs,53:qs,54:qs,55:qs,56:qs,57:qs,58:[0,.44444,0,0,.27778],59:[.125,.44444,0,0,.27778],61:[-.13,.37,0,0,.77778],63:gc,64:oa,65:oa,66:oa,67:cn,68:[0,.69444,0,0,.72223],69:Ch,70:[0,.69444,0,0,.56945],71:oa,72:vc,73:mn,74:gc,75:[0,.69444,0,0,.69445],76:_c,77:[0,.69444,0,0,.875],78:vc,79:[0,.69444,0,0,.73611],80:cn,81:[.125,.69444,0,0,.73611],82:[0,.69444,0,0,.64584],83:na,84:[0,.69444,0,0,.68056],85:[0,.69444,0,0,.6875],86:[0,.69444,.01389,0,.66667],87:[0,.69444,.01389,0,.94445],88:oa,89:[0,.69444,.025,0,.66667],90:Fs,91:fl,93:fl,94:nr,95:[.35,.09444,.02778,0,.5],97:[0,.44444,0,0,.48056],98:yc,99:bc,100:yc,101:bc,102:[0,.69444,.06944,0,.30556],103:[.19444,.44444,.01389,0,.5],104:yc,105:[0,.67937,0,0,.23889],106:[.19444,.67937,0,0,.26667],107:[0,.69444,0,0,.48889],108:[0,.69444,0,0,.23889],109:[0,.44444,0,0,.79445],110:nu,111:[0,.44444,0,0,.5],112:xc,113:xc,114:[0,.44444,.01389,0,.34167],115:Mh,116:[0,.57143,0,0,.36111],117:nu,118:[0,.44444,.01389,0,.46111],119:[0,.44444,.01389,0,.68334],120:[0,.44444,0,0,.46111],121:[.19444,.44444,.01389,0,.46111],122:[0,.44444,0,0,.43472],126:[.35,.32659,0,0,.5],160:Xe,168:[0,.67937,0,0,.5],176:oa,184:dc,305:[0,.44444,0,0,.23889],567:[.19444,.44444,0,0,.26667],710:nr,711:[0,.63194,0,0,.5],713:[0,.60889,0,0,.5],714:nr,715:nr,728:nr,729:[0,.67937,0,0,.27778],730:oa,732:[0,.67659,0,0,.5],733:nr,915:_c,916:ms,920:Ts,923:Fs,926:oa,928:vc,931:ra,933:Ts,934:ra,936:Ts,937:ra,8211:[0,.44444,.02778,0,.5],8212:[0,.44444,.02778,0,1],8216:mn,8217:mn,8220:nr,8221:nr},"Script-Regular":{32:Xe,65:[0,.7,.22925,0,.80253],66:[0,.7,.04087,0,.90757],67:[0,.7,.1689,0,.66619],68:[0,.7,.09371,0,.77443],69:[0,.7,.18583,0,.56162],70:[0,.7,.13634,0,.89544],71:[0,.7,.17322,0,.60961],72:[0,.7,.29694,0,.96919],73:[0,.7,.19189,0,.80907],74:[.27778,.7,.19189,0,1.05159],75:[0,.7,.31259,0,.91364],76:[0,.7,.19189,0,.87373],77:[0,.7,.15981,0,1.08031],78:[0,.7,.3525,0,.9015],79:[0,.7,.08078,0,.73787],80:[0,.7,.08078,0,1.01262],81:[0,.7,.03305,0,.88282],82:[0,.7,.06259,0,.85],83:[0,.7,.19189,0,.86767],84:[0,.7,.29087,0,.74697],85:[0,.7,.25815,0,.79996],86:[0,.7,.27523,0,.62204],87:[0,.7,.27523,0,.80532],88:[0,.7,.26006,0,.94445],89:[0,.7,.2939,0,.70961],90:[0,.7,.24037,0,.8212],160:Xe},"Size1-Regular":{32:Xe,40:Ns,41:Ns,47:ru,91:Rh,92:ru,93:Rh,123:dl,125:dl,160:Xe,710:su,732:su,770:su,771:su,8214:[-99e-5,.601,0,0,.77778],8593:Ih,8595:Ih,8657:Ph,8659:Ph,8719:Oh,8720:Oh,8721:[.25001,.75,0,0,1.05556],8730:[.35001,.85,0,0,1],8739:[-.00599,.606,0,0,.33333],8741:[-.00599,.606,0,0,.55556],8747:Sc,8748:wc,8749:wc,8750:Sc,8896:Ta,8897:Ta,8898:Ta,8899:Ta,8968:Qa,8969:Qa,8970:Qa,8971:Qa,9168:ml,10216:Qa,10217:Qa,10752:Ec,10753:Ec,10754:Ec,10756:Ta,10758:Ta},"Size2-Regular":{32:Xe,40:kc,41:kc,47:Fh,91:Tc,92:Fh,93:Tc,123:Bh,125:Bh,160:Xe,710:pl,732:pl,770:pl,771:pl,8719:Nh,8720:Nh,8721:[.55001,1.05,0,0,1.44445],8730:[.65002,1.15,0,0,1],8747:Kh,8748:$h,8749:$h,8750:Kh,8896:eo,8897:eo,8898:eo,8899:eo,8968:au,8969:au,8970:au,8971:au,10216:Ac,10217:Ac,10752:to,10753:to,10754:to,10756:eo,10758:eo},"Size3-Regular":{32:Xe,40:Uh,41:Uh,47:zh,91:Pr,92:zh,93:Pr,123:$s,125:$s,160:Xe,710:Ro,732:Ro,770:Ro,771:Ro,8730:[.95003,1.45,0,0,1],8968:ou,8969:ou,8970:ou,8971:ou,10216:$s,10217:$s},"Size4-Regular":{32:Xe,40:Vh,41:Vh,47:lu,91:uu,92:lu,93:uu,123:la,125:la,160:Xe,710:cu,732:cu,770:cu,771:cu,8730:[1.25003,1.75,0,0,1],8968:Ks,8969:Ks,8970:Ks,8971:Ks,9115:Ke,9116:Lc,9117:Ke,9118:Ke,9119:Lc,9120:Ke,9121:hu,9122:ml,9123:hu,9124:hu,9125:ml,9126:hu,9127:Io,9128:Gh,9129:Hh,9130:[0,.3,0,0,.88889],9131:Io,9132:Gh,9133:Hh,9143:[.88502,.915,0,0,1.05556],10216:la,10217:la,57344:Wh,57345:Wh,57680:fu,57681:fu,57682:fu,57683:fu},"Typewriter-Regular":{32:jh,33:ii,34:ii,35:ii,36:Jr,37:Jr,38:ii,39:ii,40:Jr,41:Jr,42:[0,.52083,0,0,.525],43:du,44:[.13889,.125,0,0,.525],45:du,46:[0,.125,0,0,.525],47:Jr,48:ii,49:ii,50:ii,51:ii,52:ii,53:ii,54:ii,55:ii,56:ii,57:ii,58:Kr,59:[.13889,.43056,0,0,.525],60:Dc,61:[-.19549,.41562,0,0,.525],62:Dc,63:ii,64:ii,65:ii,66:ii,67:ii,68:ii,69:ii,70:ii,71:ii,72:ii,73:ii,74:ii,75:ii,76:ii,77:ii,78:ii,79:ii,80:ii,81:[.13889,.61111,0,0,.525],82:ii,83:ii,84:ii,85:ii,86:ii,87:ii,88:ii,89:ii,90:ii,91:Jr,92:Jr,93:Jr,94:ii,95:[.09514,0,0,0,.525],96:ii,97:Kr,98:ii,99:Kr,100:ii,101:Kr,102:ii,103:Qr,104:ii,105:ii,106:[.22222,.61111,0,0,.525],107:ii,108:ii,109:Kr,110:Kr,111:Kr,112:Qr,113:Qr,114:Kr,115:Kr,116:[0,.55358,0,0,.525],117:Kr,118:Kr,119:Kr,120:Kr,121:Qr,122:Kr,123:Jr,124:Jr,125:Jr,126:ii,127:ii,160:jh,176:ii,184:[.19445,0,0,0,.525],305:Kr,567:Qr,711:[0,.56597,0,0,.525],713:[0,.56555,0,0,.525],714:ii,715:ii,728:ii,730:ii,770:ii,771:ii,776:ii,915:ii,916:ii,920:ii,923:ii,926:ii,928:ii,931:ii,933:ii,934:ii,936:ii,937:ii,8216:ii,8217:ii,8242:ii,9251:[.11111,.21944,0,0,.525]}},Zh=/[\u3040-\u309F]|[\u30A0-\u30FF]|[\u4E00-\u9FAF]|[\uAC00-\uD7AF]/,Po=10,gs=.25,od=1.2,ua=.431,Zs={slant:[.25,.25,.25],space:[0,0,0],stretch:[0,0,0],shrink:[0,0,0],xHeight:[ua,ua,ua],quad:[1,1.171,1.472],extraSpace:[0,0,0],num1:[.5,.732,.925],num2:[.394,.384,.5],num3:[.444,.471,.504],denom1:[.686,.752,1.025],denom2:[.345,.344,.532],sup1:[.413,.503,.504],sup2:[.363,.431,.404],sup3:[.289,.286,.294],sub1:[.15,.143,.2],sub2:[.247,.286,.4],supDrop:[.386,.353,.494],subDrop:[.05,.071,.1],delim1:[2.39,1.7,1.98],delim2:[1.01,1.157,1.42],axisHeight:[gs,gs,gs],defaultRuleThickness:[.04,.049,.049],bigOpSpacing1:[.111,.111,.111],bigOpSpacing2:[.166,.166,.166],bigOpSpacing3:[.2,.2,.2],bigOpSpacing4:[.6,.611,.611],bigOpSpacing5:[.1,.143,.143],sqrtRuleThickness:[.04,.04,.04]},Oo=[0,.5,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],pu=5,Yh={"\xA0":" ","\u200B":" ",\u00C5:"A",\u00C7:"C",\u00D0:"D",\u00DE:"o",\u00E5:"a",\u00E7:"c",\u00F0:"d",\u00FE:"o",\u0410:"A",\u0411:"B",\u0412:"B",\u0413:"F",\u0414:"A",\u0415:"E",\u0416:"K",\u0417:"3",\u0418:"N",\u0419:"N",\u041A:"K",\u041B:"N",\u041C:"M",\u041D:"H",\u041E:"O",\u041F:"N",\u0420:"P",\u0421:"C",\u0422:"T",\u0423:"y",\u0424:"O",\u0425:"X",\u0426:"U",\u0427:"h",\u0428:"W",\u0429:"W",\u042A:"B",\u042B:"X",\u042C:"B",\u042D:"3",\u042E:"X",\u042F:"R",\u0430:"a",\u0431:"b",\u0432:"a",\u0433:"r",\u0434:"y",\u0435:"e",\u0436:"m",\u0437:"e",\u0438:"n",\u0439:"n",\u043A:"n",\u043B:"n",\u043C:"m",\u043D:"n",\u043E:"o",\u043F:"n",\u0440:"p",\u0441:"c",\u0442:"o",\u0443:"y",\u0444:"b",\u0445:"x",\u0446:"n",\u0447:"n",\u0448:"w",\u0449:"w",\u044A:"a",\u044B:"m",\u044C:"a",\u044D:"e",\u044E:"m",\u044F:"r"};function Aa(e,i){e===void 0&&(e=77);const r=qh[i][e];if(r)return{defaultMetrics:!1,depth:r[0],height:r[1],italic:r[2],skew:r[3],width:r[4]};if(e===11034)return{defaultMetrics:!0,depth:.2,height:.8,italic:0,skew:0,width:.8};const a=String.fromCodePoint(e);if(a in Yh)e=Yh[a].codePointAt(0);else if(Zh.test(a))return e=77,{defaultMetrics:!0,depth:.2,height:.9,italic:0,skew:0,width:1};return{defaultMetrics:!0,depth:.2,height:.7,italic:0,skew:0,width:.8}}var io={overrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],overleftarrow:[["leftarrow"],.888,522,"xMinYMin"],underrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],underleftarrow:[["leftarrow"],.888,522,"xMinYMin"],xrightarrow:[["rightarrow"],1.469,522,"xMaxYMin"],longrightarrow:[["rightarrow"],1.469,522,"xMaxYMin"],xleftarrow:[["leftarrow"],1.469,522,"xMinYMin"],longleftarrow:[["leftarrow"],1.469,522,"xMinYMin"],Overrightarrow:[["doublerightarrow"],.888,560,"xMaxYMin"],xRightarrow:[["doublerightarrow"],1.526,560,"xMaxYMin"],xLeftarrow:[["doubleleftarrow"],1.526,560,"xMinYMin"],overleftharpoon:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoonup:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoondown:[["leftharpoondown"],.888,522,"xMinYMin"],overrightharpoon:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoonup:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoondown:[["rightharpoondown"],.888,522,"xMaxYMin"],xlongequal:[["longequal"],.888,334,"xMinYMin"],xtwoheadleftarrow:[["twoheadleftarrow"],.888,334,"xMinYMin"],xtwoheadrightarrow:[["twoheadrightarrow"],.888,334,"xMaxYMin"],overleftrightarrow:[["leftarrow","rightarrow"],.888,522],overbrace:[["leftbrace","midbrace","rightbrace"],1.6,548],underbrace:[["leftbraceunder","midbraceunder","rightbraceunder"],1.6,548],underleftrightarrow:[["leftarrow","rightarrow"],.888,522],xleftrightarrow:[["leftarrow","rightarrow"],1.75,522],longleftrightarrow:[["leftarrow","rightarrow"],1.75,522],xLeftrightarrow:[["doubleleftarrow","doublerightarrow"],1.75,560],xrightleftharpoons:[["leftharpoondownplus","rightharpoonplus"],1.75,716],longrightleftharpoons:[["leftharpoondownplus","rightharpoonplus"],1.75,716],xleftrightharpoons:[["leftharpoonplus","rightharpoondownplus"],1.75,716],longleftrightharpoons:[["leftharpoonplus","rightharpoondownplus"],1.75,716],xhookleftarrow:[["leftarrow","righthook"],1.08,522],xhookrightarrow:[["lefthook","rightarrow"],1.08,522],overlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],underlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],overgroup:[["leftgroup","rightgroup"],.888,342],undergroup:[["leftgroupunder","rightgroupunder"],.888,342],xmapsto:[["leftmapsto","rightarrow"],1.5,522],xtofrom:[["leftToFrom","rightToFrom"],1.75,528],xleftrightarrows:[["baraboveleftarrow","rightarrowabovebar"],1.75,901],longleftrightarrows:[["baraboveleftarrow","rightarrowabovebar"],1.75,901],xRightleftharpoons:[["baraboveshortleftharpoon","rightharpoonaboveshortbar"],1.75,716],longRightleftharpoons:[["baraboveshortleftharpoon","rightharpoonaboveshortbar"],1.75,716],xLeftrightharpoons:[["shortbaraboveleftharpoon","shortrightharpoonabovebar"],1.75,716],longLeftrightharpoons:[["shortbaraboveleftharpoon","shortrightharpoonabovebar"],1.75,716]},Cc={widehat1:[1062,239,.24],widehat2:[2364,300,.3],widehat3:[2364,360,.36],widehat4:[2364,420,.42],widecheck1:[1062,239,.24],widecheck2:[2364,300,.3],widecheck3:[2364,360,.36],widecheck4:[2364,420,.42],widetilde1:[600,260,.26],widetilde2:[1033,286,.286],widetilde3:[2339,306,.306],widetilde4:[2340,312,.34],overarc:[1061,159,.3],underarc:[1061,159,.3]},Xh={doubleleftarrow:`M262 157
l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3
0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28
14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5
c2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5
157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87
-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7
-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z
m8 0v40h399730v-40zm0 194v40h399730v-40z`,doublerightarrow:`M399738 392l
-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5
14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88
-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68
-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18
-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782
c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3
-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z`,leftarrow:`M400000 241H110l3-3c68.7-52.7 113.7-120
135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
l-3-3h399890zM100 241v40h399900v-40z`,leftbrace:`M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117
-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7
5-6 9-10 13-.7 1-7.3 1-20 1H6z`,leftbraceunder:`M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13
35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688
0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7
-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z`,overarc:"M529 0c179 0 524 115 524 115 5 1 9 5 9 10 0 1-1 2-1 3l-4 22c-1 5-5 9-11 9h-2s-338-93-512-92c-174 0-513 92-513 92h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13 0 0 342-115 520-115z",underarc:`m 529 160
c -179 0 -524 -115 -524 -115
c -5 -1 -9 -5 -9 -10
c 0 -1 1 -2 1 -3
l 4 -22
c 1 -5 5 -9 11 -9
h 2
s 338 93 512 92
c 174 0 513 -92 513 -92
h 2
c 5 0 9 4 11 9
l 5 22
c 1 6 -2 12 -8 13
c 0 0 -342 115 -520 115
z
`,leftgroup:`M400000 80
H435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0
435 0h399565z`,leftgroupunder:`M400000 262
H435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219
435 219h399565z`,leftharpoon:`M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3
-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5
-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7
-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z`,leftharpoonplus:`M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5
20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3
-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7
-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z
m0 0v40h400000v-40z`,leftharpoondown:`M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333
5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5
1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667
-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z`,leftharpoondownplus:`M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12
10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7
-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0
v40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z`,lefthook:`M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5
-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3
-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21
71.5 23h399859zM103 281v-40h399897v40z`,leftlinesegment:`M40 281 V428 H0 V94 H40 V241 H400000 v40z
M40 281 V428 H0 V94 H40 V241 H400000 v40z`,leftmapsto:`M40 281 V448H0V74H40V241H400000v40z
M40 281 V448H0V74H40V241H400000v40z`,leftToFrom:`M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23
-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8
c28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3
68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z`,longequal:`M0 50 h400000 v40H0z m0 194h40000v40H0z
M0 50 h400000 v40H0z m0 194h40000v40H0z`,midbrace:`M200428 334
c-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14
-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7
311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11
12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z`,midbraceunder:`M199572 214
c100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14
53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3
11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0
-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z`,oiintSize1:`M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6
-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z
m368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8
60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z`,oiintSize2:`M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8
-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z
m502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2
c0 110 84 276 504 276s502.4-166 502.4-276z`,oiiintSize1:`M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6
-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z
m525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0
85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z`,oiiintSize2:`M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8
-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z
m770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1
c0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z`,rightarrow:`M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
151.7 139 205zm0 0v40h399900v-40z`,rightbrace:`M400000 542l
-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5
s-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1
c124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z`,rightbraceunder:`M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3
28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237
-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z`,rightgroup:`M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0
3-1 3-3v-38c-76-158-257-219-435-219H0z`,rightgroupunder:`M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18
0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z`,rightharpoon:`M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3
-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2
-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58
69.2 92 94.5zm0 0v40h399900v-40z`,rightharpoonplus:`M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11
-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7
2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z
m0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z`,rightharpoondown:`M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8
8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5
-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95
-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z`,rightharpoondownplus:`M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8
15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3
8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3
-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z
m0-194v40h400000v-40zm0 0v40h400000v-40z`,righthook:`M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3
15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0
-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21
66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z`,rightlinesegment:`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z
M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`,rightToFrom:`M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23
1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32
-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142
-167z M100 147v40h399900v-40zM0 341v40h399900v-40z`,twoheadleftarrow:`M0 167c68 40
115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69
-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3
-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19
-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101
10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z`,twoheadrightarrow:`M400000 167
c-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3
41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42
18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333
-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70
101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z`,widetilde1:`M200 55.538c-77 0-168 73.953-177 73.953-3 0-7
-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0
114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0
4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128
-68.267.847-113-73.952-191-73.952z`,widetilde2:`M344 55.266c-142 0-300.638 81.316-311.5 86.418
-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9
31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114
c1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751
181.476 676 181.476c-149 0-189-126.21-332-126.21z`,widetilde3:`M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457
-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0
411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697
16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696
-338 0-409-156.573-744-156.573z`,widetilde4:`M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345
-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409
177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9
14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409
-175.236-744-175.236z`,vec:`M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5
3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11
10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63
-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1
-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59
H213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359
c-16-25.333-24-45-24-59z`,widehat1:`M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22
c-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z`,widehat2:`M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10
-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`,widehat3:`M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10
-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`,widehat4:`M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10
-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`,widecheck1:`M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,
-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z`,widecheck2:`M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,widecheck3:`M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,widecheck4:`M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,baraboveleftarrow:`M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202
c4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5
c-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130
s-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47
121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6
s2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11
c0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z
M100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z`,rightarrowabovebar:`M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32
-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0
13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39
-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5
-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z`,baraboveshortleftharpoon:`M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11
c1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17
c2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21
c-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40
c-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z
M0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z`,rightharpoonaboveshortbar:`M0,241 l0,40c399126,0,399993,0,399993,0
c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,
-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6
c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z
M0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z`,shortbaraboveleftharpoon:`M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11
c1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,
1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,
-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z
M93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z`,shortrightharpoonabovebar:`M53,241l0,40c398570,0,399437,0,399437,0
c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,
-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6
c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z
M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`};function Jh(e){if(Cc[e]){const[E,R,N]=Cc[e],Z=`<span class="stretchy" style="height:${N}em"><svg width="100%" height="${N}em" viewBox="0 0 ${E} ${R}" preserveAspectRatio="none" ><path fill="currentcolor" d="${Xh[e]}"></path></svg></span>`;return`<span style="display:inline-block;height:${Math.floor(100*N/2)/100}em;min-width:0">${Z}</span>`}const[i,r,a,u]=io[e];let p,g;const b=a/1e3;i.length===3?(p=["slice-1-of-3","slice-2-of-3","slice-3-of-3"],g=["xMinYMin","xMidYMin","xMaxYMin"]):i.length===2?(p=["slice-1-of-2","slice-2-of-2"],g=["xMinYMin","xMaxYMin"]):(p=["slice-1-of-1"],g=[u]);const w=i.map((E,R)=>`<span class="${p[R]}" style=height:${b}em><svg width=400em height=${b}em viewBox="0 0 400000 ${a}" preserveAspectRatio="${g[R]} slice"><path fill="currentcolor" d="${Xh[E]}"></path></svg></span>`).join("");return`<span style="display:inline-block;height:${b}em;min-width:${r}em;">${w}</span>`}function Qh(e){return io[e]?io[e][2]/1e3:Cc[e][2]}function ef(e){const i=[];for(let r=0;r<e.length;r++){let a=e.charCodeAt(r);if(a===13&&e.charCodeAt(r+1)===10&&(a=10,r++),(a===13||a===12)&&(a=10),a===0&&(a=65533),a>=55296&&a<=56319){const u=e.charCodeAt(r+1);if(u>=56320&&u<=57343){const p=a-55296,g=u-56320;a=va(2,16)+p*va(2,10)+g,r++}}i.push(a)}return i}var mu=8205,Mc=[[mu,1],[65038,2],[127995,5],[129456,4],[917536,96]],gl,Fo=[127462,127487];function gu(e){var i;if(gl===void 0){gl={};for(const r of Mc)for(let a=r[0];a<=r[0]+r[1]-1;a++)gl[a]=!0}return(i=gl[e])!=null?i:!1}function ld(e){return e>=Fo[0]&&e<=Fo[1]}function tf(e){if(/^[\u0020-\u00FF]*$/.test(e))return e;const i=[],r=ef(e);let a=0;for(;a<r.length;){const u=r[a++],p=r[a];if(p===mu){const g=a-1;for(a+=2;r[a]===mu;)a+=2;i.push(String.fromCodePoint(...r.slice(g,a-g+1)))}else if(gu(p)){const g=a-1;for(;gu(r[a]);)a+=r[a]===mu?2:1;i.push(String.fromCodePoint(...r.slice(g,2*a-g-1)))}else ld(u)?(a+=1,i.push(String.fromCodePoint(...r.slice(a-2,2)))):i.push(String.fromCodePoint(u))}return i}var nf=class{constructor(e){this.obeyspaces=!1,this.pos=0,this.s=tf(e)}end(){return this.pos>=this.s.length}get(){return this.pos<this.s.length?this.s[this.pos++]:""}peek(){return this.s[this.pos]}match(e){const i=typeof this.s=="string"?e.exec(this.s.slice(this.pos)):e.exec(this.s.slice(this.pos).join(""));return i!=null&&i[0]?(this.pos+=i[0].length,i[0]):""}next(){if(this.end())return null;if(!this.obeyspaces&&this.match(/^[ \f\n\r\t\v\u00A0\u2028\u2029]+/)||this.obeyspaces&&this.match(/^[ \f\n\r\t\v\u00A0\u2028\u2029]/))return"<space>";const e=this.get();if(e==="\\"){if(!this.end()){let i=this.match(/^[a-zA-Z\*]+/);return i?this.match(/^[ \f\n\r\t\v\u00A0\u2028\u2029]*/):i=this.get(),"\\"+i}}else{if(e==="{")return"<{>";if(e==="}")return"<}>";if(e==="^"){if(this.peek()==="^"){this.get();const i=this.match(/^(\^(\^(\^(\^[\da-f])?[\da-f])?[\da-f])?[\da-f])?[\da-f]{2}/);if(i)return String.fromCodePoint(Number.parseInt(i.slice(i.lastIndexOf("^")+1),16))}return e}else if(e==="#"){if(!this.end()){let i=!1;if(/[\d?@]/.test(this.peek())&&(i=!0,this.pos+1<this.s.length)){const r=this.s[this.pos+1];i=/[^\dA-Za-z]/.test(r)}return i?"#"+this.get():"#"}}else if(e==="$")return this.peek()==="$"?(this.get(),"<$$>"):"<$>"}return e}};function rf(e,i){var r,a,u,p;const g=[];let b=e.next();if(b&&b!=="\\relax"){if(b==="\\noexpand")b=e.next(),b&&g.push(b);else if(b==="\\obeyspaces")e.obeyspaces=!0;else if(b==="\\bgroup")g.push("<{>");else if(b==="\\egroup")g.push("<}>");else if(b==="\\string"){if(b=e.next(),b)if(b.startsWith("\\"))for(const w of b)g.push(w==="\\"?"\\backslash":w);else b==="<{>"?g.push("\\{"):b==="<space>"?g.push("~"):b==="<}>"&&g.push("\\}")}else if(b==="\\csname"){for(;e.peek()==="<space>";)e.next();let w="",E=!1,R=[];do{if(R.length===0)if(/^#[\d?@]$/.test(e.peek())){const N=e.get().slice(1);R=_u((a=(r=i==null?void 0:i(N))!=null?r:i==null?void 0:i("?"))!=null?a:"\\placeholder{}",i),b=R[0]}else b=e.next(),R=b?[b]:[];E=R.length===0,!E&&b==="\\endcsname"&&(E=!0,R.shift()),E||(E=b==="<$>"||b==="<$$>"||b==="<{>"||b==="<}>"||typeof b=="string"&&b.length>1&&b.startsWith("\\")),E||(w+=R.shift())}while(!E);w&&g.push("\\"+w),g.push(...R)}else if(b!=="\\endcsname")if(b.length>1&&b.startsWith("#")){const w=b.slice(1);g.push(..._u((p=(u=i==null?void 0:i(w))!=null?u:i==null?void 0:i("?"))!=null?p:"\\placeholder{}",i))}else g.push(b)}return g}function _u(e,i=null){const r=[];let a="";for(const g of e.toString().split(/\r?\n/)){a&&r.push(a),a=" ";const b=g.match(/((?:\\%)|[^%])*/);b!==null&&r.push(b[0])}const u=new nf(Ot(r.join(""))),p=[];do p.push(...rf(u,i));while(!u.end());return p}function sn(e){let i="";const r=[];for(const a of e)a&&(i&&/^[a-zA-Z\*]/.test(a)&&r.push(i),r.push(a),/^\\[a-zA-Z]+\*?[\"\'][^\ ]+$/.test(a)&&r.push(" "),i=/\\[a-zA-Z]+\*?$/.test(a)?" ":"");return r.join("")}function jn(e,...i){return console.assert(e.startsWith("\\")),i.length===0?e:sn([e,...i.map(r=>`{${r}}`)])}function no(e){return sn(e.map(i=>{var r;return(r={"<space>":" ","<$$>":"$$","<$>":"$","<{>":"{","<}>":"}"}[i])!=null?r:i}))}var vu=class _h{constructor(i){_h._registry[i]=this}static createAtom(i,r,a){return _h._registry[i].createAtom(r,Me(r,i),a)}static serialize(i,r){var a;if(!i||i.length===0)return"";if((a=r.skipStyles)!=null&&a){const u=[];for(const p of ud(i)){const g=_h._registry[p[0].mode];u.push(...g.serialize(p,r))}return sn(u)}return sn(Ys(i,r))}static getFont(i,r,a){return _h._registry[i].getFont(r,a)}};vu._registry={};var us=vu;function ud(e){const i=[];let r=[],a="NONE";for(const u of e)u.type!=="first"&&(u.mode!==a?(r.length>0&&i.push(r),r=[u],a=u.mode):r.push(u));return r.length>0&&i.push(r),i}function Er(e,i){const r=[];let a=[],u;for(const p of e)if(p.type!=="first"&&p.style){let g;i==="variant"?(g=p.style.variant,p.style.variantStyle&&p.style.variantStyle!=="up"&&(g+="-"+p.style.variantStyle)):g=p.style[i],g===u?a.push(p):(a.length>0&&r.push(a),a=[p],u=g)}return a.length>0&&r.push(a),r}function cd(e,i){var r;const{parent:a}=e[0],u=a==null?void 0:a.computedStyle.color,p=[];for(const g of ud(e)){const b=i.defaultMode;for(const w of Er(g,"color")){const E=w[0].computedStyle,R=us._registry[w[0].mode].serialize(w,d(P({},i),{defaultMode:b==="text"?"text":"math"}));!i.skipStyles&&E.color&&E.color!=="none"&&(!a||u!==E.color)?p.push(jn("\\textcolor",(r=E.verbatimColor)!=null?r:E.color,sn(R))):p.push(sn(R))}}return p}function hd(e,i){const{parent:r}=e[0],a=r==null?void 0:r.computedStyle.backgroundColor;return Er(e,"backgroundColor").map(u=>{var p;if(u.length>0||u[0].type!=="box"){const g=u[0].computedStyle;if(g.backgroundColor&&g.backgroundColor!=="none"&&(!r||a!==g.backgroundColor))return jn("\\colorbox",(p=g.verbatimBackgroundColor)!=null?p:g.backgroundColor,sn(cd(u,d(P({},i),{defaultMode:"text"}))))}return sn(cd(u,i))})}function Ys(e,i){if(e.length===0)return[];const{parent:r}=e[0],a=r==null?void 0:r.computedStyle.fontSize,u=[];for(const p of Er(e,"fontSize")){const g=p[0].computedStyle.fontSize,b=hd(p,i);b&&(g&&g!=="auto"&&(!r||a!==g)?u.push(["","\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"][g],...b):u.push(...b))}return u}function Rc(e){return e?{mord:"ord",mbin:"bin",mop:"op",mrel:"rel",mopen:"open",mclose:"close",mpunct:"punct",minner:"inner",spacing:"ignore",latex:"latex",composition:"inner",error:"inner",placeholder:"ord",supsub:"ignore"}[e]:void 0}function _l(e){if(e.length===0)return"ord";const i=Rc(e[0].type),r=Rc(e[e.length-1].type);return i&&i===r?i:"ord"}function vl(e,i){if(typeof e=="string")return e;if(typeof e=="number"){console.assert(Number.isFinite(e));const r=Math.ceil(100*e)/100;return r===0?"0":r.toString()+(i!=null?i:"")}return""}var Tt=class Kp{constructor(i,r){var a,u,p,g,b;if(typeof i=="number"?this.value=String.fromCodePoint(i):typeof i=="string"?this.value=i:k(i)?this.children=i.filter(E=>E!==null):i&&i instanceof Kp&&(this.children=[i]),this.children)for(const E of this.children)E.parent=this;this.type=(a=r==null?void 0:r.type)!=null?a:"ignore",this.isSelected=(r==null?void 0:r.isSelected)===!0,r!=null&&r.caret&&(this.caret=r.caret),this.classes=(u=r==null?void 0:r.classes)!=null?u:"",this.isTight=(p=r==null?void 0:r.isTight)!=null?p:!1,r!=null&&r.attributes&&(this.attributes=r.attributes);let w=r==null?void 0:r.fontFamily;r!=null&&r.style&&this.value&&(w=(b=us.getFont((g=r.mode)!=null?g:"math",this,d(P({variant:"normal"},r.style),{letterShapeStyle:r.letterShapeStyle})))!=null?b:void 0),w||(w="Main-Regular"),this._height=0,this._depth=0,this._width=0,this.hasExplicitWidth=!1,this.skew=0,this.italic=0,this.maxFontSize=0,this.scale=1,(r==null?void 0:r.maxFontSize)!==void 0&&(this.maxFontSize=r.maxFontSize),fd(this,w)}set atomID(i){i===void 0||i.length===0||(this.id=i)}selected(i){if(this.isSelected!==i&&(this.isSelected=i,this.children))for(const r of this.children)r.selected(i)}setStyle(i,r,a){if(r===void 0)return;const u=vl(r,a);u.length>0&&(this.cssProperties||(this.cssProperties={}),this.cssProperties[i]=u)}setTop(i){Number.isFinite(i)&&Math.abs(i)>.01&&(this.cssProperties||(this.cssProperties={}),this.cssProperties.top=vl(i,"em"),this.height-=i,this.depth+=i)}get left(){var i;return(i=this.cssProperties)!=null&&i["margin-left"]?Number.parseFloat(this.cssProperties["margin-left"]):0}set left(i){Number.isFinite(i)&&(i===0?this.cssProperties&&delete this.cssProperties["margin-left"]:(this.cssProperties||(this.cssProperties={}),this.cssProperties["margin-left"]=vl(i,"em")))}set right(i){Number.isFinite(i)&&(i===0?this.cssProperties&&delete this.cssProperties["margin-right"]:(this.cssProperties||(this.cssProperties={}),this.cssProperties["margin-right"]=vl(i,"em")))}set bottom(i){Number.isFinite(i)&&(i===0?this.cssProperties&&delete this.cssProperties["margin-bottom"]:(this.cssProperties||(this.cssProperties={}),this.cssProperties["margin-bottom"]=vl(i,"em")))}get width(){return this._width*this.scale}set width(i){this._width=i,this.hasExplicitWidth=!0}set softWidth(i){}get height(){return this._height*this.scale}set height(i){this._height=i}get depth(){return this._depth*this.scale}set depth(i){this._depth=i}wrap(i){const r=i.parent;if(!r)return this;i.isPhantom&&this.setStyle("opacity",0);const a=i.color;a&&a!==r.color&&this.setStyle("color",a);let u=i.backgroundColor;this.isSelected&&(u=A(u)),u&&u!==r.backgroundColor&&(this.setStyle("background-color",u),this.setStyle("display","inline-block"));const p=i.scalingFactor;return this.scale=p,this.skew*=p,this.italic*=p,this}toMarkup(){var i,r,a,u;let p=(i=this.value)!=null?i:"";if(this.children)for(const ue of this.children)p+=ue.toMarkup();let g="";if(this.svgBody)g=Jh(this.svgBody);else if(this.svgOverlay){g='<span style="',g+="display: inline-block;",g+=`height:${Math.floor(100*(this.height+this.depth))/100}em;`,g+=`vertical-align:${Math.floor(100*this.depth)/100}em;`,g+='">',g+=p,g+="</span>",g+='<svg style="position:absolute;overflow:visible;',g+=`height:${Math.floor(100*(this.height+this.depth))/100}em;`;const ue=(r=this.cssProperties)==null?void 0:r.padding;ue?(g+=`top:${ue};`,g+=`left:${ue};`,g+=`width:calc(100% - 2 * ${ue} );`):g+="top:0;left:0;width:100%;",g+="z-index:2;",g+='"',this.svgStyle&&(g+=this.svgStyle),g+=` viewBox="0 0 ${Math.floor(100*this.width)/100} ${Math.floor(100*(this.height+this.depth))/100}"`,g+=`>${this.svgOverlay}</svg>`}let b="";const w=this.classes.split(" ");w.push((a={latex:"ML__raw-latex",placeholder:"ML__placeholder",error:"ML__error"}[this.type])!=null?a:""),this.caret==="latex"&&w.push("ML__latex-caret"),this.isSelected&&w.push("ML__selected");const E=w.length===1?w[0]:w.filter((ue,me,Ve)=>ue.length>0&&Ve.indexOf(ue)===me).join(" ");if(E.length>0&&(b+=` class="${E}"`),this.id&&(b+=` data-atom-id=${this.id}`),this.cssId&&(b+=` id="${this.cssId.replace(/ /g,"-")}" `),this.attributes&&(b+=" "+Object.keys(this.attributes).map(ue=>`${ue}="${this.attributes[ue]}"`).join(" ")),this.htmlData){const ue=this.htmlData.split(",");for(const me of ue){const Ve=me.match(/([^=]+)=(.+$)/);if(Ve){const Ct=Ve[1].trim().replace(/ /g,"-");Ct&&(b+=` data-${Ct}="${Ve[2]}" `)}else{const Ct=me.trim().replace(/ /g,"-");Ct&&(b+=` data-${Ct} `)}}}const R=(u=this.cssProperties)!=null?u:{};this.hasExplicitWidth&&R.width===void 0&&(R.width=`${Math.ceil(this._width*100)/100}em`);const N=Object.keys(R).map(ue=>`${ue}:${R[ue]}`);if(this.scale!==void 0&&this.scale!==1&&(p.length>0||g.length>0)&&N.push(`font-size: ${Math.ceil(this.scale*1e4)/100}%`),this.htmlStyle){const ue=this.htmlStyle.split(";");let me="";for(const Ve of ue){const Ct=Ve.match(/([^=]+):(.+$)/);if(Ct){const Ue=Ct[1].trim().replace(/ /g,"-");Ue&&(me+=`${Ue}:${Ct[2]};`)}}me&&(b+=` style="${me}"`)}N.length>0&&(b+=` style="${N.join(";")}"`);let Z="";return b.length>0||g.length>0?Z=`<span${b}>${p}${g}</span>`:Z=p,this.caret==="text"?Z+='<span class="ML__text-caret"></span>':this.caret==="math"&&(Z+='<span class="ML__caret"></span>'),Z}tryCoalesceWith(i){if(this.svgBody||!this.value||i.svgBody||!i.value)return!1;const r=this.children&&this.children.length>0,a=i.children&&i.children.length>0;if(r||a)return!1;if(i.cssProperties||this.cssProperties){for(const w of["border","border-left","border-right","border-right-width","left","margin","margin-left","margin-right","padding","position","width"])if(i.cssProperties&&w in i.cssProperties||this.cssProperties&&w in this.cssProperties)return!1}const u=this.cssProperties?Object.keys(this.cssProperties).length:0,p=i.cssProperties?Object.keys(i.cssProperties).length:0;if(u!==p)return!1;if(u>0){for(const w of Object.keys(this.cssProperties))if(this.cssProperties[w]!==i.cssProperties[w])return!1}const g=this.classes.trim().replace(/\s+/g," ").split(" "),b=i.classes.trim().replace(/\s+/g," ").split(" ");if(g.length!==b.length)return!1;g.sort(),b.sort();for(const[w,E]of g.entries())if(E==="vertical-separator"||E!==b[w])return!1;return this.value+=i.value,this.height=Math.max(this.height,i.height),this.depth=Math.max(this.depth,i.depth),this._width=this._width+i._width,this.maxFontSize=Math.max(this.maxFontSize,i.maxFontSize),this.italic=i.italic,!0}};function yu(e){if(!e||e.length===0)return[];e[0].children=yu(e[0].children);const i=[e[0]];for(let r=1;r<e.length;r++)i[i.length-1].tryCoalesceWith(e[r])||(e[r].children=yu(e[r].children),i.push(e[r]));return i}function yl(e){return e.children&&(e.children=yu(e.children)),e}function bu(e,i){if(!e)return new Tt(null,i);const r=new Tt(null,{classes:"ML__strut",type:"ignore"});r.setStyle("height",Math.max(0,e.height),"em");const a=[r];if(e.depth!==0){const u=new Tt(null,{classes:"ML__strut--bottom",type:"ignore"});u.setStyle("height",e.height+e.depth,"em"),u.setStyle("vertical-align",-e.depth,"em"),a.push(u)}return a.push(e),new Tt(a,d(P({},i),{type:"lift"}))}function xu(e){const i=Qh(e)/2,r=new Tt(null,{maxFontSize:0});return r.height=i+.166,r.depth=i-.166,r.svgBody=e,r}function fd(e,i){var r;if(e.type==="latex"){e.height=.9,e.depth=.2,e._width=1;return}if(e.value){e.height=-1/0,e.depth=-1/0,e._width=0,e.skew=-1/0,e.italic=-1/0;for(let a=0;a<e.value.length;a++){const u=Aa(e.value.codePointAt(a),i);e.height=Math.max(e.height,u.height),e.depth=Math.max(e.depth,u.depth),e._width+=u.width,e.skew=u.skew,e.italic=u.italic}return}if(e.children&&e.children.length>0){let a=-1/0,u=-1/0,p=0;for(const g of e.children)g.height>a&&(a=g.height),g.depth>u&&(u=g.depth),p=Math.max(p,(r=g.maxFontSize)!=null?r:0);e.height=a,e.depth=u,e._width=e.children.reduce((g,b)=>g+b.width,0),e.maxFontSize=p}}function dd(e){if("individualShift"in e){const i=e.individualShift;let r=i[0];const a=[r],u=-r.shift-r.box.depth;let p=u;for(let g=1;g<i.length;g++){const b=i[g],w=-b.shift-p-b.box.depth,E=w-(r.box.height+r.box.depth);p=p+w,a.push(E),a.push(b),r=b}return[a,u]}if("top"in e){let i=e.top;for(const r of e.children)i-=typeof r=="number"?r:r.box.height+r.box.depth;return[e.children,i]}else{if("bottom"in e)return[e.children,-e.bottom];if("firstBaseline"in e){const i=e.firstBaseline[0];if(typeof i=="number")throw new Error("First child must be an element.");return[e.firstBaseline,-i.box.depth]}else if("shift"in e){const i=e.children[0];if(typeof i=="number")throw new Error("First child must be an element.");return[e.children,-i.box.depth-e.shift]}}return[null,0]}function pd(e){var i;const[r,a]=dd(e);if(!r)return[[],0,0];const u=new Tt(null,{classes:"pstrut"});let p=0;for(const me of r)if(typeof me!="number"){const Ve=me.box;p=Math.max(p,Ve.maxFontSize,Ve.height)}p+=2,u.height=p,u.setStyle("height",p,"em");const g=[];let b=a,w=a,E=a,R=0;for(const me of r){if(typeof me=="number")E+=me;else{const Ve=me.box,Ct=(i=me.classes)!=null?i:[],Ue=new Tt([u,Ve],{classes:Ct.join(" "),style:me.style});Ve.setStyle("height",Ve.height+Ve.depth,"em"),Ve.setStyle("display","inline-block"),Ue.setStyle("top",-p-E-Ve.depth,"em"),me.marginLeft&&Ue.setStyle("margin-left",me.marginLeft,"em"),me.marginRight&&Ue.setStyle("margin-right",me.marginRight,"em"),g.push(Ue),E+=Ve.height+Ve.depth,R=Math.max(R,Ue.width)}b=Math.min(b,E),w=Math.max(w,E)}g.forEach(me=>{me.softWidth=R});const N=new Tt(g,{classes:"vlist"});if(N.softWidth=R,N.height=w,N.setStyle("height",w,"em"),b>=0)return[[new Tt(N,{classes:"vlist-r"})],w,-b];const Z=new Tt(new Tt(null),{classes:"vlist"});Z.height=-b,Z.setStyle("height",-b,"em");const ue=new Tt(8203,{classes:"vlist-s",maxFontSize:0});return ue.softWidth=0,ue.height=0,ue.depth=0,[[new Tt([N,ue],{classes:"vlist-r"}),new Tt(Z,{classes:"vlist-r"})],w,-b]}var kr=class extends Tt{constructor(e,i){var r;const[a,u,p]=pd(e);super(a.length===1?a[0]:a,{type:i==null?void 0:i.type,classes:((r=i==null?void 0:i.classes)!=null?r:"")+" vlist-t"+(a.length===2?" vlist-t2":"")}),this.height=u,this.depth=p,this.softWidth=a.reduce((g,b)=>Math.max(g,b.width),0)}};function md(e,i){var r,a,u,p,g;const b=e.metrics,w=new Tt(i.base),E=(r=i.baseShift)!=null?r:0,R=(a=i.slant)!=null?a:0;let N=0,Z=0;i.above&&(N=(u=i.aboveShift)!=null?u:Math.max(b.bigOpSpacing1,b.bigOpSpacing3-i.above.depth)),i.below&&(Z=(p=i.belowShift)!=null?p:Math.max(b.bigOpSpacing2,b.bigOpSpacing4-i.below.height));let ue=null;if(i.below&&i.above){const me=b.bigOpSpacing5+i.below.height+i.below.depth+Z+w.depth+E;ue=new kr({bottom:me,children:[b.bigOpSpacing5,{box:i.below,marginLeft:-R,classes:["ML__center"]},Z,{box:w,classes:["ML__center"]},N,{box:i.above,marginLeft:R,classes:["ML__center"]},b.bigOpSpacing5]}).wrap(e)}else if(i.below&&!i.above)ue=new kr({top:w.height-E,children:[b.bigOpSpacing5,{box:i.below,marginLeft:-R,classes:["ML__center"]},Z,{box:w,classes:["ML__center"]}]}).wrap(e);else if(!i.below&&i.above){const me=w.depth+E;ue=new kr({bottom:me,children:[{box:w,classes:["ML__center"]},N,{box:i.above,marginLeft:R,classes:["ML__center"]},b.bigOpSpacing5]}).wrap(e)}else{const me=w.depth+E;ue=new kr({bottom:me,children:[{box:w},b.bigOpSpacing5]}).wrap(e)}return new Tt(ue,{type:(g=i.type)!=null?g:"op"})}var wu=7,Su=6,bl=5,ro=4,Bo=3,bs=2,so=1,es=0,La=class{constructor(e,i,r){this.id=e,this.sizeDelta=i,this.cramped=r;const a={"-4":2,"-3":1,0:0}[i];this.metrics=Object.keys(Zs).reduce((u,p)=>d(P({},u),{[p]:Zs[p][a]}),{})}getFontSize(e){return Math.max(1,e+this.sizeDelta)}get sup(){return Us[[es,so,es,so,bs,Bo,bs,Bo][this.id]]}get sub(){return Us[[es,es,es,es,bs,bs,bs,bs][this.id]]}get fracNum(){return Us[[es,so,es,so,bs,Bo,ro,bl][this.id]]}get fracDen(){return Us[[es,es,es,es,bs,bs,ro,ro][this.id]]}get cramp(){return Us[[es,es,bs,bs,ro,ro,Su,Su][this.id]]}get isTight(){return this.sizeDelta<0}},xl={7:new La(wu,0,!1),6:new La(Su,0,!0),5:new La(bl,0,!1),4:new La(ro,0,!0),3:new La(Bo,-3,!1),2:new La(bs,-3,!0),1:new La(so,-4,!1),0:new La(es,-4,!0)},Us=d(P({},xl),{displaystyle:xl[wu],textstyle:xl[bl],scriptstyle:xl[Bo],scriptscriptstyle:xl[so]});function Eu(e,i){var r;if(!e)return 0;const a={pt:1,mm:7227/2540,cm:7227/254,ex:35271/8192,px:3/4,em:Po,bp:803/800,dd:1238/1157,pc:12,in:72.27,mu:10/18}[(r=e.unit)!=null?r:"pt"];if(Number.isFinite(i)){const u=va(10,i);return Math.round(e.dimension/Po*a*u)/u}return e.dimension*a}function sf(e,i){if(e===null)return 0;const r=Eu(e)/Po;if(Number.isFinite(i)){const a=va(10,i);return Math.round(r*a)/a}return r}function wl(e){var i;return`${e.dimension}${(i=e.unit)!=null?i:"pt"}`}function Ic(e){let i=wl(e.glue);return e.grow&&e.grow.dimension!==0&&(i+=` plus ${wl(e.grow)}`),e.shrink&&e.shrink.dimension!==0&&(i+=` minus ${wl(e.shrink)}`),i}function Or(e){var i,r;if(e==null)return null;let a="";if("dimension"in e&&(a=`${e.dimension}${(i=e.unit)!=null?i:"pt"}`),"glue"in e&&(a=Ic(e)),"number"in e)if(!("base"in e)||e.base==="decimal")a=Number(e.number).toString();else if(e.base==="alpha")a=`\`${String.fromCodePoint(e.number)}`;else{const u=Math.round(e.number)>>>0;e.base==="hexadecimal"?(a=Number(u).toString(16).toUpperCase(),u<=255?a=a.padStart(2,"0"):u<=65535?a=a.padStart(4,"0"):u<=16777215?a=a.padStart(6,"0"):a=a.padStart(8,"0"),a=`"${a}`):e.base==="octal"&&(a=Number(u).toString(8),u<=63?a=a.padStart(2,"0"):u<=30583?a=a.padStart(4,"0"):a=a.padStart(8,"0"),a=`'${a}`)}return"register"in e&&("factor"in e&&(e.factor===-1?a="-":e.factor!==1&&(a=Number(e.factor).toString())),"global"in e&&e.global&&(a+="\\global"),a+=`\\${e.register}`),"string"in e&&(a=e.string),(r=e.relax)!=null&&r&&(a+="\\relax"),a}function Xs(e,i){return e==null?null:"number"in e?d(P({},e),{number:e.number*i}):"register"in e?"factor"in e&&e.factor?d(P({},e),{factor:e.factor*i}):d(P({},e),{factor:i}):"dimension"in e?d(P({},e),{dimension:e.dimension*i}):"glue"in e?e.shrink&&e.grow?{glue:Xs(e.glue,i),shrink:Xs(e.shrink,i),grow:Xs(e.grow,i)}:e.shrink?{glue:Xs(e.glue,i),shrink:Xs(e.shrink,i)}:e.grow?{glue:Xs(e.glue,i),grow:Xs(e.grow,i)}:{glue:Xs(e.glue,i)}:null}var gd={"p@":{dimension:1},"z@":{dimension:0},maxdimen:{dimension:16383.99999},hfuzz:{dimension:.1},vfuzz:{dimension:.1},overfullrule:{dimension:5},hsize:{dimension:6.5,unit:"in"},vsize:{dimension:8.9,unit:"in"},parindent:{dimension:20},maxdepth:{dimension:4},splitmaxdepth:{register:"maxdimen"},boxmaxdepth:{register:"maxdimen"},delimitershortfall:{dimension:5},nulldelimiterspace:{dimension:1.2,unit:"pt"},scriptspace:{dimension:.5},topskip:{dimension:10},splittopskip:{dimension:10},normalbaselineskip:{dimension:12},normallineskip:{dimension:1},normallineskiplimit:{dimension:0},jot:{dimension:3},doublerulesep:{dimension:2},arrayrulewidth:{dimension:.4},arraycolsep:{dimension:5},fboxsep:{dimension:3},fboxrule:{dimension:.4},"z@skip":{glue:{dimension:0},shrink:{dimension:0},grow:{dimension:0}},hideskip:{glue:{dimension:-1e3},grow:{dimension:1,unit:"fill"}},"@flushglue":{glue:{dimension:0},grow:{dimension:1,unit:"fill"}},parskip:{glue:{dimension:0},grow:{dimension:1}},abovedisplayskip:{glue:{dimension:12},grow:{dimension:3},shrink:{dimension:9}},abovedisplayshortskip:{glue:{dimension:0},grow:{dimension:3}},belowdisplayskip:{glue:{dimension:12},grow:{dimension:3},shrink:{dimension:9}},belowdisplayshortskip:{glue:{dimension:7},grow:{dimension:3},shrink:{dimension:4}},parfillskip:{glue:{dimension:0},grow:{dimension:1,unit:"fil"}},thinmuskip:{glue:{dimension:3,unit:"mu"}},medmuskip:{glue:{dimension:4,unit:"mu"},grow:{dimension:2,unit:"mu"},shrink:{dimension:4,unit:"mu"}},thickmuskip:{glue:{dimension:5,unit:"mu"},grow:{dimension:5,unit:"mu"}},smallskipamount:{glue:{dimension:3},grow:{dimension:1},shrink:{dimension:1}},medskipamount:{glue:{dimension:6},grow:{dimension:2},shrink:{dimension:3}},bigskipamount:{glue:{dimension:12},grow:{dimension:2},shrink:{dimension:4}},pretolerance:100,tolerance:200,hbadness:1e3,vbadness:1e3,linepenalty:10,hyphenpenalty:50,exhyphenpenalty:50,binoppenalty:700,relpenalty:500,clubpenalty:150,widowpenalty:150,displaywidowpenalty:50,brokenpenalty:100,predisplaypenalty:1e4,doublehyphendemerits:1e4,finalhyphendemerits:5e3,adjdemerits:1e4,tracinglostchars:1,uchyph:1,delimiterfactor:901,defaulthyphenchar:"\\-",defaultskewchar:-1,newlinechar:-1,showboxbreadth:5,showboxdepth:3,errorcontextlines:5,interdisplaylinepenalty:100,interfootnotelinepenalty:100,baselineSkip:1.2,arraystretch:1,month:new Date().getMonth()+1,day:new Date().getDate(),year:new Date().getFullYear()};function Pc(){return P({},gd)}function Ds(){return{registers:Pc(),smartFence:!1,renderPlaceholder:void 0,placeholderSymbol:"\u25A2",letterShapeStyle:$.locale.startsWith("fr")?"french":"tex",minFontScale:0,colorMap:Be,backgroundColorMap:Dt,getMacro:e=>tt(e,Gt())}}var Si=class Up{constructor(i,r){var a,u,p,g,b,w,E,R,N,Z,ue,me,Ve,Ct,Ue;let ct;i!=null&&i.parent?(this.parent=i.parent,ct=i.parent,this.registers={}):(ct=P(P({},Ds()),(a=i==null?void 0:i.from)!=null?a:{}),this.registers=ct.registers),ct.atomIdsSettings&&(this.atomIdsSettings=P({},ct.atomIdsSettings)),this.renderPlaceholder=ct.renderPlaceholder,this.isPhantom=(g=(p=i==null?void 0:i.isPhantom)!=null?p:(u=this.parent)==null?void 0:u.isPhantom)!=null?g:!1,this.letterShapeStyle=ct.letterShapeStyle,this.minFontScale=ct.minFontScale,r!=null&&r.color&&r.color!=="none"?this.color=r.color:this.color=(w=(b=this.parent)==null?void 0:b.color)!=null?w:"",r!=null&&r.backgroundColor&&r.backgroundColor!=="none"?this.backgroundColor=r.backgroundColor:this.backgroundColor=(R=(E=this.parent)==null?void 0:E.backgroundColor)!=null?R:"",r!=null&&r.fontSize&&r.fontSize!=="auto"&&r.fontSize!==((N=this.parent)==null?void 0:N.size)?this.size=r.fontSize:this.size=(ue=(Z=this.parent)==null?void 0:Z.size)!=null?ue:pu;let It=(Ve=(me=this.parent)==null?void 0:me.mathstyle)!=null?Ve:Us.displaystyle;if(typeof(i==null?void 0:i.mathstyle)=="string"){if(ct instanceof Up)switch(i.mathstyle){case"cramp":It=It.cramp;break;case"superscript":It=It.sup;break;case"subscript":It=It.sub;break;case"numerator":It=It.fracNum;break;case"denominator":It=It.fracDen;break}switch(i.mathstyle){case"textstyle":It=Us.textstyle;break;case"displaystyle":It=Us.displaystyle;break;case"scriptstyle":It=Us.scriptstyle;break;case"scriptscriptstyle":It=Us.scriptscriptstyle;break;case"":case"auto":break}}this.mathstyle=It,this.smartFence=ct.smartFence,this.placeholderSymbol=ct.placeholderSymbol,this.colorMap=(Ct=ct.colorMap)!=null?Ct:yt=>yt,this.backgroundColorMap=(Ue=ct.backgroundColorMap)!=null?Ue:yt=>yt,this.getMacro=ct.getMacro,console.assert(this.parent!==void 0||this.registers!==void 0)}makeID(){if(!this.atomIdsSettings)return;if(this.atomIdsSettings.overrideID)return this.atomIdsSettings.overrideID;if(typeof this.atomIdsSettings.seed!="number")return`${Date.now().toString(36).slice(-2)}${Math.floor(Math.random()*1e5).toString(36)}`;const i=this.atomIdsSettings.seed.toString(36);return this.atomIdsSettings.seed+=1,i}scale(i){return i*this.effectiveFontSize}get scalingFactor(){return this.parent?this.effectiveFontSize/this.parent.effectiveFontSize:1}get isDisplayStyle(){return this.mathstyle.id===wu||this.mathstyle.id===Su}get isCramped(){return this.mathstyle.cramped}get isTight(){return this.mathstyle.isTight}get metrics(){return this.mathstyle.metrics}get effectiveFontSize(){return Math.max(Oo[Math.max(1,this.size+this.mathstyle.sizeDelta)],this.minFontScale)}getRegister(i){var r;if((r=this.registers)!=null&&r[i])return this.registers[i];if(this.parent)return this.parent.getRegister(i)}getRegisterAsNumber(i){const r=this.getRegister(i);if(typeof r=="number")return r;if(typeof r=="string")return Number(r)}getRegisterAsGlue(i){var r;if((r=this.registers)!=null&&r[i]){const a=this.registers[i];return typeof a=="object"&&"glue"in a?a:typeof a=="object"&&"dimension"in a?{glue:{dimension:a.dimension}}:typeof a=="number"?{glue:{dimension:a}}:void 0}if(this.parent)return this.parent.getRegisterAsGlue(i)}getRegisterAsEm(i,r){return sf(this.getRegisterAsDimension(i),r)}getRegisterAsDimension(i){var r;if((r=this.registers)!=null&&r[i]){const a=this.registers[i];return typeof a=="object"&&"glue"in a?a.glue:typeof a=="object"&&"dimension"in a?a:typeof a=="number"?{dimension:a}:void 0}if(this.parent)return this.parent.getRegisterAsDimension(i)}setRegister(i,r){if(r===void 0){delete this.registers[i];return}this.registers[i]=r}evaluate(i){if(!i||!("register"in i))return i;let r=this;if("global"in i&&i.global)for(;r.parent;)r=r.parent;let a=1;"factor"in i&&i.factor!==1&&i.factor!==void 0&&(a=i.factor);const u=r.getRegister(i.register);if(u===void 0)return;if(typeof u=="string")return{string:Number(u).toString()+u};if(typeof u=="number")return{number:a*u};const p=r.evaluate(u);if(p!==void 0)return"string"in p?{string:Number(u).toString()+p.string}:"number"in p?{number:a*p.number}:"dimension"in p?d(P({},p),{dimension:a*p.dimension}):"glue"in p?d(P({},p),{glue:d(P({},p.glue),{dimension:a*p.glue.dimension}),shrink:p.shrink?d(P({},p.shrink),{dimension:a*p.shrink.dimension}):void 0,grow:p.grow?d(P({},p.grow),{dimension:a*p.grow.dimension}):void 0}):i}toDimension(i){const r=this.evaluate(i);return r===void 0?null:"dimension"in r?r:"glue"in r?r.glue:"number"in r?{dimension:r.number}:null}toEm(i,r){if(i===null)return 0;const a=this.toDimension(i);return a===null?0:Eu(a,r)/Po}toNumber(i){if(i===null)return null;const r=this.evaluate(i);return r===void 0?null:"number"in r?r.number:"dimension"in r?r.dimension:"glue"in r?r.glue.dimension:"string"in r?Number(r.string):null}toColor(i){var r,a;if(i===null)return null;const u=this.evaluate(i);return u===void 0?null:"string"in u?(a=(r=this.colorMap)==null?void 0:r.call(this,u.string))!=null?a:u.string:null}toBackgroundColor(i){var r,a;if(i===null)return null;const u=this.evaluate(i);return u===void 0?null:"string"in u?(a=(r=this.backgroundColorMap)==null?void 0:r.call(this,u.string))!=null?a:u.string:null}},Cs=["body","above","below","superscript","subscript"];function _s(e){return typeof e=="string"&&Cs.includes(e)}function ku(e){return e!==void 0&&Array.isArray(e)&&e.length===2}var et=class wo{constructor(i){var r,a,u,p,g,b;this.type=i.type,typeof i.value=="string"&&(this.value=i.value),this.command=(a=(r=i.command)!=null?r:this.value)!=null?a:"",this.mode=(u=i.mode)!=null?u:"math",i.isFunction&&(this.isFunction=!0),i.limits&&(this.subsupPlacement=i.limits),this.style=P({},i.style),this.displayContainsHighlight=(p=i.displayContainsHighlight)!=null?p:!1,this.captureSelection=(g=i.captureSelection)!=null?g:!1,this.skipBoundary=(b=i.skipBoundary)!=null?b:!1,i.verbatimLatex!==void 0&&i.verbatimLatex!==null&&(this.verbatimLatex=i.verbatimLatex),i.args&&(this.args=i.args),i.body&&(this.body=i.body),this._changeCounter=0}static createBox(i,r,a){var u;if(!r)return null;const p=_d(r),g=[];for(const w of p){const E=w[0].style,R=vd(i,w,{style:{color:E.color,backgroundColor:E.backgroundColor,fontSize:E.fontSize}});R&&g.push(R)}if(g.length===0)return null;const b=((u=a==null?void 0:a.classes)!=null?u:"").trim();return g.length===1&&!b&&!(a!=null&&a.type)?g[0].wrap(i):new Tt(g,{classes:b,type:a==null?void 0:a.type}).wrap(i)}static serialize(i,r){return us.serialize(i,r)}static commonAncestor(i,r){if(i===r||i.parent===r.parent)return i.parent;const a=new WeakSet;let{parent:u}=i;for(;u;)a.add(u),u=u.parent;for(u=r.parent;u;){if(a.has(u))return u;u=u.parent}console.assert(!!u)}static fromJson(i){return typeof i=="string"?new wo({type:"mord",value:i,mode:"math"}):new wo(i)}get latexMode(){return this.mode==="math"?"math":"text"}toJson(){const i={};if(this.type&&(i.type=this.type),this.mode!=="math"&&(i.mode=this.mode),this.command&&this.command!==this.value&&(i.command=this.command),this.value!==void 0&&(i.value=this.value),this.style&&Object.keys(this.style).length>0&&(i.style=P({},this.style)),this.verbatimLatex!==void 0&&(i.verbatimLatex=this.verbatimLatex),this.subsupPlacement&&(i.subsupPlacement=this.subsupPlacement),this.explicitSubsupPlacement&&(i.explicitSubsupPlacement=!0),this.isFunction&&(i.isFunction=!0),this.displayContainsHighlight&&(i.displayContainsHighlight=!0),this.isExtensibleSymbol&&(i.isExtensibleSymbol=!0),this.skipBoundary&&(i.skipBoundary=!0),this.captureSelection&&(i.captureSelection=!0),this.args&&(i.args=yd(this.args)),this._branches)for(const r of Object.keys(this._branches))this._branches[r]&&(i[r]=this._branches[r].filter(a=>a.type!=="first").map(a=>a.toJson()));return i.type==="mord"&&Object.keys(i).length===2&&"value"in i?i.value:i}get changeCounter(){return this.parent?this.parent.changeCounter:this._changeCounter}set isDirty(i){if(i){this.parent||this._changeCounter++,"verbatimLatex"in this&&(this.verbatimLatex=void 0),this._children=void 0;let{parent:r}=this;for(;r;)r.parent||r._changeCounter++,"verbatimLatex"in r&&(r.verbatimLatex=void 0),r._children=void 0,r=r.parent}}_serialize(i){if(!(i.expandMacro||i.skipStyles||i.skipPlaceholders)&&typeof this.verbatimLatex=="string")return this.verbatimLatex;const r=Me(this.command,this.mode);return r!=null&&r.serialize?r.serialize(this,i):this.body&&this.command?sn([jn(this.command,this.bodyToLatex(i)),this.supsubToLatex(i)]):this.body?sn([this.bodyToLatex(i),this.supsubToLatex(i)]):!this.value||this.value==="\u200B"?"":this.command}bodyToLatex(i){var r;return us.serialize(this.body,d(P({},i),{defaultMode:(r=i.defaultMode)!=null?r:this.latexMode}))}aboveToLatex(i){return us.serialize(this.above,i)}belowToLatex(i){return us.serialize(this.below,i)}supsubToLatex(i){let r="";if(i=d(P({},i),{defaultMode:"math"}),this.branch("subscript")!==void 0){const a=us.serialize(this.subscript,i);a.length===0?r+="_{}":a.length===1?/^[0-9]$/.test(a)?r+=`_${a}`:r+=`_{${a}}`:r+=`_{${a}}`}if(this.branch("superscript")!==void 0){const a=us.serialize(this.superscript,i);a.length===0?r+="^{}":a.length===1?a==="\u2032"?r+="^\\prime ":a==="\u2033"?r+="^\\doubleprime ":/^[0-9]$/.test(a)?r+=`^${a}`:r+=`^{${a}}`:r+=`^{${a}}`}return r}get treeDepth(){let i=1,r=this.parent;for(;r;)r=r.parent,i+=1;return i}get inCaptureSelection(){let i=this;for(;i;){if(i.captureSelection)return!0;i=i.parent}return!1}get parentPrompt(){let i=this.parent;for(;i;){if(i.type==="prompt"&&!i.captureSelection)return i;i=i.parent}return null}branch(i){if(_s(i)&&this._branches)return this._branches[i]}get branches(){if(!this._branches)return[];const i=[];for(const r of Cs)this._branches[r]&&i.push(r);return i}createBranch(i){return console.assert(_s(i)),_s(i)?(this._branches?this._branches[i]||(this._branches[i]=[this.makeFirstAtom(i)]):this._branches={[i]:[this.makeFirstAtom(i)]},this.isDirty=!0,this._branches[i]):[]}get row(){return ku(this.parentBranch)?this.parentBranch[0]:-1}get col(){return ku(this.parentBranch)?this.parentBranch[1]:-1}get body(){var i;return(i=this._branches)==null?void 0:i.body}set body(i){this.setChildren(i,"body")}get superscript(){var i;return(i=this._branches)==null?void 0:i.superscript}set superscript(i){this.setChildren(i,"superscript")}get subscript(){var i;return(i=this._branches)==null?void 0:i.subscript}set subscript(i){this.setChildren(i,"subscript")}get above(){var i;return(i=this._branches)==null?void 0:i.above}set above(i){this.setChildren(i,"above")}get below(){var i;return(i=this._branches)==null?void 0:i.below}set below(i){this.setChildren(i,"below")}get computedStyle(){var i,r;const a=typeof this.style.verbatimColor=="string",u=typeof this.style.verbatimBackgroundColor=="string",p=P(P({},(r=(i=this.parent)==null?void 0:i.computedStyle)!=null?r:{}),this.style);return delete p.variant,delete p.variantStyle,u||delete p.verbatimBackgroundColor,a||delete p.verbatimColor,p}applyStyle(i){this.isDirty=!0,this.style=P(P({},this.style),i),this.style.fontFamily==="none"&&delete this.style.fontFamily,this.style.fontShape==="auto"&&delete this.style.fontShape,this.style.fontSeries==="auto"&&delete this.style.fontSeries,this.style.color==="none"&&(delete this.style.color,delete this.style.verbatimColor),this.style.backgroundColor==="none"&&(delete this.style.backgroundColor,delete this.style.verbatimBackgroundColor),this.style.fontSize==="auto"&&delete this.style.fontSize;for(const r of this.children)r.applyStyle(i)}getInitialBaseElement(){var i,r,a;return this.hasEmptyBranch("body")?this:(console.assert(((i=this.body)==null?void 0:i[0].type)==="first"),(a=(r=this.body[1])==null?void 0:r.getInitialBaseElement())!=null?a:this)}getFinalBaseElement(){return this.hasEmptyBranch("body")?this:this.body[this.body.length-1].getFinalBaseElement()}isCharacterBox(){return this.type==="leftright"||this.type==="genfrac"||this.type==="subsup"||this.type==="delim"||this.type==="array"||this.type==="surd"?!1:this.getFinalBaseElement().type==="mord"}hasEmptyBranch(i){const r=this.branch(i);return r?(console.assert(r.length>0),console.assert(r[0].type==="first"),r.length===1):!0}setChildren(i,r){var a;if(!i||(console.assert(_s(r)),!_s(r)))return;console.assert(((a=i[0])==null?void 0:a.type)!=="first");const u=[this.makeFirstAtom(r),...i];this._branches?this._branches[r]=u:this._branches={[r]:u};for(const p of i)p.parent=this,p.parentBranch=r;this.isDirty=!0}makeFirstAtom(i){const r=new wo({type:"first",mode:this.mode});return r.parent=this,r.parentBranch=i,r}addChild(i,r){console.assert(i.type!=="first"),this.createBranch(r).push(i),this.isDirty=!0,i.parent=this,i.parentBranch=r}addChildBefore(i,r){console.assert(r.parentBranch!==void 0);const a=this.createBranch(r.parentBranch);a.splice(a.indexOf(r),0,i),this.isDirty=!0,i.parent=this,i.parentBranch=r.parentBranch}addChildAfter(i,r){console.assert(r.parentBranch!==void 0);const a=this.createBranch(r.parentBranch);a.splice(a.indexOf(r)+1,0,i),this.isDirty=!0,i.parent=this,i.parentBranch=r.parentBranch}addChildren(i,r){const a=this.createBranch(r);for(const u of i)u.parent=this,u.parentBranch=r,a.push(u);this.isDirty=!0}addChildrenAfter(i,r){console.assert(i.length===0||i[0].type!=="first"),console.assert(r.parentBranch!==void 0);const a=this.createBranch(r.parentBranch);a.splice(a.indexOf(r)+1,0,...i),this.isDirty=!0;for(const u of i)u.parent=this,u.parentBranch=r.parentBranch;return i[i.length-1]}removeBranch(i){const r=this.branch(i);if(_s(i)&&(this._branches[i]=void 0),!r)return[];for(const a of r)a.parent=void 0,a.parentBranch=void 0;return console.assert(r[0].type==="first"),r.shift(),this.isDirty=!0,r}removeChild(i){if(console.assert(i.parent===this),i.type==="first")return;const r=this.branch(i.parentBranch),a=r.indexOf(i);console.assert(a>=0),r.splice(a,1),this.isDirty=!0,i.parent=void 0,i.parentBranch=void 0}get siblings(){return this.parent?this.parent.branch(this.parentBranch):[]}get firstSibling(){return this.siblings[0]}get lastSibling(){const{siblings:i}=this;return i[i.length-1]}get isFirstSibling(){return this===this.firstSibling}get isLastSibling(){return this===this.lastSibling}get hasNoSiblings(){return this.siblings.length===1}get leftSibling(){console.assert(this.parent!==void 0);const i=this.parent.branch(this.parentBranch);return i[i.indexOf(this)-1]}get rightSibling(){console.assert(this.parent!==void 0);const i=this.parent.branch(this.parentBranch);return i[i.indexOf(this)+1]}get hasChildren(){return!!(this._branches&&this.children.length>0)}get firstChild(){return console.assert(this.hasChildren),this.children[0]}get lastChild(){console.assert(this.hasChildren);const{children:i}=this;return i[i.length-1]}get children(){if(this._children)return this._children;if(!this._branches)return[];const i=[];for(const r of Cs)if(this._branches[r])for(const a of this._branches[r])i.push(...a.children),i.push(a);return this._children=i,i}render(i){if(this.type==="first"&&!i.atomIdsSettings)return null;const r=Me(this.command,this.mode);if(r!=null&&r.render)return r.render(this,i);const a=new Si({parent:i},this.style);let u=this.createBox(a,{classes:this.parent?"":"ML__base"});return u?(!this.subsupPlacement&&(this.superscript||this.subscript)&&(u=this.attachSupsub(a,{base:u})),u.wrap(a)):null}attachSupsub(i,r){var a;const u=r.base,p=this.superscript,g=this.subscript;if(!p&&!g)return u;let b=null,w=null;const E=(a=r.isCharacterBox)!=null?a:this.isCharacterBox();let R=0;if(p){const Ve=new Si({parent:i,mathstyle:"superscript"});b=wo.createBox(Ve,p),E||(R=u.height-i.metrics.supDrop*Ve.scalingFactor)}let N=0;if(g){const Ve=new Si({parent:i,mathstyle:"subscript"});w=wo.createBox(Ve,g),E||(N=u.depth+i.metrics.subDrop*Ve.scalingFactor)}let Z;i.isDisplayStyle?Z=i.metrics.sup1:i.isCramped?Z=i.metrics.sup3:Z=i.metrics.sup2;const ue=.5/Po/i.scalingFactor;let me=null;if(w&&b){R=Math.max(R,Z,b.depth+.25*i.metrics.xHeight),N=Math.max(N,i.metrics.sub2);const Ve=i.metrics.defaultRuleThickness;if(R-b.depth-(w.height-N)<4*Ve){N=4*Ve-(R-b.depth)+w.height;const Ue=.8*i.metrics.xHeight-(R-b.depth);Ue>0&&(R+=Ue,N-=Ue)}const Ct=this.isExtensibleSymbol&&u.italic?-u.italic:0;me=new kr({individualShift:[{box:w,shift:N,marginLeft:Ct},{box:b,shift:-R}]}).wrap(i)}else w&&!b?(N=Math.max(N,i.metrics.sub1,w.height-.8*ua),me=new kr({shift:N,children:[{box:w,marginRight:ue,marginLeft:this.isCharacterBox()?-u.italic:0}]})):!w&&b&&(R=Math.max(R,Z,b.depth+.25*ua),me=new kr({shift:-R,children:[{box:b,marginRight:ue}]}));return new Tt([u,new Tt(me,{caret:this.caret,isSelected:this.isSelected,classes:"msubsup"})],{type:r.type})}attachLimits(i,r){const a=this.superscript?wo.createBox(new Si({parent:i,mathstyle:"superscript"},this.style),this.superscript):null,u=this.subscript?wo.createBox(new Si({parent:i,mathstyle:"subscript"},this.style),this.subscript):null;return!a&&!u?r.base.wrap(i):md(i,d(P({},r),{above:a,below:u}))}bind(i,r){if(!r||i.isPhantom||this.value==="\u200B")return r;let a=this.parent;for(;a&&!a.captureSelection;)a=a.parent;return a!=null&&a.captureSelection||(this.id||(this.id=i.makeID()),r.atomID=this.id),r}createBox(i,r){var a,u,p,g;const b=(a=this.value)!=null?a:this.body,w=(u=r==null?void 0:r.boxType)!=null?u:Rc(this.type);let E=(p=r==null?void 0:r.classes)!=null?p:"";this.mode==="text"&&(E+=" ML__text");const R=typeof b=="string"||b===void 0?new Tt(b!=null?b:null,{type:w,isSelected:this.isSelected,mode:this.mode,maxFontSize:i.scalingFactor,style:d(P({variant:"normal"},this.style),{fontSize:Math.max(1,i.size+i.mathstyle.sizeDelta)}),letterShapeStyle:i.letterShapeStyle,classes:E}):(g=wo.createBox(i,b,{type:w,classes:E}))!=null?g:new Tt(null);return i.isTight&&(R.isTight=!0),(this.mode!=="math"||this.style.variant==="main")&&(R.italic=0),R.right=R.italic,this.bind(i,R),this.caret&&!this.superscript&&!this.subscript&&(R.caret=this.caret),R}isDigit(){var i;return this.type==="mord"&&this.value?/^[\d,\.]$/.test(this.value):this.type==="group"&&((i=this.body)==null?void 0:i.length)===2?this.body[0].type==="first"&&this.body[1].value===",":!1}asDigit(){var i;return this.type==="mord"&&this.value&&/^[\d,\.]$/.test(this.value)?this.value:this.type==="group"&&((i=this.body)==null?void 0:i.length)===2&&this.body[0].type==="first"&&this.body[1].value===","?".":""}};function _d(e){let i;const r=[];let a=[];for(const u of e)if(!i&&!u.style)a.push(u);else{const p=u.computedStyle;i&&p.color===i.color&&p.backgroundColor===i.backgroundColor&&p.fontSize===i.fontSize?a.push(u):(a.length>0&&r.push(a),a=[u],i=p)}return a.length>0&&r.push(a),r}function vd(e,i,r){var a,u,p,g,b;if(!i||i.length===0)return null;const w=new Si({parent:e},r.style),E=!((a=w.atomIdsSettings)!=null&&a.groupNumbers);let R=[];if(i.length===1){const Z=i[0],ue=Z.render(w);ue&&(E&&Z.isSelected&&ue.selected(!0),R=[ue])}else{let Z="",ue=!0;for(const me of i){(u=w.atomIdsSettings)!=null&&u.groupNumbers&&Z&&(ue&&me.isDigit()||!ue&&Oc(me))&&(w.atomIdsSettings.overrideID=Z);const Ve=me.render(w);w.atomIdsSettings&&(w.atomIdsSettings.overrideID=void 0),Ve&&((p=w.atomIdsSettings)!=null&&p.groupNumbers&&((me.isDigit()||Oc(me))&&(!Z||ue!==me.isDigit())&&(ue=me.isDigit(),Z=(g=me.id)!=null?g:""),Z&&(!(me.isDigit()||Oc(me))||!me.hasEmptyBranch("superscript")||!me.hasEmptyBranch("subscript"))&&(Z="")),E&&me.isSelected&&Ve.selected(!0),R.push(Ve))}}if(R.length===0)return null;const N=new Tt(R,d(P({isTight:w.isTight},r),{type:(b=r.type)!=null?b:"lift"}));return N.isSelected=R.every(Z=>Z.isSelected),N.wrap(w)}function Oc(e){return e.mode==="text"}function yd(e){return e.map(i=>i===null?"<null>":Array.isArray(i)&&i[0]instanceof et?{atoms:i.map(r=>r.toJson())}:typeof i=="object"&&"group"in i?{group:i.group.map(r=>r.toJson())}:i)}var No=class zp extends et{constructor(i,r,a){super({type:"text",command:i,mode:"text",displayContainsHighlight:!0}),this.value=r,this.verbatimLatex=r,this.applyStyle(a)}static fromJson(i){return new zp(i.command,i.value,i.style)}render(i){const r=this.createBox(i);return this.caret&&(r.caret=this.caret),r}_serialize(i){var r;return(r=this.verbatimLatex)!=null?r:ft("text",this.value.codePointAt(0))}};function bd(e,i){if(e.direction===i.direction){const r=e.ranges.length;if(i.ranges.length===r){let a=0;for(;a<r&&Tu(e.ranges[a],i.ranges[a])==="equal";)a++;return a===r?"equal":"different"}}return"different"}function Tu(e,i){return e[0]===i[0]&&e[1]===i[1]?"equal":"different"}function Fr(e){let i=1/0,r=-1/0;for(const a of e.ranges)i=Math.min(i,a[0],a[1]),r=Math.max(r,a[0],a[1]);return[i,r]}function zs(e){return typeof e=="number"&&!Number.isNaN(e)}function Fc(e){return Array.isArray(e)&&e.length===2}function Au(e){return e!=null&&typeof e=="object"&&"ranges"in e&&Array.isArray(e.ranges)}function af(e,i){const r=e.at(i);let a;if(r){a=r.mode;let u=r.parent;for(;!a&&u;)u&&(a=u.mode),u=u.parent}return a}function of(e,i){if(!i)return"";if(typeof i=="string")return i;if(!e||i.after===void 0)return i.value;let r=!1,a=!1,u=!1,p=!1,g=!1,b=!1,w=!1,E=!1,R=!1,N=!1,Z=!1,ue=!1,me=!1,Ve=!1,Ct=!1,Ue=e[0],ct=0;for(;Ue!=null&&Ue.type&&/^(subsup|placeholder)$/.test(Ue.type);)ct+=1,Ue=e[ct];return r=!Ue||Ue.type==="first",Ue&&(Ve=Ue.mode==="text",a=!Ve&&Ue.type==="mord"&&ve.test(Ue.value),u=!Ve&&Ue.type==="mord"&&/\d+$/.test(Ue.value),p=!Ve&&Ue.isFunction,g=Ue.type==="genfrac",b=Ue.type==="surd",w=Ue.type==="mbin",E=Ue.type==="mrel",R=Ue.type==="mop"||Ue.type==="operator"||Ue.type==="extensible-symbol",N=Ue.type==="mpunct"||Ue.type==="minner",Z=Ue.type==="array",ue=Ue.type==="mopen",me=Ue.type==="mclose"||Ue.type==="leftright",Ct=Ue.type==="space"),i.after.includes("nothing")&&r||i.after.includes("letter")&&a||i.after.includes("digit")&&u||i.after.includes("function")&&p||i.after.includes("frac")&&g||i.after.includes("surd")&&b||i.after.includes("binop")&&w||i.after.includes("relop")&&E||i.after.includes("operator")&&R||i.after.includes("punct")&&N||i.after.includes("array")&&Z||i.after.includes("openfence")&&ue||i.after.includes("closefence")&&me||i.after.includes("text")&&Ve||i.after.includes("space")&&Ct?i.value:""}function Sl(e,i,r){return r?of(e,r[i]):""}var lf={"&":"\\&","%":"\\%",$:"\\$","''":"^{\\doubleprime}","'''":"^{\\prime\\prime\\prime}","''''":"^{\\prime\\prime\\prime\\prime}",alpha:"\\alpha",delta:"\\delta",Delta:"\\Delta",pi:"\\pi",Pi:"\\Pi",theta:"\\theta",Theta:"\\Theta",ii:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\imaginaryI"},jj:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\imaginaryJ"},ee:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\exponentialE"},nabla:"\\nabla",grad:"\\nabla",del:"\\partial",deg:{after:"digit+space",value:"\\degree"},infty:"\\infty","\u221E":"\\infty",oo:{after:"nothing+digit+frac+surd+binop+relop+punct+array+openfence+closefence+space",value:"\\infty"},"\u2211":"\\sum",sum:"\\sum_{#?}^{#?}",int:"\\int_{#?}^{#?}",prod:"\\prod_{#?}^{#?}",sqrt:"\\sqrt{#?}","\u2206":"\\differentialD","\u2202":"\\differentialD",arcsin:"\\arcsin",arccos:"\\arccos",arctan:"\\arctan",arcsec:"\\arcsec",arccsc:"\\arccsc",arsinh:"\\arsinh",arcosh:"\\arcosh",artanh:"\\artanh",arcsech:"\\arcsech",arccsch:"\\arccsch",arg:"\\arg",ch:"\\ch",cosec:"\\cosec",cosh:"\\cosh",cot:"\\cot",cotg:"\\cotg",coth:"\\coth",csc:"\\csc",ctg:"\\ctg",cth:"\\cth",sec:"\\sec",sinh:"\\sinh",sh:"\\sh",tanh:"\\tanh",tg:"\\tg",th:"\\th",sin:"\\sin",cos:"\\cos",tan:"\\tan",lg:"\\lg",lb:"\\lb",log:"\\log",ln:"\\ln",exp:"\\exp",lim:"\\lim_{#?}",dx:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\differentialD x"},dy:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\differentialD y"},dt:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\differentialD t"},AA:"\\forall",EE:"\\exists","!EE":"\\nexists","&&":"\\land",xin:{after:"nothing+text+relop+punct+openfence+space",value:"x \\in"},sint:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\sin t"},in:{after:"nothing+letter+closefence",value:"\\in"},"!in":"\\notin",NN:"\\mathbb{N}",ZZ:"\\Z",QQ:"\\Q",RR:"\\R",CC:"\\C",xx:"\\times","+-":"\\pm","\u2260":"\\ne","!=":"\\ne","\u2265":"\\ge",">=":"\\ge","\u2264":"\\le","<=":"\\le","<<":"\\ll",">>":"\\gg","~~":"\\approx","\u2248":"\\approx","?=":"\\questeq","\xF7":"\\div","\xAC":"\\neg",":=":"\\coloneq","::":"\\Colon","(:":"\\langle",":)":"\\rangle",beta:"\\beta",chi:"\\chi",epsilon:"\\epsilon",varepsilon:"\\varepsilon",eta:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\eta"},gamma:"\\gamma",Gamma:"\\Gamma",iota:"\\iota",kappa:"\\kappa",lambda:"\\lambda",Lambda:"\\Lambda",mu:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\mu"},nu:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\nu"},\u00B5:"\\mu",phi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\phi"},Phi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\Phi"},varphi:"\\varphi",psi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\psi"},Psi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\Psi"},rho:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\rho"},sigma:"\\sigma",Sigma:"\\Sigma",tau:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\tau"},vartheta:"\\vartheta",upsilon:"\\upsilon",xi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space",value:"\\xi"},Xi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\Xi"},zeta:"\\zeta",omega:"\\omega",Omega:"\\Omega",\u03A9:"\\omega",forall:"\\forall",exists:"\\exists","!exists":"\\nexists",":.":"\\therefore",liminf:"\\liminf_{#?}",limsup:"\\limsup_{#?}",argmin:"\\operatorname*{arg~min}_{#?}",argmax:"\\operatorname*{arg~max}_{#?}",det:"\\det",mod:"\\bmod{#?}","(mod":"\\pmod{#?}",max:"\\max",min:"\\min",erf:"\\operatorname{erf}",erfc:"\\operatorname{erfc}",bessel:"\\operatorname{bessel}",mean:"\\operatorname{mean}",median:"\\operatorname{median}",fft:"\\operatorname{fft}",lcm:"\\operatorname{lcm}",gcd:"\\operatorname{gcd}",randomReal:"\\operatorname{randomReal}",randomInteger:"\\operatorname{randomInteger}",Re:"\\operatorname{Re}",Im:"\\operatorname{Im}",mm:{after:"nothing+digit+operator",value:"\\operatorname{mm}"},cm:{after:"nothing+digit+operator",value:"\\operatorname{cm}"},km:{after:"nothing+digit+operator",value:"\\operatorname{km}"},kg:{after:"nothing+digit+operator",value:"\\operatorname{kg}"},"...":"\\ldots","+...":"+\\cdots","-...":"-\\cdots","->...":"\\to\\cdots","-->...":"\\longrightarrow\\cdots","->":"\\to","|->":"\\mapsto","-->":"\\longrightarrow","<--":"\\longleftarrow","=>":"\\Rightarrow","==>":"\\Longrightarrow","<=>":"\\Leftrightarrow","<->":"\\leftrightarrow","(.)":"\\odot","(+)":"\\oplus","(/)":"\\oslash","(*)":"\\otimes","(-)":"\\ominus","||":"\\Vert","*":"\\cdot","**":"\\star","***":"\\ast","//":"\\slash","\\\\":"\\backslash",setminus:"\\backslash","|><":"\\ltimes","><|":"\\rtimes","|><|":"\\bowtie","-:":"\\div",divide:"\\div","@":"\\circ","^^":"\\wedge","^^^":"\\bigwedge",vv:"\\vee",vvv:"\\bigvee",nn:"\\cap",nnn:"\\bigcap",uu:"\\cup",uuu:"\\bigcup","-=":"\\equiv","~=":"\\cong",lt:"<","lt=":"\\leq",gt:">","gt=":"\\geq","-<":"\\prec","-lt":"\\prec","-<=":"\\preceq",">-=":"\\succeq",prop:"\\propto",diamond:"\\diamond",square:"\\square",iff:"\\iff",sub:"\\subset",sup:"\\supset",sube:"\\subseteq",supe:"\\supseteq",uarr:"\\uparrow",darr:"\\downarrow",rarr:"\\rightarrow",rArr:"\\Rightarrow",larr:"\\leftarrow",lArr:"\\Leftarrow",harr:"\\leftrightarrow",hArr:"\\Leftrightarrow",aleph:"\\aleph",and:"\\land",or:"\\lor",not:"\\neg","_|_":"\\bot",TT:"\\top","|--":"\\vdash","|==":"\\models","|__":"\\lfloor","__|":"\\rfloor","|~":"\\lceil","~|":"\\rceil",">->":"\\rightarrowtail","->>":"\\twoheadrightarrow",">->>":"\\twoheadrightarrowtail",frac:"\\frac{#?}{#?}",cbrt:"\\sqrt[3]{#?}",nthroot:"\\sqrt[#?]{#?}"};function Lu(e,i){var r;let a=(r=i==null?void 0:i.format)!=null?r:"auto";return a==="auto"&&([a,e]=xd(e)),a==="ascii-math"?(e=e.replace(/\u2061/gu,""),e=e.replace(/\u3016/gu,"{"),e=e.replace(/\u3017/gu,"}"),e=e.replace(/([^\\])sinx/g,"$1\\sin x"),e=e.replace(/([^\\])cosx/g,"$1\\cos x "),e=e.replace(/\u2013/g,"-"),["ascii-math",Ur(e,{inlineShortcuts:i==null?void 0:i.inlineShortcuts})]):["latex",e]}function Ur(e,i){var r,a,u;if(!e)return"";let p=!1,g;const b=(r=i.inlineShortcuts)!=null?r:lf;if(!p&&(e.startsWith("^")||e.startsWith("_"))&&(g=ao(e.slice(1),{inlineShortcuts:b,noWrap:!0}),e=e[0]+"{"+g.match+"}",e+=Ur(g.rest,i),p=!0),p||(g=e.match(/^(sqrt|\u221A)(.*)/),g&&(g=ao(g[2],{inlineShortcuts:b,noWrap:!0}),e="\\sqrt{"+((a=g.match)!=null?a:"\\placeholder{}")+"}",e+=Ur(g.rest,i),p=!0)),p||(g=e.match(/^(\\cbrt|\u221B)(.*)/),g&&(g=ao(g[2],{inlineShortcuts:b,noWrap:!0}),e="\\sqrt[3]{"+((u=g.match)!=null?u:"\\placeholder{}")+"}",e+=Ur(g.rest,i),p=!0)),p||(g=e.match(/^abs(.*)/),g&&(g=ao(g[1],{inlineShortcuts:b,noWrap:!0}),e="\\left|"+g.match+"\\right|",e+=Ur(g.rest,i),p=!0)),p||(g=e.match(/^["”“](.*?)["”“](.*)/),g&&(e="\\text{"+g[1]+"}",e+=Ur(g[2],i),p=!0)),p||(g=e.match(/^([^a-zA-Z\(\{\[\_\^\\\s"]+)(.*)/),g&&(e=Bc(g[1],b),e+=Ur(g[2],i),p=!0)),!p&&/^([fgh])[^a-zA-Z]/.test(e)&&(g=ao(e.slice(1),{inlineShortcuts:b,noWrap:!0}),e=e[1]==="("?e[0]+"\\left("+g.match+"\\right)":e[0]+g.match,e+=Ur(g.rest,i),p=!0),p||(g=e.match(/^([a-zA-Z]+)(.*)/),g&&(e=Bc(g[1],b),e+=Ur(g[2],i),p=!0)),!p)if(g=ao(e,{inlineShortcuts:b,noWrap:!0}),g.match&&g.rest[0]==="/"){const w=ao(g.rest.slice(1),{inlineShortcuts:b,noWrap:!0});w.match&&(e="\\frac{"+g.match+"}{"+w.match+"}"+Ur(w.rest,i)),p=!0}else g.match&&(e=e.startsWith("(")?"\\left("+g.match+"\\right)"+Ur(g.rest,i):g.match+Ur(g.rest,i),p=!0);return p||(g=e.match(/^(\s+)(.*)$/),g&&(e=" "+Ur(g[2],i),p=!0)),e}function ao(e,i){let r="";e=e.trim();let a=e,u=e.charAt(0),p={"(":")","{":"}","[":"]"}[u];if(p){let g=1,b=1;for(;b<e.length&&g>0;)e[b]===u&&g++,e[b]===p&&g--,b++;g===0?(i.noWrap&&u==="("?r=Ur(e.substring(1,b-1),i):(u==="{"&&p==="}"&&(u="\\{",p="\\}"),r="\\left"+u+Ur(e.substring(1,b-1),i)+"\\right"+p),a=e.slice(Math.max(0,b))):(r=e.substring(1,b),a="")}else{let g=e.match(/^([a-zA-Z]+)/);if(g){let b=Sl(null,e,i.inlineShortcuts);if(b)return b=b.replace("_{#?}",""),b=b.replace("^{#?}",""),{match:b,rest:e.slice(b.length)}}if(g=e.match(/^([a-zA-Z])/),g)return{match:g[1],rest:e.slice(1)};if(g=e.match(/^(-)?\d+(\.\d*)?/),g)return{match:g[0],rest:e.slice(g[0].length)};/^\\(left|right)/.test(e)||(g=e.match(/^(\\[a-zA-Z]+)/),g&&(a=e.slice(g[1].length),r=g[1]))}return{match:r,rest:a}}function Bc(e,i){let r=Sl(null,e,i);return r?(r=r.replace("_{#?}",""),r=r.replace("^{#?}",""),r+=" "):r=e,r}var uf=[["\\[","\\]"],["\\(","\\)"],["$$","$$"],["$","$"],["\\begin{math}","\\end{math}"],["\\begin{displaymath}","\\end{displaymath}"],["\\begin{equation}","\\end{equation}"],["\\begin{equation*}","\\end{equation*}"]];function Nc(e){const i=e.trim();for(const r of uf)if(i.startsWith(r[0])&&i.endsWith(r[1]))return[!0,i.substring(r[0].length,i.length-r[1].length)];return[!1,e]}function xd(e){if(e=e.trim(),e.length<=1)return["latex",e];let i;return[i,e]=Nc(e),i?["latex",e]:e.startsWith("`")&&e.endsWith("`")?(e=e.substring(1,e.length-1),["ascii-math",e]):e.includes("\\")?["latex",e]:/\$.+\$/.test(e)?["latex",`\\text{${e}}`]:[void 0,e]}var wd="$$",Sd="$$",Ed=(e,i,r)=>(uf.some(a=>i.startsWith(a[0])&&i.endsWith(a[1]))||(i=`${wd} ${i} ${Sd}`),i),$c=class ad{constructor(i){ad._modes[i]=this}static onPaste(i,r,a){var u;if(!r.contentEditable&&r.userSelect==="none")return r.model.announce("plonk"),!1;if(typeof a=="string"){const g=new DataTransfer;g.setData("text/plain",a),a=g}const p=new ClipboardEvent("paste",{clipboardData:a,cancelable:!0});return(u=r.host)!=null&&u.dispatchEvent(p)?ad._modes[i].onPaste(r,a):!1}static copyToClipboard(i,r){if(!i.contentEditable&&i.userSelect==="none"){i.model.announce("plonk");return}const a=i.model,u=a.selectionIsCollapsed?[0,a.lastOffset]:Fr(a.selection),p=a.getValue(u,r);navigator.clipboard.writeText(p).then(()=>{},()=>i.model.announce("plonk"))}static onCopy(i,r){var a;if(!r.clipboardData)return;if(!i.contentEditable&&i.userSelect==="none"){i.model.announce("plonk");return}const u=i.model,p=u.selectionIsCollapsed?[0,u.lastOffset]:Fr(u.selection);let g=u.getAtoms(p);if(g.every(b=>b.mode==="text"||!b.mode))r.clipboardData.setData("text/plain",g.filter(b=>b instanceof No).map(b=>b.value).join(""));else if(g.every(b=>b.mode==="latex"))r.clipboardData.setData("text/plain",u.getAtoms(p,{includeChildren:!0}).map(b=>{var w;return(w=b.value)!=null?w:""}).join(""));else{let b;g.length===1&&g[0].verbatimLatex!==void 0?b=g[0].verbatimLatex:b=u.getValue(p,"latex-expanded"),r.clipboardData.setData("application/x-latex",b);try{r.clipboardData.setData("text/plain",i.options.onExport(i,b,p))}catch(w){}if(g.length===1){const w=g[0];(w.type==="root"||w.type==="group")&&(g=w.body.filter(E=>E.type!=="first"))}try{r.clipboardData.setData("application/json+mathlive",JSON.stringify(g.map(w=>w.toJson())))}catch(w){}if((a=window[Symbol.for("io.cortexjs.compute-engine")])!=null&&a.ComputeEngine){const w=window.MathfieldElement.computeEngine;if(w)try{const E=w.jsonSerializationOptions;w.jsonSerializationOptions={metadata:["latex"]};const R=w.parse(u.getValue(p,"latex-unstyled"));w.jsonSerializationOptions=E;const N=JSON.stringify(R.json);N&&r.clipboardData.setData("application/json",N)}catch(E){}}}r.preventDefault()}static insert(i,r,a={}){var u;const p=a.mode==="auto"?i.mode:(u=a.mode)!=null?u:i.mode;return ad._modes[p].insert(i,r,a)}onPaste(i,r){return!1}insert(i,r,a){return!1}};$c._modes={};var qn=$c,kd=[{key:"left",command:"moveToPreviousChar"},{key:"right",command:"moveToNextChar"},{key:"up",command:"moveUp"},{key:"down",command:"moveDown"},{key:"shift+[ArrowLeft]",command:"extendSelectionBackward"},{key:"shift+[ArrowRight]",command:"extendSelectionForward"},{key:"shift+[ArrowUp]",command:"extendSelectionUpward"},{key:"shift+[ArrowDown]",command:"extendSelectionDownward"},{key:"[Backspace]",command:"deleteBackward"},{key:"alt+[Delete]",command:"deleteBackward"},{key:"[Delete]",command:"deleteForward"},{key:"alt+[Backspace]",command:"deleteForward"},{key:"alt+[ArrowLeft]",command:"moveToPreviousWord"},{key:"alt+[ArrowRight]",command:"moveToNextWord"},{key:"shift+alt+[ArrowLeft]",command:"extendToPreviousWord"},{key:"shift+alt+[ArrowRight]",command:"extendToNextWord"},{key:"ctrl+[ArrowLeft]",command:"moveToGroupStart"},{key:"ctrl+[ArrowRight]",command:"moveToGroupEnd"},{key:"shift+ctrl+[ArrowLeft]",command:"extendToGroupStart"},{key:"shift+ctrl+[ArrowRight]",command:"extendToGroupEnd"},{key:"[Home]",command:"moveToMathfieldStart"},{key:"cmd+[ArrowLeft]",command:"moveToMathfieldStart"},{key:"shift+[Home]",command:"extendToMathFieldStart"},{key:"shift+cmd+[ArrowLeft]",command:"extendToMathFieldStart"},{key:"[End]",command:"moveToMathfieldEnd"},{key:"cmd+[ArrowRight]",command:"moveToMathfieldEnd"},{key:"shift+[End]",command:"extendToMathFieldEnd"},{key:"shift+cmd+[ArrowRight]",command:"extendToMathFieldEnd"},{key:"[Pageup]",command:"moveToGroupStart"},{key:"[Pagedown]",command:"moveToGroupEnd"},{key:"[Tab]",command:"moveToNextGroup"},{key:"shift+[Tab]",command:"moveToPreviousGroup"},{key:"[Escape]",ifMode:"math",command:["switchMode","latex"]},{key:"[Escape]",ifMode:"text",command:["switchMode","latex"]},{key:"[Escape]",ifMode:"latex",command:["complete","complete",{selectItem:"true"}]},{key:"\\",ifMode:"math",command:["switchMode","latex","\\"]},{key:"[IntlBackslash]",ifMode:"math",command:["switchMode","latex","\\"]},{key:"[Tab]",ifMode:"latex",command:["complete","accept-suggestion"]},{key:"[Return]",ifMode:"latex",command:"complete"},{key:"[Enter]",ifMode:"latex",command:"complete"},{key:"shift+[Escape]",ifMode:"latex",command:["complete","reject"]},{key:"[ArrowDown]",ifMode:"latex",command:"nextSuggestion"},{key:"[ArrowUp]",ifMode:"latex",command:"previousSuggestion"},{key:"ctrl+a",ifPlatform:"!macos",command:"selectAll"},{key:"cmd+a",command:"selectAll"},{key:"[Cut]",command:"cutToClipboard"},{key:"[Copy]",command:"copyToClipboard"},{key:"[Paste]",command:"pasteFromClipboard"},{key:"[Clear]",command:"deleteBackward"},{key:"[Undo]",command:"undo"},{key:"[Redo]",command:"redo"},{key:"[EraseEof]",command:"deleteToGroupEnd"},{key:"ctrl+x",ifPlatform:"ios",command:"cutToClipboard"},{key:"cmd+x",ifPlatform:"ios",command:"cutToClipboard"},{key:"ctrl+c",ifPlatform:"ios",command:"copyToClipboard"},{key:"cmd+c",ifPlatform:"ios",command:"copyToClipboard"},{key:"ctrl+v",ifPlatform:"ios",command:"pasteFromClipboard"},{key:"cmd+v",ifPlatform:"ios",command:"pasteFromClipboard"},{key:"ctrl+z",ifPlatform:"!macos",command:"undo"},{key:"cmd+z",command:"undo"},{key:"ctrl+y",ifPlatform:"!macos",command:"redo"},{key:"shift+cmd+y",command:"redo"},{key:"shift+ctrl+z",ifPlatform:"!macos",command:"redo"},{key:"shift+cmd+z",command:"redo"},{key:"ctrl+b",ifPlatform:"macos",command:"moveToPreviousChar"},{key:"ctrl+f",ifPlatform:"macos",command:"moveToNextChar"},{key:"ctrl+p",ifPlatform:"macos",command:"moveUp"},{key:"ctrl+n",ifPlatform:"macos",command:"moveDown"},{key:"ctrl+a",ifPlatform:"macos",command:"moveToMathfieldStart"},{key:"ctrl+e",ifPlatform:"macos",command:"moveToMathfieldEnd"},{key:"shift+ctrl+b",ifPlatform:"macos",command:"extendSelectionBackward"},{key:"shift+ctrl+f",ifPlatform:"macos",command:"extendSelectionForward"},{key:"shift+ctrl+p",ifPlatform:"macos",command:"extendSelectionUpward"},{key:"shift+ctrl+n",ifPlatform:"macos",command:"extendSelectionDownward"},{key:"shift+ctrl+a",ifPlatform:"macos",command:"extendToMathFieldStart"},{key:"shift+ctrl+e",ifPlatform:"macos",command:"extendToMathFieldEnd"},{key:"alt+ctrl+b",ifPlatform:"macos",command:"moveToPreviousWord"},{key:"alt+ctrl+f",ifPlatform:"macos",command:"moveToNextWord"},{key:"shift+alt+ctrl+b",ifPlatform:"macos",command:"extendToPreviousWord"},{key:"shift+alt+ctrl+f",ifPlatform:"macos",command:"extendToNextWord"},{key:"ctrl+h",ifPlatform:"macos",command:"deleteBackward"},{key:"ctrl+d",ifPlatform:"macos",command:"deleteForward"},{key:"ctrl+l",ifPlatform:"macos",command:"scrollIntoView"},{key:"ctrl+[Digit2]",ifMode:"math",command:["insert","\\sqrt{#0}"]},{key:"ctrl+[Digit5]",ifMode:"math",command:"moveToOpposite"},{key:"ctrl+[Digit6]",ifMode:"math",command:"moveToSuperscript"},{key:"ctrl+[Return]",ifMode:"math",command:"addRowAfter"},{key:"ctrl+[Enter]",ifMode:"math",command:"addRowAfter"},{key:"cmd+[Return]",ifMode:"math",command:"addRowAfter"},{key:"cmd+[Enter]",ifMode:"math",command:"addRowAfter"},{key:"alt+p",ifMode:"math",command:["insert","\\pi"]},{key:"alt+v",ifMode:"math",command:["insert","\\sqrt{#0}"]},{key:"alt+o",ifMode:"math",command:["insert","\\emptyset"]},{key:"alt+d",ifMode:"math",command:["insert","\\differentialD"]},{key:"shift+alt+o",ifMode:"math",command:["insert","\\varnothing"]},{key:"shift+alt+d",ifMode:"math",command:["insert","\\partial"]},{key:"alt+[Backslash]",ifMode:"math",command:["insert","\\backslash"]},{key:"[NumpadDivide]",ifMode:"math",command:["insert","\\frac{#@}{#?}"]},{key:"alt+[NumpadDivide]",ifMode:"math",command:["insert","\\frac{#?}{#@}"]},{key:"shift+alt+k",command:"toggleKeystrokeCaption"},{key:"alt+[Space]",command:"toggleContextMenu"},{key:"alt+shift+[Space]",command:"toggleVirtualKeyboard"},{key:"alt+ctrl+[ArrowUp]",command:["speak","all",{withHighlighting:!1}]},{key:"alt+ctrl+[ArrowDown]",command:["speak","selection",{withHighlighting:!1}]},{key:"shift+[Quote]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["switchMode","text","",""]},{key:"shift+alt+[KeyT]",ifMode:"math",command:["switchMode","text","",""]},{key:"shift+[Quote]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"text",command:["switchMode","math","",""]},{key:"shift+alt+[KeyT]",ifMode:"text",command:["switchMode","math","",""]},{key:"/",ifMode:"math",command:["insert","\\frac{#@}{#?}"]},{key:"alt+/",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","/"]},{key:"alt+shift+/",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","/"]},{key:"alt+[BracketLeft]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","\\left\\lbrack #0 \\right\\rbrack"]},{key:"ctrl+[Minus]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"moveToSubscript"},{key:"shift+alt+[BracketLeft]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","\\left\\lbrace #0 \\right\\rbrace"]},{key:"ctrl+;",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"addRowAfter"},{key:"cmd+;",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"addRowAfter"},{key:"shift+ctrl+;",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"addRowBefore"},{key:"shift+cmd+;",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"addRowBefore"},{key:"ctrl+[Backspace]",ifMode:"math",command:"removeRow"},{key:"cmd+[Backspace]",ifMode:"math",command:"removeRow"},{key:"alt+[Tab]",ifMode:"math",command:"addColumnAfter"},{key:"shift+alt+[Tab]",ifMode:"math",command:"addColumnBefore"},{key:"alt+[Enter]",ifMode:"math",command:"addRowAfter"},{key:"shift+alt+[Enter]",ifMode:"math",command:"addRowBefore"},{key:"alt+[Return]",ifMode:"math",command:"addRowAfter"},{key:"shift+alt+[Return]",ifMode:"math",command:"addRowBefore"},{key:"shift+[Backspace]",ifMode:"math",command:"removeColumn"},{key:"alt+[Digit5]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","$\\infty"]},{key:"alt+[Digit9]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","("]},{key:"alt+[Digit0]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert",")"]},{key:"alt+|",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","|"]},{key:"shift+[Backquote]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","\\~"]},{key:"[Backquote]",ifLayout:["windows.french","linux.french"],ifMode:"math",command:["insert","^2"]},{key:"[Backquote]",ifLayout:["windows.german","linux.german"],ifMode:"math",command:["insert","^"]},{key:"[IntlBackslash]",ifLayout:["apple.german"],ifMode:"math",command:["insert","^"]}],Td={"\\sqrt":["alt+v","ctrl+[Digit2]"],"\\pi":"alt+p","\\infty":"alt+[Digit5]","\\differentialD":"alt+d","\\partial":"shift+alt+d","\\frac":"Slash","\\emptyset":"alt+o","\\varnothing":"shift+alt+o","\\~":"~"};function oo(e){var i;return((i=e.element)==null?void 0:i.mathfield)===e}function Ad(e){var i,r;return(r=(i=e.querySelector(".ML__caret"))!=null?i:e.querySelector(".ML__text-caret"))!=null?r:e.querySelector(".ML__latex-caret")}function El(e){const i=Ad(e);if(!i)return null;const r=i.getBoundingClientRect();return{x:r.right,y:r.bottom,height:r.height}}function cf(e){var i;if(!e.parent)return"root";let r=(i=e.parent.id)!=null?i:"";return r+=typeof e.parentBranch=="string"?"-"+e.parentBranch:`-${e.parentBranch[0]}/${e.parentBranch[0]}`,r}function hf(e,i,r){if(!i)return null;const a=e.field.getBoundingClientRect(),u=i.right-i.left,p=i.bottom-i.top,g=Math.ceil(i.left-a.left+e.field.scrollLeft*r),b=Math.ceil(i.top-a.top);return{left:g,right:g+u,top:b,bottom:b+p}}function ff(e){const i=e.getBoundingClientRect(),r=parseInt(getComputedStyle(e).marginRight),a={top:i.top-1,bottom:i.bottom,left:i.left,right:i.right-1+r};if(e.children.length===0||e.tagName.toUpperCase()==="SVG")return a;for(const u of e.children)if(u.nodeType===1&&"atomId"in u.dataset&&!u.classList.contains("pstrut")){const p=ff(u);a.left=Math.min(a.left,p.left),a.right=Math.max(a.right,p.right),a.top=Math.min(a.top,p.top),a.bottom=Math.max(a.bottom,p.bottom)}return a}function kl(e,i){var r,a;if(!i.id)return null;let u=(a=(r=e.atomBoundsCache)==null?void 0:r.get(i.id))!=null?a:null;if(u!==null)return u;const p=e.field.querySelector(`[data-atom-id="${i.id}"]`);return u=p?ff(p):null,e.atomBoundsCache&&(u?e.atomBoundsCache.set(i.id,u):e.atomBoundsCache.delete(i.id)),u!=null?u:null}function Ld(e,i,r){const a=new Map;for(const u of e.model.getAtoms(i,{includeChildren:!0})){if(r!=null&&r.excludeAtomsWithBackground&&u.style.backgroundColor)continue;const p=e.field,g=p.offsetWidth;let w=Math.floor(p.getBoundingClientRect().width)/g;w=isNaN(w)?1:w;const E=hf(e,kl(e,u),w);if(E){const R=cf(u);if(a.has(R)){const N=a.get(R);a.set(R,{left:Math.min(N.left,E.left),right:Math.max(N.right,E.right),top:Math.min(N.top,E.top),bottom:Math.max(N.bottom,E.bottom)})}else a.set(R,E)}}return[...a.values()]}function Kc(e,i){return e.model.selection.ranges.reduce((r,a)=>r.concat(...Ld(e,a,i)),[])}function Du(e,i){return e==="*"||i==="none"?!0:i==="same-origin"?!window.origin||e===window.origin:typeof i=="function"?i(e):!1}function lo(e){let i=0,r=0;const a=e.offsetWidth,u=e.offsetHeight;for(;e instanceof HTMLElement;)i+=e.offsetTop,r+=e.offsetLeft,e=e.offsetParent;return new DOMRect(r,i,a,u)}var Cu=`@keyframes ML__caret-blink {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0;
}
}
.ML__container {
display: inline-flex;
flex-flow: row;
justify-content: space-between;
align-items: flex-end;
min-height: 39px;
/* Need some room for the virtual keyboard toggle */
width: 100%;
/* Encourage browsers to consider allocating a hardware accelerated
layer for this element. */
isolation: isolate;
/* Prevent the browser from trying to interpret touch gestures in the field */
/* "Disabling double-tap to zoom removes the need for browsers to
delay the generation of click events when the user taps the screen." */
touch-action: none;
--_caret-color: var(--caret-color, hsl(var(--_hue), 40%, 49%));
--_selection-color: var(--selection-color, #000);
--_selection-background-color: var(--selection-background-color, hsl(var(--_hue), 70%, 85%));
--_text-highlight-background-color: var(--highlight-text, hsla(var(--_hue), 40%, 50%, 0.1));
--_contains-highlight-background-color: var(--contains-highlight-background-color, hsl(var(--_hue), 40%, 95%));
--_smart-fence-color: var(--smart-fence-color, currentColor);
--_smart-fence-opacity: var(--smart-fence-opacity, 0.5);
--_latex-color: var(--latex-color, hsl(var(--_hue), 80%, 40%));
--_correct-color: var(--correct-color, #10a000);
--_incorrect-color: var(--incorrect-color, #a01b00);
--_composition-background-color: var(--composition-background-color, #fff1c2);
--_composition-text-color: var(--composition-text-color, black);
--_composition-underline-color: var(--composition-underline-color, transparent);
}
/* This is the actual field content (formula) */
.ML__content {
display: flex;
align-items: center;
align-self: center;
position: relative;
overflow: hidden;
padding: 2px 3px 2px 1px;
width: 100%;
}
.ML__virtual-keyboard-toggle,
.ML__menu-toggle {
box-sizing: border-box;
display: flex;
align-self: center;
align-items: center;
flex-shrink: 0;
flex-direction: column;
justify-content: center;
width: 34px;
height: 34px;
padding: 0;
margin-right: 4px;
cursor: pointer;
/* Avoid some weird blinking with :hover */
border-radius: 8px;
border: 1px solid transparent;
transition: background 0.2s cubic-bezier(0.64, 0.09, 0.08, 1);
color: hsl(var(--_hue), 40%, 50%);
fill: currentColor;
background: transparent;
}
.ML__virtual-keyboard-toggle:hover,
.ML__menu-toggle:hover {
background: hsla(0, 0%, 70%, 0.3);
color: #333;
fill: currentColor;
}
.ML__virtual-keyboard-toggle > span,
.ML__menu-toggle > span {
display: flex;
align-self: center;
align-items: center;
}
/* The invisible element used to capture keyboard events. We're just trying
really hard to make sure it doesn't show. */
.ML__keyboard-sink {
display: inline-block;
resize: none;
outline: none;
border: none;
/* Need these for Microsoft Edge */
position: fixed;
clip: rect(0 0 0 0);
/* Need this to prevent iOS Safari from auto-zooming */
font-size: 1em;
font-family: KaTeX_Main;
line-height: 0.5;
/* On Chromium, if this is 0, no keyboard events are received */
}
[part="placeholder"] {
color: var(--neutral-400);
}
.ML__composition {
background: var(--_composition-background-color);
color: var(--_composition-text-color);
text-decoration: underline var(--_composition-underline-color);
}
.ML__caret::after {
content: '';
visibility: hidden;
width: 0;
display: inline-block;
height: 0.76em;
--_caret-width: clamp(2px, 0.08em, 10px);
border: none;
border-radius: calc(var(--_caret-width) / 2);
border-right: var(--_caret-width) solid var(--_caret-color);
margin-right: calc(-1 * var(--_caret-width));
position: relative;
left: -0.045em;
bottom: -0.05em;
animation: ML__caret-blink 1.05s step-end forwards infinite;
}
.ML__text-caret::after {
content: '';
visibility: hidden;
width: 0;
display: inline-block;
height: 0.76em;
--_caret-width: clamp(2px, 0.08em, 10px);
border: none;
border-radius: calc(var(--_caret-width) / 2);
border-right: var(--_caret-width) solid var(--_caret-color);
margin-right: calc(-1 * var(--_caret-width));
position: relative;
left: -0.045em;
bottom: -0.05em;
animation: ML__caret-blink 1.05s step-end forwards infinite;
}
.ML__latex-caret::after {
content: '';
visibility: hidden;
--_caret-width: clamp(2px, 0.08em, 10px);
border: none;
border-radius: calc(var(--_caret-width) / 2);
border-right: var(--_caret-width) solid var(--_latex-color);
margin-right: calc(-1 * var(--_caret-width));
position: relative;
left: -0.019em;
animation: ML__caret-blink 1.05s step-end forwards infinite;
}
.ML__focused .ML__latex-caret::after,
.ML__focused .ML__text-caret::after,
.ML__focused .ML__caret::after {
visibility: visible;
}
.ML__focused .ML__text {
background: var(--_text-highlight-background-color);
}
/* When using smartFence, the anticipated closing fence is displayed
with this style */
.ML__smart-fence__close {
opacity: var(--_smart-fence-opacity);
color: var(--_smart-fence-color);
}
.ML__selected,
.ML__focused .ML__selected .ML__contains-caret,
.ML__focused .ML__selected .ML__smart-fence__close,
.ML__focused .ML__selected .ML__placeholder {
color: var(--_selection-color);
opacity: 1;
}
.ML__selection {
box-sizing: border-box;
background: var(--_selection-background-color) !important;
}
.ML__contains-caret.ML__close,
.ML__contains-caret.ML__open,
.ML__contains-caret > .ML__close,
.ML__contains-caret > .ML__open,
.ML__contains-caret .ML__sqrt-sign,
.ML__contains-caret .ML__sqrt-line {
color: var(--_caret-color);
}
.ML__contains-highlight {
box-sizing: border-box;
background: transparent;
}
.ML__focused .ML__contains-highlight {
background: var(--_contains-highlight-background-color);
}
.ML__raw-latex {
font-family: 'Berkeley Mono', 'IBM Plex Mono', 'Source Code Pro', Consolas, 'Roboto Mono', Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Courier, monospace;
font-weight: 400;
font-size: 0.8em;
letter-spacing: -0.05em;
color: var(--_latex-color);
}
.ML__suggestion {
color: var(--neutral-500);
}
.ML__virtual-keyboard-toggle.is-visible.is-pressed:hover {
background: hsl(var(--_hue), 25%, 35%);
color: #fafafa;
fill: currentColor;
}
.ML__virtual-keyboard-toggle:focus {
outline: none;
border-radius: 8px;
border: 2px solid hsl(var(--_hue), 40%, 50%);
}
.ML__virtual-keyboard-toggle.is-pressed,
.ML__virtual-keyboard-toggle.is-active:hover,
.ML__virtual-keyboard-toggle.is-active {
background: hsl(var(--_hue), 25%, 35%);
color: #fafafa;
fill: currentColor;
}
/* Add an attribute 'data-tooltip' to automatically show a
tooltip over a element on hover.
*/
[data-tooltip] {
position: relative;
}
[data-tooltip]::after {
content: attr(data-tooltip);
position: absolute;
display: block;
z-index: 2;
pointer-events: none;
right: auto;
top: calc(-100% - 4px);
width: max-content;
max-width: 200px;
padding: 8px 8px;
border-radius: 4px;
background: #616161;
color: #fff;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
text-align: center;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
font-style: normal;
font-weight: 400;
font-size: 13px;
/* Phone */
opacity: 0;
transform: scale(0.5);
}
@media only screen and (max-width: 767px) {
[data-tooltip]::after {
padding: 8px 16px;
font-size: 16px;
}
}
menu [data-tooltip]::after {
left: 100%;
top: 0%;
}
menu .ML__base {
cursor: default;
}
/** Don't display if we're tracking, i.e. have the pointer down */
.tracking [data-tooltip]:hover::after {
/* Use visibility, not display. Display will remove the after from the DOM, and the override below will not work */
visibility: hidden;
}
/** But do display if tracking and inside a menu */
.tracking menu li[data-tooltip]:hover::after,
[data-tooltip]:hover::after {
visibility: visible;
opacity: 1;
transform: scale(1);
transition-property: opacity, scale;
transition-duration: 0.15s;
transition-delay: 1s;
transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
}
.ML__prompt {
border-radius: 2px;
}
.ML__editablePromptBox {
outline: 1px solid #acacac;
border-radius: 2px;
z-index: -1;
}
.ML__focusedPromptBox {
outline: highlight auto 1px;
}
.ML__lockedPromptBox {
background-color: rgba(142, 142, 141, 0.4);
z-index: -1;
}
.ML__correctPromptBox {
outline: 1px solid var(--_correct-color);
box-shadow: 0 0 5px var(--_correct-color);
}
.ML__incorrectPromptBox {
outline: 1px solid var(--_incorrect-color);
box-shadow: 0 0 5px var(--_incorrect-color);
}
.variant-submenu {
display: flex;
flex-direction: column;
padding: 8px;
}
.variant-submenu [part=menu-item] {
font-size: 2rem;
text-align: center;
margin: 0;
}
.insert-matrix-submenu {
display: grid;
padding: 8px;
align-content: center;
justify-content: center;
grid-template-columns: repeat(5, minmax(0, 1fr));
}
.insert-matrix-submenu [part=menu-item] {
font-size: 21px;
border: none;
border-radius: 0;
line-height: 21px;
text-align: center;
padding: 0;
margin: 0;
}
.border-submenu [part=menu-item] {
font-size: 2rem;
line-height: 1.2;
text-align: center;
}
.swatches-submenu {
--_swatch-size: 2rem;
--_columns: 4;
display: flex;
flex-flow: wrap;
padding: 8px;
max-width: calc(var(--_columns) * (var(--_swatch-size) + 18px) + 16px);
box-sizing: border-box;
}
.menu-swatch {
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
width: fit-content;
height: fit-content;
margin: 2px;
padding: 0;
background: var(--neutral-200);
}
.menu-swatch > .label {
padding: 0;
margin: 0;
line-height: 0;
}
.menu-swatch > .label > span {
display: inline-block;
margin: 6px;
min-width: var(--_swatch-size);
min-height: var(--_swatch-size);
border-radius: 50%;
}
.menu-swatch.active {
background: var(--neutral-100);
scale: 1.4;
}
.menu-swatch.active > .label > span {
border-radius: 2px;
}
.menu-swatch .ui-checkmark,
.menu-swatch .ui-mixedmark {
position: absolute;
margin: 0;
padding: 0;
color: white;
}
.menu-swatch.dark-contrast .ui-checkmark,
.menu-swatch.dark-contrast .ui-mixedmark {
color: #000;
}
`,Dd=`.ML__container {
min-height: auto !important;
--_hue: var(--hue, 212);
--_placeholder-color: var(--placeholder-color, hsl(var(--_hue), 40%, 49%));
--_placeholder-opacity: var(--placeholder-opacity, 0.4);
--_text-font-family: var(--text-font-family, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif);
}
.ML__sr-only {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip: rect(0, 0, 0, 0);
clip-path: inset(50%);
white-space: nowrap;
border: 0;
}
.ML__is-inline {
display: inline-block;
}
.ML__base {
visibility: inherit;
display: inline-block;
position: relative;
cursor: text;
padding: 0;
margin: 0;
box-sizing: content-box;
border: 0;
outline: 0;
vertical-align: baseline;
font-weight: inherit;
font-family: inherit;
font-style: inherit;
text-decoration: none;
width: min-content;
}
.ML__strut,
.ML__strut--bottom {
display: inline-block;
min-height: 0.5em;
}
.ML__small-delim {
font-family: KaTeX_Main;
}
/* Text mode */
.ML__text {
font-family: var(--_text-font-family);
white-space: pre;
}
/* Use cmr for 'math upright' */
.ML__cmr {
font-family: KaTeX_Main;
font-style: normal;
}
.ML__mathit {
font-family: KaTeX_Math;
/* The KaTeX_Math font is italic by default, so the font-style below is only
useful when a fallback font is used
*/
font-style: italic;
}
.ML__mathbf {
font-family: KaTeX_Main;
font-weight: bold;
}
/* Lowercase greek symbols should stick to math font when \\mathbf is applied
to match TeX idiosyncratic behavior */
.lcGreek.ML__mathbf {
font-family: KaTeX_Math;
font-weight: normal;
}
.ML__mathbfit {
font-family: KaTeX_Math;
font-weight: bold;
font-style: italic;
}
.ML__ams {
font-family: KaTeX_AMS;
}
/* Blackboard */
.ML__bb {
font-family: KaTeX_AMS;
}
.ML__cal {
font-family: KaTeX_Caligraphic;
}
.ML__frak {
font-family: KaTeX_Fraktur;
}
.ML__tt {
font-family: KaTeX_Typewriter;
}
.ML__script {
font-family: KaTeX_Script;
}
.ML__sans {
font-family: KaTeX_SansSerif;
}
.ML__series_ul {
font-weight: 100;
}
.ML__series_el {
font-weight: 100;
}
.ML__series_l {
font-weight: 200;
}
.ML__series_sl {
font-weight: 300;
}
.ML__series_sb {
font-weight: 500;
}
.ML__bold,
.ML__boldsymbol {
font-weight: 700;
}
.ML__series_eb {
font-weight: 800;
}
.ML__series_ub {
font-weight: 900;
}
.ML__series_uc {
font-stretch: ultra-condensed;
}
.ML__series_ec {
font-stretch: extra-condensed;
}
.ML__series_c {
font-stretch: condensed;
}
.ML__series_sc {
font-stretch: semi-condensed;
}
.ML__series_sx {
font-stretch: semi-expanded;
}
.ML__series_x {
font-stretch: expanded;
}
.ML__series_ex {
font-stretch: extra-expanded;
}
.ML__series_ux {
font-stretch: ultra-expanded;
}
.ML__it {
font-style: italic;
}
.ML__shape_ol {
-webkit-text-stroke: 1px black;
text-stroke: 1px black;
color: transparent;
}
.ML__shape_sc {
font-variant: small-caps;
}
.ML__shape_sl {
font-style: oblique;
}
/* First level emphasis */
.ML__emph {
color: #bc2612;
}
/* Second level emphasis */
.ML__emph .ML__emph {
color: #0c7f99;
}
.ML__highlight {
color: #007cb2;
background: #edd1b0;
}
.ML__center {
text-align: center;
}
.ML__label_padding {
padding: 0 0.5em;
}
.ML__frac-line {
width: 100%;
min-height: 1px;
}
.ML__frac-line:after {
content: '';
display: block;
margin-top: max(-1px, -0.04em);
min-height: max(1px, 0.04em);
/* Ensure the line is visible when printing even if "turn off background images" is on*/
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
/* There's a bug since Chrome 62 where
sub-pixel border lines don't draw at some zoom
levels (110%, 90%).
Setting the min-height used to work around it, but that workaround
broke in Chrome 84 or so.
Setting the background (and the min-height) seems to work for now.
*/
background: currentColor;
box-sizing: content-box;
/* Vuetify sets the box-sizing to inherit
causes the fraction line to not draw at all sizes (see #26) */
/* On some versions of Firefox on Windows, the line fails to
draw at some zoom levels, but setting the transform triggers
the hardware accelerated path, which works */
transform: translate(0, 0);
}
.ML__sqrt {
display: inline-block;
}
.ML__sqrt-sign {
display: inline-block;
position: relative;
}
.ML__sqrt-line {
display: inline-block;
height: max(1px, 0.04em);
width: 100%;
}
.ML__sqrt-line:before {
content: '';
display: block;
margin-top: min(-1px, -0.04em);
min-height: max(1px, 0.04em);
/* Ensure the line is visible when printing even if "turn off background images" is on*/
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
background: currentColor;
/* On some versions of Firefox on Windows, the line fails to
draw at some zoom levels, but setting the transform triggers
the hardware accelerated path, which works */
transform: translate(0, 0);
}
.ML__sqrt-line:after {
border-bottom-width: 1px;
content: ' ';
display: block;
margin-top: -0.1em;
}
.ML__sqrt-index {
margin-left: 0.27777778em;
margin-right: -0.55555556em;
}
.ML__delim-size1 {
font-family: KaTeX_Size1;
}
.ML__delim-size2 {
font-family: KaTeX_Size2;
}
.ML__delim-size3 {
font-family: KaTeX_Size3;
}
.ML__delim-size4 {
font-family: KaTeX_Size4;
}
.ML__delim-mult .delim-size1 > span {
font-family: KaTeX_Size1;
}
.ML__delim-mult .delim-size4 > span {
font-family: KaTeX_Size4;
}
.ML__accent-body > span {
font-family: KaTeX_Main;
width: 0;
}
.ML__accent-vec {
position: relative;
left: 0.24em;
}
/** The markup for a LaTeX formula, either in an editable mathfield or
in a static display.
*/
.ML__latex {
display: inline-block;
direction: ltr;
text-align: left;
text-indent: 0;
text-rendering: auto;
font-family: KaTeX_Main, 'Times New Roman', serif;
font-style: normal;
font-size-adjust: none;
font-stretch: normal;
font-variant-caps: normal;
letter-spacing: normal;
line-height: 1.2;
word-wrap: normal;
word-spacing: normal;
white-space: nowrap;
text-shadow: none;
-webkit-user-select: none;
user-select: none;
width: min-content;
}
.ML__latex .style-wrap {
position: relative;
}
.ML__latex .mfrac {
display: inline-block;
}
.ML__latex .left-right {
display: inline-block;
}
.ML__latex .vlist-t {
display: inline-table;
table-layout: fixed;
border-collapse: collapse;
}
.ML__latex .vlist-r {
display: table-row;
}
.ML__latex .vlist {
display: table-cell;
vertical-align: bottom;
position: relative;
}
.ML__latex .vlist > span {
display: block;
height: 0;
position: relative;
}
.ML__latex .vlist > span > span {
display: inline-block;
}
.ML__latex .vlist > span > .pstrut {
overflow: hidden;
width: 0;
}
.ML__latex .vlist-t2 {
margin-right: -2px;
}
.ML__latex .vlist-s {
display: table-cell;
vertical-align: bottom;
font-size: 1px;
width: 2px;
min-width: 2px;
}
.ML__latex .msubsup {
text-align: left;
}
.ML__latex .negativethinspace {
display: inline-block;
margin-left: -0.16667em;
height: 0.71em;
}
.ML__latex .thinspace {
display: inline-block;
width: 0.16667em;
height: 0.71em;
}
.ML__latex .mediumspace {
display: inline-block;
width: 0.22222em;
height: 0.71em;
}
.ML__latex .thickspace {
display: inline-block;
width: 0.27778em;
height: 0.71em;
}
.ML__latex .enspace {
display: inline-block;
width: 0.5em;
height: 0.71em;
}
.ML__latex .quad {
display: inline-block;
width: 1em;
height: 0.71em;
}
.ML__latex .qquad {
display: inline-block;
width: 2em;
height: 0.71em;
}
.ML__latex .llap,
.ML__latex .rlap {
width: 0;
position: relative;
display: inline-block;
}
.ML__latex .llap > .inner,
.ML__latex .rlap > .inner {
position: absolute;
}
.ML__latex .llap > .fix,
.ML__latex .rlap > .fix {
display: inline-block;
}
.ML__latex .llap > .inner {
right: 0;
}
.ML__latex .rlap > .inner {
left: 0;
}
.ML__latex .rule {
display: inline-block;
border: solid 0;
position: relative;
box-sizing: border-box;
}
.ML__latex .overline .overline-line,
.ML__latex .underline .underline-line {
width: 100%;
}
.ML__latex .overline .overline-line:before,
.ML__latex .underline .underline-line:before {
content: '';
border-bottom-style: solid;
border-bottom-width: max(1px, 0.04em);
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
display: block;
}
.ML__latex .overline .overline-line:after,
.ML__latex .underline .underline-line:after {
border-bottom-style: solid;
border-bottom-width: max(1px, 0.04em);
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
content: '';
display: block;
margin-top: -1px;
}
.ML__latex .stretchy {
display: block;
position: absolute;
width: 100%;
left: 0;
overflow: hidden;
}
.ML__latex .stretchy:before,
.ML__latex .stretchy:after {
content: '';
}
.ML__latex .stretchy svg {
display: block;
position: absolute;
width: 100%;
height: inherit;
fill: currentColor;
stroke: currentColor;
fill-rule: nonzero;
fill-opacity: 1;
stroke-width: 1;
stroke-linecap: butt;
stroke-linejoin: miter;
stroke-miterlimit: 4;
stroke-dasharray: none;
stroke-dashoffset: 0;
stroke-opacity: 1;
}
.ML__latex .slice-1-of-2 {
display: inline-flex;
position: absolute;
left: 0;
width: 50.2%;
overflow: hidden;
}
.ML__latex .slice-2-of-2 {
display: inline-flex;
position: absolute;
right: 0;
width: 50.2%;
overflow: hidden;
}
.ML__latex .slice-1-of-3 {
display: inline-flex;
position: absolute;
left: 0;
width: 25.1%;
overflow: hidden;
}
.ML__latex .slice-2-of-3 {
display: inline-flex;
position: absolute;
left: 25%;
width: 50%;
overflow: hidden;
}
.ML__latex .slice-3-of-3 {
display: inline-flex;
position: absolute;
right: 0;
width: 25.1%;
overflow: hidden;
}
.ML__latex .slice-1-of-1 {
display: inline-flex;
position: absolute;
width: 100%;
left: 0;
overflow: hidden;
}
.ML__latex .nulldelimiter {
display: inline-block;
}
.ML__latex .op-group {
display: inline-block;
}
.ML__latex .op-symbol {
position: relative;
}
.ML__latex .op-symbol.small-op {
font-family: KaTeX_Size1;
}
.ML__latex .op-symbol.large-op {
font-family: KaTeX_Size2;
}
.ML__latex .mtable .vertical-separator {
display: inline-block;
min-width: 1px;
box-sizing: border-box;
}
.ML__latex .mtable .arraycolsep {
display: inline-block;
}
.ML__latex .mtable .col-align-m > .vlist-t {
text-align: center;
}
.ML__latex .mtable .col-align-c > .vlist-t {
text-align: center;
}
.ML__latex .mtable .col-align-l > .vlist-t {
text-align: left;
}
.ML__latex .mtable .col-align-r > .vlist-t {
text-align: right;
}
.ML__error {
display: inline-block;
background-image: radial-gradient(ellipse at center, hsl(341, 100%, 40%), rgba(0, 0, 0, 0) 70%);
background-color: hsla(341, 100%, 40%, 0.1);
background-repeat: repeat-x;
background-size: 3px 3px;
padding-bottom: 3px;
background-position: 0 100%;
}
.ML__error > .ML__error {
background: transparent;
padding: 0;
}
.ML__placeholder {
color: var(--_placeholder-color);
opacity: var(--_placeholder-opacity);
padding-left: 0.4ex;
padding-right: 0.4ex;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
}
.ML__notation {
position: absolute;
box-sizing: border-box;
line-height: 0;
}
/* This class is used to implement the \`\\mathtip\` and \`\\texttip\` commands
For UI elements, see \`[data-ML__tooltip]\`
*/
.ML__tooltip-container {
position: relative;
transform: scale(0);
}
.ML__tooltip-container .ML__tooltip-content {
position: fixed;
display: inline-table;
visibility: hidden;
z-index: 2;
width: max-content;
max-width: 400px;
padding: 12px 12px;
border-radius: 8px;
background: #616161;
--_selection-color: #fff;
color: #fff;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
opacity: 0;
transition: opacity 0.15s cubic-bezier(0.4, 0, 1, 1);
}
.ML__tooltip-container .ML__tooltip-content .ML__text {
white-space: normal;
}
.ML__tooltip-container .ML__tooltip-content .ML__base {
display: contents;
}
.ML__tooltip-container:hover .ML__tooltip-content {
visibility: visible;
opacity: 1;
font-size: 0.75em;
transform: scale(1) translate(0, 3em);
}
`,xs=`#mathlive-environment-popover.is-visible {
visibility: visible;
}
#mathlive-environment-popover {
--_environment-panel-height: var(--environment-panel-height, 70px);
--_accent-color: var(--accent-color, #aaa);
--_background: var(--environment-panel-background, #fff);
--_button-background: var(--environment-panel-button-background, white);
--_button-background-hover: var(--environment-panel-button-background-hover, #f5f5f7);
--_button-background-active: var(--environment-panel-button-background-active, #f5f5f7);
--_button-text: var(--environment-panel-button-text, #e3e4e8);
position: absolute;
width: calc(var(--_environment-panel-height) * 2);
height: var(--_environment-panel-height);
border-radius: 4px;
border: 1.5px solid var(--_accent-color);
background-color: var(--_background);
box-shadow: 0 0 30px 0 var(--environment-shadow, rgba(0, 0, 0, 0.4));
pointer-events: all;
visibility: hidden;
}
#mathlive-environment-popover .MLEP__array-buttons {
height: calc(var(--_environment-panel-height) * 5/4);
width: calc(var(--_environment-panel-height) * 5/4);
margin-left: calc(0px - var(--_environment-panel-height) * 0.16);
margin-top: calc(0px - var(--_environment-panel-height) * 0.19);
}
#mathlive-environment-popover .MLEP__array-buttons .font {
fill: white;
}
#mathlive-environment-popover .MLEP__array-buttons circle {
fill: #7f7f7f;
transition: fill 300ms;
}
#mathlive-environment-popover .MLEP__array-buttons .MLEP__array-insert-background {
fill-opacity: 1;
fill: var(--_background);
stroke: var(--_accent-color);
stroke-width: 3px;
}
#mathlive-environment-popover .MLEP__array-buttons line {
stroke: var(--_accent-color);
stroke-opacity: 0;
stroke-width: 40;
pointer-events: none;
transition: stroke-opacity 300ms;
stroke-linecap: round;
}
#mathlive-environment-popover .MLEP__array-buttons g[data-command]:hover circle {
fill: var(--_accent-color);
}
#mathlive-environment-popover .MLEP__array-buttons g[data-command]:hover line {
stroke-opacity: 1;
}
#mathlive-environment-popover .MLEP__environment-delimiter-controls {
height: 100%;
width: 50%;
}
#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options {
width: var(--_environment-panel-height);
height: var(--_environment-panel-height);
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: space-around;
}
#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg {
pointer-events: all;
margin-top: 2px;
width: calc(var(--_environment-panel-height) / 3 * 28 / 24);
height: calc(var(--_environment-panel-height) / 3 - 2px);
border-radius: calc(var(--_environment-panel-height) / 25);
background-color: var(--_button-background);
}
#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg:hover {
background-color: var(--_button-background-hover);
}
#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg path,
#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg line {
stroke: var(--_button-text);
stroke-width: 2;
stroke-linecap: round;
}
#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg rect,
#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg path {
fill-opacity: 0;
}
#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg.active {
pointer-events: none;
background-color: var(--_button-background-active);
}
#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg.active path,
#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg.active line {
stroke: var(--_accent-color);
}
#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg.active circle {
fill: var(--_accent-color);
}
`,df=`/* The element that display info while in latex mode */
#mathlive-suggestion-popover {
background-color: rgba(97, 97, 97);
color: #fff;
text-align: center;
border-radius: 8px;
position: fixed;
z-index: 1;
display: none;
flex-direction: column;
justify-content: center;
box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
}
#mathlive-suggestion-popover.top-tip::after {
content: '';
position: absolute;
top: -15px;
left: calc(50% - 15px);
width: 0;
height: 0;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-bottom: 15px solid rgba(97, 97, 97);
font-size: 1rem;
}
#mathlive-suggestion-popover.bottom-tip::after {
content: '';
position: absolute;
bottom: -15px;
left: calc(50% - 15px);
width: 0;
height: 0;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-top: 15px solid rgba(97, 97, 97);
font-size: 1rem;
}
#mathlive-suggestion-popover.is-animated {
transition: all 0.2s cubic-bezier(0.64, 0.09, 0.08, 1);
animation: ML__fade-in cubic-bezier(0, 0, 0.2, 1) 0.15s;
}
#mathlive-suggestion-popover.is-visible {
display: flex;
}
@keyframes ML__fade-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* The wrapper class for the entire content of the popover panel */
#mathlive-suggestion-popover ul {
display: flex;
flex-flow: column;
list-style: none;
margin: 0;
padding: 0;
align-items: flex-start;
max-height: 400px;
overflow-y: auto;
}
#mathlive-suggestion-popover li {
display: flex;
flex-direction: row;
justify-content: space-between;
margin: 8px;
padding: 8px;
width: calc(100% - 16px - 16px);
column-gap: 1em;
border-radius: 8px;
cursor: pointer;
/* Since the content can be clicked on, provide feedback on hover */
}
#mathlive-suggestion-popover li a {
color: #5ea6fd;
padding-top: 0.3em;
margin-top: 0.4em;
display: block;
}
#mathlive-suggestion-popover li a:hover {
color: #5ea6fd;
text-decoration: underline;
}
#mathlive-suggestion-popover li:hover,
#mathlive-suggestion-popover li.is-pressed,
#mathlive-suggestion-popover li.is-active {
background: rgba(255, 255, 255, 0.1);
}
/* The command inside a popover (inside a #mathlive-suggestion-popover) */
.ML__popover__command {
font-size: 1.6rem;
font-family: KaTeX_Main;
}
.ML__popover__current {
background: #5ea6fd;
color: #fff;
}
.ML__popover__latex {
font-family: 'IBM Plex Mono', 'Source Code Pro', Consolas, 'Roboto Mono', Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Courier, monospace;
align-self: center;
}
/* The keyboard shortcuts for a symbol as displayed in the popover */
.ML__popover__keybinding {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
font-size: 0.8em;
opacity: 0.7;
}
/* Style for the character that joins the modifiers of a keyboard shortcut
(usually a "+" sign)*/
.ML__shortcut-join {
opacity: 0.5;
}
`,Cd=`/* The element that displays the keys as the user type them */
#mathlive-keystroke-caption-panel {
visibility: hidden;
/*min-width: 160px;*/
/*background-color: rgba(97, 97, 200, .95);*/
background: var(--secondary, hsl(var(--_hue), 19%, 26%));
border-color: var(--secondary-border, hsl(0, 0%, 91%));
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
text-align: center;
border-radius: 6px;
padding: 16px;
position: absolute;
z-index: 1;
display: flex;
flex-direction: row-reverse;
justify-content: center;
--keystroke: white;
--on-keystroke: #555;
--keystroke-border: #f7f7f7;
}
@media (prefers-color-scheme: dark) {
body:not([theme='light']) #mathlive-keystroke-caption-panel {
--keystroke: hsl(var(--_hue), 50%, 30%);
--on-keystroke: hsl(0, 0%, 98%);
--keystroke-border: hsl(var(--_hue), 50%, 25%);
}
}
body[theme='dark'] #mathlive-keystroke-caption-panel {
--keystroke: hsl(var(--_hue), 50%, 30%);
--on-keystroke: hsl(0, 0%, 98%);
--keystroke-border: hsl(var(--_hue), 50%, 25%);
}
#mathlive-keystroke-caption-panel > span {
min-width: 14px;
/*height: 8px;*/
margin: 0 8px 0 0;
padding: 4px;
background-color: var(--keystroke);
color: var(--on-keystroke);
fill: currentColor;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
font-size: 1em;
border-radius: 6px;
border: 2px solid var(--keystroke-border);
/*box-shadow: 0 7px 14px rgba(0,0,0,0.25), 0 5px 5px rgba(0,0,0,0.22);*/
}
`,pf=`.ML__keyboard {
--_keyboard-height: 0;
--_keyboard-zindex: var(--keyboard-zindex, 105);
--_accent-color: var(--keyboard-accent-color, #0c75d8);
--_background: var(--keyboard-background, #cacfd7);
--_border: var(--keyboard-border, #ddd);
--_padding-horizontal: var(--keyboard-padding-horizontal, 0px);
--_padding-top: var(--keyboard-padding-top, 5px);
--_padding-bottom: var(--keyboard-padding-bottom, 0px);
--_row-padding-left: var(--keyboard-row-padding-left, 0px);
--_row-padding-right: var(--keyboard-row-padding-right, 0px);
--_toolbar-text: var(--keyboard-toolbar-text, #2c2e2f);
--_toolbar-text-active: var(--keyboard-toolbar-text-active, var(--_accent-color));
--_toolbar-background: var(--keyboard-toolbar-background, transparent);
--_toolbar-background-hover: var(--keyboard-toolbar-background-hover, #eee);
--_toolbar-background-selected: var(--keyboard-toolbar-background-selected, transparent);
--_toolbar-font-size: var(--keyboard-toolbar-font-size, '135%');
--_horizontal-rule: var(--keyboard-horizontal-rule, 1px solid #fff);
--_keycap-background: var(--keycap-background, white);
--_keycap-background-hover: var(--keycap-background-hover, #f5f5f7);
--_keycap-background-active: var(--keycap-background-active, var(--_accent-color));
--_keycap-background-pressed: var(--keycap-background-pressed, var(--_accent-color));
--_keycap-border: var(--keycap-border, #e5e6e9);
--_keycap-border-bottom: var(--keycap-border-bottom, #8d8f92);
--_keycap-text: var(--keycap-text, #000);
--_keycap-text-active: var(--keycap-text-active, #fff);
--_keycap-text-hover: var(--keycap-text-hover, var(--_keycap-text));
--_keycap-text-pressed: var(--keycap-text-pressed, #fff);
--_keycap-shift-text: var(--keycap-shift-text, var(--_accent-color));
--_keycap-primary-background: var(--keycap-primary-background, var(--_accent-color));
--_keycap-primary-text: var(--keycap-primary-text, #ddd);
--_keycap-primary-background-hover: var(--keycap-primary-background-hover, #0d80f2);
--_keycap-secondary-background: var(--keycap-secondary-background, #a0a9b8);
--_keycap-secondary-background-hover: var(--keycap-secondary-background-hover, #7d8795);
--_keycap-secondary-text: var(--keycap-secondary-text, #060707);
--_keycap-secondary-border: var(--keycap-secondary-border, #c5c9d0);
--_keycap-secondary-border-bottom: var(--keycap-secondary-border-bottom, #989da6);
--_keycap-height: var(--keycap-height, 60px);
/* Keycap width (incl. margin) */
--_keycap-max-width: var(--keycap-max-width, 100px);
--_keycap-gap: var(--keycap-gap, 8px);
--_keycap-font-size: var(--keycap-font-size, clamp(16px, 4cqw, 24px));
--_keycap-small-font-size: var(--keycap-small-font-size, calc(var(--keycap-font-size) * 0.8));
--_keycap-extra-small-font-size: var(--keycap-extra-small-font-size, calc(var(--keycap-font-size) / 1.42));
--_variant-panel-background: var(--variant-panel-background, #fff);
--_variant-keycap-text: var(--variant-keycap-text, var(--_keycap-text));
--_variant-keycap-text-active: var(--variant-keycap-text-active, var(--_keycap-text-active));
--_variant-keycap-background-active: var(--variant-keycap-background-active, var(--_accent-color));
--_variant-keycap-length: var(--variant-keycap-length, 70px);
--_variant-keycap-font-size: var(--variant-keycap-font-size, 30px);
--_variant-keycap-aside-font-size: var(--variant-keycap-aside-font-size, 12px);
--_keycap-shift-font-size: var(--keycap-shift-font-size, 16px);
--_keycap-shift-color: var(--keycap-shift-color, var(--_accent-color));
--_box-placeholder-color: var(--box-placeholder-color, var(--_accent-color));
--_box-placeholder-pressed-color: var(--box-placeholder-pressed-color, var(--keycap-text-pressed));
}
.is-math-mode .MLK__rows .if-text-mode,
.is-text-mode .MLK__rows .if-math-mode {
display: none;
}
.if-can-undo,
.if-can-redo,
.if-can-copy,
.if-can-cut,
.if-can-paste {
opacity: 0.4;
pointer-events: none;
}
.can-undo .if-can-undo,
.can-redo .if-can-redo,
.can-copy .if-can-copy,
.can-cut .if-can-cut,
.can-paste .if-can-paste {
opacity: 1;
pointer-events: all;
}
body > .ML__keyboard {
position: fixed;
--_padding-bottom: calc(var(--keyboard-padding-bottom, 0px) + env(safe-area-inset-bottom, 0));
}
body > .ML__keyboard.is-visible > .MLK__backdrop {
box-shadow: 0 -5px 6px rgba(0, 0, 0, 0.08);
border-top: 1px solid var(--_border);
}
body > .ML__keyboard.backdrop-is-transparent.is-visible > .MLK__backdrop {
box-shadow: none;
border: none;
}
body > .ML__keyboard.is-visible.animate > .MLK__backdrop {
transition: 0.28s cubic-bezier(0, 0, 0.2, 1);
transition-property: transform, opacity;
transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
}
.ML__keyboard {
position: relative;
overflow: hidden;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: var(--_keyboard-zindex);
box-sizing: border-box;
outline: none;
border: none;
margin: 0;
padding: 0;
line-height: 1;
overflow-wrap: unset;
text-align: left;
vertical-align: baseline;
cursor: auto;
white-space: pre;
box-shadow: none;
opacity: 1;
transform: none;
pointer-events: none;
}
.ML__keyboard :where(div) {
box-sizing: border-box;
outline: none;
border: none;
margin: 0;
padding: 0;
line-height: 1;
overflow-wrap: unset;
text-align: left;
vertical-align: baseline;
cursor: auto;
white-space: pre;
box-shadow: none;
transform: none;
}
.MLK__backdrop {
position: absolute;
bottom: calc(-1 * var(--_keyboard-height));
width: 100%;
height: var(--_keyboard-height);
box-sizing: border-box;
padding-top: var(--_padding-top);
padding-bottom: var(--_padding-bottom);
padding-left: var(--_padding-horizontal);
padding-right: var(--_padding-horizontal);
opacity: 0;
visibility: hidden;
transform: translate(0, 0);
background: var(--_background);
}
.backdrop-is-transparent .MLK__backdrop {
background: transparent;
}
/* If a custom layout has a custom container/backdrop
(backdrop-is-transparent), make sure to let pointer event go through. */
.backdrop-is-transparent .MLK__plate {
background: transparent;
pointer-events: none;
}
/* If a custom layout has a custom container/backdrop, make sure to
allow pointer events on it. */
.backdrop-is-transparent .MLK__layer > div > div {
pointer-events: all;
}
.ML__keyboard.is-visible > .MLK__backdrop {
transform: translate(0, calc(-1 * var(--_keyboard-height)));
opacity: 1;
visibility: visible;
}
.caps-lock-indicator {
display: none;
width: 8px;
height: 8px;
background: #0cbc0c;
box-shadow: inset 0 0 4px 0 #13ca13, 0 0 4px 0 #a9ef48;
border-radius: 8px;
right: 8px;
top: 8px;
position: absolute;
}
.ML__keyboard.is-caps-lock .caps-lock-indicator {
display: block;
}
.ML__keyboard.is-caps-lock .shift {
background: var(--_keycap-background-active);
color: var(--_keycap-text-active);
}
.MLK__plate {
position: absolute;
top: var(--_padding-top);
left: var(--_padding-horizontal);
width: calc(100% - 2 * var(--_padding-horizontal));
margin: 0;
padding: 0;
box-sizing: border-box;
container-type: inline-size;
touch-action: none;
-webkit-user-select: none;
user-select: none;
pointer-events: all;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
font-size: 16px;
/* Size of toolbar labels */
font-weight: 400;
text-shadow: none;
}
.ML__box-placeholder {
color: var(--_box-placeholder-color);
}
.MLK__tex {
font-family: KaTeX_Main, KaTeX_Math, 'Cambria Math', 'Asana Math', OpenSymbol, Symbola, STIX, Times, serif !important;
}
.MLK__tex-math {
font-family: KaTeX_Math, KaTeX_Main, 'Cambria Math', 'Asana Math', OpenSymbol, Symbola, STIX, Times, serif !important;
font-style: italic;
}
.MLK__layer {
display: none;
outline: none;
}
.MLK__layer.is-visible {
display: flex;
flex-flow: column;
}
/* Keyboard layouts are made or rows of keys... */
.MLK__rows {
--_keycap-width: min(var(--_keycap-max-width), 10cqw);
display: flex;
flex-flow: column;
align-items: center;
border-collapse: separate;
clear: both;
border: 0;
margin: 0;
margin-bottom: var(--_keycap-gap);
gap: var(--_keycap-gap);
/* If the styling include, e.g., some shadows, they will be
cut off by the overflow. In that case, set the padding to
compensate. */
padding-left: var(--_row-padding-left);
padding-right: var(--_row-padding-right);
overflow: visible;
touch-action: none;
}
.MLK__rows > .MLK__row {
display: flex;
flex-flow: row;
justify-content: center;
width: 100%;
gap: var(--_keycap-gap);
margin: 0;
padding: 0;
/* For the alignment of the text on some modifiers (e.g. shift) */
/* Extra spacing between two adjacent keys */
}
.MLK__rows > .MLK__row .tex {
font-family: KaTeX_Math, KaTeX_Main, 'Cambria Math', 'Asana Math', OpenSymbol, Symbola, STIX, Times, serif !important;
}
.MLK__rows > .MLK__row .tex-math {
font-family: KaTeX_Math, 'Cambria Math', 'Asana Math', OpenSymbol, Symbola, STIX, Times, serif !important;
}
.MLK__rows > .MLK__row .big-op {
font-size: calc(1.25 * var(--_keycap-font-size));
}
.MLK__rows > .MLK__row .small {
font-size: var(--_keycap-small-font-size);
}
.MLK__rows > .MLK__row .bottom {
justify-content: flex-end;
}
.MLK__rows > .MLK__row .left {
align-items: flex-start;
padding-left: 12px;
}
.MLK__rows > .MLK__row .right {
align-items: flex-end;
padding-right: 12px;
}
.MLK__rows > .MLK__row .w0 {
width: 0;
}
.MLK__rows > .MLK__row .w5 {
width: calc(0.5 * var(--_keycap-width) - var(--_keycap-gap));
}
.MLK__rows > .MLK__row .w15 {
width: calc(1.5 * var(--_keycap-width) - var(--_keycap-gap));
}
.MLK__rows > .MLK__row .w20 {
width: calc(2 * var(--_keycap-width) - var(--_keycap-gap));
}
.MLK__rows > .MLK__row .w40 {
width: calc(4 * var(--_keycap-width) - var(--_keycap-gap));
}
.MLK__rows > .MLK__row .w50 {
width: calc(5 * var(--_keycap-width) - var(--_keycap-gap));
}
.MLK__rows > .MLK__row .MLK__keycap.w50 {
font-size: 80%;
padding-top: 10px;
font-weight: 100;
}
.MLK__rows > .MLK__row .separator {
background: transparent;
border: none;
pointer-events: none;
}
.MLK__rows > .MLK__row .horizontal-rule {
height: 6px;
margin-top: 3px;
margin-bottom: 0;
width: 100%;
border-radius: 0;
border-top: var(--_horizontal-rule);
}
.MLK__rows > .MLK__row .ghost {
background: var(--_toolbar-background);
border: none;
color: var(--_toolbar-text);
}
.MLK__rows > .MLK__row .ghost:hover {
background: var(--_toolbar-background-hover);
}
.MLK__rows > .MLK__row .bigfnbutton {
font-size: var(--_keycap-extra-small-font-size);
}
.MLK__rows > .MLK__row .shift,
.MLK__rows > .MLK__row .action {
color: var(--_keycap-secondary-text);
background: var(--_keycap-secondary-background);
border-color: var(--_keycap-secondary-border);
border-bottom-color: var(--_keycap-secondary-border-bottom);
line-height: 0.8;
font-size: min(1rem, var(--_keycap-small-font-size));
font-weight: 600;
padding: 8px 12px 8px 12px;
}
.MLK__rows > .MLK__row .shift:hover,
.MLK__rows > .MLK__row .action:hover {
background: var(--_keycap-secondary-background-hover);
}
.MLK__rows > .MLK__row .action.primary {
background: var(--_keycap-primary-background);
color: var(--_keycap-primary-text);
}
.MLK__rows > .MLK__row .action.primary:hover {
background: var(--_keycap-primary-background-hover);
color: var(--_keycap-primary-text);
}
.MLK__rows > .MLK__row .shift.selected,
.MLK__rows > .MLK__row .action.selected {
color: var(--_toolbar-text-active);
}
.MLK__rows > .MLK__row .shift.selected.is-pressed,
.MLK__rows > .MLK__row .action.selected.is-pressed,
.MLK__rows > .MLK__row .shift.selected.is-active,
.MLK__rows > .MLK__row .action.selected.is-active {
color: white;
}
.MLK__rows > .MLK__row .warning {
background: #cd0030;
color: white;
}
.MLK__rows > .MLK__row .warning svg.svg-glyph {
width: 24px;
height: 24px;
min-height: 24px;
}
/** A regular keycap
* Use the :where() pseudo-class to give it a very low specifity,
* so that it can be overriden by custom style.
*/
:where(.MLK__rows > .MLK__row div) {
display: flex;
flex-flow: column;
align-items: center;
justify-content: space-evenly;
width: calc(var(--_keycap-width) - var(--_keycap-gap));
height: var(--_keycap-height);
box-sizing: border-box;
padding: 0;
vertical-align: top;
text-align: center;
float: left;
color: var(--_keycap-text);
fill: currentColor;
font-size: var(--_keycap-font-size);
background: var(--_keycap-background);
border: 1px solid var(--_keycap-border);
border-bottom-color: var(--_keycap-border-bottom);
border-radius: 6px;
cursor: pointer;
touch-action: none;
/* Keys with a variants panel */
position: relative;
overflow: hidden;
-webkit-user-select: none;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
:where(.MLK__rows > .MLK__row div):hover {
overflow: visible;
background: var(--_keycap-background-hover);
}
:where(.MLK__rows > .MLK__row div) .ML__latex {
pointer-events: none;
touch-action: none;
}
:where(.MLK__rows > .MLK__row div) svg.svg-glyph {
margin: 8px 0;
width: 20px;
height: 20px;
min-height: 20px;
}
:where(.MLK__rows > .MLK__row div) svg.svg-glyph-lg {
margin: 8px 0;
width: 24px;
height: 24px;
min-height: 24px;
}
:where(.MLK__rows > .MLK__row div).MLK__tex-math {
font-size: 25px;
}
:where(.MLK__rows > .MLK__row div).is-pressed {
background: var(--_keycap-background-pressed);
color: var(--_keycap-text-pressed);
--_box-placeholder-color: var(--_box-placeholder-pressed-color);
}
:where(.MLK__rows > .MLK__row div).MLK__keycap.is-active,
:where(.MLK__rows > .MLK__row div).action.is-active,
:where(.MLK__rows > .MLK__row div).MLK__keycap.is-pressed,
:where(.MLK__rows > .MLK__row div).action.is-pressed {
z-index: calc(var(--_keyboard-zindex) - 5);
}
:where(.MLK__rows > .MLK__row div).MLK__keycap.is-active aside,
:where(.MLK__rows > .MLK__row div).action.is-active aside,
:where(.MLK__rows > .MLK__row div).MLK__keycap.is-pressed aside,
:where(.MLK__rows > .MLK__row div).action.is-pressed aside {
display: none;
}
:where(.MLK__rows > .MLK__row div).MLK__keycap.is-active .MLK__shift,
:where(.MLK__rows > .MLK__row div).action.is-active .MLK__shift,
:where(.MLK__rows > .MLK__row div).MLK__keycap.is-pressed .MLK__shift,
:where(.MLK__rows > .MLK__row div).action.is-pressed .MLK__shift {
display: none;
}
:where(.MLK__rows > .MLK__row div).shift.is-pressed,
:where(.MLK__rows > .MLK__row div).MLK__keycap.is-pressed,
:where(.MLK__rows > .MLK__row div).action.is-pressed {
background: var(--_keycap-background-pressed);
color: var(--_keycap-text-pressed);
}
:where(.MLK__rows > .MLK__row div).shift.is-active,
:where(.MLK__rows > .MLK__row div).MLK__keycap.is-active,
:where(.MLK__rows > .MLK__row div).action.is-active {
background: var(--_keycap-background-active);
color: var(--_keycap-text-active);
--_box-placeholder-color: var(--_box-placeholder-pressed-color);
}
:where(.MLK__rows > .MLK__row div) small {
color: var(--_keycap-secondary-text);
}
:where(.MLK__rows > .MLK__row div) aside {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
font-size: 10px;
line-height: 10px;
color: var(--_keycap-secondary-text);
}
/* Add an attribute 'data-tooltip' to display a tooltip on hover.
Note there are a different set of tooltip rules for the keyboard toggle
(it's in a different CSS tree) */
.ML__keyboard [data-tooltip] {
position: relative;
}
.ML__keyboard [data-tooltip]::after {
position: absolute;
display: inline-table;
content: attr(data-tooltip);
top: inherit;
bottom: 100%;
width: max-content;
max-width: 200px;
padding: 8px 8px;
background: #616161;
color: #fff;
text-align: center;
z-index: 2;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
border-radius: 2px;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
font-weight: 400;
font-size: 12px;
transition: all 0.15s cubic-bezier(0.4, 0, 1, 1) 1s;
opacity: 0;
transform: scale(0.5);
}
.ML__keyboard [data-tooltip]:hover {
position: relative;
}
.ML__keyboard [data-tooltip]:hover::after {
opacity: 1;
transform: scale(1);
}
.MLK__toolbar {
align-self: center;
display: flex;
flex-flow: row;
justify-content: space-between;
width: 100%;
max-width: 996px;
min-height: 32px;
/* Icons for undo/redo, etc. */
}
.MLK__toolbar svg {
height: 20px;
width: 20px;
}
.MLK__toolbar > .left {
position: relative;
display: flex;
justify-content: flex-start;
flex-flow: row;
}
.MLK__toolbar > .right {
display: flex;
justify-content: flex-end;
flex-flow: row;
}
.MLK__toolbar > div > div {
/* "button" in the toolbar */
display: flex;
align-items: center;
justify-content: center;
color: var(--_toolbar-text);
fill: currentColor;
background: var(--_toolbar-background);
font-size: var(--_toolbar-font-size);
padding: 4px 15px;
cursor: pointer;
width: max-content;
min-width: 42px;
min-height: 34px;
border: none;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 8px;
padding-top: 8px;
margin-top: 0;
margin-bottom: 4px;
margin-left: 4px;
margin-right: 4px;
border-radius: 8px;
box-shadow: none;
border-bottom: 2px solid transparent;
}
.MLK__toolbar > div > div:not(.disabled):not(.selected):hover {
background: var(--_toolbar-background-hover);
}
.MLK__toolbar > div > div.disabled svg,
.MLK__toolbar > div > div.disabled:hover svg,
.MLK__toolbar > div > div.disabled.is-pressed svg {
color: var(--_toolbar-text);
opacity: 0.2;
}
.MLK__toolbar > div > div:hover,
.MLK__toolbar > div > div:active,
.MLK__toolbar > div > div.is-pressed,
.MLK__toolbar > div > div.is-active {
color: var(--_toolbar-text-active);
}
.MLK__toolbar > div > div.selected {
color: var(--_toolbar-text-active);
background: var(--_toolbar-background-selected);
border-radius: 0;
border-bottom-color: var(--_toolbar-text-active);
padding-bottom: 4px;
margin-bottom: 8px;
}
/* This is the element that displays variants on press+hold */
.MLK__variant-panel {
visibility: hidden;
position: fixed;
display: flex;
flex-flow: row wrap-reverse;
justify-content: center;
align-content: center;
margin: 0;
padding: 0;
bottom: auto;
top: 0;
box-sizing: content-box;
transform: none;
z-index: calc(var(--_keyboard-zindex) + 1);
touch-action: none;
max-width: 350px;
background: var(--_variant-panel-background);
text-align: center;
border-radius: 6px;
padding: 6px;
box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
transition: none;
}
.MLK__variant-panel.is-visible {
visibility: visible;
}
.MLK__variant-panel.compact {
--_variant-keycap-length: var(--variant-keycap-length, 50px);
--_variant-keycap-font-size: var(--variant-keycap-font-size, 24px);
--_variant-keycap-aside-font-size: var(--variant-keycap-aside-font-size, 10px);
}
.MLK__variant-panel .item {
display: flex;
flex-flow: column;
align-items: center;
justify-content: center;
font-size: var(--_variant-keycap-font-size);
height: var(--_variant-keycap-length);
width: var(--_variant-keycap-length);
margin: 0;
box-sizing: border-box;
border-radius: 5px;
border: 1px solid transparent;
background: transparent;
pointer-events: all;
cursor: pointer;
color: var(--_variant-keycap-text);
fill: currentColor;
}
@media (max-height: 412px) {
.MLK__variant-panel .item {
--_variant-keycap-font-size: var(--variant-keycap-font-size, 24px);
--_variant-keycap-length: var(--variant-keycap-length, 50px);
}
}
.MLK__variant-panel .item .ML__latex {
pointer-events: none;
}
.MLK__variant-panel .item.is-active {
background: var(--_variant-keycap-background-active);
color: var(--_variant-keycap-text-active);
}
.MLK__variant-panel .item.is-pressed {
background: var(--_variant-keycap-background-pressed);
color: var(--_variant-keycap-text-pressed);
}
.MLK__variant-panel .item.small {
font-size: var(--_keycap-small-font-size);
}
.MLK__variant-panel .item.swatch-button {
box-sizing: border-box;
background: #fbfbfb;
}
.MLK__variant-panel .item.swatch-button > span {
display: inline-block;
margin: 6px;
width: calc(100% - 12px);
height: calc(100% - 12px);
border-radius: 50%;
}
.MLK__variant-panel .item.swatch-button:hover {
background: #f0f0f0;
}
.MLK__variant-panel .item.swatch-button:hover > span {
border-radius: 2px;
}
.MLK__variant-panel .item.box > div,
.MLK__variant-panel .item.box > span {
border: 1px dashed rgba(0, 0, 0, 0.24);
}
.MLK__variant-panel .item .warning {
min-height: 60px;
min-width: 60px;
background: #cd0030;
color: white;
padding: 5px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 5px;
}
.MLK__variant-panel .item .warning.is-pressed,
.MLK__variant-panel .item .warning.is-active {
background: red;
}
.MLK__variant-panel .item .warning svg.svg-glyph {
width: 50px;
height: 50px;
}
.MLK__variant-panel .item aside {
font-size: var(--_variant-keycap-aside-font-size);
line-height: 12px;
opacity: 0.78;
padding-top: 2px;
}
.MLK__keycap {
position: relative;
}
.MLK__shift {
display: block;
position: absolute;
right: 4px;
top: 4px;
font-size: var(--_keycap-shift-font-size);
color: var(--_keycap-shift-color);
}
.hide-shift .MLK__shift {
display: none;
}
@media (max-width: 414px) {
.MLK__variant-panel {
max-width: 350px;
--_variant-keycap-font-size: var(--variant-keycap-font-size, 24px);
--_variant-keycap-length: var(--variant-keycap-length, 50px);
}
}
/* @xs breakpoint: iPhone 5 */
@container (max-width: 414px) {
.MLK__rows {
--_keycap-gap: max(var(--_keycap-gap, 2px), 2px);
--_keycap-height: max(var(--_keycap-height), 42px);
--_keycap-width: min(min(var(--_keycap-max-width), 10cqw), 62px);
}
.MLK__toolbar > div > div {
font-size: 100%;
margin-left: 2px;
margin-right: 2px;
}
.MLK__rows .shift,
.MLK__rows .action {
font-size: 65%;
}
.MLK__rows .warning svg.svg-glyph {
width: 14px;
height: 14px;
min-height: 14px;
}
}
@container (max-width: 744px) {
.MLK__rows {
--_keycap-gap: max(var(--keycap-gap, 2px), 2px);
--_keycap-height: max(var(--keycap-height, 52px), 52px);
--_keycap-width: min(min(var(--_keycap-max-width), 10cqw), 62px);
}
.MLK__toolbar > div > div {
padding-left: 0;
padding-right: 0;
}
.MLK__tooltip::after {
padding: 8px 16px;
font-size: 16px;
}
.MLK__rows > .MLK__row > div.fnbutton {
font-size: 16px;
}
.MLK__rows > .MLK__row > div.bigfnbutton {
font-size: calc(var(--_keycap-extra-small-font-size) / 1.55);
}
.MLK__rows > .MLK__row > div.small {
font-size: 13px;
}
.MLK__rows > .MLK__row > div > aside {
display: none;
}
.MLK__shift {
display: none;
}
}
/* Medium breakpoint: larger phones */
@container (max-width: 768px) {
.MLK__rows {
--_keycap-height: max(var(--keycap-height, 42px), 42px);
}
.MLK__rows > .MLK__row > div > small {
font-size: 14px;
}
}
@media (max-height: 768px) {
.MLK__rows {
--_keycap-height: max(var(--keycap-height, 42px), 42px);
}
.MLK__rows > .MLK__row > div > small {
font-size: 14px;
}
}
@container (max-width: 1444px) {
.MLK__rows .if-wide {
display: none;
}
}
@media (prefers-color-scheme: dark) {
.ML__keyboard {
--_accent-color: var(--keyboard-accent-color, #0b5c9c);
--_background: var(--keyboard-background, #151515);
--_border: var(--keyboard-border, transparent);
--_toolbar-text: var(--keyboard-toolbar-text, #e3e4e8);
--_toolbar-background-hover: var(--keyboard-toolbar-background-hover, #303030);
--keyboard-toolbar-background-hover: #303030;
--_horizontal-rule: var(--keyboard-horizontal-rule, 1px solid #303030);
--_keycap-background: var(--keycap-background, #1f2022);
--_keycap-background-hover: var(--keycap-background-hover, #2f3032);
--_keycap-border: var(--_keycap-border, transparent);
--_keycap-border-bottom: var(--_keycap-border-bottom, transparent);
--_keycap-text: var(--keycap-text, #e3e4e8);
--_keycap-secondary-background: var(--keycap-secondary-background, #3d4144);
--_keycap-secondary-background-hover: var(--keycap-secondary-background-hover, #4d5154);
--_keycap-secondary-text: var(--keycap-secondary-text, #e7ebee);
--keycap-secondary-border: transparent;
--keycap-secondary-border-bottom: transparent;
--_keycap-secondary-border: var(--keycap-secondary-border, transparent);
--_keycap-secondary-border-bottom: var(--keycap-secondary-border-bottom, transparent);
--_variant-panel-background: var(--variant-panel-background, #303030);
--_variant-keycap-text-active: var(--variant-keycap-text-active, #fff);
}
}
/* Same as the media query, but with a class */
[theme='dark'] .ML__keyboard {
--_accent-color: var(--keyboard-accent-color, #0b5c9c);
--_background: var(--keyboard-background, #151515);
--_border: var(--keyboard-border, transparent);
--_toolbar-text: var(--keyboard-toolbar-text, #e3e4e8);
--_toolbar-background-hover: var(--keyboard-toolbar-background-hover, #303030);
--keyboard-toolbar-background-hover: #303030;
--_horizontal-rule: var(--keyboard-horizontal-rule, 1px solid #303030);
--_keycap-background: var(--keycap-background, #1f2022);
--_keycap-background-hover: var(--keycap-background-hover, #2f3032);
--_keycap-border: var(--_keycap-border, transparent);
--_keycap-border-bottom: var(--_keycap-border-bottom, transparent);
--_keycap-text: var(--keycap-text, #e3e4e8);
--_keycap-secondary-background: var(--keycap-secondary-background, #3d4144);
--_keycap-secondary-background-hover: var(--keycap-secondary-background-hover, #4d5154);
--_keycap-secondary-text: var(--keycap-secondary-text, #e7ebee);
--keycap-secondary-border: transparent;
--keycap-secondary-border-bottom: transparent;
--_keycap-secondary-border: var(--keycap-secondary-border, transparent);
--_keycap-secondary-border-bottom: var(--keycap-secondary-border-bottom, transparent);
--_variant-panel-background: var(--variant-panel-background, #303030);
--_variant-keycap-text-active: var(--variant-keycap-text-active, #fff);
}
[theme='light'] .ML__keyboard {
--_accent-color: var(--keyboard-accent-color, #0c75d8);
--_background: var(--keyboard-background, #cacfd7);
--_border: var(--keyboard-border, #ddd);
--_toolbar-text: var(--keyboard-toolbar-text, #2c2e2f);
--_toolbar-background: var(--keyboard-toolbar-background, transparent);
--_toolbar-background-hover: var(--keyboard-toolbar-background-hover, #eee);
--_toolbar-background-selected: var(--keyboard-toolbar-background-selected, transparent);
--_horizontal-rule: var(--keyboard-horizontal-rule, 1px solid #fff);
--_keycap-background: var(--keycap-background, white);
--_keycap-background-hover: var(--keycap-background-hover, #f5f5f7);
--_keycap-background-active: var(--keycap-background-active, var(--_accent-color));
--_keycap-background-pressed: var(--keycap-background-pressed, var(--_accent-color));
--_keycap-border: var(--_keycap-border, #e5e6e9);
--_keycap-border-bottom: var(--_keycap-border-bottom, #8d8f92);
--_keycap-text: var(--keycap-text, #000);
--_keycap-text-active: var(--keycap-text-active, #fff);
--_keycap-text-hover: var(--keycap-text-hover, var(--_keycap-text));
--_keycap-text-pressed: var(--keycap-text-pressed, #fff);
--_keycap-shift-text: var(--keycap-shift-text, var(--_accent-color));
--_keycap-secondary-background: var(--keycap-secondary-background, #a0a9b8);
--_keycap-secondary-background-hover: var(--keycap-secondary-background-hover, #7d8795);
--_keycap-secondary-text: var(--keycap-secondary-text, #060707);
--_keycap-secondary-border: var(--keycap-secondary-border, #c5c9d0);
--_keycap-secondary-border-bottom: var(--keycap-secondary-border-bottom, #989da6);
--_variant-panel-background: var(--variant-panel-background, #fff);
--_variant-keycap-text: var(--variant-keycap-textvar, var(--_keycap-text));
--_variant-keycap-text-active: var(--variant-keycap-text-active, var(--_keycap-text-active));
--_variant-keycap-background-active: var(--variant-keycap-background-active, var(--_accent-color));
}
`,mf=`:host {
--primary-color: #5898ff;
--primary-color-dimmed: #c0c0f0;
--primary-color-dark: var(--blue-500);
--primary-color-light: var(--blue-100);
--primary-color-reverse: #ffffff;
--secondary-color: #ff8a65;
--secondary-color-dimmed: #f0d5c5;
--secondary-color-dark: var(--orange-500);
--secondary-color-light: var(--orange-100);
--secondary-color-reverse: #ffffff;
--link-color: #5898ff;
--link-color-dimmed: #c5c5c5;
--link-color-dark: #121212;
--link-color-light: #e2e2e2;
--link-color-reverse: #ffffff;
--semantic-blue: var(--blue-700);
--semantic-red: var(--red-400);
--semantic-orange: var(--orange-400);
--semantic-green: var(--green-700);
--neutral-100: #f5f5f5;
--neutral-200: #eeeeee;
--neutral-300: #e0e0e0;
--neutral-400: #bdbdbd;
--neutral-500: #9e9e9e;
--neutral-600: #757575;
--neutral-700: #616161;
--neutral-800: #424242;
--neutral-900: #212121;
--red-25: #fff8f7;
--red-50: #fff1ef;
--red-100: #ffeae6;
--red-200: #ffcac1;
--red-300: #ffa495;
--red-400: #ff7865;
--red-500: #f21c0d;
--red-600: #e50018;
--red-700: #d30024;
--red-800: #bd002c;
--red-900: #a1002f;
--orange-25: #fffbf8;
--orange-50: #fff7f1;
--orange-100: #fff3ea;
--orange-200: #ffe1c9;
--orange-300: #ffcca2;
--orange-400: #ffb677;
--orange-500: #fe9310;
--orange-600: #f58700;
--orange-700: #ea7c00;
--orange-800: #dc6d00;
--orange-900: #ca5b00;
--brown-25: #fff8ef;
--brown-50: #fff1df;
--brown-100: #ffe9ce;
--brown-200: #ebcca6;
--brown-300: #cdaf8a;
--brown-400: #af936f;
--brown-500: #856a47;
--brown-600: #7f5e34;
--brown-700: #78511f;
--brown-800: #6e4200;
--brown-900: #593200;
--yellow-25: #fffdf9;
--yellow-50: #fffcf2;
--yellow-100: #fffaec;
--yellow-200: #fff2ce;
--yellow-300: #ffe8ab;
--yellow-400: #ffdf85;
--yellow-500: #ffcf33;
--yellow-600: #f1c000;
--yellow-700: #dfb200;
--yellow-800: #c9a000;
--yellow-900: #ad8a00;
--lime-25: #f4ffee;
--lime-50: #e9ffdd;
--lime-100: #ddffca;
--lime-200: #a8fb6f;
--lime-300: #94e659;
--lime-400: #80d142;
--lime-500: #63b215;
--lime-600: #45a000;
--lime-700: #268e00;
--lime-800: #007417;
--lime-900: #005321;
--green-25: #f5fff5;
--green-50: #ebffea;
--green-100: #e0ffdf;
--green-200: #a7ffa7;
--green-300: #5afa65;
--green-400: #45e953;
--green-500: #17cf36;
--green-600: #00b944;
--green-700: #00a34a;
--green-800: #008749;
--green-900: #00653e;
--teal-25: #f3ffff;
--teal-50: #e6fffe;
--teal-100: #d9fffe;
--teal-200: #8dfffe;
--teal-300: #57f4f4;
--teal-400: #43e5e5;
--teal-500: #17cfcf;
--teal-600: #00c2c0;
--teal-700: #00b5b1;
--teal-800: #00a49e;
--teal-900: #009087;
--cyan-25: #f7fcff;
--cyan-50: #eff8ff;
--cyan-100: #e7f5ff;
--cyan-200: #c2e6ff;
--cyan-300: #95d5ff;
--cyan-400: #61c4ff;
--cyan-500: #13a7ec;
--cyan-600: #069eda;
--cyan-700: #0095c9;
--cyan-800: #0088b2;
--cyan-900: #0a7897;
--blue-25: #f7faff;
--blue-50: #eef5ff;
--blue-100: #e5f1ff;
--blue-200: #bfdbff;
--blue-300: #92c2ff;
--blue-400: #63a8ff;
--blue-500: #0d80f2;
--blue-600: #0077db;
--blue-700: #006dc4;
--blue-800: #0060a7;
--blue-900: #005086;
--indigo-25: #f8f7ff;
--indigo-50: #f1efff;
--indigo-100: #eae7ff;
--indigo-200: #ccc3ff;
--indigo-300: #ac99ff;
--indigo-400: #916aff;
--indigo-500: #63c;
--indigo-600: #5a21b2;
--indigo-700: #4e0b99;
--indigo-800: #3b0071;
--indigo-900: #220040;
--purple-25: #fbf7ff;
--purple-50: #f8f0ff;
--purple-100: #f4e8ff;
--purple-200: #e4c4ff;
--purple-300: #d49aff;
--purple-400: #c36aff;
--purple-500: #a219e6;
--purple-600: #9000c4;
--purple-700: #7c009f;
--purple-800: #600073;
--purple-900: #3d0043;
--magenta-25: #fff8fb;
--magenta-50: #fff2f6;
--magenta-100: #ffebf2;
--magenta-200: #ffcddf;
--magenta-300: #ffa8cb;
--magenta-400: #ff7fb7;
--magenta-500: #eb4799;
--magenta-600: #da3689;
--magenta-700: #c82179;
--magenta-800: #b00065;
--magenta-900: #8a004c;
}
@media (prefers-color-scheme: dark) {
:host {
--semantic-blue: var(--blue-700);
--semantic-red: var(--red-400);
--semantic-orange: var(--orange-400);
--semantic-green: var(--green-700);
--semantic-bg-blue: var(--blue-25);
--semantic-bg-red: var(--red-25);
--semantic-bg-orange: var(--orange-25);
--semantic-bg-green: var(--green-25);
--neutral-100: #121212;
--neutral-200: #424242;
--neutral-300: #616161;
--neutral-400: #757575;
--neutral-500: #9e9e9e;
--neutral-600: #bdbdbd;
--neutral-700: #e0e0e0;
--neutral-800: #eeeeee;
--neutral-900: #f5f5f5;
}
}
:host([theme='dark']) {
--semantic-blue: var(--blue-700);
--semantic-red: var(--red-400);
--semantic-orange: var(--orange-400);
--semantic-green: var(--green-700);
--semantic-bg-blue: var(--blue-25);
--semantic-bg-red: var(--red-25);
--semantic-bg-orange: var(--orange-25);
--semantic-bg-green: var(--green-25);
--neutral-100: #121212;
--neutral-200: #424242;
--neutral-300: #616161;
--neutral-400: #757575;
--neutral-500: #9e9e9e;
--neutral-600: #bdbdbd;
--neutral-700: #e0e0e0;
--neutral-800: #eeeeee;
--neutral-900: #f5f5f5;
}
/* @media (prefers-color-scheme: dark) {
:host {
--label-color: #fff;
--active-label-color: #000;
--menu-bg: #525252;
--active-bg: #5898ff;
--active-bg-dimmed: #5c5c5c;
}
} */
:host {
--ui-font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont,
'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji',
'Segoe UI Emoji', 'Segoe UI Symbol';
--ui-font-size: 14px;
--ui-line-height: 1.5;
--ui-letter-spacing: 0.007em;
--mono-font-family: 'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono',
'Source Code Pro', Menlo, Monaco, 'Courier New', monospace;
--ui-layer-1: var(--neutral-100);
--ui-layer-2: var(--neutral-200);
--ui-layer-3: var(--neutral-300);
--ui-layer-4: var(--neutral-400);
--ui-layer-5: var(--neutral-500);
--ui-layer-6: var(--neutral-600);
--ui-border-color: var(--primary-color);
--ui-border-radius: 4px;
--ui-text: var(--neutral-900);
--ui-text-secondary: var(--neutral-700);
--ui-text-placeholder: var(--neutral-500);
--ui-text-muted: var(--neutral-300);
/** A field is a UI element in which a user can type data, for
* example an input or textarea element.
*/
--ui-field-bg: var(--neutral-100);
--ui-field-bg-hover: var(--neutral-100);
--ui-field-bg-disabled: var(--neutral-300);
--ui-field-bg-invalid: var(--red-100);
--ui-field-bg-focus: var(--neutral-100);
--ui-field-border: 0.5px solid var(--border-color);
--ui-field-border-hover: 0.5px solid var(--border-color);
--ui-field-border-disabled: 0.5px solid var(--border-color);
--ui-field-border-invalid: 0.5px solid var(--border-color);
--ui-field-border-focus: 0.5px solid var(--border-color);
--ui-menu-bg: var(--neutral-100);
--ui-menu-text: var(--neutral-900);
--ui-menu-bg-hover: var(--neutral-200);
--ui-menu-text-hover: var(--neutral-900);
/** The \`active\` state is used for the state of menu items
* when they are selected.
*/
--ui-menu-bg-active: var(--primary-color);
--ui-menu-text-active: var(--primary-color-reverse);
/** The \`active-muted\` set is used for the state of
* submenus when they are open.
*/
--ui-menu-bg-active-muted: var(--neutral-300);
--ui-menu-text-active-muted: var(--neutral-900);
/* --ui-menu-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.302),
0 2px 6px 2px rgba(60, 64, 67, 0.149); */
--ui-menu-shadow: 0 0 2px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 0, 0, 0.2);
--ui-menu-divider: 0.5px solid #c7c7c7;
/* var(--neutral-300); */
--ui-menu-z-index: 10000;
--page-bg: var(--neutral-100);
--content-bg: var(--neutral-200);
}
@media (prefers-color-scheme: dark) {
:host {
--ui-menu-bg: var(--neutral-200);
}
}
:host([theme='dark']) {
--ui-menu-bg: var(--neutral-200);
}
/* PingFang SC is a macOS font. Microsoft Yahei is a Windows font.
Noto is a Linux/Android font.
*/
:lang(zh-cn),
:lang(zh-sg),
:lang(zh-my),
:lang(zh) {
--ui-font-family: -apple-system, system-ui, 'PingFang SC', 'Hiragino Sans GB',
'Noto Sans CJK SC', 'Noto Sans SC', 'Noto Sans', 'Microsoft Yahei UI',
'Microsoft YaHei New', 'Microsoft Yahei', '\u5FAE\u8F6F\u96C5\u9ED1', SimSun, '\u5B8B\u4F53',
STXihei, '\u534E\u6587\u7EC6\u9ED1', sans-serif;
}
:lang(zh-tw),
:lang(zh-hk),
:lang(zh-mo) {
--ui-font-family: -apple-system, system-ui, 'Noto Sans',
'Microsoft JhengHei UI', 'Microsoft JhengHei', '\u5FAE\u8EDF\u6B63\u9ED1\u9AD4', '\u65B0\u7D30\u660E\u9AD4',
'PMingLiU', '\u7D30\u660E\u9AD4', 'MingLiU', sans-serif;
}
:lang(ja),
:lang(ja-jp),
:lang(ja-jp-mac) {
--ui-font-family: -apple-system, system-ui, 'Hiragino Sans',
'Hiragino Kaku Gothic ProN', 'Noto Sans CJK JP', 'Noto Sans JP', 'Noto Sans',
'\u6E38\u30B4\u30B7\u30C3\u30AF', '\u6E38\u30B4\u30B7\u30C3\u30AF\u4F53', YuGothic, 'Yu Gothic', '\u30E1\u30A4\u30EA\u30AA', Meiryo,
'\uFF2D\uFF33 \uFF30\u30B4\u30B7\u30C3\u30AF', 'MS PGothic', sans-serif;
}
:lang(ko),
:lang(ko-kr),
:lang(ko-kr-std) {
--ui-font-family: -apple-system, system-ui, 'Noto Sans CJK KR', 'Noto Sans KR',
'Noto Sans', 'Malgun Gothic', '\uB9D1\uC740 \uACE0\uB515', 'Apple SD Gothic Neo',
'\uC560\uD50C SD \uC0B0\uB3CC\uACE0\uB515 Neo', 'Apple SD \uC0B0\uB3CC\uACE0\uB515 Neo', '\uB3CB\uC6C0', Dotum, sans-serif;
}
:lang(ko-kr-apple) {
--ui-font-family: -apple-system, system-ui, 'Noto Sans CJK KR', 'Noto Sans KR',
'Noto Sans', 'Apple SD Gothic Neo', '\uC560\uD50C SD \uC0B0\uB3CC\uACE0\uB515 Neo',
'Apple SD \uC0B0\uB3CC\uACE0\uB515 Neo', '\uB3CB\uC6C0', Dotum, sans-serif;
}
:lang(zh-cn),
:lang(zh-sg),
:lang(zh-my),
:lang(zh),
:lang(zh-tw),
:lang(zh-hk),
:lang(zh-mo),
:lang(ja),
:lang(ja-jp),
:lang(ja-jp-mac),
:lang(ko),
:lang(ko-kr),
:lang(ko-kr-std),
:lang(ko-kr-apple) {
--ui-font-size: 1rem;
--ui-line-height: 1.7;
--ui-letter-spacing: 0;
}
:dir(rtl) {
--ui-line-height: auto;
--ui-letter-spacing: 0;
}
`,$o=`.ui-menu *,
.ui-menu ::before,
.ui-menu ::after {
box-sizing: border-box;
}
.ui-menu {
display: none;
color-scheme: light dark;
-webkit-user-select: none;
/* Important: Safari iOS doesn't respect user-select */
user-select: none;
cursor: default;
-webkit-touch-callout: none;
-webkit-tap-highlight-color: rgba(0 0 0 0);
--active-label-color: #fff;
/* ui-menu-text-active */
--label-color: #121212;
/* ui-menu-text */
--menu-bg: #e2e2e2;
/* ui-menu-background */
--active-bg: #5898ff;
/* ui-menu-background-active */
--active-bg-dimmed: #c5c5c5;
/* ui-menu-background-active-muted */
}
/** Use the :where pseudo selector to make the specificity of the
* selector 0, so that it can be overridden by the user.
*/
:where(.ui-menu-container) {
position: absolute;
overflow: visible;
width: auto;
height: auto;
z-index: 10000;
border-radius: 8px;
background: var(--ui-menu-bg);
box-shadow: var(--ui-menu-shadow);
list-style: none;
padding: 6px 0 6px 0;
margin: 0;
user-select: none;
cursor: default;
color: var(--ui-menu-text);
font-weight: normal;
font-style: normal;
text-shadow: none;
text-transform: none;
letter-spacing: 0;
outline: none;
opacity: 1;
/* The [popover] elements have a 1px solid black border. Ugh. */
border: none;
width: fit-content;
height: fit-content;
}
:where(.ui-menu-container > li) {
display: flex;
flex-flow: row;
align-items: center;
padding: 1px 7px 1px 7px;
margin-top: 0;
margin-left: 6px;
margin-right: 6px;
border-radius: 4px;
white-space: nowrap;
position: relative;
outline: none;
fill: currentColor;
user-select: none;
cursor: default;
text-align: left;
color: inherit;
font-family: var(--ui-font-family);
font-size: var(--ui-font-size);
line-height: var(--ui-line-height);
letter-spacing: var(--ui-letter-spacing);
}
:where(.ui-menu-container > li > .label) {
appearance: none;
background: none;
outline: none;
width: 100%;
margin: 0;
padding: 1px 2px 1px 1px;
overflow: visible;
border: 1px solid transparent;
white-space: nowrap;
text-align: start;
}
:where(.ui-menu-container > li:has(.heading)) {
margin-top: 0.5em;
}
:where(.ui-menu-container > li > .label.heading) {
font-weight: bold;
opacity: 0.4;
}
:where(.ui-menu-container > li.indent > .label) {
margin-inline-start: 12px;
}
:where(.ui-menu-container > li > .label.indent) {
margin-inline-start: 12px;
}
:where(.ui-menu-container > li[role='divider']) {
border-bottom: 1px solid var(--ui-menu-divider);
border-radius: 0;
padding: 0;
margin-left: 15px;
margin-right: 15px;
padding-top: 5px;
margin-bottom: 5px;
width: calc(100% - 30px);
/** 100% - (margin-left + margin-right) */
}
:where(.ui-menu-container > li[aria-disabled='true']) {
opacity: 0.5;
}
:where(.ui-menu-container > li.active) {
background: var(--ui-menu-bg-active);
background: -apple-system-control-accent;
color: var(--ui-menu-text-active);
}
:where(.ui-menu-container > li.active.is-submenu-open) {
background: var(--ui-menu-bg-active-muted);
color: inherit;
}
:where(.ui-menu-container > li[aria-haspopup='true'] > .label) {
padding-inline-end: 0;
}
:where(.ui-menu-container > li[aria-haspopup='true'].active::after) {
color: var(--ui-menu-text-active);
}
/** Keyboard shortcut */
:where(.ui-menu-container > li > kbd) {
font-family: var(--ui-font-family);
margin-inline-start: 12px;
opacity: 0.4;
}
:where(.ui-menu-container > li.active > kbd) {
opacity: 0.85;
}
.ui-trailing-chevron {
display: flex;
margin-inline-start: 24px;
width: 10px;
height: 10px;
margin-bottom: 4px;
}
.ui-trailing-chevron:dir(rtl) {
transform: scaleX(-1);
}
.ui-checkmark {
display: flex;
margin-inline-end: -11px;
margin-inline-start: -4px;
margin-top: 2px;
width: 16px;
height: 16px;
}
.ui-mixedmark {
display: flex;
margin-inline-end: -11px;
margin-inline-start: -4px;
margin-top: 2px;
width: 16px;
height: 16px;
}
`,Js;function uo(e){let i="";switch(e){case"mathfield-element":i=`
:host { display: inline-block; background-color: field; color: fieldtext; border-width: 1px; border-style: solid; border-color: #acacac; border-radius: 2px; padding:4px;}
:host([hidden]) { display: none; }
:host([disabled]), :host([disabled]:focus), :host([disabled]:focus-within) { outline: none; opacity: .5; }
:host(:focus), :host(:focus-within) {
outline: Highlight auto 1px; /* For Firefox */
outline: -webkit-focus-ring-color auto 1px;
}
:host([readonly]:focus), :host([readonly]:focus-within),
:host([read-only]:focus), :host([read-only]:focus-within) {
outline: none;
}
@media (hover: none) and (pointer: coarse) {
:host(:not(:focus)) :first-child { pointer-events: none !important; }
}`;break;case"core":i=Dd;break;case"mathfield":i=Cu;break;case"environment-popover":i=xs;break;case"suggestion-popover":i=df;break;case"keystroke-caption":i=Cd;break;case"virtual-keyboard":i=pf;break;case"ui":i=mf;break;case"menu":i=$o;break;default:debugger}return i}function Ko(e){return Js||(Js={}),Js[e]||(Js[e]=new CSSStyleSheet,Js[e].replaceSync(uo(e))),Js[e]}var Ms;function ca(e){var i;if(!("adoptedStyleSheets"in document)){if(window.document.getElementById(`mathlive-style-${e}`))return;const r=window.document.createElement("style");r.id=`mathlive-style-${e}`,r.append(window.document.createTextNode(uo(e))),window.document.head.appendChild(r);return}if(Ms||(Ms={}),((i=Ms[e])!=null?i:0)!==0)Ms[e]+=1;else{const r=Ko(e);document.adoptedStyleSheets=[...document.adoptedStyleSheets,r],Ms[e]=1}}function Da(e){if("adoptedStyleSheets"in document&&Ms!=null&&Ms[e]&&(Ms[e]-=1,Ms[e]<=0)){const i=Js[e];document.adoptedStyleSheets=document.adoptedStyleSheets.filter(r=>r!==i)}}var Ca=class Vp extends et{constructor(i){var r;super(d(P({},i),{type:"accent",body:(r=i.body)!=null?r:void 0})),i.accentChar?this.accent=i.accentChar:this.svgAccent=i==null?void 0:i.svgAccent,this.skipBoundary=!0,this.captureSelection=!0}static fromJson(i){return new Vp(i)}toJson(){return d(P({},super.toJson()),{accentChar:this.accent,svgAccent:this.svgAccent})}render(i){var r;const a=new Si({parent:i,mathstyle:"cramp"},this.style),u=(r=et.createBox(a,this.body))!=null?r:new Tt("\u25A2",{style:this.style});let p=0;!this.hasEmptyBranch("body")&&this.body.length===2&&this.body[1].isCharacterBox()&&(p=u.skew);let g=Math.min(u.height,ua),b;if(this.svgAccent)b=xu(this.svgAccent),g=a.metrics.bigOpSpacing1-g;else if(this.accent){const E=new Tt(this.accent,{fontFamily:"Main-Regular"});E.italic=0;const R=this.accent===8407?" ML__accent-vec":"";b=new Tt(new Tt(E),{classes:"ML__accent-body"+R})}b=new kr({shift:0,children:[{box:new Tt(u)},-g,{box:b,marginLeft:u.left+2*p,classes:["ML__center"]}]});const w=new Tt(b,{type:"lift"});return this.caret&&(w.caret=this.caret),this.bind(a,w.wrap(a)),this.attachSupsub(a,{base:w})}},ha={"(":")","{":"}","[":"]","|":"|","\\lbrace":"\\rbrace","\\lparen":"\\rparen","\\{":"\\}","\\langle":"\\rangle","\\lfloor":"\\rfloor","\\lceil":"\\rceil","\\vert":"\\vert","\\lvert":"\\rvert","\\Vert":"\\Vert","\\lVert":"\\rVert","\\lbrack":"\\rbrack","\\ulcorner":"\\urcorner","\\llcorner":"\\lrcorner","\\lgroup":"\\rgroup","\\lmoustache":"\\rmoustache"},co=Object.fromEntries(Object.entries(ha).map(([e,i])=>[i,e]));function Mu(e){var i;return(i={"[":91,"]":93,"(":40,")":41,"\\mid":8739,"|":8739,"\u2223":8739,"\u2225":8741,"\\|":8739,"\\{":123,"\\}":125,"\\lbrace":123,"\\rbrace":125,"\\lparen":40,"\\rparen":41,"\\lbrack":91,"\\rbrack":93,"\\vert":8739,"\\lvert":8739,"\\mvert":8739,"\\rvert":8739,"\\Vert":8741,"\\lVert":8741,"\\mVert":8741,"\\rVert":8741,"\\parallel":8741,"\\shortparallel":8741,"\\langle":10216,"\\rangle":10217,"\\lfloor":8970,"\\rfloor":8971,"\\lceil":8968,"\\rceil":8969,"\\ulcorner":9484,"\\urcorner":9488,"\\llcorner":9492,"\\lrcorner":9496,"\\lgroup":10222,"\\rgroup":10223,"\\lmoustache":9136,"\\rmoustache":9137,"\\surd":8730}[e])!=null?i:e.codePointAt(0)}function Md(e,i,r,a){var u;const g=new Tt(Mu(e),{fontFamily:"Main-Regular",isSelected:a.isSelected,classes:"ML__small-delim "+((u=a.classes)!=null?u:"")}).wrap(i);return r&&g.setTop((1-i.scalingFactor)*gs),g}function Ru(e,i,r,a,u){var p,g;const b=new Si({parent:a,mathstyle:"textstyle"},u==null?void 0:u.style),w=new Tt(Mu(e),{fontFamily:`Size${i}-Regular`,isSelected:u.isSelected,classes:((p=u.classes)!=null?p:"")+` ML__delim-size${i}`,type:(g=u.type)!=null?g:"ignore"}).wrap(b);return r&&w.setTop((1-b.scalingFactor)*gs),w}function Uc(e,i,r,a,u){var p;let g,b,w,E;g=w=E=Mu(e),b=null;let R="Size1-Regular";e==="\\vert"||e==="\\lvert"||e==="\\rvert"||e==="\\mvert"||e==="\\mid"?w=g=E=8739:e==="\\Vert"||e==="\\lVert"||e==="\\rVert"||e==="\\mVert"||e==="\\|"?w=g=E=8741:e==="\\uparrow"?w=E=9168:e==="\\Uparrow"?w=E=8214:e==="\\downarrow"?g=w=9168:e==="\\Downarrow"?g=w=8214:e==="\\updownarrow"?(g=8593,w=9168,E=8595):e==="\\Updownarrow"?(g=8657,w=8214,E=8659):e==="["||e==="\\lbrack"?(g=9121,w=9122,E=9123,R="Size4-Regular"):e==="]"||e==="\\rbrack"?(g=9124,w=9125,E=9126,R="Size4-Regular"):e==="\\lfloor"||e==="\u230A"?(w=g=9122,E=9123,R="Size4-Regular"):e==="\\lceil"||e==="\u2308"?(g=9121,w=E=9122,R="Size4-Regular"):e==="\\rfloor"||e==="\u230B"?(w=g=9125,E=9126,R="Size4-Regular"):e==="\\rceil"||e==="\u2309"?(g=9124,w=E=9125,R="Size4-Regular"):e==="("||e==="\\lparen"?(g=9115,w=9116,E=9117,R="Size4-Regular"):e===")"||e==="\\rparen"?(g=9118,w=9119,E=9120,R="Size4-Regular"):e==="\\{"||e==="\\lbrace"?(g=9127,b=9128,E=9129,w=9130,R="Size4-Regular"):e==="\\}"||e==="\\rbrace"?(g=9131,b=9132,E=9133,w=9130,R="Size4-Regular"):e==="\\lgroup"||e==="\u27EE"?(g=9127,E=9129,w=9130,R="Size4-Regular"):e==="\\rgroup"||e==="\u27EF"?(g=9131,E=9133,w=9130,R="Size4-Regular"):e==="\\lmoustache"||e==="\u23B0"?(g=9127,E=9133,w=9130,R="Size4-Regular"):e==="\\rmoustache"||e==="\u23B1"?(g=9131,E=9129,w=9130,R="Size4-Regular"):e==="\\surd"?(g=57345,E=9143,w=57344,R="Size4-Regular"):e==="\\ulcorner"?(g=9484,w=E=32):e==="\\urcorner"?(g=9488,w=E=32):e==="\\llcorner"?(E=9492,w=g=32):e==="\\lrcorner"&&(g=9496,w=g=32);const N=Aa(g,R),Z=N.height+N.depth,ue=Aa(w,R),me=ue.height+ue.depth,Ve=Aa(E,R),Ct=Ve.height+Ve.depth;let Ue=0,ct=1;if(b!==null){const Gr=Aa(b,R);Ue=Gr.height+Gr.depth,ct=2}const It=Z+Ct+Ue,yt=Math.max(0,Math.ceil((i-It)/(ct*me))),ei=It+yt*ct*me;let hi=gs;r&&(hi=hi*a.scalingFactor);const ai=ei/2-hi,on=.008,Bn=[];Bn.push({box:new Tt(E,{fontFamily:R})}),Bn.push(-on);const Nt=new Tt(w,{fontFamily:R});if(b===null)for(let Gr=0;Gr<yt;Gr++)Bn.push({box:Nt});else{for(let Gr=0;Gr<yt;Gr++)Bn.push({box:Nt});Bn.push(-on),Bn.push({box:new Tt(b,{fontFamily:R})}),Bn.push(-on);for(let Gr=0;Gr<yt;Gr++)Bn.push({box:Nt})}Bn.push(-on),Bn.push({box:new Tt(g,{fontFamily:R})});let Gs="";R==="Size1-Regular"?Gs=" delim-size1":R==="Size4-Regular"&&(Gs=" delim-size4");const Ka=new kr({bottom:ai,children:Bn},{classes:Gs});return new Tt(Ka,d(P({},u!=null?u:{}),{classes:((p=u==null?void 0:u.classes)!=null?p:"")+" ML__delim-mult"}))}var Iu=new Set(["(",")","\\lparen","\\rparen","[","]","\\lbrack","\\rbrack","\\{","\\}","\\lbrace","\\rbrace","\\lfloor","\\rfloor","\\lceil","\\rceil","\\surd","\u230A","\u230B","\u2308","\u2309"]),Rd=new Set(["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\mvert","\\mid","\\lgroup","\\rgroup","\\lmoustache","\\rmoustache","\u27EE","\u27EF","\u23B0","\u23B1"]),ho=new Set(["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"]),Id=[0,1.2,1.8,2.4,3];function gf(e,i,r,a){return e===void 0||e==="."?fo(r,a.classes):(e==="<"||e==="\\lt"||e==="\u27E8"?e="\\langle":(e===">"||e==="\\gt"||e==="\u27E9")&&(e="\\rangle"),Iu.has(e)||ho.has(e)?Ru(e,i,!1,r,a):Rd.has(e)?Uc(e,Id[i],!1,r,a):(console.assert(!1,"Unknown delimiter '"+e+"'"),null))}var Pd=[{type:"small",mathstyle:"scriptscriptstyle"},{type:"small",mathstyle:"scriptstyle"},{type:"small",mathstyle:"textstyle"},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],Vs=[{type:"small",mathstyle:"scriptscriptstyle"},{type:"small",mathstyle:"scriptscriptstyle"},{type:"small",mathstyle:"textstyle"},{type:"stack"}],Od=[{type:"small",mathstyle:"scriptscriptstyle"},{type:"small",mathstyle:"scriptstyle"},{type:"small",mathstyle:"textstyle"},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}];function _f(e){return e.type==="small"?"Main-Regular":e.type==="large"?"Size"+e.size+"-Regular":(console.assert(e.type==="stack"),"Size4-Regular")}function Pu(e,i,r,a){const u={"-4":0,"-3":1,0:2}[a.mathstyle.sizeDelta];for(let p=u;p<r.length&&r[p].type!=="stack";p++){const g=Aa(e,_f(r[p]));if(g.defaultMetrics)return{type:"small",mathstyle:"scriptstyle"};let b=g.height+g.depth;if(r[p].type==="small"&&(r[p].mathstyle==="scriptscriptstyle"?b*=Math.max(Oo[Math.max(1,a.size-2)],a.minFontScale):r[p].mathstyle==="scriptstyle"&&(b*=Math.max(Oo[Math.max(1,a.size-1)],a.minFontScale))),b>i)return r[p]}return r[r.length-1]}function Ou(e,i,r,a,u,p){if(!i||i.length===0||i===".")return fo(u);i==="<"||i==="\\lt"?i="\\langle":(i===">"||i==="\\gt")&&(i="\\rangle");let g;ho.has(i)?g=Pd:Iu.has(i)?g=Od:g=Vs;const b=Pu(Mu(i),r,g,u),w=new Si({parent:u,mathstyle:b.mathstyle},p==null?void 0:p.style);return b.type==="small"?Md(i,w,a,d(P({},p),{type:e})):b.type==="large"?Ru(i,b.size,a,w,d(P({},p),{type:e})):(console.assert(b.type==="stack"),Uc(i,r,a,w,d(P({},p),{type:e})))}function Uo(e,i,r,a,u,p){if(i===".")return fo(u,p==null?void 0:p.classes);const g=gs*u.scalingFactor,b=901,w=5/Po,E=Math.max(r-g,a+g),R=Math.max(E/500*b,2*E-w);return Ou(e,i,R,!0,u,p)}function fo(e,i){const r=new Tt(null,{classes:" nulldelimiter "+(i!=null?i:""),type:"ignore"});return r.width=e.getRegisterAsEm("nulldelimiterspace"),r.wrap(new Si({parent:e,mathstyle:"textstyle"}))}var fa=class Gp extends et{constructor(i){var r;super({type:"placeholder",command:"\\placeholder",mode:(r=i==null?void 0:i.mode)!=null?r:"math",style:i==null?void 0:i.style}),this.captureSelection=!0}static fromJson(i){return new Gp(i)}toJson(){return super.toJson()}render(i){let r;return this.value=i.placeholderSymbol,typeof i.renderPlaceholder=="function"?r=i.renderPlaceholder(i):r=this.createBox(i),this.caret&&(r.classes+=" ML__placeholder-selected"),r}_serialize(i){return i.skipPlaceholders?"":"\\placeholder{}"}},vf=["matrix","matrix*","pmatrix","pmatrix*","bmatrix","bmatrix*","Bmatrix","Bmatrix*","vmatrix","vmatrix*","Vmatrix","Vmatrix*"],zc=["cases","dcases","rcases"],Rs=["align","align*","aligned","gather","gathered","split"],da=["array","subequations","eqnarray"];function Fd(e){return da.concat(Rs).concat(zc).concat(vf).includes(e)}function yf(e){return vf.includes(e)}function Bd(e){return zc.includes(e)}function Nd(e){return Rs.includes(e)}function $d(e,i,r){let a=0;for(const E of r)"align"in E&&(a+=1);let u=0;const p=[];for(const E of i){let R=0;for(u=Math.max(u,Math.min(E.length,a));R<E.length;){const N=[],Z=Math.min(E.length,R+a);for(;R<Z;){const ue=E[R];ue.length===0?N.push([new et({type:"first",mode:e.mode})]):ue[0].type!=="first"?N.push([new et({type:"first",mode:e.mode}),...ue]):(console.assert(!ue.slice(1).some(me=>me.type==="first")),N.push(ue)),R+=1}p.push(N)}}p.length>0&&p[p.length-1].length===1&&p[p.length-1][0].length===1&&p[p.length-1][0][0].type==="first"&&p.pop();const g=[];for(const E of p){if(E.length!==u)for(let R=E.length;R<u;R++)E.push([new et({type:"first",mode:e.mode}),new fa]);g.push(E)}let b=0,w=0;for(const E of g){w=0;for(const R of E){for(const N of R)N.parent=e,N.parentBranch=[b,w];w+=1}b+=1}return e.isDirty=!0,g}var Tn=class Hp extends et{constructor(i,r,a,u={}){var p;super({type:"array"}),this.environmentName=i,this.rowGaps=a,u.mathstyleName&&(this.mathstyleName=u.mathstyleName),u.columns&&(u.columns.length===0?this.colFormat=[{align:"l"}]:this.colFormat=u.columns),this.colFormat||(this.colFormat=[{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"}]),this.array=$d(this,r,this.colFormat),u.leftDelim&&(this.leftDelim=u.leftDelim),u.rightDelim&&(this.rightDelim=u.rightDelim),u.arraycolsep!==void 0&&(this.arraycolsep=u.arraycolsep),this.colSeparationType=u.colSeparationType,u.arraystretch!==void 0&&(this.arraystretch=u.arraystretch),this.minColumns=(p=u.minColumns)!=null?p:1}static fromJson(i){return new Hp(i.environmentName,i.array,i.rowGaps,i)}toJson(){const i=d(P({},super.toJson()),{environmentName:this.environmentName,array:this.array.map(r=>r.map(a=>a.map(u=>u.toJson()))),rowGaps:this.rowGaps,columns:this.colFormat,colSeparationType:this.colSeparationType});return this.arraystretch!==void 0&&(i.arraystretch=this.arraystretch),this.arraycolsep!==void 0&&(i.arraycolsep=this.arraycolsep),this.leftDelim&&(i.leftDelim=this.leftDelim),this.rightDelim&&(i.rightDelim=this.rightDelim),i}branch(i){var r;if(ku(i))return(r=this.array[i[0]][i[1]])!=null?r:void 0}createBranch(i){var r;return ku(i)?(this.isDirty=!0,(r=this.branch(i))!=null?r:[]):[]}get rowCount(){return this.array.length}get colCount(){return this.array[0].length}get maxColumns(){return this.colFormat.filter(i=>!!i.align).length}removeBranch(i){if(_s(i))return super.removeBranch(i);const r=this.branch(i);return this.array[i[0]][i[1]]=void 0,r.forEach(a=>{a.parent=void 0,a.parentBranch=void 0}),console.assert(r[0].type==="first"),r.shift(),this.isDirty=!0,r}get hasChildren(){return this.children.length>0}get children(){const i=[];for(const r of this.array)for(const a of r)if(a)for(const u of a)i.push(...u.children),i.push(u);return[...i,...super.children]}render(i){var r,a,u,p,g,b;const w=new Si({parent:i,mathstyle:this.mathstyleName},this.style),E=w.getRegisterAsEm("arrayrulewidth"),R=w.getRegisterAsEm("arraycolsep"),N=w.getRegisterAsEm("doublerulesep"),Z=(a=(r=this.arraystretch)!=null?r:w.getRegisterAsNumber("arraystretch"))!=null?a:1;let ue=typeof this.arraycolsep=="number"?this.arraycolsep:R;this.colSeparationType==="small"&&(ue=.2778*(new Si({parent:i,mathstyle:"scriptstyle"}).scalingFactor/i.scalingFactor));const me=Z*od,Ve=.7*me,Ct=.3*me;let Ue=0;const ct=[];let It=0;const yt=this.array.length;for(let zn=0;zn<yt;++zn){const br=this.array[zn];It=Math.max(It,br.length);const Hr=new Si({parent:w,mathstyle:this.mathstyleName},this.style);let Ua=Ve/Hr.scalingFactor,za=Ct/Hr.scalingFactor;const Va={cells:[],height:0,depth:0,pos:0};for(const _a of br){const B0=(u=et.createBox(Hr,_a,{type:"ignore"}))!=null?u:new Tt(null,{type:"ignore"});za=Math.max(za,B0.depth),Ua=Math.max(Ua,B0.height),Va.cells.push(B0)}let Ga=(p=sf(this.rowGaps[zn]))!=null?p:0;Ga>0&&(Ga+=Ct,za=Math.max(za,Ga),Ga=0),zn<yt-1&&!yf(this.environmentName)&&this.environmentName!=="cases"&&this.environmentName!=="array"&&(za+=w.getRegisterAsEm("jot")),Va.height=Ua,Va.depth=za,Ue+=Ua,Va.pos=Ue,Ue+=za+Ga,ct.push(Va)}const ei=Ue/2+gs,hi=[];for(let zn=0;zn<It;zn++){const br=[];for(const Hr of ct){const Ua=Hr.cells[zn];Ua.depth=Hr.depth,Ua.height=Hr.height,br.push({box:Ua,shift:Hr.pos-ei})}br.length>0&&hi.push(new kr({individualShift:br}))}const ai=[];let on=!1,Bn=!1,Nt=0,Gs=!this.leftDelim;const{colFormat:Ka}=this;for(const zn of Ka){if("align"in zn&&Nt>=hi.length)break;if("align"in zn)on?ai.push(Tl(2*ue)):(Bn||Gs)&&ai.push(Tl(ue)),ai.push(new Tt(hi[Nt],{classes:"col-align-"+zn.align})),Nt++,on=!0,Bn=!1,Gs=!1;else if("gap"in zn){if(typeof zn.gap=="number")ai.push(Tl(zn.gap));else{const br=Kd(i,ct,ei,zn.gap);br&&ai.push(br)}on=!1,Bn=!1,Gs=!1}else if("separator"in zn){const br=new Tt(null,{classes:"vertical-separator"});br.height=Ue,br.setStyle("height",Ue,"em"),br.setStyle("border-right",`${E}em ${zn.separator} currentColor`),br.setStyle("vertical-align",-(Ue-ei),"em");let Hr=0;Bn?Hr=N-E:on&&(Hr=ue-E),br.left=Hr,ai.push(br),on=!1,Bn=!0,Gs=!1}}on&&!this.rightDelim&&ai.push(Tl(ue));const ta=new Tt(ai,{classes:"mtable"});if((!this.leftDelim||this.leftDelim===".")&&(!this.rightDelim||this.rightDelim==="."))return this.caret&&(ta.caret=this.caret),this.bind(i,ta);const Gr=ta.height,Hs=ta.depth,ks=this.bind(i,new Tt([this.bind(i,Uo("open",(g=this.leftDelim)!=null?g:".",Gr,Hs,w,{isSelected:this.isSelected})),ta,this.bind(i,Uo("close",(b=this.rightDelim)!=null?b:".",Gr,Hs,w,{isSelected:this.isSelected}))],{type:"ord"}));return ks?(ks.setStyle("display","inline-block"),this.caret&&(ks.caret=this.caret),this.bind(i,this.attachSupsub(i,{base:ks}))):null}_serialize(i){var r;const a=[];if(this.environmentName==="lines"?a.push("{\\displaylines"):a.push(`\\begin{${this.environmentName}}`),this.environmentName==="array"){if(a.push("{"),this.colFormat!==void 0)for(const u of this.colFormat)"align"in u&&typeof u.align=="string"?a.push(u.align):"separator"in u&&u.separator==="solid"?a.push("|"):"separator"in u&&u.separator==="dashed"&&a.push(":");a.push("}")}for(let u=0;u<this.array.length;u++){for(let p=0;p<this.array[u].length;p++)p>0&&a.push(" & "),a.push(et.serialize(this.array[u][p],i));if(u<this.array.length-1){const p=this.rowGaps[u];p!=null&&p.dimension?a.push(`\\\\[${p.dimension} ${(r=p.unit)!=null?r:"pt"}] `):a.push("\\\\ ")}}return this.environmentName==="lines"?a.push("}"):a.push(`\\end{${this.environmentName}}`),sn(a)}getCell(i,r){return this.array[i][r]}setCell(i,r,a){console.assert(this.type==="array"&&Array.isArray(this.array)&&this.array[i][r]!==void 0);for(const p of this.array[i][r])p.parent=void 0,p.parentBranch=void 0;let u=a;(a.length===0||a[0].type!=="first")&&(u=[new et({type:"first",mode:this.mode}),...a]),this.array[i][r]=u;for(const p of u)p.parent=this,p.parentBranch=[i,r];this.isDirty=!0}addRowBefore(i){console.assert(this.type==="array"&&Array.isArray(this.array));const r=[];for(let a=0;a<this.colCount;a++)r.push(Qs(this));this.array.splice(i,0,r);for(let a=i;a<this.rowCount;a++)for(let u=0;u<this.colCount;u++){const p=this.array[a][u];if(p)for(const g of p)g.parentBranch=[a,u]}this.isDirty=!0}addRowAfter(i){console.assert(this.type==="array"&&Array.isArray(this.array));const r=[];for(let a=0;a<this.colCount;a++)r.push(Qs(this));this.array.splice(i+1,0,r);for(let a=i+1;a<this.rowCount;a++)for(let u=0;u<this.colCount;u++){const p=this.array[a][u];if(p)for(const g of p)g.parentBranch=[a,u]}this.isDirty=!0}removeRow(i){console.assert(this.type==="array"&&Array.isArray(this.array)&&this.rowCount>i);const r=this.array.splice(i,1);for(const a of r)for(const u of a)if(u)for(const p of u)p.parent=void 0,p.parentBranch=void 0;for(let a=i;a<this.rowCount;a++)for(let u=0;u<this.colCount;u++){const p=this.array[a][u];if(p)for(const g of p)g.parentBranch=[a,u]}this.isDirty=!0}addColumnBefore(i){console.assert(this.type==="array"&&Array.isArray(this.array));for(const r of this.array)r.splice(i,0,Qs(this));for(let r=0;r<this.rowCount;r++)for(let a=i;a<this.colCount;a++){const u=this.array[r][a];if(u)for(const p of u)p.parentBranch=[r,a]}this.isDirty=!0}addColumnAfter(i){console.assert(this.type==="array"&&Array.isArray(this.array));for(const r of this.array)r.splice(i+1,0,Qs(this));for(let r=0;r<this.rowCount;r++)for(let a=i+1;a<this.colCount;a++){const u=this.array[r][a];if(u)for(const p of u)p.parentBranch=[r,a]}this.isDirty=!0}addColumn(){this.addColumnAfter(this.colCount-1)}removeColumn(i){console.assert(this.type==="array"&&Array.isArray(this.array)&&this.colCount>i);for(const r of this.array){const a=r.splice(i,1);for(const u of a)if(u)for(const p of u)p.parent=void 0,p.parentBranch=void 0}for(let r=0;r<this.rowCount;r++)for(let a=i;a<this.colCount;a++){const u=this.array[r][a];if(u)for(const p of u)p.parentBranch=[r,a]}this.isDirty=!0}get cells(){const i=[];for(const r of this.array)for(const a of r)a&&i.push(a.filter(u=>u.type!=="first"));return i}};function Qs(e){const i=new et({type:"first",mode:e.mode});i.parent=e;const r=new fa;return r.parent=e,[i,r]}function Tl(e){const i=new Tt(null,{classes:"arraycolsep"});return i.width=e,i}function Kd(e,i,r,a){if(!a)return null;const u=[];for(const p of i){const g=et.createBox(e,a,{type:"ignore"});g&&(g.depth=p.depth,g.height=p.height,u.push({box:g,shift:p.pos-r}))}return new kr({individualShift:u}).wrap(e)}var Ma=class Wp extends et{constructor(i){super({mode:i.mode,command:i.command,style:i.style,body:i.body,type:"box"}),this.framecolor=i.framecolor,this.backgroundcolor=i.backgroundcolor,this.padding=i.padding,this.offset=i.offset,this.border=i.border}static fromJson(i){return new Wp(i)}toJson(){return d(P({},super.toJson()),{framecolor:this.framecolor,backgroundcolor:this.backgroundcolor,padding:this.padding,offset:this.offset,border:this.border})}render(i){var r,a,u,p;const g=et.createBox(i,this.body,{type:"lift"});if(!g)return null;const b=i.toEm((r=this.offset)!=null?r:{dimension:0});g.depth+=b,g.setStyle("display","inline-block"),g.setStyle("position","relative"),g.setStyle("height",Math.floor(100*g.height+g.depth)/100,"em"),g.setStyle("vertical-align",-Math.floor(100*g.height)/100,"em");const w=new Si({parent:i},this.style),E=w.toEm((a=this.padding)!=null?a:{register:"fboxsep"}),R=new Tt(null,{classes:"ML__box"});R.height=g.height+E,R.depth=g.depth+E,R.setStyle("box-sizing","border-box"),R.setStyle("position","absolute"),R.setStyle("top",-E+.3,"em"),R.setStyle("left",0),R.setStyle("height",R.height+R.depth,"em"),R.setStyle("width","100%"),this.backgroundcolor&&R.setStyle("background-color",(u=w.toColor(this.backgroundcolor))!=null?u:"transparent"),this.framecolor&&R.setStyle("border",`${w.getRegisterAsEm("fboxrule",2)}em solid ${(p=w.toColor(this.framecolor))!=null?p:"black"}`),this.border&&R.setStyle("border",this.border);const N=new Tt([R,g],{type:"lift"});return N.setStyle("display","inline-block"),N.setStyle("position","relative"),N.setStyle("line-height",0),N.height=g.height+E+(b>0?b:0),N.depth=g.depth+E+(b<0?-b:0),N.setStyle("padding-left",E,"em"),N.setStyle("padding-right",E,"em"),N.setStyle("height",Math.floor(100*(g.height+g.depth+2*E+Math.abs(b)))/100,"em"),N.setStyle("margin-top",-E,"em"),N.setStyle("top",Math.floor(100*(g.depth-g.height+2*E-b))/100,"em"),N.setStyle("vertical-align",Math.floor(100*(g.depth+2*E))/100,"em"),this.caret&&(N.caret=this.caret),this.attachSupsub(i,{base:N})}_serialize(i){return i.skipStyles?sn([this.bodyToLatex(i),this.supsubToLatex(i)]):super._serialize(i)}},Fu=class jp extends et{constructor(i,r){var a;super({type:"composition",mode:(a=r==null?void 0:r.mode)!=null?a:"math",value:i})}static fromJson(i){return new jp(i.value,i)}toJson(){return super.toJson()}get computedStyle(){return{}}render(i){const r=new Tt(this.value,{classes:"ML__composition",type:"composition"});return this.bind(i,r),this.caret&&(r.caret=this.caret),r}_serialize(i){return""}},Ra=class qp extends et{constructor(i){super({type:"error",value:i,command:i,mode:"math"}),this.verbatimLatex=i}static fromJson(i){return new qp(i.command)}toJson(){return super.toJson()}render(i){const r=this.createBox(i,{classes:"ML__error"});return this.caret&&(r.caret=this.caret),r}},Vc=class Zp extends et{constructor(i,r,a){super({type:"group",mode:r,style:a}),this.body=i,this.boxType=i.length>1?"ord":"ignore",this.skipBoundary=!0,this.displayContainsHighlight=!1,i&&i.length===1&&i[0].command===","&&(this.captureSelection=!0)}static fromJson(i){return new Zp(i.body,i.mode,i.style)}render(i){const r=et.createBox(i,this.body,{type:this.boxType});return r?(this.caret&&(r.caret=this.caret),this.bind(i,r)):null}_serialize(i){if(!(i.expandMacro||i.skipStyles||i.skipPlaceholders)&&typeof this.verbatimLatex=="string")return this.verbatimLatex;const r=Me(this.command,this.mode);return r!=null&&r.serialize?r.serialize(this,i):`{${this.bodyToLatex(i)}}`}},Zn=class Yp extends et{constructor(i,r,a){super({type:"leftright",style:a.style,displayContainsHighlight:!0}),this.variant=i,this.body=r,this.leftDelim=a.leftDelim,this.rightDelim=a.rightDelim}static fromJson(i){var r;return new Yp((r=i.variant)!=null?r:"",i.body,i)}toJson(){const i=super.toJson();return this.variant&&(i.variant=this.variant),this.leftDelim&&(i.leftDelim=this.leftDelim),this.rightDelim&&(i.rightDelim=this.rightDelim),i}_serialize(i){var r,a;const u=this.matchingRightDelim();return this.variant==="left...right"?sn(["\\left",(r=this.leftDelim)!=null?r:".",this.bodyToLatex(i),"\\right",u]):this.variant==="mleft...mright"?sn(["\\mleft",(a=this.leftDelim)!=null?a:".",this.bodyToLatex(i),"\\mright",u]):sn([!this.leftDelim||this.leftDelim==="."?"":this.leftDelim,this.bodyToLatex(i),u])}matchingRightDelim(){var i,r;if(this.rightDelim&&this.rightDelim!=="?")return this.rightDelim;const a=(i=this.leftDelim)!=null?i:".";return(r=ha[a])!=null?r:a}render(i){var r,a;const u=new Si({parent:i},this.style);console.assert(this.body!==void 0);const p=new Si({parent:i,mathstyle:"textstyle"},this.style),g=(r=et.createBox(u,this.body,{type:"inner"}))!=null?r:new Tt(null,{type:"inner"}),b=g.height/p.scalingFactor,w=g.depth/p.scalingFactor,E=[];if(this.leftDelim&&E.push(this.bind(p,Uo("open",this.leftDelim,b,w,p,{isSelected:this.isSelected,classes:"ML__open"+(this.containsCaret?" ML__contains-caret":""),mode:this.mode,style:this.style}))),g&&(bf(g.children,this,u,b,w),E.push(g)),this.rightDelim){let ue=this.containsCaret?" ML__contains-caret":"",me=this.rightDelim;me==="?"&&(u.smartFence?(me=this.matchingRightDelim(),ue+=" ML__smart-fence__close"):me="."),E.push(this.bind(p,Uo("close",me,b,w,p,{isSelected:this.isSelected,classes:ue+" ML__close",mode:this.mode,style:this.style})))}let R=this.variant==="mleft...mright";const N=this.leftSibling;N&&(!R&&N.isFunction&&(R=!0),!R&&N.type==="subsup"&&((a=N.leftSibling)!=null&&a.isFunction)&&(R=!0));const Z=new Tt(E,{type:R?"close":"inner",classes:"left-right"});return Z.setStyle("margin-top",`${-g.depth}em`),Z.setStyle("height",`${g.height+g.depth}em`),this.caret&&(Z.caret=this.caret),this.bind(u,Z.wrap(u))}};function bf(e,i,r,a,u){if(e)for(let p=0;p<e.length;p++){const g=e[p];g.type==="middle"?(e[p]=i.bind(r,Uo("inner",g.value,a,u,r,{isSelected:i.isSelected})),e[p].caret=g.caret,e[p].isSelected=g.isSelected,e[p].cssId=g.cssId,e[p].htmlData=g.htmlData,e[p].htmlStyle=g.htmlStyle,e[p].attributes=g.attributes,e[p].cssProperties=g.cssProperties):g.children&&bf(g.children,i,r,a,u)}}var xf=class Xp extends et{constructor(i,r){var a;super({type:"macro",command:i,style:r.style}),this.body=r.body,r.captureSelection===void 0?r.args?this.captureSelection=!1:this.captureSelection=!0:this.captureSelection=r.captureSelection,this.macroArgs=r.args,this.expand=(a=r.expand)!=null?a:!1}static fromJson(i){return new Xp(i.command,i)}toJson(){const i=super.toJson();return this.expand&&(i.expand=!0),this.captureSelection!==void 0&&(i.captureSelection=this.captureSelection),this.macroArgs&&(i.args=this.macroArgs),i}_serialize(i){var r;return i.expandMacro&&this.expand?this.bodyToLatex(i):this.command+((r=this.macroArgs)!=null?r:"")}render(i){const r=et.createBox(i,this.body);return r?(this.caret&&(r.caret=this.caret),this.bind(i,r)):null}},Gc=class Jp extends et{constructor(){super({type:"macro-argument"})}static fromJson(i){return new Jp}toJson(){return super.toJson()}_serialize(i){return""}render(i){return null}},wf=class Qp extends et{constructor(i,r,a=!1,u,p){var g;super({type:"prompt",mode:(g=p==null?void 0:p.mode)!=null?g:"math",style:p==null?void 0:p.style,command:"\\placeholder"}),this.body=u,this.correctness=r,this.placeholderId=i,this.locked=a,this.captureSelection=this.locked}static fromJson(i){return new Qp(i.placeholderId,i.correctness,i.locked,i.body,i)}toJson(){const i=super.toJson();return this.placeholderId&&(i.placeholderId=this.placeholderId),this.body||delete i.body,this.body&&(i.body=this.body.filter(r=>r.type!=="first").map(r=>r.toJson())),this.correctness&&(i.correctness=this.correctness),i.locked=this.locked,i}render(i){const r=new Si({parent:i}),a=r.getRegisterAsEm("fboxsep"),u=a,p=a,g=et.createBox(i,this.body);if(!g)return null;g.height||(g.height=r.metrics.xHeight),g.setStyle("vertical-align",-g.height,"em"),this.correctness==="correct"?g.setStyle("color","var(--correct-color, var(--ML__correct-color))"):this.correctness==="incorrect"&&g.setStyle("color","var(--incorrect-color, var(--ML__incorrect-color))");const b=new Tt(g,{type:"ord"});b.setStyle("display","inline-block"),b.setStyle("height",g.height+g.depth,"em"),b.setStyle("vertical-align",-p,"em");let w="ML__prompt ";this.locked?w+=" ML__lockedPromptBox ":w+=" ML__editablePromptBox ",this.correctness==="correct"?w+=" ML__correctPromptBox ":this.correctness==="incorrect"&&(w+=" ML__incorrectPromptBox "),this.containsCaret&&(w+=" ML__focusedPromptBox ");const E=new Tt(null,{classes:w,attributes:{part:"prompt"}});E.height=b.height+p,E.depth=b.depth+p,E.width=b.width+2*u,E.setStyle("box-sizing","border-box"),E.setStyle("position","absolute"),E.setStyle("height",b.height+b.depth+2*p,"em"),u===0&&E.setStyle("width","100%"),u!==0&&(E.setStyle("width",`calc(100% + ${2*u}em)`),E.setStyle("top",a,"em"),E.setStyle("left",-u,"em")),(!this.body||this.body.length===1)&&(E.width=3*u,E.setStyle("width",`calc(100% + ${3*u}em)`),E.setStyle("left",-1.5*u,"em"));let R="";this.correctness==="incorrect"&&(R+='<line x1="3%" y1="97%" x2="97%" y2="3%" stroke-width="0.5" stroke="var(--incorrect-color, var(--ML__incorrect-color))" stroke-linecap="round" />'),R&&(E.svgOverlay=R);const N=new Tt([E,b],{classes:"ML__prompt-atom"});return N.setStyle("position","relative"),N.setStyle("display","inline-block"),N.setStyle("line-height",0),N.height=b.height+p+.2,N.depth=b.depth+p,N.left=u,N.right=u,N.setStyle("height",b.height+p,"em"),N.setStyle("top",b.depth-b.height,"em"),N.setStyle("vertical-align",b.depth+p,"em"),N.setStyle("margin-left",.5,"em"),N.setStyle("margin-right",.5,"em"),this.caret&&(N.caret=this.caret),this.bind(r,this.attachSupsub(i,{base:N}))}_serialize(i){var r;const a=(r=this.bodyToLatex(i))!=null?r:"";if(i.skipPlaceholders)return a;let u="\\placeholder";return this.placeholderId&&(u+=`[${this.placeholderId}]`),this.correctness==="correct"?u+="[correct]":this.correctness==="incorrect"&&(u+="[incorrect]"),this.locked&&(u+="[locked]"),jn(u,a)}},Al=class em extends et{constructor(i){super({type:"subsup",style:i==null?void 0:i.style}),this.subsupPlacement="auto"}static fromJson(i){const r=new em(i);for(const a of Cs)i[a]&&r.setChildren(i[a],a);return r}render(i){var r;const a=new Si({parent:i,isPhantom:!0}),u=this.leftSibling,p=(r=u.render(a))!=null?r:new Tt(null),g=new Tt(null);return g.height=p.height,g.depth=p.depth,this.attachSupsub(i,{base:g,isCharacterBox:u.isCharacterBox(),type:"ignore"})}_serialize(i){return this.supsubToLatex(i)}};function zo(e){return e?!/^(<$$>|<$>|<space>|<{>|<}>|#[0-9\?]|\\.+)$/.test(e):!1}var Hc=class{constructor(e,i,r){this.errors=[],this.index=0,this.endCount=0;var a,u,p,g;r!=null||(r={}),this.tokens=e,this.context=i instanceof Si&&!(r!=null&&r.parseMode)&&!r.mathstyle?i:new Si({from:i,mathstyle:r.mathstyle},r.style),this.args=(a=r.args)!=null?a:void 0,this.smartFence=this.context.smartFence,this.parsingContext={parent:void 0,mathlist:[],style:(u=r.style)!=null?u:{},parseMode:(p=r.parseMode)!=null?p:"math",mathstyle:(g=r.mathstyle)!=null?g:"displaystyle",tabular:!1}}beginContext(e){var i,r,a;const u=this.parsingContext,p={parent:u,mathlist:[],style:P({},u.style),parseMode:(i=e==null?void 0:e.mode)!=null?i:u.parseMode,mathstyle:(r=e==null?void 0:e.mathstyle)!=null?r:u.mathstyle,tabular:(a=e==null?void 0:e.tabular)!=null?a:!1};this.parsingContext=p}endContext(){this.parsingContext=this.parsingContext.parent}onError(e){this.errors.push(P({before:no(this.tokens.slice(this.index,this.index+10)),after:no(this.tokens.slice(Math.max(0,this.index-10),this.index))},e))}get mathlist(){return this.parsingContext.mathlist}set mathlist(e){this.parsingContext.mathlist=e}get parseMode(){return this.parsingContext.parseMode}set parseMode(e){this.parsingContext.parseMode=e}get tabularMode(){return this.parsingContext.tabular}get style(){let e=this.parsingContext;for(;e;){if(e.style)return P({},e.style);e=e.parent}return{}}set style(e){this.parsingContext.style=e}end(){return this.endCount++,this.index>=this.tokens.length||this.endCount>1e3}next(){this.index+=1}get(){return this.endCount=0,this.index<this.tokens.length?this.tokens[this.index++]:""}peek(){return this.tokens[this.index]}match(e){return this.tokens[this.index]===e?(this.index++,!0):!1}lastSubsupAtom(){let e;return this.mathlist.length>0&&(e=this.mathlist[this.mathlist.length-1],e.type==="subsup"||e.subsupPlacement!==void 0)||(e=new Al({style:this.style}),this.mathlist.push(e)),e}hasPattern(e){return e.test(this.tokens[this.index])}hasInfixCommand(){var e;const{index:i}=this;if(i<this.tokens.length&&this.tokens[i].startsWith("\\")){const r=Me(this.tokens[i],this.parseMode);return!r||r.definitionType==="symbol"||r.ifMode&&!r.ifMode.includes(this.parseMode)?!1:(e=r.infix)!=null?e:!1}return!1}matchColumnSeparator(){return!this.tabularMode||this.peek()!=="&"?!1:(this.index++,!0)}matchRowSeparator(){if(!this.tabularMode)return!1;const e=this.peek();return e!=="\\\\"&&e!=="\\cr"&&e!=="\\tabularnewline"?!1:(this.index++,!0)}placeholder(){var e;const i=(e=this.args)==null?void 0:e.call(this,"?");return i?zr(i,{parseMode:this.parseMode,mathstyle:"textstyle"}):[new fa({mode:this.parseMode,style:this.style})]}skipWhitespace(){for(;this.match("<space>"););}skipUntilToken(e){let i=this.tokens[this.index];for(;i&&i!==e;)i=this.tokens[++this.index];i===e&&this.index++}skipFiller(){for(;this.match("\\relax")||this.match("<space>"););}matchKeyword(e){const i=this.index;let r=this.end(),a="";for(;!r;){const p=this.get();zo(p)?(a+=p,r=this.end()||a.length>=e.length):r=!0}const u=e.toUpperCase()===a.toUpperCase();return u||(this.index=i),u}scanString(){let e="";for(;!this.end();){const i=this.peek();if(i==="]")return e;if(i==="<space>")e+=" ";else if(i.startsWith("\\"))this.onError({code:"unexpected-command-in-string"}),e+=i.substring(1);else if(zo(i))e+=i;else return e;this.next()}return e}scanBalancedString(){let e="",i=this.end(),r=1;for(;!i;){const a=this.get();a==="<space>"?e+=" ":a==="<{>"?(e+="{",r+=1):a==="<}>"?(r-=1,r>0?e+="}":this.index-=1):a==="<$>"?e+="$":a==="<$$>"?e+="$$":e+=a,i=r===0||this.end()}return e}scanLiteralGroup(){var e;if(!this.match("<{>"))return"";let i="",r=1;for(;r>0&&!this.end();){const a=this.get();a==="<}>"?(r-=1,r>0&&(i+="}")):a==="<{>"?(r+=1,i+="{"):(/\\[a-zA-Z]+$/.test(i)&&/^[a-zA-Z]/.test(a)&&(i+=" "),i+=(e={"<space>":" ","<$$>":"$$","<$>":"$"}[a])!=null?e:a)}return i}scanNumber(e=!0){var i,r;let a=!1,u=this.peek();for(;u==="<space>"||u==="+"||u==="-";)this.get(),u==="-"&&(a=!a),u=this.peek();e=!!e;let p=10,g=/\d/;if(this.match("'"))p=8,g=/[0-7]/,e=!0;else if(this.match('"'))p=16,g=/[\dA-F]/,e=!0;else if(this.match("x"))p=16,g=/[\dA-Fa-f]/,e=!0;else if(this.match("`"))return u=this.get(),u?u.length===2&&u.startsWith("\\")?{number:(a?-1:1)*((i=u.codePointAt(1))!=null?i:0),base:"alpha"}:{number:(a?-1:1)*((r=u.codePointAt(0))!=null?r:0),base:"alpha"}:null;let b="";for(;this.hasPattern(g);)b+=this.get();if(!e&&(this.match(".")||this.match(",")))for(b+=".";this.hasPattern(g);)b+=this.get();const w=e?Number.parseInt(b,p):Number.parseFloat(b);return Number.isNaN(w)?null:{number:a?-w:w,base:p===16?"hexadecimal":p===8?"octal":"decimal"}}scanRegister(){var e;const i=this.index,r=this.scanNumber(!1);if(this.skipWhitespace(),this.match("\\relax"))return r;let a=!1;if(r===null)for(;;){const p=this.peek();if(p==="-")a=!a;else if(p!=="+")break;this.next(),this.skipWhitespace()}if(this.match("\\global")){this.skipWhitespace();const p=this.get();return p.startsWith("\\")?r?{register:p,global:!0,factor:(a?-1:1)*r.number}:a?{register:p,global:!0,factor:-1}:{register:p,global:!0}:(this.index=i,null)}let u=this.get();return u!=null&&u.startsWith("\\")?(u=u.substring(1),this.context.registers[u]?!a||r!==null?{register:u,factor:(a?-1:1)*((e=r==null?void 0:r.number)!=null?e:1)}:{register:u}:(this.index=i,null)):(this.index=i,null)}scanValue(){const e=this.scanRegister();if(e)return e;const i=this.index,r=this.scanGlueOrDimen();if(r&&("unit"in r||"glue"in r&&"unit"in r.glue))return r;this.index=i;const a=this.scanNumber();if(a)return a;if(this.end()||!zo(this.peek()))return null;const u=this.scanString();return u.length>0?{string:u}:null}scanDimen(){const e=this.scanNumber(!1);if(e===null)return null;const i=e.number;this.skipWhitespace(),this.matchKeyword("true"),this.skipWhitespace();let r;return this.matchKeyword("pt")?r="pt":this.matchKeyword("mm")?r="mm":this.matchKeyword("cm")?r="cm":this.matchKeyword("ex")?r="ex":this.matchKeyword("px")?r="px":this.matchKeyword("em")?r="em":this.matchKeyword("bp")?r="bp":this.matchKeyword("dd")?r="dd":this.matchKeyword("pc")?r="pc":this.matchKeyword("in")?r="in":this.matchKeyword("mu")&&(r="mu"),r?{dimension:i,unit:r}:{dimension:i}}scanGlueOrDimen(){const e=this.scanDimen();if(e===null)return null;if(this.skipWhitespace(),this.match("\\relax"))return e;const i={glue:e};if(this.matchKeyword("plus")){const r=this.scanDimen();if(r)i.grow=r;else return i}if(this.skipWhitespace(),this.match("\\relax"))return i;if(this.skipWhitespace(),this.matchKeyword("minus")){const r=this.scanDimen();if(r)i.shrink=r;else return i}return!i.grow&&!i.shrink?e:i}scanColspec(){this.skipWhitespace();const e=[];for(;!this.end()&&!(this.peek()==="<}>"||this.peek()==="]");){const i=this.get();i==="c"||i==="r"||i==="l"?e.push({align:i}):i==="|"?e.push({separator:"solid"}):i===":"?e.push({separator:"dashed"}):i==="@"&&(this.match("<{>")&&(this.beginContext({mode:"math"}),e.push({gap:this.scan(r=>r==="<}>")}),this.endContext()),this.match("<}>")||this.onError({code:"unbalanced-braces"}))}return e}scanModeSet(){let e;if(this.match("\\(")&&(e="textstyle"),!e&&this.match("\\[")&&(e="displaystyle"),!e)return null;this.beginContext({mode:"math",mathstyle:e});const i=this.scan(r=>r===(e==="displaystyle"?"\\]":"\\)"));return this.match(e==="displaystyle"?"\\]":"\\)")||this.onError({code:"unbalanced-mode-shift"}),this.endContext(),i}scanModeShift(){let e="";if(this.match("<$>")&&(e="<$>"),!e&&this.match("<$$>")&&(e="<$$>"),!e)return null;this.beginContext({mode:"math",mathstyle:"textstyle"});const i=this.scan(r=>r===e);return this.match(e)||this.onError({code:"unbalanced-mode-shift"}),this.endContext(),i}scanEnvironment(){if(!this.match("\\begin"))return null;const e=this.scanArgument("string");if(!e)return null;const i=xe(e);if(!i)return this.onError({code:"unknown-environment",arg:e}),null;const r=[];if(i.params)for(const b of i.params)if(b.isOptional)r.push(this.scanOptionalArgument(b.type));else{const w=this.scanArgument(b.type);w||this.onError({code:"missing-argument",arg:e}),r.push(w)}this.beginContext({tabular:i.tabular});const a=[],u=[];let p=[],g=!1;do if(this.end()&&(this.onError({code:"unbalanced-environment",arg:e}),g=!0),!g&&this.match("\\end")&&(this.scanArgument("string")!==e&&this.onError({code:"unbalanced-environment",arg:e}),g=!0),!g)if(this.matchColumnSeparator())p.push(this.mathlist),this.mathlist=[];else if(this.matchRowSeparator()){p.push(this.mathlist),this.mathlist=[];let b=null;this.skipWhitespace(),this.match("[")&&(b=this.scanDimen(),this.skipWhitespace(),this.match("]")),u.push(b!=null?b:{dimension:0}),a.push(p),p=[]}else this.mathlist.push(...this.scan(b=>["<}>","&","\\end","\\cr","\\\\","\\tabularnewline"].includes(b)));while(!g);return p.push(this.mathlist),p.length>0&&a.push(p),this.endContext(),i.createAtom(e,a,u,r)}scanExpression(){const e=this.mathlist;if(this.mathlist=[],this.parseExpression()){const i=this.mathlist;return this.mathlist=e,i}return this.mathlist=e,null}scan(e){this.beginContext(),e||(e=g=>g==="<}>");let i="",r=null,a=[],u=null;for(;!this.end()&&!e(this.peek());)this.hasInfixCommand()&&!i?(i=this.get(),r=Me(i,"math"),r&&(a=this.scanArguments(r)[1]),u=this.mathlist,this.mathlist=[]):this.parseExpression();let p;return i?(console.assert(!!r),a.unshift(this.mathlist),u&&a.unshift(u),p=[r.createAtom({command:i,args:a,style:this.style,mode:this.parseMode})]):p=this.mathlist,this.endContext(),p}scanGroup(){const e=this.index;if(!this.match("<{>"))return null;const i=this.scan(a=>a==="<}>");this.match("<}>")||this.onError({code:"unbalanced-braces"});const r=new Vc(i,this.parseMode,this.style);return r.verbatimLatex=no(this.tokens.slice(e,this.index)),r}scanSmartFence(){if(this.skipWhitespace(),!this.match("("))return null;this.beginContext();let e=1;for(;!this.end()&&e!==0;)this.match("(")&&(e+=1),this.match(")")&&(e-=1),e!==0&&this.parseExpression();const i=new Zn("",this.mathlist,{leftDelim:"(",rightDelim:e===0?")":"?"});return this.endContext(),i}scanDelim(){this.skipWhitespace();const e=this.peek();if(!e)return this.onError({code:"unexpected-end-of-string"}),null;if(!zo(e)&&!e.startsWith("\\"))return null;this.next();const i=Me(e,"math");return i?i.definitionType==="function"&&i.ifMode&&!i.ifMode.includes(this.parseMode)?(this.onError({code:"unexpected-delimiter",arg:e}),null):i.definitionType==="symbol"&&(i.type==="mopen"||i.type==="mclose")||/^(\.|\?|\||<|>|\\vert|\\Vert|\\\||\\surd|\\uparrow|\\downarrow|\\Uparrow|\\Downarrow|\\updownarrow|\\Updownarrow|\\mid|\\mvert|\\mVert)$/.test(e)?e:(this.onError({code:"unexpected-delimiter",arg:e}),null):(this.onError({code:"unknown-command",arg:e}),null)}scanLeftRight(){var e;if(this.match("\\right"))return this.onError({code:"unbalanced-braces"}),new Ra("\\right");if(this.match("\\mright"))return this.onError({code:"unbalanced-braces"}),new Ra("\\mright");let i="\\right";if(!this.match("\\left")){if(!this.match("\\mleft"))return null;i="\\mright"}const r=this.scanDelim();if(!r)return this.onError({code:"unexpected-delimiter"}),new Ra(i==="\\right"?"\\left":"\\mleft");for(this.beginContext();!this.end()&&!this.match(i);)this.parseExpression();const a=this.mathlist;this.endContext();const u=(e=this.scanDelim())!=null?e:".";return new Zn(i==="\\right"?"left...right":"mleft...mright",a,{leftDelim:r,rightDelim:u,style:this.style})}parseSupSub(){if(this.parseMode!=="math")return!1;let e=this.peek();if(e!=="^"&&e!=="_"&&e!=="'")return!1;const i=this.lastSubsupAtom();for(;e==="^"||e==="_"||e==="'";)this.match("'")?this.match("'")?i.addChild(new et({type:"mord",command:"\\doubleprime",mode:"math",value:"\u2032\u2032"}),"superscript"):i.addChild(new et({type:"mord",command:"\\prime",mode:"math",value:"\u2032"}),"superscript"):(this.match("^")||this.match("_"))&&i.addChildren(Ce(this.scanArgument("expression")),e==="_"?"subscript":"superscript"),e=this.peek();return!0}parseLimits(){if(this.parseMode!=="math")return!1;const e=this.match("\\limits"),i=!e&&this.match("\\nolimits"),r=!i&&!e&&this.match("\\displaylimits");if(!e&&!i&&!r)return!1;const a=this.mathlist.length>0?this.mathlist[this.mathlist.length-1]:null;return a===null?!1:(a.explicitSubsupPlacement=!0,e&&(a.subsupPlacement="over-under"),i&&(a.subsupPlacement="adjacent"),r&&(a.subsupPlacement="auto"),!0)}scanArguments(e){if(!(e!=null&&e.params))return[void 0,[]];let i;const r=[];let a=e.infix?2:0;for(;a<e.params.length;){const u=e.params[a];u.type==="rest"?r.push(this.scan(p=>["<}>","&","\\end","\\cr","\\\\","\\tabularnewline","\\right"].includes(p))):u.isOptional?r.push(this.scanOptionalArgument(u.type)):u.type.endsWith("*")?i=u.type.slice(0,-1):r.push(this.scanArgument(u.type)),a+=1}return[i,r]}scanSymbolOrLiteral(){const e=this.peek();if(!e)return null;this.next();let i;if(zo(e)){const r=us.createAtom(this.parseMode,e,P({},this.style));return r?[r]:null}if(i=this.scanMacro(e),i)return[i];if(e.startsWith("\\")){const r=Me(e,this.parseMode);if(!r)return this.onError({code:"unknown-command",arg:e}),[new Ra(e)];if(r.definitionType==="symbol"){const a=P({},this.style);r.variant&&(a.variant=r.variant),i=new et({type:r.type,command:e,style:a,value:String.fromCodePoint(r.codepoint),mode:this.parseMode,verbatimLatex:e})}else{if(r.applyMode||r.applyStyle||r.infix)return this.onError({code:"invalid-command",arg:e}),[new Ra(e)];r.createAtom&&(i=r.createAtom({command:e,args:[],style:this.style,mode:this.parseMode}))}}return i?[i]:null}scanArgument(e){var i;this.skipFiller();const r=this.parseMode;if(e==="auto"&&(e=r),!this.match("<{>")){if(e==="string")return this.scanString();if(e==="value")return this.scanValue();if(e==="delim")return(i=this.scanDelim())!=null?i:".";if(e==="expression")return this.scanExpression();if(e==="math"){e!==r&&this.beginContext({mode:"math"});const u=this.scanSymbolOrLiteral();return e!==r&&this.endContext(),u}if(e==="text"){e!==r&&this.beginContext({mode:"text"});const u=this.scanSymbolOrLiteral();return e!==r&&this.endContext(),u}return e==="balanced-string"||console.assert(!1),null}if(e==="text"){this.beginContext({mode:"text"});do this.mathlist.push(...this.scan());while(!this.match("<}>")&&!this.end());const u=this.mathlist;return this.endContext(),{group:u}}if(e==="math"){this.beginContext({mode:"math"});do this.mathlist.push(...this.scan());while(!this.match("<}>")&&!this.end());const u=this.mathlist;return this.endContext(),{group:u}}let a=null;if(e==="expression"){this.beginContext({mode:"math"});do this.mathlist.push(...this.scan());while(!this.match("<}>")&&!this.end());const u=this.mathlist;return this.endContext(),{group:u}}return e==="string"?a=this.scanString():e==="balanced-string"?a=this.scanBalancedString():e==="colspec"?a=this.scanColspec():e==="value"&&(a=this.scanValue()),this.skipUntilToken("<}>"),a}scanOptionalArgument(e){if(e=e==="auto"?this.parseMode:e,this.skipFiller(),!this.match("["))return null;let i=null;for(;!this.end()&&!this.match("]");)if(e==="string")i=this.scanString();else if(e==="value")i=this.scanValue();else if(e==="colspec")i=this.scanColspec();else if(e==="bbox"){const r={},a=this.scanString().toLowerCase().trim().split(/,(?![^(]*\)(?:(?:[^(]*\)){2})*[^"]*$)/);for(const u of a){const p=u.match(/^\s*([\d.]+)\s*([a-z]{2})/);if(p)r.padding={dimension:parseInt(p[1]),unit:p[2]};else{const g=u.match(/^\s*border\s*:\s*(.*)/);g?r.border=g[1]:r.backgroundcolor={string:u}}}i=r}else e==="math"&&(this.beginContext({mode:"math"}),i=this.mathlist.concat(this.scan(r=>r==="]")),this.endContext());return i}scanSymbolOrCommand(e){var i,r,a;if(e==="\\placeholder"){const b=this.scanOptionalArgument("string"),w=this.scanOptionalArgument("math"),E=et.serialize(w,{defaultMode:"math"});let R=[],N;!N&&E==="correct"?N="correct":!N&&E==="incorrect"?N="incorrect":E!==""&&(R=w);const Z=this.scanOptionalArgument("string")==="locked",ue=this.scanArgument("auto");let me;return ue&&Array.isArray(ue)&&ue.length>0?me=ue:ue&&typeof ue=="object"&&"group"in ue?me=ue.group:me=R,b?[new wf(b,N,Z,me!=null?me:R,{mode:this.parseMode,style:this.style})]:[new fa({mode:this.parseMode,style:this.style})]}if(e==="\\renewcommand"||e==="\\newcommand"||e==="\\providecommand"||e==="\\def"){const b=this.index,w=this.scanLiteralGroup()||this.next();if(!w)return null;if(this.context.registers[w.substring(1)]){const E=this.scanArgument("string");E!==null&&(this.context.registers[w.substring(1)]=E);const R=sn([e,no(this.tokens.slice(b,this.index))]);return[new et({type:"text",value:"",verbatimLatex:R})]}}let u=this.scanMacro(e);if(u)return[u];const p=Me(e,this.parseMode);if(!p)return this.parseMode==="text"?(/[a-zA-Z]/.test((i=this.peek())!=null?i:"")&&(e+=" "),[...e].map(b=>new et({type:"text",value:b,mode:"text",style:this.style}))):(this.onError({code:"unknown-command",arg:e}),[new Ra(e)]);const g=this.index;if(p.definitionType==="symbol"){const b=P({},this.style);p.variant&&(b.variant=p.variant),u=new et({type:p.type,command:e,style:b,value:String.fromCodePoint(p.codepoint),mode:this.parseMode})}else{if(p.ifMode&&!p.ifMode.includes(this.parseMode))return[];const b=this.parseMode;p.applyMode&&(this.parseMode=p.applyMode);let w,E=[];if(p.parse?E=p.parse(this):[w,E]=this.scanArguments(p),this.parseMode=b,p.applyMode&&!p.applyStyle&&!p.createAtom)return Ce(E[0]);if(p.infix)return this.onError({code:"too-many-infix-commands",arg:e}),null;if(typeof p.createAtom=="function")u=p.createAtom({command:e,args:E,style:this.style,mode:this.parseMode}),w&&(u.body=Ce(this.scanArgument(w)));else if(typeof p.applyStyle=="function"){const R=P(P({},this.style),p.applyStyle(e,E,this.context)),N=this.parseMode;if(p.applyMode&&(this.parseMode=p.applyMode),w){const Z=this.style;this.style=R;const ue=this.scanArgument(w);return this.style=Z,this.parseMode=N,Ce(ue)}this.style=R}else u=new et({type:"mord",command:(r=p.command)!=null?r:e,style:P({},this.style),value:e,mode:(a=p.applyMode)!=null?a:this.parseMode})}if(!u)return null;if(u instanceof et&&u.verbatimLatex===void 0&&!/^\\(llap|rlap|class|cssId|htmlData)$/.test(e)){const b=sn([e,no(this.tokens.slice(g,this.index))]);b&&(u.verbatimLatex=b)}if(u.verbatimLatex===null&&(u.verbatimLatex=void 0),u.isFunction&&this.smartFence){const b=this.scanSmartFence();if(b)return[u,b]}return[u]}scanSymbolCommandOrLiteral(){const e=this.get();if(!e)return null;if(zo(e)){const i=us.createAtom(this.parseMode,e,P({},this.style));if(!i)return null;if(i.isFunction&&this.smartFence){const r=this.scanSmartFence();if(r)return[i,r]}return[i]}return e.startsWith("\\")?this.scanSymbolOrCommand(e):e==="<space>"?this.parseMode==="text"?[new No(" "," ",this.style)]:null:(e==="<}>"?this.onError({latex:"",code:"unbalanced-braces"}):this.onError({latex:"",code:"unexpected-token",arg:e}),null)}scanMacro(e){var i;const r=this.context.getMacro(e);if(!r)return null;const a=this.index,u=r.args,p={"?":(i=this.args)==null?void 0:i.call(this,"?")};for(let g=1;g<=u;g++){let b=this.scanLiteralGroup();if(!b){const w=this.index;this.scanExpression(),b=no(this.tokens.slice(w,this.index))}p[g]=b}return new xf(e,{expand:r.expand,captureSelection:r.captureSelection,args:a===this.index?null:no(this.tokens.slice(a,this.index)),style:this.parsingContext.style,body:zr(r.def,{context:this.context,parseMode:this.parseMode,args:g=>p[g],mathstyle:this.parsingContext.mathstyle,style:this.parsingContext.style})})}parseExpression(){var e,i,r,a;let u=(a=(r=(i=(e=this.scanEnvironment())!=null?e:this.scanModeShift())!=null?i:this.scanModeSet())!=null?r:this.scanGroup())!=null?a:this.scanLeftRight();if(u===null){if(this.parseSupSub()||this.parseLimits())return!0;u=this.scanSymbolCommandOrLiteral()}return u?(Array.isArray(u)?this.mathlist.push(...u):this.mathlist.push(u),!0):!1}};function zr(e,i){var r,a,u,p;const g=(r=i==null?void 0:i.args)!=null?r:void 0,b=new Hc(_u(e,g),i==null?void 0:i.context,{args:g,mathstyle:(a=i==null?void 0:i.mathstyle)!=null?a:"displaystyle",parseMode:(u=i==null?void 0:i.parseMode)!=null?u:"math",style:(p=i==null?void 0:i.style)!=null?p:{}}),w=[];for(;!b.end();)w.push(...b.scan(()=>!1));return w}function Ll(e,i){var r;const a=new Hc(_u(e,null),i==null?void 0:i.context,{mathstyle:"displaystyle",parseMode:(r=i==null?void 0:i.parseMode)!=null?r:"math"});for(;!a.end();)a.scan();return a.errors}var Sf=class tm extends et{constructor(i,r){super({type:"chem"},{command:i,mode:"math"});const a=Jn.go(Et.go(r,i==="\\pu"?"pu":"ce"),!1);this.body=zr(a),this._verbatimLatex=i+"{"+r+"}",this.arg=r,this.captureSelection=!0}static fromJson(i){return new tm(i.command,i.arg)}set verbatimLatex(i){}get verbatimLatex(){return this._verbatimLatex}toJson(){return d(P({},super.toJson()),{arg:this.arg})}render(i){const r=et.createBox(i,this.body,{type:"inner"});return this.caret&&(r.caret=this.caret),this.bind(i,r)}_serialize(i){return console.assert(this.verbatimLatex!==void 0),this.verbatimLatex}};ke(["ce","pu"],"{chemformula:balanced-string}",{createAtom:e=>{var i;return new Sf(e.command,(i=e.args[0])!=null?i:"")}});var Et={go:function(e,i){if(!e)return[];i===void 0&&(i="ce");var r="0",a={};a.parenthesisLevel=0,e=e.replace(/\n/g," "),e=e.replace(/[\u2212\u2013\u2014\u2010]/g,"-"),e=e.replace(/[\u2026]/g,"...");for(var u,p=10,g=[];;){u!==e?(p=10,u=e):p--;var b=Et.stateMachines[i],w=b.transitions[r]||b.transitions["*"];e:for(var E=0;E<w.length;E++){var R=Et.patterns.match_(w[E].pattern,e);if(R){for(var N=w[E].task,Z=0;Z<N.action_.length;Z++){var ue;if(b.actions[N.action_[Z].type_])ue=b.actions[N.action_[Z].type_](a,R.match_,N.action_[Z].option);else if(Et.actions[N.action_[Z].type_])ue=Et.actions[N.action_[Z].type_](a,R.match_,N.action_[Z].option);else throw["MhchemBugA","mhchem bug A. Please report. ("+N.action_[Z].type_+")"];Et.concatArray(g,ue)}if(r=N.nextState||r,e.length>0){if(N.revisit||(e=R.remainder),!N.toContinue)break e}else return g}}if(p<=0)throw["MhchemBugU","mhchem bug U. Please report."]}},concatArray:function(e,i){if(i)if(Object.prototype.toString.call(i)==="[object Array]")for(var r=0;r<i.length;r++)e.push(i[r]);else e.push(i)},patterns:{patterns:{empty:/^$/,else:/^./,else2:/^./,space:/^\s/,"space A":/^\s(?=[A-Z\\$])/,space$:/^\s$/,"a-z":/^[a-z]/,x:/^x/,x$:/^x$/,i$:/^i$/,letters:/^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/,"\\greek":/^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/,"one lowercase latin letter $":/^(?:([a-z])(?:$|[^a-zA-Z]))$/,"$one lowercase latin letter$ $":/^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/,"one lowercase greek letter $":/^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/,digits:/^[0-9]+/,"-9.,9":/^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/,"-9.,9 no missing 0":/^[+\-]?[0-9]+(?:[.,][0-9]+)?/,"(-)(9.,9)(e)(99)":function(e){var i=e.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:(?:([eE])|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/);return i&&i[0]?{match_:i.slice(1),remainder:e.substr(i[0].length)}:null},"(-)(9)^(-9)":function(e){var i=e.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/);return i&&i[0]?{match_:i.slice(1),remainder:e.substr(i[0].length)}:null},"state of aggregation $":function(e){var i=Et.patterns.findObserveGroups(e,"",/^\([a-z]{1,3}(?=[\),])/,")","");if(i&&i.remainder.match(/^($|[\s,;\)\]\}])/))return i;var r=e.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/);return r?{match_:r[0],remainder:e.substr(r[0].length)}:null},"_{(state of aggregation)}$":/^_\{(\([a-z]{1,3}\))\}/,"{[(":/^(?:\\\{|\[|\()/,")]}":/^(?:\)|\]|\\\})/,", ":/^[,;]\s*/,",":/^[,;]/,".":/^[.]/,". ":/^([.\u22C5\u00B7\u2022])\s*/,"...":/^\.\.\.(?=$|[^.])/,"* ":/^([*])\s*/,"^{(...)}":function(e){return Et.patterns.findObserveGroups(e,"^{","","","}")},"^($...$)":function(e){return Et.patterns.findObserveGroups(e,"^","$","$","")},"^a":/^\^([0-9]+|[^\\_])/,"^\\x{}{}":function(e){return Et.patterns.findObserveGroups(e,"^",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"^\\x{}":function(e){return Et.patterns.findObserveGroups(e,"^",/^\\[a-zA-Z]+\{/,"}","")},"^\\x":/^\^(\\[a-zA-Z]+)\s*/,"^(-1)":/^\^(-?\d+)/,"'":/^'/,"_{(...)}":function(e){return Et.patterns.findObserveGroups(e,"_{","","","}")},"_($...$)":function(e){return Et.patterns.findObserveGroups(e,"_","$","$","")},_9:/^_([+\-]?[0-9]+|[^\\])/,"_\\x{}{}":function(e){return Et.patterns.findObserveGroups(e,"_",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"_\\x{}":function(e){return Et.patterns.findObserveGroups(e,"_",/^\\[a-zA-Z]+\{/,"}","")},"_\\x":/^_(\\[a-zA-Z]+)\s*/,"^_":/^(?:\^(?=_)|\_(?=\^)|[\^_]$)/,"{}":/^\{\}/,"{...}":function(e){return Et.patterns.findObserveGroups(e,"","{","}","")},"{(...)}":function(e){return Et.patterns.findObserveGroups(e,"{","","","}")},"$...$":function(e){return Et.patterns.findObserveGroups(e,"","$","$","")},"${(...)}$":function(e){return Et.patterns.findObserveGroups(e,"${","","","}$")},"$(...)$":function(e){return Et.patterns.findObserveGroups(e,"$","","","$")},"=<>":/^[=<>]/,"#":/^[#\u2261]/,"+":/^\+/,"-$":/^-(?=[\s_},;\]/]|$|\([a-z]+\))/,"-9":/^-(?=[0-9])/,"- orbital overlap":/^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/,"-":/^-/,"pm-operator":/^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,operator:/^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,arrowUpDown:/^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,"\\bond{(...)}":function(e){return Et.patterns.findObserveGroups(e,"\\bond{","","","}")},"->":/^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,CMT:/^[CMT](?=\[)/,"[(...)]":function(e){return Et.patterns.findObserveGroups(e,"[","","","]")},"1st-level escape":/^(&|\\\\|\\hline)\s*/,"\\,":/^(?:\\[,\ ;:])/,"\\x{}{}":function(e){return Et.patterns.findObserveGroups(e,"",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"\\x{}":function(e){return Et.patterns.findObserveGroups(e,"",/^\\[a-zA-Z]+\{/,"}","")},"\\ca":/^\\ca(?:\s+|(?![a-zA-Z]))/,"\\x":/^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/,orbital:/^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,others:/^[\/~|]/,"\\frac{(...)}":function(e){return Et.patterns.findObserveGroups(e,"\\frac{","","","}","{","","","}")},"\\overset{(...)}":function(e){return Et.patterns.findObserveGroups(e,"\\overset{","","","}","{","","","}")},"\\underset{(...)}":function(e){return Et.patterns.findObserveGroups(e,"\\underset{","","","}","{","","","}")},"\\underbrace{(...)}":function(e){return Et.patterns.findObserveGroups(e,"\\underbrace{","","","}_","{","","","}")},"\\color{(...)}0":function(e){return Et.patterns.findObserveGroups(e,"\\color{","","","}")},"\\color{(...)}{(...)}1":function(e){return Et.patterns.findObserveGroups(e,"\\color{","","","}","{","","","}")},"\\color(...){(...)}2":function(e){return Et.patterns.findObserveGroups(e,"\\color","\\","",/^(?=\{)/,"{","","","}")},"\\ce{(...)}":function(e){return Et.patterns.findObserveGroups(e,"\\ce{","","","}")},oxidation$:/^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"d-oxidation$":/^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"roman numeral":/^[IVX]+/,"1/2$":/^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,amount:function(e){var i;if(i=e.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/),i)return{match_:i[0],remainder:e.substr(i[0].length)};var r=Et.patterns.findObserveGroups(e,"","$","$","");return r&&(i=r.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/),i)?{match_:i[0],remainder:e.substr(i[0].length)}:null},amount2:function(e){return this.amount(e)},"(KV letters),":/^(?:[A-Z][a-z]{0,2}|i)(?=,)/,formula$:function(e){if(e.match(/^\([a-z]+\)$/))return null;var i=e.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/);return i?{match_:i[0],remainder:e.substr(i[0].length)}:null},uprightEntities:/^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/,"/":/^\s*(\/)\s*/,"//":/^\s*(\/\/)\s*/,"*":/^\s*[*.]\s*/},findObserveGroups:function(e,i,r,a,u,p,g,b,w,E){var R=function(Ue,ct){if(typeof ct=="string")return Ue.indexOf(ct)!==0?null:ct;var It=Ue.match(ct);return It?It[0]:null},N=function(Ue,ct,It){for(var yt=0;ct<Ue.length;){var ei=Ue.charAt(ct),hi=R(Ue.substr(ct),It);if(hi!==null&&yt===0)return{endMatchBegin:ct,endMatchEnd:ct+hi.length};if(ei==="{")yt++;else if(ei==="}"){if(yt===0)throw["ExtraCloseMissingOpen","Extra close brace or missing open brace"];yt--}ct++}return yt>0,null},Z=R(e,i);if(Z===null||(e=e.substr(Z.length),Z=R(e,r),Z===null))return null;var ue=N(e,Z.length,a||u);if(ue===null)return null;var me=e.substring(0,a?ue.endMatchEnd:ue.endMatchBegin);if(p||g){var Ve=this.findObserveGroups(e.substr(ue.endMatchEnd),p,g,b,w);if(Ve===null)return null;var Ct=[me,Ve.match_];return{match_:E?Ct.join(""):Ct,remainder:Ve.remainder}}else return{match_:me,remainder:e.substr(ue.endMatchEnd)}},match_:function(e,i){var r=Et.patterns.patterns[e];if(r===void 0)throw["MhchemBugP","mhchem bug P. Please report. ("+e+")"];if(typeof r=="function")return Et.patterns.patterns[e](i);var a=i.match(r);if(a){var u;return a[2]?u=[a[1],a[2]]:a[1]?u=a[1]:u=a[0],{match_:u,remainder:i.substr(a[0].length)}}return null}},actions:{"a=":function(e,i){e.a=(e.a||"")+i},"b=":function(e,i){e.b=(e.b||"")+i},"p=":function(e,i){e.p=(e.p||"")+i},"o=":function(e,i){e.o=(e.o||"")+i},"q=":function(e,i){e.q=(e.q||"")+i},"d=":function(e,i){e.d=(e.d||"")+i},"rm=":function(e,i){e.rm=(e.rm||"")+i},"text=":function(e,i){e.text_=(e.text_||"")+i},insert:function(e,i,r){return{type_:r}},"insert+p1":function(e,i,r){return{type_:r,p1:i}},"insert+p1+p2":function(e,i,r){return{type_:r,p1:i[0],p2:i[1]}},copy:function(e,i){return i},rm:function(e,i){return{type_:"rm",p1:i||""}},text:function(e,i){return Et.go(i,"text")},"{text}":function(e,i){var r=["{"];return Et.concatArray(r,Et.go(i,"text")),r.push("}"),r},"tex-math":function(e,i){return Et.go(i,"tex-math")},"tex-math tight":function(e,i){return Et.go(i,"tex-math tight")},bond:function(e,i,r){return{type_:"bond",kind_:r||i}},"color0-output":function(e,i){return{type_:"color0",color:i[0]}},ce:function(e,i){return Et.go(i)},"1/2":function(e,i){var r=[];i.match(/^[+\-]/)&&(r.push(i.substr(0,1)),i=i.substr(1));var a=i.match(/^([0-9]+|\$[a-z]\$|[a-z])\/([0-9]+)(\$[a-z]\$|[a-z])?$/);return a[1]=a[1].replace(/\$/g,""),r.push({type_:"frac",p1:a[1],p2:a[2]}),a[3]&&(a[3]=a[3].replace(/\$/g,""),r.push({type_:"tex-math",p1:a[3]})),r},"9,9":function(e,i){return Et.go(i,"9,9")}},createTransitions:function(e){var i,r,a,u,p={};for(i in e)for(r in e[i])for(a=r.split("|"),e[i][r].stateArray=a,u=0;u<a.length;u++)p[a[u]]=[];for(i in e)for(r in e[i])for(a=e[i][r].stateArray||[],u=0;u<a.length;u++){var g=e[i][r];if(g.action_){g.action_=[].concat(g.action_);for(var b=0;b<g.action_.length;b++)typeof g.action_[b]=="string"&&(g.action_[b]={type_:g.action_[b]})}else g.action_=[];for(var w=i.split("|"),E=0;E<w.length;E++)if(a[u]==="*")for(var R in p)p[R].push({pattern:w[E],task:g});else p[a[u]].push({pattern:w[E],task:g})}return p},stateMachines:{}};Et.stateMachines={ce:{transitions:Et.createTransitions({empty:{"*":{action_:"output"}},else:{"0|1|2":{action_:"beginsWithBond=false",revisit:!0,toContinue:!0}},oxidation$:{0:{action_:"oxidation-output"}},CMT:{r:{action_:"rdt=",nextState:"rt"},rd:{action_:"rqt=",nextState:"rdt"}},arrowUpDown:{"0|1|2|as":{action_:["sb=false","output","operator"],nextState:"1"}},uprightEntities:{"0|1|2":{action_:["o=","output"],nextState:"1"}},orbital:{"0|1|2|3":{action_:"o=",nextState:"o"}},"->":{"0|1|2|3":{action_:"r=",nextState:"r"},"a|as":{action_:["output","r="],nextState:"r"},"*":{action_:["output","r="],nextState:"r"}},"+":{o:{action_:"d= kv",nextState:"d"},"d|D":{action_:"d=",nextState:"d"},q:{action_:"d=",nextState:"qd"},"qd|qD":{action_:"d=",nextState:"qd"},dq:{action_:["output","d="],nextState:"d"},3:{action_:["sb=false","output","operator"],nextState:"0"}},amount:{"0|2":{action_:"a=",nextState:"a"}},"pm-operator":{"0|1|2|a|as":{action_:["sb=false","output",{type_:"operator",option:"\\pm"}],nextState:"0"}},operator:{"0|1|2|a|as":{action_:["sb=false","output","operator"],nextState:"0"}},"-$":{"o|q":{action_:["charge or bond","output"],nextState:"qd"},d:{action_:"d=",nextState:"d"},D:{action_:["output",{type_:"bond",option:"-"}],nextState:"3"},q:{action_:"d=",nextState:"qd"},qd:{action_:"d=",nextState:"qd"},"qD|dq":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},"-9":{"3|o":{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"3"}},"- orbital overlap":{o:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},d:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"}},"-":{"0|1|2":{action_:[{type_:"output",option:1},"beginsWithBond=true",{type_:"bond",option:"-"}],nextState:"3"},3:{action_:{type_:"bond",option:"-"}},a:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},as:{action_:[{type_:"output",option:2},{type_:"bond",option:"-"}],nextState:"3"},b:{action_:"b="},o:{action_:{type_:"- after o/d",option:!1},nextState:"2"},q:{action_:{type_:"- after o/d",option:!1},nextState:"2"},"d|qd|dq":{action_:{type_:"- after o/d",option:!0},nextState:"2"},"D|qD|p":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},amount2:{"1|3":{action_:"a=",nextState:"a"}},letters:{"0|1|2|3|a|as|b|p|bp|o":{action_:"o=",nextState:"o"},"q|dq":{action_:["output","o="],nextState:"o"},"d|D|qd|qD":{action_:"o after d",nextState:"o"}},digits:{o:{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},q:{action_:["output","o="],nextState:"o"},a:{action_:"o=",nextState:"o"}},"space A":{"b|p|bp":{}},space:{a:{nextState:"as"},0:{action_:"sb=false"},"1|2":{action_:"sb=true"},"r|rt|rd|rdt|rdq":{action_:"output",nextState:"0"},"*":{action_:["output","sb=true"],nextState:"1"}},"1st-level escape":{"1|2":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}]},"*":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}],nextState:"0"}},"[(...)]":{"r|rt":{action_:"rd=",nextState:"rd"},"rd|rdt":{action_:"rq=",nextState:"rdq"}},"...":{"o|d|D|dq|qd|qD":{action_:["output",{type_:"bond",option:"..."}],nextState:"3"},"*":{action_:[{type_:"output",option:1},{type_:"insert",option:"ellipsis"}],nextState:"1"}},". |* ":{"*":{action_:["output",{type_:"insert",option:"addition compound"}],nextState:"1"}},"state of aggregation $":{"*":{action_:["output","state of aggregation"],nextState:"1"}},"{[(":{"a|as|o":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"0|1|2|3":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"*":{action_:["output","o=","output","parenthesisLevel++"],nextState:"2"}},")]}":{"0|1|2|3|b|p|bp|o":{action_:["o=","parenthesisLevel--"],nextState:"o"},"a|as|d|D|q|qd|qD|dq":{action_:["output","o=","parenthesisLevel--"],nextState:"o"}},", ":{"*":{action_:["output","comma"],nextState:"0"}},"^_":{"*":{}},"^{(...)}|^($...$)":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"D"},q:{action_:"d=",nextState:"qD"},"d|D|qd|qD|dq":{action_:["output","d="],nextState:"D"}},"^a|^\\x{}{}|^\\x{}|^\\x|'":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"d"},q:{action_:"d=",nextState:"qd"},"d|qd|D|qD":{action_:"d="},dq:{action_:["output","d="],nextState:"d"}},"_{(state of aggregation)}$":{"d|D|q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x":{"0|1|2|as":{action_:"p=",nextState:"p"},b:{action_:"p=",nextState:"bp"},"3|o":{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},"q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"=<>":{"0|1|2|3|a|as|o|q|d|D|qd|qD|dq":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"#":{"0|1|2|3|a|as|o":{action_:[{type_:"output",option:2},{type_:"bond",option:"#"}],nextState:"3"}},"{}":{"*":{action_:{type_:"output",option:1},nextState:"1"}},"{...}":{"0|1|2|3|a|as|b|p|bp":{action_:"o=",nextState:"o"},"o|d|D|q|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"$...$":{a:{action_:"a="},"0|1|2|3|as|b|p|bp|o":{action_:"o=",nextState:"o"},"as|o":{action_:"o="},"q|d|D|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"\\bond{(...)}":{"*":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"\\frac{(...)}":{"*":{action_:[{type_:"output",option:1},"frac-output"],nextState:"3"}},"\\overset{(...)}":{"*":{action_:[{type_:"output",option:2},"overset-output"],nextState:"3"}},"\\underset{(...)}":{"*":{action_:[{type_:"output",option:2},"underset-output"],nextState:"3"}},"\\underbrace{(...)}":{"*":{action_:[{type_:"output",option:2},"underbrace-output"],nextState:"3"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:[{type_:"output",option:2},"color-output"],nextState:"3"}},"\\color{(...)}0":{"*":{action_:[{type_:"output",option:2},"color0-output"]}},"\\ce{(...)}":{"*":{action_:[{type_:"output",option:2},"ce"],nextState:"3"}},"\\,":{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"1"}},"\\x{}{}|\\x{}|\\x":{"0|1|2|3|a|as|b|p|bp|o|c0":{action_:["o=","output"],nextState:"3"},"*":{action_:["output","o=","output"],nextState:"3"}},others:{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"3"}},else2:{a:{action_:"a to o",nextState:"o",revisit:!0},as:{action_:["output","sb=true"],nextState:"1",revisit:!0},"r|rt|rd|rdt|rdq":{action_:["output"],nextState:"0",revisit:!0},"*":{action_:["output","copy"],nextState:"3"}}}),actions:{"o after d":function(e,i){var r;if((e.d||"").match(/^[0-9]+$/)){var a=e.d;e.d=void 0,r=this.output(e),e.b=a}else r=this.output(e);return Et.actions["o="](e,i),r},"d= kv":function(e,i){e.d=i,e.dType="kv"},"charge or bond":function(e,i){if(e.beginsWithBond){var r=[];return Et.concatArray(r,this.output(e)),Et.concatArray(r,Et.actions.bond(e,i,"-")),r}else e.d=i},"- after o/d":function(e,i,r){var a=Et.patterns.match_("orbital",e.o||""),u=Et.patterns.match_("one lowercase greek letter $",e.o||""),p=Et.patterns.match_("one lowercase latin letter $",e.o||""),g=Et.patterns.match_("$one lowercase latin letter$ $",e.o||""),b=i==="-"&&(a&&a.remainder===""||u||p||g);b&&!e.a&&!e.b&&!e.p&&!e.d&&!e.q&&!a&&p&&(e.o="$"+e.o+"$");var w=[];return b?(Et.concatArray(w,this.output(e)),w.push({type_:"hyphen"})):(a=Et.patterns.match_("digits",e.d||""),r&&a&&a.remainder===""?(Et.concatArray(w,Et.actions["d="](e,i)),Et.concatArray(w,this.output(e))):(Et.concatArray(w,this.output(e)),Et.concatArray(w,Et.actions.bond(e,i,"-")))),w},"a to o":function(e){e.o=e.a,e.a=void 0},"sb=true":function(e){e.sb=!0},"sb=false":function(e){e.sb=!1},"beginsWithBond=true":function(e){e.beginsWithBond=!0},"beginsWithBond=false":function(e){e.beginsWithBond=!1},"parenthesisLevel++":function(e){e.parenthesisLevel++},"parenthesisLevel--":function(e){e.parenthesisLevel--},"state of aggregation":function(e,i){return{type_:"state of aggregation",p1:Et.go(i,"o")}},comma:function(e,i){var r=i.replace(/\s*$/,""),a=r!==i;return a&&e.parenthesisLevel===0?{type_:"comma enumeration L",p1:r}:{type_:"comma enumeration M",p1:r}},output:function(e,i,r){var a;if(!e.r)a=[],!e.a&&!e.b&&!e.p&&!e.o&&!e.q&&!e.d&&!r||(e.sb&&a.push({type_:"entitySkip"}),!e.o&&!e.q&&!e.d&&!e.b&&!e.p&&r!==2?(e.o=e.a,e.a=void 0):!e.o&&!e.q&&!e.d&&(e.b||e.p)?(e.o=e.a,e.d=e.b,e.q=e.p,e.a=e.b=e.p=void 0):e.o&&e.dType==="kv"&&Et.patterns.match_("d-oxidation$",e.d||"")?e.dType="oxidation":e.o&&e.dType==="kv"&&!e.q&&(e.dType=void 0),a.push({type_:"chemfive",a:Et.go(e.a,"a"),b:Et.go(e.b,"bd"),p:Et.go(e.p,"pq"),o:Et.go(e.o,"o"),q:Et.go(e.q,"pq"),d:Et.go(e.d,e.dType==="oxidation"?"oxidation":"bd"),dType:e.dType}));else{var u;e.rdt==="M"?u=Et.go(e.rd,"tex-math"):e.rdt==="T"?u=[{type_:"text",p1:e.rd||""}]:u=Et.go(e.rd);var p;e.rqt==="M"?p=Et.go(e.rq,"tex-math"):e.rqt==="T"?p=[{type_:"text",p1:e.rq||""}]:p=Et.go(e.rq),a={type_:"arrow",r:e.r,rd:u,rq:p}}for(var g in e)g!=="parenthesisLevel"&&g!=="beginsWithBond"&&delete e[g];return a},"oxidation-output":function(e,i){var r=["{"];return Et.concatArray(r,Et.go(i,"oxidation")),r.push("}"),r},"frac-output":function(e,i){return{type_:"frac-ce",p1:Et.go(i[0]),p2:Et.go(i[1])}},"overset-output":function(e,i){return{type_:"overset",p1:Et.go(i[0]),p2:Et.go(i[1])}},"underset-output":function(e,i){return{type_:"underset",p1:Et.go(i[0]),p2:Et.go(i[1])}},"underbrace-output":function(e,i){return{type_:"underbrace",p1:Et.go(i[0]),p2:Et.go(i[1])}},"color-output":function(e,i){return{type_:"color",color1:i[0],color2:Et.go(i[1])}},"r=":function(e,i){e.r=i},"rdt=":function(e,i){e.rdt=i},"rd=":function(e,i){e.rd=i},"rqt=":function(e,i){e.rqt=i},"rq=":function(e,i){e.rq=i},operator:function(e,i,r){return{type_:"operator",kind_:r||i}}}},a:{transitions:Et.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},"$(...)$":{"*":{action_:"tex-math tight",nextState:"1"}},",":{"*":{action_:{type_:"insert",option:"commaDecimal"}}},else2:{"*":{action_:"copy"}}}),actions:{}},o:{transitions:Et.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},letters:{"*":{action_:"rm"}},"\\ca":{"*":{action_:{type_:"insert",option:"circa"}}},"\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"{text}"}},else2:{"*":{action_:"copy"}}}),actions:{}},text:{transitions:Et.createTransitions({empty:{"*":{action_:"output"}},"{...}":{"*":{action_:"text="}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"\\greek":{"*":{action_:["output","rm"]}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:["output","copy"]}},else:{"*":{action_:"text="}}}),actions:{output:function(e){if(e.text_){var i={type_:"text",p1:e.text_};for(var r in e)delete e[r];return i}}}},pq:{transitions:Et.createTransitions({empty:{"*":{}},"state of aggregation $":{"*":{action_:"state of aggregation"}},i$:{0:{nextState:"!f",revisit:!0}},"(KV letters),":{0:{action_:"rm",nextState:"0"}},formula$:{0:{nextState:"f",revisit:!0}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"!f",revisit:!0}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"a-z":{f:{action_:"tex-math"}},letters:{"*":{action_:"rm"}},"-9.,9":{"*":{action_:"9,9"}},",":{"*":{action_:{type_:"insert+p1",option:"comma enumeration S"}}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"state of aggregation":function(e,i){return{type_:"state of aggregation subscript",p1:Et.go(i,"o")}},"color-output":function(e,i){return{type_:"color",color1:i[0],color2:Et.go(i[1],"pq")}}}},bd:{transitions:Et.createTransitions({empty:{"*":{}},x$:{0:{nextState:"!f",revisit:!0}},formula$:{0:{nextState:"f",revisit:!0}},else:{0:{nextState:"!f",revisit:!0}},"-9.,9 no missing 0":{"*":{action_:"9,9"}},".":{"*":{action_:{type_:"insert",option:"electron dot"}}},"a-z":{f:{action_:"tex-math"}},x:{"*":{action_:{type_:"insert",option:"KV x"}}},letters:{"*":{action_:"rm"}},"'":{"*":{action_:{type_:"insert",option:"prime"}}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"color-output":function(e,i){return{type_:"color",color1:i[0],color2:Et.go(i[1],"bd")}}}},oxidation:{transitions:Et.createTransitions({empty:{"*":{}},"roman numeral":{"*":{action_:"roman-numeral"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},else:{"*":{action_:"copy"}}}),actions:{"roman-numeral":function(e,i){return{type_:"roman numeral",p1:i||""}}}},"tex-math":{transitions:Et.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},else:{"*":{action_:"o="}}}),actions:{output:function(e){if(e.o){var i={type_:"tex-math",p1:e.o};for(var r in e)delete e[r];return i}}}},"tex-math tight":{transitions:Et.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},"-|+":{"*":{action_:"tight operator"}},else:{"*":{action_:"o="}}}),actions:{"tight operator":function(e,i){e.o=(e.o||"")+"{"+i+"}"},output:function(e){if(e.o){var i={type_:"tex-math",p1:e.o};for(var r in e)delete e[r];return i}}}},"9,9":{transitions:Et.createTransitions({empty:{"*":{}},",":{"*":{action_:"comma"}},else:{"*":{action_:"copy"}}}),actions:{comma:function(){return{type_:"commaDecimal"}}}},pu:{transitions:Et.createTransitions({empty:{"*":{action_:"output"}},space$:{"*":{action_:["output","space"]}},"{[(|)]}":{"0|a":{action_:"copy"}},"(-)(9)^(-9)":{0:{action_:"number^",nextState:"a"}},"(-)(9.,9)(e)(99)":{0:{action_:"enumber",nextState:"a"}},space:{"0|a":{}},"pm-operator":{"0|a":{action_:{type_:"operator",option:"\\pm"},nextState:"0"}},operator:{"0|a":{action_:"copy",nextState:"0"}},"//":{d:{action_:"o=",nextState:"/"}},"/":{d:{action_:"o=",nextState:"/"}},"{...}|else":{"0|d":{action_:"d=",nextState:"d"},a:{action_:["space","d="],nextState:"d"},"/|q":{action_:"q=",nextState:"q"}}}),actions:{enumber:function(e,i){var r=[];return i[0]==="+-"||i[0]==="+/-"?r.push("\\pm "):i[0]&&r.push(i[0]),i[1]&&(Et.concatArray(r,Et.go(i[1],"pu-9,9")),i[2]&&(i[2].match(/[,.]/)?Et.concatArray(r,Et.go(i[2],"pu-9,9")):r.push(i[2])),(i[3]||i[4])&&(i[3]==="e"||i[4]==="*"?r.push({type_:"cdot"}):r.push({type_:"times"}))),i[5]&&r.push("10^{"+i[5]+"}"),r},"number^":function(e,i){var r=[];return i[0]==="+-"||i[0]==="+/-"?r.push("\\pm "):i[0]&&r.push(i[0]),Et.concatArray(r,Et.go(i[1],"pu-9,9")),r.push("^{"+i[2]+"}"),r},operator:function(e,i,r){return{type_:"operator",kind_:r||i}},space:function(){return{type_:"pu-space-1"}},output:function(e){var i,r=Et.patterns.match_("{(...)}",e.d||"");r&&r.remainder===""&&(e.d=r.match_);var a=Et.patterns.match_("{(...)}",e.q||"");if(a&&a.remainder===""&&(e.q=a.match_),e.d&&(e.d=e.d.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),e.d=e.d.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F")),e.q){e.q=e.q.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),e.q=e.q.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F");var u={d:Et.go(e.d,"pu"),q:Et.go(e.q,"pu")};e.o==="//"?i={type_:"pu-frac",p1:u.d,p2:u.q}:(i=u.d,u.d.length>1||u.q.length>1?i.push({type_:" / "}):i.push({type_:"/"}),Et.concatArray(i,u.q))}else i=Et.go(e.d,"pu-2");for(var p in e)delete e[p];return i}}},"pu-2":{transitions:Et.createTransitions({empty:{"*":{action_:"output"}},"*":{"*":{action_:["output","cdot"],nextState:"0"}},"\\x":{"*":{action_:"rm="}},space:{"*":{action_:["output","space"],nextState:"0"}},"^{(...)}|^(-1)":{1:{action_:"^(-1)"}},"-9.,9":{0:{action_:"rm=",nextState:"0"},1:{action_:"^(-1)",nextState:"0"}},"{...}|else":{"*":{action_:"rm=",nextState:"1"}}}),actions:{cdot:function(){return{type_:"tight cdot"}},"^(-1)":function(e,i){e.rm+="^{"+i+"}"},space:function(){return{type_:"pu-space-2"}},output:function(e){var i=[];if(e.rm){var r=Et.patterns.match_("{(...)}",e.rm||"");r&&r.remainder===""?i=Et.go(r.match_,"pu"):i={type_:"rm",p1:e.rm}}for(var a in e)delete e[a];return i}}},"pu-9,9":{transitions:Et.createTransitions({empty:{0:{action_:"output-0"},o:{action_:"output-o"}},",":{0:{action_:["output-0","comma"],nextState:"o"}},".":{0:{action_:["output-0","copy"],nextState:"o"}},else:{"*":{action_:"text="}}}),actions:{comma:function(){return{type_:"commaDecimal"}},"output-0":function(e){var i=[];if(e.text_=e.text_||"",e.text_.length>4){var r=e.text_.length%3;r===0&&(r=3);for(var a=e.text_.length-3;a>0;a-=3)i.push(e.text_.substr(a,3)),i.push({type_:"1000 separator"});i.push(e.text_.substr(0,r)),i.reverse()}else i.push(e.text_);for(var u in e)delete e[u];return i},"output-o":function(e){var i=[];if(e.text_=e.text_||"",e.text_.length>4){for(var r=e.text_.length-3,a=0;a<r;a+=3)i.push(e.text_.substr(a,3)),i.push({type_:"1000 separator"});i.push(e.text_.substr(a))}else i.push(e.text_);for(var u in e)delete e[u];return i}}}};var Jn={go:function(e,i){if(!e)return"";for(var r="",a=!1,u=0;u<e.length;u++){var p=e[u];typeof p=="string"?r+=p:(r+=Jn._go2(p),p.type_==="1st-level escape"&&(a=!0))}return!i&&!a&&r&&(r="{"+r+"}"),r},_goInner:function(e){return e&&Jn.go(e,!0)},_go2:function(e){var i;switch(e.type_){case"chemfive":i="";var r={a:Jn._goInner(e.a),b:Jn._goInner(e.b),p:Jn._goInner(e.p),o:Jn._goInner(e.o),q:Jn._goInner(e.q),d:Jn._goInner(e.d)};r.a&&(r.a.match(/^[+\-]/)&&(r.a="{"+r.a+"}"),i+=r.a+"\\,"),(r.b||r.p)&&(i+="{\\vphantom{X}}",i+="^{\\hphantom{"+(r.b||"")+"}}_{\\hphantom{"+(r.p||"")+"}}",i+="{\\vphantom{X}}",i+="^{\\smash[t]{\\vphantom{2}}\\llap{"+(r.b||"")+"}}",i+="_{\\vphantom{2}\\llap{\\smash[t]{"+(r.p||"")+"}}}"),r.o&&(r.o.match(/^[+\-]/)&&(r.o="{"+r.o+"}"),i+=r.o),e.dType==="kv"?((r.d||r.q)&&(i+="{\\vphantom{X}}"),r.d&&(i+="^{"+r.d+"}"),r.q&&(i+="_{\\smash[t]{"+r.q+"}}")):e.dType==="oxidation"?(r.d&&(i+="{\\vphantom{X}}",i+="^{"+r.d+"}"),r.q&&(i+="{\\vphantom{X}}",i+="_{\\smash[t]{"+r.q+"}}")):(r.q&&(i+="{\\vphantom{X}}",i+="_{\\smash[t]{"+r.q+"}}"),r.d&&(i+="{\\vphantom{X}}",i+="^{"+r.d+"}"));break;case"rm":i="\\mathrm{"+e.p1+"}";break;case"text":e.p1.match(/[\^_]/)?(e.p1=e.p1.replace(" ","~").replace("-","\\text{-}"),i="\\mathrm{"+e.p1+"}"):i="\\text{"+e.p1+"}";break;case"roman numeral":i="\\mathrm{"+e.p1+"}";break;case"state of aggregation":i="\\mskip2mu "+Jn._goInner(e.p1);break;case"state of aggregation subscript":i="\\mskip1mu "+Jn._goInner(e.p1);break;case"bond":if(i=Jn._getBond(e.kind_),!i)throw["MhchemErrorBond","mhchem Error. Unknown bond type ("+e.kind_+")"];break;case"frac":var a="\\frac{"+e.p1+"}{"+e.p2+"}";i="\\mathchoice{\\textstyle"+a+"}{"+a+"}{"+a+"}{"+a+"}";break;case"pu-frac":var u="\\frac{"+Jn._goInner(e.p1)+"}{"+Jn._goInner(e.p2)+"}";i="\\mathchoice{\\textstyle"+u+"}{"+u+"}{"+u+"}{"+u+"}";break;case"tex-math":i=e.p1+" ";break;case"frac-ce":i="\\frac{"+Jn._goInner(e.p1)+"}{"+Jn._goInner(e.p2)+"}";break;case"overset":i="\\overset{"+Jn._goInner(e.p1)+"}{"+Jn._goInner(e.p2)+"}";break;case"underset":i="\\underset{"+Jn._goInner(e.p1)+"}{"+Jn._goInner(e.p2)+"}";break;case"underbrace":i="\\underbrace{"+Jn._goInner(e.p1)+"}_{"+Jn._goInner(e.p2)+"}";break;case"color":i="{\\color{"+e.color1+"}{"+Jn._goInner(e.color2)+"}}";break;case"color0":i="\\color{"+e.color+"}";break;case"arrow":var p={rd:Jn._goInner(e.rd),rq:Jn._goInner(e.rq)},g=Jn._getArrow(e.r);p.rd||p.rq?e.r==="<=>"||e.r==="<=>>"||e.r==="<<=>"||e.r==="<-->"?(g="\\long"+g,p.rd&&(g="\\overset{"+p.rd+"}{"+g+"}"),p.rq&&(e.r==="<-->"?g="\\underset{\\lower2mu{"+p.rq+"}}{"+g+"}":g="\\underset{\\lower6mu{"+p.rq+"}}{"+g+"}"),g=" {}\\mathrel{"+g+"}{} "):(p.rq&&(g+="[{"+p.rq+"}]"),g+="{"+p.rd+"}",g=" {}\\mathrel{\\x"+g+"}{} "):g=" {}\\mathrel{\\long"+g+"}{} ",i=g;break;case"operator":i=Jn._getOperator(e.kind_);break;case"1st-level escape":i=e.p1+" ";break;case"space":i=" ";break;case"entitySkip":i="~";break;case"pu-space-1":i="~";break;case"pu-space-2":i="\\mkern3mu ";break;case"1000 separator":i="\\mkern2mu ";break;case"commaDecimal":i="{,}";break;case"comma enumeration L":i="{"+e.p1+"}\\mkern6mu ";break;case"comma enumeration M":i="{"+e.p1+"}\\mkern3mu ";break;case"comma enumeration S":i="{"+e.p1+"}\\mkern1mu ";break;case"hyphen":i="\\text{-}";break;case"addition compound":i="\\,{\\cdot}\\,";break;case"electron dot":i="\\mkern1mu \\bullet\\mkern1mu ";break;case"KV x":i="{\\times}";break;case"prime":i="\\prime ";break;case"cdot":i="\\cdot ";break;case"tight cdot":i="\\mkern1mu{\\cdot}\\mkern1mu ";break;case"times":i="\\times ";break;case"circa":i="{\\sim}";break;case"^":i="uparrow";break;case"v":i="downarrow";break;case"ellipsis":i="\\ldots ";break;case"/":i="/";break;case" / ":i="\\,/\\,";break;default:throw["MhchemBugT","mhchem bug T. Please report."]}return i},_getArrow:function(e){switch(e){case"->":return"rightarrow";case"\u2192":return"rightarrow";case"\u27F6":return"rightarrow";case"<-":return"leftarrow";case"<->":return"leftrightarrow";case"<-->":return"leftrightarrows";case"<=>":return"rightleftharpoons";case"\u21CC":return"rightleftharpoons";case"<=>>":return"Rightleftharpoons";case"<<=>":return"Leftrightharpoons";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getBond:function(e){switch(e){case"-":return"{-}";case"1":return"{-}";case"=":return"{=}";case"2":return"{=}";case"#":return"{\\equiv}";case"3":return"{\\equiv}";case"~":return"{\\tripledash}";case"~-":return"{\\rlap{\\lower.1em{-}}\\raise.1em{\\tripledash}}";case"~=":return"{\\rlap{\\lower.2em{-}}\\rlap{\\raise.2em{\\tripledash}}-}";case"~--":return"{\\rlap{\\lower.2em{-}}\\rlap{\\raise.2em{\\tripledash}}-}";case"-~-":return"{\\rlap{\\lower.2em{-}}\\rlap{\\raise.2em{-}}\\tripledash}";case"...":return"{{\\cdot}{\\cdot}{\\cdot}}";case"....":return"{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}";case"->":return"{\\rightarrow}";case"<-":return"{\\leftarrow}";case"<":return"{<}";case">":return"{>}";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getOperator:function(e){switch(e){case"+":return" {}+{} ";case"-":return" {}-{} ";case"=":return" {}={} ";case"<":return" {}<{} ";case">":return" {}>{} ";case"<<":return" {}\\ll{} ";case">>":return" {}\\gg{} ";case"\\pm":return" {}\\pm{} ";case"\\approx":return" {}\\approx{} ";case"$\\approx$":return" {}\\approx{} ";case"v":return" \\downarrow{} ";case"(v)":return" \\downarrow{} ";case"^":return" \\uparrow{} ";case"(^)":return" \\uparrow{} ";default:throw["MhchemBugT","mhchem bug T. Please report."]}}};function N0(e){}function Ef(e){}var kf=class im extends et{constructor(i){super(d(P({},i),{type:"delim"})),this.value=i.delim,this.size=i.size}static fromJson(i){return new im(i)}toJson(){return d(P({},super.toJson()),{delim:this.value,size:this.size})}render(i){return new Tt(this.value,{type:"middle"})}_serialize(i){if(!(i.expandMacro||i.skipStyles||i.skipPlaceholders)&&typeof this.verbatimLatex=="string")return this.verbatimLatex;const r=Me(this.command,this.mode);return r!=null&&r.serialize?r.serialize(this,i):jn(this.command,this.value)}},Bu=class nm extends et{constructor(i){super(d(P({},i),{type:"sizeddelim",value:i.delim})),this.delimType=i.delimType,this.size=i.size}static fromJson(i){return new nm(i)}toJson(){return d(P({},super.toJson()),{delim:this.value,size:this.size,delimType:this.delimType})}render(i){let r=gf(this.value,this.size,i,{classes:{open:"mopen",close:"mclose"}[this.delimType],type:this.delimType,isSelected:this.isSelected});return r?(r=this.bind(i,r),this.caret&&(r.caret=this.caret),r):null}_serialize(i){if(!(i.expandMacro||i.skipStyles||i.skipPlaceholders)&&typeof this.verbatimLatex=="string")return this.verbatimLatex;const r=Me(this.command,this.mode);return r!=null&&r.serialize?r.serialize(this,i):jn(this.command,this.value)}},Dl=class rm extends et{constructor(i,r,a,u){var p,g;super({type:"enclose",command:i,style:u.style}),this.body=r,this.backgroundcolor=u.backgroundcolor,a.updiagonalarrow&&(a.updiagonalstrike=!1),a.box&&(a.left=!1,a.right=!1,a.bottom=!1,a.top=!1),this.notation=a,this.shadow=(p=u.shadow)!=null?p:"none",this.strokeWidth=(g=u.strokeWidth)!=null?g:"0.06em",this.strokeWidth||(this.strokeWidth="0.06em"),this.strokeStyle=u.strokeStyle,this.svgStrokeStyle=u.svgStrokeStyle,this.strokeColor=u.strokeColor,this.borderStyle=u.borderStyle,this.padding=u.padding,this.captureSelection=!1}static fromJson(i){return new rm(i.command,i.body,i.notation,i)}toJson(){return d(P({},super.toJson()),{notation:this.notation,shadow:this.shadow,strokeWidth:this.strokeWidth,strokeStyle:this.strokeStyle,svgStrokeStyle:this.svgStrokeStyle,strokeColor:this.strokeColor,borderStyle:this.borderStyle,padding:this.padding})}_serialize(i){var r;if(!(i.expandMacro||i.skipStyles||i.skipPlaceholders)&&typeof this.verbatimLatex=="string")return this.verbatimLatex;const a=Me(this.command,this.mode);if(a!=null&&a.serialize)return a.serialize(this,i);let u=(r=this.command)!=null?r:"";if(this.command==="\\enclose"){u+="{"+Object.keys(this.notation).join(" ")+"}";let p="",g="";this.backgroundcolor&&this.backgroundcolor!=="transparent"&&(p+=g+'mathbackground="'+this.backgroundcolor+'"',g=","),this.shadow&&this.shadow!=="auto"&&(p+=g+'shadow="'+this.shadow+'"',g=","),this.strokeWidth||this.strokeStyle!=="solid"?(p+=g+this.borderStyle,g=","):this.strokeColor&&this.strokeColor!=="currentColor"&&(p+=g+'mathcolor="'+this.strokeColor+'"',g=","),p&&(u+=`[${p}]`)}return jn(u,this.bodyToLatex(i))}render(i){const r=new Si({parent:i},this.style),a=et.createBox(r,this.body);if(!a)return null;const u=Wc(this.borderStyle),p=r.toEm(!this.padding||this.padding==="auto"?{register:"fboxsep"}:{string:this.padding});a.setStyle("position","relative"),a.setStyle("display","inline-block"),a.setStyle("top",p,"em"),a.setStyle("height",a.height+a.depth,"em"),a.setStyle("width",a.width,"em");const g=new Tt(null,{classes:"ML__notation"});let b=a.height+a.depth+2*p;const w=a.width+2*p;let E="";if(this.notation.horizontalstrike&&(E+=this.line(3,50,97,50)),this.notation.verticalstrike&&(E+=this.line(50,3,50,97)),this.notation.updiagonalstrike&&(E+=this.line(3,97,97,3)),this.notation.downdiagonalstrike&&(E+=this.line(3,3,97,97)),this.notation.updiagonalarrow){E+=this.line(p.toString(),(p+a.depth+a.height).toString(),(p+a.width).toString(),p.toString());const me=.03*Math.sqrt(w*w+b*b)*1,Ve=a.width*me,Ct=(a.depth+a.height)*me,Ue=p+a.width;let ct=p;ct+Ct-.4*Ve<0&&(ct=.4*Ve-Ct),E+='<polygon points="',E+=`${Ue},${ct} ${Ue-Ve-.4*Ct},${ct+Ct-.4*Ve} `,E+=`${Ue-.7*Ve},${ct+.7*Ct} ${Ue-Ve+.4*Ct},${ct+Ct+.4*Ve} `,E+=`${Ue},${ct}`,E+=`" stroke='none' fill="${this.strokeColor}"`,E+="/>"}let R=0;if(this.notation.phasorangle){const Z=jc(r),ue=(a.height+a.depth+2*Z+p).toString(),me=(a.height+a.depth)/2;E+=this.line(p.toString(),ue,(p+me+a.width).toString(),ue),E+=this.line(p.toString(),ue,(p+me).toString(),(p-Z).toString()),b+=Z,R=me,a.left+=b/2-p}if(this.notation.longdiv){const Z=jc(r);b+=Z,E+=this.line(p.toString(),p.toString(),(p+a.width).toString(),p.toString());const ue=.3;R=ue+Z,a.left+=ue+Z,a.setTop(p+Z),E+='<path d="',E+=`M ${p} ${p} a${ue} ${(a.depth+a.height+2*Z)/2}, 0, 1, 1, 0 ${a.depth+a.height+2*Z} "`,E+=` stroke-width="${Tf(r)}" stroke="${this.strokeColor}" fill="none"`,E+="/>"}if(g.width=a.width+2*p+R,g.height=a.height+p,g.depth=a.depth+p,g.setStyle("box-sizing","border-box"),g.setStyle("left",`calc(-${u} / 2 )`),g.setStyle("height",`${Math.floor(100*b)/100}em`),g.setStyle("top",`calc(${u} / 2 )`),this.backgroundcolor&&g.setStyle("background-color",this.backgroundcolor),this.notation.box&&g.setStyle("border","1px solid red"),this.notation.actuarial&&(g.setStyle("border-top",this.borderStyle),g.setStyle("border-right",this.borderStyle)),this.notation.madruwb&&(g.setStyle("border-bottom",this.borderStyle),g.setStyle("border-right",this.borderStyle)),this.notation.roundedbox&&(g.setStyle("border-radius","8px"),g.setStyle("border",this.borderStyle)),this.notation.circle&&(g.setStyle("border-radius","50%"),g.setStyle("border",this.borderStyle)),this.notation.top&&g.setStyle("border-top",this.borderStyle),this.notation.left&&g.setStyle("border-left",this.borderStyle),this.notation.right&&g.setStyle("border-right",this.borderStyle),this.notation.bottom&&g.setStyle("border-bottom",this.borderStyle),E){let Z="";this.shadow==="auto"&&(Z+="filter: drop-shadow(0 0 .5px rgba(255, 255, 255, .7)) drop-shadow(1px 1px 2px #333)"),this.shadow!=="none"&&(Z+=`filter: drop-shadow(${this.shadow})`),Z+=` stroke-width="${this.strokeWidth}" stroke="${this.strokeColor}"`,Z+=' stroke-linecap="round"',this.svgStrokeStyle&&(Z+=` stroke-dasharray="${this.svgStrokeStyle}"`),g.svgStyle=Z,g.svgOverlay=E}const N=new Tt([g,a]);return N.setStyle("position","relative"),N.setStyle("vertical-align",p,"em"),N.setStyle("height",`${Math.floor(100*(a.height+a.depth+2*p))/100}em`),N.setStyle("display","inline-block"),N.height=g.height,N.depth=g.depth,N.width=g.width-2*p,N.left=p,N.right=p,this.caret&&(N.caret=this.caret),N.wrap(r)}line(i,r,a,u){return`<line x1="${Nu(i)}" y1="${Nu(r)}" x2="${Nu(a)}" y2="${Nu(u)}" vector-effect="non-scaling-stroke"></line>`}};function Nu(e){return typeof e=="number"?`${Math.floor(100*e)/100}%`:e}function Wc(e){if(!e)return"1px";const i=e.match(/([0-9][a-zA-Z\%]+)/);return i===null?"1px":i[1]}function Tf(e){return(Math.floor(100*e.metrics.sqrtRuleThickness/e.scalingFactor)/100/10).toString()+"em"}function jc(e){const i=e.isDisplayStyle?ua:e.metrics.defaultRuleThickness;return e.metrics.defaultRuleThickness+e.scalingFactor*i/4}var Vo=class sm extends et{constructor(i,r,a){var u,p;super(d(P({},a),{type:"genfrac",displayContainsHighlight:!0})),this.above=i,this.below=r,this.hasBarLine=(u=a==null?void 0:a.hasBarLine)!=null?u:!0,this.continuousFraction=(p=a==null?void 0:a.continuousFraction)!=null?p:!1,this.numerPrefix=a==null?void 0:a.numerPrefix,this.denomPrefix=a==null?void 0:a.denomPrefix,this.mathstyleName=a==null?void 0:a.mathstyleName,this.leftDelim=a==null?void 0:a.leftDelim,this.rightDelim=a==null?void 0:a.rightDelim,this.fractionNavigationOrder=a==null?void 0:a.fractionNavigationOrder}static fromJson(i){return new sm(i.above,i.below,i)}toJson(){const i={};return this.continuousFraction&&(i.continuousFraction=!0),this.numerPrefix&&(i.numerPrefix=this.numerPrefix),this.denomPrefix&&(i.denomPrefix=this.denomPrefix),this.leftDelim&&(i.leftDelim=this.leftDelim),this.rightDelim&&(i.rightDelim=this.rightDelim),this.hasBarLine||(i.hasBarLine=!1),this.mathstyleName&&(i.mathstyleName=this.mathstyleName),this.fractionNavigationOrder&&(i.fractionNavigationOrder=this.fractionNavigationOrder),P(P({},super.toJson()),i)}get children(){if(this._children)return this._children;const i=[];if(this.fractionNavigationOrder==="denominator-numerator"){for(const r of this.below)i.push(...r.children),i.push(r);for(const r of this.above)i.push(...r.children),i.push(r)}else{for(const r of this.above)i.push(...r.children),i.push(r);for(const r of this.below)i.push(...r.children),i.push(r)}return this._children=i,i}render(i){var r,a;const u=new Si({parent:i,mathstyle:this.mathstyleName},this.style),p=u.metrics,g=new Si({parent:u,mathstyle:this.continuousFraction?"":"numerator"},this.style),b=this.numerPrefix?new Tt([new Tt(this.numerPrefix),et.createBox(g,this.above)],{isTight:g.isTight,type:"ignore"}):(r=et.createBox(g,this.above,{type:"ignore"}))!=null?r:new Tt(null,{type:"ignore"}),w=new Si({parent:u,mathstyle:this.continuousFraction?"":"denominator"},this.style),E=this.denomPrefix?new Tt([new Tt(this.denomPrefix),et.createBox(w,this.below,{type:"ignore"})]):(a=et.createBox(w,this.below,{type:"ignore"}))!=null?a:new Tt(null,{type:"ignore"}),R=this.hasBarLine?p.defaultRuleThickness:0;let N,Z=0,ue;u.isDisplayStyle?(N=g.metrics.num1,Z=R>0?3*R:7*R,ue=w.metrics.denom1):(R>0?(N=g.metrics.num2,Z=R):(N=g.metrics.num3,Z=3*p.defaultRuleThickness),ue=w.metrics.denom2);const me=[];this.isSelected&&me.push("ML__selected");const Ve=b.depth,Ct=E.height;let Ue;if(R<=0){const ai=N-Ve-(Ct-ue);ai<Z&&(N+=(Z-ai)/2,ue+=(Z-ai)/2),Ue=new kr({individualShift:[{box:b,shift:-N,classes:[...me,"ML__center"]},{box:E,shift:ue,classes:[...me,"ML__center"]}]}).wrap(u)}else{const ai=new Tt(null,{classes:"ML__frac-line",mode:this.mode,style:this.style});ai.softWidth=Math.max(b.width,E.width),ai.height=R/2,ai.depth=R/2;const on=gs+R/2;N<Z+Ve+on&&(N=Z+Ve+on);const Bn=gs-R/2;ue<Z+Ct-Bn&&(ue=Z+Ct-Bn),Ue=new kr({individualShift:[{box:E,shift:ue,classes:[...me,"ML__center"]},{box:ai,shift:-Bn,classes:me},{box:b,shift:-N,classes:[...me,"ML__center"]}]}).wrap(u)}const ct=u.isDisplayStyle?p.delim1:p.delim2,It=this.leftDelim?this.bind(i,Ou("open",this.leftDelim,ct,!0,i,{style:this.style,mode:this.mode,isSelected:this.isSelected})):fo(u,"open");let yt=null;this.continuousFraction?yt=new Tt(null,{type:"close"}):this.rightDelim?yt=this.bind(i,Ou("close",this.rightDelim,ct,!0,i,{style:this.style,mode:this.mode,isSelected:this.isSelected})):yt=fo(u,"close");const ei=new Tt([It,Ue,yt],{isTight:u.isTight,type:"inner",classes:"mfrac"}),hi=this.bind(i,ei);return this.caret&&(hi.caret=this.caret),this.attachSupsub(i,{base:hi})}},Lr=class am extends et{constructor(i,r){var a;super({type:"latex",value:i,mode:"latex"}),this.isSuggestion=(a=r==null?void 0:r.isSuggestion)!=null?a:!1,this.isError=!1}static fromJson(i){const r=new am(i.value);return i.isSuggestion&&(r.isSuggestion=!0),i.isError&&(r.isError=!0),r}toJson(){const i={};return this.isSuggestion&&(i.isSuggestion=!0),this.isError&&(i.isError=!0),P({type:"latex",value:this.value},i)}get computedStyle(){return{}}render(i){const r=new Tt(this.value,{classes:this.isSuggestion?"ML__suggestion":this.isError?"ML__error":"",type:"latex",maxFontSize:1});return r?(this.caret&&(r.caret=this.caret),this.bind(i,r)):null}},Cl=class om extends et{constructor(i){super({type:"latexgroup",mode:"latex"}),this.body=[...i].map(r=>new Lr(r)),this.skipBoundary=!1}static fromJson(i){return new om("")}toJson(){return super.toJson()}render(i){const r=et.createBox(i,this.body);return r?(this.caret&&(r.caret=this.caret),this.bind(i,r)):null}_serialize(i){var r,a;return(a=(r=this.body)==null?void 0:r.map(u=>u.value).join(""))!=null?a:""}},Ml=class lm extends et{constructor(i,r){super(d(P({},r),{type:"extensible-symbol",isFunction:r==null?void 0:r.isFunction})),this.value=i,this.variant=r==null?void 0:r.variant,this.subsupPlacement=r==null?void 0:r.limits}static fromJson(i){return new lm(i.symbol,i)}toJson(){const i=super.toJson();return this.variant&&(i.variant=this.variant),this.subsupPlacement&&(i.limits=this.subsupPlacement),this.isExtensibleSymbol&&(i.isExtensibleSymbol=!0),this.value&&(i.symbol=this.value),i}render(i){var r;const a=i.isDisplayStyle&&this.value!=="\\smallint",u=new Tt(this.value,{fontFamily:a?"Size2-Regular":"Size1-Regular",classes:"op-symbol "+(a?"large-op":"small-op"),type:"op",maxFontSize:i.scalingFactor,isSelected:this.isSelected});if(!u)return null;u.right=u.italic;const p=(u.height-u.depth)/2-gs*i.scalingFactor,g=u.italic;u.setTop(p);let b=u;if(this.superscript||this.subscript){const w=(r=this.subsupPlacement)!=null?r:"auto";b=w==="over-under"||w==="auto"&&i.isDisplayStyle?this.attachLimits(i,{base:u,baseShift:p,slant:g}):this.attachSupsub(i,{base:u})}return new Tt(this.bind(i,b),{type:"op",caret:this.caret,isSelected:this.isSelected,classes:"op-group"}).wrap(i)}_serialize(i){if(!(i.expandMacro||i.skipStyles||i.skipPlaceholders)&&typeof this.verbatimLatex=="string")return this.verbatimLatex;const r=Me(this.command,this.mode);if(r!=null&&r.serialize)return r.serialize(this,i);const a=[];return a.push(this.command),this.explicitSubsupPlacement&&(this.subsupPlacement==="over-under"&&a.push("\\limits"),this.subsupPlacement==="adjacent"&&a.push("\\nolimits"),this.subsupPlacement==="auto"&&a.push("\\displaylimits")),a.push(this.supsubToLatex(i)),sn(a)}},Ia=class um extends et{constructor(i){const r=i.body;super(d(P({},i),{type:"overlap",body:typeof r=="string"?[new et({value:r})]:r,style:i==null?void 0:i.style})),this.skipBoundary=!0,this.align=i==null?void 0:i.align,this.boxType=i==null?void 0:i.boxType}static fromJson(i){return new um(i)}toJson(){const i={};return this.align&&(i.align=this.align),this.boxType&&(i.boxType=this.boxType),P(P({},super.toJson()),i)}render(i){const r=et.createBox(i,this.body,{classes:"inner"});return r?(this.caret&&(r.caret=this.caret),this.bind(i,new Tt([r,new Tt(null,{classes:"fix"})],{classes:this.align==="right"?"rlap":"llap",type:this.boxType}))):null}},ws=class cm extends et{constructor(i){var r,a,u,p;super({type:"overunder",command:i.command,style:i.style,mode:i.mode,body:i.body,skipBoundary:(r=i.skipBoundary)!=null?r:!0}),this.subsupPlacement=i.supsubPlacement,this.svgAbove=i.svgAbove,this.svgBelow=i.svgBelow,this.svgBody=i.svgBody,this.above=i.above,this.below=i.below,this.boxType=(a=i.boxType)!=null?a:"ord",this.paddedBody=(u=i.paddedBody)!=null?u:!1,this.paddedLabels=(p=i.paddedLabels)!=null?p:!1}static fromJson(i){return new cm(i)}toJson(){const i=super.toJson();return this.skipBoundary||(i.skipBoundary=!1),this.subsupPlacement&&(i.subsupPlacement=this.subsupPlacement),this.svgAbove&&(i.svgAbove=this.svgAbove),this.svgBelow&&(i.svgBelow=this.svgBelow),this.svgBody&&(i.svgBody=this.svgBody),this.boxType!=="ord"&&(i.boxType=this.boxType),this.paddedBody&&(i.paddedBody=!0),this.paddedLabels&&(i.paddedLabels=!0),i}render(i){let r=this.svgBody?xu(this.svgBody):et.createBox(i,this.body,{type:"ignore"});const a=new Si({parent:i,mathstyle:"scriptstyle"},this.style);let u=null;this.svgAbove?u=xu(this.svgAbove):this.above&&(u=et.createBox(a,this.above,{type:"ignore"}));let p=null;this.svgBelow?p=xu(this.svgBelow):this.below&&(p=et.createBox(a,this.below,{type:"ignore"})),this.paddedBody&&(r=new Tt([fo(i,"open"),r,fo(i,"close")],{type:"ignore"}));let g=Ud(i,{base:r,above:u,below:p,type:this.boxType==="bin"||this.boxType==="rel"?this.boxType:"ord",paddedAboveBelow:this.paddedLabels});return g?(this.subsupPlacement==="over-under"?g=this.attachLimits(i,{base:g,type:g.type}):g=this.attachSupsub(i,{base:g}),this.caret&&(g.caret=this.caret),this.bind(i,g)):null}};function Ud(e,i){if(!i.base)return null;if(!i.above&&!i.below){const b=new Tt(i.base,{type:i.type});return b.setStyle("position","relative"),b}let r=0;i.above&&(r=e.metrics.bigOpSpacing5);let a=null;const u=i.base,p=0,g=["ML__center"];if(i.paddedAboveBelow&&g.push("ML__label_padding"),i.below&&i.above){const b=e.metrics.bigOpSpacing5+i.below.height+i.below.depth+u.depth+p;a=new kr({bottom:b,children:[e.metrics.bigOpSpacing5,{box:i.below,classes:g},{box:u,classes:["ML__center"]},r,{box:i.above,classes:g},e.metrics.bigOpSpacing5]})}else i.below?a=new kr({top:u.height-p,children:[e.metrics.bigOpSpacing5,{box:i.below,classes:g},{box:u,classes:["ML__center"]}]}):i.above&&(a=new kr({bottom:u.depth+p,children:[{box:u,classes:["ML__center"]},r,{box:i.above,classes:g},e.metrics.bigOpSpacing5]}));return new Tt(a,{type:i.type})}var po=class hm extends et{constructor(i){var r,a,u,p;super(d(P({},i),{type:"phantom"})),this.captureSelection=!0,this.isInvisible=(r=i.isInvisible)!=null?r:!1,this.smashDepth=(a=i.smashDepth)!=null?a:!1,this.smashHeight=(u=i.smashHeight)!=null?u:!1,this.smashWidth=(p=i.smashWidth)!=null?p:!1}static fromJson(i){return new hm(i)}toJson(){const i={};return this.isInvisible&&(i.isInvisible=!0),this.smashDepth&&(i.smashDepth=!0),this.smashHeight&&(i.smashHeight=!0),this.smashWidth&&(i.smashWidth=!0),P(P({},super.toJson()),i)}render(i){const r=new Si({parent:i,isPhantom:!0});if(!this.smashDepth&&!this.smashHeight&&!this.smashWidth)return console.assert(this.isInvisible),et.createBox(r,this.body,{classes:"inner"});const a=et.createBox(this.isInvisible?r:i,this.body);if(!a)return null;if(this.smashWidth){const u=new Tt(null,{classes:"fix"});return new Tt([a,u],{classes:"rlap"}).wrap(i)}if(!this.smashHeight&&!this.smashDepth)return a;if(this.smashHeight&&(a.height=0),this.smashDepth&&(a.depth=0),a.children)for(const u of a.children)this.smashHeight&&(u.height=0),this.smashDepth&&(u.depth=0);return new kr({firstBaseline:[{box:a}]},{type:a.type}).wrap(i)}},Go=class fm extends et{constructor(i){var r;super(P({type:"spacing"},i)),this.width=i==null?void 0:i.width,this._braced=(r=i==null?void 0:i.braced)!=null?r:!1}static fromJson(i){return new fm(i)}toJson(){const i=super.toJson();return this.width!==void 0&&(i.width=this.width),this._braced&&(i.braced=!0),i}render(i){var r;if(this.command==="space")return new Tt(this.mode==="math"?null:" ");let a;if(this.width!==void 0)a=new Tt(null,{classes:"mspace"}),a.left=i.toEm(this.width);else{const u=(r={"\\qquad":"qquad","\\quad":"quad","\\enspace":"enspace","\\;":"thickspace","\\:":"mediumspace","\\>":"mediumspace","\\,":"thinspace","\\!":"negativethinspace"}[this.command])!=null?r:"mediumspace";a=new Tt(null,{classes:u})}return a=this.bind(i,a),this.caret&&(a.caret=this.caret),a}_serialize(i){var r;if(!i.expandMacro&&typeof this.verbatimLatex=="string")return this.verbatimLatex;const a=Me(this.command,this.mode);if(a!=null&&a.serialize)return a.serialize(this,i);const u=(r=this.command)!=null?r:"";return this.width===void 0?u:this._braced&&!("register"in this.width)?`${u}{${Or(this.width)}}`:`${u}${Or(this.width)}`}},$u=class dm extends et{constructor(i){var r;super(d(P({},i),{type:"surd",mode:(r=i.mode)!=null?r:"math",style:i.style,displayContainsHighlight:!0,body:i.body})),this.above=i.index}static fromJson(i){return new dm(d(P({},i),{index:i.above}))}_serialize(i){if(!(i.expandMacro||i.skipStyles||i.skipPlaceholders)&&typeof this.verbatimLatex=="string")return this.verbatimLatex;const r=Me(this.command,this.mode);if(r!=null&&r.serialize)return r.serialize(this,i);const a=this.command,u=this.bodyToLatex(i);return this.above&&!this.hasEmptyBranch("above")?jn(`${a}[${this.aboveToLatex(i)}]`,u):/^[0-9]$/.test(u)?`${a}${u}`:jn(a,u)}get children(){if(this._children)return this._children;const i=[];if(this.above)for(const r of this.above)i.push(...r.children),i.push(r);if(this.body)for(const r of this.body)i.push(...r.children),i.push(r);return this._children=i,i}render(i){var r;const a=new Si({parent:i,mathstyle:"cramp"},this.style),u=(r=et.createBox(a,this.body,{type:"inner"}))!=null?r:new Tt(null),p=a.scalingFactor,g=a.metrics.defaultRuleThickness/p,b=i.isDisplayStyle?ua:g,w=new Tt(null,{classes:"ML__sqrt-line",style:this.style});w.height=g,w.softWidth=u.width;let E=p*(g+b/4);const N=Math.max(p*2*b,u.height+u.depth)+E+g,Z=new Si({parent:i},this.style),ue=this.bind(Z,new Tt(Ou("inner","\\surd",N,!1,Z,{isSelected:this.isSelected}),{isSelected:this.isSelected,classes:"ML__sqrt-sign",style:this.style}));if(!ue)return null;const me=ue.height+ue.depth-g;me>u.height+u.depth+E&&(E=(E+me-(u.height+u.depth))/2),ue.setTop(ue.height-u.height-E);const Ve=this.bind(i,new kr({firstBaseline:[{box:new Tt(u)},E-2*g,{box:w},g]})),Ct=et.createBox(new Si({parent:i,mathstyle:"scriptscriptstyle"}),this.above,{type:"ignore"});if(!Ct){const It=new Tt([ue,Ve],{classes:this.containsCaret?"ML__contains-caret":"",type:"inner"});return It.setStyle("display","inline-block"),It.setStyle("height",It.height+It.depth,"em"),this.caret&&(It.caret=this.caret),this.bind(i,It)}const Ue=new kr({shift:-.6*(Math.max(ue.height,Ve.height)-Math.max(ue.depth,Ve.depth)),children:[{box:Ct}]}),ct=new Tt([new Tt(Ue,{classes:"ML__sqrt-index",type:"ignore"}),ue,Ve],{type:"inner",classes:this.containsCaret?"ML__contains-caret":""});return ct.height=ue.height,ct.depth=ue.depth,this.caret&&(ct.caret=this.caret),this.bind(i,ct)}},zd=class extends Tt{constructor(e){super(null,{type:"skip"}),this._width=e}toMarkup(){return`<span style="display:inline-block;width:${Math.ceil(this.width*100)/100}em"></span>`}};function Ku(e,i){if(!e.parent)return;const r=e.parent.children,a=r.indexOf(e);let u=a-1;for(;u>=0&&r[u].type==="ignore";)u-=1;if(u<0&&e.parent.parent&&e.parent.type==="lift"){Ku(e.parent,i);return}a>0&&r[a-1].type==="skip"?r[a-1].width+=i:r.splice(a,0,new zd(i))}var Uu={ord:{op:3,bin:4,rel:5,inner:3},op:{ord:3,op:3,rel:5,inner:3},bin:{ord:4,op:4,open:4,inner:4},rel:{ord:5,op:5,open:5,inner:5},close:{op:3,bin:4,rel:5,inner:3},punct:{ord:3,op:3,rel:3,open:3,punct:3,inner:3},inner:{ord:3,op:3,bin:4,rel:5,open:3,punct:3,inner:3}},Vd={ord:{op:3},op:{ord:3,op:3},close:{op:3},inner:{op:3}};function Af(e){Rl(e,(i,r)=>{r.type==="bin"&&(!i||/^(middle|bin|op|rel|open|punct)$/.test(i.type))&&(r.type="ord"),(i==null?void 0:i.type)==="bin"&&/^(rel|close|punct)$/.test(r.type)&&(i.type="ord"),r.type!=="ignore"&&(i=r)})}function Ho(e,i){if(!e.children)return e;const r=e.children;Af(r);const a=i.getRegisterAsEm("thinmuskip"),u=i.getRegisterAsEm("medmuskip"),p=i.getRegisterAsEm("thickmuskip");return Rl(r,(g,b)=>{var w,E,R;if(!g)return;const N=g.type,Z=b.isTight?(w=Vd[N])!=null?w:null:(E=Uu[N])!=null?E:null,ue=(R=Z==null?void 0:Z[b.type])!=null?R:null;ue===3&&Ku(b,a),ue===4&&Ku(b,u),ue===5&&Ku(b,p)}),e}function Rl(e,i,r=void 0){if(!e)return r;e=[...e];for(const a of e)a.type==="lift"?r=Rl(a.children,i,r):a.type==="ignore"?Rl(a.children,i):(i(r,a),Rl(a.children,i),r=a);return r}var zu=class pm extends et{constructor(i){super({type:"tooltip",command:i.command,mode:i.mode,style:i.style,body:i.body,displayContainsHighlight:!0}),this.tooltip=new et({type:"root",mode:i.content,body:i.tooltip,style:{}}),this.skipBoundary=!0,this.captureSelection=!1}static fromJson(i){return new pm(d(P({},i),{tooltip:Pa(i.tooltip)}))}toJson(){var i;const r=(i=this.tooltip.body)==null?void 0:i.filter(a=>a.type!=="first").map(a=>a.toJson());return d(P({},super.toJson()),{tooltip:r})}render(i){const r=et.createBox(new Si,this.body);if(!r)return null;const a=new Si({parent:i,mathstyle:"displaystyle"},{fontSize:pu}),u=yl(Ho(new Tt(this.tooltip.render(a),{classes:"ML__tooltip-content"}),a)),p=new Tt([u,r],{classes:"ML__tooltip-container"});return this.caret&&(p.caret=this.caret),this.bind(i,p)}},mo=class mm extends et{constructor(i,r){super(d(P({},r),{type:"operator",isFunction:r==null?void 0:r.isFunction})),this.value=i,this.variant=r==null?void 0:r.variant,this.variantStyle=r==null?void 0:r.variantStyle,this.subsupPlacement=r==null?void 0:r.limits}static fromJson(i){return new mm(i.symbol,i)}toJson(){const i=super.toJson();return this.variant&&(i.variant=this.variant),this.variantStyle&&(i.variantStyle=this.variantStyle),this.subsupPlacement&&(i.limits=this.subsupPlacement),this.value&&(i.symbol=this.value),i}render(i){var r;const a=new Tt(this.value,{type:"op",mode:"math",maxFontSize:i.scalingFactor,style:{variant:this.variant,variantStyle:this.variantStyle},isSelected:this.isSelected,letterShapeStyle:i.letterShapeStyle});let u=a;if(this.superscript||this.subscript){const p=(r=this.subsupPlacement)!=null?r:"auto";u=p==="over-under"||p==="auto"&&i.isDisplayStyle?this.attachLimits(i,{base:a}):this.attachSupsub(i,{base:a})}return new Tt(this.bind(i,u),{type:"op",caret:this.caret,isSelected:this.isSelected,classes:"op-group"}).wrap(i)}_serialize(i){if(!(i.expandMacro||i.skipStyles||i.skipPlaceholders)&&typeof this.verbatimLatex=="string")return this.verbatimLatex;const r=Me(this.command,this.mode);if(r!=null&&r.serialize)return r.serialize(this,i);const a=[this.command];return this.explicitSubsupPlacement&&(this.subsupPlacement==="over-under"&&a.push("\\limits"),this.subsupPlacement==="adjacent"&&a.push("\\nolimits"),this.subsupPlacement==="auto"&&a.push("\\displaylimits")),a.push(this.supsubToLatex(i)),sn(a)}};function Pa(e){if(k(e))return e.map(a=>Pa(a));if(typeof e=="string")return et.fromJson(e);e=P({},e);for(const a of Cs)e[a]&&(e[a]=Pa(e[a]));e.args&&(e.args=Gd(e.args)),e.array&&(e.array=Pa(e.array));const i=e.type;let r;i==="accent"&&(r=Ca.fromJson(e)),i==="array"&&(r=Tn.fromJson(e)),i==="box"&&(r=Ma.fromJson(e)),i==="chem"&&(r=Sf.fromJson(e)),i==="composition"&&(r=Fu.fromJson(e)),i==="delim"&&(r=kf.fromJson(e)),i==="enclose"&&(r=Dl.fromJson(e)),i==="error"&&(r=Ra.fromJson(e)),i==="extensible-symbol"&&(r=Ml.fromJson(e)),i==="genfrac"&&(r=Vo.fromJson(e)),i==="group"&&(r=Vc.fromJson(e)),i==="latex"&&(r=Lr.fromJson(e)),i==="latexgroup"&&(r=Cl.fromJson(e)),i==="leftright"&&(r=Zn.fromJson(e)),i==="macro"&&(r=xf.fromJson(e)),i==="macro-argument"&&(r=Gc.fromJson(e)),i==="operator"&&(r=mo.fromJson(e)),i==="overlap"&&(r=Ia.fromJson(e)),i==="overunder"&&(r=ws.fromJson(e)),i==="placeholder"&&(r=fa.fromJson(e)),i==="prompt"&&(r=wf.fromJson(e)),i==="phantom"&&(r=po.fromJson(e)),i==="sizeddelim"&&(r=Bu.fromJson(e)),i==="spacing"&&(r=Go.fromJson(e)),i==="subsup"&&(r=Al.fromJson(e)),i==="surd"&&(r=$u.fromJson(e)),i==="text"&&(r=No.fromJson(e)),i==="tooltip"&&(r=zu.fromJson(e)),r||(console.assert(!i||["first","mbin","mrel","mclose","minner","mop","mopen","mord","mpunct","root","space"].includes(i),`MathLive 0.98.5: an unexpected atom type "${i}" was encountered. Add new atom constructors to \`fromJson()\` in "atom.ts"`),r=et.fromJson(e));for(const a of Cs)e[a]&&r.setChildren(e[a],a);return e.verbatimLatex!==void 0&&(r.verbatimLatex=e.verbatimLatex),e.subsupPlacement&&(r.subsupPlacement=e.subsupPlacement),e.explicitSubsupPlacement&&(r.explicitSubsupPlacement=!0),e.isFunction&&(r.isFunction=!0),e.isExtensibleSymbol&&(r.isExtensibleSymbol=!0),e.skipBoundary&&(r.skipBoundary=!0),e.captureSelection&&(r.captureSelection=!0),r}function Gd(e){if(e&&Array.isArray(e))return e.map(i=>i==="<null>"?null:typeof i=="object"&&"group"in i?{group:i.group.map(r=>Pa(r))}:typeof i=="object"&&"atoms"in i?i.atoms.map(r=>Pa(r)):i)}var Lf={main:["Main-Regular","ML__cmr"],"main-italic":["Main-Italic","ML__cmr ML__it"],"main-bold":["Main-Bold","ML__cmr ML__bold"],"main-bolditalic":["Main-BoldItalic","ML__cmr ML__bold ML__it"],normal:["Main-Regular","ML__cmr"],"normal-bold":["Main-Bold","ML__mathbf"],"normal-italic":["Math-Italic","ML__mathit"],"normal-bolditalic":["Math-BoldItalic","ML__mathbfit"],ams:["AMS-Regular","ML__ams"],"ams-bold":["AMS-Regular","ML__ams"],"ams-italic":["AMS-Regular","ML__ams"],"ams-bolditalic":["AMS-Regular","ML__ams"],"sans-serif":["SansSerif-Regular","ML__sans"],"sans-serif-bold":["SansSerif-Regular","ML__sans ML__bold"],"sans-serif-italic":["SansSerif-Regular","ML__sans"],"sans-serif-bolditalic":["SansSerif-Regular","ML__sans"],calligraphic:["Caligraphic-Regular","ML__cal"],"calligraphic-bold":["Caligraphic-Regular","ML__cal ML__bold"],"calligraphic-italic":["Caligraphic-Regular","ML__cal ML__it"],"calligraphic-bolditalic":["Caligraphic-Regular","ML__cal ML__bold ML__it"],script:["Script-Regular","ML__script"],"script-bold":["Script-Regular","ML__script ML__bold"],"script-italic":["Script-Regular","ML__script ML__it"],"script-bolditalic":["Script-Regular","ML__script ML__bold ML__it"],fraktur:["Fraktur-Regular","ML__frak"],"fraktur-bold":["Fraktur-Regular","ML__frak"],"fraktur-italic":["Fraktur-Regular","ML__frak"],"fraktur-bolditalic":["Fraktur-Regular","ML__frak"],monospace:["Typewriter-Regular","ML__tt"],"monospace-bold":["Typewriter-Regular","ML__tt ML__bold"],"monospace-italic":["Typewriter-Regular","ML__tt ML__it"],"monospace-bolditalic":["Typewriter-Regular","ML__tt ML__bold ML__it"],"double-struck":["AMS-Regular","ML__bb"],"double-struck-bold":["AMS-Regular","ML__bb"],"double-struck-italic":["AMS-Regular","ML__bb"],"double-struck-bolditalic":["AMS-Regular","ML__bb"]},Vu={"double-struck":/^[A-Z ]$/,script:/^[A-Z ]$/,calligraphic:/^[\dA-Z ]$/,fraktur:/^[\dA-Za-z ]$|^[!"#$%&'()*+,\-./:;=?[]^]$/,monospace:/^[\dA-Za-z ]$|^[!"&'()*+,\-./:;=?@[\]^_~\u0131\u0237\u0393\u0394\u0398\u039B\u039E\u03A0\u03A3\u03A5\u03A8\u03A9]$/,"sans-serif":/^[\dA-Za-z ]$|^[!"&'()*+,\-./:;=?@[\]^_~\u0131\u0237\u0393\u0394\u0398\u039B\u039E\u03A0\u03A3\u03A5\u03A8\u03A9]$/},Df=/^[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5]$/,Hd=/^[\u0393|\u0394\u0398\u039B\u039E\u03A0\u03A3\u03A5\u03A6\u03A8\u03A9]$/,Wd=[/^[a-z]$/,/^[A-Z]$/,Df,Hd],jd={iso:["it","it","it","it"],tex:["it","it","it","up"],french:["it","up","up","up"],upright:["up","up","up","up"]},qd=class extends us{constructor(){super("math")}createAtom(e,i,r){var a,u,p,g;if(i===null)return new et({type:"mord",mode:"math",command:e,value:e,style:r});const b=window.MathfieldElement.isFunction((a=i.command)!=null?a:e);if(i.definitionType==="symbol"){const E=new et({type:(u=i.type)!=null?u:"mord",mode:"math",command:(p=i.command)!=null?p:e,value:String.fromCodePoint(i.codepoint),style:r});return b&&(E.isFunction=!0),e.startsWith("\\")&&(E.verbatimLatex=e),E}const w=new et({type:"mord",mode:"math",command:(g=i.command)!=null?g:e,value:e,style:r});return b&&(w.isFunction=!0),e.startsWith("\\")&&(w.verbatimLatex=e),w}serialize(e,i){const r=Zd(e,d(P({},i),{defaultMode:"math"}));return r.length===0||i.defaultMode!=="text"?r:["$ ",...r," $"]}getFont(e,i){console.assert(i.variant!==void 0);let{variant:r}=i,{variantStyle:a}=i;r==="normal"&&!a&&/[\u00A3\u0131\u0237]/.test(e.value)&&(r="main",a="italic"),r==="normal"&&!a&&e.value.length===1&&Wd.forEach((b,w)=>{var E;b.test(e.value)&&jd[(E=i.letterShapeStyle)!=null?E:"tex"][w]==="it"&&(a="italic")}),a==="up"&&(a=void 0);const u=a?r+"-"+a:r;console.assert(Lf[u]!==void 0);const[p,g]=Lf[u];return Vu[r]&&!Vu[r].test(e.value)?(e.value=ze(e.value,r,a),null):(Df.test(e.value)&&(e.classes+=" lcGreek"),g&&(e.classes+=" "+g),p)}};function Zd(e,i){const{parent:r}=e[0],a=qc(r);return Er(e,"variant").map(u=>{const p=qc(u[0]);let g="";p&&p!==a&&(g={calligraphic:"\\mathcal",fraktur:"\\mathfrak","double-struck":"\\mathbb",script:"\\mathscr",monospace:"\\mathtt","sans-serif":"\\mathsf",normal:"\\mathrm","normal-italic":"\\mathnormal","normal-bold":"\\mathbf","normal-bolditalic":"\\mathbfit",ams:"","ams-italic":"\\mathit","ams-bold":"\\mathbf","ams-bolditalic":"\\mathbfit",main:"","main-italic":"\\mathit","main-bold":"\\mathbf","main-bolditalic":"\\mathbfit"}[p],console.assert(g!==void 0));const b=sn(u.map(w=>w._serialize(i)));return g?jn(g,b):b})}function qc(e){if(!e)return"";const{style:i}=e;if(i.variant===void 0)return"";let r=i.variant;return!["calligraphic","fraktur","double-struck","script","monospace","sans-serif"].includes(i.variant)&&i.variantStyle&&i.variantStyle!=="up"&&(r+="-"+i.variantStyle),r}new qd;function Yd(e,i){return e.map(r=>r._serialize(i))}function Xd(e,i){return Er(e,"fontShape").map(r=>{const a=Yd(r,i),{fontShape:u}=r[0].style;let p="";return u==="it"&&(p="\\textit"),u==="sl"&&(p="\\textsl"),u==="sc"&&(p="\\textsc"),u==="n"&&(p="\\textup"),!p&&u?`{${jn("\\fontshape",u)}${sn(a)}}`:p?jn(p,sn(a)):sn(a)})}function Jd(e,i){return Er(e,"fontSeries").map(r=>{const a=Xd(r,i),{fontSeries:u}=r[0].style;let p="";return u==="b"&&(p="\\textbf"),u==="l"&&(p="\\textlf"),u==="m"&&(p="\\textmd"),u&&!p?`{${jn("\\fontseries",u)}${sn(a)}}`:p?jn(p,sn(a)):sn(a)})}function Qd(e,i){return Er(e,"fontSize").map(r=>{var a,u;const p=Jd(r,i),g=(u=["","\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"][(a=r[0].style.fontSize)!=null?a:""])!=null?u:"";return g?`${g} ${sn(p)}`:sn(p)})}function Zc(e,i,r){return Er(e,"fontFamily").map(a=>{var u,p;const g=Qd(a,i),b=(p={roman:"textrm",monospace:"texttt","sans-serif":"textsf"}[(u=a[0].style.fontFamily)!=null?u:""])!=null?p:"";return b?`\\${b}{${sn(g)}}`:a[0].style.fontFamily?`{\\fontfamily{${a[0].style.fontFamily}} ${sn(g)}}`:r?`\\text{${sn(g)}}`:sn(g)})}var Cf={roman:"","sans-serif":"ML__sans",monospace:"ML__tt"},Gu=class extends us{constructor(){super("text")}createAtom(e,i,r){return i&&i.definitionType==="symbol"?new No(e,String.fromCodePoint(i.codepoint),r!=null?r:{}):null}serialize(e,i){return Zc(e,d(P({},i),{defaultMode:"text"}),i.defaultMode!=="text")}getFont(e,i){var r,a,u,p,g;const{fontFamily:b}=i;if(Cf[b]?e.classes+=" "+Cf[b]:b&&e.setStyle("font-family",b),i.fontShape&&(e.classes+=" ",e.classes+=(r={it:"ML__it",sl:"ML__shape_sl",sc:"ML__shape_sc",ol:"ML__shape_ol"}[i.fontShape])!=null?r:""),i.fontSeries){const w=i.fontSeries.match(/(.?[lbm])?(.?[cx])?/);w&&(e.classes+=" ",e.classes+=(u={ul:"ML__series_ul",el:"ML__series_el",l:"ML__series_l",sl:"ML__series_sl",m:"",sb:"ML__series_sb",b:"ML__bold",eb:"ML__series_eb",ub:"ML__series_ub"}[(a=w[1])!=null?a:""])!=null?u:"",e.classes+=" ",e.classes+=(g={uc:"ML__series_uc",ec:"ML__series_ec",c:"ML__series_c",sc:"ML__series_sc",n:"",sx:"ML__series_sx",x:"ML__series_x",ex:"ML__series_ex",ux:"ML__series_ux"}[(p=w[2])!=null?p:""])!=null?g:"")}return"Main-Regular"}};new Gu;var e0=class extends us{constructor(){super("latex")}createAtom(e){return new Lr(e)}serialize(e,i){return e.filter(r=>r instanceof Lr&&!r.isSuggestion).map(r=>r.value)}getFont(){return null}};new e0;var t0={id:"dvorak",locale:"en",displayName:"Dvorak",virtualLayout:"dvorak",platform:"",score:0,mapping:{KeyA:["a","A","\xE5","\xC5"],KeyB:["x","X","\u2248","\u02DB"],KeyC:["j","J","\u2206","\xD4"],KeyD:["e","E","\xB4","\xB4"],KeyE:[".",">","\u2265","\u02D8"],KeyF:["u","U","\xA8","\xA8"],KeyG:["i","I","\u02C6","\u02C6"],KeyH:["d","D","\u2202","\xCE"],KeyI:["c","C","\xE7","\xC7"],KeyJ:["h","H","\u02D9","\xD3"],KeyK:["t","T","\u2020","\u02C7"],KeyL:["n","N","\u02DC","\u02DC"],KeyM:["m","M","\xB5","\xC2"],KeyN:["b","B","\u222B","\u0131"],KeyO:["r","R","\xAE","\u2030"],KeyP:["l","L","\xAC","\xD2"],KeyQ:["'",'"',"\xE6","\xC6"],KeyR:["p","P","\u03C0","\u220F"],KeyS:["o","O","\xF8","\xD8"],KeyT:["y","Y","\xA5","\xC1"],KeyU:["g","G","\xA9","\u02DD"],KeyV:["k","K","\u02DA","\uF8FF"],KeyW:[",","<","\u2264","\xAF"],KeyX:["q","Q","\u0153","\u0152"],KeyY:["f","F","\u0192","\xCF"],KeyZ:[";",":","\u2026","\xDA"],Digit1:["1","!","\xA1","\u2044"],Digit2:["2","@","\u2122","\u20AC"],Digit3:["3","#","\xA3","\u2039"],Digit4:["4","$","\xA2","\u203A"],Digit5:["5","%","\u221E","\uFB01"],Digit6:["6","^","\xA7","\uFB02"],Digit7:["7","&","\xB6","\u2021"],Digit8:["8","*","\u2022","\xB0"],Digit9:["9","(","\xAA","\xB7"],Digit0:["0",")","\xBA","\u201A"],Space:[" "," "," "," "],Minus:["[","{","\u201C","\u201D"],Equal:["]","}","\u2018","\u2019"],BracketLeft:["/","?","\xF7","\xBF"],BracketRight:["=","+","\u2260","\xB1"],Backslash:["\\","|","\xAB","\xBB"],Semicolon:["s","S","\xDF","\xCD"],Quote:["-","_","\u2013","\u2014"],Backquote:["`","~","`","`"],Comma:["w","W","\u2211","\u201E"],Period:["v","V","\u221A","\u25CA"],Slash:["z","Z","\u03A9","\xB8"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],Numpad1:["1","1","1","1"],Numpad2:["2","2","2","2"],Numpad3:["3","3","3","3"],Numpad4:["4","4","4","4"],Numpad5:["5","5","5","5"],Numpad6:["6","6","6","6"],Numpad7:["7","7","7","7"],Numpad8:["8","8","8","8"],Numpad9:["9","9","9","9"],Numpad0:["0","0","0","0"],NumpadDecimal:[".",".",".","."],IntlBackslash:["\xA7","\xB1","\xA7","\xB1"],NumpadEqual:["=","=","=","="],AudioVolumeUp:["","=","","="]}},Yc={id:"apple.en-intl",displayName:"English (international)",virtualLayout:"qwerty",platform:"apple",locale:"en",score:0,mapping:{KeyA:["a","A","\xE5","\xC5"],KeyB:["b","B","\u222B","\u0131"],KeyC:["c","C","\xE7","\xC7"],KeyD:["d","D","\u2202","\xCE"],KeyE:["e","E","\xB4","\xB4"],KeyF:["f","F","\u0192","\xCF"],KeyG:["g","G","\xA9","\u02DD"],KeyH:["h","H","\u02D9","\xD3"],KeyI:["i","I","\u02C6","\u02C6"],KeyJ:["j","J","\u2206","\xD4"],KeyK:["k","K","\u02DA","\uF8FF"],KeyL:["l","L","\xAC","\xD2"],KeyM:["m","M","\xB5","\xC2"],KeyN:["n","N","\u02DC","\u02DC"],KeyO:["o","O","\xF8","\xD8"],KeyP:["p","P","\u03C0","\u220F"],KeyQ:["q","Q","\u0153","\u0152"],KeyR:["r","R","\xAE","\u2030"],KeyS:["s","S","\xDF","\xCD"],KeyT:["t","T","\u2020","\u02C7"],KeyU:["u","U","\xA8","\xA8"],KeyV:["v","V","\u221A","\u25CA"],KeyW:["w","W","\u2211","\u201E"],KeyX:["x","X","\u2248","\u02DB"],KeyY:["y","Y","\xA5","\xC1"],KeyZ:["z","Z","\u03A9","\xB8"],Digit1:["1","!","\xA1","\u2044"],Digit2:["2","@","\u2122","\u20AC"],Digit3:["3","#","\xA3","\u2039"],Digit4:["4","$","\xA2","\u203A"],Digit5:["5","%","\u221E","\uFB01"],Digit6:["6","^","\xA7","\uFB02"],Digit7:["7","&","\xB6","\u2021"],Digit8:["8","*","\u2022","\xB0"],Digit9:["9","(","\xAA","\xB7"],Digit0:["0",")","\xBA","\u201A"],Space:[" "," "," "," "],Minus:["-","_","\u2013","\u2014"],Equal:["=","+","\u2260","\xB1"],BracketLeft:["[","{","\u201C","\u201D"],BracketRight:["]","}","\u2018","\u2019"],Backslash:["\\","|","\xAB","\xBB"],Semicolon:[";",":","\u2026","\xDA"],Quote:["'",'"',"\xE6","\xC6"],Backquote:["`","\u02DC","`","`"],Comma:[",","<","\u2264","\xAF"],Period:[".",">","\u2265","\u02D8"],Slash:["/","?","\xF7","\xBF"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],Numpad1:["1","1","1","1"],Numpad2:["2","2","2","2"],Numpad3:["3","3","3","3"],Numpad4:["4","4","4","4"],Numpad5:["5","5","5","5"],Numpad6:["6","6","6","6"],Numpad7:["7","7","7","7"],Numpad8:["8","8","8","8"],Numpad9:["9","9","9","9"],Numpad0:["0","0","0","0"],NumpadDecimal:[".",".",".","."],IntlBackslash:["\xA7","\xB1","\xA7","\xB1"],NumpadEqual:["=","=","=","="],AudioVolumeUp:["","=","","="]}},Mf={id:"windows.en-intl",displayName:"English (international)",platform:"windows",virtualLayout:"qwerty",locale:"en",score:0,mapping:{KeyA:["a","A","\xE1","\xC1"],KeyB:["b","B","",""],KeyC:["c","C","\xA9","\xA2"],KeyD:["d","D","\xF0","\xD0"],KeyE:["e","E","\xE9","\xC9"],KeyF:["f","F","",""],KeyG:["g","G","",""],KeyH:["h","H","",""],KeyI:["i","I","\xED","\xCD"],KeyJ:["j","J","",""],KeyK:["k","K","",""],KeyL:["l","L","\xF8","\xD8"],KeyM:["m","M","\xB5",""],KeyN:["n","N","\xF1","\xD1"],KeyO:["o","O","\xF3","\xD3"],KeyP:["p","P","\xF6","\xD6"],KeyQ:["q","Q","\xE4","\xC4"],KeyR:["r","R","\xAE",""],KeyS:["s","S","\xDF","\xA7"],KeyT:["t","T","\xFE","\xDE"],KeyU:["u","U","\xFA","\xDA"],KeyV:["v","V","",""],KeyW:["w","W","\xE5","\xC5"],KeyX:["x","X","",""],KeyY:["y","Y","\xFC","\xDC"],KeyZ:["z","Z","\xE6","\xC6"],Digit1:["1","!","\xA1","\xB9"],Digit2:["2","@","\xB2",""],Digit3:["3","#","\xB3",""],Digit4:["4","$","\xA4","\xA3"],Digit5:["5","%","\u20AC",""],Digit6:["6","^","\xBC",""],Digit7:["7","&","\xBD",""],Digit8:["8","*","\xBE",""],Digit9:["9","(","\u2018",""],Digit0:["0",")","\u2019",""],Space:[" "," ","",""],Minus:["-","_","\xA5",""],Equal:["=","+","\xD7","\xF7"],BracketLeft:["[","{","\xAB",""],BracketRight:["]","}","\xBB",""],Backslash:["\\","|","\xAC","\xA6"],Semicolon:[";",":","\xB6","\xB0"],Quote:["'",'"',"\xB4","\xA8"],Backquote:["`","~","",""],Comma:[",","<","\xE7","\xC7"],Period:[".",">","",""],Slash:["/","?","\xBF",""],NumpadDivide:["/","/","",""],NumpadMultiply:["*","*","",""],NumpadSubtract:["-","-","",""],NumpadAdd:["+","+","",""],IntlBackslash:["\\","|","",""]}},Xc={id:"linux.en",displayName:"English",platform:"linux",virtualLayout:"qwerty",locale:"en",score:0,mapping:{KeyA:["a","A","a","A"],KeyB:["b","B","b","B"],KeyC:["c","C","c","C"],KeyD:["d","D","d","D"],KeyE:["e","E","e","E"],KeyF:["f","F","f","F"],KeyG:["g","G","g","G"],KeyH:["h","H","h","H"],KeyI:["i","I","i","I"],KeyJ:["j","J","j","J"],KeyK:["k","K","k","K"],KeyL:["l","L","l","L"],KeyM:["m","M","m","M"],KeyN:["n","N","n","N"],KeyO:["o","O","o","O"],KeyP:["p","P","p","P"],KeyQ:["q","Q","q","Q"],KeyR:["r","R","r","R"],KeyS:["s","S","s","S"],KeyT:["t","T","t","T"],KeyU:["u","U","u","U"],KeyV:["v","V","v","V"],KeyW:["w","W","w","W"],KeyX:["x","X","x","X"],KeyY:["y","Y","y","Y"],KeyZ:["z","Z","z","Z"],Digit1:["1","!","1","!"],Digit2:["2","@","2","@"],Digit3:["3","#","3","#"],Digit4:["4","$","4","$"],Digit5:["5","%","5","%"],Digit6:["6","^","6","^"],Digit7:["7","&","7","&"],Digit8:["8","*","8","*"],Digit9:["9","(","9","("],Digit0:["0",")","0",")"],Space:[" "," "," "," "],Minus:["-","_","-","_"],Equal:["=","+","=","+"],BracketLeft:["[","{","[","{"],BracketRight:["]","}","]","}"],Backslash:["\\","|","\\","|"],Semicolon:[";",":",";",":"],Quote:["'",'"',"'",'"'],Backquote:["`","~","`","~"],Comma:[",","<",",","<"],Period:[".",">",".",">"],Slash:["/","?","/","?"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],Numpad1:["1","1","1","1"],Numpad2:["2","2","2","2"],Numpad3:["3","3","3","3"],Numpad4:["4","4","4","4"],Numpad5:["5","5","5","5"],Numpad6:["6","6","6","6"],Numpad7:["7","7","7","7"],Numpad8:["8","8","8","8"],Numpad9:["9","9","9","9"],Numpad0:["0","0","0","0"],NumpadDecimal:["",".","","."],IntlBackslash:["<",">","|","\xA6"],NumpadEqual:["=","=","=","="],NumpadComma:[".",".",".","."],NumpadParenLeft:["(","(","(","("],NumpadParenRight:[")",")",")",")"]}},Rf={id:"apple.french",locale:"fr",displayName:"French",platform:"apple",virtualLayout:"azerty",score:0,mapping:{KeyA:["q","Q","\u2021","\u03A9"],KeyB:["b","B","\xDF","\u222B"],KeyC:["c","C","\xA9","\xA2"],KeyD:["d","D","\u2202","\u2206"],KeyE:["e","E","\xEA","\xCA"],KeyF:["f","F","\u0192","\xB7"],KeyG:["g","G","\uFB01","\uFB02"],KeyH:["h","H","\xCC","\xCE"],KeyI:["i","I","\xEE","\xEF"],KeyJ:["j","J","\xCF","\xCD"],KeyK:["k","K","\xC8","\xCB"],KeyL:["l","L","\xAC","|"],KeyM:[",","?","\u221E","\xBF"],KeyN:["n","N","~","\u0131"],KeyO:["o","O","\u0153","\u0152"],KeyP:["p","P","\u03C0","\u220F"],KeyQ:["a","A","\xE6","\xC6"],KeyR:["r","R","\xAE","\u201A"],KeyS:["s","S","\xD2","\u2211"],KeyT:["t","T","\u2020","\u2122"],KeyU:["u","U","\xBA","\xAA"],KeyV:["v","V","\u25CA","\u221A"],KeyW:["z","Z","\xC2","\xC5"],KeyX:["x","X","\u2248","\u2044"],KeyY:["y","Y","\xDA","\u0178"],KeyZ:["w","W","\u2039","\u203A"],Digit1:["&","1","\uF8FF","\xB4"],Digit2:["\xE9","2","\xEB","\u201E"],Digit3:['"',"3","\u201C","\u201D"],Digit4:["'","4","\u2018","\u2019"],Digit5:["(","5","{","["],Digit6:["\xA7","6","\xB6","\xE5"],Digit7:["\xE8","7","\xAB","\xBB"],Digit8:["!","8","\xA1","\xDB"],Digit9:["\xE7","9","\xC7","\xC1"],Digit0:["\xE0","0","\xF8","\xD8"],Space:[" "," "," "," "],Minus:[")","\xB0","}","]"],Equal:["-","_","\u2014","\u2013"],BracketLeft:["^","\xA8","\xF4","\xD4"],BracketRight:["$","*","\u20AC","\xA5"],Backslash:["`","\xA3","@","#"],Semicolon:["m","M","\xB5","\xD3"],Quote:["\xF9","%","\xD9","\u2030"],Backquote:["<",">","\u2264","\u2265"],Comma:[";",".","\u2026","\u2022"],Period:[":","/","\xF7","\\"],Slash:["=","+","\u2260","\xB1"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],NumpadDecimal:[",",".",",","."],IntlBackslash:["@","#","\u2022","\u0178"],NumpadEqual:["=","=","=","="]}},Hu={id:"windows.french",locale:"fr",displayName:"French",virtualLayout:"azerty",platform:"windows",score:0,mapping:{KeyA:["q","Q","",""],KeyB:["b","B","",""],KeyC:["c","C","",""],KeyD:["d","D","",""],KeyE:["e","E","\u20AC",""],KeyF:["f","F","",""],KeyG:["g","G","",""],KeyH:["h","H","",""],KeyI:["i","I","",""],KeyJ:["j","J","",""],KeyK:["k","K","",""],KeyL:["l","L","",""],KeyM:[",","?","",""],KeyN:["n","N","",""],KeyO:["o","O","",""],KeyP:["p","P","",""],KeyQ:["a","A","",""],KeyR:["r","R","",""],KeyS:["s","S","",""],KeyT:["t","T","",""],KeyU:["u","U","",""],KeyV:["v","V","",""],KeyW:["z","Z","",""],KeyX:["x","X","",""],KeyY:["y","Y","",""],KeyZ:["w","W","",""],Digit1:["&","1","",""],Digit2:["\xE9","2","~",""],Digit3:['"',"3","#",""],Digit4:["'","4","{",""],Digit5:["(","5","[",""],Digit6:["-","6","|",""],Digit7:["\xE8","7","`",""],Digit8:["_","8","\\",""],Digit9:["\xE7","9","^",""],Digit0:["\xE0","0","@",""],Space:[" "," ","",""],Minus:[")","\xB0","]",""],Equal:["=","+","}",""],BracketLeft:["^","\xA8","",""],BracketRight:["$","\xA3","\xA4",""],Backslash:["*","\xB5","",""],Semicolon:["m","M","",""],Quote:["\xF9","%","",""],Backquote:["\xB2","","",""],Comma:[";",".","",""],Period:[":","/","",""],Slash:["!","\xA7","",""],NumpadDivide:["/","/","",""],NumpadMultiply:["*","*","",""],NumpadSubtract:["-","-","",""],NumpadAdd:["+","+","",""],IntlBackslash:["<",">","",""]}},i0={id:"linux.french",locale:"fr",displayName:"French",virtualLayout:"azerty",platform:"linux",score:0,mapping:{KeyA:["q","Q","@","\u03A9"],KeyB:["b","B","\u201D","\u2019"],KeyC:["c","C","\xA2","\xA9"],KeyD:["d","D","\xF0","\xD0"],KeyE:["e","E","\u20AC","\xA2"],KeyF:["f","F","\u0111","\xAA"],KeyG:["g","G","\u014B","\u014A"],KeyH:["h","H","\u0127","\u0126"],KeyI:["i","I","\u2192","\u0131"],KeyJ:["j","J","\u0309","\u031B"],KeyK:["k","K","\u0138","&"],KeyL:["l","L","\u0142","\u0141"],KeyM:[",","?","\u0301","\u030B"],KeyN:["n","N","n","N"],KeyO:["o","O","\xF8","\xD8"],KeyP:["p","P","\xFE","\xDE"],KeyQ:["a","A","\xE6","\xC6"],KeyR:["r","R","\xB6","\xAE"],KeyS:["s","S","\xDF","\xA7"],KeyT:["t","T","\u0167","\u0166"],KeyU:["u","U","\u2193","\u2191"],KeyV:["v","V","\u201C","\u2018"],KeyW:["z","Z","\xAB","<"],KeyX:["x","X","\xBB",">"],KeyY:["y","Y","\u2190","\xA5"],KeyZ:["w","W","\u0142","\u0141"],Digit1:["&","1","\xB9","\xA1"],Digit2:["\xE9","2","~","\u215B"],Digit3:['"',"3","#","\xA3"],Digit4:["'","4","{","$"],Digit5:["(","5","[","\u215C"],Digit6:["-","6","|","\u215D"],Digit7:["\xE8","7","`","\u215E"],Digit8:["_","8","\\","\u2122"],Digit9:["\xE7","9","^","\xB1"],Digit0:["\xE0","0","@","\xB0"],Enter:["\r","\r","\r","\r"],Escape:["\x1B","\x1B","\x1B","\x1B"],Backspace:["\b","\b","\b","\b"],Tab:[" ",""," ",""],Space:[" "," "," "," "],Minus:[")","\xB0","]","\xBF"],Equal:["=","+","}","\u0328"],BracketLeft:["\u0302","\u0308","\u0308","\u030A"],BracketRight:["$","\xA3","\xA4","\u0304"],Backslash:["*","\xB5","\u0300","\u0306"],Semicolon:["m","M","\xB5","\xBA"],Quote:["\xF9","%","\u0302","\u030C"],Backquote:["\xB2","~","\xAC","\xAC"],Comma:[";",".","\u2500","\xD7"],Period:[":","/","\xB7","\xF7"],Slash:["!","\xA7","\u0323","\u0307"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],NumpadDecimal:["",".","","."],IntlBackslash:["<",">","|","\xA6"]}},Jc={id:"apple.german",locale:"de",displayName:"German",virtualLayout:"qwertz",platform:"apple",score:0,mapping:{KeyA:["a","A","\xE5","\xC5"],KeyB:["b","B","\u222B","\u2039"],KeyC:["c","C","\xE7","\xC7"],KeyD:["d","D","\u2202","\u2122"],KeyE:["e","E","\u20AC","\u2030"],KeyF:["f","F","\u0192","\xCF"],KeyG:["g","G","\xA9","\xCC"],KeyH:["h","H","\xAA","\xD3"],KeyI:["i","I","\u2044","\xDB"],KeyJ:["j","J","\xBA","\u0131"],KeyK:["k","K","\u2206","\u02C6"],KeyL:["l","L","@","\uFB02"],KeyM:["m","M","\xB5","\u02D8"],KeyN:["n","N","~","\u203A"],KeyO:["o","O","\xF8","\xD8"],KeyP:["p","P","\u03C0","\u220F"],KeyQ:["q","Q","\xAB","\xBB"],KeyR:["r","R","\xAE","\xB8"],KeyS:["s","S","\u201A","\xCD"],KeyT:["t","T","\u2020","\u02DD"],KeyU:["u","U","\xA8","\xC1"],KeyV:["v","V","\u221A","\u25CA"],KeyW:["w","W","\u2211","\u201E"],KeyX:["x","X","\u2248","\xD9"],KeyY:["z","Z","\u03A9","\u02C7"],KeyZ:["y","Y","\xA5","\u2021"],Digit1:["1","!","\xA1","\xAC"],Digit2:["2",'"',"\u201C","\u201D"],Digit3:["3","\xA7","\xB6","#"],Digit4:["4","$","\xA2","\xA3"],Digit5:["5","%","[","\uFB01"],Digit6:["6","&","]","^"],Digit7:["7","/","|","\\"],Digit8:["8","(","{","\u02DC"],Digit9:["9",")","}","\xB7"],Digit0:["0","=","\u2260","\xAF"],Space:[" "," "," "," "],Minus:["\xDF","?","\xBF","\u02D9"],Equal:["\xB4","`","'","\u02DA"],BracketLeft:["\xFC","\xDC","\u2022","\xB0"],BracketRight:["+","*","\xB1","\uF8FF"],Backslash:["#","'","\u2018","\u2019"],Semicolon:["\xF6","\xD6","\u0153","\u0152"],Quote:["\xE4","\xC4","\xE6","\xC6"],Backquote:["<",">","\u2264","\u2265"],Comma:[",",";","\u221E","\u02DB"],Period:[".",":","\u2026","\xF7"],Slash:["-","_","\u2013","\u2014"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],NumpadDecimal:[",",",",".","."],IntlBackslash:["^","\xB0","\u201E","\u201C"],NumpadEqual:["=","=","=","="]}},Qc={id:"windows.german",locale:"de",displayName:"German",platform:"windows",virtualLayout:"qwertz",score:0,mapping:{KeyA:["a","A","",""],KeyB:["b","B","",""],KeyC:["c","C","",""],KeyD:["d","D","",""],KeyE:["e","E","\u20AC",""],KeyF:["f","F","",""],KeyG:["g","G","",""],KeyH:["h","H","",""],KeyI:["i","I","",""],KeyJ:["j","J","",""],KeyK:["k","K","",""],KeyL:["l","L","",""],KeyM:["m","M","\xB5",""],KeyN:["n","N","",""],KeyO:["o","O","",""],KeyP:["p","P","",""],KeyQ:["q","Q","@",""],KeyR:["r","R","",""],KeyS:["s","S","",""],KeyT:["t","T","",""],KeyU:["u","U","",""],KeyV:["v","V","",""],KeyW:["w","W","",""],KeyX:["x","X","",""],KeyY:["z","Z","",""],KeyZ:["y","Y","",""],Digit1:["1","!","",""],Digit2:["2",'"',"\xB2",""],Digit3:["3","\xA7","\xB3",""],Digit4:["4","$","",""],Digit5:["5","%","",""],Digit6:["6","&","",""],Digit7:["7","/","{",""],Digit8:["8","(","[",""],Digit9:["9",")","]",""],Digit0:["0","=","}",""],Space:[" "," ","",""],Minus:["\xDF","?","\\","\u1E9E"],Equal:["\xB4","`","",""],BracketLeft:["\xFC","\xDC","",""],BracketRight:["+","*","~",""],Backslash:["#","'","",""],Semicolon:["\xF6","\xD6","",""],Quote:["\xE4","\xC4","",""],Backquote:["^","\xB0","",""],Comma:[",",";","",""],Period:[".",":","",""],Slash:["-","_","",""],NumpadDivide:["/","/","",""],NumpadMultiply:["*","*","",""],NumpadSubtract:["-","-","",""],NumpadAdd:["+","+","",""],IntlBackslash:["<",">","|",""]}},Wu={id:"linux.german",locale:"de",displayName:"German",platform:"windows",virtualLayout:"qwertz",score:0,mapping:{KeyA:["a","A","\xE6","\xC6"],KeyB:["b","B","\u201C","\u2018"],KeyC:["c","C","\xA2","\xA9"],KeyD:["d","D","\xF0","\xD0"],KeyE:["e","E","\u20AC","\u20AC"],KeyF:["f","F","\u0111","\xAA"],KeyG:["g","G","\u014B","\u014A"],KeyH:["h","H","\u0127","\u0126"],KeyI:["i","I","\u2192","\u0131"],KeyJ:["j","J","\u0323","\u0307"],KeyK:["k","K","\u0138","&"],KeyL:["l","L","\u0142","\u0141"],KeyM:["m","M","\xB5","\xBA"],KeyN:["n","N","\u201D","\u2019"],KeyO:["o","O","\xF8","\xD8"],KeyP:["p","P","\xFE","\xDE"],KeyQ:["q","Q","@","\u03A9"],KeyR:["r","R","\xB6","\xAE"],KeyS:["s","S","\u017F","\u1E9E"],KeyT:["t","T","\u0167","\u0166"],KeyU:["u","U","\u2193","\u2191"],KeyV:["v","V","\u201E","\u201A"],KeyW:["w","W","\u0142","\u0141"],KeyX:["x","X","\xAB","\u2039"],KeyY:["z","Z","\u2190","\xA5"],KeyZ:["y","Y","\xBB","\u203A"],Digit1:["1","!","\xB9","\xA1"],Digit2:["2",'"',"\xB2","\u215B"],Digit3:["3","\xA7","\xB3","\xA3"],Digit4:["4","$","\xBC","\xA4"],Digit5:["5","%","\xBD","\u215C"],Digit6:["6","&","\xAC","\u215D"],Digit7:["7","/","{","\u215E"],Digit8:["8","(","[","\u2122"],Digit9:["9",")","]","\xB1"],Digit0:["0","=","}","\xB0"],Enter:["\r","\r","\r","\r"],Escape:["\x1B","\x1B","\x1B","\x1B"],Backspace:["\b","\b","\b","\b"],Tab:[" ",""," ",""],Space:[" "," "," "," "],Minus:["\xDF","?","\\","\xBF"],Equal:["\u0301","\u0300","\u0327","\u0328"],BracketLeft:["\xFC","\xDC","\u0308","\u030A"],BracketRight:["+","*","~","\xAF"],Backslash:["#","'","\u2019","\u0306"],Semicolon:["\xF6","\xD6","\u030B","\u0323"],Quote:["\xE4","\xC4","\u0302","\u030C"],Backquote:["\u0302","\xB0","\u2032","\u2033"],Comma:[",",";","\xB7","\xD7"],Period:[".",":","\u2026","\xF7"],Slash:["-","_","\u2013","\u2014"],PrintScreen:["","","",""],PageUp:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],Numpad1:["","1","","1"],Numpad2:["","2","","2"],Numpad3:["","3","","3"],Numpad4:["","4","","4"],Numpad5:["","5","","5"],Numpad6:["","6","","6"],Numpad7:["","7","","7"],Numpad8:["","8","","8"],Numpad9:["","9","","9"],Numpad0:["","0","","0"],NumpadDecimal:["",",","",","],IntlBackslash:["<",">","|","\u0331"],AltRight:["\r","\r","\r","\r"],MetaRight:[".",".",".","."]}},n0={id:"apple.spanish",locale:"es",displayName:"Spanish ISO",platform:"apple",virtualLayout:"qwerty",score:0,mapping:{KeyA:["a","A","\xE5","\xC5"],KeyB:["b","B","\xDF",""],KeyC:["c","C","\xA9"," "],KeyD:["d","D","\u2202","\u2206"],KeyE:["e","E","\u20AC","\u20AC"],KeyF:["f","F","\u0192","\uFB01"],KeyG:["g","G","\uF8FF","\uFB02"],KeyH:["h","H","\u2122"," "],KeyI:["i","I"," "," "],KeyJ:["j","J","\xB6","\xAF"],KeyK:["k","K","\xA7","\u02C7"],KeyL:["l","L"," ","\u02D8"],KeyM:["m","M","\xB5","\u02DA"],KeyN:["n","N"," ","\u02D9"],KeyO:["o","O","\xF8","\xD8"],KeyP:["p","P","\u03C0","\u220F"],KeyQ:["q","Q","\u0153","\u0152"],KeyR:["r","R","\xAE"," "],KeyS:["s","S","\u222B"," "],KeyT:["t","T","\u2020","\u2021"],KeyU:["u","U"," "," "],KeyV:["v","V","\u221A","\u25CA"],KeyW:["w","W","\xE6","\xC6"],KeyX:["x","X","\u2211","\u203A"],KeyY:["y","Y","\xA5"," "],KeyZ:["z","Z","\u03A9","\u2039"],Digit1:["1","!","|","\u0131"],Digit2:["2",'"',"@","\u02DD"],Digit3:["3","\xB7","#","\u2022"],Digit4:["4","$","\xA2","\xA3"],Digit5:["5","%","\u221E","\u2030"],Digit6:["6","&","\xAC"," "],Digit7:["7","/","\xF7","\u2044"],Digit8:["8","(","\u201C","\u2018"],Digit9:["9",")","\u201D","\u2019"],Digit0:["0","=","\u2260","\u2248"],Space:[" "," "," "," "],Minus:["'","?","\xB4","\xB8"],Equal:["\xA1","\xBF","\u201A","\u02DB"],BracketLeft:["`","^","[","\u02C6"],BracketRight:["+","*","]","\xB1"],Backslash:["\xE7","\xC7","}","\xBB"],Semicolon:["\xF1","\xD1","~","\u02DC"],Quote:["\xB4","\xA8","{","\xAB"],Backquote:["<",">","\u2264","\u2265"],Comma:[",",";","\u201E",""],Period:[".",":","\u2026","\u2026"],Slash:["-","_","\u2013","\u2014"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],Numpad1:["1","1","1","1"],Numpad2:["2","2","2","2"],Numpad3:["3","3","3","3"],Numpad4:["4","4","4","4"],Numpad5:["5","5","5","5"],Numpad6:["6","6","6","6"],Numpad7:["7","7","7","7"],Numpad8:["8","8","8","8"],Numpad9:["9","9","9","9"],Numpad0:["0","0","0","0"],NumpadDecimal:[",",",",",",","],IntlBackslash:["\xBA","\xAA","\\","\xB0"]}},r0={id:"windows.spanish",locale:"es",displayName:"Spanish",platform:"windows",virtualLayout:"qwerty",score:0,mapping:{KeyA:["a","A","",""],KeyB:["b","B","",""],KeyC:["c","C","",""],KeyD:["d","D","",""],KeyE:["e","E","\u20AC",""],KeyF:["f","F","",""],KeyG:["g","G","",""],KeyH:["h","H","",""],KeyI:["i","I","",""],KeyJ:["j","J","",""],KeyK:["k","K","",""],KeyL:["l","L","",""],KeyM:["m","M","",""],KeyN:["n","N","",""],KeyO:["o","O","",""],KeyP:["p","P","",""],KeyQ:["q","Q","",""],KeyR:["r","R","",""],KeyS:["s","S","",""],KeyT:["t","T","",""],KeyU:["u","U","",""],KeyV:["v","V","",""],KeyW:["w","W","",""],KeyX:["x","X","",""],KeyY:["y","Y","",""],KeyZ:["z","Z","",""],Digit1:["1","!","|",""],Digit2:["2",'"',"@",""],Digit3:["3","\xB7","#",""],Digit4:["4","$","~",""],Digit5:["5","%","\u20AC",""],Digit6:["6","&","\xAC",""],Digit7:["7","/","",""],Digit8:["8","(","",""],Digit9:["9",")","",""],Digit0:["0","=","",""],Space:[" "," ","",""],Minus:["'","?","",""],Equal:["\xA1","\xBF","",""],BracketLeft:["`","^","[",""],BracketRight:["+","*","]",""],Backslash:["\xE7","\xC7","}",""],Semicolon:["\xF1","\xD1","",""],Quote:["\xB4","\xA8","{",""],Backquote:["\xBA","\xAA","\\",""],Comma:[",",";","",""],Period:[".",":","",""],Slash:["-","_","",""],NumpadDivide:["/","/","",""],NumpadMultiply:["*","*","",""],NumpadSubtract:["-","-","",""],NumpadAdd:["+","+","",""],IntlBackslash:["<",">","",""]}},s0={id:"linux.spanish",locale:"es",displayName:"Spanish",platform:"linux",virtualLayout:"qwerty",score:0,mapping:{KeyA:["a","A","\xE6","\xC6"],KeyB:["b","B","\u201D","\u2019"],KeyC:["c","C","\xA2","\xA9"],KeyD:["d","D","\xF0","\xD0"],KeyE:["e","E","\u20AC","\xA2"],KeyF:["f","F","\u0111","\xAA"],KeyG:["g","G","\u014B","\u014A"],KeyH:["h","H","\u0127","\u0126"],KeyI:["i","I","\u2192","\u0131"],KeyJ:["j","J","\u0309","\u031B"],KeyK:["k","K","\u0138","&"],KeyL:["l","L","\u0142","\u0141"],KeyM:["m","M","\xB5","\xBA"],KeyN:["n","N","n","N"],KeyO:["o","O","\xF8","\xD8"],KeyP:["p","P","\xFE","\xDE"],KeyQ:["q","Q","@","\u03A9"],KeyR:["r","R","\xB6","\xAE"],KeyS:["s","S","\xDF","\xA7"],KeyT:["t","T","\u0167","\u0166"],KeyU:["u","U","\u2193","\u2191"],KeyV:["v","V","\u201C","\u2018"],KeyW:["w","W","\u0142","\u0141"],KeyX:["x","X","\xBB",">"],KeyY:["y","Y","\u2190","\xA5"],KeyZ:["z","Z","\xAB","<"],Digit1:["1","!","|","\xA1"],Digit2:["2",'"',"@","\u215B"],Digit3:["3","\xB7","#","\xA3"],Digit4:["4","$","~","$"],Digit5:["5","%","\xBD","\u215C"],Digit6:["6","&","\xAC","\u215D"],Digit7:["7","/","{","\u215E"],Digit8:["8","(","[","\u2122"],Digit9:["9",")","]","\xB1"],Digit0:["0","=","}","\xB0"],Enter:["\r","\r","\r","\r"],Escape:["\x1B","\x1B","\x1B","\x1B"],Backspace:["\b","\b","\b","\b"],Tab:[" ",""," ",""],Space:[" "," "," "," "],Minus:["'","?","\\","\xBF"],Equal:["\xA1","\xBF","\u0303","~"],BracketLeft:["\u0300","\u0302","[","\u030A"],BracketRight:["+","*","]","\u0304"],Backslash:["\xE7","\xC7","}","\u0306"],Semicolon:["\xF1","\xD1","~","\u030B"],Quote:["\u0301","\u0308","{","{"],Backquote:["\xBA","\xAA","\\","\\"],Comma:[",",";","\u2500","\xD7"],Period:[".",":","\xB7","\xF7"],Slash:["-","_","\u0323","\u0307"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],NumpadEnter:["\r","\r","\r","\r"],Numpad1:["","1","","1"],Numpad2:["","2","","2"],Numpad3:["","3","","3"],Numpad4:["","4","","4"],Numpad5:["","5","","5"],Numpad6:["","6","","6"],Numpad7:["","7","","7"],Numpad8:["","8","","8"],Numpad9:["","9","","9"],Numpad0:["","0","","0"],NumpadDecimal:["",".","","."],IntlBackslash:["<",">","|","\xA6"],NumpadEqual:["=","=","=","="],NumpadComma:[".",".",".","."],NumpadParenLeft:["(","(","(","("],NumpadParenRight:[")",")",")",")"]}};function eh(e){const i=e.split("+"),r={shift:!1,alt:!1,cmd:!1,win:!1,meta:!1,ctrl:!1,key:i.pop()};return i.includes("shift")&&(r.shift=!0),i.includes("alt")&&(r.alt=!0),i.includes("ctrl")&&(r.ctrl=!0),i.includes("cmd")&&(r.cmd=!0),i.includes("win")&&(r.win=!0),i.includes("meta")&&(r.meta=!0),r}function go(e){let i="";return e.shift&&(i+="shift+"),e.alt&&(i+="alt+"),e.ctrl&&(i+="ctrl+"),e.cmd&&(i+="cmd+"),e.win&&(i+="win+"),e.meta&&(i+="meta+"),i+e.key}var If={enter:"[Enter]",escape:"[Escape]",backspace:"[Backspace]",tab:"[Tab]",space:"[Space]",pausebreak:"[Pause]",insert:"[Insert]",home:"[Home]",pageup:"[PageUp]",delete:"[Delete]",end:"[End]",pagedown:"[PageDown]",right:"[ArrowRight]",left:"[ArrowLeft]",down:"[ArrowDown]",up:"[ArrowUp]",numpad0:"[Numpad0]",numpad1:"[Numpad1]",numpad2:"[Numpad2]",numpad3:"[Numpad3]",numpad4:"[Numpad4]",numpad5:"[Numpad5]",numpad6:"[Numpad6]",numpad7:"[Numpad7]",numpad8:"[Numpad8]",numpad9:"[Numpad9]",numpad_divide:"[NumpadDivide]",numpad_multiply:"[NumpadMultiply]",numpad_subtract:"[NumpadSubtract]",numpad_add:"[NumpadAdd]",numpad_decimal:"[NumpadDecimal]",numpad_separator:"[NumpadComma]",capslock:"[Capslock]",f1:"[F1]",f2:"[F2]",f3:"[F3]",f4:"[F4]",f5:"[F5]",f6:"[F6]",f7:"[F7]",f8:"[F8]",f9:"[F9]",f10:"[F10]",f11:"[F11]",f12:"[F12]",f13:"[F13]",f14:"[F14]",f15:"[F15]",f16:"[F16]",f17:"[F17]",f18:"[F18]",f19:"[F19]"},Il=[],Pl;function th(){switch(H()){case"macos":case"ios":return"apple";case"windows":return"windows"}return"linux"}function Ss(e){(!e.platform||e.platform===th())&&Il.push(e)}function a0(e,i){var r;const a={shift:!1,alt:!1,cmd:!1,win:!1,meta:!1,ctrl:!1,key:""};if(!e)return a;for(const[u,p]of Object.entries(i.mapping)){if(p[0]===e)return a.key=`[${u}]`,a;if(p[1]===e)return a.shift=!0,a.key=`[${u}]`,a;if(p[2]===e)return a.alt=!0,a.key=`[${u}]`,a;if(p[3]===e)return a.shift=!0,a.alt=!0,a.key=`[${u}]`,a}return a.key=(r=If[e])!=null?r:"",a}function ih(e){if(e.code)return e;const i=Object.entries(Ol().mapping);let r=!1,a=!1,u="";for(let p=0;p<4;p++){for(const[g,b]of i)if(b[p]===e.key){u=g,p===3?(r=!0,a=!0):p===2?r=!0:p===1&&(a=!0);break}if(u)break}return new KeyboardEvent(e.type,d(P({},e),{altKey:r,shiftKey:a,code:u}))}function Pf(e){var i,r;if(!e||e.key==="Unidentified"||e.key==="Dead")return;const a=e.shiftKey&&e.altKey?3:e.altKey?2:e.shiftKey?1:0;for(const u of Il)((i=u.mapping[e.code])==null?void 0:i[a])===e.key?u.score+=1:(r=u.mapping[e.code])!=null&&r[a]&&(u.score=0);Il.sort((u,p)=>p.score-u.score)}function nh(e){Pl=Il.find(i=>e.startsWith(i.locale))}function Ol(){return Pl!=null?Pl:Il[0]}function Oa(){switch(th()){case"apple":return Yc;case"windows":return Mf;case"linux":return Xc}return Yc}switch(th()){case"apple":Ss(Yc),Ss(Rf),Ss(n0),Ss(Jc);break;case"windows":Ss(Mf),Ss(Hu),Ss(r0),Ss(Qc);break;case"linux":Ss(Xc),Ss(i0),Ss(s0),Ss(Wu);break}Ss(t0);function h(e){var i;const r=/macos|ios/.test(H()),a=e.split("+");let u="";for(const p of a)u&&(u+=r?"\u2009":'<span class="ML__shortcut-join">+</span>'),p.startsWith("[Key")?u+=p.slice(4,5):p.startsWith("Key")?u+=p.slice(3,4):p.startsWith("[Digit")?u+=p.slice(6,7):p.startsWith("Digit")?u+=p.slice(5,6):u+=(i={cmd:"\u2318",meta:r?"\u2318":"Ctrl",shift:r?"\u21E7":"Shift",alt:r?"\u2325":"Alt",ctrl:r?"\u2303":"Ctrl","\n":r?"\u23CE":"Return","[return]":r?"\u23CE":"Return","[enter]":r?"\u2324":"Enter","[tab]":r?"\u21E5":"Tab","[escape]":"Esc","[backspace]":r?"\u232B":"Backspace","[delete]":r?"\u2326":"Del","[pageup]":r?"\u21DE":"Page Up","[pagedown]":r?"\u21DF":"Page Down","[home]":r?"\u2912":"Home","[end]":r?"\u2913":"End","[space]":"Space","[equal]":"=","[minus]":"-","[comma]":",","[slash]":"/","[backslash]":"\\","[bracketleft]":"[","[bracketright]":"]",semicolon:";",period:".",comma:",",minus:"-",equal:"=",quote:"'",backslash:"\\",intlbackslash:"\\",backquote:"`",slash:"/",numpadmultiply:"* &#128290;",numpaddivide:"/ &#128290;",numpadsubtract:"- &#128290;",numpadadd:"+ &#128290;",numpaddecimal:". &#128290;",numpadcomma:", &#128290;",help:"help",left:"\u21E0",up:"\u21E1",right:"\u21E2",down:"\u21E3","[arrowleft]":"\u21E0","[arrowup]":"\u21E1","[arrowright]":"\u21E2","[arrowdown]":"\u21E3"}[p.toLowerCase()])!=null?i:p.toUpperCase();return u}function t(e){if(e instanceof MouseEvent||e instanceof PointerEvent)return{x:e.clientX,y:e.clientY};if(e instanceof TouchEvent){const i=[...e.touches].reduce((a,u)=>({x:a.x+u.clientX,y:a.y+u.clientY}),{x:0,y:0}),r=e.touches.length;return{x:i.x/r,y:i.y/r}}}function n(e){const i={alt:!1,control:!1,shift:!1,meta:!1};return(e instanceof MouseEvent||e instanceof PointerEvent||e instanceof TouchEvent||e instanceof KeyboardEvent)&&(e.altKey&&(i.alt=!0),e.ctrlKey&&(i.control=!0),e.metaKey&&(i.meta=!0),e.shiftKey&&(i.shift=!0)),i}function s(e,i){return!e&&i||e&&!i?!1:!e||!i?!0:e.alt===i.alt&&e.control===i.control&&e.shift===i.shift&&e.meta===i.meta}var o=new Set(["Backquote","Digit0","Digit1","Digit2","Digit3","Digit4","Digit5","Digit6","Digit7","Digit8","Digit9","Minus","Equal","IntlYen","KeyQ","KeyW","KeyE","KeyR","KeyT","KeyY","KeyU","KeyI","KeyO","KeyP","BracketLeft","BracketRight","Backslash","KeyA","KeyS","KeyD","KeyF","KeyG","KeyH","KeyJ","KeyK","KeyL","Semicolon","Quote","IntlBackslash","KeyZ","KeyX","KeyC","KeyV","KeyB","KeyN","KeyM","Comma","Period","Slash","IntlRo","Space","Numpad0","Numpad1","Numpad2","Numpad3","Numpad4","Numpad5","Numpad6","Numpad7","Numpad8","Numpad9","NumpadAdd","NumpadComma","NumpadDecimal","NumpadDivide","NumpadEqual","NumpadHash","NumpadMultiply","NumpadParenLeft","NumpadParenRight","NumpadStar","NumpadSubstract"]);function l(e){return e.ctrlKey||e.metaKey||["Dead","Process"].includes(e.key)?!1:e.code===""?!0:o.has(e.code)}function c(){var e;let i=document.activeElement;for(;(e=i==null?void 0:i.shadowRoot)!=null&&e.activeElement;)i=i.shadowRoot.activeElement;return i}var f=class So{static get scrim(){return So._scrim||(So._scrim=new So),So._scrim}static open(i){So.scrim.open(i)}static close(){So.scrim.close()}static get state(){return So.scrim.state}static get element(){return So.scrim.element}constructor(i){var r,a;this.lightDismiss=(r=i==null?void 0:i.lightDismiss)!=null?r:!0,this.translucent=(a=i==null?void 0:i.translucent)!=null?a:!1,this.state="closed"}get element(){if(this._element)return this._element;const i=document.createElement("div");return i.setAttribute("role","presentation"),i.style.position="fixed",i.style.contain="content",i.style.top="0",i.style.left="0",i.style.right="0",i.style.bottom="0",i.style.zIndex="var(--scrim-zindex, 10099)",i.style.outline="none",this.translucent?(i.style.background="rgba(255, 255, 255, .2)",i.style.backdropFilter="contrast(40%)"):i.style.background="transparent",this._element=i,i}open(i){var r;if(this.state!=="closed")return;this.state="opening",this.onDismiss=i==null?void 0:i.onDismiss,this.savedActiveElement=c();const{element:a}=this;((r=i==null?void 0:i.root)!=null?r:document.body).appendChild(a),a.addEventListener("click",this),document.addEventListener("touchmove",this,!1),document.addEventListener("scroll",this,!1);const u=window.innerWidth-document.documentElement.clientWidth;this.savedMarginRight=document.body.style.marginRight,this.savedOverflow=document.body.style.overflow,document.body.style.overflow="hidden";const p=Number.parseFloat(getComputedStyle(document.body).marginRight);document.body.style.marginRight=`${p+u}px`,i!=null&&i.child&&a.append(i.child),this.state="open"}close(){var i,r,a,u;if(this.state!=="open"){console.assert(this.element.parentElement!==null);return}this.state="closing",typeof this.onDismiss=="function"&&this.onDismiss(),this.onDismiss=void 0;const{element:p}=this;p.removeEventListener("click",this),document.removeEventListener("touchmove",this,!1),document.removeEventListener("scroll",this,!1),p.remove(),document.body.style.overflow=(i=this.savedOverflow)!=null?i:"",document.body.style.marginRight=(r=this.savedMarginRight)!=null?r:"",c()!==this.savedActiveElement&&((u=(a=this.savedActiveElement)==null?void 0:a.focus)==null||u.call(a)),p.innerHTML="",this.state="closed"}handleEvent(i){this.lightDismiss&&(i.target===this._element&&i.type==="click"?(this.close(),i.preventDefault(),i.stopPropagation()):i.target===document&&(i.type==="touchmove"||i.type==="scroll")&&(this.close(),i.preventDefault(),i.stopPropagation()))}};function _(e,i,r){let a=null,u=null,p=!1,g=!1,b=!1;const w=new AbortController,E=w.signal;return e.addEventListener("keydown",R=>{if(p||R.key==="Process"||R.code==="CapsLock"||/(Control|Meta|Alt|Shift)(Left|Right)/.test(R.code)){a=null;return}a=R,u=null,r.onKeystroke(R)?e.textContent="":a=null},{capture:!0,signal:E}),e.addEventListener("keypress",R=>{p||(a&&u&&r.onKeystroke(a),u=R)},{capture:!0,signal:E}),e.addEventListener("compositionstart",R=>{e.textContent="",p=!0,r.onCompositionStart(R.data)},{capture:!0,signal:E}),e.addEventListener("compositionupdate",R=>{p&&r.onCompositionUpdate(R.data)},{capture:!0,signal:E}),e.addEventListener("compositionend",R=>{e.textContent="",p&&(p=!1,r.onCompositionEnd(R.data))},{capture:!0,signal:E}),e.addEventListener("beforeinput",R=>R.stopImmediatePropagation(),{signal:E}),e.addEventListener("input",R=>{var N;if(!p&&(e.textContent="",R.inputType!=="insertCompositionText")){if(R.inputType==="insertFromPaste"){R.preventDefault(),R.stopPropagation();return}r.onInput((N=R.data)!=null?N:""),R.preventDefault(),R.stopPropagation()}},{signal:E}),e.addEventListener("paste",R=>{e.focus({preventScroll:!0}),e.textContent="",r.onPaste(R)||R.preventDefault(),R.stopImmediatePropagation()},{signal:E}),e.addEventListener("cut",R=>r.onCut(R),{capture:!0,signal:E}),e.addEventListener("copy",R=>r.onCopy(R),{capture:!0,signal:E}),e.addEventListener("blur",R=>{var N,Z;if(((Z=(N=R.relatedTarget)==null?void 0:N._mathfield)==null?void 0:Z.element)===i){e.focus({preventScroll:!0}),R.preventDefault(),R.stopPropagation();return}const ue=f.state;if(ue==="open"||ue==="opening"){R.preventDefault(),R.stopPropagation();return}if(R.relatedTarget===R.target.getRootNode().host){R.preventDefault(),R.stopPropagation();return}b||g||(b=!0,a=null,u=null,r.onBlur(),b=!1)},{capture:!0,signal:E}),e.addEventListener("focus",R=>{b||g||(g=!0,r.onFocus(),g=!1)},{capture:!0,signal:E}),{dispose:()=>w.abort(),cancelComposition:()=>{p&&(e.blur(),requestAnimationFrame(()=>e.focus({preventScroll:!0})))},blur:()=>{typeof e.blur=="function"&&e.blur()},focus:()=>{!g&&typeof e.focus=="function"&&e.focus({preventScroll:!0})},hasFocus:()=>c()===e,setAriaLabel:R=>e.setAttribute("aria-label",R),setValue:R=>{var N;e.textContent=R,e.style.left="-1000px",(N=window.getSelection())==null||N.selectAllChildren(e)},moveTo:(R,N)=>{e.style.top=`${N}px`,e.style.left=`${R}px`}}}function m(e){var i;if(!e||!l(e))return"";let r;return e.key==="Unidentified"&&e.target&&(r=e.target.value),r=(i=r!=null?r:e.key)!=null?i:e.code,/^(Dead|Return|Enter|Tab|Escape|Delete|PageUp|PageDown|Home|End|Help|ArrowLeft|ArrowRight|ArrowUp|ArrowDown)$/.test(r)&&(r=""),r}function v(e){e=ih(e);const i=[];return e.ctrlKey&&i.push("ctrl"),e.metaKey&&i.push("meta"),e.altKey&&i.push("alt"),e.shiftKey&&i.push("shift"),i.length===0?`[${e.code}]`:(i.push(`[${e.code}]`),i.join("+"))}function y(e){if(M()){const i=H(),r=e.startsWith("!"),a=e.endsWith(i);if(r&&!a||!r&&a)return!0}return e==="!other"?!1:e==="other"}function x(e,i,r){if(e.length===0)return"";const a=go(eh(v(r))),u=go({key:r.key,shift:r.shiftKey,alt:r.altKey,ctrl:r.ctrlKey,meta:r.metaKey||r.ctrlKey&&/macos|ios/.test(H()),cmd:!1,win:!1});for(let p=e.length-1;p>=0;p--)if((e[p].key===a||e[p].key===u)&&(!e[p].ifMode||e[p].ifMode===i))return e[p].command;return""}function D(e){let i=e;return k(i)&&(i=i.length>0?i[0]+"("+i.slice(1).join("")+")":""),i}function C(e,i){let r=[];if(typeof i=="string"){const p=Td[i];k(p)?r=p.slice():p&&r.push(p)}const a=D(i),u=new RegExp("^"+a.replace("\\","\\\\").replace("|","\\|").replace("*","\\*").replace("$","\\$").replace("^","\\^")+"([^*a-zA-Z]|$)");for(const p of e)u.test(D(p.command))&&r.push(p.key);return r.map(h)}function B(e,i){if(e.ifPlatform&&!/^!?(macos|windows|android|ios|chromeos|other)$/.test(e.ifPlatform))throw new Error(`Unexpected platform "${e.ifPlatform}" for keybinding ${e.key}`);if(e.ifLayout!==void 0&&(i.score===0||!e.ifLayout.includes(i.id)))return;const r=eh(e.key);let a=e.ifPlatform;if(r.cmd){if(a&&a!=="macos"&&a!=="ios")throw new Error('Unexpected "cmd" modifier with platform "'+a+`"
"cmd" modifier can only be used with macOS or iOS platform.`);a||(a=H()==="ios"?"ios":"macos"),r.win=!1,r.cmd=!1,r.meta=!0}if(r.win){if(a&&a!=="windows")throw new Error('Unexpected "win" modifier with platform "'+a+`"
"win" modifier can only be used with Windows platform.`);a="windows",r.win=!1,r.cmd=!1,r.meta=!0}if(a&&!y(a))return;if(/^\[.+\]$/.test(r.key))return d(P({},e),{key:go(r)});const u=a0(r.key,i);if(!u)return d(P({},e),{key:go(r)});if(u.shift&&r.shift||u.alt&&r.alt)throw new Error(`The keybinding ${e.key} (${F(e.command)}) is conflicting with the key combination ${go(u)} using the ${i.displayName} keyboard layout`);return u.shift=u.shift||r.shift,u.alt=u.alt||r.alt,u.meta=r.meta,u.ctrl=r.ctrl,d(P({},e),{key:go(u)})}function F(e){if(Array.isArray(e)){const i=[...e];return i.shift()+"("+i.map(r=>typeof r=="string"?`"${r}"`:r.toString()).join(", ")+")"}return e}function Q(e,i){const r=[],a=[];for(const u of e)try{const p=B(u,i);if(!p)continue;const g=a.find(b=>b.key===p.key&&b.ifMode===p.ifMode);if(g)throw new Error(`Ambiguous key binding ${u.key} (${F(u.command)}) matches ${g.key} (${F(g.command)}) with the ${i.displayName} keyboard layout`);a.push(p)}catch(p){p instanceof Error&&r.push(p.message)}return[a,r]}var se=class extends qn{constructor(){super("latex")}createAtom(e){return new Lr(e)}onPaste(e,i){if(!i)return!1;const r=typeof i=="string"?i:i.getData("application/x-latex")||i.getData("text/plain");return r&&e.model.contentWillChange({inputType:"insertFromPaste",data:r})?(e.stopCoalescingUndo(),e.stopRecording(),this.insert(e.model,r)&&(e.startRecording(),e.snapshot("paste"),e.model.contentDidChange({inputType:"insertFromPaste"}),wn(e)),e.startRecording(),!0):!1}insert(e,i,r){if(!e.contentWillChange({data:i,inputType:"insertText"}))return!1;r||(r={}),r.insertionMode||(r.insertionMode="replaceSelection"),r.selectionMode||(r.selectionMode="placeholder");const{silenceNotifications:a}=e;r.silenceNotifications&&(e.silenceNotifications=!0);const u=e.silenceNotifications;e.silenceNotifications=!0,r.insertionMode==="replaceSelection"&&!e.selectionIsCollapsed?e.deleteAtoms(Fr(e.selection)):r.insertionMode==="replaceAll"?(e.root.setChildren([],"body"),e.position=0):r.insertionMode==="insertBefore"?e.collapseSelection("backward"):r.insertionMode==="insertAfter"&&e.collapseSelection("forward");const p=[];for(const w of i)Ge.test(w)&&p.push(new Lr(w));let g=e.at(e.position);if(g instanceof Cl&&(g=g.lastChild),!(g.parent instanceof Cl)){const w=new Cl("");g.parent.addChildAfter(w,g),g=w.firstChild}const b=g.parent.addChildrenAfter(p,g);return e.silenceNotifications=u,r.selectionMode==="before"||(r.selectionMode==="item"?e.setSelection(e.anchor,e.offsetOf(b)):b&&(e.position=e.offsetOf(b))),e.contentDidChange({data:i,inputType:"insertText"}),e.silenceNotifications=a,!0}};function le(e){return e.atoms.find(i=>i.type==="latexgroup")}function Ee(e){var i,r;const a=e.atoms.find(u=>u.type==="latexgroup");return a?(r=(i=a.body)==null?void 0:i.filter(u=>u.type==="latex"))!=null?r:[]:[]}function Ie(e,i){var r;let a=0,u=!1;const p=Number.isFinite(i==null?void 0:i.before)?(r=i==null?void 0:i.before)!=null?r:0:e.lastOffset;for(;a<=p&&!u;){const w=e.at(a);u=w instanceof Lr&&w.isSuggestion,u||a++}if(!u)return[void 0,void 0];let g=a,b=!1;for(;g<=p&&!b;){const w=e.at(g);b=!(w instanceof Lr&&w.isSuggestion),b||g++}return[a-1,g-1]}new se;function Qe(e){const i=Ee(e.model).filter(r=>r.isSuggestion);if(i.length!==0){e.model.position=e.model.offsetOf(i[0].leftSibling);for(const r of i)r.parent.removeChild(r)}}function Pe(e,i){var r;const{model:a}=e;Qe(e);for(const R of Ee(a))R.isError=!1;if(!a.selectionIsCollapsed||e.options.popoverPolicy==="off"){Vt(e);return}const u=[];let p=a.at(a.position);for(;p&&p instanceof Lr&&/^[a-zA-Z\*]$/.test(p.value);)p=p.leftSibling;if(p&&p instanceof Lr&&p.value==="\\")for(u.push(p),p=p.rightSibling;p&&p instanceof Lr&&/^[a-zA-Z\*]$/.test(p.value);)u.push(p),p=p.rightSibling;const g=u.map(R=>R.value).join(""),b=$e(e,g);if(b.length===0){if(/^\\[a-zA-Z\*]+$/.test(g))for(const R of u)R.isError=!0;Vt(e);return}const w=(r=i==null?void 0:i.atIndex)!=null?r:0;e.suggestionIndex=w<0?b.length-1:w%b.length;const E=b[e.suggestionIndex];if(E!==g){const R=u[u.length-1];R.parent.addChildrenAfter([...E.slice(g.length-E.length)].map(N=>new Lr(N,{isSuggestion:!0})),R),pa(e,{interactive:!0})}ci(e,b)}function Ze(e){const[i,r]=Ie(e,{before:e.position});if(i===void 0||r===void 0)return!1;let a=!1;return e.getAtoms([i,r]).forEach(u=>{u.isSuggestion&&(u.isSuggestion=!1,a=!0)}),a}function He(e,i="accept",r){var a,u;Vt(e);const p=le(e.model);if(!p)return!1;if(i==="accept-suggestion"||i==="accept-all"){const E=Ee(e.model).filter(R=>R.isSuggestion);if(E.length!==0){for(const R of E)R.isSuggestion=!1;e.model.position=e.model.offsetOf(E[E.length-1])}if(i==="accept-suggestion")return E.length!==0}const b=Ee(e.model).filter(E=>!E.isSuggestion).map(E=>E.value).join(""),w=p.leftSibling;return p.parent.removeChild(p),e.model.position=e.model.offsetOf(w),e.switchMode((a=r==null?void 0:r.mode)!=null?a:"math"),i==="reject"||(qn.insert(e.model,b,{selectionMode:(u=r==null?void 0:r.selectItem)!=null&&u?"item":"placeholder",format:"latex",mode:"math"}),e.snapshot(),e.model.announce("replacement"),e.switchMode("math")),!0}function Fe(e){var i;let r=document.getElementById(e);return r?r.dataset.refcount=Number(Number.parseInt((i=r.dataset.refcount)!=null?i:"0")+1).toString():(r=document.createElement("div"),r.setAttribute("aria-hidden","true"),r.dataset.refcount="1",r.id=e,document.body.append(r)),r}function bt(e){var i;const r=document.getElementById(e);if(!r)return;const a=Number.parseInt((i=r.getAttribute("data-refcount"))!=null?i:"0");a<=1?r.remove():r.dataset.refcount=Number(a-1).toString()}function Xt(e,i){const r=new Si({from:e.context}),a=new et({mode:"math",type:"root",body:zr(i,{context:r})}),u=yl(Ho(new Tt(a.render(r),{classes:"ML__base"}),r));return bu(u,{classes:"ML__latex"}).toMarkup()}function ci(e,i){var r;if(i.length===0){Vt(e);return}let a="";for(const[p,g]of i.entries()){const b=g,w=Xt(e,g),E=C(e.keybindings,b).join("<br>");a+=`<li role="button" data-command="${b}" ${p===e.suggestionIndex?"class=ML__popover__current":""}><span class="ML__popover__latex">${b}</span><span class="ML__popover__command">${w}</span>`,E&&(a+=`<span class="ML__popover__keybinding">${E}</span>`),a+="</li>"}const u=bi(e,`<ul>${a}</ul>`);yi()&&((r=u.querySelector(".ML__popover__current"))==null||r.scrollIntoView({block:"nearest",inline:"nearest"})),setTimeout(()=>{var p;u&&!yi()&&(u.classList.add("is-visible"),li(e),(p=u.querySelector(".ML__popover__current"))==null||p.scrollIntoView({block:"nearest",inline:"nearest"}))},32)}function yi(){const e=document.getElementById("mathlive-suggestion-popover");return e?e.classList.contains("is-visible"):!1}function li(e,i){var r;if(!e.element||e.element.mathfield!==e||!yi())return;if(((r=e.model.at(e.model.position))==null?void 0:r.type)!=="latex"){Vt(e);return}if(i!=null&&i.deferred){setTimeout(()=>li(e),32);return}const a=El(e.field);if(!a)return;const u=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,p=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,g=window.innerWidth-document.documentElement.clientWidth,b=window.innerHeight-document.documentElement.clientHeight,w=window.mathVirtualKeyboard.boundingRect.height,E=document.getElementById("mathlive-suggestion-popover");a.x+E.offsetWidth/2>p-g?E.style.left=`${p-E.offsetWidth-g}px`:a.x-E.offsetWidth/2<0?E.style.left="0":E.style.left=`${a.x-E.offsetWidth/2}px`;const R=a.y-a.height;u-b-w-a.y<R?(E.classList.add("ML__popover--reverse-direction"),E.classList.remove("top-tip"),E.classList.add("bottom-tip"),E.style.top=`${a.y-a.height-E.offsetHeight-15}px`):(E.classList.remove("ML__popover--reverse-direction"),E.classList.add("top-tip"),E.classList.remove("bottom-tip"),E.style.top=`${a.y+15}px`)}function Vt(e){e.suggestionIndex=0;const i=document.getElementById("mathlive-suggestion-popover");i&&(i.classList.remove("is-visible"),i.innerHTML="")}function bi(e,i){let r=document.getElementById("mathlive-suggestion-popover");return r||(r=Fe("mathlive-suggestion-popover"),ca("suggestion-popover"),ca("core"),r.addEventListener("pointerdown",a=>a.preventDefault()),r.addEventListener("click",a=>{let u=a.target;for(;u&&!u.dataset.command;)u=u.parentElement;u&&(He(e,"reject"),qn.insert(e.model,u.dataset.command,{selectionMode:"placeholder",format:"latex",mode:"math"}),e.dirty=!0,e.focus())})),r.innerHTML=window.MathfieldElement.createHTML(i),r}function si(){document.getElementById("mathlive-suggestion-popover")&&(bt("mathlive-suggestion-popover"),Da("suggestion-popover"),Da("core"))}function xi(){const e=String(new Error().stack).replace(/^Error.*\n/,"").split(`
`);if(e.length===0)return console.error(`Can't use relative paths to specify assets location because the sourcefile location could not be determined (unexpected stack trace format "${new Error().stack}").`),"";let i=e[1],r=i.match(/http.*\.ts[\?:]/);return r&&(i=e[2]),r=i.match(/(https?:.*):[0-9]+:[0-9]+/),r||(r=i.match(/at (.*(\.ts))[\?:]/),r||(r=i.match(/at (.*(\.mjs|\.js))[\?:]/))),r?r[1]:(console.error(e),console.error(`Can't use relative paths to specify assets location because the source file location could not be determined (unexpected location "${i}").`),"")}var Pi=null,qt,Zt,qi=((Zt=(qt=globalThis==null?void 0:globalThis.document)==null?void 0:qt.currentScript)==null?void 0:Zt.src)||xi();function In(e){return el(this,null,function*(){if(/^(?:[a-z+]+:)?\/\//i.test(e))return new URL(e).href;if(Pi===null)try{const i=yield fetch(qi,{method:"HEAD"});i.status===200&&(Pi=i.url)}catch(i){console.error(`Invalid URL "${e}" (relative to "${qi}")`)}return new URL(e,Pi!=null?Pi:qi).href})}function an(e,i,r={}){return new FontFace(e,`url(${i}.woff2) format('woff2')`,r)}var Vi="not-loaded";function ts(){return el(this,null,function*(){return Vi="not-loaded",Dr()})}function Dr(){return el(this,null,function*(){var e;if(Vi!=="not-loaded")return;if(Vi="loading",(e=getComputedStyle(document.documentElement).getPropertyValue("--ML__static-fonts"))!=null?e:!1){Vi="ready";return}if(document.body.classList.remove("ML__fonts-did-not-load"),"fonts"in document){const r=["KaTeX_Main","KaTeX_Math","KaTeX_AMS","KaTeX_Caligraphic","KaTeX_Fraktur","KaTeX_SansSerif","KaTeX_Script","KaTeX_Typewriter","KaTeX_Size1","KaTeX_Size2","KaTeX_Size3","KaTeX_Size4"],a=Array.from(document.fonts).map(g=>g.family);if(r.every(g=>a.includes(g))){Vi="ready";return}if(!window.MathfieldElement.fontsDirectory){Vi="not-loaded";return}const u=yield In(window.MathfieldElement.fontsDirectory);if(!u){document.body.classList.add("ML__fonts-did-not-load"),Vi="error";return}const p=[["KaTeX_Main-Regular"],["KaTeX_Main-BoldItalic",{style:"italic",weight:"bold"}],["KaTeX_Main-Bold",{weight:"bold"}],["KaTeX_Main-Italic",{style:"italic"}],["KaTeX_Math-Italic",{style:"italic"}],["KaTeX_Math-BoldItalic",{style:"italic",weight:"bold"}],["KaTeX_AMS-Regular"],["KaTeX_Caligraphic-Regular"],["KaTeX_Caligraphic-Bold",{weight:"bold"}],["KaTeX_Fraktur-Regular"],["KaTeX_Fraktur-Bold",{weight:"bold"}],["KaTeX_SansSerif-Regular"],["KaTeX_SansSerif-Bold",{weight:"bold"}],["KaTeX_SansSerif-Italic",{style:"italic"}],["KaTeX_Script-Regular"],["KaTeX_Typewriter-Regular"],["KaTeX_Size1-Regular"],["KaTeX_Size2-Regular"],["KaTeX_Size3-Regular"],["KaTeX_Size4-Regular"]].map(g=>an(g[0].replace(/-[a-zA-Z]+$/,""),`${u}/${g[0]}`,g[1]));try{(yield Promise.all(p.map(b=>{try{return b.load()}catch(w){}}))).forEach(b=>document.fonts.add(b)),Vi="ready";return}catch(g){console.error(`MathLive 0.98.5: The math fonts could not be loaded from "${u}"`,{cause:g}),document.body.classList.add("ML__fonts-did-not-load")}Vi="error"}})}function Is(e){let i=0;for(let r=0;r<e.length;r++)i=i*31+e.charCodeAt(r),i=i|0;return Math.abs(i)}function wn(e,i){e&&(e.dirty||(e.dirty=!0,requestAnimationFrame(()=>{oo(e)&&e.dirty&&(e.atomBoundsCache=new Map,pa(e,i),e.atomBoundsCache=void 0)})))}function _o(e,i){var r;i=i!=null?i:{};const a=new Si({from:d(P({},e.context),{atomIdsSettings:{seed:i.forHighlighting?Is(et.serialize([e.model.root],{expandMacro:!1,defaultMode:e.options.defaultMode})):"random",groupNumbers:(r=i.forHighlighting)!=null?r:!1},letterShapeStyle:e.options.letterShapeStyle}),mathstyle:e.options.defaultMode==="inline-math"?"textstyle":"displaystyle"}),u=e.model.root.render(a);return bu(Ho(u,a),{classes:e.hasEditablePrompts?"ML__latex ML__prompting":"ML__latex",attributes:{translate:"no","aria-hidden":"true"}})}function Of(e,i){const{model:r}=e;r.root.caret=void 0,r.root.isSelected=!1,r.root.containsCaret=!0;for(const u of r.atoms)u.caret=void 0,u.isSelected=!1,u.containsCaret=!1;if(r.selectionIsCollapsed){const u=r.at(r.position);u.caret=e.model.mode;let p=u.parent;for(;p;)p.containsCaret=!0,p=p.parent}else{const u=r.getAtoms(r.selection,{includeChildren:!0});for(const p of u)p.isSelected=!0}return _o(e,i).toMarkup()}function pa(e,i){if(!oo(e))return;i!=null||(i={});const r=e.element.querySelector("[part=virtual-keyboard-toggle]");r&&(r.style.display=e.hasEditableContent?"":"none");const a=e.field;if(!a)return;const u=e.isSelectionEditable&&e.hasFocus(),p=a.classList.contains("ML__focused");p&&!u?a.classList.remove("ML__focused"):!p&&u&&a.classList.add("ML__focused");let g=Of(e,i);const b=e.element.querySelector("[part=menu-toggle]");if(b&&(e.model.atoms.length<=1||e.disabled||e.readOnly&&!e.hasEditableContent||e.userSelect==="none"?b.style.display="none":b.style.display=""),e.model.atoms.length<=1){const w=e.options.contentPlaceholder;w&&(g+=`<span part=placeholder class="ML__content-placeholder">${Vr(w)}</span>`)}a.innerHTML=window.MathfieldElement.createHTML(g),Wo(e,i.interactive),e.dirty=!1}function Wo(e,i){const r=e.field;if(!r)return;for(const b of r.querySelectorAll(".ML__selection, .ML__contains-highlight"))b.remove();!(i!=null&&i)&&Vi!=="error"&&Vi!=="ready"&&setTimeout(()=>{Vi==="ready"?Wo(e):setTimeout(()=>Wo(e),128)},32);const a=e.model,u=r.offsetWidth,p=r.getBoundingClientRect().width;let g=Math.floor(p)/u;if(g=isNaN(g)?1:g,a.selectionIsCollapsed){li(e,{deferred:!0});let b=a.at(a.position);for(;b&&b.type!=="prompt"&&!(b.containsCaret&&b.displayContainsHighlight);)b=b.parent;if(b!=null&&b.containsCaret&&b.displayContainsHighlight){const w=hf(e,kl(e,b),g);if(w){w.left/=g,w.right/=g,w.top/=g,w.bottom/=g;const E=document.createElement("div");E.classList.add("ML__contains-highlight"),E.style.position="absolute",E.style.left=`${w.left+1}px`,E.style.top=`${Math.ceil(w.top)}px`,E.style.width=`${Math.ceil(w.right-w.left)}px`,E.style.height=`${Math.ceil(w.bottom-w.top)}px`,r.insertBefore(E,r.childNodes[0])}}return}for(const b of $0(Kc(e,{excludeAtomsWithBackground:!0}))){b.left/=g,b.right/=g,b.top/=g,b.bottom/=g;const w=document.createElement("div");w.classList.add("ML__selection"),w.style.position="absolute",w.style.left=`${b.left}px`,w.style.top=`${b.top}px`,w.style.width=`${Math.ceil(b.right-b.left)}px`,w.style.height=`${Math.ceil(b.bottom-b.top-1)}px`,r.insertBefore(w,r.childNodes[0])}}function $0(e){let i=[];for(const r of e){let a=!1;for(const u of i)if(r.left===u.left&&r.right===u.right&&r.top===u.top&&r.bottom===u.bottom){a=!0;break}a||i.push(r)}e=i,i=[];for(const r of e){let a=0;for(const u of e)if(r.left>=u.left&&r.right<=u.right&&r.top>=u.top&&r.bottom<=u.bottom&&(a+=1,a>1))break;a===1&&i.push(r)}return i}var An=3,lr;function ur(e,i){i=P({target:"mathfield",canUndo:!1,audioFeedback:void 0,changeContent:!1,changeSelection:!1},i!=null?i:{}),lr||(lr={});for(const r of Object.keys(e))console.assert(!lr[r],"Selector already defined: ",r),lr[r]=d(P({},i),{fn:e[r]})}function ma(e){let i;if(Array.isArray(e)){if(e[0]==="performWithFeedback")return ma(e[1]);i=e[0]}else i=e;return i=i.replace(/-\w/g,r=>r[1].toUpperCase()),lr[i]}function is(e){var i;return(i=ma(e))==null?void 0:i.target}function jo(e,i){var r;if(!i)return!1;let a,u=[],p=!1,g=!1;k(i)?(a=i[0],u=i.slice(1)):a=i,a=a.replace(/-\w/g,E=>E[1].toUpperCase());const b=lr[a],w=b==null?void 0:b.target;if(w==="model"){if(!e.isSelectionEditable&&(b!=null&&b.changeContent))return e.model.announce("plonk"),!1;/^(delete|add)/.test(a)&&(a!=="deleteBackward"&&e.flushInlineShortcutBuffer(),e.snapshot(a)),/^complete/.test(a)||Qe(e),lr[a].fn(e.model,...u),Pe(e),g=!0,p=!0}else if(w==="virtual-keyboard")g=(r=window.mathVirtualKeyboard.executeCommand(i))!=null?r:!1,p=!0;else if(lr[a]){if(!e.isSelectionEditable&&(b!=null&&b.changeContent))return e.model.announce("plonk"),!1;/^(undo|redo)/.test(a)&&e.flushInlineShortcutBuffer(),g=lr[a].fn(e,...u),p=!0}else throw new Error(`Unknown command "${a}"`);return w!=="virtual-keyboard"&&(!e.model.selectionIsCollapsed||b!=null&&b.changeSelection&&i!=="deleteBackward")&&(e.flushInlineShortcutBuffer(),b!=null&&b.changeContent||e.stopCoalescingUndo(),e.defaultStyle={}),g&&wn(e),p}function vo(e,i){var r;if(!e)return!1;e.focus(),Rp.keypressVibration&&Y()&&navigator.vibrate(An);const a=ma(i);window.MathfieldElement.playSound((r=a==null?void 0:a.audioFeedback)!=null?r:"keypress");const u=e.executeCommand(i);return e.scrollIntoView(),u}ur({performWithFeedback:(e,i)=>vo(e,i)});function Ff(e){return Pe(e,{atIndex:e.suggestionIndex+1}),!1}function ju(e){return Pe(e,{atIndex:e.suggestionIndex-1}),!1}ur({complete:He},{target:"mathfield",audioFeedback:"return",canUndo:!0,changeContent:!0,changeSelection:!0}),ur({nextSuggestion:Ff,previousSuggestion:ju},{target:"mathfield",audioFeedback:"keypress",changeSelection:!0});var Fl="mathlive#virtual-keyboard-message";function yo(e){var i;return e.type!=="message"?!1:((i=e.data)==null?void 0:i.type)===Fl}var Bf=class gm{constructor(){this.targetOrigin=window.origin,this.originValidator="none",this._boundingRect=new DOMRect(0,0,0,0),this._isShifted=!1,window.addEventListener("message",this),this.sendMessage("proxy-created"),this.listeners={}}static get singleton(){return this._singleton||(this._singleton=new gm),this._singleton}set alphabeticLayout(i){this.sendMessage("update-setting",{alphabeticLayout:i})}set layouts(i){this.sendMessage("update-setting",{layouts:i})}get normalizedLayouts(){return[]}set editToolbar(i){this.sendMessage("update-setting",{editToolbar:i})}set actionKeycap(i){this.sendMessage("update-setting",{actionKeycap:i})}set shiftKeycap(i){this.sendMessage("update-setting",{shiftKeycap:i})}set backspaceKeycap(i){this.sendMessage("update-setting",{backspaceKeycap:i})}set tabKeycap(i){this.sendMessage("update-setting",{tabKeycap:i})}set container(i){throw new Error("Container inside an iframe cannot be changed")}show(i){this.sendMessage("show",i)}hide(i){this.sendMessage("hide",i)}get isShifted(){return this._isShifted}get visible(){return this._boundingRect.height>0}set visible(i){i?this.show():this.hide()}get boundingRect(){return this._boundingRect}executeCommand(i){return this.sendMessage("execute-command",{command:i}),!0}updateToolbar(i){this.sendMessage("update-toolbar",i)}update(i){this.sendMessage("update-setting",i)}connect(){this.sendMessage("connect")}disconnect(){this.sendMessage("disconnect")}addEventListener(i,r,a){this.listeners[i]||(this.listeners[i]=new Set),this.listeners[i].has(r)||this.listeners[i].add(r)}dispatchEvent(i){return!this.listeners[i.type]||this.listeners[i.type].size===0?!0:(this.listeners[i.type].forEach(r=>{typeof r=="function"?r(i):r==null||r.handleEvent(i)}),!i.defaultPrevented)}removeEventListener(i,r,a){this.listeners[i]&&this.listeners[i].delete(r)}handleEvent(i){if(yo(i)){if(!Du(i.origin,this.originValidator))throw new DOMException(`Message from unknown origin (${i.origin}) cannot be handled`,"SecurityError");this.handleMessage(i.data)}}handleMessage(i){const{action:r}=i;if(r==="execute-command"){const{command:a}=i;is(a)==="virtual-keyboard"&&this.executeCommand(a);return}if(r==="synchronize-proxy"){this._boundingRect=i.boundingRect,this._isShifted=i.isShifted;return}if(r==="geometry-changed"){this._boundingRect=i.boundingRect,this.dispatchEvent(new Event("geometrychange"));return}}sendMessage(i,r={}){if(!window.top)throw new DOMException("A frame does not have access to the top window and can\u2018t communicate with the keyboard. Review virtualKeyboardTargetOrigin and originValidator on mathfields embedded in an iframe","SecurityError");window.top.postMessage(P({type:Fl,action:i},r),this.targetOrigin)}},Nf={numeric:{label:"123",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.numeric",rows:[[{latex:"x",shift:"y",variants:["y","z","t","r","x^2","x^n","x^{#?}","x_n","x_i","x_{#?}",{latex:"f(#?)",class:"small"},{latex:"g(#?)",class:"small"}]},{latex:"n",shift:"a",variants:["i","j","p","k","a","u"]},"[separator-5]","[7]","[8]","[9]","[/]","[separator-5]",{latex:"\\exponentialE",shift:"\\ln",variants:["\\exp","\\times 10^{#?}","\\ln","\\log_{10}","\\log"]},{latex:"\\imaginaryI",variants:["\\Re","\\Im","\\imaginaryJ","\\Vert #0 \\Vert"]},{latex:"\\pi",shift:"\\sin",variants:["\\prod",{latex:"\\theta",aside:"theta"},{latex:"\\rho",aside:"rho"},{latex:"\\tau",aside:"tau"},"\\sin","\\cos","\\tan"]}],[{label:"<",latex:"<",class:"hide-shift",shift:{latex:"\\le",label:"\u2264"}},{label:">",latex:">",class:"hide-shift",shift:{latex:"\\ge",label:"\u2265"}},"[separator-5]","[4]","[5]","[6]","[*]","[separator-5]",{class:"hide-shift",latex:"#@^2}",shift:"#@^{\\prime}}"},{latex:"#@^{#0}}",class:"hide-shift",shift:"#@_{#?}"},{class:"hide-shift",latex:"\\sqrt{#0}",shift:{latex:"\\sqrt[#0]{#?}}"}}],["[(]","[)]","[separator-5]","[1]","[2]","[3]","[-]","[separator-5]",{latex:"\\int^{\\infty}_{0}\\!#?\\,\\mathrm{d}x",class:"small hide-shift",shift:"\\int",variants:[{latex:"\\int_{#?}^{#?}",class:"small"},{latex:"\\int",class:"small"},{latex:"\\iint",class:"small"},{latex:"\\iiint",class:"small"},{latex:"\\oint",class:"small"},"\\mathrm{d}x",{latex:"\\dfrac{\\mathrm{d}}{\\mathrm{d} x}",class:"small"},{latex:"\\frac{\\partial}{\\partial x}",class:"small"},"\\partial"]},{class:"hide-shift",latex:"\\forall",shift:"\\exists"},{label:"[backspace]",width:1}],[{label:"[shift]",width:2},"[separator-5]","[0]","[.]","[=]","[+]","[separator-5]","[left]","[right]",{label:"[action]",width:1}]]},greek:{label:"&alpha;&beta;&gamma;",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.greek",rows:[[{label:"<i>&#x03c6;</i>",class:"MLK__tex hide-shift",insert:"\\varphi",aside:"phi var.",shift:"\\Phi"},{label:"<i>&#x03c2;</i>",class:"MLK__tex hide-shift",insert:"\\varsigma",aside:"sigma var.",shift:"\\Sigma"},{label:"<i>&#x03f5;</i>",class:"MLK__tex hide-shift",insert:"\\epsilon",aside:"espilon",shift:'\\char"0190'},{label:"<i>&rho;</i>",class:"MLK__tex hide-shift",insert:"\\rho",aside:"rho",shift:'\\char"3A1'},{label:"<i>&tau;</i>",class:"MLK__tex hide-shift",insert:"\\tau",aside:"tau",shift:'\\char"3A4'},{label:"<i>&upsilon;</i>",class:"MLK__tex hide-shift",insert:"\\upsilon",aside:"upsilon",shift:"\\Upsilon"},{label:"<i>&theta;</i>",class:"MLK__tex hide-shift",insert:"\\theta",aside:"theta",shift:"\\Theta"},{label:"<i>&iota;</i>",class:"MLK__tex hide-shift",insert:"\\iota",aside:"iota",shift:'\\char"399'},{label:"<i>&omicron;</i>",class:"MLK__tex hide-shift",insert:"\\omicron",aside:"omicron",shift:'\\char"39F'},{label:"<i>&pi;</i>",class:"MLK__tex hide-shift",insert:"\\pi",aside:"pi",shift:"\\Pi"}],["[separator-5]",{label:"<i>&alpha;</i>",class:"MLK__tex hide-shift",insert:"\\alpha",aside:"alpha",shift:'\\char"391'},{label:"<i>&sigma;</i>",class:"MLK__tex hide-shift",insert:"\\sigma",aside:"sigma",shift:"\\Sigma"},{label:"<i>&delta;</i>",class:"MLK__tex hide-shift",insert:"\\delta",aside:"delta",shift:"\\Delta"},{latex:"\\phi",class:"MLK__tex hide-shift",insert:"\\phi",aside:"phi",shift:"\\Phi"},{label:"<i>&gamma;</i>",class:"MLK__tex hide-shift",insert:"\\gamma",aside:"gamma",shift:"\\Gamma"},{label:"<i>&eta;</i>",class:"MLK__tex hide-shift",insert:"\\eta",aside:"eta",shift:'\\char"397'},{label:"<i>&xi;</i>",class:"MLK__tex hide-shift",insert:"\\xi",aside:"xi",shift:"\\Xi"},{label:"<i>&kappa;</i>",class:"MLK__tex hide-shift",insert:"\\kappa",aside:"kappa",shift:"\\Kappa"},{label:"<i>&lambda;</i>",class:"MLK__tex hide-shift",insert:"\\lambda",aside:"lambda",shift:"\\Lambda"},"[separator-5]"],["[shift]",{label:"<i>&zeta;</i>",class:"MLK__tex hide-shift",insert:"\\zeta",aside:"zeta",shift:'\\char"396'},{label:"<i>&chi;</i>",class:"MLK__tex hide-shift",insert:"\\chi",aside:"chi",shift:'\\char"3A7'},{label:"<i>&psi;</i>",class:"MLK__tex hide-shift",insert:"\\psi",aside:"zeta",shift:"\\Psi"},{label:"<i>&omega;</i>",class:"MLK__tex hide-shift",insert:"\\omega",aside:"omega",shift:"\\Omega"},{label:"<i>&beta;</i>",class:"MLK__tex hide-shift",insert:"\\beta",aside:"beta",shift:'\\char"392'},{label:"<i>&nu;</i>",class:"MLK__tex hide-shift",insert:"\\nu",aside:"nu",shift:'\\char"39D'},{label:"<i>&mu;</i>",class:"MLK__tex hide-shift",insert:"\\mu",aside:"mu",shift:'\\char"39C'},"[backspace]"],["[separator]",{label:"<i>&#x03b5;</i>",class:"MLK__tex",insert:"\\varepsilon",aside:"espilon var."},{label:"<i>&#x03d1;</i>",class:"MLK__tex",insert:"\\vartheta",aside:"theta var."},{label:"<i>&#x3f0;</i>",class:"MLK__tex",insert:"\\varkappa",aside:"kappa var."},{label:"<i>&#x03d6;</i>",class:"MLK__tex",insert:"\\varpi",aside:"pi var."},{label:"<i>&#x03f1;</i>",class:"MLK__tex",insert:"\\varrho",aside:"rho var."},"[left]","[right]","[action]"]]},symbols:{label:"&infin;\u2260\u2208",labelClass:"MLK__tex",tooltip:"keyboard.tooltip.symbols",rows:[[{latex:"\\sin",shift:"\\sin^{-1}",variants:[{class:"small",latex:"\\sinh"},{class:"small",latex:"\\sin^{-1}"},{class:"small",latex:"\\arsinh"}]},"\\ln",{latex:"\\mathrm{abs}",insert:"\\mathrm{abs}\\left(#0\\right)"},{latex:"\\rarr",shift:"\\rArr",variants:[{latex:"\\implies",aside:"implies"},{latex:"\\to",aside:"to"},"\\dashv",{latex:"\\roundimplies",aside:"round implies"}]},{latex:"\\exists",variants:["\\nexists"],shift:"\\nexists"},{latex:"\\in",shift:"\\notin",variants:["\\notin","\\owns"]},"\\cup",{latex:"\\overrightarrow{#@}",shift:"\\overleftarrow{#@}",variants:["\\overleftarrow{#@}","\\bar{#@}","\\vec{#@}","\\hat{#@}","\\check{#@}","\\dot{#@}","\\ddot{#@}","\\mathring{#@}","\\breve{#@}","\\acute{#@}","\\tilde{#@}","\\grave{#@}"]},{class:"small",latex:"\\lim_{#?}",shift:"\\lim_{x\\to\\infty}",variants:[{class:"small",latex:"\\liminf_{#?}"},{class:"small",latex:"\\limsup_{#?}"}]},"\\exponentialE"],[{latex:"\\cos",shift:"\\cos^{-1}",variants:[{class:"small",latex:"\\cosh"},{class:"small",latex:"\\cos^{-1}"},{class:"small",latex:"\\arcosh"}]},{latex:"\\log",shift:"\\log_{10}",variants:["\\log_{#0}","\\log_{10}"]},"\\left\\vert#0\\right\\vert",{latex:"\\larr",shift:"\\lArr",variants:[{latex:"\\impliedby",aside:"implied by"},{latex:"\\gets",aside:"gets"},"\\lArr","\\vdash",{latex:"\\models",aside:"models"}]},{latex:"\\forall",shift:"\\lnot",variants:[{latex:"\\land",aside:"and"},{latex:"\\lor",aside:"or"},{latex:"\\oplus",aside:"xor"},{latex:"\\lnot",aside:"not"},{latex:"\\downarrow",aside:"nor"},{latex:"\\uparrow",aside:"nand"},{latex:"\\curlywedge",aside:"nor"},{latex:"\\bar\\curlywedge",aside:"nand"}]},{latex:"\\ni",shift:"\\not\\owns"},"\\cap",{latex:"\\overline{#@}",shift:"\\underline{#@}",variants:["\\overbrace{#@}","\\overlinesegment{#@}","\\overleftrightarrow{#@}","\\overrightarrow{#@}","\\overleftarrow{#@}","\\overgroup{#@}","\\underbrace{#@}","\\underlinesegment{#@}","\\underleftrightarrow{#@}","\\underrightarrow{#@}","\\underleftarrow{#@}","\\undergroup{#@}"]},{class:"hide-shift",latex:"\\int",shift:"\\iint",variants:[{latex:"\\int_{#?}^{#?}",class:"small"},{latex:"\\int",class:"small"},{latex:"\\smallint",class:"small"},{latex:"\\iint",class:"small"},{latex:"\\iiint",class:"small"},{latex:"\\oint",class:"small"},"\\intop","\\iiint","\\oiint","\\oiiint","\\intclockwise","\\varointclockwise","\\ointctrclockwise","\\intctrclockwise"]},{latex:"\\pi",shift:"\\tau",variants:["\\tau"]}],[{latex:"\\tan",shift:"\\tan^{-1}",variants:[{class:"small",latex:"\\tanh"},{class:"small",latex:"\\tan^{-1}"},{class:"small",latex:"\\artanh"},{class:"small",latex:"\\arctan"},{class:"small",latex:"\\arctg"},{class:"small",latex:"\\tg"}]},{latex:"\\exp",insert:"\\exp\\left(#0\\right)",variants:["\\exponentialE^{#0}"]},"\\left\\Vert#0\\right\\Vert",{latex:"\\lrArr",shift:"\\leftrightarrow",variants:[{latex:"\\iff",aside:"if and only if"},"\\leftrightarrow","\\leftrightarrows","\\Leftrightarrow",{latex:"^\\biconditional",aside:"biconditional"}]},{latex:"\\vert",shift:"!"},{latex:"#@^{\\complement}",aside:"complement",variants:[{latex:"\\setminus",aside:"set minus"},{latex:"\\smallsetminus",aside:"small set minus"}]},{latex:"\\subset",shift:"\\subseteq",variants:["\\subset","\\subseteq","\\subsetneq","\\varsubsetneq","\\subsetneqq","\\nsubset","\\nsubseteq","\\supset","\\supseteq","\\supsetneq","\\supsetneqq","\\nsupset","\\nsupseteq"]},{latex:"#@^{\\prime}",shift:"#@^{\\doubleprime}",variants:["#@^{\\doubleprime}","#@\\degree"]},{latex:"\\mathrm{d}",shift:"\\partial",variants:["\\mathrm{d}x",{latex:"\\dfrac{\\mathrm{d}}{\\mathrm{d} x}",class:"small"},{latex:"\\frac{\\partial}{\\partial x}",class:"small"},"\\partial"]},{latex:"\\infty",variants:["\\aleph_0","\\aleph_1","\\omega","\\mathfrak{m}"]}],[{label:"[shift]",width:2},{class:"box",latex:",",shift:";",variants:[";","?"]},{class:"box",latex:"\\colon",shift:"\\Colon",variants:[{latex:"\\Colon",aside:"such that",class:"box"},{latex:":",aside:"ratio",class:"box"},{latex:"\\vdots",aside:"",class:"box"},{latex:"\\ddots",aside:"",class:"box"},{latex:"\\ldotp",aside:"low dot",class:"box"},{latex:"\\cdotp",aside:"center dot",class:"box"},{latex:"\\ldots",aside:"low ellipsis",class:"box"},{latex:"\\cdots",aside:"center ellipsis",class:"box"},{latex:"\\therefore",aside:"therefore",class:"box"},{latex:"\\because",aside:"because",class:"box"}]},{class:"box",latex:"\\cdot",aside:"centered dot",shift:"\\ast",variants:["\\circ","\\bigcirc","\\bullet","\\odot","\\oslash","\\circledcirc","\\ast","\\star","\\times","\\doteq","\\doteqdot"]},"[separator]","[left]","[right]",{label:"[backspace]",width:1,class:"action hide-shift"},{label:"[action]",width:1}]]},compact:{label:"compact",rows:[["[+]","[-]","[*]","[/]","[=]","[.]","[(]","[)]","\\sqrt{#0}","#@^{#?}"],["[1]","[2]","[3]","[4]","[5]","[6]","[7]","[8]","[9]","[0]"],["[hr]"],["[undo]","[redo]","[separator]","[separator]","[separator]","[left]","[right]",{label:"[backspace]",class:"action hide-shift"},"[hide-keyboard]"]]},minimalist:{label:"minimalist",layers:[{style:`
.minimalist-backdrop {
display: flex;
justify-content: center;
}
.minimalist-container {
--keycap-height: 40px;
--keycap-max-width: 53px;
--keycap-small-font-size: 12px;
background: var(--keyboard-background);
padding: 20px;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
border: 1px solid var(--keyboard-border);
box-shadow: 0 0 32px rgb(0 0 0 / 30%);
}
`,backdrop:"minimalist-backdrop",container:"minimalist-container",rows:[["+","-","\\times",{latex:"\\frac{#@}{#0}",class:"small"},"=","[.]","(",")",{latex:"\\sqrt{#0}",class:"small"},{latex:"#@^{#?}",class:"small"}],["1","2","3","4","5","6","7","8","9","0"],["[hr]"],["[undo]","[redo]","[separator]","[separator]","[separator]","[left]","[right]",{label:"[backspace]",class:"action hide-shift"},"[hide-keyboard]"]]}]},"numeric-only":{label:"123",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.numeric",id:"numeric-only",rows:[["7","8","9","[separator]",{label:"[backspace]",width:2}],["4","5","6","[separator]","[separator]","[separator]"],["1","2","3","[separator]","[separator]","[separator]"],["0",{label:"[.]",variants:[]},"-","[separator]","[left]","[right]"]]}},Bl={0:["\\varnothing","\\infty"],1:["\\frac{1}{#@}","#@^{-1}","\\times 10^{#?}","\\phi","\\imaginaryI"],2:["\\frac{1}{2}","#@^2","\\sqrt2","\\exponentialE"],3:["\\frac{1}{3}","#@^3","\\sqrt3","\\pi"],4:["\\frac{1}{4}","#@^4"],5:["\\frac{1}{5}","#@^5","\\sqrt5"],6:["\\frac{1}{6}","#@^6"],7:["\\frac{1}{7}","#@^7"],8:["\\frac{1}{8}","#@^8"],9:["\\frac{1}{9}","#@^9"],".":[".",",",";","\\colon"],",":["{,}",".",";","\\colon"],a:[{latex:"\\aleph",aside:"aleph"},{latex:"\\forall",aside:"for all"},"\xE0","\xE1","\xE2","\xE4","\xE6"],b:[{latex:"\\beth",aside:"beth"}],c:[{latex:"\\C",aside:"set of complex numbers"},"\xE7"],d:[{latex:"\\daleth",aside:"daleth"}],e:[{latex:"\\exponentialE",aside:"exponential e"},{latex:"\\exists",aside:"there is"},{latex:"\\nexists",aside:"there isn\u2019t"},"\xE8","\xE9","\xEA","\xEB"],g:[{latex:"\\gimel",aside:"gimel"}],h:[{latex:"\\hbar",aside:"h bar"},{latex:"\\hslash",aside:"h slash"}],i:[{latex:"\\imaginaryI",aside:"imaginary i"},"\xEC","\xED","\xEE","\xEF"],j:[{latex:"\\imaginaryJ",aside:"imaginary j"}],l:[{latex:"\\ell",aside:"ell"}],n:[{latex:"\\mathbb{N}",aside:"set of natural numbers"},"\xF1"],o:["\xF8","\u0153","\xF2","\xF3","\xF4","\xF6","\u0153"],p:[{latex:"\\mathbb{P}",aside:"set of primes"}],q:[{latex:"\\mathbb{Q}",aside:"set of rational numbers"}],r:[{latex:"\\mathbb{R}",aside:"set of real numbers"}],u:["\xF9","\xFA","\xFB","\xFC"],z:[{latex:"\\mathbb{Z}",aside:"set of integers"}],y:["\xFD","\xFF"],space:[{latex:'\\char"203A\\!\\char"2039',insert:"\\!",aside:"negative thin space<br>\u207B\xB3\u29F8\u2081\u2088 em"},{latex:'\\char"203A\\,\\char"2039',insert:"\\,",aside:"thin space<br>\xB3\u29F8\u2081\u2088 em"},{latex:'\\char"203A\\:\\char"2039',insert:"\\:",aside:"medium space<br>\u2074\u29F8\u2081\u2088 em"},{latex:'\\char"203A\\;\\char"2039',insert:"\\;",aside:"thick space<br>\u2075\u29F8\u2081\u2088 em"},{latex:'\\char"203A\\ \\char"2039',insert:"\\ ",aside:"\u2153 em"},{latex:'\\char"203A\\enspace\\char"2039',insert:"\\enspace",aside:"\xBD em"},{latex:'\\char"203A\\quad\\char"2039',insert:"\\quad",aside:"1 em"},{latex:'\\char"203A\\qquad\\char"2039',insert:"\\qquad",aside:"2 em"}]},qo;function Zo(e,i){var r,a,u;const p=Yo.singleton;if(!p)return;const g=qu(e),b=(a=(r=p.getKeycap(g==null?void 0:g.id))==null?void 0:r.variants)!=null?a:"";if(typeof b=="string"&&!K0(b)||Array.isArray(b)&&b.length===0){i==null||i();return}const w={};let E="";for(const Ve of xm(b)){const Ct=z0(Ve),Ue=Date.now().toString(36).slice(-2)+Math.floor(Math.random()*1e5).toString(36);w[Ue]=Ct;const[ct,It]=$f(Ct);E+=`<div id=${Ue} class="item ${It}">${ct}</div>`}const R=document.createElement("div");R.setAttribute("aria-hidden","true"),R.className="MLK__variant-panel",R.style.height="auto";const N=Object.keys(w).length;let Z=5;N===1?Z=1:N===2||N===4?Z=2:N===3||N===5||N===6?Z=3:N>=7&&N<14&&(Z=4),R.style.width=`calc(var(--variant-keycap-length) * ${Z} + 12px)`,R.innerHTML=Rp.createHTML(E),f.open({root:(u=p==null?void 0:p.container)==null?void 0:u.querySelector(".ML__keyboard"),child:R}),qo=new AbortController;const{signal:ue}=qo,me=e==null?void 0:e.getBoundingClientRect();if(me){me.top-R.clientHeight<0&&(R.style.width="auto",N<=6?R.style.height="56px":N<=12?R.style.height="108px":N<=18?R.style.height="205px":R.classList.add("compact"));const Ve=Math.max(0,Math.min(window.innerWidth-R.offsetWidth,(me.left+me.right-R.offsetWidth)/2)),Ct=me.top-R.clientHeight+5;R.style.transform=`translate(${Ve}px, ${Ct}px)`,R.classList.add("is-visible"),requestAnimationFrame(()=>{R.addEventListener("pointerup",Ue=>{const ct=qu(Ue.target);!(ct!=null&&ct.id)||!w[ct.id]||(o0(w[ct.id]),rh(),i==null||i(),Ue.preventDefault())},{capture:!0,passive:!1,signal:ue}),R.addEventListener("pointerenter",Ue=>{const ct=qu(Ue.target);!(ct!=null&&ct.id)||!w[ct.id]||ct.classList.add("is-active")},{capture:!0,signal:ue}),R.addEventListener("pointerleave",Ue=>{const ct=qu(Ue.target);!(ct!=null&&ct.id)||!w[ct.id]||ct.classList.remove("is-active")},{capture:!0,signal:ue}),window.addEventListener("pointercancel",()=>{rh(),i==null||i()},{signal:ue}),window.addEventListener("pointerup",()=>{rh(),i==null||i()},{signal:ue})})}}function rh(){qo==null||qo.abort(),qo=null,f.state==="open"&&f.close()}function bm(e){if(e==="foreground-color"){const i=[];for(const r of Object.keys(re))i.push({class:"swatch-button",label:'<span style="border: 3px solid '+re[r]+'"></span>',command:["applyStyle",{color:r}]});return i}if(e==="background-color"){const i=[];for(const r of Object.keys(Se))i.push({class:"swatch-button",label:'<span style="background:'+Se[r]+'"></span>',command:["applyStyle",{backgroundColor:r}]});return i}}function K0(e){return Bl[e]!==void 0}function xm(e){var i;return typeof e!="string"?e:(Bl[e]||(Bl[e]=(i=bm(e))!=null?i:[]),Bl[e])}function wm(e){return typeof e=="string"?e:Object.entries(e).map(([i,r])=>`${i}:${r} !important`).join(";")}function Sm(e){return Object.keys(e).map(i=>`${i} {${wm(e[i])}}`).join("")}function sh(e){if(!e)return"";const i=new Si,r=new et({mode:"math",type:"root",body:zr(e,{context:i,args:u=>u==="@"?"{\\class{ML__box-placeholder}{\\blacksquare}}":"\\placeholder{}"})}),a=yl(Ho(new Tt(r.render(i),{classes:"ML__base"}),i));return bu(a,{classes:"ML__latex"}).toMarkup()}function ah(e){var i;if(Array.isArray(e))return e.map(a=>ah(a)).flat();const r=typeof e=="string"?{markup:e}:e;return"rows"in r&&Array.isArray(r.rows)&&(r.rows=r.rows.map(a=>a.map(u=>z0(u)))),(i=r.id)!=null||(r.id="ML__layer_"+Date.now().toString(36).slice(-2)+Math.floor(Math.random()*1e5).toString(36)),[r]}function Em(){var e,i;let a=window.mathVirtualKeyboard.alphabeticLayout;if(a==="auto"){const b=Ol();b&&(a=b.virtualLayout),(!a||a==="auto")&&(a=(e={fr:"azerty",be:"azerty",al:"qwertz",ba:"qwertz",cz:"qwertz",de:"qwertz",hu:"qwertz",sk:"qwertz",ch:"qwertz"}[$.locale.slice(0,2)])!=null?e:"qwerty")}const u={qwerty:["qwertyuiop"," asdfghjkl ","^zxcvbnm~"],azerty:["azertyuiop","qsdfghjklm","^ wxcvbn ~"],qwertz:["qwertzuiop"," asdfghjkl ","^yxcvbnm~"],dvorak:["^ pyfgcrl ","aoeuidhtns","qjkxbmwvz~"],colemak:[" qwfpgjluy ","arstdhneio","^zxcvbkm~"]},p=(i=u[a])!=null?i:u.qwerty,g=a==="azerty"?[[{label:"1",variants:"1"},{label:"2",shift:{latex:"\xE9"},variants:"2"},{label:"3",shift:{latex:"\xF9"},variants:"3"},{label:"4",variants:"4"},{label:"5",shift:{label:"(",latex:"("},variants:"5"},{label:"6",shift:{label:")",latex:")"},variants:"6"},{label:"7",shift:{latex:"\xE8"},variants:"7"},{label:"8",shift:{latex:"\xEA"},variants:"8"},{label:"9",shift:{latex:"\xE7"},variants:"9"},{label:"0",shift:{latex:"\xE0"},variants:"0"}]]:[[{label:"1",variants:"1"},{label:"2",variants:"2"},{label:"3",variants:"3"},{label:"4",variants:"4"},{label:"5",shift:{latex:"\\frac{#@}{#?}"},variants:"5"},{label:"6",shift:{latex:"#@^#?"},variants:"6"},{label:"7",variants:"7"},{label:"8",shift:{latex:"\\times"},variants:"8"},{label:"9",shift:{label:"(",latex:"("},variants:"9"},{label:"0",shift:{label:")",latex:")"},variants:"0"}]];for(const b of p){const w=[];for(const E of b)/[a-z]/.test(E)?w.push({label:E,class:"hide-shift",shift:{label:E.toUpperCase()},variants:K0(E)?E:void 0}):E==="~"?a!=="dvorak"?w.push("[backspace]"):w.push({label:"[backspace]",width:1}):E==="^"?w.push("[shift]"):E===" "&&w.push("[separator-5]");g.push(w)}return g.push(["[-]","[+]","[=]",{label:" ",width:1.5},{label:",",shift:";",variants:".",class:"hide-shift"},"[.]","[left]","[right]",{label:"[action]",width:1.5}]),{label:"abc",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.alphabetic",layers:ah({rows:g})}}function U0(e){if(e==="alphabetic")return Em();if(typeof e=="string")return console.assert(Nf[e]!==void 0,`MathLive 0.98.5: unknown keyboard layout "${e}"`),U0(Nf[e]);let i;if("rows"in e&&Array.isArray(e.rows)){console.assert(!("layers"in e||"markup"in e),'MathLive 0.98.5: when providing a "rows" property, "layers" and "markup" are ignored');const u=e,{rows:p}=u,g=I(u,["rows"]);i=d(P({},g),{layers:ah({rows:e.rows})})}else if("markup"in e&&typeof e.markup=="string"){const u=e,{markup:p}=u,g=I(u,["markup"]);i=d(P({},g),{layers:ah(e.markup)})}else i=P({},e),"layers"in e?i.layers=ah(e.layers):console.error('MathLive 0.98.5: provide either a "rows", "markup" or "layers" property');let r=!1,a=!1;for(const u of i.layers)if(u.rows)for(const p of u.rows.flat()){Zu(p)&&(r=!0);const g=p.command;typeof g=="string"&&["undo","redo","cut","copy","paste"].includes(g)&&(a=!0)}return(!("displayShiftedKeycaps"in e)||e.displayShiftedKeycaps===void 0)&&(i.displayShiftedKeycaps=r),(!("displayEditToolbar"in e)||e.displayEditToolbar===void 0)&&(i.displayEditToolbar=!a),i}function km(e,i){var r,a;let u='<div class="left">';if(e.normalizedLayouts.length>1)for(const[p,g]of e.normalizedLayouts.entries()){const b=g,w=[p===i?"selected":"layer-switch"];b.tooltip&&w.push("MLK__tooltip"),b.labelClass&&w.push(...b.labelClass.split(" ")),u+=`<div class="${w.join(" ")}"`,b.tooltip&&(u+=" data-tooltip='"+((r=G(b.tooltip))!=null?r:b.tooltip)+"' "),p!==i&&(u+=`data-layer="${b.layers[0].id}"`),u+=`>${(a=b.label)!=null?a:"untitled"}</div>`}return u+="</div>",u}function Tm(e,i){let r="";if(e.editToolbar==="none")return"";const u=[];i.selectionIsCollapsed?u.push("undo","redo","pasteFromClipboard"):u.push("cutToClipboard","copyToClipboard","pasteFromClipboard");const p={undo:`<div class='action ${i.canUndo===!1?"disabled":""}'
data-command='"undo"'
data-tooltip='${G("tooltip.undo")}'>
<svg><use xlink:href='#svg-undo' /></svg>
</div>`,redo:`<div class='action ${i.canRedo===!1?"disabled":""}'
data-command='"redo"'
data-tooltip='${G("tooltip.redo")}'>
<svg><use xlink:href='#svg-redo' /></svg>
</div>`,cutToClipboard:`
<div class='action'
data-command='"cutToClipboard"'
data-tooltip='${G("tooltip.cut to clipboard")}'>
<svg><use xlink:href='#svg-cut' /></svg>
</div>
`,copyToClipboard:`
<div class='action'
data-command='"copyToClipboard"'
data-tooltip='${G("tooltip.copy to clipboard")}'>
<svg><use xlink:href='#svg-copy' /></svg>
</div>
`,pasteFromClipboard:`
<div class='action'
data-command='"pasteFromClipboard"'
data-tooltip='${G("tooltip.paste from clipboard")}'>
<svg><use xlink:href='#svg-paste' /></svg>
</div>
`};return r+=u.map(g=>p[g]).join(""),r}function Am(e){for(const i of e)Lm(i)}function Lm(e){const i=Yo.singleton;if(!i)return;const r={};if(!e.id){if(e.hasAttribute("data-label")&&(r.label=e.dataset.label),e.hasAttribute("data-latex")&&(r.latex=e.dataset.latex),e.hasAttribute("data-key")&&(r.key=e.dataset.key),e.hasAttribute("data-insert")&&(r.insert=e.dataset.insert),e.hasAttribute("data-variants")&&(r.variants=e.dataset.variants),e.hasAttribute("data-aside")&&(r.aside=e.dataset.aside),e.className&&(r.class=e.className),!r.label&&!r.latex&&!r.key&&!r.insert&&(r.latex=e.innerText,r.label=e.innerHTML),e.hasAttribute("data-command"))try{r.command=JSON.parse(e.dataset.command)}catch(a){}e.id=i.registerKeycap(r)}if(!e.innerHTML){const[a,u]=$f(r);e.innerHTML=window.MathfieldElement.createHTML(a)}}function Dm(){ca("virtual-keyboard"),ca("core"),Dr()}function Cm(){Da("core"),Da("virtual-keyboard")}var Mm=`<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol id="svg-delete-backward" viewBox="0 0 576 512">
<path d="M432.1 208.1L385.9 256L432.1 303C442.3 312.4 442.3 327.6 432.1 336.1C423.6 346.3 408.4 346.3 399 336.1L352 289.9L304.1 336.1C295.6 346.3 280.4 346.3 271 336.1C261.7 327.6 261.7 312.4 271 303L318.1 256L271 208.1C261.7 199.6 261.7 184.4 271 175C280.4 165.7 295.6 165.7 304.1 175L352 222.1L399 175C408.4 165.7 423.6 165.7 432.1 175C442.3 184.4 442.3 199.6 432.1 208.1V208.1zM512 64C547.3 64 576 92.65 576 128V384C576 419.3 547.3 448 512 448H205.3C188.3 448 172 441.3 160 429.3L9.372 278.6C3.371 272.6 0 264.5 0 256C0 247.5 3.372 239.4 9.372 233.4L160 82.75C172 70.74 188.3 64 205.3 64L512 64zM528 128C528 119.2 520.8 112 512 112H205.3C201 112 196.9 113.7 193.9 116.7L54.63 256L193.9 395.3C196.9 398.3 201 400 205.3 400H512C520.8 400 528 392.8 528 384V128z"/>
</symbol>
<symbol id="svg-shift" viewBox="0 0 384 512">
<path d="M2.438 252.3C7.391 264.2 19.06 272 32 272h80v160c0 26.51 21.49 48 48 48h64C250.5 480 272 458.5 272 432v-160H352c12.94 0 24.61-7.797 29.56-19.75c4.953-11.97 2.219-25.72-6.938-34.88l-160-176C208.4 35.13 200.2 32 192 32S175.6 35.13 169.4 41.38l-160 176C.2188 226.5-2.516 240.3 2.438 252.3zM192 86.63L313.4 224H224v208H160V224H70.63L192 86.63z"/>
</symbol>
<symbol id="svg-commit" viewBox="0 0 512 512">
<path d="M135 432.1l-128-128C2.344 300.3 0 294.2 0 288s2.344-12.28 7.031-16.97l128-128c9.375-9.375 24.56-9.375 33.94 0s9.375 24.56 0 33.94L81.94 264H464v-208C464 42.75 474.8 32 488 32S512 42.75 512 56V288c0 13.25-10.75 24-24 24H81.94l87.03 87.03c9.375 9.375 9.375 24.56 0 33.94S144.4 442.3 135 432.1z"/>
</symbol>
<symbol id="circle-plus" viewBox="0 0 512 512"><path d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM232 344c0 13.3 10.7 24 24 24s24-10.7 24-24V280h64c13.3 0 24-10.7 24-24s-10.7-24-24-24H280V168c0-13.3-10.7-24-24-24s-24 10.7-24 24v64H168c-13.3 0-24 10.7-24 24s10.7 24 24 24h64v64z"/></symbol>
<symbol id="svg-command" viewBox="0 0 640 512">
<path d="M34.495 36.465l211.051 211.05c4.686 4.686 4.686 12.284 0 16.971L34.495 475.535c-4.686 4.686-12.284 4.686-16.97 0l-7.071-7.07c-4.686-4.686-4.686-12.284 0-16.971L205.947 256 10.454 60.506c-4.686-4.686-4.686-12.284 0-16.971l7.071-7.07c4.686-4.687 12.284-4.687 16.97 0zM640 468v-10c0-6.627-5.373-12-12-12H300c-6.627 0-12 5.373-12 12v10c0 6.627 5.373 12 12 12h328c6.627 0 12-5.373 12-12z"/>
</symbol>
<symbol id="svg-undo" viewBox="0 0 512 512">
<path d="M20 8h10c6.627 0 12 5.373 12 12v110.625C85.196 57.047 165.239 7.715 256.793 8.001 393.18 8.428 504.213 120.009 504 256.396 503.786 393.181 392.834 504 256 504c-63.926 0-122.202-24.187-166.178-63.908-5.113-4.618-5.354-12.561-.482-17.433l7.069-7.069c4.503-4.503 11.749-4.714 16.482-.454C150.782 449.238 200.935 470 256 470c117.744 0 214-95.331 214-214 0-117.744-95.331-214-214-214-82.862 0-154.737 47.077-190.289 116H180c6.627 0 12 5.373 12 12v10c0 6.627-5.373 12-12 12H20c-6.627 0-12-5.373-12-12V20c0-6.627 5.373-12 12-12z"/>
</symbol>
<symbol id="svg-redo" viewBox="0 0 512 512">
<path d="M492 8h-10c-6.627 0-12 5.373-12 12v110.625C426.804 57.047 346.761 7.715 255.207 8.001 118.82 8.428 7.787 120.009 8 256.396 8.214 393.181 119.166 504 256 504c63.926 0 122.202-24.187 166.178-63.908 5.113-4.618 5.354-12.561.482-17.433l-7.069-7.069c-4.503-4.503-11.749-4.714-16.482-.454C361.218 449.238 311.065 470 256 470c-117.744 0-214-95.331-214-214 0-117.744 95.331-214 214-214 82.862 0 154.737 47.077 190.289 116H332c-6.627 0-12 5.373-12 12v10c0 6.627 5.373 12 12 12h160c6.627 0 12-5.373 12-12V20c0-6.627-5.373-12-12-12z"/>
</symbol>
<symbol id="svg-arrow-left" viewBox="0 0 320 512">
<path d="M206.7 464.6l-183.1-191.1C18.22 267.1 16 261.1 16 256s2.219-11.97 6.688-16.59l183.1-191.1c9.152-9.594 24.34-9.906 33.9-.7187c9.625 9.125 9.938 24.37 .7187 33.91L73.24 256l168 175.4c9.219 9.5 8.906 24.78-.7187 33.91C231 474.5 215.8 474.2 206.7 464.6z"/>
</symbol>
<symbol id="svg-arrow-right" viewBox="0 0 320 512">
<path d="M113.3 47.41l183.1 191.1c4.469 4.625 6.688 10.62 6.688 16.59s-2.219 11.97-6.688 16.59l-183.1 191.1c-9.152 9.594-24.34 9.906-33.9 .7187c-9.625-9.125-9.938-24.38-.7187-33.91l168-175.4L78.71 80.6c-9.219-9.5-8.906-24.78 .7187-33.91C88.99 37.5 104.2 37.82 113.3 47.41z"/>
</symbol>
<symbol id="svg-tab" viewBox="0 0 448 512">
<path d="M32 217.1c0-8.8 7.2-16 16-16h144v-93.9c0-7.1 8.6-10.7 13.6-5.7l143.5 143.1c6.3 6.3 6.3 16.4 0 22.7L205.6 410.4c-5 5-13.6 1.5-13.6-5.7v-93.9H48c-8.8 0-16-7.2-16-16v-77.7m-32 0v77.7c0 26.5 21.5 48 48 48h112v61.9c0 35.5 43 53.5 68.2 28.3l143.6-143c18.8-18.8 18.8-49.2 0-68L228.2 78.9c-25.1-25.1-68.2-7.3-68.2 28.3v61.9H48c-26.5 0-48 21.6-48 48zM436 64h-8c-6.6 0-12 5.4-12 12v360c0 6.6 5.4 12 12 12h8c6.6 0 12-5.4 12-12V76c0-6.6-5.4-12-12-12z"/>
</symbol>
<symbol id="svg-paste" viewBox="0 0 512 512"><path d="M160 32c11.6 0 21.3 8.2 23.5 19.2C185 58.6 191.6 64 199.2 64H208c8.8 0 16 7.2 16 16V96H96V80c0-8.8 7.2-16 16-16h8.8c7.6 0 14.2-5.4 15.7-12.8C138.7 40.2 148.4 32 160 32zM64 64h2.7C65 69 64 74.4 64 80V96c0 17.7 14.3 32 32 32H224c17.7 0 32-14.3 32-32V80c0-5.6-1-11-2.7-16H256c17.7 0 32 14.3 32 32h32c0-35.3-28.7-64-64-64H210.6c-9-18.9-28.3-32-50.6-32s-41.6 13.1-50.6 32H64C28.7 32 0 60.7 0 96V384c0 35.3 28.7 64 64 64H192V416H64c-17.7 0-32-14.3-32-32V96c0-17.7 14.3-32 32-32zM288 480c-17.7 0-32-14.3-32-32V192c0-17.7 14.3-32 32-32h96v56c0 22.1 17.9 40 40 40h56V448c0 17.7-14.3 32-32 32H288zM416 165.3L474.7 224H424c-4.4 0-8-3.6-8-8V165.3zM448 512c35.3 0 64-28.7 64-64V235.9c0-12.7-5.1-24.9-14.1-33.9l-59.9-59.9c-9-9-21.2-14.1-33.9-14.1H288c-35.3 0-64 28.7-64 64V448c0 35.3 28.7 64 64 64H448z"/></symbol>
<symbol id="svg-cut" viewBox="0 0 512 512"><path d="M485.6 444.2L333.6 314.9C326.9 309.2 326.1 299.1 331.8 292.4C337.5 285.6 347.6 284.8 354.4 290.5L506.4 419.8C513.1 425.5 513.9 435.6 508.2 442.4C502.5 449.1 492.4 449.9 485.6 444.2zM485.7 67.76C492.5 62.07 502.5 62.94 508.2 69.69C513.9 76.45 513.1 86.55 506.3 92.24L208.5 343.1C218.3 359.7 224 379.2 224 400C224 461.9 173.9 512 112 512C50.14 512 0 461.9 0 400C0 338.1 50.14 288 112 288C141.5 288 168.4 299.4 188.4 318.1L262.2 256L188.4 193.9C168.4 212.6 141.5 224 112 224C50.14 224 0 173.9 0 112C0 50.14 50.14 0 112 0C173.9 0 224 50.14 224 112C224 132.8 218.3 152.3 208.5 168.9L287 235.1L485.7 67.76zM32 112C32 156.2 67.82 192 112 192C156.2 192 192 156.2 192 112C192 67.82 156.2 32 112 32C67.82 32 32 67.82 32 112zM112 480C156.2 480 192 444.2 192 400C192 355.8 156.2 320 112 320C67.82 320 32 355.8 32 400C32 444.2 67.82 480 112 480z"/></symbol>
<symbol id="svg-copy" viewBox="0 0 512 512"><path d="M272 416C263.2 416 256 423.2 256 432V448c0 17.67-14.33 32-32 32H64c-17.67 0-32-14.33-32-32V192c0-17.67 14.33-32 32-32h112C184.8 160 192 152.8 192 144C192 135.2 184.8 128 176 128H63.99c-35.35 0-64 28.65-64 64l.0098 256C0 483.3 28.65 512 64 512h160c35.35 0 64-28.65 64-64v-16C288 423.2 280.8 416 272 416zM502.6 86.63l-77.25-77.25C419.4 3.371 411.2 0 402.7 0H288C252.7 0 224 28.65 224 64v256c0 35.35 28.65 64 64 64h160c35.35 0 64-28.65 64-64V109.3C512 100.8 508.6 92.63 502.6 86.63zM416 45.25L466.7 96H416V45.25zM480 320c0 17.67-14.33 32-32 32h-160c-17.67 0-32-14.33-32-32V64c0-17.67 14.33-32 32-32h96l.0026 64c0 17.67 14.33 32 32 32H480V320z"/>
</symbol>
<symbol id="svg-angle-double-right" viewBox="0 0 512 512"><path d="M470.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L402.7 256 265.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160zm-352 160l160-160c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L210.7 256 73.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0z"/>
</symbol>
<symbol id="svg-angle-double-left" viewBox="0 0 512 512"><path d="M41.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 256 246.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160zm352-160l-160 160c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L301.3 256 438.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0z"/>
</symbol>
<symbol id="svg-trash" viewBox="0 0 448 512">
<path d="M336 64l-33.6-44.8C293.3 7.1 279.1 0 264 0h-80c-15.1 0-29.3 7.1-38.4 19.2L112 64H24C10.7 64 0 74.7 0 88v2c0 3.3 2.7 6 6 6h26v368c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V96h26c3.3 0 6-2.7 6-6v-2c0-13.3-10.7-24-24-24h-88zM184 32h80c5 0 9.8 2.4 12.8 6.4L296 64H152l19.2-25.6c3-4 7.8-6.4 12.8-6.4zm200 432c0 8.8-7.2 16-16 16H80c-8.8 0-16-7.2-16-16V96h320v368zm-176-44V156c0-6.6 5.4-12 12-12h8c6.6 0 12 5.4 12 12v264c0 6.6-5.4 12-12 12h-8c-6.6 0-12-5.4-12-12zm-80 0V156c0-6.6 5.4-12 12-12h8c6.6 0 12 5.4 12 12v264c0 6.6-5.4 12-12 12h-8c-6.6 0-12-5.4-12-12zm160 0V156c0-6.6 5.4-12 12-12h8c6.6 0 12 5.4 12 12v264c0 6.6-5.4 12-12 12h-8c-6.6 0-12-5.4-12-12z"/>
</symbol>
<symbol id="svg-keyboard-down" viewBox="0 0 576 512"><path d="M64 48c-8.8 0-16 7.2-16 16V240c0 8.8 7.2 16 16 16H512c8.8 0 16-7.2 16-16V64c0-8.8-7.2-16-16-16H64zM0 64C0 28.7 28.7 0 64 0H512c35.3 0 64 28.7 64 64V240c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V64zM159 359c9.4-9.4 24.6-9.4 33.9 0l95 95 95-95c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9L305 505c-4.5 4.5-10.6 7-17 7s-12.5-2.5-17-7L159 393c-9.4-9.4-9.4-24.6 0-33.9zm1-167c0-8.8 7.2-16 16-16H400c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V192zM120 88h16c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H120c-8.8 0-16-7.2-16-16V104c0-8.8 7.2-16 16-16zm64 16c0-8.8 7.2-16 16-16h16c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H200c-8.8 0-16-7.2-16-16V104zm96-16h16c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H280c-8.8 0-16-7.2-16-16V104c0-8.8 7.2-16 16-16zm64 16c0-8.8 7.2-16 16-16h16c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H360c-8.8 0-16-7.2-16-16V104zm96-16h16c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H440c-8.8 0-16-7.2-16-16V104c0-8.8 7.2-16 16-16z"/></symbol>
</svg>`;function Rm(e){e.resetKeycapRegistry(),Dm();const i=document.createElement("div");i.className="ML__keyboard";const r=document.createElement("div");r.className="MLK__plate",r.innerHTML=window.MathfieldElement.createHTML(Mm+e.normalizedLayouts.map((g,b)=>Im(e,g,b)).join(""));const a=document.createElement("div");a.className="MLK__backdrop",a.appendChild(r),i.appendChild(a),i.addEventListener("pointerdown",Om,{passive:!1});const u=i.querySelectorAll(".ML__edit-toolbar");if(u)for(const g of u)g.addEventListener("click",b=>{var w,E;let R=b.target,N="";for(;R&&!N;)N=(w=R==null?void 0:R.getAttribute("data-command"))!=null?w:"",R=(E=R==null?void 0:R.parentElement)!=null?E:null;N&&e.executeCommand(JSON.parse(N))});Am(i.querySelectorAll(".MLK__keycap, .action, .fnbutton, .bigfnbutton"));const p=i.querySelectorAll(".MLK__layer");console.assert(p.length>0,"No virtual keyboards available");for(const g of p)g.addEventListener("pointerdown",b=>b.preventDefault());return e.currentLayer=e.latentLayer,i}function Im(e,i,r){const a=[];if(!("layers"in i))return"";for(const u of i.layers)a.push(`<div tabindex="-1" class="MLK__layer" id="${u.id}">`),(e.normalizedLayouts.length>1||i.displayEditToolbar)&&(a.push("<div class='MLK__toolbar' role='toolbar'>"),a.push(km(e,r)),i.displayEditToolbar&&a.push('<div class="ML__edit-toolbar right"></div>'),a.push("</div>")),a.push(Pm(e,u)),a.push("</div>");return a.join("")}function Pm(e,i){if(typeof i=="string")return i;let r="";if(typeof i.style=="string"?r+=`<style>${i.style}</style>`:typeof i.style=="object"&&(r+=`<style>${Sm(i.style)}</style>`),i.backdrop&&(r+=`<div class='${i.backdrop}'>`),i.container&&(r+=`<div class='${i.container}'>`),i.rows){r+="<div class=MLK__rows>";for(const a of i.rows){r+="<div dir='ltr' class=MLK__row>";for(const u of a)if(u){const p=e.registerKeycap(u),[g,b]=$f(u);/(^|\s)separator/.test(b)?r+=`<div class="${b}"`:r+=`<div tabindex="-1" id="${p}" class="${b}"`,u.tooltip&&(r+=` data-tooltip="${u.tooltip}"`),r+=`>${g}</div>`}r+="</div>"}r+="</div>"}else i.markup&&(r+=i.markup);return i.container&&(r+="</div>"),i.backdrop&&(r+="</div>"),r}function $f(e,i={shifted:!1}){var r,a,u,p,g,b,w;let E="",R=(r=e.class)!=null?r:"";if(i.shifted&&Zu(e)&&(R+=" is-active"),i.shifted&&"shift"in e)typeof e.shift=="string"?E=sh(e.shift):typeof e.shift=="object"&&(E=e.shift.label?e.shift.label:(a=sh(e.shift.latex||e.shift.insert||"")||e.shift.key)!=null?a:""),typeof e.shift=="object"&&(R=(p=(u=e.shift.class)!=null?u:e.class)!=null?p:"");else{if(E=e.label?e.label:(g=sh(e.latex||e.insert||"")||e.key)!=null?g:"",e.shift){let N;typeof e.shift=="string"?N=sh(e.shift):e.shift.label?N=e.shift.label:N=(b=sh(e.shift.latex||e.shift.insert||"")||e.shift.key)!=null?b:"",E+=`<span class="MLK__shift">${N}</span>`}e.aside&&(E+=`<aside>${e.aside}</aside>`)}return e.layer&&!/layer-switch/.test(R)&&(R+=" layer-switch"),/(^|\s)(separator|action|shift|fnbutton|bigfnbutton)($|\s)/.test(R)||(R+=" MLK__keycap"),!/\bw[0-9]+\b/.test(R)&&e.width&&(R+=(w={0:" w0",.5:" w5",1.5:" w15",2:" w20",5:" w50"}[e.width])!=null?w:""),[E,R||"MLK__keycap"]}var Nl={"[left]":{class:"action hide-shift",label:"<svg class=svg-glyph><use xlink:href=#svg-arrow-left /></svg>",command:["performWithFeedback","moveToPreviousChar"],shift:{label:"<svg class=svg-glyph><use xlink:href=#svg-angle-double-left /></svg>",command:["performWithFeedback","extendSelectionBackward"]}},"[right]":{class:"action hide-shift",label:"<svg class=svg-glyph><use xlink:href=#svg-arrow-right /></svg>",command:["performWithFeedback","moveToNextChar"],shift:{label:"<svg class=svg-glyph><use xlink:href=#svg-angle-double-right /></svg>",command:["performWithFeedback","extendSelectionForward"]}},"[up]":{class:"action hide-shift",label:"\u2191",command:["performWithFeedback","moveUp"],shift:{label:"\u219F",command:["performWithFeedback","extendSelectionUpward"]}},"[down]":{class:"action hide-shift",label:"\u2193",command:["performWithFeedback","moveDown"],shift:{label:"\u21A1",command:["performWithFeedback","extendSelectionDownward"]}},"[return]":{class:"action hide-shift",command:["performWithFeedback","commit"],shift:{command:["performWithFeedback","addRowAfter"]},width:1.5,label:"<svg class=svg-glyph><use xlink:href=#svg-commit /></svg>"},"[action]":{class:"action hide-shift",command:["performWithFeedback","commit"],shift:{label:"<svg class=svg-glyph><use xlink:href=#circle-plus /></svg>",command:["performWithFeedback","addRowAfter"]},width:1.5,label:"<svg class=svg-glyph><use xlink:href=#svg-commit /></svg>"},"[hr]":{class:"separator horizontal-rule"},"[hide-keyboard]":{class:"action",command:["hideVirtualKeyboard"],width:1.5,label:"<svg class=svg-glyph-lg><use xlink:href=#svg-keyboard-down /></svg>"},"[.]":{variants:".",command:["performWithFeedback","insertDecimalSeparator"],shift:",",class:"big-op hide-shift",label:"."},"[,]":{variants:",",command:["performWithFeedback","insertDecimalSeparator"],shift:".",class:"big-op hide-shift",label:","},"[+]":{variants:[{latex:"\\sum_{#0}^{#0}",class:"small"},"\\oplus"],latex:"+",label:"+",class:"big-op hide-shift",shift:{latex:"\\sum",insert:"\\sum",class:"small"}},"[-]":{variants:["\\pm","\\ominus"],latex:"-",label:"&#x2212;",shift:"\\pm",class:"big-op hide-shift"},"[/]":{class:"big-op hide-shift",shift:{class:"",latex:"\\frac{1}{#@}"},variants:["/","\\div","\\%","\\oslash"],latex:"\\frac{#@}{#?}",label:"&divide;"},"[*]":{variants:[{latex:"\\prod_{#0}^{#0}",class:"small"},"\\otimes","\\cdot"],latex:"\\cdot",label:"&times;",shift:{latex:"\\times"},class:"big-op hide-shift"},"[=]":{variants:["\\neq","\\equiv","\\varpropto","\\thickapprox","\\lt","\\gt","\\le","\\ge"],latex:"=",label:"=",shift:{label:"\u2260",latex:"\\ne"},class:"big-op hide-shift"},"[backspace]":{class:"action bottom right hide-shift",width:1.5,command:["performWithFeedback","deleteBackward"],label:"<svg class=svg-glyph><use xlink:href=#svg-delete-backward /></svg>",shift:{class:"action warning",label:"<svg class=svg-glyph><use xlink:href=#svg-trash /></svg>",command:"deleteAll"}},"[undo]":{class:"ghost if-can-undo",command:"undo",label:"<svg class=svg-glyph><use xlink:href=#svg-undo /></svg>",tooltip:"tooltip.undo"},"[redo]":{class:"ghost if-can-redo",command:"redo",label:"<svg class=svg-glyph><use xlink:href=#svg-redo /></svg>",tooltip:"tooltip.redo"},"[(]":{variants:[{latex:"\\lbrack",key:"["},"\\langle","\\lfloor","\\lceil",{latex:"\\lbrace",key:"{"}],key:"(",label:"(",shift:{label:"[",key:"["},class:"hide-shift"},"[)]":{variants:[{latex:"\\rbrack",key:"]"},"\\rangle","\\rfloor","\\rceil",{latex:"\\rbrace",key:"]"}],key:")",label:")",shift:{label:"]",latex:"\\rbrack"},class:"hide-shift"},"[0]":{variants:"0",latex:"0",label:"0",shift:"\\infty",class:"hide-shift"},"[1]":{variants:"1",latex:"1",label:"1",shift:"#@^{-1}",class:"hide-shift"},"[2]":{variants:"2",latex:"2",label:"2",shift:"#@^2",class:"hide-shift"},"[3]":{variants:"3",latex:"3",label:"3",shift:"#@^3",class:"hide-shift"},"[4]":{variants:"4",latex:"4",label:"4",shift:"#@^4",class:"hide-shift"},"[5]":{variants:"5",latex:"5",label:"5",shift:"#@^5",class:"hide-shift"},"[6]":{variants:"6",latex:"6",label:"6",shift:"#@^6",class:"hide-shift"},"[7]":{variants:"7",latex:"7",label:"7",shift:"#@^7",class:"hide-shift"},"[8]":{variants:"8",latex:"8",label:"8",shift:"#@^8",class:"hide-shift"},"[9]":{variants:"9",latex:"9",label:"9",shift:"#@^9",class:"hide-shift"},"[separator-5]":{class:"separator",width:.5},"[separator]":{class:"separator"},"[separator-10]":{class:"separator"},"[separator-15]":{class:"separator",width:1.5},"[separator-20]":{class:"separator",width:2},"[separator-50]":{class:"separator",width:5},"[shift]":{class:"shift bottom left",width:1.5,label:"<span class=caps-lock-indicator></span><svg class=svg-glyph><use xlink:href=#svg-shift /></svg>"},"[foreground-color]":{variants:"foreground-color",command:["applyStyle",{color:"red"}],label:"<span style='border-radius: 50%;width:22px;height:22px; border: 3px solid #cc2428; box-sizing: border-box'>"},"[background-color]":{variants:"background-color",command:["applyStyle",{backgroundColor:"yellow"}],label:"<span style='border-radius: 50%;width:22px;height:22px; background:#fff590; box-sizing: border-box'></span>"}};function z0(e){var i;if(typeof e=="string"){if(e==="[.]"&&window.MathfieldElement.decimalSeparator===","&&(e="[,]"),!Nl[e])return{latex:e};e={label:e}}let r;return"label"in e&&e.label&&Nl[e.label]&&(r=d(P(P({},Nl[e.label]),e),{label:Nl[e.label].label})),"key"in e&&e.key&&Nl[e.key]&&(r=d(P(P({},Nl[e.key]),e),{key:Nl[e.key].key})),r?(r.command==="insertDecimalSeparator"&&(r.label=(i=window.MathfieldElement.decimalSeparator)!=null?i:"."),e.label==="[action]"&&(r=P(P({},r),window.mathVirtualKeyboard.actionKeycap)),e.label==="[shift]"&&(r=P(P({},r),window.mathVirtualKeyboard.shiftKeycap)),e.label==="[backspace]"&&(r=P(P({},r),window.mathVirtualKeyboard.backspaceKeycap)),e.label==="[tab]"&&(r=P(P({},r),window.mathVirtualKeyboard.tabKeycap)),r):e}var oh;function Om(e){var i;if(e.button!==0)return;const r=Yo.singleton;if(!r)return;let a=e.target;for(;a&&!a.getAttribute("data-layer");)a=a.parentElement;if(a){r.currentLayer=(i=a.getAttribute("data-layer"))!=null?i:"",e.preventDefault();return}const u=qu(e.target);if(!(u!=null&&u.id))return;const p=r.getKeycap(u.id);if(!p)return;console.assert(e.type==="pointerdown");const g=new AbortController,b=g.signal;u.classList.add("is-pressed"),u.addEventListener("pointerenter",Kf(g),{capture:!0,signal:b}),u.addEventListener("pointerleave",Kf(g),{capture:!0,signal:b}),u.addEventListener("pointercancel",Kf(g),{signal:b}),u.addEventListener("pointerup",Kf(g),{signal:b}),Zu(p)&&(u.classList.add("is-active"),r.shiftPressCount++),p.variants&&(oh&&clearTimeout(oh),oh=setTimeout(()=>{u.classList.contains("is-pressed")&&(u.classList.remove("is-pressed"),u.classList.add("is-active"),e.target&&"releasePointerCapture"in e.target&&e.target.releasePointerCapture(e.pointerId),Zo(u,()=>{g.abort(),u==null||u.classList.remove("is-active")}))},300)),e.preventDefault()}function Kf(e){return i=>{const r=qu(i.target);if(!(r!=null&&r.id))return;const a=Yo.singleton;if(!a)return;const u=a.getKeycap(r.id);if(u){if(i.type==="pointerenter"&&i.target===r&&i.isPrimary&&r.classList.add("is-pressed"),i.type==="pointercancel"){r.classList.remove("is-pressed"),Zu(u)&&(a.shiftPressCount--,r.classList.toggle("is-active",a.isShifted)),e.abort();return}if(i.type==="pointerleave"&&i.target===r){r.classList.remove("is-pressed"),Zu(u)&&(a.shiftPressCount--,r.classList.toggle("is-active",a.isShifted));return}if(i.type==="pointerup"){oh&&clearTimeout(oh),Zu(u)?r.classList.toggle("is-active",a.isShifted):r.classList.contains("is-pressed")&&(r.classList.remove("is-pressed"),a.isShifted&&u.shift?typeof u.shift=="string"?a.executeCommand(["insert",u.shift,{focus:!0,feedback:!0,scrollIntoView:!0,mode:"math",format:"latex"}]):o0(u.shift):o0(u),a.shiftPressCount===1&&!i.shiftKey&&(a.shiftPressCount=0)),e.abort(),i.preventDefault();return}}}}function o0(e){var i;let r=e.command;!r&&e.insert&&(r=["insert",e.insert,{focus:!0,feedback:!0,scrollIntoView:!0,mode:"math",format:"latex"}]),!r&&e.key&&(r=["typedText",e.key,{focus:!0,feedback:!0,simulateKeystroke:!0}]),!r&&e.latex&&(r=["insert",e.latex,{focus:!0,feedback:!0,scrollIntoView:!0,mode:"math",format:"latex"}]),r||(r=["typedText",e.label,{focus:!0,feedback:!0,simulateKeystroke:!0}]),(i=Yo.singleton)==null||i.executeCommand(r)}function Fm(e){if(e.nodeType!==1)return!1;const i=e.classList;return i.contains("MLK__keycap")||i.contains("shift")||i.contains("action")||i.contains("fnbutton")||i.contains("bigfnbutton")}function qu(e){if(!e)return;let i=e;for(;i&&!Fm(i);)i=i.parentElement;return i!=null?i:void 0}function Zu(e){return!!e.class&&/(^|\s)shift($|\s)/.test(e.class)}var Yo=class _m{constructor(){this.originalContainerBottomPadding=null,this.keycapRegistry={},this._shiftPressCount=0;var i,r,a;this.targetOrigin=window.origin,this.originValidator="none",this._alphabeticLayout="auto",this._layouts=Object.freeze(["default"]),this._editToolbar="default",this._container=(r=(i=window.document)==null?void 0:i.body)!=null?r:null,this._visible=!1,this._rebuilding=!1,this.observer=new ResizeObserver(u=>{this.adjustBoundingRect(),this.dispatchEvent(new Event("geometrychange")),this.sendMessage("geometry-changed",{boundingRect:this.boundingRect})}),this.listeners={};try{(a=window.top)==null||a.addEventListener("message",this)}catch(u){window.addEventListener("message",this)}document.body.addEventListener("focusin",u=>{const p=u.target;p!=null&&p.isConnected&&setTimeout(()=>{const g=V0();g&&!g.readOnly&&g.mathVirtualKeyboardPolicy==="auto"&&O()&&this.show({animate:!0})},300)}),document.addEventListener("focusout",u=>{u.target.mathVirtualKeyboardPolicy!=="manual"&&setTimeout(()=>{V0()||this.hide()},300)})}get currentLayer(){var i,r,a;return(a=(r=(i=this._element)==null?void 0:i.querySelector(".MLK__layer.is-visible"))==null?void 0:r.id)!=null?a:""}set currentLayer(i){var r;if(!this._element){this.latentLayer=i;return}let a=i?this._element.querySelector(`#${i}.MLK__layer`):null;a||(a=this._element.querySelector(".MLK__layer")),a&&((r=this._element.querySelector(".MLK__layer.is-visible"))==null||r.classList.remove("is-visible"),a.classList.add("is-visible")),this.render()}get shiftPressCount(){return this._shiftPressCount}set shiftPressCount(i){var r;this._shiftPressCount=i>2||i<0?0:i,(r=this._element)==null||r.classList.toggle("is-caps-lock",this.shiftPressCount===2),this.render()}get isShifted(){return this._shiftPressCount>0}resetKeycapRegistry(){this.keycapRegistry={}}registerKeycap(i){const r="ML__k"+Date.now().toString(36).slice(-2)+Math.floor(Math.random()*1e5).toString(36);return this.keycapRegistry[r]=i,r}getKeycap(i){return i?this.keycapRegistry[i]:void 0}getLayer(i){const r=this.normalizedLayouts;for(const a of r)for(const u of a.layers)if(u.id===i)return u}get alphabeticLayout(){return this._alphabeticLayout}set alphabeticLayout(i){this._alphabeticLayout=i,this.rebuild()}get actionKeycap(){return this._actionKeycap}set actionKeycap(i){this._actionKeycap=typeof i=="string"?{label:i}:i}get shiftKeycap(){return this._shiftKeycap}set shiftKeycap(i){this._shiftKeycap=typeof i=="string"?{label:i}:i}get backspaceKeycap(){return this._backspaceKeycap}set backspaceKeycap(i){this._backspaceKeycap=typeof i=="string"?{label:i}:i}get tabKeycap(){return this._tabKeycap}set tabKeycap(i){this._tabKeycap=typeof i=="string"?{label:i}:i}get layouts(){return this._layouts}set layouts(i){this.updateNormalizedLayouts(i),this.rebuild()}updateNormalizedLayouts(i){const r=Array.isArray(i)?[...i]:[i],a=r.findIndex(u=>u==="default");a>=0&&r.splice(a,1,"numeric","symbols","alphabetic","greek"),this._layouts=Object.freeze(r),this._normalizedLayouts=r.map(u=>U0(u))}get normalizedLayouts(){return this._normalizedLayouts||this.updateNormalizedLayouts(this._layouts),this._normalizedLayouts}get editToolbar(){return this._editToolbar}set editToolbar(i){this._editToolbar=i,this.rebuild()}get container(){return this._container}set container(i){this._container=i,this.rebuild()}static get singleton(){if(this._singleton===void 0)try{this._singleton=new _m}catch(i){this._singleton=null}return this._singleton}get style(){return this._style}addEventListener(i,r,a){this.listeners[i]||(this.listeners[i]=new Set),this.listeners[i].has(r)||this.listeners[i].add(r)}dispatchEvent(i){return!this.listeners[i.type]||this.listeners[i.type].size===0?!0:(this.listeners[i.type].forEach(r=>{typeof r=="function"?r(i):r==null||r.handleEvent(i)}),!i.defaultPrevented)}removeEventListener(i,r,a){this.listeners[i]&&this.listeners[i].delete(r)}get element(){return this._element}set element(i){var r;this._element!==i&&((r=this._element)==null||r.remove(),this._element=i)}get visible(){return this._visible}set visible(i){i?this.show():this.hide()}get boundingRect(){var i;if(!this._visible)return new DOMRect;const r=(i=this._element)==null?void 0:i.getElementsByClassName("MLK__plate")[0];return r?r.getBoundingClientRect():new DOMRect}adjustBoundingRect(){var i,r;const a=this.boundingRect.height;if(this.container===document.body){(i=this._element)==null||i.style.setProperty("--_keyboard-height",`calc(${a}px + var(--_padding-top) + var(--_padding-bottom) + env(safe-area-inset-bottom, 0))`);const u=a-1;this.container.style.paddingBottom=this.originalContainerBottomPadding?`calc(${this.originalContainerBottomPadding} + ${u}px)`:`${u}px`}else(r=this._element)==null||r.style.setProperty("--_keyboard-height",`${a}px`)}rebuild(){if(this._rebuilding||!this._element)return;this._rebuilding=!0;const i=this.currentLayer;requestAnimationFrame(()=>{this._rebuilding=!1,this._element&&(this._element.remove(),this._element=void 0),this.visible&&(this.buildAndAttachElement(),this.currentLayer=i,this.render(),this.adjustBoundingRect(),this._element.classList.add("is-visible"))})}render(){if(!this._element)return;const i=this.getLayer(this.currentLayer);this._element.classList.toggle("backdrop-is-transparent",!!(i&&(i.backdrop||i.container)));const r=this._element.querySelectorAll(".MLK__layer.is-visible .MLK__keycap, .MLK__layer.is-visible .action, .fnbutton, .MLK__layer.is-visible .bigfnbutton, .MLK__layer.is-visible .shift");if(r)for(const a of r){const u=this.getKeycap(a.id);if(u){const[p,g]=$f(u,{shifted:this.isShifted});a.innerHTML=window.MathfieldElement.createHTML(p),a.className=g}}}show(i){var r;if(this._visible)return;const a=this.container;if(a&&window.mathVirtualKeyboard&&this.stateWillChange(!0)){if(this._element||(this.buildAndAttachElement(),this.adjustBoundingRect()),!this._visible){const u=this._element.getElementsByClassName("MLK__plate")[0];if(u&&this.observer.observe(u),a===window.document.body){const p=a.style.paddingBottom;this.originalContainerBottomPadding=p;const g=u.offsetHeight-1;a.style.paddingBottom=p?`calc(${p} + ${g}px)`:`${g}px`}window.addEventListener("mouseup",this),window.addEventListener("blur",this),window.addEventListener("keydown",this,{capture:!0}),window.addEventListener("keyup",this,{capture:!0}),(r=this._element)==null||r.classList.toggle("is-caps-lock",this.shiftPressCount===2),this.currentLayer=this.latentLayer}this._visible=!0,i!=null&&i.animate?requestAnimationFrame(()=>{this._element&&(this._element.classList.add("animate"),this._element.addEventListener("transitionend",()=>{var u;return(u=this._element)==null?void 0:u.classList.remove("animate")},{once:!0}),this._element.classList.add("is-visible"),this.stateChanged())}):(this._element.classList.add("is-visible"),this.stateChanged())}}hide(i){var r;const a=this.container;if(a&&this._visible&&this.stateWillChange(!1)){if(this._visible=!1,this._element){this.latentLayer=this.currentLayer;const u=this._element.getElementsByClassName("MLK__plate")[0];u&&this.observer.unobserve(u),window.removeEventListener("mouseup",this),window.removeEventListener("blur",this),window.removeEventListener("keydown",this,{capture:!0}),window.removeEventListener("keyup",this,{capture:!0}),window.removeEventListener("contextmenu",this,{capture:!0}),rh(),Cm(),(r=this._element)==null||r.remove(),this._element=void 0,this.originalContainerBottomPadding!==null&&(a.style.paddingBottom=this.originalContainerBottomPadding)}this.stateChanged()}}get height(){var i,r;return(r=(i=this.element)==null?void 0:i.offsetHeight)!=null?r:0}buildAndAttachElement(){var i;console.assert(!this.element),this.element=Rm(this),window.addEventListener("contextmenu",this,{capture:!0}),this.element.addEventListener("contextmenu",r=>{r.shiftKey||((r.ctrlKey||r.button===2)&&Zo(r.target),r.preventDefault(),r.stopPropagation())},{capture:!0}),(i=this.container)==null||i.appendChild(this.element)}handleEvent(i){if(yo(i)){if(!Du(i.origin,this.originValidator))throw new DOMException(`Message from unknown origin (${i.origin}) cannot be handled`,"SecurityError");i.data.action==="disconnect"?this.connectedMathfieldWindow=void 0:i.data.action!=="update-setting"&&i.data.action!=="proxy-created"&&i.data.action!=="execute-command"&&(console.assert(i.source!==void 0),this.connectedMathfieldWindow=i.source),this.handleMessage(i.data,i.source)}if(this._element)switch(i.type){case"mouseup":case"blur":document.body.style.userSelect="",this.shiftPressCount=0;break;case"contextmenu":i.button!==2&&i.preventDefault();break;case"keydown":{i.key==="Shift"&&!i.repeat&&(this.shiftPressCount=1);break}case"keyup":{(i.key==="Shift"||!i.getModifierState("Shift")&&this.shiftPressCount!==2)&&(this.shiftPressCount=0);break}}}handleMessage(i,r){const{action:a}=i;if(a==="execute-command"){const{command:u}=i,p=is(u);if(window.top!==void 0&&p!=="virtual-keyboard")return;this.executeCommand(u);return}if((a==="connect"||a==="show")&&this.sendMessage("synchronize-proxy",{boundingRect:this.boundingRect,alphabeticLayout:this._alphabeticLayout,layouts:this._layouts,editToolbar:this._editToolbar},r),a!=="disconnect"&&window===window.top){if(a==="show"){typeof i.animate!="undefined"?this.show({animate:i.animate}):this.show();return}if(a==="hide"){typeof i.animate!="undefined"?this.hide({animate:i.animate}):this.hide();return}if(a==="update-setting"){i.alphabeticLayout&&(this.alphabeticLayout=i.alphabeticLayout),i.layouts&&(this.layouts=i.layouts),i.editToolbar&&(this.editToolbar=i.editToolbar);return}if(a==="proxy-created"){this.sendMessage("synchronize-proxy",{boundingRect:this.boundingRect,alphabeticLayout:this._alphabeticLayout,layouts:this._layouts,editToolbar:this._editToolbar},r);return}}}sendMessage(i,r,a){if(a||(a=this.connectedMathfieldWindow),this.targetOrigin===null||this.targetOrigin==="null"||a===window){window.dispatchEvent(new MessageEvent("message",{source:window,data:P({type:Fl,action:i},r)}));return}if(a)a.postMessage(P({type:Fl,action:i},r),{targetOrigin:this.targetOrigin});else if(r.command&&this.dispatchEvent(new CustomEvent("math-virtual-keyboard-command",{detail:r.command})),i==="execute-command"&&Array.isArray(r.command)&&r.command[0]==="insert"){const u=r.command[1].split("");for(const p of u)this.dispatchEvent(new KeyboardEvent("keydown",{key:p,bubbles:!0})),this.dispatchEvent(new KeyboardEvent("keyup",{key:p,bubbles:!0}))}}stateWillChange(i){return this.dispatchEvent(new CustomEvent("before-virtual-keyboard-toggle",{detail:{visible:i},bubbles:!0,cancelable:!0,composed:!0}))}stateChanged(){this.dispatchEvent(new Event("virtual-keyboard-toggle")),this._visible||(this.dispatchEvent(new Event("geometrychange")),this.sendMessage("geometry-changed",{boundingRect:this.boundingRect}))}focus(){this.sendMessage("focus",{})}blur(){this.sendMessage("blur",{})}updateToolbar(i){const r=this._element;if(!r)return;r.classList.toggle("is-math-mode",i.mode==="math"),r.classList.toggle("is-text-mode",i.mode==="text"),r.classList.toggle("can-undo",i.canUndo),r.classList.toggle("can-redo",i.canRedo),r.classList.toggle("can-copy",!i.selectionIsCollapsed),r.classList.toggle("can-copy",!i.selectionIsCollapsed),r.classList.toggle("can-paste",!0);const a=r.querySelectorAll(".ML__edit-toolbar");if(a)for(const u of a)u.innerHTML=Tm(this,i)}update(i){this._style=i.style,this.updateToolbar(i)}connect(){this.connectedMathfieldWindow=window}disconnect(){this.connectedMathfieldWindow=void 0}executeCommand(i){let r,a=[],u=is(i);return k(i)?(r=i[0],r==="performWithFeedback"&&(i=i.slice(1),u=is(i)),a=i.slice(1)):r=i,r=r.replace(/-\w/g,p=>p[1].toUpperCase()),u==="virtual-keyboard"?lr[r].fn(void 0,...a):(this.sendMessage("execute-command",{command:i}),!1)}dispose(){window.removeEventListener("mouseup",this),window.removeEventListener("blur",this),window.removeEventListener("message",this)}};function V0(){var e,i;let r=c(),a=null;for(;r;){if("host"in r&&((i=(e=r.host)==null?void 0:e.tagName)==null?void 0:i.toLowerCase())==="math-field"){a=r.host;break}r=r.parentNode}return a}if(M()&&!("mathVirtualKeyboard"in window))if(window===window.top){const e=Yo.singleton;Object.defineProperty(window,"mathVirtualKeyboard",{get:()=>e})}else Object.defineProperty(window,"mathVirtualKeyboard",{get:()=>Bf.singleton,configurable:!0});function Uf(e){const i={};for(const r of Object.keys(e))switch(r){case"scriptDepth":const a=e.scriptDepth;if(k(a))i.scriptDepth=[a[0],a[1]];else if(typeof a=="number")i.scriptDepth=[a,a];else if(typeof a=="string"){const[p,g]=a.split(",").map(b=>parseInt(b.trim()));i.scriptDepth=[p,g]}else throw new TypeError("Unexpected value for scriptDepth");break;case"mathVirtualKeyboardPolicy":let u=e.mathVirtualKeyboardPolicy.toLowerCase();if(u==="sandboxed"){if(window!==window.top){const p=Yo.singleton;Object.defineProperty(window,"mathVirtualKeyboard",{get:()=>p})}u="manual"}i.mathVirtualKeyboardPolicy=u;break;case"letterShapeStyle":e.letterShapeStyle==="auto"?$.locale.startsWith("fr")?i.letterShapeStyle="french":i.letterShapeStyle="tex":i.letterShapeStyle=e.letterShapeStyle;break;case"defaultMode":["text","math","inline-math"].includes(e.defaultMode)?i.defaultMode=e.defaultMode:(console.error('MathLive 0.98.5: valid values for defaultMode are "text", "math" or "inline-math"'),i.defaultMode="math");break;case"macros":i.macros=Ae(e.macros);break;default:k(e[r])?i[r]=[...e[r]]:typeof e[r]=="object"&&!(e[r]instanceof Element)&&r!=="computeEngine"?i[r]=P({},e[r]):i[r]=e[r]}return i}function $l(e,i){let r;typeof i=="string"?r=[i]:i===void 0?r=Object.keys(e):r=i;const a={};for(const u of r)e[u]===null?a[u]=null:k(e[u])?a[u]=[...e[u]]:typeof e[u]=="object"&&!(e[u]instanceof Element)&&u!=="computeEngine"?a[u]=P({},e[u]):a[u]=e[u];return typeof i=="string"?a[i]:a}function zf(){return{readOnly:!1,defaultMode:"math",macros:{},registers:{},colorMap:Be,backgroundColorMap:Dt,letterShapeStyle:$.locale.startsWith("fr")?"french":"tex",minFontScale:0,smartMode:!1,smartFence:!0,smartSuperscript:!0,scriptDepth:[1/0,1/0],removeExtraneousParentheses:!0,isImplicitFunction:e=>["\\sin","\\cos","\\tan","\\arcsin","\\arccos","\\arctan","\\arcsec","\\arccsc","\\arsinh","\\arcosh","\\artanh","\\arcsech","\\arccsch","\\arg","\\ch","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\sec","\\sinh","\\sh","\\tanh","\\tg","\\th","\\lg","\\lb","\\log","\\ln"].includes(e),mathModeSpace:"",placeholderSymbol:"\u25A2",contentPlaceholder:"",popoverPolicy:"auto",environmentPopoverPolicy:"off",keybindings:kd,inlineShortcuts:lf,inlineShortcutTimeout:0,mathVirtualKeyboardPolicy:"auto",virtualKeyboardTargetOrigin:window==null?void 0:window.origin,originValidator:"none",onInlineShortcut:()=>"",onScrollIntoView:null,onExport:Ed,value:""}}function G0(e){return e.defaultMode==="inline-math"?"math":e.defaultMode}function Xo(e,i){!e||!i||(k(e)?e.forEach(r=>Xo(r,i)):typeof e=="object"&&!e.style.color&&!e.style.backgroundColor&&!e.style.fontFamily&&!e.style.fontShape&&!e.style.fontSeries&&!e.style.fontSize&&!e.style.variant&&!e.style.variantStyle&&(e.applyStyle(i),Xo(e.body,i),Xo(e.above,i),Xo(e.below,i),Xo(e.subscript,i),Xo(e.superscript,i)))}function l0(e,i,r,a){function u(g,b){for(const w of p)if(w.style[g]!==b)return!1;return!0}if(i=e.normalizeRange(i),i[0]===i[1])return!1;const p=e.getAtoms(i,{includeChildren:!0});a.operation==="toggle"&&(r.color&&u("color",r.color)&&(r.color="none",delete r.verbatimColor),r.backgroundColor&&u("backgroundColor",r.backgroundColor)&&(r.backgroundColor="none",delete r.verbatimBackgroundColor),r.fontFamily&&u("fontFamily",r.fontFamily)&&(r.fontFamily="none"),r.fontSeries&&u("fontSeries",r.fontSeries)&&(r.fontSeries="auto"),r.fontShape&&u("fontShape",r.fontShape)&&(r.fontShape="auto"),r.fontSize&&u("fontSize",r.fontSize)&&(r.fontSize=pu),r.variant&&u("variant",r.variant)&&(r.variant="normal"),r.variantStyle&&u("variantStyle",r.variantStyle)&&(r.variantStyle=""));for(const g of p)g.applyStyle(r);return!0}function Bm(e,i){const r=e.at(e.position);if(r.type==="composition")r.value=i;else{const{caret:a}=r;r.caret=void 0;const u=new Fu(i,{mode:r.mode});u.caret=a,r.parent.addChildAfter(u,r),e.position+=1}}function Nm(e){const i=e.at(e.position);i.type==="composition"&&(i.parent.removeChild(i),e.position-=1)}Yt(["math","displaymath"],ea),Yt("center",ea),ke("displaylines","",{parse:e=>{const i=[];let r=[];e.beginContext({tabular:!0});do{if(e.end()||e.match("<}>"))break;e.matchColumnSeparator()||e.matchRowSeparator()?(i.push([r]),r=[]):r.push(...e.scan(a=>["<}>","&","\\cr","\\\\","\\tabularnewline"].includes(a)))}while(!0);return e.endContext(),i.push([r]),i},createAtom:e=>new Tn("lines",e.args,[],{leftDelim:".",rightDelim:".",columns:[{align:"l"}]})}),pt("array","{columns:colspec}",(e,i,r,a)=>new Tn(e,u0(i),r,{columns:a[0],mathstyleName:"textstyle"})),pt(["equation","equation*","subequations"],"",(e,i,r)=>new Tn(e,u0(i),r,{columns:[{align:"c"}]})),pt(["multline","multline*"],"",ea),pt(["align","align*","aligned","eqnarray"],"",ea),pt("split","",ea),pt(["gather","gathered"],"",ea),pt(["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],"[columns:colspec]",ea),pt(["smallmatrix","smallmatrix*"],"[columns:colspec]",ea),pt(["cases","dcases","rcases"],"",ea);function $m(e){for(const i of e)for(const r of i)if(r.length>0)return!1;return!0}function u0(e,i=1){return $m(e)?Array(i).fill([[new et({type:"first"}),new fa]]):e.map(r=>r.length===0?[[new et({type:"first"})]]:r.map(a=>a.length===0?[new et({type:"first"})]:(a[0].type!=="first"&&a.unshift(new et({type:"first"})),a)))}function ea(e,i=[[[]]],r=[],a=[]){switch(i=u0(i,["split","align","align*","aligned","eqnarray"].includes(e)?2:1),e){case"math":return new Tn(e,i,r,{mathstyleName:"textstyle"});case"displaymath":return new Tn(e,i,r,{mathstyleName:"textstyle"});case"center":return new Tn(e,i,r,{columns:[{align:"c"}]});case"multline":case"multline*":return new Tn(e,i,r,{columns:[{align:"m"}],leftDelim:".",rightDelim:"."});case"split":return new Tn(e,i,r,{columns:[{align:"r"},{align:"l"}],minColumns:2});case"gather":case"gathered":return new Tn(e,i,r,{columns:[{gap:.25},{align:"c"},{gap:0}]});case"pmatrix":case"pmatrix*":return new Tn(e,i,r,{mathstyleName:"textstyle",leftDelim:"(",rightDelim:")",columns:Kl(a[0])});case"bmatrix":case"bmatrix*":return new Tn(e,i,r,{mathstyleName:"textstyle",leftDelim:"[",rightDelim:"]",columns:Kl(a[0])});case"Bmatrix":case"Bmatrix*":return new Tn(e,i,r,{mathstyleName:"textstyle",leftDelim:"\\lbrace",rightDelim:"\\rbrace",columns:Kl(a[0])});case"vmatrix":case"vmatrix*":return new Tn(e,i,r,{mathstyleName:"textstyle",leftDelim:"\\vert",rightDelim:"\\vert",columns:Kl(a[0])});case"Vmatrix":case"Vmatrix*":return new Tn(e,i,r,{mathstyleName:"textstyle",leftDelim:"\\Vert",rightDelim:"\\Vert",columns:Kl(a[0])});case"matrix":case"matrix*":return new Tn(e,i,r,{mathstyleName:"textstyle",leftDelim:".",rightDelim:".",columns:Kl(a==null?void 0:a[0])});case"smallmatrix":case"smallmatrix*":return new Tn(e,i,r,{mathstyleName:"scriptstyle",columns:Kl(a==null?void 0:a[0]),colSeparationType:"small",arraystretch:.5});case"cases":case"dcases":return new Tn(e,i,r,{mathstyleName:e==="dcases"?"displaystyle":"textstyle",arraystretch:1.2,leftDelim:"\\lbrace",rightDelim:".",columns:[{align:"l"},{gap:1},{align:"l"}]});case"rcases":return new Tn(e,i,r,{arraystretch:1.2,leftDelim:".",rightDelim:"\\rbrace",columns:[{align:"l"},{gap:1},{align:"l"}]});case"lines":return new Tn(e,i,r,{leftDelim:".",rightDelim:".",columns:[{align:"l"}]});case"align":case"align*":case"aligned":case"eqnarray":{let u=0;for(const b of i)u=Math.max(u,b.length);const p=[{gap:0},{align:"r"},{gap:.25},{align:"l"}];let g=2;for(;g<u;)p.push({gap:1},{align:"r"},{gap:.25},{align:"l"}),g+=2;return p.push({gap:0}),new Tn(e,i,r,{arraycolsep:0,columns:p,minColumns:2})}}return new Tn(e,i,r,{mathstyleName:"textstyle"})}function Kl(e){return e!=null?e:[{align:"c"},{align:"c"},{align:"c"},{align:"c"},{align:"c"},{align:"c"},{align:"c"},{align:"c"},{align:"c"},{align:"c"}]}function Km(e,i){let r=e.at(e.position);for(;r&&!(r.parent instanceof Tn);)r=r.parent;if(r&&r.type==="array"&&r.environmentName,!r||!(r.parent instanceof Tn)){const a=e.at(e.position);if(r=a,!r.parent.parent){let u=e.extractAtoms([e.position,e.lastOffset]),p=e.extractAtoms([0,e.position]);p.length===0&&(p=Hf()),u.length===0&&(u=Hf());let g;return i.endsWith("column")?(g=ea("split",[[p,u]]),e.root=g,Ul(g,0,0)?zl(e,g,0,0):Ul(g,0,1)?zl(e,g,0,1):e.position=e.offsetOf(a)):(g=ea("lines",[[p],[u]]),e.root=g,Ul(g,0,0)?zl(e,g,0,0):Ul(g,1,0)?zl(e,g,1,0):e.position=e.offsetOf(a)),[void 0,[0,0]]}if(r.parent instanceof Zn){const u=r.parent;let p=e.extractAtoms([e.position,e.offsetOf(u.lastChild)]),g=e.extractAtoms([e.offsetOf(u.firstChild),e.position]);g.length===0&&(g=Hf()),p.length===0&&(p=Hf());let b="pmatrix";const w=u.leftDelim,E=u.rightDelim;w==="("&&(E===")"||E==="?")?b="pmatrix":(w==="["||w==="\\lbrack")&&(E==="]"||E==="\\rbrack"||E==="?")?b="bmatrix":w==="\\vert"&&E==="\\vert"?b="vmatrix":w==="\\Vert"&&E==="\\Vert"?b="Vmatrix":(w==="{"||w==="\\lbrace")&&(E==="."||E==="?")&&(b="cases");const R=ea(b,i.endsWith("column")?[[g,p]]:[[g],[p]]);return u.parent.addChildBefore(R,u),u.parent.removeChild(u),Ul(R,0,0)?zl(e,R,0,0):i.endsWith("column")?Ul(R,0,1)?zl(e,R,0,1):e.position=e.offsetOf(r):Ul(R,1,0)?zl(e,R,1,0):e.position=e.offsetOf(r),[void 0,[0,0]]}}return r&&r.parent instanceof Tn?[r.parent,r.parentBranch]:[void 0,[0,0]]}function Ul(e,i,r){const a=e.getCell(i,r);return!a||a.length!==2?!1:a[1].type==="placeholder"}function Um(e,i,r,a){const u=i.getCell(r,a);return u?[e.offsetOf(u[0]),e.offsetOf(u[u.length-1])]:-1}function zl(e,i,r,a){const u=Um(e,i,r,a);typeof u!="number"&&e.setSelection(u)}function Vf(e,i,r,a,u){const p=i.getCell(r,a);p&&e.setPositionHandlingPlaceholder(e.offsetOf(p[u==="start"?0:p.length-1]))}function Gf(e,i){const[r,[a,u]]=Km(e,i);if(r)switch(i){case"after row":r.addRowAfter(a),Vf(e,r,a+1,0,"end");break;case"after column":if(r.maxColumns<=r.colCount){e.announce("plonk");return}r.addColumnAfter(u),Vf(e,r,a,u+1,"end");break;case"before row":r.addRowBefore(a),Vf(e,r,a,0,"start");break;case"before column":if(r.maxColumns<=r.colCount){e.announce("plonk");return}r.addColumnBefore(u),Vf(e,r,a,u,"start");break}}function H0(e){return e.contentWillChange({inputType:"insertText"})?(Gf(e,"after row"),e.contentDidChange({inputType:"insertText"}),!0):!1}function zm(e){return e.contentWillChange({inputType:"insertText"})?(Gf(e,"before row"),e.contentDidChange({inputType:"insertText"}),!0):!1}function W0(e){return e.contentWillChange({inputType:"insertText"})?(Gf(e,"after column"),e.contentDidChange({inputType:"insertText"}),!0):!1}function Vm(e){return e.contentWillChange({inputType:"insertText"})?(Gf(e,"before column"),e.contentDidChange({inputType:"insertText"}),!0):!1}function j0(e,i){if(!e.contentWillChange({}))return!1;e.mathfield.snapshot();let r=".",a=".";switch(i){case"pmatrix":case"pmatrix*":r="(",a=")";break;case"bmatrix":case"bmatrix*":r="[",a="]";break;case"Bmatrix":case"Bmatrix*":r="\\lbrace",a="\\rbrace";break;case"vmatrix":case"vmatrix*":r="\\vert",a="\\vert";break;case"Vmatrix":case"Vmatrix*":r="\\Vert",a="\\Vert";break;case"matrix":case"matrix*":r=".",a=".";break;case"cases":case"dcases":r="\\lbrace";break;case"rcases":a="\\rbrace";break}const u=e.at(e.position),p=u.type==="array"?u:e.parentEnvironment;return p.environmentName=i,p.leftDelim=r,p.rightDelim=a,e.contentDidChange({}),!0}function q0(e,i){let r=e.at(e.position);for(;r&&!(Array.isArray(r.parentBranch)&&r.parent instanceof Tn);)r=r.parent;if(Array.isArray(r==null?void 0:r.parentBranch)&&(r==null?void 0:r.parent)instanceof Tn){const a=r.parent,u=r.parentBranch;let p;switch(i){case"row":if(a.rowCount>1){a.removeRow(u[0]);const g=a.getCell(Math.max(0,u[0]-1),u[1]);p=e.offsetOf(g[g.length-1])}break;case"column":if(a.colCount>a.minColumns){a.removeColumn(u[1]);const g=a.getCell(u[0],Math.max(0,u[1]-1));p=e.offsetOf(g[g.length-1])}break}p&&e.setPositionHandlingPlaceholder(p)}}function Gm(e){return e.contentWillChange({inputType:"deleteContent"})?(q0(e,"row"),e.contentDidChange({inputType:"deleteContent"}),!0):!1}function Hm(e){return e.contentWillChange({inputType:"deleteContent"})?(q0(e,"column"),e.contentDidChange({inputType:"deleteContent"}),!0):!1}ur({addRowAfter:H0,addColumnAfter:W0,addRowBefore:zm,addColumnBefore:Vm,removeRow:Gm,removeColumn:Hm,setEnvironment:j0},{target:"model",canUndo:!0,changeContent:!0,changeSelection:!0});function Hf(){return[new fa]}var Z0=class vm{constructor(i){this.recording=!1,this.model=i,this.reset()}reset(){this.stack=[],this.index=-1,this.lastOp=""}startRecording(){this.recording=!0}stopRecording(){this.recording=!1}canUndo(){return this.index-1>=0}canRedo(){return this.stack.length-1>this.index}stopCoalescing(i){i&&this.index>=0&&(this.stack[this.index].selection=i),this.lastOp=""}undo(){return this.canUndo()?(this.model.setState(this.stack[this.index-1],{silenceNotifications:!1,type:"undo"}),this.index-=1,this.lastOp="",!0):!1}redo(){return this.canRedo()?(this.index+=1,this.model.setState(this.stack[this.index],{silenceNotifications:!1,type:"redo"}),this.lastOp="",!0):!1}pop(){this.canUndo()&&(this.stack.splice(this.index,this.stack.length-this.index),this.index-=1)}snapshot(i){return this.recording?(i&&i===this.lastOp&&this.pop(),this.stack.splice(this.index+1,this.stack.length-this.index-1),this.stack.push(this.model.getState()),this.index+=1,this.stack.length>vm.maximumDepth&&(this.stack.shift(),this.index-=1),this.lastOp=i!=null?i:"",!0):!1}};Z0.maximumDepth=1e3;var Wm=Z0;function c0(e,i,r){if(e.at(i).mode!=="text")return i;const a=r==="backward"?-1:1;let u;if(nt.test(e.at(i).value)){let p=i,g;do g=e.at(p).mode==="text"&&nt.test(e.at(p).value),p+=a;while(e.at(p)&&g);u=e.at(p)?p-2*a:p-a}else if(/\s/.test(e.at(i).value)){let p=i;for(;e.at(p)&&e.at(p).mode==="text"&&/\s/.test(e.at(p).value);)p+=a;if(!e.at(p))u=p-a;else{let g=!0;do g=e.at(p).mode==="text"&&!/\s/.test(e.at(p).value),p+=a;while(e.at(p)&&g);u=e.at(p)?p-2*a:p-a}}else{let p=i;for(;e.at(p)&&e.at(p).mode==="text"&&!/\s/.test(e.at(p).value);)p+=a;u=e.at(p)?p:p-a;let g=!0;for(;e.at(p)&&g;)g=e.at(p).mode==="text"&&/\s/.test(e.at(p).value),g&&(u=p),p+=a;u=e.at(p)?p-2*a:p-a}return u-(a>0?0:1)}function Yu(e,i,r){var a,u,p,g,b,w,E;const R=e.position;(a=r==null?void 0:r.extend)!=null&&a||e.collapseSelection(i);let N=e.at(e.position);if(i==="forward"&&(N.type==="subsup"?(N=N.rightSibling,N||(N=e.at(e.position+1))):N=e.at(e.position+1)),!N)return e.announce("plonk"),!1;let Z=e.offsetOf(N);if(N instanceof No)Z=c0(e,Z,i);else if(N instanceof Lr)if(N.isSuggestion)for(console.assert(i==="forward");N&&N instanceof Lr;)N.isSuggestion=!1,Z=e.offsetOf(N),N=N.rightSibling;else if(i==="forward"){if(N=N.rightSibling,!N||!(N instanceof Lr))return e.announce("plonk"),!1;for(;N&&N instanceof Lr&&/[a-zA-Z\*]/.test(N.value);)Z=e.offsetOf(N),N=N.rightSibling}else{if(N=N.leftSibling,!N||!(N instanceof Lr))return e.announce("plonk"),!1;for(;N&&N instanceof Lr&&/[a-zA-Z\*]/.test(N.value);)Z=e.offsetOf(N),N=N.leftSibling}else if(i==="forward"&&N.type==="mopen"){let ue=0;do N.type==="mopen"?ue+=1:N.type==="mclose"&&(ue-=1),N=N.rightSibling;while(!N.isLastSibling&&ue!==0);Z=e.offsetOf(N.leftSibling)}else if(i==="backward"&&N.type==="mclose"){let ue=0;do N.type==="mopen"?ue+=1:N.type==="mclose"&&(ue-=1),N=N.leftSibling;while(!N.isFirstSibling&&ue!==0);Z=e.offsetOf(N)}else if(i==="backward")if(N.type==="first")for(;Z>0&&N.type==="first";)Z-=1,N=e.at(Z);else{const ue=N.type;N.type==="subsup"&&(Z=e.offsetOf(e.at(Z).leftSibling)),Z-=1;let me=(u=e.at(Z))==null?void 0:u.type;for(;Z>=0&&me===ue;)((p=e.at(Z))==null?void 0:p.type)==="subsup"?Z=e.offsetOf(e.at(Z).leftSibling):Z-=1,me=e.at(Z).type}else{const{type:ue}=N;let me=(g=e.at(Z))==null?void 0:g.type;const{lastOffset:Ve}=e;for(;Z<=Ve&&(me===ue||me==="subsup");){for(;((b=e.at(Z).rightSibling)==null?void 0:b.type)==="subsup";)Z=e.offsetOf(e.at(Z).rightSibling);Z+=1,me=(w=e.at(Z))==null?void 0:w.type}Z-=1}if((E=r==null?void 0:r.extend)!=null&&E){if(!e.setSelection(e.anchor,Z))return e.announce("plonk"),!1}else{if(Z===e.position)return e.announce("plonk"),!1;e.position=Z}return e.announce("move",R),e.mathfield.stopCoalescingUndo(),!0}function Fa(e,i,r){var a,u;if(r=r!=null?r:{extend:!1},e.mathfield.adoptStyle=i==="backward"?"right":"left",i!=="forward"){const[b,w]=Ie(e);b!==void 0&&w!==void 0&&e.deleteAtoms([b,w])}if(i==="upward")return qm(e,r);if(i==="downward")return Zm(e,r);if(r.extend){let b=Wf(e,e.position,i);b<0&&(b=0),b>e.lastOffset&&(b=e.lastOffset);const w=e.setSelection(e.anchor,b);return e.mathfield.stopCoalescingUndo(),w}if(e.selectionIsPlaceholder){e.collapseSelection(i);const b=Fa(e,i);return e.mathfield.stopCoalescingUndo(),b}let p=e.position;const g=p;if(e.collapseSelection(i)?(p=e.position,Y0(e,p)||(p=Wf(e,p,i))):p=Wf(e,p,i),p<0||p>e.lastOffset){let b=!0;return e.silenceNotifications||(b=(u=(a=e.mathfield.host)==null?void 0:a.dispatchEvent(new CustomEvent("move-out",{detail:{direction:i},cancelable:!0,bubbles:!0,composed:!0})))!=null?u:!0),b&&e.announce("plonk"),b}return e.setPositionHandlingPlaceholder(p),e.mathfield.stopCoalescingUndo(),e.announce("move",g),!0}function Wf(e,i,r){return i=i+(r==="forward"?1:-1),i<0||i>e.lastOffset||Y0(e,i)?i:Wf(e,i,r)}function Y0(e,i){var r;const a=e.at(i);let u=a.parent;for(;u&&!u.inCaptureSelection;)u=u.parent;return!(u!=null&&u.inCaptureSelection||(r=a.parent)!=null&&r.skipBoundary&&(!a.isFirstSibling&&a.isLastSibling||a.type==="first")||e.mathfield.hasEditablePrompts&&!a.parentPrompt)}function jm(e,i,r){let a=1/0,u=0;for(;u<i.length;u++){const p=lo(e.getHTMLElement(i[u])).right,g=Math.abs(r-p);if(g<=a)a=g;else break}return i[u-1]}function jf(e,i,r,a,u){const p=e.mathfield.hasEditablePrompts,g=p?r.filter(E=>E.type==="prompt"&&!E.captureSelection):r,b=lo(e.mathfield.getHTMLElement(i)).right,w=e.offsetOf(jm(e.mathfield,g,b))-(p?1:0);if(a){const[E,R]=e.selection.ranges[0];let N;w<(u==="up"?E:R)?N={ranges:[[w,R]],direction:"backward"}:N={ranges:[[E,w]],direction:"forward"},e.setSelection(N)}else e.setPositionHandlingPlaceholder(w);e.announce(`move ${u}`)}function qm(e,i){var r,a;const u=(r=i==null?void 0:i.extend)!=null?r:!1;u||e.collapseSelection("backward");const p=()=>{var w,E;let R=!0;return e.silenceNotifications||(R=(E=(w=e.mathfield.host)==null?void 0:w.dispatchEvent(new CustomEvent("move-out",{detail:{direction:"upward"},cancelable:!0,bubbles:!0,composed:!0})))!=null?E:!0),e.announce(R?"plonk":"line"),R},g=e.at(e.position);let b=g;for(;b&&b.parentBranch!=="below"&&!(Array.isArray(b.parentBranch)&&b.parent instanceof Tn);)b=b.parent;if(Array.isArray(b==null?void 0:b.parentBranch)&&b.parent instanceof Tn){const w=b.parent;if(b.parentBranch[0]<1)return p();const E=b.parentBranch[0]-1,R=w.array[E][b.parentBranch[1]];if(!R.some(Z=>Z.type==="prompt"&&!Z.captureSelection)&&e.mathfield.hasEditablePrompts)return p();jf(e,g,R,u,"up")}else if(b){const w=(a=b.parent.branch("above"))!=null?a:b.parent.createBranch("above");if(!w.some(R=>R.type==="prompt"&&R.placeholderId)&&e.mathfield.hasEditablePrompts)return p();jf(e,g,w,u,"up")}else return p();return e.mathfield.stopCoalescingUndo(),!0}function Zm(e,i){var r,a;const u=(r=i==null?void 0:i.extend)!=null?r:!1;u||e.collapseSelection("forward");const p=()=>{var w,E;let R=!0;return e.silenceNotifications||(R=(E=(w=e.mathfield.host)==null?void 0:w.dispatchEvent(new CustomEvent("move-out",{detail:{direction:"downward"},cancelable:!0,bubbles:!0,composed:!0})))!=null?E:!0),e.announce(R?"plonk":"line"),R},g=e.at(e.position);let b=g;for(;b&&b.parentBranch!=="above"&&!(Array.isArray(b.parentBranch)&&b.parent instanceof Tn);)b=b.parent;if(Array.isArray(b==null?void 0:b.parentBranch)&&b.parent instanceof Tn){const w=b.parent;if(b.parentBranch[0]+1>w.array.length-1)return p();const E=b.parentBranch[0]+1,R=w.array[E][b.parentBranch[1]];if(!R.some(Z=>Z.type==="prompt"&&!Z.captureSelection)&&e.mathfield.hasEditablePrompts)return p();jf(e,g,R,u,"down")}else if(b){const w=(a=b.parent.branch("below"))!=null?a:b.parent.createBranch("below");if(!w.some(R=>R.type==="prompt")&&e.mathfield.hasEditablePrompts)return p();jf(e,g,w,u,"down")}else return p();return!0}function X0(e){const i=e.position,r=e.at(i).parent;return r!=null&&r.parent?(e.position=e.offsetOf(r),e.mathfield.stopCoalescingUndo(),e.announce("move",i),!0):(e.announce("plonk"),!1)}function Ym(e){let i=0,r=e.at(e.position),a=!1;for(;r;)(!r.hasEmptyBranch("superscript")||!r.hasEmptyBranch("subscript"))&&(i+=1),r.hasEmptyBranch("superscript")?r.hasEmptyBranch("subscript")||(a=!1):a=!0,r=r.parent;return a?i:0}function Xm(e){let i=0,r=e.at(e.position),a=!1;for(;r;)(!r.hasEmptyBranch("superscript")||!r.hasEmptyBranch("subscript"))&&(i+=1),r.hasEmptyBranch("superscript")?r.hasEmptyBranch("subscript")||(a=!0):a=!1,r=r.parent;return a?i:0}function J0(e){var i;if(e.collapseSelection(),Ym(e)>=e.mathfield.options.scriptDepth[1])return e.announce("plonk"),!1;let r=e.at(e.position);return r.subsupPlacement===void 0&&(((i=r.rightSibling)==null?void 0:i.type)!=="subsup"&&r.parent.addChildAfter(new Al({style:r.computedStyle}),r),r=r.rightSibling),r.createBranch("superscript"),e.setSelection(e.getSiblingsRange(e.offsetOf(r.superscript[0]))),!0}function Q0(e){var i;if(e.collapseSelection(),Xm(e)>=e.mathfield.options.scriptDepth[0])return e.announce("plonk"),!1;let r=e.at(e.position);return r.subsupPlacement===void 0&&(((i=e.at(e.position+1))==null?void 0:i.type)!=="subsup"&&r.parent.addChildAfter(new Al({style:e.at(e.position).computedStyle}),r),r=e.at(e.position+1)),r.createBranch("subscript"),e.setSelection(e.getSiblingsRange(e.offsetOf(r.subscript[0]))),!0}function Jm(){function e(w){const E=[],R=[];return[...w.querySelectorAll(`input, select, textarea, a[href], button,
[tabindex], audio[controls], video[controls],
[contenteditable]:not([contenteditable="false"]), details>summary`)].filter(i).forEach((Z,ue)=>{const me=a(Z);me===0?E.push(Z):R.push({documentOrder:ue,tabIndex:me,node:Z})}),R.sort((Z,ue)=>Z.tabIndex===ue.tabIndex?Z.documentOrder-ue.documentOrder:Z.tabIndex-ue.tabIndex).map(Z=>Z.node).concat(E)}function i(w){return!(!r(w)||u(w)||a(w)<0)}function r(w){return!(w.disabled||w.type==="hidden"&&w.tagName.toUpperCase()==="INPUT"||b(w))}function a(w){var E;const R=Number.parseInt((E=w.getAttribute("tabindex"))!=null?E:"NaN",10);return Number.isNaN(R)?w.contentEditable==="true"||(w.nodeName==="AUDIO"||w.nodeName==="VIDEO")&&w.getAttribute("tabindex")===null?0:w.tabIndex:R}function u(w){return w.tagName.toUpperCase()==="INPUT"&&w.type==="radio"&&!g(w)}function p(w,E){for(const R of w)if(R.checked&&R.form===E)return R;return null}function g(w){var E;if(!w.name)return!0;const N=((E=w.form)!=null?E:w.ownerDocument).querySelectorAll('input[type="radio"][name="'+w.name+'"]'),Z=p(N,w.form);return!Z||Z===w}function b(w){if(!M()||w===document.activeElement||w.contains(document.activeElement))return!1;if(getComputedStyle(w).visibility==="hidden")return!0;const E=w.getBoundingClientRect();if(E.width===0||E.height===0)return!0;for(;w;){if(getComputedStyle(w).display==="none")return!0;w=w.parentElement}return!1}return M()?e(document.body):[]}function vs(e,i,r="forward"){const a=e.position;if(Array.isArray(i)){const u=e.offsetOf(i[0]),p=e.offsetOf(i[i.length-1]);return r==="forward"?e.setSelection(u,p):e.setSelection(p,u),e.announce("move",a),e.mathfield.stopCoalescingUndo(),!0}return r==="forward"?vs(e,[i.leftSibling,i]):vs(e,[i,i.leftSibling])}function ga(e,i){const r=e.position;if(typeof i=="number"&&(i=e.at(i)),i.type==="prompt")e.setSelection(e.offsetOf(i.firstChild),e.offsetOf(i.lastChild));else{const a=e.offsetOf(i);i.type==="placeholder"?e.setSelection(a-1,a):e.position=a}return e.announce("move",r),e.mathfield.stopCoalescingUndo(),!0}function qf(e,i,r=!0){var a,u;const p=i==="forward"?1:-1;e.at(e.anchor).type==="placeholder"&&Fa(e,i);let g;const b=e.at(e.anchor).parentPrompt;b?i==="forward"?g=e.offsetOf(b)+1:g=e.offsetOf(b.leftSibling):g=Math.max(e.position+p,0);const w=h0(e,g,i);if(!w||i==="forward"&&e.offsetOf(w)<g||i==="backward"&&e.offsetOf(w)>g){if(!r||!((u=(a=e.mathfield.host)==null?void 0:a.dispatchEvent(new CustomEvent("move-out",{detail:{direction:i},cancelable:!0,bubbles:!0,composed:!0})))==null||u))return e.announce("plonk"),!1;const R=Jm();if(!document.activeElement||R.length<=1)return e.announce("plonk"),!1;let N=R.indexOf(document.activeElement)+p;return N<0&&(N=R.length-1),N>=R.length&&(N=0),R[N].focus(),e.mathfield.stopCoalescingUndo(),!0}return ga(e,w),!0}function h0(e,i=0,r="forward"){return e.findAtom(a=>a.type==="placeholder"||a.type==="prompt"||!e.mathfield.readOnly&&a.treeDepth>2&&a.isFirstSibling&&a.isLastSibling,i,r)}ur({moveToOpposite:e=>{const i={superscript:"subscript",subscript:"superscript",above:"below",below:"above"},r=e.at(e.position),{parent:a}=r;if(!a)return e.announce("plonk"),!1;const u=r.parentBranch;let p;if(typeof u=="string"&&(p=i[u]),!p){const b=r.subsupPlacement?Q0(e):J0(e);return e.mathfield.stopCoalescingUndo(),b}a.branch(p)||a.createBranch(p);const g=e.setSelection(e.getBranchRange(e.offsetOf(a),p));return e.mathfield.stopCoalescingUndo(),g},moveBeforeParent:e=>{const{parent:i}=e.at(e.position);return i?(e.position=e.offsetOf(i),e.mathfield.stopCoalescingUndo(),!0):(e.announce("plonk"),!1)},moveAfterParent:e=>X0(e),moveToNextChar:e=>Fa(e,"forward"),moveToPreviousChar:e=>Fa(e,"backward"),moveUp:e=>Fa(e,"upward"),moveDown:e=>Fa(e,"downward"),moveToNextWord:e=>Yu(e,"forward"),moveToPreviousWord:e=>Yu(e,"backward"),moveToGroupStart:e=>{const i=e.offsetOf(e.at(e.position).firstSibling);return i===e.position?(e.announce("plonk"),!1):(e.position=i,e.mathfield.stopCoalescingUndo(),!0)},moveToGroupEnd:e=>{const i=e.offsetOf(e.at(e.position).lastSibling);return i===e.position?(e.announce("plonk"),!1):(e.position=i,e.mathfield.stopCoalescingUndo(),!0)},moveToNextGroup:e=>{var i,r,a,u;if(e.position===e.lastOffset&&e.anchor===e.lastOffset)return qf(e,"forward");const p=e.at(e.position);if(p.mode==="text"){if(e.selectionIsCollapsed){let Z=p;for(;Z&&Z.mode==="text";)Z=Z.leftSibling;let ue=p;for(;((i=ue.rightSibling)==null?void 0:i.mode)==="text";)ue=ue.rightSibling;if(Z&&ue)return vs(e,[Z,ue])}if(p.rightSibling.mode==="text"){let Z=p;for(;Z&&Z.mode==="text";)Z=Z.rightSibling;return Z?(ga(e,(r=Z.leftSibling)!=null?r:Z),e.mathfield.switchMode("math"),!0):ga(e,e.lastOffset)}}const b=e.at(e.anchor).parentPrompt,w=b?e.offsetOf(b)+1:Math.max(e.position+1,0),E=h0(e,w,"forward");if(E)return ga(e,E);const R=ep(e,p,Z=>Z.type==="leftright"||Z.type==="text","forward");if(R){if(R.mode==="text"){let Z=R;for(;Z&&Z.mode==="text";)Z=Z.rightSibling;return vs(e,[(a=R.leftSibling)!=null?a:R,(u=Z.leftSibling)!=null?u:Z])}return vs(e,R)}const N=p.parent;if(N){if(N.type==="leftright"||N.type==="surd")return vs(e,N);if(p.parentBranch==="superscript"&&N.subscript)return vs(e,N.subscript);if(p.parentBranch==="above"&&N.below)return vs(e,N.below);if(p.parentBranch==="superscript"||p.parentBranch==="subscript")return ga(e,N);if(p.parentBranch==="above"||p.parentBranch==="below")return vs(e,N)}return ga(e,e.lastOffset)},moveToPreviousGroup:e=>{var i;if(e.position===0&&e.anchor===0)return qf(e,"backward");let r=e.at(e.position);const a=r.mode;if(a==="text"){if(e.selectionIsCollapsed){let b=r;for(;b&&b.mode==="text";)b=b.leftSibling;let w=r;for(;((i=w.rightSibling)==null?void 0:i.mode)==="text";)w=w.rightSibling;if(b&&w)return vs(e,[b,w])}for(;r&&r.mode==="text";)r=r.leftSibling;return r?ga(e,r):ga(e,0)}const u=e.at(e.anchor).parentPrompt,p=u?e.offsetOf(u.leftSibling):Math.max(e.position-1,0),g=h0(e,p,"backward");if(g)return ga(e,g);if(a==="math"){const b=ep(e,r,E=>E.type==="leftright"||E.type==="text","backward");if(b){if(b.mode==="text"){let E=b;for(;E&&E.mode==="text";)E=E.leftSibling;return vs(e,[b,E])}return vs(e,b)}const w=r.parent;if(w){if(w.type==="leftright"||w.type==="surd")return vs(e,w);if(r.parentBranch==="subscript"&&w.superscript)return vs(e,w.superscript);if(r.parentBranch==="below"&&w.above)return vs(e,w.above);if(r.parentBranch==="superscript"||r.parentBranch==="subscript")return ga(e,w);if(r.parentBranch==="above"||r.parentBranch==="below")return vs(e,w)}return ga(e,0)}return!1},moveToMathfieldStart:e=>e.selectionIsCollapsed&&e.position===0?(e.announce("plonk"),!1):(e.position=0,e.mathfield.stopCoalescingUndo(),!0),moveToMathfieldEnd:e=>e.selectionIsCollapsed&&e.position===e.lastOffset?(e.announce("plonk"),!1):(e.position=e.lastOffset,e.mathfield.stopCoalescingUndo(),!0),moveToSuperscript:J0,moveToSubscript:Q0},{target:"model",changeSelection:!0}),ur({moveToNextPlaceholder:e=>qf(e,"forward"),moveToPreviousPlaceholder:e=>qf(e,"backward")},{target:"model",changeSelection:!0,audioFeedback:"return"});function ep(e,i,r,a){if(a==="forward"){let p=i.rightSibling;for(;p&&!r(p);)p=p.rightSibling;return p}let u=i.leftSibling;for(;u&&!r(u);)u=u.leftSibling;return u}function Zf(e,i,r){typeof i=="function"&&(r=i,i=1/0),i===void 0&&(i=1/0);let a=e.position,u=!1,p="";for(;!u;){const g=e.at(a);u=i===0||g===void 0||g.type==="first"||g.mode!=="math"||!(g.type&&/mord|mpunct|operator/.test(g.type)||g.type==="mop"&&/[a-zA-Z ]+/.test(g.value))||!g.hasEmptyBranch("superscript")||!g.hasEmptyBranch("subscript")||typeof r=="function"&&!r(g),u||(g.mode="text",g.command=g.value,g.verbatimLatex=void 0,p+=g.value),a-=1,i-=1}e.contentDidChange({data:p,inputType:"insertText"})}function Vl(e,i,r){typeof i=="function"&&(r=i,i=1/0),i===void 0&&(i=1/0);let a=e.position,u=!1;const p=[];for(;!u;){const g=e.at(a);u=i===0||!g||g.type==="first"||g.isFirstSibling||g.mode!=="text"||g.value===" "||typeof r=="function"&&!r(g),u||(p.push(et.serialize([g],{defaultMode:"math"})),g.mode="math"),a-=1,i-=1}f0(e),e.contentDidChange({data:sn(p),inputType:"insertText"})}function f0(e){var i;let r=e.position-1;for(;r>=0&&((i=e.at(r))==null?void 0:i.mode)==="math";)r-=1;if(!(r<0)&&e.at(r).mode==="text"&&e.at(r).value===" "&&e.at(r-1).mode==="math"){e.at(r-1).parent.removeChild(e.at(r-1));const a=e.silenceNotifications;e.silenceNotifications=!0,e.position-=1,e.silenceNotifications=a,e.contentDidChange({inputType:"deleteContent"})}}function Qm(e){let i="",r=e.position,a=!1;for(;!a;){const u=e.at(r);a=!(u&&(u.mode==="text"||u.mode==="math"&&u.type&&/mord|mpunct/.test(u.type))),a||(i=u.value+i),r-=1}return i}function eg(e,i,r){const{model:a}=e;if(a.mode==="latex"||!a.at(a.position).isLastSibling||!r||!l(r))return!1;const u=m(r);if(!a.selectionIsCollapsed)return!!(e.model.mode==="text"&&/[/_^]/.test(u));const p=Qm(a)+u;if(e.model.mode==="text"){if(i==="Esc"||/[/\\]/.test(u))return!0;if(/[\^_]/.test(u))return/(^|\s)[a-zA-Z][^_]$/.test(p)&&Vl(a,1),!0;const g={")":"(","}":"{","]":"["}[u],{parent:b}=a.at(a.position);if(g&&b instanceof Zn&&b.leftDelim===g)return!0;if(/(^|[^a-zA-Z])(a|I) $/.test(p))return!1;if(/[$€£₤₺¥¤฿¢₡₧₨₹₩₱]/u.test(u))return!0;if(/(^|[^a-zA-Z'])[a-zA-Z] $/.test(p))return Vl(a,1),!1;if(/\D\.[^\d\s]$/.test(p)){Vl(a,1);const w=a.at(a.position);return w.value="\u22C5",w.style.variant="normal",w.command="\\cdot",w.verbatimLatex=void 0,a.contentDidChange({data:"\\cdot",inputType:"insertText"}),!0}if(/(^|\s)[a-zA-Z][^a-zA-Z]$/.test(p)||/\.\d$/.test(p)||/\([\d+\-.]$/.test(p))return Vl(a,1),!0;if(/\([a-z][,;]$/.test(p))return Vl(a,2),!0;if(/[\d+\-=><*|]$/.test(u))return f0(a),!0}else{if(i==="[Space]")return Zf(a,void 0,g=>/[a-z][:,;.]$/.test(g.value)),!0;if(/[a-zA-Z]{3,}$/.test(p)&&!/(dxd|abc|xyz|uvw)$/.test(p))return Zf(a,void 0,g=>/[a-zA-Z]/.test(g.value)),!0;if(/(^|\W)(if)$/i.test(p))return Zf(a,1),!0;if(/(\u0393|\u0394|\u0398|\u039B|\u039E|\u03A0|\u03A3|\u03A5|\u03A6|\u03A8|\u03A9|[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5){3,}$/u.test(p)&&!/(αβγ)$/.test(p))return Zf(a,void 0,g=>/(:|,|;|.|\u0393|\u0394|\u0398|\u039B|\u039E|\u03A0|\u03A3|\u03A5|\u03A6|\u03A8|\u03A9|[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5)/u.test(g.value)),!0;if(u==="?"||u==="."&&!/[\d-+]\.$/.test(p))return!0}return!1}function tg(e,i){if(!e.isSelectionEditable||!e.keystrokeCaptionVisible)return;const r=tp(),a=e.element.getBoundingClientRect();r.style.left=`${a.left}px`,r.style.top=`${a.top-64}px`,r.innerHTML=window.MathfieldElement.createHTML("<span>"+(h(i)||i)+"</span>"+r.innerHTML),r.style.visibility="visible",setTimeout(()=>{r.childNodes.length>0&&r.childNodes[r.childNodes.length-1].remove(),r.childNodes.length===0&&(r.style.visibility="hidden")},3e3)}function ig(e){if(e.keystrokeCaptionVisible=!e.keystrokeCaptionVisible,e.keystrokeCaptionVisible){const i=tp();i.innerHTML=""}else{const i=Fe("mathlive-keystroke-caption-panel");i.style.visibility="hidden"}return!1}function tp(){const e=document.getElementById("mathlive-keystroke-caption-panel");return e||(ca("keystroke-caption"),ca("core"),Fe("mathlive-keystroke-caption-panel"))}function ng(){document.getElementById("mathlive-keystroke-caption-panel")&&(bt("mathlive-keystroke-caption-panel"),Da("core"),Da("keystroke-caption"))}function ip(e,i){var r,a,u;const{model:p}=e,g=v(i);if(i.isTrusted){Pf(i);const ue=Ol();e.keyboardLayout!==ue.id&&(e.keyboardLayout=ue.id,e._keybindings=void 0)}if(clearTimeout(e.inlineShortcutBufferFlushTimer),e.inlineShortcutBufferFlushTimer=0,tg(e,g),i.isTrusted&&i.defaultPrevented)return e.flushInlineShortcutBuffer(),!1;let b,w="",E;const R=e.inlineShortcutBuffer;if(e.isSelectionEditable){if(p.mode==="math")if(g==="[Backspace]")R.pop();else if(!l(i))e.flushInlineShortcutBuffer();else{const ue=m(i),me=[...(a=(r=R[R.length-1])==null?void 0:r.keystrokes)!=null?a:[],ue];R.push({state:p.getState(),keystrokes:me,leftSiblings:rg(e)});let Ve=0,Ct="";for(;!b&&Ve<me.length;)E=R.length-(me.length-Ve),Ct=me.slice(Ve).join(""),b=Sl(R[E].leftSiblings,Ct,e.options.inlineShortcuts),!b&&/^[a-zA-Z][a-zA-Z0-9]+?([_\^][a-zA-Z0-9\*\+\-]+?)?$/.test(Ct)&&(b=e.options.onInlineShortcut(e,Ct)),Ve+=1;e.flushInlineShortcutBuffer({defer:!0})}e.options.smartMode&&(b?e.switchMode("math"):eg(e,g,i)&&(e.switchMode({math:"text",text:"math"}[p.mode]),w=""))}if(!b){if(w||(w=x(e.keybindings,p.mode,i)),!w&&(g==="[Enter]"||g==="[Return]")){let ue=!1;return p.contentWillChange({inputType:"insertLineBreak"})&&(e.host&&(ue=!e.host.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))),ue||i.preventDefault&&(i.preventDefault(),i.stopPropagation()),p.contentDidChange({inputType:"insertLineBreak"})),ue}if((!w||g==="[Space]")&&p.mode==="math"){if(g==="[Space]"){if(e.adoptStyle="none",e.flushInlineShortcutBuffer(),e.options.mathModeSpace)return qn.insert(p,e.options.mathModeSpace,{format:"latex",mode:"math"}),e.snapshot("insert-space"),w="",e.dirty=!0,e.scrollIntoView(),i.preventDefault&&(i.preventDefault(),i.stopPropagation()),!1;const ue=p.at(p.position+1),me=p.at(p.position-1);if((ue==null?void 0:ue.mode)==="text"||(me==null?void 0:me.mode)==="text")return qn.insert(p," ",{mode:"text"}),e.snapshot("insert-space"),e.dirty=!0,e.scrollIntoView(),!1}(u=p.at(p.position))!=null&&u.isDigit()&&window.MathfieldElement.decimalSeparator===","&&m(i)===","&&(w="insertDecimalSeparator")}}if(!b&&!w){if(p.mathfield.smartFence){if(p0(p,m(i),e.effectiveStyle))return e.dirty=!0,e.scrollIntoView(),i.preventDefault&&i.preventDefault(),!1}else{const{parent:ue}=p.at(p.position);if(ue instanceof Zn&&ue.rightDelim==="?"&&p.at(p.position).isLastSibling&&/^[)}\]|]$/.test(g))return e.snapshot(),ue.isDirty=!0,ue.rightDelim=g,p.position+=1,p.selectionDidChange(),p.contentDidChange({data:m(i),inputType:"insertText"}),e.snapshot("insert-fence"),e.dirty=!0,e.scrollIntoView(),i.preventDefault&&i.preventDefault(),!1;if(!p.selectionIsCollapsed){const me=m(i);if(me==="("||me==="{"||me==="["){const Ve={"(":"(","{":"\\lbrace","[":"\\lbrack"}[me],Ct={"(":")","{":"\\rbrace","[":"\\rbrack"}[me],[Ue,ct]=Fr(p.selection);return e.snapshot(),p.position=ct,qn.insert(p,Ct,{format:"latex"}),p.position=Ue,qn.insert(p,Ve,{format:"latex"}),p.setSelection(Ue+1,ct+1),p.contentDidChange({data:me,inputType:"insertText"}),e.snapshot("insert-fence"),e.dirty=!0,e.scrollIntoView(),i.preventDefault&&i.preventDefault(),!1}}}return!0}const N=p.at(Math.max(p.position,p.anchor)),{parent:Z}=N;if(w==="moveAfterParent"&&(Z==null?void 0:Z.type)==="leftright"&&N.isLastSibling&&e.options.smartFence&&p0(p,".",e.defaultStyle)&&(w="",wn(e)),e.keyboardDelegate.cancelComposition(),w)e.executeCommand(w);else if(b){const ue=e.effectiveStyle;p.setState(R[E].state);const me=R[R.length-1].keystrokes;for(const Ve of me)qn.insert(p,Ve,{silenceNotifications:!0,style:ue});e.snapshot("insert-shortcut"),p.setState(R[E].state),p.deferNotifications({content:!0,selection:!0,data:b,type:"insertText"},()=>(qn.insert(p,b,{format:"latex",style:ue}),f0(e.model),b.endsWith(" ")&&(e.switchMode("text"),qn.insert(p," ",{style:ue,mode:"text"})),e.snapshot(),p.selectionIsCollapsed||e.flushInlineShortcutBuffer(),!0)),e.dirty=!0,p.announce("replacement")}return e.scrollIntoView(),i.preventDefault&&i.preventDefault(),!1}function d0(e,i,r){const{model:a}=e;if(!e.isSelectionEditable){a.announce("plonk");return}r!=null||(r={}),r.focus&&e.focus(),r.feedback&&window.MathfieldElement.playSound("keypress"),typeof r.mode=="string"&&(e.switchMode(r.mode),e.snapshot());let u=tf(i);const p=window.mathVirtualKeyboard;if(p!=null&&p.isShifted&&(u=typeof u=="string"?u.toUpperCase():u.map(w=>w.toUpperCase())),r.simulateKeystroke){let w=!0;for(const E of u)ip(e,new KeyboardEvent("keypress",{key:E}))&&(w=!1);if(w)return}const g=a.at(a.position),b=P(P({},g.computedStyle),e.defaultStyle);if(a.selectionIsCollapsed||(a.deleteAtoms(Fr(a.selection)),e.snapshot("delete")),a.mode==="latex")a.deferNotifications({content:!0,selection:!0,data:i,type:"insertText"},()=>{Qe(e);for(const w of u)qn.insert(a,w);e.snapshot("insert-latex"),Pe(e)});else if(a.mode==="text"){for(const w of u)qn.insert(a,w,{style:b});e.snapshot("insert-text")}else if(a.mode==="math")for(const w of u)sg(e,w,b,g);e.dirty=!0,e.scrollIntoView()}function rg(e){const i=e.model,r=[];let a=i.at(Math.min(i.position,i.anchor));for(;a.type!=="first";)r.push(a),a=a.leftSibling;return r}function sg(e,i,r,a){const u=e.model;let p={"^":"moveToSuperscript",_:"moveToSubscript"," ":"moveAfterParent"}[i];if(i===" "&&e.options.mathModeSpace&&(p=["insert",e.options.mathModeSpace]),p){e.executeCommand(p);return}if(/\d/.test(i)&&e.options.smartSuperscript&&a.parentBranch==="superscript"&&a.parent.type!=="mop"&&a.parent.type!=="operator"&&a.parent.type!=="extensible-symbol"&&a.hasNoSiblings){ag(u),qn.insert(u,i,{style:r}),e.snapshot(),X0(u),e.snapshot();return}if(/[a-zA-Z0-9]/.test(i)&&e.adoptStyle!=="none"){const g=e.adoptStyle==="left"?a:a.parent?a.rightSibling:null;(g==null?void 0:g.type)==="mord"&&/[a-zA-Z0-9]/.test(g.value)&&(r=P({},r),g.style.variant&&(r.variant=g.style.variant),g.style.variantStyle&&(r.variantStyle=g.style.variantStyle))}qn.insert(u,i,{style:r}),e.snapshot(`insert-${u.at(u.position).type}`)}function ag(e){e.selectionIsCollapsed||(e.deleteAtoms(Fr(e.selection)),e.mathfield.snapshot("delete"))}function p0(e,i,r){if(!i||e.mode!=="math")return!1;const a=e.at(e.position),{parent:u}=a,p={"(":"(",")":")","{":"\\lbrace","}":"\\rbrace","[":"\\lbrack","]":"\\rbrack","|":"|"}[i];if(!p)return!1;const g=co[p],b=ha[p];if(!e.selectionIsCollapsed){e.mathfield.snapshot();const[w,E]=Fr(e.selection),R=e.extractAtoms([w,E]),N=u.addChildrenAfter([new Zn("left...right",R,{leftDelim:p,rightDelim:b})],e.at(w));return e.setSelection(e.offsetOf(N.firstChild),e.offsetOf(N.lastChild)),e.mathfield.snapshot("insert-fence"),e.contentDidChange({data:p,inputType:"insertText"}),!0}if(p==="|"){const w=u instanceof Zn?u.leftDelim+u.rightDelim:"";if(w==="\\lbrace\\rbrace"||w==="\\{\\}"||w==="\\lbrace?")return e.mathfield.snapshot(),qn.insert(e,"\\,\\middle\\vert\\,",{format:"latex",style:r}),e.mathfield.snapshot("insert-fence"),e.contentDidChange({data:p,inputType:"insertText"}),!0}if(b){if(u instanceof Zn&&u.firstChild===a&&(u.leftDelim==="?"||u.leftDelim==="."))return u.leftDelim=p,u.isDirty=!0,e.mathfield.snapshot(),e.contentDidChange({data:p,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0;if(!(u instanceof Zn)){let N=a;for(;N&&!(N.type==="mclose"&&N.value===b);)N=N.rightSibling;if(N){e.mathfield.snapshot();const Z=e.extractAtoms([e.offsetOf(a),e.offsetOf(N)]);return Z.pop(),u.addChildrenAfter([new Zn("left...right",Z,{leftDelim:p,rightDelim:b})],a),e.position=e.offsetOf(u.firstChild)+1,e.contentDidChange({data:p,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0}}const w=e.offsetOf(a.lastSibling);let E;for(E=e.position;E<=w;E++){const N=e.at(E);if(N instanceof Zn&&(N.leftDelim==="?"||N.leftDelim===".")&&np(p,N.rightDelim))break}const R=e.at(E);if(E<=w&&R instanceof Zn){R.leftDelim=p,e.mathfield.snapshot();let N=e.extractAtoms([e.position,E-1]);return N=N.filter(Z=>Z.type!=="first"),R.addChildren(N,R.parentBranch),e.position+=1,e.contentDidChange({data:p,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0}if(u instanceof Zn&&(u.leftDelim==="?"||u.leftDelim===".")&&np(p,u.rightDelim)){u.isDirty=!0,u.leftDelim=p,e.mathfield.snapshot();const N=e.extractAtoms([e.offsetOf(a.firstSibling),e.position]);for(const Z of N)u.parent.addChildBefore(Z,u);return e.contentDidChange({data:p,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0}if(!(u instanceof Zn&&u.leftDelim==="|")){if(e.mathfield.snapshot(),qn.insert(e,`\\left${p}\\right?`,{format:"latex",style:r}),a.lastSibling.type!=="first"){const N=e.offsetOf(a.lastSibling),Z=e.extractAtoms([e.position,N]);e.at(e.position).body=Z,e.position-=1}return e.mathfield.snapshot("insert-fence"),!0}}if(g){let w=a;for(;w;){if(w.type==="mopen"&&w.value===g){e.mathfield.snapshot();const ue=w.leftSibling,me=e.extractAtoms([e.offsetOf(w.leftSibling),e.offsetOf(a)]);me.shift();const Ve=new Zn("left...right",me,{leftDelim:g,rightDelim:p});return u.addChildrenAfter([Ve],ue),e.position=e.offsetOf(Ve),e.contentDidChange({data:p,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0}w=w.leftSibling}if(u instanceof Zn&&a.isLastSibling&&m0(u.leftDelim,p))return e.mathfield.snapshot(),u.isDirty=!0,u.rightDelim=p,e.position+=1,e.contentDidChange({data:p,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0;const E=e.offsetOf(a.firstSibling);let R;for(R=e.position;R>=E;R--){const ue=e.at(R);if(ue instanceof Zn&&(ue.rightDelim==="?"||ue.rightDelim===".")&&m0(ue.leftDelim,p))break}const N=e.at(R);if(R>=E&&N instanceof Zn)return e.mathfield.snapshot(),N.rightDelim=p,N.addChildren(e.extractAtoms([R,e.position]),N.parentBranch),e.contentDidChange({data:p,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0;if(u instanceof Zn&&(u.rightDelim==="?"||u.rightDelim===".")&&m0(u.leftDelim,p))return e.mathfield.snapshot(),u.isDirty=!0,u.rightDelim=p,u.parent.addChildren(e.extractAtoms([e.position,e.offsetOf(a.lastSibling)]),u.parentBranch),e.position=e.offsetOf(u),e.contentDidChange({data:p,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0;const Z=u.parent;return Z instanceof Zn&&(Z.rightDelim==="?"||Z.rightDelim===".")&&e.at(e.position).isLastSibling?(e.position=e.offsetOf(Z),p0(e,p,r)):!1}return!1}function m0(e,i){return e?["(","\\lparen","{","\\{","\\lbrace","[","\\lbrack"].includes(e)?[")","\\rparen","}","\\}","\\rbrace","]","\\rbrack"].includes(i):ha[e]===i:!0}function np(e,i){return i?[")","\\rparen","}","\\}","\\rbrace","]","\\rbrack"].includes(i)?["(","\\lparen","{","\\{","\\lbrace","[","\\lbrack"].includes(e):co[i]===e:!0}ur({undo:e=>(e.undo(),!0),redo:e=>(e.redo(),!0),scrollIntoView:e=>(e.scrollIntoView(),!0),scrollToStart:e=>(e.field.scroll(0,0),!0),scrollToEnd:e=>{const i=e.field.getBoundingClientRect();return e.field.scroll(i.left-window.scrollX,0),!0},toggleKeystrokeCaption:ig,toggleContextMenu:e=>{const i=e.toggleContextMenu();return i||e.model.announce("plonk"),i},plonk:e=>(e.model.announce("plonk"),!0),switchMode:(e,i,r,a)=>(e.switchMode(i,r,a),!0),insert:(e,i,r)=>e.insert(i,r),typedText:(e,i,r)=>(d0(e,i,r),!0),insertDecimalSeparator:e=>{const i=e.model;return i.mode==="math"&&window.MathfieldElement.decimalSeparator===","&&i.at(Math.max(i.position,i.anchor)).isDigit()?(e.insert("{,}",{format:"latex"}),e.snapshot("insert-mord"),!0):(e.insert("."),!0)},commit:e=>{var i;return e.model.contentWillChange({inputType:"insertLineBreak"})&&((i=e.host)==null||i.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),e.model.contentDidChange({inputType:"insertLineBreak"})),!0},insertPrompt:(e,i,r)=>{const a=e.getPrompts();let u="prompt-"+Date.now().toString(36).slice(-2)+Math.floor(Math.random()*1e5).toString(36),p=0;for(;a.includes(u)&&p<100;){if(p===99)return console.error("could not find a unique ID after 100 tries"),!1;u="prompt-"+Date.now().toString(36).slice(-2)+Math.floor(Math.random()*1e5).toString(36),p++}return e.insert(`\\placeholder[${i!=null?i:u}]{}`,r),!0}}),ur({copyToClipboard:e=>(e.focus(),e.model.selectionIsCollapsed&&e.select(),"queryCommandSupported"in document&&document.queryCommandSupported("copy")?document.execCommand("copy"):e.element.querySelector(".ML__keyboard-sink").dispatchEvent(new ClipboardEvent("copy",{bubbles:!0,composed:!0})),!1)},{target:"mathfield"}),ur({cutToClipboard:e=>(e.focus(),"queryCommandSupported"in document&&document.queryCommandSupported("cut")?document.execCommand("cut"):e.element.querySelector(".ML__keyboard-sink").dispatchEvent(new ClipboardEvent("cut",{bubbles:!0,composed:!0})),!0),pasteFromClipboard:e=>(e.focus(),"queryCommandSupported"in document&&document.queryCommandSupported("paste")?(document.execCommand("paste"),!0):(navigator.clipboard.readText().then(i=>{i&&e.model.contentWillChange({inputType:"insertFromPaste",data:i})?(e.stopCoalescingUndo(),e.stopRecording(),e.insert(i,{mode:e.model.mode})&&(Pe(e),e.startRecording(),e.snapshot("paste"),e.model.contentDidChange({inputType:"insertFromPaste"}),wn(e))):e.model.announce("plonk"),e.startRecording()}),!0))},{target:"mathfield",canUndo:!0,changeContent:!0,changeSelection:!0});function og(e,i){e.flushInlineShortcutBuffer(),e.stopCoalescingUndo();const r=g0(e,i),{model:a}=e;return a.selectionIsCollapsed?(e.defaultStyle.fontSeries&&r.fontSeries===e.defaultStyle.fontSeries&&(r.fontSeries="auto"),r.fontShape&&r.fontShape===e.defaultStyle.fontShape&&(r.fontShape="auto"),r.color&&r.color===e.defaultStyle.color&&(r.color="none"),r.backgroundColor&&r.backgroundColor===e.defaultStyle.backgroundColor&&(r.backgroundColor="none"),r.fontSize&&r.fontSize===e.defaultStyle.fontSize&&(r.fontSize="auto"),e.defaultStyle=P(P({},e.defaultStyle),r)):e.model.deferNotifications({content:!0,type:"insertText"},()=>{a.selection.ranges.forEach(u=>l0(a,u,r,{operation:"toggle"})),e.snapshot("style-change")}),!0}ur({applyStyle:og},{target:"mathfield",canUndo:!0,changeContent:!0});function g0(e,i){var r,a,u,p,g,b,w,E,R,N;const Z={};if(typeof i.color=="string"){const me=(a=e.colorMap((r=i.color)!=null?r:i.verbatimColor))!=null?a:"none";me!==i.color&&(Z.verbatimColor=(u=i.verbatimColor)!=null?u:i.color),Z.color=me}if(typeof i.backgroundColor=="string"){const me=(g=e.backgroundColorMap((p=i.backgroundColor)!=null?p:i.verbatimBackgroundColor))!=null?g:"none";me!==i.backgroundColor&&(Z.verbatimBackgroundColor=(b=i.verbatimBackgroundColor)!=null?b:i.backgroundColor),Z.backgroundColor=me}typeof i.fontFamily=="string"&&(Z.fontFamily=i.fontFamily),typeof i.series=="string"&&(Z.fontSeries=i.series),typeof i.fontSeries=="string"&&(Z.fontSeries=i.fontSeries.toLowerCase()),Z.fontSeries&&(Z.fontSeries=(w={bold:"b",medium:"m",normal:"m"}[Z.fontSeries])!=null?w:Z.fontSeries),typeof i.shape=="string"&&(Z.fontShape=i.shape),typeof i.fontShape=="string"&&(Z.fontShape=i.fontShape.toLowerCase()),Z.fontShape&&(Z.fontShape=(E={italic:"it",up:"n",upright:"n",normal:"n"}[Z.fontShape])!=null?E:Z.fontShape),i.variant&&(Z.variant=i.variant.toLowerCase()),i.variantStyle&&(Z.variantStyle=i.variantStyle.toLowerCase());const ue=(R=i.size)!=null?R:i.fontSize;return typeof ue=="number"?Z.fontSize=Math.max(1,Math.min(10,ue)):typeof ue=="string"&&(Z.fontSize=(N={size1:1,size2:2,size3:3,size4:4,size5:5,size6:6,size7:7,size8:8,size9:9,size10:10}[ue.toLowerCase()])!=null?N:{tiny:1,scriptsize:2,footnotesize:3,small:4,normal:5,normalsize:5,large:6,Large:7,LARGE:8,huge:9,Huge:10}[ue]),Z}function _0(e){let[i,r]=Fr(e.selection);if(i=rp(e,i,"backward"),r=rp(e,r,"forward"),i===r){const a=e.at(i);if(a.type==="leftright")return e.setSelection(e.offsetOf(a.firstChild)-1,r);if(a.type==="first"&&(a.parent.type==="leftright"||a.parent.type==="surd"))return e.setSelection(i-1,e.offsetOf(a.parent.lastChild)+1);e.setSelection(i-1,r)}else e.setSelection(i,r);return!0}function rp(e,i,r){var a,u,p;let g=e.at(i);if(!g)return i;const b=r==="forward"?1:-1;if(g.mode==="text"){for(;g&&!(g.mode!=="text"||!nt.test(g.value));)i+=b,g=e.at(i);return r==="backward"?i-1:i}if(g.mode==="latex"){if(/[a-zA-Z\*]/.test(g.value))if(r==="backward")for(;g&&g.mode==="latex"&&g.value!=="\\"&&/[a-zA-Z]/.test(g.value);)i+=b,g=e.at(i);else for(;g&&g.mode==="latex"&&/[a-zA-Z\*]/.test(g.value);)i+=b,g=e.at(i);else if(g.value==="{"){if(r==="forward"){for(;g&&g.mode==="latex"&&g.value!=="}";)i+=b,g=e.at(i);return i}return i-1}else if(g.value==="}"){if(r==="backward"){for(;g&&g.mode==="latex"&&g.value!=="{";)i+=b,g=e.at(i);return i-1}return i}return i-1}if(g.mode==="math"){if(g.isDigit()){for(;(a=e.at(i+b))!=null&&a.isDigit();)i+=b;return r==="backward"?i-1:i}if(g.style.variant||g.style.variantStyle){let w=(u=e.at(i))==null?void 0:u.style;for(;w&&w.variant===g.style.variant&&w.variantStyle===g.style.variantStyle;)w=(p=e.at(i+b))==null?void 0:p.style,i+=b;return r==="backward"?i-1:i}return i}return i}ur({selectGroup:e=>{const i=_0(e);return i||e.announce("plonk"),i},selectAll:e=>e.setSelection(0,e.lastOffset),extendSelectionForward:e=>Fa(e,"forward",{extend:!0}),extendSelectionBackward:e=>Fa(e,"backward",{extend:!0}),extendToNextWord:e=>Yu(e,"forward",{extend:!0}),extendToPreviousWord:e=>Yu(e,"backward",{extend:!0}),extendSelectionUpward:e=>Fa(e,"upward",{extend:!0}),extendSelectionDownward:e=>Fa(e,"downward",{extend:!0}),extendToNextBoundary:e=>Yu(e,"forward",{extend:!0}),extendToPreviousBoundary:e=>Yu(e,"backward",{extend:!0}),extendToGroupStart:e=>{const i=e.setSelection(e.anchor,e.offsetOf(e.at(e.position).firstSibling));return i||e.announce("plonk"),i},extendToGroupEnd:e=>{const i=e.setSelection(e.anchor,e.offsetOf(e.at(e.position).lastSibling));return i||e.announce("plonk"),i},extendToMathFieldStart:e=>{const i=e.setSelection(e.anchor,0);return i||e.announce("plonk"),i},extendToMathFieldEnd:e=>{const i=e.setSelection(e.anchor,e.lastOffset);return i||e.announce("plonk"),i}},{target:"model",changeSelection:!0});var Gl=null,lh=0,Yf=class ia{static start(i,r,a,u){var p;ia.element=i,(p=ia.controller)==null||p.abort(),ia.controller=new AbortController;const g={signal:ia.controller.signal};"PointerEvent"in window?(i.addEventListener("pointermove",a,g),i.addEventListener("pointerup",u,g),i.addEventListener("pointercancel",u,g),v0(r)&&(ia.pointerId=r.pointerId,i.setPointerCapture(r.pointerId))):(window.addEventListener("mousemove",a,g),window.addEventListener("blur",u,g),window.addEventListener("mouseup",u,g))}static stop(){var i;(i=ia.controller)==null||i.abort(),ia.controller=void 0,typeof ia.pointerId=="number"&&(ia.element.releasePointerCapture(ia.pointerId),ia.pointerId=void 0)}};function v0(e){return e!==null&&globalThis.PointerEvent!==void 0&&e instanceof PointerEvent}function sp(e,i){var r;if(i.buttons>1)return;e.atomBoundsCache=new Map;const a=e;let u,p=!1,g=!1,b="none",w=!1,E=!1;const R=i.clientX,N=i.clientY,Z=Date.now(),ue=a.field,me=setInterval(()=>{w?ue.scroll({top:0,left:ue.scrollLeft-16}):E&&ue.scroll({top:0,left:ue.scrollLeft+16})},32);function Ve(){Yf.stop(),p=!1,clearInterval(me),e.element.classList.remove("tracking"),i&&i.preventDefault()}function Ct(ct){if(!a.hasFocus()){Ve();return}const It=ct.clientX,yt=ct.clientY,ei=v0(ct)&&ct.pointerType==="touch"?20:5;if(Date.now()<Z+500&&Math.abs(R-It)<ei&&Math.abs(N-yt)<ei){ct.preventDefault(),ct.stopPropagation();return}const hi=ue.getBoundingClientRect();E=It>hi.right,w=It<hi.left;let ai=u;v0(ct)&&(ct.isPrimary||(ai=uh(a,ct.clientX,ct.clientY,{bias:0})));const on=uh(a,It,yt,{bias:It<=R?It===R?0:-1:1});ai>=0&&on>=0&&(a.model.extendSelectionTo(ai,on),wn(e)),g&&_0(a.model)}Gl&&Math.abs(Gl.x-R)<5&&Math.abs(Gl.y-N)<5&&Date.now()<Gl.time+500?(lh+=1,Gl.time=Z):(Gl={x:R,y:N,time:Z},lh=1);const Ue=ue.getBoundingClientRect();if(R>=Ue.left&&R<=Ue.right&&N>=Ue.top&&N<=Ue.bottom){if(e.flushInlineShortcutBuffer(),e.adoptStyle="left",u=uh(e,R,N,{bias:0}),u>=0){if(e.element.classList.add("tracking"),i.shiftKey){const ct=e.model.selectionIsCollapsed;e.model.extendSelectionTo(e.model.anchor,u),Ze(e.model)||ct?b="all":b="selection"}else e.model.at(u).type==="placeholder"?(e.model.setSelection(u-1,u),b="selection"):((r=e.model.at(u).rightSibling)==null?void 0:r.type)==="placeholder"?(e.model.setSelection(u,u+1),b="selection"):(e.model.position=u,Ze(e.model)?b="all":b="selection");e.defaultStyle={},i.detail===3||lh>2?(Ve(),(i.detail===3||lh===3)&&(e.model.selection={ranges:[[0,e.model.lastOffset]]},b="all")):p||(p=!0,Yf.start(ue,i,Ct,Ve),(i.detail===2||lh===2)&&(g=!0,_0(e.model),b="all"))}e.hasFocus()||(b="none",e.focus({preventScroll:!0}))}else Gl=null;e.stopCoalescingUndo(),b!=="none"&&(e.model.selectionIsCollapsed&&(b="all"),wn(e)),i.preventDefault()}function lg(e,i,r){if(e>=r.left&&e<=r.right&&i>=r.top&&i<=r.bottom)return 0;const a=e-(r.left+r.right)/2,u=i-(r.top+r.bottom)/2;return a*a+u*u}function ap(e,i,r,a,u){if(!r.id)return[1/0,null];if(i.has(r.id))return i.get(r.id);const p=kl(e,r);if(!p)return[1/0,null];let g=[1/0,null];if(r.hasChildren&&!r.captureSelection&&a>=p.left&&a<=p.right)for(const b of r.children){const w=ap(e,i,b,a,u);w[0]<=g[0]&&(g=w)}return g[1]||(g=[lg(a,u,p),r]),i.set(r.id,g),g}function ug(e,i,r){const[,a]=ap(e,new Map,e.model.root,i,r);return a}function uh(e,i,r,a){var u;const p=e.field.querySelector(".ML__latex").getBoundingClientRect();if(!p)return 0;if(i>p.right||r>p.bottom+8)return e.model.lastOffset;if(i<p.left||r<p.top-8)return 0;a=a!=null?a:{},a.bias=(u=a.bias)!=null?u:0;let g=ug(e,i,r);const b=[];let w=g;for(;w;)b.unshift(w),w=w.parent;for(const R of b)if(R.captureSelection){g=R;break}let E=e.model.offsetOf(g);if(E<0)return-1;if(g.leftSibling)if(a.bias===0&&g.type!=="placeholder"){const R=kl(e,g);R&&i<(R.left+R.right)/2&&(E=e.model.offsetOf(g.leftSibling))}else a.bias<0&&(E=e.model.offsetOf(g.leftSibling));return E}var cg=class extends qn{constructor(){super("math")}onPaste(e,i){if(!i||!e.model.contentWillChange({data:typeof i=="string"?i:null,dataTransfer:typeof i=="string"?null:i,inputType:"insertFromPaste"}))return!1;let r="",a="auto",u=typeof i!="string"?i.getData("application/json+mathlive"):"";if(u)try{const p=JSON.parse(u);if(p&&Array.isArray(p)){e.snapshot();const g=Pa(p),{model:b}=e;b.selectionIsCollapsed||b.deleteAtoms(Fr(b.selection));const w=b.at(b.position);if(w.parent instanceof Tn){console.assert(w.parentBranch!==void 0);const E=[];let R=[];g[0].type==="first"&&g.shift(),g[g.length-1].type==="first"&&g.pop();for(const me of g)me.type==="first"&&R.length>0?(E.push(R),R=[me]):R.push(me);R.length>0&&E.push(R);let N=Number(w.parentBranch[0]),Z=Number(w.parentBranch[1]);const ue=w.parent.maxColumns;for(;w.parent.colCount-Z<E.length&&w.parent.colCount<ue;)w.parent.addColumn();w.parent.addChildrenAfter(E[0],w);for(let me=1;me<E.length;me++)Z++,Z>=ue&&(Z=0,w.parent.addRowAfter(N),N++),w.parent.setCell(N,Z,E[me])}else w.parent.addChildrenAfter(g.filter(E=>E.type!=="first"),w);return b.position=b.offsetOf(g[g.length-1]),b.contentDidChange({inputType:"insertFromPaste"}),wn(e),!0}}catch(p){}if(u=typeof i!="string"?i.getData("application/json"):"",u&&window.MathfieldElement.computeEngine)try{const p=JSON.parse(u);if(typeof p=="object"&&"latex"in p&&p.latex&&(r=p.latex),!r){const g=window.MathfieldElement.computeEngine.box(p);g&&!g.has("Error")&&(r=g.latex)}r||(a="latex")}catch(p){}if(!r&&typeof i!="string"&&(r=i.getData("application/x-latex"),r&&(a="latex")),r||(r=typeof i=="string"?i:i.getData("text/plain")),r){let p;return[p,r]=Nc(r),a==="auto"&&p&&(a="latex"),e.stopCoalescingUndo(),e.stopRecording(),this.insert(e.model,r,{format:a})&&(e.startRecording(),e.snapshot("paste"),wn(e)),e.startRecording(),!0}return!1}insert(e,i,r){var a,u;const p=typeof i=="string"?i:(u=(a=window.MathfieldElement.computeEngine)==null?void 0:a.box(i).latex)!=null?u:"";if(!r.silenceNotifications&&!e.contentWillChange({data:p,inputType:"insertText"}))return!1;r.insertionMode||(r.insertionMode="replaceSelection"),r.selectionMode||(r.selectionMode="placeholder"),r.format||(r.format="auto");const{silenceNotifications:g}=e;r.silenceNotifications&&(e.silenceNotifications=!0);const b=e.silenceNotifications;e.silenceNotifications=!0;const w={"?":"\\placeholder{}","@":"\\placeholder{}"};w[0]=r.insertionMode==="replaceAll"?"":e.getValue(e.selection,"latex-unstyled"),r.insertionMode==="replaceSelection"&&!e.selectionIsCollapsed?e.deleteAtoms(Fr(e.selection)):r.insertionMode==="replaceAll"?(e.root.setChildren([],"body"),e.position=0):r.insertionMode==="insertBefore"?e.collapseSelection("backward"):r.insertionMode==="insertAfter"&&e.collapseSelection("forward"),!e.at(e.position).isLastSibling&&e.at(e.position+1).type==="placeholder"?e.deleteAtoms([e.position,e.position+1]):e.at(e.position).type==="placeholder"&&e.deleteAtoms([e.position-1,e.position]);let E=-1;w[0]?w["@"]=w[0]:typeof i=="string"&&/(^|[^\\])#@/.test(i)&&(E=fg(e),E>=0&&(w["@"]=e.getValue(E,e.position,"latex"))),w[0]||(w[0]=w["?"]);let R=!1;const N=It=>(R=!0,w[It]);let[Z,ue]=op(e,i,N,r);if(!ue)return!1;const me=ue.length===1&&ue[0].type==="genfrac";me&&E>=0&&typeof e.mathfield.options.isImplicitFunction=="function"&&e.mathfield.options.isImplicitFunction(e.at(e.position).command)?(w["@"]=w["?"],R=!1,[Z,ue]=op(e,i,N,r)):E>=0&&e.deleteAtoms([E,e.position]);const{parent:Ve}=e.at(e.position),Ct=Ve.hasEmptyBranch("body");if(me&&Z!=="latex"&&e.mathfield.options.removeExtraneousParentheses&&Ve instanceof Zn&&Ve.leftDelim==="("&&Ct){const It=Ve.parent,yt=Ve.parentBranch;It.removeChild(Ve),It.setChildren(ue,yt)}const Ue=e.at(e.position);Ue.parent.addChildrenAfter(ue,Ue),Z==="latex"&&typeof i=="string"&&(Ve==null?void 0:Ve.type)==="root"&&Ct&&!R&&(Ve.verbatimLatex=i),e.silenceNotifications=b;const ct=ue[ue.length-1];if(r.selectionMode==="placeholder"){const It=ue.flatMap(yt=>[yt,...yt.children]).find(yt=>yt.type==="placeholder");if(It){const yt=e.offsetOf(It);e.setSelection(yt-1,yt),e.announce("move")}else ct&&(e.position=e.offsetOf(ct))}else r.selectionMode==="before"||(r.selectionMode==="after"?ct&&(e.position=e.offsetOf(ct)):r.selectionMode==="item"&&e.setSelection(e.anchor,e.offsetOf(ct)));return e.contentDidChange({data:p,inputType:"insertText"}),e.silenceNotifications=g,!0}};function op(e,i,r,a){var u;let p,g=[];if(typeof i!="string"||a.format==="math-json"){const b=window.MathfieldElement.computeEngine;if(!b)return["math-json",[]];[p,i]=["latex",b.box(i).latex],g=zr(i,{context:e.mathfield.context})}else typeof i=="string"&&a.format==="ascii-math"?([p,i]=Lu(i,{format:"ascii-math",inlineShortcuts:e.mathfield.options.inlineShortcuts}),g=zr(i,{context:e.mathfield.context}),p!=="latex"&&e.mathfield.options.removeExtraneousParentheses&&Xf(g)):(a.format==="auto"||(u=a.format)!=null&&u.startsWith("latex"))&&(a.format==="auto"&&([p,i]=Lu(i,{format:"auto",inlineShortcuts:e.mathfield.options.inlineShortcuts})),a.format==="latex"&&([,i]=Nc(i)),g=zr(i,{context:e.mathfield.context,args:r}),a.format!=="latex"&&e.mathfield.options.removeExtraneousParentheses&&Xf(g));return Xo(g,a.style),[p!=null?p:"latex",g]}function hg(e){if(!e||(console.assert(e[0].type==="first"),e.length>1))return null;const i=e[0];return i instanceof Zn&&i.leftDelim==="("&&i.rightDelim===")"?i.removeBranch("body"):null}function Xf(e){if(e){for(let i=0;e[i];i++){const r=e[i];if(r instanceof Zn&&r.leftDelim==="("){let a=0,u=0,p=0;for(let g=0;r.body[g];g++)r.body[g].type==="genfrac"&&(a++,u=g),p++;p===0&&a===1&&(e[i]=r.body[u])}}for(const i of e){for(const r of i.branches)if(!i.hasEmptyBranch(r)){Xf(i.branch(r));const a=hg(i.branch(r));a&&i.setChildren(a,r)}if(i instanceof Tn)for(const r of i.cells)Xf(r)}}}function fg(e){let i=e.at(e.position);if(i.mode==="text"){for(;!i.isFirstSibling&&i.mode==="text";)i=i.leftSibling;return e.offsetOf(i)}const r=i;let a=!1;if(i.type==="mclose"){const u=co[i.value];for(;!i.isFirstSibling&&!(i.type==="mopen"&&i.value===u);)i=i.leftSibling;i.isFirstSibling||(i=i.leftSibling),a=!0}else i.type==="leftright"&&(i=i.leftSibling,a=!0);if(a)for(;!i.isFirstSibling&&(i.isFunction||lp(i));)i=i.leftSibling;else{const u=[];for(;!i.isFirstSibling&&(lp(i)||u.length>0);)i.type==="mclose"&&u.unshift(i.value),i.type==="mopen"&&u.length>0&&i.value===co[u[0]]&&u.shift(),i=i.leftSibling}return r===i?-1:e.offsetOf(i)}function lp(e){return e.isDigit()?!0:e.type&&/^(mord|surd|subsup|leftright|mop|mclose)$/.test(e.type)?!e.isExtensibleSymbol:!1}new cg;var dg=class extends qn{constructor(){super("text")}onPaste(e,i){if(!i)return!1;const r=typeof i=="string"?i:i.getData("text/plain");return r&&e.model.contentWillChange({inputType:"insertFromPaste",data:r})?(e.stopCoalescingUndo(),e.stopRecording(),this.insert(e.model,r)&&(e.model.contentDidChange({inputType:"insertFromPaste"}),e.startRecording(),e.snapshot("paste"),wn(e)),e.startRecording(),!0):!1}insert(e,i,r={}){if(!e.contentWillChange({data:i,inputType:"insertText"}))return!1;r.insertionMode||(r.insertionMode="replaceSelection"),r.selectionMode||(r.selectionMode="placeholder"),r.format||(r.format="auto");const{silenceNotifications:a}=e;r.silenceNotifications&&(e.silenceNotifications=!0);const u=e.silenceNotifications;e.silenceNotifications=!0,r.insertionMode==="replaceSelection"&&!e.selectionIsCollapsed?e.deleteAtoms(Fr(e.selection)):r.insertionMode==="replaceAll"?(e.root.setChildren([],"body"),e.position=0):r.insertionMode==="insertBefore"?e.collapseSelection("backward"):r.insertionMode==="insertAfter"&&e.collapseSelection("forward");const p=pg(i,e.mathfield.context);if(Xo(p,r.style),!p)return!1;const g=e.at(e.position),b=g.parent.addChildrenAfter(p,g);return e.silenceNotifications=u,r.selectionMode==="before"||(r.selectionMode==="item"?e.setSelection(e.anchor,e.offsetOf(b)):b&&(e.position=e.offsetOf(b))),e.contentDidChange({data:i,inputType:"insertText"}),e.silenceNotifications=a,!0}};function pg(e,i){return e=e.replace(/\\/g,"\\textbackslash "),e=e.replace(/#/g,"\\#"),e=e.replace(/\$/g,"\\$"),e=e.replace(/%/g,"\\%"),e=e.replace(/&/g,"\\&"),e=e.replace(/_/g,"\\_"),e=e.replace(/{/g,"\\textbraceleft "),e=e.replace(/}/g,"\\textbraceright "),e=e.replace(/lbrace/g,"\\textbraceleft "),e=e.replace(/rbrace/g,"\\textbraceright "),e=e.replace(/\^/g,"\\textasciicircum "),e=e.replace(/~/g,"\\textasciitilde "),e=e.replace(/£/g,"\\textsterling "),zr(e,{context:i,parseMode:"text"})}new dg;function Ba(e){return{value:e.model.getValue(),selectionIsCollapsed:e.model.selectionIsCollapsed,canUndo:e.canUndo(),canRedo:e.canRedo(),style:e.selectionStyle,mode:e.model.mode}}var Qn=4,Es=20,Cr=2*(Es+Qn),Jf=(e,i)=>`
<line x1="${e+Es}" y1="${i+Es}"
x2="${e>i?e+Es:7*Es+10*Qn}"
y2="${e<i?i+Es:7*Es+10*Qn}"/>
<svg id="plus" viewBox="0 0 40 40" x="${e}" y="${i}" width="40" height="40">
<circle class="cls-2" cx="20" cy="20" r="20"/>
<path class="font" d="m33.33,20c0,1.84-1.49,3.34-3.33,3.34h-6.67v6.66c0,1.84-1.49,3.34-3.33,3.34s-3.34-1.5-3.34-3.34v-6.66h-6.66c-1.84,0-3.34-1.5-3.34-3.34s1.5-3.33,3.34-3.33h6.66v-6.67c0-1.84,1.5-3.33,3.34-3.33s3.33,1.49,3.33,3.33v6.67h6.67c1.84,0,3.33,1.49,3.33,3.33Z"/>
</svg>`,up=(e,i)=>`
<line x1="${e+Es}" y1="${i+Es}"
x2="${e>i?e+Es:7*Es+10*Qn}"
y2="${e<i?i+Es:7*Es+10*Qn}"/>
<svg id="minus" viewBox="0 0 40 40" x="${e}" y="${i}" width="40" height="40">
<circle class="cls-2" cx="20" cy="20" r="20"/>
<path class="font" d="m33.33,20c0,1.84-1.49,3.33-3.33,3.33H10c-1.84,0-3.34-1.49-3.34-3.33s1.5-3.34,3.34-3.34h20c1.84,0,3.33,1.5,3.33,3.34Z"/>
</svg>`,Qf=(e,i,r)=>`
<svg id="arrow" viewBox="0 0 40 40" x="${e}" y="${i}" width="40" height="40">
<circle class="cls-2" cx="20" cy="20" r="20"/>
<g transform="rotate(${r})" transform-origin="20 20">
<path class="font" d="m17.7,7.23h4.6c.52,0,.94.42.94.94v13.82c0,.52.42.94.94.94h3.39c.83,0,1.25,1.01.66,1.6l-7.56,7.56c-.37.37-.96.37-1.32,0l-7.56-7.56c-.59-.59-.17-1.6.66-1.6h3.39c.52,0,.94-.42.94-.94v-13.82c0-.52.42-.94.94-.94Z"/>
</g>
</svg>`,mg=`
<svg class="MLEP__array-buttons" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox=
"-2 -2 ${8*Es+10*Qn+5} ${8*Es+10*Qn+5}">
<rect
class="MLEP__array-insert-background rows"
x="0"
y="${Cr+Qn}"
height="${3*Cr}"
width="${Cr}"
rx="${Cr/2}"/>
<rect
class="MLEP__array-insert-background columns"
x="${Cr+Qn}"
y="0"
height="${Cr}"
width="${3*Cr}"
rx="${Cr/2}"/>
<g data-command='"moveDown"'>
${Qf(2*(Qn+Cr),2*Qn+3*Cr,0)}
</g>
<g data-command='"moveUp"'>
${Qf(2*(Qn+Cr),2*Qn+Cr,180)}
</g>
<g data-command='"moveToNextWord"'>
${Qf(2*Qn+3*Cr,2*(Qn+Cr),-90)}
</g>
<g data-command='"moveToPreviousWord"'>
${Qf(2*Qn+Cr,2*(Qn+Cr),90)}
</g>
<g>
<g data-command='"addColumnBefore"'>
${Jf(2*Qn+Cr,Qn)}
</g>
<g data-command='"removeColumn"'>
${up(2*Qn+2*Cr,Qn)}
</g>
<g data-command='"addColumnAfter"'>
${Jf(2*Qn+3*Cr,Qn)}
</g>
<g data-command='"addRowBefore"'>
${Jf(Qn,2*Qn+Cr)}
</g>
<g data-command='"removeRow"'>
${up(Qn,2*Qn+2*Cr)}
</g>
<g data-command='"addRowAfter"'>
${Jf(Qn,2*Qn+3*Cr)}
</g>
</svg>`,gg=e=>`
<svg id="matrix" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24"
data-command='["setEnvironment","matrix"]'>
<rect class="cls-1" width="28" height="24"/>
<circle cx="10" cy="8" r="1"/>
<circle cx="14" cy="12" r="1"/>
<circle cx="18" cy="16" r="1"/></svg>`,_g=e=>`
<svg id="pmatrix" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24"
data-command='["setEnvironment","pmatrix"]'>
<rect class="cls-1" width="28" height="24"/>
<path class="cls-2" d="m6,4c-3.96,4.6-3.96,11.4,0,16"/>
<path class="cls-2" d="m22,4c3.96,4.6,3.96,11.4,0,16"/>
<circle cx="10" cy="8" r="1"/>
<circle cx="14" cy="12" r="1"/>
<circle cx="18" cy="16" r="1"/></svg>`,cp=e=>`
<svg id="Bmatrix" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24"
data-command='["setEnvironment","Bmatrix"]'>
<rect class="cls-1" width="28" height="24"/>
<path class="cls-2" d="m6,4c-1.1,0-2,.9-2,2v3c0,1.66-.9,3-2,3,1.1,0,2,1.34,2,3v3c0,1.1.9,2,2,2"/>
<path class="cls-2" d="m22,4c1.1,0,2,.9,2,2v3c0,1.66.9,3,2,3-1.1,0-2,1.34-2,3v3c0,1.1-.9,2-2,2"/>
<circle cx="10" cy="8" r="1"/>
<circle cx="14" cy="12" r="1"/>
<circle cx="18" cy="16" r="1"/>
</svg>`,vg=e=>`
<svg id="bmatrix" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24"
data-command='["setEnvironment","bmatrix"]'>
<rect class="cls-1" width="28" height="24"/>
<path class="cls-2" d="m6,4h-3v16h3"/>
<path class="cls-2" d="m22,4h3v16h-3"/>
<circle cx="10" cy="8" r="1"/>
<circle cx="14" cy="12" r="1"/>
<circle cx="18" cy="16" r="1"/>
</svg>`,yg=e=>`
<svg id="vmatrix" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24"
data-command='["setEnvironment","vmatrix"]'>
<rect class="cls-1" width="28" height="24"/>
<circle cx="10" cy="8" r="1"/>
<circle cx="14" cy="12" r="1"/>
<circle cx="18" cy="16" r="1"/>
<line class="cls-2" x1="4" y1="4" x2="4" y2="20"/>
<line class="cls-2" x1="24" y1="4" x2="24" y2="20"/>
</svg>`,bg=e=>`
<svg id="Vmatrix" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="-3.5 -3 35 30"
data-command='["setEnvironment","Vmatrix"]'>
<rect class="cls-1" width="28" height="24"/>
<circle cx="10" cy="8" r="1"/>
<circle cx="14" cy="12" r="1"/>
<circle cx="18" cy="16" r="1"/>
<line class="cls-2" x1="6" y1="4" x2="6" y2="20"/>
<line class="cls-2" x1="22" y1="4" x2="22" y2="20"/>
<line class="cls-2" x1="2" y1="4" x2="2" y2="20"/>
<line class="cls-2" x1="26" y1="4" x2="26" y2="20"/>
</svg>`,xg=e=>`
<svg id="cases" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24"
data-command='["setEnvironment","cases"]'>
<rect class="cls-1" width="28" height="24"/>
<path class="cls-2" d="m10,4c-1.1,0-2,.9-2,2v3c0,1.66-.9,3-2,3,1.1,0,2,1.34,2,3v3c0,1.1.9,2,2,2"/>
<circle cx="13" cy="8" r="1"/>
<circle cx="13" cy="16" r="1"/>
<circle cx="21" cy="8" r="1"/>
<circle cx="21" cy="16" r="1"/>
</svg>`,wg=e=>`
<svg id="rcases" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24"
data-command='["setEnvironment","rcases"]'>
<rect class="cls-1" width="28" height="24"/>
<path class="cls-2" d="m18,20c1.1,0,2-.9,2-2v-3c0-1.66.9-3,2-3-1.1,0-2-1.34-2-3v-3c0-1.1-.9-2-2-2"/>
<circle cx="15" cy="8" r="1"/>
<circle cx="15" cy="16" r="1"/>
<circle cx="7" cy="8" r="1"/>
<circle cx="7" cy="16" r="1"/>
</svg>`,y0={matrix:gg,pmatrix:_g,bmatrix:vg,Bmatrix:cp,vmatrix:yg,Vmatrix:bg},b0={cases:xg,rcases:wg,Bmatrix:cp};function Sg(e){var i,r;const a=(i=e.model.parentEnvironment)==null?void 0:i.array;if(!a)return;let u=0;a.forEach(me=>{(!u||me.length>u)&&(u=me.length)});let p=document.getElementById("mathlive-environment-popover");p||(p=Fe("mathlive-environment-popover"),ca("environment-popover"),ca("core"),p.setAttribute("aria-hidden","true"));let g;const b=p.querySelector(".MLEP__environment-controls");b?g=b:(g=document.createElement("div"),p.innerHTML="",p.appendChild(g)),g.className="MLEP__environment-controls",g.style.display="flex",g.style.width="100%",g.style.height="100%",g.style.boxSizing="border-box",g.innerHTML=mg;let w=[],E="";const R=e.model.parentEnvironment.environmentName;if(yf(R)){const me=kg(R);E=y0[me]("active");const Ve=y0,{[me]:Ct}=Ve,Ue=I(Ve,[ne(me)]);w=Object.values(Ue).map(ct=>ct("inactive"))}else if(Bd(R)){const me=Tg(R);E=b0[me]("active");const Ve=b0,{[me]:Ct}=Ve,Ue=I(Ve,[ne(me)]);w=Object.values(Ue).map(ct=>ct("inactive"))}else Nd(R)&&(E=y0.matrix("active"),w=Object.values(b0).map(me=>me("inactive")));const N=document.createElement("div");N.className="MLEP__environment-delimiter-controls",N.style.display="flex",N.style.flexDirection="column",N.innerHTML=`
<div class='MLEP__array-delimiter-options'>
${E}
${w.join("")}
</div>`,E&&g.appendChild(N),g.querySelectorAll("[data-command]").forEach(me=>{const Ve=me.dataset.command;let Ct=Ve;try{Ct=JSON.parse(Ve)}catch(Ue){}me.addEventListener("mousedown",Ue=>Ue.preventDefault()),Ct&&me.addEventListener("click",()=>e.executeCommand(Ct))});const ue=(r=e.field)==null?void 0:r.getBoundingClientRect();ue&&(p.style.top=`${window.scrollY+(ue.top-p.clientHeight-15)}px`,p.style.left=`${ue.left+20}px`,p.classList.add("is-visible"))}function x0(){const e=document.getElementById("mathlive-environment-popover");e==null||e.classList.remove("is-visible")}function Eg(){document.getElementById("mathlive-environment-popover")&&(bt("mathlive-environment-popover"),Da("environment-popover"),Da("core"))}function ed(e){if(!e.hasFocus())return;let i=!1;if(e.model.mode==="math"){const r=e.model.parentEnvironment;if(r!=null&&r.array&&Fd(r.environmentName)){const a=e.options.environmentPopoverPolicy;i=a==="auto"||a==="on"}}i?Sg(e):x0()}function kg(e){return e.replace("*","")}function Tg(e){return e==="dcases"?"cases":e}function hp(e){const i=getComputedStyle(e).direction;return i==="ltr"||i==="rtl"?i:"ltr"}function fp(e,i,r){return i==="left"||i==="leading"&&r==="ltr"||i==="trailing"&&r==="rtl"?e.left:e.right}function w0(e,i,r,a){return r==="middle"?e-i/2:r==="start"&&a==="rtl"||r==="end"&&a==="ltr"||r==="top"||r==="right"?Math.max(0,e-i):e}function Ag(e,i,r,a){return r==="middle"?e-i/2:r==="start"&&a==="ltr"||r==="end"&&a==="rtl"||r==="top"||r==="right"?e:e-i}function Lg(e,i){var r,a,u;const p=(r=hp(e))!=null?r:"ltr";e.style.position="fixed",e.style.left="",e.style.top="",e.style.right="",e.style.bottom="",e.style.height="",e.style.width="";const g=e.getBoundingClientRect(),b=Number.isFinite(i.maxHeight)?Math.min(i.maxHeight,window.innerHeight):window.innerHeight;let w=Math.min(b,(a=i.height)!=null?a:g.height),E=w0(i.location.y,w,i.verticalPos,p);E+w>window.innerHeight-8&&(i.alternateLocation?(E=w0(i.alternateLocation.y,w,i.verticalPos,p),E+w>window.innerHeight-8&&(E=void 0)):E=void 0),Number.isFinite(E)||(E=Math.max(8,window.innerHeight-8-w),8+w>window.innerHeight-8&&(e.style.bottom="8px")),w=Math.min(E+w,window.innerHeight-8)-E;const R=Number.isFinite(i.maxWidth)?Math.min(i.maxWidth,window.innerWidth):window.innerWidth;let N=Math.min(R,(u=i.width)!=null?u:g.width),Z=w0(i.location.x,N,i.horizontalPos,p);Z+N>window.innerWidth-8&&(i.alternateLocation?(Z=Ag(i.alternateLocation.x,N,i.verticalPos,p),Z+N>window.innerWidth-8&&(Z=void 0)):Z=void 0),Number.isFinite(Z)||(Z=Math.max(8,window.innerWidth-8-N),8+N>window.innerWidth-8&&(e.style.right="8px")),N=Math.min(Z+N,window.innerWidth-8)-Z,p==="rtl"?e.style.right=`${Math.ceil(window.innerWidth-Z-N).toString()}px`:e.style.left=`${Math.ceil(Z).toString()}px`,e.style.top=`${Math.ceil(E).toString()}px`,w!==g.height&&(e.style.height=`${Math.ceil(w).toString()}px`),N!==g.width&&(e.style.width=`${Math.ceil(N).toString()}px`)}function Dg(e,i){return Math.hypot(i.x-e.x,i.y-e.y)}function Xu(e){return"submenu"in e}function Na(e){return"type"in e&&e.type==="command"||"onMenuSelect"in e||"id"in e}function S0(e){return"type"in e&&e.type==="divider"}function E0(e){return"type"in e&&e.type==="heading"}var dp={};function k0(e){let i=dp[e];if(!i){let r;switch(e){case"checkmark":r=`<span aria-hidden="true" class="ui-checkmark"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"></path></svg>
</span>`;break;case"trailing-chevron":r='<span aria-hidden="true" class="ui-trailing-chevron"><svg focusable="false" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path fill="currentColor" d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"></path></svg></span>';break;case"mixedmark":r='<span aria-hidden="true" class="ui-mixedmark"><svg xmlns="http://www.w3.org/2000/svg" width="16" viewBox="0 0 512 512"><path fill="currentColor" d="M0 256c0-13.3 10.7-24 24-24H488c13.3 0 24 10.7 24 24s-10.7 24-24 24H24c-13.3 0-24-10.7-24-24z"/></svg></span>'}if(r){const a=document.createElement("template");a.innerHTML=r,dp[e]=a,i=a}}if(i){if("content"in i)return i.content.cloneNode(!0);const r=document.createElement("svg");return r.innerHTML=i.innerHTML,r}}var pp=80,mp=class{constructor(e,i){this._element=null;var r;this.parentMenu=i,this._declaration=e,Xu(e)?(this.type="submenu",this.submenu=new gp(e.submenu,{parentMenu:i,submenuClass:e.submenuClass,columnCount:e.columnCount})):this.type=(r=e.type)!=null?r:"command",this.hasCheck=Na(e)&&e.checked!==void 0}get rootMenu(){return this.parentMenu.rootMenu}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}dispose(){var e,i;(e=this._abortController)==null||e.abort(),this._abortController=void 0,(i=this._element)==null||i.remove(),this._element=null,this.submenu&&this.submenu.dispose(),this.submenu=void 0}get menuItem(){return this._declaration}get label(){var e;return(e=this._label)!=null?e:""}set label(e){e===void 0&&(e=""),e!==this._label&&(this._label=e,this.dirty=!0)}get visible(){return this._visible}set visible(e){e!==this._visible&&(this._visible=e,this.dirty=!0)}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this.element&&(e?this.element.removeAttribute("aria-disabled"):this.element.setAttribute("aria-disabled","true")),this.dirty=!0}get checked(){return this._checked}set checked(e){this._checked=e,this.dirty=!0}get tooltip(){return this._tooltip}set tooltip(e){e!==this._tooltip&&(this._tooltip=e,this.dirty=!0)}get ariaLabel(){return this._ariaLabel}set ariaLabel(e){e!==this._ariaLabel&&(this._ariaLabel=e,this.dirty=!0)}get active(){var e,i;return(i=(e=this.element)==null?void 0:e.classList.contains("active"))!=null?i:!1}set active(e){this.element&&this.element.classList.toggle("active",e)}updateState(e){var i,r,a;const u=this._declaration;if(S0(u)){this.enabled=!1,this.checked=!1;return}E0(u)&&(this.enabled=!1,this.checked=!1,this.visible=!0),Na(u)&&(this.checked=Na(u)&&((i=Ju(u.checked,e))!=null?i:!1)),(Na(u)||Xu(u))&&(this.enabled=(r=Ju(u.enabled,e))!=null?r:!0,this.visible=(a=Ju(u.visible,e))!=null?a:!0,this.visible&&this.enabled&&this.submenu&&(this.submenu.updateState(e),this.submenu.visible||(this.visible=!1))),(Na(u)||E0(u)||Xu(u))&&(this.label=Ju(u.label,e),this.tooltip=Ju(u.tooltip,e),this.ariaLabel=Ju(u.ariaLabel,e)),this._element&&this.updateElement()}set dirty(e){console.assert(e===!0),e&&this.parentMenu&&(this.parentMenu.dirty=!0)}updateElement(){if(!this.visible||!this.element)return;const e=this.element;e.textContent="",this.enabled?e.removeAttribute("aria-disabled"):e.setAttribute("aria-disabled","true"),this.checked===!0?(e.setAttribute("aria-checked","true"),e.append(k0("checkmark"))):this.checked==="mixed"?(e.setAttribute("aria-checked","mixed"),e.append(k0("mixedmark"))):e.removeAttribute("aria-checked"),this.ariaLabel&&e.setAttribute("aria-label",this.ariaLabel);const i=document.createElement("span");if(i.className=this.parentMenu.hasCheck?"label indent":"label",this.type==="heading"&&i.classList.add("heading"),i.innerHTML=this.label,e.append(i),this._tooltip&&e.setAttribute("data-tooltip",this._tooltip),Na(this._declaration)&&this._declaration.keyboardShortcut){const r=document.createElement("kbd");r.innerHTML=h(this._declaration.keyboardShortcut),e.append(r)}this.type==="submenu"&&e.append(k0("trailing-chevron"))}get element(){if(this._element)return this._element;if(S0(this._declaration)){const r=document.createElement("li");return r.setAttribute("part","menu-divider"),r.setAttribute("role","divider"),this._element=r,r}const e=document.createElement("li");this._element=e,(Na(this._declaration)||E0(this._declaration)||Xu(this._declaration))&&this._declaration.class&&(e.className=this._declaration.class),e.setAttribute("part","menu-item"),e.setAttribute("tabindex","-1"),this.hasCheck?e.setAttribute("role","menuitemcheckbox"):e.setAttribute("role","menuitem"),this.type==="submenu"&&(e.setAttribute("aria-haspopup","true"),e.setAttribute("aria-expanded","false"));const i=this.abortController.signal;return e.addEventListener("pointerenter",this,{signal:i}),e.addEventListener("pointerleave",this,{signal:i}),e.addEventListener("pointerup",this,{signal:i}),e.addEventListener("click",this,{signal:i}),this._element}dispatchSelect(){if(!Na(this._declaration))return;const e=new CustomEvent("menu-select",{cancelable:!0,bubbles:!0,detail:{modifiers:this.rootMenu.modifiers,id:this._declaration.id,data:this._declaration.data}});this.parentMenu.dispatchEvent(e)&&typeof this._declaration.onMenuSelect=="function"&&this._declaration.onMenuSelect({modifiers:this.rootMenu.modifiers,id:this._declaration.id,data:this._declaration.data})}handleEvent(e){var i;if(!(!this.visible||!this.enabled)){if(e.type==="click"){this.rootMenu.state==="modal"&&this.select(),e.stopPropagation(),e.preventDefault();return}if(e.type==="pointerenter"){const r=e;this.rootMenu.cancelDelayedOperation(),this.parentMenu.isSubmenuOpen&&((i=this.parentMenu.activeMenuItem)!=null&&i.movingTowardSubmenu(r))?this.rootMenu.scheduleOperation(()=>{this.parentMenu.activeMenuItem=this,this.openSubmenu()}):(this.parentMenu.activeMenuItem=this,this.openSubmenu({withDelay:!0}));return}if(e.type==="pointerleave"){this.rootMenu.activeSubmenu===this.parentMenu&&(this.parentMenu.activeMenuItem=null);return}if(e.type==="pointerup"){this.rootMenu.state!=="modal"&&this.select(),e.stopPropagation(),e.preventDefault();return}}}select(){if(this.rootMenu.cancelDelayedOperation(),this.type==="submenu"){this.openSubmenu();return}this.active=!1,setTimeout(()=>{this.active=!0,setTimeout(()=>{this.rootMenu.hide(),this.dispatchSelect()},pp)},pp)}openSubmenu(e){var i;if(this.type!=="submenu"||!this.element)return;if((i=e==null?void 0:e.withDelay)!=null&&i){this.rootMenu.scheduleOperation(()=>this.openSubmenu());return}const r=this.element.getBoundingClientRect(),a=hp(this.element);this.submenu.show({container:this.rootMenu.element.parentNode,location:{x:fp(r,"trailing",a),y:r.top-4},alternateLocation:{x:fp(r,"leading",a),y:r.top-4}})}movingTowardSubmenu(e){if(!this.element||this.type!=="submenu")return!1;const i=this.rootMenu.lastMoveEvent;if(!i)return!1;const r=e.timeStamp-i.timeStamp;if(r>500)return!1;const a=e.clientX-i.clientX;if(Cg(a,i.clientY-e.clientY,r)<=.2)return!1;let p="right";if(this.submenu.element){const g=this.submenu.element.getBoundingClientRect(),b=this.element.getBoundingClientRect();g.left<b.left+b.width/2&&(p="left")}return p==="right"?a>0:a<0}};function Cg(e,i,r){return Math.hypot(e,i)/r}function Ju(e,i){return e===void 0||typeof e!="function"?e:(i!=null||(i={alt:!1,control:!1,shift:!1,meta:!1}),e(i))}var gp=class ac{constructor(i,r){this._element=null,this._activeMenuItem=null,this._dirty=!0;var a,u;this.parentMenu=(a=r==null?void 0:r.parentMenu)!=null?a:null,this._submenuClass=r==null?void 0:r.submenuClass,this.columnCount=(u=r==null?void 0:r.columnCount)!=null?u:1,this.isSubmenuOpen=!1,this.menuItems=i}get children(){return this._menuItems}set menuItems(i){const r=this.parentMenu;this.dispose(),this.parentMenu=r,i=[...i],this._menuItems=i.map(a=>a.onCreate?a.onCreate(a,this):new mp(a,this)),this.hasCheck=void 0,this.dirty=!0}dispose(){var i;this.hide(),this._element&&this._element.remove(),this._abortController&&this._abortController.abort(),(i=this._menuItems)==null||i.forEach(r=>r.dispose()),this._menuItems=[],this._activeMenuItem=null,this.parentMenu=null}handleEvent(i){if(i.type==="wheel"&&this._element){const r=i;this._element.scrollBy(0,r.deltaY),i.stopPropagation()}}dispatchEvent(i){return this.rootMenu.dispatchEvent(i)}get rootMenu(){return this.parentMenu.rootMenu}updateState(i){var r,a,u;this._menuItems.forEach(E=>E.updateState(i));const p=this.hasCheck;this.hasCheck=this._menuItems.some(E=>E.visible&&E.hasCheck),this.hasCheck!==p&&this._menuItems.forEach(E=>E.updateState(i));let g,b=0;for(const E of this._menuItems)E.type==="heading"?(g&&b===0&&(g.visible=!1),g=E,b=0):E.type==="divider"&&g?(g.visible=b>0,g=void 0,b=0):g&&E.visible&&(b+=1);g&&(g.visible=b>0);let w=!0;for(const E of this._menuItems)E.type==="divider"?(E.visible=!w,w=!0):E.visible&&(w=!1);(r=this.activeMenuItem)!=null&&r.visible||(this.activeMenuItem=null),!((a=this.activeMenuItem)!=null&&a.enabled)&&((u=this.activeMenuItem)==null?void 0:u.type)==="submenu"&&this._activeMenuItem.submenu.hide(),this._dirty=!1}get enabled(){return this.updateIfDirty(),this._menuItems.some(i=>i.type!=="divider"&&i.visible&&i.enabled)}get visible(){return this.updateIfDirty(),this._menuItems.some(i=>i.type!=="divider"&&i.visible)}set dirty(i){console.assert(i===!0),this._dirty!==i&&i&&this.parentMenu&&(this._dirty=!0,this.parentMenu.dirty=!0)}updateIfDirty(){this._dirty&&this.updateState(this.rootMenu.modifiers)}updateElement(){var i;if(this._element){this._element.textContent="";for(const{element:r,visible:a}of this._menuItems)r&&a&&this._element.append(r);(i=this._element.querySelector("li:first-of-type"))==null||i.setAttribute("tabindex","0")}}get element(){if(this._element)return this._element;const i=document.createElement("menu");i.setAttribute("role","menu"),i.setAttribute("tabindex","-1"),i.setAttribute("aria-orientation","vertical"),i.setAttribute("part","ui-menu-container"),this._submenuClass&&i.classList.add(this._submenuClass),i.classList.add("ui-menu-container"),this._abortController||(this._abortController=new AbortController);const r=this._abortController.signal;return i.addEventListener("focus",this,{signal:r}),i.addEventListener("wheel",this,{passive:!0,signal:r}),this._element=i,this.updateElement(),i}get activeMenuItem(){return this._activeMenuItem}set activeMenuItem(i){var r,a,u,p;if(this.rootMenu.cancelDelayedOperation(),i!==this._activeMenuItem){if(this.activeMenuItem){const g=this.activeMenuItem;g.active=!1,(r=g.submenu)==null||r.hide()}if(!((a=i==null?void 0:i.visible)==null||a)){this._activeMenuItem=null;return}this._activeMenuItem=i,i&&(i.active=!0)}i?(u=i.element)==null||u.focus({preventScroll:!0}):(p=this._element)==null||p.focus({preventScroll:!0})}get firstMenuItem(){this.updateIfDirty();let i=0,r=!1;const a=this._menuItems;for(;!r&&i<=a.length-1;){const u=a[i];r=u.type!=="divider"&&u.visible&&u.enabled,i+=1}return r?a[i-1]:null}get lastMenuItem(){this.updateIfDirty();const i=this._menuItems;let r=i.length-1,a=!1;for(;!a&&r>=0;){const u=i[r];a=u.type!=="divider"&&u.visible&&u.enabled,r-=1}return a?i[r+1]:null}nextMenuItem(i){if(i===0)return this._activeMenuItem;if(!this._activeMenuItem)return i>0?this.firstMenuItem:this.lastMenuItem;if(!this.firstMenuItem||!this.lastMenuItem||!this._activeMenuItem)return null;this.updateIfDirty();const r=this._menuItems.indexOf(this.firstMenuItem),a=this._menuItems.indexOf(this.lastMenuItem);let u=this._menuItems.indexOf(this._activeMenuItem),p=1;for(;u>=r&&u<=a;){u+=i>0?1:-1;const g=this._menuItems[u];if(!g)break;if(g.visible&&g.enabled){if(p===Math.abs(i))return this._menuItems[u];p+=1}}return i>0?this.lastMenuItem:this.firstMenuItem}getMenuItemColumn(i){this.updateIfDirty();const a=this._menuItems.filter(u=>u.visible&&u.enabled).indexOf(i);return a<0?-1:a%this.columnCount}static get collator(){return ac._collator||(ac._collator=new Intl.Collator(void 0,{usage:"search",sensitivity:"base"})),ac._collator}findMenuItem(i){var r;this.updateIfDirty();const a=this._menuItems.filter(b=>b.type!=="divider"&&b.visible&&b.enabled);if(a.length===0)return null;const u=Math.max(...a.map(b=>b.label.length))-i.length;if(u<0)return null;let p=null,g=0;for(;g<u&&!p;)p=(r=a.find(b=>ac.collator.compare(i,b.label.substring(g,i.length))===0))!=null?r:null,g++;return p}show(i){return!this.visible||!i.container?!1:(this.updateElement(),i.container.appendChild(this.element),U()&&(this.element.popover="manual",this.element.showPopover()),i.location&&Lg(this.element,{location:i.location,alternateLocation:i.alternateLocation,verticalPos:"bottom",horizontalPos:"start"}),this.element.focus({preventScroll:!0}),this.parentMenu&&(this.parentMenu.openSubmenu=this),!0)}hide(){var i,r,a,u,p;this.openSubmenu=null,this.activeMenuItem=null,this.parentMenu&&(this.parentMenu.openSubmenu=null),U()&&((i=this._element)!=null&&i.popover)&&this.element.hidePopover(),(a=(r=this.parentMenu)==null?void 0:r.element)==null||a.focus(),(p=(u=this._element)==null?void 0:u.parentNode)==null||p.removeChild(this._element)}set openSubmenu(i){var r,a,u,p;const g=i!==null;((r=this.activeMenuItem)==null?void 0:r.type)==="submenu"&&((a=this.activeMenuItem.element)==null||a.setAttribute("aria-expanded",g.toString())),(p=(u=this.activeMenuItem)==null?void 0:u.element)==null||p.classList.toggle("is-submenu-open",g),this.isSubmenuOpen=g}},_p=class ym extends gp{constructor(i,r){var a;super(i),this.state="closed",this.typingBufferResetTimer=0,this.hysteresisTimer=0,this._updating=!1,this._host=(a=r==null?void 0:r.host)!=null?a:null,this.isDynamic=i.some(vp),this._modifiers={shift:!1,control:!1,alt:!1,meta:!1},this.typingBuffer="",this.state="closed"}get modifiers(){return this._modifiers}set modifiers(i){s(this._modifiers,i)||(this._modifiers=i,this.dirty=!0)}get activeSubmenu(){let i=this;for(;i.isSubmenuOpen;)i=i.activeMenuItem.submenu;return i}set dirty(i){this._updating||(console.assert(i===!0),this._dirty!==i&&(this._dirty=!0,i&&setTimeout(()=>{this.updateState(this.modifiers),this.updateElement()})))}updateState(i){this._updating=!0,this.modifiers=i!=null?i:this.modifiers,super.updateState(this.modifiers),this._updating=!1}handleKeyupEvent(i){this.isDynamic&&(this.modifiers=n(i)),i.stopImmediatePropagation()}handleKeydownEvent(i){var r,a,u;if(i.key==="Tab"||i.key==="Escape"){this.hide();return}this.isDynamic&&(this.modifiers=n(i));let p=!0;const g=this.activeSubmenu,b=g.activeMenuItem;switch(i.key){case" ":case"Space":case"Return":case"Enter":b==null||b.select(n(i));break;case"ArrowRight":if((b==null?void 0:b.type)==="submenu")b.select(n(i)),this.activeSubmenu.activeMenuItem=this.activeSubmenu.firstMenuItem;else if(!b)g.activeMenuItem=g.firstMenuItem;else{const w=(r=g.getMenuItemColumn(b))!=null?r:-1;if(w>=0&&w<((a=g.columnCount)!=null?a:1)-1){const E=g.nextMenuItem(1);E&&(g.activeMenuItem=E)}}break;case"ArrowLeft":if(g===this.rootMenu)b||(g.activeMenuItem=g.firstMenuItem);else if((b&&(u=g.getMenuItemColumn(b))!=null?u:-1)<=0||!b){g.hide();const E=g.parentMenu.activeMenuItem;if(E){const{element:R}=E;R==null||R.focus(),R==null||R.classList.remove("is-submenu-open")}}else{const E=g.nextMenuItem(-1);E&&(g.activeMenuItem=E)}break;case"ArrowDown":g.activeMenuItem=g.nextMenuItem(g.columnCount);break;case"ArrowUp":g.activeMenuItem=g.nextMenuItem(-g.columnCount);break;case"Home":case"PageUp":g.activeMenuItem=g.firstMenuItem;break;case"End":case"PageDown":g.activeMenuItem=g.lastMenuItem;break;case"Backspace":if(this.typingBuffer&&(this.typingBuffer=this.typingBuffer.slice(0,-1),this.typingBuffer)){clearTimeout(this.typingBufferResetTimer);const w=g.findMenuItem(this.typingBuffer);w&&(g.activeMenuItem=w),this.typingBufferResetTimer=setTimeout(()=>{this.typingBuffer=""},500)}break;default:if(l(i)){isFinite(this.typingBufferResetTimer)&&clearTimeout(this.typingBufferResetTimer),this.typingBuffer+=i.key;const w=g.findMenuItem(this.typingBuffer);w&&(g.activeMenuItem=w),this.typingBufferResetTimer=setTimeout(()=>{this.typingBuffer=""},500)}else p=!1}p&&(i.preventDefault(),i.stopPropagation())}handleEvent(i){if(i.type==="keydown")this.handleKeydownEvent(i);else if(i.type==="keyup")this.handleKeyupEvent(i);else if(i.type==="pointermove")this.lastMoveEvent=i;else if(i.type==="pointerup"&&i.target===this.scrim)Number.isFinite(this.rootMenu._openTimestamp)&&Date.now()-this.rootMenu._openTimestamp<120?this.state="modal":this.state==="modal"&&this.hide();else if(i.type==="contextmenu"){i.preventDefault(),i.stopPropagation();return}super.handleEvent(i)}dispatchEvent(i){return this._host?this._host.dispatchEvent(i):!0}get scrim(){return f.element}connectScrim(i){const r=this.scrim;r.addEventListener("pointerup",this),r.addEventListener("contextmenu",this),r.addEventListener("keydown",this),r.addEventListener("keyup",this),r.addEventListener("pointermove",this),f.open({root:i,onDismiss:()=>this.hide()})}disconnectScrim(){const i=this.scrim;i.removeEventListener("pointerup",this),i.removeEventListener("contextmenu",this),i.removeEventListener("keydown",this),i.removeEventListener("keyup",this),i.removeEventListener("pointermove",this),f.state==="open"&&f.scrim.close()}get rootMenu(){return this}show(i){return this._onDismiss=i==null?void 0:i.onDismiss,i!=null&&i.modifiers&&(this.modifiers=i.modifiers),this.updateState(),this.connectScrim(i==null?void 0:i.target),super.show(d(P({},i),{container:this.scrim}))?(this._openTimestamp=Date.now(),this.state="open",!0):(this.disconnectScrim(),!1)}hide(){this.cancelDelayedOperation(),this.state!==void 0&&(this.state!=="closed"&&(this.activeMenuItem=null,f.element.parentElement.focus(),super.hide(),this.state="closed",this.disconnectScrim()),this._onDismiss&&(this._onDismiss(),this._onDismiss=void 0))}scheduleOperation(i){this.cancelDelayedOperation();const r=ym.SUBMENU_DELAY;if(r<=0){i();return}this.hysteresisTimer=setTimeout(()=>{this.hysteresisTimer=0,i()},r)}cancelDelayedOperation(){this.hysteresisTimer&&(clearTimeout(this.hysteresisTimer),this.hysteresisTimer=0)}};_p.SUBMENU_DELAY=120;var Mg=_p;function vp(e){return S0(e)?!1:typeof e.label=="function"||typeof e.ariaLabel=="function"||typeof e.tooltip=="function"||(Na(e)||Xu(e))&&(typeof e.enabled=="function"||typeof e.visible=="function")||Na(e)&&typeof e.checked=="function"?!0:Xu(e)?e.submenu.some(vp):!1}var td=class{};td.DELAY=300,td.MAX_DISTANCE=10;function Rg(e){return new Promise((i,r)=>{const a=t(e);a||i(!1);let u=a;const p=setTimeout(()=>{g.abort(),i(Dg(u,a)<td.MAX_DISTANCE)},td.DELAY),g=new AbortController,b=g.signal;for(const w of["pointermove","pointerup","pointercancel"])window.addEventListener(w,E=>{if(E.type==="pointerup"||E.type==="pointercancel")clearTimeout(p),g.abort(),i(!1);else if(E.type==="pointermove"){const R=t(E);R&&(u=R)}},{passive:!0,signal:b})})}function yp(e,i,r){return el(this,null,function*(){if(e.type==="contextmenu"){const a=e;if(r.show({target:i,location:t(a),modifiers:n(a)}))return e.preventDefault(),e.stopPropagation(),!0}if(e.type==="keydown"){const a=e;if(a.code==="ContextMenu"||a.code==="F10"&&a.shiftKey){const u=i==null?void 0:i.getBoundingClientRect();if(u&&r.show({target:i,location:{x:Math.ceil(u.left+u.width/2),y:Math.ceil(u.top+u.height/2)},modifiers:n(a)}))return e.preventDefault(),e.stopPropagation(),!0}}if(e.type==="pointerdown"&&e.pointerType!=="mouse"&&e.button===0){let a=e.target;for(;a&&i!==a;)a=a.parentNode;if(!a||!r.visible)return!1;const u=t(e);if(yield Rg(e))return r.state!=="closed"?!1:(r.show({target:i,location:u}),!0)}return!1})}var bp={acute:714,grave:715,dot:729,ddot:168,mathring:730,tilde:126,bar:713,breve:728,check:711,hat:94,vec:8407};ke(Object.keys(bp),"{body:auto}",{createAtom:e=>new Ca(d(P({},e),{body:Ce(e.args[0]),accentChar:bp[e.command.slice(1)]}))}),ke(["widehat","widecheck","widetilde"],"{body:auto}",{createAtom:e=>{const i=gt(Ce(e.args[0]));return new Ca(d(P({},e),{body:Ce(e.args[0]),svgAccent:e.command.slice(1)+(i.length>5?"4":["1","1","2","2","3","3"][i.length])}))}}),ke(["overarc","overparen","wideparen"],"{body:auto}",{createAtom:e=>new Ca(d(P({},e),{body:Ce(e.args[0]),svgAccent:"overarc"}))}),ke(["underarc","underparen"],"{body:auto}",{createAtom:e=>new ws(d(P({},e),{body:Ce(e.args[0]),svgBelow:"underarc"}))}),ke("utilde","{body:auto}",{createAtom:e=>{const i=Ce(e.args[0]),r=gt(i),a="widetilde"+(r.length>5?"4":["1","1","2","2","3","3"][r.length]);return new ws(d(P({},e),{body:i,svgBelow:a,boxType:_l(i)}))}}),ke("^","{:string}",{createAtom:e=>{var i;return new et(d(P({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&(i={a:"\xE2",e:"\xEA",i:"\xEE",o:"\xF4",u:"\xFB",A:"\xC2",E:"\xCA",I:"\xCE",O:"\xD4",U:"\xDB"}[e.args[0]])!=null?i:"^"}))}}),ke("`","{:string}",{createAtom:e=>{var i;return new et(d(P({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&(i={a:"\xE0",e:"\xE8",i:"\xEC",o:"\xF2",u:"\xF9",A:"\xC0",E:"\xC8",I:"\xCC",O:"\xD2",U:"\xD9"}[e.args[0]])!=null?i:"`"}))}}),ke("'","{:string}",{createAtom:e=>{var i;return new et(d(P({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&(i={a:"\xE1",e:"\xE9",i:"\xED",o:"\xF3",u:"\xFA",A:"\xC1",E:"\xC9",I:"\xCD",O:"\xD3",U:"\xDA"}[e.args[0]])!=null?i:"'"}))}}),ke('"',"{:string}",{createAtom:e=>{var i,r;return new et(d(P({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:(i=e.args)!=null&&i[0]?(r={a:"\xE4",e:"\xEB",i:"\xEF",o:"\xF6",u:"\xFC",A:"\xC4",E:"\xCB",I:"\xCB",O:"\xD6",U:"\xDC"}[e.args[0]])!=null?r:'"'+e.args[0]:'"'}))}}),ke(".","{:string}",{createAtom:e=>{var i,r;return new et(d(P({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:(i=e.args)!=null&&i[0]?(r={a:"\u0227",e:"\u0117",i:"\u0307i",o:"\u022F",u:"\u0307u",A:"\u0226",E:"\u0116",I:"\u0130",O:"\u022E",U:"\u0307U"}[e.args[0]])!=null?r:"."+e.args[0]:"."}))}}),ke("=","{:string}",{createAtom:e=>{var i,r;return new et(d(P({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:(i=e.args)!=null&&i[0]?(r={a:"\u0101",e:"\u0113",i:"\u012B",o:"\u014D",u:"\u016B",A:"\u0100",E:"\u0112",I:"\u012A",O:"\u014C",U:"\u016A"}[e.args[0]])!=null?r:"="+e.args[0]:"="}))}}),ke("~","{:string}",{createAtom:e=>{var i;return new et(d(P({type:"mord"},e),{isFunction:!1,limits:"adjacent",value:e.args[0]&&(i={n:"\xF1",N:"\xD1",a:"\xE3",o:"\xF5",A:"\xC3",O:"\xD5"}[e.args[0]])!=null?i:"\xB4"}))}}),ke("c","{:string}",{createAtom:e=>{var i;return new et(d(P({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&(i={c:"\xE7",C:"\xC7"}[e.args[0]])!=null?i:""}))}}),ke("enclose","{notation:string}[style:string]{body:auto}",{createAtom:e=>{var i,r;const a=e.args,u={strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",backgroundcolor:"transparent",padding:"auto",shadow:"none",svgStrokeStyle:void 0,borderStyle:void 0,style:(i=e.style)!=null?i:{}};if(a[1]){const g=a[1].split(/,(?![^(]*\)(?:(?:[^(]*\)){2})*[^"]*$)/);for(const b of g){const w=b.match(/\s*(\S+)\s+(\S+)\s+(.*)/);if(w)u.strokeWidth=w[1],u.strokeStyle=w[2],u.strokeColor=w[3];else{const E=b.match(/\s*([a-z]*)\s*=\s*"(.*)"/);E&&(E[1]==="mathbackground"?u.backgroundcolor=E[2]:E[1]==="mathcolor"?u.strokeColor=E[2]:E[1]==="padding"?u.padding=E[2]:E[1]==="shadow"&&(u.shadow=E[2]))}}u.strokeStyle==="dashed"?u.svgStrokeStyle="5,5":u.strokeStyle==="dotted"&&(u.svgStrokeStyle="1,5")}u.borderStyle=`${u.strokeWidth} ${u.strokeStyle} ${u.strokeColor}`;const p={};return((r=a[0])!=null?r:"").split(/[, ]/).filter(g=>g.length>0).forEach(g=>{p[g.toLowerCase()]=!0}),new Dl(e.command,Ce(a[2]),p,u)}}),ke("cancel","{body:auto}",{createAtom:e=>{var i;return new Dl(e.command,Ce(e.args[0]),{updiagonalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:(i=e.style)!=null?i:{}})}}),ke("bcancel","{body:auto}",{createAtom:e=>{var i;return new Dl(e.command,Ce(e.args[0]),{downdiagonalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:(i=e.style)!=null?i:{}})}}),ke("xcancel","{body:auto}",{createAtom:e=>{var i;return new Dl(e.command,Ce(e.args[0]),{updiagonalstrike:!0,downdiagonalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:(i=e.style)!=null?i:{}})}}),ke(["overrightarrow","overleftarrow","Overrightarrow","overleftharpoon","overrightharpoon","overleftrightarrow","overlinesegment","overgroup"],"{:auto}",{createAtom:e=>{var i;return new ws(d(P({},e),{body:Ce((i=e.args)==null?void 0:i[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"rel",svgAbove:e.command.slice(1)}))}}),ke("overbrace","{:auto}",{createAtom:e=>new ws(d(P({},e),{body:Ce(e.args[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"ord",svgAbove:e.command.slice(1)}))}),ke(["underrightarrow","underleftarrow","underleftrightarrow","underlinesegment","undergroup"],"{:auto}",{createAtom:e=>new ws(d(P({},e),{body:Ce(e.args[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"rel",svgBelow:e.command.slice(1)}))}),ke(["underbrace"],"{:auto}",{createAtom:e=>new ws(d(P({},e),{body:Ce(e.args[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"ord",svgBelow:e.command.slice(1)}))}),ke(["xrightarrow","longrightarrow","xleftarrow","longleftarrow","xRightarrow","xLeftarrow","xleftharpoonup","xleftharpoondown","xrightharpoonup","xrightharpoondown","xlongequal","xtwoheadleftarrow","xtwoheadrightarrow","xleftrightarrow","longleftrightarrow","xLeftrightarrow","xrightleftharpoons","longrightleftharpoons","xleftrightharpoons","xhookleftarrow","xhookrightarrow","xmapsto","xtofrom","xleftrightarrows","longleftrightarrows","xRightleftharpoons","longRightleftharpoons","xLeftrightharpoons","longLeftrightharpoons"],"[:auto]{:auto}",{createAtom:e=>{var i,r,a,u,p;return new ws(d(P({},e),{svgBody:e.command.slice(1),above:((r=Ce((i=e.args)==null?void 0:i[1]))==null?void 0:r.length)===0?void 0:Ce((a=e.args)==null?void 0:a[1]),below:(p=Ce((u=e.args)==null?void 0:u[0]))!=null?p:null,skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,paddedLabels:!0,boxType:"rel"}))},serialize:(e,i)=>e.command+(e.hasEmptyBranch("below")?"":`[${e.belowToLatex(i)}]`)+`{${e.aboveToLatex(i)}}${e.supsubToLatex(i)}`}),ke(["arccos","arcsin","arctan","arctg","arcctg","arg","ch","cos","cosh","cot","cotg","coth","ctg","cth","csc","cosec","deg","dim","exp","gcd","hom","inf","ker","lb","lg","ln","log","Pr","sec","sh","sin","sinh","sup","tan","tanh","tg","th","arcsec","arccsc","arsinh","arcosh","artanh","arcsech","arccsch"],"",{isFunction:!0,ifMode:"math",createAtom:e=>new mo(e.command.slice(1),d(P({},e),{limits:"adjacent",isFunction:!0,variant:"main",variantStyle:"up"}))}),ke(["liminf","limsup"],"",{ifMode:"math",createAtom:e=>new mo({"\\liminf":"lim inf","\\limsup":"lim sup"}[e.command],d(P({},e),{limits:"over-under",variant:"main"}))}),ke(["lim","mod"],"",{ifMode:"math",createAtom:e=>new mo(e.command.slice(1),d(P({},e),{limits:"over-under",variant:"main"}))}),ke(["det","max","min"],"",{ifMode:"math",isFunction:!0,createAtom:e=>new mo(e.command.slice(1),d(P({},e),{limits:"over-under",isFunction:!0,variant:"main"}))}),ke(["ang"],"{:math}",{ifMode:"math",createAtom:e=>new et(d(P({},e),{body:Ce(e.args[0])})),serialize:(e,i)=>`\\ang{${e.bodyToLatex(i)}}`,render:(e,i)=>{const r=e.createBox(i),a=r.caret;r.caret=void 0;const u=new Tt("\xB0",{style:d(P({},e.style),{variant:"normal",variantStyle:"up"})});return new Tt([r,u],{type:"inner",isSelected:e.isSelected,caret:a})}}),ke("sqrt","[index:auto]{radicand:expression}",{ifMode:"math",createAtom:e=>new $u(d(P({},e),{body:Ce(e.args[1]),index:e.args[0]?Ce(e.args[0]):void 0}))}),ke(["frac","dfrac","tfrac","cfrac","binom","dbinom","tbinom"],"{:expression}{:expression}",{ifMode:"math",createAtom:e=>{const i=P({},e),r=e.command,a=e.args;switch(r){case"\\dfrac":case"\\frac":case"\\tfrac":i.hasBarLine=!0;break;case"\\atopfrac":i.hasBarLine=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":i.hasBarLine=!1,i.leftDelim="(",i.rightDelim=")";break;case"\\cfrac":i.hasBarLine=!0,i.continuousFraction=!0;break;default:}switch(r){case"\\dfrac":case"\\dbinom":i.mathstyleName="displaystyle";break;case"\\tfrac":case"\\tbinom":i.mathstyleName="textstyle";break;default:}return new Vo(a[0]?Ce(a[0]):[new fa],a[1]?Ce(a[1]):[new fa],i)},serialize:(e,i)=>{const r=e.aboveToLatex(i),a=e.belowToLatex(i);return/^[0-9]$/.test(r)&&/^[0-9]$/.test(a)?`${e.command}${r}${a}`:jn(e.command,r,a)}}),ke(["brace","brack"],"",{infix:!0,createAtom:e=>new Vo(Ce(e.args[0]),Ce(e.args[1]),d(P({},e),{hasBarLine:!1,leftDelim:e.command==="\\brace"?"\\lbrace":"\\lbrack",rightDelim:e.command==="\\brace"?"\\rbrace":"\\rbrack"})),serialize:(e,i)=>sn([e.aboveToLatex(i),e.command,e.belowToLatex(i)])}),ke(["over","atop","choose"],"",{infix:!0,createAtom:e=>{let i,r;const a=e.args;return e.command==="\\choose"&&(i="(",r=")"),new Vo(Ce(a[0]),Ce(a[1]),d(P({},e),{hasBarLine:e.command==="\\over",leftDelim:i,rightDelim:r}))},serialize:(e,i)=>sn([e.aboveToLatex(i),e.command,e.belowToLatex(i)])}),ke(["overwithdelims","atopwithdelims"],"{numer:auto}{denom:auto}{left-delim:delim}{right-delim:delim}",{infix:!0,createAtom:e=>{var i,r;const a=e.args;return new Vo(Ce(a[0]),Ce(a[1]),d(P({},e),{leftDelim:(i=a[2])!=null?i:".",rightDelim:(r=a[3])!=null?r:".",hasBarLine:!1}))},serialize:(e,i)=>`${e.aboveToLatex(i)} ${e.command}${e.leftDelim}${e.rightDelim}${e.belowToLatex(i)}`}),ke("pdiff","{numerator}{denominator}",{ifMode:"math",createAtom:e=>new Vo(Ce(e.args[0]),Ce(e.args[1]),d(P({},e),{hasBarLine:!0,numerPrefix:"\u2202",denomPrefix:"\u2202"}))}),ke(["sum","prod","bigcup","bigcap","coprod","bigvee","bigwedge","biguplus","bigotimes","bigoplus","bigodot","bigsqcup","intop"],"",{ifMode:"math",createAtom:e=>new Ml({coprod:"\u2210",bigvee:"\u22C1",bigwedge:"\u22C0",biguplus:"\u2A04",bigcap:"\u22C2",bigcup:"\u22C3",intop:"\u222B",prod:"\u220F",sum:"\u2211",bigotimes:"\u2A02",bigoplus:"\u2A01",bigodot:"\u2A00",bigsqcup:"\u2A06",smallint:"\u222B"}[e.command.slice(1)],d(P({},e),{limits:"auto",variant:"main"}))}),ke("smallint","",{ifMode:"math",createAtom:e=>new mo("\u222B",d(P({},e),{limits:"adjacent",variant:"main"}))});var xp={int:"\u222B",iint:"\u222C",iiint:"\u222D",oint:"\u222E",oiint:"\u222F",oiiint:"\u2230",intclockwise:"\u2231",varointclockwise:"\u2232",ointctrclockwise:"\u2233",intctrclockwise:"\u2A11",sqcup:"\u2294",sqcap:"\u2293",uplus:"\u228E",wr:"\u2240",amalg:"\u2A3F",Cap:"\u22D2",Cup:"\u22D3",doublecap:"\u22D2",doublecup:"\u22D3"};ke(Object.keys(xp),"",{ifMode:"math",createAtom:e=>{const i=e.command,r=xp[i.slice(1)];return new Ml(r,d(P({},e),{limits:"adjacent",variant:{"\u22D2":"ams","\u22D3":"ams"}[r]}))}}),ke(["Re","Im"],"",{ifMode:"math",createAtom:e=>new mo({"\\Re":"\u211C","\\Im":"\u2111"}[e.command],d(P({},e),{limits:"adjacent",isFunction:!0,variant:"fraktur"}))}),ke("middle","{:delim}",{ifMode:"math",createAtom:e=>{var i;return new kf(d(P({},e),{delim:(i=e.args[0])!=null?i:"|",size:1}))}}),ke("the","{:value}",{createAtom:e=>new et(d(P({},e),{captureSelection:!0,verbatimLatex:null})),render:(e,i)=>{var r;const a=new Si({parent:i},e.style);let u="";e.isSelected&&(u+=" ML__selected");const p=a.evaluate(e.args[0]);return new Tt(((r=Or(p))!=null?r:"").split("").map(g=>new Tt(g,{type:"ord",classes:u,mode:e.mode,isSelected:e.isSelected,style:P({variant:"main"},e.style)})),{type:"lift",style:e.style,caret:e.caret,isSelected:e.isSelected,classes:u}).wrap(a)},serialize:e=>{var i;return`\\the${(i=Or(e.args[0]))!=null?i:"\\relax"}`}}),ke("mathtip","{:auto}{:math}",{createAtom:e=>new zu(d(P({},e),{body:Ce(e.args[0]),tooltip:Ce(e.args[1]),content:"math"})),serialize:(e,i)=>i.skipStyles?e.bodyToLatex(i):`\\texttip{${e.bodyToLatex(i)}}{${et.serialize([e.tooltip],d(P({},i),{defaultMode:"math"}))}}`}),ke("texttip","{:auto}{:text}",{createAtom:e=>new zu(d(P({},e),{body:Ce(e.args[0]),tooltip:Ce(e.args[1]),content:"text"})),serialize:(e,i)=>i.skipStyles?e.bodyToLatex(i):`\\texttip{${e.bodyToLatex(i)}}{${et.serialize([e.tooltip],d(P({},i),{defaultMode:"text"}))}}`}),ke("error","{:math}",{createAtom:e=>new et(d(P({},e),{body:Ce(e.args[0])})),serialize:(e,i)=>`\\error{${e.bodyToLatex(i)}}`,render:(e,i)=>e.createBox(i,{classes:"ML__error"})}),ke("ensuremath","{:math}",{createAtom:e=>new et(d(P({},e),{body:Ce(e.args[0])})),serialize:(e,i)=>`${e.command}{${e.bodyToLatex(d(P({},i),{defaultMode:"math"}))}}`}),ke("color","{:value}",{applyStyle:(e,i,r)=>{var a,u;return{verbatimColor:(a=Or(i[0]))!=null?a:void 0,color:r.toColor((u=i[0])!=null?u:{string:"red"})}}}),ke("textcolor","{:value}{content:auto*}",{applyStyle:(e,i,r)=>{var a,u;return{verbatimColor:(a=Or(i[0]))!=null?a:void 0,color:r.toColor((u=i[0])!=null?u:{string:"red"})}}}),ke("boxed","{content:math}",{createAtom:e=>new Ma(d(P({},e),{body:Ce(e.args[0]),framecolor:{string:"black"}}))}),ke("colorbox","{:value}{:text*}",{applyStyle:(e,i,r)=>{var a,u;return{verbatimBackgroundColor:(a=Or(i[0]))!=null?a:void 0,backgroundColor:r.toBackgroundColor((u=i[0])!=null?u:{string:"yellow"})}}}),ke("fcolorbox","{frame-color:value}{background-color:value}{content:text}",{applyMode:"text",createAtom:e=>{var i,r;return new Ma(d(P({},e),{body:Ce(e.args[2]),framecolor:(i=e.args[0])!=null?i:{string:"blue"},backgroundcolor:(r=e.args[1])!=null?r:{string:"yellow"}}))},serialize:(e,i)=>{var r,a;return i.skipStyles?e.bodyToLatex(d(P({},i),{defaultMode:"text"})):jn(e.command,(r=Or(e.framecolor))!=null?r:"",(a=Or(e.backgroundcolor))!=null?a:"",e.bodyToLatex(d(P({},i),{defaultMode:"text"})))}}),ke("bbox","[:bbox]{body:auto}",{createAtom:e=>{var i;const r=e.args[0],a=Ce(e.args[1]);return r?new Ma(d(P({},e),{body:a,padding:r.padding,border:r.border,backgroundcolor:(i=r.backgroundcolor)!=null?i:void 0})):new Ma(d(P({},e),{body:a}))},serialize:(e,i)=>{var r,a;if(i.skipStyles)return e.bodyToLatex(i);let u=e.command;if(Number.isFinite(e.padding)||e.border!==void 0||e.backgroundcolor!==void 0){const p=[];e.padding&&p.push((r=Or(e.padding))!=null?r:""),e.border&&p.push(`border: ${e.border}`),e.backgroundcolor&&p.push((a=Or(e.backgroundcolor))!=null?a:""),u+=`[${p.join(",")}]`}return jn(u,e.bodyToLatex(i))}}),ke(["displaystyle","textstyle","scriptstyle","scriptscriptstyle"],"{:rest}",{createAtom:e=>new et(d(P({},e),{body:Ce(e.args[0])})),render:(e,i)=>{const r=new Si({parent:i,mathstyle:e.command.slice(1)},e.style),a=et.createBox(r,e.body,{type:"lift"});return e.caret&&(a.caret=e.caret),e.bind(i,a)},serialize:(e,i)=>i.skipStyles?e.bodyToLatex(i):`{${sn([e.command,e.bodyToLatex(i)])}}`}),ke(["tiny","scriptsize","footnotesize","small","normalsize","large","Large","LARGE","huge","Huge"],"",{applyStyle:e=>({fontSize:{"\\tiny":1,"\\scriptsize":2,"\\footnotesize":3,"\\small":4,"\\normalsize":5,"\\large":6,"\\Large":7,"\\LARGE":8,"\\huge":9,"\\Huge":10}[e]})}),ke("fontseries","{:string}",{ifMode:"text",applyStyle:(e,i)=>{var r;return{fontSeries:(r=i[0])!=null?r:"auto"}}}),ke("fontshape","{:string}",{ifMode:"text",applyStyle:(e,i)=>{var r;return{fontShape:(r=i[0])!=null?r:"auto"}}}),ke("fontfamily","{:string}",{ifMode:"text",applyStyle:(e,i)=>{var r;return{fontFamily:(r=i[0])!=null?r:"roman"}}}),ke("selectfont","",{ifMode:"text",applyStyle:()=>({})}),ke("bf","{:rest}",{applyStyle:()=>({fontSeries:"b",fontShape:"n",fontFamily:"roman"})}),ke(["boldsymbol","bm"],"{:math}",{applyMode:"math",createAtom:e=>new et(d(P({},e),{body:Ce(e.args[0])})),serialize:(e,i)=>`${e.command}{${e.bodyToLatex(i)}}`,render:(e,i)=>e.createBox(i,{classes:"ML__boldsymbol"})}),ke("bold","{:math*}",{applyMode:"math",applyStyle:()=>({variantStyle:"bold"})}),ke("bfseries","{:rest}",{applyMode:"text",applyStyle:()=>({fontSeries:"b"})}),ke("mdseries","{:rest}",{applyMode:"text",applyStyle:()=>({fontSeries:"m"})}),ke("upshape","{:rest}",{applyMode:"text",applyStyle:()=>({fontShape:"n"})}),ke("slshape","{:rest}",{applyMode:"text",applyStyle:()=>({fontShape:"sl"})}),ke("scshape","{:rest}",{applyMode:"text",applyStyle:()=>({fontShape:"sc"})}),ke("textbf","{:text*}",{applyMode:"text",applyStyle:()=>({fontSeries:"b"})}),ke("textmd","{:text*}",{applyMode:"text",applyStyle:()=>({fontSeries:"m"})}),ke("textup","{:text*}",{applyMode:"text",applyStyle:()=>({fontShape:"n"})}),ke("textnormal","{:text*}",{applyMode:"text",applyStyle:()=>({fontShape:"n",fontSeries:"m"})}),ke("textsl","{:text*}",{applyMode:"text",applyStyle:()=>({fontShape:"sl"})}),ke("textit","{:text*}",{applyMode:"text",applyStyle:()=>({fontShape:"it"})}),ke("textsc","{:text*}",{applyMode:"text",applyStyle:()=>({fontShape:"sc"})}),ke("textrm","{:text*}",{applyMode:"text",applyStyle:()=>({fontFamily:"roman"})}),ke("textsf","{:text*}",{applyMode:"text",applyStyle:()=>({fontFamily:"sans-serif"})}),ke("texttt","{:text*}",{applyMode:"text",applyStyle:()=>({fontFamily:"monospace"})}),ke("mathbf","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"normal",variantStyle:"bold"})}),ke("mathit","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"main",variantStyle:"italic"})}),ke("mathnormal","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"normal",variantStyle:"italic"})}),ke("mathbfit","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"main",variantStyle:"bolditalic"})}),ke("mathrm","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"normal",variantStyle:"up"})}),ke("mathsf","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"sans-serif",variantStyle:"up"})}),ke("mathtt","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"monospace",variantStyle:"up"})}),ke("it","{:rest}",{applyStyle:()=>({fontSeries:"m",fontShape:"it",fontFamily:"roman",variantStyle:"italic"})}),ke("rmfamily","",{applyStyle:()=>({fontFamily:"roman"})}),ke("sffamily","",{applyStyle:()=>({fontFamily:"sans-serif"})}),ke("ttfamily","",{applyStyle:()=>({fontFamily:"monospace"})}),ke(["Bbb","mathbb"],"{:math*}",{applyStyle:()=>({variant:"double-struck",variantStyle:"up"})}),ke(["frak","mathfrak"],"{:math*}",{applyStyle:()=>({variant:"fraktur",variantStyle:"up"})}),ke("mathcal","{:math*}",{applyStyle:()=>({variant:"calligraphic",variantStyle:"up"})}),ke("mathscr","{:math*}",{applyStyle:()=>({variant:"script",variantStyle:"up"})}),ke("mbox","{:text}",{ifMode:"math",createAtom:e=>new et(d(P({},e),{type:"mord",body:Ce(e.args[0]),mode:"math"})),serialize:(e,i)=>jn("\\mbox",e.bodyToLatex(d(P({},i),{defaultMode:"text"})))}),ke("text","{:text}",{ifMode:"math",applyMode:"text"}),ke(["class","htmlClass"],"{name:string}{content:auto}",{createAtom:e=>new et(d(P({},e),{body:Ce(e.args[1])})),serialize:(e,i)=>!e.args[0]||i.skipStyles?e.bodyToLatex(i):`${e.command}{${e.args[0]}}{${e.bodyToLatex(i)}}`,render:(e,i)=>{var r;return e.createBox(i,{classes:(r=e.args[0])!=null?r:""})}}),ke(["cssId","htmlId"],"{id:string}{content:auto}",{createAtom:e=>new et(d(P({},e),{body:Ce(e.args[1])})),serialize:(e,i)=>{var r;return!((r=e.args)!=null&&r[0])||i.skipStyles?e.bodyToLatex(i):`${e.command}{${e.args[0]}}{${e.bodyToLatex(i)}}`},render:(e,i)=>{var r;const a=e.createBox(i);return a.cssId=(r=e.args[0])!=null?r:"",a}}),ke("htmlData","{data:string}{content:auto}",{createAtom:e=>new et(d(P({},e),{body:Ce(e.args[1])})),serialize:(e,i)=>{var r;return!((r=e.args)!=null&&r[0])||i.skipStyles?e.bodyToLatex(i):`\\htmlData{${e.args[0]}}{${e.bodyToLatex(i)}}`},render:(e,i)=>{var r;const a=e.createBox(i);return a.htmlData=(r=e.args[0])!=null?r:"",a}}),ke(["style","htmlStyle"],"{data:string}{content:auto}",{createAtom:e=>new et(d(P({},e),{body:Ce(e.args[1])})),serialize:(e,i)=>{var r;return!((r=e.args)!=null&&r[0])||i.skipStyles?e.bodyToLatex(i):`${e.command}{${e.args[0]}}{${e.bodyToLatex(i)}}`},render:(e,i)=>{var r;const a=e.createBox(i);return a.htmlStyle=(r=e.args[0])!=null?r:"",a}}),ke("em","{:rest}",{createAtom:e=>new et(d(P({},e),{body:Ce(e.args[0])})),serialize:(e,i)=>i.skipStyles?e.bodyToLatex(i):`{\\em ${e.bodyToLatex(i)}}`,render:(e,i)=>e.createBox(i,{classes:"ML__emph",boxType:"lift"})}),ke("emph","{:auto}",{createAtom:e=>new et(d(P({},e),{body:Ce(e.args[1])})),serialize:(e,i)=>i.skipStyles?e.bodyToLatex(i):`\\emph{${e.bodyToLatex(i)}}`,render:(e,i)=>e.createBox(i,{classes:"ML__emph",boxType:"lift"})});var wp={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}};ke(["bigl","Bigl","biggl","Biggl","bigr","Bigr","biggr","Biggr","bigm","Bigm","biggm","Biggm","big","Big","bigg","Bigg"],"{:delim}",{createAtom:e=>{var i;return new Bu(d(P({},e),{delim:(i=e.args[0])!=null?i:".",size:wp[e.command].size,delimType:wp[e.command].mclass}))}}),ke(["hspace","hspace*"],"{width:value}",{createAtom:e=>{var i;return new Go(d(P({},e),{width:(i=e.args[0])!=null?i:{dimension:0}}))}}),ke(["mkern","kern","mskip","hskip","mspace"],"{width:value}",{createAtom:e=>{var i;return new Go(d(P({},e),{width:(i=e.args[0])!=null?i:{dimension:0}}))}}),ke("mathchoice","{:math}{:math}{:math}{:math}",{createAtom:e=>new et(e),render:(e,i)=>{let r=0;const a=i.mathstyle.id;(a===bl||a===ro)&&(r=1),(a===Bo||a===bs)&&(r=2),(a===so||a===es)&&(r=3);const u=Ce(e.args[r]);return et.createBox(i,u)},serialize:(e,i)=>`\\mathchoice{${et.serialize(e.args[0],i)}}{${et.serialize(e.args[1],i)}}{${et.serialize(e.args[2],i)}}{${et.serialize(e.args[3],i)}}`}),ke("mathop","{:auto}",{createAtom:e=>new et(d(P({},e),{type:"mop",body:Ce(e.args[0]),limits:"over-under",isFunction:!0,captureSelection:!0})),render:(e,i)=>{var r;let a=et.createBox(i,e.body);if(e.superscript||e.subscript){const u=(r=e.subsupPlacement)!=null?r:"auto";a=u==="over-under"||u==="auto"&&i.isDisplayStyle?e.attachLimits(i,{base:a}):e.attachSupsub(i,{base:a})}return new Tt(e.bind(i,a),{type:"op",isSelected:e.isSelected,classes:"op-group"})},serialize:(e,i)=>{const r=[jn(e.command,e.bodyToLatex(i))];return e.explicitSubsupPlacement&&(e.subsupPlacement==="over-under"&&r.push("\\limits"),e.subsupPlacement==="adjacent"&&r.push("\\nolimits"),e.subsupPlacement==="auto"&&r.push("\\displaylimits")),r.push(e.supsubToLatex(i)),sn(r)}}),ke(["mathbin","mathrel","mathopen","mathclose","mathpunct","mathord","mathinner"],"{:auto}",{createAtom:e=>new et(d(P({},e),{type:{"\\mathbin":"mbin","\\mathrel":"mrel","\\mathopen":"mopen","\\mathclose":"mclose","\\mathpunct":"mpunct","\\mathord":"mord","\\mathinner":"minner"}[e.command],body:Ce(e.args[0])}))}),ke(["operatorname","operatorname*"],"{operator:math}",{createAtom:e=>{const i=Ce(e.args[0]).map(r=>{var a;return r.type!=="first"&&(r.type="mord",r.value=(a={"\u2217":"*","\u2212":"-"}[r.value])!=null?a:r.value,r.isFunction=!1,!r.style.variant&&!r.style.variantStyle&&(r.style.variant="main",r.style.variantStyle="up")),r});return new et(d(P({},e),{type:"mop",body:i,isFunction:!0,limits:e.command==="\\operatorname"?"adjacent":"over-under"}))},render:(e,i)=>{var r;let a=et.createBox(i,e.body);if(e.superscript||e.subscript){const u=(r=e.subsupPlacement)!=null?r:"auto";a=u==="over-under"||u==="auto"&&i.isDisplayStyle?e.attachLimits(i,{base:a}):e.attachSupsub(i,{base:a})}return e.caret&&(a.caret=e.caret),new Tt(e.bind(i,a),{type:"op",isSelected:e.isSelected,classes:"op-group"})},serialize:(e,i)=>{const r=[jn(e.command,e.bodyToLatex(i))];return e.explicitSubsupPlacement&&(e.subsupPlacement==="over-under"&&r.push("\\limits"),e.subsupPlacement==="adjacent"&&r.push("\\nolimits"),e.subsupPlacement==="auto"&&r.push("\\displaylimits")),r.push(e.supsubToLatex(i)),sn(r)}}),ke(["char","unicode"],"{charcode:value}",{createAtom:e=>new et(d(P({},e),{type:e.mode==="text"?"text":"mord"})),serialize:e=>{var i;return`${e.command}${Or((i=e.args[0])!=null?i:{number:10067,base:"hexadecimal"})}`},render:(e,i)=>{let r=i.evaluate(e.args[0]);return(!r||!("number"in r))&&(r={number:10067,base:"hexadecimal"}),e.value=String.fromCodePoint(r.number),e.createBox(i)}}),ke("rule","[raise:value]{width:value}{thickness:value}",{createAtom:e=>new et(e),render:(e,i)=>{var r,a,u;const p=new Si({parent:i,mathstyle:"textstyle"},e.style),g=p.toEm((r=e.args[0])!=null?r:{dimension:0}),b=p.toEm((a=e.args[1])!=null?a:{dimension:10}),w=p.toEm((u=e.args[2])!=null?u:{dimension:10}),E=new Tt(null,{classes:"rule",type:"ord"});return E.width=b,E.height=w+g,E.depth=-g,E.setStyle("border-right-width",b,"em"),E.setStyle("border-top-width",w,"em"),E.setStyle("border-color",e.style.color),E.setStyle("vertical-align",g,"em"),e.isSelected&&E.setStyle("opacity","50%"),e.bind(p,E),e.caret&&(E.caret=e.caret),E.wrap(i)},serialize:e=>`\\rule${e.args[0]?`[${Or(e.args[0])}]`:""}{${Or(e.args[1])}}{${Or(e.args[2])}}`}),ke(["overline","underline"],"{:auto}",{createAtom:e=>new et(d(P({},e),{body:Ce(e.args[0])})),render:(e,i)=>{const r=e.command.substring(1),a=new Si({parent:i,mathstyle:"cramp"},e.style),u=et.createBox(a,e.body);if(!u)return null;const p=a.metrics.defaultRuleThickness/a.scalingFactor,g=new Tt(null,{classes:r+"-line"});g.height=p,g.maxFontSize=p*1.125*a.scalingFactor;let b;return r==="overline"?b=new kr({shift:0,children:[{box:u},3*p,{box:g},p]}):b=new kr({top:u.height,children:[p,{box:g},3*p,{box:u}]}),e.caret&&(b.caret=e.caret),new Tt(b,{classes:r,type:"ignore"})}}),ke("overset","{:auto}{base:auto}",{createAtom:e=>{const i=Ce(e.args[1]);return new ws(d(P({},e),{above:Ce(e.args[0]),body:i,skipBoundary:!1,boxType:_l(i)}))},serialize:(e,i)=>jn(e.command,e.aboveToLatex(i),e.bodyToLatex(i))}),ke("underset","{:auto}{base:auto}",{createAtom:e=>{const i=Ce(e.args[1]);return new ws(d(P({},e),{below:Ce(e.args[0]),body:i,skipBoundary:!1,boxType:_l(i)}))},serialize:(e,i)=>jn(e.command,e.belowToLatex(i),e.bodyToLatex(i))}),ke("overunderset","{above:auto}{below:auto}{base:auto}",{createAtom:e=>{const i=Ce(e.args[2]);return new ws(d(P({},e),{above:Ce(e.args[0]),below:Ce(e.args[1]),body:i,skipBoundary:!1,boxType:_l(i)}))},serialize:(e,i)=>jn(e.command,e.belowToLatex(i),e.bodyToLatex(i))}),ke(["stackrel","stackbin"],"[below:auto]{above:auto}{base:auto}",{createAtom:e=>new ws(d(P({},e),{body:Ce(e.args[2]),above:Ce(e.args[1]),below:Ce(e.args[0]),skipBoundary:!1,boxType:e.command==="\\stackrel"?"rel":"bin"})),serialize:(e,i)=>jn(e.command,e.aboveToLatex(i),e.bodyToLatex(i))}),ke("smash","[:string]{:auto}",{createAtom:e=>{var i,r,a,u;return new po(d(P({},e),{body:Ce(e.args[1]),smashHeight:(r=(i=e.args[0])==null?void 0:i.includes("t"))!=null?r:!0,smashDepth:(u=(a=e.args[0])==null?void 0:a.includes("b"))!=null?u:!0}))}}),ke(["vphantom"],"{:auto}",{createAtom:e=>new po(d(P({},e),{body:Ce(e.args[0]),isInvisible:!0,smashWidth:!0}))}),ke(["hphantom"],"{:auto}",{createAtom:e=>new po(d(P({},e),{body:Ce(e.args[0]),isInvisible:!0,smashHeight:!0,smashDepth:!0}))}),ke(["phantom"],"{:auto}",{createAtom:e=>new po(d(P({},e),{body:Ce(e.args[0]),isInvisible:!0}))}),ke("not","{:math}",{createAtom:e=>{const i=Ce(e.args[0]);return i.length===0?new et(d(P({},e),{type:"mrel",value:"\uE020"})):new et(d(P({},e),{body:[new Ia(d(P({},e),{body:"\uE020",align:"right"})),...i],captureSelection:!0}))},serialize:(e,i)=>{const r=e.args[0],a=r&&typeof r=="object"&&"group"in r;return e.value!=="\uE020"?a?`\\not{${et.serialize(r.group,i)}}`:`\\not${et.serialize(r,i)}`:a?"\\not{}":"\\not"},render:(e,i)=>{if(e.value)return e.createBox(i);const a=e.args[0]&&typeof e.args[0]=="object"&&"group"in e.args[0]?"ord":_l(Ce(e.args[0])),u=et.createBox(i,e.body,{type:a});return e.caret&&(u.caret=e.caret),e.bind(i,u)}}),ke(["ne","neq"],"",{createAtom:e=>new et(d(P({},e),{type:"mrel",body:[new Ia(d(P({},e),{body:"\uE020",align:"right",boxType:"rel"})),new et(d(P({},e),{value:"="}))],captureSelection:!0})),serialize:e=>e.command}),ke("rlap","{:auto}",{createAtom:e=>new Ia(d(P({},e),{body:Ce(e.args[0]),align:"right"}))}),ke("llap","{:auto}",{createAtom:e=>new Ia(d(P({},e),{body:Ce(e.args[0]),align:"left"}))}),ke("mathrlap","{:math}",{createAtom:e=>new Ia(d(P({},e),{body:Ce(e.args[0]),align:"left"}))}),ke("mathllap","{:math}",{createAtom:e=>new Ia(d(P({},e),{body:Ce(e.args[0]),align:"left"}))}),ke("raisebox","{:value}{:text}",{createAtom:e=>{var i;return new Ma(d(P({},e),{body:Ce(e.args[1]),padding:{dimension:0},offset:(i=e.args[0])!=null?i:{dimension:0}}))},serialize:(e,i)=>{var r;return jn("\\raisebox",(r=Or(e.offset))!=null?r:"0pt",e.bodyToLatex(i))}}),ke("raise","{:value}{:auto}",{createAtom:e=>{var i;return new Ma(d(P({},e),{body:Ce(e.args[1]),padding:{dimension:0},offset:(i=e.args[0])!=null?i:{dimension:0}}))},serialize:(e,i)=>{var r;return jn("\\raise",(r=Or(e.offset))!=null?r:"0pt",e.bodyToLatex(i))}}),ke("lower","{:value}{:auto}",{createAtom:e=>{var i;return new Ma(d(P({},e),{body:Ce(e.args[1]),padding:{dimension:0},offset:(i=Xs(e.args[0],-1))!=null?i:{dimension:0}}))},serialize:(e,i)=>{var r,a;return jn("\\lower",(a=Or(Xs((r=e.offset)!=null?r:{dimension:0},-1)))!=null?a:"0pt",e.bodyToLatex(i))}}),lt("0123456789/@.?!"),ee(65,90),ee(97,122),lt([["\\forall",8704],["\\exists",8707],["\\nexists",8708,"mord","ams"],["\\mid",8739,"mrel"],["\\top",8868],["\\bot",8869]]),lt([["\\#",35],["\\&",38],["\\parallelogram",9649],["\\spadesuit",9824],["\\heartsuit",9825],["\\diamondsuit",9826],["\\clubsuit",9827],["\\flat",9837],["\\natural",9838],["\\sharp",9839]]),lt([["\\backslash",92],["\\nabla",8711],["\\partial",8706],["\\ell",8467],["\\hbar",8463],["\\Q",81,"mord","double-struck"],["\\C",67,"mord","double-struck"],["\\P",80,"mord","double-struck"],["\\pounds",163],["\\euro",8364]]),lt([["\\rightarrow",8594],["\\to",8594],["\\leftarrow",8592],["\\gets",8592],["\\Rightarrow",8658],["\\Leftarrow",8656],["\\longrightarrow",10230],["\\longleftarrow",10229],["\\Longrightarrow",10233],["\\implies",10233],["\\Longleftarrow",10232],["\\impliedby",10232],["\\longleftrightarrow",10231],["\\biconditional",10231],["\\Longleftrightarrow",10234],["\\mapsto",8614],["\\longmapsto",10236],["\\uparrow",8593],["\\downarrow",8595],["\\Uparrow",8657],["\\Downarrow",8659],["\\updownarrow",8597],["\\Updownarrow",8661],["\\hookrightarrow",8618],["\\hookleftarrow",8617],["\\rightharpoonup",8640],["\\leftharpoonup",8636],["\\rightharpoondown",8641],["\\leftharpoondown",8637],["\\searrow",8600],["\\nearrow",8599],["\\swarrow",8601],["\\nwarrow",8598],["\\originalof",8886],["\\laplace",8886],["\\imageof",8887],["\\Laplace",8887]],"mrel"),lt([["\\mapsfrom",8612,"mrel"],["\\Mapsfrom",10502,"mrel"],["\\MapsTo",10503,"mrel"],["\\Yup",8516,"mord"],["\\lightning",8623,"mrel"],["\\leftarrowtriangle",8701,"mrel"],["\\rightarrowtriangle",8702,"mrel"],["\\leftrightarrowtriangle",8703,"mrel"],["\\boxdot",8865,"mbin"],["\\bigtriangleup",9651,"mbin"],["\\bigtriangledown",9661,"mbin"],["\\boxbar",9707,"mbin"],["\\Lbag",10181,"mopen"],["\\Rbag",10182,"mclose"],["\\llbracket",10214,"mopen"],["\\rrbracket",10215,"mclose"],["\\longmapsfrom",10235,"mrel"],["\\Longmapsfrom",10237,"mrel"],["\\Longmapsto",10238,"mrel"],["\\boxslash",10692,"mbin"],["\\boxbslash",10693,"mbin"],["\\boxast",10694,"mbin"],["\\boxcircle",10695,"mbin"],["\\boxbox",10696,"mbin"],["\\fatsemi",10783,"mop"],["\\leftslice",10918,"mrel"],["\\rightslice",10919,"mrel"],["\\interleave",10996,"mbin"],["\\biginterleave",11004,"mop"],["\\sslash",11005,"mbin"],["\\talloblong",11006,"mbin"]]),lt([["\\lbrace",123,"mopen"],["\\rbrace",125,"mclose"],["\\lparen",40,"mopen"],["\\rparen",41,"mclose"],["\\langle",10216,"mopen"],["\\rangle",10217,"mclose"],["\\lfloor",8970,"mopen"],["\\rfloor",8971,"mclose"],["\\lceil",8968,"mopen"],["\\rceil",8969,"mclose"],["\\vert",8739],["\\lvert",8739,"mopen"],["\\rvert",8739,"mclose"],["\\|",8741],["\\Vert",8741],["\\mVert",8741],["\\lVert",8741,"mopen"],["\\rVert",8741,"mclose"],["\\lbrack",91,"mopen"],["\\rbrack",93,"mclose"],["\\{",123,"mopen"],["\\}",125,"mclose"],["(",40,"mopen"],[")",41,"mclose"],["[",91,"mopen"],["]",93,"mclose"],["\\ulcorner",9484,"mopen","ams"],["\\urcorner",9488,"mclose","ams"],["\\llcorner",9492,"mopen","ams"],["\\lrcorner",9496,"mclose","ams"],["\\lgroup",10222,"mopen"],["\\rgroup",10223,"mclose"],["\\lmoustache",9136,"mopen"],["\\rmoustache",9137,"mclose"]]),lt([["\\dashrightarrow",8674],["\\dashleftarrow",8672],["\\Rrightarrow",8667],["\\Lleftarrow",8666],["\\leftrightarrows",8646],["\\rightleftarrows",8644],["\\curvearrowright",8631],["\\curvearrowleft",8630],["\\rightrightarrows",8649],["\\leftleftarrows",8647],["\\upuparrows",8648],["\\downdownarrows",8650],["\\vartriangle",9651],["\\triangleq",8796],["\\vartriangleleft",8882],["\\trianglelefteq",8884],["\\ntriangleleft",8938],["\\ntrianglelefteq",8940],["\\vartriangleright",8883],["\\trianglerighteq",8885],["\\ntriangleright",8939],["\\ntrianglerighteq",8941],["\\blacktriangleleft",9664],["\\blacktriangleright",9654],["\\leftarrowtail",8610],["\\rightarrowtail",8611],["\\looparrowright",8620],["\\looparrowleft",8619],["\\twoheadleftarrow",8606],["\\twoheadrightarrow",8608],["\\twoheadrightarrowtail",10518],["\\rightleftharpoons",8652],["\\leftrightharpoons",8651],["\\Rsh",8625],["\\Lsh",8624],["\\circlearrowright",8635],["\\circlearrowleft",8634],["\\restriction",8638],["\\upharpoonright",8638],["\\upharpoonleft",8639],["\\downharpoonright",8642],["\\downharpoonleft",8643],["\\rightsquigarrow",8669],["\\leadsto",8669],["\\leftrightsquigarrow",8621],["\\multimap",8888],["\\nleftarrow",8602],["\\nrightarrow",8603],["\\nRightarrow",8655],["\\nLeftarrow",8653],["\\nleftrightarrow",8622],["\\nLeftrightarrow",8654],["\\nvrightarrow",8696],["\\nvtwoheadrightarrow",10496],["\\nvrightarrowtail",10516],["\\nvtwoheadrightarrowtail",10519],["\\shortparallel",8741],["\\nless",8814],["\\nleqslant",57360],["\\lneq",10887],["\\lneqq",8808],["\\nleqq",57361],["\\lvertneqq",57356],["\\lnsim",8934],["\\lnapprox",10889],["\\nprec",8832],["\\npreceq",8928],["\\precnsim",8936],["\\precnapprox",10937],["\\nsim",8769],["\\nshortmid",57350],["\\nmid",8740],["\\nvdash",8876],["\\nvDash",8877],["\\ngtr",8815],["\\ngeqslant",57359],["\\ngeqq",57358],["\\gneq",10888],["\\gneqq",8809],["\\gvertneqq",57357],["\\gnsim",8935],["\\gnapprox",10890],["\\nsucc",8833],["\\nsucceq",8929],["\\succnsim",8937],["\\succnapprox",10938],["\\ncong",8774],["\\nshortparallel",57351],["\\nparallel",8742],["\\nVDash",8879],["\\nsupseteqq",57368],["\\supsetneq",8843],["\\varsupsetneq",57371],["\\supsetneqq",10956],["\\varsupsetneqq",57369],["\\nVdash",8878],["\\precneqq",10933],["\\succneqq",10934],["\\nsubseteqq",57366],["\\leqslant",10877],["\\geqslant",10878],["\\gtrsim",8819],["\\approxeq",8778],["\\thickapprox",8776],["\\lessapprox",10885],["\\gtrapprox",10886],["\\precapprox",10935],["\\succapprox",10936],["\\thicksim",8764],["\\succsim",8831],["\\precsim",8830],["\\backsim",8765],["\\eqsim",8770],["\\backsimeq",8909],["\\lesssim",8818],["\\nleq",8816],["\\ngeq",8817],["\\smallsmile",8995],["\\smallfrown",8994],["\\leqq",8806],["\\eqslantless",10901],["\\lll",8920],["\\lessgtr",8822],["\\lesseqgtr",8922],["\\lesseqqgtr",10891],["\\risingdotseq",8787],["\\fallingdotseq",8786],["\\subseteqq",10949],["\\Subset",8912],["\\sqsubset",8847],["\\preccurlyeq",8828],["\\curlyeqprec",8926],["\\vDash",8872],["\\Vvdash",8874],["\\bumpeq",8783],["\\Bumpeq",8782],["\\geqq",8807],["\\eqslantgtr",10902],["\\ggg",8921],["\\gtrless",8823],["\\gtreqless",8923],["\\gtreqqless",10892],["\\supseteqq",10950],["\\Supset",8913],["\\sqsupset",8848],["\\succcurlyeq",8829],["\\curlyeqsucc",8927],["\\Vdash",8873],["\\shortmid",8739],["\\between",8812],["\\pitchfork",8916],["\\varpropto",8733],["\\backepsilon",8717],["\\llless",8920],["\\gggtr",8921],["\\doteqdot",8785],["\\Doteq",8785],["\\eqcirc",8790],["\\circeq",8791],["\\therefore",8756],["\\because",8757]],"mrel","ams"),lt([["+",43],["-",8722],["\u2212",8722],["\\pm",177],["\\mp",8723],["*",8727],["\\times",215],["\\div",247],["\\divides",8739],["\\cdot",8901],["\\cap",8745],["\\cup",8746],["\\setminus",8726],["\\land",8743],["\\wedge",8743],["\\lor",8744],["\\vee",8744],["\\circ",8728],["\\bigcirc",9711],["\\bullet",8729],["\\oplus",8853],["\\ominus",8854],["\\otimes",8855],["\\odot",8857],["\\oslash",8856],["\\bigtriangleup",9651],["\\bigtriangledown",9661],["\\triangleleft",9667],["\\triangleright",9657],["\\And",38],["\\dagger",8224],["\\dag",8224],["\\ddag",8225],["\\ddagger",8225],["\\ast",8727],["\\star",8902],["\\bigstar",9733],["\\diamond",8900]],"mbin"),lt([["\\lhd",8882],["\\rhd",8883],["\\lessdot",8918],["\\gtrdot",8919],["\\ltimes",8905],["\\rtimes",8906],["\\leftthreetimes",8907],["\\rightthreetimes",8908],["\\intercal",8890],["\\dotplus",8724],["\\doublebarwedge",10846],["\\divideontimes",8903],["\\centerdot",8901],["\\smallsetminus",8726],["\\barwedge",8892],["\\veebar",8891],["\\nor",8891],["\\curlywedge",8911],["\\curlyvee",8910],["\\boxminus",8863],["\\boxplus",8862],["\\boxtimes",8864],["\\boxdot",8865],["\\circleddash",8861],["\\circledast",8859],["\\circledcirc",8858],["\\unlhd",8884],["\\unrhd",8885]],"mbin","ams"),lt([["\\surd",8730],["\\infty",8734],["\\prime",8242],["\\doubleprime",8243],["\\angle",8736],["`",8216],["\\$",36],["\\%",37],["\\_",95],["\\alpha",945],["\\beta",946],["\\gamma",947],["\\delta",948],["\\epsilon",1013],["\\varepsilon",949],["\\zeta",950],["\\eta",951],["\\theta",952],["\\vartheta",977],["\\iota",953],["\\kappa",954],["\\varkappa",1008,"mord","ams"],["\\lambda",955],["\\mu",956],["\\nu",957],["\\xi",958],["\\omicron",111],["\\pi",960],["\\varpi",982],["\\rho",961],["\\varrho",1009],["\\sigma",963],["\\varsigma",962],["\\tau",964],["\\phi",981],["\\varphi",966],["\\upsilon",965],["\\chi",967],["\\psi",968],["\\omega",969],["\\Gamma",915],["\\Delta",916],["\\Theta",920],["\\Lambda",923],["\\Xi",926],["\\Pi",928],["\\Sigma",931],["\\Upsilon",933],["\\Phi",934],["\\Psi",936],["\\Omega",937],["\\digamma",989,"mord","ams"],["\\emptyset",8709]]),lt([["=",61],["<",60],["\\lt",60],[">",62],["\\gt",62],["\\le",8804],["\\leq",8804],["\\ge",8805],["\\geq",8805],["\\ll",8810],["\\gg",8811],["\\coloneq",8788],["\\coloneqq",8788],["\\colonequals",8788],["\\measeq",8797],["\\eqdef",8798],["\\questeq",8799],[":",58],["\\cong",8773],["\\equiv",8801],["\\prec",8826],["\\preceq",10927],["\\succ",8827],["\\succeq",10928],["\\perp",8869],["\\propto",8733],["\\Colon",8759],["\\smile",8995],["\\frown",8994],["\\sim",8764],["\\doteq",8784],["\\bowtie",8904],["\\Join",8904],["\\asymp",8781],["\\sqsubseteq",8849],["\\sqsupseteq",8850],["\\approx",8776],["\\~",126],["\\leftrightarrow",8596],["\\Leftrightarrow",8660],["\\models",8872],["\\vdash",8866],["\\dashv",8867],["\\roundimplies",10608],["\\in",8712],["\\notin",8713],["\\ni",8715],["\\owns",8715],["\\subset",8834],["\\supset",8835],["\\subseteq",8838],["\\supseteq",8839],["\\differencedelta",8710],["\\mvert",8739],["\\parallel",8741],["\\simeq",8771]],"mrel"),lt([["\\lnot",172],["\\neg",172],["\\triangle",9651],["\\subsetneq",8842],["\\varsubsetneq",57370],["\\subsetneqq",10955],["\\varsubsetneqq",57367],["\\nsubset",8836],["\\nsupset",8837],["\\nsubseteq",8840],["\\nsupseteq",8841]],"mrel","ams"),lt([["\\wp",8472],["\\aleph",8501]]),lt([["\\blacktriangle",9650],["\\hslash",8463],["\\Finv",8498],["\\Game",8513],["\\eth",240],["\\mho",8487],["\\Bbbk",107],["\\yen",165],["\\square",9633],["\\Box",9633],["\\blacksquare",9632],["\\circledS",9416],["\\circledR",174],["\\triangledown",9661],["\\blacktriangledown",9660],["\\checkmark",10003],["\\diagup",9585],["\\measuredangle",8737],["\\sphericalangle",8738],["\\backprime",8245],["\\backdoubleprime",8246],["\\Diamond",9674],["\\lozenge",9674],["\\blacklozenge",10731],["\\varnothing",8709],["\\complement",8705],["\\maltese",10016],["\\beth",8502],["\\daleth",8504],["\\gimel",8503]],"mord","ams"),lt([["\\ ",160],["~",160]],"space"),ke(["!",",",":",";",">","enskip","enspace","quad","qquad"],"",{createAtom:e=>new Go(e)}),ke("space","",{createAtom:e=>new Go(e)}),lt([["\\colon",58],["\\cdotp",8901],["\\vdots",8942,"mord"],["\\ldotp",46],[",",44],[";",59]],"mpunct"),lt([["\\cdots",8943],["\\ddots",8945],["\\ldots",8230],["\\mathellipsis",8230]],"minner"),lt([["\\/",47],["|",8739,"mord"],["\\imath",305],["\\jmath",567],["\\degree",176],["'",8242],['"',8221]]);var Sp="<mo>&#x2061;</mo>",id="<mo>&#8290;</mo>";function nd(e){return e.replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Un(e,i){return!e||!i.generateID?"":` extid="${e}"`}function Ig(e,i,r){var a,u,p,g,b,w,E,R,N,Z,ue;let me=!1;i=i!=null?i:e.atoms.length;let Ve="",Ct="",Ue=e.atoms[e.index];const ct=(u=(a=Ue.style)==null?void 0:a.variant)!=null?u:"",It=(g=(p=Ue.style)==null?void 0:p.variantStyle)!=null?g:"";let yt="";if(ct||It){const hi=ze(Ue.value,(b=Ue.style)==null?void 0:b.variant,(w=Ue.style)==null?void 0:w.variantStyle);if(hi!==Ue.value)return e.index+=1,Ve=`<mi${Un(Ue.id,r)}>${hi}</mi>`,bo(Ve,e,r)||(e.mathML+=Ve,e.lastType="mi"),!0;yt=(E={upnormal:"normal",boldnormal:"bold",italicmain:"italic",bolditalicmain:"bold-italic","updouble-struck":"double-struck","double-struck":"double-struck",boldfraktur:"bold-fraktur",calligraphic:"script",upcalligraphic:"script",script:"script",boldscript:"bold-script",boldcalligraphic:"bold-script",fraktur:"fraktur","upsans-serif":"sans-serif","boldsans-serif":"bold-sans-serif","italicsans-serif":"sans-serif-italic","bolditalicsans-serif":"sans-serif-bold-italic",monospace:"monospace"}[It+ct])!=null?E:"",yt=` mathvariant="${yt}"`}const ei={"\\exponentialE":"&#x02147;","\\imaginaryI":"&#x2148;","\\differentialD":"&#x2146;","\\capitalDifferentialD":"&#x2145;","\\alpha":"&#x03b1;","\\pi":"&#x03c0;","\\infty":"&#x221e;","\\forall":"&#x2200;","\\nexists":"&#x2204;","\\exists":"&#x2203;","\\hbar":"\u210F","\\cdotp":"\u22C5","\\ldots":"\u2026","\\cdots":"\u22EF","\\ddots":"\u22F1","\\vdots":"\u22EE","\\ldotp":"."};if(Ue.command==="!")return e.index+=1,Ve="<mo>!</mo>",bo(Ve,e,r)||(e.mathML+=Ve,e.lastType="mo"),!0;if(ei[Ue.command]){e.index+=1;let hi=`<mi${Un(Ue.id,r)}${yt}>${ei[Ue.command]}</mi>`;return(e.lastType==="mi"||e.lastType==="mn"||e.lastType==="mtext"||e.lastType==="fence")&&(hi=id+hi),bo(hi,e,r)||(e.mathML+=hi,e.lastType="mi"),!0}if(Ue.command==="\\operatorname")Ct=Qu(Ue.body),e.index+=1;else if(ct||It)for(;e.index<i&&(Ue.type==="mord"||Ue.type==="macro")&&!Ue.isDigit()&&ct===((N=(R=Ue.style)==null?void 0:R.variant)!=null?N:"")&&It===((ue=(Z=Ue.style)==null?void 0:Z.variantStyle)!=null?ue:"");)Ct+=Qu([Ue]),e.index+=1,Ue=e.atoms[e.index];else(Ue.type==="mord"||Ue.type==="macro")&&!Ue.isDigit()&&(Ct+=Qu([Ue]),e.index+=1);if(Ct.length>0){me=!0,Ve=`<mi${yt}>${Ct}</mi>`;const hi=e.lastType;Ve.endsWith(">f</mi>")||Ve.endsWith(">g</mi>")?(Ve+=Sp,e.lastType="applyfunction"):e.lastType=/^<mo>(.*)<\/mo>$/.test(Ve)?"mo":"mi",bo(Ve,e,r)||((hi==="mi"||hi==="mn"||hi==="mtext"||hi==="fence")&&(Ve=id+Ve),e.mathML+=Ve)}return me}function Pg(e){return e.index<e.atoms.length&&e.atoms[e.index].superscript&&e.atoms[e.index].type==="subsup"}function Og(e){let i=-1,r=e.index,a=!1,u=!1;for(;r<e.atoms.length&&!a&&!u;){const p=e.atoms[r];a=!p.isDigit(),u=!a&&p.superscript!==void 0,r++}return u&&(i=r-1),i}function bo(e,i,r){var a;let u=i.atoms[i.index-1];if(!u)return!1;if(!u.superscript&&!u.subscript)if(((a=i.atoms[i.index])==null?void 0:a.type)==="subsup")u=i.atoms[i.index],i.index+=1;else return!1;const p=i.lastType;i.lastType="";const g=Sn(u.superscript,r);i.lastType="";const b=Sn(u.subscript,r);if(i.lastType=p,!g&&!b)return!1;let w="";return g&&b?w=`<msubsup>${e}${b}${g}</msubsup>`:g?w=`<msup>${e}${g}</msup>`:b&&(w=`<msub>${e}${b}</msub>`),i.mathML+=w,i.lastType="",!0}function Fg(e,i,r){i=i!=null?i:e.atoms.length;const a=e.index;let u="";for(;e.index<i&&e.atoms[e.index].mode==="text";)u+=e.atoms[e.index].value?e.atoms[e.index].value:" ",e.index+=1;return u.length>0?(e.mathML+=`<mtext ${Un(e.atoms[a].id,r)}>${u}</mtext>`,e.lastType="mtext",!0):!1}function Bg(e,i,r){i=i!=null?i:e.atoms.length;const a=e.index;let u="",p=Og(e);for(p>=0&&p<i&&(i=p);e.index<i&&e.atoms[e.index].isDigit();)u+=e.atoms[e.index].asDigit(),e.index+=1;return u.length<=0?!1:(u="<mn"+Un(e.atoms[a].id,r)+">"+u+"</mn>",p<0&&Pg(e)&&(p=e.index,e.index+=1),bo(u,e,r)||(e.mathML+=u,e.lastType="mn"),!0)}function Ng(e,i,r){let a=!1;i=i!=null?i:e.atoms.length;let u="",p="";if(e.index<i&&e.atoms[e.index].type==="mopen"){let g=!1,b=0;const w=e.index;let E=-1,R=w+1;for(;R<i&&!g;)e.atoms[R].type==="mopen"?b+=1:e.atoms[R].type==="mclose"&&(b-=1),b===-1&&(g=!0,E=R),R+=1;g&&(u="<mrow>",u+=Hl(e.atoms[w],r),u+=Sn(e.atoms,r,w+1,E),u+=Hl(e.atoms[E],r),u+="</mrow>",e.index=E+1,(e.lastType==="mi"||e.lastType==="mn"||e.lastType==="mfrac"||e.lastType==="fence")&&(e.mathML+=id),bo(u,e,r)&&(a=!0,e.lastType="",u=""),p="fence")}return u.length>0&&(a=!0,e.mathML+=u,e.lastType=p),a}function $g(e,i,r){let a=!1;i=i!=null?i:e.atoms.length;let u="",p="";const g=e.atoms[e.index];if(!g)return!1;const b={"\\ne":"&ne;","\\neq":"&neq;","\\pm":"&#177;","\\times":"&#215;","\\colon":":","\\vert":"|","\\Vert":"\u2225","\\mid":"\u2223","\\{":"{","\\}":"}","\\lbrace":"{","\\rbrace":"}","\\lbrack":"[","\\rbrack":"]","\\lparen":"(","\\rparen":")","\\langle":"\u27E8","\\rangle":"\u27E9","\\lfloor":"\u230A","\\rfloor":"\u230B","\\lceil":"\u2308","\\rceil":"\u2309"};if(b[g.command]){e.index+=1;const w=`<mo${Un(g.id,r)}>${b[g.command]}</mo>`;return bo(w,e,r)||(e.mathML+=w,e.lastType="mo"),!0}if(e.index<i&&(g.type==="mbin"||g.type==="mrel"))u+=T0(e.atoms[e.index],r),e.index+=1,p="mo";else if(e.index<i&&(g.type==="mop"||g.type==="operator"||g.type==="extensible-symbol")){if(g.subsupPlacement==="over-under"&&(g.superscript||g.subscript)){const w=Hl(g,r);return g.superscript&&g.subscript?(u+="<munderover>"+w,u+=Sn(g.subscript,r),u+=Sn(g.superscript,r),u+="</munderover>"):g.superscript?(u+="<mover>"+w,u+=Sn(g.superscript,r),u+="</mover>"):g.subscript&&(u+="<munder>"+w,u+=Sn(g.subscript,r),u+="</munder>"),e.mathML+=u,e.lastType="mo",e.index+=1,!0}{const w=e.atoms[e.index],E=w.value==="\\operatorname",R=E?'<mi class="MathML-Unit"'+Un(w.id,r)+">"+Qu(w.value)+"</mi>":Hl(w,r);u+=R,!E&&!/^<mo>(.*)<\/mo>$/.test(R)?(u+=Sp,p="applyfunction"):p=E?"mi":"mo"}(e.lastType==="mi"||e.lastType==="mn")&&!/^<mo>(.*)<\/mo>$/.test(u)&&(u=id+u),e.index+=1}return u.length>0&&(a=!0,bo(u,e,r)||(e.mathML+=u,e.lastType=p)),a}function Sn(e,i,r,a){i!=null||(i={});const u={atoms:[],index:r!=null?r:0,mathML:"",lastType:""};if(typeof e=="number"||typeof e=="boolean")u.mathML=e.toString();else if(typeof e=="string")u.mathML=e;else if(e instanceof et)u.mathML=T0(e,i);else if(Array.isArray(e)){u.atoms=e;let p=0;for(a=a||(e?e.length:0);u.index<a;)if(Fg(u,a,i)||Bg(u,a,i)||Ig(u,a,i)||$g(u,a,i)||Ng(u,a,i))p+=1;else if(u.index<a){let g=T0(u.atoms[u.index],i);u.lastType==="mn"&&g.length>0&&u.atoms[u.index].type==="genfrac"&&(g="<mo>&#x2064;</mo>"+g),u.atoms[u.index].type==="genfrac"?u.lastType="mfrac":u.lastType="",u.index+=1,bo(g,u,i)?p+=1:g.length>0&&(u.mathML+=g,p+=1)}p>1&&(u.mathML="<mrow>"+u.mathML+"</mrow>")}return u.mathML}function Hl(e,i){let r="";const a=Qu(e.value);return a&&(r="<mo"+Un(e.id,i)+">"+a+"</mo>"),r}function Qu(e){if(!e)return"";if(typeof e=="string")return nd(e);if(!Array.isArray(e)&&typeof e.body=="string")return nd(e.body);let i="";for(const r of e)typeof r.value=="string"&&(i+=r.value);return nd(i)}function T0(e,i){var r,a,u,p,g,b,w,E,R,N,Z,ue,me,Ve,Ct,Ue,ct,It,yt,ei,hi,ai;if(e.mode==="text")return`<mi${Un(e.id,i)}>${e.value}</mi>`;const on={widehat:"^",widecheck:"\u02C7",widetilde:"~",utilde:"~",overleftarrow:"\u2190",underleftarrow:"\u2190",xleftarrow:"\u2190",longleftarrow:"\u2190",overrightarrow:"\u2192",underrightarrow:"\u2192",xrightarrow:"\u2192",longrightarrow:"\u2192",underbrace:"\u23DF",overbrace:"\u23DE",overgroup:"\u23E0",undergroup:"\u23E1",overleftrightarrow:"\u2194",underleftrightarrow:"\u2194",xleftrightarrow:"\u2194",Overrightarrow:"\u21D2",xRightarrow:"\u21D2",overleftharpoon:"\u21BC",xleftharpoonup:"\u21BC",overrightharpoon:"\u21C0",xrightharpoonup:"\u21C0",xLeftarrow:"\u21D0",xLeftrightarrow:"\u21D4",xhookleftarrow:"\u21A9",xhookrightarrow:"\u21AA",xmapsto:"\u21A6",xrightharpoondown:"\u21C1",xleftharpoondown:"\u21BD",xrightleftharpoons:"\u21CC",longrightleftharpoons:"\u21CC",xleftrightharpoons:"\u21CB",xtwoheadleftarrow:"\u219E",xtwoheadrightarrow:"\u21A0",xlongequal:"=",xtofrom:"\u21C4",xleftrightarrows:"\u21C4",xRightleftharpoons:"\u21CC",longRightleftharpoons:"\u21CC",xLeftrightharpoons:"\u21CB",longLeftrightharpoons:"\u21CB"},Bn={"\\!":-3/18,"\\ ":6/18,"\\,":3/18,"\\:":4/18,"\\>":4/18,"\\;":5/18,"\\enspace":.5,"\\quad":1,"\\qquad":2,"\\enskip":.5};let Nt="",Gs="",Ka,ta,Gr,Hs,ks,zn;const{command:br}=e;if(e.command==="\\error")return`<merror${Un(e.id,i)}>${Sn(e.body,i)}</merror>`;const Hr={"\\vert":"|","\\Vert":"\u2225","\\mid":"\u2223","\\lbrack":"[","\\rbrack":"]","\\{":"{","\\}":"}","\\lbrace":"{","\\rbrace":"}","\\lparen":"(","\\rparen":")","\\langle":"\u27E8","\\rangle":"\u27E9","\\lfloor":"\u230A","\\rfloor":"\u230B","\\lceil":"\u2308","\\rceil":"\u2309"},Ua={"\\vec":"&#x20d7;","\\acute":"&#x00b4;","\\grave":"&#x0060;","\\dot":"&#x02d9;","\\ddot":"&#x00a8;","\\tilde":"&#x007e;","\\bar":"&#x00af;","\\breve":"&#x02d8;","\\check":"&#x02c7;","\\hat":"&#x005e;"};switch(e.type){case"first":break;case"group":case"root":Nt=Sn(e.body,i);break;case"array":if((e.leftDelim&&e.leftDelim!=="."||e.rightDelim&&e.rightDelim!==".")&&(Nt+="<mrow>",e.leftDelim&&e.leftDelim!=="."&&(Nt+="<mo>"+(Hr[e.leftDelim]||e.leftDelim)+"</mo>")),Nt+="<mtable",e.colFormat){for(Nt+=' columnalign="',Gr=0;Gr<e.colFormat.length;Gr++)e.colFormat[Gr].align&&(Nt+={l:"left",c:"center",r:"right"}[e.colFormat[Gr].align]+" ");Nt+='"'}for(Nt+=">",ta=0;ta<e.array.length;ta++){for(Nt+="<mtr>",Ka=0;Ka<e.array[ta].length;Ka++)Nt+="<mtd>"+Sn(e.array[ta][Ka],i)+"</mtd>";Nt+="</mtr>"}Nt+="</mtable>",(e.leftDelim&&e.leftDelim!=="."||e.rightDelim&&e.rightDelim!==".")&&(e.rightDelim&&e.rightDelim!=="."&&(Nt+="<mo>"+(Hr[e.leftDelim]||e.rightDelim)+"</mo>"),Nt+="</mrow>");break;case"genfrac":(e.leftDelim||e.rightDelim)&&(Nt+="<mrow>"),e.leftDelim&&e.leftDelim!=="."&&(Nt+="<mo"+Un(e.id,i)+">"+(Hr[e.leftDelim]||e.leftDelim)+"</mo>"),e.hasBarLine?(Nt+="<mfrac>",Nt+=Sn(e.above,i)||"<mi>&nbsp;</mi>",Nt+=Sn(e.below,i)||"<mi>&nbsp;</mi>",Nt+="</mfrac>"):(Nt+="<mtable"+Un(e.id,i)+">",Nt+="<mtr>"+Sn(e.above,i)+"</mtr>",Nt+="<mtr>"+Sn(e.below,i)+"</mtr>",Nt+="</mtable>"),e.rightDelim&&e.rightDelim!=="."&&(Nt+="<mo"+Un(e.id,i)+">"+(Hr[e.rightDelim]||e.rightDelim)+"</mo>"),(e.leftDelim||e.rightDelim)&&(Nt+="</mrow>");break;case"surd":e.hasEmptyBranch("above")?(Nt+="<msqrt"+Un(e.id,i)+">",Nt+=Sn(e.body,i),Nt+="</msqrt>"):(Nt+="<mroot"+Un(e.id,i)+">",Nt+=Sn(e.body,i),Nt+=Sn(e.above,i),Nt+="</mroot>");break;case"leftright":const za=e,Va=za.leftDelim;Nt="<mrow>",Va&&Va!=="."&&(Nt+=`<mo${Un(e.id,i)}>${(r=Hr[Va])!=null?r:Va}</mo>`),e.body&&(Nt+=Sn(e.body,i));const Ga=za.matchingRightDelim();Ga&&Ga!=="."&&(Nt+=`<mo${Un(e.id,i)}>${(a=Hr[Ga])!=null?a:Ga}</mo>`),Nt+="</mrow>";break;case"sizeddelim":case"delim":Nt+=`<mo${Un(e.id,i)}>${Hr[e.value]||e.value}</mo>`;break;case"accent":Nt+='<mover accent="true"'+Un(e.id,i)+">",Nt+=Sn(e.body,i),Nt+="<mo>"+(Ua[br]||e.accent)+"</mo>",Nt+="</mover>";break;case"line":case"overlap":break;case"overunder":ks=e.above,Hs=e.below,(e.svgAbove||ks)&&(e.svgBelow||Hs)?zn=e.body:ks&&ks.length>0?(zn=e.body,(p=(u=e.body)==null?void 0:u[0])!=null&&p.below?(Hs=e.body[0].below,zn=e.body[0].body):((b=(g=e.body)==null?void 0:g[0])==null?void 0:b.type)==="first"&&((E=(w=e.body)==null?void 0:w[1])!=null&&E.below)&&(Hs=e.body[1].below,zn=e.body[1].body)):Hs&&Hs.length>0&&(zn=e.body,(N=(R=e.body)==null?void 0:R[0])!=null&&N.above?(ks=e.body[0].above,zn=e.body[0].body):((ue=(Z=e.body)==null?void 0:Z[0])==null?void 0:ue.type)==="first"&&((Ve=(me=e.body)==null?void 0:me[1])!=null&&Ve.above)&&(ks=e.body[1].overscript,zn=e.body[1].body)),(e.svgAbove||ks)&&(e.svgBelow||Hs)?(Nt+=`<munderover ${Un(e.id,i)}>`,Nt+=(Ct=on[e.svgBody])!=null?Ct:Sn(zn,i),Nt+=(Ue=on[e.svgBelow])!=null?Ue:Sn(Hs,i),Nt+=(ct=on[e.svgAbove])!=null?ct:Sn(ks,i),Nt+="</munderover>"):e.svgAbove||ks?(Nt+=`<mover ${Un(e.id,i)}>`+((It=on[e.svgBody])!=null?It:Sn(zn,i)),Nt+=(yt=on[e.svgAbove])!=null?yt:Sn(ks,i),Nt+="</mover>"):(e.svgBelow||Hs)&&(Nt+=`<munder ${Un(e.id,i)}>`+((ei=on[e.svgBody])!=null?ei:Sn(zn,i)),Nt+=(hi=on[e.svgBelow])!=null?hi:Sn(Hs,i),Nt+="</munder>");break;case"placeholder":Nt+="?";break;case"mord":{Nt=typeof e.value=="string"?e.value:br,br==="\\char"?Nt="&#x"+("000000"+e.args[0].number.toString(16)).slice(-4)+";":Nt.length>0&&Nt.startsWith("\\")&&(typeof e.value=="string"&&e.value.charCodeAt(0)>255?Nt="&#x"+("000000"+e.value.charCodeAt(0).toString(16)).slice(-4)+";":typeof e.value=="string"?Nt=e.value.charAt(0):(console.error("Did not expect this"),Nt=""));const _a=/\d/.test(Nt)?"mn":"mi";Nt=`<${_a}${Un(e.id,i)}>${nd(Nt)}</${_a}>`;break}case"mbin":case"mrel":case"minner":Nt=Hl(e,i);break;case"mpunct":Nt='<mo separator="true"'+Un(e.id,i)+">"+br+"</mo>";break;case"mop":case"operator":case"extensible-symbol":e.body!=="\u200B"&&(Nt="<mo"+Un(e.id,i)+">",Nt+=br==="\\operatorname"?e.body:br||e.body,Nt+="</mo>");break;case"box":Nt='<menclose notation="box"',e.backgroundcolor&&(Nt+=' mathbackground="'+e.backgroundcolor+'"'),Nt+=Un(e.id,i)+">"+Sn(e.body,i)+"</menclose>";break;case"spacing":Nt+='<mspace width="'+((ai=Bn[br])!=null?ai:0)+'em"/>';break;case"enclose":Nt='<menclose notation="';for(const _a in e.notation)Object.prototype.hasOwnProperty.call(e.notation,_a)&&e.notation[_a]&&(Nt+=Gs+_a,Gs=" ");Nt+=Un(e.id,i)+'">'+Sn(e.body,i)+"</menclose>";break;case"prompt":Nt='<menclose notation="roundexbox""">'+Sn(e.body,i)+"</menclose>";break;case"space":Nt+="&nbsp;";break;case"subsup":break;case"phantom":break;case"composition":break;case"rule":break;case"chem":break;case"mopen":Nt+=Hl(e,i);break;case"mclose":Nt+=Hl(e,i);break;case"macro":{const _a=e.command+Qu(e.macroArgs);_a&&(Nt+=`<mo ${Un(e.id,i)}>${_a}</mo>`)}break;case"latexgroup":Nt+=Sn(e.body,i);break;case"latex":Nt+="<mtext"+Un(e.id,i)+">"+e.value+"</mtext>";break;case"tooltip":Nt+=Sn(e.body,i);break;case"text":Nt+=`<mtext ${Un(e.id,i)}x>${e.value}</mtext>`;break;default:if(e.command==="\\displaystyle")return`<mrow ${Un(e.id,i)} displaystyle="true">${Sn(e.body,i)}</mrow>`;if(e.command==="\\textstyle")return`<mrow ${Un(e.id,i)} displaystyle="false">${Sn(e.body,i)}</mrow>`;console.info("Unexpected element in conversion to MathML:",e)}return Nt}var ec={"\\alpha":"alpha ","\\mu":"mew ","\\sigma":"sigma ","\\pi":"pie ","\\imaginaryI":"imaginary eye ","\\imaginaryJ":"imaginary jay ","\\sum":"Summation ","\\prod":"Product ","+":"plus ","-":"minus ",";":'<break time="150ms"/> semi-colon <break time="150ms"/>',",":'<break time="150ms"/> comma <break time="150ms"/>',"|":'<break time="150ms"/>Vertical bar<break time="150ms"/>',"(":'<break time="150ms"/>Open paren. <break time="150ms"/>',")":'<break time="150ms"/> Close paren. <break time="150ms"/>',"=":"equals ","<":"is less than ","\\lt":"is less than ","<=":"is less than or equal to ","\\le":"is less than or equal to ","\\gt":"is greater than ",">":"is greater than ","\\pm":"plus or minus","\\mp":"minus or plus","\\ge":"is greater than or equal to ","\\geq":"is greater than or equal to ","\\leq":"is less than or equal to ","\\ne":"is not equal to ","\\neq":"is not equal to ","!":"factorial ","\\sin":"sine ","\\cos":"cosine ","\u200B":"","\u2212":"minus ",":":'<break time="150ms"/> such that <break time="200ms"/> ',"\\colon":'<break time="150ms"/> such that <break time="200ms"/> ',"\\hbar":"etch bar ","\\iff":'<break time="200ms"/>if, and only if, <break time="200ms"/>',"\\Longleftrightarrow":'<break time="200ms"/>if, and only if, <break time="200ms"/>',"\\land":"and ","\\lor":"or ","\\neg":"not ","\\div":"divided by ","\\forall":"for all ","\\exists":"there exists ","\\nexists":"there does not exists ","\\in":"element of ","\\N":'the set <break time="150ms"/><say-as interpret-as="character">n</say-as>',"\\C":'the set <break time="150ms"/><say-as interpret-as="character">c</say-as>',"\\Z":'the set <break time="150ms"/><say-as interpret-as="character">z</say-as>',"\\Q":'the set <break time="150ms"/><say-as interpret-as="character">q</say-as>',"\\infty":"infinity ","\\nabla":"nabla ","\\partial":"partial derivative of ","\\cdot":"times ","\\cdots":"dot dot dot ","\\Rightarrow":"implies ","\\lparen":'<break time="150ms"/>open paren<break time="150ms"/>',"\\rparen":'<break time="150ms"/>close paren<break time="150ms"/>',"\\lbrace":'<break time="150ms"/>open brace<break time="150ms"/>',"\\{":'<break time="150ms"/>open brace<break time="150ms"/>',"\\rbrace":'<break time="150ms"/>close brace<break time="150ms"/>',"\\}":'<break time="150ms"/>close brace<break time="150ms"/>',"\\langle":'<break time="150ms"/>left angle bracket<break time="150ms"/>',"\\rangle":'<break time="150ms"/>right angle bracket<break time="150ms"/>',"\\lfloor":'<break time="150ms"/>open floor<break time="150ms"/>',"\\rfloor":'<break time="150ms"/>close floor<break time="150ms"/>',"\\lceil":'<break time="150ms"/>open ceiling<break time="150ms"/>',"\\rceil":'<break time="150ms"/>close ceiling<break time="150ms"/>',"\\vert":'<break time="150ms"/>vertical bar<break time="150ms"/>',"\\mvert":'<break time="150ms"/>divides<break time="150ms"/>',"\\lvert":'<break time="150ms"/>left vertical bar<break time="150ms"/>',"\\rvert":'<break time="150ms"/>right vertical bar<break time="150ms"/>',"\\lbrack":'<break time="150ms"/> open square bracket <break time="150ms"/>',"\\rbrack":'<break time="150ms"/> close square bracket <break time="150ms"/>',mm:"millimeters",cm:"centimeters",km:"kilometers",kg:"kilograms"},A0={array:"array",matrix:"matrix",pmatrix:"parenthesis matrix",bmatrix:"square brackets matrix",Bmatrix:"braces matrix",vmatrix:"bars matrix",Vmatrix:"double bars matrix","matrix*":"matrix",smallmatrix:"small matrix"};function Kg(e){let i="";return e.startsWith("\\")&&(i=" "+e.replace("\\","")+" "),i}function ch(e){let i=0;if(k(e))for(const r of e)r.type!=="first"&&(i+=1);return i===1}function Ug(e){if(k(e)){for(const i of e)if(i.type!=="first"&&i.id)return i.id.toString()}return""}function Ep(e){let i="";if(k(e))for(const r of e)r.type!=="first"&&typeof r.value=="string"&&(i+=r.value);return i}function zg(e){return e?e.map(i=>i.value).join(""):""}function Zi(e,i){var r,a,u,p,g;function b(R){return window.MathfieldElement.textToSpeechMarkup?/[a-z]/.test(R)?` <say-as interpret-as="character">${R}</say-as>`:/[A-Z]/.test(R)?`capital <say-as interpret-as="character">${R.toLowerCase()}</say-as>`:R:/[a-z]/.test(R)?" '"+R.toUpperCase()+"'":/[A-Z]/.test(R)?" 'capital "+R.toUpperCase()+"'":R}function w(R){return"<emphasis>"+R+"</emphasis>"}if(!i)return"";let E="";if(k(i)){let R=!1,N=!1;for(let Z=0;Z<i.length;Z++)i[Z].type!=="first"&&(i[Z].mode!=="text"&&(N=!1),Z<i.length-2&&i[Z].type==="mopen"&&i[Z+2].type==="mclose"&&i[Z+1].type==="mord"?(E+=" of ",E+=w(Zi(e,i[Z+1])),Z+=2):i[Z].mode==="text"?N?E+=(r=i[Z].value)!=null?r:" ":(N=!0,E+=Zi("text",i[Z])):i[Z].isDigit()?R?E+=i[Z].asDigit():(R=!0,E+=Zi(e,i[Z])):(R=!1,E+=Zi(e,i[Z])))}else if(i.mode==="text")i.id&&e==="math"&&(E+='<mark name="'+i.id.toString()+'"/>'),E+=i.value;else{i.id&&e==="math"&&(E+='<mark name="'+i.id.toString()+'"/>');let R="",N="",Z="",ue=!1;const{command:me}=i;switch(me){case"\\vec":return"vector "+Zi(e,i.body);case"\\acute":return Zi(e,i.body)+" acute";case"\\grave":return Zi(e,i.body)+" grave";case"\\dot":return"dot over"+Zi(e,i.body);case"\\ddot":return"double dot over"+Zi(e,i.body);case"\\mathring":return"ring over"+Zi(e,i.body);case"\\tilde":case"\\widetilde":return"tilde over"+Zi(e,i.body);case"\\bar":return Zi(e,i.body)+" bar";case"\\breve":return Zi(e,i.body)+" breve";case"\\check":case"\\widecheck":return"check over "+Zi(e,i.body);case"\\hat":case"\\widehat":return"hat over"+Zi(e,i.body);case"\\overarc":case"\\overparen":case"\\wideparen":return"arc over "+Zi(e,i.body);case"\\underarc":case"\\underparen":return"arc under "+Zi(e,i.body)}switch(i.type){case"prompt":const Ve=i.body.length>1?'start input . <break time="500ms"/> '+Zi(e,i.body)+'. <break time="500ms"/> end input':"blank";E+=' <break time="300ms"/> '+Ve+'. <break time="700ms"/>'+((a=i.correctness)!=null?a:"")+' . <break time="700ms"/> ';break;case"array":const Ct=i.array,Ue=i.environmentName;if(Object.keys(A0).includes(Ue)){E+=` begin ${A0[Ue]} `;for(let yt=0;yt<Ct.length;yt++){yt>0&&(E+=","),E+=` row ${yt+1} `;for(let ei=0;ei<Ct[yt].length;ei++)ei>0&&(E+=","),E+=` column ${ei+1}: `,E+=Zi("math",Ct[yt][ei])}E+=` end ${A0[Ue]} `}break;case"group":me==="\\ne"?E+=" not equal ":(me==="\\not"&&(E+=" not "),E+=Zi("math",i.body));break;case"root":E+=Zi("math",i.body);break;case"genfrac":if(R=Zi("math",i.above),N=Zi("math",i.below),ch(i.above)&&ch(i.below)){const ei={"1/2":" half ","1/3":" one third ","2/3":" two third","1/4":" one quarter ","3/4":" three quarter ","1/5":" one fifth ","2/5":" two fifths ","3/5":" three fifths ","4/5":" four fifths ","1/6":" one sixth ","5/6":" five sixths ","1/8":" one eight ","3/8":" three eights ","5/8":" five eights ","7/8":" seven eights ","1/9":" one ninth ","2/9":" two ninths ","4/9":" four ninths ","5/9":" five ninths ","7/9":" seven ninths ","8/9":" eight ninths "}[Ep(i.above)+"/"+Ep(i.below)];ei?E=ei:E+=R+" over "+N}else E+=' the fraction <break time="150ms"/>'+R+' over <break time="150ms"/>'+N+'.<break time="150ms"/> End fraction.<break time="150ms"/>';break;case"surd":if(Z=Zi("math",i.body),i.hasEmptyBranch("above"))E+=ch(i.body)?" the square root of "+Z+" , ":' the square root of <break time="200ms"/>'+Z+'. <break time="200ms"/> End square root';else{let yt=Zi("math",i.above);yt=yt.trim();const ei=yt.replace(/<mark([^/]*)\/>/g,"");ei==="3"?E+=' the cube root of <break time="200ms"/>'+Z+'. <break time="200ms"/> End cube root':ei==="n"?E+=' the nth root of <break time="200ms"/>'+Z+'. <break time="200ms"/> End root':E+=' the root with index: <break time="200ms"/>'+yt+', of <break time="200ms"/>'+Z+'. <break time="200ms"/> End root'}break;case"leftright":{const yt=i;E+=(u=yt.leftDelim?ec[yt.leftDelim]:void 0)!=null?u:yt.leftDelim,E+=Zi("math",i.body),E+=(p=yt.rightDelim?ec[yt.rightDelim]:void 0)!=null?p:yt.rightDelim}break;case"rule":break;case"overunder":break;case"overlap":break;case"macro":const ct=me.replace(/^\\/g,""),It=Gt()[ct];It&&(It!=null&&It.expand?E+=Zi("math",i.body):E+=`${ct} `);break;case"placeholder":E+="placeholder ";break;case"delim":case"sizeddelim":case"mord":case"minner":case"mbin":case"mrel":case"mpunct":case"mopen":case"mclose":{if(me==="\\mathbin"||me==="\\mathrel"||me==="\\mathopen"||me==="\\mathclose"||me==="\\mathpunct"||me==="\\mathord"||me==="\\mathinner"){E=Zi(e,i.body);break}let yt=i.isDigit()?i.asDigit():i.value,ei=i.command;if((i.type==="delim"||i.type==="sizeddelim")&&(ei=i.value,yt=ei),e==="text")E+=yt;else{if(i.type==="mbin"&&(E+='<break time="150ms"/>'),yt){const hi=ec[yt]||(ei?ec[ei.trim()]:"");if(hi)E+=" "+hi;else{const ai=ei?Kg(ei.trim()):"";E+=ai||b(yt)}}else E+=Zi("math",i.body);i.type==="mbin"&&(E+='<break time="150ms"/>')}break}case"mop":case"operator":case"extensible-symbol":if(i.value!=="\u200B"){const yt=i.command;if(yt==="\\sum")if(!i.hasEmptyBranch("superscript")&&!i.hasEmptyBranch("subscript")){let ei=Zi("math",i.superscript);ei=ei.trim();let hi=Zi("math",i.subscript);hi=hi.trim(),E+=' the summation from <break time="200ms"/>'+hi+'<break time="200ms"/> to <break time="200ms"/>'+ei+'<break time="200ms"/> of <break time="150ms"/>',ue=!0}else if(i.hasEmptyBranch("subscript"))E+=" the summation of";else{let ei=Zi("math",i.subscript);ei=ei.trim(),E+=' the summation from <break time="200ms"/>'+ei+'<break time="200ms"/> of <break time="150ms"/>',ue=!0}else if(yt==="\\prod")if(!i.hasEmptyBranch("superscript")&&!i.hasEmptyBranch("subscript")){let ei=Zi("math",i.superscript);ei=ei.trim();let hi=Zi("math",i.subscript);hi=hi.trim(),E+=' the product from <break time="200ms"/>'+hi+'<break time="200ms"/> to <break time="200ms"/>'+ei+'<break time="200ms"/> of <break time="150ms"/>',ue=!0}else if(i.hasEmptyBranch("subscript"))E+=" the product of ";else{let ei=Zi("math",i.subscript);ei=ei.trim(),E+=' the product from <break time="200ms"/>'+ei+'<break time="200ms"/> of <break time="150ms"/>',ue=!0}else if(yt==="\\int")if(!i.hasEmptyBranch("superscript")&&!i.hasEmptyBranch("subscript")){let ei=Zi("math",i.superscript);ei=ei.trim();let hi=Zi("math",i.subscript);hi=hi.trim(),E+=' the integral from <break time="200ms"/>'+w(hi)+'<break time="200ms"/> to <break time="200ms"/>'+w(ei)+' <break time="200ms"/> of ',ue=!0}else E+=' the integral of <break time="200ms"/> ';else if(typeof i.value=="string"){const ei=(g=ec[i.value])!=null?g:i.command?ec[i.command]:void 0;E+=ei||" "+i.value}else i.command&&(i.command==="\\mathop"?E+=Zi("math",i.body):i.command==="\\operatorname"?E+=zg(i.body):E+=i.command.startsWith("\\")?" "+i.command.slice(1):" "+i.command)}break;case"enclose":Z=Zi("math",i.body),E+=" crossed out "+Z+". End crossed out.";break;case"space":case"spacing":break}if(!ue&&!i.hasEmptyBranch("superscript")){let Ve=Zi(e,i.superscript);Ve=Ve.trim();const Ct=Ve.replace(/<[^>]*>/g,"");if(ch(i.superscript)){if(e==="math"){const Ue=Ug(i.superscript);Ue&&(E+='<mark name="'+Ue+'"/>')}Ct==="\u2032"?E+=" prime ":Ct==="2"?E+=" squared ":Ct==="3"?E+=" cubed ":Number.isNaN(Number.parseInt(Ct))?E+=" to the "+Ve+"; ":E+=' to the <say-as interpret-as="ordinal">'+Ct+"</say-as> power; "}else Number.isNaN(Number.parseInt(Ct))?E+=" raised to the "+Ve+"; ":E+=' raised to the <say-as interpret-as="ordinal">'+Ct+"</say-as> power; "}if(!ue&&!i.hasEmptyBranch("subscript")){let Ve=Zi("math",i.subscript);Ve=Ve.trim(),E+=ch(i.subscript)?" sub "+Ve:" subscript "+Ve+". End subscript. "}}return E}function tc(e){var i,r;if(window.MathfieldElement.textToSpeechRules==="sre"&&("sre"in window||"SRE"in window)){const u=Sn(e);if(u){window.MathfieldElement.textToSpeechMarkup&&(window.MathfieldElement.textToSpeechRulesOptions=(i=window.MathfieldElement.textToSpeechRulesOptions)!=null?i:{},window.MathfieldElement.textToSpeechRulesOptions=d(P({},window.MathfieldElement.textToSpeechRulesOptions),{markup:window.MathfieldElement.textToSpeechMarkup}),window.MathfieldElement.textToSpeechRulesOptions.markup==="ssml"&&(window.MathfieldElement.textToSpeechRulesOptions=d(P({},window.MathfieldElement.textToSpeechRulesOptions),{markup:"ssml_step"})),window.MathfieldElement.textToSpeechRulesOptions=d(P({},window.MathfieldElement.textToSpeechRulesOptions),{rate:window.MathfieldElement.speechEngineRate}));const p=(r=window.SRE)!=null?r:window.sre.System.getInstance();window.MathfieldElement.textToSpeechRulesOptions&&p.setupEngine(window.MathfieldElement.textToSpeechRulesOptions);let g="";try{g=p.toSpeech(u)}catch(b){console.error("MathLive 0.98.5: `SRE.toSpeech()` runtime error",b)}return g}return""}let a=Zi("math",e);if(window.MathfieldElement.textToSpeechMarkup==="ssml"){let u="";window.MathfieldElement.speechEngineRate&&(u='<prosody rate="'+window.MathfieldElement.speechEngineRate+'">'),a='<?xml version="1.0"?><speak version="1.1" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-US"><amazon:auto-breaths>'+u+"<p><s>"+a+"</s></p>"+(u?"</prosody>":"")+"</amazon:auto-breaths></speak>"}else window.MathfieldElement.textToSpeechMarkup==="mac"&&H()==="macos"?a=a.replace(/<mark([^/]*)\/>/g,"").replace(/<emphasis>/g,"[[emph+]]").replace(/<\/emphasis>/g,"").replace(/<break time="(\d*)ms"\/>/g,"[[slc $1]]").replace(/<say-as[^>]*>/g,"").replace(/<\/say-as>/g,""):a=a.replace(/<[^>]*>/g,"").replace(/\s{2,}/g," ");return a}var hh={"\\ne":"\u2260","\\neq":"\u2260","\u2212":"-","-":"-","\\alpha":"alpha","\\beta":"beta","\\gamma":"gamma","\\delta":"delta","\\epsilon":"epsilon","\\varepsilon":"varepsilon","\\zeta":"zeta","\\eta":"eta","\\theta":"theta","\\vartheta":"vartheta","\\iota":"iota","\\kappa":"kappa","\\lambda":"lambda","\\mu":"mu","\\nu":"nu","\\xi":"xi","\\pi":"pi","\\rho":"rho","\\sigma":"sigma","\\tau":"tau","\\upsilon":"upsilon","\\phi":"phi","\\varphi":"varphi","\\chi":"chi","\\psi":"psi","\\omega":"omega","\\Gamma":"Gamma","\\Delta":"Delta","\\Theta":"Theta","\\Lambda":"Lambda","\\Xi":"Xi","\\Pi":"Pi","\\Sigma":"Sigma","\\Phi":"Phi","\\Psi":"Psi","\\Omega":"Omega","\\exponentialE":"e","\\imaginaryI":"i","\\imaginaryJ":"j","\\!":" ","\\,":" ","\\:":" ","\\>":" ","\\;":" ","\\enskip":" ","\\enspace":" ","\\qquad":" ","\\quad":" ","\\infty":"oo"},fh={"\\pm":"+-","\\colon":":","\\vert":"|","\\Vert":"||","\\mid":"|","\\lbrack":"[","\\rbrack":"]","\\lbrace":"{","\\rbrace":"}","\\lparen":"(","\\rparen":")","\\langle":"(:","\\rangle":":)","\\sum":" sum ","\\prod":" prod ","\\bigcap":" nnn ","\\bigcup":" uuu ","\\int":" int ","\\oint":" oint ","\\ge":">=","\\le":"<=","\\ne":"!=","\\neq":"!=","\\lt":"<","\\gt":">","\\gets":"<-","\\to":"->","\\land":" and ","\\lor":" or ","\\lnot":" not ","\\forall":" AA ","\\exists":" EE ","\\in":" in ","\\notin":" !in ","\\mapsto":"|->","\\implies":"=>","\\iff":"<=>","\\cdot":"*","\\ast":"**","\\star":"***","\\times":"xx","\\div":"-:","\\ltimes":"|><","\\rtimes":"><|","\\bowtie":"|><|","\\circ":"@"};function Vg(e){let i="";for(const r of e){const a=i[i.length-1];a!==void 0&&/\d/.test(a)&&/^\d/.test(r)&&(i+=" "),i+=r}return i}function yr(e){var i,r,a,u,p,g,b,w,E,R,N,Z,ue;if(!e)return"";if(k(e)){if(e.length===0)return"";if(e[0].mode==="latex")return e.map(yr).join("");if(e[0].mode==="text"){let It=0,yt="";for(;((i=e[It])==null?void 0:i.mode)==="text";)yt+=e[It].body?yr(e[It].body):e[It].value,It++;return`"${yt}" ${yr(e.slice(It))}`}let Ue=0;const ct=[];for(;e[Ue]&&e[Ue].mode==="math";){let It="";for(;e[Ue]&&e[Ue].type==="mord"&&/\d/.test(e[Ue].value);)It+=e[Ue++].value;It?ct.push(It):ct.push(yr(e[Ue++]))}return ct.push(yr(e.slice(Ue))),Vg(ct)}if(e.mode==="text")return`"${e.value}"`;let me="";const{command:Ve}=e;let Ct;if(Ve==="\\placeholder")return`(${yr(e.body)})`;switch(e.type){case"accent":const Ue={"\\vec":"vec","\\dot":"dot","\\ddot":"ddot","\\bar":"bar","\\hat":"hat","\\acute":"acute;","\\grave":"grave","\\tilde":"tilde","\\breve":"breave","\\check":"check"}[Ve];me=`${Ue!=null?Ue:""} ${yr(e.body)} `;break;case"first":return"";case"latexgroup":return e.body.map(ai=>ai.value).join("");case"group":case"root":me=(r=hh[Ve])!=null?r:yr(e.body);break;case"genfrac":{const ai=e;(ai.leftDelim||ai.rightDelim)&&(me=ai.leftDelim==="."||!ai.leftDelim?"{:":ai.leftDelim),ai.hasBarLine?(me+="(",me+=yr(ai.above),me+=")/(",me+=yr(ai.below),me+=")"):(me+="("+yr(ai.above)+"),",me+="("+yr(ai.below)+")"),(ai.leftDelim||ai.rightDelim)&&(me+=ai.rightDelim==="."||!ai.rightDelim?"{:":ai.rightDelim)}break;case"surd":me+=e.hasEmptyBranch("above")?"sqrt("+yr(e.body)+")":"root("+yr(e.above)+")("+yr(e.body)+")";break;case"latex":me=e.value;break;case"leftright":{const ai=e,on=ai.leftDelim;me+=on==="."||!on?"{:":on,me+=yr(ai.body);const Bn=ai.matchingRightDelim();me+=Bn==="."||!Bn?":}":Bn}break;case"sizeddelim":case"delim":me=e.value;break;case"overlap":break;case"overunder":break;case"mord":me=(u=(a=hh[Ve])!=null?a:Ve)!=null?u:typeof e.value=="string"?e.value:"",me.startsWith("\\")&&(me+=" "),Ct=Ve?Ve.match(/{?\\char"([\dabcdefABCDEF]+)}?/):null,Ct?me=String.fromCodePoint(Number.parseInt("0x"+Ct[1])):me.length>0&&me.startsWith("\\")&&(me=typeof e.value=="string"?e.value.charAt(0):e.command),me=Gg(me,e.style);break;case"mbin":case"mrel":case"minner":me=(g=(p=hh[Ve])!=null?p:fh[Ve])!=null?g:e.value;break;case"mopen":case"mclose":me=e.value;break;case"mpunct":me=(b=fh[Ve])!=null?b:Ve;break;case"mop":case"operator":case"extensible-symbol":e.value!=="\u200B"&&(fh[Ve]?me=fh[Ve]:me=Ve==="\\operatorname"?yr(e.body):(w=e.value)!=null?w:Ve,me+=" ");break;case"array":const ct=e.array,It=e.environmentName,yt=(E={bmatrix:["[","]"],"bmatrix*":["[","]"]}[It])!=null?E:["(",")"],ei=[];for(const ai of ct){const on=[];for(const Bn of ai)on.push(yt[0]+yr(Bn)+yt[1]);ei.push(on.join(","))}const hi=(R={bmatrix:["[","]"],"bmatrix*":["[","]"],cases:["{",":}"]}[It])!=null?R:["(",")"];me=hi[0]+ei.join(",")+hi[1];break;case"box":break;case"spacing":me=(N=hh[Ve])!=null?N:" ";break;case"enclose":me="("+yr(e.body)+")";break;case"space":me=" ";break;case"subsup":me="";break;case"macro":me=(ue=(Z=hh[Ve])!=null?Z:fh[Ve])!=null?ue:yr(e.body);break}if(!e.hasEmptyBranch("subscript")){me+="_";const Ue=yr(e.subscript);me+=Ue.length!==1?`(${Ue})`:Ue}if(!e.hasEmptyBranch("superscript")){me+="^";const Ue=yr(e.superscript);me+=Ue.length!==1?`(${Ue})`:Ue}return me}function Gg(e,i){if(!i)return e;let r=e;return i.variant==="double-struck"&&(r=`bbb "${r}"`),i.variant==="script"&&(r=`cc "${r}"`),i.variant==="fraktur"&&(r=`fr "${r}"`),i.variant==="sans-serif"&&(r=`sf "${r}"`),i.variant==="monospace"&&(r=`tt "${r}"`),i.variantStyle==="bold"&&(r=`bb "${r}"`),i.color?`color({${i.color}})(${r})`:r}function Vr(e,i){var r,a;i!=null||(i={}),i.mathstyle=(r=i.mathstyle)!=null?r:"displaystyle";const u=new Si({from:d(P({},Ds()),{renderPlaceholder:()=>new Tt(160,{maxFontSize:1}),letterShapeStyle:(a=i==null?void 0:i.letterShapeStyle)!=null?a:"tex"}),mathstyle:i.mathstyle}),g=new et({mode:"math",type:"root",body:zr(e,{context:u,parseMode:"math",mathstyle:i.mathstyle})}).render(u);return g?(yl(Ho(g,u)),bu(g,{classes:"ML__latex"}).toMarkup()):""}function P1(e){return Ll(e,{context:Ds()})}function Hg(e,i={}){return Sn(zr(e,{parseMode:"math",args:()=>"",mathstyle:"displaystyle"}),i)}function Wg(e){const i=zr(e,{parseMode:"math",mathstyle:"displaystyle"});return tc(i)}var rd;function jg(e){var i,r;if(!rd){const a=(i=globalThis[Symbol.for("io.cortexjs.compute-engine")])==null?void 0:i.ComputeEngine;a?rd=new a:console.error(`MathLive 0.98.5: The CortexJS Compute Engine library is not available.
Load the library, for example with:
import "https://unpkg.com/@cortex-js/compute-engine?module"`)}return(r=rd==null?void 0:rd.box(e).latex)!=null?r:""}function O1(e,i="math"){return yr(new et({type:"root",body:zr(e,{parseMode:i})}))}function F1(e){return Lu(e,{format:"ascii-math"})[1]}function L0(e){if(typeof e=="string"){const i=qg(e);if(!i)throw new Error(`Invalid color: ${e}`);return i}return"C"in e?Yg(e):"a"in e?kp(e):e}function ic(e){return e<0?0:e>255?255:Math.round(e)}function qg(e){if(!e||e[0]!=="#")return;e=e.slice(1);let i;return e.length<=4?(i={r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16)},e.length===4&&(i.a=parseInt(e[3]+e[3],16)/255)):(i={r:parseInt(e[0]+e[1],16),g:parseInt(e[2]+e[3],16),b:parseInt(e[4]+e[5],16)},e.length===8&&(i.a=parseInt(e[6]+e[7],16)/255)),i&&typeof i.a=="undefined"&&(i.a=1),i}function D0(e){const[i,r,a]=[e.L,e.C,e.H],u=a*Math.PI/180,p={L:i,a:r*Math.cos(u),b:r*Math.sin(u)};return e.alpha!==void 0&&(p.alpha=e.alpha),p}function Zg(e){const[i,r,a]=[e.L,e.a,e.b],u=Math.sqrt(r*r+a*a),g=Math.atan2(a,r)*180/Math.PI,b={L:i,C:u,H:g};return e.alpha!==void 0&&(b.alpha=e.alpha),b}function C0(e){const[i,r,a]=[e.L,e.a,e.b],u=Math.pow(.9999999984505198*i+.39633779217376786*r+.2158037580607588*a,3),p=Math.pow(1.00000000888176*i-.10556134232365635*r-.0638541747717059*a,3),g=Math.pow(i*1.000000054672411-.0894841820949657*r-1.2914855378640917*a,3),b=4.076741661347994*u-3.307711590408193*p+.230969928729428*g,w=-1.2684380040921763*u+2.6097574006633715*p-.3413193963102197*g,E=-.004196086541837188*u-.7034186144594493*p+1.7076147009309444*g,R=N=>{const Z=Math.abs(N);return Z<=.0031308?N*12.92:(Math.sign(N)||1)*(1.055*Math.pow(Z,1/2.4)-.055)};return[R(b),R(w),R(E)]}function M0(e){const[i,r,a]=e;return i>=0&&i<=1&&r>=0&&r<=1&&a>=0&&a<=1}function R0(e,i){let[r,a,u]=e;return r=ic(r*255),a=ic(a*255),u=ic(u*255),i!==void 0?{r,g:a,b:u,alpha:i}:{r,g:a,b:u}}function kp(e){let[i,r,a]=C0(e);if(M0([i,r,a]))return R0([i,r,a],e.alpha);const u=Zg(e);if(u.C=0,[i,r,a]=C0(D0(u)),!M0([i,r,a]))return R0([i,r,a],e.alpha);let p=0,g=e.L,b=(p+g)/2;u.C=b;const w=.36/Math.pow(2,12);for(;g-p>w;)b=(p+g)/2,u.C=b,[i,r,a]=C0(D0(u)),M0([i,r,a])?p=b:g=b;return R0([i,r,a],e.alpha)}function Yg(e){return kp(D0(e))}function Tp(e,i){const r=L0(e),a=L0(i),u=.56,p=.57,g=.62,b=.65,w=.022,E=1.414,R=.1,N=5e-4,Z=1.14,ue=.027,me=1.14,Ve=.027;function Ct(ai){return ai>=w?ai:ai+va(w-ai,E)}function Ue(ai){return(ai<0?-1:1)*Math.pow(Math.abs(ai),2.4)}const ct=Ct(Ue(a.r/255)*.2126729+Ue(a.g/255)*.7151522+Ue(a.b/255)*.072175),It=Ct(Ue(r.r/255)*.2126729+Ue(r.g/255)*.7151522+Ue(r.b/255)*.072175);let yt,ei,hi;return Math.abs(It-ct)<N?ei=0:It>ct?(yt=va(It,u)-va(ct,p),ei=yt*Z):(yt=va(It,b)-va(ct,g),ei=yt*me),Math.abs(ei)<R?hi=0:ei>0?hi=ei-Ve:hi=ei+ue,hi*100}function Ap(e,i,r){r!=null||(r="#fff"),i!=null||(i="#000");const a=Tp(e,r),u=Tp(e,i);return Math.abs(a)>Math.abs(u)?r:i}function Xg(e){const i=L0(e);let r=((1<<24)+(ic(i.r)<<16)+(ic(i.g)<<8)+ic(i.b)).toString(16).slice(1);return i.alpha!==void 0&&i.alpha<1&&(r+=("00"+Math.round(i.alpha*255).toString(16)).slice(-2)),r[0]===r[1]&&r[2]===r[3]&&r[4]===r[5]&&r[6]===r[7]&&(r=r[0]+r[2]+r[4]+(i.alpha!==void 0&&i.alpha<1?r[6]:"")),"#"+r}function rr(e){const i=Lp(e);let r="";for(const a of i){if(typeof a.value!="string")return"";r+=a.value}return r}function Lp(e){const r=e.model.selection.ranges;return r.length!==1?[]:e.model.getAtoms(r[0])}function Jg(e,i){const r=Lp(e);if(r.length!==1)return!1;const a=Vu[i];return a?!!a.test(r[0].value):!1}function Qg(e,i){return rr(e).length>0}function e1(e){return[I0(e,"double-struck","mathbb","tooltip.blackboard"),I0(e,"fraktur","mathfrak","tooltip.fraktur"),I0(e,"calligraphic","mathcal","tooltip.caligraphic"),P0(e,"up","mathrm","tooltip.roman-upright"),P0(e,"bold","mathbf","tooltip.bold"),P0(e,"italic","mathit","tooltip.italic")]}function t1(e){return[{label:()=>Vr(`\\vec{${rr(e)}}`),visible:()=>rr(e).length===1,onMenuSelect:()=>e.insert("\\vec{#@}",{selectionMode:"item"})},{label:()=>Vr(`\\overrightarrow{${rr(e)}}`),visible:()=>rr(e).length>0,onMenuSelect:()=>e.insert("\\overrightarrow{#@}",{selectionMode:"item"})},{label:()=>Vr(`\\overleftarrow{${rr(e)}}`),visible:()=>rr(e).length>0,onMenuSelect:()=>e.insert("\\overleftarrow{#@}",{selectionMode:"item"})},{label:()=>Vr(`\\dot{${rr(e)}}`),visible:()=>rr(e).length===1,onMenuSelect:()=>e.insert("\\dot{#@}",{selectionMode:"item"})},{label:()=>Vr(`\\ddot{${rr(e)}}`),visible:()=>rr(e).length===1,onMenuSelect:()=>e.insert("\\ddot{#@}",{selectionMode:"item"})},{label:()=>Vr(`\\bar{${rr(e)}}`),visible:()=>rr(e).length===1,onMenuSelect:()=>e.insert("\\bar{#@}",{selectionMode:"item"})},{label:()=>Vr(`\\overline{${rr(e)}}`),visible:()=>rr(e).length>0,onMenuSelect:()=>e.insert("\\overline{#@}",{selectionMode:"item"})},{label:()=>Vr(`\\overgroup{${rr(e)}}`),visible:()=>rr(e).length>0,onMenuSelect:()=>e.insert("\\overgroup{#@}",{selectionMode:"item"})},{label:()=>Vr(`\\overbrace{${rr(e)}}`),visible:()=>rr(e).length>0,onMenuSelect:()=>e.insert("\\overbrace{#@}",{selectionMode:"item"})},{label:()=>Vr(`\\underline{${rr(e)}}`),visible:()=>rr(e).length>0,onMenuSelect:()=>e.insert("\\underline{#@}",{selectionMode:"item"})},{label:()=>Vr(`\\undergroup{${rr(e)}}`),visible:()=>rr(e).length>0,onMenuSelect:()=>e.insert("\\undergroup{#@}",{selectionMode:"item"})},{label:()=>Vr(`\\underbrace{${rr(e)}}`),visible:()=>rr(e).length>0,onMenuSelect:()=>e.insert("\\underbrace{#@}",{selectionMode:"item"})}]}function i1(e){return[{label:()=>Vr(`\\boxed{${e.getValue(e.model.selection)}}}`),onMenuSelect:()=>e.insert("\\boxed{#@}",{selectionMode:"item"})},{label:()=>Vr(`\\bbox[5px, border: 2px solid red]{${e.getValue(e.model.selection)}}`),onMenuSelect:()=>e.insert("\\bbox[5px, border: 2px solid red]{#@}",{selectionMode:"item"})},{label:()=>Vr(`\\bbox[5px, border: 2px dashed black]{${e.getValue(e.model.selection)}}`),onMenuSelect:()=>e.insert("\\bbox[5px, border: 2px dashed black]{#@}",{selectionMode:"item"})}]}function n1(e){const i=[];for(const r of Object.keys(Se))i.push({class:(Xg(Ap(Se[r]))==="#000"?"dark-contrast":"light-contrast")+" menu-swatch",label:`<span style="background:${Se[r]} "></span>`,ariaLabel:()=>{var a;return(a=G(r))!=null?a:r},checked:()=>{var a;return{some:"mixed",all:!0}[(a=e.queryStyle({backgroundColor:r}))!=null?a:!1]},onMenuSelect:()=>{e.applyStyle({backgroundColor:r},{operation:"toggle"}),e.adoptStyle="none"}});return i}function r1(e){const i=[];for(const r of Object.keys(re))i.push({class:(Ap(re[r])==="#000"?"dark-contrast":"light-contrast")+" menu-swatch",label:`<span style="background:${re[r]} "></span>`,ariaLabel:()=>{var a;return(a=G(r))!=null?a:r},checked:()=>{var a;return{some:"mixed",all:!0}[(a=e.queryStyle({color:r}))!=null?a:!1]},onMenuSelect:()=>{e.applyStyle({color:r},{operation:"toggle"}),e.adoptStyle="none"}});return i}var s1=class extends mp{constructor(e,i,r,a){super(e,i),this.row=r,this.col=a}set active(e){const i=this.parentMenu.children;if(e)for(const r of i)r.element.classList.toggle("active",r.row<=this.row&&r.col<=this.col);else for(const r of i)r.element.classList.remove("active")}};function a1(e){const i=[];for(let r=1;r<=5;r++)for(let a=1;a<=5;a++)i.push({onCreate:(u,p)=>new s1(u,p,r,a),label:"\u2610",tooltip:()=>G("tooltip.row-by-col",r,a),data:{row:r,col:a},onMenuSelect:()=>{e.insert(`\\begin{pmatrix}${Array(r).fill(Array(a).fill("#?").join(" & ")).join("\\\\")}\\end{pmatrix}`,{selectionMode:"item"})}});return i}function o1(e){return[{label:()=>G("menu.array.add row above"),id:"add-row-above",onMenuSelect:()=>e.executeCommand("addRowBefore"),visible:()=>Wl(e)},{label:()=>G("menu.array.add row below"),id:"add-row-below",onMenuSelect:()=>e.executeCommand("addRowAfter"),visible:()=>Wl(e)},{label:()=>G("menu.array.add column before"),id:"add-column-before",onMenuSelect:()=>e.executeCommand("addColumnBefore"),visible:()=>Wl(e),enabled:()=>{const i=e.model.parentEnvironment;if(!i)return!1;const[r,a]=u1(e);return r<i.maxColumns}},{label:()=>G("menu.array.add column after"),id:"add-column-after",onMenuSelect:()=>e.executeCommand("addColumnAfter"),visible:()=>Wl(e)},{type:"divider"},{label:()=>G("menu.array.delete row"),id:"delete-row",onMenuSelect:()=>e.executeCommand("removeRow"),visible:()=>Wl(e)},{label:()=>G("menu.array.delete column"),id:"delete-column",onMenuSelect:()=>e.executeCommand("removeColumn"),visible:()=>Wl(e)},{type:"divider"},{label:()=>G("menu.borders"),visible:()=>(l1(e)||Wl(e))&&e.isSelectionEditable,submenu:[{label:" \u22F1 ",id:"environment-no-border",onMenuSelect:()=>dh(e,"matrix")},{label:"(\u22F1)",id:"environment-parentheses",onMenuSelect:()=>dh(e,"pmatrix")},{label:"[\u22F1]",id:"environment-brackets",onMenuSelect:()=>dh(e,"bmatrix")},{label:"|\u22F1|",id:"environment-bar",onMenuSelect:()=>dh(e,"vmatrix")},{label:"{\u22F1}",id:"environment-braces",onMenuSelect:()=>dh(e,"Bmatrix")}],submenuClass:"border-submenu"},{type:"divider"},{label:()=>G("menu.insert matrix"),id:"insert-matrix",visible:()=>e.isSelectionEditable,submenu:a1(e),submenuClass:"insert-matrix-submenu",columnCount:5},{label:()=>G("menu.mode"),id:"mode",visible:()=>e.isSelectionEditable&&e.model.selectionIsCollapsed,submenu:[{label:()=>G("menu.mode-math"),id:"mode-math",onMenuSelect:()=>{He(e,"accept-all"),e.executeCommand(["switchMode","math"])},checked:()=>e.model.mode==="math"},{label:()=>G("menu.mode-text"),id:"mode-text",onMenuSelect:()=>{He(e,"accept-all"),e.executeCommand(["switchMode","text"])},checked:()=>e.model.mode==="text"},{label:()=>G("menu.mode-latex"),id:"mode-latex",onMenuSelect:()=>e.executeCommand(["switchMode","latex"]),checked:()=>e.model.mode==="latex"}]},{type:"divider"},{label:()=>G("menu.font-style"),id:"variant",visible:()=>e.isSelectionEditable,submenu:e1(e),submenuClass:"variant-submenu"},{label:()=>G("menu.color"),id:"color",visible:()=>e.isSelectionEditable,submenu:r1(e),columnCount:4,submenuClass:"swatches-submenu"},{label:()=>G("menu.background-color"),id:"background-color",visible:()=>e.isSelectionEditable,submenu:n1(e),columnCount:4,submenuClass:"swatches-submenu"},{label:()=>G("menu.accent"),id:"accent",visible:()=>e.isSelectionEditable,submenu:t1(e),submenuClass:"variant-submenu"},{label:()=>G("menu.decoration"),id:"decoration",visible:()=>e.isSelectionEditable&&rr(e).length>0,submenu:i1(e),submenuClass:"variant-submenu"},{type:"divider"},{label:()=>G("menu.evaluate"),id:"ce-evaluate",visible:()=>e.isSelectionEditable&&window.MathfieldElement.computeEngine!==null,onMenuSelect:()=>{const i=c1(e);if(!i){e.model.announce("plonk");return}e.model.selectionIsCollapsed?(e.model.position=e.model.lastOffset,e.insert(`=${i}`,{insertionMode:"insertAfter",selectionMode:"item"})):e.insert(i,{insertionMode:"replaceSelection",selectionMode:"item"})}},{label:()=>G("menu.simplify"),id:"ce-simplify",visible:()=>e.isSelectionEditable&&window.MathfieldElement.computeEngine!==null,onMenuSelect:()=>{var i,r;if(e.model.selectionIsCollapsed){const a=(i=e.expression)==null?void 0:i.simplify();if(e.model.position=e.model.lastOffset,!a){e.model.announce("plonk");return}e.insert(`=${a.latex}`,{insertionMode:"insertAfter",selectionMode:"item"})}else{const a=(r=window.MathfieldElement.computeEngine)==null?void 0:r.parse(e.getValue(e.model.selection)).simplify();if(!a){e.model.announce("plonk");return}e.insert(a.latex,{insertionMode:"replaceSelection",selectionMode:"item"})}}},{label:()=>{var i;if(window.MathfieldElement.computeEngine===null)return"";const r=(i=e.expression)==null?void 0:i.unknowns[0];return r?G("menu.solve-for",Vr(r)):G("menu.solve")},id:"ce-solve",visible:()=>{var i;return e.isSelectionEditable&&window.MathfieldElement.computeEngine!==null&&((i=e.expression)==null?void 0:i.unknowns.length)===1&&e.expression.unknowns[0]!=="Nothing"},onMenuSelect:()=>{var i;const r=e.expression,a=r==null?void 0:r.unknowns[0],u=(i=r.solve(a))==null?void 0:i.map(p=>{var g;return(g=p.simplify().latex)!=null?g:""});if(!u){e.model.announce("plonk");return}e.insert(`${a}=${u.length===1?u[0]:"\\left\\lbrace"+(u==null?void 0:u.join(", "))+"\\right\\rbrace"}`,{insertionMode:"replaceAll",selectionMode:"item"})}},{type:"divider"},{label:()=>G("menu.cut"),onMenuSelect:()=>e.executeCommand("cutToClipboard"),visible:()=>!e.options.readOnly&&e.isSelectionEditable,keyboardShortcut:"meta+X"},{label:()=>G("menu.copy"),id:"copy",submenu:[{label:()=>G("menu.copy-as-latex"),id:"copy-latex",onMenuSelect:()=>qn.copyToClipboard(e,"latex"),keyboardShortcut:"meta+C"},{label:()=>G("menu.copy-as-ascii-math"),id:"copy-ascii-math",onMenuSelect:()=>qn.copyToClipboard(e,"ascii-math")},{label:()=>G("menu.copy-as-mathml"),id:"copy-math-ml",onMenuSelect:()=>qn.copyToClipboard(e,"math-ml")}]},{label:()=>G("menu.paste"),id:"paste",onMenuSelect:()=>e.executeCommand("pasteFromClipboard"),visible:()=>e.hasEditableContent,keyboardShortcut:"meta+V"},{label:()=>G("menu.select-all"),id:"select-all",keyboardShortcut:"meta+A",onMenuSelect:()=>e.executeCommand("selectAll")}]}function Wl(e){var i;return!!((i=e.model.parentEnvironment)!=null&&i.array)}function l1(e){return e.model.at(e.model.position).type==="array"}function u1(e){var i;const r=(i=e.model.parentEnvironment)==null?void 0:i.array;return r?[r.length,r.reduce((a,u)=>Math.max(a,u.length),0)]:[0,0]}function dh(e,i){Qe(e),e.flushInlineShortcutBuffer(),j0(e.model,i),wn(e)}function c1(e){var i,r;let a;if(e.model.selectionIsCollapsed?a=(i=window.MathfieldElement.computeEngine)==null?void 0:i.parse(e.getValue(),{canonical:!1}):a=(r=window.MathfieldElement.computeEngine)==null?void 0:r.parse(e.getValue(e.model.selection),{canonical:!1}),!a)return"";let u=a.evaluate();return u.isSame(a)&&(u=a.N()),u.latex}function I0(e,i,r,a){return{label:()=>Vr(`\\${r}{${rr(e)}}`),tooltip:()=>{var u;return(u=G(a))!=null?u:a},visible:()=>Jg(e,i),checked:()=>{var u;return{some:"mixed",all:!0}[(u=e.queryStyle({variant:i}))!=null?u:!1]},onMenuSelect:()=>{e.applyStyle({variant:i},{operation:"toggle"}),e.adoptStyle="none"}}}function P0(e,i,r,a){return{label:()=>Vr(`\\${r}{${rr(e)}}`),tooltip:()=>{var u;return(u=G(a))!=null?u:a},visible:()=>Qg(e,i),checked:()=>{var u;return{some:"mixed",all:!0}[(u=e.queryStyle({variantStyle:i}))!=null?u:!1]},onMenuSelect:()=>{e.applyStyle({variantStyle:i},{operation:"toggle"}),e.adoptStyle="none"}}}function nc(e,i){return e+tc(i)}ur({speak:(e,i,r)=>h1(e,i,r)},{target:"mathfield"});function h1(e,i,r){var a,u;r=r!=null?r:{withHighlighting:!1};const{model:p}=e;function g(R){let N=null;switch(R){case"all":N=p.root;break;case"selection":N=p.getAtoms(p.selection);break;case"left":{N=p.getAtoms(p.offsetOf(p.at(p.position).leftSibling),p.position);break}case"right":{N=p.getAtoms(p.position,p.offsetOf(p.at(p.position).rightSibling));break}case"group":N=p.getAtoms(p.getSiblingsRange(p.position));break;case"parent":{const{parent:Z}=p.at(p.position);Z!=null&&Z.parent?N=Z:N=p.root;break}default:N=p.root}return N}function b(R){let N="";switch(R){case"all":console.log("Internal failure: speak all failed");break;case"selection":N="no selection";break;case"left":N="at start";break;case"right":N="at end";break;case"group":console.log("Internal failure: speak group failed");break;case"parent":N="no parent";break;default:console.log('unknown speak_ param value: "'+R+'"');break}return N}const w=g(i);if(w===null)return(u=(a=window.MathfieldElement).speakHook)==null||u.call(a,b(i)),!1;(r.withHighlighting||window.MathfieldElement.speechEngine==="amazon")&&(window.MathfieldElement.textToSpeechMarkup=window.sre&&window.MathfieldElement.textToSpeechRules==="sre"?"ssml_step":"ssml");const E=tc(w);return M()&&r.withHighlighting?(Qo().readAloudMathfield=e,pa(e,{forHighlighting:!0}),window.MathfieldElement.readAloudHook&&window.MathfieldElement.readAloudHook(e.field,E)):window.MathfieldElement.speakHook&&window.MathfieldElement.speakHook(E),!1}function f1(e){var i,r;if(!M()){console.log("Speak:",e);return}if(!window.MathfieldElement.speechEngine||window.MathfieldElement.speechEngine==="local"){const a=new SpeechSynthesisUtterance(e);window.speechSynthesis.speak(a)}else if(window.MathfieldElement.speechEngine==="amazon")if(!("AWS"in window))console.error("MathLive 0.98.5: AWS SDK not loaded. See https://www.npmjs.com/package/aws-sdk");else{const a=new window.AWS.Polly({apiVersion:"2016-06-10"}),u={OutputFormat:"mp3",VoiceId:(i=window.MathfieldElement.speechEngineVoice)!=null?i:"Joanna",Engine:["Amy","Emma","Brian","Ivy","Joanna","Kendra","Kimberly","Salli","Joey","Justin","Matthew"].includes((r=window.MathfieldElement.speechEngineVoice)!=null?r:"Joanna")?"neural":"standard",Text:e,TextType:"ssml"};a.synthesizeSpeech(u,(p,g)=>{if(p)console.trace(`MathLive 0.98.5: \`polly.synthesizeSpeech()\` error: ${p}`);else if(g!=null&&g.AudioStream){const b=new Uint8Array(g.AudioStream),w=new Blob([b.buffer],{type:"audio/mpeg"}),E=URL.createObjectURL(w);new Audio(E).play().catch(N=>console.log(N))}else console.log("polly.synthesizeSpeech():",g)})}else window.MathfieldElement.speechEngine==="google"&&console.error("MathLive 0.98.5: The Google speech engine is not supported yet. Please come again.")}function Dp(e){var i;let r;if(e.parent.type==="prompt")e.parentBranch==="body"&&(r="prompt");else if(e.parentBranch==="body")r=e.type&&(i={enclose:"cross out",leftright:"delimiter",surd:"square root",root:"math field",mop:"operator",first:"first"}[e.type])!=null?i:"parent";else if(e.parent.type==="genfrac"){if(e.parentBranch==="above")return"numerator";if(e.parentBranch==="below")return"denominator"}else e.parent.type==="surd"?e.parentBranch==="above"&&(r="index"):e.parentBranch==="superscript"?r="superscript":e.parentBranch==="subscript"&&(r="subscript");return r||console.log("unknown relationship"),r!=null?r:"parent"}function d1(e,i,r,a){let u="";if(i==="plonk")window.MathfieldElement.playSound("plonk"),e.flushInlineShortcutBuffer();else if(i==="delete")u=nc("deleted: ",a);else if(i==="focus"||i.includes("move"))u=p1(e.model,r)+(e.model.selectionIsCollapsed?"":"selected: ")+m1(e.model);else if(i==="replacement")u=nc("",e.model.at(e.model.position));else if(i==="line"){const p=nc("",e.model.root);e.keyboardDelegate.setAriaLabel(p)}else u=a?nc(i+" ",a):i;if(u){const p=e.ariaLiveText.textContent.includes("\xA0")?" \u202F ":" \xA0 ";e.ariaLiveText.textContent=u+p}}function p1(e,i){if(Number.isNaN(i))return"";const r=e.at(i);if(!r||r.treeDepth<=e.at(e.position).treeDepth)return"";let a="",u=r.parent;const p=e.at(e.position).parent;for(;u!==e.root&&u!==p;)a+=`out of ${Dp(u)};`,u=u.parent;return a}function m1(e){if(!e.selectionIsCollapsed)return nc("",e.getAtoms(e.selection));let i="";const r=e.at(e.position),a=Dp(r);return r.isFirstSibling&&(i=(a?"start of "+a:"unknown")+": "),r.isLastSibling?r.isFirstSibling||(i+=a?"end of "+a:"unknown"):i+=nc("",r),i}var g1=class{constructor(e,i,r){this.mathfield=e,this.mode=i,this.silenceNotifications=!1,this._selection={ranges:[[0,0]],direction:"none"},this._anchor=0,this._position=0,this.root=r}dispose(){this.mathfield=void 0}getState(){const e={ranges:[...this._selection.ranges]};return this.selection.direction&&this.selection.direction!=="none"&&(e.direction=this.selection.direction),{content:this.root.toJson(),selection:e,mode:this.mode}}setState(e,i){var r;const a=this.silenceNotifications;this.silenceNotifications=(r=i==null?void 0:i.silenceNotifications)!=null?r:!0;let u={};if((i==null?void 0:i.type)==="undo"&&(u={inputType:"historyUndo"}),(i==null?void 0:i.type)==="redo"&&(u={inputType:"historyRedo"}),this.contentWillChange(u)){const p=this.silenceNotifications;this.silenceNotifications=!0,this.mode=e.mode,this.root=Pa(e.content),this.selection=e.selection,this.silenceNotifications=p,this.contentDidChange(u)}this.silenceNotifications=a}get atoms(){return this.root.children}get selection(){return this._selection}set selection(e){this.setSelection(e)}setSelection(e,i){return!this.mathfield.contentEditable&&this.mathfield.userSelect==="none"?!1:this.deferNotifications({selection:!0},()=>{var r,a,u;const p=this.normalizeSelection(e,i);if(p===void 0)throw new TypeError("Invalid selection");if(p.ranges.length===1&&p.ranges[0][0]===p.ranges[0][1]){const R=p.ranges[0][0];if(!this.mathfield.dirty&&!((r=this.at(R))!=null&&r.parentPrompt)&&this.mathfield.hasEditablePrompts){if((a=this.at(R-1))!=null&&a.parentPrompt){this._anchor=this.normalizeOffset(R-1),this._position=this._anchor,this._selection=this.normalizeSelection(this._anchor);return}if((u=this.at(R+1))!=null&&u.parentPrompt){this._anchor=this.normalizeOffset(R+1),this._position=this._anchor,this._selection=this.normalizeSelection(this._anchor);return}this._anchor=0,this._position=0,this._selection={ranges:[[0,0]]};return}this._anchor=R,this._position=R,this._selection=p;return}const g=Fr(p);p.direction==="backward"?[this._position,this._anchor]=g:[this._anchor,this._position]=g;const b=this.at(g[0]+1),w=this.at(g[1]),E=et.commonAncestor(b,w);(E==null?void 0:E.type)==="array"&&b.parent===E&&w.parent===E?this._selection={ranges:[g],direction:p.direction}:this._selection={ranges:[g],direction:p.direction},console.assert(this._position>=0&&this._position<=this.lastOffset)})}setPositionHandlingPlaceholder(e){var i;const r=this.at(e);(r==null?void 0:r.type)==="placeholder"?this.setSelection(e-1,e):((i=r==null?void 0:r.rightSibling)==null?void 0:i.type)==="placeholder"?this.setSelection(e,e+1):this.position=e,r instanceof Lr&&r.isSuggestion&&(r.isSuggestion=!1),this.mathfield.stopCoalescingUndo()}get position(){return this._position}set position(e){this.setSelection(e,e)}get anchor(){return this._anchor}get selectionIsCollapsed(){return this._anchor===this._position}get selectionIsPlaceholder(){return Math.abs(this._anchor-this._position)===1?this.at(Math.max(this._anchor,this._position)).type==="placeholder":!1}collapseSelection(e="forward"){return this._anchor===this._position?!1:(e==="backward"?this.position=Math.min(this._anchor,this._position):this.position=Math.max(this._anchor,this._position),!0)}get lastOffset(){return this.atoms.length-1}at(e){return this.atoms[e]}offsetOf(e){return this.atoms.indexOf(e)}getSiblingsRange(e){const i=this.at(e),{parent:r}=i;if(!r)return[0,this.lastOffset];const a=i.parent.branch(i.parentBranch);return[this.offsetOf(a[0]),this.offsetOf(a[a.length-1])]}getBranchRange(e,i){const r=this.at(e).branch(i);return[this.offsetOf(r[0]),this.offsetOf(r[r.length-1])]}getAtoms(e,i,r){let a=r!=null?r:{};if(Au(e)){if(a=i!=null?i:{},e.ranges.length>1)return e.ranges.reduce((E,R)=>[...E,...this.getAtoms(R,a)],[]);e=e.ranges[0]}let u,p;if(zs(e)){if(u=e,!zs(i))return[];p=i}else[u,p]=e,a=i!=null?i:{};if(!Number.isFinite(u))return[];a.includeChildren===void 0&&(a.includeChildren=!1),u<0&&(u=this.lastOffset-u+1),p<0&&(p=this.lastOffset-p+1);const g=Math.min(u,p)+1,b=Math.max(u,p);if(!a.includeChildren&&g===1&&b===this.lastOffset)return[this.root];let w=[];for(let E=g;E<=b;E++){const R=this.atoms[E];Cp(this,R,g,b)&&w.push(R)}return a.includeChildren||(w=w.filter(E=>{let R=!1,{parent:N}=E;for(;N&&!R;)R=Cp(this,N,g,b),N=N.parent;return!R})),w}getAllAtoms(e=0){const i=[],r=this.lastOffset;for(let a=e;a<=r;a++)i.push(this.atoms[a]);for(let a=0;a<e;a++)i.push(this.atoms[a]);return i}findAtom(e,i=0,r="forward"){let a;const u=this.lastOffset;if(r==="forward"){for(let p=i;p<=u;p++)if(a=this.atoms[p],e(a))return a;for(let p=0;p<i;p++)if(a=this.atoms[p],e(a))return a;return}for(let p=i;p>=0;p--)if(a=this.atoms[p],e(a))return a;for(let p=u;p>i;p--)if(a=this.atoms[p],e(a))return a}extractAtoms(e){let i=this.getAtoms(e);if(i.length===1&&!i[0].parent)if(i[0].type==="root")i=[...i[0].body],i.shift();else return i=this.root.cells.flat(),this.root=new et({type:"root",body:[]}),i;for(const r of i)r.parent.removeChild(r);return i}deleteAtoms(e){this.extractAtoms(e),this.position=e[0]}atomToString(e,i){const r=i!=null?i:"latex";if(r.startsWith("latex"))return et.serialize([e],{expandMacro:r==="latex-expanded",skipStyles:r==="latex-unstyled",skipPlaceholders:r==="latex-without-placeholders",defaultMode:this.mathfield.options.defaultMode});if(r==="math-ml")return Sn(e);if(r==="spoken")return tc(e);if(r==="spoken-text"){const a=window.MathfieldElement.textToSpeechMarkup;window.MathfieldElement.textToSpeechMarkup="";const u=tc(e);return window.MathfieldElement.textToSpeechMarkup=a,u}if(r==="spoken-ssml"||r==="spoken-ssml-with-highlighting"){const a=window.MathfieldElement.textToSpeechMarkup;window.MathfieldElement.textToSpeechMarkup="ssml";const u=tc(e);return window.MathfieldElement.textToSpeechMarkup=a,u}return r==="ascii-math"?yr(e):(console.error(`MathLive 0.98.5: Unexpected format "${r}`),"")}getValue(e,i,r){if(e===void 0)return this.atomToString(this.root,"latex");if(typeof e=="string"&&e!=="math-json")return this.atomToString(this.root,e);let a,u;if(zs(e)&&zs(i)?(a=[this.normalizeRange([e,i])],u=r):Fc(e)?(a=[this.normalizeRange(e)],u=i):Au(e)?(a=e.ranges,u=i):(a=[this.normalizeRange([0,-1])],u=e),u!=null||(u="latex"),u==="math-json"){if(!window.MathfieldElement.computeEngine)return window[Symbol.for("io.cortexjs.compute-engine")]||console.error(`The CortexJS Compute Engine library is not available.
Load the library, for example with:
import "https://unpkg.com/@cortex-js/compute-engine?module"`),'["Error", "compute-engine-not-available"]';const p=this.getValue({ranges:a},"latex-unstyled");try{const g=window.MathfieldElement.computeEngine.parse(p);return JSON.stringify(g.json)}catch(g){return JSON.stringify(["Error",`'${g.toString()}'`])}}if(u.startsWith("latex")){const p={expandMacro:u==="latex-expanded",skipStyles:u==="latex-unstyled",skipPlaceholders:u==="latex-without-placeholders",defaultMode:this.mathfield.options.defaultMode};return sn(a.map(g=>et.serialize(this.getAtoms(g),p)))}return a.map(p=>this.getAtoms(p).map(g=>this.atomToString(g,u)).join("")).join("")}extendSelectionTo(e,i){return!this.mathfield.contentEditable&&this.mathfield.userSelect==="none"?!1:this.deferNotifications({selection:!0},()=>{const r=this.normalizeRange([e,i]);let[a,u]=r,{parent:p}=this.at(u);if(p&&(p.type==="genfrac"||p.type==="subsup"))for(;p!==this.root&&O0(this,p,[a,u]);)u=this.offsetOf(p),p=p.parent;for(p=this.at(a).parent;p!==this.root&&O0(this,p,[a,u]);)a=this.offsetOf(p.leftSibling),p=p.parent;if(p=this.at(u).parent,(p==null?void 0:p.type)==="genfrac")for(;p!==this.root&&O0(this,p,[a,u]);)u=this.offsetOf(p),console.assert(u>=0),p=p.parent;this._position=this.normalizeOffset(i),this._selection={ranges:[[a,u]],direction:"none"}})}announce(e,i,r=[]){var a,u;((u=(a=this.mathfield.host)==null?void 0:a.dispatchEvent(new CustomEvent("announce",{detail:{command:e,previousPosition:i,atoms:r},cancelable:!0,bubbles:!0,composed:!0})))!=null?u:!0)&&d1(this.mathfield,e,i,r)}deferNotifications(e,i){const r=this._selection,a=this._anchor,u=this._position,p=this.silenceNotifications;this.silenceNotifications=!0;const g=this.root.changeCounter;i();const b=this.root.changeCounter!==g,w=a!==this._anchor||u!==this._position||bd(this._selection,r)==="different";return this.silenceNotifications=p,e.content&&b&&this.contentDidChange({inputType:e.type}),e.selection&&w&&this.selectionDidChange(),b||w}normalizeOffset(e){return e>0?e=Math.min(e,this.lastOffset):e<0&&(e=this.lastOffset+e+1),e}normalizeRange(e){let[i,r]=e;return i=this.normalizeOffset(i),r=this.normalizeOffset(r),i<r?[i,r]:[r,i]}normalizeSelection(e,i){var r;let a;if(zs(e)){const u=this.normalizeOffset(e);if(zs(i)){const p=this.normalizeOffset(i);a=u<=p?{ranges:[[u,p]],direction:"none"}:{ranges:[[p,u]],direction:"backward"}}else a={ranges:[[u,u]],direction:"none"}}else if(Fc(e)){const u=this.normalizeOffset(e[0]),p=this.normalizeOffset(e[1]);a=u<=p?{ranges:[[u,p]],direction:"none"}:{ranges:[[p,u]],direction:"backward"}}else Au(e)&&(a={ranges:e.ranges.map(u=>this.normalizeRange(u)),direction:(r=e.direction)!=null?r:"none"});return console.assert(a!==void 0),a}get parentEnvironment(){let e=this.at(this.position).parent;if(e){for(;e.parent&&e.type!=="array";)e=e.parent;if(e.type==="array")return e}}get cell(){var e;let i=this.at(this.position);if(i){for(;i&&((e=i.parent)==null?void 0:e.type)!=="array";)i=i.parent;if(!(!(i!=null&&i.parent)||i.parent.type!=="array"))return i.parentBranch}}contentWillChange(e={}){if(this.silenceNotifications||!this.mathfield)return!0;const i=this.silenceNotifications;this.silenceNotifications=!0;const r=this.mathfield.onContentWillChange(e);return this.silenceNotifications=i,r}contentDidChange(e){var i;if(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(Ba(this.mathfield)),this.silenceNotifications||!this.mathfield.host||!this.mathfield)return;const r=this.silenceNotifications;this.silenceNotifications=!0,this.mathfield.host.dispatchEvent(new InputEvent("input",d(P({},e),{data:e.data?e.data:(i=e.inputType)!=null?i:"",bubbles:!0,composed:!0}))),this.silenceNotifications=r}selectionDidChange(){if(!this.mathfield||(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(Ba(this.mathfield)),this.silenceNotifications))return;const e=this.silenceNotifications;this.silenceNotifications=!0,this.mathfield.onSelectionDidChange(),this.silenceNotifications=e}};function Cp(e,i,r,a){const u=e.offsetOf(i);if(u<r||u>a)return!1;if(!i.hasChildren)return!0;const p=e.offsetOf(i.firstChild);if(p>=r&&p<=a){const g=e.offsetOf(i.lastChild);if(g>=r&&g<=a)return!0}return!1}function O0(e,i,r){if(!(i!=null&&i.hasChildren))return!1;const[a,u]=r,p=e.offsetOf(i.firstChild),g=e.offsetOf(i.lastChild);return p>=a&&p<=u&&g>=p&&g<=u}function ph(e,i,r,a){var u,p,g,b,w,E;const R=r.parent;if(R&&r instanceof Zn){const N=!a&&i==="forward"||a==="body"&&i==="backward";let Z=N?e.offsetOf(r.firstChild):e.offsetOf(r.lastChild);return N?r.rightDelim!=="?"&&r.rightDelim!=="."?(r.leftDelim=".",r.isDirty=!0):(R.addChildrenAfter(r.removeBranch("body"),r),R.removeChild(r),Z--):r.leftDelim!=="?"&&r.leftDelim!=="."?(r.rightDelim=".",r.isDirty=!0):(R.addChildrenAfter(r.removeBranch("body"),r),R.removeChild(r),Z--),e.position=Z,!0}if(R&&r.type==="surd"){if(i==="forward"&&!a||i==="backward"&&a==="body"){const N=r.leftSibling;r.hasChildren&&R.addChildrenAfter(r.removeBranch("body"),r),R.removeChild(r),e.position=e.offsetOf(N)}else i==="forward"&&a==="body"?e.position=e.offsetOf(r):!a&&i==="backward"?r.hasChildren?e.position=e.offsetOf(r.lastChild):(e.position=Math.max(0,e.offsetOf(r)-1),R.removeChild(r)):a==="above"&&(r.hasEmptyBranch("above")&&r.removeBranch("above"),i==="backward"?e.position=e.offsetOf(r.leftSibling):e.position=e.offsetOf(r.body[0]));return!0}if(R&&(r.type==="box"||r.type==="enclose")){const N=a&&i==="backward"||!a&&i==="forward"?r.leftSibling:r.lastChild;return R.addChildrenAfter(r.removeBranch("body"),r),R.removeChild(r),e.position=e.offsetOf(N),!0}if(r.type==="genfrac"||r.type==="overunder"){if(!a)return r.type==="overunder"&&r.hasEmptyBranch("body")||r.type==="genfrac"&&r.hasEmptyBranch("below")&&r.hasEmptyBranch("above")?!1:(e.position=e.offsetOf(i==="forward"?r.firstChild:r.lastChild),!0);const N=mh.fractionNavigationOrder==="numerator-denominator"?"above":"below",Z=N==="above"?"below":"above";if(R&&(i==="forward"&&a===N||i==="backward"&&a===Z)){const ue=r.removeBranch(N),me=r.removeBranch(Z);return R.addChildrenAfter([...ue,...me],r),R.removeChild(r),e.position=e.offsetOf(ue.length>0?ue[ue.length-1]:me[0]),!0}return i==="backward"?e.position=e.offsetOf(r.leftSibling):e.position=e.offsetOf(r),!0}if(r.isExtensibleSymbol||r.type==="subsup"){if(!a&&i==="forward")return!1;if(!a){if(r.subscript||r.superscript){const N=i==="forward"?(g=(u=r.superscript)==null?void 0:u[0])!=null?g:(p=r.subscript)==null?void 0:p[0]:(E=(b=r.subscript)==null?void 0:b[0].lastSibling)!=null?E:(w=r.superscript)==null?void 0:w[0].lastSibling;return N&&(e.position=e.offsetOf(N)),!0}return!1}if(!r.hasChildren&&r.type==="subsup"){const N=i==="forward"?e.offsetOf(r):Math.max(0,e.offsetOf(r)-1);return r.parent.removeChild(r),e.position=N,!0}if(a==="superscript")if(i==="backward"){const N=e.offsetOf(r.firstChild)-1;console.assert(N>=0),e.position=N}else r.subscript?e.position=e.offsetOf(r.subscript[0]):e.position=e.offsetOf(r);else a==="subscript"&&(i==="backward"&&r.superscript?e.position=e.offsetOf(r.superscript[0].lastSibling):i==="backward"?e.position=e.offsetOf(r.firstChild)-1:e.position=e.offsetOf(r));if(a&&r.hasEmptyBranch(a)&&(r.removeBranch(a),r.type==="subsup"&&!r.subscript&&!r.superscript)){const N=i==="forward"?e.offsetOf(r):Math.max(0,e.offsetOf(r)-1);r.parent.removeChild(r),e.position=N}return!0}if((R==null?void 0:R.type)==="genfrac"&&!a&&r.type!=="first"){let N=e.offsetOf(r.leftSibling);return R.removeChild(r),R.hasEmptyBranch("above")&&R.hasEmptyBranch("below")?(N=e.offsetOf(R.leftSibling),R.parent.removeChild(R),e.announce("delete",void 0,[R]),e.position=N,!0):(e.announce("delete",void 0,[r]),e.position=N,!0)}if(i==="backward"&&((R==null?void 0:R.command)==="\\ln"||(R==null?void 0:R.command)==="\\log")&&r.parentBranch!=="body"){const N=e.offsetOf(R.leftSibling);return R.parent.removeChild(R),e.announce("delete",void 0,[R]),e.position=N,!0}return!1}function _1(e){return!e.mathfield.isSelectionEditable||!e.contentWillChange({inputType:"deleteContentBackward"})?!1:e.selectionIsCollapsed?e.deferNotifications({content:!0,selection:!0,type:"deleteContentBackward"},()=>{let i=e.at(e.position);if(!(i&&ph(e,"backward",i))){if(i!=null&&i.isFirstSibling){if(ph(e,"backward",i.parent,i.parentBranch))return;i=null}if(!i){e.announce("plonk");return}e.position=e.offsetOf(i.leftSibling),i.parent.removeChild(i),e.announce("delete",void 0,[i])}}):$a(e,Fr(e.selection),"deleteContentBackward")}function v1(e){return!e.mathfield.isSelectionEditable||!e.contentWillChange({inputType:"deleteContentForward"})?!1:e.selectionIsCollapsed?e.deferNotifications({content:!0,selection:!0,type:"deleteContentForward"},()=>{var i,r;let a=e.at(e.position).rightSibling;if(a&&ph(e,"forward",a))return;if(a){if(e.at(e.position).isLastSibling&&ph(e,"forward",a.parent,a.parentBranch))return}else{if(a=e.at(e.position),a.isLastSibling&&ph(e,"forward",a.parent,a.parentBranch))return;a=void 0}if(e.position===e.lastOffset||!a){e.announce("plonk");return}a.parent.removeChild(a);let u=(i=e.at(e.position))==null?void 0:i.rightSibling;for(;(u==null?void 0:u.type)==="subsup";)u.parent.removeChild(u),u=(r=e.at(e.position))==null?void 0:r.rightSibling;e.announce("delete",void 0,[a])}):$a(e,Fr(e.selection),"deleteContentForward")}function $a(e,i,r){const a=e.getAtoms(i);if(a.length>0&&a[0].parent){let u=a[0].parent.firstChild;u.type==="first"&&(u=u.rightSibling);const p=a[a.length-1].parent.lastChild;let g=a[0];g.type==="first"&&(g=g.rightSibling);const b=a[a.length-1];if(g===u&&b===p){const w=a[0].parent;w.parent&&w.type!=="prompt"&&(i=[e.offsetOf(w.leftSibling),e.offsetOf(w)])}if(a.length===1&&a[0].type==="placeholder"&&a[0].parent.type==="genfrac"){const w=a[0].parent,E=a[0].parentBranch==="below"?"above":"below",R=e.offsetOf(w.leftSibling);return e.deferNotifications({content:!0,selection:!0,type:r},()=>{var N,Z;const ue=w.removeBranch(E);if(ue.length===1&&ue[0].type==="placeholder")(Z=w.parent)==null||Z.removeChild(w),e.position=Math.max(0,R);else{const me=w.parent.addChildrenAfter(ue,w);(N=w.parent)==null||N.removeChild(w),e.position=e.offsetOf(me)}})}}return e.deferNotifications({content:!0,selection:!0,type:r},()=>e.deleteAtoms(i))}ur({deleteAll:e=>e.contentWillChange({inputType:"deleteContent"})&&$a(e,[0,-1],"deleteContent"),deleteForward:e=>v1(e),deleteBackward:e=>_1(e),deleteNextWord:e=>e.contentWillChange({inputType:"deleteWordForward"})&&$a(e,[e.anchor,c0(e,e.position,"forward")],"deleteWordForward"),deletePreviousWord:e=>e.contentWillChange({inputType:"deleteWordBackward"})&&$a(e,[e.anchor,c0(e,e.position,"backward")],"deleteWordBackward"),deleteToGroupStart:e=>e.contentWillChange({inputType:"deleteSoftLineBackward"})&&$a(e,[e.anchor,e.offsetOf(e.at(e.position).firstSibling)],"deleteSoftLineBackward"),deleteToGroupEnd:e=>e.contentWillChange({inputType:"deleteSoftLineForward"})&&$a(e,[e.anchor,e.offsetOf(e.at(e.position).lastSibling)],"deleteSoftLineForward"),deleteToMathFieldStart:e=>e.contentWillChange({inputType:"deleteHardLineBackward"})&&$a(e,[e.anchor,0],"deleteHardLineBackward"),deleteToMathFieldEnd:e=>e.contentWillChange({inputType:"deleteHardLineForward"})&&$a(e,[e.anchor,-1],"deleteHardLineForward")},{target:"model",audioFeedback:"delete",canUndo:!0,changeContent:!0,changeSelection:!0});var y1=`<svg xmlns="http://www.w3.org/2000/svg" style="width: 21px;" viewBox="0 0 576 512" role="img" aria-label="${G("tooltip.toggle virtual keyboard")}"><path d="M528 64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h480c26.51 0 48-21.49 48-48V112c0-26.51-21.49-48-48-48zm16 336c0 8.823-7.177 16-16 16H48c-8.823 0-16-7.177-16-16V112c0-8.823 7.177-16 16-16h480c8.823 0 16 7.177 16 16v288zM168 268v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm-336 80v-24c0-6.627-5.373-12-12-12H84c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm384 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zM120 188v-24c0-6.627-5.373-12-12-12H84c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm-96 152v-8c0-6.627-5.373-12-12-12H180c-6.627 0-12 5.373-12 12v8c0 6.627 5.373 12 12 12h216c6.627 0 12-5.373 12-12z"/></svg>`,b1=`<svg xmlns="http://www.w3.org/2000/svg" style="height: 18px;" viewBox="0 0 448 512" role="img" aria-label="${G("tooltip.menu")}"><path d="M0 96C0 78.3 14.3 64 32 64H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z"/></svg>`,x1=class{constructor(e,i){this.focusBlurInProgress=!1;var r,a,u;this.options=P(d(P({},zf()),{macros:Gt(),registers:Pc()}),Uf(i)),this.eventController=new AbortController;const p=this.eventController.signal;i.eventSink&&(this.host=i.eventSink),this.element=e,e.mathfield=this,this.blurred=!0,this.keystrokeCaptionVisible=!1,this.suggestionIndex=0,this.inlineShortcutBuffer=[],this.inlineShortcutBufferFlushTimer=0,this.defaultStyle={},this.adoptStyle="left",this.options.defaultMode==="inline-math"?this.element.classList.add("ML__is-inline"):this.element.classList.remove("ML__is-inline"),this.dirty=!1;let g=(a=(r=i.value)!=null?r:this.element.textContent)!=null?a:"";g=g.trim();const b=G0(this.options),w=new et({type:"root",mode:b,body:zr(g,{context:this.context})});this.model=new g1(this,b,w),this.undoManager=new Wm(this.model);const E=[];if(E.push("<span contenteditable=true aria-multiline=false part=keyboard-sink class=ML__keyboard-sink autocapitalize=off autocomplete=off autocorrect=off spellcheck=false inputmode=none tabindex=0></span>"),E.push('<span part=container class=ML__container aria-hidden=true style="visibility:hidden">'),E.push("<span part=content class=ML__content>"),E.push(Of(this)),E.push("</span>"),window.mathVirtualKeyboard&&(E.push(`<div part=virtual-keyboard-toggle class=ML__virtual-keyboard-toggle role=button ${this.hasEditableContent?"":'style="display:none;"'} data-l10n-tooltip="tooltip.toggle virtual keyboard">`),E.push(y1),E.push("</div>")),E.push('<div part=menu-toggle class=ML__menu-toggle role=button data-l10n-tooltip="tooltip.menu">'),E.push(b1),E.push("</div>"),E.push("</span>"),E.push("<span class=ML__sr-only>"),E.push("<span role=status aria-live=assertive aria-atomic=true></span>"),E.push("</span>"),this.element.innerHTML=window.MathfieldElement.createHTML(E.join("")),!this.element.children){console.error("%cMathLive 0.98.5: Something went wrong and the mathfield could not be created.%c\nIf you are using Vue, this may be because you are using the runtime-only build of Vue. Make sure to include `runtimeCompiler: true` in your Vue configuration. There may a warning from Vue in the log above.","color:red;font-family:system-ui;font-size:1.2rem;font-weight:bold","color:inherit;font-family:system-ui;font-size:inherit;font-weight:inherit");return}this._l10Subscription=$.subscribe(()=>$.update(this.element)),$.update(this.element),this.field=this.element.querySelector("[part=content]"),this.field.addEventListener("click",N=>N.stopImmediatePropagation(),{capture:!1,signal:p}),this.field.addEventListener("wheel",this,{passive:!1,signal:p}),"PointerEvent"in window?this.field.addEventListener("pointerdown",this,{signal:p}):this.field.addEventListener("mousedown",this,{signal:p}),(u=this.element.querySelector("[part=virtual-keyboard-toggle]"))==null||u.addEventListener("click",()=>{window.mathVirtualKeyboard.visible?window.mathVirtualKeyboard.hide():(window.mathVirtualKeyboard.show({animate:!0}),window.mathVirtualKeyboard.update(Ba(this)))},{signal:p}),this._menu=new Mg(o1(this),{host:this.host}),this.field.addEventListener("contextmenu",this,{signal:p});const R=this.element.querySelector("[part=menu-toggle]");R==null||R.addEventListener("pointerdown",N=>{if(N.currentTarget!==R||this._menu.state!=="closed")return;this.element.classList.add("tracking");const Z=R.getBoundingClientRect();this._menu.modifiers=n(N),this._menu.show({target:R,location:{x:Z.left,y:Z.bottom},onDismiss:()=>this.element.classList.remove("tracking")}),N.preventDefault(),N.stopPropagation()},{signal:p}),(this.model.atoms.length<=1||this.disabled||this.readOnly&&!this.hasEditableContent||this.userSelect==="none")&&(R.style.display="none"),this.ariaLiveText=this.element.querySelector("[role=status]"),this.keyboardDelegate=_(this.element.querySelector(".ML__keyboard-sink"),this.element,this),window.addEventListener("resize",this,{signal:p}),document.addEventListener("scroll",this,{signal:p}),this.resizeObserver=new ResizeObserver(()=>wn(this)),this.resizeObserver.observe(this.field),window.mathVirtualKeyboard.addEventListener("virtual-keyboard-toggle",this,{signal:p}),Pl&&!$.locale.startsWith(Pl.locale)&&nh($.locale),Vi!=="ready"&&document.fonts.ready.then(()=>Wo(this)),e.querySelector("[part=container]").style.removeProperty("visibility"),this.undoManager.startRecording(),this.undoManager.snapshot("set-value")}get defaultStyle(){return this._defaultStyle}set defaultStyle(e){this._defaultStyle=e}get effectiveStyle(){if(this.adoptStyle==="none")return this.defaultStyle;const e=this.model.at(this.model.position),i=this.adoptStyle==="right"?e.rightSibling:e;if(!i)return this.defaultStyle;if(i.type==="group"){const r=i.branch("body");return!r||r.length<2?{}:this.adoptStyle==="right"?r[1].computedStyle:r[r.length-1].computedStyle}return i.computedStyle}connectToVirtualKeyboard(){this.connectedToVirtualKeyboard||(this.connectedToVirtualKeyboard=!0,window.addEventListener("message",this,{signal:this.eventController.signal}),window.mathVirtualKeyboard.connect(),window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(Ba(this)),ed(this))}disconnectFromVirtualKeyboard(){this.connectedToVirtualKeyboard&&(window.removeEventListener("message",this),window.mathVirtualKeyboard.disconnect(),this.connectedToVirtualKeyboard=!1,x0())}showMenu(e){var i,r;const a=(r=(i=e==null?void 0:e.location)!=null?i:El(this.field))!=null?r:void 0,u=e==null?void 0:e.modifiers,p=this.element.querySelector("[part=container]");return this._menu.show({target:p,location:a,modifiers:u})}get colorMap(){return e=>{var i,r,a;return(a=(r=(i=this.options).colorMap)==null?void 0:r.call(i,e))!=null?a:Be(e)}}get backgroundColorMap(){return e=>{var i,r,a,u,p,g;return(g=(p=(r=(i=this.options).backgroundColorMap)==null?void 0:r.call(i,e))!=null?p:(u=(a=this.options).colorMap)==null?void 0:u.call(a,e))!=null?g:Dt(e)}}get smartFence(){var e;return(e=this.options.smartFence)!=null?e:!1}get readOnly(){var e;return(e=this.options.readOnly)!=null?e:!1}get disabled(){var e,i;return(i=(e=this.host)==null?void 0:e.disabled)!=null?i:!1}get contentEditable(){return this.host?this.host.getAttribute("contenteditable")!=="false":!1}get userSelect(){if(!this.host)return"";const e=getComputedStyle(this.host);return e.getPropertyValue("user-select")||e.getPropertyValue("-webkit-user-select")}get hasEditableContent(){return this.disabled||!this.contentEditable?!1:!this.readOnly||this.hasEditablePrompts}get hasEditablePrompts(){return this.readOnly&&!this.disabled&&this.contentEditable&&this.model.findAtom(e=>e.type==="prompt"&&!e.locked)!==void 0}get isSelectionEditable(){if(this.disabled||!this.contentEditable)return!1;if(!this.readOnly)return!0;const e=this.model.at(this.model.anchor),i=this.model.at(this.model.position),r=et.commonAncestor(e,i);return!!((r==null?void 0:r.type)==="prompt"||r!=null&&r.parentPrompt)}get letterShapeStyle(){var e;return(e=this.options.letterShapeStyle)!=null?e:"tex"}get minFontScale(){return this.options.minFontScale}get selectionStyle(){if(this.model.selectionIsCollapsed)return this.effectiveStyle;const e=this.model.getAtoms(this.model.selection);if(e.length===0)return{};const i=P({},e[0].style);for(const r of e)for(const[a,u]of Object.entries(r.style))i[a]!==u&&delete i[a];return i}queryStyle(e){const i=g0(this,e);"verbatimColor"in i&&delete i.verbatimColor,"verbatimBackgroundColor"in i&&delete i.verbatimBackgroundColor;const r=Object.keys(i).length;if(r===0)return"all";if(r>1){for(const w of Object.keys(i)){const E=this.queryStyle({[w]:i[w]});if(E==="none")return"none";if(E==="some")return"some"}return"all"}const a=Object.keys(i)[0],u=i[a];if(this.model.selectionIsCollapsed)return this.effectiveStyle[a]===u?"all":"none";const p=this.model.getAtoms(this.model.selection,{includeChildren:!0});let g=p.length;if(g===0)return"none";let b=0;for(const w of p){if(w.type==="first"){g-=1;continue}w.style[a]===u&&(b+=1)}return b===0?"none":b===g?"all":"some"}get keybindings(){var e,i;if(this._keybindings)return this._keybindings;const[r,a]=Q(this.options.keybindings,(e=Ol())!=null?e:Oa());return((i=Ol())==null?void 0:i.score)>0&&(this._keybindings=r,a.length>0&&console.error("MathLive 0.98.5: Invalid keybindings for current keyboard layout",a)),r}get menu(){return this._menu}setOptions(e){var i;this.options=P(P({},this.options),Uf(e)),this._keybindings=void 0,this.options.defaultMode==="inline-math"?this.element.classList.add("ML__is-inline"):this.element.classList.remove("ML__is-inline");let r=this.options.defaultMode;r==="inline-math"&&(r="math"),((i=this.model.root.firstChild)==null?void 0:i.mode)!==r&&(this.model.root.firstChild.mode=r),this.options.readOnly&&this.hasFocus()&&window.mathVirtualKeyboard.visible&&this.executeCommand("hideVirtualKeyboard");const a=et.serialize([this.model.root],{expandMacro:!1,defaultMode:this.options.defaultMode});("macros"in e||this.model.getValue()!==a)&&qn.insert(this.model,a,{insertionMode:"replaceAll",selectionMode:"after",format:"latex",silenceNotifications:!0,mode:"math"}),("value"in e||"macros"in e||"registers"in e||"colorMap"in e||"backgroundColorMap"in e||"letterShapeStyle"in e||"minFontScale"in e||"readOnly"in e||"placeholderSymbol"in e)&&wn(this)}getOptions(e){return $l(this.options,e)}getOption(e){return $l(this.options,e)}handleEvent(e){return el(this,null,function*(){var i;if(oo(this)){if(yo(e)){if(!Du(e.origin,(i=this.options.originValidator)!=null?i:"none"))throw new DOMException(`Message from unknown origin (${e.origin}) cannot be handled`,"SecurityError");const{action:r}=e.data;if(r==="execute-command"){const a=e.data.command;if(is(a)==="virtual-keyboard")return;this.executeCommand(a)}else r==="update-state"||(r==="focus"?this.focus({preventScroll:!0}):r==="blur"&&this.blur());return}switch(e.type){case"focus":this.onFocus();break;case"blur":this.onBlur();break;case"mousedown":this.userSelect!=="none"&&sp(this,e);break;case"pointerdown":this.userSelect!=="none"&&(sp(this,e),e.shiftKey===!1&&(yield yp(e,this.element.querySelector("[part=container]"),this._menu))&&Yf.stop());break;case"contextmenu":this.userSelect!=="none"&&e.shiftKey===!1&&(yield yp(e,this.element.querySelector("[part=container]"),this._menu))&&Yf.stop();break;case"virtual-keyboard-toggle":this.hasFocus()&&ed(this);break;case"resize":this.geometryChangeTimer&&cancelAnimationFrame(this.geometryChangeTimer),this.geometryChangeTimer=requestAnimationFrame(()=>oo(this)&&this.onGeometryChange());break;case"scroll":this.geometryChangeTimer&&cancelAnimationFrame(this.geometryChangeTimer),this.geometryChangeTimer=requestAnimationFrame(()=>oo(this)&&this.onGeometryChange());break;case"wheel":this.onWheel(e);break;default:console.warn("Unexpected event type",e.type)}}})}dispose(){if(!oo(this))return;$.unsubscribe(this._l10Subscription),this.keyboardDelegate.dispose(),this.keyboardDelegate=void 0,this.eventController.abort(),this.eventController=void 0,this.resizeObserver.disconnect(),window.mathVirtualKeyboard.removeEventListener("virtual-keyboard-toggle",this),this.disconnectFromVirtualKeyboard(),this.model.dispose();const e=this.element;delete e.mathfield,this.element=void 0,this.host=void 0,this.field=void 0,this.ariaLiveText=void 0,ng(),si(),Eg()}flushInlineShortcutBuffer(e){if(e!=null||(e={defer:!1}),!e.defer){this.inlineShortcutBuffer=[],clearTimeout(this.inlineShortcutBufferFlushTimer),this.inlineShortcutBufferFlushTimer=0;return}this.options.inlineShortcutTimeout>0&&(clearTimeout(this.inlineShortcutBufferFlushTimer),this.inlineShortcutBufferFlushTimer=setTimeout(()=>this.flushInlineShortcutBuffer(),this.options.inlineShortcutTimeout))}executeCommand(e){return is(e)==="virtual-keyboard"?(this.focus({preventScroll:!0}),window.mathVirtualKeyboard.executeCommand(e),requestAnimationFrame(()=>window.mathVirtualKeyboard.update(Ba(this))),!1):jo(this,e)}get errors(){return Ll(this.model.getValue(),{context:this.context})}getValue(e,i,r){return this.model.getValue(e,i,r)}setValue(e,i){var r;i=i!=null?i:{mode:"math"},i.insertionMode===void 0&&(i.insertionMode="replaceAll"),(i.format===void 0||i.format==="auto")&&(i.format="latex"),(i.mode===void 0||i.mode==="auto")&&(i.mode=(r=af(this.model,this.model.position))!=null?r:"math");const a=this.undoManager.canUndo();qn.insert(this.model,e,i)&&(wn(this),a||this.undoManager.reset(),this.undoManager.snapshot("set-value"))}get expression(){const e=window.MathfieldElement.computeEngine;return e?e.box(e.parse(this.model.getValue("latex-unstyled"))):(console.error("MathLive 0.98.5: no compute engine available. Make sure the Compute Engine library is loaded."),null)}scrollIntoView(){var e;if(!this.element)return;if(this.host){if(this.options.onScrollIntoView)this.options.onScrollIntoView(this);else if(this.host.scrollIntoView({block:"nearest",inline:"nearest"}),window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.container===window.document.body){const a=window.mathVirtualKeyboard.boundingRect,u=this.host.getBoundingClientRect();u.bottom>a.top&&((e=window.document.scrollingElement)==null||e.scrollBy(0,u.bottom-a.top+8))}}this.dirty&&pa(this,{interactive:!0});const i=this.field.getBoundingClientRect();let r=null;if(this.model.selectionIsCollapsed)r=El(this.field);else{const a=Kc(this);if(a.length>0){let u=-1/0,p=-1/0;for(const g of a)g.right>u&&(u=g.right),g.top<p&&(p=g.top);r={x:u+i.left-this.field.scrollLeft,y:p+i.top-this.field.scrollTop,height:0}}}if(this.host&&r){const a=this.host.getBoundingClientRect(),u=r.y;let p=this.host.scrollTop;u<a.top?p=u-a.top+this.host.scrollTop:u>a.bottom&&(p=u-a.bottom+this.host.scrollTop+r.height),this.host.scroll({top:p,left:0})}if(r){const a=r.x-window.scrollX;let u=this.field.scrollLeft;a<i.left?u=a-i.left+this.field.scrollLeft-20:a>i.right&&(u=a-i.right+this.field.scrollLeft+20),this.field.scroll({top:this.field.scrollTop,left:u})}}insert(e,i){return typeof e!="string"||e.length===0&&((i==null?void 0:i.insertionMode)==="insertBefore"||(i==null?void 0:i.insertionMode)==="insertAfter")||e.length===0&&this.model.selectionIsCollapsed?!1:(this.flushInlineShortcutBuffer(),i=i!=null?i:{mode:"math"},i.focus&&this.focus(),i.feedback&&(window.MathfieldElement.keypressVibration&&Y()&&navigator.vibrate(An),window.MathfieldElement.playSound("keypress")),e==="\\\\"?H0(this.model):e==="&"?W0(this.model):this.model.selectionIsCollapsed?qn.insert(this.model,e,P({style:this.model.at(this.model.position).computedStyle},i)):qn.insert(this.model,e,i),this.snapshot(`insert-${this.model.at(this.model.position).type}`),wn(this),i.scrollIntoView&&this.scrollIntoView(),!0)}switchMode(e,i="",r=""){var a;if(this.model.mode===e||!this.hasEditableContent||!this.contentEditable||this.disabled)return;const u=this.model.mode;if(this.model.mode=e,!((a=this.host)!=null&&a.dispatchEvent(new Event("mode-change",{bubbles:!0,composed:!0,cancelable:!0})))){this.model.mode=u;return}const p=this.model.mode,{model:g}=this;g.deferNotifications({content:!!r||!!i,selection:!0,type:"insertText"},()=>{let b=!1;if(this.flushInlineShortcutBuffer(),this.stopCoalescingUndo(),i&&e!=="latex"){const w=zr(i,{context:this.context,parseMode:e});g.collapseSelection("forward");const E=g.at(g.position);g.position=g.offsetOf(E.parent.addChildrenAfter(w,E)),b=!0}if(this.model.mode=e,e==="latex"){let w=g.selectionIsCollapsed;He(this,"accept");let E,R=g.at(g.position);if(w)E="\\";else{const Z=Fr(g.selection);E=this.model.getValue(Z,"latex");const ue=this.model.extractAtoms(Z);ue.length===1&&ue[0].type==="placeholder"&&(E=i,w=!0),R=g.at(Z[0])}const N=new Cl(E);R.parent.addChildAfter(N,R),w?g.position=g.offsetOf(N.lastChild):g.setSelection(g.offsetOf(N.firstChild),g.offsetOf(N.lastChild))}else Ee(g).forEach(w=>{w.isError=!1});if(r){const w=zr(r,{context:this.context,parseMode:p});g.collapseSelection("forward");const E=g.at(g.position);g.position=g.offsetOf(E.parent.addChildrenAfter(w,E)),b=!0}return wn(this),this.undoManager.snapshot(e==="latex"?"insert-latex":"insert"),b}),this.model.mode=e,window.mathVirtualKeyboard.update(Ba(this))}hasFocus(){return!this.blurred}focus(e){var i;this.hasFocus()||(this.keyboardDelegate.focus(),this.connectToVirtualKeyboard(),this.onFocus(),this.model.announce("line")),(i=e==null?void 0:e.preventScroll)!=null&&i||this.scrollIntoView()}blur(){this.disconnectFromVirtualKeyboard(),this.hasFocus()&&this.keyboardDelegate.blur()}select(){this.model.selection={ranges:[[0,this.model.lastOffset]]},this.focus()}applyStyle(e,i={}){var r,a;const u={operation:"set",silenceNotifications:!1};Fc(i)?u.range=i:(i.operation==="toggle"&&(u.operation="toggle"),u.range=i.range,u.silenceNotifications=(r=i.silenceNotifications)!=null?r:!1);const p=g0(this,e),g=(a=u.operation)!=null?a:"set";if(u.range===void 0&&this.model.selectionIsCollapsed){if(g==="set"){this.defaultStyle=P(P({},this.defaultStyle),p);return}const b=P({},this.defaultStyle);for(const w of Object.keys(p))b[w]===p[w]?(w==="color"&&delete b.verbatimColor,w==="backgroundColor"&&delete b.verbatimBackgroundColor,delete b[w]):b[w]=p[w];this.defaultStyle=b;return}this.model.deferNotifications({content:!u.silenceNotifications,type:"insertText"},()=>{if(u.range===void 0)for(const b of this.model.selection.ranges)l0(this.model,b,p,{operation:g});else l0(this.model,u.range,p,{operation:g})}),wn(this)}toggleContextMenu(){var e;return this._menu.visible?this._menu.state==="open"?(this._menu.hide(),!0):(this._menu.show({target:this.element.querySelector("[part=container]"),location:(e=this.getCaretPoint())!=null?e:void 0,onDismiss:()=>{var i;return(i=this.element)==null?void 0:i.focus()}}),!0):!1}getCaretPoint(){const e=El(this.field);return e?{x:e.x,y:e.y}:null}setCaretPoint(e,i){const r=uh(this,e,i,{bias:0});if(r<0)return!1;const a=this.model.position;return this.model.position=r,this.model.announce("move",a),wn(this),!0}getPrompt(e){const i=this.model.findAtom(r=>r.type==="prompt"&&r.placeholderId===e);return console.assert(i!==void 0,"MathLive 0.98.5: no prompts with matching ID found"),i}getPromptValue(e,i){const r=this.getPrompt(e);if(!r)return"";const a=this.model.offsetOf(r.firstChild),u=this.model.offsetOf(r.lastChild);return this.model.getValue(a,u,i)}getPrompts(e){return this.model.getAllAtoms().filter(i=>i.type!=="prompt"?!1:e?!(e.id&&i.placeholderId!==e.id||e.locked&&i.locked!==e.locked||e.correctness==="undefined"&&i.correctness||e.correctness&&i.correctness!==e.correctness):!0).map(i=>i.placeholderId)}setPromptValue(e,i,r){if(i!==void 0){const a=this.getPrompt(e);if(!a){console.error(`MathLive 0.98.5: unknown prompt ${e}`);return}const u=this.model.getBranchRange(this.model.offsetOf(a),"body");this.model.setSelection(u),this.insert(i,d(P({},r),{insertionMode:"replaceSelection"}))}r!=null&&r.silenceNotifications&&(this.valueOnFocus=this.getValue()),wn(this)}setPromptState(e,i,r){const a=this.getPrompt(e);if(!a){console.error(`MathLive 0.98.5: unknown prompt ${e}`);return}i==="undefined"?a.correctness=void 0:typeof i=="string"&&(a.correctness=i),typeof r=="boolean"&&(a.locked=r,a.captureSelection=r),wn(this)}getPromptState(e){const i=this.getPrompt(e);return i?[i.correctness,i.locked]:(console.error(`MathLive 0.98.5: unknown prompt ${e}`),[void 0,!0])}getPromptRange(e){const i=this.getPrompt(e);return i?this.model.getBranchRange(this.model.offsetOf(i),"body"):(console.error(`MathLive 0.98.5: unknown prompt ${e}`),[0,0])}canUndo(){return this.undoManager.canUndo()}canRedo(){return this.undoManager.canRedo()}popUndoStack(){this.undoManager.pop()}snapshot(e){var i;this.undoManager.snapshot(e)&&(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(Ba(this)),(i=this.host)==null||i.dispatchEvent(new CustomEvent("undo-state-change",{bubbles:!0,composed:!0,detail:{type:"snapshot"}})))}stopCoalescingUndo(){this.undoManager.stopCoalescing(this.model.selection)}stopRecording(){this.undoManager.stopRecording()}startRecording(){this.undoManager.startRecording()}undo(){var e;this.undoManager.undo()&&(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(Ba(this)),(e=this.host)==null||e.dispatchEvent(new CustomEvent("undo-state-change",{bubbles:!0,composed:!0,detail:{type:"undo"}})))}redo(){var e;this.undoManager.redo()&&(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(Ba(this)),(e=this.host)==null||e.dispatchEvent(new CustomEvent("undo-state-change",{bubbles:!0,composed:!0,detail:{type:"undo"}})))}resetUndo(){var e;(e=this.undoManager)==null||e.reset()}onSelectionDidChange(){var e,i;const r=this.model;this.keyboardDelegate.setValue(r.getValue(this.model.selection,"latex-expanded"));{const a=r.at(r.position),u=(e=a.mode)!=null?e:G0(this.options);this.model.mode!==u&&(this.model.mode==="latex"?(He(this,"accept",{mode:u}),r.position=r.offsetOf(a)):this.switchMode(u))}(i=this.host)==null||i.dispatchEvent(new Event("selection-change",{bubbles:!0,composed:!0})),window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(Ba(this)),ed(this)}onContentWillChange(e){var i,r,a;return(a=(r=this.host)==null?void 0:r.dispatchEvent(new InputEvent("beforeinput",d(P({},e),{data:e.data?e.data:(i=e.inputType)!=null?i:"",cancelable:!0,bubbles:!0,composed:!0}))))!=null?a:!0}onFocus(){this.focusBlurInProgress||!this.blurred||(this.focusBlurInProgress=!0,this.blurred=!1,this.keyboardDelegate.focus(),this.stopCoalescingUndo(),pa(this,{interactive:!0}),this.valueOnFocus=this.model.getValue(),this.hasEditablePrompts&&!this.model.at(this.model.anchor).parentPrompt&&this.executeCommand("moveToNextPlaceholder"),this.focusBlurInProgress=!1)}onBlur(){var e,i,r;if(this.focusBlurInProgress||this.blurred)return;this.focusBlurInProgress=!0,this.stopCoalescingUndo(),this.blurred=!0,this.ariaLiveText.textContent="",Vt(this),this.model.getValue()!==this.valueOnFocus&&((e=this.host)==null||e.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))),this.disconnectFromVirtualKeyboard(),(i=this.host)==null||i.dispatchEvent(new Event("blur",{bubbles:!1,composed:!0})),(r=this.host)==null||r.dispatchEvent(new UIEvent("focusout",{bubbles:!0,composed:!0})),wn(this),this.focusBlurInProgress=!1,x0();const a=new AbortController,u=a.signal;document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&document.addEventListener("visibilitychange",()=>{oo(this)&&document.visibilityState==="visible"&&this.focus({preventScroll:!0})},{once:!0,signal:u})},{once:!0,signal:u}),setTimeout(()=>a.abort(),100)}onInput(e){d0(this,e)}onKeystroke(e){return ip(this,e)}onCompositionStart(e){this.model.deleteAtoms(Fr(this.model.selection));const i=El(this.field);i&&requestAnimationFrame(()=>{pa(this),this.keyboardDelegate.moveTo(i.x,i.y-i.height)})}onCompositionUpdate(e){Bm(this.model,e),wn(this)}onCompositionEnd(e){Nm(this.model),d0(this,e,{simulateKeystroke:!0})}onCut(e){if(!this.isSelectionEditable){this.model.announce("plonk");return}this.model.contentWillChange({inputType:"deleteByCut"})&&(this.stopCoalescingUndo(),qn.onCopy(this,e),$a(this.model,Fr(this.model.selection),"deleteByCut"),this.snapshot("cut"),wn(this))}onCopy(e){qn.onCopy(this,e)}onPaste(e){let i=this.isSelectionEditable;return i&&(i=qn.onPaste(this.model.at(this.model.position).mode,this,e.clipboardData)),i||this.model.announce("plonk"),e.preventDefault(),e.stopPropagation(),i}onGeometryChange(){this._menu.hide(),li(this),ed(this)}onWheel(e){const i=5*e.deltaX;if(!Number.isFinite(i)||i===0)return;const r=this.field;i<0&&r.scrollLeft===0||i>0&&r.offsetWidth+r.scrollLeft>=r.scrollWidth||(r.scrollBy({top:0,left:i}),e.preventDefault(),e.stopPropagation())}getHTMLElement(e){let i=e;for(;!i.id&&i.hasChildren;)i=e.children[0];return this.field.querySelector(`[data-atom-id="${i.id}"]`)}get context(){var e,i;return{registers:(e=this.options.registers)!=null?e:{},smartFence:this.smartFence,letterShapeStyle:this.letterShapeStyle,minFontScale:this.minFontScale,placeholderSymbol:(i=this.options.placeholderSymbol)!=null?i:"\u25A2",colorMap:r=>this.colorMap(r),backgroundColorMap:r=>this.backgroundColorMap(r),getMacro:r=>tt(r,this.options.macros),atomIdsSettings:{seed:"random",groupNumbers:!1}}}};function Mp(e){if(e&&(e.classList.remove("ML__highlight"),e.children))for(const i of e.children)Mp(i)}function F0(e,i){var r;e&&(!i||((r=e.dataset)==null?void 0:r.atomId)===i?(e.classList.add("ML__highlight"),e.children&&e.children.length>0&&[...e.children].forEach(a=>{a instanceof HTMLElement&&F0(a)})):(e.classList.remove("ML__highlight"),e.children&&e.children.length>0&&[...e.children].forEach(a=>{a instanceof HTMLElement&&F0(a,i)})))}function w1(e,i){var r;if(!M())return;if(window.MathfieldElement.speechEngine!=="amazon"){console.error("MathLive 0.98.5: Use Amazon TTS Engine for synchronized highlighting"),typeof window.MathfieldElement.speakHook=="function"&&window.MathfieldElement.speakHook(i);return}if(!window.AWS){console.error("MathLive 0.98.5: AWS SDK not loaded. See https://www.npmjs.com/package/aws-sdk");return}const a=new window.AWS.Polly({apiVersion:"2016-06-10"}),u={OutputFormat:"json",VoiceId:(r=window.MathfieldElement.speechEngineVoice)!=null?r:"Joanna",Engine:"standard",Text:i,TextType:"ssml",SpeechMarkTypes:["ssml"]};Qo().readAloudElement=e,a.synthesizeSpeech(u,(p,g)=>{if(p){console.trace(`MathLive 0.98.5: \`polly.synthesizeSpeech()\` error: ${p}`);return}if(!(g!=null&&g.AudioStream)){console.log("polly.synthesizeSpeech():",g);return}const b=new TextDecoder("utf-8").decode(new Uint8Array(g.AudioStream));Qo().readAloudMarks=b.split(`
`).map(w=>w?JSON.parse(w):{}),Qo().readAloudTokens=[];for(const w of Qo().readAloudMarks)w.value&&Qo().readAloudTokens.push(w.value);Qo().readAloudCurrentMark="",u.OutputFormat="mp3",u.SpeechMarkTypes=[],a.synthesizeSpeech(u,(w,E)=>{if(w){console.trace(`MathLive 0.98.5: \`polly.synthesizeSpeech("${i}") error:${w}`);return}if(!(E!=null&&E.AudioStream))return;const R=new Uint8Array(E.AudioStream),N=new Blob([R.buffer],{type:"audio/mpeg"}),Z=URL.createObjectURL(N),ue=Qo();ue.readAloudAudio?ue.readAloudAudio.pause():(ue.readAloudAudio=new Audio,ue.readAloudAudio.addEventListener("ended",()=>{const me=ue.readAloudMathfield;ue.readAloudStatus="ended",document.body.dispatchEvent(new Event("read-aloud-status-change",{bubbles:!0,composed:!0})),me?(pa(me),ue.readAloudElement=null,ue.readAloudMathfield=null,ue.readAloudTokens=[],ue.readAloudMarks=[],ue.readAloudCurrentMark=""):Mp(ue.readAloudElement)}),ue.readAloudAudio.addEventListener("timeupdate",()=>{let me="";const Ve=ue.readAloudAudio.currentTime*1e3+100;for(const Ct of ue.readAloudMarks)Ct.time<Ve&&(me=Ct.value);ue.readAloudCurrentMark!==me&&(ue.readAloudCurrentToken=me,me&&me===ue.readAloudFinalToken?ue.readAloudAudio.pause():(ue.readAloudCurrentMark=me,F0(ue.readAloudElement,ue.readAloudCurrentMark)))})),ue.readAloudAudio.src=Z,ue.readAloudStatus="playing",document.body.dispatchEvent(new Event("read-aloud-status-change",{bubbles:!0,composed:!0})),ue.readAloudAudio.play()})})}M()||console.error('MathLive 0.98.5: this version of the MathLive library is for use in the browser. A subset of the API is available on the server side in the "mathlive-ssr" library. If using server side rendering (with React for example) you may want to do a dynamic import of the MathLive library inside a `useEffect()` call.');var gn=new WeakMap,S1=.5,Jo={letterShapeStyle:"mf.letterShapeStyle = ...",horizontalSpacingScale:'Removed. Use `"thinmuskip"`, `"medmuskip"`, and `"thickmuskip"` registers ',macros:"mf.macros = ...",registers:"mf.registers = ...",backgroundColorMap:"mf.backgroundColorMap = ...",colorMap:"mf.colorMap = ...",enablePopover:"mf.popoverPolicy = ...",mathModeSpace:"mf.mathModeSpace = ...",placeholderSymbol:"mf.placeholderSymbol = ...",readOnly:"mf.readOnly = ...",removeExtraneousParentheses:"mf.removeExtraneousParentheses = ...",scriptDepth:"mf.scriptDepth = ...",smartFence:"mf.smartFence = ...",smartMode:"mf.smartMode = ...",smartSuperscript:"mf.smartSuperscript = ...",inlineShortcutTimeout:"mf.inlineShortcutTimeout = ...",inlineShortcuts:"mf.inlineShortcuts = ...",keybindings:"mf.keybindings = ...",virtualKeyboardMode:"mf.mathVirtualKeyboardPolicy = ...",customVirtualKeyboardLayers:"mathVirtualKeyboard.layers = ...",customVirtualKeyboards:"mathVirtualKeyboard.layouts = ...",keypressSound:"mathVirtualKeyboard.keypressSound = ...",keypressVibration:"mathVirtualKeyboard.keypressVibration = ...",plonkSound:"mathVirtualKeyboard.plonkSound = ...",virtualKeyboardContainer:"mathVirtualKeyboard.container = ...",virtualKeyboardLayout:"mathVirtualKeyboard.alphabeticLayout = ...",virtualKeyboardTheme:"No longer supported",virtualKeyboardToggleGlyph:"No longer supported",virtualKeyboardToolbar:"mathVirtualKeyboard.editToolbar = ...",virtualKeyboards:"Use `mathVirtualKeyboard.layouts`",speechEngine:"`MathfieldElement.speechEngine`",speechEngineRate:"`MathfieldElement.speechEngineRate`",speechEngineVoice:"`MathfieldElement.speechEngineVoice`",textToSpeechMarkup:"`MathfieldElement.textToSpeechMarkup`",textToSpeechRules:"`MathfieldElement.textToSpeechRules`",textToSpeechRulesOptions:"`MathfieldElement.textToSpeechRulesOptions`",readAloudHook:"`MathfieldElement.readAloudHook`",speakHook:"`MathfieldElement.speakHook`",computeEngine:"`MathfieldElement.computeEngine`",fontsDirectory:"`MathfieldElement.fontsDirectory`",soundsDirectory:"`MathfieldElement.soundsDirectory`",createHTML:"`MathfieldElement.createHTML`",onExport:"`MathfieldElement.onExport`",onInlineShortcut:"`MathfieldElement.onInlineShortcut`",onScrollIntoView:"`MathfieldElement.onScrollIntoView`",locale:"MathfieldElement.locale = ...",strings:"MathfieldElement.strings = ...",decimalSeparator:"MathfieldElement.decimalSeparator = ...",fractionNavigationOrder:"MathfieldElement.fractionNavigationOrder = ..."},Zr=class jl extends HTMLElement{static get formAssociated(){return rc()}static get optionsAttributes(){return{"default-mode":"string","letter-shape-style":"string","min-font-scale":"number","popover-policy":"string","math-mode-space":"string","read-only":"boolean","remove-extraneous-parentheses":"on/off","smart-fence":"on/off","smart-mode":"on/off","smart-superscript":"on/off","inline-shortcut-timeout":"string","script-depth":"string",placeholder:"string","virtual-keyboard-target-origin":"string","math-virtual-keyboard-policy":"string"}}static get observedAttributes(){return[...Object.keys(this.optionsAttributes),"contenteditable","disabled","readonly","read-only"]}static get fontsDirectory(){return this._fontsDirectory}static set fontsDirectory(i){i!==this._fontsDirectory&&(this._fontsDirectory=i,ts())}get fontsDirectory(){throw new Error("Use MathfieldElement.fontsDirectory instead")}set fontsDirectory(i){throw new Error("Use MathfieldElement.fontsDirectory instead")}static get soundsDirectory(){return this._soundsDirectory}static set soundsDirectory(i){this._soundsDirectory=i,this.audioBuffers={}}get soundsDirectory(){throw new Error("Use MathfieldElement.soundsDirectory instead")}set soundsDirectory(i){throw new Error("Use MathfieldElement.soundsDirectory instead")}static get keypressSound(){return this._keypressSound}static set keypressSound(i){var r,a,u;this.audioBuffers={},i===null?this._keypressSound={spacebar:null,return:null,delete:null,default:null}:typeof i=="string"?this._keypressSound={spacebar:i,return:i,delete:i,default:i}:typeof i=="object"&&"default"in i&&(this._keypressSound={spacebar:(r=i.spacebar)!=null?r:i.default,return:(a=i.return)!=null?a:i.default,delete:(u=i.delete)!=null?u:i.default,default:i.default})}static get plonkSound(){return this._plonkSound}static set plonkSound(i){this.audioBuffers={},this._plonkSound=i}static get audioContext(){return this._audioContext||(this._audioContext=new AudioContext),this._audioContext}static get speechEngine(){return this._speechEngine}static set speechEngine(i){this._speechEngine=i}static get speechEngineRate(){return this._speechEngineRate}static set speechEngineRate(i){this._speechEngineRate=i}static get speechEngineVoice(){return this._speechEngineVoice}static set speechEngineVoice(i){this._speechEngineVoice=i}static get textToSpeechMarkup(){return this._textToSpeechMarkup}static set textToSpeechMarkup(i){this._textToSpeechMarkup=i}static get textToSpeechRules(){return this._textToSpeechRules}static set textToSpeechRules(i){this._textToSpeechRules=i}static get textToSpeechRulesOptions(){return this._textToSpeechRulesOptions}static set textToSpeechRulesOptions(i){this._textToSpeechRulesOptions=i}static get locale(){return $.locale}static set locale(i){i==="auto"&&(i=navigator.language.slice(0,5)),$.locale=i}get locale(){throw new Error("Use MathfieldElement.locale instead")}set locale(i){throw new Error("Use MathfieldElement.locale instead")}static get strings(){return $.strings}static set strings(i){$.merge(i)}get strings(){throw new Error("Use MathfieldElement.strings instead")}set strings(i){throw new Error("Use MathfieldElement.strings instead")}static get decimalSeparator(){return this._decimalSeparator}static set decimalSeparator(i){this._decimalSeparator=i,this._computeEngine&&(this._computeEngine.latexOptions.decimalMarker=this.decimalSeparator===","?"{,}":".")}get decimalSeparator(){throw new Error("Use MathfieldElement.decimalSeparator instead")}set decimalSeparator(i){throw new Error("Use MathfieldElement.decimalSeparator instead")}static get computeEngine(){var i,r;if(this._computeEngine===void 0){const a=(i=window[Symbol.for("io.cortexjs.compute-engine")])==null?void 0:i.ComputeEngine;if(!a)return null;this._computeEngine=new a,this._computeEngine&&this.decimalSeparator===","&&(this._computeEngine.latexOptions.decimalMarker="{,}")}return(r=this._computeEngine)!=null?r:null}static set computeEngine(i){this._computeEngine=i}get computeEngine(){throw new Error("Use MathfieldElement.computeEngine instead")}set computeEngine(i){throw new Error("Use MathfieldElement.computeEngine instead")}static get isFunction(){return typeof this._isFunction!="function"?()=>!1:this._isFunction}static set isFunction(i){this._isFunction=i}static loadSound(i){return el(this,null,function*(){delete this.audioBuffers[i];let r="";switch(i){case"keypress":r=this._keypressSound.default;break;case"return":r=this._keypressSound.return;break;case"spacebar":r=this._keypressSound.spacebar;break;case"delete":r=this._keypressSound.delete;break;case"plonk":r=this.plonkSound;break}if(typeof r!="string")return;r=r.trim();const a=this.soundsDirectory;if(!(a==null||a==="null"||r==="none"||r==="null"))try{const p=yield(yield fetch(yield In(`${a}/${r}`))).arrayBuffer(),g=yield this.audioContext.decodeAudioData(p);this.audioBuffers[i]=g}catch(u){}})}static playSound(i){return el(this,null,function*(){if((this.audioContext.state==="suspended"||this.audioContext.state==="interrupted")&&(yield this.audioContext.resume()),this.audioBuffers[i]||(yield this.loadSound(i)),!this.audioBuffers[i])return;const r=this.audioContext.createBufferSource();r.buffer=this.audioBuffers[i];const a=this.audioContext.createGain();a.gain.value=S1,r.connect(a).connect(this.audioContext.destination),r.start()})}constructor(i){if(super(),i){const r=[];for(const a of Object.keys(i))if(Jo[a])if(Jo[a].startsWith("mf."))if(Jo[a].startsWith(`mf.${a}`))r.push(`Option \`${a}\` cannot be used as a constructor option. Use ${Jo[a]}`);else{const u=Jo[a].match(/([a-zA-Z]+) =/);r.push(`Option \`${a}\` has been renamed \`${u[1]}\``)}else r.push(`Option \`${a}\` cannot be used as a constructor option. Use ${Jo[a]}`);if(r.length>0){console.group("%cMathLive 0.98.5: %cInvalid Options","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem"),console.warn("Some of the options passed to `new MathfieldElement(...)` are invalid. \n See https://cortexjs.io/mathlive/changelog/ for details.");for(const a of r)console.warn(a);console.groupEnd()}}if(rc()&&(this._internals=this.attachInternals(),this._internals.role="math",this._internals.ariaLabel="math input field",this._internals.ariaMultiLine="false"),this.attachShadow({mode:"open",delegatesFocus:!0}),this.shadowRoot&&"adoptedStyleSheets"in this.shadowRoot){this.shadowRoot.adoptedStyleSheets=[Ko("core"),Ko("mathfield"),Ko("mathfield-element"),Ko("ui"),Ko("menu")],this.shadowRoot.appendChild(document.createElement("span"));const r=document.createElement("slot");r.style.display="none",this.shadowRoot.appendChild(r)}else this.shadowRoot.innerHTML="<style>"+uo("core")+uo("mathfield")+uo("mathfield-element")+uo("ui")+uo("menu")+'</style><span></span><slot style="display:none"></slot>';i&&this._setOptions(i),this.shadowRoot.addEventListener("slotchange",()=>{var r;const a=this.shadowRoot.querySelector("slot:not([name])");this.value=(r=a==null?void 0:a.assignedNodes().map(u=>u.nodeType===3?u.textContent:"").join("").trim())!=null?r:""})}showMenu(i){var r,a;return(a=(r=this._mathfield)==null?void 0:r.showMenu(i))!=null?a:!1}get mathVirtualKeyboard(){throw new Error("The `mathVirtualKeyboard` property is not available on the MathfieldElement. Use `window.mathVirtualKeyboard` instead.")}onPointerDown(){window.addEventListener("pointerup",i=>{var r;i.target===this&&!((r=this._mathfield)!=null&&r.disabled)&&this.dispatchEvent(new MouseEvent("click",{altKey:i.altKey,button:i.button,buttons:i.buttons,clientX:i.clientX,clientY:i.clientY,ctrlKey:i.ctrlKey,metaKey:i.metaKey,movementX:i.movementX,movementY:i.movementY,relatedTarget:i.relatedTarget,screenX:i.screenX,screenY:i.screenY,shiftKey:i.shiftKey}))},{once:!0})}getPromptValue(i,r){var a,u;return(u=(a=this._mathfield)==null?void 0:a.getPromptValue(i,r))!=null?u:""}setPromptValue(i,r,a){var u;(u=this._mathfield)==null||u.setPromptValue(i,r,a)}getPromptRange(i){var r,a;return(a=(r=this._mathfield)==null?void 0:r.getPromptRange(i))!=null?a:null}getPrompts(i){var r,a;return(a=(r=this._mathfield)==null?void 0:r.getPrompts(i))!=null?a:[]}get form(){var i;return(i=this._internals)==null?void 0:i.form}get name(){var i;return(i=this.getAttribute("name"))!=null?i:""}get type(){return this.localName}get mode(){var i,r;return(r=(i=this._mathfield)==null?void 0:i.model.mode)!=null?r:this.defaultMode==="text"?"text":"math"}set mode(i){var r;(r=this._mathfield)==null||r.switchMode(i)}get expression(){if(this._mathfield)return window[Symbol.for("io.cortexjs.compute-engine")]?this._mathfield.expression:(console.error(`MathLive 0.98.5: The CortexJS Compute Engine library is not available.
Load the library, for example with:
import "https://unpkg.com/@cortex-js/compute-engine?module"`),null)}set expression(i){var r,a;if(!this._mathfield)return;const u=(a=(r=jl.computeEngine)==null?void 0:r.box(i).latex)!=null?a:null;u!==null&&this._mathfield.setValue(u),window[Symbol.for("io.cortexjs.compute-engine")]||console.error(`MathLive 0.98.5: The CortexJS Compute Engine library is not available.
Load the library, for example with:
import "https://unpkg.com/@cortex-js/compute-engine?module"`)}get errors(){var i,r;return(r=(i=this._mathfield)==null?void 0:i.errors)!=null?r:[]}_getOptions(i){return this._mathfield?$l(this._mathfield.options,i):gn.has(this)?P({},$l(P(P({},zf()),Uf(gn.get(this).options)),i)):null}getOptions(i){return console.warn("%cMathLive 0.98.5: %cDeprecated Usage%c\n `mf.getOptions()` is deprecated. Read the property directly on the mathfield instead.\n See https://cortexjs.io/mathlive/changelog/ for details.","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem","color: inherit, font-size: 1rem"),this._mathfield?$l(this._mathfield.options,i):gn.has(this)?$l(P(P({},zf()),Uf(gn.get(this).options)),i):null}reflectAttributes(){const i=zf(),r=this._getOptions();Object.keys(jl.optionsAttributes).forEach(a=>{const u=xo(a);jl.optionsAttributes[a]==="on/off"?i[u]!==r[u]?this.setAttribute(a,r[u]?"on":"off"):this.removeAttribute(a):i[u]!==r[u]&&(jl.optionsAttributes[a]==="boolean"?r[u]?this.setAttribute(a,""):this.removeAttribute(a):(typeof r[u]=="string"||typeof r[u]=="number")&&this.setAttribute(a,r[u].toString()))})}getOption(i){return console.warn("%cMathLive 0.98.5: %cDeprecated Usage%c\n `mf.getOption()` is deprecated. Read the property directly on the mathfield instead.\n See https://cortexjs.io/mathlive/changelog/ for details.","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem","color: inherit, font-size: 1rem"),this._getOptions([i])[i]}_getOption(i){return this._getOptions([i])[i]}_setOptions(i){if(this._mathfield)this._mathfield.setOptions(i);else if(gn.has(this)){const r=P(P({},gn.get(this).options),i);gn.set(this,d(P({},gn.get(this)),{selection:{ranges:r.readOnly?[[0,0]]:[[0,-1]]},options:r}))}else gn.set(this,{value:void 0,selection:{ranges:[[0,0]]},options:i,menuItems:void 0});this.reflectAttributes()}setOptions(i){console.group("%cMathLive 0.98.5: %cDeprecated Usage","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem"),console.warn(" `mf.setOptions()` is deprecated. Set the property directly on the mathfield instead.\n See https://cortexjs.io/mathlive/changelog/ for details.");for(const r of Object.keys(i))Jo[r]&&console.warn(`\`mf.setOptions({${r}:...})\` -> ${Jo[r]}`);console.groupEnd(),this._setOptions(i)}executeCommand(i){var r,a;return(a=(r=this._mathfield)==null?void 0:r.executeCommand(i))!=null?a:!1}getValue(i,r,a){var u,p;if(this._mathfield)return this._mathfield.model.getValue(i,r,a);if(gn.has(this)){let g,b,w;if(Au(i)?([g,b]=i.ranges[0],w=r):Fc(i)?([g,b]=i,w=r):zs(i)&&zs(r)?(g=i,b=r,w=a):(g=0,b=-1,w=i),(w===void 0||w==="latex")&&g===0&&b===-1)return(p=(u=gn.get(this).value)!=null?u:this.textContent)!=null?p:""}return""}setValue(i,r){if(this._mathfield&&i!==void 0){r!=null||(r={silenceNotifications:!0,mode:"math"}),this._mathfield.setValue(i,r);return}if(gn.has(this)){const u=gn.get(this).options;gn.set(this,{value:i,selection:{ranges:[[-1,-1]],direction:"forward"},options:u,menuItems:void 0});return}const a=gh(this);gn.set(this,{value:i,selection:{ranges:[[-1,-1]],direction:"forward"},options:a,menuItems:void 0})}hasFocus(){var i,r;return(r=(i=this._mathfield)==null?void 0:i.hasFocus())!=null?r:!1}focus(){var i;(i=this._mathfield)==null||i.focus()}blur(){var i;(i=this._mathfield)==null||i.blur()}select(){var i;(i=this._mathfield)==null||i.select()}insert(i,r){var a,u;return(u=(a=this._mathfield)==null?void 0:a.insert(i,r))!=null?u:!1}applyStyle(i,r){var a;return(a=this._mathfield)==null?void 0:a.applyStyle(i,r)}queryStyle(i){var r,a;return(a=(r=this._mathfield)==null?void 0:r.queryStyle(i))!=null?a:"none"}get caretPoint(){var i,r;return(r=(i=this._mathfield)==null?void 0:i.getCaretPoint())!=null?r:null}set caretPoint(i){var r;i&&((r=this._mathfield)==null||r.setCaretPoint(i.x,i.y))}setCaretPoint(i,r){var a,u;return(u=(a=this._mathfield)==null?void 0:a.setCaretPoint(i,r))!=null?u:!1}offsetFromPoint(i,r,a){return this._mathfield?uh(this._mathfield,i,r,a):-1}hitboxFromOffset(i){if(!this._mathfield)return null;const r=this._mathfield.model.at(i);if(!r)return null;const a=kl(this._mathfield,r);return a?new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top):null}resetUndo(){var i;(i=this._mathfield)==null||i.resetUndo()}canUndo(){return this._mathfield?this._mathfield.canUndo():!1}canRedo(){return this._mathfield?this._mathfield.canRedo():!1}handleEvent(i){var r,a,u,p;f.state==="closed"&&((a=(r=this._mathfield)==null?void 0:r.menu)==null?void 0:a.state)==="closed"&&(i.type==="pointerdown"&&this.onPointerDown(),i.type==="focus"&&((u=this._mathfield)==null||u.focus()),i.type==="blur"&&((p=this._mathfield)==null||p.blur()))}connectedCallback(){var i,r,a,u;const p=window.getComputedStyle(this),g=this.shadowRoot,b=p.userSelect!=="none";if(b)g.host.addEventListener("pointerdown",this,!0);else{const R=g.querySelector("span");R.style.pointerEvents="none"}g.host.addEventListener("focus",this,!0),g.host.addEventListener("blur",this,!0),rc()||(this.hasAttribute("role")||this.setAttribute("role","math"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","math input field"),this.setAttribute("aria-multiline","false")),b&&!this.hasAttribute("contenteditable")&&this.setAttribute("contenteditable","true"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0");const w=g.querySelector("slot:not([name])");if(w)try{this._style=w.assignedElements().filter(R=>R.tagName.toLowerCase()==="style").map(R=>R.textContent).join("")}catch(R){console.error(R)}if(this._style){const R=document.createElement("style");R.textContent=this._style,g.appendChild(R)}let E="";if(this.hasAttribute("value")?E=this.getAttribute("value"):E=(i=w==null?void 0:w.assignedNodes().map(R=>R.nodeType===3?R.textContent:"").join("").trim())!=null?i:"",this._mathfield=new x1(g.querySelector(":host > span"),d(P({},(a=(r=gn.get(this))==null?void 0:r.options)!=null?a:gh(this)),{eventSink:this,value:E})),!gn.has(this)){this.upgradeProperty("disabled"),this.upgradeProperty("readonly");for(const R of Object.keys(jl.optionsAttributes))this.upgradeProperty(xo(R))}if(!((u=this._mathfield)!=null&&u.model)){this._mathfield=null;return}if(gn.has(this)){const R=this._mathfield,N=gn.get(this),Z=N.menuItems;R.model.deferNotifications({content:!1,selection:!1},()=>{const ue=N.value;ue!==void 0&&R.setValue(ue),R.model.selection=N.selection,gn.delete(this)}),Z&&(this.menuItems=Z)}window.queueMicrotask(()=>{this.isConnected&&this.dispatchEvent(new Event("mount",{cancelable:!1,bubbles:!0,composed:!0}))}),Dr()}disconnectedCallback(){var i,r;if(this.shadowRoot.host.removeEventListener("pointerdown",this,!0),!this._mathfield)return;window.queueMicrotask(()=>this.dispatchEvent(new Event("unmount",{cancelable:!1,bubbles:!0,composed:!0})));const a=$l(this._mathfield.options,Object.keys(jl.optionsAttributes).map(u=>xo(u)));gn.set(this,{value:this._mathfield.getValue(),selection:this._mathfield.model.selection,menuItems:(r=(i=this._mathfield.menu)==null?void 0:i.menuItems)!=null?r:void 0,options:a}),this._mathfield.dispose(),this._mathfield=null}upgradeProperty(i){if(this.hasOwnProperty(i)){const r=this[i];delete this[i],(i==="readonly"||i==="read-only")&&(i="readOnly"),this[i]=r}}attributeChangedCallback(i,r,a){if(r===a)return;const u=a!==null;switch(i){case"contenteditable":wn(this._mathfield);break;case"disabled":this.disabled=u;break;case"read-only":case"readonly":this.readOnly=u;break;default:}}get readonly(){return this.hasAttribute("readonly")||this.hasAttribute("read-only")}set readonly(i){const r=!!i;r?(this.setAttribute("readonly",""),rc()?this._internals.ariaReadOnly="true":this.setAttribute("aria-readonly","true"),this.setAttribute("aria-readonly","true")):(rc()?this._internals.ariaReadOnly="false":this.removeAttribute("aria-readonly"),this.removeAttribute("readonly"),this.removeAttribute("read-only")),this._setOptions({readOnly:r})}get disabled(){return this.hasAttribute("disabled")}set disabled(i){var r;const a=!!i;a?this.setAttribute("disabled",""):this.removeAttribute("disabled"),rc()?this._internals.ariaDisabled=a?"true":"false":this.setAttribute("aria-disabled",a?"true":"false"),a&&((r=this._mathfield)!=null&&r.hasFocus)&&window.mathVirtualKeyboard.visible&&this._mathfield.executeCommand("hideVirtualKeyboard")}get value(){return this.getValue()}set value(i){this.setValue(i)}get defaultMode(){return this._getOption("defaultMode")}set defaultMode(i){this._setOptions({defaultMode:i})}get macros(){return this._getOption("macros")}set macros(i){this._setOptions({macros:i})}get registers(){const i=this;return new Proxy({},{get:(r,a)=>{if(typeof a=="string")return i._getOption("registers")[a]},set(r,a,u){return typeof a!="string"?!1:(i._setOptions({registers:d(P({},i._getOption("registers")),{[a]:u})}),!0)}})}set registers(i){this._setOptions({registers:i})}get colorMap(){return this._getOption("colorMap")}set colorMap(i){this._setOptions({colorMap:i})}get backgroundColorMap(){return this._getOption("backgroundColorMap")}set backgroundColorMap(i){this._setOptions({backgroundColorMap:i})}get letterShapeStyle(){return this._getOption("letterShapeStyle")}set letterShapeStyle(i){this._setOptions({letterShapeStyle:i})}get minFontScale(){return this._getOption("minFontScale")}set minFontScale(i){this._setOptions({minFontScale:i})}get smartMode(){return this._getOption("smartMode")}set smartMode(i){this._setOptions({smartMode:i})}get smartFence(){return this._getOption("smartFence")}set smartFence(i){this._setOptions({smartFence:i})}get smartSuperscript(){return this._getOption("smartSuperscript")}set smartSuperscript(i){this._setOptions({smartSuperscript:i})}get scriptDepth(){return this._getOption("scriptDepth")}set scriptDepth(i){this._setOptions({scriptDepth:i})}get removeExtraneousParentheses(){return this._getOption("removeExtraneousParentheses")}set removeExtraneousParentheses(i){this._setOptions({removeExtraneousParentheses:i})}get mathModeSpace(){return this._getOption("mathModeSpace")}set mathModeSpace(i){this._setOptions({mathModeSpace:i})}get placeholderSymbol(){return this._getOption("placeholderSymbol")}set placeholderSymbol(i){this._setOptions({placeholderSymbol:i})}get popoverPolicy(){return this._getOption("popoverPolicy")}set popoverPolicy(i){this._setOptions({popoverPolicy:i})}get environmentPopoverPolicy(){return this._getOption("environmentPopoverPolicy")}set environmentPopoverPolicy(i){this._setOptions({environmentPopoverPolicy:i})}get menuItems(){var i,r,a;return this._mathfield?(i=this._mathfield.menu._menuItems.map(u=>u.menuItem))!=null?i:[]:(a=(r=gn.get(this))==null?void 0:r.menuItems)!=null?a:[]}set menuItems(i){var r;if(this._mathfield){const a=(r=this._mathfield.element)==null?void 0:r.querySelector("[part=menu-toggle]");a&&(a.style.display=i.length===0?"none":""),this._mathfield.menu.menuItems=i}gn.has(this)?gn.set(this,d(P({},gn.get(this)),{menuItems:i})):gn.set(this,{value:void 0,selection:{ranges:[[0,0]]},options:gh(this),menuItems:i})}get mathVirtualKeyboardPolicy(){return this._getOption("mathVirtualKeyboardPolicy")}set mathVirtualKeyboardPolicy(i){this._setOptions({mathVirtualKeyboardPolicy:i})}get inlineShortcuts(){return this._getOption("inlineShortcuts")}set inlineShortcuts(i){this._setOptions({inlineShortcuts:i})}get inlineShortcutTimeout(){return this._getOption("inlineShortcutTimeout")}set inlineShortcutTimeout(i){this._setOptions({inlineShortcutTimeout:i})}get keybindings(){return this._getOption("keybindings")}set keybindings(i){this._setOptions({keybindings:i})}get onInlineShortcut(){return this._getOption("onInlineShortcut")}set onInlineShortcut(i){this._setOptions({onInlineShortcut:i})}get onScrollIntoView(){return this._getOption("onScrollIntoView")}set onScrollIntoView(i){this._setOptions({onScrollIntoView:i})}get onExport(){return this._getOption("onExport")}set onExport(i){this._setOptions({onExport:i})}get readOnly(){return this._getOption("readOnly")}set readOnly(i){this._setOptions({readOnly:i})}get isSelectionEditable(){var i,r;return(r=(i=this._mathfield)==null?void 0:i.isSelectionEditable)!=null?r:!1}setPromptState(i,r,a){var u;(u=this._mathfield)==null||u.setPromptState(i,r,a)}getPromptState(i){var r,a;return(a=(r=this._mathfield)==null?void 0:r.getPromptState(i))!=null?a:[void 0,!0]}get virtualKeyboardTargetOrigin(){return this._getOption("virtualKeyboardTargetOrigin")}set virtualKeyboardTargetOrigin(i){this._setOptions({virtualKeyboardTargetOrigin:i})}get selection(){return this._mathfield?this._mathfield.model.selection:gn.has(this)?gn.get(this).selection:{ranges:[[0,0]],direction:"forward"}}set selection(i){if(typeof i=="number"&&(i={ranges:[[i,i]]}),this._mathfield){this._mathfield.model.selection=i,wn(this._mathfield);return}if(gn.has(this)){gn.set(this,d(P({},gn.get(this)),{selection:i}));return}gn.set(this,{value:void 0,selection:i,options:gh(this),menuItems:void 0})}get selectionIsCollapsed(){const i=this.selection;return i.ranges.length===1&&i.ranges[0][0]===i.ranges[0][1]}get position(){return this._mathfield?this._mathfield.model.position:gn.has(this)?gn.get(this).selection.ranges[0][0]:0}set position(i){if(this._mathfield&&(this._mathfield.model.position=i,wn(this._mathfield)),gn.has(this)){gn.set(this,d(P({},gn.get(this)),{selection:{ranges:[[i,i]]}}));return}gn.set(this,{value:void 0,selection:{ranges:[[i,i]]},options:gh(this),menuItems:void 0})}getOffsetDepth(i){var r,a;return this._mathfield?((a=(r=this._mathfield.model.at(i))==null?void 0:r.treeDepth)!=null?a:2)-2:0}get lastOffset(){var i,r;return(r=(i=this._mathfield)==null?void 0:i.model.lastOffset)!=null?r:-1}};Zr.version="0.98.5",Zr._fontsDirectory="./fonts",Zr._soundsDirectory="./sounds",Zr.keypressVibration=!0,Zr._keypressSound={spacebar:"keypress-spacebar.wav",return:"keypress-return.wav",delete:"keypress-delete.wav",default:"keypress-standard.wav"},Zr._plonkSound="plonk.wav",Zr.audioBuffers={},Zr.createHTML=e=>e,Zr._speechEngineRate="100%",Zr._speechEngineVoice="Joanna",Zr._textToSpeechMarkup="",Zr._textToSpeechRules="mathlive",Zr._textToSpeechRulesOptions={},Zr.speakHook=f1,Zr.readAloudHook=w1,Zr._decimalSeparator=".",Zr.fractionNavigationOrder="numerator-denominator",Zr._isFunction=e=>{var i,r;const a=window.MathfieldElement.computeEngine;return(r=(i=a==null?void 0:a.parse(e).domain)==null?void 0:i.isFunction)!=null?r:!1};var mh=Zr;function xo(e){return e.replace(/[^a-zA-Z\d]+(.)/g,(i,r)=>r.toUpperCase())}function gh(e){const i={readOnly:!1},r=mh.optionsAttributes;return Object.keys(r).forEach(a=>{if(e.hasAttribute(a)){const u=e.getAttribute(a);a==="placeholder"?i.contentPlaceholder=u!=null?u:"":r[a]==="boolean"?i[xo(a)]=!0:r[a]==="on/off"?u==="on"?i[xo(a)]=!0:u==="off"?i[xo(a)]=!1:i[xo(a)]=void 0:r[a]==="number"?i[xo(a)]=Number.parseFloat(u!=null?u:"0"):i[xo(a)]=u}}),i}function rc(){return!(!("ElementInternals"in window)||!HTMLElement.prototype.attachInternals||!("role"in window.ElementInternals.prototype))}var Rp=mh,Ip,Pp,Op,Fp;if(M()&&!((Ip=window.customElements)!=null&&Ip.get("math-field"))){(Op=window[Pp=Symbol.for("io.cortexjs.mathlive")])!=null||(window[Pp]={});const e=window[Symbol.for("io.cortexjs.mathlive")];e.version="0.98.5",window.MathfieldElement=mh,(Fp=window.customElements)==null||Fp.define("math-field",mh)}function E1(e,i,r){let a=r,u=0;const p=e.length;for(;a<i.length;){const g=i[a];if(u<=0&&i.slice(a,a+p)===e)return a;g==="\\"?a++:g==="{"?u++:g==="}"&&u--,a++}return-1}function sd(e,i,r,a,u="latex"){const p=[];for(const g of e)if(g.type==="text"){const b=g.data;let w=!0,E=0,R;R=b.indexOf(i),R!==-1&&(E=R,E>0&&p.push({type:"text",data:b.slice(0,E)}),w=!1);let N=!1;for(;!N;){if(w){if(R=b.indexOf(i,E),R===-1){N=!0;break}E!==R&&p.push({type:"text",data:b.slice(E,R)}),E=R}else{if(R=E1(r,b,E+i.length),R===-1){N=!0;break}let Z=b.slice(E+i.length,R);u==="ascii-math"&&([,Z]=Lu(Z,{format:"ascii-math"})),p.push({type:"math",data:Z,rawData:b.slice(E,R+r.length),mathstyle:a}),E=R+r.length}w=!w}E<b.length&&p.push({type:"text",data:b.slice(E)})}else p.push(g);return p}function Bp(e,i,r){let a=[{type:"text",data:e}];return i!=null&&i.inline&&i.inline.forEach(([u,p])=>{a=sd(a,u,p,"textstyle")}),i!=null&&i.display&&i.display.forEach(([u,p])=>{a=sd(a,u,p,"displaystyle")}),r!=null&&r.inline&&r.inline.forEach(([u,p])=>{a=sd(a,u,p,"textstyle","ascii-math")}),r!=null&&r.display&&r.display.forEach(([u,p])=>{a=sd(a,u,p,"displaystyle","ascii-math")}),a}function k1(e,i){const r=document.createElement("span");r.setAttribute("translate","no");try{const a="<math xmlns='http://www.w3.org/1998/Math/MathML'>"+i.renderToMathML(e)+"</math>";r.innerHTML=window.MathfieldElement.createHTML(a)}catch(a){console.error(`MathLive 0.98.5: Could not convert "${e}"' to MathML with ${a}`),r.textContent=e}return r.className="ML__sr-only",r}function T1(e,i,r,a){try{const u=i.renderToMarkup(e,{mathstyle:r,format:"html"}),p=document.createElement("span");return p.dataset.latex=e,p.style.display=r==="displaystyle"?"flex":"inline-flex",p.setAttribute("aria-hidden","true"),p.setAttribute("translate","no"),p.innerHTML=window.MathfieldElement.createHTML(u),p}catch(u){if(console.error("Could not parse'"+e+"' with ",u),a)return document.createTextNode(e)}return null}function sc(e,i,r,a){var u;const p=T1(e,r,i||"textstyle",a),g=(u=r.renderAccessibleContent)!=null?u:"";if(p&&/\b(mathml|speakable-text)\b/i.test(g)){const b=document.createElement("span");if(/\bmathml\b/i.test(g)&&r.renderToMathML&&b.append(k1(e,r)),/\bspeakable-text\b/i.test(g)&&r.renderToSpeakableText){const w=document.createElement("span");w.setAttribute("translate","no");const E=r.renderToSpeakableText(e);w.innerHTML=window.MathfieldElement.createHTML(E),w.className="ML__sr-only",b.append(w)}return b.append(p),b}return p}function A1(e,i){var r,a,u;let p=null;if((r=i.TeX)!=null&&r.processEnvironments&&/^\s*\\begin/.test(e)){p=document.createDocumentFragment();const g=sc(e,"",i,!0);g&&p.appendChild(g)}else{if(!e.trim())return null;const g=Bp(e,(a=i.TeX)==null?void 0:a.delimiters,(u=i.asciiMath)==null?void 0:u.delimiters);if(g.length===1&&g[0].type==="text")return null;p=document.createDocumentFragment();for(const b of g)if(b.type==="text")p.appendChild(document.createTextNode(b.data));else{const w=sc(b.data,b.mathstyle==="textstyle"?"textstyle":"displaystyle",i,!0);w&&p.appendChild(w)}}return p}function Np(e,i){var r,a,u,p,g,b,w,E,R,N,Z,ue,me,Ve,Ct,Ue;if(e.childNodes.length===1&&e.childNodes[0].nodeType===3){const ct=(r=e.childNodes[0].textContent)!=null?r:"";if((a=i.TeX)!=null&&a.processEnvironments&&/^\s*\\begin/.test(ct)){e.textContent="";const yt=sc(ct,"",i,!0);yt&&e.append(yt);return}const It=Bp(ct,(u=i.TeX)==null?void 0:u.delimiters,(p=i.asciiMath)==null?void 0:p.delimiters);if(It.length===1&&It[0].type==="math"){e.textContent="";const yt=sc(It[0].data,It[0].mathstyle==="textstyle"?"textstyle":"displaystyle",i,!0);yt&&e.append(yt);return}if(It.length===1&&It[0].type==="text")return}for(let ct=e.childNodes.length-1;ct>=0;ct--){const It=e.childNodes[ct];if(It.nodeType===3){const yt=A1((g=It.textContent)!=null?g:"",i);yt&&(ct+=yt.childNodes.length-1,It.replaceWith(yt))}else if(It.nodeType===1){const yt=It,ei=It.nodeName.toLowerCase();if(ei==="script"){const hi=It;let ai;if((b=i.processScriptTypePattern)!=null&&b.test(hi.type))ai=(w=hi.textContent)!=null?w:"";else if((E=i.processMathJSONScriptTypePattern)!=null&&E.test(hi.type))try{ai=(N=i.serializeToLatex)==null?void 0:N.call(i,JSON.parse((R=hi.textContent)!=null?R:""))}catch(on){console.error(on)}if(ai){let on="textstyle";for(const Nt of hi.type.split(";")){const[Gs,Ka]=Nt.toLowerCase().split("=");Gs.trim()==="mode"&&(on=Ka.trim()==="display"?"displaystyle":"textstyle")}const Bn=sc(ai,on,i,!0);Bn&&hi.parentNode.replaceChild(Bn,hi)}}else if(((ue=(Z=i.processClassPattern)==null?void 0:Z.test(yt.className))!=null?ue:!1)||!((Ve=(me=i.skipTags)==null?void 0:me.includes(ei))!=null&&Ve||(Ue=(Ct=i.ignoreClassPattern)==null?void 0:Ct.test(yt.className))!=null&&Ue))if(e.childNodes.length===1&&e.childNodes[0].nodeType===3){const ai=e.textContent;e.textContent="";const on=sc(ai!=null?ai:"","displaystyle",i,!0);on&&e.append(on)}else Np(yt,i)}}}var L1={skipTags:["math-field","noscript","style","textarea","pre","code","annotation","annotation-xml"],processScriptType:"math/tex",processMathJSONScriptType:"math/json",ignoreClass:"tex2jax_ignore",processClass:"tex2jax_process",renderAccessibleContent:"mathml",asciiMath:{delimiters:{inline:[["`","`"]]}},TeX:{processEnvironments:!0,delimiters:{inline:[["\\(","\\)"]],display:[["$$","$$"],["\\[","\\]"]]}}};function D1(e,i){var r,a,u,p;try{const g=P(P({},L1),i);g.ignoreClassPattern=new RegExp((r=g.ignoreClass)!=null?r:""),g.processClassPattern=new RegExp((a=g.processClass)!=null?a:""),g.processScriptTypePattern=new RegExp((u=g.processScriptType)!=null?u:""),g.processMathJSONScriptTypePattern=new RegExp((p=g.processMathJSONScriptType)!=null?p:""),Dr(),ca("core"),Np(e,g)}catch(g){g instanceof Error?console.error("renderMathInElement(): "+g.message):console.error("renderMathInElement(): Could not render math for element",e)}}function C1(e,i){const r=Yo.singleton;return r?(r.show(),rh(),r.currentLayer=i,r.render(),r.focus(),!0):!1}function M1(){const e=window.mathVirtualKeyboard;return e.visible?e.hide({animate:!0}):e.show({animate:!0}),!1}ur({switchKeyboardLayer:C1,toggleVirtualKeyboard:M1,hideVirtualKeyboard:()=>(window.mathVirtualKeyboard.hide({animate:!0}),!1),showVirtualKeyboard:()=>(window.mathVirtualKeyboard.show({animate:!0}),!1)},{target:"virtual-keyboard"});function Qo(){var e,i;return(i=globalThis[e=Symbol.for("io.cortexjs.mathlive")])!=null||(globalThis[e]={}),globalThis[Symbol.for("io.cortexjs.mathlive")]}function B1(){return console.warn("%cMathLive 0.98.5: %cmakeSharedVirtualKeyboard() is deprecated. \n Use `window.mathVirtualKeyboard` to access the virtual keyboard instance.\n See https://cortexjs.io/mathlive/changelog/ for details.","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem"),window.mathVirtualKeyboard}function N1(e){I1(document.body,e)}function R1(e){if(typeof e=="string"){const i=document.getElementById(e);if(i===null)throw new Error(`The element with ID "${e}" could not be found.`);return i}return typeof e=="string"?null:e}function I1(e,i){var r,a,u,p;const g=R1(e);if(!g)return;const b=i!=null?i:{};(r=b.renderToMarkup)!=null||(b.renderToMarkup=Vr),(a=b.renderToMathML)!=null||(b.renderToMathML=Hg),(u=b.renderToSpeakableText)!=null||(b.renderToSpeakableText=Wg),(p=b.serializeToLatex)!=null||(b.serializeToLatex=jg),D1(g,b)}var $1={mathlive:"0.98.5"}}}]);
}());