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 • 149 kB
JavaScript
(()=>{"use strict";var t={d:(e,r)=>{for(var s in r)t.o(r,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:r[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,{FindTeX:()=>st});var r={};t.r(r),t.d(r,{default:()=>ht});var s={};t.r(s),t.d(s,{TexConstant:()=>mt});var n={};t.r(n),t.d(n,{default:()=>bt});var i={};t.r(i),t.d(i,{ConfigurationType:()=>At,HandlerType:()=>yt});var a={};t.r(a),t.d(a,{UnitUtil:()=>kt});var o={};t.r(o),t.d(o,{default:()=>wt});var c={};t.r(c),t.d(c,{default:()=>xt});var l={};t.r(l),t.d(l,{BaseItem:()=>Tt,MmlStack:()=>Pt});var h={};t.r(h),t.d(h,{default:()=>Ct});var m={};t.r(m),t.d(m,{default:()=>It});var d={};t.r(d),t.d(d,{NodeFactory:()=>Nt});var u={};t.r(u),t.d(u,{KeyValueDef:()=>Rt,KeyValueTypes:()=>Dt,ParseUtil:()=>qt});var g={};t.r(g),t.d(g,{ColumnParser:()=>_t});var p={};t.r(p),t.d(p,{default:()=>Ut});var f={};t.r(f),t.d(f,{AbstractTags:()=>Xt,AllTags:()=>Vt,Label:()=>Kt,NoTags:()=>$t,TagInfo:()=>zt,TagsFactory:()=>Yt});var b={};t.r(b),t.d(b,{Macro:()=>Zt,Token:()=>Qt});var A={};t.r(A),t.d(A,{AbstractParseMap:()=>se,AbstractTokenMap:()=>ee,CharacterMap:()=>ne,CommandMap:()=>oe,DelimiterMap:()=>ie,EnvironmentMap:()=>ce,MacroMap:()=>ae,RegExpMap:()=>re,parseResult:()=>te});var y={};t.r(y),t.d(y,{MapHandler:()=>de,SubHandler:()=>ue,SubHandlers:()=>ge});var v={};t.r(v),t.d(v,{Configuration:()=>pe,ConfigurationHandler:()=>be,ParserConfiguration:()=>Ae});var k={};t.r(k),t.d(k,{ArrayItem:()=>Ue,BeginItem:()=>Le,BreakItem:()=>Ne,CellItem:()=>Be,CloseItem:()=>xe,DotsItem:()=>je,EndItem:()=>Fe,EqnArrayItem:()=>Ke,EquationItem:()=>Xe,FnItem:()=>qe,LeftItem:()=>Se,Middle:()=>Oe,MmlItem:()=>Ge,MstyleItem:()=>ze,NonscriptItem:()=>He,NotItem:()=>_e,NullItem:()=>Pe,OpenItem:()=>Me,OverItem:()=>Ee,PositionItem:()=>De,PrimeItem:()=>Te,RightItem:()=>Ie,StartItem:()=>ke,StopItem:()=>we,StyleItem:()=>Re,SubsupItem:()=>Ce});var w={};t.r(w),t.d(w,{default:()=>er,splitAlignArray:()=>Qe});var M={};t.r(M),t.d(M,{default:()=>nr});var x={};t.r(x),t.d(x,{BaseConfiguration:()=>gr,BaseTags:()=>ur,Other:()=>dr});var P={};t.r(P),t.d(P,{TeX:()=>pr});var T={};t.r(T),t.d(T,{FlalignItem:()=>br,MultlineItem:()=>fr});var C={};t.r(C),t.d(C,{NewcommandPriority:()=>yr,NewcommandTables:()=>Ar,NewcommandUtil:()=>vr});var E={};t.r(E),t.d(E,{AmsMethods:()=>Mr});var S={};t.r(S),t.d(S,{BeginEnvItem:()=>xr});var O={};t.r(O),t.d(O,{default:()=>Tr});var I={};t.r(I),t.d(I,{NewcommandConfig:()=>Cr,NewcommandConfiguration:()=>Er});var N={};t.r(N),t.d(N,{AmsConfiguration:()=>Or,AmsTags:()=>Sr});var L={};t.r(L),t.d(L,{RequireConfiguration:()=>zr,RequireLoad:()=>jr,RequireMethods:()=>Ur,options:()=>Kr});var F={};t.r(F),t.d(F,{AutoloadConfiguration:()=>Jr});var R={};t.r(R),t.d(R,{ConfigMacrosConfiguration:()=>ts});var D={};t.r(D),t.d(D,{NoUndefinedConfiguration:()=>es});var B={};t.r(B),t.d(B,{TextParser:()=>rs});var G={};t.r(G),t.d(G,{TextMacrosMethods:()=>is});var q={};t.r(q),t.d(q,{TextBaseConfiguration:()=>os,TextMacrosConfiguration:()=>ls});const _=("undefined"!=typeof window?window:t.g).MathJax._.components.global,H=(_.GLOBAL,_.isObject,_.combineConfig,_.combineDefaults,_.combineWithMathJax),j=(_.MathJax,MathJax._.core.InputJax.AbstractInputJax),U=MathJax._.util.Options,K=(U.isObject,U.APPEND,U.REMOVE,U.OPTIONS,U.Expandable,U.expandable),z=(U.makeArray,U.keys,U.copy,U.insert),X=U.defaultOptions,$=U.userOptions,V=(U.selectOptions,U.selectOptionsFromKeys,U.separateOptions),J=U.lookup,W=MathJax._.core.FindMath.AbstractFindMath,Y=MathJax._.util.string,Q=Y.sortLength,Z=Y.quotePattern,tt=(Y.unicodeChars,Y.unicodeString,Y.isPercent,Y.split,Y.replaceUnicode),et=(Y.toEntity,MathJax._.core.MathItem),rt=et.protoItem;et.AbstractMathItem,et.STATE,et.newState;class st extends W{constructor(t){super(t),this.getPatterns()}getPatterns(){const t=this.options,e=[],r=[],s=[];this.end={},this.env=this.sub=0;let n=1;t.inlineMath.forEach((t=>this.addPattern(e,t,!1))),t.displayMath.forEach((t=>this.addPattern(e,t,!0))),e.length&&r.push(e.sort(Q).join("|")),t.processEnvironments&&(r.push("\\\\begin\\s*\\{([^}]*)\\}"),this.env=n,n++),t.processEscapes&&s.push("\\\\([\\\\$])"),t.processRefs&&s.push("(\\\\(?:eq)?ref\\s*\\{[^}]*\\})"),s.length&&(r.push("("+s.join("|")+")"),this.sub=n),this.start=new RegExp(r.join("|"),"g"),this.hasPatterns=r.length>0}addPattern(t,e,r){const[s,n]=e;t.push(Z(s)),this.end[s]=[n,r,this.endPattern(n)]}endPattern(t,e){return new RegExp((e||Z(t))+"|\\\\(?:[a-zA-Z]|.)|[{}]","g")}findEnd(t,e,r,s){const[n,i,a]=s,o=a.lastIndex=r.index+r[0].length;let c,l=0;for(;c=a.exec(t);){if((c[1]||c[0])===n&&0===l)return rt(r[0],t.substring(o,c.index),c[0],e,r.index,c.index+c[0].length,i);"{"===c[0]?l++:"}"===c[0]&&l&&l--}return null}findMathInString(t,e,r){let s,n;for(this.start.lastIndex=0;s=this.start.exec(r);){if(void 0!==s[this.env]&&this.env){const t="\\\\end\\s*(\\{"+Z(s[this.env])+"\\})";n=this.findEnd(r,e,s,["{"+s[this.env]+"}",!0,this.endPattern(null,t)]),n&&(n.math=n.open+n.math+n.close,n.open=n.close="")}else if(void 0!==s[this.sub]&&this.sub){const t=s[this.sub],r=s.index+s[this.sub].length;n=2===t.length?rt("\\",t.substring(1),"",e,s.index,r):rt("",t,"",e,s.index,r,!1)}else n=this.findEnd(r,e,s,this.end[s[0]]);n&&(t.push(n),this.start.lastIndex=n.end.n)}}findMath(t){const e=[];if(this.hasPatterns)for(let r=0,s=t.length;r<s;r++)this.findMathInString(e,r,t[r]);return e}}st.OPTIONS={inlineMath:[["\\(","\\)"]],displayMath:[["$$","$$"],["\\[","\\]"]],processEscapes:!0,processEnvironments:!0,processRefs:!0};const nt=MathJax._.core.MmlTree.MmlNode,it=nt.TEXCLASS,at=(nt.TEXCLASSNAMES,nt.MATHVARIANTS,nt.indentAttributes,nt.AbstractMmlNode),ot=(nt.AbstractMmlTokenNode,nt.AbstractMmlLayoutNode,nt.AbstractMmlBaseNode,nt.AbstractMmlEmptyNode),ct=(nt.TextNode,nt.XMLNode,MathJax._.core.MmlTree.MmlNodes.mo.MmlMo),lt={attrs:new Set(["autoOP","fnOP","movesupsub","subsupOK","texprimestyle","useHeight","variantForm","withDelims","mathaccent","open","close"]),createEntity:t=>String.fromCodePoint(parseInt(t,16)),getChildren:t=>t.childNodes,getText:t=>t.getText(),appendChildren(t,e){for(const r of e)t.appendChild(r)},setAttribute(t,e,r){t.attributes.set(e,r)},setProperty(t,e,r){t.setProperty(e,r)},setProperties(t,e){for(const r of Object.keys(e)){const s=e[r];"texClass"===r?(t.texClass=s,t.setProperty(r,s)):"movablelimits"===r?(t.setProperty("movablelimits",s),(t.isKind("mo")||t.isKind("mstyle"))&&t.attributes.set("movablelimits",s)):"inferred"===r||(lt.attrs.has(r)?t.setProperty(r,s):t.attributes.set(r,s))}},getProperty:(t,e)=>t.getProperty(e),getAttribute:(t,e)=>t.attributes.get(e),removeAttribute(t,e){t.attributes.unset(e)},removeProperties(t,...e){t.removeProperty(...e)},getChildAt:(t,e)=>t.childNodes[e],setChild(t,e,r){t.childNodes[e]=r,r&&(r.parent=t)},copyChildren(t,e){const r=t.childNodes;for(let t=0;t<r.length;t++)this.setChild(e,t,r[t])},copyAttributes(t,e){e.attributes=t.attributes;for(const[r,s]of Object.entries(t.getAllProperties()))e.setProperty(r,s)},isType:(t,e)=>t.isKind(e),isEmbellished:t=>t.isEmbellished,getTexClass:t=>t.texClass,getCoreMO:t=>t.coreMO(),isNode:t=>t instanceof at||t instanceof ot,isInferred:t=>t.isInferred,getForm(t){if(!t.isKind("mo"))return null;const e=t,r=e.getForms();for(const t of r){const r=this.getOp(e,t);if(r)return r}return null},getOp:(t,e="infix")=>ct.OPTABLE[e][t.getText()]||null,getMoAttribute(t,e){var r,s;if(!t.attributes.isSet(e))for(const n of["infix","postfix","prefix"]){const i=null===(s=null===(r=this.getOp(t,n))||void 0===r?void 0:r[3])||void 0===s?void 0:s[e];if(void 0!==i)return i}return t.attributes.get(e)}},ht=lt,mt={Variant:{NORMAL:"normal",BOLD:"bold",ITALIC:"italic",BOLDITALIC:"bold-italic",DOUBLESTRUCK:"double-struck",FRAKTUR:"fraktur",BOLDFRAKTUR:"bold-fraktur",SCRIPT:"script",BOLDSCRIPT:"bold-script",SANSSERIF:"sans-serif",BOLDSANSSERIF:"bold-sans-serif",SANSSERIFITALIC:"sans-serif-italic",SANSSERIFBOLDITALIC:"sans-serif-bold-italic",MONOSPACE:"monospace",INITIAL:"inital",TAILED:"tailed",LOOPED:"looped",STRETCHED:"stretched",CALLIGRAPHIC:"-tex-calligraphic",BOLDCALLIGRAPHIC:"-tex-bold-calligraphic",OLDSTYLE:"-tex-oldstyle",BOLDOLDSTYLE:"-tex-bold-oldstyle",MATHITALIC:"-tex-mathit"},Form:{PREFIX:"prefix",INFIX:"infix",POSTFIX:"postfix"},LineBreak:{AUTO:"auto",NEWLINE:"newline",NOBREAK:"nobreak",GOODBREAK:"goodbreak",BADBREAK:"badbreak"},LineBreakStyle:{BEFORE:"before",AFTER:"after",DUPLICATE:"duplicate",INFIXLINBREAKSTYLE:"infixlinebreakstyle"},IndentAlign:{LEFT:"left",CENTER:"center",RIGHT:"right",AUTO:"auto",ID:"id",INDENTALIGN:"indentalign"},IndentShift:{INDENTSHIFT:"indentshift"},LineThickness:{THIN:"thin",MEDIUM:"medium",THICK:"thick"},Notation:{LONGDIV:"longdiv",ACTUARIAL:"actuarial",PHASORANGLE:"phasorangle",RADICAL:"radical",BOX:"box",ROUNDEDBOX:"roundedbox",CIRCLE:"circle",LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom",UPDIAGONALSTRIKE:"updiagonalstrike",DOWNDIAGONALSTRIKE:"downdiagonalstrike",VERTICALSTRIKE:"verticalstrike",HORIZONTALSTRIKE:"horizontalstrike",NORTHEASTARROW:"northeastarrow",MADRUWB:"madruwb",UPDIAGONALARROW:"updiagonalarrow"},Align:{TOP:"top",BOTTOM:"bottom",CENTER:"center",BASELINE:"baseline",AXIS:"axis",LEFT:"left",RIGHT:"right"},Lines:{NONE:"none",SOLID:"solid",DASHED:"dashed"},Side:{LEFT:"left",RIGHT:"right",LEFTOVERLAP:"leftoverlap",RIGHTOVERLAP:"rightoverlap"},Width:{AUTO:"auto",FIT:"fit"},Actiontype:{TOGGLE:"toggle",STATUSLINE:"statusline",TOOLTIP:"tooltip",INPUT:"input"},Overflow:{LINBREAK:"linebreak",SCROLL:"scroll",ELIDE:"elide",TRUNCATE:"truncate",SCALE:"scale"},Unit:{EM:"em",EX:"ex",PX:"px",IN:"in",CM:"cm",MM:"mm",PT:"pt",PC:"pc"},Attr:{LATEX:"data-latex",LATEXITEM:"data-latex-item"}};function dt(t,e,r){const s=e.attributes,n=r.attributes;t.forEach((t=>{const e=n.getExplicit(t);null!=e&&s.set(t,e)}))}function ut(t,e){const r=(t,e)=>t.getExplicitNames().filter((r=>r!==e&&("stretchy"!==r||t.getExplicit("stretchy"))&&"data-latex"!==r&&"data-latex-item"!==r)),s=t.attributes,n=e.attributes,i=r(s,"lspace"),a=r(n,"rspace");if(i.length!==a.length)return!1;for(const t of i)if(s.getExplicit(t)!==n.getExplicit(t))return!1;return!0}function gt(t,e,r){const s=[];for(const n of t.getList("m"+e+r)){const i=n.childNodes;if(i[n[e]]&&i[n[r]])continue;const a=n.parent,o=i[n[e]]?t.nodeFactory.create("node","m"+e,[i[n.base],i[n[e]]]):t.nodeFactory.create("node","m"+r,[i[n.base],i[n[r]]]);ht.copyAttributes(n,o),a.replaceChild(o,n),s.push(n)}t.removeFromList("m"+e+r,s)}function pt(t,e,r){const s=[];for(const n of t.getList(e)){if(n.attributes.get("displaystyle"))continue;const e=n.childNodes[n.base],i=e.coreMO();if(e.getProperty("movablelimits")&&!i.attributes.hasExplicit("movablelimits")){const e=t.nodeFactory.create("node",r,n.childNodes);ht.copyAttributes(n,e),n.parent.replaceChild(e,n),s.push(n)}}t.removeFromList(e,s)}const ft={cleanStretchy(t){var e;const r=t.data;for(const t of r.getList("fixStretchy"))if(ht.getProperty(t,"fixStretchy")){const r=ht.getForm(t);(null===(e=null==r?void 0:r[3])||void 0===e?void 0:e.stretchy)&&ht.setAttribute(t,"stretchy",!1),ht.removeProperties(t,"fixStretchy")}},cleanAttributes(t){t.data.root.walkTree((t=>{const e=new Set((t.getProperty("keep-attrs")||"").split(/ /)),r=t.attributes;r.unset(mt.Attr.LATEXITEM);for(const s of r.getExplicitNames())e.has(s)||r.get(s)!==t.attributes.getInherited(s)||r.unset(s)}))},combineRelations(t){const e=[];for(const r of t.data.getList("mo")){if(r.getProperty("relationsCombined")||!r.parent||r.parent&&!ht.isType(r.parent,"mrow")||ht.getTexClass(r)!==it.REL)continue;let t;const s=r.parent.childNodes,n=s.indexOf(r)+1,i=ht.getProperty(r,"variantForm");for(;n<s.length&&(t=s[n])&&ht.isType(t,"mo")&&ht.getTexClass(t)===it.REL;){if(i!==ht.getProperty(t,"variantForm")||!ut(r,t)){r.attributes.hasExplicit("rspace")||ht.setAttribute(r,"rspace","0pt"),t.attributes.hasExplicit("lspace")||ht.setAttribute(t,"lspace","0pt");break}ht.appendChildren(r,ht.getChildren(t)),dt(["stretchy","rspace"],r,t);for(const e of t.getPropertyNames())r.setProperty(e,t.getProperty(e));t.attributes.get("data-latex")&&r.attributes.set("data-latex",r.attributes.get("data-latex")+t.attributes.get("data-latex")),s.splice(n,1),e.push(t),t.parent=null,t.setProperty("relationsCombined",!0),r.setProperty("texClass",it.REL)}r.attributes.setInherited("form",r.getForms()[0])}t.data.removeFromList("mo",e)},cleanSubSup(t){const e=t.data;e.error||(gt(e,"sub","sup"),gt(e,"under","over"))},moveLimits(t){const e=t.data;pt(e,"munderover","msubsup"),pt(e,"munder","msub"),pt(e,"mover","msup")},setInherited(t){t.data.root.setInheritedAttributes({},t.math.display,0,!1)},checkScriptlevel(t){const e=t.data,r=[];for(const t of e.getList("mstyle")){if(1!==t.childNodes[0].childNodes.length)continue;const e=t.attributes;for(const t of["displaystyle","scriptlevel"])e.getExplicit(t)===e.getInherited(t)&&e.unset(t);const s=e.getExplicitNames();if(0===s.filter((t=>"data-latex"!==t.substring(0,10))).length){const n=t.childNodes[0].childNodes[0];s.forEach((t=>n.attributes.set(t,e.get(t)))),t.parent.replaceChild(n,t),r.push(t)}}e.removeFromList("mstyle",r)}},bt=ft;var At,yt;!function(t){t.HANDLER="handler",t.FALLBACK="fallback",t.ITEMS="items",t.TAGS="tags",t.OPTIONS="options",t.NODES="nodes",t.PREPROCESSORS="preprocessors",t.POSTPROCESSORS="postprocessors",t.INIT="init",t.CONFIG="config",t.PRIORITY="priority",t.PARSER="parser"}(At||(At={})),function(t){t.DELIMITER="delimiter",t.MACRO="macro",t.CHARACTER="character",t.ENVIRONMENT="environment"}(yt||(yt={}));const vt=7.2;const kt={UNIT_CASES:new class{constructor(t){this.num="([-+]?([.,]\\d+|\\d+([.,]\\d*)?))",this.unit="",this.dimenEnd=/./,this.dimenRest=/./,this.map=new Map(t),this.updateDimen()}updateDimen(){this.unit=`(${Array.from(this.map.keys()).join("|")})`,this.dimenEnd=RegExp("^\\s*"+this.num+"\\s*"+this.unit+"\\s*$"),this.dimenRest=RegExp("^\\s*"+this.num+"\\s*"+this.unit+" ?")}set(t,e){return this.map.set(t,e),this.updateDimen(),this}get(t){return this.map.get(t)||this.map.get("pt")}delete(t){return!!this.map.delete(t)&&(this.updateDimen(),!0)}}([["em",1],["ex",.43],["pt",.1],["pc",1.2],["px",.1],["in",vt],["cm",vt/2.54],["mm",vt/25.4],["mu",1/18]]),matchDimen(t,e=!1){const r=t.match(e?kt.UNIT_CASES.dimenRest:kt.UNIT_CASES.dimenEnd);return r?function([t,e,r]){return"mu"!==e?[t,e,r]:[kt.em(kt.UNIT_CASES.get(e)*parseFloat(t)).slice(0,-2),"em",r]}([r[1].replace(/,/,"."),r[4],r[0].length]):[null,null,0]},dimen2em(t){const[e,r]=kt.matchDimen(t),s=parseFloat(e||"1");return kt.UNIT_CASES.get(r)*s},em:t=>Math.abs(t)<6e-4?"0em":t.toFixed(3).replace(/\.?0+$/,"")+"em",trimSpaces(t){if("string"!=typeof t)return t;let e=t.trim();return e.match(/\\$/)&&t.match(/ $/)&&(e+=" "),e}};class wt{constructor(t,e,r){this._factory=t,this._env=e,this.global={},this.stack=[],this.global={isInner:r},this.stack=[this._factory.create("start",this.global)],e&&(this.stack[0].env=e),this.env=this.stack[0].env}set env(t){this._env=t}get env(){return this._env}Push(...t){for(const e of t){if(!e)continue;const t=ht.isNode(e)?this._factory.create("mml",e):e;t.global=this.global;const[r,s]=this.stack.length?this.Top().checkItem(t):[null,!0];s&&(r?(this.Pop(),this.Push(...r)):(t.isKind("null")||this.stack.push(t),t.env?(t.copyEnv&&Object.assign(t.env,this.env),this.env=t.env):t.env=this.env))}}Pop(){const t=this.stack.pop();return t.isOpen||delete t.env,this.env=this.stack.length?this.Top().env:{},t}Top(t=1){return this.stack.length<t?null:this.stack[this.stack.length-t]}Prev(t){const e=this.Top();return t?e.First:e.Pop()}get height(){return this.stack.length}toString(){return"stack[\n "+this.stack.join("\n ")+"\n]"}}class Mt{static processString(t,e){const r=t.split(Mt.pattern);for(let t=1,s=r.length;t<s;t+=2){let s=r[t].charAt(0);if(s>="0"&&s<="9")r[t]=e[parseInt(r[t],10)-1],"number"==typeof r[t]&&(r[t]=r[t].toString());else if("{"===s)if(s=r[t].substring(1),s>="0"&&s<="9")r[t]=e[parseInt(r[t].substring(1,r[t].length-1),10)-1],"number"==typeof r[t]&&(r[t]=r[t].toString());else{r[t].match(/^\{([a-z]+):%(\d+)\|(.*)\}$/)&&(r[t]="%"+r[t])}}return r.join("")}constructor(t,e,...r){this.id=t,this.message=Mt.processString(e,r)}}Mt.pattern=/%(\d+|\{\d+\}|\{[a-z]+:%\d+(?:\|(?:%\{\d+\}|%.|[^}])*)+\}|.)/g;const xt=Mt;class Pt{constructor(t){this._nodes=t,this.startStr="",this.startI=0,this.stopI=0}get nodes(){return this._nodes}Push(...t){this._nodes.push(...t)}Pop(){return this._nodes.pop()}get First(){return this._nodes[this.Size()-1]}set First(t){this._nodes[this.Size()-1]=t}get Last(){return this._nodes[0]}set Last(t){this._nodes[0]=t}Peek(t){return null==t&&(t=1),this._nodes.slice(this.Size()-t)}Size(){return this._nodes.length}Clear(){this._nodes=[]}toMml(t=!0,e){return 1!==this._nodes.length||e?this.create("node",t?"inferredMrow":"mrow",this._nodes,{}):this.First}create(t,...e){return this.factory.configuration.nodeFactory.create(t,...e)}}class Tt extends Pt{constructor(t,...e){super(e),this.factory=t,this.global={},this._properties={},this.isOpen&&(this._env={})}get kind(){return"base"}get env(){return this._env}set env(t){this._env=t}get copyEnv(){return!0}getProperty(t){return this._properties[t]}setProperty(t,e){return this._properties[t]=e,this}get isOpen(){return!1}get isClose(){return!1}get isFinal(){return!1}isKind(t){return t===this.kind}checkItem(t){if(t.isKind("over")&&this.isOpen&&(t.setProperty("num",this.toMml(!1)),this.Clear()),t.isKind("cell")&&this.isOpen){if(t.getProperty("linebreak"))return Tt.fail;throw new xt("Misplaced","Misplaced %1",t.getName())}if(t.isClose&&this.getErrors(t.kind)){const[e,r]=this.getErrors(t.kind);throw new xt(e,r,t.getName())}return t.isFinal?(this.Push(t.First),Tt.fail):Tt.success}clearEnv(){for(const t of Object.keys(this.env))delete this.env[t]}setProperties(t){return Object.assign(this._properties,t),this}getName(){return this.getProperty("name")}toString(){return this.kind+"["+this.nodes.join("; ")+"]"}getErrors(t){return this.constructor.errors[t]||Tt.errors[t]}addLatexItem(t,e=""){const r=this.startStr.slice(this.startI,this.stopI);if(r){const s=e?e+r:r;t.attributes.set(mt.Attr.LATEXITEM,s),"}"!==s&&t.attributes.set(mt.Attr.LATEX,s)}}}Tt.fail=[null,!1],Tt.success=[null,!0],Tt.errors={end:["MissingBeginExtraEnd","Missing \\begin{%1} or extra \\end{%1}"],close:["ExtraCloseMissingOpen","Extra close brace or missing open brace"],right:["MissingLeftExtraRight","Missing \\left or extra \\right"],middle:["ExtraMiddle","Extra \\middle"]};class Ct{constructor(t,e,r){this._string=t,this.configuration=r,this.macroCount=0,this.i=0,this.currentCS="",this.saveI=0;const s=Object.hasOwn(e,"isInner"),n=e.isInner;let i;if(delete e.isInner,e){i={};for(const t of Object.keys(e))i[t]=e[t]}this.configuration.pushParser(this),this.stack=new wt(this.itemFactory,i,!s||n),this.Parse(),this.Push(this.itemFactory.create("stop")),this.stack.env=i}get options(){return this.configuration.options}get itemFactory(){return this.configuration.itemFactory}get tags(){return this.configuration.tags}set string(t){this._string=t}get string(){return this._string}parse(t,e){const r=this.saveI;this.saveI=this.i-("character"===t&&"&"!==e[1]?1:0);const s=this.configuration.handlers.get(t).parse(e);return"macro"!==t&&this.updateResult(e[1],r),this.saveI=r,s}lookup(t,e){return this.configuration.handlers.get(t).lookup(e)}contains(t,e){return this.configuration.handlers.get(t).contains(e)}toString(){let t="";for(const e of Array.from(this.configuration.handlers.keys()))t+=e+": "+this.configuration.handlers.get(e)+"\n";return t}Parse(){let t;for(;this.i<this.string.length;)t=this.getCodePoint(),this.i+=t.length,this.parse(yt.CHARACTER,[this,t])}Push(t){t instanceof Tt&&(t.startI=this.saveI,t.stopI=this.i,t.startStr=this.string),t instanceof at&&t.isInferred?this.PushAll(t.childNodes):this.stack.Push(t)}PushAll(t){for(const e of t)this.stack.Push(e)}mml(){if(!this.stack.Top().isKind("mml"))return null;const t=this.stack.Top().First;this.configuration.popParser();const e=this.trimTex(this.string);return e&&t.attributes.set(mt.Attr.LATEX,e),t}convertDelimiter(t){var e;const r=this.lookup(yt.DELIMITER,t);return null!==(e=null==r?void 0:r.char)&&void 0!==e?e:null}getCodePoint(){const t=this.string.codePointAt(this.i);return void 0===t?"":String.fromCodePoint(t)}nextIsSpace(){return!!this.string.charAt(this.i).match(/\s/)}GetNext(){for(;this.nextIsSpace();)this.i++;return this.getCodePoint()}GetCS(){const t=this.string.slice(this.i).match(/^(([a-z]+) ?|[\uD800-\uDBFF].|.)/i);return t?(this.i+=t[0].length,t[2]||t[1]):(this.i++," ")}GetArgument(t,e=!1){switch(this.GetNext()){case"":if(!e)throw new xt("MissingArgFor","Missing argument for %1",this.currentCS);return null;case"}":if(!e)throw new xt("ExtraCloseMissingOpen","Extra close brace or missing open brace");return null;case"\\":return this.i++,"\\"+this.GetCS();case"{":{const t=++this.i;let e=1;for(;this.i<this.string.length;)switch(this.string.charAt(this.i++)){case"\\":this.i++;break;case"{":e++;break;case"}":if(0===--e)return this.string.slice(t,this.i-1)}throw new xt("MissingCloseBrace","Missing close brace")}}const r=this.getCodePoint();return this.i+=r.length,r}GetBrackets(t,e,r=!1){if("["!==this.GetNext())return e;const s=++this.i;let n=0,i=0;for(;this.i<this.string.length;)switch(this.string.charAt(this.i++)){case"{":n++;break;case"\\":this.i++;break;case"}":if(n--<=0)throw new xt("ExtraCloseLooking","Extra close brace while looking for %1","']'");break;case"[":0===n&&i++;break;case"]":if(0===n){if(!r||0===i)return this.string.slice(s,this.i-1);i--}}throw new xt("MissingCloseBracket","Could not find closing ']' for argument to %1",this.currentCS)}GetDelimiter(t,e=!1){let r=this.GetNext();if(this.i+=r.length,this.i<=this.string.length&&("\\"===r?r+=this.GetCS():"{"===r&&e&&(this.i--,r=this.GetArgument(t).trim()),this.contains(yt.DELIMITER,r)))return this.convertDelimiter(r);throw new xt("MissingOrUnrecognizedDelim","Missing or unrecognized delimiter for %1",this.currentCS)}GetDimen(t){if("{"===this.GetNext()){const e=this.GetArgument(t),[r,s]=kt.matchDimen(e);if(r)return r+s}else{const t=this.string.slice(this.i),[e,r,s]=kt.matchDimen(t,!0);if(e)return this.i+=s,e+r}throw new xt("MissingDimOrUnits","Missing dimension or its units for %1",this.currentCS)}GetUpTo(t,e){for(;this.nextIsSpace();)this.i++;const r=this.i;let s=0;for(;this.i<this.string.length;){const t=this.i;let n=this.GetNext();switch(this.i+=n.length,n){case"\\":n+=this.GetCS();break;case"{":s++;break;case"}":if(0===s)throw new xt("ExtraCloseLooking","Extra close brace while looking for %1",e);s--}if(0===s&&n===e)return this.string.slice(r,t)}throw new xt("TokenNotFoundForCommand","Could not find %1 for %2",e,this.currentCS)}ParseArg(t){return new Ct(this.GetArgument(t),this.stack.env,this.configuration).mml()}ParseUpTo(t,e){return new Ct(this.GetUpTo(t,e),this.stack.env,this.configuration).mml()}GetDelimiterArg(t){const e=kt.trimSpaces(this.GetArgument(t));if(""===e)return null;if(this.contains(yt.DELIMITER,e))return e;throw new xt("MissingOrUnrecognizedDelim","Missing or unrecognized delimiter for %1",this.currentCS)}GetStar(){const t="*"===this.GetNext();return t&&this.i++,t}create(t,...e){const r=this.configuration.nodeFactory.create(t,...e);return r.isToken&&r.attributes.hasExplicit("mathvariant")&&"-"===r.attributes.get("mathvariant").charAt(0)&&r.setProperty("ignore-variant",!0),r}trimTex(t){return t.trim()+(t.match(/(?:^|[^\\])(?:\\\\)*\\\s+$/)?" ":"")}updateResult(t,e){const r=this.stack.Prev(!0);if(!r)return;const s=mt.Attr.LATEX,n=r.attributes.get(s),i=r.attributes.get(mt.Attr.LATEXITEM);if(void 0!==i)return void(n||("}"===t||"}"===i?this.composeBraces(r):r.attributes.set(s,i)));e=e<this.saveI?this.saveI:e;const a=this.trimTex(e!==this.i?this.string.slice(e,this.i):t);if(a&&a!==n&&("\\"!==t||"\\"!==a)){if("_"===a||"^"===a)r.setProperty("sub-sup",a);else{switch(r.getProperty("sub-sup")){case"^":if(r.childNodes[2]&&("}"===a?this.composeBraces(r.childNodes[2]):r.childNodes[2].attributes.hasExplicit(s)||r.childNodes[2].attributes.set(s,a)),r.childNodes[1]){const t=r.childNodes[1].attributes.get(s);this.composeLatex(r,`_${t}^`,0,2)}else this.composeLatex(r,"^",0,2);return;case"_":if(r.childNodes[1]&&("}"===a?this.composeBraces(r.childNodes[1]):r.childNodes[1].attributes.hasExplicit(s)||r.childNodes[1].attributes.set(s,a)),r.childNodes[2]){const t=r.childNodes[2].attributes.get(s);this.composeLatex(r,`^${t}_`,0,1)}else this.composeLatex(r,"_",0,1);return}if("}"===a)return void this.composeBraces(r)}r.attributes.set(s,a)}}composeLatex(t,e,r,s){if(!t.childNodes[r]||!t.childNodes[s])return;const n=mt.Attr.LATEX,i=(t.childNodes[r].attributes.get(n)||"")+e+t.childNodes[s].attributes.get(n);t.attributes.set(n,i)}composeBraces(t){const e=this.composeBracedContent(t);t.attributes.set(mt.Attr.LATEX,`{${e}}`)}composeBracedContent(t){var e,r;const s=(null===(e=t.childNodes[0])||void 0===e?void 0:e.childNodes)||[];let n="";for(const t of s){const e=(null===(r=null==t?void 0:t.attributes)||void 0===r?void 0:r.get(mt.Attr.LATEX))||"";e&&(n+=n&&n.match(/[a-zA-Z]$/)&&e.match(/^[a-zA-Z]/)?" "+e:e)}return n}}const Et=MathJax._.core.Tree.Factory.AbstractFactory;class St extends Tt{}class Ot extends Et{constructor(){super(...arguments),this.defaultKind="dummy",this.configuration=null}}Ot.DefaultStackItems={[St.prototype.kind]:St};const It=Ot;class Nt{constructor(){this.mmlFactory=null,this.factory={node:Nt.createNode,token:Nt.createToken,text:Nt.createText,error:Nt.createError}}static createNode(t,e,r=[],s={},n){const i=t.mmlFactory.create(e);return i.setChildren(r),n&&i.appendChild(n),ht.setProperties(i,s),i}static createToken(t,e,r={},s=""){const n=t.create("text",s);return t.create("node",e,[],r,n)}static createText(t,e){return null==e?null:t.mmlFactory.create("text").setText(e)}static createError(t,e){const r=t.create("text",e),s=t.create("node","mtext",[],{},r);return t.create("node","merror",[s],{"data-mjx-error":e})}setMmlFactory(t){this.mmlFactory=t}set(t,e){this.factory[t]=e}setCreators(t){for(const e in t)this.set(e,t[e])}create(t,...e){const r=(this.factory[t]||this.factory.node)(this,e[0],...e.slice(1));return"node"===t&&this.configuration.addNode(e[0],r),r}get(t){return this.factory[t]}}const Lt=MathJax._.util.Entities,Ft=(Lt.options,Lt.entities);Lt.add,Lt.remove,Lt.translate,Lt.numeric;class Rt{static oneof(...t){return new this("string",(e=>t.includes(e)),(t=>t))}constructor(t,e,r){this.name=t,this.verify=e,this.convert=r}}const Dt={boolean:new Rt("boolean",(t=>"true"===t||"false"===t),(t=>"true"===t)),number:new Rt("number",(t=>!!t.match(/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[-+]?\d+)?$/)),(t=>parseFloat(t))),integer:new Rt("integer",(t=>!!t.match(/^[-+]?\d+$/)),(t=>parseInt(t))),string:new Rt("string",(t=>!0),(t=>t)),dimen:new Rt("dimen",(t=>null!==kt.matchDimen(t)[0]),(t=>t))};function Bt(t,e){if(0===e)return t.replace(/^\s+/,"").replace(/([^\\\s]|^)((?:\\\\)*(?:\\\s)?)?\s+$/,"$1$2");for(;e>0;)t=t.trim().slice(1,-1),e--;return t}function Gt(t,e,r=!1,s=!1){const n=t.length;let i=0,a="",o=0,c=0,l=!0;for(;o<n;){const s=t[o++];switch(s){case"\\":a+=s+(t[o++]||""),l=!1;continue;case" ":break;case"{":l&&c++,i++;break;case"}":if(!i)throw new xt("ExtraCloseMissingOpen","Extra close brace or missing open brace");i--,l=!1;break;default:if(!i&&e.includes(s))return[Bt(a,r?Math.min(1,c):c),s,t.slice(o)];c>i&&(c=i),l=!1}a+=s}if(i)throw new xt("ExtraOpenMissingClose","Extra open brace or missing close brace");return s&&c?["","",Bt(a,1)]:[Bt(a,r?Math.min(1,c):c),"",t.slice(o)]}const qt={cols:(...t)=>t.map((t=>kt.em(t))).join(" "),fenced(t,e,r,s,n="",i=""){const a=t.nodeFactory,o=a.create("node","mrow",[],{open:e,close:s,texClass:it.INNER});let c;if(n)c=new Ct("\\"+n+"l"+e,t.parser.stack.env,t).mml();else{const t=a.create("text",e);c=a.create("node","mo",[],{fence:!0,stretchy:!0,symmetric:!0,texClass:it.OPEN},t)}if(ht.appendChildren(o,[c,r]),n)c=new Ct("\\"+n+"r"+s,t.parser.stack.env,t).mml();else{const t=a.create("text",s);c=a.create("node","mo",[],{fence:!0,stretchy:!0,symmetric:!0,texClass:it.CLOSE},t)}return i&&c.attributes.set("mathcolor",i),ht.appendChildren(o,[c]),o},fixedFence(t,e,r,s){const n=t.nodeFactory.create("node","mrow",[],{open:e,close:s,texClass:it.ORD});return e&&ht.appendChildren(n,[qt.mathPalette(t,e,"l")]),ht.isType(r,"mrow")?ht.appendChildren(n,ht.getChildren(r)):ht.appendChildren(n,[r]),s&&ht.appendChildren(n,[qt.mathPalette(t,s,"r")]),n},mathPalette(t,e,r){"{"!==e&&"}"!==e||(e="\\"+e);const s="{\\big"+r+" "+e+"}";return new Ct("\\mathchoice"+("{\\bigg"+r+" "+e+"}")+s+s+s,{},t).mml()},fixInitialMO(t,e){for(let r=0,s=e.length;r<s;r++){const s=e[r];if(s&&!ht.isType(s,"mspace")&&(!ht.isType(s,"TeXAtom")||ht.getChildren(s)[0]&&ht.getChildren(ht.getChildren(s)[0]).length)){if(ht.isEmbellished(s)||ht.isType(s,"TeXAtom")&&ht.getTexClass(s)===it.REL){const r=t.nodeFactory.create("node","mi");e.unshift(r)}break}}},internalMath(t,e,r,s){if(e=e.replace(/ +/g," "),t.configuration.options.internalMath)return t.configuration.options.internalMath(t,e,r,s);const n=s||t.stack.env.font,i=n?{mathvariant:n}:{};let a,o,c=[],l=0,h=0,m="",d=0;if(e.match(/\\?[${}\\]|\\\(|\\(?:eq)?ref\s*\{|\\U/)){for(;l<e.length;)if(a=e.charAt(l++),"$"===a)"$"===m&&0===d?(o=t.create("node","TeXAtom",[new Ct(e.slice(h,l-1),{},t.configuration).mml()]),c.push(o),m="",h=l):""===m&&(h<l-1&&c.push(qt.internalText(t,e.slice(h,l-1),i)),m="$",h=l);else if("{"===a&&""!==m)d++;else if("}"===a)if("}"===m&&0===d){const r=new Ct(e.slice(h,l),{},t.configuration).mml();o=t.create("node","TeXAtom",[r],i),c.push(o),m="",h=l}else""!==m&&d&&d--;else if("\\"===a)if(""===m&&e.substring(l).match(/^(eq)?ref\s*\{/)){const r=RegExp["$&"].length;h<l-1&&c.push(qt.internalText(t,e.slice(h,l-1),i)),m="}",h=l-1,l+=r}else if(a=e.charAt(l++),"("===a&&""===m)h<l-2&&c.push(qt.internalText(t,e.slice(h,l-2),i)),m=")",h=l;else if(")"===a&&")"===m&&0===d)o=t.create("node","TeXAtom",[new Ct(e.slice(h,l-2),{},t.configuration).mml()]),c.push(o),m="",h=l;else if(a.match(/[${}\\]/)&&""===m)l--,e=e.substring(0,l-1)+e.substring(l);else if("U"===a){const t=e.substring(l).match(/^\s*(?:([0-9A-F])|\{\s*([0-9A-F]+)\s*\})/);if(!t)throw new xt("BadRawUnicode","Argument to %1 must a hexadecimal number with 1 to 6 digits","\\U");const r=String.fromCodePoint(parseInt(t[1]||t[2],16));e=e.substring(0,l-2)+r+e.substring(l+t[0].length),l=l-2+r.length}if(""!==m)throw new xt("MathNotTerminated","Math mode is not properly terminated")}return h<e.length&&c.push(qt.internalText(t,e.slice(h),i)),null!=r?c=[t.create("node","mstyle",c,{displaystyle:!1,scriptlevel:r})]:c.length>1&&(c=[t.create("node","mrow",c)]),c},internalText(t,e,r){e=e.replace(/\n+/g," ").replace(/^ +/,Ft.nbsp).replace(/ +$/,Ft.nbsp);const s=t.create("text",e);return t.create("node","mtext",[],r,s)},underOver(t,e,r,s,n){if(qt.checkMovableLimits(e),ht.isType(e,"munderover")&&ht.isEmbellished(e)){ht.setProperties(ht.getCoreMO(e),{lspace:0,rspace:0});const r=t.create("node","mo",[],{rspace:0});e=t.create("node","mrow",[r,e])}const i=t.create("node","munderover",[e]);ht.setChild(i,"over"===s?i.over:i.under,r);let a=i;return n&&(a=t.create("node","TeXAtom",[t.create("node","mstyle",[i],{displaystyle:!0,scriptlevel:0})],{texClass:it.OP,movesupsub:!0})),ht.setProperty(a,"subsupOK",!0),a},checkMovableLimits(t){const e=ht.isType(t,"mo")?ht.getForm(t):null;(ht.getProperty(t,"movablelimits")||e&&e[3]&&e[3].movablelimits)&&ht.setProperties(t,{movablelimits:!1})},setArrayAlign:(t,e,r)=>(r||(e=kt.trimSpaces(e||"")),"t"===e?t.arraydef.align="baseline 1":"b"===e?t.arraydef.align="baseline -1":"c"===e?t.arraydef.align="axis":e&&(r?(r.string=`[${e}]`+r.string.slice(r.i),r.i=0):t.arraydef.align=e),t),substituteArgs(t,e,r){let s="",n="",i=0;for(;i<r.length;){let a=r.charAt(i++);if("\\"===a)s+=a+r.charAt(i++);else if("#"===a)if(a=r.charAt(i++),"#"===a)s+=a;else{if(!a.match(/[1-9]/)||parseInt(a,10)>e.length)throw new xt("IllegalMacroParam","Illegal macro parameter reference");n=qt.addArgs(t,qt.addArgs(t,n,s),e[parseInt(a,10)-1]),s=""}else s+=a}return qt.addArgs(t,n,s)},addArgs(t,e,r){if(r.match(/^[a-z]/i)&&e.match(/(^|[^\\])(\\\\)*\\[a-z]+$/i)&&(e+=" "),e.length+r.length>t.configuration.options.maxBuffer)throw new xt("MaxBufferSize","MathJax internal buffer size exceeded; is there a recursive macro call?");return e+r},checkMaxMacros(t,e=!0){if(!(++t.macroCount<=t.configuration.options.maxMacros))throw e?new xt("MaxMacroSub1","MathJax maximum macro substitution count exceeded; is here a recursive macro call?"):new xt("MaxMacroSub2","MathJax maximum substitution count exceeded; is there a recursive latex environment?")},checkEqnEnv(t,e=!0){const r=t.stack.Top(),s=r.First;if(!(r.getProperty("nestable")&&e&&!s||r.getProperty("nestStart"))&&(!r.isKind("start")||s))throw new xt("ErroneousNestingEq","Erroneous nesting of equation structures")},copyNode(t,e){const r=t.copy(),s=e.configuration;return r.walkTree((t=>{s.addNode(t.kind,t);const e=(t.getProperty("in-lists")||"").split(/,/);for(const r of e)r&&s.addNode(r,t)})),r},mmlFilterAttribute:(t,e,r)=>r,getFontDef(t){const e=t.stack.env.font;return e?{mathvariant:e}:{}},keyvalOptions(t,e=null,r=!1,s=!1){const n=function(t,e=!1){const r={};let s,n,i,a=t,o=!0;for(;a;)[n,s,a]=Gt(a,["=",","],e,o),o=!1,"="===s?([i,s,a]=Gt(a,[","],e),i="false"===i||"true"===i?JSON.parse(i):i,r[n]=i):n&&(r[n]=!0);return r}(t,s);if(e)for(const t of Object.keys(n))if(Object.hasOwn(e,t)){if(e[t]instanceof Rt){const r=e[t],s=String(n[t]);if(!r.verify(s))throw new xt("InvalidValue","Value for key '%1' is not of the expected type",t);n[t]=r.convert(s)}}else{if(r)throw new xt("InvalidOption","Invalid option: %1",t);delete n[t]}return n},isLatinOrGreekChar:t=>!!t.normalize("NFD").match(/[a-zA-Z\u0370-\u03F0]/)};class _t{constructor(){this.columnHandler={l:t=>t.calign[t.j++]="left",c:t=>t.calign[t.j++]="center",r:t=>t.calign[t.j++]="right",p:t=>this.getColumn(t,"top"),m:t=>this.getColumn(t,"middle"),b:t=>this.getColumn(t,"bottom"),w:t=>this.getColumn(t,"top",""),W:t=>this.getColumn(t,"top",""),"|":t=>this.addRule(t,"solid"),":":t=>this.addRule(t,"dashed"),">":t=>t.cstart[t.j]=(t.cstart[t.j]||"")+this.getBraces(t),"<":t=>t.cend[t.j-1]=(t.cend[t.j-1]||"")+this.getBraces(t),"@":t=>this.addAt(t,this.getBraces(t)),"!":t=>this.addBang(t,this.getBraces(t)),"*":t=>this.repeat(t),P:t=>this.macroColumn(t,">{$}p{#1}<{$}",1),M:t=>this.macroColumn(t,">{$}m{#1}<{$}",1),B:t=>this.macroColumn(t,">{$}b{#1}<{$}",1)," ":t=>{}},this.MAXCOLUMNS=1e4}process(t,e,r){const s={parser:t,template:e,i:0,j:0,c:"",cwidth:[],calign:[],cspace:[],clines:[],cstart:r.cstart,cend:r.cend,ralign:r.ralign,cextra:r.cextra};let n=0;for(;s.i<s.template.length;){if(n++>this.MAXCOLUMNS)throw new xt("MaxColumns","Too many column specifiers (perhaps looping column definitions?)");const t=s.template.codePointAt(s.i),e=s.c=String.fromCodePoint(t);if(s.i+=e.length,!Object.hasOwn(this.columnHandler,e))throw new xt("BadPreamToken","Illegal pream-token (%1)",e);this.columnHandler[e](s)}this.setColumnAlign(s,r),this.setColumnWidths(s,r),this.setColumnSpacing(s,r),this.setColumnLines(s,r),this.setPadding(s,r)}setColumnAlign(t,e){e.arraydef.columnalign=t.calign.join(" ")}setColumnWidths(t,e){if(!t.cwidth.length)return;const r=[...t.cwidth];r.length<t.calign.length&&r.push("auto"),e.arraydef.columnwidth=r.map((t=>t||"auto")).join(" ")}setColumnSpacing(t,e){if(!t.cspace.length)return;const r=[...t.cspace];r.length<t.calign.length&&r.push("1em"),e.arraydef.columnspacing=r.slice(1).map((t=>t||"1em")).join(" ")}setColumnLines(t,e){if(!t.clines.length)return;const r=[...t.clines];r[0]&&e.frame.push(["left",r[0]]),r.length>t.calign.length?e.frame.push(["right",r.pop()]):r.length<t.calign.length&&r.push("none"),r.length>1&&(e.arraydef.columnlines=r.slice(1).map((t=>t||"none")).join(" "))}setPadding(t,e){if(!t.cextra[0]&&!t.cextra[t.calign.length-1])return;const r=t.calign.length-1,s=t.cspace,n=t.cextra[r]?s[r]:null;e.arraydef["data-array-padding"]=`${s[0]||".5em"} ${n||".5em"}`}getColumn(t,e,r="left"){t.calign[t.j]=r||this.getAlign(t),t.cwidth[t.j]=this.getDimen(t),t.ralign[t.j]=[e,t.cwidth[t.j],t.calign[t.j]],t.j++}getDimen(t){const e=this.getBraces(t);if(!kt.matchDimen(e)[0])throw new xt("MissingColumnDimOrUnits","Missing dimension or its units for %1 column declaration",t.c);return e}getAlign(t){const e=this.getBraces(t);return J(e.toLowerCase(),{l:"left",c:"center",r:"right"},"")}getBraces(t){for(;" "===t.template[t.i];)t.i++;if(t.i>=t.template.length)throw new xt("MissingArgForColumn","Missing argument for %1 column declaration",t.c);if("{"!==t.template[t.i])return t.template[t.i++];const e=++t.i;let r=1;for(;t.i<t.template.length;)switch(t.template.charAt(t.i++)){case"\\":t.i++;break;case"{":r++;break;case"}":if(0===--r)return t.template.slice(e,t.i-1)}throw new xt("MissingCloseBrace","Missing close brace")}macroColumn(t,e,r){const s=[];for(;r>0&&r--;)s.push(this.getBraces(t));t.template=qt.substituteArgs(t.parser,s,e)+t.template.slice(t.i),t.i=0}addRule(t,e){t.clines[t.j]&&this.addAt(t,"\\,"),t.clines[t.j]=e,"0"===t.cspace[t.j]&&(t.cstart[t.j]="\\hspace{.5em}")}addAt(t,e){const{cstart:r,cspace:s,j:n}=t;t.cextra[n]=!0,t.calign[n]="center",t.clines[n]&&(".5em"===s[n]?r[n-1]+="\\hspace{.25em}":s[n]||(t.cend[n-1]=(t.cend[n-1]||"")+"\\hspace{.5em}")),r[n]=e,s[n]="0",s[++t.j]="0"}addBang(t,e){const{cstart:r,cspace:s,j:n}=t;t.cextra[n]=!0,t.calign[n]="center",r[n]=("0"===s[n]&&t.clines[n]?"\\hspace{.25em}":"")+e,s[n]||(s[n]=".5em"),s[++t.j]=".5em"}repeat(t){const e=this.getBraces(t),r=this.getBraces(t),s=parseInt(e);if(String(s)!==e)throw new xt("ColArgNotNum","First argument to %1 column specifier must be a number","*");t.template=new Array(s).fill(r).join("")+t.template.substring(t.i),t.i=0}}const Ht=mt.Variant;class jt{constructor(t,e=[]){this.options={},this.columnParser=new _t,this.packageData=new Map,this.parsers=[],this.root=null,this.nodeLists={},this.error=!1,this.handlers=t.handlers,this.nodeFactory=new Nt,this.nodeFactory.configuration=this,this.nodeFactory.setCreators(t.nodes),this.itemFactory=new It(t.items),this.itemFactory.configuration=this,X(this.options,...e),X(this.options,t.options),this.mathStyle=jt.getVariant.get(this.options.mathStyle)||jt.getVariant.get("TeX")}pushParser(t){this.parsers.unshift(t)}popParser(){this.parsers.shift()}get parser(){return this.parsers[0]}clear(){this.parsers=[],this.root=null,this.nodeLists={},this.error=!1,this.tags.resetTag()}addNode(t,e){let r=this.nodeLists[t];if(r||(r=this.nodeLists[t]=[]),r.push(e),e.kind!==t){const r=ht.getProperty(e,"in-lists")||"",s=(r?r.split(/,/):[]).concat(t).join(",");ht.setProperty(e,"in-lists",s)}}getList(t){const e=this.nodeLists[t]||[],r=[];for(const t of e)this.inTree(t)&&r.push(t);return this.nodeLists[t]=r,r}removeFromList(t,e){const r=this.nodeLists[t]||[];for(const t of e){const e=r.indexOf(t);e>=0&&r.splice(e,1)}}inTree(t){for(;t&&t!==this.root;)t=t.parent;return!!t}}jt.getVariant=new Map([["TeX",(t,e)=>e&&t.match(/^[\u0391-\u03A9\u03F4]/)?Ht.NORMAL:""],["ISO",t=>Ht.ITALIC],["French",t=>t.normalize("NFD").match(/^[a-z]/)?Ht.ITALIC:Ht.NORMAL],["upright",t=>Ht.NORMAL]]);const Ut=jt;class Kt{constructor(t="???",e=""){this.tag=t,this.id=e}}class zt{constructor(t="",e=!1,r=!1,s=null,n="",i="",a=!1,o=""){this.env=t,this.taggable=e,this.defaultTags=r,this.tag=s,this.tagId=n,this.tagFormat=i,this.noTag=a,this.labelId=o}}class Xt{constructor(){this.counter=0,this.allCounter=0,this.configuration=null,this.ids={},this.allIds={},this.labels={},this.allLabels={},this.redo=!1,this.refUpdate=!1,this.currentTag=new zt,this.history=[],this.stack=[],this.enTag=function(t,e){const r=this.configuration.nodeFactory,s=r.create("node","mtd",[t]),n=r.create("node","mlabeledtr",[e,s]);return r.create("node","mtable",[n],{side:this.configuration.options.tagSide,minlabelspacing:this.configuration.options.tagIndent,displaystyle:!0})}}start(t,e,r){this.currentTag&&this.stack.push(this.currentTag);const s=this.label;this.currentTag=new zt(t,e,r),this.label=s}get env(){return this.currentTag.env}end(){this.history.push(this.currentTag);const t=this.label;this.currentTag=this.stack.pop(),t&&!this.label&&(this.label=t)}tag(t,e){this.currentTag.tag=t,this.currentTag.tagFormat=e?t:this.formatTag(t),this.currentTag.noTag=!1}notag(){this.tag("",!0),this.currentTag.noTag=!0}get noTag(){return this.currentTag.noTag}set label(t){this.currentTag.labelId=t}get label(){return this.currentTag.labelId}formatUrl(t,e){return e+"#"+encodeURIComponent(t)}formatTag(t){return["(",t,")"]}formatRef(t){return this.formatTag(t)}formatId(t){return"mjx-eqn:"+t.replace(/\s/g,"_")}formatNumber(t){return t.toString()}autoTag(){null==this.currentTag.tag&&(this.counter++,this.tag(this.formatNumber(this.counter),!1))}clearTag(){this.tag(null,!0),this.currentTag.tagId=""}getTag(t=!1){if(t)return this.autoTag(),this.makeTag();const e=this.currentTag;return e.taggable&&!e.noTag&&(e.defaultTags&&this.autoTag(),e.tag)?this.makeTag():null}resetTag(){this.history=[],this.redo=!1,this.refUpdate=!1,this.clearTag()}reset(t=0){this.resetTag(),this.counter=this.allCounter=t,this.allLabels={},this.allIds={},this.label=""}startEquation(t){this.history=[],this.stack=[],this.clearTag(),this.currentTag=new zt("",void 0,void 0),this.labels={},this.ids={},this.counter=this.allCounter,this.redo=!1;const e=t.inputData.recompile;e&&(this.refUpdate=!0,this.counter=e.counter)}finishEquation(t){this.redo&&(t.inputData.recompile={state:t.state(),counter:this.allCounter}),this.refUpdate||(this.allCounter=this.counter),Object.assign(this.allIds,this.ids),Object.assign(this.allLabels,this.labels)}finalize(t,e){if(!e.display||this.currentTag.env||null==this.currentTag.tag)return t;const r=this.makeTag();return this.enTag(t,r)}makeId(){this.currentTag.tagId=this.formatId(this.configuration.options.useLabelIds&&this.label||this.currentTag.tag)}makeTag(){var t;this.makeId(),this.label&&(this.labels[this.label]=new Kt(this.currentTag.tag,this.currentTag.tagId),this.label="");const e=this.currentTag.tagFormat,r=Array.isArray(e)?e:(null===(t=e.match(/^(\(|\[|\{)(.*)(\}|\]|\))$/))||void 0===t?void 0:t.slice(1))||[e],s=new Ct(r.map((t=>t?`\\text{${t}}`:"")).join(""),{},this.configuration).mml();return this.configuration.nodeFactory.create("node","mtd",[s],{id:this.currentTag.tagId,rowalign:this.configuration.options.tagAlign})}}class $t extends Xt{autoTag(){}getTag(){return this.currentTag.tag?super.getTag():null}}class Vt extends Xt{finalize(t,e){if(!e.display||this.history.find((function(t){return t.taggable})))return t;const r=this.getTag(!0);return this.enTag(t,r)}}const Jt=new Map([["none",$t],["all",Vt]]);let Wt="none";const Yt={OPTIONS:{tags:Wt,tagSide:"right",tagIndent:"0.8em",useLabelIds:!0,ignoreDuplicateLabels:!1,tagAlign:"baseline"},add(t,e){Jt.set(t,e)},addTags(t){for(const e of Object.keys(t))Yt.add(e,t[e])},create(t){const e=Jt.get(t)||Jt.get(Wt);if(!e)throw Error("Unknown tags class");return new e},setDefault(t){Wt=t},getDefault:()=>Yt.create(Wt)};class Qt{constructor(t,e,r){this._token=t,this._char=e,this._attributes=r}get token(){return this._token}get char(){return this._char}get attributes(){return this._attributes}}class Zt{constructor(t,e,r=[]){this._token=t,this._func=e,this._args=r}get token(){return this._token}get func(){return this._func}get args(){return this._args}}function te(t){return void 0===t||t}class ee{constructor(t,e){this._name=t,this._parser=e,de.register(this)}get name(){return this._name}parserFor(t){return this.contains(t)?this.parser:null}parse([t,e]){const r=this.parserFor(e),s=this.lookup(e);return r&&s?te(r(t,s)):null}set parser(t){this._parser=t}get parser(){return this._parser}}class re extends ee{constructor(t,e,r){super(t,e),this._regExp=r}contains(t){return this._regExp.test(t)}lookup(t){return this.contains(t)?t:null}}class se extends ee{constructor(){super(...arguments),this.map=new Map}lookup(t){return this.map.get(t)}contains(t){return this.map.has(t)}add(t,e){this.map.set(t,e)}remove(t){this.map.delete(t)}}class ne extends se{constructor(t,e,r){super(t,e);for(const t of Object.keys(r)){const e=r[t],[s,n]="string"==typeof e?[e,null]:e,i=new Qt(t,s,n);this.add(t,i)}}}class ie extends ne{parse([t,e]){return super.parse([t,"\\"+e])}}class ae extends se{constructor(t,e,r={}){super(t,null);const s=t=>"string"==typeof t?r[t]:t;for(const[t,r]of Object.entries(e)){let e,n;Array.isArray(r)?(e=s(r[0]),n=r.slice(1)):(e=s(r),n=[]);const i=new Zt(t,e,n);this.add(t,i)}}parserFor(t){const e=this.lookup(t);return e?e.func:null}parse([t,e]){const r=this.lookup(e),s=this.parserFor(e);return r&&s?te(s(t,r.token,...r.args)):null}}class oe extends ae{parse([t,e]){const r=this.lookup(e),s=this.parserFor(e);if(!r||!s)return null;const n=t.currentCS;t.currentCS="\\"+e;const i=s(t,"\\"+r.token,...r.args);return t.currentCS=n,te(i)}}class ce extends ae{constructor(t,e,r,s={}){super(t,r,s),this.parser=e}parse([t,e]){const r=this.lookup(e),s=this.parserFor(e);return r&&s?te(this.parser(t,r.token,s,r.args)):null}}const le=MathJax._.util.PrioritizedList.PrioritizedList,he=MathJax._.util.FunctionList.FunctionList,me=new Map,de={register(t){me.set(t.name,t)},getMap:t=>me.get(t)};class ue{constructor(){this._configuration=new le,this._fallback=new he}add(t,e,r=le.DEFAULTPRIORITY){for(const e of t.slice().reverse()){const t=de.getMap(e);if(!t)return void this.warn(`Configuration '${e}' not found! Omitted.`);this._configuration.add(t,r)}e&&this._fallback.add(e,r)}remove(t,e=null){for(const e of t){const t=this.retrieve(e);t&&this._configuration.remove(t)}e&&this._fallback.remove(e)}parse(t){for(const{item:e}of this._configuration){const r=e.parse(t);if(r===ue.FALLBACK)break;if(r)return r}const[e,r]=t;Array.from(this._fallback)[0].item(e,r)}lookup(t){const e=this.applicable(t);return e?e.lookup(t):null}contains(t){const e=this.applicable(t);return!(!e||e instanceof ne&&null===e.lookup(t).char)}toString(){const t=[];for(const{item:e}of this._configuration)t.push(e.name);return t.join(", ")}applicable(t){for(const{item:e}of this._configuration)if(e.contains(t))return e;return null}retrieve(t){for(const{item:e}of this._configuration)if(e.name===t)return e;return null}warn(t){console.log("TexParser Warning: "+t)}}ue.FALLBACK=Symbol("fallback");class ge{constructor(){this.map=new Map}add(t,e,r=le.DEFAULTPRIORITY){for(const s of Object.keys(t)){const n=s;let i=this.get(n);i||(i=new ue,this.set(n,i)),i.add(t[n],e[n],r)}}remove(t,e){for(const r of Object.keys(t)){const s=this.get(r);s&&s.remove(t[r],e[r])}}set(t,e){this.map.set(t,e)}get(t){return this.map.get(t)}retrieve(t){for(const e of this.map.values()){const r=e.retrieve(t);if(r)return r}return null}keys(){return this.map.keys()}}class pe{static makeProcessor(t,e){return Array.isArray(t)?t:[t,e]}static _create(t,e={}){var r;const s=null!==(r=e.priority)&&void 0!==r?r:le.DEFAULTPRIORITY,n=e.init?this.makeProcessor(e.init,s):null,i=e.config?this.makeProcessor(e.config,s):null,a=(e.preprocessors||[]).map((t=>this.makeProcessor(t,s))),o=(e.postprocessors||[]).map((t=>this.makeProcessor(t,s))),c=e.parser||"tex";return new pe(t,e[At.HANDLER]||{},e[At.FALLBACK]||{},e[At.ITEMS]||{},e[At.TAGS]||{},e[At.OPTIONS]||{},e[At.NODES]||{},a,o,n,i,s,c)}static create(t,e={}){const r=pe._create(t,e);return be.set(t,r),r}static local(t={}){return pe._create("",t)}constructor(t,e={},r={},s={},n={},i={},a={},o=[],c=[],l=null,h=null,m,d){this.name=t,this.handler=e,this.fallback=r,this.items=s,this.tags=n,this.options=i,this.nodes=a,this.preprocessors=o,this.postprocessors=c,this.initMethod=l,this.configMethod=h,this.priority=m,this.parser=d,this.handler=Object.assign({[yt.CHARACTER]:[],[yt.DELIMITER]:[],[yt.MACRO]:[],[yt.ENVIRONMENT]:[]},e)}get init(){return this.initMethod?this.initMethod[0]:null}get config(){return this.configMethod?this.configMethod[0]:null}}const fe=new Map,be={set(t,e){fe.set(t,e)},get:t=>fe.get(t),keys:()=>fe.keys()};class Ae{constructor(t,e=["tex"]){this.initMethod=new he,this.configMethod=new he,this.configurations=new le,this.parsers=[],this.handlers=new ge,this.items={},this.tags={},this.options={},this.nodes={},this.parsers=e;for(const e of t.slice().reverse())this.addPackage(e);for(const{item:t,priority:e}of this.configurations)this.append(t,e)}init(){this.initMethod.execute(this)}config(t){this.configMethod.execute(this,t);for(const e of this.configurations)this.addFilters(t,e.item)}addPackage(t){const e="string"==typeof t?t:t[0],r=this.getPackage(e);r&&this.configurations.add(r,"string"==typeof t?r.priority:t[1])}add(t,e,r={}){const s=this.getPackage(t);this.append(s),this.configurations.add(s,s.priority),this.init();const n=e.parseOptions;n.nodeFactory.setCreators(s.nodes);for(const t of Object.keys(s.items))n.itemFactory.setNodeClass(t,s.items[t]);Yt.addTags(s.tags),X(n.options,s.options),$(n.options,r),this.addFilters(e,s),s.config&&s.config(this,e)}getPackage(t){const e=be.get(t);if(e&&!this.parsers.includes(e.parser))throw Error(`Package '${t}' doesn't target the proper parser`);return e||this.warn(`Package '${t}' not found. Omitted.`),e}append(t,e){e=e||t.priority,t.initMethod&&this.initMethod.add(t.initMethod[0],t.initMethod[1]),t.configMethod&&this.configMethod.add(t.configMethod[0],t.configMethod[1]),this.handlers.add(t.handler,t.fallback,e),Object.assign(this.items,t.items),Object.assign(this.tags,t.tags),X(this.options,t.options),Object.assign(this.nodes,t.nodes)}addFilters(t,e){for(const[r,s]of e.preprocessors)t.preFilters.add(r,s);for(const[r,s]of e.postprocessors)t.postFilters.add(r,s)}warn(t){console.warn("MathJax Warning: "+t)}}const ye=MathJax._.util.Styles,ve=ye.TRBL;ye.WSC,ye.Styles;class ke extends Tt{construct