fika-editor 3.0.40 → 3.0.42
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.
- package/dist/embed/agentic-manifest.json +2 -2
- package/dist/embed/chunks/2020.js +46 -46
- package/dist/embed/fika-embed.css +1 -1
- package/dist/embed/fika-embed.js +3 -3
- package/dist/types/embed/reveal.d.ts +32 -0
- package/dist/types/embed/types.d.ts +19 -0
- package/dist/types/store/main.d.ts +18 -0
- package/dist/types/utils/math.d.ts +3 -2
- package/dist/types/utils/portal.d.ts +5 -2
- package/dist/types/utils/revealHtml.d.ts +12 -0
- package/dist/types/views/Editor/Canvas/AiRevealBadge.d.ts +11 -0
- package/docs/EMBED.md +4 -0
- package/package.json +2 -2
|
@@ -188,7 +188,7 @@ M93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z`
|
|
|
188
188
|
c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,
|
|
189
189
|
-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6
|
|
190
190
|
c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z
|
|
191
|
-
M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`},od=[[8205,1],[65038,2],[127995,5],[129456,4],[917536,96]];function ou(e){var i;if(void 0===on)for(let e of(on={},od))for(let i=e[0];i<=e[0]+e[1]-1;i++)on[i]=!0;return null!=(i=on[e])&&i}function oh(e){if(/^[\u0020-\u00FF]*$/.test(e))return e;let i=[],r=function(e){let i=[];for(let r=0;r<e.length;r++){let a=e.charCodeAt(r);if(13===a&&10===e.charCodeAt(r+1)&&(a=10,r++),(13===a||12===a)&&(a=10),0===a&&(a=65533),a>=55296&&a<=56319){let i=e.charCodeAt(r+1);i>=56320&&i<=57343&&(a=65536+1024*(a-55296)+(i-56320),r++)}i.push(a)}return i}(e),a=0;for(;a<r.length;){let e=r[a++],o=r[a];if(8205===o){let e=a-1;for(a+=2;8205===r[a];)a+=2;i.push(String.fromCodePoint(...r.slice(e,a-e+1)))}else if(ou(o)){let e=a-1;for(;ou(r[a]);)a+=8205===r[a]?2:1;i.push(String.fromCodePoint(...r.slice(e,2*a-e-1)))}else e>=127462&&e<=127487?(a+=1,i.push(String.fromCodePoint(...r.slice(a-2,2)))):i.push(String.fromCodePoint(e))}return i}var op=class{constructor(e){this.obeyspaces=!1,this.pos=0,this.s=oh(e)}end(){return this.pos>=this.s.length}get(){return this.pos<this.s.length?this.s[this.pos++]:""}peek(){return this.s[this.pos]}match(e){let i="string"==typeof this.s?e.exec(this.s.slice(this.pos)):e.exec(this.s.slice(this.pos).join(""));return null!=i&&i[0]?(this.pos+=i[0].length,i[0]):""}next(){if(this.end())return null;if(!this.obeyspaces&&this.match(/^[ \f\n\r\t\v\u00A0\u2028\u2029]+/)||this.obeyspaces&&this.match(/^[ \f\n\r\t\v\u00A0\u2028\u2029]/))return"<space>";let e=this.get();if("\\"===e){if(!this.end()){let e=this.match(/^[a-zA-Z\*]+/);return e?this.match(/^[ \f\n\r\t\v\u00A0\u2028\u2029]*/):e=this.get(),"\\"+e}}else{if("{"===e)return"<{>";if("}"===e)return"<}>";if("^"===e){if("^"===this.peek()){this.get();let e=this.match(/^(\^(\^(\^(\^[\da-f])?[\da-f])?[\da-f])?[\da-f])?[\da-f]{2}/);if(e)return String.fromCodePoint(Number.parseInt(e.slice(e.lastIndexOf("^")+1),16))}}else if("#"===e){if(!this.end()){let e=!1;if(/[\d?@]/.test(this.peek())&&(e=!0,this.pos+1<this.s.length)){let i=this.s[this.pos+1];e=/[^\dA-Za-z]/.test(i)}return e?"#"+this.get():"#"}}else if("$"===e)return"$"===this.peek()?(this.get(),"<$$>"):"<$>"}return e}};function om(e,i=null){if(!e)return[];let r=[],a="";for(let i of e.toString().split(/\r?\n/)){a&&r.push(a),a=" ";let e=i.match(/((?:\\%)|[^%])*/);null!==e&&r.push(e[0])}let o=new op(r.join("")),n=[];do n.push(...function(e,i){var r,a,o,n;let l=[],s=e.next();if(s&&"\\relax"!==s){if("\\noexpand"===s)(s=e.next())&&l.push(s);else if("\\obeyspaces"===s)e.obeyspaces=!0;else if("\\bgroup"===s)l.push("<{>");else if("\\egroup"===s)l.push("<}>");else if("\\string"===s){if(s=e.next())if(s.startsWith("\\"))for(let e of s)l.push("\\"===e?"\\backslash":e);else"<{>"===s?l.push("\\{"):"<space>"===s?l.push("~"):"<}>"===s&&l.push("\\}")}else if("\\csname"===s){for(;"<space>"===e.peek();)e.next();let o="",n=!1,c=[];do{if(0===c.length)if(/^#[\d?@]$/.test(e.peek())){let o=e.get().slice(1);s=(c=om(null!=(a=null!=(r=null==i?void 0:i(o))?r:null==i?void 0:i("?"))?a:"\\placeholder{}",i))[0]}else c=(s=e.next())?[s]:[];(n=0===c.length)||"\\endcsname"!==s||(n=!0,c.shift()),n||(n="<$>"===s||"<$$>"===s||"<{>"===s||"<}>"===s||"string"==typeof s&&s.length>1&&s.startsWith("\\")),n||(o+=c.shift())}while(!n)o&&l.push("\\"+o),l.push(...c)}else if("\\endcsname"!==s)if(s.length>1&&s.startsWith("#")){let e=s.slice(1);l.push(...om(null!=(n=null!=(o=null==i?void 0:i(e))?o:null==i?void 0:i("?"))?n:"\\placeholder{}",i))}else l.push(s)}return l}(o,i));while(!o.end())return n}function of(e){let i="",r=[];for(let a of e)a&&(i&&/^[a-zA-Z\*]/.test(a)&&r.push(i),r.push(a),/^\\[a-zA-Z]+\*?[\"\'][^\ ]+$/.test(a)&&r.push(" "),i=/\\[a-zA-Z]+\*?$/.test(a)?" ":"");return r.join("")}function og(e,...i){return e.startsWith("\\"),0===i.length?e:of([e,...i.map(e=>`{${e}}`)])}function ob(e){return of(e.map(e=>{var i;return null!=(i=({"<space>":" ","<$$>":"$$","<$>":"$","<{>":"{","<}>":"}"})[e])?i:e}))}var oy=class e{constructor(i){e._registry[i]=this}static createAtom(i,r,a){return e._registry[i].createAtom(r,eM(r,i),a)}static serialize(i,r){var a;if(!i||0===i.length)return"";if(null!=(a=r.skipStyles)&&a){let a=[];for(let o of ox(i)){let i=e._registry[o[0].mode];a.push(...i.serialize(o,r))}return of(a)}return of(function(e,i){if(0===e.length)return[];let{parent:r}=e[0],a=null==r?void 0:r.style.fontSize,o=[];for(let n of ok(e,"fontSize")){let e=n[0].style.fontSize,l=function(e,i){let{parent:r}=e[0],a=null==r?void 0:r.style.backgroundColor;return ok(e,"backgroundColor").map(e=>{var o;if(e.length>0||"box"!==e[0].type){let n=e[0].style;if(n.backgroundColor&&"none"!==n.backgroundColor&&(!r||a!==n.backgroundColor))return og("\\colorbox",null!=(o=n.verbatimBackgroundColor)?o:n.backgroundColor,of(oM(e,g(f({},i),{defaultMode:"text"}))))}return of(oM(e,i))})}(n,i);l&&(e&&"auto"!==e&&(!r||a!==e)?o.push(["","\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"][e],...l):o.push(...l))}return o}(i,r))}static getFont(i,r,a){return e._registry[i].getFont(r,a)}};oy._registry={};var ov=oy;function ox(e){let i=[],r=[],a="NONE";for(let o of e)"first"!==o.type&&(o.mode!==a?(r.length>0&&i.push(r),r=[o],a=o.mode):r.push(o));return r.length>0&&i.push(r),i}function o_(e){if((null==e?void 0:e.mode)!=="math")return"";let{style:i}=e;return i&&i.variantStyle&&("bold"===i.variantStyle||"bolditalic"===i.variantStyle)?"bold":""}function ow(e){if(!e)return"";let{style:i}=e;if(!i)return"";let r=i.variant;return void 0===r&&(r="normal"),!["calligraphic","fraktur","double-struck","script","monospace","sans-serif"].includes(r)&&i.variantStyle&&(r+="-"+i.variantStyle),r}function ok(e,i){let r=[],a=[],o;for(let n of e){let e;"first"!==n.type&&((e="variant"===i?ow(n):"bold"===i?o_(n):n.style[i])===o?a.push(n):(a.length>0&&r.push(a),a=[n],o=e))}return a.length>0&&r.push(a),r}function oM(e,i){var r;let{parent:a}=e[0],o=null==a?void 0:a.style.color,n=[];for(let l of ox(e)){let e=i.defaultMode;for(let s of ok(l,"color")){let l=s[0].style,c=ov._registry[s[0].mode].serialize(s,g(f({},i),{defaultMode:"text"===e?"text":"math"}));i.skipStyles||!l.color||"none"===l.color||a&&o===l.color?n.push(of(c)):n.push(og("\\textcolor",null!=(r=l.verbatimColor)?r:l.color,of(c)))}}return n}function oS(e){return e?({mord:"ord",mbin:"bin",mop:"op",mrel:"rel",mopen:"open",mclose:"close",mpunct:"punct",minner:"inner",spacing:"ignore",newline:"newline",latex:"latex",composition:"inner",error:"inner",placeholder:"ord",supsub:"ignore"})[e]:void 0}function oL(e){if(0===e.length)return"ord";let i=oS(e[0].type),r=oS(e[e.length-1].type);return i&&i===r?i:"ord"}function oC(e,i){if("string"==typeof e)return e;if("number"==typeof e){Number.isFinite(e);let r=Math.ceil(100*e)/100;return 0===r?"0":r.toString()+(null!=i?i:"")}return""}var oE=class e{constructor(i,r){var a,o,n,l,s;if("number"==typeof i?this.value=String.fromCodePoint(i):"string"==typeof i?this.value=i:R(i)?this.children=i.filter(e=>null!==e):i&&i instanceof e&&(this.children=[i]),this.children)for(let e of this.children)e.parent=this;this.type=null!=(a=null==r?void 0:r.type)?a:"ignore",this.isSelected=(null==r?void 0:r.isSelected)===!0,null!=r&&r.caret&&(this.caret=r.caret),this.classes=null!=(o=null==r?void 0:r.classes)?o:"",this.isTight=null!=(n=null==r?void 0:r.isTight)&&n,null!=r&&r.attributes&&(this.attributes=r.attributes);let c=null==r?void 0:r.fontFamily;null!=r&&r.style&&this.value&&(c=null!=(s=ov.getFont(null!=(l=r.mode)?l:"math",this,g(f({variant:"normal"},r.style),{letterShapeStyle:r.letterShapeStyle})))?s:void 0),c||(c="Main-Regular"),this._height=0,this._depth=0,this._width=0,this.hasExplicitWidth=!1,this.skew=0,this.italic=0,this.maxFontSize=0,this.scale=1,(null==r?void 0:r.maxFontSize)!==void 0&&(this.maxFontSize=r.maxFontSize),function(e,i){var r;if("latex"===e.type){e.height=.9,e.depth=.2,e._width=1;return}if(e.value){e.height=-1/0,e.depth=-1/0,e._width=0,e.skew=-1/0,e.italic=-1/0;for(let r=0;r<e.value.length;r++){let a=oa(e.value.codePointAt(r),i);e.height=Math.max(e.height,a.height),e.depth=Math.max(e.depth,a.depth),e._width+=a.width,e.skew=a.skew,e.italic=a.italic}return}if(e.children&&e.children.length>0){let i=-1/0,a=-1/0,o=0;for(let n of e.children)n.height>i&&(i=n.height),n.depth>a&&(a=n.depth),o=Math.max(o,null!=(r=n.maxFontSize)?r:0);e.height=i,e.depth=a,e._width=e.children.reduce((e,i)=>e+i.width,0),e.maxFontSize=o}}(this,c)}set atomID(e){void 0===e||0===e.length||(this.id=e)}selected(e){if(this.isSelected!==e&&(this.isSelected=e,this.children))for(let i of this.children)i.selected(e)}setStyle(e,i,r){if(void 0===i)return;let a=oC(i,r);a.length>0&&(this.cssProperties||(this.cssProperties={}),this.cssProperties[e]=a)}setTop(e){Number.isFinite(e)&&Math.abs(e)>.01&&(this.cssProperties||(this.cssProperties={}),this.cssProperties.top=oC(e,"em"),this.height-=e,this.depth+=e)}get left(){var e;return null!=(e=this.cssProperties)&&e["margin-left"]?Number.parseFloat(this.cssProperties["margin-left"]):0}set left(e){Number.isFinite(e)&&(0===e?this.cssProperties&&delete this.cssProperties["margin-left"]:(this.cssProperties||(this.cssProperties={}),this.cssProperties["margin-left"]=oC(e,"em")))}set right(e){Number.isFinite(e)&&(0===e?this.cssProperties&&delete this.cssProperties["margin-right"]:(this.cssProperties||(this.cssProperties={}),this.cssProperties["margin-right"]=oC(e,"em")))}set bottom(e){Number.isFinite(e)&&(0===e?this.cssProperties&&delete this.cssProperties["margin-bottom"]:(this.cssProperties||(this.cssProperties={}),this.cssProperties["margin-bottom"]=oC(e,"em")))}get width(){return this._width*this.scale}set width(e){this._width=e,this.hasExplicitWidth=!0}set softWidth(e){}get height(){return this._height*this.scale}set height(e){this._height=e}get depth(){return this._depth*this.scale}set depth(e){this._depth=e}wrap(e){let i=e.parent;if(!i)return this;e.isPhantom&&this.setStyle("opacity",0);let r=e.color;r&&r!==i.color&&this.setStyle("color",r);let a=e.backgroundColor;this.isSelected&&(a=function(e){let i=function(e){let i;if(e&&"#"===e[0])return(e=e.slice(1)).length<=4?(i={r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16)},4===e.length&&(i.a=parseInt(e[3]+e[3],16)/255)):(i={r:parseInt(e[0]+e[1],16),g:parseInt(e[2]+e[3],16),b:parseInt(e[4]+e[5],16)},8===e.length&&(i.a=parseInt(e[6]+e[7],16)/255)),i&&void 0===i.a&&(i.a=1),i}(e);if(!i)return e;let{h:r,s:a,l:o}=function(e){let{r:i,g:r,b:a}=e;i/=255;let o=Math.min(i,r/=255,a/=255),n=Math.max(i,r,a),l=n-o,s;n===o?s=0:i===n?s=(r-a)/l:r===n?s=2+(a-i)/l:a===n&&(s=4+(i-r)/l),(s=Math.min(60*s,360))<0&&(s+=360);let c=(o+n)/2;return{h:s,s:n===o?0:c<=.5?l/(n+o):l/(2-n-o),l:c}}(i);return function(e){let{r:i,g:r,b:a}=e,o=(0x1000000+(G(i)<<16)+(G(r)<<8)+G(a)).toString(16).slice(1);return o[0]===o[1]&&o[2]===o[3]&&o[4]===o[5]&&o[6]===o[7]&&(o=o[0]+o[2]+o[4]),"#"+o}(function(e){let[i,r,a]=[e.h,e.s,e.l];i=(i+360)%360/60,a=Math.max(0,Math.min(a,1)),r=Math.max(0,Math.min(r,1));let o=a<=.5?a*(r+1):a+r-a*r,n=2*a-o;return{r:Math.round(255*X(n,o,i+2)),g:Math.round(255*X(n,o,i)),b:Math.round(255*X(n,o,i-2))}}({h:r,s:a+=.1,l:o-=.1}))}(a)),a&&a!==i.backgroundColor&&(this.setStyle("background-color",a),this.setStyle("--bg-color",a),this.setStyle("display","inline-block"),this.setStyle("position","relative"),this.classes=this.classes?`${this.classes} ML__bg`:"ML__bg");let o=e.scalingFactor;return this.scale=o,this.skew*=o,this.italic*=o,this}toMarkup(){var e,i,r;let a=this.value?this.value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"):"";if(this.children)for(let e of this.children)a+=e.toMarkup();let o="";if(this.svgBody)o=function(e){if(os[e]){let[i,r,a]=os[e],o=`<span class="ML__stretchy" style="height:${a}em"><svg width="100%" height="${a}em" viewBox="0 0 ${i} ${r}" preserveAspectRatio="none" ><path fill="currentcolor" d="${oc[e]}"></path></svg></span>`;return`<span style="display:inline-block;height:${Math.floor(100*a/2)/100}em;min-width:0">${o}</span>`}let[i,r,a,o]=ol[e],n,l,s=a/1e3;3===i.length?(n=["slice-1-of-3","slice-2-of-3","slice-3-of-3"],l=["xMinYMin","xMidYMin","xMaxYMin"]):2===i.length?(n=["slice-1-of-2","slice-2-of-2"],l=["xMinYMin","xMaxYMin"]):(n=["slice-1-of-1"],l=[o]);let c=i.map((e,i)=>`<span class="${n[i]}" style=height:${s}em><svg width=400em height=${s}em viewBox="0 0 400000 ${a}" preserveAspectRatio="${l[i]} slice"><path fill="currentcolor" d="${oc[e]}"></path></svg></span>`).join("");return`<span style="display:inline-block;height:${s}em;min-width:${r}em;">${c}</span>`}(this.svgBody);else if(this.svgOverlay){o=`<span style="display: inline-block;height:${Math.floor(100*(this.height+this.depth))/100}em;vertical-align:${Math.floor(100*this.depth)/100}em;">`+a+'</span><svg style="position:absolute;overflow:visible;'+`height:${Math.floor(100*(this.height+this.depth))/100}em;`;let i=null==(e=this.cssProperties)?void 0:e.padding;i?(o+=`top:${i};`,o+=`left:${i};`,o+=`width:calc(100% - 2 * ${i} );`):o+="top:0;left:0;width:100%;",o+="z-index:2;",o+='"',this.svgStyle&&(o+=this.svgStyle),o+=` viewBox="0 0 ${Math.floor(100*this.width)/100} ${Math.floor(100*(this.height+this.depth))/100}"`,o+=`>${this.svgOverlay}</svg>`}let n=[],l=this.classes.split(" ");l.push(null!=(i=({latex:"ML__raw-latex",placeholder:"ML__placeholder",error:"ML__error"})[this.type])?i:""),"latex"===this.caret&&l.push("ML__latex-caret"),this.isSelected&&l.push("ML__selected");let s=1===l.length?l[0]:l.filter((e,i,r)=>e.length>0&&r.indexOf(e)===i).join(" ");if(s.length>0&&n.push(`class=${oK(`"${s}"`)}`),this.id&&n.push(` data-atom-id=${oK(this.id)}`),this.cssId&&n.push(` id=${oK(`"${this.cssId.replace(/ /g,"-")}"`)}`),this.attributes&&n.push(...Object.keys(this.attributes).map(e=>`${oD(e)}=${oK(this.attributes[e])}`)),this.htmlData)for(let e of this.htmlData.split(",")){let i=e.match(/([^=]+)=(.+$)/);if(i){let e=oD(i[1]);if(e)if("href"===e){let e=new URL(i[2]);if("http:"!==e.protocol&&"https:"!==e.protocol)throw Error(`Invalid URL: ${i[2]}`);n.push(`href="${i[2].replace(/"/g,""")}"`)}else n.push(`data-${e}=${oK(i[2])}`)}else{let i=oD(e);i&&n.push(`data-${i} `)}}let c=null!=(r=this.cssProperties)?r:{};this.hasExplicitWidth&&void 0===c.width&&(c.width=`${Math.ceil(100*this._width)/100}em`);let d=Object.keys(c).map(e=>`${e}:${c[e]}`);if(void 0!==this.scale&&1!==this.scale&&(a.length>0||o.length>0)&&d.push(`font-size: ${Math.ceil(1e4*this.scale)/100}%`),this.htmlStyle)for(let e of this.htmlStyle.split(";")){let i=e.match(/([^:]+):(.+$)/);if(i){let e=i[1].trim().replace(/ /g,"-");e&&d.push(`${e}:${i[2]}`)}}d.length>0&&n.push(`style=${oK(d.join(";"))}`);let u="";return u=n.length>0||o.length>0?`<span ${n.join(" ")}>${a}${o}</span>`:a,"text"===this.caret?u+='<span class="ML__text-caret"></span>':"math"===this.caret&&(u+='<span class="ML__caret"></span>'),u}tryCoalesceWith(e){if(this.svgBody||!this.value||e.svgBody||!e.value)return!1;let i=this.children&&this.children.length>0,r=e.children&&e.children.length>0;if(i||r)return!1;if(e.cssProperties||this.cssProperties){for(let i of["border","border-left","border-right","border-right-width","left","margin","margin-left","margin-right","padding","position","width"])if(e.cssProperties&&i in e.cssProperties||this.cssProperties&&i in this.cssProperties)return!1}let a=this.cssProperties?Object.keys(this.cssProperties).length:0;if(a!==(e.cssProperties?Object.keys(e.cssProperties).length:0))return!1;if(a>0){for(let i of Object.keys(this.cssProperties))if(this.cssProperties[i]!==e.cssProperties[i])return!1}let o=this.classes.trim().replace(/\s+/g," ").split(" "),n=e.classes.trim().replace(/\s+/g," ").split(" ");if(o.length!==n.length)return!1;for(let[e,i]of(o.sort(),n.sort(),o.entries()))if("ML__vertical-separator"===i||i!==n[e])return!1;return this.value+=e.value,this.height=Math.max(this.height,e.height),this.depth=Math.max(this.depth,e.depth),this._width=this._width+e._width,this.maxFontSize=Math.max(this.maxFontSize,e.maxFontSize),this.italic=e.italic,!0}};function oA(e){return e.children&&(e.children=function e(i){if(!i||0===i.length)return[];i[0].children=e(i[0].children);let r=[i[0]];for(let a=1;a<i.length;a++)r[r.length-1].tryCoalesceWith(i[a])||(i[a].children=e(i[a].children),r.push(i[a]));return r}(e.children)),e}function oz(e,i){if(!e)return new oE(null,i);let r=new oE(null,{classes:"ML__strut",type:"ignore"});r.setStyle("height",Math.max(0,e.height),"em");let a=[r];if(0!==e.depth){let i=new oE(null,{classes:"ML__strut--bottom",type:"ignore"});i.setStyle("height",e.height+e.depth,"em"),i.setStyle("vertical-align",-e.depth,"em"),a.push(i)}return a.push(e),new oE(a,g(f({},i),{type:"lift"}))}function oT(e){let i=(ol[e]?ol[e][2]/1e3:os[e][2])/2,r=new oE(null,{maxFontSize:0});return r.height=i+.166,r.depth=i-.166,r.svgBody=e,r}function oD(e){if(0===(e=e.trim().replace(/ /g,"-")).length)throw Error("Invalid empty attribute name");if(/[\x20\x09\x0a\x0c\x0d"'>/=\x00-\x1f]/.test(e))throw Error(`Invalid attribute name "${e}"`);return e}function oK(e){if((e=e.trim()).startsWith('"')&&e.endsWith('"')){if(/"/.test(e.slice(1,-1)))throw Error(`Invalid attribute value: ${e}`);return e}if(e.startsWith("'")&&e.endsWith("'")){if(/'/.test(e.slice(1,-1)))throw Error(`Invalid attribute value: ${e}`);return e}if(0===e.length)throw Error("Invalid empty attribute value");return`"${e.replace(/"/g,""")}"`}var oB=class extends oE{constructor(e,i){var r;let[a,o,n]=function(e){var i;let[r,a]=function(e){if("individualShift"in e){let i=e.individualShift,r=i[0];if(null==r)return[null,0];let a=[r],o=-r.shift-r.box.depth,n=o;for(let e=1;e<i.length;e++){let o=i[e],l=-o.shift-n-o.box.depth,s=l-(r.box.height+r.box.depth);n+=l,a.push(s),a.push(o),r=o}return[a,o]}if("top"in e){let i=e.top;for(let r of e.children)i-="number"==typeof r?r:r.box.height+r.box.depth;return[e.children,i]}if("bottom"in e)return[e.children,-e.bottom];if("firstBaseline"in e){let i=e.firstBaseline[0];if("number"==typeof i)throw Error("First child must be an element.");return[e.firstBaseline,-i.box.depth]}if("shift"in e){let i=e.children[0];if("number"==typeof i)throw Error("First child must be an element.");return[e.children,-i.box.depth-e.shift]}return[null,0]}(e);if(!r)return[[],0,0];let o=new oE(null,{classes:"ML__pstrut"}),n=0;for(let e of r)if("number"!=typeof e){let i=e.box;n=Math.max(n,i.maxFontSize,i.height)}o.height=n+=2,o.setStyle("height",n,"em");let l=[],s=a,c=a,d=a,u=0;for(let e of r){if("number"==typeof e)d+=e;else{let r=e.box,a=new oE([o,r],{classes:(null!=(i=e.classes)?i:[]).join(" "),style:e.style});r.setStyle("height",r.height+r.depth,"em"),r.setStyle("display","inline-block"),a.setStyle("top",-n-d-r.depth,"em"),e.marginLeft&&a.setStyle("margin-left",e.marginLeft,"em"),e.marginRight&&a.setStyle("margin-right",e.marginRight,"em"),l.push(a),d+=r.height+r.depth,u=Math.max(u,a.width)}s=Math.min(s,d),c=Math.max(c,d)}l.forEach(e=>{e.softWidth=u});let h=new oE(l,{classes:"ML__vlist"});if(h.softWidth=u,h.height=c,h.setStyle("height",c,"em"),s>=0)return[[new oE(h,{classes:"ML__vlist-r"})],c,-s];let p=new oE(new oE(null),{classes:"ML__vlist"});p.height=-s,p.setStyle("height",-s,"em");let m=new oE(8203,{classes:"ML__vlist-s",maxFontSize:0});return m.softWidth=0,m.height=0,m.depth=0,[[new oE([h,m],{classes:"ML__vlist-r"}),new oE(p,{classes:"ML__vlist-r"})],c,-s]}(e);super(1===a.length?a[0]:a,{type:null==i?void 0:i.type,classes:(null!=(r=null==i?void 0:i.classes)?r:"")+" ML__vlist-t"+(2===a.length?" ML__vlist-t2":"")}),this.height=o,this.depth=n,this.softWidth=a.reduce((e,i)=>Math.max(e,i.width),0)}},o$={fractionNavigationOrder:"numerator-denominator",compactSerialization:!0},oP=class{constructor(e,i,r){this.id=e,this.sizeDelta=i,this.cramped=r;let a={"-4":2,"-3":1,0:0}[i];this.metrics=Object.keys(ot).reduce((e,i)=>g(f({},e),{[i]:ot[i][a]}),{})}getFontSize(e){return Math.max(1,e+this.sizeDelta)}get sup(){return oR[[0,1,0,1,2,3,2,3][this.id]]}get sub(){return oR[[0,0,0,0,2,2,2,2][this.id]]}get fracNum(){return oR[[0,1,0,1,2,3,4,5][this.id]]}get fracDen(){return oR[[0,0,0,0,2,2,4,4][this.id]]}get cramp(){return oR[[0,0,2,2,4,4,6,6][this.id]]}get isTight(){return this.sizeDelta<0}},oO={7:new oP(7,0,!1),6:new oP(6,0,!0),5:new oP(5,0,!1),4:new oP(4,0,!0),3:new oP(3,-3,!1),2:new oP(2,-3,!0),1:new oP(1,-4,!1),0:new oP(0,-4,!0)},oR=g(f({},oO),{displaystyle:oO[7],textstyle:oO[5],scriptstyle:oO[3],scriptscriptstyle:oO[1]});function oI(e,i){var r;if(!e)return 0;let a={pt:1,mm:7227/2540,cm:7227/254,ex:35271/8192,px:.75,em:10,bp:1.00375,dd:1238/1157,pc:12,in:72.27,mu:10/18}[null!=(r=e.unit)?r:"pt"];if(Number.isFinite(i)){let r=10**i;return Math.round(e.dimension/10*a*r)/r}return e.dimension*a}function oN(e,i){if(null===e)return 0;let r=oI(e)/10;if(Number.isFinite(i)){let e=10**i;return Math.round(r*e)/e}return r}function oq(e){var i;return`${e.dimension}${null!=(i=e.unit)?i:"pt"}`}function oF(e){var i,r;let a;if(null==e)return null;let o="";if("dimension"in e&&(o=`${e.dimension}${null!=(i=e.unit)?i:"pt"}`),"glue"in e&&(a=oq(e.glue),e.grow&&0!==e.grow.dimension&&(a+=` plus ${oq(e.grow)}`),e.shrink&&0!==e.shrink.dimension&&(a+=` minus ${oq(e.shrink)}`),o=a),"number"in e)if("base"in e&&"decimal"!==e.base)if("alpha"===e.base)o=`\`${String.fromCodePoint(e.number)}`;else{let i=Math.round(e.number)>>>0;"hexadecimal"===e.base?(o=Number(i).toString(16).toUpperCase(),o=i<=255?o.padStart(2,"0"):i<=65535?o.padStart(4,"0"):i<=0xffffff?o.padStart(6,"0"):o.padStart(8,"0"),o=`"${o}`):"octal"===e.base&&(o=Number(i).toString(8),o=i<=63?o.padStart(2,"0"):i<=30583?o.padStart(4,"0"):o.padStart(8,"0"),o=`'${o}`)}else o=Number(e.number).toString();return"register"in e&&("factor"in e&&(-1===e.factor?o="-":1!==e.factor&&(o=Number(e.factor).toString())),"global"in e&&e.global&&(o+="\\global"),o+=`\\${e.register}`),"string"in e&&(o=e.string),null!=(r=e.relax)&&r&&(o+="\\relax"),o}function oV(e,i){return null==e?null:"number"in e?g(f({},e),{number:e.number*i}):"register"in e?"factor"in e&&e.factor?g(f({},e),{factor:e.factor*i}):g(f({},e),{factor:i}):"dimension"in e?g(f({},e),{dimension:e.dimension*i}):"glue"in e?e.shrink&&e.grow?{glue:oV(e.glue,i),shrink:oV(e.shrink,i),grow:oV(e.grow,i)}:e.shrink?{glue:oV(e.glue,i),shrink:oV(e.shrink,i)}:e.grow?{glue:oV(e.glue,i),grow:oV(e.grow,i)}:{glue:oV(e.glue,i)}:null}var oj={"p@":{dimension:1},"z@":{dimension:0},maxdimen:{dimension:16383.99999},hfuzz:{dimension:.1},vfuzz:{dimension:.1},overfullrule:{dimension:5},hsize:{dimension:6.5,unit:"in"},vsize:{dimension:8.9,unit:"in"},parindent:{dimension:20},maxdepth:{dimension:4},splitmaxdepth:{register:"maxdimen"},boxmaxdepth:{register:"maxdimen"},delimitershortfall:{dimension:5},nulldelimiterspace:{dimension:1.2,unit:"pt"},scriptspace:{dimension:.5},topskip:{dimension:10},splittopskip:{dimension:10},normalbaselineskip:{dimension:12},normallineskip:{dimension:1},normallineskiplimit:{dimension:0},jot:{dimension:3},doublerulesep:{dimension:2},arrayrulewidth:{dimension:.4},arraycolsep:{dimension:5},fboxsep:{dimension:3},fboxrule:{dimension:.4},"z@skip":{glue:{dimension:0},shrink:{dimension:0},grow:{dimension:0}},hideskip:{glue:{dimension:-1e3},grow:{dimension:1,unit:"fill"}},"@flushglue":{glue:{dimension:0},grow:{dimension:1,unit:"fill"}},parskip:{glue:{dimension:0},grow:{dimension:1}},abovedisplayskip:{glue:{dimension:12},grow:{dimension:3},shrink:{dimension:9}},abovedisplayshortskip:{glue:{dimension:0},grow:{dimension:3}},belowdisplayskip:{glue:{dimension:12},grow:{dimension:3},shrink:{dimension:9}},belowdisplayshortskip:{glue:{dimension:7},grow:{dimension:3},shrink:{dimension:4}},parfillskip:{glue:{dimension:0},grow:{dimension:1,unit:"fil"}},thinmuskip:{glue:{dimension:3,unit:"mu"}},medmuskip:{glue:{dimension:4,unit:"mu"},grow:{dimension:2,unit:"mu"},shrink:{dimension:4,unit:"mu"}},thickmuskip:{glue:{dimension:5,unit:"mu"},grow:{dimension:5,unit:"mu"}},smallskipamount:{glue:{dimension:3},grow:{dimension:1},shrink:{dimension:1}},medskipamount:{glue:{dimension:6},grow:{dimension:2},shrink:{dimension:3}},bigskipamount:{glue:{dimension:12},grow:{dimension:2},shrink:{dimension:4}},pretolerance:100,tolerance:200,hbadness:1e3,vbadness:1e3,linepenalty:10,hyphenpenalty:50,exhyphenpenalty:50,binoppenalty:700,relpenalty:500,clubpenalty:150,widowpenalty:150,displaywidowpenalty:50,brokenpenalty:100,predisplaypenalty:1e4,doublehyphendemerits:1e4,finalhyphendemerits:5e3,adjdemerits:1e4,tracinglostchars:1,uchyph:1,delimiterfactor:901,defaulthyphenchar:"\\-",defaultskewchar:-1,newlinechar:-1,showboxbreadth:5,showboxdepth:3,errorcontextlines:5,interdisplaylinepenalty:100,interfootnotelinepenalty:100,baselineSkip:1.2,arraystretch:1,month:new Date().getMonth()+1,day:new Date().getDate(),year:new Date().getFullYear()};function oH(){return{registers:f({},oj),smartFence:!1,renderPlaceholder:void 0,placeholderSymbol:"▢",letterShapeStyle:I.locale.startsWith("fr")?"french":"tex",minFontScale:0,maxMatrixCols:10,colorMap:U,backgroundColorMap:J,getMacro:e=>eS(e,e_())}}var oW=class e{constructor(i,r){var a,o,n,l,s,c,d,u,h,p,m,g,b,y,v;let x;null!=i&&i.parent?(this.parent=i.parent,x=i.parent,this.registers={}):(x=f(f({},oH()),null!=(a=null==i?void 0:i.from)?a:{}),this.registers=x.registers),x.atomIdsSettings&&(this.atomIdsSettings=f({},x.atomIdsSettings)),this.renderPlaceholder=x.renderPlaceholder,this.isPhantom=null!=(l=null!=(n=null==i?void 0:i.isPhantom)?n:null==(o=this.parent)?void 0:o.isPhantom)&&l,this.letterShapeStyle=x.letterShapeStyle,this.minFontScale=x.minFontScale,this.maxMatrixCols=x.maxMatrixCols,null!=r&&r.color&&"none"!==r.color?this.color=r.color:this.color=null!=(c=null==(s=this.parent)?void 0:s.color)?c:"",null!=r&&r.backgroundColor&&"none"!==r.backgroundColor?this.backgroundColor=r.backgroundColor:this.backgroundColor=null!=(u=null==(d=this.parent)?void 0:d.backgroundColor)?u:"",null!=r&&r.fontSize&&"auto"!==r.fontSize&&r.fontSize!==(null==(h=this.parent)?void 0:h.size)?this.size=r.fontSize:this.size=null!=(m=null==(p=this.parent)?void 0:p.size)?m:5;let _=null!=(b=null==(g=this.parent)?void 0:g.mathstyle)?b:oR.displaystyle;if("string"==typeof(null==i?void 0:i.mathstyle)){if(x instanceof e)switch(i.mathstyle){case"cramp":_=_.cramp;break;case"superscript":_=_.sup;break;case"subscript":_=_.sub;break;case"numerator":_=_.fracNum;break;case"denominator":_=_.fracDen}switch(i.mathstyle){case"textstyle":_=oR.textstyle;break;case"displaystyle":_=oR.displaystyle;break;case"scriptstyle":_=oR.scriptstyle;break;case"scriptscriptstyle":_=oR.scriptscriptstyle}}this.mathstyle=_,this.smartFence=x.smartFence,this.placeholderSymbol=x.placeholderSymbol,this.colorMap=null!=(y=x.colorMap)?y:e=>e,this.backgroundColorMap=null!=(v=x.backgroundColorMap)?v:e=>e,this.getMacro=x.getMacro,void 0!==this.parent||this.registers}makeID(){if(!this.atomIdsSettings)return;if(this.atomIdsSettings.overrideID)return this.atomIdsSettings.overrideID;if("number"!=typeof this.atomIdsSettings.seed)return`${Date.now().toString(36).slice(-2)}${Math.floor(1e5*Math.random()).toString(36)}`;let e=this.atomIdsSettings.seed.toString(36);return this.atomIdsSettings.seed+=1,e}scale(e){return e*this.effectiveFontSize}get scalingFactor(){return this.parent?this.effectiveFontSize/this.parent.effectiveFontSize:1}get isDisplayStyle(){return 7===this.mathstyle.id||6===this.mathstyle.id}get isCramped(){return this.mathstyle.cramped}get isTight(){return this.mathstyle.isTight}get metrics(){return this.mathstyle.metrics}get effectiveFontSize(){return Math.max(oi[Math.max(1,this.size+this.mathstyle.sizeDelta)],this.minFontScale)}getRegister(e){return this.registers&&e in this.registers?this.registers[e]:this.parent?this.parent.getRegister(e):void 0}getRegisterAsNumber(e){let i=this.getRegister(e);return"number"==typeof i?i:"string"==typeof i?Number(i):void 0}getRegisterAsGlue(e){if(this.registers&&e in this.registers){let i=this.registers[e];return"object"==typeof i&&"glue"in i?i:"object"==typeof i&&"dimension"in i?{glue:{dimension:i.dimension}}:"number"==typeof i?{glue:{dimension:i}}:void 0}if(this.parent)return this.parent.getRegisterAsGlue(e)}getRegisterAsEm(e,i){return oN(this.getRegisterAsDimension(e),i)}getRegisterAsDimension(e){if(this.registers&&e in this.registers){let i=this.registers[e];return"object"==typeof i&&"glue"in i?i.glue:"object"==typeof i&&"dimension"in i?i:"number"==typeof i?{dimension:i}:void 0}if(this.parent)return this.parent.getRegisterAsDimension(e)}setRegister(e,i){void 0===i?delete this.registers[e]:this.registers[e]=i}evaluate(e){if(!e||!("register"in e))return e;let i=this;if("global"in e&&e.global)for(;i.parent;)i=i.parent;let r=1;"factor"in e&&1!==e.factor&&void 0!==e.factor&&(r=e.factor);let a=i.getRegister(e.register);if(void 0===a)return;if("string"==typeof a)return{string:Number(a).toString()+a};if("number"==typeof a)return{number:r*a};let o=i.evaluate(a);if(void 0!==o)return"string"in o?{string:Number(a).toString()+o.string}:"number"in o?{number:r*o.number}:"dimension"in o?g(f({},o),{dimension:r*o.dimension}):"glue"in o?g(f({},o),{glue:g(f({},o.glue),{dimension:r*o.glue.dimension}),shrink:o.shrink?g(f({},o.shrink),{dimension:r*o.shrink.dimension}):void 0,grow:o.grow?g(f({},o.grow),{dimension:r*o.grow.dimension}):void 0}):e}toDimension(e){let i=this.evaluate(e);if(void 0===i)return null;if("dimension"in i)return i;if("glue"in i)return i.glue;if("number"in i)return{dimension:i.number};if("string"in i){let e=parseFloat(i.string),r=i.string.match(/(mm|cm|ex|px|em|bp|dd|pc|in|mu)$/);return r?{dimension:e,unit:r[0]}:{dimension:e}}return null}toEm(e,i){if(null===e)return 0;let r=this.toDimension(e);return null===r?0:oI(r,i)/10}toNumber(e){if(null===e)return null;let i=this.evaluate(e);return void 0===i?null:"number"in i?i.number:"dimension"in i?i.dimension:"glue"in i?i.glue.dimension:"string"in i?Number(i.string):null}toColor(e){var i,r;if(null===e)return null;let a=this.evaluate(e);return void 0===a?null:"string"in a?null!=(r=null==(i=this.colorMap)?void 0:i.call(this,a.string))?r:a.string:null}toBackgroundColor(e){var i,r;if(null===e)return null;let a=this.evaluate(e);return void 0===a?null:"string"in a?null!=(r=null==(i=this.backgroundColorMap)?void 0:i.call(this,a.string))?r:a.string:null}},oU=["body","above","below","superscript","subscript"];function oJ(e){return"string"==typeof e&&oU.includes(e)}function oX(e){return void 0!==e&&Array.isArray(e)&&2===e.length}var oG=class e{constructor(e){var i,r,a,o,n,l,s;this.isRoot=!1,this.type=e.type,"string"==typeof e.value&&(this.value=e.value),this.command=null!=(r=null!=(i=e.command)?i:this.value)?r:"",this.mode=null!=(a=e.mode)?a:"math",e.isFunction&&(this.isFunction=!0),(e.isRoot||"root"===this.type)&&(this.isRoot=!0),e.limits&&(this.subsupPlacement=e.limits),this.style=f({},null!=(o=e.style)?o:{}),this.displayContainsHighlight=null!=(n=e.displayContainsHighlight)&&n,this.captureSelection=null!=(l=e.captureSelection)&&l,this.skipBoundary=null!=(s=e.skipBoundary)&&s,void 0!==e.verbatimLatex&&null!==e.verbatimLatex&&(this.verbatimLatex=e.verbatimLatex),e.args&&(this.args=e.args),e.body&&(this.body=e.body),this._changeCounter=0}static createBox(e,i,r){var a;if(!i)return null;let o=function(e){let i,r=[],a=[];for(let o of e){if("first"===o.type){a.push(o);continue}if(i||o.style){let e=o.style;i&&e.color===i.color&&e.backgroundColor===i.backgroundColor&&e.fontSize===i.fontSize?a.push(o):(a.length>0&&r.push(a),a=[o],i=e)}else a.push(o)}return a.length>0&&r.push(a),r}(i),n=[];for(let i of o){let r=i[0].style,a=function(e,i,r){var a,o,n,l,s;if(!i||0===i.length)return null;let c=new oW({parent:e},r.style),d=!(null!=(a=c.atomIdsSettings)&&a.groupNumbers),u=[];if(1===i.length){let e=i[0],r=e.render(c);r&&(d&&e.isSelected&&r.selected(!0),u=[r])}else{let e="",r=!0;for(let a of i){null!=(o=c.atomIdsSettings)&&o.groupNumbers&&e&&(r&&a.isDigit()||!r&&oZ(a))&&(c.atomIdsSettings.overrideID=e);let i=a.render(c);c.atomIdsSettings&&(c.atomIdsSettings.overrideID=void 0),i&&(null!=(n=c.atomIdsSettings)&&n.groupNumbers&&((a.isDigit()||oZ(a))&&(!e||r!==a.isDigit())&&(r=a.isDigit(),e=null!=(l=a.id)?l:""),!e||(a.isDigit()||oZ(a))&&a.hasEmptyBranch("superscript")&&a.hasEmptyBranch("subscript")||(e="")),d&&a.isSelected&&i.selected(!0),u.push(i))}}if(0===u.length)return null;let h=new oE(u,g(f({isTight:c.isTight},r),{type:null!=(s=r.type)?s:"lift"}));return h.isSelected=u.every(e=>e.isSelected),h.wrap(c)}(e,i,{style:{color:r.color,backgroundColor:r.backgroundColor,fontSize:r.fontSize}});a&&n.push(a)}if(0===n.length)return null;let l=(null!=(a=null==r?void 0:r.classes)?a:"").trim();return 1!==n.length||l||null!=r&&r.type?new oE(n,{classes:l,type:null==r?void 0:r.type}).wrap(e):n[0].wrap(e)}static serialize(e,i){return ov.serialize(e,i)}static commonAncestor(e,i){if(e===i||e.parent===i.parent)return e.parent;let r=new WeakSet,{parent:a}=e;for(;a;)r.add(a),a=a.parent;for(a=i.parent;a;){if(r.has(a))return a;a=a.parent}}static fromJson(i){return new e("string"==typeof i?{type:"mord",value:i,mode:"math"}:i)}toJson(){if(this._json)return this._json;let e={};if(this.type&&(e.type=this.type),"math"!==this.mode&&(e.mode=this.mode),this.command&&this.command!==this.value&&(e.command=this.command),void 0!==this.value&&(e.value=this.value),this.style&&Object.keys(this.style).length>0&&(e.style=f({},this.style)),void 0!==this.verbatimLatex&&(e.verbatimLatex=this.verbatimLatex),this.subsupPlacement&&(e.subsupPlacement=this.subsupPlacement),this.explicitSubsupPlacement&&(e.explicitSubsupPlacement=!0),this.isFunction&&(e.isFunction=!0),this.displayContainsHighlight&&(e.displayContainsHighlight=!0),this.skipBoundary&&(e.skipBoundary=!0),this.captureSelection&&(e.captureSelection=!0),this.args&&(e.args=this.args.map(e=>null===e?"<null>":Array.isArray(e)&&e[0]instanceof oG?{atoms:e.map(e=>e.toJson())}:"object"==typeof e&&"group"in e?{group:e.group.map(e=>e.toJson())}:e)),this._branches)for(let i of Object.keys(this._branches))this._branches[i]&&(e[i]=this._branches[i].filter(e=>"first"!==e.type).map(e=>e.toJson()));return"mord"===e.type&&2===Object.keys(e).length&&"value"in e?e.value:(this._json=e,e)}get changeCounter(){return this.parent?this.parent.changeCounter:this._changeCounter}set isDirty(e){e&&(this._json=void 0,this.parent||this._changeCounter++,"verbatimLatex"in this&&(this.verbatimLatex=void 0),this._children=void 0,this.parent&&(this.parent.isDirty=!0))}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let i=eM(this.command,this.mode);return null!=i&&i.serialize?i.serialize(this,e):this.body&&this.command?of([og(this.command,this.bodyToLatex(e)),this.supsubToLatex(e)]):this.body?of([this.bodyToLatex(e),this.supsubToLatex(e)]):this.value&&""!==this.value?this.command:""}bodyToLatex(e){var i;let r=null!=(i=e.defaultMode)?i:"math"===this.mode?"math":"text";return ov.serialize(this.body,g(f({},e),{defaultMode:r}))}aboveToLatex(e){return ov.serialize(this.above,e)}belowToLatex(e){return ov.serialize(this.below,e)}supsubToLatex(e){let i="";if(e=g(f({},e),{defaultMode:"math"}),void 0!==this.branch("subscript")){let r=ov.serialize(this.subscript,e);0===r.length?i+="_{}":1===r.length&&o$.compactSerialization&&/^[0-9]$/.test(r)?i+=`_${r}`:i+=`_{${r}}`}if(void 0!==this.branch("superscript")){let r=ov.serialize(this.superscript,e);0===r.length?i+="^{}":1===r.length?"′"===r?i+="^\\prime ":"″"===r?i+="^\\doubleprime ":o$.compactSerialization&&/^[0-9]$/.test(r)?i+=`^${r}`:i+=`^{${r}}`:i+=`^{${r}}`}return i}get treeDepth(){let e=1,i=this.parent;for(;i;)i=i.parent,e+=1;return e}get inCaptureSelection(){let e=this;for(;e;){if(e.captureSelection)return!0;e=e.parent}return!1}get parentPrompt(){let e=this.parent;for(;e;){if("prompt"===e.type&&!e.captureSelection)return e;e=e.parent}return null}branch(e){if(oJ(e)&&this._branches)return this._branches[e]}get branches(){if(!this._branches)return[];let e=[];for(let i of oU)this._branches[i]&&e.push(i);return e}createBranch(e){return oJ(e),oJ(e)?(this._branches?this._branches[e]||(this._branches[e]=[this.makeFirstAtom(e)]):this._branches={[e]:[this.makeFirstAtom(e)]},this.isDirty=!0,this._branches[e]):[]}get row(){return oX(this.parentBranch)?this.parentBranch[0]:-1}get col(){return oX(this.parentBranch)?this.parentBranch[1]:-1}get body(){var e;return null==(e=this._branches)?void 0:e.body}set body(e){this.setChildren(e,"body")}get superscript(){var e;return null==(e=this._branches)?void 0:e.superscript}set superscript(e){this.setChildren(e,"superscript")}get subscript(){var e;return null==(e=this._branches)?void 0:e.subscript}set subscript(e){this.setChildren(e,"subscript")}get above(){var e;return null==(e=this._branches)?void 0:e.above}set above(e){this.setChildren(e,"above")}get below(){var e;return null==(e=this._branches)?void 0:e.below}set below(e){this.setChildren(e,"below")}applyStyle(e,i){for(let r of(this.isDirty=!0,null!=i&&i.unstyledOnly?(e.color&&!this.style.color&&(this.style.color=e.color),e.backgroundColor&&!this.style.backgroundColor&&(this.style.backgroundColor=e.backgroundColor),e.fontFamily&&!this.style.fontFamily&&(this.style.fontFamily=e.fontFamily),e.fontShape&&!this.style.fontShape&&(this.style.fontShape=e.fontShape),e.fontSeries&&!this.style.fontSeries&&(this.style.fontSeries=e.fontSeries),e.fontSize&&!this.style.fontSize&&(this.style.fontSize=e.fontSize),e.variant&&!this.style.variant&&(this.style.variant=e.variant),e.variantStyle&&!this.style.variantStyle&&(this.style.variantStyle=e.variantStyle)):this.style=f(f({},this.style),e),"none"===this.style.fontFamily&&delete this.style.fontFamily,"auto"===this.style.fontShape&&delete this.style.fontShape,"auto"===this.style.fontSeries&&delete this.style.fontSeries,"none"===this.style.color&&(delete this.style.color,delete this.style.verbatimColor),"none"===this.style.backgroundColor&&(delete this.style.backgroundColor,delete this.style.verbatimBackgroundColor),"auto"===this.style.fontSize&&delete this.style.fontSize,this.children))r.applyStyle(e,i)}getInitialBaseElement(){var e,i,r;return this.hasEmptyBranch("body")?this:(null==(e=this.body)||e[0].type,null!=(r=null==(i=this.body[1])?void 0:i.getInitialBaseElement())?r:this)}getFinalBaseElement(){return this.hasEmptyBranch("body")?this:this.body[this.body.length-1].getFinalBaseElement()}isCharacterBox(){return"leftright"!==this.type&&"genfrac"!==this.type&&"subsup"!==this.type&&"delim"!==this.type&&"array"!==this.type&&"surd"!==this.type&&"mord"===this.getFinalBaseElement().type}hasEmptyBranch(e){let i=this.branch(e);return!i||(i.length,i[0].type,1===i.length)}setChildren(e,i){var r;if(!e||(oJ(i),!oJ(i)))return;let a=(null==(r=e[0])?void 0:r.type)==="first"?[...e]:[this.makeFirstAtom(i),...e];for(let r of(this._branches?this._branches[i]=a:this._branches={[i]:a},e))r.parent=this,r.parentBranch=i;this.isDirty=!0}makeFirstAtom(i){let r=new e({type:"first",mode:this.mode});return r.parent=this,r.parentBranch=i,r}addChild(e,i){e.type,this.createBranch(i).push(e),this.isDirty=!0,e.parent=this,e.parentBranch=i}addChildBefore(e,i){i.parentBranch;let r=this.createBranch(i.parentBranch);r.splice(r.indexOf(i),0,e),this.isDirty=!0,e.parent=this,e.parentBranch=i.parentBranch}addChildAfter(e,i){i.parentBranch;let r=this.createBranch(i.parentBranch);r.splice(r.indexOf(i)+1,0,e),this.isDirty=!0,e.parent=this,e.parentBranch=i.parentBranch}addChildren(e,i){let r=this.createBranch(i);for(let a of e)a.parent=this,a.parentBranch=i,r.push(a);this.isDirty=!0}addChildrenAfter(e,i){0===e.length||e[0].type,i.parentBranch;let r=this.createBranch(i.parentBranch);for(let a of(r.splice(r.indexOf(i)+1,0,...e),this.isDirty=!0,e))a.parent=this,a.parentBranch=i.parentBranch;return e[e.length-1]}removeBranch(e){let i=this.branch(e);if(oJ(e)&&(this._branches[e]=void 0),!i)return[];for(let e of i)e.parent=void 0,e.parentBranch=void 0;i[0].type;let[r,...a]=i;return this.isDirty=!0,a}removeChild(e){if(e.parent,"first"===e.type)return;let i=this.branch(e.parentBranch),r=i.indexOf(e);i.splice(r,1),this.isDirty=!0,e.parent=void 0,e.parentBranch=void 0}get siblings(){return this.parent?this.parent.branch(this.parentBranch):[]}get firstSibling(){return this.siblings[0]}get lastSibling(){let{siblings:e}=this;return e[e.length-1]}get isFirstSibling(){return this===this.firstSibling}get isLastSibling(){return this===this.lastSibling}get hasNoSiblings(){return 1===this.siblings.length}get leftSibling(){this.parent;let e=this.parent.branch(this.parentBranch);return e[e.indexOf(this)-1]}get rightSibling(){this.parent;let e=this.parent.branch(this.parentBranch);return e[e.indexOf(this)+1]}get hasChildren(){return!!(this._branches&&this.children.length>0)}get firstChild(){return this.hasChildren,this.children[0]}get lastChild(){this.hasChildren;let{children:e}=this;return e[e.length-1]}get children(){if(this._children)return this._children;if(!this._branches)return[];let e=[];for(let i of oU)if(this._branches[i])for(let r of this._branches[i])e.push(...r.children),e.push(r);return this._children=e,e}render(e){if("first"===this.type&&!e.atomIdsSettings)return null;let i=eM(this.command,this.mode);if(null!=i&&i.render)return i.render(this,e);let r=new oW({parent:e},this.style),a=this.createBox(r,{classes:this.parent?"":"ML__base"});return a?(!this.subsupPlacement&&(this.superscript||this.subscript)&&(a=this.attachSupsub(r,{base:a})),a.wrap(r)):null}attachSupsub(i,r){var a;let o,n=r.base,l=this.superscript,s=this.subscript;if(!l&&!s)return n;let c=null,d=null,u=null!=(a=r.isCharacterBox)?a:this.isCharacterBox(),h=0;if(l){let r=new oW({parent:i,mathstyle:"superscript"});c=e.createBox(r,l),u||(h=n.height-i.metrics.supDrop*r.scalingFactor)}let p=0;if(s){let r=new oW({parent:i,mathstyle:"subscript"});d=e.createBox(r,s),u||(p=n.depth+i.metrics.subDrop*r.scalingFactor)}o=i.isDisplayStyle?i.metrics.sup1:i.isCramped?i.metrics.sup3:i.metrics.sup2;let m=.05/i.scalingFactor,f=null;if(d&&c){h=Math.max(h,o,c.depth+.25*i.metrics.xHeight),p=Math.max(p,i.metrics.sub2);let e=i.metrics.defaultRuleThickness;if(h-c.depth-(d.height-p)<4*e){p=4*e-(h-c.depth)+d.height;let r=.8*i.metrics.xHeight-(h-c.depth);r>0&&(h+=r,p-=r)}f=new oB({individualShift:[{box:d,shift:p,marginLeft:"extensible-symbol"===this.type&&n.italic?-n.italic:0},{box:c,shift:-h}]})}else d&&!c?f=new oB({shift:p=Math.max(p,i.metrics.sub1,d.height-.3448),children:[{box:d,marginRight:m,marginLeft:this.isCharacterBox()?-n.italic:0}]}):!d&&c&&(f=new oB({shift:-(h=Math.max(h,o,c.depth+.10775)),children:[{box:c,marginRight:m}]}));return new oE([n,new oE(f,{caret:this.caret,isSelected:this.isSelected,classes:"ML__msubsup"})],{type:r.type})}attachLimits(i,r){var a,o,n,l,s,c;let d,u,h,p,m,b,y=this.superscript?e.createBox(new oW({parent:i,mathstyle:"superscript"},this.style),this.superscript):null,v=this.subscript?e.createBox(new oW({parent:i,mathstyle:"subscript"},this.style),this.subscript):null;return y||v?(a=g(f({},r),{above:y,below:v}),d=i.metrics,u=new oE(a.base),h=null!=(o=a.baseShift)?o:0,p=null!=(n=a.slant)?n:0,m=0,b=0,a.above&&(m=null!=(l=a.aboveShift)?l:Math.max(d.bigOpSpacing1,d.bigOpSpacing3-a.above.depth)),a.below&&(b=null!=(s=a.belowShift)?s:Math.max(d.bigOpSpacing2,d.bigOpSpacing4-a.below.height)),new oE(a.below&&a.above?new oB({bottom:d.bigOpSpacing5+a.below.height+a.below.depth+b+u.depth+h,children:[d.bigOpSpacing5,{box:a.below,marginLeft:-p,classes:["ML__center"]},b,{box:u,classes:["ML__center"]},m,{box:a.above,marginLeft:p,classes:["ML__center"]},d.bigOpSpacing5]}).wrap(i):a.below&&!a.above?new oB({top:u.height-h,children:[d.bigOpSpacing5,{box:a.below,marginLeft:-p,classes:["ML__center"]},b,{box:u,classes:["ML__center"]}]}).wrap(i):!a.below&&a.above?new oB({bottom:u.depth+h,children:[{box:u,classes:["ML__center"]},m,{box:a.above,marginLeft:p,classes:["ML__center"]},d.bigOpSpacing5]}).wrap(i):new oB({bottom:u.depth+h,children:[{box:u},d.bigOpSpacing5]}).wrap(i),{type:null!=(c=a.type)?c:"op"})):r.base.wrap(i)}bind(e,i){if(!i||e.isPhantom||""===this.value)return i;let r=this.parent;for(;r&&!r.captureSelection;)r=r.parent;return null!=r&&r.captureSelection||(this.id||(this.id=e.makeID()),i.atomID=this.id),i}createBox(i,r){var a,o,n,l;let s=null!=(a=this.value)?a:this.body,c=null!=(o=null==r?void 0:r.boxType)?o:oS(this.type),d=null!=(n=null==r?void 0:r.classes)?n:"";"text"===this.mode&&(d+=" ML__text");let u="string"==typeof s||void 0===s?new oE(null!=s?s:null,{type:c,isSelected:this.isSelected,mode:this.mode,maxFontSize:i.scalingFactor,style:g(f({variant:"normal"},this.style),{fontSize:Math.max(1,i.size+i.mathstyle.sizeDelta)}),letterShapeStyle:i.letterShapeStyle,classes:d}):null!=(l=e.createBox(i,s,{type:c,classes:d}))?l:new oE(null);return i.isTight&&(u.isTight=!0),("math"!==this.mode||"main"===this.style.variant)&&(u.italic=0),u.right=u.italic,this.bind(i,u),!this.caret||this.superscript||this.subscript||(u.caret=this.caret),u}isDigit(){var e;return"mord"===this.type&&this.value?/^[\d,\.]$/.test(this.value):"group"===this.type&&(null==(e=this.body)?void 0:e.length)===2&&"first"===this.body[0].type&&","===this.body[1].value}asDigit(){var e;return"mord"===this.type&&this.value&&/^[\d,\.]$/.test(this.value)?this.value:"group"===this.type&&(null==(e=this.body)?void 0:e.length)===2&&"first"===this.body[0].type&&","===this.body[1].value?".":""}};function oZ(e){return"text"===e.mode}var oY=class e extends oG{constructor(e,i,r){super({type:"text",command:e,mode:"text",displayContainsHighlight:!0}),this.value=i,this.verbatimLatex=i,this.applyStyle(r)}static fromJson(i){return new e(i.command,i.value,i.style)}render(e){let i=this.createBox(e);return this.caret&&(i.caret=this.caret),i}_serialize(e){var i;return null!=(i=this.verbatimLatex)?i:eL("text",this.value.codePointAt(0))}};function oQ(e){let i=1/0,r=-1/0;for(let a of e.ranges)i=Math.min(i,a[0],a[1]),r=Math.max(r,a[0],a[1]);return[i,r]}function o0(e){return"number"==typeof e&&!Number.isNaN(e)}function o1(e){return Array.isArray(e)&&2===e.length}function o4(e){return null!=e&&"object"==typeof e&&"ranges"in e&&Array.isArray(e.ranges)}function o2(e,i,r){return r?function(e,i){if(!i)return"";if("string"==typeof i)return i;if(!e||void 0===i.after)return i.value;let r=!1,a=!1,o=!1,n=!1,l=!1,s=!1,c=!1,d=!1,u=!1,h=!1,p=!1,m=!1,f=!1,g=!1,b=!1,y=e[0],v=0;for(;null!=y&&y.type&&/^(subsup|placeholder)$/.test(y.type);)v+=1,y=e[v];return r=!y||"first"===y.type,y&&(a=!(g="text"===y.mode)&&"mord"===y.type&&ei.test(y.value),o=!g&&"mord"===y.type&&/\d+$/.test(y.value),n=!g&&y.isFunction,l="genfrac"===y.type,s="surd"===y.type,c="mbin"===y.type,d="mrel"===y.type,u="mop"===y.type||"operator"===y.type||"extensible-symbol"===y.type,h="mpunct"===y.type||"minner"===y.type,p="array"===y.type,m="mopen"===y.type,f="mclose"===y.type||"leftright"===y.type,b="space"===y.type),i.after.includes("nothing")&&r||i.after.includes("letter")&&a||i.after.includes("digit")&&o||i.after.includes("function")&&n||i.after.includes("frac")&&l||i.after.includes("surd")&&s||i.after.includes("binop")&&c||i.after.includes("relop")&&d||i.after.includes("operator")&&u||i.after.includes("punct")&&h||i.after.includes("array")&&p||i.after.includes("openfence")&&m||i.after.includes("closefence")&&f||i.after.includes("text")&&g||i.after.includes("space")&&b?i.value:""}(e,r[i]):""}var o3={"&":"\\&","%":"\\%",$:"\\$","''":"^{\\doubleprime}","'''":"^{\\prime\\prime\\prime}","''''":"^{\\prime\\prime\\prime\\prime}",alpha:"\\alpha",delta:"\\delta",Delta:"\\Delta",pi:"\\pi",Pi:"\\Pi",theta:"\\theta",Theta:"\\Theta",ii:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\imaginaryI"},jj:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\imaginaryJ"},ee:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\exponentialE"},nabla:"\\nabla",grad:"\\nabla",del:"\\partial",deg:{after:"digit+space",value:"\\degree"},infty:"\\infty","∞":"\\infty",oo:{after:"nothing+digit+frac+surd+binop+relop+punct+array+openfence+closefence+space",value:"\\infty"},"∑":"\\sum",sum:"\\sum_{#?}^{#?}",int:"\\int_{#?}^{#?}",prod:"\\prod_{#?}^{#?}",sqrt:"\\sqrt{#?}","∆":"\\differentialD","∂":"\\differentialD",sin:"\\sin",cos:"\\cos",tan:"\\tan",blank:"\\blank{#?}",arccos:"\\arccos",arcsin:"\\arcsin",arctan:"\\arctan",arctg:"\\operatorname{arctg}",arcsec:"\\operatorname{arcsec}",arccsc:"\\operatorname{arccsc}",arsinh:"\\operatorname{arsinh}",arccosh:"\\operatorname{arccosh}",arcosh:"\\operatorname{arcosh}",artanh:"\\operatorname{artanh}",arctanh:"\\operatorname{arctanh}",arcsech:"\\operatorname{arcsech}",arccsch:"\\operatorname{arccsch}",ch:"\\operatorname{ch}",cosec:"\\operatorname{cosec}",cosh:"\\cosh",cot:"\\cot",cotg:"\\operatorname{cotg}",coth:"\\coth",csc:"\\csc",ctg:"\\operatorname{ctg}",cth:"\\operatorname{cth}",sec:"\\sec",sech:"\\operatorname{sech}",sinh:"\\sinh",sh:"\\operatorname{sh}",tanh:"\\tanh",tg:"\\operatorname{tg}",th:"\\operatorname{th}",arg:"\\arg",lg:"\\lg",lb:"\\operatorname{lb}",log:"\\log_{#?}",ln:"\\ln",exp:"\\exp",lim:"\\lim_{#?\\to#?}",dx:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\differentialD x"},dy:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\differentialD y"},dt:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\differentialD t"},AA:"\\forall",EE:"\\exists","!EE":"\\nexists","&&":"\\land",xin:{after:"nothing+text+relop+punct+openfence+space",value:"x \\in"},sint:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\sin t"},in:{after:"nothing+letter+closefence",value:"\\in"},"!in":"\\notin",NN:"\\mathbb{N}",ZZ:"\\mathbb{Z}",QQ:"\\mathbb{Q}",RR:"\\mathbb{R}",CC:"\\mathbb{C}",xx:"\\times","+-":"\\pm","≠":"\\ne","!=":"\\ne","≥":"\\ge",">=":"\\ge","≤":"\\le","<=":"\\le","<<":"\\ll",">>":"\\gg","~~":"\\approx","≈":"\\approx","?=":"\\questeq","÷":"\\div","¬":"\\neg",":=":"\\coloneq","::":"\\Colon","(:":"\\langle",":)":"\\rangle",beta:"\\beta",chi:"\\chi",epsilon:"\\epsilon",varepsilon:"\\varepsilon",eta:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\eta"},gamma:"\\gamma",Gamma:"\\Gamma",iota:"\\iota",kappa:"\\kappa",lambda:"\\lambda",Lambda:"\\Lambda",mu:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\mu"},nu:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\nu"},µ:"\\mu",phi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\phi"},Phi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\Phi"},varphi:"\\varphi",psi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\psi"},Psi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\Psi"},rho:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\rho"},sigma:"\\sigma",Sigma:"\\Sigma",tau:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\tau"},vartheta:"\\vartheta",upsilon:"\\upsilon",xi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space",value:"\\xi"},Xi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\Xi"},zeta:"\\zeta",omega:"\\omega",Omega:"\\Omega",Ω:"\\omega",forall:"\\forall",exists:"\\exists","!exists":"\\nexists",":.":"\\therefore",liminf:"\\liminf_{#?}",limsup:"\\limsup_{#?}",argmin:"\\operatorname*{arg~min}_{#?}",argmax:"\\operatorname*{arg~max}_{#?}",det:"\\det",mod:"\\bmod{#?}","(mod":"\\pmod{#?}",max:"\\max",min:"\\min",erf:"\\operatorname{erf}",erfc:"\\operatorname{erfc}",bessel:"\\operatorname{bessel}",mean:"\\operatorname{mean}",median:"\\operatorname{median}",fft:"\\operatorname{fft}",lcm:"\\operatorname{lcm}",gcd:"\\gcd",randomReal:"\\operatorname{randomReal}",randomInteger:"\\operatorname{randomInteger}",Re:"\\operatorname{Re}",Im:"\\operatorname{Im}",mm:{after:"nothing+digit+operator",value:"\\operatorname{mm}"},cm:{after:"nothing+digit+operator",value:"\\operatorname{cm}"},km:{after:"nothing+digit+operator",value:"\\operatorname{km}"},kg:{after:"nothing+digit+operator",value:"\\operatorname{kg}"},ft:{after:"nothing+digit+operator",value:"\\operatorname{ft}"},inch:{after:"nothing+digit+operator",value:"\\operatorname{inch}"},mi:{after:"nothing+digit+operator",value:"\\operatorname{mi}"},"...":"\\ldots","+...":"+\\cdots","-...":"-\\cdots","->...":"\\to\\cdots","--\x3e...":"\\longrightarrow\\cdots","->":"\\to","|->":"\\mapsto","--\x3e":"\\longrightarrow","<--":"\\longleftarrow","=>":"\\Rightarrow","==>":"\\Longrightarrow","<=>":"\\iff","<->":"\\leftrightarrow","(.)":"\\odot","(+)":"\\oplus","(/)":"\\oslash","(*)":"\\otimes","(-)":"\\ominus","||":"\\Vert","*":"\\cdot","**":"\\star","***":"\\ast","//":"\\slash","\\\\":"\\backslash",setminus:"\\backslash","|><":"\\ltimes","><|":"\\rtimes","|><|":"\\bowtie","-:":"\\div",divide:"\\div","@":"\\circ","^^":"\\wedge","^^^":"\\bigwedge",vv:"\\vee",vvv:"\\bigvee",nn:"\\cap",nnn:"\\bigcap",uu:"\\cup",uuu:"\\bigcup","-=":"\\equiv","~=":"\\cong",lt:"<","lt=":"\\leq",gt:">","gt=":"\\geq","-<":"\\prec","-lt":"\\prec","-<=":"\\preceq",">-=":"\\succeq",prop:"\\propto",diamond:"\\diamond",square:"\\square",iff:"\\iff",sub:"\\subset",sup:"\\supset",sube:"\\subseteq",supe:"\\supseteq",uarr:"\\uparrow",darr:"\\downarrow",rarr:"\\rightarrow",rArr:"\\Rightarrow",larr:"\\leftarrow",lArr:"\\Leftarrow",harr:"\\leftrightarrow",hArr:"\\Leftrightarrow",aleph:"\\aleph",and:"\\land",or:"\\lor",not:"\\neg","_|_":"\\bot",TT:"\\top","|--":"\\vdash","|==":"\\models","|__":"\\lfloor","__|":"\\rfloor","|~":"\\lceil","~|":"\\rceil",">->":"\\rightarrowtail","->>":"\\twoheadrightarrow",">->>":"\\twoheadrightarrowtail",times:"\\times",of:"\\circ",infinity:"\\infty",defint:"\\int_{#?}^{#?}",approaches:"\\to",ceil:"\\left\\lceil#?\\right\\rceil",floor:"\\left\\lfloor#?\\right\\rfloor",union:"\\cup",asterisk:"\\ast",frac:"\\frac{#?}{#?}",cbrt:"\\sqrt[3]{#?}",nthroot:"\\sqrt[#?]{#?}"};function o6(e,i){var r,a;let o,n=null!=(r=null==i?void 0:i.format)?r:"auto";return"auto"===n&&([n,e]=(a=(a=e).trim()).length<=1?["latex",a]:([o,a]=nt(a),o?["latex",a]:a.startsWith("`")&&a.endsWith("`")?["ascii-math",a=a.substring(1,a.length-1)]:a.includes("\\")?["latex",a]:/\$.+\$/.test(a)?["latex",`\\text{${a}}`]:[void 0,a])),"ascii-math"===n?["ascii-math",o8(e=(e=(e=(e=(e=(e=e.replace(/\u2061/gu,"")).replace(/\u3016/gu,"{")).replace(/\u3017/gu,"}")).replace(/([^\\])sinx/g,"$1\\sin x")).replace(/([^\\])cosx/g,"$1\\cos x ")).replace(/\u2013/g,"-"),{inlineShortcuts:null==i?void 0:i.inlineShortcuts})]:["latex",e]}function o8(e,i){var r;if(!(e=e.trim()))return"";let a=null!=(r=i.inlineShortcuts)?r:o3;if(e.startsWith("^")||e.startsWith("_")){let{match:r,rest:o}=o7(e.slice(1),{inlineShortcuts:a,noWrap:!0});return`${e[0]}{${r}}${o8(o,i)}`}let o=e.match(/^(sqrt|\u221A)(.*)/);if(o){let{match:e,rest:r}=o7(o[2],{inlineShortcuts:a,noWrap:!0});return`\\sqrt{${null!=e?e:"\\placeholder{}"}}${o8(r,i)}`}if(o=e.match(/^(\\cbrt|\u221B)(.*)/)){let{match:e,rest:r}=o7(o[2],{inlineShortcuts:a,noWrap:!0});return`\\sqrt[3]{${null!=e?e:"\\placeholder{}"}}${o8(r,i)}`}if(o=e.match(/^abs(.*)/)){let{match:e,rest:r}=o7(o[1],{inlineShortcuts:a,noWrap:!0});return`\\left|${null!=e?e:"\\placeholder{}"}\\right|${o8(r,i)}`}if(o=e.match(/^["”“](.*?)["”“](.*)/))return`\\text{${o[1]}}${o8(o[2],i)}`;if(o=e.match(/^([^a-zA-Z0-9\(\{\[\_\^\\\s"]+)(.*)/))return`${o9(o[1],a)}${o8(o[2],i)}`;if(/^([fgh])[^a-zA-Z]/.test(e)){let{rest:r,match:o}=o7(e.slice(1),{inlineShortcuts:a,noWrap:!0});return("("===e[1]?`${e[0]}\\left(${o}\\right)`:e[0]+o)+o8(r,i)}if(o=e.match(/^([a-zA-Z]+)(.*)/))return o9(o[1],a)+o8(o[2],i);let{match:n,rest:l}=o7(e,{inlineShortcuts:a,noWrap:!0});if(!n||"/"!==l[0])return e.startsWith("(")?"\\left("+n+"\\right)"+o8(l,i):n+o8(l,i);{let e=o7(l.slice(1),{inlineShortcuts:a,noWrap:!0});if(e.match)return`\\frac{${n}}{${e.match}}${o8(e.rest,i)}`}return(o=e.match(/^(\s+)(.*)$/))?" "+o8(o[2],i):e}var o5={"[":"\\lbrack","]":"\\rbrack","{":"\\lbrace","}":"\\rbrace"};function o7(e,i){var r,a;let o="",n=e=e.trim(),l=e.charAt(0),s={"(":")","{":"}","[":"]"}[l];if(s){let c=1,d=1;for(;d<e.length&&c>0;)e[d]===l&&c++,e[d]===s&&c--,d++;if(0===c){let c=o8(e.substring(1,d-1),i);o=i.noWrap&&"("===l?c:`\\left${null!=(r=o5[l])?r:l}${c}\\right${null!=(a=o5[s])?a:s}`,n=e.slice(Math.max(0,d))}else o=e.substring(1,d),n=""}else{let r=e.match(/^([a-zA-Z]+)/);if(r){let r=o2(null,e,i.inlineShortcuts);if(r)return{match:r=(r=r.replace("_{#?}","")).replace("^{#?}",""),rest:e.slice(r.length)}}if(r=e.match(/^([a-zA-Z])/))return{match:r[1],rest:e.slice(1)};if(r=e.match(/^(-)?\d+(\.\d*)?/))return{match:r[0],rest:e.slice(r[0].length)};/^\\(left|right)/.test(e)||(r=e.match(/^(\\[a-zA-Z]+)/))&&(n=e.slice(r[1].length),o=r[1])}return{match:o,rest:n}}function o9(e,i){let r=o2(null,e,i);return r?(r=r.replace("_{#?}","")).replace("^{#?}","")+" ":e}var ne=[["\\[","\\]"],["\\(","\\)"],["$$","$$"],["$","$"],["\\begin{math}","\\end{math}"],["\\begin{displaymath}","\\end{displaymath}"],["\\begin{equation}","\\end{equation}"],["\\begin{equation*}","\\end{equation*}"]];function nt(e){let i=e.trim();for(let e of ne)if(i.startsWith(e[0])&&i.endsWith(e[1]))return[!0,i.substring(e[0].length,i.length-e[1].length)];return[!1,e]}var ni=(e,i,r)=>(ne.some(e=>i.startsWith(e[0])&&i.endsWith(e[1]))||(i=`$$ ${i} $$`),i),nr=class e{constructor(i){e._modes[i]=this}static onPaste(i,r,a){var o;if(!r.contentEditable&&"none"===r.userSelect)return r.model.announce("plonk"),!1;if("string"==typeof a){let e=new DataTransfer;e.setData("text/plain",a),a=e}let n=new ClipboardEvent("paste",{clipboardData:a,cancelable:!0});return!!(null!=(o=r.host)&&o.dispatchEvent(n))&&e._modes[i].onPaste(r,a)}static copyToClipboard(e,i){if(!e.contentEditable&&"none"===e.userSelect)return void e.model.announce("plonk");let r=e.model,a=r.selectionIsCollapsed?[0,r.lastOffset]:oQ(r.selection),o=r.getValue(a,i);navigator.clipboard.writeText(o).then(()=>{},()=>e.model.announce("plonk"))}static onCopy(e,i){var r;if(!i.clipboardData)return;if(!e.contentEditable&&"none"===e.userSelect)return void e.model.announce("plonk");let a=e.model,o=a.selectionIsCollapsed?[0,a.lastOffset]:oQ(a.selection),n=a.getAtoms(o);if(n.every(e=>"text"===e.mode||!e.mode))i.clipboardData.setData("text/plain",n.filter(e=>e instanceof oY).map(e=>e.value).join(""));else if(n.every(e=>"latex"===e.mode))i.clipboardData.setData("text/plain",a.getAtoms(o,{includeChildren:!0}).map(e=>{var i;return null!=(i=e.value)?i:""}).join(""));else{let l;l=1===n.length&&void 0!==n[0].verbatimLatex?n[0].verbatimLatex:a.getValue(o,"latex-expanded"),i.clipboardData.setData("application/x-latex",l);try{i.clipboardData.setData("text/plain",e.options.onExport(e,l,o))}catch(e){}if(1===n.length){let e=n[0];("root"===e.type||"group"===e.type)&&(n=e.body.filter(e=>"first"!==e.type))}try{i.clipboardData.setData("application/json+mathlive",JSON.stringify(n.map(e=>e.toJson())))}catch(e){}if(null!=(r=window[Symbol.for("io.cortexjs.compute-engine")])&&r.ComputeEngine){let e=globalThis.MathfieldElement.computeEngine;if(e)try{let r=e.jsonSerializationOptions;e.jsonSerializationOptions={metadata:["latex"]};let n=e.parse(a.getValue(o,"latex-unstyled"));e.jsonSerializationOptions=r;let l=JSON.stringify(n.json);l&&i.clipboardData.setData("application/json",l)}catch(e){}}}i.preventDefault()}static insert(i,r,a={}){var o;let n="auto"===a.mode?i.mode:null!=(o=a.mode)?o:i.mode;return e._modes[n].insert(i,r,a)}onPaste(e,i){return!1}insert(e,i,r){return!1}};nr._modes={};var na=nr,no=[{key:"left",command:"moveToPreviousChar"},{key:"right",command:"moveToNextChar"},{key:"up",command:"moveUp"},{key:"down",command:"moveDown"},{key:"shift+[ArrowLeft]",command:"extendSelectionBackward"},{key:"shift+[ArrowRight]",command:"extendSelectionForward"},{key:"shift+[ArrowUp]",command:"extendSelectionUpward"},{key:"shift+[ArrowDown]",command:"extendSelectionDownward"},{key:"[Backspace]",command:"deleteBackward"},{key:"[Delete]",command:"deleteForward"},{key:"shift+[Backspace]",command:"deleteForward"},{key:"alt+[Backspace]",command:"deletePreviousWord"},{key:"alt+[Delete]",command:"deleteNextWord"},{key:"ctrl+[Backspace]",command:"deleteToGroupStart"},{key:"ctrl+[Delete]",command:"deleteToGroupEnd"},{key:"ctrl+shift+[Backspace]",command:"deleteToGroupEnd"},{key:"alt+[ArrowLeft]",command:"moveToPreviousWord"},{key:"alt+[ArrowRight]",command:"moveToNextWord"},{key:"shift+alt+[ArrowLeft]",command:"extendToPreviousWord"},{key:"shift+alt+[ArrowRight]",command:"extendToNextWord"},{key:"ctrl+[ArrowLeft]",command:"moveToGroupStart"},{key:"ctrl+[ArrowRight]",command:"moveToGroupEnd"},{key:"shift+ctrl+[ArrowLeft]",command:"extendToGroupStart"},{key:"shift+ctrl+[ArrowRight]",command:"extendToGroupEnd"},{key:"[Home]",command:"moveToMathfieldStart"},{key:"cmd+[ArrowLeft]",command:"moveToMathfieldStart"},{key:"shift+[Home]",command:"extendToMathFieldStart"},{key:"shift+cmd+[ArrowLeft]",command:"extendToMathFieldStart"},{key:"[End]",command:"moveToMathfieldEnd"},{key:"cmd+[ArrowRight]",command:"moveToMathfieldEnd"},{key:"shift+[End]",command:"extendToMathFieldEnd"},{key:"shift+cmd+[ArrowRight]",command:"extendToMathFieldEnd"},{key:"[Pageup]",command:"moveToGroupStart"},{key:"[Pagedown]",command:"moveToGroupEnd"},{key:"[Tab]",command:"moveToNextGroup"},{key:"shift+[Tab]",command:"moveToPreviousGroup"},{key:"[Escape]",ifMode:"math",command:["switchMode","latex"]},{key:"[Escape]",ifMode:"text",command:["switchMode","latex"]},{key:"[Escape]",ifMode:"latex",command:["complete","complete",{selectItem:"true"}]},{key:"\\",ifMode:"math",command:["switchMode","latex","","\\"]},{key:"[IntlBackslash]",ifMode:"math",command:["switchMode","latex","","\\"]},{key:"[Tab]",ifMode:"latex",command:["complete","accept-suggestion"]},{key:"[Return]",ifMode:"latex",command:["complete","accept-all"]},{key:"[Enter]",ifMode:"latex",command:["complete","accept-all"]},{key:"shift+[Escape]",ifMode:"latex",command:["complete","reject"]},{key:"[ArrowDown]",ifMode:"latex",command:"nextSuggestion"},{key:"[ArrowUp]",ifMode:"latex",command:"previousSuggestion"},{key:"ctrl+a",ifPlatform:"!macos",command:"selectAll"},{key:"cmd+a",command:"selectAll"},{key:"[Cut]",command:"cutToClipboard"},{key:"[Copy]",command:"copyToClipboard"},{key:"[Paste]",command:"pasteFromClipboard"},{key:"[Clear]",command:"deleteBackward"},{key:"[Undo]",command:"undo"},{key:"[Redo]",command:"redo"},{key:"[EraseEof]",command:"deleteToGroupEnd"},{key:"ctrl+x",ifPlatform:"ios",command:"cutToClipboard"},{key:"cmd+x",ifPlatform:"ios",command:"cutToClipboard"},{key:"ctrl+c",ifPlatform:"ios",command:"copyToClipboard"},{key:"cmd+c",ifPlatform:"ios",command:"copyToClipboard"},{key:"ctrl+v",ifPlatform:"ios",command:"pasteFromClipboard"},{key:"cmd+v",ifPlatform:"ios",command:"pasteFromClipboard"},{key:"ctrl+z",ifPlatform:"!macos",command:"undo"},{key:"cmd+z",command:"undo"},{key:"ctrl+y",ifPlatform:"!macos",command:"redo"},{key:"shift+cmd+y",command:"redo"},{key:"shift+ctrl+z",ifPlatform:"!macos",command:"redo"},{key:"shift+cmd+z",command:"redo"},{key:"ctrl+b",ifPlatform:"macos",command:"moveToPreviousChar"},{key:"ctrl+f",ifPlatform:"macos",command:"moveToNextChar"},{key:"ctrl+p",ifPlatform:"macos",command:"moveUp"},{key:"ctrl+n",ifPlatform:"macos",command:"moveDown"},{key:"ctrl+a",ifPlatform:"macos",command:"moveToMathfieldStart"},{key:"ctrl+e",ifPlatform:"macos",command:"moveToMathfieldEnd"},{key:"shift+ctrl+b",ifPlatform:"macos",command:"extendSelectionBackward"},{key:"shift+ctrl+f",ifPlatform:"macos",command:"extendSelectionForward"},{key:"shift+ctrl+p",ifPlatform:"macos",command:"extendSelectionUpward"},{key:"shift+ctrl+n",ifPlatform:"macos",command:"extendSelectionDownward"},{key:"shift+ctrl+a",ifPlatform:"macos",command:"extendToMathFieldStart"},{key:"shift+ctrl+e",ifPlatform:"macos",command:"extendToMathFieldEnd"},{key:"alt+ctrl+b",ifPlatform:"macos",command:"moveToPreviousWord"},{key:"alt+ctrl+f",ifPlatform:"macos",command:"moveToNextWord"},{key:"shift+alt+ctrl+b",ifPlatform:"macos",command:"extendToPreviousWord"},{key:"shift+alt+ctrl+f",ifPlatform:"macos",command:"extendToNextWord"},{key:"ctrl+h",ifPlatform:"macos",command:"deleteBackward"},{key:"ctrl+d",ifPlatform:"macos",command:"deleteForward"},{key:"ctrl+l",ifPlatform:"macos",command:"scrollIntoView"},{key:"ctrl+[Digit2]",ifMode:"math",command:["insert","\\sqrt{#0}"]},{key:"ctrl+[Digit5]",ifMode:"math",command:"moveToOpposite"},{key:"ctrl+[Digit6]",ifMode:"math",command:"moveToSuperscript"},{key:"ctrl+[Return]",ifMode:"math",command:"addRowAfter"},{key:"ctrl+[Enter]",ifMode:"math",command:"addRowAfter"},{key:"cmd+[Return]",ifMode:"math",command:"addRowAfter"},{key:"cmd+[Enter]",ifMode:"math",command:"addRowAfter"},{key:"alt+p",ifMode:"math",command:["insert","\\pi"]},{key:"alt+v",ifMode:"math",command:["insert","\\sqrt{#0}"]},{key:"alt+shift+v",ifMode:"math",command:["insert","\\sqrt[#0]{#1}"]},{key:"alt+o",ifMode:"math",command:["insert","\\emptyset"]},{key:"alt+d",ifMode:"math",command:["insert","\\differentialD"]},{key:"shift+alt+o",ifMode:"math",command:["insert","\\varnothing"]},{key:"shift+alt+d",ifMode:"math",command:["insert","\\partial"]},{key:"alt+[Backslash]",ifMode:"math",command:["insert","\\backslash"]},{key:"[NumpadDivide]",ifMode:"math",command:["insert","\\frac{#@}{#?}"]},{key:"alt+[NumpadDivide]",ifMode:"math",command:["insert","\\frac{#?}{#@}"]},{key:"shift+alt+k",command:"toggleKeystrokeCaption"},{key:"alt+[Space]",command:"toggleContextMenu"},{key:"alt+shift+[Space]",command:"toggleVirtualKeyboard"},{key:"alt+ctrl+[ArrowUp]",command:["speak","all",{withHighlighting:!1}]},{key:"alt+ctrl+[ArrowDown]",command:["speak","selection",{withHighlighting:!1}]},{key:"shift+[Quote]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["switchMode","text","",""]},{key:"shift+[Quote]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"text",command:["switchMode","math","",""]},{key:"shift+alt+[KeyT]",ifMode:"math",command:["switchMode","text"]},{key:"shift+alt+[KeyT]",ifMode:"text",command:["switchMode","math"]},{key:"/",ifMode:"math",command:["insert","\\frac{#@}{#?}"]},{key:"alt+/",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","/"]},{key:"alt+shift+/",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","/"]},{key:"alt+[BracketLeft]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","\\left\\lbrack #0 \\right\\rbrack"]},{key:"ctrl+[Minus]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"moveToSubscript"},{key:"shift+alt+[BracketLeft]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","\\left\\lbrace #0 \\right\\rbrace"]},{key:"ctrl+;",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"addRowAfter"},{key:"cmd+;",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"addRowAfter"},{key:"shift+ctrl+;",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"addRowBefore"},{key:"shift+cmd+;",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"addRowBefore"},{key:"alt+[Tab]",ifMode:"math",command:"addColumnAfter"},{key:"shift+alt+[Tab]",ifMode:"math",command:"addColumnBefore"},{key:"alt+[Enter]",ifMode:"math",command:"addRowAfter"},{key:"shift+alt+[Enter]",ifMode:"math",command:"addRowBefore"},{key:"alt+[Return]",ifMode:"math",command:"addRowAfter"},{key:"shift+alt+[Return]",ifMode:"math",command:"addRowBefore"},{key:"shift+[Backspace]",ifMode:"math",command:"removeColumn"},{key:"shift+[Delete]",ifMode:"math",command:"removeRow"},{key:"shift+alt+[Backspace]",ifMode:"math",command:"removeRow"},{key:"alt+[Digit5]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","$\\infty"]},{key:"alt+[Digit9]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","("]},{key:"alt+[Digit0]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert",")"]},{key:"alt+|",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","|"]},{key:"shift+[Backquote]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","\\~"]},{key:"[Backquote]",ifLayout:["windows.french","linux.french"],ifMode:"math",command:["insert","^2"]},{key:"[Backquote]",ifLayout:["windows.german","linux.german"],ifMode:"math",command:["insert","^"]},{key:"[IntlBackslash]",ifLayout:["apple.german"],ifMode:"math",command:["insert","^"]}],nn={"\\sqrt":["alt+v","ctrl+[Digit2]"],"\\pi":"alt+p","\\infty":"alt+[Digit5]","\\differentialD":"alt+d","\\partial":"shift+alt+d","\\frac":"Slash","\\emptyset":"alt+o","\\varnothing":"shift+alt+o","\\~":"~"};function nl(e){var i;return(null==(i=e.element)?void 0:i.mathfield)===e}function ns(e){var i,r;let a=null!=(r=null!=(i=e.querySelector(".ML__caret"))?i:e.querySelector(".ML__text-caret"))?r:e.querySelector(".ML__latex-caret");if(!a)return null;let o=a.getBoundingClientRect();return{x:o.right,y:o.bottom,height:o.height}}function nc(e,i,r){if(!i)return null;let a=e.field.getBoundingClientRect(),o=i.right-i.left,n=i.bottom-i.top,l=Math.ceil(i.left-a.left+e.field.scrollLeft*r),s=Math.ceil(i.top-a.top);return{left:l,right:l+o,top:s,bottom:s+n}}function nd(e){let i=e,r=i.getBoundingClientRect();for(;r.bottom===r.top&&i.parentElement instanceof Element&&(r=(i=i.parentElement).getBoundingClientRect()).bottom===r.top;);let a=getComputedStyle(i),o=parseInt(a.marginRight),n=r.right-r.left,l=r.bottom-r.top;if(0===n||!Number.isFinite(n)){let e=parseFloat(a.width);Number.isFinite(e)&&e>0?n=e:i instanceof HTMLElement&&i.offsetWidth>0&&(n=i.offsetWidth)}if(0===l||!Number.isFinite(l)){let e=parseFloat(a.height);Number.isFinite(e)&&e>0?l=e:i instanceof HTMLElement&&i.offsetHeight>0&&(l=i.offsetHeight)}let s={top:r.top-1,bottom:r.top-1+l,left:r.left,right:r.left+n-1+o};if(0===e.children.length||"SVG"===e.tagName.toUpperCase())return s;for(let i of e.children)if(1===i.nodeType&&"atomId"in i.dataset&&!i.classList.contains("ML__pstrut")){let e=nd(i);s.left=Math.min(s.left,e.left),s.right=Math.max(s.right,e.right),s.top=Math.min(s.top,e.top),s.bottom=Math.max(s.bottom,e.bottom)}return s}function nu(e,i){var r,a;if(!i.id)return null;let o=null!=(a=null==(r=e.atomBoundsCache)?void 0:r.get(i.id))?a:null;if(null!==o)return o;let n=Array.from(e.field.querySelectorAll(`[data-atom-id="${i.id}"]`));if("prompt"===i.type){for(let e of n)if(e.classList.contains("ML__prompt-atom")){let i=e.querySelector(".ML__prompt");if(i){let e=nd(i);o?(o.left=Math.min(o.left,e.left),o.right=Math.max(o.right,e.right),o.top=Math.min(o.top,e.top),o.bottom=Math.max(o.bottom,e.bottom)):o=e}}}for(let e of n){let i=nd(e);o?(o.left=Math.min(o.left,i.left),o.right=Math.max(o.right,i.right),o.top=Math.min(o.top,i.top),o.bottom=Math.max(o.bottom,i.bottom)):o=i}return e.atomBoundsCache&&(o?e.atomBoundsCache.set(i.id,o):e.atomBoundsCache.delete(i.id)),null!=o?o:null}function nh(e,i){return e.model.selection.ranges.reduce((r,a)=>r.concat(...function(e,i,r){let a=new Map,o=e.field,n=o.offsetWidth,l=Math.floor(o.getBoundingClientRect().width)/n;for(let o of(l=isNaN(l)?1:l,e.model.getAtoms(i,{includeChildren:!0}))){if(null!=r&&r.excludeAtomsWithBackground&&o.style.backgroundColor)continue;let i=nc(e,nu(e,o),l);if(i){let e=function(e){var i;return e.parent?(null!=(i=e.parent.id)?i:"")+("string"==typeof e.parentBranch?"-"+e.parentBranch:`-${e.parentBranch[0]}/${e.parentBranch[0]}`):"root"}(o);if(a.has(e)){let r=a.get(e);a.set(e,{left:Math.min(r.left,i.left),right:Math.max(r.right,i.right),top:Math.min(r.top,i.top),bottom:Math.max(r.bottom,i.bottom)})}else a.set(e,i)}}return[...a.values()]}(e,a,i)),[])}function np(e,i){return"*"===e||"none"===i||("same-origin"===i?!window.origin||e===window.origin:"function"==typeof i&&i(e))}function nm(e){let i=0,r=0,a=e.offsetWidth,o=e.offsetHeight;for(;e instanceof HTMLElement;)i+=e.offsetTop,r+=e.offsetLeft,e=e.offsetParent;return new DOMRect(r,i,a,o)}function nf(e,i){if(!e)return;let r=e.model.at(i);if(!r)return;let a={},o=nu(e,r);o&&(a.bounds=new DOMRect(o.left,o.top,o.right-o.left,o.bottom-o.top)),a.depth=r.treeDepth-2,a.style=r.style;let n=r;for(;n;){if("\\htmlData"===n.command&&n.args&&"string"==typeof n.args[0])for(let e of n.args[0].split(",")){let i=e.match(/([^=]+)=(.+$)/);if(i){let e=i[1].trim().replace(/ /g,"-");e&&(a.data||(a.data={}),a.data[e]=i[2])}else{let i=e.trim().replace(/ /g,"-");i&&(a.data||(a.data={}),a.data[i]=void 0)}}("\\htmlId"===n.command||"\\cssId"===n.command)&&!a.id&&n.args&&"string"==typeof n.args[0]&&(a.id=n.args[0]),n=n.parent}return("math"===r.mode||"text"===r.mode)&&(a.latex=oG.serialize([r],{defaultMode:"math"})),a}var ng,nb=`@keyframes ML__caret-blink {
|
|
191
|
+
M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`},od=[[8205,1],[65038,2],[127995,5],[129456,4],[917536,96]];function ou(e){var i;if(void 0===on)for(let e of(on={},od))for(let i=e[0];i<=e[0]+e[1]-1;i++)on[i]=!0;return null!=(i=on[e])&&i}function oh(e){if(/^[\u0020-\u00FF]*$/.test(e))return e;let i=[],r=function(e){let i=[];for(let r=0;r<e.length;r++){let a=e.charCodeAt(r);if(13===a&&10===e.charCodeAt(r+1)&&(a=10,r++),(13===a||12===a)&&(a=10),0===a&&(a=65533),a>=55296&&a<=56319){let i=e.charCodeAt(r+1);i>=56320&&i<=57343&&(a=65536+1024*(a-55296)+(i-56320),r++)}i.push(a)}return i}(e),a=0;for(;a<r.length;){let e=r[a++],o=r[a];if(8205===o){let e=a-1;for(a+=2;8205===r[a];)a+=2;i.push(String.fromCodePoint(...r.slice(e,a-e+1)))}else if(ou(o)){let e=a-1;for(;ou(r[a]);)a+=8205===r[a]?2:1;i.push(String.fromCodePoint(...r.slice(e,2*a-e-1)))}else e>=127462&&e<=127487?(a+=1,i.push(String.fromCodePoint(...r.slice(a-2,2)))):i.push(String.fromCodePoint(e))}return i}var op=class{constructor(e){this.obeyspaces=!1,this.pos=0,this.s=oh(e)}end(){return this.pos>=this.s.length}get(){return this.pos<this.s.length?this.s[this.pos++]:""}peek(){return this.s[this.pos]}match(e){let i="string"==typeof this.s?e.exec(this.s.slice(this.pos)):e.exec(this.s.slice(this.pos).join(""));return null!=i&&i[0]?(this.pos+=i[0].length,i[0]):""}next(){if(this.end())return null;if(!this.obeyspaces&&this.match(/^[ \f\n\r\t\v\u00A0\u2028\u2029]+/)||this.obeyspaces&&this.match(/^[ \f\n\r\t\v\u00A0\u2028\u2029]/))return"<space>";let e=this.get();if("\\"===e){if(!this.end()){let e=this.match(/^[a-zA-Z\*]+/);return e?this.match(/^[ \f\n\r\t\v\u00A0\u2028\u2029]*/):e=this.get(),"\\"+e}}else{if("{"===e)return"<{>";if("}"===e)return"<}>";if("^"===e){if("^"===this.peek()){this.get();let e=this.match(/^(\^(\^(\^(\^[\da-f])?[\da-f])?[\da-f])?[\da-f])?[\da-f]{2}/);if(e)return String.fromCodePoint(Number.parseInt(e.slice(e.lastIndexOf("^")+1),16))}}else if("#"===e){if(!this.end()){let e=!1;if(/[\d?@]/.test(this.peek())&&(e=!0,this.pos+1<this.s.length)){let i=this.s[this.pos+1];e=/[^\dA-Za-z]/.test(i)}return e?"#"+this.get():"#"}}else if("$"===e)return"$"===this.peek()?(this.get(),"<$$>"):"<$>"}return e}};function om(e,i=null){if(!e)return[];let r=[],a="";for(let i of e.toString().split(/\r?\n/)){a&&r.push(a),a=" ";let e=i.match(/((?:\\%)|[^%])*/);null!==e&&r.push(e[0])}let o=new op(r.join("")),n=[];do n.push(...function(e,i){var r,a,o,n;let l=[],s=e.next();if(s&&"\\relax"!==s){if("\\noexpand"===s)(s=e.next())&&l.push(s);else if("\\obeyspaces"===s)e.obeyspaces=!0;else if("\\bgroup"===s)l.push("<{>");else if("\\egroup"===s)l.push("<}>");else if("\\string"===s){if(s=e.next())if(s.startsWith("\\"))for(let e of s)l.push("\\"===e?"\\backslash":e);else"<{>"===s?l.push("\\{"):"<space>"===s?l.push("~"):"<}>"===s&&l.push("\\}")}else if("\\csname"===s){for(;"<space>"===e.peek();)e.next();let o="",n=!1,c=[];do{if(0===c.length)if(/^#[\d?@]$/.test(e.peek())){let o=e.get().slice(1);s=(c=om(null!=(a=null!=(r=null==i?void 0:i(o))?r:null==i?void 0:i("?"))?a:"\\placeholder{}",i))[0]}else c=(s=e.next())?[s]:[];(n=0===c.length)||"\\endcsname"!==s||(n=!0,c.shift()),n||(n="<$>"===s||"<$$>"===s||"<{>"===s||"<}>"===s||"string"==typeof s&&s.length>1&&s.startsWith("\\")),n||(o+=c.shift())}while(!n)o&&l.push("\\"+o),l.push(...c)}else if("\\endcsname"!==s)if(s.length>1&&s.startsWith("#")){let e=s.slice(1);l.push(...om(null!=(n=null!=(o=null==i?void 0:i(e))?o:null==i?void 0:i("?"))?n:"\\placeholder{}",i))}else l.push(s)}return l}(o,i));while(!o.end())return n}function of(e){let i="",r=[];for(let a of e)a&&(i&&/^[a-zA-Z\*]/.test(a)&&r.push(i),r.push(a),/^\\[a-zA-Z]+\*?[\"\'][^\ ]+$/.test(a)&&r.push(" "),i=/\\[a-zA-Z]+\*?$/.test(a)?" ":"");return r.join("")}function og(e,...i){return e.startsWith("\\"),0===i.length?e:of([e,...i.map(e=>`{${e}}`)])}function ob(e){return of(e.map(e=>{var i;return null!=(i=({"<space>":" ","<$$>":"$$","<$>":"$","<{>":"{","<}>":"}"})[e])?i:e}))}var oy=class e{constructor(i){e._registry[i]=this}static createAtom(i,r,a){return e._registry[i].createAtom(r,eM(r,i),a)}static serialize(i,r){var a;if(!i||0===i.length)return"";if(null!=(a=r.skipStyles)&&a){let a=[];for(let o of ox(i)){let i=e._registry[o[0].mode];a.push(...i.serialize(o,r))}return of(a)}return of(function(e,i){if(0===e.length)return[];let{parent:r}=e[0],a=null==r?void 0:r.style.fontSize,o=[];for(let n of ok(e,"fontSize")){let e=n[0].style.fontSize,l=function(e,i){let{parent:r}=e[0],a=null==r?void 0:r.style.backgroundColor;return ok(e,"backgroundColor").map(e=>{var o;if(e.length>0||"box"!==e[0].type){let n=e[0].style;if(n.backgroundColor&&"none"!==n.backgroundColor&&(!r||a!==n.backgroundColor))return og("\\colorbox",null!=(o=n.verbatimBackgroundColor)?o:n.backgroundColor,of(oM(e,g(f({},i),{defaultMode:"text"}))))}return of(oM(e,i))})}(n,i);l&&(e&&"auto"!==e&&(!r||a!==e)?o.push(["","\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"][e],...l):o.push(...l))}return o}(i,r))}static getFont(i,r,a){return e._registry[i].getFont(r,a)}};oy._registry={};var ov=oy;function ox(e){let i=[],r=[],a="NONE";for(let o of e)"first"!==o.type&&(o.mode!==a?(r.length>0&&i.push(r),r=[o],a=o.mode):r.push(o));return r.length>0&&i.push(r),i}function o_(e){if((null==e?void 0:e.mode)!=="math")return"";let{style:i}=e;return i&&i.variantStyle&&("bold"===i.variantStyle||"bolditalic"===i.variantStyle)?"bold":""}function ow(e){if(!e)return"";let{style:i}=e;if(!i)return"";let r=i.variant;return void 0===r&&(r="normal"),!["calligraphic","fraktur","double-struck","script","monospace","sans-serif"].includes(r)&&i.variantStyle&&(r+="-"+i.variantStyle),r}function ok(e,i){let r=[],a=[],o;for(let n of e){let e;"first"!==n.type&&((e="variant"===i?ow(n):"bold"===i?o_(n):n.style[i])===o?a.push(n):(a.length>0&&r.push(a),a=[n],o=e))}return a.length>0&&r.push(a),r}function oM(e,i){var r;let{parent:a}=e[0],o=null==a?void 0:a.style.color,n=[];for(let l of ox(e)){let e=i.defaultMode;for(let s of ok(l,"color")){let l=s[0].style,c=ov._registry[s[0].mode].serialize(s,g(f({},i),{defaultMode:"text"===e?"text":"math"}));i.skipStyles||!l.color||"none"===l.color||a&&o===l.color?n.push(of(c)):n.push(og("\\textcolor",null!=(r=l.verbatimColor)?r:l.color,of(c)))}}return n}function oS(e){return e?({mord:"ord",mbin:"bin",mop:"op",mrel:"rel",mopen:"open",mclose:"close",mpunct:"punct",minner:"inner",spacing:"ignore",newline:"newline",latex:"latex",composition:"inner",error:"inner",placeholder:"ord",supsub:"ignore"})[e]:void 0}function oL(e){if(0===e.length)return"ord";let i=oS(e[0].type),r=oS(e[e.length-1].type);return i&&i===r?i:"ord"}function oC(e,i){if("string"==typeof e)return e;if("number"==typeof e){Number.isFinite(e);let r=Math.ceil(100*e)/100;return 0===r?"0":r.toString()+(null!=i?i:"")}return""}var oE=class e{constructor(i,r){var a,o,n,l,s;if("number"==typeof i?this.value=String.fromCodePoint(i):"string"==typeof i?this.value=i:R(i)?this.children=i.filter(e=>null!==e):i&&i instanceof e&&(this.children=[i]),this.children)for(let e of this.children)e.parent=this;this.type=null!=(a=null==r?void 0:r.type)?a:"ignore",this.isSelected=(null==r?void 0:r.isSelected)===!0,null!=r&&r.caret&&(this.caret=r.caret),this.classes=null!=(o=null==r?void 0:r.classes)?o:"",this.isTight=null!=(n=null==r?void 0:r.isTight)&&n,null!=r&&r.attributes&&(this.attributes=r.attributes);let c=null==r?void 0:r.fontFamily;null!=r&&r.style&&this.value&&(c=null!=(s=ov.getFont(null!=(l=r.mode)?l:"math",this,g(f({variant:"normal"},r.style),{letterShapeStyle:r.letterShapeStyle})))?s:void 0),c||(c="Main-Regular"),this._height=0,this._depth=0,this._width=0,this.hasExplicitWidth=!1,this.skew=0,this.italic=0,this.maxFontSize=0,this.scale=1,(null==r?void 0:r.maxFontSize)!==void 0&&(this.maxFontSize=r.maxFontSize),function(e,i){var r;if("latex"===e.type){e.height=.9,e.depth=.2,e._width=1;return}if(e.value){e.height=-1/0,e.depth=-1/0,e._width=0,e.skew=-1/0,e.italic=-1/0;for(let r=0;r<e.value.length;r++){let a=oa(e.value.codePointAt(r),i);e.height=Math.max(e.height,a.height),e.depth=Math.max(e.depth,a.depth),e._width+=a.width,e.skew=a.skew,e.italic=a.italic}return}if(e.children&&e.children.length>0){let i=-1/0,a=-1/0,o=0;for(let n of e.children)n.height>i&&(i=n.height),n.depth>a&&(a=n.depth),o=Math.max(o,null!=(r=n.maxFontSize)?r:0);e.height=i,e.depth=a,e._width=e.children.reduce((e,i)=>e+i.width,0),e.maxFontSize=o}}(this,c)}set atomID(e){void 0===e||0===e.length||(this.id=e)}selected(e){if(this.isSelected!==e&&(this.isSelected=e,this.children))for(let i of this.children)i.selected(e)}setStyle(e,i,r){if(void 0===i)return;let a=oC(i,r);a.length>0&&(this.cssProperties||(this.cssProperties={}),this.cssProperties[e]=a)}setTop(e){Number.isFinite(e)&&Math.abs(e)>.01&&(this.cssProperties||(this.cssProperties={}),this.cssProperties.top=oC(e,"em"),this.height-=e,this.depth+=e)}get left(){var e;return null!=(e=this.cssProperties)&&e["margin-left"]?Number.parseFloat(this.cssProperties["margin-left"]):0}set left(e){Number.isFinite(e)&&(0===e?this.cssProperties&&delete this.cssProperties["margin-left"]:(this.cssProperties||(this.cssProperties={}),this.cssProperties["margin-left"]=oC(e,"em")))}set right(e){Number.isFinite(e)&&(0===e?this.cssProperties&&delete this.cssProperties["margin-right"]:(this.cssProperties||(this.cssProperties={}),this.cssProperties["margin-right"]=oC(e,"em")))}set bottom(e){Number.isFinite(e)&&(0===e?this.cssProperties&&delete this.cssProperties["margin-bottom"]:(this.cssProperties||(this.cssProperties={}),this.cssProperties["margin-bottom"]=oC(e,"em")))}get width(){return this._width*this.scale}set width(e){this._width=e,this.hasExplicitWidth=!0}set softWidth(e){}get height(){return this._height*this.scale}set height(e){this._height=e}get depth(){return this._depth*this.scale}set depth(e){this._depth=e}wrap(e){let i=e.parent;if(!i)return this;e.isPhantom&&this.setStyle("opacity",0);let r=e.color;r&&r!==i.color&&this.setStyle("color",r);let a=e.backgroundColor;this.isSelected&&(a=function(e){let i=function(e){let i;if(e&&"#"===e[0])return(e=e.slice(1)).length<=4?(i={r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16)},4===e.length&&(i.a=parseInt(e[3]+e[3],16)/255)):(i={r:parseInt(e[0]+e[1],16),g:parseInt(e[2]+e[3],16),b:parseInt(e[4]+e[5],16)},8===e.length&&(i.a=parseInt(e[6]+e[7],16)/255)),i&&void 0===i.a&&(i.a=1),i}(e);if(!i)return e;let{h:r,s:a,l:o}=function(e){let{r:i,g:r,b:a}=e;i/=255;let o=Math.min(i,r/=255,a/=255),n=Math.max(i,r,a),l=n-o,s;n===o?s=0:i===n?s=(r-a)/l:r===n?s=2+(a-i)/l:a===n&&(s=4+(i-r)/l),(s=Math.min(60*s,360))<0&&(s+=360);let c=(o+n)/2;return{h:s,s:n===o?0:c<=.5?l/(n+o):l/(2-n-o),l:c}}(i);return function(e){let{r:i,g:r,b:a}=e,o=(0x1000000+(G(i)<<16)+(G(r)<<8)+G(a)).toString(16).slice(1);return o[0]===o[1]&&o[2]===o[3]&&o[4]===o[5]&&o[6]===o[7]&&(o=o[0]+o[2]+o[4]),"#"+o}(function(e){let[i,r,a]=[e.h,e.s,e.l];i=(i+360)%360/60,a=Math.max(0,Math.min(a,1)),r=Math.max(0,Math.min(r,1));let o=a<=.5?a*(r+1):a+r-a*r,n=2*a-o;return{r:Math.round(255*X(n,o,i+2)),g:Math.round(255*X(n,o,i)),b:Math.round(255*X(n,o,i-2))}}({h:r,s:a+=.1,l:o-=.1}))}(a)),a&&a!==i.backgroundColor&&(this.setStyle("background-color",a),this.setStyle("--bg-color",a),this.setStyle("display","inline-block"),this.setStyle("position","relative"),this.classes=this.classes?`${this.classes} ML__bg`:"ML__bg");let o=e.scalingFactor;return this.scale=o,this.skew*=o,this.italic*=o,this}toMarkup(){var e,i,r;let a=this.value?this.value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"):"";if(this.children)for(let e of this.children)a+=e.toMarkup();let o="";if(this.svgBody)o=function(e){if(os[e]){let[i,r,a]=os[e],o=`<span class="ML__stretchy" style="height:${a}em"><svg width="100%" height="${a}em" viewBox="0 0 ${i} ${r}" preserveAspectRatio="none" ><path fill="currentcolor" d="${oc[e]}"></path></svg></span>`;return`<span style="display:inline-block;height:${Math.floor(100*a/2)/100}em;min-width:0">${o}</span>`}let[i,r,a,o]=ol[e],n,l,s=a/1e3;3===i.length?(n=["slice-1-of-3","slice-2-of-3","slice-3-of-3"],l=["xMinYMin","xMidYMin","xMaxYMin"]):2===i.length?(n=["slice-1-of-2","slice-2-of-2"],l=["xMinYMin","xMaxYMin"]):(n=["slice-1-of-1"],l=[o]);let c=i.map((e,i)=>`<span class="${n[i]}" style=height:${s}em><svg width=400em height=${s}em viewBox="0 0 400000 ${a}" preserveAspectRatio="${l[i]} slice"><path fill="currentcolor" d="${oc[e]}"></path></svg></span>`).join("");return`<span style="display:inline-block;height:${s}em;min-width:${r}em;">${c}</span>`}(this.svgBody);else if(this.svgOverlay){o=`<span style="display: inline-block;height:${Math.floor(100*(this.height+this.depth))/100}em;vertical-align:${Math.floor(100*this.depth)/100}em;">`+a+'</span><svg style="position:absolute;overflow:visible;'+`height:${Math.floor(100*(this.height+this.depth))/100}em;`;let i=null==(e=this.cssProperties)?void 0:e.padding;i?(o+=`top:${i};`,o+=`left:${i};`,o+=`width:calc(100% - 2 * ${i} );`):o+="top:0;left:0;width:100%;",o+="z-index:2;",o+='"',this.svgStyle&&(o+=this.svgStyle),o+=` viewBox="0 0 ${Math.floor(100*this.width)/100} ${Math.floor(100*(this.height+this.depth))/100}"`,o+=`>${this.svgOverlay}</svg>`}let n=[],l=this.classes.split(" ");l.push(null!=(i=({latex:"ML__raw-latex",placeholder:"ML__placeholder",error:"ML__error"})[this.type])?i:""),"latex"===this.caret&&l.push("ML__latex-caret"),this.isSelected&&l.push("ML__selected");let s=1===l.length?l[0]:l.filter((e,i,r)=>e.length>0&&r.indexOf(e)===i).join(" ");if(s.length>0&&n.push(`class=${oK(`"${s}"`)}`),this.id&&n.push(` data-atom-id=${oK(this.id)}`),this.cssId&&n.push(` id=${oK(`"${this.cssId.replace(/ /g,"-")}"`)}`),this.attributes&&n.push(...Object.keys(this.attributes).map(e=>`${oD(e)}=${oK(this.attributes[e])}`)),this.htmlData)for(let e of this.htmlData.split(",")){let i=e.match(/([^=]+)=(.+$)/);if(i){let e=oD(i[1]);if(e)if("href"===e){let e=new URL(i[2]);if("http:"!==e.protocol&&"https:"!==e.protocol)throw Error(`Invalid URL: ${i[2]}`);n.push(`href="${i[2].replace(/"/g,""")}"`)}else n.push(`data-${e}=${oK(i[2])}`)}else{let i=oD(e);i&&n.push(`data-${i} `)}}let c=null!=(r=this.cssProperties)?r:{};this.hasExplicitWidth&&void 0===c.width&&(c.width=`${Math.ceil(100*this._width)/100}em`);let d=Object.keys(c).map(e=>`${e}:${c[e]}`);if(void 0!==this.scale&&1!==this.scale&&(a.length>0||o.length>0)&&d.push(`font-size: ${Math.ceil(1e4*this.scale)/100}%`),this.htmlStyle)for(let e of this.htmlStyle.split(";")){let i=e.match(/([^:]+):(.+$)/);if(i){let e=i[1].trim().replace(/ /g,"-");e&&d.push(`${e}:${i[2]}`)}}d.length>0&&n.push(`style=${oK(d.join(";"))}`);let u="";return u=n.length>0||o.length>0?`<span ${n.join(" ")}>${a}${o}</span>`:a,"text"===this.caret?u+='<span class="ML__text-caret"></span>':"math"===this.caret&&(u+='<span class="ML__caret"></span>'),u}tryCoalesceWith(e){if(this.svgBody||!this.value||e.svgBody||!e.value)return!1;let i=this.children&&this.children.length>0,r=e.children&&e.children.length>0;if(i||r)return!1;if(e.cssProperties||this.cssProperties){for(let i of["border","border-left","border-right","border-right-width","left","margin","margin-left","margin-right","padding","position","width"])if(e.cssProperties&&i in e.cssProperties||this.cssProperties&&i in this.cssProperties)return!1}let a=this.cssProperties?Object.keys(this.cssProperties).length:0;if(a!==(e.cssProperties?Object.keys(e.cssProperties).length:0))return!1;if(a>0){for(let i of Object.keys(this.cssProperties))if(this.cssProperties[i]!==e.cssProperties[i])return!1}let o=this.classes.trim().replace(/\s+/g," ").split(" "),n=e.classes.trim().replace(/\s+/g," ").split(" ");if(o.length!==n.length)return!1;for(let[e,i]of(o.sort(),n.sort(),o.entries()))if("ML__vertical-separator"===i||i!==n[e])return!1;return this.value+=e.value,this.height=Math.max(this.height,e.height),this.depth=Math.max(this.depth,e.depth),this._width=this._width+e._width,this.maxFontSize=Math.max(this.maxFontSize,e.maxFontSize),this.italic=e.italic,!0}};function oA(e){return e.children&&(e.children=function e(i){if(!i||0===i.length)return[];i[0].children=e(i[0].children);let r=[i[0]];for(let a=1;a<i.length;a++)r[r.length-1].tryCoalesceWith(i[a])||(i[a].children=e(i[a].children),r.push(i[a]));return r}(e.children)),e}function oz(e,i){if(!e)return new oE(null,i);let r=new oE(null,{classes:"ML__strut",type:"ignore"});r.setStyle("height",Math.max(0,e.height),"em");let a=[r];if(0!==e.depth){let i=new oE(null,{classes:"ML__strut--bottom",type:"ignore"});i.setStyle("height",e.height+e.depth,"em"),i.setStyle("vertical-align",-e.depth,"em"),a.push(i)}return a.push(e),new oE(a,g(f({},i),{type:"lift"}))}function oT(e){let i=(ol[e]?ol[e][2]/1e3:os[e][2])/2,r=new oE(null,{maxFontSize:0});return r.height=i+.166,r.depth=i-.166,r.svgBody=e,r}function oD(e){if(0===(e=e.trim().replace(/ /g,"-")).length)throw Error("Invalid empty attribute name");if(/[\x20\x09\x0a\x0c\x0d"'>/=\x00-\x1f]/.test(e))throw Error(`Invalid attribute name "${e}"`);return e}function oK(e){if((e=e.trim()).startsWith('"')&&e.endsWith('"')){if(/"/.test(e.slice(1,-1)))throw Error(`Invalid attribute value: ${e}`);return e}if(e.startsWith("'")&&e.endsWith("'")){if(/'/.test(e.slice(1,-1)))throw Error(`Invalid attribute value: ${e}`);return e}if(0===e.length)throw Error("Invalid empty attribute value");return`"${e.replace(/"/g,""")}"`}var oB=class extends oE{constructor(e,i){var r;let[a,o,n]=function(e){var i;let[r,a]=function(e){if("individualShift"in e){let i=e.individualShift,r=i[0];if(null==r)return[null,0];let a=[r],o=-r.shift-r.box.depth,n=o;for(let e=1;e<i.length;e++){let o=i[e],l=-o.shift-n-o.box.depth,s=l-(r.box.height+r.box.depth);n+=l,a.push(s),a.push(o),r=o}return[a,o]}if("top"in e){let i=e.top;for(let r of e.children)i-="number"==typeof r?r:r.box.height+r.box.depth;return[e.children,i]}if("bottom"in e)return[e.children,-e.bottom];if("firstBaseline"in e){let i=e.firstBaseline[0];if("number"==typeof i)throw Error("First child must be an element.");return[e.firstBaseline,-i.box.depth]}if("shift"in e){let i=e.children[0];if("number"==typeof i)throw Error("First child must be an element.");return[e.children,-i.box.depth-e.shift]}return[null,0]}(e);if(!r)return[[],0,0];let o=new oE(null,{classes:"ML__pstrut"}),n=0;for(let e of r)if("number"!=typeof e){let i=e.box;n=Math.max(n,i.maxFontSize,i.height)}o.height=n+=2,o.setStyle("height",n,"em");let l=[],s=a,c=a,d=a,u=0;for(let e of r){if("number"==typeof e)d+=e;else{let r=e.box,a=new oE([o,r],{classes:(null!=(i=e.classes)?i:[]).join(" "),style:e.style});r.setStyle("height",r.height+r.depth,"em"),r.setStyle("display","inline-block"),a.setStyle("top",-n-d-r.depth,"em"),e.marginLeft&&a.setStyle("margin-left",e.marginLeft,"em"),e.marginRight&&a.setStyle("margin-right",e.marginRight,"em"),l.push(a),d+=r.height+r.depth,u=Math.max(u,a.width)}s=Math.min(s,d),c=Math.max(c,d)}l.forEach(e=>{e.softWidth=u});let h=new oE(l,{classes:"ML__vlist"});if(h.softWidth=u,h.height=c,h.setStyle("height",c,"em"),s>=0)return[[new oE(h,{classes:"ML__vlist-r"})],c,-s];let p=new oE(new oE(null),{classes:"ML__vlist"});p.height=-s,p.setStyle("height",-s,"em");let m=new oE(8203,{classes:"ML__vlist-s",maxFontSize:0});return m.softWidth=0,m.height=0,m.depth=0,[[new oE([h,m],{classes:"ML__vlist-r"}),new oE(p,{classes:"ML__vlist-r"})],c,-s]}(e);super(1===a.length?a[0]:a,{type:null==i?void 0:i.type,classes:(null!=(r=null==i?void 0:i.classes)?r:"")+" ML__vlist-t"+(2===a.length?" ML__vlist-t2":"")}),this.height=o,this.depth=n,this.softWidth=a.reduce((e,i)=>Math.max(e,i.width),0)}},o$={fractionNavigationOrder:"numerator-denominator",compactSerialization:!0},oP=class{constructor(e,i,r){this.id=e,this.sizeDelta=i,this.cramped=r;let a={"-4":2,"-3":1,0:0}[i];this.metrics=Object.keys(ot).reduce((e,i)=>g(f({},e),{[i]:ot[i][a]}),{})}getFontSize(e){return Math.max(1,e+this.sizeDelta)}get sup(){return oR[[0,1,0,1,2,3,2,3][this.id]]}get sub(){return oR[[0,0,0,0,2,2,2,2][this.id]]}get fracNum(){return oR[[0,1,0,1,2,3,4,5][this.id]]}get fracDen(){return oR[[0,0,0,0,2,2,4,4][this.id]]}get cramp(){return oR[[0,0,2,2,4,4,6,6][this.id]]}get isTight(){return this.sizeDelta<0}},oO={7:new oP(7,0,!1),6:new oP(6,0,!0),5:new oP(5,0,!1),4:new oP(4,0,!0),3:new oP(3,-3,!1),2:new oP(2,-3,!0),1:new oP(1,-4,!1),0:new oP(0,-4,!0)},oR=g(f({},oO),{displaystyle:oO[7],textstyle:oO[5],scriptstyle:oO[3],scriptscriptstyle:oO[1]});function oI(e,i){var r;if(!e)return 0;let a={pt:1,mm:7227/2540,cm:7227/254,ex:35271/8192,px:.75,em:10,bp:1.00375,dd:1238/1157,pc:12,in:72.27,mu:10/18}[null!=(r=e.unit)?r:"pt"];if(Number.isFinite(i)){let r=10**i;return Math.round(e.dimension/10*a*r)/r}return e.dimension*a}function oN(e,i){if(null===e)return 0;let r=oI(e)/10;if(Number.isFinite(i)){let e=10**i;return Math.round(r*e)/e}return r}function oq(e){var i;return`${e.dimension}${null!=(i=e.unit)?i:"pt"}`}function oF(e){var i,r;let a;if(null==e)return null;let o="";if("dimension"in e&&(o=`${e.dimension}${null!=(i=e.unit)?i:"pt"}`),"glue"in e&&(a=oq(e.glue),e.grow&&0!==e.grow.dimension&&(a+=` plus ${oq(e.grow)}`),e.shrink&&0!==e.shrink.dimension&&(a+=` minus ${oq(e.shrink)}`),o=a),"number"in e)if("base"in e&&"decimal"!==e.base)if("alpha"===e.base)o=`\`${String.fromCodePoint(e.number)}`;else{let i=Math.round(e.number)>>>0;"hexadecimal"===e.base?(o=Number(i).toString(16).toUpperCase(),o=i<=255?o.padStart(2,"0"):i<=65535?o.padStart(4,"0"):i<=0xffffff?o.padStart(6,"0"):o.padStart(8,"0"),o=`"${o}`):"octal"===e.base&&(o=Number(i).toString(8),o=i<=63?o.padStart(2,"0"):i<=30583?o.padStart(4,"0"):o.padStart(8,"0"),o=`'${o}`)}else o=Number(e.number).toString();return"register"in e&&("factor"in e&&(-1===e.factor?o="-":1!==e.factor&&(o=Number(e.factor).toString())),"global"in e&&e.global&&(o+="\\global"),o+=`\\${e.register}`),"string"in e&&(o=e.string),null!=(r=e.relax)&&r&&(o+="\\relax"),o}function oV(e,i){return null==e?null:"number"in e?g(f({},e),{number:e.number*i}):"register"in e?"factor"in e&&e.factor?g(f({},e),{factor:e.factor*i}):g(f({},e),{factor:i}):"dimension"in e?g(f({},e),{dimension:e.dimension*i}):"glue"in e?e.shrink&&e.grow?{glue:oV(e.glue,i),shrink:oV(e.shrink,i),grow:oV(e.grow,i)}:e.shrink?{glue:oV(e.glue,i),shrink:oV(e.shrink,i)}:e.grow?{glue:oV(e.glue,i),grow:oV(e.grow,i)}:{glue:oV(e.glue,i)}:null}var oj={"p@":{dimension:1},"z@":{dimension:0},maxdimen:{dimension:16383.99999},hfuzz:{dimension:.1},vfuzz:{dimension:.1},overfullrule:{dimension:5},hsize:{dimension:6.5,unit:"in"},vsize:{dimension:8.9,unit:"in"},parindent:{dimension:20},maxdepth:{dimension:4},splitmaxdepth:{register:"maxdimen"},boxmaxdepth:{register:"maxdimen"},delimitershortfall:{dimension:5},nulldelimiterspace:{dimension:1.2,unit:"pt"},scriptspace:{dimension:.5},topskip:{dimension:10},splittopskip:{dimension:10},normalbaselineskip:{dimension:12},normallineskip:{dimension:1},normallineskiplimit:{dimension:0},jot:{dimension:3},doublerulesep:{dimension:2},arrayrulewidth:{dimension:.4},arraycolsep:{dimension:5},fboxsep:{dimension:3},fboxrule:{dimension:.4},"z@skip":{glue:{dimension:0},shrink:{dimension:0},grow:{dimension:0}},hideskip:{glue:{dimension:-1e3},grow:{dimension:1,unit:"fill"}},"@flushglue":{glue:{dimension:0},grow:{dimension:1,unit:"fill"}},parskip:{glue:{dimension:0},grow:{dimension:1}},abovedisplayskip:{glue:{dimension:12},grow:{dimension:3},shrink:{dimension:9}},abovedisplayshortskip:{glue:{dimension:0},grow:{dimension:3}},belowdisplayskip:{glue:{dimension:12},grow:{dimension:3},shrink:{dimension:9}},belowdisplayshortskip:{glue:{dimension:7},grow:{dimension:3},shrink:{dimension:4}},parfillskip:{glue:{dimension:0},grow:{dimension:1,unit:"fil"}},thinmuskip:{glue:{dimension:3,unit:"mu"}},medmuskip:{glue:{dimension:4,unit:"mu"},grow:{dimension:2,unit:"mu"},shrink:{dimension:4,unit:"mu"}},thickmuskip:{glue:{dimension:5,unit:"mu"},grow:{dimension:5,unit:"mu"}},smallskipamount:{glue:{dimension:3},grow:{dimension:1},shrink:{dimension:1}},medskipamount:{glue:{dimension:6},grow:{dimension:2},shrink:{dimension:3}},bigskipamount:{glue:{dimension:12},grow:{dimension:2},shrink:{dimension:4}},pretolerance:100,tolerance:200,hbadness:1e3,vbadness:1e3,linepenalty:10,hyphenpenalty:50,exhyphenpenalty:50,binoppenalty:700,relpenalty:500,clubpenalty:150,widowpenalty:150,displaywidowpenalty:50,brokenpenalty:100,predisplaypenalty:1e4,doublehyphendemerits:1e4,finalhyphendemerits:5e3,adjdemerits:1e4,tracinglostchars:1,uchyph:1,delimiterfactor:901,defaulthyphenchar:"\\-",defaultskewchar:-1,newlinechar:-1,showboxbreadth:5,showboxdepth:3,errorcontextlines:5,interdisplaylinepenalty:100,interfootnotelinepenalty:100,baselineSkip:1.2,arraystretch:1,month:new Date().getMonth()+1,day:new Date().getDate(),year:new Date().getFullYear()};function oH(){return{registers:f({},oj),smartFence:!1,renderPlaceholder:void 0,placeholderSymbol:"▢",letterShapeStyle:I.locale.startsWith("fr")?"french":"tex",minFontScale:0,maxMatrixCols:10,colorMap:U,backgroundColorMap:J,getMacro:e=>eS(e,e_())}}var oW=class e{constructor(i,r){var a,o,n,l,s,c,d,u,h,p,m,g,b,y,v;let x;null!=i&&i.parent?(this.parent=i.parent,x=i.parent,this.registers={}):(x=f(f({},oH()),null!=(a=null==i?void 0:i.from)?a:{}),this.registers=x.registers),x.atomIdsSettings&&(this.atomIdsSettings=f({},x.atomIdsSettings)),this.renderPlaceholder=x.renderPlaceholder,this.isPhantom=null!=(l=null!=(n=null==i?void 0:i.isPhantom)?n:null==(o=this.parent)?void 0:o.isPhantom)&&l,this.letterShapeStyle=x.letterShapeStyle,this.minFontScale=x.minFontScale,this.maxMatrixCols=x.maxMatrixCols,null!=r&&r.color&&"none"!==r.color?this.color=r.color:this.color=null!=(c=null==(s=this.parent)?void 0:s.color)?c:"",null!=r&&r.backgroundColor&&"none"!==r.backgroundColor?this.backgroundColor=r.backgroundColor:this.backgroundColor=null!=(u=null==(d=this.parent)?void 0:d.backgroundColor)?u:"",null!=r&&r.fontSize&&"auto"!==r.fontSize&&r.fontSize!==(null==(h=this.parent)?void 0:h.size)?this.size=r.fontSize:this.size=null!=(m=null==(p=this.parent)?void 0:p.size)?m:5;let _=null!=(b=null==(g=this.parent)?void 0:g.mathstyle)?b:oR.displaystyle;if("string"==typeof(null==i?void 0:i.mathstyle)){if(x instanceof e)switch(i.mathstyle){case"cramp":_=_.cramp;break;case"superscript":_=_.sup;break;case"subscript":_=_.sub;break;case"numerator":_=_.fracNum;break;case"denominator":_=_.fracDen}switch(i.mathstyle){case"textstyle":_=oR.textstyle;break;case"displaystyle":_=oR.displaystyle;break;case"scriptstyle":_=oR.scriptstyle;break;case"scriptscriptstyle":_=oR.scriptscriptstyle}}this.mathstyle=_,this.smartFence=x.smartFence,this.placeholderSymbol=x.placeholderSymbol,this.colorMap=null!=(y=x.colorMap)?y:e=>e,this.backgroundColorMap=null!=(v=x.backgroundColorMap)?v:e=>e,this.getMacro=x.getMacro,void 0!==this.parent||this.registers}makeID(){if(!this.atomIdsSettings)return;if(this.atomIdsSettings.overrideID)return this.atomIdsSettings.overrideID;if("number"!=typeof this.atomIdsSettings.seed)return`${Date.now().toString(36).slice(-2)}${Math.floor(1e5*Math.random()).toString(36)}`;let e=this.atomIdsSettings.seed.toString(36);return this.atomIdsSettings.seed+=1,e}scale(e){return e*this.effectiveFontSize}get scalingFactor(){return this.parent?this.effectiveFontSize/this.parent.effectiveFontSize:1}get isDisplayStyle(){return 7===this.mathstyle.id||6===this.mathstyle.id}get isCramped(){return this.mathstyle.cramped}get isTight(){return this.mathstyle.isTight}get metrics(){return this.mathstyle.metrics}get effectiveFontSize(){return Math.max(oi[Math.max(1,this.size+this.mathstyle.sizeDelta)],this.minFontScale)}getRegister(e){return this.registers&&e in this.registers?this.registers[e]:this.parent?this.parent.getRegister(e):void 0}getRegisterAsNumber(e){let i=this.getRegister(e);return"number"==typeof i?i:"string"==typeof i?Number(i):void 0}getRegisterAsGlue(e){if(this.registers&&e in this.registers){let i=this.registers[e];return"object"==typeof i&&"glue"in i?i:"object"==typeof i&&"dimension"in i?{glue:{dimension:i.dimension}}:"number"==typeof i?{glue:{dimension:i}}:void 0}if(this.parent)return this.parent.getRegisterAsGlue(e)}getRegisterAsEm(e,i){return oN(this.getRegisterAsDimension(e),i)}getRegisterAsDimension(e){if(this.registers&&e in this.registers){let i=this.registers[e];return"object"==typeof i&&"glue"in i?i.glue:"object"==typeof i&&"dimension"in i?i:"number"==typeof i?{dimension:i}:void 0}if(this.parent)return this.parent.getRegisterAsDimension(e)}setRegister(e,i){void 0===i?delete this.registers[e]:this.registers[e]=i}evaluate(e){if(!e||!("register"in e))return e;let i=this;if("global"in e&&e.global)for(;i.parent;)i=i.parent;let r=1;"factor"in e&&1!==e.factor&&void 0!==e.factor&&(r=e.factor);let a=i.getRegister(e.register);if(void 0===a)return;if("string"==typeof a)return{string:Number(a).toString()+a};if("number"==typeof a)return{number:r*a};let o=i.evaluate(a);if(void 0!==o)return"string"in o?{string:Number(a).toString()+o.string}:"number"in o?{number:r*o.number}:"dimension"in o?g(f({},o),{dimension:r*o.dimension}):"glue"in o?g(f({},o),{glue:g(f({},o.glue),{dimension:r*o.glue.dimension}),shrink:o.shrink?g(f({},o.shrink),{dimension:r*o.shrink.dimension}):void 0,grow:o.grow?g(f({},o.grow),{dimension:r*o.grow.dimension}):void 0}):e}toDimension(e){let i=this.evaluate(e);if(void 0===i)return null;if("dimension"in i)return i;if("glue"in i)return i.glue;if("number"in i)return{dimension:i.number};if("string"in i){let e=parseFloat(i.string),r=i.string.match(/(mm|cm|ex|px|em|bp|dd|pc|in|mu)$/);return r?{dimension:e,unit:r[0]}:{dimension:e}}return null}toEm(e,i){if(null===e)return 0;let r=this.toDimension(e);return null===r?0:oI(r,i)/10}toNumber(e){if(null===e)return null;let i=this.evaluate(e);return void 0===i?null:"number"in i?i.number:"dimension"in i?i.dimension:"glue"in i?i.glue.dimension:"string"in i?Number(i.string):null}toColor(e){var i,r;if(null===e)return null;let a=this.evaluate(e);return void 0===a?null:"string"in a?null!=(r=null==(i=this.colorMap)?void 0:i.call(this,a.string))?r:a.string:null}toBackgroundColor(e){var i,r;if(null===e)return null;let a=this.evaluate(e);return void 0===a?null:"string"in a?null!=(r=null==(i=this.backgroundColorMap)?void 0:i.call(this,a.string))?r:a.string:null}},oU=["body","above","below","superscript","subscript"];function oJ(e){return"string"==typeof e&&oU.includes(e)}function oX(e){return void 0!==e&&Array.isArray(e)&&2===e.length}var oG=class e{constructor(e){var i,r,a,o,n,l,s;this.isRoot=!1,this.type=e.type,"string"==typeof e.value&&(this.value=e.value),this.command=null!=(r=null!=(i=e.command)?i:this.value)?r:"",this.mode=null!=(a=e.mode)?a:"math",e.isFunction&&(this.isFunction=!0),(e.isRoot||"root"===this.type)&&(this.isRoot=!0),e.limits&&(this.subsupPlacement=e.limits),this.style=f({},null!=(o=e.style)?o:{}),this.displayContainsHighlight=null!=(n=e.displayContainsHighlight)&&n,this.captureSelection=null!=(l=e.captureSelection)&&l,this.skipBoundary=null!=(s=e.skipBoundary)&&s,void 0!==e.verbatimLatex&&null!==e.verbatimLatex&&(this.verbatimLatex=e.verbatimLatex),e.args&&(this.args=e.args),e.body&&(this.body=e.body),this._changeCounter=0}static createBox(e,i,r){var a;if(!i)return null;let o=function(e){let i,r=[],a=[];for(let o of e){if("first"===o.type){a.push(o);continue}if(i||o.style){let e=o.style;i&&e.color===i.color&&e.backgroundColor===i.backgroundColor&&e.fontSize===i.fontSize?a.push(o):(a.length>0&&r.push(a),a=[o],i=e)}else a.push(o)}return a.length>0&&r.push(a),r}(i),n=[];for(let i of o){let r=i[0].style,a=function(e,i,r){var a,o,n,l,s;if(!i||0===i.length)return null;let c=new oW({parent:e},r.style),d=!(null!=(a=c.atomIdsSettings)&&a.groupNumbers),u=[];if(1===i.length){let e=i[0],r=e.render(c);r&&(d&&e.isSelected&&r.selected(!0),u=[r])}else{let e="",r=!0;for(let a of i){null!=(o=c.atomIdsSettings)&&o.groupNumbers&&e&&(r&&a.isDigit()||!r&&oZ(a))&&(c.atomIdsSettings.overrideID=e);let i=a.render(c);c.atomIdsSettings&&(c.atomIdsSettings.overrideID=void 0),i&&(null!=(n=c.atomIdsSettings)&&n.groupNumbers&&((a.isDigit()||oZ(a))&&(!e||r!==a.isDigit())&&(r=a.isDigit(),e=null!=(l=a.id)?l:""),!e||(a.isDigit()||oZ(a))&&a.hasEmptyBranch("superscript")&&a.hasEmptyBranch("subscript")||(e="")),d&&a.isSelected&&i.selected(!0),u.push(i))}}if(0===u.length)return null;let h=new oE(u,g(f({isTight:c.isTight},r),{type:null!=(s=r.type)?s:"lift"}));return h.isSelected=u.every(e=>e.isSelected),h.wrap(c)}(e,i,{style:{color:r.color,backgroundColor:r.backgroundColor,fontSize:r.fontSize}});a&&n.push(a)}if(0===n.length)return null;let l=(null!=(a=null==r?void 0:r.classes)?a:"").trim();return 1!==n.length||l||null!=r&&r.type?new oE(n,{classes:l,type:null==r?void 0:r.type}).wrap(e):n[0].wrap(e)}static serialize(e,i){return ov.serialize(e,i)}static commonAncestor(e,i){if(e===i||e.parent===i.parent)return e.parent;let r=new WeakSet,{parent:a}=e;for(;a;)r.add(a),a=a.parent;for(a=i.parent;a;){if(r.has(a))return a;a=a.parent}}static fromJson(i){return new e("string"==typeof i?{type:"mord",value:i,mode:"math"}:i)}toJson(){if(this._json)return this._json;let e={};if(this.type&&(e.type=this.type),"math"!==this.mode&&(e.mode=this.mode),this.command&&this.command!==this.value&&(e.command=this.command),void 0!==this.value&&(e.value=this.value),this.style&&Object.keys(this.style).length>0&&(e.style=f({},this.style)),void 0!==this.verbatimLatex&&(e.verbatimLatex=this.verbatimLatex),this.subsupPlacement&&(e.subsupPlacement=this.subsupPlacement),this.explicitSubsupPlacement&&(e.explicitSubsupPlacement=!0),this.isFunction&&(e.isFunction=!0),this.displayContainsHighlight&&(e.displayContainsHighlight=!0),this.skipBoundary&&(e.skipBoundary=!0),this.captureSelection&&(e.captureSelection=!0),this.args&&(e.args=this.args.map(e=>null===e?"<null>":Array.isArray(e)&&e[0]instanceof oG?{atoms:e.map(e=>e.toJson())}:"object"==typeof e&&"group"in e?{group:e.group.map(e=>e.toJson())}:e)),this._branches)for(let i of Object.keys(this._branches))this._branches[i]&&(e[i]=this._branches[i].filter(e=>"first"!==e.type).map(e=>e.toJson()));return"mord"===e.type&&2===Object.keys(e).length&&"value"in e?e.value:(this._json=e,e)}get changeCounter(){return this.parent?this.parent.changeCounter:this._changeCounter}set isDirty(e){e&&(this._json=void 0,this.parent||this._changeCounter++,"verbatimLatex"in this&&(this.verbatimLatex=void 0),this._children=void 0,this.parent&&(this.parent.isDirty=!0))}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let i=eM(this.command,this.mode);return null!=i&&i.serialize?i.serialize(this,e):this.body&&this.command?of([og(this.command,this.bodyToLatex(e)),this.supsubToLatex(e)]):this.body?of([this.bodyToLatex(e),this.supsubToLatex(e)]):this.value&&""!==this.value?this.command:""}bodyToLatex(e){var i;let r=null!=(i=e.defaultMode)?i:"math"===this.mode?"math":"text";return ov.serialize(this.body,g(f({},e),{defaultMode:r}))}aboveToLatex(e){return ov.serialize(this.above,e)}belowToLatex(e){return ov.serialize(this.below,e)}supsubToLatex(e){let i="";if(e=g(f({},e),{defaultMode:"math"}),void 0!==this.branch("subscript")){let r=ov.serialize(this.subscript,e);0===r.length?i+="_{}":1===r.length&&o$.compactSerialization&&/^[0-9]$/.test(r)?i+=`_${r}`:i+=`_{${r}}`}if(void 0!==this.branch("superscript")){let r=ov.serialize(this.superscript,e);0===r.length?i+="^{}":1===r.length?"′"===r?i+="^\\prime ":"″"===r?i+="^\\doubleprime ":o$.compactSerialization&&/^[0-9]$/.test(r)?i+=`^${r}`:i+=`^{${r}}`:i+=`^{${r}}`}return i}get treeDepth(){let e=1,i=this.parent;for(;i;)i=i.parent,e+=1;return e}get inCaptureSelection(){let e=this;for(;e;){if(e.captureSelection)return!0;e=e.parent}return!1}get parentPrompt(){let e=this.parent;for(;e;){if("prompt"===e.type&&!e.captureSelection)return e;e=e.parent}return null}branch(e){if(oJ(e)&&this._branches)return this._branches[e]}get branches(){if(!this._branches)return[];let e=[];for(let i of oU)this._branches[i]&&e.push(i);return e}createBranch(e){return oJ(e),oJ(e)?(this._branches?this._branches[e]||(this._branches[e]=[this.makeFirstAtom(e)]):this._branches={[e]:[this.makeFirstAtom(e)]},this.isDirty=!0,this._branches[e]):[]}get row(){return oX(this.parentBranch)?this.parentBranch[0]:-1}get col(){return oX(this.parentBranch)?this.parentBranch[1]:-1}get body(){var e;return null==(e=this._branches)?void 0:e.body}set body(e){this.setChildren(e,"body")}get superscript(){var e;return null==(e=this._branches)?void 0:e.superscript}set superscript(e){this.setChildren(e,"superscript")}get subscript(){var e;return null==(e=this._branches)?void 0:e.subscript}set subscript(e){this.setChildren(e,"subscript")}get above(){var e;return null==(e=this._branches)?void 0:e.above}set above(e){this.setChildren(e,"above")}get below(){var e;return null==(e=this._branches)?void 0:e.below}set below(e){this.setChildren(e,"below")}applyStyle(e,i){for(let r of(this.isDirty=!0,null!=i&&i.unstyledOnly?(e.color&&!this.style.color&&(this.style.color=e.color),e.backgroundColor&&!this.style.backgroundColor&&(this.style.backgroundColor=e.backgroundColor),e.fontFamily&&!this.style.fontFamily&&(this.style.fontFamily=e.fontFamily),e.fontShape&&!this.style.fontShape&&(this.style.fontShape=e.fontShape),e.fontSeries&&!this.style.fontSeries&&(this.style.fontSeries=e.fontSeries),e.fontSize&&!this.style.fontSize&&(this.style.fontSize=e.fontSize),e.variant&&!this.style.variant&&(this.style.variant=e.variant),e.variantStyle&&!this.style.variantStyle&&(this.style.variantStyle=e.variantStyle)):this.style=f(f({},this.style),e),"none"===this.style.fontFamily&&delete this.style.fontFamily,"auto"===this.style.fontShape&&delete this.style.fontShape,"auto"===this.style.fontSeries&&delete this.style.fontSeries,"none"===this.style.color&&(delete this.style.color,delete this.style.verbatimColor),"none"===this.style.backgroundColor&&(delete this.style.backgroundColor,delete this.style.verbatimBackgroundColor),"auto"===this.style.fontSize&&delete this.style.fontSize,this.children))r.applyStyle(e,i)}getInitialBaseElement(){var e,i,r;return this.hasEmptyBranch("body")?this:(null==(e=this.body)||e[0].type,null!=(r=null==(i=this.body[1])?void 0:i.getInitialBaseElement())?r:this)}getFinalBaseElement(){return this.hasEmptyBranch("body")?this:this.body[this.body.length-1].getFinalBaseElement()}isCharacterBox(){return"leftright"!==this.type&&"genfrac"!==this.type&&"subsup"!==this.type&&"delim"!==this.type&&"array"!==this.type&&"surd"!==this.type&&"mord"===this.getFinalBaseElement().type}hasEmptyBranch(e){let i=this.branch(e);return!i||(i.length,i[0].type,1===i.length)}setChildren(e,i){var r;if(!e||(oJ(i),!oJ(i)))return;let a=(null==(r=e[0])?void 0:r.type)==="first"?[...e]:[this.makeFirstAtom(i),...e];for(let r of(this._branches?this._branches[i]=a:this._branches={[i]:a},e))r.parent=this,r.parentBranch=i;this.isDirty=!0}makeFirstAtom(i){let r=new e({type:"first",mode:this.mode});return r.parent=this,r.parentBranch=i,r}addChild(e,i){e.type,this.createBranch(i).push(e),this.isDirty=!0,e.parent=this,e.parentBranch=i}addChildBefore(e,i){i.parentBranch;let r=this.createBranch(i.parentBranch);r.splice(r.indexOf(i),0,e),this.isDirty=!0,e.parent=this,e.parentBranch=i.parentBranch}addChildAfter(e,i){i.parentBranch;let r=this.createBranch(i.parentBranch);r.splice(r.indexOf(i)+1,0,e),this.isDirty=!0,e.parent=this,e.parentBranch=i.parentBranch}addChildren(e,i){let r=this.createBranch(i);for(let a of e)a.parent=this,a.parentBranch=i,r.push(a);this.isDirty=!0}addChildrenAfter(e,i){0===e.length||e[0].type,i.parentBranch;let r=this.createBranch(i.parentBranch);for(let a of(r.splice(r.indexOf(i)+1,0,...e),this.isDirty=!0,e))a.parent=this,a.parentBranch=i.parentBranch;return e[e.length-1]}removeBranch(e){let i=this.branch(e);if(oJ(e)&&(this._branches[e]=void 0),!i)return[];for(let e of i)e.parent=void 0,e.parentBranch=void 0;i[0].type;let[r,...a]=i;return this.isDirty=!0,a}removeChild(e){if(e.parent,"first"===e.type)return;let i=this.branch(e.parentBranch),r=i.indexOf(e);i.splice(r,1),this.isDirty=!0,e.parent=void 0,e.parentBranch=void 0}get siblings(){return this.parent?this.parent.branch(this.parentBranch):[]}get firstSibling(){return this.siblings[0]}get lastSibling(){let{siblings:e}=this;return e[e.length-1]}get isFirstSibling(){return this===this.firstSibling}get isLastSibling(){return this===this.lastSibling}get hasNoSiblings(){return 1===this.siblings.length}get leftSibling(){this.parent;let e=this.parent.branch(this.parentBranch);return e[e.indexOf(this)-1]}get rightSibling(){this.parent;let e=this.parent.branch(this.parentBranch);return e[e.indexOf(this)+1]}get hasChildren(){return!!(this._branches&&this.children.length>0)}get firstChild(){return this.hasChildren,this.children[0]}get lastChild(){this.hasChildren;let{children:e}=this;return e[e.length-1]}get children(){if(this._children)return this._children;if(!this._branches)return[];let e=[];for(let i of oU)if(this._branches[i])for(let r of this._branches[i])e.push(...r.children),e.push(r);return this._children=e,e}render(e){if("first"===this.type&&!e.atomIdsSettings)return null;let i=eM(this.command,this.mode);if(null!=i&&i.render)return i.render(this,e);let r=new oW({parent:e},this.style),a=this.createBox(r,{classes:this.parent?"":"ML__base"});return a?(!this.subsupPlacement&&(this.superscript||this.subscript)&&(a=this.attachSupsub(r,{base:a})),a.wrap(r)):null}attachSupsub(i,r){var a;let o,n=r.base,l=this.superscript,s=this.subscript;if(!l&&!s)return n;let c=null,d=null,u=null!=(a=r.isCharacterBox)?a:this.isCharacterBox(),h=0;if(l){let r=new oW({parent:i,mathstyle:"superscript"});c=e.createBox(r,l),u||(h=n.height-i.metrics.supDrop*r.scalingFactor)}let p=0;if(s){let r=new oW({parent:i,mathstyle:"subscript"});d=e.createBox(r,s),u||(p=n.depth+i.metrics.subDrop*r.scalingFactor)}o=i.isDisplayStyle?i.metrics.sup1:i.isCramped?i.metrics.sup3:i.metrics.sup2;let m=.05/i.scalingFactor,f=null;if(d&&c){h=Math.max(h,o,c.depth+.25*i.metrics.xHeight),p=Math.max(p,i.metrics.sub2);let e=i.metrics.defaultRuleThickness;if(h-c.depth-(d.height-p)<4*e){p=4*e-(h-c.depth)+d.height;let r=.8*i.metrics.xHeight-(h-c.depth);r>0&&(h+=r,p-=r)}f=new oB({individualShift:[{box:d,shift:p,marginLeft:"extensible-symbol"===this.type&&n.italic?-n.italic:0},{box:c,shift:-h}]})}else d&&!c?f=new oB({shift:p=Math.max(p,i.metrics.sub1,d.height-.3448),children:[{box:d,marginRight:m,marginLeft:this.isCharacterBox()?-n.italic:0}]}):!d&&c&&(f=new oB({shift:-(h=Math.max(h,o,c.depth+.10775)),children:[{box:c,marginRight:m}]}));return new oE([n,new oE(f,{caret:this.caret,isSelected:this.isSelected,classes:"ML__msubsup"})],{type:r.type})}attachLimits(i,r){var a,o,n,l,s,c;let d,u,h,p,m,b,y=this.superscript?e.createBox(new oW({parent:i,mathstyle:"superscript"},this.style),this.superscript):null,v=this.subscript?e.createBox(new oW({parent:i,mathstyle:"subscript"},this.style),this.subscript):null;return y||v?(a=g(f({},r),{above:y,below:v}),d=i.metrics,u=new oE(a.base),h=null!=(o=a.baseShift)?o:0,p=null!=(n=a.slant)?n:0,m=0,b=0,a.above&&(m=null!=(l=a.aboveShift)?l:Math.max(d.bigOpSpacing1,d.bigOpSpacing3-a.above.depth)),a.below&&(b=null!=(s=a.belowShift)?s:Math.max(d.bigOpSpacing2,d.bigOpSpacing4-a.below.height)),new oE(a.below&&a.above?new oB({bottom:d.bigOpSpacing5+a.below.height+a.below.depth+b+u.depth+h,children:[d.bigOpSpacing5,{box:a.below,marginLeft:-p,classes:["ML__center"]},b,{box:u,classes:["ML__center"]},m,{box:a.above,marginLeft:p,classes:["ML__center"]},d.bigOpSpacing5]}).wrap(i):a.below&&!a.above?new oB({top:u.height-h,children:[d.bigOpSpacing5,{box:a.below,marginLeft:-p,classes:["ML__center"]},b,{box:u,classes:["ML__center"]}]}).wrap(i):!a.below&&a.above?new oB({bottom:u.depth+h,children:[{box:u,classes:["ML__center"]},m,{box:a.above,marginLeft:p,classes:["ML__center"]},d.bigOpSpacing5]}).wrap(i):new oB({bottom:u.depth+h,children:[{box:u},d.bigOpSpacing5]}).wrap(i),{type:null!=(c=a.type)?c:"op"})):r.base.wrap(i)}bind(e,i){if(!i||e.isPhantom||""===this.value)return i;let r=this.parent;for(;r&&!r.captureSelection;)r=r.parent;return null!=r&&r.captureSelection||(this.id||(this.id=e.makeID()),i.atomID=this.id),i}createBox(i,r){var a,o,n,l;let s=null!=(a=this.value)?a:this.body,c=null!=(o=null==r?void 0:r.boxType)?o:oS(this.type),d=null!=(n=null==r?void 0:r.classes)?n:"";"text"===this.mode&&(d+=" ML__text");let u="string"==typeof s||void 0===s?new oE(null!=s?s:null,{type:c,isSelected:this.isSelected,mode:this.mode,maxFontSize:i.scalingFactor,style:g(f({variant:"normal"},this.style),{fontSize:Math.max(1,i.size+i.mathstyle.sizeDelta)}),letterShapeStyle:i.letterShapeStyle,classes:d}):null!=(l=e.createBox(i,s,{type:c,classes:d}))?l:new oE(null);return i.isTight&&(u.isTight=!0),("math"!==this.mode||"main"===this.style.variant)&&(u.italic=0),u.right=u.italic,this.bind(i,u),!this.caret||this.superscript||this.subscript||(u.caret=this.caret),u}isDigit(){var e;return"mord"===this.type&&this.value?/^[\d,\.]$/.test(this.value):"group"===this.type&&(null==(e=this.body)?void 0:e.length)===2&&"first"===this.body[0].type&&","===this.body[1].value}asDigit(){var e;return"mord"===this.type&&this.value&&/^[\d,\.]$/.test(this.value)?this.value:"group"===this.type&&(null==(e=this.body)?void 0:e.length)===2&&"first"===this.body[0].type&&","===this.body[1].value?".":""}};function oZ(e){return"text"===e.mode}var oY=class e extends oG{constructor(e,i,r){super({type:"text",command:e,mode:"text",displayContainsHighlight:!0}),this.value=i,this.verbatimLatex=i,this.applyStyle(r)}static fromJson(i){return new e(i.command,i.value,i.style)}render(e){let i=this.createBox(e);return this.caret&&(i.caret=this.caret),i}_serialize(e){var i;return null!=(i=this.verbatimLatex)?i:eL("text",this.value.codePointAt(0))}};function oQ(e){let i=1/0,r=-1/0;for(let a of e.ranges)i=Math.min(i,a[0],a[1]),r=Math.max(r,a[0],a[1]);return[i,r]}function o0(e){return"number"==typeof e&&!Number.isNaN(e)}function o1(e){return Array.isArray(e)&&2===e.length}function o4(e){return null!=e&&"object"==typeof e&&"ranges"in e&&Array.isArray(e.ranges)}function o2(e,i,r){return r?function(e,i){if(!i)return"";if("string"==typeof i)return i;if(!e||void 0===i.after)return i.value;let r=!1,a=!1,o=!1,n=!1,l=!1,s=!1,c=!1,d=!1,u=!1,h=!1,p=!1,m=!1,f=!1,g=!1,b=!1,y=e[0],v=0;for(;null!=y&&y.type&&/^(subsup|placeholder)$/.test(y.type);)v+=1,y=e[v];return r=!y||"first"===y.type,y&&(a=!(g="text"===y.mode)&&"mord"===y.type&&ei.test(y.value),o=!g&&"mord"===y.type&&/\d+$/.test(y.value),n=!g&&y.isFunction,l="genfrac"===y.type,s="surd"===y.type,c="mbin"===y.type,d="mrel"===y.type,u="mop"===y.type||"operator"===y.type||"extensible-symbol"===y.type,h="mpunct"===y.type||"minner"===y.type,p="array"===y.type,m="mopen"===y.type,f="mclose"===y.type||"leftright"===y.type,b="space"===y.type),i.after.includes("nothing")&&r||i.after.includes("letter")&&a||i.after.includes("digit")&&o||i.after.includes("function")&&n||i.after.includes("frac")&&l||i.after.includes("surd")&&s||i.after.includes("binop")&&c||i.after.includes("relop")&&d||i.after.includes("operator")&&u||i.after.includes("punct")&&h||i.after.includes("array")&&p||i.after.includes("openfence")&&m||i.after.includes("closefence")&&f||i.after.includes("text")&&g||i.after.includes("space")&&b?i.value:""}(e,r[i]):""}var o3={"&":"\\&","%":"\\%",$:"\\$","''":"^{\\doubleprime}","'''":"^{\\prime\\prime\\prime}","''''":"^{\\prime\\prime\\prime\\prime}",alpha:"\\alpha",delta:"\\delta",Delta:"\\Delta",pi:"\\pi",Pi:"\\Pi",theta:"\\theta",Theta:"\\Theta",ii:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\imaginaryI"},jj:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\imaginaryJ"},ee:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\exponentialE"},nabla:"\\nabla",grad:"\\nabla",del:"\\partial",deg:{after:"digit+space",value:"\\degree"},infty:"\\infty","∞":"\\infty",oo:{after:"nothing+digit+frac+surd+binop+relop+punct+array+openfence+closefence+space",value:"\\infty"},"∑":"\\sum",sum:"\\sum_{#?}^{#?}",int:"\\int_{#?}^{#?}",prod:"\\prod_{#?}^{#?}",sqrt:"\\sqrt{#?}","∆":"\\differentialD","∂":"\\differentialD",sin:"\\sin",cos:"\\cos",tan:"\\tan",blank:"\\blank{#?}",arccos:"\\arccos",arcsin:"\\arcsin",arctan:"\\arctan",arctg:"\\operatorname{arctg}",arcsec:"\\operatorname{arcsec}",arccsc:"\\operatorname{arccsc}",arsinh:"\\operatorname{arsinh}",arccosh:"\\operatorname{arccosh}",arcosh:"\\operatorname{arcosh}",artanh:"\\operatorname{artanh}",arctanh:"\\operatorname{arctanh}",arcsech:"\\operatorname{arcsech}",arccsch:"\\operatorname{arccsch}",ch:"\\operatorname{ch}",cosec:"\\operatorname{cosec}",cosh:"\\cosh",cot:"\\cot",cotg:"\\operatorname{cotg}",coth:"\\coth",csc:"\\csc",ctg:"\\operatorname{ctg}",cth:"\\operatorname{cth}",sec:"\\sec",sech:"\\operatorname{sech}",sinh:"\\sinh",sh:"\\operatorname{sh}",tanh:"\\tanh",tg:"\\operatorname{tg}",th:"\\operatorname{th}",arg:"\\arg",lg:"\\lg",lb:"\\operatorname{lb}",log:"\\log_{#?}",ln:"\\ln",exp:"\\exp",lim:"\\lim_{#?\\to#?}",dx:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\differentialD x"},dy:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\differentialD y"},dt:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\differentialD t"},AA:"\\forall",EE:"\\exists","!EE":"\\nexists","&&":"\\land",xin:{after:"nothing+text+relop+punct+openfence+space",value:"x \\in"},sint:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\sin t"},in:{after:"nothing+letter+closefence",value:"\\in"},"!in":"\\notin",NN:"\\mathbb{N}",ZZ:"\\mathbb{Z}",QQ:"\\mathbb{Q}",RR:"\\mathbb{R}",CC:"\\mathbb{C}",xx:"\\times","+-":"\\pm","≠":"\\ne","!=":"\\ne","≥":"\\ge",">=":"\\ge","≤":"\\le","<=":"\\le","<<":"\\ll",">>":"\\gg","~~":"\\approx","≈":"\\approx","?=":"\\questeq","÷":"\\div","¬":"\\neg",":=":"\\coloneq","::":"\\Colon","(:":"\\langle",":)":"\\rangle",beta:"\\beta",chi:"\\chi",epsilon:"\\epsilon",varepsilon:"\\varepsilon",eta:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\eta"},gamma:"\\gamma",Gamma:"\\Gamma",iota:"\\iota",kappa:"\\kappa",lambda:"\\lambda",Lambda:"\\Lambda",mu:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\mu"},nu:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\nu"},µ:"\\mu",phi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\phi"},Phi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\Phi"},varphi:"\\varphi",psi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\psi"},Psi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\Psi"},rho:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\rho"},sigma:"\\sigma",Sigma:"\\Sigma",tau:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\tau"},vartheta:"\\vartheta",upsilon:"\\upsilon",xi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space",value:"\\xi"},Xi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\Xi"},zeta:"\\zeta",omega:"\\omega",Omega:"\\Omega",Ω:"\\omega",forall:"\\forall",exists:"\\exists","!exists":"\\nexists",":.":"\\therefore",liminf:"\\liminf_{#?}",limsup:"\\limsup_{#?}",argmin:"\\operatorname*{arg~min}_{#?}",argmax:"\\operatorname*{arg~max}_{#?}",det:"\\det",mod:"\\bmod{#?}","(mod":"\\pmod{#?}",max:"\\max",min:"\\min",erf:"\\operatorname{erf}",erfc:"\\operatorname{erfc}",bessel:"\\operatorname{bessel}",mean:"\\operatorname{mean}",median:"\\operatorname{median}",fft:"\\operatorname{fft}",lcm:"\\operatorname{lcm}",gcd:"\\gcd",randomReal:"\\operatorname{randomReal}",randomInteger:"\\operatorname{randomInteger}",Re:"\\operatorname{Re}",Im:"\\operatorname{Im}",mm:{after:"nothing+digit+operator",value:"\\operatorname{mm}"},cm:{after:"nothing+digit+operator",value:"\\operatorname{cm}"},km:{after:"nothing+digit+operator",value:"\\operatorname{km}"},kg:{after:"nothing+digit+operator",value:"\\operatorname{kg}"},ft:{after:"nothing+digit+operator",value:"\\operatorname{ft}"},inch:{after:"nothing+digit+operator",value:"\\operatorname{inch}"},mi:{after:"nothing+digit+operator",value:"\\operatorname{mi}"},"...":"\\ldots","+...":"+\\cdots","-...":"-\\cdots","->...":"\\to\\cdots","--\x3e...":"\\longrightarrow\\cdots","->":"\\to","|->":"\\mapsto","--\x3e":"\\longrightarrow","<--":"\\longleftarrow","=>":"\\Rightarrow","==>":"\\Longrightarrow","<=>":"\\iff","<->":"\\leftrightarrow","(.)":"\\odot","(+)":"\\oplus","(/)":"\\oslash","(*)":"\\otimes","(-)":"\\ominus","||":"\\Vert","*":"\\cdot","**":"\\star","***":"\\ast","//":"\\slash","\\\\":"\\backslash",setminus:"\\backslash","|><":"\\ltimes","><|":"\\rtimes","|><|":"\\bowtie","-:":"\\div",divide:"\\div","@":"\\circ","^^":"\\wedge","^^^":"\\bigwedge",vv:"\\vee",vvv:"\\bigvee",nn:"\\cap",nnn:"\\bigcap",uu:"\\cup",uuu:"\\bigcup","-=":"\\equiv","~=":"\\cong",lt:"<","lt=":"\\leq",gt:">","gt=":"\\geq","-<":"\\prec","-lt":"\\prec","-<=":"\\preceq",">-=":"\\succeq",prop:"\\propto",diamond:"\\diamond",square:"\\square",iff:"\\iff",sub:"\\subset",sup:"\\supset",sube:"\\subseteq",supe:"\\supseteq",uarr:"\\uparrow",darr:"\\downarrow",rarr:"\\rightarrow",rArr:"\\Rightarrow",larr:"\\leftarrow",lArr:"\\Leftarrow",harr:"\\leftrightarrow",hArr:"\\Leftrightarrow",aleph:"\\aleph",and:"\\land",or:"\\lor",not:"\\neg","_|_":"\\bot",TT:"\\top","|--":"\\vdash","|==":"\\models","|__":"\\lfloor","__|":"\\rfloor","|~":"\\lceil","~|":"\\rceil",">->":"\\rightarrowtail","->>":"\\twoheadrightarrow",">->>":"\\twoheadrightarrowtail",times:"\\times",of:"\\circ",infinity:"\\infty",defint:"\\int_{#?}^{#?}",approaches:"\\to",ceil:"\\left\\lceil#?\\right\\rceil",floor:"\\left\\lfloor#?\\right\\rfloor",union:"\\cup",asterisk:"\\ast",frac:"\\frac{#?}{#?}",cbrt:"\\sqrt[3]{#?}",nthroot:"\\sqrt[#?]{#?}"};function o6(e,i){var r,a;let o,n=null!=(r=null==i?void 0:i.format)?r:"auto";return"auto"===n&&([n,e]=(a=(a=e).trim()).length<=1?["latex",a]:([o,a]=nt(a),o?["latex",a]:a.startsWith("`")&&a.endsWith("`")?["ascii-math",a=a.substring(1,a.length-1)]:a.includes("\\")?["latex",a]:/\$.+\$/.test(a)?["latex",`\\text{${a}}`]:[void 0,a])),"ascii-math"===n?["ascii-math",o8(e=(e=(e=(e=(e=(e=e.replace(/\u2061/gu,"")).replace(/\u3016/gu,"{")).replace(/\u3017/gu,"}")).replace(/([^\\])sinx/g,"$1\\sin x")).replace(/([^\\])cosx/g,"$1\\cos x ")).replace(/\u2013/g,"-"),{inlineShortcuts:null==i?void 0:i.inlineShortcuts})]:["latex",e]}function o8(e,i){var r;if(!(e=e.trim()))return"";let a=null!=(r=i.inlineShortcuts)?r:o3;if(e.startsWith("^")||e.startsWith("_")){let{match:r,rest:o}=o7(e.slice(1),{inlineShortcuts:a,noWrap:!0});return`${e[0]}{${r}}${o8(o,i)}`}let o=e.match(/^(sqrt|\u221A)(.*)/);if(o){let{match:e,rest:r}=o7(o[2],{inlineShortcuts:a,noWrap:!0});return`\\sqrt{${null!=e?e:"\\placeholder{}"}}${o8(r,i)}`}if(o=e.match(/^(\\cbrt|\u221B)(.*)/)){let{match:e,rest:r}=o7(o[2],{inlineShortcuts:a,noWrap:!0});return`\\sqrt[3]{${null!=e?e:"\\placeholder{}"}}${o8(r,i)}`}if(o=e.match(/^abs(.*)/)){let{match:e,rest:r}=o7(o[1],{inlineShortcuts:a,noWrap:!0});return`\\left|${null!=e?e:"\\placeholder{}"}\\right|${o8(r,i)}`}if(o=e.match(/^["”“](.*?)["”“](.*)/))return`\\text{${o[1]}}${o8(o[2],i)}`;if(o=e.match(/^([^a-zA-Z0-9\(\{\[\_\^\\\s"]+)(.*)/))return`${o9(o[1],a)}${o8(o[2],i)}`;if(/^([fgh])[^a-zA-Z]/.test(e)){let{rest:r,match:o}=o7(e.slice(1),{inlineShortcuts:a,noWrap:!0});return("("===e[1]?`${e[0]}\\left(${o}\\right)`:e[0]+o)+o8(r,i)}if(o=e.match(/^([a-zA-Z]+)(.*)/))return o9(o[1],a)+o8(o[2],i);let{match:n,rest:l}=o7(e,{inlineShortcuts:a,noWrap:!0});if(!n||"/"!==l[0])return e.startsWith("(")?"\\left("+n+"\\right)"+o8(l,i):n+o8(l,i);{let e=o7(l.slice(1),{inlineShortcuts:a,noWrap:!0});if(e.match)return`\\frac{${n}}{${e.match}}${o8(e.rest,i)}`}return(o=e.match(/^(\s+)(.*)$/))?" "+o8(o[2],i):e}var o5={"[":"\\lbrack","]":"\\rbrack","{":"\\lbrace","}":"\\rbrace"};function o7(e,i){var r,a;let o="",n=e=e.trim(),l=e.charAt(0),s={"(":")","{":"}","[":"]"}[l];if(s){let c=1,d=1;for(;d<e.length&&c>0;)e[d]===l&&c++,e[d]===s&&c--,d++;if(0===c){let c=o8(e.substring(1,d-1),i);o=i.noWrap&&"("===l?c:`\\left${null!=(r=o5[l])?r:l}${c}\\right${null!=(a=o5[s])?a:s}`,n=e.slice(Math.max(0,d))}else o=e.substring(1,d),n=""}else{let r=e.match(/^([a-zA-Z]+)/);if(r){let r=o2(null,e,i.inlineShortcuts);if(r)return{match:r=(r=r.replace("_{#?}","")).replace("^{#?}",""),rest:e.slice(r.length)}}if(r=e.match(/^([a-zA-Z])/))return{match:r[1],rest:e.slice(1)};if(r=e.match(/^(-)?\d+(\.\d*)?/))return{match:r[0],rest:e.slice(r[0].length)};/^\\(left|right)/.test(e)||(r=e.match(/^(\\[a-zA-Z]+)/))&&(n=e.slice(r[1].length),o=r[1])}return{match:o,rest:n}}function o9(e,i){let r=o2(null,e,i);return r?(r=r.replace("_{#?}","")).replace("^{#?}","")+" ":e}var ne=[["\\[","\\]"],["\\(","\\)"],["$$","$$"],["$","$"],["\\begin{math}","\\end{math}"],["\\begin{displaymath}","\\end{displaymath}"],["\\begin{equation}","\\end{equation}"],["\\begin{equation*}","\\end{equation*}"]];function nt(e){let i=e.trim();for(let e of ne)if(i.startsWith(e[0])&&i.endsWith(e[1]))return[!0,i.substring(e[0].length,i.length-e[1].length)];return[!1,e]}var ni=(e,i,r)=>(ne.some(e=>i.startsWith(e[0])&&i.endsWith(e[1]))||(i=`$$ ${i} $$`),i),nr=class e{constructor(i){e._modes[i]=this}static onPaste(i,r,a){var o;if(!r.contentEditable&&"none"===r.userSelect)return r.model.announce("plonk"),!1;if("string"==typeof a){let e=new DataTransfer;e.setData("text/plain",a),a=e}let n=new ClipboardEvent("paste",{clipboardData:a,cancelable:!0});return!!(null!=(o=r.host)&&o.dispatchEvent(n))&&e._modes[i].onPaste(r,a)}static copyToClipboard(e,i){if(!e.contentEditable&&"none"===e.userSelect)return void e.model.announce("plonk");let r=e.model,a=r.selectionIsCollapsed?[0,r.lastOffset]:oQ(r.selection),o=r.getValue(a,i);navigator.clipboard.writeText(o).then(()=>{},()=>e.model.announce("plonk"))}static onCopy(e,i){var r;if(!i.clipboardData)return;if(!e.contentEditable&&"none"===e.userSelect)return void e.model.announce("plonk");let a=e.model,o=a.selectionIsCollapsed?[0,a.lastOffset]:oQ(a.selection),n=a.getAtoms(o);if(n.every(e=>"text"===e.mode||!e.mode))i.clipboardData.setData("text/plain",n.filter(e=>e instanceof oY).map(e=>e.value).join(""));else if(n.every(e=>"latex"===e.mode))i.clipboardData.setData("text/plain",a.getAtoms(o,{includeChildren:!0}).map(e=>{var i;return null!=(i=e.value)?i:""}).join(""));else{let l;l=1===n.length&&void 0!==n[0].verbatimLatex?n[0].verbatimLatex:a.getValue(o,"latex-expanded"),i.clipboardData.setData("application/x-latex",l);try{i.clipboardData.setData("text/plain",e.options.onExport(e,l,o))}catch(e){}if(1===n.length){let e=n[0];("root"===e.type||"group"===e.type)&&(n=e.body.filter(e=>"first"!==e.type))}try{i.clipboardData.setData("application/json+mathlive",JSON.stringify(n.map(e=>e.toJson())))}catch(e){}if(null!=(r=window[Symbol.for("io.cortexjs.compute-engine")])&&r.ComputeEngine){let e=globalThis.MathfieldElement.computeEngine;if(e)try{let r=e.jsonSerializationOptions;e.jsonSerializationOptions={metadata:["latex"]};let n=e.parse(a.getValue(o,"latex-unstyled"));e.jsonSerializationOptions=r;let l=JSON.stringify(n.json);l&&i.clipboardData.setData("application/json",l)}catch(e){}}}i.preventDefault()}static insert(i,r,a={}){var o;let n="auto"===a.mode?i.mode:null!=(o=a.mode)?o:i.mode;return e._modes[n].insert(i,r,a)}onPaste(e,i){return!1}insert(e,i,r){return!1}};nr._modes={};var na=nr,no=[{key:"left",command:"moveToPreviousChar"},{key:"right",command:"moveToNextChar"},{key:"up",command:"moveUp"},{key:"down",command:"moveDown"},{key:"shift+[ArrowLeft]",command:"extendSelectionBackward"},{key:"shift+[ArrowRight]",command:"extendSelectionForward"},{key:"shift+[ArrowUp]",command:"extendSelectionUpward"},{key:"shift+[ArrowDown]",command:"extendSelectionDownward"},{key:"[Backspace]",command:"deleteBackward"},{key:"[Delete]",command:"deleteForward"},{key:"shift+[Backspace]",command:"deleteForward"},{key:"alt+[Backspace]",command:"deletePreviousWord"},{key:"alt+[Delete]",command:"deleteNextWord"},{key:"ctrl+[Backspace]",command:"deleteToGroupStart"},{key:"ctrl+[Delete]",command:"deleteToGroupEnd"},{key:"ctrl+shift+[Backspace]",command:"deleteToGroupEnd"},{key:"alt+[ArrowLeft]",command:"moveToPreviousWord"},{key:"alt+[ArrowRight]",command:"moveToNextWord"},{key:"shift+alt+[ArrowLeft]",command:"extendToPreviousWord"},{key:"shift+alt+[ArrowRight]",command:"extendToNextWord"},{key:"ctrl+[ArrowLeft]",command:"moveToGroupStart"},{key:"ctrl+[ArrowRight]",command:"moveToGroupEnd"},{key:"shift+ctrl+[ArrowLeft]",command:"extendToGroupStart"},{key:"shift+ctrl+[ArrowRight]",command:"extendToGroupEnd"},{key:"[Home]",command:"moveToMathfieldStart"},{key:"cmd+[ArrowLeft]",command:"moveToMathfieldStart"},{key:"shift+[Home]",command:"extendToMathFieldStart"},{key:"shift+cmd+[ArrowLeft]",command:"extendToMathFieldStart"},{key:"[End]",command:"moveToMathfieldEnd"},{key:"cmd+[ArrowRight]",command:"moveToMathfieldEnd"},{key:"shift+[End]",command:"extendToMathFieldEnd"},{key:"shift+cmd+[ArrowRight]",command:"extendToMathFieldEnd"},{key:"[Pageup]",command:"moveToGroupStart"},{key:"[Pagedown]",command:"moveToGroupEnd"},{key:"[Tab]",command:"moveToNextGroup"},{key:"shift+[Tab]",command:"moveToPreviousGroup"},{key:"[Escape]",ifMode:"math",command:["switchMode","latex"]},{key:"[Escape]",ifMode:"text",command:["switchMode","latex"]},{key:"[Escape]",ifMode:"latex",command:["complete","complete",{selectItem:"true"}]},{key:"\\",ifMode:"math",command:["switchMode","latex","","\\"]},{key:"[IntlBackslash]",ifMode:"math",command:["switchMode","latex","","\\"]},{key:"[Tab]",ifMode:"latex",command:["complete","accept-suggestion"]},{key:"[Return]",ifMode:"latex",command:["complete","accept-all"]},{key:"[Enter]",ifMode:"latex",command:["complete","accept-all"]},{key:"shift+[Escape]",ifMode:"latex",command:["complete","reject"]},{key:"[ArrowDown]",ifMode:"latex",command:"nextSuggestion"},{key:"[ArrowUp]",ifMode:"latex",command:"previousSuggestion"},{key:"ctrl+a",ifPlatform:"!macos",command:"selectAll"},{key:"cmd+a",command:"selectAll"},{key:"[Cut]",command:"cutToClipboard"},{key:"[Copy]",command:"copyToClipboard"},{key:"[Paste]",command:"pasteFromClipboard"},{key:"[Clear]",command:"deleteBackward"},{key:"[Undo]",command:"undo"},{key:"[Redo]",command:"redo"},{key:"[EraseEof]",command:"deleteToGroupEnd"},{key:"ctrl+x",ifPlatform:"ios",command:"cutToClipboard"},{key:"cmd+x",ifPlatform:"ios",command:"cutToClipboard"},{key:"ctrl+c",ifPlatform:"ios",command:"copyToClipboard"},{key:"cmd+c",ifPlatform:"ios",command:"copyToClipboard"},{key:"ctrl+v",ifPlatform:"ios",command:"pasteFromClipboard"},{key:"cmd+v",ifPlatform:"ios",command:"pasteFromClipboard"},{key:"ctrl+z",ifPlatform:"!macos",command:"undo"},{key:"cmd+z",command:"undo"},{key:"ctrl+y",ifPlatform:"!macos",command:"redo"},{key:"shift+cmd+y",command:"redo"},{key:"shift+ctrl+z",ifPlatform:"!macos",command:"redo"},{key:"shift+cmd+z",command:"redo"},{key:"ctrl+b",ifPlatform:"macos",command:"moveToPreviousChar"},{key:"ctrl+f",ifPlatform:"macos",command:"moveToNextChar"},{key:"ctrl+p",ifPlatform:"macos",command:"moveUp"},{key:"ctrl+n",ifPlatform:"macos",command:"moveDown"},{key:"ctrl+a",ifPlatform:"macos",command:"moveToMathfieldStart"},{key:"ctrl+e",ifPlatform:"macos",command:"moveToMathfieldEnd"},{key:"shift+ctrl+b",ifPlatform:"macos",command:"extendSelectionBackward"},{key:"shift+ctrl+f",ifPlatform:"macos",command:"extendSelectionForward"},{key:"shift+ctrl+p",ifPlatform:"macos",command:"extendSelectionUpward"},{key:"shift+ctrl+n",ifPlatform:"macos",command:"extendSelectionDownward"},{key:"shift+ctrl+a",ifPlatform:"macos",command:"extendToMathFieldStart"},{key:"shift+ctrl+e",ifPlatform:"macos",command:"extendToMathFieldEnd"},{key:"alt+ctrl+b",ifPlatform:"macos",command:"moveToPreviousWord"},{key:"alt+ctrl+f",ifPlatform:"macos",command:"moveToNextWord"},{key:"shift+alt+ctrl+b",ifPlatform:"macos",command:"extendToPreviousWord"},{key:"shift+alt+ctrl+f",ifPlatform:"macos",command:"extendToNextWord"},{key:"ctrl+h",ifPlatform:"macos",command:"deleteBackward"},{key:"ctrl+d",ifPlatform:"macos",command:"deleteForward"},{key:"ctrl+l",ifPlatform:"macos",command:"scrollIntoView"},{key:"ctrl+[Digit2]",ifMode:"math",command:["insert","\\sqrt{#0}"]},{key:"ctrl+[Digit5]",ifMode:"math",command:"moveToOpposite"},{key:"ctrl+[Digit6]",ifMode:"math",command:"moveToSuperscript"},{key:"ctrl+[Return]",ifMode:"math",command:"addRowAfter"},{key:"ctrl+[Enter]",ifMode:"math",command:"addRowAfter"},{key:"cmd+[Return]",ifMode:"math",command:"addRowAfter"},{key:"cmd+[Enter]",ifMode:"math",command:"addRowAfter"},{key:"alt+p",ifMode:"math",command:["insert","\\pi"]},{key:"alt+v",ifMode:"math",command:["insert","\\sqrt{#0}"]},{key:"alt+shift+v",ifMode:"math",command:["insert","\\sqrt[#0]{#1}"]},{key:"alt+o",ifMode:"math",command:["insert","\\emptyset"]},{key:"alt+d",ifMode:"math",command:["insert","\\differentialD"]},{key:"shift+alt+o",ifMode:"math",command:["insert","\\varnothing"]},{key:"shift+alt+d",ifMode:"math",command:["insert","\\partial"]},{key:"alt+[Backslash]",ifMode:"math",command:["insert","\\backslash"]},{key:"[NumpadDivide]",ifMode:"math",command:["insert","\\frac{#@}{#?}"]},{key:"alt+[NumpadDivide]",ifMode:"math",command:["insert","\\frac{#?}{#@}"]},{key:"shift+alt+k",command:"toggleKeystrokeCaption"},{key:"alt+[Space]",command:"toggleContextMenu"},{key:"alt+shift+[Space]",command:"toggleVirtualKeyboard"},{key:"alt+ctrl+[ArrowUp]",command:["speak","all",{withHighlighting:!1}]},{key:"alt+ctrl+[ArrowDown]",command:["speak","selection",{withHighlighting:!1}]},{key:"shift+[Quote]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["switchMode","text","",""]},{key:"shift+[Quote]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"text",command:["switchMode","math","",""]},{key:"shift+alt+[KeyT]",ifMode:"math",command:["switchMode","text"]},{key:"shift+alt+[KeyT]",ifMode:"text",command:["switchMode","math"]},{key:"/",ifMode:"math",command:["insert","\\frac{#@}{#?}"]},{key:"alt+/",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","/"]},{key:"alt+shift+/",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","/"]},{key:"alt+[BracketLeft]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","\\left\\lbrack #0 \\right\\rbrack"]},{key:"ctrl+[Minus]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"moveToSubscript"},{key:"shift+alt+[BracketLeft]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","\\left\\lbrace #0 \\right\\rbrace"]},{key:"ctrl+;",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"addRowAfter"},{key:"cmd+;",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"addRowAfter"},{key:"shift+ctrl+;",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"addRowBefore"},{key:"shift+cmd+;",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"addRowBefore"},{key:"alt+[Tab]",ifMode:"math",command:"addColumnAfter"},{key:"shift+alt+[Tab]",ifMode:"math",command:"addColumnBefore"},{key:"alt+[Enter]",ifMode:"math",command:"addRowAfter"},{key:"shift+alt+[Enter]",ifMode:"math",command:"addRowBefore"},{key:"alt+[Return]",ifMode:"math",command:"addRowAfter"},{key:"shift+alt+[Return]",ifMode:"math",command:"addRowBefore"},{key:"shift+[Backspace]",ifMode:"math",command:"removeColumn"},{key:"shift+[Delete]",ifMode:"math",command:"removeRow"},{key:"shift+alt+[Backspace]",ifMode:"math",command:"removeRow"},{key:"alt+[Digit5]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","$\\infty"]},{key:"alt+[Digit9]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","("]},{key:"alt+[Digit0]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert",")"]},{key:"alt+|",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","|"]},{key:"shift+[Backquote]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","\\~"]},{key:"[Backquote]",ifLayout:["windows.french","linux.french"],ifMode:"math",command:["insert","^2"]},{key:"[Backquote]",ifLayout:["windows.german","linux.german"],ifMode:"math",command:["insert","^"]},{key:"[IntlBackslash]",ifLayout:["apple.german"],ifMode:"math",command:["insert","^"]}],nn={"\\sqrt":["alt+v","ctrl+[Digit2]"],"\\pi":"alt+p","\\infty":"alt+[Digit5]","\\differentialD":"alt+d","\\partial":"shift+alt+d","\\frac":"Slash","\\emptyset":"alt+o","\\varnothing":"shift+alt+o","\\~":"~"};function nl(e){var i;return(null==(i=e.element)?void 0:i.mathfield)===e}function ns(e){var i,r;let a=null!=(r=null!=(i=e.querySelector(".ML__caret"))?i:e.querySelector(".ML__text-caret"))?r:e.querySelector(".ML__latex-caret");if(!a)return null;let o=a.getBoundingClientRect();return{x:o.right,y:o.bottom,height:o.height}}function nc(e,i,r){if(!i)return null;let a=e.field.getBoundingClientRect(),o=i.right-i.left,n=i.bottom-i.top,l=Math.ceil(i.left-a.left+e.field.scrollLeft*r),s=Math.ceil(i.top-a.top);return{left:l,right:l+o,top:s,bottom:s+n}}function nd(e){let i=e,r=i.getBoundingClientRect();for(;r.bottom===r.top&&i.parentElement instanceof Element&&(r=(i=i.parentElement).getBoundingClientRect()).bottom===r.top;);let a=getComputedStyle(i),o=parseInt(a.marginRight),n=r.right-r.left,l=r.bottom-r.top;if(0===n||!Number.isFinite(n)){let e=parseFloat(a.width);Number.isFinite(e)&&e>0?n=e:i instanceof HTMLElement&&i.offsetWidth>0&&(n=i.offsetWidth)}if(0===l||!Number.isFinite(l)){let e=parseFloat(a.height);Number.isFinite(e)&&e>0?l=e:i instanceof HTMLElement&&i.offsetHeight>0&&(l=i.offsetHeight)}let s={top:r.top-1,bottom:r.top-1+l,left:r.left,right:r.left+n-1+o};if(0===e.children.length||"SVG"===e.tagName.toUpperCase())return s;for(let i of e.children)if(1===i.nodeType&&"atomId"in i.dataset&&!i.classList.contains("ML__pstrut")){let e=nd(i);s.left=Math.min(s.left,e.left),s.right=Math.max(s.right,e.right),s.top=Math.min(s.top,e.top),s.bottom=Math.max(s.bottom,e.bottom)}return s}function nu(e,i){var r,a;if(!i.id)return null;let o=null!=(a=null==(r=e.atomBoundsCache)?void 0:r.get(i.id))?a:null;if(null!==o)return o;let n=Array.from(e.field.querySelectorAll(`[data-atom-id="${i.id}"]`));if("prompt"===i.type){for(let e of n)if(e.classList.contains("ML__prompt-atom")){let i=e.querySelector(".ML__prompt");if(i){let e=nd(i);o?(o.left=Math.min(o.left,e.left),o.right=Math.max(o.right,e.right),o.top=Math.min(o.top,e.top),o.bottom=Math.max(o.bottom,e.bottom)):o=e}}}for(let e of n){let i=nd(e);o?(o.left=Math.min(o.left,i.left),o.right=Math.max(o.right,i.right),o.top=Math.min(o.top,i.top),o.bottom=Math.max(o.bottom,i.bottom)):o=i}return e.atomBoundsCache&&(o?e.atomBoundsCache.set(i.id,o):e.atomBoundsCache.delete(i.id)),null!=o?o:null}function nh(e,i){return e.model.selection.ranges.reduce((r,a)=>r.concat(...function(e,i,r){let a=new Map,o=e.field,n=o.offsetWidth,l=Math.floor(o.getBoundingClientRect().width)/n;for(let o of(l=isNaN(l)?1:l,e.model.getAtoms(i,{includeChildren:!0}))){if(null!=r&&r.excludeAtomsWithBackground&&o.style.backgroundColor)continue;let i=nc(e,nu(e,o),l);if(i){let e=function(e){var i;return e.parent?(null!=(i=e.parent.id)?i:"")+("string"==typeof e.parentBranch?"-"+e.parentBranch:`-${e.parentBranch[0]}/${e.parentBranch[0]}`):"root"}(o);if(a.has(e)){let r=a.get(e);a.set(e,{left:Math.min(r.left,i.left),right:Math.max(r.right,i.right),top:Math.min(r.top,i.top),bottom:Math.max(r.bottom,i.bottom)})}else a.set(e,i)}}return[...a.values()]}(e,a,i)),[])}function np(e,i){return"*"===e||"none"===i||("same-origin"===i?!window.origin||e===window.origin:"function"==typeof i&&i(e))}function nm(e){let i=0,r=0,a=e.offsetWidth,o=e.offsetHeight;for(;e instanceof HTMLElement;)i+=e.offsetTop,r+=e.offsetLeft,e=e.offsetParent;return new DOMRect(r,i,a,o)}function nf(e,i){if(!e)return;let r=e.model.at(i);if(!r)return;let a={},o=nu(e,r);o&&(a.bounds=new DOMRect(o.left,o.top,o.right-o.left,o.bottom-o.top)),a.depth=r.treeDepth-2,a.style=r.style;let n=r;for(;n;){if("\\htmlData"===n.command&&n.args&&"string"==typeof n.args[0])for(let e of n.args[0].split(",")){let i=e.match(/([^=]+)=(.+$)/);if(i){let e=i[1].trim().replace(/ /g,"-");e&&(a.data||(a.data={}),a.data[e]=i[2])}else{let i=e.trim().replace(/ /g,"-");i&&(a.data||(a.data={}),a.data[i]=void 0)}}("\\htmlId"===n.command||"\\cssId"===n.command)&&!a.id&&n.args&&"string"==typeof n.args[0]&&(a.id=n.args[0]),n=n.parent}return("math"===r.mode||"text"===r.mode)&&(a.latex=oG.serialize([r],{defaultMode:"math"})),a}var ng,nb,ny=`@keyframes ML__caret-blink {
|
|
192
192
|
0%,
|
|
193
193
|
100% {
|
|
194
194
|
opacity: 1;
|
|
@@ -694,7 +694,7 @@ menu .ML__base {
|
|
|
694
694
|
opacity: 0.5;
|
|
695
695
|
margin-left: 2ex;
|
|
696
696
|
}
|
|
697
|
-
`,
|
|
697
|
+
`,nv=`.ML__container {
|
|
698
698
|
min-height: auto !important;
|
|
699
699
|
--_hue: var(--hue, 212);
|
|
700
700
|
--_placeholder-color: var(--placeholder-color, hsl(var(--_hue), 40%, 49%));
|
|
@@ -1369,7 +1369,7 @@ menu .ML__base {
|
|
|
1369
1369
|
z-index: -1;
|
|
1370
1370
|
box-sizing: border-box;
|
|
1371
1371
|
}
|
|
1372
|
-
`,
|
|
1372
|
+
`,nx=`#mathlive-environment-popover.is-visible {
|
|
1373
1373
|
visibility: visible;
|
|
1374
1374
|
}
|
|
1375
1375
|
#mathlive-environment-popover {
|
|
@@ -1467,7 +1467,7 @@ menu .ML__base {
|
|
|
1467
1467
|
#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg.active circle {
|
|
1468
1468
|
fill: var(--_accent-color);
|
|
1469
1469
|
}
|
|
1470
|
-
`,
|
|
1470
|
+
`,n_=`/* Refined Subtle Design Tokens - \u4F4E\u8ABF (Low-key, Understated) with 3D Depth */
|
|
1471
1471
|
#mathlive-suggestion-popover {
|
|
1472
1472
|
--_suggestion-zindex: var(--suggestion-zindex, 100);
|
|
1473
1473
|
background: #0f0f0f;
|
|
@@ -1726,7 +1726,7 @@ menu .ML__base {
|
|
|
1726
1726
|
/* Subtle pressed keycap effect */
|
|
1727
1727
|
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.04);
|
|
1728
1728
|
}
|
|
1729
|
-
`,
|
|
1729
|
+
`,nw=`/* The element that displays the keys as the user type them */
|
|
1730
1730
|
#mathlive-keystroke-caption-panel {
|
|
1731
1731
|
visibility: hidden;
|
|
1732
1732
|
/*min-width: 160px;*/
|
|
@@ -1772,7 +1772,7 @@ body[theme='dark'] #mathlive-keystroke-caption-panel {
|
|
|
1772
1772
|
border: 2px solid var(--keystroke-border);
|
|
1773
1773
|
/*box-shadow: 0 7px 14px rgba(0,0,0,0.25), 0 5px 5px rgba(0,0,0,0.22);*/
|
|
1774
1774
|
}
|
|
1775
|
-
`,
|
|
1775
|
+
`,nk=`.ML__keyboard {
|
|
1776
1776
|
--_keyboard-height: 0;
|
|
1777
1777
|
--_keyboard-zindex: var(--keyboard-zindex, 105);
|
|
1778
1778
|
--_accent-color: var(--keyboard-accent-color, #0c75d8);
|
|
@@ -2721,7 +2721,7 @@ Note there are a different set of tooltip rules for the keyboard toggle
|
|
|
2721
2721
|
--_variant-keycap-text-active: var(--variant-keycap-text-active, var(--_keycap-text-active));
|
|
2722
2722
|
--_variant-keycap-background-active: var(--variant-keycap-background-active, var(--_accent-color));
|
|
2723
2723
|
}
|
|
2724
|
-
`,
|
|
2724
|
+
`,nM=`:host {
|
|
2725
2725
|
--primary-color: #5898ff;
|
|
2726
2726
|
--primary-color-dimmed: #c0c0f0;
|
|
2727
2727
|
--primary-color-dark: var(--blue-500);
|
|
@@ -3043,7 +3043,7 @@ Note there are a different set of tooltip rules for the keyboard toggle
|
|
|
3043
3043
|
--ui-line-height: auto;
|
|
3044
3044
|
--ui-letter-spacing: 0;
|
|
3045
3045
|
}
|
|
3046
|
-
`,
|
|
3046
|
+
`,nS=`.ui-menu *,
|
|
3047
3047
|
.ui-menu ::before,
|
|
3048
3048
|
.ui-menu ::after {
|
|
3049
3049
|
box-sizing: border-box;
|
|
@@ -3213,9 +3213,9 @@ Note there are a different set of tooltip rules for the keyboard toggle
|
|
|
3213
3213
|
width: 16px;
|
|
3214
3214
|
height: 16px;
|
|
3215
3215
|
}
|
|
3216
|
-
`,
|
|
3216
|
+
`,nL=null;function nC(e,i){return nL&&"mathfield-element"!==e?`@scope (${nL}) {
|
|
3217
3217
|
${i}
|
|
3218
|
-
}`:i}function
|
|
3218
|
+
}`:i}function nE(e){let i="";switch(e){case"mathfield-element":i=`
|
|
3219
3219
|
:host { display: inline-block; background-color: field; color: fieldtext; border-width: 1px; border-style: solid; border-color: #acacac; border-radius: 2px;}
|
|
3220
3220
|
:host([hidden]) { display: none; }
|
|
3221
3221
|
:host([disabled]), :host([disabled]:focus), :host([disabled]:focus-within) { outline: none; opacity: .5; }
|
|
@@ -3226,8 +3226,8 @@ ${i}
|
|
|
3226
3226
|
:host([readonly]:focus), :host([readonly]:focus-within),
|
|
3227
3227
|
:host([read-only]:focus), :host([read-only]:focus-within) {
|
|
3228
3228
|
outline: none;
|
|
3229
|
-
}`;break;case"core":i=ny;break;case"mathfield":i=nb;break;case"environment-popover":i=nv;break;case"suggestion-popover":i=nx;break;case"keystroke-caption":i=n_;break;case"virtual-keyboard":i=nw;break;case"ui":i=nk;break;case"menu":i=nM}return i}function nE(e){return ng||(ng={}),ng[e]||(ng[e]=new CSSStyleSheet,ng[e].replaceSync(nL(e,nC(e)))),ng[e]}function nA(e){var i;try{if(!("adoptedStyleSheets"in document)){if(window.document.getElementById(`mathlive-style-${e}`))return;let i=window.document.createElement("style");i.id=`mathlive-style-${e}`,i.append(window.document.createTextNode(nL(e,nC(e)))),window.document.head.appendChild(i);return}if(sS||(sS={}),(null!=(i=sS[e])?i:0)!==0)sS[e]+=1;else{let i=nE(e);document.adoptedStyleSheets=[...document.adoptedStyleSheets,i],sS[e]=1}}catch(i){console.error("Error injecting stylesheet",e,i)}}function nz(e){if("adoptedStyleSheets"in document&&null!=sS&&sS[e]&&(sS[e]-=1,sS[e]<=0)){let i=ng[e];document.adoptedStyleSheets=document.adoptedStyleSheets.filter(e=>e!==i)}}var nT=class e extends oG{constructor(e){var i;super(g(f({},e),{type:"accent",body:null!=(i=e.body)?i:void 0})),e.accentChar?this.accent=e.accentChar:this.svgAccent=null==e?void 0:e.svgAccent,this.skipBoundary=!0,this.captureSelection=!0}static fromJson(i){return new e(i)}toJson(){return g(f({},super.toJson()),{accentChar:this.accent,svgAccent:this.svgAccent})}render(e){var i;let r=new oW({parent:e,mathstyle:"cramp"},this.style),a=null!=(i=oG.createBox(r,this.body))?i:new oE("□",{style:this.style}),o=0;!this.hasEmptyBranch("body")&&2===this.body.length&&this.body[1].isCharacterBox()&&(o=a.skew);let n=Math.min(a.height,.431),l;if(this.svgAccent)l=oT(this.svgAccent),n=r.metrics.bigOpSpacing1-n;else if(this.accent){let e=new oE(this.accent,{fontFamily:"Main-Regular"});e.italic=0,l=new oE(e,{classes:"ML__accent-body"+(8407===this.accent||8411===this.accent||8412===this.accent?" ML__accent-combining-char":"")})}let s=(a.width-l.width)/2+a.left+2*o;l=new oB({shift:0,children:[{box:new oE(a)},-n,{box:l,marginLeft:s,classes:["ML__center"]}]});let c=new oE(l,{type:"ord"});return this.caret&&(c.caret=this.caret),this.bind(r,c.wrap(r)),this.attachSupsub(r,{base:c})}},nD={"(":")","{":"}","[":"]","|":"|","\\lbrace":"\\rbrace","\\lparen":"\\rparen","\\{":"\\}","\\langle":"\\rangle","\\lfloor":"\\rfloor","\\lceil":"\\rceil","\\vert":"\\vert","\\lvert":"\\rvert","\\Vert":"\\Vert","\\lVert":"\\rVert","\\lbrack":"\\rbrack","\\ulcorner":"\\urcorner","\\llcorner":"\\lrcorner","\\lgroup":"\\rgroup","\\lmoustache":"\\rmoustache"},nK=Object.fromEntries(Object.entries(nD).map(([e,i])=>[i,e]));function nB(e){var i;return null!=(i=({"[":91,"]":93,"(":40,")":41,"\\mid":8739,"|":8739,"∣":8739,"∥":8741,"\\|":8739,"\\{":123,"\\}":125,"\\lbrace":123,"\\rbrace":125,"\\lparen":40,"\\rparen":41,"\\lbrack":91,"\\rbrack":93,"\\vert":8739,"\\lvert":8739,"\\mvert":8739,"\\rvert":8739,"\\Vert":8741,"\\lVert":8741,"\\mVert":8741,"\\rVert":8741,"\\parallel":8741,"\\shortparallel":8741,"\\langle":10216,"\\rangle":10217,"\\lfloor":8970,"\\rfloor":8971,"\\lceil":8968,"\\rceil":8969,"\\ulcorner":9484,"\\urcorner":9488,"\\llcorner":9492,"\\lrcorner":9496,"\\lgroup":10222,"\\rgroup":10223,"\\lmoustache":9136,"\\rmoustache":9137,"\\surd":8730})[e])?i:e.codePointAt(0)}function n$(e,i,r,a,o){var n,l;let s=new oW({parent:a,mathstyle:"textstyle"},null==o?void 0:o.style),c=new oE(nB(e),{fontFamily:`Size${i}-Regular`,isSelected:o.isSelected,classes:(null!=(n=o.classes)?n:"")+` ML__delim-size${i}`,type:null!=(l=o.type)?l:"ignore"}).wrap(s);return r&&c.setTop((1-s.scalingFactor)*.25),c}function nP(e,i,r,a,o){var n;let l,s,c,d;l=c=d=nB(e),s=null;let u="Size1-Regular";"\\vert"===e||"\\lvert"===e||"\\rvert"===e||"\\mvert"===e||"\\mid"===e?c=l=d=8739:"\\Vert"===e||"\\lVert"===e||"\\rVert"===e||"\\mVert"===e||"\\|"===e?c=l=d=8741:"\\uparrow"===e?c=d=9168:"\\Uparrow"===e?c=d=8214:"\\downarrow"===e?l=c=9168:"\\Downarrow"===e?l=c=8214:"\\updownarrow"===e?(l=8593,c=9168,d=8595):"\\Updownarrow"===e?(l=8657,c=8214,d=8659):"["===e||"\\lbrack"===e?(l=9121,c=9122,d=9123,u="Size4-Regular"):"]"===e||"\\rbrack"===e?(l=9124,c=9125,d=9126,u="Size4-Regular"):"\\lfloor"===e||"⌊"===e?(c=l=9122,d=9123,u="Size4-Regular"):"\\lceil"===e||"⌈"===e?(l=9121,c=d=9122,u="Size4-Regular"):"\\rfloor"===e||"⌋"===e?(c=l=9125,d=9126,u="Size4-Regular"):"\\rceil"===e||"⌉"===e?(l=9124,c=d=9125,u="Size4-Regular"):"("===e||"\\lparen"===e?(l=9115,c=9116,d=9117,u="Size4-Regular"):")"===e||"\\rparen"===e?(l=9118,c=9119,d=9120,u="Size4-Regular"):"\\{"===e||"\\lbrace"===e?(l=9127,s=9128,d=9129,c=9130,u="Size4-Regular"):"\\}"===e||"\\rbrace"===e?(l=9131,s=9132,d=9133,c=9130,u="Size4-Regular"):"\\lgroup"===e||"⟮"===e?(l=9127,d=9129,c=9130,u="Size4-Regular"):"\\rgroup"===e||"⟯"===e?(l=9131,d=9133,c=9130,u="Size4-Regular"):"\\lmoustache"===e||"⎰"===e?(l=9127,d=9133,c=9130,u="Size4-Regular"):"\\rmoustache"===e||"⎱"===e?(l=9131,d=9129,c=9130,u="Size4-Regular"):"\\surd"===e?(l=57345,d=9143,c=57344,u="Size4-Regular"):"\\ulcorner"===e?(l=9484,c=d=32):"\\urcorner"===e?(l=9488,c=d=32):"\\llcorner"===e?(d=9492,c=l=32):"\\lrcorner"===e&&(l=9496,c=l=32);let h=oa(l,u),p=h.height+h.depth,m=oa(c,u),b=m.height+m.depth,y=oa(d,u),v=y.height+y.depth,x=0,_=1;if(null!==s){let e=oa(s,u);x=e.height+e.depth,_=2}let w=p+v+x,k=Math.max(0,Math.ceil((i-w)/(_*b))),M=w+k*_*b,S=.25;r&&(S*=a.scalingFactor);let L=M/2-S,C=[];C.push({box:new oE(d,{fontFamily:u})}),C.push(-.008);let E=new oE(c,{fontFamily:u});if(null===s)for(let e=0;e<k;e++)C.push({box:E});else{for(let e=0;e<k;e++)C.push({box:E});C.push(-.008),C.push({box:new oE(s,{fontFamily:u})}),C.push(-.008);for(let e=0;e<k;e++)C.push({box:E})}C.push(-.008),C.push({box:new oE(l,{fontFamily:u})});let A="";return"Size1-Regular"===u?A=" delim-size1":"Size4-Regular"===u&&(A=" delim-size4"),new oE(new oB({bottom:L,children:C},{classes:A}),g(f({},null!=o?o:{}),{classes:(null!=(n=null==o?void 0:o.classes)?n:"")+" ML__delim-mult"}))}var nO=new Set(["(",")","\\lparen","\\rparen","[","]","\\lbrack","\\rbrack","\\{","\\}","\\lbrace","\\rbrace","\\lfloor","\\rfloor","\\lceil","\\rceil","\\surd","⌊","⌋","⌈","⌉"]),nR=new Set(["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\mvert","\\mid","\\lgroup","\\rgroup","\\lmoustache","\\rmoustache","⟮","⟯","⎰","⎱"]),nI=new Set(["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"]),nN=[0,1.2,1.8,2.4,3],nq=[{type:"small",mathstyle:"scriptscriptstyle"},{type:"small",mathstyle:"scriptstyle"},{type:"small",mathstyle:"textstyle"},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],nF=[{type:"small",mathstyle:"scriptscriptstyle"},{type:"small",mathstyle:"scriptscriptstyle"},{type:"small",mathstyle:"textstyle"},{type:"stack"}],nV=[{type:"small",mathstyle:"scriptscriptstyle"},{type:"small",mathstyle:"scriptstyle"},{type:"small",mathstyle:"textstyle"},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}];function nj(e,i,r,a,o,n){var l,s,c;let d,u;if(!i||0===i.length||"."===i)return nW(o);"<"===i||"\\lt"===i?i="\\langle":(">"===i||"\\gt"===i)&&(i="\\rangle"),d=nI.has(i)?nq:nO.has(i)?nV:nF;let h=function(e,i,r,a){let o={"-4":0,"-3":1,0:2}[a.mathstyle.sizeDelta];for(let l=o;l<r.length&&"stack"!==r[l].type;l++){var n;let o=oa(e,"small"===(n=r[l]).type?"Main-Regular":"large"===n.type?"Size"+n.size+"-Regular":(n.type,"Size4-Regular"));if(o.defaultMetrics)return{type:"small",mathstyle:"scriptstyle"};let s=o.height+o.depth;if("small"===r[l].type&&("scriptscriptstyle"===r[l].mathstyle?s*=Math.max(oi[Math.max(1,a.size-2)],a.minFontScale):"scriptstyle"===r[l].mathstyle&&(s*=Math.max(oi[Math.max(1,a.size-1)],a.minFontScale))),s>i)return r[l]}return r[r.length-1]}(nB(i),r,d,o),p=new oW({parent:o,mathstyle:h.mathstyle},null==n?void 0:n.style);return"small"===h.type?(l=i,s=g(f({},n),{type:e}),u=new oE(nB(l),{fontFamily:"Main-Regular",isSelected:s.isSelected,classes:"ML__small-delim "+(null!=(c=s.classes)?c:"")}).wrap(p),a&&u.setTop((1-p.scalingFactor)*.25),u):"large"===h.type?n$(i,h.size,a,p,g(f({},n),{type:e})):(h.type,nP(i,r,a,p,g(f({},n),{type:e})))}function nH(e,i,r,a,o,n){if("."===i)return nW(o,null==n?void 0:n.classes);let l=.25*o.scalingFactor,s=Math.max(r-l,a+l);return nj(e,i,Math.max(s/500*901,2*s-.5),!0,o,n)}function nW(e,i){let r=new oE(null,{classes:" ML__nulldelimiter "+(null!=i?i:""),type:"ignore"});return r.width=e.getRegisterAsEm("nulldelimiterspace"),r.wrap(new oW({parent:e,mathstyle:"textstyle"}))}var nU=class e extends oG{constructor(e){var i;super({type:"placeholder",command:"\\placeholder",mode:null!=(i=null==e?void 0:e.mode)?i:"math",style:null==e?void 0:e.style}),this.captureSelection=!0}static fromJson(i){return new e(i)}toJson(){return super.toJson()}render(e){let i;return this.value=e.placeholderSymbol,i="function"==typeof e.renderPlaceholder?e.renderPlaceholder(e):this.createBox(e),this.caret&&(i.classes+=" ML__placeholder-selected"),i}_serialize(e){return e.skipPlaceholders?"":"\\placeholder{}"}},nJ=["matrix","matrix*","pmatrix","pmatrix*","bmatrix","bmatrix*","Bmatrix","Bmatrix*","vmatrix","vmatrix*","Vmatrix","Vmatrix*"],nX=["cases","dcases","rcases"],nG=["align","align*","aligned","gather","gather*","gathered","split"],nZ=["array","subequations","eqnarray"];function nY(e){return nJ.includes(e)}var nQ=class e extends oG{get isMultiline(){return["lines","multline","multline*","align","split","gather","gathered"].includes(this.environmentName)}constructor(e,i,r,a={}){var o,n,l,s;if(super({type:"array",isRoot:a.isRoot}),this.environmentName=e,a.columns)0===a.columns.length?this.colFormat=[{align:"l"}]:this.colFormat=[...a.columns];else if(a.minColumns){let e=[];for(let i=0;i<a.minColumns;i++)e.push({align:"l"});this.colFormat=e}else this.colFormat=[{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"}];this.minColumns=null!=(o=a.minColumns)?o:1,this.minRows=null!=(n=a.minRows)?n:1,this.maxRows=null!=(l=a.maxRows)?l:1/0;let c=function(e,i,r){var a,o,n,l,s,c,d;let u=0;for(let e of r.columns)"align"in e&&(u+=1);u=Math.max(u,r.minColumns);let h=0,p=[],m=[];for(let n=0;n<i.length;n++){let l=i[n];h=Math.max(h,Math.min(l.length,u));let d=0,f=!0;for(;d<l.length;){let i=[],h=Math.min(l.length,d+u);for(;d<h;){i.push((s=l[d],c=e.mode,0===s.length?[new oG({type:"first",mode:c})]:"first"!==s[0].type?[new oG({type:"first",mode:c}),...s]:(s.slice(1).some(e=>"first"===e.type),s))),d+=1}if(i.length<r.minColumns)for(;i.length<r.minColumns;)i.push([new oG({type:"first",mode:e.mode})]);p.push(i),m.push(f?[...null!=(o=null==(a=r.rowRules)?void 0:a[n])?o:[]]:[]),f=!1}}if(m.push([...null!=(l=null==(n=r.rowRules)?void 0:n[i.length])?l:[]]),!e.isMultiline&&p.length>0&&1===p[p.length-1].length&&1===(d=p[p.length-1][0]).length&&"first"===d[0].type){p.pop();let e=m.pop();m[m.length-1].push(...e)}let f=[];for(let i of p){if(i.length!==h)for(let r=i.length;r<h;r++)e.isMultiline?i.push([new oG({type:"first",mode:e.mode})]):i.push([new oG({type:"first",mode:e.mode}),new nU]);f.push(i)}let g=0,b=0;for(let i of f){for(let r of(b=0,i)){for(let i of r)i.parent=e,i.parentBranch=[g,b];b+=1}g+=1}return e.isDirty=!0,{rows:f,rowRules:m}}(this,i,{columns:this.colFormat,minColumns:this.minColumns,minRows:this.minRows,maxRows:this.maxRows,rowRules:a.rowRules});this._rows=c.rows,this.rowRules=c.rowRules,this.rowGaps=r,void 0!==a.arraycolsep&&(this.arraycolsep=a.arraycolsep),this.colSeparationType=a.colSeparationType,void 0!==a.arraystretch&&(this.arraystretch=a.arraystretch),a.mathstyleName&&(this.mathstyleName=a.mathstyleName),a.leftDelim&&(this.leftDelim=a.leftDelim),a.rightDelim&&(this.rightDelim=a.rightDelim),this.classes=null!=(s=a.classes)?s:[]}static fromJson(i){return new e(i.environmentName,i.array,i.rowGaps,i)}toJson(){let e=g(f({},super.toJson()),{environmentName:this.environmentName,array:this._rows.map(e=>e.map(e=>e.map(e=>e.toJson()))),rowGaps:this.rowGaps,columns:this.colFormat,colSeparationType:this.colSeparationType,minColumns:this.minColumns,minRows:this.minRows,maxRows:this.maxRows});return void 0!==this.arraystretch&&(e.arraystretch=this.arraystretch),void 0!==this.arraycolsep&&(e.arraycolsep=this.arraycolsep),this.leftDelim&&(e.leftDelim=this.leftDelim),this.rightDelim&&(e.rightDelim=this.rightDelim),this.isRoot&&(e.isRoot=!0),e.minColumns=this.minColumns,e.minRows=this.minRows,e.maxRows=this.maxRows,this.mathstyleName&&(e.mathstyleName=this.mathstyleName),this.classes.length>0&&(e.classes=this.classes),this.hasRowRules&&(e.rowRules=this.rowRules),e}get hasRowRules(){return this.rowRules.some(e=>e.length>0)}branch(e){var i;if(oX(e))return null!=(i=this._rows[e[0]][e[1]])?i:void 0}createBranch(e){var i;return oX(e)?(this.isDirty=!0,null!=(i=this.branch(e))?i:[]):[]}get rowCount(){return this._rows.length}get colCount(){return this._rows[0].length}get maxColumns(){return this.colFormat.filter(e=>!!e.align).length}removeBranch(e){if(oJ(e))return super.removeBranch(e);let[i,...r]=this.branch(e);return i.type,this._rows[e[0]][e[1]]=void 0,r.forEach(e=>{e.parent=void 0,e.parentBranch=void 0}),this.isDirty=!0,r}get hasChildren(){return this.children.length>0}get children(){let e=[];for(let i of this._rows)for(let r of i)if(r)for(let i of r)e.push(...i.children),e.push(i);return[...e,...super.children]}render(e){var i,r,a,o,n,l,s;let c=new oW({parent:e,mathstyle:this.mathstyleName},this.style),d=c.getRegisterAsEm("arrayrulewidth"),u=c.getRegisterAsEm("arraycolsep"),h=c.getRegisterAsEm("doublerulesep"),p=null!=(r=null!=(i=this.arraystretch)?i:c.getRegisterAsNumber("arraystretch"))?r:1,m="number"==typeof this.arraycolsep?this.arraycolsep:u;"small"===this.colSeparationType&&(m=.2778*(new oW({parent:e,mathstyle:"scriptstyle"}).scalingFactor/e.scalingFactor));let f=1.2*p,g=.7*f,b=.3*f,y=0,v=[],x=0,_=this._rows.length,w=[],k=e=>{if(e)for(let i=0;i<e.length;i++)i>0&&(y+=h),w.push({rule:e[i],y:y})};k(this.rowRules[0]);for(let e=0;e<_;++e){let i=this._rows[e];x=Math.max(x,i.length);let r=new oW({parent:c,mathstyle:this.mathstyleName},this.style),n=g/r.scalingFactor,l=b/r.scalingFactor,d={cells:[],height:0,depth:0,pos:0};for(let e of i){let i=this.isMultiline&&e&&(s=e).length>0&&s.every(e=>"first"===e.type)?function(e,i,r){let a=new oE(null,{classes:"ML__empty-line-anchor"}),o=e[0];o&&(o.id||(o.id=i.makeID()),a.atomID=o.id),a.setStyle("display","inline-block"),a.setStyle("width",0),a.setStyle("position","relative"),a.setStyle("height",Math.max(0,r.height+r.depth),"em"),a.setStyle("vertical-align",-r.depth,"em"),a.height=r.height,a.depth=r.depth;let n=e.find(e=>e.caret);return null!=n&&n.caret&&(a.caret=n.caret),e.some(e=>e.isSelected)&&a.selected(!0),a}(e,r,{height:g/r.scalingFactor,depth:b/r.scalingFactor}):null!=(a=oG.createBox(r,e,{type:"ignore"}))?a:new oE(null,{type:"ignore"});l=Math.max(l,i.depth),n=Math.max(n,i.height),d.cells.push(i)}let u=null!=(o=oN(this.rowGaps[e]))?o:0;u>0&&(u+=b,l=Math.max(l,u),u=0),e<_-1&&!nY(this.environmentName)&&"cases"!==this.environmentName&&"array"!==this.environmentName&&(l+=c.getRegisterAsEm("jot")),d.height=n,d.depth=l,d.pos=y+=n,y+=l+u,v.push(d),k(this.rowRules[e+1])}let M="array"!==this.environmentName||this.isMultiline?y/2+.25:v[0].height,S=w.filter(e=>void 0===e.rule.from),L=w.filter(e=>void 0!==e.rule.from),C=(e,i)=>L.filter(({rule:r})=>{var a;return r.from<=e&&(null!=(a=r.to)?a:r.from)>=i}).map(({rule:e,y:i})=>({box:n2(e.style,d),shift:i-M})),E=[];for(let e=0;e<x;e++){let i=[];for(let r of v){let a=r.cells[e];a&&(a.depth=r.depth,a.height=r.height,i.push({box:a,shift:r.pos-M}))}i.push(...C(e,e)),i.length>0&&E.push(new oB({individualShift:i}))}let A=(e,i)=>{if(i<0||i+1>=E.length)return n4(e);let r=C(i,i+1);if(0===r.length)return n4(e);let a=new oB({individualShift:r});return a.width=e,a},z=[],T=!1,D=!1,K=0,B=!this.leftDelim,{colFormat:$}=this;for(let i of $){if("align"in i&&K>=E.length)break;if("align"in i)T?z.push(A(2*m,K-1)):(D||B)&&z.push(n4(m)),z.push(new oE(E[K],{classes:"col-align-"+i.align})),K++,T=!0,D=!1,B=!1;else if("gap"in i){if("number"==typeof i.gap)z.push(A(i.gap,T?K-1:-1));else{let r=function(e,i,r,a){if(!a)return null;let o=[];for(let n of i){let i=oG.createBox(e,a,{type:"ignore"});i&&(i.depth=n.depth,i.height=n.height,o.push({box:i,shift:n.pos-r}))}return new oB({individualShift:o}).wrap(e)}(e,v,M,i.gap);r&&z.push(r)}T=!1,D=!1,B=!1}else if("separator"in i){let e=new oE(null,{classes:"ML__vertical-separator"});e.height=y,e.setStyle("height",y,"em"),e.setStyle("border-right",`${d}em ${i.separator} currentColor`),e.setStyle("vertical-align",-(y-M),"em");let r=0;D?r=h-d:T&&(r=m-d),e.left=r,z.push(e),T=!1,D=!0,B=!1}}T&&!this.rightDelim&&z.push(n4(m));let P=new oE(z,{classes:["ML__mtable",...this.classes].join(" ")});if("array"!==this.environmentName||this.isMultiline||(P.height=v[0].height,P.depth=y-v[0].height),S.length>0&&(P=new oB({individualShift:[{box:P,shift:0},...S.map(({rule:e,y:i})=>({box:n2(e.style,d),shift:i-M}))]})),(!this.leftDelim||"."===this.leftDelim)&&(!this.rightDelim||"."===this.rightDelim))return this.caret&&(P.caret=this.caret),this.bind(e,P);let O=P.height,R=P.depth,I=this.bind(e,new oE([this.bind(e,nH("open",null!=(n=this.leftDelim)?n:".",O,R,c,{isSelected:this.isSelected})),P,this.bind(e,nH("close",null!=(l=this.rightDelim)?l:".",O,R,c,{isSelected:this.isSelected}))],{type:"ord"}));return I?(I.setStyle("display","inline-block"),this.caret&&(I.caret=this.caret),this.bind(e,this.attachSupsub(e,{base:I}))):null}_serialize(e){var i,r;let a=[];if("lines"===this.environmentName&&this._rows.length>1?a.push("\\displaylines{"):"lines"!==this.environmentName&&a.push(`\\begin{${this.environmentName}}`),"array"===this.environmentName){if(a.push("{"),void 0!==this.colFormat)for(let e of this.colFormat)"align"in e&&"string"==typeof e.align?a.push(e.align):"separator"in e&&"solid"===e.separator?a.push("|"):"separator"in e&&"dashed"===e.separator&&a.push(":");a.push("}")}a.push(...n3(this.rowRules[0]));for(let o=0;o<this._rows.length;o++){for(let i=0;i<this._rows[o].length;i++)i>0&&a.push(" & "),a.push(oG.serialize(this._rows[o][i],e));let n=null!=(i=this.rowRules[o+1])?i:[];if(o<this._rows.length-1||n.length>0){let e=this.rowGaps[o];null!=e&&e.dimension?a.push(`\\\\[${e.dimension} ${null!=(r=e.unit)?r:"pt"}] `):a.push("\\\\ ")}a.push(...n3(n))}return"lines"===this.environmentName&&this._rows.length>1?a.push("}"):"lines"!==this.environmentName&&a.push(`\\end{${this.environmentName}}`),of(a)}forEachCell(e){for(let i=0;i<this.rowCount;i++)for(let r=0;r<this.colCount;r++)e(this._rows[i][r],i,r)}getCell(e,i){var r;return null==(r=this._rows[e])?void 0:r[i]}setCell(e,i,r){for(let r of("array"===this.type&&Array.isArray(this._rows)&&this._rows[e][i],this._rows[e][i]))r.parent=void 0,r.parentBranch=void 0;let a=[new oG({type:"first",mode:this.mode}),...r.filter(e=>"first"!==e.type)];this._rows[e][i]=a,n1(this),this.isDirty=!0}addRowBefore(e){"array"===this.type&&Array.isArray(this._rows),this._rows.splice(e,0,Array.from({length:this.colCount},()=>n0(this,!this.isMultiline))),this.rowRules.splice(e,0,[]),n1(this),this.isDirty=!0}addRowAfter(e){"array"===this.type&&Array.isArray(this._rows),this._rows.splice(e+1,0,Array.from({length:this.colCount},()=>n0(this,!this.isMultiline))),this.rowRules.splice(e+1,0,[]),n1(this),this.isDirty=!0}removeRow(e){for(let i of("array"===this.type&&Array.isArray(this._rows)&&this.rowCount,this.rowRules.splice(e,1),this._rows.splice(e,1)))for(let e of i)if(e)for(let i of e)i.parent=void 0,i.parentBranch=void 0;n1(this),this.isDirty=!0}addColumnBefore(e){for(let i of("array"===this.type&&Array.isArray(this._rows),this._rows))i.splice(e,0,n0(this));n6(this.rowRules,e,1),n1(this),this.isDirty=!0}addColumnAfter(e){for(let i of("array"===this.type&&Array.isArray(this._rows),this._rows))i.splice(e+1,0,n0(this));n6(this.rowRules,e+1,1),n1(this),this.isDirty=!0}addColumn(){this.addColumnAfter(this.colCount-1)}removeColumn(e){for(let i of("array"===this.type&&Array.isArray(this._rows)&&this.colCount,this._rows))for(let r of i.splice(e,1))if(r)for(let e of r)e.parent=void 0,e.parentBranch=void 0;n6(this.rowRules,e,-1),n1(this),this.isDirty=!0}get cells(){let e=[];for(let i of this._rows)for(let r of i)r&&e.push(r.filter(e=>"first"!==e.type));return e}get rows(){return this._rows}};function n0(e,i=!1){let r=new oG({type:"first",mode:e.mode});r.parent=e;let a=[r];if(i){let i=new nU;i.parent=e,a.push(i)}return a}function n1(e){for(let i=0;i<e.rowCount;i++)for(let r=0;r<e.colCount;r++){let a=e.getCell(i,r);if(a)for(let o of a)o&&(o.parent=e,o.parentBranch=[i,r])}}function n4(e){let i=new oE(null,{classes:"ML__arraycolsep"});return i.width=e,i}function n2(e,i){let r=new oE(null,{classes:"dashed"===e?"ML__hdashline":"ML__hline"});return r.height=i,r.depth=0,r.maxFontSize=i,r.setStyle("border-bottom",`${i}em ${e} currentColor`),r}function n3(e){return e&&0!==e.length?e.map(e=>{var i;if(void 0===e.from)return"dashed"===e.style?"\\hdashline ":"\\hline ";let r=null!=(i=e.to)?i:e.from;return`\\cline{${e.from+1}-${r+1}} `}):[]}function n6(e,i,r){var a;for(let o=0;o<e.length;o++){let n=[];for(let l of e[o]){if(void 0===l.from){n.push(l);continue}let e=l.from,o=null!=(a=l.to)?a:l.from;if(r>0)e>=i&&(e+=1),o>=i&&(o+=1);else{if(e===i&&o===i)continue;e>i&&(e-=1),o>=i&&(o-=1)}n.push(g(f({},l),{from:e,to:o}))}e[o]=n}}var n8=class e extends oG{constructor(e){super({mode:e.mode,command:e.command,style:e.style,body:e.body,type:"box"}),this.framecolor=e.framecolor,this.backgroundcolor=e.backgroundcolor,this.padding=e.padding,this.offset=e.offset,this.border=e.border}static fromJson(i){return new e(i)}toJson(){return g(f({},super.toJson()),{framecolor:this.framecolor,backgroundcolor:this.backgroundcolor,padding:this.padding,offset:this.offset,border:this.border})}render(e){var i,r,a,o;let n=oG.createBox(e,this.body,{type:"lift"});if(!n)return null;let l=e.toEm(null!=(i=this.offset)?i:{dimension:0});n.depth+=l,n.setStyle("display","inline-block"),n.setStyle("position","relative"),n.setStyle("height",Math.floor(100*n.height+n.depth)/100,"em"),n.setStyle("vertical-align",-Math.floor(100*n.height)/100,"em");let s=new oW({parent:e},this.style),c=s.toEm(null!=(r=this.padding)?r:{register:"fboxsep"}),d=new oE(null,{classes:"ML__box"});d.height=n.height+c,d.depth=n.depth+c,d.setStyle("box-sizing","border-box"),d.setStyle("position","absolute"),d.setStyle("top",-c+.3,"em"),d.setStyle("left",0),d.setStyle("height",d.height+d.depth,"em"),d.setStyle("width","100%"),this.backgroundcolor&&d.setStyle("background-color",null!=(a=s.toBackgroundColor(this.backgroundcolor))?a:"transparent"),this.framecolor&&d.setStyle("border",`${s.getRegisterAsEm("fboxrule",2)}em solid ${null!=(o=s.toColor(this.framecolor))?o:"black"}`),this.border&&d.setStyle("border",this.border);let u=new oE([d,n],{type:"lift"});return u.setStyle("display","inline-block"),u.setStyle("position","relative"),u.setStyle("line-height",0),u.height=n.height+c+(l>0?l:0),u.depth=n.depth+c+(l<0?-l:0),u.setStyle("padding-left",c,"em"),u.setStyle("padding-right",c,"em"),u.setStyle("height",Math.floor(100*(n.height+n.depth+2*c+Math.abs(l)))/100,"em"),u.setStyle("margin-top",-c,"em"),u.setStyle("top",Math.floor(100*(n.depth-n.height+2*c-l))/100,"em"),u.setStyle("vertical-align",Math.floor(100*(n.depth+2*c))/100,"em"),this.caret&&(u.caret=this.caret),this.attachSupsub(e,{base:u})}_serialize(e){return e.skipStyles?of([this.bodyToLatex(e),this.supsubToLatex(e)]):super._serialize(e)}},n5=class e extends oG{constructor(e,i){var r;super({type:"composition",mode:null!=(r=null==i?void 0:i.mode)?r:"math",value:e})}static fromJson(i){return new e(i.value,i)}toJson(){return super.toJson()}render(e){let i=new oE(this.value,{classes:"ML__composition",type:"composition"});return this.bind(e,i),this.caret&&(i.caret=this.caret),i}_serialize(e){return""}},n7=class e extends oG{constructor(e){super({type:"error",value:e,command:e,mode:"math"}),this.verbatimLatex=e}static fromJson(i){return new e(i.command)}toJson(){return super.toJson()}render(e){let i=this.createBox(e,{classes:"ML__error"});return this.caret&&(i.caret=this.caret),i}},n9=class e extends oG{constructor(e,i){super({type:"group",mode:i}),this.body=e,this.boxType=e.length>1?"ord":"ignore",this.skipBoundary=!0,this.displayContainsHighlight=!1,(null==e?void 0:e.length)===1&&","===e[0].command&&(this.captureSelection=!0)}static fromJson(i){return new e(i.body,i.mode)}render(e){let i=oG.createBox(e,this.body,{type:this.boxType});return i?(this.caret&&(i.caret=this.caret),this.bind(e,i)):null}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let i=eM(this.command,this.mode);return null!=i&&i.serialize?i.serialize(this,e):`{${this.bodyToLatex(e)}}`}},le=class e extends oG{constructor(e,i,r){super({type:"leftright",style:r.style,displayContainsHighlight:!0}),this.variant=e,this.body=i,this.leftDelim=r.leftDelim,this.rightDelim=r.rightDelim}static fromJson(i){var r;return new e(null!=(r=i.variant)?r:"",i.body,i)}toJson(){let e=super.toJson();return this.variant&&(e.variant=this.variant),this.leftDelim&&(e.leftDelim=this.leftDelim),this.rightDelim&&(e.rightDelim=this.rightDelim),e}_serialize(e){var i,r;let a=this.matchingRightDelim();return"left...right"===this.variant?of(["\\left",null!=(i=this.leftDelim)?i:".",this.bodyToLatex(e),"\\right",a]):"mleft...mright"===this.variant?of(["\\mleft",null!=(r=this.leftDelim)?r:".",this.bodyToLatex(e),"\\mright",a]):of([this.leftDelim&&"."!==this.leftDelim?this.leftDelim:"",this.bodyToLatex(e),a])}matchingRightDelim(){var e,i;if(this.rightDelim&&"?"!==this.rightDelim)return this.rightDelim;let r=null!=(e=this.leftDelim)?e:".";return null!=(i=nD[r])?i:r}render(e){var i,r;let a=new oW({parent:e},this.style);this.body;let o=new oW({parent:e,mathstyle:"textstyle"},this.style),n=null!=(i=oG.createBox(a,this.body,{type:"inner"}))?i:new oE(null,{type:"inner"}),l=n.height/o.scalingFactor,s=n.depth/o.scalingFactor,c=[];if(this.leftDelim&&c.push(this.bind(o,nH("open",this.leftDelim,l,s,o,{isSelected:this.isSelected,classes:"ML__open"+(this.containsCaret?" ML__contains-caret":""),mode:this.mode,style:this.style}))),n&&(function e(i,r,a,o,n){if(i)for(let l=0;l<i.length;l++){let s=i[l];"middle"===s.type?(i[l]=r.bind(a,nH("inner",s.value,o,n,a,{isSelected:r.isSelected})),i[l].caret=s.caret,i[l].isSelected=s.isSelected,i[l].cssId=s.cssId,i[l].htmlData=s.htmlData,i[l].htmlStyle=s.htmlStyle,i[l].attributes=s.attributes,i[l].cssProperties=s.cssProperties):s.children&&e(s.children,r,a,o,n)}}(n.children,this,a,l,s),c.push(n)),this.rightDelim){let e=this.containsCaret?" ML__contains-caret":"",i=this.rightDelim;"?"===i&&(a.smartFence?(i=this.matchingRightDelim(),e+=" ML__smart-fence__close"):i="."),c.push(this.bind(o,nH("close",i,l,s,o,{isSelected:this.isSelected,classes:e+" ML__close",mode:this.mode,style:this.style})))}let d="mleft...mright"===this.variant,u=this.leftSibling;u&&(!d&&u.isFunction&&(d=!0),!d&&"subsup"===u.type&&null!=(r=u.leftSibling)&&r.isFunction&&(d=!0));let h=new oE(c,{type:d?"close":"inner",classes:"ML__left-right"});return h.setStyle("margin-top",`${-n.depth}em`),h.setStyle("height",`${n.height+n.depth}em`),this.caret&&(h.caret=this.caret),this.bind(a,h.wrap(a))}},lt=class e extends oG{constructor(e,i){var r;super({type:"macro",command:e,style:i.style}),this.body=i.body,void 0===i.captureSelection?i.args?this.captureSelection=!1:this.captureSelection=!0:this.captureSelection=i.captureSelection,this.macroArgs=i.args,this.expand=null!=(r=i.expand)&&r}static fromJson(i){return new e(i.command,i)}toJson(){let e=super.toJson();return this.expand&&(e.expand=!0),void 0!==this.captureSelection&&(e.captureSelection=this.captureSelection),this.macroArgs&&(e.args=this.macroArgs),e}_serialize(e){var i;return e.expandMacro&&this.expand?this.bodyToLatex(e):this.command+(null!=(i=this.macroArgs)?i:"")}applyStyle(e,i){let r={};e.color&&(r.color=e.color),e.backgroundColor&&(r.backgroundColor=e.backgroundColor),super.applyStyle(r,i)}render(e){let i=oG.createBox(e,this.body,{type:"lift"});return i?(this.caret&&(i.caret=this.caret),this.bind(e,i)):null}},li=class e extends oG{constructor(){super({type:"macro-argument"})}static fromJson(i){return new e}toJson(){return super.toJson()}_serialize(e){return""}render(e){return null}},lr=class e extends oG{constructor(e,i,r=!1,a,o){var n;super({type:"prompt",mode:null!=(n=null==o?void 0:o.mode)?n:"math",style:null==o?void 0:o.style,command:"\\placeholder"}),this.body=a,this.correctness=i,this.placeholderId=e,this.locked=r,this.captureSelection=this.locked}static fromJson(i){return new e(i.placeholderId,i.correctness,i.locked,i.body,i)}toJson(){let e=super.toJson();return this.placeholderId&&(e.placeholderId=this.placeholderId),this.body||delete e.body,this.body&&(e.body=this.body.filter(e=>"first"!==e.type).map(e=>e.toJson())),this.correctness&&(e.correctness=this.correctness),e.locked=this.locked,e}render(e){var i,r,a,o,n;let l=new oW({parent:e}),s=l.getRegisterAsEm("fboxsep"),c=oG.createBox(e,this.body);if(!c)return null;let d=!this.body||0===this.body.length||this.body.every(e=>"first"===e.type)?new nU({mode:this.mode,style:this.style}).render(new oW({parent:e,isPhantom:!0})):null,u=null!=(i=null==d?void 0:d.height)?i:l.metrics.xHeight,h=null!=(r=null==d?void 0:d.depth)?r:u/2,p=Math.max(null!=(a=c.height)?a:0,u),m=Math.max(null!=(o=c.depth)?o:0,h);c.setStyle("vertical-align",`calc(-${p}em + 2px)`),"correct"===this.correctness?c.setStyle("color","var(--correct-color, var(--ML__correct-color))"):"incorrect"===this.correctness&&c.setStyle("color","var(--incorrect-color, var(--ML__incorrect-color))");let f=p+m+2*s-2*s,g=new oE(c,{type:"ord"});g.setStyle("display","inline-block"),g.height=p,g.depth=m,g.setStyle("height",p+m,"em"),g.setStyle("vertical-align",-s,"em"),(null!=(n=c.width)?n:0)<f&&(g.width=f,g.setStyle("width",f,"em"));let b="ML__prompt ";this.locked?b+=" ML__lockedPromptBox ":b+=" ML__editablePromptBox ","correct"===this.correctness?b+=" ML__correctPromptBox ":"incorrect"===this.correctness&&(b+=" ML__incorrectPromptBox "),this.containsCaret&&(b+=" ML__focusedPromptBox ");let y=new oE(null,{classes:b,attributes:{part:"prompt"}});y.height=g.height+s,y.depth=g.depth+s,y.width=g.width+2*s,y.setStyle("position","absolute"),y.setStyle("height",g.height+g.depth+2*s,"em"),0===s&&y.setStyle("width","100%"),0!==s&&(y.setStyle("width",`calc(100% + ${2*s}em)`),y.setStyle("top",s,"em"),y.setStyle("left",-s,"em"));let v="";"incorrect"===this.correctness&&(v+='<line x1="3%" y1="97%" x2="97%" y2="3%" stroke-width="0.5" stroke="var(--incorrect-color, var(--ML__incorrect-color))" stroke-linecap="round" />'),v&&(y.svgOverlay=v);let x=new oE([y,g],{classes:"ML__prompt-atom"});g.setStyle("line-height",1),x.setStyle("position","relative"),x.setStyle("display","inline-block"),x.setStyle("line-height",0),x.height=p+s+.2,x.depth=m+s,x.left=s,x.right=s,x.setStyle("height",p+2*s,"em"),x.setStyle("top",m-p-s/2,"em"),x.setStyle("vertical-align",g.depth,"em"),x.setStyle("margin-left",.5,"em"),x.setStyle("margin-right",.5,"em"),this.caret&&(x.caret=this.caret);let _=this.attachSupsub(e,{base:x}),w=this.bind(l,_);return w&&this.id&&(y.atomID=this.id,g.atomID=this.id,x.atomID=this.id),w}_serialize(e){var i;let r=null!=(i=this.bodyToLatex(e))?i:"";if(e.skipPlaceholders)return r;let a="\\placeholder";return this.placeholderId&&(a+=`[${this.placeholderId}]`),"correct"===this.correctness?a+="[correct]":"incorrect"===this.correctness&&(a+="[incorrect]"),this.locked&&(a+="[locked]"),og(a,r)}},la=class e extends oG{constructor(e){super({type:"subsup",style:null==e?void 0:e.style}),this.subsupPlacement="auto"}get children(){if(!this._children){let e=[],i=this.branch("subscript");if(i)for(let r of i)e.push(...r.children),e.push(r);let r=this.branch("superscript");if(r)for(let i of r)e.push(...i.children),e.push(i);this._children=e}return this._children}static fromJson(i){let r=new e(i);for(let e of oU)i[e]&&r.setChildren(i[e],e);return r}render(e){var i;let r=new oW({parent:e,isPhantom:!0}),a=this.leftSibling,o=null!=(i=a.render(r))?i:new oE(null),n=new oE(null);return n.height=o.height,n.depth=o.depth,this.attachSupsub(e,{base:n,isCharacterBox:a.isCharacterBox(),type:"ignore"})}_serialize(e){return this.supsubToLatex(e)}};function lo(e){return!!e&&!/^(<$$>|<$>|<space>|<{>|<}>|#[0-9\?]|\\.+)$/.test(e)}var ln=class{constructor(e,i,r){var a,o,n,l;this.errors=[],this.index=0,this.endCount=0,this.localMacros={},null!=r||(r={}),this.tokens=e,this.context=i instanceof oW&&!(null!=r&&r.parseMode)&&!r.mathstyle?i:new oW({from:i,mathstyle:r.mathstyle},r.style),this.args=null!=(a=r.args)?a:void 0,this.smartFence=this.context.smartFence,this.parsingContext={parent:void 0,mathlist:[],style:null!=(o=r.style)?o:{},parseMode:null!=(n=r.parseMode)?n:"math",mathstyle:null!=(l=r.mathstyle)?l:"displaystyle",tabular:!1}}beginContext(e){var i,r,a,o,n,l;if(null!=e&&e.root){this.parsingContext={parent:this.parsingContext.parent,mathlist:[],style:{},parseMode:null!=(i=null==e?void 0:e.mode)?i:"math",mathstyle:null!=(r=null==e?void 0:e.mathstyle)?r:"displaystyle",tabular:null!=(a=null==e?void 0:e.tabular)&&a};return}let s=this.parsingContext,c={parent:s,mathlist:[],style:f({},s.style),parseMode:null!=(o=null==e?void 0:e.mode)?o:s.parseMode,mathstyle:null!=(n=null==e?void 0:e.mathstyle)?n:s.mathstyle,tabular:null!=(l=null==e?void 0:e.tabular)&&l};this.parsingContext=c}endContext(){this.parsingContext=this.parsingContext.parent}onError(e){this.errors.push(f({before:ob(this.tokens.slice(this.index,this.index+10)),after:ob(this.tokens.slice(Math.max(0,this.index-10),this.index))},e))}get mathlist(){return this.parsingContext.mathlist}set mathlist(e){this.parsingContext.mathlist=e}get parseMode(){return this.parsingContext.parseMode}set parseMode(e){this.parsingContext.parseMode=e}get tabularMode(){return this.parsingContext.tabular}get style(){let e=this.parsingContext;for(;e;){if(e.style)return f({},e.style);e=e.parent}return{}}set style(e){this.parsingContext.style=e}end(){return this.endCount++,this.index>=this.tokens.length||this.endCount>1e3}next(){this.index+=1}get(){return this.endCount=0,this.index<this.tokens.length?this.tokens[this.index++]:""}peek(){return this.tokens[this.index]}expandUnicode(){if(!this.peek()||"math"!==this.parseMode)return;let e=function(e){var i;if("{}<>[]$&*#^_%:'˜".includes(e)||e.length>1)return;let r=null!=(i=e.codePointAt(0))?i:0,a=Z[r];if(a)return a;let{char:o,variant:n,style:l}=function(e){var i;if((e<119808||e>120831)&&(e<8448||e>8527))return{char:String.fromCodePoint(e)};for(let r in Y)if(Y[r]===e){e=null!=(i=r.codePointAt(0))?i:0;break}for(let i of Q)if(e>=i.start&&e<i.start+i.len)return{char:String.fromCodePoint(e-i.start+i.offset),variant:i.variant,style:i.style};return{char:String.fromCodePoint(e)}}(r);if(!(!n&&!l)){switch(a=o,n){case"double-struck":a=`\\mathbb{${a}}`;break;case"fraktur":a=`\\mathfrak{${a}}`;break;case"script":a=`\\mathscr{${a}}`;break;case"sans-serif":a=`\\mathsf{${a}}`;break;case"monospace":a=`\\mathtt{${a}}`;break;case"calligraphic":a=`\\mathcal{${a}}`}switch(l){case"bold":a=`\\mathbf{${a}}`;break;case"italic":a=`\\mathit{${a}}`;break;case"bolditalic":a=`\\mathbfit{${a}}`}return a}}(this.peek());e&&this.tokens.splice(this.index,1,...om(e))}match(e){return this.tokens[this.index]===e&&(this.index++,!0)}lastSubsupAtom(){let e;return this.mathlist.length>0&&("subsup"===(e=this.mathlist[this.mathlist.length-1]).type||void 0!==e.subsupPlacement)||(e=new la({style:this.style}),this.mathlist.push(e)),e}hasPattern(e){return e.test(this.tokens[this.index])}hasInfixCommand(){var e;let{index:i}=this;if(i<this.tokens.length&&this.tokens[i].startsWith("\\")){let r=eM(this.tokens[i],this.parseMode);return!!r&&"symbol"!==r.definitionType&&(!r.ifMode||!!r.ifMode.includes(this.parseMode))&&null!=(e=r.infix)&&e}return!1}matchColumnSeparator(){return!!this.tabularMode&&"&"===this.peek()&&(this.index++,!0)}matchRowSeparator(){if(!this.tabularMode)return!1;let e=this.peek();return("\\\\"===e||"\\cr"===e||"\\tabularnewline"===e)&&(this.index++,!0)}placeholder(){var e;let i=null==(e=this.args)?void 0:e.call(this,"?");return i?ll(i,{parseMode:this.parseMode,mathstyle:"textstyle"}):[new nU({mode:this.parseMode,style:this.style})]}skipWhitespace(){for(;this.match("<space>"););}skipUntilToken(e){let i=this.tokens[this.index];for(;i&&i!==e;)i=this.tokens[++this.index];i===e&&this.index++}skipFiller(){for(;this.match("\\relax")||this.match("<space>"););}matchKeyword(e){let i=this.index,r=this.end(),a="";for(;!r;){let i=this.get();lo(i)?(a+=i,r=this.end()||a.length>=e.length):r=!0}let o=e.toUpperCase()===a.toUpperCase();return o||(this.index=i),o}scanString(){let e="";for(;!this.end();){let i=this.peek();if("]"===i)break;if("<space>"===i)e+=" ";else if(i.startsWith("\\"))this.onError({code:"unexpected-command-in-string"}),e+=i.substring(1);else if(lo(i))e+=i;else break;this.next()}return e}scanBalancedString(){let e="",i=this.end(),r=1;for(;!i;){let a=this.get();"<space>"===a?e+=" ":"<{>"===a?(e+="{",r+=1):"<}>"===a?(r-=1)>0?e+="}":this.index-=1:"<$>"===a?e+="$":"<$$>"===a?e+="$$":e+=a,i=0===r||this.end()}return e}scanLiteralGroup(){var e;if(!this.match("<{>"))return"";let i="",r=1;for(;r>0&&!this.end();){let a=this.get();"<}>"===a?(r-=1)>0&&(i+="}"):"<{>"===a?(r+=1,i+="{"):(/\\[a-zA-Z]+$/.test(i)&&/^[a-zA-Z]/.test(a)&&(i+=" "),i+=null!=(e=({"<space>":" ","<$$>":"$$","<$>":"$"})[a])?e:a)}return i}scanNumber(e=!0){var i,r;let a=!1,o=this.peek();for(;"<space>"===o||"+"===o||"-"===o;)this.get(),"-"===o&&(a=!a),o=this.peek();e=!!e;let n=10,l=/\d/;if(this.match("'"))n=8,l=/[0-7]/,e=!0;else if(this.match('"'))n=16,l=/[\dA-F]/,e=!0;else if(this.match("x"))n=16,l=/[\dA-Fa-f]/,e=!0;else if(this.match("`"))return(o=this.get())?2===o.length&&o.startsWith("\\")?{number:(a?-1:1)*(null!=(i=o.codePointAt(1))?i:0),base:"alpha"}:{number:(a?-1:1)*(null!=(r=o.codePointAt(0))?r:0),base:"alpha"}:null;let s="";for(;this.hasPattern(l);)s+=this.get();if(!e&&(this.match(".")||this.match(",")))for(s+=".";this.hasPattern(l);)s+=this.get();let c=e?Number.parseInt(s,n):Number.parseFloat(s);return Number.isNaN(c)?null:{number:a?-c:c,base:16===n?"hexadecimal":8===n?"octal":"decimal"}}scanRegister(){var e;let i=this.index,r=this.scanNumber(!1);if(this.skipWhitespace(),this.match("\\relax"))return r;let a=!1;if(null===r)for(;;){let e=this.peek();if("-"===e)a=!a;else if("+"!==e)break;this.next(),this.skipWhitespace()}if(this.match("\\global")){this.skipWhitespace();let e=this.get();return e.startsWith("\\")?r?{register:e,global:!0,factor:(a?-1:1)*r.number}:a?{register:e,global:!0,factor:-1}:{register:e,global:!0}:(this.index=i,null)}let o=this.get();return null!=o&&o.startsWith("\\")?(o=o.substring(1),this.context.registers[o]?a&&null===r?{register:o}:{register:o,factor:(a?-1:1)*(null!=(e=null==r?void 0:r.number)?e:1)}:(this.index=i,null)):(this.index=i,null)}scanValue(){let e=this.scanRegister();if(e)return e;let i=this.index,r=this.scanGlueOrDimen();if(r&&("unit"in r||"glue"in r&&"unit"in r.glue))return r;this.index=i;let a=this.scanNumber();if(a)return a;if(this.end()||!lo(this.peek()))return null;let o=this.scanString();return o.length>0?{string:o}:null}scanDimen(){let e,i=this.scanNumber(!1);if(null===i)return null;let r=i.number;return this.skipWhitespace(),this.matchKeyword("true"),this.skipWhitespace(),this.matchKeyword("pt")?e="pt":this.matchKeyword("mm")?e="mm":this.matchKeyword("cm")?e="cm":this.matchKeyword("ex")?e="ex":this.matchKeyword("px")?e="px":this.matchKeyword("em")?e="em":this.matchKeyword("bp")?e="bp":this.matchKeyword("dd")?e="dd":this.matchKeyword("pc")?e="pc":this.matchKeyword("in")?e="in":this.matchKeyword("mu")&&(e="mu"),e?{dimension:r,unit:e}:{dimension:r}}scanGlueOrDimen(){let e=this.scanDimen();if(null===e)return null;if(this.skipWhitespace(),this.match("\\relax"))return e;let i={glue:e};if(this.matchKeyword("plus")){let e=this.scanDimen();if(!e)return i;i.grow=e}if(this.skipWhitespace(),this.match("\\relax"))return i;if(this.skipWhitespace(),this.matchKeyword("minus")){let e=this.scanDimen();if(!e)return i;i.shrink=e}return i.grow||i.shrink?i:e}scanColspec(){this.skipWhitespace();let e=[];for(;!this.end()&&"<}>"!==this.peek()&&"]"!==this.peek();){let i=this.get();"c"===i||"r"===i||"l"===i?e.push({align:i}):"|"===i?e.push({separator:"solid"}):":"===i?e.push({separator:"dashed"}):"@"===i&&(this.match("<{>")&&(this.beginContext({mode:"math"}),e.push({gap:this.scan(e=>"<}>"===e)}),this.endContext()),this.match("<}>")||this.onError({code:"unbalanced-braces"}))}return e}scanModeSet(){let e;if(this.match("\\(")&&(e="textstyle"),!e&&this.match("\\[")&&(e="displaystyle"),!e)return null;this.beginContext({mode:"math",mathstyle:e});let i=this.scan(i=>i===("displaystyle"===e?"\\]":"\\)"));return this.match("displaystyle"===e?"\\]":"\\)")||this.onError({code:"unbalanced-mode-shift"}),this.endContext(),i}scanModeShift(){let e="";if(this.match("<$>")&&(e="<$>"),!e&&this.match("<$$>")&&(e="<$$>"),!e)return null;this.beginContext({mode:"math",mathstyle:"<$>"===e?"textstyle":"displaystyle"});let i=this.scan(i=>i===e);return this.match(e)||this.onError({code:"unbalanced-mode-shift"}),this.endContext(),i}scanEnvironment(){var e;if(!this.match("\\begin"))return null;let i=this.scanArgument("string");if(!i)return null;let r=null!=(e=el[i])?e:null;if(!r)return this.onError({code:"unknown-environment",arg:i}),null;let a=[];if(r.params)for(let e of r.params)if(e.isOptional)a.push(this.scanOptionalArgument(e.type));else{let r=this.scanArgument(e.type);r||this.onError({code:"missing-argument",arg:i}),a.push(r)}this.beginContext({tabular:r.tabular,root:r.rootOnly});let o=[],n=[],l=[this.scanRowRules()],s=[],c=!1;do if(this.end()&&(this.onError({code:"unbalanced-environment",arg:i}),c=!0),!c&&this.match("\\end")&&(this.scanArgument("string")!==i&&this.onError({code:"unbalanced-environment",arg:i}),c=!0),!c)if(this.matchColumnSeparator())s.push(this.mathlist),this.mathlist=[];else if(this.matchRowSeparator()){s.push(this.mathlist),this.mathlist=[];let e=null;this.skipWhitespace(),this.match("[")&&(e=this.scanDimen(),this.skipWhitespace(),this.match("]")),n.push(null!=e?e:{dimension:0}),o.push(s),s=[],l.push(this.scanRowRules())}else this.mathlist.push(...this.scan(e=>["<}>","&","\\end","\\cr","\\\\","\\tabularnewline"].includes(e)));while(!c)return s.push(this.mathlist),s.length>0&&o.push(s),this.endContext(),r.rootOnly&&(this.index=this.tokens.length),r.createAtom(i,o,n,a,this.context.maxMatrixCols,l.some(e=>e.length>0)?l:void 0)}scanRowRules(){var e;if(!this.tabularMode)return[];let i=[];for(this.skipWhitespace();!this.end();){if(this.match("\\hline"))i.push({style:"solid"});else if(this.match("\\hdashline"))i.push({style:"dashed"});else if(this.match("\\cline")){let r=(null!=(e=this.scanArgument("string"))?e:"").match(/^\s*(\d+)\s*(?:-\s*(\d+))?\s*$/);if(r){let e=Number.parseInt(r[1],10)-1,a=void 0===r[2]?e:Number.parseInt(r[2],10)-1;e>=0&&a>=e?i.push({style:"solid",from:e,to:a}):this.onError({code:"missing-argument",arg:"\\cline"})}else this.onError({code:"missing-argument",arg:"\\cline"})}else break;this.skipWhitespace()}return i}scanExpression(){let e=this.mathlist;if(this.mathlist=[],this.parseExpression()){let i=this.mathlist;return this.mathlist=e,i}return this.mathlist=e,null}scan(e){let i;this.beginContext(),e||(e=e=>"<}>"===e);let r="",a=null,o=[],n=null;for(;!this.end()&&!e(this.peek());)this.hasInfixCommand()&&!r?((a=eM(r=this.get(),"math"))&&(o=this.scanArguments(a)[1]),n=this.mathlist,this.mathlist=[]):this.parseExpression();return r?(o.unshift(this.mathlist),n&&o.unshift(n),i=[a.createAtom({command:r,args:o,style:this.style,mode:this.parseMode})]):i=this.mathlist,this.endContext(),i}scanGroup(){let e=this.index;if(!this.match("<{>"))return null;let i=this.scan(e=>"<}>"===e);if(this.match("<}>")||this.onError({code:"unbalanced-braces"}),1===i.length&&"placeholder"===i[0].type)return i[0];let r=new n9(i,this.parseMode);return r.verbatimLatex=ob(this.tokens.slice(e,this.index)),r}scanSmartFence(){if(this.skipWhitespace(),!this.match("("))return null;this.beginContext();let e=1;for(;!this.end()&&0!==e;)this.match("(")&&(e+=1),this.match(")")&&(e-=1),0!==e&&this.parseExpression();let i=new le("",this.mathlist,{leftDelim:"(",rightDelim:0===e?")":"?"});return this.endContext(),i}scanDelim(){this.skipWhitespace();let e=this.peek();if(!e)return this.onError({code:"unexpected-end-of-string"}),null;if(!lo(e)&&!e.startsWith("\\"))return null;this.next();let i=eM(e,"math");return i?"function"===i.definitionType&&i.ifMode&&!i.ifMode.includes(this.parseMode)?(this.onError({code:"unexpected-delimiter",arg:e}),null):"symbol"===i.definitionType&&("mopen"===i.type||"mclose"===i.type)||/^(\.|\?|\||<|>|\\vert|\\Vert|\\\||\\surd|\\uparrow|\\downarrow|\\Uparrow|\\Downarrow|\\updownarrow|\\Updownarrow|\\mid|\\mvert|\\mVert)$/.test(e)?e:(this.onError({code:"unexpected-delimiter",arg:e}),null):(this.onError({code:"unknown-command",arg:e}),null)}scanLeftRight(){var e;if(this.match("\\right"))return this.onError({code:"unbalanced-braces"}),new n7("\\right");if(this.match("\\mright"))return this.onError({code:"unbalanced-braces"}),new n7("\\mright");let i="\\right";if(!this.match("\\left")){if(!this.match("\\mleft"))return null;i="\\mright"}let r=this.scanDelim();if(!r)return this.onError({code:"unexpected-delimiter"}),new n7("\\right"===i?"\\left":"\\mleft");for(this.beginContext();!this.end()&&!this.match(i);)this.parseExpression();let a=this.mathlist;return this.endContext(),new le("\\right"===i?"left...right":"mleft...mright",a,{leftDelim:r,rightDelim:null!=(e=this.scanDelim())?e:".",style:this.style})}parseSupSub(){if("math"!==this.parseMode)return!1;let e=this.peek();if("^"!==e&&"_"!==e&&"'"!==e)return!1;let i=this.lastSubsupAtom();for(;"^"===e||"_"===e||"'"===e;)this.match("'")?this.match("'")?i.addChild(new oG({type:"mord",command:"\\doubleprime",mode:"math",value:"′′"}),"superscript"):i.addChild(new oG({type:"mord",command:"\\prime",mode:"math",value:"′"}),"superscript"):(this.match("^")||this.match("_"))&&i.addChildren(et(this.scanArgument("expression")),"_"===e?"subscript":"superscript"),e=this.peek();return!0}parseLimits(){if("math"!==this.parseMode)return!1;let e=this.match("\\limits"),i=!e&&this.match("\\nolimits"),r=!i&&!e&&this.match("\\displaylimits");if(!e&&!i&&!r)return!1;let a=this.mathlist.length>0?this.mathlist[this.mathlist.length-1]:null;return null!==a&&(a.explicitSubsupPlacement=!0,e&&(a.subsupPlacement="over-under"),i&&(a.subsupPlacement="adjacent"),r&&(a.subsupPlacement="auto"),!0)}scanArguments(e){if(!(null!=e&&e.params))return[void 0,[]];let i,r=[],a=2*!!e.infix;for(;a<e.params.length;){let o=e.params[a];"rest"===o.type?r.push(this.scan(e=>["<}>","&","\\end","\\cr","\\\\","\\tabularnewline","\\right"].includes(e))):o.isOptional?r.push(this.scanOptionalArgument(o.type)):o.type.endsWith("*")?i=o.type.slice(0,-1):r.push(this.scanArgument(o.type)),a+=1}return[i,r]}scanSymbolOrLiteral(){let e,i=this.peek();if(!i)return null;if(this.next(),lo(i)){let e=ov.createAtom(this.parseMode,i,f({},this.style));return e?[e]:null}if(e=this.scanMacro(i))return[e];if(i.startsWith("\\")){let r=eM(i,this.parseMode);if(!r)return this.onError({code:"unknown-command",arg:i}),[new n7(i)];if("symbol"===r.definitionType){let a=f({},this.style);r.variant&&(a.variant=r.variant),e=new oG({type:r.type,command:i,style:a,value:String.fromCodePoint(r.codepoint),mode:this.parseMode,verbatimLatex:i})}else{if(r.applyMode||r.applyStyle||r.infix)return this.onError({code:"invalid-command",arg:i}),[new n7(i)];r.createAtom&&(e=r.createAtom({command:i,args:[],style:this.style,mode:this.parseMode}))}}return e?[e]:null}scanArgument(e){var i;this.skipFiller();let r=this.parseMode;if("auto"===e&&(e=r),!this.match("<{>")){if("string"===e)return this.scanString();if("value"===e)return this.scanValue();if("delim"===e)return null!=(i=this.scanDelim())?i:".";if("expression"===e)return this.scanExpression();if("math"===e){e!==r&&this.beginContext({mode:"math"});let i=this.scanSymbolOrLiteral();return e!==r&&this.endContext(),i}if("text"===e){e!==r&&this.beginContext({mode:"text"});let i=this.scanSymbolOrLiteral();return e!==r&&this.endContext(),i}return"balanced-string"===e?null:"rest"===e?this.scan(e=>["<}>","&","\\end","\\cr","\\\\","\\tabularnewline","\\right"].includes(e)):null}if("text"===e){this.beginContext({mode:"text"});do this.mathlist.push(...this.scan());while(!this.match("<}>")&&!this.end())let e=this.mathlist;return this.endContext(),{group:e}}if("math"===e){this.beginContext({mode:"math"});do this.mathlist.push(...this.scan());while(!this.match("<}>")&&!this.end())let e=this.mathlist;return this.endContext(),{group:e}}if("rest"===e){let e=this.scan();return this.match("<}>")||this.onError({code:"unbalanced-braces"}),{group:e}}let a=null;if("expression"===e){this.beginContext({mode:"math"});do this.mathlist.push(...this.scan());while(!this.match("<}>")&&!this.end())let e=this.mathlist;return this.endContext(),{group:e}}return"string"===e?a=this.scanString():"balanced-string"===e?a=this.scanBalancedString():"colspec"===e?a=this.scanColspec():"value"===e&&(a=this.scanValue()),this.skipUntilToken("<}>"),a}scanOptionalArgument(e){if(e="auto"===e?this.parseMode:e,this.skipFiller(),!this.match("["))return null;let i=null;for(;!this.end()&&!this.match("]");)if("string"===e)i=this.scanString();else if("value"===e)i=this.scanValue();else if("colspec"===e)i=this.scanColspec();else if("bbox"===e){let e={};for(let i of this.scanString().toLowerCase().trim().split(/,(?![^(]*\)(?:(?:[^(]*\)){2})*[^"]*$)/)){let r=i.match(/^\s*([\d.]+)\s*([a-z]{2})/);if(r)e.padding={dimension:Number.parseFloat(r[1]),unit:r[2]};else{let r=i.match(/^\s*border\s*:\s*(.*)/);r?e.border=r[1]:e.backgroundcolor={string:i}}}i=e}else"math"===e&&(this.beginContext({mode:"math"}),i=this.mathlist.concat(this.scan(e=>"]"===e)),this.endContext());return i}scanSymbolOrCommand(e){var i,r,a;if("\\placeholder"===e){let e=this.scanOptionalArgument("string"),i=this.scanOptionalArgument("math"),r=oG.serialize(i,{defaultMode:"math"}),a=[],o;o||"correct"!==r?o||"incorrect"!==r?""!==r&&(a=i):o="incorrect":o="correct";let n="locked"===this.scanOptionalArgument("string"),l=this.scanArgument("auto"),s;return s=l&&Array.isArray(l)&&l.length>0?l:l&&"object"==typeof l&&"group"in l?l.group:a,e?[new lr(e,o,n,null!=s?s:a,{mode:this.parseMode,style:this.style})]:[new nU({mode:this.parseMode,style:this.style})]}if("\\renewcommand"===e||"\\newcommand"===e||"\\providecommand"===e||"\\def"===e){let i=this.index,r=this.scanLiteralGroup()||this.next();if(!r)return null;if(this.context.registers[r.substring(1)]){let a=this.scanArgument("string");return null!==a&&(this.context.registers[r.substring(1)]=a),[new oG({type:"text",value:"",verbatimLatex:of([e,ob(this.tokens.slice(i,this.index))])})]}}let o=this.scanMacro(e);if(o)return[o];let n=eM(e,this.parseMode);if(!n)return"text"===this.parseMode?(/[a-zA-Z]/.test(null!=(i=this.peek())?i:"")&&(e+=" "),[...e].map(e=>new oG({type:"text",value:e,mode:"text",style:this.style}))):(this.onError({code:"unknown-command",arg:e}),[new n7(e)]);let l=this.index;if("symbol"===n.definitionType){let i=f({},this.style);n.variant&&(i.variant=n.variant),o=new oG({type:n.type,command:e,style:i,value:String.fromCodePoint(n.codepoint),mode:this.parseMode})}else{if(n.ifMode&&!n.ifMode.includes(this.parseMode))return[];let i=this.parseMode;n.applyMode&&(this.parseMode=n.applyMode);let l,s=[];if(n.parse?s=n.parse(this):[l,s]=this.scanArguments(n),this.parseMode=i,n.applyMode&&!n.applyStyle&&!n.createAtom)return et(s[0]);if(n.infix)return this.onError({code:"too-many-infix-commands",arg:e}),null;if("function"==typeof n.createAtom)o=n.createAtom({command:e,args:s,style:this.style,mode:this.parseMode}),l&&(o.body=et(this.scanArgument(l)));else if("function"==typeof n.applyStyle){let i=n.applyStyle(this.style,e,s,this.context),r=this.parseMode;if(n.applyMode&&(this.parseMode=n.applyMode),l){let e=this.style;this.style=i;let a=this.scanArgument(l);return this.style=e,this.parseMode=r,et(a)}this.style=i}else o=new oG({type:"mord",command:null!=(r=n.command)?r:e,style:f({},this.style),value:e,mode:null!=(a=n.applyMode)?a:this.parseMode})}if(!o)return null;if(o instanceof oG&&void 0===o.verbatimLatex&&!/^\\(llap|rlap|class|cssId|htmlData)$/.test(e)){let i=of([e,ob(this.tokens.slice(l,this.index))]);i&&(o.verbatimLatex=i)}if(null===o.verbatimLatex&&(o.verbatimLatex=void 0),o.isFunction&&this.smartFence){let e=this.scanSmartFence();if(e)return[o,e]}return[o]}scanSymbolCommandOrLiteral(){this.expandUnicode();let e=this.get();if(!e)return null;if(lo(e)){let i=ov.createAtom(this.parseMode,e,f({},this.style));if(!i)return null;if(i.isFunction&&this.smartFence){let e=this.scanSmartFence();if(e)return[i,e]}return[i]}return e.startsWith("\\")?this.scanSymbolOrCommand(e):"<space>"===e?"text"===this.parseMode?[new oY(" "," ",this.style)]:null:("<}>"===e?this.onError({latex:"",code:"unbalanced-braces"}):this.onError({latex:"",code:"unexpected-token",arg:e}),null)}defineLocalMacro(e,i){let r=e.startsWith("\\")?e.slice(1):e;r&&(this.localMacros[r]=i)}scanMacro(e){var i;let r=e.startsWith("\\")?this.localMacros[e.slice(1)]:void 0,a=null!=r?r:this.context.getMacro(e);if(!a)return null;let o=this.index,n=a.args,l={"?":null==(i=this.args)?void 0:i.call(this,"?")};for(let e=1;e<=n;e++){let i=this.scanLiteralGroup();if(!i){let e=this.index;this.scanExpression(),i=ob(this.tokens.slice(e,this.index))}l[e]=i}return new lt(e,{expand:a.expand,captureSelection:a.captureSelection,args:o===this.index?null:ob(this.tokens.slice(o,this.index)),style:this.parsingContext.style,body:ll(a.def,{context:this.context,parseMode:this.parseMode,args:e=>l[e],mathstyle:this.parsingContext.mathstyle,style:this.parsingContext.style})})}parseExpression(){var e,i,r,a;let o=null!=(a=null!=(r=null!=(i=null!=(e=this.scanEnvironment())?e:this.scanModeShift())?i:this.scanModeSet())?r:this.scanGroup())?a:this.scanLeftRight();if(null===o){if(this.parseSupSub()||this.parseLimits())return!0;o=this.scanSymbolCommandOrLiteral()}return!!o&&(R(o)?this.mathlist.push(...o):this.mathlist.push(o),!0)}};function ll(e,i){var r,a,o,n;let l=null!=(r=null==i?void 0:i.args)?r:void 0,s=new ln(om(e,l),null==i?void 0:i.context,{args:l,mathstyle:null!=(a=null==i?void 0:i.mathstyle)?a:"displaystyle",parseMode:null!=(o=null==i?void 0:i.parseMode)?o:"math",style:null!=(n=null==i?void 0:i.style)?n:{}}),c=[];for(;!s.end();)c.push(...s.scan(()=>!1));return c}function ls(e,i){var r;let a=new ln(om(e,null),null==i?void 0:i.context,{mathstyle:"displaystyle",parseMode:null!=(r=null==i?void 0:i.parseMode)?r:"math"});for(;!a.end();)a.scan();return a.errors}var lc=class e extends oG{constructor(e,i){super({type:"chem"},{command:e,mode:"math"});let r=lu.go(ld.go(i,"\\pu"===e?"pu":"ce"),!1);this.body=ll(r),this._verbatimLatex=e+"{"+i+"}",this.arg=i,this.captureSelection=!0}static fromJson(i){return new e(i.command,i.arg)}set verbatimLatex(e){}get verbatimLatex(){return this._verbatimLatex}toJson(){return g(f({},super.toJson()),{arg:this.arg})}render(e){let i=oG.createBox(e,this.body,{type:"inner"});return this.caret&&(i.caret=this.caret),this.bind(e,i)}_serialize(e){return this.verbatimLatex,this.verbatimLatex}};ex(["ce","pu"],"{chemformula:balanced-string}",{createAtom:e=>{var i;return new lc(e.command,null!=(i=e.args[0])?i:"")}});var ld={go:function(e,i){if(!e)return[];void 0===i&&(i="ce");var r="0",a={};a.parenthesisLevel=0,e=(e=(e=e.replace(/\n/g," ")).replace(/[\u2212\u2013\u2014\u2010]/g,"-")).replace(/[\u2026]/g,"...");for(var o,n=10,l=[];;){o!==e?(n=10,o=e):n--;for(var s=ld.stateMachines[i],c=s.transitions[r]||s.transitions["*"],d=0;d<c.length;d++){var u=ld.patterns.match_(c[d].pattern,e);if(u){for(var h,p=c[d].task,m=0;m<p.action_.length;m++){if(s.actions[p.action_[m].type_])h=s.actions[p.action_[m].type_](a,u.match_,p.action_[m].option);else if(ld.actions[p.action_[m].type_])h=ld.actions[p.action_[m].type_](a,u.match_,p.action_[m].option);else throw["MhchemBugA","mhchem bug A. Please report. ("+p.action_[m].type_+")"];ld.concatArray(l,h)}if(r=p.nextState||r,!(e.length>0))return l;if(p.revisit||(e=u.remainder),!p.toContinue)break}}if(n<=0)throw["MhchemBugU","mhchem bug U. Please report."]}},concatArray:function(e,i){if(i)if("[object Array]"===Object.prototype.toString.call(i))for(var r=0;r<i.length;r++)e.push(i[r]);else e.push(i)},patterns:{patterns:{empty:/^$/,else:/^./,else2:/^./,space:/^\s/,"space A":/^\s(?=[A-Z\\$])/,space$:/^\s$/,"a-z":/^[a-z]/,x:/^x/,x$:/^x$/,i$:/^i$/,letters:/^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/,"\\greek":/^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/,"one lowercase latin letter $":/^(?:([a-z])(?:$|[^a-zA-Z]))$/,"$one lowercase latin letter$ $":/^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/,"one lowercase greek letter $":/^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/,digits:/^[0-9]+/,"-9.,9":/^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/,"-9.,9 no missing 0":/^[+\-]?[0-9]+(?:[.,][0-9]+)?/,"(-)(9.,9)(e)(99)":function(e){var i=e.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:(?:([eE])|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/);return i&&i[0]?{match_:i.slice(1),remainder:e.substr(i[0].length)}:null},"(-)(9)^(-9)":function(e){var i=e.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/);return i&&i[0]?{match_:i.slice(1),remainder:e.substr(i[0].length)}:null},"state of aggregation $":function(e){var i=ld.patterns.findObserveGroups(e,"",/^\([a-z]{1,3}(?=[\),])/,")","");if(i&&i.remainder.match(/^($|[\s,;\)\]\}])/))return i;var r=e.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/);return r?{match_:r[0],remainder:e.substr(r[0].length)}:null},"_{(state of aggregation)}$":/^_\{(\([a-z]{1,3}\))\}/,"{[(":/^(?:\\\{|\[|\()/,")]}":/^(?:\)|\]|\\\})/,", ":/^[,;]\s*/,",":/^[,;]/,".":/^[.]/,". ":/^([.\u22C5\u00B7\u2022])\s*/,"...":/^\.\.\.(?=$|[^.])/,"* ":/^([*])\s*/,"^{(...)}":function(e){return ld.patterns.findObserveGroups(e,"^{","","","}")},"^($...$)":function(e){return ld.patterns.findObserveGroups(e,"^","$","$","")},"^a":/^\^([0-9]+|[^\\_])/,"^\\x{}{}":function(e){return ld.patterns.findObserveGroups(e,"^",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"^\\x{}":function(e){return ld.patterns.findObserveGroups(e,"^",/^\\[a-zA-Z]+\{/,"}","")},"^\\x":/^\^(\\[a-zA-Z]+)\s*/,"^(-1)":/^\^(-?\d+)/,"'":/^'/,"_{(...)}":function(e){return ld.patterns.findObserveGroups(e,"_{","","","}")},"_($...$)":function(e){return ld.patterns.findObserveGroups(e,"_","$","$","")},_9:/^_([+\-]?[0-9]+|[^\\])/,"_\\x{}{}":function(e){return ld.patterns.findObserveGroups(e,"_",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"_\\x{}":function(e){return ld.patterns.findObserveGroups(e,"_",/^\\[a-zA-Z]+\{/,"}","")},"_\\x":/^_(\\[a-zA-Z]+)\s*/,"^_":/^(?:\^(?=_)|\_(?=\^)|[\^_]$)/,"{}":/^\{\}/,"{...}":function(e){return ld.patterns.findObserveGroups(e,"","{","}","")},"{(...)}":function(e){return ld.patterns.findObserveGroups(e,"{","","","}")},"$...$":function(e){return ld.patterns.findObserveGroups(e,"","$","$","")},"${(...)}$":function(e){return ld.patterns.findObserveGroups(e,"${","","","}$")},"$(...)$":function(e){return ld.patterns.findObserveGroups(e,"$","","","$")},"=<>":/^[=<>]/,"#":/^[#\u2261]/,"+":/^\+/,"-$":/^-(?=[\s_},;\]/]|$|\([a-z]+\))/,"-9":/^-(?=[0-9])/,"- orbital overlap":/^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/,"-":/^-/,"pm-operator":/^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,operator:/^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,arrowUpDown:/^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,"\\bond{(...)}":function(e){return ld.patterns.findObserveGroups(e,"\\bond{","","","}")},"->":/^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,CMT:/^[CMT](?=\[)/,"[(...)]":function(e){return ld.patterns.findObserveGroups(e,"[","","","]")},"1st-level escape":/^(&|\\\\|\\hline)\s*/,"\\,":/^(?:\\[,\ ;:])/,"\\x{}{}":function(e){return ld.patterns.findObserveGroups(e,"",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"\\x{}":function(e){return ld.patterns.findObserveGroups(e,"",/^\\[a-zA-Z]+\{/,"}","")},"\\ca":/^\\ca(?:\s+|(?![a-zA-Z]))/,"\\x":/^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/,orbital:/^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,others:/^[\/~|]/,"\\frac{(...)}":function(e){return ld.patterns.findObserveGroups(e,"\\frac{","","","}","{","","","}")},"\\overset{(...)}":function(e){return ld.patterns.findObserveGroups(e,"\\overset{","","","}","{","","","}")},"\\underset{(...)}":function(e){return ld.patterns.findObserveGroups(e,"\\underset{","","","}","{","","","}")},"\\underbrace{(...)}":function(e){return ld.patterns.findObserveGroups(e,"\\underbrace{","","","}_","{","","","}")},"\\color{(...)}0":function(e){return ld.patterns.findObserveGroups(e,"\\color{","","","}")},"\\color{(...)}{(...)}1":function(e){return ld.patterns.findObserveGroups(e,"\\color{","","","}","{","","","}")},"\\color(...){(...)}2":function(e){return ld.patterns.findObserveGroups(e,"\\color","\\","",/^(?=\{)/,"{","","","}")},"\\ce{(...)}":function(e){return ld.patterns.findObserveGroups(e,"\\ce{","","","}")},oxidation$:/^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"d-oxidation$":/^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"roman numeral":/^[IVX]+/,"1/2$":/^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,amount:function(e){if(i=e.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/))return{match_:i[0],remainder:e.substr(i[0].length)};var i,r=ld.patterns.findObserveGroups(e,"","$","$","");return r&&(i=r.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/))?{match_:i[0],remainder:e.substr(i[0].length)}:null},amount2:function(e){return this.amount(e)},"(KV letters),":/^(?:[A-Z][a-z]{0,2}|i)(?=,)/,formula$:function(e){if(e.match(/^\([a-z]+\)$/))return null;var i=e.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/);return i?{match_:i[0],remainder:e.substr(i[0].length)}:null},uprightEntities:/^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/,"/":/^\s*(\/)\s*/,"//":/^\s*(\/\/)\s*/,"*":/^\s*[*.]\s*/},findObserveGroups:function(e,i,r,a,o,n,l,s,c,d){var u=function(e,i){if("string"==typeof i)return 0!==e.indexOf(i)?null:i;var r=e.match(i);return r?r[0]:null},h=u(e,i);if(null===h||null===(h=u(e=e.substr(h.length),r)))return null;var p=function(e,i,r){for(var a=0;i<e.length;){var o=e.charAt(i),n=u(e.substr(i),r);if(null!==n&&0===a)return{endMatchBegin:i,endMatchEnd:i+n.length};if("{"===o)a++;else if("}"===o){if(0===a)throw["ExtraCloseMissingOpen","Extra close brace or missing open brace"];a--}i++}return null}(e,h.length,a||o);if(null===p)return null;var m=e.substring(0,a?p.endMatchEnd:p.endMatchBegin);if(!n&&!l)return{match_:m,remainder:e.substr(p.endMatchEnd)};var f=this.findObserveGroups(e.substr(p.endMatchEnd),n,l,s,c);if(null===f)return null;var g=[m,f.match_];return{match_:d?g.join(""):g,remainder:f.remainder}},match_:function(e,i){var r=ld.patterns.patterns[e];if(void 0===r)throw["MhchemBugP","mhchem bug P. Please report. ("+e+")"];if("function"==typeof r)return ld.patterns.patterns[e](i);var a=i.match(r);return a?{match_:a[2]?[a[1],a[2]]:a[1]?a[1]:a[0],remainder:i.substr(a[0].length)}:null}},actions:{"a=":function(e,i){e.a=(e.a||"")+i},"b=":function(e,i){e.b=(e.b||"")+i},"p=":function(e,i){e.p=(e.p||"")+i},"o=":function(e,i){e.o=(e.o||"")+i},"q=":function(e,i){e.q=(e.q||"")+i},"d=":function(e,i){e.d=(e.d||"")+i},"rm=":function(e,i){e.rm=(e.rm||"")+i},"text=":function(e,i){e.text_=(e.text_||"")+i},insert:function(e,i,r){return{type_:r}},"insert+p1":function(e,i,r){return{type_:r,p1:i}},"insert+p1+p2":function(e,i,r){return{type_:r,p1:i[0],p2:i[1]}},copy:function(e,i){return i},rm:function(e,i){return{type_:"rm",p1:i||""}},text:function(e,i){return ld.go(i,"text")},"{text}":function(e,i){var r=["{"];return ld.concatArray(r,ld.go(i,"text")),r.push("}"),r},"tex-math":function(e,i){return ld.go(i,"tex-math")},"tex-math tight":function(e,i){return ld.go(i,"tex-math tight")},bond:function(e,i,r){return{type_:"bond",kind_:r||i}},"color0-output":function(e,i){return{type_:"color0",color:i[0]}},ce:function(e,i){return ld.go(i)},"1/2":function(e,i){var r=[];i.match(/^[+\-]/)&&(r.push(i.substr(0,1)),i=i.substr(1));var a=i.match(/^([0-9]+|\$[a-z]\$|[a-z])\/([0-9]+)(\$[a-z]\$|[a-z])?$/);return a[1]=a[1].replace(/\$/g,""),r.push({type_:"frac",p1:a[1],p2:a[2]}),a[3]&&(a[3]=a[3].replace(/\$/g,""),r.push({type_:"tex-math",p1:a[3]})),r},"9,9":function(e,i){return ld.go(i,"9,9")}},createTransitions:function(e){var i,r,a,o,n={};for(i in e)for(r in e[i])for(a=r.split("|"),e[i][r].stateArray=a,o=0;o<a.length;o++)n[a[o]]=[];for(i in e)for(r in e[i])for(a=e[i][r].stateArray||[],o=0;o<a.length;o++){var l=e[i][r];if(l.action_){l.action_=[].concat(l.action_);for(var s=0;s<l.action_.length;s++)"string"==typeof l.action_[s]&&(l.action_[s]={type_:l.action_[s]})}else l.action_=[];for(var c=i.split("|"),d=0;d<c.length;d++)if("*"===a[o])for(var u in n)n[u].push({pattern:c[d],task:l});else n[a[o]].push({pattern:c[d],task:l})}return n},stateMachines:{}};ld.stateMachines={ce:{transitions:ld.createTransitions({empty:{"*":{action_:"output"}},else:{"0|1|2":{action_:"beginsWithBond=false",revisit:!0,toContinue:!0}},oxidation$:{0:{action_:"oxidation-output"}},CMT:{r:{action_:"rdt=",nextState:"rt"},rd:{action_:"rqt=",nextState:"rdt"}},arrowUpDown:{"0|1|2|as":{action_:["sb=false","output","operator"],nextState:"1"}},uprightEntities:{"0|1|2":{action_:["o=","output"],nextState:"1"}},orbital:{"0|1|2|3":{action_:"o=",nextState:"o"}},"->":{"0|1|2|3":{action_:"r=",nextState:"r"},"a|as":{action_:["output","r="],nextState:"r"},"*":{action_:["output","r="],nextState:"r"}},"+":{o:{action_:"d= kv",nextState:"d"},"d|D":{action_:"d=",nextState:"d"},q:{action_:"d=",nextState:"qd"},"qd|qD":{action_:"d=",nextState:"qd"},dq:{action_:["output","d="],nextState:"d"},3:{action_:["sb=false","output","operator"],nextState:"0"}},amount:{"0|2":{action_:"a=",nextState:"a"}},"pm-operator":{"0|1|2|a|as":{action_:["sb=false","output",{type_:"operator",option:"\\pm"}],nextState:"0"}},operator:{"0|1|2|a|as":{action_:["sb=false","output","operator"],nextState:"0"}},"-$":{"o|q":{action_:["charge or bond","output"],nextState:"qd"},d:{action_:"d=",nextState:"d"},D:{action_:["output",{type_:"bond",option:"-"}],nextState:"3"},q:{action_:"d=",nextState:"qd"},qd:{action_:"d=",nextState:"qd"},"qD|dq":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},"-9":{"3|o":{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"3"}},"- orbital overlap":{o:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},d:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"}},"-":{"0|1|2":{action_:[{type_:"output",option:1},"beginsWithBond=true",{type_:"bond",option:"-"}],nextState:"3"},3:{action_:{type_:"bond",option:"-"}},a:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},as:{action_:[{type_:"output",option:2},{type_:"bond",option:"-"}],nextState:"3"},b:{action_:"b="},o:{action_:{type_:"- after o/d",option:!1},nextState:"2"},q:{action_:{type_:"- after o/d",option:!1},nextState:"2"},"d|qd|dq":{action_:{type_:"- after o/d",option:!0},nextState:"2"},"D|qD|p":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},amount2:{"1|3":{action_:"a=",nextState:"a"}},letters:{"0|1|2|3|a|as|b|p|bp|o":{action_:"o=",nextState:"o"},"q|dq":{action_:["output","o="],nextState:"o"},"d|D|qd|qD":{action_:"o after d",nextState:"o"}},digits:{o:{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},q:{action_:["output","o="],nextState:"o"},a:{action_:"o=",nextState:"o"}},"space A":{"b|p|bp":{}},space:{a:{nextState:"as"},0:{action_:"sb=false"},"1|2":{action_:"sb=true"},"r|rt|rd|rdt|rdq":{action_:"output",nextState:"0"},"*":{action_:["output","sb=true"],nextState:"1"}},"1st-level escape":{"1|2":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}]},"*":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}],nextState:"0"}},"[(...)]":{"r|rt":{action_:"rd=",nextState:"rd"},"rd|rdt":{action_:"rq=",nextState:"rdq"}},"...":{"o|d|D|dq|qd|qD":{action_:["output",{type_:"bond",option:"..."}],nextState:"3"},"*":{action_:[{type_:"output",option:1},{type_:"insert",option:"ellipsis"}],nextState:"1"}},". |* ":{"*":{action_:["output",{type_:"insert",option:"addition compound"}],nextState:"1"}},"state of aggregation $":{"*":{action_:["output","state of aggregation"],nextState:"1"}},"{[(":{"a|as|o":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"0|1|2|3":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"*":{action_:["output","o=","output","parenthesisLevel++"],nextState:"2"}},")]}":{"0|1|2|3|b|p|bp|o":{action_:["o=","parenthesisLevel--"],nextState:"o"},"a|as|d|D|q|qd|qD|dq":{action_:["output","o=","parenthesisLevel--"],nextState:"o"}},", ":{"*":{action_:["output","comma"],nextState:"0"}},"^_":{"*":{}},"^{(...)}|^($...$)":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"D"},q:{action_:"d=",nextState:"qD"},"d|D|qd|qD|dq":{action_:["output","d="],nextState:"D"}},"^a|^\\x{}{}|^\\x{}|^\\x|'":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"d"},q:{action_:"d=",nextState:"qd"},"d|qd|D|qD":{action_:"d="},dq:{action_:["output","d="],nextState:"d"}},"_{(state of aggregation)}$":{"d|D|q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x":{"0|1|2|as":{action_:"p=",nextState:"p"},b:{action_:"p=",nextState:"bp"},"3|o":{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},"q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"=<>":{"0|1|2|3|a|as|o|q|d|D|qd|qD|dq":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"#":{"0|1|2|3|a|as|o":{action_:[{type_:"output",option:2},{type_:"bond",option:"#"}],nextState:"3"}},"{}":{"*":{action_:{type_:"output",option:1},nextState:"1"}},"{...}":{"0|1|2|3|a|as|b|p|bp":{action_:"o=",nextState:"o"},"o|d|D|q|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"$...$":{a:{action_:"a="},"0|1|2|3|as|b|p|bp|o":{action_:"o=",nextState:"o"},"as|o":{action_:"o="},"q|d|D|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"\\bond{(...)}":{"*":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"\\frac{(...)}":{"*":{action_:[{type_:"output",option:1},"frac-output"],nextState:"3"}},"\\overset{(...)}":{"*":{action_:[{type_:"output",option:2},"overset-output"],nextState:"3"}},"\\underset{(...)}":{"*":{action_:[{type_:"output",option:2},"underset-output"],nextState:"3"}},"\\underbrace{(...)}":{"*":{action_:[{type_:"output",option:2},"underbrace-output"],nextState:"3"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:[{type_:"output",option:2},"color-output"],nextState:"3"}},"\\color{(...)}0":{"*":{action_:[{type_:"output",option:2},"color0-output"]}},"\\ce{(...)}":{"*":{action_:[{type_:"output",option:2},"ce"],nextState:"3"}},"\\,":{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"1"}},"\\x{}{}|\\x{}|\\x":{"0|1|2|3|a|as|b|p|bp|o|c0":{action_:["o=","output"],nextState:"3"},"*":{action_:["output","o=","output"],nextState:"3"}},others:{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"3"}},else2:{a:{action_:"a to o",nextState:"o",revisit:!0},as:{action_:["output","sb=true"],nextState:"1",revisit:!0},"r|rt|rd|rdt|rdq":{action_:["output"],nextState:"0",revisit:!0},"*":{action_:["output","copy"],nextState:"3"}}}),actions:{"o after d":function(e,i){var r;if((e.d||"").match(/^[0-9]+$/)){var a=e.d;e.d=void 0,r=this.output(e),e.b=a}else r=this.output(e);return ld.actions["o="](e,i),r},"d= kv":function(e,i){e.d=i,e.dType="kv"},"charge or bond":function(e,i){if(e.beginsWithBond){var r=[];return ld.concatArray(r,this.output(e)),ld.concatArray(r,ld.actions.bond(e,i,"-")),r}e.d=i},"- after o/d":function(e,i,r){var a=ld.patterns.match_("orbital",e.o||""),o=ld.patterns.match_("one lowercase greek letter $",e.o||""),n=ld.patterns.match_("one lowercase latin letter $",e.o||""),l=ld.patterns.match_("$one lowercase latin letter$ $",e.o||""),s="-"===i&&(a&&""===a.remainder||o||n||l);!s||e.a||e.b||e.p||e.d||e.q||a||!n||(e.o="$"+e.o+"$");var c=[];return s?(ld.concatArray(c,this.output(e)),c.push({type_:"hyphen"})):(a=ld.patterns.match_("digits",e.d||""),r&&a&&""===a.remainder?(ld.concatArray(c,ld.actions["d="](e,i)),ld.concatArray(c,this.output(e))):(ld.concatArray(c,this.output(e)),ld.concatArray(c,ld.actions.bond(e,i,"-")))),c},"a to o":function(e){e.o=e.a,e.a=void 0},"sb=true":function(e){e.sb=!0},"sb=false":function(e){e.sb=!1},"beginsWithBond=true":function(e){e.beginsWithBond=!0},"beginsWithBond=false":function(e){e.beginsWithBond=!1},"parenthesisLevel++":function(e){e.parenthesisLevel++},"parenthesisLevel--":function(e){e.parenthesisLevel--},"state of aggregation":function(e,i){return{type_:"state of aggregation",p1:ld.go(i,"o")}},comma:function(e,i){var r=i.replace(/\s*$/,"");return r!==i&&0===e.parenthesisLevel?{type_:"comma enumeration L",p1:r}:{type_:"comma enumeration M",p1:r}},output:function(e,i,r){var a,o,n;for(var l in e.r?(o="M"===e.rdt?ld.go(e.rd,"tex-math"):"T"===e.rdt?[{type_:"text",p1:e.rd||""}]:ld.go(e.rd),n="M"===e.rqt?ld.go(e.rq,"tex-math"):"T"===e.rqt?[{type_:"text",p1:e.rq||""}]:ld.go(e.rq),a={type_:"arrow",r:e.r,rd:o,rq:n}):(a=[],(e.a||e.b||e.p||e.o||e.q||e.d||r)&&(e.sb&&a.push({type_:"entitySkip"}),e.o||e.q||e.d||e.b||e.p||2===r?e.o||e.q||e.d||!e.b&&!e.p?e.o&&"kv"===e.dType&&ld.patterns.match_("d-oxidation$",e.d||"")?e.dType="oxidation":e.o&&"kv"===e.dType&&!e.q&&(e.dType=void 0):(e.o=e.a,e.d=e.b,e.q=e.p,e.a=e.b=e.p=void 0):(e.o=e.a,e.a=void 0),a.push({type_:"chemfive",a:ld.go(e.a,"a"),b:ld.go(e.b,"bd"),p:ld.go(e.p,"pq"),o:ld.go(e.o,"o"),q:ld.go(e.q,"pq"),d:ld.go(e.d,"oxidation"===e.dType?"oxidation":"bd"),dType:e.dType}))),e)"parenthesisLevel"!==l&&"beginsWithBond"!==l&&delete e[l];return a},"oxidation-output":function(e,i){var r=["{"];return ld.concatArray(r,ld.go(i,"oxidation")),r.push("}"),r},"frac-output":function(e,i){return{type_:"frac-ce",p1:ld.go(i[0]),p2:ld.go(i[1])}},"overset-output":function(e,i){return{type_:"overset",p1:ld.go(i[0]),p2:ld.go(i[1])}},"underset-output":function(e,i){return{type_:"underset",p1:ld.go(i[0]),p2:ld.go(i[1])}},"underbrace-output":function(e,i){return{type_:"underbrace",p1:ld.go(i[0]),p2:ld.go(i[1])}},"color-output":function(e,i){return{type_:"color",color1:i[0],color2:ld.go(i[1])}},"r=":function(e,i){e.r=i},"rdt=":function(e,i){e.rdt=i},"rd=":function(e,i){e.rd=i},"rqt=":function(e,i){e.rqt=i},"rq=":function(e,i){e.rq=i},operator:function(e,i,r){return{type_:"operator",kind_:r||i}}}},a:{transitions:ld.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},"$(...)$":{"*":{action_:"tex-math tight",nextState:"1"}},",":{"*":{action_:{type_:"insert",option:"commaDecimal"}}},else2:{"*":{action_:"copy"}}}),actions:{}},o:{transitions:ld.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},letters:{"*":{action_:"rm"}},"\\ca":{"*":{action_:{type_:"insert",option:"circa"}}},"\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"{text}"}},else2:{"*":{action_:"copy"}}}),actions:{}},text:{transitions:ld.createTransitions({empty:{"*":{action_:"output"}},"{...}":{"*":{action_:"text="}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"\\greek":{"*":{action_:["output","rm"]}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:["output","copy"]}},else:{"*":{action_:"text="}}}),actions:{output:function(e){if(e.text_){var i={type_:"text",p1:e.text_};for(var r in e)delete e[r];return i}}}},pq:{transitions:ld.createTransitions({empty:{"*":{}},"state of aggregation $":{"*":{action_:"state of aggregation"}},i$:{0:{nextState:"!f",revisit:!0}},"(KV letters),":{0:{action_:"rm",nextState:"0"}},formula$:{0:{nextState:"f",revisit:!0}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"!f",revisit:!0}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"a-z":{f:{action_:"tex-math"}},letters:{"*":{action_:"rm"}},"-9.,9":{"*":{action_:"9,9"}},",":{"*":{action_:{type_:"insert+p1",option:"comma enumeration S"}}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"state of aggregation":function(e,i){return{type_:"state of aggregation subscript",p1:ld.go(i,"o")}},"color-output":function(e,i){return{type_:"color",color1:i[0],color2:ld.go(i[1],"pq")}}}},bd:{transitions:ld.createTransitions({empty:{"*":{}},x$:{0:{nextState:"!f",revisit:!0}},formula$:{0:{nextState:"f",revisit:!0}},else:{0:{nextState:"!f",revisit:!0}},"-9.,9 no missing 0":{"*":{action_:"9,9"}},".":{"*":{action_:{type_:"insert",option:"electron dot"}}},"a-z":{f:{action_:"tex-math"}},x:{"*":{action_:{type_:"insert",option:"KV x"}}},letters:{"*":{action_:"rm"}},"'":{"*":{action_:{type_:"insert",option:"prime"}}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"color-output":function(e,i){return{type_:"color",color1:i[0],color2:ld.go(i[1],"bd")}}}},oxidation:{transitions:ld.createTransitions({empty:{"*":{}},"roman numeral":{"*":{action_:"roman-numeral"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},else:{"*":{action_:"copy"}}}),actions:{"roman-numeral":function(e,i){return{type_:"roman numeral",p1:i||""}}}},"tex-math":{transitions:ld.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},else:{"*":{action_:"o="}}}),actions:{output:function(e){if(e.o){var i={type_:"tex-math",p1:e.o};for(var r in e)delete e[r];return i}}}},"tex-math tight":{transitions:ld.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},"-|+":{"*":{action_:"tight operator"}},else:{"*":{action_:"o="}}}),actions:{"tight operator":function(e,i){e.o=(e.o||"")+"{"+i+"}"},output:function(e){if(e.o){var i={type_:"tex-math",p1:e.o};for(var r in e)delete e[r];return i}}}},"9,9":{transitions:ld.createTransitions({empty:{"*":{}},",":{"*":{action_:"comma"}},else:{"*":{action_:"copy"}}}),actions:{comma:function(){return{type_:"commaDecimal"}}}},pu:{transitions:ld.createTransitions({empty:{"*":{action_:"output"}},space$:{"*":{action_:["output","space"]}},"{[(|)]}":{"0|a":{action_:"copy"}},"(-)(9)^(-9)":{0:{action_:"number^",nextState:"a"}},"(-)(9.,9)(e)(99)":{0:{action_:"enumber",nextState:"a"}},space:{"0|a":{}},"pm-operator":{"0|a":{action_:{type_:"operator",option:"\\pm"},nextState:"0"}},operator:{"0|a":{action_:"copy",nextState:"0"}},"//":{d:{action_:"o=",nextState:"/"}},"/":{d:{action_:"o=",nextState:"/"}},"{...}|else":{"0|d":{action_:"d=",nextState:"d"},a:{action_:["space","d="],nextState:"d"},"/|q":{action_:"q=",nextState:"q"}}}),actions:{enumber:function(e,i){var r=[];return"+-"===i[0]||"+/-"===i[0]?r.push("\\pm "):i[0]&&r.push(i[0]),i[1]&&(ld.concatArray(r,ld.go(i[1],"pu-9,9")),i[2]&&(i[2].match(/[,.]/)?ld.concatArray(r,ld.go(i[2],"pu-9,9")):r.push(i[2])),(i[3]||i[4])&&("e"===i[3]||"*"===i[4]?r.push({type_:"cdot"}):r.push({type_:"times"}))),i[5]&&r.push("10^{"+i[5]+"}"),r},"number^":function(e,i){var r=[];return"+-"===i[0]||"+/-"===i[0]?r.push("\\pm "):i[0]&&r.push(i[0]),ld.concatArray(r,ld.go(i[1],"pu-9,9")),r.push("^{"+i[2]+"}"),r},operator:function(e,i,r){return{type_:"operator",kind_:r||i}},space:function(){return{type_:"pu-space-1"}},output:function(e){var i,r=ld.patterns.match_("{(...)}",e.d||"");r&&""===r.remainder&&(e.d=r.match_);var a=ld.patterns.match_("{(...)}",e.q||"");if(a&&""===a.remainder&&(e.q=a.match_),e.d&&(e.d=e.d.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),e.d=e.d.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F")),e.q){e.q=e.q.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),e.q=e.q.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F");var o={d:ld.go(e.d,"pu"),q:ld.go(e.q,"pu")};"//"===e.o?i={type_:"pu-frac",p1:o.d,p2:o.q}:(i=o.d,o.d.length>1||o.q.length>1?i.push({type_:" / "}):i.push({type_:"/"}),ld.concatArray(i,o.q))}else i=ld.go(e.d,"pu-2");for(var n in e)delete e[n];return i}}},"pu-2":{transitions:ld.createTransitions({empty:{"*":{action_:"output"}},"*":{"*":{action_:["output","cdot"],nextState:"0"}},"\\x":{"*":{action_:"rm="}},space:{"*":{action_:["output","space"],nextState:"0"}},"^{(...)}|^(-1)":{1:{action_:"^(-1)"}},"-9.,9":{0:{action_:"rm=",nextState:"0"},1:{action_:"^(-1)",nextState:"0"}},"{...}|else":{"*":{action_:"rm=",nextState:"1"}}}),actions:{cdot:function(){return{type_:"tight cdot"}},"^(-1)":function(e,i){e.rm+="^{"+i+"}"},space:function(){return{type_:"pu-space-2"}},output:function(e){var i=[];if(e.rm){var r=ld.patterns.match_("{(...)}",e.rm||"");i=r&&""===r.remainder?ld.go(r.match_,"pu"):{type_:"rm",p1:e.rm}}for(var a in e)delete e[a];return i}}},"pu-9,9":{transitions:ld.createTransitions({empty:{0:{action_:"output-0"},o:{action_:"output-o"}},",":{0:{action_:["output-0","comma"],nextState:"o"}},".":{0:{action_:["output-0","copy"],nextState:"o"}},else:{"*":{action_:"text="}}}),actions:{comma:function(){return{type_:"commaDecimal"}},"output-0":function(e){var i=[];if(e.text_=e.text_||"",e.text_.length>4){var r=e.text_.length%3;0===r&&(r=3);for(var a=e.text_.length-3;a>0;a-=3)i.push(e.text_.substr(a,3)),i.push({type_:"1000 separator"});i.push(e.text_.substr(0,r)),i.reverse()}else i.push(e.text_);for(var o in e)delete e[o];return i},"output-o":function(e){var i=[];if(e.text_=e.text_||"",e.text_.length>4){for(var r=e.text_.length-3,a=0;a<r;a+=3)i.push(e.text_.substr(a,3)),i.push({type_:"1000 separator"});i.push(e.text_.substr(a))}else i.push(e.text_);for(var o in e)delete e[o];return i}}}};var lu={go:function(e,i){if(!e)return"";for(var r="",a=!1,o=0;o<e.length;o++){var n=e[o];"string"==typeof n?r+=n:(r+=lu._go2(n),"1st-level escape"===n.type_&&(a=!0))}return i||a||!r||(r="{"+r+"}"),r},_goInner:function(e){return e&&lu.go(e,!0)},_go2:function(e){var i;switch(e.type_){case"chemfive":i="";var r={a:lu._goInner(e.a),b:lu._goInner(e.b),p:lu._goInner(e.p),o:lu._goInner(e.o),q:lu._goInner(e.q),d:lu._goInner(e.d)};r.a&&(r.a.match(/^[+\-]/)&&(r.a="{"+r.a+"}"),i+=r.a+"\\,"),(r.b||r.p)&&(i+="{\\vphantom{X}}",i+="^{\\hphantom{"+(r.b||"")+"}}_{\\hphantom{"+(r.p||"")+"}}",i+="{\\vphantom{X}}",i+="^{\\smash[t]{\\vphantom{2}}\\llap{"+(r.b||"")+"}}",i+="_{\\vphantom{2}\\llap{\\smash[t]{"+(r.p||"")+"}}}"),r.o&&(r.o.match(/^[+\-]/)&&(r.o="{"+r.o+"}"),i+=r.o),"kv"===e.dType?((r.d||r.q)&&(i+="{\\vphantom{X}}"),r.d&&(i+="^{"+r.d+"}"),r.q&&(i+="_{\\smash[t]{"+r.q+"}}")):"oxidation"===e.dType?(r.d&&(i+="{\\vphantom{X}}",i+="^{"+r.d+"}"),r.q&&(i+="{\\vphantom{X}}",i+="_{\\smash[t]{"+r.q+"}}")):(r.q&&(i+="{\\vphantom{X}}",i+="_{\\smash[t]{"+r.q+"}}"),r.d&&(i+="{\\vphantom{X}}",i+="^{"+r.d+"}"));break;case"rm":case"roman numeral":i="\\mathrm{"+e.p1+"}";break;case"text":e.p1.match(/[\^_]/)?(e.p1=e.p1.replace(" ","~").replace("-","\\text{-}"),i="\\mathrm{"+e.p1+"}"):i="\\text{"+e.p1+"}";break;case"state of aggregation":i="\\mskip2mu "+lu._goInner(e.p1);break;case"state of aggregation subscript":i="\\mskip1mu "+lu._goInner(e.p1);break;case"bond":if(!(i=lu._getBond(e.kind_)))throw["MhchemErrorBond","mhchem Error. Unknown bond type ("+e.kind_+")"];break;case"frac":var a="\\frac{"+e.p1+"}{"+e.p2+"}";i="\\mathchoice{\\textstyle"+a+"}{"+a+"}{"+a+"}{"+a+"}";break;case"pu-frac":var o="\\frac{"+lu._goInner(e.p1)+"}{"+lu._goInner(e.p2)+"}";i="\\mathchoice{\\textstyle"+o+"}{"+o+"}{"+o+"}{"+o+"}";break;case"tex-math":case"1st-level escape":i=e.p1+" ";break;case"frac-ce":i="\\frac{"+lu._goInner(e.p1)+"}{"+lu._goInner(e.p2)+"}";break;case"overset":i="\\overset{"+lu._goInner(e.p1)+"}{"+lu._goInner(e.p2)+"}";break;case"underset":i="\\underset{"+lu._goInner(e.p1)+"}{"+lu._goInner(e.p2)+"}";break;case"underbrace":i="\\underbrace{"+lu._goInner(e.p1)+"}_{"+lu._goInner(e.p2)+"}";break;case"color":i="{\\color{"+e.color1+"}{"+lu._goInner(e.color2)+"}}";break;case"color0":i="\\color{"+e.color+"}";break;case"arrow":var n={rd:lu._goInner(e.rd),rq:lu._goInner(e.rq)},l=lu._getArrow(e.r);n.rd||n.rq?"<=>"===e.r||"<=>>"===e.r||"<<=>"===e.r||"<--\x3e"===e.r?(l="\\long"+l,n.rd&&(l="\\overset{"+n.rd+"}{"+l+"}"),n.rq&&(l="<--\x3e"===e.r?"\\underset{\\lower2mu{"+n.rq+"}}{"+l+"}":"\\underset{\\lower6mu{"+n.rq+"}}{"+l+"}"),l=" {}\\mathrel{"+l+"}{} "):(n.rq&&(l+="[{"+n.rq+"}]"),l+="{"+n.rd+"}",l=" {}\\mathrel{\\x"+l+"}{} "):l=" {}\\mathrel{\\long"+l+"}{} ",i=l;break;case"operator":i=lu._getOperator(e.kind_);break;case"space":i=" ";break;case"entitySkip":case"pu-space-1":i="~";break;case"pu-space-2":i="\\mkern3mu ";break;case"1000 separator":i="\\mkern2mu ";break;case"commaDecimal":i="{,}";break;case"comma enumeration L":i="{"+e.p1+"}\\mkern6mu ";break;case"comma enumeration M":i="{"+e.p1+"}\\mkern3mu ";break;case"comma enumeration S":i="{"+e.p1+"}\\mkern1mu ";break;case"hyphen":i="\\text{-}";break;case"addition compound":i="\\,{\\cdot}\\,";break;case"electron dot":i="\\mkern1mu \\bullet\\mkern1mu ";break;case"KV x":i="{\\times}";break;case"prime":i="\\prime ";break;case"cdot":i="\\cdot ";break;case"tight cdot":i="\\mkern1mu{\\cdot}\\mkern1mu ";break;case"times":i="\\times ";break;case"circa":i="{\\sim}";break;case"^":i="uparrow";break;case"v":i="downarrow";break;case"ellipsis":i="\\ldots ";break;case"/":i="/";break;case" / ":i="\\,/\\,";break;default:throw["MhchemBugT","mhchem bug T. Please report."]}return i},_getArrow:function(e){switch(e){case"->":case"→":case"⟶":return"rightarrow";case"<-":return"leftarrow";case"<->":return"leftrightarrow";case"<--\x3e":return"leftrightarrows";case"<=>":case"⇌":return"rightleftharpoons";case"<=>>":return"Rightleftharpoons";case"<<=>":return"Leftrightharpoons";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getBond:function(e){switch(e){case"-":case"1":return"{-}";case"=":case"2":return"{=}";case"#":case"3":return"{\\equiv}";case"~":return"{\\tripledash}";case"~-":return"{\\rlap{\\lower.1em{-}}\\raise.1em{\\tripledash}}";case"~=":case"~--":return"{\\rlap{\\lower.2em{-}}\\rlap{\\raise.2em{\\tripledash}}-}";case"-~-":return"{\\rlap{\\lower.2em{-}}\\rlap{\\raise.2em{-}}\\tripledash}";case"...":return"{{\\cdot}{\\cdot}{\\cdot}}";case"....":return"{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}";case"->":return"{\\rightarrow}";case"<-":return"{\\leftarrow}";case"<":return"{<}";case">":return"{>}";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getOperator:function(e){switch(e){case"+":return" {}+{} ";case"-":return" {}-{} ";case"=":return" {}={} ";case"<":return" {}<{} ";case">":return" {}>{} ";case"<<":return" {}\\ll{} ";case">>":return" {}\\gg{} ";case"\\pm":return" {}\\pm{} ";case"\\approx":case"$\\approx$":return" {}\\approx{} ";case"v":case"(v)":return" \\downarrow{} ";case"^":case"(^)":return" \\uparrow{} ";default:throw["MhchemBugT","mhchem bug T. Please report."]}}},lh=class e extends oG{constructor(e){super(g(f({},e),{type:"delim"})),this.value=e.delim,this.size=e.size}static fromJson(i){return new e(i)}toJson(){return g(f({},super.toJson()),{delim:this.value,size:this.size})}render(e){return new oE(this.value,{type:"middle"})}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let i=eM(this.command,this.mode);return null!=i&&i.serialize?i.serialize(this,e):og(this.command,this.value)}},lp=class e extends oG{constructor(e){super(g(f({},e),{type:"sizeddelim",value:e.delim})),this.delimType=e.delimType,this.size=e.size}static fromJson(i){return new e(i)}toJson(){return g(f({},super.toJson()),{delim:this.value,size:this.size,delimType:this.delimType})}render(e){var i,r,a;let o=(i=this.value,r=this.size,a={classes:({open:"ML__open",close:"ML__close"})[this.delimType],type:this.delimType,isSelected:this.isSelected},void 0===i||"."===i?nW(e,a.classes):("<"===i||"\\lt"===i||"⟨"===i?i="\\langle":(">"===i||"\\gt"===i||"⟩"===i)&&(i="\\rangle"),nO.has(i)||nI.has(i)?n$(i,r,!1,e,a):nR.has(i)?nP(i,nN[r],!1,e,a):null));return o?(o=this.bind(e,o),this.caret&&(o.caret=this.caret),o):null}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let i=eM(this.command,this.mode);return null!=i&&i.serialize?i.serialize(this,e):og(this.command,this.value)}};function lm(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}var lf=class e extends oG{constructor(e,i,r,a){var o,n;super({type:"enclose",command:e,style:a.style}),this.body=i,this.backgroundcolor=a.backgroundcolor,r.updiagonalarrow&&(r.updiagonalstrike=!1),r.box&&(r.left=!1,r.right=!1,r.bottom=!1,r.top=!1),this.notation=r,this.shadow=null!=(o=a.shadow)?o:"none",this.strokeWidth=null!=(n=a.strokeWidth)?n:"0.06em",this.strokeWidth||(this.strokeWidth="0.06em"),this.strokeStyle=a.strokeStyle,this.svgStrokeStyle=a.svgStrokeStyle,this.strokeColor=a.strokeColor,this.borderStyle=a.borderStyle,this.padding=a.padding,this.captureSelection=!1}static fromJson(i){return new e(i.command,i.body,i.notation,i)}toJson(){return g(f({},super.toJson()),{notation:this.notation,shadow:this.shadow,strokeWidth:this.strokeWidth,strokeStyle:this.strokeStyle,svgStrokeStyle:this.svgStrokeStyle,strokeColor:this.strokeColor,borderStyle:this.borderStyle,padding:this.padding})}_serialize(e){var i;if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let r=eM(this.command,this.mode);if(null!=r&&r.serialize)return r.serialize(this,e);let a=null!=(i=this.command)?i:"";if("\\enclose"===this.command){a+="{"+Object.keys(this.notation).join(" ")+"}";let e="",i="";this.backgroundcolor&&"transparent"!==this.backgroundcolor&&(e+=i+'mathbackground="'+this.backgroundcolor+'"',i=","),this.shadow&&"auto"!==this.shadow&&(e+=i+'shadow="'+this.shadow+'"',i=","),this.strokeWidth||"solid"!==this.strokeStyle?(e+=i+this.borderStyle,i=","):this.strokeColor&&"currentColor"!==this.strokeColor&&(e+=i+'mathcolor="'+this.strokeColor+'"',i=","),e&&(a+=`[${e}]`)}return og(a,this.bodyToLatex(e))}render(e){var i,r,a,o,n,l;let s=new oW({parent:e},this.style),c=oG.createBox(s,this.body);if(!c)return null;let d=function(e){if(!e)return"1px";let i=e.match(/([0-9][a-zA-Z\%]+)/);return null===i?"1px":i[1]}(this.borderStyle),u=s.toEm(this.padding&&"auto"!==this.padding?{string:this.padding}:{register:"fboxsep"});c.setStyle("position","relative"),c.setStyle("display","inline-block"),c.setStyle("height",c.height+c.depth,"em"),c.setStyle("width",c.width,"em");let h=new oE(null,{classes:"ML__notation"}),p=c.height+c.depth+2*u,m=c.width+2*u,f="",g=Math.min(.2*u,.05);if(this.notation.horizontalstrike){let e=2*u+c.height-.2155;f+=this.line((u+g).toString(),e.toString(),(u+c.width-g).toString(),e.toString())}if(this.notation.verticalstrike){let e=u+c.width/2;f+=this.line(e.toString(),(u+g).toString(),e.toString(),(p-u-g).toString())}if(this.notation.updiagonalstrike&&(f+=this.line((u+g).toString(),(p-u-g).toString(),(u+c.width-g).toString(),(u+g).toString())),this.notation.downdiagonalstrike&&(f+=this.line((u+g).toString(),(u+g).toString(),(u+c.width-g).toString(),(p-u-g).toString())),this.notation.updiagonalarrow){f+=this.line(u.toString(),(2*u+c.depth+c.height).toString(),(u+c.width).toString(),u.toString());let e=.03*Math.sqrt(m*m+p*p)*1,r=c.width*e,a=(c.depth+c.height)*e,o=u+c.width,n=u;n+a-.4*r<0&&(n=.4*r-a),f+='<polygon points="',f+=`${o},${n} ${o-r-.4*a},${n+a-.4*r} `,f+=`${o-.7*r},${n+.7*a} ${o-r+.4*a},${n+a+.4*r} `,f+=`${o},${n}`,f+=`" stroke='none' fill="${lm(null!=(i=this.strokeColor)?i:"")}"`,f+="/>"}let b=0;if(this.notation.phasorangle){let e=lb(s),i=(c.height+c.depth+2*e+2*u).toString(),r=(c.height+c.depth)/2;f+=this.line(u.toString(),i,(u+r+c.width).toString(),i),f+=this.line(u.toString(),i,(u+r).toString(),(u-e).toString()),p+=e,b=r,c.left+=p/2-u}if(this.notation.longdiv){let e=lb(s);p+=e,f+=this.line(u.toString(),u.toString(),(u+c.width).toString(),u.toString()),b=.3+e,c.left+=.3+e,c.setTop(u+e),f+='<path d="',f+=`M ${u} ${u} a0.3 ${(c.depth+c.height+2*e)/2}, 0, 1, 1, 0 ${c.depth+c.height+2*e} "`,f+=` stroke-width="${(Math.floor(100*(l=s).metrics.sqrtRuleThickness/l.scalingFactor)/100/10).toString()+"em"}" stroke="${lm(null!=(r=this.strokeColor)?r:"")}" fill="none"`,f+="/>"}if(h.width=c.width+2*u+b,h.height=c.height+2*u,h.depth=c.depth,h.setStyle("box-sizing","border-box"),h.setStyle("left",`calc(-1 * ${d} - ${u}em)`),h.setStyle("height",`calc( ${c.height+c.depth+2*u}em + ${d})`),h.setStyle("top","0em"),h.setStyle("width",`calc(${c.width+2*u}em + ${d})`),this.backgroundcolor&&h.setStyle("background-color",this.backgroundcolor),this.notation.box&&h.setStyle("border","1px solid red"),this.notation.actuarial&&(h.setStyle("border-top",this.borderStyle),h.setStyle("border-right",this.borderStyle)),this.notation.madruwb&&(h.setStyle("border-bottom",this.borderStyle),h.setStyle("border-right",this.borderStyle)),this.notation.roundedbox&&(h.setStyle("border-radius","8px"),h.setStyle("border",this.borderStyle)),this.notation.circle&&(h.setStyle("border-radius","50%"),h.setStyle("border",this.borderStyle)),this.notation.top&&h.setStyle("border-top",this.borderStyle),this.notation.left&&h.setStyle("border-left",this.borderStyle),this.notation.right&&h.setStyle("border-right",this.borderStyle),this.notation.bottom&&h.setStyle("border-bottom",this.borderStyle),f){let e="";"auto"===this.shadow&&(e+="filter: drop-shadow(0 0 .5px rgba(255, 255, 255, .7)) drop-shadow(1px 1px 2px #333)"),"none"!==this.shadow&&(e+=`filter: drop-shadow(${lm(null!=(a=this.shadow)?a:"")})`),e+=` stroke-width="${lm(null!=(o=this.strokeWidth)?o:"")}" stroke="${lm(null!=(n=this.strokeColor)?n:"")}" stroke-linecap="round"`,this.svgStrokeStyle&&(e+=` stroke-dasharray="${lm(this.svgStrokeStyle)}"`),h.svgStyle=e,h.svgOverlay=f}let y=new oE([h,c]);return y.setStyle("position","relative"),y.setStyle("height",`${Math.floor(100*(h.depth+h.height))/100}em`),y.setStyle("display","inline-block"),y.height=h.height,y.depth=h.depth,y.width=h.width-2*u,y.left=u,y.right=u,this.caret&&(y.caret=this.caret),y.wrap(s)}line(e,i,r,a){return`<line x1="${lg(e)}" y1="${lg(i)}" x2="${lg(r)}" y2="${lg(a)}" vector-effect="non-scaling-stroke"></line>`}};function lg(e){return"number"==typeof e?`${Math.floor(100*e)/100}%`:e}function lb(e){let i=e.isDisplayStyle?.431:e.metrics.defaultRuleThickness;return e.metrics.defaultRuleThickness+e.scalingFactor*i/4}var ly=class e extends oG{constructor(e,i,r){var a,o,n;super(g(f({},r),{type:"genfrac",displayContainsHighlight:!0})),this.above=e,this.below=i,this.hasBarLine=null==(a=null==r?void 0:r.hasBarLine)||a,this.continuousFraction=null!=(o=null==r?void 0:r.continuousFraction)&&o,this.align=null!=(n=null==r?void 0:r.align)?n:"center",this.numerPrefix=null==r?void 0:r.numerPrefix,this.denomPrefix=null==r?void 0:r.denomPrefix,this.mathstyleName=null==r?void 0:r.mathstyleName,this.leftDelim=null==r?void 0:r.leftDelim,this.rightDelim=null==r?void 0:r.rightDelim}static fromJson(i){return new e(i.above,i.below,i)}toJson(){let e={};return this.continuousFraction&&(e.continuousFraction=!0),"center"!==this.align&&(e.align=this.align),this.numerPrefix&&(e.numerPrefix=this.numerPrefix),this.denomPrefix&&(e.denomPrefix=this.denomPrefix),this.leftDelim&&(e.leftDelim=this.leftDelim),this.rightDelim&&(e.rightDelim=this.rightDelim),this.hasBarLine||(e.hasBarLine=!1),this.mathstyleName&&(e.mathstyleName=this.mathstyleName),f(f({},super.toJson()),e)}get children(){if(this._children)return this._children;let e=[];if("denominator-numerator"===o$.fractionNavigationOrder){for(let i of this.below)e.push(...i.children),e.push(i);for(let i of this.above)e.push(...i.children),e.push(i)}else{for(let i of this.above)e.push(...i.children),e.push(i);for(let i of this.below)e.push(...i.children),e.push(i)}return this._children=e,e}render(e){var i,r;let a=new oW({parent:e,mathstyle:this.mathstyleName},this.style),o=a.metrics,n=new oW({parent:a,mathstyle:this.continuousFraction?"":"numerator"},this.style),l=this.numerPrefix?new oE([new oE(this.numerPrefix),oG.createBox(n,this.above)],{isTight:n.isTight,type:"ignore"}):null!=(i=oG.createBox(n,this.above,{type:"ignore"}))?i:new oE(null,{type:"ignore"}),s=new oW({parent:a,mathstyle:this.continuousFraction?"":"denominator"},this.style),c=this.denomPrefix?new oE([new oE(this.denomPrefix),oG.createBox(s,this.below,{type:"ignore"})]):null!=(r=oG.createBox(s,this.below,{type:"ignore"}))?r:new oE(null,{type:"ignore"}),d=this.hasBarLine?o.defaultRuleThickness:0,u,h=0,p;a.isDisplayStyle?(u=n.metrics.num1,h=d>0?3*d:7*d,p=s.metrics.denom1):(d>0?(u=n.metrics.num2,h=d):(u=n.metrics.num3,h=3*o.defaultRuleThickness),p=s.metrics.denom2);let m=[];this.isSelected&&m.push("ML__selected");let f=l.depth,g=c.height,b;if(d<=0){let e=u-f-(g-p);e<h&&(u+=(h-e)/2,p+=(h-e)/2),b=new oB({individualShift:[{box:l,shift:-u,classes:[...m,lv(this.align)]},{box:c,shift:p,classes:[...m,lv(this.align)]}]}).wrap(a)}else{let e=new oE(null,{classes:"ML__frac-line",mode:this.mode,style:this.style});e.softWidth=Math.max(l.width,c.width),e.height=d/2,e.depth=d/2;let i=.25+d/2;u<h+f+i&&(u=h+f+i);let r=.25-d/2;p<h+g-r&&(p=h+g-r),b=new oB({individualShift:[{box:c,shift:p,classes:[...m,lv(this.align)]},{box:e,shift:-r,classes:m},{box:l,shift:-u,classes:[...m,lv(this.align)]}]}).wrap(a)}let y=a.isDisplayStyle?o.delim1:o.delim2,v=this.leftDelim?this.bind(e,nj("open",this.leftDelim,y,!0,e,{style:this.style,mode:this.mode,isSelected:this.isSelected})):nW(a,"ML__open"),x=null;x=this.continuousFraction?new oE(null,{type:"close"}):this.rightDelim?this.bind(e,nj("close",this.rightDelim,y,!0,e,{style:this.style,mode:this.mode,isSelected:this.isSelected})):nW(a,"ML__close");let _=new oE([v,b,x],{isTight:a.isTight,type:"inner",classes:"ML__mfrac"}),w=this.bind(e,_);return this.caret&&(w.caret=this.caret),this.attachSupsub(e,{base:w})}};function lv(e){var i;return null!=(i=({left:"ML__left",right:"ML__right",center:"ML__center"})[e])?i:"ML__center"}var lx=class e extends oG{constructor(e,i){var r;super({type:"latex",value:e,mode:"latex"}),this.isSuggestion=null!=(r=null==i?void 0:i.isSuggestion)&&r,this.isError=!1}static fromJson(i){let r=new e(i.value);return i.isSuggestion&&(r.isSuggestion=!0),i.isError&&(r.isError=!0),r}toJson(){let e={};return this.isSuggestion&&(e.isSuggestion=!0),this.isError&&(e.isError=!0),f({type:"latex",value:this.value},e)}render(e){let i=new oE(this.value,{classes:this.isSuggestion?"ML__suggestion":this.isError?"ML__error":"",type:"latex",maxFontSize:1});return i?(this.caret&&(i.caret=this.caret),this.bind(e,i)):null}},l_=class e extends oG{constructor(e=""){super({type:"latexgroup",mode:"latex"}),this.body=[...e].map(e=>new lx(e)),this.skipBoundary=!0}static fromJson(i){return new e}toJson(){return super.toJson()}render(e){let i=oG.createBox(e,this.body);return i?(this.caret&&(i.caret=this.caret),this.bind(e,i)):null}_serialize(e){var i,r;return null!=(r=null==(i=this.body)?void 0:i.map(e=>e.value).join(""))?r:""}},lw=class e extends oG{constructor(e,i){super(g(f({},i),{type:"extensible-symbol",isFunction:null==i?void 0:i.isFunction})),this.value=e,this.variant=null==i?void 0:i.variant,this.subsupPlacement=null==i?void 0:i.limits}static fromJson(i){return new e(i.symbol,i)}toJson(){let e=super.toJson();return this.variant&&(e.variant=this.variant),this.subsupPlacement&&(e.limits=this.subsupPlacement),this.value&&(e.symbol=this.value),e}render(e){var i;let r=e.isDisplayStyle&&"\\smallint"!==this.value,a=new oE(this.value,{fontFamily:r?"Size2-Regular":"Size1-Regular",classes:"ML__op-symbol "+(r?"ML__large-op":"ML__small-op"),type:"op",maxFontSize:e.scalingFactor,isSelected:this.isSelected});if(!a)return null;a.right=a.italic;let o=(a.height-a.depth)/2-.25*e.scalingFactor,n=a.italic;a.setTop(o);let l=a;if(this.superscript||this.subscript){let r=null!=(i=this.subsupPlacement)?i:"auto";"auto"===r&&e.isDisplayStyle&&(r="over-under"),l="over-under"===r?this.attachLimits(e,{base:a,baseShift:o,slant:n}):this.attachSupsub(e,{base:a})}return new oE(this.bind(e,l),{type:"op",caret:this.caret,isSelected:this.isSelected,classes:"ML__op-group"}).wrap(e)}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let i=eM(this.command,this.mode);if(null!=i&&i.serialize)return i.serialize(this,e);let r=[];return r.push(this.command),this.explicitSubsupPlacement&&("over-under"===this.subsupPlacement&&r.push("\\limits"),"adjacent"===this.subsupPlacement&&r.push("\\nolimits"),"auto"===this.subsupPlacement&&r.push("\\displaylimits")),r.push(this.supsubToLatex(e)),of(r)}},lk=class e extends oG{constructor(e){let i=e.body;super(g(f({},e),{type:"overlap",body:"string"==typeof i?[new oG({value:i})]:i,style:null==e?void 0:e.style})),this.skipBoundary=!0,this.align=null==e?void 0:e.align,this.boxType=null==e?void 0:e.boxType}static fromJson(i){return new e(i)}toJson(){let e={};return this.align&&(e.align=this.align),this.boxType&&(e.boxType=this.boxType),f(f({},super.toJson()),e)}render(e){let i=oG.createBox(e,this.body,{classes:"ML__inner"});if(!i)return null;this.caret&&(i.caret=this.caret);let r="right"===this.align?"ML__rlap":"center"===this.align?"ML__clap":"ML__llap";return this.bind(e,new oE([i,new oE(null,{classes:"ML__fix"})],{classes:r,type:this.boxType}))}},lM=class e extends oG{constructor(e){var i,r,a,o;super({type:"overunder",command:e.command,style:e.style,mode:e.mode,body:e.body,skipBoundary:null==(i=e.skipBoundary)||i}),this.subsupPlacement=e.supsubPlacement,this.svgAbove=e.svgAbove,this.svgBelow=e.svgBelow,this.svgBody=e.svgBody,this.above=e.above,this.below=e.below,this.boxType=null!=(r=e.boxType)?r:"ord",this.paddedBody=null!=(a=e.paddedBody)&&a,this.paddedLabels=null!=(o=e.paddedLabels)&&o}static fromJson(i){return new e(i)}toJson(){let e=super.toJson();return this.skipBoundary||(e.skipBoundary=!1),this.subsupPlacement&&(e.subsupPlacement=this.subsupPlacement),this.svgAbove&&(e.svgAbove=this.svgAbove),this.svgBelow&&(e.svgBelow=this.svgBelow),this.svgBody&&(e.svgBody=this.svgBody),"ord"!==this.boxType&&(e.boxType=this.boxType),this.paddedBody&&(e.paddedBody=!0),this.paddedLabels&&(e.paddedLabels=!0),e}render(e){let i=this.svgBody?oT(this.svgBody):oG.createBox(e,this.body,{type:"ignore"}),r=new oW({parent:e,mathstyle:"scriptstyle"},this.style),a=null;this.svgAbove?a=oT(this.svgAbove):this.above&&(a=oG.createBox(r,this.above,{type:"ignore"}));let o=null;this.svgBelow?o=oT(this.svgBelow):this.below&&(o=oG.createBox(r,this.below,{type:"ignore"})),this.paddedBody&&(i=new oE([nW(e,"ML__open"),i,nW(e,"ML__close")],{type:"ignore"}));let n=function(e,i){if(!i.base)return null;if(!i.above&&!i.below){let e=new oE(i.base,{type:i.type});return e.setStyle("position","relative"),e}let r=0;i.above&&(r=e.metrics.bigOpSpacing5);let a=null,o=i.base,n=["ML__center"];return(i.paddedAboveBelow&&n.push("ML__label_padding"),i.below&&i.above)?a=new oB({bottom:e.metrics.bigOpSpacing5+i.below.height+i.below.depth+o.depth+0,children:[e.metrics.bigOpSpacing5,{box:i.below,classes:n},{box:o,classes:["ML__center"]},r,{box:i.above,classes:n},e.metrics.bigOpSpacing5]}):i.below?a=new oB({top:o.height-0,children:[e.metrics.bigOpSpacing5,{box:i.below,classes:n},{box:o,classes:["ML__center"]}]}):i.above&&(a=new oB({bottom:o.depth+0,children:[{box:o,classes:["ML__center"]},r,{box:i.above,classes:n},e.metrics.bigOpSpacing5]})),new oE(a,{type:i.type})}(e,{base:i,above:a,below:o,type:"bin"===this.boxType||"rel"===this.boxType?this.boxType:"ord",paddedAboveBelow:this.paddedLabels});return n?(n="over-under"===this.subsupPlacement?this.attachLimits(e,{base:n,type:n.type}):this.attachSupsub(e,{base:n}),this.caret&&(n.caret=this.caret),this.bind(e,n)):null}},lS=class e extends oG{constructor(e){var i,r,a,o;super(g(f({},e),{type:"phantom"})),this.captureSelection=!0,this.isInvisible=null!=(i=e.isInvisible)&&i,this.smashDepth=null!=(r=e.smashDepth)&&r,this.smashHeight=null!=(a=e.smashHeight)&&a,this.smashWidth=null!=(o=e.smashWidth)&&o}static fromJson(i){return new e(i)}toJson(){let e={};return this.isInvisible&&(e.isInvisible=!0),this.smashDepth&&(e.smashDepth=!0),this.smashHeight&&(e.smashHeight=!0),this.smashWidth&&(e.smashWidth=!0),f(f({},super.toJson()),e)}render(e){let i=new oW({parent:e,isPhantom:!0});if(!this.smashDepth&&!this.smashHeight&&!this.smashWidth)return this.isInvisible,oG.createBox(i,this.body,{classes:"ML__inner"});let r=oG.createBox(this.isInvisible?i:e,this.body);if(!r)return null;if(this.smashWidth){let i=new oE(null,{classes:"ML__fix"});return new oE([r,i],{classes:"ML__rlap"}).wrap(e)}if(!this.smashHeight&&!this.smashDepth)return r;if(this.smashHeight&&(r.height=0),this.smashDepth&&(r.depth=0),r.children)for(let e of r.children)this.smashHeight&&(e.height=0),this.smashDepth&&(e.depth=0);return new oB({firstBaseline:[{box:r}]},{type:r.type}).wrap(e)}},lL=class e extends oG{constructor(e){var i;super(f({type:"spacing"},e)),this.width=null==e?void 0:e.width,this._braced=null!=(i=null==e?void 0:e.braced)&&i}static fromJson(i){return new e(i)}toJson(){let e=super.toJson();return void 0!==this.width&&(e.width=this.width),this._braced&&(e.braced=!0),e}render(e){var i;let r;return"space"===this.command?new oE("math"===this.mode?null:" "):(void 0!==this.width?(r=new oE(null,{classes:"ML__mspace"})).left=e.toEm(this.width):r=new oE(null,{classes:null!=(i=({"\\qquad":"ML__qquad","\\quad":"ML__quad","\\enspace":"ML__enspace","\\enskip":"ML__enspace","\\;":"ML__thickspace","\\thickspace":"ML__thickspace","\\:":"ML__mediumspace","\\>":"ML__mediumspace","\\medspace":"ML__mediumspace","\\,":"ML__thinspace","\\thinspace":"ML__thinspace","\\!":"ML__negativethinspace","\\negthinspace":"ML__negativethinspace","\\negmedspace":"ML__negativemediumspace","\\negthickspace":"ML__negativethickspace"})[this.command])?i:"ML__mediumspace"}),r=this.bind(e,r),this.caret&&(r.caret=this.caret),r)}_serialize(e){var i;if(!e.expandMacro&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let r=eM(this.command,this.mode);if(null!=r&&r.serialize)return r.serialize(this,e);let a=null!=(i=this.command)?i:"";return void 0===this.width?a:!this._braced||"register"in this.width?`${a}${oF(this.width)}`:`${a}{${oF(this.width)}}`}},lC=class e extends oG{constructor(e){var i;super(g(f({},e),{type:"surd",mode:null!=(i=e.mode)?i:"math",style:e.style,displayContainsHighlight:!0,body:e.body})),this.above=e.index}static fromJson(i){return new e(g(f({},i),{index:i.above}))}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let i=eM(this.command,this.mode);if(null!=i&&i.serialize)return i.serialize(this,e);let r=this.command,a=this.bodyToLatex(e);return this.above&&!this.hasEmptyBranch("above")?og(`${r}[${this.aboveToLatex(e)}]`,a):o$.compactSerialization&&/^[0-9]$/.test(a)?`${r}${a}`:og(r,a)}get children(){if(this._children)return this._children;let e=[];if(this.above)for(let i of this.above)e.push(...i.children),e.push(i);if(this.body)for(let i of this.body)e.push(...i.children),e.push(i);return this._children=e,e}render(e){var i;let r=new oW({parent:e,mathstyle:"cramp"},this.style),a=null!=(i=oG.createBox(r,this.body,{type:"inner"}))?i:new oE(null),o=r.scalingFactor,n=r.metrics.defaultRuleThickness/o,l=e.isDisplayStyle?.431:n,s=new oE(null,{classes:"ML__sqrt-line",style:this.style});s.height=n,s.softWidth=a.width;let c=o*(n+l/4),d=Math.max(2*o*l,a.height+a.depth)+c+n,u=new oW({parent:e},this.style),h=this.bind(u,new oE(nj("inner","\\surd",d,!1,u,{isSelected:this.isSelected}),{isSelected:this.isSelected,classes:"ML__sqrt-sign",style:this.style}));if(!h)return null;let p=h.height+h.depth-n;p>a.height+a.depth+c&&(c=(c+p-(a.height+a.depth))/2),h.setTop(h.height-a.height-c);let m=this.bind(e,new oB({firstBaseline:[{box:new oE(a)},c-2*n,{box:s},n]})),f=oG.createBox(new oW({parent:e,mathstyle:"scriptscriptstyle"}),this.above,{type:"ignore"});if(!f){let i=new oE([h,m],{classes:this.containsCaret?"ML__contains-caret":"",type:"inner"});return i.setStyle("display","inline-block"),i.setStyle("height",i.height+i.depth,"em"),this.caret&&(i.caret=this.caret),this.bind(e,i)}let g=new oE([new oE(new oB({shift:-.6*(Math.max(h.height,m.height)-Math.max(h.depth,m.depth)),children:[{box:f}]}),{classes:"ML__sqrt-index",type:"ignore"}),h,m],{type:"inner",classes:this.containsCaret?"ML__contains-caret":""});return g.height=h.height,g.depth=h.depth,this.caret&&(g.caret=this.caret),this.bind(e,g)}},lE=class extends oE{constructor(e){super(null,{type:"skip"}),this._width=e}toMarkup(){return`<span style="display:inline-block;width:${Math.ceil(100*this.width)/100}em"></span>`}};function lA(e,i){if(!e.parent)return;let r=e.parent.children,a=r.indexOf(e),o=a-1;for(;o>=0&&"ignore"===r[o].type;)o-=1;o<0&&e.parent.parent&&"lift"===e.parent.type?lA(e.parent,i):a>0&&"skip"===r[a-1].type?r[a-1].width+=i:r.splice(a,0,new lE(i))}var lz={ord:{op:3,bin:4,rel:5,inner:3},op:{ord:3,op:3,rel:5,inner:3},bin:{ord:4,op:4,open:4,inner:4},rel:{ord:5,op:5,open:5,inner:5},close:{op:3,bin:4,rel:5,inner:3},punct:{ord:3,op:3,rel:3,open:3,punct:3,inner:3},inner:{ord:3,op:3,bin:4,rel:5,open:3,punct:3,inner:3}},lT={ord:{op:3},op:{ord:3,op:3},close:{op:3},inner:{op:3}};function lD(e,i){if(!e.children)return e;let r=e.children;lK(r,(e,i)=>{"bin"===i.type&&(!e||/^(middle|bin|op|rel|open|punct)$/.test(e.type))&&(i.type="ord"),(null==e?void 0:e.type)==="bin"&&/^(rel|close|punct)$/.test(i.type)&&(e.type="ord"),"ignore"!==i.type&&(e=i)});let a=i.getRegisterAsEm("thinmuskip"),o=i.getRegisterAsEm("medmuskip"),n=i.getRegisterAsEm("thickmuskip");return lK(r,(e,i)=>{var r,l,s;if(!e)return;let c=e.type;if("newline"===c)return;let d=i.isTight?null!=(r=lT[c])?r:null:null!=(l=lz[c])?l:null,u=null!=(s=null==d?void 0:d[i.type])?s:null;3===u&&lA(i,a),4===u&&lA(i,o),5===u&&lA(i,n)}),e}function lK(e,i,r){if(!e)return r;for(let a of e=[...e])"lift"===a.type?r=lK(a.children,i,r):"ignore"===a.type?lK(a.children,i):(i(r,a),lK(a.children,i),r=a);return r}var lB=class e extends oG{constructor(e){super({type:"tooltip",command:e.command,mode:e.mode,style:e.style,body:e.body,displayContainsHighlight:!0}),this.tooltip=new oG({type:"root",mode:e.content,body:e.tooltip,style:{}}),this.skipBoundary=!0,this.captureSelection=!1}static fromJson(i){return new e(g(f({},i),{tooltip:lR(i.tooltip)}))}toJson(){var e;let i=null==(e=this.tooltip.body)?void 0:e.filter(e=>"first"!==e.type).map(e=>e.toJson());return g(f({},super.toJson()),{tooltip:i})}render(e){let i=oG.createBox(e,this.body);if(!i)return null;let r=new oW({parent:e,mathstyle:"displaystyle"},{fontSize:5}),a=oA(lD(new oE(this.tooltip.render(r),{classes:"ML__tooltip-content"}),r)),o=new oE([a,i],{classes:"ML__tooltip-container"});return this.caret&&(o.caret=this.caret),this.bind(e,o)}},l$=class e extends oG{constructor(e,i){var r;super({type:"mop",mode:null!=(r=null==i?void 0:i.mode)?r:"math",style:null==i?void 0:i.style,command:"\\blank",isFunction:!0,captureSelection:!0,body:e})}static fromJson(i){return new e(i.body,i)}render(e){let i=new oW({parent:e}),r=!this.body||0===this.body.length||this.body.every(e=>"first"===e.type)?new nU({mode:this.mode,style:this.style}).render(e):oG.createBox(e,this.body),a=new oE("blank",{type:"op",mode:"math",maxFontSize:i.scalingFactor,style:{variant:"main",variantStyle:"up"},isSelected:this.isSelected,letterShapeStyle:i.letterShapeStyle}),o=new oE("(",{type:"open",isSelected:this.isSelected,maxFontSize:i.scalingFactor}),n=new oE(")",{type:"close",isSelected:this.isSelected,maxFontSize:i.scalingFactor}),l=new oE([a,o,r,n],{type:"ord",classes:"ML__blank",isSelected:this.isSelected});this.caret&&(l.caret=this.caret);let s=this.attachSupsub(e,{base:l});return this.bind(i,s)}_serialize(e){var i;let r=null!=(i=this.bodyToLatex(e))?i:"";return e.skipPlaceholders?r:og("\\blank",r)}},lP=class e extends oG{constructor(e,i){super(g(f({},i),{type:"operator",isFunction:null==i?void 0:i.isFunction})),this.value=e,this.variant=null==i?void 0:i.variant,this.variantStyle=null==i?void 0:i.variantStyle,this.subsupPlacement=null==i?void 0:i.limits}static fromJson(i){return new e(i.symbol,i)}toJson(){let e=super.toJson();return this.variant&&(e.variant=this.variant),this.variantStyle&&(e.variantStyle=this.variantStyle),this.subsupPlacement&&(e.limits=this.subsupPlacement),this.value&&(e.symbol=this.value),e}render(e){var i;let r=new oE(this.value,{type:"op",mode:"math",maxFontSize:e.scalingFactor,style:{variant:this.variant,variantStyle:this.variantStyle},isSelected:this.isSelected,letterShapeStyle:e.letterShapeStyle}),a=r;if(this.superscript||this.subscript){let o=null!=(i=this.subsupPlacement)?i:"auto";a="over-under"===o||"auto"===o&&e.isDisplayStyle?this.attachLimits(e,{base:r}):this.attachSupsub(e,{base:r})}return new oE(this.bind(e,a),{type:"op",caret:this.caret,isSelected:this.isSelected,classes:"ML__op-group"}).wrap(e)}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let i=eM(this.command,this.mode);if(null!=i&&i.serialize)return i.serialize(this,e);let r=[this.command];return this.explicitSubsupPlacement&&("over-under"===this.subsupPlacement&&r.push("\\limits"),"adjacent"===this.subsupPlacement&&r.push("\\nolimits"),"auto"===this.subsupPlacement&&r.push("\\displaylimits")),r.push(this.supsubToLatex(e)),of(r)}},lO=class e extends oG{constructor(e){super(g(f({type:"newline"},e),{skipBoundary:!0}))}static fromJson(i){return new e(i)}toJson(){return super.toJson()}render(e){let i=new oE(null,{classes:"ML__newline",type:"newline"});return this.caret&&(i.caret=this.caret),this.bind(e,i)}_serialize(e){return"\\\\"}};function lR(e){if(R(e))return e.map(e=>lR(e));if("string"==typeof e)return oG.fromJson(e);for(let i of(e=f({},e),oU))e[i]&&(e[i]=lR(e[i]));e.args&&(e.args=function(e){if(e){if("string"==typeof e)return e;if(Array.isArray(e))return e.map(e=>"<null>"===e?null:"object"==typeof e&&"group"in e?{group:e.group.map(e=>lR(e))}:"object"==typeof e&&"atoms"in e?e.atoms.map(e=>lR(e)):e)}}(e.args)),e.array&&(e.array=lR(e.array));let i=e.type,r;for(let a of("accent"===i&&(r=nT.fromJson(e)),"array"===i&&(r=nQ.fromJson(e)),"box"===i&&(r=n8.fromJson(e)),"chem"===i&&(r=lc.fromJson(e)),"composition"===i&&(r=n5.fromJson(e)),"delim"===i&&(r=lh.fromJson(e)),"enclose"===i&&(r=lf.fromJson(e)),"error"===i&&(r=n7.fromJson(e)),"extensible-symbol"===i&&(r=lw.fromJson(e)),"genfrac"===i&&(r=ly.fromJson(e)),"group"===i&&(r=n9.fromJson(e)),"latex"===i&&(r=lx.fromJson(e)),"latexgroup"===i&&(r=l_.fromJson(e)),"leftright"===i&&(r=le.fromJson(e)),"macro"===i&&(r=lt.fromJson(e)),"macro-argument"===i&&(r=li.fromJson(e)),"newline"===i&&(r=lO.fromJson(e)),"operator"===i&&(r=lP.fromJson(e)),"overlap"===i&&(r=lk.fromJson(e)),"overunder"===i&&(r=lM.fromJson(e)),"placeholder"===i&&(r=nU.fromJson(e)),"\\blank"===e.command?r=l$.fromJson(e):"prompt"===i&&(r=lr.fromJson(e)),"phantom"===i&&(r=lS.fromJson(e)),"sizeddelim"===i&&(r=lp.fromJson(e)),"spacing"===i&&(r=lL.fromJson(e)),"subsup"===i&&(r=la.fromJson(e)),"surd"===i&&(r=lC.fromJson(e)),"text"===i&&(r=oY.fromJson(e)),"tooltip"===i&&(r=lB.fromJson(e)),r||(i&&["first","mbin","mrel","mclose","minner","mop","mopen","mord","mpunct","root","space"].includes(i),r=oG.fromJson(e)),oU))e[a]&&r.setChildren(e[a],a);return void 0!==e.verbatimLatex&&(r.verbatimLatex=e.verbatimLatex),e.subsupPlacement&&(r.subsupPlacement=e.subsupPlacement),e.explicitSubsupPlacement&&(r.explicitSubsupPlacement=!0),e.isFunction&&(r.isFunction=!0),e.skipBoundary&&(r.skipBoundary=!0),e.captureSelection&&(r.captureSelection=!0),r}function lI(e,i){e&&i&&(R(e)?e.forEach(e=>lI(e,i)):"object"==typeof e&&e.applyStyle(i,{unstyledOnly:!0}))}function lN(e,i,r,a){function o(e,i){for(let r of n)if(r.style[e]!==i)return!1;return!0}if((i=e.normalizeRange(i))[0]===i[1])return!1;let n=e.getAtoms(i,{includeChildren:!0});for(let e of("toggle"===a.operation&&(r.color&&o("color",r.color)&&(r.color="none",delete r.verbatimColor),r.backgroundColor&&o("backgroundColor",r.backgroundColor)&&(r.backgroundColor="none",delete r.verbatimBackgroundColor),r.fontFamily&&o("fontFamily",r.fontFamily)&&(r.fontFamily="none"),r.fontSeries&&o("fontSeries",r.fontSeries)&&(r.fontSeries="auto"),r.fontShape&&o("fontShape",r.fontShape)&&(r.fontShape="auto"),r.fontSize&&o("fontSize",r.fontSize)&&(r.fontSize=5),r.variant&&o("variant",r.variant)&&(r.variant="normal"),r.variantStyle&&o("variantStyle",r.variantStyle)&&(r.variantStyle="")),n))e.applyStyle(r);return!0}function lq(e){return({up:"up",bold:"bold",italic:void 0,bolditalic:"bold","":void 0})[null!=e?e:""]}var lF={acute:714,grave:715,dot:729,ddot:168,dddot:8411,ddddot:8412,mathring:730,tilde:126,bar:713,breve:728,check:711,hat:94,vec:8407};function lV(e,i=[[[]]],r=[],a=[],o,n){return new nQ(e,i,r,g(f({},function(e,i,r,a){switch(e){case"math":case"displaymath":return{mathstyleName:"textstyle",isRoot:!0,minColumns:1,maxColumns:1,minRows:1,maxRows:1};case"center":return{columns:[{align:"c"}],classes:["ML__center_environment"],isRoot:!0,minColumns:1,maxColumns:1,minRows:1,maxRows:1};case"multline":case"multline*":return{columns:[{align:"m"}],leftDelim:".",rightDelim:".",isRoot:!0,minColumns:1,maxColumns:1,minRows:1};case"split":return{columns:[{align:"r"},{align:"l"}],minColumns:2,minRows:1,isRoot:!1};case"gather":case"gather*":return{columns:[{gap:.25},{align:"c"},{gap:0}],minColumns:1,maxColumns:1,minRows:1,isRoot:!0,classes:["ML__gather_environment"]};case"gathered":return{columns:[{gap:.25},{align:"c"},{gap:0}],minColumns:1,maxColumns:1,minRows:1};case"equation":case"equation*":case"subequations":return{columns:[{align:"c"}],isRoot:!0,minColumns:1,maxColumns:1,minRows:1};case"aligned":{let r=0;for(let e of i)r=Math.max(r,e.length);let a=[{gap:0},{align:"r"},{gap:.25},{align:"l"}],o=2;for(;o<r;)a.push({gap:1},{align:"r"},{gap:.25},{align:"l"}),o+=2;return a.push({gap:0}),{arraycolsep:0,columns:a,minColumns:2,minRows:1,isRoot:"aligned"!==e}}case"eqnarray":return{arraycolsep:0,columns:[{gap:0},{align:"r"},{align:"c"},{align:"l"}],minColumns:3,maxColumns:3,minRows:1,isRoot:!0,classes:["ML__eqnarray_environment"]};case"align":case"align*":return{arraycolsep:0,columns:[{gap:0},{align:"r"},{gap:.25},{align:"l"}],minColumns:2,maxColumns:2,minRows:1,isRoot:!0,classes:["ML__align_environment"]};case"pmatrix":case"pmatrix*":return{mathstyleName:"textstyle",leftDelim:"(",rightDelim:")",columns:lj(r[0],a)};case"bmatrix":case"bmatrix*":return{mathstyleName:"textstyle",leftDelim:"[",rightDelim:"]",columns:lj(r[0],a)};case"Bmatrix":case"Bmatrix*":return{mathstyleName:"textstyle",leftDelim:"\\lbrace",rightDelim:"\\rbrace",columns:lj(r[0],a)};case"vmatrix":case"vmatrix*":return{mathstyleName:"textstyle",leftDelim:"\\vert",rightDelim:"\\vert",columns:lj(r[0],a)};case"Vmatrix":case"Vmatrix*":return{mathstyleName:"textstyle",leftDelim:"\\Vert",rightDelim:"\\Vert",columns:lj(r[0],a)};case"matrix":case"matrix*":return{mathstyleName:"textstyle",leftDelim:".",rightDelim:".",columns:lj(null==r?void 0:r[0],a)};case"smallmatrix":case"smallmatrix*":return{mathstyleName:"scriptstyle",columns:lj(null==r?void 0:r[0],a),colSeparationType:"small",arraystretch:.5};case"cases":case"dcases":return{mathstyleName:"dcases"===e?"displaystyle":"textstyle",arraystretch:1.2,leftDelim:"\\lbrace",rightDelim:".",columns:lH()};case"rcases":return{arraystretch:1.2,leftDelim:".",rightDelim:"\\rbrace",columns:lH()};case"lines":return{leftDelim:".",rightDelim:".",columns:[{align:"l"}],isRoot:!0,minColumns:1,maxColumns:1,minRows:1}}return{mathstyleName:"textstyle"}}(e,i,a,o)),{rowRules:n}))}function lj(e,i=10){return null!=e?e:Array(i).fill({align:"c"})}function lH(e=10){let i=[];for(let r=0;r<e;r++)r>0&&i.push({gap:1}),i.push({align:"l"});return i}ex(Object.keys(lF),"{body:auto}",{createAtom:e=>new nT(g(f({},e),{body:et(e.args[0]),accentChar:lF[e.command.slice(1)]}))}),ex(["widehat","widecheck","widetilde"],"{body:auto}",{createAtom:e=>{let i=eb(et(e.args[0]));return new nT(g(f({},e),{body:et(e.args[0]),svgAccent:e.command.slice(1)+(i.length>5?"4":["1","1","2","2","3","3"][i.length])}))}}),ex(["overarc","overparen","wideparen"],"{body:auto}",{createAtom:e=>new nT(g(f({},e),{body:et(e.args[0]),svgAccent:"overarc"}))}),ex(["underarc","underparen"],"{body:auto}",{createAtom:e=>new lM(g(f({},e),{body:et(e.args[0]),svgBelow:"underarc"}))}),ex("utilde","{body:auto}",{createAtom:e=>{let i=et(e.args[0]),r=eb(i),a="widetilde"+(r.length>5?"4":["1","1","2","2","3","3"][r.length]);return new lM(g(f({},e),{body:i,svgBelow:a,boxType:oL(i)}))}}),ex("^","{:string}",{createAtom:e=>{var i;return new oG(g(f({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&null!=(i=({a:"â",e:"ê",i:"î",o:"ô",u:"û",A:"Â",E:"Ê",I:"Î",O:"Ô",U:"Û"})[e.args[0]])?i:"^"}))}}),ex("`","{:string}",{createAtom:e=>{var i;return new oG(g(f({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&null!=(i=({a:"à",e:"è",i:"ì",o:"ò",u:"ù",A:"À",E:"È",I:"Ì",O:"Ò",U:"Ù"})[e.args[0]])?i:"`"}))}}),ex("'","{:string}",{createAtom:e=>{var i;return new oG(g(f({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&null!=(i=({a:"á",e:"é",i:"í",o:"ó",u:"ú",A:"Á",E:"É",I:"Í",O:"Ó",U:"Ú"})[e.args[0]])?i:"'"}))}}),ex('"',"{:string}",{createAtom:e=>{var i,r;return new oG(g(f({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:null!=(i=e.args)&&i[0]?null!=(r=({a:"ä",e:"ë",i:"ï",o:"ö",u:"ü",A:"Ä",E:"Ë",I:"Ë",O:"Ö",U:"Ü"})[e.args[0]])?r:'"'+e.args[0]:'"'}))}}),ex(".","{:string}",{createAtom:e=>{var i,r;return new oG(g(f({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:null!=(i=e.args)&&i[0]?null!=(r=({a:"ȧ",e:"ė",i:"̇i",o:"ȯ",u:"̇u",A:"Ȧ",E:"Ė",I:"İ",O:"Ȯ",U:"̇U"})[e.args[0]])?r:"."+e.args[0]:"."}))}}),ex("=","{:string}",{createAtom:e=>{var i,r;return new oG(g(f({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:null!=(i=e.args)&&i[0]?null!=(r=({a:"ā",e:"ē",i:"ī",o:"ō",u:"ū",A:"Ā",E:"Ē",I:"Ī",O:"Ō",U:"Ū"})[e.args[0]])?r:"="+e.args[0]:"="}))}}),ex("~","{:string}",{createAtom:e=>{var i;return new oG(g(f({type:"mord"},e),{isFunction:!1,limits:"adjacent",value:e.args[0]&&null!=(i=({n:"ñ",N:"Ñ",a:"ã",o:"õ",A:"Ã",O:"Õ"})[e.args[0]])?i:"´"}))}}),ex("c","{:string}",{createAtom:e=>{var i;return new oG(g(f({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&null!=(i=({c:"ç",C:"Ç"})[e.args[0]])?i:""}))}}),ex("enclose","{notation:string}[style:string]{body:auto}",{createAtom:e=>{var i,r;let a=e.args,o={strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",backgroundcolor:"transparent",padding:"auto",shadow:"none",svgStrokeStyle:void 0,borderStyle:void 0,style:null!=(i=e.style)?i:{}};if(a[1]){for(let e of a[1].split(/,(?![^(]*\)(?:(?:[^(]*\)){2})*[^"]*$)/)){let i=e.match(/\s*(\S+)\s+(\S+)\s+(.*)/);if(i)o.strokeWidth=i[1],o.strokeStyle=i[2],o.strokeColor=i[3];else{let i=e.match(/\s*([a-z]*)\s*=\s*"(.*)"/);i&&("mathbackground"===i[1]?o.backgroundcolor=i[2]:"mathcolor"===i[1]?o.strokeColor=i[2]:"padding"===i[1]?o.padding=i[2]:"shadow"===i[1]&&(o.shadow=i[2]))}}"dashed"===o.strokeStyle?o.svgStrokeStyle="5,5":"dotted"===o.strokeStyle&&(o.svgStrokeStyle="1,5")}o.borderStyle=`${o.strokeWidth} ${o.strokeStyle} ${o.strokeColor}`;let n={};return(null!=(r=a[0])?r:"").split(/[, ]/).filter(e=>e.length>0).forEach(e=>{n[e.toLowerCase()]=!0}),new lf(e.command,et(a[2]),n,o)}}),ex("cancel","{body:auto}",{createAtom:e=>{var i;return new lf(e.command,et(e.args[0]),{updiagonalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:null!=(i=e.style)?i:{}})}}),ex("bcancel","{body:auto}",{createAtom:e=>{var i;return new lf(e.command,et(e.args[0]),{downdiagonalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:null!=(i=e.style)?i:{}})}}),ex("xcancel","{body:auto}",{createAtom:e=>{var i;return new lf(e.command,et(e.args[0]),{updiagonalstrike:!0,downdiagonalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:null!=(i=e.style)?i:{}})}}),ex("sout","{body:auto}",{createAtom:e=>{var i;return new lf(e.command,et(e.args[0]),{horizontalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:null!=(i=e.style)?i:{}})}}),ev(["math","displaymath"],lV),ev("center",lV),ey(["multline","multline*"],"",lV),ex("displaylines","",{parse:e=>{if(e.skipWhitespace(),!e.match("<{>"))return[];let i=[],r=[];for(e.mathlist.length>0&&i.push([e.mathlist]),e.beginContext({tabular:!0,root:!0});!(e.end()||e.match("<}>"));)e.matchColumnSeparator()||e.matchRowSeparator()?(i.push([r]),r=[]):r.push(...e.scan(e=>["<}>","&","\\cr","\\\\","\\tabularnewline"].includes(e)));e.endContext(),i.push([r]);let a=e.scan();return a.length>0&&i.push([a]),i},createAtom:e=>new nQ("lines",e.args,[],{leftDelim:".",rightDelim:".",columns:[{align:"l"}],classes:["ML__multiline_environment"],isRoot:!0,minColumns:1,maxColumns:1,minRows:1})}),ey("split","",lV),ey(["gather","gather*","gathered"],"",lV),ey(["equation","equation*","subequations"],"",lV),ev(["align","align*","eqnarray"],lV,{tabular:!0}),ey(["aligned"],"",lV),ey("array","{columns:colspec}",(e,i,r,a,o,n)=>new nQ(e,i,r,{columns:a[0],mathstyleName:"textstyle",rowRules:n})),ey(["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],"[columns:colspec]",lV),ey(["smallmatrix","smallmatrix*"],"[columns:colspec]",lV),ey(["cases","dcases","rcases"],"",lV),ex("piecewise","{count:string}",{parse:e=>{var i,r;let a=null!=(r=null==(i=e.scanArgument("string"))?void 0:i.trim())?r:"";return 0===a.length?(e.onError({code:"missing-argument",arg:"\\piecewise"}),["1"]):!/^[1-9]\d*$/.test(a)||Number(a)>100?(e.onError({code:"unexpected-token",arg:a}),["1"]):[a]},createAtom:e=>{var i;let r=Number.parseInt(null==(i=e.args)?void 0:i[0],10);return lV("cases",Array.from({length:Number.isInteger(r)&&r>0?Math.min(r,100):1},()=>[[new nU],[new nU]]))}}),ex(["overrightarrow","overleftarrow","Overrightarrow","overleftharpoon","overrightharpoon","overleftrightarrow","overlinesegment","overgroup"],"{:auto}",{createAtom:e=>{var i;return new lM(g(f({},e),{body:et(null==(i=e.args)?void 0:i[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"rel",svgAbove:e.command.slice(1)}))}}),ex("overbrace","{:auto}",{createAtom:e=>new lM(g(f({},e),{body:et(e.args[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"ord",svgAbove:e.command.slice(1)}))}),ex(["underrightarrow","underleftarrow","underleftrightarrow","underlinesegment","undergroup"],"{:auto}",{createAtom:e=>new lM(g(f({},e),{body:et(e.args[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"rel",svgBelow:e.command.slice(1)}))}),ex(["underbrace"],"{:auto}",{createAtom:e=>new lM(g(f({},e),{body:et(e.args[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"ord",svgBelow:e.command.slice(1)}))}),ex(["xrightarrow","longrightarrow","xleftarrow","longleftarrow","xRightarrow","xLeftarrow","xleftharpoonup","xleftharpoondown","xrightharpoonup","xrightharpoondown","xlongequal","xtwoheadleftarrow","xtwoheadrightarrow","xleftrightarrow","longleftrightarrow","xLeftrightarrow","xrightleftharpoons","longrightleftharpoons","xleftrightharpoons","xhookleftarrow","xhookrightarrow","xmapsto","xtofrom","xleftrightarrows","longleftrightarrows","xRightleftharpoons","longRightleftharpoons","xLeftrightharpoons","longLeftrightharpoons"],"[:auto]{:auto}",{createAtom:e=>{var i,r,a,o,n;return new lM(g(f({},e),{svgBody:e.command.slice(1),above:(null==(r=et(null==(i=e.args)?void 0:i[1]))?void 0:r.length)===0?void 0:et(null==(a=e.args)?void 0:a[1]),below:null!=(n=et(null==(o=e.args)?void 0:o[0]))?n:null,skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,paddedLabels:!0,boxType:"rel"}))},serialize:(e,i)=>e.command+(e.hasEmptyBranch("below")?"":`[${e.belowToLatex(i)}]`)+`{${e.aboveToLatex(i)}}${e.supsubToLatex(i)}`}),ex(["arccos","arcsin","arctan","arctg","arcctg","arg","ch","cos","cosh","cot","cotg","coth","ctg","cth","csc","cosec","deg","dim","exp","gcd","hom","inf","ker","lb","lg","ln","log","Pr","sec","sh","sin","sinh","sup","tan","tanh","tg","th","arcsec","arccsc","arsinh","arcosh","artanh","arcsech","arccsch"],"",{isFunction:!0,ifMode:"math",createAtom:e=>new lP(e.command.slice(1),g(f({},e),{limits:"adjacent",isFunction:!0,variant:"main",variantStyle:"up"}))}),ex(["liminf","limsup"],"",{ifMode:"math",createAtom:e=>new lP({"\\liminf":"lim inf","\\limsup":"lim sup"}[e.command],g(f({},e),{limits:"over-under",variant:"main"}))}),ex(["lim","mod"],"",{ifMode:"math",createAtom:e=>new lP(e.command.slice(1),g(f({},e),{limits:"over-under",variant:"main"}))}),ex(["det","max","min"],"",{ifMode:"math",isFunction:!0,createAtom:e=>new lP(e.command.slice(1),g(f({},e),{limits:"over-under",isFunction:!0,variant:"main"}))}),ex("ang","{:math}",{ifMode:"math",createAtom:e=>new oG(g(f({},e),{body:et(e.args[0])})),serialize:(e,i)=>`\\ang{${e.bodyToLatex(i)}}`,render:(e,i)=>{let r=e.createBox(i),a=r.caret;r.caret=void 0;let o=new oE("°",{style:g(f({},e.style),{variant:"normal",variantStyle:"up"})});return new oE([r,o],{type:"inner",isSelected:e.isSelected,caret:a})}}),ex("sqrt","[index:auto]{radicand:expression}",{ifMode:"math",createAtom:e=>new lC(g(f({},e),{body:et(e.args[1]),index:e.args[0]?et(e.args[0]):void 0}))}),ex(["frac","dfrac","tfrac","binom","dbinom","tbinom"],"{:expression}{:expression}",{ifMode:"math",createAtom:e=>{let i=f({},e),r=e.command,a=e.args;switch(r){case"\\dfrac":case"\\frac":case"\\tfrac":i.hasBarLine=!0;break;case"\\atopfrac":i.hasBarLine=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":i.hasBarLine=!1,i.leftDelim="(",i.rightDelim=")";break;case"\\cfrac":i.hasBarLine=!0,i.continuousFraction=!0}switch(r){case"\\dfrac":case"\\dbinom":i.mathstyleName="displaystyle";break;case"\\tfrac":case"\\tbinom":i.mathstyleName="textstyle"}return new ly(a[0]?et(a[0]):[new nU],a[1]?et(a[1]):[new nU],i)},serialize:(e,i)=>{let r=e.aboveToLatex(i),a=e.belowToLatex(i);return o$.compactSerialization&&/^[0-9]$/.test(r)&&/^[0-9]$/.test(a)?`${e.command}${r}${a}`:og(e.command,r,a)}}),ex("genfrac","{:string}{:string}{:string}{:string}{:expression}{:expression}",{ifMode:"math",createAtom:e=>{var i,r,a,o,n;let l=e.args,s=(null!=(i=l[0])?i:"").trim(),c=(null!=(r=l[1])?r:"").trim(),d=(null!=(a=l[2])?a:"").trim(),u=null!=(n=({0:"displaystyle",1:"textstyle",2:"scriptstyle",3:"scriptscriptstyle"})[(null!=(o=l[3])?o:"").trim()])?n:void 0;return new ly(l[4]?et(l[4]):[new nU],l[5]?et(l[5]):[new nU],g(f({},e),{leftDelim:s&&"."!==s?s:void 0,rightDelim:c&&"."!==c?c:void 0,hasBarLine:"0pt"!==d&&"0"!==d,mathstyleName:u}))}}),ex(["cfrac"],"[:string]{:expression}{:expression}",{ifMode:"math",createAtom:e=>{let i=f({},e),r=e.args;return i.hasBarLine=!0,i.continuousFraction=!0,"r"===r[0]&&(i.align="right"),"l"===r[0]&&(i.align="left"),new ly(r[1]?et(r[1]):[new nU],r[2]?et(r[2]):[new nU],i)},serialize:(e,i)=>{let r=e.aboveToLatex(i),a=e.belowToLatex(i);return og(e.command,r,a)}}),ex(["brace","brack"],"",{infix:!0,createAtom:e=>new ly(et(e.args[0]),et(e.args[1]),g(f({},e),{hasBarLine:!1,leftDelim:"\\brace"===e.command?"\\lbrace":"\\lbrack",rightDelim:"\\brace"===e.command?"\\rbrace":"\\rbrack"})),serialize:(e,i)=>of([e.aboveToLatex(i),e.command,e.belowToLatex(i)])}),ex(["over","atop","choose"],"",{infix:!0,createAtom:e=>{let i,r,a=e.args;return"\\choose"===e.command&&(i="(",r=")"),new ly(et(a[0]),et(a[1]),g(f({},e),{hasBarLine:"\\over"===e.command,leftDelim:i,rightDelim:r}))},serialize:(e,i)=>of([e.aboveToLatex(i),e.command,e.belowToLatex(i)])}),ex(["overwithdelims","atopwithdelims"],"{numer:auto}{denom:auto}{left-delim:delim}{right-delim:delim}",{infix:!0,createAtom:e=>{var i,r;let a=e.args;return new ly(et(a[0]),et(a[1]),g(f({},e),{leftDelim:null!=(i=a[2])?i:".",rightDelim:null!=(r=a[3])?r:".",hasBarLine:!1}))},serialize:(e,i)=>`${e.aboveToLatex(i)} ${e.command}${e.leftDelim}${e.rightDelim}${e.belowToLatex(i)}`}),ex("pdiff","{numerator}{denominator}",{ifMode:"math",createAtom:e=>new ly(et(e.args[0]),et(e.args[1]),g(f({},e),{hasBarLine:!0,numerPrefix:"∂",denomPrefix:"∂"})),serialize:(e,i)=>of([e.aboveToLatex(i),e.command,e.belowToLatex(i)])}),ex(["sum","prod","bigcup","bigcap","coprod","bigvee","bigwedge","biguplus","bigotimes","bigoplus","bigodot","bigsqcup","intop"],"",{ifMode:"math",createAtom:e=>new lw({coprod:"∐",bigvee:"⋁",bigwedge:"⋀",biguplus:"⨄",bigcap:"⋂",bigcup:"⋃",intop:"∫",prod:"∏",sum:"∑",bigotimes:"⨂",bigoplus:"⨁",bigodot:"⨀",bigsqcup:"⨆",smallint:"∫"}[e.command.slice(1)],g(f({},e),{limits:"auto",variant:"main"}))}),ex("smallint","",{ifMode:"math",createAtom:e=>new lP("∫",g(f({},e),{limits:"adjacent",variant:"main"}))});var lW={int:"∫",iint:"∬",iiint:"∭",iiiint:"⨌",oint:"∮",oiint:"∯",oiiint:"∰",intclockwise:"∱",varointclockwise:"∲",ointctrclockwise:"∳",intctrclockwise:"⨑",sqcup:"⊔",sqcap:"⊓",uplus:"⊎",wr:"≀",amalg:"⨿",Cap:"⋒",Cup:"⋓",doublecap:"⋒",doublecup:"⋓"};function lU(e,i){var r,a;e.skipFiller();let o=e.scanLiteralGroup();if(!o){let i=e.peek();null!=i&&i.startsWith("\\")&&(o=i,e.next())}let n=null!=(a=null==(r=e.scanArgument("string"))?void 0:r.trim())?a:"",l=(o.startsWith("\\")?o.slice(1):o).trim();return l&&n&&e.defineLocalMacro(l,{def:i?`\\operatorname*{${n}}`:`\\operatorname{${n}}`,args:0,captureSelection:!1}),[o,n]}function lJ(e){return new oG({type:"mord",mode:"math",command:e.command,value:"",args:e.args,style:e.style})}function lX(e,i){var r,a,o,n;let l=null!=(a=null==(r=e.args)?void 0:r[0])?a:"",s=null!=(n=null==(o=e.args)?void 0:o[1])?n:"",c=l.startsWith("\\")?l:`\\${l}`;return i?`\\DeclareMathOperator*{${c}}{${s}}`:`\\DeclareMathOperator{${c}}{${s}}`}ex(Object.keys(lW),"",{ifMode:"math",createAtom:e=>{let i=lW[e.command.slice(1)];return new lw(i,g(f({},e),{limits:"adjacent",variant:{"⋒":"ams","⋓":"ams"}[i]}))}}),ex(["Re","Im"],"",{ifMode:"math",createAtom:e=>new lP({"\\Re":"ℜ","\\Im":"ℑ"}[e.command],g(f({},e),{limits:"adjacent",isFunction:!0,variant:"fraktur"}))}),ex("middle","{:delim}",{ifMode:"math",createAtom:e=>{var i;return new lh(g(f({},e),{delim:null!=(i=e.args[0])?i:"|",size:1}))}}),ex("the","{:value}",{createAtom:e=>new oG(g(f({},e),{captureSelection:!0,verbatimLatex:null})),render:(e,i)=>{var r;let a=new oW({parent:i},e.style),o="";return e.isSelected&&(o+=" ML__selected"),new oE((null!=(r=oF(a.evaluate(e.args[0])))?r:"").split("").map(i=>new oE(i,{type:"ord",classes:o,mode:e.mode,isSelected:e.isSelected,style:f({variant:"main"},e.style)})),{type:"lift",style:e.style,caret:e.caret,isSelected:e.isSelected,classes:o}).wrap(a)},serialize:e=>{var i;return`\\the${null!=(i=oF(e.args[0]))?i:"\\relax"}`}}),ex("blank","{body:auto}",{ifMode:"math",isFunction:!0,createAtom:e=>new l$(et(e.args[0]),e)}),ex("DeclareMathOperator","",{ifMode:"math",parse:e=>lU(e,!1),createAtom:lJ,render:()=>null,serialize:e=>lX(e,!1)}),ex("DeclareMathOperator*","",{ifMode:"math",parse:e=>lU(e,!0),createAtom:lJ,render:()=>null,serialize:e=>lX(e,!0)}),ex("mathtip","{:auto}{:math}",{createAtom:e=>new lB(g(f({},e),{body:et(e.args[0]),tooltip:et(e.args[1]),content:"math"})),serialize:(e,i)=>i.skipStyles?e.bodyToLatex(i):`\\mathtip{${e.bodyToLatex(i)}}{${oG.serialize([e.tooltip],g(f({},i),{defaultMode:"math"}))}}`}),ex("texttip","{:auto}{:text}",{createAtom:e=>new lB(g(f({},e),{body:et(e.args[0]),tooltip:et(e.args[1]),content:"text"})),serialize:(e,i)=>i.skipStyles?e.bodyToLatex(i):`\\texttip{${e.bodyToLatex(i)}}{${oG.serialize([e.tooltip],g(f({},i),{defaultMode:"text"}))}}`}),ex("error","{:math}",{createAtom:e=>new oG(g(f({},e),{body:et(e.args[0])})),serialize:(e,i)=>`\\error{${e.bodyToLatex(i)}}`,render:(e,i)=>e.createBox(i,{classes:"ML__error"})}),ex("ensuremath","{:math}",{createAtom:e=>new oG(g(f({},e),{body:et(e.args[0])})),serialize:(e,i)=>`${e.command}{${e.bodyToLatex(g(f({},i),{defaultMode:"math"}))}}`}),ex("color","{:value}",{applyStyle:(e,i,r,a)=>{var o,n;return g(f({},e),{verbatimColor:null!=(o=oF(r[0]))?o:void 0,color:a.toColor(null!=(n=r[0])?n:{string:"red"})})}}),ex("textcolor","{:value}{content:auto*}",{applyStyle:(e,i,r,a)=>{var o,n;return g(f({},e),{verbatimColor:null!=(o=oF(r[0]))?o:void 0,color:a.toColor(null!=(n=r[0])?n:{string:"red"})})}}),ex("boxed","{content:math}",{createAtom:e=>new n8(g(f({},e),{body:et(e.args[0]),framecolor:{string:"black"}}))}),ex("colorbox","{:value}{:text*}",{applyStyle:(e,i,r,a)=>{var o,n;return g(f({},e),{verbatimBackgroundColor:null!=(o=oF(r[0]))?o:void 0,backgroundColor:a.toBackgroundColor(null!=(n=r[0])?n:{string:"yellow"})})}}),ex("fcolorbox","{frame-color:value}{background-color:value}{content:text}",{applyMode:"text",createAtom:e=>{var i,r;return new n8(g(f({},e),{body:et(e.args[2]),framecolor:null!=(i=e.args[0])?i:{string:"blue"},backgroundcolor:null!=(r=e.args[1])?r:{string:"yellow"}}))},serialize:(e,i)=>{var r,a;return i.skipStyles?e.bodyToLatex(g(f({},i),{defaultMode:"text"})):og(e.command,null!=(r=oF(e.framecolor))?r:"",null!=(a=oF(e.backgroundcolor))?a:"",e.bodyToLatex(g(f({},i),{defaultMode:"text"})))}}),ex("bbox","[:bbox]{body:auto}",{createAtom:e=>{var i;let r=e.args[0],a=et(e.args[1]);return new n8(r?g(f({},e),{body:a,padding:r.padding,border:r.border,backgroundcolor:null!=(i=r.backgroundcolor)?i:void 0}):g(f({},e),{body:a}))},serialize:(e,i)=>{var r,a;if(i.skipStyles)return e.bodyToLatex(i);let o=e.command;if(Number.isFinite(e.padding)||void 0!==e.border||void 0!==e.backgroundcolor){let i=[];e.padding&&i.push(null!=(r=oF(e.padding))?r:""),e.border&&i.push(`border: ${e.border}`),e.backgroundcolor&&i.push(null!=(a=oF(e.backgroundcolor))?a:""),o+=`[${i.join(",")}]`}return og(o,e.bodyToLatex(i))}}),ex(["displaystyle","textstyle","scriptstyle","scriptscriptstyle"],"{:rest}",{createAtom:e=>new oG(g(f({},e),{body:et(e.args[0])})),render:(e,i)=>{let r=new oW({parent:i,mathstyle:e.command.slice(1)},e.style),a=oG.createBox(r,e.body,{type:"lift"});return e.caret&&(a.caret=e.caret),e.bind(i,a)},serialize:(e,i)=>i.skipStyles?e.bodyToLatex(i):`{${of([e.command,e.bodyToLatex(i)])}}`}),ex(["tiny","scriptsize","footnotesize","small","normalsize","large","Large","LARGE","huge","Huge"],"",{applyStyle:(e,i)=>g(f({},e),{fontSize:{"\\tiny":1,"\\scriptsize":2,"\\footnotesize":3,"\\small":4,"\\normalsize":5,"\\large":6,"\\Large":7,"\\LARGE":8,"\\huge":9,"\\Huge":10}[i]})}),ex("selectfont","",{ifMode:"text",applyStyle:e=>e}),ex("bf","{:rest*}",{applyStyle:e=>g(f({},e),{fontSeries:"b",fontShape:"n",fontFamily:"roman"})}),ex(["boldsymbol","bm","bold"],"{:math*}",{applyMode:"math",applyStyle:e=>g(f({},e),{variantStyle:"bold"})}),ex("bfseries","{:rest*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontSeries:"b"})}),ex("mdseries","{:rest*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontSeries:"m"})}),ex("upshape","{:rest*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontShape:"n"})}),ex("slshape","{:rest*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontShape:"sl"})}),ex("scshape","{:rest*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontShape:"sc"})}),ex("textbf","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontSeries:"b"})}),ex("textmd","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontSeries:"m"})}),ex("textup","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontShape:"n"})}),ex("textnormal","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontShape:"n",fontSeries:"m"})}),ex("textsl","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontShape:"sl"})}),ex("textit","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontShape:"it"})}),ex("textsc","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontShape:"sc"})}),ex("textrm","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontFamily:"roman"})}),ex("textsf","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontFamily:"sans-serif"})}),ex("texttt","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontFamily:"monospace"})}),ex("mathbf","{:math*}",{applyMode:"math",applyStyle:e=>g(f({},e),{variant:"normal",variantStyle:"bold"})}),ex("mathit","{:math*}",{applyMode:"math",applyStyle:e=>g(f({},e),{variant:"main",variantStyle:"italic"})}),ex("mathnormal","{:math*}",{applyMode:"math",applyStyle:e=>g(f({},e),{variant:"normal",variantStyle:"italic"})}),ex("mathbfit","{:math*}",{applyMode:"math",applyStyle:e=>g(f({},e),{variant:"main",variantStyle:"bolditalic"})}),ex("mathrm","{:math*}",{applyMode:"math",applyStyle:e=>g(f({},e),{variant:"normal",variantStyle:"up"})}),ex("mathsf","{:math*}",{applyMode:"math",applyStyle:e=>g(f({},e),{variant:"sans-serif",variantStyle:"up"})}),ex("mathtt","{:math*}",{applyMode:"math",applyStyle:e=>g(f({},e),{variant:"monospace",variantStyle:"up"})}),ex("it","{:rest*}",{applyStyle:e=>g(f({},e),{fontSeries:"m",fontShape:"it",fontFamily:"roman",variantStyle:"italic"})}),ex("rmfamily","{:rest*}",{applyStyle:e=>g(f({},e),{fontFamily:"roman"})}),ex("sffamily","{:rest*}",{applyStyle:e=>g(f({},e),{fontFamily:"sans-serif"})}),ex("ttfamily","{:rest*}",{applyStyle:e=>g(f({},e),{fontFamily:"monospace"})}),ex(["Bbb","mathbb"],"{:math*}",{applyStyle:e=>g(f({},e),{variant:"double-struck",variantStyle:lq(e.variantStyle)})}),ex(["frak","mathfrak"],"{:math*}",{applyStyle:e=>g(f({},e),{variant:"fraktur",variantStyle:lq(e.variantStyle)})}),ex("mathcal","{:math*}",{applyStyle:e=>g(f({},e),{variant:"calligraphic",variantStyle:lq(e.variantStyle)})}),ex("mathscr","{:math*}",{applyStyle:e=>g(f({},e),{variant:"script",variantStyle:lq(e.variantStyle)})}),ex(["mbox","hbox"],"{:text}",{ifMode:"math",createAtom:e=>new oG(g(f({},e),{type:"mord",body:et(e.args[0]),mode:"math"})),serialize:(e,i)=>{var r;return og(null!=(r=e.command)?r:"\\mbox",e.bodyToLatex(g(f({},i),{defaultMode:"text"})))}}),ex("text","{:text}",{ifMode:"math",applyMode:"text"}),ex(["class","htmlClass"],"{name:string}{content:auto*}",{createAtom:e=>new oG(g(f({},e),{type:"mord",body:et(e.args[1])})),serialize:(e,i)=>!e.args[0]||i.skipStyles?e.bodyToLatex(i):`${e.command}{${e.args[0]}}{${e.bodyToLatex(i)}}`,render:(e,i)=>{var r;return e.createBox(i,{classes:null!=(r=e.args[0])?r:"",boxType:"lift"})}}),ex(["cssId","htmlId"],"{id:string}{content:auto*}",{createAtom:e=>new oG(g(f({},e),{type:"mord",body:et(e.args[1])})),serialize:(e,i)=>{var r;return!(null!=(r=e.args)&&r[0])||i.skipStyles?e.bodyToLatex(i):`${e.command}{${e.args[0]}}{${e.bodyToLatex(i)}}`},render:(e,i)=>{var r;let a=e.createBox(i);return a.cssId=null!=(r=e.args[0])?r:"",a}}),ex("htmlData","{data:string}{content:auto*}",{createAtom:e=>new oG(g(f({},e),{type:"mord",body:et(e.args[1])})),serialize:(e,i)=>{var r;return!(null!=(r=e.args)&&r[0])||i.skipStyles?e.bodyToLatex(i):`\\htmlData{${e.args[0]}}{${e.bodyToLatex(i)}}`},render:(e,i)=>{var r;let a=e.createBox(i);return a.htmlData=null!=(r=e.args[0])?r:"",a}}),ex(["style","htmlStyle"],"{data:string}{content:auto*}",{createAtom:e=>new oG(g(f({},e),{type:"mord",body:et(e.args[1])})),serialize:(e,i)=>{var r;return!(null!=(r=e.args)&&r[0])||i.skipStyles?e.bodyToLatex(i):`${e.command}{${e.args[0]}}{${e.bodyToLatex(i)}}`},render:(e,i)=>{var r;let a=e.createBox(i);return a.htmlStyle=null!=(r=e.args[0])?r:"",a}}),ex("href","{url:string}{content:auto*}",{createAtom:e=>new oG(g(f({},e),{type:"mord",body:et(e.args[1])})),render:(e,i)=>{var r;let a=e.createBox(i),o=null!=(r=e.args[0])?r:"";return o&&(a.htmlData=`href=${o}`),a}}),ex("em","{:rest}",{createAtom:e=>new oG(g(f({},e),{body:et(e.args[0])})),serialize:(e,i)=>i.skipStyles?e.bodyToLatex(i):`{\\em ${e.bodyToLatex(i)}}`,render:(e,i)=>e.createBox(i,{classes:"ML__emph",boxType:"lift"})}),ex("emph","{:auto}",{createAtom:e=>new oG(g(f({},e),{body:et(e.args[1])})),serialize:(e,i)=>i.skipStyles?e.bodyToLatex(i):`\\emph{${e.bodyToLatex(i)}}`,render:(e,i)=>e.createBox(i,{classes:"ML__emph",boxType:"lift"})});var lG={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}};ex(["bigl","Bigl","biggl","Biggl","bigr","Bigr","biggr","Biggr","bigm","Bigm","biggm","Biggm","big","Big","bigg","Bigg"],"{:delim}",{createAtom:e=>{var i;return new lp(g(f({},e),{delim:null!=(i=e.args[0])?i:".",size:lG[e.command].size,delimType:lG[e.command].mclass}))},serialize:(e,i)=>of([e.command,/^[a-zA-Z]/.test(e.value)?`{${e.value}}`:e.value])}),ex(["hspace","hspace*"],"{width:value}",{createAtom:e=>{var i;return new lL(g(f({},e),{width:null!=(i=e.args[0])?i:{dimension:0}}))}}),ex(["mkern","kern","mskip","hskip","mspace"],"{width:value}",{createAtom:e=>{var i;return new lL(g(f({},e),{width:null!=(i=e.args[0])?i:{dimension:0}}))}}),ex("\\","",{createAtom:e=>new lO(e)}),ex("mathchoice","{:math}{:math}{:math}{:math}",{createAtom:e=>new oG(e),render:(e,i)=>{let r=0,a=i.mathstyle.id;(5===a||4===a)&&(r=1),(3===a||2===a)&&(r=2),(1===a||0===a)&&(r=3);let o=et(e.args[r]);return oG.createBox(i,o)},serialize:(e,i)=>`\\mathchoice{${oG.serialize(e.args[0],i)}}{${oG.serialize(e.args[1],i)}}{${oG.serialize(e.args[2],i)}}{${oG.serialize(e.args[3],i)}}`}),ex("mathop","{:auto}",{createAtom:e=>new oG(g(f({},e),{type:"mop",body:et(e.args[0]),limits:"over-under",isFunction:!0,captureSelection:!0})),render:(e,i)=>{var r;let a=oG.createBox(i,e.body);if(e.superscript||e.subscript){let o=null!=(r=e.subsupPlacement)?r:"auto";a="over-under"===o||"auto"===o&&i.isDisplayStyle?e.attachLimits(i,{base:a}):e.attachSupsub(i,{base:a})}return e.caret&&(a.caret=e.caret),new oE(e.bind(i,a),{type:"op",isSelected:e.isSelected,classes:"ML__op-group"})},serialize:(e,i)=>{let r=[og(e.command,e.bodyToLatex(i))];return e.explicitSubsupPlacement&&("over-under"===e.subsupPlacement&&r.push("\\limits"),"adjacent"===e.subsupPlacement&&r.push("\\nolimits"),"auto"===e.subsupPlacement&&r.push("\\displaylimits")),r.push(e.supsubToLatex(i)),of(r)}}),ex(["mathbin","mathrel","mathopen","mathclose","mathpunct","mathord","mathinner"],"{:auto}",{createAtom:e=>new oG(g(f({},e),{type:{"\\mathbin":"mbin","\\mathrel":"mrel","\\mathopen":"mopen","\\mathclose":"mclose","\\mathpunct":"mpunct","\\mathord":"mord","\\mathinner":"minner"}[e.command],body:et(e.args[0])}))}),ex(["operatorname","operatorname*"],"{operator:math}",{createAtom:e=>{let i=et(e.args[0]).map(e=>{var i;return"first"!==e.type&&(e.type="mord",e.value=null!=(i=({"∗":"*","−":"-"})[e.value])?i:e.value,e.isFunction=!1,e.style.variant||e.style.variantStyle||(e.style.variant="main",e.style.variantStyle="up")),e});return new oG(g(f({},e),{type:"mop",body:i,isFunction:!0,limits:"\\operatorname"===e.command?"adjacent":"over-under"}))},render:(e,i)=>{var r;let a=oG.createBox(i,e.body);if(e.superscript||e.subscript){let o=null!=(r=e.subsupPlacement)?r:"auto";a="over-under"===o||"auto"===o&&i.isDisplayStyle?e.attachLimits(i,{base:a}):e.attachSupsub(i,{base:a})}return e.caret&&(a.caret=e.caret),new oE(e.bind(i,a),{type:"op",isSelected:e.isSelected,classes:"ML__op-group"})},serialize:(e,i)=>{let r=[og(e.command,e.bodyToLatex(i))];return e.explicitSubsupPlacement&&("over-under"===e.subsupPlacement&&r.push("\\limits"),"adjacent"===e.subsupPlacement&&r.push("\\nolimits"),"auto"===e.subsupPlacement&&r.push("\\displaylimits")),r.push(e.supsubToLatex(i)),of(r)}}),ex(["char","unicode"],"{charcode:value}",{createAtom:e=>new oG(g(f({},e),{type:"text"===e.mode?"text":"mord"})),serialize:e=>{var i;return`${e.command}${oF(null!=(i=e.args[0])?i:{number:10067,base:"hexadecimal"})}`},render:(e,i)=>{let r=i.evaluate(e.args[0]);return r&&"number"in r||(r={number:10067,base:"hexadecimal"}),e.value=String.fromCodePoint(r.number),e.createBox(i)}}),ex("rule","[raise:value]{width:value}{thickness:value}",{createAtom:e=>new oG(e),render:(e,i)=>{var r,a,o;let n=new oW({parent:i,mathstyle:"textstyle"},e.style),l=n.toEm(null!=(r=e.args[0])?r:{dimension:0}),s=n.toEm(null!=(a=e.args[1])?a:{dimension:10}),c=n.toEm(null!=(o=e.args[2])?o:{dimension:10}),d=new oE(null,{classes:"ML__rule",type:"ord"});return d.width=s,d.height=c+l,d.depth=-l,d.setStyle("border-right-width",s,"em"),d.setStyle("border-top-width",c,"em"),d.setStyle("border-color",e.style.color),d.setStyle("vertical-align",l,"em"),e.isSelected&&d.setStyle("opacity","50%"),e.bind(n,d),e.caret&&(d.caret=e.caret),d.wrap(i)},serialize:e=>`\\rule${e.args[0]?`[${oF(e.args[0])}]`:""}{${oF(e.args[1])}}{${oF(e.args[2])}}`}),ex(["overline","underline"],"{:auto}",{createAtom:e=>new oG(g(f({},e),{body:et(e.args[0])})),render:(e,i)=>{let r,a=e.command.substring(1),o=new oW({parent:i,mathstyle:"cramp"},e.style),n=oG.createBox(o,e.body);if(!n)return null;let l=o.metrics.defaultRuleThickness/o.scalingFactor,s=new oE(null,{classes:a+"-line"});return s.height=l,s.maxFontSize=1.125*l*o.scalingFactor,r=new oB("overline"===a?{shift:0,children:[{box:n},3*l,{box:s},l]}:{top:n.height,children:[l,{box:s},3*l,{box:n}]}),e.caret&&(r.caret=e.caret),new oE(r,{classes:a,type:"ignore"})}}),ex("overset","{:auto}{base:auto}",{createAtom:e=>{let i=et(e.args[1]);return new lM(g(f({},e),{above:et(e.args[0]),body:i,skipBoundary:!1,boxType:oL(i)}))},serialize:(e,i)=>og(e.command,e.aboveToLatex(i),e.bodyToLatex(i))}),ex("underset","{:auto}{base:auto}",{createAtom:e=>{let i=et(e.args[1]);return new lM(g(f({},e),{below:et(e.args[0]),body:i,skipBoundary:!1,boxType:oL(i)}))},serialize:(e,i)=>og(e.command,e.belowToLatex(i),e.bodyToLatex(i))}),ex("overunderset","{above:auto}{below:auto}{base:auto}",{createAtom:e=>{let i=et(e.args[2]);return new lM(g(f({},e),{above:et(e.args[0]),below:et(e.args[1]),body:i,skipBoundary:!1,boxType:oL(i)}))},serialize:(e,i)=>og(e.command,e.belowToLatex(i),e.bodyToLatex(i))}),ex(["stackrel","stackbin"],"[below:auto]{above:auto}{base:auto}",{createAtom:e=>new lM(g(f({},e),{body:et(e.args[2]),above:et(e.args[1]),below:et(e.args[0]),skipBoundary:!1,boxType:"\\stackrel"===e.command?"rel":"bin"})),serialize:(e,i)=>og(e.command,e.aboveToLatex(i),e.bodyToLatex(i))}),ex("smash","[:string]{:auto}",{createAtom:e=>{var i,r,a,o;return new lS(g(f({},e),{body:et(e.args[1]),smashHeight:null==(r=null==(i=e.args[0])?void 0:i.includes("t"))||r,smashDepth:null==(o=null==(a=e.args[0])?void 0:a.includes("b"))||o}))}}),ex("vphantom","{:auto}",{createAtom:e=>new lS(g(f({},e),{body:et(e.args[0]),isInvisible:!0,smashWidth:!0}))}),ex("hphantom","{:auto}",{createAtom:e=>new lS(g(f({},e),{body:et(e.args[0]),isInvisible:!0,smashHeight:!0,smashDepth:!0}))}),ex("phantom","{:auto}",{createAtom:e=>new lS(g(f({},e),{body:et(e.args[0]),isInvisible:!0}))}),ex("mathstrut","",{createAtom:e=>new lS(g(f({},e),{body:[new oG({value:"("})],isInvisible:!0}))}),ex("not","{:math}",{createAtom:e=>{let i=et(e.args[0]);return new oG(0===i.length?g(f({},e),{type:"mrel",value:""}):g(f({},e),{body:[new lk(g(f({},e),{body:"",align:"right"})),...i],captureSelection:!0}))},serialize:(e,i)=>{let r=e.args[0],a=r&&"object"==typeof r&&"group"in r;return""!==e.value?a?`\\not{${oG.serialize(r.group,i)}}`:`\\not${oG.serialize(r,i)}`:a?"\\not{}":"\\not"},render:(e,i)=>{if(e.value)return e.createBox(i);let r=e.args[0]&&"object"==typeof e.args[0]&&"group"in e.args[0]?"ord":oL(et(e.args[0])),a=oG.createBox(i,e.body,{type:r});return e.caret&&(a.caret=e.caret),e.bind(i,a)}}),ex(["ne","neq"],"",{createAtom:e=>new oG(g(f({},e),{type:"mrel",body:[new lk(g(f({},e),{body:"",align:"right",boxType:"rel"})),new oG(g(f({},e),{value:"="}))],captureSelection:!0})),serialize:e=>e.command}),ex("rlap","{:auto}",{createAtom:e=>new lk(g(f({},e),{body:et(e.args[0]),align:"right"}))}),ex("llap","{:auto}",{createAtom:e=>new lk(g(f({},e),{body:et(e.args[0]),align:"left"}))}),ex("mathrlap","{:math}",{createAtom:e=>new lk(g(f({},e),{body:et(e.args[0]),align:"right"}))}),ex("mathllap","{:math}",{createAtom:e=>new lk(g(f({},e),{body:et(e.args[0]),align:"left"}))}),ex("clap","{:auto}",{createAtom:e=>new lk(g(f({},e),{body:et(e.args[0]),align:"center"}))}),ex("mathclap","{:math}",{createAtom:e=>new lk(g(f({},e),{body:et(e.args[0]),align:"center"}))}),ex("raisebox","{:value}{:text}",{createAtom:e=>{var i;return new n8(g(f({},e),{body:et(e.args[1]),padding:{dimension:0},offset:null!=(i=e.args[0])?i:{dimension:0}}))},serialize:(e,i)=>{var r;return og("\\raisebox",null!=(r=oF(e.offset))?r:"0pt",e.bodyToLatex(i))}}),ex("raise","{:value}{:auto}",{createAtom:e=>{var i;return new n8(g(f({},e),{body:et(e.args[1]),padding:{dimension:0},offset:null!=(i=e.args[0])?i:{dimension:0}}))},serialize:(e,i)=>{var r;return og("\\raise",null!=(r=oF(e.offset))?r:"0pt",e.bodyToLatex(i))}}),ex("lower","{:value}{:auto}",{createAtom:e=>{var i;return new n8(g(f({},e),{body:et(e.args[1]),padding:{dimension:0},offset:null!=(i=oV(e.args[0],-1))?i:{dimension:0}}))},serialize:(e,i)=>{var r,a;return og("\\lower",null!=(a=oF(oV(null!=(r=e.offset)?r:{dimension:0},-1)))?a:"0pt",e.bodyToLatex(i))}}),eh("0123456789/@.?!"),ep(65,90),ep(97,122),eh([["\\forall",8704],["\\exists",8707],["\\nexists",8708,"mord","ams"],["\\mid",8739,"mrel"],["\\top",8868],["\\bot",8869]]),eh([["\\#",35],["\\&",38],["\\parallelogram",9649],["\\spadesuit",9824],["\\heartsuit",9825],["\\diamondsuit",9826],["\\clubsuit",9827],["\\flat",9837],["\\natural",9838],["\\sharp",9839]]),eh([["\\backslash",92],["\\nabla",8711],["\\partial",8706],["\\ell",8467],["\\hbar",8463],["\\pounds",163],["\\euro",8364]]),eh([["\\rightarrow",8594],["\\to",8594],["\\leftarrow",8592],["\\gets",8592],["\\Rightarrow",8658],["\\Leftarrow",8656],["\\longrightarrow",10230],["\\longleftarrow",10229],["\\Longrightarrow",10233],["\\implies",10233],["\\Longleftarrow",10232],["\\impliedby",10232],["\\longleftrightarrow",10231],["\\biconditional",10231],["\\Longleftrightarrow",10234],["\\mapsto",8614],["\\longmapsto",10236],["\\uparrow",8593],["\\downarrow",8595],["\\Uparrow",8657],["\\Downarrow",8659],["\\updownarrow",8597],["\\Updownarrow",8661],["\\hookrightarrow",8618],["\\hookleftarrow",8617],["\\rightharpoonup",8640],["\\leftharpoonup",8636],["\\rightharpoondown",8641],["\\leftharpoondown",8637],["\\searrow",8600],["\\nearrow",8599],["\\swarrow",8601],["\\nwarrow",8598],["\\originalof",8886],["\\laplace",8886],["\\imageof",8887],["\\Laplace",8887]],"mrel"),eh([["\\mapsfrom",8612,"mrel"],["\\Mapsfrom",10502,"mrel"],["\\MapsTo",10503,"mrel"],["\\Yup",8516,"mord"],["\\lightning",8623,"mrel"],["\\leftarrowtriangle",8701,"mrel"],["\\rightarrowtriangle",8702,"mrel"],["\\leftrightarrowtriangle",8703,"mrel"],["\\boxdot",8865,"mbin"],["\\bigtriangleup",9651,"mbin"],["\\bigtriangledown",9661,"mbin"],["\\boxbar",9707,"mbin"],["\\Lbag",10181,"mopen"],["\\Rbag",10182,"mclose"],["\\llbracket",10214,"mopen"],["\\rrbracket",10215,"mclose"],["\\longmapsfrom",10235,"mrel"],["\\Longmapsfrom",10237,"mrel"],["\\Longmapsto",10238,"mrel"],["\\boxslash",10692,"mbin"],["\\boxbslash",10693,"mbin"],["\\boxast",10694,"mbin"],["\\boxcircle",10695,"mbin"],["\\boxbox",10696,"mbin"],["\\fatsemi",10783,"mop"],["\\leftslice",10918,"mrel"],["\\rightslice",10919,"mrel"],["\\interleave",10996,"mbin"],["\\biginterleave",11004,"mop"],["\\sslash",11005,"mbin"],["\\talloblong",11006,"mbin"]]),eh([["\\lbrace",123,"mopen"],["\\rbrace",125,"mclose"],["\\lparen",40,"mopen"],["\\rparen",41,"mclose"],["\\langle",10216,"mopen"],["\\rangle",10217,"mclose"],["\\lfloor",8970,"mopen"],["\\rfloor",8971,"mclose"],["\\lceil",8968,"mopen"],["\\rceil",8969,"mclose"],["\\vert",8739],["\\lvert",8739,"mopen"],["\\rvert",8739,"mclose"],["\\|",8741],["\\Vert",8741],["\\mVert",8741],["\\lVert",8741,"mopen"],["\\rVert",8741,"mclose"],["\\lbrack",91,"mopen"],["\\rbrack",93,"mclose"],["\\{",123,"mopen"],["\\}",125,"mclose"],["(",40,"mopen"],[")",41,"mclose"],["[",91,"mopen"],["]",93,"mclose"],["\\ulcorner",9484,"mopen","ams"],["\\urcorner",9488,"mclose","ams"],["\\llcorner",9492,"mopen","ams"],["\\lrcorner",9496,"mclose","ams"],["\\lgroup",10222,"mopen"],["\\rgroup",10223,"mclose"],["\\lmoustache",9136,"mopen"],["\\rmoustache",9137,"mclose"]]),eh([["\\dashrightarrow",8674],["\\dashleftarrow",8672],["\\Rrightarrow",8667],["\\Lleftarrow",8666],["\\leftrightarrows",8646],["\\rightleftarrows",8644],["\\curvearrowright",8631],["\\curvearrowleft",8630],["\\rightrightarrows",8649],["\\leftleftarrows",8647],["\\upuparrows",8648],["\\downdownarrows",8650],["\\vartriangle",9651],["\\triangleq",8796],["\\vartriangleleft",8882],["\\trianglelefteq",8884],["\\ntriangleleft",8938],["\\ntrianglelefteq",8940],["\\vartriangleright",8883],["\\trianglerighteq",8885],["\\ntriangleright",8939],["\\ntrianglerighteq",8941],["\\blacktriangleleft",9664],["\\blacktriangleright",9654],["\\leftarrowtail",8610],["\\rightarrowtail",8611],["\\looparrowright",8620],["\\looparrowleft",8619],["\\twoheadleftarrow",8606],["\\twoheadrightarrow",8608],["\\twoheadrightarrowtail",10518],["\\rightleftharpoons",8652],["\\leftrightharpoons",8651],["\\Rsh",8625],["\\Lsh",8624],["\\circlearrowright",8635],["\\circlearrowleft",8634],["\\restriction",8638],["\\upharpoonright",8638],["\\upharpoonleft",8639],["\\downharpoonright",8642],["\\downharpoonleft",8643],["\\rightsquigarrow",8669],["\\leadsto",8669],["\\leftrightsquigarrow",8621],["\\multimap",8888],["\\nleftarrow",8602],["\\nrightarrow",8603],["\\nRightarrow",8655],["\\nLeftarrow",8653],["\\nleftrightarrow",8622],["\\nLeftrightarrow",8654],["\\nvrightarrow",8696],["\\nvtwoheadrightarrow",10496],["\\nvrightarrowtail",10516],["\\nvtwoheadrightarrowtail",10519],["\\shortparallel",8741],["\\nless",8814],["\\nleqslant",57360],["\\lneq",10887],["\\lneqq",8808],["\\nleqq",57361],["\\lvertneqq",57356],["\\lnsim",8934],["\\lnapprox",10889],["\\nprec",8832],["\\npreceq",8928],["\\precnsim",8936],["\\precnapprox",10937],["\\nsim",8769],["\\nshortmid",57350],["\\nmid",8740],["\\nvdash",8876],["\\nvDash",8877],["\\ngtr",8815],["\\ngeqslant",57359],["\\ngeqq",57358],["\\gneq",10888],["\\gneqq",8809],["\\gvertneqq",57357],["\\gnsim",8935],["\\gnapprox",10890],["\\nsucc",8833],["\\nsucceq",8929],["\\succnsim",8937],["\\succnapprox",10938],["\\ncong",8774],["\\nshortparallel",57351],["\\nparallel",8742],["\\nVDash",8879],["\\nsupseteqq",57368],["\\supsetneq",8843],["\\varsupsetneq",57371],["\\supsetneqq",10956],["\\varsupsetneqq",57369],["\\nVdash",8878],["\\precneqq",10933],["\\succneqq",10934],["\\nsubseteqq",57366],["\\leqslant",10877],["\\geqslant",10878],["\\gtrsim",8819],["\\approxeq",8778],["\\thickapprox",8776],["\\lessapprox",10885],["\\gtrapprox",10886],["\\precapprox",10935],["\\succapprox",10936],["\\thicksim",8764],["\\succsim",8831],["\\precsim",8830],["\\backsim",8765],["\\eqsim",8770],["\\backsimeq",8909],["\\lesssim",8818],["\\nleq",8816],["\\ngeq",8817],["\\smallsmile",8995],["\\smallfrown",8994],["\\leqq",8806],["\\eqslantless",10901],["\\lll",8920],["\\lessgtr",8822],["\\lesseqgtr",8922],["\\lesseqqgtr",10891],["\\risingdotseq",8787],["\\fallingdotseq",8786],["\\subseteqq",10949],["\\Subset",8912],["\\sqsubset",8847],["\\preccurlyeq",8828],["\\curlyeqprec",8926],["\\vDash",8872],["\\Vvdash",8874],["\\bumpeq",8783],["\\Bumpeq",8782],["\\geqq",8807],["\\eqslantgtr",10902],["\\ggg",8921],["\\gtrless",8823],["\\gtreqless",8923],["\\gtreqqless",10892],["\\supseteqq",10950],["\\Supset",8913],["\\sqsupset",8848],["\\succcurlyeq",8829],["\\curlyeqsucc",8927],["\\Vdash",8873],["\\shortmid",8739],["\\between",8812],["\\pitchfork",8916],["\\varpropto",8733],["\\backepsilon",8717],["\\llless",8920],["\\gggtr",8921],["\\doteqdot",8785],["\\Doteq",8785],["\\eqcirc",8790],["\\circeq",8791],["\\therefore",8756],["\\because",8757]],"mrel","ams"),eh([["+",43],["-",8722],["−",8722],["\\pm",177],["\\mp",8723],["*",8727],["\\times",215],["\\div",247],["\\divides",8739],["\\cdot",8901],["\\cap",8745],["\\cup",8746],["\\setminus",8726],["\\land",8743],["\\wedge",8743],["\\lor",8744],["\\vee",8744],["\\circ",8728],["\\bigcirc",9711],["\\bullet",8729],["\\oplus",8853],["\\ominus",8854],["\\otimes",8855],["\\odot",8857],["\\oslash",8856],["\\bigtriangleup",9651],["\\bigtriangledown",9661],["\\triangleleft",9667],["\\triangleright",9657],["\\And",38],["\\dagger",8224],["\\dag",8224],["\\ddag",8225],["\\ddagger",8225],["\\ast",8727],["\\star",8902],["\\bigstar",9733],["\\diamond",8900]],"mbin"),eh([["\\lhd",8882],["\\rhd",8883],["\\lessdot",8918],["\\gtrdot",8919],["\\ltimes",8905],["\\rtimes",8906],["\\leftthreetimes",8907],["\\rightthreetimes",8908],["\\intercal",8890],["\\dotplus",8724],["\\doublebarwedge",10846],["\\divideontimes",8903],["\\centerdot",8901],["\\smallsetminus",8726],["\\barwedge",8892],["\\veebar",8891],["\\nor",8891],["\\curlywedge",8911],["\\curlyvee",8910],["\\boxminus",8863],["\\boxplus",8862],["\\boxtimes",8864],["\\boxdot",8865],["\\circleddash",8861],["\\circledast",8859],["\\circledcirc",8858],["\\unlhd",8884],["\\unrhd",8885]],"mbin","ams"),eh([["\\surd",8730],["\\S",167],["\\infty",8734],["\\prime",8242],["\\doubleprime",8243],["\\angle",8736],["`",8216],["\\$",36],["\\%",37],["\\_",95],["\\alpha",945],["\\beta",946],["\\gamma",947],["\\delta",948],["\\epsilon",1013],["\\varepsilon",949],["\\zeta",950],["\\eta",951],["\\theta",952],["\\vartheta",977],["\\iota",953],["\\kappa",954],["\\varkappa",1008,"mord","ams"],["\\lambda",955],["\\mu",956],["\\nu",957],["\\xi",958],["\\omicron",111],["\\pi",960],["\\varpi",982],["\\rho",961],["\\varrho",1009],["\\sigma",963],["\\varsigma",962],["\\tau",964],["\\phi",981],["\\varphi",966],["\\upsilon",965],["\\chi",967],["\\psi",968],["\\omega",969],["\\Gamma",915],["\\Delta",916],["\\Theta",920],["\\Lambda",923],["\\Xi",926],["\\Pi",928],["\\Sigma",931],["\\Upsilon",933],["\\Phi",934],["\\Psi",936],["\\Omega",937],["\\digamma",989,"mord","ams"],["\\varkappa",1008,"mord","ams"],["\\coppa",985,"mord","ams"],["\\koppa",985,"mord","ams"],["\\Coppa",984,"mord","ams"],["\\Koppa",984,"mord","ams"],["\\sampi",993,"mord","ams"],["\\Sampi",992,"mord","ams"],["\\emptyset",8709]]),eh([["=",61],["<",60],["\\lt",60],[">",62],["\\gt",62],["\\le",8804],["\\leq",8804],["\\ge",8805],["\\geq",8805],["\\ll",8810],["\\gg",8811],["\\coloneq",8788],["\\coloneqq",8788],["\\colonequals",8788],["\\measeq",8797],["\\eqdef",8798],["\\questeq",8799],[":",58],["\\cong",8773],["\\equiv",8801],["\\prec",8826],["\\preceq",10927],["\\succ",8827],["\\succeq",10928],["\\perp",10178],["\\propto",8733],["\\Colon",8759],["\\smile",8995],["\\frown",8994],["\\sim",8764],["\\doteq",8784],["\\bowtie",8904],["\\Join",8904],["\\asymp",8781],["\\sqsubseteq",8849],["\\sqsupseteq",8850],["\\approx",8776],["\\~",126],["\\leftrightarrow",8596],["\\Leftrightarrow",8660],["\\models",8872],["\\vdash",8866],["\\dashv",8867],["\\roundimplies",10608],["\\in",8712],["\\notin",8713],["\\ni",8715],["\\owns",8715],["\\subset",8834],["\\supset",8835],["\\subseteq",8838],["\\supseteq",8839],["\\differencedelta",8710],["\\mvert",8739],["\\parallel",8741],["\\simeq",8771]],"mrel"),eh([["\\lnot",172],["\\neg",172],["\\triangle",9651],["\\subsetneq",8842],["\\varsubsetneq",57370],["\\subsetneqq",10955],["\\varsubsetneqq",57367],["\\nsubset",8836],["\\nsupset",8837],["\\nsubseteq",8840],["\\nsupseteq",8841]],"mrel","ams"),eh([["\\wp",8472],["\\aleph",8501]]),eh([["\\blacktriangle",9650],["\\hslash",8463],["\\Finv",8498],["\\Game",8513],["\\eth",240],["\\mho",8487],["\\Bbbk",107],["\\yen",165],["\\square",9633],["\\Box",9633],["\\blacksquare",9632],["\\circledS",9416],["\\circledR",174],["\\triangledown",9661],["\\blacktriangledown",9660],["\\checkmark",10003],["\\diagup",9585],["\\measuredangle",8737],["\\sphericalangle",8738],["\\backprime",8245],["\\backdoubleprime",8246],["\\Diamond",9674],["\\lozenge",9674],["\\blacklozenge",10731],["\\varnothing",8709],["\\complement",8705],["\\maltese",10016],["\\beth",8502],["\\daleth",8504],["\\gimel",8503]],"mord","ams"),eh([["\\ ",160],["~",160]],"space"),ex(["!",",",":",";",">","enskip","enspace","quad","qquad","thinspace","negthinspace","medspace","negmedspace","thickspace","negthickspace"],"",{createAtom:e=>new lL(e)}),ex("space","",{createAtom:e=>new lL(e)}),eh([["\\colon",58],["\\cdotp",8901],["\\vdots",8942,"mord"],["\\ldotp",46],[",",44],[";",59]],"mpunct"),eh([["\\cdots",8943],["\\ddots",8945],["\\ldots",8230],["\\dots",8230],["\\mathellipsis",8230]],"minner"),eh([["\\/",47],["|",8739,"mord"],["\\imath",305],["\\jmath",567],["\\degree",176],["'",8242],['"',8221]]);var lZ={main:["Main-Regular","ML__cmr"],"main-italic":["Main-Italic","ML__cmr ML__it"],"main-bold":["Main-Bold","ML__cmr ML__bold"],"main-bolditalic":["Main-BoldItalic","ML__cmr ML__bold ML__it"],normal:["Main-Regular","ML__cmr"],"normal-bold":["Main-Bold","ML__mathbf"],"normal-italic":["Math-Italic","ML__mathit"],"normal-bolditalic":["Math-BoldItalic","ML__mathbfit"],roman:["Main-Regular","ML__cmr"],"roman-bold":["Main-Bold","ML__mathbf"],"roman-italic":["Math-Italic","ML__mathit"],"roman-bolditalic":["Math-BoldItalic","ML__mathbfit"],ams:["AMS-Regular","ML__ams"],"ams-bold":["AMS-Regular","ML__ams ML__bold"],"ams-italic":["AMS-Regular","ML__ams ML__it"],"ams-bolditalic":["AMS-Regular","ML__ams ML__bold ML__it"],"sans-serif":["SansSerif-Regular","ML__sans"],"sans-serif-bold":["SansSerif-Regular","ML__sans ML__bold"],"sans-serif-italic":["SansSerif-Regular","ML__sans ML__it"],"sans-serif-bolditalic":["SansSerif-Regular","ML__sans ML__bold ML__it"],calligraphic:["Caligraphic-Regular","ML__cal"],"calligraphic-bold":["Caligraphic-Regular","ML__cal ML__bold"],"calligraphic-italic":["Caligraphic-Regular","ML__cal ML__it"],"calligraphic-bolditalic":["Caligraphic-Regular","ML__cal ML__bold ML__it"],script:["Script-Regular","ML__script"],"script-bold":["Script-Regular","ML__script ML__bold"],"script-italic":["Script-Regular","ML__script ML__it"],"script-bolditalic":["Script-Regular","ML__script ML__bold ML__it"],fraktur:["Fraktur-Regular","ML__frak"],"fraktur-bold":["Fraktur-Regular","ML__frak ML__bold"],"fraktur-italic":["Fraktur-Regular","ML__frak ML__it"],"fraktur-bolditalic":["Fraktur-Regular","ML__frak ML__bold ML__it"],monospace:["Typewriter-Regular","ML__tt"],"monospace-bold":["Typewriter-Regular","ML__tt ML__bold"],"monospace-italic":["Typewriter-Regular","ML__tt ML__it"],"monospace-bolditalic":["Typewriter-Regular","ML__tt ML__bold ML__it"],"double-struck":["AMS-Regular","ML__bb"],"double-struck-bold":["AMS-Regular","ML__bb ML__bold"],"double-struck-italic":["AMS-Regular","ML__bb ML_italic"],"double-struck-bolditalic":["AMS-Regular","ML__bb ML_bolditalic"]},lY={"double-struck":/^[A-Z ]$/,script:/^[A-Z ]$/,calligraphic:/^[\dA-Z ]$/,fraktur:/^[\dA-Za-z ]$|^[!"#$%&'()*+,\-./:;=?[]^’‘]$/,monospace:/^[\dA-Za-z ]$|^[!"&'()*+,\-./:;=?@[\]^_~\u0131\u0237\u0393\u0394\u0398\u039B\u039E\u03A0\u03A3\u03A5\u03A8\u03A9]$/,"sans-serif":/^[\dA-Za-z ]$|^[!"&'()*+,\-./:;=?@[\]^_~\u0131\u0237\u0393\u0394\u0398\u039B\u039E\u03A0\u03A3\u03A5\u03A8\u03A9]$/},lQ=/^[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5]$/,l0=[/^[a-z]$/,/^[A-Z]$/,lQ,/^[\u0393|\u0394\u0398\u039B\u039E\u03A0\u03A3\u03A5\u03A6\u03A8\u03A9]$/],l1={iso:["it","it","it","it"],tex:["it","it","it","up"],french:["it","up","up","up"],upright:["up","up","up","up"]};function l4(e,i){let{parent:r}=e[0],a=ow(r);return ok(e,"variant").map(e=>{let r=ow(e[0]),o="";r&&r!==a&&(o=({calligraphic:"\\mathcal","calligraphic-uo":"\\mathcal",fraktur:"\\mathfrak","fraktur-uo":"\\mathfrak","double-struck":"\\mathbb","double-struck-uo":"\\mathbb",script:"\\mathscr","script-uo":"\\mathscr",monospace:"\\mathtt","monospace-uo":"\\mathtt","sans-serif":"\\mathsf","sans-serif-uo":"\\mathsf",normal:"","normal-up":"\\mathrm","normal-italic":"\\mathnormal","normal-bold":"","normal-bolditalic":"\\mathbfit",ams:"","ams-up":"\\mathrm","ams-italic":"\\mathit","ams-bold":"","ams-bolditalic":"\\mathbfit",main:"","main-up":"\\mathrm","main-italic":"\\mathit","main-bold":"","main-bolditalic":"\\mathbfit"})[r]);let n="",l=e[e.length-1],s=o&&e.length>0&&(void 0!==l.branch("subscript")||void 0!==l.branch("superscript"));s&&(n=l.supsubToLatex(i));let c=of(e.map((r,a)=>{if(s&&a===e.length-1){let e=eM(r.command,r.mode);return null!=e&&e.serialize?e.serialize(r,i):r.body&&r.command?og(r.command,r.bodyToLatex(i)):r.body?r.bodyToLatex(i):r.value&&""!==r.value?r.command||r.value:""}return r._serialize(i)}));return o?og(o,c)+n:c})}new class extends ov{constructor(){super("math")}createAtom(e,i,r){var a,o,n,l,s,c;let d;if(null===i)return new oG({type:"mord",mode:"math",command:e,value:e,style:r});try{d=null!=(n=null==(o=globalThis.MathfieldElement)?void 0:o.isFunction(null!=(a=i.command)?a:e))&&n}catch(e){d=!1}if("symbol"===i.definitionType){let a=new oG({type:null!=(l=i.type)?l:"mord",mode:"math",command:null!=(s=i.command)?s:e,value:String.fromCodePoint(i.codepoint),isFunction:d,style:r});return e.startsWith("\\")&&(a.verbatimLatex=e),a}let u=new oG({type:"mord",mode:"math",command:null!=(c=i.command)?c:e,value:e,isFunction:d,style:r});return e.startsWith("\\")&&(u.verbatimLatex=e),u}serialize(e,i){var r,a;let o=(r=e,a=g(f({},i),{defaultMode:"math"}),ok(r,"bold").map(e=>{if("bold"!==o_(e[0])||"bold"===o_(e[0].parent))return of(l4(e,a));let i=of(e.map(e=>{var i;return null!=(i=e.value)?i:""}));return/^[a-zA-Z0-9]+$/.test(i)?og("\\mathbf",of(l4(e,a))):og("\\bm",of(l4(e,a)))}));return 0===o.length||"text"!==i.defaultMode?o:["$ ",...o," $"]}getFont(e,i){var r,a,o,n;if(i.variant,i.fontFamily){let a=i.fontFamily;"b"===i.fontSeries&&"it"===i.fontShape?a+="-bolditalic":"b"===i.fontSeries?a+="-bold":"it"===i.fontShape&&(a+="-italic");let o=null!=(r=lZ[a])?r:lZ[i.fontFamily];if(!o)return console.error(`Unknown font family variant: ${a}`),null;let[n,l]=o;return l&&(e.classes+=" "+l),n}let{variant:l}=i,{variantStyle:s}=i;if("normal"===l&&!s&&/[\u00A3\u0131\u0237]/.test(e.value)&&(l="main",s="italic"),"normal"===l&&!s&&1===e.value.length){let r=!1;l0.forEach((a,o)=>{var n;a.test(e.value)&&"it"===l1[null!=(n=i.letterShapeStyle)?n:"tex"][o]&&(r=!0)}),r&&(s=({up:"italic",bold:"bolditalic",italic:"italic",bolditalic:"bolditalic","":"italic"})[null!=(n=s)?n:""])}"up"===s&&(s=void 0);let c=s?l+"-"+s:l;lZ[c];let[d,u]=lZ[c];if(lY[l]&&!lY[l].test(e.value)){let i=ee(e.value,l,s);return i||(i=null!=(a=ee(e.value,l))?a:e.value,e.classes+=null!=(o=({bold:" ML__bold",italic:" ML__it","bold-italic":" ML__bold ML__it"})[null!=s?s:""])?o:""),e.value=i,null}return lQ.test(e.value)&&(e.classes+=" lcGreek"),u&&(e.classes+=" "+u),d}};var l2={roman:"","sans-serif":"ML__sans",monospace:"ML__tt"};function l3(e){var i;let r=/macos|ios/.test(w()),a=e.split("+"),o="";for(let e of a)o&&(o+=r?" ":'<span class="ML__shortcut-join">+</span>'),e.startsWith("[Key")?o+=e.slice(4,5):e.startsWith("Key")?o+=e.slice(3,4):e.startsWith("[Digit")?o+=e.slice(6,7):e.startsWith("Digit")?o+=e.slice(5,6):o+=null!=(i=({cmd:"⌘",meta:r?"⌘":"Ctrl",shift:r?"⇧":"Shift",alt:r?"⌥":"Alt",ctrl:r?"⌃":"Ctrl","\n":r?"⏎":"Return","[return]":r?"⏎":"Return","[enter]":r?"⌤":"Enter","[tab]":r?"⇥":"Tab","[escape]":"Esc","[backspace]":r?"⌫":"Backspace","[delete]":r?"⌦":"Del","[pageup]":r?"⇞":"Page Up","[pagedown]":r?"⇟":"Page Down","[home]":r?"⤒":"Home","[end]":r?"⤓":"End","[space]":"Space","[equal]":"=","[minus]":"-","[comma]":",","[slash]":"/","[backslash]":"\\","[bracketleft]":"[","[bracketright]":"]",semicolon:";",period:".",comma:",",minus:"-",equal:"=",quote:"'",backslash:"\\",intlbackslash:"\\",backquote:"`",slash:"/",numpadmultiply:"* 🔢",numpaddivide:"/ 🔢",numpadsubtract:"- 🔢",numpadadd:"+ 🔢",numpaddecimal:". 🔢",numpadcomma:", 🔢",help:"help",left:"⇠",up:"⇡",right:"⇢",down:"⇣","[arrowleft]":"⇠","[arrowup]":"⇡","[arrowright]":"⇢","[arrowdown]":"⇣"})[e.toLowerCase()])?i:e.toUpperCase();return o}function l6(e){if(e instanceof MouseEvent||e instanceof PointerEvent)return{x:e.clientX,y:e.clientY};if("u">typeof TouchEvent&&e instanceof TouchEvent){let i=[...e.touches].reduce((e,i)=>({x:e.x+i.clientX,y:e.y+i.clientY}),{x:0,y:0}),r=e.touches.length;return{x:i.x/r,y:i.y/r}}}function l8(e){let i={alt:!1,control:!1,shift:!1,meta:!1};return(e instanceof MouseEvent||e instanceof PointerEvent||"u">typeof TouchEvent&&e instanceof TouchEvent||e instanceof KeyboardEvent)&&(e.altKey&&(i.alt=!0),e.ctrlKey&&(i.control=!0),e.metaKey&&(i.meta=!0),e.shiftKey&&(i.shift=!0)),i}new class extends ov{constructor(){super("text")}createAtom(e,i,r){return i&&"symbol"===i.definitionType?new oY(e,String.fromCodePoint(i.codepoint),null!=r?r:{}):null}serialize(e,i){var r,a;return r=g(f({},i),{defaultMode:"text"}),a="text"!==i.defaultMode,ok(e,"fontFamily").map(e=>{var i;a=a&&!e.every(e=>e.style.fontFamily||e.style.fontShape||e.style.fontSeries||e.style.fontSize);let o=ok(e,"fontSize").map(e=>{var i,a;let o=ok(e,"fontSeries").map(e=>{let i=ok(e,"fontShape").map(e=>{let i=e.map(e=>e._serialize(r)),{fontShape:a}=e[0].style,o="";return"it"===a&&(o="\\textit"),"sl"===a&&(o="\\textsl"),"sc"===a&&(o="\\textsc"),"n"===a&&(o="\\textup"),!o&&a?`{${og("\\fontshape",a)}${of(i)}}`:o?og(o,of(i)):of(i)}),{fontSeries:a}=e[0].style,o="";return"b"===a&&(o="\\textbf"),"l"===a&&(o="\\textlf"),"m"===a&&(o="\\textmd"),a&&!o?`{${og("\\fontseries",a)}${of(i)}}`:o?og(o,of(i)):of(i)}),n=null!=(a=["","\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"][null!=(i=e[0].style.fontSize)?i:""])?a:"";return n?`${n} ${of(o)}`:of(o)}),{fontFamily:n}=e[0].style,l=null!=(i=({roman:"textrm",monospace:"texttt","sans-serif":"textsf"})[null!=n?n:""])?i:"";return l?`\\${l}{${of(o)}}`:n?`{\\fontfamily{${e[0].style.fontFamily}} ${of(o)}}`:a?`\\text{${of(o)}}`:of(o)})}getFont(e,i){var r,a,o,n,l;let{fontFamily:s}=i;if(l2[s]?e.classes+=" "+l2[s]:s&&e.setStyle("font-family",s),i.fontShape&&(e.classes+=" ",e.classes+=null!=(r=({it:"ML__it",sl:"ML__shape_sl",sc:"ML__shape_sc",ol:"ML__shape_ol"})[i.fontShape])?r:""),i.fontSeries){let r=i.fontSeries.match(/(.?[lbm])?(.?[cx])?/);r&&(e.classes+=" ",e.classes+=null!=(o=({ul:"ML__series_ul",el:"ML__series_el",l:"ML__series_l",sl:"ML__series_sl",m:"",sb:"ML__series_sb",b:"ML__bold",eb:"ML__series_eb",ub:"ML__series_ub"})[null!=(a=r[1])?a:""])?o:"",e.classes+=" ",e.classes+=null!=(l=({uc:"ML__series_uc",ec:"ML__series_ec",c:"ML__series_c",sc:"ML__series_sc",n:"",sx:"ML__series_sx",x:"ML__series_x",ex:"ML__series_ex",ux:"ML__series_ux"})[null!=(n=r[2])?n:""])?l:"")}return"Main-Regular"}},new class extends ov{constructor(){super("latex")}createAtom(e){return new lx(e)}serialize(e,i){return e.filter(e=>e instanceof lx&&!e.isSuggestion).map(e=>e.value)}getFont(){return null}};var l5=new Set(["Backquote","Digit0","Digit1","Digit2","Digit3","Digit4","Digit5","Digit6","Digit7","Digit8","Digit9","Minus","Equal","IntlYen","KeyQ","KeyW","KeyE","KeyR","KeyT","KeyY","KeyU","KeyI","KeyO","KeyP","BracketLeft","BracketRight","Backslash","KeyA","KeyS","KeyD","KeyF","KeyG","KeyH","KeyJ","KeyK","KeyL","Semicolon","Quote","IntlBackslash","KeyZ","KeyX","KeyC","KeyV","KeyB","KeyN","KeyM","Comma","Period","Slash","IntlRo","Space","Numpad0","Numpad1","Numpad2","Numpad3","Numpad4","Numpad5","Numpad6","Numpad7","Numpad8","Numpad9","NumpadAdd","NumpadComma","NumpadDecimal","NumpadDivide","NumpadEqual","NumpadHash","NumpadMultiply","NumpadParenLeft","NumpadParenRight","NumpadStar","NumpadSubstract"]);function l7(e){return!(e.ctrlKey||e.metaKey||["Dead","Process"].includes(e.key))&&(""===e.code||l5.has(e.code))}function l9(){var e;let i=document.activeElement;for(;null!=(e=null==i?void 0:i.shadowRoot)&&e.activeElement;)i=i.shadowRoot.activeElement;return i}var se=class e{static get scrim(){return e._scrim||(e._scrim=new e),e._scrim}static open(i){e.scrim.open(i)}static close(){e.scrim.close()}static get state(){return e.scrim.state}static get element(){return e.scrim.element}constructor(e){var i,r;this.lightDismiss=null==(i=null==e?void 0:e.lightDismiss)||i,this.translucent=null!=(r=null==e?void 0:e.translucent)&&r,this.state="closed"}get element(){if(this._element)return this._element;let e=document.createElement("div");return e.setAttribute("role","presentation"),e.style.position="fixed",e.style.contain="content",e.style.top="0",e.style.left="0",e.style.right="0",e.style.bottom="0",e.style.zIndex="var(--scrim-zindex, 10099)",e.style.outline="none",this.translucent?(e.style.background="rgba(255, 255, 255, .2)",e.style.backdropFilter="contrast(40%)"):e.style.background="transparent",this._element=e,e}open(e){var i;if("closed"!==this.state)return;this.state="opening",this.onDismiss=null==e?void 0:e.onDismiss,this.savedActiveElement=l9();let{element:r}=this;(null!=(i=null==e?void 0:e.root)?i:document.body).appendChild(r),r.addEventListener("click",this),document.addEventListener("touchmove",this,!1),document.addEventListener("scroll",this,!1);let a=window.innerWidth-document.documentElement.clientWidth;this.savedMarginRight=document.body.style.marginRight,this.savedOverflow=document.body.style.overflow,document.body.style.overflow="hidden";let o=Number.parseFloat(getComputedStyle(document.body).marginRight);document.body.style.marginRight=`${o+a}px`;let n=document.querySelector(".MLK__plate");if(n instanceof HTMLElement){this.savedMlkPaddingRight=n.style.paddingRight;let e=Number.parseFloat(getComputedStyle(n).paddingRight);n.style.paddingRight=`${e+a}px`}null!=e&&e.child&&r.append(e.child),this.state="open"}close(){var e,i,r,a,o;if("open"!==this.state)return void this.element.parentElement;this.state="closing","function"==typeof this.onDismiss&&this.onDismiss(),this.onDismiss=void 0;let{element:n}=this;n.removeEventListener("click",this),document.removeEventListener("touchmove",this,!1),document.removeEventListener("scroll",this,!1),n.remove(),document.body.style.overflow=null!=(e=this.savedOverflow)?e:"",document.body.style.marginRight=null!=(i=this.savedMarginRight)?i:"";let l=document.querySelector(".MLK__plate");l instanceof HTMLElement&&(l.style.paddingRight=null!=(r=this.savedMlkPaddingRight)?r:""),l9()!==this.savedActiveElement&&(null==(o=null==(a=this.savedActiveElement)?void 0:a.focus)||o.call(a)),n.innerHTML="",this.state="closed"}handleEvent(e){this.lightDismiss&&(e.target===this._element&&"click"===e.type?(this.close(),e.preventDefault(),e.stopPropagation()):e.target===document&&("touchmove"===e.type||"scroll"===e.type)&&(this.close(),e.preventDefault(),e.stopPropagation()))}};function st(e){var i;let r;return e&&l7(e)?("Unidentified"===e.key&&e.target&&(r=e.target.value),r=null!=(i=null!=r?r:e.key)?i:e.code,/^(Dead|Return|Enter|Tab|Escape|Delete|PageUp|PageDown|Home|End|Help|ArrowLeft|ArrowRight|ArrowUp|ArrowDown)$/.test(r)&&(r=""),r):""}function si(e){e=function(e){if(e.code)return e;let i=Object.entries($().mapping),r=!1,a=!1,o="";for(let n=0;n<4;n++){for(let[l,s]of i)if(s[n]===e.key){o=l,3===n?(r=!0,a=!0):2===n?r=!0:1===n&&(a=!0);break}if(o)break}return new KeyboardEvent(e.type,g(f({},e),{altKey:r,shiftKey:a,code:o}))}(e);let i=[];return e.ctrlKey&&i.push("ctrl"),e.metaKey&&i.push("meta"),e.altKey&&i.push("alt"),e.shiftKey&&i.push("shift"),0===i.length?`[${e.code}]`:(i.push(`[${e.code}]`),i.join("+"))}function sr(e){let i=e;return R(i)&&(i=i.length>0?i[0]+"("+i.slice(1).join("")+")":""),i}function sa(e){if(Array.isArray(e)){let i=[...e];return i.shift()+"("+i.map(e=>"string"==typeof e?`"${e}"`:e.toString()).join(", ")+")"}return e}function so(e){return e.atoms.find(e=>"latexgroup"===e.type)}function sn(e){var i,r;let a=so(e);return null!=(r=null==(i=null==a?void 0:a.body)?void 0:i.filter(e=>"latex"===e.type))?r:[]}function sl(e,i){var r;let a=0,o=!1,n=Number.isFinite(null==i?void 0:i.before)?null!=(r=null==i?void 0:i.before)?r:0:e.lastOffset;for(;a<=n&&!o;){let i=e.at(a);(o=i instanceof lx&&i.isSuggestion)||a++}if(!o)return[void 0,void 0];let l=a,s=!1;for(;l<=n&&!s;){let i=e.at(l);(s=!(i instanceof lx&&i.isSuggestion))||l++}return[a-1,l-1]}function ss(e,i){var r,a,o,n,l,s,c,d,u,h;let p={};if("string"==typeof i.color){let n=null!=(a=e.colorMap(null!=(r=i.color)?r:i.verbatimColor))?a:"none";n!==i.color&&(p.verbatimColor=null!=(o=i.verbatimColor)?o:i.color),p.color=n}if("string"==typeof i.backgroundColor){let r=null!=(l=e.backgroundColorMap(null!=(n=i.backgroundColor)?n:i.verbatimBackgroundColor))?l:"none";r!==i.backgroundColor&&(p.verbatimBackgroundColor=null!=(s=i.verbatimBackgroundColor)?s:i.backgroundColor),p.backgroundColor=r}"string"==typeof i.fontFamily&&(p.fontFamily=i.fontFamily),"string"==typeof i.series&&(p.fontSeries=i.series),"string"==typeof i.fontSeries&&(p.fontSeries=i.fontSeries.toLowerCase()),p.fontSeries&&(p.fontSeries=null!=(c=({bold:"b",medium:"m",normal:"m"})[p.fontSeries])?c:p.fontSeries),"string"==typeof i.shape&&(p.fontShape=i.shape),"string"==typeof i.fontShape&&(p.fontShape=i.fontShape.toLowerCase()),p.fontShape&&(p.fontShape=null!=(d=({italic:"it",up:"n",upright:"n",normal:"n"})[p.fontShape])?d:p.fontShape),i.variant&&(p.variant=i.variant.toLowerCase()),void 0!==i.variantStyle&&(p.variantStyle="string"==typeof i.variantStyle&&""!==i.variantStyle?i.variantStyle.toLowerCase():i.variantStyle);let m=null!=(u=i.size)?u:i.fontSize;return"number"==typeof m?p.fontSize=Math.max(1,Math.min(10,m)):"string"==typeof m&&(p.fontSize=null!=(h=({size1:1,size2:2,size3:3,size4:4,size5:5,size6:6,size7:7,size8:8,size9:9,size10:10})[m.toLowerCase()])?h:({tiny:1,scriptsize:2,footnotesize:3,small:4,normal:5,normalsize:5,large:6,Large:7,LARGE:8,huge:9,Huge:10})[m]),p}function sc(e,i,r){var a,o;let n=e.model;if("latex"===n.mode)return{};let l=e.styleBias;if("none"===l)return e.defaultStyle;if("text"===n.mode)return null!=(o=null==(a=n.at("right"===l?r.after:r.before))?void 0:a.style)?o:e.defaultStyle;if("math"===n.mode){let i=n.at("right"===l?r.after:r.before);return f(i?g(f({},i.style),{variant:"normal"}):{variant:"normal"},e.defaultStyle)}return{}}function sd(e){let i=e.options.onInsertStyle;if(null===i)return{};void 0===i&&(i=sc);let r=e.model,a=e.styleBias,o=r.at(r.position),n=su(r,o,a),l=su(r,o.rightSibling,a);return i(e,r.position,{before:n,after:l})}function su(e,i,r){var a;return i&&("first"!==i.type||"right"===r)?"group"!==i.type?e.offsetOf(i):!i.body||i.body.length<2?-1:(null==(a=i.body)?void 0:a.length)===1||"right"!==r?e.offsetOf(i.body[0]):e.offsetOf(i.body[i.body.length-1]):-1}function sh(e){let i=sn(e.model).filter(e=>e.isSuggestion);if(0!==i.length)for(let r of(e.model.position=e.model.offsetOf(i[0].leftSibling),i))r.parent.removeChild(r)}function sp(e,i){var r,a;let{model:o}=e;for(let i of(sh(e),sn(o)))i.isError=!1;if(!o.selectionIsCollapsed||"off"===e.options.popoverPolicy)return void sM(e);let n=[],l=o.at(o.position);for(;l&&l instanceof lx&&/^[a-zA-Z\*]$/.test(l.value);)l=l.leftSibling;let s="",c=!1;if(l&&l instanceof lx&&"\\"===l.value){for(c=!0,n.push(l),l=l.rightSibling;l&&l instanceof lx&&/^[a-zA-Z\*]$/.test(l.value);)n.push(l),l=l.rightSibling;s=n.map(e=>e.value).join("")}else{let e=[],i=null!=(r=o.at(o.position-1))?r:o.at(o.position);for(;i&&i instanceof lx&&/^[a-zA-Z]$/.test(i.value);)e.unshift(i),i=i.leftSibling;e.length>=1&&!(i&&i instanceof lx&&"\\"===i.value)&&(s="\\"+e.map(e=>e.value).join(""),n.push(...e))}let d=function(e,i){var r,a;if(0===i.length||"\\"===i||!i.startsWith("\\"))return[];let o=[],n=i.substring(1).toLowerCase();for(let[e,i]of Object.entries(em))if(e.startsWith(n))for(let e of i){let i=e.startsWith("\\")?e:"\\"+e;o.push({match:i,frequency:1e4})}for(let e in en)e.startsWith(i)&&!en[e].infix&&o.push({match:e,frequency:null!=(r=en[e].frequency)?r:0});for(let e in ea)e.startsWith(i)&&o.push({match:e,frequency:null!=(a=ea[e].frequency)?a:0});let l=i.substring(1);for(let i of Object.keys(e.options.macros))i.startsWith(l)&&o.push({match:"\\"+i,frequency:0});for(let[e,r]of Object.entries({alpha:["\\alpha","\\Alpha"],beta:["\\beta","\\Beta"],gamma:["\\gamma","\\Gamma"],delta:["\\delta","\\Delta"],epsilon:["\\epsilon","\\varepsilon","\\Epsilon"],theta:["\\theta","\\vartheta","\\Theta"],pi:["\\pi","\\varpi","\\Pi"],rho:["\\rho","\\varrho","\\Rho"],sigma:["\\sigma","\\varsigma","\\Sigma"],phi:["\\phi","\\varphi","\\Phi"],psi:["\\psi","\\Psi"],omega:["\\omega","\\Omega"]}))if(("\\"+e).startsWith(i))for(let e of r)o.some(i=>i.match===e)||o.push({match:e,frequency:5e3});let s=new Set,c=o.filter(e=>!s.has(e.match)&&(s.add(e.match),!0)),d=["\\alpha","\\beta","\\gamma","\\delta","\\epsilon","\\zeta","\\eta","\\theta","\\iota","\\kappa","\\lambda","\\mu","\\nu","\\xi","\\omicron","\\pi","\\rho","\\sigma","\\tau","\\upsilon","\\phi","\\chi","\\psi","\\omega","\\Gamma","\\Delta","\\Theta","\\Lambda","\\Xi","\\Pi","\\Sigma","\\Upsilon","\\Phi","\\Psi","\\Omega","\\varepsilon","\\vartheta","\\varpi","\\varrho","\\varsigma","\\varphi"];return c.sort((e,i)=>{var r,a;let o=d.includes(e.match),n=d.includes(i.match);return o&&!n?-1:!o&&n?1:e.frequency===i.frequency?e.match.length===i.match.length?e.match<i.match?-1:1:e.match.length-i.match.length:(null!=(r=i.frequency)?r:0)-(null!=(a=e.frequency)?a:0)}),c.map(e=>e.match)}(e,s);if(0===d.length){if(c&&/^\\[a-zA-Z\*]+$/.test(s))for(let e of n)e.isError=!0;sM(e);return}let u=null!=(a=null==i?void 0:i.atIndex)?a:0;e.suggestionIndex=u<0?d.length-1:u%d.length,d[e.suggestionIndex],function(e,i){var r,a,o,n,l,s;let c;if(0===i.length)return sM(e);let d=document.getElementById("mathlive-suggestion-popover"),u=null==d?void 0:d.classList.contains("is-visible"),h=sv.length!==i.length||sv.some((e,r)=>e!==i[r]);if(u&&!h){let i;o=d,n=e.suggestionIndex,(i=o.querySelectorAll("li")).forEach(e=>{e.classList.remove("ML__popover__current")}),n>=0&&n<i.length&&i[n].classList.add("ML__popover__current"),null==(r=d.querySelector(".ML__popover__current"))||r.scrollIntoView({block:"nearest",inline:"nearest"});return}sv=[...i];let p=["\\text","\\textbf","\\textit","\\textrm","\\textsf","\\texttt","\\textmd","\\textup","\\textnormal","\\textsl","\\textsc","\\mathbf","\\mathit","\\mathrm","\\mathsf","\\mathtt","\\mathbb","\\mathcal","\\mathscr","\\mathfrak","\\mathnormal","\\mathbfit","\\Bbb","\\frak","\\bf","\\it","\\rm","\\sf","\\tt","\\rmfamily","\\sffamily","\\ttfamily","\\bfseries","\\mdseries","\\upshape","\\slshape","\\scshape","\\boldsymbol","\\bm","\\bold","\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge","\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle","\\color","\\textcolor","\\colorbox","\\fcolorbox","\\boxed","\\em","\\emph","\\the"],m=[],f=[],g=[];for(let r of i){let i=r;if(p.some(e=>i.startsWith(e)))continue;let a=function(e,i){let r=new oW({from:e.context});return oz(oA(lD(new oE(new oG({mode:"math",type:"root",body:ll(i,{context:r})}).render(r),{classes:"ML__base"}),r)),{classes:"ML__latex"}).toMarkup()}(e,r),o=(function(e,i){let r=[];if("string"==typeof i){let e=nn[i];R(e)?r=e.slice():e&&r.push(e)}let a=RegExp("^"+sr(i).replace("\\","\\\\").replace("|","\\|").replace("*","\\*").replace("$","\\$").replace("^","\\^")+"([^*a-zA-Z]|$)");for(let i of e)a.test(sr(i.command))&&r.push(i.key);return r.map(l3)})(e.keybindings,i).join("<br>"),n={command:i,markup:a,keybinding:o},l=["\\alpha","\\beta","\\gamma","\\delta","\\epsilon","\\zeta","\\eta","\\theta","\\iota","\\kappa","\\lambda","\\mu","\\nu","\\xi","\\omicron","\\pi","\\rho","\\sigma","\\tau","\\upsilon","\\phi","\\chi","\\psi","\\omega","\\Gamma","\\Delta","\\Theta","\\Lambda","\\Xi","\\Pi","\\Sigma","\\Upsilon","\\Phi","\\Psi","\\Omega","\\varepsilon","\\vartheta","\\varpi","\\varrho","\\varsigma","\\varphi"];i.startsWith("\\mathbb")||i.startsWith("\\mathcal")||2===i.length||l.some(e=>i===e||i.startsWith(e+" "))?g.push(n):i.length>3&&!i.includes("{")?m.push(n):g.push(n)}let b=[],y=(i,r,a=!1)=>{let o=r===e.suggestionIndex?"ML__popover__current":"",n=r<9?`\u2318${r+1}`:"",l=`<li role="button" data-command="${sy(i.command)}" class="${o} ${a?"ML__popover__item--grid":"ML__popover__item--list"}" tabindex="0">`;return a?(l+=`<span class="ML__popover__command">${i.markup}</span>`,n&&(l+=`<span class="ML__popover__shortcut">${n}</span>`)):(l+=`<span class="ML__popover__icon">${i.markup}</span><div class="ML__popover__label-group"><span class="ML__popover__latex">${sy(i.command)}</span><span class="ML__popover__type">Function</span></div>`,n?l+=`<span class="ML__popover__shortcut">${n}</span>`:i.keybinding&&(l+=`<span class="ML__popover__keybinding">${i.keybinding}</span>`)),l+="</li>"},v=0;if(g.length>0){for(let e of(b.push('<div class="ML__popover__section-title">Symbols</div>'),b.push('<ul class="ML__popover__grid">'),g))b.push(y(e,v++,!0));b.push("</ul>")}if(m.length>0){for(let e of(b.push('<div class="ML__popover__section-title">Variable or Function</div>'),b.push("<ul>"),m))b.push(y(e,v++,!1));b.push("</ul>")}if(f.length>0){for(let e of(b.push('<div class="ML__popover__section-title">Constant</div>'),b.push("<ul>"),f))b.push(y(e,v++,!1));b.push("</ul>")}let x=(l=e,s=`<div class="ML__popover__container">${b.join("")}</div>`,(c=document.getElementById("mathlive-suggestion-popover"))?sb("mathlive-suggestion-popover"):(nA("suggestion-popover"),nA("core")),(c=sg("mathlive-suggestion-popover")).addEventListener("pointerdown",e=>e.preventDefault()),c.addEventListener("click",e=>{let i=e.target;for(;i&&!i.dataset.command;)i=i.parentElement;i&&(sf(l,"reject"),na.insert(l.model,i.dataset.command,{selectionMode:"placeholder",format:"latex",mode:"math"}),l.dirty=!0,l.focus())}),c.innerHTML=globalThis.MathfieldElement.createHTML(s),c);sw()&&(null==(a=x.querySelector(".ML__popover__current"))||a.scrollIntoView({block:"nearest",inline:"nearest"}),s_(e)),setTimeout(()=>{var i;x&&!sw()&&(x.classList.add("is-visible"),sk(e),null==(i=x.querySelector(".ML__popover__current"))||i.scrollIntoView({block:"nearest",inline:"nearest"}),s_(e))},32)}(e,d)}function sm(e){let[i,r]=sl(e,{before:e.position});if(void 0===i||void 0===r)return!1;let a=!1;return e.getAtoms([i,r]).forEach(e=>{e.isSuggestion&&(e.isSuggestion=!1,a=!0)}),a}function sf(e,i="accept",r){var a,o;sM(e);let n=so(e.model);if(!n)return!1;if("accept-suggestion"===i||"accept-all"===i){let r=sn(e.model).filter(e=>e.isSuggestion);if(0!==r.length){for(let e of r)e.isSuggestion=!1;e.model.position=e.model.offsetOf(r[r.length-1])}if("accept-suggestion"===i)return 0!==r.length}let l=sn(e.model).filter(e=>!e.isSuggestion).map(e=>e.value).join(""),s=n.leftSibling;if(n.parent.removeChild(n),e.model.position=e.model.offsetOf(s),e.switchMode(null!=(a=null==r?void 0:r.mode)?a:"math"),"reject"===i)return!0;let c=f({},sd(e));return/^[a-zA-Z0-9]$/.test(l)||"none"===e.styleBias||(c.variant="normal",c.variantStyle=void 0),na.insert(e.model,l,{selectionMode:null!=(o=null==r?void 0:r.selectItem)&&o?"item":"placeholder",format:"latex",mode:"math",style:c}),e.snapshot(),e.model.announce("replacement"),e.switchMode("math"),!0}function sg(e){var i;let r=document.getElementById(e);return r?r.dataset.refcount=Number(Number.parseInt(null!=(i=r.dataset.refcount)?i:"0")+1).toString():((r=document.createElement("div")).setAttribute("aria-hidden","true"),r.dataset.refcount="1",r.id=e,(function(){let e=nS;if(e){let i=document.querySelector(e);if(i)return i}return document.body})().append(r)),r}function sb(e){var i;let r=document.getElementById(e);if(!r)return;let a=Number.parseInt(null!=(i=r.getAttribute("data-refcount"))?i:"0");a<=1?r.remove():r.dataset.refcount=Number(a-1).toString()}function sy(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}new class extends na{constructor(){super("latex")}createAtom(e){return new lx(e)}onPaste(e,i){if(!i)return!1;let r="string"==typeof i?i:i.getData("application/x-latex")||i.getData("text/plain");return!!(r&&e.model.contentWillChange({inputType:"insertFromPaste",data:r}))&&(e.stopCoalescingUndo(),e.stopRecording(),this.insert(e.model,r)&&(e.startRecording(),e.snapshot("paste"),e.model.contentDidChange({inputType:"insertFromPaste"}),sB(e)),e.startRecording(),!0)}insert(e,i,r){if(!e.contentWillChange({data:i,inputType:"insertText"}))return!1;r||(r={}),r.insertionMode||(r.insertionMode="replaceSelection"),r.selectionMode||(r.selectionMode="placeholder");let{silenceNotifications:a}=e;r.silenceNotifications&&(e.silenceNotifications=!0);let o=e.silenceNotifications;e.silenceNotifications=!0,"replaceSelection"!==r.insertionMode||e.selectionIsCollapsed?"replaceAll"===r.insertionMode?(e.root.setChildren([],"body"),e.position=0):"insertBefore"===r.insertionMode?e.collapseSelection("backward"):"insertAfter"===r.insertionMode&&e.collapseSelection("forward"):e.deleteAtoms(oQ(e.selection));let n=[];for(let e of i)ed.test(e)&&n.push(new lx(e));let l=e.at(e.position);if(l instanceof l_&&(l=l.lastChild),!(l.parent instanceof l_)){let e=new l_;l.parent.addChildAfter(e,l),l=e.firstChild}let s=l.parent.addChildrenAfter(n,l);return e.silenceNotifications=o,"before"===r.selectionMode||("item"===r.selectionMode?e.setSelection(e.anchor,e.offsetOf(s)):s&&(e.position=e.offsetOf(s))),e.contentDidChange({data:i,inputType:"insertText"}),e.silenceNotifications=a,!0}},sN({applyStyle:function(e,i){e.flushInlineShortcutBuffer(),e.stopCoalescingUndo();let r=ss(e,i),{model:a}=e;return a.selectionIsCollapsed?(e.defaultStyle.fontSeries&&r.fontSeries===e.defaultStyle.fontSeries&&(r.fontSeries="auto"),r.fontShape&&r.fontShape===e.defaultStyle.fontShape&&(r.fontShape="auto"),r.color&&r.color===e.defaultStyle.color&&(r.color="none"),r.backgroundColor&&r.backgroundColor===e.defaultStyle.backgroundColor&&(r.backgroundColor="none"),r.fontSize&&r.fontSize===e.defaultStyle.fontSize&&(r.fontSize="auto"),e.defaultStyle=f(f({},e.defaultStyle),r)):e.model.deferNotifications({content:!0,type:"insertText"},()=>{a.selection.ranges.forEach(e=>lN(a,e,r,{operation:"toggle"})),e.snapshot("style-change")}),!0}},{target:"mathfield",canUndo:!0,changeContent:!0});var sv=[],sx=null;function s_(e){sx||(sx=i=>{if(sw()){if("Enter"===i.key||"Return"===i.key){let r=document.getElementById("mathlive-suggestion-popover");if(!r)return;let a=r.querySelectorAll("li");if(e.suggestionIndex<a.length){i.preventDefault(),i.stopPropagation();let r=a[e.suggestionIndex];sf(e,"reject"),na.insert(e.model,r.dataset.command,{selectionMode:"placeholder",format:"latex",mode:"math"}),e.dirty=!0,e.focus()}return}if((i.metaKey||i.ctrlKey)&&i.key>="1"&&i.key<="9"){let r=parseInt(i.key)-1,a=document.getElementById("mathlive-suggestion-popover");if(!a)return;let o=a.querySelectorAll("li");if(r<o.length){i.preventDefault(),i.stopPropagation();let a=o[r];sf(e,"reject"),na.insert(e.model,a.dataset.command,{selectionMode:"placeholder",format:"latex",mode:"math"}),e.dirty=!0,e.focus()}}}},document.addEventListener("keydown",sx,{capture:!0}))}function sw(){let e=document.getElementById("mathlive-suggestion-popover");return!!e&&e.classList.contains("is-visible")}function sk(e,i){var r,a,o;if(!e.element||e.element.mathfield!==e||!sw())return;if((null==(r=e.model.at(e.model.position))?void 0:r.type)!=="latex")return void sM(e);if(null!=i&&i.deferred)return void setTimeout(()=>sk(e),32);let n=ns(e.field);if(!n)return;let l=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,s=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,c=window.innerWidth-document.documentElement.clientWidth,d=window.innerHeight-document.documentElement.clientHeight,u=null!=(o=null==(a=window.mathVirtualKeyboard)?void 0:a.boundingRect.height)?o:0,h=document.getElementById("mathlive-suggestion-popover");n.x+h.offsetWidth/2>s-c?h.style.left=`${s-h.offsetWidth-c}px`:n.x-h.offsetWidth/2<0?h.style.left="0":h.style.left=`${n.x-h.offsetWidth/2}px`;let p=n.y-n.height;l-d-u-n.y<p?(h.classList.add("ML__popover--reverse-direction"),h.classList.remove("top-tip"),h.classList.add("bottom-tip"),h.style.top=`${n.y-n.height-h.offsetHeight-15}px`):(h.classList.remove("ML__popover--reverse-direction"),h.classList.add("top-tip"),h.classList.remove("bottom-tip"),h.style.top=`${n.y+15}px`)}function sM(e){e.suggestionIndex=0,sv=[],document.getElementById("mathlive-suggestion-popover")&&sb("mathlive-suggestion-popover"),sx&&(document.removeEventListener("keydown",sx,{capture:!0}),sx=null)}var sS,sL,sC,sE=null,sA=(null==(sC=null==(sL=null==globalThis?void 0:globalThis.document)?void 0:sL.currentScript)?void 0:sC.src)||function(){let e=String(Error().stack).replace(/^Error.*\n/,"").split(`
|
|
3230
|
-
`);if(0===e.length)return console.error(`Can't use relative paths to specify assets location because the sourcefile location could not be determined (unexpected stack trace format "${Error().stack}").`),"";let i=e[1],r=i.match(/http.*\.ts[\?:]/);return r&&(i=e[2]),(r=i.match(/(https?:.*):[0-9]+:[0-9]+/))||(r=i.match(/at (.*(\.ts))[\?:]/))||(r=i.match(/at (.*(\.mjs|\.js))[\?:]/)),r?r[1]:(console.error(e),console.error(`Can't use relative paths to specify assets location because the source file location could not be determined (unexpected location "${i}").`),"")}();async function sz(e){if(/^(?:[a-z+]+:)?\/\//i.test(e)){try{return new URL(e).href}catch(e){}if(e.startsWith("//"))try{return new URL(`${window.location.protocol}${e}`).href}catch(e){}return e}if(null===sE)try{let e=await fetch(sA,{method:"HEAD"});200===e.status&&(sE=(sE=e.url).replace(/\/\+esm$/,"/")).includes("jsdelivr.net/")&&(sE+="/")}catch(i){console.error(`Invalid URL "${e}" (relative to "${sA}")`)}return new URL(e,null!=sE?sE:sA).href}var sT="not-loaded";async function sD(){return sT="not-loaded",sK()}async function sK(){var e;if("not-loaded"===sT){if(sT="loading",null!=(e=getComputedStyle(document.documentElement).getPropertyValue("--ML__static-fonts"))&&e){sT="ready";return}if(document.body.classList.remove("ML__fonts-did-not-load"),"fonts"in document){let e=Array.from(document.fonts).map(e=>e.family);if(["KaTeX_Main","KaTeX_Math","KaTeX_AMS","KaTeX_Caligraphic","KaTeX_Fraktur","KaTeX_SansSerif","KaTeX_Script","KaTeX_Typewriter","KaTeX_Size1","KaTeX_Size2","KaTeX_Size3","KaTeX_Size4"].every(i=>e.includes(i))){sT="ready";return}if(!globalThis.MathfieldElement.fontsDirectory){sT="not-loaded";return}let i=await sz(globalThis.MathfieldElement.fontsDirectory);if(!i){document.body.classList.add("ML__fonts-did-not-load"),sT="error";return}i.endsWith("/")&&(i=i.slice(0,-1));let r=[["KaTeX_Main-Regular"],["KaTeX_Main-BoldItalic",{style:"italic",weight:"bold"}],["KaTeX_Main-Bold",{weight:"bold"}],["KaTeX_Main-Italic",{style:"italic"}],["KaTeX_Math-Italic",{style:"italic"}],["KaTeX_Math-BoldItalic",{style:"italic",weight:"bold"}],["KaTeX_AMS-Regular"],["KaTeX_Caligraphic-Regular"],["KaTeX_Caligraphic-Bold",{weight:"bold"}],["KaTeX_Fraktur-Regular"],["KaTeX_Fraktur-Bold",{weight:"bold"}],["KaTeX_SansSerif-Regular"],["KaTeX_SansSerif-Bold",{weight:"bold"}],["KaTeX_SansSerif-Italic",{style:"italic"}],["KaTeX_Script-Regular"],["KaTeX_Typewriter-Regular"],["KaTeX_Size1-Regular"],["KaTeX_Size2-Regular"],["KaTeX_Size3-Regular"],["KaTeX_Size4-Regular"]].map(e=>(function(e,i,r={}){return new FontFace(e,`url(${i}.woff2) format('woff2')`,r)})(e[0].replace(/-[a-zA-Z]+$/,""),`${i}/${e[0]}`,e[1]));try{(await Promise.all(r.map(e=>{try{return e.load()}catch(e){}}))).forEach(e=>document.fonts.add(e)),sT="ready";return}catch(e){console.error(`MathLive 0.110.9: The math fonts could not be loaded from "${i}"`,{cause:e}),document.body.classList.add("ML__fonts-did-not-load")}sT="error"}}}function sB(e,i){e&&!e.dirty&&e.field&&(e.resizeObserver.unobserve(e.field),e.dirty=!0,requestAnimationFrame(()=>{nl(e)&&e.dirty&&(e.atomBoundsCache=new Map,sP(e,i),e.resizeObserver.observe(e.field),e.resizeObserverStarted=!0)}))}function s$(e,i){try{var r,a;let o,{model:n}=e;for(let e of(n.root.caret=void 0,n.root.isSelected=!1,n.root.containsCaret=!0,n.atoms))e.caret=void 0,e.isSelected=!1,e.containsCaret=!1;if(n.selectionIsCollapsed){let i=n.at(n.position);i.caret=e.model.mode;let r=i.parent;for(;r;)r.containsCaret=!0,r=r.parent}else for(let e of n.getAtoms(n.selection,{includeChildren:!0,includeFirstAtoms:!0}))e.isSelected=!0;return(r=i,r=null!=r?r:{},o=new oW({from:g(f({},e.context),{atomIdsSettings:{seed:r.forHighlighting?function(e,i=0){let r=0xdeadbeef^i,a=0x41c6ce57^i;for(let i=0;i<e.length;i++){let o=e.charCodeAt(i);r=Math.imul(r^o,0x9e3779b1),a=Math.imul(a^o,0x5f356495)}return r=Math.imul(r^r>>>16,0x85ebca6b)^Math.imul(a^a>>>13,0xc2b2ae35),0x100000000*(2097151&(a=Math.imul(a^a>>>16,0x85ebca6b)^Math.imul(r^r>>>13,0xc2b2ae35)))+(r>>>0)}(oG.serialize([e.model.root],{expandMacro:!1,defaultMode:e.options.defaultMode})):"random",groupNumbers:null!=(a=r.forHighlighting)&&a},letterShapeStyle:e.options.letterShapeStyle}),mathstyle:"inline-math"===e.options.defaultMode?"textstyle":"displaystyle"}),oz(lD(e.model.root.render(o),o),{classes:e.hasEditablePrompts?"ML__latex ML__prompting":"ML__latex",attributes:{translate:"no","aria-hidden":"true"}})).toMarkup()}catch(e){return console.error(e),'<span class="ML__latex" translate="no" aria-hidden="true">🚫</span>'}}function sP(e,i){if(!nl(e))return;null!=i||(i={});let r=e.element.querySelector("[part=virtual-keyboard-toggle]");r&&(r.style.display=e.hasEditableContent?"":"none");let a=e.field;if(!a)return;let o=e.isSelectionEditable&&e.hasFocus(),n=a.classList.contains("ML__focused");n&&!o?a.classList.remove("ML__focused"):!n&&o&&a.classList.add("ML__focused");let l=s$(e,i),s=e.element.querySelector("[part=menu-toggle]");if(s){let i=!1;(e.disabled||e.readOnly&&!e.hasEditableContent||"none"===e.userSelect)&&(i=!0),!i&&e.element.offsetWidth<50&&(i=!0),s.style.display=i?"none":""}if(e.model.atoms.length<=1){let i=e.options.contentPlaceholder;i&&(l+=`<span part=placeholder class="ML__content-placeholder">${dH(i)}</span>`)}a.innerHTML=globalThis.MathfieldElement.createHTML(l),sO(e,i.interactive),e.updateToggleLayout(),e.dirty=!1}function sO(e,i){var r;let a=e.field;if(!a)return;for(let e of a.querySelectorAll(".ML__selection, .ML__contains-highlight"))e.remove();if(!(null!=i&&i)&&"error"!==sT&&"ready"!==sT)return void setTimeout(()=>{"ready"===sT?sO(e):setTimeout(()=>sO(e),128)},32);let o=e.model;null==(r=e.atomBoundsCache)||r.clear();let n,l=()=>{if(void 0!==n)return n;let e=a.offsetWidth;return isNaN(n=Math.floor(a.getBoundingClientRect().width)/e)&&(n=1),n};if(o.selectionIsCollapsed){sk(e,{deferred:!0});let i=o.at(o.position);for(;i&&"prompt"!==i.type&&!(i.containsCaret&&i.displayContainsHighlight);)i=i.parent;if(null!=i&&i.containsCaret&&i.displayContainsHighlight){let r=l(),o=nc(e,nu(e,i),r);if(o){o.left/=r,o.right/=r,o.top/=r,o.bottom/=r;let e=document.createElement("div");e.classList.add("ML__contains-highlight"),e.style.position="absolute",e.style.left=`${o.left+1}px`,e.style.top=`${Math.ceil(o.top)}px`,e.style.width=`${Math.ceil(o.right-o.left)}px`,e.style.height=`${Math.ceil(o.bottom-o.top)}px`,a.insertBefore(e,a.childNodes[0])}}return}let s=l();for(let i of function(e){let i=[];for(let r of e){let e=!1;for(let a of i)if(r.left===a.left&&r.right===a.right&&r.top===a.top&&r.bottom===a.bottom){e=!0;break}e||i.push(r)}for(let r of(e=i,i=[],e)){let a=0;for(let i of e)if(r.left>=i.left&&r.right<=i.right&&r.top>=i.top&&r.bottom<=i.bottom&&(a+=1)>1)break;1===a&&i.push(r)}return i}(nh(e,{excludeAtomsWithBackground:!0}))){i.left/=s,i.right/=s,i.top/=s,i.bottom/=s;let e=document.createElement("div");e.classList.add("ML__selection"),e.style.position="absolute",e.style.left=`${i.left}px`,e.style.top=`${i.top}px`,e.style.width=`${Math.ceil(i.right-i.left)}px`,e.style.height=`${Math.max(1,Math.ceil(i.bottom-i.top-1))}px`,a.insertBefore(e,a.childNodes[0])}}function sR(e){if(!e)return;let i=e.model,r=i.selection,a=oG.serialize([i.root],{expandMacro:!1,defaultMode:e.options.defaultMode});na.insert(i,a,{insertionMode:"replaceAll",selectionMode:"after",format:"latex",silenceNotifications:!0,mode:"math"});let o=i.silenceNotifications;i.silenceNotifications=!0,i.selection=r,i.silenceNotifications=o,sB(e)}function sI(){for(let e of document.querySelectorAll(".ML__mathfield"))"_mathfield"in e&&sR(e._mathfield)}function sN(e,i){for(let r of(i=f({target:"mathfield",canUndo:!1,audioFeedback:void 0,changeContent:!1,changeSelection:!1},null!=i?i:{}),sW||(sW={}),Object.keys(e)))sW[r],sW[r]=g(f({},i),{fn:e[r]})}function sq(e){let i;if(Array.isArray(e)){if("performWithFeedback"===e[0])return sq(e[1]);i=e[0]}else i=e;return sW[i]}function sF(e){var i;return null==(i=sq(e))?void 0:i.target}function sV(e){if(!e)return;if(R(e)&&e.length>0){let i=e[0];return"performWithFeedback"===(i=i.replace(/-\w/g,e=>e[1].toUpperCase()))&&2===e.length?[i,sV(e[1])]:[i,...e.slice(1)]}if("string"!=typeof e)return;let i=e.trim().match(/^([a-zA-Z0-9-]+)\((.*)\)$/);return i?[i[1].replace(/-\w/g,e=>e[1].toUpperCase()),...i[2].split(",").map(e=>e.trim()).map(e=>{if(/"[^"]*"/.test(e)||/'[^']*'/.test(e))return e.slice(1,-1);if(/^true$/.test(e))return!0;if(/^false$/.test(e))return!1;if(/^[-]?\d+$/.test(e))return parseInt(e,10);if(/^\{.*\}$/.test(e))try{return JSON.parse(e)}catch(i){return console.error("Invalid argument:",e),e}return sV(e)})]:e.replace(/-\w/g,e=>e[1].toUpperCase())}sN({performWithFeedback:(e,i)=>(function(e,i){var r;if(!e)return!1;e.focus(),uO.keypressVibration&&_()&&navigator.vibrate(3);let a=sq(i);globalThis.MathfieldElement.playSound(null!=(r=null==a?void 0:a.audioFeedback)?r:"keypress");let o=e.executeCommand(i);return e.scrollIntoView(),o})(e,i)}),sN({complete:sf},{target:"mathfield",audioFeedback:"return",canUndo:!0,changeContent:!0,changeSelection:!0}),sN({dispatchEvent:(e,i,r)=>{var a,o;return null!=(o=null==(a=e.host)?void 0:a.dispatchEvent(new CustomEvent(i,{detail:r})))&&o}},{target:"mathfield"}),sN({nextSuggestion:function(e){return sp(e,{atIndex:e.suggestionIndex+1}),!1},previousSuggestion:function(e){return sp(e,{atIndex:e.suggestionIndex-1}),!1}},{target:"mathfield",audioFeedback:"keypress",changeSelection:!0});var sj="mathlive#virtual-keyboard-message";function sH(e){var i;return"message"===e.type&&(null==(i=e.data)?void 0:i.type)===sj}var sW,sU,sJ=class e{constructor(){this.targetOrigin=window.origin,this.originValidator="none",this.targetWindow=window.top,this._boundingRect=new DOMRect(0,0,0,0),this._isShifted=!1,window.addEventListener("message",this),this.sendMessage("proxy-created"),this.listeners={}}static get singleton(){return this._singleton||(this._singleton=new e),this._singleton}getKeycap(e){}setKeycap(e,i){this.sendMessage("update-setting",{setKeycap:{keycap:e,value:i}})}set alphabeticLayout(e){this.sendMessage("update-setting",{alphabeticLayout:e})}set layouts(e){this.sendMessage("update-setting",{layouts:e})}get normalizedLayouts(){return[]}set editToolbar(e){this.sendMessage("update-setting",{editToolbar:e})}set container(e){throw Error("Container inside an iframe cannot be changed")}show(e){this.dispatchEvent(new CustomEvent("before-virtual-keyboard-toggle",{detail:{visible:!0},bubbles:!0,cancelable:!0,composed:!0}))&&(this.sendMessage("show",e),this.dispatchEvent(new Event("virtual-keyboard-toggle")))}hide(e){this.dispatchEvent(new CustomEvent("before-virtual-keyboard-toggle",{detail:{visible:!1},bubbles:!0,cancelable:!0,composed:!0}))&&(this.sendMessage("hide",e),this.dispatchEvent(new Event("virtual-keyboard-toggle")))}get isShifted(){return this._isShifted}get visible(){return this._boundingRect.height>0}set visible(e){e?this.show():this.hide()}get boundingRect(){return this._boundingRect}executeCommand(e){return this.sendMessage("execute-command",{command:e}),!0}updateToolbar(e){this.sendMessage("update-toolbar",e)}update(e){this.sendMessage("update-setting",e)}connect(){this.sendMessage("connect")}disconnect(){this.sendMessage("disconnect")}addEventListener(e,i,r){this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].has(i)||this.listeners[e].add(i)}dispatchEvent(e){return!this.listeners[e.type]||0===this.listeners[e.type].size||(this.listeners[e.type].forEach(i=>{"function"==typeof i?i(e):null==i||i.handleEvent(e)}),!e.defaultPrevented)}removeEventListener(e,i,r){this.listeners[e]&&this.listeners[e].delete(i)}handleEvent(e){if(sH(e)){if(!np(e.origin,this.originValidator))throw new DOMException(`Message from unknown origin (${e.origin}) cannot be handled`,"SecurityError");this.handleMessage(e.data)}}handleMessage(e){let{action:i}=e;if("execute-command"===i){let{command:i}=e;"virtual-keyboard"===sF(i)&&this.executeCommand(i);return}if("synchronize-proxy"===i){this._boundingRect=e.boundingRect,this._isShifted=e.isShifted;return}if("geometry-changed"===i){this._boundingRect=e.boundingRect,this.dispatchEvent(new Event("geometrychange"));return}}sendMessage(e,i={}){if(!this.targetWindow)throw new DOMException("A frame does not have access to the top window and can't communicate with the keyboard.","SecurityError");this.targetWindow.postMessage(f({type:sj,action:e},i),this.targetOrigin)}},sX={numeric:{label:"123",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.numeric",rows:[[{latex:"x",shift:"y",variants:["y","z","t","r","x^2","x^n","x^{#?}","x_n","x_i","x_{#?}",{latex:"f(#?)",class:"small"},{latex:"g(#?)",class:"small"}]},{latex:"n",shift:"a",variants:["i","j","p","k","a","u"]},"[separator-5]","[7]","[8]","[9]","[/]","[separator-5]",{latex:"\\exponentialE",shift:"\\ln",variants:["\\exp","\\times 10^{#?}","\\ln","\\log_{10}","\\log","\\lg","\\operatorname{lb}"]},{latex:"\\imaginaryI",variants:["\\Re","\\Im","\\imaginaryJ","\\Vert #0 \\Vert"]},{latex:"\\pi",shift:"\\sin",variants:["\\prod",{latex:"\\theta",aside:"theta"},{latex:"\\rho",aside:"rho"},{latex:"\\tau",aside:"tau"},"\\sin","\\cos","\\tan"]}],[{label:"<",latex:"<",class:"hide-shift",shift:{latex:"\\le",label:"≤"}},{label:">",latex:">",class:"hide-shift",shift:{latex:"\\ge",label:"≥"}},"[separator-5]","[4]","[5]","[6]","[*]","[separator-5]",{class:"hide-shift",latex:"#@^2}",shift:"#@^{\\prime}}"},{latex:"#@^{#0}}",class:"hide-shift",shift:"#@_{#?}"},{class:"hide-shift",latex:"\\sqrt{#0}",shift:{latex:"\\sqrt[#0]{#?}}"}}],["[(]","[)]","[separator-5]","[1]","[2]","[3]","[-]","[separator-5]",{latex:"\\int^{\\infty}_{0}\\!#?\\,\\mathrm{d}x",class:"small hide-shift",shift:"\\int",variants:[{latex:"\\int_{#?}^{#?}",class:"small"},{latex:"\\int",class:"small"},{latex:"\\iint",class:"small"},{latex:"\\iiint",class:"small"},{latex:"\\oint",class:"small"},"\\mathrm{d}x",{latex:"\\dfrac{\\mathrm{d}}{\\mathrm{d} x}",class:"small"},{latex:"\\frac{\\partial}{\\partial x}",class:"small"},"\\partial"]},{class:"hide-shift",latex:"\\forall",shift:"\\exists"},{label:"[backspace]",width:1}],[{label:"[shift]",width:2},"[separator-5]","[0]","[.]","[=]","[+]","[separator-5]","[left]","[right]",{label:"[return]",width:1}]]},greek:{label:"αβγ",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.greek",rows:[[{label:"<i>φ</i>",class:"MLK__tex hide-shift",insert:"\\varphi",aside:"phi var.",shift:"\\Phi"},{label:"<i>ς</i>",class:"MLK__tex hide-shift",insert:"\\varsigma",aside:"sigma var.",shift:"\\Sigma"},{label:"<i>ϵ</i>",class:"MLK__tex hide-shift",insert:"\\epsilon",aside:"epsilon",shift:'\\char"0190'},{label:"<i>ρ</i>",class:"MLK__tex hide-shift",insert:"\\rho",aside:"rho",shift:'\\char"3A1'},{label:"<i>τ</i>",class:"MLK__tex hide-shift",insert:"\\tau",aside:"tau",shift:'\\char"3A4'},{label:"<i>υ</i>",class:"MLK__tex hide-shift",insert:"\\upsilon",aside:"upsilon",shift:"\\Upsilon"},{label:"<i>θ</i>",class:"MLK__tex hide-shift",insert:"\\theta",aside:"theta",shift:"\\Theta"},{label:"<i>ι</i>",class:"MLK__tex hide-shift",insert:"\\iota",aside:"iota",shift:'\\char"399'},{label:"<i>ο</i>",class:"MLK__tex hide-shift",insert:"\\omicron",aside:"omicron",shift:'\\char"39F'},{label:"<i>π</i>",class:"MLK__tex hide-shift",insert:"\\pi",aside:"pi",shift:"\\Pi"}],["[separator-5]",{label:"<i>α</i>",class:"MLK__tex hide-shift",insert:"\\alpha",aside:"alpha",shift:'\\char"391'},{label:"<i>σ</i>",class:"MLK__tex hide-shift",insert:"\\sigma",aside:"sigma",shift:"\\Sigma"},{label:"<i>δ</i>",class:"MLK__tex hide-shift",insert:"\\delta",aside:"delta",shift:"\\Delta"},{latex:"\\phi",class:"MLK__tex hide-shift",insert:"\\phi",aside:"phi",shift:"\\Phi"},{label:"<i>γ</i>",class:"MLK__tex hide-shift",insert:"\\gamma",aside:"gamma",shift:"\\Gamma"},{label:"<i>η</i>",class:"MLK__tex hide-shift",insert:"\\eta",aside:"eta",shift:'\\char"397'},{label:"<i>ξ</i>",class:"MLK__tex hide-shift",insert:"\\xi",aside:"xi",shift:"\\Xi"},{label:"<i>κ</i>",class:"MLK__tex hide-shift",insert:"\\kappa",aside:"kappa",shift:"\\Kappa"},{label:"<i>λ</i>",class:"MLK__tex hide-shift",insert:"\\lambda",aside:"lambda",shift:"\\Lambda"},"[separator-5]"],["[shift]",{label:"<i>ζ</i>",class:"MLK__tex hide-shift",insert:"\\zeta",aside:"zeta",shift:'\\char"396'},{label:"<i>χ</i>",class:"MLK__tex hide-shift",insert:"\\chi",aside:"chi",shift:'\\char"3A7'},{label:"<i>ψ</i>",class:"MLK__tex hide-shift",insert:"\\psi",aside:"psi",shift:"\\Psi"},{label:"<i>ω</i>",class:"MLK__tex hide-shift",insert:"\\omega",aside:"omega",shift:"\\Omega"},{label:"<i>β</i>",class:"MLK__tex hide-shift",insert:"\\beta",aside:"beta",shift:'\\char"392'},{label:"<i>ν</i>",class:"MLK__tex hide-shift",insert:"\\nu",aside:"nu",shift:'\\char"39D'},{label:"<i>μ</i>",class:"MLK__tex hide-shift",insert:"\\mu",aside:"mu",shift:'\\char"39C'},"[backspace]"],["[separator]",{label:"<i>ε</i>",class:"MLK__tex",insert:"\\varepsilon",aside:"epsilon var."},{label:"<i>ϑ</i>",class:"MLK__tex",insert:"\\vartheta",aside:"theta var."},{label:"<i>ϰ</i>",class:"MLK__tex",insert:"\\varkappa",aside:"kappa var."},{label:"<i>ϖ</i>",class:"MLK__tex",insert:"\\varpi",aside:"pi var."},{label:"<i>ϱ</i>",class:"MLK__tex",insert:"\\varrho",aside:"rho var."},"[left]","[right]","[return]"]]},symbols:{label:"∞≠∈",labelClass:"MLK__tex",tooltip:"keyboard.tooltip.symbols",rows:[[{latex:"\\sin",shift:"\\sin^{-1}",variants:[{class:"small",latex:"\\sinh"},{class:"small",latex:"\\sin^{-1}"},{class:"small",latex:"\\operatorname{arsinh}"}]},"\\ln",{latex:"\\mathrm{abs}",insert:"\\mathrm{abs}\\left(#0\\right)"},{latex:"\\rightarrow",shift:"\\Rightarrow",variants:[{latex:"\\implies",aside:"implies"},{latex:"\\to",aside:"to"},"\\dashv",{latex:"\\roundimplies",aside:"round implies"}]},{latex:"\\exists",variants:["\\nexists"],shift:"\\nexists"},{latex:"\\in",shift:"\\notin",variants:["\\notin","\\owns"]},"\\cup",{latex:"\\overrightarrow{#@}",shift:"\\overleftarrow{#@}",variants:["\\overleftarrow{#@}","\\bar{#@}","\\vec{#@}","\\hat{#@}","\\check{#@}","\\dot{#@}","\\ddot{#@}","\\mathring{#@}","\\breve{#@}","\\acute{#@}","\\tilde{#@}","\\grave{#@}"]},{class:"small hide-shift",latex:"\\lim_{#?}",shift:"\\lim_{x\\to\\infty}",variants:[{class:"small",latex:"\\liminf_{#?}"},{class:"small",latex:"\\limsup_{#?}"}]},"\\exponentialE"],[{latex:"\\cos",shift:"\\cos^{-1}",variants:[{class:"small",latex:"\\cosh"},{class:"small",latex:"\\cos^{-1}"},{class:"small",latex:"\\operatorname{arcosh}"}]},{latex:"\\log",shift:"\\log_{10}",variants:["\\log_{#0}","\\log_{10}"]},"\\left\\vert#0\\right\\vert",{latex:"\\larr",shift:"\\lArr",variants:[{latex:"\\impliedby",aside:"implied by"},{latex:"\\gets",aside:"gets"},"\\lArr","\\vdash",{latex:"\\models",aside:"models"}]},{latex:"\\forall",shift:"\\lnot",variants:[{latex:"\\land",aside:"and"},{latex:"\\lor",aside:"or"},{latex:"\\oplus",aside:"xor"},{latex:"\\lnot",aside:"not"},{latex:"\\downarrow",aside:"nor"},{latex:"\\uparrow",aside:"nand"},{latex:"\\curlywedge",aside:"nor"},{latex:"\\bar\\curlywedge",aside:"nand"}]},{latex:"\\ni",shift:"\\not\\owns"},"\\cap",{latex:"\\overline{#@}",shift:"\\underline{#@}",variants:["\\overbrace{#@}","\\overlinesegment{#@}","\\overleftrightarrow{#@}","\\overrightarrow{#@}","\\overleftarrow{#@}","\\overgroup{#@}","\\underbrace{#@}","\\underlinesegment{#@}","\\underleftrightarrow{#@}","\\underrightarrow{#@}","\\underleftarrow{#@}","\\undergroup{#@}"]},{class:"hide-shift small",latex:"\\int",shift:"\\iint",variants:[{latex:"\\int_{#?}^{#?}",class:"small"},{latex:"\\int",class:"small"},{latex:"\\smallint",class:"small"},{latex:"\\iint",class:"small"},{latex:"\\iiint",class:"small"},{latex:"\\oint",class:"small"},"\\intop","\\iiint","\\oiint","\\oiiint","\\intclockwise","\\varointclockwise","\\ointctrclockwise","\\intctrclockwise"]},{latex:"\\pi",shift:"\\tau",variants:["\\tau"]}],[{latex:"\\tan",shift:"\\tan^{-1}",variants:[{class:"small",latex:"\\tanh"},{class:"small",latex:"\\tan^{-1}"},{class:"small",latex:"\\operatorname{artanh}"},{class:"small",latex:"\\arctan"},{class:"small",latex:"\\operatorname{arctg}"},{class:"small",latex:"\\operatorname{tg}"}]},{latex:"\\exp",insert:"\\exp\\left(#0\\right)",variants:["\\exponentialE^{#0}"]},"\\left\\Vert#0\\right\\Vert",{latex:"\\lrArr",shift:"\\leftrightarrow",variants:[{latex:"\\iff",aside:"if and only if"},"\\leftrightarrow","\\leftrightarrows","\\Leftrightarrow",{latex:"^\\biconditional",aside:"biconditional"}]},{latex:"\\vert",shift:"!"},{latex:"#@^{\\complement}",aside:"complement",variants:[{latex:"\\setminus",aside:"set minus"},{latex:"\\smallsetminus",aside:"small set minus"}]},{latex:"\\subset",shift:"\\subseteq",variants:["\\subset","\\subseteq","\\subsetneq","\\varsubsetneq","\\subsetneqq","\\nsubset","\\nsubseteq","\\supset","\\supseteq","\\supsetneq","\\supsetneqq","\\nsupset","\\nsupseteq"]},{latex:"#@^{\\prime}",shift:"#@^{\\doubleprime}",variants:["#@^{\\doubleprime}","#@\\degree"]},{latex:"\\mathrm{d}",shift:"\\partial",variants:["\\mathrm{d}x",{latex:"\\dfrac{\\mathrm{d}}{\\mathrm{d} x}",class:"small"},{latex:"\\frac{\\partial}{\\partial x}",class:"small"},"\\partial"]},{latex:"\\infty",variants:["\\aleph_0","\\aleph_1","\\omega","\\mathfrak{m}"]}],[{label:"[shift]",width:2},{class:"box",latex:",",shift:";",variants:[";","?"]},{class:"box",latex:"\\colon",shift:"\\Colon",variants:[{latex:"\\Colon",aside:"such that",class:"box"},{latex:":",aside:"ratio",class:"box"},{latex:"\\vdots",aside:"",class:"box"},{latex:"\\ddots",aside:"",class:"box"},{latex:"\\ldotp",aside:"low dot",class:"box"},{latex:"\\cdotp",aside:"center dot",class:"box"},{latex:"\\ldots",aside:"low ellipsis",class:"box"},{latex:"\\cdots",aside:"center ellipsis",class:"box"},{latex:"\\therefore",aside:"therefore",class:"box"},{latex:"\\because",aside:"because",class:"box"}]},{class:"box",latex:"\\cdot",aside:"centered dot",shift:"\\ast",variants:["\\circ","\\bigcirc","\\bullet","\\odot","\\oslash","\\circledcirc","\\ast","\\star","\\times","\\doteq","\\doteqdot"]},"[separator]","[left]","[right]",{label:"[backspace]",width:1,class:"action hide-shift"},{label:"[return]",width:1}]]},compact:{label:"compact",rows:[["[+]","[-]","[*]","[/]","[=]","[.]","[(]","[)]","\\sqrt{#0}","#@^{#?}"],["[1]","[2]","[3]","[4]","[5]","[6]","[7]","[8]","[9]","[0]"],["[hr]"],["[undo]","[redo]","[separator]","[separator]","[separator]","[left]","[right]",{label:"[backspace]",class:"action hide-shift"},"[hide-keyboard]"]]},minimalist:{label:"minimalist",layers:[{style:`
|
|
3229
|
+
}`;break;case"core":i=nv;break;case"mathfield":i=ny;break;case"environment-popover":i=nx;break;case"suggestion-popover":i=n_;break;case"keystroke-caption":i=nw;break;case"virtual-keyboard":i=nk;break;case"ui":i=nM;break;case"menu":i=nS}return i}function nA(e){return nb||(nb={}),nb[e]||(nb[e]=new CSSStyleSheet,nb[e].replaceSync(nE(e))),nb[e]}function nz(e){var i;try{if(!("adoptedStyleSheets"in document)){if(window.document.getElementById(`mathlive-style-${e}`))return;let i=window.document.createElement("style");i.id=`mathlive-style-${e}`,i.append(window.document.createTextNode(nC(e,nE(e)))),window.document.head.appendChild(i);return}if(sL||(sL={}),(null!=(i=sL[e])?i:0)!==0)sL[e]+=1;else{let i=(ng||(ng={}),ng[e]||(ng[e]=new CSSStyleSheet,ng[e].replaceSync(nC(e,nE(e)))),ng[e]);document.adoptedStyleSheets=[...document.adoptedStyleSheets,i],sL[e]=1}}catch(i){console.error("Error injecting stylesheet",e,i)}}function nT(e){if("adoptedStyleSheets"in document&&null!=sL&&sL[e]&&(sL[e]-=1,sL[e]<=0)){let i=ng[e];document.adoptedStyleSheets=document.adoptedStyleSheets.filter(e=>e!==i)}}var nD=class e extends oG{constructor(e){var i;super(g(f({},e),{type:"accent",body:null!=(i=e.body)?i:void 0})),e.accentChar?this.accent=e.accentChar:this.svgAccent=null==e?void 0:e.svgAccent,this.skipBoundary=!0,this.captureSelection=!0}static fromJson(i){return new e(i)}toJson(){return g(f({},super.toJson()),{accentChar:this.accent,svgAccent:this.svgAccent})}render(e){var i;let r=new oW({parent:e,mathstyle:"cramp"},this.style),a=null!=(i=oG.createBox(r,this.body))?i:new oE("□",{style:this.style}),o=0;!this.hasEmptyBranch("body")&&2===this.body.length&&this.body[1].isCharacterBox()&&(o=a.skew);let n=Math.min(a.height,.431),l;if(this.svgAccent)l=oT(this.svgAccent),n=r.metrics.bigOpSpacing1-n;else if(this.accent){let e=new oE(this.accent,{fontFamily:"Main-Regular"});e.italic=0,l=new oE(e,{classes:"ML__accent-body"+(8407===this.accent||8411===this.accent||8412===this.accent?" ML__accent-combining-char":"")})}let s=(a.width-l.width)/2+a.left+2*o;l=new oB({shift:0,children:[{box:new oE(a)},-n,{box:l,marginLeft:s,classes:["ML__center"]}]});let c=new oE(l,{type:"ord"});return this.caret&&(c.caret=this.caret),this.bind(r,c.wrap(r)),this.attachSupsub(r,{base:c})}},nK={"(":")","{":"}","[":"]","|":"|","\\lbrace":"\\rbrace","\\lparen":"\\rparen","\\{":"\\}","\\langle":"\\rangle","\\lfloor":"\\rfloor","\\lceil":"\\rceil","\\vert":"\\vert","\\lvert":"\\rvert","\\Vert":"\\Vert","\\lVert":"\\rVert","\\lbrack":"\\rbrack","\\ulcorner":"\\urcorner","\\llcorner":"\\lrcorner","\\lgroup":"\\rgroup","\\lmoustache":"\\rmoustache"},nB=Object.fromEntries(Object.entries(nK).map(([e,i])=>[i,e]));function n$(e){var i;return null!=(i=({"[":91,"]":93,"(":40,")":41,"\\mid":8739,"|":8739,"∣":8739,"∥":8741,"\\|":8739,"\\{":123,"\\}":125,"\\lbrace":123,"\\rbrace":125,"\\lparen":40,"\\rparen":41,"\\lbrack":91,"\\rbrack":93,"\\vert":8739,"\\lvert":8739,"\\mvert":8739,"\\rvert":8739,"\\Vert":8741,"\\lVert":8741,"\\mVert":8741,"\\rVert":8741,"\\parallel":8741,"\\shortparallel":8741,"\\langle":10216,"\\rangle":10217,"\\lfloor":8970,"\\rfloor":8971,"\\lceil":8968,"\\rceil":8969,"\\ulcorner":9484,"\\urcorner":9488,"\\llcorner":9492,"\\lrcorner":9496,"\\lgroup":10222,"\\rgroup":10223,"\\lmoustache":9136,"\\rmoustache":9137,"\\surd":8730})[e])?i:e.codePointAt(0)}function nP(e,i,r,a,o){var n,l;let s=new oW({parent:a,mathstyle:"textstyle"},null==o?void 0:o.style),c=new oE(n$(e),{fontFamily:`Size${i}-Regular`,isSelected:o.isSelected,classes:(null!=(n=o.classes)?n:"")+` ML__delim-size${i}`,type:null!=(l=o.type)?l:"ignore"}).wrap(s);return r&&c.setTop((1-s.scalingFactor)*.25),c}function nO(e,i,r,a,o){var n;let l,s,c,d;l=c=d=n$(e),s=null;let u="Size1-Regular";"\\vert"===e||"\\lvert"===e||"\\rvert"===e||"\\mvert"===e||"\\mid"===e?c=l=d=8739:"\\Vert"===e||"\\lVert"===e||"\\rVert"===e||"\\mVert"===e||"\\|"===e?c=l=d=8741:"\\uparrow"===e?c=d=9168:"\\Uparrow"===e?c=d=8214:"\\downarrow"===e?l=c=9168:"\\Downarrow"===e?l=c=8214:"\\updownarrow"===e?(l=8593,c=9168,d=8595):"\\Updownarrow"===e?(l=8657,c=8214,d=8659):"["===e||"\\lbrack"===e?(l=9121,c=9122,d=9123,u="Size4-Regular"):"]"===e||"\\rbrack"===e?(l=9124,c=9125,d=9126,u="Size4-Regular"):"\\lfloor"===e||"⌊"===e?(c=l=9122,d=9123,u="Size4-Regular"):"\\lceil"===e||"⌈"===e?(l=9121,c=d=9122,u="Size4-Regular"):"\\rfloor"===e||"⌋"===e?(c=l=9125,d=9126,u="Size4-Regular"):"\\rceil"===e||"⌉"===e?(l=9124,c=d=9125,u="Size4-Regular"):"("===e||"\\lparen"===e?(l=9115,c=9116,d=9117,u="Size4-Regular"):")"===e||"\\rparen"===e?(l=9118,c=9119,d=9120,u="Size4-Regular"):"\\{"===e||"\\lbrace"===e?(l=9127,s=9128,d=9129,c=9130,u="Size4-Regular"):"\\}"===e||"\\rbrace"===e?(l=9131,s=9132,d=9133,c=9130,u="Size4-Regular"):"\\lgroup"===e||"⟮"===e?(l=9127,d=9129,c=9130,u="Size4-Regular"):"\\rgroup"===e||"⟯"===e?(l=9131,d=9133,c=9130,u="Size4-Regular"):"\\lmoustache"===e||"⎰"===e?(l=9127,d=9133,c=9130,u="Size4-Regular"):"\\rmoustache"===e||"⎱"===e?(l=9131,d=9129,c=9130,u="Size4-Regular"):"\\surd"===e?(l=57345,d=9143,c=57344,u="Size4-Regular"):"\\ulcorner"===e?(l=9484,c=d=32):"\\urcorner"===e?(l=9488,c=d=32):"\\llcorner"===e?(d=9492,c=l=32):"\\lrcorner"===e&&(l=9496,c=l=32);let h=oa(l,u),p=h.height+h.depth,m=oa(c,u),b=m.height+m.depth,y=oa(d,u),v=y.height+y.depth,x=0,_=1;if(null!==s){let e=oa(s,u);x=e.height+e.depth,_=2}let w=p+v+x,k=Math.max(0,Math.ceil((i-w)/(_*b))),M=w+k*_*b,S=.25;r&&(S*=a.scalingFactor);let L=M/2-S,C=[];C.push({box:new oE(d,{fontFamily:u})}),C.push(-.008);let E=new oE(c,{fontFamily:u});if(null===s)for(let e=0;e<k;e++)C.push({box:E});else{for(let e=0;e<k;e++)C.push({box:E});C.push(-.008),C.push({box:new oE(s,{fontFamily:u})}),C.push(-.008);for(let e=0;e<k;e++)C.push({box:E})}C.push(-.008),C.push({box:new oE(l,{fontFamily:u})});let A="";return"Size1-Regular"===u?A=" delim-size1":"Size4-Regular"===u&&(A=" delim-size4"),new oE(new oB({bottom:L,children:C},{classes:A}),g(f({},null!=o?o:{}),{classes:(null!=(n=null==o?void 0:o.classes)?n:"")+" ML__delim-mult"}))}var nR=new Set(["(",")","\\lparen","\\rparen","[","]","\\lbrack","\\rbrack","\\{","\\}","\\lbrace","\\rbrace","\\lfloor","\\rfloor","\\lceil","\\rceil","\\surd","⌊","⌋","⌈","⌉"]),nI=new Set(["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\mvert","\\mid","\\lgroup","\\rgroup","\\lmoustache","\\rmoustache","⟮","⟯","⎰","⎱"]),nN=new Set(["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"]),nq=[0,1.2,1.8,2.4,3],nF=[{type:"small",mathstyle:"scriptscriptstyle"},{type:"small",mathstyle:"scriptstyle"},{type:"small",mathstyle:"textstyle"},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],nV=[{type:"small",mathstyle:"scriptscriptstyle"},{type:"small",mathstyle:"scriptscriptstyle"},{type:"small",mathstyle:"textstyle"},{type:"stack"}],nj=[{type:"small",mathstyle:"scriptscriptstyle"},{type:"small",mathstyle:"scriptstyle"},{type:"small",mathstyle:"textstyle"},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}];function nH(e,i,r,a,o,n){var l,s,c;let d,u;if(!i||0===i.length||"."===i)return nU(o);"<"===i||"\\lt"===i?i="\\langle":(">"===i||"\\gt"===i)&&(i="\\rangle"),d=nN.has(i)?nF:nR.has(i)?nj:nV;let h=function(e,i,r,a){let o={"-4":0,"-3":1,0:2}[a.mathstyle.sizeDelta];for(let l=o;l<r.length&&"stack"!==r[l].type;l++){var n;let o=oa(e,"small"===(n=r[l]).type?"Main-Regular":"large"===n.type?"Size"+n.size+"-Regular":(n.type,"Size4-Regular"));if(o.defaultMetrics)return{type:"small",mathstyle:"scriptstyle"};let s=o.height+o.depth;if("small"===r[l].type&&("scriptscriptstyle"===r[l].mathstyle?s*=Math.max(oi[Math.max(1,a.size-2)],a.minFontScale):"scriptstyle"===r[l].mathstyle&&(s*=Math.max(oi[Math.max(1,a.size-1)],a.minFontScale))),s>i)return r[l]}return r[r.length-1]}(n$(i),r,d,o),p=new oW({parent:o,mathstyle:h.mathstyle},null==n?void 0:n.style);return"small"===h.type?(l=i,s=g(f({},n),{type:e}),u=new oE(n$(l),{fontFamily:"Main-Regular",isSelected:s.isSelected,classes:"ML__small-delim "+(null!=(c=s.classes)?c:"")}).wrap(p),a&&u.setTop((1-p.scalingFactor)*.25),u):"large"===h.type?nP(i,h.size,a,p,g(f({},n),{type:e})):(h.type,nO(i,r,a,p,g(f({},n),{type:e})))}function nW(e,i,r,a,o,n){if("."===i)return nU(o,null==n?void 0:n.classes);let l=.25*o.scalingFactor,s=Math.max(r-l,a+l);return nH(e,i,Math.max(s/500*901,2*s-.5),!0,o,n)}function nU(e,i){let r=new oE(null,{classes:" ML__nulldelimiter "+(null!=i?i:""),type:"ignore"});return r.width=e.getRegisterAsEm("nulldelimiterspace"),r.wrap(new oW({parent:e,mathstyle:"textstyle"}))}var nJ=class e extends oG{constructor(e){var i;super({type:"placeholder",command:"\\placeholder",mode:null!=(i=null==e?void 0:e.mode)?i:"math",style:null==e?void 0:e.style}),this.captureSelection=!0}static fromJson(i){return new e(i)}toJson(){return super.toJson()}render(e){let i;return this.value=e.placeholderSymbol,i="function"==typeof e.renderPlaceholder?e.renderPlaceholder(e):this.createBox(e),this.caret&&(i.classes+=" ML__placeholder-selected"),i}_serialize(e){return e.skipPlaceholders?"":"\\placeholder{}"}},nX=["matrix","matrix*","pmatrix","pmatrix*","bmatrix","bmatrix*","Bmatrix","Bmatrix*","vmatrix","vmatrix*","Vmatrix","Vmatrix*"],nG=["cases","dcases","rcases"],nZ=["align","align*","aligned","gather","gather*","gathered","split"],nY=["array","subequations","eqnarray"];function nQ(e){return nX.includes(e)}var n0=class e extends oG{get isMultiline(){return["lines","multline","multline*","align","split","gather","gathered"].includes(this.environmentName)}constructor(e,i,r,a={}){var o,n,l,s;if(super({type:"array",isRoot:a.isRoot}),this.environmentName=e,a.columns)0===a.columns.length?this.colFormat=[{align:"l"}]:this.colFormat=[...a.columns];else if(a.minColumns){let e=[];for(let i=0;i<a.minColumns;i++)e.push({align:"l"});this.colFormat=e}else this.colFormat=[{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"}];this.minColumns=null!=(o=a.minColumns)?o:1,this.minRows=null!=(n=a.minRows)?n:1,this.maxRows=null!=(l=a.maxRows)?l:1/0;let c=function(e,i,r){var a,o,n,l,s,c,d;let u=0;for(let e of r.columns)"align"in e&&(u+=1);u=Math.max(u,r.minColumns);let h=0,p=[],m=[];for(let n=0;n<i.length;n++){let l=i[n];h=Math.max(h,Math.min(l.length,u));let d=0,f=!0;for(;d<l.length;){let i=[],h=Math.min(l.length,d+u);for(;d<h;){i.push((s=l[d],c=e.mode,0===s.length?[new oG({type:"first",mode:c})]:"first"!==s[0].type?[new oG({type:"first",mode:c}),...s]:(s.slice(1).some(e=>"first"===e.type),s))),d+=1}if(i.length<r.minColumns)for(;i.length<r.minColumns;)i.push([new oG({type:"first",mode:e.mode})]);p.push(i),m.push(f?[...null!=(o=null==(a=r.rowRules)?void 0:a[n])?o:[]]:[]),f=!1}}if(m.push([...null!=(l=null==(n=r.rowRules)?void 0:n[i.length])?l:[]]),!e.isMultiline&&p.length>0&&1===p[p.length-1].length&&1===(d=p[p.length-1][0]).length&&"first"===d[0].type){p.pop();let e=m.pop();m[m.length-1].push(...e)}let f=[];for(let i of p){if(i.length!==h)for(let r=i.length;r<h;r++)e.isMultiline?i.push([new oG({type:"first",mode:e.mode})]):i.push([new oG({type:"first",mode:e.mode}),new nJ]);f.push(i)}let g=0,b=0;for(let i of f){for(let r of(b=0,i)){for(let i of r)i.parent=e,i.parentBranch=[g,b];b+=1}g+=1}return e.isDirty=!0,{rows:f,rowRules:m}}(this,i,{columns:this.colFormat,minColumns:this.minColumns,minRows:this.minRows,maxRows:this.maxRows,rowRules:a.rowRules});this._rows=c.rows,this.rowRules=c.rowRules,this.rowGaps=r,void 0!==a.arraycolsep&&(this.arraycolsep=a.arraycolsep),this.colSeparationType=a.colSeparationType,void 0!==a.arraystretch&&(this.arraystretch=a.arraystretch),a.mathstyleName&&(this.mathstyleName=a.mathstyleName),a.leftDelim&&(this.leftDelim=a.leftDelim),a.rightDelim&&(this.rightDelim=a.rightDelim),this.classes=null!=(s=a.classes)?s:[]}static fromJson(i){return new e(i.environmentName,i.array,i.rowGaps,i)}toJson(){let e=g(f({},super.toJson()),{environmentName:this.environmentName,array:this._rows.map(e=>e.map(e=>e.map(e=>e.toJson()))),rowGaps:this.rowGaps,columns:this.colFormat,colSeparationType:this.colSeparationType,minColumns:this.minColumns,minRows:this.minRows,maxRows:this.maxRows});return void 0!==this.arraystretch&&(e.arraystretch=this.arraystretch),void 0!==this.arraycolsep&&(e.arraycolsep=this.arraycolsep),this.leftDelim&&(e.leftDelim=this.leftDelim),this.rightDelim&&(e.rightDelim=this.rightDelim),this.isRoot&&(e.isRoot=!0),e.minColumns=this.minColumns,e.minRows=this.minRows,e.maxRows=this.maxRows,this.mathstyleName&&(e.mathstyleName=this.mathstyleName),this.classes.length>0&&(e.classes=this.classes),this.hasRowRules&&(e.rowRules=this.rowRules),e}get hasRowRules(){return this.rowRules.some(e=>e.length>0)}branch(e){var i;if(oX(e))return null!=(i=this._rows[e[0]][e[1]])?i:void 0}createBranch(e){var i;return oX(e)?(this.isDirty=!0,null!=(i=this.branch(e))?i:[]):[]}get rowCount(){return this._rows.length}get colCount(){return this._rows[0].length}get maxColumns(){return this.colFormat.filter(e=>!!e.align).length}removeBranch(e){if(oJ(e))return super.removeBranch(e);let[i,...r]=this.branch(e);return i.type,this._rows[e[0]][e[1]]=void 0,r.forEach(e=>{e.parent=void 0,e.parentBranch=void 0}),this.isDirty=!0,r}get hasChildren(){return this.children.length>0}get children(){let e=[];for(let i of this._rows)for(let r of i)if(r)for(let i of r)e.push(...i.children),e.push(i);return[...e,...super.children]}render(e){var i,r,a,o,n,l,s;let c=new oW({parent:e,mathstyle:this.mathstyleName},this.style),d=c.getRegisterAsEm("arrayrulewidth"),u=c.getRegisterAsEm("arraycolsep"),h=c.getRegisterAsEm("doublerulesep"),p=null!=(r=null!=(i=this.arraystretch)?i:c.getRegisterAsNumber("arraystretch"))?r:1,m="number"==typeof this.arraycolsep?this.arraycolsep:u;"small"===this.colSeparationType&&(m=.2778*(new oW({parent:e,mathstyle:"scriptstyle"}).scalingFactor/e.scalingFactor));let f=1.2*p,g=.7*f,b=.3*f,y=0,v=[],x=0,_=this._rows.length,w=[],k=e=>{if(e)for(let i=0;i<e.length;i++)i>0&&(y+=h),w.push({rule:e[i],y:y})};k(this.rowRules[0]);for(let e=0;e<_;++e){let i=this._rows[e];x=Math.max(x,i.length);let r=new oW({parent:c,mathstyle:this.mathstyleName},this.style),n=g/r.scalingFactor,l=b/r.scalingFactor,d={cells:[],height:0,depth:0,pos:0};for(let e of i){let i=this.isMultiline&&e&&(s=e).length>0&&s.every(e=>"first"===e.type)?function(e,i,r){let a=new oE(null,{classes:"ML__empty-line-anchor"}),o=e[0];o&&(o.id||(o.id=i.makeID()),a.atomID=o.id),a.setStyle("display","inline-block"),a.setStyle("width",0),a.setStyle("position","relative"),a.setStyle("height",Math.max(0,r.height+r.depth),"em"),a.setStyle("vertical-align",-r.depth,"em"),a.height=r.height,a.depth=r.depth;let n=e.find(e=>e.caret);return null!=n&&n.caret&&(a.caret=n.caret),e.some(e=>e.isSelected)&&a.selected(!0),a}(e,r,{height:g/r.scalingFactor,depth:b/r.scalingFactor}):null!=(a=oG.createBox(r,e,{type:"ignore"}))?a:new oE(null,{type:"ignore"});l=Math.max(l,i.depth),n=Math.max(n,i.height),d.cells.push(i)}let u=null!=(o=oN(this.rowGaps[e]))?o:0;u>0&&(u+=b,l=Math.max(l,u),u=0),e<_-1&&!nQ(this.environmentName)&&"cases"!==this.environmentName&&"array"!==this.environmentName&&(l+=c.getRegisterAsEm("jot")),d.height=n,d.depth=l,d.pos=y+=n,y+=l+u,v.push(d),k(this.rowRules[e+1])}let M="array"!==this.environmentName||this.isMultiline?y/2+.25:v[0].height,S=w.filter(e=>void 0===e.rule.from),L=w.filter(e=>void 0!==e.rule.from),C=(e,i)=>L.filter(({rule:r})=>{var a;return r.from<=e&&(null!=(a=r.to)?a:r.from)>=i}).map(({rule:e,y:i})=>({box:n3(e.style,d),shift:i-M})),E=[];for(let e=0;e<x;e++){let i=[];for(let r of v){let a=r.cells[e];a&&(a.depth=r.depth,a.height=r.height,i.push({box:a,shift:r.pos-M}))}i.push(...C(e,e)),i.length>0&&E.push(new oB({individualShift:i}))}let A=(e,i)=>{if(i<0||i+1>=E.length)return n2(e);let r=C(i,i+1);if(0===r.length)return n2(e);let a=new oB({individualShift:r});return a.width=e,a},z=[],T=!1,D=!1,K=0,B=!this.leftDelim,{colFormat:$}=this;for(let i of $){if("align"in i&&K>=E.length)break;if("align"in i)T?z.push(A(2*m,K-1)):(D||B)&&z.push(n2(m)),z.push(new oE(E[K],{classes:"col-align-"+i.align})),K++,T=!0,D=!1,B=!1;else if("gap"in i){if("number"==typeof i.gap)z.push(A(i.gap,T?K-1:-1));else{let r=function(e,i,r,a){if(!a)return null;let o=[];for(let n of i){let i=oG.createBox(e,a,{type:"ignore"});i&&(i.depth=n.depth,i.height=n.height,o.push({box:i,shift:n.pos-r}))}return new oB({individualShift:o}).wrap(e)}(e,v,M,i.gap);r&&z.push(r)}T=!1,D=!1,B=!1}else if("separator"in i){let e=new oE(null,{classes:"ML__vertical-separator"});e.height=y,e.setStyle("height",y,"em"),e.setStyle("border-right",`${d}em ${i.separator} currentColor`),e.setStyle("vertical-align",-(y-M),"em");let r=0;D?r=h-d:T&&(r=m-d),e.left=r,z.push(e),T=!1,D=!0,B=!1}}T&&!this.rightDelim&&z.push(n2(m));let P=new oE(z,{classes:["ML__mtable",...this.classes].join(" ")});if("array"!==this.environmentName||this.isMultiline||(P.height=v[0].height,P.depth=y-v[0].height),S.length>0&&(P=new oB({individualShift:[{box:P,shift:0},...S.map(({rule:e,y:i})=>({box:n3(e.style,d),shift:i-M}))]})),(!this.leftDelim||"."===this.leftDelim)&&(!this.rightDelim||"."===this.rightDelim))return this.caret&&(P.caret=this.caret),this.bind(e,P);let O=P.height,R=P.depth,I=this.bind(e,new oE([this.bind(e,nW("open",null!=(n=this.leftDelim)?n:".",O,R,c,{isSelected:this.isSelected})),P,this.bind(e,nW("close",null!=(l=this.rightDelim)?l:".",O,R,c,{isSelected:this.isSelected}))],{type:"ord"}));return I?(I.setStyle("display","inline-block"),this.caret&&(I.caret=this.caret),this.bind(e,this.attachSupsub(e,{base:I}))):null}_serialize(e){var i,r;let a=[];if("lines"===this.environmentName&&this._rows.length>1?a.push("\\displaylines{"):"lines"!==this.environmentName&&a.push(`\\begin{${this.environmentName}}`),"array"===this.environmentName){if(a.push("{"),void 0!==this.colFormat)for(let e of this.colFormat)"align"in e&&"string"==typeof e.align?a.push(e.align):"separator"in e&&"solid"===e.separator?a.push("|"):"separator"in e&&"dashed"===e.separator&&a.push(":");a.push("}")}a.push(...n6(this.rowRules[0]));for(let o=0;o<this._rows.length;o++){for(let i=0;i<this._rows[o].length;i++)i>0&&a.push(" & "),a.push(oG.serialize(this._rows[o][i],e));let n=null!=(i=this.rowRules[o+1])?i:[];if(o<this._rows.length-1||n.length>0){let e=this.rowGaps[o];null!=e&&e.dimension?a.push(`\\\\[${e.dimension} ${null!=(r=e.unit)?r:"pt"}] `):a.push("\\\\ ")}a.push(...n6(n))}return"lines"===this.environmentName&&this._rows.length>1?a.push("}"):"lines"!==this.environmentName&&a.push(`\\end{${this.environmentName}}`),of(a)}forEachCell(e){for(let i=0;i<this.rowCount;i++)for(let r=0;r<this.colCount;r++)e(this._rows[i][r],i,r)}getCell(e,i){var r;return null==(r=this._rows[e])?void 0:r[i]}setCell(e,i,r){for(let r of("array"===this.type&&Array.isArray(this._rows)&&this._rows[e][i],this._rows[e][i]))r.parent=void 0,r.parentBranch=void 0;let a=[new oG({type:"first",mode:this.mode}),...r.filter(e=>"first"!==e.type)];this._rows[e][i]=a,n4(this),this.isDirty=!0}addRowBefore(e){"array"===this.type&&Array.isArray(this._rows),this._rows.splice(e,0,Array.from({length:this.colCount},()=>n1(this,!this.isMultiline))),this.rowRules.splice(e,0,[]),n4(this),this.isDirty=!0}addRowAfter(e){"array"===this.type&&Array.isArray(this._rows),this._rows.splice(e+1,0,Array.from({length:this.colCount},()=>n1(this,!this.isMultiline))),this.rowRules.splice(e+1,0,[]),n4(this),this.isDirty=!0}removeRow(e){for(let i of("array"===this.type&&Array.isArray(this._rows)&&this.rowCount,this.rowRules.splice(e,1),this._rows.splice(e,1)))for(let e of i)if(e)for(let i of e)i.parent=void 0,i.parentBranch=void 0;n4(this),this.isDirty=!0}addColumnBefore(e){for(let i of("array"===this.type&&Array.isArray(this._rows),this._rows))i.splice(e,0,n1(this));n8(this.rowRules,e,1),n4(this),this.isDirty=!0}addColumnAfter(e){for(let i of("array"===this.type&&Array.isArray(this._rows),this._rows))i.splice(e+1,0,n1(this));n8(this.rowRules,e+1,1),n4(this),this.isDirty=!0}addColumn(){this.addColumnAfter(this.colCount-1)}removeColumn(e){for(let i of("array"===this.type&&Array.isArray(this._rows)&&this.colCount,this._rows))for(let r of i.splice(e,1))if(r)for(let e of r)e.parent=void 0,e.parentBranch=void 0;n8(this.rowRules,e,-1),n4(this),this.isDirty=!0}get cells(){let e=[];for(let i of this._rows)for(let r of i)r&&e.push(r.filter(e=>"first"!==e.type));return e}get rows(){return this._rows}};function n1(e,i=!1){let r=new oG({type:"first",mode:e.mode});r.parent=e;let a=[r];if(i){let i=new nJ;i.parent=e,a.push(i)}return a}function n4(e){for(let i=0;i<e.rowCount;i++)for(let r=0;r<e.colCount;r++){let a=e.getCell(i,r);if(a)for(let o of a)o&&(o.parent=e,o.parentBranch=[i,r])}}function n2(e){let i=new oE(null,{classes:"ML__arraycolsep"});return i.width=e,i}function n3(e,i){let r=new oE(null,{classes:"dashed"===e?"ML__hdashline":"ML__hline"});return r.height=i,r.depth=0,r.maxFontSize=i,r.setStyle("border-bottom",`${i}em ${e} currentColor`),r}function n6(e){return e&&0!==e.length?e.map(e=>{var i;if(void 0===e.from)return"dashed"===e.style?"\\hdashline ":"\\hline ";let r=null!=(i=e.to)?i:e.from;return`\\cline{${e.from+1}-${r+1}} `}):[]}function n8(e,i,r){var a;for(let o=0;o<e.length;o++){let n=[];for(let l of e[o]){if(void 0===l.from){n.push(l);continue}let e=l.from,o=null!=(a=l.to)?a:l.from;if(r>0)e>=i&&(e+=1),o>=i&&(o+=1);else{if(e===i&&o===i)continue;e>i&&(e-=1),o>=i&&(o-=1)}n.push(g(f({},l),{from:e,to:o}))}e[o]=n}}var n5=class e extends oG{constructor(e){super({mode:e.mode,command:e.command,style:e.style,body:e.body,type:"box"}),this.framecolor=e.framecolor,this.backgroundcolor=e.backgroundcolor,this.padding=e.padding,this.offset=e.offset,this.border=e.border}static fromJson(i){return new e(i)}toJson(){return g(f({},super.toJson()),{framecolor:this.framecolor,backgroundcolor:this.backgroundcolor,padding:this.padding,offset:this.offset,border:this.border})}render(e){var i,r,a,o;let n=oG.createBox(e,this.body,{type:"lift"});if(!n)return null;let l=e.toEm(null!=(i=this.offset)?i:{dimension:0});n.depth+=l,n.setStyle("display","inline-block"),n.setStyle("position","relative"),n.setStyle("height",Math.floor(100*n.height+n.depth)/100,"em"),n.setStyle("vertical-align",-Math.floor(100*n.height)/100,"em");let s=new oW({parent:e},this.style),c=s.toEm(null!=(r=this.padding)?r:{register:"fboxsep"}),d=new oE(null,{classes:"ML__box"});d.height=n.height+c,d.depth=n.depth+c,d.setStyle("box-sizing","border-box"),d.setStyle("position","absolute"),d.setStyle("top",-c+.3,"em"),d.setStyle("left",0),d.setStyle("height",d.height+d.depth,"em"),d.setStyle("width","100%"),this.backgroundcolor&&d.setStyle("background-color",null!=(a=s.toBackgroundColor(this.backgroundcolor))?a:"transparent"),this.framecolor&&d.setStyle("border",`${s.getRegisterAsEm("fboxrule",2)}em solid ${null!=(o=s.toColor(this.framecolor))?o:"black"}`),this.border&&d.setStyle("border",this.border);let u=new oE([d,n],{type:"lift"});return u.setStyle("display","inline-block"),u.setStyle("position","relative"),u.setStyle("line-height",0),u.height=n.height+c+(l>0?l:0),u.depth=n.depth+c+(l<0?-l:0),u.setStyle("padding-left",c,"em"),u.setStyle("padding-right",c,"em"),u.setStyle("height",Math.floor(100*(n.height+n.depth+2*c+Math.abs(l)))/100,"em"),u.setStyle("margin-top",-c,"em"),u.setStyle("top",Math.floor(100*(n.depth-n.height+2*c-l))/100,"em"),u.setStyle("vertical-align",Math.floor(100*(n.depth+2*c))/100,"em"),this.caret&&(u.caret=this.caret),this.attachSupsub(e,{base:u})}_serialize(e){return e.skipStyles?of([this.bodyToLatex(e),this.supsubToLatex(e)]):super._serialize(e)}},n7=class e extends oG{constructor(e,i){var r;super({type:"composition",mode:null!=(r=null==i?void 0:i.mode)?r:"math",value:e})}static fromJson(i){return new e(i.value,i)}toJson(){return super.toJson()}render(e){let i=new oE(this.value,{classes:"ML__composition",type:"composition"});return this.bind(e,i),this.caret&&(i.caret=this.caret),i}_serialize(e){return""}},n9=class e extends oG{constructor(e){super({type:"error",value:e,command:e,mode:"math"}),this.verbatimLatex=e}static fromJson(i){return new e(i.command)}toJson(){return super.toJson()}render(e){let i=this.createBox(e,{classes:"ML__error"});return this.caret&&(i.caret=this.caret),i}},le=class e extends oG{constructor(e,i){super({type:"group",mode:i}),this.body=e,this.boxType=e.length>1?"ord":"ignore",this.skipBoundary=!0,this.displayContainsHighlight=!1,(null==e?void 0:e.length)===1&&","===e[0].command&&(this.captureSelection=!0)}static fromJson(i){return new e(i.body,i.mode)}render(e){let i=oG.createBox(e,this.body,{type:this.boxType});return i?(this.caret&&(i.caret=this.caret),this.bind(e,i)):null}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let i=eM(this.command,this.mode);return null!=i&&i.serialize?i.serialize(this,e):`{${this.bodyToLatex(e)}}`}},lt=class e extends oG{constructor(e,i,r){super({type:"leftright",style:r.style,displayContainsHighlight:!0}),this.variant=e,this.body=i,this.leftDelim=r.leftDelim,this.rightDelim=r.rightDelim}static fromJson(i){var r;return new e(null!=(r=i.variant)?r:"",i.body,i)}toJson(){let e=super.toJson();return this.variant&&(e.variant=this.variant),this.leftDelim&&(e.leftDelim=this.leftDelim),this.rightDelim&&(e.rightDelim=this.rightDelim),e}_serialize(e){var i,r;let a=this.matchingRightDelim();return"left...right"===this.variant?of(["\\left",null!=(i=this.leftDelim)?i:".",this.bodyToLatex(e),"\\right",a]):"mleft...mright"===this.variant?of(["\\mleft",null!=(r=this.leftDelim)?r:".",this.bodyToLatex(e),"\\mright",a]):of([this.leftDelim&&"."!==this.leftDelim?this.leftDelim:"",this.bodyToLatex(e),a])}matchingRightDelim(){var e,i;if(this.rightDelim&&"?"!==this.rightDelim)return this.rightDelim;let r=null!=(e=this.leftDelim)?e:".";return null!=(i=nK[r])?i:r}render(e){var i,r;let a=new oW({parent:e},this.style);this.body;let o=new oW({parent:e,mathstyle:"textstyle"},this.style),n=null!=(i=oG.createBox(a,this.body,{type:"inner"}))?i:new oE(null,{type:"inner"}),l=n.height/o.scalingFactor,s=n.depth/o.scalingFactor,c=[];if(this.leftDelim&&c.push(this.bind(o,nW("open",this.leftDelim,l,s,o,{isSelected:this.isSelected,classes:"ML__open"+(this.containsCaret?" ML__contains-caret":""),mode:this.mode,style:this.style}))),n&&(function e(i,r,a,o,n){if(i)for(let l=0;l<i.length;l++){let s=i[l];"middle"===s.type?(i[l]=r.bind(a,nW("inner",s.value,o,n,a,{isSelected:r.isSelected})),i[l].caret=s.caret,i[l].isSelected=s.isSelected,i[l].cssId=s.cssId,i[l].htmlData=s.htmlData,i[l].htmlStyle=s.htmlStyle,i[l].attributes=s.attributes,i[l].cssProperties=s.cssProperties):s.children&&e(s.children,r,a,o,n)}}(n.children,this,a,l,s),c.push(n)),this.rightDelim){let e=this.containsCaret?" ML__contains-caret":"",i=this.rightDelim;"?"===i&&(a.smartFence?(i=this.matchingRightDelim(),e+=" ML__smart-fence__close"):i="."),c.push(this.bind(o,nW("close",i,l,s,o,{isSelected:this.isSelected,classes:e+" ML__close",mode:this.mode,style:this.style})))}let d="mleft...mright"===this.variant,u=this.leftSibling;u&&(!d&&u.isFunction&&(d=!0),!d&&"subsup"===u.type&&null!=(r=u.leftSibling)&&r.isFunction&&(d=!0));let h=new oE(c,{type:d?"close":"inner",classes:"ML__left-right"});return h.setStyle("margin-top",`${-n.depth}em`),h.setStyle("height",`${n.height+n.depth}em`),this.caret&&(h.caret=this.caret),this.bind(a,h.wrap(a))}},li=class e extends oG{constructor(e,i){var r;super({type:"macro",command:e,style:i.style}),this.body=i.body,void 0===i.captureSelection?i.args?this.captureSelection=!1:this.captureSelection=!0:this.captureSelection=i.captureSelection,this.macroArgs=i.args,this.expand=null!=(r=i.expand)&&r}static fromJson(i){return new e(i.command,i)}toJson(){let e=super.toJson();return this.expand&&(e.expand=!0),void 0!==this.captureSelection&&(e.captureSelection=this.captureSelection),this.macroArgs&&(e.args=this.macroArgs),e}_serialize(e){var i;return e.expandMacro&&this.expand?this.bodyToLatex(e):this.command+(null!=(i=this.macroArgs)?i:"")}applyStyle(e,i){let r={};e.color&&(r.color=e.color),e.backgroundColor&&(r.backgroundColor=e.backgroundColor),super.applyStyle(r,i)}render(e){let i=oG.createBox(e,this.body,{type:"lift"});return i?(this.caret&&(i.caret=this.caret),this.bind(e,i)):null}},lr=class e extends oG{constructor(){super({type:"macro-argument"})}static fromJson(i){return new e}toJson(){return super.toJson()}_serialize(e){return""}render(e){return null}},la=class e extends oG{constructor(e,i,r=!1,a,o){var n;super({type:"prompt",mode:null!=(n=null==o?void 0:o.mode)?n:"math",style:null==o?void 0:o.style,command:"\\placeholder"}),this.body=a,this.correctness=i,this.placeholderId=e,this.locked=r,this.captureSelection=this.locked}static fromJson(i){return new e(i.placeholderId,i.correctness,i.locked,i.body,i)}toJson(){let e=super.toJson();return this.placeholderId&&(e.placeholderId=this.placeholderId),this.body||delete e.body,this.body&&(e.body=this.body.filter(e=>"first"!==e.type).map(e=>e.toJson())),this.correctness&&(e.correctness=this.correctness),e.locked=this.locked,e}render(e){var i,r,a,o,n;let l=new oW({parent:e}),s=l.getRegisterAsEm("fboxsep"),c=oG.createBox(e,this.body);if(!c)return null;let d=!this.body||0===this.body.length||this.body.every(e=>"first"===e.type)?new nJ({mode:this.mode,style:this.style}).render(new oW({parent:e,isPhantom:!0})):null,u=null!=(i=null==d?void 0:d.height)?i:l.metrics.xHeight,h=null!=(r=null==d?void 0:d.depth)?r:u/2,p=Math.max(null!=(a=c.height)?a:0,u),m=Math.max(null!=(o=c.depth)?o:0,h);c.setStyle("vertical-align",`calc(-${p}em + 2px)`),"correct"===this.correctness?c.setStyle("color","var(--correct-color, var(--ML__correct-color))"):"incorrect"===this.correctness&&c.setStyle("color","var(--incorrect-color, var(--ML__incorrect-color))");let f=p+m+2*s-2*s,g=new oE(c,{type:"ord"});g.setStyle("display","inline-block"),g.height=p,g.depth=m,g.setStyle("height",p+m,"em"),g.setStyle("vertical-align",-s,"em"),(null!=(n=c.width)?n:0)<f&&(g.width=f,g.setStyle("width",f,"em"));let b="ML__prompt ";this.locked?b+=" ML__lockedPromptBox ":b+=" ML__editablePromptBox ","correct"===this.correctness?b+=" ML__correctPromptBox ":"incorrect"===this.correctness&&(b+=" ML__incorrectPromptBox "),this.containsCaret&&(b+=" ML__focusedPromptBox ");let y=new oE(null,{classes:b,attributes:{part:"prompt"}});y.height=g.height+s,y.depth=g.depth+s,y.width=g.width+2*s,y.setStyle("position","absolute"),y.setStyle("height",g.height+g.depth+2*s,"em"),0===s&&y.setStyle("width","100%"),0!==s&&(y.setStyle("width",`calc(100% + ${2*s}em)`),y.setStyle("top",s,"em"),y.setStyle("left",-s,"em"));let v="";"incorrect"===this.correctness&&(v+='<line x1="3%" y1="97%" x2="97%" y2="3%" stroke-width="0.5" stroke="var(--incorrect-color, var(--ML__incorrect-color))" stroke-linecap="round" />'),v&&(y.svgOverlay=v);let x=new oE([y,g],{classes:"ML__prompt-atom"});g.setStyle("line-height",1),x.setStyle("position","relative"),x.setStyle("display","inline-block"),x.setStyle("line-height",0),x.height=p+s+.2,x.depth=m+s,x.left=s,x.right=s,x.setStyle("height",p+2*s,"em"),x.setStyle("top",m-p-s/2,"em"),x.setStyle("vertical-align",g.depth,"em"),x.setStyle("margin-left",.5,"em"),x.setStyle("margin-right",.5,"em"),this.caret&&(x.caret=this.caret);let _=this.attachSupsub(e,{base:x}),w=this.bind(l,_);return w&&this.id&&(y.atomID=this.id,g.atomID=this.id,x.atomID=this.id),w}_serialize(e){var i;let r=null!=(i=this.bodyToLatex(e))?i:"";if(e.skipPlaceholders)return r;let a="\\placeholder";return this.placeholderId&&(a+=`[${this.placeholderId}]`),"correct"===this.correctness?a+="[correct]":"incorrect"===this.correctness&&(a+="[incorrect]"),this.locked&&(a+="[locked]"),og(a,r)}},lo=class e extends oG{constructor(e){super({type:"subsup",style:null==e?void 0:e.style}),this.subsupPlacement="auto"}get children(){if(!this._children){let e=[],i=this.branch("subscript");if(i)for(let r of i)e.push(...r.children),e.push(r);let r=this.branch("superscript");if(r)for(let i of r)e.push(...i.children),e.push(i);this._children=e}return this._children}static fromJson(i){let r=new e(i);for(let e of oU)i[e]&&r.setChildren(i[e],e);return r}render(e){var i;let r=new oW({parent:e,isPhantom:!0}),a=this.leftSibling,o=null!=(i=a.render(r))?i:new oE(null),n=new oE(null);return n.height=o.height,n.depth=o.depth,this.attachSupsub(e,{base:n,isCharacterBox:a.isCharacterBox(),type:"ignore"})}_serialize(e){return this.supsubToLatex(e)}};function ln(e){return!!e&&!/^(<$$>|<$>|<space>|<{>|<}>|#[0-9\?]|\\.+)$/.test(e)}var ll=class{constructor(e,i,r){var a,o,n,l;this.errors=[],this.index=0,this.endCount=0,this.localMacros={},null!=r||(r={}),this.tokens=e,this.context=i instanceof oW&&!(null!=r&&r.parseMode)&&!r.mathstyle?i:new oW({from:i,mathstyle:r.mathstyle},r.style),this.args=null!=(a=r.args)?a:void 0,this.smartFence=this.context.smartFence,this.parsingContext={parent:void 0,mathlist:[],style:null!=(o=r.style)?o:{},parseMode:null!=(n=r.parseMode)?n:"math",mathstyle:null!=(l=r.mathstyle)?l:"displaystyle",tabular:!1}}beginContext(e){var i,r,a,o,n,l;if(null!=e&&e.root){this.parsingContext={parent:this.parsingContext.parent,mathlist:[],style:{},parseMode:null!=(i=null==e?void 0:e.mode)?i:"math",mathstyle:null!=(r=null==e?void 0:e.mathstyle)?r:"displaystyle",tabular:null!=(a=null==e?void 0:e.tabular)&&a};return}let s=this.parsingContext,c={parent:s,mathlist:[],style:f({},s.style),parseMode:null!=(o=null==e?void 0:e.mode)?o:s.parseMode,mathstyle:null!=(n=null==e?void 0:e.mathstyle)?n:s.mathstyle,tabular:null!=(l=null==e?void 0:e.tabular)&&l};this.parsingContext=c}endContext(){this.parsingContext=this.parsingContext.parent}onError(e){this.errors.push(f({before:ob(this.tokens.slice(this.index,this.index+10)),after:ob(this.tokens.slice(Math.max(0,this.index-10),this.index))},e))}get mathlist(){return this.parsingContext.mathlist}set mathlist(e){this.parsingContext.mathlist=e}get parseMode(){return this.parsingContext.parseMode}set parseMode(e){this.parsingContext.parseMode=e}get tabularMode(){return this.parsingContext.tabular}get style(){let e=this.parsingContext;for(;e;){if(e.style)return f({},e.style);e=e.parent}return{}}set style(e){this.parsingContext.style=e}end(){return this.endCount++,this.index>=this.tokens.length||this.endCount>1e3}next(){this.index+=1}get(){return this.endCount=0,this.index<this.tokens.length?this.tokens[this.index++]:""}peek(){return this.tokens[this.index]}expandUnicode(){if(!this.peek()||"math"!==this.parseMode)return;let e=function(e){var i;if("{}<>[]$&*#^_%:'˜".includes(e)||e.length>1)return;let r=null!=(i=e.codePointAt(0))?i:0,a=Z[r];if(a)return a;let{char:o,variant:n,style:l}=function(e){var i;if((e<119808||e>120831)&&(e<8448||e>8527))return{char:String.fromCodePoint(e)};for(let r in Y)if(Y[r]===e){e=null!=(i=r.codePointAt(0))?i:0;break}for(let i of Q)if(e>=i.start&&e<i.start+i.len)return{char:String.fromCodePoint(e-i.start+i.offset),variant:i.variant,style:i.style};return{char:String.fromCodePoint(e)}}(r);if(!(!n&&!l)){switch(a=o,n){case"double-struck":a=`\\mathbb{${a}}`;break;case"fraktur":a=`\\mathfrak{${a}}`;break;case"script":a=`\\mathscr{${a}}`;break;case"sans-serif":a=`\\mathsf{${a}}`;break;case"monospace":a=`\\mathtt{${a}}`;break;case"calligraphic":a=`\\mathcal{${a}}`}switch(l){case"bold":a=`\\mathbf{${a}}`;break;case"italic":a=`\\mathit{${a}}`;break;case"bolditalic":a=`\\mathbfit{${a}}`}return a}}(this.peek());e&&this.tokens.splice(this.index,1,...om(e))}match(e){return this.tokens[this.index]===e&&(this.index++,!0)}lastSubsupAtom(){let e;return this.mathlist.length>0&&("subsup"===(e=this.mathlist[this.mathlist.length-1]).type||void 0!==e.subsupPlacement)||(e=new lo({style:this.style}),this.mathlist.push(e)),e}hasPattern(e){return e.test(this.tokens[this.index])}hasInfixCommand(){var e;let{index:i}=this;if(i<this.tokens.length&&this.tokens[i].startsWith("\\")){let r=eM(this.tokens[i],this.parseMode);return!!r&&"symbol"!==r.definitionType&&(!r.ifMode||!!r.ifMode.includes(this.parseMode))&&null!=(e=r.infix)&&e}return!1}matchColumnSeparator(){return!!this.tabularMode&&"&"===this.peek()&&(this.index++,!0)}matchRowSeparator(){if(!this.tabularMode)return!1;let e=this.peek();return("\\\\"===e||"\\cr"===e||"\\tabularnewline"===e)&&(this.index++,!0)}placeholder(){var e;let i=null==(e=this.args)?void 0:e.call(this,"?");return i?ls(i,{parseMode:this.parseMode,mathstyle:"textstyle"}):[new nJ({mode:this.parseMode,style:this.style})]}skipWhitespace(){for(;this.match("<space>"););}skipUntilToken(e){let i=this.tokens[this.index];for(;i&&i!==e;)i=this.tokens[++this.index];i===e&&this.index++}skipFiller(){for(;this.match("\\relax")||this.match("<space>"););}matchKeyword(e){let i=this.index,r=this.end(),a="";for(;!r;){let i=this.get();ln(i)?(a+=i,r=this.end()||a.length>=e.length):r=!0}let o=e.toUpperCase()===a.toUpperCase();return o||(this.index=i),o}scanString(){let e="";for(;!this.end();){let i=this.peek();if("]"===i)break;if("<space>"===i)e+=" ";else if(i.startsWith("\\"))this.onError({code:"unexpected-command-in-string"}),e+=i.substring(1);else if(ln(i))e+=i;else break;this.next()}return e}scanBalancedString(){let e="",i=this.end(),r=1;for(;!i;){let a=this.get();"<space>"===a?e+=" ":"<{>"===a?(e+="{",r+=1):"<}>"===a?(r-=1)>0?e+="}":this.index-=1:"<$>"===a?e+="$":"<$$>"===a?e+="$$":e+=a,i=0===r||this.end()}return e}scanLiteralGroup(){var e;if(!this.match("<{>"))return"";let i="",r=1;for(;r>0&&!this.end();){let a=this.get();"<}>"===a?(r-=1)>0&&(i+="}"):"<{>"===a?(r+=1,i+="{"):(/\\[a-zA-Z]+$/.test(i)&&/^[a-zA-Z]/.test(a)&&(i+=" "),i+=null!=(e=({"<space>":" ","<$$>":"$$","<$>":"$"})[a])?e:a)}return i}scanNumber(e=!0){var i,r;let a=!1,o=this.peek();for(;"<space>"===o||"+"===o||"-"===o;)this.get(),"-"===o&&(a=!a),o=this.peek();e=!!e;let n=10,l=/\d/;if(this.match("'"))n=8,l=/[0-7]/,e=!0;else if(this.match('"'))n=16,l=/[\dA-F]/,e=!0;else if(this.match("x"))n=16,l=/[\dA-Fa-f]/,e=!0;else if(this.match("`"))return(o=this.get())?2===o.length&&o.startsWith("\\")?{number:(a?-1:1)*(null!=(i=o.codePointAt(1))?i:0),base:"alpha"}:{number:(a?-1:1)*(null!=(r=o.codePointAt(0))?r:0),base:"alpha"}:null;let s="";for(;this.hasPattern(l);)s+=this.get();if(!e&&(this.match(".")||this.match(",")))for(s+=".";this.hasPattern(l);)s+=this.get();let c=e?Number.parseInt(s,n):Number.parseFloat(s);return Number.isNaN(c)?null:{number:a?-c:c,base:16===n?"hexadecimal":8===n?"octal":"decimal"}}scanRegister(){var e;let i=this.index,r=this.scanNumber(!1);if(this.skipWhitespace(),this.match("\\relax"))return r;let a=!1;if(null===r)for(;;){let e=this.peek();if("-"===e)a=!a;else if("+"!==e)break;this.next(),this.skipWhitespace()}if(this.match("\\global")){this.skipWhitespace();let e=this.get();return e.startsWith("\\")?r?{register:e,global:!0,factor:(a?-1:1)*r.number}:a?{register:e,global:!0,factor:-1}:{register:e,global:!0}:(this.index=i,null)}let o=this.get();return null!=o&&o.startsWith("\\")?(o=o.substring(1),this.context.registers[o]?a&&null===r?{register:o}:{register:o,factor:(a?-1:1)*(null!=(e=null==r?void 0:r.number)?e:1)}:(this.index=i,null)):(this.index=i,null)}scanValue(){let e=this.scanRegister();if(e)return e;let i=this.index,r=this.scanGlueOrDimen();if(r&&("unit"in r||"glue"in r&&"unit"in r.glue))return r;this.index=i;let a=this.scanNumber();if(a)return a;if(this.end()||!ln(this.peek()))return null;let o=this.scanString();return o.length>0?{string:o}:null}scanDimen(){let e,i=this.scanNumber(!1);if(null===i)return null;let r=i.number;return this.skipWhitespace(),this.matchKeyword("true"),this.skipWhitespace(),this.matchKeyword("pt")?e="pt":this.matchKeyword("mm")?e="mm":this.matchKeyword("cm")?e="cm":this.matchKeyword("ex")?e="ex":this.matchKeyword("px")?e="px":this.matchKeyword("em")?e="em":this.matchKeyword("bp")?e="bp":this.matchKeyword("dd")?e="dd":this.matchKeyword("pc")?e="pc":this.matchKeyword("in")?e="in":this.matchKeyword("mu")&&(e="mu"),e?{dimension:r,unit:e}:{dimension:r}}scanGlueOrDimen(){let e=this.scanDimen();if(null===e)return null;if(this.skipWhitespace(),this.match("\\relax"))return e;let i={glue:e};if(this.matchKeyword("plus")){let e=this.scanDimen();if(!e)return i;i.grow=e}if(this.skipWhitespace(),this.match("\\relax"))return i;if(this.skipWhitespace(),this.matchKeyword("minus")){let e=this.scanDimen();if(!e)return i;i.shrink=e}return i.grow||i.shrink?i:e}scanColspec(){this.skipWhitespace();let e=[];for(;!this.end()&&"<}>"!==this.peek()&&"]"!==this.peek();){let i=this.get();"c"===i||"r"===i||"l"===i?e.push({align:i}):"|"===i?e.push({separator:"solid"}):":"===i?e.push({separator:"dashed"}):"@"===i&&(this.match("<{>")&&(this.beginContext({mode:"math"}),e.push({gap:this.scan(e=>"<}>"===e)}),this.endContext()),this.match("<}>")||this.onError({code:"unbalanced-braces"}))}return e}scanModeSet(){let e;if(this.match("\\(")&&(e="textstyle"),!e&&this.match("\\[")&&(e="displaystyle"),!e)return null;this.beginContext({mode:"math",mathstyle:e});let i=this.scan(i=>i===("displaystyle"===e?"\\]":"\\)"));return this.match("displaystyle"===e?"\\]":"\\)")||this.onError({code:"unbalanced-mode-shift"}),this.endContext(),i}scanModeShift(){let e="";if(this.match("<$>")&&(e="<$>"),!e&&this.match("<$$>")&&(e="<$$>"),!e)return null;this.beginContext({mode:"math",mathstyle:"<$>"===e?"textstyle":"displaystyle"});let i=this.scan(i=>i===e);return this.match(e)||this.onError({code:"unbalanced-mode-shift"}),this.endContext(),i}scanEnvironment(){var e;if(!this.match("\\begin"))return null;let i=this.scanArgument("string");if(!i)return null;let r=null!=(e=el[i])?e:null;if(!r)return this.onError({code:"unknown-environment",arg:i}),null;let a=[];if(r.params)for(let e of r.params)if(e.isOptional)a.push(this.scanOptionalArgument(e.type));else{let r=this.scanArgument(e.type);r||this.onError({code:"missing-argument",arg:i}),a.push(r)}this.beginContext({tabular:r.tabular,root:r.rootOnly});let o=[],n=[],l=[this.scanRowRules()],s=[],c=!1;do if(this.end()&&(this.onError({code:"unbalanced-environment",arg:i}),c=!0),!c&&this.match("\\end")&&(this.scanArgument("string")!==i&&this.onError({code:"unbalanced-environment",arg:i}),c=!0),!c)if(this.matchColumnSeparator())s.push(this.mathlist),this.mathlist=[];else if(this.matchRowSeparator()){s.push(this.mathlist),this.mathlist=[];let e=null;this.skipWhitespace(),this.match("[")&&(e=this.scanDimen(),this.skipWhitespace(),this.match("]")),n.push(null!=e?e:{dimension:0}),o.push(s),s=[],l.push(this.scanRowRules())}else this.mathlist.push(...this.scan(e=>["<}>","&","\\end","\\cr","\\\\","\\tabularnewline"].includes(e)));while(!c)return s.push(this.mathlist),s.length>0&&o.push(s),this.endContext(),r.rootOnly&&(this.index=this.tokens.length),r.createAtom(i,o,n,a,this.context.maxMatrixCols,l.some(e=>e.length>0)?l:void 0)}scanRowRules(){var e;if(!this.tabularMode)return[];let i=[];for(this.skipWhitespace();!this.end();){if(this.match("\\hline"))i.push({style:"solid"});else if(this.match("\\hdashline"))i.push({style:"dashed"});else if(this.match("\\cline")){let r=(null!=(e=this.scanArgument("string"))?e:"").match(/^\s*(\d+)\s*(?:-\s*(\d+))?\s*$/);if(r){let e=Number.parseInt(r[1],10)-1,a=void 0===r[2]?e:Number.parseInt(r[2],10)-1;e>=0&&a>=e?i.push({style:"solid",from:e,to:a}):this.onError({code:"missing-argument",arg:"\\cline"})}else this.onError({code:"missing-argument",arg:"\\cline"})}else break;this.skipWhitespace()}return i}scanExpression(){let e=this.mathlist;if(this.mathlist=[],this.parseExpression()){let i=this.mathlist;return this.mathlist=e,i}return this.mathlist=e,null}scan(e){let i;this.beginContext(),e||(e=e=>"<}>"===e);let r="",a=null,o=[],n=null;for(;!this.end()&&!e(this.peek());)this.hasInfixCommand()&&!r?((a=eM(r=this.get(),"math"))&&(o=this.scanArguments(a)[1]),n=this.mathlist,this.mathlist=[]):this.parseExpression();return r?(o.unshift(this.mathlist),n&&o.unshift(n),i=[a.createAtom({command:r,args:o,style:this.style,mode:this.parseMode})]):i=this.mathlist,this.endContext(),i}scanGroup(){let e=this.index;if(!this.match("<{>"))return null;let i=this.scan(e=>"<}>"===e);if(this.match("<}>")||this.onError({code:"unbalanced-braces"}),1===i.length&&"placeholder"===i[0].type)return i[0];let r=new le(i,this.parseMode);return r.verbatimLatex=ob(this.tokens.slice(e,this.index)),r}scanSmartFence(){if(this.skipWhitespace(),!this.match("("))return null;this.beginContext();let e=1;for(;!this.end()&&0!==e;)this.match("(")&&(e+=1),this.match(")")&&(e-=1),0!==e&&this.parseExpression();let i=new lt("",this.mathlist,{leftDelim:"(",rightDelim:0===e?")":"?"});return this.endContext(),i}scanDelim(){this.skipWhitespace();let e=this.peek();if(!e)return this.onError({code:"unexpected-end-of-string"}),null;if(!ln(e)&&!e.startsWith("\\"))return null;this.next();let i=eM(e,"math");return i?"function"===i.definitionType&&i.ifMode&&!i.ifMode.includes(this.parseMode)?(this.onError({code:"unexpected-delimiter",arg:e}),null):"symbol"===i.definitionType&&("mopen"===i.type||"mclose"===i.type)||/^(\.|\?|\||<|>|\\vert|\\Vert|\\\||\\surd|\\uparrow|\\downarrow|\\Uparrow|\\Downarrow|\\updownarrow|\\Updownarrow|\\mid|\\mvert|\\mVert)$/.test(e)?e:(this.onError({code:"unexpected-delimiter",arg:e}),null):(this.onError({code:"unknown-command",arg:e}),null)}scanLeftRight(){var e;if(this.match("\\right"))return this.onError({code:"unbalanced-braces"}),new n9("\\right");if(this.match("\\mright"))return this.onError({code:"unbalanced-braces"}),new n9("\\mright");let i="\\right";if(!this.match("\\left")){if(!this.match("\\mleft"))return null;i="\\mright"}let r=this.scanDelim();if(!r)return this.onError({code:"unexpected-delimiter"}),new n9("\\right"===i?"\\left":"\\mleft");for(this.beginContext();!this.end()&&!this.match(i);)this.parseExpression();let a=this.mathlist;return this.endContext(),new lt("\\right"===i?"left...right":"mleft...mright",a,{leftDelim:r,rightDelim:null!=(e=this.scanDelim())?e:".",style:this.style})}parseSupSub(){if("math"!==this.parseMode)return!1;let e=this.peek();if("^"!==e&&"_"!==e&&"'"!==e)return!1;let i=this.lastSubsupAtom();for(;"^"===e||"_"===e||"'"===e;)this.match("'")?this.match("'")?i.addChild(new oG({type:"mord",command:"\\doubleprime",mode:"math",value:"′′"}),"superscript"):i.addChild(new oG({type:"mord",command:"\\prime",mode:"math",value:"′"}),"superscript"):(this.match("^")||this.match("_"))&&i.addChildren(et(this.scanArgument("expression")),"_"===e?"subscript":"superscript"),e=this.peek();return!0}parseLimits(){if("math"!==this.parseMode)return!1;let e=this.match("\\limits"),i=!e&&this.match("\\nolimits"),r=!i&&!e&&this.match("\\displaylimits");if(!e&&!i&&!r)return!1;let a=this.mathlist.length>0?this.mathlist[this.mathlist.length-1]:null;return null!==a&&(a.explicitSubsupPlacement=!0,e&&(a.subsupPlacement="over-under"),i&&(a.subsupPlacement="adjacent"),r&&(a.subsupPlacement="auto"),!0)}scanArguments(e){if(!(null!=e&&e.params))return[void 0,[]];let i,r=[],a=2*!!e.infix;for(;a<e.params.length;){let o=e.params[a];"rest"===o.type?r.push(this.scan(e=>["<}>","&","\\end","\\cr","\\\\","\\tabularnewline","\\right"].includes(e))):o.isOptional?r.push(this.scanOptionalArgument(o.type)):o.type.endsWith("*")?i=o.type.slice(0,-1):r.push(this.scanArgument(o.type)),a+=1}return[i,r]}scanSymbolOrLiteral(){let e,i=this.peek();if(!i)return null;if(this.next(),ln(i)){let e=ov.createAtom(this.parseMode,i,f({},this.style));return e?[e]:null}if(e=this.scanMacro(i))return[e];if(i.startsWith("\\")){let r=eM(i,this.parseMode);if(!r)return this.onError({code:"unknown-command",arg:i}),[new n9(i)];if("symbol"===r.definitionType){let a=f({},this.style);r.variant&&(a.variant=r.variant),e=new oG({type:r.type,command:i,style:a,value:String.fromCodePoint(r.codepoint),mode:this.parseMode,verbatimLatex:i})}else{if(r.applyMode||r.applyStyle||r.infix)return this.onError({code:"invalid-command",arg:i}),[new n9(i)];r.createAtom&&(e=r.createAtom({command:i,args:[],style:this.style,mode:this.parseMode}))}}return e?[e]:null}scanArgument(e){var i;this.skipFiller();let r=this.parseMode;if("auto"===e&&(e=r),!this.match("<{>")){if("string"===e)return this.scanString();if("value"===e)return this.scanValue();if("delim"===e)return null!=(i=this.scanDelim())?i:".";if("expression"===e)return this.scanExpression();if("math"===e){e!==r&&this.beginContext({mode:"math"});let i=this.scanSymbolOrLiteral();return e!==r&&this.endContext(),i}if("text"===e){e!==r&&this.beginContext({mode:"text"});let i=this.scanSymbolOrLiteral();return e!==r&&this.endContext(),i}return"balanced-string"===e?null:"rest"===e?this.scan(e=>["<}>","&","\\end","\\cr","\\\\","\\tabularnewline","\\right"].includes(e)):null}if("text"===e){this.beginContext({mode:"text"});do this.mathlist.push(...this.scan());while(!this.match("<}>")&&!this.end())let e=this.mathlist;return this.endContext(),{group:e}}if("math"===e){this.beginContext({mode:"math"});do this.mathlist.push(...this.scan());while(!this.match("<}>")&&!this.end())let e=this.mathlist;return this.endContext(),{group:e}}if("rest"===e){let e=this.scan();return this.match("<}>")||this.onError({code:"unbalanced-braces"}),{group:e}}let a=null;if("expression"===e){this.beginContext({mode:"math"});do this.mathlist.push(...this.scan());while(!this.match("<}>")&&!this.end())let e=this.mathlist;return this.endContext(),{group:e}}return"string"===e?a=this.scanString():"balanced-string"===e?a=this.scanBalancedString():"colspec"===e?a=this.scanColspec():"value"===e&&(a=this.scanValue()),this.skipUntilToken("<}>"),a}scanOptionalArgument(e){if(e="auto"===e?this.parseMode:e,this.skipFiller(),!this.match("["))return null;let i=null;for(;!this.end()&&!this.match("]");)if("string"===e)i=this.scanString();else if("value"===e)i=this.scanValue();else if("colspec"===e)i=this.scanColspec();else if("bbox"===e){let e={};for(let i of this.scanString().toLowerCase().trim().split(/,(?![^(]*\)(?:(?:[^(]*\)){2})*[^"]*$)/)){let r=i.match(/^\s*([\d.]+)\s*([a-z]{2})/);if(r)e.padding={dimension:Number.parseFloat(r[1]),unit:r[2]};else{let r=i.match(/^\s*border\s*:\s*(.*)/);r?e.border=r[1]:e.backgroundcolor={string:i}}}i=e}else"math"===e&&(this.beginContext({mode:"math"}),i=this.mathlist.concat(this.scan(e=>"]"===e)),this.endContext());return i}scanSymbolOrCommand(e){var i,r,a;if("\\placeholder"===e){let e=this.scanOptionalArgument("string"),i=this.scanOptionalArgument("math"),r=oG.serialize(i,{defaultMode:"math"}),a=[],o;o||"correct"!==r?o||"incorrect"!==r?""!==r&&(a=i):o="incorrect":o="correct";let n="locked"===this.scanOptionalArgument("string"),l=this.scanArgument("auto"),s;return s=l&&Array.isArray(l)&&l.length>0?l:l&&"object"==typeof l&&"group"in l?l.group:a,e?[new la(e,o,n,null!=s?s:a,{mode:this.parseMode,style:this.style})]:[new nJ({mode:this.parseMode,style:this.style})]}if("\\renewcommand"===e||"\\newcommand"===e||"\\providecommand"===e||"\\def"===e){let i=this.index,r=this.scanLiteralGroup()||this.next();if(!r)return null;if(this.context.registers[r.substring(1)]){let a=this.scanArgument("string");return null!==a&&(this.context.registers[r.substring(1)]=a),[new oG({type:"text",value:"",verbatimLatex:of([e,ob(this.tokens.slice(i,this.index))])})]}}let o=this.scanMacro(e);if(o)return[o];let n=eM(e,this.parseMode);if(!n)return"text"===this.parseMode?(/[a-zA-Z]/.test(null!=(i=this.peek())?i:"")&&(e+=" "),[...e].map(e=>new oG({type:"text",value:e,mode:"text",style:this.style}))):(this.onError({code:"unknown-command",arg:e}),[new n9(e)]);let l=this.index;if("symbol"===n.definitionType){let i=f({},this.style);n.variant&&(i.variant=n.variant),o=new oG({type:n.type,command:e,style:i,value:String.fromCodePoint(n.codepoint),mode:this.parseMode})}else{if(n.ifMode&&!n.ifMode.includes(this.parseMode))return[];let i=this.parseMode;n.applyMode&&(this.parseMode=n.applyMode);let l,s=[];if(n.parse?s=n.parse(this):[l,s]=this.scanArguments(n),this.parseMode=i,n.applyMode&&!n.applyStyle&&!n.createAtom)return et(s[0]);if(n.infix)return this.onError({code:"too-many-infix-commands",arg:e}),null;if("function"==typeof n.createAtom)o=n.createAtom({command:e,args:s,style:this.style,mode:this.parseMode}),l&&(o.body=et(this.scanArgument(l)));else if("function"==typeof n.applyStyle){let i=n.applyStyle(this.style,e,s,this.context),r=this.parseMode;if(n.applyMode&&(this.parseMode=n.applyMode),l){let e=this.style;this.style=i;let a=this.scanArgument(l);return this.style=e,this.parseMode=r,et(a)}this.style=i}else o=new oG({type:"mord",command:null!=(r=n.command)?r:e,style:f({},this.style),value:e,mode:null!=(a=n.applyMode)?a:this.parseMode})}if(!o)return null;if(o instanceof oG&&void 0===o.verbatimLatex&&!/^\\(llap|rlap|class|cssId|htmlData)$/.test(e)){let i=of([e,ob(this.tokens.slice(l,this.index))]);i&&(o.verbatimLatex=i)}if(null===o.verbatimLatex&&(o.verbatimLatex=void 0),o.isFunction&&this.smartFence){let e=this.scanSmartFence();if(e)return[o,e]}return[o]}scanSymbolCommandOrLiteral(){this.expandUnicode();let e=this.get();if(!e)return null;if(ln(e)){let i=ov.createAtom(this.parseMode,e,f({},this.style));if(!i)return null;if(i.isFunction&&this.smartFence){let e=this.scanSmartFence();if(e)return[i,e]}return[i]}return e.startsWith("\\")?this.scanSymbolOrCommand(e):"<space>"===e?"text"===this.parseMode?[new oY(" "," ",this.style)]:null:("<}>"===e?this.onError({latex:"",code:"unbalanced-braces"}):this.onError({latex:"",code:"unexpected-token",arg:e}),null)}defineLocalMacro(e,i){let r=e.startsWith("\\")?e.slice(1):e;r&&(this.localMacros[r]=i)}scanMacro(e){var i;let r=e.startsWith("\\")?this.localMacros[e.slice(1)]:void 0,a=null!=r?r:this.context.getMacro(e);if(!a)return null;let o=this.index,n=a.args,l={"?":null==(i=this.args)?void 0:i.call(this,"?")};for(let e=1;e<=n;e++){let i=this.scanLiteralGroup();if(!i){let e=this.index;this.scanExpression(),i=ob(this.tokens.slice(e,this.index))}l[e]=i}return new li(e,{expand:a.expand,captureSelection:a.captureSelection,args:o===this.index?null:ob(this.tokens.slice(o,this.index)),style:this.parsingContext.style,body:ls(a.def,{context:this.context,parseMode:this.parseMode,args:e=>l[e],mathstyle:this.parsingContext.mathstyle,style:this.parsingContext.style})})}parseExpression(){var e,i,r,a;let o=null!=(a=null!=(r=null!=(i=null!=(e=this.scanEnvironment())?e:this.scanModeShift())?i:this.scanModeSet())?r:this.scanGroup())?a:this.scanLeftRight();if(null===o){if(this.parseSupSub()||this.parseLimits())return!0;o=this.scanSymbolCommandOrLiteral()}return!!o&&(R(o)?this.mathlist.push(...o):this.mathlist.push(o),!0)}};function ls(e,i){var r,a,o,n;let l=null!=(r=null==i?void 0:i.args)?r:void 0,s=new ll(om(e,l),null==i?void 0:i.context,{args:l,mathstyle:null!=(a=null==i?void 0:i.mathstyle)?a:"displaystyle",parseMode:null!=(o=null==i?void 0:i.parseMode)?o:"math",style:null!=(n=null==i?void 0:i.style)?n:{}}),c=[];for(;!s.end();)c.push(...s.scan(()=>!1));return c}function lc(e,i){var r;let a=new ll(om(e,null),null==i?void 0:i.context,{mathstyle:"displaystyle",parseMode:null!=(r=null==i?void 0:i.parseMode)?r:"math"});for(;!a.end();)a.scan();return a.errors}var ld=class e extends oG{constructor(e,i){super({type:"chem"},{command:e,mode:"math"});let r=lh.go(lu.go(i,"\\pu"===e?"pu":"ce"),!1);this.body=ls(r),this._verbatimLatex=e+"{"+i+"}",this.arg=i,this.captureSelection=!0}static fromJson(i){return new e(i.command,i.arg)}set verbatimLatex(e){}get verbatimLatex(){return this._verbatimLatex}toJson(){return g(f({},super.toJson()),{arg:this.arg})}render(e){let i=oG.createBox(e,this.body,{type:"inner"});return this.caret&&(i.caret=this.caret),this.bind(e,i)}_serialize(e){return this.verbatimLatex,this.verbatimLatex}};ex(["ce","pu"],"{chemformula:balanced-string}",{createAtom:e=>{var i;return new ld(e.command,null!=(i=e.args[0])?i:"")}});var lu={go:function(e,i){if(!e)return[];void 0===i&&(i="ce");var r="0",a={};a.parenthesisLevel=0,e=(e=(e=e.replace(/\n/g," ")).replace(/[\u2212\u2013\u2014\u2010]/g,"-")).replace(/[\u2026]/g,"...");for(var o,n=10,l=[];;){o!==e?(n=10,o=e):n--;for(var s=lu.stateMachines[i],c=s.transitions[r]||s.transitions["*"],d=0;d<c.length;d++){var u=lu.patterns.match_(c[d].pattern,e);if(u){for(var h,p=c[d].task,m=0;m<p.action_.length;m++){if(s.actions[p.action_[m].type_])h=s.actions[p.action_[m].type_](a,u.match_,p.action_[m].option);else if(lu.actions[p.action_[m].type_])h=lu.actions[p.action_[m].type_](a,u.match_,p.action_[m].option);else throw["MhchemBugA","mhchem bug A. Please report. ("+p.action_[m].type_+")"];lu.concatArray(l,h)}if(r=p.nextState||r,!(e.length>0))return l;if(p.revisit||(e=u.remainder),!p.toContinue)break}}if(n<=0)throw["MhchemBugU","mhchem bug U. Please report."]}},concatArray:function(e,i){if(i)if("[object Array]"===Object.prototype.toString.call(i))for(var r=0;r<i.length;r++)e.push(i[r]);else e.push(i)},patterns:{patterns:{empty:/^$/,else:/^./,else2:/^./,space:/^\s/,"space A":/^\s(?=[A-Z\\$])/,space$:/^\s$/,"a-z":/^[a-z]/,x:/^x/,x$:/^x$/,i$:/^i$/,letters:/^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/,"\\greek":/^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/,"one lowercase latin letter $":/^(?:([a-z])(?:$|[^a-zA-Z]))$/,"$one lowercase latin letter$ $":/^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/,"one lowercase greek letter $":/^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/,digits:/^[0-9]+/,"-9.,9":/^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/,"-9.,9 no missing 0":/^[+\-]?[0-9]+(?:[.,][0-9]+)?/,"(-)(9.,9)(e)(99)":function(e){var i=e.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:(?:([eE])|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/);return i&&i[0]?{match_:i.slice(1),remainder:e.substr(i[0].length)}:null},"(-)(9)^(-9)":function(e){var i=e.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/);return i&&i[0]?{match_:i.slice(1),remainder:e.substr(i[0].length)}:null},"state of aggregation $":function(e){var i=lu.patterns.findObserveGroups(e,"",/^\([a-z]{1,3}(?=[\),])/,")","");if(i&&i.remainder.match(/^($|[\s,;\)\]\}])/))return i;var r=e.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/);return r?{match_:r[0],remainder:e.substr(r[0].length)}:null},"_{(state of aggregation)}$":/^_\{(\([a-z]{1,3}\))\}/,"{[(":/^(?:\\\{|\[|\()/,")]}":/^(?:\)|\]|\\\})/,", ":/^[,;]\s*/,",":/^[,;]/,".":/^[.]/,". ":/^([.\u22C5\u00B7\u2022])\s*/,"...":/^\.\.\.(?=$|[^.])/,"* ":/^([*])\s*/,"^{(...)}":function(e){return lu.patterns.findObserveGroups(e,"^{","","","}")},"^($...$)":function(e){return lu.patterns.findObserveGroups(e,"^","$","$","")},"^a":/^\^([0-9]+|[^\\_])/,"^\\x{}{}":function(e){return lu.patterns.findObserveGroups(e,"^",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"^\\x{}":function(e){return lu.patterns.findObserveGroups(e,"^",/^\\[a-zA-Z]+\{/,"}","")},"^\\x":/^\^(\\[a-zA-Z]+)\s*/,"^(-1)":/^\^(-?\d+)/,"'":/^'/,"_{(...)}":function(e){return lu.patterns.findObserveGroups(e,"_{","","","}")},"_($...$)":function(e){return lu.patterns.findObserveGroups(e,"_","$","$","")},_9:/^_([+\-]?[0-9]+|[^\\])/,"_\\x{}{}":function(e){return lu.patterns.findObserveGroups(e,"_",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"_\\x{}":function(e){return lu.patterns.findObserveGroups(e,"_",/^\\[a-zA-Z]+\{/,"}","")},"_\\x":/^_(\\[a-zA-Z]+)\s*/,"^_":/^(?:\^(?=_)|\_(?=\^)|[\^_]$)/,"{}":/^\{\}/,"{...}":function(e){return lu.patterns.findObserveGroups(e,"","{","}","")},"{(...)}":function(e){return lu.patterns.findObserveGroups(e,"{","","","}")},"$...$":function(e){return lu.patterns.findObserveGroups(e,"","$","$","")},"${(...)}$":function(e){return lu.patterns.findObserveGroups(e,"${","","","}$")},"$(...)$":function(e){return lu.patterns.findObserveGroups(e,"$","","","$")},"=<>":/^[=<>]/,"#":/^[#\u2261]/,"+":/^\+/,"-$":/^-(?=[\s_},;\]/]|$|\([a-z]+\))/,"-9":/^-(?=[0-9])/,"- orbital overlap":/^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/,"-":/^-/,"pm-operator":/^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,operator:/^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,arrowUpDown:/^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,"\\bond{(...)}":function(e){return lu.patterns.findObserveGroups(e,"\\bond{","","","}")},"->":/^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,CMT:/^[CMT](?=\[)/,"[(...)]":function(e){return lu.patterns.findObserveGroups(e,"[","","","]")},"1st-level escape":/^(&|\\\\|\\hline)\s*/,"\\,":/^(?:\\[,\ ;:])/,"\\x{}{}":function(e){return lu.patterns.findObserveGroups(e,"",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"\\x{}":function(e){return lu.patterns.findObserveGroups(e,"",/^\\[a-zA-Z]+\{/,"}","")},"\\ca":/^\\ca(?:\s+|(?![a-zA-Z]))/,"\\x":/^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/,orbital:/^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,others:/^[\/~|]/,"\\frac{(...)}":function(e){return lu.patterns.findObserveGroups(e,"\\frac{","","","}","{","","","}")},"\\overset{(...)}":function(e){return lu.patterns.findObserveGroups(e,"\\overset{","","","}","{","","","}")},"\\underset{(...)}":function(e){return lu.patterns.findObserveGroups(e,"\\underset{","","","}","{","","","}")},"\\underbrace{(...)}":function(e){return lu.patterns.findObserveGroups(e,"\\underbrace{","","","}_","{","","","}")},"\\color{(...)}0":function(e){return lu.patterns.findObserveGroups(e,"\\color{","","","}")},"\\color{(...)}{(...)}1":function(e){return lu.patterns.findObserveGroups(e,"\\color{","","","}","{","","","}")},"\\color(...){(...)}2":function(e){return lu.patterns.findObserveGroups(e,"\\color","\\","",/^(?=\{)/,"{","","","}")},"\\ce{(...)}":function(e){return lu.patterns.findObserveGroups(e,"\\ce{","","","}")},oxidation$:/^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"d-oxidation$":/^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"roman numeral":/^[IVX]+/,"1/2$":/^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,amount:function(e){if(i=e.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/))return{match_:i[0],remainder:e.substr(i[0].length)};var i,r=lu.patterns.findObserveGroups(e,"","$","$","");return r&&(i=r.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/))?{match_:i[0],remainder:e.substr(i[0].length)}:null},amount2:function(e){return this.amount(e)},"(KV letters),":/^(?:[A-Z][a-z]{0,2}|i)(?=,)/,formula$:function(e){if(e.match(/^\([a-z]+\)$/))return null;var i=e.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/);return i?{match_:i[0],remainder:e.substr(i[0].length)}:null},uprightEntities:/^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/,"/":/^\s*(\/)\s*/,"//":/^\s*(\/\/)\s*/,"*":/^\s*[*.]\s*/},findObserveGroups:function(e,i,r,a,o,n,l,s,c,d){var u=function(e,i){if("string"==typeof i)return 0!==e.indexOf(i)?null:i;var r=e.match(i);return r?r[0]:null},h=u(e,i);if(null===h||null===(h=u(e=e.substr(h.length),r)))return null;var p=function(e,i,r){for(var a=0;i<e.length;){var o=e.charAt(i),n=u(e.substr(i),r);if(null!==n&&0===a)return{endMatchBegin:i,endMatchEnd:i+n.length};if("{"===o)a++;else if("}"===o){if(0===a)throw["ExtraCloseMissingOpen","Extra close brace or missing open brace"];a--}i++}return null}(e,h.length,a||o);if(null===p)return null;var m=e.substring(0,a?p.endMatchEnd:p.endMatchBegin);if(!n&&!l)return{match_:m,remainder:e.substr(p.endMatchEnd)};var f=this.findObserveGroups(e.substr(p.endMatchEnd),n,l,s,c);if(null===f)return null;var g=[m,f.match_];return{match_:d?g.join(""):g,remainder:f.remainder}},match_:function(e,i){var r=lu.patterns.patterns[e];if(void 0===r)throw["MhchemBugP","mhchem bug P. Please report. ("+e+")"];if("function"==typeof r)return lu.patterns.patterns[e](i);var a=i.match(r);return a?{match_:a[2]?[a[1],a[2]]:a[1]?a[1]:a[0],remainder:i.substr(a[0].length)}:null}},actions:{"a=":function(e,i){e.a=(e.a||"")+i},"b=":function(e,i){e.b=(e.b||"")+i},"p=":function(e,i){e.p=(e.p||"")+i},"o=":function(e,i){e.o=(e.o||"")+i},"q=":function(e,i){e.q=(e.q||"")+i},"d=":function(e,i){e.d=(e.d||"")+i},"rm=":function(e,i){e.rm=(e.rm||"")+i},"text=":function(e,i){e.text_=(e.text_||"")+i},insert:function(e,i,r){return{type_:r}},"insert+p1":function(e,i,r){return{type_:r,p1:i}},"insert+p1+p2":function(e,i,r){return{type_:r,p1:i[0],p2:i[1]}},copy:function(e,i){return i},rm:function(e,i){return{type_:"rm",p1:i||""}},text:function(e,i){return lu.go(i,"text")},"{text}":function(e,i){var r=["{"];return lu.concatArray(r,lu.go(i,"text")),r.push("}"),r},"tex-math":function(e,i){return lu.go(i,"tex-math")},"tex-math tight":function(e,i){return lu.go(i,"tex-math tight")},bond:function(e,i,r){return{type_:"bond",kind_:r||i}},"color0-output":function(e,i){return{type_:"color0",color:i[0]}},ce:function(e,i){return lu.go(i)},"1/2":function(e,i){var r=[];i.match(/^[+\-]/)&&(r.push(i.substr(0,1)),i=i.substr(1));var a=i.match(/^([0-9]+|\$[a-z]\$|[a-z])\/([0-9]+)(\$[a-z]\$|[a-z])?$/);return a[1]=a[1].replace(/\$/g,""),r.push({type_:"frac",p1:a[1],p2:a[2]}),a[3]&&(a[3]=a[3].replace(/\$/g,""),r.push({type_:"tex-math",p1:a[3]})),r},"9,9":function(e,i){return lu.go(i,"9,9")}},createTransitions:function(e){var i,r,a,o,n={};for(i in e)for(r in e[i])for(a=r.split("|"),e[i][r].stateArray=a,o=0;o<a.length;o++)n[a[o]]=[];for(i in e)for(r in e[i])for(a=e[i][r].stateArray||[],o=0;o<a.length;o++){var l=e[i][r];if(l.action_){l.action_=[].concat(l.action_);for(var s=0;s<l.action_.length;s++)"string"==typeof l.action_[s]&&(l.action_[s]={type_:l.action_[s]})}else l.action_=[];for(var c=i.split("|"),d=0;d<c.length;d++)if("*"===a[o])for(var u in n)n[u].push({pattern:c[d],task:l});else n[a[o]].push({pattern:c[d],task:l})}return n},stateMachines:{}};lu.stateMachines={ce:{transitions:lu.createTransitions({empty:{"*":{action_:"output"}},else:{"0|1|2":{action_:"beginsWithBond=false",revisit:!0,toContinue:!0}},oxidation$:{0:{action_:"oxidation-output"}},CMT:{r:{action_:"rdt=",nextState:"rt"},rd:{action_:"rqt=",nextState:"rdt"}},arrowUpDown:{"0|1|2|as":{action_:["sb=false","output","operator"],nextState:"1"}},uprightEntities:{"0|1|2":{action_:["o=","output"],nextState:"1"}},orbital:{"0|1|2|3":{action_:"o=",nextState:"o"}},"->":{"0|1|2|3":{action_:"r=",nextState:"r"},"a|as":{action_:["output","r="],nextState:"r"},"*":{action_:["output","r="],nextState:"r"}},"+":{o:{action_:"d= kv",nextState:"d"},"d|D":{action_:"d=",nextState:"d"},q:{action_:"d=",nextState:"qd"},"qd|qD":{action_:"d=",nextState:"qd"},dq:{action_:["output","d="],nextState:"d"},3:{action_:["sb=false","output","operator"],nextState:"0"}},amount:{"0|2":{action_:"a=",nextState:"a"}},"pm-operator":{"0|1|2|a|as":{action_:["sb=false","output",{type_:"operator",option:"\\pm"}],nextState:"0"}},operator:{"0|1|2|a|as":{action_:["sb=false","output","operator"],nextState:"0"}},"-$":{"o|q":{action_:["charge or bond","output"],nextState:"qd"},d:{action_:"d=",nextState:"d"},D:{action_:["output",{type_:"bond",option:"-"}],nextState:"3"},q:{action_:"d=",nextState:"qd"},qd:{action_:"d=",nextState:"qd"},"qD|dq":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},"-9":{"3|o":{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"3"}},"- orbital overlap":{o:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},d:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"}},"-":{"0|1|2":{action_:[{type_:"output",option:1},"beginsWithBond=true",{type_:"bond",option:"-"}],nextState:"3"},3:{action_:{type_:"bond",option:"-"}},a:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},as:{action_:[{type_:"output",option:2},{type_:"bond",option:"-"}],nextState:"3"},b:{action_:"b="},o:{action_:{type_:"- after o/d",option:!1},nextState:"2"},q:{action_:{type_:"- after o/d",option:!1},nextState:"2"},"d|qd|dq":{action_:{type_:"- after o/d",option:!0},nextState:"2"},"D|qD|p":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},amount2:{"1|3":{action_:"a=",nextState:"a"}},letters:{"0|1|2|3|a|as|b|p|bp|o":{action_:"o=",nextState:"o"},"q|dq":{action_:["output","o="],nextState:"o"},"d|D|qd|qD":{action_:"o after d",nextState:"o"}},digits:{o:{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},q:{action_:["output","o="],nextState:"o"},a:{action_:"o=",nextState:"o"}},"space A":{"b|p|bp":{}},space:{a:{nextState:"as"},0:{action_:"sb=false"},"1|2":{action_:"sb=true"},"r|rt|rd|rdt|rdq":{action_:"output",nextState:"0"},"*":{action_:["output","sb=true"],nextState:"1"}},"1st-level escape":{"1|2":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}]},"*":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}],nextState:"0"}},"[(...)]":{"r|rt":{action_:"rd=",nextState:"rd"},"rd|rdt":{action_:"rq=",nextState:"rdq"}},"...":{"o|d|D|dq|qd|qD":{action_:["output",{type_:"bond",option:"..."}],nextState:"3"},"*":{action_:[{type_:"output",option:1},{type_:"insert",option:"ellipsis"}],nextState:"1"}},". |* ":{"*":{action_:["output",{type_:"insert",option:"addition compound"}],nextState:"1"}},"state of aggregation $":{"*":{action_:["output","state of aggregation"],nextState:"1"}},"{[(":{"a|as|o":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"0|1|2|3":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"*":{action_:["output","o=","output","parenthesisLevel++"],nextState:"2"}},")]}":{"0|1|2|3|b|p|bp|o":{action_:["o=","parenthesisLevel--"],nextState:"o"},"a|as|d|D|q|qd|qD|dq":{action_:["output","o=","parenthesisLevel--"],nextState:"o"}},", ":{"*":{action_:["output","comma"],nextState:"0"}},"^_":{"*":{}},"^{(...)}|^($...$)":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"D"},q:{action_:"d=",nextState:"qD"},"d|D|qd|qD|dq":{action_:["output","d="],nextState:"D"}},"^a|^\\x{}{}|^\\x{}|^\\x|'":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"d"},q:{action_:"d=",nextState:"qd"},"d|qd|D|qD":{action_:"d="},dq:{action_:["output","d="],nextState:"d"}},"_{(state of aggregation)}$":{"d|D|q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x":{"0|1|2|as":{action_:"p=",nextState:"p"},b:{action_:"p=",nextState:"bp"},"3|o":{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},"q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"=<>":{"0|1|2|3|a|as|o|q|d|D|qd|qD|dq":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"#":{"0|1|2|3|a|as|o":{action_:[{type_:"output",option:2},{type_:"bond",option:"#"}],nextState:"3"}},"{}":{"*":{action_:{type_:"output",option:1},nextState:"1"}},"{...}":{"0|1|2|3|a|as|b|p|bp":{action_:"o=",nextState:"o"},"o|d|D|q|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"$...$":{a:{action_:"a="},"0|1|2|3|as|b|p|bp|o":{action_:"o=",nextState:"o"},"as|o":{action_:"o="},"q|d|D|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"\\bond{(...)}":{"*":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"\\frac{(...)}":{"*":{action_:[{type_:"output",option:1},"frac-output"],nextState:"3"}},"\\overset{(...)}":{"*":{action_:[{type_:"output",option:2},"overset-output"],nextState:"3"}},"\\underset{(...)}":{"*":{action_:[{type_:"output",option:2},"underset-output"],nextState:"3"}},"\\underbrace{(...)}":{"*":{action_:[{type_:"output",option:2},"underbrace-output"],nextState:"3"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:[{type_:"output",option:2},"color-output"],nextState:"3"}},"\\color{(...)}0":{"*":{action_:[{type_:"output",option:2},"color0-output"]}},"\\ce{(...)}":{"*":{action_:[{type_:"output",option:2},"ce"],nextState:"3"}},"\\,":{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"1"}},"\\x{}{}|\\x{}|\\x":{"0|1|2|3|a|as|b|p|bp|o|c0":{action_:["o=","output"],nextState:"3"},"*":{action_:["output","o=","output"],nextState:"3"}},others:{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"3"}},else2:{a:{action_:"a to o",nextState:"o",revisit:!0},as:{action_:["output","sb=true"],nextState:"1",revisit:!0},"r|rt|rd|rdt|rdq":{action_:["output"],nextState:"0",revisit:!0},"*":{action_:["output","copy"],nextState:"3"}}}),actions:{"o after d":function(e,i){var r;if((e.d||"").match(/^[0-9]+$/)){var a=e.d;e.d=void 0,r=this.output(e),e.b=a}else r=this.output(e);return lu.actions["o="](e,i),r},"d= kv":function(e,i){e.d=i,e.dType="kv"},"charge or bond":function(e,i){if(e.beginsWithBond){var r=[];return lu.concatArray(r,this.output(e)),lu.concatArray(r,lu.actions.bond(e,i,"-")),r}e.d=i},"- after o/d":function(e,i,r){var a=lu.patterns.match_("orbital",e.o||""),o=lu.patterns.match_("one lowercase greek letter $",e.o||""),n=lu.patterns.match_("one lowercase latin letter $",e.o||""),l=lu.patterns.match_("$one lowercase latin letter$ $",e.o||""),s="-"===i&&(a&&""===a.remainder||o||n||l);!s||e.a||e.b||e.p||e.d||e.q||a||!n||(e.o="$"+e.o+"$");var c=[];return s?(lu.concatArray(c,this.output(e)),c.push({type_:"hyphen"})):(a=lu.patterns.match_("digits",e.d||""),r&&a&&""===a.remainder?(lu.concatArray(c,lu.actions["d="](e,i)),lu.concatArray(c,this.output(e))):(lu.concatArray(c,this.output(e)),lu.concatArray(c,lu.actions.bond(e,i,"-")))),c},"a to o":function(e){e.o=e.a,e.a=void 0},"sb=true":function(e){e.sb=!0},"sb=false":function(e){e.sb=!1},"beginsWithBond=true":function(e){e.beginsWithBond=!0},"beginsWithBond=false":function(e){e.beginsWithBond=!1},"parenthesisLevel++":function(e){e.parenthesisLevel++},"parenthesisLevel--":function(e){e.parenthesisLevel--},"state of aggregation":function(e,i){return{type_:"state of aggregation",p1:lu.go(i,"o")}},comma:function(e,i){var r=i.replace(/\s*$/,"");return r!==i&&0===e.parenthesisLevel?{type_:"comma enumeration L",p1:r}:{type_:"comma enumeration M",p1:r}},output:function(e,i,r){var a,o,n;for(var l in e.r?(o="M"===e.rdt?lu.go(e.rd,"tex-math"):"T"===e.rdt?[{type_:"text",p1:e.rd||""}]:lu.go(e.rd),n="M"===e.rqt?lu.go(e.rq,"tex-math"):"T"===e.rqt?[{type_:"text",p1:e.rq||""}]:lu.go(e.rq),a={type_:"arrow",r:e.r,rd:o,rq:n}):(a=[],(e.a||e.b||e.p||e.o||e.q||e.d||r)&&(e.sb&&a.push({type_:"entitySkip"}),e.o||e.q||e.d||e.b||e.p||2===r?e.o||e.q||e.d||!e.b&&!e.p?e.o&&"kv"===e.dType&&lu.patterns.match_("d-oxidation$",e.d||"")?e.dType="oxidation":e.o&&"kv"===e.dType&&!e.q&&(e.dType=void 0):(e.o=e.a,e.d=e.b,e.q=e.p,e.a=e.b=e.p=void 0):(e.o=e.a,e.a=void 0),a.push({type_:"chemfive",a:lu.go(e.a,"a"),b:lu.go(e.b,"bd"),p:lu.go(e.p,"pq"),o:lu.go(e.o,"o"),q:lu.go(e.q,"pq"),d:lu.go(e.d,"oxidation"===e.dType?"oxidation":"bd"),dType:e.dType}))),e)"parenthesisLevel"!==l&&"beginsWithBond"!==l&&delete e[l];return a},"oxidation-output":function(e,i){var r=["{"];return lu.concatArray(r,lu.go(i,"oxidation")),r.push("}"),r},"frac-output":function(e,i){return{type_:"frac-ce",p1:lu.go(i[0]),p2:lu.go(i[1])}},"overset-output":function(e,i){return{type_:"overset",p1:lu.go(i[0]),p2:lu.go(i[1])}},"underset-output":function(e,i){return{type_:"underset",p1:lu.go(i[0]),p2:lu.go(i[1])}},"underbrace-output":function(e,i){return{type_:"underbrace",p1:lu.go(i[0]),p2:lu.go(i[1])}},"color-output":function(e,i){return{type_:"color",color1:i[0],color2:lu.go(i[1])}},"r=":function(e,i){e.r=i},"rdt=":function(e,i){e.rdt=i},"rd=":function(e,i){e.rd=i},"rqt=":function(e,i){e.rqt=i},"rq=":function(e,i){e.rq=i},operator:function(e,i,r){return{type_:"operator",kind_:r||i}}}},a:{transitions:lu.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},"$(...)$":{"*":{action_:"tex-math tight",nextState:"1"}},",":{"*":{action_:{type_:"insert",option:"commaDecimal"}}},else2:{"*":{action_:"copy"}}}),actions:{}},o:{transitions:lu.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},letters:{"*":{action_:"rm"}},"\\ca":{"*":{action_:{type_:"insert",option:"circa"}}},"\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"{text}"}},else2:{"*":{action_:"copy"}}}),actions:{}},text:{transitions:lu.createTransitions({empty:{"*":{action_:"output"}},"{...}":{"*":{action_:"text="}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"\\greek":{"*":{action_:["output","rm"]}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:["output","copy"]}},else:{"*":{action_:"text="}}}),actions:{output:function(e){if(e.text_){var i={type_:"text",p1:e.text_};for(var r in e)delete e[r];return i}}}},pq:{transitions:lu.createTransitions({empty:{"*":{}},"state of aggregation $":{"*":{action_:"state of aggregation"}},i$:{0:{nextState:"!f",revisit:!0}},"(KV letters),":{0:{action_:"rm",nextState:"0"}},formula$:{0:{nextState:"f",revisit:!0}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"!f",revisit:!0}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"a-z":{f:{action_:"tex-math"}},letters:{"*":{action_:"rm"}},"-9.,9":{"*":{action_:"9,9"}},",":{"*":{action_:{type_:"insert+p1",option:"comma enumeration S"}}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"state of aggregation":function(e,i){return{type_:"state of aggregation subscript",p1:lu.go(i,"o")}},"color-output":function(e,i){return{type_:"color",color1:i[0],color2:lu.go(i[1],"pq")}}}},bd:{transitions:lu.createTransitions({empty:{"*":{}},x$:{0:{nextState:"!f",revisit:!0}},formula$:{0:{nextState:"f",revisit:!0}},else:{0:{nextState:"!f",revisit:!0}},"-9.,9 no missing 0":{"*":{action_:"9,9"}},".":{"*":{action_:{type_:"insert",option:"electron dot"}}},"a-z":{f:{action_:"tex-math"}},x:{"*":{action_:{type_:"insert",option:"KV x"}}},letters:{"*":{action_:"rm"}},"'":{"*":{action_:{type_:"insert",option:"prime"}}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"color-output":function(e,i){return{type_:"color",color1:i[0],color2:lu.go(i[1],"bd")}}}},oxidation:{transitions:lu.createTransitions({empty:{"*":{}},"roman numeral":{"*":{action_:"roman-numeral"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},else:{"*":{action_:"copy"}}}),actions:{"roman-numeral":function(e,i){return{type_:"roman numeral",p1:i||""}}}},"tex-math":{transitions:lu.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},else:{"*":{action_:"o="}}}),actions:{output:function(e){if(e.o){var i={type_:"tex-math",p1:e.o};for(var r in e)delete e[r];return i}}}},"tex-math tight":{transitions:lu.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},"-|+":{"*":{action_:"tight operator"}},else:{"*":{action_:"o="}}}),actions:{"tight operator":function(e,i){e.o=(e.o||"")+"{"+i+"}"},output:function(e){if(e.o){var i={type_:"tex-math",p1:e.o};for(var r in e)delete e[r];return i}}}},"9,9":{transitions:lu.createTransitions({empty:{"*":{}},",":{"*":{action_:"comma"}},else:{"*":{action_:"copy"}}}),actions:{comma:function(){return{type_:"commaDecimal"}}}},pu:{transitions:lu.createTransitions({empty:{"*":{action_:"output"}},space$:{"*":{action_:["output","space"]}},"{[(|)]}":{"0|a":{action_:"copy"}},"(-)(9)^(-9)":{0:{action_:"number^",nextState:"a"}},"(-)(9.,9)(e)(99)":{0:{action_:"enumber",nextState:"a"}},space:{"0|a":{}},"pm-operator":{"0|a":{action_:{type_:"operator",option:"\\pm"},nextState:"0"}},operator:{"0|a":{action_:"copy",nextState:"0"}},"//":{d:{action_:"o=",nextState:"/"}},"/":{d:{action_:"o=",nextState:"/"}},"{...}|else":{"0|d":{action_:"d=",nextState:"d"},a:{action_:["space","d="],nextState:"d"},"/|q":{action_:"q=",nextState:"q"}}}),actions:{enumber:function(e,i){var r=[];return"+-"===i[0]||"+/-"===i[0]?r.push("\\pm "):i[0]&&r.push(i[0]),i[1]&&(lu.concatArray(r,lu.go(i[1],"pu-9,9")),i[2]&&(i[2].match(/[,.]/)?lu.concatArray(r,lu.go(i[2],"pu-9,9")):r.push(i[2])),(i[3]||i[4])&&("e"===i[3]||"*"===i[4]?r.push({type_:"cdot"}):r.push({type_:"times"}))),i[5]&&r.push("10^{"+i[5]+"}"),r},"number^":function(e,i){var r=[];return"+-"===i[0]||"+/-"===i[0]?r.push("\\pm "):i[0]&&r.push(i[0]),lu.concatArray(r,lu.go(i[1],"pu-9,9")),r.push("^{"+i[2]+"}"),r},operator:function(e,i,r){return{type_:"operator",kind_:r||i}},space:function(){return{type_:"pu-space-1"}},output:function(e){var i,r=lu.patterns.match_("{(...)}",e.d||"");r&&""===r.remainder&&(e.d=r.match_);var a=lu.patterns.match_("{(...)}",e.q||"");if(a&&""===a.remainder&&(e.q=a.match_),e.d&&(e.d=e.d.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),e.d=e.d.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F")),e.q){e.q=e.q.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),e.q=e.q.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F");var o={d:lu.go(e.d,"pu"),q:lu.go(e.q,"pu")};"//"===e.o?i={type_:"pu-frac",p1:o.d,p2:o.q}:(i=o.d,o.d.length>1||o.q.length>1?i.push({type_:" / "}):i.push({type_:"/"}),lu.concatArray(i,o.q))}else i=lu.go(e.d,"pu-2");for(var n in e)delete e[n];return i}}},"pu-2":{transitions:lu.createTransitions({empty:{"*":{action_:"output"}},"*":{"*":{action_:["output","cdot"],nextState:"0"}},"\\x":{"*":{action_:"rm="}},space:{"*":{action_:["output","space"],nextState:"0"}},"^{(...)}|^(-1)":{1:{action_:"^(-1)"}},"-9.,9":{0:{action_:"rm=",nextState:"0"},1:{action_:"^(-1)",nextState:"0"}},"{...}|else":{"*":{action_:"rm=",nextState:"1"}}}),actions:{cdot:function(){return{type_:"tight cdot"}},"^(-1)":function(e,i){e.rm+="^{"+i+"}"},space:function(){return{type_:"pu-space-2"}},output:function(e){var i=[];if(e.rm){var r=lu.patterns.match_("{(...)}",e.rm||"");i=r&&""===r.remainder?lu.go(r.match_,"pu"):{type_:"rm",p1:e.rm}}for(var a in e)delete e[a];return i}}},"pu-9,9":{transitions:lu.createTransitions({empty:{0:{action_:"output-0"},o:{action_:"output-o"}},",":{0:{action_:["output-0","comma"],nextState:"o"}},".":{0:{action_:["output-0","copy"],nextState:"o"}},else:{"*":{action_:"text="}}}),actions:{comma:function(){return{type_:"commaDecimal"}},"output-0":function(e){var i=[];if(e.text_=e.text_||"",e.text_.length>4){var r=e.text_.length%3;0===r&&(r=3);for(var a=e.text_.length-3;a>0;a-=3)i.push(e.text_.substr(a,3)),i.push({type_:"1000 separator"});i.push(e.text_.substr(0,r)),i.reverse()}else i.push(e.text_);for(var o in e)delete e[o];return i},"output-o":function(e){var i=[];if(e.text_=e.text_||"",e.text_.length>4){for(var r=e.text_.length-3,a=0;a<r;a+=3)i.push(e.text_.substr(a,3)),i.push({type_:"1000 separator"});i.push(e.text_.substr(a))}else i.push(e.text_);for(var o in e)delete e[o];return i}}}};var lh={go:function(e,i){if(!e)return"";for(var r="",a=!1,o=0;o<e.length;o++){var n=e[o];"string"==typeof n?r+=n:(r+=lh._go2(n),"1st-level escape"===n.type_&&(a=!0))}return i||a||!r||(r="{"+r+"}"),r},_goInner:function(e){return e&&lh.go(e,!0)},_go2:function(e){var i;switch(e.type_){case"chemfive":i="";var r={a:lh._goInner(e.a),b:lh._goInner(e.b),p:lh._goInner(e.p),o:lh._goInner(e.o),q:lh._goInner(e.q),d:lh._goInner(e.d)};r.a&&(r.a.match(/^[+\-]/)&&(r.a="{"+r.a+"}"),i+=r.a+"\\,"),(r.b||r.p)&&(i+="{\\vphantom{X}}",i+="^{\\hphantom{"+(r.b||"")+"}}_{\\hphantom{"+(r.p||"")+"}}",i+="{\\vphantom{X}}",i+="^{\\smash[t]{\\vphantom{2}}\\llap{"+(r.b||"")+"}}",i+="_{\\vphantom{2}\\llap{\\smash[t]{"+(r.p||"")+"}}}"),r.o&&(r.o.match(/^[+\-]/)&&(r.o="{"+r.o+"}"),i+=r.o),"kv"===e.dType?((r.d||r.q)&&(i+="{\\vphantom{X}}"),r.d&&(i+="^{"+r.d+"}"),r.q&&(i+="_{\\smash[t]{"+r.q+"}}")):"oxidation"===e.dType?(r.d&&(i+="{\\vphantom{X}}",i+="^{"+r.d+"}"),r.q&&(i+="{\\vphantom{X}}",i+="_{\\smash[t]{"+r.q+"}}")):(r.q&&(i+="{\\vphantom{X}}",i+="_{\\smash[t]{"+r.q+"}}"),r.d&&(i+="{\\vphantom{X}}",i+="^{"+r.d+"}"));break;case"rm":case"roman numeral":i="\\mathrm{"+e.p1+"}";break;case"text":e.p1.match(/[\^_]/)?(e.p1=e.p1.replace(" ","~").replace("-","\\text{-}"),i="\\mathrm{"+e.p1+"}"):i="\\text{"+e.p1+"}";break;case"state of aggregation":i="\\mskip2mu "+lh._goInner(e.p1);break;case"state of aggregation subscript":i="\\mskip1mu "+lh._goInner(e.p1);break;case"bond":if(!(i=lh._getBond(e.kind_)))throw["MhchemErrorBond","mhchem Error. Unknown bond type ("+e.kind_+")"];break;case"frac":var a="\\frac{"+e.p1+"}{"+e.p2+"}";i="\\mathchoice{\\textstyle"+a+"}{"+a+"}{"+a+"}{"+a+"}";break;case"pu-frac":var o="\\frac{"+lh._goInner(e.p1)+"}{"+lh._goInner(e.p2)+"}";i="\\mathchoice{\\textstyle"+o+"}{"+o+"}{"+o+"}{"+o+"}";break;case"tex-math":case"1st-level escape":i=e.p1+" ";break;case"frac-ce":i="\\frac{"+lh._goInner(e.p1)+"}{"+lh._goInner(e.p2)+"}";break;case"overset":i="\\overset{"+lh._goInner(e.p1)+"}{"+lh._goInner(e.p2)+"}";break;case"underset":i="\\underset{"+lh._goInner(e.p1)+"}{"+lh._goInner(e.p2)+"}";break;case"underbrace":i="\\underbrace{"+lh._goInner(e.p1)+"}_{"+lh._goInner(e.p2)+"}";break;case"color":i="{\\color{"+e.color1+"}{"+lh._goInner(e.color2)+"}}";break;case"color0":i="\\color{"+e.color+"}";break;case"arrow":var n={rd:lh._goInner(e.rd),rq:lh._goInner(e.rq)},l=lh._getArrow(e.r);n.rd||n.rq?"<=>"===e.r||"<=>>"===e.r||"<<=>"===e.r||"<--\x3e"===e.r?(l="\\long"+l,n.rd&&(l="\\overset{"+n.rd+"}{"+l+"}"),n.rq&&(l="<--\x3e"===e.r?"\\underset{\\lower2mu{"+n.rq+"}}{"+l+"}":"\\underset{\\lower6mu{"+n.rq+"}}{"+l+"}"),l=" {}\\mathrel{"+l+"}{} "):(n.rq&&(l+="[{"+n.rq+"}]"),l+="{"+n.rd+"}",l=" {}\\mathrel{\\x"+l+"}{} "):l=" {}\\mathrel{\\long"+l+"}{} ",i=l;break;case"operator":i=lh._getOperator(e.kind_);break;case"space":i=" ";break;case"entitySkip":case"pu-space-1":i="~";break;case"pu-space-2":i="\\mkern3mu ";break;case"1000 separator":i="\\mkern2mu ";break;case"commaDecimal":i="{,}";break;case"comma enumeration L":i="{"+e.p1+"}\\mkern6mu ";break;case"comma enumeration M":i="{"+e.p1+"}\\mkern3mu ";break;case"comma enumeration S":i="{"+e.p1+"}\\mkern1mu ";break;case"hyphen":i="\\text{-}";break;case"addition compound":i="\\,{\\cdot}\\,";break;case"electron dot":i="\\mkern1mu \\bullet\\mkern1mu ";break;case"KV x":i="{\\times}";break;case"prime":i="\\prime ";break;case"cdot":i="\\cdot ";break;case"tight cdot":i="\\mkern1mu{\\cdot}\\mkern1mu ";break;case"times":i="\\times ";break;case"circa":i="{\\sim}";break;case"^":i="uparrow";break;case"v":i="downarrow";break;case"ellipsis":i="\\ldots ";break;case"/":i="/";break;case" / ":i="\\,/\\,";break;default:throw["MhchemBugT","mhchem bug T. Please report."]}return i},_getArrow:function(e){switch(e){case"->":case"→":case"⟶":return"rightarrow";case"<-":return"leftarrow";case"<->":return"leftrightarrow";case"<--\x3e":return"leftrightarrows";case"<=>":case"⇌":return"rightleftharpoons";case"<=>>":return"Rightleftharpoons";case"<<=>":return"Leftrightharpoons";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getBond:function(e){switch(e){case"-":case"1":return"{-}";case"=":case"2":return"{=}";case"#":case"3":return"{\\equiv}";case"~":return"{\\tripledash}";case"~-":return"{\\rlap{\\lower.1em{-}}\\raise.1em{\\tripledash}}";case"~=":case"~--":return"{\\rlap{\\lower.2em{-}}\\rlap{\\raise.2em{\\tripledash}}-}";case"-~-":return"{\\rlap{\\lower.2em{-}}\\rlap{\\raise.2em{-}}\\tripledash}";case"...":return"{{\\cdot}{\\cdot}{\\cdot}}";case"....":return"{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}";case"->":return"{\\rightarrow}";case"<-":return"{\\leftarrow}";case"<":return"{<}";case">":return"{>}";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getOperator:function(e){switch(e){case"+":return" {}+{} ";case"-":return" {}-{} ";case"=":return" {}={} ";case"<":return" {}<{} ";case">":return" {}>{} ";case"<<":return" {}\\ll{} ";case">>":return" {}\\gg{} ";case"\\pm":return" {}\\pm{} ";case"\\approx":case"$\\approx$":return" {}\\approx{} ";case"v":case"(v)":return" \\downarrow{} ";case"^":case"(^)":return" \\uparrow{} ";default:throw["MhchemBugT","mhchem bug T. Please report."]}}},lp=class e extends oG{constructor(e){super(g(f({},e),{type:"delim"})),this.value=e.delim,this.size=e.size}static fromJson(i){return new e(i)}toJson(){return g(f({},super.toJson()),{delim:this.value,size:this.size})}render(e){return new oE(this.value,{type:"middle"})}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let i=eM(this.command,this.mode);return null!=i&&i.serialize?i.serialize(this,e):og(this.command,this.value)}},lm=class e extends oG{constructor(e){super(g(f({},e),{type:"sizeddelim",value:e.delim})),this.delimType=e.delimType,this.size=e.size}static fromJson(i){return new e(i)}toJson(){return g(f({},super.toJson()),{delim:this.value,size:this.size,delimType:this.delimType})}render(e){var i,r,a;let o=(i=this.value,r=this.size,a={classes:({open:"ML__open",close:"ML__close"})[this.delimType],type:this.delimType,isSelected:this.isSelected},void 0===i||"."===i?nU(e,a.classes):("<"===i||"\\lt"===i||"⟨"===i?i="\\langle":(">"===i||"\\gt"===i||"⟩"===i)&&(i="\\rangle"),nR.has(i)||nN.has(i)?nP(i,r,!1,e,a):nI.has(i)?nO(i,nq[r],!1,e,a):null));return o?(o=this.bind(e,o),this.caret&&(o.caret=this.caret),o):null}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let i=eM(this.command,this.mode);return null!=i&&i.serialize?i.serialize(this,e):og(this.command,this.value)}};function lf(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}var lg=class e extends oG{constructor(e,i,r,a){var o,n;super({type:"enclose",command:e,style:a.style}),this.body=i,this.backgroundcolor=a.backgroundcolor,r.updiagonalarrow&&(r.updiagonalstrike=!1),r.box&&(r.left=!1,r.right=!1,r.bottom=!1,r.top=!1),this.notation=r,this.shadow=null!=(o=a.shadow)?o:"none",this.strokeWidth=null!=(n=a.strokeWidth)?n:"0.06em",this.strokeWidth||(this.strokeWidth="0.06em"),this.strokeStyle=a.strokeStyle,this.svgStrokeStyle=a.svgStrokeStyle,this.strokeColor=a.strokeColor,this.borderStyle=a.borderStyle,this.padding=a.padding,this.captureSelection=!1}static fromJson(i){return new e(i.command,i.body,i.notation,i)}toJson(){return g(f({},super.toJson()),{notation:this.notation,shadow:this.shadow,strokeWidth:this.strokeWidth,strokeStyle:this.strokeStyle,svgStrokeStyle:this.svgStrokeStyle,strokeColor:this.strokeColor,borderStyle:this.borderStyle,padding:this.padding})}_serialize(e){var i;if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let r=eM(this.command,this.mode);if(null!=r&&r.serialize)return r.serialize(this,e);let a=null!=(i=this.command)?i:"";if("\\enclose"===this.command){a+="{"+Object.keys(this.notation).join(" ")+"}";let e="",i="";this.backgroundcolor&&"transparent"!==this.backgroundcolor&&(e+=i+'mathbackground="'+this.backgroundcolor+'"',i=","),this.shadow&&"auto"!==this.shadow&&(e+=i+'shadow="'+this.shadow+'"',i=","),this.strokeWidth||"solid"!==this.strokeStyle?(e+=i+this.borderStyle,i=","):this.strokeColor&&"currentColor"!==this.strokeColor&&(e+=i+'mathcolor="'+this.strokeColor+'"',i=","),e&&(a+=`[${e}]`)}return og(a,this.bodyToLatex(e))}render(e){var i,r,a,o,n,l;let s=new oW({parent:e},this.style),c=oG.createBox(s,this.body);if(!c)return null;let d=function(e){if(!e)return"1px";let i=e.match(/([0-9][a-zA-Z\%]+)/);return null===i?"1px":i[1]}(this.borderStyle),u=s.toEm(this.padding&&"auto"!==this.padding?{string:this.padding}:{register:"fboxsep"});c.setStyle("position","relative"),c.setStyle("display","inline-block"),c.setStyle("height",c.height+c.depth,"em"),c.setStyle("width",c.width,"em");let h=new oE(null,{classes:"ML__notation"}),p=c.height+c.depth+2*u,m=c.width+2*u,f="",g=Math.min(.2*u,.05);if(this.notation.horizontalstrike){let e=2*u+c.height-.2155;f+=this.line((u+g).toString(),e.toString(),(u+c.width-g).toString(),e.toString())}if(this.notation.verticalstrike){let e=u+c.width/2;f+=this.line(e.toString(),(u+g).toString(),e.toString(),(p-u-g).toString())}if(this.notation.updiagonalstrike&&(f+=this.line((u+g).toString(),(p-u-g).toString(),(u+c.width-g).toString(),(u+g).toString())),this.notation.downdiagonalstrike&&(f+=this.line((u+g).toString(),(u+g).toString(),(u+c.width-g).toString(),(p-u-g).toString())),this.notation.updiagonalarrow){f+=this.line(u.toString(),(2*u+c.depth+c.height).toString(),(u+c.width).toString(),u.toString());let e=.03*Math.sqrt(m*m+p*p)*1,r=c.width*e,a=(c.depth+c.height)*e,o=u+c.width,n=u;n+a-.4*r<0&&(n=.4*r-a),f+='<polygon points="',f+=`${o},${n} ${o-r-.4*a},${n+a-.4*r} `,f+=`${o-.7*r},${n+.7*a} ${o-r+.4*a},${n+a+.4*r} `,f+=`${o},${n}`,f+=`" stroke='none' fill="${lf(null!=(i=this.strokeColor)?i:"")}"`,f+="/>"}let b=0;if(this.notation.phasorangle){let e=ly(s),i=(c.height+c.depth+2*e+2*u).toString(),r=(c.height+c.depth)/2;f+=this.line(u.toString(),i,(u+r+c.width).toString(),i),f+=this.line(u.toString(),i,(u+r).toString(),(u-e).toString()),p+=e,b=r,c.left+=p/2-u}if(this.notation.longdiv){let e=ly(s);p+=e,f+=this.line(u.toString(),u.toString(),(u+c.width).toString(),u.toString()),b=.3+e,c.left+=.3+e,c.setTop(u+e),f+='<path d="',f+=`M ${u} ${u} a0.3 ${(c.depth+c.height+2*e)/2}, 0, 1, 1, 0 ${c.depth+c.height+2*e} "`,f+=` stroke-width="${(Math.floor(100*(l=s).metrics.sqrtRuleThickness/l.scalingFactor)/100/10).toString()+"em"}" stroke="${lf(null!=(r=this.strokeColor)?r:"")}" fill="none"`,f+="/>"}if(h.width=c.width+2*u+b,h.height=c.height+2*u,h.depth=c.depth,h.setStyle("box-sizing","border-box"),h.setStyle("left",`calc(-1 * ${d} - ${u}em)`),h.setStyle("height",`calc( ${c.height+c.depth+2*u}em + ${d})`),h.setStyle("top","0em"),h.setStyle("width",`calc(${c.width+2*u}em + ${d})`),this.backgroundcolor&&h.setStyle("background-color",this.backgroundcolor),this.notation.box&&h.setStyle("border","1px solid red"),this.notation.actuarial&&(h.setStyle("border-top",this.borderStyle),h.setStyle("border-right",this.borderStyle)),this.notation.madruwb&&(h.setStyle("border-bottom",this.borderStyle),h.setStyle("border-right",this.borderStyle)),this.notation.roundedbox&&(h.setStyle("border-radius","8px"),h.setStyle("border",this.borderStyle)),this.notation.circle&&(h.setStyle("border-radius","50%"),h.setStyle("border",this.borderStyle)),this.notation.top&&h.setStyle("border-top",this.borderStyle),this.notation.left&&h.setStyle("border-left",this.borderStyle),this.notation.right&&h.setStyle("border-right",this.borderStyle),this.notation.bottom&&h.setStyle("border-bottom",this.borderStyle),f){let e="";"auto"===this.shadow&&(e+="filter: drop-shadow(0 0 .5px rgba(255, 255, 255, .7)) drop-shadow(1px 1px 2px #333)"),"none"!==this.shadow&&(e+=`filter: drop-shadow(${lf(null!=(a=this.shadow)?a:"")})`),e+=` stroke-width="${lf(null!=(o=this.strokeWidth)?o:"")}" stroke="${lf(null!=(n=this.strokeColor)?n:"")}" stroke-linecap="round"`,this.svgStrokeStyle&&(e+=` stroke-dasharray="${lf(this.svgStrokeStyle)}"`),h.svgStyle=e,h.svgOverlay=f}let y=new oE([h,c]);return y.setStyle("position","relative"),y.setStyle("height",`${Math.floor(100*(h.depth+h.height))/100}em`),y.setStyle("display","inline-block"),y.height=h.height,y.depth=h.depth,y.width=h.width-2*u,y.left=u,y.right=u,this.caret&&(y.caret=this.caret),y.wrap(s)}line(e,i,r,a){return`<line x1="${lb(e)}" y1="${lb(i)}" x2="${lb(r)}" y2="${lb(a)}" vector-effect="non-scaling-stroke"></line>`}};function lb(e){return"number"==typeof e?`${Math.floor(100*e)/100}%`:e}function ly(e){let i=e.isDisplayStyle?.431:e.metrics.defaultRuleThickness;return e.metrics.defaultRuleThickness+e.scalingFactor*i/4}var lv=class e extends oG{constructor(e,i,r){var a,o,n;super(g(f({},r),{type:"genfrac",displayContainsHighlight:!0})),this.above=e,this.below=i,this.hasBarLine=null==(a=null==r?void 0:r.hasBarLine)||a,this.continuousFraction=null!=(o=null==r?void 0:r.continuousFraction)&&o,this.align=null!=(n=null==r?void 0:r.align)?n:"center",this.numerPrefix=null==r?void 0:r.numerPrefix,this.denomPrefix=null==r?void 0:r.denomPrefix,this.mathstyleName=null==r?void 0:r.mathstyleName,this.leftDelim=null==r?void 0:r.leftDelim,this.rightDelim=null==r?void 0:r.rightDelim}static fromJson(i){return new e(i.above,i.below,i)}toJson(){let e={};return this.continuousFraction&&(e.continuousFraction=!0),"center"!==this.align&&(e.align=this.align),this.numerPrefix&&(e.numerPrefix=this.numerPrefix),this.denomPrefix&&(e.denomPrefix=this.denomPrefix),this.leftDelim&&(e.leftDelim=this.leftDelim),this.rightDelim&&(e.rightDelim=this.rightDelim),this.hasBarLine||(e.hasBarLine=!1),this.mathstyleName&&(e.mathstyleName=this.mathstyleName),f(f({},super.toJson()),e)}get children(){if(this._children)return this._children;let e=[];if("denominator-numerator"===o$.fractionNavigationOrder){for(let i of this.below)e.push(...i.children),e.push(i);for(let i of this.above)e.push(...i.children),e.push(i)}else{for(let i of this.above)e.push(...i.children),e.push(i);for(let i of this.below)e.push(...i.children),e.push(i)}return this._children=e,e}render(e){var i,r;let a=new oW({parent:e,mathstyle:this.mathstyleName},this.style),o=a.metrics,n=new oW({parent:a,mathstyle:this.continuousFraction?"":"numerator"},this.style),l=this.numerPrefix?new oE([new oE(this.numerPrefix),oG.createBox(n,this.above)],{isTight:n.isTight,type:"ignore"}):null!=(i=oG.createBox(n,this.above,{type:"ignore"}))?i:new oE(null,{type:"ignore"}),s=new oW({parent:a,mathstyle:this.continuousFraction?"":"denominator"},this.style),c=this.denomPrefix?new oE([new oE(this.denomPrefix),oG.createBox(s,this.below,{type:"ignore"})]):null!=(r=oG.createBox(s,this.below,{type:"ignore"}))?r:new oE(null,{type:"ignore"}),d=this.hasBarLine?o.defaultRuleThickness:0,u,h=0,p;a.isDisplayStyle?(u=n.metrics.num1,h=d>0?3*d:7*d,p=s.metrics.denom1):(d>0?(u=n.metrics.num2,h=d):(u=n.metrics.num3,h=3*o.defaultRuleThickness),p=s.metrics.denom2);let m=[];this.isSelected&&m.push("ML__selected");let f=l.depth,g=c.height,b;if(d<=0){let e=u-f-(g-p);e<h&&(u+=(h-e)/2,p+=(h-e)/2),b=new oB({individualShift:[{box:l,shift:-u,classes:[...m,lx(this.align)]},{box:c,shift:p,classes:[...m,lx(this.align)]}]}).wrap(a)}else{let e=new oE(null,{classes:"ML__frac-line",mode:this.mode,style:this.style});e.softWidth=Math.max(l.width,c.width),e.height=d/2,e.depth=d/2;let i=.25+d/2;u<h+f+i&&(u=h+f+i);let r=.25-d/2;p<h+g-r&&(p=h+g-r),b=new oB({individualShift:[{box:c,shift:p,classes:[...m,lx(this.align)]},{box:e,shift:-r,classes:m},{box:l,shift:-u,classes:[...m,lx(this.align)]}]}).wrap(a)}let y=a.isDisplayStyle?o.delim1:o.delim2,v=this.leftDelim?this.bind(e,nH("open",this.leftDelim,y,!0,e,{style:this.style,mode:this.mode,isSelected:this.isSelected})):nU(a,"ML__open"),x=null;x=this.continuousFraction?new oE(null,{type:"close"}):this.rightDelim?this.bind(e,nH("close",this.rightDelim,y,!0,e,{style:this.style,mode:this.mode,isSelected:this.isSelected})):nU(a,"ML__close");let _=new oE([v,b,x],{isTight:a.isTight,type:"inner",classes:"ML__mfrac"}),w=this.bind(e,_);return this.caret&&(w.caret=this.caret),this.attachSupsub(e,{base:w})}};function lx(e){var i;return null!=(i=({left:"ML__left",right:"ML__right",center:"ML__center"})[e])?i:"ML__center"}var l_=class e extends oG{constructor(e,i){var r;super({type:"latex",value:e,mode:"latex"}),this.isSuggestion=null!=(r=null==i?void 0:i.isSuggestion)&&r,this.isError=!1}static fromJson(i){let r=new e(i.value);return i.isSuggestion&&(r.isSuggestion=!0),i.isError&&(r.isError=!0),r}toJson(){let e={};return this.isSuggestion&&(e.isSuggestion=!0),this.isError&&(e.isError=!0),f({type:"latex",value:this.value},e)}render(e){let i=new oE(this.value,{classes:this.isSuggestion?"ML__suggestion":this.isError?"ML__error":"",type:"latex",maxFontSize:1});return i?(this.caret&&(i.caret=this.caret),this.bind(e,i)):null}},lw=class e extends oG{constructor(e=""){super({type:"latexgroup",mode:"latex"}),this.body=[...e].map(e=>new l_(e)),this.skipBoundary=!0}static fromJson(i){return new e}toJson(){return super.toJson()}render(e){let i=oG.createBox(e,this.body);return i?(this.caret&&(i.caret=this.caret),this.bind(e,i)):null}_serialize(e){var i,r;return null!=(r=null==(i=this.body)?void 0:i.map(e=>e.value).join(""))?r:""}},lk=class e extends oG{constructor(e,i){super(g(f({},i),{type:"extensible-symbol",isFunction:null==i?void 0:i.isFunction})),this.value=e,this.variant=null==i?void 0:i.variant,this.subsupPlacement=null==i?void 0:i.limits}static fromJson(i){return new e(i.symbol,i)}toJson(){let e=super.toJson();return this.variant&&(e.variant=this.variant),this.subsupPlacement&&(e.limits=this.subsupPlacement),this.value&&(e.symbol=this.value),e}render(e){var i;let r=e.isDisplayStyle&&"\\smallint"!==this.value,a=new oE(this.value,{fontFamily:r?"Size2-Regular":"Size1-Regular",classes:"ML__op-symbol "+(r?"ML__large-op":"ML__small-op"),type:"op",maxFontSize:e.scalingFactor,isSelected:this.isSelected});if(!a)return null;a.right=a.italic;let o=(a.height-a.depth)/2-.25*e.scalingFactor,n=a.italic;a.setTop(o);let l=a;if(this.superscript||this.subscript){let r=null!=(i=this.subsupPlacement)?i:"auto";"auto"===r&&e.isDisplayStyle&&(r="over-under"),l="over-under"===r?this.attachLimits(e,{base:a,baseShift:o,slant:n}):this.attachSupsub(e,{base:a})}return new oE(this.bind(e,l),{type:"op",caret:this.caret,isSelected:this.isSelected,classes:"ML__op-group"}).wrap(e)}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let i=eM(this.command,this.mode);if(null!=i&&i.serialize)return i.serialize(this,e);let r=[];return r.push(this.command),this.explicitSubsupPlacement&&("over-under"===this.subsupPlacement&&r.push("\\limits"),"adjacent"===this.subsupPlacement&&r.push("\\nolimits"),"auto"===this.subsupPlacement&&r.push("\\displaylimits")),r.push(this.supsubToLatex(e)),of(r)}},lM=class e extends oG{constructor(e){let i=e.body;super(g(f({},e),{type:"overlap",body:"string"==typeof i?[new oG({value:i})]:i,style:null==e?void 0:e.style})),this.skipBoundary=!0,this.align=null==e?void 0:e.align,this.boxType=null==e?void 0:e.boxType}static fromJson(i){return new e(i)}toJson(){let e={};return this.align&&(e.align=this.align),this.boxType&&(e.boxType=this.boxType),f(f({},super.toJson()),e)}render(e){let i=oG.createBox(e,this.body,{classes:"ML__inner"});if(!i)return null;this.caret&&(i.caret=this.caret);let r="right"===this.align?"ML__rlap":"center"===this.align?"ML__clap":"ML__llap";return this.bind(e,new oE([i,new oE(null,{classes:"ML__fix"})],{classes:r,type:this.boxType}))}},lS=class e extends oG{constructor(e){var i,r,a,o;super({type:"overunder",command:e.command,style:e.style,mode:e.mode,body:e.body,skipBoundary:null==(i=e.skipBoundary)||i}),this.subsupPlacement=e.supsubPlacement,this.svgAbove=e.svgAbove,this.svgBelow=e.svgBelow,this.svgBody=e.svgBody,this.above=e.above,this.below=e.below,this.boxType=null!=(r=e.boxType)?r:"ord",this.paddedBody=null!=(a=e.paddedBody)&&a,this.paddedLabels=null!=(o=e.paddedLabels)&&o}static fromJson(i){return new e(i)}toJson(){let e=super.toJson();return this.skipBoundary||(e.skipBoundary=!1),this.subsupPlacement&&(e.subsupPlacement=this.subsupPlacement),this.svgAbove&&(e.svgAbove=this.svgAbove),this.svgBelow&&(e.svgBelow=this.svgBelow),this.svgBody&&(e.svgBody=this.svgBody),"ord"!==this.boxType&&(e.boxType=this.boxType),this.paddedBody&&(e.paddedBody=!0),this.paddedLabels&&(e.paddedLabels=!0),e}render(e){let i=this.svgBody?oT(this.svgBody):oG.createBox(e,this.body,{type:"ignore"}),r=new oW({parent:e,mathstyle:"scriptstyle"},this.style),a=null;this.svgAbove?a=oT(this.svgAbove):this.above&&(a=oG.createBox(r,this.above,{type:"ignore"}));let o=null;this.svgBelow?o=oT(this.svgBelow):this.below&&(o=oG.createBox(r,this.below,{type:"ignore"})),this.paddedBody&&(i=new oE([nU(e,"ML__open"),i,nU(e,"ML__close")],{type:"ignore"}));let n=function(e,i){if(!i.base)return null;if(!i.above&&!i.below){let e=new oE(i.base,{type:i.type});return e.setStyle("position","relative"),e}let r=0;i.above&&(r=e.metrics.bigOpSpacing5);let a=null,o=i.base,n=["ML__center"];return(i.paddedAboveBelow&&n.push("ML__label_padding"),i.below&&i.above)?a=new oB({bottom:e.metrics.bigOpSpacing5+i.below.height+i.below.depth+o.depth+0,children:[e.metrics.bigOpSpacing5,{box:i.below,classes:n},{box:o,classes:["ML__center"]},r,{box:i.above,classes:n},e.metrics.bigOpSpacing5]}):i.below?a=new oB({top:o.height-0,children:[e.metrics.bigOpSpacing5,{box:i.below,classes:n},{box:o,classes:["ML__center"]}]}):i.above&&(a=new oB({bottom:o.depth+0,children:[{box:o,classes:["ML__center"]},r,{box:i.above,classes:n},e.metrics.bigOpSpacing5]})),new oE(a,{type:i.type})}(e,{base:i,above:a,below:o,type:"bin"===this.boxType||"rel"===this.boxType?this.boxType:"ord",paddedAboveBelow:this.paddedLabels});return n?(n="over-under"===this.subsupPlacement?this.attachLimits(e,{base:n,type:n.type}):this.attachSupsub(e,{base:n}),this.caret&&(n.caret=this.caret),this.bind(e,n)):null}},lL=class e extends oG{constructor(e){var i,r,a,o;super(g(f({},e),{type:"phantom"})),this.captureSelection=!0,this.isInvisible=null!=(i=e.isInvisible)&&i,this.smashDepth=null!=(r=e.smashDepth)&&r,this.smashHeight=null!=(a=e.smashHeight)&&a,this.smashWidth=null!=(o=e.smashWidth)&&o}static fromJson(i){return new e(i)}toJson(){let e={};return this.isInvisible&&(e.isInvisible=!0),this.smashDepth&&(e.smashDepth=!0),this.smashHeight&&(e.smashHeight=!0),this.smashWidth&&(e.smashWidth=!0),f(f({},super.toJson()),e)}render(e){let i=new oW({parent:e,isPhantom:!0});if(!this.smashDepth&&!this.smashHeight&&!this.smashWidth)return this.isInvisible,oG.createBox(i,this.body,{classes:"ML__inner"});let r=oG.createBox(this.isInvisible?i:e,this.body);if(!r)return null;if(this.smashWidth){let i=new oE(null,{classes:"ML__fix"});return new oE([r,i],{classes:"ML__rlap"}).wrap(e)}if(!this.smashHeight&&!this.smashDepth)return r;if(this.smashHeight&&(r.height=0),this.smashDepth&&(r.depth=0),r.children)for(let e of r.children)this.smashHeight&&(e.height=0),this.smashDepth&&(e.depth=0);return new oB({firstBaseline:[{box:r}]},{type:r.type}).wrap(e)}},lC=class e extends oG{constructor(e){var i;super(f({type:"spacing"},e)),this.width=null==e?void 0:e.width,this._braced=null!=(i=null==e?void 0:e.braced)&&i}static fromJson(i){return new e(i)}toJson(){let e=super.toJson();return void 0!==this.width&&(e.width=this.width),this._braced&&(e.braced=!0),e}render(e){var i;let r;return"space"===this.command?new oE("math"===this.mode?null:" "):(void 0!==this.width?(r=new oE(null,{classes:"ML__mspace"})).left=e.toEm(this.width):r=new oE(null,{classes:null!=(i=({"\\qquad":"ML__qquad","\\quad":"ML__quad","\\enspace":"ML__enspace","\\enskip":"ML__enspace","\\;":"ML__thickspace","\\thickspace":"ML__thickspace","\\:":"ML__mediumspace","\\>":"ML__mediumspace","\\medspace":"ML__mediumspace","\\,":"ML__thinspace","\\thinspace":"ML__thinspace","\\!":"ML__negativethinspace","\\negthinspace":"ML__negativethinspace","\\negmedspace":"ML__negativemediumspace","\\negthickspace":"ML__negativethickspace"})[this.command])?i:"ML__mediumspace"}),r=this.bind(e,r),this.caret&&(r.caret=this.caret),r)}_serialize(e){var i;if(!e.expandMacro&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let r=eM(this.command,this.mode);if(null!=r&&r.serialize)return r.serialize(this,e);let a=null!=(i=this.command)?i:"";return void 0===this.width?a:!this._braced||"register"in this.width?`${a}${oF(this.width)}`:`${a}{${oF(this.width)}}`}},lE=class e extends oG{constructor(e){var i;super(g(f({},e),{type:"surd",mode:null!=(i=e.mode)?i:"math",style:e.style,displayContainsHighlight:!0,body:e.body})),this.above=e.index}static fromJson(i){return new e(g(f({},i),{index:i.above}))}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let i=eM(this.command,this.mode);if(null!=i&&i.serialize)return i.serialize(this,e);let r=this.command,a=this.bodyToLatex(e);return this.above&&!this.hasEmptyBranch("above")?og(`${r}[${this.aboveToLatex(e)}]`,a):o$.compactSerialization&&/^[0-9]$/.test(a)?`${r}${a}`:og(r,a)}get children(){if(this._children)return this._children;let e=[];if(this.above)for(let i of this.above)e.push(...i.children),e.push(i);if(this.body)for(let i of this.body)e.push(...i.children),e.push(i);return this._children=e,e}render(e){var i;let r=new oW({parent:e,mathstyle:"cramp"},this.style),a=null!=(i=oG.createBox(r,this.body,{type:"inner"}))?i:new oE(null),o=r.scalingFactor,n=r.metrics.defaultRuleThickness/o,l=e.isDisplayStyle?.431:n,s=new oE(null,{classes:"ML__sqrt-line",style:this.style});s.height=n,s.softWidth=a.width;let c=o*(n+l/4),d=Math.max(2*o*l,a.height+a.depth)+c+n,u=new oW({parent:e},this.style),h=this.bind(u,new oE(nH("inner","\\surd",d,!1,u,{isSelected:this.isSelected}),{isSelected:this.isSelected,classes:"ML__sqrt-sign",style:this.style}));if(!h)return null;let p=h.height+h.depth-n;p>a.height+a.depth+c&&(c=(c+p-(a.height+a.depth))/2),h.setTop(h.height-a.height-c);let m=this.bind(e,new oB({firstBaseline:[{box:new oE(a)},c-2*n,{box:s},n]})),f=oG.createBox(new oW({parent:e,mathstyle:"scriptscriptstyle"}),this.above,{type:"ignore"});if(!f){let i=new oE([h,m],{classes:this.containsCaret?"ML__contains-caret":"",type:"inner"});return i.setStyle("display","inline-block"),i.setStyle("height",i.height+i.depth,"em"),this.caret&&(i.caret=this.caret),this.bind(e,i)}let g=new oE([new oE(new oB({shift:-.6*(Math.max(h.height,m.height)-Math.max(h.depth,m.depth)),children:[{box:f}]}),{classes:"ML__sqrt-index",type:"ignore"}),h,m],{type:"inner",classes:this.containsCaret?"ML__contains-caret":""});return g.height=h.height,g.depth=h.depth,this.caret&&(g.caret=this.caret),this.bind(e,g)}},lA=class extends oE{constructor(e){super(null,{type:"skip"}),this._width=e}toMarkup(){return`<span style="display:inline-block;width:${Math.ceil(100*this.width)/100}em"></span>`}};function lz(e,i){if(!e.parent)return;let r=e.parent.children,a=r.indexOf(e),o=a-1;for(;o>=0&&"ignore"===r[o].type;)o-=1;o<0&&e.parent.parent&&"lift"===e.parent.type?lz(e.parent,i):a>0&&"skip"===r[a-1].type?r[a-1].width+=i:r.splice(a,0,new lA(i))}var lT={ord:{op:3,bin:4,rel:5,inner:3},op:{ord:3,op:3,rel:5,inner:3},bin:{ord:4,op:4,open:4,inner:4},rel:{ord:5,op:5,open:5,inner:5},close:{op:3,bin:4,rel:5,inner:3},punct:{ord:3,op:3,rel:3,open:3,punct:3,inner:3},inner:{ord:3,op:3,bin:4,rel:5,open:3,punct:3,inner:3}},lD={ord:{op:3},op:{ord:3,op:3},close:{op:3},inner:{op:3}};function lK(e,i){if(!e.children)return e;let r=e.children;lB(r,(e,i)=>{"bin"===i.type&&(!e||/^(middle|bin|op|rel|open|punct)$/.test(e.type))&&(i.type="ord"),(null==e?void 0:e.type)==="bin"&&/^(rel|close|punct)$/.test(i.type)&&(e.type="ord"),"ignore"!==i.type&&(e=i)});let a=i.getRegisterAsEm("thinmuskip"),o=i.getRegisterAsEm("medmuskip"),n=i.getRegisterAsEm("thickmuskip");return lB(r,(e,i)=>{var r,l,s;if(!e)return;let c=e.type;if("newline"===c)return;let d=i.isTight?null!=(r=lD[c])?r:null:null!=(l=lT[c])?l:null,u=null!=(s=null==d?void 0:d[i.type])?s:null;3===u&&lz(i,a),4===u&&lz(i,o),5===u&&lz(i,n)}),e}function lB(e,i,r){if(!e)return r;for(let a of e=[...e])"lift"===a.type?r=lB(a.children,i,r):"ignore"===a.type?lB(a.children,i):(i(r,a),lB(a.children,i),r=a);return r}var l$=class e extends oG{constructor(e){super({type:"tooltip",command:e.command,mode:e.mode,style:e.style,body:e.body,displayContainsHighlight:!0}),this.tooltip=new oG({type:"root",mode:e.content,body:e.tooltip,style:{}}),this.skipBoundary=!0,this.captureSelection=!1}static fromJson(i){return new e(g(f({},i),{tooltip:lI(i.tooltip)}))}toJson(){var e;let i=null==(e=this.tooltip.body)?void 0:e.filter(e=>"first"!==e.type).map(e=>e.toJson());return g(f({},super.toJson()),{tooltip:i})}render(e){let i=oG.createBox(e,this.body);if(!i)return null;let r=new oW({parent:e,mathstyle:"displaystyle"},{fontSize:5}),a=oA(lK(new oE(this.tooltip.render(r),{classes:"ML__tooltip-content"}),r)),o=new oE([a,i],{classes:"ML__tooltip-container"});return this.caret&&(o.caret=this.caret),this.bind(e,o)}},lP=class e extends oG{constructor(e,i){var r;super({type:"mop",mode:null!=(r=null==i?void 0:i.mode)?r:"math",style:null==i?void 0:i.style,command:"\\blank",isFunction:!0,captureSelection:!0,body:e})}static fromJson(i){return new e(i.body,i)}render(e){let i=new oW({parent:e}),r=!this.body||0===this.body.length||this.body.every(e=>"first"===e.type)?new nJ({mode:this.mode,style:this.style}).render(e):oG.createBox(e,this.body),a=new oE("blank",{type:"op",mode:"math",maxFontSize:i.scalingFactor,style:{variant:"main",variantStyle:"up"},isSelected:this.isSelected,letterShapeStyle:i.letterShapeStyle}),o=new oE("(",{type:"open",isSelected:this.isSelected,maxFontSize:i.scalingFactor}),n=new oE(")",{type:"close",isSelected:this.isSelected,maxFontSize:i.scalingFactor}),l=new oE([a,o,r,n],{type:"ord",classes:"ML__blank",isSelected:this.isSelected});this.caret&&(l.caret=this.caret);let s=this.attachSupsub(e,{base:l});return this.bind(i,s)}_serialize(e){var i;let r=null!=(i=this.bodyToLatex(e))?i:"";return e.skipPlaceholders?r:og("\\blank",r)}},lO=class e extends oG{constructor(e,i){super(g(f({},i),{type:"operator",isFunction:null==i?void 0:i.isFunction})),this.value=e,this.variant=null==i?void 0:i.variant,this.variantStyle=null==i?void 0:i.variantStyle,this.subsupPlacement=null==i?void 0:i.limits}static fromJson(i){return new e(i.symbol,i)}toJson(){let e=super.toJson();return this.variant&&(e.variant=this.variant),this.variantStyle&&(e.variantStyle=this.variantStyle),this.subsupPlacement&&(e.limits=this.subsupPlacement),this.value&&(e.symbol=this.value),e}render(e){var i;let r=new oE(this.value,{type:"op",mode:"math",maxFontSize:e.scalingFactor,style:{variant:this.variant,variantStyle:this.variantStyle},isSelected:this.isSelected,letterShapeStyle:e.letterShapeStyle}),a=r;if(this.superscript||this.subscript){let o=null!=(i=this.subsupPlacement)?i:"auto";a="over-under"===o||"auto"===o&&e.isDisplayStyle?this.attachLimits(e,{base:r}):this.attachSupsub(e,{base:r})}return new oE(this.bind(e,a),{type:"op",caret:this.caret,isSelected:this.isSelected,classes:"ML__op-group"}).wrap(e)}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;let i=eM(this.command,this.mode);if(null!=i&&i.serialize)return i.serialize(this,e);let r=[this.command];return this.explicitSubsupPlacement&&("over-under"===this.subsupPlacement&&r.push("\\limits"),"adjacent"===this.subsupPlacement&&r.push("\\nolimits"),"auto"===this.subsupPlacement&&r.push("\\displaylimits")),r.push(this.supsubToLatex(e)),of(r)}},lR=class e extends oG{constructor(e){super(g(f({type:"newline"},e),{skipBoundary:!0}))}static fromJson(i){return new e(i)}toJson(){return super.toJson()}render(e){let i=new oE(null,{classes:"ML__newline",type:"newline"});return this.caret&&(i.caret=this.caret),this.bind(e,i)}_serialize(e){return"\\\\"}};function lI(e){if(R(e))return e.map(e=>lI(e));if("string"==typeof e)return oG.fromJson(e);for(let i of(e=f({},e),oU))e[i]&&(e[i]=lI(e[i]));e.args&&(e.args=function(e){if(e){if("string"==typeof e)return e;if(Array.isArray(e))return e.map(e=>"<null>"===e?null:"object"==typeof e&&"group"in e?{group:e.group.map(e=>lI(e))}:"object"==typeof e&&"atoms"in e?e.atoms.map(e=>lI(e)):e)}}(e.args)),e.array&&(e.array=lI(e.array));let i=e.type,r;for(let a of("accent"===i&&(r=nD.fromJson(e)),"array"===i&&(r=n0.fromJson(e)),"box"===i&&(r=n5.fromJson(e)),"chem"===i&&(r=ld.fromJson(e)),"composition"===i&&(r=n7.fromJson(e)),"delim"===i&&(r=lp.fromJson(e)),"enclose"===i&&(r=lg.fromJson(e)),"error"===i&&(r=n9.fromJson(e)),"extensible-symbol"===i&&(r=lk.fromJson(e)),"genfrac"===i&&(r=lv.fromJson(e)),"group"===i&&(r=le.fromJson(e)),"latex"===i&&(r=l_.fromJson(e)),"latexgroup"===i&&(r=lw.fromJson(e)),"leftright"===i&&(r=lt.fromJson(e)),"macro"===i&&(r=li.fromJson(e)),"macro-argument"===i&&(r=lr.fromJson(e)),"newline"===i&&(r=lR.fromJson(e)),"operator"===i&&(r=lO.fromJson(e)),"overlap"===i&&(r=lM.fromJson(e)),"overunder"===i&&(r=lS.fromJson(e)),"placeholder"===i&&(r=nJ.fromJson(e)),"\\blank"===e.command?r=lP.fromJson(e):"prompt"===i&&(r=la.fromJson(e)),"phantom"===i&&(r=lL.fromJson(e)),"sizeddelim"===i&&(r=lm.fromJson(e)),"spacing"===i&&(r=lC.fromJson(e)),"subsup"===i&&(r=lo.fromJson(e)),"surd"===i&&(r=lE.fromJson(e)),"text"===i&&(r=oY.fromJson(e)),"tooltip"===i&&(r=l$.fromJson(e)),r||(i&&["first","mbin","mrel","mclose","minner","mop","mopen","mord","mpunct","root","space"].includes(i),r=oG.fromJson(e)),oU))e[a]&&r.setChildren(e[a],a);return void 0!==e.verbatimLatex&&(r.verbatimLatex=e.verbatimLatex),e.subsupPlacement&&(r.subsupPlacement=e.subsupPlacement),e.explicitSubsupPlacement&&(r.explicitSubsupPlacement=!0),e.isFunction&&(r.isFunction=!0),e.skipBoundary&&(r.skipBoundary=!0),e.captureSelection&&(r.captureSelection=!0),r}function lN(e,i){e&&i&&(R(e)?e.forEach(e=>lN(e,i)):"object"==typeof e&&e.applyStyle(i,{unstyledOnly:!0}))}function lq(e,i,r,a){function o(e,i){for(let r of n)if(r.style[e]!==i)return!1;return!0}if((i=e.normalizeRange(i))[0]===i[1])return!1;let n=e.getAtoms(i,{includeChildren:!0});for(let e of("toggle"===a.operation&&(r.color&&o("color",r.color)&&(r.color="none",delete r.verbatimColor),r.backgroundColor&&o("backgroundColor",r.backgroundColor)&&(r.backgroundColor="none",delete r.verbatimBackgroundColor),r.fontFamily&&o("fontFamily",r.fontFamily)&&(r.fontFamily="none"),r.fontSeries&&o("fontSeries",r.fontSeries)&&(r.fontSeries="auto"),r.fontShape&&o("fontShape",r.fontShape)&&(r.fontShape="auto"),r.fontSize&&o("fontSize",r.fontSize)&&(r.fontSize=5),r.variant&&o("variant",r.variant)&&(r.variant="normal"),r.variantStyle&&o("variantStyle",r.variantStyle)&&(r.variantStyle="")),n))e.applyStyle(r);return!0}function lF(e){return({up:"up",bold:"bold",italic:void 0,bolditalic:"bold","":void 0})[null!=e?e:""]}var lV={acute:714,grave:715,dot:729,ddot:168,dddot:8411,ddddot:8412,mathring:730,tilde:126,bar:713,breve:728,check:711,hat:94,vec:8407};function lj(e,i=[[[]]],r=[],a=[],o,n){return new n0(e,i,r,g(f({},function(e,i,r,a){switch(e){case"math":case"displaymath":return{mathstyleName:"textstyle",isRoot:!0,minColumns:1,maxColumns:1,minRows:1,maxRows:1};case"center":return{columns:[{align:"c"}],classes:["ML__center_environment"],isRoot:!0,minColumns:1,maxColumns:1,minRows:1,maxRows:1};case"multline":case"multline*":return{columns:[{align:"m"}],leftDelim:".",rightDelim:".",isRoot:!0,minColumns:1,maxColumns:1,minRows:1};case"split":return{columns:[{align:"r"},{align:"l"}],minColumns:2,minRows:1,isRoot:!1};case"gather":case"gather*":return{columns:[{gap:.25},{align:"c"},{gap:0}],minColumns:1,maxColumns:1,minRows:1,isRoot:!0,classes:["ML__gather_environment"]};case"gathered":return{columns:[{gap:.25},{align:"c"},{gap:0}],minColumns:1,maxColumns:1,minRows:1};case"equation":case"equation*":case"subequations":return{columns:[{align:"c"}],isRoot:!0,minColumns:1,maxColumns:1,minRows:1};case"aligned":{let r=0;for(let e of i)r=Math.max(r,e.length);let a=[{gap:0},{align:"r"},{gap:.25},{align:"l"}],o=2;for(;o<r;)a.push({gap:1},{align:"r"},{gap:.25},{align:"l"}),o+=2;return a.push({gap:0}),{arraycolsep:0,columns:a,minColumns:2,minRows:1,isRoot:"aligned"!==e}}case"eqnarray":return{arraycolsep:0,columns:[{gap:0},{align:"r"},{align:"c"},{align:"l"}],minColumns:3,maxColumns:3,minRows:1,isRoot:!0,classes:["ML__eqnarray_environment"]};case"align":case"align*":return{arraycolsep:0,columns:[{gap:0},{align:"r"},{gap:.25},{align:"l"}],minColumns:2,maxColumns:2,minRows:1,isRoot:!0,classes:["ML__align_environment"]};case"pmatrix":case"pmatrix*":return{mathstyleName:"textstyle",leftDelim:"(",rightDelim:")",columns:lH(r[0],a)};case"bmatrix":case"bmatrix*":return{mathstyleName:"textstyle",leftDelim:"[",rightDelim:"]",columns:lH(r[0],a)};case"Bmatrix":case"Bmatrix*":return{mathstyleName:"textstyle",leftDelim:"\\lbrace",rightDelim:"\\rbrace",columns:lH(r[0],a)};case"vmatrix":case"vmatrix*":return{mathstyleName:"textstyle",leftDelim:"\\vert",rightDelim:"\\vert",columns:lH(r[0],a)};case"Vmatrix":case"Vmatrix*":return{mathstyleName:"textstyle",leftDelim:"\\Vert",rightDelim:"\\Vert",columns:lH(r[0],a)};case"matrix":case"matrix*":return{mathstyleName:"textstyle",leftDelim:".",rightDelim:".",columns:lH(null==r?void 0:r[0],a)};case"smallmatrix":case"smallmatrix*":return{mathstyleName:"scriptstyle",columns:lH(null==r?void 0:r[0],a),colSeparationType:"small",arraystretch:.5};case"cases":case"dcases":return{mathstyleName:"dcases"===e?"displaystyle":"textstyle",arraystretch:1.2,leftDelim:"\\lbrace",rightDelim:".",columns:lW()};case"rcases":return{arraystretch:1.2,leftDelim:".",rightDelim:"\\rbrace",columns:lW()};case"lines":return{leftDelim:".",rightDelim:".",columns:[{align:"l"}],isRoot:!0,minColumns:1,maxColumns:1,minRows:1}}return{mathstyleName:"textstyle"}}(e,i,a,o)),{rowRules:n}))}function lH(e,i=10){return null!=e?e:Array(i).fill({align:"c"})}function lW(e=10){let i=[];for(let r=0;r<e;r++)r>0&&i.push({gap:1}),i.push({align:"l"});return i}ex(Object.keys(lV),"{body:auto}",{createAtom:e=>new nD(g(f({},e),{body:et(e.args[0]),accentChar:lV[e.command.slice(1)]}))}),ex(["widehat","widecheck","widetilde"],"{body:auto}",{createAtom:e=>{let i=eb(et(e.args[0]));return new nD(g(f({},e),{body:et(e.args[0]),svgAccent:e.command.slice(1)+(i.length>5?"4":["1","1","2","2","3","3"][i.length])}))}}),ex(["overarc","overparen","wideparen"],"{body:auto}",{createAtom:e=>new nD(g(f({},e),{body:et(e.args[0]),svgAccent:"overarc"}))}),ex(["underarc","underparen"],"{body:auto}",{createAtom:e=>new lS(g(f({},e),{body:et(e.args[0]),svgBelow:"underarc"}))}),ex("utilde","{body:auto}",{createAtom:e=>{let i=et(e.args[0]),r=eb(i),a="widetilde"+(r.length>5?"4":["1","1","2","2","3","3"][r.length]);return new lS(g(f({},e),{body:i,svgBelow:a,boxType:oL(i)}))}}),ex("^","{:string}",{createAtom:e=>{var i;return new oG(g(f({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&null!=(i=({a:"â",e:"ê",i:"î",o:"ô",u:"û",A:"Â",E:"Ê",I:"Î",O:"Ô",U:"Û"})[e.args[0]])?i:"^"}))}}),ex("`","{:string}",{createAtom:e=>{var i;return new oG(g(f({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&null!=(i=({a:"à",e:"è",i:"ì",o:"ò",u:"ù",A:"À",E:"È",I:"Ì",O:"Ò",U:"Ù"})[e.args[0]])?i:"`"}))}}),ex("'","{:string}",{createAtom:e=>{var i;return new oG(g(f({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&null!=(i=({a:"á",e:"é",i:"í",o:"ó",u:"ú",A:"Á",E:"É",I:"Í",O:"Ó",U:"Ú"})[e.args[0]])?i:"'"}))}}),ex('"',"{:string}",{createAtom:e=>{var i,r;return new oG(g(f({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:null!=(i=e.args)&&i[0]?null!=(r=({a:"ä",e:"ë",i:"ï",o:"ö",u:"ü",A:"Ä",E:"Ë",I:"Ë",O:"Ö",U:"Ü"})[e.args[0]])?r:'"'+e.args[0]:'"'}))}}),ex(".","{:string}",{createAtom:e=>{var i,r;return new oG(g(f({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:null!=(i=e.args)&&i[0]?null!=(r=({a:"ȧ",e:"ė",i:"̇i",o:"ȯ",u:"̇u",A:"Ȧ",E:"Ė",I:"İ",O:"Ȯ",U:"̇U"})[e.args[0]])?r:"."+e.args[0]:"."}))}}),ex("=","{:string}",{createAtom:e=>{var i,r;return new oG(g(f({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:null!=(i=e.args)&&i[0]?null!=(r=({a:"ā",e:"ē",i:"ī",o:"ō",u:"ū",A:"Ā",E:"Ē",I:"Ī",O:"Ō",U:"Ū"})[e.args[0]])?r:"="+e.args[0]:"="}))}}),ex("~","{:string}",{createAtom:e=>{var i;return new oG(g(f({type:"mord"},e),{isFunction:!1,limits:"adjacent",value:e.args[0]&&null!=(i=({n:"ñ",N:"Ñ",a:"ã",o:"õ",A:"Ã",O:"Õ"})[e.args[0]])?i:"´"}))}}),ex("c","{:string}",{createAtom:e=>{var i;return new oG(g(f({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&null!=(i=({c:"ç",C:"Ç"})[e.args[0]])?i:""}))}}),ex("enclose","{notation:string}[style:string]{body:auto}",{createAtom:e=>{var i,r;let a=e.args,o={strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",backgroundcolor:"transparent",padding:"auto",shadow:"none",svgStrokeStyle:void 0,borderStyle:void 0,style:null!=(i=e.style)?i:{}};if(a[1]){for(let e of a[1].split(/,(?![^(]*\)(?:(?:[^(]*\)){2})*[^"]*$)/)){let i=e.match(/\s*(\S+)\s+(\S+)\s+(.*)/);if(i)o.strokeWidth=i[1],o.strokeStyle=i[2],o.strokeColor=i[3];else{let i=e.match(/\s*([a-z]*)\s*=\s*"(.*)"/);i&&("mathbackground"===i[1]?o.backgroundcolor=i[2]:"mathcolor"===i[1]?o.strokeColor=i[2]:"padding"===i[1]?o.padding=i[2]:"shadow"===i[1]&&(o.shadow=i[2]))}}"dashed"===o.strokeStyle?o.svgStrokeStyle="5,5":"dotted"===o.strokeStyle&&(o.svgStrokeStyle="1,5")}o.borderStyle=`${o.strokeWidth} ${o.strokeStyle} ${o.strokeColor}`;let n={};return(null!=(r=a[0])?r:"").split(/[, ]/).filter(e=>e.length>0).forEach(e=>{n[e.toLowerCase()]=!0}),new lg(e.command,et(a[2]),n,o)}}),ex("cancel","{body:auto}",{createAtom:e=>{var i;return new lg(e.command,et(e.args[0]),{updiagonalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:null!=(i=e.style)?i:{}})}}),ex("bcancel","{body:auto}",{createAtom:e=>{var i;return new lg(e.command,et(e.args[0]),{downdiagonalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:null!=(i=e.style)?i:{}})}}),ex("xcancel","{body:auto}",{createAtom:e=>{var i;return new lg(e.command,et(e.args[0]),{updiagonalstrike:!0,downdiagonalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:null!=(i=e.style)?i:{}})}}),ex("sout","{body:auto}",{createAtom:e=>{var i;return new lg(e.command,et(e.args[0]),{horizontalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:null!=(i=e.style)?i:{}})}}),ev(["math","displaymath"],lj),ev("center",lj),ey(["multline","multline*"],"",lj),ex("displaylines","",{parse:e=>{if(e.skipWhitespace(),!e.match("<{>"))return[];let i=[],r=[];for(e.mathlist.length>0&&i.push([e.mathlist]),e.beginContext({tabular:!0,root:!0});!(e.end()||e.match("<}>"));)e.matchColumnSeparator()||e.matchRowSeparator()?(i.push([r]),r=[]):r.push(...e.scan(e=>["<}>","&","\\cr","\\\\","\\tabularnewline"].includes(e)));e.endContext(),i.push([r]);let a=e.scan();return a.length>0&&i.push([a]),i},createAtom:e=>new n0("lines",e.args,[],{leftDelim:".",rightDelim:".",columns:[{align:"l"}],classes:["ML__multiline_environment"],isRoot:!0,minColumns:1,maxColumns:1,minRows:1})}),ey("split","",lj),ey(["gather","gather*","gathered"],"",lj),ey(["equation","equation*","subequations"],"",lj),ev(["align","align*","eqnarray"],lj,{tabular:!0}),ey(["aligned"],"",lj),ey("array","{columns:colspec}",(e,i,r,a,o,n)=>new n0(e,i,r,{columns:a[0],mathstyleName:"textstyle",rowRules:n})),ey(["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],"[columns:colspec]",lj),ey(["smallmatrix","smallmatrix*"],"[columns:colspec]",lj),ey(["cases","dcases","rcases"],"",lj),ex("piecewise","{count:string}",{parse:e=>{var i,r;let a=null!=(r=null==(i=e.scanArgument("string"))?void 0:i.trim())?r:"";return 0===a.length?(e.onError({code:"missing-argument",arg:"\\piecewise"}),["1"]):!/^[1-9]\d*$/.test(a)||Number(a)>100?(e.onError({code:"unexpected-token",arg:a}),["1"]):[a]},createAtom:e=>{var i;let r=Number.parseInt(null==(i=e.args)?void 0:i[0],10);return lj("cases",Array.from({length:Number.isInteger(r)&&r>0?Math.min(r,100):1},()=>[[new nJ],[new nJ]]))}}),ex(["overrightarrow","overleftarrow","Overrightarrow","overleftharpoon","overrightharpoon","overleftrightarrow","overlinesegment","overgroup"],"{:auto}",{createAtom:e=>{var i;return new lS(g(f({},e),{body:et(null==(i=e.args)?void 0:i[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"rel",svgAbove:e.command.slice(1)}))}}),ex("overbrace","{:auto}",{createAtom:e=>new lS(g(f({},e),{body:et(e.args[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"ord",svgAbove:e.command.slice(1)}))}),ex(["underrightarrow","underleftarrow","underleftrightarrow","underlinesegment","undergroup"],"{:auto}",{createAtom:e=>new lS(g(f({},e),{body:et(e.args[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"rel",svgBelow:e.command.slice(1)}))}),ex(["underbrace"],"{:auto}",{createAtom:e=>new lS(g(f({},e),{body:et(e.args[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"ord",svgBelow:e.command.slice(1)}))}),ex(["xrightarrow","longrightarrow","xleftarrow","longleftarrow","xRightarrow","xLeftarrow","xleftharpoonup","xleftharpoondown","xrightharpoonup","xrightharpoondown","xlongequal","xtwoheadleftarrow","xtwoheadrightarrow","xleftrightarrow","longleftrightarrow","xLeftrightarrow","xrightleftharpoons","longrightleftharpoons","xleftrightharpoons","xhookleftarrow","xhookrightarrow","xmapsto","xtofrom","xleftrightarrows","longleftrightarrows","xRightleftharpoons","longRightleftharpoons","xLeftrightharpoons","longLeftrightharpoons"],"[:auto]{:auto}",{createAtom:e=>{var i,r,a,o,n;return new lS(g(f({},e),{svgBody:e.command.slice(1),above:(null==(r=et(null==(i=e.args)?void 0:i[1]))?void 0:r.length)===0?void 0:et(null==(a=e.args)?void 0:a[1]),below:null!=(n=et(null==(o=e.args)?void 0:o[0]))?n:null,skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,paddedLabels:!0,boxType:"rel"}))},serialize:(e,i)=>e.command+(e.hasEmptyBranch("below")?"":`[${e.belowToLatex(i)}]`)+`{${e.aboveToLatex(i)}}${e.supsubToLatex(i)}`}),ex(["arccos","arcsin","arctan","arctg","arcctg","arg","ch","cos","cosh","cot","cotg","coth","ctg","cth","csc","cosec","deg","dim","exp","gcd","hom","inf","ker","lb","lg","ln","log","Pr","sec","sh","sin","sinh","sup","tan","tanh","tg","th","arcsec","arccsc","arsinh","arcosh","artanh","arcsech","arccsch"],"",{isFunction:!0,ifMode:"math",createAtom:e=>new lO(e.command.slice(1),g(f({},e),{limits:"adjacent",isFunction:!0,variant:"main",variantStyle:"up"}))}),ex(["liminf","limsup"],"",{ifMode:"math",createAtom:e=>new lO({"\\liminf":"lim inf","\\limsup":"lim sup"}[e.command],g(f({},e),{limits:"over-under",variant:"main"}))}),ex(["lim","mod"],"",{ifMode:"math",createAtom:e=>new lO(e.command.slice(1),g(f({},e),{limits:"over-under",variant:"main"}))}),ex(["det","max","min"],"",{ifMode:"math",isFunction:!0,createAtom:e=>new lO(e.command.slice(1),g(f({},e),{limits:"over-under",isFunction:!0,variant:"main"}))}),ex("ang","{:math}",{ifMode:"math",createAtom:e=>new oG(g(f({},e),{body:et(e.args[0])})),serialize:(e,i)=>`\\ang{${e.bodyToLatex(i)}}`,render:(e,i)=>{let r=e.createBox(i),a=r.caret;r.caret=void 0;let o=new oE("°",{style:g(f({},e.style),{variant:"normal",variantStyle:"up"})});return new oE([r,o],{type:"inner",isSelected:e.isSelected,caret:a})}}),ex("sqrt","[index:auto]{radicand:expression}",{ifMode:"math",createAtom:e=>new lE(g(f({},e),{body:et(e.args[1]),index:e.args[0]?et(e.args[0]):void 0}))}),ex(["frac","dfrac","tfrac","binom","dbinom","tbinom"],"{:expression}{:expression}",{ifMode:"math",createAtom:e=>{let i=f({},e),r=e.command,a=e.args;switch(r){case"\\dfrac":case"\\frac":case"\\tfrac":i.hasBarLine=!0;break;case"\\atopfrac":i.hasBarLine=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":i.hasBarLine=!1,i.leftDelim="(",i.rightDelim=")";break;case"\\cfrac":i.hasBarLine=!0,i.continuousFraction=!0}switch(r){case"\\dfrac":case"\\dbinom":i.mathstyleName="displaystyle";break;case"\\tfrac":case"\\tbinom":i.mathstyleName="textstyle"}return new lv(a[0]?et(a[0]):[new nJ],a[1]?et(a[1]):[new nJ],i)},serialize:(e,i)=>{let r=e.aboveToLatex(i),a=e.belowToLatex(i);return o$.compactSerialization&&/^[0-9]$/.test(r)&&/^[0-9]$/.test(a)?`${e.command}${r}${a}`:og(e.command,r,a)}}),ex("genfrac","{:string}{:string}{:string}{:string}{:expression}{:expression}",{ifMode:"math",createAtom:e=>{var i,r,a,o,n;let l=e.args,s=(null!=(i=l[0])?i:"").trim(),c=(null!=(r=l[1])?r:"").trim(),d=(null!=(a=l[2])?a:"").trim(),u=null!=(n=({0:"displaystyle",1:"textstyle",2:"scriptstyle",3:"scriptscriptstyle"})[(null!=(o=l[3])?o:"").trim()])?n:void 0;return new lv(l[4]?et(l[4]):[new nJ],l[5]?et(l[5]):[new nJ],g(f({},e),{leftDelim:s&&"."!==s?s:void 0,rightDelim:c&&"."!==c?c:void 0,hasBarLine:"0pt"!==d&&"0"!==d,mathstyleName:u}))}}),ex(["cfrac"],"[:string]{:expression}{:expression}",{ifMode:"math",createAtom:e=>{let i=f({},e),r=e.args;return i.hasBarLine=!0,i.continuousFraction=!0,"r"===r[0]&&(i.align="right"),"l"===r[0]&&(i.align="left"),new lv(r[1]?et(r[1]):[new nJ],r[2]?et(r[2]):[new nJ],i)},serialize:(e,i)=>{let r=e.aboveToLatex(i),a=e.belowToLatex(i);return og(e.command,r,a)}}),ex(["brace","brack"],"",{infix:!0,createAtom:e=>new lv(et(e.args[0]),et(e.args[1]),g(f({},e),{hasBarLine:!1,leftDelim:"\\brace"===e.command?"\\lbrace":"\\lbrack",rightDelim:"\\brace"===e.command?"\\rbrace":"\\rbrack"})),serialize:(e,i)=>of([e.aboveToLatex(i),e.command,e.belowToLatex(i)])}),ex(["over","atop","choose"],"",{infix:!0,createAtom:e=>{let i,r,a=e.args;return"\\choose"===e.command&&(i="(",r=")"),new lv(et(a[0]),et(a[1]),g(f({},e),{hasBarLine:"\\over"===e.command,leftDelim:i,rightDelim:r}))},serialize:(e,i)=>of([e.aboveToLatex(i),e.command,e.belowToLatex(i)])}),ex(["overwithdelims","atopwithdelims"],"{numer:auto}{denom:auto}{left-delim:delim}{right-delim:delim}",{infix:!0,createAtom:e=>{var i,r;let a=e.args;return new lv(et(a[0]),et(a[1]),g(f({},e),{leftDelim:null!=(i=a[2])?i:".",rightDelim:null!=(r=a[3])?r:".",hasBarLine:!1}))},serialize:(e,i)=>`${e.aboveToLatex(i)} ${e.command}${e.leftDelim}${e.rightDelim}${e.belowToLatex(i)}`}),ex("pdiff","{numerator}{denominator}",{ifMode:"math",createAtom:e=>new lv(et(e.args[0]),et(e.args[1]),g(f({},e),{hasBarLine:!0,numerPrefix:"∂",denomPrefix:"∂"})),serialize:(e,i)=>of([e.aboveToLatex(i),e.command,e.belowToLatex(i)])}),ex(["sum","prod","bigcup","bigcap","coprod","bigvee","bigwedge","biguplus","bigotimes","bigoplus","bigodot","bigsqcup","intop"],"",{ifMode:"math",createAtom:e=>new lk({coprod:"∐",bigvee:"⋁",bigwedge:"⋀",biguplus:"⨄",bigcap:"⋂",bigcup:"⋃",intop:"∫",prod:"∏",sum:"∑",bigotimes:"⨂",bigoplus:"⨁",bigodot:"⨀",bigsqcup:"⨆",smallint:"∫"}[e.command.slice(1)],g(f({},e),{limits:"auto",variant:"main"}))}),ex("smallint","",{ifMode:"math",createAtom:e=>new lO("∫",g(f({},e),{limits:"adjacent",variant:"main"}))});var lU={int:"∫",iint:"∬",iiint:"∭",iiiint:"⨌",oint:"∮",oiint:"∯",oiiint:"∰",intclockwise:"∱",varointclockwise:"∲",ointctrclockwise:"∳",intctrclockwise:"⨑",sqcup:"⊔",sqcap:"⊓",uplus:"⊎",wr:"≀",amalg:"⨿",Cap:"⋒",Cup:"⋓",doublecap:"⋒",doublecup:"⋓"};function lJ(e,i){var r,a;e.skipFiller();let o=e.scanLiteralGroup();if(!o){let i=e.peek();null!=i&&i.startsWith("\\")&&(o=i,e.next())}let n=null!=(a=null==(r=e.scanArgument("string"))?void 0:r.trim())?a:"",l=(o.startsWith("\\")?o.slice(1):o).trim();return l&&n&&e.defineLocalMacro(l,{def:i?`\\operatorname*{${n}}`:`\\operatorname{${n}}`,args:0,captureSelection:!1}),[o,n]}function lX(e){return new oG({type:"mord",mode:"math",command:e.command,value:"",args:e.args,style:e.style})}function lG(e,i){var r,a,o,n;let l=null!=(a=null==(r=e.args)?void 0:r[0])?a:"",s=null!=(n=null==(o=e.args)?void 0:o[1])?n:"",c=l.startsWith("\\")?l:`\\${l}`;return i?`\\DeclareMathOperator*{${c}}{${s}}`:`\\DeclareMathOperator{${c}}{${s}}`}ex(Object.keys(lU),"",{ifMode:"math",createAtom:e=>{let i=lU[e.command.slice(1)];return new lk(i,g(f({},e),{limits:"adjacent",variant:{"⋒":"ams","⋓":"ams"}[i]}))}}),ex(["Re","Im"],"",{ifMode:"math",createAtom:e=>new lO({"\\Re":"ℜ","\\Im":"ℑ"}[e.command],g(f({},e),{limits:"adjacent",isFunction:!0,variant:"fraktur"}))}),ex("middle","{:delim}",{ifMode:"math",createAtom:e=>{var i;return new lp(g(f({},e),{delim:null!=(i=e.args[0])?i:"|",size:1}))}}),ex("the","{:value}",{createAtom:e=>new oG(g(f({},e),{captureSelection:!0,verbatimLatex:null})),render:(e,i)=>{var r;let a=new oW({parent:i},e.style),o="";return e.isSelected&&(o+=" ML__selected"),new oE((null!=(r=oF(a.evaluate(e.args[0])))?r:"").split("").map(i=>new oE(i,{type:"ord",classes:o,mode:e.mode,isSelected:e.isSelected,style:f({variant:"main"},e.style)})),{type:"lift",style:e.style,caret:e.caret,isSelected:e.isSelected,classes:o}).wrap(a)},serialize:e=>{var i;return`\\the${null!=(i=oF(e.args[0]))?i:"\\relax"}`}}),ex("blank","{body:auto}",{ifMode:"math",isFunction:!0,createAtom:e=>new lP(et(e.args[0]),e)}),ex("DeclareMathOperator","",{ifMode:"math",parse:e=>lJ(e,!1),createAtom:lX,render:()=>null,serialize:e=>lG(e,!1)}),ex("DeclareMathOperator*","",{ifMode:"math",parse:e=>lJ(e,!0),createAtom:lX,render:()=>null,serialize:e=>lG(e,!0)}),ex("mathtip","{:auto}{:math}",{createAtom:e=>new l$(g(f({},e),{body:et(e.args[0]),tooltip:et(e.args[1]),content:"math"})),serialize:(e,i)=>i.skipStyles?e.bodyToLatex(i):`\\mathtip{${e.bodyToLatex(i)}}{${oG.serialize([e.tooltip],g(f({},i),{defaultMode:"math"}))}}`}),ex("texttip","{:auto}{:text}",{createAtom:e=>new l$(g(f({},e),{body:et(e.args[0]),tooltip:et(e.args[1]),content:"text"})),serialize:(e,i)=>i.skipStyles?e.bodyToLatex(i):`\\texttip{${e.bodyToLatex(i)}}{${oG.serialize([e.tooltip],g(f({},i),{defaultMode:"text"}))}}`}),ex("error","{:math}",{createAtom:e=>new oG(g(f({},e),{body:et(e.args[0])})),serialize:(e,i)=>`\\error{${e.bodyToLatex(i)}}`,render:(e,i)=>e.createBox(i,{classes:"ML__error"})}),ex("ensuremath","{:math}",{createAtom:e=>new oG(g(f({},e),{body:et(e.args[0])})),serialize:(e,i)=>`${e.command}{${e.bodyToLatex(g(f({},i),{defaultMode:"math"}))}}`}),ex("color","{:value}",{applyStyle:(e,i,r,a)=>{var o,n;return g(f({},e),{verbatimColor:null!=(o=oF(r[0]))?o:void 0,color:a.toColor(null!=(n=r[0])?n:{string:"red"})})}}),ex("textcolor","{:value}{content:auto*}",{applyStyle:(e,i,r,a)=>{var o,n;return g(f({},e),{verbatimColor:null!=(o=oF(r[0]))?o:void 0,color:a.toColor(null!=(n=r[0])?n:{string:"red"})})}}),ex("boxed","{content:math}",{createAtom:e=>new n5(g(f({},e),{body:et(e.args[0]),framecolor:{string:"black"}}))}),ex("colorbox","{:value}{:text*}",{applyStyle:(e,i,r,a)=>{var o,n;return g(f({},e),{verbatimBackgroundColor:null!=(o=oF(r[0]))?o:void 0,backgroundColor:a.toBackgroundColor(null!=(n=r[0])?n:{string:"yellow"})})}}),ex("fcolorbox","{frame-color:value}{background-color:value}{content:text}",{applyMode:"text",createAtom:e=>{var i,r;return new n5(g(f({},e),{body:et(e.args[2]),framecolor:null!=(i=e.args[0])?i:{string:"blue"},backgroundcolor:null!=(r=e.args[1])?r:{string:"yellow"}}))},serialize:(e,i)=>{var r,a;return i.skipStyles?e.bodyToLatex(g(f({},i),{defaultMode:"text"})):og(e.command,null!=(r=oF(e.framecolor))?r:"",null!=(a=oF(e.backgroundcolor))?a:"",e.bodyToLatex(g(f({},i),{defaultMode:"text"})))}}),ex("bbox","[:bbox]{body:auto}",{createAtom:e=>{var i;let r=e.args[0],a=et(e.args[1]);return new n5(r?g(f({},e),{body:a,padding:r.padding,border:r.border,backgroundcolor:null!=(i=r.backgroundcolor)?i:void 0}):g(f({},e),{body:a}))},serialize:(e,i)=>{var r,a;if(i.skipStyles)return e.bodyToLatex(i);let o=e.command;if(Number.isFinite(e.padding)||void 0!==e.border||void 0!==e.backgroundcolor){let i=[];e.padding&&i.push(null!=(r=oF(e.padding))?r:""),e.border&&i.push(`border: ${e.border}`),e.backgroundcolor&&i.push(null!=(a=oF(e.backgroundcolor))?a:""),o+=`[${i.join(",")}]`}return og(o,e.bodyToLatex(i))}}),ex(["displaystyle","textstyle","scriptstyle","scriptscriptstyle"],"{:rest}",{createAtom:e=>new oG(g(f({},e),{body:et(e.args[0])})),render:(e,i)=>{let r=new oW({parent:i,mathstyle:e.command.slice(1)},e.style),a=oG.createBox(r,e.body,{type:"lift"});return e.caret&&(a.caret=e.caret),e.bind(i,a)},serialize:(e,i)=>i.skipStyles?e.bodyToLatex(i):`{${of([e.command,e.bodyToLatex(i)])}}`}),ex(["tiny","scriptsize","footnotesize","small","normalsize","large","Large","LARGE","huge","Huge"],"",{applyStyle:(e,i)=>g(f({},e),{fontSize:{"\\tiny":1,"\\scriptsize":2,"\\footnotesize":3,"\\small":4,"\\normalsize":5,"\\large":6,"\\Large":7,"\\LARGE":8,"\\huge":9,"\\Huge":10}[i]})}),ex("selectfont","",{ifMode:"text",applyStyle:e=>e}),ex("bf","{:rest*}",{applyStyle:e=>g(f({},e),{fontSeries:"b",fontShape:"n",fontFamily:"roman"})}),ex(["boldsymbol","bm","bold"],"{:math*}",{applyMode:"math",applyStyle:e=>g(f({},e),{variantStyle:"bold"})}),ex("bfseries","{:rest*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontSeries:"b"})}),ex("mdseries","{:rest*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontSeries:"m"})}),ex("upshape","{:rest*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontShape:"n"})}),ex("slshape","{:rest*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontShape:"sl"})}),ex("scshape","{:rest*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontShape:"sc"})}),ex("textbf","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontSeries:"b"})}),ex("textmd","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontSeries:"m"})}),ex("textup","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontShape:"n"})}),ex("textnormal","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontShape:"n",fontSeries:"m"})}),ex("textsl","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontShape:"sl"})}),ex("textit","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontShape:"it"})}),ex("textsc","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontShape:"sc"})}),ex("textrm","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontFamily:"roman"})}),ex("textsf","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontFamily:"sans-serif"})}),ex("texttt","{:text*}",{applyMode:"text",applyStyle:e=>g(f({},e),{fontFamily:"monospace"})}),ex("mathbf","{:math*}",{applyMode:"math",applyStyle:e=>g(f({},e),{variant:"normal",variantStyle:"bold"})}),ex("mathit","{:math*}",{applyMode:"math",applyStyle:e=>g(f({},e),{variant:"main",variantStyle:"italic"})}),ex("mathnormal","{:math*}",{applyMode:"math",applyStyle:e=>g(f({},e),{variant:"normal",variantStyle:"italic"})}),ex("mathbfit","{:math*}",{applyMode:"math",applyStyle:e=>g(f({},e),{variant:"main",variantStyle:"bolditalic"})}),ex("mathrm","{:math*}",{applyMode:"math",applyStyle:e=>g(f({},e),{variant:"normal",variantStyle:"up"})}),ex("mathsf","{:math*}",{applyMode:"math",applyStyle:e=>g(f({},e),{variant:"sans-serif",variantStyle:"up"})}),ex("mathtt","{:math*}",{applyMode:"math",applyStyle:e=>g(f({},e),{variant:"monospace",variantStyle:"up"})}),ex("it","{:rest*}",{applyStyle:e=>g(f({},e),{fontSeries:"m",fontShape:"it",fontFamily:"roman",variantStyle:"italic"})}),ex("rmfamily","{:rest*}",{applyStyle:e=>g(f({},e),{fontFamily:"roman"})}),ex("sffamily","{:rest*}",{applyStyle:e=>g(f({},e),{fontFamily:"sans-serif"})}),ex("ttfamily","{:rest*}",{applyStyle:e=>g(f({},e),{fontFamily:"monospace"})}),ex(["Bbb","mathbb"],"{:math*}",{applyStyle:e=>g(f({},e),{variant:"double-struck",variantStyle:lF(e.variantStyle)})}),ex(["frak","mathfrak"],"{:math*}",{applyStyle:e=>g(f({},e),{variant:"fraktur",variantStyle:lF(e.variantStyle)})}),ex("mathcal","{:math*}",{applyStyle:e=>g(f({},e),{variant:"calligraphic",variantStyle:lF(e.variantStyle)})}),ex("mathscr","{:math*}",{applyStyle:e=>g(f({},e),{variant:"script",variantStyle:lF(e.variantStyle)})}),ex(["mbox","hbox"],"{:text}",{ifMode:"math",createAtom:e=>new oG(g(f({},e),{type:"mord",body:et(e.args[0]),mode:"math"})),serialize:(e,i)=>{var r;return og(null!=(r=e.command)?r:"\\mbox",e.bodyToLatex(g(f({},i),{defaultMode:"text"})))}}),ex("text","{:text}",{ifMode:"math",applyMode:"text"}),ex(["class","htmlClass"],"{name:string}{content:auto*}",{createAtom:e=>new oG(g(f({},e),{type:"mord",body:et(e.args[1])})),serialize:(e,i)=>!e.args[0]||i.skipStyles?e.bodyToLatex(i):`${e.command}{${e.args[0]}}{${e.bodyToLatex(i)}}`,render:(e,i)=>{var r;return e.createBox(i,{classes:null!=(r=e.args[0])?r:"",boxType:"lift"})}}),ex(["cssId","htmlId"],"{id:string}{content:auto*}",{createAtom:e=>new oG(g(f({},e),{type:"mord",body:et(e.args[1])})),serialize:(e,i)=>{var r;return!(null!=(r=e.args)&&r[0])||i.skipStyles?e.bodyToLatex(i):`${e.command}{${e.args[0]}}{${e.bodyToLatex(i)}}`},render:(e,i)=>{var r;let a=e.createBox(i);return a.cssId=null!=(r=e.args[0])?r:"",a}}),ex("htmlData","{data:string}{content:auto*}",{createAtom:e=>new oG(g(f({},e),{type:"mord",body:et(e.args[1])})),serialize:(e,i)=>{var r;return!(null!=(r=e.args)&&r[0])||i.skipStyles?e.bodyToLatex(i):`\\htmlData{${e.args[0]}}{${e.bodyToLatex(i)}}`},render:(e,i)=>{var r;let a=e.createBox(i);return a.htmlData=null!=(r=e.args[0])?r:"",a}}),ex(["style","htmlStyle"],"{data:string}{content:auto*}",{createAtom:e=>new oG(g(f({},e),{type:"mord",body:et(e.args[1])})),serialize:(e,i)=>{var r;return!(null!=(r=e.args)&&r[0])||i.skipStyles?e.bodyToLatex(i):`${e.command}{${e.args[0]}}{${e.bodyToLatex(i)}}`},render:(e,i)=>{var r;let a=e.createBox(i);return a.htmlStyle=null!=(r=e.args[0])?r:"",a}}),ex("href","{url:string}{content:auto*}",{createAtom:e=>new oG(g(f({},e),{type:"mord",body:et(e.args[1])})),render:(e,i)=>{var r;let a=e.createBox(i),o=null!=(r=e.args[0])?r:"";return o&&(a.htmlData=`href=${o}`),a}}),ex("em","{:rest}",{createAtom:e=>new oG(g(f({},e),{body:et(e.args[0])})),serialize:(e,i)=>i.skipStyles?e.bodyToLatex(i):`{\\em ${e.bodyToLatex(i)}}`,render:(e,i)=>e.createBox(i,{classes:"ML__emph",boxType:"lift"})}),ex("emph","{:auto}",{createAtom:e=>new oG(g(f({},e),{body:et(e.args[1])})),serialize:(e,i)=>i.skipStyles?e.bodyToLatex(i):`\\emph{${e.bodyToLatex(i)}}`,render:(e,i)=>e.createBox(i,{classes:"ML__emph",boxType:"lift"})});var lZ={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}};ex(["bigl","Bigl","biggl","Biggl","bigr","Bigr","biggr","Biggr","bigm","Bigm","biggm","Biggm","big","Big","bigg","Bigg"],"{:delim}",{createAtom:e=>{var i;return new lm(g(f({},e),{delim:null!=(i=e.args[0])?i:".",size:lZ[e.command].size,delimType:lZ[e.command].mclass}))},serialize:(e,i)=>of([e.command,/^[a-zA-Z]/.test(e.value)?`{${e.value}}`:e.value])}),ex(["hspace","hspace*"],"{width:value}",{createAtom:e=>{var i;return new lC(g(f({},e),{width:null!=(i=e.args[0])?i:{dimension:0}}))}}),ex(["mkern","kern","mskip","hskip","mspace"],"{width:value}",{createAtom:e=>{var i;return new lC(g(f({},e),{width:null!=(i=e.args[0])?i:{dimension:0}}))}}),ex("\\","",{createAtom:e=>new lR(e)}),ex("mathchoice","{:math}{:math}{:math}{:math}",{createAtom:e=>new oG(e),render:(e,i)=>{let r=0,a=i.mathstyle.id;(5===a||4===a)&&(r=1),(3===a||2===a)&&(r=2),(1===a||0===a)&&(r=3);let o=et(e.args[r]);return oG.createBox(i,o)},serialize:(e,i)=>`\\mathchoice{${oG.serialize(e.args[0],i)}}{${oG.serialize(e.args[1],i)}}{${oG.serialize(e.args[2],i)}}{${oG.serialize(e.args[3],i)}}`}),ex("mathop","{:auto}",{createAtom:e=>new oG(g(f({},e),{type:"mop",body:et(e.args[0]),limits:"over-under",isFunction:!0,captureSelection:!0})),render:(e,i)=>{var r;let a=oG.createBox(i,e.body);if(e.superscript||e.subscript){let o=null!=(r=e.subsupPlacement)?r:"auto";a="over-under"===o||"auto"===o&&i.isDisplayStyle?e.attachLimits(i,{base:a}):e.attachSupsub(i,{base:a})}return e.caret&&(a.caret=e.caret),new oE(e.bind(i,a),{type:"op",isSelected:e.isSelected,classes:"ML__op-group"})},serialize:(e,i)=>{let r=[og(e.command,e.bodyToLatex(i))];return e.explicitSubsupPlacement&&("over-under"===e.subsupPlacement&&r.push("\\limits"),"adjacent"===e.subsupPlacement&&r.push("\\nolimits"),"auto"===e.subsupPlacement&&r.push("\\displaylimits")),r.push(e.supsubToLatex(i)),of(r)}}),ex(["mathbin","mathrel","mathopen","mathclose","mathpunct","mathord","mathinner"],"{:auto}",{createAtom:e=>new oG(g(f({},e),{type:{"\\mathbin":"mbin","\\mathrel":"mrel","\\mathopen":"mopen","\\mathclose":"mclose","\\mathpunct":"mpunct","\\mathord":"mord","\\mathinner":"minner"}[e.command],body:et(e.args[0])}))}),ex(["operatorname","operatorname*"],"{operator:math}",{createAtom:e=>{let i=et(e.args[0]).map(e=>{var i;return"first"!==e.type&&(e.type="mord",e.value=null!=(i=({"∗":"*","−":"-"})[e.value])?i:e.value,e.isFunction=!1,e.style.variant||e.style.variantStyle||(e.style.variant="main",e.style.variantStyle="up")),e});return new oG(g(f({},e),{type:"mop",body:i,isFunction:!0,limits:"\\operatorname"===e.command?"adjacent":"over-under"}))},render:(e,i)=>{var r;let a=oG.createBox(i,e.body);if(e.superscript||e.subscript){let o=null!=(r=e.subsupPlacement)?r:"auto";a="over-under"===o||"auto"===o&&i.isDisplayStyle?e.attachLimits(i,{base:a}):e.attachSupsub(i,{base:a})}return e.caret&&(a.caret=e.caret),new oE(e.bind(i,a),{type:"op",isSelected:e.isSelected,classes:"ML__op-group"})},serialize:(e,i)=>{let r=[og(e.command,e.bodyToLatex(i))];return e.explicitSubsupPlacement&&("over-under"===e.subsupPlacement&&r.push("\\limits"),"adjacent"===e.subsupPlacement&&r.push("\\nolimits"),"auto"===e.subsupPlacement&&r.push("\\displaylimits")),r.push(e.supsubToLatex(i)),of(r)}}),ex(["char","unicode"],"{charcode:value}",{createAtom:e=>new oG(g(f({},e),{type:"text"===e.mode?"text":"mord"})),serialize:e=>{var i;return`${e.command}${oF(null!=(i=e.args[0])?i:{number:10067,base:"hexadecimal"})}`},render:(e,i)=>{let r=i.evaluate(e.args[0]);return r&&"number"in r||(r={number:10067,base:"hexadecimal"}),e.value=String.fromCodePoint(r.number),e.createBox(i)}}),ex("rule","[raise:value]{width:value}{thickness:value}",{createAtom:e=>new oG(e),render:(e,i)=>{var r,a,o;let n=new oW({parent:i,mathstyle:"textstyle"},e.style),l=n.toEm(null!=(r=e.args[0])?r:{dimension:0}),s=n.toEm(null!=(a=e.args[1])?a:{dimension:10}),c=n.toEm(null!=(o=e.args[2])?o:{dimension:10}),d=new oE(null,{classes:"ML__rule",type:"ord"});return d.width=s,d.height=c+l,d.depth=-l,d.setStyle("border-right-width",s,"em"),d.setStyle("border-top-width",c,"em"),d.setStyle("border-color",e.style.color),d.setStyle("vertical-align",l,"em"),e.isSelected&&d.setStyle("opacity","50%"),e.bind(n,d),e.caret&&(d.caret=e.caret),d.wrap(i)},serialize:e=>`\\rule${e.args[0]?`[${oF(e.args[0])}]`:""}{${oF(e.args[1])}}{${oF(e.args[2])}}`}),ex(["overline","underline"],"{:auto}",{createAtom:e=>new oG(g(f({},e),{body:et(e.args[0])})),render:(e,i)=>{let r,a=e.command.substring(1),o=new oW({parent:i,mathstyle:"cramp"},e.style),n=oG.createBox(o,e.body);if(!n)return null;let l=o.metrics.defaultRuleThickness/o.scalingFactor,s=new oE(null,{classes:a+"-line"});return s.height=l,s.maxFontSize=1.125*l*o.scalingFactor,r=new oB("overline"===a?{shift:0,children:[{box:n},3*l,{box:s},l]}:{top:n.height,children:[l,{box:s},3*l,{box:n}]}),e.caret&&(r.caret=e.caret),new oE(r,{classes:a,type:"ignore"})}}),ex("overset","{:auto}{base:auto}",{createAtom:e=>{let i=et(e.args[1]);return new lS(g(f({},e),{above:et(e.args[0]),body:i,skipBoundary:!1,boxType:oL(i)}))},serialize:(e,i)=>og(e.command,e.aboveToLatex(i),e.bodyToLatex(i))}),ex("underset","{:auto}{base:auto}",{createAtom:e=>{let i=et(e.args[1]);return new lS(g(f({},e),{below:et(e.args[0]),body:i,skipBoundary:!1,boxType:oL(i)}))},serialize:(e,i)=>og(e.command,e.belowToLatex(i),e.bodyToLatex(i))}),ex("overunderset","{above:auto}{below:auto}{base:auto}",{createAtom:e=>{let i=et(e.args[2]);return new lS(g(f({},e),{above:et(e.args[0]),below:et(e.args[1]),body:i,skipBoundary:!1,boxType:oL(i)}))},serialize:(e,i)=>og(e.command,e.belowToLatex(i),e.bodyToLatex(i))}),ex(["stackrel","stackbin"],"[below:auto]{above:auto}{base:auto}",{createAtom:e=>new lS(g(f({},e),{body:et(e.args[2]),above:et(e.args[1]),below:et(e.args[0]),skipBoundary:!1,boxType:"\\stackrel"===e.command?"rel":"bin"})),serialize:(e,i)=>og(e.command,e.aboveToLatex(i),e.bodyToLatex(i))}),ex("smash","[:string]{:auto}",{createAtom:e=>{var i,r,a,o;return new lL(g(f({},e),{body:et(e.args[1]),smashHeight:null==(r=null==(i=e.args[0])?void 0:i.includes("t"))||r,smashDepth:null==(o=null==(a=e.args[0])?void 0:a.includes("b"))||o}))}}),ex("vphantom","{:auto}",{createAtom:e=>new lL(g(f({},e),{body:et(e.args[0]),isInvisible:!0,smashWidth:!0}))}),ex("hphantom","{:auto}",{createAtom:e=>new lL(g(f({},e),{body:et(e.args[0]),isInvisible:!0,smashHeight:!0,smashDepth:!0}))}),ex("phantom","{:auto}",{createAtom:e=>new lL(g(f({},e),{body:et(e.args[0]),isInvisible:!0}))}),ex("mathstrut","",{createAtom:e=>new lL(g(f({},e),{body:[new oG({value:"("})],isInvisible:!0}))}),ex("not","{:math}",{createAtom:e=>{let i=et(e.args[0]);return new oG(0===i.length?g(f({},e),{type:"mrel",value:""}):g(f({},e),{body:[new lM(g(f({},e),{body:"",align:"right"})),...i],captureSelection:!0}))},serialize:(e,i)=>{let r=e.args[0],a=r&&"object"==typeof r&&"group"in r;return""!==e.value?a?`\\not{${oG.serialize(r.group,i)}}`:`\\not${oG.serialize(r,i)}`:a?"\\not{}":"\\not"},render:(e,i)=>{if(e.value)return e.createBox(i);let r=e.args[0]&&"object"==typeof e.args[0]&&"group"in e.args[0]?"ord":oL(et(e.args[0])),a=oG.createBox(i,e.body,{type:r});return e.caret&&(a.caret=e.caret),e.bind(i,a)}}),ex(["ne","neq"],"",{createAtom:e=>new oG(g(f({},e),{type:"mrel",body:[new lM(g(f({},e),{body:"",align:"right",boxType:"rel"})),new oG(g(f({},e),{value:"="}))],captureSelection:!0})),serialize:e=>e.command}),ex("rlap","{:auto}",{createAtom:e=>new lM(g(f({},e),{body:et(e.args[0]),align:"right"}))}),ex("llap","{:auto}",{createAtom:e=>new lM(g(f({},e),{body:et(e.args[0]),align:"left"}))}),ex("mathrlap","{:math}",{createAtom:e=>new lM(g(f({},e),{body:et(e.args[0]),align:"right"}))}),ex("mathllap","{:math}",{createAtom:e=>new lM(g(f({},e),{body:et(e.args[0]),align:"left"}))}),ex("clap","{:auto}",{createAtom:e=>new lM(g(f({},e),{body:et(e.args[0]),align:"center"}))}),ex("mathclap","{:math}",{createAtom:e=>new lM(g(f({},e),{body:et(e.args[0]),align:"center"}))}),ex("raisebox","{:value}{:text}",{createAtom:e=>{var i;return new n5(g(f({},e),{body:et(e.args[1]),padding:{dimension:0},offset:null!=(i=e.args[0])?i:{dimension:0}}))},serialize:(e,i)=>{var r;return og("\\raisebox",null!=(r=oF(e.offset))?r:"0pt",e.bodyToLatex(i))}}),ex("raise","{:value}{:auto}",{createAtom:e=>{var i;return new n5(g(f({},e),{body:et(e.args[1]),padding:{dimension:0},offset:null!=(i=e.args[0])?i:{dimension:0}}))},serialize:(e,i)=>{var r;return og("\\raise",null!=(r=oF(e.offset))?r:"0pt",e.bodyToLatex(i))}}),ex("lower","{:value}{:auto}",{createAtom:e=>{var i;return new n5(g(f({},e),{body:et(e.args[1]),padding:{dimension:0},offset:null!=(i=oV(e.args[0],-1))?i:{dimension:0}}))},serialize:(e,i)=>{var r,a;return og("\\lower",null!=(a=oF(oV(null!=(r=e.offset)?r:{dimension:0},-1)))?a:"0pt",e.bodyToLatex(i))}}),eh("0123456789/@.?!"),ep(65,90),ep(97,122),eh([["\\forall",8704],["\\exists",8707],["\\nexists",8708,"mord","ams"],["\\mid",8739,"mrel"],["\\top",8868],["\\bot",8869]]),eh([["\\#",35],["\\&",38],["\\parallelogram",9649],["\\spadesuit",9824],["\\heartsuit",9825],["\\diamondsuit",9826],["\\clubsuit",9827],["\\flat",9837],["\\natural",9838],["\\sharp",9839]]),eh([["\\backslash",92],["\\nabla",8711],["\\partial",8706],["\\ell",8467],["\\hbar",8463],["\\pounds",163],["\\euro",8364]]),eh([["\\rightarrow",8594],["\\to",8594],["\\leftarrow",8592],["\\gets",8592],["\\Rightarrow",8658],["\\Leftarrow",8656],["\\longrightarrow",10230],["\\longleftarrow",10229],["\\Longrightarrow",10233],["\\implies",10233],["\\Longleftarrow",10232],["\\impliedby",10232],["\\longleftrightarrow",10231],["\\biconditional",10231],["\\Longleftrightarrow",10234],["\\mapsto",8614],["\\longmapsto",10236],["\\uparrow",8593],["\\downarrow",8595],["\\Uparrow",8657],["\\Downarrow",8659],["\\updownarrow",8597],["\\Updownarrow",8661],["\\hookrightarrow",8618],["\\hookleftarrow",8617],["\\rightharpoonup",8640],["\\leftharpoonup",8636],["\\rightharpoondown",8641],["\\leftharpoondown",8637],["\\searrow",8600],["\\nearrow",8599],["\\swarrow",8601],["\\nwarrow",8598],["\\originalof",8886],["\\laplace",8886],["\\imageof",8887],["\\Laplace",8887]],"mrel"),eh([["\\mapsfrom",8612,"mrel"],["\\Mapsfrom",10502,"mrel"],["\\MapsTo",10503,"mrel"],["\\Yup",8516,"mord"],["\\lightning",8623,"mrel"],["\\leftarrowtriangle",8701,"mrel"],["\\rightarrowtriangle",8702,"mrel"],["\\leftrightarrowtriangle",8703,"mrel"],["\\boxdot",8865,"mbin"],["\\bigtriangleup",9651,"mbin"],["\\bigtriangledown",9661,"mbin"],["\\boxbar",9707,"mbin"],["\\Lbag",10181,"mopen"],["\\Rbag",10182,"mclose"],["\\llbracket",10214,"mopen"],["\\rrbracket",10215,"mclose"],["\\longmapsfrom",10235,"mrel"],["\\Longmapsfrom",10237,"mrel"],["\\Longmapsto",10238,"mrel"],["\\boxslash",10692,"mbin"],["\\boxbslash",10693,"mbin"],["\\boxast",10694,"mbin"],["\\boxcircle",10695,"mbin"],["\\boxbox",10696,"mbin"],["\\fatsemi",10783,"mop"],["\\leftslice",10918,"mrel"],["\\rightslice",10919,"mrel"],["\\interleave",10996,"mbin"],["\\biginterleave",11004,"mop"],["\\sslash",11005,"mbin"],["\\talloblong",11006,"mbin"]]),eh([["\\lbrace",123,"mopen"],["\\rbrace",125,"mclose"],["\\lparen",40,"mopen"],["\\rparen",41,"mclose"],["\\langle",10216,"mopen"],["\\rangle",10217,"mclose"],["\\lfloor",8970,"mopen"],["\\rfloor",8971,"mclose"],["\\lceil",8968,"mopen"],["\\rceil",8969,"mclose"],["\\vert",8739],["\\lvert",8739,"mopen"],["\\rvert",8739,"mclose"],["\\|",8741],["\\Vert",8741],["\\mVert",8741],["\\lVert",8741,"mopen"],["\\rVert",8741,"mclose"],["\\lbrack",91,"mopen"],["\\rbrack",93,"mclose"],["\\{",123,"mopen"],["\\}",125,"mclose"],["(",40,"mopen"],[")",41,"mclose"],["[",91,"mopen"],["]",93,"mclose"],["\\ulcorner",9484,"mopen","ams"],["\\urcorner",9488,"mclose","ams"],["\\llcorner",9492,"mopen","ams"],["\\lrcorner",9496,"mclose","ams"],["\\lgroup",10222,"mopen"],["\\rgroup",10223,"mclose"],["\\lmoustache",9136,"mopen"],["\\rmoustache",9137,"mclose"]]),eh([["\\dashrightarrow",8674],["\\dashleftarrow",8672],["\\Rrightarrow",8667],["\\Lleftarrow",8666],["\\leftrightarrows",8646],["\\rightleftarrows",8644],["\\curvearrowright",8631],["\\curvearrowleft",8630],["\\rightrightarrows",8649],["\\leftleftarrows",8647],["\\upuparrows",8648],["\\downdownarrows",8650],["\\vartriangle",9651],["\\triangleq",8796],["\\vartriangleleft",8882],["\\trianglelefteq",8884],["\\ntriangleleft",8938],["\\ntrianglelefteq",8940],["\\vartriangleright",8883],["\\trianglerighteq",8885],["\\ntriangleright",8939],["\\ntrianglerighteq",8941],["\\blacktriangleleft",9664],["\\blacktriangleright",9654],["\\leftarrowtail",8610],["\\rightarrowtail",8611],["\\looparrowright",8620],["\\looparrowleft",8619],["\\twoheadleftarrow",8606],["\\twoheadrightarrow",8608],["\\twoheadrightarrowtail",10518],["\\rightleftharpoons",8652],["\\leftrightharpoons",8651],["\\Rsh",8625],["\\Lsh",8624],["\\circlearrowright",8635],["\\circlearrowleft",8634],["\\restriction",8638],["\\upharpoonright",8638],["\\upharpoonleft",8639],["\\downharpoonright",8642],["\\downharpoonleft",8643],["\\rightsquigarrow",8669],["\\leadsto",8669],["\\leftrightsquigarrow",8621],["\\multimap",8888],["\\nleftarrow",8602],["\\nrightarrow",8603],["\\nRightarrow",8655],["\\nLeftarrow",8653],["\\nleftrightarrow",8622],["\\nLeftrightarrow",8654],["\\nvrightarrow",8696],["\\nvtwoheadrightarrow",10496],["\\nvrightarrowtail",10516],["\\nvtwoheadrightarrowtail",10519],["\\shortparallel",8741],["\\nless",8814],["\\nleqslant",57360],["\\lneq",10887],["\\lneqq",8808],["\\nleqq",57361],["\\lvertneqq",57356],["\\lnsim",8934],["\\lnapprox",10889],["\\nprec",8832],["\\npreceq",8928],["\\precnsim",8936],["\\precnapprox",10937],["\\nsim",8769],["\\nshortmid",57350],["\\nmid",8740],["\\nvdash",8876],["\\nvDash",8877],["\\ngtr",8815],["\\ngeqslant",57359],["\\ngeqq",57358],["\\gneq",10888],["\\gneqq",8809],["\\gvertneqq",57357],["\\gnsim",8935],["\\gnapprox",10890],["\\nsucc",8833],["\\nsucceq",8929],["\\succnsim",8937],["\\succnapprox",10938],["\\ncong",8774],["\\nshortparallel",57351],["\\nparallel",8742],["\\nVDash",8879],["\\nsupseteqq",57368],["\\supsetneq",8843],["\\varsupsetneq",57371],["\\supsetneqq",10956],["\\varsupsetneqq",57369],["\\nVdash",8878],["\\precneqq",10933],["\\succneqq",10934],["\\nsubseteqq",57366],["\\leqslant",10877],["\\geqslant",10878],["\\gtrsim",8819],["\\approxeq",8778],["\\thickapprox",8776],["\\lessapprox",10885],["\\gtrapprox",10886],["\\precapprox",10935],["\\succapprox",10936],["\\thicksim",8764],["\\succsim",8831],["\\precsim",8830],["\\backsim",8765],["\\eqsim",8770],["\\backsimeq",8909],["\\lesssim",8818],["\\nleq",8816],["\\ngeq",8817],["\\smallsmile",8995],["\\smallfrown",8994],["\\leqq",8806],["\\eqslantless",10901],["\\lll",8920],["\\lessgtr",8822],["\\lesseqgtr",8922],["\\lesseqqgtr",10891],["\\risingdotseq",8787],["\\fallingdotseq",8786],["\\subseteqq",10949],["\\Subset",8912],["\\sqsubset",8847],["\\preccurlyeq",8828],["\\curlyeqprec",8926],["\\vDash",8872],["\\Vvdash",8874],["\\bumpeq",8783],["\\Bumpeq",8782],["\\geqq",8807],["\\eqslantgtr",10902],["\\ggg",8921],["\\gtrless",8823],["\\gtreqless",8923],["\\gtreqqless",10892],["\\supseteqq",10950],["\\Supset",8913],["\\sqsupset",8848],["\\succcurlyeq",8829],["\\curlyeqsucc",8927],["\\Vdash",8873],["\\shortmid",8739],["\\between",8812],["\\pitchfork",8916],["\\varpropto",8733],["\\backepsilon",8717],["\\llless",8920],["\\gggtr",8921],["\\doteqdot",8785],["\\Doteq",8785],["\\eqcirc",8790],["\\circeq",8791],["\\therefore",8756],["\\because",8757]],"mrel","ams"),eh([["+",43],["-",8722],["−",8722],["\\pm",177],["\\mp",8723],["*",8727],["\\times",215],["\\div",247],["\\divides",8739],["\\cdot",8901],["\\cap",8745],["\\cup",8746],["\\setminus",8726],["\\land",8743],["\\wedge",8743],["\\lor",8744],["\\vee",8744],["\\circ",8728],["\\bigcirc",9711],["\\bullet",8729],["\\oplus",8853],["\\ominus",8854],["\\otimes",8855],["\\odot",8857],["\\oslash",8856],["\\bigtriangleup",9651],["\\bigtriangledown",9661],["\\triangleleft",9667],["\\triangleright",9657],["\\And",38],["\\dagger",8224],["\\dag",8224],["\\ddag",8225],["\\ddagger",8225],["\\ast",8727],["\\star",8902],["\\bigstar",9733],["\\diamond",8900]],"mbin"),eh([["\\lhd",8882],["\\rhd",8883],["\\lessdot",8918],["\\gtrdot",8919],["\\ltimes",8905],["\\rtimes",8906],["\\leftthreetimes",8907],["\\rightthreetimes",8908],["\\intercal",8890],["\\dotplus",8724],["\\doublebarwedge",10846],["\\divideontimes",8903],["\\centerdot",8901],["\\smallsetminus",8726],["\\barwedge",8892],["\\veebar",8891],["\\nor",8891],["\\curlywedge",8911],["\\curlyvee",8910],["\\boxminus",8863],["\\boxplus",8862],["\\boxtimes",8864],["\\boxdot",8865],["\\circleddash",8861],["\\circledast",8859],["\\circledcirc",8858],["\\unlhd",8884],["\\unrhd",8885]],"mbin","ams"),eh([["\\surd",8730],["\\S",167],["\\infty",8734],["\\prime",8242],["\\doubleprime",8243],["\\angle",8736],["`",8216],["\\$",36],["\\%",37],["\\_",95],["\\alpha",945],["\\beta",946],["\\gamma",947],["\\delta",948],["\\epsilon",1013],["\\varepsilon",949],["\\zeta",950],["\\eta",951],["\\theta",952],["\\vartheta",977],["\\iota",953],["\\kappa",954],["\\varkappa",1008,"mord","ams"],["\\lambda",955],["\\mu",956],["\\nu",957],["\\xi",958],["\\omicron",111],["\\pi",960],["\\varpi",982],["\\rho",961],["\\varrho",1009],["\\sigma",963],["\\varsigma",962],["\\tau",964],["\\phi",981],["\\varphi",966],["\\upsilon",965],["\\chi",967],["\\psi",968],["\\omega",969],["\\Gamma",915],["\\Delta",916],["\\Theta",920],["\\Lambda",923],["\\Xi",926],["\\Pi",928],["\\Sigma",931],["\\Upsilon",933],["\\Phi",934],["\\Psi",936],["\\Omega",937],["\\digamma",989,"mord","ams"],["\\varkappa",1008,"mord","ams"],["\\coppa",985,"mord","ams"],["\\koppa",985,"mord","ams"],["\\Coppa",984,"mord","ams"],["\\Koppa",984,"mord","ams"],["\\sampi",993,"mord","ams"],["\\Sampi",992,"mord","ams"],["\\emptyset",8709]]),eh([["=",61],["<",60],["\\lt",60],[">",62],["\\gt",62],["\\le",8804],["\\leq",8804],["\\ge",8805],["\\geq",8805],["\\ll",8810],["\\gg",8811],["\\coloneq",8788],["\\coloneqq",8788],["\\colonequals",8788],["\\measeq",8797],["\\eqdef",8798],["\\questeq",8799],[":",58],["\\cong",8773],["\\equiv",8801],["\\prec",8826],["\\preceq",10927],["\\succ",8827],["\\succeq",10928],["\\perp",10178],["\\propto",8733],["\\Colon",8759],["\\smile",8995],["\\frown",8994],["\\sim",8764],["\\doteq",8784],["\\bowtie",8904],["\\Join",8904],["\\asymp",8781],["\\sqsubseteq",8849],["\\sqsupseteq",8850],["\\approx",8776],["\\~",126],["\\leftrightarrow",8596],["\\Leftrightarrow",8660],["\\models",8872],["\\vdash",8866],["\\dashv",8867],["\\roundimplies",10608],["\\in",8712],["\\notin",8713],["\\ni",8715],["\\owns",8715],["\\subset",8834],["\\supset",8835],["\\subseteq",8838],["\\supseteq",8839],["\\differencedelta",8710],["\\mvert",8739],["\\parallel",8741],["\\simeq",8771]],"mrel"),eh([["\\lnot",172],["\\neg",172],["\\triangle",9651],["\\subsetneq",8842],["\\varsubsetneq",57370],["\\subsetneqq",10955],["\\varsubsetneqq",57367],["\\nsubset",8836],["\\nsupset",8837],["\\nsubseteq",8840],["\\nsupseteq",8841]],"mrel","ams"),eh([["\\wp",8472],["\\aleph",8501]]),eh([["\\blacktriangle",9650],["\\hslash",8463],["\\Finv",8498],["\\Game",8513],["\\eth",240],["\\mho",8487],["\\Bbbk",107],["\\yen",165],["\\square",9633],["\\Box",9633],["\\blacksquare",9632],["\\circledS",9416],["\\circledR",174],["\\triangledown",9661],["\\blacktriangledown",9660],["\\checkmark",10003],["\\diagup",9585],["\\measuredangle",8737],["\\sphericalangle",8738],["\\backprime",8245],["\\backdoubleprime",8246],["\\Diamond",9674],["\\lozenge",9674],["\\blacklozenge",10731],["\\varnothing",8709],["\\complement",8705],["\\maltese",10016],["\\beth",8502],["\\daleth",8504],["\\gimel",8503]],"mord","ams"),eh([["\\ ",160],["~",160]],"space"),ex(["!",",",":",";",">","enskip","enspace","quad","qquad","thinspace","negthinspace","medspace","negmedspace","thickspace","negthickspace"],"",{createAtom:e=>new lC(e)}),ex("space","",{createAtom:e=>new lC(e)}),eh([["\\colon",58],["\\cdotp",8901],["\\vdots",8942,"mord"],["\\ldotp",46],[",",44],[";",59]],"mpunct"),eh([["\\cdots",8943],["\\ddots",8945],["\\ldots",8230],["\\dots",8230],["\\mathellipsis",8230]],"minner"),eh([["\\/",47],["|",8739,"mord"],["\\imath",305],["\\jmath",567],["\\degree",176],["'",8242],['"',8221]]);var lY={main:["Main-Regular","ML__cmr"],"main-italic":["Main-Italic","ML__cmr ML__it"],"main-bold":["Main-Bold","ML__cmr ML__bold"],"main-bolditalic":["Main-BoldItalic","ML__cmr ML__bold ML__it"],normal:["Main-Regular","ML__cmr"],"normal-bold":["Main-Bold","ML__mathbf"],"normal-italic":["Math-Italic","ML__mathit"],"normal-bolditalic":["Math-BoldItalic","ML__mathbfit"],roman:["Main-Regular","ML__cmr"],"roman-bold":["Main-Bold","ML__mathbf"],"roman-italic":["Math-Italic","ML__mathit"],"roman-bolditalic":["Math-BoldItalic","ML__mathbfit"],ams:["AMS-Regular","ML__ams"],"ams-bold":["AMS-Regular","ML__ams ML__bold"],"ams-italic":["AMS-Regular","ML__ams ML__it"],"ams-bolditalic":["AMS-Regular","ML__ams ML__bold ML__it"],"sans-serif":["SansSerif-Regular","ML__sans"],"sans-serif-bold":["SansSerif-Regular","ML__sans ML__bold"],"sans-serif-italic":["SansSerif-Regular","ML__sans ML__it"],"sans-serif-bolditalic":["SansSerif-Regular","ML__sans ML__bold ML__it"],calligraphic:["Caligraphic-Regular","ML__cal"],"calligraphic-bold":["Caligraphic-Regular","ML__cal ML__bold"],"calligraphic-italic":["Caligraphic-Regular","ML__cal ML__it"],"calligraphic-bolditalic":["Caligraphic-Regular","ML__cal ML__bold ML__it"],script:["Script-Regular","ML__script"],"script-bold":["Script-Regular","ML__script ML__bold"],"script-italic":["Script-Regular","ML__script ML__it"],"script-bolditalic":["Script-Regular","ML__script ML__bold ML__it"],fraktur:["Fraktur-Regular","ML__frak"],"fraktur-bold":["Fraktur-Regular","ML__frak ML__bold"],"fraktur-italic":["Fraktur-Regular","ML__frak ML__it"],"fraktur-bolditalic":["Fraktur-Regular","ML__frak ML__bold ML__it"],monospace:["Typewriter-Regular","ML__tt"],"monospace-bold":["Typewriter-Regular","ML__tt ML__bold"],"monospace-italic":["Typewriter-Regular","ML__tt ML__it"],"monospace-bolditalic":["Typewriter-Regular","ML__tt ML__bold ML__it"],"double-struck":["AMS-Regular","ML__bb"],"double-struck-bold":["AMS-Regular","ML__bb ML__bold"],"double-struck-italic":["AMS-Regular","ML__bb ML_italic"],"double-struck-bolditalic":["AMS-Regular","ML__bb ML_bolditalic"]},lQ={"double-struck":/^[A-Z ]$/,script:/^[A-Z ]$/,calligraphic:/^[\dA-Z ]$/,fraktur:/^[\dA-Za-z ]$|^[!"#$%&'()*+,\-./:;=?[]^’‘]$/,monospace:/^[\dA-Za-z ]$|^[!"&'()*+,\-./:;=?@[\]^_~\u0131\u0237\u0393\u0394\u0398\u039B\u039E\u03A0\u03A3\u03A5\u03A8\u03A9]$/,"sans-serif":/^[\dA-Za-z ]$|^[!"&'()*+,\-./:;=?@[\]^_~\u0131\u0237\u0393\u0394\u0398\u039B\u039E\u03A0\u03A3\u03A5\u03A8\u03A9]$/},l0=/^[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5]$/,l1=[/^[a-z]$/,/^[A-Z]$/,l0,/^[\u0393|\u0394\u0398\u039B\u039E\u03A0\u03A3\u03A5\u03A6\u03A8\u03A9]$/],l4={iso:["it","it","it","it"],tex:["it","it","it","up"],french:["it","up","up","up"],upright:["up","up","up","up"]};function l2(e,i){let{parent:r}=e[0],a=ow(r);return ok(e,"variant").map(e=>{let r=ow(e[0]),o="";r&&r!==a&&(o=({calligraphic:"\\mathcal","calligraphic-uo":"\\mathcal",fraktur:"\\mathfrak","fraktur-uo":"\\mathfrak","double-struck":"\\mathbb","double-struck-uo":"\\mathbb",script:"\\mathscr","script-uo":"\\mathscr",monospace:"\\mathtt","monospace-uo":"\\mathtt","sans-serif":"\\mathsf","sans-serif-uo":"\\mathsf",normal:"","normal-up":"\\mathrm","normal-italic":"\\mathnormal","normal-bold":"","normal-bolditalic":"\\mathbfit",ams:"","ams-up":"\\mathrm","ams-italic":"\\mathit","ams-bold":"","ams-bolditalic":"\\mathbfit",main:"","main-up":"\\mathrm","main-italic":"\\mathit","main-bold":"","main-bolditalic":"\\mathbfit"})[r]);let n="",l=e[e.length-1],s=o&&e.length>0&&(void 0!==l.branch("subscript")||void 0!==l.branch("superscript"));s&&(n=l.supsubToLatex(i));let c=of(e.map((r,a)=>{if(s&&a===e.length-1){let e=eM(r.command,r.mode);return null!=e&&e.serialize?e.serialize(r,i):r.body&&r.command?og(r.command,r.bodyToLatex(i)):r.body?r.bodyToLatex(i):r.value&&""!==r.value?r.command||r.value:""}return r._serialize(i)}));return o?og(o,c)+n:c})}new class extends ov{constructor(){super("math")}createAtom(e,i,r){var a,o,n,l,s,c;let d;if(null===i)return new oG({type:"mord",mode:"math",command:e,value:e,style:r});try{d=null!=(n=null==(o=globalThis.MathfieldElement)?void 0:o.isFunction(null!=(a=i.command)?a:e))&&n}catch(e){d=!1}if("symbol"===i.definitionType){let a=new oG({type:null!=(l=i.type)?l:"mord",mode:"math",command:null!=(s=i.command)?s:e,value:String.fromCodePoint(i.codepoint),isFunction:d,style:r});return e.startsWith("\\")&&(a.verbatimLatex=e),a}let u=new oG({type:"mord",mode:"math",command:null!=(c=i.command)?c:e,value:e,isFunction:d,style:r});return e.startsWith("\\")&&(u.verbatimLatex=e),u}serialize(e,i){var r,a;let o=(r=e,a=g(f({},i),{defaultMode:"math"}),ok(r,"bold").map(e=>{if("bold"!==o_(e[0])||"bold"===o_(e[0].parent))return of(l2(e,a));let i=of(e.map(e=>{var i;return null!=(i=e.value)?i:""}));return/^[a-zA-Z0-9]+$/.test(i)?og("\\mathbf",of(l2(e,a))):og("\\bm",of(l2(e,a)))}));return 0===o.length||"text"!==i.defaultMode?o:["$ ",...o," $"]}getFont(e,i){var r,a,o,n;if(i.variant,i.fontFamily){let a=i.fontFamily;"b"===i.fontSeries&&"it"===i.fontShape?a+="-bolditalic":"b"===i.fontSeries?a+="-bold":"it"===i.fontShape&&(a+="-italic");let o=null!=(r=lY[a])?r:lY[i.fontFamily];if(!o)return console.error(`Unknown font family variant: ${a}`),null;let[n,l]=o;return l&&(e.classes+=" "+l),n}let{variant:l}=i,{variantStyle:s}=i;if("normal"===l&&!s&&/[\u00A3\u0131\u0237]/.test(e.value)&&(l="main",s="italic"),"normal"===l&&!s&&1===e.value.length){let r=!1;l1.forEach((a,o)=>{var n;a.test(e.value)&&"it"===l4[null!=(n=i.letterShapeStyle)?n:"tex"][o]&&(r=!0)}),r&&(s=({up:"italic",bold:"bolditalic",italic:"italic",bolditalic:"bolditalic","":"italic"})[null!=(n=s)?n:""])}"up"===s&&(s=void 0);let c=s?l+"-"+s:l;lY[c];let[d,u]=lY[c];if(lQ[l]&&!lQ[l].test(e.value)){let i=ee(e.value,l,s);return i||(i=null!=(a=ee(e.value,l))?a:e.value,e.classes+=null!=(o=({bold:" ML__bold",italic:" ML__it","bold-italic":" ML__bold ML__it"})[null!=s?s:""])?o:""),e.value=i,null}return l0.test(e.value)&&(e.classes+=" lcGreek"),u&&(e.classes+=" "+u),d}};var l3={roman:"","sans-serif":"ML__sans",monospace:"ML__tt"};function l6(e){var i;let r=/macos|ios/.test(w()),a=e.split("+"),o="";for(let e of a)o&&(o+=r?" ":'<span class="ML__shortcut-join">+</span>'),e.startsWith("[Key")?o+=e.slice(4,5):e.startsWith("Key")?o+=e.slice(3,4):e.startsWith("[Digit")?o+=e.slice(6,7):e.startsWith("Digit")?o+=e.slice(5,6):o+=null!=(i=({cmd:"⌘",meta:r?"⌘":"Ctrl",shift:r?"⇧":"Shift",alt:r?"⌥":"Alt",ctrl:r?"⌃":"Ctrl","\n":r?"⏎":"Return","[return]":r?"⏎":"Return","[enter]":r?"⌤":"Enter","[tab]":r?"⇥":"Tab","[escape]":"Esc","[backspace]":r?"⌫":"Backspace","[delete]":r?"⌦":"Del","[pageup]":r?"⇞":"Page Up","[pagedown]":r?"⇟":"Page Down","[home]":r?"⤒":"Home","[end]":r?"⤓":"End","[space]":"Space","[equal]":"=","[minus]":"-","[comma]":",","[slash]":"/","[backslash]":"\\","[bracketleft]":"[","[bracketright]":"]",semicolon:";",period:".",comma:",",minus:"-",equal:"=",quote:"'",backslash:"\\",intlbackslash:"\\",backquote:"`",slash:"/",numpadmultiply:"* 🔢",numpaddivide:"/ 🔢",numpadsubtract:"- 🔢",numpadadd:"+ 🔢",numpaddecimal:". 🔢",numpadcomma:", 🔢",help:"help",left:"⇠",up:"⇡",right:"⇢",down:"⇣","[arrowleft]":"⇠","[arrowup]":"⇡","[arrowright]":"⇢","[arrowdown]":"⇣"})[e.toLowerCase()])?i:e.toUpperCase();return o}function l8(e){if(e instanceof MouseEvent||e instanceof PointerEvent)return{x:e.clientX,y:e.clientY};if("u">typeof TouchEvent&&e instanceof TouchEvent){let i=[...e.touches].reduce((e,i)=>({x:e.x+i.clientX,y:e.y+i.clientY}),{x:0,y:0}),r=e.touches.length;return{x:i.x/r,y:i.y/r}}}function l5(e){let i={alt:!1,control:!1,shift:!1,meta:!1};return(e instanceof MouseEvent||e instanceof PointerEvent||"u">typeof TouchEvent&&e instanceof TouchEvent||e instanceof KeyboardEvent)&&(e.altKey&&(i.alt=!0),e.ctrlKey&&(i.control=!0),e.metaKey&&(i.meta=!0),e.shiftKey&&(i.shift=!0)),i}new class extends ov{constructor(){super("text")}createAtom(e,i,r){return i&&"symbol"===i.definitionType?new oY(e,String.fromCodePoint(i.codepoint),null!=r?r:{}):null}serialize(e,i){var r,a;return r=g(f({},i),{defaultMode:"text"}),a="text"!==i.defaultMode,ok(e,"fontFamily").map(e=>{var i;a=a&&!e.every(e=>e.style.fontFamily||e.style.fontShape||e.style.fontSeries||e.style.fontSize);let o=ok(e,"fontSize").map(e=>{var i,a;let o=ok(e,"fontSeries").map(e=>{let i=ok(e,"fontShape").map(e=>{let i=e.map(e=>e._serialize(r)),{fontShape:a}=e[0].style,o="";return"it"===a&&(o="\\textit"),"sl"===a&&(o="\\textsl"),"sc"===a&&(o="\\textsc"),"n"===a&&(o="\\textup"),!o&&a?`{${og("\\fontshape",a)}${of(i)}}`:o?og(o,of(i)):of(i)}),{fontSeries:a}=e[0].style,o="";return"b"===a&&(o="\\textbf"),"l"===a&&(o="\\textlf"),"m"===a&&(o="\\textmd"),a&&!o?`{${og("\\fontseries",a)}${of(i)}}`:o?og(o,of(i)):of(i)}),n=null!=(a=["","\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"][null!=(i=e[0].style.fontSize)?i:""])?a:"";return n?`${n} ${of(o)}`:of(o)}),{fontFamily:n}=e[0].style,l=null!=(i=({roman:"textrm",monospace:"texttt","sans-serif":"textsf"})[null!=n?n:""])?i:"";return l?`\\${l}{${of(o)}}`:n?`{\\fontfamily{${e[0].style.fontFamily}} ${of(o)}}`:a?`\\text{${of(o)}}`:of(o)})}getFont(e,i){var r,a,o,n,l;let{fontFamily:s}=i;if(l3[s]?e.classes+=" "+l3[s]:s&&e.setStyle("font-family",s),i.fontShape&&(e.classes+=" ",e.classes+=null!=(r=({it:"ML__it",sl:"ML__shape_sl",sc:"ML__shape_sc",ol:"ML__shape_ol"})[i.fontShape])?r:""),i.fontSeries){let r=i.fontSeries.match(/(.?[lbm])?(.?[cx])?/);r&&(e.classes+=" ",e.classes+=null!=(o=({ul:"ML__series_ul",el:"ML__series_el",l:"ML__series_l",sl:"ML__series_sl",m:"",sb:"ML__series_sb",b:"ML__bold",eb:"ML__series_eb",ub:"ML__series_ub"})[null!=(a=r[1])?a:""])?o:"",e.classes+=" ",e.classes+=null!=(l=({uc:"ML__series_uc",ec:"ML__series_ec",c:"ML__series_c",sc:"ML__series_sc",n:"",sx:"ML__series_sx",x:"ML__series_x",ex:"ML__series_ex",ux:"ML__series_ux"})[null!=(n=r[2])?n:""])?l:"")}return"Main-Regular"}},new class extends ov{constructor(){super("latex")}createAtom(e){return new l_(e)}serialize(e,i){return e.filter(e=>e instanceof l_&&!e.isSuggestion).map(e=>e.value)}getFont(){return null}};var l7=new Set(["Backquote","Digit0","Digit1","Digit2","Digit3","Digit4","Digit5","Digit6","Digit7","Digit8","Digit9","Minus","Equal","IntlYen","KeyQ","KeyW","KeyE","KeyR","KeyT","KeyY","KeyU","KeyI","KeyO","KeyP","BracketLeft","BracketRight","Backslash","KeyA","KeyS","KeyD","KeyF","KeyG","KeyH","KeyJ","KeyK","KeyL","Semicolon","Quote","IntlBackslash","KeyZ","KeyX","KeyC","KeyV","KeyB","KeyN","KeyM","Comma","Period","Slash","IntlRo","Space","Numpad0","Numpad1","Numpad2","Numpad3","Numpad4","Numpad5","Numpad6","Numpad7","Numpad8","Numpad9","NumpadAdd","NumpadComma","NumpadDecimal","NumpadDivide","NumpadEqual","NumpadHash","NumpadMultiply","NumpadParenLeft","NumpadParenRight","NumpadStar","NumpadSubstract"]);function l9(e){return!(e.ctrlKey||e.metaKey||["Dead","Process"].includes(e.key))&&(""===e.code||l7.has(e.code))}function se(){var e;let i=document.activeElement;for(;null!=(e=null==i?void 0:i.shadowRoot)&&e.activeElement;)i=i.shadowRoot.activeElement;return i}var st=class e{static get scrim(){return e._scrim||(e._scrim=new e),e._scrim}static open(i){e.scrim.open(i)}static close(){e.scrim.close()}static get state(){return e.scrim.state}static get element(){return e.scrim.element}constructor(e){var i,r;this.lightDismiss=null==(i=null==e?void 0:e.lightDismiss)||i,this.translucent=null!=(r=null==e?void 0:e.translucent)&&r,this.state="closed"}get element(){if(this._element)return this._element;let e=document.createElement("div");return e.setAttribute("role","presentation"),e.style.position="fixed",e.style.contain="content",e.style.top="0",e.style.left="0",e.style.right="0",e.style.bottom="0",e.style.zIndex="var(--scrim-zindex, 10099)",e.style.outline="none",this.translucent?(e.style.background="rgba(255, 255, 255, .2)",e.style.backdropFilter="contrast(40%)"):e.style.background="transparent",this._element=e,e}open(e){var i;if("closed"!==this.state)return;this.state="opening",this.onDismiss=null==e?void 0:e.onDismiss,this.savedActiveElement=se();let{element:r}=this;(null!=(i=null==e?void 0:e.root)?i:document.body).appendChild(r),r.addEventListener("click",this),document.addEventListener("touchmove",this,!1),document.addEventListener("scroll",this,!1);let a=window.innerWidth-document.documentElement.clientWidth;this.savedMarginRight=document.body.style.marginRight,this.savedOverflow=document.body.style.overflow,document.body.style.overflow="hidden";let o=Number.parseFloat(getComputedStyle(document.body).marginRight);document.body.style.marginRight=`${o+a}px`;let n=document.querySelector(".MLK__plate");if(n instanceof HTMLElement){this.savedMlkPaddingRight=n.style.paddingRight;let e=Number.parseFloat(getComputedStyle(n).paddingRight);n.style.paddingRight=`${e+a}px`}null!=e&&e.child&&r.append(e.child),this.state="open"}close(){var e,i,r,a,o;if("open"!==this.state)return void this.element.parentElement;this.state="closing","function"==typeof this.onDismiss&&this.onDismiss(),this.onDismiss=void 0;let{element:n}=this;n.removeEventListener("click",this),document.removeEventListener("touchmove",this,!1),document.removeEventListener("scroll",this,!1),n.remove(),document.body.style.overflow=null!=(e=this.savedOverflow)?e:"",document.body.style.marginRight=null!=(i=this.savedMarginRight)?i:"";let l=document.querySelector(".MLK__plate");l instanceof HTMLElement&&(l.style.paddingRight=null!=(r=this.savedMlkPaddingRight)?r:""),se()!==this.savedActiveElement&&(null==(o=null==(a=this.savedActiveElement)?void 0:a.focus)||o.call(a)),n.innerHTML="",this.state="closed"}handleEvent(e){this.lightDismiss&&(e.target===this._element&&"click"===e.type?(this.close(),e.preventDefault(),e.stopPropagation()):e.target===document&&("touchmove"===e.type||"scroll"===e.type)&&(this.close(),e.preventDefault(),e.stopPropagation()))}};function si(e){var i;let r;return e&&l9(e)?("Unidentified"===e.key&&e.target&&(r=e.target.value),r=null!=(i=null!=r?r:e.key)?i:e.code,/^(Dead|Return|Enter|Tab|Escape|Delete|PageUp|PageDown|Home|End|Help|ArrowLeft|ArrowRight|ArrowUp|ArrowDown)$/.test(r)&&(r=""),r):""}function sr(e){e=function(e){if(e.code)return e;let i=Object.entries($().mapping),r=!1,a=!1,o="";for(let n=0;n<4;n++){for(let[l,s]of i)if(s[n]===e.key){o=l,3===n?(r=!0,a=!0):2===n?r=!0:1===n&&(a=!0);break}if(o)break}return new KeyboardEvent(e.type,g(f({},e),{altKey:r,shiftKey:a,code:o}))}(e);let i=[];return e.ctrlKey&&i.push("ctrl"),e.metaKey&&i.push("meta"),e.altKey&&i.push("alt"),e.shiftKey&&i.push("shift"),0===i.length?`[${e.code}]`:(i.push(`[${e.code}]`),i.join("+"))}function sa(e){let i=e;return R(i)&&(i=i.length>0?i[0]+"("+i.slice(1).join("")+")":""),i}function so(e){if(Array.isArray(e)){let i=[...e];return i.shift()+"("+i.map(e=>"string"==typeof e?`"${e}"`:e.toString()).join(", ")+")"}return e}function sn(e){return e.atoms.find(e=>"latexgroup"===e.type)}function sl(e){var i,r;let a=sn(e);return null!=(r=null==(i=null==a?void 0:a.body)?void 0:i.filter(e=>"latex"===e.type))?r:[]}function ss(e,i){var r;let a=0,o=!1,n=Number.isFinite(null==i?void 0:i.before)?null!=(r=null==i?void 0:i.before)?r:0:e.lastOffset;for(;a<=n&&!o;){let i=e.at(a);(o=i instanceof l_&&i.isSuggestion)||a++}if(!o)return[void 0,void 0];let l=a,s=!1;for(;l<=n&&!s;){let i=e.at(l);(s=!(i instanceof l_&&i.isSuggestion))||l++}return[a-1,l-1]}function sc(e,i){var r,a,o,n,l,s,c,d,u,h;let p={};if("string"==typeof i.color){let n=null!=(a=e.colorMap(null!=(r=i.color)?r:i.verbatimColor))?a:"none";n!==i.color&&(p.verbatimColor=null!=(o=i.verbatimColor)?o:i.color),p.color=n}if("string"==typeof i.backgroundColor){let r=null!=(l=e.backgroundColorMap(null!=(n=i.backgroundColor)?n:i.verbatimBackgroundColor))?l:"none";r!==i.backgroundColor&&(p.verbatimBackgroundColor=null!=(s=i.verbatimBackgroundColor)?s:i.backgroundColor),p.backgroundColor=r}"string"==typeof i.fontFamily&&(p.fontFamily=i.fontFamily),"string"==typeof i.series&&(p.fontSeries=i.series),"string"==typeof i.fontSeries&&(p.fontSeries=i.fontSeries.toLowerCase()),p.fontSeries&&(p.fontSeries=null!=(c=({bold:"b",medium:"m",normal:"m"})[p.fontSeries])?c:p.fontSeries),"string"==typeof i.shape&&(p.fontShape=i.shape),"string"==typeof i.fontShape&&(p.fontShape=i.fontShape.toLowerCase()),p.fontShape&&(p.fontShape=null!=(d=({italic:"it",up:"n",upright:"n",normal:"n"})[p.fontShape])?d:p.fontShape),i.variant&&(p.variant=i.variant.toLowerCase()),void 0!==i.variantStyle&&(p.variantStyle="string"==typeof i.variantStyle&&""!==i.variantStyle?i.variantStyle.toLowerCase():i.variantStyle);let m=null!=(u=i.size)?u:i.fontSize;return"number"==typeof m?p.fontSize=Math.max(1,Math.min(10,m)):"string"==typeof m&&(p.fontSize=null!=(h=({size1:1,size2:2,size3:3,size4:4,size5:5,size6:6,size7:7,size8:8,size9:9,size10:10})[m.toLowerCase()])?h:({tiny:1,scriptsize:2,footnotesize:3,small:4,normal:5,normalsize:5,large:6,Large:7,LARGE:8,huge:9,Huge:10})[m]),p}function sd(e,i,r){var a,o;let n=e.model;if("latex"===n.mode)return{};let l=e.styleBias;if("none"===l)return e.defaultStyle;if("text"===n.mode)return null!=(o=null==(a=n.at("right"===l?r.after:r.before))?void 0:a.style)?o:e.defaultStyle;if("math"===n.mode){let i=n.at("right"===l?r.after:r.before);return f(i?g(f({},i.style),{variant:"normal"}):{variant:"normal"},e.defaultStyle)}return{}}function su(e){let i=e.options.onInsertStyle;if(null===i)return{};void 0===i&&(i=sd);let r=e.model,a=e.styleBias,o=r.at(r.position),n=sh(r,o,a),l=sh(r,o.rightSibling,a);return i(e,r.position,{before:n,after:l})}function sh(e,i,r){var a;return i&&("first"!==i.type||"right"===r)?"group"!==i.type?e.offsetOf(i):!i.body||i.body.length<2?-1:(null==(a=i.body)?void 0:a.length)===1||"right"!==r?e.offsetOf(i.body[0]):e.offsetOf(i.body[i.body.length-1]):-1}function sp(e){let i=sl(e.model).filter(e=>e.isSuggestion);if(0!==i.length)for(let r of(e.model.position=e.model.offsetOf(i[0].leftSibling),i))r.parent.removeChild(r)}function sm(e,i){var r,a;let{model:o}=e;for(let i of(sp(e),sl(o)))i.isError=!1;if(!o.selectionIsCollapsed||"off"===e.options.popoverPolicy)return void sS(e);let n=[],l=o.at(o.position);for(;l&&l instanceof l_&&/^[a-zA-Z\*]$/.test(l.value);)l=l.leftSibling;let s="",c=!1;if(l&&l instanceof l_&&"\\"===l.value){for(c=!0,n.push(l),l=l.rightSibling;l&&l instanceof l_&&/^[a-zA-Z\*]$/.test(l.value);)n.push(l),l=l.rightSibling;s=n.map(e=>e.value).join("")}else{let e=[],i=null!=(r=o.at(o.position-1))?r:o.at(o.position);for(;i&&i instanceof l_&&/^[a-zA-Z]$/.test(i.value);)e.unshift(i),i=i.leftSibling;e.length>=1&&!(i&&i instanceof l_&&"\\"===i.value)&&(s="\\"+e.map(e=>e.value).join(""),n.push(...e))}let d=function(e,i){var r,a;if(0===i.length||"\\"===i||!i.startsWith("\\"))return[];let o=[],n=i.substring(1).toLowerCase();for(let[e,i]of Object.entries(em))if(e.startsWith(n))for(let e of i){let i=e.startsWith("\\")?e:"\\"+e;o.push({match:i,frequency:1e4})}for(let e in en)e.startsWith(i)&&!en[e].infix&&o.push({match:e,frequency:null!=(r=en[e].frequency)?r:0});for(let e in ea)e.startsWith(i)&&o.push({match:e,frequency:null!=(a=ea[e].frequency)?a:0});let l=i.substring(1);for(let i of Object.keys(e.options.macros))i.startsWith(l)&&o.push({match:"\\"+i,frequency:0});for(let[e,r]of Object.entries({alpha:["\\alpha","\\Alpha"],beta:["\\beta","\\Beta"],gamma:["\\gamma","\\Gamma"],delta:["\\delta","\\Delta"],epsilon:["\\epsilon","\\varepsilon","\\Epsilon"],theta:["\\theta","\\vartheta","\\Theta"],pi:["\\pi","\\varpi","\\Pi"],rho:["\\rho","\\varrho","\\Rho"],sigma:["\\sigma","\\varsigma","\\Sigma"],phi:["\\phi","\\varphi","\\Phi"],psi:["\\psi","\\Psi"],omega:["\\omega","\\Omega"]}))if(("\\"+e).startsWith(i))for(let e of r)o.some(i=>i.match===e)||o.push({match:e,frequency:5e3});let s=new Set,c=o.filter(e=>!s.has(e.match)&&(s.add(e.match),!0)),d=["\\alpha","\\beta","\\gamma","\\delta","\\epsilon","\\zeta","\\eta","\\theta","\\iota","\\kappa","\\lambda","\\mu","\\nu","\\xi","\\omicron","\\pi","\\rho","\\sigma","\\tau","\\upsilon","\\phi","\\chi","\\psi","\\omega","\\Gamma","\\Delta","\\Theta","\\Lambda","\\Xi","\\Pi","\\Sigma","\\Upsilon","\\Phi","\\Psi","\\Omega","\\varepsilon","\\vartheta","\\varpi","\\varrho","\\varsigma","\\varphi"];return c.sort((e,i)=>{var r,a;let o=d.includes(e.match),n=d.includes(i.match);return o&&!n?-1:!o&&n?1:e.frequency===i.frequency?e.match.length===i.match.length?e.match<i.match?-1:1:e.match.length-i.match.length:(null!=(r=i.frequency)?r:0)-(null!=(a=e.frequency)?a:0)}),c.map(e=>e.match)}(e,s);if(0===d.length){if(c&&/^\\[a-zA-Z\*]+$/.test(s))for(let e of n)e.isError=!0;sS(e);return}let u=null!=(a=null==i?void 0:i.atIndex)?a:0;e.suggestionIndex=u<0?d.length-1:u%d.length,d[e.suggestionIndex],function(e,i){var r,a,o,n,l,s;let c;if(0===i.length)return sS(e);let d=document.getElementById("mathlive-suggestion-popover"),u=null==d?void 0:d.classList.contains("is-visible"),h=sx.length!==i.length||sx.some((e,r)=>e!==i[r]);if(u&&!h){let i;o=d,n=e.suggestionIndex,(i=o.querySelectorAll("li")).forEach(e=>{e.classList.remove("ML__popover__current")}),n>=0&&n<i.length&&i[n].classList.add("ML__popover__current"),null==(r=d.querySelector(".ML__popover__current"))||r.scrollIntoView({block:"nearest",inline:"nearest"});return}sx=[...i];let p=["\\text","\\textbf","\\textit","\\textrm","\\textsf","\\texttt","\\textmd","\\textup","\\textnormal","\\textsl","\\textsc","\\mathbf","\\mathit","\\mathrm","\\mathsf","\\mathtt","\\mathbb","\\mathcal","\\mathscr","\\mathfrak","\\mathnormal","\\mathbfit","\\Bbb","\\frak","\\bf","\\it","\\rm","\\sf","\\tt","\\rmfamily","\\sffamily","\\ttfamily","\\bfseries","\\mdseries","\\upshape","\\slshape","\\scshape","\\boldsymbol","\\bm","\\bold","\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge","\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle","\\color","\\textcolor","\\colorbox","\\fcolorbox","\\boxed","\\em","\\emph","\\the"],m=[],f=[],g=[];for(let r of i){let i=r;if(p.some(e=>i.startsWith(e)))continue;let a=function(e,i){let r=new oW({from:e.context});return oz(oA(lK(new oE(new oG({mode:"math",type:"root",body:ls(i,{context:r})}).render(r),{classes:"ML__base"}),r)),{classes:"ML__latex"}).toMarkup()}(e,r),o=(function(e,i){let r=[];if("string"==typeof i){let e=nn[i];R(e)?r=e.slice():e&&r.push(e)}let a=RegExp("^"+sa(i).replace("\\","\\\\").replace("|","\\|").replace("*","\\*").replace("$","\\$").replace("^","\\^")+"([^*a-zA-Z]|$)");for(let i of e)a.test(sa(i.command))&&r.push(i.key);return r.map(l6)})(e.keybindings,i).join("<br>"),n={command:i,markup:a,keybinding:o},l=["\\alpha","\\beta","\\gamma","\\delta","\\epsilon","\\zeta","\\eta","\\theta","\\iota","\\kappa","\\lambda","\\mu","\\nu","\\xi","\\omicron","\\pi","\\rho","\\sigma","\\tau","\\upsilon","\\phi","\\chi","\\psi","\\omega","\\Gamma","\\Delta","\\Theta","\\Lambda","\\Xi","\\Pi","\\Sigma","\\Upsilon","\\Phi","\\Psi","\\Omega","\\varepsilon","\\vartheta","\\varpi","\\varrho","\\varsigma","\\varphi"];i.startsWith("\\mathbb")||i.startsWith("\\mathcal")||2===i.length||l.some(e=>i===e||i.startsWith(e+" "))?g.push(n):i.length>3&&!i.includes("{")?m.push(n):g.push(n)}let b=[],y=(i,r,a=!1)=>{let o=r===e.suggestionIndex?"ML__popover__current":"",n=r<9?`\u2318${r+1}`:"",l=`<li role="button" data-command="${sv(i.command)}" class="${o} ${a?"ML__popover__item--grid":"ML__popover__item--list"}" tabindex="0">`;return a?(l+=`<span class="ML__popover__command">${i.markup}</span>`,n&&(l+=`<span class="ML__popover__shortcut">${n}</span>`)):(l+=`<span class="ML__popover__icon">${i.markup}</span><div class="ML__popover__label-group"><span class="ML__popover__latex">${sv(i.command)}</span><span class="ML__popover__type">Function</span></div>`,n?l+=`<span class="ML__popover__shortcut">${n}</span>`:i.keybinding&&(l+=`<span class="ML__popover__keybinding">${i.keybinding}</span>`)),l+="</li>"},v=0;if(g.length>0){for(let e of(b.push('<div class="ML__popover__section-title">Symbols</div>'),b.push('<ul class="ML__popover__grid">'),g))b.push(y(e,v++,!0));b.push("</ul>")}if(m.length>0){for(let e of(b.push('<div class="ML__popover__section-title">Variable or Function</div>'),b.push("<ul>"),m))b.push(y(e,v++,!1));b.push("</ul>")}if(f.length>0){for(let e of(b.push('<div class="ML__popover__section-title">Constant</div>'),b.push("<ul>"),f))b.push(y(e,v++,!1));b.push("</ul>")}let x=(l=e,s=`<div class="ML__popover__container">${b.join("")}</div>`,(c=document.getElementById("mathlive-suggestion-popover"))?sy("mathlive-suggestion-popover"):(nz("suggestion-popover"),nz("core")),(c=sb("mathlive-suggestion-popover")).addEventListener("pointerdown",e=>e.preventDefault()),c.addEventListener("click",e=>{let i=e.target;for(;i&&!i.dataset.command;)i=i.parentElement;i&&(sg(l,"reject"),na.insert(l.model,i.dataset.command,{selectionMode:"placeholder",format:"latex",mode:"math"}),l.dirty=!0,l.focus())}),c.innerHTML=globalThis.MathfieldElement.createHTML(s),c);sk()&&(null==(a=x.querySelector(".ML__popover__current"))||a.scrollIntoView({block:"nearest",inline:"nearest"}),sw(e)),setTimeout(()=>{var i;x&&!sk()&&(x.classList.add("is-visible"),sM(e),null==(i=x.querySelector(".ML__popover__current"))||i.scrollIntoView({block:"nearest",inline:"nearest"}),sw(e))},32)}(e,d)}function sf(e){let[i,r]=ss(e,{before:e.position});if(void 0===i||void 0===r)return!1;let a=!1;return e.getAtoms([i,r]).forEach(e=>{e.isSuggestion&&(e.isSuggestion=!1,a=!0)}),a}function sg(e,i="accept",r){var a,o;sS(e);let n=sn(e.model);if(!n)return!1;if("accept-suggestion"===i||"accept-all"===i){let r=sl(e.model).filter(e=>e.isSuggestion);if(0!==r.length){for(let e of r)e.isSuggestion=!1;e.model.position=e.model.offsetOf(r[r.length-1])}if("accept-suggestion"===i)return 0!==r.length}let l=sl(e.model).filter(e=>!e.isSuggestion).map(e=>e.value).join(""),s=n.leftSibling;if(n.parent.removeChild(n),e.model.position=e.model.offsetOf(s),e.switchMode(null!=(a=null==r?void 0:r.mode)?a:"math"),"reject"===i)return!0;let c=f({},su(e));return/^[a-zA-Z0-9]$/.test(l)||"none"===e.styleBias||(c.variant="normal",c.variantStyle=void 0),na.insert(e.model,l,{selectionMode:null!=(o=null==r?void 0:r.selectItem)&&o?"item":"placeholder",format:"latex",mode:"math",style:c}),e.snapshot(),e.model.announce("replacement"),e.switchMode("math"),!0}function sb(e){var i;let r=document.getElementById(e);return r?r.dataset.refcount=Number(Number.parseInt(null!=(i=r.dataset.refcount)?i:"0")+1).toString():((r=document.createElement("div")).setAttribute("aria-hidden","true"),r.dataset.refcount="1",r.id=e,(function(){let e=nL;if(e){let i=document.querySelector(e);if(i)return i}return document.body})().append(r)),r}function sy(e){var i;let r=document.getElementById(e);if(!r)return;let a=Number.parseInt(null!=(i=r.getAttribute("data-refcount"))?i:"0");a<=1?r.remove():r.dataset.refcount=Number(a-1).toString()}function sv(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}new class extends na{constructor(){super("latex")}createAtom(e){return new l_(e)}onPaste(e,i){if(!i)return!1;let r="string"==typeof i?i:i.getData("application/x-latex")||i.getData("text/plain");return!!(r&&e.model.contentWillChange({inputType:"insertFromPaste",data:r}))&&(e.stopCoalescingUndo(),e.stopRecording(),this.insert(e.model,r)&&(e.startRecording(),e.snapshot("paste"),e.model.contentDidChange({inputType:"insertFromPaste"}),s$(e)),e.startRecording(),!0)}insert(e,i,r){if(!e.contentWillChange({data:i,inputType:"insertText"}))return!1;r||(r={}),r.insertionMode||(r.insertionMode="replaceSelection"),r.selectionMode||(r.selectionMode="placeholder");let{silenceNotifications:a}=e;r.silenceNotifications&&(e.silenceNotifications=!0);let o=e.silenceNotifications;e.silenceNotifications=!0,"replaceSelection"!==r.insertionMode||e.selectionIsCollapsed?"replaceAll"===r.insertionMode?(e.root.setChildren([],"body"),e.position=0):"insertBefore"===r.insertionMode?e.collapseSelection("backward"):"insertAfter"===r.insertionMode&&e.collapseSelection("forward"):e.deleteAtoms(oQ(e.selection));let n=[];for(let e of i)ed.test(e)&&n.push(new l_(e));let l=e.at(e.position);if(l instanceof lw&&(l=l.lastChild),!(l.parent instanceof lw)){let e=new lw;l.parent.addChildAfter(e,l),l=e.firstChild}let s=l.parent.addChildrenAfter(n,l);return e.silenceNotifications=o,"before"===r.selectionMode||("item"===r.selectionMode?e.setSelection(e.anchor,e.offsetOf(s)):s&&(e.position=e.offsetOf(s))),e.contentDidChange({data:i,inputType:"insertText"}),e.silenceNotifications=a,!0}},sq({applyStyle:function(e,i){e.flushInlineShortcutBuffer(),e.stopCoalescingUndo();let r=sc(e,i),{model:a}=e;return a.selectionIsCollapsed?(e.defaultStyle.fontSeries&&r.fontSeries===e.defaultStyle.fontSeries&&(r.fontSeries="auto"),r.fontShape&&r.fontShape===e.defaultStyle.fontShape&&(r.fontShape="auto"),r.color&&r.color===e.defaultStyle.color&&(r.color="none"),r.backgroundColor&&r.backgroundColor===e.defaultStyle.backgroundColor&&(r.backgroundColor="none"),r.fontSize&&r.fontSize===e.defaultStyle.fontSize&&(r.fontSize="auto"),e.defaultStyle=f(f({},e.defaultStyle),r)):e.model.deferNotifications({content:!0,type:"insertText"},()=>{a.selection.ranges.forEach(e=>lq(a,e,r,{operation:"toggle"})),e.snapshot("style-change")}),!0}},{target:"mathfield",canUndo:!0,changeContent:!0});var sx=[],s_=null;function sw(e){s_||(s_=i=>{if(sk()){if("Enter"===i.key||"Return"===i.key){let r=document.getElementById("mathlive-suggestion-popover");if(!r)return;let a=r.querySelectorAll("li");if(e.suggestionIndex<a.length){i.preventDefault(),i.stopPropagation();let r=a[e.suggestionIndex];sg(e,"reject"),na.insert(e.model,r.dataset.command,{selectionMode:"placeholder",format:"latex",mode:"math"}),e.dirty=!0,e.focus()}return}if((i.metaKey||i.ctrlKey)&&i.key>="1"&&i.key<="9"){let r=parseInt(i.key)-1,a=document.getElementById("mathlive-suggestion-popover");if(!a)return;let o=a.querySelectorAll("li");if(r<o.length){i.preventDefault(),i.stopPropagation();let a=o[r];sg(e,"reject"),na.insert(e.model,a.dataset.command,{selectionMode:"placeholder",format:"latex",mode:"math"}),e.dirty=!0,e.focus()}}}},document.addEventListener("keydown",s_,{capture:!0}))}function sk(){let e=document.getElementById("mathlive-suggestion-popover");return!!e&&e.classList.contains("is-visible")}function sM(e,i){var r,a,o;if(!e.element||e.element.mathfield!==e||!sk())return;if((null==(r=e.model.at(e.model.position))?void 0:r.type)!=="latex")return void sS(e);if(null!=i&&i.deferred)return void setTimeout(()=>sM(e),32);let n=ns(e.field);if(!n)return;let l=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,s=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,c=window.innerWidth-document.documentElement.clientWidth,d=window.innerHeight-document.documentElement.clientHeight,u=null!=(o=null==(a=window.mathVirtualKeyboard)?void 0:a.boundingRect.height)?o:0,h=document.getElementById("mathlive-suggestion-popover");n.x+h.offsetWidth/2>s-c?h.style.left=`${s-h.offsetWidth-c}px`:n.x-h.offsetWidth/2<0?h.style.left="0":h.style.left=`${n.x-h.offsetWidth/2}px`;let p=n.y-n.height;l-d-u-n.y<p?(h.classList.add("ML__popover--reverse-direction"),h.classList.remove("top-tip"),h.classList.add("bottom-tip"),h.style.top=`${n.y-n.height-h.offsetHeight-15}px`):(h.classList.remove("ML__popover--reverse-direction"),h.classList.add("top-tip"),h.classList.remove("bottom-tip"),h.style.top=`${n.y+15}px`)}function sS(e){e.suggestionIndex=0,sx=[],document.getElementById("mathlive-suggestion-popover")&&sy("mathlive-suggestion-popover"),s_&&(document.removeEventListener("keydown",s_,{capture:!0}),s_=null)}var sL,sC,sE,sA=null,sz=(null==(sE=null==(sC=null==globalThis?void 0:globalThis.document)?void 0:sC.currentScript)?void 0:sE.src)||function(){let e=String(Error().stack).replace(/^Error.*\n/,"").split(`
|
|
3230
|
+
`);if(0===e.length)return console.error(`Can't use relative paths to specify assets location because the sourcefile location could not be determined (unexpected stack trace format "${Error().stack}").`),"";let i=e[1],r=i.match(/http.*\.ts[\?:]/);return r&&(i=e[2]),(r=i.match(/(https?:.*):[0-9]+:[0-9]+/))||(r=i.match(/at (.*(\.ts))[\?:]/))||(r=i.match(/at (.*(\.mjs|\.js))[\?:]/)),r?r[1]:(console.error(e),console.error(`Can't use relative paths to specify assets location because the source file location could not be determined (unexpected location "${i}").`),"")}();async function sT(e){if(/^(?:[a-z+]+:)?\/\//i.test(e)){try{return new URL(e).href}catch(e){}if(e.startsWith("//"))try{return new URL(`${window.location.protocol}${e}`).href}catch(e){}return e}if(null===sA)try{let e=await fetch(sz,{method:"HEAD"});200===e.status&&(sA=(sA=e.url).replace(/\/\+esm$/,"/")).includes("jsdelivr.net/")&&(sA+="/")}catch(i){console.error(`Invalid URL "${e}" (relative to "${sz}")`)}return new URL(e,null!=sA?sA:sz).href}var sD="not-loaded";async function sK(){return sD="not-loaded",sB()}async function sB(){var e;if("not-loaded"===sD){if(sD="loading",null!=(e=getComputedStyle(document.documentElement).getPropertyValue("--ML__static-fonts"))&&e){sD="ready";return}if(document.body.classList.remove("ML__fonts-did-not-load"),"fonts"in document){let e=Array.from(document.fonts).map(e=>e.family);if(["KaTeX_Main","KaTeX_Math","KaTeX_AMS","KaTeX_Caligraphic","KaTeX_Fraktur","KaTeX_SansSerif","KaTeX_Script","KaTeX_Typewriter","KaTeX_Size1","KaTeX_Size2","KaTeX_Size3","KaTeX_Size4"].every(i=>e.includes(i))){sD="ready";return}if(!globalThis.MathfieldElement.fontsDirectory){sD="not-loaded";return}let i=await sT(globalThis.MathfieldElement.fontsDirectory);if(!i){document.body.classList.add("ML__fonts-did-not-load"),sD="error";return}i.endsWith("/")&&(i=i.slice(0,-1));let r=[["KaTeX_Main-Regular"],["KaTeX_Main-BoldItalic",{style:"italic",weight:"bold"}],["KaTeX_Main-Bold",{weight:"bold"}],["KaTeX_Main-Italic",{style:"italic"}],["KaTeX_Math-Italic",{style:"italic"}],["KaTeX_Math-BoldItalic",{style:"italic",weight:"bold"}],["KaTeX_AMS-Regular"],["KaTeX_Caligraphic-Regular"],["KaTeX_Caligraphic-Bold",{weight:"bold"}],["KaTeX_Fraktur-Regular"],["KaTeX_Fraktur-Bold",{weight:"bold"}],["KaTeX_SansSerif-Regular"],["KaTeX_SansSerif-Bold",{weight:"bold"}],["KaTeX_SansSerif-Italic",{style:"italic"}],["KaTeX_Script-Regular"],["KaTeX_Typewriter-Regular"],["KaTeX_Size1-Regular"],["KaTeX_Size2-Regular"],["KaTeX_Size3-Regular"],["KaTeX_Size4-Regular"]].map(e=>(function(e,i,r={}){return new FontFace(e,`url(${i}.woff2) format('woff2')`,r)})(e[0].replace(/-[a-zA-Z]+$/,""),`${i}/${e[0]}`,e[1]));try{(await Promise.all(r.map(e=>{try{return e.load()}catch(e){}}))).forEach(e=>document.fonts.add(e)),sD="ready";return}catch(e){console.error(`MathLive 0.110.10: The math fonts could not be loaded from "${i}"`,{cause:e}),document.body.classList.add("ML__fonts-did-not-load")}sD="error"}}}function s$(e,i){e&&!e.dirty&&e.field&&(e.resizeObserver.unobserve(e.field),e.dirty=!0,requestAnimationFrame(()=>{nl(e)&&e.dirty&&(e.atomBoundsCache=new Map,sO(e,i),e.resizeObserver.observe(e.field),e.resizeObserverStarted=!0)}))}function sP(e,i){try{var r,a;let o,{model:n}=e;for(let e of(n.root.caret=void 0,n.root.isSelected=!1,n.root.containsCaret=!0,n.atoms))e.caret=void 0,e.isSelected=!1,e.containsCaret=!1;if(n.selectionIsCollapsed){let i=n.at(n.position);i.caret=e.model.mode;let r=i.parent;for(;r;)r.containsCaret=!0,r=r.parent}else for(let e of n.getAtoms(n.selection,{includeChildren:!0,includeFirstAtoms:!0}))e.isSelected=!0;return(r=i,r=null!=r?r:{},o=new oW({from:g(f({},e.context),{atomIdsSettings:{seed:r.forHighlighting?function(e,i=0){let r=0xdeadbeef^i,a=0x41c6ce57^i;for(let i=0;i<e.length;i++){let o=e.charCodeAt(i);r=Math.imul(r^o,0x9e3779b1),a=Math.imul(a^o,0x5f356495)}return r=Math.imul(r^r>>>16,0x85ebca6b)^Math.imul(a^a>>>13,0xc2b2ae35),0x100000000*(2097151&(a=Math.imul(a^a>>>16,0x85ebca6b)^Math.imul(r^r>>>13,0xc2b2ae35)))+(r>>>0)}(oG.serialize([e.model.root],{expandMacro:!1,defaultMode:e.options.defaultMode})):"random",groupNumbers:null!=(a=r.forHighlighting)&&a},letterShapeStyle:e.options.letterShapeStyle}),mathstyle:"inline-math"===e.options.defaultMode?"textstyle":"displaystyle"}),oz(lK(e.model.root.render(o),o),{classes:e.hasEditablePrompts?"ML__latex ML__prompting":"ML__latex",attributes:{translate:"no","aria-hidden":"true"}})).toMarkup()}catch(e){return console.error(e),'<span class="ML__latex" translate="no" aria-hidden="true">🚫</span>'}}function sO(e,i){if(!nl(e))return;null!=i||(i={});let r=e.element.querySelector("[part=virtual-keyboard-toggle]");r&&(r.style.display=e.hasEditableContent?"":"none");let a=e.field;if(!a)return;let o=e.isSelectionEditable&&e.hasFocus(),n=a.classList.contains("ML__focused");n&&!o?a.classList.remove("ML__focused"):!n&&o&&a.classList.add("ML__focused");let l=sP(e,i),s=e.element.querySelector("[part=menu-toggle]");if(s){let i=!1;(e.disabled||e.readOnly&&!e.hasEditableContent||"none"===e.userSelect)&&(i=!0),!i&&e.element.offsetWidth<50&&(i=!0),s.style.display=i?"none":""}if(e.model.atoms.length<=1){let i=e.options.contentPlaceholder;i&&(l+=`<span part=placeholder class="ML__content-placeholder">${dW(i)}</span>`)}a.innerHTML=globalThis.MathfieldElement.createHTML(l),sR(e,i.interactive),e.updateToggleLayout(),e.dirty=!1}function sR(e,i){var r;let a=e.field;if(!a)return;for(let e of a.querySelectorAll(".ML__selection, .ML__contains-highlight"))e.remove();if(!(null!=i&&i)&&"error"!==sD&&"ready"!==sD)return void setTimeout(()=>{"ready"===sD?sR(e):setTimeout(()=>sR(e),128)},32);let o=e.model;null==(r=e.atomBoundsCache)||r.clear();let n,l=()=>{if(void 0!==n)return n;let e=a.offsetWidth;return isNaN(n=Math.floor(a.getBoundingClientRect().width)/e)&&(n=1),n};if(o.selectionIsCollapsed){sM(e,{deferred:!0});let i=o.at(o.position);for(;i&&"prompt"!==i.type&&!(i.containsCaret&&i.displayContainsHighlight);)i=i.parent;if(null!=i&&i.containsCaret&&i.displayContainsHighlight){let r=l(),o=nc(e,nu(e,i),r);if(o){o.left/=r,o.right/=r,o.top/=r,o.bottom/=r;let e=document.createElement("div");e.classList.add("ML__contains-highlight"),e.style.position="absolute",e.style.left=`${o.left+1}px`,e.style.top=`${Math.ceil(o.top)}px`,e.style.width=`${Math.ceil(o.right-o.left)}px`,e.style.height=`${Math.ceil(o.bottom-o.top)}px`,a.insertBefore(e,a.childNodes[0])}}return}let s=l();for(let i of function(e){let i=[];for(let r of e){let e=!1;for(let a of i)if(r.left===a.left&&r.right===a.right&&r.top===a.top&&r.bottom===a.bottom){e=!0;break}e||i.push(r)}for(let r of(e=i,i=[],e)){let a=0;for(let i of e)if(r.left>=i.left&&r.right<=i.right&&r.top>=i.top&&r.bottom<=i.bottom&&(a+=1)>1)break;1===a&&i.push(r)}return i}(nh(e,{excludeAtomsWithBackground:!0}))){i.left/=s,i.right/=s,i.top/=s,i.bottom/=s;let e=document.createElement("div");e.classList.add("ML__selection"),e.style.position="absolute",e.style.left=`${i.left}px`,e.style.top=`${i.top}px`,e.style.width=`${Math.ceil(i.right-i.left)}px`,e.style.height=`${Math.max(1,Math.ceil(i.bottom-i.top-1))}px`,a.insertBefore(e,a.childNodes[0])}}function sI(e){if(!e)return;let i=e.model,r=i.selection,a=oG.serialize([i.root],{expandMacro:!1,defaultMode:e.options.defaultMode});na.insert(i,a,{insertionMode:"replaceAll",selectionMode:"after",format:"latex",silenceNotifications:!0,mode:"math"});let o=i.silenceNotifications;i.silenceNotifications=!0,i.selection=r,i.silenceNotifications=o,s$(e)}function sN(){for(let e of document.querySelectorAll(".ML__mathfield"))"_mathfield"in e&&sI(e._mathfield)}function sq(e,i){for(let r of(i=f({target:"mathfield",canUndo:!1,audioFeedback:void 0,changeContent:!1,changeSelection:!1},null!=i?i:{}),sU||(sU={}),Object.keys(e)))sU[r],sU[r]=g(f({},i),{fn:e[r]})}function sF(e){let i;if(Array.isArray(e)){if("performWithFeedback"===e[0])return sF(e[1]);i=e[0]}else i=e;return sU[i]}function sV(e){var i;return null==(i=sF(e))?void 0:i.target}function sj(e){if(!e)return;if(R(e)&&e.length>0){let i=e[0];return"performWithFeedback"===(i=i.replace(/-\w/g,e=>e[1].toUpperCase()))&&2===e.length?[i,sj(e[1])]:[i,...e.slice(1)]}if("string"!=typeof e)return;let i=e.trim().match(/^([a-zA-Z0-9-]+)\((.*)\)$/);return i?[i[1].replace(/-\w/g,e=>e[1].toUpperCase()),...i[2].split(",").map(e=>e.trim()).map(e=>{if(/"[^"]*"/.test(e)||/'[^']*'/.test(e))return e.slice(1,-1);if(/^true$/.test(e))return!0;if(/^false$/.test(e))return!1;if(/^[-]?\d+$/.test(e))return parseInt(e,10);if(/^\{.*\}$/.test(e))try{return JSON.parse(e)}catch(i){return console.error("Invalid argument:",e),e}return sj(e)})]:e.replace(/-\w/g,e=>e[1].toUpperCase())}sq({performWithFeedback:(e,i)=>(function(e,i){var r;if(!e)return!1;e.focus(),uR.keypressVibration&&_()&&navigator.vibrate(3);let a=sF(i);globalThis.MathfieldElement.playSound(null!=(r=null==a?void 0:a.audioFeedback)?r:"keypress");let o=e.executeCommand(i);return e.scrollIntoView(),o})(e,i)}),sq({complete:sg},{target:"mathfield",audioFeedback:"return",canUndo:!0,changeContent:!0,changeSelection:!0}),sq({dispatchEvent:(e,i,r)=>{var a,o;return null!=(o=null==(a=e.host)?void 0:a.dispatchEvent(new CustomEvent(i,{detail:r})))&&o}},{target:"mathfield"}),sq({nextSuggestion:function(e){return sm(e,{atIndex:e.suggestionIndex+1}),!1},previousSuggestion:function(e){return sm(e,{atIndex:e.suggestionIndex-1}),!1}},{target:"mathfield",audioFeedback:"keypress",changeSelection:!0});var sH="mathlive#virtual-keyboard-message";function sW(e){var i;return"message"===e.type&&(null==(i=e.data)?void 0:i.type)===sH}var sU,sJ,sX=class e{constructor(){this.targetOrigin=window.origin,this.originValidator="none",this.targetWindow=window.top,this._boundingRect=new DOMRect(0,0,0,0),this._isShifted=!1,window.addEventListener("message",this),this.sendMessage("proxy-created"),this.listeners={}}static get singleton(){return this._singleton||(this._singleton=new e),this._singleton}getKeycap(e){}setKeycap(e,i){this.sendMessage("update-setting",{setKeycap:{keycap:e,value:i}})}set alphabeticLayout(e){this.sendMessage("update-setting",{alphabeticLayout:e})}set layouts(e){this.sendMessage("update-setting",{layouts:e})}get normalizedLayouts(){return[]}set editToolbar(e){this.sendMessage("update-setting",{editToolbar:e})}set container(e){throw Error("Container inside an iframe cannot be changed")}show(e){this.dispatchEvent(new CustomEvent("before-virtual-keyboard-toggle",{detail:{visible:!0},bubbles:!0,cancelable:!0,composed:!0}))&&(this.sendMessage("show",e),this.dispatchEvent(new Event("virtual-keyboard-toggle")))}hide(e){this.dispatchEvent(new CustomEvent("before-virtual-keyboard-toggle",{detail:{visible:!1},bubbles:!0,cancelable:!0,composed:!0}))&&(this.sendMessage("hide",e),this.dispatchEvent(new Event("virtual-keyboard-toggle")))}get isShifted(){return this._isShifted}get visible(){return this._boundingRect.height>0}set visible(e){e?this.show():this.hide()}get boundingRect(){return this._boundingRect}executeCommand(e){return this.sendMessage("execute-command",{command:e}),!0}updateToolbar(e){this.sendMessage("update-toolbar",e)}update(e){this.sendMessage("update-setting",e)}connect(){this.sendMessage("connect")}disconnect(){this.sendMessage("disconnect")}addEventListener(e,i,r){this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].has(i)||this.listeners[e].add(i)}dispatchEvent(e){return!this.listeners[e.type]||0===this.listeners[e.type].size||(this.listeners[e.type].forEach(i=>{"function"==typeof i?i(e):null==i||i.handleEvent(e)}),!e.defaultPrevented)}removeEventListener(e,i,r){this.listeners[e]&&this.listeners[e].delete(i)}handleEvent(e){if(sW(e)){if(!np(e.origin,this.originValidator))throw new DOMException(`Message from unknown origin (${e.origin}) cannot be handled`,"SecurityError");this.handleMessage(e.data)}}handleMessage(e){let{action:i}=e;if("execute-command"===i){let{command:i}=e;"virtual-keyboard"===sV(i)&&this.executeCommand(i);return}if("synchronize-proxy"===i){this._boundingRect=e.boundingRect,this._isShifted=e.isShifted;return}if("geometry-changed"===i){this._boundingRect=e.boundingRect,this.dispatchEvent(new Event("geometrychange"));return}}sendMessage(e,i={}){if(!this.targetWindow)throw new DOMException("A frame does not have access to the top window and can't communicate with the keyboard.","SecurityError");this.targetWindow.postMessage(f({type:sH,action:e},i),this.targetOrigin)}},sG={numeric:{label:"123",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.numeric",rows:[[{latex:"x",shift:"y",variants:["y","z","t","r","x^2","x^n","x^{#?}","x_n","x_i","x_{#?}",{latex:"f(#?)",class:"small"},{latex:"g(#?)",class:"small"}]},{latex:"n",shift:"a",variants:["i","j","p","k","a","u"]},"[separator-5]","[7]","[8]","[9]","[/]","[separator-5]",{latex:"\\exponentialE",shift:"\\ln",variants:["\\exp","\\times 10^{#?}","\\ln","\\log_{10}","\\log","\\lg","\\operatorname{lb}"]},{latex:"\\imaginaryI",variants:["\\Re","\\Im","\\imaginaryJ","\\Vert #0 \\Vert"]},{latex:"\\pi",shift:"\\sin",variants:["\\prod",{latex:"\\theta",aside:"theta"},{latex:"\\rho",aside:"rho"},{latex:"\\tau",aside:"tau"},"\\sin","\\cos","\\tan"]}],[{label:"<",latex:"<",class:"hide-shift",shift:{latex:"\\le",label:"≤"}},{label:">",latex:">",class:"hide-shift",shift:{latex:"\\ge",label:"≥"}},"[separator-5]","[4]","[5]","[6]","[*]","[separator-5]",{class:"hide-shift",latex:"#@^2}",shift:"#@^{\\prime}}"},{latex:"#@^{#0}}",class:"hide-shift",shift:"#@_{#?}"},{class:"hide-shift",latex:"\\sqrt{#0}",shift:{latex:"\\sqrt[#0]{#?}}"}}],["[(]","[)]","[separator-5]","[1]","[2]","[3]","[-]","[separator-5]",{latex:"\\int^{\\infty}_{0}\\!#?\\,\\mathrm{d}x",class:"small hide-shift",shift:"\\int",variants:[{latex:"\\int_{#?}^{#?}",class:"small"},{latex:"\\int",class:"small"},{latex:"\\iint",class:"small"},{latex:"\\iiint",class:"small"},{latex:"\\oint",class:"small"},"\\mathrm{d}x",{latex:"\\dfrac{\\mathrm{d}}{\\mathrm{d} x}",class:"small"},{latex:"\\frac{\\partial}{\\partial x}",class:"small"},"\\partial"]},{class:"hide-shift",latex:"\\forall",shift:"\\exists"},{label:"[backspace]",width:1}],[{label:"[shift]",width:2},"[separator-5]","[0]","[.]","[=]","[+]","[separator-5]","[left]","[right]",{label:"[return]",width:1}]]},greek:{label:"αβγ",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.greek",rows:[[{label:"<i>φ</i>",class:"MLK__tex hide-shift",insert:"\\varphi",aside:"phi var.",shift:"\\Phi"},{label:"<i>ς</i>",class:"MLK__tex hide-shift",insert:"\\varsigma",aside:"sigma var.",shift:"\\Sigma"},{label:"<i>ϵ</i>",class:"MLK__tex hide-shift",insert:"\\epsilon",aside:"epsilon",shift:'\\char"0190'},{label:"<i>ρ</i>",class:"MLK__tex hide-shift",insert:"\\rho",aside:"rho",shift:'\\char"3A1'},{label:"<i>τ</i>",class:"MLK__tex hide-shift",insert:"\\tau",aside:"tau",shift:'\\char"3A4'},{label:"<i>υ</i>",class:"MLK__tex hide-shift",insert:"\\upsilon",aside:"upsilon",shift:"\\Upsilon"},{label:"<i>θ</i>",class:"MLK__tex hide-shift",insert:"\\theta",aside:"theta",shift:"\\Theta"},{label:"<i>ι</i>",class:"MLK__tex hide-shift",insert:"\\iota",aside:"iota",shift:'\\char"399'},{label:"<i>ο</i>",class:"MLK__tex hide-shift",insert:"\\omicron",aside:"omicron",shift:'\\char"39F'},{label:"<i>π</i>",class:"MLK__tex hide-shift",insert:"\\pi",aside:"pi",shift:"\\Pi"}],["[separator-5]",{label:"<i>α</i>",class:"MLK__tex hide-shift",insert:"\\alpha",aside:"alpha",shift:'\\char"391'},{label:"<i>σ</i>",class:"MLK__tex hide-shift",insert:"\\sigma",aside:"sigma",shift:"\\Sigma"},{label:"<i>δ</i>",class:"MLK__tex hide-shift",insert:"\\delta",aside:"delta",shift:"\\Delta"},{latex:"\\phi",class:"MLK__tex hide-shift",insert:"\\phi",aside:"phi",shift:"\\Phi"},{label:"<i>γ</i>",class:"MLK__tex hide-shift",insert:"\\gamma",aside:"gamma",shift:"\\Gamma"},{label:"<i>η</i>",class:"MLK__tex hide-shift",insert:"\\eta",aside:"eta",shift:'\\char"397'},{label:"<i>ξ</i>",class:"MLK__tex hide-shift",insert:"\\xi",aside:"xi",shift:"\\Xi"},{label:"<i>κ</i>",class:"MLK__tex hide-shift",insert:"\\kappa",aside:"kappa",shift:"\\Kappa"},{label:"<i>λ</i>",class:"MLK__tex hide-shift",insert:"\\lambda",aside:"lambda",shift:"\\Lambda"},"[separator-5]"],["[shift]",{label:"<i>ζ</i>",class:"MLK__tex hide-shift",insert:"\\zeta",aside:"zeta",shift:'\\char"396'},{label:"<i>χ</i>",class:"MLK__tex hide-shift",insert:"\\chi",aside:"chi",shift:'\\char"3A7'},{label:"<i>ψ</i>",class:"MLK__tex hide-shift",insert:"\\psi",aside:"psi",shift:"\\Psi"},{label:"<i>ω</i>",class:"MLK__tex hide-shift",insert:"\\omega",aside:"omega",shift:"\\Omega"},{label:"<i>β</i>",class:"MLK__tex hide-shift",insert:"\\beta",aside:"beta",shift:'\\char"392'},{label:"<i>ν</i>",class:"MLK__tex hide-shift",insert:"\\nu",aside:"nu",shift:'\\char"39D'},{label:"<i>μ</i>",class:"MLK__tex hide-shift",insert:"\\mu",aside:"mu",shift:'\\char"39C'},"[backspace]"],["[separator]",{label:"<i>ε</i>",class:"MLK__tex",insert:"\\varepsilon",aside:"epsilon var."},{label:"<i>ϑ</i>",class:"MLK__tex",insert:"\\vartheta",aside:"theta var."},{label:"<i>ϰ</i>",class:"MLK__tex",insert:"\\varkappa",aside:"kappa var."},{label:"<i>ϖ</i>",class:"MLK__tex",insert:"\\varpi",aside:"pi var."},{label:"<i>ϱ</i>",class:"MLK__tex",insert:"\\varrho",aside:"rho var."},"[left]","[right]","[return]"]]},symbols:{label:"∞≠∈",labelClass:"MLK__tex",tooltip:"keyboard.tooltip.symbols",rows:[[{latex:"\\sin",shift:"\\sin^{-1}",variants:[{class:"small",latex:"\\sinh"},{class:"small",latex:"\\sin^{-1}"},{class:"small",latex:"\\operatorname{arsinh}"}]},"\\ln",{latex:"\\mathrm{abs}",insert:"\\mathrm{abs}\\left(#0\\right)"},{latex:"\\rightarrow",shift:"\\Rightarrow",variants:[{latex:"\\implies",aside:"implies"},{latex:"\\to",aside:"to"},"\\dashv",{latex:"\\roundimplies",aside:"round implies"}]},{latex:"\\exists",variants:["\\nexists"],shift:"\\nexists"},{latex:"\\in",shift:"\\notin",variants:["\\notin","\\owns"]},"\\cup",{latex:"\\overrightarrow{#@}",shift:"\\overleftarrow{#@}",variants:["\\overleftarrow{#@}","\\bar{#@}","\\vec{#@}","\\hat{#@}","\\check{#@}","\\dot{#@}","\\ddot{#@}","\\mathring{#@}","\\breve{#@}","\\acute{#@}","\\tilde{#@}","\\grave{#@}"]},{class:"small hide-shift",latex:"\\lim_{#?}",shift:"\\lim_{x\\to\\infty}",variants:[{class:"small",latex:"\\liminf_{#?}"},{class:"small",latex:"\\limsup_{#?}"}]},"\\exponentialE"],[{latex:"\\cos",shift:"\\cos^{-1}",variants:[{class:"small",latex:"\\cosh"},{class:"small",latex:"\\cos^{-1}"},{class:"small",latex:"\\operatorname{arcosh}"}]},{latex:"\\log",shift:"\\log_{10}",variants:["\\log_{#0}","\\log_{10}"]},"\\left\\vert#0\\right\\vert",{latex:"\\larr",shift:"\\lArr",variants:[{latex:"\\impliedby",aside:"implied by"},{latex:"\\gets",aside:"gets"},"\\lArr","\\vdash",{latex:"\\models",aside:"models"}]},{latex:"\\forall",shift:"\\lnot",variants:[{latex:"\\land",aside:"and"},{latex:"\\lor",aside:"or"},{latex:"\\oplus",aside:"xor"},{latex:"\\lnot",aside:"not"},{latex:"\\downarrow",aside:"nor"},{latex:"\\uparrow",aside:"nand"},{latex:"\\curlywedge",aside:"nor"},{latex:"\\bar\\curlywedge",aside:"nand"}]},{latex:"\\ni",shift:"\\not\\owns"},"\\cap",{latex:"\\overline{#@}",shift:"\\underline{#@}",variants:["\\overbrace{#@}","\\overlinesegment{#@}","\\overleftrightarrow{#@}","\\overrightarrow{#@}","\\overleftarrow{#@}","\\overgroup{#@}","\\underbrace{#@}","\\underlinesegment{#@}","\\underleftrightarrow{#@}","\\underrightarrow{#@}","\\underleftarrow{#@}","\\undergroup{#@}"]},{class:"hide-shift small",latex:"\\int",shift:"\\iint",variants:[{latex:"\\int_{#?}^{#?}",class:"small"},{latex:"\\int",class:"small"},{latex:"\\smallint",class:"small"},{latex:"\\iint",class:"small"},{latex:"\\iiint",class:"small"},{latex:"\\oint",class:"small"},"\\intop","\\iiint","\\oiint","\\oiiint","\\intclockwise","\\varointclockwise","\\ointctrclockwise","\\intctrclockwise"]},{latex:"\\pi",shift:"\\tau",variants:["\\tau"]}],[{latex:"\\tan",shift:"\\tan^{-1}",variants:[{class:"small",latex:"\\tanh"},{class:"small",latex:"\\tan^{-1}"},{class:"small",latex:"\\operatorname{artanh}"},{class:"small",latex:"\\arctan"},{class:"small",latex:"\\operatorname{arctg}"},{class:"small",latex:"\\operatorname{tg}"}]},{latex:"\\exp",insert:"\\exp\\left(#0\\right)",variants:["\\exponentialE^{#0}"]},"\\left\\Vert#0\\right\\Vert",{latex:"\\lrArr",shift:"\\leftrightarrow",variants:[{latex:"\\iff",aside:"if and only if"},"\\leftrightarrow","\\leftrightarrows","\\Leftrightarrow",{latex:"^\\biconditional",aside:"biconditional"}]},{latex:"\\vert",shift:"!"},{latex:"#@^{\\complement}",aside:"complement",variants:[{latex:"\\setminus",aside:"set minus"},{latex:"\\smallsetminus",aside:"small set minus"}]},{latex:"\\subset",shift:"\\subseteq",variants:["\\subset","\\subseteq","\\subsetneq","\\varsubsetneq","\\subsetneqq","\\nsubset","\\nsubseteq","\\supset","\\supseteq","\\supsetneq","\\supsetneqq","\\nsupset","\\nsupseteq"]},{latex:"#@^{\\prime}",shift:"#@^{\\doubleprime}",variants:["#@^{\\doubleprime}","#@\\degree"]},{latex:"\\mathrm{d}",shift:"\\partial",variants:["\\mathrm{d}x",{latex:"\\dfrac{\\mathrm{d}}{\\mathrm{d} x}",class:"small"},{latex:"\\frac{\\partial}{\\partial x}",class:"small"},"\\partial"]},{latex:"\\infty",variants:["\\aleph_0","\\aleph_1","\\omega","\\mathfrak{m}"]}],[{label:"[shift]",width:2},{class:"box",latex:",",shift:";",variants:[";","?"]},{class:"box",latex:"\\colon",shift:"\\Colon",variants:[{latex:"\\Colon",aside:"such that",class:"box"},{latex:":",aside:"ratio",class:"box"},{latex:"\\vdots",aside:"",class:"box"},{latex:"\\ddots",aside:"",class:"box"},{latex:"\\ldotp",aside:"low dot",class:"box"},{latex:"\\cdotp",aside:"center dot",class:"box"},{latex:"\\ldots",aside:"low ellipsis",class:"box"},{latex:"\\cdots",aside:"center ellipsis",class:"box"},{latex:"\\therefore",aside:"therefore",class:"box"},{latex:"\\because",aside:"because",class:"box"}]},{class:"box",latex:"\\cdot",aside:"centered dot",shift:"\\ast",variants:["\\circ","\\bigcirc","\\bullet","\\odot","\\oslash","\\circledcirc","\\ast","\\star","\\times","\\doteq","\\doteqdot"]},"[separator]","[left]","[right]",{label:"[backspace]",width:1,class:"action hide-shift"},{label:"[return]",width:1}]]},compact:{label:"compact",rows:[["[+]","[-]","[*]","[/]","[=]","[.]","[(]","[)]","\\sqrt{#0}","#@^{#?}"],["[1]","[2]","[3]","[4]","[5]","[6]","[7]","[8]","[9]","[0]"],["[hr]"],["[undo]","[redo]","[separator]","[separator]","[separator]","[left]","[right]",{label:"[backspace]",class:"action hide-shift"},"[hide-keyboard]"]]},minimalist:{label:"minimalist",layers:[{style:`
|
|
3231
3231
|
div.minimalist-backdrop {
|
|
3232
3232
|
display: flex;
|
|
3233
3233
|
justify-content: center;
|
|
@@ -3243,7 +3243,7 @@ ${i}
|
|
|
3243
3243
|
border: 1px solid var(--keyboard-border);
|
|
3244
3244
|
box-shadow: 0 0 32px rgb(0 0 0 / 30%);
|
|
3245
3245
|
}
|
|
3246
|
-
`,backdrop:"minimalist-backdrop",container:"minimalist-container",rows:[["+","-","\\times",{latex:"\\frac{#@}{#0}",class:"small"},"=","[.]","(",")",{latex:"\\sqrt{#0}",class:"small"},{latex:"#@^{#?}",class:"small"}],["1","2","3","4","5","6","7","8","9","0"],["[hr]"],["[undo]","[redo]","[separator]","[separator]","[separator]","[left]","[right]",{label:"[backspace]",class:"action hide-shift"},"[hide-keyboard]"]]}]},"numeric-only":{label:"123",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.numeric",id:"numeric-only",rows:[["7","8","9","[separator]",{label:"[backspace]",width:2}],["4","5","6","[separator]","[separator]","[separator]"],["1","2","3","[separator]","[separator]","[separator]"],["0",{label:"[.]",variants:[]},"-","[separator]","[left]","[right]"]]}},
|
|
3246
|
+
`,backdrop:"minimalist-backdrop",container:"minimalist-container",rows:[["+","-","\\times",{latex:"\\frac{#@}{#0}",class:"small"},"=","[.]","(",")",{latex:"\\sqrt{#0}",class:"small"},{latex:"#@^{#?}",class:"small"}],["1","2","3","4","5","6","7","8","9","0"],["[hr]"],["[undo]","[redo]","[separator]","[separator]","[separator]","[left]","[right]",{label:"[backspace]",class:"action hide-shift"},"[hide-keyboard]"]]}]},"numeric-only":{label:"123",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.numeric",id:"numeric-only",rows:[["7","8","9","[separator]",{label:"[backspace]",width:2}],["4","5","6","[separator]","[separator]","[separator]"],["1","2","3","[separator]","[separator]","[separator]"],["0",{label:"[.]",variants:[]},"-","[separator]","[left]","[right]"]]}},sZ={0:["\\varnothing","\\infty"],1:["\\frac{1}{#@}","#@^{-1}","\\times 10^{#?}","\\phi","\\imaginaryI"],2:["\\frac{1}{2}","#@^2","\\sqrt2","\\exponentialE"],3:["\\frac{1}{3}","#@^3","\\sqrt3","\\pi"],4:["\\frac{1}{4}","#@^4"],5:["\\frac{1}{5}","#@^5","\\sqrt5"],6:["\\frac{1}{6}","#@^6"],7:["\\frac{1}{7}","#@^7"],8:["\\frac{1}{8}","#@^8"],9:["\\frac{1}{9}","#@^9"],".":[".",",",";","\\colon"],",":["{,}",".",";","\\colon"],a:[{latex:"\\aleph",aside:"aleph"},{latex:"\\forall",aside:"for all"},"å","à","á","â","ä","æ"],A:[{latex:"\\aleph",aside:"aleph"},{latex:"\\forall",aside:"for all"},"Å","À","Á","Â","Ä","Æ"],b:[{latex:"\\beth",aside:"beth"}],c:[{latex:"\\C",aside:"set of complex numbers"},"ç"],d:[{latex:"\\daleth",aside:"daleth"}],e:[{latex:"\\exponentialE",aside:"exponential e"},{latex:"\\exists",aside:"there is"},{latex:"\\nexists",aside:"there isn’t"},"è","é","ê","ë"],E:[{latex:"\\exponentialE",aside:"exponential e"},{latex:"\\exists",aside:"there is"},{latex:"\\nexists",aside:"there isn’t"},"È","É","Ê","Ë"],g:[{latex:"\\gimel",aside:"gimel"}],h:[{latex:"\\hbar",aside:"h bar"},{latex:"\\hslash",aside:"h slash"}],i:[{latex:"\\imaginaryI",aside:"imaginary i"},"ì","í","î","ï"],I:[{latex:"\\imaginaryI",aside:"imaginary i"},"Ì","Í","Î","Ï"],j:[{latex:"\\imaginaryJ",aside:"imaginary j"}],l:[{latex:"\\ell",aside:"ell"}],n:[{latex:"\\mathbb{N}",aside:"set of natural numbers"},"ñ"],o:["ø","œ","ò","ó","ô","ö"],O:["ø","Œ","Ò","Ó","Ô","Ö"],p:[{latex:"\\mathbb{P}",aside:"set of primes"}],q:[{latex:"\\mathbb{Q}",aside:"set of rational numbers"}],r:[{latex:"\\mathbb{R}",aside:"set of real numbers"}],u:["ù","ú","û","ü"],U:["Ù","Ú","Û","Ü"],z:[{latex:"\\mathbb{Z}",aside:"set of integers"}],y:["ý","ÿ"],Y:["Ÿ"],space:[{latex:'\\char"203A\\!\\char"2039',insert:"\\!",aside:"negative thin space<br>⁻³⧸₁₈ em"},{latex:'\\char"203A\\,\\char"2039',insert:"\\,",aside:"thin space<br>³⧸₁₈ em"},{latex:'\\char"203A\\:\\char"2039',insert:"\\:",aside:"medium space<br>⁴⧸₁₈ em"},{latex:'\\char"203A\\;\\char"2039',insert:"\\;",aside:"thick space<br>⁵⧸₁₈ em"},{latex:'\\char"203A\\ \\char"2039',insert:"\\ ",aside:"⅓ em"},{latex:'\\char"203A\\enspace\\char"2039',insert:"\\enspace",aside:"½ em"},{latex:'\\char"203A\\quad\\char"2039',insert:"\\quad",aside:"1 em"},{latex:'\\char"203A\\qquad\\char"2039',insert:"\\qquad",aside:"2 em"}]};function sY(e,i){var r,a,o,n,l,s,c;let d=cr.singleton;if(!d)return;let u=ct(e),h="";if(window.mathVirtualKeyboard.isShifted){let e=null==(r=d.getKeycap(null==u?void 0:u.id))?void 0:r.shift;"object"==typeof e&&"variants"in e&&(h=null!=(a=e.variants)?a:"")}else h=null!=(n=null==(o=d.getKeycap(null==u?void 0:u.id))?void 0:o.variants)?n:"";if("string"==typeof h&&!s0(h)||Array.isArray(h)&&0===h.length){null==i||i();return}let p={},m="";for(let e of"string"!=typeof(s=h)?s:(sZ[s]||(sZ[s]=null!=(c=function(e){if("foreground-color"===e){let e=[];for(let i of Object.keys(j))e.push({class:"swatch-button",label:'<span style="border: 3px solid '+j[i]+'"></span>',command:["applyStyle",{color:i}]});return e}if("background-color"===e){let e=[];for(let i of Object.keys(V))e.push({class:"swatch-button",label:'<span style="background:'+V[i]+'"></span>',command:["applyStyle",{backgroundColor:i}]});return e}}(s))?c:[]),sZ[s])){let i=s5(e),r=Date.now().toString(36).slice(-2)+Math.floor(1e5*Math.random()).toString(36);p[r]=i;let[a,o]=s6(i);m+=`<div id=${r} class="item ${o}">${a}</div>`}let f=document.createElement("div");f.setAttribute("aria-hidden","true"),f.className="MLK__variant-panel",f.style.height="auto";let g=Object.keys(p).length,b=5;1===g?b=1:2===g||4===g?b=2:3===g||5===g||6===g?b=3:g>=7&&g<14&&(b=4),f.style.width=`calc(var(--variant-keycap-length) * ${b} + 12px)`,f.innerHTML=uR.createHTML(m),st.open({root:null==(l=null==d?void 0:d.container)?void 0:l.querySelector(".ML__keyboard"),child:f});let{signal:y}=sJ=new AbortController,v=null==e?void 0:e.getBoundingClientRect();if(v){v.top-f.clientHeight<0&&(f.style.width="auto",g<=6?f.style.height="56px":g<=12?f.style.height="108px":g<=18?f.style.height="205px":f.classList.add("compact"));let e=Math.max(0,Math.min(window.innerWidth-f.offsetWidth,(v.left+v.right-f.offsetWidth)/2)),r=v.top-f.clientHeight+5;f.style.left=`${e}px`,f.style.top=`${r}px`,f.classList.add("is-visible"),requestAnimationFrame(()=>{var e;f.addEventListener("pointerup",e=>{let r=ct(e.target);null!=r&&r.id&&p[r.id]&&(ce(p[r.id]),sQ(),null==i||i(),e.preventDefault())},{capture:!0,passive:!1,signal:y}),f.addEventListener("pointerenter",e=>{let i=ct(e.target);null!=i&&i.id&&p[i.id]&&i.classList.add("is-active")},{capture:!0,signal:y}),f.addEventListener("pointerleave",e=>{let i=ct(e.target);e.target&&"tagName"in e.target&&"string"==typeof e.target.tagName&&"ASIDE"===e.target.tagName.toUpperCase()||!(null!=i&&i.id)||!p[i.id]||i.classList.remove("is-active")},{capture:!0,signal:y}),null!=(e=d.getKeycap(null==u?void 0:u.id))&&e.stickyVariantPanel?window.addEventListener("pointerdown",e=>{if(!(e.target instanceof Node))return;let r=f.contains(e.target);e.target===f||r||(sQ(),null==i||i())},{signal:y}):(window.addEventListener("pointercancel",()=>{sQ(),null==i||i()},{signal:y}),window.addEventListener("pointerup",()=>{sQ(),null==i||i()},{signal:y}))})}}function sQ(){null==sJ||sJ.abort(),sJ=null,"open"===st.state&&st.close()}function s0(e){return void 0!==sZ[e]}function s1(e){if(!e)return"";let i=new oW;return oz(oA(lK(new oE(new oG({mode:"math",type:"root",body:ls(e,{context:i,args:e=>"@"===e?"{\\class{ML__box-placeholder}{\\blacksquare}}":"\\placeholder{}"})}).render(i),{classes:"ML__base"}),i)),{classes:"ML__latex"}).toMarkup()}function s4(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function s2(e){if(Array.isArray(e))return e.map(e=>s2(e)).flat();let i="string"==typeof e?{markup:e}:e;return"rows"in i&&Array.isArray(i.rows)&&(i.rows=i.rows.map(e=>e.map(e=>s5(e)))),null!=i.id||(i.id="ML__layer_"+Date.now().toString(36).slice(-2)+Math.floor(1e5*Math.random()).toString(36)),[i]}var s3=`<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
|
|
3247
3247
|
|
|
3248
3248
|
<symbol id="svg-delete-backward" viewBox="0 0 576 512">
|
|
3249
3249
|
<path d="M432.1 208.1L385.9 256L432.1 303C442.3 312.4 442.3 327.6 432.1 336.1C423.6 346.3 408.4 346.3 399 336.1L352 289.9L304.1 336.1C295.6 346.3 280.4 346.3 271 336.1C261.7 327.6 261.7 312.4 271 303L318.1 256L271 208.1C261.7 199.6 261.7 184.4 271 175C280.4 165.7 295.6 165.7 304.1 175L352 222.1L399 175C408.4 165.7 423.6 165.7 432.1 175C442.3 184.4 442.3 199.6 432.1 208.1V208.1zM512 64C547.3 64 576 92.65 576 128V384C576 419.3 547.3 448 512 448H205.3C188.3 448 172 441.3 160 429.3L9.372 278.6C3.371 272.6 0 264.5 0 256C0 247.5 3.372 239.4 9.372 233.4L160 82.75C172 70.74 188.3 64 205.3 64L512 64zM528 128C528 119.2 520.8 112 512 112H205.3C201 112 196.9 113.7 193.9 116.7L54.63 256L193.9 395.3C196.9 398.3 201 400 205.3 400H512C520.8 400 528 392.8 528 384V128z"/>
|
|
@@ -3297,7 +3297,7 @@ ${i}
|
|
|
3297
3297
|
<path d="M336 64l-33.6-44.8C293.3 7.1 279.1 0 264 0h-80c-15.1 0-29.3 7.1-38.4 19.2L112 64H24C10.7 64 0 74.7 0 88v2c0 3.3 2.7 6 6 6h26v368c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V96h26c3.3 0 6-2.7 6-6v-2c0-13.3-10.7-24-24-24h-88zM184 32h80c5 0 9.8 2.4 12.8 6.4L296 64H152l19.2-25.6c3-4 7.8-6.4 12.8-6.4zm200 432c0 8.8-7.2 16-16 16H80c-8.8 0-16-7.2-16-16V96h320v368zm-176-44V156c0-6.6 5.4-12 12-12h8c6.6 0 12 5.4 12 12v264c0 6.6-5.4 12-12 12h-8c-6.6 0-12-5.4-12-12zm-80 0V156c0-6.6 5.4-12 12-12h8c6.6 0 12 5.4 12 12v264c0 6.6-5.4 12-12 12h-8c-6.6 0-12-5.4-12-12zm160 0V156c0-6.6 5.4-12 12-12h8c6.6 0 12 5.4 12 12v264c0 6.6-5.4 12-12 12h-8c-6.6 0-12-5.4-12-12z"/>
|
|
3298
3298
|
</symbol>
|
|
3299
3299
|
<symbol id="svg-keyboard-down" viewBox="0 0 576 512"><path d="M64 48c-8.8 0-16 7.2-16 16V240c0 8.8 7.2 16 16 16H512c8.8 0 16-7.2 16-16V64c0-8.8-7.2-16-16-16H64zM0 64C0 28.7 28.7 0 64 0H512c35.3 0 64 28.7 64 64V240c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V64zM159 359c9.4-9.4 24.6-9.4 33.9 0l95 95 95-95c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9L305 505c-4.5 4.5-10.6 7-17 7s-12.5-2.5-17-7L159 393c-9.4-9.4-9.4-24.6 0-33.9zm1-167c0-8.8 7.2-16 16-16H400c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V192zM120 88h16c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H120c-8.8 0-16-7.2-16-16V104c0-8.8 7.2-16 16-16zm64 16c0-8.8 7.2-16 16-16h16c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H200c-8.8 0-16-7.2-16-16V104zm96-16h16c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H280c-8.8 0-16-7.2-16-16V104c0-8.8 7.2-16 16-16zm64 16c0-8.8 7.2-16 16-16h16c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H360c-8.8 0-16-7.2-16-16V104zm96-16h16c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H440c-8.8 0-16-7.2-16-16V104c0-8.8 7.2-16 16-16z"/></symbol>
|
|
3300
|
-
</svg>`;function s3(e,i={shifted:!1}){var r,a,o,n,l,s,c;let d="",u=null!=(r=e.class)?r:"";if(i.shifted&&ct(e)&&(u+=" is-active"),i.shifted&&"shift"in e)"string"==typeof e.shift?d=s0(e.shift):"object"==typeof e.shift&&(d=e.shift.label?e.shift.label:null!=(a=s0(e.shift.latex||e.shift.insert||"")||e.shift.key)?a:""),"object"==typeof e.shift&&(u=null!=(n=null!=(o=e.shift.class)?o:e.class)?n:"");else{if(d=e.label?e.label:null!=(l=s0(e.latex||e.insert||"")||e.key)?l:"",e.shift){let i;i="string"==typeof e.shift?s0(e.shift):e.shift.label?e.shift.label:null!=(s=s0(e.shift.latex||e.shift.insert||"")||e.shift.key)?s:"",d+=`<span class="MLK__shift">${i}</span>`}e.aside&&(d+=`<aside>${e.aside}</aside>`)}return e.layer&&!/layer-switch/.test(u)&&(u+=" layer-switch"),/(^|\s)(separator|action|shift|fnbutton|bigfnbutton)($|\s)/.test(u)||(u+=" MLK__keycap"),!/\bw[0-9]+\b/.test(u)&&e.width&&(u+=null!=(c=({0:" w0",.5:" w5",1.5:" w15",2:" w20",5:" w50"})[e.width])?c:""),[d,u||"MLK__keycap"]}var s6={"[left]":{class:"action hide-shift",label:"<svg class=svg-glyph><use xlink:href=#svg-arrow-left /></svg>",command:"performWithFeedback(moveToPreviousChar)",shift:{label:"<svg class=svg-glyph><use xlink:href=#svg-angle-double-left /></svg>",command:"performWithFeedback(extendSelectionBackward)"}},"[right]":{class:"action hide-shift",label:"<svg class=svg-glyph><use xlink:href=#svg-arrow-right /></svg>",command:"performWithFeedback(moveToNextChar)",shift:{label:"<svg class=svg-glyph><use xlink:href=#svg-angle-double-right /></svg>",command:"performWithFeedback(extendSelectionForward)"}},"[up]":{class:"action hide-shift",label:"↑",command:"performWithFeedback(moveUp)",shift:{label:"↟",command:"performWithFeedback(extendSelectionUpward)"}},"[down]":{class:"action hide-shift",label:"↓",command:"performWithFeedback(moveDown)",shift:{label:"↡",command:"performWithFeedback(extendSelectionDownward)"}},"[return]":{class:"action hide-shift",insert:"\\\\",shift:{command:"performWithFeedback(commit)"},width:1.5,label:"<svg class=svg-glyph><use xlink:href=#svg-commit /></svg>"},"[action]":{class:"action hide-shift",command:"performWithFeedback(commit)",shift:{label:"<svg class=svg-glyph><use xlink:href=#circle-plus /></svg>",command:"performWithFeedback(addRowAfter)"},width:1.5,label:"<svg class=svg-glyph><use xlink:href=#svg-commit /></svg>"},"[hr]":{class:"separator horizontal-rule"},"[hide-keyboard]":{class:"action",command:["hideVirtualKeyboard"],width:1.5,label:"<svg class=svg-glyph-lg><use xlink:href=#svg-keyboard-down /></svg>"},"[.]":{variants:".",command:"performWithFeedback(insertDecimalSeparator)",shift:",",class:"big-op hide-shift",label:"."},"[,]":{variants:",",command:"performWithFeedback(insertDecimalSeparator)",shift:".",class:"big-op hide-shift",label:","},"[+]":{variants:[{latex:"\\sum_{#0}^{#0}",class:"small"},"\\oplus"],latex:"+",label:"+",class:"big-op hide-shift",shift:{latex:"\\sum",insert:"\\sum",class:"small"}},"[-]":{variants:["\\pm","\\ominus"],latex:"-",label:"−",shift:"\\pm",class:"big-op hide-shift"},"[/]":{class:"big-op hide-shift",shift:{class:"",latex:"\\frac{1}{#@}"},variants:["/","\\div","\\%","\\oslash"],latex:"\\frac{#@}{#?}",label:"÷"},"[*]":{variants:[{latex:"\\prod_{#0}^{#0}",class:"small"},"\\otimes","\\cdot"],latex:"\\cdot",label:"×",shift:{latex:"\\times"},class:"big-op hide-shift"},"[=]":{variants:["\\neq","\\equiv","\\varpropto","\\thickapprox","\\lt","\\gt","\\le","\\ge"],latex:"=",label:"=",shift:{label:"≠",latex:"\\ne"},class:"big-op hide-shift"},"[backspace]":{class:"action bottom right hide-shift",width:1.5,command:"performWithFeedback(deleteBackward)",label:"<svg class=svg-glyph><use xlink:href=#svg-delete-backward /></svg>",shift:{class:"action warning",label:"<svg class=svg-glyph><use xlink:href=#svg-trash /></svg>",command:"deleteAll"}},"[undo]":{class:"ghost if-can-undo",command:"undo",label:"<svg class=svg-glyph><use xlink:href=#svg-undo /></svg>",tooltip:"tooltip.undo"},"[redo]":{class:"ghost if-can-redo",command:"redo",label:"<svg class=svg-glyph><use xlink:href=#svg-redo /></svg>",tooltip:"tooltip.redo"},"[(]":{variants:[{latex:"\\lbrack",key:"["},"\\langle","\\lfloor","\\lceil",{latex:"\\lbrace",key:"{"}],key:"(",label:"(",shift:{label:"[",key:"["},class:"hide-shift"},"[)]":{variants:[{latex:"\\rbrack",key:"]"},"\\rangle","\\rfloor","\\rceil",{latex:"\\rbrace",key:"}"}],key:")",label:")",shift:{label:"]",latex:"\\rbrack"},class:"hide-shift"},"[0]":{variants:"0",latex:"0",label:"0",shift:"\\infty",class:"hide-shift"},"[1]":{variants:"1",latex:"1",label:"1",shift:"#@^{-1}",class:"hide-shift"},"[2]":{variants:"2",latex:"2",label:"2",shift:"#@^2",class:"hide-shift"},"[3]":{variants:"3",latex:"3",label:"3",shift:"#@^3",class:"hide-shift"},"[4]":{variants:"4",latex:"4",label:"4",shift:"#@^4",class:"hide-shift"},"[5]":{variants:"5",latex:"5",label:"5",shift:"#@^5",class:"hide-shift"},"[6]":{variants:"6",latex:"6",label:"6",shift:"#@^6",class:"hide-shift"},"[7]":{variants:"7",latex:"7",label:"7",shift:"#@^7",class:"hide-shift"},"[8]":{variants:"8",latex:"8",label:"8",shift:"#@^8",class:"hide-shift"},"[9]":{variants:"9",latex:"9",label:"9",shift:"#@^9",class:"hide-shift"},"[separator-5]":{class:"separator",width:.5},"[separator]":{class:"separator"},"[separator-10]":{class:"separator"},"[separator-15]":{class:"separator",width:1.5},"[separator-20]":{class:"separator",width:2},"[separator-50]":{class:"separator",width:5},"[shift]":{class:"shift bottom left",width:1.5,label:"<span class=caps-lock-indicator></span><svg class=svg-glyph><use xlink:href=#svg-shift /></svg>"},"[foreground-color]":{variants:"foreground-color",command:["applyStyle",{color:"red"}],label:"<span style='border-radius: 50%;width:22px;height:22px; border: 3px solid #cc2428; box-sizing: border-box'>"},"[background-color]":{variants:"background-color",command:["applyStyle",{backgroundColor:"yellow"}],label:"<span style='border-radius: 50%;width:22px;height:22px; background:#fff590; box-sizing: border-box'></span>"}};function s8(e){var i;let r;if("string"==typeof e){if("[.]"===e&&","===globalThis.MathfieldElement.decimalSeparator&&(e="[,]"),!s6[e])return{latex:e};e={label:e}}return"label"in e&&e.label&&s6[e.label]&&(r=g(f(f({},s6[e.label]),e),{label:s6[e.label].label})),"key"in e&&e.key&&s6[e.key]&&(r=g(f(f({},s6[e.key]),e),{key:s6[e.key].key})),r?("insertDecimalSeparator"===r.command&&(r.label=null!=(i=globalThis.MathfieldElement.decimalSeparator)?i:"."),(void 0===r.tooltip||null===r.tooltip||!1===r.tooltip)&&delete r.tooltip,(void 0===r.tooltip||null===r.tooltip||!1===r.tooltip)&&delete r.tooltip,(void 0===r.aside||null===r.aside||!1===r.aside)&&delete r.aside,(void 0===r.variants||null===r.variants||!1===r.variants)&&delete r.variants,(void 0===r.shift||null===r.shift||!1===r.shift)&&delete r.shift,r):e}function s5(e){var i,r,a,o;if(0!==e.button)return;let n=ci.singleton;if(!n)return;let l=e.target;for(;l&&!l.getAttribute("data-layer");)l=l.parentElement;if(l){n.currentLayer=null!=(i=l.getAttribute("data-layer"))?i:"",e.preventDefault();return}let s=ce(e.target);if(!(null!=s&&s.id))return;let c=n.getKeycap(s.id);if(!c)return;if(e.type,!n.connectedMathfieldWindow){let e=null==(r=window.focusedMathfield)?void 0:r.call(window);if(e){let i=null==(o=null==(a=e.element)?void 0:a.ownerDocument)?void 0:o.defaultView;i&&i!==window&&(n.connectedMathfieldWindow=i)}}let d=new AbortController,u=d.signal;s.classList.add("is-pressed"),s.addEventListener("pointerenter",s7(d),{capture:!0,signal:u}),s.addEventListener("pointerleave",s7(d),{capture:!0,signal:u}),s.addEventListener("pointercancel",s7(d),{signal:u}),s.addEventListener("pointerup",s7(d),{signal:u}),ct(c)&&(s.classList.add("is-active"),n.shiftPressCount++),c.variants&&(uD&&clearTimeout(uD),uD=setTimeout(()=>{s.classList.contains("is-pressed")&&(s.classList.remove("is-pressed"),s.classList.add("is-active"),e.target&&"releasePointerCapture"in e.target&&e.target.releasePointerCapture(e.pointerId),sZ(s,()=>{d.abort(),null==s||s.classList.remove("is-active")}))},300*!c.stickyVariantPanel)),e.preventDefault()}function s7(e){return i=>{let r=ce(i.target);if(!(null!=r&&r.id))return;let a=ci.singleton;if(!a)return;let o=a.getKeycap(r.id);if(o){if("pointerenter"===i.type&&i.target===r&&i.isPrimary&&r.classList.add("is-pressed"),"pointercancel"===i.type){r.classList.remove("is-pressed"),ct(o)&&(a.shiftPressCount--,r.classList.toggle("is-active",a.isShifted)),e.abort();return}if("pointerleave"===i.type&&i.target===r){r.classList.remove("is-pressed"),ct(o)&&(a.shiftPressCount--,r.classList.toggle("is-active",a.isShifted));return}if("pointerup"===i.type){uD&&clearTimeout(uD),ct(o)?r.classList.toggle("is-active",a.isShifted):r.classList.contains("is-pressed")&&(r.classList.remove("is-pressed"),a.isShifted&&o.shift?"string"==typeof o.shift?a.executeCommand(["insert",o.shift,{focus:!0,feedback:!0,scrollIntoView:!0,mode:"math",format:"latex"}]):s9(o.shift):s9(o),1!==a.shiftPressCount||i.shiftKey||(a.shiftPressCount=0)),e.abort(),i.preventDefault();return}}}}function s9(e){let i=e.command;!i&&e.insert&&(i=["insert",e.insert,{focus:!0,feedback:!0,scrollIntoView:!0,mode:"math",format:"latex"}]),!i&&e.key&&(i=["typedText",e.key,{focus:!0,feedback:!0,simulateKeystroke:!0}]),!i&&e.latex&&(i=["insert",e.latex,{focus:!0,feedback:!0,scrollIntoView:!0,mode:"math",format:"latex"}]),i||(i=["typedText",e.label,{focus:!0,feedback:!0,simulateKeystroke:!0}]),ci.singleton&&ci.singleton.executeCommand(i)}function ce(e){if(!e)return;let i=e;for(;i&&!function(e){if(1!==e.nodeType)return!1;let i=e.classList;return i.contains("MLK__keycap")||i.contains("shift")||i.contains("action")||i.contains("fnbutton")||i.contains("bigfnbutton")}(i);)i=i.parentElement;return null!=i?i:void 0}function ct(e){return!!e.class&&/(^|\s)shift($|\s)/.test(e.class)}var ci=class e{constructor(){var e;this.originalContainerBottomPadding=null,this.userHeight=null,this.userResizing=!1,this.rowMetricsCache=new WeakMap,this.keycapRegistry={},this._shiftPressCount=0,this.isSandbox=!1,this.targetOrigin=window.origin,this.originValidator="none",this._alphabeticLayout="auto",this._layouts=Object.freeze(["default"]),this._editToolbar="default",this._container=void 0,this._visible=!1,this._rebuilding=!1,this.observer=new ResizeObserver(e=>{this.adjustBoundingRect(),this.dispatchEvent(new Event("geometrychange")),this.sendMessage("geometry-changed",{boundingRect:this.boundingRect})}),this.listeners={};try{null==(e=window.top)||e.addEventListener("message",this)}catch(e){window.addEventListener("message",this)}x()&&document.addEventListener("focusin",e=>{let i=e.target;null!=i&&i.isConnected&&setTimeout(()=>{let e=cr();e&&"auto"===e.mathVirtualKeyboardPolicy&&e.hasEditableContent&&this.show({animate:!0})},300)}),document.addEventListener("focusout",e=>{e.target instanceof uE&&"manual"!==e.target.mathVirtualKeyboardPolicy&&setTimeout(()=>{cr()||this.hide()},300)})}get currentLayer(){var e,i,r;return null!=(r=null==(i=null==(e=this._element)?void 0:e.querySelector(".MLK__layer.is-visible"))?void 0:i.id)?r:""}set currentLayer(e){var i;if(!this._element){this.latentLayer=e;return}let r=e?this._element.querySelector(`#${e}.MLK__layer`):null;r||(r=this._element.querySelector(".MLK__layer")),r&&(null==(i=this._element.querySelector(".MLK__layer.is-visible"))||i.classList.remove("is-visible"),r.classList.add("is-visible")),this.render(),this.adjustBoundingRect()}get shiftPressCount(){return this._shiftPressCount}set shiftPressCount(e){var i;this._shiftPressCount=e>2||e<0?0:e,null==(i=this._element)||i.classList.toggle("is-caps-lock",2===this.shiftPressCount),this.render()}get isShifted(){return this._shiftPressCount>0}resetKeycapRegistry(){this.keycapRegistry={}}registerKeycap(e){let i="ML__k"+Date.now().toString(36).slice(-2)+Math.floor(1e5*Math.random()).toString(36);return this.keycapRegistry[i]=e,i}setKeycap(e,i){s6[e]=s8(i),this.rebuild()}getKeycap(e){var i;return e?null!=(i=s6[e])?i:this.keycapRegistry[e]:void 0}getLayer(e){for(let i of this.normalizedLayouts)for(let r of i.layers)if(r.id===e)return r}get alphabeticLayout(){return this._alphabeticLayout}set alphabeticLayout(e){this._alphabeticLayout=e,this._normalizedLayouts=void 0,this.rebuild()}get layouts(){return this._layouts}set layouts(e){this.updateNormalizedLayouts(e),this.rebuild()}updateNormalizedLayouts(e){let i=Array.isArray(e)?[...e]:[e],r=i.findIndex(e=>"default"===e);r>=0&&i.splice(r,1,"numeric","symbols","alphabetic","greek"),this._layouts=Object.freeze(i),this._normalizedLayouts=i.map(e=>(function e(i){let r;if("alphabetic"===i)return function(){var e,i;let r=window.mathVirtualKeyboard.alphabeticLayout;if("auto"===r){let i=$();i&&(r=i.virtualLayout),r&&"auto"!==r||(r=null!=(e=({fr:"azerty",be:"azerty",al:"qwertz",ba:"qwertz",cz:"qwertz",de:"qwertz",hu:"qwertz",sk:"qwertz",ch:"qwertz"})[I.locale.slice(0,2)])?e:"qwerty")}let a={qwerty:["qwertyuiop"," asdfghjkl ","^zxcvbnm~"],azerty:["azertyuiop","qsdfghjklm","^ wxcvbn ~"],qwertz:["qwertzuiop"," asdfghjkl ","^yxcvbnm~"],dvorak:["^ pyfgcrl ","aoeuidhtns","qjkxbmwvz~"],colemak:[" qwfpgjluy ","arstdhneio","^zxcvbkm~"]},o=null!=(i=a[r])?i:a.qwerty,n="azerty"===r?[[{label:"1",variants:"1"},{label:"2",shift:{latex:"é"},variants:"2"},{label:"3",shift:{latex:"ù"},variants:"3"},{label:"4",variants:"4"},{label:"5",shift:{label:"(",latex:"("},variants:"5"},{label:"6",shift:{label:")",latex:")"},variants:"6"},{label:"7",shift:{latex:"è"},variants:"7"},{label:"8",shift:{latex:"ê"},variants:"8"},{label:"9",shift:{latex:"ç"},variants:"9"},{label:"0",shift:{latex:"à"},variants:"0"}]]:[[{label:"1",variants:"1"},{label:"2",variants:"2"},{label:"3",variants:"3"},{label:"4",variants:"4"},{label:"5",shift:{latex:"\\frac{#@}{#?}"},variants:"5"},{label:"6",shift:{latex:"#@^#?"},variants:"6"},{label:"7",variants:"7"},{label:"8",shift:{latex:"\\times"},variants:"8"},{label:"9",shift:{label:"(",latex:"("},variants:"9"},{label:"0",shift:{label:")",latex:")"},variants:"0"}]];for(let e of o){let i=[];for(let a of e)/[a-z]/.test(a)?i.push({label:a,class:"hide-shift",shift:{label:a.toUpperCase(),variants:sQ(a.toUpperCase())?a.toUpperCase():void 0},variants:sQ(a)?a:void 0}):"~"===a?"dvorak"!==r?i.push("[backspace]"):i.push({label:"[backspace]",width:1}):"^"===a?i.push("[shift]"):" "===a&&i.push("[separator-5]");n.push(i)}return n.push(["[-]","[+]","[=]",{label:" ",width:1.5},{label:",",shift:";",variants:".",class:"hide-shift"},"[.]","[left]","[right]",{label:"[return]",width:1.5}]),{label:"abc",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.alphabetic",layers:s4({rows:n})}}();if("string"==typeof i)return sX[i],e(sX[i]);if("rows"in i&&Array.isArray(i.rows)){let{rows:e}=i;r=g(f({},y(i,["rows"])),{layers:s4({rows:i.rows})})}else if("markup"in i&&"string"==typeof i.markup){let{markup:e}=i;r=g(f({},y(i,["markup"])),{layers:s4(i.markup)})}else r=f({},i),"layers"in i?r.layers=s4(i.layers):console.error('MathLive 0.110.9: provide either a "rows", "markup" or "layers" property');let a=!1,o=!1;for(let e of r.layers)if(e.rows)for(let i of e.rows.flat()){ct(i)&&(a=!0);let e=i.command;"string"==typeof e&&["undo","redo","cut","copy","paste"].includes(e)&&(o=!0)}return"displayShiftedKeycaps"in i&&void 0!==i.displayShiftedKeycaps||(r.displayShiftedKeycaps=a),"displayEditToolbar"in i&&void 0!==i.displayEditToolbar||(r.displayEditToolbar=!o),r})(e))}get normalizedLayouts(){return this._normalizedLayouts||this.updateNormalizedLayouts(this._layouts),this._normalizedLayouts}get editToolbar(){return this._editToolbar}set editToolbar(e){this._editToolbar=e,this.rebuild()}get container(){return void 0===this._container?window.document.body:this._container}set container(e){this._container=e,this.rebuild()}static get singleton(){if(void 0===this._singleton)try{this._singleton=new e}catch(e){this._singleton=null}return this._singleton}get style(){return this._style}addEventListener(e,i,r){this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].has(i)||this.listeners[e].add(i)}dispatchEvent(e){return!this.listeners[e.type]||0===this.listeners[e.type].size||(this.listeners[e.type].forEach(i=>{"function"==typeof i?i(e):null==i||i.handleEvent(e)}),!e.defaultPrevented)}removeEventListener(e,i,r){this.listeners[e]&&this.listeners[e].delete(i)}get element(){return this._element}set element(e){var i;this._element!==e&&(null==(i=this._element)||i.remove(),this._element=e)}get visible(){return this._visible}set visible(e){e?this.show():this.hide()}get boundingRect(){var e;if(!this._visible)return new DOMRect;let i=null==(e=this._element)?void 0:e.getElementsByClassName("MLK__plate")[0];return i?i.getBoundingClientRect():new DOMRect}get plateHeight(){var e,i,r;return null!=(r=null==(i=null==(e=this._element)?void 0:e.querySelector(".MLK__plate"))?void 0:i.getBoundingClientRect().height)?r:0}setUserHeight(e){var i;let r=null==(i=this._element)?void 0:i.querySelector(".MLK__plate");if(!r)return;let a=Math.max(96,window.innerHeight-16);this.userHeight=Math.min(Math.max(e,96),a),r.style.height=`${this.userHeight}px`,this.adjustBoundingRect()}beginUserResize(){this.userResizing=!0}endUserResize(){this.userResizing=!1,this.adjustBoundingRect()}pageRows(e){var i,r,a;let o=null==(i=this._element)?void 0:i.querySelector(".MLK__layer.is-visible");if(!o)return;let n=Number(null!=(r=o.dataset.pageCount)?r:1),l=Math.min(Math.max(Number(null!=(a=o.dataset.page)?a:0)+e,0),n-1);o.dataset.page=String(l),this.updatePaging()}adjustBoundingRect(){if(!this._element)return;this.userResizing||this.updatePaging();let e=this.boundingRect.height;if(this.container===document.body){this._element.style.setProperty("--_keyboard-height",`calc(${e}px + var(--_padding-top) + var(--_padding-bottom))`);let i=e-1;this.container.style.paddingBottom=this.originalContainerBottomPadding?`calc(${this.originalContainerBottomPadding} + ${i}px)`:`${i}px`}else this._element.style.setProperty("--_keyboard-height",`${e}px`)}updatePaging(){var e,i;if(this._element)for(let r of this._element.querySelectorAll(".MLK__layer")){let a=r.querySelector(".MLK__rows-viewport"),o=r.querySelectorAll(".MLK__rows > .MLK__row"),n=r.querySelector(".MLK__rows"),l=r.querySelector(".MLK__page-up"),s=r.querySelector(".MLK__page-down");if(!a||!n||!l||!s||0===o.length)continue;l.hidden=!1,s.hidden=!1,l.disabled=!0,s.disabled=!0;let c=parseFloat(getComputedStyle(n).rowGap)||0,d=n.clientWidth,u=this.rowMetricsCache.get(n);u&&u.width===d&&u.gap===c&&u.heights.length===o.length||(o.forEach(e=>e.classList.remove("is-paged-out")),u={width:d,gap:c,heights:Array.from(o,e=>e.offsetHeight)},this.rowMetricsCache.set(n,u));let h=e=>{let i=[],r=[],a=0;return u.heights.forEach((o,n)=>{let l=o||1,s=l+(r.length>0?c:0);r.length>0&&a+s>e&&(i.push(r),r=[],a=0),r.push(n),a+=l+(r.length>1?c:0)}),r.length>0&&i.push(r),i},p=h(Math.max(1,a.clientHeight));p.length>1&&(l.disabled=!1,s.disabled=!1,p=h(Math.max(1,a.clientHeight-l.offsetHeight-s.offsetHeight)));let m=Math.max(1,p.length),f=Math.min(Math.max(Number(null!=(e=r.dataset.page)?e:0),0),m-1);r.dataset.page=String(f),r.dataset.pageCount=String(m);let g=new Set(null!=(i=p[f])?i:[]);o.forEach((e,i)=>e.classList.toggle("is-paged-out",!g.has(i))),l.disabled=0===f,s.disabled=f===m-1}}rebuild(){if(this._rebuilding||!this._element)return;this._rebuilding=!0;let e=this.currentLayer;requestAnimationFrame(()=>{this._rebuilding=!1,this._element&&(this._element.remove(),this._element=void 0),this.visible&&(this.buildAndAttachElement(),this.currentLayer=e,this.render(),this.adjustBoundingRect(),this._element.classList.add("is-visible"))})}render(){var e;if(!this._element)return;let i=this.getLayer(this.currentLayer);this._element.classList.toggle("backdrop-is-transparent",!!(i&&(i.backdrop||i.container)));let r=this._element.querySelectorAll(".MLK__layer.is-visible .MLK__keycap, .MLK__layer.is-visible .action, .fnbutton, .MLK__layer.is-visible .bigfnbutton, .MLK__layer.is-visible .shift");if(!r)return;let a=this.isShifted;for(let i of r){let r=this.getKeycap(i.id);if(r){let[o,n]=s3(r,{shifted:a});i.innerHTML=globalThis.MathfieldElement.createHTML(o),i.className=n,a&&"object"==typeof r.shift&&null!=(e=r.shift)&&e.tooltip?i.dataset.tooltip=r.shift.tooltip:!a&&r.tooltip&&(i.dataset.tooltip=r.tooltip)}}}show(e){var i;if(this._visible)return;let r=this.container;if(r&&window.mathVirtualKeyboard&&this.stateWillChange(!0)){if(this._element||(this.buildAndAttachElement(),this.adjustBoundingRect()),!this._visible){let e=this._element.getElementsByClassName("MLK__plate")[0];if(e&&this.observer.observe(e),r===window.document.body){let i=r.style.paddingBottom;this.originalContainerBottomPadding=i;let a=e.offsetHeight-1;r.style.paddingBottom=i?`calc(${i} + ${a}px)`:`${a}px`}window.addEventListener("mouseup",this),window.addEventListener("blur",this),window.addEventListener("keydown",this,{capture:!0}),window.addEventListener("keyup",this,{capture:!0}),null==(i=this._element)||i.classList.toggle("is-caps-lock",2===this.shiftPressCount),this.currentLayer=this.latentLayer}this._visible=!0,null!=e&&e.animate?requestAnimationFrame(()=>{this._element&&(this._element.classList.add("animate"),this._element.addEventListener("transitionend",()=>{var e;return null==(e=this._element)?void 0:e.classList.remove("animate")},{once:!0}),this._element.classList.add("is-visible"),this.stateChanged())}):(this._element.classList.add("is-visible"),this.stateChanged())}}hide(e){var i;let r=this.container;if(r&&this._visible&&this.stateWillChange(!1)){if(this._visible=!1,this._element){this.latentLayer=this.currentLayer;let e=this._element.getElementsByClassName("MLK__plate")[0];e&&this.observer.unobserve(e),window.removeEventListener("mouseup",this),window.removeEventListener("blur",this),window.removeEventListener("keydown",this,{capture:!0}),window.removeEventListener("keyup",this,{capture:!0}),window.removeEventListener("contextmenu",this,{capture:!0}),sY(),nz("core"),nz("virtual-keyboard"),null==(i=this._element)||i.remove(),this._element=void 0,null!==this.originalContainerBottomPadding&&(r.style.paddingBottom=this.originalContainerBottomPadding)}this.stateChanged()}}get height(){var e,i;return null!=(i=null==(e=this.element)?void 0:e.offsetHeight)?i:0}buildAndAttachElement(){var e;if(this.element,this.element=function(e){var i;e.resetKeycapRegistry(),nA("virtual-keyboard"),nA("core"),sK();let r=document.createElement("div");r.className="ML__keyboard";let a=document.createElement("div");a.className="MLK__plate",a.innerHTML=globalThis.MathfieldElement.createHTML(s2+e.normalizedLayouts.map((i,r)=>(function(e,i,r){var a;let o=[];if(!("layers"in i))return"";for(let n of i.layers)o.push(`<div tabindex="-1" class="MLK__layer" id="${n.id}">`),(e.normalizedLayouts.length>1||i.displayEditToolbar)&&(o.push("<div class='MLK__toolbar' role='toolbar'>"),o.push(function(e,i){var r,a;let o='<div class="left">';if(e.normalizedLayouts.length>1)for(let[n,l]of e.normalizedLayouts.entries()){let e=[n===i?"selected":"layer-switch"];l.tooltip&&e.push("MLK__tooltip"),l.labelClass&&e.push(...l.labelClass.split(" ")),o+=`<div class="${e.join(" ")}"`,l.tooltip&&(o+=" data-tooltip='"+(null!=(r=N(l.tooltip))?r:l.tooltip)+"' "),n!==i&&(o+=`data-layer="${l.layers[0].id}"`),o+=`>${null!=(a=l.label)?a:"untitled"}</div>`}return o+"</div>"}(e,r)),(null==(a=i.displayEditToolbar)||a)&&o.push('<div class="ML__edit-toolbar right"></div>'),o.push("</div>")),o.push(function(e,i){var r;if("string"==typeof i)return i;let a="";if("string"==typeof i.style?a+=`<style>${i.style}</style>`:"object"==typeof i.style&&(a+=`<style>${Object.keys(r=i.style).map(e=>{var i;return`${e} {${"string"==typeof(i=r[e])?i:Object.entries(i).map(([e,i])=>`${e}:${i} !important`).join(";")}}`}).join("")}</style>`),i.backdrop&&(a+=`<div class='${i.backdrop}'>`),i.container&&(a+=`<div class='${i.container}'>`),i.rows){for(let r of(a+="<div class=MLK__rows-viewport>",a+='<button type="button" class="MLK__page-button MLK__page-up" data-page-delta="-1" data-l10n-tooltip="keyboard.tooltip.previous rows" data-l10n-arial-label="keyboard.tooltip.previous rows"><svg class=svg-glyph aria-hidden="true"><use xlink:href=#svg-angle-up /></svg></button>',a+="<div class=MLK__rows>",i.rows)){for(let i of(a+='<div dir="ltr" class=MLK__row>',r))if(i){let r=e.registerKeycap(i),[o,n]=s3(i);/(^|\s)separator/.test(n)?a+=`<div class="${n}"`:a+=`<div tabindex="-1" id="${r}" class="${n}"`,i.tooltip&&(a+=` data-tooltip="${s1(i.tooltip)}"`);let l=function(e){var i,r,a,o;let n=null!=(o=null!=(a=null!=(r=null!=(i=e.tooltip)?i:"string"==typeof e.label?e.label.replace(/<\/?[^>]+(>|$)/g," "):void 0)?r:e.insert)?a:e.latex)?o:e.key;return n&&n.replace(/\s+/g," ").trim()||null}(i);l&&(a+=` aria-label="${s1(l)}"`);let s=function(e){if(null==e)return null;try{return JSON.stringify(e)}catch(e){return null}}(i.command);s&&(a+=` data-command="${s1(s)}"`);let c=function(e){var i,r;let a=null!=(r=null!=(i=e.insert)?i:e.latex)?r:e.key;return null!=a?a:null}(i);c&&(a+=` data-keycap-value="${s1(c)}"`),a+=`>${o}</div>`}a+="</div>"}a+="</div>",a+='<button type="button" class="MLK__page-button MLK__page-down" data-page-delta="1" data-l10n-tooltip="keyboard.tooltip.next rows" data-l10n-arial-label="keyboard.tooltip.next rows"><svg class=svg-glyph aria-hidden="true"><use xlink:href=#svg-angle-down /></svg></button>',a+="</div>"}else i.markup&&(a+=i.markup);return i.container&&(a+="</div>"),i.backdrop&&(a+="</div>"),a}(e,n)),o.push("</div>");return o.join("")})(e,i,r)).join("")),a.insertAdjacentHTML("afterbegin",'<div class="MLK__resize-handle" role="separator" tabindex="0" data-l10n-tooltip="keyboard.tooltip.resize" data-l10n-arial-label="keyboard.tooltip.resize"></div>'),null==(i=a.querySelector(".MLK__resize-handle"))||i.addEventListener("pointerdown",i=>{i.stopPropagation(),function(e,i){let r=e.clientY,a=i.plateHeight,o=e.pointerId,n=e.currentTarget instanceof HTMLElement?e.currentTarget:null;i.beginUserResize();try{null==n||n.setPointerCapture(o)}catch(e){}let l=e=>{e.pointerId===o&&(i.setUserHeight(a+r-e.clientY),e.preventDefault())},s=e=>{if(e.pointerId===o){window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",s),window.removeEventListener("pointercancel",s);try{null!=n&&n.hasPointerCapture(o)&&n.releasePointerCapture(o)}catch(e){}i.endUserResize()}};window.addEventListener("pointermove",l,{passive:!1}),window.addEventListener("pointerup",s),window.addEventListener("pointercancel",s),e.preventDefault()}(i,e)}),a.querySelectorAll(".MLK__page-button").forEach(i=>i.addEventListener("pointerdown",r=>{var a;r.stopPropagation(),e.pageRows(Number(null!=(a=i.dataset.pageDelta)?a:0)),r.preventDefault()}));let o=document.createElement("div");o.className="MLK__backdrop",o.appendChild(a),r.appendChild(o),r.addEventListener("pointerdown",s5,{passive:!1});let n=r.querySelectorAll(".ML__edit-toolbar");if(n)for(let i of n)i.addEventListener("click",i=>{var r,a;let o=i.target,n="";for(;o&&!n;)n=null!=(r=null==o?void 0:o.getAttribute("data-command"))?r:"",o=null!=(a=null==o?void 0:o.parentElement)?a:null;n&&e.executeCommand(JSON.parse(n))});for(let e of r.querySelectorAll(".MLK__keycap, .action, .fnbutton, .bigfnbutton"))!function(e){let i=ci.singleton;if(!i)return;let r={};if(!e.id){if(e.hasAttribute("data-label")&&(r.label=e.dataset.label),e.hasAttribute("data-latex")&&(r.latex=e.dataset.latex),e.hasAttribute("data-key")&&(r.key=e.dataset.key),e.hasAttribute("data-insert")&&(r.insert=e.dataset.insert),e.hasAttribute("data-variants")&&(r.variants=e.dataset.variants),e.hasAttribute("data-aside")&&(r.aside=e.dataset.aside),e.className&&(r.class=e.className),r.label||r.latex||r.key||r.insert||(r.latex=e.innerText,r.label=e.innerHTML),e.hasAttribute("data-command"))try{r.command=JSON.parse(e.dataset.command)}catch(e){console.warn("Invalid JSON in data-command attribute",e)}e.id=i.registerKeycap(r)}if(!e.innerHTML){let[i,a]=s3(r);e.innerHTML=globalThis.MathfieldElement.createHTML(i)}}(e);let l=r.querySelectorAll(".MLK__layer");for(let e of(l.length,l))e.addEventListener("pointerdown",e=>e.preventDefault());return e.currentLayer=e.latentLayer,I.update(r),r}(this),window.addEventListener("contextmenu",this,{capture:!0}),this.element.addEventListener("contextmenu",e=>{e.shiftKey||((e.ctrlKey||2===e.button)&&sZ(e.target),e.preventDefault(),e.stopPropagation())},{capture:!0}),null==(e=this.container)||e.appendChild(this.element),null!==this.userHeight){let e=this.element.querySelector(".MLK__plate");e&&(e.style.height=`${this.userHeight}px`)}}handleEvent(e){if(sH(e)){if(!np(e.origin,this.originValidator))throw new DOMException(`Message from unknown origin (${e.origin}) cannot be handled`,"SecurityError");if("disconnect"===e.data.action){if(this._visible)return;this.connectedMathfieldWindow=void 0}else"update-setting"!==e.data.action&&"proxy-created"!==e.data.action&&"execute-command"!==e.data.action&&(e.source,this.connectedMathfieldWindow=e.source);this.handleMessage(e.data,e.source)}if(this._element)switch(e.type){case"mouseup":case"blur":document.body.style.userSelect="",this.shiftPressCount=0;break;case"contextmenu":2!==e.button&&e.preventDefault();break;case"keydown":"Shift"!==e.key||e.repeat||(this.shiftPressCount=1);break;case"keyup":"Shift"!==e.key&&(e.getModifierState("Shift")||2===this.shiftPressCount)||(this.shiftPressCount=0)}}handleMessage(e,i){let{action:r}=e;if("execute-command"===r){let{command:r}=e,a=sF(r);if(window===window.top&&i!==window||i===window&&"virtual-keyboard"!==a)return;this.executeCommand(r);return}if(("connect"===r||"show"===r)&&this.sendMessage("synchronize-proxy",{boundingRect:this.boundingRect,alphabeticLayout:this._alphabeticLayout,layouts:this._layouts,editToolbar:this._editToolbar},i),"disconnect"!==r&&!this.isSandbox){if("show"===r)return void(void 0!==e.animate?this.show({animate:e.animate}):this.show());if("hide"===r)return void(void 0!==e.animate?this.hide({animate:e.animate}):this.hide());if("update-setting"===r){if(e.alphabeticLayout&&(this.alphabeticLayout=e.alphabeticLayout),e.layouts&&(this.layouts=e.layouts),e.editToolbar&&(this.editToolbar=e.editToolbar),e.setKeycap){let{keycap:i,value:r}=e.setKeycap;this.setKeycap(i,r),this.render()}return}if("proxy-created"===r)return void this.sendMessage("synchronize-proxy",{boundingRect:this.boundingRect,alphabeticLayout:this._alphabeticLayout,layouts:this._layouts,editToolbar:this._editToolbar},i)}}sendMessage(e,i,r){if(i.command&&this.dispatchEvent(new CustomEvent("math-virtual-keyboard-command",{detail:i.command})),r||(r=this.connectedMathfieldWindow),null===this.targetOrigin||"null"===this.targetOrigin||r===window)return void window.dispatchEvent(new MessageEvent("message",{source:window,origin:window.origin,data:f({type:sj,action:e},i)}));if(r)r.postMessage(f({type:sj,action:e},i),{targetOrigin:this.targetOrigin});else if("execute-command"===e&&Array.isArray(i.command)&&"insert"===i.command[0])for(let e of i.command[1].split(""))this.dispatchEvent(new KeyboardEvent("keydown",{key:e,bubbles:!0})),this.dispatchEvent(new KeyboardEvent("keyup",{key:e,bubbles:!0}))}stateWillChange(e){return this.dispatchEvent(new CustomEvent("before-virtual-keyboard-toggle",{detail:{visible:e},bubbles:!0,cancelable:!0,composed:!0}))}stateChanged(){this.dispatchEvent(new Event("virtual-keyboard-toggle")),this._visible||(this.dispatchEvent(new Event("geometrychange")),this.sendMessage("geometry-changed",{boundingRect:this.boundingRect}))}focus(){this.sendMessage("focus",{})}blur(){this.sendMessage("blur",{})}updateToolbar(e){let i=this._element;if(!i)return;i.classList.toggle("is-math-mode","math"===e.mode),i.classList.toggle("is-text-mode","text"===e.mode),i.classList.toggle("can-undo",e.canUndo),i.classList.toggle("can-redo",e.canRedo),i.classList.toggle("can-copy",!e.selectionIsCollapsed),i.classList.toggle("can-cut",!e.selectionIsCollapsed),i.classList.toggle("can-paste",!0);let r=i.querySelectorAll(".ML__edit-toolbar");if(r)for(let i of r)i.innerHTML=function(e,i){let r="";if("none"===e.editToolbar)return"";let a=[];i.selectionIsCollapsed?a.push("undo","redo","pasteFromClipboard"):a.push("cutToClipboard","copyToClipboard","pasteFromClipboard");let o={undo:`<div class='action ${!1===i.canUndo?"disabled":""}'
|
|
3300
|
+
</svg>`;function s6(e,i={shifted:!1}){var r,a,o,n,l,s,c;let d="",u=null!=(r=e.class)?r:"";if(i.shifted&&ci(e)&&(u+=" is-active"),i.shifted&&"shift"in e)"string"==typeof e.shift?d=s1(e.shift):"object"==typeof e.shift&&(d=e.shift.label?e.shift.label:null!=(a=s1(e.shift.latex||e.shift.insert||"")||e.shift.key)?a:""),"object"==typeof e.shift&&(u=null!=(n=null!=(o=e.shift.class)?o:e.class)?n:"");else{if(d=e.label?e.label:null!=(l=s1(e.latex||e.insert||"")||e.key)?l:"",e.shift){let i;i="string"==typeof e.shift?s1(e.shift):e.shift.label?e.shift.label:null!=(s=s1(e.shift.latex||e.shift.insert||"")||e.shift.key)?s:"",d+=`<span class="MLK__shift">${i}</span>`}e.aside&&(d+=`<aside>${e.aside}</aside>`)}return e.layer&&!/layer-switch/.test(u)&&(u+=" layer-switch"),/(^|\s)(separator|action|shift|fnbutton|bigfnbutton)($|\s)/.test(u)||(u+=" MLK__keycap"),!/\bw[0-9]+\b/.test(u)&&e.width&&(u+=null!=(c=({0:" w0",.5:" w5",1.5:" w15",2:" w20",5:" w50"})[e.width])?c:""),[d,u||"MLK__keycap"]}var s8={"[left]":{class:"action hide-shift",label:"<svg class=svg-glyph><use xlink:href=#svg-arrow-left /></svg>",command:"performWithFeedback(moveToPreviousChar)",shift:{label:"<svg class=svg-glyph><use xlink:href=#svg-angle-double-left /></svg>",command:"performWithFeedback(extendSelectionBackward)"}},"[right]":{class:"action hide-shift",label:"<svg class=svg-glyph><use xlink:href=#svg-arrow-right /></svg>",command:"performWithFeedback(moveToNextChar)",shift:{label:"<svg class=svg-glyph><use xlink:href=#svg-angle-double-right /></svg>",command:"performWithFeedback(extendSelectionForward)"}},"[up]":{class:"action hide-shift",label:"↑",command:"performWithFeedback(moveUp)",shift:{label:"↟",command:"performWithFeedback(extendSelectionUpward)"}},"[down]":{class:"action hide-shift",label:"↓",command:"performWithFeedback(moveDown)",shift:{label:"↡",command:"performWithFeedback(extendSelectionDownward)"}},"[return]":{class:"action hide-shift",insert:"\\\\",shift:{command:"performWithFeedback(commit)"},width:1.5,label:"<svg class=svg-glyph><use xlink:href=#svg-commit /></svg>"},"[action]":{class:"action hide-shift",command:"performWithFeedback(commit)",shift:{label:"<svg class=svg-glyph><use xlink:href=#circle-plus /></svg>",command:"performWithFeedback(addRowAfter)"},width:1.5,label:"<svg class=svg-glyph><use xlink:href=#svg-commit /></svg>"},"[hr]":{class:"separator horizontal-rule"},"[hide-keyboard]":{class:"action",command:["hideVirtualKeyboard"],width:1.5,label:"<svg class=svg-glyph-lg><use xlink:href=#svg-keyboard-down /></svg>"},"[.]":{variants:".",command:"performWithFeedback(insertDecimalSeparator)",shift:",",class:"big-op hide-shift",label:"."},"[,]":{variants:",",command:"performWithFeedback(insertDecimalSeparator)",shift:".",class:"big-op hide-shift",label:","},"[+]":{variants:[{latex:"\\sum_{#0}^{#0}",class:"small"},"\\oplus"],latex:"+",label:"+",class:"big-op hide-shift",shift:{latex:"\\sum",insert:"\\sum",class:"small"}},"[-]":{variants:["\\pm","\\ominus"],latex:"-",label:"−",shift:"\\pm",class:"big-op hide-shift"},"[/]":{class:"big-op hide-shift",shift:{class:"",latex:"\\frac{1}{#@}"},variants:["/","\\div","\\%","\\oslash"],latex:"\\frac{#@}{#?}",label:"÷"},"[*]":{variants:[{latex:"\\prod_{#0}^{#0}",class:"small"},"\\otimes","\\cdot"],latex:"\\cdot",label:"×",shift:{latex:"\\times"},class:"big-op hide-shift"},"[=]":{variants:["\\neq","\\equiv","\\varpropto","\\thickapprox","\\lt","\\gt","\\le","\\ge"],latex:"=",label:"=",shift:{label:"≠",latex:"\\ne"},class:"big-op hide-shift"},"[backspace]":{class:"action bottom right hide-shift",width:1.5,command:"performWithFeedback(deleteBackward)",label:"<svg class=svg-glyph><use xlink:href=#svg-delete-backward /></svg>",shift:{class:"action warning",label:"<svg class=svg-glyph><use xlink:href=#svg-trash /></svg>",command:"deleteAll"}},"[undo]":{class:"ghost if-can-undo",command:"undo",label:"<svg class=svg-glyph><use xlink:href=#svg-undo /></svg>",tooltip:"tooltip.undo"},"[redo]":{class:"ghost if-can-redo",command:"redo",label:"<svg class=svg-glyph><use xlink:href=#svg-redo /></svg>",tooltip:"tooltip.redo"},"[(]":{variants:[{latex:"\\lbrack",key:"["},"\\langle","\\lfloor","\\lceil",{latex:"\\lbrace",key:"{"}],key:"(",label:"(",shift:{label:"[",key:"["},class:"hide-shift"},"[)]":{variants:[{latex:"\\rbrack",key:"]"},"\\rangle","\\rfloor","\\rceil",{latex:"\\rbrace",key:"}"}],key:")",label:")",shift:{label:"]",latex:"\\rbrack"},class:"hide-shift"},"[0]":{variants:"0",latex:"0",label:"0",shift:"\\infty",class:"hide-shift"},"[1]":{variants:"1",latex:"1",label:"1",shift:"#@^{-1}",class:"hide-shift"},"[2]":{variants:"2",latex:"2",label:"2",shift:"#@^2",class:"hide-shift"},"[3]":{variants:"3",latex:"3",label:"3",shift:"#@^3",class:"hide-shift"},"[4]":{variants:"4",latex:"4",label:"4",shift:"#@^4",class:"hide-shift"},"[5]":{variants:"5",latex:"5",label:"5",shift:"#@^5",class:"hide-shift"},"[6]":{variants:"6",latex:"6",label:"6",shift:"#@^6",class:"hide-shift"},"[7]":{variants:"7",latex:"7",label:"7",shift:"#@^7",class:"hide-shift"},"[8]":{variants:"8",latex:"8",label:"8",shift:"#@^8",class:"hide-shift"},"[9]":{variants:"9",latex:"9",label:"9",shift:"#@^9",class:"hide-shift"},"[separator-5]":{class:"separator",width:.5},"[separator]":{class:"separator"},"[separator-10]":{class:"separator"},"[separator-15]":{class:"separator",width:1.5},"[separator-20]":{class:"separator",width:2},"[separator-50]":{class:"separator",width:5},"[shift]":{class:"shift bottom left",width:1.5,label:"<span class=caps-lock-indicator></span><svg class=svg-glyph><use xlink:href=#svg-shift /></svg>"},"[foreground-color]":{variants:"foreground-color",command:["applyStyle",{color:"red"}],label:"<span style='border-radius: 50%;width:22px;height:22px; border: 3px solid #cc2428; box-sizing: border-box'>"},"[background-color]":{variants:"background-color",command:["applyStyle",{backgroundColor:"yellow"}],label:"<span style='border-radius: 50%;width:22px;height:22px; background:#fff590; box-sizing: border-box'></span>"}};function s5(e){var i;let r;if("string"==typeof e){if("[.]"===e&&","===globalThis.MathfieldElement.decimalSeparator&&(e="[,]"),!s8[e])return{latex:e};e={label:e}}return"label"in e&&e.label&&s8[e.label]&&(r=g(f(f({},s8[e.label]),e),{label:s8[e.label].label})),"key"in e&&e.key&&s8[e.key]&&(r=g(f(f({},s8[e.key]),e),{key:s8[e.key].key})),r?("insertDecimalSeparator"===r.command&&(r.label=null!=(i=globalThis.MathfieldElement.decimalSeparator)?i:"."),(void 0===r.tooltip||null===r.tooltip||!1===r.tooltip)&&delete r.tooltip,(void 0===r.tooltip||null===r.tooltip||!1===r.tooltip)&&delete r.tooltip,(void 0===r.aside||null===r.aside||!1===r.aside)&&delete r.aside,(void 0===r.variants||null===r.variants||!1===r.variants)&&delete r.variants,(void 0===r.shift||null===r.shift||!1===r.shift)&&delete r.shift,r):e}function s7(e){var i,r,a,o;if(0!==e.button)return;let n=cr.singleton;if(!n)return;let l=e.target;for(;l&&!l.getAttribute("data-layer");)l=l.parentElement;if(l){n.currentLayer=null!=(i=l.getAttribute("data-layer"))?i:"",e.preventDefault();return}let s=ct(e.target);if(!(null!=s&&s.id))return;let c=n.getKeycap(s.id);if(!c)return;if(e.type,!n.connectedMathfieldWindow){let e=null==(r=window.focusedMathfield)?void 0:r.call(window);if(e){let i=null==(o=null==(a=e.element)?void 0:a.ownerDocument)?void 0:o.defaultView;i&&i!==window&&(n.connectedMathfieldWindow=i)}}let d=new AbortController,u=d.signal;s.classList.add("is-pressed"),s.addEventListener("pointerenter",s9(d),{capture:!0,signal:u}),s.addEventListener("pointerleave",s9(d),{capture:!0,signal:u}),s.addEventListener("pointercancel",s9(d),{signal:u}),s.addEventListener("pointerup",s9(d),{signal:u}),ci(c)&&(s.classList.add("is-active"),n.shiftPressCount++),c.variants&&(uK&&clearTimeout(uK),uK=setTimeout(()=>{s.classList.contains("is-pressed")&&(s.classList.remove("is-pressed"),s.classList.add("is-active"),e.target&&"releasePointerCapture"in e.target&&e.target.releasePointerCapture(e.pointerId),sY(s,()=>{d.abort(),null==s||s.classList.remove("is-active")}))},300*!c.stickyVariantPanel)),e.preventDefault()}function s9(e){return i=>{let r=ct(i.target);if(!(null!=r&&r.id))return;let a=cr.singleton;if(!a)return;let o=a.getKeycap(r.id);if(o){if("pointerenter"===i.type&&i.target===r&&i.isPrimary&&r.classList.add("is-pressed"),"pointercancel"===i.type){r.classList.remove("is-pressed"),ci(o)&&(a.shiftPressCount--,r.classList.toggle("is-active",a.isShifted)),e.abort();return}if("pointerleave"===i.type&&i.target===r){r.classList.remove("is-pressed"),ci(o)&&(a.shiftPressCount--,r.classList.toggle("is-active",a.isShifted));return}if("pointerup"===i.type){uK&&clearTimeout(uK),ci(o)?r.classList.toggle("is-active",a.isShifted):r.classList.contains("is-pressed")&&(r.classList.remove("is-pressed"),a.isShifted&&o.shift?"string"==typeof o.shift?a.executeCommand(["insert",o.shift,{focus:!0,feedback:!0,scrollIntoView:!0,mode:"math",format:"latex"}]):ce(o.shift):ce(o),1!==a.shiftPressCount||i.shiftKey||(a.shiftPressCount=0)),e.abort(),i.preventDefault();return}}}}function ce(e){let i=e.command;!i&&e.insert&&(i=["insert",e.insert,{focus:!0,feedback:!0,scrollIntoView:!0,mode:"math",format:"latex"}]),!i&&e.key&&(i=["typedText",e.key,{focus:!0,feedback:!0,simulateKeystroke:!0}]),!i&&e.latex&&(i=["insert",e.latex,{focus:!0,feedback:!0,scrollIntoView:!0,mode:"math",format:"latex"}]),i||(i=["typedText",e.label,{focus:!0,feedback:!0,simulateKeystroke:!0}]),cr.singleton&&cr.singleton.executeCommand(i)}function ct(e){if(!e)return;let i=e;for(;i&&!function(e){if(1!==e.nodeType)return!1;let i=e.classList;return i.contains("MLK__keycap")||i.contains("shift")||i.contains("action")||i.contains("fnbutton")||i.contains("bigfnbutton")}(i);)i=i.parentElement;return null!=i?i:void 0}function ci(e){return!!e.class&&/(^|\s)shift($|\s)/.test(e.class)}var cr=class e{constructor(){var e;this.originalContainerBottomPadding=null,this.userHeight=null,this.userResizing=!1,this.rowMetricsCache=new WeakMap,this.keycapRegistry={},this._shiftPressCount=0,this.isSandbox=!1,this.targetOrigin=window.origin,this.originValidator="none",this._alphabeticLayout="auto",this._layouts=Object.freeze(["default"]),this._editToolbar="default",this._container=void 0,this._visible=!1,this._rebuilding=!1,this.observer=new ResizeObserver(e=>{this.adjustBoundingRect(),this.dispatchEvent(new Event("geometrychange")),this.sendMessage("geometry-changed",{boundingRect:this.boundingRect})}),this.listeners={};try{null==(e=window.top)||e.addEventListener("message",this)}catch(e){window.addEventListener("message",this)}x()&&document.addEventListener("focusin",e=>{let i=e.target;null!=i&&i.isConnected&&setTimeout(()=>{let e=ca();e&&"auto"===e.mathVirtualKeyboardPolicy&&e.hasEditableContent&&this.show({animate:!0})},300)}),document.addEventListener("focusout",e=>{e.target instanceof uA&&"manual"!==e.target.mathVirtualKeyboardPolicy&&setTimeout(()=>{ca()||this.hide()},300)})}get currentLayer(){var e,i,r;return null!=(r=null==(i=null==(e=this._element)?void 0:e.querySelector(".MLK__layer.is-visible"))?void 0:i.id)?r:""}set currentLayer(e){var i;if(!this._element){this.latentLayer=e;return}let r=e?this._element.querySelector(`#${e}.MLK__layer`):null;r||(r=this._element.querySelector(".MLK__layer")),r&&(null==(i=this._element.querySelector(".MLK__layer.is-visible"))||i.classList.remove("is-visible"),r.classList.add("is-visible")),this.render(),this.adjustBoundingRect()}get shiftPressCount(){return this._shiftPressCount}set shiftPressCount(e){var i;this._shiftPressCount=e>2||e<0?0:e,null==(i=this._element)||i.classList.toggle("is-caps-lock",2===this.shiftPressCount),this.render()}get isShifted(){return this._shiftPressCount>0}resetKeycapRegistry(){this.keycapRegistry={}}registerKeycap(e){let i="ML__k"+Date.now().toString(36).slice(-2)+Math.floor(1e5*Math.random()).toString(36);return this.keycapRegistry[i]=e,i}setKeycap(e,i){s8[e]=s5(i),this.rebuild()}getKeycap(e){var i;return e?null!=(i=s8[e])?i:this.keycapRegistry[e]:void 0}getLayer(e){for(let i of this.normalizedLayouts)for(let r of i.layers)if(r.id===e)return r}get alphabeticLayout(){return this._alphabeticLayout}set alphabeticLayout(e){this._alphabeticLayout=e,this._normalizedLayouts=void 0,this.rebuild()}get layouts(){return this._layouts}set layouts(e){this.updateNormalizedLayouts(e),this.rebuild()}updateNormalizedLayouts(e){let i=Array.isArray(e)?[...e]:[e],r=i.findIndex(e=>"default"===e);r>=0&&i.splice(r,1,"numeric","symbols","alphabetic","greek"),this._layouts=Object.freeze(i),this._normalizedLayouts=i.map(e=>(function e(i){let r;if("alphabetic"===i)return function(){var e,i;let r=window.mathVirtualKeyboard.alphabeticLayout;if("auto"===r){let i=$();i&&(r=i.virtualLayout),r&&"auto"!==r||(r=null!=(e=({fr:"azerty",be:"azerty",al:"qwertz",ba:"qwertz",cz:"qwertz",de:"qwertz",hu:"qwertz",sk:"qwertz",ch:"qwertz"})[I.locale.slice(0,2)])?e:"qwerty")}let a={qwerty:["qwertyuiop"," asdfghjkl ","^zxcvbnm~"],azerty:["azertyuiop","qsdfghjklm","^ wxcvbn ~"],qwertz:["qwertzuiop"," asdfghjkl ","^yxcvbnm~"],dvorak:["^ pyfgcrl ","aoeuidhtns","qjkxbmwvz~"],colemak:[" qwfpgjluy ","arstdhneio","^zxcvbkm~"]},o=null!=(i=a[r])?i:a.qwerty,n="azerty"===r?[[{label:"1",variants:"1"},{label:"2",shift:{latex:"é"},variants:"2"},{label:"3",shift:{latex:"ù"},variants:"3"},{label:"4",variants:"4"},{label:"5",shift:{label:"(",latex:"("},variants:"5"},{label:"6",shift:{label:")",latex:")"},variants:"6"},{label:"7",shift:{latex:"è"},variants:"7"},{label:"8",shift:{latex:"ê"},variants:"8"},{label:"9",shift:{latex:"ç"},variants:"9"},{label:"0",shift:{latex:"à"},variants:"0"}]]:[[{label:"1",variants:"1"},{label:"2",variants:"2"},{label:"3",variants:"3"},{label:"4",variants:"4"},{label:"5",shift:{latex:"\\frac{#@}{#?}"},variants:"5"},{label:"6",shift:{latex:"#@^#?"},variants:"6"},{label:"7",variants:"7"},{label:"8",shift:{latex:"\\times"},variants:"8"},{label:"9",shift:{label:"(",latex:"("},variants:"9"},{label:"0",shift:{label:")",latex:")"},variants:"0"}]];for(let e of o){let i=[];for(let a of e)/[a-z]/.test(a)?i.push({label:a,class:"hide-shift",shift:{label:a.toUpperCase(),variants:s0(a.toUpperCase())?a.toUpperCase():void 0},variants:s0(a)?a:void 0}):"~"===a?"dvorak"!==r?i.push("[backspace]"):i.push({label:"[backspace]",width:1}):"^"===a?i.push("[shift]"):" "===a&&i.push("[separator-5]");n.push(i)}return n.push(["[-]","[+]","[=]",{label:" ",width:1.5},{label:",",shift:";",variants:".",class:"hide-shift"},"[.]","[left]","[right]",{label:"[return]",width:1.5}]),{label:"abc",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.alphabetic",layers:s2({rows:n})}}();if("string"==typeof i)return sG[i],e(sG[i]);if("rows"in i&&Array.isArray(i.rows)){let{rows:e}=i;r=g(f({},y(i,["rows"])),{layers:s2({rows:i.rows})})}else if("markup"in i&&"string"==typeof i.markup){let{markup:e}=i;r=g(f({},y(i,["markup"])),{layers:s2(i.markup)})}else r=f({},i),"layers"in i?r.layers=s2(i.layers):console.error('MathLive 0.110.10: provide either a "rows", "markup" or "layers" property');let a=!1,o=!1;for(let e of r.layers)if(e.rows)for(let i of e.rows.flat()){ci(i)&&(a=!0);let e=i.command;"string"==typeof e&&["undo","redo","cut","copy","paste"].includes(e)&&(o=!0)}return"displayShiftedKeycaps"in i&&void 0!==i.displayShiftedKeycaps||(r.displayShiftedKeycaps=a),"displayEditToolbar"in i&&void 0!==i.displayEditToolbar||(r.displayEditToolbar=!o),r})(e))}get normalizedLayouts(){return this._normalizedLayouts||this.updateNormalizedLayouts(this._layouts),this._normalizedLayouts}get editToolbar(){return this._editToolbar}set editToolbar(e){this._editToolbar=e,this.rebuild()}get container(){return void 0===this._container?window.document.body:this._container}set container(e){this._container=e,this.rebuild()}static get singleton(){if(void 0===this._singleton)try{this._singleton=new e}catch(e){this._singleton=null}return this._singleton}get style(){return this._style}addEventListener(e,i,r){this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].has(i)||this.listeners[e].add(i)}dispatchEvent(e){return!this.listeners[e.type]||0===this.listeners[e.type].size||(this.listeners[e.type].forEach(i=>{"function"==typeof i?i(e):null==i||i.handleEvent(e)}),!e.defaultPrevented)}removeEventListener(e,i,r){this.listeners[e]&&this.listeners[e].delete(i)}get element(){return this._element}set element(e){var i;this._element!==e&&(null==(i=this._element)||i.remove(),this._element=e)}get visible(){return this._visible}set visible(e){e?this.show():this.hide()}get boundingRect(){var e;if(!this._visible)return new DOMRect;let i=null==(e=this._element)?void 0:e.getElementsByClassName("MLK__plate")[0];return i?i.getBoundingClientRect():new DOMRect}get plateHeight(){var e,i,r;return null!=(r=null==(i=null==(e=this._element)?void 0:e.querySelector(".MLK__plate"))?void 0:i.getBoundingClientRect().height)?r:0}setUserHeight(e){var i;let r=null==(i=this._element)?void 0:i.querySelector(".MLK__plate");if(!r)return;let a=Math.max(96,window.innerHeight-16);this.userHeight=Math.min(Math.max(e,96),a),r.style.height=`${this.userHeight}px`,this.adjustBoundingRect()}beginUserResize(){this.userResizing=!0}endUserResize(){this.userResizing=!1,this.adjustBoundingRect()}pageRows(e){var i,r,a;let o=null==(i=this._element)?void 0:i.querySelector(".MLK__layer.is-visible");if(!o)return;let n=Number(null!=(r=o.dataset.pageCount)?r:1),l=Math.min(Math.max(Number(null!=(a=o.dataset.page)?a:0)+e,0),n-1);o.dataset.page=String(l),this.updatePaging()}adjustBoundingRect(){if(!this._element)return;this.userResizing||this.updatePaging();let e=this.boundingRect.height;if(this.container===document.body){this._element.style.setProperty("--_keyboard-height",`calc(${e}px + var(--_padding-top) + var(--_padding-bottom))`);let i=e-1;this.container.style.paddingBottom=this.originalContainerBottomPadding?`calc(${this.originalContainerBottomPadding} + ${i}px)`:`${i}px`}else this._element.style.setProperty("--_keyboard-height",`${e}px`)}updatePaging(){var e,i;if(this._element)for(let r of this._element.querySelectorAll(".MLK__layer")){let a=r.querySelector(".MLK__rows-viewport"),o=r.querySelectorAll(".MLK__rows > .MLK__row"),n=r.querySelector(".MLK__rows"),l=r.querySelector(".MLK__page-up"),s=r.querySelector(".MLK__page-down");if(!a||!n||!l||!s||0===o.length)continue;l.hidden=!1,s.hidden=!1,l.disabled=!0,s.disabled=!0;let c=parseFloat(getComputedStyle(n).rowGap)||0,d=n.clientWidth,u=this.rowMetricsCache.get(n);u&&u.width===d&&u.gap===c&&u.heights.length===o.length||(o.forEach(e=>e.classList.remove("is-paged-out")),u={width:d,gap:c,heights:Array.from(o,e=>e.offsetHeight)},this.rowMetricsCache.set(n,u));let h=e=>{let i=[],r=[],a=0;return u.heights.forEach((o,n)=>{let l=o||1,s=l+(r.length>0?c:0);r.length>0&&a+s>e&&(i.push(r),r=[],a=0),r.push(n),a+=l+(r.length>1?c:0)}),r.length>0&&i.push(r),i},p=h(Math.max(1,a.clientHeight));p.length>1&&(l.disabled=!1,s.disabled=!1,p=h(Math.max(1,a.clientHeight-l.offsetHeight-s.offsetHeight)));let m=Math.max(1,p.length),f=Math.min(Math.max(Number(null!=(e=r.dataset.page)?e:0),0),m-1);r.dataset.page=String(f),r.dataset.pageCount=String(m);let g=new Set(null!=(i=p[f])?i:[]);o.forEach((e,i)=>e.classList.toggle("is-paged-out",!g.has(i))),l.disabled=0===f,s.disabled=f===m-1}}rebuild(){if(this._rebuilding||!this._element)return;this._rebuilding=!0;let e=this.currentLayer;requestAnimationFrame(()=>{this._rebuilding=!1,this._element&&(this._element.remove(),this._element=void 0),this.visible&&(this.buildAndAttachElement(),this.currentLayer=e,this.render(),this.adjustBoundingRect(),this._element.classList.add("is-visible"))})}render(){var e;if(!this._element)return;let i=this.getLayer(this.currentLayer);this._element.classList.toggle("backdrop-is-transparent",!!(i&&(i.backdrop||i.container)));let r=this._element.querySelectorAll(".MLK__layer.is-visible .MLK__keycap, .MLK__layer.is-visible .action, .fnbutton, .MLK__layer.is-visible .bigfnbutton, .MLK__layer.is-visible .shift");if(!r)return;let a=this.isShifted;for(let i of r){let r=this.getKeycap(i.id);if(r){let[o,n]=s6(r,{shifted:a});i.innerHTML=globalThis.MathfieldElement.createHTML(o),i.className=n,a&&"object"==typeof r.shift&&null!=(e=r.shift)&&e.tooltip?i.dataset.tooltip=r.shift.tooltip:!a&&r.tooltip&&(i.dataset.tooltip=r.tooltip)}}}show(e){var i;if(this._visible)return;let r=this.container;if(r&&window.mathVirtualKeyboard&&this.stateWillChange(!0)){if(this._element||(this.buildAndAttachElement(),this.adjustBoundingRect()),!this._visible){let e=this._element.getElementsByClassName("MLK__plate")[0];if(e&&this.observer.observe(e),r===window.document.body){let i=r.style.paddingBottom;this.originalContainerBottomPadding=i;let a=e.offsetHeight-1;r.style.paddingBottom=i?`calc(${i} + ${a}px)`:`${a}px`}window.addEventListener("mouseup",this),window.addEventListener("blur",this),window.addEventListener("keydown",this,{capture:!0}),window.addEventListener("keyup",this,{capture:!0}),null==(i=this._element)||i.classList.toggle("is-caps-lock",2===this.shiftPressCount),this.currentLayer=this.latentLayer}this._visible=!0,null!=e&&e.animate?requestAnimationFrame(()=>{this._element&&(this._element.classList.add("animate"),this._element.addEventListener("transitionend",()=>{var e;return null==(e=this._element)?void 0:e.classList.remove("animate")},{once:!0}),this._element.classList.add("is-visible"),this.stateChanged())}):(this._element.classList.add("is-visible"),this.stateChanged())}}hide(e){var i;let r=this.container;if(r&&this._visible&&this.stateWillChange(!1)){if(this._visible=!1,this._element){this.latentLayer=this.currentLayer;let e=this._element.getElementsByClassName("MLK__plate")[0];e&&this.observer.unobserve(e),window.removeEventListener("mouseup",this),window.removeEventListener("blur",this),window.removeEventListener("keydown",this,{capture:!0}),window.removeEventListener("keyup",this,{capture:!0}),window.removeEventListener("contextmenu",this,{capture:!0}),sQ(),nT("core"),nT("virtual-keyboard"),null==(i=this._element)||i.remove(),this._element=void 0,null!==this.originalContainerBottomPadding&&(r.style.paddingBottom=this.originalContainerBottomPadding)}this.stateChanged()}}get height(){var e,i;return null!=(i=null==(e=this.element)?void 0:e.offsetHeight)?i:0}buildAndAttachElement(){var e;if(this.element,this.element=function(e){var i;e.resetKeycapRegistry(),nz("virtual-keyboard"),nz("core"),sB();let r=document.createElement("div");r.className="ML__keyboard";let a=document.createElement("div");a.className="MLK__plate",a.innerHTML=globalThis.MathfieldElement.createHTML(s3+e.normalizedLayouts.map((i,r)=>(function(e,i,r){var a;let o=[];if(!("layers"in i))return"";for(let n of i.layers)o.push(`<div tabindex="-1" class="MLK__layer" id="${n.id}">`),(e.normalizedLayouts.length>1||i.displayEditToolbar)&&(o.push("<div class='MLK__toolbar' role='toolbar'>"),o.push(function(e,i){var r,a;let o='<div class="left">';if(e.normalizedLayouts.length>1)for(let[n,l]of e.normalizedLayouts.entries()){let e=[n===i?"selected":"layer-switch"];l.tooltip&&e.push("MLK__tooltip"),l.labelClass&&e.push(...l.labelClass.split(" ")),o+=`<div class="${e.join(" ")}"`,l.tooltip&&(o+=" data-tooltip='"+(null!=(r=N(l.tooltip))?r:l.tooltip)+"' "),n!==i&&(o+=`data-layer="${l.layers[0].id}"`),o+=`>${null!=(a=l.label)?a:"untitled"}</div>`}return o+"</div>"}(e,r)),(null==(a=i.displayEditToolbar)||a)&&o.push('<div class="ML__edit-toolbar right"></div>'),o.push("</div>")),o.push(function(e,i){var r;if("string"==typeof i)return i;let a="";if("string"==typeof i.style?a+=`<style>${i.style}</style>`:"object"==typeof i.style&&(a+=`<style>${Object.keys(r=i.style).map(e=>{var i;return`${e} {${"string"==typeof(i=r[e])?i:Object.entries(i).map(([e,i])=>`${e}:${i} !important`).join(";")}}`}).join("")}</style>`),i.backdrop&&(a+=`<div class='${i.backdrop}'>`),i.container&&(a+=`<div class='${i.container}'>`),i.rows){for(let r of(a+="<div class=MLK__rows-viewport>",a+='<button type="button" class="MLK__page-button MLK__page-up" data-page-delta="-1" data-l10n-tooltip="keyboard.tooltip.previous rows" data-l10n-arial-label="keyboard.tooltip.previous rows"><svg class=svg-glyph aria-hidden="true"><use xlink:href=#svg-angle-up /></svg></button>',a+="<div class=MLK__rows>",i.rows)){for(let i of(a+='<div dir="ltr" class=MLK__row>',r))if(i){let r=e.registerKeycap(i),[o,n]=s6(i);/(^|\s)separator/.test(n)?a+=`<div class="${n}"`:a+=`<div tabindex="-1" id="${r}" class="${n}"`,i.tooltip&&(a+=` data-tooltip="${s4(i.tooltip)}"`);let l=function(e){var i,r,a,o;let n=null!=(o=null!=(a=null!=(r=null!=(i=e.tooltip)?i:"string"==typeof e.label?e.label.replace(/<\/?[^>]+(>|$)/g," "):void 0)?r:e.insert)?a:e.latex)?o:e.key;return n&&n.replace(/\s+/g," ").trim()||null}(i);l&&(a+=` aria-label="${s4(l)}"`);let s=function(e){if(null==e)return null;try{return JSON.stringify(e)}catch(e){return null}}(i.command);s&&(a+=` data-command="${s4(s)}"`);let c=function(e){var i,r;let a=null!=(r=null!=(i=e.insert)?i:e.latex)?r:e.key;return null!=a?a:null}(i);c&&(a+=` data-keycap-value="${s4(c)}"`),a+=`>${o}</div>`}a+="</div>"}a+="</div>",a+='<button type="button" class="MLK__page-button MLK__page-down" data-page-delta="1" data-l10n-tooltip="keyboard.tooltip.next rows" data-l10n-arial-label="keyboard.tooltip.next rows"><svg class=svg-glyph aria-hidden="true"><use xlink:href=#svg-angle-down /></svg></button>',a+="</div>"}else i.markup&&(a+=i.markup);return i.container&&(a+="</div>"),i.backdrop&&(a+="</div>"),a}(e,n)),o.push("</div>");return o.join("")})(e,i,r)).join("")),a.insertAdjacentHTML("afterbegin",'<div class="MLK__resize-handle" role="separator" tabindex="0" data-l10n-tooltip="keyboard.tooltip.resize" data-l10n-arial-label="keyboard.tooltip.resize"></div>'),null==(i=a.querySelector(".MLK__resize-handle"))||i.addEventListener("pointerdown",i=>{i.stopPropagation(),function(e,i){let r=e.clientY,a=i.plateHeight,o=e.pointerId,n=e.currentTarget instanceof HTMLElement?e.currentTarget:null;i.beginUserResize();try{null==n||n.setPointerCapture(o)}catch(e){}let l=e=>{e.pointerId===o&&(i.setUserHeight(a+r-e.clientY),e.preventDefault())},s=e=>{if(e.pointerId===o){window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",s),window.removeEventListener("pointercancel",s);try{null!=n&&n.hasPointerCapture(o)&&n.releasePointerCapture(o)}catch(e){}i.endUserResize()}};window.addEventListener("pointermove",l,{passive:!1}),window.addEventListener("pointerup",s),window.addEventListener("pointercancel",s),e.preventDefault()}(i,e)}),a.querySelectorAll(".MLK__page-button").forEach(i=>i.addEventListener("pointerdown",r=>{var a;r.stopPropagation(),e.pageRows(Number(null!=(a=i.dataset.pageDelta)?a:0)),r.preventDefault()}));let o=document.createElement("div");o.className="MLK__backdrop",o.appendChild(a),r.appendChild(o),r.addEventListener("pointerdown",s7,{passive:!1});let n=r.querySelectorAll(".ML__edit-toolbar");if(n)for(let i of n)i.addEventListener("click",i=>{var r,a;let o=i.target,n="";for(;o&&!n;)n=null!=(r=null==o?void 0:o.getAttribute("data-command"))?r:"",o=null!=(a=null==o?void 0:o.parentElement)?a:null;n&&e.executeCommand(JSON.parse(n))});for(let e of r.querySelectorAll(".MLK__keycap, .action, .fnbutton, .bigfnbutton"))!function(e){let i=cr.singleton;if(!i)return;let r={};if(!e.id){if(e.hasAttribute("data-label")&&(r.label=e.dataset.label),e.hasAttribute("data-latex")&&(r.latex=e.dataset.latex),e.hasAttribute("data-key")&&(r.key=e.dataset.key),e.hasAttribute("data-insert")&&(r.insert=e.dataset.insert),e.hasAttribute("data-variants")&&(r.variants=e.dataset.variants),e.hasAttribute("data-aside")&&(r.aside=e.dataset.aside),e.className&&(r.class=e.className),r.label||r.latex||r.key||r.insert||(r.latex=e.innerText,r.label=e.innerHTML),e.hasAttribute("data-command"))try{r.command=JSON.parse(e.dataset.command)}catch(e){console.warn("Invalid JSON in data-command attribute",e)}e.id=i.registerKeycap(r)}if(!e.innerHTML){let[i,a]=s6(r);e.innerHTML=globalThis.MathfieldElement.createHTML(i)}}(e);let l=r.querySelectorAll(".MLK__layer");for(let e of(l.length,l))e.addEventListener("pointerdown",e=>e.preventDefault());return e.currentLayer=e.latentLayer,I.update(r),r}(this),window.addEventListener("contextmenu",this,{capture:!0}),this.element.addEventListener("contextmenu",e=>{e.shiftKey||((e.ctrlKey||2===e.button)&&sY(e.target),e.preventDefault(),e.stopPropagation())},{capture:!0}),null==(e=this.container)||e.appendChild(this.element),null!==this.userHeight){let e=this.element.querySelector(".MLK__plate");e&&(e.style.height=`${this.userHeight}px`)}}handleEvent(e){if(sW(e)){if(!np(e.origin,this.originValidator))throw new DOMException(`Message from unknown origin (${e.origin}) cannot be handled`,"SecurityError");if("disconnect"===e.data.action){if(this._visible)return;this.connectedMathfieldWindow=void 0}else"update-setting"!==e.data.action&&"proxy-created"!==e.data.action&&"execute-command"!==e.data.action&&(e.source,this.connectedMathfieldWindow=e.source);this.handleMessage(e.data,e.source)}if(this._element)switch(e.type){case"mouseup":case"blur":document.body.style.userSelect="",this.shiftPressCount=0;break;case"contextmenu":2!==e.button&&e.preventDefault();break;case"keydown":"Shift"!==e.key||e.repeat||(this.shiftPressCount=1);break;case"keyup":"Shift"!==e.key&&(e.getModifierState("Shift")||2===this.shiftPressCount)||(this.shiftPressCount=0)}}handleMessage(e,i){let{action:r}=e;if("execute-command"===r){let{command:r}=e,a=sV(r);if(window===window.top&&i!==window||i===window&&"virtual-keyboard"!==a)return;this.executeCommand(r);return}if(("connect"===r||"show"===r)&&this.sendMessage("synchronize-proxy",{boundingRect:this.boundingRect,alphabeticLayout:this._alphabeticLayout,layouts:this._layouts,editToolbar:this._editToolbar},i),"disconnect"!==r&&!this.isSandbox){if("show"===r)return void(void 0!==e.animate?this.show({animate:e.animate}):this.show());if("hide"===r)return void(void 0!==e.animate?this.hide({animate:e.animate}):this.hide());if("update-setting"===r){if(e.alphabeticLayout&&(this.alphabeticLayout=e.alphabeticLayout),e.layouts&&(this.layouts=e.layouts),e.editToolbar&&(this.editToolbar=e.editToolbar),e.setKeycap){let{keycap:i,value:r}=e.setKeycap;this.setKeycap(i,r),this.render()}return}if("proxy-created"===r)return void this.sendMessage("synchronize-proxy",{boundingRect:this.boundingRect,alphabeticLayout:this._alphabeticLayout,layouts:this._layouts,editToolbar:this._editToolbar},i)}}sendMessage(e,i,r){if(i.command&&this.dispatchEvent(new CustomEvent("math-virtual-keyboard-command",{detail:i.command})),r||(r=this.connectedMathfieldWindow),null===this.targetOrigin||"null"===this.targetOrigin||r===window)return void window.dispatchEvent(new MessageEvent("message",{source:window,origin:window.origin,data:f({type:sH,action:e},i)}));if(r)r.postMessage(f({type:sH,action:e},i),{targetOrigin:this.targetOrigin});else if("execute-command"===e&&Array.isArray(i.command)&&"insert"===i.command[0])for(let e of i.command[1].split(""))this.dispatchEvent(new KeyboardEvent("keydown",{key:e,bubbles:!0})),this.dispatchEvent(new KeyboardEvent("keyup",{key:e,bubbles:!0}))}stateWillChange(e){return this.dispatchEvent(new CustomEvent("before-virtual-keyboard-toggle",{detail:{visible:e},bubbles:!0,cancelable:!0,composed:!0}))}stateChanged(){this.dispatchEvent(new Event("virtual-keyboard-toggle")),this._visible||(this.dispatchEvent(new Event("geometrychange")),this.sendMessage("geometry-changed",{boundingRect:this.boundingRect}))}focus(){this.sendMessage("focus",{})}blur(){this.sendMessage("blur",{})}updateToolbar(e){let i=this._element;if(!i)return;i.classList.toggle("is-math-mode","math"===e.mode),i.classList.toggle("is-text-mode","text"===e.mode),i.classList.toggle("can-undo",e.canUndo),i.classList.toggle("can-redo",e.canRedo),i.classList.toggle("can-copy",!e.selectionIsCollapsed),i.classList.toggle("can-cut",!e.selectionIsCollapsed),i.classList.toggle("can-paste",!0);let r=i.querySelectorAll(".ML__edit-toolbar");if(r)for(let i of r)i.innerHTML=function(e,i){let r="";if("none"===e.editToolbar)return"";let a=[];i.selectionIsCollapsed?a.push("undo","redo","pasteFromClipboard"):a.push("cutToClipboard","copyToClipboard","pasteFromClipboard");let o={undo:`<div class='action ${!1===i.canUndo?"disabled":""}'
|
|
3301
3301
|
data-command='"undo"'
|
|
3302
3302
|
data-tooltip='${N("tooltip.undo")}'>
|
|
3303
3303
|
<svg><use xlink:href='#svg-undo' /></svg>
|
|
@@ -3329,29 +3329,29 @@ ${i}
|
|
|
3329
3329
|
data-tooltip='${N("tooltip.toggle virtual keyboard")}'>
|
|
3330
3330
|
<svg><use xlink:href='#svg-keyboard-down' /></svg>
|
|
3331
3331
|
</div>
|
|
3332
|
-
`};return a.push("hideVirtualKeyboard"),r+=a.map(e=>o[e]).join("")}(this,e)}update(e){this._style=e.style,this.updateToolbar(e)}connect(){this.connectedMathfieldWindow=window}disconnect(){this._visible||(this.connectedMathfieldWindow=void 0)}executeCommand(e){if(!(e=sV(e)))return!1;let i,r=[],a=sF(e);return R(e)?("performWithFeedback"===(i=e[0])&&(a=sF(e.slice(1))),r=e.slice(1)):i=e,"virtual-keyboard"===a?sW[i].fn(void 0,...r):(this.sendMessage("execute-command",{command:e}),!1)}dispose(){window.removeEventListener("mouseup",this),window.removeEventListener("blur",this),window.removeEventListener("message",this)}};function cr(){let e=l9(),i=null;for(;e;){if("host"in e&&e.host instanceof uE){i=e.host;break}e=e.parentNode}return i}function ca(){let e=ci.singleton;return window.mathVirtualKeyboard!==e&&Object.defineProperty(window,"mathVirtualKeyboard",{get:()=>e}),e}function co(e){let i={};for(let r of Object.keys(e))switch(r){case"scriptDepth":let a=e.scriptDepth;if(R(a))i.scriptDepth=[a[0],a[1]];else if("number"==typeof a)i.scriptDepth=[a,a];else if("string"==typeof a){let[e,r]=a.split(",").map(e=>parseInt(e.trim()));i.scriptDepth=[e,r]}else throw TypeError("Unexpected value for scriptDepth");break;case"mathVirtualKeyboardPolicy":let o=e.mathVirtualKeyboardPolicy.toLowerCase();if("sandboxed"===o){let e=ca();e&&(e.isSandbox=!0),o="manual"}i.mathVirtualKeyboardPolicy=o;break;case"letterShapeStyle":"auto"===e.letterShapeStyle?I.locale.startsWith("fr")?i.letterShapeStyle="french":i.letterShapeStyle="tex":i.letterShapeStyle=e.letterShapeStyle;break;case"defaultMode":["text","math","inline-math"].includes(e.defaultMode)?i.defaultMode=e.defaultMode:(console.error('MathLive 0.110.9: valid values for defaultMode are "text", "math" or "inline-math"'),i.defaultMode="math");break;case"macros":i.macros=ek(e.macros);break;default:R(e[r])?i[r]=[...e[r]]:"object"!=typeof e[r]||e[r]instanceof Element||"computeEngine"===r?i[r]=e[r]:i[r]=f({},e[r])}return i}function cn(e,i){let r;r="string"==typeof i?[i]:void 0===i?Object.keys(e):i;let a={};for(let i of r)null===e[i]?a[i]=null:R(e[i])?a[i]=[...e[i]]:"object"!=typeof e[i]||e[i]instanceof Element||"computeEngine"===i?a[i]=e[i]:a[i]=f({},e[i]);return"string"==typeof i?a[i]:a}function cl(){return{readOnly:!1,defaultMode:"math",macros:{},registers:{},colorMap:U,backgroundColorMap:J,letterShapeStyle:I.locale.startsWith("fr")?"french":"tex",minFontScale:0,maxMatrixCols:10,smartMode:!1,smartFence:!0,smartSuperscript:!0,scriptDepth:[1/0,1/0],removeExtraneousParentheses:!0,isImplicitFunction:e=>["\\sin","\\cos","\\tan","\\arcsin","\\arccos","\\arctan","\\arcsec","\\arccsc","\\arsinh","\\arcosh","\\artanh","\\arcsech","\\arccsch","\\arg","\\ch","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\sec","\\sinh","\\sh","\\tanh","\\tg","\\th","\\lg","\\lb","\\log","\\ln"].includes(e),mathModeSpace:"",placeholderSymbol:"▢",contentPlaceholder:"",popoverPolicy:"auto",environmentPopoverPolicy:"off",keybindings:no,inlineShortcuts:o3,inlineShortcutTimeout:0,mathVirtualKeyboardPolicy:"auto",originValidator:"none",onInsertStyle:sc,onInlineShortcut:()=>"",onScrollIntoView:null,onExport:ni,value:""}}function cs(e){return"inline-math"===e.defaultMode?"math":e.defaultMode}function cc(e,i,r){let a=e.getCell(i,r);return(null==a?void 0:a.length)===2&&"placeholder"===a[1].type}function cd(e,i,r,a){let o,n=(o=i.getCell(r,a))?[e.offsetOf(o[0]),e.offsetOf(o[o.length-1])]:-1;"number"!=typeof n&&e.setSelection(n)}function cu(e,i,r,a,o){let n=i.getCell(r,a);n&&e.setPositionHandlingPlaceholder(e.offsetOf(n["start"===o?0:n.length-1]))}function ch(e,i){let[r,[a,o]]=function(e,i){let r=e.at(e.position);for(;r&&!(r.parent instanceof nQ);)r=r.parent;if((null==r?void 0:r.type)==="array"&&r.environmentName,!r||!(r.parent instanceof nQ)){let a=e.at(e.position);if(!(r=a).parent.parent){let r=e.extractAtoms([e.position,e.lastOffset]),o=e.extractAtoms([0,e.position]),n;return i.endsWith("column")?(0===o.length&&(o=cb()),0===r.length&&(r=cb()),e.root=n=lV("split",[[o,r]]),cc(n,0,0)?cd(e,n,0,0):cc(n,0,1)?cd(e,n,0,1):e.position=e.offsetOf(a)):(e.root=n=lV("lines",[[o],[r]]),cd(e,n,1,0)),[void 0,[0,0]]}if(r.parent instanceof le){let a=r.parent,o=e.extractAtoms([e.position,e.offsetOf(a.lastChild)]),n=e.extractAtoms([e.offsetOf(a.firstChild),e.position]);0===n.length&&(n=cb()),0===o.length&&(o=cb());let l="pmatrix",s=a.leftDelim,c=a.rightDelim;"("===s&&(")"===c||"?"===c)?l="pmatrix":("["===s||"\\lbrack"===s)&&("]"===c||"\\rbrack"===c||"?"===c)?l="bmatrix":"\\vert"===s&&"\\vert"===c?l="vmatrix":"\\Vert"===s&&"\\Vert"===c?l="Vmatrix":("{"===s||"\\lbrace"===s)&&("."===c||"?"===c)&&(l="cases");let d=lV(l,i.endsWith("column")?[[n,o]]:[[n],[o]]);return a.parent.addChildBefore(d,a),a.parent.removeChild(a),cc(d,0,0)?cd(e,d,0,0):i.endsWith("column")?cc(d,0,1)?cd(e,d,0,1):e.position=e.offsetOf(r):cc(d,1,0)?cd(e,d,1,0):e.position=e.offsetOf(r),[void 0,[0,0]]}}return r&&r.parent instanceof nQ?[r.parent,r.parentBranch]:[void 0,[0,0]]}(e,i);if(r)switch(i){case"after row":r.addRowAfter(a),cu(e,r,a+1,0,"end");break;case"after column":if(r.maxColumns<=r.colCount)return void e.announce("plonk");r.addColumnAfter(o),cu(e,r,a,o+1,"end");break;case"before row":r.addRowBefore(a),cu(e,r,a,0,"start");break;case"before column":if(r.maxColumns<=r.colCount)return void e.announce("plonk");r.addColumnBefore(o),cu(e,r,a,o,"start")}}function cp(e){var i;let r=e.at(e.position);if(!oX(r.parentBranch)&&r.parent!==e.root&&"root"!==e.root.type)return e.announce("plonk"),!1;if(!e.contentWillChange({inputType:"insertText"}))return!1;if(null!=(i=e.parentEnvironment)&&i.isMultiline){e.selectionIsCollapsed||e.deleteAtoms(oQ(e.selection));let[i,r]=function(e){let i=e.at(e.position);for(;i&&!oX(i.parentBranch);)i=i.parent;return[i.firstSibling,i.lastSibling]}(e),a=e.extractAtoms([e.position,e.offsetOf(r)]),o=e.extractAtoms([e.offsetOf(i),e.position]),n=i.parent,[l,s]=i.parentBranch;return n.setCell(l,s,o),ch(e,"after row"),n.setCell(l+1,s,a),e.position=e.offsetOf(n.getCell(l+1,s)[0]),e.contentDidChange({inputType:"insertText"}),!0}return ch(e,"after row"),e.contentDidChange({inputType:"insertText"}),!0}function cm(e){return!!e.contentWillChange({inputType:"insertText"})&&(ch(e,"after column"),e.contentDidChange({inputType:"insertText"}),!0)}function cf(e,i){if(!e.contentWillChange({}))return!1;e.mathfield.snapshot();let r=".",a=".";switch(i){case"pmatrix":case"pmatrix*":r="(",a=")";break;case"bmatrix":case"bmatrix*":r="[",a="]";break;case"Bmatrix":case"Bmatrix*":r="\\lbrace",a="\\rbrace";break;case"vmatrix":case"vmatrix*":r="\\vert",a="\\vert";break;case"Vmatrix":case"Vmatrix*":r="\\Vert",a="\\Vert";break;case"matrix":case"matrix*":r=".",a=".";break;case"cases":case"dcases":r="\\lbrace";break;case"rcases":a="\\rbrace"}let o=e.at(e.position),n="array"===o.type?o:e.parentEnvironment;return n.environmentName=i,n.leftDelim=r,n.rightDelim=a,e.contentDidChange({}),!0}function cg(e,i){let r=e.at(e.position);for(;r&&!(Array.isArray(r.parentBranch)&&r.parent instanceof nQ);)r=r.parent;if(Array.isArray(null==r?void 0:r.parentBranch)&&(null==r?void 0:r.parent)instanceof nQ){let a=r.parent,o=r.parentBranch,n;switch(i){case"row":if(a.rowCount>1){a.removeRow(o[0]);let i=a.getCell(Math.max(0,o[0]-1),o[1]);n=e.offsetOf(i[i.length-1])}break;case"column":if(a.colCount>a.minColumns){a.removeColumn(o[1]);let i=a.getCell(o[0],Math.max(0,o[1]-1));n=e.offsetOf(i[i.length-1])}}void 0!==n&&e.setPositionHandlingPlaceholder(n)}}function cb(){return[new nU]}!v()||"mathVirtualKeyboard"in window||(window===window.top?ca():Object.defineProperty(window,"mathVirtualKeyboard",{get:()=>sJ.singleton,configurable:!0})),sN({addRowAfter:cp,addColumnAfter:cm,addRowBefore:function(e){return!!e.contentWillChange({inputType:"insertText"})&&(ch(e,"before row"),e.contentDidChange({inputType:"insertText"}),!0)},addColumnBefore:function(e){return!!e.contentWillChange({inputType:"insertText"})&&(ch(e,"before column"),e.contentDidChange({inputType:"insertText"}),!0)},removeRow:function(e){return!!e.contentWillChange({inputType:"deleteContent"})&&(cg(e,"row"),e.contentDidChange({inputType:"deleteContent"}),!0)},removeColumn:function(e){return!!e.contentWillChange({inputType:"deleteContent"})&&(cg(e,"column"),e.contentDidChange({inputType:"deleteContent"}),!0)},setEnvironment:cf},{target:"model",canUndo:!0,changeContent:!0,changeSelection:!0});var cy=class e{constructor(e){this.recording=!1,this.model=e,this.reset()}reset(){this.stack=[],this.index=-1,this.lastOp=""}startRecording(){this.recording=!0}stopRecording(){this.recording=!1}canUndo(){return this.index-1>=0}canRedo(){return this.stack.length-1>this.index}stopCoalescing(e){e&&this.index>=0&&(this.stack[this.index].selection=e),this.lastOp=""}undo(){if(!this.canUndo())return!1;let e=this.stack[this.index-1];return this.index-=1,this.lastOp="",this.model.setState(e,{silenceNotifications:!1,type:"undo"}),!0}redo(){if(!this.canRedo())return!1;let e=this.stack[this.index+1];return this.index+=1,this.lastOp="",this.model.setState(e,{silenceNotifications:!1,type:"redo"}),!0}pop(){this.canUndo()&&(this.stack.splice(this.index,this.stack.length-this.index),this.index-=1)}snapshot(i){return!!this.recording&&(i&&i===this.lastOp&&this.pop(),this.stack.splice(this.index+1,this.stack.length-this.index-1),this.stack.push(this.model.getState()),this.index+=1,this.stack.length>e.maximumDepth&&(this.stack.shift(),this.index-=1),this.lastOp=null!=i?i:"",!0)}};function cv(e,i,r,a){var o,n,l,s,c,d;let u=r.parent;if(oX(a)&&r instanceof nQ&&r.isMultiline&&function(e,i,r,a){if(!(i instanceof nQ)||!i.isMultiline||1===i.rows.length||i.rows[r].length>1)return!1;let o=i.getCell(r,0);if(!o)return!1;if(i.removeRow(r),"backward"===a){let a=i.getCell(r-1,0);if(!a)return e.position=e.offsetOf(i),!0;a.length>0?e.position=e.offsetOf(a[a.length-1]):e.position=e.offsetOf(i),i.setCell(r-1,0,[...a,...o])}else{let a=i.getCell(r,0);if(!a)return e.position=e.offsetOf(i),!0;a.length>0?e.position=e.offsetOf(a[0]):e.position=e.offsetOf(i),i.setCell(r,0,[...o,...a])}return!0}(e,r,a[0],i))return!0;if(u&&r instanceof le){let o=!a&&"forward"===i||"body"===a&&"backward"===i,n=o?e.offsetOf(r.firstChild):e.offsetOf(r.lastChild);return o?"?"!==r.rightDelim&&"."!==r.rightDelim?(r.leftDelim=".",r.isDirty=!0):(u.addChildrenAfter(r.removeBranch("body"),r),u.removeChild(r),n--):"?"!==r.leftDelim&&"."!==r.leftDelim?(r.rightDelim=".",r.isDirty=!0):(u.addChildrenAfter(r.removeBranch("body"),r),u.removeChild(r),n--),e.position=n,!0}if(u&&"surd"===r.type){if(("forward"!==i||a)&&("backward"!==i||"body"!==a))"forward"===i&&"body"===a?e.position=e.offsetOf(r):a||"backward"!==i?"above"===a&&(r.hasEmptyBranch("above")&&r.removeBranch("above"),"backward"===i?e.position=e.offsetOf(r.leftSibling):e.position=e.offsetOf(r.body[0])):r.hasChildren?e.position=e.offsetOf(r.lastChild):(e.position=Math.max(0,e.offsetOf(r)-1),u.removeChild(r));else{let i=r.leftSibling;r.hasChildren&&u.addChildrenAfter(r.removeBranch("body"),r),u.removeChild(r),e.position=e.offsetOf(i)}return!0}if(u&&("box"===r.type||"enclose"===r.type)){let o=a&&"backward"===i||!a&&"forward"===i?r.leftSibling:r.lastChild;return u.addChildrenAfter(r.removeBranch("body"),r),u.removeChild(r),e.position=e.offsetOf(o),!0}if("genfrac"===r.type||"overunder"===r.type){if(!a)return!("overunder"===r.type&&r.hasEmptyBranch("body")||"genfrac"===r.type&&r.hasEmptyBranch("below")&&r.hasEmptyBranch("above"))&&(e.position=e.offsetOf("forward"===i?r.firstChild:r.lastChild),!0);let o="numerator-denominator"===uE.fractionNavigationOrder?"above":"below",n="above"===o?"below":"above";if(u&&("forward"===i&&a===o||"backward"===i&&a===n)){let i=r.removeBranch(o),a=r.removeBranch(n);return u.addChildrenAfter([...i,...a],r),u.removeChild(r),e.position=e.offsetOf(i.length>0?i[i.length-1]:a[0]),!0}return"backward"===i?e.position=e.offsetOf(r.leftSibling):e.position=e.offsetOf(r),!0}if("extensible-symbol"===r.type||"subsup"===r.type||"operator"===r.type){if(!a&&"forward"===i)return!1;if(!a){if(r.subscript||r.superscript){let a="forward"===i?null!=(l=null==(o=r.superscript)?void 0:o[0])?l:null==(n=r.subscript)?void 0:n[0]:null!=(d=null==(s=r.subscript)?void 0:s[0].lastSibling)?d:null==(c=r.superscript)?void 0:c[0].lastSibling;return a&&(e.position=e.offsetOf(a)),!0}return!1}if(!r.hasChildren&&"subsup"===r.type){let a="forward"===i?e.offsetOf(r):Math.max(0,e.offsetOf(r)-1);return r.parent.removeChild(r),e.position=a,!0}if(a&&r.hasEmptyBranch(a)){if(r.removeBranch(a),"subsup"===r.type&&!r.subscript&&!r.superscript){let a="forward"===i?e.offsetOf(r):Math.max(0,e.offsetOf(r)-1);return r.parent.removeChild(r),e.position=a,!0}return"superscript"===a&&"backward"===i?e.position=e.offsetOf(r.firstChild)-1:"subscript"===a&&"backward"===i?r.superscript?e.position=e.offsetOf(r.superscript[0].lastSibling):e.position=e.offsetOf(r.firstChild)-1:e.position=e.offsetOf(r),!0}if("superscript"===a)if("backward"===i){let i=e.offsetOf(r.firstChild)-1;e.position=i}else r.subscript?e.position=e.offsetOf(r.subscript[0]):e.position=e.offsetOf(r);else"subscript"===a&&("backward"===i&&r.superscript?e.position=e.offsetOf(r.superscript[0].lastSibling):"backward"===i?e.position=e.offsetOf(r.firstChild)-1:e.position=e.offsetOf(r));return!0}if((null==u?void 0:u.type)==="genfrac"&&!a&&"first"!==r.type){let i=e.offsetOf(r.leftSibling);return u.removeChild(r),u.hasEmptyBranch("above")&&u.hasEmptyBranch("below")?(i=e.offsetOf(u.leftSibling),u.parent.removeChild(u),e.announce("delete",void 0,[u])):e.announce("delete",void 0,[r]),e.position=i,!0}if("backward"===i&&((null==u?void 0:u.command)==="\\ln"||(null==u?void 0:u.command)==="\\log")&&"body"!==r.parentBranch){let i=e.offsetOf(u.leftSibling);return u.parent.removeChild(u),e.announce("delete",void 0,[u]),e.position=i,!0}return!1}function cx(e,i,r){let a=e.getAtoms(i);if(a.length>0&&a[0].parent){let o=a[0];for(;o&&!(o instanceof nQ);)o=o.parent;let n=a[a.length-1];for(;n&&!(n instanceof nQ);)n=n.parent;if(o&&o instanceof nQ){let i=o;if(i&&n===i&&i.isMultiline){let[a,o]=[Math.min(e.position,e.anchor),Math.max(e.position,e.anchor)],[n,l]=e.at(a).parentBranch,[s,c]=e.at(o).parentBranch;if(s-n+1>=2)return e.deferNotifications({content:!0,selection:!0,type:r},()=>{var r;let d=i.getCell(n,l),u=i.getCell(s,c);if(!d||!u)return;e.extractAtoms([a,o]);let h=i.getCell(n,l);i.getCell(s,c);for(let e=s-1;e>n;e--)i.removeRow(e);if(n!==s){let e=i.getCell(n+1,l);if(h&&e){let r=[...h.filter(e=>"first"!==e.type),...e.filter(e=>"first"!==e.type)];i.setCell(n,l,r),i.removeRow(n+1)}}let p=i.getCell(n,l);if(p){let i=h?h.filter(e=>"first"!==e.type).length:0;e.position=e.offsetOf(null!=(r=p[i])?r:p[0])}else e.position=a;i.isDirty=!0})}}let l=a[0].parent.firstChild;"first"===l.type&&(l=l.rightSibling);let s=a[a.length-1].parent.lastChild,c=a[0];"first"===c.type&&(c=c.rightSibling);let d=a[a.length-1];if(c===l&&d===s){let r=a[0].parent;r.parent&&"prompt"!==r.type&&(i=[e.offsetOf(r.leftSibling),e.offsetOf(r)])}if(1===a.length&&"placeholder"===a[0].type&&"genfrac"===a[0].parent.type){let i=a[0].parent,o="below"===a[0].parentBranch?"above":"below",n=e.offsetOf(i.leftSibling);return e.deferNotifications({content:!0,selection:!0,type:r},()=>{var r,a;let l=i.removeBranch(o);if(1===l.length&&"placeholder"===l[0].type)null==(a=i.parent)||a.removeChild(i),e.position=Math.max(0,n);else{let a=i.parent.addChildrenAfter(l,i);null==(r=i.parent)||r.removeChild(i),e.position=e.offsetOf(a)}})}}return e.deferNotifications({content:!0,selection:!0,type:r},()=>{let r=new Map;if(a.length>0){let e=a[0],i=a[a.length-1],o=new Set,n=e.parent;for(;n;)("surd"===n.type||"box"===n.type||"enclose"===n.type||"leftright"===n.type||"genfrac"===n.type||"overunder"===n.type)&&n.parent&&o.add(n),n=n.parent;let l=new Set;for(n=i.parent;n;)("surd"===n.type||"box"===n.type||"enclose"===n.type||"leftright"===n.type||"genfrac"===n.type||"overunder"===n.type)&&n.parent&&l.add(n),n=n.parent;for(let e of a)for(n=e.parent;n;){if(("surd"===n.type||"box"===n.type||"enclose"===n.type||"leftright"===n.type||"genfrac"===n.type||"overunder"===n.type)&&n.parent){r.has(n)||r.set(n,{containsStart:o.has(n),containsEnd:l.has(n)});break}n=n.parent}}let o=Math.min(...i);for(let[a,o]of(e.deleteAtoms(i),r)){if(!a.parent)continue;let i=o.containsStart!==o.containsEnd;if("surd"===a.type||"box"===a.type||"enclose"===a.type||"leftright"===a.type){let r=a.branch("body");if(r&&0!==r.length&&(1!==r.length||"placeholder"!==r[0].type)){if(i&&!o.containsStart&&o.containsEnd){let i=e.offsetOf(a.leftSibling),r=a.removeBranch("body");r&&r.length>0&&a.parent.addChildrenAfter(r,a),a.parent.removeChild(a),e.position=Math.max(0,i)}}else{let i=e.offsetOf(a.leftSibling);a.parent.removeChild(a),e.position=Math.max(0,i)}}if("genfrac"===a.type){let r=a.branch("above"),n=a.branch("below"),l=!r||0===r.length||1===r.length&&"placeholder"===r[0].type,s=!n||0===n.length||1===n.length&&"placeholder"===n[0].type;if(l&&s){let i=e.offsetOf(a.leftSibling);a.parent.removeChild(a),e.position=Math.max(0,i)}else if(l&&!s){let i=e.offsetOf(a.leftSibling),r=a.removeBranch("below");r&&r.length>0&&a.parent.addChildrenAfter(r,a),a.parent.removeChild(a),e.position=Math.max(0,i)}else if(!l&&s){let i=e.offsetOf(a.leftSibling),r=a.removeBranch("above");r&&r.length>0&&a.parent.addChildrenAfter(r,a),a.parent.removeChild(a),e.position=Math.max(0,i)}else if(i&&!o.containsStart&&o.containsEnd&&!l&&!s){let i=e.offsetOf(a.leftSibling),r=a.removeBranch("above");r&&r.length>0&&a.parent.addChildrenAfter(r,a),a.parent.removeChild(a),e.position=Math.max(0,i)}}}0===r.size&&(e.position=o),e.root.hasEmptyBranch("body")&&e.mathfield.flushInlineShortcutBuffer()})}function c_(e,i,r){var a,o,n,l,s,c,d,u;let h=e.position;null!=(a=null==r?void 0:r.extend)&&a||e.collapseSelection(i);let p=e.at(e.position);if("forward"===i&&("subsup"===p.type&&(p=p.rightSibling)||(p=e.at(e.position+1))),!p)return e.announce("plonk"),!1;let m=e.offsetOf(p);if(p instanceof oY)m=function(e,i,r){var a,o;if("text"!==e.at(i).mode)return i;let n="backward"===r?-1:1,l;if(er.test(e.at(i).value)){let r=i,a;do a="text"===e.at(r).mode&&er.test(e.at(r).value),r+=n;while(e.at(r)&&a)l=e.at(r)?r-2*n:r-n}else if(/\s/.test(e.at(i).value)){let r=i;for(;(null==(a=e.at(r))?void 0:a.mode)==="text"&&/\s/.test(e.at(r).value);)r+=n;if(e.at(r)){let i=!0;do i="text"===e.at(r).mode&&!/\s/.test(e.at(r).value),r+=n;while(e.at(r)&&i)l=e.at(r)?r-2*n:r-n}else l=r-n}else{let r=i;for(;(null==(o=e.at(r))?void 0:o.mode)==="text"&&!/\s/.test(e.at(r).value);)r+=n;l=e.at(r)?r:r-n;let a=!0;for(;e.at(r)&&a;)(a="text"===e.at(r).mode&&/\s/.test(e.at(r).value))&&(l=r),r+=n;l=e.at(r)?r-2*n:r-n}return l-(n>0?0:1)}(e,m,i);else if(p instanceof lx)if(p.isSuggestion)for(;p&&p instanceof lx;)p.isSuggestion=!1,m=e.offsetOf(p),p=p.rightSibling;else if("forward"===i){if(!(p=p.rightSibling)||!(p instanceof lx))return e.announce("plonk"),!1;for(;p&&p instanceof lx&&/[a-zA-Z\*]/.test(p.value);)m=e.offsetOf(p),p=p.rightSibling}else{if(!(p=p.leftSibling)||!(p instanceof lx))return e.announce("plonk"),!1;for(;p&&p instanceof lx&&/[a-zA-Z\*]/.test(p.value);)m=e.offsetOf(p),p=p.leftSibling}else if("forward"===i&&"mopen"===p.type){let i=0;do"mopen"===p.type?i+=1:"mclose"===p.type&&(i-=1),p=p.rightSibling;while(!p.isLastSibling&&0!==i)m=e.offsetOf(p.leftSibling)}else if("backward"===i&&"mclose"===p.type){let i=0;do"mopen"===p.type?i+=1:"mclose"===p.type&&(i-=1),p=p.leftSibling;while(!p.isFirstSibling&&0!==i)m=e.offsetOf(p)}else if("backward"===i)if("first"===p.type)for(;m>0&&"first"===p.type;)m-=1,p=e.at(m);else{let i=p.type;"subsup"===p.type&&(m=e.offsetOf(e.at(m).leftSibling)),m-=1;let r=null==(o=e.at(m))?void 0:o.type;for(;m>=0&&r===i;)(null==(n=e.at(m))?void 0:n.type)==="subsup"?m=e.offsetOf(e.at(m).leftSibling):m-=1,r=e.at(m).type}else{let{type:i}=p,r=null==(l=e.at(m))?void 0:l.type,{lastOffset:a}=e;for(;m<=a&&(r===i||"subsup"===r);){for(;(null==(s=e.at(m).rightSibling)?void 0:s.type)==="subsup";)m=e.offsetOf(e.at(m).rightSibling);m+=1,r=null==(c=e.at(m))?void 0:c.type}m-=1}if(null!=(d=null==r?void 0:r.extend)&&d){if(!e.setSelection(e.anchor,m))return e.announce("plonk"),!1;e.announce("move",h)}else{if(m===e.position)return e.announce("plonk"),!1;null!=(u=null==r?void 0:r.delete)&&u?"forward"===i?cx(e,[h,m],"deleteWordForward"):(cx(e,[h,m],"deleteWordBackward"),e.position=m):(e.position=m,e.announce("move",h))}return e.mathfield.stopCoalescingUndo(),!0}function cw(e,i,r){var a,o;if(r=null!=r?r:{extend:!1},e.mathfield.styleBias="backward"===i?"right":"left","forward"!==i){let[i,r]=sl(e);void 0!==i&&void 0!==r&&e.deleteAtoms([i,r])}if("upward"===i)return function(e,i){var r,a;let o=null!=(r=null==i?void 0:i.extend)&&r;o||e.collapseSelection("backward");let n=()=>{var i,r;let a=!0;return e.silenceNotifications||(a=null==(r=null==(i=e.mathfield.host)?void 0:i.dispatchEvent(new CustomEvent("move-out",{detail:{direction:"upward"},cancelable:!0,bubbles:!0,composed:!0})))||r),e.announce(a?"line":"plonk"),a},l=e.at(e.position),s=l;for(;s&&"below"!==s.parentBranch&&!(Array.isArray(s.parentBranch)&&s.parent instanceof nQ);)s=s.parent;if(Array.isArray(null==s?void 0:s.parentBranch)&&s.parent instanceof nQ){let i=s.parent;if(s.parentBranch[0]<1)return n();let r=s.parentBranch[0]-1,a=i.getCell(r,s.parentBranch[1]);if(!a.some(e=>"prompt"===e.type&&!e.captureSelection)&&e.mathfield.hasEditablePrompts)return n();cS(e,l,a,o,"up")}else{if(!s)return n();let i=null!=(a=s.parent.branch("above"))?a:s.parent.createBranch("above");if(!i.some(e=>"prompt"===e.type&&e.placeholderId)&&e.mathfield.hasEditablePrompts)return n();cS(e,l,i,o,"up")}return e.mathfield.stopCoalescingUndo(),!0}(e,r);if("downward"===i)return function(e,i){var r,a;let o=null!=(r=null==i?void 0:i.extend)&&r;o||e.collapseSelection("forward");let n=()=>{var i,r;let a=!0;return e.silenceNotifications||(a=null==(r=null==(i=e.mathfield.host)?void 0:i.dispatchEvent(new CustomEvent("move-out",{detail:{direction:"downward"},cancelable:!0,bubbles:!0,composed:!0})))||r),e.announce(a?"line":"plonk"),a},l=e.at(e.position),s=l;for(;s&&"above"!==s.parentBranch&&!(oX(s.parentBranch)&&s.parent instanceof nQ);)s=s.parent;if(oX(null==s?void 0:s.parentBranch)&&s.parent instanceof nQ){let i=s.parent;if(s.parentBranch[0]+1>i.rows.length-1)return n();let r=s.parentBranch[0]+1,a=i.getCell(r,s.parentBranch[1]);if(!a.some(e=>"prompt"===e.type&&!e.captureSelection)&&e.mathfield.hasEditablePrompts)return n();cS(e,l,a,o,"down")}else{if(!s)return n();let i=null!=(a=s.parent.branch("below"))?a:s.parent.createBranch("below");if(!i.some(e=>"prompt"===e.type)&&e.mathfield.hasEditablePrompts)return n();cS(e,l,i,o,"down")}return!0}(e,r);if(r.extend){let r=ck(e,e.position,i);r<0&&(r=0),r>e.lastOffset&&(r=e.lastOffset);let a=e.setSelection(e.anchor,r);return e.mathfield.stopCoalescingUndo(),a}if(e.selectionIsPlaceholder){e.collapseSelection(i);let r=cw(e,i);return e.mathfield.stopCoalescingUndo(),r}let n=e.position,l=n;if(e.collapseSelection(i)?(n=e.position,cM(e,n)||(n=ck(e,n,i))):n=ck(e,n,i),n<0||n>e.lastOffset){let r=!0;return e.silenceNotifications||(r=null==(o=null==(a=e.mathfield.host)?void 0:a.dispatchEvent(new CustomEvent("move-out",{detail:{direction:i},cancelable:!0,bubbles:!0,composed:!0})))||o),r&&e.announce("plonk"),r}return e.setPositionHandlingPlaceholder(n),e.mathfield.stopCoalescingUndo(),e.announce("move",l),!0}function ck(e,i,r){return(i+="forward"===r?1:-1)<0||i>e.lastOffset||cM(e,i)?i:ck(e,i,r)}function cM(e,i){var r;let a=e.at(i),o=a.parent;for(;o&&!o.inCaptureSelection;)o=o.parent;return!(null!=o&&o.inCaptureSelection||null!=(r=a.parent)&&r.skipBoundary&&(!a.isFirstSibling&&a.isLastSibling||"first"===a.type)||e.mathfield.hasEditablePrompts&&!a.parentPrompt)}function cS(e,i,r,a,o){let n=e.mathfield.hasEditablePrompts,l=n?r.filter(e=>"prompt"===e.type&&!e.captureSelection):r,s=nm(e.mathfield.getHTMLElement(i)).right,c=e.offsetOf(function(e,i,r){let a=1/0,o=0;for(;o<i.length;o++){let n=i[o],l=e.getHTMLElement(n);if(!l)continue;let s=Math.abs(r-nm(l).right);if(s<=a)a=s;else break}return i[o-1]}(e.mathfield,l,s))-!!n;if(a){let[i,r]=e.selection.ranges[0],a;a=c<("up"===o?i:r)?{ranges:[[c,r]],direction:"backward"}:{ranges:[[i,c]],direction:"forward"},e.setSelection(a)}else e.setPositionHandlingPlaceholder(c);e.announce(`move ${o}`)}function cL(e){let i=e.position,r=e.at(i).parent;return null!=r&&r.parent?(e.position=e.offsetOf(r),e.mathfield.stopCoalescingUndo(),e.announce("move",i),!0):(e.announce("plonk"),!1)}function cC(e){if(e.collapseSelection(),function(e){let i=0,r=e.at(e.position),a=!1;for(;r;)r.hasEmptyBranch("superscript")?r.hasEmptyBranch("subscript")||(a=!1):(i+=1,a=!0),r=r.parent;return a?i:0}(e)>=e.mathfield.options.scriptDepth[1])return e.announce("plonk"),!1;let i=e.at(e.position);if(void 0===i.subsupPlacement){let e=i.rightSibling;(null==e?void 0:e.type)!=="subsup"&&(e=new la({style:i.style}),i.parent.addChildAfter(e,i)),i=e}return i.createBranch("superscript"),e.setSelection(e.getSiblingsRange(e.offsetOf(i.superscript[0]))),!0}function cE(e){if(e.collapseSelection(),function(e){let i=0,r=e.at(e.position),a=!1;for(;r;)r.hasEmptyBranch("subscript")?r.hasEmptyBranch("superscript")||(a=!1):(i+=1,a=!0),r=r.parent;return a?i:0}(e)>=e.mathfield.options.scriptDepth[0])return e.announce("plonk"),!1;let i=e.at(e.position);if(void 0===i.subsupPlacement){let e=i.rightSibling;(null==e?void 0:e.type)!=="subsup"&&(e=new la({style:i.style}),i.parent.addChildAfter(e,i)),i=e}return i.createBranch("subscript"),e.setSelection(e.getSiblingsRange(e.offsetOf(i.subscript[0]))),!0}function cA(e,i,r="forward"){let a=e.position;if(R(i)){let o=e.offsetOf(i[0]),n=e.offsetOf(i[i.length-1]);return"forward"===r?e.setSelection(o,n):e.setSelection(n,o),e.announce("move",a),e.mathfield.stopCoalescingUndo(),!0}return"forward"===r?cA(e,[i.leftSibling,i]):cA(e,[i,i.leftSibling])}function cz(e,i){let r=e.position;if("number"==typeof i&&(i=e.at(i)),"prompt"===i.type)e.setSelection(e.offsetOf(i.firstChild),e.offsetOf(i.lastChild));else{let r=e.offsetOf(i);"placeholder"===i.type?e.setSelection(r-1,r):e.position=r}return e.announce("move",r),e.mathfield.stopCoalescingUndo(),!0}function cT(e,i){var r,a;let o="forward"===i?1:-1;"placeholder"===e.at(e.anchor).type&&cw(e,i);let n,l=e.at(e.anchor).parentPrompt;n=l?"forward"===i?e.offsetOf(l)+1:e.offsetOf(l.leftSibling):Math.max(e.position+o,0);let s=cD(e,n,i);if(!s||"forward"===i&&e.offsetOf(s)<n||"backward"===i&&e.offsetOf(s)>n){if(!(null==(a=null==(r=e.mathfield.host)?void 0:r.dispatchEvent(new CustomEvent("move-out",{detail:{direction:i},cancelable:!0,bubbles:!0,composed:!0})))||a))return e.announce("plonk"),!1;let n=function(){var e;let i,r;function a(e){var i;let r=Number.parseInt(null!=(i=e.getAttribute("tabindex"))?i:"NaN",10);return Number.isNaN(r)?"true"===e.contentEditable||("AUDIO"===e.nodeName||"VIDEO"===e.nodeName)&&null===e.getAttribute("tabindex")?0:e.tabIndex:r}return v()?(e=document.body,i=[],r=[],[...e.querySelectorAll(`input, select, textarea, a[href], button,
|
|
3332
|
+
`};return a.push("hideVirtualKeyboard"),r+=a.map(e=>o[e]).join("")}(this,e)}update(e){this._style=e.style,this.updateToolbar(e)}connect(){this.connectedMathfieldWindow=window}disconnect(){this._visible||(this.connectedMathfieldWindow=void 0)}executeCommand(e){if(!(e=sj(e)))return!1;let i,r=[],a=sV(e);return R(e)?("performWithFeedback"===(i=e[0])&&(a=sV(e.slice(1))),r=e.slice(1)):i=e,"virtual-keyboard"===a?sU[i].fn(void 0,...r):(this.sendMessage("execute-command",{command:e}),!1)}dispose(){window.removeEventListener("mouseup",this),window.removeEventListener("blur",this),window.removeEventListener("message",this)}};function ca(){let e=se(),i=null;for(;e;){if("host"in e&&e.host instanceof uA){i=e.host;break}e=e.parentNode}return i}function co(){let e=cr.singleton;return window.mathVirtualKeyboard!==e&&Object.defineProperty(window,"mathVirtualKeyboard",{get:()=>e}),e}function cn(e){let i={};for(let r of Object.keys(e))switch(r){case"scriptDepth":let a=e.scriptDepth;if(R(a))i.scriptDepth=[a[0],a[1]];else if("number"==typeof a)i.scriptDepth=[a,a];else if("string"==typeof a){let[e,r]=a.split(",").map(e=>parseInt(e.trim()));i.scriptDepth=[e,r]}else throw TypeError("Unexpected value for scriptDepth");break;case"mathVirtualKeyboardPolicy":let o=e.mathVirtualKeyboardPolicy.toLowerCase();if("sandboxed"===o){let e=co();e&&(e.isSandbox=!0),o="manual"}i.mathVirtualKeyboardPolicy=o;break;case"letterShapeStyle":"auto"===e.letterShapeStyle?I.locale.startsWith("fr")?i.letterShapeStyle="french":i.letterShapeStyle="tex":i.letterShapeStyle=e.letterShapeStyle;break;case"defaultMode":["text","math","inline-math"].includes(e.defaultMode)?i.defaultMode=e.defaultMode:(console.error('MathLive 0.110.10: valid values for defaultMode are "text", "math" or "inline-math"'),i.defaultMode="math");break;case"macros":i.macros=ek(e.macros);break;default:R(e[r])?i[r]=[...e[r]]:"object"!=typeof e[r]||e[r]instanceof Element||"computeEngine"===r?i[r]=e[r]:i[r]=f({},e[r])}return i}function cl(e,i){let r;r="string"==typeof i?[i]:void 0===i?Object.keys(e):i;let a={};for(let i of r)null===e[i]?a[i]=null:R(e[i])?a[i]=[...e[i]]:"object"!=typeof e[i]||e[i]instanceof Element||"computeEngine"===i?a[i]=e[i]:a[i]=f({},e[i]);return"string"==typeof i?a[i]:a}function cs(){return{readOnly:!1,defaultMode:"math",macros:{},registers:{},colorMap:U,backgroundColorMap:J,letterShapeStyle:I.locale.startsWith("fr")?"french":"tex",minFontScale:0,maxMatrixCols:10,smartMode:!1,smartFence:!0,smartSuperscript:!0,scriptDepth:[1/0,1/0],removeExtraneousParentheses:!0,isImplicitFunction:e=>["\\sin","\\cos","\\tan","\\arcsin","\\arccos","\\arctan","\\arcsec","\\arccsc","\\arsinh","\\arcosh","\\artanh","\\arcsech","\\arccsch","\\arg","\\ch","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\sec","\\sinh","\\sh","\\tanh","\\tg","\\th","\\lg","\\lb","\\log","\\ln"].includes(e),mathModeSpace:"",placeholderSymbol:"▢",contentPlaceholder:"",popoverPolicy:"auto",environmentPopoverPolicy:"off",keybindings:no,inlineShortcuts:o3,inlineShortcutTimeout:0,mathVirtualKeyboardPolicy:"auto",originValidator:"none",onInsertStyle:sd,onInlineShortcut:()=>"",onScrollIntoView:null,onExport:ni,value:""}}function cc(e){return"inline-math"===e.defaultMode?"math":e.defaultMode}function cd(e,i,r){let a=e.getCell(i,r);return(null==a?void 0:a.length)===2&&"placeholder"===a[1].type}function cu(e,i,r,a){let o,n=(o=i.getCell(r,a))?[e.offsetOf(o[0]),e.offsetOf(o[o.length-1])]:-1;"number"!=typeof n&&e.setSelection(n)}function ch(e,i,r,a,o){let n=i.getCell(r,a);n&&e.setPositionHandlingPlaceholder(e.offsetOf(n["start"===o?0:n.length-1]))}function cp(e,i){let[r,[a,o]]=function(e,i){let r=e.at(e.position);for(;r&&!(r.parent instanceof n0);)r=r.parent;if((null==r?void 0:r.type)==="array"&&r.environmentName,!r||!(r.parent instanceof n0)){let a=e.at(e.position);if(!(r=a).parent.parent){let r=e.extractAtoms([e.position,e.lastOffset]),o=e.extractAtoms([0,e.position]),n;return i.endsWith("column")?(0===o.length&&(o=cy()),0===r.length&&(r=cy()),e.root=n=lj("split",[[o,r]]),cd(n,0,0)?cu(e,n,0,0):cd(n,0,1)?cu(e,n,0,1):e.position=e.offsetOf(a)):(e.root=n=lj("lines",[[o],[r]]),cu(e,n,1,0)),[void 0,[0,0]]}if(r.parent instanceof lt){let a=r.parent,o=e.extractAtoms([e.position,e.offsetOf(a.lastChild)]),n=e.extractAtoms([e.offsetOf(a.firstChild),e.position]);0===n.length&&(n=cy()),0===o.length&&(o=cy());let l="pmatrix",s=a.leftDelim,c=a.rightDelim;"("===s&&(")"===c||"?"===c)?l="pmatrix":("["===s||"\\lbrack"===s)&&("]"===c||"\\rbrack"===c||"?"===c)?l="bmatrix":"\\vert"===s&&"\\vert"===c?l="vmatrix":"\\Vert"===s&&"\\Vert"===c?l="Vmatrix":("{"===s||"\\lbrace"===s)&&("."===c||"?"===c)&&(l="cases");let d=lj(l,i.endsWith("column")?[[n,o]]:[[n],[o]]);return a.parent.addChildBefore(d,a),a.parent.removeChild(a),cd(d,0,0)?cu(e,d,0,0):i.endsWith("column")?cd(d,0,1)?cu(e,d,0,1):e.position=e.offsetOf(r):cd(d,1,0)?cu(e,d,1,0):e.position=e.offsetOf(r),[void 0,[0,0]]}}return r&&r.parent instanceof n0?[r.parent,r.parentBranch]:[void 0,[0,0]]}(e,i);if(r)switch(i){case"after row":r.addRowAfter(a),ch(e,r,a+1,0,"end");break;case"after column":if(r.maxColumns<=r.colCount)return void e.announce("plonk");r.addColumnAfter(o),ch(e,r,a,o+1,"end");break;case"before row":r.addRowBefore(a),ch(e,r,a,0,"start");break;case"before column":if(r.maxColumns<=r.colCount)return void e.announce("plonk");r.addColumnBefore(o),ch(e,r,a,o,"start")}}function cm(e){var i;let r=e.at(e.position);if(!oX(r.parentBranch)&&r.parent!==e.root&&"root"!==e.root.type)return e.announce("plonk"),!1;if(!e.contentWillChange({inputType:"insertText"}))return!1;if(null!=(i=e.parentEnvironment)&&i.isMultiline){e.selectionIsCollapsed||e.deleteAtoms(oQ(e.selection));let[i,r]=function(e){let i=e.at(e.position);for(;i&&!oX(i.parentBranch);)i=i.parent;return[i.firstSibling,i.lastSibling]}(e),a=e.extractAtoms([e.position,e.offsetOf(r)]),o=e.extractAtoms([e.offsetOf(i),e.position]),n=i.parent,[l,s]=i.parentBranch;return n.setCell(l,s,o),cp(e,"after row"),n.setCell(l+1,s,a),e.position=e.offsetOf(n.getCell(l+1,s)[0]),e.contentDidChange({inputType:"insertText"}),!0}return cp(e,"after row"),e.contentDidChange({inputType:"insertText"}),!0}function cf(e){return!!e.contentWillChange({inputType:"insertText"})&&(cp(e,"after column"),e.contentDidChange({inputType:"insertText"}),!0)}function cg(e,i){if(!e.contentWillChange({}))return!1;e.mathfield.snapshot();let r=".",a=".";switch(i){case"pmatrix":case"pmatrix*":r="(",a=")";break;case"bmatrix":case"bmatrix*":r="[",a="]";break;case"Bmatrix":case"Bmatrix*":r="\\lbrace",a="\\rbrace";break;case"vmatrix":case"vmatrix*":r="\\vert",a="\\vert";break;case"Vmatrix":case"Vmatrix*":r="\\Vert",a="\\Vert";break;case"matrix":case"matrix*":r=".",a=".";break;case"cases":case"dcases":r="\\lbrace";break;case"rcases":a="\\rbrace"}let o=e.at(e.position),n="array"===o.type?o:e.parentEnvironment;return n.environmentName=i,n.leftDelim=r,n.rightDelim=a,e.contentDidChange({}),!0}function cb(e,i){let r=e.at(e.position);for(;r&&!(Array.isArray(r.parentBranch)&&r.parent instanceof n0);)r=r.parent;if(Array.isArray(null==r?void 0:r.parentBranch)&&(null==r?void 0:r.parent)instanceof n0){let a=r.parent,o=r.parentBranch,n;switch(i){case"row":if(a.rowCount>1){a.removeRow(o[0]);let i=a.getCell(Math.max(0,o[0]-1),o[1]);n=e.offsetOf(i[i.length-1])}break;case"column":if(a.colCount>a.minColumns){a.removeColumn(o[1]);let i=a.getCell(o[0],Math.max(0,o[1]-1));n=e.offsetOf(i[i.length-1])}}void 0!==n&&e.setPositionHandlingPlaceholder(n)}}function cy(){return[new nJ]}!v()||"mathVirtualKeyboard"in window||(window===window.top?co():Object.defineProperty(window,"mathVirtualKeyboard",{get:()=>sX.singleton,configurable:!0})),sq({addRowAfter:cm,addColumnAfter:cf,addRowBefore:function(e){return!!e.contentWillChange({inputType:"insertText"})&&(cp(e,"before row"),e.contentDidChange({inputType:"insertText"}),!0)},addColumnBefore:function(e){return!!e.contentWillChange({inputType:"insertText"})&&(cp(e,"before column"),e.contentDidChange({inputType:"insertText"}),!0)},removeRow:function(e){return!!e.contentWillChange({inputType:"deleteContent"})&&(cb(e,"row"),e.contentDidChange({inputType:"deleteContent"}),!0)},removeColumn:function(e){return!!e.contentWillChange({inputType:"deleteContent"})&&(cb(e,"column"),e.contentDidChange({inputType:"deleteContent"}),!0)},setEnvironment:cg},{target:"model",canUndo:!0,changeContent:!0,changeSelection:!0});var cv=class e{constructor(e){this.recording=!1,this.model=e,this.reset()}reset(){this.stack=[],this.index=-1,this.lastOp=""}startRecording(){this.recording=!0}stopRecording(){this.recording=!1}canUndo(){return this.index-1>=0}canRedo(){return this.stack.length-1>this.index}stopCoalescing(e){e&&this.index>=0&&(this.stack[this.index].selection=e),this.lastOp=""}undo(){if(!this.canUndo())return!1;let e=this.stack[this.index-1];return this.index-=1,this.lastOp="",this.model.setState(e,{silenceNotifications:!1,type:"undo"}),!0}redo(){if(!this.canRedo())return!1;let e=this.stack[this.index+1];return this.index+=1,this.lastOp="",this.model.setState(e,{silenceNotifications:!1,type:"redo"}),!0}pop(){this.canUndo()&&(this.stack.splice(this.index,this.stack.length-this.index),this.index-=1)}snapshot(i){return!!this.recording&&(i&&i===this.lastOp&&this.pop(),this.stack.splice(this.index+1,this.stack.length-this.index-1),this.stack.push(this.model.getState()),this.index+=1,this.stack.length>e.maximumDepth&&(this.stack.shift(),this.index-=1),this.lastOp=null!=i?i:"",!0)}};function cx(e,i,r,a){var o,n,l,s,c,d;let u=r.parent;if(oX(a)&&r instanceof n0&&r.isMultiline&&function(e,i,r,a){if(!(i instanceof n0)||!i.isMultiline||1===i.rows.length||i.rows[r].length>1)return!1;let o=i.getCell(r,0);if(!o)return!1;if(i.removeRow(r),"backward"===a){let a=i.getCell(r-1,0);if(!a)return e.position=e.offsetOf(i),!0;a.length>0?e.position=e.offsetOf(a[a.length-1]):e.position=e.offsetOf(i),i.setCell(r-1,0,[...a,...o])}else{let a=i.getCell(r,0);if(!a)return e.position=e.offsetOf(i),!0;a.length>0?e.position=e.offsetOf(a[0]):e.position=e.offsetOf(i),i.setCell(r,0,[...o,...a])}return!0}(e,r,a[0],i))return!0;if(u&&r instanceof lt){let o=!a&&"forward"===i||"body"===a&&"backward"===i,n=o?e.offsetOf(r.firstChild):e.offsetOf(r.lastChild);return o?"?"!==r.rightDelim&&"."!==r.rightDelim?(r.leftDelim=".",r.isDirty=!0):(u.addChildrenAfter(r.removeBranch("body"),r),u.removeChild(r),n--):"?"!==r.leftDelim&&"."!==r.leftDelim?(r.rightDelim=".",r.isDirty=!0):(u.addChildrenAfter(r.removeBranch("body"),r),u.removeChild(r),n--),e.position=n,!0}if(u&&"surd"===r.type){if(("forward"!==i||a)&&("backward"!==i||"body"!==a))"forward"===i&&"body"===a?e.position=e.offsetOf(r):a||"backward"!==i?"above"===a&&(r.hasEmptyBranch("above")&&r.removeBranch("above"),"backward"===i?e.position=e.offsetOf(r.leftSibling):e.position=e.offsetOf(r.body[0])):r.hasChildren?e.position=e.offsetOf(r.lastChild):(e.position=Math.max(0,e.offsetOf(r)-1),u.removeChild(r));else{let i=r.leftSibling;r.hasChildren&&u.addChildrenAfter(r.removeBranch("body"),r),u.removeChild(r),e.position=e.offsetOf(i)}return!0}if(u&&("box"===r.type||"enclose"===r.type)){let o=a&&"backward"===i||!a&&"forward"===i?r.leftSibling:r.lastChild;return u.addChildrenAfter(r.removeBranch("body"),r),u.removeChild(r),e.position=e.offsetOf(o),!0}if("genfrac"===r.type||"overunder"===r.type){if(!a)return!("overunder"===r.type&&r.hasEmptyBranch("body")||"genfrac"===r.type&&r.hasEmptyBranch("below")&&r.hasEmptyBranch("above"))&&(e.position=e.offsetOf("forward"===i?r.firstChild:r.lastChild),!0);let o="numerator-denominator"===uA.fractionNavigationOrder?"above":"below",n="above"===o?"below":"above";if(u&&("forward"===i&&a===o||"backward"===i&&a===n)){let i=r.removeBranch(o),a=r.removeBranch(n);return u.addChildrenAfter([...i,...a],r),u.removeChild(r),e.position=e.offsetOf(i.length>0?i[i.length-1]:a[0]),!0}return"backward"===i?e.position=e.offsetOf(r.leftSibling):e.position=e.offsetOf(r),!0}if("extensible-symbol"===r.type||"subsup"===r.type||"operator"===r.type){if(!a&&"forward"===i)return!1;if(!a){if(r.subscript||r.superscript){let a="forward"===i?null!=(l=null==(o=r.superscript)?void 0:o[0])?l:null==(n=r.subscript)?void 0:n[0]:null!=(d=null==(s=r.subscript)?void 0:s[0].lastSibling)?d:null==(c=r.superscript)?void 0:c[0].lastSibling;return a&&(e.position=e.offsetOf(a)),!0}return!1}if(!r.hasChildren&&"subsup"===r.type){let a="forward"===i?e.offsetOf(r):Math.max(0,e.offsetOf(r)-1);return r.parent.removeChild(r),e.position=a,!0}if(a&&r.hasEmptyBranch(a)){if(r.removeBranch(a),"subsup"===r.type&&!r.subscript&&!r.superscript){let a="forward"===i?e.offsetOf(r):Math.max(0,e.offsetOf(r)-1);return r.parent.removeChild(r),e.position=a,!0}return"superscript"===a&&"backward"===i?e.position=e.offsetOf(r.firstChild)-1:"subscript"===a&&"backward"===i?r.superscript?e.position=e.offsetOf(r.superscript[0].lastSibling):e.position=e.offsetOf(r.firstChild)-1:e.position=e.offsetOf(r),!0}if("superscript"===a)if("backward"===i){let i=e.offsetOf(r.firstChild)-1;e.position=i}else r.subscript?e.position=e.offsetOf(r.subscript[0]):e.position=e.offsetOf(r);else"subscript"===a&&("backward"===i&&r.superscript?e.position=e.offsetOf(r.superscript[0].lastSibling):"backward"===i?e.position=e.offsetOf(r.firstChild)-1:e.position=e.offsetOf(r));return!0}if((null==u?void 0:u.type)==="genfrac"&&!a&&"first"!==r.type){let i=e.offsetOf(r.leftSibling);return u.removeChild(r),u.hasEmptyBranch("above")&&u.hasEmptyBranch("below")?(i=e.offsetOf(u.leftSibling),u.parent.removeChild(u),e.announce("delete",void 0,[u])):e.announce("delete",void 0,[r]),e.position=i,!0}if("backward"===i&&((null==u?void 0:u.command)==="\\ln"||(null==u?void 0:u.command)==="\\log")&&"body"!==r.parentBranch){let i=e.offsetOf(u.leftSibling);return u.parent.removeChild(u),e.announce("delete",void 0,[u]),e.position=i,!0}return!1}function c_(e,i,r){let a=e.getAtoms(i);if(a.length>0&&a[0].parent){let o=a[0];for(;o&&!(o instanceof n0);)o=o.parent;let n=a[a.length-1];for(;n&&!(n instanceof n0);)n=n.parent;if(o&&o instanceof n0){let i=o;if(i&&n===i&&i.isMultiline){let[a,o]=[Math.min(e.position,e.anchor),Math.max(e.position,e.anchor)],[n,l]=e.at(a).parentBranch,[s,c]=e.at(o).parentBranch;if(s-n+1>=2)return e.deferNotifications({content:!0,selection:!0,type:r},()=>{var r;let d=i.getCell(n,l),u=i.getCell(s,c);if(!d||!u)return;e.extractAtoms([a,o]);let h=i.getCell(n,l);i.getCell(s,c);for(let e=s-1;e>n;e--)i.removeRow(e);if(n!==s){let e=i.getCell(n+1,l);if(h&&e){let r=[...h.filter(e=>"first"!==e.type),...e.filter(e=>"first"!==e.type)];i.setCell(n,l,r),i.removeRow(n+1)}}let p=i.getCell(n,l);if(p){let i=h?h.filter(e=>"first"!==e.type).length:0;e.position=e.offsetOf(null!=(r=p[i])?r:p[0])}else e.position=a;i.isDirty=!0})}}let l=a[0].parent.firstChild;"first"===l.type&&(l=l.rightSibling);let s=a[a.length-1].parent.lastChild,c=a[0];"first"===c.type&&(c=c.rightSibling);let d=a[a.length-1];if(c===l&&d===s){let r=a[0].parent;r.parent&&"prompt"!==r.type&&(i=[e.offsetOf(r.leftSibling),e.offsetOf(r)])}if(1===a.length&&"placeholder"===a[0].type&&"genfrac"===a[0].parent.type){let i=a[0].parent,o="below"===a[0].parentBranch?"above":"below",n=e.offsetOf(i.leftSibling);return e.deferNotifications({content:!0,selection:!0,type:r},()=>{var r,a;let l=i.removeBranch(o);if(1===l.length&&"placeholder"===l[0].type)null==(a=i.parent)||a.removeChild(i),e.position=Math.max(0,n);else{let a=i.parent.addChildrenAfter(l,i);null==(r=i.parent)||r.removeChild(i),e.position=e.offsetOf(a)}})}}return e.deferNotifications({content:!0,selection:!0,type:r},()=>{let r=new Map;if(a.length>0){let e=a[0],i=a[a.length-1],o=new Set,n=e.parent;for(;n;)("surd"===n.type||"box"===n.type||"enclose"===n.type||"leftright"===n.type||"genfrac"===n.type||"overunder"===n.type)&&n.parent&&o.add(n),n=n.parent;let l=new Set;for(n=i.parent;n;)("surd"===n.type||"box"===n.type||"enclose"===n.type||"leftright"===n.type||"genfrac"===n.type||"overunder"===n.type)&&n.parent&&l.add(n),n=n.parent;for(let e of a)for(n=e.parent;n;){if(("surd"===n.type||"box"===n.type||"enclose"===n.type||"leftright"===n.type||"genfrac"===n.type||"overunder"===n.type)&&n.parent){r.has(n)||r.set(n,{containsStart:o.has(n),containsEnd:l.has(n)});break}n=n.parent}}let o=Math.min(...i);for(let[a,o]of(e.deleteAtoms(i),r)){if(!a.parent)continue;let i=o.containsStart!==o.containsEnd;if("surd"===a.type||"box"===a.type||"enclose"===a.type||"leftright"===a.type){let r=a.branch("body");if(r&&0!==r.length&&(1!==r.length||"placeholder"!==r[0].type)){if(i&&!o.containsStart&&o.containsEnd){let i=e.offsetOf(a.leftSibling),r=a.removeBranch("body");r&&r.length>0&&a.parent.addChildrenAfter(r,a),a.parent.removeChild(a),e.position=Math.max(0,i)}}else{let i=e.offsetOf(a.leftSibling);a.parent.removeChild(a),e.position=Math.max(0,i)}}if("genfrac"===a.type){let r=a.branch("above"),n=a.branch("below"),l=!r||0===r.length||1===r.length&&"placeholder"===r[0].type,s=!n||0===n.length||1===n.length&&"placeholder"===n[0].type;if(l&&s){let i=e.offsetOf(a.leftSibling);a.parent.removeChild(a),e.position=Math.max(0,i)}else if(l&&!s){let i=e.offsetOf(a.leftSibling),r=a.removeBranch("below");r&&r.length>0&&a.parent.addChildrenAfter(r,a),a.parent.removeChild(a),e.position=Math.max(0,i)}else if(!l&&s){let i=e.offsetOf(a.leftSibling),r=a.removeBranch("above");r&&r.length>0&&a.parent.addChildrenAfter(r,a),a.parent.removeChild(a),e.position=Math.max(0,i)}else if(i&&!o.containsStart&&o.containsEnd&&!l&&!s){let i=e.offsetOf(a.leftSibling),r=a.removeBranch("above");r&&r.length>0&&a.parent.addChildrenAfter(r,a),a.parent.removeChild(a),e.position=Math.max(0,i)}}}0===r.size&&(e.position=o),e.root.hasEmptyBranch("body")&&e.mathfield.flushInlineShortcutBuffer()})}function cw(e,i,r){var a,o,n,l,s,c,d,u;let h=e.position;null!=(a=null==r?void 0:r.extend)&&a||e.collapseSelection(i);let p=e.at(e.position);if("forward"===i&&("subsup"===p.type&&(p=p.rightSibling)||(p=e.at(e.position+1))),!p)return e.announce("plonk"),!1;let m=e.offsetOf(p);if(p instanceof oY)m=function(e,i,r){var a,o;if("text"!==e.at(i).mode)return i;let n="backward"===r?-1:1,l;if(er.test(e.at(i).value)){let r=i,a;do a="text"===e.at(r).mode&&er.test(e.at(r).value),r+=n;while(e.at(r)&&a)l=e.at(r)?r-2*n:r-n}else if(/\s/.test(e.at(i).value)){let r=i;for(;(null==(a=e.at(r))?void 0:a.mode)==="text"&&/\s/.test(e.at(r).value);)r+=n;if(e.at(r)){let i=!0;do i="text"===e.at(r).mode&&!/\s/.test(e.at(r).value),r+=n;while(e.at(r)&&i)l=e.at(r)?r-2*n:r-n}else l=r-n}else{let r=i;for(;(null==(o=e.at(r))?void 0:o.mode)==="text"&&!/\s/.test(e.at(r).value);)r+=n;l=e.at(r)?r:r-n;let a=!0;for(;e.at(r)&&a;)(a="text"===e.at(r).mode&&/\s/.test(e.at(r).value))&&(l=r),r+=n;l=e.at(r)?r-2*n:r-n}return l-(n>0?0:1)}(e,m,i);else if(p instanceof l_)if(p.isSuggestion)for(;p&&p instanceof l_;)p.isSuggestion=!1,m=e.offsetOf(p),p=p.rightSibling;else if("forward"===i){if(!(p=p.rightSibling)||!(p instanceof l_))return e.announce("plonk"),!1;for(;p&&p instanceof l_&&/[a-zA-Z\*]/.test(p.value);)m=e.offsetOf(p),p=p.rightSibling}else{if(!(p=p.leftSibling)||!(p instanceof l_))return e.announce("plonk"),!1;for(;p&&p instanceof l_&&/[a-zA-Z\*]/.test(p.value);)m=e.offsetOf(p),p=p.leftSibling}else if("forward"===i&&"mopen"===p.type){let i=0;do"mopen"===p.type?i+=1:"mclose"===p.type&&(i-=1),p=p.rightSibling;while(!p.isLastSibling&&0!==i)m=e.offsetOf(p.leftSibling)}else if("backward"===i&&"mclose"===p.type){let i=0;do"mopen"===p.type?i+=1:"mclose"===p.type&&(i-=1),p=p.leftSibling;while(!p.isFirstSibling&&0!==i)m=e.offsetOf(p)}else if("backward"===i)if("first"===p.type)for(;m>0&&"first"===p.type;)m-=1,p=e.at(m);else{let i=p.type;"subsup"===p.type&&(m=e.offsetOf(e.at(m).leftSibling)),m-=1;let r=null==(o=e.at(m))?void 0:o.type;for(;m>=0&&r===i;)(null==(n=e.at(m))?void 0:n.type)==="subsup"?m=e.offsetOf(e.at(m).leftSibling):m-=1,r=e.at(m).type}else{let{type:i}=p,r=null==(l=e.at(m))?void 0:l.type,{lastOffset:a}=e;for(;m<=a&&(r===i||"subsup"===r);){for(;(null==(s=e.at(m).rightSibling)?void 0:s.type)==="subsup";)m=e.offsetOf(e.at(m).rightSibling);m+=1,r=null==(c=e.at(m))?void 0:c.type}m-=1}if(null!=(d=null==r?void 0:r.extend)&&d){if(!e.setSelection(e.anchor,m))return e.announce("plonk"),!1;e.announce("move",h)}else{if(m===e.position)return e.announce("plonk"),!1;null!=(u=null==r?void 0:r.delete)&&u?"forward"===i?c_(e,[h,m],"deleteWordForward"):(c_(e,[h,m],"deleteWordBackward"),e.position=m):(e.position=m,e.announce("move",h))}return e.mathfield.stopCoalescingUndo(),!0}function ck(e,i,r){var a,o;if(r=null!=r?r:{extend:!1},e.mathfield.styleBias="backward"===i?"right":"left","forward"!==i){let[i,r]=ss(e);void 0!==i&&void 0!==r&&e.deleteAtoms([i,r])}if("upward"===i)return function(e,i){var r,a;let o=null!=(r=null==i?void 0:i.extend)&&r;o||e.collapseSelection("backward");let n=()=>{var i,r;let a=!0;return e.silenceNotifications||(a=null==(r=null==(i=e.mathfield.host)?void 0:i.dispatchEvent(new CustomEvent("move-out",{detail:{direction:"upward"},cancelable:!0,bubbles:!0,composed:!0})))||r),e.announce(a?"line":"plonk"),a},l=e.at(e.position),s=l;for(;s&&"below"!==s.parentBranch&&!(Array.isArray(s.parentBranch)&&s.parent instanceof n0);)s=s.parent;if(Array.isArray(null==s?void 0:s.parentBranch)&&s.parent instanceof n0){let i=s.parent;if(s.parentBranch[0]<1)return n();let r=s.parentBranch[0]-1,a=i.getCell(r,s.parentBranch[1]);if(!a.some(e=>"prompt"===e.type&&!e.captureSelection)&&e.mathfield.hasEditablePrompts)return n();cL(e,l,a,o,"up")}else{if(!s)return n();let i=null!=(a=s.parent.branch("above"))?a:s.parent.createBranch("above");if(!i.some(e=>"prompt"===e.type&&e.placeholderId)&&e.mathfield.hasEditablePrompts)return n();cL(e,l,i,o,"up")}return e.mathfield.stopCoalescingUndo(),!0}(e,r);if("downward"===i)return function(e,i){var r,a;let o=null!=(r=null==i?void 0:i.extend)&&r;o||e.collapseSelection("forward");let n=()=>{var i,r;let a=!0;return e.silenceNotifications||(a=null==(r=null==(i=e.mathfield.host)?void 0:i.dispatchEvent(new CustomEvent("move-out",{detail:{direction:"downward"},cancelable:!0,bubbles:!0,composed:!0})))||r),e.announce(a?"line":"plonk"),a},l=e.at(e.position),s=l;for(;s&&"above"!==s.parentBranch&&!(oX(s.parentBranch)&&s.parent instanceof n0);)s=s.parent;if(oX(null==s?void 0:s.parentBranch)&&s.parent instanceof n0){let i=s.parent;if(s.parentBranch[0]+1>i.rows.length-1)return n();let r=s.parentBranch[0]+1,a=i.getCell(r,s.parentBranch[1]);if(!a.some(e=>"prompt"===e.type&&!e.captureSelection)&&e.mathfield.hasEditablePrompts)return n();cL(e,l,a,o,"down")}else{if(!s)return n();let i=null!=(a=s.parent.branch("below"))?a:s.parent.createBranch("below");if(!i.some(e=>"prompt"===e.type)&&e.mathfield.hasEditablePrompts)return n();cL(e,l,i,o,"down")}return!0}(e,r);if(r.extend){let r=cM(e,e.position,i);r<0&&(r=0),r>e.lastOffset&&(r=e.lastOffset);let a=e.setSelection(e.anchor,r);return e.mathfield.stopCoalescingUndo(),a}if(e.selectionIsPlaceholder){e.collapseSelection(i);let r=ck(e,i);return e.mathfield.stopCoalescingUndo(),r}let n=e.position,l=n;if(e.collapseSelection(i)?(n=e.position,cS(e,n)||(n=cM(e,n,i))):n=cM(e,n,i),n<0||n>e.lastOffset){let r=!0;return e.silenceNotifications||(r=null==(o=null==(a=e.mathfield.host)?void 0:a.dispatchEvent(new CustomEvent("move-out",{detail:{direction:i},cancelable:!0,bubbles:!0,composed:!0})))||o),r&&e.announce("plonk"),r}return e.setPositionHandlingPlaceholder(n),e.mathfield.stopCoalescingUndo(),e.announce("move",l),!0}function cM(e,i,r){return(i+="forward"===r?1:-1)<0||i>e.lastOffset||cS(e,i)?i:cM(e,i,r)}function cS(e,i){var r;let a=e.at(i),o=a.parent;for(;o&&!o.inCaptureSelection;)o=o.parent;return!(null!=o&&o.inCaptureSelection||null!=(r=a.parent)&&r.skipBoundary&&(!a.isFirstSibling&&a.isLastSibling||"first"===a.type)||e.mathfield.hasEditablePrompts&&!a.parentPrompt)}function cL(e,i,r,a,o){let n=e.mathfield.hasEditablePrompts,l=n?r.filter(e=>"prompt"===e.type&&!e.captureSelection):r,s=nm(e.mathfield.getHTMLElement(i)).right,c=e.offsetOf(function(e,i,r){let a=1/0,o=0;for(;o<i.length;o++){let n=i[o],l=e.getHTMLElement(n);if(!l)continue;let s=Math.abs(r-nm(l).right);if(s<=a)a=s;else break}return i[o-1]}(e.mathfield,l,s))-!!n;if(a){let[i,r]=e.selection.ranges[0],a;a=c<("up"===o?i:r)?{ranges:[[c,r]],direction:"backward"}:{ranges:[[i,c]],direction:"forward"},e.setSelection(a)}else e.setPositionHandlingPlaceholder(c);e.announce(`move ${o}`)}function cC(e){let i=e.position,r=e.at(i).parent;return null!=r&&r.parent?(e.position=e.offsetOf(r),e.mathfield.stopCoalescingUndo(),e.announce("move",i),!0):(e.announce("plonk"),!1)}function cE(e){if(e.collapseSelection(),function(e){let i=0,r=e.at(e.position),a=!1;for(;r;)r.hasEmptyBranch("superscript")?r.hasEmptyBranch("subscript")||(a=!1):(i+=1,a=!0),r=r.parent;return a?i:0}(e)>=e.mathfield.options.scriptDepth[1])return e.announce("plonk"),!1;let i=e.at(e.position);if(void 0===i.subsupPlacement){let e=i.rightSibling;(null==e?void 0:e.type)!=="subsup"&&(e=new lo({style:i.style}),i.parent.addChildAfter(e,i)),i=e}return i.createBranch("superscript"),e.setSelection(e.getSiblingsRange(e.offsetOf(i.superscript[0]))),!0}function cA(e){if(e.collapseSelection(),function(e){let i=0,r=e.at(e.position),a=!1;for(;r;)r.hasEmptyBranch("subscript")?r.hasEmptyBranch("superscript")||(a=!1):(i+=1,a=!0),r=r.parent;return a?i:0}(e)>=e.mathfield.options.scriptDepth[0])return e.announce("plonk"),!1;let i=e.at(e.position);if(void 0===i.subsupPlacement){let e=i.rightSibling;(null==e?void 0:e.type)!=="subsup"&&(e=new lo({style:i.style}),i.parent.addChildAfter(e,i)),i=e}return i.createBranch("subscript"),e.setSelection(e.getSiblingsRange(e.offsetOf(i.subscript[0]))),!0}function cz(e,i,r="forward"){let a=e.position;if(R(i)){let o=e.offsetOf(i[0]),n=e.offsetOf(i[i.length-1]);return"forward"===r?e.setSelection(o,n):e.setSelection(n,o),e.announce("move",a),e.mathfield.stopCoalescingUndo(),!0}return"forward"===r?cz(e,[i.leftSibling,i]):cz(e,[i,i.leftSibling])}function cT(e,i){let r=e.position;if("number"==typeof i&&(i=e.at(i)),"prompt"===i.type)e.setSelection(e.offsetOf(i.firstChild),e.offsetOf(i.lastChild));else{let r=e.offsetOf(i);"placeholder"===i.type?e.setSelection(r-1,r):e.position=r}return e.announce("move",r),e.mathfield.stopCoalescingUndo(),!0}function cD(e,i){var r,a;let o="forward"===i?1:-1;"placeholder"===e.at(e.anchor).type&&ck(e,i);let n,l=e.at(e.anchor).parentPrompt;n=l?"forward"===i?e.offsetOf(l)+1:e.offsetOf(l.leftSibling):Math.max(e.position+o,0);let s=cK(e,n,i);if(!s||"forward"===i&&e.offsetOf(s)<n||"backward"===i&&e.offsetOf(s)>n){if(!(null==(a=null==(r=e.mathfield.host)?void 0:r.dispatchEvent(new CustomEvent("move-out",{detail:{direction:i},cancelable:!0,bubbles:!0,composed:!0})))||a))return e.announce("plonk"),!1;let n=function(){var e;let i,r;function a(e){var i;let r=Number.parseInt(null!=(i=e.getAttribute("tabindex"))?i:"NaN",10);return Number.isNaN(r)?"true"===e.contentEditable||("AUDIO"===e.nodeName||"VIDEO"===e.nodeName)&&null===e.getAttribute("tabindex")?0:e.tabIndex:r}return v()?(e=document.body,i=[],r=[],[...e.querySelectorAll(`input, select, textarea, a[href], button,
|
|
3333
3333
|
[tabindex], audio[controls], video[controls],
|
|
3334
|
-
[contenteditable]:not([contenteditable="false"]), details>summary`)].filter(function(e){var i,r;return!((i=e).disabled||"hidden"===i.type&&"INPUT"===i.tagName.toUpperCase()||function(e){if(!v()||e===document.activeElement||e.contains(document.activeElement))return!1;if("hidden"===getComputedStyle(e).visibility)return!0;let i=e.getBoundingClientRect();if(0===i.width||0===i.height)return!0;for(;e;){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(i)||"INPUT"===(r=e).tagName.toUpperCase()&&"radio"===r.type&&!function(e){var i;if(!e.name)return!0;let r=function(e,i){for(let r of e)if(r.checked&&r.form===i)return r;return null}((null!=(i=e.form)?i:e.ownerDocument).querySelectorAll('input[type="radio"][name="'+e.name+'"]'),e.form);return!r||r===e}(r)||0>a(e))}).forEach((e,o)=>{let n=a(e);0===n?i.push(e):r.push({documentOrder:o,tabIndex:n,node:e})}),r.sort((e,i)=>e.tabIndex===i.tabIndex?e.documentOrder-i.documentOrder:e.tabIndex-i.tabIndex).map(e=>e.node).concat(i)):[]}();if(!document.activeElement||n.length<=1)return e.announce("plonk"),!1;let l=n.indexOf(document.activeElement)+o;return l<0&&(l=n.length-1),l>=n.length&&(l=0),n[l].focus(),e.mathfield.stopCoalescingUndo(),!0}return cz(e,s),!0}function cD(e,i=0,r="forward"){return e.findAtom(i=>"placeholder"===i.type||"prompt"===i.type||!e.mathfield.readOnly&&i.treeDepth>2&&i.isFirstSibling&&i.isLastSibling,i,r)}function cK(e,i,r,a){if("forward"===a){let e=i.rightSibling;for(;e&&!r(e);)e=e.rightSibling;return e}let o=i.leftSibling;for(;o&&!r(o);)o=o.leftSibling;return o}function cB(e,i,r){"function"==typeof i&&(r=i,i=1/0),void 0===i&&(i=1/0);let a=e.position,o=!1,n="";for(;!o;){let l=e.at(a);(o=0===i||void 0===l||"first"===l.type||"math"!==l.mode||!(l.type&&/mord|mpunct|operator/.test(l.type)||"mop"===l.type&&/[a-zA-Z ]+/.test(l.value))||!l.hasEmptyBranch("superscript")||!l.hasEmptyBranch("subscript")||"function"==typeof r&&!r(l))||(l.mode="text",l.command=l.value,l.verbatimLatex=void 0,n+=l.value),a-=1,i-=1}e.contentDidChange({data:n,inputType:"insertText"})}function c$(e,i,r){"function"==typeof i&&(r=i,i=1/0),void 0===i&&(i=1/0);let a=e.position,o=!1,n=[];for(;!o;){let l=e.at(a);(o=0===i||!l||"first"===l.type||l.isFirstSibling||"text"!==l.mode||" "===l.value||"function"==typeof r&&!r(l))||(n.push(oG.serialize([l],{defaultMode:"math"})),l.mode="math"),a-=1,i-=1}cP(e),e.contentDidChange({data:of(n),inputType:"insertText"})}function cP(e){var i;let r=e.position-1;for(;r>=0&&(null==(i=e.at(r))?void 0:i.mode)==="math";)r-=1;if(!(r<0)&&"text"===e.at(r).mode&&" "===e.at(r).value&&"math"===e.at(r-1).mode){e.at(r-1).parent.removeChild(e.at(r-1));let i=e.silenceNotifications;e.silenceNotifications=!0,e.position-=1,e.silenceNotifications=i,e.contentDidChange({inputType:"deleteContent"})}}function cO(){return document.getElementById("mathlive-keystroke-caption-panel")||(nA("keystroke-caption"),nA("core"),sg("mathlive-keystroke-caption-panel"))}function cR(e,i){var r,a,o,n;let{model:l}=e,s=si(i);if(i.isTrusted){!function(e){var i,r;if(!e||"Unidentified"===e.key||"Dead"===e.key)return;let a=e.shiftKey&&e.altKey?3:e.altKey?2:+!!e.shiftKey;for(let o of T)(null==(i=o.mapping[e.code])?void 0:i[a])===e.key?o.score+=1:null!=(r=o.mapping[e.code])&&r[a]&&(o.score=0);T.sort((e,i)=>i.score-e.score)}(i);let r=$();e.keyboardLayout!==r.id&&(e.keyboardLayout=r.id,e._keybindings=void 0)}if(clearTimeout(e.inlineShortcutBufferFlushTimer),e.inlineShortcutBufferFlushTimer=0,function(e,i){if(!e.isSelectionEditable||!e.keystrokeCaptionVisible)return;let r=cO(),a=e.element.getBoundingClientRect();r.style.left=`${a.left}px`,r.style.top=`${a.top-64}px`,r.innerHTML=globalThis.MathfieldElement.createHTML("<span>"+(l3(i)||i)+"</span>"+r.innerHTML),r.style.visibility="visible",setTimeout(()=>{r.childNodes.length>0&&r.childNodes[r.childNodes.length-1].remove(),0===r.childNodes.length&&(r.style.visibility="hidden")},3e3)}(e,s),i.isTrusted&&i.defaultPrevented)return e.flushInlineShortcutBuffer(),!1;let c,d=0,u="",h=0,p=e.inlineShortcutBuffer,m=!1;if(e.isSelectionEditable&&l.selectionIsPlaceholder&&l7(i)&&(e.flushInlineShortcutBuffer(),l.deleteAtoms(oQ(l.selection)),e.snapshot("delete"),m=!0),e.isSelectionEditable){if("math"===l.mode&&(!l.selectionIsPlaceholder||m))if("[Backspace]"===s)"insert-shortcut"===e.undoManager.lastOp?u="undo":p.pop();else if(l7(i)){let o=st(i),n=[...null!=(a=null==(r=p[p.length-1])?void 0:r.keystrokes)?a:[],o];p.push({state:l.getState(),keystrokes:n,leftSiblings:function(e){let i=e.model,r=[],a=i.at(Math.min(i.position,i.anchor));for(;"first"!==a.type;)r.push(a),a=a.leftSibling;return r}(e)}),d=0;let s="";for(;!c&&d<n.length;)h=p.length-(n.length-d),s=n.slice(d).join(""),!(c=o2(p[h].leftSiblings,s,e.options.inlineShortcuts))&&/^[a-zA-Z][a-zA-Z0-9]+?([_\^][a-zA-Z0-9\*\+\-]+?)?$/.test(s)&&(c=e.options.onInlineShortcut(e,s)),d+=1;e.flushInlineShortcutBuffer({defer:!0})}else e.flushInlineShortcutBuffer();e.options.smartMode&&(c?e.switchMode("math"):function(e,i,r){var a,o;let{model:n}=e;if("latex"===n.mode||!n.at(n.position).isLastSibling||!r||!l7(r))return!1;let l=st(r);if(!n.selectionIsCollapsed)return!!("text"===e.model.mode&&/[/_^]/.test(l));let s=function(e){let i="",r=e.position,a=!1;for(;!a;){let o=e.at(r);(a=!(o&&("text"===o.mode||"math"===o.mode&&o.type&&/mord|mpunct/.test(o.type))))||(i=o.value+i),r-=1}return i}(n)+l;if("text"===e.model.mode){if("Esc"===i||/[/\\]/.test(l))return!0;if(/[\^_]/.test(l))return/(^|\s)[a-zA-Z][^_]$/.test(s)&&c$(n,1),!0;let e={")":"(","}":"{","]":"["}[l],{parent:r}=n.at(n.position);if(e&&r instanceof le&&r.leftDelim===e)return!0;if(/(^|[^a-zA-Z])(a|I) $/.test(s))return!1;if(/[$€£₤₺¥¤฿¢₡₧₨₹₩₱]/u.test(l))return!0;if(/(^|[^a-zA-Z'’])[a-zA-Z] $/.test(s))return c$(n,1),!1;if(/\D\.[^\d\s]$/.test(s)){c$(n,1);let e=n.at(n.position);return e.value="⋅",e.style.variant="normal",e.command="\\cdot",e.verbatimLatex=void 0,n.contentDidChange({data:"\\cdot",inputType:"insertText"}),!0}if(/(^|\s)[a-zA-Z][^a-zA-Z]$/.test(s)||/\.\d$/.test(s)||/\([\d+\-.]$/.test(s))return c$(n,1),!0;if(/\([a-z][,;]$/.test(s))return c$(n,2),!0;if(/[\d+\-=><*|]$/.test(l))return cP(n),!0}else{if("[Space]"===i)return cB(n,void 0,e=>/[a-z][:,;.]$/.test(e.value)),!0;if(/[a-zA-Z]{3,}$/.test(s)&&!/(dxd|abc|xyz|uvw)$/.test(s)){let i=null!=(o=null==(a=/[a-zA-Z]+$/.exec(s))?void 0:a[0])?o:"",r=e.options.inlineShortcuts;if(!(i&&r&&Object.keys(r).some(e=>e.startsWith(i))))return cB(n,void 0,e=>/[a-zA-Z]/.test(e.value)),!0}if(/(^|\W)(if)$/i.test(s))return cB(n,1),!0;if(/(\u0393|\u0394|\u0398|\u039B|\u039E|\u03A0|\u03A3|\u03A5|\u03A6|\u03A8|\u03A9|[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5){3,}$/u.test(s)&&!/(αβγ)$/.test(s))return cB(n,void 0,e=>/(:|,|;|.|\u0393|\u0394|\u0398|\u039B|\u039E|\u03A0|\u03A3|\u03A5|\u03A6|\u03A8|\u03A9|[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5)/u.test(e.value)),!0;if("?"===l||"."===l&&!/[\d-+]\.$/.test(s))return!0}return!1}(e,s,i)&&(e.switchMode({math:"text",text:"math"}[l.mode]),u=""))}if(!c){if(u||(u=function(e,i,r){if(0===e.length)return"";let a=E(C(si(r))),o=E({key:r.key,shift:r.shiftKey,alt:r.altKey,ctrl:r.ctrlKey,meta:r.metaKey||r.ctrlKey&&/macos|ios/.test(w()),cmd:!1,win:!1});for(let r=e.length-1;r>=0;r--)if((e[r].key===a||e[r].key===o)&&(!e[r].ifMode||e[r].ifMode===i))return e[r].command;return""}(e.keybindings,l.mode,i)),!u&&("[Enter]"===s||"[Return]"===s)){if(sw())return!1;let r=!0;return l.contentWillChange({inputType:"insertLineBreak"})&&(e.host&&(r=e.host.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))),!r&&i.preventDefault?(i.preventDefault(),i.stopPropagation()):(null!=(o=l.parentEnvironment)&&o.isMultiline&&e.executeCommand("addRowAfter"),l.contentDidChange({inputType:"insertLineBreak"}))),r}if("[Space]"===s&&"latex"===l.mode&&sf(e,"accept-all"))return e.dirty=!0,e.scrollIntoView(),i.preventDefault&&(i.preventDefault(),i.stopPropagation()),!1;if((!u||"[Space]"===s)&&"math"===l.mode){if("[Space]"===s){if(e.styleBias="none",e.flushInlineShortcutBuffer(),e.options.mathModeSpace)return na.insert(l,e.options.mathModeSpace,{format:"latex",mode:"math"}),e.snapshot("insert-space"),u="",e.dirty=!0,e.scrollIntoView(),i.preventDefault&&(i.preventDefault(),i.stopPropagation()),!1;let r=l.at(l.position+1),a=l.at(l.position-1);if((null==r?void 0:r.mode)==="text"||(null==a?void 0:a.mode)==="text")return na.insert(l," ",{mode:"text"}),e.snapshot("insert-space"),e.dirty=!0,e.scrollIntoView(),!1}null!=(n=l.at(l.position))&&n.isDigit()&&","===globalThis.MathfieldElement.decimalSeparator&&","===st(i)&&(u="insertDecimalSeparator")}}if(!c&&!u){if(l.mathfield.smartFence){if(function e(i,r,a){var o;if(!r||"math"!==i.mode)return!1;let n=i.at(i.position),{parent:l}=n,s={"(":"(",")":")","{":"\\lbrace","}":"\\rbrace","[":"\\lbrack","]":"\\rbrack","|":"|"}[r];if(!s)return!1;let c=nK[s],d=nD[s];if(!i.selectionIsCollapsed){i.mathfield.snapshot();let[e,r]=oQ(i.selection),a=i.extractAtoms([e,r]);a=a.filter(e=>"first"!==e.type);let o=l.addChildrenAfter([new le("left...right",a,{leftDelim:s,rightDelim:d})],i.at(e));return i.setSelection(i.offsetOf(o.firstChild),i.offsetOf(o.lastChild)),i.mathfield.snapshot("insert-fence"),i.contentDidChange({data:s,inputType:"insertText"}),!0}if("|"===s){let e=l instanceof le?l.leftDelim+l.rightDelim:"";if("\\lbrace\\rbrace"===e||"\\{\\}"===e||"\\lbrace?"===e)return i.mathfield.snapshot(),na.insert(i,"\\,\\middle\\vert\\,",{format:"latex",style:a}),i.mathfield.snapshot("insert-fence"),i.contentDidChange({data:s,inputType:"insertText"}),!0}if(d){if(l instanceof le&&l.firstChild===n&&("?"===l.leftDelim||"."===l.leftDelim))return l.leftDelim=s,l.isDirty=!0,i.mathfield.snapshot(),i.contentDidChange({data:s,inputType:"insertText"}),i.mathfield.snapshot("insert-fence"),!0;if(!(l instanceof le)){let e=n;for(;e&&("mclose"!==e.type||e.value!==d);)e=e.rightSibling;if(e){i.mathfield.snapshot();let r=i.extractAtoms([i.offsetOf(n),i.offsetOf(e)]);r.pop();let a=new le("left...right",r=r.filter(e=>"first"!==e.type),{leftDelim:s,rightDelim:d});return l.addChildrenAfter([a],n),i.position=i.offsetOf(a.firstChild),i.contentDidChange({data:s,inputType:"insertText"}),i.mathfield.snapshot("insert-fence"),!0}}let e=i.offsetOf(n.lastSibling),r;for(r=i.position;r<=e;r++){let e=i.at(r);if(e instanceof le&&("?"===e.leftDelim||"."===e.leftDelim)&&cF(s,e.rightDelim))break}let c=i.at(r);if(r<=e&&c instanceof le){c.leftDelim=s,i.mathfield.snapshot();let e=i.extractAtoms([i.position,r-1]);return e=e.filter(e=>"first"!==e.type),c.addChildren(e,c.parentBranch),i.position+=1,i.contentDidChange({data:s,inputType:"insertText"}),i.mathfield.snapshot("insert-fence"),!0}if(l instanceof le&&("?"===l.leftDelim||"."===l.leftDelim)&&cF(s,l.rightDelim)){for(let e of(l.isDirty=!0,l.leftDelim=s,i.mathfield.snapshot(),i.extractAtoms([i.offsetOf(n.firstSibling),i.position])))l.parent.addChildBefore(e,l);return i.contentDidChange({data:s,inputType:"insertText"}),i.mathfield.snapshot("insert-fence"),!0}if(!(l instanceof le&&"|"===l.leftDelim)){if("("===s){let e=i.position-1,r=!1;for(;e>=0;){let a=i.at(e);if("first"===a.type)break;if("mord"===a.type&&a.value&&/^[\d]$/.test(a.value)){e-=1;continue}if("group"===a.type&&(null==(o=a.body)?void 0:o.length)===2&&"first"===a.body[0].type&&","===a.body[1].value){r=!0;break}"mord"===a.type&&(","===a.value||"."===a.value)&&(r=!0);break}if(r)return!1}if(i.mathfield.snapshot(),na.insert(i,`\\left${s}\\right?`,{format:"latex",style:a}),"first"!==n.lastSibling.type){let e=i.offsetOf(n.lastSibling),r=i.extractAtoms([i.position,e]);i.at(i.position).body=r,i.position-=1}return i.mathfield.snapshot("insert-fence"),!0}}if(c){if(")"===s){let e=i.position-1,r=!1;for(;e>=0;){let a=i.at(e);if("first"===a.type)break;if("mord"===a.type&&a.value&&/^[\d]$/.test(a.value)){r=!0,e-=1;continue}break}if(r&&"mopen"===i.at(e).type&&"("===i.at(e).value)return!1}let r=n;for(;r;){if("mopen"===r.type&&r.value===c){i.mathfield.snapshot();let e=r.leftSibling,a=i.extractAtoms([i.offsetOf(r.leftSibling),i.offsetOf(n)]);[,...a]=a;let o=new le("left...right",a,{leftDelim:c,rightDelim:s});return l.addChildrenAfter([o],e),i.position=i.offsetOf(o),i.contentDidChange({data:s,inputType:"insertText"}),i.mathfield.snapshot("insert-fence"),!0}r=r.leftSibling}if(l instanceof le&&n.isLastSibling&&cq(l.leftDelim,s))return i.mathfield.snapshot(),l.isDirty=!0,l.rightDelim=s,i.position+=1,i.contentDidChange({data:s,inputType:"insertText"}),i.mathfield.snapshot("insert-fence"),!0;let o=i.offsetOf(n.firstSibling),d;for(d=i.position;d>=o;d--){let e=i.at(d);if(e instanceof le&&("?"===e.rightDelim||"."===e.rightDelim)&&cq(e.leftDelim,s))break}let u=i.at(d);if(d>=o&&u instanceof le)return i.mathfield.snapshot(),u.rightDelim=s,u.addChildren(i.extractAtoms([d,i.position]),u.parentBranch),i.contentDidChange({data:s,inputType:"insertText"}),i.mathfield.snapshot("insert-fence"),!0;if(l instanceof le&&("?"===l.rightDelim||"."===l.rightDelim)&&cq(l.leftDelim,s))return i.mathfield.snapshot(),l.isDirty=!0,l.rightDelim=s,l.parent.addChildren(i.extractAtoms([i.position,i.offsetOf(n.lastSibling)]),l.parentBranch),i.position=i.offsetOf(l),i.contentDidChange({data:s,inputType:"insertText"}),i.mathfield.snapshot("insert-fence"),!0;let h=l.parent;return h instanceof le&&("?"===h.rightDelim||"."===h.rightDelim)&&!!i.at(i.position).isLastSibling&&(i.position=i.offsetOf(h),e(i,s,a))}return!1}(l,st(i),sd(e)))return e.dirty=!0,e.scrollIntoView(),i.preventDefault&&i.preventDefault(),!1}else{let{parent:r}=l.at(l.position);if(r instanceof le&&"?"===r.rightDelim&&l.at(l.position).isLastSibling&&/^[)}\]|]$/.test(s))return e.snapshot(),r.isDirty=!0,r.rightDelim=s,l.position+=1,l.selectionDidChange(),l.contentDidChange({data:st(i),inputType:"insertText"}),e.snapshot("insert-fence"),e.dirty=!0,e.scrollIntoView(),i.preventDefault&&i.preventDefault(),!1;if(!l.selectionIsCollapsed){let r=st(i);if("("===r||"{"===r||"["===r){let[a,o]=oQ(l.selection);return e.snapshot(),l.position=o,na.insert(l,{"(":")","{":"\\rbrace","[":"\\rbrack"}[r],{format:"latex"}),l.position=a,na.insert(l,{"(":"(","{":"\\lbrace","[":"\\lbrack"}[r],{format:"latex"}),l.setSelection(a+1,o+1),l.contentDidChange({data:r,inputType:"insertText"}),e.snapshot("insert-fence"),e.dirty=!0,e.scrollIntoView(),i.preventDefault&&i.preventDefault(),!1}}}return!0}let f=l.at(Math.max(l.position,l.anchor)),{parent:g}=f;if("moveAfterParent"===u&&g instanceof le&&f.isLastSibling&&e.options.smartFence&&"?"===g.rightDelim&&(e.snapshot(),g.rightDelim=g.matchingRightDelim(),g.isDirty=!0,l.contentDidChange({inputType:"insertText"}),e.snapshot("insert-fence")),e.keyboardDelegate.cancelComposition(),u)e.executeCommand(u);else if(c){let i=sd(e);l.setState(p[h].state);let r=p[p.length-1].keystrokes;for(let e of r=r.slice(d-1))na.insert(l,e,{silenceNotifications:!0,style:i});e.snapshot("insert-shortcut"),l.setState(p[h].state),l.deferNotifications({content:!0,selection:!0,data:c,type:"insertText"},()=>(na.insert(l,c,{format:"latex",style:i}),cP(e.model),c.endsWith(" ")&&(e.switchMode("text"),na.insert(l," ",{style:i,mode:"text"})),e.snapshot(),l.selectionIsCollapsed||e.flushInlineShortcutBuffer(),!0)),e.dirty=!0,l.announce("replacement")}return e.scrollIntoView(),i.preventDefault&&i.preventDefault(),!1}function cI(e){var i,r,a;let o,{model:n}=e;if("math"!==n.mode)return!1;let l=function(e){var i,r;let{position:a}=e,o=a,n=[];for(;o>0;){let i=e.at(o),r=i.value;if("mord"===i.type||"mbin"===i.type&&("+"===r||"-"===r||"−"===r))n.unshift(i),o--;else break}if(0===n.length)return null;let l=n.map(e=>e.value).join(""),s=(null!=(r=null==(i=globalThis.MathfieldElement)?void 0:i.decimalSeparator)?r:".")==="."?"\\.":",",c=RegExp(`^(\\d+(?:${s}\\d*)?)[eE]([+\\-\u2212]?)(\\d+)$`),d=l.match(c);return d?{startOffset:o,endOffset:a,significand:d[1],exponent:d[2]+d[3]}:null}(n);if(!l)return!1;let s=(i=l.significand,r=l.exponent,(o=null==(a=globalThis.MathfieldElement)?void 0:a.scientificNotationTemplate)&&""!==o&&o.includes("#1")&&o.includes("#2")?o.replace("#1",i).replace("#2",r):null);return!!s&&(n.deferNotifications({content:!0,selection:!0,type:"insertText"},()=>{n.selection={ranges:[[l.startOffset,l.endOffset]],direction:"forward"},na.insert(n,s,{insertionMode:"replaceSelection",selectionMode:"after"})}),e.snapshot("format-scientific-notation"),e.dirty=!0,e.scrollIntoView(),!0)}function cN(e,i,r){let{model:a}=e;if(!e.isSelectionEditable)return void a.announce("plonk");null!=r||(r={}),r.focus&&e.focus(),r.feedback&&(globalThis.MathfieldElement.keypressVibration&&_()&&navigator.vibrate(3),globalThis.MathfieldElement.playSound("keypress")),"string"==typeof r.mode&&(e.switchMode(r.mode),e.snapshot());let o=oh(i),n=window.mathVirtualKeyboard;if(null!=n&&n.isShifted&&(o="string"==typeof o?o.toUpperCase():o.map(e=>e.toUpperCase())),r.simulateKeystroke){let i=!0;for(let r of o)cR(e,new KeyboardEvent("keypress",{key:r}))&&(i=!1);if(i)return}if("latex"===a.mode){if(a.deferNotifications({content:!0,selection:!0,data:i,type:"insertText"},()=>{for(let i of(sh(e),o))na.insert(a,i,{insertionMode:"replaceSelection"});e.snapshot("insert-latex"),sp(e)}),"}"===i){let i=sn(a).map(e=>e.value).join(""),r=i.match(/^\\([a-zA-Z]+)/);if(r){let a=eM("\\"+r[1],"math");if((null==a?void 0:a.definitionType)==="function"){let r=a.params.filter(e=>!e.isOptional).length;if(r>0){let a=0,o=0,n=!0;for(let e=0;e<i.length;e++){let r=i[e];if(n){if("\\"===r||/[a-zA-Z]/.test(r))continue;n=!1}"{"===r?a++:"}"===r&&0==--a&&o++}if(0===a&&o===r&&sf(e,"accept-all")){e.dirty=!0,e.scrollIntoView();return}}}}}}else if("text"===a.mode){let i=f(f({},function(e){var i,r,a,o;if(e.selectionIsCollapsed)return null!=(r=null==(i=e.at(e.position))?void 0:i.style)?r:{};let n=oQ(e.selection)[0];return null!=(o=null==(a=e.at(n+1))?void 0:a.style)?o:{}}(a)),e.defaultStyle);for(let e of o)na.insert(a,e,{style:i,insertionMode:"replaceSelection"});e.snapshot("insert-text")}else if("math"===a.mode)for(let i of o)!function(e,i){let r=e.model;/\d/.test(i)||cI(e);let a={"^":"moveToSuperscript",_:"moveToSubscript"," ":e.options.mathModeSpace?["insert",e.options.mathModeSpace]:"moveAfterParent"}[i];if("moveAfterParent"===a){let i=r.at(Math.max(r.position,r.anchor)),{parent:a}=i;a instanceof le&&i.isLastSibling&&e.options.smartFence&&"?"===a.rightDelim&&(e.snapshot(),a.rightDelim=a.matchingRightDelim(),a.isDirty=!0,r.contentDidChange({inputType:"insertText"}),e.snapshot("insert-fence"))}if(a)return e.executeCommand(a);let o=f({},sd(e));/[a-zA-Z0-9]/.test(i)||"none"===e.styleBias||(o.variant="normal",o.variantStyle=void 0);let n=r.at(r.position),l=r.selectionIsPlaceholder;if(/\d/.test(i)&&e.options.smartSuperscript&&"superscript"===n.parentBranch&&"mop"!==n.parent.type&&"operator"!==n.parent.type&&"extensible-symbol"!==n.parent.type&&n.hasNoSiblings)return na.insert(r,i,{style:o,insertionMode:"replaceSelection",selectionMode:l?"after":"placeholder"})?(e.snapshot("insert-mord"),cL(r)):e.undoManager.pop();let s=i;if("{"===s?s="\\lbrace":"}"===s?s="\\rbrace":"&"===s?s="\\&":"#"===s?s="\\#":"$"===s?s="\\$":"%"===s?s="\\%":"~"===s?s="\\~":"\\"===s&&(s="\\backslash"),na.insert(r,s,{style:o,insertionMode:"replaceSelection",selectionMode:l?"after":"placeholder"})){if(e.snapshot(`insert-${r.at(r.position).type}`),/\d/.test(i)){let i=e.options.inlineShortcutTimeout>0?e.options.inlineShortcutTimeout:1e3;clearTimeout(e.scientificNotationTimer),e.scientificNotationTimer=setTimeout(()=>{cI(e)},i)}/^[a-zA-Z]$/.test(i)&&sp(e)}}(e,i);e.dirty=!0,e.scrollIntoView()}function cq(e,i){return!e||(["(","\\lparen","{","\\{","\\lbrace","[","\\lbrack"].includes(e)?[")","\\rparen","}","\\}","\\rbrace","]","\\rbrack"].includes(i):nD[e]===i)}function cF(e,i){return!i||([")","\\rparen","}","\\}","\\rbrace","]","\\rbrack"].includes(i)?["(","\\lparen","{","\\{","\\lbrace","[","\\lbrack"].includes(e):nK[i]===e)}function cV(e){let[i,r]=oQ(e.selection);if((i=cj(e,i,"backward"))===(r=cj(e,r,"forward"))){let a=e.at(i);if("leftright"===a.type)return e.setSelection(e.offsetOf(a.firstChild)-1,r);if("first"===a.type&&("leftright"===a.parent.type||"surd"===a.parent.type))return e.setSelection(i-1,e.offsetOf(a.parent.lastChild)+1);e.setSelection(i-1,r)}else e.setSelection(i,r);return!0}function cj(e,i,r){var a;let o=e.at(i);if(!o)return i;let n="forward"===r?1:-1;if("text"===o.mode){for(;o&&!("text"!==o.mode||!er.test(o.value));)i+=n,o=e.at(i);return"backward"===r?i-1:i}if("latex"===o.mode){if(/[a-zA-Z\\*]/.test(o.value))if("backward"===r)for(;(null==o?void 0:o.mode)==="latex"&&"\\"!==o.value&&/[a-zA-Z]/.test(o.value);)i+=n,o=e.at(i);else for(;(null==o?void 0:o.mode)==="latex"&&/[a-zA-Z\\*]/.test(o.value);)i+=n,o=e.at(i);else if("{"===o.value){if("forward"===r){for(;(null==o?void 0:o.mode)==="latex"&&"}"!==o.value;)i+=n,o=e.at(i);return i}}else if("}"===o.value){if("backward"===r){for(;(null==o?void 0:o.mode)==="latex"&&"{"!==o.value;)i+=n,o=e.at(i);return i-1}return i}return i-1}if("math"===o.mode){if(o.isDigit()){for(;null!=(a=e.at(i+n))&&a.isDigit();)i+=n;return"backward"===r?i-1:i}if(o.style.variant||o.style.variantStyle){let a=o.style.variant,l=o.style.variantStyle;for(;;){let r=e.at(i+n);if(!r||r.style.variant!==a||r.style.variantStyle!==l)break;i+=n}return"backward"===r?i-1:i}}return i}cy.maximumDepth=1e3,sN({moveToOpposite:e=>{let i=e.at(e.position),{parent:r}=i;if(!r)return e.announce("plonk"),!1;let a=i.parentBranch,o;if("string"==typeof a&&(o=({superscript:"subscript",subscript:"superscript",above:"below",below:"above"})[a]),!o){let r=i.subsupPlacement?cE(e):cC(e);return e.mathfield.stopCoalescingUndo(),r}r.branch(o)||r.createBranch(o);let n=e.setSelection(e.getBranchRange(e.offsetOf(r),o));return e.mathfield.stopCoalescingUndo(),n},moveBeforeParent:e=>{let{parent:i}=e.at(e.position);return i?(e.position=e.offsetOf(i),e.mathfield.stopCoalescingUndo(),!0):(e.announce("plonk"),!1)},moveAfterParent:e=>cL(e),moveToNextChar:e=>cw(e,"forward"),moveToPreviousChar:e=>cw(e,"backward"),moveUp:e=>cw(e,"upward"),moveDown:e=>cw(e,"downward"),moveToNextWord:e=>c_(e,"forward"),moveToPreviousWord:e=>c_(e,"backward"),moveToGroupStart:e=>{let i=e.offsetOf(e.at(e.position).firstSibling);return i===e.position?(e.announce("plonk"),!1):(e.position=i,e.mathfield.stopCoalescingUndo(),!0)},moveToGroupEnd:e=>{let i=e.offsetOf(e.at(e.position).lastSibling);return i===e.position?(e.announce("plonk"),!1):(e.position=i,e.mathfield.stopCoalescingUndo(),!0)},moveToNextGroup:e=>{var i,r,a,o;if(e.position===e.lastOffset&&e.anchor===e.lastOffset)return cT(e,"forward");let n=e.at(e.position);if("text"===n.mode){if(e.selectionIsCollapsed){let r=n;for(;(null==r?void 0:r.mode)==="text";)r=r.leftSibling;let a=n;for(;(null==(i=a.rightSibling)?void 0:i.mode)==="text";)a=a.rightSibling;if(r&&a)return cA(e,[r,a])}if("text"===n.rightSibling.mode){let i=n;for(;(null==i?void 0:i.mode)==="text";)i=i.rightSibling;return i?(cz(e,null!=(r=i.leftSibling)?r:i),e.mathfield.switchMode("math"),!0):cz(e,e.lastOffset)}}let l=e.at(e.anchor).parentPrompt,s=l?e.offsetOf(l)+1:Math.max(e.position+1,0),c=cD(e,s,"forward");if(c&&e.offsetOf(c)<s)return cT(e,"forward");if(c)return cz(e,c);let d=cK(e,n,e=>"leftright"===e.type||"text"===e.type,"forward");if(d){if("text"===d.mode){let i=d;for(;(null==i?void 0:i.mode)==="text";)i=i.rightSibling;return cA(e,[null!=(a=d.leftSibling)?a:d,null!=(o=i.leftSibling)?o:i])}return cA(e,d)}let u=n.parent;if(u){if("leftright"===u.type||"surd"===u.type)return cA(e,u);if("superscript"===n.parentBranch&&u.subscript)return cA(e,u.subscript);if("above"===n.parentBranch&&u.below)return cA(e,u.below);if("superscript"===n.parentBranch||"subscript"===n.parentBranch)return cz(e,u);if("above"===n.parentBranch||"below"===n.parentBranch)return cA(e,u)}return cz(e,e.lastOffset)},moveToPreviousGroup:e=>{var i;if(0===e.position&&0===e.anchor)return cT(e,"backward");let r=e.at(e.position),a=r.mode;if("text"===a){if(e.selectionIsCollapsed){let a=r;for(;(null==a?void 0:a.mode)==="text";)a=a.leftSibling;let o=r;for(;(null==(i=o.rightSibling)?void 0:i.mode)==="text";)o=o.rightSibling;if(a&&o)return cA(e,[a,o])}for(;(null==r?void 0:r.mode)==="text";)r=r.leftSibling;return r?cz(e,r):cz(e,0)}let o=e.at(e.anchor).parentPrompt,n=o?e.offsetOf(o.leftSibling):Math.max(e.position-1,0),l=cD(e,n,"backward");if(l&&e.offsetOf(l)>n)return cT(e,"backward");if(l)return cz(e,l);if("math"===a){let i=cK(e,r,e=>"leftright"===e.type||"text"===e.type,"backward");if(i){if("text"===i.mode){let r=i;for(;(null==r?void 0:r.mode)==="text";)r=r.leftSibling;return cA(e,[i,r])}return cA(e,i)}let a=r.parent;if(a){if("leftright"===a.type||"surd"===a.type)return cA(e,a);if("subscript"===r.parentBranch&&a.superscript)return cA(e,a.superscript);if("below"===r.parentBranch&&a.above)return cA(e,a.above);if("superscript"===r.parentBranch||"subscript"===r.parentBranch)return cz(e,a);if("above"===r.parentBranch||"below"===r.parentBranch)return cA(e,a)}return cz(e,0)}return!1},moveToMathfieldStart:e=>e.selectionIsCollapsed&&0===e.position?(e.announce("plonk"),!1):(e.position=0,e.mathfield.stopCoalescingUndo(),!0),moveToMathfieldEnd:e=>e.selectionIsCollapsed&&e.position===e.lastOffset?(e.announce("plonk"),!1):(e.position=e.lastOffset,e.mathfield.stopCoalescingUndo(),!0),moveToSuperscript:cC,moveToSubscript:cE},{target:"model",changeSelection:!0}),sN({moveToNextPlaceholder:e=>cT(e,"forward"),moveToPreviousPlaceholder:e=>cT(e,"backward")},{target:"model",changeSelection:!0,audioFeedback:"return"}),sN({scrollIntoView:e=>(e.scrollIntoView(),!0),scrollToStart:e=>(e.field.scroll(0,0),!0),scrollToEnd:e=>{let i=e.field.getBoundingClientRect();return e.field.scroll(i.left-window.scrollX,0),!0},toggleKeystrokeCaption:function(e){return(e.keystrokeCaptionVisible=!e.keystrokeCaptionVisible,e.keystrokeCaptionVisible)?cO().innerHTML="":sg("mathlive-keystroke-caption-panel").style.visibility="hidden",!1},toggleContextMenu:e=>{let i=e.toggleContextMenu();return i||e.model.announce("plonk"),i},plonk:e=>(e.model.announce("plonk"),!0),switchMode:(e,i,r,a)=>(e.switchMode(i,r,a),!0)}),sN({undo:e=>(e.undo(),!0),redo:e=>(e.redo(),!0)},{target:"mathfield",changeContent:!0}),sN({insert:(e,i,r)=>e.insert(i,r),typedText:(e,i,r)=>(cN(e,i,r),!0),insertDecimalSeparator:e=>{let i=e.model;return"math"===i.mode&&","===globalThis.MathfieldElement.decimalSeparator&&i.at(Math.max(i.position,i.anchor)).isDigit()?(e.insert("{,}",{format:"latex"}),e.snapshot("insert-mord")):e.insert("."),!0},commit:e=>{var i,r;let a=e.model;return a.contentWillChange({inputType:"insertLineBreak"})&&(null==(i=e.host)||i.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),null!=(r=a.parentEnvironment)&&r.isMultiline&&e.executeCommand("addRowAfter"),a.contentDidChange({inputType:"insertLineBreak"})),!0},insertPrompt:(e,i,r)=>{let a=e.getPrompts(),o="prompt-"+Date.now().toString(36).slice(-2)+Math.floor(1e5*Math.random()).toString(36),n=0;for(;a.includes(o)&&n<100;){if(99===n)return console.error("could not find a unique ID after 100 tries"),!1;o="prompt-"+Date.now().toString(36).slice(-2)+Math.floor(1e5*Math.random()).toString(36),n++}return e.insert(`\\placeholder[${null!=i?i:o}]{}`,r),!0}},{target:"mathfield",canUndo:!0,changeContent:!0,changeSelection:!0}),sN({copyToClipboard:e=>(e.focus(),e.model.selectionIsCollapsed&&e.select(),"queryCommandSupported"in document&&document.queryCommandSupported("copy")&&document.execCommand("copy")||e.element.querySelector(".ML__keyboard-sink").dispatchEvent(new ClipboardEvent("copy",{bubbles:!0,composed:!0})),!1)},{target:"mathfield"}),sN({cutToClipboard:e=>(e.focus(),"queryCommandSupported"in document&&document.queryCommandSupported("cut")&&document.execCommand("cut")||e.element.querySelector(".ML__keyboard-sink").dispatchEvent(new ClipboardEvent("cut",{bubbles:!0,composed:!0})),!0),pasteFromClipboard:e=>(e.focus(),"queryCommandSupported"in document&&document.queryCommandSupported("paste")?document.execCommand("paste"):navigator.clipboard.readText().then(i=>{i&&e.model.contentWillChange({inputType:"insertFromPaste",data:i})?(e.stopCoalescingUndo(),e.stopRecording(),e.insert(i,{mode:e.model.mode})&&(sp(e),e.startRecording(),e.snapshot("paste"),e.model.contentDidChange({inputType:"insertFromPaste"}),sB(e))):e.model.announce("plonk"),e.startRecording()}).catch(()=>{e.model.announce("plonk"),e.startRecording()}),!0)},{target:"mathfield",canUndo:!0,changeContent:!0,changeSelection:!0}),sN({selectGroup:e=>{let i=cV(e);return i||e.announce("plonk"),i},selectAll:e=>e.setSelection(0,e.lastOffset),extendSelectionForward:e=>cw(e,"forward",{extend:!0}),extendSelectionBackward:e=>cw(e,"backward",{extend:!0}),extendToNextWord:e=>c_(e,"forward",{extend:!0}),extendToPreviousWord:e=>c_(e,"backward",{extend:!0}),extendSelectionUpward:e=>cw(e,"upward",{extend:!0}),extendSelectionDownward:e=>cw(e,"downward",{extend:!0}),extendToNextBoundary:e=>c_(e,"forward",{extend:!0}),extendToPreviousBoundary:e=>c_(e,"backward",{extend:!0}),extendToGroupStart:e=>{let i=e.setSelection(e.anchor,e.offsetOf(e.at(e.position).firstSibling));return i||e.announce("plonk"),i},extendToGroupEnd:e=>{let i=e.setSelection(e.anchor,e.offsetOf(e.at(e.position).lastSibling));return i||e.announce("plonk"),i},extendToMathFieldStart:e=>{let i=e.setSelection(e.anchor,0);return i||e.announce("plonk"),i},extendToMathFieldEnd:e=>{let i=e.setSelection(e.anchor,e.lastOffset);return i||e.announce("plonk"),i}},{target:"model",changeSelection:!0});var cH=null,cW=0,cU=class e{static start(i,r,a,o){var n;e.element=i,null==(n=e.controller)||n.abort(),e.controller=new AbortController;let l={signal:e.controller.signal};"PointerEvent"in window?(i.addEventListener("pointermove",a,l),i.addEventListener("pointerup",o,l),i.addEventListener("pointercancel",o,l),cJ(r)&&(e.pointerId=r.pointerId,i.setPointerCapture(r.pointerId))):(window.addEventListener("mousemove",a,l),window.addEventListener("blur",o,l),window.addEventListener("mouseup",o,l))}static stop(){var i;null==(i=e.controller)||i.abort(),e.controller=void 0,"number"==typeof e.pointerId&&(e.element.releasePointerCapture(e.pointerId),e.pointerId=void 0)}};function cJ(e){return null!==e&&void 0!==globalThis.PointerEvent&&e instanceof PointerEvent}function cX(e,i,r){return e>=r.left&&e<=r.right&&i>=r.top&&i<=r.bottom}function cG(e,i){var r,a,o,n,l,s,c,d,u,h;if(i.buttons>1)return;e.atomBoundsCache?e.atomBoundsCache.clear():e.atomBoundsCache=new Map;let p,m=!1,f=!1,g="none",b=!1,y=!1,v=i.clientX,x=i.clientY,_=Date.now(),w=e.field,k=setInterval(()=>{b?w.scroll({top:0,left:w.scrollLeft-16}):y&&w.scroll({top:0,left:w.scrollLeft+16})},32);function M(){cU.stop(),m=!1,clearInterval(k),e.element.classList.remove("tracking"),i&&i.preventDefault()}cH&&5>Math.abs(cH.x-v)&&5>Math.abs(cH.y-x)&&Date.now()<cH.time+500?(cW+=1,cH.time=_):(cH={x:v,y:x,time:_},cW=1);let S=w.getBoundingClientRect(),L=null!=(a=null==(r=e.container)?void 0:r.getBoundingClientRect())?a:e.element.getBoundingClientRect(),C=null!=(n=null==(o=e.element)?void 0:o.getBoundingClientRect())?n:L,E=cX(v,x,S),A=!E&&!!L&&cX(v,x,L),z=!E&&!A&&!!C&&cX(v,x,C),T=E?v:A||z?(c=S.left,d=S.right,v<c?c:v>d?d:v):v,D=E?x:A||z?(u=S.top,h=S.bottom,x<u?u:x>h?h:x):x;if(E||A||z){if(e.flushInlineShortcutBuffer(),(p=cZ(e,T,D,{bias:0}))!==e.model.anchor){let i=e.defaultStyle.variantStyle;e.defaultStyle=void 0!==i?{variantStyle:i}:{},e.styleBias="left"}if(p>=0){if(e.element.classList.add("tracking"),i.shiftKey){let i=e.model.selectionIsCollapsed;e.model.extendSelectionTo(e.model.anchor,p),g=sm(e.model)||i?"all":"selection"}else if("placeholder"===e.model.at(p).type||"prompt"===e.model.at(p).type){let i=e.model.at(p);i.hasChildren&&i.firstChild?e.model.position=e.model.offsetOf(i.firstChild):e.model.setSelection(p-1,p),g="selection"}else if((null==(l=e.model.at(p).rightSibling)?void 0:l.type)==="placeholder"||(null==(s=e.model.at(p).rightSibling)?void 0:s.type)==="prompt"){let i=e.model.at(p).rightSibling;i.hasChildren&&i.firstChild?e.model.position=e.model.offsetOf(i.firstChild):e.model.setSelection(p,p+1),g="selection"}else{let i=e.model.at(p);if(i.captureSelection&&i.hasChildren&&i.body&&i.body.length>0){let r=i.body.find(e=>"first"!==e.type);r&&("placeholder"===r.type||"prompt"===r.type)&&r.hasChildren&&r.firstChild?(e.model.position=e.model.offsetOf(r.firstChild),g="selection"):(e.model.position=p,g=sm(e.model)?"all":"selection")}else e.model.position=p,g=sm(e.model)?"all":"selection"}3===i.detail||cW>2?(M(),(3===i.detail||3===cW)&&(e.model.selection={ranges:[[0,e.model.lastOffset]]},g="all")):m||(m=!0,cU.start(w,i,function(i){if(!e.hasFocus())return void M();let r=i.clientX,a=i.clientY,o=cJ(i)&&"touch"===i.pointerType?20:5;if(Date.now()<_+500&&Math.abs(v-r)<o&&Math.abs(x-a)<o){i.preventDefault(),i.stopPropagation();return}let n=w.getBoundingClientRect();y=r>n.right,b=r<n.left;let l=p;cJ(i)&&(i.isPrimary||(l=cZ(e,i.clientX,i.clientY,{bias:0})));let s=cZ(e,r,a,{bias:r<=v?r===v?0:-1:1});l>=0&&s>=0&&(e.model.extendSelectionTo(l,s),sB(e)),f&&cV(e.model)},M),(2===i.detail||2===cW)&&(f=!0,cV(e.model),g="all"))}e.hasFocus()||(g="none",e.onFocus(),e.model.announce("line"))}else cH=null;e.stopCoalescingUndo(),"none"!==g&&(e.model.selectionIsCollapsed&&(g="all"),sB(e)),i.preventDefault()}function cZ(e,i,r,a){var o;let n=e.field.querySelector(".ML__latex").getBoundingClientRect();if(!n)return 0;if(i>n.right||r>n.bottom+8)return e.model.lastOffset;if(i<n.left||r<n.top-8)return 0;(a=null!=a?a:{}).bias=null!=(o=a.bias)?o:0;let l=function(e,i,r){let[,a]=function e(i,r,a,o,n){if(!a.id)return[1/0,null];if(r.has(a.id))return r.get(a.id);let l=nu(i,a);if(!l)return[1/0,null];let s=[1/0,null],c=i.model;if(a instanceof nQ){let l=-1,c=1/0;for(let e=0;e<a.rows.length;e++){let r=a.rows[e];if(!r||0===r.length)continue;let o=1/0,s=-1/0;for(let e of r)if(e)for(let r of e){let e=nu(i,r);e&&(o=Math.min(o,e.top),s=Math.max(s,e.bottom))}if(1/0!==o&&-1/0!==s){let i;(i=n<o?o-n:n>s?n-s:0)<c&&(c=i,l=e)}}for(let c of l>=0?[a.rows[l]]:a.rows)for(let a of c)if(a)for(let l of a){let a=e(i,r,l,o,n);a[0]<=s[0]&&(s=a)}if(!a.isMultiline)for(let l of a.children){let a=e(i,r,l,o,n);a[0]<=s[0]&&(s=a)}}else if(a.hasChildren&&!a.captureSelection&&o>=l.left&&o<=l.right){for(let l of a.children){let a=e(i,r,l,o,n);a[0]<=s[0]&&(s=a)}for(let l of a.branches){let d=a.branch(l);if(!d||0===d.length)continue;let u=function(e,i){let[r,a]=i,o=null;for(let i=r;i<=a;i++){let r=nu(e,e.model.at(i));r&&(o?(o.top=Math.min(o.top,r.top),o.bottom=Math.max(o.bottom,r.bottom),o.left=Math.min(o.left,r.left),o.right=Math.max(o.right,r.right)):o=r)}return null!=o?o:{top:0,bottom:0,left:0,right:0}}(i,[c.offsetOf(d[0]),c.offsetOf(d[d.length-1])]);if(n>=u.top&&n<=u.bottom)for(let a of d){let l=e(i,r,a,o,n);l[0]<=s[0]&&(s=l)}}}return s[1]||(s=[function(e,i,r){if(e>=r.left&&e<=r.right&&i>=r.top&&i<=r.bottom)return 0;let a=e-(r.left+r.right)/2,o=i-(r.top+r.bottom)/2;return a*a+o*o}(o,n,l),a]),r.set(a.id,s),s}(e,new Map,e.model.root,i,r);return a}(e,i,r),s=[],c=l;for(;c;)s.unshift(c),c=c.parent;for(let e of s)if(e.captureSelection){l=e;break}let d=e.model.offsetOf(l);if(d<0)return -1;if(l.leftSibling){let r="placeholder"===l.type||"prompt"===l.type;if(0!==a.bias||r)a.bias<0&&(d=e.model.offsetOf(l.leftSibling));else{let r=nu(e,l);r&&i<(r.left+r.right)/2&&(d=e.model.offsetOf(l.leftSibling))}}return d}function cY(e,i,r,a){var o;let n,l=[];if("string"!=typeof i||"math-json"===a.format){let r=globalThis.MathfieldElement.computeEngine;if(!r)return["math-json",[]];[n,i]=["latex",r.box(i).latex],l=ll(i,{context:e.mathfield.context})}else"string"==typeof i&&"ascii-math"===a.format?([n,i]=o6(i,{format:"ascii-math",inlineShortcuts:e.mathfield.options.inlineShortcuts}),l=ll(i,{context:e.mathfield.context}),"latex"!==n&&e.mathfield.options.removeExtraneousParentheses&&(l=l.map(e=>cQ(e)))):("auto"===a.format||null!=(o=a.format)&&o.startsWith("latex"))&&("auto"===a.format&&([n,i]=o6(i,{format:"auto",inlineShortcuts:e.mathfield.options.inlineShortcuts})),"latex"===a.format&&([,i]=nt(i)),l=ll(i,{context:e.mathfield.context,args:r}),"latex"!==a.format&&e.mathfield.options.removeExtraneousParentheses&&(l=l.map(e=>cQ(e))));return lI(l,a.style),[null!=n?n:"latex",l]}function cQ(e){var i;if(e instanceof le&&"("!==e.leftDelim&&")"===e.rightDelim){let r=null==(i=e.body)?void 0:i.filter(e=>"first"!==e.type);if((null==r?void 0:r.length)===1&&"genfrac"===r[0].type)return r[0]}for(let i of e.branches)e.hasEmptyBranch(i)||e.setChildren(e.branch(i).map(e=>cQ(e)),i);return e instanceof nQ&&e.forEachCell((i,r,a)=>{e.setCell(r,a,i.map(e=>cQ(e)))}),e}function c0(e){return!!(e.isDigit()||function(e){if("mord"===e.type&&"e"===e.value){let i=e.leftSibling;if(i&&i.isDigit())return!0}if("mbin"===e.type&&("+"===e.value||"-"===e.value||"−"===e.value)){let i=e.leftSibling,r=e.rightSibling;if((null==i?void 0:i.type)==="mord"&&"e"===i.value&&r&&r.isDigit()){let e=i.leftSibling;if(e&&e.isDigit())return!0}}if("subsup"===e.type){let i=e.leftSibling;if(i&&i.isDigit()&&"0"===i.value){let e=i.leftSibling;if(e&&e.isDigit()&&"1"===e.value){let i=e.leftSibling;if((null==i?void 0:i.type)==="mbin"&&("×"===i.value||"\\times"===i.value)){let e=i.leftSibling;if(e&&e.isDigit())return!0}}}}if(e.isDigit()&&"0"===e.value){let i=e.leftSibling,r=e.rightSibling;if(i&&i.isDigit()&&"1"===i.value&&(null==r?void 0:r.type)==="subsup"){let e=i.leftSibling;if((null==e?void 0:e.type)==="mbin"&&("×"===e.value||"\\times"===e.value)){let i=e.leftSibling;if(i&&i.isDigit())return!0}}}if(e.isDigit()&&"1"===e.value){let i=e.rightSibling;if(i&&i.isDigit()&&"0"===i.value){let r=i.rightSibling;if((null==r?void 0:r.type)==="subsup"){let i=e.leftSibling;if((null==i?void 0:i.type)==="mbin"&&("×"===i.value||"\\times"===i.value)){let e=i.leftSibling;if(e&&e.isDigit())return!0}}}}if("mbin"===e.type&&("×"===e.value||"\\times"===e.value)){let i=e.leftSibling,r=e.rightSibling;if(i&&i.isDigit()&&r&&r.isDigit()&&"1"===r.value){let e=r.rightSibling;if(e&&e.isDigit()&&"0"===e.value){let i=e.rightSibling;if((null==i?void 0:i.type)==="subsup")return!0}}}return!1}(e))||!!(e.type&&/^(mord|surd|subsup|leftright|mop|mclose)$/.test(e.type))&&"extensible-symbol"!==e.type}function c1(e){return(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/\\/g,"\\textbackslash ")).replace(/#/g,"\\#")).replace(/%/g,"\\%")).replace(/&/g,"\\&")).replace(/_/g,"\\_")).replace(/{/g,"\\textbraceleft ")).replace(/}/g,"\\textbraceright ")).replace(/lbrace/g,"\\textbraceleft ")).replace(/rbrace/g,"\\textbraceright ")).replace(/\^/g,"\\textasciicircum ")).replace(/~/g,"\\textasciitilde ")).replace(/£/g,"\\textsterling ")}function c4(e){return{value:e.model.getValue(),selectionIsCollapsed:e.model.selectionIsCollapsed,canUndo:e.canUndo(),canRedo:e.canRedo(),style:function(e){var i;if(e.selectionIsCollapsed)return null==(i=e.at(e.position))?void 0:i.style;let r=e.getAtoms(e.selection);if(0===r.length)return{};let a=f({},r[0].style);for(let e of r)for(let[i,r]of Object.entries(e.style))a[i]!==r&&delete a[i];return a}(e.model),mode:e.model.mode}}new class extends na{constructor(){super("math")}onPaste(e,i){if(!i||!e.model.contentWillChange({data:"string"==typeof i?i:null,dataTransfer:"string"==typeof i?null:i,inputType:"insertFromPaste"}))return!1;let r="",a="auto",o="string"!=typeof i?i.getData("application/json+mathlive"):"";if(o)try{let i=JSON.parse(o);if(i&&Array.isArray(i)){e.snapshot();let r=lR(i),{model:a}=e;a.selectionIsCollapsed||a.deleteAtoms(oQ(a.selection));let o=a.at(a.position);if(o.parent instanceof nQ){o.parentBranch;let e=[],i=[];for(let a of("first"===r[0].type&&r.shift(),"first"===r[r.length-1].type&&r.pop(),r))"first"===a.type&&i.length>0?(e.push(i),i=[a]):i.push(a);i.length>0&&e.push(i);let a=Number(o.parentBranch[0]),n=Number(o.parentBranch[1]),l=o.parent.maxColumns;for(;o.parent.colCount-n<e.length&&o.parent.colCount<l;)o.parent.addColumn();o.parent.addChildrenAfter(e[0],o);for(let i=1;i<e.length;i++)++n>=l&&(n=0,o.parent.addRowAfter(a),a++),o.parent.setCell(a,n,e[i])}else o.parent.addChildrenAfter(r.filter(e=>"first"!==e.type),o);return a.position=a.offsetOf(r[r.length-1]),a.contentDidChange({inputType:"insertFromPaste"}),sB(e),!0}}catch(e){}if((o="string"!=typeof i?i.getData("application/json"):"")&&globalThis.MathfieldElement.computeEngine)try{let e=JSON.parse(o);if("object"==typeof e&&"latex"in e&&e.latex&&(r=e.latex),!r){let i=globalThis.MathfieldElement.computeEngine.box(e);i&&!i.has("Error")&&(r=i.latex)}r||(a="latex")}catch(e){}if(!r&&"string"!=typeof i&&(r=i.getData("application/x-latex"))&&(a="latex"),r||(r="string"==typeof i?i:i.getData("text/plain")),r){let i;return[i,r]=nt(r),"auto"===a&&i&&(a="latex"),e.stopCoalescingUndo(),e.stopRecording(),this.insert(e.model,r,{format:a})&&(e.startRecording(),e.snapshot("paste"),sB(e)),e.startRecording(),!0}return!1}insert(e,i,r){var a,o,n,l;let s="string"==typeof i?i:null!=(o=null==(a=globalThis.MathfieldElement.computeEngine)?void 0:a.box(i).latex)?o:"";if(!r.silenceNotifications&&!e.contentWillChange({data:s,inputType:"insertText"}))return!1;r.insertionMode||(r.insertionMode="replaceSelection"),r.selectionMode||(r.selectionMode="placeholder"),r.format||(r.format="auto");let{silenceNotifications:c}=e;r.silenceNotifications&&(e.silenceNotifications=!0);let d=e.silenceNotifications;e.silenceNotifications=!0;let u={"?":"\\placeholder{}","@":"\\placeholder{}"};u[0]="replaceAll"===r.insertionMode?"":e.getValue(e.selection,"latex-unstyled"),"replaceSelection"===r.insertionMode?e.deleteAtoms(oQ(e.selection)):"replaceAll"===r.insertionMode?e.deleteAtoms():"insertBefore"===r.insertionMode?e.collapseSelection("backward"):"insertAfter"===r.insertionMode&&e.collapseSelection("forward");let h=e.at(e.position);h&&!h.isLastSibling&&(null==(n=e.at(e.position+1))?void 0:n.type)==="placeholder"?e.deleteAtoms([e.position,e.position+1]):(null==h?void 0:h.type)==="placeholder"&&e.deleteAtoms([e.position-1,e.position]);let p=-1;u[0]?u["@"]=u[0]:"string"==typeof i&&/(^|[^\\])#@/.test(i)&&(p=function(e){let i=e.at(e.position);if(!i)return -1;if("text"===i.mode){for(;!i.isFirstSibling&&"text"===i.mode;)i=i.leftSibling;return e.offsetOf(i)}let r=i,a=!1;if("mclose"===i.type){let e=nK[i.value];for(;!i.isFirstSibling&&("mopen"!==i.type||i.value!==e);){let e=i.leftSibling;if(!e)break;i=e}if(!i.isFirstSibling){let e=i.leftSibling;e&&(i=e)}a=!0}else if("leftright"===i.type){let e=i.leftSibling;e&&(i=e),a=!0}if(a)for(;!i.isFirstSibling&&(i.isFunction||c0(i));){let e=i.leftSibling;if(!e)break;i=e}else{let e=[];for(;!i.isFirstSibling&&(c0(i)||e.length>0);){"mclose"===i.type&&e.unshift(i.value),"mopen"===i.type&&e.length>0&&i.value===nK[e[0]]&&e.shift();let r=i.leftSibling;if(!r)break;i=r}}return r===i?-1:e.offsetOf(i)}(e))>=0&&(u["@"]=e.getValue(p,e.position,"latex")),u[0]||(u[0]=u["?"]);let m=!1,f=e=>(m=!0,u[e]),[g,b]=cY(e,i,f,r);if(!b)return!1;let y=1===b.length&&"genfrac"===b[0].type,v=e.at(e.position);y&&p>=0&&"function"==typeof e.mathfield.options.isImplicitFunction&&v&&e.mathfield.options.isImplicitFunction(v.command)&&(u["@"]=u["?"],m=!1,[g,b]=cY(e,i,f,r));let x=e.position;if(1===b.length&&b[0].isRoot)e.root=b[0];else{let r=e.at(e.position),a=null!=(l=null==r?void 0:r.parent)?l:e.root,o=a.hasEmptyBranch("body");if(y&&"latex"!==g&&e.mathfield.options.removeExtraneousParentheses&&a instanceof le&&"("===a.leftDelim&&o){let e=a.parent,i=a.parentBranch;e.removeChild(a),e.setChildren(b,i)}let n=e.at(e.position);if(n)n.parent.addChildrenAfter(b,n);else{let e=a.branch("body"),i=null==e?void 0:e[0];i?a.addChildrenAfter(b,i):a.setChildren(b,"body")}if(p>=0){e.deleteAtoms([p,x]);let i=e.root.branch("body");if(i)for(let r of i)r.parent!==e.root&&(r.parent=e.root,r.parentBranch="body")}"latex"===g&&"string"==typeof i&&(null==a?void 0:a.type)==="root"&&o&&!m&&(a.verbatimLatex=i)}e.silenceNotifications=d;let _=b[b.length-1];if("placeholder"===r.selectionMode){let i;if(1===b.length&&"genfrac"===b[0].type){let e=b[0].branch("above");if(!(i=null==e?void 0:e.find(e=>"placeholder"===e.type))){let e=b[0].branch("below");i=null==e?void 0:e.find(e=>"placeholder"===e.type)}}if(i||(i=b.flatMap(e=>[e,...e.children]).find(e=>"placeholder"===e.type)),i){let r=e.offsetOf(i);e.setSelection(r-1,r),e.announce("move")}else if(_){let i=_.body,r=_.hasEmptyBranch("body");i&&r?e.setSelection(e.offsetOf(i[0]),e.offsetOf(i[i.length-1])+1):e.position=e.offsetOf(_)}}else"before"===r.selectionMode||("after"===r.selectionMode?_&&(e.position=e.offsetOf(_)):"item"===r.selectionMode&&e.setSelection(e.anchor,e.offsetOf(_)));return e.contentDidChange({data:s,inputType:"insertText"}),e.silenceNotifications=c,!0}},new class extends na{constructor(){super("text")}onPaste(e,i){if(!i)return!1;let r="string"==typeof i?i:i.getData("text/plain");return!!(r&&e.model.contentWillChange({inputType:"insertFromPaste",data:r}))&&(e.stopCoalescingUndo(),e.stopRecording(),this.insert(e.model,r)&&(e.model.contentDidChange({inputType:"insertFromPaste"}),e.startRecording(),e.snapshot("paste"),sB(e)),e.startRecording(),!0)}insert(e,i,r={}){if(!e.contentWillChange({data:i,inputType:"insertText"}))return!1;r.insertionMode||(r.insertionMode="replaceSelection"),r.selectionMode||(r.selectionMode="placeholder"),r.format||(r.format="auto");let{silenceNotifications:a}=e;r.silenceNotifications&&(e.silenceNotifications=!0);let o=e.silenceNotifications;e.silenceNotifications=!0,"replaceSelection"!==r.insertionMode||e.selectionIsCollapsed?"replaceAll"===r.insertionMode?(e.root.setChildren([],"body"),e.position=0):"insertBefore"===r.insertionMode?e.collapseSelection("backward"):"insertAfter"===r.insertionMode&&e.collapseSelection("forward"):e.deleteAtoms(oQ(e.selection));let n=function(e,i){if(e.includes("$")){let r=[],a=0,o=!1,n="";for(;a<e.length;)"$"===e[a]?a+1<e.length&&"$"===e[a+1]?(!o&&n?(r.push(c1(n)),n=""):o&&n&&(r.push(n),n=""),r.push("$$"),o=!o,a+=2):(!o&&n?(r.push(c1(n)),n=""):o&&n&&(r.push(n),n=""),r.push("$"),o=!o,a+=1):(n+=e[a],a+=1);return n&&(o?r.push(n):r.push(c1(n))),ll(r.join(""),{context:i,parseMode:"text"})}return ll(c1(e),{context:i,parseMode:"text"})}(i,e.mathfield.context);if(lI(n,r.style),!n)return!1;let l=e.at(e.position),s=l.parent.addChildrenAfter(n,l);return e.silenceNotifications=o,"before"===r.selectionMode||("item"===r.selectionMode?e.setSelection(e.anchor,e.offsetOf(s)):s&&(e.position=e.offsetOf(s))),e.contentDidChange({data:i,inputType:"insertText"}),e.silenceNotifications=a,!0}};var c2=(e,i)=>`
|
|
3334
|
+
[contenteditable]:not([contenteditable="false"]), details>summary`)].filter(function(e){var i,r;return!((i=e).disabled||"hidden"===i.type&&"INPUT"===i.tagName.toUpperCase()||function(e){if(!v()||e===document.activeElement||e.contains(document.activeElement))return!1;if("hidden"===getComputedStyle(e).visibility)return!0;let i=e.getBoundingClientRect();if(0===i.width||0===i.height)return!0;for(;e;){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(i)||"INPUT"===(r=e).tagName.toUpperCase()&&"radio"===r.type&&!function(e){var i;if(!e.name)return!0;let r=function(e,i){for(let r of e)if(r.checked&&r.form===i)return r;return null}((null!=(i=e.form)?i:e.ownerDocument).querySelectorAll('input[type="radio"][name="'+e.name+'"]'),e.form);return!r||r===e}(r)||0>a(e))}).forEach((e,o)=>{let n=a(e);0===n?i.push(e):r.push({documentOrder:o,tabIndex:n,node:e})}),r.sort((e,i)=>e.tabIndex===i.tabIndex?e.documentOrder-i.documentOrder:e.tabIndex-i.tabIndex).map(e=>e.node).concat(i)):[]}();if(!document.activeElement||n.length<=1)return e.announce("plonk"),!1;let l=n.indexOf(document.activeElement)+o;return l<0&&(l=n.length-1),l>=n.length&&(l=0),n[l].focus(),e.mathfield.stopCoalescingUndo(),!0}return cT(e,s),!0}function cK(e,i=0,r="forward"){return e.findAtom(i=>"placeholder"===i.type||"prompt"===i.type||!e.mathfield.readOnly&&i.treeDepth>2&&i.isFirstSibling&&i.isLastSibling,i,r)}function cB(e,i,r,a){if("forward"===a){let e=i.rightSibling;for(;e&&!r(e);)e=e.rightSibling;return e}let o=i.leftSibling;for(;o&&!r(o);)o=o.leftSibling;return o}function c$(e,i,r){"function"==typeof i&&(r=i,i=1/0),void 0===i&&(i=1/0);let a=e.position,o=!1,n="";for(;!o;){let l=e.at(a);(o=0===i||void 0===l||"first"===l.type||"math"!==l.mode||!(l.type&&/mord|mpunct|operator/.test(l.type)||"mop"===l.type&&/[a-zA-Z ]+/.test(l.value))||!l.hasEmptyBranch("superscript")||!l.hasEmptyBranch("subscript")||"function"==typeof r&&!r(l))||(l.mode="text",l.command=l.value,l.verbatimLatex=void 0,n+=l.value),a-=1,i-=1}e.contentDidChange({data:n,inputType:"insertText"})}function cP(e,i,r){"function"==typeof i&&(r=i,i=1/0),void 0===i&&(i=1/0);let a=e.position,o=!1,n=[];for(;!o;){let l=e.at(a);(o=0===i||!l||"first"===l.type||l.isFirstSibling||"text"!==l.mode||" "===l.value||"function"==typeof r&&!r(l))||(n.push(oG.serialize([l],{defaultMode:"math"})),l.mode="math"),a-=1,i-=1}cO(e),e.contentDidChange({data:of(n),inputType:"insertText"})}function cO(e){var i;let r=e.position-1;for(;r>=0&&(null==(i=e.at(r))?void 0:i.mode)==="math";)r-=1;if(!(r<0)&&"text"===e.at(r).mode&&" "===e.at(r).value&&"math"===e.at(r-1).mode){e.at(r-1).parent.removeChild(e.at(r-1));let i=e.silenceNotifications;e.silenceNotifications=!0,e.position-=1,e.silenceNotifications=i,e.contentDidChange({inputType:"deleteContent"})}}function cR(){return document.getElementById("mathlive-keystroke-caption-panel")||(nz("keystroke-caption"),nz("core"),sb("mathlive-keystroke-caption-panel"))}function cI(e,i){var r,a,o,n;let{model:l}=e,s=sr(i);if(i.isTrusted){!function(e){var i,r;if(!e||"Unidentified"===e.key||"Dead"===e.key)return;let a=e.shiftKey&&e.altKey?3:e.altKey?2:+!!e.shiftKey;for(let o of T)(null==(i=o.mapping[e.code])?void 0:i[a])===e.key?o.score+=1:null!=(r=o.mapping[e.code])&&r[a]&&(o.score=0);T.sort((e,i)=>i.score-e.score)}(i);let r=$();e.keyboardLayout!==r.id&&(e.keyboardLayout=r.id,e._keybindings=void 0)}if(clearTimeout(e.inlineShortcutBufferFlushTimer),e.inlineShortcutBufferFlushTimer=0,function(e,i){if(!e.isSelectionEditable||!e.keystrokeCaptionVisible)return;let r=cR(),a=e.element.getBoundingClientRect();r.style.left=`${a.left}px`,r.style.top=`${a.top-64}px`,r.innerHTML=globalThis.MathfieldElement.createHTML("<span>"+(l6(i)||i)+"</span>"+r.innerHTML),r.style.visibility="visible",setTimeout(()=>{r.childNodes.length>0&&r.childNodes[r.childNodes.length-1].remove(),0===r.childNodes.length&&(r.style.visibility="hidden")},3e3)}(e,s),i.isTrusted&&i.defaultPrevented)return e.flushInlineShortcutBuffer(),!1;let c,d=0,u="",h=0,p=e.inlineShortcutBuffer,m=!1;if(e.isSelectionEditable&&l.selectionIsPlaceholder&&l9(i)&&(e.flushInlineShortcutBuffer(),l.deleteAtoms(oQ(l.selection)),e.snapshot("delete"),m=!0),e.isSelectionEditable){if("math"===l.mode&&(!l.selectionIsPlaceholder||m))if("[Backspace]"===s)"insert-shortcut"===e.undoManager.lastOp?u="undo":p.pop();else if(l9(i)){let o=si(i),n=[...null!=(a=null==(r=p[p.length-1])?void 0:r.keystrokes)?a:[],o];p.push({state:l.getState(),keystrokes:n,leftSiblings:function(e){let i=e.model,r=[],a=i.at(Math.min(i.position,i.anchor));for(;"first"!==a.type;)r.push(a),a=a.leftSibling;return r}(e)}),d=0;let s="";for(;!c&&d<n.length;)h=p.length-(n.length-d),s=n.slice(d).join(""),!(c=o2(p[h].leftSiblings,s,e.options.inlineShortcuts))&&/^[a-zA-Z][a-zA-Z0-9]+?([_\^][a-zA-Z0-9\*\+\-]+?)?$/.test(s)&&(c=e.options.onInlineShortcut(e,s)),d+=1;e.flushInlineShortcutBuffer({defer:!0})}else e.flushInlineShortcutBuffer();e.options.smartMode&&(c?e.switchMode("math"):function(e,i,r){var a,o;let{model:n}=e;if("latex"===n.mode||!n.at(n.position).isLastSibling||!r||!l9(r))return!1;let l=si(r);if(!n.selectionIsCollapsed)return!!("text"===e.model.mode&&/[/_^]/.test(l));let s=function(e){let i="",r=e.position,a=!1;for(;!a;){let o=e.at(r);(a=!(o&&("text"===o.mode||"math"===o.mode&&o.type&&/mord|mpunct/.test(o.type))))||(i=o.value+i),r-=1}return i}(n)+l;if("text"===e.model.mode){if("Esc"===i||/[/\\]/.test(l))return!0;if(/[\^_]/.test(l))return/(^|\s)[a-zA-Z][^_]$/.test(s)&&cP(n,1),!0;let e={")":"(","}":"{","]":"["}[l],{parent:r}=n.at(n.position);if(e&&r instanceof lt&&r.leftDelim===e)return!0;if(/(^|[^a-zA-Z])(a|I) $/.test(s))return!1;if(/[$€£₤₺¥¤฿¢₡₧₨₹₩₱]/u.test(l))return!0;if(/(^|[^a-zA-Z'’])[a-zA-Z] $/.test(s))return cP(n,1),!1;if(/\D\.[^\d\s]$/.test(s)){cP(n,1);let e=n.at(n.position);return e.value="⋅",e.style.variant="normal",e.command="\\cdot",e.verbatimLatex=void 0,n.contentDidChange({data:"\\cdot",inputType:"insertText"}),!0}if(/(^|\s)[a-zA-Z][^a-zA-Z]$/.test(s)||/\.\d$/.test(s)||/\([\d+\-.]$/.test(s))return cP(n,1),!0;if(/\([a-z][,;]$/.test(s))return cP(n,2),!0;if(/[\d+\-=><*|]$/.test(l))return cO(n),!0}else{if("[Space]"===i)return c$(n,void 0,e=>/[a-z][:,;.]$/.test(e.value)),!0;if(/[a-zA-Z]{3,}$/.test(s)&&!/(dxd|abc|xyz|uvw)$/.test(s)){let i=null!=(o=null==(a=/[a-zA-Z]+$/.exec(s))?void 0:a[0])?o:"",r=e.options.inlineShortcuts;if(!(i&&r&&Object.keys(r).some(e=>e.startsWith(i))))return c$(n,void 0,e=>/[a-zA-Z]/.test(e.value)),!0}if(/(^|\W)(if)$/i.test(s))return c$(n,1),!0;if(/(\u0393|\u0394|\u0398|\u039B|\u039E|\u03A0|\u03A3|\u03A5|\u03A6|\u03A8|\u03A9|[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5){3,}$/u.test(s)&&!/(αβγ)$/.test(s))return c$(n,void 0,e=>/(:|,|;|.|\u0393|\u0394|\u0398|\u039B|\u039E|\u03A0|\u03A3|\u03A5|\u03A6|\u03A8|\u03A9|[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5)/u.test(e.value)),!0;if("?"===l||"."===l&&!/[\d-+]\.$/.test(s))return!0}return!1}(e,s,i)&&(e.switchMode({math:"text",text:"math"}[l.mode]),u=""))}if(!c){if(u||(u=function(e,i,r){if(0===e.length)return"";let a=E(C(sr(r))),o=E({key:r.key,shift:r.shiftKey,alt:r.altKey,ctrl:r.ctrlKey,meta:r.metaKey||r.ctrlKey&&/macos|ios/.test(w()),cmd:!1,win:!1});for(let r=e.length-1;r>=0;r--)if((e[r].key===a||e[r].key===o)&&(!e[r].ifMode||e[r].ifMode===i))return e[r].command;return""}(e.keybindings,l.mode,i)),!u&&("[Enter]"===s||"[Return]"===s)){if(sk())return!1;let r=!0;return l.contentWillChange({inputType:"insertLineBreak"})&&(e.host&&(r=e.host.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))),!r&&i.preventDefault?(i.preventDefault(),i.stopPropagation()):(null!=(o=l.parentEnvironment)&&o.isMultiline&&e.executeCommand("addRowAfter"),l.contentDidChange({inputType:"insertLineBreak"}))),r}if("[Space]"===s&&"latex"===l.mode&&sg(e,"accept-all"))return e.dirty=!0,e.scrollIntoView(),i.preventDefault&&(i.preventDefault(),i.stopPropagation()),!1;if((!u||"[Space]"===s)&&"math"===l.mode){if("[Space]"===s){if(e.styleBias="none",e.flushInlineShortcutBuffer(),e.options.mathModeSpace)return na.insert(l,e.options.mathModeSpace,{format:"latex",mode:"math"}),e.snapshot("insert-space"),u="",e.dirty=!0,e.scrollIntoView(),i.preventDefault&&(i.preventDefault(),i.stopPropagation()),!1;let r=l.at(l.position+1),a=l.at(l.position-1);if((null==r?void 0:r.mode)==="text"||(null==a?void 0:a.mode)==="text")return na.insert(l," ",{mode:"text"}),e.snapshot("insert-space"),e.dirty=!0,e.scrollIntoView(),!1}null!=(n=l.at(l.position))&&n.isDigit()&&","===globalThis.MathfieldElement.decimalSeparator&&","===si(i)&&(u="insertDecimalSeparator")}}if(!c&&!u){if(l.mathfield.smartFence){if(function e(i,r,a){var o;if(!r||"math"!==i.mode)return!1;let n=i.at(i.position),{parent:l}=n,s={"(":"(",")":")","{":"\\lbrace","}":"\\rbrace","[":"\\lbrack","]":"\\rbrack","|":"|"}[r];if(!s)return!1;let c=nB[s],d=nK[s];if(!i.selectionIsCollapsed){i.mathfield.snapshot();let[e,r]=oQ(i.selection),a=i.extractAtoms([e,r]);a=a.filter(e=>"first"!==e.type);let o=l.addChildrenAfter([new lt("left...right",a,{leftDelim:s,rightDelim:d})],i.at(e));return i.setSelection(i.offsetOf(o.firstChild),i.offsetOf(o.lastChild)),i.mathfield.snapshot("insert-fence"),i.contentDidChange({data:s,inputType:"insertText"}),!0}if("|"===s){let e=l instanceof lt?l.leftDelim+l.rightDelim:"";if("\\lbrace\\rbrace"===e||"\\{\\}"===e||"\\lbrace?"===e)return i.mathfield.snapshot(),na.insert(i,"\\,\\middle\\vert\\,",{format:"latex",style:a}),i.mathfield.snapshot("insert-fence"),i.contentDidChange({data:s,inputType:"insertText"}),!0}if(d){if(l instanceof lt&&l.firstChild===n&&("?"===l.leftDelim||"."===l.leftDelim))return l.leftDelim=s,l.isDirty=!0,i.mathfield.snapshot(),i.contentDidChange({data:s,inputType:"insertText"}),i.mathfield.snapshot("insert-fence"),!0;if(!(l instanceof lt)){let e=n;for(;e&&("mclose"!==e.type||e.value!==d);)e=e.rightSibling;if(e){i.mathfield.snapshot();let r=i.extractAtoms([i.offsetOf(n),i.offsetOf(e)]);r.pop();let a=new lt("left...right",r=r.filter(e=>"first"!==e.type),{leftDelim:s,rightDelim:d});return l.addChildrenAfter([a],n),i.position=i.offsetOf(a.firstChild),i.contentDidChange({data:s,inputType:"insertText"}),i.mathfield.snapshot("insert-fence"),!0}}let e=i.offsetOf(n.lastSibling),r;for(r=i.position;r<=e;r++){let e=i.at(r);if(e instanceof lt&&("?"===e.leftDelim||"."===e.leftDelim)&&cV(s,e.rightDelim))break}let c=i.at(r);if(r<=e&&c instanceof lt){c.leftDelim=s,i.mathfield.snapshot();let e=i.extractAtoms([i.position,r-1]);return e=e.filter(e=>"first"!==e.type),c.addChildren(e,c.parentBranch),i.position+=1,i.contentDidChange({data:s,inputType:"insertText"}),i.mathfield.snapshot("insert-fence"),!0}if(l instanceof lt&&("?"===l.leftDelim||"."===l.leftDelim)&&cV(s,l.rightDelim)){for(let e of(l.isDirty=!0,l.leftDelim=s,i.mathfield.snapshot(),i.extractAtoms([i.offsetOf(n.firstSibling),i.position])))l.parent.addChildBefore(e,l);return i.contentDidChange({data:s,inputType:"insertText"}),i.mathfield.snapshot("insert-fence"),!0}if(!(l instanceof lt&&"|"===l.leftDelim)){if("("===s){let e=i.position-1,r=!1;for(;e>=0;){let a=i.at(e);if("first"===a.type)break;if("mord"===a.type&&a.value&&/^[\d]$/.test(a.value)){e-=1;continue}if("group"===a.type&&(null==(o=a.body)?void 0:o.length)===2&&"first"===a.body[0].type&&","===a.body[1].value){r=!0;break}"mord"===a.type&&(","===a.value||"."===a.value)&&(r=!0);break}if(r)return!1}if(i.mathfield.snapshot(),na.insert(i,`\\left${s}\\right?`,{format:"latex",style:a}),"first"!==n.lastSibling.type){let e=i.offsetOf(n.lastSibling),r=i.extractAtoms([i.position,e]);i.at(i.position).body=r,i.position-=1}return i.mathfield.snapshot("insert-fence"),!0}}if(c){if(")"===s){let e=i.position-1,r=!1;for(;e>=0;){let a=i.at(e);if("first"===a.type)break;if("mord"===a.type&&a.value&&/^[\d]$/.test(a.value)){r=!0,e-=1;continue}break}if(r&&"mopen"===i.at(e).type&&"("===i.at(e).value)return!1}let r=n;for(;r;){if("mopen"===r.type&&r.value===c){i.mathfield.snapshot();let e=r.leftSibling,a=i.extractAtoms([i.offsetOf(r.leftSibling),i.offsetOf(n)]);[,...a]=a;let o=new lt("left...right",a,{leftDelim:c,rightDelim:s});return l.addChildrenAfter([o],e),i.position=i.offsetOf(o),i.contentDidChange({data:s,inputType:"insertText"}),i.mathfield.snapshot("insert-fence"),!0}r=r.leftSibling}if(l instanceof lt&&n.isLastSibling&&cF(l.leftDelim,s))return i.mathfield.snapshot(),l.isDirty=!0,l.rightDelim=s,i.position+=1,i.contentDidChange({data:s,inputType:"insertText"}),i.mathfield.snapshot("insert-fence"),!0;let o=i.offsetOf(n.firstSibling),d;for(d=i.position;d>=o;d--){let e=i.at(d);if(e instanceof lt&&("?"===e.rightDelim||"."===e.rightDelim)&&cF(e.leftDelim,s))break}let u=i.at(d);if(d>=o&&u instanceof lt)return i.mathfield.snapshot(),u.rightDelim=s,u.addChildren(i.extractAtoms([d,i.position]),u.parentBranch),i.contentDidChange({data:s,inputType:"insertText"}),i.mathfield.snapshot("insert-fence"),!0;if(l instanceof lt&&("?"===l.rightDelim||"."===l.rightDelim)&&cF(l.leftDelim,s))return i.mathfield.snapshot(),l.isDirty=!0,l.rightDelim=s,l.parent.addChildren(i.extractAtoms([i.position,i.offsetOf(n.lastSibling)]),l.parentBranch),i.position=i.offsetOf(l),i.contentDidChange({data:s,inputType:"insertText"}),i.mathfield.snapshot("insert-fence"),!0;let h=l.parent;return h instanceof lt&&("?"===h.rightDelim||"."===h.rightDelim)&&!!i.at(i.position).isLastSibling&&(i.position=i.offsetOf(h),e(i,s,a))}return!1}(l,si(i),su(e)))return e.dirty=!0,e.scrollIntoView(),i.preventDefault&&i.preventDefault(),!1}else{let{parent:r}=l.at(l.position);if(r instanceof lt&&"?"===r.rightDelim&&l.at(l.position).isLastSibling&&/^[)}\]|]$/.test(s))return e.snapshot(),r.isDirty=!0,r.rightDelim=s,l.position+=1,l.selectionDidChange(),l.contentDidChange({data:si(i),inputType:"insertText"}),e.snapshot("insert-fence"),e.dirty=!0,e.scrollIntoView(),i.preventDefault&&i.preventDefault(),!1;if(!l.selectionIsCollapsed){let r=si(i);if("("===r||"{"===r||"["===r){let[a,o]=oQ(l.selection);return e.snapshot(),l.position=o,na.insert(l,{"(":")","{":"\\rbrace","[":"\\rbrack"}[r],{format:"latex"}),l.position=a,na.insert(l,{"(":"(","{":"\\lbrace","[":"\\lbrack"}[r],{format:"latex"}),l.setSelection(a+1,o+1),l.contentDidChange({data:r,inputType:"insertText"}),e.snapshot("insert-fence"),e.dirty=!0,e.scrollIntoView(),i.preventDefault&&i.preventDefault(),!1}}}return!0}let f=l.at(Math.max(l.position,l.anchor)),{parent:g}=f;if("moveAfterParent"===u&&g instanceof lt&&f.isLastSibling&&e.options.smartFence&&"?"===g.rightDelim&&(e.snapshot(),g.rightDelim=g.matchingRightDelim(),g.isDirty=!0,l.contentDidChange({inputType:"insertText"}),e.snapshot("insert-fence")),e.keyboardDelegate.cancelComposition(),u)e.executeCommand(u);else if(c){let i=su(e);l.setState(p[h].state);let r=p[p.length-1].keystrokes;for(let e of r=r.slice(d-1))na.insert(l,e,{silenceNotifications:!0,style:i});e.snapshot("insert-shortcut"),l.setState(p[h].state),l.deferNotifications({content:!0,selection:!0,data:c,type:"insertText"},()=>(na.insert(l,c,{format:"latex",style:i}),cO(e.model),c.endsWith(" ")&&(e.switchMode("text"),na.insert(l," ",{style:i,mode:"text"})),e.snapshot(),l.selectionIsCollapsed||e.flushInlineShortcutBuffer(),!0)),e.dirty=!0,l.announce("replacement")}return e.scrollIntoView(),i.preventDefault&&i.preventDefault(),!1}function cN(e){var i,r,a;let o,{model:n}=e;if("math"!==n.mode)return!1;let l=function(e){var i,r;let{position:a}=e,o=a,n=[];for(;o>0;){let i=e.at(o),r=i.value;if("mord"===i.type||"mbin"===i.type&&("+"===r||"-"===r||"−"===r))n.unshift(i),o--;else break}if(0===n.length)return null;let l=n.map(e=>e.value).join(""),s=(null!=(r=null==(i=globalThis.MathfieldElement)?void 0:i.decimalSeparator)?r:".")==="."?"\\.":",",c=RegExp(`^(\\d+(?:${s}\\d*)?)[eE]([+\\-\u2212]?)(\\d+)$`),d=l.match(c);return d?{startOffset:o,endOffset:a,significand:d[1],exponent:d[2]+d[3]}:null}(n);if(!l)return!1;let s=(i=l.significand,r=l.exponent,(o=null==(a=globalThis.MathfieldElement)?void 0:a.scientificNotationTemplate)&&""!==o&&o.includes("#1")&&o.includes("#2")?o.replace("#1",i).replace("#2",r):null);return!!s&&(n.deferNotifications({content:!0,selection:!0,type:"insertText"},()=>{n.selection={ranges:[[l.startOffset,l.endOffset]],direction:"forward"},na.insert(n,s,{insertionMode:"replaceSelection",selectionMode:"after"})}),e.snapshot("format-scientific-notation"),e.dirty=!0,e.scrollIntoView(),!0)}function cq(e,i,r){let{model:a}=e;if(!e.isSelectionEditable)return void a.announce("plonk");null!=r||(r={}),r.focus&&e.focus(),r.feedback&&(globalThis.MathfieldElement.keypressVibration&&_()&&navigator.vibrate(3),globalThis.MathfieldElement.playSound("keypress")),"string"==typeof r.mode&&(e.switchMode(r.mode),e.snapshot());let o=oh(i),n=window.mathVirtualKeyboard;if(null!=n&&n.isShifted&&(o="string"==typeof o?o.toUpperCase():o.map(e=>e.toUpperCase())),r.simulateKeystroke){let i=!0;for(let r of o)cI(e,new KeyboardEvent("keypress",{key:r}))&&(i=!1);if(i)return}if("latex"===a.mode){if(a.deferNotifications({content:!0,selection:!0,data:i,type:"insertText"},()=>{for(let i of(sp(e),o))na.insert(a,i,{insertionMode:"replaceSelection"});e.snapshot("insert-latex"),sm(e)}),"}"===i){let i=sl(a).map(e=>e.value).join(""),r=i.match(/^\\([a-zA-Z]+)/);if(r){let a=eM("\\"+r[1],"math");if((null==a?void 0:a.definitionType)==="function"){let r=a.params.filter(e=>!e.isOptional).length;if(r>0){let a=0,o=0,n=!0;for(let e=0;e<i.length;e++){let r=i[e];if(n){if("\\"===r||/[a-zA-Z]/.test(r))continue;n=!1}"{"===r?a++:"}"===r&&0==--a&&o++}if(0===a&&o===r&&sg(e,"accept-all")){e.dirty=!0,e.scrollIntoView();return}}}}}}else if("text"===a.mode){let i=f(f({},function(e){var i,r,a,o;if(e.selectionIsCollapsed)return null!=(r=null==(i=e.at(e.position))?void 0:i.style)?r:{};let n=oQ(e.selection)[0];return null!=(o=null==(a=e.at(n+1))?void 0:a.style)?o:{}}(a)),e.defaultStyle);for(let e of o)na.insert(a,e,{style:i,insertionMode:"replaceSelection"});e.snapshot("insert-text")}else if("math"===a.mode)for(let i of o)!function(e,i){let r=e.model;/\d/.test(i)||cN(e);let a={"^":"moveToSuperscript",_:"moveToSubscript"," ":e.options.mathModeSpace?["insert",e.options.mathModeSpace]:"moveAfterParent"}[i];if("moveAfterParent"===a){let i=r.at(Math.max(r.position,r.anchor)),{parent:a}=i;a instanceof lt&&i.isLastSibling&&e.options.smartFence&&"?"===a.rightDelim&&(e.snapshot(),a.rightDelim=a.matchingRightDelim(),a.isDirty=!0,r.contentDidChange({inputType:"insertText"}),e.snapshot("insert-fence"))}if(a)return e.executeCommand(a);let o=f({},su(e));/[a-zA-Z0-9]/.test(i)||"none"===e.styleBias||(o.variant="normal",o.variantStyle=void 0);let n=r.at(r.position),l=r.selectionIsPlaceholder;if(/\d/.test(i)&&e.options.smartSuperscript&&"superscript"===n.parentBranch&&"mop"!==n.parent.type&&"operator"!==n.parent.type&&"extensible-symbol"!==n.parent.type&&n.hasNoSiblings)return na.insert(r,i,{style:o,insertionMode:"replaceSelection",selectionMode:l?"after":"placeholder"})?(e.snapshot("insert-mord"),cC(r)):e.undoManager.pop();let s=i;if("{"===s?s="\\lbrace":"}"===s?s="\\rbrace":"&"===s?s="\\&":"#"===s?s="\\#":"$"===s?s="\\$":"%"===s?s="\\%":"~"===s?s="\\~":"\\"===s&&(s="\\backslash"),na.insert(r,s,{style:o,insertionMode:"replaceSelection",selectionMode:l?"after":"placeholder"})){if(e.snapshot(`insert-${r.at(r.position).type}`),/\d/.test(i)){let i=e.options.inlineShortcutTimeout>0?e.options.inlineShortcutTimeout:1e3;clearTimeout(e.scientificNotationTimer),e.scientificNotationTimer=setTimeout(()=>{cN(e)},i)}/^[a-zA-Z]$/.test(i)&&sm(e)}}(e,i);e.dirty=!0,e.scrollIntoView()}function cF(e,i){return!e||(["(","\\lparen","{","\\{","\\lbrace","[","\\lbrack"].includes(e)?[")","\\rparen","}","\\}","\\rbrace","]","\\rbrack"].includes(i):nK[e]===i)}function cV(e,i){return!i||([")","\\rparen","}","\\}","\\rbrace","]","\\rbrack"].includes(i)?["(","\\lparen","{","\\{","\\lbrace","[","\\lbrack"].includes(e):nB[i]===e)}function cj(e){let[i,r]=oQ(e.selection);if((i=cH(e,i,"backward"))===(r=cH(e,r,"forward"))){let a=e.at(i);if("leftright"===a.type)return e.setSelection(e.offsetOf(a.firstChild)-1,r);if("first"===a.type&&("leftright"===a.parent.type||"surd"===a.parent.type))return e.setSelection(i-1,e.offsetOf(a.parent.lastChild)+1);e.setSelection(i-1,r)}else e.setSelection(i,r);return!0}function cH(e,i,r){var a;let o=e.at(i);if(!o)return i;let n="forward"===r?1:-1;if("text"===o.mode){for(;o&&!("text"!==o.mode||!er.test(o.value));)i+=n,o=e.at(i);return"backward"===r?i-1:i}if("latex"===o.mode){if(/[a-zA-Z\\*]/.test(o.value))if("backward"===r)for(;(null==o?void 0:o.mode)==="latex"&&"\\"!==o.value&&/[a-zA-Z]/.test(o.value);)i+=n,o=e.at(i);else for(;(null==o?void 0:o.mode)==="latex"&&/[a-zA-Z\\*]/.test(o.value);)i+=n,o=e.at(i);else if("{"===o.value){if("forward"===r){for(;(null==o?void 0:o.mode)==="latex"&&"}"!==o.value;)i+=n,o=e.at(i);return i}}else if("}"===o.value){if("backward"===r){for(;(null==o?void 0:o.mode)==="latex"&&"{"!==o.value;)i+=n,o=e.at(i);return i-1}return i}return i-1}if("math"===o.mode){if(o.isDigit()){for(;null!=(a=e.at(i+n))&&a.isDigit();)i+=n;return"backward"===r?i-1:i}if(o.style.variant||o.style.variantStyle){let a=o.style.variant,l=o.style.variantStyle;for(;;){let r=e.at(i+n);if(!r||r.style.variant!==a||r.style.variantStyle!==l)break;i+=n}return"backward"===r?i-1:i}}return i}cv.maximumDepth=1e3,sq({moveToOpposite:e=>{let i=e.at(e.position),{parent:r}=i;if(!r)return e.announce("plonk"),!1;let a=i.parentBranch,o;if("string"==typeof a&&(o=({superscript:"subscript",subscript:"superscript",above:"below",below:"above"})[a]),!o){let r=i.subsupPlacement?cA(e):cE(e);return e.mathfield.stopCoalescingUndo(),r}r.branch(o)||r.createBranch(o);let n=e.setSelection(e.getBranchRange(e.offsetOf(r),o));return e.mathfield.stopCoalescingUndo(),n},moveBeforeParent:e=>{let{parent:i}=e.at(e.position);return i?(e.position=e.offsetOf(i),e.mathfield.stopCoalescingUndo(),!0):(e.announce("plonk"),!1)},moveAfterParent:e=>cC(e),moveToNextChar:e=>ck(e,"forward"),moveToPreviousChar:e=>ck(e,"backward"),moveUp:e=>ck(e,"upward"),moveDown:e=>ck(e,"downward"),moveToNextWord:e=>cw(e,"forward"),moveToPreviousWord:e=>cw(e,"backward"),moveToGroupStart:e=>{let i=e.offsetOf(e.at(e.position).firstSibling);return i===e.position?(e.announce("plonk"),!1):(e.position=i,e.mathfield.stopCoalescingUndo(),!0)},moveToGroupEnd:e=>{let i=e.offsetOf(e.at(e.position).lastSibling);return i===e.position?(e.announce("plonk"),!1):(e.position=i,e.mathfield.stopCoalescingUndo(),!0)},moveToNextGroup:e=>{var i,r,a,o;if(e.position===e.lastOffset&&e.anchor===e.lastOffset)return cD(e,"forward");let n=e.at(e.position);if("text"===n.mode){if(e.selectionIsCollapsed){let r=n;for(;(null==r?void 0:r.mode)==="text";)r=r.leftSibling;let a=n;for(;(null==(i=a.rightSibling)?void 0:i.mode)==="text";)a=a.rightSibling;if(r&&a)return cz(e,[r,a])}if("text"===n.rightSibling.mode){let i=n;for(;(null==i?void 0:i.mode)==="text";)i=i.rightSibling;return i?(cT(e,null!=(r=i.leftSibling)?r:i),e.mathfield.switchMode("math"),!0):cT(e,e.lastOffset)}}let l=e.at(e.anchor).parentPrompt,s=l?e.offsetOf(l)+1:Math.max(e.position+1,0),c=cK(e,s,"forward");if(c&&e.offsetOf(c)<s)return cD(e,"forward");if(c)return cT(e,c);let d=cB(e,n,e=>"leftright"===e.type||"text"===e.type,"forward");if(d){if("text"===d.mode){let i=d;for(;(null==i?void 0:i.mode)==="text";)i=i.rightSibling;return cz(e,[null!=(a=d.leftSibling)?a:d,null!=(o=i.leftSibling)?o:i])}return cz(e,d)}let u=n.parent;if(u){if("leftright"===u.type||"surd"===u.type)return cz(e,u);if("superscript"===n.parentBranch&&u.subscript)return cz(e,u.subscript);if("above"===n.parentBranch&&u.below)return cz(e,u.below);if("superscript"===n.parentBranch||"subscript"===n.parentBranch)return cT(e,u);if("above"===n.parentBranch||"below"===n.parentBranch)return cz(e,u)}return cT(e,e.lastOffset)},moveToPreviousGroup:e=>{var i;if(0===e.position&&0===e.anchor)return cD(e,"backward");let r=e.at(e.position),a=r.mode;if("text"===a){if(e.selectionIsCollapsed){let a=r;for(;(null==a?void 0:a.mode)==="text";)a=a.leftSibling;let o=r;for(;(null==(i=o.rightSibling)?void 0:i.mode)==="text";)o=o.rightSibling;if(a&&o)return cz(e,[a,o])}for(;(null==r?void 0:r.mode)==="text";)r=r.leftSibling;return r?cT(e,r):cT(e,0)}let o=e.at(e.anchor).parentPrompt,n=o?e.offsetOf(o.leftSibling):Math.max(e.position-1,0),l=cK(e,n,"backward");if(l&&e.offsetOf(l)>n)return cD(e,"backward");if(l)return cT(e,l);if("math"===a){let i=cB(e,r,e=>"leftright"===e.type||"text"===e.type,"backward");if(i){if("text"===i.mode){let r=i;for(;(null==r?void 0:r.mode)==="text";)r=r.leftSibling;return cz(e,[i,r])}return cz(e,i)}let a=r.parent;if(a){if("leftright"===a.type||"surd"===a.type)return cz(e,a);if("subscript"===r.parentBranch&&a.superscript)return cz(e,a.superscript);if("below"===r.parentBranch&&a.above)return cz(e,a.above);if("superscript"===r.parentBranch||"subscript"===r.parentBranch)return cT(e,a);if("above"===r.parentBranch||"below"===r.parentBranch)return cz(e,a)}return cT(e,0)}return!1},moveToMathfieldStart:e=>e.selectionIsCollapsed&&0===e.position?(e.announce("plonk"),!1):(e.position=0,e.mathfield.stopCoalescingUndo(),!0),moveToMathfieldEnd:e=>e.selectionIsCollapsed&&e.position===e.lastOffset?(e.announce("plonk"),!1):(e.position=e.lastOffset,e.mathfield.stopCoalescingUndo(),!0),moveToSuperscript:cE,moveToSubscript:cA},{target:"model",changeSelection:!0}),sq({moveToNextPlaceholder:e=>cD(e,"forward"),moveToPreviousPlaceholder:e=>cD(e,"backward")},{target:"model",changeSelection:!0,audioFeedback:"return"}),sq({scrollIntoView:e=>(e.scrollIntoView(),!0),scrollToStart:e=>(e.field.scroll(0,0),!0),scrollToEnd:e=>{let i=e.field.getBoundingClientRect();return e.field.scroll(i.left-window.scrollX,0),!0},toggleKeystrokeCaption:function(e){return(e.keystrokeCaptionVisible=!e.keystrokeCaptionVisible,e.keystrokeCaptionVisible)?cR().innerHTML="":sb("mathlive-keystroke-caption-panel").style.visibility="hidden",!1},toggleContextMenu:e=>{let i=e.toggleContextMenu();return i||e.model.announce("plonk"),i},plonk:e=>(e.model.announce("plonk"),!0),switchMode:(e,i,r,a)=>(e.switchMode(i,r,a),!0)}),sq({undo:e=>(e.undo(),!0),redo:e=>(e.redo(),!0)},{target:"mathfield",changeContent:!0}),sq({insert:(e,i,r)=>e.insert(i,r),typedText:(e,i,r)=>(cq(e,i,r),!0),insertDecimalSeparator:e=>{let i=e.model;return"math"===i.mode&&","===globalThis.MathfieldElement.decimalSeparator&&i.at(Math.max(i.position,i.anchor)).isDigit()?(e.insert("{,}",{format:"latex"}),e.snapshot("insert-mord")):e.insert("."),!0},commit:e=>{var i,r;let a=e.model;return a.contentWillChange({inputType:"insertLineBreak"})&&(null==(i=e.host)||i.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),null!=(r=a.parentEnvironment)&&r.isMultiline&&e.executeCommand("addRowAfter"),a.contentDidChange({inputType:"insertLineBreak"})),!0},insertPrompt:(e,i,r)=>{let a=e.getPrompts(),o="prompt-"+Date.now().toString(36).slice(-2)+Math.floor(1e5*Math.random()).toString(36),n=0;for(;a.includes(o)&&n<100;){if(99===n)return console.error("could not find a unique ID after 100 tries"),!1;o="prompt-"+Date.now().toString(36).slice(-2)+Math.floor(1e5*Math.random()).toString(36),n++}return e.insert(`\\placeholder[${null!=i?i:o}]{}`,r),!0}},{target:"mathfield",canUndo:!0,changeContent:!0,changeSelection:!0}),sq({copyToClipboard:e=>(e.focus(),e.model.selectionIsCollapsed&&e.select(),"queryCommandSupported"in document&&document.queryCommandSupported("copy")&&document.execCommand("copy")||e.element.querySelector(".ML__keyboard-sink").dispatchEvent(new ClipboardEvent("copy",{bubbles:!0,composed:!0})),!1)},{target:"mathfield"}),sq({cutToClipboard:e=>(e.focus(),"queryCommandSupported"in document&&document.queryCommandSupported("cut")&&document.execCommand("cut")||e.element.querySelector(".ML__keyboard-sink").dispatchEvent(new ClipboardEvent("cut",{bubbles:!0,composed:!0})),!0),pasteFromClipboard:e=>(e.focus(),"queryCommandSupported"in document&&document.queryCommandSupported("paste")?document.execCommand("paste"):navigator.clipboard.readText().then(i=>{i&&e.model.contentWillChange({inputType:"insertFromPaste",data:i})?(e.stopCoalescingUndo(),e.stopRecording(),e.insert(i,{mode:e.model.mode})&&(sm(e),e.startRecording(),e.snapshot("paste"),e.model.contentDidChange({inputType:"insertFromPaste"}),s$(e))):e.model.announce("plonk"),e.startRecording()}).catch(()=>{e.model.announce("plonk"),e.startRecording()}),!0)},{target:"mathfield",canUndo:!0,changeContent:!0,changeSelection:!0}),sq({selectGroup:e=>{let i=cj(e);return i||e.announce("plonk"),i},selectAll:e=>e.setSelection(0,e.lastOffset),extendSelectionForward:e=>ck(e,"forward",{extend:!0}),extendSelectionBackward:e=>ck(e,"backward",{extend:!0}),extendToNextWord:e=>cw(e,"forward",{extend:!0}),extendToPreviousWord:e=>cw(e,"backward",{extend:!0}),extendSelectionUpward:e=>ck(e,"upward",{extend:!0}),extendSelectionDownward:e=>ck(e,"downward",{extend:!0}),extendToNextBoundary:e=>cw(e,"forward",{extend:!0}),extendToPreviousBoundary:e=>cw(e,"backward",{extend:!0}),extendToGroupStart:e=>{let i=e.setSelection(e.anchor,e.offsetOf(e.at(e.position).firstSibling));return i||e.announce("plonk"),i},extendToGroupEnd:e=>{let i=e.setSelection(e.anchor,e.offsetOf(e.at(e.position).lastSibling));return i||e.announce("plonk"),i},extendToMathFieldStart:e=>{let i=e.setSelection(e.anchor,0);return i||e.announce("plonk"),i},extendToMathFieldEnd:e=>{let i=e.setSelection(e.anchor,e.lastOffset);return i||e.announce("plonk"),i}},{target:"model",changeSelection:!0});var cW=null,cU=0,cJ=class e{static start(i,r,a,o){var n;e.element=i,null==(n=e.controller)||n.abort(),e.controller=new AbortController;let l={signal:e.controller.signal};"PointerEvent"in window?(i.addEventListener("pointermove",a,l),i.addEventListener("pointerup",o,l),i.addEventListener("pointercancel",o,l),cX(r)&&(e.pointerId=r.pointerId,i.setPointerCapture(r.pointerId))):(window.addEventListener("mousemove",a,l),window.addEventListener("blur",o,l),window.addEventListener("mouseup",o,l))}static stop(){var i;null==(i=e.controller)||i.abort(),e.controller=void 0,"number"==typeof e.pointerId&&(e.element.releasePointerCapture(e.pointerId),e.pointerId=void 0)}};function cX(e){return null!==e&&void 0!==globalThis.PointerEvent&&e instanceof PointerEvent}function cG(e,i,r){return e>=r.left&&e<=r.right&&i>=r.top&&i<=r.bottom}function cZ(e,i){var r,a,o,n,l,s,c,d,u,h;if(i.buttons>1)return;e.atomBoundsCache?e.atomBoundsCache.clear():e.atomBoundsCache=new Map;let p,m=!1,f=!1,g="none",b=!1,y=!1,v=i.clientX,x=i.clientY,_=Date.now(),w=e.field,k=setInterval(()=>{b?w.scroll({top:0,left:w.scrollLeft-16}):y&&w.scroll({top:0,left:w.scrollLeft+16})},32);function M(){cJ.stop(),m=!1,clearInterval(k),e.element.classList.remove("tracking"),i&&i.preventDefault()}cW&&5>Math.abs(cW.x-v)&&5>Math.abs(cW.y-x)&&Date.now()<cW.time+500?(cU+=1,cW.time=_):(cW={x:v,y:x,time:_},cU=1);let S=w.getBoundingClientRect(),L=null!=(a=null==(r=e.container)?void 0:r.getBoundingClientRect())?a:e.element.getBoundingClientRect(),C=null!=(n=null==(o=e.element)?void 0:o.getBoundingClientRect())?n:L,E=cG(v,x,S),A=!E&&!!L&&cG(v,x,L),z=!E&&!A&&!!C&&cG(v,x,C),T=E?v:A||z?(c=S.left,d=S.right,v<c?c:v>d?d:v):v,D=E?x:A||z?(u=S.top,h=S.bottom,x<u?u:x>h?h:x):x;if(E||A||z){if(e.flushInlineShortcutBuffer(),(p=cY(e,T,D,{bias:0}))!==e.model.anchor){let i=e.defaultStyle.variantStyle;e.defaultStyle=void 0!==i?{variantStyle:i}:{},e.styleBias="left"}if(p>=0){if(e.element.classList.add("tracking"),i.shiftKey){let i=e.model.selectionIsCollapsed;e.model.extendSelectionTo(e.model.anchor,p),g=sf(e.model)||i?"all":"selection"}else if("placeholder"===e.model.at(p).type||"prompt"===e.model.at(p).type){let i=e.model.at(p);i.hasChildren&&i.firstChild?e.model.position=e.model.offsetOf(i.firstChild):e.model.setSelection(p-1,p),g="selection"}else if((null==(l=e.model.at(p).rightSibling)?void 0:l.type)==="placeholder"||(null==(s=e.model.at(p).rightSibling)?void 0:s.type)==="prompt"){let i=e.model.at(p).rightSibling;i.hasChildren&&i.firstChild?e.model.position=e.model.offsetOf(i.firstChild):e.model.setSelection(p,p+1),g="selection"}else{let i=e.model.at(p);if(i.captureSelection&&i.hasChildren&&i.body&&i.body.length>0){let r=i.body.find(e=>"first"!==e.type);r&&("placeholder"===r.type||"prompt"===r.type)&&r.hasChildren&&r.firstChild?(e.model.position=e.model.offsetOf(r.firstChild),g="selection"):(e.model.position=p,g=sf(e.model)?"all":"selection")}else e.model.position=p,g=sf(e.model)?"all":"selection"}3===i.detail||cU>2?(M(),(3===i.detail||3===cU)&&(e.model.selection={ranges:[[0,e.model.lastOffset]]},g="all")):m||(m=!0,cJ.start(w,i,function(i){if(!e.hasFocus())return void M();let r=i.clientX,a=i.clientY,o=cX(i)&&"touch"===i.pointerType?20:5;if(Date.now()<_+500&&Math.abs(v-r)<o&&Math.abs(x-a)<o){i.preventDefault(),i.stopPropagation();return}let n=w.getBoundingClientRect();y=r>n.right,b=r<n.left;let l=p;cX(i)&&(i.isPrimary||(l=cY(e,i.clientX,i.clientY,{bias:0})));let s=cY(e,r,a,{bias:r<=v?r===v?0:-1:1});l>=0&&s>=0&&(e.model.extendSelectionTo(l,s),s$(e)),f&&cj(e.model)},M),(2===i.detail||2===cU)&&(f=!0,cj(e.model),g="all"))}e.hasFocus()||(g="none",e.onFocus(),e.model.announce("line"))}else cW=null;e.stopCoalescingUndo(),"none"!==g&&(e.model.selectionIsCollapsed&&(g="all"),s$(e)),i.preventDefault()}function cY(e,i,r,a){var o;let n=e.field.querySelector(".ML__latex").getBoundingClientRect();if(!n)return 0;if(i>n.right||r>n.bottom+8)return e.model.lastOffset;if(i<n.left||r<n.top-8)return 0;(a=null!=a?a:{}).bias=null!=(o=a.bias)?o:0;let l=function(e,i,r){let[,a]=function e(i,r,a,o,n){if(!a.id)return[1/0,null];if(r.has(a.id))return r.get(a.id);let l=nu(i,a);if(!l)return[1/0,null];let s=[1/0,null],c=i.model;if(a instanceof n0){let l=-1,c=1/0;for(let e=0;e<a.rows.length;e++){let r=a.rows[e];if(!r||0===r.length)continue;let o=1/0,s=-1/0;for(let e of r)if(e)for(let r of e){let e=nu(i,r);e&&(o=Math.min(o,e.top),s=Math.max(s,e.bottom))}if(1/0!==o&&-1/0!==s){let i;(i=n<o?o-n:n>s?n-s:0)<c&&(c=i,l=e)}}for(let c of l>=0?[a.rows[l]]:a.rows)for(let a of c)if(a)for(let l of a){let a=e(i,r,l,o,n);a[0]<=s[0]&&(s=a)}if(!a.isMultiline)for(let l of a.children){let a=e(i,r,l,o,n);a[0]<=s[0]&&(s=a)}}else if(a.hasChildren&&!a.captureSelection&&o>=l.left&&o<=l.right){for(let l of a.children){let a=e(i,r,l,o,n);a[0]<=s[0]&&(s=a)}for(let l of a.branches){let d=a.branch(l);if(!d||0===d.length)continue;let u=function(e,i){let[r,a]=i,o=null;for(let i=r;i<=a;i++){let r=nu(e,e.model.at(i));r&&(o?(o.top=Math.min(o.top,r.top),o.bottom=Math.max(o.bottom,r.bottom),o.left=Math.min(o.left,r.left),o.right=Math.max(o.right,r.right)):o=r)}return null!=o?o:{top:0,bottom:0,left:0,right:0}}(i,[c.offsetOf(d[0]),c.offsetOf(d[d.length-1])]);if(n>=u.top&&n<=u.bottom)for(let a of d){let l=e(i,r,a,o,n);l[0]<=s[0]&&(s=l)}}}return s[1]||(s=[function(e,i,r){if(e>=r.left&&e<=r.right&&i>=r.top&&i<=r.bottom)return 0;let a=e-(r.left+r.right)/2,o=i-(r.top+r.bottom)/2;return a*a+o*o}(o,n,l),a]),r.set(a.id,s),s}(e,new Map,e.model.root,i,r);return a}(e,i,r),s=[],c=l;for(;c;)s.unshift(c),c=c.parent;for(let e of s)if(e.captureSelection){l=e;break}let d=e.model.offsetOf(l);if(d<0)return -1;if(l.leftSibling){let r="placeholder"===l.type||"prompt"===l.type;if(0!==a.bias||r)a.bias<0&&(d=e.model.offsetOf(l.leftSibling));else{let r=nu(e,l);r&&i<(r.left+r.right)/2&&(d=e.model.offsetOf(l.leftSibling))}}return d}function cQ(e,i,r,a){var o;let n,l=[];if("string"!=typeof i||"math-json"===a.format){let r=globalThis.MathfieldElement.computeEngine;if(!r)return["math-json",[]];[n,i]=["latex",r.box(i).latex],l=ls(i,{context:e.mathfield.context})}else"string"==typeof i&&"ascii-math"===a.format?([n,i]=o6(i,{format:"ascii-math",inlineShortcuts:e.mathfield.options.inlineShortcuts}),l=ls(i,{context:e.mathfield.context}),"latex"!==n&&e.mathfield.options.removeExtraneousParentheses&&(l=l.map(e=>c0(e)))):("auto"===a.format||null!=(o=a.format)&&o.startsWith("latex"))&&("auto"===a.format&&([n,i]=o6(i,{format:"auto",inlineShortcuts:e.mathfield.options.inlineShortcuts})),"latex"===a.format&&([,i]=nt(i)),l=ls(i,{context:e.mathfield.context,args:r}),"latex"!==a.format&&e.mathfield.options.removeExtraneousParentheses&&(l=l.map(e=>c0(e))));return lN(l,a.style),[null!=n?n:"latex",l]}function c0(e){var i;if(e instanceof lt&&"("!==e.leftDelim&&")"===e.rightDelim){let r=null==(i=e.body)?void 0:i.filter(e=>"first"!==e.type);if((null==r?void 0:r.length)===1&&"genfrac"===r[0].type)return r[0]}for(let i of e.branches)e.hasEmptyBranch(i)||e.setChildren(e.branch(i).map(e=>c0(e)),i);return e instanceof n0&&e.forEachCell((i,r,a)=>{e.setCell(r,a,i.map(e=>c0(e)))}),e}function c1(e){return!!(e.isDigit()||function(e){if("mord"===e.type&&"e"===e.value){let i=e.leftSibling;if(i&&i.isDigit())return!0}if("mbin"===e.type&&("+"===e.value||"-"===e.value||"−"===e.value)){let i=e.leftSibling,r=e.rightSibling;if((null==i?void 0:i.type)==="mord"&&"e"===i.value&&r&&r.isDigit()){let e=i.leftSibling;if(e&&e.isDigit())return!0}}if("subsup"===e.type){let i=e.leftSibling;if(i&&i.isDigit()&&"0"===i.value){let e=i.leftSibling;if(e&&e.isDigit()&&"1"===e.value){let i=e.leftSibling;if((null==i?void 0:i.type)==="mbin"&&("×"===i.value||"\\times"===i.value)){let e=i.leftSibling;if(e&&e.isDigit())return!0}}}}if(e.isDigit()&&"0"===e.value){let i=e.leftSibling,r=e.rightSibling;if(i&&i.isDigit()&&"1"===i.value&&(null==r?void 0:r.type)==="subsup"){let e=i.leftSibling;if((null==e?void 0:e.type)==="mbin"&&("×"===e.value||"\\times"===e.value)){let i=e.leftSibling;if(i&&i.isDigit())return!0}}}if(e.isDigit()&&"1"===e.value){let i=e.rightSibling;if(i&&i.isDigit()&&"0"===i.value){let r=i.rightSibling;if((null==r?void 0:r.type)==="subsup"){let i=e.leftSibling;if((null==i?void 0:i.type)==="mbin"&&("×"===i.value||"\\times"===i.value)){let e=i.leftSibling;if(e&&e.isDigit())return!0}}}}if("mbin"===e.type&&("×"===e.value||"\\times"===e.value)){let i=e.leftSibling,r=e.rightSibling;if(i&&i.isDigit()&&r&&r.isDigit()&&"1"===r.value){let e=r.rightSibling;if(e&&e.isDigit()&&"0"===e.value){let i=e.rightSibling;if((null==i?void 0:i.type)==="subsup")return!0}}}return!1}(e))||!!(e.type&&/^(mord|surd|subsup|leftright|mop|mclose)$/.test(e.type))&&"extensible-symbol"!==e.type}function c4(e){return(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/\\/g,"\\textbackslash ")).replace(/#/g,"\\#")).replace(/%/g,"\\%")).replace(/&/g,"\\&")).replace(/_/g,"\\_")).replace(/{/g,"\\textbraceleft ")).replace(/}/g,"\\textbraceright ")).replace(/lbrace/g,"\\textbraceleft ")).replace(/rbrace/g,"\\textbraceright ")).replace(/\^/g,"\\textasciicircum ")).replace(/~/g,"\\textasciitilde ")).replace(/£/g,"\\textsterling ")}function c2(e){return{value:e.model.getValue(),selectionIsCollapsed:e.model.selectionIsCollapsed,canUndo:e.canUndo(),canRedo:e.canRedo(),style:function(e){var i;if(e.selectionIsCollapsed)return null==(i=e.at(e.position))?void 0:i.style;let r=e.getAtoms(e.selection);if(0===r.length)return{};let a=f({},r[0].style);for(let e of r)for(let[i,r]of Object.entries(e.style))a[i]!==r&&delete a[i];return a}(e.model),mode:e.model.mode}}new class extends na{constructor(){super("math")}onPaste(e,i){if(!i||!e.model.contentWillChange({data:"string"==typeof i?i:null,dataTransfer:"string"==typeof i?null:i,inputType:"insertFromPaste"}))return!1;let r="",a="auto",o="string"!=typeof i?i.getData("application/json+mathlive"):"";if(o)try{let i=JSON.parse(o);if(i&&Array.isArray(i)){e.snapshot();let r=lI(i),{model:a}=e;a.selectionIsCollapsed||a.deleteAtoms(oQ(a.selection));let o=a.at(a.position);if(o.parent instanceof n0){o.parentBranch;let e=[],i=[];for(let a of("first"===r[0].type&&r.shift(),"first"===r[r.length-1].type&&r.pop(),r))"first"===a.type&&i.length>0?(e.push(i),i=[a]):i.push(a);i.length>0&&e.push(i);let a=Number(o.parentBranch[0]),n=Number(o.parentBranch[1]),l=o.parent.maxColumns;for(;o.parent.colCount-n<e.length&&o.parent.colCount<l;)o.parent.addColumn();o.parent.addChildrenAfter(e[0],o);for(let i=1;i<e.length;i++)++n>=l&&(n=0,o.parent.addRowAfter(a),a++),o.parent.setCell(a,n,e[i])}else o.parent.addChildrenAfter(r.filter(e=>"first"!==e.type),o);return a.position=a.offsetOf(r[r.length-1]),a.contentDidChange({inputType:"insertFromPaste"}),s$(e),!0}}catch(e){}if((o="string"!=typeof i?i.getData("application/json"):"")&&globalThis.MathfieldElement.computeEngine)try{let e=JSON.parse(o);if("object"==typeof e&&"latex"in e&&e.latex&&(r=e.latex),!r){let i=globalThis.MathfieldElement.computeEngine.box(e);i&&!i.has("Error")&&(r=i.latex)}r||(a="latex")}catch(e){}if(!r&&"string"!=typeof i&&(r=i.getData("application/x-latex"))&&(a="latex"),r||(r="string"==typeof i?i:i.getData("text/plain")),r){let i;return[i,r]=nt(r),"auto"===a&&i&&(a="latex"),e.stopCoalescingUndo(),e.stopRecording(),this.insert(e.model,r,{format:a})&&(e.startRecording(),e.snapshot("paste"),s$(e)),e.startRecording(),!0}return!1}insert(e,i,r){var a,o,n,l;let s="string"==typeof i?i:null!=(o=null==(a=globalThis.MathfieldElement.computeEngine)?void 0:a.box(i).latex)?o:"";if(!r.silenceNotifications&&!e.contentWillChange({data:s,inputType:"insertText"}))return!1;r.insertionMode||(r.insertionMode="replaceSelection"),r.selectionMode||(r.selectionMode="placeholder"),r.format||(r.format="auto");let{silenceNotifications:c}=e;r.silenceNotifications&&(e.silenceNotifications=!0);let d=e.silenceNotifications;e.silenceNotifications=!0;let u={"?":"\\placeholder{}","@":"\\placeholder{}"};u[0]="replaceAll"===r.insertionMode?"":e.getValue(e.selection,"latex-unstyled"),"replaceSelection"===r.insertionMode?e.deleteAtoms(oQ(e.selection)):"replaceAll"===r.insertionMode?e.deleteAtoms():"insertBefore"===r.insertionMode?e.collapseSelection("backward"):"insertAfter"===r.insertionMode&&e.collapseSelection("forward");let h=e.at(e.position);h&&!h.isLastSibling&&(null==(n=e.at(e.position+1))?void 0:n.type)==="placeholder"?e.deleteAtoms([e.position,e.position+1]):(null==h?void 0:h.type)==="placeholder"&&e.deleteAtoms([e.position-1,e.position]);let p=-1;u[0]?u["@"]=u[0]:"string"==typeof i&&/(^|[^\\])#@/.test(i)&&(p=function(e){let i=e.at(e.position);if(!i)return -1;if("text"===i.mode){for(;!i.isFirstSibling&&"text"===i.mode;)i=i.leftSibling;return e.offsetOf(i)}let r=i,a=!1;if("mclose"===i.type){let e=nB[i.value];for(;!i.isFirstSibling&&("mopen"!==i.type||i.value!==e);){let e=i.leftSibling;if(!e)break;i=e}if(!i.isFirstSibling){let e=i.leftSibling;e&&(i=e)}a=!0}else if("leftright"===i.type){let e=i.leftSibling;e&&(i=e),a=!0}if(a)for(;!i.isFirstSibling&&(i.isFunction||c1(i));){let e=i.leftSibling;if(!e)break;i=e}else{let e=[];for(;!i.isFirstSibling&&(c1(i)||e.length>0);){"mclose"===i.type&&e.unshift(i.value),"mopen"===i.type&&e.length>0&&i.value===nB[e[0]]&&e.shift();let r=i.leftSibling;if(!r)break;i=r}}return r===i?-1:e.offsetOf(i)}(e))>=0&&(u["@"]=e.getValue(p,e.position,"latex")),u[0]||(u[0]=u["?"]);let m=!1,f=e=>(m=!0,u[e]),[g,b]=cQ(e,i,f,r);if(!b)return!1;let y=1===b.length&&"genfrac"===b[0].type,v=e.at(e.position);y&&p>=0&&"function"==typeof e.mathfield.options.isImplicitFunction&&v&&e.mathfield.options.isImplicitFunction(v.command)&&(u["@"]=u["?"],m=!1,[g,b]=cQ(e,i,f,r));let x=e.position;if(1===b.length&&b[0].isRoot)e.root=b[0];else{let r=e.at(e.position),a=null!=(l=null==r?void 0:r.parent)?l:e.root,o=a.hasEmptyBranch("body");if(y&&"latex"!==g&&e.mathfield.options.removeExtraneousParentheses&&a instanceof lt&&"("===a.leftDelim&&o){let e=a.parent,i=a.parentBranch;e.removeChild(a),e.setChildren(b,i)}let n=e.at(e.position);if(n)n.parent.addChildrenAfter(b,n);else{let e=a.branch("body"),i=null==e?void 0:e[0];i?a.addChildrenAfter(b,i):a.setChildren(b,"body")}if(p>=0){e.deleteAtoms([p,x]);let i=e.root.branch("body");if(i)for(let r of i)r.parent!==e.root&&(r.parent=e.root,r.parentBranch="body")}"latex"===g&&"string"==typeof i&&(null==a?void 0:a.type)==="root"&&o&&!m&&(a.verbatimLatex=i)}e.silenceNotifications=d;let _=b[b.length-1];if("placeholder"===r.selectionMode){let i;if(1===b.length&&"genfrac"===b[0].type){let e=b[0].branch("above");if(!(i=null==e?void 0:e.find(e=>"placeholder"===e.type))){let e=b[0].branch("below");i=null==e?void 0:e.find(e=>"placeholder"===e.type)}}if(i||(i=b.flatMap(e=>[e,...e.children]).find(e=>"placeholder"===e.type)),i){let r=e.offsetOf(i);e.setSelection(r-1,r),e.announce("move")}else if(_){let i=_.body,r=_.hasEmptyBranch("body");i&&r?e.setSelection(e.offsetOf(i[0]),e.offsetOf(i[i.length-1])+1):e.position=e.offsetOf(_)}}else"before"===r.selectionMode||("after"===r.selectionMode?_&&(e.position=e.offsetOf(_)):"item"===r.selectionMode&&e.setSelection(e.anchor,e.offsetOf(_)));return e.contentDidChange({data:s,inputType:"insertText"}),e.silenceNotifications=c,!0}},new class extends na{constructor(){super("text")}onPaste(e,i){if(!i)return!1;let r="string"==typeof i?i:i.getData("text/plain");return!!(r&&e.model.contentWillChange({inputType:"insertFromPaste",data:r}))&&(e.stopCoalescingUndo(),e.stopRecording(),this.insert(e.model,r)&&(e.model.contentDidChange({inputType:"insertFromPaste"}),e.startRecording(),e.snapshot("paste"),s$(e)),e.startRecording(),!0)}insert(e,i,r={}){if(!e.contentWillChange({data:i,inputType:"insertText"}))return!1;r.insertionMode||(r.insertionMode="replaceSelection"),r.selectionMode||(r.selectionMode="placeholder"),r.format||(r.format="auto");let{silenceNotifications:a}=e;r.silenceNotifications&&(e.silenceNotifications=!0);let o=e.silenceNotifications;e.silenceNotifications=!0,"replaceSelection"!==r.insertionMode||e.selectionIsCollapsed?"replaceAll"===r.insertionMode?(e.root.setChildren([],"body"),e.position=0):"insertBefore"===r.insertionMode?e.collapseSelection("backward"):"insertAfter"===r.insertionMode&&e.collapseSelection("forward"):e.deleteAtoms(oQ(e.selection));let n=function(e,i){if(e.includes("$")){let r=[],a=0,o=!1,n="";for(;a<e.length;)"$"===e[a]?a+1<e.length&&"$"===e[a+1]?(!o&&n?(r.push(c4(n)),n=""):o&&n&&(r.push(n),n=""),r.push("$$"),o=!o,a+=2):(!o&&n?(r.push(c4(n)),n=""):o&&n&&(r.push(n),n=""),r.push("$"),o=!o,a+=1):(n+=e[a],a+=1);return n&&(o?r.push(n):r.push(c4(n))),ls(r.join(""),{context:i,parseMode:"text"})}return ls(c4(e),{context:i,parseMode:"text"})}(i,e.mathfield.context);if(lN(n,r.style),!n)return!1;let l=e.at(e.position),s=l.parent.addChildrenAfter(n,l);return e.silenceNotifications=o,"before"===r.selectionMode||("item"===r.selectionMode?e.setSelection(e.anchor,e.offsetOf(s)):s&&(e.position=e.offsetOf(s))),e.contentDidChange({data:i,inputType:"insertText"}),e.silenceNotifications=a,!0}};var c3=(e,i)=>`
|
|
3335
3335
|
<line x1="${e+20}" y1="${i+20}"
|
|
3336
3336
|
x2="${e>i?e+20:180}"
|
|
3337
3337
|
y2="${e<i?i+20:180}"/>
|
|
3338
3338
|
<svg id="plus" viewBox="0 0 40 40" x="${e}" y="${i}" width="40" height="40">
|
|
3339
3339
|
<circle class="cls-2" cx="20" cy="20" r="20"/>
|
|
3340
3340
|
<path class="font" d="m33.33,20c0,1.84-1.49,3.34-3.33,3.34h-6.67v6.66c0,1.84-1.49,3.34-3.33,3.34s-3.34-1.5-3.34-3.34v-6.66h-6.66c-1.84,0-3.34-1.5-3.34-3.34s1.5-3.33,3.34-3.33h6.66v-6.67c0-1.84,1.5-3.33,3.34-3.33s3.33,1.49,3.33,3.33v6.67h6.67c1.84,0,3.33,1.49,3.33,3.33Z"/>
|
|
3341
|
-
</svg>`,
|
|
3341
|
+
</svg>`,c6=(e,i)=>`
|
|
3342
3342
|
<line x1="${e+20}" y1="${i+20}"
|
|
3343
3343
|
x2="${e>i?e+20:180}"
|
|
3344
3344
|
y2="${e<i?i+20:180}"/>
|
|
3345
3345
|
<svg id="minus" viewBox="0 0 40 40" x="${e}" y="${i}" width="40" height="40">
|
|
3346
3346
|
<circle class="cls-2" cx="20" cy="20" r="20"/>
|
|
3347
3347
|
<path class="font" d="m33.33,20c0,1.84-1.49,3.33-3.33,3.33H10c-1.84,0-3.34-1.49-3.34-3.33s1.5-3.34,3.34-3.34h20c1.84,0,3.33,1.5,3.33,3.34Z"/>
|
|
3348
|
-
</svg>`,
|
|
3348
|
+
</svg>`,c8=(e,i,r)=>`
|
|
3349
3349
|
<svg id="arrow" viewBox="0 0 40 40" x="${e}" y="${i}" width="40" height="40">
|
|
3350
3350
|
<circle class="cls-2" cx="20" cy="20" r="20"/>
|
|
3351
3351
|
<g transform="rotate(${r})" transform-origin="20 20">
|
|
3352
3352
|
<path class="font" d="m17.7,7.23h4.6c.52,0,.94.42.94.94v13.82c0,.52.42.94.94.94h3.39c.83,0,1.25,1.01.66,1.6l-7.56,7.56c-.37.37-.96.37-1.32,0l-7.56-7.56c-.59-.59-.17-1.6.66-1.6h3.39c.52,0,.94-.42.94-.94v-13.82c0-.52.42-.94.94-.94Z"/>
|
|
3353
3353
|
</g>
|
|
3354
|
-
</svg>`,
|
|
3354
|
+
</svg>`,c5=`
|
|
3355
3355
|
<svg class="MLEP__array-buttons" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
3356
3356
|
viewBox=
|
|
3357
3357
|
"-2 -2 205 205">
|
|
@@ -3370,38 +3370,38 @@ viewBox=
|
|
|
3370
3370
|
width="${144}"
|
|
3371
3371
|
rx="${24}"/>
|
|
3372
3372
|
<g data-command='"moveDown"'>
|
|
3373
|
-
${
|
|
3373
|
+
${c8(104,152,0)}
|
|
3374
3374
|
</g>
|
|
3375
3375
|
<g data-command='"moveUp"'>
|
|
3376
|
-
${
|
|
3376
|
+
${c8(104,56,180)}
|
|
3377
3377
|
</g>
|
|
3378
3378
|
<g data-command='"moveToNextWord"'>
|
|
3379
|
-
${
|
|
3379
|
+
${c8(152,104,-90)}
|
|
3380
3380
|
</g>
|
|
3381
3381
|
<g data-command='"moveToPreviousWord"'>
|
|
3382
|
-
${
|
|
3382
|
+
${c8(56,104,90)}
|
|
3383
3383
|
</g>
|
|
3384
3384
|
<g>
|
|
3385
3385
|
|
|
3386
3386
|
<g data-command='"addColumnBefore"'>
|
|
3387
|
-
${
|
|
3387
|
+
${c3(56,4)}
|
|
3388
3388
|
</g>
|
|
3389
3389
|
<g data-command='"removeColumn"'>
|
|
3390
|
-
${
|
|
3390
|
+
${c6(104,4)}
|
|
3391
3391
|
</g>
|
|
3392
3392
|
<g data-command='"addColumnAfter"'>
|
|
3393
|
-
${
|
|
3393
|
+
${c3(152,4)}
|
|
3394
3394
|
</g>
|
|
3395
3395
|
<g data-command='"addRowBefore"'>
|
|
3396
|
-
${
|
|
3396
|
+
${c3(4,56)}
|
|
3397
3397
|
</g>
|
|
3398
3398
|
<g data-command='"removeRow"'>
|
|
3399
|
-
${
|
|
3399
|
+
${c6(4,104)}
|
|
3400
3400
|
</g>
|
|
3401
3401
|
<g data-command='"addRowAfter"'>
|
|
3402
|
-
${
|
|
3402
|
+
${c3(4,152)}
|
|
3403
3403
|
</g>
|
|
3404
|
-
</svg>`,
|
|
3404
|
+
</svg>`,c7=e=>`
|
|
3405
3405
|
<svg id="Bmatrix" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24"
|
|
3406
3406
|
data-command='["setEnvironment","Bmatrix"]'>
|
|
3407
3407
|
<rect class="cls-1" width="28" height="24"/>
|
|
@@ -3410,7 +3410,7 @@ viewBox=
|
|
|
3410
3410
|
<circle cx="10" cy="8" r="1"/>
|
|
3411
3411
|
<circle cx="14" cy="12" r="1"/>
|
|
3412
3412
|
<circle cx="18" cy="16" r="1"/>
|
|
3413
|
-
</svg>`,
|
|
3413
|
+
</svg>`,c9={matrix:e=>`
|
|
3414
3414
|
<svg id="matrix" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24"
|
|
3415
3415
|
data-command='["setEnvironment","matrix"]'>
|
|
3416
3416
|
<rect class="cls-1" width="28" height="24"/>
|
|
@@ -3433,7 +3433,7 @@ data-command='["setEnvironment","pmatrix"]'>
|
|
|
3433
3433
|
<circle cx="10" cy="8" r="1"/>
|
|
3434
3434
|
<circle cx="14" cy="12" r="1"/>
|
|
3435
3435
|
<circle cx="18" cy="16" r="1"/>
|
|
3436
|
-
</svg>`,Bmatrix:
|
|
3436
|
+
</svg>`,Bmatrix:c7,vmatrix:e=>`
|
|
3437
3437
|
<svg id="vmatrix" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24"
|
|
3438
3438
|
data-command='["setEnvironment","vmatrix"]'>
|
|
3439
3439
|
<rect class="cls-1" width="28" height="24"/>
|
|
@@ -3453,7 +3453,7 @@ data-command='["setEnvironment","pmatrix"]'>
|
|
|
3453
3453
|
<line class="cls-2" x1="22" y1="4" x2="22" y2="20"/>
|
|
3454
3454
|
<line class="cls-2" x1="2" y1="4" x2="2" y2="20"/>
|
|
3455
3455
|
<line class="cls-2" x1="26" y1="4" x2="26" y2="20"/>
|
|
3456
|
-
</svg>`},
|
|
3456
|
+
</svg>`},de={cases:e=>`
|
|
3457
3457
|
<svg id="cases" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24"
|
|
3458
3458
|
data-command='["setEnvironment","cases"]'>
|
|
3459
3459
|
<rect class="cls-1" width="28" height="24"/>
|
|
@@ -3471,30 +3471,30 @@ data-command='["setEnvironment","pmatrix"]'>
|
|
|
3471
3471
|
<circle cx="15" cy="16" r="1"/>
|
|
3472
3472
|
<circle cx="7" cy="8" r="1"/>
|
|
3473
3473
|
<circle cx="7" cy="16" r="1"/>
|
|
3474
|
-
</svg>`,Bmatrix:
|
|
3474
|
+
</svg>`,Bmatrix:c7};function dt(){let e=document.getElementById("mathlive-environment-popover");null==e||e.classList.remove("is-visible")}function di(e){if(!e.hasFocus())return;let i=!1;if("math"===e.model.mode){var r;let a=e.model.parentEnvironment;if(null!=a&&a.rows&&(r=a.environmentName,nZ.includes(r)||nG.includes(r)||nG.includes(r)||nX.includes(r)||nY.includes(r))){let r=e.options.environmentPopoverPolicy;i="auto"===r||"on"===r}}i?function(e){var i,r,a;let o=null==(i=e.model.parentEnvironment)?void 0:i.rows;if(!o)return;let n=0;o.forEach(e=>{(!n||e.length>n)&&(n=e.length)});let l=document.getElementById("mathlive-environment-popover");l||(l=sb("mathlive-environment-popover"),nz("environment-popover"),nz("core"),l.setAttribute("aria-hidden","true"));let s,c=l.querySelector(".MLEP__environment-controls");c?s=c:(s=document.createElement("div"),l.innerHTML="",l.appendChild(s)),s.className="MLEP__environment-controls",s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.boxSizing="border-box",s.innerHTML=c5;let d=[],u="",h=e.model.parentEnvironment.environmentName;if(nQ(h)){let e=h.replace("*","");u=c9[e]("active");let{[e]:i}=c9;d=Object.values(y(c9,[b(e)])).map(e=>e("inactive"))}else if(nG.includes(h)){let e="dcases"===(a=h)?"cases":a;u=de[e]("active");let{[e]:i}=de;d=Object.values(y(de,[b(e)])).map(e=>e("inactive"))}else nZ.includes(h)&&(u=c9.matrix("active"),d=Object.values(de).map(e=>e("inactive")));let p=document.createElement("div");p.className="MLEP__environment-delimiter-controls",p.style.display="flex",p.style.flexDirection="column",p.innerHTML=`
|
|
3475
3475
|
<div class='MLEP__array-delimiter-options'>
|
|
3476
3476
|
${u}
|
|
3477
3477
|
${d.join("")}
|
|
3478
|
-
</div>`,u&&s.appendChild(p),s.querySelectorAll("[data-command]").forEach(i=>{let r=i.dataset.command,a=r;try{a=JSON.parse(r)}catch(e){}i.addEventListener("mousedown",e=>e.preventDefault()),a&&i.addEventListener("click",()=>e.executeCommand(a))});let m=null==(r=e.field)?void 0:r.getBoundingClientRect();m&&(l.style.top=`${window.scrollY+(m.top-l.clientHeight-15)}px`,l.style.left=`${m.left+20}px`,l.classList.add("is-visible"))}(e):
|
|
3479
|
-
</span>`;break;case"trailing-chevron":r='<span aria-hidden="true" class="ui-trailing-chevron"><svg focusable="false" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path fill="currentColor" d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"></path></svg></span>';break;case"mixedmark":r='<span aria-hidden="true" class="ui-mixedmark"><svg xmlns="http://www.w3.org/2000/svg" width="16" viewBox="0 0 512 512"><path fill="currentColor" d="M0 256c0-13.3 10.7-24 24-24H488c13.3 0 24 10.7 24 24s-10.7 24-24 24H24c-13.3 0-24-10.7-24-24z"/></svg></span>'}if(r){let a=document.createElement("template");a.innerHTML=r,dd[e]=a,i=a}}if(i){if("content"in i)return i.content.cloneNode(!0);let e=document.createElement("svg");return e.innerHTML=i.innerHTML,e}}var dh=class{constructor(e,i){var r;this._className="",this._element=null,this.parentMenu=i,this._declaration=e,Object.freeze(this._declaration),dn(e)?(this.type="submenu",this.submenu=new dm(e.submenu,{parentMenu:i,submenuClass:e.submenuClass,columnCount:e.columnCount})):this.type=null!=(r=e.type)?r:"command",this.hasCheck=dl(e)&&void 0!==e.checked}get rootMenu(){return this.parentMenu.rootMenu}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}dispose(){var e,i;null==(e=this._abortController)||e.abort(),this._abortController=void 0,null==(i=this._element)||i.remove(),this._element=null,this.submenu&&this.submenu.dispose(),this.submenu=void 0}get menuItem(){return this._declaration}get label(){var e;return null!=(e=this._label)?e:""}set label(e){void 0===e&&(e=""),e!==this._label&&(this._label=e,this.dirty=!0)}get visible(){return this._visible}set visible(e){e!==this._visible&&(this._visible=e,this.dirty=!0)}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this.element&&(e?this.element.removeAttribute("aria-disabled"):this.element.setAttribute("aria-disabled","true")),this.dirty=!0}get checked(){return this._checked}set checked(e){this._checked=e,this.dirty=!0}get tooltip(){return this._tooltip}set tooltip(e){e!==this._tooltip&&(this._tooltip=e,this.dirty=!0)}get ariaLabel(){return this._ariaLabel}set ariaLabel(e){e!==this._ariaLabel&&(this._ariaLabel=e,this.dirty=!0)}get active(){var e,i;return null!=(i=null==(e=this.element)?void 0:e.classList.contains("active"))&&i}set active(e){this.element&&this.element.classList.toggle("active",e)}updateState(e){var i,r,a;let o=this._declaration;if(ds(o)){this.enabled=!1,this.checked=!1;return}dc(o)&&(this.enabled=!1,this.checked=!1,this.visible=!0),dl(o)&&(this.checked=null!=(i=dp(o.checked,e))&&i),(dl(o)||dn(o))&&(this.enabled=null==(r=dp(o.enabled,e))||r,this.visible=null==(a=dp(o.visible,e))||a,this.visible&&this.enabled&&this.submenu&&(this.submenu.updateState(e),this.submenu.visible||(this.visible=!1))),(dl(o)||dc(o)||dn(o))&&(this.label=dp(o.label,e),this._className=dp(o.class,e),this.tooltip=dp(o.tooltip,e),this.ariaLabel=dp(o.ariaLabel,e)),this._element&&this.updateElement()}set dirty(e){e&&this.parentMenu&&(this.parentMenu.dirty=!0)}updateElement(){var e;if(!this.visible||!this.element)return;let i=this.element;i.textContent="",i.className="",i.className=null!=(e=this._className)?e:"",this.enabled?i.removeAttribute("aria-disabled"):i.setAttribute("aria-disabled","true"),!0===this.checked?(i.setAttribute("aria-checked","true"),i.append(du("checkmark"))):"mixed"===this.checked?(i.setAttribute("aria-checked","mixed"),i.append(du("mixedmark"))):i.removeAttribute("aria-checked"),this.ariaLabel&&i.setAttribute("aria-label",this.ariaLabel);let r=document.createElement("span");if(r.className=this.parentMenu.hasCheck?"label indent":"label","heading"===this.type&&r.classList.add("heading"),r.innerHTML=this.label,i.append(r),this._tooltip&&i.setAttribute("data-tooltip",this._tooltip),dl(this._declaration)&&this._declaration.keyboardShortcut){let e=document.createElement("kbd");e.innerHTML=l3(this._declaration.keyboardShortcut),i.append(e)}"submenu"===this.type&&i.append(du("trailing-chevron"))}get element(){if(this._element)return this._element;if(ds(this._declaration)){let e=document.createElement("li");return e.setAttribute("part","menu-divider"),e.setAttribute("role","divider"),this._element=e,e}let e=document.createElement("li");this._element=e,(dl(this._declaration)||dc(this._declaration)||dn(this._declaration))&&e.setAttribute("part","menu-item"),e.setAttribute("tabindex","-1"),this.hasCheck?e.setAttribute("role","menuitemcheckbox"):e.setAttribute("role","menuitem"),"submenu"===this.type&&(e.setAttribute("aria-haspopup","true"),e.setAttribute("aria-expanded","false"));let i=this.abortController.signal;return e.addEventListener("pointerenter",this,{signal:i}),e.addEventListener("pointerleave",this,{signal:i}),e.addEventListener("pointerup",this,{signal:i}),e.addEventListener("click",this,{signal:i}),this._element}dispatchSelect(){var e;if(!dl(this._declaration))return;let i=new CustomEvent("menu-select",{cancelable:!0,bubbles:!0,detail:{modifiers:this.rootMenu.modifiers,id:this._declaration.id,data:this._declaration.data}});this.parentMenu.dispatchEvent(i)&&"function"==typeof this._declaration.onMenuSelect&&this._declaration.onMenuSelect({target:null!=(e=this.parentMenu.host)?e:void 0,modifiers:this.rootMenu.modifiers,id:this._declaration.id,data:this._declaration.data})}handleEvent(e){var i;if(!(!this.visible||!this.enabled)){if("click"===e.type){"modal"===this.rootMenu.state&&this.select(),e.stopPropagation(),e.preventDefault();return}if("pointerenter"===e.type){this.rootMenu.cancelDelayedOperation(),this.parentMenu.isSubmenuOpen&&null!=(i=this.parentMenu.activeMenuItem)&&i.movingTowardSubmenu(e)?this.rootMenu.scheduleOperation(()=>{this.parentMenu.activeMenuItem=this,this.openSubmenu()}):(this.parentMenu.activeMenuItem=this,this.openSubmenu({withDelay:!0}));return}if("pointerleave"===e.type){this.rootMenu.activeSubmenu===this.parentMenu&&(this.parentMenu.activeMenuItem=null);return}if("pointerup"===e.type){"modal"!==this.rootMenu.state&&this.select(),e.stopPropagation(),e.preventDefault();return}}}select(){(this.rootMenu.cancelDelayedOperation(),"submenu"===this.type)?this.openSubmenu():(this.active=!1,setTimeout(()=>{this.active=!0,setTimeout(()=>{this.active=!1,this.rootMenu.hide(),this.dispatchSelect()},80)},80))}openSubmenu(e){var i;if("submenu"!==this.type||!this.element)return;if(null!=(i=null==e?void 0:e.withDelay)&&i)return void this.rootMenu.scheduleOperation(()=>this.openSubmenu());let r=this.element.getBoundingClientRect(),a=di(this.element);this.submenu.show({container:this.rootMenu.element.parentNode,location:{x:dr(r,"trailing",a),y:r.top-4},alternateLocation:{x:dr(r,"leading",a),y:r.top-4}})}movingTowardSubmenu(e){var i,r;if(!this.element||"submenu"!==this.type)return!1;let a=this.rootMenu.lastMoveEvent;if(!a)return!1;let o=e.timeStamp-a.timeStamp;if(o>500)return!1;let n=e.clientX-a.clientX;if(.2>=(i=n,r=a.clientY-e.clientY,Math.hypot(i,r)/o))return!1;let l="right";if(this.submenu.element){let e=this.submenu.element.getBoundingClientRect(),i=this.element.getBoundingClientRect();e.left<i.left+i.width/2&&(l="left")}return"right"===l?n>0:n<0}};function dp(e,i){return void 0===e||"function"!=typeof e?e:(null!=i||(i={alt:!1,control:!1,shift:!1,meta:!1}),e(i))}var dm=class e{constructor(e,i){var r,a;this._element=null,this._activeMenuItem=null,this._dirty=!0,this.parentMenu=null!=(r=null==i?void 0:i.parentMenu)?r:null,this._submenuClass=null==i?void 0:i.submenuClass,this.columnCount=null!=(a=null==i?void 0:i.columnCount)?a:1,this.isSubmenuOpen=!1,this.menuItems=e}get children(){return Object.freeze([...this._menuItems])}set menuItems(e){let i=this.parentMenu;this.dispose(),this.parentMenu=i,e=[...e],this._menuItems=e.map(e=>e.onCreate?e.onCreate(e,this):new dh(e,this)),this.hasCheck=void 0,this.dirty=!0}dispose(){var e;this.hide(),this._element&&this._element.remove(),this._abortController&&this._abortController.abort(),null==(e=this._menuItems)||e.forEach(e=>e.dispose()),this._menuItems=[],this._activeMenuItem=null,this.parentMenu=null}handleEvent(e){"wheel"===e.type&&this._element&&(this._element.scrollBy(0,e.deltaY),e.stopPropagation())}dispatchEvent(e){return this.rootMenu.dispatchEvent(e)}get host(){return this.rootMenu.host}get rootMenu(){return this.parentMenu.rootMenu}updateState(e){var i,r,a;this._menuItems.forEach(i=>i.updateState(e));let o=this.hasCheck;this.hasCheck=this._menuItems.some(e=>e.visible&&e.hasCheck),this.hasCheck!==o&&this._menuItems.forEach(i=>i.updateState(e));let n,l=0;for(let e of this._menuItems)"heading"===e.type?(n&&0===l&&(n.visible=!1),n=e,l=0):"divider"===e.type&&n?(n.visible=l>0,n=void 0,l=0):n&&e.visible&&(l+=1);n&&(n.visible=l>0);let s=!0;for(let e of this._menuItems)"divider"===e.type?(e.visible=!s,s=!0):e.visible&&(s=!1);null!=(i=this.activeMenuItem)&&i.visible||(this.activeMenuItem=null),null!=(r=this.activeMenuItem)&&r.enabled||(null==(a=this.activeMenuItem)?void 0:a.type)!=="submenu"||this._activeMenuItem.submenu.hide(),this._dirty=!1}get enabled(){return this.updateIfDirty(),this._menuItems.some(e=>"divider"!==e.type&&e.visible&&e.enabled)}get visible(){return this.updateIfDirty(),this._menuItems.some(e=>"divider"!==e.type&&e.visible)}set dirty(e){this._dirty!==e&&e&&this.parentMenu&&(this._dirty=!0,this.parentMenu.dirty=!0)}updateIfDirty(){this._dirty&&this.updateState(this.rootMenu.modifiers)}updateElement(){var e;if(this._element){for(let{element:e,visible:i}of(this._element.textContent="",this._menuItems))e&&i&&this._element.append(e);null==(e=this._element.querySelector("li:first-of-type"))||e.setAttribute("tabindex","0")}}get element(){if(this._element)return this._element;let e=document.createElement("menu");e.setAttribute("role","menu"),e.setAttribute("tabindex","-1"),e.setAttribute("aria-orientation","vertical"),e.setAttribute("part","ui-menu-container"),this._submenuClass&&e.classList.add(this._submenuClass),e.classList.add("ui-menu-container"),this._abortController||(this._abortController=new AbortController);let i=this._abortController.signal;return e.addEventListener("focus",this,{signal:i}),e.addEventListener("wheel",this,{passive:!0,signal:i}),this._element=e,this.updateElement(),e}get activeMenuItem(){return this._activeMenuItem}set activeMenuItem(e){var i,r,a,o;if(this.rootMenu.cancelDelayedOperation(),e!==this._activeMenuItem){if(this.activeMenuItem){let e=this.activeMenuItem;e.active=!1,null==(i=e.submenu)||i.hide()}if(!(null==(r=null==e?void 0:e.visible)||r)){this._activeMenuItem=null;return}this._activeMenuItem=e,e&&(e.active=!0)}e?null==(a=e.element)||a.focus({preventScroll:!0}):null==(o=this._element)||o.focus({preventScroll:!0})}get firstMenuItem(){this.updateIfDirty();let e=0,i=!1,r=this._menuItems;for(;!i&&e<=r.length-1;){let a=r[e];i="divider"!==a.type&&a.visible&&a.enabled,e+=1}return i?r[e-1]:null}get lastMenuItem(){this.updateIfDirty();let e=this._menuItems,i=e.length-1,r=!1;for(;!r&&i>=0;){let a=e[i];r="divider"!==a.type&&a.visible&&a.enabled,i-=1}return r?e[i+1]:null}nextMenuItem(e){if(0===e)return this._activeMenuItem;if(!this._activeMenuItem)return e>0?this.firstMenuItem:this.lastMenuItem;if(!this.firstMenuItem||!this.lastMenuItem||!this._activeMenuItem)return null;this.updateIfDirty();let i=this._menuItems.indexOf(this.firstMenuItem),r=this._menuItems.indexOf(this.lastMenuItem),a=this._menuItems.indexOf(this._activeMenuItem),o=1;for(;a>=i&&a<=r;){a+=e>0?1:-1;let i=this._menuItems[a];if(!i)break;if(i.visible&&i.enabled){if(o===Math.abs(e))return this._menuItems[a];o+=1}}return e>0?this.lastMenuItem:this.firstMenuItem}getMenuItemColumn(e){this.updateIfDirty();let i=this._menuItems.filter(e=>e.visible&&e.enabled).indexOf(e);return i<0?-1:i%this.columnCount}static get collator(){return e._collator||(e._collator=new Intl.Collator(void 0,{usage:"search",sensitivity:"base"})),e._collator}findMenuItem(i){var r;this.updateIfDirty();let a=this._menuItems.filter(e=>"divider"!==e.type&&e.visible&&e.enabled);if(0===a.length)return null;let o=Math.max(...a.map(e=>e.label.length))-i.length;if(o<0)return null;let n=null,l=0;for(;l<o&&!n;)n=null!=(r=a.find(r=>0===e.collator.compare(i,r.label.substring(l,i.length))))?r:null,l++;return n}show(e){var i,r,a,o,n,l,s,c;let d,u,h,p,m,f;return!!this.visible&&!!e.container&&(this.updateElement(),e.container.appendChild(this.element),k()&&(this.element.popover="manual",this.element.showPopover()),e.location&&(i=this.element,r={location:e.location,alternateLocation:e.alternateLocation,verticalPos:"bottom",horizontalPos:"start"},d=null!=(a=di(i))?a:"ltr",i.style.position="fixed",i.style.left="",i.style.top="",i.style.right="",i.style.bottom="",i.style.height="",i.style.width="",u=i.getBoundingClientRect(),h=Math.min(Number.isFinite(r.maxHeight)?Math.min(r.maxHeight,window.innerHeight):window.innerHeight,null!=(o=r.height)?o:u.height),(p=da(r.location.y,h,r.verticalPos,d))+h>window.innerHeight-8&&(r.alternateLocation?(p=da(r.alternateLocation.y,h,r.verticalPos,d))+h>window.innerHeight-8&&(p=void 0):p=void 0),Number.isFinite(p)||(p=Math.max(8,window.innerHeight-8-h),8+h>window.innerHeight-8&&(i.style.bottom="8px")),h=Math.min(p+h,window.innerHeight-8)-p,m=Math.min(Number.isFinite(r.maxWidth)?Math.min(r.maxWidth,window.innerWidth):window.innerWidth,null!=(n=r.width)?n:u.width),(f=da(r.location.x,m,r.horizontalPos,d))+m>window.innerWidth-8&&(r.alternateLocation?(l=r.alternateLocation.x,s=m,c=r.verticalPos,(f="middle"===c?l-s/2:"start"===c&&"ltr"===d||"end"===c&&"rtl"===d||"top"===c||"right"===c?l:l-s)+m>window.innerWidth-8&&(f=void 0)):f=void 0),Number.isFinite(f)||(f=Math.max(8,window.innerWidth-8-m),8+m>window.innerWidth-8&&(i.style.right="8px")),m=Math.min(f+m,window.innerWidth-8)-f,"rtl"===d?i.style.right=`${Math.ceil(window.innerWidth-f-m).toString()}px`:i.style.left=`${Math.ceil(f).toString()}px`,i.style.top=`${Math.ceil(p).toString()}px`,h!==u.height&&(i.style.height=`${Math.ceil(h).toString()}px`),m!==u.width&&(i.style.width=`${Math.ceil(m).toString()}px`)),df(),this.element.focus({preventScroll:!0}),db(),this.parentMenu&&(this.parentMenu.openSubmenu=this),!0)}hide(){var e,i,r,a,o,n;this.openSubmenu=null,this.activeMenuItem=null,this.parentMenu&&(this.parentMenu.openSubmenu=null),null!=(e=this._element)&&e.isConnected&&this._element.parentElement&&(k()&&null!=(i=this._element)&&i.popover&&this._element.hidePopover(),df(),null==(a=null==(r=this.parentMenu)?void 0:r.element)||a.focus(),null==(n=null==(o=this._element)?void 0:o.parentNode)||n.removeChild(this._element),db())}set openSubmenu(e){var i,r,a,o;let n=null!==e;(null==(i=this.activeMenuItem)?void 0:i.type)==="submenu"&&(null==(r=this.activeMenuItem.element)||r.setAttribute("aria-expanded",n.toString())),null==(o=null==(a=this.activeMenuItem)?void 0:a.element)||o.classList.toggle("is-submenu-open",n),this.isSubmenuOpen=n}};function df(){document.addEventListener("focusin",dg,!0),document.addEventListener("focusout",dg,!0),document.addEventListener("focus",dg,!0),document.addEventListener("blur",dg,!0)}function dg(e){e.stopImmediatePropagation(),e.preventDefault()}function db(){document.removeEventListener("focusin",dg,!0),document.removeEventListener("focusout",dg,!0),document.removeEventListener("focus",dg,!0),document.removeEventListener("blur",dg,!0)}var dy=class e extends dm{constructor(e,i){var r;super(e),this.state="closed",this.typingBufferResetTimer=0,this.hysteresisTimer=0,this._updating=!1,this._host=null!=(r=null==i?void 0:i.host)?r:null,this.isDynamic=e.some(dv),this._modifiers={shift:!1,control:!1,alt:!1,meta:!1},this.typingBuffer="",this.state="closed"}get modifiers(){return this._modifiers}set modifiers(e){var i;i=this._modifiers,(!i&&e||i&&!e||i&&e&&(i.alt!==e.alt||i.control!==e.control||i.shift!==e.shift||i.meta!==e.meta))&&(this._modifiers=e,this.dirty=!0)}get activeSubmenu(){let e=this;for(;e.isSubmenuOpen;)e=e.activeMenuItem.submenu;return e}set dirty(e){this._updating||this._dirty!==e&&(this._dirty=!0,e&&setTimeout(()=>{this.updateState(this.modifiers),this.updateElement()}))}updateState(e){this._updating=!0,this.modifiers=null!=e?e:this.modifiers,super.updateState(this.modifiers),this._updating=!1}handleKeyupEvent(e){this.isDynamic&&(this.modifiers=l8(e)),e.stopImmediatePropagation()}handleKeydownEvent(e){var i,r,a;if("Tab"===e.key||"Escape"===e.key)return void this.hide();this.isDynamic&&(this.modifiers=l8(e));let o=!0,n=this.activeSubmenu,l=n.activeMenuItem;switch(e.key){case" ":case"Space":case"Return":case"Enter":null==l||l.select(l8(e));break;case"ArrowRight":if((null==l?void 0:l.type)==="submenu")l.select(l8(e)),this.activeSubmenu.activeMenuItem=this.activeSubmenu.firstMenuItem;else if(l){let e=null!=(i=n.getMenuItemColumn(l))?i:-1;if(e>=0&&e<(null!=(r=n.columnCount)?r:1)-1){let e=n.nextMenuItem(1);e&&(n.activeMenuItem=e)}}else n.activeMenuItem=n.firstMenuItem;break;case"ArrowLeft":if(n===this.rootMenu)l||(n.activeMenuItem=n.firstMenuItem);else if((l&&null!=(a=n.getMenuItemColumn(l))?a:-1)<=0||!l){n.hide();let e=n.parentMenu.activeMenuItem;if(e){let{element:i}=e;null==i||i.focus(),null==i||i.classList.remove("is-submenu-open")}}else{let e=n.nextMenuItem(-1);e&&(n.activeMenuItem=e)}break;case"ArrowDown":n.activeMenuItem=n.nextMenuItem(n.columnCount);break;case"ArrowUp":n.activeMenuItem=n.nextMenuItem(-n.columnCount);break;case"Home":case"PageUp":n.activeMenuItem=n.firstMenuItem;break;case"End":case"PageDown":n.activeMenuItem=n.lastMenuItem;break;case"Backspace":if(this.typingBuffer&&(this.typingBuffer=this.typingBuffer.slice(0,-1),this.typingBuffer)){clearTimeout(this.typingBufferResetTimer);let e=n.findMenuItem(this.typingBuffer);e&&(n.activeMenuItem=e),this.typingBufferResetTimer=setTimeout(()=>{this.typingBuffer=""},500)}break;default:if(l7(e)){isFinite(this.typingBufferResetTimer)&&clearTimeout(this.typingBufferResetTimer),this.typingBuffer+=e.key;let i=n.findMenuItem(this.typingBuffer);i&&(n.activeMenuItem=i),this.typingBufferResetTimer=setTimeout(()=>{this.typingBuffer=""},500)}else o=!1}o&&(e.preventDefault(),e.stopPropagation())}handleEvent(e){if("keydown"===e.type)this.handleKeydownEvent(e);else if("keyup"===e.type)this.handleKeyupEvent(e);else if("pointermove"===e.type)this.lastMoveEvent=e;else if("pointerup"===e.type)Number.isFinite(this.rootMenu._openTimestamp)&&Date.now()-this.rootMenu._openTimestamp<120?this.state="modal":"modal"===this.state&&e.target===this.scrim&&this.hide();else if("contextmenu"===e.type){e.preventDefault(),e.stopPropagation();return}super.handleEvent(e)}dispatchEvent(e){return!this._host||this._host.dispatchEvent(e)}get host(){return this._host}get scrim(){return se.element}connectScrim(e){let i=this.scrim;i.addEventListener("pointerup",this,!0),i.addEventListener("contextmenu",this),i.addEventListener("keydown",this),i.addEventListener("keyup",this),i.addEventListener("pointermove",this),se.open({root:e,onDismiss:()=>this.hide()})}disconnectScrim(){let e=this.scrim;e.removeEventListener("pointerup",this,!0),e.removeEventListener("contextmenu",this),e.removeEventListener("keydown",this),e.removeEventListener("keyup",this),e.removeEventListener("pointermove",this),"open"===se.state&&se.scrim.close()}get rootMenu(){return this}show(e){return this._onDismiss=null==e?void 0:e.onDismiss,null!=e&&e.modifiers&&(this.modifiers=e.modifiers),this.updateState(),this.connectScrim(null==e?void 0:e.target),super.show(g(f({},e),{container:this.scrim}))?(this._openTimestamp=Date.now(),this.state="open",!0):(this.disconnectScrim(),!1)}hide(){this.cancelDelayedOperation(),void 0!==this.state&&("closed"!==this.state&&(this.activeMenuItem=null,se.element.parentElement.focus(),super.hide(),this.state="closed",this.disconnectScrim()),this._onDismiss&&(this._onDismiss(),this._onDismiss=void 0))}scheduleOperation(i){this.cancelDelayedOperation();let r=e.SUBMENU_DELAY;r<=0?i():this.hysteresisTimer=setTimeout(()=>{this.hysteresisTimer=0,i()},r)}cancelDelayedOperation(){this.hysteresisTimer&&(clearTimeout(this.hysteresisTimer),this.hysteresisTimer=0)}};function dv(e){return!ds(e)&&(!!("function"==typeof e.label||"function"==typeof e.ariaLabel||"function"==typeof e.tooltip||(dl(e)||dn(e))&&("function"==typeof e.enabled||"function"==typeof e.visible)||dl(e)&&"function"==typeof e.checked)||!!dn(e)&&e.submenu.some(dv))}dy.SUBMENU_DELAY=120;var dx=class{};async function d_(e,i,r){if(e.defaultPrevented)return!1;if("contextmenu"===e.type&&(e.preventDefault(),e.stopPropagation(),r.show({target:i,location:l6(e),modifiers:l8(e)})))return!0;if("keydown"===e.type&&("ContextMenu"===e.code||"F10"===e.code&&e.shiftKey)){let a=null==i?void 0:i.getBoundingClientRect();if(dw(i)&&a&&r.show({target:i,location:{x:Math.ceil(a.left+a.width/2),y:Math.ceil(a.top+a.height/2)},modifiers:l8(e)}))return e.preventDefault(),e.stopPropagation(),!0}if("pointerdown"===e.type&&"mouse"!==e.pointerType&&0===e.button){let a=e.target;for(;a&&i!==a;)a=a.parentNode;if(!a||!r.visible)return!1;let o=l6(e);if(await new Promise((i,r)=>{let a=l6(e);a||i(!1);let o=a,n=setTimeout(()=>{var e;l.abort(),i((e=o,Math.hypot(a.x-e.x,a.y-e.y)<dx.MAX_DISTANCE))},dx.DELAY),l=new AbortController,s=l.signal;for(let e of["pointermove","pointerup","pointercancel"])window.addEventListener(e,e=>{if("pointerup"===e.type||"pointercancel"===e.type)clearTimeout(n),l.abort(),i(!1);else if("pointermove"===e.type){let i=l6(e);i&&(o=i)}},{passive:!0,signal:s})}))return"closed"===r.state&&!!dw(i)&&(r.show({target:i,location:o}),!0)}return!1}function dw(e){return e.dispatchEvent(new Event("contextmenu",{cancelable:!0}))}dx.DELAY=300,dx.MAX_DISTANCE=10;var dk="<mo>⁡</mo>",dM="<mo>⁢</mo>";function dS(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function dL(e,i){return e&&i.generateID?` extid="${e}"`:""}function dC(e){return e.index<e.atoms.length&&e.atoms[e.index].superscript&&"subsup"===e.atoms[e.index].type}function dE(e){let i=-1,r=e.index,a=!1,o=!1;for(;r<e.atoms.length&&!a&&!o;){let i=e.atoms[r];o=!(a=!i.isDigit())&&void 0!==i.superscript,r++}return o&&(i=r-1),i}function dA(e,i,r){var a;let o=i.atoms[i.index-1];if(!o)return!1;if(!o.superscript&&!o.subscript)if((null==(a=i.atoms[i.index])?void 0:a.type)!=="subsup")return!1;else o=i.atoms[i.index],i.index+=1;let n=i.lastType;i.lastType="";let l=dz(o.superscript,r);i.lastType="";let s=dz(o.subscript,r);if(i.lastType=n,!l&&!s)return!1;let c="";return l&&s?c=`<msubsup>${e}${s}${l}</msubsup>`:l?c=`<msup>${e}${l}</msup>`:s&&(c=`<msub>${e}${s}</msub>`),i.mathML+=c,i.lastType="",!0}function dz(e,i,r,a){null!=i||(i={});let o={atoms:[],index:null!=r?r:0,mathML:"",lastType:""};if("number"==typeof e||"boolean"==typeof e)o.mathML=e.toString();else if("string"==typeof e)o.mathML=e;else if(e instanceof oG)o.mathML=dK(e,i);else if(Array.isArray(e)){o.atoms=e;let r=0;for(a=a||(e?e.length:0);o.index<a;)if(function(e,i,r){i=null!=i?i:e.atoms.length;let a=e.index,o="",n=dE(e);for(n>=0&&n<i&&(i=n);e.index<i&&"text"===e.atoms[e.index].mode;)o+=e.atoms[e.index].value?e.atoms[e.index].value:" ",e.index+=1;return o.length>0&&(o=`<mtext ${dL(e.atoms[a].id,r)}>${dS(o)}</mtext>`,n<0&&dC(e)&&(n=e.index,e.index+=1),dA(o,e,r)||(e.mathML+=o,e.lastType="mtext"),!0)}(o,a,i)||function(e,i,r){i=null!=i?i:e.atoms.length;let a=e.index,o="",n=dE(e);for(n>=0&&n<i&&(i=n);e.index<i&&e.atoms[e.index].isDigit();)o+=e.atoms[e.index].asDigit(),e.index+=1;return!(o.length<=0)&&(o="<mn"+dL(e.atoms[a].id,r)+">"+o+"</mn>",n<0&&dC(e)&&(n=e.index,e.index+=1),dA(o,e,r)||(e.mathML+=o,e.lastType="mn"),!0)}(o,a,i)||function(e,i,r){var a,o,n,l,s,c,d,u;let h=!1;i=null!=i?i:e.atoms.length;let p="",m="",f=e.atoms[e.index],g=null==(a=f.style)?void 0:a.variant,b=null==(o=f.style)?void 0:o.variantStyle,y="";if(f.value&&(g||b)){let i=null!=(n=ee(f.value,g,b))?n:f.value;if(i!==f.value)return e.index+=1,dA(p=`<mi${dL(f.id,r)}>${i}</mi>`,e,r)||(e.mathML+=p,e.lastType="mi"),!0;(y=null!=(l=({upnormal:"normal",boldnormal:"bold",italicmain:"italic",bolditalicmain:"bold-italic","updouble-struck":"double-struck","double-struck":"double-struck",boldfraktur:"bold-fraktur",calligraphic:"script",upcalligraphic:"script",script:"script",boldscript:"bold-script",boldcalligraphic:"bold-script",fraktur:"fraktur","upsans-serif":"sans-serif","boldsans-serif":"bold-sans-serif","italicsans-serif":"sans-serif-italic","bolditalicsans-serif":"sans-serif-bold-italic",monospace:"monospace"})[(null!=b?b:"")+(null!=g?g:"")])?l:"")&&(y=` mathvariant="${y}"`)}let v={"\\exponentialE":"ⅇ","\\imaginaryI":"ⅈ","\\differentialD":"ⅆ","\\capitalDifferentialD":"ⅅ","\\alpha":"α","\\pi":"π","\\infty":"∞","\\forall":"∀","\\nexists":"∄","\\exists":"∃","\\hbar":"ℏ","\\cdotp":"⋅","\\ldots":"…","\\dots":"…","\\cdots":"⋯","\\ddots":"⋱","\\vdots":"⋮","\\ldotp":"."};if("!"===f.command)return e.index+=1,dA(p="<mo>!</mo>",e,r)||(e.mathML+=p,e.lastType="mo"),!0;if(v[f.command]){e.index+=1;let i=`<mi${dL(f.id,r)}${y}>${v[f.command]}</mi>`;return("mi"===e.lastType||"mn"===e.lastType||"mtext"===e.lastType||"fence"===e.lastType)&&(i=dM+i),dA(i,e,r)||(e.mathML+=i,e.lastType="mi"),!0}if("\\operatorname"===f.command)m=dD(f.body),e.index+=1;else if(g||b)for(;e.index<i&&("mord"===f.type||"macro"===f.type)&&!f.isDigit()&&g===(null!=(c=null==(s=f.style)?void 0:s.variant)?c:"")&&b===(null!=(u=null==(d=f.style)?void 0:d.variantStyle)?u:"");)m+=dD([f]),e.index+=1,f=e.atoms[e.index];else"mord"!==f.type&&"macro"!==f.type||f.isDigit()||(m+=dD([f]),e.index+=1);if(m.length>0){h=!0,p=`<mi${y}>${m}</mi>`;let i=e.lastType;p.endsWith(">f</mi>")||p.endsWith(">g</mi>")?(p+=dk,e.lastType="applyfunction"):e.lastType=/^<mo>(.*)<\/mo>$/.test(p)?"mo":"mi",dA(p,e,r)||(("mi"===i||"mn"===i||"mtext"===i||"fence"===i)&&(p=dM+p),e.mathML+=p)}return h}(o,a,i)||function(e,i,r){let a=!1;i=null!=i?i:e.atoms.length;let o="",n="",l=e.atoms[e.index];if(!l)return!1;let s={"\\ne":"≠","\\neq":"≠","\\pm":"±","\\times":"×","\\colon":":","\\vert":"|","\\Vert":"∥","\\mid":"∣","\\{":"{","\\}":"}","\\lbrace":"{","\\rbrace":"}","\\lbrack":"[","\\rbrack":"]","\\lparen":"(","\\rparen":")","\\langle":"⟨","\\rangle":"⟩","\\lfloor":"⌊","\\rfloor":"⌋","\\lceil":"⌈","\\rceil":"⌉"};if(s[l.command]){e.index+=1;let i=`<mo${dL(l.id,r)}>${s[l.command]}</mo>`;return dA(i,e,r)||(e.mathML+=i,e.lastType="mo"),!0}if(e.index<i&&("mbin"===l.type||"mrel"===l.type))o+=dK(e.atoms[e.index],r),e.index+=1,n="mo";else if(e.index<i&&("mop"===l.type||"operator"===l.type||"extensible-symbol"===l.type)){if("over-under"===l.subsupPlacement&&(l.superscript||l.subscript)){let i=dT(l,r);return l.superscript&&l.subscript?(o+="<munderover>"+i,o+=dz(l.subscript,r),o+=dz(l.superscript,r),o+="</munderover>"):l.superscript?(o+="<mover>"+i,o+=dz(l.superscript,r),o+="</mover>"):l.subscript&&(o+="<munder>"+i,o+=dz(l.subscript,r),o+="</munder>"),e.mathML+=o,e.lastType="mo",e.index+=1,!0}{let i=e.atoms[e.index],a="\\operatorname"===i.value,l=a?'<mi class="MathML-Unit"'+dL(i.id,r)+">"+dD(i.value)+"</mi>":dT(i,r);o+=l,a||/^<mo>(.*)<\/mo>$/.test(l)?n=a?"mi":"mo":(o+=dk,n="applyfunction")}"mi"!==e.lastType&&"mn"!==e.lastType||/^<mo>(.*)<\/mo>$/.test(o)||(o=dM+o),e.index+=1}return o.length>0&&(a=!0,dA(o,e,r)||(e.mathML+=o,e.lastType=n)),a}(o,a,i)||function(e,i,r){let a=!1;i=null!=i?i:e.atoms.length;let o="",n="";if(e.index<i&&"mopen"===e.atoms[e.index].type){let l=!1,s=0,c=e.index,d=-1,u=c+1;for(;u<i&&!l;)"mopen"===e.atoms[u].type?s+=1:"mclose"===e.atoms[u].type&&(s-=1),-1===s&&(l=!0,d=u),u+=1;l&&(o="<mrow>"+dT(e.atoms[c],r)+dz(e.atoms,r,c+1,d)+dT(e.atoms[d],r)+"</mrow>",e.index=d+1,("mi"===e.lastType||"mn"===e.lastType||"mfrac"===e.lastType||"fence"===e.lastType)&&(e.mathML+=dM),dA(o,e,r)&&(a=!0,e.lastType="",o=""),n="fence")}return o.length>0&&(a=!0,e.mathML+=o,e.lastType=n),a}(o,a,i))r+=1;else if(o.index<a){let e=dK(o.atoms[o.index],i);"mn"===o.lastType&&e.length>0&&"genfrac"===o.atoms[o.index].type&&(e="<mo>⁤</mo>"+e),"genfrac"===o.atoms[o.index].type?o.lastType="mfrac":o.lastType="",o.index+=1,dA(e,o,i)?r+=1:e.length>0&&(o.mathML+=e,r+=1)}r>1&&(o.mathML="<mrow>"+o.mathML+"</mrow>")}return o.mathML}function dT(e,i){let r="",a=dD(e.value);return a&&(r="<mo"+dL(e.id,i)+">"+a+"</mo>"),r}function dD(e){if(!e)return"";if("string"==typeof e)return dS(e);if(!Array.isArray(e)&&"string"==typeof e.body)return dS(e.body);let i="";for(let r of e)"string"==typeof r.value&&(i+=r.value);return dS(i)}function dK(e,i){var r,a,o,n,l,s,c,d,u,h,p,m,f,g,b,y,v,x,_,w,k,M,S;if("text"===e.mode)return`<mi${dL(e.id,i)}>${dS(e.value)}</mi>`;let L={widehat:"^",widecheck:"ˇ",widetilde:"~",utilde:"~",overleftarrow:"←",underleftarrow:"←",xleftarrow:"←",longleftarrow:"←",overrightarrow:"→",underrightarrow:"→",xrightarrow:"→",longrightarrow:"→",underbrace:"⏟",overbrace:"⏞",overgroup:"⏠",undergroup:"⏡",overleftrightarrow:"↔",underleftrightarrow:"↔",xleftrightarrow:"↔",Overrightarrow:"⇒",xRightarrow:"⇒",overleftharpoon:"↼",xleftharpoonup:"↼",overrightharpoon:"⇀",xrightharpoonup:"⇀",xLeftarrow:"⇐",xLeftrightarrow:"⇔",xhookleftarrow:"↩",xhookrightarrow:"↪",xmapsto:"↦",xrightharpoondown:"⇁",xleftharpoondown:"↽",xrightleftharpoons:"⇌",longrightleftharpoons:"⇌",xleftrightharpoons:"⇋",xtwoheadleftarrow:"↞",xtwoheadrightarrow:"↠",xlongequal:"=",xtofrom:"⇄",xleftrightarrows:"⇄",xRightleftharpoons:"⇌",longRightleftharpoons:"⇌",xLeftrightharpoons:"⇋",longLeftrightharpoons:"⇋"},C="",E="",A,z,T,D,K,B,{command:$}=e;if("\\error"===e.command)return`<merror${dL(e.id,i)}>${dz(e.body,i)}</merror>`;let P={"\\vert":"|","\\Vert":"∥","\\mid":"∣","\\lbrack":"[","\\rbrack":"]","\\{":"{","\\}":"}","\\lbrace":"{","\\rbrace":"}","\\lparen":"(","\\rparen":")","\\langle":"⟨","\\rangle":"⟩","\\lfloor":"⌊","\\rfloor":"⌋","\\lceil":"⌈","\\rceil":"⌉"};switch(e.type){case"first":case"line":case"overlap":case"subsup":case"phantom":case"composition":case"rule":case"chem":break;case"error":if("\\\\"===e.command)break;C=`<merror${dL(e.id,i)}>${dz(e.body,i)}</merror>`;break;case"group":case"root":C=dz(e.body,i);break;case"array":if((e.leftDelim&&"."!==e.leftDelim||e.rightDelim&&"."!==e.rightDelim)&&(C+="<mrow>",e.leftDelim&&"."!==e.leftDelim&&(C+=`<mo>${dS(P[e.leftDelim]||e.leftDelim)}</mo>`)),C+="<mtable",e.colFormat){for(C+=' columnalign="',T=0;T<e.colFormat.length;T++){let i=e.colFormat[T];"align"in i&&(C+=({l:"left",c:"center",r:"right"})[i.align]+" ")}C+='"'}if(e.rows.length>1&&e.hasRowRules){let i=[];for(z=1;z<e.rows.length;z++){let r=e.rowRules[z];0===r.length?i.push("none"):r.some(e=>"solid"===e.style)?i.push("solid"):i.push("dashed")}C+=` rowlines="${i.join(" ")}"`}for(C+=">",z=0;z<e.rows.length;z++){for(C+="<mtr>",A=0;A<e.rows[z].length;A++)C+="<mtd>"+dz(e.rows[z][A],i)+"</mtd>";C+="</mtr>"}C+="</mtable>",(e.leftDelim&&"."!==e.leftDelim||e.rightDelim&&"."!==e.rightDelim)&&(e.rightDelim&&"."!==e.rightDelim&&(C+=`<mo>${dS(P[e.rightDelim]||e.rightDelim)}</mo>`),C+="</mrow>");break;case"genfrac":(e.leftDelim||e.rightDelim)&&(C+="<mrow>"),e.leftDelim&&"."!==e.leftDelim&&(C+="<mo"+dL(e.id,i)+">"+dS(P[e.leftDelim]||e.leftDelim)+"</mo>"),e.hasBarLine?(C+="<mfrac>",C+=dz(e.above,i)||"<mi> </mi>",C+=dz(e.below,i)||"<mi> </mi>",C+="</mfrac>"):(C+="<mtable"+dL(e.id,i)+">",C+="<mtr>"+dz(e.above,i)+"</mtr>",C+="<mtr>"+dz(e.below,i)+"</mtr>",C+="</mtable>"),e.rightDelim&&"."!==e.rightDelim&&(C+="<mo"+dL(e.id,i)+">"+dS(P[e.rightDelim]||e.rightDelim)+"</mo>"),(e.leftDelim||e.rightDelim)&&(C+="</mrow>");break;case"surd":e.hasEmptyBranch("above")?(C+="<msqrt"+dL(e.id,i)+">",C+=dz(e.body,i),C+="</msqrt>"):(C+="<mroot"+dL(e.id,i)+">",C+=dz(e.body,i),C+=dz(e.above,i),C+="</mroot>");break;case"leftright":let O=e.leftDelim;C="<mrow>",O&&"."!==O&&(C+=`<mo${dL(e.id,i)}>${dS(null!=(r=P[O])?r:O)}</mo>`),e.body&&(C+=dz(e.body,i));let R=e.matchingRightDelim();R&&"."!==R&&(C+=`<mo${dL(e.id,i)}>${dS(null!=(a=P[R])?a:R)}</mo>`),C+="</mrow>";break;case"sizeddelim":case"delim":C+=`<mo${dL(e.id,i)}>${dS(P[e.value]||e.value)}</mo>`;break;case"accent":C+='<mover accent="true"'+dL(e.id,i)+">",C+=dz(e.body,i),C+="<mo>"+(({"\\vec":"⃗","\\acute":"´","\\grave":"`","\\dot":"˙","\\ddot":"¨","\\tilde":"~","\\bar":"¯","\\breve":"˘","\\check":"ˇ","\\hat":"^"})[$]||e.accent)+"</mo>",C+="</mover>";break;case"newline":C+='<mspace linebreak="newline"></mspace>';break;case"overunder":K=e.above,D=e.below,(e.svgAbove||K)&&(e.svgBelow||D)?B=e.body:K&&K.length>0?(B=e.body,null!=(n=null==(o=e.body)?void 0:o[0])&&n.below?(D=e.body[0].below,B=e.body[0].body):(null==(s=null==(l=e.body)?void 0:l[0])?void 0:s.type)==="first"&&null!=(d=null==(c=e.body)?void 0:c[1])&&d.below&&(D=e.body[1].below,B=e.body[1].body)):D&&D.length>0&&(B=e.body,null!=(h=null==(u=e.body)?void 0:u[0])&&h.above?(K=e.body[0].above,B=e.body[0].body):(null==(m=null==(p=e.body)?void 0:p[0])?void 0:m.type)==="first"&&null!=(g=null==(f=e.body)?void 0:f[1])&&g.above&&(K=e.body[1].above,B=e.body[1].body)),(e.svgAbove||K)&&(e.svgBelow||D)?(C+=`<munderover ${dL(e.id,i)}>`,C+=null!=(b=L[e.svgBody])?b:dz(B,i),C+=null!=(y=L[e.svgBelow])?y:dz(D,i),C+=null!=(v=L[e.svgAbove])?v:dz(K,i),C+="</munderover>"):e.svgAbove||K?(C+=`<mover ${dL(e.id,i)}>`+(null!=(x=L[e.svgBody])?x:dz(B,i)),C+=null!=(_=L[e.svgAbove])?_:dz(K,i),C+="</mover>"):(e.svgBelow||D)&&(C+=`<munder ${dL(e.id,i)}>`+(null!=(w=L[e.svgBody])?w:dz(B,i)),C+=null!=(k=L[e.svgBelow])?k:dz(D,i),C+="</munder>");break;case"placeholder":C+="?";break;case"mord":{if((C="string"==typeof e.value?e.value:$).length>0&&C.startsWith("\\"))"string"==typeof e.value&&e.value.charCodeAt(0)>255?C=String.fromCodePoint(e.value.codePointAt(0)):"string"==typeof e.value&&(C=e.value.charAt(0));else if("\\char"===e.command){let i=null==(M=e.args)?void 0:M[0];if(void 0!==i&&"number"in i){let e=i.number;"number"==typeof e&&e>=0&&e<=1114111&&(C=String.fromCodePoint(e))}}else"string"==typeof e.value?C=e.value:(console.error("Did not expect this"),C="");let r=/\d/.test(C)?"mn":"mi";C=`<${r}${dL(e.id,i)}>${dS(C)}</${r}>`;break}case"mbin":case"mrel":case"minner":C=dT(e,i);break;case"mpunct":C='<mo separator="true"'+dL(e.id,i)+">"+$+"</mo>";break;case"mop":case"operator":case"extensible-symbol":""!==e.value&&(C="<mo"+dL(e.id,i)+">"+("\\operatorname"===$?e.body:$||e.body)+"</mo>");break;case"box":C='<menclose notation="box"',e.backgroundcolor&&(C+=' mathbackground="'+e.backgroundcolor+'"'),C+=dL(e.id,i)+">"+dz(e.body,i)+"</menclose>";break;case"spacing":C+='<mspace width="'+(null!=(S=({"\\!":-3/18,"\\ ":6/18,"\\,":3/18,"\\:":4/18,"\\>":4/18,"\\;":5/18,"\\enspace":.5,"\\quad":1,"\\qquad":2,"\\enskip":.5})[$])?S:0)+'em"/>';break;case"enclose":for(let i in C='<menclose notation="',e.notation)Object.prototype.hasOwnProperty.call(e.notation,i)&&e.notation[i]&&(C+=E+i,E=" ");C+=dL(e.id,i)+'">'+dz(e.body,i)+"</menclose>";break;case"prompt":C='<menclose notation="roundexbox""">'+dz(e.body,i)+"</menclose>";break;case"space":C+=" ";break;case"mopen":case"mclose":C+=dT(e,i);break;case"macro":{let r=e.command+dD(e.macroArgs);r&&(C+=`<mo ${dL(e.id,i)}>${r}</mo>`)}break;case"latexgroup":case"tooltip":C+=dz(e.body,i);break;case"latex":C+="<mtext"+dL(e.id,i)+">"+dS(e.value)+"</mtext>";break;case"text":C+=`<mtext ${dL(e.id,i)}x>${dS(e.value)}</mtext>`;break;default:if("\\displaystyle"===e.command)return`<mrow ${dL(e.id,i)} displaystyle="true">${dz(e.body,i)}</mrow>`;if("\\textstyle"===e.command)return`<mrow ${dL(e.id,i)} displaystyle="false">${dz(e.body,i)}</mrow>`;console.info("Unexpected element in conversion to MathML:",e)}return C}var dB={"\\alpha":"alpha ","\\mu":"mew ","\\sigma":"sigma ","\\pi":"pie ","\\imaginaryI":"imaginary eye ","\\imaginaryJ":"imaginary jay ","\\sum":"Summation ","\\prod":"Product ","+":"plus ","-":"minus ",";":'<break time="150ms"/> semi-colon <break time="150ms"/>',",":'<break time="150ms"/> comma <break time="150ms"/>',"|":'<break time="150ms"/>Vertical bar<break time="150ms"/>',"(":'<break time="150ms"/>Open paren. <break time="150ms"/>',")":'<break time="150ms"/> Close paren. <break time="150ms"/>',"=":"equals ","<":"is less than ","\\lt":"is less than ","<=":"is less than or equal to ","\\le":"is less than or equal to ","\\gt":"is greater than ",">":"is greater than ","\\pm":"plus or minus","\\mp":"minus or plus","\\ge":"is greater than or equal to ","\\geq":"is greater than or equal to ","\\leq":"is less than or equal to ","\\ne":"is not equal to ","\\neq":"is not equal to ","!":"factorial ","\\sin":"sine ","\\cos":"cosine ","":"","−":"minus ",":":'<break time="150ms"/> such that <break time="200ms"/> ',"\\colon":'<break time="150ms"/> such that <break time="200ms"/> ',"\\hbar":"etch bar ","\\iff":'<break time="200ms"/>if, and only if, <break time="200ms"/>',"\\Longleftrightarrow":'<break time="200ms"/>if, and only if, <break time="200ms"/>',"\\land":"and ","\\lor":"or ","\\neg":"not ","\\div":"divided by ","\\forall":"for all ","\\exists":"there exists ","\\nexists":"there does not exists ","\\in":"element of ","\\N":'the set <break time="150ms"/><say-as interpret-as="character">n</say-as>',"\\C":'the set <break time="150ms"/><say-as interpret-as="character">c</say-as>',"\\Z":'the set <break time="150ms"/><say-as interpret-as="character">z</say-as>',"\\Q":'the set <break time="150ms"/><say-as interpret-as="character">q</say-as>',"\\infty":"infinity ","\\nabla":"nabla ","\\partial":"partial derivative of ","\\cdot":"times ","\\cdots":"dot dot dot ","\\ldots":"dot dot dot ","\\dots":"dot dot dot ","\\Rightarrow":"implies ","\\lparen":'<break time="150ms"/>open paren<break time="150ms"/>',"\\rparen":'<break time="150ms"/>close paren<break time="150ms"/>',"\\lbrace":'<break time="150ms"/>open brace<break time="150ms"/>',"\\{":'<break time="150ms"/>open brace<break time="150ms"/>',"\\rbrace":'<break time="150ms"/>close brace<break time="150ms"/>',"\\}":'<break time="150ms"/>close brace<break time="150ms"/>',"\\langle":'<break time="150ms"/>left angle bracket<break time="150ms"/>',"\\rangle":'<break time="150ms"/>right angle bracket<break time="150ms"/>',"\\lfloor":'<break time="150ms"/>open floor<break time="150ms"/>',"\\rfloor":'<break time="150ms"/>close floor<break time="150ms"/>',"\\lceil":'<break time="150ms"/>open ceiling<break time="150ms"/>',"\\rceil":'<break time="150ms"/>close ceiling<break time="150ms"/>',"\\vert":'<break time="150ms"/>vertical bar<break time="150ms"/>',"\\mvert":'<break time="150ms"/>divides<break time="150ms"/>',"\\lvert":'<break time="150ms"/>left vertical bar<break time="150ms"/>',"\\rvert":'<break time="150ms"/>right vertical bar<break time="150ms"/>',"\\lbrack":'<break time="150ms"/> open square bracket <break time="150ms"/>',"\\rbrack":'<break time="150ms"/> close square bracket <break time="150ms"/>',mm:"millimeters",cm:"centimeters",km:"kilometers",kg:"kilograms"},d$={array:"array",matrix:"matrix",pmatrix:"parenthesis matrix",bmatrix:"square brackets matrix",Bmatrix:"braces matrix",vmatrix:"bars matrix",Vmatrix:"double bars matrix","matrix*":"matrix",smallmatrix:"small matrix"};function dP(e){let i=0;if(R(e))for(let r of e)"first"!==r.type&&(i+=1);return 1===i}function dO(e){let i="";if(R(e))for(let r of e)"first"!==r.type&&"string"==typeof r.value&&(i+=r.value);return i}function dR(e){if(e&&!e.some(e=>"first"!==e.type&&void 0===e.value))return e.map(e=>e.value).join("")}function dI(e){return`<emphasis>${e}</emphasis>`}function dN(e){var i,r;let a=globalThis.MathfieldElement;if("sre"===a.textToSpeechRules&&("sre"in window||"SRE"in window)){let o=dz(e);if(o){a.textToSpeechMarkup&&(a.textToSpeechRulesOptions=null!=(i=a.textToSpeechRulesOptions)?i:{},a.textToSpeechRulesOptions=g(f({},a.textToSpeechRulesOptions),{markup:a.textToSpeechMarkup}),"ssml"===a.textToSpeechRulesOptions.markup&&(a.textToSpeechRulesOptions=g(f({},a.textToSpeechRulesOptions),{markup:"ssml_step"})),a.textToSpeechRulesOptions=g(f({},a.textToSpeechRulesOptions),{rate:a.speechEngineRate}));let e=null!=(r=window.SRE)?r:globalThis.sre.System.getInstance();a.textToSpeechRulesOptions&&e.setupEngine(a.textToSpeechRulesOptions);let n="";try{n=e.toSpeech(o)}catch(e){console.error("MathLive 0.110.9: `SRE.toSpeech()` runtime error",e)}return n}return""}let o=function e(i,r){var a,o,n,l,s,c,d,u,h,p,m;if(!r)return"";if(R(r))return function(i,r){var a;let o="",n=!1,l=!1;for(let s=0;s<r.length;s++)"first"!==r[s].type&&("text"!==r[s].mode&&(l=!1),s<r.length-2&&"mopen"===r[s].type&&"mclose"===r[s+2].type&&"mord"===r[s+1].type?(o+=" of ",o+=dI(e(i,r[s+1])),s+=2):"text"===r[s].mode?l?o+=null!=(a=r[s].value)?a:" ":(l=!0,o+=e("text",r[s])):r[s].isDigit()?n?o+=r[s].asDigit():(n=!0,o+=e(i,r[s])):(n=!1,o+=e(i,r[s])));return o}(i,r);let f="";if(r.id&&"math"===i&&(f+='<mark name="'+r.id.toString()+'"/>'),"text"===r.mode)return f+r.value;let g="",b="",y="",v=!1,{command:x}=r;switch(x){case"\\vec":return"vector "+e(i,r.body);case"\\acute":return e(i,r.body)+" acute";case"\\grave":return e(i,r.body)+" grave";case"\\dot":return"dot over"+e(i,r.body);case"\\ddot":return"double dot over"+e(i,r.body);case"\\mathring":return"ring over"+e(i,r.body);case"\\tilde":case"\\widetilde":return"tilde over"+e(i,r.body);case"\\bar":return e(i,r.body)+" bar";case"\\breve":return e(i,r.body)+" breve";case"\\check":case"\\widecheck":return"check over "+e(i,r.body);case"\\hat":case"\\widehat":return"hat over"+e(i,r.body);case"\\overarc":case"\\overparen":case"\\wideparen":return"arc over "+e(i,r.body);case"\\underarc":case"\\underparen":return"arc under "+e(i,r.body);case"\\mathop":return null!=(a=dR(r.body))?a:e(i,r.body);case"\\mathit":return null!=(o=dR(r.body))?o:e(i,r.body);case"\\mathrm":return null!=(n=dR(r.body))?n:e(i,r.body);case"\\mathbb":return"blackboard"+(null!=(l=dR(r.body))?l:e(i,r.body))}switch(r.type){case"prompt":f+=' <break time="300ms"/> '+(r.body.length>1?'start input . <break time="500ms"/> '+e(i,r.body)+'. <break time="500ms"/> end input':"blank")+'. <break time="700ms"/>'+(null!=(s=r.correctness)?s:"")+' . <break time="700ms"/> ';break;case"array":let _=r.rows,w=r.environmentName;if(Object.keys(d$).includes(w)){f+=` begin ${d$[w]} `;for(let i=0;i<_.length;i++){i>0&&(f+=","),f+=` row ${i+1} `;for(let r=0;r<_[i].length;r++)r>0&&(f+=","),f+=` column ${r+1}: `,f+=e("math",_[i][r])}f+=` end ${d$[w]} `}break;case"group":"\\ne"===x?f+=" not equal ":("\\not"===x&&(f+=" not "),f+=e("math",r.body));break;case"root":f+=e("math",r.body);break;case"genfrac":if(g=e("math",r.above),b=e("math",r.below),dP(r.above)&&dP(r.below)){let e={"1/2":" half ","1/3":" one third ","2/3":" two third","1/4":" one quarter ","3/4":" three quarter ","1/5":" one fifth ","2/5":" two fifths ","3/5":" three fifths ","4/5":" four fifths ","1/6":" one sixth ","5/6":" five sixths ","1/8":" one eight ","3/8":" three eights ","5/8":" five eights ","7/8":" seven eights ","1/9":" one ninth ","2/9":" two ninths ","4/9":" four ninths ","5/9":" five ninths ","7/9":" seven ninths ","8/9":" eight ninths "}[dO(r.above)+"/"+dO(r.below)];e?f=e:f+=g+" over "+b}else f+=' the fraction <break time="150ms"/>'+g+' over <break time="150ms"/>'+b+'.<break time="150ms"/> End fraction.<break time="150ms"/>';break;case"surd":if(y=e("math",r.body),r.hasEmptyBranch("above"))f+=dP(r.body)?" the square root of "+y+" , ":' the square root of <break time="200ms"/>'+y+'. <break time="200ms"/> End square root';else{let i=e("math",r.above),a=(i=i.trim()).replace(/<mark([^/]*)\/>/g,"");"3"===a?f+=' the cube root of <break time="200ms"/>'+y+'. <break time="200ms"/> End cube root':"n"===a?f+=' the nth root of <break time="200ms"/>'+y+'. <break time="200ms"/> End root':f+=' the root with index: <break time="200ms"/>'+i+', of <break time="200ms"/>'+y+'. <break time="200ms"/> End root'}break;case"leftright":f+=null!=(c=r.leftDelim?dB[r.leftDelim]:void 0)?c:r.leftDelim,f+=e("math",r.body),f+=null!=(d=r.rightDelim?dB[r.rightDelim]:void 0)?d:r.rightDelim;break;case"rule":case"overunder":case"overlap":case"space":case"spacing":break;case"macro":let k=x.replace(/^\\/g,""),M=e_()[k];null!=M&&M.expand?f+=e("math",r.body):f+=`${k} `;break;case"placeholder":f+="placeholder ";break;case"delim":case"sizeddelim":case"mord":case"minner":case"mbin":case"mrel":case"mpunct":case"mopen":case"mclose":{if("\\mathbin"===x||"\\mathrel"===x||"\\mathopen"===x||"\\mathclose"===x||"\\mathpunct"===x||"\\mathord"===x||"\\mathinner"===x){f=e(i,r.body);break}let a=r.isDigit()?r.asDigit():r.value,o=r.command;if(("delim"===r.type||"sizeddelim"===r.type)&&(a=o=r.value),"text"===i)f+=a;else{if("mbin"===r.type&&(f+='<break time="150ms"/>'),a){let e=dB[a]||(o?dB[o.trim()]:"");if(e)f+=" "+e;else{let e;f+=(o?(h=o.trim(),e="",h.startsWith("\\")&&(e=" "+h.replace("\\","")+" "),e):"")||(p=a,globalThis.MathfieldElement.textToSpeechMarkup?/[a-z]/.test(p)?` <say-as interpret-as="character">${p}</say-as>`:/[A-Z]/.test(p)?`capital <say-as interpret-as="character">${p.toLowerCase()}</say-as>`:p:/[a-z]/.test(p)?" '"+p.toUpperCase()+"'":/[A-Z]/.test(p)?" 'capital "+p.toUpperCase()+"'":p)}}else f+=e("math",r.body);"mbin"===r.type&&(f+='<break time="150ms"/>')}break}case"mop":case"operator":case"extensible-symbol":if(""!==r.value){let i=r.command;if("\\sum"===i)if(r.hasEmptyBranch("superscript")||r.hasEmptyBranch("subscript"))if(r.hasEmptyBranch("subscript"))f+=" the summation of";else{let i=e("math",r.subscript);f+=' the summation from <break time="200ms"/>'+(i=i.trim())+'<break time="200ms"/> of <break time="150ms"/>',v=!0}else{let i=e("math",r.superscript);i=i.trim();let a=e("math",r.subscript);f+=' the summation from <break time="200ms"/>'+(a=a.trim())+'<break time="200ms"/> to <break time="200ms"/>'+i+'<break time="200ms"/> of <break time="150ms"/>',v=!0}else if("\\prod"===i)if(r.hasEmptyBranch("superscript")||r.hasEmptyBranch("subscript"))if(r.hasEmptyBranch("subscript"))f+=" the product of ";else{let i=e("math",r.subscript);f+=' the product from <break time="200ms"/>'+(i=i.trim())+'<break time="200ms"/> of <break time="150ms"/>',v=!0}else{let i=e("math",r.superscript);i=i.trim();let a=e("math",r.subscript);f+=' the product from <break time="200ms"/>'+(a=a.trim())+'<break time="200ms"/> to <break time="200ms"/>'+i+'<break time="200ms"/> of <break time="150ms"/>',v=!0}else if("\\int"===i)if(r.hasEmptyBranch("superscript")||r.hasEmptyBranch("subscript"))f+=' the integral of <break time="200ms"/> ';else{let i=e("math",r.superscript);i=i.trim();let a=e("math",r.subscript);f+=' the integral from <break time="200ms"/>'+dI(a=a.trim())+'<break time="200ms"/> to <break time="200ms"/>'+dI(i)+' <break time="200ms"/> of ',v=!0}else"\\operatorname"===i||"\\operatorname*"===i?f+=((m=r.body)?m.map(e=>e.value).join(""):"")+" ":"string"==typeof r.value?f+=(null!=(u=dB[r.value])?u:r.command?dB[r.command]:void 0)||" "+r.value:r.command&&("\\mathop"===r.command?f+=e("math",r.body):f+=r.command.startsWith("\\")?" "+r.command.slice(1):" "+r.command)}break;case"enclose":f+=" crossed out "+(y=e("math",r.body))+". End crossed out.";break;case"newline":f+=" newline "}if(!v&&!r.hasEmptyBranch("superscript")){let a=e(i,r.superscript),o=(a=a.trim()).replace(/<[^>]*>/g,"");if(dP(r.superscript)){if("math"===i){let e=function(e){if(R(e)){for(let i of e)if("first"!==i.type&&i.id)return i.id.toString()}return""}(r.superscript);e&&(f+='<mark name="'+e+'"/>')}"′"===o?f+=" prime ":"2"===o?f+=" squared ":"3"===o?f+=" cubed ":Number.isNaN(Number.parseInt(o))?f+=" to the "+a+"; ":f+=' to the <say-as interpret-as="ordinal">'+o+"</say-as> power; "}else Number.isNaN(Number.parseInt(o))?f+=" raised to the "+a+"; ":f+=' raised to the <say-as interpret-as="ordinal">'+o+"</say-as> power; "}if(!v&&!r.hasEmptyBranch("subscript")){let i=e("math",r.subscript);i=i.trim(),f+=dP(r.subscript)?" sub "+i:" subscript "+i+". End subscript. "}return f}("math",e);if("ssml"===a.textToSpeechMarkup){let e="";a.speechEngineRate&&(e='<prosody rate="'+a.speechEngineRate+'">'),o='<?xml version="1.0"?><speak version="1.1" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-US"><amazon:auto-breaths>'+e+"<p><s>"+o+"</s></p>"+(e?"</prosody>":"")+"</amazon:auto-breaths></speak>"}else o="mac"===a.textToSpeechMarkup&&"macos"===w()?o.replace(/<mark([^/]*)\/>/g,"").replace(/<emphasis>/g,"[[emph+]]").replace(/<\/emphasis>/g,"").replace(/<break time="(\d*)ms"\/>/g,"[[slc $1]]").replace(/<say-as[^>]*>/g,"").replace(/<\/say-as>/g,""):o.replace(/<[^>]*>/g,"").replace(/\s{2,}/g," ");return o}var dq={"\\ne":"≠","\\neq":"≠","−":"-","-":"-","\\alpha":"alpha","\\beta":"beta","\\gamma":"gamma","\\delta":"delta","\\epsilon":"epsilon","\\varepsilon":"varepsilon","\\zeta":"zeta","\\eta":"eta","\\theta":"theta","\\vartheta":"vartheta","\\iota":"iota","\\kappa":"kappa","\\lambda":"lambda","\\mu":"mu","\\nu":"nu","\\xi":"xi","\\pi":"pi","\\rho":"rho","\\sigma":"sigma","\\tau":"tau","\\upsilon":"upsilon","\\phi":"phi","\\varphi":"varphi","\\chi":"chi","\\psi":"psi","\\omega":"omega","\\Gamma":"Gamma","\\Delta":"Delta","\\Theta":"Theta","\\Lambda":"Lambda","\\Xi":"Xi","\\Pi":"Pi","\\Sigma":"Sigma","\\Phi":"Phi","\\Psi":"Psi","\\Omega":"Omega","\\exponentialE":"e","\\imaginaryI":"i","\\imaginaryJ":"j","\\!":" ","\\,":" ","\\:":" ","\\>":" ","\\;":" ","\\enskip":" ","\\enspace":" ","\\qquad":" ","\\quad":" ","\\infty":"oo","\\R":"RR","\\mathbb{R}":"RR","\\N":"NN","\\mathbb{N}":"NN","\\Z":"ZZ","\\mathbb{Z}":"ZZ","\\Q":"QQ","\\mathbb{Q}":"QQ","\\C":"CC","\\mathbb{C}":"CC","\\emptyset":"O/","\\varnothing":"O/","\\varDelta":"Delta","\\varTheta":"Theta","\\varLambda":"Lambda","\\varXi":"Xi","\\varPi":"Pi","\\varSigma":"Sigma","\\varUpsilon":"Upsilon","\\varPhi":"Phi","\\varPsi":"Psi","\\varOmega":"Omega"},dF={"\\pm":"+-","\\colon":" : ","\\sum":" sum ","\\prod":" prod ","\\bigcap":" nnn ","\\bigcup":" uuu ","\\int":" int ","\\oint":" oint ","\\ge":">=","\\le":"<=","\\ne":"!=","\\neq":"!=","\\lt":"<","\\gt":">","\\gets":"<-","\\to":"->","\\land":" and ","\\lor":" or ","\\lnot":" not ","\\forall":" AA ","\\exists":" EE ","\\in":" in ","\\notin":" !in ","\\mapsto":"|->","\\implies":"=>","\\iff":"<=>","\\cdot":" * ","\\ast":" ** ","\\star":" *** ","\\times":" * ","\\div":" -: ","\\ltimes":" |>< ","\\rtimes":" ><| ","\\bowtie":" |><| ","\\circ":"@"},dV={"\\vert":"|","\\Vert":"||","\\mid":"|","\\lbrack":"[","\\rbrack":"]","\\lbrace":"{","\\rbrace":"}","\\lparen":"(","\\rparen":")","\\langle":"(:","\\rangle":":)"};function dj(e,i){var r,a,o,n,l,s,c,d,u,h,p,m,f,g,b,y,v,x,_;if(!e)return"";if(R(e)){if(0===e.length)return"";if("latex"===e[0].mode)return e.map(e=>dj(e)).join("");if("text"===e[0].mode){let a=0,o="";for(;(null==(r=e[a])?void 0:r.mode)==="text";)o+=e[a].body?dj(e[a].body,i):e[a].value,a++;return null!=i&&i.plain?o+dj(e.slice(a),i):`"${o}" ${dj(e.slice(a))}`}let n=0,l=[];for(;(null==(a=e[n])?void 0:a.mode)==="math";){let r="";for(;(null==(o=e[n])?void 0:o.type)==="mord"&&/\d/.test(e[n].value);)r+=e[n++].value;r?l.push(r):l.push(dj(e[n++],i))}return l.push(dj(e.slice(n),i)),function(e){let i="";for(let r of e){let e=i[i.length-1];void 0!==e&&(/\d$/.test(e)&&/^\d/.test(r)||/[a-zA-Z]$/.test(e)&&/^[a-zA-Z]/.test(r))&&(i+=" "),i+=r}return i}(l)}if("text"===e.mode)return null!=i&&i.plain?e.value:`"${e.value}"`;let w="",{command:k}=e,M;if("\\placeholder"===k||"\\blank"===k)return`(${dj(e.body,i)})`;let S=oG.serialize([e],{expandMacro:!1,defaultMode:"math"});switch(e.type){case"accent":let L={"\\vec":"vec","\\dot":"dot","\\ddot":"ddot","\\bar":"bar","\\hat":"hat","\\acute":"acute;","\\grave":"grave","\\tilde":"tilde","\\breve":"breave","\\check":"check"}[k];w=`${null!=L?L:""} ${dj(e.body,i)} `;break;case"first":return"";case"latexgroup":return e.body.map(e=>e.value).join("");case"group":case"root":w=null!=(n=dq[k])?n:dj(e.body,i);break;case"genfrac":(e.leftDelim||e.rightDelim)&&(w="."!==e.leftDelim&&e.leftDelim?e.leftDelim:"{:"),e.hasBarLine?(w+="(",w+=dj(e.above,i),w+=")/(",w+=dj(e.below,i),w+=")"):(w+="((",w+=dj(e.above,i),w+=") choose (",w+=dj(e.below,i),w+="))"),(e.leftDelim||e.rightDelim)&&(w+="."!==e.rightDelim&&e.rightDelim?e.rightDelim:"{:");break;case"surd":e.hasEmptyBranch("above")?w+=`sqrt(${dj(e.body,i)})`:w+=`root(${dj(e.above,i)})(${dj(e.body,i)})`;break;case"latex":case"sizeddelim":case"delim":case"mopen":case"mclose":w=e.value;break;case"leftright":{let r=e.leftDelim;r&&dV[r]&&(r=dV[r]),w+="."!==r&&r?r:"{:",w+=dj(e.body,i);let a=e.matchingRightDelim();a&&dV[a]&&(a=dV[a]),w+="."!==a&&a?a:":}"}break;case"overlap":case"overunder":case"box":break;case"mord":if(dq[S])return dq[S];(w=null!=(c=null!=(s=null!=(l=dq[k])?l:k)?s:k)?c:"string"==typeof e.value?e.value:"").startsWith("\\")&&(w+=" "),(M=k?k.match(/{?\\char"([\dabcdefABCDEF]+)}?/):null)?w=String.fromCodePoint(Number.parseInt("0x"+M[1])):w.length>0&&w.startsWith("\\")&&(w="string"==typeof e.value?e.value.charAt(0):e.command),w=function(e,i){if(!i)return e;let r=e;return"double-struck"===i.variant&&(r=`bbb "${r}"`),"script"===i.variant&&(r=`cc "${r}"`),"fraktur"===i.variant&&(r=`fr "${r}"`),"sans-serif"===i.variant&&(r=`sf "${r}"`),"monospace"===i.variant&&(r=`tt "${r}"`),"bold"===i.variantStyle&&(r=`bb "${r}"`),i.color?`color({${i.color}})(${r})`:r}(w,e.style);break;case"mbin":case"mrel":case"minner":w=null!=(h=null!=(u=null!=(d=dq[S])?d:dq[k])?u:dF[k])?h:e.value;break;case"mpunct":w=null!=(p=dF[k])?p:k;break;case"mop":case"operator":case"extensible-symbol":""!==e.value&&(w=(dF[k]?dF[k]:"\\operatorname"===k?dj(e.body,i):null!=(m=e.value)?m:k)+" ");break;case"array":let C=e.environmentName;if(e.isMultiline)w=e.rows.map(e=>e.map(e=>dj(e,i)).join("")).join(`
|
|
3480
|
-
`);else{let r=null!=(f=({bmatrix:["[","]"],"bmatrix*":["[","]"]})[C])?f:["(",")"],a=[];for(let o of e.rows){let e=[];for(let r of o)e.push(
|
|
3481
|
-
`;break;case"enclose":w="("+
|
|
3478
|
+
</div>`,u&&s.appendChild(p),s.querySelectorAll("[data-command]").forEach(i=>{let r=i.dataset.command,a=r;try{a=JSON.parse(r)}catch(e){}i.addEventListener("mousedown",e=>e.preventDefault()),a&&i.addEventListener("click",()=>e.executeCommand(a))});let m=null==(r=e.field)?void 0:r.getBoundingClientRect();m&&(l.style.top=`${window.scrollY+(m.top-l.clientHeight-15)}px`,l.style.left=`${m.left+20}px`,l.classList.add("is-visible"))}(e):dt()}function dr(e){let i=getComputedStyle(e).direction;return"ltr"===i||"rtl"===i?i:"ltr"}function da(e,i,r){return"left"===i||"leading"===i&&"ltr"===r||"trailing"===i&&"rtl"===r?e.left:e.right}function dn(e,i,r,a){return"middle"===r?e-i/2:"start"===r&&"rtl"===a||"end"===r&&"ltr"===a||"top"===r||"right"===r?Math.max(0,e-i):e}function dl(e){return"submenu"in e}function ds(e){return"type"in e&&"command"===e.type||"onMenuSelect"in e||"id"in e}function dc(e){return"type"in e&&"divider"===e.type}function dd(e){return"type"in e&&"heading"===e.type}var du={};function dh(e){let i=du[e];if(!i){let r;switch(e){case"checkmark":r=`<span aria-hidden="true" class="ui-checkmark"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"></path></svg>
|
|
3479
|
+
</span>`;break;case"trailing-chevron":r='<span aria-hidden="true" class="ui-trailing-chevron"><svg focusable="false" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path fill="currentColor" d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"></path></svg></span>';break;case"mixedmark":r='<span aria-hidden="true" class="ui-mixedmark"><svg xmlns="http://www.w3.org/2000/svg" width="16" viewBox="0 0 512 512"><path fill="currentColor" d="M0 256c0-13.3 10.7-24 24-24H488c13.3 0 24 10.7 24 24s-10.7 24-24 24H24c-13.3 0-24-10.7-24-24z"/></svg></span>'}if(r){let a=document.createElement("template");a.innerHTML=r,du[e]=a,i=a}}if(i){if("content"in i)return i.content.cloneNode(!0);let e=document.createElement("svg");return e.innerHTML=i.innerHTML,e}}var dp=class{constructor(e,i){var r;this._className="",this._element=null,this.parentMenu=i,this._declaration=e,Object.freeze(this._declaration),dl(e)?(this.type="submenu",this.submenu=new df(e.submenu,{parentMenu:i,submenuClass:e.submenuClass,columnCount:e.columnCount})):this.type=null!=(r=e.type)?r:"command",this.hasCheck=ds(e)&&void 0!==e.checked}get rootMenu(){return this.parentMenu.rootMenu}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}dispose(){var e,i;null==(e=this._abortController)||e.abort(),this._abortController=void 0,null==(i=this._element)||i.remove(),this._element=null,this.submenu&&this.submenu.dispose(),this.submenu=void 0}get menuItem(){return this._declaration}get label(){var e;return null!=(e=this._label)?e:""}set label(e){void 0===e&&(e=""),e!==this._label&&(this._label=e,this.dirty=!0)}get visible(){return this._visible}set visible(e){e!==this._visible&&(this._visible=e,this.dirty=!0)}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this.element&&(e?this.element.removeAttribute("aria-disabled"):this.element.setAttribute("aria-disabled","true")),this.dirty=!0}get checked(){return this._checked}set checked(e){this._checked=e,this.dirty=!0}get tooltip(){return this._tooltip}set tooltip(e){e!==this._tooltip&&(this._tooltip=e,this.dirty=!0)}get ariaLabel(){return this._ariaLabel}set ariaLabel(e){e!==this._ariaLabel&&(this._ariaLabel=e,this.dirty=!0)}get active(){var e,i;return null!=(i=null==(e=this.element)?void 0:e.classList.contains("active"))&&i}set active(e){this.element&&this.element.classList.toggle("active",e)}updateState(e){var i,r,a;let o=this._declaration;if(dc(o)){this.enabled=!1,this.checked=!1;return}dd(o)&&(this.enabled=!1,this.checked=!1,this.visible=!0),ds(o)&&(this.checked=null!=(i=dm(o.checked,e))&&i),(ds(o)||dl(o))&&(this.enabled=null==(r=dm(o.enabled,e))||r,this.visible=null==(a=dm(o.visible,e))||a,this.visible&&this.enabled&&this.submenu&&(this.submenu.updateState(e),this.submenu.visible||(this.visible=!1))),(ds(o)||dd(o)||dl(o))&&(this.label=dm(o.label,e),this._className=dm(o.class,e),this.tooltip=dm(o.tooltip,e),this.ariaLabel=dm(o.ariaLabel,e)),this._element&&this.updateElement()}set dirty(e){e&&this.parentMenu&&(this.parentMenu.dirty=!0)}updateElement(){var e;if(!this.visible||!this.element)return;let i=this.element;i.textContent="",i.className="",i.className=null!=(e=this._className)?e:"",this.enabled?i.removeAttribute("aria-disabled"):i.setAttribute("aria-disabled","true"),!0===this.checked?(i.setAttribute("aria-checked","true"),i.append(dh("checkmark"))):"mixed"===this.checked?(i.setAttribute("aria-checked","mixed"),i.append(dh("mixedmark"))):i.removeAttribute("aria-checked"),this.ariaLabel&&i.setAttribute("aria-label",this.ariaLabel);let r=document.createElement("span");if(r.className=this.parentMenu.hasCheck?"label indent":"label","heading"===this.type&&r.classList.add("heading"),r.innerHTML=this.label,i.append(r),this._tooltip&&i.setAttribute("data-tooltip",this._tooltip),ds(this._declaration)&&this._declaration.keyboardShortcut){let e=document.createElement("kbd");e.innerHTML=l6(this._declaration.keyboardShortcut),i.append(e)}"submenu"===this.type&&i.append(dh("trailing-chevron"))}get element(){if(this._element)return this._element;if(dc(this._declaration)){let e=document.createElement("li");return e.setAttribute("part","menu-divider"),e.setAttribute("role","divider"),this._element=e,e}let e=document.createElement("li");this._element=e,(ds(this._declaration)||dd(this._declaration)||dl(this._declaration))&&e.setAttribute("part","menu-item"),e.setAttribute("tabindex","-1"),this.hasCheck?e.setAttribute("role","menuitemcheckbox"):e.setAttribute("role","menuitem"),"submenu"===this.type&&(e.setAttribute("aria-haspopup","true"),e.setAttribute("aria-expanded","false"));let i=this.abortController.signal;return e.addEventListener("pointerenter",this,{signal:i}),e.addEventListener("pointerleave",this,{signal:i}),e.addEventListener("pointerup",this,{signal:i}),e.addEventListener("click",this,{signal:i}),this._element}dispatchSelect(){var e;if(!ds(this._declaration))return;let i=new CustomEvent("menu-select",{cancelable:!0,bubbles:!0,detail:{modifiers:this.rootMenu.modifiers,id:this._declaration.id,data:this._declaration.data}});this.parentMenu.dispatchEvent(i)&&"function"==typeof this._declaration.onMenuSelect&&this._declaration.onMenuSelect({target:null!=(e=this.parentMenu.host)?e:void 0,modifiers:this.rootMenu.modifiers,id:this._declaration.id,data:this._declaration.data})}handleEvent(e){var i;if(!(!this.visible||!this.enabled)){if("click"===e.type){"modal"===this.rootMenu.state&&this.select(),e.stopPropagation(),e.preventDefault();return}if("pointerenter"===e.type){this.rootMenu.cancelDelayedOperation(),this.parentMenu.isSubmenuOpen&&null!=(i=this.parentMenu.activeMenuItem)&&i.movingTowardSubmenu(e)?this.rootMenu.scheduleOperation(()=>{this.parentMenu.activeMenuItem=this,this.openSubmenu()}):(this.parentMenu.activeMenuItem=this,this.openSubmenu({withDelay:!0}));return}if("pointerleave"===e.type){this.rootMenu.activeSubmenu===this.parentMenu&&(this.parentMenu.activeMenuItem=null);return}if("pointerup"===e.type){"modal"!==this.rootMenu.state&&this.select(),e.stopPropagation(),e.preventDefault();return}}}select(){(this.rootMenu.cancelDelayedOperation(),"submenu"===this.type)?this.openSubmenu():(this.active=!1,setTimeout(()=>{this.active=!0,setTimeout(()=>{this.active=!1,this.rootMenu.hide(),this.dispatchSelect()},80)},80))}openSubmenu(e){var i;if("submenu"!==this.type||!this.element)return;if(null!=(i=null==e?void 0:e.withDelay)&&i)return void this.rootMenu.scheduleOperation(()=>this.openSubmenu());let r=this.element.getBoundingClientRect(),a=dr(this.element);this.submenu.show({container:this.rootMenu.element.parentNode,location:{x:da(r,"trailing",a),y:r.top-4},alternateLocation:{x:da(r,"leading",a),y:r.top-4}})}movingTowardSubmenu(e){var i,r;if(!this.element||"submenu"!==this.type)return!1;let a=this.rootMenu.lastMoveEvent;if(!a)return!1;let o=e.timeStamp-a.timeStamp;if(o>500)return!1;let n=e.clientX-a.clientX;if(.2>=(i=n,r=a.clientY-e.clientY,Math.hypot(i,r)/o))return!1;let l="right";if(this.submenu.element){let e=this.submenu.element.getBoundingClientRect(),i=this.element.getBoundingClientRect();e.left<i.left+i.width/2&&(l="left")}return"right"===l?n>0:n<0}};function dm(e,i){return void 0===e||"function"!=typeof e?e:(null!=i||(i={alt:!1,control:!1,shift:!1,meta:!1}),e(i))}var df=class e{constructor(e,i){var r,a;this._element=null,this._activeMenuItem=null,this._dirty=!0,this.parentMenu=null!=(r=null==i?void 0:i.parentMenu)?r:null,this._submenuClass=null==i?void 0:i.submenuClass,this.columnCount=null!=(a=null==i?void 0:i.columnCount)?a:1,this.isSubmenuOpen=!1,this.menuItems=e}get children(){return Object.freeze([...this._menuItems])}set menuItems(e){let i=this.parentMenu;this.dispose(),this.parentMenu=i,e=[...e],this._menuItems=e.map(e=>e.onCreate?e.onCreate(e,this):new dp(e,this)),this.hasCheck=void 0,this.dirty=!0}dispose(){var e;this.hide(),this._element&&this._element.remove(),this._abortController&&this._abortController.abort(),null==(e=this._menuItems)||e.forEach(e=>e.dispose()),this._menuItems=[],this._activeMenuItem=null,this.parentMenu=null}handleEvent(e){"wheel"===e.type&&this._element&&(this._element.scrollBy(0,e.deltaY),e.stopPropagation())}dispatchEvent(e){return this.rootMenu.dispatchEvent(e)}get host(){return this.rootMenu.host}get rootMenu(){return this.parentMenu.rootMenu}updateState(e){var i,r,a;this._menuItems.forEach(i=>i.updateState(e));let o=this.hasCheck;this.hasCheck=this._menuItems.some(e=>e.visible&&e.hasCheck),this.hasCheck!==o&&this._menuItems.forEach(i=>i.updateState(e));let n,l=0;for(let e of this._menuItems)"heading"===e.type?(n&&0===l&&(n.visible=!1),n=e,l=0):"divider"===e.type&&n?(n.visible=l>0,n=void 0,l=0):n&&e.visible&&(l+=1);n&&(n.visible=l>0);let s=!0;for(let e of this._menuItems)"divider"===e.type?(e.visible=!s,s=!0):e.visible&&(s=!1);null!=(i=this.activeMenuItem)&&i.visible||(this.activeMenuItem=null),null!=(r=this.activeMenuItem)&&r.enabled||(null==(a=this.activeMenuItem)?void 0:a.type)!=="submenu"||this._activeMenuItem.submenu.hide(),this._dirty=!1}get enabled(){return this.updateIfDirty(),this._menuItems.some(e=>"divider"!==e.type&&e.visible&&e.enabled)}get visible(){return this.updateIfDirty(),this._menuItems.some(e=>"divider"!==e.type&&e.visible)}set dirty(e){this._dirty!==e&&e&&this.parentMenu&&(this._dirty=!0,this.parentMenu.dirty=!0)}updateIfDirty(){this._dirty&&this.updateState(this.rootMenu.modifiers)}updateElement(){var e;if(this._element){for(let{element:e,visible:i}of(this._element.textContent="",this._menuItems))e&&i&&this._element.append(e);null==(e=this._element.querySelector("li:first-of-type"))||e.setAttribute("tabindex","0")}}get element(){if(this._element)return this._element;let e=document.createElement("menu");e.setAttribute("role","menu"),e.setAttribute("tabindex","-1"),e.setAttribute("aria-orientation","vertical"),e.setAttribute("part","ui-menu-container"),this._submenuClass&&e.classList.add(this._submenuClass),e.classList.add("ui-menu-container"),this._abortController||(this._abortController=new AbortController);let i=this._abortController.signal;return e.addEventListener("focus",this,{signal:i}),e.addEventListener("wheel",this,{passive:!0,signal:i}),this._element=e,this.updateElement(),e}get activeMenuItem(){return this._activeMenuItem}set activeMenuItem(e){var i,r,a,o;if(this.rootMenu.cancelDelayedOperation(),e!==this._activeMenuItem){if(this.activeMenuItem){let e=this.activeMenuItem;e.active=!1,null==(i=e.submenu)||i.hide()}if(!(null==(r=null==e?void 0:e.visible)||r)){this._activeMenuItem=null;return}this._activeMenuItem=e,e&&(e.active=!0)}e?null==(a=e.element)||a.focus({preventScroll:!0}):null==(o=this._element)||o.focus({preventScroll:!0})}get firstMenuItem(){this.updateIfDirty();let e=0,i=!1,r=this._menuItems;for(;!i&&e<=r.length-1;){let a=r[e];i="divider"!==a.type&&a.visible&&a.enabled,e+=1}return i?r[e-1]:null}get lastMenuItem(){this.updateIfDirty();let e=this._menuItems,i=e.length-1,r=!1;for(;!r&&i>=0;){let a=e[i];r="divider"!==a.type&&a.visible&&a.enabled,i-=1}return r?e[i+1]:null}nextMenuItem(e){if(0===e)return this._activeMenuItem;if(!this._activeMenuItem)return e>0?this.firstMenuItem:this.lastMenuItem;if(!this.firstMenuItem||!this.lastMenuItem||!this._activeMenuItem)return null;this.updateIfDirty();let i=this._menuItems.indexOf(this.firstMenuItem),r=this._menuItems.indexOf(this.lastMenuItem),a=this._menuItems.indexOf(this._activeMenuItem),o=1;for(;a>=i&&a<=r;){a+=e>0?1:-1;let i=this._menuItems[a];if(!i)break;if(i.visible&&i.enabled){if(o===Math.abs(e))return this._menuItems[a];o+=1}}return e>0?this.lastMenuItem:this.firstMenuItem}getMenuItemColumn(e){this.updateIfDirty();let i=this._menuItems.filter(e=>e.visible&&e.enabled).indexOf(e);return i<0?-1:i%this.columnCount}static get collator(){return e._collator||(e._collator=new Intl.Collator(void 0,{usage:"search",sensitivity:"base"})),e._collator}findMenuItem(i){var r;this.updateIfDirty();let a=this._menuItems.filter(e=>"divider"!==e.type&&e.visible&&e.enabled);if(0===a.length)return null;let o=Math.max(...a.map(e=>e.label.length))-i.length;if(o<0)return null;let n=null,l=0;for(;l<o&&!n;)n=null!=(r=a.find(r=>0===e.collator.compare(i,r.label.substring(l,i.length))))?r:null,l++;return n}show(e){var i,r,a,o,n,l,s,c;let d,u,h,p,m,f;return!!this.visible&&!!e.container&&(this.updateElement(),e.container.appendChild(this.element),k()&&(this.element.popover="manual",this.element.showPopover()),e.location&&(i=this.element,r={location:e.location,alternateLocation:e.alternateLocation,verticalPos:"bottom",horizontalPos:"start"},d=null!=(a=dr(i))?a:"ltr",i.style.position="fixed",i.style.left="",i.style.top="",i.style.right="",i.style.bottom="",i.style.height="",i.style.width="",u=i.getBoundingClientRect(),h=Math.min(Number.isFinite(r.maxHeight)?Math.min(r.maxHeight,window.innerHeight):window.innerHeight,null!=(o=r.height)?o:u.height),(p=dn(r.location.y,h,r.verticalPos,d))+h>window.innerHeight-8&&(r.alternateLocation?(p=dn(r.alternateLocation.y,h,r.verticalPos,d))+h>window.innerHeight-8&&(p=void 0):p=void 0),Number.isFinite(p)||(p=Math.max(8,window.innerHeight-8-h),8+h>window.innerHeight-8&&(i.style.bottom="8px")),h=Math.min(p+h,window.innerHeight-8)-p,m=Math.min(Number.isFinite(r.maxWidth)?Math.min(r.maxWidth,window.innerWidth):window.innerWidth,null!=(n=r.width)?n:u.width),(f=dn(r.location.x,m,r.horizontalPos,d))+m>window.innerWidth-8&&(r.alternateLocation?(l=r.alternateLocation.x,s=m,c=r.verticalPos,(f="middle"===c?l-s/2:"start"===c&&"ltr"===d||"end"===c&&"rtl"===d||"top"===c||"right"===c?l:l-s)+m>window.innerWidth-8&&(f=void 0)):f=void 0),Number.isFinite(f)||(f=Math.max(8,window.innerWidth-8-m),8+m>window.innerWidth-8&&(i.style.right="8px")),m=Math.min(f+m,window.innerWidth-8)-f,"rtl"===d?i.style.right=`${Math.ceil(window.innerWidth-f-m).toString()}px`:i.style.left=`${Math.ceil(f).toString()}px`,i.style.top=`${Math.ceil(p).toString()}px`,h!==u.height&&(i.style.height=`${Math.ceil(h).toString()}px`),m!==u.width&&(i.style.width=`${Math.ceil(m).toString()}px`)),dg(),this.element.focus({preventScroll:!0}),dy(),this.parentMenu&&(this.parentMenu.openSubmenu=this),!0)}hide(){var e,i,r,a,o,n;this.openSubmenu=null,this.activeMenuItem=null,this.parentMenu&&(this.parentMenu.openSubmenu=null),null!=(e=this._element)&&e.isConnected&&this._element.parentElement&&(k()&&null!=(i=this._element)&&i.popover&&this._element.hidePopover(),dg(),null==(a=null==(r=this.parentMenu)?void 0:r.element)||a.focus(),null==(n=null==(o=this._element)?void 0:o.parentNode)||n.removeChild(this._element),dy())}set openSubmenu(e){var i,r,a,o;let n=null!==e;(null==(i=this.activeMenuItem)?void 0:i.type)==="submenu"&&(null==(r=this.activeMenuItem.element)||r.setAttribute("aria-expanded",n.toString())),null==(o=null==(a=this.activeMenuItem)?void 0:a.element)||o.classList.toggle("is-submenu-open",n),this.isSubmenuOpen=n}};function dg(){document.addEventListener("focusin",db,!0),document.addEventListener("focusout",db,!0),document.addEventListener("focus",db,!0),document.addEventListener("blur",db,!0)}function db(e){e.stopImmediatePropagation(),e.preventDefault()}function dy(){document.removeEventListener("focusin",db,!0),document.removeEventListener("focusout",db,!0),document.removeEventListener("focus",db,!0),document.removeEventListener("blur",db,!0)}var dv=class e extends df{constructor(e,i){var r;super(e),this.state="closed",this.typingBufferResetTimer=0,this.hysteresisTimer=0,this._updating=!1,this._host=null!=(r=null==i?void 0:i.host)?r:null,this.isDynamic=e.some(dx),this._modifiers={shift:!1,control:!1,alt:!1,meta:!1},this.typingBuffer="",this.state="closed"}get modifiers(){return this._modifiers}set modifiers(e){var i;i=this._modifiers,(!i&&e||i&&!e||i&&e&&(i.alt!==e.alt||i.control!==e.control||i.shift!==e.shift||i.meta!==e.meta))&&(this._modifiers=e,this.dirty=!0)}get activeSubmenu(){let e=this;for(;e.isSubmenuOpen;)e=e.activeMenuItem.submenu;return e}set dirty(e){this._updating||this._dirty!==e&&(this._dirty=!0,e&&setTimeout(()=>{this.updateState(this.modifiers),this.updateElement()}))}updateState(e){this._updating=!0,this.modifiers=null!=e?e:this.modifiers,super.updateState(this.modifiers),this._updating=!1}handleKeyupEvent(e){this.isDynamic&&(this.modifiers=l5(e)),e.stopImmediatePropagation()}handleKeydownEvent(e){var i,r,a;if("Tab"===e.key||"Escape"===e.key)return void this.hide();this.isDynamic&&(this.modifiers=l5(e));let o=!0,n=this.activeSubmenu,l=n.activeMenuItem;switch(e.key){case" ":case"Space":case"Return":case"Enter":null==l||l.select(l5(e));break;case"ArrowRight":if((null==l?void 0:l.type)==="submenu")l.select(l5(e)),this.activeSubmenu.activeMenuItem=this.activeSubmenu.firstMenuItem;else if(l){let e=null!=(i=n.getMenuItemColumn(l))?i:-1;if(e>=0&&e<(null!=(r=n.columnCount)?r:1)-1){let e=n.nextMenuItem(1);e&&(n.activeMenuItem=e)}}else n.activeMenuItem=n.firstMenuItem;break;case"ArrowLeft":if(n===this.rootMenu)l||(n.activeMenuItem=n.firstMenuItem);else if((l&&null!=(a=n.getMenuItemColumn(l))?a:-1)<=0||!l){n.hide();let e=n.parentMenu.activeMenuItem;if(e){let{element:i}=e;null==i||i.focus(),null==i||i.classList.remove("is-submenu-open")}}else{let e=n.nextMenuItem(-1);e&&(n.activeMenuItem=e)}break;case"ArrowDown":n.activeMenuItem=n.nextMenuItem(n.columnCount);break;case"ArrowUp":n.activeMenuItem=n.nextMenuItem(-n.columnCount);break;case"Home":case"PageUp":n.activeMenuItem=n.firstMenuItem;break;case"End":case"PageDown":n.activeMenuItem=n.lastMenuItem;break;case"Backspace":if(this.typingBuffer&&(this.typingBuffer=this.typingBuffer.slice(0,-1),this.typingBuffer)){clearTimeout(this.typingBufferResetTimer);let e=n.findMenuItem(this.typingBuffer);e&&(n.activeMenuItem=e),this.typingBufferResetTimer=setTimeout(()=>{this.typingBuffer=""},500)}break;default:if(l9(e)){isFinite(this.typingBufferResetTimer)&&clearTimeout(this.typingBufferResetTimer),this.typingBuffer+=e.key;let i=n.findMenuItem(this.typingBuffer);i&&(n.activeMenuItem=i),this.typingBufferResetTimer=setTimeout(()=>{this.typingBuffer=""},500)}else o=!1}o&&(e.preventDefault(),e.stopPropagation())}handleEvent(e){if("keydown"===e.type)this.handleKeydownEvent(e);else if("keyup"===e.type)this.handleKeyupEvent(e);else if("pointermove"===e.type)this.lastMoveEvent=e;else if("pointerup"===e.type)Number.isFinite(this.rootMenu._openTimestamp)&&Date.now()-this.rootMenu._openTimestamp<120?this.state="modal":"modal"===this.state&&e.target===this.scrim&&this.hide();else if("contextmenu"===e.type){e.preventDefault(),e.stopPropagation();return}super.handleEvent(e)}dispatchEvent(e){return!this._host||this._host.dispatchEvent(e)}get host(){return this._host}get scrim(){return st.element}connectScrim(e){let i=this.scrim;i.addEventListener("pointerup",this,!0),i.addEventListener("contextmenu",this),i.addEventListener("keydown",this),i.addEventListener("keyup",this),i.addEventListener("pointermove",this),st.open({root:e,onDismiss:()=>this.hide()})}disconnectScrim(){let e=this.scrim;e.removeEventListener("pointerup",this,!0),e.removeEventListener("contextmenu",this),e.removeEventListener("keydown",this),e.removeEventListener("keyup",this),e.removeEventListener("pointermove",this),"open"===st.state&&st.scrim.close()}get rootMenu(){return this}show(e){return this._onDismiss=null==e?void 0:e.onDismiss,null!=e&&e.modifiers&&(this.modifiers=e.modifiers),this.updateState(),this.connectScrim(null==e?void 0:e.target),super.show(g(f({},e),{container:this.scrim}))?(this._openTimestamp=Date.now(),this.state="open",!0):(this.disconnectScrim(),!1)}hide(){this.cancelDelayedOperation(),void 0!==this.state&&("closed"!==this.state&&(this.activeMenuItem=null,st.element.parentElement.focus(),super.hide(),this.state="closed",this.disconnectScrim()),this._onDismiss&&(this._onDismiss(),this._onDismiss=void 0))}scheduleOperation(i){this.cancelDelayedOperation();let r=e.SUBMENU_DELAY;r<=0?i():this.hysteresisTimer=setTimeout(()=>{this.hysteresisTimer=0,i()},r)}cancelDelayedOperation(){this.hysteresisTimer&&(clearTimeout(this.hysteresisTimer),this.hysteresisTimer=0)}};function dx(e){return!dc(e)&&(!!("function"==typeof e.label||"function"==typeof e.ariaLabel||"function"==typeof e.tooltip||(ds(e)||dl(e))&&("function"==typeof e.enabled||"function"==typeof e.visible)||ds(e)&&"function"==typeof e.checked)||!!dl(e)&&e.submenu.some(dx))}dv.SUBMENU_DELAY=120;var d_=class{};async function dw(e,i,r){if(e.defaultPrevented)return!1;if("contextmenu"===e.type&&(e.preventDefault(),e.stopPropagation(),r.show({target:i,location:l8(e),modifiers:l5(e)})))return!0;if("keydown"===e.type&&("ContextMenu"===e.code||"F10"===e.code&&e.shiftKey)){let a=null==i?void 0:i.getBoundingClientRect();if(dk(i)&&a&&r.show({target:i,location:{x:Math.ceil(a.left+a.width/2),y:Math.ceil(a.top+a.height/2)},modifiers:l5(e)}))return e.preventDefault(),e.stopPropagation(),!0}if("pointerdown"===e.type&&"mouse"!==e.pointerType&&0===e.button){let a=e.target;for(;a&&i!==a;)a=a.parentNode;if(!a||!r.visible)return!1;let o=l8(e);if(await new Promise((i,r)=>{let a=l8(e);a||i(!1);let o=a,n=setTimeout(()=>{var e;l.abort(),i((e=o,Math.hypot(a.x-e.x,a.y-e.y)<d_.MAX_DISTANCE))},d_.DELAY),l=new AbortController,s=l.signal;for(let e of["pointermove","pointerup","pointercancel"])window.addEventListener(e,e=>{if("pointerup"===e.type||"pointercancel"===e.type)clearTimeout(n),l.abort(),i(!1);else if("pointermove"===e.type){let i=l8(e);i&&(o=i)}},{passive:!0,signal:s})}))return"closed"===r.state&&!!dk(i)&&(r.show({target:i,location:o}),!0)}return!1}function dk(e){return e.dispatchEvent(new Event("contextmenu",{cancelable:!0}))}d_.DELAY=300,d_.MAX_DISTANCE=10;var dM="<mo>⁡</mo>",dS="<mo>⁢</mo>";function dL(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function dC(e,i){return e&&i.generateID?` extid="${e}"`:""}function dE(e){return e.index<e.atoms.length&&e.atoms[e.index].superscript&&"subsup"===e.atoms[e.index].type}function dA(e){let i=-1,r=e.index,a=!1,o=!1;for(;r<e.atoms.length&&!a&&!o;){let i=e.atoms[r];o=!(a=!i.isDigit())&&void 0!==i.superscript,r++}return o&&(i=r-1),i}function dz(e,i,r){var a;let o=i.atoms[i.index-1];if(!o)return!1;if(!o.superscript&&!o.subscript)if((null==(a=i.atoms[i.index])?void 0:a.type)!=="subsup")return!1;else o=i.atoms[i.index],i.index+=1;let n=i.lastType;i.lastType="";let l=dT(o.superscript,r);i.lastType="";let s=dT(o.subscript,r);if(i.lastType=n,!l&&!s)return!1;let c="";return l&&s?c=`<msubsup>${e}${s}${l}</msubsup>`:l?c=`<msup>${e}${l}</msup>`:s&&(c=`<msub>${e}${s}</msub>`),i.mathML+=c,i.lastType="",!0}function dT(e,i,r,a){null!=i||(i={});let o={atoms:[],index:null!=r?r:0,mathML:"",lastType:""};if("number"==typeof e||"boolean"==typeof e)o.mathML=e.toString();else if("string"==typeof e)o.mathML=e;else if(e instanceof oG)o.mathML=dB(e,i);else if(Array.isArray(e)){o.atoms=e;let r=0;for(a=a||(e?e.length:0);o.index<a;)if(function(e,i,r){i=null!=i?i:e.atoms.length;let a=e.index,o="",n=dA(e);for(n>=0&&n<i&&(i=n);e.index<i&&"text"===e.atoms[e.index].mode;)o+=e.atoms[e.index].value?e.atoms[e.index].value:" ",e.index+=1;return o.length>0&&(o=`<mtext ${dC(e.atoms[a].id,r)}>${dL(o)}</mtext>`,n<0&&dE(e)&&(n=e.index,e.index+=1),dz(o,e,r)||(e.mathML+=o,e.lastType="mtext"),!0)}(o,a,i)||function(e,i,r){i=null!=i?i:e.atoms.length;let a=e.index,o="",n=dA(e);for(n>=0&&n<i&&(i=n);e.index<i&&e.atoms[e.index].isDigit();)o+=e.atoms[e.index].asDigit(),e.index+=1;return!(o.length<=0)&&(o="<mn"+dC(e.atoms[a].id,r)+">"+o+"</mn>",n<0&&dE(e)&&(n=e.index,e.index+=1),dz(o,e,r)||(e.mathML+=o,e.lastType="mn"),!0)}(o,a,i)||function(e,i,r){var a,o,n,l,s,c,d,u;let h=!1;i=null!=i?i:e.atoms.length;let p="",m="",f=e.atoms[e.index],g=null==(a=f.style)?void 0:a.variant,b=null==(o=f.style)?void 0:o.variantStyle,y="";if(f.value&&(g||b)){let i=null!=(n=ee(f.value,g,b))?n:f.value;if(i!==f.value)return e.index+=1,dz(p=`<mi${dC(f.id,r)}>${i}</mi>`,e,r)||(e.mathML+=p,e.lastType="mi"),!0;(y=null!=(l=({upnormal:"normal",boldnormal:"bold",italicmain:"italic",bolditalicmain:"bold-italic","updouble-struck":"double-struck","double-struck":"double-struck",boldfraktur:"bold-fraktur",calligraphic:"script",upcalligraphic:"script",script:"script",boldscript:"bold-script",boldcalligraphic:"bold-script",fraktur:"fraktur","upsans-serif":"sans-serif","boldsans-serif":"bold-sans-serif","italicsans-serif":"sans-serif-italic","bolditalicsans-serif":"sans-serif-bold-italic",monospace:"monospace"})[(null!=b?b:"")+(null!=g?g:"")])?l:"")&&(y=` mathvariant="${y}"`)}let v={"\\exponentialE":"ⅇ","\\imaginaryI":"ⅈ","\\differentialD":"ⅆ","\\capitalDifferentialD":"ⅅ","\\alpha":"α","\\pi":"π","\\infty":"∞","\\forall":"∀","\\nexists":"∄","\\exists":"∃","\\hbar":"ℏ","\\cdotp":"⋅","\\ldots":"…","\\dots":"…","\\cdots":"⋯","\\ddots":"⋱","\\vdots":"⋮","\\ldotp":"."};if("!"===f.command)return e.index+=1,dz(p="<mo>!</mo>",e,r)||(e.mathML+=p,e.lastType="mo"),!0;if(v[f.command]){e.index+=1;let i=`<mi${dC(f.id,r)}${y}>${v[f.command]}</mi>`;return("mi"===e.lastType||"mn"===e.lastType||"mtext"===e.lastType||"fence"===e.lastType)&&(i=dS+i),dz(i,e,r)||(e.mathML+=i,e.lastType="mi"),!0}if("\\operatorname"===f.command)m=dK(f.body),e.index+=1;else if(g||b)for(;e.index<i&&("mord"===f.type||"macro"===f.type)&&!f.isDigit()&&g===(null!=(c=null==(s=f.style)?void 0:s.variant)?c:"")&&b===(null!=(u=null==(d=f.style)?void 0:d.variantStyle)?u:"");)m+=dK([f]),e.index+=1,f=e.atoms[e.index];else"mord"!==f.type&&"macro"!==f.type||f.isDigit()||(m+=dK([f]),e.index+=1);if(m.length>0){h=!0,p=`<mi${y}>${m}</mi>`;let i=e.lastType;p.endsWith(">f</mi>")||p.endsWith(">g</mi>")?(p+=dM,e.lastType="applyfunction"):e.lastType=/^<mo>(.*)<\/mo>$/.test(p)?"mo":"mi",dz(p,e,r)||(("mi"===i||"mn"===i||"mtext"===i||"fence"===i)&&(p=dS+p),e.mathML+=p)}return h}(o,a,i)||function(e,i,r){let a=!1;i=null!=i?i:e.atoms.length;let o="",n="",l=e.atoms[e.index];if(!l)return!1;let s={"\\ne":"≠","\\neq":"≠","\\pm":"±","\\times":"×","\\colon":":","\\vert":"|","\\Vert":"∥","\\mid":"∣","\\{":"{","\\}":"}","\\lbrace":"{","\\rbrace":"}","\\lbrack":"[","\\rbrack":"]","\\lparen":"(","\\rparen":")","\\langle":"⟨","\\rangle":"⟩","\\lfloor":"⌊","\\rfloor":"⌋","\\lceil":"⌈","\\rceil":"⌉"};if(s[l.command]){e.index+=1;let i=`<mo${dC(l.id,r)}>${s[l.command]}</mo>`;return dz(i,e,r)||(e.mathML+=i,e.lastType="mo"),!0}if(e.index<i&&("mbin"===l.type||"mrel"===l.type))o+=dB(e.atoms[e.index],r),e.index+=1,n="mo";else if(e.index<i&&("mop"===l.type||"operator"===l.type||"extensible-symbol"===l.type)){if("over-under"===l.subsupPlacement&&(l.superscript||l.subscript)){let i=dD(l,r);return l.superscript&&l.subscript?(o+="<munderover>"+i,o+=dT(l.subscript,r),o+=dT(l.superscript,r),o+="</munderover>"):l.superscript?(o+="<mover>"+i,o+=dT(l.superscript,r),o+="</mover>"):l.subscript&&(o+="<munder>"+i,o+=dT(l.subscript,r),o+="</munder>"),e.mathML+=o,e.lastType="mo",e.index+=1,!0}{let i=e.atoms[e.index],a="\\operatorname"===i.value,l=a?'<mi class="MathML-Unit"'+dC(i.id,r)+">"+dK(i.value)+"</mi>":dD(i,r);o+=l,a||/^<mo>(.*)<\/mo>$/.test(l)?n=a?"mi":"mo":(o+=dM,n="applyfunction")}"mi"!==e.lastType&&"mn"!==e.lastType||/^<mo>(.*)<\/mo>$/.test(o)||(o=dS+o),e.index+=1}return o.length>0&&(a=!0,dz(o,e,r)||(e.mathML+=o,e.lastType=n)),a}(o,a,i)||function(e,i,r){let a=!1;i=null!=i?i:e.atoms.length;let o="",n="";if(e.index<i&&"mopen"===e.atoms[e.index].type){let l=!1,s=0,c=e.index,d=-1,u=c+1;for(;u<i&&!l;)"mopen"===e.atoms[u].type?s+=1:"mclose"===e.atoms[u].type&&(s-=1),-1===s&&(l=!0,d=u),u+=1;l&&(o="<mrow>"+dD(e.atoms[c],r)+dT(e.atoms,r,c+1,d)+dD(e.atoms[d],r)+"</mrow>",e.index=d+1,("mi"===e.lastType||"mn"===e.lastType||"mfrac"===e.lastType||"fence"===e.lastType)&&(e.mathML+=dS),dz(o,e,r)&&(a=!0,e.lastType="",o=""),n="fence")}return o.length>0&&(a=!0,e.mathML+=o,e.lastType=n),a}(o,a,i))r+=1;else if(o.index<a){let e=dB(o.atoms[o.index],i);"mn"===o.lastType&&e.length>0&&"genfrac"===o.atoms[o.index].type&&(e="<mo>⁤</mo>"+e),"genfrac"===o.atoms[o.index].type?o.lastType="mfrac":o.lastType="",o.index+=1,dz(e,o,i)?r+=1:e.length>0&&(o.mathML+=e,r+=1)}r>1&&(o.mathML="<mrow>"+o.mathML+"</mrow>")}return o.mathML}function dD(e,i){let r="",a=dK(e.value);return a&&(r="<mo"+dC(e.id,i)+">"+a+"</mo>"),r}function dK(e){if(!e)return"";if("string"==typeof e)return dL(e);if(!Array.isArray(e)&&"string"==typeof e.body)return dL(e.body);let i="";for(let r of e)"string"==typeof r.value&&(i+=r.value);return dL(i)}function dB(e,i){var r,a,o,n,l,s,c,d,u,h,p,m,f,g,b,y,v,x,_,w,k,M,S;if("text"===e.mode)return`<mi${dC(e.id,i)}>${dL(e.value)}</mi>`;let L={widehat:"^",widecheck:"ˇ",widetilde:"~",utilde:"~",overleftarrow:"←",underleftarrow:"←",xleftarrow:"←",longleftarrow:"←",overrightarrow:"→",underrightarrow:"→",xrightarrow:"→",longrightarrow:"→",underbrace:"⏟",overbrace:"⏞",overgroup:"⏠",undergroup:"⏡",overleftrightarrow:"↔",underleftrightarrow:"↔",xleftrightarrow:"↔",Overrightarrow:"⇒",xRightarrow:"⇒",overleftharpoon:"↼",xleftharpoonup:"↼",overrightharpoon:"⇀",xrightharpoonup:"⇀",xLeftarrow:"⇐",xLeftrightarrow:"⇔",xhookleftarrow:"↩",xhookrightarrow:"↪",xmapsto:"↦",xrightharpoondown:"⇁",xleftharpoondown:"↽",xrightleftharpoons:"⇌",longrightleftharpoons:"⇌",xleftrightharpoons:"⇋",xtwoheadleftarrow:"↞",xtwoheadrightarrow:"↠",xlongequal:"=",xtofrom:"⇄",xleftrightarrows:"⇄",xRightleftharpoons:"⇌",longRightleftharpoons:"⇌",xLeftrightharpoons:"⇋",longLeftrightharpoons:"⇋"},C="",E="",A,z,T,D,K,B,{command:$}=e;if("\\error"===e.command)return`<merror${dC(e.id,i)}>${dT(e.body,i)}</merror>`;let P={"\\vert":"|","\\Vert":"∥","\\mid":"∣","\\lbrack":"[","\\rbrack":"]","\\{":"{","\\}":"}","\\lbrace":"{","\\rbrace":"}","\\lparen":"(","\\rparen":")","\\langle":"⟨","\\rangle":"⟩","\\lfloor":"⌊","\\rfloor":"⌋","\\lceil":"⌈","\\rceil":"⌉"};switch(e.type){case"first":case"line":case"overlap":case"subsup":case"phantom":case"composition":case"rule":case"chem":break;case"error":if("\\\\"===e.command)break;C=`<merror${dC(e.id,i)}>${dT(e.body,i)}</merror>`;break;case"group":case"root":C=dT(e.body,i);break;case"array":if((e.leftDelim&&"."!==e.leftDelim||e.rightDelim&&"."!==e.rightDelim)&&(C+="<mrow>",e.leftDelim&&"."!==e.leftDelim&&(C+=`<mo>${dL(P[e.leftDelim]||e.leftDelim)}</mo>`)),C+="<mtable",e.colFormat){for(C+=' columnalign="',T=0;T<e.colFormat.length;T++){let i=e.colFormat[T];"align"in i&&(C+=({l:"left",c:"center",r:"right"})[i.align]+" ")}C+='"'}if(e.rows.length>1&&e.hasRowRules){let i=[];for(z=1;z<e.rows.length;z++){let r=e.rowRules[z];0===r.length?i.push("none"):r.some(e=>"solid"===e.style)?i.push("solid"):i.push("dashed")}C+=` rowlines="${i.join(" ")}"`}for(C+=">",z=0;z<e.rows.length;z++){for(C+="<mtr>",A=0;A<e.rows[z].length;A++)C+="<mtd>"+dT(e.rows[z][A],i)+"</mtd>";C+="</mtr>"}C+="</mtable>",(e.leftDelim&&"."!==e.leftDelim||e.rightDelim&&"."!==e.rightDelim)&&(e.rightDelim&&"."!==e.rightDelim&&(C+=`<mo>${dL(P[e.rightDelim]||e.rightDelim)}</mo>`),C+="</mrow>");break;case"genfrac":(e.leftDelim||e.rightDelim)&&(C+="<mrow>"),e.leftDelim&&"."!==e.leftDelim&&(C+="<mo"+dC(e.id,i)+">"+dL(P[e.leftDelim]||e.leftDelim)+"</mo>"),e.hasBarLine?(C+="<mfrac>",C+=dT(e.above,i)||"<mi> </mi>",C+=dT(e.below,i)||"<mi> </mi>",C+="</mfrac>"):(C+="<mtable"+dC(e.id,i)+">",C+="<mtr>"+dT(e.above,i)+"</mtr>",C+="<mtr>"+dT(e.below,i)+"</mtr>",C+="</mtable>"),e.rightDelim&&"."!==e.rightDelim&&(C+="<mo"+dC(e.id,i)+">"+dL(P[e.rightDelim]||e.rightDelim)+"</mo>"),(e.leftDelim||e.rightDelim)&&(C+="</mrow>");break;case"surd":e.hasEmptyBranch("above")?(C+="<msqrt"+dC(e.id,i)+">",C+=dT(e.body,i),C+="</msqrt>"):(C+="<mroot"+dC(e.id,i)+">",C+=dT(e.body,i),C+=dT(e.above,i),C+="</mroot>");break;case"leftright":let O=e.leftDelim;C="<mrow>",O&&"."!==O&&(C+=`<mo${dC(e.id,i)}>${dL(null!=(r=P[O])?r:O)}</mo>`),e.body&&(C+=dT(e.body,i));let R=e.matchingRightDelim();R&&"."!==R&&(C+=`<mo${dC(e.id,i)}>${dL(null!=(a=P[R])?a:R)}</mo>`),C+="</mrow>";break;case"sizeddelim":case"delim":C+=`<mo${dC(e.id,i)}>${dL(P[e.value]||e.value)}</mo>`;break;case"accent":C+='<mover accent="true"'+dC(e.id,i)+">",C+=dT(e.body,i),C+="<mo>"+(({"\\vec":"⃗","\\acute":"´","\\grave":"`","\\dot":"˙","\\ddot":"¨","\\tilde":"~","\\bar":"¯","\\breve":"˘","\\check":"ˇ","\\hat":"^"})[$]||e.accent)+"</mo>",C+="</mover>";break;case"newline":C+='<mspace linebreak="newline"></mspace>';break;case"overunder":K=e.above,D=e.below,(e.svgAbove||K)&&(e.svgBelow||D)?B=e.body:K&&K.length>0?(B=e.body,null!=(n=null==(o=e.body)?void 0:o[0])&&n.below?(D=e.body[0].below,B=e.body[0].body):(null==(s=null==(l=e.body)?void 0:l[0])?void 0:s.type)==="first"&&null!=(d=null==(c=e.body)?void 0:c[1])&&d.below&&(D=e.body[1].below,B=e.body[1].body)):D&&D.length>0&&(B=e.body,null!=(h=null==(u=e.body)?void 0:u[0])&&h.above?(K=e.body[0].above,B=e.body[0].body):(null==(m=null==(p=e.body)?void 0:p[0])?void 0:m.type)==="first"&&null!=(g=null==(f=e.body)?void 0:f[1])&&g.above&&(K=e.body[1].above,B=e.body[1].body)),(e.svgAbove||K)&&(e.svgBelow||D)?(C+=`<munderover ${dC(e.id,i)}>`,C+=null!=(b=L[e.svgBody])?b:dT(B,i),C+=null!=(y=L[e.svgBelow])?y:dT(D,i),C+=null!=(v=L[e.svgAbove])?v:dT(K,i),C+="</munderover>"):e.svgAbove||K?(C+=`<mover ${dC(e.id,i)}>`+(null!=(x=L[e.svgBody])?x:dT(B,i)),C+=null!=(_=L[e.svgAbove])?_:dT(K,i),C+="</mover>"):(e.svgBelow||D)&&(C+=`<munder ${dC(e.id,i)}>`+(null!=(w=L[e.svgBody])?w:dT(B,i)),C+=null!=(k=L[e.svgBelow])?k:dT(D,i),C+="</munder>");break;case"placeholder":C+="?";break;case"mord":{if((C="string"==typeof e.value?e.value:$).length>0&&C.startsWith("\\"))"string"==typeof e.value&&e.value.charCodeAt(0)>255?C=String.fromCodePoint(e.value.codePointAt(0)):"string"==typeof e.value&&(C=e.value.charAt(0));else if("\\char"===e.command){let i=null==(M=e.args)?void 0:M[0];if(void 0!==i&&"number"in i){let e=i.number;"number"==typeof e&&e>=0&&e<=1114111&&(C=String.fromCodePoint(e))}}else"string"==typeof e.value?C=e.value:(console.error("Did not expect this"),C="");let r=/\d/.test(C)?"mn":"mi";C=`<${r}${dC(e.id,i)}>${dL(C)}</${r}>`;break}case"mbin":case"mrel":case"minner":C=dD(e,i);break;case"mpunct":C='<mo separator="true"'+dC(e.id,i)+">"+$+"</mo>";break;case"mop":case"operator":case"extensible-symbol":""!==e.value&&(C="<mo"+dC(e.id,i)+">"+("\\operatorname"===$?e.body:$||e.body)+"</mo>");break;case"box":C='<menclose notation="box"',e.backgroundcolor&&(C+=' mathbackground="'+e.backgroundcolor+'"'),C+=dC(e.id,i)+">"+dT(e.body,i)+"</menclose>";break;case"spacing":C+='<mspace width="'+(null!=(S=({"\\!":-3/18,"\\ ":6/18,"\\,":3/18,"\\:":4/18,"\\>":4/18,"\\;":5/18,"\\enspace":.5,"\\quad":1,"\\qquad":2,"\\enskip":.5})[$])?S:0)+'em"/>';break;case"enclose":for(let i in C='<menclose notation="',e.notation)Object.prototype.hasOwnProperty.call(e.notation,i)&&e.notation[i]&&(C+=E+i,E=" ");C+=dC(e.id,i)+'">'+dT(e.body,i)+"</menclose>";break;case"prompt":C='<menclose notation="roundexbox""">'+dT(e.body,i)+"</menclose>";break;case"space":C+=" ";break;case"mopen":case"mclose":C+=dD(e,i);break;case"macro":{let r=e.command+dK(e.macroArgs);r&&(C+=`<mo ${dC(e.id,i)}>${r}</mo>`)}break;case"latexgroup":case"tooltip":C+=dT(e.body,i);break;case"latex":C+="<mtext"+dC(e.id,i)+">"+dL(e.value)+"</mtext>";break;case"text":C+=`<mtext ${dC(e.id,i)}x>${dL(e.value)}</mtext>`;break;default:if("\\displaystyle"===e.command)return`<mrow ${dC(e.id,i)} displaystyle="true">${dT(e.body,i)}</mrow>`;if("\\textstyle"===e.command)return`<mrow ${dC(e.id,i)} displaystyle="false">${dT(e.body,i)}</mrow>`;console.info("Unexpected element in conversion to MathML:",e)}return C}var d$={"\\alpha":"alpha ","\\mu":"mew ","\\sigma":"sigma ","\\pi":"pie ","\\imaginaryI":"imaginary eye ","\\imaginaryJ":"imaginary jay ","\\sum":"Summation ","\\prod":"Product ","+":"plus ","-":"minus ",";":'<break time="150ms"/> semi-colon <break time="150ms"/>',",":'<break time="150ms"/> comma <break time="150ms"/>',"|":'<break time="150ms"/>Vertical bar<break time="150ms"/>',"(":'<break time="150ms"/>Open paren. <break time="150ms"/>',")":'<break time="150ms"/> Close paren. <break time="150ms"/>',"=":"equals ","<":"is less than ","\\lt":"is less than ","<=":"is less than or equal to ","\\le":"is less than or equal to ","\\gt":"is greater than ",">":"is greater than ","\\pm":"plus or minus","\\mp":"minus or plus","\\ge":"is greater than or equal to ","\\geq":"is greater than or equal to ","\\leq":"is less than or equal to ","\\ne":"is not equal to ","\\neq":"is not equal to ","!":"factorial ","\\sin":"sine ","\\cos":"cosine ","":"","−":"minus ",":":'<break time="150ms"/> such that <break time="200ms"/> ',"\\colon":'<break time="150ms"/> such that <break time="200ms"/> ',"\\hbar":"etch bar ","\\iff":'<break time="200ms"/>if, and only if, <break time="200ms"/>',"\\Longleftrightarrow":'<break time="200ms"/>if, and only if, <break time="200ms"/>',"\\land":"and ","\\lor":"or ","\\neg":"not ","\\div":"divided by ","\\forall":"for all ","\\exists":"there exists ","\\nexists":"there does not exists ","\\in":"element of ","\\N":'the set <break time="150ms"/><say-as interpret-as="character">n</say-as>',"\\C":'the set <break time="150ms"/><say-as interpret-as="character">c</say-as>',"\\Z":'the set <break time="150ms"/><say-as interpret-as="character">z</say-as>',"\\Q":'the set <break time="150ms"/><say-as interpret-as="character">q</say-as>',"\\infty":"infinity ","\\nabla":"nabla ","\\partial":"partial derivative of ","\\cdot":"times ","\\cdots":"dot dot dot ","\\ldots":"dot dot dot ","\\dots":"dot dot dot ","\\Rightarrow":"implies ","\\lparen":'<break time="150ms"/>open paren<break time="150ms"/>',"\\rparen":'<break time="150ms"/>close paren<break time="150ms"/>',"\\lbrace":'<break time="150ms"/>open brace<break time="150ms"/>',"\\{":'<break time="150ms"/>open brace<break time="150ms"/>',"\\rbrace":'<break time="150ms"/>close brace<break time="150ms"/>',"\\}":'<break time="150ms"/>close brace<break time="150ms"/>',"\\langle":'<break time="150ms"/>left angle bracket<break time="150ms"/>',"\\rangle":'<break time="150ms"/>right angle bracket<break time="150ms"/>',"\\lfloor":'<break time="150ms"/>open floor<break time="150ms"/>',"\\rfloor":'<break time="150ms"/>close floor<break time="150ms"/>',"\\lceil":'<break time="150ms"/>open ceiling<break time="150ms"/>',"\\rceil":'<break time="150ms"/>close ceiling<break time="150ms"/>',"\\vert":'<break time="150ms"/>vertical bar<break time="150ms"/>',"\\mvert":'<break time="150ms"/>divides<break time="150ms"/>',"\\lvert":'<break time="150ms"/>left vertical bar<break time="150ms"/>',"\\rvert":'<break time="150ms"/>right vertical bar<break time="150ms"/>',"\\lbrack":'<break time="150ms"/> open square bracket <break time="150ms"/>',"\\rbrack":'<break time="150ms"/> close square bracket <break time="150ms"/>',mm:"millimeters",cm:"centimeters",km:"kilometers",kg:"kilograms"},dP={array:"array",matrix:"matrix",pmatrix:"parenthesis matrix",bmatrix:"square brackets matrix",Bmatrix:"braces matrix",vmatrix:"bars matrix",Vmatrix:"double bars matrix","matrix*":"matrix",smallmatrix:"small matrix"};function dO(e){let i=0;if(R(e))for(let r of e)"first"!==r.type&&(i+=1);return 1===i}function dR(e){let i="";if(R(e))for(let r of e)"first"!==r.type&&"string"==typeof r.value&&(i+=r.value);return i}function dI(e){if(e&&!e.some(e=>"first"!==e.type&&void 0===e.value))return e.map(e=>e.value).join("")}function dN(e){return`<emphasis>${e}</emphasis>`}function dq(e){var i,r;let a=globalThis.MathfieldElement;if("sre"===a.textToSpeechRules&&("sre"in window||"SRE"in window)){let o=dT(e);if(o){a.textToSpeechMarkup&&(a.textToSpeechRulesOptions=null!=(i=a.textToSpeechRulesOptions)?i:{},a.textToSpeechRulesOptions=g(f({},a.textToSpeechRulesOptions),{markup:a.textToSpeechMarkup}),"ssml"===a.textToSpeechRulesOptions.markup&&(a.textToSpeechRulesOptions=g(f({},a.textToSpeechRulesOptions),{markup:"ssml_step"})),a.textToSpeechRulesOptions=g(f({},a.textToSpeechRulesOptions),{rate:a.speechEngineRate}));let e=null!=(r=window.SRE)?r:globalThis.sre.System.getInstance();a.textToSpeechRulesOptions&&e.setupEngine(a.textToSpeechRulesOptions);let n="";try{n=e.toSpeech(o)}catch(e){console.error("MathLive 0.110.10: `SRE.toSpeech()` runtime error",e)}return n}return""}let o=function e(i,r){var a,o,n,l,s,c,d,u,h,p,m;if(!r)return"";if(R(r))return function(i,r){var a;let o="",n=!1,l=!1;for(let s=0;s<r.length;s++)"first"!==r[s].type&&("text"!==r[s].mode&&(l=!1),s<r.length-2&&"mopen"===r[s].type&&"mclose"===r[s+2].type&&"mord"===r[s+1].type?(o+=" of ",o+=dN(e(i,r[s+1])),s+=2):"text"===r[s].mode?l?o+=null!=(a=r[s].value)?a:" ":(l=!0,o+=e("text",r[s])):r[s].isDigit()?n?o+=r[s].asDigit():(n=!0,o+=e(i,r[s])):(n=!1,o+=e(i,r[s])));return o}(i,r);let f="";if(r.id&&"math"===i&&(f+='<mark name="'+r.id.toString()+'"/>'),"text"===r.mode)return f+r.value;let g="",b="",y="",v=!1,{command:x}=r;switch(x){case"\\vec":return"vector "+e(i,r.body);case"\\acute":return e(i,r.body)+" acute";case"\\grave":return e(i,r.body)+" grave";case"\\dot":return"dot over"+e(i,r.body);case"\\ddot":return"double dot over"+e(i,r.body);case"\\mathring":return"ring over"+e(i,r.body);case"\\tilde":case"\\widetilde":return"tilde over"+e(i,r.body);case"\\bar":return e(i,r.body)+" bar";case"\\breve":return e(i,r.body)+" breve";case"\\check":case"\\widecheck":return"check over "+e(i,r.body);case"\\hat":case"\\widehat":return"hat over"+e(i,r.body);case"\\overarc":case"\\overparen":case"\\wideparen":return"arc over "+e(i,r.body);case"\\underarc":case"\\underparen":return"arc under "+e(i,r.body);case"\\mathop":return null!=(a=dI(r.body))?a:e(i,r.body);case"\\mathit":return null!=(o=dI(r.body))?o:e(i,r.body);case"\\mathrm":return null!=(n=dI(r.body))?n:e(i,r.body);case"\\mathbb":return"blackboard"+(null!=(l=dI(r.body))?l:e(i,r.body))}switch(r.type){case"prompt":f+=' <break time="300ms"/> '+(r.body.length>1?'start input . <break time="500ms"/> '+e(i,r.body)+'. <break time="500ms"/> end input':"blank")+'. <break time="700ms"/>'+(null!=(s=r.correctness)?s:"")+' . <break time="700ms"/> ';break;case"array":let _=r.rows,w=r.environmentName;if(Object.keys(dP).includes(w)){f+=` begin ${dP[w]} `;for(let i=0;i<_.length;i++){i>0&&(f+=","),f+=` row ${i+1} `;for(let r=0;r<_[i].length;r++)r>0&&(f+=","),f+=` column ${r+1}: `,f+=e("math",_[i][r])}f+=` end ${dP[w]} `}break;case"group":"\\ne"===x?f+=" not equal ":("\\not"===x&&(f+=" not "),f+=e("math",r.body));break;case"root":f+=e("math",r.body);break;case"genfrac":if(g=e("math",r.above),b=e("math",r.below),dO(r.above)&&dO(r.below)){let e={"1/2":" half ","1/3":" one third ","2/3":" two third","1/4":" one quarter ","3/4":" three quarter ","1/5":" one fifth ","2/5":" two fifths ","3/5":" three fifths ","4/5":" four fifths ","1/6":" one sixth ","5/6":" five sixths ","1/8":" one eight ","3/8":" three eights ","5/8":" five eights ","7/8":" seven eights ","1/9":" one ninth ","2/9":" two ninths ","4/9":" four ninths ","5/9":" five ninths ","7/9":" seven ninths ","8/9":" eight ninths "}[dR(r.above)+"/"+dR(r.below)];e?f=e:f+=g+" over "+b}else f+=' the fraction <break time="150ms"/>'+g+' over <break time="150ms"/>'+b+'.<break time="150ms"/> End fraction.<break time="150ms"/>';break;case"surd":if(y=e("math",r.body),r.hasEmptyBranch("above"))f+=dO(r.body)?" the square root of "+y+" , ":' the square root of <break time="200ms"/>'+y+'. <break time="200ms"/> End square root';else{let i=e("math",r.above),a=(i=i.trim()).replace(/<mark([^/]*)\/>/g,"");"3"===a?f+=' the cube root of <break time="200ms"/>'+y+'. <break time="200ms"/> End cube root':"n"===a?f+=' the nth root of <break time="200ms"/>'+y+'. <break time="200ms"/> End root':f+=' the root with index: <break time="200ms"/>'+i+', of <break time="200ms"/>'+y+'. <break time="200ms"/> End root'}break;case"leftright":f+=null!=(c=r.leftDelim?d$[r.leftDelim]:void 0)?c:r.leftDelim,f+=e("math",r.body),f+=null!=(d=r.rightDelim?d$[r.rightDelim]:void 0)?d:r.rightDelim;break;case"rule":case"overunder":case"overlap":case"space":case"spacing":break;case"macro":let k=x.replace(/^\\/g,""),M=e_()[k];null!=M&&M.expand?f+=e("math",r.body):f+=`${k} `;break;case"placeholder":f+="placeholder ";break;case"delim":case"sizeddelim":case"mord":case"minner":case"mbin":case"mrel":case"mpunct":case"mopen":case"mclose":{if("\\mathbin"===x||"\\mathrel"===x||"\\mathopen"===x||"\\mathclose"===x||"\\mathpunct"===x||"\\mathord"===x||"\\mathinner"===x){f=e(i,r.body);break}let a=r.isDigit()?r.asDigit():r.value,o=r.command;if(("delim"===r.type||"sizeddelim"===r.type)&&(a=o=r.value),"text"===i)f+=a;else{if("mbin"===r.type&&(f+='<break time="150ms"/>'),a){let e=d$[a]||(o?d$[o.trim()]:"");if(e)f+=" "+e;else{let e;f+=(o?(h=o.trim(),e="",h.startsWith("\\")&&(e=" "+h.replace("\\","")+" "),e):"")||(p=a,globalThis.MathfieldElement.textToSpeechMarkup?/[a-z]/.test(p)?` <say-as interpret-as="character">${p}</say-as>`:/[A-Z]/.test(p)?`capital <say-as interpret-as="character">${p.toLowerCase()}</say-as>`:p:/[a-z]/.test(p)?" '"+p.toUpperCase()+"'":/[A-Z]/.test(p)?" 'capital "+p.toUpperCase()+"'":p)}}else f+=e("math",r.body);"mbin"===r.type&&(f+='<break time="150ms"/>')}break}case"mop":case"operator":case"extensible-symbol":if(""!==r.value){let i=r.command;if("\\sum"===i)if(r.hasEmptyBranch("superscript")||r.hasEmptyBranch("subscript"))if(r.hasEmptyBranch("subscript"))f+=" the summation of";else{let i=e("math",r.subscript);f+=' the summation from <break time="200ms"/>'+(i=i.trim())+'<break time="200ms"/> of <break time="150ms"/>',v=!0}else{let i=e("math",r.superscript);i=i.trim();let a=e("math",r.subscript);f+=' the summation from <break time="200ms"/>'+(a=a.trim())+'<break time="200ms"/> to <break time="200ms"/>'+i+'<break time="200ms"/> of <break time="150ms"/>',v=!0}else if("\\prod"===i)if(r.hasEmptyBranch("superscript")||r.hasEmptyBranch("subscript"))if(r.hasEmptyBranch("subscript"))f+=" the product of ";else{let i=e("math",r.subscript);f+=' the product from <break time="200ms"/>'+(i=i.trim())+'<break time="200ms"/> of <break time="150ms"/>',v=!0}else{let i=e("math",r.superscript);i=i.trim();let a=e("math",r.subscript);f+=' the product from <break time="200ms"/>'+(a=a.trim())+'<break time="200ms"/> to <break time="200ms"/>'+i+'<break time="200ms"/> of <break time="150ms"/>',v=!0}else if("\\int"===i)if(r.hasEmptyBranch("superscript")||r.hasEmptyBranch("subscript"))f+=' the integral of <break time="200ms"/> ';else{let i=e("math",r.superscript);i=i.trim();let a=e("math",r.subscript);f+=' the integral from <break time="200ms"/>'+dN(a=a.trim())+'<break time="200ms"/> to <break time="200ms"/>'+dN(i)+' <break time="200ms"/> of ',v=!0}else"\\operatorname"===i||"\\operatorname*"===i?f+=((m=r.body)?m.map(e=>e.value).join(""):"")+" ":"string"==typeof r.value?f+=(null!=(u=d$[r.value])?u:r.command?d$[r.command]:void 0)||" "+r.value:r.command&&("\\mathop"===r.command?f+=e("math",r.body):f+=r.command.startsWith("\\")?" "+r.command.slice(1):" "+r.command)}break;case"enclose":f+=" crossed out "+(y=e("math",r.body))+". End crossed out.";break;case"newline":f+=" newline "}if(!v&&!r.hasEmptyBranch("superscript")){let a=e(i,r.superscript),o=(a=a.trim()).replace(/<[^>]*>/g,"");if(dO(r.superscript)){if("math"===i){let e=function(e){if(R(e)){for(let i of e)if("first"!==i.type&&i.id)return i.id.toString()}return""}(r.superscript);e&&(f+='<mark name="'+e+'"/>')}"′"===o?f+=" prime ":"2"===o?f+=" squared ":"3"===o?f+=" cubed ":Number.isNaN(Number.parseInt(o))?f+=" to the "+a+"; ":f+=' to the <say-as interpret-as="ordinal">'+o+"</say-as> power; "}else Number.isNaN(Number.parseInt(o))?f+=" raised to the "+a+"; ":f+=' raised to the <say-as interpret-as="ordinal">'+o+"</say-as> power; "}if(!v&&!r.hasEmptyBranch("subscript")){let i=e("math",r.subscript);i=i.trim(),f+=dO(r.subscript)?" sub "+i:" subscript "+i+". End subscript. "}return f}("math",e);if("ssml"===a.textToSpeechMarkup){let e="";a.speechEngineRate&&(e='<prosody rate="'+a.speechEngineRate+'">'),o='<?xml version="1.0"?><speak version="1.1" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-US"><amazon:auto-breaths>'+e+"<p><s>"+o+"</s></p>"+(e?"</prosody>":"")+"</amazon:auto-breaths></speak>"}else o="mac"===a.textToSpeechMarkup&&"macos"===w()?o.replace(/<mark([^/]*)\/>/g,"").replace(/<emphasis>/g,"[[emph+]]").replace(/<\/emphasis>/g,"").replace(/<break time="(\d*)ms"\/>/g,"[[slc $1]]").replace(/<say-as[^>]*>/g,"").replace(/<\/say-as>/g,""):o.replace(/<[^>]*>/g,"").replace(/\s{2,}/g," ");return o}var dF={"\\ne":"≠","\\neq":"≠","−":"-","-":"-","\\alpha":"alpha","\\beta":"beta","\\gamma":"gamma","\\delta":"delta","\\epsilon":"epsilon","\\varepsilon":"varepsilon","\\zeta":"zeta","\\eta":"eta","\\theta":"theta","\\vartheta":"vartheta","\\iota":"iota","\\kappa":"kappa","\\lambda":"lambda","\\mu":"mu","\\nu":"nu","\\xi":"xi","\\pi":"pi","\\rho":"rho","\\sigma":"sigma","\\tau":"tau","\\upsilon":"upsilon","\\phi":"phi","\\varphi":"varphi","\\chi":"chi","\\psi":"psi","\\omega":"omega","\\Gamma":"Gamma","\\Delta":"Delta","\\Theta":"Theta","\\Lambda":"Lambda","\\Xi":"Xi","\\Pi":"Pi","\\Sigma":"Sigma","\\Phi":"Phi","\\Psi":"Psi","\\Omega":"Omega","\\exponentialE":"e","\\imaginaryI":"i","\\imaginaryJ":"j","\\!":" ","\\,":" ","\\:":" ","\\>":" ","\\;":" ","\\enskip":" ","\\enspace":" ","\\qquad":" ","\\quad":" ","\\infty":"oo","\\R":"RR","\\mathbb{R}":"RR","\\N":"NN","\\mathbb{N}":"NN","\\Z":"ZZ","\\mathbb{Z}":"ZZ","\\Q":"QQ","\\mathbb{Q}":"QQ","\\C":"CC","\\mathbb{C}":"CC","\\emptyset":"O/","\\varnothing":"O/","\\varDelta":"Delta","\\varTheta":"Theta","\\varLambda":"Lambda","\\varXi":"Xi","\\varPi":"Pi","\\varSigma":"Sigma","\\varUpsilon":"Upsilon","\\varPhi":"Phi","\\varPsi":"Psi","\\varOmega":"Omega"},dV={"\\pm":"+-","\\colon":" : ","\\sum":" sum ","\\prod":" prod ","\\bigcap":" nnn ","\\bigcup":" uuu ","\\int":" int ","\\oint":" oint ","\\ge":">=","\\le":"<=","\\ne":"!=","\\neq":"!=","\\lt":"<","\\gt":">","\\gets":"<-","\\to":"->","\\land":" and ","\\lor":" or ","\\lnot":" not ","\\forall":" AA ","\\exists":" EE ","\\in":" in ","\\notin":" !in ","\\mapsto":"|->","\\implies":"=>","\\iff":"<=>","\\cdot":" * ","\\ast":" ** ","\\star":" *** ","\\times":" * ","\\div":" -: ","\\ltimes":" |>< ","\\rtimes":" ><| ","\\bowtie":" |><| ","\\circ":"@"},dj={"\\vert":"|","\\Vert":"||","\\mid":"|","\\lbrack":"[","\\rbrack":"]","\\lbrace":"{","\\rbrace":"}","\\lparen":"(","\\rparen":")","\\langle":"(:","\\rangle":":)"};function dH(e,i){var r,a,o,n,l,s,c,d,u,h,p,m,f,g,b,y,v,x,_;if(!e)return"";if(R(e)){if(0===e.length)return"";if("latex"===e[0].mode)return e.map(e=>dH(e)).join("");if("text"===e[0].mode){let a=0,o="";for(;(null==(r=e[a])?void 0:r.mode)==="text";)o+=e[a].body?dH(e[a].body,i):e[a].value,a++;return null!=i&&i.plain?o+dH(e.slice(a),i):`"${o}" ${dH(e.slice(a))}`}let n=0,l=[];for(;(null==(a=e[n])?void 0:a.mode)==="math";){let r="";for(;(null==(o=e[n])?void 0:o.type)==="mord"&&/\d/.test(e[n].value);)r+=e[n++].value;r?l.push(r):l.push(dH(e[n++],i))}return l.push(dH(e.slice(n),i)),function(e){let i="";for(let r of e){let e=i[i.length-1];void 0!==e&&(/\d$/.test(e)&&/^\d/.test(r)||/[a-zA-Z]$/.test(e)&&/^[a-zA-Z]/.test(r))&&(i+=" "),i+=r}return i}(l)}if("text"===e.mode)return null!=i&&i.plain?e.value:`"${e.value}"`;let w="",{command:k}=e,M;if("\\placeholder"===k||"\\blank"===k)return`(${dH(e.body,i)})`;let S=oG.serialize([e],{expandMacro:!1,defaultMode:"math"});switch(e.type){case"accent":let L={"\\vec":"vec","\\dot":"dot","\\ddot":"ddot","\\bar":"bar","\\hat":"hat","\\acute":"acute;","\\grave":"grave","\\tilde":"tilde","\\breve":"breave","\\check":"check"}[k];w=`${null!=L?L:""} ${dH(e.body,i)} `;break;case"first":return"";case"latexgroup":return e.body.map(e=>e.value).join("");case"group":case"root":w=null!=(n=dF[k])?n:dH(e.body,i);break;case"genfrac":(e.leftDelim||e.rightDelim)&&(w="."!==e.leftDelim&&e.leftDelim?e.leftDelim:"{:"),e.hasBarLine?(w+="(",w+=dH(e.above,i),w+=")/(",w+=dH(e.below,i),w+=")"):(w+="((",w+=dH(e.above,i),w+=") choose (",w+=dH(e.below,i),w+="))"),(e.leftDelim||e.rightDelim)&&(w+="."!==e.rightDelim&&e.rightDelim?e.rightDelim:"{:");break;case"surd":e.hasEmptyBranch("above")?w+=`sqrt(${dH(e.body,i)})`:w+=`root(${dH(e.above,i)})(${dH(e.body,i)})`;break;case"latex":case"sizeddelim":case"delim":case"mopen":case"mclose":w=e.value;break;case"leftright":{let r=e.leftDelim;r&&dj[r]&&(r=dj[r]),w+="."!==r&&r?r:"{:",w+=dH(e.body,i);let a=e.matchingRightDelim();a&&dj[a]&&(a=dj[a]),w+="."!==a&&a?a:":}"}break;case"overlap":case"overunder":case"box":break;case"mord":if(dF[S])return dF[S];(w=null!=(c=null!=(s=null!=(l=dF[k])?l:k)?s:k)?c:"string"==typeof e.value?e.value:"").startsWith("\\")&&(w+=" "),(M=k?k.match(/{?\\char"([\dabcdefABCDEF]+)}?/):null)?w=String.fromCodePoint(Number.parseInt("0x"+M[1])):w.length>0&&w.startsWith("\\")&&(w="string"==typeof e.value?e.value.charAt(0):e.command),w=function(e,i){if(!i)return e;let r=e;return"double-struck"===i.variant&&(r=`bbb "${r}"`),"script"===i.variant&&(r=`cc "${r}"`),"fraktur"===i.variant&&(r=`fr "${r}"`),"sans-serif"===i.variant&&(r=`sf "${r}"`),"monospace"===i.variant&&(r=`tt "${r}"`),"bold"===i.variantStyle&&(r=`bb "${r}"`),i.color?`color({${i.color}})(${r})`:r}(w,e.style);break;case"mbin":case"mrel":case"minner":w=null!=(h=null!=(u=null!=(d=dF[S])?d:dF[k])?u:dV[k])?h:e.value;break;case"mpunct":w=null!=(p=dV[k])?p:k;break;case"mop":case"operator":case"extensible-symbol":""!==e.value&&(w=(dV[k]?dV[k]:"\\operatorname"===k?dH(e.body,i):null!=(m=e.value)?m:k)+" ");break;case"array":let C=e.environmentName;if(e.isMultiline)w=e.rows.map(e=>e.map(e=>dH(e,i)).join("")).join(`
|
|
3480
|
+
`);else{let r=null!=(f=({bmatrix:["[","]"],"bmatrix*":["[","]"]})[C])?f:["(",")"],a=[];for(let o of e.rows){let e=[];for(let r of o)e.push(dH(r,i));a.push(r[0]+e.join(",")+r[1])}let o=null!=(g=({bmatrix:["[","]"],"bmatrix*":["[","]"],cases:["{",":}"]})[C])?g:["(",")"];w=o[0]+a.join(",")+o[1]}break;case"spacing":w=null!=(y=null!=(b=dF[S])?b:dF[k])?y:" ";break;case"newline":w=`
|
|
3481
|
+
`;break;case"enclose":w="("+dH(e.body,i)+")";break;case"space":w=" ";break;case"subsup":w="";break;case"macro":w=null!=(_=null!=(x=null!=(v=dF[S])?v:dF[k])?x:dV[k])?_:dH(e.body,i)}if(!e.hasEmptyBranch("subscript")){w+="_";let r=dH(e.subscript,i);w+=1!==r.length?`(${r})`:r}if(!e.hasEmptyBranch("superscript")){w+="^";let r=dH(e.superscript,i);w+=1!==r.length?`(${r})`:r}return w}function dW(e,i){var r;let a=g(f({},oH()),{renderPlaceholder:()=>new oE(160,{maxFontSize:1})});if(null!=i&&i.letterShapeStyle&&(null==i?void 0:i.letterShapeStyle)!=="auto"&&(a.letterShapeStyle=i.letterShapeStyle),null!=i&&i.macros){let e=ek(null==i?void 0:i.macros);a.getMacro=i=>eS(i,e)}null!=i&&i.registers&&(a.registers=f(f({},a.registers),i.registers));let o=null!=(r=null==i?void 0:i.defaultMode)?r:"math",n="math",l="displaystyle";"inline-math"===o?l="textstyle":"math"===o?l="displaystyle":"text"===o&&(l="textstyle",n="text");let s=new oW({from:a}),c=new oG({type:"root",mode:n,body:ls(e,{context:s,parseMode:n,mathstyle:l})}).render(s);return c?(oA(lK(c,s)),oz(c,{classes:"ML__latex"}).toMarkup()):""}function dU(e,i){let r=f({},oH());if(null!=i&&i.macros){let e=ek(i.macros);r.getMacro=i=>eS(i,e)}return lc(e,{context:r})}function dJ(e,i={}){return dT(ls(e,{parseMode:"math",args:()=>"",mathstyle:"displaystyle"}),i)}function dX(e){return dq(ls(e,{parseMode:"math",mathstyle:"displaystyle"}))}function dG(e){var i,r;if(!uB){let e=null==(i=globalThis[Symbol.for("io.cortexjs.compute-engine")])?void 0:i.ComputeEngine;e?uB=new e:console.error(`MathLive 0.110.10: The CortexJS Compute Engine library is not available.
|
|
3482
3482
|
|
|
3483
3483
|
Load the library, for example with:
|
|
3484
3484
|
|
|
3485
|
-
import "https://esm.run/@cortex-js/compute-engine"`)}return null!=(r=null==uK?void 0:uK.box(e).latex)?r:""}function dG(e,i="math"){return dj(new oG({type:"root",body:ll(e,{parseMode:i})}))}function dZ(e){return o6(e,{format:"ascii-math"})[1]}function dY(e){if("string"==typeof e){let i=function(e){let i;if(e&&"#"===e[0])return(e=e.slice(1)).length<=4?(i={r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16)},4===e.length&&(i.a=parseInt(e[3]+e[3],16)/255)):(i={r:parseInt(e[0]+e[1],16),g:parseInt(e[2]+e[3],16),b:parseInt(e[4]+e[5],16)},8===e.length&&(i.a=parseInt(e[6]+e[7],16)/255)),void 0===(null==i?void 0:i.a)&&(i.a=1),i}(e);if(!i)throw Error(`Invalid color: ${e}`);return i}return"C"in e?d3(d0(e)):"a"in e?d3(e):e}function dQ(e){return e<0?0:e>255?255:Math.round(e)}function d0(e){let[i,r,a]=[e.L,e.C,e.H],o=a*Math.PI/180,n={L:i,a:r*Math.cos(o),b:r*Math.sin(o)};return void 0!==e.alpha&&(n.alpha=e.alpha),n}function d1(e){let[i,r,a]=[e.L,e.a,e.b],o=Math.pow(.9999999984505198*i+.39633779217376786*r+.2158037580607588*a,3),n=Math.pow(1.00000000888176*i-.10556134232365635*r-.0638541747717059*a,3),l=Math.pow(1.000000054672411*i-.0894841820949657*r-1.2914855378640917*a,3),s=e=>{let i=Math.abs(e);return i<=.0031308?12.92*e:(Math.sign(e)||1)*(1.055*Math.pow(i,1/2.4)-.055)};return[s(4.076741661347994*o-3.307711590408193*n+.230969928729428*l),s(-1.2684380040921763*o+2.6097574006633715*n-.3413193963102197*l),s(-.004196086541837188*o-.7034186144594493*n+1.7076147009309444*l)]}function d4(e){let[i,r,a]=e;return i>=0&&i<=1&&r>=0&&r<=1&&a>=0&&a<=1}function d2(e,i){let[r,a,o]=e;return r=dQ(255*r),a=dQ(255*a),o=dQ(255*o),void 0!==i?{r,g:a,b:o,alpha:i}:{r,g:a,b:o}}function d3(e){let[i,r,a]=d1(e);if(d4([i,r,a]))return d2([i,r,a],e.alpha);let o=function(e){let[i,r,a]=[e.L,e.a,e.b],o={L:i,C:Math.sqrt(r*r+a*a),H:180*Math.atan2(a,r)/Math.PI};return void 0!==e.alpha&&(o.alpha=e.alpha),o}(e);if(o.C=0,[i,r,a]=d1(d0(o)),!d4([i,r,a]))return d2([i,r,a],e.alpha);let n=0,l=e.L,s=(n+l)/2;o.C=s;let c=.36/4096;for(;l-n>c;)o.C=s=(n+l)/2,[i,r,a]=d1(d0(o)),d4([i,r,a])?n=s:l=s;return d2([i,r,a],e.alpha)}function d6(e,i){let r=dY(e),a=dY(i);function o(e){return e>=.022?e:e+(.022-e)**1.414}function n(e){return(e<0?-1:1)*Math.pow(Math.abs(e),2.4)}let l=o(.2126729*n(a.r/255)+.7151522*n(a.g/255)+.072175*n(a.b/255)),s=o(.2126729*n(r.r/255)+.7151522*n(r.g/255)+.072175*n(r.b/255)),c;return 100*(.1>Math.abs(c=5e-4>Math.abs(s-l)?0:s>l?1.14*(s**.56-l**.57):1.14*(s**.65-l**.62))?0:c>0?c-.027:c+.027)}function d8(e,i,r){return null!=r||(r="#fff"),null!=i||(i="#000"),Math.abs(d6(e,r))>Math.abs(d6(e,i))?r:i}function d5(e){let i=d7(e),r="";for(let e of i){if("string"!=typeof e.value)return"";r+=e.value}return r}function d7(e){let i=e.model.selection.ranges;if(1!==i.length)return[];let r=e.model.getAtoms(i[0]);return 1===r.length&&r[0].isRoot&&(r=r[0].children),r.filter(e=>"first"!==e.type)}var d9=class extends dh{constructor(e,i,r,a){super(e,i),this.row=r,this.col=a}set active(e){let i=this.parentMenu.children;if(e)for(let e of i)e.element.classList.toggle("active",e.row<=this.row&&e.col<=this.col);else for(let e of i)e.element.classList.remove("active")}};function ue(e){var i,r;return["array","matrix","pmatrix","bmatrix","vmatrix","Bmatrix","cases","dcases","rcases"].includes(null!=(r=null==(i=e.model.parentEnvironment)?void 0:i.environmentName)?r:"")}function ut(e){var i;let r=null==(i=e.model.parentEnvironment)?void 0:i.rows;return r?[r.length,r.reduce((e,i)=>Math.max(e,i.length),0)]:[0,0]}function ui(e){let i=e.model.parentEnvironment;return i?[i.minRows,i.minColumns]:[0,0]}function ur(e){let i=e.model.parentEnvironment;return i?[i.maxRows,i.maxColumns]:[0,0]}function ua(e,i){sh(e),e.flushInlineShortcutBuffer(),cf(e.model,i),sB(e)}function uo(e,i,r,a){return{id:`variant-${i}`,label:()=>{var i;return d5(e).length<12?dH(`\\${r}{${d5(e)}}`):null!=(i=N(a))?i:a},class:"ML__xl",tooltip:()=>{var e;return null!=(e=N(a))?e:a},visible:()=>(function(e,i){let r=d7(e);if(1!==r.length)return!1;let a=lY[i];return!!a&&!!a.test(r[0].value)})(e,i),checked:()=>{var r;return null!=(r=({some:"mixed",all:!0})[e.queryStyle({variant:i})])&&r},onMenuSelect:()=>e.applyStyle({variant:i},{operation:"toggle"})}}function un(e,i,r,a){return{id:`variant-style-${i}`,label:()=>{var i;let o=d5(e);return o.length>0&&o.length<12?dH(`\\${r}{${d5(e)}}`):null!=(i=N(a))?i:a},class:()=>{let i=d5(e);return i.length>0&&i.length<12?"ML__xl":""},tooltip:()=>{var e;return null!=(e=N(a))?e:a},visible:!0,checked:()=>{var r;return null!=(r=({some:"mixed",all:!0})[e.queryStyle({variantStyle:i})])&&r},onMenuSelect:()=>e.applyStyle({variantStyle:i},{operation:"toggle"})}}function ul(e){return`<span class='ML__insert-template'> ${dH(N(`menu.insert.${e}-template`))}</span><span class="ML__insert-label">${N(`menu.insert.${e}`)}</span>`}var us={"\\ne":"!=","\\neq":"!=","−":"-","-":"-","\\alpha":"alpha","\\beta":"beta","\\gamma":"gamma","\\delta":"delta","\\epsilon":"epsilon.alt","\\varepsilon":"epsilon","\\zeta":"zeta","\\eta":"eta","\\theta":"theta.alt","\\vartheta":"theta","\\iota":"iota","\\kappa":"kappa","\\lambda":"lambda","\\mu":"mu","\\nu":"nu","\\xi":"xi","\\pi":"pi","\\rho":"rho","\\sigma":"sigma","\\tau":"tau","\\upsilon":"upsilon","\\phi":"phi.alt","\\varphi":"phi","\\chi":"chi","\\psi":"psi","\\omega":"omega","\\Gamma":"Gamma","\\Delta":"Delta","\\Theta":"Theta","\\Lambda":"Lambda","\\Xi":"Xi","\\Pi":"Pi","\\Sigma":"Sigma","\\Phi":"Phi","\\Psi":"Psi","\\Omega":"Omega","\\exponentialE":"e","\\imaginaryI":"i","\\imaginaryJ":"j","\\!":" #h(-1em/6) ","\\,":" thin ","\\:":" med ","\\>":" med ","\\;":" thick ","\\enskip":"space.en","\\enspace":"space.en","\\qquad":"space.quad space.quad","\\quad":"space.quad","\\infty":"infinity","\\R":"RR","\\mathbb{R}":"RR","\\N":"NN","\\mathbb{N}":"NN","\\Z":"ZZ","\\mathbb{Z}":"ZZ","\\Q":"QQ","\\mathbb{Q}":"QQ","\\C":"CC","\\mathbb{C}":"CC","\\emptyset":"emptyset","\\varnothing":"nothing","\\varDelta":"Delta","\\varTheta":"Theta","\\varLambda":"Lambda","\\varXi":"Xi","\\varPi":"Pi","\\varSigma":"Sigma","\\varUpsilon":"Upsilon","\\varPhi":"Phi","\\varPsi":"Psi","\\varOmega":"Omega","\\vert":" | ","\\Vert":" || ","\\mid":" divides ","\\lbrack":" bracket.l ","\\rbrack":" bracket.r ","\\lbrace":" brace.l ","\\rbrace":" brace.r ","\\lparen":" paren.l ","\\rparen":" paren.r ","\\langle":" angle.l ","\\rangle":" angle.r ","\\differentialD":" dif ","\\diamond":" diamond.stroked.small ","\\square":" square.stroked.small ","\\lceil":" ceil.l ","\\rceil":" ceil.r ","\\lfloor":" floor.l ","\\rfloor":" floor.r ","\\aleph":" aleph ","\\bet":" bet ","\\gimel":" gimel ","\\dalet":" dalet ","\\mod":" mod ","\\equiv":" equiv ","\\subset":" subset ","\\supset":" supset ","\\subseteq":" subset.eq ","\\supseteq":" supset.eq ","\\subsetneq":" subset.neq ","\\supsetneq":" supset.neq ","\\supsetneqq":" supset.neq ","\\nsubset":" subset.not ","\\nsupset":" supset.not ","\\nsubseteq":" subset.eq.not ","\\nsupseteq":" supset.eq.not ","\\approx":" approx ","\\uparrow":" arrow.t ","\\downarrow":" arrow.b ","\\rightarrow":" arrow.r ","\\leftarrow":" arrow.l ","\\longmapsto":" mapsto.long ","\\longmapsfrom":" arrow.l.bar.long ","/":"\\/","&":"&"},uc={"[":" bracket.l ","]":" bracket.r ","{":" brace.l ","}":" brace.r ","(":" paren.l ",")":" paren.r ","<":" angle.l ",">":" angle.r ",".":""},ud={" bracket.l ":"["," bracket.r ":"]"," brace.l ":"{"," brace.r ":"}"," paren.l ":"("," paren.r ":")"," angle.l ":" angle.l "," angle.r ":" angle.r "},uu={"\\pm":"plus.minus","\\colon":" : ","\\sum":" sum ","\\prod":" product ","\\bigcap":" inter.big ","\\bigcup":" union.big ","\\int":" integral ","\\iint":" integral.double ","\\iiint":" integral.triple ","\\intop":" integral ","\\oint":" integral.cont ","\\oiint":" integral.surf ","\\oiiint":" integral.vol ","\\setminus":" without ","\\vdots":" without ","\\ddots":" dots.down ","\\ge":">=","\\le":"<=","\\ne":"!=","\\neq":"!=","\\lt":"<","\\gt":">","\\gets":"<-","\\to":"->","\\land":" and ","\\lor":" or ","\\lnot":" not ","\\forall":" forall ","\\exists":" exists ","\\in":" in ","\\notin":" in.not ","\\mapsto":"|->","\\implies":"==>","\\iff":"<==>","\\cdot":" dot.op ","\\ast":" * ","\\star":" star.op ","\\times":" times ","\\div":" div ","\\ltimes":" times.l ","\\rtimes":" times.r ","\\bowtie":" ⋈ ","\\circ":" circle.stroked.small "},uh={underarc:"underparen",underparen:"underparen",underbrace:"underbrace",underline:"underline",overarc:"overparen",overparen:"overparen",overbrace:"overbrace",overline:"overline",cancel:"cancel",displaystyle:"display",textstyle:"inline"},up={longrightarrow:e=>`arrow.r.long^(${um(e.above)})`,longleftarrow:e=>`arrow.l.long^(${um(e.above)})`};function um(e){var i,r,a,o,n,l,s,c,d,u,h,p,m,f,g,b,y,v,x,_,w,k,M;if(!e)return"";if(R(e)){if(0===e.length)return"";if("latex"===e[0].mode)return e.map(e=>um(e)).join("");if("text"===e[0].mode){let r=0,a="";for(;(null==(i=e[r])?void 0:i.mode)==="text";)a+=e[r].body?um(e[r].body):e[r].value,r++;return` "${a}" ${um(e.slice(r))}`}let o=0,n=[];for(;(null==(r=e[o])?void 0:r.mode)==="math";){let i="";for(;(null==(a=e[o])?void 0:a.type)==="mord"&&/\d/.test(e[o].value);)i+=e[o++].value;i?n.push(i):n.push(um(e[o++]))}return n.push(um(e.slice(o))),function(e){let i="";for(let r of e){let e=i[i.length-1];void 0!==e&&(/\d$/.test(e)&&/^\d/.test(r)||/[a-zA-Z]$/.test(e)&&/^[a-zA-Z]/.test(r))&&(i+=" "),i+=r}return i}(n)}if("text"===e.mode)return`"${e.value}"`;let S="",{command:L}=e,C;if("\\placeholder"===L||"\\blank"===L)return`"${um(e.body)}"`;let E=oG.serialize([e],{expandMacro:!0,defaultMode:"math"});switch(e.type){case"accent":let A={"\\vec":"arrow","\\dot":"dot","\\ddot":"dot.double","\\bar":"overline","\\hat":"hat","\\acute":"acute","\\grave":"grave","\\tilde":"tilde","\\breve":"breve","\\check":"caron"}[L];S=`${null!=A?A:""}(${um(e.body)}) `;break;case"first":return"";case"latexgroup":return e.body.map(e=>e.value).join("");case"group":case"root":S=null!=(o=us[L])?o:um(e.body);break;case"genfrac":e.hasBarLine?(S+="(",S+=um(e.above),S+=")/(",S+=um(e.below),S+=")"):S+=`binom(${um(e.above)}, ${um(e.below)})`;break;case"surd":e.hasEmptyBranch("above")?S+=`sqrt(${um(e.body)})`:S+=`root(${um(e.above)}, ${um(e.body)})`;break;case"latex":case"sizeddelim":case"delim":S=e.value;break;case"leftright":{let i=e.leftDelim;i&&us[i]&&(i=us[i]);let r=e.matchingRightDelim();r&&us[r]&&(r=us[r]),i&&(i=null!=(n=uc[i])?n:i),r&&(r=null!=(l=uc[r])?l:r),S=i&&r?`lr(${null!=(s=ud[i])?s:i}${um(e.body)}${null!=(c=ud[r])?c:r})`:`lr(${i}${um(e.body)}${r})`}break;case"overlap":case"box":break;case"mord":if(us[E])return us[E];(S=null!=(h=null!=(u=null!=(d=us[L])?d:L)?u:L)?h:"string"==typeof e.value?e.value:"").startsWith("\\")&&(S+=" "),(C=L?L.match(/{?\\char"([\dabcdefABCDEF]+)}?/):null)?S=String.fromCodePoint(Number.parseInt("0x"+C[1])):S.length>0&&S.startsWith("\\")&&(S="string"==typeof e.value?e.value.charAt(0):e.command),S=function(e,i){if(!i)return e;let r=e;return"double-struck"===i.variant&&(r=`bb(${r})`),"script"===i.variant&&(r=`cal(${r})`),"fraktur"===i.variant&&(r=`frak(${r})`),"sans-serif"===i.variant&&(r=`sans(${r})`),"monospace"===i.variant&&(r=`mono(${r})`),"bold"===i.variantStyle&&(r=`bold(${r})`),r}(S,e.style),S=` ${S} `;break;case"mbin":case"mrel":case"minner":S=null!=(f=null!=(m=null!=(p=us[E])?p:us[L])?m:uu[L])?f:e.value;break;case"mopen":case"mclose":S=null!=(g=us[E])?g:e.value;break;case"mpunct":S=null!=(b=uu[L])?b:L;break;case"mop":case"operator":case"extensible-symbol":""!==e.value&&(S=(uu[L]?uu[L]:"\\operatorname"===L?um(e.body):null!=(y=e.value)?y:L)+" ");break;case"array":let z=e.environmentName;if(e.isMultiline)S=e.rows.map(e=>e.map(e=>um(e)).join("")).join(`
|
|
3486
|
-
`);else{let i=e.rows,r=i.map(e=>e.map(
|
|
3487
|
-
`;break;case"space":S=" ";break;case"subsup":S=null!=(_=e.leftSibling)&&_.value?"":'""';break;case"macro":S=null!=(M=null!=(k=null!=(w=
|
|
3485
|
+
import "https://esm.run/@cortex-js/compute-engine"`)}return null!=(r=null==uB?void 0:uB.box(e).latex)?r:""}function dZ(e,i="math"){return dH(new oG({type:"root",body:ls(e,{parseMode:i})}))}function dY(e){return o6(e,{format:"ascii-math"})[1]}function dQ(e){if("string"==typeof e){let i=function(e){let i;if(e&&"#"===e[0])return(e=e.slice(1)).length<=4?(i={r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16)},4===e.length&&(i.a=parseInt(e[3]+e[3],16)/255)):(i={r:parseInt(e[0]+e[1],16),g:parseInt(e[2]+e[3],16),b:parseInt(e[4]+e[5],16)},8===e.length&&(i.a=parseInt(e[6]+e[7],16)/255)),void 0===(null==i?void 0:i.a)&&(i.a=1),i}(e);if(!i)throw Error(`Invalid color: ${e}`);return i}return"C"in e?d6(d1(e)):"a"in e?d6(e):e}function d0(e){return e<0?0:e>255?255:Math.round(e)}function d1(e){let[i,r,a]=[e.L,e.C,e.H],o=a*Math.PI/180,n={L:i,a:r*Math.cos(o),b:r*Math.sin(o)};return void 0!==e.alpha&&(n.alpha=e.alpha),n}function d4(e){let[i,r,a]=[e.L,e.a,e.b],o=Math.pow(.9999999984505198*i+.39633779217376786*r+.2158037580607588*a,3),n=Math.pow(1.00000000888176*i-.10556134232365635*r-.0638541747717059*a,3),l=Math.pow(1.000000054672411*i-.0894841820949657*r-1.2914855378640917*a,3),s=e=>{let i=Math.abs(e);return i<=.0031308?12.92*e:(Math.sign(e)||1)*(1.055*Math.pow(i,1/2.4)-.055)};return[s(4.076741661347994*o-3.307711590408193*n+.230969928729428*l),s(-1.2684380040921763*o+2.6097574006633715*n-.3413193963102197*l),s(-.004196086541837188*o-.7034186144594493*n+1.7076147009309444*l)]}function d2(e){let[i,r,a]=e;return i>=0&&i<=1&&r>=0&&r<=1&&a>=0&&a<=1}function d3(e,i){let[r,a,o]=e;return r=d0(255*r),a=d0(255*a),o=d0(255*o),void 0!==i?{r,g:a,b:o,alpha:i}:{r,g:a,b:o}}function d6(e){let[i,r,a]=d4(e);if(d2([i,r,a]))return d3([i,r,a],e.alpha);let o=function(e){let[i,r,a]=[e.L,e.a,e.b],o={L:i,C:Math.sqrt(r*r+a*a),H:180*Math.atan2(a,r)/Math.PI};return void 0!==e.alpha&&(o.alpha=e.alpha),o}(e);if(o.C=0,[i,r,a]=d4(d1(o)),!d2([i,r,a]))return d3([i,r,a],e.alpha);let n=0,l=e.L,s=(n+l)/2;o.C=s;let c=.36/4096;for(;l-n>c;)o.C=s=(n+l)/2,[i,r,a]=d4(d1(o)),d2([i,r,a])?n=s:l=s;return d3([i,r,a],e.alpha)}function d8(e,i){let r=dQ(e),a=dQ(i);function o(e){return e>=.022?e:e+(.022-e)**1.414}function n(e){return(e<0?-1:1)*Math.pow(Math.abs(e),2.4)}let l=o(.2126729*n(a.r/255)+.7151522*n(a.g/255)+.072175*n(a.b/255)),s=o(.2126729*n(r.r/255)+.7151522*n(r.g/255)+.072175*n(r.b/255)),c;return 100*(.1>Math.abs(c=5e-4>Math.abs(s-l)?0:s>l?1.14*(s**.56-l**.57):1.14*(s**.65-l**.62))?0:c>0?c-.027:c+.027)}function d5(e,i,r){return null!=r||(r="#fff"),null!=i||(i="#000"),Math.abs(d8(e,r))>Math.abs(d8(e,i))?r:i}function d7(e){let i=d9(e),r="";for(let e of i){if("string"!=typeof e.value)return"";r+=e.value}return r}function d9(e){let i=e.model.selection.ranges;if(1!==i.length)return[];let r=e.model.getAtoms(i[0]);return 1===r.length&&r[0].isRoot&&(r=r[0].children),r.filter(e=>"first"!==e.type)}var ue=class extends dp{constructor(e,i,r,a){super(e,i),this.row=r,this.col=a}set active(e){let i=this.parentMenu.children;if(e)for(let e of i)e.element.classList.toggle("active",e.row<=this.row&&e.col<=this.col);else for(let e of i)e.element.classList.remove("active")}};function ut(e){var i,r;return["array","matrix","pmatrix","bmatrix","vmatrix","Bmatrix","cases","dcases","rcases"].includes(null!=(r=null==(i=e.model.parentEnvironment)?void 0:i.environmentName)?r:"")}function ui(e){var i;let r=null==(i=e.model.parentEnvironment)?void 0:i.rows;return r?[r.length,r.reduce((e,i)=>Math.max(e,i.length),0)]:[0,0]}function ur(e){let i=e.model.parentEnvironment;return i?[i.minRows,i.minColumns]:[0,0]}function ua(e){let i=e.model.parentEnvironment;return i?[i.maxRows,i.maxColumns]:[0,0]}function uo(e,i){sp(e),e.flushInlineShortcutBuffer(),cg(e.model,i),s$(e)}function un(e,i,r,a){return{id:`variant-${i}`,label:()=>{var i;return d7(e).length<12?dW(`\\${r}{${d7(e)}}`):null!=(i=N(a))?i:a},class:"ML__xl",tooltip:()=>{var e;return null!=(e=N(a))?e:a},visible:()=>(function(e,i){let r=d9(e);if(1!==r.length)return!1;let a=lQ[i];return!!a&&!!a.test(r[0].value)})(e,i),checked:()=>{var r;return null!=(r=({some:"mixed",all:!0})[e.queryStyle({variant:i})])&&r},onMenuSelect:()=>e.applyStyle({variant:i},{operation:"toggle"})}}function ul(e,i,r,a){return{id:`variant-style-${i}`,label:()=>{var i;let o=d7(e);return o.length>0&&o.length<12?dW(`\\${r}{${d7(e)}}`):null!=(i=N(a))?i:a},class:()=>{let i=d7(e);return i.length>0&&i.length<12?"ML__xl":""},tooltip:()=>{var e;return null!=(e=N(a))?e:a},visible:!0,checked:()=>{var r;return null!=(r=({some:"mixed",all:!0})[e.queryStyle({variantStyle:i})])&&r},onMenuSelect:()=>e.applyStyle({variantStyle:i},{operation:"toggle"})}}function us(e){return`<span class='ML__insert-template'> ${dW(N(`menu.insert.${e}-template`))}</span><span class="ML__insert-label">${N(`menu.insert.${e}`)}</span>`}var uc={"\\ne":"!=","\\neq":"!=","−":"-","-":"-","\\alpha":"alpha","\\beta":"beta","\\gamma":"gamma","\\delta":"delta","\\epsilon":"epsilon.alt","\\varepsilon":"epsilon","\\zeta":"zeta","\\eta":"eta","\\theta":"theta.alt","\\vartheta":"theta","\\iota":"iota","\\kappa":"kappa","\\lambda":"lambda","\\mu":"mu","\\nu":"nu","\\xi":"xi","\\pi":"pi","\\rho":"rho","\\sigma":"sigma","\\tau":"tau","\\upsilon":"upsilon","\\phi":"phi.alt","\\varphi":"phi","\\chi":"chi","\\psi":"psi","\\omega":"omega","\\Gamma":"Gamma","\\Delta":"Delta","\\Theta":"Theta","\\Lambda":"Lambda","\\Xi":"Xi","\\Pi":"Pi","\\Sigma":"Sigma","\\Phi":"Phi","\\Psi":"Psi","\\Omega":"Omega","\\exponentialE":"e","\\imaginaryI":"i","\\imaginaryJ":"j","\\!":" #h(-1em/6) ","\\,":" thin ","\\:":" med ","\\>":" med ","\\;":" thick ","\\enskip":"space.en","\\enspace":"space.en","\\qquad":"space.quad space.quad","\\quad":"space.quad","\\infty":"infinity","\\R":"RR","\\mathbb{R}":"RR","\\N":"NN","\\mathbb{N}":"NN","\\Z":"ZZ","\\mathbb{Z}":"ZZ","\\Q":"QQ","\\mathbb{Q}":"QQ","\\C":"CC","\\mathbb{C}":"CC","\\emptyset":"emptyset","\\varnothing":"nothing","\\varDelta":"Delta","\\varTheta":"Theta","\\varLambda":"Lambda","\\varXi":"Xi","\\varPi":"Pi","\\varSigma":"Sigma","\\varUpsilon":"Upsilon","\\varPhi":"Phi","\\varPsi":"Psi","\\varOmega":"Omega","\\vert":" | ","\\Vert":" || ","\\mid":" divides ","\\lbrack":" bracket.l ","\\rbrack":" bracket.r ","\\lbrace":" brace.l ","\\rbrace":" brace.r ","\\lparen":" paren.l ","\\rparen":" paren.r ","\\langle":" angle.l ","\\rangle":" angle.r ","\\differentialD":" dif ","\\diamond":" diamond.stroked.small ","\\square":" square.stroked.small ","\\lceil":" ceil.l ","\\rceil":" ceil.r ","\\lfloor":" floor.l ","\\rfloor":" floor.r ","\\aleph":" aleph ","\\bet":" bet ","\\gimel":" gimel ","\\dalet":" dalet ","\\mod":" mod ","\\equiv":" equiv ","\\subset":" subset ","\\supset":" supset ","\\subseteq":" subset.eq ","\\supseteq":" supset.eq ","\\subsetneq":" subset.neq ","\\supsetneq":" supset.neq ","\\supsetneqq":" supset.neq ","\\nsubset":" subset.not ","\\nsupset":" supset.not ","\\nsubseteq":" subset.eq.not ","\\nsupseteq":" supset.eq.not ","\\approx":" approx ","\\uparrow":" arrow.t ","\\downarrow":" arrow.b ","\\rightarrow":" arrow.r ","\\leftarrow":" arrow.l ","\\longmapsto":" mapsto.long ","\\longmapsfrom":" arrow.l.bar.long ","/":"\\/","&":"&"},ud={"[":" bracket.l ","]":" bracket.r ","{":" brace.l ","}":" brace.r ","(":" paren.l ",")":" paren.r ","<":" angle.l ",">":" angle.r ",".":""},uu={" bracket.l ":"["," bracket.r ":"]"," brace.l ":"{"," brace.r ":"}"," paren.l ":"("," paren.r ":")"," angle.l ":" angle.l "," angle.r ":" angle.r "},uh={"\\pm":"plus.minus","\\colon":" : ","\\sum":" sum ","\\prod":" product ","\\bigcap":" inter.big ","\\bigcup":" union.big ","\\int":" integral ","\\iint":" integral.double ","\\iiint":" integral.triple ","\\intop":" integral ","\\oint":" integral.cont ","\\oiint":" integral.surf ","\\oiiint":" integral.vol ","\\setminus":" without ","\\vdots":" without ","\\ddots":" dots.down ","\\ge":">=","\\le":"<=","\\ne":"!=","\\neq":"!=","\\lt":"<","\\gt":">","\\gets":"<-","\\to":"->","\\land":" and ","\\lor":" or ","\\lnot":" not ","\\forall":" forall ","\\exists":" exists ","\\in":" in ","\\notin":" in.not ","\\mapsto":"|->","\\implies":"==>","\\iff":"<==>","\\cdot":" dot.op ","\\ast":" * ","\\star":" star.op ","\\times":" times ","\\div":" div ","\\ltimes":" times.l ","\\rtimes":" times.r ","\\bowtie":" ⋈ ","\\circ":" circle.stroked.small "},up={underarc:"underparen",underparen:"underparen",underbrace:"underbrace",underline:"underline",overarc:"overparen",overparen:"overparen",overbrace:"overbrace",overline:"overline",cancel:"cancel",displaystyle:"display",textstyle:"inline"},um={longrightarrow:e=>`arrow.r.long^(${uf(e.above)})`,longleftarrow:e=>`arrow.l.long^(${uf(e.above)})`};function uf(e){var i,r,a,o,n,l,s,c,d,u,h,p,m,f,g,b,y,v,x,_,w,k,M;if(!e)return"";if(R(e)){if(0===e.length)return"";if("latex"===e[0].mode)return e.map(e=>uf(e)).join("");if("text"===e[0].mode){let r=0,a="";for(;(null==(i=e[r])?void 0:i.mode)==="text";)a+=e[r].body?uf(e[r].body):e[r].value,r++;return` "${a}" ${uf(e.slice(r))}`}let o=0,n=[];for(;(null==(r=e[o])?void 0:r.mode)==="math";){let i="";for(;(null==(a=e[o])?void 0:a.type)==="mord"&&/\d/.test(e[o].value);)i+=e[o++].value;i?n.push(i):n.push(uf(e[o++]))}return n.push(uf(e.slice(o))),function(e){let i="";for(let r of e){let e=i[i.length-1];void 0!==e&&(/\d$/.test(e)&&/^\d/.test(r)||/[a-zA-Z]$/.test(e)&&/^[a-zA-Z]/.test(r))&&(i+=" "),i+=r}return i}(n)}if("text"===e.mode)return`"${e.value}"`;let S="",{command:L}=e,C;if("\\placeholder"===L||"\\blank"===L)return`"${uf(e.body)}"`;let E=oG.serialize([e],{expandMacro:!0,defaultMode:"math"});switch(e.type){case"accent":let A={"\\vec":"arrow","\\dot":"dot","\\ddot":"dot.double","\\bar":"overline","\\hat":"hat","\\acute":"acute","\\grave":"grave","\\tilde":"tilde","\\breve":"breve","\\check":"caron"}[L];S=`${null!=A?A:""}(${uf(e.body)}) `;break;case"first":return"";case"latexgroup":return e.body.map(e=>e.value).join("");case"group":case"root":S=null!=(o=uc[L])?o:uf(e.body);break;case"genfrac":e.hasBarLine?(S+="(",S+=uf(e.above),S+=")/(",S+=uf(e.below),S+=")"):S+=`binom(${uf(e.above)}, ${uf(e.below)})`;break;case"surd":e.hasEmptyBranch("above")?S+=`sqrt(${uf(e.body)})`:S+=`root(${uf(e.above)}, ${uf(e.body)})`;break;case"latex":case"sizeddelim":case"delim":S=e.value;break;case"leftright":{let i=e.leftDelim;i&&uc[i]&&(i=uc[i]);let r=e.matchingRightDelim();r&&uc[r]&&(r=uc[r]),i&&(i=null!=(n=ud[i])?n:i),r&&(r=null!=(l=ud[r])?l:r),S=i&&r?`lr(${null!=(s=uu[i])?s:i}${uf(e.body)}${null!=(c=uu[r])?c:r})`:`lr(${i}${uf(e.body)}${r})`}break;case"overlap":case"box":break;case"mord":if(uc[E])return uc[E];(S=null!=(h=null!=(u=null!=(d=uc[L])?d:L)?u:L)?h:"string"==typeof e.value?e.value:"").startsWith("\\")&&(S+=" "),(C=L?L.match(/{?\\char"([\dabcdefABCDEF]+)}?/):null)?S=String.fromCodePoint(Number.parseInt("0x"+C[1])):S.length>0&&S.startsWith("\\")&&(S="string"==typeof e.value?e.value.charAt(0):e.command),S=function(e,i){if(!i)return e;let r=e;return"double-struck"===i.variant&&(r=`bb(${r})`),"script"===i.variant&&(r=`cal(${r})`),"fraktur"===i.variant&&(r=`frak(${r})`),"sans-serif"===i.variant&&(r=`sans(${r})`),"monospace"===i.variant&&(r=`mono(${r})`),"bold"===i.variantStyle&&(r=`bold(${r})`),r}(S,e.style),S=` ${S} `;break;case"mbin":case"mrel":case"minner":S=null!=(f=null!=(m=null!=(p=uc[E])?p:uc[L])?m:uh[L])?f:e.value;break;case"mopen":case"mclose":S=null!=(g=uc[E])?g:e.value;break;case"mpunct":S=null!=(b=uh[L])?b:L;break;case"mop":case"operator":case"extensible-symbol":""!==e.value&&(S=(uh[L]?uh[L]:"\\operatorname"===L?uf(e.body):null!=(y=e.value)?y:L)+" ");break;case"array":let z=e.environmentName;if(e.isMultiline)S=e.rows.map(e=>e.map(e=>uf(e)).join("")).join(`
|
|
3486
|
+
`);else{let i=e.rows,r=i.map(e=>e.map(uf).join(", ")),a={pmatrix:'"("',bmatrix:'"["',"bmatrix*":'"["',Bmatrix:'"{"',vmatrix:'"|"',matrix:"#none"}[z];S=a?`mat(delim: ${a}, ${r.join(" ; ")})`:"cases"===z||"rcases"===z?`cases(reverse: #${"rcases"===z}, ${r.join(", ")})`:"aligned"===z?i.map(e=>e.map(uf).join(" & ")).join(" \\ "):i.map(e=>e.map(uf).join("")).join("")}break;case"spacing":S=null!=(x=null!=(v=uc[E])?v:uc[L])?x:" ";break;case"newline":S=`\\
|
|
3487
|
+
`;break;case"space":S=" ";break;case"subsup":S=null!=(_=e.leftSibling)&&_.value?"":'""';break;case"macro":S=null!=(M=null!=(k=null!=(w=uc[E])?w:uc[L])?k:uh[L])?M:uf(e.body)}if(!S){let i=up[e.command.slice(1)];i&&(S=`${i}(${uf(e.body)})`)}if(!S){let i=um[e.command.slice(1)];i&&(S=i(e))}if(!e.hasEmptyBranch("subscript")){S+="_";let i=uf(e.subscript);S+=1!==i.length?`(${i})`:i}if(!e.hasEmptyBranch("superscript")){S+="^";let i=uf(e.superscript);S+=1!==i.length?`(${i})`:i}return S}function ug(e,i){return"string"==typeof e?e+dq(i):dq(e)}function ub(e){var i;let r;if("prompt"===e.parent.type)"body"===e.parentBranch&&(r="prompt");else if("body"===e.parentBranch){if("first"===e.type&&("root"===e.parent.type?r="mathfield":"surd"===e.parent.type?r="radicand":"genfrac"===e.parent.type?r="fraction":"sizeddelim"===e.parent.type&&(r="delimiter"),r))return r;"subsup"===e.type?e.superscript&&e.subscript?r="superscript and subscript":e.superscript?r="superscript":e.subscript&&(r="subscript"):e.type&&(r=null!=(i=({accent:"accented",array:"array",box:"box",chem:"chemical formula",delim:"delimiter",enclose:"cross out","extensible-symbol":"extensible symbol",error:"error",first:"first",genfrac:"fraction",group:"group",latex:"LaTeX",leftright:"delimiter",line:"line",subsup:"subscript-superscript",operator:"operator",overunder:"over-under",placeholder:"placeholder",rule:"rule",sizeddelim:"delimiter",space:"space",spacing:"spacing",surd:"square root",text:"text",prompt:"prompt",root:"math field",mop:"operator"})[e.type])?i:"parent")}else if("genfrac"===e.parent.type){if("above"===e.parentBranch)return"numerator";if("below"===e.parentBranch)return"denominator"}else"surd"===e.parent.type?"above"===e.parentBranch&&(r="index"):"superscript"===e.parentBranch?r="superscript":"subscript"===e.parentBranch&&(r="subscript");return null!=r?r:"parent"}var uy=class{constructor(e,i,r){this.mathfield=e,this.mode=i,this.silenceNotifications=!1,this._selection={ranges:[[0,0]],direction:"none"},this._anchor=0,this._position=0,this.root=r}dispose(){this.mathfield=void 0}getState(){let e={ranges:[...this._selection.ranges]};return this.selection.direction&&"none"!==this.selection.direction&&(e.direction=this.selection.direction),{content:this.root.toJson(),selection:e,mode:this.mode}}setState(e,i){var r;let a=this.silenceNotifications;this.silenceNotifications=null==(r=null==i?void 0:i.silenceNotifications)||r;let o={};if((null==i?void 0:i.type)==="undo"&&(o={inputType:"historyUndo"}),(null==i?void 0:i.type)==="redo"&&(o={inputType:"historyRedo"}),this.contentWillChange(o)){let i=this.silenceNotifications;this.silenceNotifications=!0,this.mode=e.mode,this.root=lI(e.content),this.selection=e.selection,this.silenceNotifications=i,this.contentDidChange(o),this.selectionDidChange()}this.silenceNotifications=a}get atoms(){return this.root.children}get selection(){return this._selection}set selection(e){this.setSelection(e)}setSelection(e,i){return(!!this.mathfield.contentEditable||"none"!==this.mathfield.userSelect)&&this.deferNotifications({selection:!0,content:!0},()=>{var r,a,o,n;let l=this.normalizeSelection(e,i);if(void 0===l)throw TypeError("Invalid selection");if(1===l.ranges.length&&l.ranges[0][0]===l.ranges[0][1]){let e=l.ranges[0][0];if(!this.mathfield.dirty&&!(null!=(r=this.at(e))&&r.parentPrompt)&&this.mathfield.hasEditablePrompts){if(null!=(a=this.at(e-1))&&a.parentPrompt){this._anchor=this.normalizeOffset(e-1),this._position=this._anchor,this._selection=this.normalizeSelection(this._anchor);return}if(null!=(o=this.at(e+1))&&o.parentPrompt){this._anchor=this.normalizeOffset(e+1),this._position=this._anchor,this._selection=this.normalizeSelection(this._anchor);return}this._anchor=0,this._position=0,this._selection={ranges:[[0,0]]};return}this._anchor=e,this._position=e,this._selection=l;return}let s=oQ(l);s=function(e,i){let[r,a]=i,o=a+1;if(o>e.lastOffset)return i;let n=e.at(o);return function(e,i,r,a){if((null==i?void 0:i.type)!=="subsup"||!ux(e,i,[r,a]))return!1;let o=i.leftSibling;if(!o)return!1;let n=e.offsetOf(o);return n>r&&n<=a}(e,n,r,a)&&(a=e.offsetOf(n)),[r,a]}(this,s),"backward"===l.direction?[this._position,this._anchor]=s:[this._anchor,this._position]=s;let c=s[0]+1;for(;c<=this.lastOffset&&(null==(n=this.at(c))?void 0:n.type)==="first"&&c<s[1];)c+=1;let d=c<=this.lastOffset?this.at(c):this.at(s[1]),u=this.at(s[1]),h=oG.commonAncestor(d,u);(null==h?void 0:h.type)==="array"&&d.parent===h&&u.parent,this._selection={ranges:[s],direction:l.direction},this._position>=0&&(this._position,this.lastOffset)})}setPositionHandlingPlaceholder(e){var i;let r=this.at(e);(null==r?void 0:r.type)==="placeholder"?this.setSelection(e-1,e):(null==(i=null==r?void 0:r.rightSibling)?void 0:i.type)==="placeholder"?this.setSelection(e,e+1):this.position=e,r instanceof l_&&r.isSuggestion&&(r.isSuggestion=!1),this.mathfield.stopCoalescingUndo()}get position(){return this._position}set position(e){this.setSelection(e,e)}get anchor(){return this._anchor}get selectionIsCollapsed(){return this._anchor===this._position}get selectionIsPlaceholder(){return 1===Math.abs(this._anchor-this._position)&&"placeholder"===this.at(Math.max(this._anchor,this._position)).type}collapseSelection(e="forward"){return this._anchor!==this._position&&("backward"===e?this.position=Math.min(this._anchor,this._position):this.position=Math.max(this._anchor,this._position),!0)}get lastOffset(){return this.atoms.length-1}at(e){return this.atoms[e]}offsetOf(e){return this.atoms.indexOf(e)}getSiblingsRange(e){let i=this.at(e),{parent:r}=i;if(!r)return[0,this.lastOffset];let a=i.parent.branch(i.parentBranch);return[this.offsetOf(a[0]),this.offsetOf(a[a.length-1])]}getBranchRange(e,i){let r=this.at(e).branch(i);return[this.offsetOf(r[0]),this.offsetOf(r[r.length-1])]}getCellRange(e){var i,r;this.getParentCell(e);let a=this.at(e);if(a){for(;a&&(null==(i=a.parent)?void 0:i.type)!=="array";)a=a.parent;if((null==(r=null==a?void 0:a.parent)?void 0:r.type)==="array")return[this.offsetOf(a.firstSibling),this.offsetOf(a.lastSibling)]}}getAtoms(e,i,r){let a,o,n=null!=r?r:{};if(o4(e)){if(n=null!=i?i:{},e.ranges.length>1)return e.ranges.reduce((e,i)=>[...e,...this.getAtoms(i,n)],[]);e=e.ranges[0]}if(o0(e)){if(a=e,!o0(i))return[];o=i}else[a,o]=e,0===Object.keys(n).length&&(n=null!=i?i:{});if(!Number.isFinite(a))return[];void 0===n.includeChildren&&(n.includeChildren=!1),a<0&&(a=this.lastOffset-a+1),o<0&&(o=this.lastOffset+o+1);let l=Math.min(a,o),s=Math.max(a,o),c=0===l?0:l+1;if(!n.includeChildren&&1===c&&s===this.lastOffset)return[this.root];let d=[];for(let e=c;e<=s;e++){let i=this.atoms[e];uv(this,i,c,s,n.includeFirstAtoms)&&d.push(i)}return n.includeChildren||(d=d.filter(e=>{let i=!1,{parent:r}=e;for(;r&&!i;)i=uv(this,r,c,s,n.includeFirstAtoms),r=r.parent;return!i})),d}findAtom(e,i=0,r="forward"){let a,o=this.lastOffset;if("forward"===r){for(let r=i;r<=o;r++)if(e(a=this.atoms[r]))return a;for(let r=0;r<i;r++)if(e(a=this.atoms[r]))return a;return}for(let r=i;r>=0;r--)if(e(a=this.atoms[r]))return a;for(let r=o;r>i;r--)if(e(a=this.atoms[r]))return a}extractAtoms(e){var i;let r=this.getAtoms(e);for(let e of(1===r.length&&!r[0].parent&&r[0].isRoot&&(r=(r=r[0]instanceof n0?r[0].rows.flatMap(e=>e.flatMap(e=>e)):[...null!=(i=r[0].body)?i:r[0].children]).filter(e=>"first"!==e.type)),r))e.parent.removeChild(e);return r}deleteAtoms(e){if(null!=e||(e=[0,-1]),this.extractAtoms(e),0===e[0]&&-1===e[1]&&this.root instanceof n0)for(;this.root.rowCount>1;)this.root.removeRow(1);this.position=e[0]}atomToString(e,i){let r=null!=i?i:"latex";if(r.startsWith("latex"))return oG.serialize([e],{expandMacro:"latex-expanded"===r,skipStyles:"latex-unstyled"===r,skipPlaceholders:"latex-without-placeholders"===r,defaultMode:this.mathfield.options.defaultMode});if("math-ml"===r)return dT(e);if("spoken"===r)return dq(e);if("spoken-text"===r){let i=globalThis.MathfieldElement.textToSpeechMarkup;globalThis.MathfieldElement.textToSpeechMarkup="";let r=dq(e);return globalThis.MathfieldElement.textToSpeechMarkup=i,r}if("spoken-ssml"===r||"spoken-ssml-with-highlighting"===r){let i=globalThis.MathfieldElement.textToSpeechMarkup;globalThis.MathfieldElement.textToSpeechMarkup="ssml";let r=dq(e);return globalThis.MathfieldElement.textToSpeechMarkup=i,r}return"typst"===r?uf(e):"plain-text"===r?dH(e,{plain:!0}):"ascii-math"===r?dH(e):(console.error(`MathLive 0.110.10: Unexpected format "${r}`),"")}getValue(e,i,r){let a,o;if(void 0===e)return this.atomToString(this.root,"latex");if("string"==typeof e&&"math-json"!==e)return this.atomToString(this.root,e);if(o0(e)&&o0(i)?(a=[this.normalizeRange([e,i])],o=r):o1(e)?(a=[this.normalizeRange(e)],o=i):o4(e)?(a=e.ranges,o=i):(a=[this.normalizeRange([0,-1])],o=e),null!=o||(o="latex"),"math-json"===o){if(!globalThis.MathfieldElement.computeEngine)return window[Symbol.for("io.cortexjs.compute-engine")]||console.error(`The CortexJS Compute Engine library is not available.
|
|
3488
3488
|
Load the library, for example with:
|
|
3489
|
-
import "https://esm.run/@cortex-js/compute-engine"`),'["Error", "compute-engine-not-available"]';let e=this.getValue({ranges:a},"latex-unstyled");try{let i=globalThis.MathfieldElement.computeEngine.parse(e);return JSON.stringify(i.json)}catch(e){return JSON.stringify(["Error",`'${e.toString()}'`])}}if(o.startsWith("latex")){let e={expandMacro:"latex-expanded"===o,skipStyles:"latex-unstyled"===o,skipPlaceholders:"latex-without-placeholders"===o,defaultMode:this.mathfield.options.defaultMode};return of(a.map(i=>oG.serialize(this.getAtoms(i),e)))}return a.map(e=>this.getAtoms(e).map(e=>this.atomToString(e,o)).join("")).join("")}extendSelectionTo(e,i){return(!!this.mathfield.contentEditable||"none"!==this.mathfield.userSelect)&&this.deferNotifications({selection:!0},()=>{let[r,a]=this.normalizeRange([e,i]),o=new Set(["genfrac","subsup","accent","box","overlap","overunder"]),{parent:n}=this.at(a);if(null!=n&&n.type&&o.has(n.type))for(;null!=n&&n.type&&o.has(n.type)&&uv(this,n,[r,a]);)a=this.offsetOf(n),n=n.parent;for(n=this.at(r).parent;null!=n&&n.type&&o.has(n.type)&&uv(this,n,[r,a]);)r=this.offsetOf(n.leftSibling),n=n.parent;if(null!=(n=this.at(a).parent)&&n.type&&o.has(n.type))for(;null!=n&&n.type&&o.has(n.type)&&uv(this,n,[r,a]);)a=this.offsetOf(n),n=n.parent;this._position=this.normalizeOffset(i),this._selection={ranges:[[r,a]],direction:"none"}})}announce(e,i,r=[]){var a,o;(null==(o=null==(a=this.mathfield.host)?void 0:a.dispatchEvent(new CustomEvent("announce",{detail:{command:e,previousPosition:i,atoms:r},cancelable:!0,bubbles:!0,composed:!0})))||o)&&function(e,i,r,a){let o="";if("plonk"===i){globalThis.MathfieldElement.playSound("plonk"),e.flushInlineShortcutBuffer();return}if("delete"===i)o=uf("deleted: ",a);else if("focus"===i||i.includes("move"))o=function(e,i){if(Number.isNaN(i))return"";let r=e.at(i);if(!r||r.treeDepth<=e.at(e.position).treeDepth)return"";let a="",o=r.parent,n=e.at(e.position).parent;for(;o!==e.root&&o!==n;)a+=`out of ${ug(o)};`,o=o.parent;return a}(e.model,r)+function(e){if(!e.selectionIsCollapsed)return`selected: ${uf(e.getAtoms(e.selection))}`;let i="",r=e.at(e.position);if(r.isFirstSibling&&(i=`start of ${ug(r)}: `),r.isLastSibling){if(!r.isFirstSibling){if(!r.parent.parent)return`${uf(r)}; end of mathfield`;i=`${uf(r)}; end of ${ug(r)}`}}else i+=uf(r);return i}(e.model);else if("replacement"===i)o=uf(e.model.at(e.model.position));else if("line"===i){let i=uf(e.model.root);e.keyboardDelegate.setAriaLabel(i)}else o=a?uf(i+" ",a):i;if(o&&e.ariaLiveText){let i=e.ariaLiveText.textContent.includes(" ")?" ":" ";e.ariaLiveText.textContent=o+i}}(this.mathfield,e,i,r)}deferNotifications(e,i){let r=this._selection,a=this._anchor,o=this._position,n=this.silenceNotifications;this.silenceNotifications=!0;let l=this.root.changeCounter;i(),this.silenceNotifications=n;let s=a!==this._anchor||o!==this._position||"different"===function(e,i){if(e.direction===i.direction){let o=e.ranges.length;if(i.ranges.length===o){var r,a;let n=0;for(;n<o&&"equal"==(r=e.ranges[n],a=i.ranges[n],r[0]===a[0]&&r[1]===a[1]?"equal":"different");)n++;return n===o?"equal":"different"}}return"different"}(this._selection,r);e.selection&&s&&this.selectionDidChange();let c=this.root.changeCounter!==l;return e.content&&c&&this.contentDidChange({inputType:e.type}),c||s}normalizeOffset(e){return e>0?e=Math.min(e,this.lastOffset):e<0&&(e=this.lastOffset+e+1),e}normalizeRange(e){let[i,r]=e;return(i=this.normalizeOffset(i))<(r=this.normalizeOffset(r))?[i,r]:[r,i]}normalizeSelection(e,i){var r;let a;if(o0(e)){let r=this.normalizeOffset(e);if(o0(i)){let e=this.normalizeOffset(i);a=r<=e?{ranges:[[r,e]],direction:"none"}:{ranges:[[e,r]],direction:"backward"}}else a={ranges:[[r,r]],direction:"none"}}else if(o1(e)){let i=this.normalizeOffset(e[0]),r=this.normalizeOffset(e[1]);a=i<=r?{ranges:[[i,r]],direction:"none"}:{ranges:[[r,i]],direction:"backward"}}else o4(e)&&(a={ranges:e.ranges.map(e=>this.normalizeRange(e)),direction:null!=(r=e.direction)?r:"none"});return a}get parentEnvironment(){let e=this.at(this.position).parent;if(e){for(;e.parent&&"array"!==e.type;)e=e.parent;if("array"===e.type)return e}}get parentCell(){return this.getParentCell(this.position)}getParentCell(e){var i,r;let a=this.at(e);if(a){for(;a&&(null==(i=a.parent)?void 0:i.type)!=="array";)a=a.parent;if((null==(r=null==a?void 0:a.parent)?void 0:r.type)==="array")return a.parentBranch}}contentWillChange(e={}){if(this.silenceNotifications||!this.mathfield)return!0;let i=this.silenceNotifications;this.silenceNotifications=!0;let r=this.mathfield.onContentWillChange(e);return this.silenceNotifications=i,r}contentDidChange(e){var i;if(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(c4(this.mathfield)),this.silenceNotifications||!(null!=(i=this.mathfield)&&i.host))return;let r=this.silenceNotifications;this.silenceNotifications=!0,setTimeout(()=>{var i;this.mathfield&&nl(this.mathfield)&&this.mathfield.host&&this.mathfield.host.dispatchEvent(new InputEvent("input",g(f({},e),{data:e.data?e.data:null!=(i=e.inputType)?i:"",bubbles:!0,composed:!0})))},0),this.silenceNotifications=r}selectionDidChange(){if(!this.mathfield)return;let e=this.silenceNotifications;e||(this.silenceNotifications=!0,this.mathfield.onSelectionDidChange()),this.silenceNotifications=e}};function uy(e,i,r,a,o){let n=e.offsetOf(i);if(n<r||n>a)return!1;if(!i.hasChildren)return!0;let l=o?i.firstChild:ux(i);if(!l)return!0;let s=o?i.lastChild:u_(i);if(!s)return!0;let c=e.offsetOf(l);if(c>=r&&c<=a){let i=e.offsetOf(s);if(i>=r&&i<=a)return!0}return!1}function uv(e,i,r){if(!(null!=i&&i.hasChildren))return!1;let[a,o]=r,n=ux(i);if(!n)return!1;let l=u_(i);if(!l)return!1;let s=e.offsetOf(n),c=e.offsetOf(l);return s>=a&&s<=o&&c>=s&&c<=o}function ux(e){for(let i of e.children)if("first"!==i.type)return i}function u_(e){let{children:i}=e;for(let e=i.length-1;e>=0;e--)if("first"!==i[e].type)return i[e]}sN({deleteAll:e=>e.contentWillChange({inputType:"deleteContent"})&&cx(e,[0,-1],"deleteContent"),deleteForward:e=>!!e.mathfield.isSelectionEditable&&!!e.contentWillChange({inputType:"deleteContentForward"})&&(e.selectionIsCollapsed?e.deferNotifications({content:!0,selection:!0,type:"deleteContentForward"},()=>{var i,r,a;let o=e.at(e.position).rightSibling;if(o&&cv(e,"forward",o))return;if(o){if(e.at(e.position).isLastSibling&&cv(e,"forward",o.parent,o.parentBranch))return}else{if((o=e.at(e.position)).isLastSibling&&cv(e,"forward",o.parent,o.parentBranch))return;o=void 0}if(e.position===e.lastOffset||!o)return void e.announce("plonk");let n=o.parent;n.removeChild(o);let l=null==(i=e.at(e.position))?void 0:i.rightSibling;for(;(null==l?void 0:l.type)==="subsup";)l.parent.removeChild(l),l=null==(r=e.at(e.position))?void 0:r.rightSibling;if(e.announce("delete",void 0,[o]),"latexgroup"===n.type&&n.hasEmptyBranch("body")){let i=e.offsetOf(n.leftSibling);null==(a=n.parent)||a.removeChild(n),e.position=Math.max(0,i)}e.root.hasEmptyBranch("body")&&e.mathfield.flushInlineShortcutBuffer()}):cx(e,oQ(e.selection),"deleteContentForward")),deleteBackward:e=>!!e.mathfield.isSelectionEditable&&!!e.contentWillChange({inputType:"deleteContentBackward"})&&(e.selectionIsCollapsed?e.deferNotifications({content:!0,selection:!0,type:"deleteContentBackward"},()=>{var i;let r=e.at(e.position);if(r&&cv(e,"backward",r))return;if(null!=r&&r.isFirstSibling){if(cv(e,"backward",r.parent,r.parentBranch))return;r=null}if(!r)return void e.announce("plonk");let a=r.parent;if(e.position=e.offsetOf(r.leftSibling),a.removeChild(r),e.announce("delete",void 0,[r]),"latexgroup"===a.type&&a.hasEmptyBranch("body")){let r=e.offsetOf(a.leftSibling);null==(i=a.parent)||i.removeChild(a),e.position=Math.max(0,r)}e.root.hasEmptyBranch("body")&&e.mathfield.flushInlineShortcutBuffer()}):cx(e,oQ(e.selection),"deleteContentBackward")),deleteNextWord:e=>e.contentWillChange({inputType:"deleteWordForward"})&&c_(e,"forward",{delete:!0}),deletePreviousWord:e=>e.contentWillChange({inputType:"deleteWordBackward"})&&c_(e,"backward",{delete:!0}),deleteToGroupStart:e=>{if(!e.contentWillChange({inputType:"deleteSoftLineBackward"}))return!1;let i=e.offsetOf(e.at(e.position).firstSibling);return i===e.position?(e.announce("plonk"),!1):(e.deferNotifications({content:!0,selection:!0,type:"deleteSoftLineBackward"},()=>e.deleteAtoms([e.anchor,i])),e.position=i,!0)},deleteToGroupEnd:e=>{if(!e.contentWillChange({inputType:"deleteSoftLineForward"}))return!1;let i=e.offsetOf(e.at(e.position).lastSibling);return i===e.position?(e.announce("plonk"),!1):(e.deferNotifications({content:!0,selection:!0,type:"deleteSoftLineForward"},()=>e.deleteAtoms([e.anchor,i])),!0)},deleteToMathFieldStart:e=>e.contentWillChange({inputType:"deleteHardLineBackward"})&&cx(e,[e.anchor,0],"deleteHardLineBackward"),deleteToMathFieldEnd:e=>e.contentWillChange({inputType:"deleteHardLineForward"})&&cx(e,[e.anchor,-1],"deleteHardLineForward")},{target:"model",audioFeedback:"delete",canUndo:!0,changeContent:!0,changeSelection:!0});var uw=`<svg xmlns="http://www.w3.org/2000/svg" style="width: 21px;" viewBox="0 0 576 512" role="img" aria-label="${N("tooltip.toggle virtual keyboard")}"><path d="M528 64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h480c26.51 0 48-21.49 48-48V112c0-26.51-21.49-48-48-48zm16 336c0 8.823-7.177 16-16 16H48c-8.823 0-16-7.177-16-16V112c0-8.823 7.177-16 16-16h480c8.823 0 16 7.177 16 16v288zM168 268v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm-336 80v-24c0-6.627-5.373-12-12-12H84c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm384 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zM120 188v-24c0-6.627-5.373-12-12-12H84c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm-96 152v-8c0-6.627-5.373-12-12-12H180c-6.627 0-12 5.373-12 12v8c0 6.627 5.373 12 12 12h216c6.627 0 12-5.373 12-12z"/></svg>`,uk=`<svg xmlns="http://www.w3.org/2000/svg" style="height: 18px;" viewBox="0 0 448 512" role="img" aria-label="${N("tooltip.menu")}"><path d="M0 96C0 78.3 14.3 64 32 64H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z"/></svg>`,uM=class e{constructor(e,i){var r,a,o,n,l,s;let c,d,u,h,p,m,b;this.focusBlurInProgress=!1,this.programmaticFocusInProgress=!1,this.connectedToVirtualKeyboard=!1,this.options=f(g(f({},cl()),{macros:e_(),registers:f({},oj)}),co(i)),this.eventController=new AbortController;let y=this.eventController.signal;i.eventSink&&(this.host=i.eventSink),this.element=e,e.mathfield=this,this.blurred=!0,this.keystrokeCaptionVisible=!1,this.suggestionIndex=0,this.inlineShortcutBuffer=[],this.inlineShortcutBufferFlushTimer=0,this.scientificNotationTimer=0,this.defaultStyle={},this.styleBias="left","inline-math"===this.options.defaultMode?this.element.classList.add("ML__is-inline"):this.element.classList.remove("ML__is-inline"),this.dirty=!1;let v=null!=(a=null!=(r=i.value)?r:this.element.textContent)?a:"";v=v.trim();let x=cs(this.options),_=ll(v,{context:this.context}),w;w=1===_.length&&_[0].isRoot?_[0]:new oG({type:"root",mode:x,body:_}),this.model=new ub(this,x,w),this.undoManager=new cy(this.model);let k=[];if(k.push("<span contenteditable=true role=textbox aria-autocomplete=none aria-multiline=false part=keyboard-sink class=ML__keyboard-sink autocapitalize=off autocomplete=off autocorrect=off spellcheck=false inputmode=none tabindex=0></span>"),k.push('<span part=container class=ML__container style="visibility:hidden">'),k.push("<span part=content class=ML__content>"),k.push(s$(this)),k.push("</span>"),k.push("<div class=ML__toggles>"),window.mathVirtualKeyboard&&(k.push(`<div part=virtual-keyboard-toggle class=ML__virtual-keyboard-toggle role=button ${this.hasEditableContent?"":'style="display:none;"'} data-l10n-tooltip="tooltip.toggle virtual keyboard">`),k.push(uw),k.push("</div>")),k.push('<div part=menu-toggle class=ML__menu-toggle role=button data-l10n-tooltip="tooltip.menu">'),k.push(uk),k.push("</div>"),k.push("</div>"),k.push("</span>"),k.push("<span class=ML__sr-only>"),k.push("<span role=status aria-live=assertive aria-atomic=true></span>"),k.push("</span>"),this.element.innerHTML=globalThis.MathfieldElement.createHTML(k.join("")),!this.element.children)return void console.error("%cMathLive 0.110.9: Something went wrong and the mathfield could not be created.%c\nIf you are using Vue, this may be because you are using the runtime-only build of Vue. Make sure to include `runtimeCompiler: true` in your Vue configuration. There may a warning from Vue in the log above.","color:red;font-family:system-ui;font-size:1.2rem;font-weight:bold","color:inherit;font-family:system-ui;font-size:inherit;font-weight:inherit");this._l10Subscription=I.subscribe(()=>I.update(this.element)),I.update(this.element),this.container=this.element.querySelector("[part=container]"),this.field=this.container.querySelector("[part=content]"),this.field.addEventListener("click",e=>e.stopImmediatePropagation(),{capture:!1,signal:y}),this.field.addEventListener("wheel",this,{passive:!1,signal:y});let M=this.element;if("PointerEvent"in window?M.addEventListener("pointerdown",this,{signal:y}):M.addEventListener("mousedown",this,{signal:y}),this.host){let e=e=>{e.target===this.host&&this.handleEvent(e)};"PointerEvent"in window?this.host.addEventListener("pointerdown",e,{signal:y}):this.host.addEventListener("mousedown",e,{signal:y})}let S=this.element.querySelector("[part=virtual-keyboard-toggle]");null==S||S.addEventListener("pointerdown",e=>{e.currentTarget===S&&(window.mathVirtualKeyboard.visible?window.mathVirtualKeyboard.hide():(window.mathVirtualKeyboard.show({animate:!0}),window.mathVirtualKeyboard.update(c4(this)),setTimeout(()=>this.scrollIntoView(),300)),e.preventDefault(),e.stopPropagation(),this.hasFocus()||this.focus({preventScroll:!0}))},{signal:y}),this.field.addEventListener("contextmenu",this,{signal:y});let L=this.element.querySelector("[part=menu-toggle]");null==L||L.addEventListener("pointerdown",e=>{if(e.currentTarget!==L)return;let i=this.menu;if("closed"!==i.state)return;this.element.classList.add("tracking");let r=L.getBoundingClientRect();i.modifiers=l8(e),i.show({target:L,location:{x:r.left,y:r.bottom},onDismiss:()=>this.element.classList.remove("tracking")}),e.preventDefault(),e.stopPropagation()},{signal:y}),(this.disabled||this.readOnly&&!this.hasEditableContent||"none"===this.userSelect)&&(L.style.display="none"),this.ariaLiveText=null!=(o=this.element.querySelector("[role=status]"))?o:void 0,this.keyboardDelegate=(n=this.element.querySelector(".ML__keyboard-sink"),l=this.element,s=this,c=null,d=null,u=!1,h=!1,p=!1,b=(m=new AbortController).signal,n.addEventListener("keydown",e=>{if(u||"Process"===e.key||"CapsLock"===e.code||/(Control|Meta|Alt|Shift)(Left|Right)/.test(e.code)){c=null;return}c=e,d=null,s.onKeystroke(e)?n.textContent="":c=null},{capture:!0,signal:b}),n.addEventListener("keypress",e=>{u||(c&&d&&s.onKeystroke(c),d=e)},{capture:!0,signal:b}),n.addEventListener("compositionstart",e=>{n.textContent="",u=!0,s.onCompositionStart(e.data)},{capture:!0,signal:b}),n.addEventListener("compositionupdate",e=>{u&&s.onCompositionUpdate(e.data)},{capture:!0,signal:b}),n.addEventListener("compositionend",e=>{n.textContent="",u&&(u=!1,s.onCompositionEnd(e.data))},{capture:!0,signal:b}),n.addEventListener("beforeinput",e=>e.stopImmediatePropagation(),{signal:b}),n.addEventListener("input",e=>{var i;if(!u&&(n.textContent="","insertCompositionText"!==e.inputType)){if("insertFromPaste"===e.inputType){e.preventDefault(),e.stopPropagation();return}s.onInput(null!=(i=e.data)?i:""),e.preventDefault(),e.stopPropagation()}},{signal:b}),n.addEventListener("paste",e=>{n.focus({preventScroll:!0}),n.textContent="",s.onPaste(e)||e.preventDefault(),e.stopImmediatePropagation()},{signal:b}),n.addEventListener("cut",e=>s.onCut(e),{capture:!0,signal:b}),n.addEventListener("copy",e=>s.onCopy(e),{capture:!0,signal:b}),n.addEventListener("blur",e=>{var i,r;if((null==(r=null==(i=e.relatedTarget)?void 0:i._mathfield)?void 0:r.element)===l){n.focus({preventScroll:!0}),e.preventDefault(),e.stopPropagation();return}let a=!1,o=e.relatedTarget;for(;o;){if(o.classList.contains("ML__keyboard")){a=!0;break}o=o.parentElement}if(a){n.focus({preventScroll:!0}),e.preventDefault(),e.stopPropagation();return}let u=se.state;if("open"===u||"opening"===u||e.relatedTarget===e.target.getRootNode().host){e.preventDefault(),e.stopPropagation();return}p||h||(p=!0,c=null,d=null,s.onBlur(),p=!1)},{capture:!0,signal:b}),n.addEventListener("focus",e=>{p||h||(h=!0,s.onFocus(),h=!1)},{capture:!0,signal:b}),{dispose:()=>m.abort(),cancelComposition:()=>{u&&("function"==typeof n.blur&&n.blur(),requestAnimationFrame(()=>n.focus({preventScroll:!0})))},blur:()=>{"function"==typeof n.blur&&(p=!0,n.blur(),p=!1)},focus:()=>{h||"function"!=typeof n.focus||(h=!0,n.focus({preventScroll:!0}),h=!1)},hasFocus:()=>l9()===n,setAriaLabel:e=>n.setAttribute("aria-label",e),setValue:e=>{var i;n.textContent!==e&&(n.textContent=e,n.style.left="-1000px",null==(i=window.getSelection())||i.selectAllChildren(n))},moveTo:(e,i)=>{n.style.top=`${i}px`,n.style.left=`${e}px`}}),window.addEventListener("resize",this,{signal:y}),document.addEventListener("scroll",this,{signal:y}),this.resizeObserver=new ResizeObserver(e=>{if(this.resizeObserverStarted){this.resizeObserverStarted=!1;return}this.updateToggleLayout(),sB(this)}),this.resizeObserverStarted=!0,this.resizeObserver.observe(this.field),this.resizeObserver.observe(this.container),setTimeout(()=>this.updateToggleLayout(),100),window.mathVirtualKeyboard.addEventListener("virtual-keyboard-toggle",this,{signal:y}),A&&!I.locale.startsWith(A.locale)&&B(I.locale),"ready"!==sT&&document.fonts.ready.then(()=>sO(this)),e.querySelector("[part=container]").style.removeProperty("visibility"),this.undoManager.startRecording(),this.undoManager.snapshot("set-value"),sB(this)}connectToVirtualKeyboard(){this.connectedToVirtualKeyboard||(this.connectedToVirtualKeyboard=!0,window.addEventListener("message",this,{signal:this.eventController.signal}),window.mathVirtualKeyboard.connect(),window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(c4(this)),dt(this))}disconnectFromVirtualKeyboard(){this.connectedToVirtualKeyboard&&(window.removeEventListener("message",this),window.mathVirtualKeyboard.disconnect(),this.connectedToVirtualKeyboard=!1,de())}showMenu(e){var i,r;let a=null!=(r=null!=(i=null==e?void 0:e.location)?i:ns(this.field))?r:void 0,o=null==e?void 0:e.modifiers,n=this.element.querySelector("[part=container]");return this._menu.show({target:n,location:a,modifiers:o})}get colorMap(){return e=>{var i,r,a;return null!=(a=null==(r=(i=this.options).colorMap)?void 0:r.call(i,e))?a:U(e)}}get backgroundColorMap(){return e=>{var i,r,a,o,n,l;return null!=(l=null!=(n=null==(r=(i=this.options).backgroundColorMap)?void 0:r.call(i,e))?n:null==(o=(a=this.options).colorMap)?void 0:o.call(a,e))?l:J(e)}}get smartFence(){var e;return null!=(e=this.options.smartFence)&&e}get readOnly(){var e;return null!=(e=this.options.readOnly)&&e}get disabled(){var e,i;return null!=(i=null==(e=this.host)?void 0:e.disabled)&&i}get contentEditable(){return!!this.host&&"false"!==this.host.getAttribute("contenteditable")}get userSelect(){if(!this.host)return"";let e=getComputedStyle(this.host);return e.getPropertyValue("user-select")||e.getPropertyValue("-webkit-user-select")}get hasEditableContent(){return!this.disabled&&!!this.contentEditable&&(!this.readOnly||this.hasEditablePrompts)}get hasEditablePrompts(){return this.readOnly&&!this.disabled&&this.contentEditable&&void 0!==this.model.findAtom(e=>"prompt"===e.type&&!e.locked)}get isSelectionEditable(){if(this.disabled||!this.contentEditable)return!1;if(!this.readOnly)return!0;let e=this.model.at(this.model.anchor),i=this.model.at(this.model.position),r=oG.commonAncestor(e,i);return!!((null==r?void 0:r.type)==="prompt"||null!=r&&r.parentPrompt)}get letterShapeStyle(){var e;return null!=(e=this.options.letterShapeStyle)?e:"tex"}get minFontScale(){return this.options.minFontScale}get maxMatrixCols(){return this.options.maxMatrixCols}queryStyle(e){let i=ss(this,e);"verbatimColor"in i&&delete i.verbatimColor,"verbatimBackgroundColor"in i&&delete i.verbatimBackgroundColor;let r=Object.keys(i).length;if(0===r)return"all";if(r>1){for(let e of Object.keys(i)){let r=this.queryStyle({[e]:i[e]});if("none"===r)return"none";if("some"===r)return"some"}return"all"}let a=Object.keys(i)[0],o=i[a];if(this.model.selectionIsCollapsed)return sd(this)[a]===o?"all":"none";let n=this.model.getAtoms(this.model.selection,{includeChildren:!0}),l=n.length;if(0===l)return"none";let s=0;for(let e of n){if("first"===e.type){l-=1;continue}e.style[a]===o&&(s+=1)}return 0===s?"none":s===l?"all":"some"}get keybindings(){var e,i;if(this._keybindings)return this._keybindings;let[r,a]=function(e,i){let r=[],a=[];for(let o of e)try{let e=function(e,i){if(e.ifPlatform&&!/^!?(macos|windows|android|ios|chromeos|other)$/.test(e.ifPlatform))throw Error(`Unexpected platform "${e.ifPlatform}" for keybinding ${e.key}`);if(void 0!==e.ifLayout&&(0===i.score||!e.ifLayout.includes(i.id)))return;let r=C(e.key),a=e.ifPlatform;if(r.cmd){if(a&&"macos"!==a&&"ios"!==a)throw Error('Unexpected "cmd" modifier with platform "'+a+`"
|
|
3489
|
+
import "https://esm.run/@cortex-js/compute-engine"`),'["Error", "compute-engine-not-available"]';let e=this.getValue({ranges:a},"latex-unstyled");try{let i=globalThis.MathfieldElement.computeEngine.parse(e);return JSON.stringify(i.json)}catch(e){return JSON.stringify(["Error",`'${e.toString()}'`])}}if(o.startsWith("latex")){let e={expandMacro:"latex-expanded"===o,skipStyles:"latex-unstyled"===o,skipPlaceholders:"latex-without-placeholders"===o,defaultMode:this.mathfield.options.defaultMode};return of(a.map(i=>oG.serialize(this.getAtoms(i),e)))}return a.map(e=>this.getAtoms(e).map(e=>this.atomToString(e,o)).join("")).join("")}extendSelectionTo(e,i){return(!!this.mathfield.contentEditable||"none"!==this.mathfield.userSelect)&&this.deferNotifications({selection:!0},()=>{let[r,a]=this.normalizeRange([e,i]),o=new Set(["genfrac","subsup","accent","box","overlap","overunder"]),{parent:n}=this.at(a);if(null!=n&&n.type&&o.has(n.type))for(;null!=n&&n.type&&o.has(n.type)&&ux(this,n,[r,a]);)a=this.offsetOf(n),n=n.parent;for(n=this.at(r).parent;null!=n&&n.type&&o.has(n.type)&&ux(this,n,[r,a]);)r=this.offsetOf(n.leftSibling),n=n.parent;if(null!=(n=this.at(a).parent)&&n.type&&o.has(n.type))for(;null!=n&&n.type&&o.has(n.type)&&ux(this,n,[r,a]);)a=this.offsetOf(n),n=n.parent;this._position=this.normalizeOffset(i),this._selection={ranges:[[r,a]],direction:"none"}})}announce(e,i,r=[]){var a,o;(null==(o=null==(a=this.mathfield.host)?void 0:a.dispatchEvent(new CustomEvent("announce",{detail:{command:e,previousPosition:i,atoms:r},cancelable:!0,bubbles:!0,composed:!0})))||o)&&function(e,i,r,a){let o="";if("plonk"===i){globalThis.MathfieldElement.playSound("plonk"),e.flushInlineShortcutBuffer();return}if("delete"===i)o=ug("deleted: ",a);else if("focus"===i||i.includes("move"))o=function(e,i){if(Number.isNaN(i))return"";let r=e.at(i);if(!r||r.treeDepth<=e.at(e.position).treeDepth)return"";let a="",o=r.parent,n=e.at(e.position).parent;for(;o!==e.root&&o!==n;)a+=`out of ${ub(o)};`,o=o.parent;return a}(e.model,r)+function(e){if(!e.selectionIsCollapsed)return`selected: ${ug(e.getAtoms(e.selection))}`;let i="",r=e.at(e.position);if(r.isFirstSibling&&(i=`start of ${ub(r)}: `),r.isLastSibling){if(!r.isFirstSibling){if(!r.parent.parent)return`${ug(r)}; end of mathfield`;i=`${ug(r)}; end of ${ub(r)}`}}else i+=ug(r);return i}(e.model);else if("replacement"===i)o=ug(e.model.at(e.model.position));else if("line"===i){let i=ug(e.model.root);e.keyboardDelegate.setAriaLabel(i)}else o=a?ug(i+" ",a):i;if(o&&e.ariaLiveText){let i=e.ariaLiveText.textContent.includes(" ")?" ":" ";e.ariaLiveText.textContent=o+i}}(this.mathfield,e,i,r)}deferNotifications(e,i){let r=this._selection,a=this._anchor,o=this._position,n=this.silenceNotifications;this.silenceNotifications=!0;let l=this.root.changeCounter;i(),this.silenceNotifications=n;let s=a!==this._anchor||o!==this._position||"different"===function(e,i){if(e.direction===i.direction){let o=e.ranges.length;if(i.ranges.length===o){var r,a;let n=0;for(;n<o&&"equal"==(r=e.ranges[n],a=i.ranges[n],r[0]===a[0]&&r[1]===a[1]?"equal":"different");)n++;return n===o?"equal":"different"}}return"different"}(this._selection,r);e.selection&&s&&this.selectionDidChange();let c=this.root.changeCounter!==l;return e.content&&c&&this.contentDidChange({inputType:e.type}),c||s}normalizeOffset(e){return e>0?e=Math.min(e,this.lastOffset):e<0&&(e=this.lastOffset+e+1),e}normalizeRange(e){let[i,r]=e;return(i=this.normalizeOffset(i))<(r=this.normalizeOffset(r))?[i,r]:[r,i]}normalizeSelection(e,i){var r;let a;if(o0(e)){let r=this.normalizeOffset(e);if(o0(i)){let e=this.normalizeOffset(i);a=r<=e?{ranges:[[r,e]],direction:"none"}:{ranges:[[e,r]],direction:"backward"}}else a={ranges:[[r,r]],direction:"none"}}else if(o1(e)){let i=this.normalizeOffset(e[0]),r=this.normalizeOffset(e[1]);a=i<=r?{ranges:[[i,r]],direction:"none"}:{ranges:[[r,i]],direction:"backward"}}else o4(e)&&(a={ranges:e.ranges.map(e=>this.normalizeRange(e)),direction:null!=(r=e.direction)?r:"none"});return a}get parentEnvironment(){let e=this.at(this.position).parent;if(e){for(;e.parent&&"array"!==e.type;)e=e.parent;if("array"===e.type)return e}}get parentCell(){return this.getParentCell(this.position)}getParentCell(e){var i,r;let a=this.at(e);if(a){for(;a&&(null==(i=a.parent)?void 0:i.type)!=="array";)a=a.parent;if((null==(r=null==a?void 0:a.parent)?void 0:r.type)==="array")return a.parentBranch}}contentWillChange(e={}){if(this.silenceNotifications||!this.mathfield)return!0;let i=this.silenceNotifications;this.silenceNotifications=!0;let r=this.mathfield.onContentWillChange(e);return this.silenceNotifications=i,r}contentDidChange(e){var i;if(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(c2(this.mathfield)),this.silenceNotifications||!(null!=(i=this.mathfield)&&i.host))return;let r=this.silenceNotifications;this.silenceNotifications=!0,setTimeout(()=>{var i;this.mathfield&&nl(this.mathfield)&&this.mathfield.host&&this.mathfield.host.dispatchEvent(new InputEvent("input",g(f({},e),{data:e.data?e.data:null!=(i=e.inputType)?i:"",bubbles:!0,composed:!0})))},0),this.silenceNotifications=r}selectionDidChange(){if(!this.mathfield)return;let e=this.silenceNotifications;e||(this.silenceNotifications=!0,this.mathfield.onSelectionDidChange()),this.silenceNotifications=e}};function uv(e,i,r,a,o){let n=e.offsetOf(i);if(n<r||n>a)return!1;if(!i.hasChildren)return!0;let l=o?i.firstChild:u_(i);if(!l)return!0;let s=o?i.lastChild:uw(i);if(!s)return!0;let c=e.offsetOf(l);if(c>=r&&c<=a){let i=e.offsetOf(s);if(i>=r&&i<=a)return!0}return!1}function ux(e,i,r){if(!(null!=i&&i.hasChildren))return!1;let[a,o]=r,n=u_(i);if(!n)return!1;let l=uw(i);if(!l)return!1;let s=e.offsetOf(n),c=e.offsetOf(l);return s>=a&&s<=o&&c>=s&&c<=o}function u_(e){for(let i of e.children)if("first"!==i.type)return i}function uw(e){let{children:i}=e;for(let e=i.length-1;e>=0;e--)if("first"!==i[e].type)return i[e]}sq({deleteAll:e=>e.contentWillChange({inputType:"deleteContent"})&&c_(e,[0,-1],"deleteContent"),deleteForward:e=>!!e.mathfield.isSelectionEditable&&!!e.contentWillChange({inputType:"deleteContentForward"})&&(e.selectionIsCollapsed?e.deferNotifications({content:!0,selection:!0,type:"deleteContentForward"},()=>{var i,r,a;let o=e.at(e.position).rightSibling;if(o&&cx(e,"forward",o))return;if(o){if(e.at(e.position).isLastSibling&&cx(e,"forward",o.parent,o.parentBranch))return}else{if((o=e.at(e.position)).isLastSibling&&cx(e,"forward",o.parent,o.parentBranch))return;o=void 0}if(e.position===e.lastOffset||!o)return void e.announce("plonk");let n=o.parent;n.removeChild(o);let l=null==(i=e.at(e.position))?void 0:i.rightSibling;for(;(null==l?void 0:l.type)==="subsup";)l.parent.removeChild(l),l=null==(r=e.at(e.position))?void 0:r.rightSibling;if(e.announce("delete",void 0,[o]),"latexgroup"===n.type&&n.hasEmptyBranch("body")){let i=e.offsetOf(n.leftSibling);null==(a=n.parent)||a.removeChild(n),e.position=Math.max(0,i)}e.root.hasEmptyBranch("body")&&e.mathfield.flushInlineShortcutBuffer()}):c_(e,oQ(e.selection),"deleteContentForward")),deleteBackward:e=>!!e.mathfield.isSelectionEditable&&!!e.contentWillChange({inputType:"deleteContentBackward"})&&(e.selectionIsCollapsed?e.deferNotifications({content:!0,selection:!0,type:"deleteContentBackward"},()=>{var i;let r=e.at(e.position);if(r&&cx(e,"backward",r))return;if(null!=r&&r.isFirstSibling){if(cx(e,"backward",r.parent,r.parentBranch))return;r=null}if(!r)return void e.announce("plonk");let a=r.parent;if(e.position=e.offsetOf(r.leftSibling),a.removeChild(r),e.announce("delete",void 0,[r]),"latexgroup"===a.type&&a.hasEmptyBranch("body")){let r=e.offsetOf(a.leftSibling);null==(i=a.parent)||i.removeChild(a),e.position=Math.max(0,r)}e.root.hasEmptyBranch("body")&&e.mathfield.flushInlineShortcutBuffer()}):c_(e,oQ(e.selection),"deleteContentBackward")),deleteNextWord:e=>e.contentWillChange({inputType:"deleteWordForward"})&&cw(e,"forward",{delete:!0}),deletePreviousWord:e=>e.contentWillChange({inputType:"deleteWordBackward"})&&cw(e,"backward",{delete:!0}),deleteToGroupStart:e=>{if(!e.contentWillChange({inputType:"deleteSoftLineBackward"}))return!1;let i=e.offsetOf(e.at(e.position).firstSibling);return i===e.position?(e.announce("plonk"),!1):(e.deferNotifications({content:!0,selection:!0,type:"deleteSoftLineBackward"},()=>e.deleteAtoms([e.anchor,i])),e.position=i,!0)},deleteToGroupEnd:e=>{if(!e.contentWillChange({inputType:"deleteSoftLineForward"}))return!1;let i=e.offsetOf(e.at(e.position).lastSibling);return i===e.position?(e.announce("plonk"),!1):(e.deferNotifications({content:!0,selection:!0,type:"deleteSoftLineForward"},()=>e.deleteAtoms([e.anchor,i])),!0)},deleteToMathFieldStart:e=>e.contentWillChange({inputType:"deleteHardLineBackward"})&&c_(e,[e.anchor,0],"deleteHardLineBackward"),deleteToMathFieldEnd:e=>e.contentWillChange({inputType:"deleteHardLineForward"})&&c_(e,[e.anchor,-1],"deleteHardLineForward")},{target:"model",audioFeedback:"delete",canUndo:!0,changeContent:!0,changeSelection:!0});var uk=`<svg xmlns="http://www.w3.org/2000/svg" style="width: 21px;" viewBox="0 0 576 512" role="img" aria-label="${N("tooltip.toggle virtual keyboard")}"><path d="M528 64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h480c26.51 0 48-21.49 48-48V112c0-26.51-21.49-48-48-48zm16 336c0 8.823-7.177 16-16 16H48c-8.823 0-16-7.177-16-16V112c0-8.823 7.177-16 16-16h480c8.823 0 16 7.177 16 16v288zM168 268v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm-336 80v-24c0-6.627-5.373-12-12-12H84c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm384 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zM120 188v-24c0-6.627-5.373-12-12-12H84c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm-96 152v-8c0-6.627-5.373-12-12-12H180c-6.627 0-12 5.373-12 12v8c0 6.627 5.373 12 12 12h216c6.627 0 12-5.373 12-12z"/></svg>`,uM=`<svg xmlns="http://www.w3.org/2000/svg" style="height: 18px;" viewBox="0 0 448 512" role="img" aria-label="${N("tooltip.menu")}"><path d="M0 96C0 78.3 14.3 64 32 64H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z"/></svg>`,uS=class e{constructor(e,i){var r,a,o,n,l,s;let c,d,u,h,p,m,b;this.focusBlurInProgress=!1,this.programmaticFocusInProgress=!1,this.connectedToVirtualKeyboard=!1,this.options=f(g(f({},cs()),{macros:e_(),registers:f({},oj)}),cn(i)),this.eventController=new AbortController;let y=this.eventController.signal;i.eventSink&&(this.host=i.eventSink),this.element=e,e.mathfield=this,this.blurred=!0,this.keystrokeCaptionVisible=!1,this.suggestionIndex=0,this.inlineShortcutBuffer=[],this.inlineShortcutBufferFlushTimer=0,this.scientificNotationTimer=0,this.defaultStyle={},this.styleBias="left","inline-math"===this.options.defaultMode?this.element.classList.add("ML__is-inline"):this.element.classList.remove("ML__is-inline"),this.dirty=!1;let v=null!=(a=null!=(r=i.value)?r:this.element.textContent)?a:"";v=v.trim();let x=cc(this.options),_=ls(v,{context:this.context}),w;w=1===_.length&&_[0].isRoot?_[0]:new oG({type:"root",mode:x,body:_}),this.model=new uy(this,x,w),this.undoManager=new cv(this.model);let k=[];if(k.push("<span contenteditable=true role=textbox aria-autocomplete=none aria-multiline=false part=keyboard-sink class=ML__keyboard-sink autocapitalize=off autocomplete=off autocorrect=off spellcheck=false inputmode=none tabindex=0></span>"),k.push('<span part=container class=ML__container style="visibility:hidden">'),k.push("<span part=content class=ML__content>"),k.push(sP(this)),k.push("</span>"),k.push("<div class=ML__toggles>"),window.mathVirtualKeyboard&&(k.push(`<div part=virtual-keyboard-toggle class=ML__virtual-keyboard-toggle role=button ${this.hasEditableContent?"":'style="display:none;"'} data-l10n-tooltip="tooltip.toggle virtual keyboard">`),k.push(uk),k.push("</div>")),k.push('<div part=menu-toggle class=ML__menu-toggle role=button data-l10n-tooltip="tooltip.menu">'),k.push(uM),k.push("</div>"),k.push("</div>"),k.push("</span>"),k.push("<span class=ML__sr-only>"),k.push("<span role=status aria-live=assertive aria-atomic=true></span>"),k.push("</span>"),this.element.innerHTML=globalThis.MathfieldElement.createHTML(k.join("")),!this.element.children)return void console.error("%cMathLive 0.110.10: Something went wrong and the mathfield could not be created.%c\nIf you are using Vue, this may be because you are using the runtime-only build of Vue. Make sure to include `runtimeCompiler: true` in your Vue configuration. There may a warning from Vue in the log above.","color:red;font-family:system-ui;font-size:1.2rem;font-weight:bold","color:inherit;font-family:system-ui;font-size:inherit;font-weight:inherit");this._l10Subscription=I.subscribe(()=>I.update(this.element)),I.update(this.element),this.container=this.element.querySelector("[part=container]"),this.field=this.container.querySelector("[part=content]"),this.field.addEventListener("click",e=>e.stopImmediatePropagation(),{capture:!1,signal:y}),this.field.addEventListener("wheel",this,{passive:!1,signal:y});let M=this.element;if("PointerEvent"in window?M.addEventListener("pointerdown",this,{signal:y}):M.addEventListener("mousedown",this,{signal:y}),this.host){let e=e=>{e.target===this.host&&this.handleEvent(e)};"PointerEvent"in window?this.host.addEventListener("pointerdown",e,{signal:y}):this.host.addEventListener("mousedown",e,{signal:y})}let S=this.element.querySelector("[part=virtual-keyboard-toggle]");null==S||S.addEventListener("pointerdown",e=>{e.currentTarget===S&&(window.mathVirtualKeyboard.visible?window.mathVirtualKeyboard.hide():(window.mathVirtualKeyboard.show({animate:!0}),window.mathVirtualKeyboard.update(c2(this)),setTimeout(()=>this.scrollIntoView(),300)),e.preventDefault(),e.stopPropagation(),this.hasFocus()||this.focus({preventScroll:!0}))},{signal:y}),this.field.addEventListener("contextmenu",this,{signal:y});let L=this.element.querySelector("[part=menu-toggle]");null==L||L.addEventListener("pointerdown",e=>{if(e.currentTarget!==L)return;let i=this.menu;if("closed"!==i.state)return;this.element.classList.add("tracking");let r=L.getBoundingClientRect();i.modifiers=l5(e),i.show({target:L,location:{x:r.left,y:r.bottom},onDismiss:()=>this.element.classList.remove("tracking")}),e.preventDefault(),e.stopPropagation()},{signal:y}),(this.disabled||this.readOnly&&!this.hasEditableContent||"none"===this.userSelect)&&(L.style.display="none"),this.ariaLiveText=null!=(o=this.element.querySelector("[role=status]"))?o:void 0,this.keyboardDelegate=(n=this.element.querySelector(".ML__keyboard-sink"),l=this.element,s=this,c=null,d=null,u=!1,h=!1,p=!1,b=(m=new AbortController).signal,n.addEventListener("keydown",e=>{if(u||"Process"===e.key||"CapsLock"===e.code||/(Control|Meta|Alt|Shift)(Left|Right)/.test(e.code)){c=null;return}c=e,d=null,s.onKeystroke(e)?n.textContent="":c=null},{capture:!0,signal:b}),n.addEventListener("keypress",e=>{u||(c&&d&&s.onKeystroke(c),d=e)},{capture:!0,signal:b}),n.addEventListener("compositionstart",e=>{n.textContent="",u=!0,s.onCompositionStart(e.data)},{capture:!0,signal:b}),n.addEventListener("compositionupdate",e=>{u&&s.onCompositionUpdate(e.data)},{capture:!0,signal:b}),n.addEventListener("compositionend",e=>{n.textContent="",u&&(u=!1,s.onCompositionEnd(e.data))},{capture:!0,signal:b}),n.addEventListener("beforeinput",e=>e.stopImmediatePropagation(),{signal:b}),n.addEventListener("input",e=>{var i;if(!u&&(n.textContent="","insertCompositionText"!==e.inputType)){if("insertFromPaste"===e.inputType){e.preventDefault(),e.stopPropagation();return}s.onInput(null!=(i=e.data)?i:""),e.preventDefault(),e.stopPropagation()}},{signal:b}),n.addEventListener("paste",e=>{n.focus({preventScroll:!0}),n.textContent="",s.onPaste(e)||e.preventDefault(),e.stopImmediatePropagation()},{signal:b}),n.addEventListener("cut",e=>s.onCut(e),{capture:!0,signal:b}),n.addEventListener("copy",e=>s.onCopy(e),{capture:!0,signal:b}),n.addEventListener("blur",e=>{var i,r;if((null==(r=null==(i=e.relatedTarget)?void 0:i._mathfield)?void 0:r.element)===l){n.focus({preventScroll:!0}),e.preventDefault(),e.stopPropagation();return}let a=!1,o=e.relatedTarget;for(;o;){if(o.classList.contains("ML__keyboard")){a=!0;break}o=o.parentElement}if(a){n.focus({preventScroll:!0}),e.preventDefault(),e.stopPropagation();return}let u=st.state;if("open"===u||"opening"===u||e.relatedTarget===e.target.getRootNode().host){e.preventDefault(),e.stopPropagation();return}p||h||(p=!0,c=null,d=null,s.onBlur(),p=!1)},{capture:!0,signal:b}),n.addEventListener("focus",e=>{p||h||(h=!0,s.onFocus(),h=!1)},{capture:!0,signal:b}),{dispose:()=>m.abort(),cancelComposition:()=>{u&&("function"==typeof n.blur&&n.blur(),requestAnimationFrame(()=>n.focus({preventScroll:!0})))},blur:()=>{"function"==typeof n.blur&&(p=!0,n.blur(),p=!1)},focus:()=>{h||"function"!=typeof n.focus||(h=!0,n.focus({preventScroll:!0}),h=!1)},hasFocus:()=>se()===n,setAriaLabel:e=>n.setAttribute("aria-label",e),setValue:e=>{var i;n.textContent!==e&&(n.textContent=e,n.style.left="-1000px",null==(i=window.getSelection())||i.selectAllChildren(n))},moveTo:(e,i)=>{n.style.top=`${i}px`,n.style.left=`${e}px`}}),window.addEventListener("resize",this,{signal:y}),document.addEventListener("scroll",this,{signal:y}),this.resizeObserver=new ResizeObserver(e=>{if(this.resizeObserverStarted){this.resizeObserverStarted=!1;return}this.updateToggleLayout(),s$(this)}),this.resizeObserverStarted=!0,this.resizeObserver.observe(this.field),this.resizeObserver.observe(this.container),setTimeout(()=>this.updateToggleLayout(),100),window.mathVirtualKeyboard.addEventListener("virtual-keyboard-toggle",this,{signal:y}),A&&!I.locale.startsWith(A.locale)&&B(I.locale),"ready"!==sD&&document.fonts.ready.then(()=>sR(this)),e.querySelector("[part=container]").style.removeProperty("visibility"),this.undoManager.startRecording(),this.undoManager.snapshot("set-value"),s$(this)}connectToVirtualKeyboard(){this.connectedToVirtualKeyboard||(this.connectedToVirtualKeyboard=!0,window.addEventListener("message",this,{signal:this.eventController.signal}),window.mathVirtualKeyboard.connect(),window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(c2(this)),di(this))}disconnectFromVirtualKeyboard(){this.connectedToVirtualKeyboard&&(window.removeEventListener("message",this),window.mathVirtualKeyboard.disconnect(),this.connectedToVirtualKeyboard=!1,dt())}showMenu(e){var i,r;let a=null!=(r=null!=(i=null==e?void 0:e.location)?i:ns(this.field))?r:void 0,o=null==e?void 0:e.modifiers,n=this.element.querySelector("[part=container]");return this._menu.show({target:n,location:a,modifiers:o})}get colorMap(){return e=>{var i,r,a;return null!=(a=null==(r=(i=this.options).colorMap)?void 0:r.call(i,e))?a:U(e)}}get backgroundColorMap(){return e=>{var i,r,a,o,n,l;return null!=(l=null!=(n=null==(r=(i=this.options).backgroundColorMap)?void 0:r.call(i,e))?n:null==(o=(a=this.options).colorMap)?void 0:o.call(a,e))?l:J(e)}}get smartFence(){var e;return null!=(e=this.options.smartFence)&&e}get readOnly(){var e;return null!=(e=this.options.readOnly)&&e}get disabled(){var e,i;return null!=(i=null==(e=this.host)?void 0:e.disabled)&&i}get contentEditable(){return!!this.host&&"false"!==this.host.getAttribute("contenteditable")}get userSelect(){if(!this.host)return"";let e=getComputedStyle(this.host);return e.getPropertyValue("user-select")||e.getPropertyValue("-webkit-user-select")}get hasEditableContent(){return!this.disabled&&!!this.contentEditable&&(!this.readOnly||this.hasEditablePrompts)}get hasEditablePrompts(){return this.readOnly&&!this.disabled&&this.contentEditable&&void 0!==this.model.findAtom(e=>"prompt"===e.type&&!e.locked)}get isSelectionEditable(){if(this.disabled||!this.contentEditable)return!1;if(!this.readOnly)return!0;let e=this.model.at(this.model.anchor),i=this.model.at(this.model.position),r=oG.commonAncestor(e,i);return!!((null==r?void 0:r.type)==="prompt"||null!=r&&r.parentPrompt)}get letterShapeStyle(){var e;return null!=(e=this.options.letterShapeStyle)?e:"tex"}get minFontScale(){return this.options.minFontScale}get maxMatrixCols(){return this.options.maxMatrixCols}queryStyle(e){let i=sc(this,e);"verbatimColor"in i&&delete i.verbatimColor,"verbatimBackgroundColor"in i&&delete i.verbatimBackgroundColor;let r=Object.keys(i).length;if(0===r)return"all";if(r>1){for(let e of Object.keys(i)){let r=this.queryStyle({[e]:i[e]});if("none"===r)return"none";if("some"===r)return"some"}return"all"}let a=Object.keys(i)[0],o=i[a];if(this.model.selectionIsCollapsed)return su(this)[a]===o?"all":"none";let n=this.model.getAtoms(this.model.selection,{includeChildren:!0}),l=n.length;if(0===l)return"none";let s=0;for(let e of n){if("first"===e.type){l-=1;continue}e.style[a]===o&&(s+=1)}return 0===s?"none":s===l?"all":"some"}get keybindings(){var e,i;if(this._keybindings)return this._keybindings;let[r,a]=function(e,i){let r=[],a=[];for(let o of e)try{let e=function(e,i){if(e.ifPlatform&&!/^!?(macos|windows|android|ios|chromeos|other)$/.test(e.ifPlatform))throw Error(`Unexpected platform "${e.ifPlatform}" for keybinding ${e.key}`);if(void 0!==e.ifLayout&&(0===i.score||!e.ifLayout.includes(i.id)))return;let r=C(e.key),a=e.ifPlatform;if(r.cmd){if(a&&"macos"!==a&&"ios"!==a)throw Error('Unexpected "cmd" modifier with platform "'+a+`"
|
|
3490
3490
|
"cmd" modifier can only be used with macOS or iOS platform.`);a||(a="ios"===w()?"ios":"macos"),r.win=!1,r.cmd=!1,r.meta=!0}if(r.win){if(a&&"windows"!==a)throw Error('Unexpected "win" modifier with platform "'+a+`"
|
|
3491
|
-
"win" modifier can only be used with Windows platform.`);a="windows",r.win=!1,r.cmd=!1,r.meta=!0}if(a&&!function(e){if(v()){let i=w(),r=e.startsWith("!"),a=e.endsWith(i);if(r&&!a||!r&&a)return!0}return"!other"!==e&&"other"===e}(a))return;if(/^\[.+\]$/.test(r.key))return g(f({},e),{key:E(r)});let o=function(e,i){var r;let a={shift:!1,alt:!1,cmd:!1,win:!1,meta:!1,ctrl:!1,key:""};if(!e)return a;for(let[r,o]of Object.entries(i.mapping)){if(o[0]===e)return a.key=`[${r}]`,a;if(o[1]===e)return a.shift=!0,a.key=`[${r}]`,a;if(o[2]===e)return a.alt=!0,a.key=`[${r}]`,a;if(o[3]===e)return a.shift=!0,a.alt=!0,a.key=`[${r}]`,a}return a.key=null!=(r=z[e])?r:"",a}(r.key,i);if(!o)return g(f({},e),{key:E(r)});if(o.shift&&r.shift||o.alt&&r.alt)throw Error(`The keybinding ${e.key} (${sa(e.command)}) is conflicting with the key combination ${E(o)} using the ${i.displayName} keyboard layout`);return o.shift=o.shift||r.shift,o.alt=o.alt||r.alt,o.meta=r.meta,o.ctrl=r.ctrl,g(f({},e),{key:E(o)})}(o,i);if(!e)continue;let r=a.find(i=>i.key===e.key&&i.ifMode===e.ifMode);if(r)throw Error(`Ambiguous key binding ${o.key} (${sa(o.command)}) matches ${r.key} (${sa(r.command)}) with the ${i.displayName} keyboard layout`);a.push(e)}catch(e){e instanceof Error&&r.push(e.message)}return[a,r]}(this.options.keybindings,null!=(e=$())?e:function(){switch(D()){case"apple":break;case"windows":return S;case"linux":return L}return M}());return(null==(i=$())?void 0:i.score)>0&&(this._keybindings=r,a.length>0&&console.error("MathLive 0.110.9: Invalid keybindings for current keyboard layout",a)),r}get menu(){var e,i;return null!=this._menu||(this._menu=new dy((e=this,[{label:()=>N("menu.array.add row above"),id:"add-row-above",onMenuSelect:()=>e.executeCommand("addRowBefore"),keyboardShortcut:"shift+alt+[Return]",visible:()=>{if(!e.isSelectionEditable||!ue(e))return!1;let[i,r]=ui(e),[a,o]=ur(e);return i!==a}},{label:()=>N("menu.array.add row below"),id:"add-row-below",onMenuSelect:()=>e.executeCommand("addRowAfter"),keyboardShortcut:"alt+[Return]",visible:()=>{if(!e.isSelectionEditable||!ue(e))return!1;let[i,r]=ui(e),[a,o]=ur(e);return i!==a}},{label:()=>N("menu.array.add column before"),id:"add-column-before",onMenuSelect:()=>e.executeCommand("addColumnBefore"),visible:()=>{if(!e.isSelectionEditable||!ue(e))return!1;let[i,r]=ui(e),[a,o]=ur(e);return r!==o},keyboardShortcut:"shift+alt+[Tab]",enabled:()=>{let i=e.model.parentEnvironment;if(!i)return!1;let[r,a]=ut(e);return r<i.maxColumns}},{label:()=>N("menu.array.add column after"),id:"add-column-after",onMenuSelect:()=>e.executeCommand("addColumnAfter"),keyboardShortcut:"alt+[Tab]",visible:()=>{if(!e.isSelectionEditable||!ue(e))return!1;let[i,r]=ui(e),[a,o]=ur(e);return r!==o}},{type:"divider"},{label:()=>N("menu.array.delete row"),id:"delete-row",onMenuSelect:()=>e.executeCommand("removeRow"),enabled:()=>{let[i,r]=ui(e),[a,o]=ut(e);return a>i},visible:()=>{if(!e.isSelectionEditable||!ue(e))return!1;let[i,r]=ui(e),[a,o]=ur(e);return i!==a}},{label:()=>N("menu.array.delete column"),id:"delete-column",onMenuSelect:()=>e.executeCommand("removeColumn"),enabled:()=>{let[i,r]=ui(e),[a,o]=ut(e);return o>r},visible:()=>{if(!e.isSelectionEditable||!ue(e))return!1;let[i,r]=ui(e),[a,o]=ur(e);return r!==o}},{type:"divider"},{label:()=>N("menu.borders"),visible:()=>{var i;let r;return("array"===(r=(i=e).model.at(i.model.position)).type&&["matrix","pmatrix","bmatrix","vmatrix","Bmatrix"].includes(r.environmentName)||ue(e))&&e.isSelectionEditable},submenu:[{label:" ⋱ ",id:"environment-no-border",onMenuSelect:()=>ua(e,"matrix")},{label:"(⋱)",id:"environment-parentheses",onMenuSelect:()=>ua(e,"pmatrix")},{label:"[⋱]",id:"environment-brackets",onMenuSelect:()=>ua(e,"bmatrix")},{label:"|⋱|",id:"environment-bar",onMenuSelect:()=>ua(e,"vmatrix")},{label:"{⋱}",id:"environment-braces",onMenuSelect:()=>ua(e,"Bmatrix")}],submenuClass:"border-submenu"},{type:"divider"},{label:()=>N("menu.insert matrix"),id:"insert-matrix",visible:()=>e.isSelectionEditable,submenu:function(e){let i=[];for(let r=1;r<=5;r++)for(let a=1;a<=5;a++)i.push({id:`insert-matrix-${r}x${a}`,onCreate:(e,i)=>new d9(e,i,r,a),label:"☐",tooltip:()=>N("tooltip.row-by-col",r,a),data:{row:r,col:a},onMenuSelect:()=>{e.insert(`\\begin{pmatrix}${Array(r).fill(Array(a).fill("#?").join(" & ")).join("\\\\")}\\end{pmatrix}`,{selectionMode:"item"})}});return i}(e),submenuClass:"insert-matrix-submenu",columnCount:5},{type:"divider"},{label:()=>N("menu.insert"),id:"insert",submenu:(i=e,[{label:()=>ul("abs"),id:"insert-abs",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("|#?|")},{label:()=>ul("nth-root"),id:"insert-nth-root",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\sqrt[#?]{#?}")},{label:()=>ul("log-base"),id:"insert-log-base",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\log_{#?}{#?}")},{type:"heading",label:()=>N("menu.insert.heading-calculus")},{label:()=>ul("derivative"),id:"insert-derivative",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\dfrac{\\mathrm{d}}{\\mathrm{d}x}#?\\bigm|_{x=#?}")},{label:()=>ul("nth-derivative"),id:"insert-nth-derivative",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\dfrac{\\mathrm{d}^#?}{\\mathrm{d}x^#?}#?\\bigm|_{x=#?}")},{label:()=>ul("integral"),id:"insert-integral",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\int_#?^#?#?\\,\\mathrm{d}#?")},{label:()=>ul("sum"),id:"insert-sum",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\sum_#?^#?#?")},{label:()=>ul("product"),id:"insert-product",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\prod_#?^#?#?")},{type:"heading",label:()=>N("menu.insert.heading-complex-numbers")},{label:()=>ul("modulus"),id:"insert-modulus",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\lvert#?\\rvert")},{label:()=>ul("argument"),id:"insert-argument",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\arg(#?)")},{label:()=>ul("real-part"),id:"insert-real-part",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\Re(#?)")},{label:()=>ul("imaginary-part"),id:"insert-imaginary-part",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\Im(#?)")},{label:()=>ul("conjugate"),id:"insert-conjugate",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\overline{#?}")}])},{type:"divider"},{label:()=>N("menu.mode"),id:"mode",visible:()=>e.isSelectionEditable&&e.model.selectionIsCollapsed,submenu:[{label:()=>N("menu.mode-math"),id:"mode-math",onMenuSelect:()=>{sf(e,"accept-all"),e.executeCommand(["switchMode","math"])},checked:()=>"math"===e.model.mode},{label:()=>N("menu.mode-text"),id:"mode-text",onMenuSelect:()=>{sf(e,"accept-all"),e.executeCommand(["switchMode","text"])},checked:()=>"text"===e.model.mode},{label:()=>N("menu.mode-latex"),id:"mode-latex",onMenuSelect:()=>e.executeCommand(["switchMode","latex"]),checked:()=>"latex"===e.model.mode}]},{type:"divider"},{label:()=>N("menu.font-style"),id:"variant",visible:()=>e.isSelectionEditable,submenu:[uo(e,"double-struck","mathbb","tooltip.blackboard"),uo(e,"fraktur","mathfrak","tooltip.fraktur"),uo(e,"calligraphic","mathcal","tooltip.caligraphic"),un(e,"up","mathrm","tooltip.roman-upright"),un(e,"bold","bm","tooltip.bold"),un(e,"italic","mathit","tooltip.italic")],submenuClass:"variant-submenu"},{label:()=>N("menu.color"),id:"color",visible:()=>e.isSelectionEditable,submenu:function(e){let i=[];for(let r of Object.keys(j))i.push({id:`color-${r}`,class:("#000"===d8(j[r])?"dark-contrast":"light-contrast")+" menu-swatch",label:`<span style="background:${j[r]} "></span>`,ariaLabel:()=>{var e;return null!=(e=N(r))?e:r},checked:()=>{var i;return null!=(i=({some:"mixed",all:!0})[e.queryStyle({color:r})])&&i},onMenuSelect:()=>e.applyStyle({color:r},{operation:"toggle"})});return i}(e),columnCount:4,submenuClass:"swatches-submenu"},{label:()=>N("menu.background-color"),id:"background-color",visible:()=>e.isSelectionEditable,submenu:function(e){let i=[];for(let r of Object.keys(V))i.push({id:`background-color-${r}`,class:("#000"===function(e){let i=dY(e),r=(0x1000000+(dQ(i.r)<<16)+(dQ(i.g)<<8)+dQ(i.b)).toString(16).slice(1);return void 0!==i.alpha&&i.alpha<1&&(r+=("00"+Math.round(255*i.alpha).toString(16)).slice(-2)),r[0]===r[1]&&r[2]===r[3]&&r[4]===r[5]&&r[6]===r[7]&&(r=r[0]+r[2]+r[4]+(void 0!==i.alpha&&i.alpha<1?r[6]:"")),"#"+r}(d8(V[r]))?"dark-contrast":"light-contrast")+" menu-swatch",label:`<span style="background:${V[r]} "></span>`,ariaLabel:()=>{var e;return null!=(e=N(r))?e:r},checked:()=>{var i;return null!=(i=({some:"mixed",all:!0})[e.queryStyle({backgroundColor:r})])&&i},onMenuSelect:()=>e.applyStyle({backgroundColor:r},{operation:"toggle"})});return i}(e),columnCount:4,submenuClass:"swatches-submenu"},{label:()=>N("menu.accent"),id:"accent",visible:()=>e.isSelectionEditable,submenu:[{id:"accent-vec",class:"ML__center-menu",label:()=>dH(`\\vec{${d5(e)}}`),visible:()=>1===d5(e).length,onMenuSelect:()=>e.insert("\\vec{#@}",{selectionMode:"item"})},{id:"accent-overrightarrow",class:"ML__center-menu",label:()=>dH(`\\overrightarrow{${d5(e)}}`),visible:()=>d5(e).length>0,onMenuSelect:()=>e.insert("\\overrightarrow{#@}",{selectionMode:"item"})},{id:"accent-overleftarrow",class:"ML__center-menu",label:()=>dH(`\\overleftarrow{${d5(e)}}`),visible:()=>d5(e).length>0,onMenuSelect:()=>e.insert("\\overleftarrow{#@}",{selectionMode:"item"})},{id:"accent-dot",class:"ML__center-menu",label:()=>dH(`\\dot{${d5(e)}}`),visible:()=>1===d5(e).length,onMenuSelect:()=>e.insert("\\dot{#@}",{selectionMode:"item"})},{id:"accent-ddot",class:"ML__center-menu",label:()=>dH(`\\ddot{${d5(e)}}`),visible:()=>1===d5(e).length,onMenuSelect:()=>e.insert("\\ddot{#@}",{selectionMode:"item"})},{id:"accent-bar",class:"ML__center-menu",label:()=>dH(`\\bar{${d5(e)}}`),visible:()=>1===d5(e).length,onMenuSelect:()=>e.insert("\\bar{#@}",{selectionMode:"item"})},{id:"accent-overline",class:"ML__center-menu",label:()=>dH(`\\overline{${d5(e)}}`),visible:()=>d5(e).length>0,onMenuSelect:()=>e.insert("\\overline{#@}",{selectionMode:"item"})},{id:"accent-overgroup",class:"ML__center-menu",label:()=>dH(`\\overgroup{${d5(e)}}`),visible:()=>d5(e).length>0,onMenuSelect:()=>e.insert("\\overgroup{#@}",{selectionMode:"item"})},{id:"accent-overbrace",class:"ML__center-menu",label:()=>dH(`\\overbrace{${d5(e)}}`),visible:()=>d5(e).length>0,onMenuSelect:()=>e.insert("\\overbrace{#@}",{selectionMode:"item"})},{id:"accent-underline",class:"ML__center-menu",label:()=>dH(`\\underline{${d5(e)}}`),visible:()=>d5(e).length>0,onMenuSelect:()=>e.insert("\\underline{#@}",{selectionMode:"item"})},{id:"accent-undergroup",class:"ML__center-menu",label:()=>dH(`\\undergroup{${d5(e)}}`),visible:()=>d5(e).length>0,onMenuSelect:()=>e.insert("\\undergroup{#@}",{selectionMode:"item"})},{id:"accent-underbrace",class:"ML__center-menu",label:()=>dH(`\\underbrace{${d5(e)}}`),visible:()=>d5(e).length>0,onMenuSelect:()=>e.insert("\\underbrace{#@}",{selectionMode:"item"})}],submenuClass:"variant-submenu"},{label:()=>N("menu.decoration"),id:"decoration",visible:()=>e.isSelectionEditable&&d5(e).length>0,submenu:[{id:"decoration-boxed",label:()=>dH(`\\boxed{${e.getValue(e.model.selection)}}}`),onMenuSelect:()=>e.insert("\\boxed{#@}",{selectionMode:"item"})},{id:"decoration-red-box",label:()=>dH(`\\bbox[5px, border: 2px solid red]{${e.getValue(e.model.selection)}}`),onMenuSelect:()=>e.insert("\\bbox[5px, border: 2px solid red]{#@}",{selectionMode:"item"})},{id:"decoration-dashed-black-box",label:()=>dH(`\\bbox[5px, border: 2px dashed black]{${e.getValue(e.model.selection)}}`),onMenuSelect:()=>e.insert("\\bbox[5px, border: 2px dashed black]{#@}",{selectionMode:"item"})}],submenuClass:"variant-submenu"},{type:"divider"},{label:()=>N("menu.evaluate"),id:"ce-evaluate",visible:()=>e.isSelectionEditable&&null!==globalThis.MathfieldElement.computeEngine,onMenuSelect:()=>{let i=function(e){var i,r;let a;if(!(a=e.model.selectionIsCollapsed?null==(i=globalThis.MathfieldElement.computeEngine)?void 0:i.parse(e.getValue(),{canonical:!1}):null==(r=globalThis.MathfieldElement.computeEngine)?void 0:r.parse(e.getValue(e.model.selection),{canonical:!1})))return"";let o=a.evaluate();return o.isSame(a)&&(o=a.N()),o.latex}(e);i?e.model.selectionIsCollapsed?(e.model.position=e.model.lastOffset,e.insert(`=${i}`,{insertionMode:"insertAfter",selectionMode:"item"})):e.insert(i,{insertionMode:"replaceSelection",selectionMode:"item"}):e.model.announce("plonk")}},{label:()=>N("menu.simplify"),id:"ce-simplify",visible:()=>e.isSelectionEditable&&null!==globalThis.MathfieldElement.computeEngine,onMenuSelect:()=>{var i,r;if(e.model.selectionIsCollapsed){let r=null==(i=e.expression)?void 0:i.simplify();if(e.model.position=e.model.lastOffset,!r)return void e.model.announce("plonk");e.insert(`=${r.latex}`,{insertionMode:"insertAfter",selectionMode:"item"})}else{let i=null==(r=globalThis.MathfieldElement.computeEngine)?void 0:r.parse(e.getValue(e.model.selection)).simplify();if(!i)return void e.model.announce("plonk");e.insert(i.latex,{insertionMode:"replaceSelection",selectionMode:"item"})}}},{label:()=>{var i;let r=globalThis.MathfieldElement.computeEngine;if(null===r)return"";let a=null==(i=e.expression)?void 0:i.unknowns[0];return a?N("menu.solve-for",dH(r.box(a).latex)):N("menu.solve")},id:"ce-solve",visible:()=>{var i;return e.isSelectionEditable&&null!==globalThis.MathfieldElement.computeEngine&&(null==(i=e.expression)?void 0:i.unknowns.length)===1&&"Nothing"!==e.expression.unknowns[0]},onMenuSelect:()=>{let i=e.expression,r=null==i?void 0:i.unknowns[0],a=i.solve(r),o=Array.isArray(a)?a.map(e=>{var i;return null!=(i=e.simplify().latex)?i:""}):null;o?e.insert(`${r}=${1===o.length?o[0]:"\\left\\lbrace"+(null==o?void 0:o.join(", "))+"\\right\\rbrace"}`,{insertionMode:"replaceAll",selectionMode:"item"}):e.model.announce("plonk")}},{type:"divider"},{label:()=>N("menu.cut"),id:"cut",onMenuSelect:()=>e.executeCommand("cutToClipboard"),visible:()=>!e.options.readOnly&&e.isSelectionEditable,keyboardShortcut:"meta+X"},{label:()=>N("menu.copy"),id:"copy",submenu:[{label:()=>N("menu.copy-as-latex"),id:"copy-latex",onMenuSelect:()=>na.copyToClipboard(e,"latex"),keyboardShortcut:"meta+C"},{label:()=>N("menu.copy-as-typst"),id:"copy-latex",onMenuSelect:()=>na.copyToClipboard(e,"typst")},{label:()=>N("menu.copy-as-ascii-math"),id:"copy-ascii-math",onMenuSelect:()=>na.copyToClipboard(e,"ascii-math")},{label:()=>N("menu.copy-as-mathml"),id:"copy-math-ml",onMenuSelect:()=>na.copyToClipboard(e,"math-ml")}]},{label:()=>N("menu.paste"),id:"paste",onMenuSelect:()=>e.executeCommand("pasteFromClipboard"),visible:()=>e.hasEditableContent,keyboardShortcut:"meta+V"},{label:()=>N("menu.select-all"),id:"select-all",keyboardShortcut:"meta+A",onMenuSelect:()=>e.executeCommand("selectAll")}]),{host:this.host})),this._menu}set menuItems(e){this._menu?this._menu.menuItems=e:this._menu=new dy(e,{host:this.host})}setOptions(e){var i;this.options=f(f({},this.options),co(e)),this._keybindings=void 0,"inline-math"===this.options.defaultMode?this.element.classList.add("ML__is-inline"):this.element.classList.remove("ML__is-inline");let r=this.options.defaultMode;"inline-math"===r&&(r="math"),(null==(i=this.model.root.firstChild)?void 0:i.mode)!==r&&(this.model.root.firstChild.mode=r),this.options.readOnly&&this.hasFocus()&&window.mathVirtualKeyboard.visible&&this.executeCommand("hideVirtualKeyboard");let a=oG.serialize([this.model.root],{expandMacro:!1,defaultMode:this.options.defaultMode});("macros"in e||this.model.getValue()!==a)&&sR(this),("value"in e||"registers"in e||"colorMap"in e||"backgroundColorMap"in e||"letterShapeStyle"in e||"minFontScale"in e||"maxMatrixCols"in e||"readOnly"in e||"contentPlaceholder"in e||"placeholderSymbol"in e)&&sB(this)}getOptions(e){return cn(this.options,e)}getOption(e){return cn(this.options,e)}async handleEvent(e){var i,r,a;if(nl(this)){if(sH(e)){if(!np(e.origin,null!=(i=this.options.originValidator)?i:"none"))throw new DOMException(`Message from unknown origin (${e.origin}) cannot be handled`,"SecurityError");let{action:r}=e.data;if("execute-command"===r){let i=sV(e.data.command);if(!i||"virtual-keyboard"===sF(i))return;this.executeCommand(i)}else"update-state"===r||("focus"===r?this.focus({preventScroll:!0}):"blur"===r&&this.blur());return}switch(e.type){case"focus":this.programmaticFocusInProgress||this.onFocus({suppressEvents:!0});break;case"blur":this.onBlur({dispatchEvents:!1});break;case"mousedown":"none"===this.userSelect||null!=(r=e.target)&&r.closest("[part=virtual-keyboard-toggle],[part=menu-toggle]")||cG(this,e);break;case"pointerdown":!e.defaultPrevented&&"none"!==this.userSelect&&!(null!=(a=e.target)&&a.closest("[part=virtual-keyboard-toggle],[part=menu-toggle]"))&&(cG(this,e),!1===e.shiftKey&&await d_(e,this.container,this.menu)&&cU.stop());break;case"contextmenu":"none"!==this.userSelect&&!1===e.shiftKey&&await d_(e,this.container,this.menu)&&cU.stop();break;case"virtual-keyboard-toggle":this.hasFocus()&&dt(this),this.hasFocus()&&"manual"!==this.options.mathVirtualKeyboardPolicy&&(this.focusBlurInProgress=!0,this.keyboardDelegate.blur(),this.keyboardDelegate.focus(),this.focusBlurInProgress=!1);break;case"resize":this.geometryChangeTimer&&cancelAnimationFrame(this.geometryChangeTimer),this.geometryChangeTimer=requestAnimationFrame(()=>nl(this)&&this.onGeometryChange());break;case"scroll":this.geometryChangeTimer&&cancelAnimationFrame(this.geometryChangeTimer),this.geometryChangeTimer=requestAnimationFrame(()=>nl(this)&&this.onGeometryChange());break;case"wheel":this.onWheel(e);break;case"message":break;default:console.warn("Unexpected event type",e.type)}}}updateToggleLayout(){if(!this.element||!this.host)return;let e=this.element.querySelector(".ML__toggles");if(!e)return;let i=this.host.offsetHeight,r=e.classList.contains("ML__toggles--vertical");i>=100&&!r?e.classList.add("ML__toggles--vertical"):i<100&&r&&e.classList.remove("ML__toggles--vertical")}dispose(){if(!nl(this))return;I.unsubscribe(this._l10Subscription),this.keyboardDelegate.dispose(),this.keyboardDelegate=void 0,this.eventController.abort(),this.eventController=void 0,this.resizeObserver.disconnect(),window.mathVirtualKeyboard.removeEventListener("virtual-keyboard-toggle",this),this.disconnectFromVirtualKeyboard(),this.model.dispose();let e=this.element;delete e.mathfield,this.element=void 0,this.host=void 0,this.field=void 0,this.ariaLiveText=void 0,document.getElementById("mathlive-keystroke-caption-panel")&&(sb("mathlive-keystroke-caption-panel"),nz("core"),nz("keystroke-caption")),document.getElementById("mathlive-suggestion-popover")&&(sb("mathlive-suggestion-popover"),nz("suggestion-popover"),nz("core")),document.getElementById("mathlive-environment-popover")&&(sb("mathlive-environment-popover"),nz("environment-popover"),nz("core"))}flushInlineShortcutBuffer(e){if(null!=e||(e={defer:!1}),!e.defer){this.inlineShortcutBuffer.length=0,clearTimeout(this.inlineShortcutBufferFlushTimer),this.inlineShortcutBufferFlushTimer=0;return}this.options.inlineShortcutTimeout>0&&(clearTimeout(this.inlineShortcutBufferFlushTimer),this.inlineShortcutBufferFlushTimer=setTimeout(()=>this.flushInlineShortcutBuffer(),this.options.inlineShortcutTimeout))}executeCommand(e){return"virtual-keyboard"===sF(e)?(this.focus({preventScroll:!0}),window.mathVirtualKeyboard.executeCommand(e),requestAnimationFrame(()=>window.mathVirtualKeyboard.update(c4(this))),!1):function(e,i){var r,a;if(!(i=sV(i)))return!1;let o,n=[],l=!1,s=!1;R(i)?(o=i[0],n=i.slice(1)):o=i;let c=sW[o],d=null==c?void 0:c.target;if("model"===d){if(!e.isSelectionEditable&&null!=c&&c.changeContent)return e.model.announce("plonk"),!1;/^(delete|add)/.test(o)&&("deleteBackward"!==o&&e.flushInlineShortcutBuffer(),e.snapshot(o)),/^complete/.test(o)||sh(e),sW[o].fn(e.model,...n),sp(e),s=!0,l=!0}else if("virtual-keyboard"===d)s=null!=(a=null==(r=window.mathVirtualKeyboard)?void 0:r.executeCommand(i))&&a,l=!0;else if(sW[o]){if(!e.isSelectionEditable&&null!=c&&c.changeContent)return e.model.announce("plonk"),!1;/^(undo|redo)/.test(o)&&e.flushInlineShortcutBuffer(),s=sW[o].fn(e,...n),l=!0}else throw Error(`Unknown command "${o}"`);return"virtual-keyboard"!==d&&(!e.model.selectionIsCollapsed||null!=c&&c.changeSelection&&"deleteBackward"!==o)&&(e.flushInlineShortcutBuffer(),null!=c&&c.changeContent||e.stopCoalescingUndo(),e.defaultStyle={}),s&&(null!=c&&c.changeSelection&&l?(e.dirty=!0,e.scrollIntoView()):sB(e)),l}(this,e)}get errors(){return ls(this.model.getValue(),{context:this.context})}getValue(e,i,r){return this.model.getValue(e,i,r)}setValue(e,i){var r;void 0===(i=null!=i?i:{mode:"math"}).insertionMode&&(i.insertionMode="replaceAll"),(void 0===i.format||"auto"===i.format)&&(i.format="latex"),(void 0===i.mode||"auto"===i.mode)&&(i.mode=null!=(r=function(e,i){let r=e.at(i),a;if(r){a=r.mode;let e=r.parent;for(;!a&&e;)e&&(a=e.mode),e=e.parent}return a}(this.model,this.model.position))?r:"math");let a=this.undoManager.canUndo();na.insert(this.model,e,i)&&(sB(this),a||this.undoManager.reset(),this.undoManager.snapshot("set-value"))}get expression(){let e=globalThis.MathfieldElement.computeEngine;return e?e.box(e.parse(this.model.getValue("latex-unstyled"))):(console.error("MathLive 0.110.9: no compute engine available. Make sure the Compute Engine library is loaded."),null)}scrollIntoView(){var e;if(!this.element)return;if(this.host){if(this.options.onScrollIntoView)this.options.onScrollIntoView(this);else if(this.host.scrollIntoView({block:"nearest",inline:"nearest"}),window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.container===window.document.body){let i=window.mathVirtualKeyboard.boundingRect,r=this.host.getBoundingClientRect();r.bottom>i.top&&(null==(e=window.document.scrollingElement)||e.scrollBy(0,r.bottom-i.top+8))}}this.dirty&&sP(this,{interactive:!0});let i=this.field.getBoundingClientRect(),r=null;if(this.model.selectionIsCollapsed)r=ns(this.field);else{let e=nh(this);if(e.length>0){let a=-1/0,o=1/0,n=-1/0;for(let i of e)i.right>a&&(a=i.right),i.top<o&&(o=i.top),i.bottom>n&&(n=i.bottom);let l=n-o;r={x:a+i.left-this.field.scrollLeft,y:o+i.top-this.field.scrollTop,height:l}}}if(this.host&&r){let e=this.host.getBoundingClientRect(),i=r.y,a=r.y+r.height,o=this.host.scrollTop;i<e.top+20?o=i-e.top+this.host.scrollTop-20:a>e.bottom-20&&(o=a-e.bottom+this.host.scrollTop+20),o!==this.host.scrollTop&&this.host.scroll({top:o,behavior:"auto"})}if(r){let e=r.x-window.scrollX,a=this.field.scrollLeft;e<i.left?a=e-i.left+this.field.scrollLeft-20:e>i.right&&(a=e-i.right+this.field.scrollLeft+20),this.field.scroll({top:this.field.scrollTop,left:a})}}insert(e,i){if("string"!=typeof e||0===e.length&&((null==i?void 0:i.insertionMode)==="insertBefore"||(null==i?void 0:i.insertionMode)==="insertAfter")||0===e.length&&this.model.selectionIsCollapsed)return!1;if(this.flushInlineShortcutBuffer(),(i=null!=i?i:{mode:"math"}).focus&&this.focus(),i.feedback&&(globalThis.MathfieldElement.keypressVibration&&_()&&navigator.vibrate(3),globalThis.MathfieldElement.playSound("keypress")),"\\\\"===e&&this.model.parentEnvironment)cp(this.model);else if("&"===e&&this.model.parentEnvironment)cm(this.model);else if(this.model.selectionIsCollapsed){let r=f({},sd(this));/^[a-zA-Z0-9]$/.test(e)||"none"===this.styleBias||(r.variant="normal",r.variantStyle=void 0),na.insert(this.model,e,f({style:r},i))}else na.insert(this.model,e,i);return this.snapshot(`insert-${this.model.at(this.model.position).type}`),sB(this),i.scrollIntoView&&this.scrollIntoView(),!0}switchMode(e,i="",r=""){if(this.model.mode===e||!this.hasEditableContent||!this.contentEditable||this.disabled)return;let{model:a}=this,o=a.mode;if(a.mode=e,this.host&&!this.host.dispatchEvent(new Event("mode-change",{bubbles:!0,composed:!0,cancelable:!0}))){a.mode=o;return}a.mode=o,a.deferNotifications({content:!!r||!!i,selection:!0,type:"insertText"},()=>{let o=a.at(a.position),n=(e,i)=>{if(!e)return;let r="math"===a.mode?ll(o6(e,{format:"ascii-math"})[1],{context:this.context}):[...e].map(e=>new oY(e,e,{}));if(i.select){let e=o.parent.addChildrenAfter(r,o);a.setSelection(a.offsetOf(r[0].leftSibling),a.offsetOf(e))}else a.position=a.offsetOf(o.parent.addChildrenAfter(r,o));c=!0},l=(e,i)=>{let r=new l_(e);o.parent.addChildAfter(r,o),i.select?a.setSelection(a.offsetOf(r.firstChild),a.offsetOf(r.lastChild)):a.position=a.offsetOf(r.lastChild),c=!0},s=()=>{let i="latex"===e?"latex":"math"===e?"plain-text":"ascii-math",n=oQ(a.selection),l=this.model.getValue(n,i),s=this.model.extractAtoms(n);return 1===s.length&&"placeholder"===s[0].type&&(l=r),o=a.at(n[0]),l},c=!1;if(this.flushInlineShortcutBuffer(),this.stopCoalescingUndo(),sf(this,"accept"),a.selectionIsCollapsed)n(i,{select:!1}),a.mode=e,"latex"===e?l(r,{select:!1}):n(r,{select:!1});else{let i=s();a.mode=e,"latex"===e?l(i,{select:!0}):n(i,{select:!0})}return sB(this),this.undoManager.snapshot("latex"===e?"insert-latex":"insert"),c}),a.mode=e,window.mathVirtualKeyboard.update(c4(this))}hasFocus(){return!this.blurred}focus(e){var i;this.disabled||this.focusBlurInProgress||(this.hasFocus()||(this.programmaticFocusInProgress=!0,this.onFocus(),this.model.announce("line")),null!=(i=null==e?void 0:e.preventScroll)&&i||this.scrollIntoView())}blur(){this.disconnectFromVirtualKeyboard(),this.hasFocus()&&this.keyboardDelegate.blur()}select(){this.model.selection={ranges:[[0,this.model.lastOffset]]},this.focus()}applyStyle(e,i={}){var r;let a,o="set",n=!1;o1(i)?a=i:("toggle"===i.operation&&(o="toggle"),a=i.range,n=null!=(r=i.silenceNotifications)&&r),a&&(a=this.model.normalizeRange(a)),a&&a[0]===a[1]&&(a=void 0);let l=ss(this,e);if(void 0===a&&this.model.selectionIsCollapsed){if("set"===o){let e=f({},this.defaultStyle);"color"in l&&delete e.verbatimColor,"backgroundColor"in l&&delete e.verbatimBackgroundColor,this.defaultStyle=f(f({},e),l),this.styleBias="none";return}let e=sd(this),i=f({},this.defaultStyle);for(let r of Object.keys(l))e[r]===l[r]?("color"===r&&delete i.verbatimColor,"backgroundColor"===r&&delete i.verbatimBackgroundColor,delete i[r]):i[r]=l[r];this.defaultStyle=i,this.styleBias="none";return}this.model.deferNotifications({content:!n,type:"insertText"},()=>{if(void 0===a)for(let e of this.model.selection.ranges)lN(this.model,e,l,{operation:o});else lN(this.model,a,l,{operation:o})}),sB(this)}toggleContextMenu(){var e;let i=this.menu;if(!i.visible)return!1;if("open"===i.state)return i.hide(),!0;let r=null==(e=nf(this,this.model.position))?void 0:e.bounds;if(!r)return!1;let a={x:r.right,y:r.bottom};return i.show({target:this.element.querySelector("[part=container]"),location:a,onDismiss:()=>{var e;return null==(e=this.element)?void 0:e.focus()}}),!0}getPrompt(e){return this.model.findAtom(i=>"prompt"===i.type&&i.placeholderId===e)}getPromptValue(e,i){let r=this.getPrompt(e);if(!r)return"";let a=this.model.offsetOf(r.firstChild),o=this.model.offsetOf(r.lastChild);return this.model.getValue(a,o,i)}getPrompts(e){return this.model.atoms.filter(i=>"prompt"===i.type&&(!e||!(e.id&&i.placeholderId!==e.id||e.locked&&i.locked!==e.locked||"undefined"===e.correctness&&i.correctness||e.correctness&&i.correctness!==e.correctness))).map(e=>e.placeholderId)}setPromptValue(e,i,r){if(void 0!==i){let a=this.getPrompt(e);if(!a)return void console.error(`MathLive 0.110.9: unknown prompt ${e}`);let o=this.model.getBranchRange(this.model.offsetOf(a),"body");this.model.setSelection(o),this.insert(i,g(f({},r),{insertionMode:"replaceSelection"}))}null!=r&&r.silenceNotifications&&(this.valueOnFocus=this.getValue()),sB(this)}setPromptState(e,i,r){let a=this.getPrompt(e);a?("undefined"===i?a.correctness=void 0:"string"==typeof i&&(a.correctness=i),"boolean"==typeof r&&(a.locked=r,a.captureSelection=r),sB(this)):console.error(`MathLive 0.110.9: unknown prompt ${e}`)}getPromptState(e){let i=this.getPrompt(e);return i?[i.correctness,i.locked]:(console.error(`MathLive 0.110.9: unknown prompt ${e}`),[void 0,!0])}getPromptRange(e){let i=this.getPrompt(e);return i?this.model.getBranchRange(this.model.offsetOf(i),"body"):(console.error(`MathLive 0.110.9: unknown prompt ${e}`),[0,0])}canUndo(){return this.undoManager.canUndo()}canRedo(){return this.undoManager.canRedo()}popUndoStack(){this.undoManager.pop(),window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(c4(this))}snapshot(e){var i;this.undoManager.snapshot(e)&&(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(c4(this)),null==(i=this.host)||i.dispatchEvent(new CustomEvent("undo-state-change",{bubbles:!0,composed:!0,detail:{type:"snapshot"}})))}stopCoalescingUndo(){this.undoManager.stopCoalescing(this.model.selection)}stopRecording(){this.undoManager.stopRecording()}startRecording(){this.undoManager.startRecording()}undo(){var e;this.undoManager.undo()&&(null==(e=this.host)||e.dispatchEvent(new CustomEvent("undo-state-change",{bubbles:!0,composed:!0,detail:{type:"undo"}})))}redo(){var e;this.undoManager.redo()&&(null==(e=this.host)||e.dispatchEvent(new CustomEvent("undo-state-change",{bubbles:!0,composed:!0,detail:{type:"redo"}})))}resetUndo(){var e;null==(e=this.undoManager)||e.reset()}onSelectionDidChange(){var e,i;let r=this.model;if(r.mathfield.hasFocus()&&this.keyboardDelegate.setValue(r.getValue(r.selection,"latex-expanded")),r.selectionIsCollapsed){let i=so(r),a=r.position,o=r.at(a),n=null!=(e=o.mode)?e:cs(this.options);if(i&&(a<r.offsetOf(i.firstChild)||a>r.offsetOf(i.lastChild))){sf(this,"accept",{mode:n});let e=r.offsetOf(o);e>=0&&(r.position=e)}else{let e=r.at(a+1);(null==e?void 0:e.type)==="first"&&"latex"===e.mode?r.position=a+1:i&&(null==e?void 0:e.mode)!=="latex"?r.position=a-1:this.switchMode(n)}}null==(i=this.host)||i.dispatchEvent(new Event("selection-change",{bubbles:!0,composed:!0})),window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(c4(this)),dt(this)}onContentWillChange(e){var i,r,a;return null==(a=null==(r=this.host)?void 0:r.dispatchEvent(new InputEvent("beforeinput",g(f({},e),{data:e.data?e.data:null!=(i=e.inputType)?i:"",cancelable:!0,bubbles:!0,composed:!0}))))||a}onFocus(i){if(this.disabled||this.focusBlurInProgress||!this.blurred)return;let r=e._globallyFocusedMathfield;r&&r!==this&&!r.disabled&&r.hasFocus()&&r.onBlur({dispatchEvents:!0}),this.focusBlurInProgress=!0,this.blurred=!1,e._globallyFocusedMathfield=this,this.stopCoalescingUndo(),this.valueOnFocus=this.model.getValue(),this.hasEditablePrompts&&!this.model.at(this.model.anchor).parentPrompt&&this.executeCommand("moveToNextPlaceholder"),sP(this,{interactive:!0}),setTimeout(()=>{var e,r;if(nl(this))if(null!=(e=null==i?void 0:i.suppressEvents)&&e){let e=new AbortController,i=e.signal,a=e=>{e.preventDefault(),e.stopPropagation()};for(let e of["focus","focusin"])null==(r=this.host)||r.addEventListener(e,a,{capture:!0,signal:i});this.focusBlurInProgress=!1,this.keyboardDelegate.focus(),this.connectToVirtualKeyboard(),setTimeout(()=>e.abort(),0)}else this.focusBlurInProgress=!1,this.keyboardDelegate.focus(),this.connectToVirtualKeyboard(),setTimeout(()=>{this.programmaticFocusInProgress=!1},0)},60)}onBlur(i){var r,a,o,n;if(!this.focusBlurInProgress&&!this.blurred&&(this.focusBlurInProgress=!0,this.stopCoalescingUndo(),this.blurred=!0,e._globallyFocusedMathfield===this&&(e._globallyFocusedMathfield=void 0),this.ariaLiveText&&(this.ariaLiveText.textContent=""),sM(this),this.model.getValue()!==this.valueOnFocus&&(null==(r=this.host)||r.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))),this.disconnectFromVirtualKeyboard(),(null==(a=null==i?void 0:i.dispatchEvents)||a)&&(null==(o=this.host)||o.dispatchEvent(new Event("blur",{bubbles:!1,composed:!0})),null==(n=this.host)||n.dispatchEvent(new UIEvent("focusout",{bubbles:!0,composed:!0}))),sB(this),this.focusBlurInProgress=!1,de(),uO.restoreFocusWhenDocumentFocused)){let e=new AbortController,i=e.signal;window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{nl(this)&&this.focus({preventScroll:!0})},{once:!0,signal:i})},{once:!0,signal:i}),document.addEventListener("focusin",()=>e.abort(),{once:!0}),document.addEventListener("click",()=>e.abort(),{once:!0})}}onInput(e){cN(this,e)}onKeystroke(e){return cR(this,e)}onCompositionStart(e){cx(this.model,oQ(this.model.selection),"insertText");let i=ns(this.field);i&&requestAnimationFrame(()=>{sP(this),this.keyboardDelegate.moveTo(i.x,i.y-i.height)})}onCompositionUpdate(e){(function(e,i){let r=e.at(e.position);if("composition"===r.type)r.value=i;else{let{caret:a}=r;r.caret=void 0;let o=new n5(i,{mode:r.mode});o.caret=a,r.parent.addChildAfter(o,r),e.position+=1}})(this.model,e),sB(this)}onCompositionEnd(e){var i;let r;"composition"===(r=(i=this.model).at(i.position)).type&&(r.parent.removeChild(r),i.position-=1),cN(this,e,{simulateKeystroke:!0})}onCut(e){this.isSelectionEditable?this.model.contentWillChange({inputType:"deleteByCut"})&&(this.stopCoalescingUndo(),e.clipboardData?na.onCopy(this,e):na.copyToClipboard(this,"latex"),cx(this.model,oQ(this.model.selection),"deleteByCut"),this.snapshot("cut"),sB(this)):this.model.announce("plonk")}onCopy(e){e.clipboardData?na.onCopy(this,e):na.copyToClipboard(this,"latex")}onPaste(e){let i=this.isSelectionEditable;return i&&(i=na.onPaste(this.model.at(this.model.position).mode,this,e.clipboardData)),i||this.model.announce("plonk"),e.preventDefault(),e.stopPropagation(),i}onGeometryChange(){var e;null==(e=this._menu)||e.hide(),sk(this),dt(this)}onWheel(e){let i=5*e.deltaX;if(!Number.isFinite(i)||0===i)return;let r=this.field;i<0&&0===r.scrollLeft||i>0&&r.offsetWidth+r.scrollLeft>=r.scrollWidth||(r.scrollBy({top:0,left:i}),e.preventDefault(),e.stopPropagation())}getHTMLElement(e){let i=e;for(;!i.id&&i.hasChildren;)i=e.children[0];return this.field.querySelector(`[data-atom-id="${i.id}"]`)}get context(){var e,i;return{registers:null!=(e=this.options.registers)?e:{},smartFence:this.smartFence,letterShapeStyle:this.letterShapeStyle,minFontScale:this.minFontScale,maxMatrixCols:this.maxMatrixCols,placeholderSymbol:null!=(i=this.options.placeholderSymbol)?i:"▢",colorMap:e=>this.colorMap(e),backgroundColorMap:e=>this.backgroundColorMap(e),getMacro:e=>eS(e,this.options.macros),atomIdsSettings:{seed:"random",groupNumbers:!1}}}};sN({speak:(e,i,r)=>(function(e,i,r){var a;r=null!=r?r:{withHighlighting:!1};let{model:o}=e,n=globalThis.MathfieldElement,l=function(e){let i=null;switch(e){case"all":default:i=o.root;break;case"selection":i=o.getAtoms(o.selection);break;case"left":i=o.getAtoms(o.offsetOf(o.at(o.position).leftSibling),o.position);break;case"right":i=o.getAtoms(o.position,o.offsetOf(o.at(o.position).rightSibling));break;case"group":i=o.getAtoms(o.getSiblingsRange(o.position));break;case"parent":{let{parent:e}=o.at(o.position);i=null!=e&&e.parent?e:o.root}}return i}(i);if(null===l)return null==(a=n.speakHook)||a.call(n,function(e){let i="";switch(e){case"all":console.error("Internal failure: speak all failed");break;case"selection":i="no selection";break;case"left":i="at start";break;case"right":i="at end";break;case"group":console.error("Internal failure: speak group failed");break;case"parent":i="no parent";break;default:console.error('unknown speak_ param value: "'+e+'"')}return i}(i)),!1;(r.withHighlighting||"amazon"===n.speechEngine)&&(n.textToSpeechMarkup=globalThis.sre&&"sre"===n.textToSpeechRules?"ssml_step":"ssml");let s=dN(l);return v()&&r.withHighlighting?(uX().readAloudMathfield=e,sP(e,{forHighlighting:!0}),n.readAloudHook&&n.readAloudHook(e.field,s)):n.speakHook&&n.speakHook(s),!1})(e,i,r)},{target:"mathfield"}),v()||console.error('MathLive 0.110.9: this version of the MathLive library is for use in the browser. A subset of the API is available on the server side in the "mathlive-ssr" library. If using server side rendering (with React for example) you may want to do a dynamic import of the MathLive library inside a `useEffect()` call.');var uS=new WeakMap,uL={letterShapeStyle:"mf.letterShapeStyle = ...",horizontalSpacingScale:'Removed. Use `"thinmuskip"`, `"medmuskip"`, and `"thickmuskip"` registers ',macros:"mf.macros = ...",registers:"mf.registers = ...",backgroundColorMap:"mf.backgroundColorMap = ...",colorMap:"mf.colorMap = ...",enablePopover:"mf.popoverPolicy = ...",mathModeSpace:"mf.mathModeSpace = ...",placeholderSymbol:"mf.placeholderSymbol = ...",readOnly:"mf.readOnly = ...",removeExtraneousParentheses:"mf.removeExtraneousParentheses = ...",scriptDepth:"mf.scriptDepth = ...",smartFence:"mf.smartFence = ...",smartMode:"mf.smartMode = ...",smartSuperscript:"mf.smartSuperscript = ...",inlineShortcutTimeout:"mf.inlineShortcutTimeout = ...",inlineShortcuts:"mf.inlineShortcuts = ...",keybindings:"mf.keybindings = ...",virtualKeyboardMode:"mf.mathVirtualKeyboardPolicy = ...",customVirtualKeyboardLayers:"mathVirtualKeyboard.layers = ...",customVirtualKeyboards:"mathVirtualKeyboard.layouts = ...",keypressSound:"mathVirtualKeyboard.keypressSound = ...",keypressVibration:"mathVirtualKeyboard.keypressVibration = ...",plonkSound:"mathVirtualKeyboard.plonkSound = ...",virtualKeyboardContainer:"mathVirtualKeyboard.container = ...",virtualKeyboardLayout:"mathVirtualKeyboard.alphabeticLayout = ...",virtualKeyboardTheme:"No longer supported",virtualKeyboardToggleGlyph:"No longer supported",virtualKeyboardToolbar:"mathVirtualKeyboard.editToolbar = ...",virtualKeyboards:"Use `mathVirtualKeyboard.layouts`",speechEngine:"`MathfieldElement.speechEngine`",speechEngineRate:"`MathfieldElement.speechEngineRate`",speechEngineVoice:"`MathfieldElement.speechEngineVoice`",textToSpeechMarkup:"`MathfieldElement.textToSpeechMarkup`",textToSpeechRules:"`MathfieldElement.textToSpeechRules`",textToSpeechRulesOptions:"`MathfieldElement.textToSpeechRulesOptions`",readAloudHook:"`MathfieldElement.readAloudHook`",speakHook:"`MathfieldElement.speakHook`",computeEngine:"`MathfieldElement.computeEngine`",fontsDirectory:"`MathfieldElement.fontsDirectory`",soundsDirectory:"`MathfieldElement.soundsDirectory`",createHTML:"`MathfieldElement.createHTML`",onExport:"`mf.onExport`",onInlineShortcut:"`mf.onInlineShortcut`",onScrollIntoView:"`mf.onScrollIntoView`",locale:"MathfieldElement.locale = ...",strings:"MathfieldElement.strings = ...",decimalSeparator:"MathfieldElement.decimalSeparator = ...",fractionNavigationOrder:"MathfieldElement.fractionNavigationOrder = ..."},uC=class e extends HTMLElement{constructor(e){if(super(),this._observer=null,e){let i=[];for(let r of Object.keys(e))if(uL[r])if(uL[r].startsWith("mf."))if(uL[r].startsWith(`mf.${r}`))i.push(`Option \`${r}\` cannot be used as a constructor option. Use ${uL[r]}`);else{let e=uL[r].match(/([a-zA-Z]+) =/);i.push(`Option \`${r}\` has been renamed \`${e[1]}\``)}else i.push(`Option \`${r}\` cannot be used as a constructor option. Use ${uL[r]}`);if(i.length>0){for(let e of(console.group("%cMathLive 0.110.9: %cInvalid Options","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem"),console.warn("Some of the options passed to `new MathfieldElement(...)` are invalid. \n See mathfield/changelog/ for details."),i))console.warn(e);console.groupEnd()}}if(uT()&&(this._internals=this.attachInternals(),this._internals.role="math",this._internals.ariaLabel="math input field",this._internals.ariaMultiLine="false"),this.attachShadow({mode:"open",delegatesFocus:!0}),this.shadowRoot&&"adoptedStyleSheets"in this.shadowRoot){this.shadowRoot.adoptedStyleSheets=[nE("core"),nE("mathfield"),nE("mathfield-element"),nE("ui"),nE("menu")],this.shadowRoot.appendChild(document.createElement("span"));let e=document.createElement("slot");e.style.display="none",this.shadowRoot.appendChild(e)}else this.shadowRoot.innerHTML="<style>"+nC("core")+nC("mathfield")+nC("mathfield-element")+nC("ui")+nC("menu")+'</style><span></span><slot style="display:none"></slot>';e&&this._setOptions(e)}static get formAssociated(){return uT()}static get optionsAttributes(){return{"default-mode":"string","letter-shape-style":"string","min-font-scale":"number","max-matrix-cols":"number","popover-policy":"string","math-mode-space":"string","read-only":"boolean","remove-extraneous-parentheses":"on/off","smart-fence":"on/off","smart-mode":"on/off","smart-superscript":"on/off","inline-shortcut-timeout":"string","script-depth":"string",placeholder:"string","virtual-keyboard-target-origin":"string","math-virtual-keyboard-policy":"string"}}static get observedAttributes(){return[...Object.keys(this.optionsAttributes),"contenteditable","disabled","readonly","read-only"]}static get fontsDirectory(){return this._fontsDirectory}static set fontsDirectory(e){e!==this._fontsDirectory&&(this._fontsDirectory=e,sD())}get fontsDirectory(){throw Error("Use MathfieldElement.fontsDirectory instead")}set fontsDirectory(e){throw Error("Use MathfieldElement.fontsDirectory instead")}static get stylesheetScope(){return nS}static set stylesheetScope(e){e!==nS&&(nS=e,ng={})}get stylesheetScope(){throw Error("Use MathfieldElement.stylesheetScope instead")}set stylesheetScope(e){throw Error("Use MathfieldElement.stylesheetScope instead")}static get soundsDirectory(){return this._soundsDirectory}static set soundsDirectory(e){this._soundsDirectory=e,this.audioBuffers={}}get soundsDirectory(){throw Error("Use MathfieldElement.soundsDirectory instead")}set soundsDirectory(e){throw Error("Use MathfieldElement.soundsDirectory instead")}static get keypressSound(){return this._keypressSound}static set keypressSound(e){var i,r,a;this.audioBuffers={},null===e?this._keypressSound={spacebar:null,return:null,delete:null,default:null}:"string"==typeof e?this._keypressSound={spacebar:e,return:e,delete:e,default:e}:"object"==typeof e&&"default"in e&&(this._keypressSound={spacebar:null!=(i=e.spacebar)?i:e.default,return:null!=(r=e.return)?r:e.default,delete:null!=(a=e.delete)?a:e.default,default:e.default})}static get plonkSound(){return this._plonkSound}static set plonkSound(e){this.audioBuffers={},this._plonkSound=e}static get audioContext(){return this._audioContext||(this._audioContext=new AudioContext),this._audioContext}static get speechEngine(){return this._speechEngine}static set speechEngine(e){this._speechEngine=e}static get speechEngineRate(){return this._speechEngineRate}static set speechEngineRate(e){this._speechEngineRate=e}static get speechEngineVoice(){return this._speechEngineVoice}static set speechEngineVoice(e){this._speechEngineVoice=e}static get textToSpeechMarkup(){return this._textToSpeechMarkup}static set textToSpeechMarkup(e){this._textToSpeechMarkup=e}static get textToSpeechRules(){return this._textToSpeechRules}static set textToSpeechRules(e){this._textToSpeechRules=e}static get textToSpeechRulesOptions(){return this._textToSpeechRulesOptions}static set textToSpeechRulesOptions(e){this._textToSpeechRulesOptions=e}static get locale(){return I.locale}static set locale(e){"auto"===e&&(e=navigator.language.slice(0,5)),I.locale=e}get locale(){throw Error("Use MathfieldElement.locale instead")}set locale(e){throw Error("Use MathfieldElement.locale instead")}static get strings(){return I.strings}static set strings(e){I.merge(e)}get strings(){throw Error("Use MathfieldElement.strings instead")}set strings(e){throw Error("Use MathfieldElement.strings instead")}static get decimalSeparator(){return this._decimalSeparator}static set decimalSeparator(e){this._decimalSeparator=e,this._computeEngine&&console.warn("MathLive 0.110.9: setting MathfieldElement.decimalSeparator after the Compute Engine has been created has no effect on the engine. Reassign MathfieldElement.computeEngine with a freshly configured instance to apply the new separator.")}get decimalSeparator(){throw Error("Use MathfieldElement.decimalSeparator instead")}set decimalSeparator(e){throw Error("Use MathfieldElement.decimalSeparator instead")}static set scientificNotationTemplate(e){this._scientificNotationTemplate=e}static get scientificNotationTemplate(){return this._scientificNotationTemplate}static get fractionNavigationOrder(){return o$.fractionNavigationOrder}static set fractionNavigationOrder(e){if("numerator-denominator"!==e&&"denominator-numerator"!==e)throw Error("Invalid value");o$.fractionNavigationOrder!==e&&(o$.fractionNavigationOrder=e,sI())}static get compactSerialization(){return o$.compactSerialization}static set compactSerialization(e){o$.compactSerialization=!!e}static get computeEngine(){var e,i;if(void 0===this._computeEngine){let i=window[Symbol.for("io.cortexjs.compute-engine")],r=null==i?void 0:i.ComputeEngine;if(!r)return null;if(this._computeEngine=new r,this._computeEngine&&","===this.decimalSeparator){let[r,a]=String(null!=(e=null==i?void 0:i.version)?e:"").split(".").map(e=>parseInt(e,10));(r>0||0===r&&a>=58)&&(this._computeEngine.latexOptions=g(f({},this._computeEngine.latexOptions),{decimalSeparator:"{,}"}))}}return null!=(i=this._computeEngine)?i:null}static set computeEngine(e){this._computeEngine=e}get computeEngine(){throw Error("Use MathfieldElement.computeEngine instead")}set computeEngine(e){throw Error("Use MathfieldElement.computeEngine instead")}static get isFunction(){return"function"!=typeof this._isFunction?()=>!1:this._isFunction}static set isFunction(e){this._isFunction=e,sI()}static async loadSound(e){delete this.audioBuffers[e];let i="";switch(e){case"keypress":i=this._keypressSound.default;break;case"return":i=this._keypressSound.return;break;case"spacebar":i=this._keypressSound.spacebar;break;case"delete":i=this._keypressSound.delete;break;case"plonk":i=this.plonkSound}if("string"!=typeof i)return;i=i.trim();let r=this.soundsDirectory;if(null!=r&&"null"!==r&&"none"!==i&&"null"!==i)try{let a=await (await fetch(await sz(`${r}/${i}`))).arrayBuffer(),o=await this.audioContext.decodeAudioData(a);this.audioBuffers[e]=o}catch(e){}}static async playSound(e){if(("suspended"===this.audioContext.state||"interrupted"===this.audioContext.state)&&await this.audioContext.resume(),this.audioBuffers[e]||await this.loadSound(e),!this.audioBuffers[e])return;let i=this.audioContext.createBufferSource();i.buffer=this.audioBuffers[e];let r=this.audioContext.createGain();r.gain.value=.5,i.connect(r).connect(this.audioContext.destination),i.start()}showMenu(e){var i,r;return null!=(r=null==(i=this._mathfield)?void 0:i.showMenu(e))&&r}get mathVirtualKeyboard(){throw Error("The `mathVirtualKeyboard` property is not available on the MathfieldElement. Use `window.mathVirtualKeyboard` instead.")}onPointerDown(){window.addEventListener("pointerup",i=>{let r=this._mathfield;if(r&&i.target===this&&!r.disabled){this.dispatchEvent(new MouseEvent("click",{altKey:i.altKey,button:i.button,buttons:i.buttons,clientX:i.clientX,clientY:i.clientY,ctrlKey:i.ctrlKey,metaKey:i.metaKey,movementX:i.movementX,movementY:i.movementY,relatedTarget:i.relatedTarget,screenX:i.screenX,screenY:i.screenY,shiftKey:i.shiftKey}));let a=this.getOffsetFromPoint(i.clientX,i.clientY);a>=0&&e.openUrl(function(e,i){let r=e.model.at(i);for(;r;){if("\\href"===r.command){let e=r.args[0];if("string"==typeof e)return e}r=r.parent}return""}(r,a)),"touch"===i.pointerType&&this.selectionIsCollapsed&&(this.position=a)}},{once:!0})}getPromptValue(e,i){var r,a;return null!=(a=null==(r=this._mathfield)?void 0:r.getPromptValue(e,i))?a:""}setPromptValue(e,i,r){var a;null==(a=this._mathfield)||a.setPromptValue(e,i,r)}getPromptRange(e){var i,r;return null!=(r=null==(i=this._mathfield)?void 0:i.getPromptRange(e))?r:null}getPrompts(e){var i,r;return null!=(r=null==(i=this._mathfield)?void 0:i.getPrompts(e))?r:[]}get hasEditableContent(){var e,i;return null!=(i=null==(e=this._mathfield)?void 0:e.hasEditableContent)&&i}get form(){var e;return null==(e=this._internals)?void 0:e.form}get name(){var e;return null!=(e=this.getAttribute("name"))?e:""}get type(){return this.localName}get mode(){var e,i;return null!=(i=null==(e=this._mathfield)?void 0:e.model.mode)?i:"text"===this.defaultMode?"text":"math"}set mode(e){var i;null==(i=this._mathfield)||i.switchMode(e)}get expression(){if(this._mathfield)return window[Symbol.for("io.cortexjs.compute-engine")]?this._mathfield.expression:(console.error(`MathLive 0.110.9: The CortexJS Compute Engine library is not available.
|
|
3491
|
+
"win" modifier can only be used with Windows platform.`);a="windows",r.win=!1,r.cmd=!1,r.meta=!0}if(a&&!function(e){if(v()){let i=w(),r=e.startsWith("!"),a=e.endsWith(i);if(r&&!a||!r&&a)return!0}return"!other"!==e&&"other"===e}(a))return;if(/^\[.+\]$/.test(r.key))return g(f({},e),{key:E(r)});let o=function(e,i){var r;let a={shift:!1,alt:!1,cmd:!1,win:!1,meta:!1,ctrl:!1,key:""};if(!e)return a;for(let[r,o]of Object.entries(i.mapping)){if(o[0]===e)return a.key=`[${r}]`,a;if(o[1]===e)return a.shift=!0,a.key=`[${r}]`,a;if(o[2]===e)return a.alt=!0,a.key=`[${r}]`,a;if(o[3]===e)return a.shift=!0,a.alt=!0,a.key=`[${r}]`,a}return a.key=null!=(r=z[e])?r:"",a}(r.key,i);if(!o)return g(f({},e),{key:E(r)});if(o.shift&&r.shift||o.alt&&r.alt)throw Error(`The keybinding ${e.key} (${so(e.command)}) is conflicting with the key combination ${E(o)} using the ${i.displayName} keyboard layout`);return o.shift=o.shift||r.shift,o.alt=o.alt||r.alt,o.meta=r.meta,o.ctrl=r.ctrl,g(f({},e),{key:E(o)})}(o,i);if(!e)continue;let r=a.find(i=>i.key===e.key&&i.ifMode===e.ifMode);if(r)throw Error(`Ambiguous key binding ${o.key} (${so(o.command)}) matches ${r.key} (${so(r.command)}) with the ${i.displayName} keyboard layout`);a.push(e)}catch(e){e instanceof Error&&r.push(e.message)}return[a,r]}(this.options.keybindings,null!=(e=$())?e:function(){switch(D()){case"apple":break;case"windows":return S;case"linux":return L}return M}());return(null==(i=$())?void 0:i.score)>0&&(this._keybindings=r,a.length>0&&console.error("MathLive 0.110.10: Invalid keybindings for current keyboard layout",a)),r}get menu(){var e,i;return null!=this._menu||(this._menu=new dv((e=this,[{label:()=>N("menu.array.add row above"),id:"add-row-above",onMenuSelect:()=>e.executeCommand("addRowBefore"),keyboardShortcut:"shift+alt+[Return]",visible:()=>{if(!e.isSelectionEditable||!ut(e))return!1;let[i,r]=ur(e),[a,o]=ua(e);return i!==a}},{label:()=>N("menu.array.add row below"),id:"add-row-below",onMenuSelect:()=>e.executeCommand("addRowAfter"),keyboardShortcut:"alt+[Return]",visible:()=>{if(!e.isSelectionEditable||!ut(e))return!1;let[i,r]=ur(e),[a,o]=ua(e);return i!==a}},{label:()=>N("menu.array.add column before"),id:"add-column-before",onMenuSelect:()=>e.executeCommand("addColumnBefore"),visible:()=>{if(!e.isSelectionEditable||!ut(e))return!1;let[i,r]=ur(e),[a,o]=ua(e);return r!==o},keyboardShortcut:"shift+alt+[Tab]",enabled:()=>{let i=e.model.parentEnvironment;if(!i)return!1;let[r,a]=ui(e);return r<i.maxColumns}},{label:()=>N("menu.array.add column after"),id:"add-column-after",onMenuSelect:()=>e.executeCommand("addColumnAfter"),keyboardShortcut:"alt+[Tab]",visible:()=>{if(!e.isSelectionEditable||!ut(e))return!1;let[i,r]=ur(e),[a,o]=ua(e);return r!==o}},{type:"divider"},{label:()=>N("menu.array.delete row"),id:"delete-row",onMenuSelect:()=>e.executeCommand("removeRow"),enabled:()=>{let[i,r]=ur(e),[a,o]=ui(e);return a>i},visible:()=>{if(!e.isSelectionEditable||!ut(e))return!1;let[i,r]=ur(e),[a,o]=ua(e);return i!==a}},{label:()=>N("menu.array.delete column"),id:"delete-column",onMenuSelect:()=>e.executeCommand("removeColumn"),enabled:()=>{let[i,r]=ur(e),[a,o]=ui(e);return o>r},visible:()=>{if(!e.isSelectionEditable||!ut(e))return!1;let[i,r]=ur(e),[a,o]=ua(e);return r!==o}},{type:"divider"},{label:()=>N("menu.borders"),visible:()=>{var i;let r;return("array"===(r=(i=e).model.at(i.model.position)).type&&["matrix","pmatrix","bmatrix","vmatrix","Bmatrix"].includes(r.environmentName)||ut(e))&&e.isSelectionEditable},submenu:[{label:" ⋱ ",id:"environment-no-border",onMenuSelect:()=>uo(e,"matrix")},{label:"(⋱)",id:"environment-parentheses",onMenuSelect:()=>uo(e,"pmatrix")},{label:"[⋱]",id:"environment-brackets",onMenuSelect:()=>uo(e,"bmatrix")},{label:"|⋱|",id:"environment-bar",onMenuSelect:()=>uo(e,"vmatrix")},{label:"{⋱}",id:"environment-braces",onMenuSelect:()=>uo(e,"Bmatrix")}],submenuClass:"border-submenu"},{type:"divider"},{label:()=>N("menu.insert matrix"),id:"insert-matrix",visible:()=>e.isSelectionEditable,submenu:function(e){let i=[];for(let r=1;r<=5;r++)for(let a=1;a<=5;a++)i.push({id:`insert-matrix-${r}x${a}`,onCreate:(e,i)=>new ue(e,i,r,a),label:"☐",tooltip:()=>N("tooltip.row-by-col",r,a),data:{row:r,col:a},onMenuSelect:()=>{e.insert(`\\begin{pmatrix}${Array(r).fill(Array(a).fill("#?").join(" & ")).join("\\\\")}\\end{pmatrix}`,{selectionMode:"item"})}});return i}(e),submenuClass:"insert-matrix-submenu",columnCount:5},{type:"divider"},{label:()=>N("menu.insert"),id:"insert",submenu:(i=e,[{label:()=>us("abs"),id:"insert-abs",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("|#?|")},{label:()=>us("nth-root"),id:"insert-nth-root",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\sqrt[#?]{#?}")},{label:()=>us("log-base"),id:"insert-log-base",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\log_{#?}{#?}")},{type:"heading",label:()=>N("menu.insert.heading-calculus")},{label:()=>us("derivative"),id:"insert-derivative",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\dfrac{\\mathrm{d}}{\\mathrm{d}x}#?\\bigm|_{x=#?}")},{label:()=>us("nth-derivative"),id:"insert-nth-derivative",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\dfrac{\\mathrm{d}^#?}{\\mathrm{d}x^#?}#?\\bigm|_{x=#?}")},{label:()=>us("integral"),id:"insert-integral",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\int_#?^#?#?\\,\\mathrm{d}#?")},{label:()=>us("sum"),id:"insert-sum",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\sum_#?^#?#?")},{label:()=>us("product"),id:"insert-product",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\prod_#?^#?#?")},{type:"heading",label:()=>N("menu.insert.heading-complex-numbers")},{label:()=>us("modulus"),id:"insert-modulus",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\lvert#?\\rvert")},{label:()=>us("argument"),id:"insert-argument",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\arg(#?)")},{label:()=>us("real-part"),id:"insert-real-part",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\Re(#?)")},{label:()=>us("imaginary-part"),id:"insert-imaginary-part",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\Im(#?)")},{label:()=>us("conjugate"),id:"insert-conjugate",visible:()=>i.isSelectionEditable,onMenuSelect:()=>i.insert("\\overline{#?}")}])},{type:"divider"},{label:()=>N("menu.mode"),id:"mode",visible:()=>e.isSelectionEditable&&e.model.selectionIsCollapsed,submenu:[{label:()=>N("menu.mode-math"),id:"mode-math",onMenuSelect:()=>{sg(e,"accept-all"),e.executeCommand(["switchMode","math"])},checked:()=>"math"===e.model.mode},{label:()=>N("menu.mode-text"),id:"mode-text",onMenuSelect:()=>{sg(e,"accept-all"),e.executeCommand(["switchMode","text"])},checked:()=>"text"===e.model.mode},{label:()=>N("menu.mode-latex"),id:"mode-latex",onMenuSelect:()=>e.executeCommand(["switchMode","latex"]),checked:()=>"latex"===e.model.mode}]},{type:"divider"},{label:()=>N("menu.font-style"),id:"variant",visible:()=>e.isSelectionEditable,submenu:[un(e,"double-struck","mathbb","tooltip.blackboard"),un(e,"fraktur","mathfrak","tooltip.fraktur"),un(e,"calligraphic","mathcal","tooltip.caligraphic"),ul(e,"up","mathrm","tooltip.roman-upright"),ul(e,"bold","bm","tooltip.bold"),ul(e,"italic","mathit","tooltip.italic")],submenuClass:"variant-submenu"},{label:()=>N("menu.color"),id:"color",visible:()=>e.isSelectionEditable,submenu:function(e){let i=[];for(let r of Object.keys(j))i.push({id:`color-${r}`,class:("#000"===d5(j[r])?"dark-contrast":"light-contrast")+" menu-swatch",label:`<span style="background:${j[r]} "></span>`,ariaLabel:()=>{var e;return null!=(e=N(r))?e:r},checked:()=>{var i;return null!=(i=({some:"mixed",all:!0})[e.queryStyle({color:r})])&&i},onMenuSelect:()=>e.applyStyle({color:r},{operation:"toggle"})});return i}(e),columnCount:4,submenuClass:"swatches-submenu"},{label:()=>N("menu.background-color"),id:"background-color",visible:()=>e.isSelectionEditable,submenu:function(e){let i=[];for(let r of Object.keys(V))i.push({id:`background-color-${r}`,class:("#000"===function(e){let i=dQ(e),r=(0x1000000+(d0(i.r)<<16)+(d0(i.g)<<8)+d0(i.b)).toString(16).slice(1);return void 0!==i.alpha&&i.alpha<1&&(r+=("00"+Math.round(255*i.alpha).toString(16)).slice(-2)),r[0]===r[1]&&r[2]===r[3]&&r[4]===r[5]&&r[6]===r[7]&&(r=r[0]+r[2]+r[4]+(void 0!==i.alpha&&i.alpha<1?r[6]:"")),"#"+r}(d5(V[r]))?"dark-contrast":"light-contrast")+" menu-swatch",label:`<span style="background:${V[r]} "></span>`,ariaLabel:()=>{var e;return null!=(e=N(r))?e:r},checked:()=>{var i;return null!=(i=({some:"mixed",all:!0})[e.queryStyle({backgroundColor:r})])&&i},onMenuSelect:()=>e.applyStyle({backgroundColor:r},{operation:"toggle"})});return i}(e),columnCount:4,submenuClass:"swatches-submenu"},{label:()=>N("menu.accent"),id:"accent",visible:()=>e.isSelectionEditable,submenu:[{id:"accent-vec",class:"ML__center-menu",label:()=>dW(`\\vec{${d7(e)}}`),visible:()=>1===d7(e).length,onMenuSelect:()=>e.insert("\\vec{#@}",{selectionMode:"item"})},{id:"accent-overrightarrow",class:"ML__center-menu",label:()=>dW(`\\overrightarrow{${d7(e)}}`),visible:()=>d7(e).length>0,onMenuSelect:()=>e.insert("\\overrightarrow{#@}",{selectionMode:"item"})},{id:"accent-overleftarrow",class:"ML__center-menu",label:()=>dW(`\\overleftarrow{${d7(e)}}`),visible:()=>d7(e).length>0,onMenuSelect:()=>e.insert("\\overleftarrow{#@}",{selectionMode:"item"})},{id:"accent-dot",class:"ML__center-menu",label:()=>dW(`\\dot{${d7(e)}}`),visible:()=>1===d7(e).length,onMenuSelect:()=>e.insert("\\dot{#@}",{selectionMode:"item"})},{id:"accent-ddot",class:"ML__center-menu",label:()=>dW(`\\ddot{${d7(e)}}`),visible:()=>1===d7(e).length,onMenuSelect:()=>e.insert("\\ddot{#@}",{selectionMode:"item"})},{id:"accent-bar",class:"ML__center-menu",label:()=>dW(`\\bar{${d7(e)}}`),visible:()=>1===d7(e).length,onMenuSelect:()=>e.insert("\\bar{#@}",{selectionMode:"item"})},{id:"accent-overline",class:"ML__center-menu",label:()=>dW(`\\overline{${d7(e)}}`),visible:()=>d7(e).length>0,onMenuSelect:()=>e.insert("\\overline{#@}",{selectionMode:"item"})},{id:"accent-overgroup",class:"ML__center-menu",label:()=>dW(`\\overgroup{${d7(e)}}`),visible:()=>d7(e).length>0,onMenuSelect:()=>e.insert("\\overgroup{#@}",{selectionMode:"item"})},{id:"accent-overbrace",class:"ML__center-menu",label:()=>dW(`\\overbrace{${d7(e)}}`),visible:()=>d7(e).length>0,onMenuSelect:()=>e.insert("\\overbrace{#@}",{selectionMode:"item"})},{id:"accent-underline",class:"ML__center-menu",label:()=>dW(`\\underline{${d7(e)}}`),visible:()=>d7(e).length>0,onMenuSelect:()=>e.insert("\\underline{#@}",{selectionMode:"item"})},{id:"accent-undergroup",class:"ML__center-menu",label:()=>dW(`\\undergroup{${d7(e)}}`),visible:()=>d7(e).length>0,onMenuSelect:()=>e.insert("\\undergroup{#@}",{selectionMode:"item"})},{id:"accent-underbrace",class:"ML__center-menu",label:()=>dW(`\\underbrace{${d7(e)}}`),visible:()=>d7(e).length>0,onMenuSelect:()=>e.insert("\\underbrace{#@}",{selectionMode:"item"})}],submenuClass:"variant-submenu"},{label:()=>N("menu.decoration"),id:"decoration",visible:()=>e.isSelectionEditable&&d7(e).length>0,submenu:[{id:"decoration-boxed",label:()=>dW(`\\boxed{${e.getValue(e.model.selection)}}}`),onMenuSelect:()=>e.insert("\\boxed{#@}",{selectionMode:"item"})},{id:"decoration-red-box",label:()=>dW(`\\bbox[5px, border: 2px solid red]{${e.getValue(e.model.selection)}}`),onMenuSelect:()=>e.insert("\\bbox[5px, border: 2px solid red]{#@}",{selectionMode:"item"})},{id:"decoration-dashed-black-box",label:()=>dW(`\\bbox[5px, border: 2px dashed black]{${e.getValue(e.model.selection)}}`),onMenuSelect:()=>e.insert("\\bbox[5px, border: 2px dashed black]{#@}",{selectionMode:"item"})}],submenuClass:"variant-submenu"},{type:"divider"},{label:()=>N("menu.evaluate"),id:"ce-evaluate",visible:()=>e.isSelectionEditable&&null!==globalThis.MathfieldElement.computeEngine,onMenuSelect:()=>{let i=function(e){var i,r;let a;if(!(a=e.model.selectionIsCollapsed?null==(i=globalThis.MathfieldElement.computeEngine)?void 0:i.parse(e.getValue(),{canonical:!1}):null==(r=globalThis.MathfieldElement.computeEngine)?void 0:r.parse(e.getValue(e.model.selection),{canonical:!1})))return"";let o=a.evaluate();return o.isSame(a)&&(o=a.N()),o.latex}(e);i?e.model.selectionIsCollapsed?(e.model.position=e.model.lastOffset,e.insert(`=${i}`,{insertionMode:"insertAfter",selectionMode:"item"})):e.insert(i,{insertionMode:"replaceSelection",selectionMode:"item"}):e.model.announce("plonk")}},{label:()=>N("menu.simplify"),id:"ce-simplify",visible:()=>e.isSelectionEditable&&null!==globalThis.MathfieldElement.computeEngine,onMenuSelect:()=>{var i,r;if(e.model.selectionIsCollapsed){let r=null==(i=e.expression)?void 0:i.simplify();if(e.model.position=e.model.lastOffset,!r)return void e.model.announce("plonk");e.insert(`=${r.latex}`,{insertionMode:"insertAfter",selectionMode:"item"})}else{let i=null==(r=globalThis.MathfieldElement.computeEngine)?void 0:r.parse(e.getValue(e.model.selection)).simplify();if(!i)return void e.model.announce("plonk");e.insert(i.latex,{insertionMode:"replaceSelection",selectionMode:"item"})}}},{label:()=>{var i;let r=globalThis.MathfieldElement.computeEngine;if(null===r)return"";let a=null==(i=e.expression)?void 0:i.unknowns[0];return a?N("menu.solve-for",dW(r.box(a).latex)):N("menu.solve")},id:"ce-solve",visible:()=>{var i;return e.isSelectionEditable&&null!==globalThis.MathfieldElement.computeEngine&&(null==(i=e.expression)?void 0:i.unknowns.length)===1&&"Nothing"!==e.expression.unknowns[0]},onMenuSelect:()=>{let i=e.expression,r=null==i?void 0:i.unknowns[0],a=i.solve(r),o=Array.isArray(a)?a.map(e=>{var i;return null!=(i=e.simplify().latex)?i:""}):null;o?e.insert(`${r}=${1===o.length?o[0]:"\\left\\lbrace"+(null==o?void 0:o.join(", "))+"\\right\\rbrace"}`,{insertionMode:"replaceAll",selectionMode:"item"}):e.model.announce("plonk")}},{type:"divider"},{label:()=>N("menu.cut"),id:"cut",onMenuSelect:()=>e.executeCommand("cutToClipboard"),visible:()=>!e.options.readOnly&&e.isSelectionEditable,keyboardShortcut:"meta+X"},{label:()=>N("menu.copy"),id:"copy",submenu:[{label:()=>N("menu.copy-as-latex"),id:"copy-latex",onMenuSelect:()=>na.copyToClipboard(e,"latex"),keyboardShortcut:"meta+C"},{label:()=>N("menu.copy-as-typst"),id:"copy-latex",onMenuSelect:()=>na.copyToClipboard(e,"typst")},{label:()=>N("menu.copy-as-ascii-math"),id:"copy-ascii-math",onMenuSelect:()=>na.copyToClipboard(e,"ascii-math")},{label:()=>N("menu.copy-as-mathml"),id:"copy-math-ml",onMenuSelect:()=>na.copyToClipboard(e,"math-ml")}]},{label:()=>N("menu.paste"),id:"paste",onMenuSelect:()=>e.executeCommand("pasteFromClipboard"),visible:()=>e.hasEditableContent,keyboardShortcut:"meta+V"},{label:()=>N("menu.select-all"),id:"select-all",keyboardShortcut:"meta+A",onMenuSelect:()=>e.executeCommand("selectAll")}]),{host:this.host})),this._menu}set menuItems(e){this._menu?this._menu.menuItems=e:this._menu=new dv(e,{host:this.host})}setOptions(e){var i;this.options=f(f({},this.options),cn(e)),this._keybindings=void 0,"inline-math"===this.options.defaultMode?this.element.classList.add("ML__is-inline"):this.element.classList.remove("ML__is-inline");let r=this.options.defaultMode;"inline-math"===r&&(r="math"),(null==(i=this.model.root.firstChild)?void 0:i.mode)!==r&&(this.model.root.firstChild.mode=r),this.options.readOnly&&this.hasFocus()&&window.mathVirtualKeyboard.visible&&this.executeCommand("hideVirtualKeyboard");let a=oG.serialize([this.model.root],{expandMacro:!1,defaultMode:this.options.defaultMode});("macros"in e||this.model.getValue()!==a)&&sI(this),("value"in e||"registers"in e||"colorMap"in e||"backgroundColorMap"in e||"letterShapeStyle"in e||"minFontScale"in e||"maxMatrixCols"in e||"readOnly"in e||"contentPlaceholder"in e||"placeholderSymbol"in e)&&s$(this)}getOptions(e){return cl(this.options,e)}getOption(e){return cl(this.options,e)}async handleEvent(e){var i,r,a;if(nl(this)){if(sW(e)){if(!np(e.origin,null!=(i=this.options.originValidator)?i:"none"))throw new DOMException(`Message from unknown origin (${e.origin}) cannot be handled`,"SecurityError");let{action:r}=e.data;if("execute-command"===r){let i=sj(e.data.command);if(!i||"virtual-keyboard"===sV(i))return;this.executeCommand(i)}else"update-state"===r||("focus"===r?this.focus({preventScroll:!0}):"blur"===r&&this.blur());return}switch(e.type){case"focus":this.programmaticFocusInProgress||this.onFocus({suppressEvents:!0});break;case"blur":this.onBlur({dispatchEvents:!1});break;case"mousedown":"none"===this.userSelect||null!=(r=e.target)&&r.closest("[part=virtual-keyboard-toggle],[part=menu-toggle]")||cZ(this,e);break;case"pointerdown":!e.defaultPrevented&&"none"!==this.userSelect&&!(null!=(a=e.target)&&a.closest("[part=virtual-keyboard-toggle],[part=menu-toggle]"))&&(cZ(this,e),!1===e.shiftKey&&await dw(e,this.container,this.menu)&&cJ.stop());break;case"contextmenu":"none"!==this.userSelect&&!1===e.shiftKey&&await dw(e,this.container,this.menu)&&cJ.stop();break;case"virtual-keyboard-toggle":this.hasFocus()&&di(this),this.hasFocus()&&"manual"!==this.options.mathVirtualKeyboardPolicy&&(this.focusBlurInProgress=!0,this.keyboardDelegate.blur(),this.keyboardDelegate.focus(),this.focusBlurInProgress=!1);break;case"resize":this.geometryChangeTimer&&cancelAnimationFrame(this.geometryChangeTimer),this.geometryChangeTimer=requestAnimationFrame(()=>nl(this)&&this.onGeometryChange());break;case"scroll":this.geometryChangeTimer&&cancelAnimationFrame(this.geometryChangeTimer),this.geometryChangeTimer=requestAnimationFrame(()=>nl(this)&&this.onGeometryChange());break;case"wheel":this.onWheel(e);break;case"message":break;default:console.warn("Unexpected event type",e.type)}}}updateToggleLayout(){if(!this.element||!this.host)return;let e=this.element.querySelector(".ML__toggles");if(!e)return;let i=this.host.offsetHeight,r=e.classList.contains("ML__toggles--vertical");i>=100&&!r?e.classList.add("ML__toggles--vertical"):i<100&&r&&e.classList.remove("ML__toggles--vertical")}dispose(){if(!nl(this))return;I.unsubscribe(this._l10Subscription),this.keyboardDelegate.dispose(),this.keyboardDelegate=void 0,this.eventController.abort(),this.eventController=void 0,this.resizeObserver.disconnect(),window.mathVirtualKeyboard.removeEventListener("virtual-keyboard-toggle",this),this.disconnectFromVirtualKeyboard(),this.model.dispose();let e=this.element;delete e.mathfield,this.element=void 0,this.host=void 0,this.field=void 0,this.ariaLiveText=void 0,document.getElementById("mathlive-keystroke-caption-panel")&&(sy("mathlive-keystroke-caption-panel"),nT("core"),nT("keystroke-caption")),document.getElementById("mathlive-suggestion-popover")&&(sy("mathlive-suggestion-popover"),nT("suggestion-popover"),nT("core")),document.getElementById("mathlive-environment-popover")&&(sy("mathlive-environment-popover"),nT("environment-popover"),nT("core"))}flushInlineShortcutBuffer(e){if(null!=e||(e={defer:!1}),!e.defer){this.inlineShortcutBuffer.length=0,clearTimeout(this.inlineShortcutBufferFlushTimer),this.inlineShortcutBufferFlushTimer=0;return}this.options.inlineShortcutTimeout>0&&(clearTimeout(this.inlineShortcutBufferFlushTimer),this.inlineShortcutBufferFlushTimer=setTimeout(()=>this.flushInlineShortcutBuffer(),this.options.inlineShortcutTimeout))}executeCommand(e){return"virtual-keyboard"===sV(e)?(this.focus({preventScroll:!0}),window.mathVirtualKeyboard.executeCommand(e),requestAnimationFrame(()=>window.mathVirtualKeyboard.update(c2(this))),!1):function(e,i){var r,a;if(!(i=sj(i)))return!1;let o,n=[],l=!1,s=!1;R(i)?(o=i[0],n=i.slice(1)):o=i;let c=sU[o],d=null==c?void 0:c.target;if("model"===d){if(!e.isSelectionEditable&&null!=c&&c.changeContent)return e.model.announce("plonk"),!1;/^(delete|add)/.test(o)&&("deleteBackward"!==o&&e.flushInlineShortcutBuffer(),e.snapshot(o)),/^complete/.test(o)||sp(e),sU[o].fn(e.model,...n),sm(e),s=!0,l=!0}else if("virtual-keyboard"===d)s=null!=(a=null==(r=window.mathVirtualKeyboard)?void 0:r.executeCommand(i))&&a,l=!0;else if(sU[o]){if(!e.isSelectionEditable&&null!=c&&c.changeContent)return e.model.announce("plonk"),!1;/^(undo|redo)/.test(o)&&e.flushInlineShortcutBuffer(),s=sU[o].fn(e,...n),l=!0}else throw Error(`Unknown command "${o}"`);return"virtual-keyboard"!==d&&(!e.model.selectionIsCollapsed||null!=c&&c.changeSelection&&"deleteBackward"!==o)&&(e.flushInlineShortcutBuffer(),null!=c&&c.changeContent||e.stopCoalescingUndo(),e.defaultStyle={}),s&&(null!=c&&c.changeSelection&&l?(e.dirty=!0,e.scrollIntoView()):s$(e)),l}(this,e)}get errors(){return lc(this.model.getValue(),{context:this.context})}getValue(e,i,r){return this.model.getValue(e,i,r)}setValue(e,i){var r;void 0===(i=null!=i?i:{mode:"math"}).insertionMode&&(i.insertionMode="replaceAll"),(void 0===i.format||"auto"===i.format)&&(i.format="latex"),(void 0===i.mode||"auto"===i.mode)&&(i.mode=null!=(r=function(e,i){let r=e.at(i),a;if(r){a=r.mode;let e=r.parent;for(;!a&&e;)e&&(a=e.mode),e=e.parent}return a}(this.model,this.model.position))?r:"math");let a=this.undoManager.canUndo();na.insert(this.model,e,i)&&(s$(this),a||this.undoManager.reset(),this.undoManager.snapshot("set-value"))}get expression(){let e=globalThis.MathfieldElement.computeEngine;return e?e.box(e.parse(this.model.getValue("latex-unstyled"))):(console.error("MathLive 0.110.10: no compute engine available. Make sure the Compute Engine library is loaded."),null)}scrollIntoView(){var e;if(!this.element)return;if(this.host){if(this.options.onScrollIntoView)this.options.onScrollIntoView(this);else if(this.host.scrollIntoView({block:"nearest",inline:"nearest"}),window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.container===window.document.body){let i=window.mathVirtualKeyboard.boundingRect,r=this.host.getBoundingClientRect();r.bottom>i.top&&(null==(e=window.document.scrollingElement)||e.scrollBy(0,r.bottom-i.top+8))}}this.dirty&&sO(this,{interactive:!0});let i=this.field.getBoundingClientRect(),r=null;if(this.model.selectionIsCollapsed)r=ns(this.field);else{let e=nh(this);if(e.length>0){let a=-1/0,o=1/0,n=-1/0;for(let i of e)i.right>a&&(a=i.right),i.top<o&&(o=i.top),i.bottom>n&&(n=i.bottom);let l=n-o;r={x:a+i.left-this.field.scrollLeft,y:o+i.top-this.field.scrollTop,height:l}}}if(this.host&&r){let e=this.host.getBoundingClientRect(),i=r.y,a=r.y+r.height,o=this.host.scrollTop;i<e.top+20?o=i-e.top+this.host.scrollTop-20:a>e.bottom-20&&(o=a-e.bottom+this.host.scrollTop+20),o!==this.host.scrollTop&&this.host.scroll({top:o,behavior:"auto"})}if(r){let e=r.x-window.scrollX,a=this.field.scrollLeft;e<i.left?a=e-i.left+this.field.scrollLeft-20:e>i.right&&(a=e-i.right+this.field.scrollLeft+20),this.field.scroll({top:this.field.scrollTop,left:a})}}insert(e,i){if("string"!=typeof e||0===e.length&&((null==i?void 0:i.insertionMode)==="insertBefore"||(null==i?void 0:i.insertionMode)==="insertAfter")||0===e.length&&this.model.selectionIsCollapsed)return!1;if(this.flushInlineShortcutBuffer(),(i=null!=i?i:{mode:"math"}).focus&&this.focus(),i.feedback&&(globalThis.MathfieldElement.keypressVibration&&_()&&navigator.vibrate(3),globalThis.MathfieldElement.playSound("keypress")),"\\\\"===e&&this.model.parentEnvironment)cm(this.model);else if("&"===e&&this.model.parentEnvironment)cf(this.model);else if(this.model.selectionIsCollapsed){let r=f({},su(this));/^[a-zA-Z0-9]$/.test(e)||"none"===this.styleBias||(r.variant="normal",r.variantStyle=void 0),na.insert(this.model,e,f({style:r},i))}else na.insert(this.model,e,i);return this.snapshot(`insert-${this.model.at(this.model.position).type}`),s$(this),i.scrollIntoView&&this.scrollIntoView(),!0}switchMode(e,i="",r=""){if(this.model.mode===e||!this.hasEditableContent||!this.contentEditable||this.disabled)return;let{model:a}=this,o=a.mode;if(a.mode=e,this.host&&!this.host.dispatchEvent(new Event("mode-change",{bubbles:!0,composed:!0,cancelable:!0}))){a.mode=o;return}a.mode=o,a.deferNotifications({content:!!r||!!i,selection:!0,type:"insertText"},()=>{let o=a.at(a.position),n=(e,i)=>{if(!e)return;let r="math"===a.mode?ls(o6(e,{format:"ascii-math"})[1],{context:this.context}):[...e].map(e=>new oY(e,e,{}));if(i.select){let e=o.parent.addChildrenAfter(r,o);a.setSelection(a.offsetOf(r[0].leftSibling),a.offsetOf(e))}else a.position=a.offsetOf(o.parent.addChildrenAfter(r,o));c=!0},l=(e,i)=>{let r=new lw(e);o.parent.addChildAfter(r,o),i.select?a.setSelection(a.offsetOf(r.firstChild),a.offsetOf(r.lastChild)):a.position=a.offsetOf(r.lastChild),c=!0},s=()=>{let i="latex"===e?"latex":"math"===e?"plain-text":"ascii-math",n=oQ(a.selection),l=this.model.getValue(n,i),s=this.model.extractAtoms(n);return 1===s.length&&"placeholder"===s[0].type&&(l=r),o=a.at(n[0]),l},c=!1;if(this.flushInlineShortcutBuffer(),this.stopCoalescingUndo(),sg(this,"accept"),a.selectionIsCollapsed)n(i,{select:!1}),a.mode=e,"latex"===e?l(r,{select:!1}):n(r,{select:!1});else{let i=s();a.mode=e,"latex"===e?l(i,{select:!0}):n(i,{select:!0})}return s$(this),this.undoManager.snapshot("latex"===e?"insert-latex":"insert"),c}),a.mode=e,window.mathVirtualKeyboard.update(c2(this))}hasFocus(){return!this.blurred}focus(e){var i;this.disabled||this.focusBlurInProgress||(this.hasFocus()||(this.programmaticFocusInProgress=!0,this.onFocus(),this.model.announce("line")),null!=(i=null==e?void 0:e.preventScroll)&&i||this.scrollIntoView())}blur(){this.disconnectFromVirtualKeyboard(),this.hasFocus()&&this.keyboardDelegate.blur()}select(){this.model.selection={ranges:[[0,this.model.lastOffset]]},this.focus()}applyStyle(e,i={}){var r;let a,o="set",n=!1;o1(i)?a=i:("toggle"===i.operation&&(o="toggle"),a=i.range,n=null!=(r=i.silenceNotifications)&&r),a&&(a=this.model.normalizeRange(a)),a&&a[0]===a[1]&&(a=void 0);let l=sc(this,e);if(void 0===a&&this.model.selectionIsCollapsed){if("set"===o){let e=f({},this.defaultStyle);"color"in l&&delete e.verbatimColor,"backgroundColor"in l&&delete e.verbatimBackgroundColor,this.defaultStyle=f(f({},e),l),this.styleBias="none";return}let e=su(this),i=f({},this.defaultStyle);for(let r of Object.keys(l))e[r]===l[r]?("color"===r&&delete i.verbatimColor,"backgroundColor"===r&&delete i.verbatimBackgroundColor,delete i[r]):i[r]=l[r];this.defaultStyle=i,this.styleBias="none";return}this.model.deferNotifications({content:!n,type:"insertText"},()=>{if(void 0===a)for(let e of this.model.selection.ranges)lq(this.model,e,l,{operation:o});else lq(this.model,a,l,{operation:o})}),s$(this)}toggleContextMenu(){var e;let i=this.menu;if(!i.visible)return!1;if("open"===i.state)return i.hide(),!0;let r=null==(e=nf(this,this.model.position))?void 0:e.bounds;if(!r)return!1;let a={x:r.right,y:r.bottom};return i.show({target:this.element.querySelector("[part=container]"),location:a,onDismiss:()=>{var e;return null==(e=this.element)?void 0:e.focus()}}),!0}getPrompt(e){return this.model.findAtom(i=>"prompt"===i.type&&i.placeholderId===e)}getPromptValue(e,i){let r=this.getPrompt(e);if(!r)return"";let a=this.model.offsetOf(r.firstChild),o=this.model.offsetOf(r.lastChild);return this.model.getValue(a,o,i)}getPrompts(e){return this.model.atoms.filter(i=>"prompt"===i.type&&(!e||!(e.id&&i.placeholderId!==e.id||e.locked&&i.locked!==e.locked||"undefined"===e.correctness&&i.correctness||e.correctness&&i.correctness!==e.correctness))).map(e=>e.placeholderId)}setPromptValue(e,i,r){if(void 0!==i){let a=this.getPrompt(e);if(!a)return void console.error(`MathLive 0.110.10: unknown prompt ${e}`);let o=this.model.getBranchRange(this.model.offsetOf(a),"body");this.model.setSelection(o),this.insert(i,g(f({},r),{insertionMode:"replaceSelection"}))}null!=r&&r.silenceNotifications&&(this.valueOnFocus=this.getValue()),s$(this)}setPromptState(e,i,r){let a=this.getPrompt(e);a?("undefined"===i?a.correctness=void 0:"string"==typeof i&&(a.correctness=i),"boolean"==typeof r&&(a.locked=r,a.captureSelection=r),s$(this)):console.error(`MathLive 0.110.10: unknown prompt ${e}`)}getPromptState(e){let i=this.getPrompt(e);return i?[i.correctness,i.locked]:(console.error(`MathLive 0.110.10: unknown prompt ${e}`),[void 0,!0])}getPromptRange(e){let i=this.getPrompt(e);return i?this.model.getBranchRange(this.model.offsetOf(i),"body"):(console.error(`MathLive 0.110.10: unknown prompt ${e}`),[0,0])}canUndo(){return this.undoManager.canUndo()}canRedo(){return this.undoManager.canRedo()}popUndoStack(){this.undoManager.pop(),window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(c2(this))}snapshot(e){var i;this.undoManager.snapshot(e)&&(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(c2(this)),null==(i=this.host)||i.dispatchEvent(new CustomEvent("undo-state-change",{bubbles:!0,composed:!0,detail:{type:"snapshot"}})))}stopCoalescingUndo(){this.undoManager.stopCoalescing(this.model.selection)}stopRecording(){this.undoManager.stopRecording()}startRecording(){this.undoManager.startRecording()}undo(){var e;this.undoManager.undo()&&(null==(e=this.host)||e.dispatchEvent(new CustomEvent("undo-state-change",{bubbles:!0,composed:!0,detail:{type:"undo"}})))}redo(){var e;this.undoManager.redo()&&(null==(e=this.host)||e.dispatchEvent(new CustomEvent("undo-state-change",{bubbles:!0,composed:!0,detail:{type:"redo"}})))}resetUndo(){var e;null==(e=this.undoManager)||e.reset()}onSelectionDidChange(){var e,i;let r=this.model;if(r.mathfield.hasFocus()&&this.keyboardDelegate.setValue(r.getValue(r.selection,"latex-expanded")),r.selectionIsCollapsed){let i=sn(r),a=r.position,o=r.at(a),n=null!=(e=o.mode)?e:cc(this.options);if(i&&(a<r.offsetOf(i.firstChild)||a>r.offsetOf(i.lastChild))){sg(this,"accept",{mode:n});let e=r.offsetOf(o);e>=0&&(r.position=e)}else{let e=r.at(a+1);(null==e?void 0:e.type)==="first"&&"latex"===e.mode?r.position=a+1:i&&(null==e?void 0:e.mode)!=="latex"?r.position=a-1:this.switchMode(n)}}null==(i=this.host)||i.dispatchEvent(new Event("selection-change",{bubbles:!0,composed:!0})),window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(c2(this)),di(this)}onContentWillChange(e){var i,r,a;return null==(a=null==(r=this.host)?void 0:r.dispatchEvent(new InputEvent("beforeinput",g(f({},e),{data:e.data?e.data:null!=(i=e.inputType)?i:"",cancelable:!0,bubbles:!0,composed:!0}))))||a}onFocus(i){if(this.disabled||this.focusBlurInProgress||!this.blurred)return;let r=e._globallyFocusedMathfield;r&&r!==this&&!r.disabled&&r.hasFocus()&&r.onBlur({dispatchEvents:!0}),this.focusBlurInProgress=!0,this.blurred=!1,e._globallyFocusedMathfield=this,this.stopCoalescingUndo(),this.valueOnFocus=this.model.getValue(),this.hasEditablePrompts&&!this.model.at(this.model.anchor).parentPrompt&&this.executeCommand("moveToNextPlaceholder"),sO(this,{interactive:!0}),setTimeout(()=>{var e,r;if(nl(this))if(null!=(e=null==i?void 0:i.suppressEvents)&&e){let e=new AbortController,i=e.signal,a=e=>{e.preventDefault(),e.stopPropagation()};for(let e of["focus","focusin"])null==(r=this.host)||r.addEventListener(e,a,{capture:!0,signal:i});this.focusBlurInProgress=!1,this.keyboardDelegate.focus(),this.connectToVirtualKeyboard(),setTimeout(()=>e.abort(),0)}else this.focusBlurInProgress=!1,this.keyboardDelegate.focus(),this.connectToVirtualKeyboard(),setTimeout(()=>{this.programmaticFocusInProgress=!1},0)},60)}onBlur(i){var r,a,o,n;if(!this.focusBlurInProgress&&!this.blurred&&(this.focusBlurInProgress=!0,this.stopCoalescingUndo(),this.blurred=!0,e._globallyFocusedMathfield===this&&(e._globallyFocusedMathfield=void 0),this.ariaLiveText&&(this.ariaLiveText.textContent=""),sS(this),this.model.getValue()!==this.valueOnFocus&&(null==(r=this.host)||r.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))),this.disconnectFromVirtualKeyboard(),(null==(a=null==i?void 0:i.dispatchEvents)||a)&&(null==(o=this.host)||o.dispatchEvent(new Event("blur",{bubbles:!1,composed:!0})),null==(n=this.host)||n.dispatchEvent(new UIEvent("focusout",{bubbles:!0,composed:!0}))),s$(this),this.focusBlurInProgress=!1,dt(),uR.restoreFocusWhenDocumentFocused)){let e=new AbortController,i=e.signal;window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{nl(this)&&this.focus({preventScroll:!0})},{once:!0,signal:i})},{once:!0,signal:i}),document.addEventListener("focusin",()=>e.abort(),{once:!0}),document.addEventListener("click",()=>e.abort(),{once:!0})}}onInput(e){cq(this,e)}onKeystroke(e){return cI(this,e)}onCompositionStart(e){c_(this.model,oQ(this.model.selection),"insertText");let i=ns(this.field);i&&requestAnimationFrame(()=>{sO(this),this.keyboardDelegate.moveTo(i.x,i.y-i.height)})}onCompositionUpdate(e){(function(e,i){let r=e.at(e.position);if("composition"===r.type)r.value=i;else{let{caret:a}=r;r.caret=void 0;let o=new n7(i,{mode:r.mode});o.caret=a,r.parent.addChildAfter(o,r),e.position+=1}})(this.model,e),s$(this)}onCompositionEnd(e){var i;let r;"composition"===(r=(i=this.model).at(i.position)).type&&(r.parent.removeChild(r),i.position-=1),cq(this,e,{simulateKeystroke:!0})}onCut(e){this.isSelectionEditable?this.model.contentWillChange({inputType:"deleteByCut"})&&(this.stopCoalescingUndo(),e.clipboardData?na.onCopy(this,e):na.copyToClipboard(this,"latex"),c_(this.model,oQ(this.model.selection),"deleteByCut"),this.snapshot("cut"),s$(this)):this.model.announce("plonk")}onCopy(e){e.clipboardData?na.onCopy(this,e):na.copyToClipboard(this,"latex")}onPaste(e){let i=this.isSelectionEditable;return i&&(i=na.onPaste(this.model.at(this.model.position).mode,this,e.clipboardData)),i||this.model.announce("plonk"),e.preventDefault(),e.stopPropagation(),i}onGeometryChange(){var e;null==(e=this._menu)||e.hide(),sM(this),di(this)}onWheel(e){let i=5*e.deltaX;if(!Number.isFinite(i)||0===i)return;let r=this.field;i<0&&0===r.scrollLeft||i>0&&r.offsetWidth+r.scrollLeft>=r.scrollWidth||(r.scrollBy({top:0,left:i}),e.preventDefault(),e.stopPropagation())}getHTMLElement(e){let i=e;for(;!i.id&&i.hasChildren;)i=e.children[0];return this.field.querySelector(`[data-atom-id="${i.id}"]`)}get context(){var e,i;return{registers:null!=(e=this.options.registers)?e:{},smartFence:this.smartFence,letterShapeStyle:this.letterShapeStyle,minFontScale:this.minFontScale,maxMatrixCols:this.maxMatrixCols,placeholderSymbol:null!=(i=this.options.placeholderSymbol)?i:"▢",colorMap:e=>this.colorMap(e),backgroundColorMap:e=>this.backgroundColorMap(e),getMacro:e=>eS(e,this.options.macros),atomIdsSettings:{seed:"random",groupNumbers:!1}}}};sq({speak:(e,i,r)=>(function(e,i,r){var a;r=null!=r?r:{withHighlighting:!1};let{model:o}=e,n=globalThis.MathfieldElement,l=function(e){let i=null;switch(e){case"all":default:i=o.root;break;case"selection":i=o.getAtoms(o.selection);break;case"left":i=o.getAtoms(o.offsetOf(o.at(o.position).leftSibling),o.position);break;case"right":i=o.getAtoms(o.position,o.offsetOf(o.at(o.position).rightSibling));break;case"group":i=o.getAtoms(o.getSiblingsRange(o.position));break;case"parent":{let{parent:e}=o.at(o.position);i=null!=e&&e.parent?e:o.root}}return i}(i);if(null===l)return null==(a=n.speakHook)||a.call(n,function(e){let i="";switch(e){case"all":console.error("Internal failure: speak all failed");break;case"selection":i="no selection";break;case"left":i="at start";break;case"right":i="at end";break;case"group":console.error("Internal failure: speak group failed");break;case"parent":i="no parent";break;default:console.error('unknown speak_ param value: "'+e+'"')}return i}(i)),!1;(r.withHighlighting||"amazon"===n.speechEngine)&&(n.textToSpeechMarkup=globalThis.sre&&"sre"===n.textToSpeechRules?"ssml_step":"ssml");let s=dq(l);return v()&&r.withHighlighting?(uG().readAloudMathfield=e,sO(e,{forHighlighting:!0}),n.readAloudHook&&n.readAloudHook(e.field,s)):n.speakHook&&n.speakHook(s),!1})(e,i,r)},{target:"mathfield"}),v()||console.error('MathLive 0.110.10: this version of the MathLive library is for use in the browser. A subset of the API is available on the server side in the "mathlive-ssr" library. If using server side rendering (with React for example) you may want to do a dynamic import of the MathLive library inside a `useEffect()` call.');var uL=new WeakMap,uC={letterShapeStyle:"mf.letterShapeStyle = ...",horizontalSpacingScale:'Removed. Use `"thinmuskip"`, `"medmuskip"`, and `"thickmuskip"` registers ',macros:"mf.macros = ...",registers:"mf.registers = ...",backgroundColorMap:"mf.backgroundColorMap = ...",colorMap:"mf.colorMap = ...",enablePopover:"mf.popoverPolicy = ...",mathModeSpace:"mf.mathModeSpace = ...",placeholderSymbol:"mf.placeholderSymbol = ...",readOnly:"mf.readOnly = ...",removeExtraneousParentheses:"mf.removeExtraneousParentheses = ...",scriptDepth:"mf.scriptDepth = ...",smartFence:"mf.smartFence = ...",smartMode:"mf.smartMode = ...",smartSuperscript:"mf.smartSuperscript = ...",inlineShortcutTimeout:"mf.inlineShortcutTimeout = ...",inlineShortcuts:"mf.inlineShortcuts = ...",keybindings:"mf.keybindings = ...",virtualKeyboardMode:"mf.mathVirtualKeyboardPolicy = ...",customVirtualKeyboardLayers:"mathVirtualKeyboard.layers = ...",customVirtualKeyboards:"mathVirtualKeyboard.layouts = ...",keypressSound:"mathVirtualKeyboard.keypressSound = ...",keypressVibration:"mathVirtualKeyboard.keypressVibration = ...",plonkSound:"mathVirtualKeyboard.plonkSound = ...",virtualKeyboardContainer:"mathVirtualKeyboard.container = ...",virtualKeyboardLayout:"mathVirtualKeyboard.alphabeticLayout = ...",virtualKeyboardTheme:"No longer supported",virtualKeyboardToggleGlyph:"No longer supported",virtualKeyboardToolbar:"mathVirtualKeyboard.editToolbar = ...",virtualKeyboards:"Use `mathVirtualKeyboard.layouts`",speechEngine:"`MathfieldElement.speechEngine`",speechEngineRate:"`MathfieldElement.speechEngineRate`",speechEngineVoice:"`MathfieldElement.speechEngineVoice`",textToSpeechMarkup:"`MathfieldElement.textToSpeechMarkup`",textToSpeechRules:"`MathfieldElement.textToSpeechRules`",textToSpeechRulesOptions:"`MathfieldElement.textToSpeechRulesOptions`",readAloudHook:"`MathfieldElement.readAloudHook`",speakHook:"`MathfieldElement.speakHook`",computeEngine:"`MathfieldElement.computeEngine`",fontsDirectory:"`MathfieldElement.fontsDirectory`",soundsDirectory:"`MathfieldElement.soundsDirectory`",createHTML:"`MathfieldElement.createHTML`",onExport:"`mf.onExport`",onInlineShortcut:"`mf.onInlineShortcut`",onScrollIntoView:"`mf.onScrollIntoView`",locale:"MathfieldElement.locale = ...",strings:"MathfieldElement.strings = ...",decimalSeparator:"MathfieldElement.decimalSeparator = ...",fractionNavigationOrder:"MathfieldElement.fractionNavigationOrder = ..."},uE=class e extends HTMLElement{constructor(e){if(super(),this._observer=null,e){let i=[];for(let r of Object.keys(e))if(uC[r])if(uC[r].startsWith("mf."))if(uC[r].startsWith(`mf.${r}`))i.push(`Option \`${r}\` cannot be used as a constructor option. Use ${uC[r]}`);else{let e=uC[r].match(/([a-zA-Z]+) =/);i.push(`Option \`${r}\` has been renamed \`${e[1]}\``)}else i.push(`Option \`${r}\` cannot be used as a constructor option. Use ${uC[r]}`);if(i.length>0){for(let e of(console.group("%cMathLive 0.110.10: %cInvalid Options","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem"),console.warn("Some of the options passed to `new MathfieldElement(...)` are invalid. \n See mathfield/changelog/ for details."),i))console.warn(e);console.groupEnd()}}if(uD()&&(this._internals=this.attachInternals(),this._internals.role="math",this._internals.ariaLabel="math input field",this._internals.ariaMultiLine="false"),this.attachShadow({mode:"open",delegatesFocus:!0}),this.shadowRoot&&"adoptedStyleSheets"in this.shadowRoot){this.shadowRoot.adoptedStyleSheets=[nA("core"),nA("mathfield"),nA("mathfield-element"),nA("ui"),nA("menu")],this.shadowRoot.appendChild(document.createElement("span"));let e=document.createElement("slot");e.style.display="none",this.shadowRoot.appendChild(e)}else this.shadowRoot.innerHTML="<style>"+nE("core")+nE("mathfield")+nE("mathfield-element")+nE("ui")+nE("menu")+'</style><span></span><slot style="display:none"></slot>';e&&this._setOptions(e)}static get formAssociated(){return uD()}static get optionsAttributes(){return{"default-mode":"string","letter-shape-style":"string","min-font-scale":"number","max-matrix-cols":"number","popover-policy":"string","math-mode-space":"string","read-only":"boolean","remove-extraneous-parentheses":"on/off","smart-fence":"on/off","smart-mode":"on/off","smart-superscript":"on/off","inline-shortcut-timeout":"string","script-depth":"string",placeholder:"string","virtual-keyboard-target-origin":"string","math-virtual-keyboard-policy":"string"}}static get observedAttributes(){return[...Object.keys(this.optionsAttributes),"contenteditable","disabled","readonly","read-only"]}static get fontsDirectory(){return this._fontsDirectory}static set fontsDirectory(e){e!==this._fontsDirectory&&(this._fontsDirectory=e,sK())}get fontsDirectory(){throw Error("Use MathfieldElement.fontsDirectory instead")}set fontsDirectory(e){throw Error("Use MathfieldElement.fontsDirectory instead")}static get stylesheetScope(){return nL}static set stylesheetScope(e){e!==nL&&(nL=e,ng={})}get stylesheetScope(){throw Error("Use MathfieldElement.stylesheetScope instead")}set stylesheetScope(e){throw Error("Use MathfieldElement.stylesheetScope instead")}static get soundsDirectory(){return this._soundsDirectory}static set soundsDirectory(e){this._soundsDirectory=e,this.audioBuffers={}}get soundsDirectory(){throw Error("Use MathfieldElement.soundsDirectory instead")}set soundsDirectory(e){throw Error("Use MathfieldElement.soundsDirectory instead")}static get keypressSound(){return this._keypressSound}static set keypressSound(e){var i,r,a;this.audioBuffers={},null===e?this._keypressSound={spacebar:null,return:null,delete:null,default:null}:"string"==typeof e?this._keypressSound={spacebar:e,return:e,delete:e,default:e}:"object"==typeof e&&"default"in e&&(this._keypressSound={spacebar:null!=(i=e.spacebar)?i:e.default,return:null!=(r=e.return)?r:e.default,delete:null!=(a=e.delete)?a:e.default,default:e.default})}static get plonkSound(){return this._plonkSound}static set plonkSound(e){this.audioBuffers={},this._plonkSound=e}static get audioContext(){return this._audioContext||(this._audioContext=new AudioContext),this._audioContext}static get speechEngine(){return this._speechEngine}static set speechEngine(e){this._speechEngine=e}static get speechEngineRate(){return this._speechEngineRate}static set speechEngineRate(e){this._speechEngineRate=e}static get speechEngineVoice(){return this._speechEngineVoice}static set speechEngineVoice(e){this._speechEngineVoice=e}static get textToSpeechMarkup(){return this._textToSpeechMarkup}static set textToSpeechMarkup(e){this._textToSpeechMarkup=e}static get textToSpeechRules(){return this._textToSpeechRules}static set textToSpeechRules(e){this._textToSpeechRules=e}static get textToSpeechRulesOptions(){return this._textToSpeechRulesOptions}static set textToSpeechRulesOptions(e){this._textToSpeechRulesOptions=e}static get locale(){return I.locale}static set locale(e){"auto"===e&&(e=navigator.language.slice(0,5)),I.locale=e}get locale(){throw Error("Use MathfieldElement.locale instead")}set locale(e){throw Error("Use MathfieldElement.locale instead")}static get strings(){return I.strings}static set strings(e){I.merge(e)}get strings(){throw Error("Use MathfieldElement.strings instead")}set strings(e){throw Error("Use MathfieldElement.strings instead")}static get decimalSeparator(){return this._decimalSeparator}static set decimalSeparator(e){this._decimalSeparator=e,this._computeEngine&&console.warn("MathLive 0.110.10: setting MathfieldElement.decimalSeparator after the Compute Engine has been created has no effect on the engine. Reassign MathfieldElement.computeEngine with a freshly configured instance to apply the new separator.")}get decimalSeparator(){throw Error("Use MathfieldElement.decimalSeparator instead")}set decimalSeparator(e){throw Error("Use MathfieldElement.decimalSeparator instead")}static set scientificNotationTemplate(e){this._scientificNotationTemplate=e}static get scientificNotationTemplate(){return this._scientificNotationTemplate}static get fractionNavigationOrder(){return o$.fractionNavigationOrder}static set fractionNavigationOrder(e){if("numerator-denominator"!==e&&"denominator-numerator"!==e)throw Error("Invalid value");o$.fractionNavigationOrder!==e&&(o$.fractionNavigationOrder=e,sN())}static get compactSerialization(){return o$.compactSerialization}static set compactSerialization(e){o$.compactSerialization=!!e}static get computeEngine(){var e,i;if(void 0===this._computeEngine){let i=window[Symbol.for("io.cortexjs.compute-engine")],r=null==i?void 0:i.ComputeEngine;if(!r)return null;if(this._computeEngine=new r,this._computeEngine&&","===this.decimalSeparator){let[r,a]=String(null!=(e=null==i?void 0:i.version)?e:"").split(".").map(e=>parseInt(e,10));(r>0||0===r&&a>=58)&&(this._computeEngine.latexOptions=g(f({},this._computeEngine.latexOptions),{decimalSeparator:"{,}"}))}}return null!=(i=this._computeEngine)?i:null}static set computeEngine(e){this._computeEngine=e}get computeEngine(){throw Error("Use MathfieldElement.computeEngine instead")}set computeEngine(e){throw Error("Use MathfieldElement.computeEngine instead")}static get isFunction(){return"function"!=typeof this._isFunction?()=>!1:this._isFunction}static set isFunction(e){this._isFunction=e,sN()}static async loadSound(e){delete this.audioBuffers[e];let i="";switch(e){case"keypress":i=this._keypressSound.default;break;case"return":i=this._keypressSound.return;break;case"spacebar":i=this._keypressSound.spacebar;break;case"delete":i=this._keypressSound.delete;break;case"plonk":i=this.plonkSound}if("string"!=typeof i)return;i=i.trim();let r=this.soundsDirectory;if(null!=r&&"null"!==r&&"none"!==i&&"null"!==i)try{let a=await (await fetch(await sT(`${r}/${i}`))).arrayBuffer(),o=await this.audioContext.decodeAudioData(a);this.audioBuffers[e]=o}catch(e){}}static async playSound(e){if(("suspended"===this.audioContext.state||"interrupted"===this.audioContext.state)&&await this.audioContext.resume(),this.audioBuffers[e]||await this.loadSound(e),!this.audioBuffers[e])return;let i=this.audioContext.createBufferSource();i.buffer=this.audioBuffers[e];let r=this.audioContext.createGain();r.gain.value=.5,i.connect(r).connect(this.audioContext.destination),i.start()}showMenu(e){var i,r;return null!=(r=null==(i=this._mathfield)?void 0:i.showMenu(e))&&r}get mathVirtualKeyboard(){throw Error("The `mathVirtualKeyboard` property is not available on the MathfieldElement. Use `window.mathVirtualKeyboard` instead.")}onPointerDown(){window.addEventListener("pointerup",i=>{let r=this._mathfield;if(r&&i.target===this&&!r.disabled){this.dispatchEvent(new MouseEvent("click",{altKey:i.altKey,button:i.button,buttons:i.buttons,clientX:i.clientX,clientY:i.clientY,ctrlKey:i.ctrlKey,metaKey:i.metaKey,movementX:i.movementX,movementY:i.movementY,relatedTarget:i.relatedTarget,screenX:i.screenX,screenY:i.screenY,shiftKey:i.shiftKey}));let a=this.getOffsetFromPoint(i.clientX,i.clientY);a>=0&&e.openUrl(function(e,i){let r=e.model.at(i);for(;r;){if("\\href"===r.command){let e=r.args[0];if("string"==typeof e)return e}r=r.parent}return""}(r,a)),"touch"===i.pointerType&&this.selectionIsCollapsed&&(this.position=a)}},{once:!0})}getPromptValue(e,i){var r,a;return null!=(a=null==(r=this._mathfield)?void 0:r.getPromptValue(e,i))?a:""}setPromptValue(e,i,r){var a;null==(a=this._mathfield)||a.setPromptValue(e,i,r)}getPromptRange(e){var i,r;return null!=(r=null==(i=this._mathfield)?void 0:i.getPromptRange(e))?r:null}getPrompts(e){var i,r;return null!=(r=null==(i=this._mathfield)?void 0:i.getPrompts(e))?r:[]}get hasEditableContent(){var e,i;return null!=(i=null==(e=this._mathfield)?void 0:e.hasEditableContent)&&i}get form(){var e;return null==(e=this._internals)?void 0:e.form}get name(){var e;return null!=(e=this.getAttribute("name"))?e:""}get type(){return this.localName}get mode(){var e,i;return null!=(i=null==(e=this._mathfield)?void 0:e.model.mode)?i:"text"===this.defaultMode?"text":"math"}set mode(e){var i;null==(i=this._mathfield)||i.switchMode(e)}get expression(){if(this._mathfield)return window[Symbol.for("io.cortexjs.compute-engine")]?this._mathfield.expression:(console.error(`MathLive 0.110.10: The CortexJS Compute Engine library is not available.
|
|
3492
3492
|
|
|
3493
3493
|
Load the library, for example with:
|
|
3494
3494
|
|
|
3495
|
-
import "https://esm.run/@cortex-js/compute-engine"`),null)}set expression(i){var r,a;if(!this._mathfield)return;let o=null!=(a=null==(r=e.computeEngine)?void 0:r.box(i).latex)?a:null;null!==o&&this._mathfield.setValue(o),window[Symbol.for("io.cortexjs.compute-engine")]||console.error(`MathLive 0.110.
|
|
3495
|
+
import "https://esm.run/@cortex-js/compute-engine"`),null)}set expression(i){var r,a;if(!this._mathfield)return;let o=null!=(a=null==(r=e.computeEngine)?void 0:r.box(i).latex)?a:null;null!==o&&this._mathfield.setValue(o),window[Symbol.for("io.cortexjs.compute-engine")]||console.error(`MathLive 0.110.10: The Compute Engine library is not available.
|
|
3496
3496
|
|
|
3497
3497
|
Load the library, for example with:
|
|
3498
3498
|
|
|
3499
|
-
import "https://esm.run/@cortex-js/compute-engine"`)}get errors(){var e,i;return null!=(i=null==(e=this._mathfield)?void 0:e.errors)?i:[]}_getOptions(e){return this._mathfield?cn(this._mathfield.options,e):uS.has(this)?f({},cn(f(f({},cl()),co(uS.get(this).options)),e)):null}getOptions(e){return console.warn("%cMathLive 0.110.9: %cDeprecated Usage%c\n `mf.getOptions()` is deprecated. Read the property directly on the mathfield instead.\n See mathfield/changelog/ for details.","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem","color: inherit, font-size: 1rem"),this._mathfield?cn(this._mathfield.options,e):uS.has(this)?cn(f(f({},cl()),co(uS.get(this).options)),e):null}reflectAttributes(){let i=cl(),r=this._getOptions();Object.keys(e.optionsAttributes).forEach(a=>{let o="placeholder"===a?"contentPlaceholder":uA(a);"on/off"===e.optionsAttributes[a]?i[o]!==r[o]?this.setAttribute(a,r[o]?"on":"off"):this.removeAttribute(a):i[o]!==r[o]&&("boolean"===e.optionsAttributes[a]?r[o]?this.setAttribute(a,""):this.removeAttribute(a):("string"==typeof r[o]||"number"==typeof r[o])&&this.setAttribute(a,r[o].toString()))})}getOption(e){return console.warn("%cMathLive 0.110.9: %cDeprecated Usage%c\n `mf.getOption()` is deprecated. Read the property directly on the mathfield instead.\n See mathfield/changelog/ for details.","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem","color: inherit, font-size: 1rem"),this._getOptions([e])[e]}_getOption(e){return this._getOptions([e])[e]}_setOptions(e){if(this._mathfield)this._mathfield.setOptions(e);else if(uS.has(this)){let i=f(f({},uS.get(this).options),e);uS.set(this,g(f({},uS.get(this)),{selection:{ranges:i.readOnly?[[0,0]]:[[0,-1]]},options:i}))}else uS.set(this,{value:void 0,selection:{ranges:[[0,0]]},options:e,menuItems:void 0});this.reflectAttributes()}setOptions(e){for(let i of(console.group("%cMathLive 0.110.9: %cDeprecated Usage","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem"),console.warn(" `mf.setOptions()` is deprecated. Set the property directly on the mathfield instead.\n See mathfield/changelog/ for details."),Object.keys(e)))uL[i]&&console.warn(`\`mf.setOptions({${i}:...})\` -> ${uL[i]}`);console.groupEnd(),this._setOptions(e)}executeCommand(...e){var i,r;let a;if(a=1===e.length?e[0]:[e[0],...e.slice(1)])return null!=(r=null==(i=this._mathfield)?void 0:i.executeCommand(a))&&r;throw Error("Invalid selector")}getValue(e,i,r){var a,o;if(this._mathfield)return this._mathfield.model.getValue(e,i,r);if(uS.has(this)){let n,l,s;if(o4(e)?([n,l]=e.ranges[0],s=i):o1(e)?([n,l]=e,s=i):o0(e)&&o0(i)?(n=e,l=i,s=r):(n=0,l=-1,s=e),(void 0===s||"latex"===s)&&0===n&&-1===l)return null!=(o=null!=(a=uS.get(this).value)?a:this.textContent)?o:""}return""}setValue(e,i){if(this._mathfield&&void 0!==e){if(this._mathfield.model.getValue()===e)return;null!=i||(i={silenceNotifications:!0,mode:"math"}),this._mathfield.setValue(e,i);return}if(uS.has(this)){let i=uS.get(this).options;uS.set(this,{value:e,selection:{ranges:[[-1,-1]],direction:"forward"},options:i,menuItems:void 0});return}let r=uz(this);uS.set(this,{value:e,selection:{ranges:[[-1,-1]],direction:"forward"},options:r,menuItems:void 0})}hasFocus(){var e,i;return null!=(i=null==(e=this._mathfield)?void 0:e.hasFocus())&&i}focus(){var e;this.disabled||null==(e=this._mathfield)||e.focus()}blur(){var e;null==(e=this._mathfield)||e.blur()}select(){var e;null==(e=this._mathfield)||e.select()}insert(e,i){var r,a;return null!=(a=null==(r=this._mathfield)?void 0:r.insert(e,i))&&a}applyStyle(e,i){var r;return null==(r=this._mathfield)?void 0:r.applyStyle(e,i)}queryStyle(e){var i,r;return null!=(r=null==(i=this._mathfield)?void 0:i.queryStyle(e))?r:"none"}getOffsetFromPoint(e,i,r){return this._mathfield?cZ(this._mathfield,e,i,r):-1}getElementInfo(e){return nf(this._mathfield,e)}resetUndo(){var e;null==(e=this._mathfield)||e.resetUndo()}canUndo(){return!!this._mathfield&&this._mathfield.canUndo()}canRedo(){return!!this._mathfield&&this._mathfield.canRedo()}handleEvent(e){var i,r,a,o,n;if("closed"!==se.state||(null==(r=null==(i=this._mathfield)?void 0:i.menu)?void 0:r.state)!=="closed"||("pointerdown"===e.type&&this.onPointerDown(),"focus"===e.type)||"blur"!==e.type)return;let l=x();l&&null!=(a=null==window?void 0:window.mathVirtualKeyboard)&&a.visible||(null==(o=se.scrim)?void 0:o.state)!=="closed"||l&&function(){try{return window.self!==window.top}catch(e){return!0}}()||null==(n=this._mathfield)||n.onBlur({dispatchEvents:!1})}connectedCallback(){var i,r,a,o;let n=this.shadowRoot,l=n.host,s="none"!==window.getComputedStyle(this).userSelect;s?l.addEventListener("pointerdown",this,!0):n.querySelector("span").style.pointerEvents="none",l.addEventListener("focus",this,!0),l.addEventListener("blur",this,!0),this._observer=new MutationObserver(()=>{var e;this.value=null!=(e=this.textContent)?e:""}),this._observer.observe(this,{childList:!0,characterData:!0,subtree:!0}),uT()||(this.hasAttribute("role")||this.setAttribute("role","math"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","math input field"),this.setAttribute("aria-multiline","false")),s&&!this.hasAttribute("contenteditable")&&this.setAttribute("contenteditable","true"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0");let c=n.querySelector("slot:not([name])");if(c)try{this._style=c.assignedElements().filter(e=>"style"===e.tagName.toLowerCase()).map(e=>e.textContent).join("")}catch(e){console.error(e)}if(this._style){let e=document.createElement("style");e.textContent=this._style,n.appendChild(e)}let d="";if(d=this.hasAttribute("value")?this.getAttribute("value"):null!=(i=null==c?void 0:c.assignedNodes().map(e=>3===e.nodeType?e.textContent:"").join("").trim())?i:"",this._mathfield=new uM(n.querySelector(":host > span"),g(f({},null!=(a=null==(r=uS.get(this))?void 0:r.options)?a:uz(this)),{eventSink:this,value:d})),!uS.has(this))for(let i of(this.upgradeProperty("disabled"),this.upgradeProperty("readonly"),Object.keys(e.optionsAttributes)))this.upgradeProperty(uA(i));if(!(null!=(o=this._mathfield)&&o.model)){this._mathfield=null;return}if(uS.has(this)){let e=this._mathfield,i=uS.get(this),r=i.menuItems;e.model.deferNotifications({content:!1,selection:!1},()=>{let r=i.value;void 0!==r&&e.setValue(r),e.model.selection=i.selection,uS.delete(this)}),r&&(this.menuItems=r)}window.queueMicrotask(()=>{this.isConnected&&this.dispatchEvent(new Event("mount",{cancelable:!1,bubbles:!0,composed:!0}))}),sK()}disconnectedCallback(){var i,r,a;if(this.shadowRoot.host.removeEventListener("pointerdown",this,!0),!this._mathfield)return;null==(i=this._observer)||i.disconnect(),this._observer=null,window.queueMicrotask(()=>this.dispatchEvent(new Event("unmount",{cancelable:!1,bubbles:!0,composed:!0})));let o=cn(this._mathfield.options,Object.keys(e.optionsAttributes).map(e=>uA(e)));uS.set(this,{value:this._mathfield.getValue(),selection:this._mathfield.model.selection,menuItems:null!=(a=null==(r=this._mathfield.menu)?void 0:r.menuItems)?a:void 0,options:o}),this._mathfield.dispose(),this._mathfield=null}upgradeProperty(e){if(this.hasOwnProperty(e)){let i=this[e];delete this[e],("readonly"===e||"read-only"===e)&&(e="readOnly"),this[e]=i}}attributeChangedCallback(e,i,r){if(i===r)return;let a=null!==r;switch(e){case"contenteditable":sB(this._mathfield);break;case"placeholder":!1===r&&(r=""),this.placeholder=r;break;case"disabled":this.disabled=a;break;case"read-only":case"readonly":this.readOnly=a}}get readonly(){return this.hasAttribute("readonly")||this.hasAttribute("read-only")}set readonly(e){let i=!!e;i?(this.setAttribute("readonly",""),uT()?this._internals.ariaReadOnly="true":this.setAttribute("aria-readonly","true"),this.setAttribute("aria-readonly","true")):(uT()?this._internals.ariaReadOnly="false":this.removeAttribute("aria-readonly"),this.removeAttribute("readonly"),this.removeAttribute("read-only")),this._setOptions({readOnly:i})}get disabled(){return this.hasAttribute("disabled")}set disabled(e){var i;let r=!!e;r?this.setAttribute("disabled",""):this.removeAttribute("disabled"),uT()?this._internals.ariaDisabled=r?"true":"false":this.setAttribute("aria-disabled",r?"true":"false"),r&&null!=(i=this._mathfield)&&i.hasFocus&&window.mathVirtualKeyboard.visible&&this._mathfield.executeCommand("hideVirtualKeyboard")}get value(){return this.getValue()}set value(e){this.setValue(e)}get defaultMode(){return this._getOption("defaultMode")}set defaultMode(e){this._setOptions({defaultMode:e})}get macros(){if(!this._mathfield)throw Error("Mathfield not mounted");return this._getOption("macros")}set macros(e){this._setOptions({macros:e})}get registers(){if(!this._mathfield)throw Error("Mathfield not mounted");let e=this;return new Proxy({},{get:(i,r)=>{if("string"==typeof r)return e._getOption("registers")[r]},set:(i,r,a)=>"string"==typeof r&&(e._setOptions({registers:g(f({},e._getOption("registers")),{[r]:a})}),!0),ownKeys:()=>Reflect.ownKeys(e._getOption("registers")),getOwnPropertyDescriptor:(i,r)=>{let a=e._getOption("registers")[r];if(void 0!==a)return{configurable:!0,enumerable:!0,value:a,writable:!0}}})}set registers(e){this._setOptions({registers:e})}get colorMap(){return this._getOption("colorMap")}set colorMap(e){this._setOptions({colorMap:e})}get backgroundColorMap(){return this._getOption("backgroundColorMap")}set backgroundColorMap(e){this._setOptions({backgroundColorMap:e})}get letterShapeStyle(){return this._getOption("letterShapeStyle")}set letterShapeStyle(e){this._setOptions({letterShapeStyle:e})}get minFontScale(){return this._getOption("minFontScale")}set minFontScale(e){this._setOptions({minFontScale:e})}get maxMatrixCols(){return this._getOption("maxMatrixCols")}set maxMatrixCols(e){this._setOptions({maxMatrixCols:e})}get smartMode(){return this._getOption("smartMode")}set smartMode(e){this._setOptions({smartMode:e})}get smartFence(){return this._getOption("smartFence")}set smartFence(e){this._setOptions({smartFence:e})}get smartSuperscript(){return this._getOption("smartSuperscript")}set smartSuperscript(e){this._setOptions({smartSuperscript:e})}get scriptDepth(){return this._getOption("scriptDepth")}set scriptDepth(e){this._setOptions({scriptDepth:e})}get removeExtraneousParentheses(){return this._getOption("removeExtraneousParentheses")}set removeExtraneousParentheses(e){this._setOptions({removeExtraneousParentheses:e})}get mathModeSpace(){return this._getOption("mathModeSpace")}set mathModeSpace(e){this._setOptions({mathModeSpace:e})}get placeholderSymbol(){return this._getOption("placeholderSymbol")}set placeholderSymbol(e){this._setOptions({placeholderSymbol:e})}get placeholder(){return this._getOption("contentPlaceholder")}set placeholder(e){this._setOptions({contentPlaceholder:e})}get popoverPolicy(){return this._getOption("popoverPolicy")}set popoverPolicy(e){this._setOptions({popoverPolicy:e})}get environmentPopoverPolicy(){return this._getOption("environmentPopoverPolicy")}set environmentPopoverPolicy(e){this._setOptions({environmentPopoverPolicy:e})}get menuItems(){var e;if(!this._mathfield)throw Error("Mathfield not mounted");return null!=(e=this._mathfield.menu._menuItems.map(e=>e.menuItem))?e:[]}set menuItems(e){var i;if(!this._mathfield)throw Error("Mathfield not mounted");if(this._mathfield){let r=null==(i=this._mathfield.element)?void 0:i.querySelector("[part=menu-toggle]");r&&(r.style.display=0===e.length?"none":""),this._mathfield.menu.menuItems=e}}get mathVirtualKeyboardPolicy(){return this._getOption("mathVirtualKeyboardPolicy")}set mathVirtualKeyboardPolicy(e){this._setOptions({mathVirtualKeyboardPolicy:e})}get inlineShortcuts(){if(!this._mathfield)throw Error("Mathfield not mounted");return this._getOption("inlineShortcuts")}set inlineShortcuts(e){if(!this._mathfield)throw Error("Mathfield not mounted");this._setOptions({inlineShortcuts:e})}get inlineShortcutTimeout(){return this._getOption("inlineShortcutTimeout")}set inlineShortcutTimeout(e){this._setOptions({inlineShortcutTimeout:e})}get keybindings(){if(!this._mathfield)throw Error("Mathfield not mounted");return this._getOption("keybindings")}set keybindings(e){if(!this._mathfield)throw Error("Mathfield not mounted");this._setOptions({keybindings:e})}get onInsertStyle(){let e=this._getOption("onInsertStyle");return void 0===e?sc:e}set onInsertStyle(e){this._setOptions({onInsertStyle:e})}get onInlineShortcut(){return this._getOption("onInlineShortcut")}set onInlineShortcut(e){this._setOptions({onInlineShortcut:e})}get onScrollIntoView(){return this._getOption("onScrollIntoView")}set onScrollIntoView(e){this._setOptions({onScrollIntoView:e})}get onExport(){return this._getOption("onExport")}set onExport(e){this._setOptions({onExport:e})}get readOnly(){return this._getOption("readOnly")}set readOnly(e){this._setOptions({readOnly:e})}get isSelectionEditable(){var e,i;return null!=(i=null==(e=this._mathfield)?void 0:e.isSelectionEditable)&&i}setPromptState(e,i,r){var a;null==(a=this._mathfield)||a.setPromptState(e,i,r)}getPromptState(e){var i,r;return null!=(r=null==(i=this._mathfield)?void 0:i.getPromptState(e))?r:[void 0,!0]}get selection(){return this._mathfield?this._mathfield.model.selection:uS.has(this)?uS.get(this).selection:{ranges:[[0,0]],direction:"forward"}}set selection(e){if("number"==typeof e&&(e={ranges:[[e,e]]}),this._mathfield){this._mathfield.model.selection=e,sB(this._mathfield);return}uS.has(this)?uS.set(this,g(f({},uS.get(this)),{selection:e})):uS.set(this,{value:void 0,selection:e,options:uz(this),menuItems:void 0})}get selectionIsCollapsed(){let e=this.selection;return 1===e.ranges.length&&e.ranges[0][0]===e.ranges[0][1]}get position(){return this._mathfield?this._mathfield.model.position:uS.has(this)?uS.get(this).selection.ranges[0][0]:0}set position(e){(this._mathfield&&(this._mathfield.model.position=e,sB(this._mathfield)),uS.has(this))?uS.set(this,g(f({},uS.get(this)),{selection:{ranges:[[e,e]]}})):uS.set(this,{value:void 0,selection:{ranges:[[e,e]]},options:uz(this),menuItems:void 0})}get lastOffset(){var e,i;return null!=(i=null==(e=this._mathfield)?void 0:e.model.lastOffset)?i:-1}};uC.version="0.110.9",uC.openUrl=e=>{if(!e)return;let i=new URL(e);["http:","https:","file:"].includes(i.protocol.toLowerCase())?window.open(i,"_blank"):uC.playSound("plonk")},uC._fontsDirectory="./fonts/",uC._soundsDirectory="./sounds",uC.keypressVibration=!0,uC._keypressSound={spacebar:"keypress-spacebar.wav",return:"keypress-return.wav",delete:"keypress-delete.wav",default:"keypress-standard.wav"},uC._plonkSound="plonk.wav",uC.audioBuffers={},uC.createHTML=e=>e,uC._speechEngineRate="100%",uC._speechEngineVoice="Joanna",uC._textToSpeechMarkup="",uC._textToSpeechRules="mathlive",uC._textToSpeechRulesOptions={},uC.speakHook=function(e){var i,r;if(!v())return;let a=globalThis.MathfieldElement;if(a.speechEngine&&"local"!==a.speechEngine)if("amazon"===a.speechEngine)if("AWS"in window){let o=new globalThis.AWS.Polly({apiVersion:"2016-06-10"}),n={OutputFormat:"mp3",VoiceId:null!=(i=a.speechEngineVoice)?i:"Joanna",Engine:["Amy","Emma","Brian","Ivy","Joanna","Kendra","Kimberly","Salli","Joey","Justin","Matthew"].includes(null!=(r=a.speechEngineVoice)?r:"Joanna")?"neural":"standard",Text:e,TextType:"ssml"};o.synthesizeSpeech(n,(e,i)=>{if(e)console.trace(`MathLive 0.110.9: \`polly.synthesizeSpeech()\` error: ${e}`);else if(null!=i&&i.AudioStream){let e=new Blob([new Uint8Array(i.AudioStream).buffer],{type:"audio/mpeg"});new Audio(URL.createObjectURL(e)).play().catch(e=>console.error(e))}})}else console.error("MathLive 0.110.9: AWS SDK not loaded. See https://www.npmjs.com/package/aws-sdk");else"google"===a.speechEngine&&console.error("MathLive 0.110.9: The Google speech engine is not supported yet. Please come again.");else{let i=new SpeechSynthesisUtterance(e);globalThis.speechSynthesis.speak(i)}},uC.readAloudHook=function(e,i){var r;if(!v())return;if("amazon"!==globalThis.MathfieldElement.speechEngine){console.error("MathLive 0.110.9: Use Amazon TTS Engine for synchronized highlighting"),"function"==typeof globalThis.MathfieldElement.speakHook&&globalThis.MathfieldElement.speakHook(i);return}if(!globalThis.AWS)return void console.error("MathLive 0.110.9: AWS SDK not loaded. See https://www.npmjs.com/package/aws-sdk");let a=new globalThis.AWS.Polly({apiVersion:"2016-06-10"}),o={OutputFormat:"json",VoiceId:null!=(r=globalThis.MathfieldElement.speechEngineVoice)?r:"Joanna",Engine:"standard",Text:i,TextType:"ssml",SpeechMarkTypes:["ssml"]};uX().readAloudElement=e,a.synthesizeSpeech(o,(e,r)=>{if(e)return void console.trace(`MathLive 0.110.9: \`polly.synthesizeSpeech()\` error: ${e}`);if(!(null!=r&&r.AudioStream))return;let n=new TextDecoder("utf-8").decode(new Uint8Array(r.AudioStream));for(let e of(uX().readAloudMarks=n.split(`
|
|
3500
|
-
`).map(e=>e?JSON.parse(e):{}),uX().readAloudTokens=[],uX().readAloudMarks))e.value&&uX().readAloudTokens.push(e.value);uX().readAloudCurrentMark="",o.OutputFormat="mp3",o.SpeechMarkTypes=[],a.synthesizeSpeech(o,(e,r)=>{if(e)return void console.trace(`MathLive 0.110.9: \`polly.synthesizeSpeech("${i}") error:${e}`);if(!(null!=r&&r.AudioStream))return;let a=new Blob([new Uint8Array(r.AudioStream).buffer],{type:"audio/mpeg"}),o=URL.createObjectURL(a),n=uX();n.readAloudAudio?n.readAloudAudio.pause():(n.readAloudAudio=new Audio,n.readAloudAudio.addEventListener("ended",()=>{let e=n.readAloudMathfield;n.readAloudStatus="ended",document.body.dispatchEvent(new Event("read-aloud-status-change",{bubbles:!0,composed:!0})),e?(sP(e),n.readAloudElement=null,n.readAloudMathfield=null,n.readAloudTokens=[],n.readAloudMarks=[],n.readAloudCurrentMark=""):function e(i){if(i&&(i.classList.remove("ML__highlight"),i.children))for(let r of i.children)e(r)}(n.readAloudElement)}),n.readAloudAudio.addEventListener("timeupdate",()=>{let e="",i=1e3*n.readAloudAudio.currentTime+100;for(let r of n.readAloudMarks)r.time<i&&(e=r.value);n.readAloudCurrentMark!==e&&(n.readAloudCurrentToken=e,e&&e===n.readAloudFinalToken?n.readAloudAudio.pause():(n.readAloudCurrentMark=e,function e(i,r){var a;i&&(r&&(null==(a=i.dataset)?void 0:a.atomId)!==r?(i.classList.remove("ML__highlight"),i.children&&i.children.length>0&&[...i.children].forEach(i=>{i instanceof HTMLElement&&e(i,r)})):(i.classList.add("ML__highlight"),i.children&&i.children.length>0&&[...i.children].forEach(i=>{i instanceof HTMLElement&&e(i)})))}(n.readAloudElement,n.readAloudCurrentMark)))})),n.readAloudAudio.src=o,n.readAloudStatus="playing",document.body.dispatchEvent(new Event("read-aloud-status-change",{bubbles:!0,composed:!0})),n.readAloudAudio.play()})})},uC.restoreFocusWhenDocumentFocused=!0,uC._decimalSeparator=".",uC._scientificNotationTemplate="#1\\times10^{#2}",uC._isFunction=e=>{var i,r;let a=globalThis.MathfieldElement.computeEngine;return null!=(r=null==(i=null==a?void 0:a.parse(e).domain)?void 0:i.isFunction)&&r};var uE=uC;function uA(e){return e.replace(/[^a-zA-Z\d]+(.)/g,(e,i)=>i.toUpperCase())}function uz(e){let i={readOnly:!1},r=uE.optionsAttributes;return Object.keys(r).forEach(a=>{var o;if(e.hasAttribute(a)){let n=e.getAttribute(a);"placeholder"===a?i.contentPlaceholder=null!=n?n:"":"boolean"===r[a]?i[uA(a)]=!0:"on/off"===r[a]?"on"===(n=null!=(o=null==n?void 0:n.toLowerCase())?o:"")||"true"===n?i[uA(a)]=!0:"off"===n||"false"===n?i[uA(a)]=!1:i[uA(a)]=void 0:"number"===r[a]?i[uA(a)]=Number.parseFloat(null!=n?n:"0"):i[uA(a)]=n}}),i}function uT(){return!(!("ElementInternals"in window)||!HTMLElement.prototype.attachInternals||!("role"in window.ElementInternals.prototype))}var uD,uK,uB,u$,uP,uO=uE;v()&&!(null!=(uB=window.customElements)&&uB.get("math-field"))&&(null!=window[u$=Symbol.for("io.cortexjs.mathlive")]||(window[u$]={}),window[Symbol.for("io.cortexjs.mathlive")].version="0.110.9",globalThis.MathfieldElement=uE,null==(uP=window.customElements)||uP.define("math-field",uE));var uR=!1,uI=null,uN=class extends HTMLElement{constructor(){if(super(),this._hasRendered=!1,this._shadowRoot=this.attachShadow({mode:"open"}),"adoptedStyleSheets"in this._shadowRoot)this._shadowRoot.adoptedStyleSheets=[nE("core")];else{let e=document.createElement("style");e.textContent=nC("core"),this._shadowRoot.appendChild(e)}this._contentSlot=document.createElement("div"),this._contentSlot.style.display="none",this._contentSlot.setAttribute("part","content"),this._renderContainer=document.createElement("div"),this._renderContainer.setAttribute("part","render"),this._renderContainer.setAttribute("aria-hidden","true"),this._errorFallback=document.createElement("div"),this._errorFallback.style.display="none",this._errorFallback.setAttribute("part","error"),this._shadowRoot.appendChild(this._contentSlot),this._shadowRoot.appendChild(this._renderContainer),this._shadowRoot.appendChild(this._errorFallback),this.addEventListener("keydown",this._handleKeydown.bind(this))}static get observedAttributes(){return["mode","format","macros","letter-shape-style","min-font-scale","max-matrix-cols"]}connectedCallback(){uR||uI||(uI=sK().then(()=>{uR=!0})),"IntersectionObserver"in window&&!this._hasRendered?(this._observer=new IntersectionObserver(e=>{var i;e[0].isIntersecting&&!this._hasRendered&&(this.render(),null==(i=this._observer)||i.disconnect())},{rootMargin:"50px"}),this._observer.observe(this)):this.render()}disconnectedCallback(){var e;null==(e=this._observer)||e.disconnect()}attributeChangedCallback(e,i,r){i!==r&&this._hasRendered&&this.render()}_handleKeydown(e){if(null!==this.getAttribute("tabindex")&&(" "===e.key||"Enter"===e.key)){e.preventDefault();let i=this.getAttribute("aria-label");if(i&&"speechSynthesis"in window){let e=new SpeechSynthesisUtterance(i);speechSynthesis.speak(e)}}}get mode(){let e=this.getAttribute("mode");return"textstyle"===e||"displaystyle"===e?e:this.getDefaultMathstyle()}set mode(e){this.setAttribute("mode",e)}get format(){let e=this.getAttribute("format");return"latex"===e||"ascii-math"===e||"math-json"===e?e:"latex"}set format(e){this.setAttribute("format",e)}get letterShapeStyle(){let e=this.getAttribute("letter-shape-style");if("auto"===e||"tex"===e||"iso"===e||"french"===e||"upright"===e)return e}set letterShapeStyle(e){void 0===e?this.removeAttribute("letter-shape-style"):this.setAttribute("letter-shape-style",e)}get macros(){var e;return null!=(e=this.getAttribute("macros"))?e:void 0}set macros(e){void 0===e?this.removeAttribute("macros"):this.setAttribute("macros",e)}get minFontScale(){let e=this.getAttribute("min-font-scale");return e?parseFloat(e):void 0}set minFontScale(e){void 0===e?this.removeAttribute("min-font-scale"):this.setAttribute("min-font-scale",String(e))}get maxMatrixCols(){let e=this.getAttribute("max-matrix-cols");return e?parseInt(e,10):void 0}set maxMatrixCols(e){void 0===e?this.removeAttribute("max-matrix-cols"):this.setAttribute("max-matrix-cols",String(e))}render(){var e,i,r;try{let r=null!=(i=null==(e=this.textContent)?void 0:e.trim())?i:"";if(!r){this._renderContainer.innerHTML="",this._errorFallback.style.display="none",this._renderContainer.style.display="none",this._removeMathML();return}this._contentSlot.textContent=r;let a,o=this.format;if("ascii-math"===o)a=dZ(r);else if("math-json"===o){let e=JSON.parse(r);a=dX(e)}else a=r;let n={defaultMode:"displaystyle"===this.mode?"math":"inline-math"};if(this.letterShapeStyle&&(n.letterShapeStyle=this.letterShapeStyle),this.macros)try{n.macros=JSON.parse(this.macros)}catch(e){console.warn("Invalid macros JSON:",e)}void 0!==this.minFontScale&&(n.minFontScale=this.minFontScale),void 0!==this.maxMatrixCols&&(n.maxMatrixCols=this.maxMatrixCols);let l=dH(a,n);this._renderContainer.innerHTML=l,this._renderContainer.style.display=this.getDefaultDisplay(),this._errorFallback.style.display="none",this._updateAccessibility(a),this._hasRendered=!0,this.dispatchEvent(new CustomEvent("render",{bubbles:!0,composed:!0,detail:{format:o,content:a}}))}catch(e){console.error("MathLive static element render error:",e),this._renderContainer.style.display="none",this._errorFallback.textContent=null!=(r=this.textContent)?r:"",this._errorFallback.style.display="block",this._removeMathML(),this.dispatchEvent(new CustomEvent("render-error",{bubbles:!0,composed:!0,detail:{error:e,content:this.textContent}}))}}_updateAccessibility(e){if(!this.hasAttribute("aria-label"))try{let i=dJ(e);this.setAttribute("aria-label",i)}catch(e){console.warn("Could not generate speakable text:",e)}this.hasAttribute("role")||this.setAttribute("role","img"),this._addMathML(e)}_addMathML(e){try{let i=dU(e);this._mathMLContainer||(this._mathMLContainer=document.createElement("div"),this._mathMLContainer.style.position="absolute",this._mathMLContainer.style.width="1px",this._mathMLContainer.style.height="1px",this._mathMLContainer.style.overflow="hidden",this._mathMLContainer.style.clip="rect(0, 0, 0, 0)",this._mathMLContainer.setAttribute("aria-hidden","false"),this._shadowRoot.appendChild(this._mathMLContainer)),this._mathMLContainer.innerHTML=i}catch(e){console.warn("Could not generate MathML:",e)}}_removeMathML(){this._mathMLContainer&&(this._mathMLContainer.remove(),this._mathMLContainer=void 0)}},uq=class extends uN{getDefaultMathstyle(){return"textstyle"}getDefaultDisplay(){return"inline-flex"}},uF=class extends uN{getDefaultMathstyle(){return"displaystyle"}getDefaultDisplay(){return"flex"}};function uV(e,i,r,a,o="latex"){let n=[];for(let l of e)if("text"===l.type){let e=l.data,s=!0,c=0,d;-1!==(d=e.indexOf(i))&&((c=d)>0&&n.push({type:"text",data:e.slice(0,c)}),s=!1);let u=!1;for(;!u;){if(s){if(-1===(d=e.indexOf(i,c))){u=!0;break}c!==d&&n.push({type:"text",data:e.slice(c,d)}),c=d}else{if(-1===(d=function(e,i,r){let a=r,o=0,n=e.length;for(;a<i.length;){let r=i[a];if(o<=0&&i.slice(a,a+n)===e)return a;"\\"===r?a++:"{"===r?o++:"}"===r&&o--,a++}return -1}(r,e,c+i.length))){u=!0;break}let l=e.slice(c+i.length,d);"ascii-math"===o&&([,l]=o6(l,{format:"ascii-math"})),n.push({type:"math",data:l,mathstyle:a}),c=d+r.length}s=!s}c<e.length&&n.push({type:"text",data:e.slice(c)})}else n.push(l);return n}function uj(e,i){var r,a,o,n,l,s,c,d;let u=[{type:"text",data:e}];return null!=(a=null==(r=i.TeX)?void 0:r.delimiters)&&a.display&&i.TeX.delimiters.display.forEach(([e,i])=>{u=uV(u,e,i,"displaystyle")}),null!=(n=null==(o=i.TeX)?void 0:o.delimiters)&&n.inline&&i.TeX.delimiters.inline.forEach(([e,i])=>{u=uV(u,e,i,"textstyle")}),null!=(s=null==(l=i.asciiMath)?void 0:l.delimiters)&&s.inline&&i.asciiMath.delimiters.inline.forEach(([e,i])=>{u=uV(u,e,i,"textstyle","ascii-math")}),null!=(d=null==(c=i.asciiMath)?void 0:c.delimiters)&&d.display&&i.asciiMath.delimiters.display.forEach(([e,i])=>{u=uV(u,e,i,"displaystyle","ascii-math")}),u}function uH(e,i,r){var a;let o=function(e,i,r){try{let a=i.renderToMarkup(e,g(f({},i),{defaultMode:"displaystyle"===r?"math":"inline-math"})),o=document.createElement("span");return o.dataset.latex=e,o.style.display="displaystyle"===r?"flex":"inline-flex",o.setAttribute("aria-hidden","true"),o.setAttribute("translate","no"),o.innerHTML=globalThis.MathfieldElement.createHTML(a),o}catch(i){return console.error("Could not parse'"+e+"' with ",i),document.createTextNode(e)}}(e,r,i||"textstyle"),n=null!=(a=r.renderAccessibleContent)?a:"";if(/\b(mathml|speakable-text)\b/i.test(n)){let i=document.createElement("span");if(/\bmathml\b/i.test(n)&&r.renderToMathML&&i.append(function(e,i){let r=document.createElement("span");r.setAttribute("translate","no");try{let a="<math xmlns='http://www.w3.org/1998/Math/MathML'>"+i.renderToMathML(e)+"</math>";r.innerHTML=globalThis.MathfieldElement.createHTML(a)}catch(i){console.error(`MathLive 0.110.9: Could not convert "${e}"' to MathML with ${i}`),r.textContent=e}return r.className="ML__sr-only",r}(e,r)),/\bspeakable-text\b/i.test(n)&&r.renderToSpeakableText){let a=document.createElement("span");a.setAttribute("translate","no");let o=r.renderToSpeakableText(e);a.innerHTML=globalThis.MathfieldElement.createHTML(o),a.className="ML__sr-only",i.append(a)}return i.append(o),i}return o}"u">typeof window&&(null!=(a=window.customElements)&&a.get("math-span")||null==(o=window.customElements)||o.define("math-span",uq),null!=(n=window.customElements)&&n.get("math-div")||null==(l=window.customElements)||l.define("math-div",uF));var uW={skipTags:["math-field","noscript","style","textarea","pre","code","annotation","annotation-xml"],processScriptType:"math/tex",processMathJSONScriptType:"math/json",ignoreClass:"^(tex2jax_ignore|ML__latex)$",processClass:"tex2jax_process",renderAccessibleContent:"mathml",asciiMath:{delimiters:{inline:[["`","`"]]}},TeX:{processEnvironments:!0,delimiters:{inline:[["\\(","\\)"]],display:[["$$","$$"],["\\[","\\]"]]}}};function uU(e,i){var r,a,o,n,l,s,c,d;try{let u=f(f({},uW),i);u.ignoreClassPattern=new RegExp(null!=(r=u.ignoreClass)?r:""),u.processClassPattern=new RegExp(null!=(a=u.processClass)?a:""),u.processScriptTypePattern=new RegExp(null!=(o=u.processScriptType)?o:""),u.processMathJSONScriptTypePattern=new RegExp(null!=(n=u.processMathJSONScriptType)?n:""),null!=(s=null==(l=u.TeX)?void 0:l.className)&&s.display&&(u.texClassDisplayPattern=new RegExp(u.TeX.className.display)),null!=(d=null==(c=u.TeX)?void 0:c.className)&&d.inline&&(u.texClassInlinePattern=new RegExp(u.TeX.className.inline)),sK(),nA("core"),function e(i,r){var a,o,n,l,s,c,d,u,h,p,m,f,g,b,y,v,x,_;if(1===i.childNodes.length&&3===i.childNodes[0].nodeType){let e=null!=(a=i.childNodes[0].textContent)?a:"";if(null!=(o=r.TeX)&&o.processEnvironments&&/^\s*\\begin/.test(e)){i.textContent="",i.append(uH(e,"",r));return}let n=uj(e,r);if(1===n.length){let e=n[0];if("text"===e.type)return;i.textContent="",i.append(uH(e.data,"textstyle"===e.mathstyle?"textstyle":"displaystyle",r));return}}for(let a of[...i.childNodes])if(3===a.nodeType){let e=function(e,i){var r;if(/^\s*$/.test(e))return null;if(null!=(r=i.TeX)&&r.processEnvironments&&/^\s*\\begin/.test(e))return[uH(e,"",i)];let a=uj(e,i);if(1===a.length&&"text"===a[0].type)return null;let o=[];for(let e of a)"text"===e.type?o.push(e.data):o.push(uH(e.data,"textstyle"===e.mathstyle?"textstyle":"displaystyle",i));return o}(null!=(n=a.textContent)?n:"",r);e&&a.replaceWith(...e)}else if(1===a.nodeType){let i=a.nodeName.toLowerCase();if("script"===i){let e,i=a.type.toLowerCase();if("module"===i||"javascript"===i)continue;if(null!=(l=r.processScriptTypePattern)&&l.test(i))e=null!=(s=a.textContent)?s:"";else if(null!=(c=r.processMathJSONScriptTypePattern)&&c.test(i))try{e=null==(u=r.serializeToLatex)?void 0:u.call(r,JSON.parse(null!=(d=a.textContent)?d:""))}catch(e){console.error(e)}if(e){let o="textstyle";for(let e of i.split(";")){let[i,r]=e.split("=");"mode"===i.trim()&&(o="display"===r.trim()?"displaystyle":"textstyle")}uJ(a,e,o,r)}}else{if(null!=(h=r.texClassDisplayPattern)&&h.test(a.className)){uJ(a,null!=(p=a.textContent)?p:"","displaystyle",r);continue}if(null!=(m=r.texClassInlinePattern)&&m.test(a.className)){uJ(a,null!=(f=a.textContent)?f:"","textstyle",r);continue}(null!=(b=null==(g=r.processClassPattern)?void 0:g.test(a.className))&&b||!(null!=(v=null==(y=r.skipTags)?void 0:y.includes(i))&&v||null!=(_=null==(x=r.ignoreClassPattern)?void 0:x.test(a.className))&&_))&&e(a,r)}}}(e,u)}catch(i){i instanceof Error?console.error("renderMathInElement(): "+i.message):console.error("renderMathInElement(): Could not render math for element",e)}}function uJ(e,i,r,a){e.parentNode.replaceChild(uH(i,r,a),e)}function uX(){var e;return null!=globalThis[e=Symbol.for("io.cortexjs.mathlive")]||(globalThis[e]={}),globalThis[Symbol.for("io.cortexjs.mathlive")]}function uG(e){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>uZ(document.body,e)):uZ(document.body,e)}function uZ(e,i){if("loading"===document.readyState)return void document.addEventListener("DOMContentLoaded",()=>uZ(e,i));let r=function(e){if("string"==typeof e){let i=document.getElementById(e);if(null===i)throw Error(`The element with ID "${e}" could not be found.`);return i}return e}(e);if(!r)return;let a=null!=i?i:{};null!=a.renderToMarkup||(a.renderToMarkup=dH),null!=a.renderToMathML||(a.renderToMathML=dU),null!=a.renderToSpeakableText||(a.renderToSpeakableText=dJ),null!=a.serializeToLatex||(a.serializeToLatex=dX),uU(r,a)}sN({switchKeyboardLayer:function(e,i){let r=ci.singleton;return!!r&&(r.show(),sY(),r.currentLayer=i,r.render(),r.focus(),!0)},toggleVirtualKeyboard:function(){let e=window.mathVirtualKeyboard;return e.visible?e.hide({animate:!0}):e.show({animate:!0}),!1},hideVirtualKeyboard:()=>(window.mathVirtualKeyboard.hide({animate:!0}),!1),showVirtualKeyboard:()=>(window.mathVirtualKeyboard.show({animate:!0}),!1)},{target:"virtual-keyboard"});var uY={mathlive:"0.110.9"};r.d(i,{MathDivElement:()=>uF,MathSpanElement:()=>uq,MathfieldElement:()=>uE,_renderMathInElement:()=>uU,convertAsciiMathToLatex:()=>dZ,convertLatexToAsciiMath:()=>dG,convertLatexToMarkup:()=>dH,convertLatexToMathMl:()=>dU,convertLatexToSpeakableText:()=>dJ,convertMathJsonToLatex:()=>dX,globalMathLive:()=>uX,initVirtualKeyboardInCurrentBrowsingContext:()=>ca,renderMathInDocument:()=>uG,renderMathInElement:()=>uZ,setKeyboardLayout:()=>P,setKeyboardLayoutLocale:()=>O,validateLatex:()=>dW,version:()=>uY})}};
|
|
3499
|
+
import "https://esm.run/@cortex-js/compute-engine"`)}get errors(){var e,i;return null!=(i=null==(e=this._mathfield)?void 0:e.errors)?i:[]}_getOptions(e){return this._mathfield?cl(this._mathfield.options,e):uL.has(this)?f({},cl(f(f({},cs()),cn(uL.get(this).options)),e)):null}getOptions(e){return console.warn("%cMathLive 0.110.10: %cDeprecated Usage%c\n `mf.getOptions()` is deprecated. Read the property directly on the mathfield instead.\n See mathfield/changelog/ for details.","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem","color: inherit, font-size: 1rem"),this._mathfield?cl(this._mathfield.options,e):uL.has(this)?cl(f(f({},cs()),cn(uL.get(this).options)),e):null}reflectAttributes(){let i=cs(),r=this._getOptions();Object.keys(e.optionsAttributes).forEach(a=>{let o="placeholder"===a?"contentPlaceholder":uz(a);"on/off"===e.optionsAttributes[a]?i[o]!==r[o]?this.setAttribute(a,r[o]?"on":"off"):this.removeAttribute(a):i[o]!==r[o]&&("boolean"===e.optionsAttributes[a]?r[o]?this.setAttribute(a,""):this.removeAttribute(a):("string"==typeof r[o]||"number"==typeof r[o])&&this.setAttribute(a,r[o].toString()))})}getOption(e){return console.warn("%cMathLive 0.110.10: %cDeprecated Usage%c\n `mf.getOption()` is deprecated. Read the property directly on the mathfield instead.\n See mathfield/changelog/ for details.","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem","color: inherit, font-size: 1rem"),this._getOptions([e])[e]}_getOption(e){return this._getOptions([e])[e]}_setOptions(e){if(this._mathfield)this._mathfield.setOptions(e);else if(uL.has(this)){let i=f(f({},uL.get(this).options),e);uL.set(this,g(f({},uL.get(this)),{selection:{ranges:i.readOnly?[[0,0]]:[[0,-1]]},options:i}))}else uL.set(this,{value:void 0,selection:{ranges:[[0,0]]},options:e,menuItems:void 0});this.reflectAttributes()}setOptions(e){for(let i of(console.group("%cMathLive 0.110.10: %cDeprecated Usage","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem"),console.warn(" `mf.setOptions()` is deprecated. Set the property directly on the mathfield instead.\n See mathfield/changelog/ for details."),Object.keys(e)))uC[i]&&console.warn(`\`mf.setOptions({${i}:...})\` -> ${uC[i]}`);console.groupEnd(),this._setOptions(e)}executeCommand(...e){var i,r;let a;if(a=1===e.length?e[0]:[e[0],...e.slice(1)])return null!=(r=null==(i=this._mathfield)?void 0:i.executeCommand(a))&&r;throw Error("Invalid selector")}getValue(e,i,r){var a,o;if(this._mathfield)return this._mathfield.model.getValue(e,i,r);if(uL.has(this)){let n,l,s;if(o4(e)?([n,l]=e.ranges[0],s=i):o1(e)?([n,l]=e,s=i):o0(e)&&o0(i)?(n=e,l=i,s=r):(n=0,l=-1,s=e),(void 0===s||"latex"===s)&&0===n&&-1===l)return null!=(o=null!=(a=uL.get(this).value)?a:this.textContent)?o:""}return""}setValue(e,i){if(this._mathfield&&void 0!==e){if(this._mathfield.model.getValue()===e)return;null!=i||(i={silenceNotifications:!0,mode:"math"}),this._mathfield.setValue(e,i);return}if(uL.has(this)){let i=uL.get(this).options;uL.set(this,{value:e,selection:{ranges:[[-1,-1]],direction:"forward"},options:i,menuItems:void 0});return}let r=uT(this);uL.set(this,{value:e,selection:{ranges:[[-1,-1]],direction:"forward"},options:r,menuItems:void 0})}hasFocus(){var e,i;return null!=(i=null==(e=this._mathfield)?void 0:e.hasFocus())&&i}focus(){var e;this.disabled||null==(e=this._mathfield)||e.focus()}blur(){var e;null==(e=this._mathfield)||e.blur()}select(){var e;null==(e=this._mathfield)||e.select()}insert(e,i){var r,a;return null!=(a=null==(r=this._mathfield)?void 0:r.insert(e,i))&&a}applyStyle(e,i){var r;return null==(r=this._mathfield)?void 0:r.applyStyle(e,i)}queryStyle(e){var i,r;return null!=(r=null==(i=this._mathfield)?void 0:i.queryStyle(e))?r:"none"}getOffsetFromPoint(e,i,r){return this._mathfield?cY(this._mathfield,e,i,r):-1}getElementInfo(e){return nf(this._mathfield,e)}resetUndo(){var e;null==(e=this._mathfield)||e.resetUndo()}canUndo(){return!!this._mathfield&&this._mathfield.canUndo()}canRedo(){return!!this._mathfield&&this._mathfield.canRedo()}handleEvent(e){var i,r,a,o,n;if("closed"!==st.state||(null==(r=null==(i=this._mathfield)?void 0:i.menu)?void 0:r.state)!=="closed"||("pointerdown"===e.type&&this.onPointerDown(),"focus"===e.type)||"blur"!==e.type)return;let l=x();l&&null!=(a=null==window?void 0:window.mathVirtualKeyboard)&&a.visible||(null==(o=st.scrim)?void 0:o.state)!=="closed"||l&&function(){try{return window.self!==window.top}catch(e){return!0}}()||null==(n=this._mathfield)||n.onBlur({dispatchEvents:!1})}connectedCallback(){var i,r,a,o;let n=this.shadowRoot,l=n.host,s="none"!==window.getComputedStyle(this).userSelect;s?l.addEventListener("pointerdown",this,!0):n.querySelector("span").style.pointerEvents="none",l.addEventListener("focus",this,!0),l.addEventListener("blur",this,!0),this._observer=new MutationObserver(()=>{var e;this.value=null!=(e=this.textContent)?e:""}),this._observer.observe(this,{childList:!0,characterData:!0,subtree:!0}),uD()||(this.hasAttribute("role")||this.setAttribute("role","math"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","math input field"),this.setAttribute("aria-multiline","false")),s&&!this.hasAttribute("contenteditable")&&this.setAttribute("contenteditable","true"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0");let c=n.querySelector("slot:not([name])");if(c)try{this._style=c.assignedElements().filter(e=>"style"===e.tagName.toLowerCase()).map(e=>e.textContent).join("")}catch(e){console.error(e)}if(this._style){let e=document.createElement("style");e.textContent=this._style,n.appendChild(e)}let d="";if(d=this.hasAttribute("value")?this.getAttribute("value"):null!=(i=null==c?void 0:c.assignedNodes().map(e=>3===e.nodeType?e.textContent:"").join("").trim())?i:"",this._mathfield=new uS(n.querySelector(":host > span"),g(f({},null!=(a=null==(r=uL.get(this))?void 0:r.options)?a:uT(this)),{eventSink:this,value:d})),!uL.has(this))for(let i of(this.upgradeProperty("disabled"),this.upgradeProperty("readonly"),Object.keys(e.optionsAttributes)))this.upgradeProperty(uz(i));if(!(null!=(o=this._mathfield)&&o.model)){this._mathfield=null;return}if(uL.has(this)){let e=this._mathfield,i=uL.get(this),r=i.menuItems;e.model.deferNotifications({content:!1,selection:!1},()=>{let r=i.value;void 0!==r&&e.setValue(r),e.model.selection=i.selection,uL.delete(this)}),r&&(this.menuItems=r)}window.queueMicrotask(()=>{this.isConnected&&this.dispatchEvent(new Event("mount",{cancelable:!1,bubbles:!0,composed:!0}))}),sB()}disconnectedCallback(){var i,r,a;if(this.shadowRoot.host.removeEventListener("pointerdown",this,!0),!this._mathfield)return;null==(i=this._observer)||i.disconnect(),this._observer=null,window.queueMicrotask(()=>this.dispatchEvent(new Event("unmount",{cancelable:!1,bubbles:!0,composed:!0})));let o=cl(this._mathfield.options,Object.keys(e.optionsAttributes).map(e=>uz(e)));uL.set(this,{value:this._mathfield.getValue(),selection:this._mathfield.model.selection,menuItems:null!=(a=null==(r=this._mathfield.menu)?void 0:r.menuItems)?a:void 0,options:o}),this._mathfield.dispose(),this._mathfield=null}upgradeProperty(e){if(this.hasOwnProperty(e)){let i=this[e];delete this[e],("readonly"===e||"read-only"===e)&&(e="readOnly"),this[e]=i}}attributeChangedCallback(e,i,r){if(i===r)return;let a=null!==r;switch(e){case"contenteditable":s$(this._mathfield);break;case"placeholder":!1===r&&(r=""),this.placeholder=r;break;case"disabled":this.disabled=a;break;case"read-only":case"readonly":this.readOnly=a}}get readonly(){return this.hasAttribute("readonly")||this.hasAttribute("read-only")}set readonly(e){let i=!!e;i?(this.setAttribute("readonly",""),uD()?this._internals.ariaReadOnly="true":this.setAttribute("aria-readonly","true"),this.setAttribute("aria-readonly","true")):(uD()?this._internals.ariaReadOnly="false":this.removeAttribute("aria-readonly"),this.removeAttribute("readonly"),this.removeAttribute("read-only")),this._setOptions({readOnly:i})}get disabled(){return this.hasAttribute("disabled")}set disabled(e){var i;let r=!!e;r?this.setAttribute("disabled",""):this.removeAttribute("disabled"),uD()?this._internals.ariaDisabled=r?"true":"false":this.setAttribute("aria-disabled",r?"true":"false"),r&&null!=(i=this._mathfield)&&i.hasFocus&&window.mathVirtualKeyboard.visible&&this._mathfield.executeCommand("hideVirtualKeyboard")}get value(){return this.getValue()}set value(e){this.setValue(e)}get defaultMode(){return this._getOption("defaultMode")}set defaultMode(e){this._setOptions({defaultMode:e})}get macros(){if(!this._mathfield)throw Error("Mathfield not mounted");return this._getOption("macros")}set macros(e){this._setOptions({macros:e})}get registers(){if(!this._mathfield)throw Error("Mathfield not mounted");let e=this;return new Proxy({},{get:(i,r)=>{if("string"==typeof r)return e._getOption("registers")[r]},set:(i,r,a)=>"string"==typeof r&&(e._setOptions({registers:g(f({},e._getOption("registers")),{[r]:a})}),!0),ownKeys:()=>Reflect.ownKeys(e._getOption("registers")),getOwnPropertyDescriptor:(i,r)=>{let a=e._getOption("registers")[r];if(void 0!==a)return{configurable:!0,enumerable:!0,value:a,writable:!0}}})}set registers(e){this._setOptions({registers:e})}get colorMap(){return this._getOption("colorMap")}set colorMap(e){this._setOptions({colorMap:e})}get backgroundColorMap(){return this._getOption("backgroundColorMap")}set backgroundColorMap(e){this._setOptions({backgroundColorMap:e})}get letterShapeStyle(){return this._getOption("letterShapeStyle")}set letterShapeStyle(e){this._setOptions({letterShapeStyle:e})}get minFontScale(){return this._getOption("minFontScale")}set minFontScale(e){this._setOptions({minFontScale:e})}get maxMatrixCols(){return this._getOption("maxMatrixCols")}set maxMatrixCols(e){this._setOptions({maxMatrixCols:e})}get smartMode(){return this._getOption("smartMode")}set smartMode(e){this._setOptions({smartMode:e})}get smartFence(){return this._getOption("smartFence")}set smartFence(e){this._setOptions({smartFence:e})}get smartSuperscript(){return this._getOption("smartSuperscript")}set smartSuperscript(e){this._setOptions({smartSuperscript:e})}get scriptDepth(){return this._getOption("scriptDepth")}set scriptDepth(e){this._setOptions({scriptDepth:e})}get removeExtraneousParentheses(){return this._getOption("removeExtraneousParentheses")}set removeExtraneousParentheses(e){this._setOptions({removeExtraneousParentheses:e})}get mathModeSpace(){return this._getOption("mathModeSpace")}set mathModeSpace(e){this._setOptions({mathModeSpace:e})}get placeholderSymbol(){return this._getOption("placeholderSymbol")}set placeholderSymbol(e){this._setOptions({placeholderSymbol:e})}get placeholder(){return this._getOption("contentPlaceholder")}set placeholder(e){this._setOptions({contentPlaceholder:e})}get popoverPolicy(){return this._getOption("popoverPolicy")}set popoverPolicy(e){this._setOptions({popoverPolicy:e})}get environmentPopoverPolicy(){return this._getOption("environmentPopoverPolicy")}set environmentPopoverPolicy(e){this._setOptions({environmentPopoverPolicy:e})}get menuItems(){var e;if(!this._mathfield)throw Error("Mathfield not mounted");return null!=(e=this._mathfield.menu._menuItems.map(e=>e.menuItem))?e:[]}set menuItems(e){var i;if(!this._mathfield)throw Error("Mathfield not mounted");if(this._mathfield){let r=null==(i=this._mathfield.element)?void 0:i.querySelector("[part=menu-toggle]");r&&(r.style.display=0===e.length?"none":""),this._mathfield.menu.menuItems=e}}get mathVirtualKeyboardPolicy(){return this._getOption("mathVirtualKeyboardPolicy")}set mathVirtualKeyboardPolicy(e){this._setOptions({mathVirtualKeyboardPolicy:e})}get inlineShortcuts(){if(!this._mathfield)throw Error("Mathfield not mounted");return this._getOption("inlineShortcuts")}set inlineShortcuts(e){if(!this._mathfield)throw Error("Mathfield not mounted");this._setOptions({inlineShortcuts:e})}get inlineShortcutTimeout(){return this._getOption("inlineShortcutTimeout")}set inlineShortcutTimeout(e){this._setOptions({inlineShortcutTimeout:e})}get keybindings(){if(!this._mathfield)throw Error("Mathfield not mounted");return this._getOption("keybindings")}set keybindings(e){if(!this._mathfield)throw Error("Mathfield not mounted");this._setOptions({keybindings:e})}get onInsertStyle(){let e=this._getOption("onInsertStyle");return void 0===e?sd:e}set onInsertStyle(e){this._setOptions({onInsertStyle:e})}get onInlineShortcut(){return this._getOption("onInlineShortcut")}set onInlineShortcut(e){this._setOptions({onInlineShortcut:e})}get onScrollIntoView(){return this._getOption("onScrollIntoView")}set onScrollIntoView(e){this._setOptions({onScrollIntoView:e})}get onExport(){return this._getOption("onExport")}set onExport(e){this._setOptions({onExport:e})}get readOnly(){return this._getOption("readOnly")}set readOnly(e){this._setOptions({readOnly:e})}get isSelectionEditable(){var e,i;return null!=(i=null==(e=this._mathfield)?void 0:e.isSelectionEditable)&&i}setPromptState(e,i,r){var a;null==(a=this._mathfield)||a.setPromptState(e,i,r)}getPromptState(e){var i,r;return null!=(r=null==(i=this._mathfield)?void 0:i.getPromptState(e))?r:[void 0,!0]}get selection(){return this._mathfield?this._mathfield.model.selection:uL.has(this)?uL.get(this).selection:{ranges:[[0,0]],direction:"forward"}}set selection(e){if("number"==typeof e&&(e={ranges:[[e,e]]}),this._mathfield){this._mathfield.model.selection=e,s$(this._mathfield);return}uL.has(this)?uL.set(this,g(f({},uL.get(this)),{selection:e})):uL.set(this,{value:void 0,selection:e,options:uT(this),menuItems:void 0})}get selectionIsCollapsed(){let e=this.selection;return 1===e.ranges.length&&e.ranges[0][0]===e.ranges[0][1]}get position(){return this._mathfield?this._mathfield.model.position:uL.has(this)?uL.get(this).selection.ranges[0][0]:0}set position(e){(this._mathfield&&(this._mathfield.model.position=e,s$(this._mathfield)),uL.has(this))?uL.set(this,g(f({},uL.get(this)),{selection:{ranges:[[e,e]]}})):uL.set(this,{value:void 0,selection:{ranges:[[e,e]]},options:uT(this),menuItems:void 0})}get lastOffset(){var e,i;return null!=(i=null==(e=this._mathfield)?void 0:e.model.lastOffset)?i:-1}};uE.version="0.110.10",uE.openUrl=e=>{if(!e)return;let i=new URL(e);["http:","https:","file:"].includes(i.protocol.toLowerCase())?window.open(i,"_blank"):uE.playSound("plonk")},uE._fontsDirectory="./fonts/",uE._soundsDirectory="./sounds",uE.keypressVibration=!0,uE._keypressSound={spacebar:"keypress-spacebar.wav",return:"keypress-return.wav",delete:"keypress-delete.wav",default:"keypress-standard.wav"},uE._plonkSound="plonk.wav",uE.audioBuffers={},uE.createHTML=e=>e,uE._speechEngineRate="100%",uE._speechEngineVoice="Joanna",uE._textToSpeechMarkup="",uE._textToSpeechRules="mathlive",uE._textToSpeechRulesOptions={},uE.speakHook=function(e){var i,r;if(!v())return;let a=globalThis.MathfieldElement;if(a.speechEngine&&"local"!==a.speechEngine)if("amazon"===a.speechEngine)if("AWS"in window){let o=new globalThis.AWS.Polly({apiVersion:"2016-06-10"}),n={OutputFormat:"mp3",VoiceId:null!=(i=a.speechEngineVoice)?i:"Joanna",Engine:["Amy","Emma","Brian","Ivy","Joanna","Kendra","Kimberly","Salli","Joey","Justin","Matthew"].includes(null!=(r=a.speechEngineVoice)?r:"Joanna")?"neural":"standard",Text:e,TextType:"ssml"};o.synthesizeSpeech(n,(e,i)=>{if(e)console.trace(`MathLive 0.110.10: \`polly.synthesizeSpeech()\` error: ${e}`);else if(null!=i&&i.AudioStream){let e=new Blob([new Uint8Array(i.AudioStream).buffer],{type:"audio/mpeg"});new Audio(URL.createObjectURL(e)).play().catch(e=>console.error(e))}})}else console.error("MathLive 0.110.10: AWS SDK not loaded. See https://www.npmjs.com/package/aws-sdk");else"google"===a.speechEngine&&console.error("MathLive 0.110.10: The Google speech engine is not supported yet. Please come again.");else{let i=new SpeechSynthesisUtterance(e);globalThis.speechSynthesis.speak(i)}},uE.readAloudHook=function(e,i){var r;if(!v())return;if("amazon"!==globalThis.MathfieldElement.speechEngine){console.error("MathLive 0.110.10: Use Amazon TTS Engine for synchronized highlighting"),"function"==typeof globalThis.MathfieldElement.speakHook&&globalThis.MathfieldElement.speakHook(i);return}if(!globalThis.AWS)return void console.error("MathLive 0.110.10: AWS SDK not loaded. See https://www.npmjs.com/package/aws-sdk");let a=new globalThis.AWS.Polly({apiVersion:"2016-06-10"}),o={OutputFormat:"json",VoiceId:null!=(r=globalThis.MathfieldElement.speechEngineVoice)?r:"Joanna",Engine:"standard",Text:i,TextType:"ssml",SpeechMarkTypes:["ssml"]};uG().readAloudElement=e,a.synthesizeSpeech(o,(e,r)=>{if(e)return void console.trace(`MathLive 0.110.10: \`polly.synthesizeSpeech()\` error: ${e}`);if(!(null!=r&&r.AudioStream))return;let n=new TextDecoder("utf-8").decode(new Uint8Array(r.AudioStream));for(let e of(uG().readAloudMarks=n.split(`
|
|
3500
|
+
`).map(e=>e?JSON.parse(e):{}),uG().readAloudTokens=[],uG().readAloudMarks))e.value&&uG().readAloudTokens.push(e.value);uG().readAloudCurrentMark="",o.OutputFormat="mp3",o.SpeechMarkTypes=[],a.synthesizeSpeech(o,(e,r)=>{if(e)return void console.trace(`MathLive 0.110.10: \`polly.synthesizeSpeech("${i}") error:${e}`);if(!(null!=r&&r.AudioStream))return;let a=new Blob([new Uint8Array(r.AudioStream).buffer],{type:"audio/mpeg"}),o=URL.createObjectURL(a),n=uG();n.readAloudAudio?n.readAloudAudio.pause():(n.readAloudAudio=new Audio,n.readAloudAudio.addEventListener("ended",()=>{let e=n.readAloudMathfield;n.readAloudStatus="ended",document.body.dispatchEvent(new Event("read-aloud-status-change",{bubbles:!0,composed:!0})),e?(sO(e),n.readAloudElement=null,n.readAloudMathfield=null,n.readAloudTokens=[],n.readAloudMarks=[],n.readAloudCurrentMark=""):function e(i){if(i&&(i.classList.remove("ML__highlight"),i.children))for(let r of i.children)e(r)}(n.readAloudElement)}),n.readAloudAudio.addEventListener("timeupdate",()=>{let e="",i=1e3*n.readAloudAudio.currentTime+100;for(let r of n.readAloudMarks)r.time<i&&(e=r.value);n.readAloudCurrentMark!==e&&(n.readAloudCurrentToken=e,e&&e===n.readAloudFinalToken?n.readAloudAudio.pause():(n.readAloudCurrentMark=e,function e(i,r){var a;i&&(r&&(null==(a=i.dataset)?void 0:a.atomId)!==r?(i.classList.remove("ML__highlight"),i.children&&i.children.length>0&&[...i.children].forEach(i=>{i instanceof HTMLElement&&e(i,r)})):(i.classList.add("ML__highlight"),i.children&&i.children.length>0&&[...i.children].forEach(i=>{i instanceof HTMLElement&&e(i)})))}(n.readAloudElement,n.readAloudCurrentMark)))})),n.readAloudAudio.src=o,n.readAloudStatus="playing",document.body.dispatchEvent(new Event("read-aloud-status-change",{bubbles:!0,composed:!0})),n.readAloudAudio.play()})})},uE.restoreFocusWhenDocumentFocused=!0,uE._decimalSeparator=".",uE._scientificNotationTemplate="#1\\times10^{#2}",uE._isFunction=e=>{var i,r;let a=globalThis.MathfieldElement.computeEngine;return null!=(r=null==(i=null==a?void 0:a.parse(e).domain)?void 0:i.isFunction)&&r};var uA=uE;function uz(e){return e.replace(/[^a-zA-Z\d]+(.)/g,(e,i)=>i.toUpperCase())}function uT(e){let i={readOnly:!1},r=uA.optionsAttributes;return Object.keys(r).forEach(a=>{var o;if(e.hasAttribute(a)){let n=e.getAttribute(a);"placeholder"===a?i.contentPlaceholder=null!=n?n:"":"boolean"===r[a]?i[uz(a)]=!0:"on/off"===r[a]?"on"===(n=null!=(o=null==n?void 0:n.toLowerCase())?o:"")||"true"===n?i[uz(a)]=!0:"off"===n||"false"===n?i[uz(a)]=!1:i[uz(a)]=void 0:"number"===r[a]?i[uz(a)]=Number.parseFloat(null!=n?n:"0"):i[uz(a)]=n}}),i}function uD(){return!(!("ElementInternals"in window)||!HTMLElement.prototype.attachInternals||!("role"in window.ElementInternals.prototype))}var uK,uB,u$,uP,uO,uR=uA;v()&&!(null!=(u$=window.customElements)&&u$.get("math-field"))&&(null!=window[uP=Symbol.for("io.cortexjs.mathlive")]||(window[uP]={}),window[Symbol.for("io.cortexjs.mathlive")].version="0.110.10",globalThis.MathfieldElement=uA,null==(uO=window.customElements)||uO.define("math-field",uA));var uI=!1,uN=null,uq=class extends HTMLElement{constructor(){if(super(),this._hasRendered=!1,this._shadowRoot=this.attachShadow({mode:"open"}),"adoptedStyleSheets"in this._shadowRoot)this._shadowRoot.adoptedStyleSheets=[nA("core")];else{let e=document.createElement("style");e.textContent=nE("core"),this._shadowRoot.appendChild(e)}this._contentSlot=document.createElement("div"),this._contentSlot.style.display="none",this._contentSlot.setAttribute("part","content"),this._renderContainer=document.createElement("div"),this._renderContainer.setAttribute("part","render"),this._renderContainer.setAttribute("aria-hidden","true"),this._errorFallback=document.createElement("div"),this._errorFallback.style.display="none",this._errorFallback.setAttribute("part","error"),this._shadowRoot.appendChild(this._contentSlot),this._shadowRoot.appendChild(this._renderContainer),this._shadowRoot.appendChild(this._errorFallback),this.addEventListener("keydown",this._handleKeydown.bind(this))}static get observedAttributes(){return["mode","format","macros","letter-shape-style","min-font-scale","max-matrix-cols"]}connectedCallback(){uI||uN||(uN=sB().then(()=>{uI=!0})),"IntersectionObserver"in window&&!this._hasRendered?(this._observer=new IntersectionObserver(e=>{var i;e[0].isIntersecting&&!this._hasRendered&&(this.render(),null==(i=this._observer)||i.disconnect())},{rootMargin:"50px"}),this._observer.observe(this)):this.render()}disconnectedCallback(){var e;null==(e=this._observer)||e.disconnect()}attributeChangedCallback(e,i,r){i!==r&&this._hasRendered&&this.render()}_handleKeydown(e){if(null!==this.getAttribute("tabindex")&&(" "===e.key||"Enter"===e.key)){e.preventDefault();let i=this.getAttribute("aria-label");if(i&&"speechSynthesis"in window){let e=new SpeechSynthesisUtterance(i);speechSynthesis.speak(e)}}}get mode(){let e=this.getAttribute("mode");return"textstyle"===e||"displaystyle"===e?e:this.getDefaultMathstyle()}set mode(e){this.setAttribute("mode",e)}get format(){let e=this.getAttribute("format");return"latex"===e||"ascii-math"===e||"math-json"===e?e:"latex"}set format(e){this.setAttribute("format",e)}get letterShapeStyle(){let e=this.getAttribute("letter-shape-style");if("auto"===e||"tex"===e||"iso"===e||"french"===e||"upright"===e)return e}set letterShapeStyle(e){void 0===e?this.removeAttribute("letter-shape-style"):this.setAttribute("letter-shape-style",e)}get macros(){var e;return null!=(e=this.getAttribute("macros"))?e:void 0}set macros(e){void 0===e?this.removeAttribute("macros"):this.setAttribute("macros",e)}get minFontScale(){let e=this.getAttribute("min-font-scale");return e?parseFloat(e):void 0}set minFontScale(e){void 0===e?this.removeAttribute("min-font-scale"):this.setAttribute("min-font-scale",String(e))}get maxMatrixCols(){let e=this.getAttribute("max-matrix-cols");return e?parseInt(e,10):void 0}set maxMatrixCols(e){void 0===e?this.removeAttribute("max-matrix-cols"):this.setAttribute("max-matrix-cols",String(e))}render(){var e,i,r;try{let r=null!=(i=null==(e=this.textContent)?void 0:e.trim())?i:"";if(!r){this._renderContainer.innerHTML="",this._errorFallback.style.display="none",this._renderContainer.style.display="none",this._removeMathML();return}this._contentSlot.textContent=r;let a,o=this.format;if("ascii-math"===o)a=dY(r);else if("math-json"===o){let e=JSON.parse(r);a=dG(e)}else a=r;let n={defaultMode:"displaystyle"===this.mode?"math":"inline-math"};if(this.letterShapeStyle&&(n.letterShapeStyle=this.letterShapeStyle),this.macros)try{n.macros=JSON.parse(this.macros)}catch(e){console.warn("Invalid macros JSON:",e)}void 0!==this.minFontScale&&(n.minFontScale=this.minFontScale),void 0!==this.maxMatrixCols&&(n.maxMatrixCols=this.maxMatrixCols);let l=dW(a,n);this._renderContainer.innerHTML=l,this._renderContainer.style.display=this.getDefaultDisplay(),this._errorFallback.style.display="none",this._updateAccessibility(a),this._hasRendered=!0,this.dispatchEvent(new CustomEvent("render",{bubbles:!0,composed:!0,detail:{format:o,content:a}}))}catch(e){console.error("MathLive static element render error:",e),this._renderContainer.style.display="none",this._errorFallback.textContent=null!=(r=this.textContent)?r:"",this._errorFallback.style.display="block",this._removeMathML(),this.dispatchEvent(new CustomEvent("render-error",{bubbles:!0,composed:!0,detail:{error:e,content:this.textContent}}))}}_updateAccessibility(e){if(!this.hasAttribute("aria-label"))try{let i=dX(e);this.setAttribute("aria-label",i)}catch(e){console.warn("Could not generate speakable text:",e)}this.hasAttribute("role")||this.setAttribute("role","img"),this._addMathML(e)}_addMathML(e){try{let i=dJ(e);this._mathMLContainer||(this._mathMLContainer=document.createElement("div"),this._mathMLContainer.style.position="absolute",this._mathMLContainer.style.width="1px",this._mathMLContainer.style.height="1px",this._mathMLContainer.style.overflow="hidden",this._mathMLContainer.style.clip="rect(0, 0, 0, 0)",this._mathMLContainer.setAttribute("aria-hidden","false"),this._shadowRoot.appendChild(this._mathMLContainer)),this._mathMLContainer.innerHTML=i}catch(e){console.warn("Could not generate MathML:",e)}}_removeMathML(){this._mathMLContainer&&(this._mathMLContainer.remove(),this._mathMLContainer=void 0)}},uF=class extends uq{getDefaultMathstyle(){return"textstyle"}getDefaultDisplay(){return"inline-flex"}},uV=class extends uq{getDefaultMathstyle(){return"displaystyle"}getDefaultDisplay(){return"flex"}};function uj(e,i,r,a,o="latex"){let n=[];for(let l of e)if("text"===l.type){let e=l.data,s=!0,c=0,d;-1!==(d=e.indexOf(i))&&((c=d)>0&&n.push({type:"text",data:e.slice(0,c)}),s=!1);let u=!1;for(;!u;){if(s){if(-1===(d=e.indexOf(i,c))){u=!0;break}c!==d&&n.push({type:"text",data:e.slice(c,d)}),c=d}else{if(-1===(d=function(e,i,r){let a=r,o=0,n=e.length;for(;a<i.length;){let r=i[a];if(o<=0&&i.slice(a,a+n)===e)return a;"\\"===r?a++:"{"===r?o++:"}"===r&&o--,a++}return -1}(r,e,c+i.length))){u=!0;break}let l=e.slice(c+i.length,d);"ascii-math"===o&&([,l]=o6(l,{format:"ascii-math"})),n.push({type:"math",data:l,mathstyle:a}),c=d+r.length}s=!s}c<e.length&&n.push({type:"text",data:e.slice(c)})}else n.push(l);return n}function uH(e,i){var r,a,o,n,l,s,c,d;let u=[{type:"text",data:e}];return null!=(a=null==(r=i.TeX)?void 0:r.delimiters)&&a.display&&i.TeX.delimiters.display.forEach(([e,i])=>{u=uj(u,e,i,"displaystyle")}),null!=(n=null==(o=i.TeX)?void 0:o.delimiters)&&n.inline&&i.TeX.delimiters.inline.forEach(([e,i])=>{u=uj(u,e,i,"textstyle")}),null!=(s=null==(l=i.asciiMath)?void 0:l.delimiters)&&s.inline&&i.asciiMath.delimiters.inline.forEach(([e,i])=>{u=uj(u,e,i,"textstyle","ascii-math")}),null!=(d=null==(c=i.asciiMath)?void 0:c.delimiters)&&d.display&&i.asciiMath.delimiters.display.forEach(([e,i])=>{u=uj(u,e,i,"displaystyle","ascii-math")}),u}function uW(e,i,r){var a;let o=function(e,i,r){try{let a=i.renderToMarkup(e,g(f({},i),{defaultMode:"displaystyle"===r?"math":"inline-math"})),o=document.createElement("span");return o.dataset.latex=e,o.style.display="displaystyle"===r?"flex":"inline-flex",o.setAttribute("aria-hidden","true"),o.setAttribute("translate","no"),o.innerHTML=globalThis.MathfieldElement.createHTML(a),o}catch(i){return console.error("Could not parse'"+e+"' with ",i),document.createTextNode(e)}}(e,r,i||"textstyle"),n=null!=(a=r.renderAccessibleContent)?a:"";if(/\b(mathml|speakable-text)\b/i.test(n)){let i=document.createElement("span");if(/\bmathml\b/i.test(n)&&r.renderToMathML&&i.append(function(e,i){let r=document.createElement("span");r.setAttribute("translate","no");try{let a="<math xmlns='http://www.w3.org/1998/Math/MathML'>"+i.renderToMathML(e)+"</math>";r.innerHTML=globalThis.MathfieldElement.createHTML(a)}catch(i){console.error(`MathLive 0.110.10: Could not convert "${e}"' to MathML with ${i}`),r.textContent=e}return r.className="ML__sr-only",r}(e,r)),/\bspeakable-text\b/i.test(n)&&r.renderToSpeakableText){let a=document.createElement("span");a.setAttribute("translate","no");let o=r.renderToSpeakableText(e);a.innerHTML=globalThis.MathfieldElement.createHTML(o),a.className="ML__sr-only",i.append(a)}return i.append(o),i}return o}"u">typeof window&&(null!=(a=window.customElements)&&a.get("math-span")||null==(o=window.customElements)||o.define("math-span",uF),null!=(n=window.customElements)&&n.get("math-div")||null==(l=window.customElements)||l.define("math-div",uV));var uU={skipTags:["math-field","noscript","style","textarea","pre","code","annotation","annotation-xml"],processScriptType:"math/tex",processMathJSONScriptType:"math/json",ignoreClass:"^(tex2jax_ignore|ML__latex)$",processClass:"tex2jax_process",renderAccessibleContent:"mathml",asciiMath:{delimiters:{inline:[["`","`"]]}},TeX:{processEnvironments:!0,delimiters:{inline:[["\\(","\\)"]],display:[["$$","$$"],["\\[","\\]"]]}}};function uJ(e,i){var r,a,o,n,l,s,c,d;try{let u=f(f({},uU),i);u.ignoreClassPattern=new RegExp(null!=(r=u.ignoreClass)?r:""),u.processClassPattern=new RegExp(null!=(a=u.processClass)?a:""),u.processScriptTypePattern=new RegExp(null!=(o=u.processScriptType)?o:""),u.processMathJSONScriptTypePattern=new RegExp(null!=(n=u.processMathJSONScriptType)?n:""),null!=(s=null==(l=u.TeX)?void 0:l.className)&&s.display&&(u.texClassDisplayPattern=new RegExp(u.TeX.className.display)),null!=(d=null==(c=u.TeX)?void 0:c.className)&&d.inline&&(u.texClassInlinePattern=new RegExp(u.TeX.className.inline)),sB(),nz("core"),function e(i,r){var a,o,n,l,s,c,d,u,h,p,m,f,g,b,y,v,x,_;if(1===i.childNodes.length&&3===i.childNodes[0].nodeType){let e=null!=(a=i.childNodes[0].textContent)?a:"";if(null!=(o=r.TeX)&&o.processEnvironments&&/^\s*\\begin/.test(e)){i.textContent="",i.append(uW(e,"",r));return}let n=uH(e,r);if(1===n.length){let e=n[0];if("text"===e.type)return;i.textContent="",i.append(uW(e.data,"textstyle"===e.mathstyle?"textstyle":"displaystyle",r));return}}for(let a of[...i.childNodes])if(3===a.nodeType){let e=function(e,i){var r;if(/^\s*$/.test(e))return null;if(null!=(r=i.TeX)&&r.processEnvironments&&/^\s*\\begin/.test(e))return[uW(e,"",i)];let a=uH(e,i);if(1===a.length&&"text"===a[0].type)return null;let o=[];for(let e of a)"text"===e.type?o.push(e.data):o.push(uW(e.data,"textstyle"===e.mathstyle?"textstyle":"displaystyle",i));return o}(null!=(n=a.textContent)?n:"",r);e&&a.replaceWith(...e)}else if(1===a.nodeType){let i=a.nodeName.toLowerCase();if("script"===i){let e,i=a.type.toLowerCase();if("module"===i||"javascript"===i)continue;if(null!=(l=r.processScriptTypePattern)&&l.test(i))e=null!=(s=a.textContent)?s:"";else if(null!=(c=r.processMathJSONScriptTypePattern)&&c.test(i))try{e=null==(u=r.serializeToLatex)?void 0:u.call(r,JSON.parse(null!=(d=a.textContent)?d:""))}catch(e){console.error(e)}if(e){let o="textstyle";for(let e of i.split(";")){let[i,r]=e.split("=");"mode"===i.trim()&&(o="display"===r.trim()?"displaystyle":"textstyle")}uX(a,e,o,r)}}else{if(null!=(h=r.texClassDisplayPattern)&&h.test(a.className)){uX(a,null!=(p=a.textContent)?p:"","displaystyle",r);continue}if(null!=(m=r.texClassInlinePattern)&&m.test(a.className)){uX(a,null!=(f=a.textContent)?f:"","textstyle",r);continue}(null!=(b=null==(g=r.processClassPattern)?void 0:g.test(a.className))&&b||!(null!=(v=null==(y=r.skipTags)?void 0:y.includes(i))&&v||null!=(_=null==(x=r.ignoreClassPattern)?void 0:x.test(a.className))&&_))&&e(a,r)}}}(e,u)}catch(i){i instanceof Error?console.error("renderMathInElement(): "+i.message):console.error("renderMathInElement(): Could not render math for element",e)}}function uX(e,i,r,a){e.parentNode.replaceChild(uW(i,r,a),e)}function uG(){var e;return null!=globalThis[e=Symbol.for("io.cortexjs.mathlive")]||(globalThis[e]={}),globalThis[Symbol.for("io.cortexjs.mathlive")]}function uZ(e){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>uY(document.body,e)):uY(document.body,e)}function uY(e,i){if("loading"===document.readyState)return void document.addEventListener("DOMContentLoaded",()=>uY(e,i));let r=function(e){if("string"==typeof e){let i=document.getElementById(e);if(null===i)throw Error(`The element with ID "${e}" could not be found.`);return i}return e}(e);if(!r)return;let a=null!=i?i:{};null!=a.renderToMarkup||(a.renderToMarkup=dW),null!=a.renderToMathML||(a.renderToMathML=dJ),null!=a.renderToSpeakableText||(a.renderToSpeakableText=dX),null!=a.serializeToLatex||(a.serializeToLatex=dG),uJ(r,a)}sq({switchKeyboardLayer:function(e,i){let r=cr.singleton;return!!r&&(r.show(),sQ(),r.currentLayer=i,r.render(),r.focus(),!0)},toggleVirtualKeyboard:function(){let e=window.mathVirtualKeyboard;return e.visible?e.hide({animate:!0}):e.show({animate:!0}),!1},hideVirtualKeyboard:()=>(window.mathVirtualKeyboard.hide({animate:!0}),!1),showVirtualKeyboard:()=>(window.mathVirtualKeyboard.show({animate:!0}),!1)},{target:"virtual-keyboard"});var uQ={mathlive:"0.110.10"};r.d(i,{MathDivElement:()=>uV,MathSpanElement:()=>uF,MathfieldElement:()=>uA,_renderMathInElement:()=>uJ,convertAsciiMathToLatex:()=>dY,convertLatexToAsciiMath:()=>dZ,convertLatexToMarkup:()=>dW,convertLatexToMathMl:()=>dJ,convertLatexToSpeakableText:()=>dX,convertMathJsonToLatex:()=>dG,globalMathLive:()=>uG,initVirtualKeyboardInCurrentBrowsingContext:()=>co,renderMathInDocument:()=>uZ,renderMathInElement:()=>uY,setKeyboardLayout:()=>P,setKeyboardLayoutLocale:()=>O,validateLatex:()=>dU,version:()=>uQ})}};
|