"?null:typeof t=="object"&&"group"in t?{group:t.group.map(r=>wi(r))}:typeof t=="object"&&"atoms"in t?t.atoms.map(r=>wi(r)):t)}var ea={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"],ams:["AMS-Regular","ML__ams"],"ams-bold":["AMS-Regular","ML__ams"],"ams-italic":["AMS-Regular","ML__ams"],"ams-bolditalic":["AMS-Regular","ML__ams"],"sans-serif":["SansSerif-Regular","ML__sans"],"sans-serif-bold":["SansSerif-Regular","ML__sans ML__bold"],"sans-serif-italic":["SansSerif-Regular","ML__sans"],"sans-serif-bolditalic":["SansSerif-Regular","ML__sans"],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"],"fraktur-italic":["Fraktur-Regular","ML__frak"],"fraktur-bolditalic":["Fraktur-Regular","ML__frak"],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"],"double-struck-italic":["AMS-Regular","ML__bb"],"double-struck-bolditalic":["AMS-Regular","ML__bb"]},To={"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]$/},ks=/^[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5]$/,Jo=/^[\u0393|\u0394\u0398\u039B\u039E\u03A0\u03A3\u03A5\u03A6\u03A8\u03A9]$/,Il=[/^[a-z]$/,/^[A-Z]$/,ks,Jo],$l={iso:["it","it","it","it"],tex:["it","it","it","up"],french:["it","up","up","up"],upright:["up","up","up","up"]},Dd=class extends Ai{constructor(){super("math")}createAtom(e,t,r){var n,i,a,s;if(t===null)return new _e({type:"mord",mode:"math",command:e,value:e,style:r});const u=window.MathfieldElement.isFunction((n=t.command)!=null?n:e);if(t.definitionType==="symbol"){const h=new _e({type:(i=t.type)!=null?i:"mord",mode:"math",command:(a=t.command)!=null?a:e,value:String.fromCodePoint(t.codepoint),style:r});return u&&(h.isFunction=!0),e.startsWith("\\")&&(h.verbatimLatex=e),h}const d=new _e({type:"mord",mode:"math",command:(s=t.command)!=null?s:e,value:e,style:r});return u&&(d.isFunction=!0),e.startsWith("\\")&&(d.verbatimLatex=e),d}serialize(e,t){const r=J0(e,_(S({},t),{defaultMode:"math"}));return r.length===0||t.defaultMode!=="text"?r:["$ ",...r," $"]}getFont(e,t){console.assert(t.variant!==void 0);let{variant:r}=t,{variantStyle:n}=t;r==="normal"&&!n&&/[\u00A3\u0131\u0237]/.test(e.value)&&(r="main",n="italic"),r==="normal"&&!n&&e.value.length===1&&Il.forEach((u,d)=>{var h;u.test(e.value)&&$l[(h=t.letterShapeStyle)!=null?h:"tex"][d]==="it"&&(n="italic")}),n==="up"&&(n=void 0);const i=n?r+"-"+n:r;console.assert(ea[i]!==void 0);const[a,s]=ea[i];return To[r]&&!To[r].test(e.value)?(e.value=Fe(e.value,r,n),null):(ks.test(e.value)&&(e.classes+=" lcGreek"),s&&(e.classes+=" "+s),a)}};function J0(e,t){const{parent:r}=e[0],n=Ds(r);return Hi(e,"variant").map(i=>{const a=Ds(i[0]);let s="";a&&a!==n&&(s={calligraphic:"\\mathcal",fraktur:"\\mathfrak","double-struck":"\\mathbb",script:"\\mathscr",monospace:"\\mathtt","sans-serif":"\\mathsf",normal:"\\mathrm","normal-italic":"\\mathnormal","normal-bold":"\\mathbf","normal-bolditalic":"\\mathbfit",ams:"","ams-italic":"\\mathit","ams-bold":"\\mathbf","ams-bolditalic":"\\mathbfit",main:"","main-italic":"\\mathit","main-bold":"\\mathbf","main-bolditalic":"\\mathbfit"}[a],console.assert(s!==void 0));const u=Cr(i.map(d=>d._serialize(t)));return s?an(s,u):u})}function Ds(e){if(!e)return"";const{style:t}=e;if(t.variant===void 0)return"";let r=t.variant;return!["calligraphic","fraktur","double-struck","script","monospace","sans-serif"].includes(t.variant)&&t.variantStyle&&t.variantStyle!=="up"&&(r+="-"+t.variantStyle),r}new Dd;function Y0(e,t){return e.map(r=>r._serialize(t))}function Ad(e,t){return Hi(e,"fontShape").map(r=>{const n=Y0(r,t),{fontShape:i}=r[0].style;let a="";return i==="it"&&(a="\\textit"),i==="sl"&&(a="\\textsl"),i==="sc"&&(a="\\textsc"),i==="n"&&(a="\\textup"),!a&&i?`{${an("\\fontshape",i)}${Cr(n)}}`:a?an(a,Cr(n)):Cr(n)})}function Nc(e,t){return Hi(e,"fontSeries").map(r=>{const n=Ad(r,t),{fontSeries:i}=r[0].style;let a="";return i==="b"&&(a="\\textbf"),i==="l"&&(a="\\textlf"),i==="m"&&(a="\\textmd"),i&&!a?`{${an("\\fontseries",i)}${Cr(n)}}`:a?an(a,Cr(n)):Cr(n)})}function Tl(e,t){return Hi(e,"fontSize").map(r=>{var n,i;const a=Nc(r,t),s=(i=["","\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"][(n=r[0].style.fontSize)!=null?n:""])!=null?i:"";return s?`${s} ${Cr(a)}`:Cr(a)})}function Ld(e,t,r){return Hi(e,"fontFamily").map(n=>{var i,a;const s=Tl(n,t),u=(a={roman:"textrm",monospace:"texttt","sans-serif":"textsf"}[(i=n[0].style.fontFamily)!=null?i:""])!=null?a:"";return u?`\\${u}{${Cr(s)}}`:n[0].style.fontFamily?`{\\fontfamily{${n[0].style.fontFamily}} ${Cr(s)}}`:r?`\\text{${Cr(s)}}`:Cr(s)})}var Pl={roman:"","sans-serif":"ML__sans",monospace:"ML__tt"},Fc=class extends Ai{constructor(){super("text")}createAtom(e,t,r){return t&&t.definitionType==="symbol"?new Ms(e,String.fromCodePoint(t.codepoint),r!=null?r:{}):null}serialize(e,t){return Ld(e,_(S({},t),{defaultMode:"text"}),t.defaultMode!=="text")}getFont(e,t){var r,n,i,a,s;const{fontFamily:u}=t;if(Pl[u]?e.classes+=" "+Pl[u]:u&&e.setStyle("font-family",u),t.fontShape&&(e.classes+=" ",e.classes+=(r={it:"ML__it",sl:"ML__shape_sl",sc:"ML__shape_sc",ol:"ML__shape_ol"}[t.fontShape])!=null?r:""),t.fontSeries){const d=t.fontSeries.match(/(.?[lbm])?(.?[cx])?/);d&&(e.classes+=" ",e.classes+=(i={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"}[(n=d[1])!=null?n:""])!=null?i:"",e.classes+=" ",e.classes+=(s={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"}[(a=d[2])!=null?a:""])!=null?s:"")}return"Main-Regular"}};new Fc;var Q0=class extends Ai{constructor(){super("latex")}createAtom(e){return new Pt(e)}serialize(e,t){return e.filter(r=>r instanceof Pt&&!r.isSuggestion).map(r=>r.value)}getFont(){return null}};new Q0;var As={id:"dvorak",locale:"en",displayName:"Dvorak",virtualLayout:"dvorak",platform:"",score:0,mapping:{KeyA:["a","A","\xE5","\xC5"],KeyB:["x","X","\u2248","\u02DB"],KeyC:["j","J","\u2206","\xD4"],KeyD:["e","E","\xB4","\xB4"],KeyE:[".",">","\u2265","\u02D8"],KeyF:["u","U","\xA8","\xA8"],KeyG:["i","I","\u02C6","\u02C6"],KeyH:["d","D","\u2202","\xCE"],KeyI:["c","C","\xE7","\xC7"],KeyJ:["h","H","\u02D9","\xD3"],KeyK:["t","T","\u2020","\u02C7"],KeyL:["n","N","\u02DC","\u02DC"],KeyM:["m","M","\xB5","\xC2"],KeyN:["b","B","\u222B","\u0131"],KeyO:["r","R","\xAE","\u2030"],KeyP:["l","L","\xAC","\xD2"],KeyQ:["'",'"',"\xE6","\xC6"],KeyR:["p","P","\u03C0","\u220F"],KeyS:["o","O","\xF8","\xD8"],KeyT:["y","Y","\xA5","\xC1"],KeyU:["g","G","\xA9","\u02DD"],KeyV:["k","K","\u02DA","\uF8FF"],KeyW:[",","<","\u2264","\xAF"],KeyX:["q","Q","\u0153","\u0152"],KeyY:["f","F","\u0192","\xCF"],KeyZ:[";",":","\u2026","\xDA"],Digit1:["1","!","\xA1","\u2044"],Digit2:["2","@","\u2122","\u20AC"],Digit3:["3","#","\xA3","\u2039"],Digit4:["4","$","\xA2","\u203A"],Digit5:["5","%","\u221E","\uFB01"],Digit6:["6","^","\xA7","\uFB02"],Digit7:["7","&","\xB6","\u2021"],Digit8:["8","*","\u2022","\xB0"],Digit9:["9","(","\xAA","\xB7"],Digit0:["0",")","\xBA","\u201A"],Space:[" "," "," "," "],Minus:["[","{","\u201C","\u201D"],Equal:["]","}","\u2018","\u2019"],BracketLeft:["/","?","\xF7","\xBF"],BracketRight:["=","+","\u2260","\xB1"],Backslash:["\\","|","\xAB","\xBB"],Semicolon:["s","S","\xDF","\xCD"],Quote:["-","_","\u2013","\u2014"],Backquote:["`","~","`","`"],Comma:["w","W","\u2211","\u201E"],Period:["v","V","\u221A","\u25CA"],Slash:["z","Z","\u03A9","\xB8"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],Numpad1:["1","1","1","1"],Numpad2:["2","2","2","2"],Numpad3:["3","3","3","3"],Numpad4:["4","4","4","4"],Numpad5:["5","5","5","5"],Numpad6:["6","6","6","6"],Numpad7:["7","7","7","7"],Numpad8:["8","8","8","8"],Numpad9:["9","9","9","9"],Numpad0:["0","0","0","0"],NumpadDecimal:[".",".",".","."],IntlBackslash:["\xA7","\xB1","\xA7","\xB1"],NumpadEqual:["=","=","=","="],AudioVolumeUp:["","=","","="]}},Ls={id:"apple.en-intl",displayName:"English (international)",virtualLayout:"qwerty",platform:"apple",locale:"en",score:0,mapping:{KeyA:["a","A","\xE5","\xC5"],KeyB:["b","B","\u222B","\u0131"],KeyC:["c","C","\xE7","\xC7"],KeyD:["d","D","\u2202","\xCE"],KeyE:["e","E","\xB4","\xB4"],KeyF:["f","F","\u0192","\xCF"],KeyG:["g","G","\xA9","\u02DD"],KeyH:["h","H","\u02D9","\xD3"],KeyI:["i","I","\u02C6","\u02C6"],KeyJ:["j","J","\u2206","\xD4"],KeyK:["k","K","\u02DA","\uF8FF"],KeyL:["l","L","\xAC","\xD2"],KeyM:["m","M","\xB5","\xC2"],KeyN:["n","N","\u02DC","\u02DC"],KeyO:["o","O","\xF8","\xD8"],KeyP:["p","P","\u03C0","\u220F"],KeyQ:["q","Q","\u0153","\u0152"],KeyR:["r","R","\xAE","\u2030"],KeyS:["s","S","\xDF","\xCD"],KeyT:["t","T","\u2020","\u02C7"],KeyU:["u","U","\xA8","\xA8"],KeyV:["v","V","\u221A","\u25CA"],KeyW:["w","W","\u2211","\u201E"],KeyX:["x","X","\u2248","\u02DB"],KeyY:["y","Y","\xA5","\xC1"],KeyZ:["z","Z","\u03A9","\xB8"],Digit1:["1","!","\xA1","\u2044"],Digit2:["2","@","\u2122","\u20AC"],Digit3:["3","#","\xA3","\u2039"],Digit4:["4","$","\xA2","\u203A"],Digit5:["5","%","\u221E","\uFB01"],Digit6:["6","^","\xA7","\uFB02"],Digit7:["7","&","\xB6","\u2021"],Digit8:["8","*","\u2022","\xB0"],Digit9:["9","(","\xAA","\xB7"],Digit0:["0",")","\xBA","\u201A"],Space:[" "," "," "," "],Minus:["-","_","\u2013","\u2014"],Equal:["=","+","\u2260","\xB1"],BracketLeft:["[","{","\u201C","\u201D"],BracketRight:["]","}","\u2018","\u2019"],Backslash:["\\","|","\xAB","\xBB"],Semicolon:[";",":","\u2026","\xDA"],Quote:["'",'"',"\xE6","\xC6"],Backquote:["`","\u02DC","`","`"],Comma:[",","<","\u2264","\xAF"],Period:[".",">","\u2265","\u02D8"],Slash:["/","?","\xF7","\xBF"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],Numpad1:["1","1","1","1"],Numpad2:["2","2","2","2"],Numpad3:["3","3","3","3"],Numpad4:["4","4","4","4"],Numpad5:["5","5","5","5"],Numpad6:["6","6","6","6"],Numpad7:["7","7","7","7"],Numpad8:["8","8","8","8"],Numpad9:["9","9","9","9"],Numpad0:["0","0","0","0"],NumpadDecimal:[".",".",".","."],IntlBackslash:["\xA7","\xB1","\xA7","\xB1"],NumpadEqual:["=","=","=","="],AudioVolumeUp:["","=","","="]}},zf={id:"windows.en-intl",displayName:"English (international)",platform:"windows",virtualLayout:"qwerty",locale:"en",score:0,mapping:{KeyA:["a","A","\xE1","\xC1"],KeyB:["b","B","",""],KeyC:["c","C","\xA9","\xA2"],KeyD:["d","D","\xF0","\xD0"],KeyE:["e","E","\xE9","\xC9"],KeyF:["f","F","",""],KeyG:["g","G","",""],KeyH:["h","H","",""],KeyI:["i","I","\xED","\xCD"],KeyJ:["j","J","",""],KeyK:["k","K","",""],KeyL:["l","L","\xF8","\xD8"],KeyM:["m","M","\xB5",""],KeyN:["n","N","\xF1","\xD1"],KeyO:["o","O","\xF3","\xD3"],KeyP:["p","P","\xF6","\xD6"],KeyQ:["q","Q","\xE4","\xC4"],KeyR:["r","R","\xAE",""],KeyS:["s","S","\xDF","\xA7"],KeyT:["t","T","\xFE","\xDE"],KeyU:["u","U","\xFA","\xDA"],KeyV:["v","V","",""],KeyW:["w","W","\xE5","\xC5"],KeyX:["x","X","",""],KeyY:["y","Y","\xFC","\xDC"],KeyZ:["z","Z","\xE6","\xC6"],Digit1:["1","!","\xA1","\xB9"],Digit2:["2","@","\xB2",""],Digit3:["3","#","\xB3",""],Digit4:["4","$","\xA4","\xA3"],Digit5:["5","%","\u20AC",""],Digit6:["6","^","\xBC",""],Digit7:["7","&","\xBD",""],Digit8:["8","*","\xBE",""],Digit9:["9","(","\u2018",""],Digit0:["0",")","\u2019",""],Space:[" "," ","",""],Minus:["-","_","\xA5",""],Equal:["=","+","\xD7","\xF7"],BracketLeft:["[","{","\xAB",""],BracketRight:["]","}","\xBB",""],Backslash:["\\","|","\xAC","\xA6"],Semicolon:[";",":","\xB6","\xB0"],Quote:["'",'"',"\xB4","\xA8"],Backquote:["`","~","",""],Comma:[",","<","\xE7","\xC7"],Period:[".",">","",""],Slash:["/","?","\xBF",""],NumpadDivide:["/","/","",""],NumpadMultiply:["*","*","",""],NumpadSubtract:["-","-","",""],NumpadAdd:["+","+","",""],IntlBackslash:["\\","|","",""]}},Kf={id:"linux.en",displayName:"English",platform:"linux",virtualLayout:"qwerty",locale:"en",score:0,mapping:{KeyA:["a","A","a","A"],KeyB:["b","B","b","B"],KeyC:["c","C","c","C"],KeyD:["d","D","d","D"],KeyE:["e","E","e","E"],KeyF:["f","F","f","F"],KeyG:["g","G","g","G"],KeyH:["h","H","h","H"],KeyI:["i","I","i","I"],KeyJ:["j","J","j","J"],KeyK:["k","K","k","K"],KeyL:["l","L","l","L"],KeyM:["m","M","m","M"],KeyN:["n","N","n","N"],KeyO:["o","O","o","O"],KeyP:["p","P","p","P"],KeyQ:["q","Q","q","Q"],KeyR:["r","R","r","R"],KeyS:["s","S","s","S"],KeyT:["t","T","t","T"],KeyU:["u","U","u","U"],KeyV:["v","V","v","V"],KeyW:["w","W","w","W"],KeyX:["x","X","x","X"],KeyY:["y","Y","y","Y"],KeyZ:["z","Z","z","Z"],Digit1:["1","!","1","!"],Digit2:["2","@","2","@"],Digit3:["3","#","3","#"],Digit4:["4","$","4","$"],Digit5:["5","%","5","%"],Digit6:["6","^","6","^"],Digit7:["7","&","7","&"],Digit8:["8","*","8","*"],Digit9:["9","(","9","("],Digit0:["0",")","0",")"],Space:[" "," "," "," "],Minus:["-","_","-","_"],Equal:["=","+","=","+"],BracketLeft:["[","{","[","{"],BracketRight:["]","}","]","}"],Backslash:["\\","|","\\","|"],Semicolon:[";",":",";",":"],Quote:["'",'"',"'",'"'],Backquote:["`","~","`","~"],Comma:[",","<",",","<"],Period:[".",">",".",">"],Slash:["/","?","/","?"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],Numpad1:["1","1","1","1"],Numpad2:["2","2","2","2"],Numpad3:["3","3","3","3"],Numpad4:["4","4","4","4"],Numpad5:["5","5","5","5"],Numpad6:["6","6","6","6"],Numpad7:["7","7","7","7"],Numpad8:["8","8","8","8"],Numpad9:["9","9","9","9"],Numpad0:["0","0","0","0"],NumpadDecimal:["",".","","."],IntlBackslash:["<",">","|","\xA6"],NumpadEqual:["=","=","=","="],NumpadComma:[".",".",".","."],NumpadParenLeft:["(","(","(","("],NumpadParenRight:[")",")",")",")"]}},$p={id:"apple.french",locale:"fr",displayName:"French",platform:"apple",virtualLayout:"azerty",score:0,mapping:{KeyA:["q","Q","\u2021","\u03A9"],KeyB:["b","B","\xDF","\u222B"],KeyC:["c","C","\xA9","\xA2"],KeyD:["d","D","\u2202","\u2206"],KeyE:["e","E","\xEA","\xCA"],KeyF:["f","F","\u0192","\xB7"],KeyG:["g","G","\uFB01","\uFB02"],KeyH:["h","H","\xCC","\xCE"],KeyI:["i","I","\xEE","\xEF"],KeyJ:["j","J","\xCF","\xCD"],KeyK:["k","K","\xC8","\xCB"],KeyL:["l","L","\xAC","|"],KeyM:[",","?","\u221E","\xBF"],KeyN:["n","N","~","\u0131"],KeyO:["o","O","\u0153","\u0152"],KeyP:["p","P","\u03C0","\u220F"],KeyQ:["a","A","\xE6","\xC6"],KeyR:["r","R","\xAE","\u201A"],KeyS:["s","S","\xD2","\u2211"],KeyT:["t","T","\u2020","\u2122"],KeyU:["u","U","\xBA","\xAA"],KeyV:["v","V","\u25CA","\u221A"],KeyW:["z","Z","\xC2","\xC5"],KeyX:["x","X","\u2248","\u2044"],KeyY:["y","Y","\xDA","\u0178"],KeyZ:["w","W","\u2039","\u203A"],Digit1:["&","1","\uF8FF","\xB4"],Digit2:["\xE9","2","\xEB","\u201E"],Digit3:['"',"3","\u201C","\u201D"],Digit4:["'","4","\u2018","\u2019"],Digit5:["(","5","{","["],Digit6:["\xA7","6","\xB6","\xE5"],Digit7:["\xE8","7","\xAB","\xBB"],Digit8:["!","8","\xA1","\xDB"],Digit9:["\xE7","9","\xC7","\xC1"],Digit0:["\xE0","0","\xF8","\xD8"],Space:[" "," "," "," "],Minus:[")","\xB0","}","]"],Equal:["-","_","\u2014","\u2013"],BracketLeft:["^","\xA8","\xF4","\xD4"],BracketRight:["$","*","\u20AC","\xA5"],Backslash:["`","\xA3","@","#"],Semicolon:["m","M","\xB5","\xD3"],Quote:["\xF9","%","\xD9","\u2030"],Backquote:["<",">","\u2264","\u2265"],Comma:[";",".","\u2026","\u2022"],Period:[":","/","\xF7","\\"],Slash:["=","+","\u2260","\xB1"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],NumpadDecimal:[",",".",",","."],IntlBackslash:["@","#","\u2022","\u0178"],NumpadEqual:["=","=","=","="]}},Tp={id:"windows.french",locale:"fr",displayName:"French",virtualLayout:"azerty",platform:"windows",score:0,mapping:{KeyA:["q","Q","",""],KeyB:["b","B","",""],KeyC:["c","C","",""],KeyD:["d","D","",""],KeyE:["e","E","\u20AC",""],KeyF:["f","F","",""],KeyG:["g","G","",""],KeyH:["h","H","",""],KeyI:["i","I","",""],KeyJ:["j","J","",""],KeyK:["k","K","",""],KeyL:["l","L","",""],KeyM:[",","?","",""],KeyN:["n","N","",""],KeyO:["o","O","",""],KeyP:["p","P","",""],KeyQ:["a","A","",""],KeyR:["r","R","",""],KeyS:["s","S","",""],KeyT:["t","T","",""],KeyU:["u","U","",""],KeyV:["v","V","",""],KeyW:["z","Z","",""],KeyX:["x","X","",""],KeyY:["y","Y","",""],KeyZ:["w","W","",""],Digit1:["&","1","",""],Digit2:["\xE9","2","~",""],Digit3:['"',"3","#",""],Digit4:["'","4","{",""],Digit5:["(","5","[",""],Digit6:["-","6","|",""],Digit7:["\xE8","7","`",""],Digit8:["_","8","\\",""],Digit9:["\xE7","9","^",""],Digit0:["\xE0","0","@",""],Space:[" "," ","",""],Minus:[")","\xB0","]",""],Equal:["=","+","}",""],BracketLeft:["^","\xA8","",""],BracketRight:["$","\xA3","\xA4",""],Backslash:["*","\xB5","",""],Semicolon:["m","M","",""],Quote:["\xF9","%","",""],Backquote:["\xB2","","",""],Comma:[";",".","",""],Period:[":","/","",""],Slash:["!","\xA7","",""],NumpadDivide:["/","/","",""],NumpadMultiply:["*","*","",""],NumpadSubtract:["-","-","",""],NumpadAdd:["+","+","",""],IntlBackslash:["<",">","",""]}},Pp={id:"linux.french",locale:"fr",displayName:"French",virtualLayout:"azerty",platform:"linux",score:0,mapping:{KeyA:["q","Q","@","\u03A9"],KeyB:["b","B","\u201D","\u2019"],KeyC:["c","C","\xA2","\xA9"],KeyD:["d","D","\xF0","\xD0"],KeyE:["e","E","\u20AC","\xA2"],KeyF:["f","F","\u0111","\xAA"],KeyG:["g","G","\u014B","\u014A"],KeyH:["h","H","\u0127","\u0126"],KeyI:["i","I","\u2192","\u0131"],KeyJ:["j","J","\u0309","\u031B"],KeyK:["k","K","\u0138","&"],KeyL:["l","L","\u0142","\u0141"],KeyM:[",","?","\u0301","\u030B"],KeyN:["n","N","n","N"],KeyO:["o","O","\xF8","\xD8"],KeyP:["p","P","\xFE","\xDE"],KeyQ:["a","A","\xE6","\xC6"],KeyR:["r","R","\xB6","\xAE"],KeyS:["s","S","\xDF","\xA7"],KeyT:["t","T","\u0167","\u0166"],KeyU:["u","U","\u2193","\u2191"],KeyV:["v","V","\u201C","\u2018"],KeyW:["z","Z","\xAB","<"],KeyX:["x","X","\xBB",">"],KeyY:["y","Y","\u2190","\xA5"],KeyZ:["w","W","\u0142","\u0141"],Digit1:["&","1","\xB9","\xA1"],Digit2:["\xE9","2","~","\u215B"],Digit3:['"',"3","#","\xA3"],Digit4:["'","4","{","$"],Digit5:["(","5","[","\u215C"],Digit6:["-","6","|","\u215D"],Digit7:["\xE8","7","`","\u215E"],Digit8:["_","8","\\","\u2122"],Digit9:["\xE7","9","^","\xB1"],Digit0:["\xE0","0","@","\xB0"],Enter:["\r","\r","\r","\r"],Escape:["\x1B","\x1B","\x1B","\x1B"],Backspace:["\b","\b","\b","\b"],Tab:[" ",""," ",""],Space:[" "," "," "," "],Minus:[")","\xB0","]","\xBF"],Equal:["=","+","}","\u0328"],BracketLeft:["\u0302","\u0308","\u0308","\u030A"],BracketRight:["$","\xA3","\xA4","\u0304"],Backslash:["*","\xB5","\u0300","\u0306"],Semicolon:["m","M","\xB5","\xBA"],Quote:["\xF9","%","\u0302","\u030C"],Backquote:["\xB2","~","\xAC","\xAC"],Comma:[";",".","\u2500","\xD7"],Period:[":","/","\xB7","\xF7"],Slash:["!","\xA7","\u0323","\u0307"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],NumpadDecimal:["",".","","."],IntlBackslash:["<",">","|","\xA6"]}},Rp={id:"apple.german",locale:"de",displayName:"German",virtualLayout:"qwertz",platform:"apple",score:0,mapping:{KeyA:["a","A","\xE5","\xC5"],KeyB:["b","B","\u222B","\u2039"],KeyC:["c","C","\xE7","\xC7"],KeyD:["d","D","\u2202","\u2122"],KeyE:["e","E","\u20AC","\u2030"],KeyF:["f","F","\u0192","\xCF"],KeyG:["g","G","\xA9","\xCC"],KeyH:["h","H","\xAA","\xD3"],KeyI:["i","I","\u2044","\xDB"],KeyJ:["j","J","\xBA","\u0131"],KeyK:["k","K","\u2206","\u02C6"],KeyL:["l","L","@","\uFB02"],KeyM:["m","M","\xB5","\u02D8"],KeyN:["n","N","~","\u203A"],KeyO:["o","O","\xF8","\xD8"],KeyP:["p","P","\u03C0","\u220F"],KeyQ:["q","Q","\xAB","\xBB"],KeyR:["r","R","\xAE","\xB8"],KeyS:["s","S","\u201A","\xCD"],KeyT:["t","T","\u2020","\u02DD"],KeyU:["u","U","\xA8","\xC1"],KeyV:["v","V","\u221A","\u25CA"],KeyW:["w","W","\u2211","\u201E"],KeyX:["x","X","\u2248","\xD9"],KeyY:["z","Z","\u03A9","\u02C7"],KeyZ:["y","Y","\xA5","\u2021"],Digit1:["1","!","\xA1","\xAC"],Digit2:["2",'"',"\u201C","\u201D"],Digit3:["3","\xA7","\xB6","#"],Digit4:["4","$","\xA2","\xA3"],Digit5:["5","%","[","\uFB01"],Digit6:["6","&","]","^"],Digit7:["7","/","|","\\"],Digit8:["8","(","{","\u02DC"],Digit9:["9",")","}","\xB7"],Digit0:["0","=","\u2260","\xAF"],Space:[" "," "," "," "],Minus:["\xDF","?","\xBF","\u02D9"],Equal:["\xB4","`","'","\u02DA"],BracketLeft:["\xFC","\xDC","\u2022","\xB0"],BracketRight:["+","*","\xB1","\uF8FF"],Backslash:["#","'","\u2018","\u2019"],Semicolon:["\xF6","\xD6","\u0153","\u0152"],Quote:["\xE4","\xC4","\xE6","\xC6"],Backquote:["<",">","\u2264","\u2265"],Comma:[",",";","\u221E","\u02DB"],Period:[".",":","\u2026","\xF7"],Slash:["-","_","\u2013","\u2014"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],NumpadDecimal:[",",",",".","."],IntlBackslash:["^","\xB0","\u201E","\u201C"],NumpadEqual:["=","=","=","="]}},Op={id:"windows.german",locale:"de",displayName:"German",platform:"windows",virtualLayout:"qwertz",score:0,mapping:{KeyA:["a","A","",""],KeyB:["b","B","",""],KeyC:["c","C","",""],KeyD:["d","D","",""],KeyE:["e","E","\u20AC",""],KeyF:["f","F","",""],KeyG:["g","G","",""],KeyH:["h","H","",""],KeyI:["i","I","",""],KeyJ:["j","J","",""],KeyK:["k","K","",""],KeyL:["l","L","",""],KeyM:["m","M","\xB5",""],KeyN:["n","N","",""],KeyO:["o","O","",""],KeyP:["p","P","",""],KeyQ:["q","Q","@",""],KeyR:["r","R","",""],KeyS:["s","S","",""],KeyT:["t","T","",""],KeyU:["u","U","",""],KeyV:["v","V","",""],KeyW:["w","W","",""],KeyX:["x","X","",""],KeyY:["z","Z","",""],KeyZ:["y","Y","",""],Digit1:["1","!","",""],Digit2:["2",'"',"\xB2",""],Digit3:["3","\xA7","\xB3",""],Digit4:["4","$","",""],Digit5:["5","%","",""],Digit6:["6","&","",""],Digit7:["7","/","{",""],Digit8:["8","(","[",""],Digit9:["9",")","]",""],Digit0:["0","=","}",""],Space:[" "," ","",""],Minus:["\xDF","?","\\","\u1E9E"],Equal:["\xB4","`","",""],BracketLeft:["\xFC","\xDC","",""],BracketRight:["+","*","~",""],Backslash:["#","'","",""],Semicolon:["\xF6","\xD6","",""],Quote:["\xE4","\xC4","",""],Backquote:["^","\xB0","",""],Comma:[",",";","",""],Period:[".",":","",""],Slash:["-","_","",""],NumpadDivide:["/","/","",""],NumpadMultiply:["*","*","",""],NumpadSubtract:["-","-","",""],NumpadAdd:["+","+","",""],IntlBackslash:["<",">","|",""]}},Np={id:"linux.german",locale:"de",displayName:"German",platform:"windows",virtualLayout:"qwertz",score:0,mapping:{KeyA:["a","A","\xE6","\xC6"],KeyB:["b","B","\u201C","\u2018"],KeyC:["c","C","\xA2","\xA9"],KeyD:["d","D","\xF0","\xD0"],KeyE:["e","E","\u20AC","\u20AC"],KeyF:["f","F","\u0111","\xAA"],KeyG:["g","G","\u014B","\u014A"],KeyH:["h","H","\u0127","\u0126"],KeyI:["i","I","\u2192","\u0131"],KeyJ:["j","J","\u0323","\u0307"],KeyK:["k","K","\u0138","&"],KeyL:["l","L","\u0142","\u0141"],KeyM:["m","M","\xB5","\xBA"],KeyN:["n","N","\u201D","\u2019"],KeyO:["o","O","\xF8","\xD8"],KeyP:["p","P","\xFE","\xDE"],KeyQ:["q","Q","@","\u03A9"],KeyR:["r","R","\xB6","\xAE"],KeyS:["s","S","\u017F","\u1E9E"],KeyT:["t","T","\u0167","\u0166"],KeyU:["u","U","\u2193","\u2191"],KeyV:["v","V","\u201E","\u201A"],KeyW:["w","W","\u0142","\u0141"],KeyX:["x","X","\xAB","\u2039"],KeyY:["z","Z","\u2190","\xA5"],KeyZ:["y","Y","\xBB","\u203A"],Digit1:["1","!","\xB9","\xA1"],Digit2:["2",'"',"\xB2","\u215B"],Digit3:["3","\xA7","\xB3","\xA3"],Digit4:["4","$","\xBC","\xA4"],Digit5:["5","%","\xBD","\u215C"],Digit6:["6","&","\xAC","\u215D"],Digit7:["7","/","{","\u215E"],Digit8:["8","(","[","\u2122"],Digit9:["9",")","]","\xB1"],Digit0:["0","=","}","\xB0"],Enter:["\r","\r","\r","\r"],Escape:["\x1B","\x1B","\x1B","\x1B"],Backspace:["\b","\b","\b","\b"],Tab:[" ",""," ",""],Space:[" "," "," "," "],Minus:["\xDF","?","\\","\xBF"],Equal:["\u0301","\u0300","\u0327","\u0328"],BracketLeft:["\xFC","\xDC","\u0308","\u030A"],BracketRight:["+","*","~","\xAF"],Backslash:["#","'","\u2019","\u0306"],Semicolon:["\xF6","\xD6","\u030B","\u0323"],Quote:["\xE4","\xC4","\u0302","\u030C"],Backquote:["\u0302","\xB0","\u2032","\u2033"],Comma:[",",";","\xB7","\xD7"],Period:[".",":","\u2026","\xF7"],Slash:["-","_","\u2013","\u2014"],PrintScreen:["","","",""],PageUp:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],Numpad1:["","1","","1"],Numpad2:["","2","","2"],Numpad3:["","3","","3"],Numpad4:["","4","","4"],Numpad5:["","5","","5"],Numpad6:["","6","","6"],Numpad7:["","7","","7"],Numpad8:["","8","","8"],Numpad9:["","9","","9"],Numpad0:["","0","","0"],NumpadDecimal:["",",","",","],IntlBackslash:["<",">","|","\u0331"],AltRight:["\r","\r","\r","\r"],MetaRight:[".",".",".","."]}},Fp={id:"apple.spanish",locale:"es",displayName:"Spanish ISO",platform:"apple",virtualLayout:"qwerty",score:0,mapping:{KeyA:["a","A","\xE5","\xC5"],KeyB:["b","B","\xDF",""],KeyC:["c","C","\xA9"," "],KeyD:["d","D","\u2202","\u2206"],KeyE:["e","E","\u20AC","\u20AC"],KeyF:["f","F","\u0192","\uFB01"],KeyG:["g","G","\uF8FF","\uFB02"],KeyH:["h","H","\u2122"," "],KeyI:["i","I"," "," "],KeyJ:["j","J","\xB6","\xAF"],KeyK:["k","K","\xA7","\u02C7"],KeyL:["l","L"," ","\u02D8"],KeyM:["m","M","\xB5","\u02DA"],KeyN:["n","N"," ","\u02D9"],KeyO:["o","O","\xF8","\xD8"],KeyP:["p","P","\u03C0","\u220F"],KeyQ:["q","Q","\u0153","\u0152"],KeyR:["r","R","\xAE"," "],KeyS:["s","S","\u222B"," "],KeyT:["t","T","\u2020","\u2021"],KeyU:["u","U"," "," "],KeyV:["v","V","\u221A","\u25CA"],KeyW:["w","W","\xE6","\xC6"],KeyX:["x","X","\u2211","\u203A"],KeyY:["y","Y","\xA5"," "],KeyZ:["z","Z","\u03A9","\u2039"],Digit1:["1","!","|","\u0131"],Digit2:["2",'"',"@","\u02DD"],Digit3:["3","\xB7","#","\u2022"],Digit4:["4","$","\xA2","\xA3"],Digit5:["5","%","\u221E","\u2030"],Digit6:["6","&","\xAC"," "],Digit7:["7","/","\xF7","\u2044"],Digit8:["8","(","\u201C","\u2018"],Digit9:["9",")","\u201D","\u2019"],Digit0:["0","=","\u2260","\u2248"],Space:[" "," "," "," "],Minus:["'","?","\xB4","\xB8"],Equal:["\xA1","\xBF","\u201A","\u02DB"],BracketLeft:["`","^","[","\u02C6"],BracketRight:["+","*","]","\xB1"],Backslash:["\xE7","\xC7","}","\xBB"],Semicolon:["\xF1","\xD1","~","\u02DC"],Quote:["\xB4","\xA8","{","\xAB"],Backquote:["<",">","\u2264","\u2265"],Comma:[",",";","\u201E",""],Period:[".",":","\u2026","\u2026"],Slash:["-","_","\u2013","\u2014"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],Numpad1:["1","1","1","1"],Numpad2:["2","2","2","2"],Numpad3:["3","3","3","3"],Numpad4:["4","4","4","4"],Numpad5:["5","5","5","5"],Numpad6:["6","6","6","6"],Numpad7:["7","7","7","7"],Numpad8:["8","8","8","8"],Numpad9:["9","9","9","9"],Numpad0:["0","0","0","0"],NumpadDecimal:[",",",",",",","],IntlBackslash:["\xBA","\xAA","\\","\xB0"]}},zp={id:"windows.spanish",locale:"es",displayName:"Spanish",platform:"windows",virtualLayout:"qwerty",score:0,mapping:{KeyA:["a","A","",""],KeyB:["b","B","",""],KeyC:["c","C","",""],KeyD:["d","D","",""],KeyE:["e","E","\u20AC",""],KeyF:["f","F","",""],KeyG:["g","G","",""],KeyH:["h","H","",""],KeyI:["i","I","",""],KeyJ:["j","J","",""],KeyK:["k","K","",""],KeyL:["l","L","",""],KeyM:["m","M","",""],KeyN:["n","N","",""],KeyO:["o","O","",""],KeyP:["p","P","",""],KeyQ:["q","Q","",""],KeyR:["r","R","",""],KeyS:["s","S","",""],KeyT:["t","T","",""],KeyU:["u","U","",""],KeyV:["v","V","",""],KeyW:["w","W","",""],KeyX:["x","X","",""],KeyY:["y","Y","",""],KeyZ:["z","Z","",""],Digit1:["1","!","|",""],Digit2:["2",'"',"@",""],Digit3:["3","\xB7","#",""],Digit4:["4","$","~",""],Digit5:["5","%","\u20AC",""],Digit6:["6","&","\xAC",""],Digit7:["7","/","",""],Digit8:["8","(","",""],Digit9:["9",")","",""],Digit0:["0","=","",""],Space:[" "," ","",""],Minus:["'","?","",""],Equal:["\xA1","\xBF","",""],BracketLeft:["`","^","[",""],BracketRight:["+","*","]",""],Backslash:["\xE7","\xC7","}",""],Semicolon:["\xF1","\xD1","",""],Quote:["\xB4","\xA8","{",""],Backquote:["\xBA","\xAA","\\",""],Comma:[",",";","",""],Period:[".",":","",""],Slash:["-","_","",""],NumpadDivide:["/","/","",""],NumpadMultiply:["*","*","",""],NumpadSubtract:["-","-","",""],NumpadAdd:["+","+","",""],IntlBackslash:["<",">","",""]}},Kp={id:"linux.spanish",locale:"es",displayName:"Spanish",platform:"linux",virtualLayout:"qwerty",score:0,mapping:{KeyA:["a","A","\xE6","\xC6"],KeyB:["b","B","\u201D","\u2019"],KeyC:["c","C","\xA2","\xA9"],KeyD:["d","D","\xF0","\xD0"],KeyE:["e","E","\u20AC","\xA2"],KeyF:["f","F","\u0111","\xAA"],KeyG:["g","G","\u014B","\u014A"],KeyH:["h","H","\u0127","\u0126"],KeyI:["i","I","\u2192","\u0131"],KeyJ:["j","J","\u0309","\u031B"],KeyK:["k","K","\u0138","&"],KeyL:["l","L","\u0142","\u0141"],KeyM:["m","M","\xB5","\xBA"],KeyN:["n","N","n","N"],KeyO:["o","O","\xF8","\xD8"],KeyP:["p","P","\xFE","\xDE"],KeyQ:["q","Q","@","\u03A9"],KeyR:["r","R","\xB6","\xAE"],KeyS:["s","S","\xDF","\xA7"],KeyT:["t","T","\u0167","\u0166"],KeyU:["u","U","\u2193","\u2191"],KeyV:["v","V","\u201C","\u2018"],KeyW:["w","W","\u0142","\u0141"],KeyX:["x","X","\xBB",">"],KeyY:["y","Y","\u2190","\xA5"],KeyZ:["z","Z","\xAB","<"],Digit1:["1","!","|","\xA1"],Digit2:["2",'"',"@","\u215B"],Digit3:["3","\xB7","#","\xA3"],Digit4:["4","$","~","$"],Digit5:["5","%","\xBD","\u215C"],Digit6:["6","&","\xAC","\u215D"],Digit7:["7","/","{","\u215E"],Digit8:["8","(","[","\u2122"],Digit9:["9",")","]","\xB1"],Digit0:["0","=","}","\xB0"],Enter:["\r","\r","\r","\r"],Escape:["\x1B","\x1B","\x1B","\x1B"],Backspace:["\b","\b","\b","\b"],Tab:[" ",""," ",""],Space:[" "," "," "," "],Minus:["'","?","\\","\xBF"],Equal:["\xA1","\xBF","\u0303","~"],BracketLeft:["\u0300","\u0302","[","\u030A"],BracketRight:["+","*","]","\u0304"],Backslash:["\xE7","\xC7","}","\u0306"],Semicolon:["\xF1","\xD1","~","\u030B"],Quote:["\u0301","\u0308","{","{"],Backquote:["\xBA","\xAA","\\","\\"],Comma:[",",";","\u2500","\xD7"],Period:[".",":","\xB7","\xF7"],Slash:["-","_","\u0323","\u0307"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],NumpadEnter:["\r","\r","\r","\r"],Numpad1:["","1","","1"],Numpad2:["","2","","2"],Numpad3:["","3","","3"],Numpad4:["","4","","4"],Numpad5:["","5","","5"],Numpad6:["","6","","6"],Numpad7:["","7","","7"],Numpad8:["","8","","8"],Numpad9:["","9","","9"],Numpad0:["","0","","0"],NumpadDecimal:["",".","","."],IntlBackslash:["<",">","|","\xA6"],NumpadEqual:["=","=","=","="],NumpadComma:[".",".",".","."],NumpadParenLeft:["(","(","(","("],NumpadParenRight:[")",")",")",")"]}};function Hf(e){const t=e.split("+"),r={shift:!1,alt:!1,cmd:!1,win:!1,meta:!1,ctrl:!1,key:t.pop()};return t.includes("shift")&&(r.shift=!0),t.includes("alt")&&(r.alt=!0),t.includes("ctrl")&&(r.ctrl=!0),t.includes("cmd")&&(r.cmd=!0),t.includes("win")&&(r.win=!0),t.includes("meta")&&(r.meta=!0),r}function Rl(e){let t="";return e.shift&&(t+="shift+"),e.alt&&(t+="alt+"),e.ctrl&&(t+="ctrl+"),e.cmd&&(t+="cmd+"),e.win&&(t+="win+"),e.meta&&(t+="meta+"),t+e.key}var Hp={enter:"[Enter]",escape:"[Escape]",backspace:"[Backspace]",tab:"[Tab]",space:"[Space]",pausebreak:"[Pause]",insert:"[Insert]",home:"[Home]",pageup:"[PageUp]",delete:"[Delete]",end:"[End]",pagedown:"[PageDown]",right:"[ArrowRight]",left:"[ArrowLeft]",down:"[ArrowDown]",up:"[ArrowUp]",numpad0:"[Numpad0]",numpad1:"[Numpad1]",numpad2:"[Numpad2]",numpad3:"[Numpad3]",numpad4:"[Numpad4]",numpad5:"[Numpad5]",numpad6:"[Numpad6]",numpad7:"[Numpad7]",numpad8:"[Numpad8]",numpad9:"[Numpad9]",numpad_divide:"[NumpadDivide]",numpad_multiply:"[NumpadMultiply]",numpad_subtract:"[NumpadSubtract]",numpad_add:"[NumpadAdd]",numpad_decimal:"[NumpadDecimal]",numpad_separator:"[NumpadComma]",capslock:"[Capslock]",f1:"[F1]",f2:"[F2]",f3:"[F3]",f4:"[F4]",f5:"[F5]",f6:"[F6]",f7:"[F7]",f8:"[F8]",f9:"[F9]",f10:"[F10]",f11:"[F11]",f12:"[F12]",f13:"[F13]",f14:"[F14]",f15:"[F15]",f16:"[F16]",f17:"[F17]",f18:"[F18]",f19:"[F19]"},zc=[],Kc;function ef(){switch(Qe()){case"macos":case"ios":return"apple";case"windows":return"windows"}return"linux"}function ta(e){(!e.platform||e.platform===ef())&&zc.push(e)}function Wp(e,t){var r;const n={shift:!1,alt:!1,cmd:!1,win:!1,meta:!1,ctrl:!1,key:""};if(!e)return n;for(const[i,a]of Object.entries(t.mapping)){if(a[0]===e)return n.key=`[${i}]`,n;if(a[1]===e)return n.shift=!0,n.key=`[${i}]`,n;if(a[2]===e)return n.alt=!0,n.key=`[${i}]`,n;if(a[3]===e)return n.shift=!0,n.alt=!0,n.key=`[${i}]`,n}return n.key=(r=Hp[e])!=null?r:"",n}function Vp(e){if(e.code)return e;const t=Object.entries(Hc().mapping);let r=!1,n=!1,i="";for(let a=0;a<4;a++){for(const[s,u]of t)if(u[a]===e.key){i=s,a===3?(r=!0,n=!0):a===2?r=!0:a===1&&(n=!0);break}if(i)break}return new KeyboardEvent(e.type,_(S({},e),{altKey:r,shiftKey:n,code:i}))}function Zp(e){var t,r;if(!e||e.key==="Unidentified"||e.key==="Dead")return;const n=e.shiftKey&&e.altKey?3:e.altKey?2:e.shiftKey?1:0;for(const i of zc)((t=i.mapping[e.code])==null?void 0:t[n])===e.key?i.score+=1:(r=i.mapping[e.code])!=null&&r[n]&&(i.score=0);zc.sort((i,a)=>a.score-i.score)}function jp(e){Kc=zc.find(t=>e.startsWith(t.locale))}function Hc(){return Kc!=null?Kc:zc[0]}function Up(){switch(ef()){case"apple":return Ls;case"windows":return zf;case"linux":return Kf}return Ls}switch(ef()){case"apple":ta(Ls),ta($p),ta(Fp),ta(Rp);break;case"windows":ta(zf),ta(Tp),ta(zp),ta(Op);break;case"linux":ta(Kf),ta(Pp),ta(Kp),ta(Np);break}ta(As);function tf(e){var t;const r=/macos|ios/.test(Qe()),n=e.split("+");let i="";for(const a of n)i&&(i+=r?"\u2009":'+'),a.startsWith("[Key")?i+=a.slice(4,5):a.startsWith("Key")?i+=a.slice(3,4):a.startsWith("[Digit")?i+=a.slice(6,7):a.startsWith("Digit")?i+=a.slice(5,6):i+=(t={cmd:"\u2318",meta:r?"\u2318":"Ctrl",shift:r?"\u21E7":"Shift",alt:r?"\u2325":"Alt",ctrl:r?"\u2303":"Ctrl","\n":r?"\u23CE":"Return","[return]":r?"\u23CE":"Return","[enter]":r?"\u2324":"Enter","[tab]":r?"\u21E5":"Tab","[escape]":"Esc","[backspace]":r?"\u232B":"Backspace","[delete]":r?"\u2326":"Del","[pageup]":r?"\u21DE":"Page Up","[pagedown]":r?"\u21DF":"Page Down","[home]":r?"\u2912":"Home","[end]":r?"\u2913":"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:"\u21E0",up:"\u21E1",right:"\u21E2",down:"\u21E3","[arrowleft]":"\u21E0","[arrowup]":"\u21E1","[arrowright]":"\u21E2","[arrowdown]":"\u21E3"}[a.toLowerCase()])!=null?t:a.toUpperCase();return i}function Bd(e){if(e instanceof MouseEvent||e instanceof PointerEvent)return{x:e.clientX,y:e.clientY};if(e instanceof TouchEvent){const t=[...e.touches].reduce((n,i)=>({x:n.x+i.clientX,y:n.y+i.clientY}),{x:0,y:0}),r=e.touches.length;return{x:t.x/r,y:t.y/r}}}function Bs(e){const t={alt:!1,control:!1,shift:!1,meta:!1};return(e instanceof MouseEvent||e instanceof PointerEvent||e instanceof TouchEvent||e instanceof KeyboardEvent)&&(e.altKey&&(t.alt=!0),e.ctrlKey&&(t.control=!0),e.metaKey&&(t.meta=!0),e.shiftKey&&(t.shift=!0)),t}function Gp(e,t){return!e&&t||e&&!t?!1:!e||!t?!0:e.alt===t.alt&&e.control===t.control&&e.shift===t.shift&&e.meta===t.meta}var qp=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 Id(e){return e.ctrlKey||e.metaKey||["Dead","Process"].includes(e.key)?!1:e.code===""?!0:qp.has(e.code)}function $d(){var e;let t=document.activeElement;for(;(e=t==null?void 0:t.shadowRoot)!=null&&e.activeElement;)t=t.shadowRoot.activeElement;return t}var ro=class No{static get scrim(){return No._scrim||(No._scrim=new No),No._scrim}static open(t){No.scrim.open(t)}static close(){No.scrim.close()}static get state(){return No.scrim.state}static get element(){return No.scrim.element}constructor(t){var r,n;this.lightDismiss=(r=t==null?void 0:t.lightDismiss)!=null?r:!0,this.translucent=(n=t==null?void 0:t.translucent)!=null?n:!1,this.state="closed"}get element(){if(this._element)return this._element;const t=document.createElement("div");return t.setAttribute("role","presentation"),t.style.position="fixed",t.style.contain="content",t.style.top="0",t.style.left="0",t.style.right="0",t.style.bottom="0",t.style.zIndex="var(--scrim-zindex, 10099)",t.style.outline="none",this.translucent?(t.style.background="rgba(255, 255, 255, .2)",t.style.backdropFilter="contrast(40%)"):t.style.background="transparent",this._element=t,t}open(t){var r;if(this.state!=="closed")return;this.state="opening",this.onDismiss=t==null?void 0:t.onDismiss,this.savedActiveElement=$d();const{element:n}=this;((r=t==null?void 0:t.root)!=null?r:document.body).appendChild(n),n.addEventListener("click",this),document.addEventListener("touchmove",this,!1),document.addEventListener("scroll",this,!1);const i=window.innerWidth-document.documentElement.clientWidth;this.savedMarginRight=document.body.style.marginRight,this.savedOverflow=document.body.style.overflow,document.body.style.overflow="hidden";const a=Number.parseFloat(getComputedStyle(document.body).marginRight);document.body.style.marginRight=`${a+i}px`,t!=null&&t.child&&n.append(t.child),this.state="open"}close(){var t,r,n,i;if(this.state!=="open"){console.assert(this.element.parentElement!==null);return}this.state="closing",typeof this.onDismiss=="function"&&this.onDismiss(),this.onDismiss=void 0;const{element:a}=this;a.removeEventListener("click",this),document.removeEventListener("touchmove",this,!1),document.removeEventListener("scroll",this,!1),a.remove(),document.body.style.overflow=(t=this.savedOverflow)!=null?t:"",document.body.style.marginRight=(r=this.savedMarginRight)!=null?r:"",$d()!==this.savedActiveElement&&((i=(n=this.savedActiveElement)==null?void 0:n.focus)==null||i.call(n)),a.innerHTML="",this.state="closed"}handleEvent(t){this.lightDismiss&&(t.target===this._element&&t.type==="click"?(this.close(),t.preventDefault(),t.stopPropagation()):t.target===document&&(t.type==="touchmove"||t.type==="scroll")&&(this.close(),t.preventDefault(),t.stopPropagation()))}};function Xp(e,t,r){let n=null,i=null,a=!1,s=!1,u=!1;const d=new AbortController,h=d.signal;return e.addEventListener("keydown",p=>{if(a||p.key==="Process"||p.code==="CapsLock"||/(Control|Meta|Alt|Shift)(Left|Right)/.test(p.code)){n=null;return}n=p,i=null,r.onKeystroke(p)?e.textContent="":n=null},{capture:!0,signal:h}),e.addEventListener("keypress",p=>{a||(n&&i&&r.onKeystroke(n),i=p)},{capture:!0,signal:h}),e.addEventListener("compositionstart",p=>{e.textContent="",a=!0,r.onCompositionStart(p.data)},{capture:!0,signal:h}),e.addEventListener("compositionupdate",p=>{a&&r.onCompositionUpdate(p.data)},{capture:!0,signal:h}),e.addEventListener("compositionend",p=>{e.textContent="",a&&(a=!1,r.onCompositionEnd(p.data))},{capture:!0,signal:h}),e.addEventListener("beforeinput",p=>p.stopImmediatePropagation(),{signal:h}),e.addEventListener("input",p=>{var y;if(!a&&(e.textContent="",p.inputType!=="insertCompositionText")){if(p.inputType==="insertFromPaste"){p.preventDefault(),p.stopPropagation();return}r.onInput((y=p.data)!=null?y:""),p.preventDefault(),p.stopPropagation()}},{signal:h}),e.addEventListener("paste",p=>{e.focus({preventScroll:!0}),e.textContent="",r.onPaste(p)||p.preventDefault(),p.stopImmediatePropagation()},{signal:h}),e.addEventListener("cut",p=>r.onCut(p),{capture:!0,signal:h}),e.addEventListener("copy",p=>r.onCopy(p),{capture:!0,signal:h}),e.addEventListener("blur",p=>{var y,M;if(((M=(y=p.relatedTarget)==null?void 0:y._mathfield)==null?void 0:M.element)===t){e.focus({preventScroll:!0}),p.preventDefault(),p.stopPropagation();return}const I=ro.state;if(I==="open"||I==="opening"){p.preventDefault(),p.stopPropagation();return}if(p.relatedTarget===p.target.getRootNode().host){p.preventDefault(),p.stopPropagation();return}u||s||(u=!0,n=null,i=null,r.onBlur(),u=!1)},{capture:!0,signal:h}),e.addEventListener("focus",p=>{u||s||(s=!0,r.onFocus(),s=!1)},{capture:!0,signal:h}),{dispose:()=>d.abort(),cancelComposition:()=>{a&&(e.blur(),requestAnimationFrame(()=>e.focus({preventScroll:!0})))},blur:()=>{typeof e.blur=="function"&&e.blur()},focus:()=>{!s&&typeof e.focus=="function"&&e.focus({preventScroll:!0})},hasFocus:()=>$d()===e,setAriaLabel:p=>e.setAttribute("aria-label",p),setValue:p=>{var y;e.textContent=p,e.style.left="-1000px",(y=window.getSelection())==null||y.selectAllChildren(e)},moveTo:(p,y)=>{e.style.top=`${y}px`,e.style.left=`${p}px`}}}function Ol(e){var t;if(!e||!Id(e))return"";let r;return e.key==="Unidentified"&&e.target&&(r=e.target.value),r=(t=r!=null?r:e.key)!=null?t:e.code,/^(Dead|Return|Enter|Tab|Escape|Delete|PageUp|PageDown|Home|End|Help|ArrowLeft|ArrowRight|ArrowUp|ArrowDown)$/.test(r)&&(r=""),r}function Wf(e){e=Vp(e);const t=[];return e.ctrlKey&&t.push("ctrl"),e.metaKey&&t.push("meta"),e.altKey&&t.push("alt"),e.shiftKey&&t.push("shift"),t.length===0?`[${e.code}]`:(t.push(`[${e.code}]`),t.join("+"))}function Jp(e){if(Ke()){const t=Qe(),r=e.startsWith("!"),n=e.endsWith(t);if(r&&!n||!r&&n)return!0}return e==="!other"?!1:e==="other"}function Yp(e,t,r){if(e.length===0)return"";const n=Rl(Hf(Wf(r))),i=Rl({key:r.key,shift:r.shiftKey,alt:r.altKey,ctrl:r.ctrlKey,meta:r.metaKey||r.ctrlKey&&/macos|ios/.test(Qe()),cmd:!1,win:!1});for(let a=e.length-1;a>=0;a--)if((e[a].key===n||e[a].key===i)&&(!e[a].ifMode||e[a].ifMode===t))return e[a].command;return""}function Vf(e){let t=e;return A(t)&&(t=t.length>0?t[0]+"("+t.slice(1).join("")+")":""),t}function Qp(e,t){let r=[];if(typeof t=="string"){const a=ud[t];A(a)?r=a.slice():a&&r.push(a)}const n=Vf(t),i=new RegExp("^"+n.replace("\\","\\\\").replace("|","\\|").replace("*","\\*").replace("$","\\$").replace("^","\\^")+"([^*a-zA-Z]|$)");for(const a of e)i.test(Vf(a.command))&&r.push(a.key);return r.map(tf)}function em(e,t){if(e.ifPlatform&&!/^!?(macos|windows|android|ios|chromeos|other)$/.test(e.ifPlatform))throw new Error(`Unexpected platform "${e.ifPlatform}" for keybinding ${e.key}`);if(e.ifLayout!==void 0&&(t.score===0||!e.ifLayout.includes(t.id)))return;const r=Hf(e.key);let n=e.ifPlatform;if(r.cmd){if(n&&n!=="macos"&&n!=="ios")throw new Error('Unexpected "cmd" modifier with platform "'+n+`"
"cmd" modifier can only be used with macOS or iOS platform.`);n||(n=Qe()==="ios"?"ios":"macos"),r.win=!1,r.cmd=!1,r.meta=!0}if(r.win){if(n&&n!=="windows")throw new Error('Unexpected "win" modifier with platform "'+n+`"
"win" modifier can only be used with Windows platform.`);n="windows",r.win=!1,r.cmd=!1,r.meta=!0}if(n&&!Jp(n))return;if(/^\[.+\]$/.test(r.key))return _(S({},e),{key:Rl(r)});const i=Wp(r.key,t);if(!i)return _(S({},e),{key:Rl(r)});if(i.shift&&r.shift||i.alt&&r.alt)throw new Error(`The keybinding ${e.key} (${rf(e.command)}) is conflicting with the key combination ${Rl(i)} using the ${t.displayName} keyboard layout`);return i.shift=i.shift||r.shift,i.alt=i.alt||r.alt,i.meta=r.meta,i.ctrl=r.ctrl,_(S({},e),{key:Rl(i)})}function rf(e){if(Array.isArray(e)){const t=[...e];return t.shift()+"("+t.map(r=>typeof r=="string"?`"${r}"`:r.toString()).join(", ")+")"}return e}function tm(e,t){const r=[],n=[];for(const i of e)try{const a=em(i,t);if(!a)continue;const s=n.find(u=>u.key===a.key&&u.ifMode===a.ifMode);if(s)throw new Error(`Ambiguous key binding ${i.key} (${rf(i.command)}) matches ${s.key} (${rf(s.command)}) with the ${t.displayName} keyboard layout`);n.push(a)}catch(a){a instanceof Error&&r.push(a.message)}return[n,r]}var rm=class extends Qr{constructor(){super("latex")}createAtom(e){return new Pt(e)}onPaste(e,t){if(!t)return!1;const r=typeof t=="string"?t:t.getData("application/x-latex")||t.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"}),xn(e)),e.startRecording(),!0):!1}insert(e,t,r){if(!e.contentWillChange({data:t,inputType:"insertText"}))return!1;r||(r={}),r.insertionMode||(r.insertionMode="replaceSelection"),r.selectionMode||(r.selectionMode="placeholder");const{silenceNotifications:n}=e;r.silenceNotifications&&(e.silenceNotifications=!0);const i=e.silenceNotifications;e.silenceNotifications=!0,r.insertionMode==="replaceSelection"&&!e.selectionIsCollapsed?e.deleteAtoms(Qn(e.selection)):r.insertionMode==="replaceAll"?(e.root.setChildren([],"body"),e.position=0):r.insertionMode==="insertBefore"?e.collapseSelection("backward"):r.insertionMode==="insertAfter"&&e.collapseSelection("forward");const a=[];for(const d of t)oe.test(d)&&a.push(new Pt(d));let s=e.at(e.position);if(s instanceof vr&&(s=s.lastChild),!(s.parent instanceof vr)){const d=new vr("");s.parent.addChildAfter(d,s),s=d.firstChild}const u=s.parent.addChildrenAfter(a,s);return e.silenceNotifications=i,r.selectionMode==="before"||(r.selectionMode==="item"?e.setSelection(e.anchor,e.offsetOf(u)):u&&(e.position=e.offsetOf(u))),e.contentDidChange({data:t,inputType:"insertText"}),e.silenceNotifications=n,!0}};function nm(e){return e.atoms.find(t=>t.type==="latexgroup")}function Wc(e){var t,r;const n=e.atoms.find(i=>i.type==="latexgroup");return n?(r=(t=n.body)==null?void 0:t.filter(i=>i.type==="latex"))!=null?r:[]:[]}function Zf(e,t){var r;let n=0,i=!1;const a=Number.isFinite(t==null?void 0:t.before)?(r=t==null?void 0:t.before)!=null?r:0:e.lastOffset;for(;n<=a&&!i;){const d=e.at(n);i=d instanceof Pt&&d.isSuggestion,i||n++}if(!i)return[void 0,void 0];let s=n,u=!1;for(;s<=a&&!u;){const d=e.at(s);u=!(d instanceof Pt&&d.isSuggestion),u||s++}return[n-1,s-1]}new rm;function Td(e){const t=Wc(e.model).filter(r=>r.isSuggestion);if(t.length!==0){e.model.position=e.model.offsetOf(t[0].leftSibling);for(const r of t)r.parent.removeChild(r)}}function Vc(e,t){var r;const{model:n}=e;Td(e);for(const p of Wc(n))p.isError=!1;if(!n.selectionIsCollapsed||e.options.popoverPolicy==="off"){Fl(e);return}const i=[];let a=n.at(n.position);for(;a&&a instanceof Pt&&/^[a-zA-Z\*]$/.test(a.value);)a=a.leftSibling;if(a&&a instanceof Pt&&a.value==="\\")for(i.push(a),a=a.rightSibling;a&&a instanceof Pt&&/^[a-zA-Z\*]$/.test(a.value);)i.push(a),a=a.rightSibling;const s=i.map(p=>p.value).join(""),u=ie(e,s);if(u.length===0){if(/^\\[a-zA-Z\*]+$/.test(s))for(const p of i)p.isError=!0;Fl(e);return}const d=(r=t==null?void 0:t.atIndex)!=null?r:0;e.suggestionIndex=d<0?u.length-1:d%u.length;const h=u[e.suggestionIndex];if(h!==s){const p=i[i.length-1];p.parent.addChildrenAfter([...h.slice(s.length-h.length)].map(y=>new Pt(y,{isSuggestion:!0})),p),Is(e,{interactive:!0})}am(e,u)}function jf(e){const[t,r]=Zf(e,{before:e.position});if(t===void 0||r===void 0)return!1;let n=!1;return e.getAtoms([t,r]).forEach(i=>{i.isSuggestion&&(i.isSuggestion=!1,n=!0)}),n}function Nl(e,t="accept",r){var n,i;Fl(e);const a=nm(e.model);if(!a)return!1;if(t==="accept-suggestion"||t==="accept-all"){const h=Wc(e.model).filter(p=>p.isSuggestion);if(h.length!==0){for(const p of h)p.isSuggestion=!1;e.model.position=e.model.offsetOf(h[h.length-1])}if(t==="accept-suggestion")return h.length!==0}const u=Wc(e.model).filter(h=>!h.isSuggestion).map(h=>h.value).join(""),d=a.leftSibling;return a.parent.removeChild(a),e.model.position=e.model.offsetOf(d),e.switchMode((n=r==null?void 0:r.mode)!=null?n:"math"),t==="reject"||(Qr.insert(e.model,u,{selectionMode:(i=r==null?void 0:r.selectItem)!=null&&i?"item":"placeholder",format:"latex",mode:"math"}),e.snapshot(),e.model.announce("replacement"),e.switchMode("math")),!0}function Pd(e){var t;let r=document.getElementById(e);return r?r.dataset.refcount=Number(Number.parseInt((t=r.dataset.refcount)!=null?t:"0")+1).toString():(r=document.createElement("div"),r.setAttribute("aria-hidden","true"),r.dataset.refcount="1",r.id=e,document.body.append(r)),r}function nf(e){var t;const r=document.getElementById(e);if(!r)return;const n=Number.parseInt((t=r.getAttribute("data-refcount"))!=null?t:"0");n<=1?r.remove():r.dataset.refcount=Number(n-1).toString()}function im(e,t){const r=new Dr({from:e.context}),n=new _e({mode:"math",type:"root",body:b(t,{context:r})}),i=gl(Pa(new Ue(n.render(r),{classes:"ML__base"}),r));return vl(i,{classes:"ML__latex"}).toMarkup()}function am(e,t){var r;if(t.length===0){Fl(e);return}let n="";for(const[a,s]of t.entries()){const u=s,d=im(e,s),h=Qp(e.keybindings,u).join("
");n+=`${u}${d}`,h&&(n+=`${h}`),n+=""}const i=om(e,``);af()&&((r=i.querySelector(".ML__popover__current"))==null||r.scrollIntoView({block:"nearest",inline:"nearest"})),setTimeout(()=>{var a;i&&!af()&&(i.classList.add("is-visible"),Rd(e),(a=i.querySelector(".ML__popover__current"))==null||a.scrollIntoView({block:"nearest",inline:"nearest"}))},32)}function af(){const e=document.getElementById("mathlive-suggestion-popover");return e?e.classList.contains("is-visible"):!1}function Rd(e,t){var r;if(!e.element||e.element.mathfield!==e||!af())return;if(((r=e.model.at(e.model.position))==null?void 0:r.type)!=="latex"){Fl(e);return}if(t!=null&&t.deferred){setTimeout(()=>Rd(e),32);return}const n=Sl(e.field);if(!n)return;const i=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,a=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,s=window.innerWidth-document.documentElement.clientWidth,u=window.innerHeight-document.documentElement.clientHeight,d=window.mathVirtualKeyboard.boundingRect.height,h=document.getElementById("mathlive-suggestion-popover");n.x+h.offsetWidth/2>a-s?h.style.left=`${a-h.offsetWidth-s}px`:n.x-h.offsetWidth/2<0?h.style.left="0":h.style.left=`${n.x-h.offsetWidth/2}px`;const p=n.y-n.height;i-u-d-n.yn.preventDefault()),r.addEventListener("click",n=>{let i=n.target;for(;i&&!i.dataset.command;)i=i.parentElement;i&&(Nl(e,"reject"),Qr.insert(e.model,i.dataset.command,{selectionMode:"placeholder",format:"latex",mode:"math"}),e.dirty=!0,e.focus())})),r.innerHTML=window.MathfieldElement.createHTML(t),r}function sm(){document.getElementById("mathlive-suggestion-popover")&&(nf("mathlive-suggestion-popover"),pa("suggestion-popover"),pa("core"))}function lm(){const e=String(new Error().stack).replace(/^Error.*\n/,"").split(`
`);if(e.length===0)return console.error(`Can't use relative paths to specify assets location because the sourcefile location could not be determined (unexpected stack trace format "${new Error().stack}").`),"";let t=e[1],r=t.match(/http.*\.ts[\?:]/);return r&&(t=e[2]),r=t.match(/(https?:.*):[0-9]+:[0-9]+/),r||(r=t.match(/at (.*(\.ts))[\?:]/),r||(r=t.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 "${t}").`),"")}var Od=null,Uf,Gf,of=((Gf=(Uf=globalThis==null?void 0:globalThis.document)==null?void 0:Uf.currentScript)==null?void 0:Gf.src)||lm();function qf(e){return rs(this,null,function*(){if(/^(?:[a-z+]+:)?\/\//i.test(e))return new URL(e).href;if(Od===null)try{const t=yield fetch(of,{method:"HEAD"});t.status===200&&(Od=t.url)}catch(t){console.error(`Invalid URL "${e}" (relative to "${of}")`)}return new URL(e,Od!=null?Od:of).href})}function cm(e,t,r={}){return new FontFace(e,`url(${t}.woff2) format('woff2')`,r)}var ra="not-loaded";function um(){return rs(this,null,function*(){return ra="not-loaded",Nd()})}function Nd(){return rs(this,null,function*(){var e;if(ra!=="not-loaded")return;if(ra="loading",(e=getComputedStyle(document.documentElement).getPropertyValue("--ML__static-fonts"))!=null?e:!1){ra="ready";return}if(document.body.classList.remove("ML__fonts-did-not-load"),"fonts"in document){const r=["KaTeX_Main","KaTeX_Math","KaTeX_AMS","KaTeX_Caligraphic","KaTeX_Fraktur","KaTeX_SansSerif","KaTeX_Script","KaTeX_Typewriter","KaTeX_Size1","KaTeX_Size2","KaTeX_Size3","KaTeX_Size4"],n=Array.from(document.fonts).map(s=>s.family);if(r.every(s=>n.includes(s))){ra="ready";return}if(!window.MathfieldElement.fontsDirectory){ra="not-loaded";return}const i=yield qf(window.MathfieldElement.fontsDirectory);if(!i){document.body.classList.add("ML__fonts-did-not-load"),ra="error";return}const a=[["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(s=>cm(s[0].replace(/-[a-zA-Z]+$/,""),`${i}/${s[0]}`,s[1]));try{(yield Promise.all(a.map(u=>{try{return u.load()}catch(d){}}))).forEach(u=>document.fonts.add(u)),ra="ready";return}catch(s){console.error(`MathLive 0.98.5: The math fonts could not be loaded from "${i}"`,{cause:s}),document.body.classList.add("ML__fonts-did-not-load")}ra="error"}})}function dm(e){let t=0;for(let r=0;r{Bo(e)&&e.dirty&&(e.atomBoundsCache=new Map,Is(e,t),e.atomBoundsCache=void 0)})))}function fm(e,t){var r;t=t!=null?t:{};const n=new Dr({from:_(S({},e.context),{atomIdsSettings:{seed:t.forHighlighting?dm(_e.serialize([e.model.root],{expandMacro:!1,defaultMode:e.options.defaultMode})):"random",groupNumbers:(r=t.forHighlighting)!=null?r:!1},letterShapeStyle:e.options.letterShapeStyle}),mathstyle:e.options.defaultMode==="inline-math"?"textstyle":"displaystyle"}),i=e.model.root.render(n);return vl(Pa(i,n),{classes:e.hasEditablePrompts?"ML__latex ML__prompting":"ML__latex",attributes:{translate:"no","aria-hidden":"true"}})}function Xf(e,t){const{model:r}=e;r.root.caret=void 0,r.root.isSelected=!1,r.root.containsCaret=!0;for(const i of r.atoms)i.caret=void 0,i.isSelected=!1,i.containsCaret=!1;if(r.selectionIsCollapsed){const i=r.at(r.position);i.caret=e.model.mode;let a=i.parent;for(;a;)a.containsCaret=!0,a=a.parent}else{const i=r.getAtoms(r.selection,{includeChildren:!0});for(const a of i)a.isSelected=!0}return fm(e,t).toMarkup()}function Is(e,t){if(!Bo(e))return;t!=null||(t={});const r=e.element.querySelector("[part=virtual-keyboard-toggle]");r&&(r.style.display=e.hasEditableContent?"":"none");const n=e.field;if(!n)return;const i=e.isSelectionEditable&&e.hasFocus(),a=n.classList.contains("ML__focused");a&&!i?n.classList.remove("ML__focused"):!a&&i&&n.classList.add("ML__focused");let s=Xf(e,t);const u=e.element.querySelector("[part=menu-toggle]");if(u&&(e.model.atoms.length<=1||e.disabled||e.readOnly&&!e.hasEditableContent||e.userSelect==="none"?u.style.display="none":u.style.display=""),e.model.atoms.length<=1){const d=e.options.contentPlaceholder;d&&(s+=`${Un(d)}`)}n.innerHTML=window.MathfieldElement.createHTML(s),Fd(e,t.interactive),e.dirty=!1}function Fd(e,t){const r=e.field;if(!r)return;for(const u of r.querySelectorAll(".ML__selection, .ML__contains-highlight"))u.remove();!(t!=null&&t)&&ra!=="error"&&ra!=="ready"&&setTimeout(()=>{ra==="ready"?Fd(e):setTimeout(()=>Fd(e),128)},32);const n=e.model,i=r.offsetWidth,a=r.getBoundingClientRect().width;let s=Math.floor(a)/i;if(s=isNaN(s)?1:s,n.selectionIsCollapsed){Rd(e,{deferred:!0});let u=n.at(n.position);for(;u&&u.type!=="prompt"&&!(u.containsCaret&&u.displayContainsHighlight);)u=u.parent;if(u!=null&&u.containsCaret&&u.displayContainsHighlight){const d=fd(e,Es(e,u),s);if(d){d.left/=s,d.right/=s,d.top/=s,d.bottom/=s;const h=document.createElement("div");h.classList.add("ML__contains-highlight"),h.style.position="absolute",h.style.left=`${d.left+1}px`,h.style.top=`${Math.ceil(d.top)}px`,h.style.width=`${Math.ceil(d.right-d.left)}px`,h.style.height=`${Math.ceil(d.bottom-d.top)}px`,r.insertBefore(h,r.childNodes[0])}}return}for(const u of hm(pd(e,{excludeAtomsWithBackground:!0}))){u.left/=s,u.right/=s,u.top/=s,u.bottom/=s;const d=document.createElement("div");d.classList.add("ML__selection"),d.style.position="absolute",d.style.left=`${u.left}px`,d.style.top=`${u.top}px`,d.style.width=`${Math.ceil(u.right-u.left)}px`,d.style.height=`${Math.ceil(u.bottom-u.top-1)}px`,r.insertBefore(d,r.childNodes[0])}}function hm(e){let t=[];for(const r of e){let n=!1;for(const i of t)if(r.left===i.left&&r.right===i.right&&r.top===i.top&&r.bottom===i.bottom){n=!0;break}n||t.push(r)}e=t,t=[];for(const r of e){let n=0;for(const i of e)if(r.left>=i.left&&r.right<=i.right&&r.top>=i.top&&r.bottom<=i.bottom&&(n+=1,n>1))break;n===1&&t.push(r)}return t}var Jf=3,no;function Vi(e,t){t=S({target:"mathfield",canUndo:!1,audioFeedback:void 0,changeContent:!1,changeSelection:!1},t!=null?t:{}),no||(no={});for(const r of Object.keys(e))console.assert(!no[r],"Selector already defined: ",r),no[r]=_(S({},t),{fn:e[r]})}function sf(e){let t;if(Array.isArray(e)){if(e[0]==="performWithFeedback")return sf(e[1]);t=e[0]}else t=e;return t=t.replace(/-\w/g,r=>r[1].toUpperCase()),no[t]}function zl(e){var t;return(t=sf(e))==null?void 0:t.target}function pm(e,t){var r;if(!t)return!1;let n,i=[],a=!1,s=!1;A(t)?(n=t[0],i=t.slice(1)):n=t,n=n.replace(/-\w/g,h=>h[1].toUpperCase());const u=no[n],d=u==null?void 0:u.target;if(d==="model"){if(!e.isSelectionEditable&&(u!=null&&u.changeContent))return e.model.announce("plonk"),!1;/^(delete|add)/.test(n)&&(n!=="deleteBackward"&&e.flushInlineShortcutBuffer(),e.snapshot(n)),/^complete/.test(n)||Td(e),no[n].fn(e.model,...i),Vc(e),s=!0,a=!0}else if(d==="virtual-keyboard")s=(r=window.mathVirtualKeyboard.executeCommand(t))!=null?r:!1,a=!0;else if(no[n]){if(!e.isSelectionEditable&&(u!=null&&u.changeContent))return e.model.announce("plonk"),!1;/^(undo|redo)/.test(n)&&e.flushInlineShortcutBuffer(),s=no[n].fn(e,...i),a=!0}else throw new Error(`Unknown command "${n}"`);return d!=="virtual-keyboard"&&(!e.model.selectionIsCollapsed||u!=null&&u.changeSelection&&t!=="deleteBackward")&&(e.flushInlineShortcutBuffer(),u!=null&&u.changeContent||e.stopCoalescingUndo(),e.defaultStyle={}),s&&xn(e),a}function mm(e,t){var r;if(!e)return!1;e.focus(),jh.keypressVibration&>()&&navigator.vibrate(Jf);const n=sf(t);window.MathfieldElement.playSound((r=n==null?void 0:n.audioFeedback)!=null?r:"keypress");const i=e.executeCommand(t);return e.scrollIntoView(),i}Vi({performWithFeedback:(e,t)=>mm(e,t)});function gm(e){return Vc(e,{atIndex:e.suggestionIndex+1}),!1}function vm(e){return Vc(e,{atIndex:e.suggestionIndex-1}),!1}Vi({complete:Nl},{target:"mathfield",audioFeedback:"return",canUndo:!0,changeContent:!0,changeSelection:!0}),Vi({nextSuggestion:gm,previousSuggestion:vm},{target:"mathfield",audioFeedback:"keypress",changeSelection:!0});var zd="mathlive#virtual-keyboard-message";function lf(e){var t;return e.type!=="message"?!1:((t=e.data)==null?void 0:t.type)===zd}var bm=class Ap{constructor(){this.targetOrigin=window.origin,this.originValidator="none",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 Ap),this._singleton}set alphabeticLayout(t){this.sendMessage("update-setting",{alphabeticLayout:t})}set layouts(t){this.sendMessage("update-setting",{layouts:t})}get normalizedLayouts(){return[]}set editToolbar(t){this.sendMessage("update-setting",{editToolbar:t})}set actionKeycap(t){this.sendMessage("update-setting",{actionKeycap:t})}set shiftKeycap(t){this.sendMessage("update-setting",{shiftKeycap:t})}set backspaceKeycap(t){this.sendMessage("update-setting",{backspaceKeycap:t})}set tabKeycap(t){this.sendMessage("update-setting",{tabKeycap:t})}set container(t){throw new Error("Container inside an iframe cannot be changed")}show(t){this.sendMessage("show",t)}hide(t){this.sendMessage("hide",t)}get isShifted(){return this._isShifted}get visible(){return this._boundingRect.height>0}set visible(t){t?this.show():this.hide()}get boundingRect(){return this._boundingRect}executeCommand(t){return this.sendMessage("execute-command",{command:t}),!0}updateToolbar(t){this.sendMessage("update-toolbar",t)}update(t){this.sendMessage("update-setting",t)}connect(){this.sendMessage("connect")}disconnect(){this.sendMessage("disconnect")}addEventListener(t,r,n){this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].has(r)||this.listeners[t].add(r)}dispatchEvent(t){return!this.listeners[t.type]||this.listeners[t.type].size===0?!0:(this.listeners[t.type].forEach(r=>{typeof r=="function"?r(t):r==null||r.handleEvent(t)}),!t.defaultPrevented)}removeEventListener(t,r,n){this.listeners[t]&&this.listeners[t].delete(r)}handleEvent(t){if(lf(t)){if(!Tc(t.origin,this.originValidator))throw new DOMException(`Message from unknown origin (${t.origin}) cannot be handled`,"SecurityError");this.handleMessage(t.data)}}handleMessage(t){const{action:r}=t;if(r==="execute-command"){const{command:n}=t;zl(n)==="virtual-keyboard"&&this.executeCommand(n);return}if(r==="synchronize-proxy"){this._boundingRect=t.boundingRect,this._isShifted=t.isShifted;return}if(r==="geometry-changed"){this._boundingRect=t.boundingRect,this.dispatchEvent(new Event("geometrychange"));return}}sendMessage(t,r={}){if(!window.top)throw new DOMException("A frame does not have access to the top window and can\u2018t communicate with the keyboard. Review virtualKeyboardTargetOrigin and originValidator on mathfields embedded in an iframe","SecurityError");window.top.postMessage(S({type:zd,action:t},r),this.targetOrigin)}},Yf={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"]},{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:"\u2264"}},{label:">",latex:">",class:"hide-shift",shift:{latex:"\\ge",label:"\u2265"}},"[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:"[action]",width:1}]]},greek:{label:"αβγ",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.greek",rows:[[{label:"φ",class:"MLK__tex hide-shift",insert:"\\varphi",aside:"phi var.",shift:"\\Phi"},{label:"ς",class:"MLK__tex hide-shift",insert:"\\varsigma",aside:"sigma var.",shift:"\\Sigma"},{label:"ϵ",class:"MLK__tex hide-shift",insert:"\\epsilon",aside:"espilon",shift:'\\char"0190'},{label:"ρ",class:"MLK__tex hide-shift",insert:"\\rho",aside:"rho",shift:'\\char"3A1'},{label:"τ",class:"MLK__tex hide-shift",insert:"\\tau",aside:"tau",shift:'\\char"3A4'},{label:"υ",class:"MLK__tex hide-shift",insert:"\\upsilon",aside:"upsilon",shift:"\\Upsilon"},{label:"θ",class:"MLK__tex hide-shift",insert:"\\theta",aside:"theta",shift:"\\Theta"},{label:"ι",class:"MLK__tex hide-shift",insert:"\\iota",aside:"iota",shift:'\\char"399'},{label:"ο",class:"MLK__tex hide-shift",insert:"\\omicron",aside:"omicron",shift:'\\char"39F'},{label:"π",class:"MLK__tex hide-shift",insert:"\\pi",aside:"pi",shift:"\\Pi"}],["[separator-5]",{label:"α",class:"MLK__tex hide-shift",insert:"\\alpha",aside:"alpha",shift:'\\char"391'},{label:"σ",class:"MLK__tex hide-shift",insert:"\\sigma",aside:"sigma",shift:"\\Sigma"},{label:"δ",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:"γ",class:"MLK__tex hide-shift",insert:"\\gamma",aside:"gamma",shift:"\\Gamma"},{label:"η",class:"MLK__tex hide-shift",insert:"\\eta",aside:"eta",shift:'\\char"397'},{label:"ξ",class:"MLK__tex hide-shift",insert:"\\xi",aside:"xi",shift:"\\Xi"},{label:"κ",class:"MLK__tex hide-shift",insert:"\\kappa",aside:"kappa",shift:"\\Kappa"},{label:"λ",class:"MLK__tex hide-shift",insert:"\\lambda",aside:"lambda",shift:"\\Lambda"},"[separator-5]"],["[shift]",{label:"ζ",class:"MLK__tex hide-shift",insert:"\\zeta",aside:"zeta",shift:'\\char"396'},{label:"χ",class:"MLK__tex hide-shift",insert:"\\chi",aside:"chi",shift:'\\char"3A7'},{label:"ψ",class:"MLK__tex hide-shift",insert:"\\psi",aside:"zeta",shift:"\\Psi"},{label:"ω",class:"MLK__tex hide-shift",insert:"\\omega",aside:"omega",shift:"\\Omega"},{label:"β",class:"MLK__tex hide-shift",insert:"\\beta",aside:"beta",shift:'\\char"392'},{label:"ν",class:"MLK__tex hide-shift",insert:"\\nu",aside:"nu",shift:'\\char"39D'},{label:"μ",class:"MLK__tex hide-shift",insert:"\\mu",aside:"mu",shift:'\\char"39C'},"[backspace]"],["[separator]",{label:"ε",class:"MLK__tex",insert:"\\varepsilon",aside:"espilon var."},{label:"ϑ",class:"MLK__tex",insert:"\\vartheta",aside:"theta var."},{label:"ϰ",class:"MLK__tex",insert:"\\varkappa",aside:"kappa var."},{label:"ϖ",class:"MLK__tex",insert:"\\varpi",aside:"pi var."},{label:"ϱ",class:"MLK__tex",insert:"\\varrho",aside:"rho var."},"[left]","[right]","[action]"]]},symbols:{label:"∞\u2260\u2208",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:"\\arsinh"}]},"\\ln",{latex:"\\mathrm{abs}",insert:"\\mathrm{abs}\\left(#0\\right)"},{latex:"\\rarr",shift:"\\rArr",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",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:"\\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",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:"\\artanh"},{class:"small",latex:"\\arctan"},{class:"small",latex:"\\arctg"},{class:"small",latex:"\\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:"[action]",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:`
.minimalist-backdrop {
display: flex;
justify-content: center;
}
.minimalist-container {
--keycap-height: 40px;
--keycap-max-width: 53px;
--keycap-small-font-size: 12px;
background: var(--keyboard-background);
padding: 20px;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
border: 1px solid var(--keyboard-border);
box-shadow: 0 0 32px rgb(0 0 0 / 30%);
}
`,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]"]]}},Kd={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"},"\xE0","\xE1","\xE2","\xE4","\xE6"],b:[{latex:"\\beth",aside:"beth"}],c:[{latex:"\\C",aside:"set of complex numbers"},"\xE7"],d:[{latex:"\\daleth",aside:"daleth"}],e:[{latex:"\\exponentialE",aside:"exponential e"},{latex:"\\exists",aside:"there is"},{latex:"\\nexists",aside:"there isn\u2019t"},"\xE8","\xE9","\xEA","\xEB"],g:[{latex:"\\gimel",aside:"gimel"}],h:[{latex:"\\hbar",aside:"h bar"},{latex:"\\hslash",aside:"h slash"}],i:[{latex:"\\imaginaryI",aside:"imaginary i"},"\xEC","\xED","\xEE","\xEF"],j:[{latex:"\\imaginaryJ",aside:"imaginary j"}],l:[{latex:"\\ell",aside:"ell"}],n:[{latex:"\\mathbb{N}",aside:"set of natural numbers"},"\xF1"],o:["\xF8","\u0153","\xF2","\xF3","\xF4","\xF6","\u0153"],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:["\xF9","\xFA","\xFB","\xFC"],z:[{latex:"\\mathbb{Z}",aside:"set of integers"}],y:["\xFD","\xFF"],space:[{latex:'\\char"203A\\!\\char"2039',insert:"\\!",aside:"negative thin space
\u207B\xB3\u29F8\u2081\u2088 em"},{latex:'\\char"203A\\,\\char"2039',insert:"\\,",aside:"thin space
\xB3\u29F8\u2081\u2088 em"},{latex:'\\char"203A\\:\\char"2039',insert:"\\:",aside:"medium space
\u2074\u29F8\u2081\u2088 em"},{latex:'\\char"203A\\;\\char"2039',insert:"\\;",aside:"thick space
\u2075\u29F8\u2081\u2088 em"},{latex:'\\char"203A\\ \\char"2039',insert:"\\ ",aside:"\u2153 em"},{latex:'\\char"203A\\enspace\\char"2039',insert:"\\enspace",aside:"\xBD em"},{latex:'\\char"203A\\quad\\char"2039',insert:"\\quad",aside:"1 em"},{latex:'\\char"203A\\qquad\\char"2039',insert:"\\qquad",aside:"2 em"}]},Zc;function Qf(e,t){var r,n,i;const a=Yo.singleton;if(!a)return;const s=Kl(e),u=(n=(r=a.getKeycap(s==null?void 0:s.id))==null?void 0:r.variants)!=null?n:"";if(typeof u=="string"&&!eh(u)||Array.isArray(u)&&u.length===0){t==null||t();return}const d={};let h="";for(const se of xm(u)){const Ze=rh(se),ee=Date.now().toString(36).slice(-2)+Math.floor(Math.random()*1e5).toString(36);d[ee]=Ze;const[De,Je]=Hd(Ze);h+=`${De}
`}const p=document.createElement("div");p.setAttribute("aria-hidden","true"),p.className="MLK__variant-panel",p.style.height="auto";const y=Object.keys(d).length;let M=5;y===1?M=1:y===2||y===4?M=2:y===3||y===5||y===6?M=3:y>=7&&y<14&&(M=4),p.style.width=`calc(var(--variant-keycap-length) * ${M} + 12px)`,p.innerHTML=jh.createHTML(h),ro.open({root:(i=a==null?void 0:a.container)==null?void 0:i.querySelector(".ML__keyboard"),child:p}),Zc=new AbortController;const{signal:I}=Zc,$=e==null?void 0:e.getBoundingClientRect();if($){$.top-p.clientHeight<0&&(p.style.width="auto",y<=6?p.style.height="56px":y<=12?p.style.height="108px":y<=18?p.style.height="205px":p.classList.add("compact"));const se=Math.max(0,Math.min(window.innerWidth-p.offsetWidth,($.left+$.right-p.offsetWidth)/2)),Ze=$.top-p.clientHeight+5;p.style.transform=`translate(${se}px, ${Ze}px)`,p.classList.add("is-visible"),requestAnimationFrame(()=>{p.addEventListener("pointerup",ee=>{const De=Kl(ee.target);!(De!=null&&De.id)||!d[De.id]||(cf(d[De.id]),jc(),t==null||t(),ee.preventDefault())},{capture:!0,passive:!1,signal:I}),p.addEventListener("pointerenter",ee=>{const De=Kl(ee.target);!(De!=null&&De.id)||!d[De.id]||De.classList.add("is-active")},{capture:!0,signal:I}),p.addEventListener("pointerleave",ee=>{const De=Kl(ee.target);!(De!=null&&De.id)||!d[De.id]||De.classList.remove("is-active")},{capture:!0,signal:I}),window.addEventListener("pointercancel",()=>{jc(),t==null||t()},{signal:I}),window.addEventListener("pointerup",()=>{jc(),t==null||t()},{signal:I})})}}function jc(){Zc==null||Zc.abort(),Zc=null,ro.state==="open"&&ro.close()}function ym(e){if(e==="foreground-color"){const t=[];for(const r of Object.keys(te))t.push({class:"swatch-button",label:'',command:["applyStyle",{color:r}]});return t}if(e==="background-color"){const t=[];for(const r of Object.keys(Y))t.push({class:"swatch-button",label:'',command:["applyStyle",{backgroundColor:r}]});return t}}function eh(e){return Kd[e]!==void 0}function xm(e){var t;return typeof e!="string"?e:(Kd[e]||(Kd[e]=(t=ym(e))!=null?t:[]),Kd[e])}function wm(e){return typeof e=="string"?e:Object.entries(e).map(([t,r])=>`${t}:${r} !important`).join(";")}function Sm(e){return Object.keys(e).map(t=>`${t} {${wm(e[t])}}`).join("")}function Uc(e){if(!e)return"";const t=new Dr,r=new _e({mode:"math",type:"root",body:b(e,{context:t,args:i=>i==="@"?"{\\class{ML__box-placeholder}{\\blacksquare}}":"\\placeholder{}"})}),n=gl(Pa(new Ue(r.render(t),{classes:"ML__base"}),t));return vl(n,{classes:"ML__latex"}).toMarkup()}function Gc(e){var t;if(Array.isArray(e))return e.map(n=>Gc(n)).flat();const r=typeof e=="string"?{markup:e}:e;return"rows"in r&&Array.isArray(r.rows)&&(r.rows=r.rows.map(n=>n.map(i=>rh(i)))),(t=r.id)!=null||(r.id="ML__layer_"+Date.now().toString(36).slice(-2)+Math.floor(Math.random()*1e5).toString(36)),[r]}function _m(){var e,t;let n=window.mathVirtualKeyboard.alphabeticLayout;if(n==="auto"){const u=Hc();u&&(n=u.virtualLayout),(!n||n==="auto")&&(n=(e={fr:"azerty",be:"azerty",al:"qwertz",ba:"qwertz",cz:"qwertz",de:"qwertz",hu:"qwertz",sk:"qwertz",ch:"qwertz"}[Ce.locale.slice(0,2)])!=null?e:"qwerty")}const i={qwerty:["qwertyuiop"," asdfghjkl ","^zxcvbnm~"],azerty:["azertyuiop","qsdfghjklm","^ wxcvbn ~"],qwertz:["qwertzuiop"," asdfghjkl ","^yxcvbnm~"],dvorak:["^ pyfgcrl ","aoeuidhtns","qjkxbmwvz~"],colemak:[" qwfpgjluy ","arstdhneio","^zxcvbkm~"]},a=(t=i[n])!=null?t:i.qwerty,s=n==="azerty"?[[{label:"1",variants:"1"},{label:"2",shift:{latex:"\xE9"},variants:"2"},{label:"3",shift:{latex:"\xF9"},variants:"3"},{label:"4",variants:"4"},{label:"5",shift:{label:"(",latex:"("},variants:"5"},{label:"6",shift:{label:")",latex:")"},variants:"6"},{label:"7",shift:{latex:"\xE8"},variants:"7"},{label:"8",shift:{latex:"\xEA"},variants:"8"},{label:"9",shift:{latex:"\xE7"},variants:"9"},{label:"0",shift:{latex:"\xE0"},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(const u of a){const d=[];for(const h of u)/[a-z]/.test(h)?d.push({label:h,class:"hide-shift",shift:{label:h.toUpperCase()},variants:eh(h)?h:void 0}):h==="~"?n!=="dvorak"?d.push("[backspace]"):d.push({label:"[backspace]",width:1}):h==="^"?d.push("[shift]"):h===" "&&d.push("[separator-5]");s.push(d)}return s.push(["[-]","[+]","[=]",{label:" ",width:1.5},{label:",",shift:";",variants:".",class:"hide-shift"},"[.]","[left]","[right]",{label:"[action]",width:1.5}]),{label:"abc",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.alphabetic",layers:Gc({rows:s})}}function th(e){if(e==="alphabetic")return _m();if(typeof e=="string")return console.assert(Yf[e]!==void 0,`MathLive 0.98.5: unknown keyboard layout "${e}"`),th(Yf[e]);let t;if("rows"in e&&Array.isArray(e.rows)){console.assert(!("layers"in e||"markup"in e),'MathLive 0.98.5: when providing a "rows" property, "layers" and "markup" are ignored');const i=e,{rows:a}=i,s=je(i,["rows"]);t=_(S({},s),{layers:Gc({rows:e.rows})})}else if("markup"in e&&typeof e.markup=="string"){const i=e,{markup:a}=i,s=je(i,["markup"]);t=_(S({},s),{layers:Gc(e.markup)})}else t=S({},e),"layers"in e?t.layers=Gc(e.layers):console.error('MathLive 0.98.5: provide either a "rows", "markup" or "layers" property');let r=!1,n=!1;for(const i of t.layers)if(i.rows)for(const a of i.rows.flat()){Hl(a)&&(r=!0);const s=a.command;typeof s=="string"&&["undo","redo","cut","copy","paste"].includes(s)&&(n=!0)}return(!("displayShiftedKeycaps"in e)||e.displayShiftedKeycaps===void 0)&&(t.displayShiftedKeycaps=r),(!("displayEditToolbar"in e)||e.displayEditToolbar===void 0)&&(t.displayEditToolbar=!n),t}function Mm(e,t){var r,n;let i='';if(e.normalizedLayouts.length>1)for(const[a,s]of e.normalizedLayouts.entries()){const u=s,d=[a===t?"selected":"layer-switch"];u.tooltip&&d.push("MLK__tooltip"),u.labelClass&&d.push(...u.labelClass.split(" ")),i+=`
${(n=u.label)!=null?n:"untitled"}
`}return i+="
",i}function Cm(e,t){let r="";if(e.editToolbar==="none")return"";const i=[];t.selectionIsCollapsed?i.push("undo","redo","pasteFromClipboard"):i.push("cutToClipboard","copyToClipboard","pasteFromClipboard");const a={undo:`
`,redo:`
`,cutToClipboard:`
`,copyToClipboard:`
`,pasteFromClipboard:`
`};return r+=i.map(s=>a[s]).join(""),r}function Em(e){for(const t of e)km(t)}function km(e){const t=Yo.singleton;if(!t)return;const 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(n){}e.id=t.registerKeycap(r)}if(!e.innerHTML){const[n,i]=Hd(r);e.innerHTML=window.MathfieldElement.createHTML(n)}}function Dm(){Yi("virtual-keyboard"),Yi("core"),Nd()}function Am(){pa("core"),pa("virtual-keyboard")}var Lm=``;function Bm(e){e.resetKeycapRegistry(),Dm();const t=document.createElement("div");t.className="ML__keyboard";const r=document.createElement("div");r.className="MLK__plate",r.innerHTML=window.MathfieldElement.createHTML(Lm+e.normalizedLayouts.map((s,u)=>Im(e,s,u)).join(""));const n=document.createElement("div");n.className="MLK__backdrop",n.appendChild(r),t.appendChild(n),t.addEventListener("pointerdown",Tm,{passive:!1});const i=t.querySelectorAll(".ML__edit-toolbar");if(i)for(const s of i)s.addEventListener("click",u=>{var d,h;let p=u.target,y="";for(;p&&!y;)y=(d=p==null?void 0:p.getAttribute("data-command"))!=null?d:"",p=(h=p==null?void 0:p.parentElement)!=null?h:null;y&&e.executeCommand(JSON.parse(y))});Em(t.querySelectorAll(".MLK__keycap, .action, .fnbutton, .bigfnbutton"));const a=t.querySelectorAll(".MLK__layer");console.assert(a.length>0,"No virtual keyboards available");for(const s of a)s.addEventListener("pointerdown",u=>u.preventDefault());return e.currentLayer=e.latentLayer,t}function Im(e,t,r){const n=[];if(!("layers"in t))return"";for(const i of t.layers)n.push(``),(e.normalizedLayouts.length>1||t.displayEditToolbar)&&(n.push("
")),n.push($m(e,i)),n.push("
");return n.join("")}function $m(e,t){if(typeof t=="string")return t;let r="";if(typeof t.style=="string"?r+=``:typeof t.style=="object"&&(r+=``),t.backdrop&&(r+=``),t.container&&(r+=`
`),t.rows){r+="
";for(const n of t.rows){r+="
";for(const i of n)if(i){const a=e.registerKeycap(i),[s,u]=Hd(i);/(^|\s)separator/.test(u)?r+=`
${s}
`}r+="
"}r+="
"}else t.markup&&(r+=t.markup);return t.container&&(r+="
"),t.backdrop&&(r+="
"),r}function Hd(e,t={shifted:!1}){var r,n,i,a,s,u,d;let h="",p=(r=e.class)!=null?r:"";if(t.shifted&&Hl(e)&&(p+=" is-active"),t.shifted&&"shift"in e)typeof e.shift=="string"?h=Uc(e.shift):typeof e.shift=="object"&&(h=e.shift.label?e.shift.label:(n=Uc(e.shift.latex||e.shift.insert||"")||e.shift.key)!=null?n:""),typeof e.shift=="object"&&(p=(a=(i=e.shift.class)!=null?i:e.class)!=null?a:"");else{if(h=e.label?e.label:(s=Uc(e.latex||e.insert||"")||e.key)!=null?s:"",e.shift){let y;typeof e.shift=="string"?y=Uc(e.shift):e.shift.label?y=e.shift.label:y=(u=Uc(e.shift.latex||e.shift.insert||"")||e.shift.key)!=null?u:"",h+=`${y}`}e.aside&&(h+=``)}return e.layer&&!/layer-switch/.test(p)&&(p+=" layer-switch"),/(^|\s)(separator|action|shift|fnbutton|bigfnbutton)($|\s)/.test(p)||(p+=" MLK__keycap"),!/\bw[0-9]+\b/.test(p)&&e.width&&(p+=(d={0:" w0",.5:" w5",1.5:" w15",2:" w20",5:" w50"}[e.width])!=null?d:""),[h,p||"MLK__keycap"]}var $s={"[left]":{class:"action hide-shift",label:"",command:["performWithFeedback","moveToPreviousChar"],shift:{label:"",command:["performWithFeedback","extendSelectionBackward"]}},"[right]":{class:"action hide-shift",label:"",command:["performWithFeedback","moveToNextChar"],shift:{label:"",command:["performWithFeedback","extendSelectionForward"]}},"[up]":{class:"action hide-shift",label:"\u2191",command:["performWithFeedback","moveUp"],shift:{label:"\u219F",command:["performWithFeedback","extendSelectionUpward"]}},"[down]":{class:"action hide-shift",label:"\u2193",command:["performWithFeedback","moveDown"],shift:{label:"\u21A1",command:["performWithFeedback","extendSelectionDownward"]}},"[return]":{class:"action hide-shift",command:["performWithFeedback","commit"],shift:{command:["performWithFeedback","addRowAfter"]},width:1.5,label:""},"[action]":{class:"action hide-shift",command:["performWithFeedback","commit"],shift:{label:"",command:["performWithFeedback","addRowAfter"]},width:1.5,label:""},"[hr]":{class:"separator horizontal-rule"},"[hide-keyboard]":{class:"action",command:["hideVirtualKeyboard"],width:1.5,label:""},"[.]":{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:"\u2260",latex:"\\ne"},class:"big-op hide-shift"},"[backspace]":{class:"action bottom right hide-shift",width:1.5,command:["performWithFeedback","deleteBackward"],label:"",shift:{class:"action warning",label:"",command:"deleteAll"}},"[undo]":{class:"ghost if-can-undo",command:"undo",label:"",tooltip:"tooltip.undo"},"[redo]":{class:"ghost if-can-redo",command:"redo",label:"",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:""},"[foreground-color]":{variants:"foreground-color",command:["applyStyle",{color:"red"}],label:""},"[background-color]":{variants:"background-color",command:["applyStyle",{backgroundColor:"yellow"}],label:""}};function rh(e){var t;if(typeof e=="string"){if(e==="[.]"&&window.MathfieldElement.decimalSeparator===","&&(e="[,]"),!$s[e])return{latex:e};e={label:e}}let r;return"label"in e&&e.label&&$s[e.label]&&(r=_(S(S({},$s[e.label]),e),{label:$s[e.label].label})),"key"in e&&e.key&&$s[e.key]&&(r=_(S(S({},$s[e.key]),e),{key:$s[e.key].key})),r?(r.command==="insertDecimalSeparator"&&(r.label=(t=window.MathfieldElement.decimalSeparator)!=null?t:"."),e.label==="[action]"&&(r=S(S({},r),window.mathVirtualKeyboard.actionKeycap)),e.label==="[shift]"&&(r=S(S({},r),window.mathVirtualKeyboard.shiftKeycap)),e.label==="[backspace]"&&(r=S(S({},r),window.mathVirtualKeyboard.backspaceKeycap)),e.label==="[tab]"&&(r=S(S({},r),window.mathVirtualKeyboard.tabKeycap)),r):e}var qc;function Tm(e){var t;if(e.button!==0)return;const r=Yo.singleton;if(!r)return;let n=e.target;for(;n&&!n.getAttribute("data-layer");)n=n.parentElement;if(n){r.currentLayer=(t=n.getAttribute("data-layer"))!=null?t:"",e.preventDefault();return}const i=Kl(e.target);if(!(i!=null&&i.id))return;const a=r.getKeycap(i.id);if(!a)return;console.assert(e.type==="pointerdown");const s=new AbortController,u=s.signal;i.classList.add("is-pressed"),i.addEventListener("pointerenter",Wd(s),{capture:!0,signal:u}),i.addEventListener("pointerleave",Wd(s),{capture:!0,signal:u}),i.addEventListener("pointercancel",Wd(s),{signal:u}),i.addEventListener("pointerup",Wd(s),{signal:u}),Hl(a)&&(i.classList.add("is-active"),r.shiftPressCount++),a.variants&&(qc&&clearTimeout(qc),qc=setTimeout(()=>{i.classList.contains("is-pressed")&&(i.classList.remove("is-pressed"),i.classList.add("is-active"),e.target&&"releasePointerCapture"in e.target&&e.target.releasePointerCapture(e.pointerId),Qf(i,()=>{s.abort(),i==null||i.classList.remove("is-active")}))},300)),e.preventDefault()}function Wd(e){return t=>{const r=Kl(t.target);if(!(r!=null&&r.id))return;const n=Yo.singleton;if(!n)return;const i=n.getKeycap(r.id);if(i){if(t.type==="pointerenter"&&t.target===r&&t.isPrimary&&r.classList.add("is-pressed"),t.type==="pointercancel"){r.classList.remove("is-pressed"),Hl(i)&&(n.shiftPressCount--,r.classList.toggle("is-active",n.isShifted)),e.abort();return}if(t.type==="pointerleave"&&t.target===r){r.classList.remove("is-pressed"),Hl(i)&&(n.shiftPressCount--,r.classList.toggle("is-active",n.isShifted));return}if(t.type==="pointerup"){qc&&clearTimeout(qc),Hl(i)?r.classList.toggle("is-active",n.isShifted):r.classList.contains("is-pressed")&&(r.classList.remove("is-pressed"),n.isShifted&&i.shift?typeof i.shift=="string"?n.executeCommand(["insert",i.shift,{focus:!0,feedback:!0,scrollIntoView:!0,mode:"math",format:"latex"}]):cf(i.shift):cf(i),n.shiftPressCount===1&&!t.shiftKey&&(n.shiftPressCount=0)),e.abort(),t.preventDefault();return}}}}function cf(e){var t;let r=e.command;!r&&e.insert&&(r=["insert",e.insert,{focus:!0,feedback:!0,scrollIntoView:!0,mode:"math",format:"latex"}]),!r&&e.key&&(r=["typedText",e.key,{focus:!0,feedback:!0,simulateKeystroke:!0}]),!r&&e.latex&&(r=["insert",e.latex,{focus:!0,feedback:!0,scrollIntoView:!0,mode:"math",format:"latex"}]),r||(r=["typedText",e.label,{focus:!0,feedback:!0,simulateKeystroke:!0}]),(t=Yo.singleton)==null||t.executeCommand(r)}function Pm(e){if(e.nodeType!==1)return!1;const t=e.classList;return t.contains("MLK__keycap")||t.contains("shift")||t.contains("action")||t.contains("fnbutton")||t.contains("bigfnbutton")}function Kl(e){if(!e)return;let t=e;for(;t&&!Pm(t);)t=t.parentElement;return t!=null?t:void 0}function Hl(e){return!!e.class&&/(^|\s)shift($|\s)/.test(e.class)}var Yo=class Lp{constructor(){this.originalContainerBottomPadding=null,this.keycapRegistry={},this._shiftPressCount=0;var t,r,n;this.targetOrigin=window.origin,this.originValidator="none",this._alphabeticLayout="auto",this._layouts=Object.freeze(["default"]),this._editToolbar="default",this._container=(r=(t=window.document)==null?void 0:t.body)!=null?r:null,this._visible=!1,this._rebuilding=!1,this.observer=new ResizeObserver(i=>{this.adjustBoundingRect(),this.dispatchEvent(new Event("geometrychange")),this.sendMessage("geometry-changed",{boundingRect:this.boundingRect})}),this.listeners={};try{(n=window.top)==null||n.addEventListener("message",this)}catch(i){window.addEventListener("message",this)}document.body.addEventListener("focusin",i=>{const a=i.target;a!=null&&a.isConnected&&setTimeout(()=>{const s=nh();s&&!s.readOnly&&s.mathVirtualKeyboardPolicy==="auto"&&mt()&&this.show({animate:!0})},300)}),document.addEventListener("focusout",i=>{i.target.mathVirtualKeyboardPolicy!=="manual"&&setTimeout(()=>{nh()||this.hide()},300)})}get currentLayer(){var t,r,n;return(n=(r=(t=this._element)==null?void 0:t.querySelector(".MLK__layer.is-visible"))==null?void 0:r.id)!=null?n:""}set currentLayer(t){var r;if(!this._element){this.latentLayer=t;return}let n=t?this._element.querySelector(`#${t}.MLK__layer`):null;n||(n=this._element.querySelector(".MLK__layer")),n&&((r=this._element.querySelector(".MLK__layer.is-visible"))==null||r.classList.remove("is-visible"),n.classList.add("is-visible")),this.render()}get shiftPressCount(){return this._shiftPressCount}set shiftPressCount(t){var r;this._shiftPressCount=t>2||t<0?0:t,(r=this._element)==null||r.classList.toggle("is-caps-lock",this.shiftPressCount===2),this.render()}get isShifted(){return this._shiftPressCount>0}resetKeycapRegistry(){this.keycapRegistry={}}registerKeycap(t){const r="ML__k"+Date.now().toString(36).slice(-2)+Math.floor(Math.random()*1e5).toString(36);return this.keycapRegistry[r]=t,r}getKeycap(t){return t?this.keycapRegistry[t]:void 0}getLayer(t){const r=this.normalizedLayouts;for(const n of r)for(const i of n.layers)if(i.id===t)return i}get alphabeticLayout(){return this._alphabeticLayout}set alphabeticLayout(t){this._alphabeticLayout=t,this.rebuild()}get actionKeycap(){return this._actionKeycap}set actionKeycap(t){this._actionKeycap=typeof t=="string"?{label:t}:t}get shiftKeycap(){return this._shiftKeycap}set shiftKeycap(t){this._shiftKeycap=typeof t=="string"?{label:t}:t}get backspaceKeycap(){return this._backspaceKeycap}set backspaceKeycap(t){this._backspaceKeycap=typeof t=="string"?{label:t}:t}get tabKeycap(){return this._tabKeycap}set tabKeycap(t){this._tabKeycap=typeof t=="string"?{label:t}:t}get layouts(){return this._layouts}set layouts(t){this.updateNormalizedLayouts(t),this.rebuild()}updateNormalizedLayouts(t){const r=Array.isArray(t)?[...t]:[t],n=r.findIndex(i=>i==="default");n>=0&&r.splice(n,1,"numeric","symbols","alphabetic","greek"),this._layouts=Object.freeze(r),this._normalizedLayouts=r.map(i=>th(i))}get normalizedLayouts(){return this._normalizedLayouts||this.updateNormalizedLayouts(this._layouts),this._normalizedLayouts}get editToolbar(){return this._editToolbar}set editToolbar(t){this._editToolbar=t,this.rebuild()}get container(){return this._container}set container(t){this._container=t,this.rebuild()}static get singleton(){if(this._singleton===void 0)try{this._singleton=new Lp}catch(t){this._singleton=null}return this._singleton}get style(){return this._style}addEventListener(t,r,n){this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].has(r)||this.listeners[t].add(r)}dispatchEvent(t){return!this.listeners[t.type]||this.listeners[t.type].size===0?!0:(this.listeners[t.type].forEach(r=>{typeof r=="function"?r(t):r==null||r.handleEvent(t)}),!t.defaultPrevented)}removeEventListener(t,r,n){this.listeners[t]&&this.listeners[t].delete(r)}get element(){return this._element}set element(t){var r;this._element!==t&&((r=this._element)==null||r.remove(),this._element=t)}get visible(){return this._visible}set visible(t){t?this.show():this.hide()}get boundingRect(){var t;if(!this._visible)return new DOMRect;const r=(t=this._element)==null?void 0:t.getElementsByClassName("MLK__plate")[0];return r?r.getBoundingClientRect():new DOMRect}adjustBoundingRect(){var t,r;const n=this.boundingRect.height;if(this.container===document.body){(t=this._element)==null||t.style.setProperty("--_keyboard-height",`calc(${n}px + var(--_padding-top) + var(--_padding-bottom) + env(safe-area-inset-bottom, 0))`);const i=n-1;this.container.style.paddingBottom=this.originalContainerBottomPadding?`calc(${this.originalContainerBottomPadding} + ${i}px)`:`${i}px`}else(r=this._element)==null||r.style.setProperty("--_keyboard-height",`${n}px`)}rebuild(){if(this._rebuilding||!this._element)return;this._rebuilding=!0;const t=this.currentLayer;requestAnimationFrame(()=>{this._rebuilding=!1,this._element&&(this._element.remove(),this._element=void 0),this.visible&&(this.buildAndAttachElement(),this.currentLayer=t,this.render(),this.adjustBoundingRect(),this._element.classList.add("is-visible"))})}render(){if(!this._element)return;const t=this.getLayer(this.currentLayer);this._element.classList.toggle("backdrop-is-transparent",!!(t&&(t.backdrop||t.container)));const 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)for(const n of r){const i=this.getKeycap(n.id);if(i){const[a,s]=Hd(i,{shifted:this.isShifted});n.innerHTML=window.MathfieldElement.createHTML(a),n.className=s}}}show(t){var r;if(this._visible)return;const n=this.container;if(n&&window.mathVirtualKeyboard&&this.stateWillChange(!0)){if(this._element||(this.buildAndAttachElement(),this.adjustBoundingRect()),!this._visible){const i=this._element.getElementsByClassName("MLK__plate")[0];if(i&&this.observer.observe(i),n===window.document.body){const a=n.style.paddingBottom;this.originalContainerBottomPadding=a;const s=i.offsetHeight-1;n.style.paddingBottom=a?`calc(${a} + ${s}px)`:`${s}px`}window.addEventListener("mouseup",this),window.addEventListener("blur",this),window.addEventListener("keydown",this,{capture:!0}),window.addEventListener("keyup",this,{capture:!0}),(r=this._element)==null||r.classList.toggle("is-caps-lock",this.shiftPressCount===2),this.currentLayer=this.latentLayer}this._visible=!0,t!=null&&t.animate?requestAnimationFrame(()=>{this._element&&(this._element.classList.add("animate"),this._element.addEventListener("transitionend",()=>{var i;return(i=this._element)==null?void 0:i.classList.remove("animate")},{once:!0}),this._element.classList.add("is-visible"),this.stateChanged())}):(this._element.classList.add("is-visible"),this.stateChanged())}}hide(t){var r;const n=this.container;if(n&&this._visible&&this.stateWillChange(!1)){if(this._visible=!1,this._element){this.latentLayer=this.currentLayer;const i=this._element.getElementsByClassName("MLK__plate")[0];i&&this.observer.unobserve(i),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}),jc(),Am(),(r=this._element)==null||r.remove(),this._element=void 0,this.originalContainerBottomPadding!==null&&(n.style.paddingBottom=this.originalContainerBottomPadding)}this.stateChanged()}}get height(){var t,r;return(r=(t=this.element)==null?void 0:t.offsetHeight)!=null?r:0}buildAndAttachElement(){var t;console.assert(!this.element),this.element=Bm(this),window.addEventListener("contextmenu",this,{capture:!0}),this.element.addEventListener("contextmenu",r=>{r.shiftKey||((r.ctrlKey||r.button===2)&&Qf(r.target),r.preventDefault(),r.stopPropagation())},{capture:!0}),(t=this.container)==null||t.appendChild(this.element)}handleEvent(t){if(lf(t)){if(!Tc(t.origin,this.originValidator))throw new DOMException(`Message from unknown origin (${t.origin}) cannot be handled`,"SecurityError");t.data.action==="disconnect"?this.connectedMathfieldWindow=void 0:t.data.action!=="update-setting"&&t.data.action!=="proxy-created"&&t.data.action!=="execute-command"&&(console.assert(t.source!==void 0),this.connectedMathfieldWindow=t.source),this.handleMessage(t.data,t.source)}if(this._element)switch(t.type){case"mouseup":case"blur":document.body.style.userSelect="",this.shiftPressCount=0;break;case"contextmenu":t.button!==2&&t.preventDefault();break;case"keydown":{t.key==="Shift"&&!t.repeat&&(this.shiftPressCount=1);break}case"keyup":{(t.key==="Shift"||!t.getModifierState("Shift")&&this.shiftPressCount!==2)&&(this.shiftPressCount=0);break}}}handleMessage(t,r){const{action:n}=t;if(n==="execute-command"){const{command:i}=t,a=zl(i);if(window.top!==void 0&&a!=="virtual-keyboard")return;this.executeCommand(i);return}if((n==="connect"||n==="show")&&this.sendMessage("synchronize-proxy",{boundingRect:this.boundingRect,alphabeticLayout:this._alphabeticLayout,layouts:this._layouts,editToolbar:this._editToolbar},r),n!=="disconnect"&&window===window.top){if(n==="show"){typeof t.animate!="undefined"?this.show({animate:t.animate}):this.show();return}if(n==="hide"){typeof t.animate!="undefined"?this.hide({animate:t.animate}):this.hide();return}if(n==="update-setting"){t.alphabeticLayout&&(this.alphabeticLayout=t.alphabeticLayout),t.layouts&&(this.layouts=t.layouts),t.editToolbar&&(this.editToolbar=t.editToolbar);return}if(n==="proxy-created"){this.sendMessage("synchronize-proxy",{boundingRect:this.boundingRect,alphabeticLayout:this._alphabeticLayout,layouts:this._layouts,editToolbar:this._editToolbar},r);return}}}sendMessage(t,r,n){if(n||(n=this.connectedMathfieldWindow),this.targetOrigin===null||this.targetOrigin==="null"||n===window){window.dispatchEvent(new MessageEvent("message",{source:window,data:S({type:zd,action:t},r)}));return}if(n)n.postMessage(S({type:zd,action:t},r),{targetOrigin:this.targetOrigin});else if(r.command&&this.dispatchEvent(new CustomEvent("math-virtual-keyboard-command",{detail:r.command})),t==="execute-command"&&Array.isArray(r.command)&&r.command[0]==="insert"){const i=r.command[1].split("");for(const a of i)this.dispatchEvent(new KeyboardEvent("keydown",{key:a,bubbles:!0})),this.dispatchEvent(new KeyboardEvent("keyup",{key:a,bubbles:!0}))}}stateWillChange(t){return this.dispatchEvent(new CustomEvent("before-virtual-keyboard-toggle",{detail:{visible:t},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(t){const r=this._element;if(!r)return;r.classList.toggle("is-math-mode",t.mode==="math"),r.classList.toggle("is-text-mode",t.mode==="text"),r.classList.toggle("can-undo",t.canUndo),r.classList.toggle("can-redo",t.canRedo),r.classList.toggle("can-copy",!t.selectionIsCollapsed),r.classList.toggle("can-copy",!t.selectionIsCollapsed),r.classList.toggle("can-paste",!0);const n=r.querySelectorAll(".ML__edit-toolbar");if(n)for(const i of n)i.innerHTML=Cm(this,t)}update(t){this._style=t.style,this.updateToolbar(t)}connect(){this.connectedMathfieldWindow=window}disconnect(){this.connectedMathfieldWindow=void 0}executeCommand(t){let r,n=[],i=zl(t);return A(t)?(r=t[0],r==="performWithFeedback"&&(t=t.slice(1),i=zl(t)),n=t.slice(1)):r=t,r=r.replace(/-\w/g,a=>a[1].toUpperCase()),i==="virtual-keyboard"?no[r].fn(void 0,...n):(this.sendMessage("execute-command",{command:t}),!1)}dispose(){window.removeEventListener("mouseup",this),window.removeEventListener("blur",this),window.removeEventListener("message",this)}};function nh(){var e,t;let r=$d(),n=null;for(;r;){if("host"in r&&((t=(e=r.host)==null?void 0:e.tagName)==null?void 0:t.toLowerCase())==="math-field"){n=r.host;break}r=r.parentNode}return n}if(Ke()&&!("mathVirtualKeyboard"in window))if(window===window.top){const e=Yo.singleton;Object.defineProperty(window,"mathVirtualKeyboard",{get:()=>e})}else Object.defineProperty(window,"mathVirtualKeyboard",{get:()=>bm.singleton,configurable:!0});function Vd(e){const t={};for(const r of Object.keys(e))switch(r){case"scriptDepth":const n=e.scriptDepth;if(A(n))t.scriptDepth=[n[0],n[1]];else if(typeof n=="number")t.scriptDepth=[n,n];else if(typeof n=="string"){const[a,s]=n.split(",").map(u=>parseInt(u.trim()));t.scriptDepth=[a,s]}else throw new TypeError("Unexpected value for scriptDepth");break;case"mathVirtualKeyboardPolicy":let i=e.mathVirtualKeyboardPolicy.toLowerCase();if(i==="sandboxed"){if(window!==window.top){const a=Yo.singleton;Object.defineProperty(window,"mathVirtualKeyboard",{get:()=>a})}i="manual"}t.mathVirtualKeyboardPolicy=i;break;case"letterShapeStyle":e.letterShapeStyle==="auto"?Ce.locale.startsWith("fr")?t.letterShapeStyle="french":t.letterShapeStyle="tex":t.letterShapeStyle=e.letterShapeStyle;break;case"defaultMode":["text","math","inline-math"].includes(e.defaultMode)?t.defaultMode=e.defaultMode:(console.error('MathLive 0.98.5: valid values for defaultMode are "text", "math" or "inline-math"'),t.defaultMode="math");break;case"macros":t.macros=q(e.macros);break;default:A(e[r])?t[r]=[...e[r]]:typeof e[r]=="object"&&!(e[r]instanceof Element)&&r!=="computeEngine"?t[r]=S({},e[r]):t[r]=e[r]}return t}function Ts(e,t){let r;typeof t=="string"?r=[t]:t===void 0?r=Object.keys(e):r=t;const n={};for(const i of r)e[i]===null?n[i]=null:A(e[i])?n[i]=[...e[i]]:typeof e[i]=="object"&&!(e[i]instanceof Element)&&i!=="computeEngine"?n[i]=S({},e[i]):n[i]=e[i];return typeof t=="string"?n[t]:n}function Zd(){return{readOnly:!1,defaultMode:"math",macros:{},registers:{},colorMap:ut,backgroundColorMap:dt,letterShapeStyle:Ce.locale.startsWith("fr")?"french":"tex",minFontScale:0,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:"\u25A2",contentPlaceholder:"",popoverPolicy:"auto",environmentPopoverPolicy:"off",keybindings:$0,inlineShortcuts:ad,inlineShortcutTimeout:0,mathVirtualKeyboardPolicy:"auto",virtualKeyboardTargetOrigin:window==null?void 0:window.origin,originValidator:"none",onInlineShortcut:()=>"",onScrollIntoView:null,onExport:I0,value:""}}function ih(e){return e.defaultMode==="inline-math"?"math":e.defaultMode}function Qo(e,t){!e||!t||(A(e)?e.forEach(r=>Qo(r,t)):typeof e=="object"&&!e.style.color&&!e.style.backgroundColor&&!e.style.fontFamily&&!e.style.fontShape&&!e.style.fontSeries&&!e.style.fontSize&&!e.style.variant&&!e.style.variantStyle&&(e.applyStyle(t),Qo(e.body,t),Qo(e.above,t),Qo(e.below,t),Qo(e.subscript,t),Qo(e.superscript,t)))}function uf(e,t,r,n){function i(s,u){for(const d of a)if(d.style[s]!==u)return!1;return!0}if(t=e.normalizeRange(t),t[0]===t[1])return!1;const a=e.getAtoms(t,{includeChildren:!0});n.operation==="toggle"&&(r.color&&i("color",r.color)&&(r.color="none",delete r.verbatimColor),r.backgroundColor&&i("backgroundColor",r.backgroundColor)&&(r.backgroundColor="none",delete r.verbatimBackgroundColor),r.fontFamily&&i("fontFamily",r.fontFamily)&&(r.fontFamily="none"),r.fontSeries&&i("fontSeries",r.fontSeries)&&(r.fontSeries="auto"),r.fontShape&&i("fontShape",r.fontShape)&&(r.fontShape="auto"),r.fontSize&&i("fontSize",r.fontSize)&&(r.fontSize=Co),r.variant&&i("variant",r.variant)&&(r.variant="normal"),r.variantStyle&&i("variantStyle",r.variantStyle)&&(r.variantStyle=""));for(const s of a)s.applyStyle(r);return!0}function Rm(e,t){const r=e.at(e.position);if(r.type==="composition")r.value=t;else{const{caret:n}=r;r.caret=void 0;const i=new Ed(t,{mode:r.mode});i.caret=n,r.parent.addChildAfter(i,r),e.position+=1}}function Om(e){const t=e.at(e.position);t.type==="composition"&&(t.parent.removeChild(t),e.position-=1)}Et(["math","displaymath"],va),Et("center",va),W("displaylines","",{parse:e=>{const t=[];let r=[];e.beginContext({tabular:!0});do{if(e.end()||e.match("<}>"))break;e.matchColumnSeparator()||e.matchRowSeparator()?(t.push([r]),r=[]):r.push(...e.scan(n=>["<}>","&","\\cr","\\\\","\\tabularnewline"].includes(n)))}while(!0);return e.endContext(),t.push([r]),t},createAtom:e=>new jr("lines",e.args,[],{leftDelim:".",rightDelim:".",columns:[{align:"l"}]})}),Bt("array","{columns:colspec}",(e,t,r,n)=>new jr(e,df(t),r,{columns:n[0],mathstyleName:"textstyle"})),Bt(["equation","equation*","subequations"],"",(e,t,r)=>new jr(e,df(t),r,{columns:[{align:"c"}]})),Bt(["multline","multline*"],"",va),Bt(["align","align*","aligned","eqnarray"],"",va),Bt("split","",va),Bt(["gather","gathered"],"",va),Bt(["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],"[columns:colspec]",va),Bt(["smallmatrix","smallmatrix*"],"[columns:colspec]",va),Bt(["cases","dcases","rcases"],"",va);function Nm(e){for(const t of e)for(const r of t)if(r.length>0)return!1;return!0}function df(e,t=1){return Nm(e)?Array(t).fill([[new _e({type:"first"}),new Ta]]):e.map(r=>r.length===0?[[new _e({type:"first"})]]:r.map(n=>n.length===0?[new _e({type:"first"})]:(n[0].type!=="first"&&n.unshift(new _e({type:"first"})),n)))}function va(e,t=[[[]]],r=[],n=[]){switch(t=df(t,["split","align","align*","aligned","eqnarray"].includes(e)?2:1),e){case"math":return new jr(e,t,r,{mathstyleName:"textstyle"});case"displaymath":return new jr(e,t,r,{mathstyleName:"textstyle"});case"center":return new jr(e,t,r,{columns:[{align:"c"}]});case"multline":case"multline*":return new jr(e,t,r,{columns:[{align:"m"}],leftDelim:".",rightDelim:"."});case"split":return new jr(e,t,r,{columns:[{align:"r"},{align:"l"}],minColumns:2});case"gather":case"gathered":return new jr(e,t,r,{columns:[{gap:.25},{align:"c"},{gap:0}]});case"pmatrix":case"pmatrix*":return new jr(e,t,r,{mathstyleName:"textstyle",leftDelim:"(",rightDelim:")",columns:Ps(n[0])});case"bmatrix":case"bmatrix*":return new jr(e,t,r,{mathstyleName:"textstyle",leftDelim:"[",rightDelim:"]",columns:Ps(n[0])});case"Bmatrix":case"Bmatrix*":return new jr(e,t,r,{mathstyleName:"textstyle",leftDelim:"\\lbrace",rightDelim:"\\rbrace",columns:Ps(n[0])});case"vmatrix":case"vmatrix*":return new jr(e,t,r,{mathstyleName:"textstyle",leftDelim:"\\vert",rightDelim:"\\vert",columns:Ps(n[0])});case"Vmatrix":case"Vmatrix*":return new jr(e,t,r,{mathstyleName:"textstyle",leftDelim:"\\Vert",rightDelim:"\\Vert",columns:Ps(n[0])});case"matrix":case"matrix*":return new jr(e,t,r,{mathstyleName:"textstyle",leftDelim:".",rightDelim:".",columns:Ps(n==null?void 0:n[0])});case"smallmatrix":case"smallmatrix*":return new jr(e,t,r,{mathstyleName:"scriptstyle",columns:Ps(n==null?void 0:n[0]),colSeparationType:"small",arraystretch:.5});case"cases":case"dcases":return new jr(e,t,r,{mathstyleName:e==="dcases"?"displaystyle":"textstyle",arraystretch:1.2,leftDelim:"\\lbrace",rightDelim:".",columns:[{align:"l"},{gap:1},{align:"l"}]});case"rcases":return new jr(e,t,r,{arraystretch:1.2,leftDelim:".",rightDelim:"\\rbrace",columns:[{align:"l"},{gap:1},{align:"l"}]});case"lines":return new jr(e,t,r,{leftDelim:".",rightDelim:".",columns:[{align:"l"}]});case"align":case"align*":case"aligned":case"eqnarray":{let i=0;for(const u of t)i=Math.max(i,u.length);const a=[{gap:0},{align:"r"},{gap:.25},{align:"l"}];let s=2;for(;s1){n.removeRow(i[0]);const s=n.getCell(Math.max(0,i[0]-1),i[1]);a=e.offsetOf(s[s.length-1])}break;case"column":if(n.colCount>n.minColumns){n.removeColumn(i[1]);const s=n.getCell(i[0],Math.max(0,i[1]-1));a=e.offsetOf(s[s.length-1])}break}a&&e.setPositionHandlingPlaceholder(a)}}function Wm(e){return e.contentWillChange({inputType:"deleteContent"})?(lh(e,"row"),e.contentDidChange({inputType:"deleteContent"}),!0):!1}function Vm(e){return e.contentWillChange({inputType:"deleteContent"})?(lh(e,"column"),e.contentDidChange({inputType:"deleteContent"}),!0):!1}Vi({addRowAfter:ah,addColumnAfter:oh,addRowBefore:Km,addColumnBefore:Hm,removeRow:Wm,removeColumn:Vm,setEnvironment:sh},{target:"model",canUndo:!0,changeContent:!0,changeSelection:!0});function Gd(){return[new Ta]}var ch=class Bp{constructor(t){this.recording=!1,this.model=t,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(t){t&&this.index>=0&&(this.stack[this.index].selection=t),this.lastOp=""}undo(){return this.canUndo()?(this.model.setState(this.stack[this.index-1],{silenceNotifications:!1,type:"undo"}),this.index-=1,this.lastOp="",!0):!1}redo(){return this.canRedo()?(this.index+=1,this.model.setState(this.stack[this.index],{silenceNotifications:!1,type:"redo"}),this.lastOp="",!0):!1}pop(){this.canUndo()&&(this.stack.splice(this.index,this.stack.length-this.index),this.index-=1)}snapshot(t){return this.recording?(t&&t===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>Bp.maximumDepth&&(this.stack.shift(),this.index-=1),this.lastOp=t!=null?t:"",!0):!1}};ch.maximumDepth=1e3;var Zm=ch;function ff(e,t,r){if(e.at(t).mode!=="text")return t;const n=r==="backward"?-1:1;let i;if(K.test(e.at(t).value)){let a=t,s;do s=e.at(a).mode==="text"&&K.test(e.at(a).value),a+=n;while(e.at(a)&&s);i=e.at(a)?a-2*n:a-n}else if(/\s/.test(e.at(t).value)){let a=t;for(;e.at(a)&&e.at(a).mode==="text"&&/\s/.test(e.at(a).value);)a+=n;if(!e.at(a))i=a-n;else{let s=!0;do s=e.at(a).mode==="text"&&!/\s/.test(e.at(a).value),a+=n;while(e.at(a)&&s);i=e.at(a)?a-2*n:a-n}}else{let a=t;for(;e.at(a)&&e.at(a).mode==="text"&&!/\s/.test(e.at(a).value);)a+=n;i=e.at(a)?a:a-n;let s=!0;for(;e.at(a)&&s;)s=e.at(a).mode==="text"&&/\s/.test(e.at(a).value),s&&(i=a),a+=n;i=e.at(a)?a-2*n:a-n}return i-(n>0?0:1)}function Wl(e,t,r){var n,i,a,s,u,d,h;const p=e.position;(n=r==null?void 0:r.extend)!=null&&n||e.collapseSelection(t);let y=e.at(e.position);if(t==="forward"&&(y.type==="subsup"?(y=y.rightSibling,y||(y=e.at(e.position+1))):y=e.at(e.position+1)),!y)return e.announce("plonk"),!1;let M=e.offsetOf(y);if(y instanceof Ms)M=ff(e,M,t);else if(y instanceof Pt)if(y.isSuggestion)for(console.assert(t==="forward");y&&y instanceof Pt;)y.isSuggestion=!1,M=e.offsetOf(y),y=y.rightSibling;else if(t==="forward"){if(y=y.rightSibling,!y||!(y instanceof Pt))return e.announce("plonk"),!1;for(;y&&y instanceof Pt&&/[a-zA-Z\*]/.test(y.value);)M=e.offsetOf(y),y=y.rightSibling}else{if(y=y.leftSibling,!y||!(y instanceof Pt))return e.announce("plonk"),!1;for(;y&&y instanceof Pt&&/[a-zA-Z\*]/.test(y.value);)M=e.offsetOf(y),y=y.leftSibling}else if(t==="forward"&&y.type==="mopen"){let I=0;do y.type==="mopen"?I+=1:y.type==="mclose"&&(I-=1),y=y.rightSibling;while(!y.isLastSibling&&I!==0);M=e.offsetOf(y.leftSibling)}else if(t==="backward"&&y.type==="mclose"){let I=0;do y.type==="mopen"?I+=1:y.type==="mclose"&&(I-=1),y=y.leftSibling;while(!y.isFirstSibling&&I!==0);M=e.offsetOf(y)}else if(t==="backward")if(y.type==="first")for(;M>0&&y.type==="first";)M-=1,y=e.at(M);else{const I=y.type;y.type==="subsup"&&(M=e.offsetOf(e.at(M).leftSibling)),M-=1;let $=(i=e.at(M))==null?void 0:i.type;for(;M>=0&&$===I;)((a=e.at(M))==null?void 0:a.type)==="subsup"?M=e.offsetOf(e.at(M).leftSibling):M-=1,$=e.at(M).type}else{const{type:I}=y;let $=(s=e.at(M))==null?void 0:s.type;const{lastOffset:se}=e;for(;M<=se&&($===I||$==="subsup");){for(;((u=e.at(M).rightSibling)==null?void 0:u.type)==="subsup";)M=e.offsetOf(e.at(M).rightSibling);M+=1,$=(d=e.at(M))==null?void 0:d.type}M-=1}if((h=r==null?void 0:r.extend)!=null&&h){if(!e.setSelection(e.anchor,M))return e.announce("plonk"),!1}else{if(M===e.position)return e.announce("plonk"),!1;e.position=M}return e.announce("move",p),e.mathfield.stopCoalescingUndo(),!0}function io(e,t,r){var n,i;if(r=r!=null?r:{extend:!1},e.mathfield.adoptStyle=t==="backward"?"right":"left",t!=="forward"){const[u,d]=Zf(e);u!==void 0&&d!==void 0&&e.deleteAtoms([u,d])}if(t==="upward")return Um(e,r);if(t==="downward")return Gm(e,r);if(r.extend){let u=qd(e,e.position,t);u<0&&(u=0),u>e.lastOffset&&(u=e.lastOffset);const d=e.setSelection(e.anchor,u);return e.mathfield.stopCoalescingUndo(),d}if(e.selectionIsPlaceholder){e.collapseSelection(t);const u=io(e,t);return e.mathfield.stopCoalescingUndo(),u}let a=e.position;const s=a;if(e.collapseSelection(t)?(a=e.position,uh(e,a)||(a=qd(e,a,t))):a=qd(e,a,t),a<0||a>e.lastOffset){let u=!0;return e.silenceNotifications||(u=(i=(n=e.mathfield.host)==null?void 0:n.dispatchEvent(new CustomEvent("move-out",{detail:{direction:t},cancelable:!0,bubbles:!0,composed:!0})))!=null?i:!0),u&&e.announce("plonk"),u}return e.setPositionHandlingPlaceholder(a),e.mathfield.stopCoalescingUndo(),e.announce("move",s),!0}function qd(e,t,r){return t=t+(r==="forward"?1:-1),t<0||t>e.lastOffset||uh(e,t)?t:qd(e,t,r)}function uh(e,t){var r;const n=e.at(t);let i=n.parent;for(;i&&!i.inCaptureSelection;)i=i.parent;return!(i!=null&&i.inCaptureSelection||(r=n.parent)!=null&&r.skipBoundary&&(!n.isFirstSibling&&n.isLastSibling||n.type==="first")||e.mathfield.hasEditablePrompts&&!n.parentPrompt)}function jm(e,t,r){let n=1/0,i=0;for(;ih.type==="prompt"&&!h.captureSelection):r,u=md(e.mathfield.getHTMLElement(t)).right,d=e.offsetOf(jm(e.mathfield,s,u))-(a?1:0);if(n){const[h,p]=e.selection.ranges[0];let y;d<(i==="up"?h:p)?y={ranges:[[d,p]],direction:"backward"}:y={ranges:[[h,d]],direction:"forward"},e.setSelection(y)}else e.setPositionHandlingPlaceholder(d);e.announce(`move ${i}`)}function Um(e,t){var r,n;const i=(r=t==null?void 0:t.extend)!=null?r:!1;i||e.collapseSelection("backward");const a=()=>{var d,h;let p=!0;return e.silenceNotifications||(p=(h=(d=e.mathfield.host)==null?void 0:d.dispatchEvent(new CustomEvent("move-out",{detail:{direction:"upward"},cancelable:!0,bubbles:!0,composed:!0})))!=null?h:!0),e.announce(p?"plonk":"line"),p},s=e.at(e.position);let u=s;for(;u&&u.parentBranch!=="below"&&!(Array.isArray(u.parentBranch)&&u.parent instanceof jr);)u=u.parent;if(Array.isArray(u==null?void 0:u.parentBranch)&&u.parent instanceof jr){const d=u.parent;if(u.parentBranch[0]<1)return a();const h=u.parentBranch[0]-1,p=d.array[h][u.parentBranch[1]];if(!p.some(M=>M.type==="prompt"&&!M.captureSelection)&&e.mathfield.hasEditablePrompts)return a();Xd(e,s,p,i,"up")}else if(u){const d=(n=u.parent.branch("above"))!=null?n:u.parent.createBranch("above");if(!d.some(p=>p.type==="prompt"&&p.placeholderId)&&e.mathfield.hasEditablePrompts)return a();Xd(e,s,d,i,"up")}else return a();return e.mathfield.stopCoalescingUndo(),!0}function Gm(e,t){var r,n;const i=(r=t==null?void 0:t.extend)!=null?r:!1;i||e.collapseSelection("forward");const a=()=>{var d,h;let p=!0;return e.silenceNotifications||(p=(h=(d=e.mathfield.host)==null?void 0:d.dispatchEvent(new CustomEvent("move-out",{detail:{direction:"downward"},cancelable:!0,bubbles:!0,composed:!0})))!=null?h:!0),e.announce(p?"plonk":"line"),p},s=e.at(e.position);let u=s;for(;u&&u.parentBranch!=="above"&&!(Array.isArray(u.parentBranch)&&u.parent instanceof jr);)u=u.parent;if(Array.isArray(u==null?void 0:u.parentBranch)&&u.parent instanceof jr){const d=u.parent;if(u.parentBranch[0]+1>d.array.length-1)return a();const h=u.parentBranch[0]+1,p=d.array[h][u.parentBranch[1]];if(!p.some(M=>M.type==="prompt"&&!M.captureSelection)&&e.mathfield.hasEditablePrompts)return a();Xd(e,s,p,i,"down")}else if(u){const d=(n=u.parent.branch("below"))!=null?n:u.parent.createBranch("below");if(!d.some(p=>p.type==="prompt")&&e.mathfield.hasEditablePrompts)return a();Xd(e,s,d,i,"down")}else return a();return!0}function dh(e){const t=e.position,r=e.at(t).parent;return r!=null&&r.parent?(e.position=e.offsetOf(r),e.mathfield.stopCoalescingUndo(),e.announce("move",t),!0):(e.announce("plonk"),!1)}function qm(e){let t=0,r=e.at(e.position),n=!1;for(;r;)(!r.hasEmptyBranch("superscript")||!r.hasEmptyBranch("subscript"))&&(t+=1),r.hasEmptyBranch("superscript")?r.hasEmptyBranch("subscript")||(n=!1):n=!0,r=r.parent;return n?t:0}function Xm(e){let t=0,r=e.at(e.position),n=!1;for(;r;)(!r.hasEmptyBranch("superscript")||!r.hasEmptyBranch("subscript"))&&(t+=1),r.hasEmptyBranch("superscript")?r.hasEmptyBranch("subscript")||(n=!0):n=!1,r=r.parent;return n?t:0}function fh(e){var t;if(e.collapseSelection(),qm(e)>=e.mathfield.options.scriptDepth[1])return e.announce("plonk"),!1;let r=e.at(e.position);return r.subsupPlacement===void 0&&(((t=r.rightSibling)==null?void 0:t.type)!=="subsup"&&r.parent.addChildAfter(new m({style:r.computedStyle}),r),r=r.rightSibling),r.createBranch("superscript"),e.setSelection(e.getSiblingsRange(e.offsetOf(r.superscript[0]))),!0}function hh(e){var t;if(e.collapseSelection(),Xm(e)>=e.mathfield.options.scriptDepth[0])return e.announce("plonk"),!1;let r=e.at(e.position);return r.subsupPlacement===void 0&&(((t=e.at(e.position+1))==null?void 0:t.type)!=="subsup"&&r.parent.addChildAfter(new m({style:e.at(e.position).computedStyle}),r),r=e.at(e.position+1)),r.createBranch("subscript"),e.setSelection(e.getSiblingsRange(e.offsetOf(r.subscript[0]))),!0}function Jm(){function e(d){const h=[],p=[];return[...d.querySelectorAll(`input, select, textarea, a[href], button,
[tabindex], audio[controls], video[controls],
[contenteditable]:not([contenteditable="false"]), details>summary`)].filter(t).forEach((M,I)=>{const $=n(M);$===0?h.push(M):p.push({documentOrder:I,tabIndex:$,node:M})}),p.sort((M,I)=>M.tabIndex===I.tabIndex?M.documentOrder-I.documentOrder:M.tabIndex-I.tabIndex).map(M=>M.node).concat(h)}function t(d){return!(!r(d)||i(d)||n(d)<0)}function r(d){return!(d.disabled||d.type==="hidden"&&d.tagName.toUpperCase()==="INPUT"||u(d))}function n(d){var h;const p=Number.parseInt((h=d.getAttribute("tabindex"))!=null?h:"NaN",10);return Number.isNaN(p)?d.contentEditable==="true"||(d.nodeName==="AUDIO"||d.nodeName==="VIDEO")&&d.getAttribute("tabindex")===null?0:d.tabIndex:p}function i(d){return d.tagName.toUpperCase()==="INPUT"&&d.type==="radio"&&!s(d)}function a(d,h){for(const p of d)if(p.checked&&p.form===h)return p;return null}function s(d){var h;if(!d.name)return!0;const y=((h=d.form)!=null?h:d.ownerDocument).querySelectorAll('input[type="radio"][name="'+d.name+'"]'),M=a(y,d.form);return!M||M===d}function u(d){if(!Ke()||d===document.activeElement||d.contains(document.activeElement))return!1;if(getComputedStyle(d).visibility==="hidden")return!0;const h=d.getBoundingClientRect();if(h.width===0||h.height===0)return!0;for(;d;){if(getComputedStyle(d).display==="none")return!0;d=d.parentElement}return!1}return Ke()?e(document.body):[]}function Si(e,t,r="forward"){const n=e.position;if(Array.isArray(t)){const i=e.offsetOf(t[0]),a=e.offsetOf(t[t.length-1]);return r==="forward"?e.setSelection(i,a):e.setSelection(a,i),e.announce("move",n),e.mathfield.stopCoalescingUndo(),!0}return r==="forward"?Si(e,[t.leftSibling,t]):Si(e,[t,t.leftSibling])}function Ra(e,t){const r=e.position;if(typeof t=="number"&&(t=e.at(t)),t.type==="prompt")e.setSelection(e.offsetOf(t.firstChild),e.offsetOf(t.lastChild));else{const n=e.offsetOf(t);t.type==="placeholder"?e.setSelection(n-1,n):e.position=n}return e.announce("move",r),e.mathfield.stopCoalescingUndo(),!0}function Jd(e,t,r=!0){var n,i;const a=t==="forward"?1:-1;e.at(e.anchor).type==="placeholder"&&io(e,t);let s;const u=e.at(e.anchor).parentPrompt;u?t==="forward"?s=e.offsetOf(u)+1:s=e.offsetOf(u.leftSibling):s=Math.max(e.position+a,0);const d=hf(e,s,t);if(!d||t==="forward"&&e.offsetOf(d)s){if(!r||!((i=(n=e.mathfield.host)==null?void 0:n.dispatchEvent(new CustomEvent("move-out",{detail:{direction:t},cancelable:!0,bubbles:!0,composed:!0})))==null||i))return e.announce("plonk"),!1;const p=Jm();if(!document.activeElement||p.length<=1)return e.announce("plonk"),!1;let y=p.indexOf(document.activeElement)+a;return y<0&&(y=p.length-1),y>=p.length&&(y=0),p[y].focus(),e.mathfield.stopCoalescingUndo(),!0}return Ra(e,d),!0}function hf(e,t=0,r="forward"){return e.findAtom(n=>n.type==="placeholder"||n.type==="prompt"||!e.mathfield.readOnly&&n.treeDepth>2&&n.isFirstSibling&&n.isLastSibling,t,r)}Vi({moveToOpposite:e=>{const t={superscript:"subscript",subscript:"superscript",above:"below",below:"above"},r=e.at(e.position),{parent:n}=r;if(!n)return e.announce("plonk"),!1;const i=r.parentBranch;let a;if(typeof i=="string"&&(a=t[i]),!a){const u=r.subsupPlacement?hh(e):fh(e);return e.mathfield.stopCoalescingUndo(),u}n.branch(a)||n.createBranch(a);const s=e.setSelection(e.getBranchRange(e.offsetOf(n),a));return e.mathfield.stopCoalescingUndo(),s},moveBeforeParent:e=>{const{parent:t}=e.at(e.position);return t?(e.position=e.offsetOf(t),e.mathfield.stopCoalescingUndo(),!0):(e.announce("plonk"),!1)},moveAfterParent:e=>dh(e),moveToNextChar:e=>io(e,"forward"),moveToPreviousChar:e=>io(e,"backward"),moveUp:e=>io(e,"upward"),moveDown:e=>io(e,"downward"),moveToNextWord:e=>Wl(e,"forward"),moveToPreviousWord:e=>Wl(e,"backward"),moveToGroupStart:e=>{const t=e.offsetOf(e.at(e.position).firstSibling);return t===e.position?(e.announce("plonk"),!1):(e.position=t,e.mathfield.stopCoalescingUndo(),!0)},moveToGroupEnd:e=>{const t=e.offsetOf(e.at(e.position).lastSibling);return t===e.position?(e.announce("plonk"),!1):(e.position=t,e.mathfield.stopCoalescingUndo(),!0)},moveToNextGroup:e=>{var t,r,n,i;if(e.position===e.lastOffset&&e.anchor===e.lastOffset)return Jd(e,"forward");const a=e.at(e.position);if(a.mode==="text"){if(e.selectionIsCollapsed){let M=a;for(;M&&M.mode==="text";)M=M.leftSibling;let I=a;for(;((t=I.rightSibling)==null?void 0:t.mode)==="text";)I=I.rightSibling;if(M&&I)return Si(e,[M,I])}if(a.rightSibling.mode==="text"){let M=a;for(;M&&M.mode==="text";)M=M.rightSibling;return M?(Ra(e,(r=M.leftSibling)!=null?r:M),e.mathfield.switchMode("math"),!0):Ra(e,e.lastOffset)}}const u=e.at(e.anchor).parentPrompt,d=u?e.offsetOf(u)+1:Math.max(e.position+1,0),h=hf(e,d,"forward");if(h)return Ra(e,h);const p=ph(e,a,M=>M.type==="leftright"||M.type==="text","forward");if(p){if(p.mode==="text"){let M=p;for(;M&&M.mode==="text";)M=M.rightSibling;return Si(e,[(n=p.leftSibling)!=null?n:p,(i=M.leftSibling)!=null?i:M])}return Si(e,p)}const y=a.parent;if(y){if(y.type==="leftright"||y.type==="surd")return Si(e,y);if(a.parentBranch==="superscript"&&y.subscript)return Si(e,y.subscript);if(a.parentBranch==="above"&&y.below)return Si(e,y.below);if(a.parentBranch==="superscript"||a.parentBranch==="subscript")return Ra(e,y);if(a.parentBranch==="above"||a.parentBranch==="below")return Si(e,y)}return Ra(e,e.lastOffset)},moveToPreviousGroup:e=>{var t;if(e.position===0&&e.anchor===0)return Jd(e,"backward");let r=e.at(e.position);const n=r.mode;if(n==="text"){if(e.selectionIsCollapsed){let u=r;for(;u&&u.mode==="text";)u=u.leftSibling;let d=r;for(;((t=d.rightSibling)==null?void 0:t.mode)==="text";)d=d.rightSibling;if(u&&d)return Si(e,[u,d])}for(;r&&r.mode==="text";)r=r.leftSibling;return r?Ra(e,r):Ra(e,0)}const i=e.at(e.anchor).parentPrompt,a=i?e.offsetOf(i.leftSibling):Math.max(e.position-1,0),s=hf(e,a,"backward");if(s)return Ra(e,s);if(n==="math"){const u=ph(e,r,h=>h.type==="leftright"||h.type==="text","backward");if(u){if(u.mode==="text"){let h=u;for(;h&&h.mode==="text";)h=h.leftSibling;return Si(e,[u,h])}return Si(e,u)}const d=r.parent;if(d){if(d.type==="leftright"||d.type==="surd")return Si(e,d);if(r.parentBranch==="subscript"&&d.superscript)return Si(e,d.superscript);if(r.parentBranch==="below"&&d.above)return Si(e,d.above);if(r.parentBranch==="superscript"||r.parentBranch==="subscript")return Ra(e,d);if(r.parentBranch==="above"||r.parentBranch==="below")return Si(e,d)}return Ra(e,0)}return!1},moveToMathfieldStart:e=>e.selectionIsCollapsed&&e.position===0?(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:fh,moveToSubscript:hh},{target:"model",changeSelection:!0}),Vi({moveToNextPlaceholder:e=>Jd(e,"forward"),moveToPreviousPlaceholder:e=>Jd(e,"backward")},{target:"model",changeSelection:!0,audioFeedback:"return"});function ph(e,t,r,n){if(n==="forward"){let a=t.rightSibling;for(;a&&!r(a);)a=a.rightSibling;return a}let i=t.leftSibling;for(;i&&!r(i);)i=i.leftSibling;return i}function Yd(e,t,r){typeof t=="function"&&(r=t,t=1/0),t===void 0&&(t=1/0);let n=e.position,i=!1,a="";for(;!i;){const s=e.at(n);i=t===0||s===void 0||s.type==="first"||s.mode!=="math"||!(s.type&&/mord|mpunct|operator/.test(s.type)||s.type==="mop"&&/[a-zA-Z ]+/.test(s.value))||!s.hasEmptyBranch("superscript")||!s.hasEmptyBranch("subscript")||typeof r=="function"&&!r(s),i||(s.mode="text",s.command=s.value,s.verbatimLatex=void 0,a+=s.value),n-=1,t-=1}e.contentDidChange({data:a,inputType:"insertText"})}function Ns(e,t,r){typeof t=="function"&&(r=t,t=1/0),t===void 0&&(t=1/0);let n=e.position,i=!1;const a=[];for(;!i;){const s=e.at(n);i=t===0||!s||s.type==="first"||s.isFirstSibling||s.mode!=="text"||s.value===" "||typeof r=="function"&&!r(s),i||(a.push(_e.serialize([s],{defaultMode:"math"})),s.mode="math"),n-=1,t-=1}pf(e),e.contentDidChange({data:Cr(a),inputType:"insertText"})}function pf(e){var t;let r=e.position-1;for(;r>=0&&((t=e.at(r))==null?void 0:t.mode)==="math";)r-=1;if(!(r<0)&&e.at(r).mode==="text"&&e.at(r).value===" "&&e.at(r-1).mode==="math"){e.at(r-1).parent.removeChild(e.at(r-1));const n=e.silenceNotifications;e.silenceNotifications=!0,e.position-=1,e.silenceNotifications=n,e.contentDidChange({inputType:"deleteContent"})}}function Ym(e){let t="",r=e.position,n=!1;for(;!n;){const i=e.at(r);n=!(i&&(i.mode==="text"||i.mode==="math"&&i.type&&/mord|mpunct/.test(i.type))),n||(t=i.value+t),r-=1}return t}function Qm(e,t,r){const{model:n}=e;if(n.mode==="latex"||!n.at(n.position).isLastSibling||!r||!Id(r))return!1;const i=Ol(r);if(!n.selectionIsCollapsed)return!!(e.model.mode==="text"&&/[/_^]/.test(i));const a=Ym(n)+i;if(e.model.mode==="text"){if(t==="Esc"||/[/\\]/.test(i))return!0;if(/[\^_]/.test(i))return/(^|\s)[a-zA-Z][^_]$/.test(a)&&Ns(n,1),!0;const s={")":"(","}":"{","]":"["}[i],{parent:u}=n.at(n.position);if(s&&u instanceof ln&&u.leftDelim===s)return!0;if(/(^|[^a-zA-Z])(a|I) $/.test(a))return!1;if(/[$€£₤₺¥¤฿¢₡₧₨₹₩₱]/u.test(i))return!0;if(/(^|[^a-zA-Z'’])[a-zA-Z] $/.test(a))return Ns(n,1),!1;if(/\D\.[^\d\s]$/.test(a)){Ns(n,1);const d=n.at(n.position);return d.value="\u22C5",d.style.variant="normal",d.command="\\cdot",d.verbatimLatex=void 0,n.contentDidChange({data:"\\cdot",inputType:"insertText"}),!0}if(/(^|\s)[a-zA-Z][^a-zA-Z]$/.test(a)||/\.\d$/.test(a)||/\([\d+\-.]$/.test(a))return Ns(n,1),!0;if(/\([a-z][,;]$/.test(a))return Ns(n,2),!0;if(/[\d+\-=><*|]$/.test(i))return pf(n),!0}else{if(t==="[Space]")return Yd(n,void 0,s=>/[a-z][:,;.]$/.test(s.value)),!0;if(/[a-zA-Z]{3,}$/.test(a)&&!/(dxd|abc|xyz|uvw)$/.test(a))return Yd(n,void 0,s=>/[a-zA-Z]/.test(s.value)),!0;if(/(^|\W)(if)$/i.test(a))return Yd(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(a)&&!/(αβγ)$/.test(a))return Yd(n,void 0,s=>/(:|,|;|.|\u0393|\u0394|\u0398|\u039B|\u039E|\u03A0|\u03A3|\u03A5|\u03A6|\u03A8|\u03A9|[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5)/u.test(s.value)),!0;if(i==="?"||i==="."&&!/[\d-+]\.$/.test(a))return!0}return!1}function eg(e,t){if(!e.isSelectionEditable||!e.keystrokeCaptionVisible)return;const r=mh(),n=e.element.getBoundingClientRect();r.style.left=`${n.left}px`,r.style.top=`${n.top-64}px`,r.innerHTML=window.MathfieldElement.createHTML(""+(tf(t)||t)+""+r.innerHTML),r.style.visibility="visible",setTimeout(()=>{r.childNodes.length>0&&r.childNodes[r.childNodes.length-1].remove(),r.childNodes.length===0&&(r.style.visibility="hidden")},3e3)}function tg(e){if(e.keystrokeCaptionVisible=!e.keystrokeCaptionVisible,e.keystrokeCaptionVisible){const t=mh();t.innerHTML=""}else{const t=Pd("mathlive-keystroke-caption-panel");t.style.visibility="hidden"}return!1}function mh(){const e=document.getElementById("mathlive-keystroke-caption-panel");return e||(Yi("keystroke-caption"),Yi("core"),Pd("mathlive-keystroke-caption-panel"))}function rg(){document.getElementById("mathlive-keystroke-caption-panel")&&(nf("mathlive-keystroke-caption-panel"),pa("core"),pa("keystroke-caption"))}function gh(e,t){var r,n,i;const{model:a}=e,s=Wf(t);if(t.isTrusted){Zp(t);const I=Hc();e.keyboardLayout!==I.id&&(e.keyboardLayout=I.id,e._keybindings=void 0)}if(clearTimeout(e.inlineShortcutBufferFlushTimer),e.inlineShortcutBufferFlushTimer=0,eg(e,s),t.isTrusted&&t.defaultPrevented)return e.flushInlineShortcutBuffer(),!1;let u,d="",h;const p=e.inlineShortcutBuffer;if(e.isSelectionEditable){if(a.mode==="math")if(s==="[Backspace]")p.pop();else if(!Id(t))e.flushInlineShortcutBuffer();else{const I=Ol(t),$=[...(n=(r=p[p.length-1])==null?void 0:r.keystrokes)!=null?n:[],I];p.push({state:a.getState(),keystrokes:$,leftSiblings:ng(e)});let se=0,Ze="";for(;!u&&se<$.length;)h=p.length-($.length-se),Ze=$.slice(se).join(""),u=Bc(p[h].leftSiblings,Ze,e.options.inlineShortcuts),!u&&/^[a-zA-Z][a-zA-Z0-9]+?([_\^][a-zA-Z0-9\*\+\-]+?)?$/.test(Ze)&&(u=e.options.onInlineShortcut(e,Ze)),se+=1;e.flushInlineShortcutBuffer({defer:!0})}e.options.smartMode&&(u?e.switchMode("math"):Qm(e,s,t)&&(e.switchMode({math:"text",text:"math"}[a.mode]),d=""))}if(!u){if(d||(d=Yp(e.keybindings,a.mode,t)),!d&&(s==="[Enter]"||s==="[Return]")){let I=!1;return a.contentWillChange({inputType:"insertLineBreak"})&&(e.host&&(I=!e.host.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))),I||t.preventDefault&&(t.preventDefault(),t.stopPropagation()),a.contentDidChange({inputType:"insertLineBreak"})),I}if((!d||s==="[Space]")&&a.mode==="math"){if(s==="[Space]"){if(e.adoptStyle="none",e.flushInlineShortcutBuffer(),e.options.mathModeSpace)return Qr.insert(a,e.options.mathModeSpace,{format:"latex",mode:"math"}),e.snapshot("insert-space"),d="",e.dirty=!0,e.scrollIntoView(),t.preventDefault&&(t.preventDefault(),t.stopPropagation()),!1;const I=a.at(a.position+1),$=a.at(a.position-1);if((I==null?void 0:I.mode)==="text"||($==null?void 0:$.mode)==="text")return Qr.insert(a," ",{mode:"text"}),e.snapshot("insert-space"),e.dirty=!0,e.scrollIntoView(),!1}(i=a.at(a.position))!=null&&i.isDigit()&&window.MathfieldElement.decimalSeparator===","&&Ol(t)===","&&(d="insertDecimalSeparator")}}if(!u&&!d){if(a.mathfield.smartFence){if(gf(a,Ol(t),e.effectiveStyle))return e.dirty=!0,e.scrollIntoView(),t.preventDefault&&t.preventDefault(),!1}else{const{parent:I}=a.at(a.position);if(I instanceof ln&&I.rightDelim==="?"&&a.at(a.position).isLastSibling&&/^[)}\]|]$/.test(s))return e.snapshot(),I.isDirty=!0,I.rightDelim=s,a.position+=1,a.selectionDidChange(),a.contentDidChange({data:Ol(t),inputType:"insertText"}),e.snapshot("insert-fence"),e.dirty=!0,e.scrollIntoView(),t.preventDefault&&t.preventDefault(),!1;if(!a.selectionIsCollapsed){const $=Ol(t);if($==="("||$==="{"||$==="["){const se={"(":"(","{":"\\lbrace","[":"\\lbrack"}[$],Ze={"(":")","{":"\\rbrace","[":"\\rbrack"}[$],[ee,De]=Qn(a.selection);return e.snapshot(),a.position=De,Qr.insert(a,Ze,{format:"latex"}),a.position=ee,Qr.insert(a,se,{format:"latex"}),a.setSelection(ee+1,De+1),a.contentDidChange({data:$,inputType:"insertText"}),e.snapshot("insert-fence"),e.dirty=!0,e.scrollIntoView(),t.preventDefault&&t.preventDefault(),!1}}}return!0}const y=a.at(Math.max(a.position,a.anchor)),{parent:M}=y;if(d==="moveAfterParent"&&(M==null?void 0:M.type)==="leftright"&&y.isLastSibling&&e.options.smartFence&&gf(a,".",e.defaultStyle)&&(d="",xn(e)),e.keyboardDelegate.cancelComposition(),d)e.executeCommand(d);else if(u){const I=e.effectiveStyle;a.setState(p[h].state);const $=p[p.length-1].keystrokes;for(const se of $)Qr.insert(a,se,{silenceNotifications:!0,style:I});e.snapshot("insert-shortcut"),a.setState(p[h].state),a.deferNotifications({content:!0,selection:!0,data:u,type:"insertText"},()=>(Qr.insert(a,u,{format:"latex",style:I}),pf(e.model),u.endsWith(" ")&&(e.switchMode("text"),Qr.insert(a," ",{style:I,mode:"text"})),e.snapshot(),a.selectionIsCollapsed||e.flushInlineShortcutBuffer(),!0)),e.dirty=!0,a.announce("replacement")}return e.scrollIntoView(),t.preventDefault&&t.preventDefault(),!1}function mf(e,t,r){const{model:n}=e;if(!e.isSelectionEditable){n.announce("plonk");return}r!=null||(r={}),r.focus&&e.focus(),r.feedback&&window.MathfieldElement.playSound("keypress"),typeof r.mode=="string"&&(e.switchMode(r.mode),e.snapshot());let i=ed(t);const a=window.mathVirtualKeyboard;if(a!=null&&a.isShifted&&(i=typeof i=="string"?i.toUpperCase():i.map(d=>d.toUpperCase())),r.simulateKeystroke){let d=!0;for(const h of i)gh(e,new KeyboardEvent("keypress",{key:h}))&&(d=!1);if(d)return}const s=n.at(n.position),u=S(S({},s.computedStyle),e.defaultStyle);if(n.selectionIsCollapsed||(n.deleteAtoms(Qn(n.selection)),e.snapshot("delete")),n.mode==="latex")n.deferNotifications({content:!0,selection:!0,data:t,type:"insertText"},()=>{Td(e);for(const d of i)Qr.insert(n,d);e.snapshot("insert-latex"),Vc(e)});else if(n.mode==="text"){for(const d of i)Qr.insert(n,d,{style:u});e.snapshot("insert-text")}else if(n.mode==="math")for(const d of i)ig(e,d,u,s);e.dirty=!0,e.scrollIntoView()}function ng(e){const t=e.model,r=[];let n=t.at(Math.min(t.position,t.anchor));for(;n.type!=="first";)r.push(n),n=n.leftSibling;return r}function ig(e,t,r,n){const i=e.model;let a={"^":"moveToSuperscript",_:"moveToSubscript"," ":"moveAfterParent"}[t];if(t===" "&&e.options.mathModeSpace&&(a=["insert",e.options.mathModeSpace]),a){e.executeCommand(a);return}if(/\d/.test(t)&&e.options.smartSuperscript&&n.parentBranch==="superscript"&&n.parent.type!=="mop"&&n.parent.type!=="operator"&&n.parent.type!=="extensible-symbol"&&n.hasNoSiblings){ag(i),Qr.insert(i,t,{style:r}),e.snapshot(),dh(i),e.snapshot();return}if(/[a-zA-Z0-9]/.test(t)&&e.adoptStyle!=="none"){const s=e.adoptStyle==="left"?n:n.parent?n.rightSibling:null;(s==null?void 0:s.type)==="mord"&&/[a-zA-Z0-9]/.test(s.value)&&(r=S({},r),s.style.variant&&(r.variant=s.style.variant),s.style.variantStyle&&(r.variantStyle=s.style.variantStyle))}Qr.insert(i,t,{style:r}),e.snapshot(`insert-${i.at(i.position).type}`)}function ag(e){e.selectionIsCollapsed||(e.deleteAtoms(Qn(e.selection)),e.mathfield.snapshot("delete"))}function gf(e,t,r){if(!t||e.mode!=="math")return!1;const n=e.at(e.position),{parent:i}=n,a={"(":"(",")":")","{":"\\lbrace","}":"\\rbrace","[":"\\lbrack","]":"\\rbrack","|":"|"}[t];if(!a)return!1;const s=kl[a],u=El[a];if(!e.selectionIsCollapsed){e.mathfield.snapshot();const[d,h]=Qn(e.selection),p=e.extractAtoms([d,h]),y=i.addChildrenAfter([new ln("left...right",p,{leftDelim:a,rightDelim:u})],e.at(d));return e.setSelection(e.offsetOf(y.firstChild),e.offsetOf(y.lastChild)),e.mathfield.snapshot("insert-fence"),e.contentDidChange({data:a,inputType:"insertText"}),!0}if(a==="|"){const d=i instanceof ln?i.leftDelim+i.rightDelim:"";if(d==="\\lbrace\\rbrace"||d==="\\{\\}"||d==="\\lbrace?")return e.mathfield.snapshot(),Qr.insert(e,"\\,\\middle\\vert\\,",{format:"latex",style:r}),e.mathfield.snapshot("insert-fence"),e.contentDidChange({data:a,inputType:"insertText"}),!0}if(u){if(i instanceof ln&&i.firstChild===n&&(i.leftDelim==="?"||i.leftDelim==="."))return i.leftDelim=a,i.isDirty=!0,e.mathfield.snapshot(),e.contentDidChange({data:a,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0;if(!(i instanceof ln)){let y=n;for(;y&&!(y.type==="mclose"&&y.value===u);)y=y.rightSibling;if(y){e.mathfield.snapshot();const M=e.extractAtoms([e.offsetOf(n),e.offsetOf(y)]);return M.pop(),i.addChildrenAfter([new ln("left...right",M,{leftDelim:a,rightDelim:u})],n),e.position=e.offsetOf(i.firstChild)+1,e.contentDidChange({data:a,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0}}const d=e.offsetOf(n.lastSibling);let h;for(h=e.position;h<=d;h++){const y=e.at(h);if(y instanceof ln&&(y.leftDelim==="?"||y.leftDelim===".")&&vh(a,y.rightDelim))break}const p=e.at(h);if(h<=d&&p instanceof ln){p.leftDelim=a,e.mathfield.snapshot();let y=e.extractAtoms([e.position,h-1]);return y=y.filter(M=>M.type!=="first"),p.addChildren(y,p.parentBranch),e.position+=1,e.contentDidChange({data:a,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0}if(i instanceof ln&&(i.leftDelim==="?"||i.leftDelim===".")&&vh(a,i.rightDelim)){i.isDirty=!0,i.leftDelim=a,e.mathfield.snapshot();const y=e.extractAtoms([e.offsetOf(n.firstSibling),e.position]);for(const M of y)i.parent.addChildBefore(M,i);return e.contentDidChange({data:a,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0}if(!(i instanceof ln&&i.leftDelim==="|")){if(e.mathfield.snapshot(),Qr.insert(e,`\\left${a}\\right?`,{format:"latex",style:r}),n.lastSibling.type!=="first"){const y=e.offsetOf(n.lastSibling),M=e.extractAtoms([e.position,y]);e.at(e.position).body=M,e.position-=1}return e.mathfield.snapshot("insert-fence"),!0}}if(s){let d=n;for(;d;){if(d.type==="mopen"&&d.value===s){e.mathfield.snapshot();const I=d.leftSibling,$=e.extractAtoms([e.offsetOf(d.leftSibling),e.offsetOf(n)]);$.shift();const se=new ln("left...right",$,{leftDelim:s,rightDelim:a});return i.addChildrenAfter([se],I),e.position=e.offsetOf(se),e.contentDidChange({data:a,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0}d=d.leftSibling}if(i instanceof ln&&n.isLastSibling&&vf(i.leftDelim,a))return e.mathfield.snapshot(),i.isDirty=!0,i.rightDelim=a,e.position+=1,e.contentDidChange({data:a,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0;const h=e.offsetOf(n.firstSibling);let p;for(p=e.position;p>=h;p--){const I=e.at(p);if(I instanceof ln&&(I.rightDelim==="?"||I.rightDelim===".")&&vf(I.leftDelim,a))break}const y=e.at(p);if(p>=h&&y instanceof ln)return e.mathfield.snapshot(),y.rightDelim=a,y.addChildren(e.extractAtoms([p,e.position]),y.parentBranch),e.contentDidChange({data:a,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0;if(i instanceof ln&&(i.rightDelim==="?"||i.rightDelim===".")&&vf(i.leftDelim,a))return e.mathfield.snapshot(),i.isDirty=!0,i.rightDelim=a,i.parent.addChildren(e.extractAtoms([e.position,e.offsetOf(n.lastSibling)]),i.parentBranch),e.position=e.offsetOf(i),e.contentDidChange({data:a,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0;const M=i.parent;return M instanceof ln&&(M.rightDelim==="?"||M.rightDelim===".")&&e.at(e.position).isLastSibling?(e.position=e.offsetOf(M),gf(e,a,r)):!1}return!1}function vf(e,t){return e?["(","\\lparen","{","\\{","\\lbrace","[","\\lbrack"].includes(e)?[")","\\rparen","}","\\}","\\rbrace","]","\\rbrack"].includes(t):El[e]===t:!0}function vh(e,t){return t?[")","\\rparen","}","\\}","\\rbrace","]","\\rbrack"].includes(t)?["(","\\lparen","{","\\{","\\lbrace","[","\\lbrack"].includes(e):kl[t]===e:!0}Vi({undo:e=>(e.undo(),!0),redo:e=>(e.redo(),!0),scrollIntoView:e=>(e.scrollIntoView(),!0),scrollToStart:e=>(e.field.scroll(0,0),!0),scrollToEnd:e=>{const t=e.field.getBoundingClientRect();return e.field.scroll(t.left-window.scrollX,0),!0},toggleKeystrokeCaption:tg,toggleContextMenu:e=>{const t=e.toggleContextMenu();return t||e.model.announce("plonk"),t},plonk:e=>(e.model.announce("plonk"),!0),switchMode:(e,t,r,n)=>(e.switchMode(t,r,n),!0),insert:(e,t,r)=>e.insert(t,r),typedText:(e,t,r)=>(mf(e,t,r),!0),insertDecimalSeparator:e=>{const t=e.model;return t.mode==="math"&&window.MathfieldElement.decimalSeparator===","&&t.at(Math.max(t.position,t.anchor)).isDigit()?(e.insert("{,}",{format:"latex"}),e.snapshot("insert-mord"),!0):(e.insert("."),!0)},commit:e=>{var t;return e.model.contentWillChange({inputType:"insertLineBreak"})&&((t=e.host)==null||t.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),e.model.contentDidChange({inputType:"insertLineBreak"})),!0},insertPrompt:(e,t,r)=>{const n=e.getPrompts();let i="prompt-"+Date.now().toString(36).slice(-2)+Math.floor(Math.random()*1e5).toString(36),a=0;for(;n.includes(i)&&a<100;){if(a===99)return console.error("could not find a unique ID after 100 tries"),!1;i="prompt-"+Date.now().toString(36).slice(-2)+Math.floor(Math.random()*1e5).toString(36),a++}return e.insert(`\\placeholder[${t!=null?t:i}]{}`,r),!0}}),Vi({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"}),Vi({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"),!0):(navigator.clipboard.readText().then(t=>{t&&e.model.contentWillChange({inputType:"insertFromPaste",data:t})?(e.stopCoalescingUndo(),e.stopRecording(),e.insert(t,{mode:e.model.mode})&&(Vc(e),e.startRecording(),e.snapshot("paste"),e.model.contentDidChange({inputType:"insertFromPaste"}),xn(e))):e.model.announce("plonk"),e.startRecording()}),!0))},{target:"mathfield",canUndo:!0,changeContent:!0,changeSelection:!0});function og(e,t){e.flushInlineShortcutBuffer(),e.stopCoalescingUndo();const r=bf(e,t),{model:n}=e;return n.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=S(S({},e.defaultStyle),r)):e.model.deferNotifications({content:!0,type:"insertText"},()=>{n.selection.ranges.forEach(i=>uf(n,i,r,{operation:"toggle"})),e.snapshot("style-change")}),!0}Vi({applyStyle:og},{target:"mathfield",canUndo:!0,changeContent:!0});function bf(e,t){var r,n,i,a,s,u,d,h,p,y;const M={};if(typeof t.color=="string"){const $=(n=e.colorMap((r=t.color)!=null?r:t.verbatimColor))!=null?n:"none";$!==t.color&&(M.verbatimColor=(i=t.verbatimColor)!=null?i:t.color),M.color=$}if(typeof t.backgroundColor=="string"){const $=(s=e.backgroundColorMap((a=t.backgroundColor)!=null?a:t.verbatimBackgroundColor))!=null?s:"none";$!==t.backgroundColor&&(M.verbatimBackgroundColor=(u=t.verbatimBackgroundColor)!=null?u:t.backgroundColor),M.backgroundColor=$}typeof t.fontFamily=="string"&&(M.fontFamily=t.fontFamily),typeof t.series=="string"&&(M.fontSeries=t.series),typeof t.fontSeries=="string"&&(M.fontSeries=t.fontSeries.toLowerCase()),M.fontSeries&&(M.fontSeries=(d={bold:"b",medium:"m",normal:"m"}[M.fontSeries])!=null?d:M.fontSeries),typeof t.shape=="string"&&(M.fontShape=t.shape),typeof t.fontShape=="string"&&(M.fontShape=t.fontShape.toLowerCase()),M.fontShape&&(M.fontShape=(h={italic:"it",up:"n",upright:"n",normal:"n"}[M.fontShape])!=null?h:M.fontShape),t.variant&&(M.variant=t.variant.toLowerCase()),t.variantStyle&&(M.variantStyle=t.variantStyle.toLowerCase());const I=(p=t.size)!=null?p:t.fontSize;return typeof I=="number"?M.fontSize=Math.max(1,Math.min(10,I)):typeof I=="string"&&(M.fontSize=(y={size1:1,size2:2,size3:3,size4:4,size5:5,size6:6,size7:7,size8:8,size9:9,size10:10}[I.toLowerCase()])!=null?y:{tiny:1,scriptsize:2,footnotesize:3,small:4,normal:5,normalsize:5,large:6,Large:7,LARGE:8,huge:9,Huge:10}[I]),M}function yf(e){let[t,r]=Qn(e.selection);if(t=bh(e,t,"backward"),r=bh(e,r,"forward"),t===r){const n=e.at(t);if(n.type==="leftright")return e.setSelection(e.offsetOf(n.firstChild)-1,r);if(n.type==="first"&&(n.parent.type==="leftright"||n.parent.type==="surd"))return e.setSelection(t-1,e.offsetOf(n.parent.lastChild)+1);e.setSelection(t-1,r)}else e.setSelection(t,r);return!0}function bh(e,t,r){var n,i,a;let s=e.at(t);if(!s)return t;const u=r==="forward"?1:-1;if(s.mode==="text"){for(;s&&!(s.mode!=="text"||!K.test(s.value));)t+=u,s=e.at(t);return r==="backward"?t-1:t}if(s.mode==="latex"){if(/[a-zA-Z\*]/.test(s.value))if(r==="backward")for(;s&&s.mode==="latex"&&s.value!=="\\"&&/[a-zA-Z]/.test(s.value);)t+=u,s=e.at(t);else for(;s&&s.mode==="latex"&&/[a-zA-Z\*]/.test(s.value);)t+=u,s=e.at(t);else if(s.value==="{"){if(r==="forward"){for(;s&&s.mode==="latex"&&s.value!=="}";)t+=u,s=e.at(t);return t}return t-1}else if(s.value==="}"){if(r==="backward"){for(;s&&s.mode==="latex"&&s.value!=="{";)t+=u,s=e.at(t);return t-1}return t}return t-1}if(s.mode==="math"){if(s.isDigit()){for(;(n=e.at(t+u))!=null&&n.isDigit();)t+=u;return r==="backward"?t-1:t}if(s.style.variant||s.style.variantStyle){let d=(i=e.at(t))==null?void 0:i.style;for(;d&&d.variant===s.style.variant&&d.variantStyle===s.style.variantStyle;)d=(a=e.at(t+u))==null?void 0:a.style,t+=u;return r==="backward"?t-1:t}return t}return t}Vi({selectGroup:e=>{const t=yf(e);return t||e.announce("plonk"),t},selectAll:e=>e.setSelection(0,e.lastOffset),extendSelectionForward:e=>io(e,"forward",{extend:!0}),extendSelectionBackward:e=>io(e,"backward",{extend:!0}),extendToNextWord:e=>Wl(e,"forward",{extend:!0}),extendToPreviousWord:e=>Wl(e,"backward",{extend:!0}),extendSelectionUpward:e=>io(e,"upward",{extend:!0}),extendSelectionDownward:e=>io(e,"downward",{extend:!0}),extendToNextBoundary:e=>Wl(e,"forward",{extend:!0}),extendToPreviousBoundary:e=>Wl(e,"backward",{extend:!0}),extendToGroupStart:e=>{const t=e.setSelection(e.anchor,e.offsetOf(e.at(e.position).firstSibling));return t||e.announce("plonk"),t},extendToGroupEnd:e=>{const t=e.setSelection(e.anchor,e.offsetOf(e.at(e.position).lastSibling));return t||e.announce("plonk"),t},extendToMathFieldStart:e=>{const t=e.setSelection(e.anchor,0);return t||e.announce("plonk"),t},extendToMathFieldEnd:e=>{const t=e.setSelection(e.anchor,e.lastOffset);return t||e.announce("plonk"),t}},{target:"model",changeSelection:!0});var Fs=null,Xc=0,Qd=class ya{static start(t,r,n,i){var a;ya.element=t,(a=ya.controller)==null||a.abort(),ya.controller=new AbortController;const s={signal:ya.controller.signal};"PointerEvent"in window?(t.addEventListener("pointermove",n,s),t.addEventListener("pointerup",i,s),t.addEventListener("pointercancel",i,s),xf(r)&&(ya.pointerId=r.pointerId,t.setPointerCapture(r.pointerId))):(window.addEventListener("mousemove",n,s),window.addEventListener("blur",i,s),window.addEventListener("mouseup",i,s))}static stop(){var t;(t=ya.controller)==null||t.abort(),ya.controller=void 0,typeof ya.pointerId=="number"&&(ya.element.releasePointerCapture(ya.pointerId),ya.pointerId=void 0)}};function xf(e){return e!==null&&globalThis.PointerEvent!==void 0&&e instanceof PointerEvent}function yh(e,t){var r;if(t.buttons>1)return;e.atomBoundsCache=new Map;const n=e;let i,a=!1,s=!1,u="none",d=!1,h=!1;const p=t.clientX,y=t.clientY,M=Date.now(),I=n.field,$=setInterval(()=>{d?I.scroll({top:0,left:I.scrollLeft-16}):h&&I.scroll({top:0,left:I.scrollLeft+16})},32);function se(){Qd.stop(),a=!1,clearInterval($),e.element.classList.remove("tracking"),t&&t.preventDefault()}function Ze(De){if(!n.hasFocus()){se();return}const Je=De.clientX,Te=De.clientY,yt=xf(De)&&De.pointerType==="touch"?20:5;if(Date.now()Rt.right,d=Je=0&&Ar>=0&&(n.model.extendSelectionTo(Dt,Ar),xn(e)),s&&yf(n.model)}Fs&&Math.abs(Fs.x-p)<5&&Math.abs(Fs.y-y)<5&&Date.now()=ee.left&&p<=ee.right&&y>=ee.top&&y<=ee.bottom){if(e.flushInlineShortcutBuffer(),e.adoptStyle="left",i=Jc(e,p,y,{bias:0}),i>=0){if(e.element.classList.add("tracking"),t.shiftKey){const De=e.model.selectionIsCollapsed;e.model.extendSelectionTo(e.model.anchor,i),jf(e.model)||De?u="all":u="selection"}else e.model.at(i).type==="placeholder"?(e.model.setSelection(i-1,i),u="selection"):((r=e.model.at(i).rightSibling)==null?void 0:r.type)==="placeholder"?(e.model.setSelection(i,i+1),u="selection"):(e.model.position=i,jf(e.model)?u="all":u="selection");e.defaultStyle={},t.detail===3||Xc>2?(se(),(t.detail===3||Xc===3)&&(e.model.selection={ranges:[[0,e.model.lastOffset]]},u="all")):a||(a=!0,Qd.start(I,t,Ze,se),(t.detail===2||Xc===2)&&(s=!0,yf(e.model),u="all"))}e.hasFocus()||(u="none",e.focus({preventScroll:!0}))}else Fs=null;e.stopCoalescingUndo(),u!=="none"&&(e.model.selectionIsCollapsed&&(u="all"),xn(e)),t.preventDefault()}function sg(e,t,r){if(e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom)return 0;const n=e-(r.left+r.right)/2,i=t-(r.top+r.bottom)/2;return n*n+i*i}function xh(e,t,r,n,i){if(!r.id)return[1/0,null];if(t.has(r.id))return t.get(r.id);const a=Es(e,r);if(!a)return[1/0,null];let s=[1/0,null];if(r.hasChildren&&!r.captureSelection&&n>=a.left&&n<=a.right)for(const u of r.children){const d=xh(e,t,u,n,i);d[0]<=s[0]&&(s=d)}return s[1]||(s=[sg(n,i,a),r]),t.set(r.id,s),s}function lg(e,t,r){const[,n]=xh(e,new Map,e.model.root,t,r);return n}function Jc(e,t,r,n){var i;const a=e.field.querySelector(".ML__latex").getBoundingClientRect();if(!a)return 0;if(t>a.right||r>a.bottom+8)return e.model.lastOffset;if(t0?(h.push(p),p=[$]):p.push($);p.length>0&&h.push(p);let y=Number(d.parentBranch[0]),M=Number(d.parentBranch[1]);const I=d.parent.maxColumns;for(;d.parent.colCount-M=I&&(M=0,d.parent.addRowAfter(y),y++),d.parent.setCell(y,M,h[$])}else d.parent.addChildrenAfter(s.filter(h=>h.type!=="first"),d);return u.position=u.offsetOf(s[s.length-1]),u.contentDidChange({inputType:"insertFromPaste"}),xn(e),!0}}catch(a){}if(i=typeof t!="string"?t.getData("application/json"):"",i&&window.MathfieldElement.computeEngine)try{const a=JSON.parse(i);if(typeof a=="object"&&"latex"in a&&a.latex&&(r=a.latex),!r){const s=window.MathfieldElement.computeEngine.box(a);s&&!s.has("Error")&&(r=s.latex)}r||(n="latex")}catch(a){}if(!r&&typeof t!="string"&&(r=t.getData("application/x-latex"),r&&(n="latex")),r||(r=typeof t=="string"?t:t.getData("text/plain")),r){let a;return[a,r]=ld(r),n==="auto"&&a&&(n="latex"),e.stopCoalescingUndo(),e.stopRecording(),this.insert(e.model,r,{format:n})&&(e.startRecording(),e.snapshot("paste"),xn(e)),e.startRecording(),!0}return!1}insert(e,t,r){var n,i;const a=typeof t=="string"?t:(i=(n=window.MathfieldElement.computeEngine)==null?void 0:n.box(t).latex)!=null?i:"";if(!r.silenceNotifications&&!e.contentWillChange({data:a,inputType:"insertText"}))return!1;r.insertionMode||(r.insertionMode="replaceSelection"),r.selectionMode||(r.selectionMode="placeholder"),r.format||(r.format="auto");const{silenceNotifications:s}=e;r.silenceNotifications&&(e.silenceNotifications=!0);const u=e.silenceNotifications;e.silenceNotifications=!0;const d={"?":"\\placeholder{}","@":"\\placeholder{}"};d[0]=r.insertionMode==="replaceAll"?"":e.getValue(e.selection,"latex-unstyled"),r.insertionMode==="replaceSelection"&&!e.selectionIsCollapsed?e.deleteAtoms(Qn(e.selection)):r.insertionMode==="replaceAll"?(e.root.setChildren([],"body"),e.position=0):r.insertionMode==="insertBefore"?e.collapseSelection("backward"):r.insertionMode==="insertAfter"&&e.collapseSelection("forward"),!e.at(e.position).isLastSibling&&e.at(e.position+1).type==="placeholder"?e.deleteAtoms([e.position,e.position+1]):e.at(e.position).type==="placeholder"&&e.deleteAtoms([e.position-1,e.position]);let h=-1;d[0]?d["@"]=d[0]:typeof t=="string"&&/(^|[^\\])#@/.test(t)&&(h=dg(e),h>=0&&(d["@"]=e.getValue(h,e.position,"latex"))),d[0]||(d[0]=d["?"]);let p=!1;const y=Je=>(p=!0,d[Je]);let[M,I]=wh(e,t,y,r);if(!I)return!1;const $=I.length===1&&I[0].type==="genfrac";$&&h>=0&&typeof e.mathfield.options.isImplicitFunction=="function"&&e.mathfield.options.isImplicitFunction(e.at(e.position).command)?(d["@"]=d["?"],p=!1,[M,I]=wh(e,t,y,r)):h>=0&&e.deleteAtoms([h,e.position]);const{parent:se}=e.at(e.position),Ze=se.hasEmptyBranch("body");if($&&M!=="latex"&&e.mathfield.options.removeExtraneousParentheses&&se instanceof ln&&se.leftDelim==="("&&Ze){const Je=se.parent,Te=se.parentBranch;Je.removeChild(se),Je.setChildren(I,Te)}const ee=e.at(e.position);ee.parent.addChildrenAfter(I,ee),M==="latex"&&typeof t=="string"&&(se==null?void 0:se.type)==="root"&&Ze&&!p&&(se.verbatimLatex=t),e.silenceNotifications=u;const De=I[I.length-1];if(r.selectionMode==="placeholder"){const Je=I.flatMap(Te=>[Te,...Te.children]).find(Te=>Te.type==="placeholder");if(Je){const Te=e.offsetOf(Je);e.setSelection(Te-1,Te),e.announce("move")}else De&&(e.position=e.offsetOf(De))}else r.selectionMode==="before"||(r.selectionMode==="after"?De&&(e.position=e.offsetOf(De)):r.selectionMode==="item"&&e.setSelection(e.anchor,e.offsetOf(De)));return e.contentDidChange({data:a,inputType:"insertText"}),e.silenceNotifications=s,!0}};function wh(e,t,r,n){var i;let a,s=[];if(typeof t!="string"||n.format==="math-json"){const u=window.MathfieldElement.computeEngine;if(!u)return["math-json",[]];[a,t]=["latex",u.box(t).latex],s=b(t,{context:e.mathfield.context})}else typeof t=="string"&&n.format==="ascii-math"?([a,t]=qa(t,{format:"ascii-math",inlineShortcuts:e.mathfield.options.inlineShortcuts}),s=b(t,{context:e.mathfield.context}),a!=="latex"&&e.mathfield.options.removeExtraneousParentheses&&e0(s)):(n.format==="auto"||(i=n.format)!=null&&i.startsWith("latex"))&&(n.format==="auto"&&([a,t]=qa(t,{format:"auto",inlineShortcuts:e.mathfield.options.inlineShortcuts})),n.format==="latex"&&([,t]=ld(t)),s=b(t,{context:e.mathfield.context,args:r}),n.format!=="latex"&&e.mathfield.options.removeExtraneousParentheses&&e0(s));return Qo(s,n.style),[a!=null?a:"latex",s]}function ug(e){if(!e||(console.assert(e[0].type==="first"),e.length>1))return null;const t=e[0];return t instanceof ln&&t.leftDelim==="("&&t.rightDelim===")"?t.removeBranch("body"):null}function e0(e){if(e){for(let t=0;e[t];t++){const r=e[t];if(r instanceof ln&&r.leftDelim==="("){let n=0,i=0,a=0;for(let s=0;r.body[s];s++)r.body[s].type==="genfrac"&&(n++,i=s),a++;a===0&&n===1&&(e[t]=r.body[i])}}for(const t of e){for(const r of t.branches)if(!t.hasEmptyBranch(r)){e0(t.branch(r));const n=ug(t.branch(r));n&&t.setChildren(n,r)}if(t instanceof jr)for(const r of t.cells)e0(r)}}}function dg(e){let t=e.at(e.position);if(t.mode==="text"){for(;!t.isFirstSibling&&t.mode==="text";)t=t.leftSibling;return e.offsetOf(t)}const r=t;let n=!1;if(t.type==="mclose"){const i=kl[t.value];for(;!t.isFirstSibling&&!(t.type==="mopen"&&t.value===i);)t=t.leftSibling;t.isFirstSibling||(t=t.leftSibling),n=!0}else t.type==="leftright"&&(t=t.leftSibling,n=!0);if(n)for(;!t.isFirstSibling&&(t.isFunction||Sh(t));)t=t.leftSibling;else{const i=[];for(;!t.isFirstSibling&&(Sh(t)||i.length>0);)t.type==="mclose"&&i.unshift(t.value),t.type==="mopen"&&i.length>0&&t.value===kl[i[0]]&&i.shift(),t=t.leftSibling}return r===t?-1:e.offsetOf(t)}function Sh(e){return e.isDigit()?!0:e.type&&/^(mord|surd|subsup|leftright|mop|mclose)$/.test(e.type)?!e.isExtensibleSymbol:!1}new cg;var fg=class extends Qr{constructor(){super("text")}onPaste(e,t){if(!t)return!1;const r=typeof t=="string"?t:t.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"),xn(e)),e.startRecording(),!0):!1}insert(e,t,r={}){if(!e.contentWillChange({data:t,inputType:"insertText"}))return!1;r.insertionMode||(r.insertionMode="replaceSelection"),r.selectionMode||(r.selectionMode="placeholder"),r.format||(r.format="auto");const{silenceNotifications:n}=e;r.silenceNotifications&&(e.silenceNotifications=!0);const i=e.silenceNotifications;e.silenceNotifications=!0,r.insertionMode==="replaceSelection"&&!e.selectionIsCollapsed?e.deleteAtoms(Qn(e.selection)):r.insertionMode==="replaceAll"?(e.root.setChildren([],"body"),e.position=0):r.insertionMode==="insertBefore"?e.collapseSelection("backward"):r.insertionMode==="insertAfter"&&e.collapseSelection("forward");const a=hg(t,e.mathfield.context);if(Qo(a,r.style),!a)return!1;const s=e.at(e.position),u=s.parent.addChildrenAfter(a,s);return e.silenceNotifications=i,r.selectionMode==="before"||(r.selectionMode==="item"?e.setSelection(e.anchor,e.offsetOf(u)):u&&(e.position=e.offsetOf(u))),e.contentDidChange({data:t,inputType:"insertText"}),e.silenceNotifications=n,!0}};function hg(e,t){return e=e.replace(/\\/g,"\\textbackslash "),e=e.replace(/#/g,"\\#"),e=e.replace(/\$/g,"\\$"),e=e.replace(/%/g,"\\%"),e=e.replace(/&/g,"\\&"),e=e.replace(/_/g,"\\_"),e=e.replace(/{/g,"\\textbraceleft "),e=e.replace(/}/g,"\\textbraceright "),e=e.replace(/lbrace/g,"\\textbraceleft "),e=e.replace(/rbrace/g,"\\textbraceright "),e=e.replace(/\^/g,"\\textasciicircum "),e=e.replace(/~/g,"\\textasciitilde "),e=e.replace(/£/g,"\\textsterling "),b(e,{context:t,parseMode:"text"})}new fg;function ao(e){return{value:e.model.getValue(),selectionIsCollapsed:e.model.selectionIsCollapsed,canUndo:e.canUndo(),canRedo:e.canRedo(),style:e.selectionStyle,mode:e.model.mode}}var on=4,$i=20,In=2*($i+on),t0=(e,t)=>`
`,_h=(e,t)=>`
`,r0=(e,t,r)=>`
`,pg=`
`,mg=e=>`
`,gg=e=>`
`,Mh=e=>`
`,vg=e=>`
`,bg=e=>`
`,yg=e=>`
`,xg=e=>`
`,wg=e=>`
`,wf={matrix:mg,pmatrix:gg,bmatrix:vg,Bmatrix:Mh,vmatrix:bg,Vmatrix:yg},Sf={cases:xg,rcases:wg,Bmatrix:Mh};function Sg(e){var t,r;const n=(t=e.model.parentEnvironment)==null?void 0:t.array;if(!n)return;let i=0;n.forEach($=>{(!i||$.length>i)&&(i=$.length)});let a=document.getElementById("mathlive-environment-popover");a||(a=Pd("mathlive-environment-popover"),Yi("environment-popover"),Yi("core"),a.setAttribute("aria-hidden","true"));let s;const u=a.querySelector(".MLEP__environment-controls");u?s=u:(s=document.createElement("div"),a.innerHTML="",a.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=pg;let d=[],h="";const p=e.model.parentEnvironment.environmentName;if(_d(p)){const $=Mg(p);h=wf[$]("active");const se=wf,{[$]:Ze}=se,ee=je(se,[Ge($)]);d=Object.values(ee).map(De=>De("inactive"))}else if(q0(p)){const $=Cg(p);h=Sf[$]("active");const se=Sf,{[$]:Ze}=se,ee=je(se,[Ge($)]);d=Object.values(ee).map(De=>De("inactive"))}else X0(p)&&(h=wf.matrix("active"),d=Object.values(Sf).map($=>$("inactive")));const y=document.createElement("div");y.className="MLEP__environment-delimiter-controls",y.style.display="flex",y.style.flexDirection="column",y.innerHTML=`
${h}
${d.join("")}
`,h&&s.appendChild(y),s.querySelectorAll("[data-command]").forEach($=>{const se=$.dataset.command;let Ze=se;try{Ze=JSON.parse(se)}catch(ee){}$.addEventListener("mousedown",ee=>ee.preventDefault()),Ze&&$.addEventListener("click",()=>e.executeCommand(Ze))});const I=(r=e.field)==null?void 0:r.getBoundingClientRect();I&&(a.style.top=`${window.scrollY+(I.top-a.clientHeight-15)}px`,a.style.left=`${I.left+20}px`,a.classList.add("is-visible"))}function _f(){const e=document.getElementById("mathlive-environment-popover");e==null||e.classList.remove("is-visible")}function _g(){document.getElementById("mathlive-environment-popover")&&(nf("mathlive-environment-popover"),pa("environment-popover"),pa("core"))}function n0(e){if(!e.hasFocus())return;let t=!1;if(e.model.mode==="math"){const r=e.model.parentEnvironment;if(r!=null&&r.array&&G0(r.environmentName)){const n=e.options.environmentPopoverPolicy;t=n==="auto"||n==="on"}}t?Sg(e):_f()}function Mg(e){return e.replace("*","")}function Cg(e){return e==="dcases"?"cases":e}function Ch(e){const t=getComputedStyle(e).direction;return t==="ltr"||t==="rtl"?t:"ltr"}function Eh(e,t,r){return t==="left"||t==="leading"&&r==="ltr"||t==="trailing"&&r==="rtl"?e.left:e.right}function Mf(e,t,r,n){return r==="middle"?e-t/2:r==="start"&&n==="rtl"||r==="end"&&n==="ltr"||r==="top"||r==="right"?Math.max(0,e-t):e}function Eg(e,t,r,n){return r==="middle"?e-t/2:r==="start"&&n==="ltr"||r==="end"&&n==="rtl"||r==="top"||r==="right"?e:e-t}function kg(e,t){var r,n,i;const a=(r=Ch(e))!=null?r:"ltr";e.style.position="fixed",e.style.left="",e.style.top="",e.style.right="",e.style.bottom="",e.style.height="",e.style.width="";const s=e.getBoundingClientRect(),u=Number.isFinite(t.maxHeight)?Math.min(t.maxHeight,window.innerHeight):window.innerHeight;let d=Math.min(u,(n=t.height)!=null?n:s.height),h=Mf(t.location.y,d,t.verticalPos,a);h+d>window.innerHeight-8&&(t.alternateLocation?(h=Mf(t.alternateLocation.y,d,t.verticalPos,a),h+d>window.innerHeight-8&&(h=void 0)):h=void 0),Number.isFinite(h)||(h=Math.max(8,window.innerHeight-8-d),8+d>window.innerHeight-8&&(e.style.bottom="8px")),d=Math.min(h+d,window.innerHeight-8)-h;const p=Number.isFinite(t.maxWidth)?Math.min(t.maxWidth,window.innerWidth):window.innerWidth;let y=Math.min(p,(i=t.width)!=null?i:s.width),M=Mf(t.location.x,y,t.horizontalPos,a);M+y>window.innerWidth-8&&(t.alternateLocation?(M=Eg(t.alternateLocation.x,y,t.verticalPos,a),M+y>window.innerWidth-8&&(M=void 0)):M=void 0),Number.isFinite(M)||(M=Math.max(8,window.innerWidth-8-y),8+y>window.innerWidth-8&&(e.style.right="8px")),y=Math.min(M+y,window.innerWidth-8)-M,a==="rtl"?e.style.right=`${Math.ceil(window.innerWidth-M-y).toString()}px`:e.style.left=`${Math.ceil(M).toString()}px`,e.style.top=`${Math.ceil(h).toString()}px`,d!==s.height&&(e.style.height=`${Math.ceil(d).toString()}px`),y!==s.width&&(e.style.width=`${Math.ceil(y).toString()}px`)}function Dg(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function Vl(e){return"submenu"in e}function oo(e){return"type"in e&&e.type==="command"||"onMenuSelect"in e||"id"in e}function Cf(e){return"type"in e&&e.type==="divider"}function Ef(e){return"type"in e&&e.type==="heading"}var kh={};function kf(e){let t=kh[e];if(!t){let r;switch(e){case"checkmark":r=`
`;break;case"trailing-chevron":r='';break;case"mixedmark":r=''}if(r){const n=document.createElement("template");n.innerHTML=r,kh[e]=n,t=n}}if(t){if("content"in t)return t.content.cloneNode(!0);const r=document.createElement("svg");return r.innerHTML=t.innerHTML,r}}var Dh=80,Ah=class{constructor(e,t){this._element=null;var r;this.parentMenu=t,this._declaration=e,Vl(e)?(this.type="submenu",this.submenu=new Lh(e.submenu,{parentMenu:t,submenuClass:e.submenuClass,columnCount:e.columnCount})):this.type=(r=e.type)!=null?r:"command",this.hasCheck=oo(e)&&e.checked!==void 0}get rootMenu(){return this.parentMenu.rootMenu}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}dispose(){var e,t;(e=this._abortController)==null||e.abort(),this._abortController=void 0,(t=this._element)==null||t.remove(),this._element=null,this.submenu&&this.submenu.dispose(),this.submenu=void 0}get menuItem(){return this._declaration}get label(){var e;return(e=this._label)!=null?e:""}set label(e){e===void 0&&(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,t;return(t=(e=this.element)==null?void 0:e.classList.contains("active"))!=null?t:!1}set active(e){this.element&&this.element.classList.toggle("active",e)}updateState(e){var t,r,n;const i=this._declaration;if(Cf(i)){this.enabled=!1,this.checked=!1;return}Ef(i)&&(this.enabled=!1,this.checked=!1,this.visible=!0),oo(i)&&(this.checked=oo(i)&&((t=Zl(i.checked,e))!=null?t:!1)),(oo(i)||Vl(i))&&(this.enabled=(r=Zl(i.enabled,e))!=null?r:!0,this.visible=(n=Zl(i.visible,e))!=null?n:!0,this.visible&&this.enabled&&this.submenu&&(this.submenu.updateState(e),this.submenu.visible||(this.visible=!1))),(oo(i)||Ef(i)||Vl(i))&&(this.label=Zl(i.label,e),this.tooltip=Zl(i.tooltip,e),this.ariaLabel=Zl(i.ariaLabel,e)),this._element&&this.updateElement()}set dirty(e){console.assert(e===!0),e&&this.parentMenu&&(this.parentMenu.dirty=!0)}updateElement(){if(!this.visible||!this.element)return;const e=this.element;e.textContent="",this.enabled?e.removeAttribute("aria-disabled"):e.setAttribute("aria-disabled","true"),this.checked===!0?(e.setAttribute("aria-checked","true"),e.append(kf("checkmark"))):this.checked==="mixed"?(e.setAttribute("aria-checked","mixed"),e.append(kf("mixedmark"))):e.removeAttribute("aria-checked"),this.ariaLabel&&e.setAttribute("aria-label",this.ariaLabel);const t=document.createElement("span");if(t.className=this.parentMenu.hasCheck?"label indent":"label",this.type==="heading"&&t.classList.add("heading"),t.innerHTML=this.label,e.append(t),this._tooltip&&e.setAttribute("data-tooltip",this._tooltip),oo(this._declaration)&&this._declaration.keyboardShortcut){const r=document.createElement("kbd");r.innerHTML=tf(this._declaration.keyboardShortcut),e.append(r)}this.type==="submenu"&&e.append(kf("trailing-chevron"))}get element(){if(this._element)return this._element;if(Cf(this._declaration)){const r=document.createElement("li");return r.setAttribute("part","menu-divider"),r.setAttribute("role","divider"),this._element=r,r}const e=document.createElement("li");this._element=e,(oo(this._declaration)||Ef(this._declaration)||Vl(this._declaration))&&this._declaration.class&&(e.className=this._declaration.class),e.setAttribute("part","menu-item"),e.setAttribute("tabindex","-1"),this.hasCheck?e.setAttribute("role","menuitemcheckbox"):e.setAttribute("role","menuitem"),this.type==="submenu"&&(e.setAttribute("aria-haspopup","true"),e.setAttribute("aria-expanded","false"));const t=this.abortController.signal;return e.addEventListener("pointerenter",this,{signal:t}),e.addEventListener("pointerleave",this,{signal:t}),e.addEventListener("pointerup",this,{signal:t}),e.addEventListener("click",this,{signal:t}),this._element}dispatchSelect(){if(!oo(this._declaration))return;const e=new CustomEvent("menu-select",{cancelable:!0,bubbles:!0,detail:{modifiers:this.rootMenu.modifiers,id:this._declaration.id,data:this._declaration.data}});this.parentMenu.dispatchEvent(e)&&typeof this._declaration.onMenuSelect=="function"&&this._declaration.onMenuSelect({modifiers:this.rootMenu.modifiers,id:this._declaration.id,data:this._declaration.data})}handleEvent(e){var t;if(!(!this.visible||!this.enabled)){if(e.type==="click"){this.rootMenu.state==="modal"&&this.select(),e.stopPropagation(),e.preventDefault();return}if(e.type==="pointerenter"){const r=e;this.rootMenu.cancelDelayedOperation(),this.parentMenu.isSubmenuOpen&&((t=this.parentMenu.activeMenuItem)!=null&&t.movingTowardSubmenu(r))?this.rootMenu.scheduleOperation(()=>{this.parentMenu.activeMenuItem=this,this.openSubmenu()}):(this.parentMenu.activeMenuItem=this,this.openSubmenu({withDelay:!0}));return}if(e.type==="pointerleave"){this.rootMenu.activeSubmenu===this.parentMenu&&(this.parentMenu.activeMenuItem=null);return}if(e.type==="pointerup"){this.rootMenu.state!=="modal"&&this.select(),e.stopPropagation(),e.preventDefault();return}}}select(){if(this.rootMenu.cancelDelayedOperation(),this.type==="submenu"){this.openSubmenu();return}this.active=!1,setTimeout(()=>{this.active=!0,setTimeout(()=>{this.rootMenu.hide(),this.dispatchSelect()},Dh)},Dh)}openSubmenu(e){var t;if(this.type!=="submenu"||!this.element)return;if((t=e==null?void 0:e.withDelay)!=null&&t){this.rootMenu.scheduleOperation(()=>this.openSubmenu());return}const r=this.element.getBoundingClientRect(),n=Ch(this.element);this.submenu.show({container:this.rootMenu.element.parentNode,location:{x:Eh(r,"trailing",n),y:r.top-4},alternateLocation:{x:Eh(r,"leading",n),y:r.top-4}})}movingTowardSubmenu(e){if(!this.element||this.type!=="submenu")return!1;const t=this.rootMenu.lastMoveEvent;if(!t)return!1;const r=e.timeStamp-t.timeStamp;if(r>500)return!1;const n=e.clientX-t.clientX;if(Ag(n,t.clientY-e.clientY,r)<=.2)return!1;let a="right";if(this.submenu.element){const s=this.submenu.element.getBoundingClientRect(),u=this.element.getBoundingClientRect();s.left0:n<0}};function Ag(e,t,r){return Math.hypot(e,t)/r}function Zl(e,t){return e===void 0||typeof e!="function"?e:(t!=null||(t={alt:!1,control:!1,shift:!1,meta:!1}),e(t))}var Lh=class Ql{constructor(t,r){this._element=null,this._activeMenuItem=null,this._dirty=!0;var n,i;this.parentMenu=(n=r==null?void 0:r.parentMenu)!=null?n:null,this._submenuClass=r==null?void 0:r.submenuClass,this.columnCount=(i=r==null?void 0:r.columnCount)!=null?i:1,this.isSubmenuOpen=!1,this.menuItems=t}get children(){return this._menuItems}set menuItems(t){const r=this.parentMenu;this.dispose(),this.parentMenu=r,t=[...t],this._menuItems=t.map(n=>n.onCreate?n.onCreate(n,this):new Ah(n,this)),this.hasCheck=void 0,this.dirty=!0}dispose(){var t;this.hide(),this._element&&this._element.remove(),this._abortController&&this._abortController.abort(),(t=this._menuItems)==null||t.forEach(r=>r.dispose()),this._menuItems=[],this._activeMenuItem=null,this.parentMenu=null}handleEvent(t){if(t.type==="wheel"&&this._element){const r=t;this._element.scrollBy(0,r.deltaY),t.stopPropagation()}}dispatchEvent(t){return this.rootMenu.dispatchEvent(t)}get rootMenu(){return this.parentMenu.rootMenu}updateState(t){var r,n,i;this._menuItems.forEach(h=>h.updateState(t));const a=this.hasCheck;this.hasCheck=this._menuItems.some(h=>h.visible&&h.hasCheck),this.hasCheck!==a&&this._menuItems.forEach(h=>h.updateState(t));let s,u=0;for(const h of this._menuItems)h.type==="heading"?(s&&u===0&&(s.visible=!1),s=h,u=0):h.type==="divider"&&s?(s.visible=u>0,s=void 0,u=0):s&&h.visible&&(u+=1);s&&(s.visible=u>0);let d=!0;for(const h of this._menuItems)h.type==="divider"?(h.visible=!d,d=!0):h.visible&&(d=!1);(r=this.activeMenuItem)!=null&&r.visible||(this.activeMenuItem=null),!((n=this.activeMenuItem)!=null&&n.enabled)&&((i=this.activeMenuItem)==null?void 0:i.type)==="submenu"&&this._activeMenuItem.submenu.hide(),this._dirty=!1}get enabled(){return this.updateIfDirty(),this._menuItems.some(t=>t.type!=="divider"&&t.visible&&t.enabled)}get visible(){return this.updateIfDirty(),this._menuItems.some(t=>t.type!=="divider"&&t.visible)}set dirty(t){console.assert(t===!0),this._dirty!==t&&t&&this.parentMenu&&(this._dirty=!0,this.parentMenu.dirty=!0)}updateIfDirty(){this._dirty&&this.updateState(this.rootMenu.modifiers)}updateElement(){var t;if(this._element){this._element.textContent="";for(const{element:r,visible:n}of this._menuItems)r&&n&&this._element.append(r);(t=this._element.querySelector("li:first-of-type"))==null||t.setAttribute("tabindex","0")}}get element(){if(this._element)return this._element;const t=document.createElement("menu");t.setAttribute("role","menu"),t.setAttribute("tabindex","-1"),t.setAttribute("aria-orientation","vertical"),t.setAttribute("part","ui-menu-container"),this._submenuClass&&t.classList.add(this._submenuClass),t.classList.add("ui-menu-container"),this._abortController||(this._abortController=new AbortController);const r=this._abortController.signal;return t.addEventListener("focus",this,{signal:r}),t.addEventListener("wheel",this,{passive:!0,signal:r}),this._element=t,this.updateElement(),t}get activeMenuItem(){return this._activeMenuItem}set activeMenuItem(t){var r,n,i,a;if(this.rootMenu.cancelDelayedOperation(),t!==this._activeMenuItem){if(this.activeMenuItem){const s=this.activeMenuItem;s.active=!1,(r=s.submenu)==null||r.hide()}if(!((n=t==null?void 0:t.visible)==null||n)){this._activeMenuItem=null;return}this._activeMenuItem=t,t&&(t.active=!0)}t?(i=t.element)==null||i.focus({preventScroll:!0}):(a=this._element)==null||a.focus({preventScroll:!0})}get firstMenuItem(){this.updateIfDirty();let t=0,r=!1;const n=this._menuItems;for(;!r&&t<=n.length-1;){const i=n[t];r=i.type!=="divider"&&i.visible&&i.enabled,t+=1}return r?n[t-1]:null}get lastMenuItem(){this.updateIfDirty();const t=this._menuItems;let r=t.length-1,n=!1;for(;!n&&r>=0;){const i=t[r];n=i.type!=="divider"&&i.visible&&i.enabled,r-=1}return n?t[r+1]:null}nextMenuItem(t){if(t===0)return this._activeMenuItem;if(!this._activeMenuItem)return t>0?this.firstMenuItem:this.lastMenuItem;if(!this.firstMenuItem||!this.lastMenuItem||!this._activeMenuItem)return null;this.updateIfDirty();const r=this._menuItems.indexOf(this.firstMenuItem),n=this._menuItems.indexOf(this.lastMenuItem);let i=this._menuItems.indexOf(this._activeMenuItem),a=1;for(;i>=r&&i<=n;){i+=t>0?1:-1;const s=this._menuItems[i];if(!s)break;if(s.visible&&s.enabled){if(a===Math.abs(t))return this._menuItems[i];a+=1}}return t>0?this.lastMenuItem:this.firstMenuItem}getMenuItemColumn(t){this.updateIfDirty();const n=this._menuItems.filter(i=>i.visible&&i.enabled).indexOf(t);return n<0?-1:n%this.columnCount}static get collator(){return Ql._collator||(Ql._collator=new Intl.Collator(void 0,{usage:"search",sensitivity:"base"})),Ql._collator}findMenuItem(t){var r;this.updateIfDirty();const n=this._menuItems.filter(u=>u.type!=="divider"&&u.visible&&u.enabled);if(n.length===0)return null;const i=Math.max(...n.map(u=>u.label.length))-t.length;if(i<0)return null;let a=null,s=0;for(;sQl.collator.compare(t,u.label.substring(s,t.length))===0))!=null?r:null,s++;return a}show(t){return!this.visible||!t.container?!1:(this.updateElement(),t.container.appendChild(this.element),Nt()&&(this.element.popover="manual",this.element.showPopover()),t.location&&kg(this.element,{location:t.location,alternateLocation:t.alternateLocation,verticalPos:"bottom",horizontalPos:"start"}),this.element.focus({preventScroll:!0}),this.parentMenu&&(this.parentMenu.openSubmenu=this),!0)}hide(){var t,r,n,i,a;this.openSubmenu=null,this.activeMenuItem=null,this.parentMenu&&(this.parentMenu.openSubmenu=null),Nt()&&((t=this._element)!=null&&t.popover)&&this.element.hidePopover(),(n=(r=this.parentMenu)==null?void 0:r.element)==null||n.focus(),(a=(i=this._element)==null?void 0:i.parentNode)==null||a.removeChild(this._element)}set openSubmenu(t){var r,n,i,a;const s=t!==null;((r=this.activeMenuItem)==null?void 0:r.type)==="submenu"&&((n=this.activeMenuItem.element)==null||n.setAttribute("aria-expanded",s.toString())),(a=(i=this.activeMenuItem)==null?void 0:i.element)==null||a.classList.toggle("is-submenu-open",s),this.isSubmenuOpen=s}},Bh=class Ip extends Lh{constructor(t,r){var n;super(t),this.state="closed",this.typingBufferResetTimer=0,this.hysteresisTimer=0,this._updating=!1,this._host=(n=r==null?void 0:r.host)!=null?n:null,this.isDynamic=t.some(Ih),this._modifiers={shift:!1,control:!1,alt:!1,meta:!1},this.typingBuffer="",this.state="closed"}get modifiers(){return this._modifiers}set modifiers(t){Gp(this._modifiers,t)||(this._modifiers=t,this.dirty=!0)}get activeSubmenu(){let t=this;for(;t.isSubmenuOpen;)t=t.activeMenuItem.submenu;return t}set dirty(t){this._updating||(console.assert(t===!0),this._dirty!==t&&(this._dirty=!0,t&&setTimeout(()=>{this.updateState(this.modifiers),this.updateElement()})))}updateState(t){this._updating=!0,this.modifiers=t!=null?t:this.modifiers,super.updateState(this.modifiers),this._updating=!1}handleKeyupEvent(t){this.isDynamic&&(this.modifiers=Bs(t)),t.stopImmediatePropagation()}handleKeydownEvent(t){var r,n,i;if(t.key==="Tab"||t.key==="Escape"){this.hide();return}this.isDynamic&&(this.modifiers=Bs(t));let a=!0;const s=this.activeSubmenu,u=s.activeMenuItem;switch(t.key){case" ":case"Space":case"Return":case"Enter":u==null||u.select(Bs(t));break;case"ArrowRight":if((u==null?void 0:u.type)==="submenu")u.select(Bs(t)),this.activeSubmenu.activeMenuItem=this.activeSubmenu.firstMenuItem;else if(!u)s.activeMenuItem=s.firstMenuItem;else{const d=(r=s.getMenuItemColumn(u))!=null?r:-1;if(d>=0&&d<((n=s.columnCount)!=null?n:1)-1){const h=s.nextMenuItem(1);h&&(s.activeMenuItem=h)}}break;case"ArrowLeft":if(s===this.rootMenu)u||(s.activeMenuItem=s.firstMenuItem);else if((u&&(i=s.getMenuItemColumn(u))!=null?i:-1)<=0||!u){s.hide();const h=s.parentMenu.activeMenuItem;if(h){const{element:p}=h;p==null||p.focus(),p==null||p.classList.remove("is-submenu-open")}}else{const h=s.nextMenuItem(-1);h&&(s.activeMenuItem=h)}break;case"ArrowDown":s.activeMenuItem=s.nextMenuItem(s.columnCount);break;case"ArrowUp":s.activeMenuItem=s.nextMenuItem(-s.columnCount);break;case"Home":case"PageUp":s.activeMenuItem=s.firstMenuItem;break;case"End":case"PageDown":s.activeMenuItem=s.lastMenuItem;break;case"Backspace":if(this.typingBuffer&&(this.typingBuffer=this.typingBuffer.slice(0,-1),this.typingBuffer)){clearTimeout(this.typingBufferResetTimer);const d=s.findMenuItem(this.typingBuffer);d&&(s.activeMenuItem=d),this.typingBufferResetTimer=setTimeout(()=>{this.typingBuffer=""},500)}break;default:if(Id(t)){isFinite(this.typingBufferResetTimer)&&clearTimeout(this.typingBufferResetTimer),this.typingBuffer+=t.key;const d=s.findMenuItem(this.typingBuffer);d&&(s.activeMenuItem=d),this.typingBufferResetTimer=setTimeout(()=>{this.typingBuffer=""},500)}else a=!1}a&&(t.preventDefault(),t.stopPropagation())}handleEvent(t){if(t.type==="keydown")this.handleKeydownEvent(t);else if(t.type==="keyup")this.handleKeyupEvent(t);else if(t.type==="pointermove")this.lastMoveEvent=t;else if(t.type==="pointerup"&&t.target===this.scrim)Number.isFinite(this.rootMenu._openTimestamp)&&Date.now()-this.rootMenu._openTimestamp<120?this.state="modal":this.state==="modal"&&this.hide();else if(t.type==="contextmenu"){t.preventDefault(),t.stopPropagation();return}super.handleEvent(t)}dispatchEvent(t){return this._host?this._host.dispatchEvent(t):!0}get scrim(){return ro.element}connectScrim(t){const r=this.scrim;r.addEventListener("pointerup",this),r.addEventListener("contextmenu",this),r.addEventListener("keydown",this),r.addEventListener("keyup",this),r.addEventListener("pointermove",this),ro.open({root:t,onDismiss:()=>this.hide()})}disconnectScrim(){const t=this.scrim;t.removeEventListener("pointerup",this),t.removeEventListener("contextmenu",this),t.removeEventListener("keydown",this),t.removeEventListener("keyup",this),t.removeEventListener("pointermove",this),ro.state==="open"&&ro.scrim.close()}get rootMenu(){return this}show(t){return this._onDismiss=t==null?void 0:t.onDismiss,t!=null&&t.modifiers&&(this.modifiers=t.modifiers),this.updateState(),this.connectScrim(t==null?void 0:t.target),super.show(_(S({},t),{container:this.scrim}))?(this._openTimestamp=Date.now(),this.state="open",!0):(this.disconnectScrim(),!1)}hide(){this.cancelDelayedOperation(),this.state!==void 0&&(this.state!=="closed"&&(this.activeMenuItem=null,ro.element.parentElement.focus(),super.hide(),this.state="closed",this.disconnectScrim()),this._onDismiss&&(this._onDismiss(),this._onDismiss=void 0))}scheduleOperation(t){this.cancelDelayedOperation();const r=Ip.SUBMENU_DELAY;if(r<=0){t();return}this.hysteresisTimer=setTimeout(()=>{this.hysteresisTimer=0,t()},r)}cancelDelayedOperation(){this.hysteresisTimer&&(clearTimeout(this.hysteresisTimer),this.hysteresisTimer=0)}};Bh.SUBMENU_DELAY=120;var Lg=Bh;function Ih(e){return Cf(e)?!1:typeof e.label=="function"||typeof e.ariaLabel=="function"||typeof e.tooltip=="function"||(oo(e)||Vl(e))&&(typeof e.enabled=="function"||typeof e.visible=="function")||oo(e)&&typeof e.checked=="function"?!0:Vl(e)?e.submenu.some(Ih):!1}var i0=class{};i0.DELAY=300,i0.MAX_DISTANCE=10;function Bg(e){return new Promise((t,r)=>{const n=Bd(e);n||t(!1);let i=n;const a=setTimeout(()=>{s.abort(),t(Dg(i,n){if(h.type==="pointerup"||h.type==="pointercancel")clearTimeout(a),s.abort(),t(!1);else if(h.type==="pointermove"){const p=Bd(h);p&&(i=p)}},{passive:!0,signal:u})})}function $h(e,t,r){return rs(this,null,function*(){if(e.type==="contextmenu"){const n=e;if(r.show({target:t,location:Bd(n),modifiers:Bs(n)}))return e.preventDefault(),e.stopPropagation(),!0}if(e.type==="keydown"){const n=e;if(n.code==="ContextMenu"||n.code==="F10"&&n.shiftKey){const i=t==null?void 0:t.getBoundingClientRect();if(i&&r.show({target:t,location:{x:Math.ceil(i.left+i.width/2),y:Math.ceil(i.top+i.height/2)},modifiers:Bs(n)}))return e.preventDefault(),e.stopPropagation(),!0}}if(e.type==="pointerdown"&&e.pointerType!=="mouse"&&e.button===0){let n=e.target;for(;n&&t!==n;)n=n.parentNode;if(!n||!r.visible)return!1;const i=Bd(e);if(yield Bg(e))return r.state!=="closed"?!1:(r.show({target:t,location:i}),!0)}return!1})}var Th={acute:714,grave:715,dot:729,ddot:168,mathring:730,tilde:126,bar:713,breve:728,check:711,hat:94,vec:8407};W(Object.keys(Th),"{body:auto}",{createAtom:e=>new Cl(_(S({},e),{body:ce(e.args[0]),accentChar:Th[e.command.slice(1)]}))}),W(["widehat","widecheck","widetilde"],"{body:auto}",{createAtom:e=>{const t=it(ce(e.args[0]));return new Cl(_(S({},e),{body:ce(e.args[0]),svgAccent:e.command.slice(1)+(t.length>5?"4":["1","1","2","2","3","3"][t.length])}))}}),W(["overarc","overparen","wideparen"],"{body:auto}",{createAtom:e=>new Cl(_(S({},e),{body:ce(e.args[0]),svgAccent:"overarc"}))}),W(["underarc","underparen"],"{body:auto}",{createAtom:e=>new Kr(_(S({},e),{body:ce(e.args[0]),svgBelow:"underarc"}))}),W("utilde","{body:auto}",{createAtom:e=>{const t=ce(e.args[0]),r=it(t),n="widetilde"+(r.length>5?"4":["1","1","2","2","3","3"][r.length]);return new Kr(_(S({},e),{body:t,svgBelow:n,boxType:Ss(t)}))}}),W("^","{:string}",{createAtom:e=>{var t;return new _e(_(S({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&(t={a:"\xE2",e:"\xEA",i:"\xEE",o:"\xF4",u:"\xFB",A:"\xC2",E:"\xCA",I:"\xCE",O:"\xD4",U:"\xDB"}[e.args[0]])!=null?t:"^"}))}}),W("`","{:string}",{createAtom:e=>{var t;return new _e(_(S({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&(t={a:"\xE0",e:"\xE8",i:"\xEC",o:"\xF2",u:"\xF9",A:"\xC0",E:"\xC8",I:"\xCC",O:"\xD2",U:"\xD9"}[e.args[0]])!=null?t:"`"}))}}),W("'","{:string}",{createAtom:e=>{var t;return new _e(_(S({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&(t={a:"\xE1",e:"\xE9",i:"\xED",o:"\xF3",u:"\xFA",A:"\xC1",E:"\xC9",I:"\xCD",O:"\xD3",U:"\xDA"}[e.args[0]])!=null?t:"'"}))}}),W('"',"{:string}",{createAtom:e=>{var t,r;return new _e(_(S({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:(t=e.args)!=null&&t[0]?(r={a:"\xE4",e:"\xEB",i:"\xEF",o:"\xF6",u:"\xFC",A:"\xC4",E:"\xCB",I:"\xCB",O:"\xD6",U:"\xDC"}[e.args[0]])!=null?r:'"'+e.args[0]:'"'}))}}),W(".","{:string}",{createAtom:e=>{var t,r;return new _e(_(S({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:(t=e.args)!=null&&t[0]?(r={a:"\u0227",e:"\u0117",i:"\u0307i",o:"\u022F",u:"\u0307u",A:"\u0226",E:"\u0116",I:"\u0130",O:"\u022E",U:"\u0307U"}[e.args[0]])!=null?r:"."+e.args[0]:"."}))}}),W("=","{:string}",{createAtom:e=>{var t,r;return new _e(_(S({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:(t=e.args)!=null&&t[0]?(r={a:"\u0101",e:"\u0113",i:"\u012B",o:"\u014D",u:"\u016B",A:"\u0100",E:"\u0112",I:"\u012A",O:"\u014C",U:"\u016A"}[e.args[0]])!=null?r:"="+e.args[0]:"="}))}}),W("~","{:string}",{createAtom:e=>{var t;return new _e(_(S({type:"mord"},e),{isFunction:!1,limits:"adjacent",value:e.args[0]&&(t={n:"\xF1",N:"\xD1",a:"\xE3",o:"\xF5",A:"\xC3",O:"\xD5"}[e.args[0]])!=null?t:"\xB4"}))}}),W("c","{:string}",{createAtom:e=>{var t;return new _e(_(S({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&(t={c:"\xE7",C:"\xC7"}[e.args[0]])!=null?t:""}))}}),W("enclose","{notation:string}[style:string]{body:auto}",{createAtom:e=>{var t,r;const n=e.args,i={strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",backgroundcolor:"transparent",padding:"auto",shadow:"none",svgStrokeStyle:void 0,borderStyle:void 0,style:(t=e.style)!=null?t:{}};if(n[1]){const s=n[1].split(/,(?![^(]*\)(?:(?:[^(]*\)){2})*[^"]*$)/);for(const u of s){const d=u.match(/\s*(\S+)\s+(\S+)\s+(.*)/);if(d)i.strokeWidth=d[1],i.strokeStyle=d[2],i.strokeColor=d[3];else{const h=u.match(/\s*([a-z]*)\s*=\s*"(.*)"/);h&&(h[1]==="mathbackground"?i.backgroundcolor=h[2]:h[1]==="mathcolor"?i.strokeColor=h[2]:h[1]==="padding"?i.padding=h[2]:h[1]==="shadow"&&(i.shadow=h[2]))}}i.strokeStyle==="dashed"?i.svgStrokeStyle="5,5":i.strokeStyle==="dotted"&&(i.svgStrokeStyle="1,5")}i.borderStyle=`${i.strokeWidth} ${i.strokeStyle} ${i.strokeColor}`;const a={};return((r=n[0])!=null?r:"").split(/[, ]/).filter(s=>s.length>0).forEach(s=>{a[s.toLowerCase()]=!0}),new qe(e.command,ce(n[2]),a,i)}}),W("cancel","{body:auto}",{createAtom:e=>{var t;return new qe(e.command,ce(e.args[0]),{updiagonalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:(t=e.style)!=null?t:{}})}}),W("bcancel","{body:auto}",{createAtom:e=>{var t;return new qe(e.command,ce(e.args[0]),{downdiagonalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:(t=e.style)!=null?t:{}})}}),W("xcancel","{body:auto}",{createAtom:e=>{var t;return new qe(e.command,ce(e.args[0]),{updiagonalstrike:!0,downdiagonalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:(t=e.style)!=null?t:{}})}}),W(["overrightarrow","overleftarrow","Overrightarrow","overleftharpoon","overrightharpoon","overleftrightarrow","overlinesegment","overgroup"],"{:auto}",{createAtom:e=>{var t;return new Kr(_(S({},e),{body:ce((t=e.args)==null?void 0:t[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"rel",svgAbove:e.command.slice(1)}))}}),W("overbrace","{:auto}",{createAtom:e=>new Kr(_(S({},e),{body:ce(e.args[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"ord",svgAbove:e.command.slice(1)}))}),W(["underrightarrow","underleftarrow","underleftrightarrow","underlinesegment","undergroup"],"{:auto}",{createAtom:e=>new Kr(_(S({},e),{body:ce(e.args[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"rel",svgBelow:e.command.slice(1)}))}),W(["underbrace"],"{:auto}",{createAtom:e=>new Kr(_(S({},e),{body:ce(e.args[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"ord",svgBelow:e.command.slice(1)}))}),W(["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 t,r,n,i,a;return new Kr(_(S({},e),{svgBody:e.command.slice(1),above:((r=ce((t=e.args)==null?void 0:t[1]))==null?void 0:r.length)===0?void 0:ce((n=e.args)==null?void 0:n[1]),below:(a=ce((i=e.args)==null?void 0:i[0]))!=null?a:null,skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,paddedLabels:!0,boxType:"rel"}))},serialize:(e,t)=>e.command+(e.hasEmptyBranch("below")?"":`[${e.belowToLatex(t)}]`)+`{${e.aboveToLatex(t)}}${e.supsubToLatex(t)}`}),W(["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 li(e.command.slice(1),_(S({},e),{limits:"adjacent",isFunction:!0,variant:"main",variantStyle:"up"}))}),W(["liminf","limsup"],"",{ifMode:"math",createAtom:e=>new li({"\\liminf":"lim inf","\\limsup":"lim sup"}[e.command],_(S({},e),{limits:"over-under",variant:"main"}))}),W(["lim","mod"],"",{ifMode:"math",createAtom:e=>new li(e.command.slice(1),_(S({},e),{limits:"over-under",variant:"main"}))}),W(["det","max","min"],"",{ifMode:"math",isFunction:!0,createAtom:e=>new li(e.command.slice(1),_(S({},e),{limits:"over-under",isFunction:!0,variant:"main"}))}),W(["ang"],"{:math}",{ifMode:"math",createAtom:e=>new _e(_(S({},e),{body:ce(e.args[0])})),serialize:(e,t)=>`\\ang{${e.bodyToLatex(t)}}`,render:(e,t)=>{const r=e.createBox(t),n=r.caret;r.caret=void 0;const i=new Ue("\xB0",{style:_(S({},e.style),{variant:"normal",variantStyle:"up"})});return new Ue([r,i],{type:"inner",isSelected:e.isSelected,caret:n})}}),W("sqrt","[index:auto]{radicand:expression}",{ifMode:"math",createAtom:e=>new Wi(_(S({},e),{body:ce(e.args[1]),index:e.args[0]?ce(e.args[0]):void 0}))}),W(["frac","dfrac","tfrac","cfrac","binom","dbinom","tbinom"],"{:expression}{:expression}",{ifMode:"math",createAtom:e=>{const t=S({},e),r=e.command,n=e.args;switch(r){case"\\dfrac":case"\\frac":case"\\tfrac":t.hasBarLine=!0;break;case"\\atopfrac":t.hasBarLine=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":t.hasBarLine=!1,t.leftDelim="(",t.rightDelim=")";break;case"\\cfrac":t.hasBarLine=!0,t.continuousFraction=!0;break;default:}switch(r){case"\\dfrac":case"\\dbinom":t.mathstyleName="displaystyle";break;case"\\tfrac":case"\\tbinom":t.mathstyleName="textstyle";break;default:}return new lr(n[0]?ce(n[0]):[new Ta],n[1]?ce(n[1]):[new Ta],t)},serialize:(e,t)=>{const r=e.aboveToLatex(t),n=e.belowToLatex(t);return/^[0-9]$/.test(r)&&/^[0-9]$/.test(n)?`${e.command}${r}${n}`:an(e.command,r,n)}}),W(["brace","brack"],"",{infix:!0,createAtom:e=>new lr(ce(e.args[0]),ce(e.args[1]),_(S({},e),{hasBarLine:!1,leftDelim:e.command==="\\brace"?"\\lbrace":"\\lbrack",rightDelim:e.command==="\\brace"?"\\rbrace":"\\rbrack"})),serialize:(e,t)=>Cr([e.aboveToLatex(t),e.command,e.belowToLatex(t)])}),W(["over","atop","choose"],"",{infix:!0,createAtom:e=>{let t,r;const n=e.args;return e.command==="\\choose"&&(t="(",r=")"),new lr(ce(n[0]),ce(n[1]),_(S({},e),{hasBarLine:e.command==="\\over",leftDelim:t,rightDelim:r}))},serialize:(e,t)=>Cr([e.aboveToLatex(t),e.command,e.belowToLatex(t)])}),W(["overwithdelims","atopwithdelims"],"{numer:auto}{denom:auto}{left-delim:delim}{right-delim:delim}",{infix:!0,createAtom:e=>{var t,r;const n=e.args;return new lr(ce(n[0]),ce(n[1]),_(S({},e),{leftDelim:(t=n[2])!=null?t:".",rightDelim:(r=n[3])!=null?r:".",hasBarLine:!1}))},serialize:(e,t)=>`${e.aboveToLatex(t)} ${e.command}${e.leftDelim}${e.rightDelim}${e.belowToLatex(t)}`}),W("pdiff","{numerator}{denominator}",{ifMode:"math",createAtom:e=>new lr(ce(e.args[0]),ce(e.args[1]),_(S({},e),{hasBarLine:!0,numerPrefix:"\u2202",denomPrefix:"\u2202"}))}),W(["sum","prod","bigcup","bigcap","coprod","bigvee","bigwedge","biguplus","bigotimes","bigoplus","bigodot","bigsqcup","intop"],"",{ifMode:"math",createAtom:e=>new pn({coprod:"\u2210",bigvee:"\u22C1",bigwedge:"\u22C0",biguplus:"\u2A04",bigcap:"\u22C2",bigcup:"\u22C3",intop:"\u222B",prod:"\u220F",sum:"\u2211",bigotimes:"\u2A02",bigoplus:"\u2A01",bigodot:"\u2A00",bigsqcup:"\u2A06",smallint:"\u222B"}[e.command.slice(1)],_(S({},e),{limits:"auto",variant:"main"}))}),W("smallint","",{ifMode:"math",createAtom:e=>new li("\u222B",_(S({},e),{limits:"adjacent",variant:"main"}))});var Ph={int:"\u222B",iint:"\u222C",iiint:"\u222D",oint:"\u222E",oiint:"\u222F",oiiint:"\u2230",intclockwise:"\u2231",varointclockwise:"\u2232",ointctrclockwise:"\u2233",intctrclockwise:"\u2A11",sqcup:"\u2294",sqcap:"\u2293",uplus:"\u228E",wr:"\u2240",amalg:"\u2A3F",Cap:"\u22D2",Cup:"\u22D3",doublecap:"\u22D2",doublecup:"\u22D3"};W(Object.keys(Ph),"",{ifMode:"math",createAtom:e=>{const t=e.command,r=Ph[t.slice(1)];return new pn(r,_(S({},e),{limits:"adjacent",variant:{"\u22D2":"ams","\u22D3":"ams"}[r]}))}}),W(["Re","Im"],"",{ifMode:"math",createAtom:e=>new li({"\\Re":"\u211C","\\Im":"\u2111"}[e.command],_(S({},e),{limits:"adjacent",isFunction:!0,variant:"fraktur"}))}),W("middle","{:delim}",{ifMode:"math",createAtom:e=>{var t;return new Q(_(S({},e),{delim:(t=e.args[0])!=null?t:"|",size:1}))}}),W("the","{:value}",{createAtom:e=>new _e(_(S({},e),{captureSelection:!0,verbatimLatex:null})),render:(e,t)=>{var r;const n=new Dr({parent:t},e.style);let i="";e.isSelected&&(i+=" ML__selected");const a=n.evaluate(e.args[0]);return new Ue(((r=Zn(a))!=null?r:"").split("").map(s=>new Ue(s,{type:"ord",classes:i,mode:e.mode,isSelected:e.isSelected,style:S({variant:"main"},e.style)})),{type:"lift",style:e.style,caret:e.caret,isSelected:e.isSelected,classes:i}).wrap(n)},serialize:e=>{var t;return`\\the${(t=Zn(e.args[0]))!=null?t:"\\relax"}`}}),W("mathtip","{:auto}{:math}",{createAtom:e=>new ga(_(S({},e),{body:ce(e.args[0]),tooltip:ce(e.args[1]),content:"math"})),serialize:(e,t)=>t.skipStyles?e.bodyToLatex(t):`\\texttip{${e.bodyToLatex(t)}}{${_e.serialize([e.tooltip],_(S({},t),{defaultMode:"math"}))}}`}),W("texttip","{:auto}{:text}",{createAtom:e=>new ga(_(S({},e),{body:ce(e.args[0]),tooltip:ce(e.args[1]),content:"text"})),serialize:(e,t)=>t.skipStyles?e.bodyToLatex(t):`\\texttip{${e.bodyToLatex(t)}}{${_e.serialize([e.tooltip],_(S({},t),{defaultMode:"text"}))}}`}),W("error","{:math}",{createAtom:e=>new _e(_(S({},e),{body:ce(e.args[0])})),serialize:(e,t)=>`\\error{${e.bodyToLatex(t)}}`,render:(e,t)=>e.createBox(t,{classes:"ML__error"})}),W("ensuremath","{:math}",{createAtom:e=>new _e(_(S({},e),{body:ce(e.args[0])})),serialize:(e,t)=>`${e.command}{${e.bodyToLatex(_(S({},t),{defaultMode:"math"}))}}`}),W("color","{:value}",{applyStyle:(e,t,r)=>{var n,i;return{verbatimColor:(n=Zn(t[0]))!=null?n:void 0,color:r.toColor((i=t[0])!=null?i:{string:"red"})}}}),W("textcolor","{:value}{content:auto*}",{applyStyle:(e,t,r)=>{var n,i;return{verbatimColor:(n=Zn(t[0]))!=null?n:void 0,color:r.toColor((i=t[0])!=null?i:{string:"red"})}}}),W("boxed","{content:math}",{createAtom:e=>new eo(_(S({},e),{body:ce(e.args[0]),framecolor:{string:"black"}}))}),W("colorbox","{:value}{:text*}",{applyStyle:(e,t,r)=>{var n,i;return{verbatimBackgroundColor:(n=Zn(t[0]))!=null?n:void 0,backgroundColor:r.toBackgroundColor((i=t[0])!=null?i:{string:"yellow"})}}}),W("fcolorbox","{frame-color:value}{background-color:value}{content:text}",{applyMode:"text",createAtom:e=>{var t,r;return new eo(_(S({},e),{body:ce(e.args[2]),framecolor:(t=e.args[0])!=null?t:{string:"blue"},backgroundcolor:(r=e.args[1])!=null?r:{string:"yellow"}}))},serialize:(e,t)=>{var r,n;return t.skipStyles?e.bodyToLatex(_(S({},t),{defaultMode:"text"})):an(e.command,(r=Zn(e.framecolor))!=null?r:"",(n=Zn(e.backgroundcolor))!=null?n:"",e.bodyToLatex(_(S({},t),{defaultMode:"text"})))}}),W("bbox","[:bbox]{body:auto}",{createAtom:e=>{var t;const r=e.args[0],n=ce(e.args[1]);return r?new eo(_(S({},e),{body:n,padding:r.padding,border:r.border,backgroundcolor:(t=r.backgroundcolor)!=null?t:void 0})):new eo(_(S({},e),{body:n}))},serialize:(e,t)=>{var r,n;if(t.skipStyles)return e.bodyToLatex(t);let i=e.command;if(Number.isFinite(e.padding)||e.border!==void 0||e.backgroundcolor!==void 0){const a=[];e.padding&&a.push((r=Zn(e.padding))!=null?r:""),e.border&&a.push(`border: ${e.border}`),e.backgroundcolor&&a.push((n=Zn(e.backgroundcolor))!=null?n:""),i+=`[${a.join(",")}]`}return an(i,e.bodyToLatex(t))}}),W(["displaystyle","textstyle","scriptstyle","scriptscriptstyle"],"{:rest}",{createAtom:e=>new _e(_(S({},e),{body:ce(e.args[0])})),render:(e,t)=>{const r=new Dr({parent:t,mathstyle:e.command.slice(1)},e.style),n=_e.createBox(r,e.body,{type:"lift"});return e.caret&&(n.caret=e.caret),e.bind(t,n)},serialize:(e,t)=>t.skipStyles?e.bodyToLatex(t):`{${Cr([e.command,e.bodyToLatex(t)])}}`}),W(["tiny","scriptsize","footnotesize","small","normalsize","large","Large","LARGE","huge","Huge"],"",{applyStyle:e=>({fontSize:{"\\tiny":1,"\\scriptsize":2,"\\footnotesize":3,"\\small":4,"\\normalsize":5,"\\large":6,"\\Large":7,"\\LARGE":8,"\\huge":9,"\\Huge":10}[e]})}),W("fontseries","{:string}",{ifMode:"text",applyStyle:(e,t)=>{var r;return{fontSeries:(r=t[0])!=null?r:"auto"}}}),W("fontshape","{:string}",{ifMode:"text",applyStyle:(e,t)=>{var r;return{fontShape:(r=t[0])!=null?r:"auto"}}}),W("fontfamily","{:string}",{ifMode:"text",applyStyle:(e,t)=>{var r;return{fontFamily:(r=t[0])!=null?r:"roman"}}}),W("selectfont","",{ifMode:"text",applyStyle:()=>({})}),W("bf","{:rest}",{applyStyle:()=>({fontSeries:"b",fontShape:"n",fontFamily:"roman"})}),W(["boldsymbol","bm"],"{:math}",{applyMode:"math",createAtom:e=>new _e(_(S({},e),{body:ce(e.args[0])})),serialize:(e,t)=>`${e.command}{${e.bodyToLatex(t)}}`,render:(e,t)=>e.createBox(t,{classes:"ML__boldsymbol"})}),W("bold","{:math*}",{applyMode:"math",applyStyle:()=>({variantStyle:"bold"})}),W("bfseries","{:rest}",{applyMode:"text",applyStyle:()=>({fontSeries:"b"})}),W("mdseries","{:rest}",{applyMode:"text",applyStyle:()=>({fontSeries:"m"})}),W("upshape","{:rest}",{applyMode:"text",applyStyle:()=>({fontShape:"n"})}),W("slshape","{:rest}",{applyMode:"text",applyStyle:()=>({fontShape:"sl"})}),W("scshape","{:rest}",{applyMode:"text",applyStyle:()=>({fontShape:"sc"})}),W("textbf","{:text*}",{applyMode:"text",applyStyle:()=>({fontSeries:"b"})}),W("textmd","{:text*}",{applyMode:"text",applyStyle:()=>({fontSeries:"m"})}),W("textup","{:text*}",{applyMode:"text",applyStyle:()=>({fontShape:"n"})}),W("textnormal","{:text*}",{applyMode:"text",applyStyle:()=>({fontShape:"n",fontSeries:"m"})}),W("textsl","{:text*}",{applyMode:"text",applyStyle:()=>({fontShape:"sl"})}),W("textit","{:text*}",{applyMode:"text",applyStyle:()=>({fontShape:"it"})}),W("textsc","{:text*}",{applyMode:"text",applyStyle:()=>({fontShape:"sc"})}),W("textrm","{:text*}",{applyMode:"text",applyStyle:()=>({fontFamily:"roman"})}),W("textsf","{:text*}",{applyMode:"text",applyStyle:()=>({fontFamily:"sans-serif"})}),W("texttt","{:text*}",{applyMode:"text",applyStyle:()=>({fontFamily:"monospace"})}),W("mathbf","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"normal",variantStyle:"bold"})}),W("mathit","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"main",variantStyle:"italic"})}),W("mathnormal","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"normal",variantStyle:"italic"})}),W("mathbfit","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"main",variantStyle:"bolditalic"})}),W("mathrm","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"normal",variantStyle:"up"})}),W("mathsf","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"sans-serif",variantStyle:"up"})}),W("mathtt","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"monospace",variantStyle:"up"})}),W("it","{:rest}",{applyStyle:()=>({fontSeries:"m",fontShape:"it",fontFamily:"roman",variantStyle:"italic"})}),W("rmfamily","",{applyStyle:()=>({fontFamily:"roman"})}),W("sffamily","",{applyStyle:()=>({fontFamily:"sans-serif"})}),W("ttfamily","",{applyStyle:()=>({fontFamily:"monospace"})}),W(["Bbb","mathbb"],"{:math*}",{applyStyle:()=>({variant:"double-struck",variantStyle:"up"})}),W(["frak","mathfrak"],"{:math*}",{applyStyle:()=>({variant:"fraktur",variantStyle:"up"})}),W("mathcal","{:math*}",{applyStyle:()=>({variant:"calligraphic",variantStyle:"up"})}),W("mathscr","{:math*}",{applyStyle:()=>({variant:"script",variantStyle:"up"})}),W("mbox","{:text}",{ifMode:"math",createAtom:e=>new _e(_(S({},e),{type:"mord",body:ce(e.args[0]),mode:"math"})),serialize:(e,t)=>an("\\mbox",e.bodyToLatex(_(S({},t),{defaultMode:"text"})))}),W("text","{:text}",{ifMode:"math",applyMode:"text"}),W(["class","htmlClass"],"{name:string}{content:auto}",{createAtom:e=>new _e(_(S({},e),{body:ce(e.args[1])})),serialize:(e,t)=>!e.args[0]||t.skipStyles?e.bodyToLatex(t):`${e.command}{${e.args[0]}}{${e.bodyToLatex(t)}}`,render:(e,t)=>{var r;return e.createBox(t,{classes:(r=e.args[0])!=null?r:""})}}),W(["cssId","htmlId"],"{id:string}{content:auto}",{createAtom:e=>new _e(_(S({},e),{body:ce(e.args[1])})),serialize:(e,t)=>{var r;return!((r=e.args)!=null&&r[0])||t.skipStyles?e.bodyToLatex(t):`${e.command}{${e.args[0]}}{${e.bodyToLatex(t)}}`},render:(e,t)=>{var r;const n=e.createBox(t);return n.cssId=(r=e.args[0])!=null?r:"",n}}),W("htmlData","{data:string}{content:auto}",{createAtom:e=>new _e(_(S({},e),{body:ce(e.args[1])})),serialize:(e,t)=>{var r;return!((r=e.args)!=null&&r[0])||t.skipStyles?e.bodyToLatex(t):`\\htmlData{${e.args[0]}}{${e.bodyToLatex(t)}}`},render:(e,t)=>{var r;const n=e.createBox(t);return n.htmlData=(r=e.args[0])!=null?r:"",n}}),W(["style","htmlStyle"],"{data:string}{content:auto}",{createAtom:e=>new _e(_(S({},e),{body:ce(e.args[1])})),serialize:(e,t)=>{var r;return!((r=e.args)!=null&&r[0])||t.skipStyles?e.bodyToLatex(t):`${e.command}{${e.args[0]}}{${e.bodyToLatex(t)}}`},render:(e,t)=>{var r;const n=e.createBox(t);return n.htmlStyle=(r=e.args[0])!=null?r:"",n}}),W("em","{:rest}",{createAtom:e=>new _e(_(S({},e),{body:ce(e.args[0])})),serialize:(e,t)=>t.skipStyles?e.bodyToLatex(t):`{\\em ${e.bodyToLatex(t)}}`,render:(e,t)=>e.createBox(t,{classes:"ML__emph",boxType:"lift"})}),W("emph","{:auto}",{createAtom:e=>new _e(_(S({},e),{body:ce(e.args[1])})),serialize:(e,t)=>t.skipStyles?e.bodyToLatex(t):`\\emph{${e.bodyToLatex(t)}}`,render:(e,t)=>e.createBox(t,{classes:"ML__emph",boxType:"lift"})});var Rh={"\\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}};W(["bigl","Bigl","biggl","Biggl","bigr","Bigr","biggr","Biggr","bigm","Bigm","biggm","Biggm","big","Big","bigg","Bigg"],"{:delim}",{createAtom:e=>{var t;return new We(_(S({},e),{delim:(t=e.args[0])!=null?t:".",size:Rh[e.command].size,delimType:Rh[e.command].mclass}))}}),W(["hspace","hspace*"],"{width:value}",{createAtom:e=>{var t;return new xi(_(S({},e),{width:(t=e.args[0])!=null?t:{dimension:0}}))}}),W(["mkern","kern","mskip","hskip","mspace"],"{width:value}",{createAtom:e=>{var t;return new xi(_(S({},e),{width:(t=e.args[0])!=null?t:{dimension:0}}))}}),W("mathchoice","{:math}{:math}{:math}{:math}",{createAtom:e=>new _e(e),render:(e,t)=>{let r=0;const n=t.mathstyle.id;(n===Do||n===Va)&&(r=1),(n===Ao||n===Li)&&(r=2),(n===Za||n===si)&&(r=3);const i=ce(e.args[r]);return _e.createBox(t,i)},serialize:(e,t)=>`\\mathchoice{${_e.serialize(e.args[0],t)}}{${_e.serialize(e.args[1],t)}}{${_e.serialize(e.args[2],t)}}{${_e.serialize(e.args[3],t)}}`}),W("mathop","{:auto}",{createAtom:e=>new _e(_(S({},e),{type:"mop",body:ce(e.args[0]),limits:"over-under",isFunction:!0,captureSelection:!0})),render:(e,t)=>{var r;let n=_e.createBox(t,e.body);if(e.superscript||e.subscript){const i=(r=e.subsupPlacement)!=null?r:"auto";n=i==="over-under"||i==="auto"&&t.isDisplayStyle?e.attachLimits(t,{base:n}):e.attachSupsub(t,{base:n})}return new Ue(e.bind(t,n),{type:"op",isSelected:e.isSelected,classes:"op-group"})},serialize:(e,t)=>{const r=[an(e.command,e.bodyToLatex(t))];return e.explicitSubsupPlacement&&(e.subsupPlacement==="over-under"&&r.push("\\limits"),e.subsupPlacement==="adjacent"&&r.push("\\nolimits"),e.subsupPlacement==="auto"&&r.push("\\displaylimits")),r.push(e.supsubToLatex(t)),Cr(r)}}),W(["mathbin","mathrel","mathopen","mathclose","mathpunct","mathord","mathinner"],"{:auto}",{createAtom:e=>new _e(_(S({},e),{type:{"\\mathbin":"mbin","\\mathrel":"mrel","\\mathopen":"mopen","\\mathclose":"mclose","\\mathpunct":"mpunct","\\mathord":"mord","\\mathinner":"minner"}[e.command],body:ce(e.args[0])}))}),W(["operatorname","operatorname*"],"{operator:math}",{createAtom:e=>{const t=ce(e.args[0]).map(r=>{var n;return r.type!=="first"&&(r.type="mord",r.value=(n={"\u2217":"*","\u2212":"-"}[r.value])!=null?n:r.value,r.isFunction=!1,!r.style.variant&&!r.style.variantStyle&&(r.style.variant="main",r.style.variantStyle="up")),r});return new _e(_(S({},e),{type:"mop",body:t,isFunction:!0,limits:e.command==="\\operatorname"?"adjacent":"over-under"}))},render:(e,t)=>{var r;let n=_e.createBox(t,e.body);if(e.superscript||e.subscript){const i=(r=e.subsupPlacement)!=null?r:"auto";n=i==="over-under"||i==="auto"&&t.isDisplayStyle?e.attachLimits(t,{base:n}):e.attachSupsub(t,{base:n})}return e.caret&&(n.caret=e.caret),new Ue(e.bind(t,n),{type:"op",isSelected:e.isSelected,classes:"op-group"})},serialize:(e,t)=>{const r=[an(e.command,e.bodyToLatex(t))];return e.explicitSubsupPlacement&&(e.subsupPlacement==="over-under"&&r.push("\\limits"),e.subsupPlacement==="adjacent"&&r.push("\\nolimits"),e.subsupPlacement==="auto"&&r.push("\\displaylimits")),r.push(e.supsubToLatex(t)),Cr(r)}}),W(["char","unicode"],"{charcode:value}",{createAtom:e=>new _e(_(S({},e),{type:e.mode==="text"?"text":"mord"})),serialize:e=>{var t;return`${e.command}${Zn((t=e.args[0])!=null?t:{number:10067,base:"hexadecimal"})}`},render:(e,t)=>{let r=t.evaluate(e.args[0]);return(!r||!("number"in r))&&(r={number:10067,base:"hexadecimal"}),e.value=String.fromCodePoint(r.number),e.createBox(t)}}),W("rule","[raise:value]{width:value}{thickness:value}",{createAtom:e=>new _e(e),render:(e,t)=>{var r,n,i;const a=new Dr({parent:t,mathstyle:"textstyle"},e.style),s=a.toEm((r=e.args[0])!=null?r:{dimension:0}),u=a.toEm((n=e.args[1])!=null?n:{dimension:10}),d=a.toEm((i=e.args[2])!=null?i:{dimension:10}),h=new Ue(null,{classes:"rule",type:"ord"});return h.width=u,h.height=d+s,h.depth=-s,h.setStyle("border-right-width",u,"em"),h.setStyle("border-top-width",d,"em"),h.setStyle("border-color",e.style.color),h.setStyle("vertical-align",s,"em"),e.isSelected&&h.setStyle("opacity","50%"),e.bind(a,h),e.caret&&(h.caret=e.caret),h.wrap(t)},serialize:e=>`\\rule${e.args[0]?`[${Zn(e.args[0])}]`:""}{${Zn(e.args[1])}}{${Zn(e.args[2])}}`}),W(["overline","underline"],"{:auto}",{createAtom:e=>new _e(_(S({},e),{body:ce(e.args[0])})),render:(e,t)=>{const r=e.command.substring(1),n=new Dr({parent:t,mathstyle:"cramp"},e.style),i=_e.createBox(n,e.body);if(!i)return null;const a=n.metrics.defaultRuleThickness/n.scalingFactor,s=new Ue(null,{classes:r+"-line"});s.height=a,s.maxFontSize=a*1.125*n.scalingFactor;let u;return r==="overline"?u=new An({shift:0,children:[{box:i},3*a,{box:s},a]}):u=new An({top:i.height,children:[a,{box:s},3*a,{box:i}]}),e.caret&&(u.caret=e.caret),new Ue(u,{classes:r,type:"ignore"})}}),W("overset","{:auto}{base:auto}",{createAtom:e=>{const t=ce(e.args[1]);return new Kr(_(S({},e),{above:ce(e.args[0]),body:t,skipBoundary:!1,boxType:Ss(t)}))},serialize:(e,t)=>an(e.command,e.aboveToLatex(t),e.bodyToLatex(t))}),W("underset","{:auto}{base:auto}",{createAtom:e=>{const t=ce(e.args[1]);return new Kr(_(S({},e),{below:ce(e.args[0]),body:t,skipBoundary:!1,boxType:Ss(t)}))},serialize:(e,t)=>an(e.command,e.belowToLatex(t),e.bodyToLatex(t))}),W("overunderset","{above:auto}{below:auto}{base:auto}",{createAtom:e=>{const t=ce(e.args[2]);return new Kr(_(S({},e),{above:ce(e.args[0]),below:ce(e.args[1]),body:t,skipBoundary:!1,boxType:Ss(t)}))},serialize:(e,t)=>an(e.command,e.belowToLatex(t),e.bodyToLatex(t))}),W(["stackrel","stackbin"],"[below:auto]{above:auto}{base:auto}",{createAtom:e=>new Kr(_(S({},e),{body:ce(e.args[2]),above:ce(e.args[1]),below:ce(e.args[0]),skipBoundary:!1,boxType:e.command==="\\stackrel"?"rel":"bin"})),serialize:(e,t)=>an(e.command,e.aboveToLatex(t),e.bodyToLatex(t))}),W("smash","[:string]{:auto}",{createAtom:e=>{var t,r,n,i;return new Ln(_(S({},e),{body:ce(e.args[1]),smashHeight:(r=(t=e.args[0])==null?void 0:t.includes("t"))!=null?r:!0,smashDepth:(i=(n=e.args[0])==null?void 0:n.includes("b"))!=null?i:!0}))}}),W(["vphantom"],"{:auto}",{createAtom:e=>new Ln(_(S({},e),{body:ce(e.args[0]),isInvisible:!0,smashWidth:!0}))}),W(["hphantom"],"{:auto}",{createAtom:e=>new Ln(_(S({},e),{body:ce(e.args[0]),isInvisible:!0,smashHeight:!0,smashDepth:!0}))}),W(["phantom"],"{:auto}",{createAtom:e=>new Ln(_(S({},e),{body:ce(e.args[0]),isInvisible:!0}))}),W("not","{:math}",{createAtom:e=>{const t=ce(e.args[0]);return t.length===0?new _e(_(S({},e),{type:"mrel",value:"\uE020"})):new _e(_(S({},e),{body:[new br(_(S({},e),{body:"\uE020",align:"right"})),...t],captureSelection:!0}))},serialize:(e,t)=>{const r=e.args[0],n=r&&typeof r=="object"&&"group"in r;return e.value!=="\uE020"?n?`\\not{${_e.serialize(r.group,t)}}`:`\\not${_e.serialize(r,t)}`:n?"\\not{}":"\\not"},render:(e,t)=>{if(e.value)return e.createBox(t);const n=e.args[0]&&typeof e.args[0]=="object"&&"group"in e.args[0]?"ord":Ss(ce(e.args[0])),i=_e.createBox(t,e.body,{type:n});return e.caret&&(i.caret=e.caret),e.bind(t,i)}}),W(["ne","neq"],"",{createAtom:e=>new _e(_(S({},e),{type:"mrel",body:[new br(_(S({},e),{body:"\uE020",align:"right",boxType:"rel"})),new _e(_(S({},e),{value:"="}))],captureSelection:!0})),serialize:e=>e.command}),W("rlap","{:auto}",{createAtom:e=>new br(_(S({},e),{body:ce(e.args[0]),align:"right"}))}),W("llap","{:auto}",{createAtom:e=>new br(_(S({},e),{body:ce(e.args[0]),align:"left"}))}),W("mathrlap","{:math}",{createAtom:e=>new br(_(S({},e),{body:ce(e.args[0]),align:"left"}))}),W("mathllap","{:math}",{createAtom:e=>new br(_(S({},e),{body:ce(e.args[0]),align:"left"}))}),W("raisebox","{:value}{:text}",{createAtom:e=>{var t;return new eo(_(S({},e),{body:ce(e.args[1]),padding:{dimension:0},offset:(t=e.args[0])!=null?t:{dimension:0}}))},serialize:(e,t)=>{var r;return an("\\raisebox",(r=Zn(e.offset))!=null?r:"0pt",e.bodyToLatex(t))}}),W("raise","{:value}{:auto}",{createAtom:e=>{var t;return new eo(_(S({},e),{body:ce(e.args[1]),padding:{dimension:0},offset:(t=e.args[0])!=null?t:{dimension:0}}))},serialize:(e,t)=>{var r;return an("\\raise",(r=Zn(e.offset))!=null?r:"0pt",e.bodyToLatex(t))}}),W("lower","{:value}{:auto}",{createAtom:e=>{var t;return new eo(_(S({},e),{body:ce(e.args[1]),padding:{dimension:0},offset:(t=fa(e.args[0],-1))!=null?t:{dimension:0}}))},serialize:(e,t)=>{var r,n;return an("\\lower",(n=Zn(fa((r=e.offset)!=null?r:{dimension:0},-1)))!=null?n:"0pt",e.bodyToLatex(t))}}),he("0123456789/@.?!"),ze(65,90),ze(97,122),he([["\\forall",8704],["\\exists",8707],["\\nexists",8708,"mord","ams"],["\\mid",8739,"mrel"],["\\top",8868],["\\bot",8869]]),he([["\\#",35],["\\&",38],["\\parallelogram",9649],["\\spadesuit",9824],["\\heartsuit",9825],["\\diamondsuit",9826],["\\clubsuit",9827],["\\flat",9837],["\\natural",9838],["\\sharp",9839]]),he([["\\backslash",92],["\\nabla",8711],["\\partial",8706],["\\ell",8467],["\\hbar",8463],["\\Q",81,"mord","double-struck"],["\\C",67,"mord","double-struck"],["\\P",80,"mord","double-struck"],["\\pounds",163],["\\euro",8364]]),he([["\\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"),he([["\\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"]]),he([["\\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"]]),he([["\\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"),he([["+",43],["-",8722],["\u2212",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"),he([["\\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"),he([["\\surd",8730],["\\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"],["\\emptyset",8709]]),he([["=",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",8869],["\\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"),he([["\\lnot",172],["\\neg",172],["\\triangle",9651],["\\subsetneq",8842],["\\varsubsetneq",57370],["\\subsetneqq",10955],["\\varsubsetneqq",57367],["\\nsubset",8836],["\\nsupset",8837],["\\nsubseteq",8840],["\\nsupseteq",8841]],"mrel","ams"),he([["\\wp",8472],["\\aleph",8501]]),he([["\\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"),he([["\\ ",160],["~",160]],"space"),W(["!",",",":",";",">","enskip","enspace","quad","qquad"],"",{createAtom:e=>new xi(e)}),W("space","",{createAtom:e=>new xi(e)}),he([["\\colon",58],["\\cdotp",8901],["\\vdots",8942,"mord"],["\\ldotp",46],[",",44],[";",59]],"mpunct"),he([["\\cdots",8943],["\\ddots",8945],["\\ldots",8230],["\\mathellipsis",8230]],"minner"),he([["\\/",47],["|",8739,"mord"],["\\imath",305],["\\jmath",567],["\\degree",176],["'",8242],['"',8221]]);var Oh="",a0="";function o0(e){return e.replace(/"/g,""").replace(/'/g,"'").replace(//g,">")}function en(e,t){return!e||!t.generateID?"":` extid="${e}"`}function Ig(e,t,r){var n,i,a,s,u,d,h,p,y,M,I;let $=!1;t=t!=null?t:e.atoms.length;let se="",Ze="",ee=e.atoms[e.index];const De=(i=(n=ee.style)==null?void 0:n.variant)!=null?i:"",Je=(s=(a=ee.style)==null?void 0:a.variantStyle)!=null?s:"";let Te="";if(De||Je){const Rt=Fe(ee.value,(u=ee.style)==null?void 0:u.variant,(d=ee.style)==null?void 0:d.variantStyle);if(Rt!==ee.value)return e.index+=1,se=`${Rt}`,Po(se,e,r)||(e.mathML+=se,e.lastType="mi"),!0;Te=(h={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"}[Je+De])!=null?h:"",Te=` mathvariant="${Te}"`}const yt={"\\exponentialE":"ⅇ","\\imaginaryI":"ⅈ","\\differentialD":"ⅆ","\\capitalDifferentialD":"ⅅ","\\alpha":"α","\\pi":"π","\\infty":"∞","\\forall":"∀","\\nexists":"∄","\\exists":"∃","\\hbar":"\u210F","\\cdotp":"\u22C5","\\ldots":"\u2026","\\cdots":"\u22EF","\\ddots":"\u22F1","\\vdots":"\u22EE","\\ldotp":"."};if(ee.command==="!")return e.index+=1,se="!",Po(se,e,r)||(e.mathML+=se,e.lastType="mo"),!0;if(yt[ee.command]){e.index+=1;let Rt=`${yt[ee.command]}`;return(e.lastType==="mi"||e.lastType==="mn"||e.lastType==="mtext"||e.lastType==="fence")&&(Rt=a0+Rt),Po(Rt,e,r)||(e.mathML+=Rt,e.lastType="mi"),!0}if(ee.command==="\\operatorname")Ze=jl(ee.body),e.index+=1;else if(De||Je)for(;e.index0){$=!0,se=`${Ze}`;const Rt=e.lastType;se.endsWith(">f")||se.endsWith(">g")?(se+=Oh,e.lastType="applyfunction"):e.lastType=/^(.*)<\/mo>$/.test(se)?"mo":"mi",Po(se,e,r)||((Rt==="mi"||Rt==="mn"||Rt==="mtext"||Rt==="fence")&&(se=a0+se),e.mathML+=se)}return $}function $g(e){return e.index${e}${u}${s}`:s?d=`${e}${s}`:u&&(d=`${e}${u}`),t.mathML+=d,t.lastType="",!0}function Pg(e,t,r){t=t!=null?t:e.atoms.length;const n=e.index;let i="";for(;e.index0?(e.mathML+=`${i}`,e.lastType="mtext",!0):!1}function Rg(e,t,r){t=t!=null?t:e.atoms.length;const n=e.index;let i="",a=Tg(e);for(a>=0&&a"+i+"",a<0&&$g(e)&&(a=e.index,e.index+=1),Po(i,e,r)||(e.mathML+=i,e.lastType="mn"),!0)}function Og(e,t,r){let n=!1;t=t!=null?t:e.atoms.length;let i="",a="";if(e.index",i+=zs(e.atoms[d],r),i+=Hr(e.atoms,r,d+1,h),i+=zs(e.atoms[h],r),i+="",e.index=h+1,(e.lastType==="mi"||e.lastType==="mn"||e.lastType==="mfrac"||e.lastType==="fence")&&(e.mathML+=a0),Po(i,e,r)&&(n=!0,e.lastType="",i=""),a="fence")}return i.length>0&&(n=!0,e.mathML+=i,e.lastType=a),n}function Ng(e,t,r){let n=!1;t=t!=null?t:e.atoms.length;let i="",a="";const s=e.atoms[e.index];if(!s)return!1;const u={"\\ne":"≠","\\neq":"&neq;","\\pm":"±","\\times":"×","\\colon":":","\\vert":"|","\\Vert":"\u2225","\\mid":"\u2223","\\{":"{","\\}":"}","\\lbrace":"{","\\rbrace":"}","\\lbrack":"[","\\rbrack":"]","\\lparen":"(","\\rparen":")","\\langle":"\u27E8","\\rangle":"\u27E9","\\lfloor":"\u230A","\\rfloor":"\u230B","\\lceil":"\u2308","\\rceil":"\u2309"};if(u[s.command]){e.index+=1;const d=`${u[s.command]}`;return Po(d,e,r)||(e.mathML+=d,e.lastType="mo"),!0}if(e.index"+d,i+=Hr(s.subscript,r),i+=Hr(s.superscript,r),i+=""):s.superscript?(i+=""+d,i+=Hr(s.superscript,r),i+=""):s.subscript&&(i+=""+d,i+=Hr(s.subscript,r),i+=""),e.mathML+=i,e.lastType="mo",e.index+=1,!0}{const d=e.atoms[e.index],h=d.value==="\\operatorname",p=h?'"+jl(d.value)+"":zs(d,r);i+=p,!h&&!/^(.*)<\/mo>$/.test(p)?(i+=Oh,a="applyfunction"):a=h?"mi":"mo"}(e.lastType==="mi"||e.lastType==="mn")&&!/^(.*)<\/mo>$/.test(i)&&(i=a0+i),e.index+=1}return i.length>0&&(n=!0,Po(i,e,r)||(e.mathML+=i,e.lastType=a)),n}function Hr(e,t,r,n){t!=null||(t={});const i={atoms:[],index:r!=null?r:0,mathML:"",lastType:""};if(typeof e=="number"||typeof e=="boolean")i.mathML=e.toString();else if(typeof e=="string")i.mathML=e;else if(e instanceof _e)i.mathML=Df(e,t);else if(Array.isArray(e)){i.atoms=e;let a=0;for(n=n||(e?e.length:0);i.index0&&i.atoms[i.index].type==="genfrac"&&(s=""+s),i.atoms[i.index].type==="genfrac"?i.lastType="mfrac":i.lastType="",i.index+=1,Po(s,i,t)?a+=1:s.length>0&&(i.mathML+=s,a+=1)}a>1&&(i.mathML=""+i.mathML+"")}return i.mathML}function zs(e,t){let r="";const n=jl(e.value);return n&&(r=""+n+""),r}function jl(e){if(!e)return"";if(typeof e=="string")return o0(e);if(!Array.isArray(e)&&typeof e.body=="string")return o0(e.body);let t="";for(const r of e)typeof r.value=="string"&&(t+=r.value);return o0(t)}function Df(e,t){var r,n,i,a,s,u,d,h,p,y,M,I,$,se,Ze,ee,De,Je,Te,yt,Rt,Dt;if(e.mode==="text")return`${e.value}`;const Ar={widehat:"^",widecheck:"\u02C7",widetilde:"~",utilde:"~",overleftarrow:"\u2190",underleftarrow:"\u2190",xleftarrow:"\u2190",longleftarrow:"\u2190",overrightarrow:"\u2192",underrightarrow:"\u2192",xrightarrow:"\u2192",longrightarrow:"\u2192",underbrace:"\u23DF",overbrace:"\u23DE",overgroup:"\u23E0",undergroup:"\u23E1",overleftrightarrow:"\u2194",underleftrightarrow:"\u2194",xleftrightarrow:"\u2194",Overrightarrow:"\u21D2",xRightarrow:"\u21D2",overleftharpoon:"\u21BC",xleftharpoonup:"\u21BC",overrightharpoon:"\u21C0",xrightharpoonup:"\u21C0",xLeftarrow:"\u21D0",xLeftrightarrow:"\u21D4",xhookleftarrow:"\u21A9",xhookrightarrow:"\u21AA",xmapsto:"\u21A6",xrightharpoondown:"\u21C1",xleftharpoondown:"\u21BD",xrightleftharpoons:"\u21CC",longrightleftharpoons:"\u21CC",xleftrightharpoons:"\u21CB",xtwoheadleftarrow:"\u219E",xtwoheadrightarrow:"\u21A0",xlongequal:"=",xtofrom:"\u21C4",xleftrightarrows:"\u21C4",xRightleftharpoons:"\u21CC",longRightleftharpoons:"\u21CC",xLeftrightharpoons:"\u21CB",longLeftrightharpoons:"\u21CB"},Xr={"\\!":-3/18,"\\ ":6/18,"\\,":3/18,"\\:":4/18,"\\>":4/18,"\\;":5/18,"\\enspace":.5,"\\quad":1,"\\qquad":2,"\\enskip":.5};let nt="",na="",lo,ba,Gn,ia,Ti,tn;const{command:Cn}=e;if(e.command==="\\error")return`${Hr(e.body,t)}`;const qn={"\\vert":"|","\\Vert":"\u2225","\\mid":"\u2223","\\lbrack":"[","\\rbrack":"]","\\{":"{","\\}":"}","\\lbrace":"{","\\rbrace":"}","\\lparen":"(","\\rparen":")","\\langle":"\u27E8","\\rangle":"\u27E9","\\lfloor":"\u230A","\\rfloor":"\u230B","\\lceil":"\u2308","\\rceil":"\u2309"},co={"\\vec":"⃗","\\acute":"´","\\grave":"`","\\dot":"˙","\\ddot":"¨","\\tilde":"~","\\bar":"¯","\\breve":"˘","\\check":"ˇ","\\hat":"^"};switch(e.type){case"first":break;case"group":case"root":nt=Hr(e.body,t);break;case"array":if((e.leftDelim&&e.leftDelim!=="."||e.rightDelim&&e.rightDelim!==".")&&(nt+="",e.leftDelim&&e.leftDelim!=="."&&(nt+=""+(qn[e.leftDelim]||e.leftDelim)+"")),nt+="",ba=0;ba",lo=0;lo"+Hr(e.array[ba][lo],t)+"";nt+=""}nt+="",(e.leftDelim&&e.leftDelim!=="."||e.rightDelim&&e.rightDelim!==".")&&(e.rightDelim&&e.rightDelim!=="."&&(nt+=""+(qn[e.leftDelim]||e.rightDelim)+""),nt+="");break;case"genfrac":(e.leftDelim||e.rightDelim)&&(nt+=""),e.leftDelim&&e.leftDelim!=="."&&(nt+=""+(qn[e.leftDelim]||e.leftDelim)+""),e.hasBarLine?(nt+="",nt+=Hr(e.above,t)||" ",nt+=Hr(e.below,t)||" ",nt+=""):(nt+="",nt+=""+Hr(e.above,t)+"",nt+=""+Hr(e.below,t)+"",nt+=""),e.rightDelim&&e.rightDelim!=="."&&(nt+=""+(qn[e.rightDelim]||e.rightDelim)+""),(e.leftDelim||e.rightDelim)&&(nt+="");break;case"surd":e.hasEmptyBranch("above")?(nt+="",nt+=Hr(e.body,t),nt+=""):(nt+="",nt+=Hr(e.body,t),nt+=Hr(e.above,t),nt+="");break;case"leftright":const uo=e,fo=uo.leftDelim;nt="",fo&&fo!=="."&&(nt+=`${(r=qn[fo])!=null?r:fo}`),e.body&&(nt+=Hr(e.body,t));const ho=uo.matchingRightDelim();ho&&ho!=="."&&(nt+=`${(n=qn[ho])!=null?n:ho}`),nt+="";break;case"sizeddelim":case"delim":nt+=`${qn[e.value]||e.value}`;break;case"accent":nt+='",nt+=Hr(e.body,t),nt+=""+(co[Cn]||e.accent)+"",nt+="";break;case"line":case"overlap":break;case"overunder":Ti=e.above,ia=e.below,(e.svgAbove||Ti)&&(e.svgBelow||ia)?tn=e.body:Ti&&Ti.length>0?(tn=e.body,(a=(i=e.body)==null?void 0:i[0])!=null&&a.below?(ia=e.body[0].below,tn=e.body[0].body):((u=(s=e.body)==null?void 0:s[0])==null?void 0:u.type)==="first"&&((h=(d=e.body)==null?void 0:d[1])!=null&&h.below)&&(ia=e.body[1].below,tn=e.body[1].body)):ia&&ia.length>0&&(tn=e.body,(y=(p=e.body)==null?void 0:p[0])!=null&&y.above?(Ti=e.body[0].above,tn=e.body[0].body):((I=(M=e.body)==null?void 0:M[0])==null?void 0:I.type)==="first"&&((se=($=e.body)==null?void 0:$[1])!=null&&se.above)&&(Ti=e.body[1].overscript,tn=e.body[1].body)),(e.svgAbove||Ti)&&(e.svgBelow||ia)?(nt+=``,nt+=(Ze=Ar[e.svgBody])!=null?Ze:Hr(tn,t),nt+=(ee=Ar[e.svgBelow])!=null?ee:Hr(ia,t),nt+=(De=Ar[e.svgAbove])!=null?De:Hr(Ti,t),nt+=""):e.svgAbove||Ti?(nt+=``+((Je=Ar[e.svgBody])!=null?Je:Hr(tn,t)),nt+=(Te=Ar[e.svgAbove])!=null?Te:Hr(Ti,t),nt+=""):(e.svgBelow||ia)&&(nt+=``+((yt=Ar[e.svgBody])!=null?yt:Hr(tn,t)),nt+=(Rt=Ar[e.svgBelow])!=null?Rt:Hr(ia,t),nt+="");break;case"placeholder":nt+="?";break;case"mord":{nt=typeof e.value=="string"?e.value:Cn,Cn==="\\char"?nt=""+("000000"+e.args[0].number.toString(16)).slice(-4)+";":nt.length>0&&nt.startsWith("\\")&&(typeof e.value=="string"&&e.value.charCodeAt(0)>255?nt=""+("000000"+e.value.charCodeAt(0).toString(16)).slice(-4)+";":typeof e.value=="string"?nt=e.value.charAt(0):(console.error("Did not expect this"),nt=""));const Oa=/\d/.test(nt)?"mn":"mi";nt=`<${Oa}${en(e.id,t)}>${o0(nt)}${Oa}>`;break}case"mbin":case"mrel":case"minner":nt=zs(e,t);break;case"mpunct":nt='"+Cn+"";break;case"mop":case"operator":case"extensible-symbol":e.body!=="\u200B"&&(nt="",nt+=Cn==="\\operatorname"?e.body:Cn||e.body,nt+="");break;case"box":nt='"+Hr(e.body,t)+"";break;case"spacing":nt+='';break;case"enclose":nt=''+Hr(e.body,t)+"";break;case"prompt":nt=''+Hr(e.body,t)+"";break;case"space":nt+=" ";break;case"subsup":break;case"phantom":break;case"composition":break;case"rule":break;case"chem":break;case"mopen":nt+=zs(e,t);break;case"mclose":nt+=zs(e,t);break;case"macro":{const Oa=e.command+jl(e.macroArgs);Oa&&(nt+=`${Oa}`)}break;case"latexgroup":nt+=Hr(e.body,t);break;case"latex":nt+=""+e.value+"";break;case"tooltip":nt+=Hr(e.body,t);break;case"text":nt+=`${e.value}`;break;default:if(e.command==="\\displaystyle")return`${Hr(e.body,t)}`;if(e.command==="\\textstyle")return`${Hr(e.body,t)}`;console.info("Unexpected element in conversion to MathML:",e)}return nt}var Ul={"\\alpha":"alpha ","\\mu":"mew ","\\sigma":"sigma ","\\pi":"pie ","\\imaginaryI":"imaginary eye ","\\imaginaryJ":"imaginary jay ","\\sum":"Summation ","\\prod":"Product ","+":"plus ","-":"minus ",";":' semi-colon ',",":' comma ',"|":'Vertical bar',"(":'Open paren. ',")":' Close paren. ',"=":"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 ","\u200B":"","\u2212":"minus ",":":' such that ',"\\colon":' such that ',"\\hbar":"etch bar ","\\iff":'if, and only if, ',"\\Longleftrightarrow":'if, and only if, ',"\\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 n',"\\C":'the set c',"\\Z":'the set z',"\\Q":'the set q',"\\infty":"infinity ","\\nabla":"nabla ","\\partial":"partial derivative of ","\\cdot":"times ","\\cdots":"dot dot dot ","\\Rightarrow":"implies ","\\lparen":'open paren',"\\rparen":'close paren',"\\lbrace":'open brace',"\\{":'open brace',"\\rbrace":'close brace',"\\}":'close brace',"\\langle":'left angle bracket',"\\rangle":'right angle bracket',"\\lfloor":'open floor',"\\rfloor":'close floor',"\\lceil":'open ceiling',"\\rceil":'close ceiling',"\\vert":'vertical bar',"\\mvert":'divides',"\\lvert":'left vertical bar',"\\rvert":'right vertical bar',"\\lbrack":' open square bracket ',"\\rbrack":' close square bracket ',mm:"millimeters",cm:"centimeters",km:"kilometers",kg:"kilograms"},Af={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 Fg(e){let t="";return e.startsWith("\\")&&(t=" "+e.replace("\\","")+" "),t}function Yc(e){let t=0;if(A(e))for(const r of e)r.type!=="first"&&(t+=1);return t===1}function zg(e){if(A(e)){for(const t of e)if(t.type!=="first"&&t.id)return t.id.toString()}return""}function Nh(e){let t="";if(A(e))for(const r of e)r.type!=="first"&&typeof r.value=="string"&&(t+=r.value);return t}function Kg(e){return e?e.map(t=>t.value).join(""):""}function _r(e,t){var r,n,i,a,s;function u(p){return window.MathfieldElement.textToSpeechMarkup?/[a-z]/.test(p)?` ${p}`:/[A-Z]/.test(p)?`capital ${p.toLowerCase()}`:p:/[a-z]/.test(p)?" '"+p.toUpperCase()+"'":/[A-Z]/.test(p)?" 'capital "+p.toUpperCase()+"'":p}function d(p){return""+p+""}if(!t)return"";let h="";if(A(t)){let p=!1,y=!1;for(let M=0;M'),h+=t.value;else{t.id&&e==="math"&&(h+='');let p="",y="",M="",I=!1;const{command:$}=t;switch($){case"\\vec":return"vector "+_r(e,t.body);case"\\acute":return _r(e,t.body)+" acute";case"\\grave":return _r(e,t.body)+" grave";case"\\dot":return"dot over"+_r(e,t.body);case"\\ddot":return"double dot over"+_r(e,t.body);case"\\mathring":return"ring over"+_r(e,t.body);case"\\tilde":case"\\widetilde":return"tilde over"+_r(e,t.body);case"\\bar":return _r(e,t.body)+" bar";case"\\breve":return _r(e,t.body)+" breve";case"\\check":case"\\widecheck":return"check over "+_r(e,t.body);case"\\hat":case"\\widehat":return"hat over"+_r(e,t.body);case"\\overarc":case"\\overparen":case"\\wideparen":return"arc over "+_r(e,t.body);case"\\underarc":case"\\underparen":return"arc under "+_r(e,t.body)}switch(t.type){case"prompt":const se=t.body.length>1?'start input . '+_r(e,t.body)+'. end input':"blank";h+=' '+se+'. '+((n=t.correctness)!=null?n:"")+' . ';break;case"array":const Ze=t.array,ee=t.environmentName;if(Object.keys(Af).includes(ee)){h+=` begin ${Af[ee]} `;for(let Te=0;Te0&&(h+=","),h+=` row ${Te+1} `;for(let yt=0;yt0&&(h+=","),h+=` column ${yt+1}: `,h+=_r("math",Ze[Te][yt])}h+=` end ${Af[ee]} `}break;case"group":$==="\\ne"?h+=" not equal ":($==="\\not"&&(h+=" not "),h+=_r("math",t.body));break;case"root":h+=_r("math",t.body);break;case"genfrac":if(p=_r("math",t.above),y=_r("math",t.below),Yc(t.above)&&Yc(t.below)){const yt={"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 "}[Nh(t.above)+"/"+Nh(t.below)];yt?h=yt:h+=p+" over "+y}else h+=' the fraction '+p+' over '+y+'. End fraction.';break;case"surd":if(M=_r("math",t.body),t.hasEmptyBranch("above"))h+=Yc(t.body)?" the square root of "+M+" , ":' the square root of '+M+'. End square root';else{let Te=_r("math",t.above);Te=Te.trim();const yt=Te.replace(//g,"");yt==="3"?h+=' the cube root of '+M+'. End cube root':yt==="n"?h+=' the nth root of '+M+'. End root':h+=' the root with index: '+Te+', of '+M+'. End root'}break;case"leftright":{const Te=t;h+=(i=Te.leftDelim?Ul[Te.leftDelim]:void 0)!=null?i:Te.leftDelim,h+=_r("math",t.body),h+=(a=Te.rightDelim?Ul[Te.rightDelim]:void 0)!=null?a:Te.rightDelim}break;case"rule":break;case"overunder":break;case"overlap":break;case"macro":const De=$.replace(/^\\/g,""),Je=vt()[De];Je&&(Je!=null&&Je.expand?h+=_r("math",t.body):h+=`${De} `);break;case"placeholder":h+="placeholder ";break;case"delim":case"sizeddelim":case"mord":case"minner":case"mbin":case"mrel":case"mpunct":case"mopen":case"mclose":{if($==="\\mathbin"||$==="\\mathrel"||$==="\\mathopen"||$==="\\mathclose"||$==="\\mathpunct"||$==="\\mathord"||$==="\\mathinner"){h=_r(e,t.body);break}let Te=t.isDigit()?t.asDigit():t.value,yt=t.command;if((t.type==="delim"||t.type==="sizeddelim")&&(yt=t.value,Te=yt),e==="text")h+=Te;else{if(t.type==="mbin"&&(h+=''),Te){const Rt=Ul[Te]||(yt?Ul[yt.trim()]:"");if(Rt)h+=" "+Rt;else{const Dt=yt?Fg(yt.trim()):"";h+=Dt||u(Te)}}else h+=_r("math",t.body);t.type==="mbin"&&(h+='')}break}case"mop":case"operator":case"extensible-symbol":if(t.value!=="\u200B"){const Te=t.command;if(Te==="\\sum")if(!t.hasEmptyBranch("superscript")&&!t.hasEmptyBranch("subscript")){let yt=_r("math",t.superscript);yt=yt.trim();let Rt=_r("math",t.subscript);Rt=Rt.trim(),h+=' the summation from '+Rt+' to '+yt+' of ',I=!0}else if(t.hasEmptyBranch("subscript"))h+=" the summation of";else{let yt=_r("math",t.subscript);yt=yt.trim(),h+=' the summation from '+yt+' of ',I=!0}else if(Te==="\\prod")if(!t.hasEmptyBranch("superscript")&&!t.hasEmptyBranch("subscript")){let yt=_r("math",t.superscript);yt=yt.trim();let Rt=_r("math",t.subscript);Rt=Rt.trim(),h+=' the product from '+Rt+' to '+yt+' of ',I=!0}else if(t.hasEmptyBranch("subscript"))h+=" the product of ";else{let yt=_r("math",t.subscript);yt=yt.trim(),h+=' the product from '+yt+' of ',I=!0}else if(Te==="\\int")if(!t.hasEmptyBranch("superscript")&&!t.hasEmptyBranch("subscript")){let yt=_r("math",t.superscript);yt=yt.trim();let Rt=_r("math",t.subscript);Rt=Rt.trim(),h+=' the integral from '+d(Rt)+' to '+d(yt)+' of ',I=!0}else h+=' the integral of ';else if(typeof t.value=="string"){const yt=(s=Ul[t.value])!=null?s:t.command?Ul[t.command]:void 0;h+=yt||" "+t.value}else t.command&&(t.command==="\\mathop"?h+=_r("math",t.body):t.command==="\\operatorname"?h+=Kg(t.body):h+=t.command.startsWith("\\")?" "+t.command.slice(1):" "+t.command)}break;case"enclose":M=_r("math",t.body),h+=" crossed out "+M+". End crossed out.";break;case"space":case"spacing":break}if(!I&&!t.hasEmptyBranch("superscript")){let se=_r(e,t.superscript);se=se.trim();const Ze=se.replace(/<[^>]*>/g,"");if(Yc(t.superscript)){if(e==="math"){const ee=zg(t.superscript);ee&&(h+='')}Ze==="\u2032"?h+=" prime ":Ze==="2"?h+=" squared ":Ze==="3"?h+=" cubed ":Number.isNaN(Number.parseInt(Ze))?h+=" to the "+se+"; ":h+=' to the '+Ze+" power; "}else Number.isNaN(Number.parseInt(Ze))?h+=" raised to the "+se+"; ":h+=' raised to the '+Ze+" power; "}if(!I&&!t.hasEmptyBranch("subscript")){let se=_r("math",t.subscript);se=se.trim(),h+=Yc(t.subscript)?" sub "+se:" subscript "+se+". End subscript. "}}return h}function Gl(e){var t,r;if(window.MathfieldElement.textToSpeechRules==="sre"&&("sre"in window||"SRE"in window)){const i=Hr(e);if(i){window.MathfieldElement.textToSpeechMarkup&&(window.MathfieldElement.textToSpeechRulesOptions=(t=window.MathfieldElement.textToSpeechRulesOptions)!=null?t:{},window.MathfieldElement.textToSpeechRulesOptions=_(S({},window.MathfieldElement.textToSpeechRulesOptions),{markup:window.MathfieldElement.textToSpeechMarkup}),window.MathfieldElement.textToSpeechRulesOptions.markup==="ssml"&&(window.MathfieldElement.textToSpeechRulesOptions=_(S({},window.MathfieldElement.textToSpeechRulesOptions),{markup:"ssml_step"})),window.MathfieldElement.textToSpeechRulesOptions=_(S({},window.MathfieldElement.textToSpeechRulesOptions),{rate:window.MathfieldElement.speechEngineRate}));const a=(r=window.SRE)!=null?r:window.sre.System.getInstance();window.MathfieldElement.textToSpeechRulesOptions&&a.setupEngine(window.MathfieldElement.textToSpeechRulesOptions);let s="";try{s=a.toSpeech(i)}catch(u){console.error("MathLive 0.98.5: `SRE.toSpeech()` runtime error",u)}return s}return""}let n=_r("math",e);if(window.MathfieldElement.textToSpeechMarkup==="ssml"){let i="";window.MathfieldElement.speechEngineRate&&(i=''),n=''+i+""+n+"
"+(i?"":"")+""}else window.MathfieldElement.textToSpeechMarkup==="mac"&&Qe()==="macos"?n=n.replace(//g,"").replace(//g,"[[emph+]]").replace(/<\/emphasis>/g,"").replace(//g,"[[slc $1]]").replace(/]*>/g,"").replace(/<\/say-as>/g,""):n=n.replace(/<[^>]*>/g,"").replace(/\s{2,}/g," ");return n}var Qc={"\\ne":"\u2260","\\neq":"\u2260","\u2212":"-","-":"-","\\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"},eu={"\\pm":"+-","\\colon":":","\\vert":"|","\\Vert":"||","\\mid":"|","\\lbrack":"[","\\rbrack":"]","\\lbrace":"{","\\rbrace":"}","\\lparen":"(","\\rparen":")","\\langle":"(:","\\rangle":":)","\\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":"xx","\\div":"-:","\\ltimes":"|><","\\rtimes":"><|","\\bowtie":"|><|","\\circ":"@"};function Hg(e){let t="";for(const r of e){const n=t[t.length-1];n!==void 0&&/\d/.test(n)&&/^\d/.test(r)&&(t+=" "),t+=r}return t}function Mn(e){var t,r,n,i,a,s,u,d,h,p,y,M,I;if(!e)return"";if(A(e)){if(e.length===0)return"";if(e[0].mode==="latex")return e.map(Mn).join("");if(e[0].mode==="text"){let Je=0,Te="";for(;((t=e[Je])==null?void 0:t.mode)==="text";)Te+=e[Je].body?Mn(e[Je].body):e[Je].value,Je++;return`"${Te}" ${Mn(e.slice(Je))}`}let ee=0;const De=[];for(;e[ee]&&e[ee].mode==="math";){let Je="";for(;e[ee]&&e[ee].type==="mord"&&/\d/.test(e[ee].value);)Je+=e[ee++].value;Je?De.push(Je):De.push(Mn(e[ee++]))}return De.push(Mn(e.slice(ee))),Hg(De)}if(e.mode==="text")return`"${e.value}"`;let $="";const{command:se}=e;let Ze;if(se==="\\placeholder")return`(${Mn(e.body)})`;switch(e.type){case"accent":const ee={"\\vec":"vec","\\dot":"dot","\\ddot":"ddot","\\bar":"bar","\\hat":"hat","\\acute":"acute;","\\grave":"grave","\\tilde":"tilde","\\breve":"breave","\\check":"check"}[se];$=`${ee!=null?ee:""} ${Mn(e.body)} `;break;case"first":return"";case"latexgroup":return e.body.map(Dt=>Dt.value).join("");case"group":case"root":$=(r=Qc[se])!=null?r:Mn(e.body);break;case"genfrac":{const Dt=e;(Dt.leftDelim||Dt.rightDelim)&&($=Dt.leftDelim==="."||!Dt.leftDelim?"{:":Dt.leftDelim),Dt.hasBarLine?($+="(",$+=Mn(Dt.above),$+=")/(",$+=Mn(Dt.below),$+=")"):($+="("+Mn(Dt.above)+"),",$+="("+Mn(Dt.below)+")"),(Dt.leftDelim||Dt.rightDelim)&&($+=Dt.rightDelim==="."||!Dt.rightDelim?"{:":Dt.rightDelim)}break;case"surd":$+=e.hasEmptyBranch("above")?"sqrt("+Mn(e.body)+")":"root("+Mn(e.above)+")("+Mn(e.body)+")";break;case"latex":$=e.value;break;case"leftright":{const Dt=e,Ar=Dt.leftDelim;$+=Ar==="."||!Ar?"{:":Ar,$+=Mn(Dt.body);const Xr=Dt.matchingRightDelim();$+=Xr==="."||!Xr?":}":Xr}break;case"sizeddelim":case"delim":$=e.value;break;case"overlap":break;case"overunder":break;case"mord":$=(i=(n=Qc[se])!=null?n:se)!=null?i:typeof e.value=="string"?e.value:"",$.startsWith("\\")&&($+=" "),Ze=se?se.match(/{?\\char"([\dabcdefABCDEF]+)}?/):null,Ze?$=String.fromCodePoint(Number.parseInt("0x"+Ze[1])):$.length>0&&$.startsWith("\\")&&($=typeof e.value=="string"?e.value.charAt(0):e.command),$=Wg($,e.style);break;case"mbin":case"mrel":case"minner":$=(s=(a=Qc[se])!=null?a:eu[se])!=null?s:e.value;break;case"mopen":case"mclose":$=e.value;break;case"mpunct":$=(u=eu[se])!=null?u:se;break;case"mop":case"operator":case"extensible-symbol":e.value!=="\u200B"&&(eu[se]?$=eu[se]:$=se==="\\operatorname"?Mn(e.body):(d=e.value)!=null?d:se,$+=" ");break;case"array":const De=e.array,Je=e.environmentName,Te=(h={bmatrix:["[","]"],"bmatrix*":["[","]"]}[Je])!=null?h:["(",")"],yt=[];for(const Dt of De){const Ar=[];for(const Xr of Dt)Ar.push(Te[0]+Mn(Xr)+Te[1]);yt.push(Ar.join(","))}const Rt=(p={bmatrix:["[","]"],"bmatrix*":["[","]"],cases:["{",":}"]}[Je])!=null?p:["(",")"];$=Rt[0]+yt.join(",")+Rt[1];break;case"box":break;case"spacing":$=(y=Qc[se])!=null?y:" ";break;case"enclose":$="("+Mn(e.body)+")";break;case"space":$=" ";break;case"subsup":$="";break;case"macro":$=(I=(M=Qc[se])!=null?M:eu[se])!=null?I:Mn(e.body);break}if(!e.hasEmptyBranch("subscript")){$+="_";const ee=Mn(e.subscript);$+=ee.length!==1?`(${ee})`:ee}if(!e.hasEmptyBranch("superscript")){$+="^";const ee=Mn(e.superscript);$+=ee.length!==1?`(${ee})`:ee}return $}function Wg(e,t){if(!t)return e;let r=e;return t.variant==="double-struck"&&(r=`bbb "${r}"`),t.variant==="script"&&(r=`cc "${r}"`),t.variant==="fraktur"&&(r=`fr "${r}"`),t.variant==="sans-serif"&&(r=`sf "${r}"`),t.variant==="monospace"&&(r=`tt "${r}"`),t.variantStyle==="bold"&&(r=`bb "${r}"`),t.color?`color({${t.color}})(${r})`:r}function Un(e,t){var r,n;t!=null||(t={}),t.mathstyle=(r=t.mathstyle)!=null?r:"displaystyle";const i=new Dr({from:_(S({},Lc()),{renderPlaceholder:()=>new Ue(160,{maxFontSize:1}),letterShapeStyle:(n=t==null?void 0:t.letterShapeStyle)!=null?n:"tex"}),mathstyle:t.mathstyle}),s=new _e({mode:"math",type:"root",body:b(e,{context:i,parseMode:"math",mathstyle:t.mathstyle})}).render(i);return s?(gl(Pa(s,i)),vl(s,{classes:"ML__latex"}).toMarkup()):""}function $v(e){return D(e,{context:Lc()})}function Vg(e,t={}){return Hr(b(e,{parseMode:"math",args:()=>"",mathstyle:"displaystyle"}),t)}function Zg(e){const t=b(e,{parseMode:"math",mathstyle:"displaystyle"});return Gl(t)}var s0;function jg(e){var t,r;if(!s0){const n=(t=globalThis[Symbol.for("io.cortexjs.compute-engine")])==null?void 0:t.ComputeEngine;n?s0=new n:console.error(`MathLive 0.98.5: The CortexJS Compute Engine library is not available.
Load the library, for example with:
import "https://unpkg.com/@cortex-js/compute-engine?module"`)}return(r=s0==null?void 0:s0.box(e).latex)!=null?r:""}function Tv(e,t="math"){return Mn(new _e({type:"root",body:b(e,{parseMode:t})}))}function Pv(e){return qa(e,{format:"ascii-math"})[1]}function Lf(e){if(typeof e=="string"){const t=Ug(e);if(!t)throw new Error(`Invalid color: ${e}`);return t}return"C"in e?qg(e):"a"in e?Fh(e):e}function ql(e){return e<0?0:e>255?255:Math.round(e)}function Ug(e){if(!e||e[0]!=="#")return;e=e.slice(1);let t;return e.length<=4?(t={r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16)},e.length===4&&(t.a=parseInt(e[3]+e[3],16)/255)):(t={r:parseInt(e[0]+e[1],16),g:parseInt(e[2]+e[3],16),b:parseInt(e[4]+e[5],16)},e.length===8&&(t.a=parseInt(e[6]+e[7],16)/255)),t&&typeof t.a=="undefined"&&(t.a=1),t}function Bf(e){const[t,r,n]=[e.L,e.C,e.H],i=n*Math.PI/180,a={L:t,a:r*Math.cos(i),b:r*Math.sin(i)};return e.alpha!==void 0&&(a.alpha=e.alpha),a}function Gg(e){const[t,r,n]=[e.L,e.a,e.b],i=Math.sqrt(r*r+n*n),s=Math.atan2(n,r)*180/Math.PI,u={L:t,C:i,H:s};return e.alpha!==void 0&&(u.alpha=e.alpha),u}function If(e){const[t,r,n]=[e.L,e.a,e.b],i=Math.pow(.9999999984505198*t+.39633779217376786*r+.2158037580607588*n,3),a=Math.pow(1.00000000888176*t-.10556134232365635*r-.0638541747717059*n,3),s=Math.pow(t*1.000000054672411-.0894841820949657*r-1.2914855378640917*n,3),u=4.076741661347994*i-3.307711590408193*a+.230969928729428*s,d=-1.2684380040921763*i+2.6097574006633715*a-.3413193963102197*s,h=-.004196086541837188*i-.7034186144594493*a+1.7076147009309444*s,p=y=>{const M=Math.abs(y);return M<=.0031308?y*12.92:(Math.sign(y)||1)*(1.055*Math.pow(M,1/2.4)-.055)};return[p(u),p(d),p(h)]}function $f(e){const[t,r,n]=e;return t>=0&&t<=1&&r>=0&&r<=1&&n>=0&&n<=1}function Tf(e,t){let[r,n,i]=e;return r=ql(r*255),n=ql(n*255),i=ql(i*255),t!==void 0?{r,g:n,b:i,alpha:t}:{r,g:n,b:i}}function Fh(e){let[t,r,n]=If(e);if($f([t,r,n]))return Tf([t,r,n],e.alpha);const i=Gg(e);if(i.C=0,[t,r,n]=If(Bf(i)),!$f([t,r,n]))return Tf([t,r,n],e.alpha);let a=0,s=e.L,u=(a+s)/2;i.C=u;const d=.36/Math.pow(2,12);for(;s-a>d;)u=(a+s)/2,i.C=u,[t,r,n]=If(Bf(i)),$f([t,r,n])?a=u:s=u;return Tf([t,r,n],e.alpha)}function qg(e){return Fh(Bf(e))}function zh(e,t){const r=Lf(e),n=Lf(t),i=.56,a=.57,s=.62,u=.65,d=.022,h=1.414,p=.1,y=5e-4,M=1.14,I=.027,$=1.14,se=.027;function Ze(Dt){return Dt>=d?Dt:Dt+po(d-Dt,h)}function ee(Dt){return(Dt<0?-1:1)*Math.pow(Math.abs(Dt),2.4)}const De=Ze(ee(n.r/255)*.2126729+ee(n.g/255)*.7151522+ee(n.b/255)*.072175),Je=Ze(ee(r.r/255)*.2126729+ee(r.g/255)*.7151522+ee(r.b/255)*.072175);let Te,yt,Rt;return Math.abs(Je-De)De?(Te=po(Je,i)-po(De,a),yt=Te*M):(Te=po(Je,u)-po(De,s),yt=Te*$),Math.abs(yt)0?Rt=yt-se:Rt=yt+I,Rt*100}function Kh(e,t,r){r!=null||(r="#fff"),t!=null||(t="#000");const n=zh(e,r),i=zh(e,t);return Math.abs(n)>Math.abs(i)?r:t}function Xg(e){const t=Lf(e);let r=((1<<24)+(ql(t.r)<<16)+(ql(t.g)<<8)+ql(t.b)).toString(16).slice(1);return t.alpha!==void 0&&t.alpha<1&&(r+=("00"+Math.round(t.alpha*255).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]+(t.alpha!==void 0&&t.alpha<1?r[6]:"")),"#"+r}function cn(e){const t=Hh(e);let r="";for(const n of t){if(typeof n.value!="string")return"";r+=n.value}return r}function Hh(e){const r=e.model.selection.ranges;return r.length!==1?[]:e.model.getAtoms(r[0])}function Jg(e,t){const r=Hh(e);if(r.length!==1)return!1;const n=To[t];return n?!!n.test(r[0].value):!1}function Yg(e,t){return cn(e).length>0}function Qg(e){return[Pf(e,"double-struck","mathbb","tooltip.blackboard"),Pf(e,"fraktur","mathfrak","tooltip.fraktur"),Pf(e,"calligraphic","mathcal","tooltip.caligraphic"),Rf(e,"up","mathrm","tooltip.roman-upright"),Rf(e,"bold","mathbf","tooltip.bold"),Rf(e,"italic","mathit","tooltip.italic")]}function ev(e){return[{label:()=>Un(`\\vec{${cn(e)}}`),visible:()=>cn(e).length===1,onMenuSelect:()=>e.insert("\\vec{#@}",{selectionMode:"item"})},{label:()=>Un(`\\overrightarrow{${cn(e)}}`),visible:()=>cn(e).length>0,onMenuSelect:()=>e.insert("\\overrightarrow{#@}",{selectionMode:"item"})},{label:()=>Un(`\\overleftarrow{${cn(e)}}`),visible:()=>cn(e).length>0,onMenuSelect:()=>e.insert("\\overleftarrow{#@}",{selectionMode:"item"})},{label:()=>Un(`\\dot{${cn(e)}}`),visible:()=>cn(e).length===1,onMenuSelect:()=>e.insert("\\dot{#@}",{selectionMode:"item"})},{label:()=>Un(`\\ddot{${cn(e)}}`),visible:()=>cn(e).length===1,onMenuSelect:()=>e.insert("\\ddot{#@}",{selectionMode:"item"})},{label:()=>Un(`\\bar{${cn(e)}}`),visible:()=>cn(e).length===1,onMenuSelect:()=>e.insert("\\bar{#@}",{selectionMode:"item"})},{label:()=>Un(`\\overline{${cn(e)}}`),visible:()=>cn(e).length>0,onMenuSelect:()=>e.insert("\\overline{#@}",{selectionMode:"item"})},{label:()=>Un(`\\overgroup{${cn(e)}}`),visible:()=>cn(e).length>0,onMenuSelect:()=>e.insert("\\overgroup{#@}",{selectionMode:"item"})},{label:()=>Un(`\\overbrace{${cn(e)}}`),visible:()=>cn(e).length>0,onMenuSelect:()=>e.insert("\\overbrace{#@}",{selectionMode:"item"})},{label:()=>Un(`\\underline{${cn(e)}}`),visible:()=>cn(e).length>0,onMenuSelect:()=>e.insert("\\underline{#@}",{selectionMode:"item"})},{label:()=>Un(`\\undergroup{${cn(e)}}`),visible:()=>cn(e).length>0,onMenuSelect:()=>e.insert("\\undergroup{#@}",{selectionMode:"item"})},{label:()=>Un(`\\underbrace{${cn(e)}}`),visible:()=>cn(e).length>0,onMenuSelect:()=>e.insert("\\underbrace{#@}",{selectionMode:"item"})}]}function tv(e){return[{label:()=>Un(`\\boxed{${e.getValue(e.model.selection)}}}`),onMenuSelect:()=>e.insert("\\boxed{#@}",{selectionMode:"item"})},{label:()=>Un(`\\bbox[5px, border: 2px solid red]{${e.getValue(e.model.selection)}}`),onMenuSelect:()=>e.insert("\\bbox[5px, border: 2px solid red]{#@}",{selectionMode:"item"})},{label:()=>Un(`\\bbox[5px, border: 2px dashed black]{${e.getValue(e.model.selection)}}`),onMenuSelect:()=>e.insert("\\bbox[5px, border: 2px dashed black]{#@}",{selectionMode:"item"})}]}function rv(e){const t=[];for(const r of Object.keys(Y))t.push({class:(Xg(Kh(Y[r]))==="#000"?"dark-contrast":"light-contrast")+" menu-swatch",label:``,ariaLabel:()=>{var n;return(n=Se(r))!=null?n:r},checked:()=>{var n;return{some:"mixed",all:!0}[(n=e.queryStyle({backgroundColor:r}))!=null?n:!1]},onMenuSelect:()=>{e.applyStyle({backgroundColor:r},{operation:"toggle"}),e.adoptStyle="none"}});return t}function nv(e){const t=[];for(const r of Object.keys(te))t.push({class:(Kh(te[r])==="#000"?"dark-contrast":"light-contrast")+" menu-swatch",label:``,ariaLabel:()=>{var n;return(n=Se(r))!=null?n:r},checked:()=>{var n;return{some:"mixed",all:!0}[(n=e.queryStyle({color:r}))!=null?n:!1]},onMenuSelect:()=>{e.applyStyle({color:r},{operation:"toggle"}),e.adoptStyle="none"}});return t}var iv=class extends Ah{constructor(e,t,r,n){super(e,t),this.row=r,this.col=n}set active(e){const t=this.parentMenu.children;if(e)for(const r of t)r.element.classList.toggle("active",r.row<=this.row&&r.col<=this.col);else for(const r of t)r.element.classList.remove("active")}};function av(e){const t=[];for(let r=1;r<=5;r++)for(let n=1;n<=5;n++)t.push({onCreate:(i,a)=>new iv(i,a,r,n),label:"\u2610",tooltip:()=>Se("tooltip.row-by-col",r,n),data:{row:r,col:n},onMenuSelect:()=>{e.insert(`\\begin{pmatrix}${Array(r).fill(Array(n).fill("#?").join(" & ")).join("\\\\")}\\end{pmatrix}`,{selectionMode:"item"})}});return t}function ov(e){return[{label:()=>Se("menu.array.add row above"),id:"add-row-above",onMenuSelect:()=>e.executeCommand("addRowBefore"),visible:()=>Ks(e)},{label:()=>Se("menu.array.add row below"),id:"add-row-below",onMenuSelect:()=>e.executeCommand("addRowAfter"),visible:()=>Ks(e)},{label:()=>Se("menu.array.add column before"),id:"add-column-before",onMenuSelect:()=>e.executeCommand("addColumnBefore"),visible:()=>Ks(e),enabled:()=>{const t=e.model.parentEnvironment;if(!t)return!1;const[r,n]=lv(e);return rSe("menu.array.add column after"),id:"add-column-after",onMenuSelect:()=>e.executeCommand("addColumnAfter"),visible:()=>Ks(e)},{type:"divider"},{label:()=>Se("menu.array.delete row"),id:"delete-row",onMenuSelect:()=>e.executeCommand("removeRow"),visible:()=>Ks(e)},{label:()=>Se("menu.array.delete column"),id:"delete-column",onMenuSelect:()=>e.executeCommand("removeColumn"),visible:()=>Ks(e)},{type:"divider"},{label:()=>Se("menu.borders"),visible:()=>(sv(e)||Ks(e))&&e.isSelectionEditable,submenu:[{label:" \u22F1 ",id:"environment-no-border",onMenuSelect:()=>tu(e,"matrix")},{label:"(\u22F1)",id:"environment-parentheses",onMenuSelect:()=>tu(e,"pmatrix")},{label:"[\u22F1]",id:"environment-brackets",onMenuSelect:()=>tu(e,"bmatrix")},{label:"|\u22F1|",id:"environment-bar",onMenuSelect:()=>tu(e,"vmatrix")},{label:"{\u22F1}",id:"environment-braces",onMenuSelect:()=>tu(e,"Bmatrix")}],submenuClass:"border-submenu"},{type:"divider"},{label:()=>Se("menu.insert matrix"),id:"insert-matrix",visible:()=>e.isSelectionEditable,submenu:av(e),submenuClass:"insert-matrix-submenu",columnCount:5},{label:()=>Se("menu.mode"),id:"mode",visible:()=>e.isSelectionEditable&&e.model.selectionIsCollapsed,submenu:[{label:()=>Se("menu.mode-math"),id:"mode-math",onMenuSelect:()=>{Nl(e,"accept-all"),e.executeCommand(["switchMode","math"])},checked:()=>e.model.mode==="math"},{label:()=>Se("menu.mode-text"),id:"mode-text",onMenuSelect:()=>{Nl(e,"accept-all"),e.executeCommand(["switchMode","text"])},checked:()=>e.model.mode==="text"},{label:()=>Se("menu.mode-latex"),id:"mode-latex",onMenuSelect:()=>e.executeCommand(["switchMode","latex"]),checked:()=>e.model.mode==="latex"}]},{type:"divider"},{label:()=>Se("menu.font-style"),id:"variant",visible:()=>e.isSelectionEditable,submenu:Qg(e),submenuClass:"variant-submenu"},{label:()=>Se("menu.color"),id:"color",visible:()=>e.isSelectionEditable,submenu:nv(e),columnCount:4,submenuClass:"swatches-submenu"},{label:()=>Se("menu.background-color"),id:"background-color",visible:()=>e.isSelectionEditable,submenu:rv(e),columnCount:4,submenuClass:"swatches-submenu"},{label:()=>Se("menu.accent"),id:"accent",visible:()=>e.isSelectionEditable,submenu:ev(e),submenuClass:"variant-submenu"},{label:()=>Se("menu.decoration"),id:"decoration",visible:()=>e.isSelectionEditable&&cn(e).length>0,submenu:tv(e),submenuClass:"variant-submenu"},{type:"divider"},{label:()=>Se("menu.evaluate"),id:"ce-evaluate",visible:()=>e.isSelectionEditable&&window.MathfieldElement.computeEngine!==null,onMenuSelect:()=>{const t=cv(e);if(!t){e.model.announce("plonk");return}e.model.selectionIsCollapsed?(e.model.position=e.model.lastOffset,e.insert(`=${t}`,{insertionMode:"insertAfter",selectionMode:"item"})):e.insert(t,{insertionMode:"replaceSelection",selectionMode:"item"})}},{label:()=>Se("menu.simplify"),id:"ce-simplify",visible:()=>e.isSelectionEditable&&window.MathfieldElement.computeEngine!==null,onMenuSelect:()=>{var t,r;if(e.model.selectionIsCollapsed){const n=(t=e.expression)==null?void 0:t.simplify();if(e.model.position=e.model.lastOffset,!n){e.model.announce("plonk");return}e.insert(`=${n.latex}`,{insertionMode:"insertAfter",selectionMode:"item"})}else{const n=(r=window.MathfieldElement.computeEngine)==null?void 0:r.parse(e.getValue(e.model.selection)).simplify();if(!n){e.model.announce("plonk");return}e.insert(n.latex,{insertionMode:"replaceSelection",selectionMode:"item"})}}},{label:()=>{var t;if(window.MathfieldElement.computeEngine===null)return"";const r=(t=e.expression)==null?void 0:t.unknowns[0];return r?Se("menu.solve-for",Un(r)):Se("menu.solve")},id:"ce-solve",visible:()=>{var t;return e.isSelectionEditable&&window.MathfieldElement.computeEngine!==null&&((t=e.expression)==null?void 0:t.unknowns.length)===1&&e.expression.unknowns[0]!=="Nothing"},onMenuSelect:()=>{var t;const r=e.expression,n=r==null?void 0:r.unknowns[0],i=(t=r.solve(n))==null?void 0:t.map(a=>{var s;return(s=a.simplify().latex)!=null?s:""});if(!i){e.model.announce("plonk");return}e.insert(`${n}=${i.length===1?i[0]:"\\left\\lbrace"+(i==null?void 0:i.join(", "))+"\\right\\rbrace"}`,{insertionMode:"replaceAll",selectionMode:"item"})}},{type:"divider"},{label:()=>Se("menu.cut"),onMenuSelect:()=>e.executeCommand("cutToClipboard"),visible:()=>!e.options.readOnly&&e.isSelectionEditable,keyboardShortcut:"meta+X"},{label:()=>Se("menu.copy"),id:"copy",submenu:[{label:()=>Se("menu.copy-as-latex"),id:"copy-latex",onMenuSelect:()=>Qr.copyToClipboard(e,"latex"),keyboardShortcut:"meta+C"},{label:()=>Se("menu.copy-as-ascii-math"),id:"copy-ascii-math",onMenuSelect:()=>Qr.copyToClipboard(e,"ascii-math")},{label:()=>Se("menu.copy-as-mathml"),id:"copy-math-ml",onMenuSelect:()=>Qr.copyToClipboard(e,"math-ml")}]},{label:()=>Se("menu.paste"),id:"paste",onMenuSelect:()=>e.executeCommand("pasteFromClipboard"),visible:()=>e.hasEditableContent,keyboardShortcut:"meta+V"},{label:()=>Se("menu.select-all"),id:"select-all",keyboardShortcut:"meta+A",onMenuSelect:()=>e.executeCommand("selectAll")}]}function Ks(e){var t;return!!((t=e.model.parentEnvironment)!=null&&t.array)}function sv(e){return e.model.at(e.model.position).type==="array"}function lv(e){var t;const r=(t=e.model.parentEnvironment)==null?void 0:t.array;return r?[r.length,r.reduce((n,i)=>Math.max(n,i.length),0)]:[0,0]}function tu(e,t){Td(e),e.flushInlineShortcutBuffer(),sh(e.model,t),xn(e)}function cv(e){var t,r;let n;if(e.model.selectionIsCollapsed?n=(t=window.MathfieldElement.computeEngine)==null?void 0:t.parse(e.getValue(),{canonical:!1}):n=(r=window.MathfieldElement.computeEngine)==null?void 0:r.parse(e.getValue(e.model.selection),{canonical:!1}),!n)return"";let i=n.evaluate();return i.isSame(n)&&(i=n.N()),i.latex}function Pf(e,t,r,n){return{label:()=>Un(`\\${r}{${cn(e)}}`),tooltip:()=>{var i;return(i=Se(n))!=null?i:n},visible:()=>Jg(e,t),checked:()=>{var i;return{some:"mixed",all:!0}[(i=e.queryStyle({variant:t}))!=null?i:!1]},onMenuSelect:()=>{e.applyStyle({variant:t},{operation:"toggle"}),e.adoptStyle="none"}}}function Rf(e,t,r,n){return{label:()=>Un(`\\${r}{${cn(e)}}`),tooltip:()=>{var i;return(i=Se(n))!=null?i:n},visible:()=>Yg(e,t),checked:()=>{var i;return{some:"mixed",all:!0}[(i=e.queryStyle({variantStyle:t}))!=null?i:!1]},onMenuSelect:()=>{e.applyStyle({variantStyle:t},{operation:"toggle"}),e.adoptStyle="none"}}}function Xl(e,t){return e+Gl(t)}Vi({speak:(e,t,r)=>uv(e,t,r)},{target:"mathfield"});function uv(e,t,r){var n,i;r=r!=null?r:{withHighlighting:!1};const{model:a}=e;function s(p){let y=null;switch(p){case"all":y=a.root;break;case"selection":y=a.getAtoms(a.selection);break;case"left":{y=a.getAtoms(a.offsetOf(a.at(a.position).leftSibling),a.position);break}case"right":{y=a.getAtoms(a.position,a.offsetOf(a.at(a.position).rightSibling));break}case"group":y=a.getAtoms(a.getSiblingsRange(a.position));break;case"parent":{const{parent:M}=a.at(a.position);M!=null&&M.parent?y=M:y=a.root;break}default:y=a.root}return y}function u(p){let y="";switch(p){case"all":console.log("Internal failure: speak all failed");break;case"selection":y="no selection";break;case"left":y="at start";break;case"right":y="at end";break;case"group":console.log("Internal failure: speak group failed");break;case"parent":y="no parent";break;default:console.log('unknown speak_ param value: "'+p+'"');break}return y}const d=s(t);if(d===null)return(i=(n=window.MathfieldElement).speakHook)==null||i.call(n,u(t)),!1;(r.withHighlighting||window.MathfieldElement.speechEngine==="amazon")&&(window.MathfieldElement.textToSpeechMarkup=window.sre&&window.MathfieldElement.textToSpeechRules==="sre"?"ssml_step":"ssml");const h=Gl(d);return Ke()&&r.withHighlighting?(ts().readAloudMathfield=e,Is(e,{forHighlighting:!0}),window.MathfieldElement.readAloudHook&&window.MathfieldElement.readAloudHook(e.field,h)):window.MathfieldElement.speakHook&&window.MathfieldElement.speakHook(h),!1}function dv(e){var t,r;if(!Ke()){console.log("Speak:",e);return}if(!window.MathfieldElement.speechEngine||window.MathfieldElement.speechEngine==="local"){const n=new SpeechSynthesisUtterance(e);window.speechSynthesis.speak(n)}else if(window.MathfieldElement.speechEngine==="amazon")if(!("AWS"in window))console.error("MathLive 0.98.5: AWS SDK not loaded. See https://www.npmjs.com/package/aws-sdk");else{const n=new window.AWS.Polly({apiVersion:"2016-06-10"}),i={OutputFormat:"mp3",VoiceId:(t=window.MathfieldElement.speechEngineVoice)!=null?t:"Joanna",Engine:["Amy","Emma","Brian","Ivy","Joanna","Kendra","Kimberly","Salli","Joey","Justin","Matthew"].includes((r=window.MathfieldElement.speechEngineVoice)!=null?r:"Joanna")?"neural":"standard",Text:e,TextType:"ssml"};n.synthesizeSpeech(i,(a,s)=>{if(a)console.trace(`MathLive 0.98.5: \`polly.synthesizeSpeech()\` error: ${a}`);else if(s!=null&&s.AudioStream){const u=new Uint8Array(s.AudioStream),d=new Blob([u.buffer],{type:"audio/mpeg"}),h=URL.createObjectURL(d);new Audio(h).play().catch(y=>console.log(y))}else console.log("polly.synthesizeSpeech():",s)})}else window.MathfieldElement.speechEngine==="google"&&console.error("MathLive 0.98.5: The Google speech engine is not supported yet. Please come again.")}function Wh(e){var t;let r;if(e.parent.type==="prompt")e.parentBranch==="body"&&(r="prompt");else if(e.parentBranch==="body")r=e.type&&(t={enclose:"cross out",leftright:"delimiter",surd:"square root",root:"math field",mop:"operator",first:"first"}[e.type])!=null?t:"parent";else if(e.parent.type==="genfrac"){if(e.parentBranch==="above")return"numerator";if(e.parentBranch==="below")return"denominator"}else e.parent.type==="surd"?e.parentBranch==="above"&&(r="index"):e.parentBranch==="superscript"?r="superscript":e.parentBranch==="subscript"&&(r="subscript");return r||console.log("unknown relationship"),r!=null?r:"parent"}function fv(e,t,r,n){let i="";if(t==="plonk")window.MathfieldElement.playSound("plonk"),e.flushInlineShortcutBuffer();else if(t==="delete")i=Xl("deleted: ",n);else if(t==="focus"||t.includes("move"))i=hv(e.model,r)+(e.model.selectionIsCollapsed?"":"selected: ")+pv(e.model);else if(t==="replacement")i=Xl("",e.model.at(e.model.position));else if(t==="line"){const a=Xl("",e.model.root);e.keyboardDelegate.setAriaLabel(a)}else i=n?Xl(t+" ",n):t;if(i){const a=e.ariaLiveText.textContent.includes("\xA0")?" \u202F ":" \xA0 ";e.ariaLiveText.textContent=i+a}}function hv(e,t){if(Number.isNaN(t))return"";const r=e.at(t);if(!r||r.treeDepth<=e.at(e.position).treeDepth)return"";let n="",i=r.parent;const a=e.at(e.position).parent;for(;i!==e.root&&i!==a;)n+=`out of ${Wh(i)};`,i=i.parent;return n}function pv(e){if(!e.selectionIsCollapsed)return Xl("",e.getAtoms(e.selection));let t="";const r=e.at(e.position),n=Wh(r);return r.isFirstSibling&&(t=(n?"start of "+n:"unknown")+": "),r.isLastSibling?r.isFirstSibling||(t+=n?"end of "+n:"unknown"):t+=Xl("",r),t}var mv=class{constructor(e,t,r){this.mathfield=e,this.mode=t,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(){const e={ranges:[...this._selection.ranges]};return this.selection.direction&&this.selection.direction!=="none"&&(e.direction=this.selection.direction),{content:this.root.toJson(),selection:e,mode:this.mode}}setState(e,t){var r;const n=this.silenceNotifications;this.silenceNotifications=(r=t==null?void 0:t.silenceNotifications)!=null?r:!0;let i={};if((t==null?void 0:t.type)==="undo"&&(i={inputType:"historyUndo"}),(t==null?void 0:t.type)==="redo"&&(i={inputType:"historyRedo"}),this.contentWillChange(i)){const a=this.silenceNotifications;this.silenceNotifications=!0,this.mode=e.mode,this.root=wi(e.content),this.selection=e.selection,this.silenceNotifications=a,this.contentDidChange(i)}this.silenceNotifications=n}get atoms(){return this.root.children}get selection(){return this._selection}set selection(e){this.setSelection(e)}setSelection(e,t){return!this.mathfield.contentEditable&&this.mathfield.userSelect==="none"?!1:this.deferNotifications({selection:!0},()=>{var r,n,i;const a=this.normalizeSelection(e,t);if(a===void 0)throw new TypeError("Invalid selection");if(a.ranges.length===1&&a.ranges[0][0]===a.ranges[0][1]){const p=a.ranges[0][0];if(!this.mathfield.dirty&&!((r=this.at(p))!=null&&r.parentPrompt)&&this.mathfield.hasEditablePrompts){if((n=this.at(p-1))!=null&&n.parentPrompt){this._anchor=this.normalizeOffset(p-1),this._position=this._anchor,this._selection=this.normalizeSelection(this._anchor);return}if((i=this.at(p+1))!=null&&i.parentPrompt){this._anchor=this.normalizeOffset(p+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=p,this._position=p,this._selection=a;return}const s=Qn(a);a.direction==="backward"?[this._position,this._anchor]=s:[this._anchor,this._position]=s;const u=this.at(s[0]+1),d=this.at(s[1]),h=_e.commonAncestor(u,d);(h==null?void 0:h.type)==="array"&&u.parent===h&&d.parent===h?this._selection={ranges:[s],direction:a.direction}:this._selection={ranges:[s],direction:a.direction},console.assert(this._position>=0&&this._position<=this.lastOffset)})}setPositionHandlingPlaceholder(e){var t;const r=this.at(e);(r==null?void 0:r.type)==="placeholder"?this.setSelection(e-1,e):((t=r==null?void 0:r.rightSibling)==null?void 0:t.type)==="placeholder"?this.setSelection(e,e+1):this.position=e,r instanceof Pt&&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 Math.abs(this._anchor-this._position)===1?this.at(Math.max(this._anchor,this._position)).type==="placeholder":!1}collapseSelection(e="forward"){return this._anchor===this._position?!1:(e==="backward"?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){const t=this.at(e),{parent:r}=t;if(!r)return[0,this.lastOffset];const n=t.parent.branch(t.parentBranch);return[this.offsetOf(n[0]),this.offsetOf(n[n.length-1])]}getBranchRange(e,t){const r=this.at(e).branch(t);return[this.offsetOf(r[0]),this.offsetOf(r[r.length-1])]}getAtoms(e,t,r){let n=r!=null?r:{};if(Cs(e)){if(n=t!=null?t:{},e.ranges.length>1)return e.ranges.reduce((h,p)=>[...h,...this.getAtoms(p,n)],[]);e=e.ranges[0]}let i,a;if(Ga(e)){if(i=e,!Ga(t))return[];a=t}else[i,a]=e,n=t!=null?t:{};if(!Number.isFinite(i))return[];n.includeChildren===void 0&&(n.includeChildren=!1),i<0&&(i=this.lastOffset-i+1),a<0&&(a=this.lastOffset-a+1);const s=Math.min(i,a)+1,u=Math.max(i,a);if(!n.includeChildren&&s===1&&u===this.lastOffset)return[this.root];let d=[];for(let h=s;h<=u;h++){const p=this.atoms[h];Vh(this,p,s,u)&&d.push(p)}return n.includeChildren||(d=d.filter(h=>{let p=!1,{parent:y}=h;for(;y&&!p;)p=Vh(this,y,s,u),y=y.parent;return!p})),d}getAllAtoms(e=0){const t=[],r=this.lastOffset;for(let n=e;n<=r;n++)t.push(this.atoms[n]);for(let n=0;n=0;a--)if(n=this.atoms[a],e(n))return n;for(let a=i;a>t;a--)if(n=this.atoms[a],e(n))return n}extractAtoms(e){let t=this.getAtoms(e);if(t.length===1&&!t[0].parent)if(t[0].type==="root")t=[...t[0].body],t.shift();else return t=this.root.cells.flat(),this.root=new _e({type:"root",body:[]}),t;for(const r of t)r.parent.removeChild(r);return t}deleteAtoms(e){this.extractAtoms(e),this.position=e[0]}atomToString(e,t){const r=t!=null?t:"latex";if(r.startsWith("latex"))return _e.serialize([e],{expandMacro:r==="latex-expanded",skipStyles:r==="latex-unstyled",skipPlaceholders:r==="latex-without-placeholders",defaultMode:this.mathfield.options.defaultMode});if(r==="math-ml")return Hr(e);if(r==="spoken")return Gl(e);if(r==="spoken-text"){const n=window.MathfieldElement.textToSpeechMarkup;window.MathfieldElement.textToSpeechMarkup="";const i=Gl(e);return window.MathfieldElement.textToSpeechMarkup=n,i}if(r==="spoken-ssml"||r==="spoken-ssml-with-highlighting"){const n=window.MathfieldElement.textToSpeechMarkup;window.MathfieldElement.textToSpeechMarkup="ssml";const i=Gl(e);return window.MathfieldElement.textToSpeechMarkup=n,i}return r==="ascii-math"?Mn(e):(console.error(`MathLive 0.98.5: Unexpected format "${r}`),"")}getValue(e,t,r){if(e===void 0)return this.atomToString(this.root,"latex");if(typeof e=="string"&&e!=="math-json")return this.atomToString(this.root,e);let n,i;if(Ga(e)&&Ga(t)?(n=[this.normalizeRange([e,t])],i=r):Lo(e)?(n=[this.normalizeRange(e)],i=t):Cs(e)?(n=e.ranges,i=t):(n=[this.normalizeRange([0,-1])],i=e),i!=null||(i="latex"),i==="math-json"){if(!window.MathfieldElement.computeEngine)return window[Symbol.for("io.cortexjs.compute-engine")]||console.error(`The CortexJS Compute Engine library is not available.
Load the library, for example with:
import "https://unpkg.com/@cortex-js/compute-engine?module"`),'["Error", "compute-engine-not-available"]';const a=this.getValue({ranges:n},"latex-unstyled");try{const s=window.MathfieldElement.computeEngine.parse(a);return JSON.stringify(s.json)}catch(s){return JSON.stringify(["Error",`'${s.toString()}'`])}}if(i.startsWith("latex")){const a={expandMacro:i==="latex-expanded",skipStyles:i==="latex-unstyled",skipPlaceholders:i==="latex-without-placeholders",defaultMode:this.mathfield.options.defaultMode};return Cr(n.map(s=>_e.serialize(this.getAtoms(s),a)))}return n.map(a=>this.getAtoms(a).map(s=>this.atomToString(s,i)).join("")).join("")}extendSelectionTo(e,t){return!this.mathfield.contentEditable&&this.mathfield.userSelect==="none"?!1:this.deferNotifications({selection:!0},()=>{const r=this.normalizeRange([e,t]);let[n,i]=r,{parent:a}=this.at(i);if(a&&(a.type==="genfrac"||a.type==="subsup"))for(;a!==this.root&&Of(this,a,[n,i]);)i=this.offsetOf(a),a=a.parent;for(a=this.at(n).parent;a!==this.root&&Of(this,a,[n,i]);)n=this.offsetOf(a.leftSibling),a=a.parent;if(a=this.at(i).parent,(a==null?void 0:a.type)==="genfrac")for(;a!==this.root&&Of(this,a,[n,i]);)i=this.offsetOf(a),console.assert(i>=0),a=a.parent;this._position=this.normalizeOffset(t),this._selection={ranges:[[n,i]],direction:"none"}})}announce(e,t,r=[]){var n,i;((i=(n=this.mathfield.host)==null?void 0:n.dispatchEvent(new CustomEvent("announce",{detail:{command:e,previousPosition:t,atoms:r},cancelable:!0,bubbles:!0,composed:!0})))!=null?i:!0)&&fv(this.mathfield,e,t,r)}deferNotifications(e,t){const r=this._selection,n=this._anchor,i=this._position,a=this.silenceNotifications;this.silenceNotifications=!0;const s=this.root.changeCounter;t();const u=this.root.changeCounter!==s,d=n!==this._anchor||i!==this._position||E0(this._selection,r)==="different";return this.silenceNotifications=a,e.content&&u&&this.contentDidChange({inputType:e.type}),e.selection&&d&&this.selectionDidChange(),u||d}normalizeOffset(e){return e>0?e=Math.min(e,this.lastOffset):e<0&&(e=this.lastOffset+e+1),e}normalizeRange(e){let[t,r]=e;return t=this.normalizeOffset(t),r=this.normalizeOffset(r),tthis.normalizeRange(i)),direction:(r=e.direction)!=null?r:"none"});return console.assert(n!==void 0),n}get parentEnvironment(){let e=this.at(this.position).parent;if(e){for(;e.parent&&e.type!=="array";)e=e.parent;if(e.type==="array")return e}}get cell(){var e;let t=this.at(this.position);if(t){for(;t&&((e=t.parent)==null?void 0:e.type)!=="array";)t=t.parent;if(!(!(t!=null&&t.parent)||t.parent.type!=="array"))return t.parentBranch}}contentWillChange(e={}){if(this.silenceNotifications||!this.mathfield)return!0;const t=this.silenceNotifications;this.silenceNotifications=!0;const r=this.mathfield.onContentWillChange(e);return this.silenceNotifications=t,r}contentDidChange(e){var t;if(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(ao(this.mathfield)),this.silenceNotifications||!this.mathfield.host||!this.mathfield)return;const r=this.silenceNotifications;this.silenceNotifications=!0,this.mathfield.host.dispatchEvent(new InputEvent("input",_(S({},e),{data:e.data?e.data:(t=e.inputType)!=null?t:"",bubbles:!0,composed:!0}))),this.silenceNotifications=r}selectionDidChange(){if(!this.mathfield||(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(ao(this.mathfield)),this.silenceNotifications))return;const e=this.silenceNotifications;this.silenceNotifications=!0,this.mathfield.onSelectionDidChange(),this.silenceNotifications=e}};function Vh(e,t,r,n){const i=e.offsetOf(t);if(in)return!1;if(!t.hasChildren)return!0;const a=e.offsetOf(t.firstChild);if(a>=r&&a<=n){const s=e.offsetOf(t.lastChild);if(s>=r&&s<=n)return!0}return!1}function Of(e,t,r){if(!(t!=null&&t.hasChildren))return!1;const[n,i]=r,a=e.offsetOf(t.firstChild),s=e.offsetOf(t.lastChild);return a>=n&&a<=i&&s>=a&&s<=i}function ru(e,t,r,n){var i,a,s,u,d,h;const p=r.parent;if(p&&r instanceof ln){const y=!n&&t==="forward"||n==="body"&&t==="backward";let M=y?e.offsetOf(r.firstChild):e.offsetOf(r.lastChild);return y?r.rightDelim!=="?"&&r.rightDelim!=="."?(r.leftDelim=".",r.isDirty=!0):(p.addChildrenAfter(r.removeBranch("body"),r),p.removeChild(r),M--):r.leftDelim!=="?"&&r.leftDelim!=="."?(r.rightDelim=".",r.isDirty=!0):(p.addChildrenAfter(r.removeBranch("body"),r),p.removeChild(r),M--),e.position=M,!0}if(p&&r.type==="surd"){if(t==="forward"&&!n||t==="backward"&&n==="body"){const y=r.leftSibling;r.hasChildren&&p.addChildrenAfter(r.removeBranch("body"),r),p.removeChild(r),e.position=e.offsetOf(y)}else t==="forward"&&n==="body"?e.position=e.offsetOf(r):!n&&t==="backward"?r.hasChildren?e.position=e.offsetOf(r.lastChild):(e.position=Math.max(0,e.offsetOf(r)-1),p.removeChild(r)):n==="above"&&(r.hasEmptyBranch("above")&&r.removeBranch("above"),t==="backward"?e.position=e.offsetOf(r.leftSibling):e.position=e.offsetOf(r.body[0]));return!0}if(p&&(r.type==="box"||r.type==="enclose")){const y=n&&t==="backward"||!n&&t==="forward"?r.leftSibling:r.lastChild;return p.addChildrenAfter(r.removeBranch("body"),r),p.removeChild(r),e.position=e.offsetOf(y),!0}if(r.type==="genfrac"||r.type==="overunder"){if(!n)return r.type==="overunder"&&r.hasEmptyBranch("body")||r.type==="genfrac"&&r.hasEmptyBranch("below")&&r.hasEmptyBranch("above")?!1:(e.position=e.offsetOf(t==="forward"?r.firstChild:r.lastChild),!0);const y=nu.fractionNavigationOrder==="numerator-denominator"?"above":"below",M=y==="above"?"below":"above";if(p&&(t==="forward"&&n===y||t==="backward"&&n===M)){const I=r.removeBranch(y),$=r.removeBranch(M);return p.addChildrenAfter([...I,...$],r),p.removeChild(r),e.position=e.offsetOf(I.length>0?I[I.length-1]:$[0]),!0}return t==="backward"?e.position=e.offsetOf(r.leftSibling):e.position=e.offsetOf(r),!0}if(r.isExtensibleSymbol||r.type==="subsup"){if(!n&&t==="forward")return!1;if(!n){if(r.subscript||r.superscript){const y=t==="forward"?(s=(i=r.superscript)==null?void 0:i[0])!=null?s:(a=r.subscript)==null?void 0:a[0]:(h=(u=r.subscript)==null?void 0:u[0].lastSibling)!=null?h:(d=r.superscript)==null?void 0:d[0].lastSibling;return y&&(e.position=e.offsetOf(y)),!0}return!1}if(!r.hasChildren&&r.type==="subsup"){const y=t==="forward"?e.offsetOf(r):Math.max(0,e.offsetOf(r)-1);return r.parent.removeChild(r),e.position=y,!0}if(n==="superscript")if(t==="backward"){const y=e.offsetOf(r.firstChild)-1;console.assert(y>=0),e.position=y}else r.subscript?e.position=e.offsetOf(r.subscript[0]):e.position=e.offsetOf(r);else n==="subscript"&&(t==="backward"&&r.superscript?e.position=e.offsetOf(r.superscript[0].lastSibling):t==="backward"?e.position=e.offsetOf(r.firstChild)-1:e.position=e.offsetOf(r));if(n&&r.hasEmptyBranch(n)&&(r.removeBranch(n),r.type==="subsup"&&!r.subscript&&!r.superscript)){const y=t==="forward"?e.offsetOf(r):Math.max(0,e.offsetOf(r)-1);r.parent.removeChild(r),e.position=y}return!0}if((p==null?void 0:p.type)==="genfrac"&&!n&&r.type!=="first"){let y=e.offsetOf(r.leftSibling);return p.removeChild(r),p.hasEmptyBranch("above")&&p.hasEmptyBranch("below")?(y=e.offsetOf(p.leftSibling),p.parent.removeChild(p),e.announce("delete",void 0,[p]),e.position=y,!0):(e.announce("delete",void 0,[r]),e.position=y,!0)}if(t==="backward"&&((p==null?void 0:p.command)==="\\ln"||(p==null?void 0:p.command)==="\\log")&&r.parentBranch!=="body"){const y=e.offsetOf(p.leftSibling);return p.parent.removeChild(p),e.announce("delete",void 0,[p]),e.position=y,!0}return!1}function gv(e){return!e.mathfield.isSelectionEditable||!e.contentWillChange({inputType:"deleteContentBackward"})?!1:e.selectionIsCollapsed?e.deferNotifications({content:!0,selection:!0,type:"deleteContentBackward"},()=>{let t=e.at(e.position);if(!(t&&ru(e,"backward",t))){if(t!=null&&t.isFirstSibling){if(ru(e,"backward",t.parent,t.parentBranch))return;t=null}if(!t){e.announce("plonk");return}e.position=e.offsetOf(t.leftSibling),t.parent.removeChild(t),e.announce("delete",void 0,[t])}}):so(e,Qn(e.selection),"deleteContentBackward")}function vv(e){return!e.mathfield.isSelectionEditable||!e.contentWillChange({inputType:"deleteContentForward"})?!1:e.selectionIsCollapsed?e.deferNotifications({content:!0,selection:!0,type:"deleteContentForward"},()=>{var t,r;let n=e.at(e.position).rightSibling;if(n&&ru(e,"forward",n))return;if(n){if(e.at(e.position).isLastSibling&&ru(e,"forward",n.parent,n.parentBranch))return}else{if(n=e.at(e.position),n.isLastSibling&&ru(e,"forward",n.parent,n.parentBranch))return;n=void 0}if(e.position===e.lastOffset||!n){e.announce("plonk");return}n.parent.removeChild(n);let i=(t=e.at(e.position))==null?void 0:t.rightSibling;for(;(i==null?void 0:i.type)==="subsup";)i.parent.removeChild(i),i=(r=e.at(e.position))==null?void 0:r.rightSibling;e.announce("delete",void 0,[n])}):so(e,Qn(e.selection),"deleteContentForward")}function so(e,t,r){const n=e.getAtoms(t);if(n.length>0&&n[0].parent){let i=n[0].parent.firstChild;i.type==="first"&&(i=i.rightSibling);const a=n[n.length-1].parent.lastChild;let s=n[0];s.type==="first"&&(s=s.rightSibling);const u=n[n.length-1];if(s===i&&u===a){const d=n[0].parent;d.parent&&d.type!=="prompt"&&(t=[e.offsetOf(d.leftSibling),e.offsetOf(d)])}if(n.length===1&&n[0].type==="placeholder"&&n[0].parent.type==="genfrac"){const d=n[0].parent,h=n[0].parentBranch==="below"?"above":"below",p=e.offsetOf(d.leftSibling);return e.deferNotifications({content:!0,selection:!0,type:r},()=>{var y,M;const I=d.removeBranch(h);if(I.length===1&&I[0].type==="placeholder")(M=d.parent)==null||M.removeChild(d),e.position=Math.max(0,p);else{const $=d.parent.addChildrenAfter(I,d);(y=d.parent)==null||y.removeChild(d),e.position=e.offsetOf($)}})}}return e.deferNotifications({content:!0,selection:!0,type:r},()=>e.deleteAtoms(t))}Vi({deleteAll:e=>e.contentWillChange({inputType:"deleteContent"})&&so(e,[0,-1],"deleteContent"),deleteForward:e=>vv(e),deleteBackward:e=>gv(e),deleteNextWord:e=>e.contentWillChange({inputType:"deleteWordForward"})&&so(e,[e.anchor,ff(e,e.position,"forward")],"deleteWordForward"),deletePreviousWord:e=>e.contentWillChange({inputType:"deleteWordBackward"})&&so(e,[e.anchor,ff(e,e.position,"backward")],"deleteWordBackward"),deleteToGroupStart:e=>e.contentWillChange({inputType:"deleteSoftLineBackward"})&&so(e,[e.anchor,e.offsetOf(e.at(e.position).firstSibling)],"deleteSoftLineBackward"),deleteToGroupEnd:e=>e.contentWillChange({inputType:"deleteSoftLineForward"})&&so(e,[e.anchor,e.offsetOf(e.at(e.position).lastSibling)],"deleteSoftLineForward"),deleteToMathFieldStart:e=>e.contentWillChange({inputType:"deleteHardLineBackward"})&&so(e,[e.anchor,0],"deleteHardLineBackward"),deleteToMathFieldEnd:e=>e.contentWillChange({inputType:"deleteHardLineForward"})&&so(e,[e.anchor,-1],"deleteHardLineForward")},{target:"model",audioFeedback:"delete",canUndo:!0,changeContent:!0,changeSelection:!0});var bv=``,yv=``,xv=class{constructor(e,t){this.focusBlurInProgress=!1;var r,n,i;this.options=S(_(S({},Zd()),{macros:vt(),registers:id()}),Vd(t)),this.eventController=new AbortController;const a=this.eventController.signal;t.eventSink&&(this.host=t.eventSink),this.element=e,e.mathfield=this,this.blurred=!0,this.keystrokeCaptionVisible=!1,this.suggestionIndex=0,this.inlineShortcutBuffer=[],this.inlineShortcutBufferFlushTimer=0,this.defaultStyle={},this.adoptStyle="left",this.options.defaultMode==="inline-math"?this.element.classList.add("ML__is-inline"):this.element.classList.remove("ML__is-inline"),this.dirty=!1;let s=(n=(r=t.value)!=null?r:this.element.textContent)!=null?n:"";s=s.trim();const u=ih(this.options),d=new _e({type:"root",mode:u,body:b(s,{context:this.context})});this.model=new mv(this,u,d),this.undoManager=new Zm(this.model);const h=[];if(h.push(""),h.push(''),h.push(""),h.push(Xf(this)),h.push(""),window.mathVirtualKeyboard&&(h.push(``),h.push(bv),h.push("
")),h.push('"),h.push(""),h.push(""),h.push(""),h.push(""),this.element.innerHTML=window.MathfieldElement.createHTML(h.join("")),!this.element.children){console.error("%cMathLive 0.98.5: 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");return}this._l10Subscription=Ce.subscribe(()=>Ce.update(this.element)),Ce.update(this.element),this.field=this.element.querySelector("[part=content]"),this.field.addEventListener("click",y=>y.stopImmediatePropagation(),{capture:!1,signal:a}),this.field.addEventListener("wheel",this,{passive:!1,signal:a}),"PointerEvent"in window?this.field.addEventListener("pointerdown",this,{signal:a}):this.field.addEventListener("mousedown",this,{signal:a}),(i=this.element.querySelector("[part=virtual-keyboard-toggle]"))==null||i.addEventListener("click",()=>{window.mathVirtualKeyboard.visible?window.mathVirtualKeyboard.hide():(window.mathVirtualKeyboard.show({animate:!0}),window.mathVirtualKeyboard.update(ao(this)))},{signal:a}),this._menu=new Lg(ov(this),{host:this.host}),this.field.addEventListener("contextmenu",this,{signal:a});const p=this.element.querySelector("[part=menu-toggle]");p==null||p.addEventListener("pointerdown",y=>{if(y.currentTarget!==p||this._menu.state!=="closed")return;this.element.classList.add("tracking");const M=p.getBoundingClientRect();this._menu.modifiers=Bs(y),this._menu.show({target:p,location:{x:M.left,y:M.bottom},onDismiss:()=>this.element.classList.remove("tracking")}),y.preventDefault(),y.stopPropagation()},{signal:a}),(this.model.atoms.length<=1||this.disabled||this.readOnly&&!this.hasEditableContent||this.userSelect==="none")&&(p.style.display="none"),this.ariaLiveText=this.element.querySelector("[role=status]"),this.keyboardDelegate=Xp(this.element.querySelector(".ML__keyboard-sink"),this.element,this),window.addEventListener("resize",this,{signal:a}),document.addEventListener("scroll",this,{signal:a}),this.resizeObserver=new ResizeObserver(()=>xn(this)),this.resizeObserver.observe(this.field),window.mathVirtualKeyboard.addEventListener("virtual-keyboard-toggle",this,{signal:a}),Kc&&!Ce.locale.startsWith(Kc.locale)&&jp(Ce.locale),ra!=="ready"&&document.fonts.ready.then(()=>Fd(this)),e.querySelector("[part=container]").style.removeProperty("visibility"),this.undoManager.startRecording(),this.undoManager.snapshot("set-value")}get defaultStyle(){return this._defaultStyle}set defaultStyle(e){this._defaultStyle=e}get effectiveStyle(){if(this.adoptStyle==="none")return this.defaultStyle;const e=this.model.at(this.model.position),t=this.adoptStyle==="right"?e.rightSibling:e;if(!t)return this.defaultStyle;if(t.type==="group"){const r=t.branch("body");return!r||r.length<2?{}:this.adoptStyle==="right"?r[1].computedStyle:r[r.length-1].computedStyle}return t.computedStyle}connectToVirtualKeyboard(){this.connectedToVirtualKeyboard||(this.connectedToVirtualKeyboard=!0,window.addEventListener("message",this,{signal:this.eventController.signal}),window.mathVirtualKeyboard.connect(),window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(ao(this)),n0(this))}disconnectFromVirtualKeyboard(){this.connectedToVirtualKeyboard&&(window.removeEventListener("message",this),window.mathVirtualKeyboard.disconnect(),this.connectedToVirtualKeyboard=!1,_f())}showMenu(e){var t,r;const n=(r=(t=e==null?void 0:e.location)!=null?t:Sl(this.field))!=null?r:void 0,i=e==null?void 0:e.modifiers,a=this.element.querySelector("[part=container]");return this._menu.show({target:a,location:n,modifiers:i})}get colorMap(){return e=>{var t,r,n;return(n=(r=(t=this.options).colorMap)==null?void 0:r.call(t,e))!=null?n:ut(e)}}get backgroundColorMap(){return e=>{var t,r,n,i,a,s;return(s=(a=(r=(t=this.options).backgroundColorMap)==null?void 0:r.call(t,e))!=null?a:(i=(n=this.options).colorMap)==null?void 0:i.call(n,e))!=null?s:dt(e)}}get smartFence(){var e;return(e=this.options.smartFence)!=null?e:!1}get readOnly(){var e;return(e=this.options.readOnly)!=null?e:!1}get disabled(){var e,t;return(t=(e=this.host)==null?void 0:e.disabled)!=null?t:!1}get contentEditable(){return this.host?this.host.getAttribute("contenteditable")!=="false":!1}get userSelect(){if(!this.host)return"";const e=getComputedStyle(this.host);return e.getPropertyValue("user-select")||e.getPropertyValue("-webkit-user-select")}get hasEditableContent(){return this.disabled||!this.contentEditable?!1:!this.readOnly||this.hasEditablePrompts}get hasEditablePrompts(){return this.readOnly&&!this.disabled&&this.contentEditable&&this.model.findAtom(e=>e.type==="prompt"&&!e.locked)!==void 0}get isSelectionEditable(){if(this.disabled||!this.contentEditable)return!1;if(!this.readOnly)return!0;const e=this.model.at(this.model.anchor),t=this.model.at(this.model.position),r=_e.commonAncestor(e,t);return!!((r==null?void 0:r.type)==="prompt"||r!=null&&r.parentPrompt)}get letterShapeStyle(){var e;return(e=this.options.letterShapeStyle)!=null?e:"tex"}get minFontScale(){return this.options.minFontScale}get selectionStyle(){if(this.model.selectionIsCollapsed)return this.effectiveStyle;const e=this.model.getAtoms(this.model.selection);if(e.length===0)return{};const t=S({},e[0].style);for(const r of e)for(const[n,i]of Object.entries(r.style))t[n]!==i&&delete t[n];return t}queryStyle(e){const t=bf(this,e);"verbatimColor"in t&&delete t.verbatimColor,"verbatimBackgroundColor"in t&&delete t.verbatimBackgroundColor;const r=Object.keys(t).length;if(r===0)return"all";if(r>1){for(const d of Object.keys(t)){const h=this.queryStyle({[d]:t[d]});if(h==="none")return"none";if(h==="some")return"some"}return"all"}const n=Object.keys(t)[0],i=t[n];if(this.model.selectionIsCollapsed)return this.effectiveStyle[n]===i?"all":"none";const a=this.model.getAtoms(this.model.selection,{includeChildren:!0});let s=a.length;if(s===0)return"none";let u=0;for(const d of a){if(d.type==="first"){s-=1;continue}d.style[n]===i&&(u+=1)}return u===0?"none":u===s?"all":"some"}get keybindings(){var e,t;if(this._keybindings)return this._keybindings;const[r,n]=tm(this.options.keybindings,(e=Hc())!=null?e:Up());return((t=Hc())==null?void 0:t.score)>0&&(this._keybindings=r,n.length>0&&console.error("MathLive 0.98.5: Invalid keybindings for current keyboard layout",n)),r}get menu(){return this._menu}setOptions(e){var t;this.options=S(S({},this.options),Vd(e)),this._keybindings=void 0,this.options.defaultMode==="inline-math"?this.element.classList.add("ML__is-inline"):this.element.classList.remove("ML__is-inline");let r=this.options.defaultMode;r==="inline-math"&&(r="math"),((t=this.model.root.firstChild)==null?void 0:t.mode)!==r&&(this.model.root.firstChild.mode=r),this.options.readOnly&&this.hasFocus()&&window.mathVirtualKeyboard.visible&&this.executeCommand("hideVirtualKeyboard");const n=_e.serialize([this.model.root],{expandMacro:!1,defaultMode:this.options.defaultMode});("macros"in e||this.model.getValue()!==n)&&Qr.insert(this.model,n,{insertionMode:"replaceAll",selectionMode:"after",format:"latex",silenceNotifications:!0,mode:"math"}),("value"in e||"macros"in e||"registers"in e||"colorMap"in e||"backgroundColorMap"in e||"letterShapeStyle"in e||"minFontScale"in e||"readOnly"in e||"placeholderSymbol"in e)&&xn(this)}getOptions(e){return Ts(this.options,e)}getOption(e){return Ts(this.options,e)}handleEvent(e){return rs(this,null,function*(){var t;if(Bo(this)){if(lf(e)){if(!Tc(e.origin,(t=this.options.originValidator)!=null?t:"none"))throw new DOMException(`Message from unknown origin (${e.origin}) cannot be handled`,"SecurityError");const{action:r}=e.data;if(r==="execute-command"){const n=e.data.command;if(zl(n)==="virtual-keyboard")return;this.executeCommand(n)}else r==="update-state"||(r==="focus"?this.focus({preventScroll:!0}):r==="blur"&&this.blur());return}switch(e.type){case"focus":this.onFocus();break;case"blur":this.onBlur();break;case"mousedown":this.userSelect!=="none"&&yh(this,e);break;case"pointerdown":this.userSelect!=="none"&&(yh(this,e),e.shiftKey===!1&&(yield $h(e,this.element.querySelector("[part=container]"),this._menu))&&Qd.stop());break;case"contextmenu":this.userSelect!=="none"&&e.shiftKey===!1&&(yield $h(e,this.element.querySelector("[part=container]"),this._menu))&&Qd.stop();break;case"virtual-keyboard-toggle":this.hasFocus()&&n0(this);break;case"resize":this.geometryChangeTimer&&cancelAnimationFrame(this.geometryChangeTimer),this.geometryChangeTimer=requestAnimationFrame(()=>Bo(this)&&this.onGeometryChange());break;case"scroll":this.geometryChangeTimer&&cancelAnimationFrame(this.geometryChangeTimer),this.geometryChangeTimer=requestAnimationFrame(()=>Bo(this)&&this.onGeometryChange());break;case"wheel":this.onWheel(e);break;default:console.warn("Unexpected event type",e.type)}}})}dispose(){if(!Bo(this))return;Ce.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();const e=this.element;delete e.mathfield,this.element=void 0,this.host=void 0,this.field=void 0,this.ariaLiveText=void 0,rg(),sm(),_g()}flushInlineShortcutBuffer(e){if(e!=null||(e={defer:!1}),!e.defer){this.inlineShortcutBuffer=[],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 zl(e)==="virtual-keyboard"?(this.focus({preventScroll:!0}),window.mathVirtualKeyboard.executeCommand(e),requestAnimationFrame(()=>window.mathVirtualKeyboard.update(ao(this))),!1):pm(this,e)}get errors(){return D(this.model.getValue(),{context:this.context})}getValue(e,t,r){return this.model.getValue(e,t,r)}setValue(e,t){var r;t=t!=null?t:{mode:"math"},t.insertionMode===void 0&&(t.insertionMode="replaceAll"),(t.format===void 0||t.format==="auto")&&(t.format="latex"),(t.mode===void 0||t.mode==="auto")&&(t.mode=(r=D0(this.model,this.model.position))!=null?r:"math");const n=this.undoManager.canUndo();Qr.insert(this.model,e,t)&&(xn(this),n||this.undoManager.reset(),this.undoManager.snapshot("set-value"))}get expression(){const e=window.MathfieldElement.computeEngine;return e?e.box(e.parse(this.model.getValue("latex-unstyled"))):(console.error("MathLive 0.98.5: 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){const n=window.mathVirtualKeyboard.boundingRect,i=this.host.getBoundingClientRect();i.bottom>n.top&&((e=window.document.scrollingElement)==null||e.scrollBy(0,i.bottom-n.top+8))}}this.dirty&&Is(this,{interactive:!0});const t=this.field.getBoundingClientRect();let r=null;if(this.model.selectionIsCollapsed)r=Sl(this.field);else{const n=pd(this);if(n.length>0){let i=-1/0,a=-1/0;for(const s of n)s.right>i&&(i=s.right),s.topn.bottom&&(a=i-n.bottom+this.host.scrollTop+r.height),this.host.scroll({top:a,left:0})}if(r){const n=r.x-window.scrollX;let i=this.field.scrollLeft;nt.right&&(i=n-t.right+this.field.scrollLeft+20),this.field.scroll({top:this.field.scrollTop,left:i})}}insert(e,t){return typeof e!="string"||e.length===0&&((t==null?void 0:t.insertionMode)==="insertBefore"||(t==null?void 0:t.insertionMode)==="insertAfter")||e.length===0&&this.model.selectionIsCollapsed?!1:(this.flushInlineShortcutBuffer(),t=t!=null?t:{mode:"math"},t.focus&&this.focus(),t.feedback&&(window.MathfieldElement.keypressVibration&>()&&navigator.vibrate(Jf),window.MathfieldElement.playSound("keypress")),e==="\\\\"?ah(this.model):e==="&"?oh(this.model):this.model.selectionIsCollapsed?Qr.insert(this.model,e,S({style:this.model.at(this.model.position).computedStyle},t)):Qr.insert(this.model,e,t),this.snapshot(`insert-${this.model.at(this.model.position).type}`),xn(this),t.scrollIntoView&&this.scrollIntoView(),!0)}switchMode(e,t="",r=""){var n;if(this.model.mode===e||!this.hasEditableContent||!this.contentEditable||this.disabled)return;const i=this.model.mode;if(this.model.mode=e,!((n=this.host)!=null&&n.dispatchEvent(new Event("mode-change",{bubbles:!0,composed:!0,cancelable:!0})))){this.model.mode=i;return}const a=this.model.mode,{model:s}=this;s.deferNotifications({content:!!r||!!t,selection:!0,type:"insertText"},()=>{let u=!1;if(this.flushInlineShortcutBuffer(),this.stopCoalescingUndo(),t&&e!=="latex"){const d=b(t,{context:this.context,parseMode:e});s.collapseSelection("forward");const h=s.at(s.position);s.position=s.offsetOf(h.parent.addChildrenAfter(d,h)),u=!0}if(this.model.mode=e,e==="latex"){let d=s.selectionIsCollapsed;Nl(this,"accept");let h,p=s.at(s.position);if(d)h="\\";else{const M=Qn(s.selection);h=this.model.getValue(M,"latex");const I=this.model.extractAtoms(M);I.length===1&&I[0].type==="placeholder"&&(h=t,d=!0),p=s.at(M[0])}const y=new vr(h);p.parent.addChildAfter(y,p),d?s.position=s.offsetOf(y.lastChild):s.setSelection(s.offsetOf(y.firstChild),s.offsetOf(y.lastChild))}else Wc(s).forEach(d=>{d.isError=!1});if(r){const d=b(r,{context:this.context,parseMode:a});s.collapseSelection("forward");const h=s.at(s.position);s.position=s.offsetOf(h.parent.addChildrenAfter(d,h)),u=!0}return xn(this),this.undoManager.snapshot(e==="latex"?"insert-latex":"insert"),u}),this.model.mode=e,window.mathVirtualKeyboard.update(ao(this))}hasFocus(){return!this.blurred}focus(e){var t;this.hasFocus()||(this.keyboardDelegate.focus(),this.connectToVirtualKeyboard(),this.onFocus(),this.model.announce("line")),(t=e==null?void 0:e.preventScroll)!=null&&t||this.scrollIntoView()}blur(){this.disconnectFromVirtualKeyboard(),this.hasFocus()&&this.keyboardDelegate.blur()}select(){this.model.selection={ranges:[[0,this.model.lastOffset]]},this.focus()}applyStyle(e,t={}){var r,n;const i={operation:"set",silenceNotifications:!1};Lo(t)?i.range=t:(t.operation==="toggle"&&(i.operation="toggle"),i.range=t.range,i.silenceNotifications=(r=t.silenceNotifications)!=null?r:!1);const a=bf(this,e),s=(n=i.operation)!=null?n:"set";if(i.range===void 0&&this.model.selectionIsCollapsed){if(s==="set"){this.defaultStyle=S(S({},this.defaultStyle),a);return}const u=S({},this.defaultStyle);for(const d of Object.keys(a))u[d]===a[d]?(d==="color"&&delete u.verbatimColor,d==="backgroundColor"&&delete u.verbatimBackgroundColor,delete u[d]):u[d]=a[d];this.defaultStyle=u;return}this.model.deferNotifications({content:!i.silenceNotifications,type:"insertText"},()=>{if(i.range===void 0)for(const u of this.model.selection.ranges)uf(this.model,u,a,{operation:s});else uf(this.model,i.range,a,{operation:s})}),xn(this)}toggleContextMenu(){var e;return this._menu.visible?this._menu.state==="open"?(this._menu.hide(),!0):(this._menu.show({target:this.element.querySelector("[part=container]"),location:(e=this.getCaretPoint())!=null?e:void 0,onDismiss:()=>{var t;return(t=this.element)==null?void 0:t.focus()}}),!0):!1}getCaretPoint(){const e=Sl(this.field);return e?{x:e.x,y:e.y}:null}setCaretPoint(e,t){const r=Jc(this,e,t,{bias:0});if(r<0)return!1;const n=this.model.position;return this.model.position=r,this.model.announce("move",n),xn(this),!0}getPrompt(e){const t=this.model.findAtom(r=>r.type==="prompt"&&r.placeholderId===e);return console.assert(t!==void 0,"MathLive 0.98.5: no prompts with matching ID found"),t}getPromptValue(e,t){const r=this.getPrompt(e);if(!r)return"";const n=this.model.offsetOf(r.firstChild),i=this.model.offsetOf(r.lastChild);return this.model.getValue(n,i,t)}getPrompts(e){return this.model.getAllAtoms().filter(t=>t.type!=="prompt"?!1:e?!(e.id&&t.placeholderId!==e.id||e.locked&&t.locked!==e.locked||e.correctness==="undefined"&&t.correctness||e.correctness&&t.correctness!==e.correctness):!0).map(t=>t.placeholderId)}setPromptValue(e,t,r){if(t!==void 0){const n=this.getPrompt(e);if(!n){console.error(`MathLive 0.98.5: unknown prompt ${e}`);return}const i=this.model.getBranchRange(this.model.offsetOf(n),"body");this.model.setSelection(i),this.insert(t,_(S({},r),{insertionMode:"replaceSelection"}))}r!=null&&r.silenceNotifications&&(this.valueOnFocus=this.getValue()),xn(this)}setPromptState(e,t,r){const n=this.getPrompt(e);if(!n){console.error(`MathLive 0.98.5: unknown prompt ${e}`);return}t==="undefined"?n.correctness=void 0:typeof t=="string"&&(n.correctness=t),typeof r=="boolean"&&(n.locked=r,n.captureSelection=r),xn(this)}getPromptState(e){const t=this.getPrompt(e);return t?[t.correctness,t.locked]:(console.error(`MathLive 0.98.5: unknown prompt ${e}`),[void 0,!0])}getPromptRange(e){const t=this.getPrompt(e);return t?this.model.getBranchRange(this.model.offsetOf(t),"body"):(console.error(`MathLive 0.98.5: unknown prompt ${e}`),[0,0])}canUndo(){return this.undoManager.canUndo()}canRedo(){return this.undoManager.canRedo()}popUndoStack(){this.undoManager.pop()}snapshot(e){var t;this.undoManager.snapshot(e)&&(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(ao(this)),(t=this.host)==null||t.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()&&(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(ao(this)),(e=this.host)==null||e.dispatchEvent(new CustomEvent("undo-state-change",{bubbles:!0,composed:!0,detail:{type:"undo"}})))}redo(){var e;this.undoManager.redo()&&(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(ao(this)),(e=this.host)==null||e.dispatchEvent(new CustomEvent("undo-state-change",{bubbles:!0,composed:!0,detail:{type:"undo"}})))}resetUndo(){var e;(e=this.undoManager)==null||e.reset()}onSelectionDidChange(){var e,t;const r=this.model;this.keyboardDelegate.setValue(r.getValue(this.model.selection,"latex-expanded"));{const n=r.at(r.position),i=(e=n.mode)!=null?e:ih(this.options);this.model.mode!==i&&(this.model.mode==="latex"?(Nl(this,"accept",{mode:i}),r.position=r.offsetOf(n)):this.switchMode(i))}(t=this.host)==null||t.dispatchEvent(new Event("selection-change",{bubbles:!0,composed:!0})),window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(ao(this)),n0(this)}onContentWillChange(e){var t,r,n;return(n=(r=this.host)==null?void 0:r.dispatchEvent(new InputEvent("beforeinput",_(S({},e),{data:e.data?e.data:(t=e.inputType)!=null?t:"",cancelable:!0,bubbles:!0,composed:!0}))))!=null?n:!0}onFocus(){this.focusBlurInProgress||!this.blurred||(this.focusBlurInProgress=!0,this.blurred=!1,this.keyboardDelegate.focus(),this.stopCoalescingUndo(),Is(this,{interactive:!0}),this.valueOnFocus=this.model.getValue(),this.hasEditablePrompts&&!this.model.at(this.model.anchor).parentPrompt&&this.executeCommand("moveToNextPlaceholder"),this.focusBlurInProgress=!1)}onBlur(){var e,t,r;if(this.focusBlurInProgress||this.blurred)return;this.focusBlurInProgress=!0,this.stopCoalescingUndo(),this.blurred=!0,this.ariaLiveText.textContent="",Fl(this),this.model.getValue()!==this.valueOnFocus&&((e=this.host)==null||e.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))),this.disconnectFromVirtualKeyboard(),(t=this.host)==null||t.dispatchEvent(new Event("blur",{bubbles:!1,composed:!0})),(r=this.host)==null||r.dispatchEvent(new UIEvent("focusout",{bubbles:!0,composed:!0})),xn(this),this.focusBlurInProgress=!1,_f();const n=new AbortController,i=n.signal;document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&document.addEventListener("visibilitychange",()=>{Bo(this)&&document.visibilityState==="visible"&&this.focus({preventScroll:!0})},{once:!0,signal:i})},{once:!0,signal:i}),setTimeout(()=>n.abort(),100)}onInput(e){mf(this,e)}onKeystroke(e){return gh(this,e)}onCompositionStart(e){this.model.deleteAtoms(Qn(this.model.selection));const t=Sl(this.field);t&&requestAnimationFrame(()=>{Is(this),this.keyboardDelegate.moveTo(t.x,t.y-t.height)})}onCompositionUpdate(e){Rm(this.model,e),xn(this)}onCompositionEnd(e){Om(this.model),mf(this,e,{simulateKeystroke:!0})}onCut(e){if(!this.isSelectionEditable){this.model.announce("plonk");return}this.model.contentWillChange({inputType:"deleteByCut"})&&(this.stopCoalescingUndo(),Qr.onCopy(this,e),so(this.model,Qn(this.model.selection),"deleteByCut"),this.snapshot("cut"),xn(this))}onCopy(e){Qr.onCopy(this,e)}onPaste(e){let t=this.isSelectionEditable;return t&&(t=Qr.onPaste(this.model.at(this.model.position).mode,this,e.clipboardData)),t||this.model.announce("plonk"),e.preventDefault(),e.stopPropagation(),t}onGeometryChange(){this._menu.hide(),Rd(this),n0(this)}onWheel(e){const t=5*e.deltaX;if(!Number.isFinite(t)||t===0)return;const r=this.field;t<0&&r.scrollLeft===0||t>0&&r.offsetWidth+r.scrollLeft>=r.scrollWidth||(r.scrollBy({top:0,left:t}),e.preventDefault(),e.stopPropagation())}getHTMLElement(e){let t=e;for(;!t.id&&t.hasChildren;)t=e.children[0];return this.field.querySelector(`[data-atom-id="${t.id}"]`)}get context(){var e,t;return{registers:(e=this.options.registers)!=null?e:{},smartFence:this.smartFence,letterShapeStyle:this.letterShapeStyle,minFontScale:this.minFontScale,placeholderSymbol:(t=this.options.placeholderSymbol)!=null?t:"\u25A2",colorMap:r=>this.colorMap(r),backgroundColorMap:r=>this.backgroundColorMap(r),getMacro:r=>at(r,this.options.macros),atomIdsSettings:{seed:"random",groupNumbers:!1}}}};function Zh(e){if(e&&(e.classList.remove("ML__highlight"),e.children))for(const t of e.children)Zh(t)}function Nf(e,t){var r;e&&(!t||((r=e.dataset)==null?void 0:r.atomId)===t?(e.classList.add("ML__highlight"),e.children&&e.children.length>0&&[...e.children].forEach(n=>{n instanceof HTMLElement&&Nf(n)})):(e.classList.remove("ML__highlight"),e.children&&e.children.length>0&&[...e.children].forEach(n=>{n instanceof HTMLElement&&Nf(n,t)})))}function wv(e,t){var r;if(!Ke())return;if(window.MathfieldElement.speechEngine!=="amazon"){console.error("MathLive 0.98.5: Use Amazon TTS Engine for synchronized highlighting"),typeof window.MathfieldElement.speakHook=="function"&&window.MathfieldElement.speakHook(t);return}if(!window.AWS){console.error("MathLive 0.98.5: AWS SDK not loaded. See https://www.npmjs.com/package/aws-sdk");return}const n=new window.AWS.Polly({apiVersion:"2016-06-10"}),i={OutputFormat:"json",VoiceId:(r=window.MathfieldElement.speechEngineVoice)!=null?r:"Joanna",Engine:"standard",Text:t,TextType:"ssml",SpeechMarkTypes:["ssml"]};ts().readAloudElement=e,n.synthesizeSpeech(i,(a,s)=>{if(a){console.trace(`MathLive 0.98.5: \`polly.synthesizeSpeech()\` error: ${a}`);return}if(!(s!=null&&s.AudioStream)){console.log("polly.synthesizeSpeech():",s);return}const u=new TextDecoder("utf-8").decode(new Uint8Array(s.AudioStream));ts().readAloudMarks=u.split(`
`).map(d=>d?JSON.parse(d):{}),ts().readAloudTokens=[];for(const d of ts().readAloudMarks)d.value&&ts().readAloudTokens.push(d.value);ts().readAloudCurrentMark="",i.OutputFormat="mp3",i.SpeechMarkTypes=[],n.synthesizeSpeech(i,(d,h)=>{if(d){console.trace(`MathLive 0.98.5: \`polly.synthesizeSpeech("${t}") error:${d}`);return}if(!(h!=null&&h.AudioStream))return;const p=new Uint8Array(h.AudioStream),y=new Blob([p.buffer],{type:"audio/mpeg"}),M=URL.createObjectURL(y),I=ts();I.readAloudAudio?I.readAloudAudio.pause():(I.readAloudAudio=new Audio,I.readAloudAudio.addEventListener("ended",()=>{const $=I.readAloudMathfield;I.readAloudStatus="ended",document.body.dispatchEvent(new Event("read-aloud-status-change",{bubbles:!0,composed:!0})),$?(Is($),I.readAloudElement=null,I.readAloudMathfield=null,I.readAloudTokens=[],I.readAloudMarks=[],I.readAloudCurrentMark=""):Zh(I.readAloudElement)}),I.readAloudAudio.addEventListener("timeupdate",()=>{let $="";const se=I.readAloudAudio.currentTime*1e3+100;for(const Ze of I.readAloudMarks)Ze.time!1:this._isFunction}static set isFunction(t){this._isFunction=t}static loadSound(t){return rs(this,null,function*(){delete this.audioBuffers[t];let r="";switch(t){case"keypress":r=this._keypressSound.default;break;case"return":r=this._keypressSound.return;break;case"spacebar":r=this._keypressSound.spacebar;break;case"delete":r=this._keypressSound.delete;break;case"plonk":r=this.plonkSound;break}if(typeof r!="string")return;r=r.trim();const n=this.soundsDirectory;if(!(n==null||n==="null"||r==="none"||r==="null"))try{const a=yield(yield fetch(yield qf(`${n}/${r}`))).arrayBuffer(),s=yield this.audioContext.decodeAudioData(a);this.audioBuffers[t]=s}catch(i){}})}static playSound(t){return rs(this,null,function*(){if((this.audioContext.state==="suspended"||this.audioContext.state==="interrupted")&&(yield this.audioContext.resume()),this.audioBuffers[t]||(yield this.loadSound(t)),!this.audioBuffers[t])return;const r=this.audioContext.createBufferSource();r.buffer=this.audioBuffers[t];const n=this.audioContext.createGain();n.gain.value=Sv,r.connect(n).connect(this.audioContext.destination),r.start()})}constructor(t){if(super(),t){const r=[];for(const n of Object.keys(t))if(es[n])if(es[n].startsWith("mf."))if(es[n].startsWith(`mf.${n}`))r.push(`Option \`${n}\` cannot be used as a constructor option. Use ${es[n]}`);else{const i=es[n].match(/([a-zA-Z]+) =/);r.push(`Option \`${n}\` has been renamed \`${i[1]}\``)}else r.push(`Option \`${n}\` cannot be used as a constructor option. Use ${es[n]}`);if(r.length>0){console.group("%cMathLive 0.98.5: %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 https://cortexjs.io/mathlive/changelog/ for details.");for(const n of r)console.warn(n);console.groupEnd()}}if(Jl()&&(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=[Ya("core"),Ya("mathfield"),Ya("mathfield-element"),Ya("ui"),Ya("menu")],this.shadowRoot.appendChild(document.createElement("span"));const r=document.createElement("slot");r.style.display="none",this.shadowRoot.appendChild(r)}else this.shadowRoot.innerHTML="';t&&this._setOptions(t),this.shadowRoot.addEventListener("slotchange",()=>{var r;const n=this.shadowRoot.querySelector("slot:not([name])");this.value=(r=n==null?void 0:n.assignedNodes().map(i=>i.nodeType===3?i.textContent:"").join("").trim())!=null?r:""})}showMenu(t){var r,n;return(n=(r=this._mathfield)==null?void 0:r.showMenu(t))!=null?n:!1}get mathVirtualKeyboard(){throw new Error("The `mathVirtualKeyboard` property is not available on the MathfieldElement. Use `window.mathVirtualKeyboard` instead.")}onPointerDown(){window.addEventListener("pointerup",t=>{var r;t.target===this&&!((r=this._mathfield)!=null&&r.disabled)&&this.dispatchEvent(new MouseEvent("click",{altKey:t.altKey,button:t.button,buttons:t.buttons,clientX:t.clientX,clientY:t.clientY,ctrlKey:t.ctrlKey,metaKey:t.metaKey,movementX:t.movementX,movementY:t.movementY,relatedTarget:t.relatedTarget,screenX:t.screenX,screenY:t.screenY,shiftKey:t.shiftKey}))},{once:!0})}getPromptValue(t,r){var n,i;return(i=(n=this._mathfield)==null?void 0:n.getPromptValue(t,r))!=null?i:""}setPromptValue(t,r,n){var i;(i=this._mathfield)==null||i.setPromptValue(t,r,n)}getPromptRange(t){var r,n;return(n=(r=this._mathfield)==null?void 0:r.getPromptRange(t))!=null?n:null}getPrompts(t){var r,n;return(n=(r=this._mathfield)==null?void 0:r.getPrompts(t))!=null?n:[]}get form(){var t;return(t=this._internals)==null?void 0:t.form}get name(){var t;return(t=this.getAttribute("name"))!=null?t:""}get type(){return this.localName}get mode(){var t,r;return(r=(t=this._mathfield)==null?void 0:t.model.mode)!=null?r:this.defaultMode==="text"?"text":"math"}set mode(t){var r;(r=this._mathfield)==null||r.switchMode(t)}get expression(){if(this._mathfield)return window[Symbol.for("io.cortexjs.compute-engine")]?this._mathfield.expression:(console.error(`MathLive 0.98.5: The CortexJS Compute Engine library is not available.
Load the library, for example with:
import "https://unpkg.com/@cortex-js/compute-engine?module"`),null)}set expression(t){var r,n;if(!this._mathfield)return;const i=(n=(r=Hs.computeEngine)==null?void 0:r.box(t).latex)!=null?n:null;i!==null&&this._mathfield.setValue(i),window[Symbol.for("io.cortexjs.compute-engine")]||console.error(`MathLive 0.98.5: The CortexJS Compute Engine library is not available.
Load the library, for example with:
import "https://unpkg.com/@cortex-js/compute-engine?module"`)}get errors(){var t,r;return(r=(t=this._mathfield)==null?void 0:t.errors)!=null?r:[]}_getOptions(t){return this._mathfield?Ts(this._mathfield.options,t):Rr.has(this)?S({},Ts(S(S({},Zd()),Vd(Rr.get(this).options)),t)):null}getOptions(t){return console.warn("%cMathLive 0.98.5: %cDeprecated Usage%c\n `mf.getOptions()` is deprecated. Read the property directly on the mathfield instead.\n See https://cortexjs.io/mathlive/changelog/ for details.","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem","color: inherit, font-size: 1rem"),this._mathfield?Ts(this._mathfield.options,t):Rr.has(this)?Ts(S(S({},Zd()),Vd(Rr.get(this).options)),t):null}reflectAttributes(){const t=Zd(),r=this._getOptions();Object.keys(Hs.optionsAttributes).forEach(n=>{const i=Ro(n);Hs.optionsAttributes[n]==="on/off"?t[i]!==r[i]?this.setAttribute(n,r[i]?"on":"off"):this.removeAttribute(n):t[i]!==r[i]&&(Hs.optionsAttributes[n]==="boolean"?r[i]?this.setAttribute(n,""):this.removeAttribute(n):(typeof r[i]=="string"||typeof r[i]=="number")&&this.setAttribute(n,r[i].toString()))})}getOption(t){return console.warn("%cMathLive 0.98.5: %cDeprecated Usage%c\n `mf.getOption()` is deprecated. Read the property directly on the mathfield instead.\n See https://cortexjs.io/mathlive/changelog/ for details.","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem","color: inherit, font-size: 1rem"),this._getOptions([t])[t]}_getOption(t){return this._getOptions([t])[t]}_setOptions(t){if(this._mathfield)this._mathfield.setOptions(t);else if(Rr.has(this)){const r=S(S({},Rr.get(this).options),t);Rr.set(this,_(S({},Rr.get(this)),{selection:{ranges:r.readOnly?[[0,0]]:[[0,-1]]},options:r}))}else Rr.set(this,{value:void 0,selection:{ranges:[[0,0]]},options:t,menuItems:void 0});this.reflectAttributes()}setOptions(t){console.group("%cMathLive 0.98.5: %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 https://cortexjs.io/mathlive/changelog/ for details.");for(const r of Object.keys(t))es[r]&&console.warn(`\`mf.setOptions({${r}:...})\` -> ${es[r]}`);console.groupEnd(),this._setOptions(t)}executeCommand(t){var r,n;return(n=(r=this._mathfield)==null?void 0:r.executeCommand(t))!=null?n:!1}getValue(t,r,n){var i,a;if(this._mathfield)return this._mathfield.model.getValue(t,r,n);if(Rr.has(this)){let s,u,d;if(Cs(t)?([s,u]=t.ranges[0],d=r):Lo(t)?([s,u]=t,d=r):Ga(t)&&Ga(r)?(s=t,u=r,d=n):(s=0,u=-1,d=t),(d===void 0||d==="latex")&&s===0&&u===-1)return(a=(i=Rr.get(this).value)!=null?i:this.textContent)!=null?a:""}return""}setValue(t,r){if(this._mathfield&&t!==void 0){r!=null||(r={silenceNotifications:!0,mode:"math"}),this._mathfield.setValue(t,r);return}if(Rr.has(this)){const i=Rr.get(this).options;Rr.set(this,{value:t,selection:{ranges:[[-1,-1]],direction:"forward"},options:i,menuItems:void 0});return}const n=iu(this);Rr.set(this,{value:t,selection:{ranges:[[-1,-1]],direction:"forward"},options:n,menuItems:void 0})}hasFocus(){var t,r;return(r=(t=this._mathfield)==null?void 0:t.hasFocus())!=null?r:!1}focus(){var t;(t=this._mathfield)==null||t.focus()}blur(){var t;(t=this._mathfield)==null||t.blur()}select(){var t;(t=this._mathfield)==null||t.select()}insert(t,r){var n,i;return(i=(n=this._mathfield)==null?void 0:n.insert(t,r))!=null?i:!1}applyStyle(t,r){var n;return(n=this._mathfield)==null?void 0:n.applyStyle(t,r)}queryStyle(t){var r,n;return(n=(r=this._mathfield)==null?void 0:r.queryStyle(t))!=null?n:"none"}get caretPoint(){var t,r;return(r=(t=this._mathfield)==null?void 0:t.getCaretPoint())!=null?r:null}set caretPoint(t){var r;t&&((r=this._mathfield)==null||r.setCaretPoint(t.x,t.y))}setCaretPoint(t,r){var n,i;return(i=(n=this._mathfield)==null?void 0:n.setCaretPoint(t,r))!=null?i:!1}offsetFromPoint(t,r,n){return this._mathfield?Jc(this._mathfield,t,r,n):-1}hitboxFromOffset(t){if(!this._mathfield)return null;const r=this._mathfield.model.at(t);if(!r)return null;const n=Es(this._mathfield,r);return n?new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top):null}resetUndo(){var t;(t=this._mathfield)==null||t.resetUndo()}canUndo(){return this._mathfield?this._mathfield.canUndo():!1}canRedo(){return this._mathfield?this._mathfield.canRedo():!1}handleEvent(t){var r,n,i,a;ro.state==="closed"&&((n=(r=this._mathfield)==null?void 0:r.menu)==null?void 0:n.state)==="closed"&&(t.type==="pointerdown"&&this.onPointerDown(),t.type==="focus"&&((i=this._mathfield)==null||i.focus()),t.type==="blur"&&((a=this._mathfield)==null||a.blur()))}connectedCallback(){var t,r,n,i;const a=window.getComputedStyle(this),s=this.shadowRoot,u=a.userSelect!=="none";if(u)s.host.addEventListener("pointerdown",this,!0);else{const p=s.querySelector("span");p.style.pointerEvents="none"}s.host.addEventListener("focus",this,!0),s.host.addEventListener("blur",this,!0),Jl()||(this.hasAttribute("role")||this.setAttribute("role","math"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","math input field"),this.setAttribute("aria-multiline","false")),u&&!this.hasAttribute("contenteditable")&&this.setAttribute("contenteditable","true"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0");const d=s.querySelector("slot:not([name])");if(d)try{this._style=d.assignedElements().filter(p=>p.tagName.toLowerCase()==="style").map(p=>p.textContent).join("")}catch(p){console.error(p)}if(this._style){const p=document.createElement("style");p.textContent=this._style,s.appendChild(p)}let h="";if(this.hasAttribute("value")?h=this.getAttribute("value"):h=(t=d==null?void 0:d.assignedNodes().map(p=>p.nodeType===3?p.textContent:"").join("").trim())!=null?t:"",this._mathfield=new xv(s.querySelector(":host > span"),_(S({},(n=(r=Rr.get(this))==null?void 0:r.options)!=null?n:iu(this)),{eventSink:this,value:h})),!Rr.has(this)){this.upgradeProperty("disabled"),this.upgradeProperty("readonly");for(const p of Object.keys(Hs.optionsAttributes))this.upgradeProperty(Ro(p))}if(!((i=this._mathfield)!=null&&i.model)){this._mathfield=null;return}if(Rr.has(this)){const p=this._mathfield,y=Rr.get(this),M=y.menuItems;p.model.deferNotifications({content:!1,selection:!1},()=>{const I=y.value;I!==void 0&&p.setValue(I),p.model.selection=y.selection,Rr.delete(this)}),M&&(this.menuItems=M)}window.queueMicrotask(()=>{this.isConnected&&this.dispatchEvent(new Event("mount",{cancelable:!1,bubbles:!0,composed:!0}))}),Nd()}disconnectedCallback(){var t,r;if(this.shadowRoot.host.removeEventListener("pointerdown",this,!0),!this._mathfield)return;window.queueMicrotask(()=>this.dispatchEvent(new Event("unmount",{cancelable:!1,bubbles:!0,composed:!0})));const n=Ts(this._mathfield.options,Object.keys(Hs.optionsAttributes).map(i=>Ro(i)));Rr.set(this,{value:this._mathfield.getValue(),selection:this._mathfield.model.selection,menuItems:(r=(t=this._mathfield.menu)==null?void 0:t.menuItems)!=null?r:void 0,options:n}),this._mathfield.dispose(),this._mathfield=null}upgradeProperty(t){if(this.hasOwnProperty(t)){const r=this[t];delete this[t],(t==="readonly"||t==="read-only")&&(t="readOnly"),this[t]=r}}attributeChangedCallback(t,r,n){if(r===n)return;const i=n!==null;switch(t){case"contenteditable":xn(this._mathfield);break;case"disabled":this.disabled=i;break;case"read-only":case"readonly":this.readOnly=i;break;default:}}get readonly(){return this.hasAttribute("readonly")||this.hasAttribute("read-only")}set readonly(t){const r=!!t;r?(this.setAttribute("readonly",""),Jl()?this._internals.ariaReadOnly="true":this.setAttribute("aria-readonly","true"),this.setAttribute("aria-readonly","true")):(Jl()?this._internals.ariaReadOnly="false":this.removeAttribute("aria-readonly"),this.removeAttribute("readonly"),this.removeAttribute("read-only")),this._setOptions({readOnly:r})}get disabled(){return this.hasAttribute("disabled")}set disabled(t){var r;const n=!!t;n?this.setAttribute("disabled",""):this.removeAttribute("disabled"),Jl()?this._internals.ariaDisabled=n?"true":"false":this.setAttribute("aria-disabled",n?"true":"false"),n&&((r=this._mathfield)!=null&&r.hasFocus)&&window.mathVirtualKeyboard.visible&&this._mathfield.executeCommand("hideVirtualKeyboard")}get value(){return this.getValue()}set value(t){this.setValue(t)}get defaultMode(){return this._getOption("defaultMode")}set defaultMode(t){this._setOptions({defaultMode:t})}get macros(){return this._getOption("macros")}set macros(t){this._setOptions({macros:t})}get registers(){const t=this;return new Proxy({},{get:(r,n)=>{if(typeof n=="string")return t._getOption("registers")[n]},set(r,n,i){return typeof n!="string"?!1:(t._setOptions({registers:_(S({},t._getOption("registers")),{[n]:i})}),!0)}})}set registers(t){this._setOptions({registers:t})}get colorMap(){return this._getOption("colorMap")}set colorMap(t){this._setOptions({colorMap:t})}get backgroundColorMap(){return this._getOption("backgroundColorMap")}set backgroundColorMap(t){this._setOptions({backgroundColorMap:t})}get letterShapeStyle(){return this._getOption("letterShapeStyle")}set letterShapeStyle(t){this._setOptions({letterShapeStyle:t})}get minFontScale(){return this._getOption("minFontScale")}set minFontScale(t){this._setOptions({minFontScale:t})}get smartMode(){return this._getOption("smartMode")}set smartMode(t){this._setOptions({smartMode:t})}get smartFence(){return this._getOption("smartFence")}set smartFence(t){this._setOptions({smartFence:t})}get smartSuperscript(){return this._getOption("smartSuperscript")}set smartSuperscript(t){this._setOptions({smartSuperscript:t})}get scriptDepth(){return this._getOption("scriptDepth")}set scriptDepth(t){this._setOptions({scriptDepth:t})}get removeExtraneousParentheses(){return this._getOption("removeExtraneousParentheses")}set removeExtraneousParentheses(t){this._setOptions({removeExtraneousParentheses:t})}get mathModeSpace(){return this._getOption("mathModeSpace")}set mathModeSpace(t){this._setOptions({mathModeSpace:t})}get placeholderSymbol(){return this._getOption("placeholderSymbol")}set placeholderSymbol(t){this._setOptions({placeholderSymbol:t})}get popoverPolicy(){return this._getOption("popoverPolicy")}set popoverPolicy(t){this._setOptions({popoverPolicy:t})}get environmentPopoverPolicy(){return this._getOption("environmentPopoverPolicy")}set environmentPopoverPolicy(t){this._setOptions({environmentPopoverPolicy:t})}get menuItems(){var t,r,n;return this._mathfield?(t=this._mathfield.menu._menuItems.map(i=>i.menuItem))!=null?t:[]:(n=(r=Rr.get(this))==null?void 0:r.menuItems)!=null?n:[]}set menuItems(t){var r;if(this._mathfield){const n=(r=this._mathfield.element)==null?void 0:r.querySelector("[part=menu-toggle]");n&&(n.style.display=t.length===0?"none":""),this._mathfield.menu.menuItems=t}Rr.has(this)?Rr.set(this,_(S({},Rr.get(this)),{menuItems:t})):Rr.set(this,{value:void 0,selection:{ranges:[[0,0]]},options:iu(this),menuItems:t})}get mathVirtualKeyboardPolicy(){return this._getOption("mathVirtualKeyboardPolicy")}set mathVirtualKeyboardPolicy(t){this._setOptions({mathVirtualKeyboardPolicy:t})}get inlineShortcuts(){return this._getOption("inlineShortcuts")}set inlineShortcuts(t){this._setOptions({inlineShortcuts:t})}get inlineShortcutTimeout(){return this._getOption("inlineShortcutTimeout")}set inlineShortcutTimeout(t){this._setOptions({inlineShortcutTimeout:t})}get keybindings(){return this._getOption("keybindings")}set keybindings(t){this._setOptions({keybindings:t})}get onInlineShortcut(){return this._getOption("onInlineShortcut")}set onInlineShortcut(t){this._setOptions({onInlineShortcut:t})}get onScrollIntoView(){return this._getOption("onScrollIntoView")}set onScrollIntoView(t){this._setOptions({onScrollIntoView:t})}get onExport(){return this._getOption("onExport")}set onExport(t){this._setOptions({onExport:t})}get readOnly(){return this._getOption("readOnly")}set readOnly(t){this._setOptions({readOnly:t})}get isSelectionEditable(){var t,r;return(r=(t=this._mathfield)==null?void 0:t.isSelectionEditable)!=null?r:!1}setPromptState(t,r,n){var i;(i=this._mathfield)==null||i.setPromptState(t,r,n)}getPromptState(t){var r,n;return(n=(r=this._mathfield)==null?void 0:r.getPromptState(t))!=null?n:[void 0,!0]}get virtualKeyboardTargetOrigin(){return this._getOption("virtualKeyboardTargetOrigin")}set virtualKeyboardTargetOrigin(t){this._setOptions({virtualKeyboardTargetOrigin:t})}get selection(){return this._mathfield?this._mathfield.model.selection:Rr.has(this)?Rr.get(this).selection:{ranges:[[0,0]],direction:"forward"}}set selection(t){if(typeof t=="number"&&(t={ranges:[[t,t]]}),this._mathfield){this._mathfield.model.selection=t,xn(this._mathfield);return}if(Rr.has(this)){Rr.set(this,_(S({},Rr.get(this)),{selection:t}));return}Rr.set(this,{value:void 0,selection:t,options:iu(this),menuItems:void 0})}get selectionIsCollapsed(){const t=this.selection;return t.ranges.length===1&&t.ranges[0][0]===t.ranges[0][1]}get position(){return this._mathfield?this._mathfield.model.position:Rr.has(this)?Rr.get(this).selection.ranges[0][0]:0}set position(t){if(this._mathfield&&(this._mathfield.model.position=t,xn(this._mathfield)),Rr.has(this)){Rr.set(this,_(S({},Rr.get(this)),{selection:{ranges:[[t,t]]}}));return}Rr.set(this,{value:void 0,selection:{ranges:[[t,t]]},options:iu(this),menuItems:void 0})}getOffsetDepth(t){var r,n;return this._mathfield?((n=(r=this._mathfield.model.at(t))==null?void 0:r.treeDepth)!=null?n:2)-2:0}get lastOffset(){var t,r;return(r=(t=this._mathfield)==null?void 0:t.model.lastOffset)!=null?r:-1}};ti.version="0.98.5",ti._fontsDirectory="./fonts",ti._soundsDirectory="./sounds",ti.keypressVibration=!0,ti._keypressSound={spacebar:"keypress-spacebar.wav",return:"keypress-return.wav",delete:"keypress-delete.wav",default:"keypress-standard.wav"},ti._plonkSound="plonk.wav",ti.audioBuffers={},ti.createHTML=e=>e,ti._speechEngineRate="100%",ti._speechEngineVoice="Joanna",ti._textToSpeechMarkup="",ti._textToSpeechRules="mathlive",ti._textToSpeechRulesOptions={},ti.speakHook=dv,ti.readAloudHook=wv,ti._decimalSeparator=".",ti.fractionNavigationOrder="numerator-denominator",ti._isFunction=e=>{var t,r;const n=window.MathfieldElement.computeEngine;return(r=(t=n==null?void 0:n.parse(e).domain)==null?void 0:t.isFunction)!=null?r:!1};var nu=ti;function Ro(e){return e.replace(/[^a-zA-Z\d]+(.)/g,(t,r)=>r.toUpperCase())}function iu(e){const t={readOnly:!1},r=nu.optionsAttributes;return Object.keys(r).forEach(n=>{if(e.hasAttribute(n)){const i=e.getAttribute(n);n==="placeholder"?t.contentPlaceholder=i!=null?i:"":r[n]==="boolean"?t[Ro(n)]=!0:r[n]==="on/off"?i==="on"?t[Ro(n)]=!0:i==="off"?t[Ro(n)]=!1:t[Ro(n)]=void 0:r[n]==="number"?t[Ro(n)]=Number.parseFloat(i!=null?i:"0"):t[Ro(n)]=i}}),t}function Jl(){return!(!("ElementInternals"in window)||!HTMLElement.prototype.attachInternals||!("role"in window.ElementInternals.prototype))}var jh=nu,Uh,Gh,qh,Xh;if(Ke()&&!((Uh=window.customElements)!=null&&Uh.get("math-field"))){(qh=window[Gh=Symbol.for("io.cortexjs.mathlive")])!=null||(window[Gh]={});const e=window[Symbol.for("io.cortexjs.mathlive")];e.version="0.98.5",window.MathfieldElement=nu,(Xh=window.customElements)==null||Xh.define("math-field",nu)}function _v(e,t,r){let n=r,i=0;const a=e.length;for(;n0&&a.push({type:"text",data:u.slice(0,h)}),d=!1);let y=!1;for(;!y;){if(d){if(p=u.indexOf(t,h),p===-1){y=!0;break}h!==p&&a.push({type:"text",data:u.slice(h,p)}),h=p}else{if(p=_v(r,u,h+t.length),p===-1){y=!0;break}let M=u.slice(h+t.length,p);i==="ascii-math"&&([,M]=qa(M,{format:"ascii-math"})),a.push({type:"math",data:M,rawData:u.slice(h,p+r.length),mathstyle:n}),h=p+r.length}d=!d}h{n=l0(n,i,a,"textstyle")}),t!=null&&t.display&&t.display.forEach(([i,a])=>{n=l0(n,i,a,"displaystyle")}),r!=null&&r.inline&&r.inline.forEach(([i,a])=>{n=l0(n,i,a,"textstyle","ascii-math")}),r!=null&&r.display&&r.display.forEach(([i,a])=>{n=l0(n,i,a,"displaystyle","ascii-math")}),n}function Mv(e,t){const r=document.createElement("span");r.setAttribute("translate","no");try{const n="";r.innerHTML=window.MathfieldElement.createHTML(n)}catch(n){console.error(`MathLive 0.98.5: Could not convert "${e}"' to MathML with ${n}`),r.textContent=e}return r.className="ML__sr-only",r}function Cv(e,t,r,n){try{const i=t.renderToMarkup(e,{mathstyle:r,format:"html"}),a=document.createElement("span");return a.dataset.latex=e,a.style.display=r==="displaystyle"?"flex":"inline-flex",a.setAttribute("aria-hidden","true"),a.setAttribute("translate","no"),a.innerHTML=window.MathfieldElement.createHTML(i),a}catch(i){if(console.error("Could not parse'"+e+"' with ",i),n)return document.createTextNode(e)}return null}function Yl(e,t,r,n){var i;const a=Cv(e,r,t||"textstyle",n),s=(i=r.renderAccessibleContent)!=null?i:"";if(a&&/\b(mathml|speakable-text)\b/i.test(s)){const u=document.createElement("span");if(/\bmathml\b/i.test(s)&&r.renderToMathML&&u.append(Mv(e,r)),/\bspeakable-text\b/i.test(s)&&r.renderToSpeakableText){const d=document.createElement("span");d.setAttribute("translate","no");const h=r.renderToSpeakableText(e);d.innerHTML=window.MathfieldElement.createHTML(h),d.className="ML__sr-only",u.append(d)}return u.append(a),u}return a}function Ev(e,t){var r,n,i;let a=null;if((r=t.TeX)!=null&&r.processEnvironments&&/^\s*\\begin/.test(e)){a=document.createDocumentFragment();const s=Yl(e,"",t,!0);s&&a.appendChild(s)}else{if(!e.trim())return null;const s=Jh(e,(n=t.TeX)==null?void 0:n.delimiters,(i=t.asciiMath)==null?void 0:i.delimiters);if(s.length===1&&s[0].type==="text")return null;a=document.createDocumentFragment();for(const u of s)if(u.type==="text")a.appendChild(document.createTextNode(u.data));else{const d=Yl(u.data,u.mathstyle==="textstyle"?"textstyle":"displaystyle",t,!0);d&&a.appendChild(d)}}return a}function Yh(e,t){var r,n,i,a,s,u,d,h,p,y,M,I,$,se,Ze,ee;if(e.childNodes.length===1&&e.childNodes[0].nodeType===3){const De=(r=e.childNodes[0].textContent)!=null?r:"";if((n=t.TeX)!=null&&n.processEnvironments&&/^\s*\\begin/.test(De)){e.textContent="";const Te=Yl(De,"",t,!0);Te&&e.append(Te);return}const Je=Jh(De,(i=t.TeX)==null?void 0:i.delimiters,(a=t.asciiMath)==null?void 0:a.delimiters);if(Je.length===1&&Je[0].type==="math"){e.textContent="";const Te=Yl(Je[0].data,Je[0].mathstyle==="textstyle"?"textstyle":"displaystyle",t,!0);Te&&e.append(Te);return}if(Je.length===1&&Je[0].type==="text")return}for(let De=e.childNodes.length-1;De>=0;De--){const Je=e.childNodes[De];if(Je.nodeType===3){const Te=Ev((s=Je.textContent)!=null?s:"",t);Te&&(De+=Te.childNodes.length-1,Je.replaceWith(Te))}else if(Je.nodeType===1){const Te=Je,yt=Je.nodeName.toLowerCase();if(yt==="script"){const Rt=Je;let Dt;if((u=t.processScriptTypePattern)!=null&&u.test(Rt.type))Dt=(d=Rt.textContent)!=null?d:"";else if((h=t.processMathJSONScriptTypePattern)!=null&&h.test(Rt.type))try{Dt=(y=t.serializeToLatex)==null?void 0:y.call(t,JSON.parse((p=Rt.textContent)!=null?p:""))}catch(Ar){console.error(Ar)}if(Dt){let Ar="textstyle";for(const nt of Rt.type.split(";")){const[na,lo]=nt.toLowerCase().split("=");na.trim()==="mode"&&(Ar=lo.trim()==="display"?"displaystyle":"textstyle")}const Xr=Yl(Dt,Ar,t,!0);Xr&&Rt.parentNode.replaceChild(Xr,Rt)}}else if(((I=(M=t.processClassPattern)==null?void 0:M.test(Te.className))!=null?I:!1)||!((se=($=t.skipTags)==null?void 0:$.includes(yt))!=null&&se||(ee=(Ze=t.ignoreClassPattern)==null?void 0:Ze.test(Te.className))!=null&&ee))if(e.childNodes.length===1&&e.childNodes[0].nodeType===3){const Dt=e.textContent;e.textContent="";const Ar=Yl(Dt!=null?Dt:"","displaystyle",t,!0);Ar&&e.append(Ar)}else Yh(Te,t)}}}var kv={skipTags:["math-field","noscript","style","textarea","pre","code","annotation","annotation-xml"],processScriptType:"math/tex",processMathJSONScriptType:"math/json",ignoreClass:"tex2jax_ignore",processClass:"tex2jax_process",renderAccessibleContent:"mathml",asciiMath:{delimiters:{inline:[["`","`"]]}},TeX:{processEnvironments:!0,delimiters:{inline:[["\\(","\\)"]],display:[["$$","$$"],["\\[","\\]"]]}}};function Dv(e,t){var r,n,i,a;try{const s=S(S({},kv),t);s.ignoreClassPattern=new RegExp((r=s.ignoreClass)!=null?r:""),s.processClassPattern=new RegExp((n=s.processClass)!=null?n:""),s.processScriptTypePattern=new RegExp((i=s.processScriptType)!=null?i:""),s.processMathJSONScriptTypePattern=new RegExp((a=s.processMathJSONScriptType)!=null?a:""),Nd(),Yi("core"),Yh(e,s)}catch(s){s instanceof Error?console.error("renderMathInElement(): "+s.message):console.error("renderMathInElement(): Could not render math for element",e)}}function Av(e,t){const r=Yo.singleton;return r?(r.show(),jc(),r.currentLayer=t,r.render(),r.focus(),!0):!1}function Lv(){const e=window.mathVirtualKeyboard;return e.visible?e.hide({animate:!0}):e.show({animate:!0}),!1}Vi({switchKeyboardLayer:Av,toggleVirtualKeyboard:Lv,hideVirtualKeyboard:()=>(window.mathVirtualKeyboard.hide({animate:!0}),!1),showVirtualKeyboard:()=>(window.mathVirtualKeyboard.show({animate:!0}),!1)},{target:"virtual-keyboard"});function ts(){var e,t;return(t=globalThis[e=Symbol.for("io.cortexjs.mathlive")])!=null||(globalThis[e]={}),globalThis[Symbol.for("io.cortexjs.mathlive")]}function Rv(){return console.warn("%cMathLive 0.98.5: %cmakeSharedVirtualKeyboard() is deprecated. \n Use `window.mathVirtualKeyboard` to access the virtual keyboard instance.\n See https://cortexjs.io/mathlive/changelog/ for details.","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem"),window.mathVirtualKeyboard}function Ov(e){Iv(document.body,e)}function Bv(e){if(typeof e=="string"){const t=document.getElementById(e);if(t===null)throw new Error(`The element with ID "${e}" could not be found.`);return t}return typeof e=="string"?null:e}function Iv(e,t){var r,n,i,a;const s=Bv(e);if(!s)return;const u=t!=null?t:{};(r=u.renderToMarkup)!=null||(u.renderToMarkup=Un),(n=u.renderToMathML)!=null||(u.renderToMathML=Vg),(i=u.renderToSpeakableText)!=null||(u.renderToSpeakableText=Zg),(a=u.serializeToLatex)!=null||(u.serializeToLatex=jg),Dv(s,u)}var Nv={mathlive:"0.98.5"}}}]);
}());