var w=class e{constructor(t,r){let o=" "+t,s,i=r&&r.loc;if(i&&i.start<=i.end){let u=i.lexer.input;s=i.start;let h=i.end;s===u.length?o+=" at end of input: ":o+=" at position "+(s+1)+": ";let x=u.slice(s,h).replace(/[^]/g,"$&\u0332"),A;s>15?A="\u2026"+u.slice(s-15,s):A=u.slice(0,s);let q;h+15":">","<":"<",'"':""","'":"'"},Ar=/[&><"']/g;function Sr(e){return String(e).replace(Ar,t=>kr[t])}var me=function(e){return e.type==="ordgroup"||e.type==="color"?e.body.length===1?me(e.body[0]):e:e.type==="font"?me(e.body):e},qr=function(e){let t=me(e);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},_r=function(e){if(!e)throw new Error("Expected non-null, but got "+String(e));return e},Tr=function(e){let t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?t[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():"_relative"},Cr=function(e){return+e.toFixed(4)},N={deflt:yr,escape:Sr,hyphenate:vr,getBaseElem:me,isCharacterBox:qr,protocolFromUrl:Tr,round:Cr},pe=class{constructor(t){t=t||{},this.displayMode=N.deflt(t.displayMode,!1),this.annotate=N.deflt(t.annotate,!1),this.leqno=N.deflt(t.leqno,!1),this.throwOnError=N.deflt(t.throwOnError,!1),this.errorColor=N.deflt(t.errorColor,"#b22222"),this.macros=t.macros||{},this.wrap=N.deflt(t.wrap,"tex"),this.xml=N.deflt(t.xml,!1),this.colorIsTextColor=N.deflt(t.colorIsTextColor,!1),this.strict=N.deflt(t.strict,!1),this.trust=N.deflt(t.trust,!1),this.maxSize=t.maxSize===void 0?[1/0,1/0]:Array.isArray(t.maxSize)?t.maxSize:[1/0,1/0],this.maxExpand=Math.max(0,N.deflt(t.maxExpand,1e3))}isTrusted(t){if(t.url&&!t.protocol){let o=N.protocolFromUrl(t.url);if(o==null)return!1;t.protocol=o}return!!(typeof this.trust=="function"?this.trust(t):this.trust)}},Ut={},Ce={};function S({type:e,names:t,props:r,handler:o,mathmlBuilder:s}){let i={type:e,numArgs:r.numArgs,argTypes:r.argTypes,allowedInArgument:!!r.allowedInArgument,allowedInText:!!r.allowedInText,allowedInMath:r.allowedInMath===void 0?!0:r.allowedInMath,numOptionalArgs:r.numOptionalArgs||0,infix:!!r.infix,primitive:!!r.primitive,handler:o};for(let l=0;lr.toText();return this.children.map(t).join("")}},ue=function(e){return e.filter(t=>t).join(" ")},Dr=function(e,t){this.classes=e||[],this.attributes={},this.style=t||{}},Br=function(e){let t=document.createElement(e);t.className=ue(this.classes);for(let r in this.style)Object.prototype.hasOwnProperty.call(this.style,r)&&(t.style[r]=this.style[r]);for(let r in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,r)&&t.setAttribute(r,this.attributes[r]);for(let r=0;r`,t},De=class{constructor(t,r,o){Dr.call(this,t,o),this.children=r||[]}setAttribute(t,r){this.attributes[t]=r}toNode(){return Br.call(this,"span")}toMarkup(){return Nr.call(this,"span")}},Or=class{constructor(t){this.text=t}toNode(){return document.createTextNode(this.text)}toMarkup(){return N.escape(this.text)}},be=class{constructor(t,r,o){this.href=t,this.classes=r,this.children=o||[]}toNode(){let t=document.createElement("a");t.setAttribute("href",this.href),this.classes.length>0&&(t.className=ue(this.classes));for(let r=0;r0&&(t+=` class="${N.escape(ue(this.classes))}"`),t+=">";for(let r=0;r0&&(t.className=ue(this.classes));for(let r in this.style)Object.prototype.hasOwnProperty.call(this.style,r)&&(t.style[r]=this.style[r]);for(let r=0;r0&&(t+=` class="${N.escape(ue(this.classes))}"`);let r="";for(let o in this.style)Object.prototype.hasOwnProperty.call(this.style,o)&&(r+=`${N.hyphenate(o)}:${this.style[o]};`);r&&(t+=` style="${r}"`),t+=">";for(let o=0;o",t}toText(){return this.children.map(t=>t.toText()).join("")}},ae=class{constructor(t){this.text=t}toNode(){return document.createTextNode(this.text)}toMarkup(){return N.escape(this.toText())}toText(){return this.text}},Je=e=>{let t;return e.length===1&&e[0].type==="mrow"?(t=e.pop(),t.type="mstyle"):t=new R("mstyle",e),t},p={MathNode:R,TextNode:ae,newDocumentFragment:$r},de=e=>{let t=0;if(e.body)for(let r of e.body)t+=de(r);else if(e.type==="supsub")t+=de(e.base),e.sub&&(t+=.7*de(e.sub)),e.sup&&(t+=.7*de(e.sup));else if(e.type==="mathord"||e.type==="textord")for(let r of e.text.split("")){let o=r.codePointAt(0);96{let t=Vt(e.label);if(Er.includes(e.label)){let r=de(e.base);1","\\gt",!0);n(a,d,"\u2208","\\in",!0);n(a,d,"\u2209","\\notin",!0);n(a,d,"\uE020","\\@not");n(a,d,"\u2282","\\subset",!0);n(a,d,"\u2283","\\supset",!0);n(a,d,"\u2286","\\subseteq",!0);n(a,d,"\u2287","\\supseteq",!0);n(a,d,"\u2288","\\nsubseteq",!0);n(a,d,"\u2288","\\nsubseteqq");n(a,d,"\u2289","\\nsupseteq",!0);n(a,d,"\u2289","\\nsupseteqq");n(a,d,"\u22A8","\\models");n(a,d,"\u2190","\\leftarrow",!0);n(a,d,"\u2264","\\le");n(a,d,"\u2264","\\leq",!0);n(a,d,"<","\\lt",!0);n(a,d,"\u2192","\\rightarrow",!0);n(a,d,"\u2192","\\to");n(a,d,"\u2271","\\ngeq",!0);n(a,d,"\u2271","\\ngeqq");n(a,d,"\u2271","\\ngeqslant");n(a,d,"\u2270","\\nleq",!0);n(a,d,"\u2270","\\nleqq");n(a,d,"\u2270","\\nleqslant");n(a,d,"\u2AEB","\\Perp",!0);n(a,ee,"\xA0","\\ ");n(a,ee,"\xA0","\\space");n(a,ee,"\xA0","\\nobreakspace");n(g,ee,"\xA0","\\ ");n(g,ee,"\xA0"," ");n(g,ee,"\xA0","\\space");n(g,ee,"\xA0","\\nobreakspace");n(a,ee,null,"\\nobreak");n(a,ee,null,"\\allowbreak");n(a,we,",",",");n(g,we,":",":");n(a,we,";",";");n(a,f,"\u22BC","\\barwedge");n(a,f,"\u22BB","\\veebar");n(a,f,"\u2299","\\odot",!0);n(a,f,"\u2295\uFE0E","\\oplus");n(a,f,"\u2297","\\otimes",!0);n(a,m,"\u2202","\\partial",!0);n(a,f,"\u2298","\\oslash",!0);n(a,f,"\u229A","\\circledcirc",!0);n(a,f,"\u22A1","\\boxdot",!0);n(a,f,"\u25B3","\\bigtriangleup");n(a,f,"\u25BD","\\bigtriangledown");n(a,f,"\u2020","\\dagger");n(a,f,"\u22C4","\\diamond");n(a,f,"\u25C3","\\triangleleft");n(a,f,"\u25B9","\\triangleright");n(a,P,"{","\\{");n(g,m,"{","\\{");n(g,m,"{","\\textbraceleft");n(a,L,"}","\\}");n(g,m,"}","\\}");n(g,m,"}","\\textbraceright");n(a,P,"{","\\lbrace");n(a,L,"}","\\rbrace");n(a,P,"[","\\lbrack",!0);n(g,m,"[","\\lbrack",!0);n(a,L,"]","\\rbrack",!0);n(g,m,"]","\\rbrack",!0);n(a,P,"(","\\lparen",!0);n(a,L,")","\\rparen",!0);n(a,P,"\u2987","\\llparenthesis",!0);n(a,L,"\u2988","\\rrparenthesis",!0);n(g,m,"<","\\textless",!0);n(g,m,">","\\textgreater",!0);n(a,P,"\u230A","\\lfloor",!0);n(a,L,"\u230B","\\rfloor",!0);n(a,P,"\u2308","\\lceil",!0);n(a,L,"\u2309","\\rceil",!0);n(a,m,"\\","\\backslash");n(a,m,"|","|");n(a,m,"|","\\vert");n(g,m,"|","\\textbar",!0);n(a,m,"\u2016","\\|");n(a,m,"\u2016","\\Vert");n(g,m,"\u2016","\\textbardbl");n(g,m,"~","\\textasciitilde");n(g,m,"\\","\\textbackslash");n(g,m,"^","\\textasciicircum");n(a,d,"\u2191","\\uparrow",!0);n(a,d,"\u21D1","\\Uparrow",!0);n(a,d,"\u2193","\\downarrow",!0);n(a,d,"\u21D3","\\Downarrow",!0);n(a,d,"\u2195","\\updownarrow",!0);n(a,d,"\u21D5","\\Updownarrow",!0);n(a,D,"\u2210","\\coprod");n(a,D,"\u22C1","\\bigvee");n(a,D,"\u22C0","\\bigwedge");n(a,D,"\u2A04","\\biguplus");n(a,D,"\u2A04","\\bigcupplus");n(a,D,"\u2A03","\\bigcupdot");n(a,D,"\u2A07","\\bigdoublevee");n(a,D,"\u2A08","\\bigdoublewedge");n(a,D,"\u22C2","\\bigcap");n(a,D,"\u22C3","\\bigcup");n(a,D,"\u222B","\\int");n(a,D,"\u222B","\\intop");n(a,D,"\u222C","\\iint");n(a,D,"\u222D","\\iiint");n(a,D,"\u220F","\\prod");n(a,D,"\u2211","\\sum");n(a,D,"\u2A02","\\bigotimes");n(a,D,"\u2A01","\\bigoplus");n(a,D,"\u2A00","\\bigodot");n(a,D,"\u2A09","\\bigtimes");n(a,D,"\u222E","\\oint");n(a,D,"\u222F","\\oiint");n(a,D,"\u2230","\\oiiint");n(a,D,"\u2231","\\intclockwise");n(a,D,"\u2232","\\varointclockwise");n(a,D,"\u2A0C","\\iiiint");n(a,D,"\u2A0D","\\intbar");n(a,D,"\u2A0E","\\intBar");n(a,D,"\u2A0F","\\fint");n(a,D,"\u2A12","\\rppolint");n(a,D,"\u2A13","\\scpolint");n(a,D,"\u2A15","\\pointint");n(a,D,"\u2A16","\\sqint");n(a,D,"\u2A17","\\intlarhk");n(a,D,"\u2A18","\\intx");n(a,D,"\u2A19","\\intcap");n(a,D,"\u2A1A","\\intcup");n(a,D,"\u2A05","\\bigsqcap");n(a,D,"\u2A06","\\bigsqcup");n(a,D,"\u222B","\\smallint");n(g,ie,"\u2026","\\textellipsis");n(a,ie,"\u2026","\\mathellipsis");n(g,ie,"\u2026","\\ldots",!0);n(a,ie,"\u2026","\\ldots",!0);n(a,ie,"\u22F0","\\iddots",!0);n(a,ie,"\u22EF","\\@cdots",!0);n(a,ie,"\u22F1","\\ddots",!0);n(a,m,"\u22EE","\\varvdots");n(g,m,"\u22EE","\\varvdots");n(a,B,"\u02CA","\\acute");n(a,B,"`","\\grave");n(a,B,"\xA8","\\ddot");n(a,B,"\u2026","\\dddot");n(a,B,"\u2026.","\\ddddot");n(a,B,"~","\\tilde");n(a,B,"\u203E","\\bar");n(a,B,"\u02D8","\\breve");n(a,B,"\u02C7","\\check");n(a,B,"^","\\hat");n(a,B,"\u2192","\\vec");n(a,B,"\u02D9","\\dot");n(a,B,"\u02DA","\\mathring");n(a,v,"\u0131","\\imath",!0);n(a,v,"\u0237","\\jmath",!0);n(a,m,"\u0131","\u0131");n(a,m,"\u0237","\u0237");n(g,m,"\u0131","\\i",!0);n(g,m,"\u0237","\\j",!0);n(g,m,"\xDF","\\ss",!0);n(g,m,"\xE6","\\ae",!0);n(g,m,"\u0153","\\oe",!0);n(g,m,"\xF8","\\o",!0);n(a,v,"\xF8","\\o",!0);n(g,m,"\xC6","\\AE",!0);n(g,m,"\u0152","\\OE",!0);n(g,m,"\xD8","\\O",!0);n(a,v,"\xD8","\\O",!0);n(g,B,"\u02CA","\\'");n(g,B,"\u02CB","\\`");n(g,B,"\u02C6","\\^");n(g,B,"\u02DC","\\~");n(g,B,"\u02C9","\\=");n(g,B,"\u02D8","\\u");n(g,B,"\u02D9","\\.");n(g,B,"\xB8","\\c");n(g,B,"\u02DA","\\r");n(g,B,"\u02C7","\\v");n(g,B,"\xA8",'\\"');n(g,B,"\u02DD","\\H");n(a,B,"\u02CA","\\'");n(a,B,"\u02CB","\\`");n(a,B,"\u02C6","\\^");n(a,B,"\u02DC","\\~");n(a,B,"\u02C9","\\=");n(a,B,"\u02D8","\\u");n(a,B,"\u02D9","\\.");n(a,B,"\xB8","\\c");n(a,B,"\u02DA","\\r");n(a,B,"\u02C7","\\v");n(a,B,"\xA8",'\\"');n(a,B,"\u02DD","\\H");var Ir={"--":!0,"---":!0,"``":!0,"''":!0};n(g,m,"\u2013","--",!0);n(g,m,"\u2013","\\textendash");n(g,m,"\u2014","---",!0);n(g,m,"\u2014","\\textemdash");n(g,m,"\u2018","`",!0);n(g,m,"\u2018","\\textquoteleft");n(g,m,"\u2019","'",!0);n(g,m,"\u2019","\\textquoteright");n(g,m,"\u201C","``",!0);n(g,m,"\u201C","\\textquotedblleft");n(g,m,"\u201D","''",!0);n(g,m,"\u201D","\\textquotedblright");n(a,m,"\xB0","\\degree",!0);n(g,m,"\xB0","\\degree");n(g,m,"\xB0","\\textdegree",!0);n(a,m,"\xA3","\\pounds");n(a,m,"\xA3","\\mathsterling",!0);n(g,m,"\xA3","\\pounds");n(g,m,"\xA3","\\textsterling",!0);n(a,m,"\u2720","\\maltese");n(g,m,"\u2720","\\maltese");n(a,m,"\u20AC","\\euro",!0);n(g,m,"\u20AC","\\euro",!0);n(g,m,"\u20AC","\\texteuro");n(a,m,"\xA9","\\copyright",!0);n(g,m,"\xA9","\\textcopyright");n(a,m,"\u2300","\\diameter",!0);n(g,m,"\u2300","\\diameter");n(a,m,"\u{1D6E4}","\\varGamma");n(a,m,"\u{1D6E5}","\\varDelta");n(a,m,"\u{1D6E9}","\\varTheta");n(a,m,"\u{1D6EC}","\\varLambda");n(a,m,"\u{1D6EF}","\\varXi");n(a,m,"\u{1D6F1}","\\varPi");n(a,m,"\u{1D6F4}","\\varSigma");n(a,m,"\u{1D6F6}","\\varUpsilon");n(a,m,"\u{1D6F7}","\\varPhi");n(a,m,"\u{1D6F9}","\\varPsi");n(a,m,"\u{1D6FA}","\\varOmega");n(g,m,"\u{1D6E4}","\\varGamma");n(g,m,"\u{1D6E5}","\\varDelta");n(g,m,"\u{1D6E9}","\\varTheta");n(g,m,"\u{1D6EC}","\\varLambda");n(g,m,"\u{1D6EF}","\\varXi");n(g,m,"\u{1D6F1}","\\varPi");n(g,m,"\u{1D6F4}","\\varSigma");n(g,m,"\u{1D6F6}","\\varUpsilon");n(g,m,"\u{1D6F7}","\\varPhi");n(g,m,"\u{1D6F9}","\\varPsi");n(g,m,"\u{1D6FA}","\\varOmega");var ut='0123456789/@."';for(let e=0;e0&&s.push(new p.MathNode("mrow",i)),s.push(x),i=[];let A=new p.MathNode("mtd",s);A.style.textAlign="left",o.push(new p.MathNode("mtr",[A])),s=[],u+=1;continue}if(i.push(x),x.type&&x.type==="mo"&&x.children.length===1&&!Object.hasOwn(x.attributes,"movablelimits")){let A=x.children[0].text;if(Pr.indexOf(A)>-1)h+=1;else if(Gr.indexOf(A)>-1)h-=1;else if(h===0&&t==="="&&A==="="){if(l+=1,l>1){i.pop();let q=new p.MathNode("mrow",i);s.push(q),i=[x]}}else if(h===0&&t==="tex"&&A!=="\u2207"){let q=u0){let x=new p.MathNode("mrow",i);s.push(x)}if(o.length>0){let x=new p.MathNode("mtd",s);x.style.textAlign="left";let A=new p.MathNode("mtr",[x]);o.push(A);let q=new p.MathNode("mtable",o);return r||(q.setAttribute("columnalign","left"),q.setAttribute("rowspacing","0em")),q}return p.newDocumentFragment(s)}var W=function(e,t,r){return I[t][e]&&I[t][e].replace&&e.charCodeAt(0)!==55349&&!(Object.prototype.hasOwnProperty.call(Ir,e)&&r&&(r.fontFamily&&r.fontFamily.slice(4,6)==="tt"||r.font&&r.font.slice(4,6)==="tt"))&&(e=I[t][e].replace),new p.TextNode(e)},mt=(e,t)=>{if(e.children.length===0||e.children[e.children.length-1].type!=="mtext"){let r=new p.MathNode("mtext",[new p.TextNode(t.children[0].text)]);e.children.push(r)}else e.children[e.children.length-1].children[0].text+=t.children[0].text},Ee=e=>{if(e.type!=="mrow"&&e.type!=="mstyle"||e.children.length===0)return e;let t=new p.MathNode("mrow");for(let r=0;r0&&o.children[0].text.charAt(s-1)===" "&&(o.children[0].text=o.children[0].text.slice(0,-1)+"\xA0");for(let[i,l]of Object.entries(e.attributes))o.attributes[i]=l}return t.children.length===1&&t.children[0].type==="mtext"?t.children[0]:t},Qe=function(e,t=!1){if(e.length===1&&!(e[0]instanceof ge))return e[0];if(!t){e[0]instanceof R&&e[0].type==="mo"&&!e[0].attributes.fence&&(e[0].attributes.lspace="0em",e[0].attributes.rspace="0em");let r=e.length-1;e[r]instanceof R&&e[r].type==="mo"&&!e[r].attributes.fence&&(e[r].attributes.lspace="0em",e[r].attributes.rspace="0em")}return new p.MathNode("mrow",e)};function Fe(e){if(!e)return!1;if(e.type==="mi"&&e.children.length===1){let t=e.children[0];return t instanceof ae&&t.text==="."}else if(e.type==="mtext"&&e.children.length===1){let t=e.children[0];return t instanceof ae&&t.text==="\u2008"}else if(e.type==="mo"&&e.children.length===1&&e.getAttribute("separator")==="true"&&e.getAttribute("lspace")==="0em"&&e.getAttribute("rspace")==="0em"){let t=e.children[0];return t instanceof ae&&t.text===","}else return!1}var jr=(e,t)=>{let r=e[t],o=e[t+1];return r.type==="atom"&&r.text===","&&r.loc&&o.loc&&r.loc.end===o.loc.start},Se=e=>e.type==="atom"&&e.family==="rel"||e.type==="mclass"&&e.mclass==="mrel",U=function(e,t,r=!1){if(!r&&e.length===1){let l=O(e[0],t);return l instanceof R&&l.type==="mo"&&(l.setAttribute("lspace","0em"),l.setAttribute("rspace","0em")),[l]}let o=[],s=[],i;for(let l=0;l0&&Se(e[l])&&Se(e[l-1])&&u.setAttribute("lspace","0em"),u.type==="mn"&&i&&i.type==="mn"){i.children.push(...u.children);continue}else if(Fe(u)&&i&&i.type==="mn"){i.children.push(...u.children);continue}else if(i&&i.type==="mn"&&l=1&&i&&(i.type==="mn"||Fe(i))){let h=u.children[0];h instanceof R&&h.type==="mn"&&i&&(h.children=[...i.children,...h.children],o.pop())}o.push(u),i=u}return o},te=function(e,t,r=!1){return Qe(U(e,t,r),r)},O=function(e,t){if(!e)return new p.MathNode("mrow");if(Ce[e.type])return Ce[e.type](e,t);throw new w("Got group of unknown type: '"+e.type+"'")},ht=e=>new p.MathNode("mtd",[],[],{padding:"0",width:"50%"}),Ur=["mrow","mtd","mtable","mtr"],je=e=>{for(let t of e.children)if(t.type&&Ur.includes(t.type)){if(t.classes&&t.classes[0]==="tml-label")return t.label;{let r=je(t);if(r)return r}}else if(!t.type){let r=je(t);if(r)return r}},Vr=(e,t,r,o)=>{t=te(t[0].body,r),t=Ee(t),t.classes.push("tml-tag");let s=je(e);e=new p.MathNode("mtd",[e]);let i=[ht(),e,ht()];i[o?0:2].classes.push(o?"tml-left":"tml-right"),i[o?0:2].children.push(t);let l=new p.MathNode("mtr",i,["tml-tageqn"]);s&&l.setAttribute("id",s);let u=new p.MathNode("mtable",[l]);return u.style.width="100%",u.setAttribute("displaystyle","true"),u};function Wr(e,t,r,o){let s=null;e.length===1&&e[0].type==="tag"&&(s=e[0].tag,e=e[0].body);let i=U(e,r);if(i.length===1&&i[0]instanceof be)return i[0];let l=o.displayMode||o.annotate?"none":o.wrap,u=i.length===0?null:i[0],h=i.length===1&&s===null&&u instanceof R?i[0]:Rr(i,l,o.displayMode);if(s&&(h=Vr(h,s,r,o.leqno)),o.annotate){let A=new p.MathNode("annotation",[new p.TextNode(t)]);A.setAttribute("encoding","application/x-tex"),h=new p.MathNode("semantics",[h,A])}let x=new p.MathNode("math",[h]);return o.xml&&x.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),h.style.width&&(x.style.width="100%"),o.displayMode&&(x.setAttribute("display","block"),x.style.display="block math",x.classes=["tml-display"]),x}var Wt="aceg\u0131\u0237mnopqrsuvwxyz\u03B1\u03B3\u03B5\u03B7\u03B9\u03BA\u03BC\u03BD\u03BF\u03C0\u03C1\u03C2\u03C3\u03C4\u03C5\u03C7\u03C9\u03D5\u{1D41A}\u{1D41C}\u{1D41E}\u{1D420}\u{1D426}\u{1D427}\u{1D428}\u{1D429}\u{1D42A}\u{1D42B}\u{1D42C}\u{1D42E}\u{1D42F}\u{1D430}\u{1D431}\u{1D432}\u{1D433}",Hr="ABCDEFGHIJKLMNOPQRSTUVWXYZbdfhklt\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u0398\u0399\u039A\u039B\u039C\u039D\u039E\u039F\u03A0\u03A1\u03A3\u03A4\u03A5\u03A6\u03A7\u03A8\u03A9\u03B2\u03B4\u03BB\u03B6\u03C6\u03B8\u03C8\u{1D400}\u{1D401}\u{1D402}\u{1D403}\u{1D404}\u{1D405}\u{1D406}\u{1D407}\u{1D408}\u{1D409}\u{1D40A}\u{1D40B}\u{1D40C}\u{1D40D}\u{1D40E}\u{1D40F}\u{1D410}\u{1D411}\u{1D412}\u{1D413}\u{1D414}\u{1D415}\u{1D416}\u{1D417}\u{1D418}\u{1D419}\u{1D41B}\u{1D41D}\u{1D41F}\u{1D421}\u{1D424}\u{1D425}\u{1D42D}",Zr=new Set(["\\alpha","\\gamma","\\delta","\\epsilon","\\eta","\\iota","\\kappa","\\mu","\\nu","\\pi","\\rho","\\sigma","\\tau","\\upsilon","\\chi","\\psi","\\omega","\\imath","\\jmath"]),Xr=new Set(["\\Gamma","\\Delta","\\Sigma","\\Omega","\\beta","\\delta","\\lambda","\\theta","\\psi"]),Ht=(e,t)=>{let r=e.isStretchy?Me.accentNode(e):new p.MathNode("mo",[W(e.label,e.mode)]);if(e.label==="\\vec")r.style.transform="scale(0.75) translate(10%, 30%)";else if(r.style.mathStyle="normal",r.style.mathDepth="0",Kr.has(e.label)&&N.isCharacterBox(e.base)){let s="",i=e.base.text;(Wt.indexOf(i)>-1||Zr.has(i))&&(s="tml-xshift"),(Hr.indexOf(i)>-1||Xr.has(i))&&(s="tml-capshift"),s&&r.classes.push(s)}return e.isStretchy||r.setAttribute("stretchy","false"),new p.MathNode(e.label==="\\c"?"munder":"mover",[O(e.base,t),r])},Yr=new Set(["\\acute","\\grave","\\ddot","\\dddot","\\ddddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"]),Kr=new Set(["\\acute","\\bar","\\breve","\\check","\\dot","\\ddot","\\grave","\\hat","\\mathring","\\'","\\^","\\~","\\=","\\u","\\.",'\\"',"\\r","\\H","\\v"]),pt={"\\`":"\u0300","\\'":"\u0301","\\^":"\u0302","\\~":"\u0303","\\=":"\u0304","\\u":"\u0306","\\.":"\u0307",'\\"':"\u0308","\\r":"\u030A","\\H":"\u030B","\\v":"\u030C"};S({type:"accent",names:["\\acute","\\grave","\\ddot","\\dddot","\\ddddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring","\\overparen","\\widecheck","\\widehat","\\wideparen","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overleftharpoon","\\overrightharpoon"],props:{numArgs:1},handler:(e,t)=>{let r=fe(t[0]),o=!Yr.has(e.funcName);return{type:"accent",mode:e.parser.mode,label:e.funcName,isStretchy:o,base:r}},mathmlBuilder:Ht});S({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\c","\\u","\\.",'\\"',"\\r","\\H","\\v"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(e,t)=>{let r=fe(t[0]),o=e.parser.mode;return o==="math"&&e.parser.settings.strict&&console.log(`Temml parse error: Command ${e.funcName} is invalid in math mode.`),o==="text"&&r.text&&r.text.length===1&&e.funcName in pt&&Wt.indexOf(r.text)>-1?{type:"textord",mode:"text",text:r.text+pt[e.funcName]}:{type:"accent",mode:o,label:e.funcName,isStretchy:!1,base:r}},mathmlBuilder:Ht});S({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underparen","\\utilde"],props:{numArgs:1},handler:({parser:e,funcName:t},r)=>{let o=r[0];return{type:"accentUnder",mode:e.mode,label:t,base:o}},mathmlBuilder:(e,t)=>{let r=Me.accentNode(e);return r.style["math-depth"]=0,new p.MathNode("munder",[O(e.base,t),r])}});var ft={pt:800/803,pc:12*800/803,dd:1238/1157*800/803,cc:14856/1157*800/803,nd:685/642*800/803,nc:1370/107*800/803,sp:1/65536*800/803,mm:25.4/72,cm:2.54/72,in:1/72,px:96/72},Jr=["em","ex","mu","pt","mm","cm","in","px","bp","pc","dd","cc","nd","nc","sp"],Zt=function(e){return typeof e!="string"&&(e=e.unit),Jr.indexOf(e)>-1},Xt=e=>{let t=Math.max(e-1,0);return[1,.7,.5][t]},K=function(e,t){let r=e.number;if(t.maxSize[0]<0&&r>0)return{number:0,unit:"em"};let o=e.unit;switch(o){case"mm":case"cm":case"in":case"px":return r*ft[o]>t.maxSize[1]?{number:t.maxSize[1],unit:"pt"}:{number:r,unit:o};case"em":case"ex":return o==="ex"&&(r*=.431),r=Math.min(r/Xt(t.level),t.maxSize[0]),{number:N.round(r),unit:"em"};case"bp":return r>t.maxSize[1]&&(r=t.maxSize[1]),{number:r,unit:"pt"};case"pt":case"pc":case"dd":case"cc":case"nd":case"nc":case"sp":return r=Math.min(r*ft[o],t.maxSize[1]),{number:N.round(r),unit:"pt"};case"mu":return r=Math.min(r/18,t.maxSize[0]),{number:N.round(r),unit:"em"};default:throw new w("Invalid unit: '"+o+"'")}},Q=e=>{let t=new p.MathNode("mspace");return t.setAttribute("width",e+"em"),t},qe=(e,t=.3,r=0,o=!1)=>{if(e==null&&r===0)return Q(t);let s=e?[e]:[];if(t!==0&&s.unshift(Q(t)),r>0&&s.push(Q(r)),o){let i=new p.MathNode("mpadded",s);return i.setAttribute("height","0"),i}else return new p.MathNode("mrow",s)},Ie=(e,t)=>Number(e)/Xt(t),Ue=(e,t,r,o)=>{let s=Me.mathMLnode(e),i=e.slice(1,3)==="eq",l=e.charAt(1)==="x"?"1.75":e.slice(2,4)==="cd"?"3.0":i?"1.0":"2.0";s.setAttribute("lspace","0"),s.setAttribute("rspace",i?"0.5em":"0");let u=o.withLevel(o.level<2?2:3),h=Ie(l,u.level),x=Ie(l,3),A=qe(null,h.toFixed(4),0),q=qe(null,x.toFixed(4),0),b=Ie(i?0:.3,u.level).toFixed(4),k,T,$=t&&t.body&&(t.body.body||t.body.length>0);if($){let E=O(t,u);E=qe(E,b,b,e==="\\\\cdrightarrow"||e==="\\\\cdleftarrow"),k=new p.MathNode("mover",[E,q])}let j=r&&r.body&&(r.body.body||r.body.length>0);if(j){let E=O(r,u);E=qe(E,b,b),T=new p.MathNode("munder",[E,q])}let G;return!$&&!j?G=new p.MathNode("mover",[s,A]):$&&j?G=new p.MathNode("munderover",[s,T,k]):$?G=new p.MathNode("mover",[s,k]):G=new p.MathNode("munder",[s,T]),l==="3.0"&&(G.style.height="1em"),G.setAttribute("accent","false"),G};S({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\yields","\\yieldsLeft","\\mesomerism","\\longrightharpoonup","\\longleftharpoondown","\\\\cdrightarrow","\\\\cdleftarrow","\\\\cdlongequal"],props:{numArgs:1,numOptionalArgs:1},handler({parser:e,funcName:t},r,o){return{type:"xArrow",mode:e.mode,name:t,body:r[0],below:o[0]}},mathmlBuilder(e,t){let o=[Ue(e.name,e.body,e.below,t)];return o.unshift(Q(.2778)),o.push(Q(.2778)),new p.MathNode("mrow",o)}});var gt={"\\xtofrom":["\\xrightarrow","\\xleftarrow"],"\\xleftrightharpoons":["\\xleftharpoonup","\\xrightharpoondown"],"\\xrightleftharpoons":["\\xrightharpoonup","\\xleftharpoondown"],"\\yieldsLeftRight":["\\yields","\\yieldsLeft"],"\\equilibrium":["\\longrightharpoonup","\\longleftharpoondown"],"\\equilibriumRight":["\\longrightharpoonup","\\eqleftharpoondown"],"\\equilibriumLeft":["\\eqrightharpoonup","\\longleftharpoondown"]};S({type:"stackedArrow",names:["\\xtofrom","\\xleftrightharpoons","\\xrightleftharpoons","\\yieldsLeftRight","\\equilibrium","\\equilibriumRight","\\equilibriumLeft"],props:{numArgs:1,numOptionalArgs:1},handler({parser:e,funcName:t},r,o){let s=r[0]?{type:"hphantom",mode:e.mode,body:r[0]}:null,i=o[0]?{type:"hphantom",mode:e.mode,body:o[0]}:null;return{type:"stackedArrow",mode:e.mode,name:t,body:r[0],upperArrowBelow:i,lowerArrowBody:s,below:o[0]}},mathmlBuilder(e,t){let r=gt[e.name][0],o=gt[e.name][1],s=Ue(r,e.body,e.upperArrowBelow,t),i=Ue(o,e.lowerArrowBody,e.below,t),l,u=new p.MathNode("mpadded",[s]);if(u.setAttribute("voffset","0.3em"),u.setAttribute("height","+0.3em"),u.setAttribute("depth","-0.3em"),e.name==="\\equilibriumLeft"){let h=new p.MathNode("mpadded",[i]);h.setAttribute("width","0.5em"),l=new p.MathNode("mpadded",[Q(.2778),h,u,Q(.2778)])}else u.setAttribute("width",e.name==="\\equilibriumRight"?"0.5em":"0"),l=new p.MathNode("mpadded",[Q(.2778),u,i,Q(.2778)]);return l.setAttribute("voffset","-0.18em"),l.setAttribute("height","-0.18em"),l.setAttribute("depth","+0.18em"),l}});function C(e,t){if(!e||e.type!==t)throw new Error(`Expected node of type ${t}, but got `+(e?`node of type ${e.type}`:String(e)));return e}function et(e){let t=ze(e);if(!t)throw new Error("Expected node of symbol group type, but got "+(e?`node of type ${e.type}`:String(e)));return t}function ze(e){return e&&(e.type==="atom"||Object.prototype.hasOwnProperty.call(Fr,e.type))?e:null}var Qr={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},bt=()=>({type:"styling",body:[],mode:"math",scriptLevel:"display"}),xt=e=>e.type==="textord"&&e.text==="@",en=(e,t)=>(e.type==="mathord"||e.type==="atom")&&e.text===t;function tn(e,t,r){let o=Qr[e];switch(o){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return r.callFunction(o,[t[0]],[t[1]]);case"\\uparrow":case"\\downarrow":{let s=r.callFunction("\\\\cdleft",[t[0]],[]),i={type:"atom",text:o,mode:"math",family:"rel"},l=r.callFunction("\\Big",[i],[]),u=r.callFunction("\\\\cdright",[t[1]],[]),h={type:"ordgroup",mode:"math",body:[s,l,u],semisimple:!0};return r.callFunction("\\\\cdparent",[h],[])}case"\\\\cdlongequal":return r.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":{let s={type:"textord",text:"\\Vert",mode:"math"};return r.callFunction("\\Big",[s],[])}default:return{type:"textord",text:" ",mode:"math"}}}function rn(e){let t=[];for(e.gullet.beginGroup(),e.gullet.macros.set("\\cr","\\\\\\relax"),e.gullet.beginGroup();;){t.push(e.parseExpression(!1,"\\\\")),e.gullet.endGroup(),e.gullet.beginGroup();let s=e.fetch().text;if(s==="&"||s==="\\\\")e.consume();else if(s==="\\end"){t[t.length-1].length===0&&t.pop();break}else throw new w("Expected \\\\ or \\cr or \\end",e.nextToken)}let r=[],o=[r];for(let s=0;s-1))if("<>AV".indexOf(h)>-1)for(let q=0;q<2;q++){let b=!0;for(let k=u+1;kAV=|." after @.');let A=tn(h,x,e);r.push(A),l=bt()}s%2===0?r.push(l):r.shift(),r=[],o.push(r)}return o.pop(),e.gullet.endGroup(),e.gullet.endGroup(),{type:"array",mode:"math",body:o,tags:null,labels:new Array(o.length+1).fill(""),envClasses:["jot","cd"],cols:[],hLinesBeforeRow:new Array(o.length+1).fill([])}}S({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],props:{numArgs:1},handler({parser:e,funcName:t},r){return{type:"cdlabel",mode:e.mode,side:t.slice(4),label:r[0]}},mathmlBuilder(e,t){if(e.label.body.length===0)return new p.MathNode("mrow",t);let r=new p.MathNode("mtd",[O(e.label,t)]);r.style.padding="0";let o=new p.MathNode("mtr",[r]),s=new p.MathNode("mtable",[o]),i=new p.MathNode("mpadded",[s]);return i.setAttribute("width","0"),i.setAttribute("displaystyle","false"),i.setAttribute("scriptlevel","1"),e.side==="left"&&(i.style.display="flex",i.style.justifyContent="flex-end"),i}});S({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler({parser:e},t){return{type:"cdlabelparent",mode:e.mode,fragment:t[0]}},mathmlBuilder(e,t){return new p.MathNode("mrow",[O(e.fragment,t)])}});S({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler({parser:e,token:t},r){let s=C(r[0],"ordgroup").body,i="";for(let u=0;u{let t=e.toString(16);return t.length===1&&(t="0"+t),t},wt=JSON.parse(`{ "Apricot": "#ffb484", "Aquamarine": "#08b4bc", "Bittersweet": "#c84c14", "blue": "#0000FF", "Blue": "#303494", "BlueGreen": "#08b4bc", "BlueViolet": "#503c94", "BrickRed": "#b8341c", "brown": "#BF8040", "Brown": "#802404", "BurntOrange": "#f8941c", "CadetBlue": "#78749c", "CarnationPink": "#f884b4", "Cerulean": "#08a4e4", "CornflowerBlue": "#40ace4", "cyan": "#00FFFF", "Cyan": "#08acec", "Dandelion": "#ffbc44", "darkgray": "#404040", "DarkOrchid": "#a8548c", "Emerald": "#08ac9c", "ForestGreen": "#089c54", "Fuchsia": "#90348c", "Goldenrod": "#ffdc44", "gray": "#808080", "Gray": "#98949c", "green": "#00FF00", "Green": "#08a44c", "GreenYellow": "#e0e474", "JungleGreen": "#08ac9c", "Lavender": "#f89cc4", "lightgray": "#c0c0c0", "lime": "#BFFF00", "LimeGreen": "#90c43c", "magenta": "#FF00FF", "Magenta": "#f0048c", "Mahogany": "#b0341c", "Maroon": "#b03434", "Melon": "#f89c7c", "MidnightBlue": "#086494", "Mulberry": "#b03c94", "NavyBlue": "#086cbc", "olive": "#7F7F00", "OliveGreen": "#407c34", "orange": "#FF8000", "Orange": "#f8843c", "OrangeRed": "#f0145c", "Orchid": "#b074ac", "Peach": "#f8945c", "Periwinkle": "#8074bc", "PineGreen": "#088c74", "pink": "#ff7f7f", "Plum": "#98248c", "ProcessBlue": "#08b4ec", "purple": "#BF0040", "Purple": "#a0449c", "RawSienna": "#983c04", "red": "#ff0000", "Red": "#f01c24", "RedOrange": "#f86434", "RedViolet": "#a0246c", "Rhodamine": "#f0549c", "Royallue": "#0874bc", "RoyalPurple": "#683c9c", "RubineRed": "#f0047c", "Salmon": "#f8948c", "SeaGreen": "#30bc9c", "Sepia": "#701404", "SkyBlue": "#48c4dc", "SpringGreen": "#c8dc64", "Tan": "#e09c74", "teal": "#007F7F", "TealBlue": "#08acb4", "Thistle": "#d884b4", "Turquoise": "#08b4cc", "violet": "#800080", "Violet": "#60449c", "VioletRed": "#f054a4", "WildStrawberry": "#f0246c", "yellow": "#FFFF00", "Yellow": "#fff404", "YellowGreen": "#98cc6c", "YellowOrange": "#ffa41c" }`),ce=(e,t)=>{let r="";if(e==="HTML"){if(!nn.test(t))throw new w("Invalid HTML input.");r=t}else if(e==="RGB"){if(!an.test(t))throw new w("Invalid RGB input.");t.split(",").map(o=>{r+=yt(Number(o.trim()))})}else{if(!sn.test(t))throw new w("Invalid rbg input.");t.split(",").map(o=>{let s=Number(o.trim());if(s>1)throw new w("Color rgb input must be < 1.");r+=yt(Number((s*255).toFixed(0)))})}return r.charAt(0)!=="#"&&(r="#"+r),r},xe=(e,t,r)=>{let o=`\\\\color@${e}`;if(!on.exec(e))throw new w("Invalid color: '"+e+"'",r);return ln.test(e)?"#"+e:(e.charAt(0)==="#"||(t.has(o)?e=t.get(o).tokens[0].text:wt[e]&&(e=wt[e])),e)},Yt=(e,t)=>{let r=U(e.body,t.withColor(e.color));return r=r.map(o=>(o.style.color=e.color,o)),p.newDocumentFragment(r)};S({type:"color",names:["\\textcolor"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","original"]},handler({parser:e,token:t},r,o){let s=o[0]&&C(o[0],"raw").string,i="";if(s){let u=C(r[0],"raw").string;i=ce(s,u)}else i=xe(C(r[0],"raw").string,e.gullet.macros,t);let l=r[1];return{type:"color",mode:e.mode,color:i,isTextColor:!0,body:z(l)}},mathmlBuilder:Yt});S({type:"color",names:["\\color"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw"]},handler({parser:e,breakOnTokenText:t,token:r},o,s){let i=s[0]&&C(s[0],"raw").string,l="";if(i){let h=C(o[0],"raw").string;l=ce(i,h)}else l=xe(C(o[0],"raw").string,e.gullet.macros,r);let u=e.parseExpression(!0,t,!0);return{type:"color",mode:e.mode,color:l,isTextColor:!1,body:u}},mathmlBuilder:Yt});S({type:"color",names:["\\definecolor"],props:{numArgs:3,allowedInText:!0,argTypes:["raw","raw","raw"]},handler({parser:e,funcName:t,token:r},o){let s=C(o[0],"raw").string;if(!/^[A-Za-z]+$/.test(s))throw new w("Color name must be latin letters.",r);let i=C(o[1],"raw").string;if(!["HTML","RGB","rgb"].includes(i))throw new w("Color model must be HTML, RGB, or rgb.",r);let l=C(o[2],"raw").string,u=ce(i,l);return e.gullet.macros.set(`\\\\color@${s}`,{tokens:[{text:u}],numArgs:0}),{type:"internal",mode:e.mode}}});S({type:"cr",names:["\\\\"],props:{numArgs:0,numOptionalArgs:0,allowedInText:!0},handler({parser:e},t,r){let o=e.gullet.future().text==="["?e.parseSizeGroup(!0):null,s=!e.settings.displayMode;return{type:"cr",mode:e.mode,newLine:s,size:o&&C(o,"size").value}},mathmlBuilder(e,t){let r=new p.MathNode("mo");if(e.newLine&&(r.setAttribute("linebreak","newline"),e.size)){let o=K(e.size,t);r.setAttribute("height",o.number+o.unit)}return r}});var Ve={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},Ne=e=>{let t=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(t))throw new w("Expected a control sequence",e);return t},un=e=>{let t=e.gullet.popToken();return t.text==="="&&(t=e.gullet.popToken(),t.text===" "&&(t=e.gullet.popToken())),t},Kt=(e,t,r,o)=>{let s=e.gullet.macros.get(r.text);s==null&&(r.noexpand=!0,s={tokens:[r],numArgs:0,unexpandable:!e.gullet.isExpandable(r.text)}),e.gullet.macros.set(t,s,o)};S({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler({parser:e,funcName:t}){e.consumeSpaces();let r=e.fetch();if(Ve[r.text])return(t==="\\global"||t==="\\\\globallong")&&(r.text=Ve[r.text]),C(e.parseFunction(),"internal");throw new w("Invalid token after macro prefix",r)}});S({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let r=e.gullet.popToken(),o=r.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(o))throw new w("Expected a control sequence",r);let s=0,i,l=[[]];for(;e.gullet.future().text!=="{";)if(r=e.gullet.popToken(),r.text==="#"){if(e.gullet.future().text==="{"){i=e.gullet.future(),l[s].push("{");break}if(r=e.gullet.popToken(),!/^[1-9]$/.test(r.text))throw new w(`Invalid argument number "${r.text}"`);if(parseInt(r.text)!==s+1)throw new w(`Argument number "${r.text}" out of order`);s++,l.push([])}else{if(r.text==="EOF")throw new w("Expected a macro definition");l[s].push(r.text)}let{tokens:u}=e.gullet.consumeArg();if(i&&u.unshift(i),t==="\\edef"||t==="\\xdef"){if(u=e.gullet.expandTokens(u),u.length>e.gullet.settings.maxExpand)throw new w("Too many expansions in an "+t);u.reverse()}return e.gullet.macros.set(o,{tokens:u,numArgs:s,delimiters:l},t===Ve[t]),{type:"internal",mode:e.mode}}});S({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let r=Ne(e.gullet.popToken());e.gullet.consumeSpaces();let o=un(e);return Kt(e,r,o,t==="\\\\globallet"),{type:"internal",mode:e.mode}}});S({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let r=Ne(e.gullet.popToken()),o=e.gullet.popToken(),s=e.gullet.popToken();return Kt(e,r,s,t==="\\\\globalfuture"),e.gullet.pushToken(s),e.gullet.pushToken(o),{type:"internal",mode:e.mode}}});S({type:"internal",names:["\\newcommand","\\renewcommand","\\providecommand"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let r="",o=e.gullet.popToken();o.text==="{"?(r=Ne(e.gullet.popToken()),e.gullet.popToken()):r=Ne(o);let s=e.gullet.isDefined(r);if(s&&t==="\\newcommand")throw new w(`\\newcommand{${r}} attempting to redefine ${r}; use \\renewcommand`);if(!s&&t==="\\renewcommand")throw new w(`\\renewcommand{${r}} when command ${r} does not yet exist; use \\newcommand`);let i=0;if(e.gullet.future().text==="["){let u=e.gullet.popToken();if(u=e.gullet.popToken(),!/^[0-9]$/.test(u.text))throw new w(`Invalid number of arguments: "${u.text}"`);if(i=parseInt(u.text),u=e.gullet.popToken(),u.text!=="]")throw new w(`Invalid argument "${u.text}"`)}let{tokens:l}=e.gullet.consumeArg();return t==="\\providecommand"&&e.gullet.macros.has(r)||e.gullet.macros.set(r,{tokens:l,numArgs:i}),{type:"internal",mode:e.mode}}});var We={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}},Jt=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\u2987","\\llparenthesis","\u2988","\\rrparenthesis","\\lfloor","\\rfloor","\u230A","\u230B","\\lceil","\\rceil","\u2308","\u2309","<",">","\\langle","\u27E8","\\rangle","\u27E9","\\lAngle","\u27EA","\\rAngle","\u27EB","\\llangle","\u2989","\\rrangle","\u298A","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27EE","\u27EF","\\lmoustache","\\rmoustache","\u23B0","\u23B1","\\llbracket","\\rrbracket","\u27E6","\u27E6","\\lBrace","\\rBrace","\u2983","\u2984","/","\\backslash","|","\\vert","\\|","\\Vert","\u2016","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."],cn=["}","\\left","\\middle","\\right"],Le=e=>e.length>0&&(Jt.includes(e)||We[e]||cn.includes(e)),vt=[0,1.2,1.8,2.4,3];function ye(e,t){let r=ze(e);if(r&&Jt.includes(r.text))return["<","\\lt"].includes(r.text)&&(r.text="\u27E8"),[">","\\gt"].includes(r.text)&&(r.text="\u27E9"),r;throw r?new w(`Invalid delimiter '${r.text}' after '${t.funcName}'`,e):new w(`Invalid delimiter type '${e.type}'`,e)}var dn=["/","\\","\\backslash","\\vert","|"];S({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>{let r=ye(t[0],e);return{type:"delimsizing",mode:e.parser.mode,size:We[e.funcName].size,mclass:We[e.funcName].mclass,delim:r.text}},mathmlBuilder:e=>{let t=[];e.delim==="."&&(e.delim=""),t.push(W(e.delim,e.mode));let r=new p.MathNode("mo",t);return e.mclass==="mopen"||e.mclass==="mclose"?r.setAttribute("fence","true"):r.setAttribute("fence","false"),(dn.includes(e.delim)||e.delim.indexOf("arrow")>-1)&&r.setAttribute("stretchy","true"),r.setAttribute("symmetric","true"),r.setAttribute("minsize",vt[e.size]+"em"),r.setAttribute("maxsize",vt[e.size]+"em"),r}});function mn(e){if(!e.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}S({type:"leftright-right",names:["\\right"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>({type:"leftright-right",mode:e.parser.mode,delim:ye(t[0],e).text})});S({type:"leftright",names:["\\left"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>{let r=ye(t[0],e),o=e.parser;++o.leftrightDepth;let s=o.parseExpression(!1,null,!0),i=o.fetch();for(;i.text==="\\middle";){o.consume();let u=o.fetch().text;if(!I.math[u])throw new w(`Invalid delimiter '${u}' after '\\middle'`);ye({type:"atom",mode:"math",text:u},{funcName:"\\middle"}),s.push({type:"middle",mode:"math",delim:u}),o.consume(),s=s.concat(o.parseExpression(!1,null,!0)),i=o.fetch()}--o.leftrightDepth,o.expect("\\right",!1);let l=C(o.parseFunction(),"leftright-right");return{type:"leftright",mode:o.mode,body:s,left:r.text,right:l.delim}},mathmlBuilder:(e,t)=>{mn(e);let r=U(e.body,t);e.left==="."&&(e.left="");let o=new p.MathNode("mo",[W(e.left,e.mode)]);o.setAttribute("fence","true"),o.setAttribute("form","prefix"),(e.left==="/"||e.left==="\\"||e.left.indexOf("arrow")>-1)&&o.setAttribute("stretchy","true"),r.unshift(o),e.right==="."&&(e.right="");let s=new p.MathNode("mo",[W(e.right,e.mode)]);if(s.setAttribute("fence","true"),s.setAttribute("form","postfix"),(e.right==="\u2216"||e.right.indexOf("arrow")>-1)&&s.setAttribute("stretchy","true"),e.body.length>0){let i=e.body[e.body.length-1];i.type==="color"&&!i.isTextColor&&s.setAttribute("mathcolor",i.color)}return r.push(s),Qe(r)}});S({type:"middle",names:["\\middle"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>{let r=ye(t[0],e);if(!e.parser.leftrightDepth)throw new w("\\middle without preceding \\left",r);return{type:"middle",mode:e.parser.mode,delim:r.text}},mathmlBuilder:(e,t)=>{let r=W(e.delim,e.mode),o=new p.MathNode("mo",[r]);return o.setAttribute("fence","true"),e.delim.indexOf("arrow")>-1&&o.setAttribute("stretchy","true"),o.setAttribute("form","prefix"),o.setAttribute("lspace","0.05em"),o.setAttribute("rspace","0.05em"),o}});var kt=e=>{let t=new p.MathNode("mspace");return t.setAttribute("width","3pt"),t},ve=(e,t)=>{let r;switch(e.label.indexOf("colorbox")>-1||e.label==="\\boxed"?r=new p.MathNode("mrow",[kt(),O(e.body,t),kt()]):r=new p.MathNode("menclose",[O(e.body,t)]),e.label){case"\\overline":r.setAttribute("notation","top"),r.classes.push("tml-overline");break;case"\\underline":r.setAttribute("notation","bottom"),r.classes.push("tml-underline");break;case"\\cancel":r.setAttribute("notation","updiagonalstrike"),r.children.push(new p.MathNode("mrow",[],["tml-cancel","upstrike"]));break;case"\\bcancel":r.setAttribute("notation","downdiagonalstrike"),r.children.push(new p.MathNode("mrow",[],["tml-cancel","downstrike"]));break;case"\\sout":r.setAttribute("notation","horizontalstrike"),r.children.push(new p.MathNode("mrow",[],["tml-cancel","sout"]));break;case"\\xcancel":r.setAttribute("notation","updiagonalstrike downdiagonalstrike"),r.classes.push("tml-xcancel");break;case"\\longdiv":r.setAttribute("notation","longdiv"),r.classes.push("longdiv-top"),r.children.push(new p.MathNode("mrow",[],["longdiv-arc"]));break;case"\\phase":r.setAttribute("notation","phasorangle"),r.classes.push("phasor-bottom"),r.children.push(new p.MathNode("mrow",[],["phasor-angle"]));break;case"\\textcircled":r.setAttribute("notation","circle"),r.classes.push("circle-pad"),r.children.push(new p.MathNode("mrow",[],["textcircle"]));break;case"\\angl":r.setAttribute("notation","actuarial"),r.classes.push("actuarial");break;case"\\boxed":r.setAttribute("notation","box"),r.classes.push("tml-box"),r.setAttribute("scriptlevel","0"),r.setAttribute("displaystyle","true");break;case"\\fbox":r.setAttribute("notation","box"),r.classes.push("tml-fbox");break;case"\\fcolorbox":case"\\colorbox":{let o={padding:"3pt 0 3pt 0"};e.label==="\\fcolorbox"&&(o.border="0.0667em solid "+String(e.borderColor)),r.style=o;break}}return e.backgroundColor&&r.setAttribute("mathbackground",e.backgroundColor),r};S({type:"enclose",names:["\\colorbox"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","text"]},handler({parser:e,funcName:t},r,o){let s=o[0]&&C(o[0],"raw").string,i="";if(s){let u=C(r[0],"raw").string;i=ce(s,u)}else i=xe(C(r[0],"raw").string,e.gullet.macros);let l=r[1];return{type:"enclose",mode:e.mode,label:t,backgroundColor:i,body:l}},mathmlBuilder:ve});S({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","raw","text"]},handler({parser:e,funcName:t},r,o){let s=o[0]&&C(o[0],"raw").string,i="",l;if(s){let h=C(r[0],"raw").string,x=C(r[0],"raw").string;i=ce(s,h),l=ce(s,x)}else i=xe(C(r[0],"raw").string,e.gullet.macros),l=xe(C(r[1],"raw").string,e.gullet.macros);let u=r[2];return{type:"enclose",mode:e.mode,label:t,backgroundColor:l,borderColor:i,body:u}},mathmlBuilder:ve});S({type:"enclose",names:["\\fbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler({parser:e},t){return{type:"enclose",mode:e.mode,label:"\\fbox",body:t[0]}}});S({type:"enclose",names:["\\angl","\\cancel","\\bcancel","\\xcancel","\\sout","\\overline","\\boxed","\\longdiv","\\phase"],props:{numArgs:1},handler({parser:e,funcName:t},r){let o=r[0];return{type:"enclose",mode:e.mode,label:t,body:o}},mathmlBuilder:ve});S({type:"enclose",names:["\\underline"],props:{numArgs:1,allowedInText:!0},handler({parser:e,funcName:t},r){let o=r[0];return{type:"enclose",mode:e.mode,label:t,body:o}},mathmlBuilder:ve});S({type:"enclose",names:["\\textcircled"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler({parser:e,funcName:t},r){let o=r[0];return{type:"enclose",mode:e.mode,label:t,body:o}},mathmlBuilder:ve});var Qt={};function X({type:e,names:t,props:r,handler:o,mathmlBuilder:s}){let i={type:e,numArgs:r.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:o};for(let l=0;l{let t="";for(let r=e.length-1;r>-1;r--)t+=e[r].text;return t},tt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15},At=e=>{let t=e.future().text;return t==="EOF"?[null,""]:[tt[t.charAt(0)],t]},St=(e,t,r)=>{for(let o=1;o=r)throw new w(`Invalid base-${r} digit ${t.text}`);o=St(o,s,r);let i;for([i,s]=At(e);i!=null&&i=0;s--){let i=t[s].loc.start;i>o&&(r+=" ",o=i),r+=t[s].text,o+=t[s].text.length}return r}c("\\surd","\\sqrt{\\vphantom{|}}");c("\u2295","\\oplus");c("\\long","");c("\\bgroup","{");c("\\egroup","}");c("~","\\nobreakspace");c("\\lq","`");c("\\rq","'");c("\\aa","\\r a");c("\\Bbbk","\\Bbb{k}");c("\\mathstrut","\\vphantom{(}");c("\\underbar","\\underline{\\text{#1}}");c("\\vdots","{\\varvdots\\rule{0pt}{15pt}}");c("\u22EE","\\vdots");c("\\arraystretch","1");c("\\arraycolsep","6pt");c("\\substack","\\begin{subarray}{c}#1\\end{subarray}");c("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;");c("\\implies","\\DOTSB\\;\\Longrightarrow\\;");c("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");var qt={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcap":"\\dotsb","\\bigsqcup":"\\dotsb","\\bigtimes":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"};c("\\dots",function(e){let t="\\dotso",r=e.expandAfterFuture().text;return r in qt?t=qt[r]:(r.slice(0,4)==="\\not"||r in I.math&&["bin","rel"].includes(I.math[r].group))&&(t="\\dotsb"),t});var nt={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};c("\\dotso",function(e){return e.future().text in nt?"\\ldots\\,":"\\ldots"});c("\\dotsc",function(e){let t=e.future().text;return t in nt&&t!==","?"\\ldots\\,":"\\ldots"});c("\\cdots",function(e){return e.future().text in nt?"\\@cdots\\,":"\\@cdots"});c("\\dotsb","\\cdots");c("\\dotsm","\\cdots");c("\\dotsi","\\!\\cdots");c("\\idotsint","\\dotsi");c("\\dotsx","\\ldots\\,");c("\\DOTSI","\\relax");c("\\DOTSB","\\relax");c("\\DOTSX","\\relax");c("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax");c("\\,","{\\tmspace+{3mu}{.1667em}}");c("\\thinspace","\\,");c("\\>","\\mskip{4mu}");c("\\:","{\\tmspace+{4mu}{.2222em}}");c("\\medspace","\\:");c("\\;","{\\tmspace+{5mu}{.2777em}}");c("\\thickspace","\\;");c("\\!","{\\tmspace-{3mu}{.1667em}}");c("\\negthinspace","\\!");c("\\negmedspace","{\\tmspace-{4mu}{.2222em}}");c("\\negthickspace","{\\tmspace-{5mu}{.277em}}");c("\\enspace","\\kern.5em ");c("\\enskip","\\hskip.5em\\relax");c("\\quad","\\hskip1em\\relax");c("\\qquad","\\hskip2em\\relax");c("\\AA","\\TextOrMath{\\Angstrom}{\\mathring{A}}\\relax");c("\\tag","\\@ifstar\\tag@literal\\tag@paren");c("\\tag@paren","\\tag@literal{({#1})}");c("\\tag@literal",e=>{if(e.macros.get("\\df@tag"))throw new w("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"});c("\\notag","\\nonumber");c("\\nonumber","\\gdef\\@eqnsw{0}");c("\\bmod","\\mathbin{\\text{mod}}");c("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)");c("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}");c("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1");c("\\newline","\\\\\\relax");c("\\TeX","\\textrm{T}\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125em\\textrm{X}");c("\\LaTeX","\\textrm{L}\\kern-.35em\\raisebox{0.2em}{\\scriptstyle A}\\kern-.15em\\TeX");c("\\Temml","\\textrm{T}\\kern-0.2em\\lower{0.2em}{\\textrm{E}}\\kern-0.08em{\\textrm{M}\\kern-0.08em\\raise{0.2em}\\textrm{M}\\kern-0.08em\\textrm{L}}");c("\\hspace","\\@ifstar\\@hspacer\\@hspace");c("\\@hspace","\\hskip #1\\relax");c("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax");c("\\colon",'\\mathpunct{\\char"3a}');c("\\prescript","\\pres@cript{_{#1}^{#2}}{}{#3}");c("\\ordinarycolon",'\\char"3a');c("\\vcentcolon","\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}}");c("\\coloneq",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2212}');c("\\Coloneq",'\\mathrel{\\char"2237\\char"2212}');c("\\Eqqcolon",'\\mathrel{\\char"3d\\char"2237}');c("\\Eqcolon",'\\mathrel{\\char"2212\\char"2237}');c("\\colonapprox",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2248}');c("\\Colonapprox",'\\mathrel{\\char"2237\\char"2248}');c("\\colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}');c("\\Colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}');c("\\ratio","\\vcentcolon");c("\\coloncolon","\\dblcolon");c("\\colonequals","\\coloneqq");c("\\coloncolonequals","\\Coloneqq");c("\\equalscolon","\\eqqcolon");c("\\equalscoloncolon","\\Eqqcolon");c("\\colonminus","\\coloneq");c("\\coloncolonminus","\\Coloneq");c("\\minuscolon","\\eqcolon");c("\\minuscoloncolon","\\Eqcolon");c("\\coloncolonapprox","\\Colonapprox");c("\\coloncolonsim","\\Colonsim");c("\\notni","\\mathrel{\\char`\u220C}");c("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}");c("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}");c("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}");c("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}");c("\\varlimsup","\\DOTSB\\operatorname*{\\overline{\\text{lim}}}");c("\\varliminf","\\DOTSB\\operatorname*{\\underline{\\text{lim}}}");c("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{\\text{lim}}}");c("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{\\text{lim}}}");c("\\centerdot","{\\medspace\\rule{0.167em}{0.189em}\\medspace}");c("\\argmin","\\DOTSB\\operatorname*{arg\\,min}");c("\\argmax","\\DOTSB\\operatorname*{arg\\,max}");c("\\plim","\\DOTSB\\operatorname*{plim}");c("\\leftmodels","\\mathop{\\reflectbox{$\\models$}}");c("\\bra","\\mathinner{\\langle{#1}|}");c("\\ket","\\mathinner{|{#1}\\rangle}");c("\\braket","\\mathinner{\\langle{#1}\\rangle}");c("\\Bra","\\left\\langle#1\\right|");c("\\Ket","\\left|#1\\right\\rangle");var tr=(e,t)=>{let o=`}\\,\\middle${t[0]==="|"?"\\vert":"\\Vert"}\\,{`;return e.slice(0,t.index)+o+e.slice(t.index+t[0].length)};c("\\Braket",function(e){let t=rt(e),r=/\|\||\||\\\|/g,o;for(;(o=r.exec(t))!==null;)t=tr(t,o);return"\\left\\langle{"+t+"}\\right\\rangle"});c("\\Set",function(e){let t=rt(e),r=/\|\||\||\\\|/.exec(t);return r&&(t=tr(t,r)),"\\left\\{\\:{"+t+"}\\:\\right\\}"});c("\\set",function(e){return"\\{{"+rt(e).replace(/\|/,"}\\mid{")+"}\\}"});c("\\angln","{\\angl n}");c("\\odv","\\@ifstar\\odv@next\\odv@numerator");c("\\odv@numerator","\\frac{\\mathrm{d}#1}{\\mathrm{d}#2}");c("\\odv@next","\\frac{\\mathrm{d}}{\\mathrm{d}#2}#1");c("\\pdv","\\@ifstar\\pdv@next\\pdv@numerator");var rr=e=>{let t=e[0][0].text,r=He(e[1]).split(","),o=String(r.length),s=o==="1"?"\\partial":`\\partial^${o}`,i="";return r.map(l=>{i+="\\partial "+l.trim()+"\\,"}),[t,s,i.replace(/\\,$/,"")]};c("\\pdv@numerator",function(e){let[t,r,o]=rr(e.consumeArgs(2));return`\\frac{${r} ${t}}{${o}}`});c("\\pdv@next",function(e){let[t,r,o]=rr(e.consumeArgs(2));return`\\frac{${r}}{${o}} ${t}`});c("\\upalpha","\\up@greek{\\alpha}");c("\\upbeta","\\up@greek{\\beta}");c("\\upgamma","\\up@greek{\\gamma}");c("\\updelta","\\up@greek{\\delta}");c("\\upepsilon","\\up@greek{\\epsilon}");c("\\upzeta","\\up@greek{\\zeta}");c("\\upeta","\\up@greek{\\eta}");c("\\uptheta","\\up@greek{\\theta}");c("\\upiota","\\up@greek{\\iota}");c("\\upkappa","\\up@greek{\\kappa}");c("\\uplambda","\\up@greek{\\lambda}");c("\\upmu","\\up@greek{\\mu}");c("\\upnu","\\up@greek{\\nu}");c("\\upxi","\\up@greek{\\xi}");c("\\upomicron","\\up@greek{\\omicron}");c("\\uppi","\\up@greek{\\pi}");c("\\upalpha","\\up@greek{\\alpha}");c("\\uprho","\\up@greek{\\rho}");c("\\upsigma","\\up@greek{\\sigma}");c("\\uptau","\\up@greek{\\tau}");c("\\upupsilon","\\up@greek{\\upsilon}");c("\\upphi","\\up@greek{\\phi}");c("\\upchi","\\up@greek{\\chi}");c("\\uppsi","\\up@greek{\\psi}");c("\\upomega","\\up@greek{\\omega}");c("\\invamp",'\\mathbin{\\char"214b}');c("\\parr",'\\mathbin{\\char"214b}');c("\\with",'\\mathbin{\\char"26}');c("\\multimapinv",'\\mathrel{\\char"27dc}');c("\\multimapboth",'\\mathrel{\\char"29df}');c("\\scoh",'{\\mkern5mu\\char"2322\\mkern5mu}');c("\\sincoh",'{\\mkern5mu\\char"2323\\mkern5mu}');c("\\coh",`{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2322}}} {\\smash{\\lower4mu{\\char"2323}}}\\mkern5mu}`);c("\\incoh",`{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2323}}} {\\smash{\\lower4mu{\\char"2322}}}\\mkern5mu}`);c("\\standardstate","\\text{\\tiny\\char`\u29B5}");c("\\ce",function(e){return nr(e.consumeArgs(1)[0],"ce")});c("\\pu",function(e){return nr(e.consumeArgs(1)[0],"pu")});c("\\uniDash","{\\rule{0.672em}{0.06em}}");c("\\triDash","{\\rule{0.15em}{0.06em}\\kern2mu\\rule{0.15em}{0.06em}\\kern2mu\\rule{0.15em}{0.06em}}");c("\\tripleDash","\\kern0.075em\\raise0.25em{\\triDash}\\kern0.075em");c("\\tripleDashOverLine","\\kern0.075em\\mathrlap{\\raise0.125em{\\uniDash}}\\raise0.34em{\\triDash}\\kern0.075em");c("\\tripleDashOverDoubleLine","\\kern0.075em\\mathrlap{\\mathrlap{\\raise0.48em{\\triDash}}\\raise0.27em{\\uniDash}}{\\raise0.05em{\\uniDash}}\\kern0.075em");c("\\tripleDashBetweenDoubleLine","\\kern0.075em\\mathrlap{\\mathrlap{\\raise0.48em{\\uniDash}}\\raise0.27em{\\triDash}}{\\raise0.05em{\\uniDash}}\\kern0.075em");var nr=function(e,t){for(var r="",o=e.length&&e[e.length-1].loc.start,s=e.length-1;s>=0;s--)e[s].loc.start>o&&(r+=" ",o=e[s].loc.start),r+=e[s].text,o+=e[s].text.length;var i=M.go(y.go(r,t));return i},y={go:function(e,t){if(!e)return[];t===void 0&&(t="ce");var r="0",o={};o.parenthesisLevel=0,e=e.replace(/\n/g," "),e=e.replace(/[\u2212\u2013\u2014\u2010]/g,"-"),e=e.replace(/[\u2026]/g,"...");for(var s,i=10,l=[];;){s!==e?(i=10,s=e):i--;var u=y.stateMachines[t],h=u.transitions[r]||u.transitions["*"];e:for(var x=0;x0){if(q.revisit||(e=A.remainder),!q.toContinue)break e}else return l}}if(i<=0)throw["MhchemBugU","mhchem bug U. Please report."]}},concatArray:function(e,t){if(t)if(Array.isArray(t))for(var r=0;r":/^[=<>]/,"#":/^[#\u2261]/,"+":/^\+/,"-$":/^-(?=[\s_},;\]/]|$|\([a-z]+\))/,"-9":/^-(?=[0-9])/,"- orbital overlap":/^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/,"-":/^-/,"pm-operator":/^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,operator:/^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,arrowUpDown:/^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,"\\bond{(...)}":function(e){return y.patterns.findObserveGroups(e,"\\bond{","","","}")},"->":/^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,CMT:/^[CMT](?=\[)/,"[(...)]":function(e){return y.patterns.findObserveGroups(e,"[","","","]")},"1st-level escape":/^(&|\\\\|\\hline)\s*/,"\\,":/^(?:\\[,\ ;:])/,"\\x{}{}":function(e){return y.patterns.findObserveGroups(e,"",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"\\x{}":function(e){return y.patterns.findObserveGroups(e,"",/^\\[a-zA-Z]+\{/,"}","")},"\\ca":/^\\ca(?:\s+|(?![a-zA-Z]))/,"\\x":/^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/,orbital:/^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,others:/^[\/~|]/,"\\frac{(...)}":function(e){return y.patterns.findObserveGroups(e,"\\frac{","","","}","{","","","}")},"\\overset{(...)}":function(e){return y.patterns.findObserveGroups(e,"\\overset{","","","}","{","","","}")},"\\underset{(...)}":function(e){return y.patterns.findObserveGroups(e,"\\underset{","","","}","{","","","}")},"\\underbrace{(...)}":function(e){return y.patterns.findObserveGroups(e,"\\underbrace{","","","}_","{","","","}")},"\\color{(...)}0":function(e){return y.patterns.findObserveGroups(e,"\\color{","","","}")},"\\color{(...)}{(...)}1":function(e){return y.patterns.findObserveGroups(e,"\\color{","","","}","{","","","}")},"\\color(...){(...)}2":function(e){return y.patterns.findObserveGroups(e,"\\color","\\","",/^(?=\{)/,"{","","","}")},"\\ce{(...)}":function(e){return y.patterns.findObserveGroups(e,"\\ce{","","","}")},oxidation$:/^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"d-oxidation$":/^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"roman numeral":/^[IVX]+/,"1/2$":/^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,amount:function(e){var t;if(t=e.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/),t)return{match_:t[0],remainder:e.substr(t[0].length)};var r=y.patterns.findObserveGroups(e,"","$","$","");return r&&(t=r.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/),t)?{match_:t[0],remainder:e.substr(t[0].length)}:null},amount2:function(e){return this.amount(e)},"(KV letters),":/^(?:[A-Z][a-z]{0,2}|i)(?=,)/,formula$:function(e){if(e.match(/^\([a-z]+\)$/))return null;var t=e.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/);return t?{match_:t[0],remainder:e.substr(t[0].length)}:null},uprightEntities:/^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/,"/":/^\s*(\/)\s*/,"//":/^\s*(\/\/)\s*/,"*":/^\s*[*.]\s*/},findObserveGroups:function(e,t,r,o,s,i,l,u,h,x){var A=function(G,E){if(typeof E=="string")return G.indexOf(E)!==0?null:E;var H=G.match(E);return H?H[0]:null},q=function(G,E,H){for(var J=0;E0,null},b=A(e,t);if(b===null||(e=e.substr(b.length),b=A(e,r),b===null))return null;var k=q(e,b.length,o||s);if(k===null)return null;var T=e.substring(0,o?k.endMatchEnd:k.endMatchBegin);if(i||l){var $=this.findObserveGroups(e.substr(k.endMatchEnd),i,l,u,h);if($===null)return null;var j=[T,$.match_];return{match_:x?j.join(""):j,remainder:$.remainder}}else return{match_:T,remainder:e.substr(k.endMatchEnd)}},match_:function(e,t){var r=y.patterns.patterns[e];if(r===void 0)throw["MhchemBugP","mhchem bug P. Please report. ("+e+")"];if(typeof r=="function")return y.patterns.patterns[e](t);var o=t.match(r);if(o){var s;return o[2]?s=[o[1],o[2]]:o[1]?s=o[1]:s=o[0],{match_:s,remainder:t.substr(o[0].length)}}return null}},actions:{"a=":function(e,t){e.a=(e.a||"")+t},"b=":function(e,t){e.b=(e.b||"")+t},"p=":function(e,t){e.p=(e.p||"")+t},"o=":function(e,t){e.o=(e.o||"")+t},"q=":function(e,t){e.q=(e.q||"")+t},"d=":function(e,t){e.d=(e.d||"")+t},"rm=":function(e,t){e.rm=(e.rm||"")+t},"text=":function(e,t){e.text_=(e.text_||"")+t},insert:function(e,t,r){return{type_:r}},"insert+p1":function(e,t,r){return{type_:r,p1:t}},"insert+p1+p2":function(e,t,r){return{type_:r,p1:t[0],p2:t[1]}},copy:function(e,t){return t},rm:function(e,t){return{type_:"rm",p1:t||""}},text:function(e,t){return y.go(t,"text")},"{text}":function(e,t){var r=["{"];return y.concatArray(r,y.go(t,"text")),r.push("}"),r},"tex-math":function(e,t){return y.go(t,"tex-math")},"tex-math tight":function(e,t){return y.go(t,"tex-math tight")},bond:function(e,t,r){return{type_:"bond",kind_:r||t}},"color0-output":function(e,t){return{type_:"color0",color:t[0]}},ce:function(e,t){return y.go(t)},"1/2":function(e,t){var r=[];t.match(/^[+\-]/)&&(r.push(t.substr(0,1)),t=t.substr(1));var o=t.match(/^([0-9]+|\$[a-z]\$|[a-z])\/([0-9]+)(\$[a-z]\$|[a-z])?$/);return o[1]=o[1].replace(/\$/g,""),r.push({type_:"frac",p1:o[1],p2:o[2]}),o[3]&&(o[3]=o[3].replace(/\$/g,""),r.push({type_:"tex-math",p1:o[3]})),r},"9,9":function(e,t){return y.go(t,"9,9")}},createTransitions:function(e){var t,r,o,s,i={};for(t in e)for(r in e[t])for(o=r.split("|"),e[t][r].stateArray=o,s=0;s":{"0|1|2|3":{action_:"r=",nextState:"r"},"a|as":{action_:["output","r="],nextState:"r"},"*":{action_:["output","r="],nextState:"r"}},"+":{o:{action_:"d= kv",nextState:"d"},"d|D":{action_:"d=",nextState:"d"},q:{action_:"d=",nextState:"qd"},"qd|qD":{action_:"d=",nextState:"qd"},dq:{action_:["output","d="],nextState:"d"},3:{action_:["sb=false","output","operator"],nextState:"0"}},amount:{"0|2":{action_:"a=",nextState:"a"}},"pm-operator":{"0|1|2|a|as":{action_:["sb=false","output",{type_:"operator",option:"\\pm"}],nextState:"0"}},operator:{"0|1|2|a|as":{action_:["sb=false","output","operator"],nextState:"0"}},"-$":{"o|q":{action_:["charge or bond","output"],nextState:"qd"},d:{action_:"d=",nextState:"d"},D:{action_:["output",{type_:"bond",option:"-"}],nextState:"3"},q:{action_:"d=",nextState:"qd"},qd:{action_:"d=",nextState:"qd"},"qD|dq":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},"-9":{"3|o":{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"3"}},"- orbital overlap":{o:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},d:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"}},"-":{"0|1|2":{action_:[{type_:"output",option:1},"beginsWithBond=true",{type_:"bond",option:"-"}],nextState:"3"},3:{action_:{type_:"bond",option:"-"}},a:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},as:{action_:[{type_:"output",option:2},{type_:"bond",option:"-"}],nextState:"3"},b:{action_:"b="},o:{action_:{type_:"- after o/d",option:!1},nextState:"2"},q:{action_:{type_:"- after o/d",option:!1},nextState:"2"},"d|qd|dq":{action_:{type_:"- after o/d",option:!0},nextState:"2"},"D|qD|p":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},amount2:{"1|3":{action_:"a=",nextState:"a"}},letters:{"0|1|2|3|a|as|b|p|bp|o":{action_:"o=",nextState:"o"},"q|dq":{action_:["output","o="],nextState:"o"},"d|D|qd|qD":{action_:"o after d",nextState:"o"}},digits:{o:{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},q:{action_:["output","o="],nextState:"o"},a:{action_:"o=",nextState:"o"}},"space A":{"b|p|bp":{}},space:{a:{nextState:"as"},0:{action_:"sb=false"},"1|2":{action_:"sb=true"},"r|rt|rd|rdt|rdq":{action_:"output",nextState:"0"},"*":{action_:["output","sb=true"],nextState:"1"}},"1st-level escape":{"1|2":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}]},"*":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}],nextState:"0"}},"[(...)]":{"r|rt":{action_:"rd=",nextState:"rd"},"rd|rdt":{action_:"rq=",nextState:"rdq"}},"...":{"o|d|D|dq|qd|qD":{action_:["output",{type_:"bond",option:"..."}],nextState:"3"},"*":{action_:[{type_:"output",option:1},{type_:"insert",option:"ellipsis"}],nextState:"1"}},". |* ":{"*":{action_:["output",{type_:"insert",option:"addition compound"}],nextState:"1"}},"state of aggregation $":{"*":{action_:["output","state of aggregation"],nextState:"1"}},"{[(":{"a|as|o":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"0|1|2|3":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"*":{action_:["output","o=","output","parenthesisLevel++"],nextState:"2"}},")]}":{"0|1|2|3|b|p|bp|o":{action_:["o=","parenthesisLevel--"],nextState:"o"},"a|as|d|D|q|qd|qD|dq":{action_:["output","o=","parenthesisLevel--"],nextState:"o"}},", ":{"*":{action_:["output","comma"],nextState:"0"}},"^_":{"*":{}},"^{(...)}|^($...$)":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"D"},q:{action_:"d=",nextState:"qD"},"d|D|qd|qD|dq":{action_:["output","d="],nextState:"D"}},"^a|^\\x{}{}|^\\x{}|^\\x|'":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"d"},q:{action_:"d=",nextState:"qd"},"d|qd|D|qD":{action_:"d="},dq:{action_:["output","d="],nextState:"d"}},"_{(state of aggregation)}$":{"d|D|q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x":{"0|1|2|as":{action_:"p=",nextState:"p"},b:{action_:"p=",nextState:"bp"},"3|o":{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},"q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"=<>":{"0|1|2|3|a|as|o|q|d|D|qd|qD|dq":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"#":{"0|1|2|3|a|as|o":{action_:[{type_:"output",option:2},{type_:"bond",option:"#"}],nextState:"3"}},"{}":{"*":{action_:{type_:"output",option:1},nextState:"1"}},"{...}":{"0|1|2|3|a|as|b|p|bp":{action_:"o=",nextState:"o"},"o|d|D|q|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"$...$":{a:{action_:"a="},"0|1|2|3|as|b|p|bp|o":{action_:"o=",nextState:"o"},"as|o":{action_:"o="},"q|d|D|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"\\bond{(...)}":{"*":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"\\frac{(...)}":{"*":{action_:[{type_:"output",option:1},"frac-output"],nextState:"3"}},"\\overset{(...)}":{"*":{action_:[{type_:"output",option:2},"overset-output"],nextState:"3"}},"\\underset{(...)}":{"*":{action_:[{type_:"output",option:2},"underset-output"],nextState:"3"}},"\\underbrace{(...)}":{"*":{action_:[{type_:"output",option:2},"underbrace-output"],nextState:"3"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:[{type_:"output",option:2},"color-output"],nextState:"3"}},"\\color{(...)}0":{"*":{action_:[{type_:"output",option:2},"color0-output"]}},"\\ce{(...)}":{"*":{action_:[{type_:"output",option:2},"ce"],nextState:"3"}},"\\,":{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"1"}},"\\x{}{}|\\x{}|\\x":{"0|1|2|3|a|as|b|p|bp|o|c0":{action_:["o=","output"],nextState:"3"},"*":{action_:["output","o=","output"],nextState:"3"}},others:{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"3"}},else2:{a:{action_:"a to o",nextState:"o",revisit:!0},as:{action_:["output","sb=true"],nextState:"1",revisit:!0},"r|rt|rd|rdt|rdq":{action_:["output"],nextState:"0",revisit:!0},"*":{action_:["output","copy"],nextState:"3"}}}),actions:{"o after d":function(e,t){var r;if((e.d||"").match(/^[0-9]+$/)){var o=e.d;e.d=void 0,r=this.output(e),e.b=o}else r=this.output(e);return y.actions["o="](e,t),r},"d= kv":function(e,t){e.d=t,e.dType="kv"},"charge or bond":function(e,t){if(e.beginsWithBond){var r=[];return y.concatArray(r,this.output(e)),y.concatArray(r,y.actions.bond(e,t,"-")),r}else e.d=t},"- after o/d":function(e,t,r){var o=y.patterns.match_("orbital",e.o||""),s=y.patterns.match_("one lowercase greek letter $",e.o||""),i=y.patterns.match_("one lowercase latin letter $",e.o||""),l=y.patterns.match_("$one lowercase latin letter$ $",e.o||""),u=t==="-"&&(o&&o.remainder===""||s||i||l);u&&!e.a&&!e.b&&!e.p&&!e.d&&!e.q&&!o&&i&&(e.o="$"+e.o+"$");var h=[];return u?(y.concatArray(h,this.output(e)),h.push({type_:"hyphen"})):(o=y.patterns.match_("digits",e.d||""),r&&o&&o.remainder===""?(y.concatArray(h,y.actions["d="](e,t)),y.concatArray(h,this.output(e))):(y.concatArray(h,this.output(e)),y.concatArray(h,y.actions.bond(e,t,"-")))),h},"a to o":function(e){e.o=e.a,e.a=void 0},"sb=true":function(e){e.sb=!0},"sb=false":function(e){e.sb=!1},"beginsWithBond=true":function(e){e.beginsWithBond=!0},"beginsWithBond=false":function(e){e.beginsWithBond=!1},"parenthesisLevel++":function(e){e.parenthesisLevel++},"parenthesisLevel--":function(e){e.parenthesisLevel--},"state of aggregation":function(e,t){return{type_:"state of aggregation",p1:y.go(t,"o")}},comma:function(e,t){var r=t.replace(/\s*$/,""),o=r!==t;return o&&e.parenthesisLevel===0?{type_:"comma enumeration L",p1:r}:{type_:"comma enumeration M",p1:r}},output:function(e,t,r){var o;if(!e.r)o=[],!e.a&&!e.b&&!e.p&&!e.o&&!e.q&&!e.d&&!r||(e.sb&&o.push({type_:"entitySkip"}),!e.o&&!e.q&&!e.d&&!e.b&&!e.p&&r!==2?(e.o=e.a,e.a=void 0):!e.o&&!e.q&&!e.d&&(e.b||e.p)?(e.o=e.a,e.d=e.b,e.q=e.p,e.a=e.b=e.p=void 0):e.o&&e.dType==="kv"&&y.patterns.match_("d-oxidation$",e.d||"")?e.dType="oxidation":e.o&&e.dType==="kv"&&!e.q&&(e.dType=void 0),o.push({type_:"chemfive",a:y.go(e.a,"a"),b:y.go(e.b,"bd"),p:y.go(e.p,"pq"),o:y.go(e.o,"o"),q:y.go(e.q,"pq"),d:y.go(e.d,e.dType==="oxidation"?"oxidation":"bd"),dType:e.dType}));else{var s;e.rdt==="M"?s=y.go(e.rd,"tex-math"):e.rdt==="T"?s=[{type_:"text",p1:e.rd||""}]:s=y.go(e.rd);var i;e.rqt==="M"?i=y.go(e.rq,"tex-math"):e.rqt==="T"?i=[{type_:"text",p1:e.rq||""}]:i=y.go(e.rq),o={type_:"arrow",r:e.r,rd:s,rq:i}}for(var l in e)l!=="parenthesisLevel"&&l!=="beginsWithBond"&&delete e[l];return o},"oxidation-output":function(e,t){var r=["{"];return y.concatArray(r,y.go(t,"oxidation")),r.push("}"),r},"frac-output":function(e,t){return{type_:"frac-ce",p1:y.go(t[0]),p2:y.go(t[1])}},"overset-output":function(e,t){return{type_:"overset",p1:y.go(t[0]),p2:y.go(t[1])}},"underset-output":function(e,t){return{type_:"underset",p1:y.go(t[0]),p2:y.go(t[1])}},"underbrace-output":function(e,t){return{type_:"underbrace",p1:y.go(t[0]),p2:y.go(t[1])}},"color-output":function(e,t){return{type_:"color",color1:t[0],color2:y.go(t[1])}},"r=":function(e,t){e.r=t},"rdt=":function(e,t){e.rdt=t},"rd=":function(e,t){e.rd=t},"rqt=":function(e,t){e.rqt=t},"rq=":function(e,t){e.rq=t},operator:function(e,t,r){return{type_:"operator",kind_:r||t}}}},a:{transitions:y.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},"$(...)$":{"*":{action_:"tex-math tight",nextState:"1"}},",":{"*":{action_:{type_:"insert",option:"commaDecimal"}}},else2:{"*":{action_:"copy"}}}),actions:{}},o:{transitions:y.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},letters:{"*":{action_:"rm"}},"\\ca":{"*":{action_:{type_:"insert",option:"circa"}}},"\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"{text}"}},else2:{"*":{action_:"copy"}}}),actions:{}},text:{transitions:y.createTransitions({empty:{"*":{action_:"output"}},"{...}":{"*":{action_:"text="}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"\\greek":{"*":{action_:["output","rm"]}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:["output","copy"]}},else:{"*":{action_:"text="}}}),actions:{output:function(e){if(e.text_){var t={type_:"text",p1:e.text_};for(var r in e)delete e[r];return t}}}},pq:{transitions:y.createTransitions({empty:{"*":{}},"state of aggregation $":{"*":{action_:"state of aggregation"}},i$:{0:{nextState:"!f",revisit:!0}},"(KV letters),":{0:{action_:"rm",nextState:"0"}},formula$:{0:{nextState:"f",revisit:!0}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"!f",revisit:!0}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"a-z":{f:{action_:"tex-math"}},letters:{"*":{action_:"rm"}},"-9.,9":{"*":{action_:"9,9"}},",":{"*":{action_:{type_:"insert+p1",option:"comma enumeration S"}}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"state of aggregation":function(e,t){return{type_:"state of aggregation subscript",p1:y.go(t,"o")}},"color-output":function(e,t){return{type_:"color",color1:t[0],color2:y.go(t[1],"pq")}}}},bd:{transitions:y.createTransitions({empty:{"*":{}},x$:{0:{nextState:"!f",revisit:!0}},formula$:{0:{nextState:"f",revisit:!0}},else:{0:{nextState:"!f",revisit:!0}},"-9.,9 no missing 0":{"*":{action_:"9,9"}},".":{"*":{action_:{type_:"insert",option:"electron dot"}}},"a-z":{f:{action_:"tex-math"}},x:{"*":{action_:{type_:"insert",option:"KV x"}}},letters:{"*":{action_:"rm"}},"'":{"*":{action_:{type_:"insert",option:"prime"}}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"color-output":function(e,t){return{type_:"color",color1:t[0],color2:y.go(t[1],"bd")}}}},oxidation:{transitions:y.createTransitions({empty:{"*":{}},"roman numeral":{"*":{action_:"roman-numeral"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},else:{"*":{action_:"copy"}}}),actions:{"roman-numeral":function(e,t){return{type_:"roman numeral",p1:t||""}}}},"tex-math":{transitions:y.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},else:{"*":{action_:"o="}}}),actions:{output:function(e){if(e.o){var t={type_:"tex-math",p1:e.o};for(var r in e)delete e[r];return t}}}},"tex-math tight":{transitions:y.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},"-|+":{"*":{action_:"tight operator"}},else:{"*":{action_:"o="}}}),actions:{"tight operator":function(e,t){e.o=(e.o||"")+"{"+t+"}"},output:function(e){if(e.o){var t={type_:"tex-math",p1:e.o};for(var r in e)delete e[r];return t}}}},"9,9":{transitions:y.createTransitions({empty:{"*":{}},",":{"*":{action_:"comma"}},else:{"*":{action_:"copy"}}}),actions:{comma:function(){return{type_:"commaDecimal"}}}},pu:{transitions:y.createTransitions({empty:{"*":{action_:"output"}},space$:{"*":{action_:["output","space"]}},"{[(|)]}":{"0|a":{action_:"copy"}},"(-)(9)^(-9)":{0:{action_:"number^",nextState:"a"}},"(-)(9.,9)(e)(99)":{0:{action_:"enumber",nextState:"a"}},space:{"0|a":{}},"pm-operator":{"0|a":{action_:{type_:"operator",option:"\\pm"},nextState:"0"}},operator:{"0|a":{action_:"copy",nextState:"0"}},"//":{d:{action_:"o=",nextState:"/"}},"/":{d:{action_:"o=",nextState:"/"}},"{...}|else":{"0|d":{action_:"d=",nextState:"d"},a:{action_:["space","d="],nextState:"d"},"/|q":{action_:"q=",nextState:"q"}}}),actions:{enumber:function(e,t){var r=[];return t[0]==="+-"||t[0]==="+/-"?r.push("\\pm "):t[0]&&r.push(t[0]),t[1]&&(y.concatArray(r,y.go(t[1],"pu-9,9")),t[2]&&(t[2].match(/[,.]/)?y.concatArray(r,y.go(t[2],"pu-9,9")):r.push(t[2])),t[3]=t[4]||t[3],t[3]&&(t[3]=t[3].trim(),t[3]==="e"||t[3].substr(0,1)==="*"?r.push({type_:"cdot"}):r.push({type_:"times"}))),t[3]&&r.push("10^{"+t[5]+"}"),r},"number^":function(e,t){var r=[];return t[0]==="+-"||t[0]==="+/-"?r.push("\\pm "):t[0]&&r.push(t[0]),y.concatArray(r,y.go(t[1],"pu-9,9")),r.push("^{"+t[2]+"}"),r},operator:function(e,t,r){return{type_:"operator",kind_:r||t}},space:function(){return{type_:"pu-space-1"}},output:function(e){var t,r=y.patterns.match_("{(...)}",e.d||"");r&&r.remainder===""&&(e.d=r.match_);var o=y.patterns.match_("{(...)}",e.q||"");if(o&&o.remainder===""&&(e.q=o.match_),e.d&&(e.d=e.d.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),e.d=e.d.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F")),e.q){e.q=e.q.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),e.q=e.q.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F");var s={d:y.go(e.d,"pu"),q:y.go(e.q,"pu")};e.o==="//"?t={type_:"pu-frac",p1:s.d,p2:s.q}:(t=s.d,s.d.length>1||s.q.length>1?t.push({type_:" / "}):t.push({type_:"/"}),y.concatArray(t,s.q))}else t=y.go(e.d,"pu-2");for(var i in e)delete e[i];return t}}},"pu-2":{transitions:y.createTransitions({empty:{"*":{action_:"output"}},"*":{"*":{action_:["output","cdot"],nextState:"0"}},"\\x":{"*":{action_:"rm="}},space:{"*":{action_:["output","space"],nextState:"0"}},"^{(...)}|^(-1)":{1:{action_:"^(-1)"}},"-9.,9":{0:{action_:"rm=",nextState:"0"},1:{action_:"^(-1)",nextState:"0"}},"{...}|else":{"*":{action_:"rm=",nextState:"1"}}}),actions:{cdot:function(){return{type_:"tight cdot"}},"^(-1)":function(e,t){e.rm+="^{"+t+"}"},space:function(){return{type_:"pu-space-2"}},output:function(e){var t=[];if(e.rm){var r=y.patterns.match_("{(...)}",e.rm||"");r&&r.remainder===""?t=y.go(r.match_,"pu"):t={type_:"rm",p1:e.rm}}for(var o in e)delete e[o];return t}}},"pu-9,9":{transitions:y.createTransitions({empty:{0:{action_:"output-0"},o:{action_:"output-o"}},",":{0:{action_:["output-0","comma"],nextState:"o"}},".":{0:{action_:["output-0","copy"],nextState:"o"}},else:{"*":{action_:"text="}}}),actions:{comma:function(){return{type_:"commaDecimal"}},"output-0":function(e){var t=[];if(e.text_=e.text_||"",e.text_.length>4){var r=e.text_.length%3;r===0&&(r=3);for(var o=e.text_.length-3;o>0;o-=3)t.push(e.text_.substr(o,3)),t.push({type_:"1000 separator"});t.push(e.text_.substr(0,r)),t.reverse()}else t.push(e.text_);for(var s in e)delete e[s];return t},"output-o":function(e){var t=[];if(e.text_=e.text_||"",e.text_.length>4){for(var r=e.text_.length-3,o=0;o":return"\\yields";case"\u2192":return"\\yields";case"\u27F6":return"\\yields";case"<-":return"\\yieldsLeft";case"<->":return"\\mesomerism";case"<-->":return"\\yieldsLeftRight";case"<=>":return"\\equilibrium";case"\u21CC":return"\\equilibrium";case"<=>>":return"\\equilibriumRight";case"<<=>":return"\\equilibriumLeft";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getBond:function(e){switch(e){case"-":return"{-}";case"1":return"{-}";case"=":return"{=}";case"2":return"{=}";case"#":return"{\\equiv}";case"3":return"{\\equiv}";case"~":return"{\\tripleDash}";case"~-":return"{\\tripleDashOverLine}";case"~=":return"{\\tripleDashOverDoubleLine}";case"~--":return"{\\tripleDashOverDoubleLine}";case"-~-":return"{\\tripleDashBetweenDoubleLine}";case"...":return"{{\\cdot}{\\cdot}{\\cdot}}";case"....":return"{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}";case"->":return"{\\rightarrow}";case"<-":return"{\\leftarrow}";case"<":return"{<}";case">":return"{>}";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getOperator:function(e){switch(e){case"+":return" {}+{} ";case"-":return" {}-{} ";case"=":return" {}={} ";case"<":return" {}<{} ";case">":return" {}>{} ";case"<<":return" {}\\ll{} ";case">>":return" {}\\gg{} ";case"\\pm":return" {}\\pm{} ";case"\\approx":return" {}\\approx{} ";case"$\\approx$":return" {}\\approx{} ";case"v":return" \\downarrow{} ";case"(v)":return" \\downarrow{} ";case"^":return" \\uparrow{} ";case"(^)":return" \\uparrow{} ";default:throw["MhchemBugT","mhchem bug T. Please report."]}}};c("\\darr","\\downarrow");c("\\dArr","\\Downarrow");c("\\Darr","\\Downarrow");c("\\lang","\\langle");c("\\rang","\\rangle");c("\\uarr","\\uparrow");c("\\uArr","\\Uparrow");c("\\Uarr","\\Uparrow");c("\\N","\\mathbb{N}");c("\\R","\\mathbb{R}");c("\\Z","\\mathbb{Z}");c("\\alef","\\aleph");c("\\alefsym","\\aleph");c("\\bull","\\bullet");c("\\clubs","\\clubsuit");c("\\cnums","\\mathbb{C}");c("\\Complex","\\mathbb{C}");c("\\Dagger","\\ddagger");c("\\diamonds","\\diamondsuit");c("\\empty","\\emptyset");c("\\exist","\\exists");c("\\harr","\\leftrightarrow");c("\\hArr","\\Leftrightarrow");c("\\Harr","\\Leftrightarrow");c("\\hearts","\\heartsuit");c("\\image","\\Im");c("\\infin","\\infty");c("\\isin","\\in");c("\\larr","\\leftarrow");c("\\lArr","\\Leftarrow");c("\\Larr","\\Leftarrow");c("\\lrarr","\\leftrightarrow");c("\\lrArr","\\Leftrightarrow");c("\\Lrarr","\\Leftrightarrow");c("\\natnums","\\mathbb{N}");c("\\plusmn","\\pm");c("\\rarr","\\rightarrow");c("\\rArr","\\Rightarrow");c("\\Rarr","\\Rightarrow");c("\\real","\\Re");c("\\reals","\\mathbb{R}");c("\\Reals","\\mathbb{R}");c("\\sdot","\\cdot");c("\\sect","\\S");c("\\spades","\\spadesuit");c("\\sub","\\subset");c("\\sube","\\subseteq");c("\\supe","\\supseteq");c("\\thetasym","\\vartheta");c("\\weierp","\\wp");c("\\quantity","{\\left\\{ #1 \\right\\}}");c("\\qty","{\\left\\{ #1 \\right\\}}");c("\\pqty","{\\left( #1 \\right)}");c("\\bqty","{\\left[ #1 \\right]}");c("\\vqty","{\\left\\vert #1 \\right\\vert}");c("\\Bqty","{\\left\\{ #1 \\right\\}}");c("\\absolutevalue","{\\left\\vert #1 \\right\\vert}");c("\\abs","{\\left\\vert #1 \\right\\vert}");c("\\norm","{\\left\\Vert #1 \\right\\Vert}");c("\\evaluated","{\\left.#1 \\right\\vert}");c("\\eval","{\\left.#1 \\right\\vert}");c("\\order","{\\mathcal{O} \\left( #1 \\right)}");c("\\commutator","{\\left[ #1 , #2 \\right]}");c("\\comm","{\\left[ #1 , #2 \\right]}");c("\\anticommutator","{\\left\\{ #1 , #2 \\right\\}}");c("\\acomm","{\\left\\{ #1 , #2 \\right\\}}");c("\\poissonbracket","{\\left\\{ #1 , #2 \\right\\}}");c("\\pb","{\\left\\{ #1 , #2 \\right\\}}");c("\\vectorbold","{\\boldsymbol{ #1 }}");c("\\vb","{\\boldsymbol{ #1 }}");c("\\vectorarrow","{\\vec{\\boldsymbol{ #1 }}}");c("\\va","{\\vec{\\boldsymbol{ #1 }}}");c("\\vectorunit","{{\\boldsymbol{\\hat{ #1 }}}}");c("\\vu","{{\\boldsymbol{\\hat{ #1 }}}}");c("\\dotproduct","\\mathbin{\\boldsymbol\\cdot}");c("\\vdot","{\\boldsymbol\\cdot}");c("\\crossproduct","\\mathbin{\\boldsymbol\\times}");c("\\cross","\\mathbin{\\boldsymbol\\times}");c("\\cp","\\mathbin{\\boldsymbol\\times}");c("\\gradient","{\\boldsymbol\\nabla}");c("\\grad","{\\boldsymbol\\nabla}");c("\\divergence","{\\grad\\vdot}");c("\\curl","{\\grad\\cross}");c("\\laplacian","\\nabla^2");c("\\tr","{\\operatorname{tr}}");c("\\Tr","{\\operatorname{Tr}}");c("\\rank","{\\operatorname{rank}}");c("\\erf","{\\operatorname{erf}}");c("\\Res","{\\operatorname{Res}}");c("\\principalvalue","{\\mathcal{P}}");c("\\pv","{\\mathcal{P}}");c("\\PV","{\\operatorname{P.V.}}");c("\\qqtext","{\\quad\\text{ #1 }\\quad}");c("\\qq","{\\quad\\text{ #1 }\\quad}");c("\\qcomma","{\\text{,}\\quad}");c("\\qc","{\\text{,}\\quad}");c("\\qcc","{\\quad\\text{c.c.}\\quad}");c("\\qif","{\\quad\\text{if}\\quad}");c("\\qthen","{\\quad\\text{then}\\quad}");c("\\qelse","{\\quad\\text{else}\\quad}");c("\\qotherwise","{\\quad\\text{otherwise}\\quad}");c("\\qunless","{\\quad\\text{unless}\\quad}");c("\\qgiven","{\\quad\\text{given}\\quad}");c("\\qusing","{\\quad\\text{using}\\quad}");c("\\qassume","{\\quad\\text{assume}\\quad}");c("\\qsince","{\\quad\\text{since}\\quad}");c("\\qlet","{\\quad\\text{let}\\quad}");c("\\qfor","{\\quad\\text{for}\\quad}");c("\\qall","{\\quad\\text{all}\\quad}");c("\\qeven","{\\quad\\text{even}\\quad}");c("\\qodd","{\\quad\\text{odd}\\quad}");c("\\qinteger","{\\quad\\text{integer}\\quad}");c("\\qand","{\\quad\\text{and}\\quad}");c("\\qor","{\\quad\\text{or}\\quad}");c("\\qas","{\\quad\\text{as}\\quad}");c("\\qin","{\\quad\\text{in}\\quad}");c("\\differential","{\\text{d}}");c("\\dd","{\\text{d}}");c("\\derivative","{\\frac{\\text{d}{ #1 }}{\\text{d}{ #2 }}}");c("\\dv","{\\frac{\\text{d}{ #1 }}{\\text{d}{ #2 }}}");c("\\partialderivative","{\\frac{\\partial{ #1 }}{\\partial{ #2 }}}");c("\\variation","{\\delta}");c("\\var","{\\delta}");c("\\functionalderivative","{\\frac{\\delta{ #1 }}{\\delta{ #2 }}}");c("\\fdv","{\\frac{\\delta{ #1 }}{\\delta{ #2 }}}");c("\\innerproduct","{\\left\\langle {#1} \\mid { #2} \\right\\rangle}");c("\\outerproduct","{\\left\\vert { #1 } \\right\\rangle\\left\\langle { #2} \\right\\vert}");c("\\dyad","{\\left\\vert { #1 } \\right\\rangle\\left\\langle { #2} \\right\\vert}");c("\\ketbra","{\\left\\vert { #1 } \\right\\rangle\\left\\langle { #2} \\right\\vert}");c("\\op","{\\left\\vert { #1 } \\right\\rangle\\left\\langle { #2} \\right\\vert}");c("\\expectationvalue","{\\left\\langle {#1 } \\right\\rangle}");c("\\expval","{\\left\\langle {#1 } \\right\\rangle}");c("\\ev","{\\left\\langle {#1 } \\right\\rangle}");c("\\matrixelement","{\\left\\langle{ #1 }\\right\\vert{ #2 }\\left\\vert{#3}\\right\\rangle}");c("\\matrixel","{\\left\\langle{ #1 }\\right\\vert{ #2 }\\left\\vert{#3}\\right\\rangle}");c("\\mel","{\\left\\langle{ #1 }\\right\\vert{ #2 }\\left\\vert{#3}\\right\\rangle}");function _t(e){let t=[];e.consumeSpaces();let r=e.fetch().text;for(r==="\\relax"&&(e.consume(),e.consumeSpaces(),r=e.fetch().text);r==="\\hline"||r==="\\hdashline";)e.consume(),t.push(r==="\\hdashline"),e.consumeSpaces(),r=e.fetch().text;return t}var ke=e=>{if(!e.parser.settings.displayMode)throw new w(`{${e.envName}} can be used only in display mode.`)},pn=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,or=e=>{let t=e.get("\\arraystretch");typeof t!="string"&&(t=He(t.tokens)),t=isNaN(t)?null:Number(t);let r=e.get("\\arraycolsep");typeof r!="string"&&(r=He(r.tokens));let o=pn.exec(r),s=o?{number:+(o[1]+o[2]),unit:o[3]}:null;return[t,s]},Tt=e=>{let t="";for(let r=0;r1||!i)&&b.pop(),T.push(Tt(H.body)),$.length{let t=new p.MathNode("mtd",[]);return t.style={padding:"0",width:"50%"},e.envClasses.includes("multline")&&(t.style.width="7.5%"),t},Y=function(e,t){let r=[],o=e.body.length,s=e.hLinesBeforeRow;for(let u=0;u0&&(s[0].length===2?b.children.forEach(T=>{T.style.borderTop="0.15em double"}):b.children.forEach(T=>{T.style.borderTop=s[0][0]?"0.06em dashed":"0.06em solid"})),s[u+1].length>0&&(s[u+1].length===2?b.children.forEach(T=>{T.style.borderBottom="0.15em double"}):b.children.forEach(T=>{T.style.borderBottom=s[u+1][0]?"0.06em dashed":"0.06em solid"})),r.push(b)}if(e.envClasses.length>0){if(e.arraystretch&&e.arraystretch!==1){let b=String(1.4*e.arraystretch-.8)+"ex";for(let k=0;kb===0&&k===0||b===x-1&&k===1?"0":e.envClasses[0]!=="align"?u:k===1?"0":e.autoTag?b%2?"1":"0":b%2?"0":"1";for(let b=0;b1&&e.envClasses.includes("cases")&&(k.children[1].style.paddingLeft="1em"),e.envClasses.includes("cases")||e.envClasses.includes("subarray"))for(let T of k.children)T.classes.push("tml-left")}}else for(let u=0;u0&&(e.envClasses.includes("jot")?i.classes.push("tml-jot"):e.envClasses.includes("small")&&i.classes.push("tml-small")),e.scriptLevel==="display"&&i.setAttribute("displaystyle","true"),(e.autoTag||e.envClasses.includes("multline"))&&(i.style.width="100%");let l="";if(e.cols&&e.cols.length>0){let u=e.cols,h=!1,x=0,A=u.length;for(;u[x].type==="separator";)x+=1;for(;u[A-1].type==="separator";)A-=1;if(u[0].type==="separator"){let b=u[1].type==="separator"?"0.15em double":u[0].separator==="|"?"0.06em solid ":"0.06em dashed ";for(let k of i.children)k.children[0].style.borderLeft=b}let q=e.autoTag?0:-1;for(let b=x;b0?l:"center ")+"right "),l&&i.setAttribute("columnalign",l.trim()),e.envClasses.includes("small")&&(i=new p.MathNode("mstyle",[i]),i.setAttribute("scriptlevel","1")),i},sr=function(e,t){e.envName.indexOf("ed")===-1&&ke(e);let r=e.envName==="split",o=[],s=re(e.parser,{cols:o,emptySingleRow:!0,autoTag:r?void 0:ot(e.envName),envClasses:["abut","jot"],maxNumCols:e.envName==="split"?2:void 0,leqno:e.parser.settings.leqno},"display"),i,l=0,u=e.envName.indexOf("at")>-1;if(t[0]&&u){let h="";for(let x=0;x1)throw new w("{subarray} can contain only one column");let i={cols:s,envClasses:["small"]};if(i=re(e.parser,i,"script"),i.body.length>0&&i.body[0].length>1)throw new w("{subarray} can contain only one column");return i},mathmlBuilder:Y});X({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(e){let t={cols:[],envClasses:["cases"]},r=re(e.parser,t,ar(e.envName));return{type:"leftright",mode:e.mode,body:[r],left:e.envName.indexOf("r")>-1?".":"\\{",right:e.envName.indexOf("r")>-1?"\\}":".",rightColor:void 0}},mathmlBuilder:Y});X({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:sr,mathmlBuilder:Y});X({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:sr,mathmlBuilder:Y});X({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(e){e.envName!=="gathered"&&ke(e);let t={cols:[],envClasses:["abut","jot"],autoTag:ot(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return re(e.parser,t,"display")},mathmlBuilder:Y});X({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(e){ke(e);let t={autoTag:ot(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,envClasses:["align"],leqno:e.parser.settings.leqno};return re(e.parser,t,"display")},mathmlBuilder:Y});X({type:"array",names:["multline","multline*"],props:{numArgs:0},handler(e){ke(e);let t={autoTag:e.envName==="multline",maxNumCols:1,envClasses:["jot","multline"],leqno:e.parser.settings.leqno};return re(e.parser,t,"display")},mathmlBuilder:Y});X({type:"array",names:["CD"],props:{numArgs:0},handler(e){return ke(e),rn(e.parser)},mathmlBuilder:Y});S({type:"text",names:["\\hline","\\hdashline"],props:{numArgs:0,allowedInText:!0,allowedInMath:!0},handler(e,t){throw new w(`${e.funcName} valid only within array environment`)}});var Dt=Qt;S({type:"environment",names:["\\begin","\\end"],props:{numArgs:1,argTypes:["text"]},handler({parser:e,funcName:t},r){let o=r[0];if(o.type!=="ordgroup")throw new w("Invalid environment name",o);let s="";for(let i=0;i{if(t!=="mathrm"||e.body.type!=="ordgroup"||e.body.body.length===1||e.body.body[0].type!=="mathord")return!1;for(let r=1;r{let r=e.font,o=t.withFont(r),s=O(e.body,o);if(s.children.length===0)return s;if(r==="boldsymbol"&&["mo","mpadded","mrow"].includes(s.type))return s.style.fontWeight="bold",s;if(gn(e,r)){let u=s.children[0].children[0];delete u.attributes.mathvariant;for(let x=1;x{let o=fe(r[0]),s=t;return s in Bt&&(s=Bt[s]),{type:"font",mode:e.mode,font:s.slice(1),body:o}},mathmlBuilder:ir});S({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],props:{numArgs:0,allowedInText:!0},handler:({parser:e,funcName:t,breakOnTokenText:r},o)=>{let{mode:s}=e,i=e.parseExpression(!0,r,!0),l=`math${t.slice(1)}`;return{type:"font",mode:s,font:l,body:{type:"ordgroup",mode:e.mode,body:i}}},mathmlBuilder:ir});var Nt=["display","text","script","scriptscript"],bn={auto:-1,display:0,text:0,script:1,scriptscript:2},at=(e,t)=>{let r=e.scriptLevel==="auto"?t.incrementLevel():e.scriptLevel==="display"?t.withLevel(F.TEXT):e.scriptLevel==="text"?t.withLevel(F.SCRIPT):t.withLevel(F.SCRIPTSCRIPT),o=O(e.numer,r),s=O(e.denom,r);t.level===3&&(o.style.mathDepth="2",o.setAttribute("scriptlevel","2"),s.style.mathDepth="2",s.setAttribute("scriptlevel","2"));let i=new p.MathNode("mfrac",[o,s]);if(!e.hasBarLine)i.setAttribute("linethickness","0px");else if(e.barSize){let l=K(e.barSize,t);i.setAttribute("linethickness",l.number+l.unit)}if(e.leftDelim!=null||e.rightDelim!=null){let l=[];if(e.leftDelim!=null){let u=new p.MathNode("mo",[new p.TextNode(e.leftDelim.replace("\\",""))]);u.setAttribute("fence","true"),l.push(u)}if(l.push(i),e.rightDelim!=null){let u=new p.MathNode("mo",[new p.TextNode(e.rightDelim.replace("\\",""))]);u.setAttribute("fence","true"),l.push(u)}i=Qe(l)}return e.scriptLevel!=="auto"&&(i=new p.MathNode("mstyle",[i]),i.setAttribute("displaystyle",String(e.scriptLevel==="display")),i.setAttribute("scriptlevel",bn[e.scriptLevel])),i};S({type:"genfrac",names:["\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],props:{numArgs:2,allowedInArgument:!0},handler:({parser:e,funcName:t},r)=>{let o=r[0],s=r[1],i=!1,l=null,u=null,h="auto";switch(t){case"\\dfrac":case"\\frac":case"\\tfrac":i=!0;break;case"\\\\atopfrac":i=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":l="(",u=")";break;case"\\\\bracefrac":l="\\{",u="\\}";break;case"\\\\brackfrac":l="[",u="]";break;default:throw new Error("Unrecognized genfrac command")}switch(t){case"\\dfrac":case"\\dbinom":h="display";break;case"\\tfrac":case"\\tbinom":h="text";break}return{type:"genfrac",mode:e.mode,continued:!1,numer:o,denom:s,hasBarLine:i,leftDelim:l,rightDelim:u,scriptLevel:h,barSize:null}},mathmlBuilder:at});S({type:"genfrac",names:["\\cfrac"],props:{numArgs:2},handler:({parser:e,funcName:t},r)=>{let o=r[0],s=r[1];return{type:"genfrac",mode:e.mode,continued:!0,numer:o,denom:s,hasBarLine:!0,leftDelim:null,rightDelim:null,scriptLevel:"display",barSize:null}}});S({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],props:{numArgs:0,infix:!0},handler({parser:e,funcName:t,token:r}){let o;switch(t){case"\\over":o="\\frac";break;case"\\choose":o="\\binom";break;case"\\atop":o="\\\\atopfrac";break;case"\\brace":o="\\\\bracefrac";break;case"\\brack":o="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:e.mode,replaceWith:o,token:r}}});var Ot=function(e){let t=null;return e.length>0&&(t=e,t=t==="."?null:t),t};S({type:"genfrac",names:["\\genfrac"],props:{numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"]},handler({parser:e},t){let r=t[4],o=t[5],s=fe(t[0]),i=s.type==="atom"&&s.family==="open"?Ot(s.text):null,l=fe(t[1]),u=l.type==="atom"&&l.family==="close"?Ot(l.text):null,h=C(t[2],"size"),x,A=null;h.isBlank?x=!0:(A=h.value,x=A.number>0);let q="auto",b=t[3];if(b.type==="ordgroup"){if(b.body.length>0){let k=C(b.body[0],"textord");q=Nt[Number(k.text)]}}else b=C(b,"textord"),q=Nt[Number(b.text)];return{type:"genfrac",mode:e.mode,numer:r,denom:o,continued:!1,hasBarLine:x,barSize:A,leftDelim:i,rightDelim:u,scriptLevel:q}},mathmlBuilder:at});S({type:"infix",names:["\\above"],props:{numArgs:1,argTypes:["size"],infix:!0},handler({parser:e,funcName:t,token:r},o){return{type:"infix",mode:e.mode,replaceWith:"\\\\abovefrac",barSize:C(o[0],"size").value,token:r}}});S({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:({parser:e,funcName:t},r)=>{let o=r[0],s=_r(C(r[1],"infix").barSize),i=r[2],l=s.number>0;return{type:"genfrac",mode:e.mode,numer:o,denom:i,continued:!1,hasBarLine:l,barSize:s,leftDelim:null,rightDelim:null,scriptLevel:"auto"}},mathmlBuilder:at});S({type:"hbox",names:["\\hbox"],props:{numArgs:1,argTypes:["hbox"],allowedInArgument:!0,allowedInText:!1},handler({parser:e},t){return{type:"hbox",mode:e.mode,body:z(t[0])}},mathmlBuilder(e,t){let r=t.withLevel(F.TEXT),o=te(e.body,r);return Ee(o)}});var xn=(e,t)=>{let r=Me.mathMLnode(e.label);return r.style["math-depth"]=0,new p.MathNode(e.isOver?"mover":"munder",[O(e.base,t),r])};S({type:"horizBrace",names:["\\overbrace","\\underbrace"],props:{numArgs:1},handler({parser:e,funcName:t},r){return{type:"horizBrace",mode:e.mode,label:t,isOver:/^\\over/.test(t),base:r[0]}},mathmlBuilder:xn});S({type:"href",names:["\\href"],props:{numArgs:2,argTypes:["url","original"],allowedInText:!0},handler:({parser:e,token:t},r)=>{let o=r[1],s=C(r[0],"url").url;if(!e.settings.isTrusted({command:"\\href",url:s}))throw new w('Function "\\href" is not trusted',t);return{type:"href",mode:e.mode,href:s,body:z(o)}},mathmlBuilder:(e,t)=>{let r=new R("math",[te(e.body,t)]);return new be(e.href,[],[r])}});S({type:"href",names:["\\url"],props:{numArgs:1,argTypes:["url"],allowedInText:!0},handler:({parser:e,token:t},r)=>{let o=C(r[0],"url").url;if(!e.settings.isTrusted({command:"\\url",url:o}))throw new w('Function "\\url" is not trusted',t);let s=[];for(let l=0;l{let s=C(o[0],"raw").string,i=o[1];if(e.settings.strict)throw new w(`Function "${t}" is disabled in strict mode`,r);let l,u={};switch(t){case"\\class":u.class=s,l={command:"\\class",class:s};break;case"\\id":u.id=s,l={command:"\\id",id:s};break;case"\\style":u.style=s,l={command:"\\style",style:s};break;case"\\data":{let h=s.split(",");for(let x=0;x{let r=te(e.body,t),o=[];e.attributes.class&&o.push(...e.attributes.class.trim().split(/\s+/)),r.classes=o;for(let s in e.attributes)s!=="class"&&Object.prototype.hasOwnProperty.call(e.attributes,s)&&r.setAttribute(s,e.attributes[s]);return r}});var Pe=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:"bp"};{let t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new w("Invalid size: '"+e+"' in \\includegraphics");let r={number:+(t[1]+t[2]),unit:t[3]};if(!Zt(r))throw new w("Invalid unit: '"+r.unit+"' in \\includegraphics.");return r}};S({type:"includegraphics",names:["\\includegraphics"],props:{numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1},handler:({parser:e,token:t},r,o)=>{let s={number:0,unit:"em"},i={number:.9,unit:"em"},l={number:0,unit:"em"},u="";if(o[0]){let A=C(o[0],"raw").string.split(",");for(let q=0;q{let r=K(e.height,t),o={number:0,unit:"em"};e.totalheight.number>0&&e.totalheight.unit===r.unit&&e.totalheight.number>r.number&&(o.number=e.totalheight.number-r.number,o.unit=r.unit);let s=0;e.width.number>0&&(s=K(e.width,t));let i={height:r.number+o.number+"em"};s.number>0&&(i.width=s.number+s.unit),o.number>0&&(i.verticalAlign=-o.number+o.unit);let l=new Re(e.src,e.alt,i);return l.height=r,l.depth=o,new p.MathNode("mtext",[l])}});S({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],props:{numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0},handler({parser:e,funcName:t,token:r},o){let s=C(o[0],"size");if(e.settings.strict){let i=t[1]==="m",l=s.value.unit==="mu";if(i){if(!l)throw new w(`LaTeX's ${t} supports only mu units, not ${s.value.unit} units`,r);if(e.mode!=="math")throw new w(`LaTeX's ${t} works only in math mode`,r)}else if(l)throw new w(`LaTeX's ${t} doesn't support mu units`,r)}return{type:"kern",mode:e.mode,dimension:s.value}},mathmlBuilder(e,t){let r=K(e.dimension,t),o=r.unit==="em"?lr(r.number):"";if(e.mode==="text"&&o.length>0){let s=new p.TextNode(o);return new p.MathNode("mtext",[s])}else{let s=new p.MathNode("mspace");return s.setAttribute("width",r.number+r.unit),r.number<0&&(s.style.marginLeft=r.number+r.unit),s}}});var lr=function(e){return e>=.05555&&e<=.05556?"\u200A":e>=.1666&&e<=.1667?"\u2009":e>=.2222&&e<=.2223?"\u2005":e>=.2777&&e<=.2778?"\u2005\u200A":""},ur=/[^A-Za-z_0-9-]/g;S({type:"label",names:["\\label"],props:{numArgs:1,argTypes:["raw"]},handler({parser:e},t){return{type:"label",mode:e.mode,string:t[0].string.replace(ur,"")}},mathmlBuilder(e,t){let r=new p.MathNode("mrow",[],["tml-label"]);return e.string.length>0&&r.setLabel(e.string),r}});var yn=["\\clap","\\llap","\\rlap"];S({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap","\\clap","\\llap","\\rlap"],props:{numArgs:1,allowedInText:!0},handler:({parser:e,funcName:t,token:r},o)=>{if(yn.includes(t)){if(e.settings.strict&&e.mode!=="text")throw new w(`{${t}} can be used only in text mode. Try \\math${t.slice(1)}`,r);t=t.slice(1)}else t=t.slice(5);let s=o[0];return{type:"lap",mode:e.mode,alignment:t,body:s}},mathmlBuilder:(e,t)=>{let r;if(e.alignment==="llap"){let i=U(z(e.body),t),l=new p.MathNode("mphantom",i);r=new p.MathNode("mpadded",[l]),r.setAttribute("width","0px")}let o=O(e.body,t),s;if(e.alignment==="llap"?(o.style.position="absolute",o.style.right="0",o.style.bottom="0",s=new p.MathNode("mpadded",[r,o])):s=new p.MathNode("mpadded",[o]),e.alignment==="rlap")e.body.body.length>0&&e.body.body[0].type==="genfrac"&&s.setAttribute("lspace","0.16667em");else{let i=e.alignment==="llap"?"-1":"-0.5";s.setAttribute("lspace",i+"width"),e.alignment==="llap"?s.style.position="relative":(s.style.display="flex",s.style.justifyContent="center")}return s.setAttribute("width","0px"),s}});S({type:"ordgroup",names:["\\(","$"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler({funcName:e,parser:t},r){let o=t.mode;t.switchMode("math");let s=e==="\\("?"\\)":"$",i=t.parseExpression(!1,s);return t.expect(s),t.switchMode(o),{type:"ordgroup",mode:t.mode,body:i}}});S({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(e,t){throw new w(`Mismatched ${e.funcName}`,t)}});var wn=(e,t)=>{switch(t.level){case F.DISPLAY:return e.display;case F.TEXT:return e.text;case F.SCRIPT:return e.script;case F.SCRIPTSCRIPT:return e.scriptscript;default:return e.text}};S({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:({parser:e},t)=>({type:"mathchoice",mode:e.mode,display:z(t[0]),text:z(t[1]),script:z(t[2]),scriptscript:z(t[3])}),mathmlBuilder:(e,t)=>{let r=wn(e,t);return te(r,t)}});var vn=["text","textord","mathord","atom"],ne=e=>{let t=new p.MathNode("mspace");return t.setAttribute("width",e+"em"),t};function cr(e,t){let r,o=U(e.body,t);if(e.mclass==="minner")r=new p.MathNode("mpadded",o);else if(e.mclass==="mord")e.isCharacterBox||o[0].type==="mathord"?(r=o[0],r.type="mi",r.children.length===1&&r.children[0].text&&r.children[0].text==="\u2207"&&r.setAttribute("mathvariant","normal")):r=new p.MathNode("mi",o);else{r=new p.MathNode("mrow",o),e.mustPromote?(r=o[0],r.type="mo",e.isCharacterBox&&e.body[0].text&&/[A-Za-z]/.test(e.body[0].text)&&r.setAttribute("mathvariant","italic")):r=new p.MathNode("mrow",o);let s=t.level<2;r.type==="mrow"?s&&(e.mclass==="mbin"?(r.children.unshift(ne(.2222)),r.children.push(ne(.2222))):e.mclass==="mrel"?(r.children.unshift(ne(.2778)),r.children.push(ne(.2778))):e.mclass==="mpunct"?r.children.push(ne(.1667)):e.mclass==="minner"&&(r.children.unshift(ne(.0556)),r.children.push(ne(.0556)))):e.mclass==="mbin"?(r.attributes.lspace=s?"0.2222em":"0",r.attributes.rspace=s?"0.2222em":"0"):e.mclass==="mrel"?(r.attributes.lspace=s?"0.2778em":"0",r.attributes.rspace=s?"0.2778em":"0"):e.mclass==="mpunct"?(r.attributes.lspace="0em",r.attributes.rspace=s?"0.1667em":"0"):e.mclass==="mopen"||e.mclass==="mclose"?(r.attributes.lspace="0em",r.attributes.rspace="0em"):e.mclass==="minner"&&s&&(r.attributes.lspace="0.0556em",r.attributes.width="+0.1111em"),e.mclass==="mopen"||e.mclass==="mclose"||(delete r.attributes.stretchy,delete r.attributes.form)}return r}S({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],props:{numArgs:1,primitive:!0},handler({parser:e,funcName:t},r){let o=r[0],s=N.isCharacterBox(o),i=!0,l={type:"mathord",text:"",mode:e.mode},u=o.body?o.body:[o];for(let h of u)if(vn.includes(h.type))I[e.mode][h.text]?l.text+=I[e.mode][h.text].replace:h.text?l.text+=h.text:h.body&&h.body.map(x=>{l.text+=x.text});else{i=!1;break}return{type:"mclass",mode:e.mode,mclass:"m"+t.slice(5),body:z(i?l:o),isCharacterBox:s,mustPromote:i}},mathmlBuilder:cr});var kn=e=>{let t=e.type==="ordgroup"&&e.body.length?e.body[0]:e;return t.type==="atom"&&(t.family==="bin"||t.family==="rel")?"m"+t.family:"mord"};S({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler({parser:e},t){return{type:"mclass",mode:e.mode,mclass:kn(t[0]),body:z(t[1]),isCharacterBox:N.isCharacterBox(t[1])}}});S({type:"mclass",names:["\\stackrel","\\overset","\\underset"],props:{numArgs:2},handler({parser:e,funcName:t},r){let o=r[1],s=r[0],i={type:"op",mode:o.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,stack:!0,suppressBaseShift:t!=="\\stackrel",body:z(o)};return{type:"supsub",mode:s.mode,base:i,sup:t==="\\underset"?null:s,sub:t==="\\underset"?s:null}},mathmlBuilder:cr});var _e=(e,t,r)=>{if(!e)return r;let o=O(e,t);return o.type==="mrow"&&o.children.length===0?r:o};S({type:"multiscript",names:["\\sideset","\\pres@cript"],props:{numArgs:3},handler({parser:e,funcName:t,token:r},o){if(o[2].body.length===0)throw new w(t+"cannot parse an empty base.");let s=o[2].body[0];if(e.settings.strict&&t==="\\sideset"&&!s.symbol)throw new w("The base of \\sideset must be a big operator. Try \\prescript.");if(o[0].body.length>0&&o[0].body[0].type!=="supsub"||o[1].body.length>0&&o[1].body[0].type!=="supsub")throw new w("\\sideset can parse only subscripts and superscripts in its first two arguments",r);let i=o[0].body.length>0?o[0].body[0]:null,l=o[1].body.length>0?o[1].body[0]:null;return!i&&!l?s:i?{type:"multiscript",mode:e.mode,isSideset:t==="\\sideset",prescripts:i,postscripts:l,base:s}:{type:"styling",mode:e.mode,scriptLevel:"text",body:[{type:"supsub",mode:e.mode,base:s,sup:l.sup,sub:l.sub}]}},mathmlBuilder(e,t){let r=O(e.base,t),o=new p.MathNode("mprescripts"),s=new p.MathNode("none"),i=[],l=_e(e.prescripts.sub,t,s),u=_e(e.prescripts.sup,t,s);if(e.isSideset&&(l.setAttribute("style","text-align: left;"),u.setAttribute("style","text-align: left;")),e.postscripts){let h=_e(e.postscripts.sub,t,s),x=_e(e.postscripts.sup,t,s);i=[r,h,x,o,l,u]}else i=[r,o,l,u];return new p.MathNode("mmultiscripts",i)}});S({type:"not",names:["\\not"],props:{numArgs:1,primitive:!0,allowedInText:!1},handler({parser:e},t){let r=N.isCharacterBox(t[0]),o;return r?(o=z(t[0]),o[0].text.charAt(0)==="\\"&&(o[0].text=I.math[o[0].text].replace),o[0].text=o[0].text.slice(0,1)+"\u0338"+o[0].text.slice(1)):o=[{type:"textord",mode:"math",text:"\u0338"},{type:"kern",mode:"math",dimension:{number:-.6,unit:"em"}},t[0]],{type:"not",mode:e.mode,body:o,isCharacterBox:r}},mathmlBuilder(e,t){return e.isCharacterBox?U(e.body,t,!0)[0]:te(e.body,t)}});var An=["textord","mathord","atom"],Sn=["\\smallint"],st=["textord","mathord","ordgroup","close","leftright","font"],$t=e=>{e.attributes.lspace="0.1667em",e.attributes.rspace="0.1667em"},Ae=(e,t)=>{let r;if(e.symbol)r=new R("mo",[W(e.name,e.mode)]),Sn.includes(e.name)?r.setAttribute("largeop","false"):r.setAttribute("movablelimits","false"),e.fromMathOp&&$t(r);else if(e.body)r=new R("mo",U(e.body,t)),e.fromMathOp&&$t(r);else if(r=new R("mi",[new ae(e.name.slice(1))]),!e.parentIsSupSub){let o=new R("mo",[W("\u2061","text")]),s=[r,o];if(e.needsLeadingSpace){let i=new R("mspace");i.setAttribute("width","0.1667em"),s.unshift(i)}if(!e.isFollowedByDelimiter){let i=new R("mspace");i.setAttribute("width","0.1667em"),s.push(i)}r=new R("mrow",s)}return r},qn={"\u220F":"\\prod","\u2210":"\\coprod","\u2211":"\\sum","\u22C0":"\\bigwedge","\u22C1":"\\bigvee","\u22C2":"\\bigcap","\u22C3":"\\bigcup","\u2A00":"\\bigodot","\u2A01":"\\bigoplus","\u2A02":"\\bigotimes","\u2A04":"\\biguplus","\u2A05":"\\bigsqcap","\u2A06":"\\bigsqcup","\u2A03":"\\bigcupdot","\u2A07":"\\bigdoublevee","\u2A08":"\\bigdoublewedge","\u2A09":"\\bigtimes"};S({type:"op",names:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcupplus","\\bigcupdot","\\bigcap","\\bigcup","\\bigdoublevee","\\bigdoublewedge","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcap","\\bigsqcup","\\bigtimes","\\smallint","\u220F","\u2210","\u2211","\u22C0","\u22C1","\u22C2","\u22C3","\u2A00","\u2A01","\u2A02","\u2A04","\u2A06"],props:{numArgs:0},handler:({parser:e,funcName:t},r)=>{let o=t;return o.length===1&&(o=qn[o]),{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!0,stack:!1,name:o}},mathmlBuilder:Ae});S({type:"op",names:["\\mathop"],props:{numArgs:1,primitive:!0},handler:({parser:e},t)=>{let r=t[0],o=r.body?r.body:[r],s=o.length===1&&An.includes(o[0].type);return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:s,fromMathOp:!0,stack:!1,name:s?o[0].text:null,body:s?null:z(r)}},mathmlBuilder:Ae});var _n={"\u222B":"\\int","\u222C":"\\iint","\u222D":"\\iiint","\u222E":"\\oint","\u222F":"\\oiint","\u2230":"\\oiiint","\u2231":"\\intclockwise","\u2232":"\\varointclockwise","\u2A0C":"\\iiiint","\u2A0D":"\\intbar","\u2A0E":"\\intBar","\u2A0F":"\\fint","\u2A12":"\\rppolint","\u2A13":"\\scpolint","\u2A15":"\\pointint","\u2A16":"\\sqint","\u2A17":"\\intlarhk","\u2A18":"\\intx","\u2A19":"\\intcap","\u2A1A":"\\intcup"};S({type:"op",names:["\\arcsin","\\arccos","\\arctan","\\arctg","\\arcctg","\\arg","\\ch","\\cos","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\sh","\\sgn","\\tan","\\tanh","\\tg","\\th"],props:{numArgs:0},handler({parser:e,funcName:t}){let r=e.prevAtomType,o=e.gullet.future().text;return{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!1,stack:!1,isFollowedByDelimiter:Le(o),needsLeadingSpace:r.length>0&&st.includes(r),name:t}},mathmlBuilder:Ae});S({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],props:{numArgs:0},handler({parser:e,funcName:t}){let r=e.prevAtomType,o=e.gullet.future().text;return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!1,stack:!1,isFollowedByDelimiter:Le(o),needsLeadingSpace:r.length>0&&st.includes(r),name:t}},mathmlBuilder:Ae});S({type:"op",names:["\\int","\\iint","\\iiint","\\iiiint","\\oint","\\oiint","\\oiiint","\\intclockwise","\\varointclockwise","\\intbar","\\intBar","\\fint","\\rppolint","\\scpolint","\\pointint","\\sqint","\\intlarhk","\\intx","\\intcap","\\intcup","\u222B","\u222C","\u222D","\u222E","\u222F","\u2230","\u2231","\u2232","\u2A0C","\u2A0D","\u2A0E","\u2A0F","\u2A12","\u2A13","\u2A15","\u2A16","\u2A17","\u2A18","\u2A19","\u2A1A"],props:{numArgs:0},handler({parser:e,funcName:t}){let r=t;return r.length===1&&(r=_n[r]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,stack:!1,name:r}},mathmlBuilder:Ae});var Tn=(e,t)=>{let r=U(e.body,t.withFont("mathrm")),o=!0;for(let i=0;il.toText()).join("");r=[new p.TextNode(i)]}else if(r.length===1&&["mover","munder"].includes(r[0].type)&&(r[0].children[0].type==="mi"||r[0].children[0].type==="mtext")){if(r[0].children[0].type="mi",e.parentIsSupSub)return new p.MathNode("mrow",r);{let i=new p.MathNode("mo",[W("\u2061","text")]);return p.newDocumentFragment([r[0],i])}}let s;if(o?(s=new p.MathNode("mi",r),r[0].text.length===1&&s.setAttribute("mathvariant","normal")):s=new p.MathNode("mrow",r),!e.parentIsSupSub){let i=new p.MathNode("mo",[W("\u2061","text")]),l=[s,i];if(e.needsLeadingSpace){let u=new p.MathNode("mspace");u.setAttribute("width","0.1667em"),l.unshift(u)}if(!e.isFollowedByDelimiter){let u=new p.MathNode("mspace");u.setAttribute("width","0.1667em"),l.push(u)}return p.newDocumentFragment(l)}return s};S({type:"operatorname",names:["\\operatorname@","\\operatornamewithlimits"],props:{numArgs:1,allowedInArgument:!0},handler:({parser:e,funcName:t},r)=>{let o=r[0],s=e.prevAtomType,i=e.gullet.future().text;return{type:"operatorname",mode:e.mode,body:z(o),alwaysHandleSupSub:t==="\\operatornamewithlimits",limits:!1,parentIsSupSub:!1,isFollowedByDelimiter:Le(i),needsLeadingSpace:s.length>0&&st.includes(s)}},mathmlBuilder:Tn});c("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@");se({type:"ordgroup",mathmlBuilder(e,t){return te(e.body,t,e.semisimple)}});S({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{let r=t[0];return{type:"phantom",mode:e.mode,body:z(r)}},mathmlBuilder:(e,t)=>{let r=U(e.body,t);return new p.MathNode("mphantom",r)}});S({type:"hphantom",names:["\\hphantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{let r=t[0];return{type:"hphantom",mode:e.mode,body:r}},mathmlBuilder:(e,t)=>{let r=U(z(e.body),t),o=new p.MathNode("mphantom",r),s=new p.MathNode("mpadded",[o]);return s.setAttribute("height","0px"),s.setAttribute("depth","0px"),s}});S({type:"vphantom",names:["\\vphantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{let r=t[0];return{type:"vphantom",mode:e.mode,body:r}},mathmlBuilder:(e,t)=>{let r=U(z(e.body),t),o=new p.MathNode("mphantom",r),s=new p.MathNode("mpadded",[o]);return s.setAttribute("width","0px"),s}});S({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler({parser:e},t){return{type:"pmb",mode:e.mode,body:z(t[0])}},mathmlBuilder(e,t){let r=U(e.body,t),o=Je(r);return o.setAttribute("style","font-weight:bold"),o}});var dr=(e,t)=>{let r=t.withLevel(F.TEXT),o=new p.MathNode("mpadded",[O(e.body,r)]),s=K(e.dy,t);return o.setAttribute("voffset",s.number+s.unit),s.number>0?o.style.padding=s.number+s.unit+" 0 0 0":o.style.padding="0 0 "+Math.abs(s.number)+s.unit+" 0",o};S({type:"raise",names:["\\raise","\\lower"],props:{numArgs:2,argTypes:["size","primitive"],primitive:!0},handler({parser:e,funcName:t},r){let o=C(r[0],"size").value;t==="\\lower"&&(o.number*=-1);let s=r[1];return{type:"raise",mode:e.mode,dy:o,body:s}},mathmlBuilder:dr});S({type:"raise",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler({parser:e,funcName:t},r){let o=C(r[0],"size").value,s=r[1];return{type:"raise",mode:e.mode,dy:o,body:s}},mathmlBuilder:dr});S({type:"ref",names:["\\ref","\\eqref"],props:{numArgs:1,argTypes:["raw"]},handler({parser:e,funcName:t},r){return{type:"ref",mode:e.mode,funcName:t,string:r[0].string.replace(ur,"")}},mathmlBuilder(e,t){let r=e.funcName==="\\ref"?["tml-ref"]:["tml-ref","tml-eqref"];return new be("#"+e.string,r,null)}});S({type:"reflect",names:["\\reflectbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler({parser:e},t){return{type:"reflect",mode:e.mode,body:t[0]}},mathmlBuilder(e,t){let r=O(e.body,t);return r.style.transform="scaleX(-1)",r}});S({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0},handler({parser:e}){return{type:"internal",mode:e.mode}}});S({type:"rule",names:["\\rule"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["size","size","size"]},handler({parser:e},t,r){let o=r[0],s=C(t[0],"size"),i=C(t[1],"size");return{type:"rule",mode:e.mode,shift:o&&C(o,"size").value,width:s.value,height:i.value}},mathmlBuilder(e,t){let r=K(e.width,t),o=K(e.height,t),s=e.shift?K(e.shift,t):{number:0,unit:"em"},i=t.color&&t.getColor()||"black",l=new p.MathNode("mspace");if(r.number>0&&o.number>0&&l.setAttribute("mathbackground",i),l.setAttribute("width",r.number+r.unit),l.setAttribute("height",o.number+o.unit),s.number===0)return l;let u=new p.MathNode("mpadded",[l]);return s.number>=0?u.setAttribute("height","+"+s.number+s.unit):(u.setAttribute("height",s.number+s.unit),u.setAttribute("depth","+"+-s.number+s.unit)),u.setAttribute("voffset",s.number+s.unit),u}});var Mt={"\\tiny":.5,"\\sixptsize":.6,"\\Tiny":.6,"\\scriptsize":.7,"\\footnotesize":.8,"\\small":.9,"\\normalsize":1,"\\large":1.2,"\\Large":1.44,"\\LARGE":1.728,"\\huge":2.074,"\\Huge":2.488};S({type:"sizing",names:["\\tiny","\\sixptsize","\\Tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"],props:{numArgs:0,allowedInText:!0},handler:({breakOnTokenText:e,funcName:t,parser:r},o)=>{r.settings.strict&&r.mode==="math"&&console.log(`Temml strict-mode warning: Command ${t} is invalid in math mode.`);let s=r.parseExpression(!1,e,!0);return{type:"sizing",mode:r.mode,funcName:t,body:s}},mathmlBuilder:(e,t)=>{let r=t.withFontSize(Mt[e.funcName]),o=U(e.body,r),s=Je(o),i=(Mt[e.funcName]/t.fontSize).toFixed(4);return s.setAttribute("mathsize",i+"em"),s}});S({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:({parser:e},t,r)=>{let o=!1,s=!1,i=r[0]&&C(r[0],"ordgroup");if(i){let u="";for(let h=0;h{let r=new p.MathNode("mpadded",[O(e.body,t)]);return e.smashHeight&&r.setAttribute("height","0px"),e.smashDepth&&r.setAttribute("depth","0px"),r}});S({type:"sqrt",names:["\\sqrt"],props:{numArgs:1,numOptionalArgs:1},handler({parser:e},t,r){let o=r[0],s=t[0];return{type:"sqrt",mode:e.mode,body:s,index:o}},mathmlBuilder(e,t){let{body:r,index:o}=e;return o?new p.MathNode("mroot",[O(r,t),O(o,t.incrementLevel())]):new p.MathNode("msqrt",[O(r,t)])}});var Cn={display:0,text:1,script:2,scriptscript:3},Dn={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]};S({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({breakOnTokenText:e,funcName:t,parser:r},o){let s=r.parseExpression(!0,e,!0),i=t.slice(1,t.length-5);return{type:"styling",mode:r.mode,scriptLevel:i,body:s}},mathmlBuilder(e,t){let r=t.withLevel(Cn[e.scriptLevel]),o=U(e.body,r),s=Je(o),i=Dn[e.scriptLevel];return s.setAttribute("scriptlevel",i[0]),s.setAttribute("displaystyle",i[1]),s}});var Bn=/^m(over|under|underover)$/;se({type:"supsub",mathmlBuilder(e,t){let r=!1,o,s,i=!1,l=!1,u=!1;e.base&&e.base.type==="horizBrace"&&(s=!!e.sup,s===e.base.isOver&&(r=!0,o=e.base.isOver)),e.base&&!e.base.stack&&(e.base.type==="op"||e.base.type==="operatorname")&&(e.base.parentIsSupSub=!0,i=!e.base.symbol,l=i&&!e.isFollowedByDelimiter,u=e.base.needsLeadingSpace);let h=e.base&&e.base.stack?[O(e.base.body[0],t)]:[O(e.base,t)],x=t.inSubOrSup();if(e.sub){let b=O(e.sub,x);t.level===3&&b.setAttribute("scriptlevel","2"),h.push(b)}if(e.sup){let b=O(e.sup,x);t.level===3&&b.setAttribute("scriptlevel","2");let k=b.type==="mrow"?b.children[0]:b;k&&k.type==="mo"&&k.classes.includes("tml-prime")&&e.base&&e.base.text&&"fF".indexOf(e.base.text)>-1&&k.classes.push("prime-pad"),h.push(b)}let A;if(r)A=o?"mover":"munder";else if(e.sub)if(e.sup){let b=e.base;b&&(b.type==="op"&&b.limits||b.type==="multiscript")&&(t.level===F.DISPLAY||b.alwaysHandleSupSub)||b&&b.type==="operatorname"&&b.alwaysHandleSupSub&&(t.level===F.DISPLAY||b.limits)?A="munderover":A="msubsup"}else{let b=e.base;b&&b.type==="op"&&b.limits&&(t.level===F.DISPLAY||b.alwaysHandleSupSub)||b&&b.type==="operatorname"&&b.alwaysHandleSupSub&&(b.limits||t.level===F.DISPLAY)?A="munder":A="msub"}else{let b=e.base;b&&b.type==="op"&&b.limits&&(t.level===F.DISPLAY||b.alwaysHandleSupSub)||b&&b.type==="operatorname"&&b.alwaysHandleSupSub&&(b.limits||t.level===F.DISPLAY)?A="mover":A="msup"}let q=new p.MathNode(A,h);if(i){let b=new p.MathNode("mo",[W("\u2061","text")]);if(u){let k=new p.MathNode("mspace");k.setAttribute("width","0.1667em"),q=p.newDocumentFragment([k,q,b])}else q=p.newDocumentFragment([q,b]);if(l){let k=new p.MathNode("mspace");k.setAttribute("width","0.1667em"),q.children.push(k)}}else Bn.test(A)&&(q=new p.MathNode("mrow",[q]));return q}});var Nn=["\\shortmid","\\nshortmid","\\shortparallel","\\nshortparallel","\\smallsetminus"],On=["\\Rsh","\\Lsh","\\restriction"],$n=e=>{if(e.length===1){let t=e.codePointAt(0);return 8591-1||e.indexOf("harpoon")>-1||On.includes(e)};se({type:"atom",mathmlBuilder(e,t){let r=new p.MathNode("mo",[W(e.text,e.mode)]);return e.family==="punct"?r.setAttribute("separator","true"):e.family==="open"||e.family==="close"?e.family==="open"?(r.setAttribute("form","prefix"),r.setAttribute("stretchy","false")):e.family==="close"&&(r.setAttribute("form","postfix"),r.setAttribute("stretchy","false")):e.text==="\\mid"?(r.setAttribute("lspace","0.22em"),r.setAttribute("rspace","0.22em"),r.setAttribute("stretchy","false")):e.family==="rel"&&$n(e.text)?r.setAttribute("stretchy","false"):Nn.includes(e.text)?r.setAttribute("mathsize","70%"):e.text===":"&&(r.attributes.lspace="0.2222em",r.attributes.rspace="0.2222em"),r}});var Et={mathbf:"bold",mathrm:"normal",textit:"italic",mathit:"italic",mathnormal:"italic",mathbb:"double-struck",mathcal:"script",mathfrak:"fraktur",mathscr:"script",mathsf:"sans-serif",mathtt:"monospace"},mr=function(e,t){if(t.fontFamily==="texttt")return"monospace";if(t.fontFamily==="textsc")return"normal";if(t.fontFamily==="textsf")return t.fontShape==="textit"&&t.fontWeight==="textbf"?"sans-serif-bold-italic":t.fontShape==="textit"?"sans-serif-italic":t.fontWeight==="textbf"?"sans-serif-bold":"sans-serif";if(t.fontShape==="textit"&&t.fontWeight==="textbf")return"bold-italic";if(t.fontShape==="textit")return"italic";if(t.fontWeight==="textbf")return"bold";let r=t.font;if(!r||r==="mathnormal")return null;let o=e.mode;switch(r){case"mathit":return"italic";case"mathrm":{let i=e.text.codePointAt(0);return 9390,bold:e=>119743,italic:e=>119795,"bold-italic":e=>119847,script:e=>zt[e]||119899,"script-bold":e=>119951,fraktur:e=>Mn[e]||120003,"fraktur-bold":e=>120107,"double-struck":e=>En[e]||120055,"sans-serif":e=>120159,"sans-serif-bold":e=>120211,"sans-serif-italic":e=>120263,"sans-serif-bold-italic":e=>120380,monospace:e=>120367},lowerCaseLatin:{normal:e=>0,bold:e=>119737,italic:e=>e==="h"?8358:119789,"bold-italic":e=>119841,script:e=>zt[e]||119893,"script-bold":e=>119945,fraktur:e=>119997,"fraktur-bold":e=>120101,"double-struck":e=>120049,"sans-serif":e=>120153,"sans-serif-bold":e=>120205,"sans-serif-italic":e=>120257,"sans-serif-bold-italic":e=>120309,monospace:e=>120361},upperCaseGreek:{normal:e=>0,bold:e=>119575,italic:e=>119633,"bold-italic":e=>119575,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>119749,"sans-serif-bold":e=>119749,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>119807,monospace:e=>0},lowerCaseGreek:{normal:e=>0,bold:e=>119569,italic:e=>119627,"bold-italic":e=>e==="\u03D5"?119678:119685,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>119743,"sans-serif-bold":e=>119743,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>119801,monospace:e=>0},varGreek:{normal:e=>0,bold:e=>hr[e]||-51,italic:e=>0,"bold-italic":e=>zn[e]||58,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>Lt[e]||116,"sans-serif-bold":e=>Lt[e]||116,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>Ln[e]||174,monospace:e=>0},numeral:{normal:e=>0,bold:e=>120734,italic:e=>0,"bold-italic":e=>0,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>120744,"sans-serif":e=>120754,"sans-serif-bold":e=>120764,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>0,monospace:e=>120774}}),he=(e,t)=>{let r=e.codePointAt(0),o=64{let o=new p.MathNode(r,[e]),s=new p.MathNode("mstyle",[o]);return s.style["font-style"]="italic",s.style["font-family"]="Cambria, 'Times New Roman', serif",t==="bold-italic"&&(s.style["font-weight"]="bold"),s};se({type:"mathord",mathmlBuilder(e,t){let r=W(e.text,e.mode,t),o=r.text.codePointAt(0),s=912he(h,i)).join("")),l=new p.MathNode(u,[s])}else if(e.mode==="text")i!=="normal"&&(s.text=he(s.text,i)),l=new p.MathNode("mtext",[s]);else if(Rn.has(e.text))l=new p.MathNode("mo",[s]),l.classes.push("tml-prime");else{let u=s.text;i!=="italic"&&(s.text=he(s.text,i)),l=new p.MathNode("mi",[s]),s.text===u&&Gn.test(u)&&l.setAttribute("mathvariant","italic")}return l}});var Un={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},Vn={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};se({type:"spacing",mathmlBuilder(e,t){let r;if(Object.prototype.hasOwnProperty.call(Vn,e.text))r=new p.MathNode("mtext",[new p.TextNode("\xA0")]);else if(Object.prototype.hasOwnProperty.call(Un,e.text))r=new p.MathNode("mo"),e.text==="\\nobreak"&&r.setAttribute("linebreak","nobreak");else throw new w(`Unknown type of space "${e.text}"`);return r}});se({type:"tag"});var Ft={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm","\\textsc":"textsc"},It={"\\textbf":"textbf","\\textmd":"textmd"},Wn={"\\textit":"textit","\\textup":"textup"},Hn=(e,t)=>{let r=e.font;if(r){if(Ft[r])return t.withTextFontFamily(Ft[r]);if(It[r])return t.withTextFontWeight(It[r]);if(r==="\\emph")return t.fontShape==="textit"?t.withTextFontShape("textup"):t.withTextFontShape("textit")}else return t;return t.withTextFontShape(Wn[r])};S({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textsc","\\textbf","\\textmd","\\textit","\\textup","\\emph"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler({parser:e,funcName:t},r){let o=r[0];return{type:"text",mode:e.mode,body:z(o),font:t}},mathmlBuilder(e,t){let r=Hn(e,t),o=te(e.body,r);return Ee(o)}});S({type:"vcenter",names:["\\vcenter"],props:{numArgs:1,argTypes:["original"],allowedInText:!1},handler({parser:e},t){return{type:"vcenter",mode:e.mode,body:t[0]}},mathmlBuilder(e,t){let r=new p.MathNode("mtd",[O(e.body,t)]);r.style.padding="0";let o=new p.MathNode("mtr",[r]);return new p.MathNode("mtable",[o])}});S({type:"verb",names:["\\verb"],props:{numArgs:0,allowedInText:!0},handler(e,t,r){throw new w("\\verb ended by end of line instead of matching delimiter")},mathmlBuilder(e,t){let r=new p.TextNode(Zn(e)),o=new p.MathNode("mtext",[r]);return o.setAttribute("mathvariant","monospace"),o}});var Zn=e=>e.body.replace(/ /g,e.star?"\u2423":"\xA0"),oe=Ut,pr=`[ \r ]`,Xn="\\\\[a-zA-Z@]+",Yn="\\\\[^\uD800-\uDFFF]",Kn=`(${Xn})${pr}*`,Jn=`\\\\( |[ \r ]+ ?)[ \r ]*`,Ze="[\u0300-\u036F]",Pt=new RegExp(`${Ze}+$`),Qn=`(${pr}+)|${Jn}|([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]${Ze}*|[\uD800-\uDBFF][\uDC00-\uDFFF]${Ze}*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|${Kn}|${Yn})`,Oe=class{constructor(t,r){this.input=t,this.settings=r,this.tokenRegex=new RegExp(Qn,"g"),this.catcodes={"%":14,"~":13}}setCatcode(t,r){this.catcodes[t]=r}lex(){let t=this.input,r=this.tokenRegex.lastIndex;if(r===t.length)return new Z("EOF",new V(this,r,r));let o=this.tokenRegex.exec(t);if(o===null||o.index!==r)throw new w(`Unexpected character: '${t[r]}'`,new Z(t[r],new V(this,r,r+1)));let s=o[6]||o[3]||(o[2]?"\\ ":" ");if(this.catcodes[s]===14){let i=t.indexOf(` `,this.tokenRegex.lastIndex);if(i===-1){if(this.tokenRegex.lastIndex=t.length,this.settings.strict)throw new w("% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode")}else this.tokenRegex.lastIndex=i+1;return this.lex()}return new Z(s,new V(this,r,this.tokenRegex.lastIndex))}},Xe=class{constructor(t={},r={}){this.current=r,this.builtins=t,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new w("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");let t=this.undefStack.pop();for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&(t[r]===void 0?delete this.current[r]:this.current[r]=t[r])}has(t){return Object.prototype.hasOwnProperty.call(this.current,t)||Object.prototype.hasOwnProperty.call(this.builtins,t)}get(t){return Object.prototype.hasOwnProperty.call(this.current,t)?this.current[t]:this.builtins[t]}set(t,r,o=!1){if(o){for(let s=0;s0&&(this.undefStack[this.undefStack.length-1][t]=r)}else{let s=this.undefStack[this.undefStack.length-1];s&&!Object.prototype.hasOwnProperty.call(s,t)&&(s[t]=this.current[t])}this.current[t]=r}},fr={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},Ye=class{constructor(t,r,o){this.settings=r,this.expansionCount=0,this.feed(t),this.macros=new Xe(hn,r.macros),this.mode=o,this.stack=[]}feed(t){this.lexer=new Oe(t,this.settings)}switchMode(t){this.mode=t}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(t){this.stack.push(t)}pushTokens(t){this.stack.push(...t)}scanArgument(t){let r,o,s;if(t){if(this.consumeSpaces(),this.future().text!=="[")return null;r=this.popToken(),{tokens:s,end:o}=this.consumeArg(["]"])}else({tokens:s,start:r,end:o}=this.consumeArg());return this.pushToken(new Z("EOF",o.loc)),this.pushTokens(s),r.range(o,"")}consumeSpaces(){for(;this.future().text===" ";)this.stack.pop()}consumeArg(t){let r=[],o=t&&t.length>0;o||this.consumeSpaces();let s=this.future(),i,l=0,u=0;do{if(i=this.popToken(),r.push(i),i.text==="{")++l;else if(i.text==="}"){if(--l,l===-1)throw new w("Extra }",i)}else if(i.text==="EOF")throw new w("Unexpected end of input in a macro argument, expected '"+(t&&o?t[u]:"}")+"'",i);if(t&&o)if((l===0||l===1&&t[u]==="{")&&i.text===t[u]){if(++u,u===t.length){r.splice(-u,u);break}}else u=0}while(l!==0||o);return s.text==="{"&&r[r.length-1].text==="}"&&(r.pop(),r.shift()),r.reverse(),{tokens:r,start:s,end:i}}consumeArgs(t,r){if(r){if(r.length!==t+1)throw new w("The length of delimiters doesn't match the number of args!");let s=r[0];for(let i=0;ithis.settings.maxExpand)throw new w("Too many expansions: infinite loop or need to increase maxExpand setting");let i=s.tokens,l=this.consumeArgs(s.numArgs,s.delimiters);if(s.numArgs){i=i.slice();for(let u=i.length-1;u>=0;--u){let h=i[u];if(h.text==="#"){if(u===0)throw new w("Incomplete placeholder at end of macro body",h);if(h=i[--u],h.text==="#")i.splice(u+1,1);else if(/^[1-9]$/.test(h.text))i.splice(u,2,...l[+h.text-1]);else throw new w("Not a valid argument number",h)}}}return this.pushTokens(i),i.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){let t=this.stack.pop();return t.treatAsRelax&&(t.text="\\relax"),t}throw new Error}expandMacro(t){return this.macros.has(t)?this.expandTokens([new Z(t)]):void 0}expandTokens(t){let r=[],o=this.stack.length;for(this.pushTokens(t);this.stack.length>o;)if(this.expandOnce(!0)===!1){let s=this.stack.pop();s.treatAsRelax&&(s.noexpand=!1,s.treatAsRelax=!1),r.push(s)}return r}expandMacroAsText(t){let r=this.expandMacro(t);return r&&r.map(o=>o.text).join("")}_getExpansion(t){let r=this.macros.get(t);if(r==null)return r;if(t.length===1){let s=this.lexer.catcodes[t];if(s!=null&&s!==13)return}let o=typeof r=="function"?r(this):r;if(typeof o=="string"){let s=0;if(o.indexOf("#")!==-1){let x=o.replace(/##/g,"");for(;x.indexOf("#"+(s+1))!==-1;)++s}let i=new Oe(o,this.settings),l=[],u=i.lex();for(;u.text!=="EOF";)l.push(u),u=i.lex();return l.reverse(),{tokens:l,numArgs:s}}return o}isDefined(t){return this.macros.has(t)||Object.prototype.hasOwnProperty.call(oe,t)||Object.prototype.hasOwnProperty.call(I.math,t)||Object.prototype.hasOwnProperty.call(I.text,t)||Object.prototype.hasOwnProperty.call(fr,t)}isExpandable(t){let r=this.macros.get(t);return r!=null?typeof r=="string"||typeof r=="function"||!r.unexpandable:Object.prototype.hasOwnProperty.call(oe,t)&&!oe[t].primitive}},Gt=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,Te=Object.freeze({"\u208A":"+","\u208B":"-","\u208C":"=","\u208D":"(","\u208E":")","\u2080":"0","\u2081":"1","\u2082":"2","\u2083":"3","\u2084":"4","\u2085":"5","\u2086":"6","\u2087":"7","\u2088":"8","\u2089":"9","\u2090":"a","\u2091":"e","\u2095":"h","\u1D62":"i","\u2C7C":"j","\u2096":"k","\u2097":"l","\u2098":"m","\u2099":"n","\u2092":"o","\u209A":"p","\u1D63":"r","\u209B":"s","\u209C":"t","\u1D64":"u","\u1D65":"v","\u2093":"x","\u1D66":"\u03B2","\u1D67":"\u03B3","\u1D68":"\u03C1","\u1D69":"\u03D5","\u1D6A":"\u03C7","\u207A":"+","\u207B":"-","\u207C":"=","\u207D":"(","\u207E":")","\u2070":"0","\xB9":"1","\xB2":"2","\xB3":"3","\u2074":"4","\u2075":"5","\u2076":"6","\u2077":"7","\u2078":"8","\u2079":"9","\u1D2C":"A","\u1D2E":"B","\u1D30":"D","\u1D31":"E","\u1D33":"G","\u1D34":"H","\u1D35":"I","\u1D36":"J","\u1D37":"K","\u1D38":"L","\u1D39":"M","\u1D3A":"N","\u1D3C":"O","\u1D3E":"P","\u1D3F":"R","\u1D40":"T","\u1D41":"U","\u2C7D":"V","\u1D42":"W","\u1D43":"a","\u1D47":"b","\u1D9C":"c","\u1D48":"d","\u1D49":"e","\u1DA0":"f","\u1D4D":"g",\u02B0:"h","\u2071":"i",\u02B2:"j","\u1D4F":"k",\u02E1:"l","\u1D50":"m",\u207F:"n","\u1D52":"o","\u1D56":"p",\u02B3:"r",\u02E2:"s","\u1D57":"t","\u1D58":"u","\u1D5B":"v",\u02B7:"w",\u02E3:"x",\u02B8:"y","\u1DBB":"z","\u1D5D":"\u03B2","\u1D5E":"\u03B3","\u1D5F":"\u03B4","\u1D60":"\u03D5","\u1D61":"\u03C7","\u1DBF":"\u03B8"}),Rt=Object.freeze({"\u{1D49C}":"A",\u212C:"B","\u{1D49E}":"C","\u{1D49F}":"D",\u2130:"E",\u2131:"F","\u{1D4A2}":"G",\u210B:"H",\u2110:"I","\u{1D4A5}":"J","\u{1D4A6}":"K",\u2112:"L",\u2133:"M","\u{1D4A9}":"N","\u{1D4AA}":"O","\u{1D4AB}":"P","\u{1D4AC}":"Q",\u211B:"R","\u{1D4AE}":"S","\u{1D4AF}":"T","\u{1D4B0}":"U","\u{1D4B1}":"V","\u{1D4B2}":"W","\u{1D4B3}":"X","\u{1D4B4}":"Y","\u{1D4B5}":"Z"}),Ge={"\u0301":{text:"\\'",math:"\\acute"},"\u0300":{text:"\\`",math:"\\grave"},"\u0308":{text:'\\"',math:"\\ddot"},"\u0303":{text:"\\~",math:"\\tilde"},"\u0304":{text:"\\=",math:"\\bar"},"\u0306":{text:"\\u",math:"\\breve"},"\u030C":{text:"\\v",math:"\\check"},"\u0302":{text:"\\^",math:"\\hat"},"\u0307":{text:"\\.",math:"\\dot"},"\u030A":{text:"\\r",math:"\\mathring"},"\u030B":{text:"\\H"},"\u0327":{text:"\\c"}},jt={\u00E1:"a\u0301",\u00E0:"a\u0300",\u00E4:"a\u0308",\u01DF:"a\u0308\u0304",\u00E3:"a\u0303",\u0101:"a\u0304",\u0103:"a\u0306",\u1EAF:"a\u0306\u0301",\u1EB1:"a\u0306\u0300",\u1EB5:"a\u0306\u0303",\u01CE:"a\u030C",\u00E2:"a\u0302",\u1EA5:"a\u0302\u0301",\u1EA7:"a\u0302\u0300",\u1EAB:"a\u0302\u0303",\u0227:"a\u0307",\u01E1:"a\u0307\u0304",\u00E5:"a\u030A",\u01FB:"a\u030A\u0301",\u1E03:"b\u0307",\u0107:"c\u0301",\u010D:"c\u030C",\u0109:"c\u0302",\u010B:"c\u0307",\u010F:"d\u030C",\u1E0B:"d\u0307",\u00E9:"e\u0301",\u00E8:"e\u0300",\u00EB:"e\u0308",\u1EBD:"e\u0303",\u0113:"e\u0304",\u1E17:"e\u0304\u0301",\u1E15:"e\u0304\u0300",\u0115:"e\u0306",\u011B:"e\u030C",\u00EA:"e\u0302",\u1EBF:"e\u0302\u0301",\u1EC1:"e\u0302\u0300",\u1EC5:"e\u0302\u0303",\u0117:"e\u0307",\u1E1F:"f\u0307",\u01F5:"g\u0301",\u1E21:"g\u0304",\u011F:"g\u0306",\u01E7:"g\u030C",\u011D:"g\u0302",\u0121:"g\u0307",\u1E27:"h\u0308",\u021F:"h\u030C",\u0125:"h\u0302",\u1E23:"h\u0307",\u00ED:"i\u0301",\u00EC:"i\u0300",\u00EF:"i\u0308",\u1E2F:"i\u0308\u0301",\u0129:"i\u0303",\u012B:"i\u0304",\u012D:"i\u0306",\u01D0:"i\u030C",\u00EE:"i\u0302",\u01F0:"j\u030C",\u0135:"j\u0302",\u1E31:"k\u0301",\u01E9:"k\u030C",\u013A:"l\u0301",\u013E:"l\u030C",\u1E3F:"m\u0301",\u1E41:"m\u0307",\u0144:"n\u0301",\u01F9:"n\u0300",\u00F1:"n\u0303",\u0148:"n\u030C",\u1E45:"n\u0307",\u00F3:"o\u0301",\u00F2:"o\u0300",\u00F6:"o\u0308",\u022B:"o\u0308\u0304",\u00F5:"o\u0303",\u1E4D:"o\u0303\u0301",\u1E4F:"o\u0303\u0308",\u022D:"o\u0303\u0304",\u014D:"o\u0304",\u1E53:"o\u0304\u0301",\u1E51:"o\u0304\u0300",\u014F:"o\u0306",\u01D2:"o\u030C",\u00F4:"o\u0302",\u1ED1:"o\u0302\u0301",\u1ED3:"o\u0302\u0300",\u1ED7:"o\u0302\u0303",\u022F:"o\u0307",\u0231:"o\u0307\u0304",\u0151:"o\u030B",\u1E55:"p\u0301",\u1E57:"p\u0307",\u0155:"r\u0301",\u0159:"r\u030C",\u1E59:"r\u0307",\u015B:"s\u0301",\u1E65:"s\u0301\u0307",\u0161:"s\u030C",\u1E67:"s\u030C\u0307",\u015D:"s\u0302",\u1E61:"s\u0307",\u1E97:"t\u0308",\u0165:"t\u030C",\u1E6B:"t\u0307",\u00FA:"u\u0301",\u00F9:"u\u0300",\u00FC:"u\u0308",\u01D8:"u\u0308\u0301",\u01DC:"u\u0308\u0300",\u01D6:"u\u0308\u0304",\u01DA:"u\u0308\u030C",\u0169:"u\u0303",\u1E79:"u\u0303\u0301",\u016B:"u\u0304",\u1E7B:"u\u0304\u0308",\u016D:"u\u0306",\u01D4:"u\u030C",\u00FB:"u\u0302",\u016F:"u\u030A",\u0171:"u\u030B",\u1E7D:"v\u0303",\u1E83:"w\u0301",\u1E81:"w\u0300",\u1E85:"w\u0308",\u0175:"w\u0302",\u1E87:"w\u0307",\u1E98:"w\u030A",\u1E8D:"x\u0308",\u1E8B:"x\u0307",\u00FD:"y\u0301",\u1EF3:"y\u0300",\u00FF:"y\u0308",\u1EF9:"y\u0303",\u0233:"y\u0304",\u0177:"y\u0302",\u1E8F:"y\u0307",\u1E99:"y\u030A",\u017A:"z\u0301",\u017E:"z\u030C",\u1E91:"z\u0302",\u017C:"z\u0307",\u00C1:"A\u0301",\u00C0:"A\u0300",\u00C4:"A\u0308",\u01DE:"A\u0308\u0304",\u00C3:"A\u0303",\u0100:"A\u0304",\u0102:"A\u0306",\u1EAE:"A\u0306\u0301",\u1EB0:"A\u0306\u0300",\u1EB4:"A\u0306\u0303",\u01CD:"A\u030C",\u00C2:"A\u0302",\u1EA4:"A\u0302\u0301",\u1EA6:"A\u0302\u0300",\u1EAA:"A\u0302\u0303",\u0226:"A\u0307",\u01E0:"A\u0307\u0304",\u00C5:"A\u030A",\u01FA:"A\u030A\u0301",\u1E02:"B\u0307",\u0106:"C\u0301",\u010C:"C\u030C",\u0108:"C\u0302",\u010A:"C\u0307",\u010E:"D\u030C",\u1E0A:"D\u0307",\u00C9:"E\u0301",\u00C8:"E\u0300",\u00CB:"E\u0308",\u1EBC:"E\u0303",\u0112:"E\u0304",\u1E16:"E\u0304\u0301",\u1E14:"E\u0304\u0300",\u0114:"E\u0306",\u011A:"E\u030C",\u00CA:"E\u0302",\u1EBE:"E\u0302\u0301",\u1EC0:"E\u0302\u0300",\u1EC4:"E\u0302\u0303",\u0116:"E\u0307",\u1E1E:"F\u0307",\u01F4:"G\u0301",\u1E20:"G\u0304",\u011E:"G\u0306",\u01E6:"G\u030C",\u011C:"G\u0302",\u0120:"G\u0307",\u1E26:"H\u0308",\u021E:"H\u030C",\u0124:"H\u0302",\u1E22:"H\u0307",\u00CD:"I\u0301",\u00CC:"I\u0300",\u00CF:"I\u0308",\u1E2E:"I\u0308\u0301",\u0128:"I\u0303",\u012A:"I\u0304",\u012C:"I\u0306",\u01CF:"I\u030C",\u00CE:"I\u0302",\u0130:"I\u0307",\u0134:"J\u0302",\u1E30:"K\u0301",\u01E8:"K\u030C",\u0139:"L\u0301",\u013D:"L\u030C",\u1E3E:"M\u0301",\u1E40:"M\u0307",\u0143:"N\u0301",\u01F8:"N\u0300",\u00D1:"N\u0303",\u0147:"N\u030C",\u1E44:"N\u0307",\u00D3:"O\u0301",\u00D2:"O\u0300",\u00D6:"O\u0308",\u022A:"O\u0308\u0304",\u00D5:"O\u0303",\u1E4C:"O\u0303\u0301",\u1E4E:"O\u0303\u0308",\u022C:"O\u0303\u0304",\u014C:"O\u0304",\u1E52:"O\u0304\u0301",\u1E50:"O\u0304\u0300",\u014E:"O\u0306",\u01D1:"O\u030C",\u00D4:"O\u0302",\u1ED0:"O\u0302\u0301",\u1ED2:"O\u0302\u0300",\u1ED6:"O\u0302\u0303",\u022E:"O\u0307",\u0230:"O\u0307\u0304",\u0150:"O\u030B",\u1E54:"P\u0301",\u1E56:"P\u0307",\u0154:"R\u0301",\u0158:"R\u030C",\u1E58:"R\u0307",\u015A:"S\u0301",\u1E64:"S\u0301\u0307",\u0160:"S\u030C",\u1E66:"S\u030C\u0307",\u015C:"S\u0302",\u1E60:"S\u0307",\u0164:"T\u030C",\u1E6A:"T\u0307",\u00DA:"U\u0301",\u00D9:"U\u0300",\u00DC:"U\u0308",\u01D7:"U\u0308\u0301",\u01DB:"U\u0308\u0300",\u01D5:"U\u0308\u0304",\u01D9:"U\u0308\u030C",\u0168:"U\u0303",\u1E78:"U\u0303\u0301",\u016A:"U\u0304",\u1E7A:"U\u0304\u0308",\u016C:"U\u0306",\u01D3:"U\u030C",\u00DB:"U\u0302",\u016E:"U\u030A",\u0170:"U\u030B",\u1E7C:"V\u0303",\u1E82:"W\u0301",\u1E80:"W\u0300",\u1E84:"W\u0308",\u0174:"W\u0302",\u1E86:"W\u0307",\u1E8C:"X\u0308",\u1E8A:"X\u0307",\u00DD:"Y\u0301",\u1EF2:"Y\u0300",\u0178:"Y\u0308",\u1EF8:"Y\u0303",\u0232:"Y\u0304",\u0176:"Y\u0302",\u1E8E:"Y\u0307",\u0179:"Z\u0301",\u017D:"Z\u030C",\u1E90:"Z\u0302",\u017B:"Z\u0307",\u03AC:"\u03B1\u0301",\u1F70:"\u03B1\u0300",\u1FB1:"\u03B1\u0304",\u1FB0:"\u03B1\u0306",\u03AD:"\u03B5\u0301",\u1F72:"\u03B5\u0300",\u03AE:"\u03B7\u0301",\u1F74:"\u03B7\u0300",\u03AF:"\u03B9\u0301",\u1F76:"\u03B9\u0300",\u03CA:"\u03B9\u0308",\u0390:"\u03B9\u0308\u0301",\u1FD2:"\u03B9\u0308\u0300",\u1FD1:"\u03B9\u0304",\u1FD0:"\u03B9\u0306",\u03CC:"\u03BF\u0301",\u1F78:"\u03BF\u0300",\u03CD:"\u03C5\u0301",\u1F7A:"\u03C5\u0300",\u03CB:"\u03C5\u0308",\u03B0:"\u03C5\u0308\u0301",\u1FE2:"\u03C5\u0308\u0300",\u1FE1:"\u03C5\u0304",\u1FE0:"\u03C5\u0306",\u03CE:"\u03C9\u0301",\u1F7C:"\u03C9\u0300",\u038E:"\u03A5\u0301",\u1FEA:"\u03A5\u0300",\u03AB:"\u03A5\u0308",\u1FE9:"\u03A5\u0304",\u1FE8:"\u03A5\u0306",\u038F:"\u03A9\u0301",\u1FFA:"\u03A9\u0300"},eo=["bin","op","open","punct","rel"],to=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,$e=class e{constructor(t,r,o=!1){this.mode="math",this.gullet=new Ye(t,r,this.mode),this.settings=r,this.isPreamble=o,this.leftrightDepth=0,this.prevAtomType=""}expect(t,r=!0){if(this.fetch().text!==t)throw new w(`Expected '${t}', got '${this.fetch().text}'`,this.fetch());r&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken==null&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(t){this.mode=t,this.gullet.switchMode(t)}parse(){this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");let t=this.parseExpression(!1);if(this.expect("EOF"),this.isPreamble){let o=Object.create(null);return Object.entries(this.gullet.macros.current).forEach(([s,i])=>{o[s]=i}),this.gullet.endGroup(),o}let r=this.gullet.macros.get("\\df@tag");return this.gullet.endGroup(),r&&(this.gullet.macros.current["\\df@tag"]=r),t}static get endOfExpression(){return["}","\\endgroup","\\end","\\right","\\endtoggle","&"]}subparse(t){let r=this.nextToken;this.consume(),this.gullet.pushToken(new Z("}")),this.gullet.pushTokens(t);let o=this.parseExpression(!1);return this.expect("}"),this.nextToken=r,o}parseExpression(t,r,o){let s=[];for(this.prevAtomType="";;){this.mode==="math"&&this.consumeSpaces();let i=this.fetch();if(e.endOfExpression.indexOf(i.text)!==-1||r&&i.text===r||o&&i.text==="\\middle"||t&&oe[i.text]&&oe[i.text].infix)break;let l=this.parseAtom(r);if(l){if(l.type==="internal")continue}else break;s.push(l),this.prevAtomType=l.type==="atom"?l.family:l.type}return this.mode==="text"&&this.formLigatures(s),this.handleInfixNodes(s)}handleInfixNodes(t){let r=-1,o;for(let s=0;s=128||Pt.exec(r)){if(this.settings.strict&&this.mode==="math")throw new w(`Unicode text character "${r[0]}" used in math mode`,t);s={type:"textord",mode:"text",loc:V.range(t),text:r}}else return null;if(this.consume(),o)for(let i=0;i0&&o[0].type&&o[0].type==="array"&&o[0].addEqnNum)&&r.gullet.macros.get("\\df@tag")){if(!t.displayMode)throw new w("\\tag works only in display mode");r.gullet.feed("\\df@tag"),o=[{type:"tag",mode:"text",body:o,tag:r.parse()}]}return o},ro=[2,2,3,3],Ke=class e{constructor(t){this.level=t.level,this.color=t.color,this.font=t.font||"",this.fontFamily=t.fontFamily||"",this.fontSize=t.fontSize||1,this.fontWeight=t.fontWeight||"",this.fontShape=t.fontShape||"",this.maxSize=t.maxSize}extend(t){let r={level:this.level,color:this.color,font:this.font,fontFamily:this.fontFamily,fontSize:this.fontSize,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize};for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o]);return new e(r)}withLevel(t){return this.extend({level:t})}incrementLevel(){return this.extend({level:Math.min(this.level+1,3)})}inSubOrSup(){return this.extend({level:ro[this.level]})}withColor(t){return this.extend({color:t})}withFont(t){return this.extend({font:t})}withTextFontFamily(t){return this.extend({fontFamily:t,font:""})}withFontSize(t){return this.extend({fontSize:t})}withTextFontWeight(t){return this.extend({fontWeight:t,font:""})}withTextFontShape(t){return this.extend({fontShape:t,font:""})}getColor(){return this.color}},no="0.10.34";function oo(e){let t={},r=0,o=document.getElementsByClassName("tml-eqn");for(let l of o)for(r+=1,l.setAttribute("id","tml-eqn-"+String(r));l.tagName!=="mtable";)if(l.getElementsByClassName("tml-label").length>0){let h=l.attributes.id.value;t[h]=String(r);break}else l=l.parentElement;let s=document.getElementsByClassName("tml-tageqn");for(let l of s)if(l.getElementsByClassName("tml-label").length>0){let h=l.getElementsByClassName("tml-tag");if(h.length>0){let x=l.attributes.id.value;t[x]=h[0].textContent}}[...e.getElementsByClassName("tml-ref")].forEach(l=>{let u=l.getAttribute("href"),h=t[u.slice(1)];l.className.indexOf("tml-eqref")===-1?(h=h.replace(/^\(/,""),h=h.replace(/\)$/,"")):(h.charAt(0)!=="("&&(h="("+h),h.slice(-1)!==")"&&(h=h+")"));let x=document.createElementNS("http://www.w3.org/1998/Math/MathML","mtext");x.appendChild(document.createTextNode(h));let A=document.createElementNS("http://www.w3.org/1998/Math/MathML","math");A.appendChild(x),l.appendChild(A)})}var br=function(e,t,r={}){t.textContent="";let o=t.tagName.toLowerCase()==="math";o&&(r.wrap="none");let s=it(e,r);o?(t.textContent="",s.children.forEach(i=>{t.appendChild(i.toNode())})):s.children.length>1?(t.textContent="",s.children.forEach(i=>{t.appendChild(i.toNode())})):t.appendChild(s.toNode())};typeof document<"u"&&document.compatMode!=="CSS1Compat"&&(typeof console<"u"&&console.warn("Warning: Temml doesn't work in quirks mode. Make sure your website has a suitable doctype."),br=function(){throw new w("Temml doesn't work in quirks mode.")});var ao=function(e,t){return it(e,t).toMarkup()},so=function(e,t){let r=new pe(t);return gr(e,r)},io=function(e,t){let r=new pe(t);if(r.macros={},!(typeof e=="string"||e instanceof String))throw new TypeError("Temml can only parse string typed expression");let o=new $e(e,r,!0);return delete o.gullet.macros.current["\\df@tag"],o.parse()},lo=function(e,t,r){if(r.throwOnError||!(e instanceof w))throw e;let o=new De(["temml-error"],[new Or(t+` `+e.toString())]);return o.style.color=r.errorColor,o.style.whiteSpace="pre-line",o},it=function(e,t){let r=new pe(t);try{let o=gr(e,r),s=new Ke({level:r.displayMode?F.DISPLAY:F.TEXT,maxSize:r.maxSize});return Wr(o,e,s,r)}catch(o){return lo(o,e,r)}},xr={version:no,render:br,renderToString:ao,postProcess:oo,ParseError:w,definePreamble:io,__parse:so,__renderToMathMLTree:it,__defineSymbol:n,__defineMacro:c};function ho(e,{displayMode:t=!0}={}){let r=xr.renderToString(e,{displayMode:t,annotate:!0,throwOnError:!0}),o=document.implementation.createHTMLDocument("");return o.body.innerHTML=r,o.body.querySelector("math")?.innerHTML??""}export{ho as default};