UNPKG

mathjax

Version:

Beautiful and accessible math in all browsers. MathJax is an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all browsers. This package includes the packaged components (install mathjax-full to get the source

1 lines 56.7 kB
(()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var e={};t.r(e),t.d(e,{AbstractRegion:()=>M,DummyRegion:()=>N,HoverRegion:()=>I,LiveRegion:()=>T,SpeechRegion:()=>O,StringRegion:()=>E,ToolTip:()=>R});var i={};t.r(i),t.d(i,{AbstractExplorer:()=>L});var s={};t.r(s),t.d(s,{SpeechExplorer:()=>K,hasModifiers:()=>F,isContainer:()=>J});var o={};t.r(o),t.d(o,{AbstractMouseExplorer:()=>q,ContentHoverer:()=>W,FlameHoverer:()=>Y,Hoverer:()=>X,ValueHoverer:()=>z});var r={};t.r(r),t.d(r,{AbstractTreeExplorer:()=>G,ContrastPicker:()=>tt,FlameColorer:()=>Q,TreeColorer:()=>Z});var n={};t.r(n),t.d(n,{ATTR:()=>st,getHighlighter:()=>at});var a={};t.r(a),t.d(a,{ExplorerPool:()=>ut,RegionPool:()=>lt});var h={};t.r(h),t.d(h,{ExplorerHandler:()=>mt,ExplorerMathDocumentMixin:()=>gt,ExplorerMathItemMixin:()=>pt,setA11yOption:()=>ft,setA11yOptions:()=>bt});const l=("undefined"!=typeof window?window:t.g).MathJax._.components.global,c=(l.GLOBAL,l.isObject,l.combineConfig,l.combineDefaults,l.combineWithMathJax),u=(l.MathJax,MathJax._.core.MathItem),d=(u.protoItem,u.AbstractMathItem,u.STATE),p=u.newState,g=MathJax._.a11y.speech_ts,m=(g.SpeechMathItemMixin,g.SpeechMathDocumentMixin,g.SpeechHandler),b=MathJax._.util.Options,f=(b.isObject,b.APPEND,b.REMOVE,b.OPTIONS,b.Expandable,b.expandable),x=(b.makeArray,b.keys,b.copy,b.insert,b.defaultOptions,b.userOptions,b.selectOptions,b.selectOptionsFromKeys,b.separateOptions,b.lookup,MathJax._.core.MmlTree.SerializedMmlVisitor.SerializedMmlVisitor),v=MathJax._.util.context,y=v.hasWindow,A=v.context,S=MathJax._.util.StyleJson.StyleJsonSheet,k=MathJax._.a11y.speech.SpeechUtil,w=(k.ssmlParsing,k.buildLabel,k.buildSpeech),j=k.honk,C=(k.InPlace,k.SemAttr);class M{constructor(t){this.document=t,this.CLASS=this.constructor,this.AddStyles()}static get sheetId(){return"MJX-"+this.name+"-styles"}static get styleSheet(){return document.head.querySelector("#"+this.sheetId)}AddStyles(){const t=this.CLASS.sheetId;if(!this.CLASS.style||this.document.adaptor.head().querySelector("#"+t))return;const e=this.document.adaptor.node("style",{id:t});e.innerHTML=this.CLASS.style.cssText,this.document.adaptor.head().appendChild(e)}AddElement(){if(this.div)return;const t=this.document.adaptor.node("div");t.classList.add(this.CLASS.className),this.div=t,this.inner=this.document.adaptor.node("div"),this.div.appendChild(this.inner),this.document.adaptor.body(this.document.adaptor.document).appendChild(this.div)}Show(t){this.AddElement(),this.position(t),this.div.classList.add(this.CLASS.className+"_Show")}Hide(){this.div&&(this.div.remove(),this.div=null,this.inner=null)}stackRegions(t){const e=t.getBoundingClientRect();let i=0,s=Number.POSITIVE_INFINITY;const o=this.document.adaptor.document.getElementsByClassName(this.CLASS.className+"_Show");for(let t,e=0;t=o[e];e++)t!==this.div&&(i=Math.max(t.getBoundingClientRect().bottom,i),s=Math.min(t.getBoundingClientRect().left,s));const r=(i||e.bottom+10)+window.scrollY,n=(s<Number.POSITIVE_INFINITY?s:e.left)+window.scrollX;this.div.style.top=r+"px",this.div.style.left=n+"px"}}class N extends M{Clear(){}Update(){}Hide(){}Show(){}AddElement(){}AddStyles(){}position(){}}class E extends M{Clear(){this.div&&(this.Update(""),this.inner.style.top="",this.inner.style.backgroundColor="")}Update(t){t&&this.AddElement(),this.inner&&(this.inner.textContent="",this.inner.textContent=t||"\xa0")}position(t){this.stackRegions(t)}}class R extends E{}R.className="MJX_ToolTip",R.style=new S({[`.${R.className}`]:{width:"auto",height:"auto",opacity:1,"text-align":"center","border-radius":"4px",padding:0,"border-bottom":"1px dotted black",position:"absolute",display:"inline-block","background-color":"white","z-index":202},[`.${R.className} > div`]:{"border-radius":"inherit",padding:"0 2px"},"@media (prefers-color-scheme: dark)":{["."+R.className]:{"background-color":"#222025","box-shadow":"0px 5px 20px #000",border:"1px solid #7C7C7C"}}});class T extends E{static setColor(t,e,i,s){const o=this.styleSheet;if(o){const r=o.sheet.cssRules[0].style,n=`--mjx-${t}${e}-color`,a=`rgba(var(--mjx-${t}-${i}), ${1===s?1:`var(--mjx-${t}${e}-alpha)`})`;r.getPropertyValue(n)!==a&&r.setProperty(n,a);const h=`--mjx-${t}${e}-alpha`;r.getPropertyValue(h)!==String(s)&&(r.setProperty(h,s),o.sheet.cssRules[1].cssRules[0].style.setProperty(h,Math.pow(s,.7071)))}}}T.className="MJX_LiveRegion",T.priority={primary:1,secondary:2},T.style=new S({":root":{"--mjx-fg-red":"255, 0, 0","--mjx-fg-green":"0, 255, 0","--mjx-fg-blue":"0, 0, 255","--mjx-fg-yellow":"255, 255, 0","--mjx-fg-cyan":"0, 255, 255","--mjx-fg-magenta":"255, 0, 255","--mjx-fg-white":"255, 255, 255","--mjx-fg-black":"0, 0, 0","--mjx-bg-red":"255, 0, 0","--mjx-bg-green":"0, 255, 0","--mjx-bg-blue":"0, 0, 255","--mjx-bg-yellow":"255, 255, 0","--mjx-bg-cyan":"0, 255, 255","--mjx-bg-magenta":"255, 0, 255","--mjx-bg-white":"255, 255, 255","--mjx-bg-black":"0, 0, 0","--mjx-live-bg-color":"white","--mjx-live-shadow-color":"#888","--mjx-live-border-color":"#CCCCCC","--mjx-bg1-color":"rgba(var(--mjx-bg-blue), var(--mjx-bg-alpha))","--mjx-fg1-color":"rgba(var(--mjx-fg-black), 1)","--mjx-bg2-color":"rgba(var(--mjx-bg-red), 1)","--mjx-fg2-color":"rgba(var(--mjx-fg-black), 1)","--mjx-bg1-alpha":.2,"--mjx-fg1-alpha":1,"--mjx-bg2-alpha":1,"--mjx-fg2-alpha":1},"@media (prefers-color-scheme: dark)":{":root":{"--mjx-bg-blue":"132, 132, 255","--mjx-bg-white":"0, 0, 0","--mjx-bg-black":"255, 255, 255","--mjx-fg-white":"0, 0, 0","--mjx-fg-black":"255, 255, 255","--mjx-live-bg-color":"#222025","--mjx-live-shadow-color":"black","--mjx-live-border-color":"#7C7C7C","--mjx-bg1-alpha":.3,"--mjx-fg1-alpha":1,"--mjx-bg2-alpha":1,"--mjx-fg2-alpha":1}},[`.${T.className}`]:{position:"absolute",top:0,display:"none",width:"auto",height:"auto",padding:0,opacity:1,"z-index":"202",left:0,right:0,margin:"0 auto","background-color":"var(--mjx-live-bg-color)","box-shadow":"0px 5px 20px var(--mjx-live-shadow-color)",border:"2px solid var(--mjx-live-border-color)"},[`.${T.className}_Show`]:{display:"block"},[`.${T.className} > div`]:{color:"var(--mjx-fg1-color)","background-color":"var(--mjx-bg1-color)"},"mjx-container [data-sre-highlight-1]:not([data-mjx-collapsed], rect)":{color:"var(--mjx-fg1-color) ! important",fill:"var(--mjx-fg1-color) ! important"},[["mjx-container:not([data-mjx-clone-container])","[data-sre-highlight-1]:not([data-sre-enclosed], rect)"].join(" ")]:{"background-color":"var(--mjx-bg1-color) ! important"},"mjx-container rect[data-sre-highlight-1]:not([data-sre-enclosed])":{fill:"var(--mjx-bg1-color) ! important"},"mjx-container [data-sre-highlight-2]":{color:"var(--mjx-fg2-color) ! important","background-color":"var(--mjx-bg2-color) ! important",fill:"var(--mjx-fg2-color) ! important"},"mjx-container rect[data-sre-highlight-2]":{fill:"var(--mjx-bg2-color) ! important"}});class O extends T{constructor(){super(...arguments),this.active=!1,this.node=null,this.clear=!1,this.voiceRequest=!1,this.voiceCancelled=!1}Show(t){super.Update("\xa0"),this.node=t,super.Show(t)}Update(t){if(this.voiceRequest)return void this.makeVoice(t);speechSynthesis.onvoiceschanged=(()=>this.voiceRequest=!0).bind(this);new Promise((t=>{setTimeout((()=>{this.voiceRequest?t(!0):setTimeout((()=>{this.voiceRequest=!0,t(!0)}),100)}),100)})).then((()=>this.makeVoice(t)))}makeVoice(t){this.active=this.document.options.a11y.voicing&&!!speechSynthesis.getVoices().length,speechSynthesis.cancel(),this.clear=!0;const[e,i]=w(t,this.document.options.sre.locale,this.document.options.sre.rate);super.Update(e),this.active&&e&&this.makeUtterances(i,this.document.options.sre.locale)}makeUtterances(t,e){this.voiceCancelled=!1;let i=null;for(const s of t)if(s.mark){if(!i){this.highlightNode(s.mark,!0);continue}i.addEventListener("end",(t=>{this.voiceCancelled||this.highlightNode(s.mark)}))}else if(s.pause){const t=parseInt(s.pause.match(/^[0-9]+/)[0]);if(isNaN(t)||!i)continue;i.addEventListener("end",(e=>{speechSynthesis.pause(),setTimeout((()=>{speechSynthesis.resume()}),t)}))}else i=new SpeechSynthesisUtterance(s.text),s.rate&&(i.rate=s.rate),s.pitch&&(i.pitch=s.pitch),i.lang=e,speechSynthesis.speak(i);i&&i.addEventListener("end",(t=>{this.highlighter.unhighlight()}))}Hide(){this.cancelVoice(),super.Hide()}cancelVoice(){this.voiceCancelled=!0,speechSynthesis.cancel(),this.highlighter.unhighlight()}highlightNode(t,e=!1){this.highlighter.unhighlight();const i=Array.from(this.node.querySelectorAll(`[data-semantic-id="${t}"]`));this.clear&&!e||this.highlighter.highlight(i),this.clear=!1}}O.style=null;class I extends M{position(t){const e=t.getBoundingClientRect(),i=this.div.getBoundingClientRect();let s,o=e.left+e.width/2-i.width/2;switch(o=o<0?0:o,o+=window.scrollX,this.document.options.a11y.align){case"top":s=e.top-i.height-10;break;case"bottom":s=e.bottom+10;break;default:s=e.top+e.height/2-i.height/2}s+=window.scrollY,s=s<0?0:s,this.div.style.top=s+"px",this.div.style.left=o+"px"}Show(t){this.AddElement(),this.div.style.fontSize=this.document.options.a11y.magnify,this.Update(t),super.Show(t)}Clear(){this.div&&(this.inner.textContent="",this.inner.style.top="",this.inner.style.backgroundColor="")}Update(t){if(!this.div)return;this.Clear();const e=this.cloneNode(t),i=e.querySelector("[data-mjx-clone]");this.inner.style.backgroundColor=t.style.backgroundColor,i.style.backgroundColor="",i.classList.remove("mjx-selected"),this.inner.appendChild(e),this.position(t)}cloneNode(t){let e=t.cloneNode(!0);if(e.setAttribute("data-mjx-clone","true"),"MJX-CONTAINER"!==e.nodeName){"g"!==e.nodeName&&(e.style.marginLeft=e.style.marginRight="0");const i=t.closest("mjx-container");if("MJX-MATH"!==e.nodeName&&"svg"!==e.nodeName){let s=i.firstChild;"MJX-BBOX"===s.nodeName&&(s=s.nextSibling),e=s.cloneNode(!1).appendChild(e).parentElement;const o=Array.from(i.querySelectorAll("[data-sre-enclosed]"));"svg"===s.nodeName?this.svgClone(t,o,e,i):this.chtmlClone(t,o,e)}e=i.cloneNode(!1).appendChild(e).parentElement,e.style.margin="0",e.style.minWidth=""}return e.setAttribute("data-mjx-clone-container","true"),e}chtmlClone(t,e,i){for(const s of e)if(s!==t){const t=s.getAttribute("data-semantic-id");t&&i.querySelector(`[data-semantic-id="${t}"]`)||i.appendChild(s.cloneNode(!0))}}svgClone(t,e,i,s){var o;let{x:r,y:n,width:a,height:h}=t.getBBox();if(e.length){i.firstChild.remove();const o=s.querySelector("g").cloneNode(!1);for(const i of e){const e=o.appendChild(i.cloneNode(!0));i===t&&e.setAttribute("data-mjx-clone","true");const[s,r]=this.xy(i);e.setAttribute("transform",`translate(${s}, ${r})`)}i.appendChild(o);const l=t.previousSibling,c=l.getBBox();a=c.width,h=c.height;const[u,d]=this.xy(l);r=u,n=d+c.y}const l=s.querySelector("g");if("full"===s.getAttribute("width")&&l.firstChild.lastChild===t)return i.innerHTML="",i.appendChild(s.cloneNode(!0).firstChild),i.querySelector(".mjx-selected").setAttribute("data-mjx-clone","true"),void(null===(o=i.querySelector("[data-sre-highlighter-added]"))||void 0===o||o.remove());i.firstChild.setAttribute("transform","scale(1, -1)");const c=parseFloat((i.getAttribute("viewBox")||i.getAttribute("data-mjx-viewBox")).split(/ /)[2]),u=parseFloat(i.style.minWidth||i.getAttribute("width"));i.setAttribute("viewBox",[r,-(n+h),a,h].join(" ")),i.removeAttribute("style"),i.setAttribute("width",u/c*a+"ex"),i.setAttribute("height",u/c*h+"ex")}xy(t){const e=DOMPoint.fromPoint({x:0,y:0}).matrixTransform(t.getCTM().inverse());return[-e.x,-e.y]}}I.className="MJX_HoverRegion",I.style=new S({[`.${I.className}`]:{display:"block",position:"absolute",width:"max-content",height:"auto",padding:0,opacity:1,"z-index":"202",margin:"0 auto","background-color":"white","line-height":0,"box-shadow":"0px 10px 20px #888",border:"2px solid #CCCCCC"},[`.${I.className} > div`]:{overflow:"hidden",color:"var(--mjx-fg1-color)","background-color":"var(--mjx-bg1-color)"},"@media (prefers-color-scheme: dark)":{["."+I.className]:{"background-color":"#222025","box-shadow":"0px 5px 20px #000",border:"1px solid #7C7C7C"}},"mjx-container[data-mjx-clone-container]":{padding:"2px ! important"},"mjx-math > mjx-mlabeledtr":{display:"inline-block","margin-right":".5em ! important"},"mjx-math > mjx-mtd":{float:"right"}});class L{get highlighter(){return this.pool.highlighter}static stopEvent(t){t.preventDefault?t.preventDefault():t.returnValue=!1,t.stopImmediatePropagation?t.stopImmediatePropagation():t.stopPropagation&&t.stopPropagation(),t.cancelBubble=!0}static create(t,e,i,s,...o){return new this(t,e,i,s,...o)}constructor(t,e,i,s,...o){this.document=t,this.pool=e,this.region=i,this.node=s,this.stoppable=!0,this.events=[],this._active=!1}Events(){return this.events}get active(){return this._active}set active(t){this._active=t}Attach(){this.AddEvents()}Detach(){this.RemoveEvents()}Start(){this.active=!0}Stop(){this.active&&(this.region.Clear(),this.region.Hide(),this.active=!1)}AddEvents(){for(const[t,e]of this.events)this.node.addEventListener(t,e)}RemoveEvents(){for(const[t,e]of this.events)this.node.removeEventListener(t,e)}Update(t=!1){}stopEvent(t){this.stoppable&&L.stopEvent(t)}}const P=MathJax._.ui.dialog.InfoDialog.InfoDialog;var D=function(t,e,i,s){return new(i||(i=Promise))((function(o,r){function n(t){try{h(s.next(t))}catch(t){r(t)}}function a(t){try{h(s.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(n,a)}h((s=s.apply(t,e||[])).next())}))};const H="Windows"===A.os,B=Array(40).fill("\u2800").join(""),_="[data-speech-node]";function J(t){return t.matches("mjx-container")}function F(t,e=!0){return t.shiftKey&&e||t.metaKey||t.altKey||t.ctrlKey}class K extends L{static helpMessage(t,e,i){return`\n <h2 role="heading" aria-level="2">Exploring expressions ${t}</h2>\n\n <p>The mathematics on this page is being rendered by <a\n href="https://www.mathjax.org/" target="_blank">MathJax</a>, which\n generates both the text spoken by screen readers, as well as the\n visual layout for sighted users.</p>\n\n <p>Expressions typeset by MathJax can be explored interactively, and\n are focusable. You can use the <kbd>Tab</kbd> key to move to a typeset\n expression${e}. Initially, the expression will be read in full,\n but you can use the following keys to explore the expression\n further:</p>\n\n <ul>\n\n <li><kbd>Down Arrow</kbd> moves one level deeper into the\n expression to allow you to explore the current subexpression term by\n term.</li>\n\n <li><kbd>Up Arrow</kbd> moves back up a level within the\n expression.</li>\n\n <li><kbd>Right Arrow</kbd> moves to the next term in the\n current subexpression.</li>\n\n <li><kbd>Left Arrow</kbd> moves to the next term in the\n current subexpression.</li>\n\n <li><kbd>Shift</kbd>+<kbd>Arrow</kbd> moves to a\n neighboring cell within a table.</li>\n\n <li><kbd>0-9</kbd>+<kbd>0-9</kbd> jumps to a cell\n by its index in the table, where 0 = 10.</li>\n\n <li><kbd>Home</kbd> takes you to the top of the\n expression.</li>\n\n <li><kbd>Enter</kbd> or <kbd>Return</kbd> clicks a\n link or activates an active subexpression.</li>\n\n <li><kbd>Space</kbd> opens the MathJax contextual menu\n where you can view or copy the source format of the expression, or\n modify MathJax's settings.</li>\n\n <li><kbd>Escape</kbd> exits the expression\n explorer.</li>\n\n <li><kbd>x</kbd> gives a summary of the current\n subexpression.</li>\n\n <li><kbd>z</kbd> gives the full text of a collapsed\n expression.</li>\n\n <li><kbd>d</kbd> gives the current depth within the\n expression.</li>\n\n <li><kbd>s</kbd> starts or stops auto-voicing with\n synchronized highlighting.</li>\n\n <li><kbd>v</kbd> marks the current position in the\n expression.</li>\n\n <li><kbd>p</kbd> cycles through the marked positions in\n the expression.</li>\n\n <li><kbd>u</kbd> clears all marked positions and returns\n to the starting position.</li>\n\n <li><kbd>&gt;</kbd> cycles through the available speech\n rule sets (MathSpeak, ClearSpeak).</li>\n\n <li><kbd>&lt;</kbd> cycles through the verbosity levels\n for the current rule set.</li>\n\n <li><kbd>b</kbd> toggles whether Braille notation is combined\n with speech text for tactile Braille devices, as discussed\n below.\n\n <li><kbd>h</kbd> produces this help listing.</li>\n </ul>\n\n <p>The MathJax contextual menu allows you to enable or disable speech\n or Braille generation for mathematical expressions, the language to\n use for the spoken mathematics, and other features of MathJax. In\n particular, the Explorer submenu allows you to specify how the\n mathematics should be identified in the page (e.g., by saying "math"\n when the expression is spoken), and whether or not to include a\n message about the letter "h" bringing up this dialog box. Turning off\n speech and Braille will disable the expression explorer, its\n highlighting, and its help icon.</p>\n\n <p>Support for tactile Braille devices varies across screen readers,\n browsers, and operative systems. If you are using a Braille output\n device, you may need to select the "Combine with Speech" option in the\n contextual menu's Braille submenu in order to obtain Nemeth or Euro\n Braille output rather than the speech text on your Braille\n device. ${i}</p>\n\n <p>The contextual menu also provides options for viewing or copying a\n MathML version of the expression or its original source format,\n creating an SVG version of the expression, and viewing various other\n information.</p>\n\n <p>Finally, selecting the "Insert Hidden MathML" item from the options\n submenu will turn of MathJax's speech and Braille generation and\n instead use visually hidden MathML that some screen readers can voice,\n though support for this is not universal across all screen readers and\n operating systems. Selecting speech or Braille generation in their\n submenus will remove the hidden MathML again.</p>\n\n <p>For more help, see the <a\n href="https://docs.mathjax.org/en/latest/basic/accessibility.html"\n target="_blank">MathJax accessibility documentation.</a></p>\n `}get generators(){var t;return null===(t=this.item)||void 0===t?void 0:t.generatorPool}get role(){return this.item.ariaRole}get description(){return this.item.roleDescription}get none(){return this.document.options.a11y.brailleSpeech?this.item.brailleNone:this.item.none}get brailleNone(){return this.item.brailleNone}FocusIn(t){this.item.outputData.nofocus?this.item.outputData.nofocus=!1:(this.clicked||(this.Start(),this.backTab=t.target===this.img),this.clicked=null)}FocusOut(t){this.current&&!this.focusSpeech&&(this.document.options.keepRegions||(this.setCurrent(null),this.Stop()),document.hasFocus()||this.focusTop())}KeyDown(t){if(this.pendingIndex.shift(),this.region.cancelVoice(),F(t,!1))return;const e=this.constructor,i=1===t.key.length?t.key.toLowerCase():t.key,[s,o]=e.keyMap.get(i)||[],r=s?void 0===o||this.active?s(this,t):o:this.undefinedKey(t);r||(this.stopEvent(t),!1===r&&this.sound&&this.NoMove())}MouseDown(t){var e;if(this.pendingIndex=[],this.region.cancelVoice(),F(t)||2===t.buttons)return void(this.item.outputData.nofocus=!0);const i=this.findClicked(t.target,t.x,t.y);i!==this.document.infoIcon?(null===(e=document.getSelection())||void 0===e||e.removeAllRanges(),t.target.getAttribute("sre-highlighter-added")?this.refocus=i:this.clicked=i):this.stopEvent(t)}Click(t){if(F(t)||2===t.buttons||"Range"===document.getSelection().type)return void this.FocusOut(null);const e=this.findClicked(t.target,t.x,t.y);if(e===this.document.infoIcon)return this.stopEvent(t),void this.help();e&&!this.node.contains(e)||(this.stopEvent(t),this.refocus=e,this.triggerLinkMouse()||this.Start())}DblClick(t){var e;const i=null!==(e=document.getSelection().direction)&&void 0!==e?e:"none";F(t)||2===t.buttons||"none"!==i?this.FocusOut(null):(this.stopEvent(t),this.refocus=this.rootNode(),this.Start())}spaceKey(){return this.refocus=this.current,!0}hKey(){if(!this.document.options.enableExplorerHelp)return!0;this.refocus=this.current,this.help()}escapeKey(){return this.Stop(),this.focusTop(),this.setCurrent(null),!0}tabKey(t){if(0===this.anchors.length||!this.current)return!0;if(this.backTab){if(!t.shiftKey)return!0;const e=this.linkFor(this.anchors[this.anchors.length-1]);return 1===this.anchors.length&&e===this.current||void this.setCurrent(e)}const[e,i,s]=t.shiftKey?[this.anchors.slice(0).reverse(),Node.DOCUMENT_POSITION_PRECEDING,this.isLink()?this.getAnchor():this.current]:[this.anchors,Node.DOCUMENT_POSITION_FOLLOWING,this.current];for(const t of e)if(s.compareDocumentPosition(t)&i)return void this.setCurrent(this.linkFor(t));return!0}enterKey(t){if(this.active)if(this.triggerLinkKeyboard(t))this.Stop();else{const t=this.actionable(this.current);if(!t)return!1;this.refocus=t,t.dispatchEvent(new Event("click"))}else this.Start()}homeKey(){this.setCurrent(this.rootNode())}moveDown(t){return t?this.moveToNeighborCell(1,0):this.moveTo(this.firstNode(this.current))}moveUp(t){return t?this.moveToNeighborCell(-1,0):this.moveTo(this.getParent(this.current))}moveRight(t){return t?this.moveToNeighborCell(0,1):this.moveTo(this.nextSibling(this.current))}moveLeft(t){return t?this.moveToNeighborCell(0,-1):this.moveTo(this.prevSibling(this.current))}moveTo(t){if(!t)return!1;this.setCurrent(t)}moveToNeighborCell(t,e){const i=this.tableCell(this.current);if(!i)return!1;const[s,o]=this.cellPosition(i);if(null==s)return!1;const r=this.cellAt(this.cellTable(i),s+t,o+e);if(!r)return!1;this.setCurrent(r)}undefinedKey(t){return!this.active||F(t)}addMark(){this.current===this.marks[this.marks.length-1]?this.setCurrent(this.current):(this.currentMark=this.marks.length-1,this.marks.push(this.current),this.speak("Position marked"))}prevMark(){if(this.currentMark<0){if(0===this.marks.length)return void this.setCurrent(this.lastMark||this.rootNode());this.currentMark=this.marks.length-1}const t=this.currentMark;this.setCurrent(this.marks[t]),this.currentMark=t-1}clearMarks(){this.marks=[],this.currentMark=-1,this.prevMark()}autoVoice(){const t=!this.document.options.a11y.voicing;this.document.menu?this.document.menu.menu.pool.lookup("voicing").setValue(t):this.document.options.a11y.voicing=t,this.Update()}toggleBraille(){const t=!this.document.options.a11y.brailleCombine;this.document.menu?this.document.menu.menu.pool.lookup("brailleCombine").setValue(t):this.document.options.a11y.brailleCombine=t}numberKey(t){if(!this.tableCell(this.current))return!1;if(0===t&&(t=10),this.pendingIndex.length){const e=this.cellTable(this.tableCell(this.current)),i=this.cellAt(e,this.pendingIndex[0]-1,t-1);if(this.pendingIndex=[],this.speak(String(t)),!i)return!1;setTimeout((()=>this.setCurrent(i)),500)}else this.pendingIndex=[null,t],this.speak(`Jump to row ${t} and column`)}depth(){var t,e,i;if("d"===this.speechType)return void this.setCurrent(this.current);this.speechType="d";const s=[[null!==(t=this.node.getAttribute("data-semantic-level"))&&void 0!==t?t:"Level",null!==(e=this.current.getAttribute("data-semantic-level-number"))&&void 0!==e?e:"0"].join(" ").trim()],o=this.actionable(this.current);o&&s.unshift(null!==(i=this.node.getAttribute("1"===o.getAttribute("toggle")?"data-semantic-expandable":"data-semantic-collapsible"))&&void 0!==i?i:""),this.speak(s.join(" "),this.current.getAttribute(C.BRAILLE))}summary(){if("x"===this.speechType)return void this.setCurrent(this.current);this.speechType="x";const t=this.current.getAttribute(C.SUMMARY);this.speak(t,this.current.getAttribute(C.BRAILLE),this.SsmlAttributes(this.current,C.SUMMARY_SSML))}nextRules(){this.node.removeAttribute("data-speech-attached"),this.restartAfter(this.generators.nextRules(this.item))}nextStyle(){this.node.removeAttribute("data-speech-attached"),this.restartAfter(this.generators.nextStyle(this.current,this.item))}details(){const t=this.actionable(this.current);if(!t||!t.getAttribute("data-collapsible")||"1"!==t.getAttribute("toggle")||"z"===this.speechType)return void this.setCurrent(this.current);this.speechType="z";const e=this.nodeId(this.current);let i;this.item.root.walkTree((t=>{t.attributes.get("data-semantic-id")===e&&(i=t)}));let s=this.item.toMathML(i,this.item);i.isKind("math")||(s=`<math>${s}</math>`),s=s.replace(/ (?:data-semantic-|aria-|data-speech-|data-latex).*?=".*?"/g,""),this.item.speechFor(s).then((([t,e])=>this.speak(t,e)))}help(){if(!this.document.options.enableExplorerHelp)return;const t=this.constructor,[e,i,s]=t.helpData.get(A.os);P.post({title:"MathJax Expression Explorer Help",message:t.helpMessage(e,i,s),node:this.node,adaptor:this.document.adaptor,styles:{".mjx-dialog":{"max-height":"calc(min(35em, 90%))"},"mjx-dialog mjx-title":{"font-size":"133%",margin:".5em 1.75em"},"mjx-dialog h2":{"font-size":"20px",margin:".5em 0"},"mjx-dialog ul":{"list-style-type":"none"},"mjx-dialog li":{"margin-bottom":".5em"}}})}setCurrent(t,e=!1){if(this.backTab=!1,this.speechType="",document.hasFocus()||(this.refocus=this.current),this.node.setAttribute("aria-busy","true"),this.current){this.pool.unhighlight();for(const t of Array.from(this.node.querySelectorAll(".mjx-selected")))t.classList.remove("mjx-selected");"last"===this.document.options.a11y.tabSelects&&(this.refocus=this.current),t||(this.lastMark=this.current,this.removeSpeech()),this.current=null}if(this.current=t,this.currentMark=-1,this.current){const i=[...this.getSplitNodes(this.current)];this.highlighter.encloseNodes(i,this.node);for(const t of i)t.getAttribute("data-sre-enclosed")||t.classList.add("mjx-selected");this.pool.highlight(i),this.addSpeech(t,e),this.node.setAttribute("tabindex","-1"),this.Update()}this.node.removeAttribute("aria-busy")}getSplitNodes(t){const e=this.nodeId(t);if(!e)return[t];if(this.cacheParts.has(e))return this.cacheParts.get(e);const i=Array.from(this.node.querySelectorAll(`[data-semantic-id="${e}"]`)),s=this.subtree(e,i);return this.cacheParts.set(e,[...i,...s]),this.cacheParts.get(e)}subtree(t,e){const i=this.subtrees.get(t),s=new Set;for(const t of e)Array.from(t.querySelectorAll("[data-semantic-id]")).forEach((t=>s.add(this.nodeId(t))));return[...function(t,e){if(!t)return new Set;if(!e)return t;return new Set([...t].filter((t=>!e.has(t))))}(i,s)].map((t=>this.getNode(t))).filter((t=>null!==t))}addSpeech(t,e){var i;if(!this.document.options.enableSpeech&&!this.document.options.enableBraille)return;this.anchors.length?setTimeout((()=>{var t;return null===(t=this.img)||void 0===t?void 0:t.remove()}),10):null===(i=this.img)||void 0===i||i.remove();let s=this.addComma([t.getAttribute(C.PREFIX),t.getAttribute(C.SPEECH),t.getAttribute(C.POSTFIX)]).join(" ").trim();if(e){let t=this.description===this.none?"":", "+this.description;this.document.options.a11y.help&&this.document.options.enableExplorerHelp&&(t+=", press h for help"),s+=t}this.speak(s,t.getAttribute(C.BRAILLE),this.SsmlAttributes(t,C.SPEECH_SSML))}addComma(t){return t[2]&&(t[1]||t[0])&&(t[1]+=","),t}removeSpeech(){this.speech&&(this.unspeak(this.speech),this.speech=null,this.img&&this.node.append(this.img),this.node.setAttribute("tabindex","0"))}speak(t,e="",i=null,s=this.none){const o=this.speech,r=this.speech=document.createElement("mjx-speech");if(r.setAttribute("role",this.role),r.setAttribute("aria-label",t||this.none),r.setAttribute("aria-roledescription",s||this.none),r.setAttribute(C.SPEECH,t),i&&(r.setAttribute(C.PREFIX_SSML,i[0]||""),r.setAttribute(C.SPEECH_SSML,i[1]||""),r.setAttribute(C.POSTFIX_SSML,i[2]||"")),e&&(this.document.options.a11y.brailleSpeech&&(r.setAttribute("aria-label",e),r.setAttribute("aria-roledescription",this.brailleNone)),r.setAttribute("aria-braillelabel",e),r.setAttribute("aria-brailleroledescription",this.brailleNone),this.document.options.a11y.brailleCombine&&r.setAttribute("aria-label",e+B+t)),r.setAttribute("tabindex","0"),H){const t=document.createElement("mjx-speech-container");t.setAttribute("role","application"),t.setAttribute("aria-roledescription",this.none),t.setAttribute("aria-brailleroledescription",this.brailleNone),t.append(r),this.node.append(t),r.setAttribute("role","img")}else this.node.append(r);this.focusSpeech=!0,r.focus(),this.focusSpeech=!1,this.Update(),o&&setTimeout((()=>this.unspeak(o)),100)}unspeak(t){H&&(t=t.parentElement),t.remove()}attachSpeech(){var t;const e=this.item,i=this.node;if(!i.hasAttribute("has-speech")){for(const t of Array.from(i.childNodes))t.setAttribute("aria-hidden","true");i.setAttribute("has-speech","true")}const s=e.roleDescription,o=(i.getAttribute(C.SPEECH)||"")+(s?", "+s:"");null===(t=this.img)||void 0===t||t.remove(),this.img=this.document.adaptor.node("mjx-speech",{"aria-label":o,role:"img","aria-roledescription":e.none});const r=i.getAttribute(C.BRAILLE);r&&(this.document.options.a11y.brailleSpeech&&(this.img.setAttribute("aria-label",r),this.img.setAttribute("aria-roledescription",this.brailleNone)),this.img.setAttribute("aria-braillelabel",r),this.img.setAttribute("aria-brailleroledescription",this.brailleNone),this.document.options.a11y.brailleCombine&&this.img.setAttribute("aria-label",r+B+o)),i.appendChild(this.img),this.adjustAnchors()}detachSpeech(){var t;const e=this.node;null===(t=this.img)||void 0===t||t.remove(),e.removeAttribute("has-speech");for(const t of Array.from(e.childNodes))t.removeAttribute("aria-hidden");this.restoreAnchors()}adjustAnchors(){this.anchors=Array.from(this.node.querySelectorAll("a[href]"));for(const t of this.anchors){const e=t.getAttribute("href");t.setAttribute("data-mjx-href",e),t.removeAttribute("href")}this.anchors.length&&this.img.setAttribute("tabindex","0")}restoreAnchors(){for(const t of this.anchors)t.setAttribute("href",t.getAttribute("data-mjx-href")),t.removeAttribute("data-mjx-href");this.anchors=[]}focus(){this.node.focus()}nodeId(t){return t.getAttribute("data-semantic-id")}parentId(t){return t.getAttribute("data-semantic-parent")}getNode(t){return t?this.node.querySelector(`[data-semantic-id="${t}"]`):null}getParent(t){return this.getNode(this.parentId(t))}childArray(t){return t?t.getAttribute("data-semantic-children").split(/,/):[]}isCell(t){return!!t&&this.cellTypes.includes(t.getAttribute("data-semantic-type"))}isRow(t){return!!t&&"row"===t.getAttribute("data-semantic-type")}tableCell(t){for(;t&&t!==this.node;){if(this.isCell(t))return t;t=t.parentNode}return null}cellTable(t){const e=this.getParent(t);return this.isRow(e)?this.getParent(e):e}cellPosition(t){const e=this.getParent(t),i=this.childArray(e).indexOf(this.nodeId(t));if(!this.isRow(e))return[i,1];const s=this.getParent(e);return[this.childArray(s).indexOf(this.nodeId(e)),i]}cellAt(t,e,i){const s=this.getNode(this.childArray(t)[e]);if(!this.isRow(s))return 1===i?s:null;return this.getNode(this.childArray(s)[i])}firstNode(t){const e=t.getAttribute("data-semantic-owns");if(!e)return t.querySelector(_);const i=e.split(/ /);for(const t of i){const e=this.getNode(t);if(null==e?void 0:e.hasAttribute("data-speech-node"))return e}return t.querySelector(_)}rootNode(){const t=this.node.querySelector("[data-semantic-structure]");if(!t)return this.node.querySelector(_);const e=t.getAttribute("data-semantic-structure").split(/ /)[0].replace("(","");return this.getNode(e)}nextSibling(t){var e;const i=this.parentId(t);if(!i)return null;const s=null===(e=this.getNode(i).getAttribute("data-semantic-owns"))||void 0===e?void 0:e.split(/ /);if(!s)return null;let o,r=s.indexOf(this.nodeId(t));do{o=this.getNode(s[++r])}while(o&&!o.hasAttribute("data-speech-node"));return o}prevSibling(t){var e;const i=this.parentId(t);if(!i)return null;const s=null===(e=this.getNode(i).getAttribute("data-semantic-owns"))||void 0===e?void 0:e.split(/ /);if(!s)return null;let o,r=s.indexOf(this.nodeId(t));do{o=this.getNode(s[--r])}while(o&&!o.hasAttribute("data-speech-node"));return o}findClicked(t,e,i){const s=this.document.infoIcon;if(s===t||s.contains(t))return s;if("SVG"!==this.node.getAttribute("jax"))return t.closest(_);let o=null,r=this.node;for(;r;){r.matches(_)&&(o=r);const t=Array.from(r.childNodes);r=null;for(const s of t)if(s!==this.speech&&s!==this.img&&s.tagName&&"rect"!==s.tagName.toLowerCase()){const{left:t,right:o,top:n,bottom:a}=s.getBoundingClientRect();if(t<=e&&e<=o&&n<=i&&i<=a){r=s;break}}}return o}isLink(t=this.current){var e;return!!(null===(e=null==t?void 0:t.getAttribute("data-semantic-attributes"))||void 0===e?void 0:e.includes("href:"))}getAnchor(t=this.current){const e=t.closest("a");return e&&this.node.contains(e)?e:null}linkFor(t){return null==t?void 0:t.querySelector('[data-semantic-attributes*="href:"]')}parentLink(t){const e=null==t?void 0:t.closest('[data-semantic-attributes*="href:"]');return e&&this.node.contains(e)?e:null}focusTop(){this.focusSpeech=!0,this.node.focus(),this.focusSpeech=!1}SsmlAttributes(t,e){return[t.getAttribute(C.PREFIX_SSML),t.getAttribute(e),t.getAttribute(C.POSTFIX_SSML)]}restartAfter(t){return D(this,void 0,void 0,(function*(){yield t,this.attachSpeech();const e=this.current;this.current=null,this.pool.unhighlight(),this.setCurrent(e)}))}constructor(t,e,i,s,o,r,n,a){super(t,e,null,s),this.document=t,this.pool=e,this.region=i,this.node=s,this.brailleRegion=o,this.magnifyRegion=r,this.item=a,this.sound=!1,this.current=null,this.clicked=null,this.refocus=null,this.focusSpeech=!1,this.restarted=null,this.speech=null,this.speechType="",this.img=null,this.attached=!1,this.eventsAttached=!1,this.marks=[],this.currentMark=-1,this.lastMark=null,this.pendingIndex=[],this.cellTypes=["cell","line"],this.backTab=!1,this.events=super.Events().concat([["focusin",this.FocusIn.bind(this)],["focusout",this.FocusOut.bind(this)],["keydown",this.KeyDown.bind(this)],["mousedown",this.MouseDown.bind(this)],["click",this.Click.bind(this)],["dblclick",this.DblClick.bind(this)]]),this.subtrees=null,this.cacheParts=new Map}findStartNode(){let t=this.refocus||this.current;return!t&&this.restarted&&(t=this.node.querySelector(this.restarted)),this.refocus=this.restarted=null,t}Start(){const t=Object.create(null,{Start:{get:()=>super.Start}});return D(this,void 0,void 0,(function*(){if(this.subtrees||(this.subtrees=new Map,this.getSubtrees()),!this.attached||this.active)return;if(this.document.activeItem=this.item,this.item.state()<d.ATTACHSPEECH&&(this.item.attachSpeech(this.document),yield this.generators.promise),this.focusSpeech)return;this.node.classList.add("mjx-explorer-active"),this.document.options.enableExplorerHelp&&this.node.append(this.document.infoIcon);const e=this.findStartNode();this.setCurrent(e||this.rootNode(),!e),t.Start.call(this);const i=this.document.options,s=i.a11y;s.subtitles&&s.speech&&i.enableSpeech&&this.region.Show(this.node),s.viewBraille&&s.braille&&i.enableBraille&&this.brailleRegion.Show(this.node),s.keyMagnifier&&this.magnifyRegion.Show(this.current),this.Update()}))}Stop(){this.active&&(this.node.classList.remove("mjx-explorer-active"),this.document.options.enableExplorerHelp&&this.document.infoIcon.remove(),this.pool.unhighlight(),this.magnifyRegion.Hide(),this.region.Hide(),this.brailleRegion.Hide()),super.Stop()}Update(){this.active&&(this.region.node=this.node,(this.document.options.enableSpeech||this.document.options.enableBraille)&&this.generators.updateRegions(this.speech||this.node,this.region,this.brailleRegion),this.magnifyRegion.Update(this.current))}Attach(){this.attached||(super.Attach(),this.node.setAttribute("tabindex","0"),this.attached=!0)}Detach(){var t;super.RemoveEvents(),this.node.removeAttribute("role"),this.node.removeAttribute("aria-roledescription"),this.node.removeAttribute("aria-label"),null===(t=this.img)||void 0===t||t.remove(),this.active&&this.node.setAttribute("tabindex","0"),this.attached=!1}NoMove(){j()}AddEvents(){this.eventsAttached||(super.AddEvents(),this.eventsAttached=!0)}actionable(t){const e=null==t?void 0:t.parentNode;return e&&this.highlighter.isMactionNode(e)?e:null}triggerLinkKeyboard(t){return this.current?this.triggerLink(this.current):t.target instanceof HTMLAnchorElement&&(t.target.dispatchEvent(new MouseEvent("click")),!0)}triggerLink(t){if(this.isLink(t)){const e=this.getAnchor(t);return e.classList.add("mjx-visited"),setTimeout((()=>this.FocusOut(null)),50),window.location.href=e.getAttribute("data-mjx-href"),!0}return!1}triggerLinkMouse(){const t=this.parentLink(this.refocus);return!!this.triggerLink(t)}semanticFocus(){const t=[];let e="data-semantic-id",i=this.current||this.refocus||this.node;const s=this.actionable(i);s&&(e=s.hasAttribute("data-maction-id")?"data-maction-id":"id",i=s,t.push(_));const o=i.getAttribute(e);return o&&t.unshift(`[${e}="${o}"]`),t.join(" ")}getSubtrees(){const t=this.node.querySelector("[data-semantic-structure]");if(!t)return;const e=t.getAttribute("data-semantic-structure");const i=function(t){const e=[[]];for(const i of t)if("("===i){const t=[];e[e.length-1].push(t),e.push(t)}else")"===i?e.pop():e[e.length-1].push(i);return e[0][0]}(e.replace(/\(/g," ( ").replace(/\)/g," ) ").trim().split(/\s+/));V(i,this.subtrees)}}function V(t,e){if("string"==typeof t)return e.has(t)||e.set(t,new Set),new Set;const[i,...s]=t,o=i,r=new Set;for(const t of s){const i="string"==typeof t?t:t[0],s=V(t,e);r.add(i),s.forEach((t=>r.add(t)))}return e.set(o,r),r}K.helpData=new Map([["MacOS",["on MacOS and iOS using VoiceOver",", or the VoiceOver arrow keys to select an expression",""]],["Windows",["in Windows using NVDA or JAWS",". The screen reader should enter focus or forms mode automatically\n when the expression gets the browser focus, but if not, you can toggle\n focus mode using NVDA+space in NVDA; for JAWS, Enter should start\n forms mode while Numpad Plus leaves it. Also note that you can use\n the NVDA or JAWS key plus the arrow keys to explore the expression\n even in browse mode, and you can use NVDA+shift+arrow keys to\n navigate out of an expression that has the focus in NVDA","NVDA users need to select this option, while JAWS users should be able\n to get Braille output without changing this setting."]],["Unix",["in Unix using Orca",", and Orca should enter focus mode automatically. If not, use the\n Orca+a key to toggle focus mode on or off. Also note that you can use\n Orca+arrow keys to explore expressions even in browse mode",""]],["unknown",["with a Screen Reader.","",""]]]),K.keyMap=new Map([["Tab",[(t,e)=>t.tabKey(e)]],["Escape",[t=>t.escapeKey()]],["Enter",[(t,e)=>t.enterKey(e)]],["Home",[t=>t.homeKey()]],["ArrowDown",[(t,e)=>t.moveDown(e.shiftKey),!0]],["ArrowUp",[(t,e)=>t.moveUp(e.shiftKey),!0]],["ArrowLeft",[(t,e)=>t.moveLeft(e.shiftKey),!0]],["ArrowRight",[(t,e)=>t.moveRight(e.shiftKey),!0]],[" ",[t=>t.spaceKey()]],["h",[t=>t.hKey()]],[">",[t=>t.nextRules(),!1]],["<",[t=>t.nextStyle(),!1]],["x",[t=>t.summary(),!1]],["z",[t=>t.details(),!1]],["d",[t=>t.depth(),!1]],["v",[t=>t.addMark(),!1]],["p",[t=>t.prevMark(),!1]],["u",[t=>t.clearMarks(),!1]],["s",[t=>t.autoVoice(),!1]],["b",[t=>t.toggleBraille(),!1]],...[..."0123456789"].map((t=>[t,[e=>e.numberKey(parseInt(t)),!1]]))]);const $=MathJax._.a11y.sre_ts,U=($.locales,$.setupEngine,$.engineSetup);$.toEnriched,$.parseDOM,$.addPreference,$.fromPreference,$.toPreference;class q extends L{constructor(){super(...arguments),this.events=super.Events().concat([["mouseover",this.MouseOver.bind(this)],["mouseout",this.MouseOut.bind(this)]])}MouseOver(t){this.Start()}MouseOut(t){this.Stop()}}class X extends q{constructor(t,e,i,s,o,r){super(t,e,i,s),this.document=t,this.pool=e,this.region=i,this.node=s,this.nodeQuery=o,this.nodeAccess=r}MouseOut(t){this.highlighter.unhighlight(),this.region.Hide(),super.MouseOut(t)}MouseOver(t){super.MouseOver(t);const e=t.target,[i,s]=this.getNode(e);i&&(this.highlighter.unhighlight(),this.highlighter.highlight([i]),this.region.Update(s),this.region.Show(i))}getNode(t){const e=t;for(;t&&t!==this.node;){if(this.nodeQuery(t))return[t,this.nodeAccess(t)];t=t.parentNode}for(t=e;t;){if(this.nodeQuery(t))return[t,this.nodeAccess(t)];const e=t.childNodes[0];t=e&&"defs"===e.tagName?t.childNodes[1]:e}return[null,null]}}class z extends X{}class W extends X{}class Y extends X{constructor(t,e,i,s){super(t,e,new N(t),s,(t=>this.highlighter.isMactionNode(t)),(()=>{})),this.document=t,this.pool=e,this.node=s}}class G extends L{constructor(t,e,i,s,o){super(t,e,null,s),this.document=t,this.pool=e,this.region=i,this.node=s,this.mml=o,this.stoppable=!1}Attach(){super.Attach(),this.Start()}Detach(){this.Stop(),super.Detach()}}class Q extends G{Start(){this.active||(this.active=!0,this.highlighter.highlightAll(this.node))}Stop(){this.active&&this.highlighter.unhighlightAll(),this.active=!1}}class Z extends G{constructor(){super(...arguments),this.contrast=new tt,this.leaves=[],this.modality="data-semantic-foreground"}Start(){this.active||(this.active=!0,this.node.hasAttribute("hasforegroundcolor")||(this.colorLeaves(),this.node.setAttribute("hasforegroundcolor","true")),this.leaves.forEach((t=>this.colorize(t))))}Stop(){this.active&&this.leaves.forEach((t=>this.uncolorize(t))),this.active=!1}colorLeaves(){this.leaves=Array.from(this.node.querySelectorAll("[data-semantic-id]:not([data-semantic-children])"));for(const t of this.leaves)t.setAttribute(this.modality,this.contrast.generate()),this.contrast.increment()}colorize(t){t.hasAttribute(this.modality)&&(t.setAttribute(this.modality+"-old",t.style.color),t.style.color=t.getAttribute(this.modality))}uncolorize(t){const e=this.modality+"-old";t.hasAttribute(e)&&(t.style.color=t.getAttribute(e))}}class tt{constructor(){this.hue=10,this.sat=100,this.light=50,this.incr=53}generate(){return tt.hsl2rgb(this.hue,this.sat,this.light)}increment(){this.hue=(this.hue+this.incr)%360}static hsl2rgb(t,e,i){e=e>1?e/100:e,i=i>1?i/100:i;const s=(1-Math.abs(2*i-1))*e,o=s*(1-Math.abs(t/60%2-1)),r=i-s/2;let n=0,a=0,h=0;return 0<=t&&t<60?[n,a,h]=[s,o,0]:60<=t&&t<120?[n,a,h]=[o,s,0]:120<=t&&t<180?[n,a,h]=[0,s,o]:180<=t&&t<240?[n,a,h]=[0,o,s]:240<=t&&t<300?[n,a,h]=[o,0,s]:300<=t&&t<360&&([n,a,h]=[s,0,o]),`rgb(${255*(n+r)}, ${255*(a+r)}, ${255*(h+r)})`}}const et={color:"blue",alpha:.2},it={color:"black",alpha:1},st={ENCLOSED:"data-sre-enclosed",BBOX:"data-sre-highlighter-bbox",ADDED:"data-sre-highlighter-added"};class ot{constructor(t){this.currentHighlights=[],this.priority=t,this.ATTR="data-sre-highlight-"+t}highlight(t){this.currentHighlights.push(t);for(const e of t)this.highlightNode(e),this.setHighlighted(e)}highlightAll(t){const e=this.getMactionNodes(t);for(const t of e)this.highlight([t])}unhighlight(){const t=this.currentHighlights.pop();t&&t.forEach((t=>{this.isHighlighted(t)&&(this.unhighlightNode(t),this.unsetHighlighted(t))}))}unhighlightAll(){for(;this.currentHighlights.length>0;)this.unhighlight()}encloseNodes(t,e){if(1===t.length)return t;const i=this.constructor,s=i.lineSelector,o=i.lineAttr,r=new Map;for(const e of t){const t=e.closest(s),i=t?t.getAttribute(o):"";r.has(i)||r.set(i,[]),r.get(i).push(e)}for(const i of r.values())if(i.length>1){let[s,o,r,n]=[1/0,1/0,-1/0,-1/0];for(const t of i){t.setAttribute(st.ENCLOSED,"true");const{left:e,top:i,right:a,bottom:h}=t.getBoundingClientRect();i===h&&e===a||(e<s&&(s=e),i<o&&(o=i),h>n&&(n=h),a>r&&(r=a))}const a=this.createEnclosure(s,n,r-s,n-o,e,i[0]);t.push(a)}return t}setColorCSS(t,e,i){var s,o;const r=null!==(s=e.color)&&void 0!==s?s:i.color,n=null!==(o=e.alpha)&&void 0!==o?o:i.alpha;T.setColor(t,this.priority,r,n)}setColor(t,e){this.setColorCSS("fg",e,it),this.setColorCSS("bg",t,et)}isHighlighted(t){return t.hasAttribute(this.ATTR)}setHighlighted(t){t.setAttribute(this.ATTR,"true")}unsetHighlighted(t){t.removeAttribute(this.ATTR),t.removeAttribute(st.ENCLOSED)}}class rt extends ot{highlightNode(t){if(this.isHighlighted(t)||"svg"===t.tagName||"MJX-CONTAINER"===t.tagName||t.hasAttribute(st.BBOX)||t.hasAttribute(st.ENCLOSED))return;const{x:e,y:i,width:s,height:o}=t.getBBox(),r=this.createRect(e,i,s,o,t.getAttribute("transform"));this.setHighlighted(r),t.parentNode.insertBefore(r,t)}unhighlightNode(t){if(t.hasAttribute(st.BBOX))return void t.remove();const e=t.previousSibling;(null==e?void 0:e.hasAttribute(st.ADDED))&&e.remove()}createEnclosure(t,e,i,s,o,r){const[n,a]=this.screen2svg(t,e,r),[h,l]=this.screen2svg(t+i,e-s,r),c=this.createRect(n,a,h-n,l-a,r.getAttribute("transform"));return c.setAttribute(st.BBOX,"true"),r.parentNode.insertBefore(c,r),c}screen2svg(t,e,i){const s=i,o=DOMPoint.fromPoint({x:t,y:e}).matrixTransform(s.getScreenCTM().inverse());return[o.x,o.y]}createRect(t,e,i,s,o){const r=document.createElementNS("http://www.w3.org/2000/svg","rect");return r.setAttribute(st.ADDED,"true"),r.setAttribute("x",String(t-40)),r.setAttribute("y",String(e-40)),r.setAttribute("width",String(i+80)),r.setAttribute("height",String(s+80)),o&&r.setAttribute("transform",o),r}isMactionNode(t){return"maction"===t.getAttribute("data-mml-node")}getMactionNodes(t){return Array.from(t.querySelectorAll('[data-mml-node="maction"]'))}}rt.lineSelector="[data-mjx-linebox]",rt.lineAttr="data-mjx-lineno";class nt extends ot{highlightNode(t){}unhighlightNode(t){"mjx-bbox"===t.tagName.toLowerCase()&&t.remove()}createEnclosure(t,e,i,s,o){const r=o.getBoundingClientRect(),n=document.createElement("mjx-bbox");return n.style.width=i+"px",n.style.height=s+"px",n.style.left=t-r.left+"px",n.style.top=e-s-r.top+"px",n.style.position="absolute",o.prepend(n),n}isMactionNode(t){var e;return"mjx-maction"===(null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase())}getMactionNodes(t){return Array.from(t.querySelectorAll("mjx-maction"))}}function at(t,e,i,s){const o=new ht[s](t);return o.setColor(e,i),o}nt.lineSelector="mjx-linebox",nt.lineAttr="lineno";const ht={SVG:rt,CHTML:nt,generic:nt};class lt{constructor(t){this.document=t,this.speechRegion=new O(this.document),this.brailleRegion=new T(this.document),this.magnifier=new I(this.document),this.tooltip1=new R(this.document),this.tooltip2=new R(this.document),this.tooltip3=new R(this.document)}}const ct={speech:(t,e,i,...s)=>{const o=K.create(t,e,t.explorerRegions.speechRegion,i,t.explorerRegions.brailleRegion,t.explorerRegions.magnifier,s[0],s[1]);return o.sound=!0,o},mouseMagnifier:(t,e,i,...s)=>W.create(t,e,t.explorerRegions.magnifier,i,(t=>t.hasAttribute("data-semantic-type")),(t=>t)),hover:(t,e,i,...s)=>Y.create(t,e,null,i),infoType:(t,e,i,...s)=>z.create(t,e,t.explorerRegions.tooltip1,i,(t=>t.hasAttribute("data-semantic-type")),(t=>t.getAttribute("data-semantic-type"))),infoRole:(t,e,i,...s)=>z.create(t,e,t.explorerRegions.tooltip2,i,(t=>t.hasAttribute("data-semantic-role")),(t=>t.getAttribute("data-semantic-role"))),infoPrefix:(t,e,i,...s)=>z.create(t,e,t.explorerRegions.tooltip3,i,(t=>{var e;return null===(e=t.hasAttribute)||void 0===e?void 0:e.call(t,"data-semantic-prefix-none")}),(t=>{var e;return null===(e=t.getAttribute)||void 0===e?void 0:e.call(t,"data-semantic-prefix-none")})),flame:(t,e,i,...s)=>Q.create(t,e,null,i),treeColoring:(t,e,i,...s)=>Z.create(t,e,null,i,...s)};class ut{constructor(){this.explorers={},this.attached=[],this._restart=[],this.speechExplorerKeys=["speech","braille","keyMagnifier"]}get highlighter(){if(this._renderer!==this.document.outputJax.name)return this._renderer=this.document.outputJax.name,this.setPrimaryHighlighter(),this._highlighter;const[t,e]=this.colorOptions();return this._highlighter.setColor(e,t),this._highlighter}init(t,e,i,s){this.document=t,this.mml=i,this.node=e,this.setPrimaryHighlighter();for(const t of Object.keys(ct))this.explorers[t]=ct[t](this.document,this,this.node,this.mml,s);this.setSecondaryHighlighter(),this.attach()}attach(){this.attached=[];const t=[],e=this.document.options.a11y;for(const[i,s]of Object.entries(this.explorers))s instanceof K?(s.stoppable=!1,t.unshift(s),this.speechExplorerKeys.some((t=>this.document.options.a11y[t]))?(s.Attach(),this.attached.push(i)):s.Detach()):e[i]||"speech"===i&&(e.braille||e.keyMagnifier)?(s.Attach(),this.attached.push(i)):s.Detach();for(const e of t)if(e.attached){e.stoppable=!0;break}}reattach(){for(const t of this.attached){const e=this.explorers[t];e.active&&(this._restart.push(t),e.Stop())}}restart(){this._restart.forEach((t=>{this.explorers[t].Start()})),this._restart=[]}setPrimaryHighlighter(){const[t,e]=this.colorOptions();this._highlighter=at(T.priority.primary,e,t,this.document.outputJax.name)}setSecondaryHighlighter(){this.secondaryHighlighter=at(T.priority.secondary,{color:"red"},{color:"black"},this.document.outputJax.name),this.speech.region.highlighter=this.secondaryHighlighter}highlight(t){this.highlighter.highlight(t)}unhighlight(){this.secondaryHighlighter.unhighlight(),this.highlighter.unhighlight()}get speech(){return this.explorers.speech}colorOptions(){const t=this.document.options.a11y;return[{color:t.foregroundColor.toLowerCase(),alpha:t.foregroundOpacity/100},{color:t.backgroundColor.toLowerCase(),alpha:t.backgroundOpacity/100}]}}const dt="Unix"===A.os;function pt(t,e){var i;return i=class extends t{constructor(){super(...arguments),this.refocus=null}get ariaRole(){return this.constructor.ariaRole}get roleDescription(){const t=this.constructor;return"none"===t.roleDescription?t.none:t.roleDescription}get none(){return this.constructor.none}get brailleNone(){return thi