tex2typst 0.3.27 → 0.3.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,13 @@
1
- "use strict";(()=>{function Re(n){return"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".includes(n)}function T(n,e="Assertion failed."){if(!n)throw new Error(e)}var l=class n{type;value;constructor(e,r){this.type=e,this.value=r}eq(e){return this.type===e.type&&this.value===e.value}toString(){switch(this.type){case 4:return"%"+this.value;default:return this.value}}toNode(){return new we(this)}static EMPTY=new n(0,"")},k=class{type;head;constructor(e,r){this.type=e,this.head=r||l.EMPTY}eq(e){return this.type===e.type&&this.head.eq(e.head)}toString(){return this.serialize().reduce(be,"")}},we=class extends k{constructor(e){super("terminal",e)}serialize(){switch(this.head.type){case 0:return[];case 1:case 2:case 3:case 4:case 7:return[this.head];case 5:case 6:{let e=[];for(let r of this.head.value){let t=r===" "?5:6;e.push(new l(t,r))}return e}default:throw new Error(`Unknown terminal token type: ${this.head.type}`)}}},S=class extends k{constructor(e){T(e.type===3),super("text",e)}serialize(){return[new l(2,"\\text"),new l(1,"{"),this.head,new l(1,"}")]}},E=class extends k{items;constructor(e){super("ordgroup",l.EMPTY),this.items=e}serialize(){return this.items.map(e=>e.serialize()).flat()}},R=class extends k{base;sup;sub;constructor(e){super("supsub",l.EMPTY),this.base=e.base,this.sup=e.sup,this.sub=e.sub}serialize(){let e=[],{base:r,sup:t,sub:s}=this;e=e.concat(r.serialize());function o(a){return a.type==="ordgroup"||a.type==="supsub"||a.head.type===0?!0:!!(a.head.type===1&&/\d+(\.\d+)?/.test(a.head.value)&&a.head.value.length>1)}return s&&(e.push(new l(7,"_")),o(s)?(e.push(new l(1,"{")),e=e.concat(s.serialize()),e.push(new l(1,"}"))):e=e.concat(s.serialize())),t&&(e.push(new l(7,"^")),o(t)?(e.push(new l(1,"{")),e=e.concat(t.serialize()),e.push(new l(1,"}"))):e=e.concat(t.serialize())),e}},g=class extends k{args;data;constructor(e,r,t=null){super("funcCall",e),this.args=r,this.data=t}serialize(){let e=[];e.push(this.head),this.head.value==="\\sqrt"&&this.data&&(e.push(new l(1,"[")),e=e.concat(this.data.serialize()),e.push(new l(1,"]")));for(let r of this.args)e.push(new l(1,"{")),e=e.concat(r.serialize()),e.push(new l(1,"}"));return e}},I=class extends k{body;left;right;constructor(e){super("leftright",l.EMPTY),this.body=e.body,this.left=e.left,this.right=e.right}serialize(){let e=[];return e.push(new l(2,"\\left")),e.push(new l(1,this.left?this.left.value:".")),e=e.concat(this.body.serialize()),e.push(new l(2,"\\right")),e.push(new l(1,this.right?this.right.value:".")),e}},M=class extends k{matrix;data;constructor(e,r,t=null){T(e.type===3),super("beginend",e),this.matrix=r,this.data=t}serialize(){let e=[],r=this.matrix;e.push(new l(2,"\\begin")),e.push(new l(1,"{")),e=e.concat(this.head),e.push(new l(1,"}")),e.push(new l(6,`
2
- `));for(let t=0;t<r.length;t++){let s=r[t];for(let o=0;o<s.length;o++){let a=s[o];e=e.concat(a.serialize()),o!==s.length-1&&e.push(new l(7,"&"))}t!==r.length-1&&e.push(new l(7,"\\\\"))}return e.push(new l(6,`
3
- `)),e.push(new l(2,"\\end")),e.push(new l(1,"{")),e=e.concat(this.head),e.push(new l(1,"}")),e}};function be(n,e){let r=e.toString(),t=!1;return e.type===5?t=!0:(t||=/[{\(\[\|]$/.test(n),t||=/\\\w+$/.test(n)&&r==="[",t||=/^[\.,;:!\?\(\)\]{}_^]$/.test(r),t||=["\\{","\\}"].includes(r),t||=r==="'",t||=n.endsWith("_")||n.endsWith("^"),t||=/\s$/.test(n),t||=/^\s/.test(r),t||=n==="",t||=/[\(\[{]\s*(-|\+)$/.test(n)||n==="-"||n==="+",t||=n.endsWith("&")&&r==="=",t||=/\d$/.test(n)&&/^[a-zA-Z]$/.test(r)),t||(n+=" "),n+r}function G(n,e,r=0){let t=n.slice(r).findIndex(s=>s.eq(e));return t===-1?-1:t+r}function re(n,e){return n.some(r=>r.eq(e))}function me(n,e){let r=[],t=[];for(let s of n)s.eq(e)?(r.push(t),t=[]):t.push(s);return r.push(t),r}function Ie(n,e){return n.flatMap((r,t)=>t!==n.length-1?[r,e]:[r])}var Pe={};function et(n,e){let r=n.reMatchArray[0].length,t=e.reMatchArray[0].length;return t!==r?t-r:n.index-e.index}var fe=class{_input;_lexer;_pos=0;_line=0;_col=0;_offset=0;_less=null;_go=!1;_newstate=null;_state;_text=null;_leng=null;_reMatchArray=null;constructor(e,r){this._input=e,this._lexer=r,this._state=r.states[0]}text(){return this._text}leng(){return this._leng}reMatchArray(){return this._reMatchArray}pos(){return this._pos}line(){return this._line}column(){return this._col}input(){return this._input.charAt(this._pos+this._leng+this._offset++)}unput(){return this._offset=this._offset>0?this._offset--:0}less(e){return this._less=e,this._offset=0,this._text=this._text.substring(0,e),this._leng=this._text.length}pushback(e){return this.less(this._leng-e)}reject(){this._go=!0}begin(e){if(this._lexer.specification[e])return this._newstate=e;let r=this._lexer.states[parseInt(e)];if(r)return this._newstate=r;throw"Unknown state '"+e+"' requested"}state(){return this._state}scan(){if(this._pos>=this._input.length)return Pe;let e=this._input.substring(this._pos),r=this._lexer.specification[this._state],t=[];for(let c=0;c<r.length;c++){let h=r[c],d=e.match(h.re);d!==null&&d[0].length>0&&t.push({index:c,rule:h,reMatchArray:d})}if(t.length===0)throw new Error("No match found for input '"+e+"'");t.sort(et),this._go=!0;let s,o;for(let c=0,h=t.length;c<h&&this._go;c++){this._offset=0,this._less=null,this._go=!1,this._newstate=null;let d=t[c];if(o=d.reMatchArray[0],this._text=o,this._leng=o.length,this._reMatchArray=d.reMatchArray,s=d.rule.action(this),this._newstate&&this._newstate!=this._state){this._state=this._newstate;break}}let a=this._less===null?o:o.substring(0,this._less),u=a.length;this._pos+=u+this._offset;let p=a.match(/\n/g);return p!==null?(this._line+=p.length,this._col=u-a.lastIndexOf(`
4
- `)-1):this._col+=u,s}},B=class{states;specification;constructor(e){this.states=Object.keys(e),this.specification={};for(let r of this.states){let t=e[r];if(r in this.specification)throw"Duplicate state declaration encountered for state '"+r+"'";this.specification[r]=[];for(let[s,o]of t.entries()){let a;try{a=new RegExp("^"+s)}catch(u){throw"Invalid regexp '"+s+"' in state '"+r+"' ("+u.message+")"}this.specification[r].push({re:a,action:o})}}}scanner(e){return new fe(e,this)}lex(e,r){let t=this.scanner(e);for(;;){let s=t.scan();if(s===Pe)return;s!==void 0&&r(s)}}collect(e){let r=[],t=function(s){Array.isArray(s)?r.push(...s):r.push(s)};return this.lex(e,t),r}};var H=["sqrt","text","bar","bold","boldsymbol","ddot","dot","hat","mathbb","mathbf","mathcal","mathfrak","mathit","mathrm","mathscr","mathsf","mathtt","operatorname","overbrace","overline","pmb","rm","tilde","underbrace","underline","vec","widehat","widetilde","overleftarrow","overrightarrow","hspace","substack","set"],X=["frac","tfrac","binom","dbinom","dfrac","tbinom","overset","underset","textcolor"];function tt(n){let e=["{","}","\\","$","&","#","_","%"];for(let r of e)n=n.replaceAll("\\"+r,r);return n}var rt=new Map([[String.raw`\\begin{(array|subarry)}{(.+?)}`,n=>{let e=n.reMatchArray();return[new l(2,"\\begin"),new l(7,"{"),new l(3,e[1]),new l(7,"}"),new l(7,"{"),new l(3,e[2]),new l(7,"}")]}],[String.raw`\\(text|operatorname|textcolor|begin|end|hspace|array){(.+?)}`,n=>{let e=n.reMatchArray();return[new l(2,"\\"+e[1]),new l(7,"{"),new l(3,tt(e[2])),new l(7,"}")]}],[String.raw`%[^\n]*`,n=>new l(4,n.text().substring(1))],[String.raw`[{}_^&]`,n=>new l(7,n.text())],[String.raw`\\[\\,:;! ]`,n=>new l(7,n.text())],[String.raw`\r?\n`,n=>new l(6,`
5
- `)],[String.raw`\s+`,n=>new l(5,n.text())],[String.raw`\\[{}%$&#_|]`,n=>new l(1,n.text())],[String.raw`(\\[a-zA-Z]+)(\s*\d|\s+[a-zA-Z])\s*([0-9a-zA-Z])`,n=>{let e=n.reMatchArray(),r=e[1];if(X.includes(r.substring(1))){let t=e[2].trimStart(),s=e[3];return[new l(2,r),new l(1,t),new l(1,s)]}else return n.reject(),[]}],[String.raw`(\\[a-zA-Z]+)(\s*\d|\s+[a-zA-Z])`,n=>{let e=n.reMatchArray(),r=e[1];if(H.includes(r.substring(1))){let t=e[2].trimStart();return[new l(2,r),new l(1,t)]}else return n.reject(),[]}],[String.raw`\\[a-zA-Z]+`,n=>new l(2,n.text())],[String.raw`[0-9]+(\.[0-9]+)?`,n=>new l(1,n.text())],[String.raw`[a-zA-Z]`,n=>new l(1,n.text())],[String.raw`[+\-*/='<>!.,;:?()\[\]|]`,n=>new l(1,n.text())],[String.raw`[^\x00-\x7F]`,n=>new l(1,n.text())],[String.raw`.`,n=>new l(8,n.text())]]),nt={start:rt};function ye(n){return new B(nt).collect(n)}var st=["bigl","bigr","bigm","biggl","biggr","biggm","Bigl","Bigr","Bigm","Biggl","Biggr","Biggm"],De=l.EMPTY.toNode();function ot(n){return H.includes(n)?1:X.includes(n)?2:0}var ne=new l(7,"{"),se=new l(7,"}"),ze=new l(1,"["),at=new l(1,"]");function oe(n,e){let r=e;for(;r<n.length&&[5,6].includes(n[r].type);)r++;return n.slice(e,r)}function Ye(n,e){let r=n[e];return r.type===1&&["(",")","[","]","|","\\{","\\}",".","\\|"].includes(r.value)||r.type===2&&["lfloor","rfloor","lceil","rceil","langle","rangle"].includes(r.value.slice(1))?r:null}function j(n,e){let r=e;for(;r<n.length&&n[r].eq(new l(1,"'"));)r+=1;return r-e}function ae(n,e,r,t){T(n[e].eq(r));let s=1,o=e+1;for(;s>0;){if(o>=n.length)return-1;n[o].eq(r)?s+=1:n[o].eq(t)&&(s-=1),o+=1}return o-1}var Ee=new l(2,"\\left"),it=new l(2,"\\right");function lt(n,e){return ae(n,e,Ee,it)}var xe=new l(2,"\\begin"),ut=new l(2,"\\end");function pt(n,e){return ae(n,e,xe,ut)}var w=class extends Error{constructor(e){super(e),this.name="LatexParserError"}},Ne=new l(7,"_"),qe=new l(7,"^"),ve=class{space_sensitive;newline_sensitive;constructor(e=!1,r=!0){this.space_sensitive=e,this.newline_sensitive=r}parse(e){let r=new l(2,"\\displaystyle"),t=G(e,r);if(t===-1){let[s,o]=this.parseGroup(e,0,e.length);return s}else if(t===0){let[s,o]=this.parseGroup(e,1,e.length);return new g(r,[s])}else{let[s,o]=this.parseGroup(e,0,t),[a,u]=this.parseGroup(e,t+1,e.length),p=new g(r,[a]);return new E([s,p])}}parseGroup(e,r,t){let s=[],o=r;for(;o<t;){let[u,p]=this.parseNextExpr(e,o);if(o=p,!((u.head.type===5||u.head.type===6)&&(!this.space_sensitive&&u.head.value.replace(/ /g,"").length===0||!this.newline_sensitive&&u.head.value===`
6
- `))){if(u.head.eq(new l(7,"&")))throw new w("Unexpected & outside of an alignment");s.push(u)}}let a;return s.length===1?a=s[0]:a=new E(s),[a,t+1]}parseNextExpr(e,r){let[t,s]=this.parseNextExprWithoutSupSub(e,r),o=null,a=null,u=0;if(u+=j(e,s),s+=u,s<e.length&&e[s].eq(Ne)){if([o,s]=this.parseNextExprWithoutSupSub(e,s+1),u+=j(e,s),s+=u,s<e.length&&e[s].eq(qe)&&([a,s]=this.parseNextExprWithoutSupSub(e,s+1),j(e,s)>0))throw new w("Double superscript")}else if(s<e.length&&e[s].eq(qe)){if([a,s]=this.parseNextExprWithoutSupSub(e,s+1),j(e,s)>0)throw new w("Double superscript");if(s<e.length&&e[s].eq(Ne)&&([o,s]=this.parseNextExprWithoutSupSub(e,s+1),j(e,s)>0))throw new w("Double superscript")}if(o!==null||a!==null||u>0){let p={base:t,sup:null,sub:null};if(o&&(p.sub=o),u>0){let c=[];for(let h=0;h<u;h++)c.push(new l(1,"'").toNode());a&&c.push(a),p.sup=c.length===1?c[0]:new E(c)}else a&&(p.sup=a);return[new R(p),s]}else return[t,s]}parseNextExprWithoutSupSub(e,r){if(r>=e.length)return[De,r];let t=e[r];switch(t.type){case 1:case 3:case 4:case 5:case 6:return[t.toNode(),r+1];case 2:let s=t.value.slice(1);return st.includes(s)?this.parseNextExprWithoutSupSub(e,r+1):t.eq(xe)?this.parseBeginEndExpr(e,r):t.eq(Ee)?this.parseLeftRightExpr(e,r):this.parseCommandExpr(e,r);case 7:switch(t.value){case"{":let a=ae(e,r,ne,se);if(a===-1)throw new w("Unmatched '{'");return this.parseGroup(e,r+1,a);case"}":throw new w("Unmatched '}'");case"\\\\":case"\\!":case"\\,":case"\\:":case"\\;":return[t.toNode(),r+1];case"\\ ":return[t.toNode(),r+1];case"_":case"^":return[De,r];case"&":return[t.toNode(),r+1];default:throw new w("Unknown control sequence")}default:throw new w("Unknown token type")}}parseCommandExpr(e,r){T(e[r].type===2);let t=e[r],s=t.value,o=r+1;if(["left","right","begin","end"].includes(s.slice(1)))throw new w("Unexpected command: "+s);switch(ot(s.slice(1))){case 0:return[t.toNode(),o];case 1:{if(o>=e.length)throw new w("Expecting argument for "+s);if(s==="\\sqrt"&&o<e.length&&e[o].eq(ze)){let c=o,h=ae(e,o,ze,at);if(h===-1)throw new w("No matching right square bracket for [");let[d,v]=this.parseGroup(e,c+1,h),[C,O]=this.parseNextArg(e,h+1);return[new g(t,[C],d),O]}else if(s==="\\text"){if(o+2>=e.length)throw new w("Expecting content for \\text command");T(e[o].eq(ne)),T(e[o+1].type===3),T(e[o+2].eq(se));let c=e[o+1];return[new S(c),o+3]}let[u,p]=this.parseNextArg(e,o);return[new g(t,[u]),p]}case 2:{let[u,p]=this.parseNextArg(e,o),[c,h]=this.parseNextArg(e,p);return[new g(t,[u,c]),h]}default:throw new Error("Invalid number of parameters")}}parseNextArg(e,r){let t=r,s=null;for(;t<e.length;){let o;if([o,t]=this.parseNextExprWithoutSupSub(e,t),!(o.head.type===5||o.head.type===6)){s=o;break}}if(s===null)throw new w("Expecting argument but token stream ended");return[s,t]}parseLeftRightExpr(e,r){T(e[r].eq(Ee));let t=r+1;if(t+=oe(e,t).length,t>=e.length)throw new w("Expecting delimiter after \\left");let s=Ye(e,t);if(s===null)throw new w("Invalid delimiter after \\left");t++;let o=t,a=lt(e,r);if(a===-1)throw new w("No matching \\right");let u=a;if(t=a+1,t+=oe(e,t).length,t>=e.length)throw new w("Expecting \\right after \\left");let p=Ye(e,t);if(p===null)throw new w("Invalid delimiter after \\right");t++;let[c,h]=this.parseGroup(e,o,u),d=s.value==="."?null:s,v=p.value==="."?null:p;return[new I({body:c,left:d,right:v}),t]}parseBeginEndExpr(e,r){T(e[r].eq(xe));let t=r+1;T(e[t].eq(ne)),T(e[t+1].type===3),T(e[t+2].eq(se));let s=e[t+1].value;t+=3;let o=null;["array","subarray"].includes(s)&&(t+=oe(e,t).length,[o,t]=this.parseNextArg(e,t)),t+=oe(e,t).length;let a=t,u=pt(e,r);if(u===-1)throw new w("No matching \\end");let p=u;if(t=u+1,T(e[t].eq(ne)),T(e[t+1].type===3),T(e[t+2].eq(se)),e[t+1].value!==s)throw new w("Mismatched \\begin and \\end environments");t+=3;let c=e.slice(a,p);for(;c.length>0&&[5,6].includes(c[c.length-1].type);)c.pop();let h=this.parseAligned(c);return[new M(new l(3,s),h,o),t]}parseAligned(e){let r=0,t=[],s=[];t.push(s);let o=new E([]);for(s.push(o);r<e.length;){let[a,u]=this.parseNextExpr(e,r);r=u,!((a.head.type===5||a.head.type===6)&&(!this.space_sensitive&&a.head.value.replace(/ /g,"").length===0||!this.newline_sensitive&&a.head.value===`
7
- `))&&(a.head.eq(new l(7,"\\\\"))?(s=[],o=new E([]),s.push(o),t.push(s)):a.head.eq(new l(7,"&"))?(o=new E([]),s.push(o)):o.items.push(a))}return t}};function ct(n){let e=t=>t.eq(Ne)||t.eq(qe),r=[];for(let t=0;t<n.length;t++)n[t].type===5&&t+1<n.length&&e(n[t+1])||n[t].type===5&&t-1>=0&&e(n[t-1])||r.push(n[t]);return r}function ht(n,e){let r=[];for(let t of n)if(t.type===2&&e[t.value]){let s=ye(e[t.value]);r=r.concat(s)}else r.push(t);return r}function We(n,e){let r=new ve,t=ye(n);return t=ct(t),t=ht(t,e),r.parse(t)}var V=new Map([["arrow.l.r.double.long","<==>"],["arrow.l.r.long","<-->"],["arrow.r.bar","|->"],["arrow.r.double.bar","|=>"],["arrow.r.double.long","==>"],["arrow.r.long","-->"],["arrow.r.long.squiggly","~~>"],["arrow.r.tail",">->"],["arrow.r.twohead","->>"],["arrow.l.double.long","<=="],["arrow.l.long","<--"],["arrow.l.long.squiggly","<~~"],["arrow.l.tail","<-<"],["arrow.l.twohead","<<-"],["arrow.l.r","<->"],["arrow.l.r.double","<=>"],["colon.double.eq","::="],["dots.h","..."],["gt.triple",">>>"],["lt.triple","<<<"],["arrow.r","->"],["arrow.r.double","=>"],["arrow.r.squiggly","~>"],["arrow.l","<-"],["arrow.l.squiggly","<~"],["bar.v.double","||"],["bracket.l.double","[|"],["bracket.r.double","|]"],["colon.eq",":="],["eq.colon","=:"],["eq.not","!="],["gt.double",">>"],["gt.eq",">="],["lt.double","<<"],["lt.eq","<="],["ast.op","*"],["minus","-"],["tilde.op","~"]]),ie=new Map;for(let[n,e]of V.entries())e.length>1&&ie.set(e,n);var i=class n{type;value;constructor(e,r){this.type=e,this.value=r}eq(e){return this.type===e.type&&this.value===e.value}isOneOf(e){return re(e,this)}toNode(){return new K(this)}toString(){switch(this.type){case 4:return`"${this.value}"`;case 5:return`//${this.value}`;default:return this.value}}static NONE=new n(0,"#none");static EMPTY=new n(2,"");static LEFT_BRACE=new n(2,"{");static RIGHT_BRACE=new n(2,"}");static LEFT_DELIMITERS=[new n(2,"("),new n(2,"["),new n(2,"{"),new n(2,"|"),new n(1,"angle.l")];static RIGHT_DELIMITERS=[new n(2,")"),new n(2,"]"),new n(2,"}"),new n(2,"|"),new n(1,"angle.r")]},Le=class extends Error{node;constructor(e,r){super(e),this.name="TypstWriterError",this.node=r}},Z=new i(7," "),N=class{type;head;options;constructor(e,r){this.type=e,this.head=r||i.NONE}setOptions(e){this.options=e}eq(e){return this.type===e.type&&this.head.eq(e.head)}toString(){throw new Error("Unimplemented toString() in base class TypstNode")}},K=class extends N{constructor(e){super("terminal",e)}isOverHigh(){return!1}toString(){return this.head.toString()}serialize(e,r){if(this.head.type===2){if(this.head.value===","&&e.insideFunctionDepth>0)return[new i(1,"comma")]}else if(this.head.type===1){let t=this.head.value;return r.preferShorthands&&V.has(t)&&(t=V.get(t)),r.inftyToOo&&t==="infinity"&&(t="oo"),[new i(1,t)]}else if(this.head.type===6||this.head.type===8){let t=[];for(let s of this.head.value)if(s===" ")r.keepSpaces&&t.push(new i(6,s));else if(s===`
8
- `)t.push(new i(1,s));else throw new Le(`Unexpected whitespace character: ${s}`,this);return t}return[this.head]}},_=class extends N{items;constructor(e){super("group",i.NONE),this.items=e}isOverHigh(){return this.items.some(e=>e.isOverHigh())}serialize(e,r){let t=this.items.flatMap(s=>s.serialize(e,r));return t.length>0&&t[0].eq(Z)&&t.shift(),t.length>0&&t[t.length-1].eq(Z)&&t.pop(),t}},A=class extends N{base;sup;sub;constructor(e){super("supsub",i.NONE),this.base=e.base,this.sup=e.sup,this.sub=e.sub}isOverHigh(){return this.base.isOverHigh()}serialize(e,r){let t=[],{base:s,sup:o,sub:a}=this;t.push(...s.serialize(e,r));let u=o&&o.head.eq(new i(2,"'"));return u&&t.push(new i(2,"'")),a&&(t.push(new i(2,"_")),t.push(...a.serialize(e,r))),o&&!u&&(t.push(new i(2,"^")),t.push(...o.serialize(e,r))),t.push(Z),t}},f=class extends N{args;constructor(e,r){super("funcCall",e),this.args=r}isOverHigh(){return this.head.value==="frac"?!0:this.args.some(e=>e.isOverHigh())}serialize(e,r){let t=[],s=this.head;t.push(s),e.insideFunctionDepth++,t.push(le);for(let o=0;o<this.args.length;o++)t.push(...this.args[o].serialize(e,r)),o<this.args.length-1&&t.push(new i(2,","));if(this.options)for(let[o,a]of Object.entries(this.options))t.push(new i(3,`, ${o}: ${a.toString()}`));return t.push(ue),e.insideFunctionDepth--,t}},D=class extends N{args;constructor(e){super("fraction",i.NONE),this.args=e}isOverHigh(){return!0}serialize(e,r){let t=[],[s,o]=this.args;return t.push(Z),t.push(...s.serialize(e,r)),t.push(new i(2,"/")),t.push(...o.serialize(e,r)),t.push(Z),t}},le=new i(2,"("),ue=new i(2,")"),q=class extends N{body;left;right;constructor(e,r){super("leftright",e),this.body=r.body,this.left=r.left,this.right=r.right}isOverHigh(){return this.body.isOverHigh()}serialize(e,r){let t=[],s=new i(1,"lr"),{left:o,right:a}=this;return this.head.eq(s)&&(t.push(s),t.push(le)),o&&t.push(o),t.push(...this.body.serialize(e,r)),a&&t.push(a),this.head.eq(s)&&t.push(ue),t}},y=class n extends N{matrix;constructor(e,r){super("matrixLike",e),this.matrix=r}isOverHigh(){return!0}serialize(e,r){let t=[],s,o;if(this.head.eq(n.MAT)?(s=new i(2,","),o=new i(2,";")):this.head.eq(n.CASES)?(s=new i(2,"&"),o=new i(2,",")):this.head.eq(i.NONE)&&(s=new i(2,"&"),o=new i(1,"\\")),!this.head.eq(i.NONE)&&(t.push(this.head),e.insideFunctionDepth++,t.push(le),this.options))for(let[a,u]of Object.entries(this.options))t.push(new i(3,`${a}: ${u.toString()}, `));return this.matrix.forEach((a,u)=>{a.forEach((p,c)=>{t.push(...p.serialize(e,r)),c<a.length-1?t.push(s):u<this.matrix.length-1&&t.push(o)})}),this.head.eq(i.NONE)||(t.push(ue),e.insideFunctionDepth--),t}static MAT=new i(1,"mat");static CASES=new i(1,"cases")},z=class extends N{fragments;constructor(e,r){super("markupFunc",e),this.fragments=r}isOverHigh(){return this.fragments.some(e=>e.isOverHigh())}serialize(e,r){let t=[];if(t.push(this.head),e.insideFunctionDepth++,t.push(le),this.options){let s=Object.entries(this.options);for(let o=0;o<s.length;o++){let[a,u]=s[o];t.push(new i(3,`${a}: ${u.toString()}`)),o<s.length-1&&t.push(new i(2,","))}}t.push(ue),t.push(new i(3,"["));for(let s of this.fragments)t.push(new i(3,"$")),t.push(...s.serialize(e,r)),t.push(new i(3,"$"));return t.push(new i(3,"]")),t}};var dt=new i(2,"("),Tt=new i(2,")"),gt=new i(2,","),Ue=new i(1,`
9
- `),ke=new i(7," ");var pe=class{buffer="";queue=[];options;constructor(e){this.options=e}writeBuffer(e,r){let t=r.toString();if(t==="")return;let s=!1;s||=/[\(\[\|]$/.test(this.buffer)&&/^\w/.test(t),s||=/^[})\]\|]$/.test(t),s||=/[^=]$/.test(this.buffer)&&t==="(",s||=/^[_^,;!]$/.test(t),s||=t==="'",s||=/[\(\[{]\s*(-|\+)$/.test(this.buffer)||this.buffer==="-"||this.buffer==="+",s||=t.startsWith(`
10
- `),s||=this.buffer==="",s||=/\s$/.test(this.buffer)||/^\s/.test(t),s||=this.buffer.endsWith("&")&&t==="=",s||=this.buffer.endsWith("/")||t==="/",s||=r.type===3,s||=/[\s_^{\(]$/.test(this.buffer),e!==null&&(s||=e.type===3),s||(this.buffer+=" "),this.buffer+=t}serialize(e){let r={insideFunctionDepth:0};this.queue.push(...e.serialize(r,this.options))}flushQueue(){let e=[];for(let t of this.queue)t.eq(ke)&&e.length>0&&e[e.length-1].eq(ke)||e.push(t);let r=new i(1,"");for(let t=0;t<e.length;t++)e[t].eq(ke)&&(t===0||t===e.length-1||e[t-1].type===6||e[t-1].isOneOf([dt,Ue])||e[t+1].isOneOf([Tt,gt,Ue]))&&(e[t]=r);e=e.filter(t=>!t.eq(r));for(let t=0;t<e.length;t++){let s=e[t],o=t===0?null:e[t-1];this.writeBuffer(o,s)}this.queue=[]}finalize(){this.flushQueue();let e=function(s){let o=s.replace(/floor\.l\s*(.*?)\s*floor\.r/g,"floor($1)");return o=o.replace(/floor\(\)/g,'floor("")'),o},r=function(s){let o=s.replace(/ceil\.l\s*(.*?)\s*ceil\.r/g,"ceil($1)");return o=o.replace(/ceil\(\)/g,'ceil("")'),o},t=function(s){let o=s.replace(/floor\.l\s*(.*?)\s*ceil\.r/g,"round($1)");return o=o.replace(/round\(\)/g,'round("")'),o};if(this.options.optimize){let s=[e,r,t];for(let o of s)this.buffer=o(this.buffer)}return this.buffer}};var x=new Map([["displaystyle","display"],["hspace","#h"],["|","bar.v.double"],[",","thin"],[":","med"],[" ","med"],[";","thick"],["ln","ln"],["log","log"],["cos","cos"],["sin","sin"],["tan","tan"],["cot","cot"],["sec","sec"],["csc","csc"],["mod","mod"],["omicron","omicron"],["Xi","Xi"],["Upsilon","Upsilon"],["lim","lim"],["binom","binom"],["tilde","tilde"],["hat","hat"],["sqrt","sqrt"],["nonumber",""],["vec","arrow"],["neq","eq.not"],["dot","dot"],["ddot","dot.double"],["doteq","dot(eq)"],["dots","dots.h"],["vdots","dots.v"],["ddots","dots.down"],["widehat","hat"],["widetilde","tilde"],["quad","quad"],["qquad","wide"],["overbrace","overbrace"],["underbrace","underbrace"],["overline","overline"],["underline","underline"],["bar","macron"],["dbinom","binom"],["tbinom","binom"],["dfrac","frac"],["tfrac","frac"],["operatorname","op"],["boldsymbol","bold"],["mathbb","bb"],["mathbf","bold"],["mathcal","cal"],["mathit","italic"],["mathfrak","frak"],["mathrm","upright"],["mathsf","sans"],["mathtt","mono"],["rm","upright"],["pmb","bold"],["leadsto","arrow.r.squiggly"],["P","pilcrow"],["S","section"],["aleph","alef"],["infin","infinity"],["Delta","Delta"],["Gamma","Gamma"],["Lambda","Lambda"],["Omega","Omega"],["Phi","Phi"],["Pi","Pi"],["Psi","Psi"],["Sigma","Sigma"],["Theta","Theta"],["alpha","alpha"],["beta","beta"],["bigcirc","circle.big"],["bullet","bullet"],["cdot","dot.op"],["cdots","dots.c"],["checkmark","checkmark"],["chi","chi"],["circ","circle.small"],["colon","colon"],["cong","tilde.equiv"],["coprod","product.co"],["copyright","copyright"],["cup","union"],["curlyvee","or.curly"],["curlywedge","and.curly"],["dagger","dagger"],["dashv","tack.l"],["ddagger","dagger.double"],["delta","delta"],["ddots","dots.down"],["diamond","diamond"],["div","div"],["divideontimes","times.div"],["dotplus","plus.dot"],["ell","ell"],["emptyset","nothing"],["epsilon","epsilon.alt"],["equiv","equiv"],["eta","eta"],["exists","exists"],["forall","forall"],["gamma","gamma"],["ge","gt.eq"],["geq","gt.eq"],["geqslant","gt.eq.slant"],["gg","gt.double"],["hbar","planck.reduce"],["imath","dotless.i"],["iiiint","integral.quad"],["iiint","integral.triple"],["iint","integral.double"],["in","in"],["infty","infinity"],["int","integral"],["intercal","top"],["iota","iota"],["jmath","dotless.j"],["kappa","kappa"],["lambda","lambda"],["land","and"],["langle","angle.l"],["lbrace","brace.l"],["lbrack","bracket.l"],["ldots","dots.h"],["le","lt.eq"],["leftthreetimes","times.three.l"],["leftrightarrow","arrow.l.r"],["leq","lt.eq"],["leqslant","lt.eq.slant"],["lhd","triangle.l"],["ll","lt.double"],["lor","or"],["ltimes","times.l"],["measuredangle","angle.arc"],["mid","divides"],["models","models"],["mp","minus.plus"],["mu","mu"],["nabla","nabla"],["ncong","tilde.equiv.not"],["ne","eq.not"],["neg","not"],["neq","eq.not"],["nexists","exists.not"],["ni","in.rev"],["nleftarrow","arrow.l.not"],["nleq","lt.eq.not"],["nparallel","parallel.not"],["ngeq","gt.eq.not"],["nmid","divides.not"],["notin","in.not"],["nsim","tilde.not"],["nsubseteq","subset.eq.not"],["nu","nu"],["ntriangleleft","lt.tri.not"],["ntriangleright","gt.tri.not"],["odot","dot.circle"],["oint","integral.cont"],["oiint","integral.surf"],["oiiint","integral.vol"],["omega","omega"],["ominus","minus.circle"],["otimes","times.circle"],["parallel","parallel"],["partial","diff"],["perp","perp"],["phi","phi.alt"],["pi","pi"],["pm","plus.minus"],["pounds","pound"],["prec","prec"],["preceq","prec.eq"],["prime","prime"],["prod","product"],["propto","prop"],["psi","psi"],["rangle","angle.r"],["rbrace","brace.r"],["rbrack","bracket.r"],["rhd","triangle"],["rho","rho"],["rightarrow","arrow.r"],["rightthreetimes","times.three.r"],["rtimes","times.r"],["setminus","without"],["sigma","sigma"],["sim","tilde.op"],["simeq","tilde.eq"],["slash","slash"],["smallsetminus","without"],["spadesuit","suit.spade"],["sqsubseteq","subset.eq.sq"],["sqsupseteq","supset.eq.sq"],["subset","subset"],["subseteq","subset.eq"],["subsetneq","subset.neq"],["succ","succ"],["succeq","succ.eq"],["sum","sum"],["supset","supset"],["supseteq","supset.eq"],["supsetneq","supset.neq"],["tau","tau"],["theta","theta"],["times","times"],["to","arrow.r"],["top","top"],["triangle","triangle.t"],["twoheadrightarrow","arrow.r.twohead"],["upharpoonright","harpoon.tr"],["uplus","union.plus"],["upsilon","upsilon"],["varepsilon","epsilon"],["varnothing","diameter"],["varphi","phi"],["varpi","pi.alt"],["varrho","rho.alt"],["varsigma","sigma.alt"],["vartheta","theta.alt"],["vdash","tack.r"],["vdots","dots.v"],["vee","or"],["wedge","and"],["wr","wreath"],["xi","xi"],["yen","yen"],["zeta","zeta"],["intop","limits(integral)"],["mathscr","scr"],["LaTeX","#LaTeX"],["TeX","#TeX"]]),wt=new Map([["acwopencirclearrow","arrow.ccw"],["adots","dots.up"],["angdnr","angle.acute"],["angle","angle"],["angles","angle.s"],["approx","approx"],["approxeq","approx.eq"],["approxident","tilde.triple"],["assert","tack.r.short"],["ast","ast.op"],["asymp","asymp"],["awint","integral.ccw"],["backcong","tilde.rev.equiv"],["backdprime","prime.double.rev"],["backprime","prime.rev"],["backsim","tilde.rev"],["backsimeq","tilde.eq.rev"],["backslash","backslash"],["backtrprime","prime.triple.rev"],["bardownharpoonleft","harpoon.bl.bar"],["bardownharpoonright","harpoon.br.bar"],["barleftarrow","arrow.l.stop"],["barleftarrowrightarrowbar","arrows.lr.stop"],["barleftharpoondown","harpoon.lb.stop"],["barleftharpoonup","harpoon.lt.stop"],["barrightharpoondown","harpoon.rb.bar"],["barrightharpoonup","harpoon.rt.bar"],["baruparrow","arrow.t.stop"],["barupharpoonleft","harpoon.tl.stop"],["barupharpoonright","harpoon.tr.stop"],["barV","tack.b.double"],["BbbA","AA"],["BbbB","BB"],["BbbC","CC"],["BbbD","DD"],["BbbE","EE"],["BbbF","FF"],["BbbG","GG"],["BbbH","HH"],["BbbI","II"],["BbbJ","JJ"],["BbbK","KK"],["BbbL","LL"],["BbbM","MM"],["BbbN","NN"],["BbbO","OO"],["BbbP","PP"],["BbbQ","QQ"],["BbbR","RR"],["BbbS","SS"],["BbbT","TT"],["BbbU","UU"],["BbbV","VV"],["BbbW","WW"],["BbbX","XX"],["BbbY","YY"],["BbbZ","ZZ"],["because","because"],["bigblacktriangledown","triangle.filled.b"],["bigblacktriangleup","triangle.filled.t"],["bigbot","tack.t.big"],["bigcap","inter.big"],["bigcup","union.big"],["bigcupdot","union.dot.big"],["biginterleave","interleave.big"],["bigodot","dot.circle.big"],["bigoplus","plus.circle.big"],["bigotimes","times.circle.big"],["bigsqcap","inter.sq.big"],["bigsqcup","union.sq.big"],["bigstar","star.filled"],["bigtimes","times.big"],["bigtop","tack.b.big"],["bigtriangledown","triangle.stroked.b"],["bigtriangleup","triangle.stroked.t"],["biguplus","union.plus.big"],["bigvee","or.big"],["bigwedge","and.big"],["bigwhitestar","star.stroked"],["blackhourglass","hourglass.filled"],["blacktriangle","triangle.filled.small.t"],["blacktriangledown","triangle.filled.small.b"],["blacktriangleleft","triangle.filled.l"],["blacktriangleright","triangle.filled.r"],["blkhorzoval","ellipse.filled.h"],["blkvertoval","ellipse.filled.v"],["bot","bot"],["boxast","ast.square"],["boxdot","dot.square"],["boxminus","minus.square"],["boxplus","plus.square"],["boxtimes","times.square"],["cap","inter"],["Cap","inter.double"],["capdot","inter.dot"],["capwedge","inter.and"],["caretinsert","caret"],["cdot","dot.op"],["cdotp","dot.c"],["checkmark","checkmark"],["circledast","ast.circle"],["circledcirc","circle.nested"],["circleddash","dash.circle"],["circledequal","eq.circle"],["circledparallel","parallel.circle"],["circledvert","bar.v.circle"],["clubsuit","suit.club.filled"],["Colon","colon.double"],["coloneq","colon.eq"],["Coloneq","colon.double.eq"],["complement","complement"],["cong","tilde.equiv"],["coprod","product.co"],["cup","union"],["Cup","union.double"],["cupdot","union.dot"],["cupleftarrow","union.arrow"],["cupvee","union.or"],["curlyeqprec","eq.prec"],["curlyeqsucc","eq.succ"],["curlyvee","or.curly"],["curlywedge","and.curly"],["curvearrowleft","arrow.ccw.half"],["curvearrowright","arrow.cw.half"],["cwopencirclearrow","arrow.cw"],["dagger","dagger"],["dashcolon","dash.colon"],["dashv","tack.l"],["Dashv","tack.l.double"],["dashVdash","tack.l.r"],["ddagger","dagger.double"],["ddddot","dot.quad"],["dddot","dot.triple"],["ddots","dots.down"],["DDownarrow","arrow.b.quad"],["Ddownarrow","arrow.b.triple"],["diameter","diameter"],["diamondcdot","diamond.stroked.dot"],["diamondsuit","suit.diamond.stroked"],["dicei","die.one"],["diceii","die.two"],["diceiii","die.three"],["diceiv","die.four"],["dicev","die.five"],["dicevi","die.six"],["div","div"],["divideontimes","times.div"],["Doteq","eq.dots"],["dotminus","minus.dot"],["dotplus","plus.dot"],["dotsim","tilde.dot"],["dottedcircle","circle.dotted"],["dottedsquare","square.stroked.dotted"],["doubleplus","plus.double"],["downarrow","arrow.b"],["Downarrow","arrow.b.double"],["downarrowbar","arrow.b.stop"],["downdasharrow","arrow.b.dashed"],["downdownarrows","arrows.bb"],["downharpoonleft","harpoon.bl"],["downharpoonleftbar","harpoon.bl.stop"],["downharpoonright","harpoon.br"],["downharpoonrightbar","harpoon.br.stop"],["downharpoonsleftright","harpoons.blbr"],["downrightcurvedarrow","arrow.b.curve"],["downuparrows","arrows.bt"],["downupharpoonsleftright","harpoons.bltr"],["downwhitearrow","arrow.b.stroked"],["downzigzagarrow","arrow.zigzag"],["dprime","prime.double"],["dualmap","multimap.double"],["eighthnote","note.eighth.alt"],["ell","ell"],["emptysetoarr","emptyset.arrow.r"],["emptysetoarrl","emptyset.arrow.l"],["emptysetobar","emptyset.bar"],["emptysetocirc","emptyset.circle"],["eparsl","parallel.slanted.eq"],["eqcolon","eq.colon"],["eqdef","eq.def"],["eqgtr","eq.gt"],["eqless","eq.lt"],["eqsim","minus.tilde"],["equal","eq"],["equalparallel","parallel.eq"],["equiv","eq.triple"],["Equiv","eq.quad"],["equivVert","parallel.equiv"],["eqvparsl","parallel.slanted.equiv"],["errbarblackcircle","errorbar.circle.filled"],["errbarblackdiamond","errorbar.diamond.filled"],["errbarblacksquare","errorbar.square.filled"],["errbarcircle","errorbar.circle.stroked"],["errbardiamond","errorbar.diamond.stroked"],["errbarsquare","errorbar.square.stroked"],["euro","euro"],["Exclam","excl.double"],["exists","exists"],["fallingdotseq","eq.dots.down"],["fint","integral.slash"],["flat","flat"],["forall","forall"],["fourvdots","fence.dotted"],["fullouterjoin","join.l.r"],["geq","gt.eq"],["geqq","gt.equiv"],["geqslant","gt.eq.slant"],["gg","gt.double"],["ggg","gt.triple"],["gggnest","gt.triple.nested"],["gnapprox","gt.napprox"],["gneq","gt.neq"],["gneqq","gt.nequiv"],["gnsim","gt.ntilde"],["greater","gt"],["gtlpar","angle.spheric.rev"],["gtrapprox","gt.approx"],["gtrdot","gt.dot"],["gtreqless","gt.eq.lt"],["gtrless","gt.lt"],["gtrsim","gt.tilde"],["heartsuit","suit.heart.stroked"],["hknearrow","arrow.tr.hook"],["hknwarrow","arrow.tl.hook"],["hksearrow","arrow.br.hook"],["hkswarrow","arrow.bl.hook"],["hookleftarrow","arrow.l.hook"],["hookrightarrow","arrow.r.hook"],["horizbar","bar.h"],["hourglass","hourglass.stroked"],["hrectangle","rect.stroked.h"],["hrectangleblack","rect.filled.h"],["hslash","planck.reduce"],["hzigzag","dash.wave.double"],["iiiint","integral.quad"],["iiint","integral.triple"],["iinfin","infinity.incomplete"],["iint","integral.double"],["Im","Im"],["imageof","image"],["in","in"],["increment","laplace"],["infty","infinity"],["int","integral"],["intbar","integral.dash"],["intBar","integral.dash.double"],["intcap","integral.inter"],["intclockwise","integral.cw"],["intcup","integral.union"],["interleave","interleave"],["intlarhk","integral.arrow.hook"],["intx","integral.times"],["Join","join"],["langle","angle.l"],["lAngle","angle.l.double"],["langledot","angle.l.dot"],["lat","lat"],["late","lat.eq"],["lbrace","brace.l"],["lBrace","brace.l.double"],["lbrack","bracket.l"],["lBrack","bracket.l.double"],["lbrbrak","shell.l"],["Lbrbrak","shell.l.double"],["lceil","ceil.l"],["lcurvyangle","angle.l.curly"],["leftarrow","arrow.l"],["Leftarrow","arrow.l.double"],["leftarrowtail","arrow.l.tail"],["leftdasharrow","arrow.l.dashed"],["leftdotarrow","arrow.l.dotted"],["leftdowncurvedarrow","arrow.l.curve"],["leftharpoondown","harpoon.lb"],["leftharpoondownbar","harpoon.lb.bar"],["leftharpoonsupdown","harpoons.ltlb"],["leftharpoonup","harpoon.lt"],["leftharpoonupbar","harpoon.lt.bar"],["leftleftarrows","arrows.ll"],["leftouterjoin","join.l"],["leftrightarrow","arrow.l.r"],["Leftrightarrow","arrow.l.r.double"],["leftrightarrows","arrows.lr"],["leftrightharpoondowndown","harpoon.lb.rb"],["leftrightharpoondownup","harpoon.lb.rt"],["leftrightharpoons","harpoons.ltrb"],["leftrightharpoonsdown","harpoons.lbrb"],["leftrightharpoonsup","harpoons.ltrt"],["leftrightharpoonupdown","harpoon.lt.rb"],["leftrightharpoonupup","harpoon.lt.rt"],["leftrightsquigarrow","arrow.l.r.wave"],["leftsquigarrow","arrow.l.squiggly"],["leftthreearrows","arrows.lll"],["leftthreetimes","times.three.l"],["leftwavearrow","arrow.l.wave"],["leftwhitearrow","arrow.l.stroked"],["leq","lt.eq"],["leqq","lt.equiv"],["leqslant","lt.eq.slant"],["less","lt"],["lessapprox","lt.approx"],["lessdot","lt.dot"],["lesseqgtr","lt.eq.gt"],["lessgtr","lt.gt"],["lesssim","lt.tilde"],["lfloor","floor.l"],["lgblkcircle","circle.filled.big"],["lgblksquare","square.filled.big"],["lgwhtcircle","circle.stroked.big"],["lgwhtsquare","square.stroked.big"],["ll","lt.double"],["llblacktriangle","triangle.filled.bl"],["LLeftarrow","arrow.l.quad"],["Lleftarrow","arrow.l.triple"],["lll","lt.triple"],["lllnest","lt.triple.nested"],["lltriangle","triangle.stroked.bl"],["lnapprox","lt.napprox"],["lneq","lt.neq"],["lneqq","lt.nequiv"],["lnsim","lt.ntilde"],["longdashv","tack.l.long"],["Longleftarrow","arrow.l.double.long"],["longleftarrow","arrow.l.long"],["Longleftrightarrow","arrow.l.r.double.long"],["longleftrightarrow","arrow.l.r.long"],["longleftsquigarrow","arrow.l.long.squiggly"],["Longmapsfrom","arrow.l.double.long.bar"],["longmapsfrom","arrow.l.long.bar"],["longmapsto","arrow.r.long.bar"],["Longmapsto","arrow.r.double.long.bar"],["Longrightarrow","arrow.r.double.long"],["longrightarrow","arrow.r.long"],["longrightsquigarrow","arrow.r.long.squiggly"],["looparrowleft","arrow.l.loop"],["looparrowright","arrow.r.loop"],["lparen","paren.l"],["lParen","paren.l.double"],["lrblacktriangle","triangle.filled.br"],["lrtriangle","triangle.stroked.br"],["ltimes","times.l"],["lvzigzag","fence.l"],["Lvzigzag","fence.l.double"],["maltese","maltese"],["mapsdown","arrow.b.bar"],["mapsfrom","arrow.l.bar"],["Mapsfrom","arrow.l.double.bar"],["mapsto","arrow.r.bar"],["Mapsto","arrow.r.double.bar"],["mapsup","arrow.t.bar"],["mathampersand","amp"],["mathatsign","at"],["mathcolon","colon"],["mathcomma","comma"],["mathdollar","dollar"],["mathexclam","excl"],["mathoctothorpe","hash"],["mathparagraph","pilcrow"],["mathpercent","percent"],["mathperiod","dot.basic"],["mathplus","plus"],["mathquestion","quest"],["mathratio","ratio"],["mathsection","section"],["mathsemicolon","semi"],["mathslash","slash"],["mathsterling","pound"],["mathyen","yen"],["mdblkdiamond","diamond.filled.medium"],["mdblklozenge","lozenge.filled.medium"],["mdblksquare","square.filled.medium"],["mdlgblkcircle","circle.filled"],["mdlgblkdiamond","diamond.filled"],["mdlgblklozenge","lozenge.filled"],["mdlgblksquare","square.filled"],["mdlgwhtcircle","circle.stroked"],["mdlgwhtdiamond","diamond.stroked"],["mdlgwhtlozenge","lozenge.stroked"],["mdlgwhtsquare","square.stroked"],["mdsmblkcircle","circle.filled.tiny"],["mdsmblksquare","square.filled.small"],["mdsmwhtcircle","circle.stroked.small"],["mdsmwhtsquare","square.stroked.small"],["mdwhtdiamond","diamond.stroked.medium"],["mdwhtlozenge","lozenge.stroked.medium"],["mdwhtsquare","square.stroked.medium"],["measeq","eq.m"],["measuredangle","angle.arc"],["measuredangleleft","angle.arc.rev"],["measuredrightangle","angle.right.arc"],["mho","Omega.inv"],["mid","divides"],["minus","minus"],["models","models"],["mp","minus.plus"],["multimap","multimap"],["nabla","gradient"],["napprox","approx.not"],["nasymp","asymp.not"],["natural","natural"],["ncong","tilde.equiv.not"],["ne","eq.not"],["nearrow","arrow.tr"],["Nearrow","arrow.tr.double"],["neg","not"],["nequiv","equiv.not"],["neswarrow","arrow.tr.bl"],["nexists","exists.not"],["ngeq","gt.eq.not"],["ngtr","gt.not"],["ngtrless","gt.lt.not"],["ngtrsim","gt.tilde.not"],["nhpar","parallel.struck"],["nhVvert","interleave.struck"],["ni","in.rev"],["nLeftarrow","arrow.l.double.not"],["nleftarrow","arrow.l.not"],["nLeftrightarrow","arrow.l.r.double.not"],["nleftrightarrow","arrow.l.r.not"],["nleq","lt.eq.not"],["nless","lt.not"],["nlessgtr","lt.gt.not"],["nlesssim","lt.tilde.not"],["nmid","divides.not"],["nni","in.rev.not"],["notin","in.not"],["nparallel","parallel.not"],["nprec","prec.not"],["npreccurlyeq","prec.curly.eq.not"],["nRightarrow","arrow.r.double.not"],["nrightarrow","arrow.r.not"],["nsim","tilde.not"],["nsimeq","tilde.eq.not"],["nsqsubseteq","subset.eq.sq.not"],["nsqsupseteq","supset.eq.sq.not"],["nsubset","subset.not"],["nsubseteq","subset.eq.not"],["nsucc","succ.not"],["nsucccurlyeq","succ.curly.eq.not"],["nsupset","supset.not"],["nsupseteq","supset.eq.not"],["ntrianglelefteq","lt.tri.eq.not"],["ntrianglerighteq","gt.tri.eq.not"],["nvartriangleleft","lt.tri.not"],["nvartriangleright","gt.tri.not"],["nVdash","forces.not"],["nvdash","tack.r.not"],["nvDash","tack.r.double.not"],["nvinfty","infinity.bar"],["nwarrow","arrow.tl"],["Nwarrow","arrow.tl.double"],["nwsearrow","arrow.tl.br"],["obrbrak","shell.t"],["obslash","backslash.circle"],["odiv","div.circle"],["odot","dot.circle"],["ogreaterthan","gt.circle"],["oiiint","integral.vol"],["oiint","integral.surf"],["oint","integral.cont"],["ointctrclockwise","integral.cont.ccw"],["olessthan","lt.circle"],["ominus","minus.circle"],["operp","perp.circle"],["oplus","plus.circle"],["origof","original"],["otimes","times.circle"],["overbracket","bracket.t"],["overparen","paren.t"],["parallel","parallel"],["parallelogram","parallelogram.stroked"],["parallelogramblack","parallelogram.filled"],["parsim","parallel.tilde"],["partial","diff"],["pentagon","penta.stroked"],["pentagonblack","penta.filled"],["perp","perp"],["Planckconst","planck"],["pm","plus.minus"],["prec","prec"],["Prec","prec.double"],["precapprox","prec.approx"],["preccurlyeq","prec.curly.eq"],["preceq","prec.eq"],["preceqq","prec.equiv"],["precnapprox","prec.napprox"],["precneq","prec.neq"],["precneqq","prec.nequiv"],["precnsim","prec.ntilde"],["precsim","prec.tilde"],["prime","prime"],["prod","product"],["propto","prop"],["QED","qed"],["qprime","prime.quad"],["quarternote","note.quarter.alt"],["questeq","eq.quest"],["Question","quest.double"],["rangle","angle.r"],["rAngle","angle.r.double"],["rangledot","angle.r.dot"],["rbrace","brace.r"],["rBrace","brace.r.double"],["rbrack","bracket.r"],["rBrack","bracket.r.double"],["rbrbrak","shell.r"],["Rbrbrak","shell.r.double"],["rceil","ceil.r"],["rcurvyangle","angle.r.curly"],["Re","Re"],["revangle","angle.rev"],["revemptyset","emptyset.rev"],["revnmid","divides.not.rev"],["rfloor","floor.r"],["rightangle","angle.right"],["rightanglemdot","angle.right.dot"],["rightanglesqr","angle.right.sq"],["rightarrow","arrow.r"],["Rightarrow","arrow.r.double"],["rightarrowbar","arrow.r.stop"],["rightarrowonoplus","plus.circle.arrow"],["rightarrowtail","arrow.r.tail"],["rightdasharrow","arrow.r.dashed"],["rightdotarrow","arrow.r.dotted"],["rightdowncurvedarrow","arrow.r.curve"],["rightharpoondown","harpoon.rb"],["rightharpoondownbar","harpoon.rb.stop"],["rightharpoonsupdown","harpoons.rtrb"],["rightharpoonup","harpoon.rt"],["rightharpoonupbar","harpoon.rt.stop"],["rightleftarrows","arrows.rl"],["rightleftharpoons","harpoons.rtlb"],["rightleftharpoonsdown","harpoons.rblb"],["rightleftharpoonsup","harpoons.rtlt"],["rightouterjoin","join.r"],["rightrightarrows","arrows.rr"],["rightsquigarrow","arrow.r.squiggly"],["rightthreearrows","arrows.rrr"],["rightthreetimes","times.three.r"],["rightwavearrow","arrow.r.wave"],["rightwhitearrow","arrow.r.stroked"],["risingdotseq","eq.dots.up"],["rparen","paren.r"],["rParen","paren.r.double"],["RRightarrow","arrow.r.quad"],["Rrightarrow","arrow.r.triple"],["rsolbar","backslash.not"],["rtimes","times.r"],["rvzigzag","fence.r"],["Rvzigzag","fence.r.double"],["searrow","arrow.br"],["Searrow","arrow.br.double"],["setminus","without"],["sharp","sharp"],["shortdowntack","tack.b.short"],["shortlefttack","tack.l.short"],["shortuptack","tack.t.short"],["sim","tilde.op"],["sime","tilde.eq"],["similarleftarrow","arrow.l.tilde"],["similarrightarrow","arrow.r.tilde"],["simneqq","tilde.nequiv"],["smallblacktriangleleft","triangle.filled.small.l"],["smallblacktriangleright","triangle.filled.small.r"],["smallin","in.small"],["smallni","in.rev.small"],["smalltriangleleft","triangle.stroked.small.l"],["smalltriangleright","triangle.stroked.small.r"],["smashtimes","smash"],["smblkcircle","bullet"],["smblkdiamond","diamond.filled.small"],["smblklozenge","lozenge.filled.small"],["smblksquare","square.filled.tiny"],["smeparsl","parallel.slanted.eq.tilde"],["smt","smt"],["smte","smt.eq"],["smwhtdiamond","diamond.stroked.small"],["smwhtlozenge","lozenge.stroked.small"],["smwhtsquare","square.stroked.tiny"],["spadesuit","suit.spade.filled"],["sphericalangle","angle.spheric"],["sphericalangleup","angle.spheric.top"],["sqcap","inter.sq"],["Sqcap","inter.sq.double"],["sqcup","union.sq"],["Sqcup","union.sq.double"],["sqint","integral.square"],["sqsubset","subset.sq"],["sqsubseteq","subset.eq.sq"],["sqsubsetneq","subset.sq.neq"],["sqsupset","supset.sq"],["sqsupseteq","supset.eq.sq"],["sqsupsetneq","supset.sq.neq"],["squoval","square.stroked.rounded"],["sslash","slash.double"],["star","star.op"],["stareq","eq.star"],["subset","subset"],["Subset","subset.double"],["subsetdot","subset.dot"],["subseteq","subset.eq"],["subsetneq","subset.neq"],["succ","succ"],["Succ","succ.double"],["succapprox","succ.approx"],["succcurlyeq","succ.curly.eq"],["succeq","succ.eq"],["succeqq","succ.equiv"],["succnapprox","succ.napprox"],["succneq","succ.neq"],["succneqq","succ.nequiv"],["succnsim","succ.ntilde"],["succsim","succ.tilde"],["sum","sum"],["sumint","sum.integral"],["supset","supset"],["Supset","supset.double"],["supsetdot","supset.dot"],["supseteq","supset.eq"],["supsetneq","supset.neq"],["swarrow","arrow.bl"],["Swarrow","arrow.bl.double"],["therefore","therefore"],["threedangle","angle.spatial"],["threedotcolon","colon.tri.op"],["tieinfty","infinity.tie"],["times","times"],["tminus","miny"],["top","tack.b"],["tplus","tiny"],["trianglecdot","triangle.stroked.dot"],["triangledown","triangle.stroked.small.b"],["triangleleft","triangle.stroked.l"],["trianglelefteq","lt.tri.eq"],["triangleminus","minus.triangle"],["triangleplus","plus.triangle"],["triangleq","eq.delta"],["triangleright","triangle.stroked.r"],["trianglerighteq","gt.tri.eq"],["triangletimes","times.triangle"],["tripleplus","plus.triple"],["trprime","prime.triple"],["trslash","slash.triple"],["twoheaddownarrow","arrow.b.twohead"],["twoheadleftarrow","arrow.l.twohead"],["twoheadmapsfrom","arrow.l.twohead.bar"],["twoheadmapsto","arrow.r.twohead.bar"],["twoheadrightarrow","arrow.r.twohead"],["twoheaduparrow","arrow.t.twohead"],["twonotes","note.eighth.beamed"],["ubrbrak","shell.b"],["ulblacktriangle","triangle.filled.tl"],["ultriangle","triangle.stroked.tl"],["uminus","union.minus"],["underbrace","brace.b"],["underbracket","bracket.b"],["underparen","paren.b"],["unicodecdots","dots.h.c"],["unicodeellipsis","dots.h"],["upand","amp.inv"],["uparrow","arrow.t"],["Uparrow","arrow.t.double"],["updasharrow","arrow.t.dashed"],["updownarrow","arrow.t.b"],["Updownarrow","arrow.t.b.double"],["updownarrows","arrows.tb"],["updownharpoonleftleft","harpoon.tl.bl"],["updownharpoonleftright","harpoon.tl.br"],["updownharpoonrightleft","harpoon.tr.bl"],["updownharpoonrightright","harpoon.tr.br"],["updownharpoonsleftright","harpoons.tlbr"],["upharpoonleft","harpoon.tl"],["upharpoonleftbar","harpoon.tl.bar"],["upharpoonright","harpoon.tr"],["upharpoonrightbar","harpoon.tr.bar"],["upharpoonsleftright","harpoons.tltr"],["uplus","union.plus"],["uprightcurvearrow","arrow.t.curve"],["upuparrows","arrows.tt"],["upwhitearrow","arrow.t.stroked"],["urblacktriangle","triangle.filled.tr"],["urtriangle","triangle.stroked.tr"],["UUparrow","arrow.t.quad"],["Uuparrow","arrow.t.triple"],["varclubsuit","suit.club.stroked"],["vardiamondsuit","suit.diamond.filled"],["varheartsuit","suit.heart.filled"],["varhexagon","hexa.stroked"],["varhexagonblack","hexa.filled"],["varnothing","emptyset"],["varointclockwise","integral.cont.cw"],["varspadesuit","suit.spade.stroked"],["vartriangle","triangle.stroked.small.t"],["vartriangleleft","lt.tri"],["vartriangleright","gt.tri"],["Vbar","tack.t.double"],["Vdash","forces"],["vdash","tack.r"],["vDash","tack.r.double"],["vdots","dots.v"],["vee","or"],["Vee","or.double"],["veedot","or.dot"],["veeeq","eq.equi"],["vert","bar.v"],["Vert","bar.v.double"],["vlongdash","tack.r.long"],["vrectangle","rect.stroked.v"],["vrectangleblack","rect.filled.v"],["Vvert","bar.v.triple"],["vysmblkcircle","circle.filled.small"],["vysmwhtcircle","circle.stroked.tiny"],["wedge","and"],["Wedge","and.double"],["wedgedot","and.dot"],["wedgeq","eq.est"],["whiteinwhitetriangle","triangle.stroked.nested"],["whthorzoval","ellipse.stroked.h"],["whtvertoval","ellipse.stroked.v"],["wideangledown","angle.oblique"],["wr","wreath"],["xsol","slash.big"]]),bt=new Map([["gets","leftarrow"],["iff","Longleftrightarrow"],["implies","Longrightarrow"]]);for(let[n,e]of wt)x.has(n)||x.set(n,e);var Y=new Map;for(let[n,e]of Array.from(x.entries()).reverse())Y.set(e,n);Y.set("oo","infty");var mt=new Map([["top","top"],["frac","frac"],["tilde","tilde"],["hat","hat"],["upright","mathrm"],["bold","boldsymbol"],["infinity","infty"]]);for(let[n,e]of mt)Y.set(n,e);for(let[n,e]of bt)x.has(n)||x.set(n,x.get(e));var U=class extends Error{node;constructor(e,r=null){super(e),this.name="ConverterError",this.node=r}},ft=i.NONE.toNode(),yt=["dim","id","im","mod","Pr","sech","csch"];function Et(n){if(/^[a-zA-Z0-9]$/.test(n))return n;if(n==="/")return"\\/";if(["\\\\","\\{","\\}","\\%"].includes(n))return n.substring(1);if(["\\$","\\#","\\&","\\_"].includes(n))return n;if(n.startsWith("\\")){let e=n.slice(1);return x.has(e)?x.get(e):null}return n}function W(n,e){let r;switch(n.type){case 0:return i.NONE;case 2:r=1;break;case 1:r=2;break;case 3:r=3;break;case 4:r=5;break;case 5:r=6;break;case 6:r=8;break;case 7:{if(n.value==="\\\\")return new i(7,"\\");if(n.value==="\\!")return new i(1,"#h(-math.thin.amount)");if(x.has(n.value.substring(1))){let s=x.get(n.value.substring(1));return new i(1,s)}else throw new Error(`Unknown control sequence: ${n.value}`)}default:throw Error(`Unknown token type: ${n.type}`)}let t=Et(n.value);if(t===null){if(e.nonStrict)return new i(r,n.value.substring(1));throw new U(`Unknown token: ${n.value}`,n)}return new i(r,t)}function xt(n,e){let[r,t]=n.args;if(e.optimize&&["\\overset{\\text{def}}{=}","\\overset{d e f}{=}"].includes(n.toString()))return new i(1,"eq.def").toNode();let s=new f(new i(1,"limits"),[m(t,e)]);return new A({base:s,sup:m(r,e),sub:null})}function Nt(n,e){let[r,t]=n.args,s=new f(new i(1,"limits"),[m(t,e)]);return new A({base:s,sub:m(r,e),sup:null})}function qt(n){let e={},r={l:"#left",c:"#center",r:"#right"},t=Array.from(n),s=[],o=0;for(let u of t)u==="|"?s.push(o):(u==="l"||u==="c"||u==="r")&&o++;if(s.length>0){let u;s.length===1?u=`#${s[0]}`:u=`#(vline: (${s.join(", ")}))`,e.augment=new i(3,u).toNode()}let a=t.map(u=>r[u]).filter(u=>u!==void 0).map(u=>new i(3,u).toNode());if(a.length>0){let u=a.every(p=>p.eq(a[0]));e.align=u?a[0]:new i(3,"#center").toNode()}return e}var vt=new i(2,"("),Lt=new i(2,")");function $e(n){return n.head.type===2&&["(",")","[","]","{","}","|","\u230A","\u230B","\u2308","\u2309"].includes(n.head.value)}function ce(n){let e=["group","supsub","matrixLike","fraction","empty"].includes(n.type);if(n.type==="group"){let r=n;if(r.items.length===0)e=!0;else{let t=r.items[0],s=r.items[r.items.length-1];$e(t)&&$e(s)&&(e=!1)}}return e?new q(null,{left:vt,right:Lt,body:n}):n}function m(n,e={}){switch(n.type){case"terminal":return W(n.head,e).toNode();case"text":{let t=n;return/[^\x00-\x7F]+/.test(t.head.value)&&e.nonAsciiWrapper!==""?new f(new i(1,e.nonAsciiWrapper),[new i(4,t.head.value).toNode()]):new i(4,t.head.value).toNode()}case"ordgroup":let r=n;return new _(r.items.map(t=>m(t,e)));case"supsub":{let t=n,{base:s,sup:o,sub:a}=t;if(s&&s.type==="funcCall"&&s.head.value==="\\overbrace"&&o)return new f(new i(1,"overbrace"),[m(s.args[0],e),m(o,e)]);if(s&&s.type==="funcCall"&&s.head.value==="\\underbrace"&&a)return new f(new i(1,"underbrace"),[m(s.args[0],e),m(a,e)]);let u={base:m(s,e),sup:o?m(o,e):null,sub:a?m(a,e):null};return u.base=ce(u.base),u.sup&&(u.sup=ce(u.sup)),u.sub&&(u.sub=ce(u.sub)),new A(u)}case"leftright":{let t=n,{left:s,right:o}=t,a=m(t.body,e);if(e.optimize&&s!==null&&o!==null){let h=W(s,e),d=W(o,e);if(s.value==="\\|"&&o.value==="\\|")return new f(new i(1,"norm"),[a]);if(["[]","()","\\{\\}","\\lfloor\\rfloor","\\lceil\\rceil","\\lfloor\\rceil"].includes(s.value+o.value))return new _([h.toNode(),a,d.toNode()])}let u=function(h){return["(",")","{","["].includes(h.value)?new i(2,"\\"+h.value):h},p=s?W(s,e):null,c=o?W(o,e):null;return p===null&&c!==null&&(c=u(c)),c===null&&p!==null&&(p=u(p)),new q(new i(1,"lr"),{body:a,left:p,right:c})}case"funcCall":{let t=n,s=m(t.args[0],e);if(t.head.value==="\\sqrt"&&t.data){let o=m(t.data,e);return new f(new i(1,"root"),[o,s])}if(t.head.value==="\\mathbf"){let o=new f(new i(1,"bold"),[s]);return new f(new i(1,"upright"),[o])}if(t.head.value==="\\overrightarrow")return new f(new i(1,"arrow"),[s]);if(t.head.value==="\\overleftarrow")return new f(new i(1,"accent"),[s,new i(1,"arrow.l").toNode()]);if(t.head.value==="\\operatorname")return e.optimize&&yt.includes(s.head.value)?new i(1,s.head.value).toNode():new f(new i(1,"op"),[new i(4,s.head.value).toNode()]);if(t.head.value==="\\textcolor"){let o=new z(new i(1,"#text"),[m(t.args[1],e)]);return o.setOptions({fill:s}),o}if(t.head.value==="\\substack")return s;if(t.head.value==="\\set")return new q(null,{body:s,left:i.LEFT_BRACE,right:i.RIGHT_BRACE});if(t.head.value==="\\overset")return xt(t,e);if(t.head.value==="\\underset")return Nt(t,e);if(t.head.value==="\\frac"&&e.fracToSlash)return new D(t.args.map(o=>m(o,e)).map(ce));if(e.optimize){if(t.head.value==="\\mathbb"&&/^\\mathbb{[A-Z]}$/.test(t.toString()))return new i(1,s.head.value.repeat(2)).toNode();if(t.head.value==="\\mathrm"&&t.toString()==="\\mathrm{d}")return new i(1,"dif").toNode()}return new f(W(t.head,e),t.args.map(o=>m(o,e)))}case"beginend":{let t=n,s=t.matrix.map(o=>o.map(a=>m(a,e)));if(t.head.value.startsWith("align"))return new y(null,s);if(t.head.value==="cases")return new y(y.CASES,s);if(t.head.value==="subarray"){if(t.data)switch(t.data.head.value){case"r":s.forEach(a=>a.push(i.EMPTY.toNode()));break;case"l":s.forEach(a=>a.unshift(i.EMPTY.toNode()));break;default:break}return new y(null,s)}if(t.head.value==="array"){let o={delim:ft};T(t.data!==null&&t.head.type===3);let a=qt(t.data.head.value);Object.assign(o,a);let u=new y(y.MAT,s);return u.setOptions(o),u}if(t.head.value.endsWith("matrix")){let o=new y(y.MAT,s),a;switch(t.head.value){case"matrix":a=i.NONE;break;case"pmatrix":return o;case"bmatrix":a=new i(4,"[");break;case"Bmatrix":a=new i(4,"{");break;case"vmatrix":a=new i(4,"|");break;case"Vmatrix":{a=new i(1,"bar.v.double");break}default:throw new U(`Unimplemented beginend: ${t.head}`,t)}return o.setOptions({delim:a.toNode()}),o}throw new U(`Unimplemented beginend: ${t.head}`,t)}default:throw new U(`Unimplemented node type: ${n.type}`,n)}}function P(n){switch(n.type){case 0:return l.EMPTY;case 1:{let e=function(r){return Y.has(r)?"\\"+Y.get(r):"\\"+r};return new l(2,e(n.value))}case 2:{let e;return["{","}","%"].includes(n.value)?e="\\"+n.value:e=n.value,new l(1,e)}case 3:return new l(3,n.value);case 4:return new l(3,n.value);case 5:return new l(4,n.value);case 6:return new l(5,n.value);case 7:{let e;switch(n.value){case"\\":e="\\\\";break;case"&":e="&";break;default:throw new Error(`[typst_token_to_tex]Unimplemented control sequence: ${n.value}`)}return new l(7,e)}case 8:return new l(6,n.value);default:throw new Error(`Unimplemented token type: ${n.type}`)}}var kt=new l(1,",").toNode();function b(n){switch(n.type){case"terminal":{let e=n;if(e.head.type===1){if(e.head.value==="eq.def")return new g(new l(2,"\\overset"),[new S(new l(3,"def")),new l(1,"=").toNode()]);if(e.head.value==="comma")return new l(1,",").toNode();if(e.head.value==="dif")return new g(new l(2,"\\mathrm"),[new l(1,"d").toNode()]);if(e.head.value==="hyph"||e.head.value==="hyph.minus")return new S(new l(3,"-"));if(/^([A-Z])\1$/.test(e.head.value))return new g(new l(2,"\\mathbb"),[new l(1,e.head.value[0]).toNode()])}return e.head.type===4?new S(new l(3,e.head.value)):P(e.head).toNode()}case"group":{let r=n.items.map(b),t=new l(7,"&").toNode(),s=new l(7,"\\\\").toNode();if(re(r,t)){let o=me(r,s),a=[];for(let u of o){let p=me(u,t);a.push(p.map(c=>new E(c)))}return new M(new l(3,"aligned"),a)}return new E(r)}case"leftright":{let e=n,r=b(e.body),t=e.left?P(e.left):new l(1,"."),s=e.right?P(e.right):new l(1,".");return e.isOverHigh()&&(t.value="\\left"+t.value,s.value="\\right"+s.value),new E([t.toNode(),r,s.toNode()])}case"funcCall":{let e=n;switch(e.head.value){case"norm":{let r=e.args[0],t=b(r);return e.isOverHigh()?new I({body:t,left:new l(2,"\\|"),right:new l(2,"\\|")}):t}case"floor":case"ceil":{let r="\\l"+e.head.value,t="\\r"+e.head.value,s=e.args[0],o=b(s),a=new l(2,r),u=new l(2,t);return e.isOverHigh()?new I({body:o,left:a,right:u}):new E([a.toNode(),o,u.toNode()])}case"root":{let[r,t]=e.args,s=b(r);return new g(new l(2,"\\sqrt"),[b(t)],s)}case"overbrace":case"underbrace":{let[r,t]=e.args,s=new g(P(e.head),[b(r)]),o=b(t),a=e.head.value==="overbrace"?{base:s,sup:o,sub:null}:{base:s,sub:o,sup:null};return new R(a)}case"vec":{let r=e.args.map(b).map(t=>[t]);return new M(new l(3,"pmatrix"),r)}case"op":{let r=e.args[0];return T(r.head.type===4),new g(P(e.head),[new l(3,r.head.value).toNode()])}default:{let r=P(e.head),t=H.includes(r.value.substring(1))||X.includes(r.value.substring(1));return r.value.length>0&&t?new g(r,e.args.map(b)):new E([P(e.head).toNode(),new l(1,"(").toNode(),...Ie(e.args.map(b),kt),new l(1,")").toNode()])}}}case"markupFunc":{let e=n;switch(e.head.value){case"#text":if(e.options&&e.options.fill){let r=e.options.fill;return new g(new l(2,"\\textcolor"),[b(r),b(e.fragments[0])])}case"#heading":default:throw new Error(`Unimplemented markup function: ${e.head.value}`)}}case"supsub":{let e=n,{base:r,sup:t,sub:s}=e,o=t?b(t):null,a=s?b(s):null;if(r.head.eq(new i(1,"limits"))){let h=b(r.args[0]);if(o!==null&&a===null)return new g(new l(2,"\\overset"),[o,h]);if(o===null&&a!==null)return new g(new l(2,"\\underset"),[a,h]);{let d=new g(new l(2,"\\underset"),[a,h]);return new g(new l(2,"\\overset"),[o,d])}}let u=b(r);return new R({base:u,sup:o,sub:a})}case"matrixLike":{let e=n,r=e.matrix.map(t=>t.map(b));if(e.head.eq(y.MAT)){let t="pmatrix";if(e.options&&"delim"in e.options){let s=e.options.delim;switch(s.head.value){case"#none":t="matrix";break;case"[":case"]":t="bmatrix";break;case"(":case")":t="pmatrix";break;case"{":case"}":t="Bmatrix";break;case"|":t="vmatrix";break;case"bar":case"bar.v":t="vmatrix";break;case"bar.v.double":t="Vmatrix";break;default:throw new Error(`Unexpected delimiter ${s.head}`)}}return new M(new l(3,t),r)}else{if(e.head.eq(y.CASES))return new M(new l(3,"cases"),r);throw new Error(`Unexpected matrix type ${e.head}`)}}case"fraction":{let e=n,[r,t]=e.args,s=b(r),o=b(t);return new g(new l(2,"\\frac"),[s,o])}default:throw new Error("[convert_typst_node_to_tex] Unimplemented type: "+n.type)}}var Mt=Array.from(ie.keys());function _t(){return`(${Mt.map(e=>(e=e.replaceAll("|","\\|"),e=e.replaceAll(".","\\."),e=e.replaceAll("[","\\["),e=e.replaceAll("]","\\]"),e)).join("|")})`}var Ot=_t(),St=new Map([[String.raw`//[^\n]*`,n=>new i(5,n.text().substring(2))],[String.raw`/`,n=>new i(2,n.text())],[String.raw`[_^&]`,n=>new i(7,n.text())],[String.raw`\r?\n`,n=>new i(8,`
11
- `)],[String.raw`\s+`,n=>new i(6,n.text())],[String.raw`\\[$&#_]`,n=>new i(2,n.text())],[String.raw`\\\n`,n=>[new i(7,"\\"),new i(8,`
12
- `)]],[String.raw`\\\s`,n=>[new i(7,"\\"),new i(6," ")]],[String.raw`\\\S`,n=>new i(7,"")],[String.raw`"([^"]|(\\"))*"`,n=>{let e=n.text().substring(1,n.text().length-1);return e.replaceAll('\\"','"'),new i(4,e)}],[Ot,n=>{let e=n.text(),r=ie.get(e);return new i(1,r)}],[String.raw`[0-9]+(\.[0-9]+)?`,n=>new i(2,n.text())],[String.raw`[+\-*/=\'<>!.,;?()\[\]|]`,n=>new i(2,n.text())],[String.raw`#h\((.+?)\)`,n=>{let e=n.reMatchArray();return[new i(1,"#h"),new i(2,"("),new i(3,e[1]),new i(2,")")]}],[String.raw`#none`,n=>new i(0,n.text())],[String.raw`#?[a-zA-Z\.]+`,n=>new i(n.text().length===1?2:1,n.text())],[String.raw`.`,n=>new i(2,n.text())]]),At={start:St};function Fe(n){return new B(At).collect(n)}function Ge(n,e){let r=e;for(;r<n.length&&n[r].eq(new i(2,"'"));)r+=1;return r-e}function Ae(n,e,r,t){T(n[e].isOneOf(r));let s=1,o=e+1;for(;s>0;){if(o>=n.length)throw new Error("Unmatched brackets or parentheses");n[o].isOneOf(t)?s-=1:n[o].isOneOf(r)&&(s+=1),o+=1}return o-1}function Q(n,e){return Ae(n,e,[$,Ve,Dt],[Oe,Ze,zt])}function Ct(n,e){return Ae(n,e,i.LEFT_DELIMITERS,i.RIGHT_DELIMITERS)}function Rt(n,e){let r=new i(2,"(").toNode(),t=new i(2,")").toNode();T(n[e].eq(r));let s=1,o=e+1;for(;s>0;){if(o>=n.length)throw new Error("Unmatched '('");n[o].eq(r)?s+=1:n[o].eq(t)&&(s-=1),o+=1}return o-1}function He(n){let e=[];for(let r=0;r<n;r++)e.push(new i(2,"'").toNode());return e}var de=new i(2,"/").toNode();function It(n,e){let r=e;for(;r<n.length&&(n[r].head.type===6||n[r].head.type===8);)r++;return r===n.length?null:n[r]}function Pt(n){let e=!1,r=[];for(let t=0;t<n.length;t++){let s=n[t];(s.head.type===6||s.head.type===8)&&(e||It(n,t+1)?.eq(de))||(s.eq(de)?e=!0:e=!1,r.push(s))}return r}function he(n,e=!1){n=Pt(n);let r=$.toNode(),t=Oe.toNode(),s=[],o=[],a=0;for(;a<n.length;){let p=n[a];if(p.eq(t))throw new F("Unexpected ')'");if(p.eq(de))s.push(p),a++;else{let c;if(p.eq(r)){let h=Rt(n,a);c=he(n.slice(a+1,h),!0),a=h+1}else c=p,a++;if(s.length>0&&s[s.length-1].eq(de)){let h=c;if(o.length===0)throw new F("Unexpected '/' operator, no numerator before it");let d=o.pop();h.type==="leftright"&&(h=h.body),d.type==="leftright"&&(d=d.body),o.push(new D([d,h])),s.pop()}else o.push(c)}}let u=o.length===1?o[0]:new _(o);return e?new q(null,{body:u,left:$,right:Oe}):u}function Bt(n){let e=new i(2,":").toNode(),r={};for(let t of n)T(t.items.length==3),T(t.items[1].eq(e)),r[t.items[0].toString()]=new K(new i(3,t.items[2].toString()));return r}var F=class extends Error{constructor(e){super(e),this.name="TypstParserError"}},Xe=new i(7,"_"),je=new i(7,"^"),$=new i(2,"("),Oe=new i(2,")"),Ve=new i(2,"["),Ze=new i(2,"]"),Dt=new i(2,"{"),zt=new i(2,"}"),_e=new i(2,","),Yt=new i(2,";"),Wt=new i(6," "),Ut=new i(7,"&"),Se=class{space_sensitive;newline_sensitive;constructor(e=!0,r=!0){this.space_sensitive=e,this.newline_sensitive=r}parse(e){let[r,t]=this.parseGroup(e,0,e.length);return r}parseGroup(e,r,t,s=!1){let o=[],a=r;for(;a<t;){let[p,c]=this.parseNextExpr(e,a);a=c,!((p.head.type===6||p.head.type===8)&&(!this.space_sensitive&&p.head.value.replace(/ /g,"").length===0||!this.newline_sensitive&&p.head.value===`
13
- `))&&o.push(p)}let u;return s?u=he(o,!0):o.length===1?u=o[0]:u=he(o),[u,t+1]}parseNextExpr(e,r){let[t,s]=this.parseNextExprWithoutSupSub(e,r),o=null,a=null,u=Ge(e,s);if(u>0&&(t=new _([t].concat(He(u))),s+=u),s<e.length&&e[s].eq(Xe)?([o,s]=this.parseSupOrSub(e,s+1),s<e.length&&e[s].eq(je)&&([a,s]=this.parseSupOrSub(e,s+1))):s<e.length&&e[s].eq(je)&&([a,s]=this.parseSupOrSub(e,s+1),s<e.length&&e[s].eq(Xe)&&([o,s]=this.parseSupOrSub(e,s+1))),o!==null||a!==null){let p={base:t,sup:a,sub:o};return[new A(p),s]}else return[t,s]}parseSupOrSub(e,r){let t,s;if(e[r].eq($)){let a=Q(e,r);[t,s]=this.parseGroup(e,r+1,a)}else[t,s]=this.parseNextExprWithoutSupSub(e,r);let o=Ge(e,s);return o>0&&(t=new _([t].concat(He(o))),s+=o),[t,s]}parseNextExprWithoutSupSub(e,r){let t=e[r],s=t.toNode();if(t.eq($)){let o=Q(e,r);return this.parseGroup(e,r+1,o,!0)}if(t.type===2&&!Re(t.value[0]))return[s,r+1];if([2,1].includes(t.type)&&r+1<e.length&&e[r+1].eq($)){if(t.value==="mat"){let[p,c,h]=this.parseMatrix(e,r+1,Yt,_e),d=new y(t,p);return d.setOptions(c),[d,h]}if(t.value==="cases"){let[p,c,h]=this.parseMatrix(e,r+1,_e,Ut),d=new y(t,p);return d.setOptions(c),[d,h]}if(t.value==="lr")return this.parseLrArguments(e,r+1);if(["#heading","#text"].includes(t.value)){let[p,c]=this.parseArguments(e,r+1),h=Bt(p);T(e[c].eq(Ve));let d=new i(2,"$"),v=Ae(e,c+1,[d],[d]),[C,O]=this.parseGroup(e,c+2,v);T(e[v+1].eq(Ze));let J=new z(t,[C]);return J.setOptions(h),[J,v+2]}let[o,a]=this.parseArguments(e,r+1);return[new f(t,o),a]}return[s,r+1]}parseArguments(e,r){let t=Q(e,r);return[this.parseArgumentsWithSeparator(e,r+1,t,_e),t+1]}parseLrArguments(e,r){let t=e[r],s=Q(e,r);if(e[r+1].isOneOf(i.LEFT_DELIMITERS)){let o=r+1,a=Ct(e,o),[u,p]=this.parseGroup(e,o+1,a);return[new q(t,{body:u,left:e[o],right:e[a]}),s+1]}else{let[o,a]=this.parseGroup(e,r+1,s-1);return[new q(t,{body:o,left:null,right:null}),s+1]}}parseMatrix(e,r,t,s){let o=Q(e,r);e=e.slice(0,o);let a=[],u={},p=r+1;for(;p<o;)for(;p<o;){let C=function(O){let J=new i(2,":").toNode(),Ce={},ge=[];for(let L=0;L<O.length;L++){if(O[L].type!=="group")continue;let ee=O[L],te=G(ee.items,J);if(te===-1||te===0)continue;if(ge.push(L),ee.items[te-1].eq(new i(1,"delim").toNode())){if(ee.items.length!==3)throw new F("Invalid number of arguments for delim");Ce.delim=ee.items[te+1]}else throw new F("Not implemented for other named parameters")}for(let L=ge.length-1;L>=0;L--)O.splice(ge[L],1);return[O,Ce]};var c=C;let h=G(e,t,p);h===-1&&(h=o);let d=this.parseArgumentsWithSeparator(e,p,h,s),v={};[d,v]=C(d),a.push(d),Object.assign(u,v),p=h+1}return[a,u,o+1]}parseArgumentsWithSeparator(e,r,t,s){let o=[],a=r;for(;a<t;){let u=[];for(;a<t;){if(e[a].eq(s)){a+=1;break}else if(e[a].eq(Wt)){a+=1;continue}let[c,h]=this.parseNextExpr(e,a);a=h,u.push(c)}let p;u.length===1?p=u[0]:p=he(u),o.push(p)}return o}};function Ke(n){let e=new Se,r=Fe(n);return e.parse(r)}var Te=class{buffer="";queue=[];append(e){this.queue=this.queue.concat(e.serialize())}flushQueue(){for(let e=0;e<this.queue.length;e++)this.buffer=be(this.buffer,this.queue[e]);this.queue=[]}finalize(){return this.flushQueue(),this.buffer}};function Qe(n,e){let r={nonStrict:!0,preferShorthands:!0,keepSpaces:!1,fracToSlash:!0,inftyToOo:!1,optimize:!0,nonAsciiWrapper:"",customTexMacros:{}};if(e!==void 0){if(typeof e!="object")throw new Error("options must be an object");for(let a in r)a in e&&(r[a]=e[a])}let t=We(n,r.customTexMacros),s=m(t,r),o=new pe(r);return o.serialize(s),o.finalize()}function Je(n){let e=Ke(n),r=b(e),t=new Te;return t.append(r),t.finalize()}window.tex2typst=Qe;window.typst2tex=Je;})();
1
+ "use strict";(()=>{function Se(n){return"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".includes(n)}function T(n,e="Assertion failed."){if(!n)throw new Error(e)}var l=class n{type;value;constructor(e,r){this.type=e,this.value=r}eq(e){return this.type===e.type&&this.value===e.value}toString(){switch(this.type){case 4:return"%"+this.value;default:return this.value}}toNode(){return new ge(this)}static EMPTY=new n(0,"")},M=class{type;head;constructor(e,r){this.type=e,this.head=r||l.EMPTY}eq(e){return this.type===e.type&&this.head.eq(e.head)}toString(){return this.serialize().reduce(we,"")}},ge=class extends M{constructor(e){super("terminal",e)}serialize(){switch(this.head.type){case 0:return[];case 1:case 2:case 3:case 4:case 7:return[this.head];case 5:case 6:{let e=[];for(let r of this.head.value){let t=r===" "?5:6;e.push(new l(t,r))}return e}default:throw new Error(`Unknown terminal token type: ${this.head.type}`)}}},O=class extends M{constructor(e){T(e.type===3),super("text",e)}serialize(){return[new l(2,"\\text"),new l(1,"{"),this.head,new l(1,"}")]}},y=class extends M{items;constructor(e){super("ordgroup",l.EMPTY),this.items=e}serialize(){return this.items.map(e=>e.serialize()).flat()}},A=class extends M{base;sup;sub;constructor(e){super("supsub",l.EMPTY),this.base=e.base,this.sup=e.sup,this.sub=e.sub}serialize(){let e=[],{base:r,sup:t,sub:s}=this;e=e.concat(r.serialize());function o(i){return i.type==="ordgroup"||i.type==="supsub"||i.head.type===0?!0:!!(i.head.type===1&&/\d+(\.\d+)?/.test(i.head.value)&&i.head.value.length>1)}return s&&(e.push(new l(7,"_")),o(s)?(e.push(new l(1,"{")),e=e.concat(s.serialize()),e.push(new l(1,"}"))):e=e.concat(s.serialize())),t&&(e.push(new l(7,"^")),o(t)?(e.push(new l(1,"{")),e=e.concat(t.serialize()),e.push(new l(1,"}"))):e=e.concat(t.serialize())),e}},w=class extends M{args;data;constructor(e,r,t=null){super("funcCall",e),this.args=r,this.data=t}serialize(){let e=[];e.push(this.head),this.head.value==="\\sqrt"&&this.data&&(e.push(new l(1,"[")),e=e.concat(this.data.serialize()),e.push(new l(1,"]")));for(let r of this.args)e.push(new l(1,"{")),e=e.concat(r.serialize()),e.push(new l(1,"}"));return e}},C=class extends M{body;left;right;constructor(e){super("leftright",l.EMPTY),this.body=e.body,this.left=e.left,this.right=e.right}serialize(){let e=[];return e.push(new l(2,"\\left")),e.push(new l(1,this.left?this.left.value:".")),e=e.concat(this.body.serialize()),e.push(new l(2,"\\right")),e.push(new l(1,this.right?this.right.value:".")),e}},L=class extends M{matrix;data;constructor(e,r,t=null){T(e.type===3),super("beginend",e),this.matrix=r,this.data=t}serialize(){let e=[],r=this.matrix;e.push(new l(2,"\\begin")),e.push(new l(1,"{")),e=e.concat(this.head),e.push(new l(1,"}")),e.push(new l(6,`
2
+ `));for(let t=0;t<r.length;t++){let s=r[t];for(let o=0;o<s.length;o++){let i=s[o];e=e.concat(i.serialize()),o!==s.length-1&&e.push(new l(7,"&"))}t!==r.length-1&&e.push(new l(7,"\\\\"))}return e.push(new l(6,`
3
+ `)),e.push(new l(2,"\\end")),e.push(new l(1,"{")),e=e.concat(this.head),e.push(new l(1,"}")),e}};function we(n,e){let r=e.toString(),t=!1;return e.type===5?t=!0:(t||=/[{\(\[\|]$/.test(n),t||=/\\\w+$/.test(n)&&r==="[",t||=/^[\.,;:!\?\(\)\]{}_^]$/.test(r),t||=["\\{","\\}"].includes(r),t||=r==="'",t||=n.endsWith("_")||n.endsWith("^"),t||=/\s$/.test(n),t||=/^\s/.test(r),t||=n==="",t||=/[\(\[{]\s*(-|\+)$/.test(n)||n==="-"||n==="+",t||=n.endsWith("&")&&r==="=",t||=/\d$/.test(n)&&/^[a-zA-Z]$/.test(r)),t||(n+=" "),n+r}function F(n,e,r=0){let t=n.slice(r).findIndex(s=>s.eq(e));return t===-1?-1:t+r}function ne(n,e){return n.some(r=>r.eq(e))}function be(n,e){let r=[],t=[];for(let s of n)s.eq(e)?(r.push(t),t=[]):t.push(s);return r.push(t),r}function Ae(n,e){return n.flatMap((r,t)=>t!==n.length-1?[...r,e]:r)}function Ce(n,e){return n.flatMap((r,t)=>t!==n.length-1?[r,e]:[r])}var Re={};function tt(n,e){let r=n.reMatchArray[0].length,t=e.reMatchArray[0].length;return t!==r?t-r:n.index-e.index}var me=class{_input;_lexer;_pos=0;_line=0;_col=0;_offset=0;_less=null;_go=!1;_newstate=null;_state;_text=null;_leng=null;_reMatchArray=null;constructor(e,r){this._input=e,this._lexer=r,this._state=r.states[0]}text(){return this._text}leng(){return this._leng}reMatchArray(){return this._reMatchArray}pos(){return this._pos}line(){return this._line}column(){return this._col}input(){return this._input.charAt(this._pos+this._leng+this._offset++)}unput(){return this._offset=this._offset>0?this._offset--:0}less(e){return this._less=e,this._offset=0,this._text=this._text.substring(0,e),this._leng=this._text.length}pushback(e){return this.less(this._leng-e)}reject(){this._go=!0}begin(e){if(this._lexer.specification[e])return this._newstate=e;let r=this._lexer.states[parseInt(e)];if(r)return this._newstate=r;throw"Unknown state '"+e+"' requested"}state(){return this._state}scan(){if(this._pos>=this._input.length)return Re;let e=this._input.substring(this._pos),r=this._lexer.specification[this._state],t=[];for(let c=0;c<r.length;c++){let h=r[c],d=e.match(h.re);d!==null&&d[0].length>0&&t.push({index:c,rule:h,reMatchArray:d})}if(t.length===0)throw new Error("No match found for input '"+e+"'");t.sort(tt),this._go=!0;let s,o;for(let c=0,h=t.length;c<h&&this._go;c++){this._offset=0,this._less=null,this._go=!1,this._newstate=null;let d=t[c];if(o=d.reMatchArray[0],this._text=o,this._leng=o.length,this._reMatchArray=d.reMatchArray,s=d.rule.action(this),this._newstate&&this._newstate!=this._state){this._state=this._newstate;break}}let i=this._less===null?o:o.substring(0,this._less),u=i.length;this._pos+=u+this._offset;let p=i.match(/\n/g);return p!==null?(this._line+=p.length,this._col=u-i.lastIndexOf(`
4
+ `)-1):this._col+=u,s}},D=class{states;specification;constructor(e){this.states=Object.keys(e),this.specification={};for(let r of this.states){let t=e[r];if(r in this.specification)throw"Duplicate state declaration encountered for state '"+r+"'";this.specification[r]=[];for(let[s,o]of t.entries()){let i;try{i=new RegExp("^"+s)}catch(u){throw"Invalid regexp '"+s+"' in state '"+r+"' ("+u.message+")"}this.specification[r].push({re:i,action:o})}}}scanner(e){return new me(e,this)}lex(e,r){let t=this.scanner(e);for(;;){let s=t.scan();if(s===Re)return;s!==void 0&&r(s)}}collect(e){let r=[],t=function(s){Array.isArray(s)?r.push(...s):r.push(s)};return this.lex(e,t),r}};var $=["sqrt","text","bar","bold","boldsymbol","ddot","dot","hat","mathbb","mathbf","mathcal","mathfrak","mathit","mathrm","mathscr","mathsf","mathtt","operatorname","overbrace","overline","pmb","rm","tilde","underbrace","underline","vec","widehat","widetilde","overleftarrow","overrightarrow","hspace","substack","set","displaylines","mathinner","mathrel","mathbin","mathop"],G=["frac","tfrac","binom","dbinom","dfrac","tbinom","overset","underset","textcolor"];function rt(n){let e=["{","}","\\","$","&","#","_","%"];for(let r of e)n=n.replaceAll("\\"+r,r);return n}var nt=new Map([[String.raw`\\begin{(array|subarry)}{(.+?)}`,n=>{let e=n.reMatchArray();return[new l(2,"\\begin"),new l(7,"{"),new l(3,e[1]),new l(7,"}"),new l(7,"{"),new l(3,e[2]),new l(7,"}")]}],[String.raw`\\(text|operatorname|textcolor|begin|end|hspace|array){(.+?)}`,n=>{let e=n.reMatchArray();return[new l(2,"\\"+e[1]),new l(7,"{"),new l(3,rt(e[2])),new l(7,"}")]}],[String.raw`%[^\n]*`,n=>new l(4,n.text().substring(1))],[String.raw`[{}_^&]`,n=>new l(7,n.text())],[String.raw`\\[\\,:;! ]`,n=>new l(7,n.text())],[String.raw`\r?\n`,n=>new l(6,`
5
+ `)],[String.raw`\s+`,n=>new l(5,n.text())],[String.raw`\\[{}%$&#_|]`,n=>new l(1,n.text())],[String.raw`(\\[a-zA-Z]+)(\s*\d|\s+[a-zA-Z])\s*([0-9a-zA-Z])`,n=>{let e=n.reMatchArray(),r=e[1];if(G.includes(r.substring(1))){let t=e[2].trimStart(),s=e[3];return[new l(2,r),new l(1,t),new l(1,s)]}else return n.reject(),[]}],[String.raw`(\\[a-zA-Z]+)(\s*\d|\s+[a-zA-Z])`,n=>{let e=n.reMatchArray(),r=e[1];if($.includes(r.substring(1))){let t=e[2].trimStart();return[new l(2,r),new l(1,t)]}else return n.reject(),[]}],[String.raw`\\[a-zA-Z]+`,n=>new l(2,n.text())],[String.raw`[0-9]+(\.[0-9]+)?`,n=>new l(1,n.text())],[String.raw`[a-zA-Z]`,n=>new l(1,n.text())],[String.raw`[+\-*/='<>!.,;:?()\[\]|]`,n=>new l(1,n.text())],[String.raw`[^\x00-\x7F]`,n=>new l(1,n.text())],[String.raw`.`,n=>new l(8,n.text())]]),st={start:nt};function fe(n){return new D(st).collect(n)}var ot=["bigl","bigr","bigm","biggl","biggr","biggm","Bigl","Bigr","Bigm","Biggl","Biggr","Biggm"],De=l.EMPTY.toNode();function at(n){return $.includes(n)?1:G.includes(n)?2:0}var se=new l(7,"{"),X=new l(7,"}"),it=new l(1,"["),lt=new l(1,"]");function oe(n,e){let r=e;for(;r<n.length&&[5,6].includes(n[r].type);)r++;return n.slice(e,r)}function Be(n,e){let r=n[e];return r.type===1&&["(",")","[","]","|","\\{","\\}",".","\\|"].includes(r.value)||r.type===2&&["lfloor","rfloor","lceil","rceil","langle","rangle","lparen","rparen","lbrace","rbrace"].includes(r.value.slice(1))?r:null}function j(n,e){let r=e;for(;r<n.length&&n[r].eq(new l(1,"'"));)r+=1;return r-e}var Pe=new l(2,"\\left"),ze=new l(2,"\\right"),Ye=new l(2,"\\begin"),We=new l(2,"\\end"),ut=new l(7,"\\\\"),g=class n extends Error{constructor(e){super(e),this.name="LatexParserError"}static UNMATCHED_LEFT_BRACE=new n("Unmatched '\\{'");static UNMATCHED_RIGHT_BRACE=new n("Unmatched '\\}'");static UNMATCHED_LEFT_BRACKET=new n("Unmatched '\\['");static UNMATCHED_RIGHT_BRACKET=new n("Unmatched '\\]'");static UNMATCHED_COMMAND_BEGIN=new n("Unmatched '\\begin'");static UNMATCHED_COMMAND_END=new n("Unmatched '\\end'");static UNMATCHED_COMMAND_LEFT=new n("Unmatched '\\left'");static UNMATCHED_COMMAND_RIGHT=new n("Unmatched '\\right'")},ye=new l(7,"_"),Ee=new l(7,"^"),Ne=class{space_sensitive;newline_sensitive;alignmentDepth=0;constructor(e=!1,r=!0){this.space_sensitive=e,this.newline_sensitive=r}parse(e){let r=new l(2,"\\displaystyle"),t=F(e,r);if(t===-1)return this.parseGroup(e.slice(0));if(t===0){let s=this.parseGroup(e.slice(1));return new w(r,[s])}else{let s=this.parseGroup(e.slice(0,t)),o=this.parseGroup(e.slice(t+1,e.length)),i=new w(r,[o]);return new y([s,i])}}parseGroup(e){let[r,t]=this.parseClosure(e,0,null);return r}parseClosure(e,r,t){let s=[],o=r;for(;o<e.length&&!(t!==null&&e[o].eq(t));){let[u,p]=this.parseNextExpr(e,o);o=p,!((u.head.type===5||u.head.type===6)&&(!this.space_sensitive&&u.head.value.replace(/ /g,"").length===0||!this.newline_sensitive&&u.head.value===`
6
+ `))&&s.push(u)}if(o>=e.length&&t!==null)return[De,-1];let i;return s.length===1?i=s[0]:i=new y(s),[i,o+1]}parseNextExpr(e,r){let[t,s]=this.parseNextExprWithoutSupSub(e,r),o=null,i=null,u=0;if(u+=j(e,s),s+=u,s<e.length){let p=e[s];if(p.eq(ye)){if([o,s]=this.parseNextExprWithoutSupSub(e,s+1),u+=j(e,s),s+=u,s<e.length&&e[s].eq(Ee)&&([i,s]=this.parseNextExprWithoutSupSub(e,s+1),j(e,s)>0))throw new g("Double superscript")}else if(p.eq(Ee)){if([i,s]=this.parseNextExprWithoutSupSub(e,s+1),j(e,s)>0)throw new g("Double superscript");if(s<e.length&&e[s].eq(ye)&&([o,s]=this.parseNextExprWithoutSupSub(e,s+1),j(e,s)>0))throw new g("Double superscript")}}if(o!==null||i!==null||u>0){let p={base:t,sup:null,sub:null};if(o&&(p.sub=o),u>0){let c=[];for(let h=0;h<u;h++)c.push(new l(1,"'").toNode());i&&c.push(i),p.sup=c.length===1?c[0]:new y(c)}else i&&(p.sup=i);return[new A(p),s]}else return[t,s]}parseNextExprWithoutSupSub(e,r){if(r>=e.length)throw new g("Unexpected end of input");let t=e[r];switch(t.type){case 1:case 3:case 4:case 5:case 6:return[t.toNode(),r+1];case 2:let s=t.value.slice(1);if(ot.includes(s))return this.parseNextExprWithoutSupSub(e,r+1);if(t.eq(Ye))return this.parseBeginEndExpr(e,r);if(t.eq(We))throw g.UNMATCHED_COMMAND_END;if(t.eq(Pe))return this.parseLeftRightExpr(e,r);if(t.eq(ze))throw g.UNMATCHED_COMMAND_RIGHT;return this.parseCommandExpr(e,r);case 7:switch(t.value){case"{":let[i,u]=this.parseClosure(e,r+1,X);if(u===-1)throw g.UNMATCHED_LEFT_BRACE;return[i,u];case"}":throw g.UNMATCHED_RIGHT_BRACE;case"\\\\":case"\\!":case"\\,":case"\\:":case"\\;":return[t.toNode(),r+1];case"\\ ":return[t.toNode(),r+1];case"_":case"^":return[De,r];case"&":if(this.alignmentDepth<=0)throw new g("Unexpected & outside of an alignment");return[t.toNode(),r+1];default:throw new g("Unknown control sequence")}default:throw new g("Unknown token type")}}parseCommandExpr(e,r){T(e[r].type===2);let t=e[r],s=t.value,o=r+1;switch(at(s.slice(1))){case 0:return[t.toNode(),o];case 1:{if(o>=e.length)throw new g("Expecting argument for "+s);if(s==="\\sqrt"&&o<e.length&&e[o].eq(it)){let[c,h]=this.parseClosure(e,o+1,lt);if(h===-1)throw g.UNMATCHED_LEFT_BRACKET;let[d,k]=this.parseNextArg(e,h);return[new w(t,[d],c),k]}else if(s==="\\text"){if(o+2>=e.length)throw new g("Expecting content for \\text command");T(e[o].eq(se)),T(e[o+1].type===3),T(e[o+2].eq(X));let c=e[o+1];return[new O(c),o+3]}else if(s==="\\displaylines"){T(e[o].eq(se));let[c,h]=this.parseAligned(e,o+1,X);if(h===-1)throw g.UNMATCHED_LEFT_BRACE;let d=new y(Ae(c,ut.toNode()));return[new w(t,[d]),h]}let[u,p]=this.parseNextArg(e,o);return[new w(t,[u]),p]}case 2:{let[u,p]=this.parseNextArg(e,o),[c,h]=this.parseNextArg(e,p);return[new w(t,[u,c]),h]}default:throw new Error("Invalid number of parameters")}}parseNextArg(e,r){let t=r,s=null;for(;t<e.length;){let o;if([o,t]=this.parseNextExprWithoutSupSub(e,t),!(o.head.type===5||o.head.type===6)){s=o;break}}if(s===null)throw new g("Expecting argument but token stream ended");return[s,t]}parseLeftRightExpr(e,r){T(e[r].eq(Pe));let t=r+1;if(t+=oe(e,t).length,t>=e.length)throw new g("Expecting a delimiter after \\left");let s=Be(e,t);if(s===null)throw new g("Invalid delimiter after \\left");t++;let[o,i]=this.parseClosure(e,t,ze);if(i===-1)throw g.UNMATCHED_COMMAND_LEFT;if(t=i,t+=oe(e,t).length,t>=e.length)throw new g("Expecting a delimiter after \\right");let u=Be(e,t);if(u===null)throw new g("Invalid delimiter after \\right");t++;let p=s.value==="."?null:s,c=u.value==="."?null:u;return[new C({body:o,left:p,right:c}),t]}parseBeginEndExpr(e,r){T(e[r].eq(Ye));let t=r+1;T(e[t].eq(se)),T(e[t+1].type===3),T(e[t+2].eq(X));let s=e[t+1].value;t+=3;let o=null;["array","subarray"].includes(s)&&(t+=oe(e,t).length,[o,t]=this.parseNextArg(e,t));let[i,u]=this.parseAligned(e,t,We);if(u===-1)throw g.UNMATCHED_COMMAND_BEGIN;if(t=u,T(e[t].eq(se)),T(e[t+1].type===3),T(e[t+2].eq(X)),e[t+1].value!==s)throw new g("\\begin and \\end environments mismatch");return t+=3,[new L(new l(3,s),i,o),t]}parseAligned(e,r,t){this.alignmentDepth++;let s=r;s+=oe(e,s).length;let o=[],i=[];o.push(i);let u=new y([]);for(i.push(u);s<e.length&&!e[s].eq(t);){let[p,c]=this.parseNextExpr(e,s);s=c,!((p.head.type===5||p.head.type===6)&&(!this.space_sensitive&&p.head.value.replace(/ /g,"").length===0||!this.newline_sensitive&&p.head.value===`
7
+ `))&&(p.head.eq(new l(7,"\\\\"))?(i=[],u=new y([]),i.push(u),o.push(i)):p.head.eq(new l(7,"&"))?(u=new y([]),i.push(u)):u.items.push(p))}if(s>=e.length)return[[],-1];if(o.length>0&&o[o.length-1].length>0){let p=o[o.length-1][o[o.length-1].length-1];if(p.type==="ordgroup"){let c=p.items;for(;c.length>0&&[5,6].includes(c[c.length-1].head.type);)c.pop()}}return this.alignmentDepth--,[o,s+1]}};function pt(n){let e=t=>t.eq(ye)||t.eq(Ee),r=[];for(let t=0;t<n.length;t++)n[t].type===5&&t+1<n.length&&e(n[t+1])||n[t].type===5&&t-1>=0&&e(n[t-1])||r.push(n[t]);return r}function ct(n,e){let r=[];for(let t of n)if(t.type===2&&e[t.value]){let s=fe(e[t.value]);r=r.concat(s)}else r.push(t);return r}function Ue(n,e={}){let r=new Ne,t=fe(n);return t=pt(t),t=ct(t,e),r.parse(t)}var K=new Map([["arrow.l.r.double.long","<==>"],["arrow.l.r.long","<-->"],["arrow.r.bar","|->"],["arrow.r.double.bar","|=>"],["arrow.r.double.long","==>"],["arrow.r.long","-->"],["arrow.r.long.squiggly","~~>"],["arrow.r.tail",">->"],["arrow.r.twohead","->>"],["arrow.l.double.long","<=="],["arrow.l.long","<--"],["arrow.l.long.squiggly","<~~"],["arrow.l.tail","<-<"],["arrow.l.twohead","<<-"],["arrow.l.r","<->"],["arrow.l.r.double","<=>"],["colon.double.eq","::="],["dots.h","..."],["gt.triple",">>>"],["lt.triple","<<<"],["arrow.r","->"],["arrow.r.double","=>"],["arrow.r.squiggly","~>"],["arrow.l","<-"],["arrow.l.squiggly","<~"],["bar.v.double","||"],["bracket.l.double","[|"],["bracket.r.double","|]"],["colon.eq",":="],["eq.colon","=:"],["eq.not","!="],["gt.double",">>"],["gt.eq",">="],["lt.double","<<"],["lt.eq","<="],["ast.op","*"],["minus","-"],["tilde.op","~"]]),ae=new Map;for(let[n,e]of K.entries())e.length>1&&ae.set(e,n);var a=class n{type;value;constructor(e,r){this.type=e,this.value=r}eq(e){return this.type===e.type&&this.value===e.value}isOneOf(e){return ne(e,this)}toNode(){return new Z(this)}toString(){switch(this.type){case 4:return`"${this.value}"`;case 5:return`//${this.value}`;default:return this.value}}static NONE=new n(0,"#none");static EMPTY=new n(2,"");static LEFT_BRACE=new n(2,"{");static RIGHT_BRACE=new n(2,"}");static LEFT_DELIMITERS=[new n(2,"("),new n(2,"["),new n(2,"{"),new n(2,"|"),new n(1,"angle.l")];static RIGHT_DELIMITERS=[new n(2,")"),new n(2,"]"),new n(2,"}"),new n(2,"|"),new n(1,"angle.r")]},xe=class extends Error{node;constructor(e,r){super(e),this.name="TypstWriterError",this.node=r}},V=new a(7," "),x=class{type;head;options;constructor(e,r){this.type=e,this.head=r||a.NONE}setOptions(e){this.options=e}eq(e){return this.type===e.type&&this.head.eq(e.head)}toString(){throw new Error("Unimplemented toString() in base class TypstNode")}},Z=class extends x{constructor(e){super("terminal",e)}isOverHigh(){return!1}toString(){return this.head.toString()}serialize(e,r){if(this.head.type===2){if(this.head.value===","&&e.insideFunctionDepth>0)return[new a(1,"comma")]}else if(this.head.type===1){let t=this.head.value;return r.preferShorthands&&K.has(t)&&(t=K.get(t)),r.inftyToOo&&t==="infinity"&&(t="oo"),[new a(1,t)]}else if(this.head.type===6||this.head.type===8){let t=[];for(let s of this.head.value)if(s===" ")r.keepSpaces&&t.push(new a(6,s));else if(s===`
8
+ `)t.push(new a(1,s));else throw new xe(`Unexpected whitespace character: ${s}`,this);return t}return[this.head]}},_=class extends x{items;constructor(e){super("group",a.NONE),this.items=e}isOverHigh(){return this.items.some(e=>e.isOverHigh())}serialize(e,r){let t=this.items.flatMap(s=>s.serialize(e,r));return t.length>0&&t[0].eq(V)&&t.shift(),t.length>0&&t[t.length-1].eq(V)&&t.pop(),t}},S=class extends x{base;sup;sub;constructor(e){super("supsub",a.NONE),this.base=e.base,this.sup=e.sup,this.sub=e.sub}isOverHigh(){return this.base.isOverHigh()}serialize(e,r){let t=[],{base:s,sup:o,sub:i}=this;t.push(...s.serialize(e,r));let u=o&&o.head.eq(new a(2,"'"));return u&&t.push(new a(2,"'")),i&&(t.push(new a(2,"_")),t.push(...i.serialize(e,r))),o&&!u&&(t.push(new a(2,"^")),t.push(...o.serialize(e,r))),t.push(V),t}},f=class extends x{args;constructor(e,r){super("funcCall",e),this.args=r}isOverHigh(){return this.head.value==="frac"?!0:this.args.some(e=>e.isOverHigh())}serialize(e,r){let t=[],s=this.head;t.push(s),e.insideFunctionDepth++,t.push(ie);for(let o=0;o<this.args.length;o++)t.push(...this.args[o].serialize(e,r)),o<this.args.length-1&&t.push(new a(2,","));if(this.options)for(let[o,i]of Object.entries(this.options))t.push(new a(3,`, ${o}: ${i.toString()}`));return t.push(le),e.insideFunctionDepth--,t}},B=class extends x{args;constructor(e){super("fraction",a.NONE),this.args=e}isOverHigh(){return!0}serialize(e,r){let t=[],[s,o]=this.args;return t.push(V),t.push(...s.serialize(e,r)),t.push(new a(2,"/")),t.push(...o.serialize(e,r)),t.push(V),t}},ie=new a(2,"("),le=new a(2,")"),q=class extends x{body;left;right;constructor(e,r){super("leftright",e),this.body=r.body,this.left=r.left,this.right=r.right}isOverHigh(){return this.body.isOverHigh()}serialize(e,r){let t=[],s=new a(1,"lr"),{left:o,right:i}=this;return this.head.eq(s)&&(t.push(s),t.push(ie)),o&&t.push(o),t.push(...this.body.serialize(e,r)),i&&t.push(i),this.head.eq(s)&&t.push(le),t}},E=class n extends x{matrix;constructor(e,r){super("matrixLike",e),this.matrix=r}isOverHigh(){return!0}serialize(e,r){let t=[],s,o;if(this.head.eq(n.MAT)?(s=new a(2,","),o=new a(2,";")):this.head.eq(n.CASES)?(s=new a(2,"&"),o=new a(2,",")):this.head.eq(a.NONE)&&(s=new a(2,"&"),o=new a(1,"\\")),!this.head.eq(a.NONE)&&(t.push(this.head),e.insideFunctionDepth++,t.push(ie),this.options))for(let[i,u]of Object.entries(this.options))t.push(new a(3,`${i}: ${u.toString()}, `));return this.matrix.forEach((i,u)=>{i.forEach((p,c)=>{t.push(...p.serialize(e,r)),c<i.length-1?t.push(s):u<this.matrix.length-1&&t.push(o)})}),this.head.eq(a.NONE)||(t.push(le),e.insideFunctionDepth--),t}static MAT=new a(1,"mat");static CASES=new a(1,"cases")},P=class extends x{fragments;constructor(e,r){super("markupFunc",e),this.fragments=r}isOverHigh(){return this.fragments.some(e=>e.isOverHigh())}serialize(e,r){let t=[];if(t.push(this.head),e.insideFunctionDepth++,t.push(ie),this.options){let s=Object.entries(this.options);for(let o=0;o<s.length;o++){let[i,u]=s[o];t.push(new a(3,`${i}: ${u.toString()}`)),o<s.length-1&&t.push(new a(2,","))}}t.push(le),t.push(new a(3,"["));for(let s of this.fragments)t.push(new a(3,"$")),t.push(...s.serialize(e,r)),t.push(new a(3,"$"));return t.push(new a(3,"]")),t}};var ht=new a(2,"("),dt=new a(2,")"),Tt=new a(2,","),He=new a(1,`
9
+ `),qe=new a(7," ");var ue=class{buffer="";queue=[];options;constructor(e){this.options=e}writeBuffer(e,r){let t=r.toString();if(t==="")return;let s=!1;s||=/[\(\[\|]$/.test(this.buffer)&&/^\w/.test(t),s||=/^[})\]\|]$/.test(t),s||=/[^=]$/.test(this.buffer)&&t==="(",s||=/^[_^,;!]$/.test(t),s||=t==="'",s||=/[\(\[{]\s*(-|\+)$/.test(this.buffer)||this.buffer==="-"||this.buffer==="+",s||=t.startsWith(`
10
+ `),s||=this.buffer==="",s||=/\s$/.test(this.buffer)||/^\s/.test(t),s||=this.buffer.endsWith("&")&&t==="=",s||=this.buffer.endsWith("/")||t==="/",s||=r.type===3,s||=/[\s_^{\(]$/.test(this.buffer),e!==null&&(s||=e.type===3),s||(this.buffer+=" "),this.buffer+=t}serialize(e){let r={insideFunctionDepth:0};this.queue.push(...e.serialize(r,this.options))}flushQueue(){let e=[];for(let t of this.queue)t.eq(qe)&&e.length>0&&e[e.length-1].eq(qe)||e.push(t);let r=new a(1,"");for(let t=0;t<e.length;t++)e[t].eq(qe)&&(t===0||t===e.length-1||e[t-1].type===6||e[t-1].isOneOf([ht,He])||e[t+1].isOneOf([dt,Tt,He]))&&(e[t]=r);e=e.filter(t=>!t.eq(r));for(let t=0;t<e.length;t++){let s=e[t],o=t===0?null:e[t-1];this.writeBuffer(o,s)}this.queue=[]}finalize(){this.flushQueue();let e=function(s){let o=s.replace(/floor\.l\s*(.*?)\s*floor\.r/g,"floor($1)");return o=o.replace(/floor\(\)/g,'floor("")'),o},r=function(s){let o=s.replace(/ceil\.l\s*(.*?)\s*ceil\.r/g,"ceil($1)");return o=o.replace(/ceil\(\)/g,'ceil("")'),o},t=function(s){let o=s.replace(/floor\.l\s*(.*?)\s*ceil\.r/g,"round($1)");return o=o.replace(/round\(\)/g,'round("")'),o};if(this.options.optimize){let s=[e,r,t];for(let o of s)this.buffer=o(this.buffer)}return this.buffer}};var N=new Map([["displaystyle","display"],["hspace","#h"],["|","bar.v.double"],[",","thin"],[":","med"],[" ","med"],[";","thick"],["ln","ln"],["log","log"],["cos","cos"],["sin","sin"],["tan","tan"],["cot","cot"],["sec","sec"],["csc","csc"],["mod","mod"],["omicron","omicron"],["Xi","Xi"],["Upsilon","Upsilon"],["lim","lim"],["binom","binom"],["tilde","tilde"],["hat","hat"],["sqrt","sqrt"],["nonumber",""],["vec","arrow"],["neq","eq.not"],["dot","dot"],["ddot","dot.double"],["doteq","dot(eq)"],["dots","dots.h"],["vdots","dots.v"],["ddots","dots.down"],["widehat","hat"],["widetilde","tilde"],["quad","quad"],["qquad","wide"],["overbrace","overbrace"],["underbrace","underbrace"],["overline","overline"],["underline","underline"],["bar","macron"],["dbinom","binom"],["tbinom","binom"],["dfrac","frac"],["tfrac","frac"],["operatorname","op"],["boldsymbol","bold"],["mathbb","bb"],["mathbf","bold"],["mathcal","cal"],["mathscr","scr"],["mathit","italic"],["mathfrak","frak"],["mathrm","upright"],["mathsf","sans"],["mathtt","mono"],["rm","upright"],["pmb","bold"],["leadsto","arrow.r.squiggly"],["P","pilcrow"],["S","section"],["aleph","alef"],["infin","infinity"],["Delta","Delta"],["Gamma","Gamma"],["Lambda","Lambda"],["Omega","Omega"],["Phi","Phi"],["Pi","Pi"],["Psi","Psi"],["Sigma","Sigma"],["Theta","Theta"],["alpha","alpha"],["beta","beta"],["bigcirc","circle.big"],["bullet","bullet"],["cdot","dot.op"],["cdots","dots.c"],["checkmark","checkmark"],["chi","chi"],["circ","circle.small"],["colon","colon"],["cong","tilde.equiv"],["coprod","product.co"],["copyright","copyright"],["cup","union"],["curlyvee","or.curly"],["curlywedge","and.curly"],["dagger","dagger"],["dashv","tack.l"],["ddagger","dagger.double"],["delta","delta"],["ddots","dots.down"],["diamond","diamond"],["div","div"],["divideontimes","times.div"],["dotplus","plus.dot"],["ell","ell"],["emptyset","nothing"],["epsilon","epsilon.alt"],["equiv","equiv"],["eta","eta"],["exists","exists"],["forall","forall"],["gamma","gamma"],["ge","gt.eq"],["geq","gt.eq"],["geqslant","gt.eq.slant"],["gg","gt.double"],["hbar","planck.reduce"],["imath","dotless.i"],["iiiint","integral.quad"],["iiint","integral.triple"],["iint","integral.double"],["in","in"],["infty","infinity"],["int","integral"],["intercal","top"],["iota","iota"],["jmath","dotless.j"],["kappa","kappa"],["lambda","lambda"],["land","and"],["langle","angle.l"],["lbrace","brace.l"],["lbrack","bracket.l"],["ldots","dots.h"],["le","lt.eq"],["leftthreetimes","times.three.l"],["leftrightarrow","arrow.l.r"],["leq","lt.eq"],["leqslant","lt.eq.slant"],["lhd","triangle.l"],["ll","lt.double"],["lor","or"],["ltimes","times.l"],["measuredangle","angle.arc"],["mid","divides"],["models","models"],["mp","minus.plus"],["mu","mu"],["nabla","nabla"],["ncong","tilde.equiv.not"],["ne","eq.not"],["neg","not"],["neq","eq.not"],["nexists","exists.not"],["ni","in.rev"],["nleftarrow","arrow.l.not"],["nleq","lt.eq.not"],["nparallel","parallel.not"],["ngeq","gt.eq.not"],["nmid","divides.not"],["notin","in.not"],["nsim","tilde.not"],["nsubseteq","subset.eq.not"],["nu","nu"],["ntriangleleft","lt.tri.not"],["ntriangleright","gt.tri.not"],["odot","dot.circle"],["oint","integral.cont"],["oiint","integral.surf"],["oiiint","integral.vol"],["omega","omega"],["ominus","minus.circle"],["otimes","times.circle"],["parallel","parallel"],["partial","diff"],["perp","perp"],["phi","phi.alt"],["pi","pi"],["pm","plus.minus"],["pounds","pound"],["prec","prec"],["preceq","prec.eq"],["prime","prime"],["prod","product"],["propto","prop"],["psi","psi"],["rangle","angle.r"],["rbrace","brace.r"],["rbrack","bracket.r"],["rhd","triangle"],["rho","rho"],["rightarrow","arrow.r"],["rightthreetimes","times.three.r"],["rtimes","times.r"],["setminus","without"],["sigma","sigma"],["sim","tilde.op"],["simeq","tilde.eq"],["slash","slash"],["smallsetminus","without"],["spadesuit","suit.spade"],["sqsubseteq","subset.eq.sq"],["sqsupseteq","supset.eq.sq"],["subset","subset"],["subseteq","subset.eq"],["subsetneq","subset.neq"],["succ","succ"],["succeq","succ.eq"],["sum","sum"],["supset","supset"],["supseteq","supset.eq"],["supsetneq","supset.neq"],["tau","tau"],["theta","theta"],["times","times"],["to","arrow.r"],["top","top"],["triangle","triangle.t"],["twoheadrightarrow","arrow.r.twohead"],["upharpoonright","harpoon.tr"],["uplus","union.plus"],["upsilon","upsilon"],["varepsilon","epsilon"],["varnothing","diameter"],["varphi","phi"],["varpi","pi.alt"],["varrho","rho.alt"],["varsigma","sigma.alt"],["vartheta","theta.alt"],["vdash","tack.r"],["vdots","dots.v"],["vee","or"],["wedge","and"],["wr","wreath"],["xi","xi"],["yen","yen"],["zeta","zeta"],["intop","limits(integral)"],["LaTeX","#LaTeX"],["TeX","#TeX"]]),gt=new Map([["acwopencirclearrow","arrow.ccw"],["adots","dots.up"],["angdnr","angle.acute"],["angle","angle"],["angles","angle.s"],["approx","approx"],["approxeq","approx.eq"],["approxident","tilde.triple"],["assert","tack.r.short"],["ast","ast.op"],["asymp","asymp"],["awint","integral.ccw"],["backcong","tilde.rev.equiv"],["backdprime","prime.double.rev"],["backprime","prime.rev"],["backsim","tilde.rev"],["backsimeq","tilde.eq.rev"],["backslash","backslash"],["backtrprime","prime.triple.rev"],["bardownharpoonleft","harpoon.bl.bar"],["bardownharpoonright","harpoon.br.bar"],["barleftarrow","arrow.l.stop"],["barleftarrowrightarrowbar","arrows.lr.stop"],["barleftharpoondown","harpoon.lb.stop"],["barleftharpoonup","harpoon.lt.stop"],["barrightharpoondown","harpoon.rb.bar"],["barrightharpoonup","harpoon.rt.bar"],["baruparrow","arrow.t.stop"],["barupharpoonleft","harpoon.tl.stop"],["barupharpoonright","harpoon.tr.stop"],["barV","tack.b.double"],["BbbA","AA"],["BbbB","BB"],["BbbC","CC"],["BbbD","DD"],["BbbE","EE"],["BbbF","FF"],["BbbG","GG"],["BbbH","HH"],["BbbI","II"],["BbbJ","JJ"],["BbbK","KK"],["BbbL","LL"],["BbbM","MM"],["BbbN","NN"],["BbbO","OO"],["BbbP","PP"],["BbbQ","QQ"],["BbbR","RR"],["BbbS","SS"],["BbbT","TT"],["BbbU","UU"],["BbbV","VV"],["BbbW","WW"],["BbbX","XX"],["BbbY","YY"],["BbbZ","ZZ"],["because","because"],["bigblacktriangledown","triangle.filled.b"],["bigblacktriangleup","triangle.filled.t"],["bigbot","tack.t.big"],["bigcap","inter.big"],["bigcup","union.big"],["bigcupdot","union.dot.big"],["biginterleave","interleave.big"],["bigodot","dot.circle.big"],["bigoplus","plus.circle.big"],["bigotimes","times.circle.big"],["bigsqcap","inter.sq.big"],["bigsqcup","union.sq.big"],["bigstar","star.filled"],["bigtimes","times.big"],["bigtop","tack.b.big"],["bigtriangledown","triangle.stroked.b"],["bigtriangleup","triangle.stroked.t"],["biguplus","union.plus.big"],["bigvee","or.big"],["bigwedge","and.big"],["bigwhitestar","star.stroked"],["blackhourglass","hourglass.filled"],["blacktriangle","triangle.filled.small.t"],["blacktriangledown","triangle.filled.small.b"],["blacktriangleleft","triangle.filled.l"],["blacktriangleright","triangle.filled.r"],["blkhorzoval","ellipse.filled.h"],["blkvertoval","ellipse.filled.v"],["bot","bot"],["boxast","ast.square"],["boxdot","dot.square"],["boxminus","minus.square"],["boxplus","plus.square"],["boxtimes","times.square"],["cap","inter"],["Cap","inter.double"],["capdot","inter.dot"],["capwedge","inter.and"],["caretinsert","caret"],["cdot","dot.op"],["cdotp","dot.c"],["checkmark","checkmark"],["circledast","ast.circle"],["circledcirc","circle.nested"],["circleddash","dash.circle"],["circledequal","eq.circle"],["circledparallel","parallel.circle"],["circledvert","bar.v.circle"],["clubsuit","suit.club.filled"],["Colon","colon.double"],["coloneq","colon.eq"],["Coloneq","colon.double.eq"],["complement","complement"],["cong","tilde.equiv"],["coprod","product.co"],["cup","union"],["Cup","union.double"],["cupdot","union.dot"],["cupleftarrow","union.arrow"],["cupvee","union.or"],["curlyeqprec","eq.prec"],["curlyeqsucc","eq.succ"],["curlyvee","or.curly"],["curlywedge","and.curly"],["curvearrowleft","arrow.ccw.half"],["curvearrowright","arrow.cw.half"],["cwopencirclearrow","arrow.cw"],["dagger","dagger"],["dashcolon","dash.colon"],["dashv","tack.l"],["Dashv","tack.l.double"],["dashVdash","tack.l.r"],["ddagger","dagger.double"],["ddddot","dot.quad"],["dddot","dot.triple"],["ddots","dots.down"],["DDownarrow","arrow.b.quad"],["Ddownarrow","arrow.b.triple"],["diameter","diameter"],["diamondcdot","diamond.stroked.dot"],["diamondsuit","suit.diamond.stroked"],["dicei","die.one"],["diceii","die.two"],["diceiii","die.three"],["diceiv","die.four"],["dicev","die.five"],["dicevi","die.six"],["div","div"],["divideontimes","times.div"],["Doteq","eq.dots"],["dotminus","minus.dot"],["dotplus","plus.dot"],["dotsim","tilde.dot"],["dottedcircle","circle.dotted"],["dottedsquare","square.stroked.dotted"],["doubleplus","plus.double"],["downarrow","arrow.b"],["Downarrow","arrow.b.double"],["downarrowbar","arrow.b.stop"],["downdasharrow","arrow.b.dashed"],["downdownarrows","arrows.bb"],["downharpoonleft","harpoon.bl"],["downharpoonleftbar","harpoon.bl.stop"],["downharpoonright","harpoon.br"],["downharpoonrightbar","harpoon.br.stop"],["downharpoonsleftright","harpoons.blbr"],["downrightcurvedarrow","arrow.b.curve"],["downuparrows","arrows.bt"],["downupharpoonsleftright","harpoons.bltr"],["downwhitearrow","arrow.b.stroked"],["downzigzagarrow","arrow.zigzag"],["dprime","prime.double"],["dualmap","multimap.double"],["eighthnote","note.eighth.alt"],["ell","ell"],["emptysetoarr","emptyset.arrow.r"],["emptysetoarrl","emptyset.arrow.l"],["emptysetobar","emptyset.bar"],["emptysetocirc","emptyset.circle"],["eparsl","parallel.slanted.eq"],["eqcolon","eq.colon"],["eqdef","eq.def"],["eqgtr","eq.gt"],["eqless","eq.lt"],["eqsim","minus.tilde"],["equal","eq"],["equalparallel","parallel.eq"],["equiv","eq.triple"],["Equiv","eq.quad"],["equivVert","parallel.equiv"],["eqvparsl","parallel.slanted.equiv"],["errbarblackcircle","errorbar.circle.filled"],["errbarblackdiamond","errorbar.diamond.filled"],["errbarblacksquare","errorbar.square.filled"],["errbarcircle","errorbar.circle.stroked"],["errbardiamond","errorbar.diamond.stroked"],["errbarsquare","errorbar.square.stroked"],["euro","euro"],["Exclam","excl.double"],["exists","exists"],["fallingdotseq","eq.dots.down"],["fint","integral.slash"],["flat","flat"],["forall","forall"],["fourvdots","fence.dotted"],["fullouterjoin","join.l.r"],["geq","gt.eq"],["geqq","gt.equiv"],["geqslant","gt.eq.slant"],["gg","gt.double"],["ggg","gt.triple"],["gggnest","gt.triple.nested"],["gnapprox","gt.napprox"],["gneq","gt.neq"],["gneqq","gt.nequiv"],["gnsim","gt.ntilde"],["greater","gt"],["gtlpar","angle.spheric.rev"],["gtrapprox","gt.approx"],["gtrdot","gt.dot"],["gtreqless","gt.eq.lt"],["gtrless","gt.lt"],["gtrsim","gt.tilde"],["heartsuit","suit.heart.stroked"],["hknearrow","arrow.tr.hook"],["hknwarrow","arrow.tl.hook"],["hksearrow","arrow.br.hook"],["hkswarrow","arrow.bl.hook"],["hookleftarrow","arrow.l.hook"],["hookrightarrow","arrow.r.hook"],["horizbar","bar.h"],["hourglass","hourglass.stroked"],["hrectangle","rect.stroked.h"],["hrectangleblack","rect.filled.h"],["hslash","planck.reduce"],["hzigzag","dash.wave.double"],["iiiint","integral.quad"],["iiint","integral.triple"],["iinfin","infinity.incomplete"],["iint","integral.double"],["Im","Im"],["imageof","image"],["in","in"],["increment","laplace"],["infty","infinity"],["int","integral"],["intbar","integral.dash"],["intBar","integral.dash.double"],["intcap","integral.inter"],["intclockwise","integral.cw"],["intcup","integral.union"],["interleave","interleave"],["intlarhk","integral.arrow.hook"],["intx","integral.times"],["Join","join"],["langle","angle.l"],["lAngle","angle.l.double"],["langledot","angle.l.dot"],["lat","lat"],["late","lat.eq"],["lbrace","brace.l"],["lBrace","brace.l.double"],["lbrack","bracket.l"],["lBrack","bracket.l.double"],["lbrbrak","shell.l"],["Lbrbrak","shell.l.double"],["lceil","ceil.l"],["lcurvyangle","angle.l.curly"],["leftarrow","arrow.l"],["Leftarrow","arrow.l.double"],["leftarrowtail","arrow.l.tail"],["leftdasharrow","arrow.l.dashed"],["leftdotarrow","arrow.l.dotted"],["leftdowncurvedarrow","arrow.l.curve"],["leftharpoondown","harpoon.lb"],["leftharpoondownbar","harpoon.lb.bar"],["leftharpoonsupdown","harpoons.ltlb"],["leftharpoonup","harpoon.lt"],["leftharpoonupbar","harpoon.lt.bar"],["leftleftarrows","arrows.ll"],["leftouterjoin","join.l"],["leftrightarrow","arrow.l.r"],["Leftrightarrow","arrow.l.r.double"],["leftrightarrows","arrows.lr"],["leftrightharpoondowndown","harpoon.lb.rb"],["leftrightharpoondownup","harpoon.lb.rt"],["leftrightharpoons","harpoons.ltrb"],["leftrightharpoonsdown","harpoons.lbrb"],["leftrightharpoonsup","harpoons.ltrt"],["leftrightharpoonupdown","harpoon.lt.rb"],["leftrightharpoonupup","harpoon.lt.rt"],["leftrightsquigarrow","arrow.l.r.wave"],["leftsquigarrow","arrow.l.squiggly"],["leftthreearrows","arrows.lll"],["leftthreetimes","times.three.l"],["leftwavearrow","arrow.l.wave"],["leftwhitearrow","arrow.l.stroked"],["leq","lt.eq"],["leqq","lt.equiv"],["leqslant","lt.eq.slant"],["less","lt"],["lessapprox","lt.approx"],["lessdot","lt.dot"],["lesseqgtr","lt.eq.gt"],["lessgtr","lt.gt"],["lesssim","lt.tilde"],["lfloor","floor.l"],["lgblkcircle","circle.filled.big"],["lgblksquare","square.filled.big"],["lgwhtcircle","circle.stroked.big"],["lgwhtsquare","square.stroked.big"],["ll","lt.double"],["llblacktriangle","triangle.filled.bl"],["LLeftarrow","arrow.l.quad"],["Lleftarrow","arrow.l.triple"],["lll","lt.triple"],["lllnest","lt.triple.nested"],["lltriangle","triangle.stroked.bl"],["lnapprox","lt.napprox"],["lneq","lt.neq"],["lneqq","lt.nequiv"],["lnsim","lt.ntilde"],["longdashv","tack.l.long"],["Longleftarrow","arrow.l.double.long"],["longleftarrow","arrow.l.long"],["Longleftrightarrow","arrow.l.r.double.long"],["longleftrightarrow","arrow.l.r.long"],["longleftsquigarrow","arrow.l.long.squiggly"],["Longmapsfrom","arrow.l.double.long.bar"],["longmapsfrom","arrow.l.long.bar"],["longmapsto","arrow.r.long.bar"],["Longmapsto","arrow.r.double.long.bar"],["Longrightarrow","arrow.r.double.long"],["longrightarrow","arrow.r.long"],["longrightsquigarrow","arrow.r.long.squiggly"],["looparrowleft","arrow.l.loop"],["looparrowright","arrow.r.loop"],["lparen","paren.l"],["lParen","paren.l.double"],["lrblacktriangle","triangle.filled.br"],["lrtriangle","triangle.stroked.br"],["ltimes","times.l"],["lvzigzag","fence.l"],["Lvzigzag","fence.l.double"],["maltese","maltese"],["mapsdown","arrow.b.bar"],["mapsfrom","arrow.l.bar"],["Mapsfrom","arrow.l.double.bar"],["mapsto","arrow.r.bar"],["Mapsto","arrow.r.double.bar"],["mapsup","arrow.t.bar"],["mathampersand","amp"],["mathatsign","at"],["mathcolon","colon"],["mathcomma","comma"],["mathdollar","dollar"],["mathexclam","excl"],["mathoctothorpe","hash"],["mathparagraph","pilcrow"],["mathpercent","percent"],["mathperiod","dot.basic"],["mathplus","plus"],["mathquestion","quest"],["mathratio","ratio"],["mathsection","section"],["mathsemicolon","semi"],["mathslash","slash"],["mathsterling","pound"],["mathyen","yen"],["mdblkdiamond","diamond.filled.medium"],["mdblklozenge","lozenge.filled.medium"],["mdblksquare","square.filled.medium"],["mdlgblkcircle","circle.filled"],["mdlgblkdiamond","diamond.filled"],["mdlgblklozenge","lozenge.filled"],["mdlgblksquare","square.filled"],["mdlgwhtcircle","circle.stroked"],["mdlgwhtdiamond","diamond.stroked"],["mdlgwhtlozenge","lozenge.stroked"],["mdlgwhtsquare","square.stroked"],["mdsmblkcircle","circle.filled.tiny"],["mdsmblksquare","square.filled.small"],["mdsmwhtcircle","circle.stroked.small"],["mdsmwhtsquare","square.stroked.small"],["mdwhtdiamond","diamond.stroked.medium"],["mdwhtlozenge","lozenge.stroked.medium"],["mdwhtsquare","square.stroked.medium"],["measeq","eq.m"],["measuredangle","angle.arc"],["measuredangleleft","angle.arc.rev"],["measuredrightangle","angle.right.arc"],["mho","Omega.inv"],["mid","divides"],["minus","minus"],["models","models"],["mp","minus.plus"],["multimap","multimap"],["nabla","gradient"],["napprox","approx.not"],["nasymp","asymp.not"],["natural","natural"],["ncong","tilde.equiv.not"],["ne","eq.not"],["nearrow","arrow.tr"],["Nearrow","arrow.tr.double"],["neg","not"],["nequiv","equiv.not"],["neswarrow","arrow.tr.bl"],["nexists","exists.not"],["ngeq","gt.eq.not"],["ngtr","gt.not"],["ngtrless","gt.lt.not"],["ngtrsim","gt.tilde.not"],["nhpar","parallel.struck"],["nhVvert","interleave.struck"],["ni","in.rev"],["nLeftarrow","arrow.l.double.not"],["nleftarrow","arrow.l.not"],["nLeftrightarrow","arrow.l.r.double.not"],["nleftrightarrow","arrow.l.r.not"],["nleq","lt.eq.not"],["nless","lt.not"],["nlessgtr","lt.gt.not"],["nlesssim","lt.tilde.not"],["nmid","divides.not"],["nni","in.rev.not"],["notin","in.not"],["nparallel","parallel.not"],["nprec","prec.not"],["npreccurlyeq","prec.curly.eq.not"],["nRightarrow","arrow.r.double.not"],["nrightarrow","arrow.r.not"],["nsim","tilde.not"],["nsimeq","tilde.eq.not"],["nsqsubseteq","subset.eq.sq.not"],["nsqsupseteq","supset.eq.sq.not"],["nsubset","subset.not"],["nsubseteq","subset.eq.not"],["nsucc","succ.not"],["nsucccurlyeq","succ.curly.eq.not"],["nsupset","supset.not"],["nsupseteq","supset.eq.not"],["ntrianglelefteq","lt.tri.eq.not"],["ntrianglerighteq","gt.tri.eq.not"],["nvartriangleleft","lt.tri.not"],["nvartriangleright","gt.tri.not"],["nVdash","forces.not"],["nvdash","tack.r.not"],["nvDash","tack.r.double.not"],["nvinfty","infinity.bar"],["nwarrow","arrow.tl"],["Nwarrow","arrow.tl.double"],["nwsearrow","arrow.tl.br"],["obrbrak","shell.t"],["obslash","backslash.circle"],["odiv","div.circle"],["odot","dot.circle"],["ogreaterthan","gt.circle"],["oiiint","integral.vol"],["oiint","integral.surf"],["oint","integral.cont"],["ointctrclockwise","integral.cont.ccw"],["olessthan","lt.circle"],["ominus","minus.circle"],["operp","perp.circle"],["oplus","plus.circle"],["origof","original"],["otimes","times.circle"],["overbracket","bracket.t"],["overparen","paren.t"],["parallel","parallel"],["parallelogram","parallelogram.stroked"],["parallelogramblack","parallelogram.filled"],["parsim","parallel.tilde"],["partial","diff"],["pentagon","penta.stroked"],["pentagonblack","penta.filled"],["perp","perp"],["Planckconst","planck"],["pm","plus.minus"],["prec","prec"],["Prec","prec.double"],["precapprox","prec.approx"],["preccurlyeq","prec.curly.eq"],["preceq","prec.eq"],["preceqq","prec.equiv"],["precnapprox","prec.napprox"],["precneq","prec.neq"],["precneqq","prec.nequiv"],["precnsim","prec.ntilde"],["precsim","prec.tilde"],["prime","prime"],["prod","product"],["propto","prop"],["QED","qed"],["qprime","prime.quad"],["quarternote","note.quarter.alt"],["questeq","eq.quest"],["Question","quest.double"],["rangle","angle.r"],["rAngle","angle.r.double"],["rangledot","angle.r.dot"],["rbrace","brace.r"],["rBrace","brace.r.double"],["rbrack","bracket.r"],["rBrack","bracket.r.double"],["rbrbrak","shell.r"],["Rbrbrak","shell.r.double"],["rceil","ceil.r"],["rcurvyangle","angle.r.curly"],["Re","Re"],["revangle","angle.rev"],["revemptyset","emptyset.rev"],["revnmid","divides.not.rev"],["rfloor","floor.r"],["rightangle","angle.right"],["rightanglemdot","angle.right.dot"],["rightanglesqr","angle.right.sq"],["rightarrow","arrow.r"],["Rightarrow","arrow.r.double"],["rightarrowbar","arrow.r.stop"],["rightarrowonoplus","plus.circle.arrow"],["rightarrowtail","arrow.r.tail"],["rightdasharrow","arrow.r.dashed"],["rightdotarrow","arrow.r.dotted"],["rightdowncurvedarrow","arrow.r.curve"],["rightharpoondown","harpoon.rb"],["rightharpoondownbar","harpoon.rb.stop"],["rightharpoonsupdown","harpoons.rtrb"],["rightharpoonup","harpoon.rt"],["rightharpoonupbar","harpoon.rt.stop"],["rightleftarrows","arrows.rl"],["rightleftharpoons","harpoons.rtlb"],["rightleftharpoonsdown","harpoons.rblb"],["rightleftharpoonsup","harpoons.rtlt"],["rightouterjoin","join.r"],["rightrightarrows","arrows.rr"],["rightsquigarrow","arrow.r.squiggly"],["rightthreearrows","arrows.rrr"],["rightthreetimes","times.three.r"],["rightwavearrow","arrow.r.wave"],["rightwhitearrow","arrow.r.stroked"],["risingdotseq","eq.dots.up"],["rparen","paren.r"],["rParen","paren.r.double"],["RRightarrow","arrow.r.quad"],["Rrightarrow","arrow.r.triple"],["rsolbar","backslash.not"],["rtimes","times.r"],["rvzigzag","fence.r"],["Rvzigzag","fence.r.double"],["searrow","arrow.br"],["Searrow","arrow.br.double"],["setminus","without"],["sharp","sharp"],["shortdowntack","tack.b.short"],["shortlefttack","tack.l.short"],["shortuptack","tack.t.short"],["sim","tilde.op"],["sime","tilde.eq"],["similarleftarrow","arrow.l.tilde"],["similarrightarrow","arrow.r.tilde"],["simneqq","tilde.nequiv"],["smallblacktriangleleft","triangle.filled.small.l"],["smallblacktriangleright","triangle.filled.small.r"],["smallin","in.small"],["smallni","in.rev.small"],["smalltriangleleft","triangle.stroked.small.l"],["smalltriangleright","triangle.stroked.small.r"],["smashtimes","smash"],["smblkcircle","bullet"],["smblkdiamond","diamond.filled.small"],["smblklozenge","lozenge.filled.small"],["smblksquare","square.filled.tiny"],["smeparsl","parallel.slanted.eq.tilde"],["smt","smt"],["smte","smt.eq"],["smwhtdiamond","diamond.stroked.small"],["smwhtlozenge","lozenge.stroked.small"],["smwhtsquare","square.stroked.tiny"],["spadesuit","suit.spade.filled"],["sphericalangle","angle.spheric"],["sphericalangleup","angle.spheric.top"],["sqcap","inter.sq"],["Sqcap","inter.sq.double"],["sqcup","union.sq"],["Sqcup","union.sq.double"],["sqint","integral.square"],["sqsubset","subset.sq"],["sqsubseteq","subset.eq.sq"],["sqsubsetneq","subset.sq.neq"],["sqsupset","supset.sq"],["sqsupseteq","supset.eq.sq"],["sqsupsetneq","supset.sq.neq"],["squoval","square.stroked.rounded"],["sslash","slash.double"],["star","star.op"],["stareq","eq.star"],["subset","subset"],["Subset","subset.double"],["subsetdot","subset.dot"],["subseteq","subset.eq"],["subsetneq","subset.neq"],["succ","succ"],["Succ","succ.double"],["succapprox","succ.approx"],["succcurlyeq","succ.curly.eq"],["succeq","succ.eq"],["succeqq","succ.equiv"],["succnapprox","succ.napprox"],["succneq","succ.neq"],["succneqq","succ.nequiv"],["succnsim","succ.ntilde"],["succsim","succ.tilde"],["sum","sum"],["sumint","sum.integral"],["supset","supset"],["Supset","supset.double"],["supsetdot","supset.dot"],["supseteq","supset.eq"],["supsetneq","supset.neq"],["swarrow","arrow.bl"],["Swarrow","arrow.bl.double"],["therefore","therefore"],["threedangle","angle.spatial"],["threedotcolon","colon.tri.op"],["tieinfty","infinity.tie"],["times","times"],["tminus","miny"],["top","tack.b"],["tplus","tiny"],["trianglecdot","triangle.stroked.dot"],["triangledown","triangle.stroked.small.b"],["triangleleft","triangle.stroked.l"],["trianglelefteq","lt.tri.eq"],["triangleminus","minus.triangle"],["triangleplus","plus.triangle"],["triangleq","eq.delta"],["triangleright","triangle.stroked.r"],["trianglerighteq","gt.tri.eq"],["triangletimes","times.triangle"],["tripleplus","plus.triple"],["trprime","prime.triple"],["trslash","slash.triple"],["twoheaddownarrow","arrow.b.twohead"],["twoheadleftarrow","arrow.l.twohead"],["twoheadmapsfrom","arrow.l.twohead.bar"],["twoheadmapsto","arrow.r.twohead.bar"],["twoheadrightarrow","arrow.r.twohead"],["twoheaduparrow","arrow.t.twohead"],["twonotes","note.eighth.beamed"],["ubrbrak","shell.b"],["ulblacktriangle","triangle.filled.tl"],["ultriangle","triangle.stroked.tl"],["uminus","union.minus"],["underbrace","brace.b"],["underbracket","bracket.b"],["underparen","paren.b"],["unicodecdots","dots.h.c"],["unicodeellipsis","dots.h"],["upand","amp.inv"],["uparrow","arrow.t"],["Uparrow","arrow.t.double"],["updasharrow","arrow.t.dashed"],["updownarrow","arrow.t.b"],["Updownarrow","arrow.t.b.double"],["updownarrows","arrows.tb"],["updownharpoonleftleft","harpoon.tl.bl"],["updownharpoonleftright","harpoon.tl.br"],["updownharpoonrightleft","harpoon.tr.bl"],["updownharpoonrightright","harpoon.tr.br"],["updownharpoonsleftright","harpoons.tlbr"],["upharpoonleft","harpoon.tl"],["upharpoonleftbar","harpoon.tl.bar"],["upharpoonright","harpoon.tr"],["upharpoonrightbar","harpoon.tr.bar"],["upharpoonsleftright","harpoons.tltr"],["uplus","union.plus"],["uprightcurvearrow","arrow.t.curve"],["upuparrows","arrows.tt"],["upwhitearrow","arrow.t.stroked"],["urblacktriangle","triangle.filled.tr"],["urtriangle","triangle.stroked.tr"],["UUparrow","arrow.t.quad"],["Uuparrow","arrow.t.triple"],["varclubsuit","suit.club.stroked"],["vardiamondsuit","suit.diamond.filled"],["varheartsuit","suit.heart.filled"],["varhexagon","hexa.stroked"],["varhexagonblack","hexa.filled"],["varnothing","emptyset"],["varointclockwise","integral.cont.cw"],["varspadesuit","suit.spade.stroked"],["vartriangle","triangle.stroked.small.t"],["vartriangleleft","lt.tri"],["vartriangleright","gt.tri"],["Vbar","tack.t.double"],["Vdash","forces"],["vdash","tack.r"],["vDash","tack.r.double"],["vdots","dots.v"],["vee","or"],["Vee","or.double"],["veedot","or.dot"],["veeeq","eq.equi"],["vert","bar.v"],["Vert","bar.v.double"],["vlongdash","tack.r.long"],["vrectangle","rect.stroked.v"],["vrectangleblack","rect.filled.v"],["Vvert","bar.v.triple"],["vysmblkcircle","circle.filled.small"],["vysmwhtcircle","circle.stroked.tiny"],["wedge","and"],["Wedge","and.double"],["wedgedot","and.dot"],["wedgeq","eq.est"],["whiteinwhitetriangle","triangle.stroked.nested"],["whthorzoval","ellipse.stroked.h"],["whtvertoval","ellipse.stroked.v"],["wideangledown","angle.oblique"],["wr","wreath"],["xsol","slash.big"]]),wt=new Map([["gets","leftarrow"],["iff","Longleftrightarrow"],["implies","Longrightarrow"]]);for(let[n,e]of gt)N.has(n)||N.set(n,e);var z=new Map;for(let[n,e]of Array.from(N.entries()).reverse())z.set(e,n);z.set("oo","infty");var bt=new Map([["top","top"],["frac","frac"],["tilde","tilde"],["hat","hat"],["upright","mathrm"],["bold","boldsymbol"],["infinity","infty"]]);for(let[n,e]of bt)z.set(n,e);for(let[n,e]of wt)N.has(n)||N.set(n,N.get(e));var W=class extends Error{node;constructor(e,r=null){super(e),this.name="ConverterError",this.node=r}},mt=a.NONE.toNode(),ft=["dim","id","im","mod","Pr","sech","csch"];function yt(n){if(/^[a-zA-Z0-9]$/.test(n))return n;if(n==="/")return"\\/";if(["\\\\","\\{","\\}","\\%"].includes(n))return n.substring(1);if(["\\$","\\#","\\&","\\_"].includes(n))return n;if(n.startsWith("\\")){let e=n.slice(1);return N.has(e)?N.get(e):null}return n}function Y(n,e){let r;switch(n.type){case 0:return a.NONE;case 2:r=1;break;case 1:r=2;break;case 3:r=3;break;case 4:r=5;break;case 5:r=6;break;case 6:r=8;break;case 7:{if(n.value==="\\\\")return new a(7,"\\");if(n.value==="\\!")return new a(1,"#h(-math.thin.amount)");if(N.has(n.value.substring(1))){let s=N.get(n.value.substring(1));return new a(1,s)}else throw new Error(`Unknown control sequence: ${n.value}`)}default:throw Error(`Unknown token type: ${n.type}`)}let t=yt(n.value);if(t===null){if(e.nonStrict)return new a(r,n.value.substring(1));throw new W(`Unknown token: ${n.value}`,n)}return new a(r,t)}function Et(n,e){let[r,t]=n.args;if(e.optimize&&["\\overset{\\text{def}}{=}","\\overset{d e f}{=}"].includes(n.toString()))return new a(1,"eq.def").toNode();let s=new f(new a(1,"limits"),[m(t,e)]);return new S({base:s,sup:m(r,e),sub:null})}function Nt(n,e){let[r,t]=n.args,s=new f(new a(1,"limits"),[m(t,e)]);return new S({base:s,sub:m(r,e),sup:null})}function xt(n){let e={},r={l:"#left",c:"#center",r:"#right"},t=Array.from(n),s=[],o=0;for(let u of t)u==="|"?s.push(o):(u==="l"||u==="c"||u==="r")&&o++;if(s.length>0){let u;s.length===1?u=`#${s[0]}`:u=`#(vline: (${s.join(", ")}))`,e.augment=new a(3,u).toNode()}let i=t.map(u=>r[u]).filter(u=>u!==void 0).map(u=>new a(3,u).toNode());if(i.length>0){let u=i.every(p=>p.eq(i[0]));e.align=u?i[0]:new a(3,"#center").toNode()}return e}var qt=new a(2,"("),vt=new a(2,")");function Fe(n){return n.head.type===2&&["(",")","[","]","{","}","|","\u230A","\u230B","\u2308","\u2309"].includes(n.head.value)}function pe(n){let e=["group","supsub","matrixLike","fraction","empty"].includes(n.type);if(n.type==="group"){let r=n;if(r.items.length===0)e=!0;else{let t=r.items[0],s=r.items[r.items.length-1];Fe(t)&&Fe(s)&&(e=!1)}}return e?new q(null,{left:qt,right:vt,body:n}):n}function m(n,e={}){switch(n.type){case"terminal":return Y(n.head,e).toNode();case"text":{let t=n;return new a(4,t.head.value).toNode()}case"ordgroup":let r=n;return new _(r.items.map(t=>m(t,e)));case"supsub":{let t=n,{base:s,sup:o,sub:i}=t;if(s&&s.type==="funcCall"&&s.head.value==="\\overbrace"&&o)return new f(new a(1,"overbrace"),[m(s.args[0],e),m(o,e)]);if(s&&s.type==="funcCall"&&s.head.value==="\\underbrace"&&i)return new f(new a(1,"underbrace"),[m(s.args[0],e),m(i,e)]);let u={base:m(s,e),sup:o?m(o,e):null,sub:i?m(i,e):null};return u.base=pe(u.base),u.sup&&(u.sup=pe(u.sup)),u.sub&&(u.sub=pe(u.sub)),new S(u)}case"leftright":{let t=n,{left:s,right:o}=t,i=m(t.body,e);if(e.optimize&&s!==null&&o!==null){let h=Y(s,e),d=Y(o,e);if(s.value==="\\|"&&o.value==="\\|")return new f(new a(1,"norm"),[i]);if(["[]","()","\\{\\}","\\lfloor\\rfloor","\\lceil\\rceil","\\lfloor\\rceil"].includes(s.value+o.value))return new _([h.toNode(),i,d.toNode()])}let u=function(h){return["(",")","{","["].includes(h.value)?new a(2,"\\"+h.value):h},p=s?Y(s,e):null,c=o?Y(o,e):null;return p===null&&c!==null&&(c=u(c)),c===null&&p!==null&&(p=u(p)),new q(new a(1,"lr"),{body:i,left:p,right:c})}case"funcCall":{let t=n,s=m(t.args[0],e);if(t.head.value==="\\sqrt"&&t.data){let o=m(t.data,e);return new f(new a(1,"root"),[o,s])}if(t.head.value==="\\mathbf"){let o=new f(new a(1,"bold"),[s]);return new f(new a(1,"upright"),[o])}if(t.head.value==="\\overrightarrow")return new f(new a(1,"arrow"),[s]);if(t.head.value==="\\overleftarrow")return new f(new a(1,"accent"),[s,new a(1,"arrow.l").toNode()]);if(t.head.value==="\\operatorname")return e.optimize&&ft.includes(s.head.value)?new a(1,s.head.value).toNode():new f(new a(1,"op"),[new a(4,s.head.value).toNode()]);if(t.head.value==="\\textcolor"){let o=new P(new a(1,"#text"),[m(t.args[1],e)]);return o.setOptions({fill:s}),o}if(t.head.value==="\\substack"||t.head.value==="\\displaylines"||t.head.value==="\\mathinner")return s;if(t.head.value==="\\mathrel")return new f(new a(1,"class"),[new a(4,"relation").toNode(),s]);if(t.head.value==="\\mathbin")return new f(new a(1,"class"),[new a(4,"binary").toNode(),s]);if(t.head.value==="\\mathop")return new f(new a(1,"class"),[new a(4,"large").toNode(),s]);if(t.head.value==="\\set")return new q(null,{body:s,left:a.LEFT_BRACE,right:a.RIGHT_BRACE});if(t.head.value==="\\overset")return Et(t,e);if(t.head.value==="\\underset")return Nt(t,e);if(t.head.value==="\\frac"&&e.fracToSlash)return new B(t.args.map(o=>m(o,e)).map(pe));if(e.optimize){if(t.head.value==="\\mathbb"&&/^\\mathbb{[A-Z]}$/.test(t.toString()))return new a(1,s.head.value.repeat(2)).toNode();if(t.head.value==="\\mathrm"&&t.toString()==="\\mathrm{d}")return new a(1,"dif").toNode()}return new f(Y(t.head,e),t.args.map(o=>m(o,e)))}case"beginend":{let t=n,s=t.matrix.map(o=>o.map(i=>m(i,e)));if(t.head.value.startsWith("align"))return new E(null,s);if(t.head.value==="cases")return new E(E.CASES,s);if(t.head.value==="subarray"){if(t.data)switch(t.data.head.value){case"r":s.forEach(i=>i.push(a.EMPTY.toNode()));break;case"l":s.forEach(i=>i.unshift(a.EMPTY.toNode()));break;default:break}return new E(null,s)}if(t.head.value==="array"){let o={delim:mt};T(t.data!==null&&t.head.type===3);let i=xt(t.data.head.value);Object.assign(o,i);let u=new E(E.MAT,s);return u.setOptions(o),u}if(t.head.value.endsWith("matrix")){let o=new E(E.MAT,s),i;switch(t.head.value){case"matrix":i=a.NONE;break;case"pmatrix":return o;case"bmatrix":i=new a(4,"[");break;case"Bmatrix":i=new a(4,"{");break;case"vmatrix":i=new a(4,"|");break;case"Vmatrix":{i=new a(1,"bar.v.double");break}default:throw new W(`Unimplemented beginend: ${t.head}`,t)}return o.setOptions({delim:i.toNode()}),o}throw new W(`Unimplemented beginend: ${t.head}`,t)}default:throw new W(`Unimplemented node type: ${n.type}`,n)}}function R(n){switch(n.type){case 0:return l.EMPTY;case 1:{let e=function(r){return z.has(r)?"\\"+z.get(r):"\\"+r};return new l(2,e(n.value))}case 2:{let e;return["{","}","%"].includes(n.value)?e="\\"+n.value:e=n.value,new l(1,e)}case 3:return new l(3,n.value);case 4:return new l(3,n.value);case 5:return new l(4,n.value);case 6:return new l(5,n.value);case 7:{let e;switch(n.value){case"\\":e="\\\\";break;case"&":e="&";break;default:throw new Error(`[typst_token_to_tex]Unimplemented control sequence: ${n.value}`)}return new l(7,e)}case 8:return new l(6,n.value);default:throw new Error(`Unimplemented token type: ${n.type}`)}}var Mt=new l(1,",").toNode();function b(n){switch(n.type){case"terminal":{let e=n;if(e.head.type===1){if(e.head.value==="eq.def")return new w(new l(2,"\\overset"),[new O(new l(3,"def")),new l(1,"=").toNode()]);if(e.head.value==="comma")return new l(1,",").toNode();if(e.head.value==="dif")return new w(new l(2,"\\mathrm"),[new l(1,"d").toNode()]);if(e.head.value==="hyph"||e.head.value==="hyph.minus")return new O(new l(3,"-"));if(/^([A-Z])\1$/.test(e.head.value))return new w(new l(2,"\\mathbb"),[new l(1,e.head.value[0]).toNode()])}return e.head.type===4?new O(new l(3,e.head.value)):R(e.head).toNode()}case"group":{let r=n.items.map(b),t=new l(7,"&").toNode(),s=new l(7,"\\\\").toNode();if(ne(r,t)){let o=be(r,s),i=[];for(let u of o){let p=be(u,t);i.push(p.map(c=>new y(c)))}return new L(new l(3,"aligned"),i)}return new y(r)}case"leftright":{let e=n,r=b(e.body),t=e.left?R(e.left):new l(1,"."),s=e.right?R(e.right):new l(1,".");return e.isOverHigh()&&(t.value="\\left"+t.value,s.value="\\right"+s.value),new y([t.toNode(),r,s.toNode()])}case"funcCall":{let e=n;switch(e.head.value){case"norm":{let r=e.args[0],t=b(r);return e.isOverHigh()?new C({body:t,left:new l(2,"\\|"),right:new l(2,"\\|")}):t}case"floor":case"ceil":{let r="\\l"+e.head.value,t="\\r"+e.head.value,s=e.args[0],o=b(s),i=new l(2,r),u=new l(2,t);return e.isOverHigh()?new C({body:o,left:i,right:u}):new y([i.toNode(),o,u.toNode()])}case"root":{let[r,t]=e.args,s=b(r);return new w(new l(2,"\\sqrt"),[b(t)],s)}case"overbrace":case"underbrace":{let[r,t]=e.args,s=new w(R(e.head),[b(r)]),o=b(t),i=e.head.value==="overbrace"?{base:s,sup:o,sub:null}:{base:s,sub:o,sup:null};return new A(i)}case"vec":{let r=e.args.map(b).map(t=>[t]);return new L(new l(3,"pmatrix"),r)}case"op":{let r=e.args[0];return T(r.head.type===4),new w(R(e.head),[new l(3,r.head.value).toNode()])}case"class":{let r=e.args[0];T(r.head.type===4);let t;switch(r.head.value){case"relation":t="\\mathrel";break;case"binary":t="\\mathbin";break;case"large":t="\\mathop";break;default:throw new Error(`Unimplemented class: ${r.head.value}`)}return new w(new l(2,t),[b(e.args[1])])}default:{let r=R(e.head),t=$.includes(r.value.substring(1))||G.includes(r.value.substring(1));return r.value.length>0&&t?new w(r,e.args.map(b)):new y([R(e.head).toNode(),new l(1,"(").toNode(),...Ce(e.args.map(b),Mt),new l(1,")").toNode()])}}}case"markupFunc":{let e=n;switch(e.head.value){case"#text":if(e.options&&e.options.fill){let r=e.options.fill;return new w(new l(2,"\\textcolor"),[b(r),b(e.fragments[0])])}case"#heading":default:throw new Error(`Unimplemented markup function: ${e.head.value}`)}}case"supsub":{let e=n,{base:r,sup:t,sub:s}=e,o=t?b(t):null,i=s?b(s):null;if(r.head.eq(new a(1,"limits"))){let h=b(r.args[0]);if(o!==null&&i===null)return new w(new l(2,"\\overset"),[o,h]);if(o===null&&i!==null)return new w(new l(2,"\\underset"),[i,h]);{let d=new w(new l(2,"\\underset"),[i,h]);return new w(new l(2,"\\overset"),[o,d])}}let u=b(r);return new A({base:u,sup:o,sub:i})}case"matrixLike":{let e=n,r=e.matrix.map(t=>t.map(b));if(e.head.eq(E.MAT)){let t="pmatrix";if(e.options&&"delim"in e.options){let s=e.options.delim;switch(s.head.value){case"#none":t="matrix";break;case"[":case"]":t="bmatrix";break;case"(":case")":t="pmatrix";break;case"{":case"}":t="Bmatrix";break;case"|":t="vmatrix";break;case"bar":case"bar.v":t="vmatrix";break;case"bar.v.double":t="Vmatrix";break;default:throw new Error(`Unexpected delimiter ${s.head}`)}}return new L(new l(3,t),r)}else{if(e.head.eq(E.CASES))return new L(new l(3,"cases"),r);throw new Error(`Unexpected matrix type ${e.head}`)}}case"fraction":{let e=n,[r,t]=e.args,s=b(r),o=b(t);return new w(new l(2,"\\frac"),[s,o])}default:throw new Error("[convert_typst_node_to_tex] Unimplemented type: "+n.type)}}var Lt=Array.from(ae.keys());function _t(){return`(${Lt.map(e=>(e=e.replaceAll("|","\\|"),e=e.replaceAll(".","\\."),e=e.replaceAll("[","\\["),e=e.replaceAll("]","\\]"),e)).join("|")})`}var kt=_t(),Ot=new Map([[String.raw`//[^\n]*`,n=>new a(5,n.text().substring(2))],[String.raw`/`,n=>new a(2,n.text())],[String.raw`[_^&]`,n=>new a(7,n.text())],[String.raw`\r?\n`,n=>new a(8,`
11
+ `)],[String.raw`\s+`,n=>new a(6,n.text())],[String.raw`\\[$&#_]`,n=>new a(2,n.text())],[String.raw`\\\n`,n=>[new a(7,"\\"),new a(8,`
12
+ `)]],[String.raw`\\\s`,n=>[new a(7,"\\"),new a(6," ")]],[String.raw`\\\S`,n=>new a(7,"")],[String.raw`"([^"]|(\\"))*"`,n=>{let e=n.text().substring(1,n.text().length-1);return e.replaceAll('\\"','"'),new a(4,e)}],[kt,n=>{let e=n.text(),r=ae.get(e);return new a(1,r)}],[String.raw`[0-9]+(\.[0-9]+)?`,n=>new a(2,n.text())],[String.raw`[+\-*/=\'<>!.,;?()\[\]|]`,n=>new a(2,n.text())],[String.raw`#h\((.+?)\)`,n=>{let e=n.reMatchArray();return[new a(1,"#h"),new a(2,"("),new a(3,e[1]),new a(2,")")]}],[String.raw`#none`,n=>new a(0,n.text())],[String.raw`#?[a-zA-Z\.]+`,n=>new a(n.text().length===1?2:1,n.text())],[String.raw`.`,n=>new a(2,n.text())]]),St={start:Ot};function $e(n){return new D(St).collect(n)}function Ge(n,e){let r=e;for(;r<n.length&&n[r].eq(new a(2,"'"));)r+=1;return r-e}function ke(n,e,r,t){T(n[e].isOneOf(r));let s=1,o=e+1;for(;s>0;){if(o>=n.length)throw new Error("Unmatched brackets or parentheses");n[o].isOneOf(t)?s-=1:n[o].isOneOf(r)&&(s+=1),o+=1}return o-1}function Q(n,e){return ke(n,e,[U,Ve,Bt],[Le,Ze,Pt])}function At(n,e){return ke(n,e,a.LEFT_DELIMITERS,a.RIGHT_DELIMITERS)}function Ct(n,e){let r=new a(2,"(").toNode(),t=new a(2,")").toNode();T(n[e].eq(r));let s=1,o=e+1;for(;s>0;){if(o>=n.length)throw new Error("Unmatched '('");n[o].eq(r)?s+=1:n[o].eq(t)&&(s-=1),o+=1}return o-1}function Xe(n){let e=[];for(let r=0;r<n;r++)e.push(new a(2,"'").toNode());return e}var he=new a(2,"/").toNode();function Rt(n,e){let r=e;for(;r<n.length&&(n[r].head.type===6||n[r].head.type===8);)r++;return r===n.length?null:n[r]}function It(n){let e=!1,r=[];for(let t=0;t<n.length;t++){let s=n[t];(s.head.type===6||s.head.type===8)&&(e||Rt(n,t+1)?.eq(he))||(s.eq(he)?e=!0:e=!1,r.push(s))}return r}function ce(n,e=!1){n=It(n);let r=U.toNode(),t=Le.toNode(),s=[],o=[],i=0;for(;i<n.length;){let p=n[i];if(p.eq(t))throw new H("Unexpected ')'");if(p.eq(he))s.push(p),i++;else{let c;if(p.eq(r)){let h=Ct(n,i);c=ce(n.slice(i+1,h),!0),i=h+1}else c=p,i++;if(s.length>0&&s[s.length-1].eq(he)){let h=c;if(o.length===0)throw new H("Unexpected '/' operator, no numerator before it");let d=o.pop();h.type==="leftright"&&(h=h.body),d.type==="leftright"&&(d=d.body),o.push(new B([d,h])),s.pop()}else o.push(c)}}let u=o.length===1?o[0]:new _(o);return e?new q(null,{body:u,left:U,right:Le}):u}function Dt(n){let e=new a(2,":").toNode(),r={};for(let t of n)T(t.items.length==3),T(t.items[1].eq(e)),r[t.items[0].toString()]=new Z(new a(3,t.items[2].toString()));return r}var H=class extends Error{constructor(e){super(e),this.name="TypstParserError"}},je=new a(7,"_"),Ke=new a(7,"^"),U=new a(2,"("),Le=new a(2,")"),Ve=new a(2,"["),Ze=new a(2,"]"),Bt=new a(2,"{"),Pt=new a(2,"}"),Me=new a(2,","),zt=new a(2,";"),Yt=new a(6," "),Wt=new a(7,"&"),_e=class{space_sensitive;newline_sensitive;constructor(e=!0,r=!0){this.space_sensitive=e,this.newline_sensitive=r}parse(e){let[r,t]=this.parseGroup(e,0,e.length);return r}parseGroup(e,r,t,s=!1){let o=[],i=r;for(;i<t;){let[p,c]=this.parseNextExpr(e,i);i=c,!((p.head.type===6||p.head.type===8)&&(!this.space_sensitive&&p.head.value.replace(/ /g,"").length===0||!this.newline_sensitive&&p.head.value===`
13
+ `))&&o.push(p)}let u;return s?u=ce(o,!0):o.length===1?u=o[0]:u=ce(o),[u,t+1]}parseNextExpr(e,r){let[t,s]=this.parseNextExprWithoutSupSub(e,r),o=null,i=null,u=Ge(e,s);if(u>0&&(t=new _([t].concat(Xe(u))),s+=u),s<e.length&&e[s].eq(je)?([o,s]=this.parseSupOrSub(e,s+1),s<e.length&&e[s].eq(Ke)&&([i,s]=this.parseSupOrSub(e,s+1))):s<e.length&&e[s].eq(Ke)&&([i,s]=this.parseSupOrSub(e,s+1),s<e.length&&e[s].eq(je)&&([o,s]=this.parseSupOrSub(e,s+1))),o!==null||i!==null){let p={base:t,sup:i,sub:o};return[new S(p),s]}else return[t,s]}parseSupOrSub(e,r){let t,s;if(e[r].eq(U)){let i=Q(e,r);[t,s]=this.parseGroup(e,r+1,i)}else[t,s]=this.parseNextExprWithoutSupSub(e,r);let o=Ge(e,s);return o>0&&(t=new _([t].concat(Xe(o))),s+=o),[t,s]}parseNextExprWithoutSupSub(e,r){let t=e[r],s=t.toNode();if(t.eq(U)){let o=Q(e,r);return this.parseGroup(e,r+1,o,!0)}if(t.type===2&&!Se(t.value[0]))return[s,r+1];if([2,1].includes(t.type)&&r+1<e.length&&e[r+1].eq(U)){if(t.value==="mat"){let[p,c,h]=this.parseMatrix(e,r+1,zt,Me),d=new E(t,p);return d.setOptions(c),[d,h]}if(t.value==="cases"){let[p,c,h]=this.parseMatrix(e,r+1,Me,Wt),d=new E(t,p);return d.setOptions(c),[d,h]}if(t.value==="lr")return this.parseLrArguments(e,r+1);if(["#heading","#text"].includes(t.value)){let[p,c]=this.parseArguments(e,r+1),h=Dt(p);T(e[c].eq(Ve));let d=new a(2,"$"),k=ke(e,c+1,[d],[d]),[J,I]=this.parseGroup(e,c+2,k);T(e[k+1].eq(Ze));let ee=new P(t,[J]);return ee.setOptions(h),[ee,k+2]}let[o,i]=this.parseArguments(e,r+1);return[new f(t,o),i]}return[s,r+1]}parseArguments(e,r){let t=Q(e,r);return[this.parseArgumentsWithSeparator(e,r+1,t,Me),t+1]}parseLrArguments(e,r){let t=e[r],s=Q(e,r);if(e[r+1].isOneOf(a.LEFT_DELIMITERS)){let o=r+1,i=At(e,o),[u,p]=this.parseGroup(e,o+1,i);return[new q(t,{body:u,left:e[o],right:e[i]}),s+1]}else{let[o,i]=this.parseGroup(e,r+1,s-1);return[new q(t,{body:o,left:null,right:null}),s+1]}}parseMatrix(e,r,t,s){let o=Q(e,r);e=e.slice(0,o);let i=[],u={},p=r+1;for(;p<o;)for(;p<o;){let J=function(I){let ee=new a(2,":").toNode(),Oe={},Te=[];for(let v=0;v<I.length;v++){if(I[v].type!=="group")continue;let te=I[v],re=F(te.items,ee);if(re===-1||re===0)continue;if(Te.push(v),te.items[re-1].eq(new a(1,"delim").toNode())){if(te.items.length!==3)throw new H("Invalid number of arguments for delim");Oe.delim=te.items[re+1]}else throw new H("Not implemented for other named parameters")}for(let v=Te.length-1;v>=0;v--)I.splice(Te[v],1);return[I,Oe]};var c=J;let h=F(e,t,p);h===-1&&(h=o);let d=this.parseArgumentsWithSeparator(e,p,h,s),k={};[d,k]=J(d),i.push(d),Object.assign(u,k),p=h+1}return[i,u,o+1]}parseArgumentsWithSeparator(e,r,t,s){let o=[],i=r;for(;i<t;){let u=[];for(;i<t;){if(e[i].eq(s)){i+=1;break}else if(e[i].eq(Yt)){i+=1;continue}let[c,h]=this.parseNextExpr(e,i);i=h,u.push(c)}let p;u.length===1?p=u[0]:p=ce(u),o.push(p)}return o}};function Qe(n){let e=new _e,r=$e(n);return e.parse(r)}var de=class{buffer="";queue=[];append(e){this.queue=this.queue.concat(e.serialize())}flushQueue(){for(let e=0;e<this.queue.length;e++)this.buffer=we(this.buffer,this.queue[e]);this.queue=[]}finalize(){return this.flushQueue(),this.buffer}};function Je(n,e){let r={nonStrict:!0,preferShorthands:!0,keepSpaces:!1,fracToSlash:!0,inftyToOo:!1,optimize:!0,customTexMacros:{}};if(e!==void 0){if(typeof e!="object")throw new Error("options must be an object");for(let i in r)i in e&&(r[i]=e[i])}let t=Ue(n,r.customTexMacros),s=m(t,r),o=new ue(r);return o.serialize(s),o.finalize()}function et(n){let e=Qe(n),r=b(e),t=new de;return t.append(r),t.finalize()}window.tex2typst=Je;window.typst2tex=et;})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tex2typst",
3
- "version": "0.3.27",
3
+ "version": "0.3.28",
4
4
  "description": "JavaScript library for converting TeX code to Typst",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/convert.ts CHANGED
@@ -232,12 +232,6 @@ export function convert_tex_node_to_typst(abstractNode: TexNode, options: Tex2Ty
232
232
  }
233
233
  case 'text': {
234
234
  const node = abstractNode as TexText;
235
- if ((/[^\x00-\x7F]+/).test(node.head.value) && options.nonAsciiWrapper !== "") {
236
- return new TypstFuncCall(
237
- new TypstToken(TypstTokenType.SYMBOL, options.nonAsciiWrapper!),
238
- [new TypstToken(TypstTokenType.TEXT, node.head.value).toNode()]
239
- );
240
- }
241
235
  return new TypstToken(TypstTokenType.TEXT, node.head.value).toNode();
242
236
  }
243
237
  case 'ordgroup':
@@ -397,6 +391,40 @@ export function convert_tex_node_to_typst(abstractNode: TexNode, options: Tex2Ty
397
391
  return arg0;
398
392
  }
399
393
 
394
+ // \displaylines{...} -> ...
395
+ if (node.head.value === '\\displaylines') {
396
+ return arg0;
397
+ }
398
+
399
+ // \mathinner{...} -> ...
400
+ if (node.head.value === '\\mathinner') {
401
+ return arg0;
402
+ }
403
+
404
+ // \mathrel{X} -> class("relation", X)
405
+ if (node.head.value === '\\mathrel') {
406
+ return new TypstFuncCall(
407
+ new TypstToken(TypstTokenType.SYMBOL, 'class'),
408
+ [new TypstToken(TypstTokenType.TEXT, 'relation').toNode(), arg0]
409
+ );
410
+ }
411
+
412
+ // \mathbin{X} -> class("binary", X)
413
+ if (node.head.value === '\\mathbin') {
414
+ return new TypstFuncCall(
415
+ new TypstToken(TypstTokenType.SYMBOL, 'class'),
416
+ [new TypstToken(TypstTokenType.TEXT, 'binary').toNode(), arg0]
417
+ );
418
+ }
419
+
420
+ // \mathop{X} -> class("large", X)
421
+ if (node.head.value === '\\mathop') {
422
+ return new TypstFuncCall(
423
+ new TypstToken(TypstTokenType.SYMBOL, 'class'),
424
+ [new TypstToken(TypstTokenType.TEXT, 'large').toNode(), arg0]
425
+ );
426
+ }
427
+
400
428
  // \set{a, b, c} -> {a, b, c}
401
429
  if (node.head.value === '\\set') {
402
430
  return new TypstLeftright(
@@ -748,6 +776,31 @@ export function convert_typst_node_to_tex(abstractNode: TypstNode): TexNode {
748
776
  assert(arg0.head.type === TypstTokenType.TEXT);
749
777
  return new TexFuncCall(typst_token_to_tex(node.head), [new TexToken(TexTokenType.LITERAL, arg0.head.value).toNode()]);
750
778
  }
779
+ case 'class': {
780
+ const arg0 = node.args[0];
781
+ assert(arg0.head.type === TypstTokenType.TEXT);
782
+ let command: string;
783
+ switch (arg0.head.value) {
784
+ // \mathrel{X} <- class("relation", X)
785
+ case 'relation':
786
+ command = '\\mathrel';
787
+ break;
788
+ // \mathbin{X} <- class("binary", X)
789
+ case 'binary':
790
+ command = '\\mathbin';
791
+ break;
792
+ // \mathop{X} <- class("large", X)
793
+ case 'large':
794
+ command = '\\mathop';
795
+ break;
796
+ default:
797
+ throw new Error(`Unimplemented class: ${arg0.head.value}`);
798
+ }
799
+ return new TexFuncCall(
800
+ new TexToken(TexTokenType.COMMAND, command),
801
+ [convert_typst_node_to_tex(node.args[1])]
802
+ );
803
+ }
751
804
  // general case
752
805
  default: {
753
806
  const func_name_tex = typst_token_to_tex(node.head);
@@ -12,7 +12,6 @@ export interface Tex2TypstOptions {
12
12
  fracToSlash?: boolean; /** default is true */
13
13
  inftyToOo?: boolean; /** default is false */
14
14
  optimize?: boolean; /** default is true */
15
- nonAsciiWrapper?: string; /** default is "" */
16
15
  customTexMacros?: { [key: string]: string; };
17
16
  }
18
17
 
package/src/generic.ts CHANGED
@@ -59,6 +59,22 @@ export function array_split<T extends IEquatable>(array: T[], sep: T): T[][] {
59
59
  return res;
60
60
  }
61
61
 
62
+ // e.g. input array=[['a', 'b'], ['c'], ['d', 'e']], sep = '+'
63
+ // return ['a', 'b', '+', 'c', '+', 'd', 'e']
64
+ export function array_join<T>(arrays: T[][], sep: T): T[] {
65
+ /*
66
+ const res: T[] = [];
67
+ for (let i = 0; i < arrays.length; i++) {
68
+ res.push(...arrays[i]);
69
+ if (i !== arrays.length - 1) {
70
+ res.push(sep);
71
+ }
72
+ }
73
+ return res;
74
+ */
75
+ return arrays.flatMap((arr, i) => i !== arrays.length - 1? [...arr, sep]: arr);
76
+ }
77
+
62
78
  // e.g. input array=['a', 'b', 'c'], sep = '+'
63
79
  // return ['a','+', 'b', '+','c']
64
80
  export function array_intersperse<T>(array: T[], sep: T): T[] {